Skip to content

Commit

Permalink
Upped version, example mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
BebeSparkelSparkel committed Feb 27, 2024
1 parent ac63d4e commit 8596802
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mono-traversable/mono-traversable.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: mono-traversable
version: 1.0.16.0
version: 1.0.17.0
synopsis: Type classes for mapping, folding, and traversing monomorphic containers
description: Please see the README at <https://www.stackage.org/package/mono-traversable>
category: Data
Expand Down
2 changes: 1 addition & 1 deletion mono-traversable/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: mono-traversable
version: 1.0.16.0
version: 1.0.17.0
synopsis: Type classes for mapping, folding, and traversing monomorphic containers
description: Please see the README at <https://www.stackage.org/package/mono-traversable>
category: Data
Expand Down
26 changes: 21 additions & 5 deletions mono-traversable/src/Data/Sequences.hs
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,27 @@ class (Monoid seq, MonoTraversable seq, SemiSequence seq, MonoPointed seq) => Is

-- | Returns all the final segments of 'seq' with the longest first.
--
-- @since ????
-- @
-- > tails [1,2]
-- [[1,2],[2],[]]
-- > tails []
-- [[]]
-- @
--
-- @since 1.0.17.0
tails :: seq -> [seq]
tails x = x : maybe mempty tails (tailMay x)

-- | Return all the initial segments of 'seq' with the shortest first.
--
-- @since ????
-- @
-- > inits [1,2]
-- [[],[1],[1,2]]
-- > inits []
-- [[]]
-- @
--
-- @since 1.0.17.0
inits :: seq -> [seq]
inits seq = is seq [seq]
where
Expand All @@ -489,11 +503,13 @@ class (Monoid seq, MonoTraversable seq, SemiSequence seq, MonoPointed seq) => Is
-- | Return all the pairs of inital and final segments of 'seq'.
--
-- @
-- > 'initTails' [1,2]
-- [([],[1,2]), ([1],[2]), ([1,2],[])]
-- > initTails [1,2]
-- [([],[1,2]),([1],[2]),([1,2],[])]
-- > initTails []
-- [([],[])]
-- @
--
-- @since ????
-- @since 1.0.17.0
initTails :: seq -> [(seq,seq)]
initTails seq = List.zip (inits seq) (tails seq)

Expand Down

0 comments on commit 8596802

Please sign in to comment.