]> Git — Sourcephile - haskell/symantic.git/blob - Language/Symantic/Expr/Root.hs
factorizing Type1_From ast Type0
[haskell/symantic.git] / Language / Symantic / Expr / Root.hs
1 {-# LANGUAGE ConstraintKinds #-}
2 {-# LANGUAGE DataKinds #-}
3 {-# LANGUAGE FlexibleContexts #-}
4 {-# LANGUAGE FlexibleInstances #-}
5 {-# LANGUAGE GADTs #-}
6 {-# LANGUAGE KindSignatures #-}
7 {-# LANGUAGE MultiParamTypeClasses #-}
8 {-# LANGUAGE Rank2Types #-}
9 {-# LANGUAGE ScopedTypeVariables #-}
10 {-# LANGUAGE TypeFamilies #-}
11 {-# LANGUAGE TypeOperators #-}
12 {-# LANGUAGE UndecidableInstances #-}
13 module Language.Symantic.Expr.Root where
14
15 import Language.Symantic.Type
16
17 -- * Type 'Expr_Root'
18 -- | The root expression, passing itself as parameter to the given expression.
19 newtype Expr_Root (ex:: * -> *)
20 = Expr_Root (ex (Expr_Root ex))
21 type instance Root_of_Expr (Expr_Root ex) = Expr_Root ex
22 type instance Type_of_Expr (Expr_Root ex) = Type_of_Expr (ex (Expr_Root ex))
23
24 -- * Type family 'Root_of_Expr'
25 -- | The root expression of an expression.
26 type family Root_of_Expr (ex:: *) :: *
27
28 -- * Type family 'Type_of_Expr'
29 -- | The type of an expression, parameterized by a root type.
30 type family Type_of_Expr (ex:: *) :: {-root-}(* -> *) -> {-h-}* -> *
31
32 -- ** Type 'Type_Root_of_Expr'
33 -- | Convenient alias.
34 --
35 -- NOTE: include 'Type_Var' only to use it
36 -- within 'Error_Expr_Type_mismatch' so far.
37 type Type_Root_of_Expr (ex:: *)
38 = Type_Root (Type_Var0 :|: Type_Var1 :|: Type_of_Expr (Root_of_Expr ex))