Reputation: 1114
Is there any way to use lens
to get functionality similar to the functions in Data.List
? For instance I am thinking of something like
isPrefixOf :: Eq a => Seq a -> Seq a -> Bool
isSuffixOf :: Eq a => Seq a -> Seq a -> Bool
And of course these functions would work on a list, vector, etc. I would think lens
could do this sort of thing but from the Haddocks it's not apparent to me.
Upvotes: 0
Views: 114
Reputation: 27756
This is not a lens-based answer, but the monoid-subclasses package has the RightReductiveMonoid typeclass that offers isSuffixOf
, and LeftReductiveMonoid that offers isPrefixOf
.
List and Seq (along with many other containers) are instances of those typeclasses.
Upvotes: 4