Mikan
Safe HaskellNone
LanguageHaskell2010

Mikan.TypeChecking.CompiledClause

Description

Case trees.

After coverage checking, pattern matching is translated to case trees, i.e., a tree of successive case splits on one variable at a time.

Synopsis

Documentation

type ClauseNumber = Int Source #

The number of a Clause (starting with 0) in the clause list of a FunctionData.

data WithArity c Source #

Constructors

WithArity 

Fields

Instances

Instances details
Functor WithArity Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

fmap :: (a -> b) -> WithArity a -> WithArity b #

(<$) :: a -> WithArity b -> WithArity a #

Foldable WithArity Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

fold :: Monoid m => WithArity m -> m #

foldMap :: Monoid m => (a -> m) -> WithArity a -> m #

foldMap' :: Monoid m => (a -> m) -> WithArity a -> m #

foldr :: (a -> b -> b) -> b -> WithArity a -> b #

foldr' :: (a -> b -> b) -> b -> WithArity a -> b #

foldl :: (b -> a -> b) -> b -> WithArity a -> b #

foldl' :: (b -> a -> b) -> b -> WithArity a -> b #

foldr1 :: (a -> a -> a) -> WithArity a -> a #

foldl1 :: (a -> a -> a) -> WithArity a -> a #

toList :: WithArity a -> [a] #

null :: WithArity a -> Bool #

length :: WithArity a -> Int #

elem :: Eq a => a -> WithArity a -> Bool #

maximum :: Ord a => WithArity a -> a #

minimum :: Ord a => WithArity a -> a #

sum :: Num a => WithArity a -> a #

product :: Num a => WithArity a -> a #

Traversable WithArity Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

traverse :: Applicative f => (a -> f b) -> WithArity a -> f (WithArity b) #

sequenceA :: Applicative f => WithArity (f a) -> f (WithArity a) #

mapM :: Monad m => (a -> m b) -> WithArity a -> m (WithArity b) #

sequence :: Monad m => WithArity (m a) -> m (WithArity a) #

Pretty a => Pretty (WithArity a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

TermLike a => TermLike (WithArity a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

traverseTermM :: Monad m => (Term -> m Term) -> WithArity a -> m (WithArity a) Source #

foldTerm :: Monoid m => (Term -> m) -> WithArity a -> m Source #

NamesIn a => NamesIn (WithArity a) Source # 
Instance details

Defined in Mikan.Syntax.Internal.Names

Methods

namesAndMetasIn' :: Monoid m => (Either QName MetaId -> m) -> WithArity a -> m Source #

KillRange c => KillRange (WithArity c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

InstantiateFull t => InstantiateFull (WithArity t) Source # 
Instance details

Defined in Mikan.TypeChecking.Reduce

EmbPrj a => EmbPrj (WithArity a) Source # 
Instance details

Defined in Mikan.TypeChecking.Serialise.Instances.Internal

Abstract a => Abstract (WithArity a) Source # 
Instance details

Defined in Mikan.TypeChecking.Substitute

Apply a => Apply (WithArity a) Source # 
Instance details

Defined in Mikan.TypeChecking.Substitute

NFData c => NFData (WithArity c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

rnf :: WithArity c -> () #

Monoid c => Monoid (WithArity c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Semigroup c => Semigroup (WithArity c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

(<>) :: WithArity c -> WithArity c -> WithArity c #

sconcat :: NonEmpty (WithArity c) -> WithArity c #

stimes :: Integral b => b -> WithArity c -> WithArity c #

Generic (WithArity c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Associated Types

type Rep (WithArity c) 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

type Rep (WithArity c) = D1 ('MetaData "WithArity" "Mikan.TypeChecking.CompiledClause" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "WithArity" 'PrefixI 'True) (S1 ('MetaSel ('Just "arity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "content") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 c)))

Methods

from :: WithArity c -> Rep (WithArity c) x #

to :: Rep (WithArity c) x -> WithArity c #

Show c => Show (WithArity c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

type Rep (WithArity c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

type Rep (WithArity c) = D1 ('MetaData "WithArity" "Mikan.TypeChecking.CompiledClause" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "WithArity" 'PrefixI 'True) (S1 ('MetaSel ('Just "arity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "content") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 c)))

data Case c Source #

Branches in a case tree.

Constructors

Branches 

Fields

Instances

Instances details
Functor Case Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

fmap :: (a -> b) -> Case a -> Case b #

(<$) :: a -> Case b -> Case a #

Foldable Case Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

fold :: Monoid m => Case m -> m #

foldMap :: Monoid m => (a -> m) -> Case a -> m #

foldMap' :: Monoid m => (a -> m) -> Case a -> m #

foldr :: (a -> b -> b) -> b -> Case a -> b #

foldr' :: (a -> b -> b) -> b -> Case a -> b #

foldl :: (b -> a -> b) -> b -> Case a -> b #

foldl' :: (b -> a -> b) -> b -> Case a -> b #

foldr1 :: (a -> a -> a) -> Case a -> a #

foldl1 :: (a -> a -> a) -> Case a -> a #

toList :: Case a -> [a] #

null :: Case a -> Bool #

length :: Case a -> Int #

elem :: Eq a => a -> Case a -> Bool #

maximum :: Ord a => Case a -> a #

minimum :: Ord a => Case a -> a #

sum :: Num a => Case a -> a #

product :: Num a => Case a -> a #

Traversable Case Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

traverse :: Applicative f => (a -> f b) -> Case a -> f (Case b) #

sequenceA :: Applicative f => Case (f a) -> f (Case a) #

mapM :: Monad m => (a -> m b) -> Case a -> m (Case b) #

sequence :: Monad m => Case (m a) -> m (Case a) #

Pretty a => Pretty (Case a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

pretty :: Case a -> Doc Source #

prettyPrec :: Int -> Case a -> Doc Source #

prettyList :: [Case a] -> Doc Source #

TermLike a => TermLike (Case a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

traverseTermM :: Monad m => (Term -> m Term) -> Case a -> m (Case a) Source #

foldTerm :: Monoid m => (Term -> m) -> Case a -> m Source #

NamesIn a => NamesIn (Case a) Source # 
Instance details

Defined in Mikan.Syntax.Internal.Names

Methods

namesAndMetasIn' :: Monoid m => (Either QName MetaId -> m) -> Case a -> m Source #

KillRange c => KillRange (Case c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

InstantiateFull a => InstantiateFull (Case a) Source # 
Instance details

Defined in Mikan.TypeChecking.Reduce

EmbPrj a => EmbPrj (Case a) Source # 
Instance details

Defined in Mikan.TypeChecking.Serialise.Instances.Internal

Methods

icode :: Case a -> S Word32 Source #

icod_ :: Case a -> S Word32 Source #

value :: Word32 -> R (Case a) Source #

Abstract a => Abstract (Case a) Source # 
Instance details

Defined in Mikan.TypeChecking.Substitute

Methods

abstract :: Telescope -> Case a -> Case a Source #

Apply a => Apply (Case a) Source # 
Instance details

Defined in Mikan.TypeChecking.Substitute

Methods

apply :: Case a -> Args -> Case a Source #

applyE :: Case a -> Elims -> Case a Source #

Null (Case m) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

empty :: Case m Source #

null :: Case m -> Bool Source #

NFData a => NFData (Case a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

rnf :: Case a -> () #

Monoid m => Monoid (Case m) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

mempty :: Case m #

mappend :: Case m -> Case m -> Case m #

mconcat :: [Case m] -> Case m #

Semigroup m => Semigroup (Case m) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

(<>) :: Case m -> Case m -> Case m #

sconcat :: NonEmpty (Case m) -> Case m #

stimes :: Integral b => b -> Case m -> Case m #

Generic (Case c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Associated Types

type Rep (Case c) 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

type Rep (Case c) = D1 ('MetaData "Case" "Mikan.TypeChecking.CompiledClause" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "Branches" 'PrefixI 'True) ((S1 ('MetaSel ('Just "projPatterns") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "conBranches") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map QName (WithArity c))) :*: S1 ('MetaSel ('Just "etaBranch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe (ConHead, WithArity c))))) :*: ((S1 ('MetaSel ('Just "litBranches") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map Literal c)) :*: S1 ('MetaSel ('Just "catchallBranch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe c))) :*: (S1 ('MetaSel ('Just "fallThrough") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Bool)) :*: S1 ('MetaSel ('Just "lazyMatch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))))

Methods

from :: Case c -> Rep (Case c) x #

to :: Rep (Case c) x -> Case c #

Show c => Show (Case c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

showsPrec :: Int -> Case c -> ShowS #

show :: Case c -> String #

showList :: [Case c] -> ShowS #

type Rep (Case c) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

type Rep (Case c) = D1 ('MetaData "Case" "Mikan.TypeChecking.CompiledClause" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "Branches" 'PrefixI 'True) ((S1 ('MetaSel ('Just "projPatterns") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "conBranches") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map QName (WithArity c))) :*: S1 ('MetaSel ('Just "etaBranch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe (ConHead, WithArity c))))) :*: ((S1 ('MetaSel ('Just "litBranches") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map Literal c)) :*: S1 ('MetaSel ('Just "catchallBranch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe c))) :*: (S1 ('MetaSel ('Just "fallThrough") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Bool)) :*: S1 ('MetaSel ('Just "lazyMatch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))))

data CompiledClauses' a Source #

Case tree with bodies.

Constructors

Case !(Arg Int) !(Case (CompiledClauses' a))

Case n bs stands for a match on the n-th argument (counting from zero) with bs as the case branches. If the n-th argument is a projection, we have only conBranches with arity 0.

Done_ !(CCDone a) 
Fail ![Arg ArgName]

Absurd case. Add the free variables here as well so we can build correct number of lambdas for strict backends. (#4280)

Instances

Instances details
NamesIn CompiledClauses Source # 
Instance details

Defined in Mikan.Syntax.Internal.Names

KillRange CompiledClauses Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

MapDone CompiledClauses' Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

DropArgs CompiledClauses Source #

To drop the first n arguments in a compiled clause, we reduce the split argument indices by n and drop n arguments from the bodies. NOTE: this only works for non-recursive functions, we are not dropping arguments to recursive calls in bodies.

Instance details

Defined in Mikan.TypeChecking.DropArgs

InstantiateFull CompiledClauses Source # 
Instance details

Defined in Mikan.TypeChecking.Reduce

EmbPrj CompiledClauses Source # 
Instance details

Defined in Mikan.TypeChecking.Serialise.Instances.Internal

Abstract CompiledClauses Source # 
Instance details

Defined in Mikan.TypeChecking.Substitute

Apply CompiledClauses Source # 
Instance details

Defined in Mikan.TypeChecking.Substitute

Functor CompiledClauses' Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

fmap :: (a -> b) -> CompiledClauses' a -> CompiledClauses' b #

(<$) :: a -> CompiledClauses' b -> CompiledClauses' a #

Foldable CompiledClauses' Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

fold :: Monoid m => CompiledClauses' m -> m #

foldMap :: Monoid m => (a -> m) -> CompiledClauses' a -> m #

foldMap' :: Monoid m => (a -> m) -> CompiledClauses' a -> m #

foldr :: (a -> b -> b) -> b -> CompiledClauses' a -> b #

foldr' :: (a -> b -> b) -> b -> CompiledClauses' a -> b #

foldl :: (b -> a -> b) -> b -> CompiledClauses' a -> b #

foldl' :: (b -> a -> b) -> b -> CompiledClauses' a -> b #

foldr1 :: (a -> a -> a) -> CompiledClauses' a -> a #

foldl1 :: (a -> a -> a) -> CompiledClauses' a -> a #

toList :: CompiledClauses' a -> [a] #

null :: CompiledClauses' a -> Bool #

length :: CompiledClauses' a -> Int #

elem :: Eq a => a -> CompiledClauses' a -> Bool #

maximum :: Ord a => CompiledClauses' a -> a #

minimum :: Ord a => CompiledClauses' a -> a #

sum :: Num a => CompiledClauses' a -> a #

product :: Num a => CompiledClauses' a -> a #

Traversable CompiledClauses' Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

traverse :: Applicative f => (a -> f b) -> CompiledClauses' a -> f (CompiledClauses' b) #

sequenceA :: Applicative f => CompiledClauses' (f a) -> f (CompiledClauses' a) #

mapM :: Monad m => (a -> m b) -> CompiledClauses' a -> m (CompiledClauses' b) #

sequence :: Monad m => CompiledClauses' (m a) -> m (CompiledClauses' a) #

Pretty a => Pretty (CompiledClauses' a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

TermLike a => TermLike (CompiledClauses' a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

traverseTermM :: Monad m => (Term -> m Term) -> CompiledClauses' a -> m (CompiledClauses' a) Source #

foldTerm :: Monoid m => (Term -> m) -> CompiledClauses' a -> m Source #

PrecomputeFreeVars a => PrecomputeFreeVars (CompiledClauses' a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause.Compile

NFData a => NFData (CompiledClauses' a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

rnf :: CompiledClauses' a -> () #

Generic (CompiledClauses' a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Associated Types

type Rep (CompiledClauses' a) 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Show a => Show (CompiledClauses' a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

type Rep (CompiledClauses' a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

data CCDone a Source #

Data stored in Done nodes of the case tree. CCDone no mr xs b stands for the body b where the xs contains hiding and name suggestions for the free variables. This is needed to build lambdas on the right hand side for partial applications which can still reduce. The no is the number of the original Clause this case tree leaf comes from. mr tells whether this body contains calls to the mutually recursive functions.

Instances

Instances details
Functor CCDone Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

fmap :: (a -> b) -> CCDone a -> CCDone b #

(<$) :: a -> CCDone b -> CCDone a #

Foldable CCDone Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

fold :: Monoid m => CCDone m -> m #

foldMap :: Monoid m => (a -> m) -> CCDone a -> m #

foldMap' :: Monoid m => (a -> m) -> CCDone a -> m #

foldr :: (a -> b -> b) -> b -> CCDone a -> b #

foldr' :: (a -> b -> b) -> b -> CCDone a -> b #

foldl :: (b -> a -> b) -> b -> CCDone a -> b #

foldl' :: (b -> a -> b) -> b -> CCDone a -> b #

foldr1 :: (a -> a -> a) -> CCDone a -> a #

foldl1 :: (a -> a -> a) -> CCDone a -> a #

toList :: CCDone a -> [a] #

null :: CCDone a -> Bool #

length :: CCDone a -> Int #

elem :: Eq a => a -> CCDone a -> Bool #

maximum :: Ord a => CCDone a -> a #

minimum :: Ord a => CCDone a -> a #

sum :: Num a => CCDone a -> a #

product :: Num a => CCDone a -> a #

Traversable CCDone Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

traverse :: Applicative f => (a -> f b) -> CCDone a -> f (CCDone b) #

sequenceA :: Applicative f => CCDone (f a) -> f (CCDone a) #

mapM :: Monad m => (a -> m b) -> CCDone a -> m (CCDone b) #

sequence :: Monad m => CCDone (m a) -> m (CCDone a) #

Pretty a => Pretty (CCDone a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

TermLike a => TermLike (CCDone a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

traverseTermM :: Monad m => (Term -> m Term) -> CCDone a -> m (CCDone a) Source #

foldTerm :: Monoid m => (Term -> m) -> CCDone a -> m Source #

NFData a => NFData (CCDone a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

rnf :: CCDone a -> () #

Generic (CCDone a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Associated Types

type Rep (CCDone a) 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

type Rep (CCDone a) = D1 ('MetaData "CCDone" "Mikan.TypeChecking.CompiledClause" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "CCDone" 'PrefixI 'True) ((S1 ('MetaSel ('Just "ccClauseNumber") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ClauseNumber) :*: S1 ('MetaSel ('Just "ccClauseRecursive") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ClauseRecursive)) :*: (S1 ('MetaSel ('Just "ccBoundVars") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Arg ArgName]) :*: S1 ('MetaSel ('Just "ccBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))))

Methods

from :: CCDone a -> Rep (CCDone a) x #

to :: Rep (CCDone a) x -> CCDone a #

Show a => Show (CCDone a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

Methods

showsPrec :: Int -> CCDone a -> ShowS #

show :: CCDone a -> String #

showList :: [CCDone a] -> ShowS #

type Rep (CCDone a) Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

type Rep (CCDone a) = D1 ('MetaData "CCDone" "Mikan.TypeChecking.CompiledClause" "Mikan-2.9.0-CZbYRMbHmng2A9zjJ31VFu" 'False) (C1 ('MetaCons "CCDone" 'PrefixI 'True) ((S1 ('MetaSel ('Just "ccClauseNumber") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ClauseNumber) :*: S1 ('MetaSel ('Just "ccClauseRecursive") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ClauseRecursive)) :*: (S1 ('MetaSel ('Just "ccBoundVars") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Arg ArgName]) :*: S1 ('MetaSel ('Just "ccBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))))

litCase :: Literal -> c -> Case c Source #

projCase :: QName -> c -> Case c Source #

catchall :: c -> Case c Source #

checkLazyMatch :: Case c -> Case c Source #

Check that the requirements on lazy matching (single inductive case) are met, and set lazy to False otherwise.

hasCatchall :: CompiledClauses -> Bool Source #

Check whether a case tree has a catch-all clause.

hasProjectionPatterns :: CompiledClauses -> Bool Source #

Check whether a case tree has any projection patterns

Traversing the Done leaves

class MapDone (f :: Type -> Type) where Source #

Methods

mapDone :: (CCDone a -> CCDone b) -> f a -> f b Source #

Instances

Instances details
MapDone CompiledClauses' Source # 
Instance details

Defined in Mikan.TypeChecking.CompiledClause

prettyMap_ :: (Pretty k, Pretty v) => Map k v -> [Doc] Source #