I have a type:
type DifferentiableFunction n a = (Function n a, List n (Function n a), String)
Elsewhere I define:
data Something where
Operator :: Something -> (forall a . Floating a => DifferentiableFunction n a) -> Something
Now I try to pattern match:
case something of
(Operator s f) -> let (_, _, l) = f in l
I get Could not deduce (Floating a0) arising from a use of ‘f’. I don't understand why this is happening.
The problem is that
let (_, _. l) = f in ldoes not specify what type to use forf: it could beDifferentiableFunction n DoubleorDifferentiableFunction n Floator something else altogether. Because you only use a part which does not depend ona(lis just aString, no matter whatais), the compiler is unable to decide what typefshould have (ais ambigious, i.e. the compile does not know what to pick fora).The solution therefore is to give an explicit type signature for f:
Or alternatively, lift the
Stringout of the forall:Now you can get the
Stringwithout needing to pick a specifica, because it really is independent ofa.