Re: using composition with multiple argument functions

[Moved to Cafe] At 2002-02-02 17:42, Dean Herington wrote:
With `h1 f g = f # g` and the type declaration for h1, the compiler sees that f1 and g1 must be used at the same type. With `h1 = f1 # g1`, that connection is missing.
Yes. Haskell cannot be sure that the last instance declaration is the one it wants, because, even though it would work, there might be other possible instance declarations that could apply. Here's a simpler example: -- class C f where foo :: f -> Bool instance C (Bool->Bool) where foo f = f True instance C (Int->Int) where foo f = False f :: Bool f = foo id -- Either instance declaration would work, but Haskell needs one unambiguously for the general type of 'id'. You can fix it by restricting the type of 'id': -- f :: Bool f = foo (id :: Int -> Int) --
So I guess my `Composable` class example can't work in general.
Maybe, maybe not. -- Ashley Yakeley, Seattle WA
participants (1)
-
Ashley Yakeley