Skip to content

Commit 2181c94

Browse files
authored
Merge pull request #163 from mlabs-haskell/jared/added-neq-lam-val
Added LamVal for neq instances
2 parents 31fb021 + 8752b12 commit 2181c94

File tree

1 file changed

+15
-1
lines changed
  • lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal

1 file changed

+15
-1
lines changed

lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Eq.hs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module LambdaBuffers.Codegen.LamVal.Eq (deriveEqImpl) where
1+
module LambdaBuffers.Codegen.LamVal.Eq (deriveEqImpl, deriveNeqImpl) where
22

33
import Control.Exception qualified as Exception
44
import Data.Map.Ordered qualified as OMap
@@ -95,6 +95,16 @@ eqListHelper lxs rxs tys =
9595
deriveEqImpl :: PC.ModuleName -> PC.TyDefs -> PC.Ty -> Either P.InternalError ValueE
9696
deriveEqImpl mn tydefs = deriveImpl mn tydefs eqSum eqProduct eqRecord
9797

98+
-- | Essentially, takes the 'deriveEqImpl' and sticks a not in front of it.
99+
deriveNeqImpl :: PC.ModuleName -> PC.TyDefs -> PC.Ty -> Either P.InternalError ValueE
100+
deriveNeqImpl mn tydefs =
101+
deriveImpl
102+
mn
103+
tydefs
104+
(\qsum -> LamE (\l -> LamE (\r -> notE @ (eqSum qsum @ l @ r))))
105+
(\qprod -> LamE (\l -> LamE (\r -> notE @ (eqProduct qprod @ l @ r))))
106+
(\qrec -> LamE (\l -> LamE (\r -> notE @ (eqRecord qrec @ l @ r))))
107+
98108
-- | Domain value references
99109

100110
-- | `eq :: a -> a -> Bool`
@@ -112,3 +122,7 @@ trueE = RefE ([], "true")
112122
-- | `and :: Bool -> Bool -> Bool`
113123
andE :: ValueE
114124
andE = RefE ([], "and")
125+
126+
-- | `not :: Bool -> Bool`
127+
notE :: ValueE
128+
notE = RefE ([], "not")

0 commit comments

Comments
 (0)