Idris2/tests/idris2/reg006/Cmd.idr
Edwin Brady a972778eab Add test script
They don't all pass yet, for minor reasons. Coming shortly...
Unfortunately the startup overhead for chez is really noticeable here!
2020-05-19 18:25:18 +01:00

21 lines
525 B
Idris

data MyCmd : Type -> Type where
Display : String -> MyCmd ()
Input : MyCmd String
Pure : ty -> MyCmd ty
(>>=) : MyCmd a -> (a -> MyCmd b) -> MyCmd b
runMyCmd : MyCmd a -> IO a
runMyCmd (Display str) = putStrLn str
runMyCmd Input = do str <- getLine
pure str
runMyCmd (Pure x) = pure x
runMyCmd (c >>= f) = do res <- runMyCmd c
runMyCmd (f res)
myCmdTest : MyCmd ()
myCmdTest = do Display "Hello"
x <- Input
Display x
Pure ()