I am new to Haskell. One quirk I have come across is that if I want to implement a Show
instance for an arbitrary function, I am told by the compiler that I need to enable the FlexibleInstances
pragma, and the relaxation there indeed fixes my code, which looks like this:
instance Show (a -> ()) where
show a = "OK"
The use case is not really important; a dead-simple “test runner” function which computes some assertions in a do
block and finishes with a pure ()
.
My question is: How would I write the above (presumably using a newtype
?) such that it wouldn’t require the pragma?