
10 Jan
2019
10 Jan
'19
9:27 a.m.
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.