Skip to content

Commit

Permalink
[#19] Add @since annotations to all functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pgujjula committed May 23, 2024
1 parent 00f0965 commit 49993bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Data/List/ApplyMerge.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
--
-- Lift a binary, non-decreasing function onto ordered lists and order the
-- output.
--
-- @since 0.1.0.0
module Data.List.ApplyMerge
( -- * Functions
applyMerge,
Expand Down Expand Up @@ -48,10 +50,14 @@ import Data.Text qualified as Text
--
-- For more examples, see
-- [README#examples](https://github.com/pgujjula/apply-merge/#examples).
--
-- @since 0.1.0.0
applyMerge :: (Ord c) => (a -> b -> c) -> [a] -> [b] -> [c]
applyMerge = ApplyMerge.IntSet.applyMerge

-- | Like 'applyMerge', but uses a custom comparison function.
--
-- @since 0.1.1.0
applyMergeBy :: (c -> c -> Ordering) -> (a -> b -> c) -> [a] -> [b] -> [c]
applyMergeBy = applyMergeBy_

Expand Down Expand Up @@ -90,6 +96,8 @@ instance (Reifies s (a -> a -> Ordering)) => Ord (ReflectedOrd s a) where
-- >
-- > gaussianIntegers :: [GaussianInteger] -- `GaussianInteger` from arithmoi
-- > gaussianIntegers = applyMergeOn norm (:+) zs zs
--
-- @since 0.1.1.0
applyMergeOn ::
(Ord d) => (c -> d) -> (a -> b -> c) -> [a] -> [b] -> [c]
applyMergeOn p f as bs =
Expand All @@ -116,6 +124,8 @@ type ApplyMerge = forall a b c. (Ord c) => (a -> b -> c) -> [a] -> [b] -> [c]
-- . . . * * * * * * *
-- . . * * * * * * * *
-- . * * * * * * * * *
--
-- @since 0.1.2.0
drawMergePattern :: (Ord c) => (a -> b -> c) -> [a] -> [b] -> Int -> Int -> Text
drawMergePattern = drawMergePatternWith applyMerge

Expand Down
8 changes: 8 additions & 0 deletions src/Data/List/NonEmpty/ApplyMerge.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
-- Stability: experimental
--
-- Like "Data.List.ApplyMerge", but for 'NonEmpty' instead of lists.
--
-- @since 0.1.1.0
module Data.List.NonEmpty.ApplyMerge
( applyMerge,
applyMergeBy,
Expand All @@ -25,10 +27,14 @@ import Data.Semigroup (Arg (..))

-- | Like 'Data.List.ApplyMerge.applyMerge', but operates on 'NonEmpty's instead
-- of lists.
--
-- @since 0.1.1.0
applyMerge :: (Ord c) => (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c
applyMerge = ApplyMerge.IntSet.applyMergeNonEmpty

-- | Like 'applyMerge', but uses a custom comparison function.
--
-- @since 0.1.1.0
applyMergeBy ::
(c -> c -> Ordering) ->
(a -> b -> c) ->
Expand Down Expand Up @@ -69,6 +75,8 @@ instance (Reifies s (a -> a -> Ordering)) => Ord (ReflectedOrd s a) where

-- | Like 'applyMerge', but applies a custom projection function before
-- performing comparisons.
--
-- @since 0.1.1.0
applyMergeOn ::
(Ord d) => (c -> d) -> (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c
applyMergeOn p f as bs =
Expand Down

0 comments on commit 49993bc

Please sign in to comment.