1 {-# LANGUAGE UndecidableInstances #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
3 -- | Symantic for '()'.
4 module Language.Symantic.Lib.Unit where
6 import Control.Applicative ((<*))
8 import Data.Function (($))
9 import Data.Functor ((<$))
10 import Data.Maybe (Maybe(..))
11 import Data.Monoid (Monoid)
13 import Prelude (Bounded, Enum)
14 import Text.Show (Show)
16 import Language.Symantic
17 import Language.Symantic.Grammar
20 type instance Sym () = Sym_Unit
21 class Sym_Unit term where
23 default unit :: Sym_Unit (UnT term) => Trans term => term ()
27 instance Sym_Unit Eval where
29 instance Sym_Unit View where
30 unit = View $ \_p _v -> "()"
31 instance (Sym_Unit r1, Sym_Unit r2) => Sym_Unit (Dup r1 r2) where
32 unit = unit `Dup` unit
35 instance (Sym_Unit term, Sym_Lambda term) => Sym_Unit (BetaT term)
38 instance NameTyOf () where
39 nameTyOf _c = [] `Mod` ""
40 instance ClassInstancesFor () where
41 proveConstraintFor _ (TyConst _ _ q :$ z)
42 | Just HRefl <- proj_ConstKiTy @_ @() z
44 _ | Just Refl <- proj_Const @Bounded q -> Just Dict
45 | Just Refl <- proj_Const @Enum q -> Just Dict
46 | Just Refl <- proj_Const @Eq q -> Just Dict
47 | Just Refl <- proj_Const @Monoid q -> Just Dict
48 | Just Refl <- proj_Const @Ord q -> Just Dict
49 | Just Refl <- proj_Const @Show q -> Just Dict
51 proveConstraintFor _c _q = Nothing
52 instance TypeInstancesFor ()
60 ) => Gram_Term_AtomsFor src ss g () where
64 (\src -> BinTree0 $ Token_Term $ TermAVT $ (`setSource` src) $ teUnit)
68 instance ModuleFor src ss ()
71 tyUnit :: Source src => LenInj vs => Type src vs ()
72 tyUnit = tyConst @(K ()) @()
75 teUnit :: TermDef () '[] (() #> ())
76 teUnit = Term noConstraint tyUnit $ teSym @() $ unit