module DDC.Core.Exp.Simple
( module DDC.Type.Exp
, Exp (..)
, Cast (..)
, Lets (..)
, Alt (..)
, Pat (..)
, Witness (..)
, DaCon (..)
, WiCon (..)
, WbCon (..))
where
import DDC.Core.Exp.WiCon
import DDC.Core.Exp.DaCon
import DDC.Core.Exp.Pat
import DDC.Type.Exp
import DDC.Type.Sum ()
import Control.DeepSeq
data Exp a n
= XAnnot a (Exp a n)
| XVar !(Bound n)
| XCon !(DaCon n)
| XLAM !(Bind n) !(Exp a n)
| XLam !(Bind n) !(Exp a n)
| XApp !(Exp a n) !(Exp a n)
| XLet !(Lets a n) !(Exp a n)
| XCase !(Exp a n) ![Alt a n]
| XCast !(Cast a n) !(Exp a n)
| XType !(Type n)
| XWitness !(Witness a n)
deriving (Show, Eq)
data Lets a n
= LLet !(Bind n) !(Exp a n)
| LRec ![(Bind n, Exp a n)]
| LPrivate ![Bind n] !(Maybe (Type n)) ![Bind n]
| LWithRegion !(Bound n)
deriving (Show, Eq)
data Alt a n
= AAlt !(Pat n) !(Exp a n)
deriving (Show, Eq)
data Witness a n
= WAnnot a (Witness a n)
| WVar !(Bound n)
| WCon !(WiCon n)
| WApp !(Witness a n) !(Witness a n)
| WJoin !(Witness a n) !(Witness a n)
| WType !(Type n)
deriving (Show, Eq)
data Cast a n
= CastWeakenEffect !(Effect n)
| CastWeakenClosure ![Exp a n]
| CastPurify !(Witness a n)
| CastForget !(Witness a n)
| CastBox
| CastRun
deriving (Show, Eq)
instance (NFData a, NFData n) => NFData (Exp a n) where
rnf xx
= case xx of
XAnnot a x -> rnf a `seq` rnf x
XVar u -> rnf u
XCon dc -> rnf dc
XLAM b x -> rnf b `seq` rnf x
XLam b x -> rnf b `seq` rnf x
XApp x1 x2 -> rnf x1 `seq` rnf x2
XLet lts x -> rnf lts `seq` rnf x
XCase x alts -> rnf x `seq` rnf alts
XCast c x -> rnf c `seq` rnf x
XType t -> rnf t
XWitness w -> rnf w
instance (NFData a, NFData n) => NFData (Cast a n) where
rnf cc
= case cc of
CastWeakenEffect e -> rnf e
CastWeakenClosure xs -> rnf xs
CastPurify w -> rnf w
CastForget w -> rnf w
CastBox -> ()
CastRun -> ()
instance (NFData a, NFData n) => NFData (Lets a n) where
rnf lts
= case lts of
LLet b x -> rnf b `seq` rnf x
LRec bxs -> rnf bxs
LPrivate bs1 t2 bs3 -> rnf bs1 `seq` rnf t2 `seq` rnf bs3
LWithRegion u -> rnf u
instance (NFData a, NFData n) => NFData (Alt a n) where
rnf aa
= case aa of
AAlt w x -> rnf w `seq` rnf x
instance (NFData a, NFData n) => NFData (Witness a n) where
rnf ww
= case ww of
WAnnot a w -> rnf a `seq` rnf w
WVar u -> rnf u
WCon c -> rnf c
WApp w1 w2 -> rnf w1 `seq` rnf w2
WJoin w1 w2 -> rnf w1 `seq` rnf w2
WType t -> rnf t