Data.Unfoldable1.Trivial1.Internal
- Package
- purescript-trivial-unfold
- Repository
- UnrelatedString/purescript-trivial-unfold
This module provides the Trivial1 type as an existentially quantified
dumb wrapper around unfold1, which can be inspected and manipulated
to implement various typeclasses and the utilities in Data.Unfoldable1.Trivia1.
This module also contains the implementations of utilities which rely on directly
inspecting Trivial1 values and are re-exported by Data.Unfoldable.Trivial1.
Use this module directly only if you intend to directly inspect Trivial1 values yourself.
#Trivial1 Source
newtype Trivial1 aA type wrapping unfoldr1 calls, existentially quantified over the seed type
so that it can be ignored in the type constructor. Its Unfoldable1 instance
means that it can directly be constructed by calling unfoldr1.
Instances
Unfoldable1 Trivial1Functor Trivial1Invariant Trivial1Foldable Trivial1Foldable1 Trivial1The raison d'être for
Trivial1. Allows folding polymorphicUnfoldable1s as they generate with no explicit starting value. In particular,foldMap1needs map only into aSemigrouprather than aMonoid.foldr1uses a default implementation and may be inefficient.(Arbitrary a, Coarbitrary a) => Arbitrary (Trivial1 a)Guaranteed finite.
Lazy (Trivial1 a)Semigroup (Trivial1 a)Concatenation.
Do not use this to create a data structure. Please use Data.List.Lazy instead.
Apply Trivial1Zipwith; chosen over the
Monad-compatible nondet choice used forArrayetc. because that would require effectively forcing one argument and either re-evaluating it constantly or storing its elements in a real container at which point please please please just do that without usingTrivial1. Length is the minimum of the arguments' lengths.Applicative Trivial1Infinitely cycles to satisfy the Applicative laws! If you just want one element, use
singletoninstead.Alt Trivial1Not concatenation!
(<|>)clobbers a prefix of the right argument of the length of the left for consistency withAlternative Trivial, althoughTrivial1itself fundamentally lacks aPlusinstance.(Eq a) => Eq (Trivial1 a)Does not and cannot memoize the values being produced to compare. Please consider using Data.List.Lazy or your strict container of choice instead if you have any intention of using this for anything else.
(Ord a) => Ord (Trivial1 a)Eq1 Trivial1Ord1 Trivial1(Show a) => Show (Trivial1 a)
#Generator1 Source
type Generator1 a b = b -> a /\ (Maybe b)Alias for the generator function passed to unfoldr1.
#untrivial1 Source
untrivial1 :: forall a c. (forall b. Generator1 a b -> b -> c) -> Trivial1 a -> cConvenience function for inspecting Trivial values.
Calls the function argument on the contents of the inner Exists.
#turbofish1 Source
turbofish1 :: forall a b. (Trivial1 a -> b) -> Trivial1 a -> bFunction application specialized to a Trivial1 argument,
at the same precedence as ($).
Inspired by the Rust syntax of the same name, often used in the analogous context of collecting from an iterator.
#(::<+>) Source
Operator alias for Data.Unfoldable1.Trivial1.Internal.turbofish1 (right-associative / precedence 0)
#uncons1 Source
uncons1 :: forall a u. Unfoldable u => Trivial1 a -> a /\ (u a)Returns the first element, and an Unfoldable of the remaining elements.
#runTrivial1 Source
runTrivial1 :: forall a u. Unfoldable1 u => Trivial1 a -> u aConverts to any other Unfoldable1.
Can also be seen as evaluating the inner Unfoldr1Call.
This is only useful in implementing utility functions. In all other cases, simply use the desired type directly.
Wraps both arguments to
unfoldr1in anUnfoldr1Call.