{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
module Language.PTS.Systems (
STLC (..),
SystemF (..),
HindleyMilner (..),
CoC (..),
MartinLof (..),
HOL (..),
LambdaStar (..),
SystemU (..),
) where
import Prelude ()
import Prelude.Compat
import Numeric.Natural (Natural)
import Language.PTS.Specification
import Language.PTS.Pretty
data LambdaStar = LambdaStar deriving (Eq, Show, Enum, Bounded)
instance PrettyPrec LambdaStar where
ppp _ _ = "⋆"
instance Specification LambdaStar where
typeSort = LambdaStar
typeSortSort = LambdaStar
axiom _ = Just LambdaStar
rule _ _ = Just LambdaStar
data STLC = STLCStar | STLCBox deriving (Eq, Show, Enum, Bounded)
instance PrettyPrec STLC where
ppp _ STLCStar = pppChar '⋆'
ppp _ STLCBox = pppChar '□'
instance Specification STLC where
typeSort = STLCStar
typeSortSort = STLCBox
axiom STLCStar = Just STLCBox
axiom _ = Nothing
rule STLCStar STLCStar = Just STLCStar
rule _ _ = Nothing
instance HasBox STLC where box_ = STLCBox
data SystemF = SysFStar | SysFBox deriving (Eq, Show, Enum, Bounded)
instance PrettyPrec SystemF where
ppp _ SysFStar = pppChar '⋆'
ppp _ SysFBox = pppChar '□'
instance Specification SystemF where
typeSort = SysFStar
typeSortSort = SysFBox
axiom SysFStar = Just SysFBox
axiom _ = Nothing
rule SysFStar SysFStar = Just SysFStar
rule SysFBox SysFStar = Just SysFStar
rule _ _ = Nothing
instance HasBox SystemF where box_ = SysFBox
data HindleyMilner = HMMono | HMPoly deriving (Eq, Show, Enum, Bounded)
instance PrettyPrec HindleyMilner where
ppp _ HMMono = pppChar 'M'
ppp _ HMPoly = pppChar 'P'
instance Specification HindleyMilner where
typeSort = HMMono
typeSortSort = HMPoly
axiom HMMono = Just HMPoly
axiom _ = Nothing
rule HMMono HMMono = Just HMMono
rule HMPoly HMMono = Just HMPoly
rule HMPoly HMPoly = Just HMPoly
rule _ _ = Nothing
instance HasBox HindleyMilner where box_ = HMPoly
data CoC = CoCStar | CoCBox deriving (Eq, Show, Enum, Bounded)
instance PrettyPrec CoC where
ppp _ CoCStar = pppChar '⋆'
ppp _ CoCBox = pppChar '□'
instance Specification CoC where
typeSort = CoCStar
typeSortSort = CoCBox
axiom CoCStar = Just CoCBox
axiom _ = Nothing
rule _ = Just
instance HasBox CoC where box_ = CoCBox
newtype MartinLof = MartinLof Natural deriving (Eq, Show, Enum)
instance PrettyPrec MartinLof where
ppp _ (MartinLof 0) = "𝓤"
ppp _ (MartinLof n) = "𝓤" <> pppIntegralSub n
instance Specification MartinLof where
typeSort = MartinLof 0
typeSortSort = MartinLof 1
axiom (MartinLof n) = Just (MartinLof (succ n))
rule (MartinLof n) (MartinLof m) = Just (MartinLof (max n m))
instance HasBox MartinLof where box_ = MartinLof 1
instance HasTriangle MartinLof where triangle_ = MartinLof 2
data HOL = HOLStar | HOLBox | HOLTri deriving (Eq, Show, Enum, Bounded)
instance PrettyPrec HOL where
ppp _ HOLStar = pppChar '⋆'
ppp _ HOLBox = pppChar '□'
ppp _ HOLTri = pppChar '△'
instance Specification HOL where
typeSort = HOLStar
typeSortSort = HOLBox
axiom HOLStar = Just HOLBox
axiom HOLBox = Just HOLTri
axiom _ = Nothing
rule HOLStar HOLStar = Just HOLStar
rule HOLBox HOLStar = Just HOLStar
rule HOLTri HOLStar = Just HOLStar
rule HOLBox HOLBox = Just HOLBox
rule _ _ = Nothing
instance HasBox HOL where box_ = HOLBox
instance HasTriangle HOL where triangle_ = HOLTri
data SystemU = SysUStar | SysUBox | SysUTri deriving (Eq, Show, Enum, Bounded)
instance PrettyPrec SystemU where
ppp _ SysUStar = pppChar '⋆'
ppp _ SysUBox = pppChar '□'
ppp _ SysUTri = pppChar '△'
instance Specification SystemU where
typeSort = SysUStar
typeSortSort = SysUBox
axiom SysUStar = Just SysUBox
axiom SysUBox = Just SysUTri
axiom _ = Nothing
rule SysUStar SysUStar = Just SysUStar
rule SysUBox SysUStar = Just SysUStar
rule SysUBox SysUBox = Just SysUBox
rule SysUTri SysUStar = Just SysUStar
rule SysUTri SysUBox = Just SysUBox
rule _ _ = Nothing
instance HasBox SystemU where box_ = SysUBox
instance HasTriangle SystemU where triangle_ = SysUTri