shithub: MicroHs

Download patch

ref: 68db361d357d02a1616037a92b7be59cea625944
parent: 5b6168bbba78656837ecb73c48ba207cd514d7ea
author: konsumlamm <konsumlamm@gmail.com>
date: Wed Jan 8 10:58:41 EST 2025

Add some missing functions/instances from the report

--- a/lib/Control/Monad.hs
+++ b/lib/Control/Monad.hs
@@ -32,6 +32,8 @@
   liftM,
   liftM2,
   liftM3,
+  liftM4,
+  liftM5,
   ap,
   ) where
 import Prelude()              -- do not import Prelude
@@ -171,6 +173,10 @@
 liftM2 f m1 m2 = do { x1 <- m1; x2 <- m2; return (f x1 x2) }
 liftM3 :: forall m r a1 a2 a3 . (Monad m) => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
 liftM3 f m1 m2 m3 = do { x1 <- m1; x2 <- m2; x3 <- m3; return (f x1 x2 x3) }
+liftM4 :: forall m r a1 a2 a3 a4 . (Monad m) => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
+liftM4 f m1 m2 m3 m4 = do { x1 <- m1; x2 <- m2; x3 <- m3; x4 <- m4; return (f x1 x2 x3 x4) }
+liftM5 :: forall m r a1 a2 a3 a4 a5 . (Monad m) => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r
+liftM5 f m1 m2 m3 m4 m5 = do { x1 <- m1; x2 <- m2; x3 <- m3; x4 <- m4; x5 <- m5; return (f x1 x2 x3 x4 x5) }
 
 ap :: forall m a b . Monad m => m (a -> b) -> m a -> m b
 ap f a = do
--- a/lib/Data/Array.hs
+++ b/lib/Data/Array.hs
@@ -43,8 +43,8 @@
 instance (Ix a, Eq b)  => Eq (Array a b) where
   (==) (Array b1 _ a1) (Array b2 _ a2) = b1 == b2 && primArrEQ a1 a2
 
-instance (Ix a, Ord b) => Ord  (Array a b) where
-  compare = undefined
+instance (Ix a, Ord b) => Ord (Array a b) where
+  compare arr1 arr2 = compare (assocs arr1) (assocs arr2)
 
 instance (Ix a, Show a, Show b) => Show (Array a b) where
   showsPrec p a =
--- a/lib/Data/Char.hs
+++ b/lib/Data/Char.hs
@@ -87,6 +87,12 @@
 isAscii :: Char -> Bool
 isAscii c = c <= '\127'
 
+isControl :: Char -> Bool
+isControl c = c <= '\31' || c == '\127'
+
+isLetter :: Char -> Bool
+isLetter = isAlpha
+
 digitToInt :: Char -> Int
 digitToInt c | (primCharLE '0' c) && (primCharLE c '9') = ord c - ord '0'
              | (primCharLE 'a' c) && (primCharLE c 'f') = ord c - (ord 'a' - 10)
--- a/lib/System/Exit.hs
+++ b/lib/System/Exit.hs
@@ -11,7 +11,7 @@
 import System.IO
 
 data ExitCode = ExitSuccess | ExitFailure Int
-  deriving (Eq, Typeable, Show)
+  deriving (Eq, Ord, Typeable, Show)
 
 instance Exception ExitCode