I am trying to define a type with two parameters i and m. I want to specialize this type fixing two specific instances which fix the m parameter. At the moment I have the following definitions:
-- | ZadehMembership: represents a membership value between 0 and 1 with min and max operators
newtype ZadehMembership = Z Double deriving (Show, Eq, Ord, Num)
-- | PAMembership: represents a membership value between 0 and 1 with algebraic sum and product operators
newtype PAMembership = PA Double deriving (Show, Eq, Ord, Num)
-- | FuzzySet type
newtype FuzzySet i m = FS (Map.Map i m) deriving (Eq, Ord)
add :: (Ord i, Eq m, L.BoundedLattice m) => FuzzySet i m -> (i, m) -> FuzzySet i m
add (FS fs) (i, m) = if m == L.bottom then FS fs else FS (Map.insert i m fs)
fromList :: (Ord i, Eq m, L.BoundedLattice m) => [(i, m)] -> FuzzySet i m
fromList = foldl add empty
I use the FuzzySet definition in this way:
let fs = fromList [(1, Z 0.2), (2, Z 0.5)]
I want to define a Functor on the FuzzySet type, but I have some class constraints that must be satisfied on both type parameters i and m, but it is not possible. Is there a way to improve my type definitions in order to solve this problem?
Thank you.