{-# LANGUAGE PostfixOperators #-}
{-# OPTIONS_HADDOCK show-extensions, prune #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  ForSyDe.Atom.Skel
-- Copyright   :  (c) George Ungureanu, KTH/ICT/ESY 2015
-- License     :  BSD-style (see the file LICENSE)
-- 
-- Maintainer  :  ugeorge@kth.se
-- Stability   :  experimental
-- Portability :  portable
--
-- This module defines the Skeleton layer, and is concerned in modeling the aspects of
-- inherent potential for parallelism in CPS. Its formal foundation is the theory of
-- algorithmic skeletons <ForSyDe-Atom.html#skillicorn05 [Skillicorn05]>, and it
-- adapts it according to the atom approach. For more on our approach, and how it fits
-- into the layered framework, please consult
-- <ForSyDe-Atom.html#ungureanu20a [Ungureanu20a]>
--
-- This library is concerned in modeling the theoretical aspects as faithfully as
-- possible using a shallow DSL, and not necessarily reaping the benefits of
-- parallelization directly in simulations. The latter would require further
-- engineering and the modeling concepts are likely to be lost the process. Instead
-- most of the atom and pattern formulations in this module and sub-modules might not
-- be the most efficient implementations for the given functionality, but rather
-- expose the fundamental properties which can be further exploited in design
-- processes. Of these properties our special interest lies in the /factorization/
-- theorem (see <ForSyDe-Atom.html#skillicorn05 [Skillicorn05]>,
-- <ForSyDe-Atom.html#gorlatch03 [Gorlatch03]>), which sets the framework for any
-- skeleton to be further transformed into semantically-equivalent forms, more
-- appropriate for execution on various platforms.
--
-- Similar to other layer libraries, this module defines only atoms and patterns as
-- type class methods, i.e. "shells" which are not loaded with any semantics. It is
-- unlikely that the user will need this API, but rather load any of its sub-modules
-- directly:
--
-- * "ForSyDe.Atom.Skel.Vector" is a shallow interpretation of the /vector/
--   category, susceptible to algorithmic skeletons. It defines a large library of
--   patterns commonly used in designs.
--
-- * "ForSyDe.Atom.Skel.FastVector" is an un-official alternative to
--   "ForSyDe.Atom.Skel.Vector" meant for simulations of large data which is
--   likely to become too cumbersome. It /does not/ use atoms, but rather it wraps
--   native Haskell types into @newtype@ wrappers and uses "Prelude" functions
--   internally. The API tries to copy that of "ForSyDe.Atom.Skel.Vector" so that
--   switching betwen libraries can be made seamlessly just by changing the import.
-------------------------------------------------------------------------------

module ForSyDe.Atom.Skel (

  -- * Atoms
  
  Skeleton(..),

  -- * Skeleton constructors

  -- | Patterns of in the skeleton layer are provided, like all other patterns in
  -- ForSyDe-Atom, as constructors. If the layer below this one is the
  -- 'ForSyDe.Atom.MoC.MoC' layer, i.e. the functions taken as arguments are
  -- processes, then these skeletons can be regarded as process network constructors,
  -- as the structures created are process networks with inherent potential for
  -- parallel implementation.
  
  farm11, farm12, farm13, farm14,
  farm21, farm22, farm23, farm24,
  farm31, farm32, farm33, farm34,
  farm41, farm42, farm43, farm44,
  farm51, farm52, farm53, farm54,
  farm61, farm62, farm63, farm64,
  farm71, farm72, farm73, farm74,
  farm81, farm82, farm83, farm84,

  reduce, reducei, pipe,
  
  pipe1, pipe2, pipe3, pipe4,
  pipe5, pipe6, pipe7, pipe8,
  
  ) where

import ForSyDe.Atom.Utility.Tuple

infixl 4 =.=, =*=
infixl 2 =\=, =<<=

-- | Class containing all the Skeleton layer atoms.
--
-- This class is instantiated by a set of categorical types, i.e. types which describe
-- an inherent potential for being evaluated in parallel. Skeletons are patterns from
-- this layer. All skeletons can be described as composition of the three atoms
-- below. This possible due to an existing theorem in the categorical type theory,
-- also called the Bird-Merteens formalism:
--
-- #factorization#
--
-- [factorization] A function on a categorical type is an algorithmic skeleton
-- (i.e. catamorphism) /iff/ it can be represented in a factorized form, i.e. as a
-- /map/ composed with a /reduce/.
class Functor c => Skeleton c where
  -- | Atom which maps a function on each element of a structure
  -- (i.e. categorical type), defined as:
  --
  -- <<fig/eqs-skel-atom-dot.png>>
  --
  -- '=.=' together with '=*=' form the @map@ pattern.
  (=.=)  :: (a -> b) -> c a -> c b

  -- | Atom which applies the functions contained by as structure (i.e. categorical
  -- type), on the elements of another structure, defined as:
  --
  -- <<fig/eqs-skel-atom-star.png>>
  --
  -- '=.=' together with '=*=' form the @map@ pattern.
  (=*=)  :: c (a -> b) -> c a -> c b

  -- | Atom which reduces a structure to an element based on an /associative/
  -- function, defined as:
  --
  -- <<fig/eqs-skel-atom-red.png>>
  (=\=)  :: (a -> a -> a) -> c a -> a

  -- | Skeleton which /pipes/ an element through all the functions contained by a
  -- structure. This is not an atom. It has an implicit definition which might be
  -- augmented by instances of this class to include edge cases.
  --
  -- <<fig/eqs-skel-pattern-pipe.png>>
  --
  -- As the composition operation is not associative, we cannot treat @pipe@ as a true
  -- reduction. However it can still be exploited in parallel since it exposes another
  -- type of parallelism: time parallelism.
  (=<<=) :: c (a -> a)  -- ^ vector of functions
         -> a           -- ^ kernel element
         -> a           -- ^ result 
  (=<<=) ps :: c (a -> a)
ps = (a -> a) -> (a -> a) -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) ((a -> a) -> (a -> a) -> a -> a) -> c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => (a -> a -> a) -> c a -> a
=\= c (a -> a)
ps

            
  -- | Returns the first element in a structure. This is not an atom. It has an
  -- implicit definition which might be replaced by instances of this class with a
  -- more efficient implementation.
  --
  -- <<fig/eqs-skel-pattern-first.png>>
  first :: c a -> a
  first v :: c a
v = (\x :: a
x y :: a
y -> a
x) (a -> a -> a) -> c a -> a
forall (c :: * -> *) a. Skeleton c => (a -> a -> a) -> c a -> a
=\= c a
v

  -- | Returns the last element in a structure. This is not an atom. It has an
  -- implicit definition which might be replaced by instances of this class with a
  -- more efficient implementation.
  --
  -- <<fig/eqs-skel-pattern-last.png>>
  last :: c a -> a
  last v :: c a
v = (\x :: a
x y :: a
y -> a
y) (a -> a -> a) -> c a -> a
forall (c :: * -> *) a. Skeleton c => (a -> a -> a) -> c a -> a
=\= c a
v

--------------
-- PATTERNS --
--------------

-- | @farm@ maps a function on a vector. It is the embodiment of the
-- @map@ homomorphism, and its naming is inspired from the pattern
-- predominant in HPC. Indeed, if we consider the layer below as being
-- the 'ForSyDe.Atom.MoC.MoC' layer (i.e. the passed functions are
-- processes), the resulting structure could be regarded as a "farm of
-- data-parallel processes".
--
-- Constructors: @farm[1-8][1-4]@.
--
-- <<fig/eqs-skel-pattern-farm.png>>
-- <<fig/skel-pattern-farm.png>>
farm22 :: Skeleton c => (a1 -> a2 -> (b1, b2)) -> c a1 -> c a2 -> (c b1, c b2)
farm11 :: (a -> b) -> c a -> c b
farm11 p :: a -> b
p v1 :: c a
v1                      = (a -> b
p (a -> b) -> c a -> c b
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= c a
v1)
farm21 :: (a -> a -> b) -> c a -> c a -> c b
farm21 p :: a -> a -> b
p v1 :: c a
v1 v2 :: c a
v2                   = (a -> a -> b
p (a -> a -> b) -> c a -> c (a -> b)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= c a
v1 c (a -> b) -> c a -> c b
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v2)
farm31 :: (a -> a -> a -> b) -> c a -> c a -> c a -> c b
farm31 p :: a -> a -> a -> b
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3                = (a -> a -> a -> b
p (a -> a -> a -> b) -> c a -> c (a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= c a
v1 c (a -> a -> b) -> c a -> c (a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v2 c (a -> b) -> c a -> c b
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v3)
farm41 :: (a -> a -> a -> a -> b) -> c a -> c a -> c a -> c a -> c b
farm41 p :: a -> a -> a -> a -> b
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4             = (a -> a -> a -> a -> b
p (a -> a -> a -> a -> b) -> c a -> c (a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= c a
v1 c (a -> a -> a -> b) -> c a -> c (a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v2 c (a -> a -> b) -> c a -> c (a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v3 c (a -> b) -> c a -> c b
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v4)
farm51 :: (a -> a -> a -> a -> a -> b)
-> c a -> c a -> c a -> c a -> c a -> c b
farm51 p :: a -> a -> a -> a -> a -> b
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4 v5 :: c a
v5          = (a -> a -> a -> a -> a -> b
p (a -> a -> a -> a -> a -> b) -> c a -> c (a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= c a
v1 c (a -> a -> a -> a -> b) -> c a -> c (a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v2 c (a -> a -> a -> b) -> c a -> c (a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v3 c (a -> a -> b) -> c a -> c (a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v4 c (a -> b) -> c a -> c b
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v5)
farm61 :: (a -> a -> a -> a -> a -> a -> b)
-> c a -> c a -> c a -> c a -> c a -> c a -> c b
farm61 p :: a -> a -> a -> a -> a -> a -> b
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4 v5 :: c a
v5 v6 :: c a
v6       = (a -> a -> a -> a -> a -> a -> b
p (a -> a -> a -> a -> a -> a -> b)
-> c a -> c (a -> a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= c a
v1 c (a -> a -> a -> a -> a -> b) -> c a -> c (a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v2 c (a -> a -> a -> a -> b) -> c a -> c (a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v3 c (a -> a -> a -> b) -> c a -> c (a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v4 c (a -> a -> b) -> c a -> c (a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v5 c (a -> b) -> c a -> c b
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v6)
farm71 :: (a -> a -> a -> a -> a -> a -> a -> b)
-> c a -> c a -> c a -> c a -> c a -> c a -> c a -> c b
farm71 p :: a -> a -> a -> a -> a -> a -> a -> b
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4 v5 :: c a
v5 v6 :: c a
v6 v7 :: c a
v7    = (a -> a -> a -> a -> a -> a -> a -> b
p (a -> a -> a -> a -> a -> a -> a -> b)
-> c a -> c (a -> a -> a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= c a
v1 c (a -> a -> a -> a -> a -> a -> b)
-> c a -> c (a -> a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v2 c (a -> a -> a -> a -> a -> b) -> c a -> c (a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v3 c (a -> a -> a -> a -> b) -> c a -> c (a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v4 c (a -> a -> a -> b) -> c a -> c (a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v5 c (a -> a -> b) -> c a -> c (a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v6 c (a -> b) -> c a -> c b
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v7)
farm81 :: (a -> a -> a -> a -> a -> a -> a -> a -> b)
-> c a -> c a -> c a -> c a -> c a -> c a -> c a -> c a -> c b
farm81 p :: a -> a -> a -> a -> a -> a -> a -> a -> b
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4 v5 :: c a
v5 v6 :: c a
v6 v7 :: c a
v7 v8 :: c a
v8 = (a -> a -> a -> a -> a -> a -> a -> a -> b
p (a -> a -> a -> a -> a -> a -> a -> a -> b)
-> c a -> c (a -> a -> a -> a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= c a
v1 c (a -> a -> a -> a -> a -> a -> a -> b)
-> c a -> c (a -> a -> a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v2 c (a -> a -> a -> a -> a -> a -> b)
-> c a -> c (a -> a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v3 c (a -> a -> a -> a -> a -> b) -> c a -> c (a -> a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v4 c (a -> a -> a -> a -> b) -> c a -> c (a -> a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v5 c (a -> a -> a -> b) -> c a -> c (a -> a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v6 c (a -> a -> b) -> c a -> c (a -> b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v7 c (a -> b) -> c a -> c b
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a
v8)
farm12 :: (a -> (a1, b)) -> f a -> (f a1, f b)
farm12 p :: a -> (a1, b)
p v1 :: f a
v1                      = (a -> (a1, b)
p (a -> (a1, b)) -> f a -> f (a1, b)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
farm22 :: (a1 -> a2 -> (b1, b2)) -> c a1 -> c a2 -> (c b1, c b2)
farm22 p :: a1 -> a2 -> (b1, b2)
p v1 :: c a1
v1 v2 :: c a2
v2                   = (a1 -> a2 -> (b1, b2)
p (a1 -> a2 -> (b1, b2)) -> c a1 -> c (a2 -> (b1, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= c a1
v1 c (a2 -> (b1, b2)) -> c a2 -> c (b1, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= c a2
v2 c (b1, b2) -> (c b1, c b2)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
farm32 :: (a -> a -> a -> (a1, b)) -> f a -> f a -> f a -> (f a1, f b)
farm32 p :: a -> a -> a -> (a1, b)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3                = (a -> a -> a -> (a1, b)
p (a -> a -> a -> (a1, b)) -> f a -> f (a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> (a1, b)) -> f a -> f (a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> (a1, b)) -> f a -> f (a1, b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
farm42 :: (a -> a -> a -> a -> (a1, b))
-> f a -> f a -> f a -> f a -> (f a1, f b)
farm42 p :: a -> a -> a -> a -> (a1, b)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4             = (a -> a -> a -> a -> (a1, b)
p (a -> a -> a -> a -> (a1, b)) -> f a -> f (a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> (a1, b)) -> f a -> f (a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> (a1, b)) -> f a -> f (a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> (a1, b)) -> f a -> f (a1, b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
farm52 :: (a -> a -> a -> a -> a -> (a1, b))
-> f a -> f a -> f a -> f a -> f a -> (f a1, f b)
farm52 p :: a -> a -> a -> a -> a -> (a1, b)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5          = (a -> a -> a -> a -> a -> (a1, b)
p (a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> (a1, b)) -> f a -> f (a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> (a1, b)) -> f a -> f (a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> (a1, b)) -> f a -> f (a1, b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
farm62 :: (a -> a -> a -> a -> a -> a -> (a1, b))
-> f a -> f a -> f a -> f a -> f a -> f a -> (f a1, f b)
farm62 p :: a -> a -> a -> a -> a -> a -> (a1, b)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5 v6 :: f a
v6       = (a -> a -> a -> a -> a -> a -> (a1, b)
p (a -> a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> a -> (a1, b)) -> f a -> f (a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> a -> (a1, b)) -> f a -> f (a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> (a1, b)) -> f a -> f (a1, b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v6 f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
farm72 :: (a -> a -> a -> a -> a -> a -> a -> (a1, b))
-> f a -> f a -> f a -> f a -> f a -> f a -> f a -> (f a1, f b)
farm72 p :: a -> a -> a -> a -> a -> a -> a -> (a1, b)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5 v6 :: f a
v6 v7 :: f a
v7    = (a -> a -> a -> a -> a -> a -> a -> (a1, b)
p (a -> a -> a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> a -> a -> (a1, b)) -> f a -> f (a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> a -> (a1, b)) -> f a -> f (a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v6 f (a -> (a1, b)) -> f a -> f (a1, b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v7 f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
farm82 :: (a -> a -> a -> a -> a -> a -> a -> a -> (a1, b))
-> f a
-> f a
-> f a
-> f a
-> f a
-> f a
-> p
-> f a
-> (f a1, f b)
farm82 p :: a -> a -> a -> a -> a -> a -> a -> a -> (a1, b)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5 v6 :: f a
v6 v7 :: p
v7 v8 :: f a
v8 = (a -> a -> a -> a -> a -> a -> a -> a -> (a1, b)
p (a -> a -> a -> a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> a -> a -> a -> (a1, b))
-> f a -> f (a -> a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> a -> a -> (a1, b)) -> f a -> f (a -> a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v6 f (a -> a -> (a1, b)) -> f a -> f (a -> (a1, b))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> (a1, b)) -> f a -> f (a1, b)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v8 f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
farm13 :: (a -> (a, b1, b2)) -> f a -> (f a, f b1, f b2)
farm13 p :: a -> (a, b1, b2)
p v1 :: f a
v1                      = (a -> (a, b1, b2)
p (a -> (a, b1, b2)) -> f a -> f (a, b1, b2)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a, b1, b2) -> (f a, f b1, f b2)
forall (f :: * -> *) a b1 b2.
Functor f =>
f (a, b1, b2) -> (f a, f b1, f b2)
|<<)
farm23 :: (a -> a -> (a, b1, b2)) -> f a -> f a -> (f a, f b1, f b2)
farm23 p :: a -> a -> (a, b1, b2)
p v1 :: f a
v1 v2 :: f a
v2                   = (a -> a -> (a, b1, b2)
p (a -> a -> (a, b1, b2)) -> f a -> f (a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> (a, b1, b2)) -> f a -> f (a, b1, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a, b1, b2) -> (f a, f b1, f b2)
forall (f :: * -> *) a b1 b2.
Functor f =>
f (a, b1, b2) -> (f a, f b1, f b2)
|<<)
farm33 :: (a -> a -> a -> (a, b1, b2))
-> f a -> f a -> f a -> (f a, f b1, f b2)
farm33 p :: a -> a -> a -> (a, b1, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3                = (a -> a -> a -> (a, b1, b2)
p (a -> a -> a -> (a, b1, b2)) -> f a -> f (a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> (a, b1, b2)) -> f a -> f (a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> (a, b1, b2)) -> f a -> f (a, b1, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a, b1, b2) -> (f a, f b1, f b2)
forall (f :: * -> *) a b1 b2.
Functor f =>
f (a, b1, b2) -> (f a, f b1, f b2)
|<<)
farm43 :: (a -> a -> a -> a -> (a, b1, b2))
-> f a -> f a -> f a -> f a -> (f a, f b1, f b2)
farm43 p :: a -> a -> a -> a -> (a, b1, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4             = (a -> a -> a -> a -> (a, b1, b2)
p (a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> (a, b1, b2)) -> f a -> f (a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> (a, b1, b2)) -> f a -> f (a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> (a, b1, b2)) -> f a -> f (a, b1, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a, b1, b2) -> (f a, f b1, f b2)
forall (f :: * -> *) a b1 b2.
Functor f =>
f (a, b1, b2) -> (f a, f b1, f b2)
|<<)
farm53 :: (a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f a -> f a -> f a -> f a -> (f a, f b1, f b2)
farm53 p :: a -> a -> a -> a -> a -> (a, b1, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5          = (a -> a -> a -> a -> a -> (a, b1, b2)
p (a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> (a, b1, b2)) -> f a -> f (a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> (a, b1, b2)) -> f a -> f (a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> (a, b1, b2)) -> f a -> f (a, b1, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a, b1, b2) -> (f a, f b1, f b2)
forall (f :: * -> *) a b1 b2.
Functor f =>
f (a, b1, b2) -> (f a, f b1, f b2)
|<<)
farm63 :: (a -> a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f a -> f a -> f a -> f a -> f a -> (f a, f b1, f b2)
farm63 p :: a -> a -> a -> a -> a -> a -> (a, b1, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5 v6 :: f a
v6       = (a -> a -> a -> a -> a -> a -> (a, b1, b2)
p (a -> a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> a -> (a, b1, b2)) -> f a -> f (a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> a -> (a, b1, b2)) -> f a -> f (a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> (a, b1, b2)) -> f a -> f (a, b1, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v6 f (a, b1, b2) -> (f a, f b1, f b2)
forall (f :: * -> *) a b1 b2.
Functor f =>
f (a, b1, b2) -> (f a, f b1, f b2)
|<<)
farm73 :: (a -> a -> a -> a -> a -> a -> a -> (a, b1, b2))
-> f a
-> f a
-> f a
-> f a
-> f a
-> f a
-> f a
-> (f a, f b1, f b2)
farm73 p :: a -> a -> a -> a -> a -> a -> a -> (a, b1, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5 v6 :: f a
v6 v7 :: f a
v7    = (a -> a -> a -> a -> a -> a -> a -> (a, b1, b2)
p (a -> a -> a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> a -> a -> (a, b1, b2)) -> f a -> f (a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> a -> (a, b1, b2)) -> f a -> f (a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v6 f (a -> (a, b1, b2)) -> f a -> f (a, b1, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v7 f (a, b1, b2) -> (f a, f b1, f b2)
forall (f :: * -> *) a b1 b2.
Functor f =>
f (a, b1, b2) -> (f a, f b1, f b2)
|<<)
farm83 :: (a -> a -> a -> a -> a -> a -> a -> a -> (a, b1, b2))
-> f a
-> f a
-> f a
-> f a
-> f a
-> f a
-> p
-> f a
-> (f a, f b1, f b2)
farm83 p :: a -> a -> a -> a -> a -> a -> a -> a -> (a, b1, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5 v6 :: f a
v6 v7 :: p
v7 v8 :: f a
v8 = (a -> a -> a -> a -> a -> a -> a -> a -> (a, b1, b2)
p (a -> a -> a -> a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> a -> a -> a -> (a, b1, b2))
-> f a -> f (a -> a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> a -> a -> (a, b1, b2)) -> f a -> f (a -> a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v6 f (a -> a -> (a, b1, b2)) -> f a -> f (a -> (a, b1, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> (a, b1, b2)) -> f a -> f (a, b1, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v8 f (a, b1, b2) -> (f a, f b1, f b2)
forall (f :: * -> *) a b1 b2.
Functor f =>
f (a, b1, b2) -> (f a, f b1, f b2)
|<<)
farm14 :: (a -> (a, b1, c, b2)) -> f a -> (f a, f b1, f c, f b2)
farm14 p :: a -> (a, b1, c, b2)
p v1 :: f a
v1                      = (a -> (a, b1, c, b2)
p (a -> (a, b1, c, b2)) -> f a -> f (a, b1, c, b2)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
forall (f :: * -> *) a b1 c b2.
Functor f =>
f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
|<<<)
farm24 :: (a -> a -> (a, b1, c, b2)) -> f a -> f a -> (f a, f b1, f c, f b2)
farm24 p :: a -> a -> (a, b1, c, b2)
p v1 :: f a
v1 v2 :: f a
v2                   = (a -> a -> (a, b1, c, b2)
p (a -> a -> (a, b1, c, b2)) -> f a -> f (a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> (a, b1, c, b2)) -> f a -> f (a, b1, c, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
forall (f :: * -> *) a b1 c b2.
Functor f =>
f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
|<<<)
farm34 :: (a -> a -> a -> (a, b1, c, b2))
-> f a -> f a -> f a -> (f a, f b1, f c, f b2)
farm34 p :: a -> a -> a -> (a, b1, c, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3                = (a -> a -> a -> (a, b1, c, b2)
p (a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> (a, b1, c, b2)) -> f a -> f (a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> (a, b1, c, b2)) -> f a -> f (a, b1, c, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
forall (f :: * -> *) a b1 c b2.
Functor f =>
f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
|<<<)
farm44 :: (a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f a -> f a -> f a -> (f a, f b1, f c, f b2)
farm44 p :: a -> a -> a -> a -> (a, b1, c, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4             = (a -> a -> a -> a -> (a, b1, c, b2)
p (a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> (a, b1, c, b2)) -> f a -> f (a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> (a, b1, c, b2)) -> f a -> f (a, b1, c, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
forall (f :: * -> *) a b1 c b2.
Functor f =>
f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
|<<<)
farm54 :: (a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f a -> f a -> f a -> f a -> (f a, f b1, f c, f b2)
farm54 p :: a -> a -> a -> a -> a -> (a, b1, c, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5          = (a -> a -> a -> a -> a -> (a, b1, c, b2)
p (a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> (a, b1, c, b2)) -> f a -> f (a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> (a, b1, c, b2)) -> f a -> f (a, b1, c, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
forall (f :: * -> *) a b1 c b2.
Functor f =>
f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
|<<<)
farm64 :: (a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f a -> f a -> f a -> f a -> f a -> (f a, f b1, f c, f b2)
farm64 p :: a -> a -> a -> a -> a -> a -> (a, b1, c, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5 v6 :: f a
v6       = (a -> a -> a -> a -> a -> a -> (a, b1, c, b2)
p (a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> a -> (a, b1, c, b2)) -> f a -> f (a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> (a, b1, c, b2)) -> f a -> f (a, b1, c, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v6 f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
forall (f :: * -> *) a b1 c b2.
Functor f =>
f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
|<<<)
farm74 :: (a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a
-> f a
-> f a
-> f a
-> f a
-> f a
-> f a
-> (f a, f b1, f c, f b2)
farm74 p :: a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5 v6 :: f a
v6 v7 :: f a
v7    = (a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2)
p (a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> a -> (a, b1, c, b2)) -> f a -> f (a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v6 f (a -> (a, b1, c, b2)) -> f a -> f (a, b1, c, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v7 f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
forall (f :: * -> *) a b1 c b2.
Functor f =>
f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
|<<<)
farm84 :: (a -> a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a
-> f a
-> f a
-> f a
-> f a
-> f a
-> f a
-> f a
-> (f a, f b1, f c, f b2)
farm84 p :: a -> a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2)
p v1 :: f a
v1 v2 :: f a
v2 v3 :: f a
v3 v4 :: f a
v4 v5 :: f a
v5 v6 :: f a
v6 v7 :: f a
v7 v8 :: f a
v8 = (a -> a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2)
p (a -> a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
=.= f a
v1 f (a -> a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v2 f (a -> a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v3 f (a -> a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v4 f (a -> a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v5 f (a -> a -> a -> (a, b1, c, b2))
-> f a -> f (a -> a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v6 f (a -> a -> (a, b1, c, b2)) -> f a -> f (a -> (a, b1, c, b2))
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v7 f (a -> (a, b1, c, b2)) -> f a -> f (a, b1, c, b2)
forall (c :: * -> *) a b. Skeleton c => c (a -> b) -> c a -> c b
=*= f a
v8 f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
forall (f :: * -> *) a b1 c b2.
Functor f =>
f (a, b1, c, b2) -> (f a, f b1, f c, f b2)
|<<<)

-- | Infix name for the '=\=' atom operator.
--
-- (*) if the operation is not associative then the network can be
-- treated like a pipeline.
reduce :: Skeleton c
       => (a -> a -> a) -- ^ associative function (*)
       -> c a           -- ^ structure
       -> a             -- ^ reduced element
reduce :: (a -> a -> a) -> c a -> a
reduce = (a -> a -> a) -> c a -> a
forall (c :: * -> *) a. Skeleton c => (a -> a -> a) -> c a -> a
(=\=)

-- | 'reducei' is special case of 'reduce' where an initial element is
-- specified outside the reduced vector. It is implemented as a
-- 'pipe' with switched arguments, and the reduction function is
-- constrained to be associative. It is semantically equivalent to the
-- pattern depicted below.
--
-- (*) if the operation is not associative then the network is
-- semantically equivalent to @pipe1@ (see 'pipe2').
--
-- <<fig/eqs-skel-pattern-reducei.png>>
-- <<fig/skel-pattern-reducei.png>>
reducei :: Skeleton c
        => (a -> a -> a) -- ^ associative function (*)
        -> a             -- ^ initial element of structure
        -> c a           -- ^ structure
        -> a             -- ^ reduced element
reducei :: (a -> a -> a) -> a -> c a -> a
reducei p :: a -> a -> a
p i :: a
i v :: c a
v = (a -> a -> a) -> c a -> c (a -> a)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
farm11 a -> a -> a
p c a
v c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
=<<= a
i  


-- | Infix name for the '=<<=' skeleton operator.
pipe :: Skeleton c
     => c (a -> a)  -- ^ vector of functions
     -> a           -- ^ kernel element
     -> a           -- ^ result 
pipe :: c (a -> a) -> a -> a
pipe = c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
(=<<=)

-- | The @pipe@ constructors are a more generic form of the '=<<='
-- ('pipe') skeleton apt for successive partial application and create
-- more robust parameterizable pipeline networks.
--
-- Constructors: @comb[1-8]@.
--
-- <<fig/eqs-skel-pattern-pipe1.png>>
-- <<fig/skel-pattern-pipe1.png>>
pipe2 :: Skeleton c
      => (a1 -> a2 -> a -> a)
      -> c a1 -> c a2
      -> a -> a
pipe1 :: (a -> a -> a) -> c a -> a -> a
pipe1 p :: a -> a -> a
p v1 :: c a
v1 s :: a
s                      = (a -> a -> a) -> c a -> c (a -> a)
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
farm11 a -> a -> a
p c a
v1 c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
=<<= a
s
pipe2 :: (a1 -> a2 -> a -> a) -> c a1 -> c a2 -> a -> a
pipe2 p :: a1 -> a2 -> a -> a
p v1 :: c a1
v1 v2 :: c a2
v2 s :: a
s                   = (a1 -> a2 -> a -> a) -> c a1 -> c a2 -> c (a -> a)
forall (c :: * -> *) a a b.
Skeleton c =>
(a -> a -> b) -> c a -> c a -> c b
farm21 a1 -> a2 -> a -> a
p c a1
v1 c a2
v2 c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
=<<= a
s
pipe3 :: (a -> a -> a -> a -> a) -> c a -> c a -> c a -> a -> a
pipe3 p :: a -> a -> a -> a -> a
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 s :: a
s                = (a -> a -> a -> a -> a) -> c a -> c a -> c a -> c (a -> a)
forall (c :: * -> *) a a a b.
Skeleton c =>
(a -> a -> a -> b) -> c a -> c a -> c a -> c b
farm31 a -> a -> a -> a -> a
p c a
v1 c a
v2 c a
v3 c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
=<<= a
s
pipe4 :: (a -> a -> a -> a -> a -> a) -> c a -> c a -> c a -> c a -> a -> a
pipe4 p :: a -> a -> a -> a -> a -> a
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4 s :: a
s             = (a -> a -> a -> a -> a -> a)
-> c a -> c a -> c a -> c a -> c (a -> a)
forall (c :: * -> *) a a a a b.
Skeleton c =>
(a -> a -> a -> a -> b) -> c a -> c a -> c a -> c a -> c b
farm41 a -> a -> a -> a -> a -> a
p c a
v1 c a
v2 c a
v3 c a
v4 c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
=<<= a
s
pipe5 :: (a -> a -> a -> a -> a -> a -> a)
-> c a -> c a -> c a -> c a -> c a -> a -> a
pipe5 p :: a -> a -> a -> a -> a -> a -> a
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4 v5 :: c a
v5 s :: a
s          = (a -> a -> a -> a -> a -> a -> a)
-> c a -> c a -> c a -> c a -> c a -> c (a -> a)
forall (c :: * -> *) a a a a a b.
Skeleton c =>
(a -> a -> a -> a -> a -> b)
-> c a -> c a -> c a -> c a -> c a -> c b
farm51 a -> a -> a -> a -> a -> a -> a
p c a
v1 c a
v2 c a
v3 c a
v4 c a
v5 c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
=<<= a
s
pipe6 :: (a -> a -> a -> a -> a -> a -> a -> a)
-> c a -> c a -> c a -> c a -> c a -> c a -> a -> a
pipe6 p :: a -> a -> a -> a -> a -> a -> a -> a
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4 v5 :: c a
v5 v6 :: c a
v6 s :: a
s       = (a -> a -> a -> a -> a -> a -> a -> a)
-> c a -> c a -> c a -> c a -> c a -> c a -> c (a -> a)
forall (c :: * -> *) a a a a a a b.
Skeleton c =>
(a -> a -> a -> a -> a -> a -> b)
-> c a -> c a -> c a -> c a -> c a -> c a -> c b
farm61 a -> a -> a -> a -> a -> a -> a -> a
p c a
v1 c a
v2 c a
v3 c a
v4 c a
v5 c a
v6 c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
=<<= a
s
pipe7 :: (a -> a -> a -> a -> a -> a -> a -> a -> a)
-> c a -> c a -> c a -> c a -> c a -> c a -> c a -> a -> a
pipe7 p :: a -> a -> a -> a -> a -> a -> a -> a -> a
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4 v5 :: c a
v5 v6 :: c a
v6 v7 :: c a
v7 s :: a
s    = (a -> a -> a -> a -> a -> a -> a -> a -> a)
-> c a -> c a -> c a -> c a -> c a -> c a -> c a -> c (a -> a)
forall (c :: * -> *) a a a a a a a b.
Skeleton c =>
(a -> a -> a -> a -> a -> a -> a -> b)
-> c a -> c a -> c a -> c a -> c a -> c a -> c a -> c b
farm71 a -> a -> a -> a -> a -> a -> a -> a -> a
p c a
v1 c a
v2 c a
v3 c a
v4 c a
v5 c a
v6 c a
v7 c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
=<<= a
s
pipe8 :: (a -> a -> a -> a -> a -> a -> a -> a -> a -> a)
-> c a -> c a -> c a -> c a -> c a -> c a -> c a -> c a -> a -> a
pipe8 p :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a
p v1 :: c a
v1 v2 :: c a
v2 v3 :: c a
v3 v4 :: c a
v4 v5 :: c a
v5 v6 :: c a
v6 v7 :: c a
v7 v8 :: c a
v8 s :: a
s = (a -> a -> a -> a -> a -> a -> a -> a -> a -> a)
-> c a
-> c a
-> c a
-> c a
-> c a
-> c a
-> c a
-> c a
-> c (a -> a)
forall (c :: * -> *) a a a a a a a a b.
Skeleton c =>
(a -> a -> a -> a -> a -> a -> a -> a -> b)
-> c a -> c a -> c a -> c a -> c a -> c a -> c a -> c a -> c b
farm81 a -> a -> a -> a -> a -> a -> a -> a -> a -> a
p c a
v1 c a
v2 c a
v3 c a
v4 c a
v5 c a
v6 c a
v7 c a
v8 c (a -> a) -> a -> a
forall (c :: * -> *) a. Skeleton c => c (a -> a) -> a -> a
=<<= a
s