shithub: MicroHs

Download patch

ref: 817c8c561beab73347c1f9783123a719ec1dadcd
parent: 60e96185f08ab8f36698c16c41633bc3a4295b77
author: Lennart Augustsson <lennart@augustsson.net>
date: Wed Sep 11 18:10:52 EDT 2024

Split NonEmpty

--- a/lib/Data/List/NonEmpty.hs
+++ b/lib/Data/List/NonEmpty.hs
@@ -125,11 +125,20 @@
 import Data.Function(on)
 import qualified Data.List as List
 import GHC.Stack(HasCallStack)
+import Data.List.NonEmpty_Type
 
+{- In Data.List.NonEmpty_Type
 infixr 5 :|
 
 data NonEmpty a = a :| [a]
   deriving (Eq, Ord)
+-}
+
+instance (Eq a) => Eq (NonEmpty a) where
+  (x :| xs) == (y :| ys)  =  x == y && xs == ys
+
+instance (Ord a) => Ord (NonEmpty a) where
+  compare (x :| xs) (y :| ys) = compare x y <> compare xs ys
 
 instance Semigroup (NonEmpty a) where
   (a :| as) <> ~(b :| bs) = a :| (as ++ b : bs)
--- /dev/null
+++ b/lib/Data/List/NonEmpty_Type.hs
@@ -1,0 +1,6 @@
+module Data.List.NonEmpty_Type(module Data.List.NonEmpty_Type) where
+import Prelude()
+
+infixr 5 :|
+
+data NonEmpty a = a :| [a]
--