{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# Language TypeFamilies, TypeSynonymInstances, FlexibleInstances #-}
-- | Boolean instances
module Csound.Dynamic.Build.Logic(
    when1, whens,
    ifBegin, ifEnd, elseBegin,
    untilDo,
    untilBegin, untilEnd,
    whileDo,
    whileBegin, whileRef, whileEnd
) where

import Control.Monad.Trans.State(State, state, evalState)
import qualified Data.IntMap as IM(fromList)

import Data.Boolean
import Csound.Dynamic.Types
import Csound.Dynamic.Build(onExp, toExp)

------------------------------------------------------
-- imperative if-then-else

when1 :: Monad m => Rate -> E -> DepT m () -> DepT m ()
when1 :: Rate -> E -> DepT m () -> DepT m ()
when1 Rate
rate E
p DepT m ()
body = do
    Rate -> E -> DepT m ()
forall (m :: * -> *). Monad m => Rate -> E -> DepT m ()
ifBegin Rate
rate E
p
    DepT m ()
body
    DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
ifEnd

whens :: Monad m => Rate -> [(E, DepT m ())] -> DepT m () -> DepT m ()
whens :: Rate -> [(E, DepT m ())] -> DepT m () -> DepT m ()
whens Rate
rate [(E, DepT m ())]
bodies DepT m ()
el = case [(E, DepT m ())]
bodies of
    []   -> DepT m ()
el
    (E, DepT m ())
a:[(E, DepT m ())]
as -> do
        Rate -> E -> DepT m ()
forall (m :: * -> *). Monad m => Rate -> E -> DepT m ()
ifBegin Rate
rate ((E, DepT m ()) -> E
forall a b. (a, b) -> a
fst (E, DepT m ())
a)
        (E, DepT m ()) -> DepT m ()
forall a b. (a, b) -> b
snd (E, DepT m ())
a
        [(E, DepT m ())] -> DepT m ()
elseIfs [(E, DepT m ())]
as
        DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
elseBegin
        DepT m ()
el
        (DepT m () -> DepT m () -> DepT m ()) -> [DepT m ()] -> DepT m ()
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldl1 DepT m () -> DepT m () -> DepT m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
(>>) ([DepT m ()] -> DepT m ()) -> [DepT m ()] -> DepT m ()
forall a b. (a -> b) -> a -> b
$ Int -> DepT m () -> [DepT m ()]
forall a. Int -> a -> [a]
replicate (Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [(E, DepT m ())] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(E, DepT m ())]
as) DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
ifEnd
    where elseIfs :: [(E, DepT m ())] -> DepT m ()
elseIfs = ((E, DepT m ()) -> DepT m ()) -> [(E, DepT m ())] -> DepT m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (\(E
p, DepT m ()
body) -> DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
elseBegin DepT m () -> DepT m () -> DepT m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Rate -> E -> DepT m ()
forall (m :: * -> *). Monad m => Rate -> E -> DepT m ()
ifBegin Rate
rate E
p DepT m () -> DepT m () -> DepT m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> DepT m ()
body)

ifBegin :: Monad m => Rate -> E -> DepT m ()
ifBegin :: Rate -> E -> DepT m ()
ifBegin Rate
rate = (CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ()
forall (m :: * -> *).
Monad m =>
(CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ()
withCond ((CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ())
-> (CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ Rate -> CondInfo (PrimOr E) -> MainExp (PrimOr E)
forall a. Rate -> CondInfo a -> MainExp a
IfBegin Rate
rate

elseBegin :: Monad m => DepT m ()
elseBegin :: DepT m ()
elseBegin = MainExp (PrimOr E) -> DepT m ()
forall (m :: * -> *). Monad m => MainExp (PrimOr E) -> DepT m ()
stmtOnlyT MainExp (PrimOr E)
forall a. MainExp a
ElseBegin

ifEnd :: Monad m => DepT m ()
ifEnd :: DepT m ()
ifEnd = MainExp (PrimOr E) -> DepT m ()
forall (m :: * -> *). Monad m => MainExp (PrimOr E) -> DepT m ()
stmtOnlyT MainExp (PrimOr E)
forall a. MainExp a
IfEnd

untilDo :: Monad m => E -> DepT m () -> DepT m ()
untilDo :: E -> DepT m () -> DepT m ()
untilDo E
p DepT m ()
body = do
    E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
untilBegin E
p
    DepT m ()
body
    DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
untilEnd

untilBegin :: Monad m => E -> DepT m ()
untilBegin :: E -> DepT m ()
untilBegin = (CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ()
forall (m :: * -> *).
Monad m =>
(CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ()
withCond CondInfo (PrimOr E) -> MainExp (PrimOr E)
forall a. CondInfo a -> MainExp a
UntilBegin

untilEnd :: Monad m => DepT m ()
untilEnd :: DepT m ()
untilEnd = MainExp (PrimOr E) -> DepT m ()
forall (m :: * -> *). Monad m => MainExp (PrimOr E) -> DepT m ()
stmtOnlyT MainExp (PrimOr E)
forall a. MainExp a
UntilEnd

whileDo :: Monad m => E -> DepT m () -> DepT m ()
whileDo :: E -> DepT m () -> DepT m ()
whileDo E
p DepT m ()
body = do
    E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
whileBegin E
p
    DepT m ()
body
    DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
whileEnd

whileBegin :: Monad m => E -> DepT m ()
whileBegin :: E -> DepT m ()
whileBegin = (CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ()
forall (m :: * -> *).
Monad m =>
(CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ()
withCond CondInfo (PrimOr E) -> MainExp (PrimOr E)
forall a. CondInfo a -> MainExp a
WhileBegin

whileRef :: Monad m => Var -> DepT m ()
whileRef :: Var -> DepT m ()
whileRef Var
var = MainExp (PrimOr E) -> DepT m ()
forall (m :: * -> *). Monad m => MainExp (PrimOr E) -> DepT m ()
stmtOnlyT (MainExp (PrimOr E) -> DepT m ())
-> MainExp (PrimOr E) -> DepT m ()
forall a b. (a -> b) -> a -> b
$ Var -> MainExp (PrimOr E)
forall a. Var -> MainExp a
WhileRefBegin Var
var

whileEnd :: Monad m => DepT m ()
whileEnd :: DepT m ()
whileEnd = MainExp (PrimOr E) -> DepT m ()
forall (m :: * -> *). Monad m => MainExp (PrimOr E) -> DepT m ()
stmtOnlyT MainExp (PrimOr E)
forall a. MainExp a
WhileEnd

withCond :: Monad m => (CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ()
withCond :: (CondInfo (PrimOr E) -> MainExp (PrimOr E)) -> E -> DepT m ()
withCond CondInfo (PrimOr E) -> MainExp (PrimOr E)
stmt E
p = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ MainExp (PrimOr E) -> E
noRate (MainExp (PrimOr E) -> E) -> MainExp (PrimOr E) -> E
forall a b. (a -> b) -> a -> b
$ CondInfo (PrimOr E) -> MainExp (PrimOr E)
stmt (E -> CondInfo (PrimOr E)
condInfo E
p)

instance Boolean E where
    true :: E
true = CondOp -> E
boolOp0 CondOp
TrueOp
    false :: E
false = CondOp -> E
boolOp0 CondOp
FalseOp
    notB :: E -> E
notB = E -> E
notE
    &&* :: E -> E -> E
(&&*) = CondOp -> E -> E -> E
boolOp2 CondOp
And
    ||* :: E -> E -> E
(||*) = CondOp -> E -> E -> E
boolOp2 CondOp
Or

-- instances

type instance BooleanOf E = E

instance IfB E where
    ifB :: bool -> E -> E -> E
ifB = bool -> E -> E -> E
E -> E -> E -> E
condExp

instance EqB E where
    ==* :: E -> E -> bool
(==*) = CondOp -> E -> E -> E
boolOp2 CondOp
Equals
    /=* :: E -> E -> bool
(/=*) = CondOp -> E -> E -> E
boolOp2 CondOp
NotEquals

instance OrdB E where
    <* :: E -> E -> bool
(<*) = CondOp -> E -> E -> E
boolOp2 CondOp
Less
    >* :: E -> E -> bool
(>*) = CondOp -> E -> E -> E
boolOp2 CondOp
Greater
    <=* :: E -> E -> bool
(<=*) = CondOp -> E -> E -> E
boolOp2 CondOp
LessEquals
    >=* :: E -> E -> bool
(>=*) = CondOp -> E -> E -> E
boolOp2 CondOp
GreaterEquals

--------------------------------------------------------------------------
-- if-then-else
--
-- performs inlining of the boolean expressions

boolExp :: a -> [b] -> PreInline a b
boolExp :: a -> [b] -> PreInline a b
boolExp = a -> [b] -> PreInline a b
forall a b. a -> [b] -> PreInline a b
PreInline

condExp :: E -> E -> E -> E
condExp :: E -> E -> E -> E
condExp = CondInfo (PrimOr E) -> E -> E -> E
mkCond (CondInfo (PrimOr E) -> E -> E -> E)
-> (E -> CondInfo (PrimOr E)) -> E -> E -> E -> E
forall b c a. (b -> c) -> (a -> b) -> a -> c
. E -> CondInfo (PrimOr E)
condInfo
    where mkCond :: CondInfo (PrimOr E) -> E -> E -> E
          mkCond :: CondInfo (PrimOr E) -> E -> E -> E
mkCond CondInfo (PrimOr E)
pr E
th E
el
            | CondInfo (PrimOr E) -> Bool
forall a. CondInfo a -> Bool
isTrue CondInfo (PrimOr E)
pr = E
th
            | CondInfo (PrimOr E) -> Bool
forall a. CondInfo a -> Bool
isFalse CondInfo (PrimOr E)
pr = E
el
            | Bool
otherwise = MainExp (PrimOr E) -> E
noRate (MainExp (PrimOr E) -> E) -> MainExp (PrimOr E) -> E
forall a b. (a -> b) -> a -> b
$ CondInfo (PrimOr E) -> PrimOr E -> PrimOr E -> MainExp (PrimOr E)
forall a. CondInfo a -> a -> a -> MainExp a
If CondInfo (PrimOr E)
pr (E -> PrimOr E
toPrimOr E
th) (E -> PrimOr E
toPrimOr E
el)

condInfo :: E -> CondInfo (PrimOr E)
condInfo :: E -> CondInfo (PrimOr E)
condInfo E
p = PrimOr E -> CondInfo (PrimOr E)
go (PrimOr E -> CondInfo (PrimOr E))
-> PrimOr E -> CondInfo (PrimOr E)
forall a b. (a -> b) -> a -> b
$ E -> PrimOr E
toPrimOr E
p
    where
        go :: PrimOr E -> CondInfo (PrimOr E)
        go :: PrimOr E -> CondInfo (PrimOr E)
go PrimOr E
expr = (\(InlineExp CondOp
a, [(Int, PrimOr E)]
b) -> InlineExp CondOp -> IntMap (PrimOr E) -> CondInfo (PrimOr E)
forall a b. InlineExp a -> IntMap b -> Inline a b
Inline InlineExp CondOp
a ([(Int, PrimOr E)] -> IntMap (PrimOr E)
forall a. [(Int, a)] -> IntMap a
IM.fromList [(Int, PrimOr E)]
b)) ((InlineExp CondOp, [(Int, PrimOr E)]) -> CondInfo (PrimOr E))
-> (InlineExp CondOp, [(Int, PrimOr E)]) -> CondInfo (PrimOr E)
forall a b. (a -> b) -> a -> b
$ State Int (InlineExp CondOp, [(Int, PrimOr E)])
-> Int -> (InlineExp CondOp, [(Int, PrimOr E)])
forall s a. State s a -> s -> a
evalState (PrimOr E -> State Int (InlineExp CondOp, [(Int, PrimOr E)])
condInfo' PrimOr E
expr) Int
0
        condInfo' :: PrimOr E -> State Int (InlineExp CondOp, [(Int, PrimOr E)])
        condInfo' :: PrimOr E -> State Int (InlineExp CondOp, [(Int, PrimOr E)])
condInfo' PrimOr E
e = State Int (InlineExp CondOp, [(Int, PrimOr E)])
-> ((CondOp, [PrimOr E])
    -> State Int (InlineExp CondOp, [(Int, PrimOr E)]))
-> Maybe (CondOp, [PrimOr E])
-> State Int (InlineExp CondOp, [(Int, PrimOr E)])
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (PrimOr E -> State Int (InlineExp CondOp, [(Int, PrimOr E)])
forall (m :: * -> *) b a.
Monad m =>
b -> StateT Int m (InlineExp a, [(Int, b)])
onLeaf PrimOr E
e) (PrimOr E
-> (CondOp, [PrimOr E])
-> State Int (InlineExp CondOp, [(Int, PrimOr E)])
forall p.
p
-> (CondOp, [PrimOr E])
-> State Int (InlineExp CondOp, [(Int, PrimOr E)])
onExpr PrimOr E
e) (Maybe (CondOp, [PrimOr E])
 -> State Int (InlineExp CondOp, [(Int, PrimOr E)]))
-> Maybe (CondOp, [PrimOr E])
-> State Int (InlineExp CondOp, [(Int, PrimOr E)])
forall a b. (a -> b) -> a -> b
$ PrimOr E -> Maybe (CondOp, [PrimOr E])
parseNode PrimOr E
e
        onLeaf :: b -> StateT Int m (InlineExp a, [(Int, b)])
onLeaf b
e = (Int -> ((InlineExp a, [(Int, b)]), Int))
-> StateT Int m (InlineExp a, [(Int, b)])
forall (m :: * -> *) s a. Monad m => (s -> (a, s)) -> StateT s m a
state ((Int -> ((InlineExp a, [(Int, b)]), Int))
 -> StateT Int m (InlineExp a, [(Int, b)]))
-> (Int -> ((InlineExp a, [(Int, b)]), Int))
-> StateT Int m (InlineExp a, [(Int, b)])
forall a b. (a -> b) -> a -> b
$ \Int
n -> ((Int -> InlineExp a
forall a. Int -> InlineExp a
InlinePrim Int
n, [(Int
n, b
e)]), Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)
        onExpr :: p
-> (CondOp, [PrimOr E])
-> State Int (InlineExp CondOp, [(Int, PrimOr E)])
onExpr  p
_ (CondOp
op, [PrimOr E]
args) = ([(InlineExp CondOp, [(Int, PrimOr E)])]
 -> (InlineExp CondOp, [(Int, PrimOr E)]))
-> StateT Int Identity [(InlineExp CondOp, [(Int, PrimOr E)])]
-> State Int (InlineExp CondOp, [(Int, PrimOr E)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [(InlineExp CondOp, [(Int, PrimOr E)])]
-> (InlineExp CondOp, [(Int, PrimOr E)])
mkNode (StateT Int Identity [(InlineExp CondOp, [(Int, PrimOr E)])]
 -> State Int (InlineExp CondOp, [(Int, PrimOr E)]))
-> StateT Int Identity [(InlineExp CondOp, [(Int, PrimOr E)])]
-> State Int (InlineExp CondOp, [(Int, PrimOr E)])
forall a b. (a -> b) -> a -> b
$ (PrimOr E -> State Int (InlineExp CondOp, [(Int, PrimOr E)]))
-> [PrimOr E]
-> StateT Int Identity [(InlineExp CondOp, [(Int, PrimOr E)])]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM PrimOr E -> State Int (InlineExp CondOp, [(Int, PrimOr E)])
condInfo' [PrimOr E]
args
            where mkNode :: [(InlineExp CondOp, [(Int, PrimOr E)])]
-> (InlineExp CondOp, [(Int, PrimOr E)])
mkNode [(InlineExp CondOp, [(Int, PrimOr E)])]
as = (CondOp -> [InlineExp CondOp] -> InlineExp CondOp
forall a. a -> [InlineExp a] -> InlineExp a
InlineExp CondOp
op (((InlineExp CondOp, [(Int, PrimOr E)]) -> InlineExp CondOp)
-> [(InlineExp CondOp, [(Int, PrimOr E)])] -> [InlineExp CondOp]
forall a b. (a -> b) -> [a] -> [b]
map (InlineExp CondOp, [(Int, PrimOr E)]) -> InlineExp CondOp
forall a b. (a, b) -> a
fst [(InlineExp CondOp, [(Int, PrimOr E)])]
as), [[(Int, PrimOr E)]] -> [(Int, PrimOr E)]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[(Int, PrimOr E)]] -> [(Int, PrimOr E)])
-> [[(Int, PrimOr E)]] -> [(Int, PrimOr E)]
forall a b. (a -> b) -> a -> b
$ ((InlineExp CondOp, [(Int, PrimOr E)]) -> [(Int, PrimOr E)])
-> [(InlineExp CondOp, [(Int, PrimOr E)])] -> [[(Int, PrimOr E)]]
forall a b. (a -> b) -> [a] -> [b]
map (InlineExp CondOp, [(Int, PrimOr E)]) -> [(Int, PrimOr E)]
forall a b. (a, b) -> b
snd [(InlineExp CondOp, [(Int, PrimOr E)])]
as)

        parseNode :: PrimOr E -> Maybe (CondOp, [PrimOr E])
        parseNode :: PrimOr E -> Maybe (CondOp, [PrimOr E])
parseNode PrimOr E
x = case PrimOr (MainExp (PrimOr E)) -> Either Prim (MainExp (PrimOr E))
forall a. PrimOr a -> Either Prim a
unPrimOr (PrimOr (MainExp (PrimOr E)) -> Either Prim (MainExp (PrimOr E)))
-> PrimOr (MainExp (PrimOr E)) -> Either Prim (MainExp (PrimOr E))
forall a b. (a -> b) -> a -> b
$ (E -> MainExp (PrimOr E))
-> PrimOr E -> PrimOr (MainExp (PrimOr E))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap E -> MainExp (PrimOr E)
toExp PrimOr E
x of
          Right (ExpBool (PreInline CondOp
op [PrimOr E]
args)) -> (CondOp, [PrimOr E]) -> Maybe (CondOp, [PrimOr E])
forall a. a -> Maybe a
Just (CondOp
op, [PrimOr E]
args)
          Either Prim (MainExp (PrimOr E))
_ -> Maybe (CondOp, [PrimOr E])
forall a. Maybe a
Nothing

--------------------------------------------------------------------------------
-- constructors for boolean expressions

boolOps :: CondOp -> [E] -> E
boolOps :: CondOp -> [E] -> E
boolOps CondOp
op [E]
as = MainExp (PrimOr E) -> E
noRate (MainExp (PrimOr E) -> E) -> MainExp (PrimOr E) -> E
forall a b. (a -> b) -> a -> b
$ PreInline CondOp (PrimOr E) -> MainExp (PrimOr E)
forall a. BoolExp a -> MainExp a
ExpBool (PreInline CondOp (PrimOr E) -> MainExp (PrimOr E))
-> PreInline CondOp (PrimOr E) -> MainExp (PrimOr E)
forall a b. (a -> b) -> a -> b
$ CondOp -> [PrimOr E] -> PreInline CondOp (PrimOr E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
op ([PrimOr E] -> PreInline CondOp (PrimOr E))
-> [PrimOr E] -> PreInline CondOp (PrimOr E)
forall a b. (a -> b) -> a -> b
$ (E -> PrimOr E) -> [E] -> [PrimOr E]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap E -> PrimOr E
toPrimOr [E]
as

boolOp0 :: CondOp -> E
boolOp2 :: CondOp -> E -> E -> E

boolOp0 :: CondOp -> E
boolOp0 CondOp
op = CondOp -> [E] -> E
boolOps CondOp
op []

boolOp2 :: CondOp -> E -> E -> E
boolOp2 CondOp
op E
a E
b = CondOp -> [E] -> E
boolOps CondOp
op [E
a, E
b]

-----------------------------------------------------------------------------
-- no support for not in csound so we perform not-elimination
notE :: E -> E
notE :: E -> E
notE E
x = (MainExp (PrimOr E) -> MainExp (PrimOr E)) -> E -> E
onExp MainExp (PrimOr E) -> MainExp (PrimOr E)
forall (f :: * -> *). Functor f => MainExp (f E) -> MainExp (f E)
phi E
x
    where phi :: MainExp (f E) -> MainExp (f E)
phi (ExpBool (PreInline CondOp
op [f E]
args)) = PreInline CondOp (f E) -> MainExp (f E)
forall a. BoolExp a -> MainExp a
ExpBool (PreInline CondOp (f E) -> MainExp (f E))
-> PreInline CondOp (f E) -> MainExp (f E)
forall a b. (a -> b) -> a -> b
$ case CondOp
op of
            CondOp
TrueOp            -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
FalseOp        []
            CondOp
FalseOp           -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
TrueOp         []
            CondOp
And               -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
Or             ([f E] -> PreInline CondOp (f E))
-> [f E] -> PreInline CondOp (f E)
forall a b. (a -> b) -> a -> b
$ (f E -> f E) -> [f E] -> [f E]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((E -> E) -> f E -> f E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap E -> E
notE) [f E]
args
            CondOp
Or                -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
And            ([f E] -> PreInline CondOp (f E))
-> [f E] -> PreInline CondOp (f E)
forall a b. (a -> b) -> a -> b
$ (f E -> f E) -> [f E] -> [f E]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((E -> E) -> f E -> f E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap E -> E
notE) [f E]
args
            CondOp
Equals            -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
NotEquals      [f E]
args
            CondOp
NotEquals         -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
Equals         [f E]
args
            CondOp
Less              -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
GreaterEquals  [f E]
args
            CondOp
Greater           -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
LessEquals     [f E]
args
            CondOp
LessEquals        -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
Greater        [f E]
args
            CondOp
GreaterEquals     -> CondOp -> [f E] -> PreInline CondOp (f E)
forall a b. a -> [b] -> PreInline a b
boolExp CondOp
Less           [f E]
args

          phi MainExp (f E)
_ = [Char] -> MainExp (f E)
forall a. HasCallStack => [Char] -> a
error [Char]
"Logic.hs:notE - expression is not Boolean"