@@ -22,7 +22,7 @@ module Data.List
2222 , null
2323 , length
2424
25- , (:)
25+ , (:), cons
2626 , snoc
2727 , insert
2828 , insertBy
@@ -71,7 +71,7 @@ module Data.List
7171 , unionBy
7272 , delete
7373 , deleteBy
74- , (\\)
74+ , (\\), difference
7575 , intersect
7676 , intersectBy
7777
@@ -88,20 +88,20 @@ module Data.List
8888 , fromList
8989 ) where
9090
91- import Prelude
91+ import Prelude ( class Monad , class Bind , class Applicative , class Apply , class Functor , class Semigroup , class Ord , class Eq , class Show , Ordering (EQ, GT, LT), append , flip , (<*>), (<$>), (<>), pure , (<<<), ($), compare , (==), (&&), show , (++), (>>=), return , not , eq , (-), otherwise , (/=), id , bind , (+), one , (<), (<=), negate , (>))
9292
93- import Control.Alt (Alt , (<|>))
94- import Control.Alternative (Alternative )
95- import Control.Lazy (Lazy , defer )
96- import Control.MonadPlus (MonadPlus )
97- import Control.Plus (Plus )
93+ import Control.Alt (class Alt , (<|>))
94+ import Control.Alternative (class Alternative )
95+ import Control.Lazy (class Lazy , defer )
96+ import Control.MonadPlus (class MonadPlus )
97+ import Control.Plus (class Plus )
9898
99- import Data.Foldable (Foldable , foldl , foldr , any )
99+ import Data.Foldable (class Foldable , foldl , foldr , any )
100100import Data.Maybe (Maybe (..))
101- import Data.Monoid (Monoid , mempty )
102- import Data.Traversable (Traversable , traverse , sequence )
101+ import Data.Monoid (class Monoid , mempty )
102+ import Data.Traversable (class Traversable , traverse , sequence )
103103import Data.Tuple (Tuple (..))
104- import Data.Unfoldable (Unfoldable , unfoldr )
104+ import Data.Unfoldable (class Unfoldable , unfoldr )
105105
106106-- | A strict linked list.
107107-- |
@@ -132,11 +132,8 @@ fromFoldable = foldr Cons Nil
132132singleton :: forall a . a -> List a
133133singleton a = Cons a Nil
134134
135- infix 8 ..
136-
137135-- | An infix synonym for `range`.
138- (..) :: Int -> Int -> List Int
139- (..) = range
136+ infix 8 range as ..
140137
141138-- | Create a list containing a range of integers, including both endpoints.
142139range :: Int -> Int -> List Int
@@ -196,14 +193,13 @@ length = foldl (\acc _ -> acc + 1) 0
196193-- Extending arrays ------------------------------------------------------------
197194-- ------------------------------------------------------------------------------
198195
199- infixr 6 :
200-
201196-- | An infix alias for `Cons`; attaches an element to the front of
202197-- | a list.
203198-- |
204199-- | Running time: `O(1)`
205- (:) :: forall a . a -> List a -> List a
206- (:) = Cons
200+ cons :: forall a . a -> List a -> List a
201+ cons = Cons
202+ infixr 6 cons as :
207203
208204-- | Append an element to the end of an array, creating a new array.
209205-- |
@@ -285,11 +281,8 @@ index Nil _ = Nothing
285281index (Cons a _) 0 = Just a
286282index (Cons _ as) i = index as (i - 1 )
287283
288- infixl 8 !!
289-
290284-- | An infix synonym for `index`.
291- (!!) :: forall a . List a -> Int -> Maybe a
292- (!!) = index
285+ infixl 8 index as !!
293286
294287-- | Find the index of the first element equal to the specified element.
295288elemIndex :: forall a . (Eq a ) => a -> List a -> Maybe Int
@@ -614,13 +607,13 @@ deleteBy _ _ Nil = Nil
614607deleteBy (==) x (Cons y ys) | x == y = ys
615608deleteBy (==) x (Cons y ys) = Cons y (deleteBy (==) x ys)
616609
617- infix 5 \\
610+ infix 5 difference as \\
618611
619612-- | Delete the first occurrence of each element in the second list from the first list.
620613-- |
621614-- | Running time: `O(n^2)`
622- (\\) :: forall a . (Eq a ) => List a -> List a -> List a
623- (\\) = foldl (flip delete)
615+ difference :: forall a . (Eq a ) => List a -> List a -> List a
616+ difference = foldl (flip delete)
624617
625618-- | Calculate the intersection of two lists.
626619-- |
0 commit comments