From 04de80b602e6930579a76c48fa8ad2fb5e21498d Mon Sep 17 00:00:00 2001 From: Matthew Leon Date: Sun, 5 Feb 2017 15:04:11 +0000 Subject: [PATCH] style: even more usage of ~> --- src/Data/List.purs | 8 ++++---- src/Data/List/Lazy.purs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Data/List.purs b/src/Data/List.purs index 14b9b3c..d50c9cb 100644 --- a/src/Data/List.purs +++ b/src/Data/List.purs @@ -220,14 +220,14 @@ insertBy cmp x ys@(y : ys') = -- | Get the first element in a list, or `Nothing` if the list is empty. -- | -- | Running time: `O(1)`. -head :: forall a. List a -> Maybe a +head :: List ~> Maybe head Nil = Nothing head (x : _) = Just x -- | Get the last element in a list, or `Nothing` if the list is empty. -- | -- | Running time: `O(n)`. -last :: forall a. List a -> Maybe a +last :: List ~> Maybe last (x : Nil) = Just x last (_ : xs) = last xs last _ = Nothing @@ -355,7 +355,7 @@ alterAt _ _ _ = Nothing -- | Reverse a list. -- | -- | Running time: `O(n)` -reverse :: forall a. List a -> List a +reverse :: List ~> List reverse = go Nil where go acc Nil = acc @@ -476,7 +476,7 @@ sortBy cmp = mergeAll <<< sequences -------------------------------------------------------------------------------- -- | Extract a sublist by a start and end index. -slice :: forall a. Int -> Int -> List a -> List a +slice :: Int -> Int -> List ~> List slice start end xs = take (end - start) (drop start xs) -- | Take the specified number of elements from the front of a list. diff --git a/src/Data/List/Lazy.purs b/src/Data/List/Lazy.purs index d8ab3a4..44c5e9c 100644 --- a/src/Data/List/Lazy.purs +++ b/src/Data/List/Lazy.purs @@ -224,13 +224,13 @@ insertBy cmp x xs = List (go <$> unwrap xs) -- | Get the first element in a list, or `Nothing` if the list is empty. -- | -- | Running time: `O(1)`. -head :: forall a. List a -> Maybe a +head :: List ~> Maybe head xs = _.head <$> uncons xs -- | Get the last element in a list, or `Nothing` if the list is empty. -- | -- | Running time: `O(n)`. -last :: forall a. List a -> Maybe a +last :: List ~> Maybe last = go <<< step where go (Cons x xs) @@ -382,7 +382,7 @@ alterAt n f xs = List (go n <$> unwrap xs) -- | Reverse a list. -- | -- | Running time: `O(n)` -reverse :: forall a. List a -> List a +reverse :: List ~> List reverse xs = Z.defer \_ -> foldl (flip cons) nil xs -- | Flatten a list of lists. @@ -454,7 +454,7 @@ catMaybes = mapMaybe id -------------------------------------------------------------------------------- -- | Extract a sublist by a start and end index. -slice :: forall a. Int -> Int -> List a -> List a +slice :: Int -> Int -> List ~> List slice start end xs = take (end - start) (drop start xs) -- | Take the specified number of elements from the front of a list.