concise-0.1.0.1: Utilities for Control.Lens.Cons

Safe HaskellNone
LanguageHaskell2010

Control.Lens.Cons.Extras

Synopsis

Documentation

recons :: (Cons s1 s1 a a, Cons s2 s2 a a, AsEmpty s2) => Getter s1 s2 Source #

Convert one type with a Cons instance into the other.

Rewrite rules are provided for efficient conversion between String and Text, [Word8] and ByteString, and lazy and strict Text and ByteString. Programs must be compiled with -O to use them.

Although the type does not prove it, if (recons . recons) exists it should obey:

recons . recons ≡ id

The NOINLINE pragma is used to ensure that recons does not get inlined into function that are polymorphic in s1 or s2. Such functions should use the INLINE pragma to give rewrite rules the best chance of firing.

unfoldr :: (Cons s2 s2 a a, AsEmpty s2) => (s1 -> Maybe (a, s1)) -> s1 -> s2 Source #

unfoldr f = foldrOf (unfolded f) cons (_Empty # ())