Copyright | (c) Edward Kmett |
---|---|
License | BSD3 |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
- data Pattern t
- _SigP :: forall t. Prism' (Pattern t) t
- _WildcardP :: forall t. Prism' (Pattern t) ()
- _AsP :: forall t. Prism' (Pattern t) (Pattern t)
- _StrictP :: forall t. Prism' (Pattern t) (Pattern t)
- _LazyP :: forall t. Prism' (Pattern t) (Pattern t)
- _LitP :: forall t. Prism' (Pattern t) Literal
- _ConP :: forall t. Prism' (Pattern t) (Global, [Pattern t])
- _TupP :: forall t. Prism' (Pattern t) [Pattern t]
- _ConP' :: Global -> Prism' (Pattern t) [Pattern t]
- _LitP' :: Literal -> Prism' (Pattern t) [Pattern t]
- data PatternHead
- _TupH :: Prism' PatternHead Word64
- _ConH :: Prism' PatternHead ([Convention], Global)
- conventions :: PatternHead -> [Convention]
- headName :: Traversal' PatternHead Global
- traverseHead :: PatternHead -> Traversal' (Pattern t) [Pattern t]
- data PatternPath
- type PatternPaths = Endo PatternPath
- fieldPP :: Word64 -> PatternPaths
- argPP :: Word64 -> PatternPaths
- leafPP :: PatternPaths -> PatternPath
- paths :: Pattern t -> [PatternPath]
- manyPaths :: [Pattern t] -> [PatternPath]
- data Guarded tm
- data Alt t f a = Alt !(Pattern t) (Guarded (Scope PatternPath f a))
- bitraverseAlt :: (Bitraversable k, Applicative f) => (t -> f t') -> (a -> f b) -> Alt t (k t) a -> f (Alt t' (k t') b)
- patternHead :: Fold (Pattern t) PatternHead
- prune :: Pattern t -> Pattern t
- forces :: Pattern t -> Bool
- irrefutable :: Pattern t -> Bool
- serializeAlt3 :: MonadPut m => (t -> m ()) -> (forall a. (a -> m ()) -> f a -> m ()) -> (v -> m ()) -> Alt t f v -> m ()
- deserializeAlt3 :: MonadGet m => m t -> (forall a. m a -> m (f a)) -> m v -> m (Alt t f v)
Documentation
Patterns used by Term
SigP t | |
WildcardP | |
AsP (Pattern t) | |
StrictP (Pattern t) | |
LazyP (Pattern t) | |
LitP !Literal | |
ConP !Global [Pattern t] | |
TupP [Pattern t] |
Functor Pattern | |
Foldable Pattern | |
Traversable Pattern | |
Serial1 Pattern | |
(Bifunctor p, Choice p, Applicative f) => Tup p f (Pattern t) | |
Eq t => Eq (Pattern t) | |
Show t => Show (Pattern t) | |
Binary t => Binary (Pattern t) | |
Serialize t => Serialize (Pattern t) | |
Serial a => Serial (Pattern a) | |
IsString s => IsString (P (Annot t) s) |
_WildcardP :: forall t. Prism' (Pattern t) () Source
data PatternHead Source
_TupH :: Prism' PatternHead Word64 Source
_ConH :: Prism' PatternHead ([Convention], Global) Source
conventions :: PatternHead -> [Convention] Source
headName :: Traversal' PatternHead Global Source
traverseHead :: PatternHead -> Traversal' (Pattern t) [Pattern t] Source
data PatternPath Source
Paths into a pattern tree. These will be used as the bound variables for scopes that have patterns in their binder. No effort has been made to enforce statically that pattern paths used in a given scope correspond only to well-formed paths into the particular tree; it will merely have to be an invariant maintained in the compiler.
LeafPP represents a reference to the variable at a node that binds a variable. For instance, LeafPP is a valid path into SigP. It is also valid for AsP p for all p, because AsP binds a variable. It is invalid for ConP, however.
No effort is made to represent paths with no decision points. This is primarily because it is detrimental to the compilation strategy. AsP, StrictP and LazyP can be thought of as annotations that are not full-fledged patterns in themselves. AsP signals that it is valid to make reference to an entire piece of substructure, while StrictP and LazyP inform the pattern compilation process. But it is unnecessary to distinguish between pointing at an AsP---which is always valid---and pointing at the right portion of an AsP---which is invalid unless the pattern contains redundancies.
LeafPP | refer to a variable |
FieldPP !Word64 PatternPath | refer to the n-th subpattern of a constructor |
ArgPP !Word64 PatternPath | refer to the n-th pattern of many top-level patterns |
Eq PatternPath | |
Ord PatternPath | |
Read PatternPath | |
Show PatternPath | |
Generic PatternPath | |
Binary PatternPath | |
Hashable PatternPath | |
Serialize PatternPath | |
Serial PatternPath | |
type Rep PatternPath |
type PatternPaths = Endo PatternPath Source
fieldPP :: Word64 -> PatternPaths Source
argPP :: Word64 -> PatternPaths Source
leafPP :: PatternPaths -> PatternPath Source
paths :: Pattern t -> [PatternPath] Source
Returns all the paths pointing to variables in the given pattern, in order from left to right.
manyPaths :: [Pattern t] -> [PatternPath] Source
Returns all the paths pointing to variables in a series of patterns. The list is assumed to contain patterns in left-to-right order, and the resulting list will be in the same order.
A datatype for representing potentially guarded cases of a function or case body.
Functor Guarded | |
Foldable Guarded | |
Traversable Guarded | |
Serial1 Guarded | |
Eq tm => Eq (Guarded tm) | |
Ord tm => Ord (Guarded tm) | |
Read tm => Read (Guarded tm) | |
Show tm => Show (Guarded tm) | |
Generic (Guarded tm) | |
Binary tm => Binary (Guarded tm) | |
Serialize tm => Serialize (Guarded tm) | |
Serial v => Serial (Guarded v) | |
type Rep (Guarded tm) |
One alternative of a core expression
Alt !(Pattern t) (Guarded (Scope PatternPath f a)) |
Bound (Alt t) | |
Functor f => Functor (Alt t f) | |
Foldable f => Foldable (Alt t f) | |
Traversable f => Traversable (Alt t f) | |
(Serial t, Serial1 f) => Serial1 (Alt t f) | |
Monad f => BoundBy (Alt t f) f | |
(Eq t, Eq a, Monad f, Eq1 f) => Eq (Alt t f a) | |
(Functor f, Show t, Show a, Show1 f) => Show (Alt t f a) | |
(Serial t, Serial1 f, Serial a) => Serial (Alt t f a) |
bitraverseAlt :: (Bitraversable k, Applicative f) => (t -> f t') -> (a -> f b) -> Alt t (k t) a -> f (Alt t' (k t') b) Source
Helper function for traversing both sides of an Alt
.
patternHead :: Fold (Pattern t) PatternHead Source
irrefutable :: Pattern t -> Bool Source
serializeAlt3 :: MonadPut m => (t -> m ()) -> (forall a. (a -> m ()) -> f a -> m ()) -> (v -> m ()) -> Alt t f v -> m () Source
deserializeAlt3 :: MonadGet m => m t -> (forall a. m a -> m (f a)) -> m v -> m (Alt t f v) Source