generics-sop-0.2.5.0: Generic Programming using True Sums of Products

Safe Haskell | None
Language | Haskell2010

Generics.SOP.NP

Contents

- Datatypes
- Constructing products
  - Construction from a list
- Application
- Destructing products
- Lifting / mapping
- Dealing with ``All` c`
- Collapsing
- Sequencing
- Catamorphism and anamorphism

Description

n-ary products (and products of products)

Synopsis

- data NP :: (k -> *) -> [k] -> * where
  - Nil :: NP f '[]
  - (:*) :: f x -> NP f xs -> NP f (x ': xs)
- newtype POP f xss = POP (NP (NP f) xss)
- unPOP :: POP f xss -> NP (NP f) xss
- pure_NP :: forall f xs. SListI xs => (forall a. f a) -> NP f xs
- pure_POP :: All SListI xss => (forall a. f a) -> POP f xss
- cpure_NP :: forall c xs proxy f. All c xs => proxy c -> (forall a. c a => f a) -> NP f xs
- cpure_POP :: forall c xss proxy f. All2 c xss => proxy c -> (forall a. c a => f a) -> POP f xss
- fromList :: SListI xs => [a] -> Maybe (NP (K a) xs)
- ap_NP :: NP (f -.-> g) xs -> NP f xs -> NP g xs
- ap_POP :: POP (f -.-> g) xss -> POP f xss -> POP g xss
- hd :: NP f (x ': xs) -> f x
- tl :: NP f (x ': xs) -> NP f xs
- type Projection f xs = K (NP f xs) -.-> f
- projections :: forall xs f. SListI xs => NP (Projection f xs) xs
- shiftProjection :: Projection f xs a -> Projection f (x ': xs) a
- liftA_NP :: SListI xs => (forall a. f a -> g a) -> NP f xs -> NP g xs
- liftA_POP :: All SListI xss => (forall a. f a -> g a) -> POP f xss -> POP g xss
- liftA2_NP :: SListI xs => (forall a. f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs
- liftA2_POP :: All SListI xss => (forall a. f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss
- liftA3_NP :: SListI xs => (forall a. f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs
- liftA3_POP :: All SListI xss => (forall a. f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss
- map_NP :: SListI xs => (forall a. f a -> g a) -> NP f xs -> NP g xs
- map_POP :: All SListI xss => (forall a. f a -> g a) -> POP f xss -> POP g xss
- zipWith_NP :: SListI xs => (forall a. f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs
- zipWith_POP :: All SListI xss => (forall a. f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss
- zipWith3_NP :: SListI xs => (forall a. f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs
- zipWith3_POP :: All SListI xss => (forall a. f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss
- cliftA_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a) -> NP f xs -> NP g xs
- cliftA_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a) -> POP f xss -> POP g xss
- cliftA2_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs
- cliftA2_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss
- cliftA3_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs
- cliftA3_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss
- cmap_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a) -> NP f xs -> NP g xs
- cmap_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a) -> POP f xss -> POP g xss
- czipWith_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs
- czipWith_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss
- czipWith3_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs
- czipWith3_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss
- hcliftA' :: (All2 c xss, Prod h ~ NP, HAp h) => proxy c -> (forall xs. All c xs => f xs -> f' xs) -> h f xss -> h f' xss
- hcliftA2' :: (All2 c xss, Prod h ~ NP, HAp h) => proxy c -> (forall xs. All c xs => f xs -> f' xs -> f'' xs) -> Prod h f xss -> h f' xss -> h f'' xss
- hcliftA3' :: (All2 c xss, Prod h ~ NP, HAp h) => proxy c -> (forall xs. All c xs => f xs -> f' xs -> f'' xs -> f''' xs) -> Prod h f xss -> Prod h f' xss -> h f'' xss -> h f''' xss
- cliftA2'_NP :: All2 c xss => proxy c -> (forall xs. All c xs => f xs -> g xs -> h xs) -> NP f xss -> NP g xss -> NP h xss
- collapse_NP :: NP (K a) xs -> [a]
- collapse_POP :: SListI xss => POP (K a) xss -> [[a]]
- sequence'_NP :: Applicative f => NP (f :.: g) xs -> f (NP g xs)
- sequence'_POP :: (SListI xss, Applicative f) => POP (f :.: g) xss -> f (POP g xss)
- sequence_NP :: (SListI xs, Applicative f) => NP f xs -> f (NP I xs)
- sequence_POP :: (All SListI xss, Applicative f) => POP f xss -> f (POP I xss)
- cata_NP :: forall r f xs. r '[] -> (forall y ys. f y -> r ys -> r (y ': ys)) -> NP f xs -> r xs
- ccata_NP :: forall c proxy r f xs. All c xs => proxy c -> r '[] -> (forall y ys. c y => f y -> r ys -> r (y ': ys)) -> NP f xs -> r xs
- ana_NP :: forall s f xs. SListI xs => (forall y ys. s (y ': ys) -> (f y, s ys)) -> s xs -> NP f xs
- cana_NP :: forall c proxy s f xs. All c xs => proxy c -> (forall y ys. c y => s (y ': ys) -> (f y, s ys)) -> s xs -> NP f xs

# Datatypes

data NP :: (k -> *) -> [k] -> * where #

An n-ary product.

The product is parameterized by a type constructor `f` and indexed by a type-level list `xs`. The length of the list determines the number of elements in the product, and if the `i`-th element of the list is of type `x`, then the `i`-th element of the product is of type `f x`.

The constructor names are chosen to resemble the names of the list constructors.

Two common instantiations of `f` are the identity functor `I` and the constant functor `K`. For `I`, the product becomes a heterogeneous list, where the type-level list describes the types of its components. For ``K` a`, the product becomes a homogeneous list, where the contents of the type-level list are ignored, but its length still specifies the number of elements.

In the context of the SOP approach to generic programming, an n-ary product describes the structure of the arguments of a single data constructor.

Examples:

    I 'x'    :* I True  :* Nil  ::  NP I       '[ Char, Bool ]
    K 0      :* K 1     :* Nil  ::  NP (K Int) '[ Char, Bool ]
    Just 'x' :* Nothing :* Nil  ::  NP Maybe   '[ Char, Bool ]

Constructors

Nil :: NP f '[] |
(:*) :: f x -> NP f xs -> NP f (x ': xs) infixr 5 |

Instances

HSequence [k] k (NP k) # |
Methods hsequence' :: (SListIN (NP k) k h xs, Applicative f) => h ((k :.: *) f g) xs -> f (h g xs) #
HCollapse [k] k (NP k) # |
Methods hcollapse :: SListIN (NP k) k h xs => h (K k a) xs -> CollapseTo (NP k) k h a #
HAp [k] k (NP k) # |
Methods hap :: Prod (NP k) k h ((k -.-> f) g) xs -> h f xs -> h g xs #
HPure [k] k (NP k) # |
Methods hpure :: SListIN (NP k) k h xs => (forall a. f a) -> h f xs # hcpure :: AllN (NP k) k h c xs => proxy c -> (forall a. c a => f a) -> h f xs #
All k (Compose * k Eq f) xs => Eq (NP k f xs) # |
Methods (==) :: NP k f xs -> NP k f xs -> Bool # (/=) :: NP k f xs -> NP k f xs -> Bool #
(All k (Compose * k Eq f) xs, All k (Compose * k Ord f) xs) => Ord (NP k f xs) # |
Methods compare :: NP k f xs -> NP k f xs -> Ordering # (<) :: NP k f xs -> NP k f xs -> Bool # (<=) :: NP k f xs -> NP k f xs -> Bool # (>) :: NP k f xs -> NP k f xs -> Bool # (>=) :: NP k f xs -> NP k f xs -> Bool # max :: NP k f xs -> NP k f xs -> NP k f xs # min :: NP k f xs -> NP k f xs -> NP k f xs #
All k (Compose * k Show f) xs => Show (NP k f xs) # |
Methods showsPrec :: Int -> NP k f xs -> ShowS # show :: NP k f xs -> String # showList :: [NP k f xs] -> ShowS #
All k (Compose * k NFData f) xs => NFData (NP k f xs) # | Since: 0.2.5.0
Methods rnf :: NP k f xs -> () #
type SListIN [k] k (NP k) # |
type SListIN [k] k (NP k) = SListI k
type UnProd [k] k (NP k) # |
type UnProd [k] k (NP k) = NS k
type Prod [k] k (NP k) # |
type Prod [k] k (NP k) = NP k
type AllN [k] k (NP k) c # |
type AllN [k] k (NP k) c = All k c
type CollapseTo [k] k (NP k) a # |
type CollapseTo [k] k (NP k) a = [a]

newtype POP f xss #

A product of products.

This is a 'newtype' for an `NP` of an `NP`. The elements of the inner products are applications of the parameter `f`. The type `POP` is indexed by the list of lists that determines the lengths of both the outer and all the inner products, as well as the types of all the elements of the inner products.

A `POP` is reminiscent of a two-dimensional table (but the inner lists can all be of different length). In the context of the SOP approach to generic programming, a `POP` is useful to represent information that is available for all arguments of all constructors of a datatype.

Constructors

POP (NP (NP f) xss) |

Instances

HSequence [[k]] k (POP k) # |
Methods hsequence' :: (SListIN (POP k) k h xs, Applicative f) => h ((k :.: *) f g) xs -> f (h g xs) #
HCollapse [[k]] k (POP k) # |
Methods hcollapse :: SListIN (POP k) k h xs => h (K k a) xs -> CollapseTo (POP k) k h a #
HAp [[k]] k (POP k) # |
Methods hap :: Prod (POP k) k h ((k -.-> f) g) xs -> h f xs -> h g xs #
HPure [[k]] k (POP k) # |
Methods hpure :: SListIN (POP k) k h xs => (forall a. f a) -> h f xs # hcpure :: AllN (POP k) k h c xs => proxy c -> (forall a. c a => f a) -> h f xs #
Eq (NP [k] (NP k f) xss) => Eq (POP k f xss) # |
Methods (==) :: POP k f xss -> POP k f xss -> Bool # (/=) :: POP k f xss -> POP k f xss -> Bool #
Ord (NP [k] (NP k f) xss) => Ord (POP k f xss) # |
Methods compare :: POP k f xss -> POP k f xss -> Ordering # (<) :: POP k f xss -> POP k f xss -> Bool # (<=) :: POP k f xss -> POP k f xss -> Bool # (>) :: POP k f xss -> POP k f xss -> Bool # (>=) :: POP k f xss -> POP k f xss -> Bool # max :: POP k f xss -> POP k f xss -> POP k f xss # min :: POP k f xss -> POP k f xss -> POP k f xss #
Show (NP [k] (NP k f) xss) => Show (POP k f xss) # |
Methods showsPrec :: Int -> POP k f xss -> ShowS # show :: POP k f xss -> String # showList :: [POP k f xss] -> ShowS #
NFData (NP [k] (NP k f) xss) => NFData (POP k f xss) # | Since: 0.2.5.0
Methods rnf :: POP k f xss -> () #
type SListIN [[k]] k (POP k) # |
type SListIN [[k]] k (POP k) = SListI2 k
type UnProd [[k]] k (POP k) # |
type UnProd [[k]] k (POP k) = SOP k
type Prod [[k]] k (POP k) # |
type Prod [[k]] k (POP k) = POP k
type AllN [[k]] k (POP k) c # |
type AllN [[k]] k (POP k) c = All2 k c
type CollapseTo [[k]] k (POP k) a # |
type CollapseTo [[k]] k (POP k) a = [[a]]

unPOP :: POP f xss -> NP (NP f) xss #

Unwrap a product of products.

# Constructing products

pure_NP :: forall f xs. SListI xs => (forall a. f a) -> NP f xs #

Specialization of `hpure`.

The call ``pure_NP` x` generates a product that contains `x` in every element position.

Example:

    >>> pure_NP [] :: NP [] '[Char, Bool]
    "" :* [] :* Nil
    >>> pure_NP (K 0) :: NP (K Int) '[Double, Int, String]
    K 0 :* K 0 :* K 0 :* Nil

pure_POP :: All SListI xss => (forall a. f a) -> POP f xss #

Specialization of `hpure`.

The call ``pure_POP` x` generates a product of products that contains `x` in every element position.

cpure_NP :: forall c xs proxy f. All c xs => proxy c -> (forall a. c a => f a) -> NP f xs #

Specialization of `hcpure`.

The call ``cpure_NP` p x` generates a product that contains `x` in every element position.

cpure_POP :: forall c xss proxy f. All2 c xss => proxy c -> (forall a. c a => f a) -> POP f xss #

Specialization of `hcpure`.

The call ``cpure_NP` p x` generates a product of products that contains `x` in every element position.

## Construction from a list

fromList :: SListI xs => [a] -> Maybe (NP (K a) xs) #

Construct a homogeneous n-ary product from a normal Haskell list.

Returns `Nothing` if the length of the list does not exactly match the expected size of the product.

# Application

ap_NP :: NP (f -.-> g) xs -> NP f xs -> NP g xs #

Specialization of `hap`.

Applies a product of (lifted) functions pointwise to a product of suitable arguments.

ap_POP :: POP (f -.-> g) xss -> POP f xss -> POP g xss #

Specialization of `hap`.

Applies a product of (lifted) functions pointwise to a product of suitable arguments.

# Destructing products

hd :: NP f (x ': xs) -> f x #

Obtain the head of an n-ary product.

Since: 0.2.1.0

tl :: NP f (x ': xs) -> NP f xs #

Obtain the tail of an n-ary product.

Since: 0.2.1.0

type Projection f xs = K (NP f xs) -.-> f #

The type of projections from an n-ary product.

projections :: forall xs f. SListI xs => NP (Projection f xs) xs #

Compute all projections from an n-ary product.

Each element of the resulting product contains one of the projections.

shiftProjection :: Projection f xs a -> Projection f (x ': xs) a #

# Lifting / mapping

liftA_NP :: SListI xs => (forall a. f a -> g a) -> NP f xs -> NP g xs #

Specialization of `hliftA`.

liftA_POP :: All SListI xss => (forall a. f a -> g a) -> POP f xss -> POP g xss #

Specialization of `hliftA`.

liftA2_NP :: SListI xs => (forall a. f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs #

Specialization of `hliftA2`.

liftA2_POP :: All SListI xss => (forall a. f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss #

Specialization of `hliftA2`.

liftA3_NP :: SListI xs => (forall a. f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs #

Specialization of `hliftA3`.

liftA3_POP :: All SListI xss => (forall a. f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss #

Specialization of `hliftA3`.

map_NP :: SListI xs => (forall a. f a -> g a) -> NP f xs -> NP g xs #

Specialization of `hmap`, which is equivalent to `hliftA`.

map_POP :: All SListI xss => (forall a. f a -> g a) -> POP f xss -> POP g xss #

Specialization of `hmap`, which is equivalent to `hliftA`.

zipWith_NP :: SListI xs => (forall a. f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs #

Specialization of `hzipWith`, which is equivalent to `hliftA2`.

zipWith_POP :: All SListI xss => (forall a. f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss #

Specialization of `hzipWith`, which is equivalent to `hliftA2`.

zipWith3_NP :: SListI xs => (forall a. f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs #

Specialization of `hzipWith3`, which is equivalent to `hliftA3`.

zipWith3_POP :: All SListI xss => (forall a. f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss #

Specialization of `hzipWith3`, which is equivalent to `hliftA3`.

cliftA_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a) -> NP f xs -> NP g xs #

Specialization of `hcliftA`.

cliftA_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a) -> POP f xss -> POP g xss #

Specialization of `hcliftA`.

cliftA2_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs #

Specialization of `hcliftA2`.

cliftA2_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss #

Specialization of `hcliftA2`.

cliftA3_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs #

Specialization of `hcliftA3`.

cliftA3_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss #

Specialization of `hcliftA3`.

cmap_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a) -> NP f xs -> NP g xs #

Specialization of `hcmap`, which is equivalent to `hcliftA`.

cmap_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a) -> POP f xss -> POP g xss #

Specialization of `hcmap`, which is equivalent to `hcliftA`.

czipWith_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs #

Specialization of `hczipWith`, which is equivalent to `hcliftA2`.

czipWith_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss #

Specialization of `hczipWith`, which is equivalent to `hcliftA2`.

czipWith3_NP :: All c xs => proxy c -> (forall a. c a => f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs #

Specialization of `hczipWith3`, which is equivalent to `hcliftA3`.

czipWith3_POP :: All2 c xss => proxy c -> (forall a. c a => f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss #

Specialization of `hczipWith3`, which is equivalent to `hcliftA3`.

# Dealing with ``All` c`

hcliftA' :: (All2 c xss, Prod h ~ NP, HAp h) => proxy c -> (forall xs. All c xs => f xs -> f' xs) -> h f xss -> h f' xss #

Deprecated: Use `hcliftA` or `hcmap` instead.

Lift a constrained function operating on a list-indexed structure to a function on a list-of-list-indexed structure.

This is a variant of `hcliftA`.

Specification:

    hcliftA' p f xs = hpure (fn_2 $ \ AllDictC -> f) ` hap ` allDict_NP p ` hap ` xs

Instances:

    hcliftA' :: All2 c xss => proxy c -> (forall xs. All c xs => f xs -> f' xs) -> NP f xss -> NP f' xss
    hcliftA' :: All2 c xss => proxy c -> (forall xs. All c xs => f xs -> f' xs) -> NS f xss -> NS f' xss

hcliftA2' :: (All2 c xss, Prod h ~ NP, HAp h) => proxy c -> (forall xs. All c xs => f xs -> f' xs -> f'' xs) -> Prod h f xss -> h f' xss -> h f'' xss #

Deprecated: Use `hcliftA2` or `hczipWith` instead.

Like `hcliftA'`, but for binary functions.

hcliftA3' :: (All2 c xss, Prod h ~ NP, HAp h) => proxy c -> (forall xs. All c xs => f xs -> f' xs -> f'' xs -> f''' xs) -> Prod h f xss -> Prod h f' xss -> h f'' xss -> h f''' xss #

Deprecated: Use `hcliftA3` or `hczipWith3` instead.

Like `hcliftA'`, but for ternay functions.

cliftA2'_NP :: All2 c xss => proxy c -> (forall xs. All c xs => f xs -> g xs -> h xs) -> NP f xss -> NP g xss -> NP h xss #

Deprecated: Use `cliftA2_NP` instead.

Specialization of `hcliftA2'`.

# Collapsing

collapse_NP :: NP (K a) xs -> [a] #

Specialization of `hcollapse`.

Example:

    >>> collapse_NP (K 1 :* K 2 :* K 3 :* Nil)
    [1,2,3]

collapse_POP :: SListI xss => POP (K a) xss -> [[a]] #

Specialization of `hcollapse`.

Example:

    >>> collapse_POP (POP ((K 'a' :* Nil) :* (K 'b' :* K 'c' :* Nil) :* Nil) :: POP (K Char) '[ '[(a :: *)], '[b, c] ])
    ["a", "bc"]

(The type signature is only necessary in this case to fix the kind of the type variables.)

# Sequencing

sequence'_NP :: Applicative f => NP (f :.: g) xs -> f (NP g xs) #

Specialization of `hsequence'`.

sequence'_POP :: (SListI xss, Applicative f) => POP (f :.: g) xss -> f (POP g xss) #

Specialization of `hsequence'`.

sequence_NP :: (SListI xs, Applicative f) => NP f xs -> f (NP I xs) #

Specialization of `hsequence`.

Example:

    >>> sequence_NP (Just 1 :* Just 2 :* Nil)
    Just (I 1 :* I 2 :* Nil)

sequence_POP :: (All SListI xss, Applicative f) => POP f xss -> f (POP I xss) #

Specialization of `hsequence`.

Example:

    >>> sequence_POP (POP ((Just 1 :* Nil) :* (Just 2 :* Just 3 :* Nil) :* Nil))
    Just (POP ((I 1 :* Nil) :* ((I 2 :* (I 3 :* Nil)) :* Nil)))

# Catamorphism and anamorphism

cata_NP :: forall r f xs. r '[] -> (forall y ys. f y -> r ys -> r (y ': ys)) -> NP f xs -> r xs #

Catamorphism for `NP`.

This is a suitable generalization of `foldr`. It takes parameters on what to do for `Nil` and `:*`. Since the input list is heterogeneous, the result is also indexed by a type-level list.

Since: 0.2.3.0

ccata_NP :: forall c proxy r f xs. All c xs => proxy c -> r '[] -> (forall y ys. c y => f y -> r ys -> r (y ': ys)) -> NP f xs -> r xs #

Constrained catamorphism for `NP`.

The difference compared to `cata_NP` is that the function for the cons-case can make use of the fact that the specified constraint holds for all the types in the signature of the product.

Since: 0.2.3.0

ana_NP :: forall s f xs. SListI xs => (forall y ys. s (y ': ys) -> (f y, s ys)) -> s xs -> NP f xs #

Anamorphism for `NP`.

In contrast to the anamorphism for normal lists, the generating function does not return an `Either`, but simply an element and a new seed value.

This is because the decision on whether to generate a `Nil` or a `:*` is determined by the types.

Since: 0.2.3.0

cana_NP :: forall c proxy s f xs. All c xs => proxy c -> (forall y ys. c y => s (y ': ys) -> (f y, s ys)) -> s xs -> NP f xs #

Constrained anamorphism for `NP`.

Compared to `ana_NP`, the generating function can make use of the specified constraint here for the elements that it generates.

Since: 0.2.3.0