{-# LANGUAGE CPP                   #-}
{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE DeriveDataTypeable    #-}
{-# LANGUAGE DeriveFoldable        #-}
{-# LANGUAGE DeriveFunctor         #-}
{-# LANGUAGE DeriveTraversable     #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE GADTs                 #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PatternSynonyms       #-}
{-# LANGUAGE PolyKinds             #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE StandaloneDeriving    #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE TypeOperators         #-}
{-# LANGUAGE UndecidableInstances  #-}
{-# LANGUAGE ViewPatterns          #-}
-- |
-- Generic API for vectors with fixed length.
--
-- For encoding of vector size library uses Peano naturals defined in
-- the library. At come point in the future it would make sense to
-- switch to new GHC type level numerals.
--
-- [@Common pitfalls@]
--
-- Library provide instances for tuples. But there's a catch. Tuples
-- are monomorphic in element type. Let consider 2-tuple @(Int,Int)@.
-- Vector type @v@ is @(,) Int@ and only allowed element type is
-- @Int@.  Because of that we cannot change element type and following
-- code will fail:
--
-- > >>> map (== 1) ((1,2) :: (Int,Int))
-- >
-- > <interactive>:3:1:
-- >     Couldn't match type `Int' with `Bool'
-- >     In the expression: F.map (== 1) ((1, 2) :: (Int, Int))
-- >     In an equation for `it': it = map (== 1) ((1, 2) :: (Int, Int))
--
-- To make it work we need to change vector type as well. Functions
-- from module "Data.Vector.Fixed.Generic" provide this functionality.
--
-- > >>> map (== 1) ((1,2) :: (Int,Int)) :: (Bool,Bool)
-- > (True,False)
module Data.Vector.Fixed (
    -- * Vector type class
    -- ** Vector size
    Dim
    -- ** Type class
  , Vector(..)
  , VectorN
  , Arity
  , Fun(..)
  , length
    -- * Constructors
    -- $construction
    -- ** Small dimensions
    -- $smallDim
  , mk0
  , mk1
  , mk2
  , mk3
  , mk4
  , mk5
  , mk6
  , mk7
  , mk8
  , mkN
    -- ** Pattern for low-dimension vectors
  , pattern V2
  , pattern V3
  , pattern V4
    -- ** Continuation-based vectors
  , ContVec
  , empty
  , vector
  , C.cvec
    -- ** Functions
  , replicate
  , replicateM
  , generate
  , generateM
  , unfoldr
  , basis
    -- * Modifying vectors
    -- ** Transformations
  , head
  , tail
  , cons
  , snoc
  , concat
  , reverse
    -- ** Indexing & lenses
  -- , C.Index
  , (!)
  , index
  , set
  , element
  , elementTy
    -- ** Comparison
  , eq
  , ord
    -- ** Maps
  , map
  , mapM
  , mapM_
  , imap
  , imapM
  , imapM_
  , scanl
  , scanl1
  , sequence
  , sequence_
  , sequenceA
  , traverse
  , distribute
  , collect
    -- * Folding
  , foldl
  , foldr
  , foldl1
  , fold
  , foldMap
  , ifoldl
  , ifoldr
  , foldM
  , ifoldM
    -- ** Special folds
  , sum
  , maximum
  , minimum
  , and
  , or
  , all
  , any
  , find
    -- * Zips
  , zipWith
  , zipWith3
  , zipWithM
  , zipWithM_
  , izipWith
  , izipWith3
  , izipWithM
  , izipWithM_
    -- * Storable methods
    -- $storable
  , defaultAlignemnt
  , defaultSizeOf
  , defaultPeek
  , defaultPoke
    -- * NFData
  , defaultRnf
    -- * Conversion
  , convert
  , toList
  , fromList
  , fromList'
  , fromListM
  , fromFoldable
    -- * Data types
  , VecList(..)
  , VecPeano(..)
  , Only(..)
  , Empty(..)
    -- ** Tuple synonyms
  , Tuple2
  , Tuple3
  , Tuple4
  , Tuple5
  ) where

import Control.Applicative (Applicative(..),(<$>))
import Control.DeepSeq     (NFData(..))
import Data.Data           (Typeable,Data)
import Data.Monoid         (Monoid(..))
import Data.Semigroup      (Semigroup(..))
import qualified Data.Foldable    as F
import qualified Data.Traversable as T
import Foreign.Storable (Storable(..))
import Foreign.Ptr      (castPtr)
import GHC.TypeLits

import Data.Vector.Fixed.Cont     (Vector(..),VectorN,Dim,length,ContVec,PeanoNum(..),
                                   vector,empty,Arity,Fun(..),accum,apply,vector)
import qualified Data.Vector.Fixed.Cont as C
import Data.Vector.Fixed.Internal

import Prelude (Show(..),Eq(..),Ord(..),Functor(..),id,(.),($),undefined)


-- $construction
--
-- There are several ways to construct fixed vectors except using
-- their constructor if it's available. For small ones it's possible
-- to use functions 'mk1', 'mk2', etc.
--
-- >>> mk3 'a' 'b' 'c' :: (Char,Char,Char)
-- ('a','b','c')
--
-- Alternatively one could use 'mkN'. See its documentation for
-- examples.
--
-- Another option is to create tuple and 'convert' it to desired
-- vector type. For example:
--
-- > v = convert (x,y,z)
--
-- It will work on if type of @v@ is know from elsewhere. Same trick
-- could be used to pattern match on the vector with opaque
-- representation using view patterns
--
-- > function :: Vec N3 Double -> ...
-- > function (convert -> (x,y,z)) = ...
--
-- For small vectors pattern synonyms @V2@, @V3$, @V4@ are provided
-- that use same trick internally.


-- $smallDim
--
-- Constructors for vectors with small dimensions.


-- $storable
--
-- Default implementation of methods for Storable type class assumes
-- that individual elements of vector are stored as N-element array.



-- | Type-based vector with statically known length parametrized by
--   GHC's type naturals
newtype VecList (n :: Nat) a = VecList (VecPeano (C.Peano n) a)

-- | Standard GADT-based vector with statically known length
--   parametrized by Peano numbers.
data VecPeano (n :: PeanoNum) a where
  Nil  :: VecPeano 'Z a
  Cons :: a -> VecPeano n a -> VecPeano ('S n) a
  deriving (Typeable)

instance (Arity n, NFData a) => NFData (VecList n a) where
  rnf :: VecList n a -> ()
rnf = VecList n a -> ()
forall a (v :: * -> *). (NFData a, Vector v a) => v a -> ()
defaultRnf
  {-# INLINE rnf #-}

type instance Dim (VecList n) = n

instance Arity n => Vector (VecList n) a where
  construct :: Fun (Peano (Dim (VecList n))) a (VecList n a)
construct = (VecPeano (Peano n) a -> VecList n a)
-> Fun (Peano n) a (VecPeano (Peano n) a)
-> Fun (Peano n) a (VecList n a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap VecPeano (Peano n) a -> VecList n a
forall (n :: Nat) a. VecPeano (Peano n) a -> VecList n a
VecList (Fun (Peano n) a (VecPeano (Peano n) a)
 -> Fun (Peano n) a (VecList n a))
-> Fun (Peano n) a (VecPeano (Peano n) a)
-> Fun (Peano n) a (VecList n a)
forall a b. (a -> b) -> a -> b
$ (forall (k :: PeanoNum).
 T_List a (Peano n) ('S k) -> a -> T_List a (Peano n) k)
-> (T_List a (Peano n) 'Z -> VecPeano (Peano n) a)
-> T_List a (Peano n) (Peano n)
-> Fun (Peano n) a (VecPeano (Peano n) a)
forall (n :: PeanoNum) (t :: PeanoNum -> *) a b.
ArityPeano n =>
(forall (k :: PeanoNum). t ('S k) -> a -> t k)
-> (t 'Z -> b) -> t n -> Fun n a b
accum
    (\(T_List f) a
a -> (VecPeano k a -> VecPeano (Peano n) a) -> T_List a (Peano n) k
forall a (n :: PeanoNum) (k :: PeanoNum).
(VecPeano k a -> VecPeano n a) -> T_List a n k
T_List (VecPeano ('S k) a -> VecPeano (Peano n) a
f (VecPeano ('S k) a -> VecPeano (Peano n) a)
-> (VecPeano k a -> VecPeano ('S k) a)
-> VecPeano k a
-> VecPeano (Peano n) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> VecPeano k a -> VecPeano ('S k) a
forall a (n :: PeanoNum). a -> VecPeano n a -> VecPeano ('S n) a
Cons a
a))
    (\(T_List VecPeano 'Z a -> VecPeano (Peano n) a
f)   -> VecPeano 'Z a -> VecPeano (Peano n) a
f VecPeano 'Z a
forall a. VecPeano 'Z a
Nil)
    ((VecPeano (Peano n) a -> VecPeano (Peano n) a)
-> T_List a (Peano n) (Peano n)
forall a (n :: PeanoNum) (k :: PeanoNum).
(VecPeano k a -> VecPeano n a) -> T_List a n k
T_List VecPeano (Peano n) a -> VecPeano (Peano n) a
forall a. a -> a
id :: T_List a (C.Peano n) (C.Peano n))
  inspect :: VecList n a -> Fun (Peano (Dim (VecList n))) a b -> b
inspect (VecList VecPeano (Peano n) a
v)
    = ContVec n a -> Fun (Peano (Dim (ContVec n))) a b -> b
forall (v :: * -> *) a b.
Vector v a =>
v a -> Fun (Peano (Dim v)) a b -> b
inspect ((forall (k :: PeanoNum).
 Flip VecPeano a ('S k) -> (a, Flip VecPeano a k))
-> Flip VecPeano a (Peano n) -> ContVec n a
forall (n :: Nat) (t :: PeanoNum -> *) a.
Arity n =>
(forall (k :: PeanoNum). t ('S k) -> (a, t k))
-> t (Peano n) -> ContVec n a
apply forall (k :: PeanoNum).
Flip VecPeano a ('S k) -> (a, Flip VecPeano a k)
step (VecPeano (Peano n) a -> Flip VecPeano a (Peano n)
forall k k (f :: k -> k -> *) (a :: k) (n :: k).
f n a -> Flip f a n
Flip VecPeano (Peano n) a
v) :: C.ContVec n a)
    where
      step :: Flip VecPeano a ('S k)  -> (a, Flip VecPeano a k)
      step :: Flip VecPeano a ('S k) -> (a, Flip VecPeano a k)
step (Flip (Cons a
a VecPeano n a
xs)) = (a
a, VecPeano n a -> Flip VecPeano a n
forall k k (f :: k -> k -> *) (a :: k) (n :: k).
f n a -> Flip f a n
Flip VecPeano n a
xs)
  {-# INLINE construct #-}
  {-# INLINE inspect   #-}
instance Arity n => VectorN VecList n a

newtype Flip f a n = Flip (f n a)
newtype T_List a n k = T_List (VecPeano k a -> VecPeano n a)


-- Standard instances
instance (Show a, Arity n) => Show (VecList n a) where
  show :: VecList n a -> String
show = [a] -> String
forall a. Show a => a -> String
show ([a] -> String) -> (VecList n a -> [a]) -> VecList n a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> [a] -> [a]) -> [a] -> VecList n a -> [a]
forall (v :: * -> *) a b.
Vector v a =>
(a -> b -> b) -> b -> v a -> b
foldr (:) []
instance (Eq a, Arity n) => Eq (VecList n a) where
  == :: VecList n a -> VecList n a -> Bool
(==) = VecList n a -> VecList n a -> Bool
forall (v :: * -> *) a. (Vector v a, Eq a) => v a -> v a -> Bool
eq
instance (Ord a, Arity n) => Ord (VecList n a) where
  compare :: VecList n a -> VecList n a -> Ordering
compare = VecList n a -> VecList n a -> Ordering
forall (v :: * -> *) a.
(Vector v a, Ord a) =>
v a -> v a -> Ordering
ord
instance Arity n => Functor (VecList n) where
  fmap :: (a -> b) -> VecList n a -> VecList n b
fmap = (a -> b) -> VecList n a -> VecList n b
forall (v :: * -> *) a b.
(Vector v a, Vector v b) =>
(a -> b) -> v a -> v b
map
instance Arity n => Applicative (VecList n) where
  pure :: a -> VecList n a
pure  = a -> VecList n a
forall (v :: * -> *) a. Vector v a => a -> v a
replicate
  <*> :: VecList n (a -> b) -> VecList n a -> VecList n b
(<*>) = ((a -> b) -> a -> b)
-> VecList n (a -> b) -> VecList n a -> VecList n b
forall (v :: * -> *) a b c.
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> v a -> v b -> v c
zipWith (a -> b) -> a -> b
forall a b. (a -> b) -> a -> b
($)
instance Arity n => F.Foldable (VecList n) where
  foldr :: (a -> b -> b) -> b -> VecList n a -> b
foldr = (a -> b -> b) -> b -> VecList n a -> b
forall (v :: * -> *) a b.
Vector v a =>
(a -> b -> b) -> b -> v a -> b
foldr
instance Arity n => T.Traversable (VecList n) where
  sequenceA :: VecList n (f a) -> f (VecList n a)
sequenceA = VecList n (f a) -> f (VecList n a)
forall (v :: * -> *) a (f :: * -> *).
(Vector v a, Vector v (f a), Applicative f) =>
v (f a) -> f (v a)
sequenceA
  traverse :: (a -> f b) -> VecList n a -> f (VecList n b)
traverse  = (a -> f b) -> VecList n a -> f (VecList n b)
forall (v :: * -> *) a b (f :: * -> *).
(Vector v a, Vector v b, Applicative f) =>
(a -> f b) -> v a -> f (v b)
traverse
instance (Arity n, Monoid a) => Monoid (VecList n a) where
  mempty :: VecList n a
mempty  = a -> VecList n a
forall (v :: * -> *) a. Vector v a => a -> v a
replicate a
forall a. Monoid a => a
mempty
  mappend :: VecList n a -> VecList n a -> VecList n a
mappend = (a -> a -> a) -> VecList n a -> VecList n a -> VecList n a
forall (v :: * -> *) a b c.
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> v a -> v b -> v c
zipWith a -> a -> a
forall a. Monoid a => a -> a -> a
mappend
  {-# INLINE mempty  #-}
  {-# INLINE mappend #-}

instance (Arity n, Semigroup a) => Semigroup (VecList n a) where
  <> :: VecList n a -> VecList n a -> VecList n a
(<>) = (a -> a -> a) -> VecList n a -> VecList n a -> VecList n a
forall (v :: * -> *) a b c.
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> v a -> v b -> v c
zipWith a -> a -> a
forall a. Semigroup a => a -> a -> a
(<>)
  {-# INLINE (<>) #-}


instance (Storable a, Arity n) => Storable (VecList n a) where
  alignment :: VecList n a -> Int
alignment = VecList n a -> Int
forall a (v :: * -> *). Storable a => v a -> Int
defaultAlignemnt
  sizeOf :: VecList n a -> Int
sizeOf    = VecList n a -> Int
forall a (v :: * -> *). (Storable a, Vector v a) => v a -> Int
defaultSizeOf
  peek :: Ptr (VecList n a) -> IO (VecList n a)
peek      = Ptr (VecList n a) -> IO (VecList n a)
forall a (v :: * -> *).
(Storable a, Vector v a) =>
Ptr (v a) -> IO (v a)
defaultPeek
  poke :: Ptr (VecList n a) -> VecList n a -> IO ()
poke      = Ptr (VecList n a) -> VecList n a -> IO ()
forall a (v :: * -> *).
(Storable a, Vector v a) =>
Ptr (v a) -> v a -> IO ()
defaultPoke
  {-# INLINE alignment #-}
  {-# INLINE sizeOf    #-}
  {-# INLINE peek      #-}
  {-# INLINE poke      #-}



-- | Single-element tuple.
newtype Only a = Only a
                 deriving (Int -> Only a -> ShowS
[Only a] -> ShowS
Only a -> String
(Int -> Only a -> ShowS)
-> (Only a -> String) -> ([Only a] -> ShowS) -> Show (Only a)
forall a. Show a => Int -> Only a -> ShowS
forall a. Show a => [Only a] -> ShowS
forall a. Show a => Only a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Only a] -> ShowS
$cshowList :: forall a. Show a => [Only a] -> ShowS
show :: Only a -> String
$cshow :: forall a. Show a => Only a -> String
showsPrec :: Int -> Only a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Only a -> ShowS
Show,Only a -> Only a -> Bool
(Only a -> Only a -> Bool)
-> (Only a -> Only a -> Bool) -> Eq (Only a)
forall a. Eq a => Only a -> Only a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Only a -> Only a -> Bool
$c/= :: forall a. Eq a => Only a -> Only a -> Bool
== :: Only a -> Only a -> Bool
$c== :: forall a. Eq a => Only a -> Only a -> Bool
Eq,Eq (Only a)
Eq (Only a)
-> (Only a -> Only a -> Ordering)
-> (Only a -> Only a -> Bool)
-> (Only a -> Only a -> Bool)
-> (Only a -> Only a -> Bool)
-> (Only a -> Only a -> Bool)
-> (Only a -> Only a -> Only a)
-> (Only a -> Only a -> Only a)
-> Ord (Only a)
Only a -> Only a -> Bool
Only a -> Only a -> Ordering
Only a -> Only a -> Only a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Only a)
forall a. Ord a => Only a -> Only a -> Bool
forall a. Ord a => Only a -> Only a -> Ordering
forall a. Ord a => Only a -> Only a -> Only a
min :: Only a -> Only a -> Only a
$cmin :: forall a. Ord a => Only a -> Only a -> Only a
max :: Only a -> Only a -> Only a
$cmax :: forall a. Ord a => Only a -> Only a -> Only a
>= :: Only a -> Only a -> Bool
$c>= :: forall a. Ord a => Only a -> Only a -> Bool
> :: Only a -> Only a -> Bool
$c> :: forall a. Ord a => Only a -> Only a -> Bool
<= :: Only a -> Only a -> Bool
$c<= :: forall a. Ord a => Only a -> Only a -> Bool
< :: Only a -> Only a -> Bool
$c< :: forall a. Ord a => Only a -> Only a -> Bool
compare :: Only a -> Only a -> Ordering
$ccompare :: forall a. Ord a => Only a -> Only a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Only a)
Ord,Typeable,Typeable (Only a)
DataType
Constr
Typeable (Only a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Only a -> c (Only a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Only a))
-> (Only a -> Constr)
-> (Only a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Only a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Only a)))
-> ((forall b. Data b => b -> b) -> Only a -> Only a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Only a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Only a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Only a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Only a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Only a -> m (Only a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Only a -> m (Only a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Only a -> m (Only a))
-> Data (Only a)
Only a -> DataType
Only a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Only a))
(forall b. Data b => b -> b) -> Only a -> Only a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Only a -> c (Only a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Only a)
forall a. Data a => Typeable (Only a)
forall a. Data a => Only a -> DataType
forall a. Data a => Only a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Only a -> Only a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Only a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Only a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Only a -> m (Only a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Only a -> m (Only a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Only a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Only a -> c (Only a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Only a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Only a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Only a -> u
forall u. (forall d. Data d => d -> u) -> Only a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Only a -> m (Only a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Only a -> m (Only a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Only a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Only a -> c (Only a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Only a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Only a))
$cOnly :: Constr
$tOnly :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Only a -> m (Only a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Only a -> m (Only a)
gmapMp :: (forall d. Data d => d -> m d) -> Only a -> m (Only a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Only a -> m (Only a)
gmapM :: (forall d. Data d => d -> m d) -> Only a -> m (Only a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Only a -> m (Only a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Only a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Only a -> u
gmapQ :: (forall d. Data d => d -> u) -> Only a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Only a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r
gmapT :: (forall b. Data b => b -> b) -> Only a -> Only a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Only a -> Only a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Only a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Only a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Only a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Only a))
dataTypeOf :: Only a -> DataType
$cdataTypeOf :: forall a. Data a => Only a -> DataType
toConstr :: Only a -> Constr
$ctoConstr :: forall a. Data a => Only a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Only a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Only a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Only a -> c (Only a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Only a -> c (Only a)
$cp1Data :: forall a. Data a => Typeable (Only a)
Data,a -> Only b -> Only a
(a -> b) -> Only a -> Only b
(forall a b. (a -> b) -> Only a -> Only b)
-> (forall a b. a -> Only b -> Only a) -> Functor Only
forall a b. a -> Only b -> Only a
forall a b. (a -> b) -> Only a -> Only b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Only b -> Only a
$c<$ :: forall a b. a -> Only b -> Only a
fmap :: (a -> b) -> Only a -> Only b
$cfmap :: forall a b. (a -> b) -> Only a -> Only b
Functor,Only a -> Bool
(a -> m) -> Only a -> m
(a -> b -> b) -> b -> Only a -> b
(forall m. Monoid m => Only m -> m)
-> (forall m a. Monoid m => (a -> m) -> Only a -> m)
-> (forall m a. Monoid m => (a -> m) -> Only a -> m)
-> (forall a b. (a -> b -> b) -> b -> Only a -> b)
-> (forall a b. (a -> b -> b) -> b -> Only a -> b)
-> (forall b a. (b -> a -> b) -> b -> Only a -> b)
-> (forall b a. (b -> a -> b) -> b -> Only a -> b)
-> (forall a. (a -> a -> a) -> Only a -> a)
-> (forall a. (a -> a -> a) -> Only a -> a)
-> (forall a. Only a -> [a])
-> (forall a. Only a -> Bool)
-> (forall a. Only a -> Int)
-> (forall a. Eq a => a -> Only a -> Bool)
-> (forall a. Ord a => Only a -> a)
-> (forall a. Ord a => Only a -> a)
-> (forall a. Num a => Only a -> a)
-> (forall a. Num a => Only a -> a)
-> Foldable Only
forall a. Eq a => a -> Only a -> Bool
forall a. Num a => Only a -> a
forall a. Ord a => Only a -> a
forall m. Monoid m => Only m -> m
forall a. Only a -> Bool
forall a. Only a -> Int
forall a. Only a -> [a]
forall a. (a -> a -> a) -> Only a -> a
forall m a. Monoid m => (a -> m) -> Only a -> m
forall b a. (b -> a -> b) -> b -> Only a -> b
forall a b. (a -> b -> b) -> b -> Only a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Only a -> a
$cproduct :: forall a. Num a => Only a -> a
sum :: Only a -> a
$csum :: forall a. Num a => Only a -> a
minimum :: Only a -> a
$cminimum :: forall a. Ord a => Only a -> a
maximum :: Only a -> a
$cmaximum :: forall a. Ord a => Only a -> a
elem :: a -> Only a -> Bool
$celem :: forall a. Eq a => a -> Only a -> Bool
length :: Only a -> Int
$clength :: forall a. Only a -> Int
null :: Only a -> Bool
$cnull :: forall a. Only a -> Bool
toList :: Only a -> [a]
$ctoList :: forall a. Only a -> [a]
foldl1 :: (a -> a -> a) -> Only a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Only a -> a
foldr1 :: (a -> a -> a) -> Only a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Only a -> a
foldl' :: (b -> a -> b) -> b -> Only a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Only a -> b
foldl :: (b -> a -> b) -> b -> Only a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Only a -> b
foldr' :: (a -> b -> b) -> b -> Only a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Only a -> b
foldr :: (a -> b -> b) -> b -> Only a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Only a -> b
foldMap' :: (a -> m) -> Only a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Only a -> m
foldMap :: (a -> m) -> Only a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Only a -> m
fold :: Only m -> m
$cfold :: forall m. Monoid m => Only m -> m
F.Foldable,Functor Only
Foldable Only
Functor Only
-> Foldable Only
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Only a -> f (Only b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Only (f a) -> f (Only a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Only a -> m (Only b))
-> (forall (m :: * -> *) a. Monad m => Only (m a) -> m (Only a))
-> Traversable Only
(a -> f b) -> Only a -> f (Only b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Only (m a) -> m (Only a)
forall (f :: * -> *) a. Applicative f => Only (f a) -> f (Only a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Only a -> m (Only b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Only a -> f (Only b)
sequence :: Only (m a) -> m (Only a)
$csequence :: forall (m :: * -> *) a. Monad m => Only (m a) -> m (Only a)
mapM :: (a -> m b) -> Only a -> m (Only b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Only a -> m (Only b)
sequenceA :: Only (f a) -> f (Only a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Only (f a) -> f (Only a)
traverse :: (a -> f b) -> Only a -> f (Only b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Only a -> f (Only b)
$cp2Traversable :: Foldable Only
$cp1Traversable :: Functor Only
T.Traversable)

instance Monoid a => Monoid (Only a) where
  mempty :: Only a
mempty = a -> Only a
forall a. a -> Only a
Only a
forall a. Monoid a => a
mempty
  Only a
a mappend :: Only a -> Only a -> Only a
`mappend` Only a
b = a -> Only a
forall a. a -> Only a
Only (a -> Only a) -> a -> Only a
forall a b. (a -> b) -> a -> b
$ a -> a -> a
forall a. Monoid a => a -> a -> a
mappend a
a a
b
instance (Semigroup a) => Semigroup (Only a) where
  Only a
a <> :: Only a -> Only a -> Only a
<> Only a
b = a -> Only a
forall a. a -> Only a
Only (a
a a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
b)
  {-# INLINE (<>) #-}


instance NFData a => NFData (Only a) where
  rnf :: Only a -> ()
rnf (Only a
a) = a -> ()
forall a. NFData a => a -> ()
rnf a
a

type instance Dim Only = 1

instance Vector Only a where
  construct :: Fun (Peano (Dim Only)) a (Only a)
construct = Fn ('S 'Z) a (Only a) -> Fun ('S 'Z) a (Only a)
forall (n :: PeanoNum) a b. Fn n a b -> Fun n a b
Fun Fn ('S 'Z) a (Only a)
forall a. a -> Only a
Only
  inspect :: Only a -> Fun (Peano (Dim Only)) a b -> b
inspect (Only a
a) (Fun Fn (Peano (Dim Only)) a b
f) = Fn (Peano (Dim Only)) a b
a -> b
f a
a
  {-# INLINE construct #-}
  {-# INLINE inspect   #-}

instance (Storable a) => Storable (Only a) where
  alignment :: Only a -> Int
alignment Only a
_ = a -> Int
forall a. Storable a => a -> Int
alignment (a
forall a. HasCallStack => a
undefined :: a)
  sizeOf :: Only a -> Int
sizeOf    Only a
_ = a -> Int
forall a. Storable a => a -> Int
sizeOf    (a
forall a. HasCallStack => a
undefined :: a)
  peek :: Ptr (Only a) -> IO (Only a)
peek Ptr (Only a)
p          = a -> Only a
forall a. a -> Only a
Only (a -> Only a) -> IO a -> IO (Only a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr a -> IO a
forall a. Storable a => Ptr a -> IO a
peek (Ptr (Only a) -> Ptr a
forall a b. Ptr a -> Ptr b
castPtr Ptr (Only a)
p)
  poke :: Ptr (Only a) -> Only a -> IO ()
poke Ptr (Only a)
p (Only a
a) = Ptr a -> a -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr (Only a) -> Ptr a
forall a b. Ptr a -> Ptr b
castPtr Ptr (Only a)
p) a
a
  {-# INLINE alignment #-}
  {-# INLINE sizeOf    #-}
  {-# INLINE peek      #-}
  {-# INLINE poke      #-}


-- | Empty tuple.
data Empty a = Empty
  deriving (Int -> Empty a -> ShowS
[Empty a] -> ShowS
Empty a -> String
(Int -> Empty a -> ShowS)
-> (Empty a -> String) -> ([Empty a] -> ShowS) -> Show (Empty a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (a :: k). Int -> Empty a -> ShowS
forall k (a :: k). [Empty a] -> ShowS
forall k (a :: k). Empty a -> String
showList :: [Empty a] -> ShowS
$cshowList :: forall k (a :: k). [Empty a] -> ShowS
show :: Empty a -> String
$cshow :: forall k (a :: k). Empty a -> String
showsPrec :: Int -> Empty a -> ShowS
$cshowsPrec :: forall k (a :: k). Int -> Empty a -> ShowS
Show,Empty a -> Empty a -> Bool
(Empty a -> Empty a -> Bool)
-> (Empty a -> Empty a -> Bool) -> Eq (Empty a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (a :: k). Empty a -> Empty a -> Bool
/= :: Empty a -> Empty a -> Bool
$c/= :: forall k (a :: k). Empty a -> Empty a -> Bool
== :: Empty a -> Empty a -> Bool
$c== :: forall k (a :: k). Empty a -> Empty a -> Bool
Eq,Eq (Empty a)
Eq (Empty a)
-> (Empty a -> Empty a -> Ordering)
-> (Empty a -> Empty a -> Bool)
-> (Empty a -> Empty a -> Bool)
-> (Empty a -> Empty a -> Bool)
-> (Empty a -> Empty a -> Bool)
-> (Empty a -> Empty a -> Empty a)
-> (Empty a -> Empty a -> Empty a)
-> Ord (Empty a)
Empty a -> Empty a -> Bool
Empty a -> Empty a -> Ordering
Empty a -> Empty a -> Empty a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k (a :: k). Eq (Empty a)
forall k (a :: k). Empty a -> Empty a -> Bool
forall k (a :: k). Empty a -> Empty a -> Ordering
forall k (a :: k). Empty a -> Empty a -> Empty a
min :: Empty a -> Empty a -> Empty a
$cmin :: forall k (a :: k). Empty a -> Empty a -> Empty a
max :: Empty a -> Empty a -> Empty a
$cmax :: forall k (a :: k). Empty a -> Empty a -> Empty a
>= :: Empty a -> Empty a -> Bool
$c>= :: forall k (a :: k). Empty a -> Empty a -> Bool
> :: Empty a -> Empty a -> Bool
$c> :: forall k (a :: k). Empty a -> Empty a -> Bool
<= :: Empty a -> Empty a -> Bool
$c<= :: forall k (a :: k). Empty a -> Empty a -> Bool
< :: Empty a -> Empty a -> Bool
$c< :: forall k (a :: k). Empty a -> Empty a -> Bool
compare :: Empty a -> Empty a -> Ordering
$ccompare :: forall k (a :: k). Empty a -> Empty a -> Ordering
$cp1Ord :: forall k (a :: k). Eq (Empty a)
Ord,Typeable,Typeable (Empty a)
DataType
Constr
Typeable (Empty a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Empty a -> c (Empty a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Empty a))
-> (Empty a -> Constr)
-> (Empty a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Empty a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Empty a)))
-> ((forall b. Data b => b -> b) -> Empty a -> Empty a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Empty a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Empty a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Empty a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Empty a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Empty a -> m (Empty a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Empty a -> m (Empty a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Empty a -> m (Empty a))
-> Data (Empty a)
Empty a -> DataType
Empty a -> Constr
(forall b. Data b => b -> b) -> Empty a -> Empty a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Empty a -> c (Empty a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Empty a)
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Empty a -> u
forall u. (forall d. Data d => d -> u) -> Empty a -> [u]
forall k (a :: k). (Typeable a, Typeable k) => Typeable (Empty a)
forall k (a :: k). (Typeable a, Typeable k) => Empty a -> DataType
forall k (a :: k). (Typeable a, Typeable k) => Empty a -> Constr
forall k (a :: k).
(Typeable a, Typeable k) =>
(forall b. Data b => b -> b) -> Empty a -> Empty a
forall k (a :: k) u.
(Typeable a, Typeable k) =>
Int -> (forall d. Data d => d -> u) -> Empty a -> u
forall k (a :: k) u.
(Typeable a, Typeable k) =>
(forall d. Data d => d -> u) -> Empty a -> [u]
forall k (a :: k) r r'.
(Typeable a, Typeable k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Empty a -> r
forall k (a :: k) r r'.
(Typeable a, Typeable k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Empty a -> r
forall k (a :: k) (m :: * -> *).
(Typeable a, Typeable k, Monad m) =>
(forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
forall k (a :: k) (m :: * -> *).
(Typeable a, Typeable k, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
forall k (a :: k) (c :: * -> *).
(Typeable a, Typeable k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Empty a)
forall k (a :: k) (c :: * -> *).
(Typeable a, Typeable k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Empty a -> c (Empty a)
forall k (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable k, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Empty a))
forall k (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable k, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Empty a))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Empty a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Empty a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Empty a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Empty a -> c (Empty a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Empty a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Empty a))
$cEmpty :: Constr
$tEmpty :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
$cgmapMo :: forall k (a :: k) (m :: * -> *).
(Typeable a, Typeable k, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
gmapMp :: (forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
$cgmapMp :: forall k (a :: k) (m :: * -> *).
(Typeable a, Typeable k, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
gmapM :: (forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
$cgmapM :: forall k (a :: k) (m :: * -> *).
(Typeable a, Typeable k, Monad m) =>
(forall d. Data d => d -> m d) -> Empty a -> m (Empty a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Empty a -> u
$cgmapQi :: forall k (a :: k) u.
(Typeable a, Typeable k) =>
Int -> (forall d. Data d => d -> u) -> Empty a -> u
gmapQ :: (forall d. Data d => d -> u) -> Empty a -> [u]
$cgmapQ :: forall k (a :: k) u.
(Typeable a, Typeable k) =>
(forall d. Data d => d -> u) -> Empty a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Empty a -> r
$cgmapQr :: forall k (a :: k) r r'.
(Typeable a, Typeable k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Empty a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Empty a -> r
$cgmapQl :: forall k (a :: k) r r'.
(Typeable a, Typeable k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Empty a -> r
gmapT :: (forall b. Data b => b -> b) -> Empty a -> Empty a
$cgmapT :: forall k (a :: k).
(Typeable a, Typeable k) =>
(forall b. Data b => b -> b) -> Empty a -> Empty a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Empty a))
$cdataCast2 :: forall k (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable k, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Empty a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Empty a))
$cdataCast1 :: forall k (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable k, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Empty a))
dataTypeOf :: Empty a -> DataType
$cdataTypeOf :: forall k (a :: k). (Typeable a, Typeable k) => Empty a -> DataType
toConstr :: Empty a -> Constr
$ctoConstr :: forall k (a :: k). (Typeable a, Typeable k) => Empty a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Empty a)
$cgunfold :: forall k (a :: k) (c :: * -> *).
(Typeable a, Typeable k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Empty a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Empty a -> c (Empty a)
$cgfoldl :: forall k (a :: k) (c :: * -> *).
(Typeable a, Typeable k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Empty a -> c (Empty a)
$cp1Data :: forall k (a :: k). (Typeable a, Typeable k) => Typeable (Empty a)
Data,(a -> b) -> Empty a -> Empty b
(forall a b. (a -> b) -> Empty a -> Empty b)
-> (forall a b. a -> Empty b -> Empty a) -> Functor Empty
forall a b. a -> Empty b -> Empty a
forall a b. (a -> b) -> Empty a -> Empty b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Empty b -> Empty a
$c<$ :: forall a b. a -> Empty b -> Empty a
fmap :: (a -> b) -> Empty a -> Empty b
$cfmap :: forall a b. (a -> b) -> Empty a -> Empty b
Functor,(a -> m) -> Empty a -> m
(forall m. Monoid m => Empty m -> m)
-> (forall m a. Monoid m => (a -> m) -> Empty a -> m)
-> (forall m a. Monoid m => (a -> m) -> Empty a -> m)
-> (forall a b. (a -> b -> b) -> b -> Empty a -> b)
-> (forall a b. (a -> b -> b) -> b -> Empty a -> b)
-> (forall b a. (b -> a -> b) -> b -> Empty a -> b)
-> (forall b a. (b -> a -> b) -> b -> Empty a -> b)
-> (forall a. (a -> a -> a) -> Empty a -> a)
-> (forall a. (a -> a -> a) -> Empty a -> a)
-> (forall a. Empty a -> [a])
-> (forall a. Empty a -> Bool)
-> (forall a. Empty a -> Int)
-> (forall a. Eq a => a -> Empty a -> Bool)
-> (forall a. Ord a => Empty a -> a)
-> (forall a. Ord a => Empty a -> a)
-> (forall a. Num a => Empty a -> a)
-> (forall a. Num a => Empty a -> a)
-> Foldable Empty
forall a. Eq a => a -> Empty a -> Bool
forall a. Num a => Empty a -> a
forall a. Ord a => Empty a -> a
forall m. Monoid m => Empty m -> m
forall a. Empty a -> Bool
forall a. Empty a -> Int
forall a. Empty a -> [a]
forall a. (a -> a -> a) -> Empty a -> a
forall m a. Monoid m => (a -> m) -> Empty a -> m
forall b a. (b -> a -> b) -> b -> Empty a -> b
forall a b. (a -> b -> b) -> b -> Empty a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Empty a -> a
$cproduct :: forall a. Num a => Empty a -> a
sum :: Empty a -> a
$csum :: forall a. Num a => Empty a -> a
minimum :: Empty a -> a
$cminimum :: forall a. Ord a => Empty a -> a
maximum :: Empty a -> a
$cmaximum :: forall a. Ord a => Empty a -> a
elem :: a -> Empty a -> Bool
$celem :: forall a. Eq a => a -> Empty a -> Bool
length :: Empty a -> Int
$clength :: forall a. Empty a -> Int
null :: Empty a -> Bool
$cnull :: forall a. Empty a -> Bool
toList :: Empty a -> [a]
$ctoList :: forall a. Empty a -> [a]
foldl1 :: (a -> a -> a) -> Empty a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Empty a -> a
foldr1 :: (a -> a -> a) -> Empty a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Empty a -> a
foldl' :: (b -> a -> b) -> b -> Empty a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Empty a -> b
foldl :: (b -> a -> b) -> b -> Empty a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Empty a -> b
foldr' :: (a -> b -> b) -> b -> Empty a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Empty a -> b
foldr :: (a -> b -> b) -> b -> Empty a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Empty a -> b
foldMap' :: (a -> m) -> Empty a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Empty a -> m
foldMap :: (a -> m) -> Empty a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Empty a -> m
fold :: Empty m -> m
$cfold :: forall m. Monoid m => Empty m -> m
F.Foldable,Functor Empty
Foldable Empty
Functor Empty
-> Foldable Empty
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Empty a -> f (Empty b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Empty (f a) -> f (Empty a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Empty a -> m (Empty b))
-> (forall (m :: * -> *) a. Monad m => Empty (m a) -> m (Empty a))
-> Traversable Empty
(a -> f b) -> Empty a -> f (Empty b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Empty (m a) -> m (Empty a)
forall (f :: * -> *) a. Applicative f => Empty (f a) -> f (Empty a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Empty a -> m (Empty b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Empty a -> f (Empty b)
sequence :: Empty (m a) -> m (Empty a)
$csequence :: forall (m :: * -> *) a. Monad m => Empty (m a) -> m (Empty a)
mapM :: (a -> m b) -> Empty a -> m (Empty b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Empty a -> m (Empty b)
sequenceA :: Empty (f a) -> f (Empty a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Empty (f a) -> f (Empty a)
traverse :: (a -> f b) -> Empty a -> f (Empty b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Empty a -> f (Empty b)
$cp2Traversable :: Foldable Empty
$cp1Traversable :: Functor Empty
T.Traversable)

instance NFData (Empty a) where
  rnf :: Empty a -> ()
rnf Empty a
Empty = ()

type instance Dim Empty = 0

instance Vector Empty a where
  construct :: Fun (Peano (Dim Empty)) a (Empty a)
construct = Fn 'Z a (Empty a) -> Fun 'Z a (Empty a)
forall (n :: PeanoNum) a b. Fn n a b -> Fun n a b
Fun Fn 'Z a (Empty a)
forall k (a :: k). Empty a
Empty
  inspect :: Empty a -> Fun (Peano (Dim Empty)) a b -> b
inspect Empty a
_ (Fun Fn (Peano (Dim Empty)) a b
b) = b
Fn (Peano (Dim Empty)) a b
b
  {-# INLINE construct #-}
  {-# INLINE inspect   #-}

type Tuple2 a = (a,a)
type Tuple3 a = (a,a,a)
type Tuple4 a = (a,a,a,a)
type Tuple5 a = (a,a,a,a,a)


----------------------------------------------------------------
-- Patterns
----------------------------------------------------------------

pattern V2 :: (Vector v a, Dim v ~ 2) => a -> a -> v a
pattern $bV2 :: a -> a -> v a
$mV2 :: forall r (v :: * -> *) a.
(Vector v a, Dim v ~ 2) =>
v a -> (a -> a -> r) -> (Void# -> r) -> r
V2 x y <- (convert -> (x,y)) where
  V2 a
x a
y = a -> a -> v a
forall (v :: * -> *) a. (Vector v a, Dim v ~ 2) => a -> a -> v a
mk2 a
x a
y
#if MIN_VERSION_base(4,16,0)
{-# INLINE V2 #-}
#endif

pattern V3 :: (Vector v a, Dim v ~ 3) => a -> a -> a -> v a
pattern $bV3 :: a -> a -> a -> v a
$mV3 :: forall r (v :: * -> *) a.
(Vector v a, Dim v ~ 3) =>
v a -> (a -> a -> a -> r) -> (Void# -> r) -> r
V3 x y z <- (convert -> (x,y,z)) where
  V3 a
x a
y a
z = a -> a -> a -> v a
forall (v :: * -> *) a.
(Vector v a, Dim v ~ 3) =>
a -> a -> a -> v a
mk3 a
x a
y a
z
#if MIN_VERSION_base(4,16,0)
{-# INLINE V3 #-}
#endif

pattern V4 :: (Vector v a, Dim v ~ 4) => a -> a -> a -> a -> v a
pattern $bV4 :: a -> a -> a -> a -> v a
$mV4 :: forall r (v :: * -> *) a.
(Vector v a, Dim v ~ 4) =>
v a -> (a -> a -> a -> a -> r) -> (Void# -> r) -> r
V4 t x y z <- (convert -> (t,x,y,z)) where
  V4 a
t a
x a
y a
z = a -> a -> a -> a -> v a
forall (v :: * -> *) a.
(Vector v a, Dim v ~ 4) =>
a -> a -> a -> a -> v a
mk4 a
t a
x a
y a
z
#if MIN_VERSION_base(4,16,0)
{-# INLINE V4 #-}
#endif


-- $setup
--
-- >>> import Data.Char