Portability | portable |
---|---|
Stability | experimental |
Maintainer | Reiner Pope <reiner.pope@gmail.com> |
The main types used.
- newtype Pattern vars a = Pattern {
- runPattern :: a -> Maybe (Tuple vars)
- type Pat0 a = Pattern Nil a
- type Pat1 b a = forall bs. Pattern bs b -> Pattern bs a
- type Pat2 b c a = forall bs cs. Pattern bs b -> Pattern cs c -> Pattern (bs :++: cs) a
- type Pat3 b c d a = forall bs cs ds. Pattern bs b -> Pattern cs c -> Pattern ds d -> Pattern (bs :++: (cs :++: ds)) a
- type Pat4 b c d e a = forall bs cs ds es. Pattern bs b -> Pattern cs c -> Pattern ds d -> Pattern es e -> Pattern (bs :++: (cs :++: (ds :++: es))) a
- type Pat5 b c d e f a = forall bs cs ds es fs. Pattern bs b -> Pattern cs c -> Pattern ds d -> Pattern es e -> Pattern fs f -> Pattern (bs :++: (cs :++: (ds :++: (es :++: fs)))) a
- data Clause a r
- (->>) :: Pattern vars a -> Fun vars r -> Clause a r
- (|||) :: Clause a r -> Clause a r -> Clause a r
- tryMatch :: a -> Clause a r -> Maybe r
- match :: a -> Clause a r -> r
- module Data.Pattern.Base.TypeList
- module Data.Pattern.Base.Tuple
Patterns
The pattern type. A Pattern vars a
is a pattern which matches
against a
s and binds variables with types given by the type-list
vars
.
Although this is the basic type used by patterns, many of
pattern combinators (for instance, Data.Pattern.Base.Common.left
)
have types better expressed by the type synonyms Pat0
, Pat1
,
Pat2
, etc, Pat5
, so that nesting of patterns (e.g. left (tup2
var var)
) can be written as function application.
Most "normal" pattern matchers (in fact, all of the matchers in
Data.Pattern.Common except var
and (/)
) can be conveniently
defined using mk0
, mk1
, etc, mk5
.
Pattern | |
|
Pattern synonyms. A PatN
is a function which takes N
subpatterns and yields a Pattern
which binds all of the
subpatterns' variables in order.
type Pat3 b c d a = forall bs cs ds. Pattern bs b -> Pattern cs c -> Pattern ds d -> Pattern (bs :++: (cs :++: ds)) aSource
type Pat4 b c d e a = forall bs cs ds es. Pattern bs b -> Pattern cs c -> Pattern ds d -> Pattern es e -> Pattern (bs :++: (cs :++: (ds :++: es))) aSource
type Pat5 b c d e f a = forall bs cs ds es fs. Pattern bs b -> Pattern cs c -> Pattern ds d -> Pattern es e -> Pattern fs f -> Pattern (bs :++: (cs :++: (ds :++: (es :++: fs)))) aSource
Clauses
(|||) :: Clause a r -> Clause a r -> Clause a rSource
Alternative clauses: p ||| q
is the clause which first
attempts p
, and then q
if p
fails.
module Data.Pattern.Base.TypeList
module Data.Pattern.Base.Tuple