Not that this is completely satisfactory, but you could do:
data Greek = Alpha | Beta | Gamma | Phi deriving (Show) showGreek Beta = "2" showGreek x = show x
And use showGreek instead of show. If you need a real instance to display (in my code, I think I need it less than beginners think), you can do it rather cumbersome:
newtype Greek' = Greek' Greek instance Show Greek' where show (Greek' g) = showGreek g
If this were my code, I would just stick with showGreek .
The good rule of thumb that I use is that Show and Read instances are generated only by Haskell. If show does not generate valid Haskell code, it should not be in the Show instance.
luqui
source share