]> Git — Sourcephile - comptalang.git/blob - cli/Hcompta/Expr/Bool/Test.hs
Sync with symantic.
[comptalang.git] / cli / Hcompta / Expr / Bool / Test.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE NoImplicitPrelude #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE OverloadedStrings #-}
5 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
6 {-# OPTIONS_GHC -fno-warn-tabs #-}
7
8 module Expr.Bool.Test where
9
10 import Data.Bool (Bool(..))
11 import Data.Function (($))
12
13 import Hcompta.Expr.Lit
14 import Hcompta.Expr.Bool
15 import Hcompta.Expr.Trans
16 import Hcompta.Trans.Bool.Const
17 import Hcompta.Repr
18
19 e1 = lit True `and` lit False
20 e2 = (lit True `and` lit False) `or` (lit True `and` lit True)
21 e3 = (lit True `or` lit False) `and` (lit True `or` lit True)
22 e4 = lit True `and` neg (lit False)
23 e5 = lit True `and` neg x
24 e6 = x `xor` y
25 e7 = (x `xor` y) `xor` z
26 e8 = x `xor` (y `xor` lit True)
27
28 -- * Class 'Expr_Bool_Vars'
29
30 -- | A few boolean variables.
31 class Expr_Bool_Vars repr where
32 x :: repr Bool
33 y :: repr Bool
34 z :: repr Bool
35 instance -- Trans_Boo_Const
36 ( Expr_Bool_Vars repr
37 , Expr_Lit repr
38 ) => Expr_Bool_Vars (Trans_Bool_Const repr) where
39 x = trans_lift x
40 y = trans_lift y
41 z = trans_lift z
42 instance Expr_Bool_Vars Repr_Text_Write where
43 x = Repr_Text_Write $ \_p _v -> "x"
44 y = Repr_Text_Write $ \_p _v -> "y"
45 z = Repr_Text_Write $ \_p _v -> "z"