| Copyright | James Koppel 2013 |
|---|---|
| License | BSD-style (see the LICENSE file in the distribution) |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Comp.Multi.Strategy.Classification
Description
This module contains typeclasses and operations allowing dynamic casing on sorts.
Synopsis
- class DynCase (f :: Type -> Type) a where
- class KDynCase (f :: Node) a where
- dynProj :: DynCase f l => f l' -> Maybe (f l)
- fromDynProj :: DynCase f l => f l' -> f l
- caseE :: DynCase f l => E f -> Maybe (f l)
- caseDyn :: DynCase f l => (f l -> r) -> f i -> r -> r
- subterms :: forall (f :: (Type -> Type) -> Type -> Type) l l'. (DynCase (HFix f) l, HFoldable f) => HFix f l' -> [HFix f l]
- isSort :: forall l e. DynCase e l => forall i. e i -> Bool
- hasAnySort :: forall (ls :: [Sort]) e. All (DynCase e) ls => forall i. e i -> Bool
- kIsSort :: forall l f. KDynCase f l => forall i (e :: Family). f e i -> Bool
- kHasAnySort :: forall (ls :: [Sort]) f. All (KDynCase f) ls => forall i (e :: Family). f e i -> Bool
Documentation
class DynCase (f :: Type -> Type) a where Source #
This operation allows you to rediscover the label giving
the sort of a term by inspecting the term. It is mainly used
through the caseE and dynProj operators
class KDynCase (f :: Node) a where Source #
An instance KDynCase f a defines an instance DynCase (HFix f) a
dynProj :: DynCase f l => f l' -> Maybe (f l) Source #
Takes a term t of unknown sort. Returns Just t if t is of sort l, and Nothing otherwise.
caseE :: DynCase f l => E f -> Maybe (f l) Source #
Inspect an existentially-quantified sort to determine if it is of sort l
Arguments
| :: DynCase f l | |
| => (f l -> r) | Function to run on term of sort |
| -> f i | Term of unknown sort |
| -> r | Default value |
| -> r |
Runs a sort-specific function on a term of unknown sort, returning a default value if it is of the wrong sort
subterms :: forall (f :: (Type -> Type) -> Type -> Type) l l'. (DynCase (HFix f) l, HFoldable f) => HFix f l' -> [HFix f l] Source #
Gives all subterms of any given sort of a term
isSort :: forall l e. DynCase e l => forall i. e i -> Bool Source #
isSort @l returns a boolean function that tests whether a term has sort l
hasAnySort :: forall (ls :: [Sort]) e. All (DynCase e) ls => forall i. e i -> Bool Source #
hasAnySort @ls returns a boolean function that tests
whether a term has any sort in the list of sorts ls
Example usage: hasAnySort @'[FunctionDefL, FunctionDeclL] t
kIsSort :: forall l f. KDynCase f l => forall i (e :: Family). f e i -> Bool Source #
Like isSort, but runs on (unwrapped) nodes rather than terms.
kHasAnySort :: forall (ls :: [Sort]) f. All (KDynCase f) ls => forall i (e :: Family). f e i -> Bool Source #
Like hasAnySort, but runs on (unwrapped) nodes rather than terms.