online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
import Duck main = do let mallard = makeDuck (print "(normal flying)") (print "quack") (print "I'm a mallard duck") fly mallard -- prints "(normal flying)" quack mallard -- prints "quack" display mallard -- prints "I'm a mallard duck" let mallard' = setFly (print "they cut my limbs!") mallard fly mallard' -- prints "they cut my limbs!" return ()
module Duck (makeDuck, fly, quack, display, setFly, setQuack) where data Duck = Duck { fly :: IO (), quack :: IO (), display :: IO () } -- Duck, the ctor is not expeorted, otherwise client code could -- pattern match on a Duck internals; instead, we expose a make -- function equivalent to it makeDuck :: IO () -> IO () -> IO () -> Duck makeDuck = Duck setFly f' (Duck f q d) = Duck f' q d setQuack f' (Duck f q d) = Duck f' q d -- but not setDisplay

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue