syntactic-1.11: Generic abstract syntax, and utilities for embedded languages

Safe HaskellNone

Language.Syntactic.Sugar

Description

"Syntactic sugar"

Synopsis

Documentation

class Syntactic a whereSource

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

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) -> aSource

Instances

(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, IsHODomain dom p pVar, p (Internal a -> Internal b), p (Internal a), pVar (Internal a)) => Syntactic (a -> b) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, InjectC Tuple dom (Internal a, Internal b), InjectC Select dom (Internal a), InjectC Select dom (Internal b)) => Syntactic (a, b) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, TupleSat dom p, p (Internal a, Internal b), p (Internal a), p (Internal b), InjectC (:|| Tuple p) dom (Internal a, Internal b), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b)) => Syntactic (a, b) 
Syntactic (ASTF dom a) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, InjectC Tuple dom (Internal a, Internal b, Internal c), InjectC Select dom (Internal a), InjectC Select dom (Internal b), InjectC Select dom (Internal c)) => Syntactic (a, b, c) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, TupleSat dom p, p (Internal a, Internal b, Internal c), p (Internal a), p (Internal b), p (Internal c), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c)) => Syntactic (a, b, c) 
(Syntactic a, ~ (* -> *) (Domain a) dom, IsHODomain dom Typeable pVar, InjectC (MONAD m) dom (m (Internal a)), Monad m, Typeable1 m, Typeable (Internal a), pVar (Internal a)) => Syntactic (Mon dom m a) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, InjectC Tuple dom (Internal a, Internal b, Internal c, Internal d), InjectC Select dom (Internal a), InjectC Select dom (Internal b), InjectC Select dom (Internal c), InjectC Select dom (Internal d)) => Syntactic (a, b, c, d) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, TupleSat dom p, p (Internal a, Internal b, Internal c, Internal d), p (Internal a), p (Internal b), p (Internal c), p (Internal d), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c, Internal d), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c), InjectC (:|| Select p) dom (Internal d)) => Syntactic (a, b, c, d) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, Syntactic e, ~ (* -> *) (Domain e) dom, InjectC Tuple dom (Internal a, Internal b, Internal c, Internal d, Internal e), InjectC Select dom (Internal a), InjectC Select dom (Internal b), InjectC Select dom (Internal c), InjectC Select dom (Internal d), InjectC Select dom (Internal e)) => Syntactic (a, b, c, d, e) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, Syntactic e, ~ (* -> *) (Domain e) dom, TupleSat dom p, p (Internal a, Internal b, Internal c, Internal d, Internal e), p (Internal a), p (Internal b), p (Internal c), p (Internal d), p (Internal e), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c, Internal d, Internal e), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c), InjectC (:|| Select p) dom (Internal d), InjectC (:|| Select p) dom (Internal e)) => Syntactic (a, b, c, d, e) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, Syntactic e, ~ (* -> *) (Domain e) dom, Syntactic f, ~ (* -> *) (Domain f) dom, InjectC Tuple dom (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f), InjectC Select dom (Internal a), InjectC Select dom (Internal b), InjectC Select dom (Internal c), InjectC Select dom (Internal d), InjectC Select dom (Internal e), InjectC Select dom (Internal f)) => Syntactic (a, b, c, d, e, f) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, Syntactic e, ~ (* -> *) (Domain e) dom, Syntactic f, ~ (* -> *) (Domain f) dom, TupleSat dom p, p (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f), p (Internal a), p (Internal b), p (Internal c), p (Internal d), p (Internal e), p (Internal f), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c), InjectC (:|| Select p) dom (Internal d), InjectC (:|| Select p) dom (Internal e), InjectC (:|| Select p) dom (Internal f)) => Syntactic (a, b, c, d, e, f) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, Syntactic e, ~ (* -> *) (Domain e) dom, Syntactic f, ~ (* -> *) (Domain f) dom, Syntactic g, ~ (* -> *) (Domain g) dom, InjectC Tuple dom (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f, Internal g), InjectC Select dom (Internal a), InjectC Select dom (Internal b), InjectC Select dom (Internal c), InjectC Select dom (Internal d), InjectC Select dom (Internal e), InjectC Select dom (Internal f), InjectC Select dom (Internal g)) => Syntactic (a, b, c, d, e, f, g) 
(Syntactic a, ~ (* -> *) (Domain a) dom, Syntactic b, ~ (* -> *) (Domain b) dom, Syntactic c, ~ (* -> *) (Domain c) dom, Syntactic d, ~ (* -> *) (Domain d) dom, Syntactic e, ~ (* -> *) (Domain e) dom, Syntactic f, ~ (* -> *) (Domain f) dom, Syntactic g, ~ (* -> *) (Domain g) dom, TupleSat dom p, p (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f, Internal g), p (Internal a), p (Internal b), p (Internal c), p (Internal d), p (Internal e), p (Internal f), p (Internal g), InjectC (:|| Tuple p) dom (Internal a, Internal b, Internal c, Internal d, Internal e, Internal f, Internal g), InjectC (:|| Select p) dom (Internal a), InjectC (:|| Select p) dom (Internal b), InjectC (:|| Select p) dom (Internal c), InjectC (:|| Select p) dom (Internal d), InjectC (:|| Select p) dom (Internal e), InjectC (:|| Select p) dom (Internal f), InjectC (:|| Select p) dom (Internal g)) => Syntactic (a, b, c, d, e, f, g) 

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

Syntactic type casting

class SyntacticN a internal | a -> internal whereSource

N-ary syntactic functions

desugarN has any type of the form:

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

...and vice versa for sugarN.

Methods

desugarN :: a -> internalSource

sugarN :: internal -> aSource

Instances

(Syntactic a, ~ (* -> *) (Domain a) dom, ~ * ia (AST dom (Full (Internal a)))) => SyntacticN a ia 
(Syntactic a, ~ (* -> *) (Domain a) dom, ~ * ia (Internal a), SyntacticN b ib) => SyntacticN (a -> b) (AST dom (Full ia) -> ib) 

sugarSym :: (sym :<: AST dom, ApplySym sig b dom, SyntacticN c b) => sym sig -> cSource

"Sugared" symbol application

sugarSym has any type of the form:

 sugarSym ::
     ( expr :<: AST dom
     , Syntactic a dom
     , Syntactic b dom
     , ...
     , Syntactic x dom
     ) => expr (Internal a :-> Internal b :-> ... :-> Full (Internal x))
       -> (a -> b -> ... -> x)

sugarSymC :: (InjectC sym (AST dom) (DenResult sig), ApplySym sig b dom, SyntacticN c b) => sym sig -> cSource

"Sugared" symbol application

sugarSymC has any type of the form:

 sugarSymC ::
     ( InjectC expr (AST dom) (Internal x)
     , Syntactic a dom
     , Syntactic b dom
     , ...
     , Syntactic x dom
     ) => expr (Internal a :-> Internal b :-> ... :-> Full (Internal x))
       -> (a -> b -> ... -> x)