[Haskell-beginners] applicative default structure
toad3k at gmail.com
Thu Dec 22 15:33:41 UTC 2016
Rather than bailing with an instance error for both Applicative and Num,
which is the technically the right way, and the way that it used to be in
the dark ages of ghci. Instead it chooses types which are probably what
you wanted. In this case it defaults f to IO and a to Int, and then runs
You can read more about type defaulting in ghci here:
On Thu, Dec 22, 2016 at 10:18 AM, Ovidiu Deac <ovidiudeac at gmail.com> wrote:
> My understanding is that x can take any form required for type-inference.
> That's fine but what is the "default" structure if you don't specify any?
> On Thu, Dec 22, 2016 at 5:13 PM, Imants Cekusins <imantc at gmail.com> wrote:
>> > What is f here?
>> anything Applicative:
>> Prelude> let a1 = pure 1
>> Prelude> let a2 = pure 1
>> Prelude> (a1::Maybe Int) == a2
>> Prelude> (a1::Maybe Float) == a2
>> Prelude> (a1::Either String Float) == a2
>> Beginners mailing list
>> Beginners at haskell.org
> Beginners mailing list
> Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners