@@ -335,7 +335,6 @@ ext Nothing = Nothing
335335>>> rtraverse ext testRec
336336Nothing
337337-}
338-
339338rtraverse
340339 :: Applicative h
341340 => (forall x . f x -> h (g x ))
@@ -345,13 +344,28 @@ rtraverse _ RNil = pure RNil
345344rtraverse f (x :& xs) = (:&) <$> f x <*> rtraverse f xs
346345{-# INLINABLE rtraverse #-}
347346
348- -- | While 'rtraverse' pulls the interpretation functor out of the
349- -- record, 'rtraverseIn' pushes the interpretation functor in to each
350- -- field type. This is particularly useful when you wish to discharge
351- -- that interpretation on a per-field basis. For instance, rather than
352- -- a @Rec IO '[a,b]@, you may wish to have a @Rec Identity '[IO a, IO
353- -- b]@ so that you can evaluate a single field to obtain a value of
354- -- type @Rec Identity '[a, IO b]@.
347+ {- |
348+ While 'rtraverse' pulls the interpretation functor out of the
349+ record, 'rtraverseIn' pushes the interpretation functor in to each
350+ field type. This is particularly useful when you wish to discharge
351+ that interpretation on a per-field basis. For instance, rather than
352+ a @Rec IO '[a,b]@, you may wish to have a @Rec Identity '[IO a, IO
353+ b]@ so that you can evaluate a single field to obtain a value of
354+ type @Rec Identity '[a, IO b]@.
355+
356+ >>> import Data.Vinyl.Functor (Identity(Identity))
357+ >>> testRec :: Rec Maybe '[String, Double, Int] = Just "Ho" :& Just 3.0 :& Nothing :& RNil
358+ >>>
359+ :{
360+ push :: forall x. Maybe x -> Identity (Maybe x)
361+ push (Just x) = Identity (Just x)
362+ push Nothing = Identity Nothing
363+ :}
364+ >>> :t rtraverseIn push testRec
365+ rtraverseIn push testRec
366+ :: Rec Identity '[Maybe [Char], Maybe Double, Maybe Int]
367+ -}
368+
355369rtraverseIn :: forall h f g rs .
356370 (forall a . f a -> g (ApplyToField h a ))
357371 -> Rec f rs
0 commit comments