Lazily finds all (non-isomorphic) values of or below a given size that satisfy a predicate.
Modulelazy-search-0.1.3.0Haskell2010
Control.Search
Efficient size-based search for values satisfying/falsifying a lazy boolean predicate.
Predicates are typically of type a -> Bool, although an alternative boolean type called Cool is provided and using it may give faster searches.
See Control.Enumerable for defining default enumerations of data types (required for searching).
- 9 types
- 8 classes
- 45 values
- Packagelazy-search-0.1.3.0
- Exports63
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceSearch.hs
Searching
5 declarationsIs there a value of or below a given size that satisfies this predicate?
Find a counterexample to the given predicate, of or below a given size. If no counterexample is found, the number of performed executions of the predicate is returned.
Lazily finds all non-isomorphic (w.r.t. laziness) inputs to a predicate and returns them along with the result of the predicate.
Unsafe version of search. Non-deterministic for some predicates.
Testing properties
2 declarationsSmallCheck-like test driver. Tests a property with gradually increasing sizes until a conunterexample is found. For each size, it shows the worst case number of tests required (if the predicate is fully eager).
Stop testing after a given number of seconds
Options for parallel conjunction
7 declarationsOptions for parallel conjunction strategies. Only matters for
predicates using the Cool data type instead of Bool.
Deep embedded boolean type
8 declarationsCommutative conjunction
Commutative disjunction
Parallel implication
Negation
Concurrent booleans. Writing properties with the Cool data type often yields faster searches compared to Bool.
Provides better interoperability between Bool and Cool by overloading operators.
Re-exported
41 declarationsInstances30Enumerable, …
Enumerable IntegerDefined in size-based-0.1.3.2 · Control.EnumerableEnumerable Int16Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable Int32Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable Int64Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable Int8Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable Word16Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable Word32Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable Word64Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable Word8Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable BoolDefined in size-based-0.1.3.2 · Control.EnumerableEnumerable CharDefined in size-based-0.1.3.2 · Control.EnumerableASCII characters
Enumerable DoubleDefined in size-based-0.1.3.2 · Control.EnumerableNot a proper injection
Enumerable FloatDefined in size-based-0.1.3.2 · Control.EnumerableNot a proper injection
Enumerable IntDefined in size-based-0.1.3.2 · Control.EnumerableEnumerable OrderingDefined in size-based-0.1.3.2 · Control.EnumerableEnumerable WordDefined in size-based-0.1.3.2 · Control.EnumerableEnumerable PrintableDefined in size-based-0.1.3.2 · Control.EnumerableEnumerable UnicodeDefined in size-based-0.1.3.2 · Control.EnumerableEnumerable ()Defined in size-based-0.1.3.2 · Control.EnumerableThe unit constructor is free
Enumerable a => Enumerable (Maybe a)Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable a => Enumerable (NonEmpty a)Defined in size-based-0.1.3.2 · Control.EnumerableEnumerable a => Enumerable [a]Defined in size-based-0.1.3.2 · Control.EnumerableInfinite a => Enumerable (Ratio a)Defined in size-based-0.1.3.2 · Control.EnumerableInfinite integer => Enumerable (Nat integer)Defined in size-based-0.1.3.2 · Control.Enumerable(CoEnumerable a, Enumerable b) => Enumerable (a -> b)Defined in size-based-0.1.3.2 · Control.Enumerable(Enumerable a, Enumerable b) => Enumerable (Either a b)Defined in size-based-0.1.3.2 · Control.Enumerable(Enumerable a, Enumerable b) => Enumerable (a, b)Defined in size-based-0.1.3.2 · Control.Enumerable(Enumerable a, Enumerable b, Enumerable c) => Enumerable (a, b, c)Defined in size-based-0.1.3.2 · Control.Enumerable(Enumerable a, Enumerable b, Enumerable c, Enumerable d) => Enumerable (a, b, c, d)Defined in size-based-0.1.3.2 · Control.Enumerable(Enumerable a, Enumerable b, Enumerable c, Enumerable d, Enumerable e) => Enumerable (a, b, c, d, e)Defined in size-based-0.1.3.2 · Control.Enumerable
A sized functor is an applicative functor extended with a notion of cost/size of contained values. This is useful for any type of bounded recursion over infinite sets, most notably for various kind of enumerations.
The intention is that every sized functor definition models a (usually) infinite set (technically a bag) with a finite number of values of any given size. As long as every cyclic (recursive) definition has at least one application of pay, this invariant is guaranteed.
The module Control.Enumerable provides sized functor definitions for a lot of data types, such that the size of a value is the number of constructor applications it contains. It also allows deriving these functors for any user defined data type (using Template Haskell).
Methods
pay :: f a -> f aIncreases the cost/size of all values in the given set.
pair :: f a -> f b -> f (a, b)aconcat :: [f a] -> f aDefault:
aconcat = foldr (<|>) emptyfin :: Integer -> f IntegerFinite numeric types.
fin ncontains all non-negative numbers below n. This definition is flat, all integers have the same size. Implementing this function efficiently will have a great impact on applications that use a lot of bounded numeric types (e.g. Int).Default: aconcat (map pure [0..n-1])
finSized :: Integer -> f IntegerSame as fin but the size of values may differ. By default, the size of an integer is the number of significant bits in its binary representation. In other words, 0 has size zero, the values for size k>0 in
finBits nare in the interval(2^(k-1),min (2^k-1) n).naturals :: f IntegerNon-negative integers. By default, the size of an integer is the number of digits in its binary representation.
Instances5Sized
Sized MinimalDefined in lazy-search-0.1.3.0 · Control.SearchSized CountDefined in size-based-0.1.3.2 · Control.Enumerable.CountSized MaxSizeDefined in size-based-0.1.3.2 · Control.Enumerable.ValuesSized ValuesDefined in size-based-0.1.3.2 · Control.Enumerable.Values(Typeable f, Sized f) => Sized (Shareable f)Defined in size-based-0.1.3.2 · Control.Enumerable · orphan
Takes a constructor of arity 1
Takes a constructor with arity 0 (a pure value)
An infix synonym for fmap.
The name of this operator is an allusion to Prelude.$.
Note the similarities between their types:
($) :: (a -> b) -> a -> b
(<$>) :: Functor f => (a -> b) -> f a -> f bWhereas Prelude.$ is function application, <$> is function
application lifted over a Functor.
Examples
Convert from a Maybe Int to a Maybe
String using show:
show <$> NothingNothing
show <$> Just 3Just "3"
Convert from an Either Int Int to an
Either Int String using show:
show <$> Left 17Left 17
show <$> Right 17Right "17"
Double each element of a list:
(*2) <$> [1,2,3][2,4,6]
Apply even to the second element of a pair:
even <$> (2,2)(2,True)
A functor with application, providing operations to
A minimal complete definition must include implementations of pure and of either <*> or liftA2. If it defines both, then they must behave the same as their default definitions:
(<*>) = liftA2 idliftA2 f x y = f Prelude.<$> x <*> yFurther, any definition must satisfy the following:
- Identity
pure id <*> v = v- Composition
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)- Homomorphism
pure f <*> pure x = pure (f x)- Interchange
u <*> pure y = pure ($ y) <*> u
The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:
As a consequence of these laws, the Functor instance for f will satisfy
It may be useful to note that supposing
forall x y. p (q x y) = f x . g yit follows from the above that
liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g vIf f is also a Monad, it should satisfy
(which implies that pure and <*> satisfy the applicative functor laws).
Methods
pure :: a -> f aLift a value into the Structure.
Examples
Example1 expression pure 1 :: Maybe IntJust 1
Example1 expression pure 'z' :: [Char]"z"
Example1 expression pure (pure ":D") :: Maybe [String]Just [":D"]
(<*>) :: f (a -> b) -> f a -> f binfixl 4Sequential application.
A few functors support an implementation of <*> that is more efficient than the default one.
Example
Used in combination with
,(Data.Functor.<$>)can be used to build a record.(<*>)Example1 expression data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}Example3 expressions produceFoo :: Applicative f => f FooproduceBar :: Applicative f => f BarproduceBaz :: Applicative f => f Baz
Example2 expressions mkState :: Applicative f => f MyStatemkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
liftA2 :: (a -> b -> c) -> f a -> f b -> f cLift a binary function to actions.
Some functors support an implementation of liftA2 that is more efficient than the default one. In particular, if fmap is an expensive operation, it is likely better to use liftA2 than to fmap over the structure and then use <*>.
This became a typeclass method in 4.10.0.0. Prior to that, it was a function defined in terms of <*> and fmap.
Example
Example1 expression liftA2 (,) (Just 3) (Just 5)Just (3,5)
Example1 expression liftA2 (+) [1, 2, 3] [4, 5, 6][5,6,7,6,7,8,7,8,9]
(*>) :: f a -> f b -> f binfixl 4Sequence actions, discarding the value of the first argument.
Examples
If used in conjunction with the Applicative instance for Maybe, you can chain Maybe computations, with a possible "early return" in case of Nothing.
Example1 expression Just 2 *> Just 3Just 3
Example1 expression Nothing *> Just 3Nothing
Of course a more interesting use case would be to have effectful computations instead of just returning pure values.
Example4 expressions import Data.Charimport GHC.Internal.Text.ParserCombinators.ReadPlet p = string "my name is " *> munch1 isAlpha <* eofreadP_to_S p "my name is Simon"[("Simon","")]
(<*) :: f a -> f b -> f ainfixl 4Sequence actions, discarding the value of the second argument.
Instances66Applicative, …
Applicative ComplexDefined in base-4.20.2.0 · Data.ComplexApplicative FirstDefined in base-4.20.2.0 · Data.SemigroupApplicative LastDefined in base-4.20.2.0 · Data.SemigroupApplicative MaxDefined in base-4.20.2.0 · Data.SemigroupApplicative MinDefined in base-4.20.2.0 · Data.SemigroupApplicative SeqDefined in containers-0.7 · Data.Sequence.InternalApplicative TreeDefined in containers-0.7 · Data.TreeApplicative NonEmptyDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncApplicative IdentityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.IdentityApplicative FirstDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidApplicative LastDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidApplicative DownDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.OrdApplicative DualDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalApplicative ProductDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalApplicative SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalApplicative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListf <$> ZipList xs1 <*> ... <*> ZipList xsN = ZipList (zipWithN f xs1 ... xsN)where
zipWithNrefers to thezipWithfunction of the appropriate arity (zipWith,zipWith3,zipWith4, ...). For example:(\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..] = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..]) = ZipList {getZipList = ["a5","b6b6","c7c7c7"]}Applicative NoIODefined in ghc-internal-9.1003.0 · GHC.Internal.GHCiApplicative Par1Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsApplicative MaybeDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative PDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPApplicative ReadPDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPApplicative ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecApplicative SoloDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative IODefined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative MinimalDefined in lazy-search-0.1.3.0 · Control.SearchApplicative CountDefined in size-based-0.1.3.2 · Control.Enumerable.CountApplicative MaxSizeDefined in size-based-0.1.3.2 · Control.Enumerable.ValuesApplicative ValuesDefined in size-based-0.1.3.2 · Control.Enumerable.ValuesApplicative PprMDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.PprLibApplicative QDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxApplicative []Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyApplicative U1Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsApplicative (SetM s)Defined in containers-0.7 · Data.GraphApplicative (State s)Defined in containers-0.7 · Utils.Containers.Internal.StateApplicative (ST s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Monad.ST.Lazy.ImpApplicative (Either e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.EitherApplicative (StateL s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.UtilsApplicative (StateR s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.UtilsApplicative (ST s)Defined in ghc-internal-9.1003.0 · GHC.Internal.STApplicative f => Applicative (Shareable f)Defined in dictionary-sharing-0.1.0.0 · Data.ClassSharingMonad m => Applicative (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonoid a => Applicative (Tuple2 a)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseArrow a => Applicative (ArrowMonad a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.ArrowApplicative f => Applicative (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidApplicative f => Applicative (Alt f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalApplicative f => Applicative (Rec1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsApplicative m => Applicative (Kleisli m a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.ArrowMonad m => Applicative (StateT s m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.UtilsMonoid m => Applicative (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstArrow a => Applicative (WrappedArrow a b)Defined in base-4.20.2.0 · Control.Applicative(Applicative f, Monad f) => Applicative (WhenMissing f x)Defined in containers-0.7 · Data.IntMap.InternalEquivalent to
ReaderT k (ReaderT x (MaybeT f)).(Monoid a, Monoid b) => Applicative (Tuple3 a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base(Generic1 f, Applicative (Rep1 f)) => Applicative (Generically1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsApplicative ((->) r)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid c => Applicative (K1 i c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Applicative f, Applicative g) => Applicative (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product(Applicative f, Applicative g) => Applicative (f :*: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Applicative f, Monad f) => Applicative (WhenMissing f k x)Defined in containers-0.7 · Data.Map.InternalEquivalent to
ReaderT k (ReaderT x (MaybeT f)).(Monad f, Applicative f) => Applicative (WhenMatched f x y)Defined in containers-0.7 · Data.IntMap.InternalEquivalent to
ReaderT Key (ReaderT x (ReaderT y (MaybeT f)))(Monoid a, Monoid b, Monoid c) => Applicative (Tuple4 a b c)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative f => Applicative (M1 i c f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Applicative f, Applicative g) => Applicative (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose(Applicative f, Applicative g) => Applicative (f :.: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Monad f, Applicative f) => Applicative (WhenMatched f k x y)Defined in containers-0.7 · Data.Map.InternalEquivalent to
ReaderT k (ReaderT x (ReaderT y (MaybeT f)))
Replace all locations in the input with the same value.
The default definition is fmap . const, but this may be
overridden with a more efficient version.
Examples
Perform a computation with Maybe and replace the result with a constant value if it is Just:
'a' <$ Just 2Just 'a''a' <$ NothingNothing
A variant of <*> with the types of the arguments reversed. It differs from
flip in that the effects are resolved in the order the arguments are
presented.(<*>)
Examples
(<**>) (print 1) (id <$ print 2)12
flip (<*>) (print 1) (id <$ print 2)21
ZipList [4, 5, 6] <**> ZipList [(+1), (*2), (/3)]ZipList {getZipList = [5.0,10.0,2.0]}
A monoid on applicative functors.
If defined, some and many should be the least solutions of the equations:
Examples
Nothing <|> Just 42Just 42
[1, 2] <|> [3, 4][1,2,3,4]
empty <|> print (2^15)32768
Methods
empty :: f aThe identity of <|>
empty <|> a == a a <|> empty == a(<|>) :: f a -> f a -> f ainfixl 3An associative binary operation
some :: f a -> f [a]One or more.
Examples
Example1 expression some (putStr "la")lalalalalalalalala... * goes on forever *
Example1 expression some Nothingnothing
Example1 expression take 5 <$> some (Just 1)* hangs forever *
Note that this function can be used with Parsers based on Applicatives. In that case
some parserwill attempt to parseparserone or more times until it fails.many :: f a -> f [a]Zero or more.
Examples
Example1 expression many (putStr "la")lalalalalalalalala... * goes on forever *
Example1 expression many NothingJust []
Example1 expression take 5 <$> many (Just 1)* hangs forever *
Note that this function can be used with Parsers based on Applicatives. In that case
many parserwill attempt to parseparserzero or more times until it fails.
Instances29Alternative, …
Alternative SeqDefined in containers-0.7 · Data.Sequence.InternalAlternative STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncAlternative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListAlternative MaybeDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseAlternative PDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPAlternative ReadPDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPAlternative ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecAlternative IODefined in ghc-internal-9.1003.0 · GHC.Internal.BaseAlternative MinimalDefined in lazy-search-0.1.3.0 · Control.SearchAlternative CountDefined in size-based-0.1.3.2 · Control.Enumerable.CountAlternative MaxSizeDefined in size-based-0.1.3.2 · Control.Enumerable.ValuesAlternative ValuesDefined in size-based-0.1.3.2 · Control.Enumerable.ValuesAlternative []Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseCombines lists by concatenation, starting from the empty list.
Alternative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyAlternative U1Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsAlternative f => Alternative (Shareable f)Defined in dictionary-sharing-0.1.0.0 · Data.ClassSharingMonadPlus m => Alternative (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeArrowPlus a => Alternative (ArrowMonad a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.ArrowAlternative f => Alternative (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidAlternative f => Alternative (Alt f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalAlternative f => Alternative (Rec1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsAlternative m => Alternative (Kleisli m a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b)Defined in base-4.20.2.0 · Control.Applicative(Generic1 f, Alternative (Rep1 f)) => Alternative (Generically1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Alternative f, Alternative g) => Alternative (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product(Alternative f, Alternative g) => Alternative (f :*: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsAlternative f => Alternative (M1 i c f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Alternative f, Applicative g) => Alternative (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose(Alternative f, Applicative g) => Alternative (f :.: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
Lift a function to actions.
Equivalent to Functor's fmap but implemented using only Applicative's methods:
liftA f a = pure f <*> a
As such this function may be used to implement a Functor instance from an Applicative one.
Examples
Using the Applicative instance for Lists:
liftA (+1) [1, 2][2,3]
Or the Applicative instance for Maybe
liftA (+1) (Just 3)Just 4
Lift a ternary function to actions.
The class Typeable allows a concrete representation of a type to be calculated.
Guarantees local sharing. All enumerations are shared inside each invokation of local, but may not be shared between them.
This is the primary way to access enumerations for usage. Guarantees global sharing of enumerations of the same type. Note that this means the enumerations are never garbage collected.
One or none.
It is useful for modelling any computation that is allowed to fail.
Examples
Using the Alternative instance of Control.Monad.Except, the following functions:
import Control.Monad.ExceptcanFail = throwError "it failed" :: Except String Intfinal = return 42 :: Except String Int
Can be combined by allowing the first function to fail:
runExcept $ canFail *> finalLeft "it failed"
runExcept $ optional canFail *> finalRight 42
The sum of a collection of actions using (<|>), generalizing concat.
asum is just like msum, but generalised to Alternative.
Examples
Basic usage:
asum [Just "Hello", Nothing, Just "World"]Just "Hello"
Constructors
WrapArrowunwrapArrow :: a b c
Instances8Generic1, Functor, Applicative, Alternative, Data, Generic, …
Generic1 (WrappedArrow a b)Defined in base-4.20.2.0 · Control.ApplicativeArrow a => Functor (WrappedArrow a b)Defined in base-4.20.2.0 · Control.ApplicativeArrow a => Applicative (WrappedArrow a b)Defined in base-4.20.2.0 · Control.Applicative(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b)Defined in base-4.20.2.0 · Control.Applicative(Typeable a, Typeable b, Typeable c, Data (a b c)) => Data (WrappedArrow a b c)Defined in base-4.20.2.0 · Control.ApplicativeGeneric (WrappedArrow a b c)Defined in base-4.20.2.0 · Control.Applicativetype Rep (WrappedArrow a b c) = D1 ('MetaDataDefined in base-4.20.2.0 · Control.Applicative"WrappedArrow"
"Control.Applicative"
"base"
'True) (C1 ('MetaCons"WrapArrow"
'PrefixI 'True) (S1 ('MetaSel ('Just"unwrapArrow"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (a b c))))type Rep1 (WrappedArrow a b) = D1 ('MetaDataDefined in base-4.20.2.0 · Control.Applicative"WrappedArrow"
"Control.Applicative"
"base"
'True) (C1 ('MetaCons"WrapArrow"
'PrefixI 'True) (S1 ('MetaSel ('Just"unwrapArrow"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 (a b))))
Constructors
WrapMonadunwrapMonad :: m a
Instances9Generic1, Monad, Functor, Applicative, Alternative, Data, …
Generic1 (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonad m => Monad (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonad m => Functor (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonad m => Applicative (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonadPlus m => Alternative (WrappedMonad m)Defined in base-4.20.2.0 · Control.Applicative(Typeable m, Typeable a, Data (m a)) => Data (WrappedMonad m a)Defined in base-4.20.2.0 · Control.ApplicativeGeneric (WrappedMonad m a)Defined in base-4.20.2.0 · Control.Applicativetype Rep (WrappedMonad m a) = D1 ('MetaDataDefined in base-4.20.2.0 · Control.Applicative"WrappedMonad"
"Control.Applicative"
"base"
'True) (C1 ('MetaCons"WrapMonad"
'PrefixI 'True) (S1 ('MetaSel ('Just"unwrapMonad"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (m a))))type Rep1 (WrappedMonad m) = D1 ('MetaDataDefined in base-4.20.2.0 · Control.Applicative"WrappedMonad"
"Control.Applicative"
"base"
'True) (C1 ('MetaCons"WrapMonad"
'PrefixI 'True) (S1 ('MetaSel ('Just"unwrapMonad"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 m)))
The Const functor.
Examples
fmap (++ "World") (Const "Hello")Const "Hello"
Because we ignore the second type parameter to Const,
the Applicative instance, which has
essentially turns into (<*>) :: Monoid m => Const m (a -> b) -> Const m a -> Const m bMonoid m => m -> m -> m, which is (<>)
Const [1, 2, 3] <*> Const [4, 5, 6]Const [1,2,3,4,5,6]
Instances45Generic1, Bifoldable, Bifoldable1, Bifunctor, Bitraversable, Eq2, …
Generic1 (Const a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstBifoldable ConstDefined in base-4.20.2.0 · Data.BifoldableBifoldable1 ConstDefined in base-4.20.2.0 · Data.Bifoldable1Bifunctor ConstDefined in base-4.20.2.0 · Data.BifunctorBitraversable ConstDefined in base-4.20.2.0 · Data.BitraversableEq2 ConstDefined in base-4.20.2.0 · Data.Functor.ClassesOrd2 ConstDefined in base-4.20.2.0 · Data.Functor.ClassesRead2 ConstDefined in base-4.20.2.0 · Data.Functor.ClassesShow2 ConstDefined in base-4.20.2.0 · Data.Functor.ClassesNFData2 ConstDefined in deepseq-1.5.0.0 · Control.DeepSeqFunctor (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstMonoid m => Applicative (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFoldable (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstTraversable (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.TraversableEq a => Eq1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesOrd a => Ord1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesRead a => Read1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesShow a => Show1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesContravariant (Const a)Defined in base-4.20.2.0 · Data.Functor.ContravariantNFData a => NFData1 (Const a)Defined in deepseq-1.5.0.0 · Control.DeepSeqBounded a => Bounded (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstEnum a => Enum (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstEq a => Eq (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFloating a => Floating (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFractional a => Fractional (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstIntegral a => Integral (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const(Typeable k, Data a, Typeable b) => Data (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.DataNum a => Num (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstOrd a => Ord (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstRead a => Read (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstReal a => Real (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstRealFloat a => RealFloat (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstRealFrac a => RealFrac (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstShow a => Show (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstIx a => Ix (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstIsString a => IsString (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.StringGeneric (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstSemigroup a => Semigroup (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstMonoid a => Monoid (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstBits a => Bits (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFiniteBits a => FiniteBits (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstStorable a => Storable (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstNFData a => NFData (Const a b)Defined in deepseq-1.5.0.0 · Control.DeepSeqtype Rep (Const a b) = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const"Const"
"GHC.Internal.Data.Functor.Const"
"ghc-internal"
'True) (C1 ('MetaCons"Const"
'PrefixI 'True) (S1 ('MetaSel ('Just"getConst"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))type Rep1 (Const a) = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const"Const"
"GHC.Internal.Data.Functor.Const"
"ghc-internal"
'True) (C1 ('MetaCons"Const"
'PrefixI 'True) (S1 ('MetaSel ('Just"getConst"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
Lists, but with an Applicative functor based on zipping.
Examples
In contrast to the Applicative for GHC.List.List:
(+) <$> [1, 2, 3] <*> [4, 5, 6][5,6,7,6,7,8,7,8,9]
The Applicative instance of ZipList applies the operation by pairing up the elements, analogous to zipWithN
(+) <$> ZipList [1, 2, 3] <*> ZipList [4, 5, 6]ZipList {getZipList = [5,7,9]}
(,,,) <$> ZipList [1, 2] <*> ZipList [3, 4] <*> ZipList [5, 6] <*> ZipList [7, 8]ZipList {getZipList = [(1,3,5,7),(2,4,6,8)]}
ZipList [(+1), (^2), (/ 2)] <*> ZipList [5, 5, 5]ZipList {getZipList = [6.0,25.0,2.5]}
Constructors
ZipListgetZipList :: [a]
Instances18Functor, Applicative, Foldable, Traversable, Alternative, NFData1, …
Functor ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListApplicative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListf <$> ZipList xs1 <*> ... <*> ZipList xsN = ZipList (zipWithN f xs1 ... xsN)where
zipWithNrefers to thezipWithfunction of the appropriate arity (zipWith,zipWith3,zipWith4, ...). For example:(\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..] = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..]) = ZipList {getZipList = ["a5","b6b6","c7c7c7"]}Foldable ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListTraversable ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListAlternative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListNFData1 ZipListDefined in deepseq-1.5.0.0 · Control.DeepSeqGeneric1 ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListIsList (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IsListEq a => Eq (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListData a => Data (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListOrd a => Ord (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListRead a => Read (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListShow a => Show (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListGeneric (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListNFData a => NFData (ZipList a)Defined in deepseq-1.5.0.0 · Control.DeepSeqtype Rep (ZipList a) = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList"ZipList"
"GHC.Internal.Functor.ZipList"
"ghc-internal"
'True) (C1 ('MetaCons"ZipList"
'PrefixI 'True) (S1 ('MetaSel ('Just"getZipList"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a])))type Rep1 ZipList = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList"ZipList"
"GHC.Internal.Functor.ZipList"
"ghc-internal"
'True) (C1 ('MetaCons"ZipList"
'PrefixI 'True) (S1 ('MetaSel ('Just"getZipList"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 [])))type Item (ZipList a) = aDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList
Work in progress
Methods
coEnumerate :: (Enumerable b, Sized f, Typeable f) => Shared f (a -> b)
Instances2CoEnumerable
CoEnumerable BoolDefined in size-based-0.1.3.2 · Control.EnumerableCoEnumerable a => CoEnumerable [a]Defined in size-based-0.1.3.2 · Control.Enumerable
A class of infinite precision integral types. Integer is the principal class member.
Used instead of enumerate when manually building instances.
Builds an enumeration of a data type from a list of constructors (see c0-c7)
Derive an instance of Enumberable with Template Haskell, with rules for some specific constructors
Builds a suitable definition for coEnumerate given an pattern matching function for a data type (see source for examples).