[Haskell-cafe] using type variables in type declarations inside function

Ryan Reich ryan.reich at gmail.com
Thu Apr 12 20:41:33 UTC 2018


I too am curious about the forall in ScopedTypeVariables. It seems formally
unnecessary, so I assume it is designed to avert some kind of inconsistency
with standard behavior? Thinking about other extensions, e.g.
FlexibleInstances or MultiParamTypeClasses, it seems like they all give
meaning to constructs that are forbidden by the standard, while this one
actually changes the standard behavior (for the better, imho) and so
requires protection by some nonstandard signifier, i.e. forall.

On Apr 12, 2018 13:27, "Dennis Raddle" <dennis.raddle at gmail.com> wrote:

Thanks!

By the way, why do I sometimes have to use forall, and sometimes not?

I'm also learning Purescript, and I noticed that the examples use 'forall'
in every case. Why would it be different with Purescript?
D

On Thu, Apr 12, 2018 at 12:51 PM, Brandon Allbery <allbery.b at gmail.com>
wrote:

> On Thu, Apr 12, 2018 at 3:47 PM, Dennis Raddle <dennis.raddle at gmail.com>
> wrote:
>
>> myFunc :: a -> b -> c
>> myFunc x y z = ...
>>   where
>>     helper :: a -> [b]
>>     helper xx = ...
>>
>> Notice that I'm attempting to declare 'helper' using my type variables.
>> I've noticed that this results in an error.
>> Is this actually possible, and how?
>>
>
> You need the ScopedTypeVariables extension, *and* to "declare" the type
> variables whose scope is to be extended with an explicit "forall" in the
> signature.
>
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180412/91e25739/attachment.html>


More information about the Haskell-Cafe mailing list