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:  infinite type (Imants Cekusins)
   2. Re:  infinite type (Theodore Lief Gannon)
   3. Re:  infinite type (Imants Cekusins)
   4. Re:  infinite type (Imants Cekusins)
   5.  Functor instance for ordered lists (martin)
   6. Re:  Functor instance for ordered lists (Imants Cekusins)


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

Message: 1
Date: Sun, 3 Jan 2016 22:05:04 +0100
From: Imants Cekusins <ima...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] infinite type
Message-ID:
        <CAP1qinZJ_=1k1vgrTDhUd+QeeqmVbu7AkA=awlqbgysbqgr...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

>Where does the infinity come from?

Here is composition signature:

(.) <http://hackage.haskell.org/package/base-4.8.1.0/docs/Prelude.html#v:.> ::
(b -> c) -> (a -> b) -> a -> c

It looks like it is applicable to functions with 1 arg. Sum expects 2 args.
I guess this explains why sum can not be passed to f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160103/06feacaa/attachment-0001.html>

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

Message: 2
Date: Sun, 3 Jan 2016 13:30:38 -0800
From: Theodore Lief Gannon <tan...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] infinite type
Message-ID:
        <cajopsuazshrk4spjxiqhygwg23n17suqpgg70fogzop372q...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sun, Jan 3, 2016 at 1:05 PM, Imants Cekusins <ima...@gmail.com> wrote:

> Here is composition signature:
>
> (.)
> <http://hackage.haskell.org/package/base-4.8.1.0/docs/Prelude.html#v:.> ::
> (b -> c) -> (a -> b) -> a -> c
>
> It looks like it is applicable to functions with 1 arg. Sum expects 2
> args. I guess this explains why sum can not be passed to f
>
This isn't accurate, and it's useful to understand why. Every function in
Haskell has exactly one argument. Joel touched on this earlier. It's easier
to see if you add the implied parentheses to the type signatures:

    sum :: Num a => a -> (a -> a)
    f :: (a -> a) -> (a -> a)

To really drive it home, let's play with synonyms.

    type Endo' a = (a -> a)

Endo already exists as a newtype in Data.Monoid, thus Endo' here. Now:

    sum :: Num a => a -> Endo' a
    f :: Endo' a -> Endo' a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160103/5be32480/attachment-0001.html>

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

Message: 3
Date: Sun, 3 Jan 2016 22:50:27 +0100
From: Imants Cekusins <ima...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] infinite type
Message-ID:
        <CAP1qinbh6ST4HaiZ98Gqiy14Qe-zZWVYf=qbep+9j-ezzrf...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Well even if (.) can be used with functions returning functions (partially
applied),

calling g . g where g expects 2 args and returns 1 does not seem intuitive.

Could you think of a useful practical example of

(a->a->a) . (a->a->a)

?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160103/22f951f0/attachment-0001.html>

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

Message: 4
Date: Sun, 3 Jan 2016 23:43:31 +0100
From: Imants Cekusins <ima...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] infinite type
Message-ID:
        <CAP1qinY_y6dEPiVs-RR+ZszaxFhb003G=qros39ekpwrz-1...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

> Every function in Haskell has exactly one argument.

well partially applied functions may be used in the intermediary stages of
function processing however if programmer expects a function to return
primitive value (as opposed to a function), that return value will only be
available once that function is fully applied.

In other words, for
f:: (...) -> z

where z is a primitive value (not a function), (...) can be as long as we
like, if not full (...) are applied, we get
f1::(...')->z

To obtain z - the purpose f was written for - we need to pass full (...)

although every function may be passed 1 (or even 0) args, n  or
(in)complete args has some meaning.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160103/d9227244/attachment-0001.html>

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

Message: 5
Date: Mon, 4 Jan 2016 10:57:27 +0100
From: martin <martin.drautzb...@web.de>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] Functor instance for ordered lists
Message-ID: <568a4207.9040...@web.de>
Content-Type: text/plain; charset=utf-8

Hello all,

Data.List.Ordered is just a bunch of functions operating on ordinary Lists. 
Fmapping a function over an ordered list has
the potential of blowing the ordering.

Would it be possible to define a newtype for ordered lists where the order is 
guaranteed to be maintained? The functor
instance then may have to re-order the elements.

The problem I see is that

data Ordlist a = ...

would certainly require an Ord constraint on a, but where would I put it? I can 
put it on all the functions manipulating
OrdLists, but I still wouldn't know how to define a functor instance, because a 
Functor a does not require Ord a.


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

Message: 6
Date: Mon, 4 Jan 2016 11:45:52 +0100
From: Imants Cekusins <ima...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Functor instance for ordered lists
Message-ID:
        <cap1qinbhxapnhr+3pc1cs0y4juus4shtxryfuzvmcggskjq...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

> a newtype for ordered lists

why not:
newtype Ordlist a = Ordlist [a]

and a ctor:
ordList::[a]->OrdList a
ordList = OrdList . sort

sort :: Ord a => [a] -> [a]
from Data.List


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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 91, Issue 5
****************************************

Reply via email to