Copyright | (c) Dan Doel and Edward Kmett 2013-2014 |
---|---|
License | BSD3 |
Maintainer | Dan Doel <dan.doel@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
- data Matching c a = Matching {
- _pathMap :: HashMap PatternPath (c a)
- _colCores :: [c a]
- _colPaths :: [PatternPaths]
- class HasMatching t c a | t -> c a where
- matching :: Lens' t (Matching c a)
- colCores :: Lens' t [c a]
- colPaths :: Lens' t [PatternPaths]
- pathMap :: Lens' t (HashMap PatternPath (c a))
- compile :: (AsConvention cc, MonadPattern m, Cored cc c) => Matching c a -> PatternMatrix t c a -> m (c a)
- compileBinding :: (MonadPattern m, AsConvention cc, Cored cc c) => [cc] -> [[Pattern t]] -> [Guarded (Scope BodyBound c a)] -> [[Scope (Var WhereBound Word64) c a]] -> m (Scope Word64 c a)
- compileLambda :: (MonadPattern m, AsConvention cc, Cored cc c) => [Pattern t] -> Scope PatternPath c a -> m (Scope Word64 c a)
- compileCase :: (MonadPattern m, AsConvention cc, Cored cc c) => [Pattern t] -> c a -> [Guarded (Scope PatternPath c a)] -> m (c a)
- plam :: (AsConvention cc, Eq v, MonadPattern m) => [P t v] -> Core cc v -> m (Core cc v)
Matching
Additional information needed for pattern compilation that does not really belong in the pattern matrix.
The pathMap
stores information for resolving previous levels of the
pattern to appropriate cores for the current context.
colCores
contains core terms that refer to each of the columns of the
matrix in the current context.
colPaths
contains the paths into the original pattern that correspond to
each of the current columns.
Matching | |
|
Functor c => Functor (Matching c) | |
Foldable c => Foldable (Matching c) | |
Traversable c => Traversable (Matching c) | |
HasMatching (Matching c a) c a |
class HasMatching t c a | t -> c a where Source
matching :: Lens' t (Matching c a) Source
colCores :: Lens' t [c a] Source
colPaths :: Lens' t [PatternPaths] Source
pathMap :: Lens' t (HashMap PatternPath (c a)) Source
HasMatching (Matching c a) c a |
Compilation
compile :: (AsConvention cc, MonadPattern m, Cored cc c) => Matching c a -> PatternMatrix t c a -> m (c a) Source
Compiles a pattern matrix together with a corresponding set of core branches to a final Core value, which will be the decision tree version of the pattern matrix.
compileBinding :: (MonadPattern m, AsConvention cc, Cored cc c) => [cc] -> [[Pattern t]] -> [Guarded (Scope BodyBound c a)] -> [[Scope (Var WhereBound Word64) c a]] -> m (Scope Word64 c a) Source
compileLambda :: (MonadPattern m, AsConvention cc, Cored cc c) => [Pattern t] -> Scope PatternPath c a -> m (Scope Word64 c a) Source
compileCase :: (MonadPattern m, AsConvention cc, Cored cc c) => [Pattern t] -> c a -> [Guarded (Scope PatternPath c a)] -> m (c a) Source
builtin lambda using patterns
plam :: (AsConvention cc, Eq v, MonadPattern m) => [P t v] -> Core cc v -> m (Core cc v) Source