Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Perf.Algos
Description
Algorithms and functions for testing purposes
Synopsis
- data Example
- parseExample :: Parser Example
- data ExamplePattern a
- = PatternSumFuse Text (Num a => a -> a) a
- | PatternSum Text (Num a => [a] -> a) [a]
- | PatternLengthF Text ([a] -> Int) [a]
- | PatternConstFuse Text (Int -> ()) Int
- | PatternMapInc Text ([Int] -> [Int]) [Int]
- | PatternNoOp Text (() -> ()) ()
- | PatternNub Text ([Int] -> [Int]) [Int]
- | PatternFib Text (Int -> Integer) Int
- examplePattern :: Example -> Int -> ExamplePattern Int
- exampleLabel :: ExamplePattern a -> Text
- testExample :: (Semigroup a, MonadIO m) => ExamplePattern Int -> PerfT m a ()
- tastyExample :: ExamplePattern Int -> Benchmarkable
- data SumPattern a
- allSums :: Int -> [SumPattern Int]
- testSum :: (Semigroup a, MonadIO m) => SumPattern Int -> PerfT m a Int
- statSums :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [a])
- sumTail :: Num a => [a] -> a
- sumTailLazy :: Num a => [a] -> a
- sumFlip :: Num a => [a] -> a
- sumFlipLazy :: Num a => [a] -> a
- sumCo :: Num a => [a] -> a
- sumCoGo :: Num a => [a] -> a
- sumCoCase :: Num a => [a] -> a
- sumAux :: Num a => [a] -> a
- sumFoldr :: Num a => [a] -> a
- sumCata :: Num a => [a] -> a
- sumSum :: Num a => [a] -> a
- sumMono :: [Int] -> Int
- sumPoly :: Num a => [a] -> a
- sumLambda :: Num a => [a] -> a
- sumF :: Num a => [a] -> a
- sumFuse :: Int -> Int
- sumFusePoly :: (Enum a, Num a) => a -> a
- sumFuseFoldl' :: Int -> Int
- sumFuseFoldr :: Int -> Int
- data LengthPattern a
- = LengthPoly Text ([a] -> Int) [a]
- | LengthMono Text ([Int] -> Int) [Int]
- allLengths :: Int -> [LengthPattern Int]
- testLength :: (Semigroup a, MonadIO m) => LengthPattern Int -> PerfT m a Int
- statLengths :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [a])
- lengthTail :: [a] -> Int
- lengthTailLazy :: [a] -> Int
- lengthFlip :: [a] -> Int
- lengthFlipLazy :: [a] -> Int
- lengthCo :: [a] -> Int
- lengthCoCase :: [a] -> Int
- lengthAux :: [a] -> Int
- lengthFoldr :: [a] -> Int
- lengthFoldrConst :: [a] -> Int
- lengthF :: [a] -> Int
- lengthFMono :: [Int] -> Int
- recurseTail :: (a -> b -> b) -> b -> [a] -> b
- recurseTailLazy :: (a -> b -> b) -> b -> [a] -> b
- recurseFlip :: (a -> b -> b) -> b -> [a] -> b
- recurseFlipLazy :: (a -> b -> b) -> b -> [a] -> b
- recurseCo :: (a -> b -> b) -> b -> [a] -> b
- recurseCoLazy :: (a -> b -> b) -> b -> [a] -> b
- recurseCata :: (a -> b -> b) -> b -> [a] -> b
- mapInc :: [Int] -> [Int]
- constFuse :: Int -> ()
- splitHalf :: [a] -> ([a], [a])
command-line options
Algorithm examples for testing
parseExample :: Parser Example Source #
Parse command-line options for algorithm examples.
data ExamplePattern a Source #
Unification of example function applications
Constructors
PatternSumFuse Text (Num a => a -> a) a | |
PatternSum Text (Num a => [a] -> a) [a] | |
PatternLengthF Text ([a] -> Int) [a] | |
PatternConstFuse Text (Int -> ()) Int | |
PatternMapInc Text ([Int] -> [Int]) [Int] | |
PatternNoOp Text (() -> ()) () | |
PatternNub Text ([Int] -> [Int]) [Int] | |
PatternFib Text (Int -> Integer) Int |
examplePattern :: Example -> Int -> ExamplePattern Int Source #
Convert an Example
to an ExamplePattern
.
exampleLabel :: ExamplePattern a -> Text Source #
Labels
testExample :: (Semigroup a, MonadIO m) => ExamplePattern Int -> PerfT m a () Source #
Convert an ExamplePattern
to a PerfT
.
tastyExample :: ExamplePattern Int -> Benchmarkable Source #
Convert an ExamplePattern
to a tasty-bench run.
sum algorithms
data SumPattern a Source #
Unification of sum function applications
testSum :: (Semigroup a, MonadIO m) => SumPattern Int -> PerfT m a Int Source #
Convert an SumPattern
to a PerfT
.
statSums :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [a]) Source #
Run a sum algorithm measurement.
sumTailLazy :: Num a => [a] -> a Source #
lazy recursion.
sumFlipLazy :: Num a => [a] -> a Source #
Lazy with argument order flipped.
sumFusePoly :: (Enum a, Num a) => a -> a Source #
Fusion under polymorph
sumFuseFoldl' :: Int -> Int Source #
foldl' fusion
sumFuseFoldr :: Int -> Int Source #
foldr fusion
length algorithms
data LengthPattern a Source #
Unification of length function applications
Constructors
LengthPoly Text ([a] -> Int) [a] | |
LengthMono Text ([Int] -> Int) [Int] |
allLengths :: Int -> [LengthPattern Int] Source #
All the length algorithms.
testLength :: (Semigroup a, MonadIO m) => LengthPattern Int -> PerfT m a Int Source #
Convert an LengthPattern
to a PerfT
.
statLengths :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [a]) Source #
Run a lengths algorithm
length
lengthTail :: [a] -> Int Source #
tail resursive
lengthTailLazy :: [a] -> Int Source #
lazy recursion.
lengthFlip :: [a] -> Int Source #
With argument order flipped
lengthFlipLazy :: [a] -> Int Source #
Lazy with argument order flipped.
lengthCoCase :: [a] -> Int Source #
Co-routine style as a Case statement.
lengthFoldr :: [a] -> Int Source #
foldr style
lengthFoldrConst :: [a] -> Int Source #
foldr style with explicit const usage.
lengthFMono :: [Int] -> Int Source #
Monomorphic, GHC style
recursion patterns
recurseTail :: (a -> b -> b) -> b -> [a] -> b Source #
Tail recursion
recurseTailLazy :: (a -> b -> b) -> b -> [a] -> b Source #
Lazy tail recursion
recurseFlip :: (a -> b -> b) -> b -> [a] -> b Source #
Tail resursion with flipped argument order.
recurseFlipLazy :: (a -> b -> b) -> b -> [a] -> b Source #
Lazy tail resursion with flipped argument order.
recurseCoLazy :: (a -> b -> b) -> b -> [a] -> b Source #
Lazy, coroutine
recurseCata :: (a -> b -> b) -> b -> [a] -> b Source #
Cata style