compstrat-0.1.0.3: Strategy combinators for compositional data types
CopyrightJames Koppel 2013
LicenseBSD-style (see the LICENSE file in the distribution)
Safe HaskellNone
LanguageHaskell98

Data.Comp.Multi.Strategy.Classification

Description

This module contains typeclasses and operations allowing dynamic casing on sorts.

Synopsis

Documentation

class DynCase f 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

Methods

dyncase :: f b -> Maybe (b :~: a) Source #

Determines whether a node has sort a

Instances

Instances details
DynCase (K a) b Source # 
Instance details

Defined in Data.Comp.Multi.Strategy.Classification

Methods

dyncase :: K a b0 -> Maybe (b0 :~: b) Source #

(KDynCase f l, DynCase a l) => DynCase (Cxt h f a) l Source # 
Instance details

Defined in Data.Comp.Multi.Strategy.Classification

Methods

dyncase :: Cxt h f a b -> Maybe (b :~: l) Source #

class KDynCase (f :: (* -> *) -> * -> *) a where Source #

An instance KDynCase f a defines an instance DynCase (HFix f) a

Methods

kdyncase :: f e b -> Maybe (b :~: a) Source #

Instances

Instances details
NotSum f => KDynCase f a Source # 
Instance details

Defined in Data.Comp.Multi.Strategy.Classification

Methods

kdyncase :: forall (e :: Type -> Type) b. f e b -> Maybe (b :~: a) Source #

All (KDynCaseFlip l) fs => KDynCase (Sum fs) l Source # 
Instance details

Defined in Data.Comp.Multi.Strategy.Classification

Methods

kdyncase :: forall (e :: Type -> Type) b. Sum fs e b -> Maybe (b :~: l) Source #

KDynCase f l => KDynCase (f :&: a) l Source # 
Instance details

Defined in Data.Comp.Multi.Strategy.Classification

Methods

kdyncase :: forall (e :: Type -> Type) b. (f :&: a) e b -> Maybe (b :~: l) Source #

dynProj :: forall f l l'. 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.

fromDynProj :: DynCase f l => f l' -> f l Source #

Equivalent to fromJust . dynProj

caseE :: DynCase f l => E f -> Maybe (f l) Source #

Inspect an existentially-quantified sort to determine if it is of sort l

caseDyn Source #

Arguments

:: DynCase f l 
=> (f l -> r)

Function to run on term of sort l

-> 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 :: (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 e l. DynCase e l => Proxy l -> forall i. e i -> Bool Source #

isSort (Proxy :: Proxy l) returns a boolean function that tests whether a term has sort l

kIsSort :: forall f l. KDynCase f l => Proxy l -> forall i e. f e i -> Bool Source #

Like isSort, but runs on (unwrapped) nodes rather than terms.