Singpolyma

singpolyma commented on Return type overloading question at Reddit, saying

You can overload two different types, but not two different values for the same type — how would it even choose which one to return?

Here's what I think you want:

data B = B String
data C = C Int

class BorC a where
    get :: a

instance BorC B where
    get = B "1"

instance BorC C where
    get = C 1
in reply to @ 2016-97 20:33 UTC

Leave a Response