diff --git a/bower.json b/bower.json index 3c007ca..270b7e4 100644 --- a/bower.json +++ b/bower.json @@ -16,7 +16,8 @@ "url": "git://github.com/paf31/purescript-nonempty.git" }, "dependencies": { - "purescript-foldable-traversable": "^1.0.0" + "purescript-foldable-traversable": "^1.0.0", + "purescript-generics": "^1.0.0" }, "devDependencies": { "purescript-console": "^1.0.0", diff --git a/src/Data/NonEmpty.purs b/src/Data/NonEmpty.purs index 36bfcc9..edde167 100644 --- a/src/Data/NonEmpty.purs +++ b/src/Data/NonEmpty.purs @@ -21,6 +21,7 @@ import Control.Alternative (class Alternative) import Control.Plus (class Plus, empty) import Data.Foldable (class Foldable, foldl, foldr, foldMap) +import Data.Generic (class Generic) import Data.Traversable (class Traversable, traverse, sequence) -- | 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 EQ -> compare fa1 fa2 other -> other +derive instance genericNonEmpty :: (Generic (f a), Generic a) => Generic (NonEmpty f a) + instance functorNonEmpty :: Functor f => Functor (NonEmpty f) where map f (a :| fa) = f a :| map f fa