Skip to content

Commit bf3bfa3

Browse files
committed
add example for rpure
1 parent e754df5 commit bf3bfa3

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Data/Vinyl/Core.hs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,23 @@ funcRec = Lift (\x -> Const "String")
291291
(<<*>>) = rapply
292292
{-# INLINE (<<*>>) #-}
293293

294-
-- | Given a section of some functor, records in that functor of any size are
295-
-- inhabited.
294+
{- |
295+
Given a section of some functor, records in that functor of any size are
296+
inhabited. Note that you need a value that can inhabit any type in the record.
297+
It is not possible, with this function, to derive a default with a type class
298+
method. Here are a few examples:
299+
300+
>>> testRec :: Rec Maybe '[Double, String] = rpure Nothing
301+
>>> testRec
302+
{Nothing, Nothing}
303+
>>> testRec :: Rec [] '[Double, String] = rpure []
304+
>>> testRec
305+
{[], []}
306+
>>> import Data.Proxy (Proxy(Proxy))
307+
>>> testRec :: Rec Proxy '[Double, String] = rpure Proxy
308+
>>> testRec
309+
{Proxy, Proxy}
310+
-}
296311
class RecApplicative rs where
297312
rpure
298313
:: (forall x. f x)

0 commit comments

Comments
 (0)