main :: IO ()
getArgs :: IO [String]
ls :: Bool -> [FilePath] -> IO ()
silly date
Wed Feb 9 21:41:37 PST 2005
silly bla
Expected one of: cat, ls, date, help Found: bla
silly help
Usage:
cat {<filename>} -- concatenate files
ls [-l] {<filename>} -- list files (long)
date -- print current date and time
help -- show usage
Usage:
cat {<filename>} -- concatenate files
ls [-l] {<filename>} -- list files (long)
date -- print current date and time
help -- show usage
silly = cmd "cat" cat <@ files :-- "concatenate files" ! cmd "ls" ls <@ flag "-l" <@ files :-- "list files (long)" ! cmd "date" date :-- "print current date and time" ! cmd "help" help :-- "show usage"
main = run silly silly = cmd "cat" cat <@ files :-- "concatenate files" ! cmd "ls" ls <@ flag "-l" <@ files :-- "list files (long)" ! cmd "date" date :-- "print current date and time" ! cmd "help" help :-- "show usage"
files...
files :: P [FilePath]
cat :: [FilePath] -> IO ()
ls :: Bool -> [FilePath] -> IO ()
date :: IO ()
help :: IO ()
type P a nil :: a -> P a token :: (String->Maybe a) -> P a (!) :: P a -> P a -> P a (<@) :: P (a->b) -> P a -> P b parse :: P a -> [String] -> Either ErrorMessage a
type P a nil :: a -> P a token :: (String->Maybe a) -> String -> P a (!) :: P a -> P a -> P a (<@) :: P (a->b) -> P a -> P b (:--) :: P a -> String -> P a parse :: P a -> [String] -> Either ErrorMessage a usage :: P a -> String
cmd :: String -> a -> P a flag :: String -> P Bool run :: P (IO a) -> IO a kw :: String -> P () many :: P a -> P [a] some :: P a -> P [a] opt :: P a -> P (Maybe a) (#@) :: (a->b) -> P a -> P b
ap :: P (a->b) -> P a -> P b
>>= :: P a -> (a->P b) -> P b
pair :: P a -> P b -> P (a,b)
type P a = String -> Maybe (a,String)
type P a = String -> [(a,String)]
data P a where
Nil :: a -> P a
Ap :: P (b->a) -> P b -> P a
Token :: (String->Maybe a) -> String -> P a
(:--) :: P a -> String -> P a
(:!) :: P a -> P a -> P a
Many :: P a -> P [a]
...
Ap.
Many
data P a where
...
Ap :: P (b->a) -> P b -> P a
...
Many :: P a -> P [a]
...
data P res
= Nil res
| forall arg . Ap (P (arg->res)) (P arg)
| P res :-- String
| Token (String->Maybe res) String
| P res :! P res
| forall item . Many (res->[item]) ([item]->res) (P item)
many :: P a -> P [a]
many = Many id id
Many express
the fact that the result type is expected to be isomorphic to
some list type.
P a
parse :: P a -> [String] -> Either ErrorMessage a
usage :: P a -> String
data P a = P Grammar (PM a)
data Grammar = ...