Haskell why does “Num x” require “Show x”?

后端 未结 4 1647
北荒
北荒 2020-12-20 13:00

Recently I took a look at Haskell, using LYAH.

I was messing around with type classes and wrote this quick test function:

foo :: (Num x) => x ->         


        
4条回答
  •  甜味超标
    2020-12-20 13:18

    It used to be that an instance of Num was also an instance of Show and Eq , but that's no longer the case.

    You'll need to add a Show constraint as well.

提交回复
热议问题