invertible- bidirectional arrows, bijective functions, and invariant functors

Safe HaskellSafe



Bidirectional version of Data.List and other operations over lists.



cons :: Maybe (a, [a]) <-> [a] Source #

Convert between Just (head, tail) and the non-empty list head:tail.

uncons :: [a] <-> Maybe (a, [a]) Source #

Convert between the non-empty list head:tail and Just (head, tail). (invert cons)

consMaybe :: (Maybe a, [a]) <-> [a] Source #

Convert between (Just head, tail) and the non-empty list head:tail, or (Nothing, list) and list.

repLen :: Int <-> [()] Source #

Combine replicate and length for unit lists.

map :: (a <-> b) -> [a] <-> [b] Source #

Apply a bijection over a list using map.

reverse :: [a] <-> [a] Source #

reverse the order of a (finite) list.

transpose :: [[a]] <-> [[a]] Source #

transpose the rows and columns of its argument.

lookup :: (Eq a, Eq b) => [(a, b)] -> Maybe a <-> Maybe b Source #

Bi-directional lookup.

index :: Eq a => [a] -> Maybe a <-> Maybe Int Source #

Combine elemIndex and safe !!.

zip :: ([a], [b]) <-> [(a, b)] Source #

zip two lists together.

zip3 :: ([a], [b], [c]) <-> [(a, b, c)] Source #

zip3 three lists together.

zip4 :: ([a], [b], [c], [d]) <-> [(a, b, c, d)] Source #

zip4 four lists together.

zip5 :: ([a], [b], [c], [d], [e]) <-> [(a, b, c, d, e)] Source #

zip5 five lists together.

zip6 :: ([a], [b], [c], [d], [e], [f]) <-> [(a, b, c, d, e, f)] Source #

zip6 six lists together.

zip7 :: ([a], [b], [c], [d], [e], [f], [g]) <-> [(a, b, c, d, e, f, g)] Source #

zip7 seven lists together.

zipWith :: ((a, b) <-> c) -> ([a], [b]) <-> [c] Source #

zipWith two lists together using a bijection.

interleave :: ([a], [a]) <-> [a] Source #

(Un)interleave two lists, e.g., between ([2,5,11],[3,7]) and [2,3,5,7,11].

lines :: String <-> [String] Source #

Split a string into lines.

words :: String <-> [String] Source #

Split a string into words.