Why does the Haskell language not allow "type" declarations to appear in the declaration parts of where and let clauses? I've just been writing a huge functions which requires lots and lots of repetitive internal type annotations (to disambiguate some complicated overloading) but I can't abbreviate them with "type" because they depend on things only in scope inside the function. In the end I abbreviated them with a few #define's but I don't really think it should be that way . . .
Wed, 25 Oct 2000 22:08:55 +0200, George Russell <ger@Informatik.Uni-Bremen.DE> pisze:
Why does the Haskell language not allow "type" declarations to appear in the declaration parts of where and let clauses?
Because you can always lift them to the top level. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
George Russell complained: | Why does the Haskell language not allow "type" | declarations to appear in the declaration parts of | where and let clauses? Marcin 'Qrczak' Kowalczyk replied: | Because you can always lift them to the top level. This is the ultimate non-answer. First of all, it is wrong. George meant to be able to use type variables present in the top-level type in the local type declarations. Something like: doWithStack :: a -> a doWithStack x = stacking [] where type Stack = [a] stacking :: Stack -> a stacking = ... The problem is really two-fold: bound type variables (like "a") are not in scope in the body of the function, and local type declarations are not allowed. Secondly, "because another way of doing it is possible" is not an answer. We allow local declarations of functions, but we have known for ages we can all lambda-lift them to top-level... Regards, Koen. -- Koen Claessen http://www.cs.chalmers.se/~koen phone:+46-31-772 5424 mailto:koen@cs.chalmers.se ----------------------------------------------------- Chalmers University of Technology, Gothenburg, Sweden
On Thu, 26 Oct 2000, Koen Claessen wrote:
The problem is really two-fold: bound type variables (like "a") are not in scope in the body of the function, and local type declarations are not allowed.
GHC and Hugs do solve the first problem by providing a language extension: names of type variables in pattern type signatures and result type signatures are available in their scope. I wish this extension becomes a future standard. Some people say that type variables from ordinary type signatures should be in scope too. -- Marcin 'Qrczak' Kowalczyk
participants (4)
-
George Russell -
Koen Claessen -
Marcin 'Qrczak' Kowalczyk -
qrczak@knm.org.pl