From 5af98f6c9a3602b60d2cce33c201ba958793e214 Mon Sep 17 00:00:00 2001 From: "Niels G. W. Serup" Date: Wed, 9 Oct 2024 23:19:32 +0200 Subject: [PATCH] Use Typeable instead of homegrown WitnessFor for ElemOf --- byg/src/Function.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/byg/src/Function.hs b/byg/src/Function.hs index 59b6b9c..04d3cb3 100644 --- a/byg/src/Function.hs +++ b/byg/src/Function.hs @@ -16,11 +16,12 @@ module Function import Prelude hiding (String, FilePath) import Types.Values -import Types.Value (Valuable, WitnessFor(..)) +import Types.Value (Valuable) import Types.Function import Types.Token (Token(..)) import DependencyGenerator (DepGenM, TokenableTo(..), toTupleToken, runFunction) +import Type.Reflection (Typeable, TypeRep, typeRep) import qualified Codec.Picture as CP import qualified Codec.Picture.STBIR as CPS import Data.Char (toLower) @@ -76,13 +77,13 @@ lowerString :: TokenableTo String a => a -> DepGenM (Token String) lowerString a = runFunction LowerString =<< toToken a -data ElemOf a where ElemOf :: WitnessFor w a => w -> ElemOf a +data ElemOf a where ElemOf :: TypeRep a -> ElemOf a deriving instance Show (ElemOf a) instance (Show a, Valuable a, Eq a) => IsFunction (ElemOf a) (a, [a]) Bool where evalFunction (ElemOf _) (y, ys) = y `elem` ys -elemOf :: forall t w a b. (Show t, Valuable t, Eq t, TokenableTo t a, TokenableTo [t] b, WitnessFor w t) => a -> b -> DepGenM (Token Bool) -elemOf a b = runFunction (ElemOf (witnessValue :: w)) =<< toTupleToken a b +elemOf :: forall t a b. (Show t, Valuable t, Eq t, TokenableTo t a, TokenableTo [t] b, Typeable t) => a -> b -> DepGenM (Token Bool) +elemOf a b = runFunction (ElemOf (typeRep :: TypeRep t)) =<< toTupleToken a b data MakeTemplate = MakeTemplate deriving Show