Module

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 a

A 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 Trivial1

    Wraps both arguments to unfoldr1 in an Unfoldr1Call.

  • Functor Trivial1
  • Invariant Trivial1
  • Foldable Trivial1
  • Foldable1 Trivial1

    The raison d'être for Trivial1. Allows folding polymorphic Unfoldable1s as they generate with no explicit starting value. In particular, foldMap1 needs map only into a Semigroup rather than a Monoid.

    foldr1 uses 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 Trivial1

    Zipwith; chosen over the Monad-compatible nondet choice used for Array etc. 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 using Trivial1. Length is the minimum of the arguments' lengths.

  • Applicative Trivial1

    Infinitely cycles to satisfy the Applicative laws! If you just want one element, use singleton instead.

  • Alt Trivial1

    Not concatenation! (<|>) clobbers a prefix of the right argument of the length of the left for consistency with Alternative Trivial, although Trivial1 itself fundamentally lacks a Plus instance.

  • (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 Trivial1
  • Ord1 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 -> c

Convenience function for inspecting Trivial values. Calls the function argument on the contents of the inner Exists.

#trivial1 Source

trivial1 :: forall a. Trivial1 a -> Trivial1 a

Specializes its argument to Trivial1.

#turbofish1 Source

turbofish1 :: forall a b. (Trivial1 a -> b) -> Trivial1 a -> b

Function 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 a

Converts 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.