Skip to content

style: even more usage of ~> #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Data/List.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/Data/List/Lazy.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down