From eb22a2b19e7a095e446150ee3f8b59d8a04ff5c3 Mon Sep 17 00:00:00 2001 From: jared <> Date: Mon, 4 Dec 2023 16:25:26 -0700 Subject: [PATCH] Added LamVal for neq instances --- .../src/LambdaBuffers/Codegen/LamVal/Eq.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Eq.hs b/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Eq.hs index ff57f4ed..82a526ed 100644 --- a/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Eq.hs +++ b/lambda-buffers-codegen/src/LambdaBuffers/Codegen/LamVal/Eq.hs @@ -1,4 +1,4 @@ -module LambdaBuffers.Codegen.LamVal.Eq (deriveEqImpl) where +module LambdaBuffers.Codegen.LamVal.Eq (deriveEqImpl, deriveNeqImpl) where import Control.Exception qualified as Exception import Data.Map.Ordered qualified as OMap @@ -95,6 +95,16 @@ eqListHelper lxs rxs tys = deriveEqImpl :: PC.ModuleName -> PC.TyDefs -> PC.Ty -> Either P.InternalError ValueE deriveEqImpl mn tydefs = deriveImpl mn tydefs eqSum eqProduct eqRecord +-- | Essentially, takes the 'deriveEqImpl' and sticks a not in front of it. +deriveNeqImpl :: PC.ModuleName -> PC.TyDefs -> PC.Ty -> Either P.InternalError ValueE +deriveNeqImpl mn tydefs = + deriveImpl + mn + tydefs + (\qsum -> LamE (\l -> LamE (\r -> notE @ (eqSum qsum @ l @ r)))) + (\qprod -> LamE (\l -> LamE (\r -> notE @ (eqProduct qprod @ l @ r)))) + (\qrec -> LamE (\l -> LamE (\r -> notE @ (eqRecord qrec @ l @ r)))) + -- | Domain value references -- | `eq :: a -> a -> Bool` @@ -112,3 +122,7 @@ trueE = RefE ([], "true") -- | `and :: Bool -> Bool -> Bool` andE :: ValueE andE = RefE ([], "and") + +-- | `not :: Bool -> Bool` +notE :: ValueE +notE = RefE ([], "not")