Associated Parameter Restriction using Functional Dependency
问题 The function f below, for a given type 'a', takes a parameter of type 'c'. For different types 'a', 'c' is restricted in different ways. Concretely, when 'a' is any Integral type, 'c' should be allowed to be any 'Real' type. When 'a' is Float, 'c' can ONLY be Float. One attempt is: {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies, UndecidableInstances #-} class AllowedParamType a c | a -> c class Foo a where f :: (AllowedParamType a c) => c -> a fIntegral ::