ref: d94f038f5aa4b763b550395914bad4a0562e5034
parent: e8c7af116f1efbbc00568ab0d8ca0ad9e9b5c085
	author: Lennart Augustsson <lennart@augustsson.net>
	date: Wed Dec 27 14:05:00 EST 2023
	
Add Solo
--- a/lib/Data/Tuple.hs
+++ b/lib/Data/Tuple.hs
@@ -9,7 +9,9 @@
import Data.Bounded
import Data.Eq
import Data.Function
+import Data.Int
import Data.Monoid
+import Data.Ord
import Data.Semigroup
import Text.Show
@@ -17,6 +19,9 @@
--data (a,b,c) = (a,b,c)
-- etc
+data Solo a = Solo a
+ deriving (Eq)
+
fst :: forall a b . (a, b) -> a
fst (a, _) = a
@@ -42,6 +47,9 @@
instance Show () where
showsPrec _ () = showString "()"
+instance forall a . Show a => Show (Solo a) where
+ showsPrec p (Solo a) = showParen (p > 10) (showString "Solo " . showsPrec 11 a)
+
instance forall a b . (Show a, Show b) => Show (a, b) where
showsPrec _ (a, b) = showParen True (showsPrec 0 a . showString "," . showsPrec 0 b)
@@ -58,6 +66,10 @@
minBound = ()
maxBound = ()
+instance forall a . (Bounded a) => Bounded (Solo a) where
+ minBound = Solo minBound
+ maxBound = Solo maxBound
+
instance forall a b . (Bounded a, Bounded b) => Bounded (a, b) where
minBound = (minBound, minBound)
maxBound = (maxBound, maxBound)
@@ -75,6 +87,9 @@
instance Semigroup () where
_ <> _ = ()
+instance forall a . Semigroup a => Semigroup (Solo a) where
+ Solo a <> Solo b = Solo (a <> b)
+
instance forall a b . (Semigroup a, Semigroup b) => Semigroup (a, b) where
(a, b) <> (a', b') = (a <> a', b <> b')
@@ -88,6 +103,9 @@
instance Monoid () where
mempty = ()
+
+instance forall a . Monoid a => Monoid (Solo a) where
+ mempty = Solo mempty
instance forall a b . (Monoid a, Monoid b) => Monoid (a, b) where
mempty = (mempty, mempty)
--
⑨