- data Match where
- class Typeable a => Matchable a where
- data Param = Param {}
- class Matchable (PatternType t) => Case t where
- type PatternType t
- type ResultType t
- type ParameterType t
- start :: PatternType t -> t -> Maybe (ParameterType t)
- continue :: Typeable p => PatternType t -> t -> p -> Maybe [p]
- matchCase :: PatternType t -> t -> Maybe (ResultType t)
- data SomeCase t where
- SomeCase :: Case a => a -> SomeCase (PatternType a, ResultType a)
- matchSomeCase :: pat -> SomeCase (pat, res) -> Maybe res
- matchCases :: pat -> [SomeCase (pat, res)] -> res
- matchHelp :: Typeable p => Match -> p -> Maybe [p]
- matchFold :: Typeable p => p -> [Match] -> Maybe [p]
- package :: String
- unbound :: String
- nonlinear :: String
- nonparametric :: String
- matchError :: String -> a
Matchability
A data type to be used in Matchable
instances.
class Typeable a => Matchable a whereSource
Matchable
data types can be used in patterns.
(.=.) :: a -> a -> Maybe [Match]Source
The conditions of a match. In most cases, this is the only function in this class to implement.
If the result is Nothing
, there is no match.
If the result is Just [x :=: x', y :=: y', ... ]
, condition of the match is
that x
matches x'
, y
matches y'
etc.
Creates an extra value of type a
with a Bool
inside.
The default implementation throws an exception.
isParam :: a -> Maybe BoolSource
Checks if the argument is an extra value created by makeParam
.
The default implementation evaluates the argument and catches the exception thrown.
Matchable Bool | |
Matchable Char | |
Matchable Double | |
Matchable Float | |
Matchable Int | |
Matchable Integer | |
Matchable Ordering | |
Matchable () | |
Matchable a => Matchable [a] | |
Matchable a => Matchable (Maybe a) | |
(Matchable a, Matchable b) => Matchable (Either a b) | |
(Matchable a, Matchable b) => Matchable (a, b) | |
(Matchable a, Matchable b, Matchable c) => Matchable (a, b, c) | |
(Matchable a, Matchable b, Matchable c, Matchable d) => Matchable (a, b, c, d) | |
(Matchable a, Matchable b, Matchable c, Matchable d, Matchable e) => Matchable (a, b, c, d, e) | |
(Matchable a, Matchable b, Matchable c, Matchable d, Matchable e, Matchable f) => Matchable (a, b, c, d, e, f) | |
(Matchable a, Matchable b, Matchable c, Matchable d, Matchable e, Matchable f, Matchable g) => Matchable (a, b, c, d, e, f, g) |
Implementation
class Matchable (PatternType t) => Case t whereSource
Case
instances are allowed to form cases of a pattern match. (Normally, there is no need to implement more instances of this class.)
start :: PatternType t -> t -> Maybe (ParameterType t)Source
continue :: Typeable p => PatternType t -> t -> p -> Maybe [p]Source
matchCase :: PatternType t -> t -> Maybe (ResultType t)Source
SomeCase :: Case a => a -> SomeCase (PatternType a, ResultType a) |
matchSomeCase :: pat -> SomeCase (pat, res) -> Maybe resSource
Processes one case.
matchCases :: pat -> [SomeCase (pat, res)] -> resSource
Processes multiple cases.
Helper functions
matchError :: String -> aSource