mirror of
https://github.com/sdiehl/write-you-a-haskell.git
synced 2024-09-11 19:47:31 +03:00
infixOp to prefixOp
This commit is contained in:
parent
846a6c19f5
commit
19bb1520c7
@ -43,17 +43,17 @@ semiSep = Tok.semiSep lexer
|
|||||||
reservedOp :: String -> Parser ()
|
reservedOp :: String -> Parser ()
|
||||||
reservedOp = Tok.reservedOp lexer
|
reservedOp = Tok.reservedOp lexer
|
||||||
|
|
||||||
infixOp :: String -> (a -> a) -> Ex.Operator String () Identity a
|
prefixOp :: String -> (a -> a) -> Ex.Operator String () Identity a
|
||||||
infixOp s f = Ex.Prefix (reservedOp s >> return f)
|
prefixOp s f = Ex.Prefix (reservedOp s >> return f)
|
||||||
|
|
||||||
|
|
||||||
-- Infix operators
|
-- Infix operators
|
||||||
table :: Ex.OperatorTable String () Identity Expr
|
table :: Ex.OperatorTable String () Identity Expr
|
||||||
table = [
|
table = [
|
||||||
[
|
[
|
||||||
infixOp "succ" Succ
|
prefixOp "succ" Succ
|
||||||
, infixOp "pred" Pred
|
, prefixOp "pred" Pred
|
||||||
, infixOp "iszero" IsZero
|
, prefixOp "iszero" IsZero
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user