{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}

#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE Trustworthy #-}
#endif

#if __GLASGOW_HASKELL__ >= 707
{-# LANGUAGE DataKinds #-}
#endif

#if __GLASGOW_HASKELL__ >= 800
{-# LANGUAGE DeriveLift #-}
#endif

#ifndef MIN_VERSION_hashable
#define MIN_VERSION_hashable(x,y,z) 1
#endif

#ifndef MIN_VERSION_vector
#define MIN_VERSION_vector(x,y,z) 1
#endif

#ifndef MIN_VERSION_transformers
#define MIN_VERSION_transformers(x,y,z) 1
#endif

#ifndef MIN_VERSION_base
#define MIN_VERSION_base(x,y,z) 1
#endif

-----------------------------------------------------------------------------
-- |
-- Copyright   :  (C) 2012-2015 Edward Kmett
-- License     :  BSD-style (see the file LICENSE)
--
-- Maintainer  :  Edward Kmett <ekmett@gmail.com>
-- Stability   :  experimental
-- Portability :  non-portable
--
-- 0-D Vectors
----------------------------------------------------------------------------
module Linear.V0
  ( V0(..)
  ) where

import Control.Applicative
import Control.DeepSeq (NFData(rnf))
import Control.Lens as Lens
import Control.Monad.Fix
import Control.Monad.Zip
import Data.Binary -- binary
import Data.Bytes.Serial -- bytes
import Data.Data
import Data.Distributive
import Data.Foldable
import qualified Data.Foldable.WithIndex as WithIndex
import Data.Functor.Bind
import Data.Functor.Classes
import Data.Functor.Rep
import qualified Data.Functor.WithIndex as WithIndex
import Data.Hashable
#if (MIN_VERSION_hashable(1,2,5))
import Data.Hashable.Lifted
#endif
import Data.Ix
#if !(MIN_VERSION_base(4,11,0))
import Data.Semigroup
#endif
import Data.Serialize -- cereal
import qualified Data.Traversable.WithIndex as WithIndex
#if __GLASGOW_HASKELL__ >= 707
import qualified Data.Vector as V
#endif
import Foreign.Storable (Storable(..))
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
import GHC.Generics (Generic)
#endif
#if __GLASGOW_HASKELL__ >= 706
import GHC.Generics (Generic1)
#endif
#if __GLASGOW_HASKELL__ >= 800
import Language.Haskell.TH.Syntax (Lift)
#endif
import qualified Data.Vector.Generic.Mutable as M
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Unboxed.Base as U
import Linear.Metric
import Linear.Epsilon
import Linear.Vector
#if __GLASGOW_HASKELL__ >= 707
import Linear.V
#endif
import System.Random
import Prelude hiding (sum)

-- $setup
-- >>> import Control.Applicative
-- >>> import Control.Lens
-- >>> import qualified Data.Foldable as F
-- >>> let sum xs = F.sum xs

-- | A 0-dimensional vector
--
-- >>> pure 1 :: V0 Int
-- V0
--
-- >>> V0 + V0
-- V0
--
data V0 a = V0 deriving (V0 a -> V0 a -> Bool
(V0 a -> V0 a -> Bool) -> (V0 a -> V0 a -> Bool) -> Eq (V0 a)
forall a. V0 a -> V0 a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: V0 a -> V0 a -> Bool
$c/= :: forall a. V0 a -> V0 a -> Bool
== :: V0 a -> V0 a -> Bool
$c== :: forall a. V0 a -> V0 a -> Bool
Eq,Eq (V0 a)
Eq (V0 a)
-> (V0 a -> V0 a -> Ordering)
-> (V0 a -> V0 a -> Bool)
-> (V0 a -> V0 a -> Bool)
-> (V0 a -> V0 a -> Bool)
-> (V0 a -> V0 a -> Bool)
-> (V0 a -> V0 a -> V0 a)
-> (V0 a -> V0 a -> V0 a)
-> Ord (V0 a)
V0 a -> V0 a -> Bool
V0 a -> V0 a -> Ordering
V0 a -> V0 a -> V0 a
forall a. Eq (V0 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. V0 a -> V0 a -> Bool
forall a. V0 a -> V0 a -> Ordering
forall a. V0 a -> V0 a -> V0 a
min :: V0 a -> V0 a -> V0 a
$cmin :: forall a. V0 a -> V0 a -> V0 a
max :: V0 a -> V0 a -> V0 a
$cmax :: forall a. V0 a -> V0 a -> V0 a
>= :: V0 a -> V0 a -> Bool
$c>= :: forall a. V0 a -> V0 a -> Bool
> :: V0 a -> V0 a -> Bool
$c> :: forall a. V0 a -> V0 a -> Bool
<= :: V0 a -> V0 a -> Bool
$c<= :: forall a. V0 a -> V0 a -> Bool
< :: V0 a -> V0 a -> Bool
$c< :: forall a. V0 a -> V0 a -> Bool
compare :: V0 a -> V0 a -> Ordering
$ccompare :: forall a. V0 a -> V0 a -> Ordering
$cp1Ord :: forall a. Eq (V0 a)
Ord,Int -> V0 a -> ShowS
[V0 a] -> ShowS
V0 a -> String
(Int -> V0 a -> ShowS)
-> (V0 a -> String) -> ([V0 a] -> ShowS) -> Show (V0 a)
forall a. Int -> V0 a -> ShowS
forall a. [V0 a] -> ShowS
forall a. V0 a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [V0 a] -> ShowS
$cshowList :: forall a. [V0 a] -> ShowS
show :: V0 a -> String
$cshow :: forall a. V0 a -> String
showsPrec :: Int -> V0 a -> ShowS
$cshowsPrec :: forall a. Int -> V0 a -> ShowS
Show,ReadPrec [V0 a]
ReadPrec (V0 a)
Int -> ReadS (V0 a)
ReadS [V0 a]
(Int -> ReadS (V0 a))
-> ReadS [V0 a]
-> ReadPrec (V0 a)
-> ReadPrec [V0 a]
-> Read (V0 a)
forall a. ReadPrec [V0 a]
forall a. ReadPrec (V0 a)
forall a. Int -> ReadS (V0 a)
forall a. ReadS [V0 a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [V0 a]
$creadListPrec :: forall a. ReadPrec [V0 a]
readPrec :: ReadPrec (V0 a)
$creadPrec :: forall a. ReadPrec (V0 a)
readList :: ReadS [V0 a]
$creadList :: forall a. ReadS [V0 a]
readsPrec :: Int -> ReadS (V0 a)
$creadsPrec :: forall a. Int -> ReadS (V0 a)
Read,Ord (V0 a)
Ord (V0 a)
-> ((V0 a, V0 a) -> [V0 a])
-> ((V0 a, V0 a) -> V0 a -> Int)
-> ((V0 a, V0 a) -> V0 a -> Int)
-> ((V0 a, V0 a) -> V0 a -> Bool)
-> ((V0 a, V0 a) -> Int)
-> ((V0 a, V0 a) -> Int)
-> Ix (V0 a)
(V0 a, V0 a) -> Int
(V0 a, V0 a) -> [V0 a]
(V0 a, V0 a) -> V0 a -> Bool
(V0 a, V0 a) -> V0 a -> Int
forall a. Ord (V0 a)
forall a.
Ord a
-> ((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
forall a. (V0 a, V0 a) -> Int
forall a. (V0 a, V0 a) -> [V0 a]
forall a. (V0 a, V0 a) -> V0 a -> Bool
forall a. (V0 a, V0 a) -> V0 a -> Int
unsafeRangeSize :: (V0 a, V0 a) -> Int
$cunsafeRangeSize :: forall a. (V0 a, V0 a) -> Int
rangeSize :: (V0 a, V0 a) -> Int
$crangeSize :: forall a. (V0 a, V0 a) -> Int
inRange :: (V0 a, V0 a) -> V0 a -> Bool
$cinRange :: forall a. (V0 a, V0 a) -> V0 a -> Bool
unsafeIndex :: (V0 a, V0 a) -> V0 a -> Int
$cunsafeIndex :: forall a. (V0 a, V0 a) -> V0 a -> Int
index :: (V0 a, V0 a) -> V0 a -> Int
$cindex :: forall a. (V0 a, V0 a) -> V0 a -> Int
range :: (V0 a, V0 a) -> [V0 a]
$crange :: forall a. (V0 a, V0 a) -> [V0 a]
$cp1Ix :: forall a. Ord (V0 a)
Ix,Int -> V0 a
V0 a -> Int
V0 a -> [V0 a]
V0 a -> V0 a
V0 a -> V0 a -> [V0 a]
V0 a -> V0 a -> V0 a -> [V0 a]
(V0 a -> V0 a)
-> (V0 a -> V0 a)
-> (Int -> V0 a)
-> (V0 a -> Int)
-> (V0 a -> [V0 a])
-> (V0 a -> V0 a -> [V0 a])
-> (V0 a -> V0 a -> [V0 a])
-> (V0 a -> V0 a -> V0 a -> [V0 a])
-> Enum (V0 a)
forall a. Int -> V0 a
forall a. V0 a -> Int
forall a. V0 a -> [V0 a]
forall a. V0 a -> V0 a
forall a. V0 a -> V0 a -> [V0 a]
forall a. V0 a -> V0 a -> V0 a -> [V0 a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: V0 a -> V0 a -> V0 a -> [V0 a]
$cenumFromThenTo :: forall a. V0 a -> V0 a -> V0 a -> [V0 a]
enumFromTo :: V0 a -> V0 a -> [V0 a]
$cenumFromTo :: forall a. V0 a -> V0 a -> [V0 a]
enumFromThen :: V0 a -> V0 a -> [V0 a]
$cenumFromThen :: forall a. V0 a -> V0 a -> [V0 a]
enumFrom :: V0 a -> [V0 a]
$cenumFrom :: forall a. V0 a -> [V0 a]
fromEnum :: V0 a -> Int
$cfromEnum :: forall a. V0 a -> Int
toEnum :: Int -> V0 a
$ctoEnum :: forall a. Int -> V0 a
pred :: V0 a -> V0 a
$cpred :: forall a. V0 a -> V0 a
succ :: V0 a -> V0 a
$csucc :: forall a. V0 a -> V0 a
Enum,Typeable (V0 a)
DataType
Constr
Typeable (V0 a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> V0 a -> c (V0 a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (V0 a))
-> (V0 a -> Constr)
-> (V0 a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (V0 a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V0 a)))
-> ((forall b. Data b => b -> b) -> V0 a -> V0 a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r)
-> (forall u. (forall d. Data d => d -> u) -> V0 a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> V0 a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> V0 a -> m (V0 a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> V0 a -> m (V0 a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> V0 a -> m (V0 a))
-> Data (V0 a)
V0 a -> DataType
V0 a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (V0 a))
(forall b. Data b => b -> b) -> V0 a -> V0 a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> V0 a -> c (V0 a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (V0 a)
forall a. Data a => Typeable (V0 a)
forall a. Data a => V0 a -> DataType
forall a. Data a => V0 a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> V0 a -> V0 a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> V0 a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> V0 a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (V0 a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> V0 a -> c (V0 a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (V0 a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V0 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) -> V0 a -> u
forall u. (forall d. Data d => d -> u) -> V0 a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (V0 a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> V0 a -> c (V0 a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (V0 a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V0 a))
$cV0 :: Constr
$tV0 :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
gmapMp :: (forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
gmapM :: (forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> V0 a -> m (V0 a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> V0 a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> V0 a -> u
gmapQ :: (forall d. Data d => d -> u) -> V0 a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> V0 a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V0 a -> r
gmapT :: (forall b. Data b => b -> b) -> V0 a -> V0 a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> V0 a -> V0 a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V0 a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V0 a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (V0 a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (V0 a))
dataTypeOf :: V0 a -> DataType
$cdataTypeOf :: forall a. Data a => V0 a -> DataType
toConstr :: V0 a -> Constr
$ctoConstr :: forall a. Data a => V0 a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (V0 a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (V0 a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> V0 a -> c (V0 a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> V0 a -> c (V0 a)
$cp1Data :: forall a. Data a => Typeable (V0 a)
Data,Typeable
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
                        ,(forall x. V0 a -> Rep (V0 a) x)
-> (forall x. Rep (V0 a) x -> V0 a) -> Generic (V0 a)
forall x. Rep (V0 a) x -> V0 a
forall x. V0 a -> Rep (V0 a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (V0 a) x -> V0 a
forall a x. V0 a -> Rep (V0 a) x
$cto :: forall a x. Rep (V0 a) x -> V0 a
$cfrom :: forall a x. V0 a -> Rep (V0 a) x
Generic
#endif
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 706
                        ,(forall a. V0 a -> Rep1 V0 a)
-> (forall a. Rep1 V0 a -> V0 a) -> Generic1 V0
forall a. Rep1 V0 a -> V0 a
forall a. V0 a -> Rep1 V0 a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 V0 a -> V0 a
$cfrom1 :: forall a. V0 a -> Rep1 V0 a
Generic1
#endif
#if __GLASGOW_HASKELL__ >= 800
                        ,V0 a -> Q Exp
V0 a -> Q (TExp (V0 a))
(V0 a -> Q Exp) -> (V0 a -> Q (TExp (V0 a))) -> Lift (V0 a)
forall a. V0 a -> Q Exp
forall a. V0 a -> Q (TExp (V0 a))
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: V0 a -> Q (TExp (V0 a))
$cliftTyped :: forall a. V0 a -> Q (TExp (V0 a))
lift :: V0 a -> Q Exp
$clift :: forall a. V0 a -> Q Exp
Lift
#endif
                        )

#if __GLASGOW_HASKELL__ >= 707
instance Finite V0 where
  type Size V0 = 0
  toV :: V0 a -> V (Size V0) a
toV V0 a
_ = Vector a -> V 0 a
forall k (n :: k) a. Vector a -> V n a
V Vector a
forall a. Vector a
V.empty
  fromV :: V (Size V0) a -> V0 a
fromV V (Size V0) a
_ = V0 a
forall a. V0 a
V0
#endif

instance Random (V0 a) where
  random :: g -> (V0 a, g)
random g
g = (V0 a
forall a. V0 a
V0, g
g)
  randomR :: (V0 a, V0 a) -> g -> (V0 a, g)
randomR (V0 a, V0 a)
_ g
g = (V0 a
forall a. V0 a
V0, g
g)
  randomRs :: (V0 a, V0 a) -> g -> [V0 a]
randomRs (V0 a, V0 a)
_ g
_ = V0 a -> [V0 a]
forall a. a -> [a]
repeat V0 a
forall a. V0 a
V0
  randoms :: g -> [V0 a]
randoms g
_ = V0 a -> [V0 a]
forall a. a -> [a]
repeat V0 a
forall a. V0 a
V0

instance Serial1 V0 where
  serializeWith :: (a -> m ()) -> V0 a -> m ()
serializeWith a -> m ()
_ = V0 a -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
serialize
  deserializeWith :: m a -> m (V0 a)
deserializeWith m a
_ = m (V0 a)
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
deserialize

instance Serial (V0 a) where
  serialize :: V0 a -> m ()
serialize V0 a
V0 = () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  deserialize :: m (V0 a)
deserialize = V0 a -> m (V0 a)
forall (m :: * -> *) a. Monad m => a -> m a
return V0 a
forall a. V0 a
V0

instance Binary (V0 a) where
  put :: V0 a -> Put
put V0 a
V0 = () -> Put
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  get :: Get (V0 a)
get = V0 a -> Get (V0 a)
forall (m :: * -> *) a. Monad m => a -> m a
return V0 a
forall a. V0 a
V0

instance Serialize (V0 a) where
  put :: Putter (V0 a)
put V0 a
V0 = () -> PutM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  get :: Get (V0 a)
get = V0 a -> Get (V0 a)
forall (m :: * -> *) a. Monad m => a -> m a
return V0 a
forall a. V0 a
V0

instance Functor V0 where
  fmap :: (a -> b) -> V0 a -> V0 b
fmap a -> b
_ V0 a
V0 = V0 b
forall a. V0 a
V0
  {-# INLINE fmap #-}
  a
_ <$ :: a -> V0 b -> V0 a
<$ V0 b
_ = V0 a
forall a. V0 a
V0
  {-# INLINE (<$) #-}

instance Foldable V0 where
  foldMap :: (a -> m) -> V0 a -> m
foldMap a -> m
_ V0 a
V0 = m
forall a. Monoid a => a
mempty
  {-# INLINE foldMap #-}
#if __GLASGOW_HASKELL__ >= 710
  null :: V0 a -> Bool
null V0 a
_ = Bool
True
  length :: V0 a -> Int
length V0 a
_ = Int
0
#endif

instance Traversable V0 where
  traverse :: (a -> f b) -> V0 a -> f (V0 b)
traverse a -> f b
_ V0 a
V0 = V0 b -> f (V0 b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure V0 b
forall a. V0 a
V0
  {-# INLINE traverse #-}

instance Apply V0 where
  V0 (a -> b)
V0 <.> :: V0 (a -> b) -> V0 a -> V0 b
<.> V0 a
V0 = V0 b
forall a. V0 a
V0
  {-# INLINE (<.>) #-}

instance Applicative V0 where
  pure :: a -> V0 a
pure a
_ = V0 a
forall a. V0 a
V0
  {-# INLINE pure #-}
  V0 (a -> b)
V0 <*> :: V0 (a -> b) -> V0 a -> V0 b
<*> V0 a
V0 = V0 b
forall a. V0 a
V0
  {-# INLINE (<*>) #-}

instance Semigroup (V0 a) where
  V0 a
_ <> :: V0 a -> V0 a -> V0 a
<> V0 a
_ = V0 a
forall a. V0 a
V0

instance Monoid (V0 a) where
  mempty :: V0 a
mempty = V0 a
forall a. V0 a
V0
#if !(MIN_VERSION_base(4,11,0))
  mappend _ _ = V0
#endif

instance Additive V0 where
  zero :: V0 a
zero = V0 a
forall a. V0 a
V0
  {-# INLINE zero #-}
  liftU2 :: (a -> a -> a) -> V0 a -> V0 a -> V0 a
liftU2 a -> a -> a
_ V0 a
V0 V0 a
V0 = V0 a
forall a. V0 a
V0
  {-# INLINE liftU2 #-}
  liftI2 :: (a -> b -> c) -> V0 a -> V0 b -> V0 c
liftI2 a -> b -> c
_ V0 a
V0 V0 b
V0 = V0 c
forall a. V0 a
V0
  {-# INLINE liftI2 #-}

instance Bind V0 where
  V0 a
V0 >>- :: V0 a -> (a -> V0 b) -> V0 b
>>- a -> V0 b
_ = V0 b
forall a. V0 a
V0
  {-# INLINE (>>-) #-}

instance Monad V0 where
  return :: a -> V0 a
return a
_ = V0 a
forall a. V0 a
V0
  {-# INLINE return #-}
  V0 a
V0 >>= :: V0 a -> (a -> V0 b) -> V0 b
>>= a -> V0 b
_ = V0 b
forall a. V0 a
V0
  {-# INLINE (>>=) #-}

instance Num (V0 a) where
  V0 a
V0 + :: V0 a -> V0 a -> V0 a
+ V0 a
V0 = V0 a
forall a. V0 a
V0
  {-# INLINE (+) #-}
  V0 a
V0 - :: V0 a -> V0 a -> V0 a
- V0 a
V0 = V0 a
forall a. V0 a
V0
  {-# INLINE (-) #-}
  V0 a
V0 * :: V0 a -> V0 a -> V0 a
* V0 a
V0 = V0 a
forall a. V0 a
V0
  {-# INLINE (*) #-}
  negate :: V0 a -> V0 a
negate V0 a
V0 = V0 a
forall a. V0 a
V0
  {-# INLINE negate #-}
  abs :: V0 a -> V0 a
abs V0 a
V0 = V0 a
forall a. V0 a
V0
  {-# INLINE abs #-}
  signum :: V0 a -> V0 a
signum V0 a
V0 = V0 a
forall a. V0 a
V0
  {-# INLINE signum #-}
  fromInteger :: Integer -> V0 a
fromInteger Integer
_ = V0 a
forall a. V0 a
V0
  {-# INLINE fromInteger #-}

instance Fractional (V0 a) where
  recip :: V0 a -> V0 a
recip V0 a
_ = V0 a
forall a. V0 a
V0
  {-# INLINE recip #-}
  V0 a
V0 / :: V0 a -> V0 a -> V0 a
/ V0 a
V0 = V0 a
forall a. V0 a
V0
  {-# INLINE (/) #-}
  fromRational :: Rational -> V0 a
fromRational Rational
_ = V0 a
forall a. V0 a
V0
  {-# INLINE fromRational #-}

instance Floating (V0 a) where
    pi :: V0 a
pi = V0 a
forall a. V0 a
V0
    {-# INLINE pi #-}
    exp :: V0 a -> V0 a
exp V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE exp #-}
    sqrt :: V0 a -> V0 a
sqrt V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE sqrt #-}
    log :: V0 a -> V0 a
log V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE log #-}
    V0 a
V0 ** :: V0 a -> V0 a -> V0 a
** V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE (**) #-}
    logBase :: V0 a -> V0 a -> V0 a
logBase V0 a
V0 V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE logBase #-}
    sin :: V0 a -> V0 a
sin V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE sin #-}
    tan :: V0 a -> V0 a
tan V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE tan #-}
    cos :: V0 a -> V0 a
cos V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE cos #-}
    asin :: V0 a -> V0 a
asin V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE asin #-}
    atan :: V0 a -> V0 a
atan V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE atan #-}
    acos :: V0 a -> V0 a
acos V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE acos #-}
    sinh :: V0 a -> V0 a
sinh V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE sinh #-}
    tanh :: V0 a -> V0 a
tanh V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE tanh #-}
    cosh :: V0 a -> V0 a
cosh V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE cosh #-}
    asinh :: V0 a -> V0 a
asinh V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE asinh #-}
    atanh :: V0 a -> V0 a
atanh V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE atanh #-}
    acosh :: V0 a -> V0 a
acosh V0 a
V0 = V0 a
forall a. V0 a
V0
    {-# INLINE acosh #-}

instance Metric V0 where
  dot :: V0 a -> V0 a -> a
dot V0 a
V0 V0 a
V0 = a
0
  {-# INLINE dot #-}

instance Distributive V0 where
  distribute :: f (V0 a) -> V0 (f a)
distribute f (V0 a)
_ = V0 (f a)
forall a. V0 a
V0
  {-# INLINE distribute #-}

instance Hashable (V0 a) where
#if (MIN_VERSION_hashable(1,2,1)) || !(MIN_VERSION_hashable(1,2,0))
  hash :: V0 a -> Int
hash V0 a
V0 = Int
0
  {-# INLINE hash #-}
#endif
  hashWithSalt :: Int -> V0 a -> Int
hashWithSalt Int
s V0 a
V0 = Int
s
  {-# INLINE hashWithSalt #-}

#if (MIN_VERSION_hashable(1,2,5))
instance Hashable1 V0 where
  liftHashWithSalt :: (Int -> a -> Int) -> Int -> V0 a -> Int
liftHashWithSalt Int -> a -> Int
_ Int
s V0 a
V0 = Int
s
  {-# INLINE liftHashWithSalt #-}
#endif

instance Epsilon (V0 a) where
  nearZero :: V0 a -> Bool
nearZero V0 a
_ = Bool
True
  {-# INLINE nearZero #-}

instance Storable (V0 a) where
  sizeOf :: V0 a -> Int
sizeOf V0 a
_ = Int
0
  {-# INLINE sizeOf #-}
  alignment :: V0 a -> Int
alignment V0 a
_ = Int
1
  {-# INLINE alignment #-}
  poke :: Ptr (V0 a) -> V0 a -> IO ()
poke Ptr (V0 a)
_ V0 a
V0 = () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  {-# INLINE poke #-}
  peek :: Ptr (V0 a) -> IO (V0 a)
peek Ptr (V0 a)
_ = V0 a -> IO (V0 a)
forall (m :: * -> *) a. Monad m => a -> m a
return V0 a
forall a. V0 a
V0
  {-# INLINE peek #-}

instance WithIndex.FunctorWithIndex (E V0) V0 where
  imap :: (E V0 -> a -> b) -> V0 a -> V0 b
imap E V0 -> a -> b
_ V0 a
V0 = V0 b
forall a. V0 a
V0
  {-# INLINE imap #-}

instance WithIndex.FoldableWithIndex (E V0) V0 where
  ifoldMap :: (E V0 -> a -> m) -> V0 a -> m
ifoldMap E V0 -> a -> m
_ V0 a
V0 = m
forall a. Monoid a => a
mempty
  {-# INLINE ifoldMap #-}

instance WithIndex.TraversableWithIndex (E V0) V0 where
  itraverse :: (E V0 -> a -> f b) -> V0 a -> f (V0 b)
itraverse E V0 -> a -> f b
_ V0 a
V0 = V0 b -> f (V0 b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure V0 b
forall a. V0 a
V0
  {-# INLINE itraverse #-}

#if !MIN_VERSION_lens(5,0,0)
instance Lens.FunctorWithIndex     (E V0) V0 where imap      = WithIndex.imap
instance Lens.FoldableWithIndex    (E V0) V0 where ifoldMap  = WithIndex.ifoldMap
instance Lens.TraversableWithIndex (E V0) V0 where itraverse = WithIndex.itraverse
#endif

instance Representable V0 where
  type Rep V0 = E V0
  tabulate :: (Rep V0 -> a) -> V0 a
tabulate Rep V0 -> a
_ = V0 a
forall a. V0 a
V0
  {-# INLINE tabulate #-}
  index :: V0 a -> Rep V0 -> a
index V0 a
xs (E l) = Getting a (V0 a) a -> V0 a -> a
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting a (V0 a) a
forall x. Lens' (V0 x) x
l V0 a
xs
  {-# INLINE index #-}

type instance Index (V0 a) = E V0
type instance IxValue (V0 a) = a

instance Ixed (V0 a) where
  ix :: Index (V0 a) -> Traversal' (V0 a) (IxValue (V0 a))
ix Index (V0 a)
i = E V0 -> forall x. Lens' (V0 x) x
forall (t :: * -> *).
E t
-> forall x (f :: * -> *).
   Functor f =>
   (x -> f x) -> t x -> f (t x)
el Index (V0 a)
E V0
i
  {-# INLINE ix #-}

instance Each (V0 a) (V0 b) a b where
  each :: (a -> f b) -> V0 a -> f (V0 b)
each = (a -> f b) -> V0 a -> f (V0 b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
  {-# INLINE each #-}

newtype instance U.Vector    (V0 a) = V_V0 Int
newtype instance U.MVector s (V0 a) = MV_V0 Int
instance U.Unbox (V0 a)

instance M.MVector U.MVector (V0 a) where
  {-# INLINE basicLength #-}
  {-# INLINE basicUnsafeSlice #-}
  {-# INLINE basicOverlaps #-}
  {-# INLINE basicUnsafeNew #-}
  {-# INLINE basicUnsafeRead #-}
  {-# INLINE basicUnsafeWrite #-}
  basicLength :: MVector s (V0 a) -> Int
basicLength (MV_V0 n) = Int
n
  basicUnsafeSlice :: Int -> Int -> MVector s (V0 a) -> MVector s (V0 a)
basicUnsafeSlice Int
_ Int
n MVector s (V0 a)
_ = Int -> MVector s (V0 a)
forall s a. Int -> MVector s (V0 a)
MV_V0 Int
n
  basicOverlaps :: MVector s (V0 a) -> MVector s (V0 a) -> Bool
basicOverlaps MVector s (V0 a)
_ MVector s (V0 a)
_ = Bool
False
  basicUnsafeNew :: Int -> m (MVector (PrimState m) (V0 a))
basicUnsafeNew Int
n = MVector (PrimState m) (V0 a) -> m (MVector (PrimState m) (V0 a))
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> MVector (PrimState m) (V0 a)
forall s a. Int -> MVector s (V0 a)
MV_V0 Int
n)
  basicUnsafeRead :: MVector (PrimState m) (V0 a) -> Int -> m (V0 a)
basicUnsafeRead MVector (PrimState m) (V0 a)
_ Int
_ = V0 a -> m (V0 a)
forall (m :: * -> *) a. Monad m => a -> m a
return V0 a
forall a. V0 a
V0
  basicUnsafeWrite :: MVector (PrimState m) (V0 a) -> Int -> V0 a -> m ()
basicUnsafeWrite MVector (PrimState m) (V0 a)
_ Int
_ V0 a
_ = () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if MIN_VERSION_vector(0,11,0)
  basicInitialize :: MVector (PrimState m) (V0 a) -> m ()
basicInitialize MVector (PrimState m) (V0 a)
_ = () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  {-# INLINE basicInitialize #-}
#endif

instance G.Vector U.Vector (V0 a) where
  {-# INLINE basicUnsafeFreeze #-}
  {-# INLINE basicUnsafeThaw   #-}
  {-# INLINE basicLength       #-}
  {-# INLINE basicUnsafeSlice  #-}
  {-# INLINE basicUnsafeIndexM #-}
  basicUnsafeFreeze :: Mutable Vector (PrimState m) (V0 a) -> m (Vector (V0 a))
basicUnsafeFreeze (MV_V0 n) = Vector (V0 a) -> m (Vector (V0 a))
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> Vector (V0 a)
forall a. Int -> Vector (V0 a)
V_V0 Int
n)
  basicUnsafeThaw :: Vector (V0 a) -> m (Mutable Vector (PrimState m) (V0 a))
basicUnsafeThaw (V_V0 n) = MVector (PrimState m) (V0 a) -> m (MVector (PrimState m) (V0 a))
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> MVector (PrimState m) (V0 a)
forall s a. Int -> MVector s (V0 a)
MV_V0 Int
n)
  basicLength :: Vector (V0 a) -> Int
basicLength (V_V0 n) = Int
n
  basicUnsafeSlice :: Int -> Int -> Vector (V0 a) -> Vector (V0 a)
basicUnsafeSlice Int
_ Int
n Vector (V0 a)
_ = Int -> Vector (V0 a)
forall a. Int -> Vector (V0 a)
V_V0 Int
n
  basicUnsafeIndexM :: Vector (V0 a) -> Int -> m (V0 a)
basicUnsafeIndexM Vector (V0 a)
_ Int
_ = V0 a -> m (V0 a)
forall (m :: * -> *) a. Monad m => a -> m a
return V0 a
forall a. V0 a
V0

instance MonadZip V0 where
  mzip :: V0 a -> V0 b -> V0 (a, b)
mzip V0 a
V0 V0 b
V0 = V0 (a, b)
forall a. V0 a
V0
  mzipWith :: (a -> b -> c) -> V0 a -> V0 b -> V0 c
mzipWith a -> b -> c
_ V0 a
V0 V0 b
V0 = V0 c
forall a. V0 a
V0
  munzip :: V0 (a, b) -> (V0 a, V0 b)
munzip V0 (a, b)
V0 = (V0 a
forall a. V0 a
V0, V0 b
forall a. V0 a
V0)

instance MonadFix V0 where
  mfix :: (a -> V0 a) -> V0 a
mfix a -> V0 a
_ = V0 a
forall a. V0 a
V0

instance Bounded (V0 a) where
  minBound :: V0 a
minBound = V0 a
forall a. V0 a
V0
  {-# INLINE minBound #-}
  maxBound :: V0 a
maxBound = V0 a
forall a. V0 a
V0
  {-# INLINE maxBound #-}

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

#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0))
instance Eq1 V0   where
  liftEq :: (a -> b -> Bool) -> V0 a -> V0 b -> Bool
liftEq a -> b -> Bool
_ V0 a
_ V0 b
_ = Bool
True
instance Ord1 V0  where
  liftCompare :: (a -> b -> Ordering) -> V0 a -> V0 b -> Ordering
liftCompare a -> b -> Ordering
_ V0 a
_ V0 b
_ = Ordering
EQ
instance Show1 V0 where
  liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> V0 a -> ShowS
liftShowsPrec Int -> a -> ShowS
_ [a] -> ShowS
_ = Int -> V0 a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec
instance Read1 V0 where
  liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (V0 a)
liftReadsPrec Int -> ReadS a
_ ReadS [a]
_ = Int -> ReadS (V0 a)
forall a. Read a => Int -> ReadS a
readsPrec
#else
instance Eq1 V0   where eq1 = (==)
instance Ord1 V0  where compare1 = compare
instance Show1 V0 where showsPrec1 = showsPrec
instance Read1 V0 where readsPrec1 = readsPrec
#endif