CC: [EMAIL PROTECTED]
Yes, I've always tended to think that the parameters of a function need
to be given types explicity. Simon missed one interesting line from my
example -- something is needed to specify the context in a form that
makes it usable within the body of the function. How about this:
(Num c) =>
(f (xs::[a]))::c =
-- do I need an explicit fromInteger here?
if len > 3 then len else 0 where
len :: c = length xs
?
It's not very pretty, but I'm not sure that's important just now...
----------
From: mpj
Sent: 22 July 1998 12:00
To: Simon L Peyton Jones <[EMAIL PROTECTED]>;
[EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: Scoped typed variables.
To: Simon L Peyton Jones <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Subject: RE: Scoped typed variables.
| Michael suggested
|
| f :: [a] -> c
| f xs = if len > fromInteger 3 then len else 0
| where
| len :: c
| len = length xs
|
| This relies on the 'c' from the type signature scoping over
| the definition, which is on alternative notation for scoped
| type variables.
Hmm, interesting. Perhaps we need to allow type annotations on
left hand sides as well as embedded in patterns:
f xs :: c = ...
I know it looks a bit ugly ... add a few more parens and it
starts to remind me of Pascal! :-)
All the best,
Mark