shithub: MicroHs

Download patch

ref: 6df47fd333e14e0eea63e5892f987597b0ef1584
parent: 40e35fd3527efb901c250b347a1a822b3ea98e45
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Thu Aug 24 08:43:06 EDT 2023

Neater definitions.

--- a/lib/Control/Monad/State/Strict.hs
+++ b/lib/Control/Monad/State/Strict.hs
@@ -5,9 +5,7 @@
 data State s a = S (s -> (a, s))
 
 runState :: forall s a . State s a -> (s -> (a,s))
-runState sa =
-  case sa of
-    S x -> x
+runState (S x) = x
 
 evalState :: forall s a . State s a -> (s -> a)
 evalState sa = fst . runState sa
--- a/lib/Data/Bool.hs
+++ b/lib/Data/Bool.hs
@@ -8,20 +8,14 @@
 
 --Yinfixr 2 ||
 (||) :: Bool -> Bool -> Bool
-(||) x y =
-  case x of
-    False -> y
-    True  -> True
+(||) False y = y
+(||) True  _ = True
 
 --Yinfixr 3 &&
 (&&) :: Bool -> Bool -> Bool
-(&&) x y =
-  case x of
-    False -> False
-    True  -> y
+(&&) False _ = False
+(&&) True  y = y
 
 not :: Bool -> Bool
-not b =
-  case b of
-    False -> True
-    True  -> False
+not False = True
+not True  = False
--- a/lib/Data/IntMap.hs
+++ b/lib/Data/IntMap.hs
@@ -63,9 +63,7 @@
 toList :: forall a . IntMap a -> [(Int, a)]
 toList am =
   let
-    f o ka =
-      case ka of
-        (k, a) -> (k*4 + o, a)
+    f o (k, a) = (k*4 + o, a)
   in
     case am of
       Empty -> []
--- a/lib/Data/List.hs
+++ b/lib/Data/List.hs
@@ -184,10 +184,8 @@
 head (x:_) = x
 
 tail :: forall a . [a] -> [a]
-tail xs =
-  case xs of
-    [] -> error "tail"
-    _:ys -> ys
+tail [] = error "tail"
+tail (_:ys) = ys
 
 intersperse :: forall a . a -> [a] -> [a]
 intersperse sep axs =
--