Use Typeable instead of homegrown WitnessFor for ElemOf
This commit is contained in:
parent
418ebcb60f
commit
5af98f6c9a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue