how to write a derivable class?

前端 未结 2 1243
太阳男子
太阳男子 2020-12-31 08:24

i have this

data Something = Something Integer deriving (MyClass, Show)

class MyClass a where   
    hello :: MyClass a => a -> a

instance MyClass In         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 09:05

    You may want to have a look at the GHC documentation on Generic Programming.
    You need to create a class that can work on a generic representation of arbitrary types. I don't think the specific example you gave is reasonable for a derivable class.

提交回复
热议问题