Copyright | disco team and contributors |
---|---|
Maintainer | byorgey@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Abstract syntax trees representing the generic syntax of the Disco language. Concrete AST instances may use this module as a template.
For more detail on the approach used here, see
Najd and Peyton Jones, "Trees that Grow". Journal of Universal Computer Science, vol. 23 no. 1 (2017), 42-62. https://arxiv.org/abs/1610.04799
Essentially, we define a basic generic Term_
type, with a type
index to indicate what kind of term it is, i.e. what phase the term
belongs to. Each constructor has a type family used to define any
extra data that should go in the constructor for a particular
phase; there is also one additional constructor which can be used
to store arbitrary additional information, again governed by a type
family. Together with the use of pattern synonyms, the result is
that it looks like we have a different type for each phase, each
with its own set of constructors, but in fact all use the same
underlying type. Particular instantiations of the generic
framework here can be found in Disco.AST.Surface,
Disco.AST.Typed, and Disco.AST.Desugared.
Synopsis
- data Telescope b where
- telCons :: Alpha b => b -> Telescope b -> Telescope b
- foldTelescope :: Alpha b => (b -> r -> r) -> r -> Telescope b -> r
- mapTelescope :: (Alpha a, Alpha b) => (a -> b) -> Telescope a -> Telescope b
- traverseTelescope :: (Applicative f, Alpha a, Alpha b) => (a -> f b) -> Telescope a -> f (Telescope b)
- toTelescope :: Alpha b => [b] -> Telescope b
- fromTelescope :: Alpha b => Telescope b -> [b]
- data Side
- selectSide :: Side -> a -> a -> a
- fromSide :: Side -> Bool
- data Container where
- data Ellipsis t where
- data Term_ e where
- TVar_ :: X_TVar e -> Name (Term_ e) -> Term_ e
- TPrim_ :: X_TPrim e -> Prim -> Term_ e
- TLet_ :: X_TLet e -> Bind (Telescope (Binding_ e)) (Term_ e) -> Term_ e
- TParens_ :: X_TParens e -> Term_ e -> Term_ e
- TUnit_ :: X_TUnit e -> Term_ e
- TBool_ :: X_TBool e -> Bool -> Term_ e
- TNat_ :: X_TNat e -> Integer -> Term_ e
- TRat_ :: X_TRat e -> Rational -> Term_ e
- TChar_ :: X_TChar e -> Char -> Term_ e
- TString_ :: X_TString e -> [Char] -> Term_ e
- TAbs_ :: Quantifier -> X_TAbs e -> Binder_ e (Term_ e) -> Term_ e
- TApp_ :: X_TApp e -> Term_ e -> Term_ e -> Term_ e
- TTup_ :: X_TTup e -> [Term_ e] -> Term_ e
- TCase_ :: X_TCase e -> [Branch_ e] -> Term_ e
- TChain_ :: X_TChain e -> Term_ e -> [Link_ e] -> Term_ e
- TTyOp_ :: X_TTyOp e -> TyOp -> Type -> Term_ e
- TContainer_ :: X_TContainer e -> Container -> [(Term_ e, Maybe (Term_ e))] -> Maybe (Ellipsis (Term_ e)) -> Term_ e
- TContainerComp_ :: X_TContainerComp e -> Container -> Bind (Telescope (Qual_ e)) (Term_ e) -> Term_ e
- TAscr_ :: X_TAscr e -> Term_ e -> PolyType -> Term_ e
- XTerm_ :: X_Term e -> Term_ e
- type family X_TVar e
- type family X_TPrim e
- type family X_TLet e
- type family X_TParens e
- type family X_TUnit e
- type family X_TBool e
- type family X_TNat e
- type family X_TRat e
- type family X_TChar e
- type family X_TString e
- type family X_TAbs e
- type family X_TApp e
- type family X_TTup e
- type family X_TCase e
- type family X_TChain e
- type family X_TTyOp e
- type family X_TContainer e
- type family X_TContainerComp e
- type family X_TAscr e
- type family X_Term e
- type ForallTerm (a :: * -> Constraint) e = (a (X_TVar e), a (X_TPrim e), a (X_TLet e), a (X_TParens e), a (X_TUnit e), a (X_TBool e), a (X_TNat e), a (X_TRat e), a (X_TChar e), a (X_TString e), a (X_TAbs e), a (X_TApp e), a (X_TCase e), a (X_TTup e), a (X_TChain e), a (X_TTyOp e), a (X_TContainer e), a (X_TContainerComp e), a (X_TAscr e), a (X_Term e), a (Qual_ e), a (Guard_ e), a (Link_ e), a (Binding_ e), a (Pattern_ e), a (Binder_ e (Term_ e)))
- data Link_ e where
- type family X_TLink e
- type ForallLink (a :: * -> Constraint) e = (a (X_TLink e), a (Term_ e))
- data Qual_ e where
- type family X_QBind e
- type family X_QGuard e
- type ForallQual (a :: * -> Constraint) e = (a (X_QBind e), a (X_QGuard e), a (Term_ e))
- data Binding_ e = Binding_ (Maybe (Embed PolyType)) (Name (Term_ e)) (Embed (Term_ e))
- type Branch_ e = Bind (Telescope (Guard_ e)) (Term_ e)
- data Guard_ e where
- type family X_GBool e
- type family X_GPat e
- type family X_GLet e
- type ForallGuard (a :: * -> Constraint) e = (a (X_GBool e), a (X_GPat e), a (X_GLet e), a (Term_ e), a (Pattern_ e), a (Binding_ e))
- data Pattern_ e where
- PVar_ :: X_PVar e -> Name (Term_ e) -> Pattern_ e
- PWild_ :: X_PWild e -> Pattern_ e
- PAscr_ :: X_PAscr e -> Pattern_ e -> Type -> Pattern_ e
- PUnit_ :: X_PUnit e -> Pattern_ e
- PBool_ :: X_PBool e -> Bool -> Pattern_ e
- PTup_ :: X_PTup e -> [Pattern_ e] -> Pattern_ e
- PInj_ :: X_PInj e -> Side -> Pattern_ e -> Pattern_ e
- PNat_ :: X_PNat e -> Integer -> Pattern_ e
- PChar_ :: X_PChar e -> Char -> Pattern_ e
- PString_ :: X_PString e -> String -> Pattern_ e
- PCons_ :: X_PCons e -> Pattern_ e -> Pattern_ e -> Pattern_ e
- PList_ :: X_PList e -> [Pattern_ e] -> Pattern_ e
- PAdd_ :: X_PAdd e -> Side -> Pattern_ e -> Term_ e -> Pattern_ e
- PMul_ :: X_PMul e -> Side -> Pattern_ e -> Term_ e -> Pattern_ e
- PSub_ :: X_PSub e -> Pattern_ e -> Term_ e -> Pattern_ e
- PNeg_ :: X_PNeg e -> Pattern_ e -> Pattern_ e
- PFrac_ :: X_PFrac e -> Pattern_ e -> Pattern_ e -> Pattern_ e
- XPattern_ :: X_Pattern e -> Pattern_ e
- type family X_PVar e
- type family X_PWild e
- type family X_PAscr e
- type family X_PUnit e
- type family X_PBool e
- type family X_PTup e
- type family X_PInj e
- type family X_PNat e
- type family X_PChar e
- type family X_PString e
- type family X_PCons e
- type family X_PList e
- type family X_PAdd e
- type family X_PMul e
- type family X_PSub e
- type family X_PNeg e
- type family X_PFrac e
- type family X_Pattern e
- type ForallPattern (a :: * -> Constraint) e = (a (X_PVar e), a (X_PWild e), a (X_PAscr e), a (X_PUnit e), a (X_PBool e), a (X_PNat e), a (X_PChar e), a (X_PString e), a (X_PTup e), a (X_PInj e), a (X_PCons e), a (X_PList e), a (X_PAdd e), a (X_PMul e), a (X_PSub e), a (X_PNeg e), a (X_PFrac e), a (X_Pattern e), a (Term_ e))
- data Quantifier
- type Binder_ e a = Bind (X_Binder e) a
- type family X_Binder e
- type Property_ e = Term_ e
Telescopes
data Telescope b where Source #
A telescope is essentially a list, except that each item can bind names in the rest of the list.
TelEmpty :: Telescope b | The empty telescope. |
TelCons :: Rebind b (Telescope b) -> Telescope b | A binder of type |
Instances
Pretty Branch Source # | Pretty-print a single branch in a case expression. |
HasType ABranch Source # | |
Subst t b => Subst t (Telescope b) Source # | |
Data b => Data (Telescope b) Source # | |
Defined in Disco.AST.Generic gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Telescope b -> c (Telescope b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Telescope b) # toConstr :: Telescope b -> Constr # dataTypeOf :: Telescope b -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Telescope b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Telescope b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Telescope b -> Telescope b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Telescope b -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Telescope b -> r # gmapQ :: (forall d. Data d => d -> u) -> Telescope b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Telescope b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Telescope b -> m (Telescope b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Telescope b -> m (Telescope b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Telescope b -> m (Telescope b) # | |
Show b => Show (Telescope b) Source # | |
Generic (Telescope b) Source # | |
Alpha b => Alpha (Telescope b) Source # | |
Defined in Disco.AST.Generic aeq' :: AlphaCtx -> Telescope b -> Telescope b -> Bool # fvAny' :: (Contravariant f, Applicative f) => AlphaCtx -> (AnyName -> f AnyName) -> Telescope b -> f (Telescope b) # close :: AlphaCtx -> NamePatFind -> Telescope b -> Telescope b # open :: AlphaCtx -> NthPatFind -> Telescope b -> Telescope b # isPat :: Telescope b -> DisjointSet AnyName # isTerm :: Telescope b -> All # isEmbed :: Telescope b -> Bool # nthPatFind :: Telescope b -> NthPatFind # namePatFind :: Telescope b -> NamePatFind # swaps' :: AlphaCtx -> Perm AnyName -> Telescope b -> Telescope b # lfreshen' :: LFresh m => AlphaCtx -> Telescope b -> (Telescope b -> Perm AnyName -> m b0) -> m b0 # freshen' :: Fresh m => AlphaCtx -> Telescope b -> m (Telescope b, Perm AnyName) # acompare' :: AlphaCtx -> Telescope b -> Telescope b -> Ordering # | |
Pretty (Telescope Guard) Source # | Pretty-print the guards in a single branch of a case expression. |
Pretty (Telescope Qual) Source # | Pretty-print the qualifiers in a comprehension. |
type Rep (Telescope b) Source # | |
Defined in Disco.AST.Generic type Rep (Telescope b) = D1 ('MetaData "Telescope" "Disco.AST.Generic" "disco-0.1.5-Dj6M4uP9IofLLslCWcCyVQ" 'False) (C1 ('MetaCons "TelEmpty" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TelCons" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Rebind b (Telescope b))))) |
telCons :: Alpha b => b -> Telescope b -> Telescope b Source #
Add a new item to the beginning of a Telescope
.
foldTelescope :: Alpha b => (b -> r -> r) -> r -> Telescope b -> r Source #
Fold a telescope given a combining function and a value to use
for the empty telescope. Analogous to foldr
for lists.
mapTelescope :: (Alpha a, Alpha b) => (a -> b) -> Telescope a -> Telescope b Source #
Apply a function to every item in a telescope.
traverseTelescope :: (Applicative f, Alpha a, Alpha b) => (a -> f b) -> Telescope a -> f (Telescope b) Source #
Traverse over a telescope.
toTelescope :: Alpha b => [b] -> Telescope b Source #
Convert a list to a telescope.
fromTelescope :: Alpha b => Telescope b -> [b] Source #
Convert a telescope to a list.
Utility types
Injections into a sum type (inl
or inr
) have a "side" (L
or R
).
Instances
Bounded Side Source # | |
Enum Side Source # | |
Eq Side Source # | |
Data Side Source # | |
Defined in Disco.AST.Generic gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Side -> c Side # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Side # dataTypeOf :: Side -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Side) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Side) # gmapT :: (forall b. Data b => b -> b) -> Side -> Side # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Side -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Side -> r # gmapQ :: (forall d. Data d => d -> u) -> Side -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Side -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Side -> m Side # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Side -> m Side # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Side -> m Side # | |
Ord Side Source # | |
Show Side Source # | |
Generic Side Source # | |
Alpha Side Source # | |
Defined in Disco.AST.Generic aeq' :: AlphaCtx -> Side -> Side -> Bool # fvAny' :: (Contravariant f, Applicative f) => AlphaCtx -> (AnyName -> f AnyName) -> Side -> f Side # close :: AlphaCtx -> NamePatFind -> Side -> Side # open :: AlphaCtx -> NthPatFind -> Side -> Side # isPat :: Side -> DisjointSet AnyName # nthPatFind :: Side -> NthPatFind # namePatFind :: Side -> NamePatFind # swaps' :: AlphaCtx -> Perm AnyName -> Side -> Side # lfreshen' :: LFresh m => AlphaCtx -> Side -> (Side -> Perm AnyName -> m b) -> m b # freshen' :: Fresh m => AlphaCtx -> Side -> m (Side, Perm AnyName) # | |
Pretty Side Source # | |
Subst t Side Source # | |
type Rep Side Source # | |
selectSide :: Side -> a -> a -> a Source #
An enumeration of the different kinds of containers in disco: lists, bags, and sets.
Instances
data Ellipsis t where Source #
An ellipsis is an "omitted" part of a literal container (such as
a list or set), of the form .. t
. We don't have open-ended
ellipses since everything is evaluated eagerly and hence
containers must be finite.
Instances
Functor Ellipsis Source # | |
Foldable Ellipsis Source # | |
Defined in Disco.AST.Generic fold :: Monoid m => Ellipsis m -> m # foldMap :: Monoid m => (a -> m) -> Ellipsis a -> m # foldMap' :: Monoid m => (a -> m) -> Ellipsis a -> m # foldr :: (a -> b -> b) -> b -> Ellipsis a -> b # foldr' :: (a -> b -> b) -> b -> Ellipsis a -> b # foldl :: (b -> a -> b) -> b -> Ellipsis a -> b # foldl' :: (b -> a -> b) -> b -> Ellipsis a -> b # foldr1 :: (a -> a -> a) -> Ellipsis a -> a # foldl1 :: (a -> a -> a) -> Ellipsis a -> a # elem :: Eq a => a -> Ellipsis a -> Bool # maximum :: Ord a => Ellipsis a -> a # minimum :: Ord a => Ellipsis a -> a # | |
Traversable Ellipsis Source # | |
Subst a t => Subst a (Ellipsis t) Source # | |
Data t => Data (Ellipsis t) Source # | |
Defined in Disco.AST.Generic gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ellipsis t -> c (Ellipsis t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Ellipsis t) # toConstr :: Ellipsis t -> Constr # dataTypeOf :: Ellipsis t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Ellipsis t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Ellipsis t)) # gmapT :: (forall b. Data b => b -> b) -> Ellipsis t -> Ellipsis t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ellipsis t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ellipsis t -> r # gmapQ :: (forall d. Data d => d -> u) -> Ellipsis t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Ellipsis t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ellipsis t -> m (Ellipsis t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ellipsis t -> m (Ellipsis t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ellipsis t -> m (Ellipsis t) # | |
Show t => Show (Ellipsis t) Source # | |
Generic (Ellipsis t) Source # | |
Alpha t => Alpha (Ellipsis t) Source # | |
Defined in Disco.AST.Generic aeq' :: AlphaCtx -> Ellipsis t -> Ellipsis t -> Bool # fvAny' :: (Contravariant f, Applicative f) => AlphaCtx -> (AnyName -> f AnyName) -> Ellipsis t -> f (Ellipsis t) # close :: AlphaCtx -> NamePatFind -> Ellipsis t -> Ellipsis t # open :: AlphaCtx -> NthPatFind -> Ellipsis t -> Ellipsis t # isPat :: Ellipsis t -> DisjointSet AnyName # isEmbed :: Ellipsis t -> Bool # nthPatFind :: Ellipsis t -> NthPatFind # namePatFind :: Ellipsis t -> NamePatFind # swaps' :: AlphaCtx -> Perm AnyName -> Ellipsis t -> Ellipsis t # lfreshen' :: LFresh m => AlphaCtx -> Ellipsis t -> (Ellipsis t -> Perm AnyName -> m b) -> m b # freshen' :: Fresh m => AlphaCtx -> Ellipsis t -> m (Ellipsis t, Perm AnyName) # acompare' :: AlphaCtx -> Ellipsis t -> Ellipsis t -> Ordering # | |
type Rep (Ellipsis t) Source # | |
Defined in Disco.AST.Generic |
Term
The base generic AST representing terms in the disco language.
e
is a type index indicating the kind of term, i.e. the phase
(for example, surface, typed, or desugared). Type families like
X_TVar
and so on use the phase index to determine what extra
information (if any) should be stored in each constructor. For
example, in the typed phase many constructors store an extra
type, giving the type of the term.
TVar_ :: X_TVar e -> Name (Term_ e) -> Term_ e | A term variable. |
TPrim_ :: X_TPrim e -> Prim -> Term_ e | A primitive, i.e. a constant which is interpreted specially at runtime. See Disco.Syntax.Prims. |
TLet_ :: X_TLet e -> Bind (Telescope (Binding_ e)) (Term_ e) -> Term_ e | A (non-recursive) let expression, |
TParens_ :: X_TParens e -> Term_ e -> Term_ e | Explicit parentheses. We need to keep track of these in the surface syntax in order to syntactically distinguish multiplication and function application. However, note that these disappear after the surface syntax phase. |
TUnit_ :: X_TUnit e -> Term_ e | The unit value, (), of type Unit. |
TBool_ :: X_TBool e -> Bool -> Term_ e | A boolean value. |
TNat_ :: X_TNat e -> Integer -> Term_ e | A natural number. |
TRat_ :: X_TRat e -> Rational -> Term_ e | A nonnegative rational number, parsed as a decimal. (Note
syntax like |
TChar_ :: X_TChar e -> Char -> Term_ e | A literal unicode character, e.g. |
TString_ :: X_TString e -> [Char] -> Term_ e | A string literal, e.g. |
TAbs_ :: Quantifier -> X_TAbs e -> Binder_ e (Term_ e) -> Term_ e | A binding abstraction, of the form |
TApp_ :: X_TApp e -> Term_ e -> Term_ e -> Term_ e | Function application, |
TTup_ :: X_TTup e -> [Term_ e] -> Term_ e | An n-tuple, |
TCase_ :: X_TCase e -> [Branch_ e] -> Term_ e | A case expression. |
TChain_ :: X_TChain e -> Term_ e -> [Link_ e] -> Term_ e | A chained comparison, consisting of a term followed by one or more "links", where each link is a comparison operator and another term. |
TTyOp_ :: X_TTyOp e -> TyOp -> Type -> Term_ e | An application of a type operator. |
TContainer_ :: X_TContainer e -> Container -> [(Term_ e, Maybe (Term_ e))] -> Maybe (Ellipsis (Term_ e)) -> Term_ e | A containter literal (set, bag, or list). |
TContainerComp_ :: X_TContainerComp e -> Container -> Bind (Telescope (Qual_ e)) (Term_ e) -> Term_ e | A container comprehension. |
TAscr_ :: X_TAscr e -> Term_ e -> PolyType -> Term_ e | Type ascription, |
XTerm_ :: X_Term e -> Term_ e | A data constructor with an extension descriptor that a "concrete" implementation of a generic AST may use to carry extra information. |
Instances
type family X_TContainer e Source #
Instances
type X_TContainer UD Source # | |
Defined in Disco.AST.Surface |
type family X_TContainerComp e Source #
Instances
type X_TContainerComp UD Source # | |
Defined in Disco.AST.Surface |
type ForallTerm (a :: * -> Constraint) e = (a (X_TVar e), a (X_TPrim e), a (X_TLet e), a (X_TParens e), a (X_TUnit e), a (X_TBool e), a (X_TNat e), a (X_TRat e), a (X_TChar e), a (X_TString e), a (X_TAbs e), a (X_TApp e), a (X_TCase e), a (X_TTup e), a (X_TChain e), a (X_TTyOp e), a (X_TContainer e), a (X_TContainerComp e), a (X_TAscr e), a (X_Term e), a (Qual_ e), a (Guard_ e), a (Link_ e), a (Binding_ e), a (Pattern_ e), a (Binder_ e (Term_ e))) Source #
Link
A "link" is a comparison operator and a term; a single term
followed by a sequence of links makes up a comparison chain, such
as 2 < x < y < 10
.
TLink_ :: X_TLink e -> BOp -> Term_ e -> Link_ e | Note that although the type of |
Instances
ForallLink (Subst Type) e => Subst Type (Link_ e) Source # | |
(Typeable e, Data e, ForallLink Data e) => Data (Link_ e) Source # | |
Defined in Disco.AST.Generic gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Link_ e -> c (Link_ e) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Link_ e) # toConstr :: Link_ e -> Constr # dataTypeOf :: Link_ e -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Link_ e)) # dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (Link_ e)) # gmapT :: (forall b. Data b => b -> b) -> Link_ e -> Link_ e # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Link_ e -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Link_ e -> r # gmapQ :: (forall d. Data d => d -> u) -> Link_ e -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Link_ e -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Link_ e -> m (Link_ e) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Link_ e -> m (Link_ e) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Link_ e -> m (Link_ e) # | |
ForallLink Show e => Show (Link_ e) Source # | |
Generic (Link_ e) Source # | |
(Typeable e, Show (Link_ e), ForallLink Alpha e) => Alpha (Link_ e) Source # | |
Defined in Disco.AST.Generic aeq' :: AlphaCtx -> Link_ e -> Link_ e -> Bool # fvAny' :: (Contravariant f, Applicative f) => AlphaCtx -> (AnyName -> f AnyName) -> Link_ e -> f (Link_ e) # close :: AlphaCtx -> NamePatFind -> Link_ e -> Link_ e # open :: AlphaCtx -> NthPatFind -> Link_ e -> Link_ e # isPat :: Link_ e -> DisjointSet AnyName # nthPatFind :: Link_ e -> NthPatFind # namePatFind :: Link_ e -> NamePatFind # swaps' :: AlphaCtx -> Perm AnyName -> Link_ e -> Link_ e # lfreshen' :: LFresh m => AlphaCtx -> Link_ e -> (Link_ e -> Perm AnyName -> m b) -> m b # freshen' :: Fresh m => AlphaCtx -> Link_ e -> m (Link_ e, Perm AnyName) # | |
type Rep (Link_ e) Source # | |
Defined in Disco.AST.Generic type Rep (Link_ e) = D1 ('MetaData "Link_" "Disco.AST.Generic" "disco-0.1.5-Dj6M4uP9IofLLslCWcCyVQ" 'False) (C1 ('MetaCons "TLink_" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (X_TLink e)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BOp) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term_ e))))) |
type ForallLink (a :: * -> Constraint) e = (a (X_TLink e), a (Term_ e)) Source #
Qual
A container comprehension consists of a head term and then a list of qualifiers. Each qualifier either binds a variable to some collection or consists of a boolean guard.
QBind_ :: X_QBind e -> Name (Term_ e) -> Embed (Term_ e) -> Qual_ e | A binding qualifier (i.e. |
QGuard_ :: X_QGuard e -> Embed (Term_ e) -> Qual_ e | A boolean guard qualfier (i.e. |
Instances
Pretty Qual Source # | Pretty-print a single qualifier in a comprehension. |
ForallQual (Subst Type) e => Subst Type (Qual_ e) Source # | |
(Typeable e, Data e, ForallQual Data e) => Data (Qual_ e) Source # | |
Defined in Disco.AST.Generic gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Qual_ e -> c (Qual_ e) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Qual_ e) # toConstr :: Qual_ e -> Constr # dataTypeOf :: Qual_ e -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Qual_ e)) # dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (Qual_ e)) # gmapT :: (forall b. Data b => b -> b) -> Qual_ e -> Qual_ e # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Qual_ e -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Qual_ e -> r # gmapQ :: (forall d. Data d => d -> u) -> Qual_ e -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Qual_ e -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Qual_ e -> m (Qual_ e) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Qual_ e -> m (Qual_ e) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Qual_ e -> m (Qual_ e) # | |
ForallQual Show e => Show (Qual_ e) Source # | |
Generic (Qual_ e) Source # | |
(Typeable e, ForallQual Alpha e) => Alpha (Qual_ e) Source # | |
Defined in Disco.AST.Generic aeq' :: AlphaCtx -> Qual_ e -> Qual_ e -> Bool # fvAny' :: (Contravariant f, Applicative f) => AlphaCtx -> (AnyName -> f AnyName) -> Qual_ e -> f (Qual_ e) # close :: AlphaCtx -> NamePatFind -> Qual_ e -> Qual_ e # open :: AlphaCtx -> NthPatFind -> Qual_ e -> Qual_ e # isPat :: Qual_ e -> DisjointSet AnyName # nthPatFind :: Qual_ e -> NthPatFind # namePatFind :: Qual_ e -> NamePatFind # swaps' :: AlphaCtx -> Perm AnyName -> Qual_ e -> Qual_ e # lfreshen' :: LFresh m => AlphaCtx -> Qual_ e -> (Qual_ e -> Perm AnyName -> m b) -> m b # freshen' :: Fresh m => AlphaCtx -> Qual_ e -> m (Qual_ e, Perm AnyName) # | |
Pretty (Telescope Qual) Source # | Pretty-print the qualifiers in a comprehension. |
type Rep (Qual_ e) Source # | |
Defined in Disco.AST.Generic type Rep (Qual_ e) = D1 ('MetaData "Qual_" "Disco.AST.Generic" "disco-0.1.5-Dj6M4uP9IofLLslCWcCyVQ" 'False) (C1 ('MetaCons "QBind_" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (X_QBind e)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Name (Term_ e))) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Embed (Term_ e))))) :+: C1 ('MetaCons "QGuard_" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (X_QGuard e)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Embed (Term_ e))))) |
type ForallQual (a :: * -> Constraint) e = (a (X_QBind e), a (X_QGuard e), a (Term_ e)) Source #
Binding
A binding is a name along with its definition, and optionally its type.
Instances
Branch
type Branch_ e = Bind (Telescope (Guard_ e)) (Term_ e) Source #
A branch of a case is a list of guards with an accompanying term. The guards scope over the term. Additionally, each guard scopes over subsequent guards.
Guard
Guards in case expressions.
GBool_ :: X_GBool e -> Embed (Term_ e) -> Guard_ e | Boolean guard ( |
GPat_ :: X_GPat e -> Embed (Term_ e) -> Pattern_ e -> Guard_ e | Pattern guard ( |
GLet_ :: X_GLet e -> Binding_ e -> Guard_ e | Let ( |
Instances
type ForallGuard (a :: * -> Constraint) e = (a (X_GBool e), a (X_GPat e), a (X_GLet e), a (Term_ e), a (Pattern_ e), a (Binding_ e)) Source #
Pattern
data Pattern_ e where Source #
Patterns.
PVar_ :: X_PVar e -> Name (Term_ e) -> Pattern_ e | Variable pattern: matches anything and binds the variable. |
PWild_ :: X_PWild e -> Pattern_ e | Wildcard pattern |
PAscr_ :: X_PAscr e -> Pattern_ e -> Type -> Pattern_ e | Type ascription pattern |
PUnit_ :: X_PUnit e -> Pattern_ e | Unit pattern |
PBool_ :: X_PBool e -> Bool -> Pattern_ e | Literal boolean pattern. |
PTup_ :: X_PTup e -> [Pattern_ e] -> Pattern_ e | Tuple pattern |
PInj_ :: X_PInj e -> Side -> Pattern_ e -> Pattern_ e | Injection pattern ( |
PNat_ :: X_PNat e -> Integer -> Pattern_ e | Literal natural number pattern. |
PChar_ :: X_PChar e -> Char -> Pattern_ e | Unicode character pattern |
PString_ :: X_PString e -> String -> Pattern_ e | String pattern. |
PCons_ :: X_PCons e -> Pattern_ e -> Pattern_ e -> Pattern_ e | Cons pattern |
PList_ :: X_PList e -> [Pattern_ e] -> Pattern_ e | List pattern |
PAdd_ :: X_PAdd e -> Side -> Pattern_ e -> Term_ e -> Pattern_ e | Addition pattern, |
PMul_ :: X_PMul e -> Side -> Pattern_ e -> Term_ e -> Pattern_ e | Multiplication pattern, |
PSub_ :: X_PSub e -> Pattern_ e -> Term_ e -> Pattern_ e | Subtraction pattern, |
PNeg_ :: X_PNeg e -> Pattern_ e -> Pattern_ e | Negation pattern, |
PFrac_ :: X_PFrac e -> Pattern_ e -> Pattern_ e -> Pattern_ e | Fraction pattern, |
XPattern_ :: X_Pattern e -> Pattern_ e | Expansion slot. |
Instances
type ForallPattern (a :: * -> Constraint) e = (a (X_PVar e), a (X_PWild e), a (X_PAscr e), a (X_PUnit e), a (X_PBool e), a (X_PNat e), a (X_PChar e), a (X_PString e), a (X_PTup e), a (X_PInj e), a (X_PCons e), a (X_PList e), a (X_PAdd e), a (X_PMul e), a (X_PSub e), a (X_PNeg e), a (X_PFrac e), a (X_Pattern e), a (Term_ e)) Source #
Quantifiers
data Quantifier Source #
A quantifier: λ, ∀, or ∃
Instances
type Binder_ e a = Bind (X_Binder e) a Source #
A binder represents the stuff between the quantifier and the body
of a lambda, ∀, or ∃ abstraction, as in x : N, r : F
.
type family X_Binder e Source #
A type family specifying what the binder in an abstraction can be. Should have at least variables in it, but how many variables and what other information is carried along may vary.
Property
Orphan instances
Alpha Void Source # | |
aeq' :: AlphaCtx -> Void -> Void -> Bool # fvAny' :: (Contravariant f, Applicative f) => AlphaCtx -> (AnyName -> f AnyName) -> Void -> f Void # close :: AlphaCtx -> NamePatFind -> Void -> Void # open :: AlphaCtx -> NthPatFind -> Void -> Void # isPat :: Void -> DisjointSet AnyName # nthPatFind :: Void -> NthPatFind # namePatFind :: Void -> NamePatFind # swaps' :: AlphaCtx -> Perm AnyName -> Void -> Void # lfreshen' :: LFresh m => AlphaCtx -> Void -> (Void -> Perm AnyName -> m b) -> m b # freshen' :: Fresh m => AlphaCtx -> Void -> m (Void, Perm AnyName) # |