Skip to content

Commit e8202a4

Browse files
authored
Merge pull request #10 from purescript-contrib/generic
Add generic instance
2 parents dc23610 + 90c1087 commit e8202a4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"url": "git://github.com/paf31/purescript-nonempty.git"
1717
},
1818
"dependencies": {
19-
"purescript-foldable-traversable": "^1.0.0"
19+
"purescript-foldable-traversable": "^1.0.0",
20+
"purescript-generics": "^1.0.0"
2021
},
2122
"devDependencies": {
2223
"purescript-console": "^1.0.0",

src/Data/NonEmpty.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Control.Alternative (class Alternative)
2121
import Control.Plus (class Plus, empty)
2222

2323
import Data.Foldable (class Foldable, foldl, foldr, foldMap)
24+
import Data.Generic (class Generic)
2425
import Data.Traversable (class Traversable, traverse, sequence)
2526

2627
-- | A non-empty container of elements of type a.
@@ -78,6 +79,8 @@ instance ordNonEmpty :: (Ord a, Ord (f a)) => Ord (NonEmpty f a) where
7879
EQ -> compare fa1 fa2
7980
other -> other
8081

82+
derive instance genericNonEmpty :: (Generic (f a), Generic a) => Generic (NonEmpty f a)
83+
8184
instance functorNonEmpty :: Functor f => Functor (NonEmpty f) where
8285
map f (a :| fa) = f a :| map f fa
8386

0 commit comments

Comments
 (0)