Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Okay, I'll have to bite: this kata is pointless in Haskell.
First, it's because it's reimplementing
NumandFractionalfrom scratch that also exactly matches them. Secondly, the design of usingData Numberwith every type being a constructor is extremely dumb and very anti-Haskell, to the point that I'm suspecting you haven't read Learn You a Haskell at all: Haskell unifies every number datatype to theNumtypeclass exactly so that:Numinstances by implementing theNuminstance of your datatype, and then it automatically worksNuminstances without modifying theNumdefinition itself (it's why makingNuma datatype is a bad idea)n^2definitions forntypes you haveAnd this is why you have all sorts of problems in the first place with
Complexand such. It's because this entire kata is based on a very wrong approach.Integeris definitely not an instance ofFractional. What's the supposed behaviour?absandsignumof a complex number is not defined. As mentioned in the official docs, You need to haveabsandsignumrespect the lawBut this property is impossible for complex numbers.
Also,
Your definition of
Numberallows constructions likeComplex (Complex (Real 0) (Real 1)) (Complex (Real 1) (Real 0)), which is absurd.This comment is hidden because it contains spoiler information about the solution