-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Description
Please consider adding a Unit
type:
newtype Unit = Unit { runUnit :: () }
instance Semigroup Unit where
(<>) = seq
instance Monoid Unit where
mempty = Unit ()
This makes it possible to writes instances conveniently using folds. Some examples:
instance NFData1 [] where
liftRnf f = runUnit . foldMap (Unit . f)
-- from containers
instance NFData2 Map where
liftRnf2 f g = runUnit . foldMapWithKey (\k x -> Unit (f k `seq` g x))
See related: #18
Unit
here is the UnitLTR
type defined there. However, #18 only uses it internally. This issue is about exporting the type so users can use it freely.
edmundnoble
Metadata
Metadata
Assignees
Labels
No labels