I know that String is defined as [Char], but I would like to make the difference between the two of them in an instance of the class. Is this possible with some kind of clever trick besides using newtype to create a separate type? I would like to do something like:
class Something a where doSomething :: a -> a instance Something String where doSomething = id instance (Something a) => Something [a] where doSomething = doSoemthingElse
And get different results when I call it with doSomething ("a" :: [Char]) and doSomething ("a" :: String) .
I know about FlexibleInstances and OverlappingInstances , but they obviously don't cut the case.
types haskell
qwe2
source share