We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
map
1 parent 1d53fbd commit eecf17cCopy full SHA for eecf17c
src/Data/NonEmpty.purs
@@ -71,6 +71,11 @@ head (x :| _) = x
71
tail :: forall f a. NonEmpty f a -> f a
72
tail (_ :| xs) = xs
73
74
+-- | Useful for functorish non-functors like `Set`.
75
+-- > NonEmpty.map Set.map (_ + 1)
76
+map :: forall a b f. ((a -> b) -> f a -> f b) -> (a -> b) -> NonEmpty f a -> NonEmpty f b
77
+map mapper f (a :| as) = (f a :| mapper f as)
78
+
79
instance showNonEmpty :: (Show a, Show (f a)) => Show (NonEmpty f a) where
80
show (a :| fa) = "(NonEmpty " <> show a <> " " <> show fa <> ")"
81
0 commit comments