-
Notifications
You must be signed in to change notification settings - Fork 63
/
Unit.hs
36 lines (28 loc) · 921 Bytes
/
Unit.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Plutarch.Unit (PUnit (..)) where
import Plutarch (PlutusType (PInner, pcon', pmatch'), Term, pcon)
import Plutarch.Bool (PBool (PFalse, PTrue), PEq, POrd, (#<), (#<=), (#==))
import Plutarch.Lift (
DerivePConstantViaCoercible (DerivePConstantViaCoercible),
PConstant,
PLifted,
PUnsafeLiftDecl,
pconstant,
)
data PUnit s = PUnit
instance PUnsafeLiftDecl PUnit where type PLifted PUnit = ()
deriving via (DerivePConstantViaCoercible () PUnit ()) instance (PConstant ())
instance PlutusType PUnit where
type PInner PUnit _ = PUnit
pcon' PUnit = pconstant ()
pmatch' _ f = f PUnit
instance PEq PUnit where
_ #== _ = pcon PTrue
instance POrd PUnit where
_ #<= _ = pcon PTrue
_ #< _ = pcon PFalse
instance Semigroup (Term s PUnit) where
_ <> _ = pcon PUnit
instance Monoid (Term s PUnit) where
mempty = pcon PUnit