ref: 2cf8fa5c8198ac891bc832ad7c278725cbf16d78
parent: 434694cbdc08d382afff2dd71bfbe4f52f6a7a31
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Mon Sep 18 19:34:27 EDT 2023
Nicer
--- a/lib/Data/List.hs
+++ b/lib/Data/List.hs
@@ -11,14 +11,11 @@
--Yimport Data.Char
---X{- --Y{-infixr 5 :
+data [] a = [] | (:) a [a] -- Parser hacks makes this acceptable
--Y-}
---X-}
-data [] a = [] | (:) a [a] -- Parser hacks makes this acceptable --Z
-
null :: forall a . [a] -> Bool
null [] = True
null _ = False
@@ -113,6 +110,7 @@
zipWith f (x:xs) (y:ys) = f x y : zipWith f xs ys
zipWith _ _ _ = []
+-- XXX not as lazy as it could be
unzip :: forall a b . [(a, b)] -> ([a], [b])
unzip axys =
case axys of
@@ -121,6 +119,7 @@
case unzip xys of
(xs, ys) -> (x:xs, y:ys)
+-- XXX not as lazy as it could be
unzip3 :: forall a b c . [(a, b, c)] -> ([a], [b], [c])
unzip3 axyzs =
case axyzs of
@@ -185,11 +184,10 @@
intersperse :: forall a . a -> [a] -> [a]
intersperse _ [] = []
-intersperse sep (x:xs) = x : prependToAll sep xs
-
-prependToAll :: forall a . a -> [a] -> [a]
-prependToAll _ [] = []
-prependToAll sep (x:xs) = sep : x : prependToAll sep xs
+intersperse sep (a:as) = a : prepend as
+ where
+ prepend [] = []
+ prepend (x:xs) = sep : x : prepend xs
intercalate :: forall a . [a] -> [[a]] -> [a]
intercalate xs xss = concat (intersperse xs xss)
--
⑨