Unfortunately — for historical reasons — you need to implement readsPrec
:
λ> :t readsPrec
readsPrec :: Read a => Int -> ReadS a
λ> :i ReadS
type ReadS :: * -> *
type ReadS a = String -> [(a, String)]
-- Defined in ‘Text.ParserCombinators.ReadP’
So, most likely:
instance Read Fruit where
readsPrec _ c =
let (s, r) = span (/= ' ') c
in case c of
"XYZ" -> Foo
-- ⁝ got to buy groceries now
I wonder if that last catch-all case could come back to bite you in a creative read
/show
sequence in a nested data type.