| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Optic.Iso
Synopsis
- type Iso s t a b = forall (p :: * -> * -> *) (f :: * -> *). (Profunctor p, Functor f) => p a (f b) -> p s (f t)
- type Iso' s a = Iso s s a a
- iso :: (s -> a) -> (b -> t) -> Iso s t a b
- from :: AnIso s t a b -> Iso b a t s
- under :: AnIso s t a b -> (t -> s) -> b -> a
- enum :: Enum a => Iso' Int a
- curried :: (Profunctor p, Functor f) => p (a -> b -> c) (f (d -> e -> f)) -> p ((a, b) -> c) (f ((d, e) -> f))
- uncurried :: (Profunctor p, Functor f) => p ((a, b) -> c) (f ((d, e) -> f)) -> p (a -> b -> c) (f (d -> e -> f))
- flipped :: (Profunctor p, Functor f) => p (b -> a -> c) (f (b' -> a' -> c')) -> p (a -> b -> c) (f (a' -> b' -> c'))
- class Reversing t where
- reversed :: Reversing a => Iso' a a
- class Strict lazy strict | lazy -> strict, strict -> lazy where
- lazy :: Strict lazy strict => Iso' strict lazy
Iso
type Iso s t a b = forall (p :: * -> * -> *) (f :: * -> *). (Profunctor p, Functor f) => p a (f b) -> p s (f t) #
enum :: Enum a => Iso' Int a #
This isomorphism can be used to convert to or from an instance of Enum.
>>>LT^.from enum0
>>>97^.enum :: Char'a'
Note: this is only an isomorphism from the numeric range actually used
and it is a bit of a pleasant fiction, since there are questionable
Enum instances for Double, and Float that exist solely for
[1.0 .. 4.0] sugar and the instances for those and Integer don't
cover all values in their range.
curried :: (Profunctor p, Functor f) => p (a -> b -> c) (f (d -> e -> f)) -> p ((a, b) -> c) (f ((d, e) -> f)) #
uncurried :: (Profunctor p, Functor f) => p ((a, b) -> c) (f ((d, e) -> f)) -> p (a -> b -> c) (f (d -> e -> f)) #
flipped :: (Profunctor p, Functor f) => p (b -> a -> c) (f (b' -> a' -> c')) -> p (a -> b -> c) (f (a' -> b' -> c')) #
The isomorphism for flipping a function.
>>>((,)^.flipped) 1 2(2,1)
Reversing
This class provides a generalized notion of list reversal extended to other containers.
Minimal complete definition
Instances
| Reversing ByteString | |
Defined in Control.Lens.Internal.Iso Methods reversing :: ByteString -> ByteString # | |
| Reversing ByteString | |
Defined in Control.Lens.Internal.Iso Methods reversing :: ByteString -> ByteString # | |
| Reversing Text | |
Defined in Control.Lens.Internal.Iso | |
| Reversing Text | |
Defined in Control.Lens.Internal.Iso | |
| Reversing [a] | |
Defined in Control.Lens.Internal.Iso | |
| Reversing (NonEmpty a) | |
Defined in Control.Lens.Internal.Iso | |
| Reversing (Seq a) | |
Defined in Control.Lens.Internal.Iso | |
| Prim a => Reversing (Vector a) | |
Defined in Control.Lens.Internal.Iso | |
| Storable a => Reversing (Vector a) | |
Defined in Control.Lens.Internal.Iso | |
| Unbox a => Reversing (Vector a) | |
Defined in Control.Lens.Internal.Iso | |
| Reversing (Vector a) | |
Defined in Control.Lens.Internal.Iso | |
reversed :: Reversing a => Iso' a a #
An Iso between a list, ByteString, Text fragment, etc. and its reversal.
>>>"live" ^. reversed"evil"
>>>"live" & reversed %~ ('d':)"lived"
Strict
class Strict lazy strict | lazy -> strict, strict -> lazy where #
Ad hoc conversion between "strict" and "lazy" versions of a structure,
such as Text or ByteString.
Minimal complete definition