com.jnape.palatable.lambda.adt.hlist

## Class SingletonHList<_1>

- java.lang.Object
- - com.jnape.palatable.lambda.adt.hlist.HList
  - - com.jnape.palatable.lambda.adt.hlist.HList.HCons<_1,HList.HNil>
    - - com.jnape.palatable.lambda.adt.hlist.SingletonHList<_1>

- Type Parameters:
    `_1` - The single slot element type
  All Implemented Interfaces:
    Applicative<_1,SingletonHList<?>>, Functor<_1,SingletonHList<?>>, Monad<_1,SingletonHList<?>>, MonadRec<_1,SingletonHList<?>>, Traversable<_1,SingletonHList<?>>

      public class SingletonHList<_1>
      extends HList.HCons<_1,HList.HNil>
      implements MonadRec<_1,SingletonHList<?>>, Traversable<_1,SingletonHList<?>>

  A singleton HList. Supports random access.
  See Also:
    `HList`, `Tuple2`, `Tuple3`, `Tuple4`, `Tuple5`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.jnape.palatable.lambda.adt.hlist.HList

      `HList.HCons<Head,Tail extends HList>, HList.HNil`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<_0> Tuple2<_0,_1>` | `cons(_0 _0)` Cons an element onto the front of this HList.
    `<_1Prime> SingletonHList<_1Prime>` | `discardL(Applicative<_1Prime,SingletonHList<?>> appB)` Sequence both this `Applicative` and `appB`, discarding this `Applicative's` result and returning `appB`.
    `<_1Prime> SingletonHList<_1>` | `discardR(Applicative<_1Prime,SingletonHList<?>> appB)` Sequence both this `Applicative` and `appB`, discarding `appB's` result and returning this `Applicative`.
    `<_1Prime> SingletonHList<_1Prime>` | `flatMap(Fn1<? super _1,? extends Monad<_1Prime,SingletonHList<?>>> f)` Chain dependent computations that may continue or short-circuit based on previous results.
    `<_1Prime> SingletonHList<_1Prime>` | `fmap(Fn1<? super _1,? extends _1Prime> fn)` Covariantly transmute this functor's parameter using the given mapping function.
    `<R> R` | `into(Fn1<? super _1,? extends R> fn)` Apply `HList.HCons.head()` to `fn` and return the result.
    `<_1Prime> Lazy<SingletonHList<_1Prime>>` | `lazyZip(Lazy<? extends Applicative<Fn1<? super _1,? extends _1Prime>,SingletonHList<?>>> lazyAppFn)` Given a `lazy` instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
    `<_1Prime> SingletonHList<_1Prime>` | `pure(_1Prime _1Prime)` Lift the value `b` into this applicative functor.
    `static Pure<SingletonHList<?>>` | `pureSingletonHList()` The canonical `Pure` instance for `SingletonHList`.
    `<_1Prime> SingletonHList<_1Prime>` | `trampolineM(Fn1<? super _1,? extends MonadRec<RecursiveResult<_1,_1Prime>,SingletonHList<?>>> fn)` Given some operation yielding a `RecursiveResult` inside this `MonadRec`, internally trampoline the operation until it yields a `termination` instruction.
    `<B,App extends Applicative<?,App>,TravB extends Traversable<B,SingletonHList<?>>,AppTrav extends Applicative<TravB,App>> AppTrav` | `traverse(Fn1<? super _1,? extends Applicative<B,App>> fn, Fn1<? super TravB,? extends AppTrav> pure)` Apply `fn` to each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.
    `<_1Prime> SingletonHList<_1Prime>` | `zip(Applicative<Fn1<? super _1,? extends _1Prime>,SingletonHList<?>> appFn)` Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.

    - ### Methods inherited from class com.jnape.palatable.lambda.adt.hlist.HList.HCons

      `equals, hashCode, head, tail`

    - ### Methods inherited from class com.jnape.palatable.lambda.adt.hlist.HList

      `cons, nil, singletonHList, toString, tuple, tuple, tuple, tuple, tuple, tuple, tuple`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.jnape.palatable.lambda.monad.Monad

      `join`

    - ### Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

      `coerce`

- - ### Method Detail

    - #### cons

          public <_0> Tuple2<_0,_1> cons(_0 _0)

      Cons an element onto the front of this HList.
      Overrides:
        `cons` in class `HList.HCons<_1,HList.HNil>`
      Type Parameters:
        `_0` - the new head type
      Parameters:
        `_0` - the new head element
      Returns:
        the updated HList

    - #### fmap

          public <_1Prime> SingletonHList<_1Prime> fmap(Fn1<? super _1,? extends _1Prime> fn)

      Covariantly transmute this functor's parameter using the given mapping function. Generally this method is specialized to return an instance of the class implementing Functor.
      Specified by:
        `fmap` in interface `Applicative<_1,SingletonHList<?>>`
      Specified by:
        `fmap` in interface `Functor<_1,SingletonHList<?>>`
      Specified by:
        `fmap` in interface `Monad<_1,SingletonHList<?>>`
      Specified by:
        `fmap` in interface `MonadRec<_1,SingletonHList<?>>`
      Specified by:
        `fmap` in interface `Traversable<_1,SingletonHList<?>>`
      Type Parameters:
        `_1Prime` - the new parameter type
      Parameters:
        `fn` - the mapping function
      Returns:
        a functor over B (the new parameter type)

    - #### pure

          public <_1Prime> SingletonHList<_1Prime> pure(_1Prime _1Prime)

      Lift the value `b` into this applicative functor.
      Specified by:
        `pure` in interface `Applicative<_1,SingletonHList<?>>`
      Specified by:
        `pure` in interface `Monad<_1,SingletonHList<?>>`
      Specified by:
        `pure` in interface `MonadRec<_1,SingletonHList<?>>`
      Type Parameters:
        `_1Prime` - the type of the returned applicative's parameter
      Parameters:
        `_1Prime` - the value
      Returns:
        an instance of this applicative over b

    - #### zip

          public <_1Prime> SingletonHList<_1Prime> zip(Applicative<Fn1<? super _1,? extends _1Prime>,SingletonHList<?>> appFn)

      Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
      Specified by:
        `zip` in interface `Applicative<_1,SingletonHList<?>>`
      Specified by:
        `zip` in interface `Monad<_1,SingletonHList<?>>`
      Specified by:
        `zip` in interface `MonadRec<_1,SingletonHList<?>>`
      Type Parameters:
        `_1Prime` - the resulting applicative parameter type
      Parameters:
        `appFn` - the other applicative instance
      Returns:
        the mapped applicative

    - #### lazyZip

          public <_1Prime> Lazy<SingletonHList<_1Prime>> lazyZip(Lazy<? extends Applicative<Fn1<? super _1,? extends _1Prime>,SingletonHList<?>>> lazyAppFn)

      Given a `lazy` instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. This is useful for applicatives that support lazy evaluation and early termination.
      Specified by:
        `lazyZip` in interface `Applicative<_1,SingletonHList<?>>`
      Specified by:
        `lazyZip` in interface `Monad<_1,SingletonHList<?>>`
      Specified by:
        `lazyZip` in interface `MonadRec<_1,SingletonHList<?>>`
      Type Parameters:
        `_1Prime` - the resulting applicative parameter type
      Parameters:
        `lazyAppFn` - the lazy other applicative instance
      Returns:
        the mapped applicative
      See Also:
        `Maybe`, `Either`

    - #### discardL

          public <_1Prime> SingletonHList<_1Prime> discardL(Applicative<_1Prime,SingletonHList<?>> appB)

      Sequence both this `Applicative` and `appB`, discarding this `Applicative's` result and returning `appB`. This is generally useful for sequentially performing side-effects.
      Specified by:
        `discardL` in interface `Applicative<_1,SingletonHList<?>>`
      Specified by:
        `discardL` in interface `Monad<_1,SingletonHList<?>>`
      Specified by:
        `discardL` in interface `MonadRec<_1,SingletonHList<?>>`
      Type Parameters:
        `_1Prime` - the type of the returned Applicative's parameter
      Parameters:
        `appB` - the other Applicative
      Returns:
        appB

    - #### discardR

          public <_1Prime> SingletonHList<_1> discardR(Applicative<_1Prime,SingletonHList<?>> appB)

      Sequence both this `Applicative` and `appB`, discarding `appB's` result and returning this `Applicative`. This is generally useful for sequentially performing side-effects.
      Specified by:
        `discardR` in interface `Applicative<_1,SingletonHList<?>>`
      Specified by:
        `discardR` in interface `Monad<_1,SingletonHList<?>>`
      Specified by:
        `discardR` in interface `MonadRec<_1,SingletonHList<?>>`
      Type Parameters:
        `_1Prime` - the type of appB's parameter
      Parameters:
        `appB` - the other Applicative
      Returns:
        this Applicative

    - #### flatMap

          public <_1Prime> SingletonHList<_1Prime> flatMap(Fn1<? super _1,? extends Monad<_1Prime,SingletonHList<?>>> f)

      Chain dependent computations that may continue or short-circuit based on previous results.
      Specified by:
        `flatMap` in interface `Monad<_1,SingletonHList<?>>`
      Specified by:
        `flatMap` in interface `MonadRec<_1,SingletonHList<?>>`
      Type Parameters:
        `_1Prime` - the resulting monad parameter type
      Parameters:
        `f` - the dependent computation over A
      Returns:
        the new monad instance

    - #### trampolineM

          public <_1Prime> SingletonHList<_1Prime> trampolineM(Fn1<? super _1,? extends MonadRec<RecursiveResult<_1,_1Prime>,SingletonHList<?>>> fn)

      Given some operation yielding a `RecursiveResult` inside this `MonadRec`, internally trampoline the operation until it yields a `termination` instruction.

      Stack-safety depends on implementations guaranteeing that the growth of the call stack is a constant factor independent of the number of invocations of the operation. For various examples of how this can be achieved in stereotypical circumstances, see the referenced types.

      Specified by:
        `trampolineM` in interface `MonadRec<_1,SingletonHList<?>>`
      Type Parameters:
        `_1Prime` - the ultimate resulting carrier type
      Parameters:
        `fn` - the function to internally trampoline
      Returns:
        the trampolined `MonadRec`
      See Also:
        `for a basic implementation`, `for a {@link CoProduct2 coproduct} implementation`, `for an implementation leveraging an already stack-safe {@link Monad#flatMap(Fn1)}`, `for a {@link MonadT monad transformer} implementation`

    - #### traverse

          public <B,App extends Applicative<?,App>,TravB extends Traversable<B,SingletonHList<?>>,AppTrav extends Applicative<TravB,App>> AppTrav traverse(Fn1<? super _1,? extends Applicative<B,App>> fn,
                                                                                                                                                           Fn1<? super TravB,? extends AppTrav> pure)

      Apply `fn` to each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.
      Specified by:
        `traverse` in interface `Traversable<_1,SingletonHList<?>>`
      Type Parameters:
        `B` - the resulting element type
        `App` - the result applicative type
        `TravB` - this Traversable instance over B
        `AppTrav` - the full inferred resulting type from the traversal
      Parameters:
        `fn` - the function to apply
        `pure` - the applicative pure function
      Returns:
        the traversed Traversable, wrapped inside an applicative

    - #### into

          public <R> R into(Fn1<? super _1,? extends R> fn)

      Apply `HList.HCons.head()` to `fn` and return the result.
      Type Parameters:
        `R` - the return type of the function
      Parameters:
        `fn` - the function to apply
      Returns:
        the result of applying the head to the function

    - #### pureSingletonHList

          public static Pure<SingletonHList<?>> pureSingletonHList()

      The canonical `Pure` instance for `SingletonHList`.
      Returns:
        the `Pure` instance