ermine-0.6: Ermine

Copyright(c) Dan Doel and Edward Kmett 2013-2014
LicenseBSD3
MaintainerDan Doel <dan.doel@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Ermine.Pattern.Matching

Contents

Description

 

Synopsis

Matching

data Matching c a Source

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.

Constructors

Matching 

Fields

_pathMap :: HashMap PatternPath (c a)
 
_colCores :: [c a]
 
_colPaths :: [PatternPaths]
 

class HasMatching t c a | t -> c a where Source

Minimal complete definition

matching

Methods

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

Instances

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