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@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@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


--

Lawrence Bottorff
Grand Marais, MN, USA
borgauf@gmail.com