speculate-0.3.2: discovery of properties about Haskell functions

Copyright(c) 2016-2017 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellNone
LanguageHaskell2010

Test.Speculate.Utils

Description

This module is part of Speculate.

Exports utility functions of all utils sub-modules.

This is not intended to be used by users of Speculate, only by modules of Speculate itself. Expect symbols exported here to come and go with every minor version.

Synopsis

Documentation

iss :: Int -> Int -> [[Int]] #

thn :: Ordering -> Ordering -> Ordering infixr 8 #

reportCountsBy :: (Eq b, Show b) => (a -> b) -> [a] -> IO () #

bell :: Int -> Int #

maybe2 :: c -> (a -> b -> c) -> Maybe a -> Maybe b -> c #

iterateUntil :: (a -> a -> Bool) -> (a -> a) -> a -> a #

iterateUntilLimit :: Int -> (a -> a -> Bool) -> (a -> a) -> a -> a #

showRatio :: (Integral a, Show a) => Ratio a -> String #

percent :: Integral a => Ratio a -> a #

putLines :: [String] -> IO () #

(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d #

(..:) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e #

beside :: String -> String -> String #

Appends two Strings side by side, line by line

beside ["asdf\nqw\n","zxvc\nas"] ==
 "asdfzxvc\n\
 \qw  as\n"

above :: String -> String -> String #

Append two Strings on top of each other, adding line breaks *when needed*.

table :: String -> [[String]] -> String #

Formats a table. Examples:

table "l  l  l" [ ["asdf", "qwer",     "zxvc\nzxvc"]
                , ["0",    "1",        "2"]
                , ["123",  "456\n789", "3"] ] ==
  "asdf  qwer  zxvc\n\
  \            zxvc\n\
  \0     1     2\n\
  \123   456   3\n\
  \      789\n"
table "r  l  l" [ ["asdf", "qwer",     "zxvc\nzxvc"]
                , ["0",    "1",        "2"]
                , ["123",  "456\n789", "3"] ] ==
  "asdf  qwer  zxvc\n\
  \            zxvc\n\
  \   0  1     2\n\
  \ 123  456   3\n\
  \      789\n"
table "r  r  l" [ ["asdf", "qwer",     "zxvc\nzxvc"]
                , ["0",    "1",        "2"]
                , ["123",  "456\n789", "3"] ] ==
  "asdf  qwer  zxvc\n\
  \            zxvc\n\
  \   0     1  2\n\
  \ 123   456  3\n\
  \       789\n"

module Data.Tuple

fst3 :: (a, b, c) -> a #

fst4 :: (a, b, c, d) -> a #

snd3 :: (a, b, c) -> b #

snd4 :: (a, b, c, d) -> b #

trd3 :: (a, b, c) -> c #

trd4 :: (a, b, c, d) -> c #

fth4 :: (a, b, c, d) -> d #

curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d #

curry4 :: ((a, b, c, d) -> e) -> a -> b -> c -> d -> e #

uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d #

uncurry4 :: (a -> b -> c -> d -> e) -> (a, b, c, d) -> e #

uncurry5 :: (a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f #

uncurry6 :: (a -> b -> c -> d -> e -> f -> g) -> (a, b, c, d, e, f) -> g #

uncurry7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> (a, b, c, d, e, f, g) -> h #

uncurry8 :: (a -> b -> c -> d -> e -> f -> g -> h -> i) -> (a, b, c, d, e, f, g, h) -> i #

uncurry9 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> (a, b, c, d, e, f, g, h, i) -> j #

uncurry10 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> (a, b, c, d, e, f, g, h, i, j) -> k #

uncurry11 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) -> (a, b, c, d, e, f, g, h, i, j, k) -> l #

uncurry12 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> m #

(***) :: (a -> b) -> (c -> d) -> (a, c) -> (b, d) #

catPairs :: [(a, a)] -> [a] #

module Data.Char

isInfix :: String -> Bool #

Check if a function / operator is infix

isInfix "foo"   == False
isInfix "(+)"   == False
isInfix "`foo`" == True
isInfix "+"     == True

isInfixedPrefix :: String -> Bool #

Is the string of the form string

toPrefix :: String -> String #

Transform an infix operator into an infix function:

toPrefix "`foo`" == "foo"
toPrefix "+"     == "(+)"

prec :: String -> Int #

Returns the precedence of default Haskell operators

pairsThat :: (a -> a -> Bool) -> [a] -> [(a, a)] #

count :: Eq a => a -> [a] -> Int #

counts :: Eq a => [a] -> [(a, Int)] #

countsOn :: Eq b => (a -> b) -> [a] -> [(b, Int)] #

countsBy :: (a -> a -> Bool) -> [a] -> [(a, Int)] #

firsts :: Eq a => [a] -> [a] #

nubSort :: Ord a => [a] -> [a] #

nubSortBy :: (a -> a -> Ordering) -> [a] -> [a] #

(+++) :: Ord a => [a] -> [a] -> [a] infixr 5 #

nubMerge :: Ord a => [a] -> [a] -> [a] #

nubMergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a] #

nubMergeOn :: Ord b => (a -> b) -> [a] -> [a] -> [a] #

nubMerges :: Ord a => [[a]] -> [a] #

nubMergesBy :: Ord a => (a -> a -> Ordering) -> [[a]] -> [a] #

nubMergeMap :: Ord b => (a -> [b]) -> [a] -> [b] #

ordIntersect :: Ord a => [a] -> [a] -> [a] #

ordIntersectBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a] #

ordered :: Ord a => [a] -> Bool #

orderedBy :: (a -> a -> Bool) -> [a] -> Bool #

orderedOn :: Ord b => (a -> b) -> [a] -> Bool #

strictlyOrdered :: Ord a => [a] -> Bool #

strictlyOrderedOn :: Ord b => (a -> b) -> [a] -> Bool #

areAll :: [a] -> (a -> Bool) -> Bool #

areAny :: [a] -> (a -> Bool) -> Bool #

allLater :: (a -> a -> Bool) -> [a] -> Bool #

(+-) :: Eq a => [a] -> [a] -> [a] #

xs +- ys superimposes xs over ys.

1,2,3
+- [0,0,0,0,0,0,0] == [1,2,3,0,0,0,0]
x,y,z
+- [a,b,c,d,e,f,g] == [x,y,z,d,e,f,g] "asdf" +- "this is a test" == "asdf is a test"

sortOn :: Ord b => (a -> b) -> [a] -> [a] #

Sort a list by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (comparing f), but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform.

Elements are arranged from from lowest to highest, keeping duplicates in the order they appeared in the input.

Since: 4.8.0.0

groupOn :: Eq b => (a -> b) -> [a] -> [[a]] #

collectOn :: Ord b => (a -> b) -> [a] -> [[a]] #

collectBy :: (a -> a -> Ordering) -> [a] -> [[a]] #

collectWith :: Ord b => (a -> b) -> (a -> c) -> (b -> [c] -> d) -> [a] -> [d] #

collectSndByFst :: Ord a => [(a, b)] -> [(a, [b])] #

discard :: (a -> Bool) -> [a] -> [a] #

discardLater :: (a -> a -> Bool) -> [a] -> [a] #

discardEarlier :: (a -> a -> Bool) -> [a] -> [a] #

discardOthers :: (a -> a -> Bool) -> [a] -> [a] #

discardByOthers :: (a -> [a] -> Bool) -> [a] -> [a] #

allUnique :: Ord a => [a] -> Bool #

chain :: [a -> a] -> a -> a #

zipWithReverse :: (a -> a -> b) -> [a] -> [b] #

medianate :: (a -> a -> b) -> [a] -> [b] #

takeGreaterHalf :: [a] -> [a] #

accum :: Num a => [a] -> [a] #

partitionByMarkers :: Eq a => a -> a -> [a] -> ([a], [a]) #

(!) :: [[a]] -> Int -> [a] #

halve :: [a] -> ([a], [a]) #

productsList :: [[a]] -> [[a]] #

mapTMaybe :: (a -> Maybe b) -> [[a]] -> [[b]] #

uptoT :: Int -> [[a]] -> [a] #

filterTS :: (Int -> a -> Bool) -> [[a]] -> [[a]] #

discardTS :: (Int -> a -> Bool) -> [[a]] -> [[a]] #

typesIn :: TypeRep -> [TypeRep] #

For a given type, return all *-kinded types. (all non-function types)

typesIn (typeOf (undefined :: (Int -> Int) -> Int -> Bool))
  == [Bool,Int]

timeoutToNothing :: RealFrac s => s -> a -> Maybe a #

Returns Nothing if value cannot be evaluated to WHNF in a given number of seconds

fromTimeout :: RealFrac s => s -> a -> a -> a #

timeoutToTrue :: RealFrac s => s -> Bool -> Bool #

timeoutToError :: RealFrac s => s -> a -> a #

module Data.Ord

compareIndex :: Eq a => [a] -> a -> a -> Ordering #

memory :: (Listable a, Ord a) => (a -> b) -> Map a b #

memory2 :: (Listable a, Listable b, Ord a, Ord b) => (a -> b -> c) -> Map (a, b) c #

memoryFor :: (Listable a, Ord a) => Int -> (a -> b) -> Map a b #

memory2For :: (Listable a, Listable b, Ord a, Ord b) => Int -> (a -> b -> c) -> Map (a, b) c #

withMemory :: Ord a => (a -> b) -> Map a b -> a -> b #

withMemory2 :: (Ord a, Ord b) => (a -> b -> c) -> Map (a, b) c -> a -> b -> c #