Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Fwd: Re:  Multiple letters between -> -> (Francesco Ariis)
   2. Re:  Fwd: Re: Multiple letters between -> -> (Marcus Manning)
   3. Re:  Fwd: Re: Multiple letters between -> -> (Francesco Ariis)
   4. Re:  Fwd: Re: Multiple letters between -> -> (Marcus Manning)
   5. Re:  Fwd: Re: Multiple letters between -> -> (Francesco Ariis)
   6. Re:  Fwd: Re: Multiple letters between -> -> (Jeffrey Brown)


----------------------------------------------------------------------

Message: 1
Date: Sat, 25 Nov 2017 13:48:32 +0100
From: Francesco Ariis <fa...@ariis.it>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] Fwd: Re:  Multiple letters between ->
        ->
Message-ID: <20171125124832.2aosbp247cp6i...@x60s.casa>
Content-Type: text/plain; charset=utf-8

On Sat, Nov 25, 2017 at 01:06:03PM +0100, Marcus Manning wrote:
> I do not believe that h is a higher kinded type. What I want to express
> is that a function f could take a type constructor as argument and
> simply returns it, but
> 
> f Maybe
> 
> throws an Error

Hello Marcus,
    you cannot pass type constructors (Maybe) to functions! Only *data*
constructors (Just, Nothing).
Hence the reason why the compiler complains, there is no *data* constructor
named `Maybe`. Even in ghci, to inspect type constructors, we use a
different command

    λ> :type Maybe

    <interactive>:1:1: error:
        • Data constructor not in scope: Maybe
        • Perhaps you meant variable ‘maybe’ (imported from Prelude)
    λ> :kind Maybe
    Maybe :: * -> *



------------------------------

Message: 2
Date: Sat, 25 Nov 2017 15:03:26 +0100
From: Marcus Manning <icons...@gmail.com>
To: Francesco Ariis <fa...@ariis.it>, The Haskell-Beginners Mailing
        List - Discussion of primarily beginner-level topics related to
        Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Fwd: Re: Multiple letters between ->
        ->
Message-ID: <dccb9c0d-5adc-a94f-2f93-3396ac9b8...@gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed

Ok,

but what is h in:

f :: h a -> ...

is "h" a data constructor or a type constructor or a normal function? 
What is j in

f:: j k l -> ...

and hwat is the difference between j and h?

On 11/25/2017 01:48 PM, Francesco Ariis wrote:
> On Sat, Nov 25, 2017 at 01:06:03PM +0100, Marcus Manning wrote:
>> I do not believe that h is a higher kinded type. What I want to express
>> is that a function f could take a type constructor as argument and
>> simply returns it, but
>>
>> f Maybe
>>
>> throws an Error
> Hello Marcus,
>      you cannot pass type constructors (Maybe) to functions! Only *data*
> constructors (Just, Nothing).
> Hence the reason why the compiler complains, there is no *data* constructor
> named `Maybe`. Even in ghci, to inspect type constructors, we use a
> different command
>
>      λ> :type Maybe
>
>      <interactive>:1:1: error:
>          • Data constructor not in scope: Maybe
>          • Perhaps you meant variable ‘maybe’ (imported from Prelude)
>      λ> :kind Maybe
>      Maybe :: * -> *
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners




------------------------------

Message: 3
Date: Sat, 25 Nov 2017 15:34:47 +0100
From: Francesco Ariis <fa...@ariis.it>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Fwd: Re: Multiple letters between ->
        ->
Message-ID: <20171125143447.gznsf63rh6put...@x60s.casa>
Content-Type: text/plain; charset=utf-8

On Sat, Nov 25, 2017 at 03:03:26PM +0100, Marcus Manning wrote:
> Ok,
> 
> but what is h in:
> 
> f :: h a -> ...
> 
> is "h" a data constructor or a type constructor or a normal function?
> What is j in
> 
> f:: j k l -> ...
> 
> and hwat is the difference between j and h?

`h` is a type constructor and `h a` denotes a kind of `* -> *`, hence

    λ> :t f
    f :: h s -> h s
    λ> :t f (Just 8)
    f (Just 8) :: Num s => Maybe s
        -- because Maybe :: * -> *
    λ> :t f Bool
    <interactive>:1:3: error:
        Data constructor not in scope: Bool :: h s

Similarly, `f :: j k l -> j k l` would only work on kinds
`* -> * -> *` (tuples, etc.) and not on Maybes (* -> *).




------------------------------

Message: 4
Date: Sat, 25 Nov 2017 16:19:04 +0100
From: Marcus Manning <icons...@gmail.com>
To: Francesco Ariis <fa...@ariis.it>, The Haskell-Beginners Mailing
        List - Discussion of primarily beginner-level topics related to
        Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Fwd: Re: Multiple letters between ->
        ->
Message-ID: <d8cbfda9-60cc-528c-8515-a46fe2e79...@gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed

Ah thanks,

I get confused with instance and declaration level.

But why I can call g with Just:


let g :: h a b -> h a b; g a = a

g Just

but Just is a->Maybe a

On 11/25/2017 03:34 PM, Francesco Ariis wrote:
> On Sat, Nov 25, 2017 at 03:03:26PM +0100, Marcus Manning wrote:
>> Ok,
>>
>> but what is h in:
>>
>> f :: h a -> ...
>>
>> is "h" a data constructor or a type constructor or a normal function?
>> What is j in
>>
>> f:: j k l -> ...
>>
>> and hwat is the difference between j and h?
> `h` is a type constructor and `h a` denotes a kind of `* -> *`, hence
>
>      λ> :t f
>      f :: h s -> h s
>      λ> :t f (Just 8)
>      f (Just 8) :: Num s => Maybe s
>          -- because Maybe :: * -> *
>      λ> :t f Bool
>      <interactive>:1:3: error:
>          Data constructor not in scope: Bool :: h s
>
> Similarly, `f :: j k l -> j k l` would only work on kinds
> `* -> * -> *` (tuples, etc.) and not on Maybes (* -> *).
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners




------------------------------

Message: 5
Date: Sat, 25 Nov 2017 17:39:54 +0100
From: Francesco Ariis <fa...@ariis.it>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Fwd: Re: Multiple letters between ->
        ->
Message-ID: <20171125163954.5rlpyxcxxxjmz...@x60s.casa>
Content-Type: text/plain; charset=utf-8

On Sat, Nov 25, 2017 at 04:19:04PM +0100, Marcus Manning wrote:
> But why I can call g with Just:
> 
> 
> let g :: h a b -> h a b; g a = a
> 
> g Just
> 
> but Just is a->Maybe a

Because (->) is a type constructor itself, just with
convenient infix syntax:

    λ> :k (->)
    (->) :: TYPE q -> TYPE r -> *



------------------------------

Message: 6
Date: Sat, 25 Nov 2017 09:56:50 -0800
From: Jeffrey Brown <jeffbrown....@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Fwd: Re: Multiple letters between ->
        ->
Message-ID:
        <CAEc4Ma3Dh-1+wxUn_gACEhkfxS0x5M9TW3CvXM3A2RY=ows...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I don't know if this is helpful, but I've abbreviated and elaborated on
what Francesco said.

> Original I thought a Signature like:
>
> f :: h a -> h a
>
> means that h is a higher kinded type just like in Type Classes ( for
instance f in Functor f).
>
> But I heard such a meaning is not allowed in normal Haskell functions.
What instead is the meaning of h a?

Let's take a concrete example:

Prelude> let f = fmap id
Prelude> :t f
f :: Functor f => f b -> f b
Prelude>

The (->) symbol goes between types (it takes one type to another), so f b
must be a type, and therefore f is a type constructor.

> f Maybe
>
> throws an Error

Maybe is a type constructor, not a value constructor. Functions in Haskell
can only take types. Value constructors are types; type constructors are
not.

> but what is h in:
>
> f :: h a -> ...
>
> is "h" a data constructor or a type constructor or a normal function?
What is j in
>
> f:: j k l -> ...
>
> and hwat is the difference between j and h?

h and j in those examples are both type constructors. One of them takes two
arguments, the other only takes one.

> But why I can call g with Just:
>
>
> let g :: h a b -> h a b; g a = a
>
> g Just
>
> but Just is a->Maybe a

Just has type "(->) a (Maybe a)", a.k.a. type "a -> Maybe a". (->) is a
two-argument type constructor.

On Sat, Nov 25, 2017 at 8:39 AM, Francesco Ariis <fa...@ariis.it> wrote:

> On Sat, Nov 25, 2017 at 04:19:04PM +0100, Marcus Manning wrote:
> > But why I can call g with Just:
> >
> >
> > let g :: h a b -> h a b; g a = a
> >
> > g Just
> >
> > but Just is a->Maybe a
>
> Because (->) is a type constructor itself, just with
> convenient infix syntax:
>
>     λ> :k (->)
>     (->) :: TYPE q -> TYPE r -> *
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>



-- 
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/>   |   Facebook
<https://www.facebook.com/mejeff.younotjeff>   |   LinkedIn
<https://www.linkedin.com/in/jeffreybenjaminbrown>(spammy, so I often miss
messages here)   |   Github <https://github.com/jeffreybenjaminbrown>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20171125/f37cec53/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 113, Issue 25
******************************************

Reply via email to