ref: d4dea2defccb349c3a6833bcd10ebf16c6cea49d
parent: 388f6e4274710b3a8631c3bf87b811e58f9e711d
author: Lennart Augustsson <lennart@augustsson.net>
date: Sun Sep 22 06:40:23 EDT 2024
Add missing Down type.
--- a/lib/Data/Ord.hs
+++ b/lib/Data/Ord.hs
@@ -6,6 +6,7 @@
import Primitives
import Data.Bool_Type
import Data.Bounded
+import Data.Functor
import Data.Ordering_Type
import Data.Eq
import Text.Show
@@ -70,38 +71,36 @@
, RealFloat -- ^ @since 4.14.0.0
, Storable -- ^ @since 4.14.0.0
)
+-}
--- | This instance would be equivalent to the derived instances of the
--- 'Down' newtype if the 'getDown' field were removed
--- @since 4.7.0.0
-instance (Read a) => Read (Down a) where
- readsPrec d = readParen (d > 10) $ \ r ->
- [(Down x,t) | ("Down",s) <- lex r, (x,t) <- readsPrec 11 s]
+newtype Down a = Down a
--- | This instance would be equivalent to the derived instances of the
--- 'Down' newtype if the 'getDown' field were removed
--- @since 4.7.0.0
+getDown :: Down a -> a
+getDown (Down a) = a
+
+{-
+instance (Read a) => Read (Down a) where
+ readsPrec d = readParen (d > 10) $ \ r ->
+ [(Down x,t) | ("Down",s) <- lex r, (x,t) <- readsPrec 11 s]
+-}
+{- In Data.Orphans
instance (Show a) => Show (Down a) where
- showsPrec d (Down x) = showParen (d > 10) $
- showString "Down " . showsPrec 11 x
+-}
--- | @since 4.6.0.0
+instance Eq a => Eq (Down a) where
+ Down x == Down y = x == y
+
instance Ord a => Ord (Down a) where
- compare (Down x) (Down y) = y `compare` x
+ compare (Down x) (Down y) = y `compare` x
--- | Swaps @'minBound'@ and @'maxBound'@ of the underlying type.
--- @since 4.14.0.0
instance Bounded a => Bounded (Down a) where
minBound = Down maxBound
maxBound = Down minBound
--- | @since 4.11.0.0
instance Functor Down where
- fmap = coerce
+ fmap f (Down a) = Down (f a)
+{-
-- | @since 4.11.0.0
instance Applicative Down where
pure = Down
--- /dev/null
+++ b/lib/Data/Orphans.hs
@@ -1,0 +1,8 @@
+-- Instance declarations that can't be put where
+-- due to import cycles.
+module Data.Orphans where
+import Prelude(); import MiniPrelude
+
+instance (Show a) => Show (Down a) where
+ showsPrec d (Down x) = showParen (d > 10) $
+ showString "Down " . showsPrec 11 x
--- a/lib/Prelude.hs
+++ b/lib/Prelude.hs
@@ -87,6 +87,8 @@
import Text.Show(Show(..), ShowS, shows, showChar, showString, showParen)
import Primitives(_wordSize, _isWindows)
+import Data.Orphans() -- Extra instances
+
-- So we can detect mhs vs ghc
usingMhs :: Bool
usingMhs = True
--
⑨