mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-11-27 13:40:15 +03:00
32 lines
801 B
Idris
32 lines
801 B
Idris
module Main
|
|
|
|
import Data.String.Parser
|
|
import Control.Monad.Identity
|
|
import Control.Monad.Trans
|
|
|
|
%default partial
|
|
-- Buld this program with '-p contrib'
|
|
|
|
parseStuff : ParseT IO ()
|
|
parseStuff = do a <- string "abc"
|
|
lift $ putStrLn "hiya"
|
|
b <- string "def"
|
|
pure ()
|
|
|
|
|
|
main : IO ()
|
|
main = do
|
|
res <- parseT parseStuff "abcdef"
|
|
res <- parseT (string "hi") "hideous"
|
|
case res of
|
|
Left err => putStrLn "NOOOOOOO!"
|
|
Right () => putStrLn "YEEEES!"
|
|
digs <- parseT (satisfy isDigit) "8878993"
|
|
case digs of
|
|
Left err => putStrLn "NOOOOOOO!"
|
|
Right ds => printLn ds
|
|
migs <- parseT (many (satisfy isDigit)) "766775"
|
|
case migs of
|
|
Left err => putStrLn "NOOOOOOO!"
|
|
Right ds => printLn ds
|
|
pure () |