An Iso is a tool which converts elements of type A into elements of type B and back without loss.
Identity: \x -> iso.get(iso.reverseGet x) == x
Reversed: \x -> iso.reverseGet(iso.get x) == xstring2CharListIso : Iso String (List Char)
string2CharListIso =
Iso String.toList String.fromList
(string2CharListIso.get "ABcdE") == ['A','B','c','d','E']
(string2CharListIso.reverseGet ['A','B','c','d','E']) == "ABcdE"Creates reversed Iso b a, exchanges functions get and reverseGet
.get (Iso.reversed someiso) == someiso.reverseGet
.reverseGet (Iso.reversed someiso) == someiso.get
Iso.compose someiso (Iso.reversed someiso) == Iso identity identityModifies given function (b -> b) to be (a -> a) using Iso a b
someiso = Iso String.toList String.fromList
somefx xs = '@' :: xs
modified = Iso.modify someiso somefx
(modified "artur") == "@artur"Composes Iso a b with Iso b c and returns Iso a c
In order to create an
Isowe need to supply two total functions:getandreverseGet