From 10aa2245414fea92cf8918842ebef60ba5d4a5e1 Mon Sep 17 00:00:00 2001 From: "Cary M. Robbins" Date: Mon, 17 Aug 2015 11:33:51 -0500 Subject: [PATCH] Add generic deriving. --- bower.json | 1 + src/Data/List.purs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/bower.json b/bower.json index 7142a40..c0aa34c 100644 --- a/bower.json +++ b/bower.json @@ -24,6 +24,7 @@ ], "dependencies": { "purescript-foldable-traversable": "^0.4.0", + "purescript-generics": "^0.4.0", "purescript-lazy": "^0.4.0", "purescript-unfoldable": "^0.4.0" }, diff --git a/src/Data/List.purs b/src/Data/List.purs index 4be0f4f..708b438 100644 --- a/src/Data/List.purs +++ b/src/Data/List.purs @@ -85,6 +85,7 @@ module Data.List import Prelude +import Data.Generic import Data.Maybe import Data.Tuple (Tuple(..)) import Data.Monoid @@ -680,6 +681,8 @@ foldM f a (Cons b bs) = f a b >>= \a' -> foldM f a' bs -- Instances ------------------------------------------------------------------- -------------------------------------------------------------------------------- +derive instance genericList :: (Generic a) => Generic (List a) + instance showList :: (Show a) => Show (List a) where show Nil = "Nil" show (Cons x xs) = "Cons (" ++ show x ++ ") (" ++ show xs ++ ")"