Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Dec 27, 2023
1 parent 63ac1a2 commit 4b2eba9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# 0.3.4.0

* Breaking change: remove deprecated `zipSubvectors`, use `zipWithSubvectors`.
* Add `foldr` catamorphism and `fromInfinite` / `toInfinite` conversions.
* Add `iterateWithIndex` and `iterateWithIndexM`.

Expand Down
4 changes: 2 additions & 2 deletions src/Data/Chimera/ContinuousMapping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ contramapToZCurve
contramapToZCurve f = (f .) . toZCurve

-- | For an input function @f@ return function @g@ such that
-- 'fix' @f@ = throughZCurve ('fix' @g@).
-- 'Data.Function.fix' @f@ = ('Data.Function.fix' @g@ '.') '.' 'toZCurve'.
--
-- @since 0.4.0.0
throughZCurveFix
Expand Down Expand Up @@ -285,7 +285,7 @@ contramapToZCurve3
contramapToZCurve3 f = ((f .) .) . toZCurve3

-- | For an input function @f@ return function @g@ such that
-- 'fix' @f@ = throughZCurve ('fix' @g@).
-- 'Data.Function.fix' @f@ = (('Data.Function.fix' @g@ '.') '.') '.' 'toZCurve3'.
--
-- @since 0.4.0.0
throughZCurveFix3
Expand Down
8 changes: 3 additions & 5 deletions src/Data/Chimera/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ module Data.Chimera.Internal (
toInfinite,

-- * Monadic construction
-- $monadic
tabulateM,
tabulateFixM,
tabulateFixM',
Expand All @@ -53,7 +52,6 @@ module Data.Chimera.Internal (
unfoldrM,

-- * Subvectors
-- $subvectors
mapSubvectors,
traverseSubvectors,
zipWithSubvectors,
Expand Down Expand Up @@ -202,15 +200,15 @@ tabulateM f = Chimera <$> generateArrayM (bits + 1) tabulateSubVector
{-# INLINEABLE tabulateM #-}
{-# SPECIALIZE tabulateM :: G.Vector v a => (Word -> Identity a) -> Identity (Chimera v a) #-}

-- | For a given @f@ create a stream of values of a recursive function 'fix' @f@.
-- | For a given @f@ create a stream of values of a recursive function 'Data.Function.fix' @f@.
-- Once created it can be accessed via 'index' or 'toList'.
--
-- For example, imagine that we want to tabulate
-- <https://en.wikipedia.org/wiki/Catalan_number Catalan numbers>:
--
-- >>> catalan n = if n == 0 then 1 else sum [ catalan i * catalan (n - 1 - i) | i <- [0 .. n - 1] ]
--
-- Can we find @catalanF@ such that @catalan@ = 'fix' @catalanF@?
-- Can we find @catalanF@ such that @catalan@ = 'Data.Function.fix' @catalanF@?
-- Just replace all recursive calls to @catalan@ with @f@:
--
-- >>> catalanF f n = if n == 0 then 1 else sum [ f i * f (n - 1 - i) | i <- [0 .. n - 1] ]
Expand Down Expand Up @@ -252,7 +250,7 @@ tabulateFix uf = runIdentity $ tabulateFixM (coerce uf)
-- >>> maximumBy (comparing $ index $ tabulateFix' collatzF) [0..1000000]
-- ...
--
-- Using 'memoizeFix' instead fixes the problem:
-- Using 'Data.Chimera.memoizeFix' instead fixes the problem:
--
-- >>> maximumBy (comparing $ memoizeFix collatzF) [0..1000000]
-- 56991483520
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Chimera/Memoize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import Data.Chimera.Internal
memoize :: (Word -> a) -> (Word -> a)
memoize = index @V.Vector . tabulate

-- | For a given @f@ memoize a recursive function 'fix' @f@,
-- | For a given @f@ memoize a recursive function 'Data.Function.fix' @f@,
-- caching results in 'VChimera'.
-- This is just a shortcut for 'index' '.' 'tabulateFix'.
--
Expand All @@ -55,7 +55,7 @@ memoize = index @V.Vector . tabulate
--
-- >>> fibo n = if n < 2 then toInteger n else fibo (n - 1) + fibo (n - 2)
--
-- Can we find @fiboF@ such that @fibo@ = 'fix' @fiboF@?
-- Can we find @fiboF@ such that @fibo@ = 'Data.Function.fix' @fiboF@?
-- Just replace all recursive calls to @fibo@ with @f@:
--
-- >>> fiboF f n = if n < 2 then toInteger n else f (n - 1) + f (n - 2)
Expand Down

0 comments on commit 4b2eba9

Please sign in to comment.