ermine-0.6: Ermine

Copyright(c) Edward Kmett and Dan Doel 2012-2014
MaintainerEdward Kmett <>
Safe HaskellNone






Core Terms

data Core t a Source

Core values are the output of the compilation process.

They are terms where the dictionary passing has been made explicit and all of the types have been checked and removed.


Var a 
HardCore !HardCore 
Data [t] !Word64 !Global [Core t a] 
Prim [t] t !Global [Core t a] 
App !t !(Core t a) !(Core t a) 
Lam [t] !(Scope Word64 (Core t) a) 
Let [Scope Word64 (Core t) a] !(Scope Word64 (Core t) a) 
Case !(Core t a) (Map Word64 (Match t (Core t) a)) (Maybe (Scope () (Core t) a)) 


supers :: [Core t a]
slots :: [Scope Word64 (Core t) a]


Show2 Core 
Eq2 Core 
Bitraversable Core 
Serial2 Core 
Hashable2 Core 
Bifunctor Core 
Bifoldable Core 
AsConvention t => Cored t (Core t) 
Monad (Core b) 
Functor (Core t) 
Applicative (Core b) 
Foldable (Core t) 
Traversable (Core t) 
Show b => Show1 (Core b) 
Eq b => Eq1 (Core b) 
Hashable a => Hashable1 (Core a) 
Serial t => Serial1 (Core t) 
AsConvention t => AppDict (Core t) 
AsConvention t => AppHash (Core t) 
AsConvention b => App (Core b) 
Variable (Core b) 
(Eq t, Eq a) => Eq (Core t a) 
(Show t, Show a) => Show (Core t a) 
IsString a => IsString (Core b a) 
(Binary t, Binary a) => Binary (Core t a) 
(Hashable t, Hashable a) => Hashable (Core t a) 
(Serialize t, Serialize a) => Serialize (Core t a) 
(Serial t, Serial a) => Serial (Core t a) 
AsGlobal (Core t a) 
AsId (Core t a) 
AsHardCore (Core t a) 

data Match t c a Source




_matchArgs :: [t]
_matchGlobal :: !Global
_matchBody :: Scope Word64 c a


Functor c => Functor (Match t c) 
Foldable c => Foldable (Match t c) 
Traversable c => Traversable (Match t c) 
(Hashable t, Monad c, Hashable1 c) => Hashable1 (Match t c) 
(Serial t, Serial1 c) => Serial1 (Match t c) 
Monad c => BoundBy (Match t c) c 
(Eq t, Eq a, Monad c, Eq1 c) => Eq (Match t c a) 
(Functor c, Show t, Show a, Show1 c) => Show (Match t c a) 
(Serial t, Serial1 c, Binary a) => Binary (Match t c a) 
(Monad c, Hashable t, Hashable1 c, Hashable a) => Hashable (Match t c a) 
(Serial t, Serial1 c, Serialize a) => Serialize (Match t c a) 
(Serial t, Serial1 c, Serial a) => Serial (Match t c a) 

matchArgs :: Lens (Match t c a) (Match t' c a) [t] [t'] Source

matchGlobal :: Lens' (Match t c a) Global Source

matchBody :: Lens (Match t c a) (Match t d b) (Scope Word64 c a) (Scope Word64 d b) Source

triverseMatch :: Applicative f => (t -> f t') -> (forall x y. (x -> f y) -> c x -> f (c' y)) -> (a -> f a') -> Match t c a -> f (Match t' c' a') Source

class (Variable c, AppHash c, AppDict c, App c, Applicative c, Monad c) => Cored t c | c -> t where Source

Instances of this are things we can both construct from a Core expression, and perform case analysis upon.

e.g. Core and Scope b Core

Minimal complete definition

core, case_, lambda, letrec


core :: Core t a -> c a Source

case_ :: c a -> Map Word64 (Match t c a) -> Maybe (Scope () c a) -> c a Source

lambda :: [t] -> Scope Word64 c a -> c a Source

letrec :: [Scope Word64 c a] -> Scope Word64 c a -> c a Source

hardCore :: HardCore -> c a Source


AsConvention t => Cored t (Core t) 
Cored t m => Cored t (Scope b m) 

data JavaLike Source


Method !Bool !Text !Text [Text]

Java methods: static, class name, method name, arg class names

Constructor !Text [Text]

Java constructors: class name, arg class names

Value !Bool !Text !Text

Java values: static, class name, field name

data HardCore Source

HardCore is the subset of Core terms that can be unified with value equality.


Super !Word64 
Slot !Word64 
Lit !Literal 
Foreign !Foreign 
Error !Text 
Id !Id 

class AsId c => AsHardCore c where Source

This class describes things that could be HardCore.

Minimal complete definition



_HardCore :: Prism' c HardCore Source

_Lit :: Prism' c Literal Source

_Error :: Prism' c Text Source

_Super :: Prism' c Word64 Source

_Slot :: Prism' c Word64 Source

_Foreign :: Prism' c Foreign Source


AsHardCore HardCore 
AsHardCore (Core t a) 
(~) (* -> *) f (Core t) => AsHardCore (Scope b f a) 

super :: (AsHardCore (c a), AppDict c) => Word64 -> c a -> c a Source

ask for the nth the superclass of a given dictionary as a core expression

slot :: (AsHardCore (c a), AppDict c) => Word64 -> c a -> c a Source

ask for the nth slot of a given dictionary as a core expression

Smart constructors

lam :: (Cored t m, Eq a) => t -> [a] -> Core t a -> m a Source

Smart Lam constructor

let_ :: (Cored t m, Eq a) => [(a, Core t a)] -> Core t a -> m a Source

Smart Let constructor

dataCon :: Cored t m => [t] -> Word64 -> Global -> m a Source

Builds an n-ary data constructor

prim :: Cored t m => [t] -> t -> Global -> m a Source

Builds an n-ary primop