model-0.3: Derive a model of a data type using Generics

Safe HaskellSafe
LanguageHaskell2010

Data.Model.Types

Contents

Description

A model for simple algebraic data types.

Synopsis

Model

data TypeModel adtName consName inRef exRef Source #

The complete model of a type, a reference to the type plus its environment:

  • adtName: type used to represent the name of a data type
  • consName: type used to represent the name of a constructor
  • inRef: type used to represent a reference to a type or a type variable inside the data type definition (for example HTypeRef)
  • exRef: type used to represent a reference to a type in the type name (for example QualName)

Constructors

TypeModel 

Fields

  • typeName :: Type exRef

    The type application corresponding to the type

  • typeEnv :: TypeEnv adtName consName inRef exRef

    The environment in which the type is defined

Instances

(Eq adtName, Eq inRef, Eq consName, Eq exRef) => Eq (TypeModel adtName consName inRef exRef) Source # 

Methods

(==) :: TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef -> Bool #

(/=) :: TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef -> Bool #

(Ord adtName, Ord inRef, Ord consName, Ord exRef) => Ord (TypeModel adtName consName inRef exRef) Source # 

Methods

compare :: TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef -> Ordering #

(<) :: TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef -> Bool #

(<=) :: TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef -> Bool #

(>) :: TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef -> Bool #

(>=) :: TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef -> Bool #

max :: TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef #

min :: TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef -> TypeModel adtName consName inRef exRef #

(Show adtName, Show inRef, Show consName, Show exRef) => Show (TypeModel adtName consName inRef exRef) Source # 

Methods

showsPrec :: Int -> TypeModel adtName consName inRef exRef -> ShowS #

show :: TypeModel adtName consName inRef exRef -> String #

showList :: [TypeModel adtName consName inRef exRef] -> ShowS #

Generic (TypeModel adtName consName inRef exRef) Source # 

Associated Types

type Rep (TypeModel adtName consName inRef exRef) :: * -> * #

Methods

from :: TypeModel adtName consName inRef exRef -> Rep (TypeModel adtName consName inRef exRef) x #

to :: Rep (TypeModel adtName consName inRef exRef) x -> TypeModel adtName consName inRef exRef #

(NFData adtName, NFData inRef, NFData consName, NFData exRef) => NFData (TypeModel adtName consName inRef exRef) Source # 

Methods

rnf :: TypeModel adtName consName inRef exRef -> () #

type Rep (TypeModel adtName consName inRef exRef) Source # 
type Rep (TypeModel adtName consName inRef exRef) = D1 (MetaData "TypeModel" "Data.Model.Types" "model-0.3-A2rozqcGuQN4U385Cv7Taj" False) (C1 (MetaCons "TypeModel" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "typeName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Type exRef))) (S1 (MetaSel (Just Symbol "typeEnv") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (TypeEnv adtName consName inRef exRef)))))

type TypeEnv adtName consName inRef exRef = Map exRef (ADT adtName consName inRef) Source #

A map of all the ADTs that are directly or indirectly referred by a type, indexed by a type reference

typeADTs :: TypeModel adtName consName inRef k -> [ADT adtName consName inRef] Source #

The ADTs defined in the TypeModel

data ADT name consName ref Source #

Simple algebraic data type (not a GADT):

  • declName: type used to represent the name of the data type
  • consName: type used to represent the name of a constructor
  • ref: type used to represent a reference to a type or a type variable inside the data type definition (for example HTypeRef)

Constructors

ADT 

Fields

Instances

Functor (ADT name consName) Source # 

Methods

fmap :: (a -> b) -> ADT name consName a -> ADT name consName b #

(<$) :: a -> ADT name consName b -> ADT name consName a #

Foldable (ADT name consName) Source # 

Methods

fold :: Monoid m => ADT name consName m -> m #

foldMap :: Monoid m => (a -> m) -> ADT name consName a -> m #

foldr :: (a -> b -> b) -> b -> ADT name consName a -> b #

foldr' :: (a -> b -> b) -> b -> ADT name consName a -> b #

foldl :: (b -> a -> b) -> b -> ADT name consName a -> b #

foldl' :: (b -> a -> b) -> b -> ADT name consName a -> b #

foldr1 :: (a -> a -> a) -> ADT name consName a -> a #

foldl1 :: (a -> a -> a) -> ADT name consName a -> a #

toList :: ADT name consName a -> [a] #

null :: ADT name consName a -> Bool #

length :: ADT name consName a -> Int #

elem :: Eq a => a -> ADT name consName a -> Bool #

maximum :: Ord a => ADT name consName a -> a #

minimum :: Ord a => ADT name consName a -> a #

sum :: Num a => ADT name consName a -> a #

product :: Num a => ADT name consName a -> a #

Traversable (ADT name consName) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> ADT name consName a -> f (ADT name consName b) #

sequenceA :: Applicative f => ADT name consName (f a) -> f (ADT name consName a) #

mapM :: Monad m => (a -> m b) -> ADT name consName a -> m (ADT name consName b) #

sequence :: Monad m => ADT name consName (m a) -> m (ADT name consName a) #

(Eq consName, Eq ref, Eq name) => Eq (ADT name consName ref) Source # 

Methods

(==) :: ADT name consName ref -> ADT name consName ref -> Bool #

(/=) :: ADT name consName ref -> ADT name consName ref -> Bool #

(Ord consName, Ord ref, Ord name) => Ord (ADT name consName ref) Source # 

Methods

compare :: ADT name consName ref -> ADT name consName ref -> Ordering #

(<) :: ADT name consName ref -> ADT name consName ref -> Bool #

(<=) :: ADT name consName ref -> ADT name consName ref -> Bool #

(>) :: ADT name consName ref -> ADT name consName ref -> Bool #

(>=) :: ADT name consName ref -> ADT name consName ref -> Bool #

max :: ADT name consName ref -> ADT name consName ref -> ADT name consName ref #

min :: ADT name consName ref -> ADT name consName ref -> ADT name consName ref #

(Show consName, Show ref, Show name) => Show (ADT name consName ref) Source # 

Methods

showsPrec :: Int -> ADT name consName ref -> ShowS #

show :: ADT name consName ref -> String #

showList :: [ADT name consName ref] -> ShowS #

Generic (ADT name consName ref) Source # 

Associated Types

type Rep (ADT name consName ref) :: * -> * #

Methods

from :: ADT name consName ref -> Rep (ADT name consName ref) x #

to :: Rep (ADT name consName ref) x -> ADT name consName ref #

(NFData consName, NFData ref, NFData name) => NFData (ADT name consName ref) Source # 

Methods

rnf :: ADT name consName ref -> () #

type Rep (ADT name consName ref) Source # 
type Rep (ADT name consName ref) = D1 (MetaData "ADT" "Data.Model.Types" "model-0.3-A2rozqcGuQN4U385Cv7Taj" False) (C1 (MetaCons "ADT" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "declName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 name)) ((:*:) (S1 (MetaSel (Just Symbol "declNumParameters") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Word8)) (S1 (MetaSel (Just Symbol "declCons") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (ConTree consName ref)))))))

data ConTree name ref Source #

Constructors are assembled in a binary tree

Constructors

Con 

Fields

  • constrName :: name

    The constructor name, unique in the data type

  • constrFields :: Either [Type ref] [(name, Type ref)]

    Constructor fields, they can be either unnamed (Left case) or named (Right case) If they are named, they must all be named

ConTree (ConTree name ref) (ConTree name ref)

Constructor tree.

Constructors are disposed in an optimally balanced, right heavier tree:

For example, the data type:

data N = One | Two | Three | Four | Five

Would have its contructors ordered in the following tree:

         |
    |            |
 One Two   Three   |
               Four Five

To get a list of constructor in declaration order, use constructors

Instances

Functor (ConTree name) Source # 

Methods

fmap :: (a -> b) -> ConTree name a -> ConTree name b #

(<$) :: a -> ConTree name b -> ConTree name a #

Foldable (ConTree name) Source # 

Methods

fold :: Monoid m => ConTree name m -> m #

foldMap :: Monoid m => (a -> m) -> ConTree name a -> m #

foldr :: (a -> b -> b) -> b -> ConTree name a -> b #

foldr' :: (a -> b -> b) -> b -> ConTree name a -> b #

foldl :: (b -> a -> b) -> b -> ConTree name a -> b #

foldl' :: (b -> a -> b) -> b -> ConTree name a -> b #

foldr1 :: (a -> a -> a) -> ConTree name a -> a #

foldl1 :: (a -> a -> a) -> ConTree name a -> a #

toList :: ConTree name a -> [a] #

null :: ConTree name a -> Bool #

length :: ConTree name a -> Int #

elem :: Eq a => a -> ConTree name a -> Bool #

maximum :: Ord a => ConTree name a -> a #

minimum :: Ord a => ConTree name a -> a #

sum :: Num a => ConTree name a -> a #

product :: Num a => ConTree name a -> a #

Traversable (ConTree name) Source # 

Methods

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

sequenceA :: Applicative f => ConTree name (f a) -> f (ConTree name a) #

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

sequence :: Monad m => ConTree name (m a) -> m (ConTree name a) #

(Eq ref, Eq name) => Eq (ConTree name ref) Source # 

Methods

(==) :: ConTree name ref -> ConTree name ref -> Bool #

(/=) :: ConTree name ref -> ConTree name ref -> Bool #

(Ord ref, Ord name) => Ord (ConTree name ref) Source # 

Methods

compare :: ConTree name ref -> ConTree name ref -> Ordering #

(<) :: ConTree name ref -> ConTree name ref -> Bool #

(<=) :: ConTree name ref -> ConTree name ref -> Bool #

(>) :: ConTree name ref -> ConTree name ref -> Bool #

(>=) :: ConTree name ref -> ConTree name ref -> Bool #

max :: ConTree name ref -> ConTree name ref -> ConTree name ref #

min :: ConTree name ref -> ConTree name ref -> ConTree name ref #

(Show ref, Show name) => Show (ConTree name ref) Source # 

Methods

showsPrec :: Int -> ConTree name ref -> ShowS #

show :: ConTree name ref -> String #

showList :: [ConTree name ref] -> ShowS #

Generic (ConTree name ref) Source # 

Associated Types

type Rep (ConTree name ref) :: * -> * #

Methods

from :: ConTree name ref -> Rep (ConTree name ref) x #

to :: Rep (ConTree name ref) x -> ConTree name ref #

(NFData ref, NFData name) => NFData (ConTree name ref) Source # 

Methods

rnf :: ConTree name ref -> () #

type Rep (ConTree name ref) Source # 
type Rep (ConTree name ref) = D1 (MetaData "ConTree" "Data.Model.Types" "model-0.3-A2rozqcGuQN4U385Cv7Taj" False) ((:+:) (C1 (MetaCons "Con" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "constrName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 name)) (S1 (MetaSel (Just Symbol "constrFields") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Either [Type ref] [(name, Type ref)]))))) (C1 (MetaCons "ConTree" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ConTree name ref))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ConTree name ref))))))

data Type ref Source #

A type

Constructors

TypeCon ref

Type constructor (Bool,Maybe,..)

TypeApp (Type ref) (Type ref)

Type application

Instances

Functor Type Source # 

Methods

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

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

Foldable Type Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Type a -> [a] #

null :: Type a -> Bool #

length :: Type a -> Int #

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

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

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

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

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

Traversable Type Source # 

Methods

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

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

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

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

Eq ref => Eq (Type ref) Source # 

Methods

(==) :: Type ref -> Type ref -> Bool #

(/=) :: Type ref -> Type ref -> Bool #

Ord ref => Ord (Type ref) Source # 

Methods

compare :: Type ref -> Type ref -> Ordering #

(<) :: Type ref -> Type ref -> Bool #

(<=) :: Type ref -> Type ref -> Bool #

(>) :: Type ref -> Type ref -> Bool #

(>=) :: Type ref -> Type ref -> Bool #

max :: Type ref -> Type ref -> Type ref #

min :: Type ref -> Type ref -> Type ref #

Show ref => Show (Type ref) Source # 

Methods

showsPrec :: Int -> Type ref -> ShowS #

show :: Type ref -> String #

showList :: [Type ref] -> ShowS #

Generic (Type ref) Source # 

Associated Types

type Rep (Type ref) :: * -> * #

Methods

from :: Type ref -> Rep (Type ref) x #

to :: Rep (Type ref) x -> Type ref #

NFData ref => NFData (Type ref) Source # 

Methods

rnf :: Type ref -> () #

type Rep (Type ref) Source # 

data TypeN r Source #

Another representation of a type, sometime easier to work with

Constructors

TypeN r [TypeN r] 

Instances

Functor TypeN Source # 

Methods

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

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

Foldable TypeN Source # 

Methods

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

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

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

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

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

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

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

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

toList :: TypeN a -> [a] #

null :: TypeN a -> Bool #

length :: TypeN a -> Int #

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

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

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

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

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

Traversable TypeN Source # 

Methods

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

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

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

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

Eq r => Eq (TypeN r) Source # 

Methods

(==) :: TypeN r -> TypeN r -> Bool #

(/=) :: TypeN r -> TypeN r -> Bool #

Ord r => Ord (TypeN r) Source # 

Methods

compare :: TypeN r -> TypeN r -> Ordering #

(<) :: TypeN r -> TypeN r -> Bool #

(<=) :: TypeN r -> TypeN r -> Bool #

(>) :: TypeN r -> TypeN r -> Bool #

(>=) :: TypeN r -> TypeN r -> Bool #

max :: TypeN r -> TypeN r -> TypeN r #

min :: TypeN r -> TypeN r -> TypeN r #

Read r => Read (TypeN r) Source # 
Show r => Show (TypeN r) Source # 

Methods

showsPrec :: Int -> TypeN r -> ShowS #

show :: TypeN r -> String #

showList :: [TypeN r] -> ShowS #

Generic (TypeN r) Source # 

Associated Types

type Rep (TypeN r) :: * -> * #

Methods

from :: TypeN r -> Rep (TypeN r) x #

to :: Rep (TypeN r) x -> TypeN r #

NFData r => NFData (TypeN r) Source # 

Methods

rnf :: TypeN r -> () #

type Rep (TypeN r) Source # 
type Rep (TypeN r) = D1 (MetaData "TypeN" "Data.Model.Types" "model-0.3-A2rozqcGuQN4U385Cv7Taj" False) (C1 (MetaCons "TypeN" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 r)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [TypeN r]))))

data TypeRef name Source #

A reference to a type

Constructors

TypVar Word8

Type variable

TypRef name

Type reference

Instances

Functor TypeRef Source # 

Methods

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

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

Foldable TypeRef Source # 

Methods

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

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

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

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

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

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

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

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

toList :: TypeRef a -> [a] #

null :: TypeRef a -> Bool #

length :: TypeRef a -> Int #

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

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

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

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

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

Traversable TypeRef Source # 

Methods

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

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

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

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

Eq name => Eq (TypeRef name) Source # 

Methods

(==) :: TypeRef name -> TypeRef name -> Bool #

(/=) :: TypeRef name -> TypeRef name -> Bool #

Ord name => Ord (TypeRef name) Source # 

Methods

compare :: TypeRef name -> TypeRef name -> Ordering #

(<) :: TypeRef name -> TypeRef name -> Bool #

(<=) :: TypeRef name -> TypeRef name -> Bool #

(>) :: TypeRef name -> TypeRef name -> Bool #

(>=) :: TypeRef name -> TypeRef name -> Bool #

max :: TypeRef name -> TypeRef name -> TypeRef name #

min :: TypeRef name -> TypeRef name -> TypeRef name #

Show name => Show (TypeRef name) Source # 

Methods

showsPrec :: Int -> TypeRef name -> ShowS #

show :: TypeRef name -> String #

showList :: [TypeRef name] -> ShowS #

Generic (TypeRef name) Source # 

Associated Types

type Rep (TypeRef name) :: * -> * #

Methods

from :: TypeRef name -> Rep (TypeRef name) x #

to :: Rep (TypeRef name) x -> TypeRef name #

NFData name => NFData (TypeRef name) Source # 

Methods

rnf :: TypeRef name -> () #

type Rep (TypeRef name) Source # 
type Rep (TypeRef name) = D1 (MetaData "TypeRef" "Data.Model.Types" "model-0.3-A2rozqcGuQN4U385Cv7Taj" False) ((:+:) (C1 (MetaCons "TypVar" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Word8))) (C1 (MetaCons "TypRef" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 name))))

Names

data Name Source #

Simple name

Constructors

Name String 

Instances

Eq Name Source # 

Methods

(==) :: Name -> Name -> Bool #

(/=) :: Name -> Name -> Bool #

Ord Name Source # 

Methods

compare :: Name -> Name -> Ordering #

(<) :: Name -> Name -> Bool #

(<=) :: Name -> Name -> Bool #

(>) :: Name -> Name -> Bool #

(>=) :: Name -> Name -> Bool #

max :: Name -> Name -> Name #

min :: Name -> Name -> Name #

Show Name Source # 

Methods

showsPrec :: Int -> Name -> ShowS #

show :: Name -> String #

showList :: [Name] -> ShowS #

Generic Name Source # 

Associated Types

type Rep Name :: * -> * #

Methods

from :: Name -> Rep Name x #

to :: Rep Name x -> Name #

StringLike Name Source # 

Methods

toString :: Name -> String #

fromString :: String -> Name #

lines :: ListLike full Name => Name -> full #

words :: ListLike full Name => Name -> full #

unlines :: ListLike full Name => full -> Name #

unwords :: ListLike full Name => full -> Name #

NFData Name Source # 

Methods

rnf :: Name -> () #

type Rep Name Source # 
type Rep Name = D1 (MetaData "Name" "Data.Model.Types" "model-0.3-A2rozqcGuQN4U385Cv7Taj" False) (C1 (MetaCons "Name" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)))

data QualName Source #

A fully qualified Haskell name

Constructors

QualName 

Instances

Eq QualName Source # 
Ord QualName Source # 
Show QualName Source # 
Generic QualName Source # 

Associated Types

type Rep QualName :: * -> * #

Methods

from :: QualName -> Rep QualName x #

to :: Rep QualName x -> QualName #

StringLike QualName Source # 

Methods

toString :: QualName -> String #

fromString :: String -> QualName #

lines :: ListLike full QualName => QualName -> full #

words :: ListLike full QualName => QualName -> full #

unlines :: ListLike full QualName => full -> QualName #

unwords :: ListLike full QualName => full -> QualName #

NFData QualName Source # 

Methods

rnf :: QualName -> () #

type Rep QualName Source # 

qualName :: QualName -> String Source #

Return the qualified name, minus the package name.

Model Utilities

adtNamesMap :: (adtName1 -> adtName2) -> (consName1 -> consName2) -> ADT adtName1 consName1 ref -> ADT adtName2 consName2 ref Source #

Map over the names of an ADT and of its constructors

typeN :: Type r -> TypeN r Source #

Convert from Type to TypeN

typeA :: TypeN ref -> Type ref Source #

Convert from TypeN to Type

constructors :: ConTree t t1 -> [ConTree t t1] Source #

Return the list of constructors in definition order

constructorInfo :: Eq consName => consName -> ConTree consName t -> Maybe ([Bool], [Type t]) Source #

Return the binary encoding and parameter types of a constructor The binary encoding is the sequence of Left (False) and Right (True) turns needed to reach the constructor from the constructor tree root. constructorInfo :: Eq consName => consName -> ADT name consName ref -> Maybe ([Bool], [Type ref]) constructorInfo consName dt = declCons dt >>= ((first reverse $) . loc [])

conTreeNameMap :: (name -> name2) -> ConTree name t -> ConTree name2 t Source #

Map over a constructor tree names

conTreeTypeMap :: (Type t -> Type ref) -> ConTree name t -> ConTree name ref Source #

Map on the constructor types (used for example when eliminating variables)

conTreeTypeList :: ConTree name t -> [Type t] Source #

Extract list of types in a constructor tree

conTreeTypeFoldMap :: Monoid a => (Type t -> a) -> ConTree name t -> a Source #

Fold over the types in a constructor tree

fieldsTypes :: Either [b] [(a, b)] -> [b] Source #

Return just the field types

fieldsNames :: Either t [(a, t1)] -> [t1] Source #

Return just the field names (or an empty list if unspecified)

Handy aliases

type HADT = ADT String String HTypeRef Source #

Haskell ADT

type HType = Type HTypeRef Source #

Haskell Type

type HTypeRef = TypeRef QualName Source #

Reference to an Haskell Type

Utilities

solve :: (Ord k, Show k) => k -> Map k a -> a Source #

Solve a key in an environment, returns an error if the key is missing

solveAll :: (Functor f, Show k, Ord k) => Map k b -> f k -> f b Source #

Solve all references in a data structure, using the given environment

unVar :: TypeRef t -> t Source #

Remove variable references (for example if we know that a type is fully saturated and cannot contain variables)

getHRef :: TypeRef a -> Maybe a Source #

Extract reference

Re-exports

data Proxy k t :: forall k. k -> * #

A concrete, poly-kinded proxy type

Constructors

Proxy 

Instances

Monad (Proxy *) 

Methods

(>>=) :: Proxy * a -> (a -> Proxy * b) -> Proxy * b #

(>>) :: Proxy * a -> Proxy * b -> Proxy * b #

return :: a -> Proxy * a #

fail :: String -> Proxy * a #

Functor (Proxy *) 

Methods

fmap :: (a -> b) -> Proxy * a -> Proxy * b #

(<$) :: a -> Proxy * b -> Proxy * a #

Applicative (Proxy *) 

Methods

pure :: a -> Proxy * a #

(<*>) :: Proxy * (a -> b) -> Proxy * a -> Proxy * b #

(*>) :: Proxy * a -> Proxy * b -> Proxy * b #

(<*) :: Proxy * a -> Proxy * b -> Proxy * a #

Foldable (Proxy *) 

Methods

fold :: Monoid m => Proxy * m -> m #

foldMap :: Monoid m => (a -> m) -> Proxy * a -> m #

foldr :: (a -> b -> b) -> b -> Proxy * a -> b #

foldr' :: (a -> b -> b) -> b -> Proxy * a -> b #

foldl :: (b -> a -> b) -> b -> Proxy * a -> b #

foldl' :: (b -> a -> b) -> b -> Proxy * a -> b #

foldr1 :: (a -> a -> a) -> Proxy * a -> a #

foldl1 :: (a -> a -> a) -> Proxy * a -> a #

toList :: Proxy * a -> [a] #

null :: Proxy * a -> Bool #

length :: Proxy * a -> Int #

elem :: Eq a => a -> Proxy * a -> Bool #

maximum :: Ord a => Proxy * a -> a #

minimum :: Ord a => Proxy * a -> a #

sum :: Num a => Proxy * a -> a #

product :: Num a => Proxy * a -> a #

Traversable (Proxy *) 

Methods

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

sequenceA :: Applicative f => Proxy * (f a) -> f (Proxy * a) #

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

sequence :: Monad m => Proxy * (m a) -> m (Proxy * a) #

Generic1 (Proxy *) 

Associated Types

type Rep1 (Proxy * :: * -> *) :: * -> * #

Methods

from1 :: Proxy * a -> Rep1 (Proxy *) a #

to1 :: Rep1 (Proxy *) a -> Proxy * a #

Alternative (Proxy *) 

Methods

empty :: Proxy * a #

(<|>) :: Proxy * a -> Proxy * a -> Proxy * a #

some :: Proxy * a -> Proxy * [a] #

many :: Proxy * a -> Proxy * [a] #

MonadPlus (Proxy *) 

Methods

mzero :: Proxy * a #

mplus :: Proxy * a -> Proxy * a -> Proxy * a #

Bounded (Proxy k s) 

Methods

minBound :: Proxy k s #

maxBound :: Proxy k s #

Enum (Proxy k s) 

Methods

succ :: Proxy k s -> Proxy k s #

pred :: Proxy k s -> Proxy k s #

toEnum :: Int -> Proxy k s #

fromEnum :: Proxy k s -> Int #

enumFrom :: Proxy k s -> [Proxy k s] #

enumFromThen :: Proxy k s -> Proxy k s -> [Proxy k s] #

enumFromTo :: Proxy k s -> Proxy k s -> [Proxy k s] #

enumFromThenTo :: Proxy k s -> Proxy k s -> Proxy k s -> [Proxy k s] #

Eq (Proxy k s) 

Methods

(==) :: Proxy k s -> Proxy k s -> Bool #

(/=) :: Proxy k s -> Proxy k s -> Bool #

Ord (Proxy k s) 

Methods

compare :: Proxy k s -> Proxy k s -> Ordering #

(<) :: Proxy k s -> Proxy k s -> Bool #

(<=) :: Proxy k s -> Proxy k s -> Bool #

(>) :: Proxy k s -> Proxy k s -> Bool #

(>=) :: Proxy k s -> Proxy k s -> Bool #

max :: Proxy k s -> Proxy k s -> Proxy k s #

min :: Proxy k s -> Proxy k s -> Proxy k s #

Read (Proxy k s) 
Show (Proxy k s) 

Methods

showsPrec :: Int -> Proxy k s -> ShowS #

show :: Proxy k s -> String #

showList :: [Proxy k s] -> ShowS #

Ix (Proxy k s) 

Methods

range :: (Proxy k s, Proxy k s) -> [Proxy k s] #

index :: (Proxy k s, Proxy k s) -> Proxy k s -> Int #

unsafeIndex :: (Proxy k s, Proxy k s) -> Proxy k s -> Int

inRange :: (Proxy k s, Proxy k s) -> Proxy k s -> Bool #

rangeSize :: (Proxy k s, Proxy k s) -> Int #

unsafeRangeSize :: (Proxy k s, Proxy k s) -> Int

Generic (Proxy k t) 

Associated Types

type Rep (Proxy k t) :: * -> * #

Methods

from :: Proxy k t -> Rep (Proxy k t) x #

to :: Rep (Proxy k t) x -> Proxy k t #

Semigroup (Proxy k s) 

Methods

(<>) :: Proxy k s -> Proxy k s -> Proxy k s #

sconcat :: NonEmpty (Proxy k s) -> Proxy k s #

stimes :: Integral b => b -> Proxy k s -> Proxy k s #

Monoid (Proxy k s) 

Methods

mempty :: Proxy k s #

mappend :: Proxy k s -> Proxy k s -> Proxy k s #

mconcat :: [Proxy k s] -> Proxy k s #

NFData (Proxy k a)

Since: 1.4.0.0

Methods

rnf :: Proxy k a -> () #

type Rep1 (Proxy *) 
type Rep1 (Proxy *) = D1 (MetaData "Proxy" "Data.Proxy" "base" False) (C1 (MetaCons "Proxy" PrefixI False) U1)
type Rep (Proxy k t) 
type Rep (Proxy k t) = D1 (MetaData "Proxy" "Data.Proxy" "base" False) (C1 (MetaCons "Proxy" PrefixI False) U1)

Orphan instances

StringLike String Source # 

Methods

toString :: String -> String #

fromString :: String -> String #

lines :: ListLike full String => String -> full #

words :: ListLike full String => String -> full #

unlines :: ListLike full String => full -> String #

unwords :: ListLike full String => full -> String #