[Haskell-beginners] Implementing Read
Peter Hall
peter.hall at memorphic.com
Sun Sep 11 23:58:52 CEST 2011
Thanks, I was just responding, with:
readsPrec _ (b:a:rest) = [(Card{ suit=(toSuit a), rank=(read [b]) }, rest)]
Thanks for your help!
Peter
On Sun, Sep 11, 2011 at 10:56 PM, Daniel Fischer
<daniel.is.fischer at googlemail.com> wrote:
> On Sunday 11 September 2011, 23:27:53, Peter Hall wrote:
>> Thanks,
>> Good spot on the order. I'll get to that, but I still didn't have
>> success with your other suggestion.
>
> Oops, yes.
>
> readsPrec returns a list of pairs, [(parsed value, remaining input)],
>
> so
>
> readsPrec _ (a:b) =
> [(Card{suit = toSuit a, rank = r}, trl) | (r, trl) <- reads b]
> where
> toSuit 'c' = Club
> ...
>
More information about the Beginners
mailing list