composite-tuple-0.1.0.0: Tuple functions for composite records.

LicenseMIT
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Composite.Record.Tuple

Description

Tuple functions for composite records, inspired by relude.

Synopsis

Documentation

toFst :: (a -> b) -> a -> Record ((s :-> b) ': ((s' :-> a) ': '[])) Source #

Apply a function, with the result in the fst slot, and the value in the other.

toSnd :: (a -> b) -> a -> Record ((s :-> a) ': ((s' :-> b) ': '[])) Source #

Apply a function with the result in the snd slot, and the value in the other.

fmapToFst :: Functor f => (a -> b) -> f a -> f (Record ((s :-> b) ': ((s' :-> a) ': '[]))) Source #

Like fmap, but also keep the original value in the snd position.

fmapToSnd :: Functor f => (a -> b) -> f a -> f (Record ((s :-> a) ': ((s' :-> b) ': '[]))) Source #

Like fmap, but also keep the original value in the fst position.

traverseToFst :: Functor m => (a -> m b) -> a -> m (Record ((s :-> b) ': ((s' :-> a) ': '[]))) Source #

Apply a function that returns a value inside of a functor, with the output in the first slot, the input in the second, and the entire tuple inside the functor.

traverseToSnd :: Functor m => (a -> m b) -> a -> m (Record ((s :-> a) ': ((s' :-> b) ': '[]))) Source #

Apply a function that returns a value inside of a functor, with the output in the second slot, the input in the fist, and the entire tuple inside the functor.

fanout :: (x -> a) -> (x -> b) -> x -> Record ((s :-> a) ': ((s' :-> b) ': '[])) Source #

Apply two functions to a single value and store the results in each slot.

fanoutM :: Applicative m => (x -> m a) -> (x -> m b) -> x -> m (Record ((s :-> a) ': ((s' :-> b) ': '[]))) Source #

Apply two applicative functions to a single value and store the results in each slot.