[Haskell-cafe] overloading functions

Damien Mattei damien.mattei at gmail.com
Thu Jan 10 19:38:23 UTC 2019


i'm not so pessimist,i'm beginning to have fun with haskell...really!
about teaching ressource i will be happy to know where i can find them...
i only post in haskell cafe when i have not find the answer online
(tutorials,stackoverflow,real haskell book
<http://book.realworldhaskell.org/>etc,etc... in the hunded pages i search
i even get a look at Categories for the working Mathematician
<https://books.google.fr/books?id=6KPSBwAAQBAJ&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false>)
it is only when i have exhausted all the online ressource that i post to
the cafe...

On Thu, Jan 10, 2019 at 6:52 PM Tom Ellis <
tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> wrote:

> On Thu, Jan 10, 2019 at 04:23:49PM +0100, Damien Mattei wrote:
> > Le 10/01/2019 15:27, Tom Ellis a écrit :
> > > On Thu, Jan 10, 2019 at 12:34:04PM +0100, Damien Mattei wrote:
> > >> i have this definition:
> > >>
> > >> {-# LANGUAGE FlexibleInstances #-}
> > >>
> > >> class ConcatenateMaybeString a where
> > >>   cms :: Maybe String -> a -> Maybe String
> > >>
> > >>
> > >> instance  ConcatenateMaybeString (Maybe String) where
> > >>      cms mf ms =
> > >>        mf >>= (\f ->
> > >>             ms >>= (\s ->
> > >>                       return (f ++ s)))
> > >>
> > >>
> > >>
> > >> instance  ConcatenateMaybeString String where
> > >>      cms mf s =
> > >>        mf >>= (\f -> return (f ++ s))
> > >
> > > Trying to simulate overloading like this is ultimately going to lead
> to more
> > > frustration than benefit.  I strongly suggest you just define two
> different
> > > functions.
> >
> > those functions could be seen as a "style exercise" , for me,coming from
> > untyped languages such as Scheme or LisP it's Haskell which is a
> > frustration :-)
>
> I think you're going to get significantly more frustrated with Haskell if
> you try to learn it like this by yourself rather than by working through
> some widely approved teaching resource.  Of course, how you spend your time
> is up to you, but if you're frustrated with Haskell then trying to make it
> up as you go along is only going to worsen the feeling!
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190110/912d6d4f/attachment.html>


More information about the Haskell-Cafe mailing list