module Plutarch.Extra.Bool (
pcompare,
pcond,
passert,
) where
import Data.Monoid (Endo (Endo, appEndo))
pcompare ::
forall (a :: S -> Type) (b :: S -> Type) (s :: S).
(POrd a) =>
Term s a ->
Term s a ->
Term s b ->
Term s b ->
Term s b ->
Term s b
pcompare :: forall (a :: S -> Type) (b :: S -> Type) (s :: S).
POrd a =>
Term s a
-> Term s a -> Term s b -> Term s b -> Term s b -> Term s b
pcompare Term s a
t1 Term s a
t2 Term s b
ifLT Term s b
ifEQ Term s b
ifGT =
forall (s :: S) (a :: S -> Type).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term s a
t1 forall (t :: S -> Type) (s :: S).
PPartialOrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s a
t2) Term s b
ifLT (forall (s :: S) (a :: S -> Type).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term s a
t1 forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s a
t2) Term s b
ifEQ Term s b
ifGT)
pcond :: forall (s :: S) (a :: S -> Type). [Term s a -> Term s a] -> Term s a -> Term s a
pcond :: forall (s :: S) (a :: S -> Type).
[Term s a -> Term s a] -> Term s a -> Term s a
pcond = forall a. Endo a -> a -> a
appEndo forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: Type -> Type) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap forall a. (a -> a) -> Endo a
Endo
passert ::
forall (a :: PType) (s :: S).
Term s PString ->
Term s PBool ->
Term s a ->
Term s a
passert :: forall (a :: S -> Type) (s :: S).
Term s PString -> Term s PBool -> Term s a -> Term s a
passert Term s PString
msg Term s PBool
cond Term s a
x = forall (s :: S) (a :: S -> Type).
Term s PBool -> Term s a -> Term s a -> Term s a
pif Term s PBool
cond Term s a
x forall a b. (a -> b) -> a -> b
$ forall (s :: S) (a :: S -> Type). Term s PString -> Term s a
ptraceError Term s PString
msg