module Language.FunPat.Interface where import Language.FunPat.Match import Control.Monad.State -- | Matches a value with cases. match :: pat -> State [SomeCase (pat, res)] () -> res match x m = matchCases x $ snd $ runState m [] -- | Creates one /case/ of the match. with :: (Case a) => a -> State [SomeCase (PatternType a, ResultType a)] () with c = do cs <- get put $ cs ++ [SomeCase c] -- | Syntactic sugar to compose @(pattern,result)@ pairs. infix 1 ~> (~>) :: a -> b -> (a,b) (~>) = (,)