Closed Rosuavio closed 3 years ago
To my knowledge, the desired implementation for the Read typeclass can only be derived when the language extensions GeneralizedNewtypeDeriving and DerivingStrategies are enabled.
To fix this problem, I would suggest one of the following:
a.) adding
{-# LANGUAGE GeneralizedNewtypeDeriving, DerivingStrategies #-}
at the top of the file - but even with this modification, solving the exercise might be beyond the scope of this tutorial
or:
b.) changing the Unit test to:
testCase "Read Interest Rate" $ map read ["InterestRate 0.5", "InterestRate 0.3", "InterestRate 0.788"] @?= [InterestRate 0.5, InterestRate 0.3, InterestRate 0.788]
(Just to be clear, these suggestions are for the maintainers, not for the user. I'm happy to make these changes if no one else does.)
I think maybe the best solution is b
, I don't think having exercises use language extensions without explaining them would allow the user to properly understand the problem when they find a solution and I don't think that this exercise is a good place to introduce language extensions.
In the Typeclasses3
https://github.com/MondayMorningHaskell/haskellings/blob/6bf3510e1bfd15f190de2e899699113b04ac2954/exercises/typeclasses/Typeclasses3.hs#L56-L58
these directions say to simply "Derive"
Read
. I would think that means simply addedRead
to the list ofderiving
s resulting inBut when I do that I get this error.
I am not sure if I am doing something wrong as the user, ~or if maybe it was intended to instruct the users to implement
Read
,~ or if this is supposed to work and is not for me for some reason.Edit: Implementing
Read
seems too complicated for this exercise.