Copyright | disco team and contributors |
---|---|
License | BSD-3-Clause |
Maintainer | byorgey@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Abstract syntax trees representing the desugared, untyped core language for Disco.
Synopsis
- data RationalDisplay
- data Core where
- CVar :: QName Core -> Core
- CNum :: RationalDisplay -> Rational -> Core
- CConst :: Op -> Core
- CInj :: Side -> Core -> Core
- CCase :: Core -> Bind (Name Core) Core -> Bind (Name Core) Core -> Core
- CUnit :: Core
- CPair :: Core -> Core -> Core
- CProj :: Side -> Core -> Core
- CAbs :: Bind [Name Core] Core -> Core
- CApp :: Core -> Core -> Core
- CTest :: [(String, Type, Name Core)] -> Core -> Core
- CType :: Type -> Core
- CDelay :: Bind [Name Core] [Core] -> Core
- CForce :: Core -> Core
- data Op
- = OAdd
- | ONeg
- | OSqrt
- | OFloor
- | OCeil
- | OAbs
- | OMul
- | ODiv
- | OExp
- | OMod
- | ODivides
- | OMultinom
- | OFact
- | OEq
- | OLt
- | OEnum
- | OCount
- | OPower
- | OBagElem
- | OListElem
- | OEachBag
- | OEachSet
- | OFilterBag
- | OMerge
- | OBagUnions
- | OSummary
- | OEmptyGraph
- | OVertex
- | OOverlay
- | OConnect
- | OInsert
- | OLookup
- | OUntil
- | OSetToList
- | OBagToSet
- | OBagToList
- | OListToSet
- | OListToBag
- | OBagToCounts
- | OCountsToBag
- | OUnsafeCountsToBag
- | OMapToSet
- | OSetToMap
- | OIsPrime
- | OFactor
- | OFrac
- | OForall [Type]
- | OExists [Type]
- | OHolds
- | ONotProp
- | OShouldEq Type
- | OMatchErr
- | OCrash
- | OId
- | OLookupSeq
- | OExtendSeq
- opArity :: Op -> Int
- substQC :: QName Core -> Core -> Core -> Core
- substsQC :: [(QName Core, Core)] -> Core -> Core
Core AST
data RationalDisplay Source #
A type of flags specifying whether to display a rational number as a fraction or a decimal.
Instances
AST for the desugared, untyped core language.
CVar :: QName Core -> Core | A variable. |
CNum :: RationalDisplay -> Rational -> Core | A rational number. |
CConst :: Op -> Core | A built-in constant. |
CInj :: Side -> Core -> Core | An injection into a sum type, i.e. a value together with a tag
indicating which element of a sum type we are in. For example,
false is represented by |
CCase :: Core -> Bind (Name Core) Core -> Bind (Name Core) Core -> Core | A primitive case expression on a value of a sum type. |
CUnit :: Core | The unit value. |
CPair :: Core -> Core -> Core | A pair of values. |
CProj :: Side -> Core -> Core | A projection from a product type, i.e. |
CAbs :: Bind [Name Core] Core -> Core | An anonymous function. |
CApp :: Core -> Core -> Core | Function application. |
CTest :: [(String, Type, Name Core)] -> Core -> Core | A "test frame" under which a test case is run. Records the types and legible names of the variables that should be reported to the user if the test fails. |
CType :: Type -> Core | A type. |
CDelay :: Bind [Name Core] [Core] -> Core | Introduction form for a lazily evaluated value of type Lazy T for some type T. We can have multiple bindings to multiple terms to create a simple target for compiling mutual recursion. |
CForce :: Core -> Core | Force evaluation of a lazy value. |
Instances
Operators that can show up in the core language. Note that not all surface language operators show up here, since some are desugared into combinators of the operators here.
OAdd | Addition ( |
ONeg | Arithmetic negation ( |
OSqrt | Integer square root ( |
OFloor | Floor of fractional type ( |
OCeil | Ceiling of fractional type ( |
OAbs | Absolute value ( |
OMul | Multiplication ( |
ODiv | Division ( |
OExp | Exponentiation ( |
OMod | Modulo ( |
ODivides | Divisibility test ( |
OMultinom | Multinomial coefficient ( |
OFact | Factorial ( |
OEq | Equality test ( |
OLt | Less than ( |
OEnum | Enumerate the values of a type. |
OCount | Count the values of a type. |
OPower | Power setbag of a given setbag
( |
OBagElem | Set/bag element test. |
OListElem | List element test. |
OEachBag | Map a function over a bag. Carries the output type of the function. |
OEachSet | Map a function over a set. Carries the output type of the function. |
OFilterBag | Filter a bag. |
OMerge | Merge two bags/sets. |
OBagUnions | Bag join, i.e. union a bag of bags. |
OSummary | Adjacency List of given graph |
OEmptyGraph | Empty graph |
OVertex | Construct a vertex with given value |
OOverlay | Graph overlay |
OConnect | Graph connect |
OInsert | Map insert |
OLookup | Map lookup |
OUntil | Continue until end, |
OSetToList | set -> list conversion (sorted order). |
OBagToSet | bag -> set conversion (forget duplicates). |
OBagToList | bag -> list conversion (sorted order). |
OListToSet | list -> set conversion (forget order, duplicates). |
OListToBag | list -> bag conversion (forget order). |
OBagToCounts | bag -> set of counts |
OCountsToBag | set of counts -> bag |
OUnsafeCountsToBag | unsafe set of counts -> bag, assumes all are distinct |
OMapToSet | Map k v -> Set (k × v) |
OSetToMap | Set (k × v) -> Map k v |
OIsPrime | Primality test |
OFactor | Factorization |
OFrac | Turn a rational into a (num, denom) pair |
OForall [Type] | Universal quantification. Applied to a closure
|
OExists [Type] | Existential quantification. Applied to a closure
|
OHolds | Convert Prop -> Bool via exhaustive search. |
ONotProp | Flip success and failure for a prop. |
OShouldEq Type | Equality assertion, |
OMatchErr | Error for non-exhaustive pattern match |
OCrash | Crash with a user-supplied message |
OId | No-op/identity function |
OLookupSeq | Lookup OEIS sequence |
OExtendSeq | Extend a List via OEIS |
Instances
Eq Op Source # | |
Data Op Source # | |
Defined in Disco.AST.Core gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Op -> c Op # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Op # dataTypeOf :: Op -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Op) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Op) # gmapT :: (forall b. Data b => b -> b) -> Op -> Op # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Op -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Op -> r # gmapQ :: (forall d. Data d => d -> u) -> Op -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Op -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Op -> m Op # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Op -> m Op # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Op -> m Op # | |
Ord Op Source # | |
Show Op Source # | |
Generic Op Source # | |
Alpha Op Source # | |
Defined in Disco.AST.Core aeq' :: AlphaCtx -> Op -> Op -> Bool # fvAny' :: (Contravariant f, Applicative f) => AlphaCtx -> (AnyName -> f AnyName) -> Op -> f Op # close :: AlphaCtx -> NamePatFind -> Op -> Op # open :: AlphaCtx -> NthPatFind -> Op -> Op # isPat :: Op -> DisjointSet AnyName # nthPatFind :: Op -> NthPatFind # namePatFind :: Op -> NamePatFind # swaps' :: AlphaCtx -> Perm AnyName -> Op -> Op # lfreshen' :: LFresh m => AlphaCtx -> Op -> (Op -> Perm AnyName -> m b) -> m b # freshen' :: Fresh m => AlphaCtx -> Op -> m (Op, Perm AnyName) # | |
Pretty Op Source # | |
type Rep Op Source # | |
Defined in Disco.AST.Core type Rep Op = D1 ('MetaData "Op" "Disco.AST.Core" "disco-0.1.4-1clYYKcZnjx9lpTJaM1Fby" 'False) (((((C1 ('MetaCons "OAdd" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ONeg" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OSqrt" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "OFloor" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OCeil" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OAbs" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OMul" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "ODiv" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OExp" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OMod" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "ODivides" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OMultinom" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OFact" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OEq" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "OLt" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OEnum" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OCount" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "OPower" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OBagElem" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OListElem" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OEachBag" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "OEachSet" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OFilterBag" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OMerge" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "OBagUnions" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OSummary" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OEmptyGraph" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OVertex" 'PrefixI 'False) (U1 :: Type -> Type)))))) :+: ((((C1 ('MetaCons "OOverlay" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OConnect" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OInsert" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "OLookup" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OUntil" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OSetToList" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OBagToSet" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "OBagToList" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OListToSet" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OListToBag" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "OBagToCounts" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OCountsToBag" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OUnsafeCountsToBag" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OMapToSet" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "OSetToMap" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OIsPrime" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OFactor" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "OFrac" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OForall" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Type]))) :+: (C1 ('MetaCons "OExists" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Type])) :+: C1 ('MetaCons "OHolds" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "ONotProp" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OShouldEq" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type)) :+: C1 ('MetaCons "OMatchErr" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "OCrash" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OId" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OLookupSeq" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OExtendSeq" 'PrefixI 'False) (U1 :: Type -> Type))))))) |
Get the arity (desired number of arguments) of a function constant. A few constants have arity 0; everything else is uncurried and hence has arity 1.