Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

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


Today's Topics:

   1.  Fwd:  Functional Dependencies (dan portin)
   2. Re:  About 'Curry' (Chadda? Fouch?)


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

Message: 1
Date: Fri, 10 Dec 2010 23:22:08 -0800
From: dan portin <[email protected]>
Subject: [Haskell-beginners] Fwd:  Functional Dependencies
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

*unflt* was a poor choice of name. *flt2*, which flattens a datatype
containing a flattenable datatype, would have been a better name.

>
> If I was making a flatten class, I wouldn't want Monad as a constraint
> on the result container. Monad doesn't really say anything about
> "containers" - there are some containers that are Monads, but there
> are monads that aren't containers and there are containers that aren't
> monads.
>

You're right. My initial class was

class Monoid m => t -> m where
   flt :: t -> m

instance (Tree a) [a] where flt = fltTree
instance (Maybe a) [a] where flt = maybeToList

for some tree type like `data Tree a = Nil | Node a (Tree a) (Tree a)` (for
simplicity). The problem is that I couldn't figure out how to type the
"flatten twice" function, which required a declaration like

flt2 :: (F t' m) => t' t -> m

which is clearly incorrect (since it gives rise to a kind mismatch). "Monad"
and "Functor" were introduced just to get the definition of *unflt* to work,
and was unsatisfactory.

I need to be able to assert that *flt2* is a nested flattenable datatype,
and that the return type of the nested and containing datatype is the same
monoid. I can't figure out how to type this, however.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101210/92906aad/attachment-0001.htm>

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

Message: 2
Date: Sat, 11 Dec 2010 10:27:15 +0100
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] About 'Curry'
To: Tobias Brandt <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

On Fri, Dec 10, 2010 at 1:05 PM, Tobias Brandt
<[email protected]> wrote:
> To use an operator as a function you must use the section notation:
>
> pl a = (a ++)

Note that the section notation is slightly more flexible than the
above since you can also do :

> pl b = (++ b)

So that's not currying per se since operators are not syntactically
handled like functions.
Of course behind the scene operators are only functions, to use them
strictly as normal functions Haskell provide the following syntax :

> pl a b = (++) a b

So your first try could be written :

> pl a = (++) a

Just like with an ordinary function.

The second section notation variant (++ b) is perfectly equivalent to
the following :

> pl b = flip (++) b

-- 
Jeda?



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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 30, Issue 15
*****************************************

Reply via email to