syntactic-3.7: Generic representation and manipulation of abstract syntax

Safe HaskellNone
LanguageHaskell2010

Language.Syntactic.Sugar

Description

"Syntactic sugar"

For details, see "Combining Deep and Shallow Embedding for EDSL" (TFP 2013, http://www.cse.chalmers.se/~emax/documents/svenningsson2013combining.pdf).

Synopsis

Documentation

class Syntactic a where Source #

It is usually assumed that (desugar (sugar a)) has the same meaning as a.

Minimal complete definition

desugar, sugar

Associated Types

type Domain a :: * -> * Source #

type Internal a Source #

Methods

desugar :: a -> ASTF (Domain a) (Internal a) Source #

sugar :: ASTF (Domain a) (Internal a) -> a Source #

Instances

Syntactic (ASTFull sym a) Source # 

Associated Types

type Domain (ASTFull sym a) :: * -> * Source #

type Internal (ASTFull sym a) :: * Source #

Methods

desugar :: ASTFull sym a -> ASTF (Domain (ASTFull sym a)) (Internal (ASTFull sym a)) Source #

sugar :: ASTF (Domain (ASTFull sym a)) (Internal (ASTFull sym a)) -> ASTFull sym a Source #

Syntactic (ASTF sym a) Source # 

Associated Types

type Domain (ASTF sym a) :: * -> * Source #

type Internal (ASTF sym a) :: * Source #

Methods

desugar :: ASTF sym a -> ASTF (Domain (ASTF sym a)) (Internal (ASTF sym a)) Source #

sugar :: ASTF (Domain (ASTF sym a)) (Internal (ASTF sym a)) -> ASTF sym a Source #

resugar :: (Syntactic a, Syntactic b, Domain a ~ Domain b, Internal a ~ Internal b) => a -> b Source #

Syntactic type casting

class SyntacticN f internal | f -> internal where Source #

N-ary syntactic functions

desugarN has any type of the form:

desugarN ::
    ( Syntactic a
    , Syntactic b
    , ...
    , Syntactic x
    , Domain a ~ sym
    , Domain b ~ sym
    , ...
    , Domain x ~ sym
    ) => (a -> b -> ... -> x)
      -> (  ASTF sym (Internal a)
         -> ASTF sym (Internal b)
         -> ...
         -> ASTF sym (Internal x)
         )

...and vice versa for sugarN.

Minimal complete definition

desugarN, sugarN

Methods

desugarN :: f -> internal Source #

sugarN :: internal -> f Source #

Instances

(Syntactic f, (~) (* -> *) (Domain f) sym, (~) * fi (AST sym (Full (Internal f)))) => SyntacticN f fi Source # 

Methods

desugarN :: f -> fi Source #

sugarN :: fi -> f Source #

(Syntactic a, (~) (* -> *) (Domain a) sym, (~) * ia (Internal a), SyntacticN f fi) => SyntacticN (a -> f) (AST sym (Full ia) -> fi) Source # 

Methods

desugarN :: (a -> f) -> AST sym (Full ia) -> fi Source #

sugarN :: (AST sym (Full ia) -> fi) -> a -> f Source #

sugarSym :: (Signature sig, fi ~ SmartFun sup sig, sig ~ SmartSig fi, sup ~ SmartSym fi, SyntacticN f fi, sub :<: sup) => sub sig -> f Source #

"Sugared" symbol application

sugarSym has any type of the form:

sugarSym ::
    ( sub :<: AST sup
    , Syntactic a
    , Syntactic b
    , ...
    , Syntactic x
    , Domain a ~ Domain b ~ ... ~ Domain x
    ) => sub (Internal a :-> Internal b :-> ... :-> Full (Internal x))
      -> (a -> b -> ... -> x)

sugarSymTyped :: (Signature sig, fi ~ SmartFun (Typed sup) sig, sig ~ SmartSig fi, Typed sup ~ SmartSym fi, SyntacticN f fi, sub :<: sup, Typeable (DenResult sig)) => sub sig -> f Source #

"Sugared" symbol application

sugarSymTyped has any type of the form:

sugarSymTyped ::
    ( sub :<: AST (Typed sup)
    , Syntactic a
    , Syntactic b
    , ...
    , Syntactic x
    , Domain a ~ Domain b ~ ... ~ Domain x
    , Typeable (Internal x)
    ) => sub (Internal a :-> Internal b :-> ... :-> Full (Internal x))
      -> (a -> b -> ... -> x)