Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Streaming/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ module Streaming.Prelude (
, fst'
, snd'
, mapOf
, uncurry'
, _first
, _second

Expand Down Expand Up @@ -365,6 +366,15 @@ mapOf :: (a -> b) -> Of a r -> Of b r
mapOf f (a:> b) = (f a :> b)
{-#INLINE mapOf #-}

{-| The analogue of 'uncurry' to apply a function to both elements of a left-strict pair.

This can be especially useful combined with functions like 'mapped'.

-}
uncurry' :: (a -> b -> c) -> Of a b -> c
uncurry' f (a :> b) = f a b
{-# INLINE uncurry' #-}

{-| A lens into the first element of a left-strict pair -}
_first :: Functor f => (a -> f a') -> Of a b -> f (Of a' b)
_first afb (a:>b) = fmap (\c -> (c:>b)) (afb a)
Expand Down