Closed
Description
Currently StringLike is implemented by String and looks like it was in mind to only allowe structures which contain some Chars.
But I think it could be easily changed to support arbitrary containers of arbitrary data.
for example one might define some sumtype Data Color = Red | Blue| Orange ...
and have wants to parse List Color
into some other structure or maybe even in itself and just validate that colors in the List are in correct order or whatever.
But the StringLike is limiting this kind of use.
What i think is that the class could be changed to:
class StringLike f where
drop :: forall a. Int -> f a -> f a
indexOf :: forall a. f a -> f a -> Maybe Int
null :: forall a. f a -> Boolean
uncons :: forall a. f a -> Maybe { head :: a, tail :: f a }
This way one could implement StringLike for List/Array ... and for example anyChar
will change to
anyChar :: forall f s m. StringLike f => Monad m => ParserT (f s) m s
Metadata
Metadata
Assignees
Labels
No labels