[Haskell-beginners] Type signatures returned with :t

Galaxy Being borgauf at gmail.com
Sun Sep 19 02:19:09 UTC 2021


Either returns with its parameters, reversed, but Maybe did not. That's my
main question.

On Sat, Sep 18, 2021 at 5:43 PM Francesco Ariis <fa-ml at ariis.it> wrote:

> Il 18 settembre 2021 alle 17:30 Galaxy Being ha scritto:
> > > :t Just True
> > Just True :: Maybe Bool
> > > :t Left True
> > Left True :: Either Bool b
> > > :t Right False
> > Right False :: Either a Bool
> >
> > What am I being told here? It seems
> > are both straightforward parameterized types, but Maybe doesn't give me a
> > type parameter back, while Either does, and in different order, different
> > names (a becomes b; b becomes a) depending on which variable I invoke.
> What
> > deeper lore am I not seeing here?
>
> When you ask the type of
>
>     λ> :t Just True
>
> the interpreter *knows* that that `Maybe` is not just a `Maybe a` (so
> type constructor and its type parameter) but the /concrete/ type `Maybe
> Bool`. This would not be the case if we did
>
>     λ> :t Nothing
>     Nothing :: Maybe a
>
> Same story with `Either`. Each of the two data constructors (`Left` and
> `Right`) let the interpreter infer just *one* of the type parameters
> (the `a` and `b` in `Either a b`).
> Does this answer your question?
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>


-- 
⨽
Lawrence Bottorff
Grand Marais, MN, USA
borgauf at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210918/73fa3562/attachment.html>


More information about the Beginners mailing list