Ambiguity between Haskell Num class and my show-like class?

You're right about the overloading. It's a little tricky. Firstly, you will have to give a type signature to resolve the numeric overloading in your example: Ambiguous type variable `a0' in the constraints: (Some a0) arising from a use of `toSome' at A.

Hs:11:16-21 (Num a0) arising from the literal `3' at A. Hs:11:23 this means, as you noticed, that you have to pick a particular solution type, such as Int So how does Show work? By the magic of extended defaulting rules Show is special, and GHCi enables some special defaulting rules to help "default" the type in arguments of Show to Integer Your new class isn't one of the magic classes that the extended defaulting feature knows about, so sadly, you will need to give type annotations.

You're right about the overloading. It's a little tricky. Firstly, you will have to give a type signature to resolve the numeric overloading in your example: Ambiguous type variable `a0' in the constraints: (Some a0) arising from a use of `toSome' at A.

Hs:11:16-21 (Num a0) arising from the literal `3' at A. Hs:11:23 this means, as you noticed, that you have to pick a particular solution type, such as Int. So how does Show work?

By the magic of extended defaulting rules. Show is special, and GHCi enables some special defaulting rules to help "default" the type in arguments of Show to Integer. Your new class isn't one of the magic classes that the extended defaulting feature knows about, so sadly, you will need to give type annotations.

The reason something like show 3 works in the first place is due to the defaulting rule which picks a particular type when there is an ambiguity involving the Num class. The reason it doesn't work with your Some class is that the rule says that all classes involved have to be standard classes (i.e. , from the Prelude etc.).

This latter part of the rule is somewhat silly in opinion.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions