{-# LANGUAGE AllowAmbiguousTypes        #-}
{-# LANGUAGE BangPatterns               #-}
{-# LANGUAGE CPP                        #-}
{-# LANGUAGE DataKinds                  #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE DeriveTraversable          #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE GADTs                      #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE PatternSynonyms            #-}
{-# LANGUAGE PolyKinds                  #-}
{-# LANGUAGE RankNTypes                 #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TypeApplications           #-}
{-# LANGUAGE TypeFamilyDependencies     #-}
{-# LANGUAGE TypeOperators              #-}
{-# LANGUAGE UndecidableInstances       #-}
{-# LANGUAGE ViewPatterns               #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Numeric.Tuple.Lazy
-- Copyright   :  (c) Artem Chirkin
-- License     :  BSD3
--
--
-----------------------------------------------------------------------------
module Numeric.Tuple.Lazy
    ( Id (..), Tuple
    , TypedList (U, (:*), (:$), (:!), Empty, TypeList, Cons, Snoc, Reverse)
    , (*$), ($*), (*!), (!*)
    ) where


import           Control.Arrow        (first)
import           Control.Monad.Fix
import           Control.Monad.Zip
import           Data.Bits            (Bits, FiniteBits)
import           Data.Coerce
import           Data.Data            (Data)
import           Data.Foldable
import           Data.Functor.Classes
import           Data.Ix              (Ix)
import           Data.Monoid          as Mon (Monoid (..))
import           Data.Semigroup       as Sem (Semigroup (..))
import           Data.String          (IsString)
import           Foreign.Storable     (Storable)
import           GHC.Base             (Type, Any)
import           GHC.Generics         (Generic, Generic1)
import qualified Text.Read            as P
import           Unsafe.Coerce        (unsafeCoerce)

import Data.Type.List
import Numeric.TypedList

-- | This is an almost complete copy of `Data.Functor.Identity`
--   by (c) Andy Gill 2001.
newtype Id a = Id { Id a -> a
runId :: a }
    deriving ( Eq (Id a)
Id a
Eq (Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Int -> Id a)
-> (Id a -> Int -> Id a)
-> Id a
-> (Int -> Id a)
-> (Id a -> Int -> Id a)
-> (Id a -> Int -> Id a)
-> (Id a -> Int -> Id a)
-> (Id a -> Int -> Bool)
-> (Id a -> Maybe Int)
-> (Id a -> Int)
-> (Id a -> Bool)
-> (Id a -> Int -> Id a)
-> (Id a -> Int -> Id a)
-> (Id a -> Int -> Id a)
-> (Id a -> Int -> Id a)
-> (Id a -> Int -> Id a)
-> (Id a -> Int -> Id a)
-> (Id a -> Int)
-> Bits (Id a)
Int -> Id a
Id a -> Bool
Id a -> Int
Id a -> Maybe Int
Id a -> Id a
Id a -> Int -> Bool
Id a -> Int -> Id a
Id a -> Id a -> Id a
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall a. Bits a => Eq (Id a)
forall a. Bits a => Id a
forall a. Bits a => Int -> Id a
forall a. Bits a => Id a -> Bool
forall a. Bits a => Id a -> Int
forall a. Bits a => Id a -> Maybe Int
forall a. Bits a => Id a -> Id a
forall a. Bits a => Id a -> Int -> Bool
forall a. Bits a => Id a -> Int -> Id a
forall a. Bits a => Id a -> Id a -> Id a
popCount :: Id a -> Int
$cpopCount :: forall a. Bits a => Id a -> Int
rotateR :: Id a -> Int -> Id a
$crotateR :: forall a. Bits a => Id a -> Int -> Id a
rotateL :: Id a -> Int -> Id a
$crotateL :: forall a. Bits a => Id a -> Int -> Id a
unsafeShiftR :: Id a -> Int -> Id a
$cunsafeShiftR :: forall a. Bits a => Id a -> Int -> Id a
shiftR :: Id a -> Int -> Id a
$cshiftR :: forall a. Bits a => Id a -> Int -> Id a
unsafeShiftL :: Id a -> Int -> Id a
$cunsafeShiftL :: forall a. Bits a => Id a -> Int -> Id a
shiftL :: Id a -> Int -> Id a
$cshiftL :: forall a. Bits a => Id a -> Int -> Id a
isSigned :: Id a -> Bool
$cisSigned :: forall a. Bits a => Id a -> Bool
bitSize :: Id a -> Int
$cbitSize :: forall a. Bits a => Id a -> Int
bitSizeMaybe :: Id a -> Maybe Int
$cbitSizeMaybe :: forall a. Bits a => Id a -> Maybe Int
testBit :: Id a -> Int -> Bool
$ctestBit :: forall a. Bits a => Id a -> Int -> Bool
complementBit :: Id a -> Int -> Id a
$ccomplementBit :: forall a. Bits a => Id a -> Int -> Id a
clearBit :: Id a -> Int -> Id a
$cclearBit :: forall a. Bits a => Id a -> Int -> Id a
setBit :: Id a -> Int -> Id a
$csetBit :: forall a. Bits a => Id a -> Int -> Id a
bit :: Int -> Id a
$cbit :: forall a. Bits a => Int -> Id a
zeroBits :: Id a
$czeroBits :: forall a. Bits a => Id a
rotate :: Id a -> Int -> Id a
$crotate :: forall a. Bits a => Id a -> Int -> Id a
shift :: Id a -> Int -> Id a
$cshift :: forall a. Bits a => Id a -> Int -> Id a
complement :: Id a -> Id a
$ccomplement :: forall a. Bits a => Id a -> Id a
xor :: Id a -> Id a -> Id a
$cxor :: forall a. Bits a => Id a -> Id a -> Id a
.|. :: Id a -> Id a -> Id a
$c.|. :: forall a. Bits a => Id a -> Id a -> Id a
.&. :: Id a -> Id a -> Id a
$c.&. :: forall a. Bits a => Id a -> Id a -> Id a
$cp1Bits :: forall a. Bits a => Eq (Id a)
Bits, Id a
Id a -> Id a -> Bounded (Id a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Id a
maxBound :: Id a
$cmaxBound :: forall a. Bounded a => Id a
minBound :: Id a
$cminBound :: forall a. Bounded a => Id a
Bounded, Typeable (Id a)
DataType
Constr
Typeable (Id a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Id a -> c (Id a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Id a))
-> (Id a -> Constr)
-> (Id a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Id a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Id a)))
-> ((forall b. Data b => b -> b) -> Id a -> Id a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Id a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Id a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Id a -> m (Id a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Id a -> m (Id a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Id a -> m (Id a))
-> Data (Id a)
Id a -> DataType
Id a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Id a))
(forall b. Data b => b -> b) -> Id a -> Id a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Id a -> c (Id a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Id a)
forall a. Data a => Typeable (Id a)
forall a. Data a => Id a -> DataType
forall a. Data a => Id a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> Id a -> Id a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Id a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Id a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Id a -> m (Id a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Id a -> m (Id a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Id a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Id a -> c (Id a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Id a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Id 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) -> Id a -> u
forall u. (forall d. Data d => d -> u) -> Id a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Id a -> m (Id a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Id a -> m (Id a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Id a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Id a -> c (Id a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Id a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Id a))
$cId :: Constr
$tId :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Id a -> m (Id a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Id a -> m (Id a)
gmapMp :: (forall d. Data d => d -> m d) -> Id a -> m (Id a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Id a -> m (Id a)
gmapM :: (forall d. Data d => d -> m d) -> Id a -> m (Id a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Id a -> m (Id a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Id a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Id a -> u
gmapQ :: (forall d. Data d => d -> u) -> Id a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Id a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Id a -> r
gmapT :: (forall b. Data b => b -> b) -> Id a -> Id a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> Id a -> Id a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Id a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Id a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Id a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Id a))
dataTypeOf :: Id a -> DataType
$cdataTypeOf :: forall a. Data a => Id a -> DataType
toConstr :: Id a -> Constr
$ctoConstr :: forall a. Data a => Id a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Id a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Id a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Id a -> c (Id a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Id a -> c (Id a)
$cp1Data :: forall a. Data a => Typeable (Id a)
Data, Int -> Id a
Id a -> Int
Id a -> [Id a]
Id a -> Id a
Id a -> Id a -> [Id a]
Id a -> Id a -> Id a -> [Id a]
(Id a -> Id a)
-> (Id a -> Id a)
-> (Int -> Id a)
-> (Id a -> Int)
-> (Id a -> [Id a])
-> (Id a -> Id a -> [Id a])
-> (Id a -> Id a -> [Id a])
-> (Id a -> Id a -> Id a -> [Id a])
-> Enum (Id a)
forall a. Enum a => Int -> Id a
forall a. Enum a => Id a -> Int
forall a. Enum a => Id a -> [Id a]
forall a. Enum a => Id a -> Id a
forall a. Enum a => Id a -> Id a -> [Id a]
forall a. Enum a => Id a -> Id a -> Id a -> [Id 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 :: Id a -> Id a -> Id a -> [Id a]
$cenumFromThenTo :: forall a. Enum a => Id a -> Id a -> Id a -> [Id a]
enumFromTo :: Id a -> Id a -> [Id a]
$cenumFromTo :: forall a. Enum a => Id a -> Id a -> [Id a]
enumFromThen :: Id a -> Id a -> [Id a]
$cenumFromThen :: forall a. Enum a => Id a -> Id a -> [Id a]
enumFrom :: Id a -> [Id a]
$cenumFrom :: forall a. Enum a => Id a -> [Id a]
fromEnum :: Id a -> Int
$cfromEnum :: forall a. Enum a => Id a -> Int
toEnum :: Int -> Id a
$ctoEnum :: forall a. Enum a => Int -> Id a
pred :: Id a -> Id a
$cpred :: forall a. Enum a => Id a -> Id a
succ :: Id a -> Id a
$csucc :: forall a. Enum a => Id a -> Id a
Enum, Id a -> Id a -> Bool
(Id a -> Id a -> Bool) -> (Id a -> Id a -> Bool) -> Eq (Id a)
forall a. Eq a => Id a -> Id a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Id a -> Id a -> Bool
$c/= :: forall a. Eq a => Id a -> Id a -> Bool
== :: Id a -> Id a -> Bool
$c== :: forall a. Eq a => Id a -> Id a -> Bool
Eq, Bits (Id a)
Bits (Id a)
-> (Id a -> Int)
-> (Id a -> Int)
-> (Id a -> Int)
-> FiniteBits (Id a)
Id a -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
forall a. FiniteBits a => Bits (Id a)
forall a. FiniteBits a => Id a -> Int
countTrailingZeros :: Id a -> Int
$ccountTrailingZeros :: forall a. FiniteBits a => Id a -> Int
countLeadingZeros :: Id a -> Int
$ccountLeadingZeros :: forall a. FiniteBits a => Id a -> Int
finiteBitSize :: Id a -> Int
$cfiniteBitSize :: forall a. FiniteBits a => Id a -> Int
$cp1FiniteBits :: forall a. FiniteBits a => Bits (Id a)
FiniteBits, Fractional (Id a)
Id a
Fractional (Id a)
-> Id a
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> Floating (Id a)
Id a -> Id a
Id a -> Id a -> Id a
forall a. Floating a => Fractional (Id a)
forall a. Floating a => Id a
forall a. Floating a => Id a -> Id a
forall a. Floating a => Id a -> Id a -> Id a
forall a.
Fractional a
-> a
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> Floating a
log1mexp :: Id a -> Id a
$clog1mexp :: forall a. Floating a => Id a -> Id a
log1pexp :: Id a -> Id a
$clog1pexp :: forall a. Floating a => Id a -> Id a
expm1 :: Id a -> Id a
$cexpm1 :: forall a. Floating a => Id a -> Id a
log1p :: Id a -> Id a
$clog1p :: forall a. Floating a => Id a -> Id a
atanh :: Id a -> Id a
$catanh :: forall a. Floating a => Id a -> Id a
acosh :: Id a -> Id a
$cacosh :: forall a. Floating a => Id a -> Id a
asinh :: Id a -> Id a
$casinh :: forall a. Floating a => Id a -> Id a
tanh :: Id a -> Id a
$ctanh :: forall a. Floating a => Id a -> Id a
cosh :: Id a -> Id a
$ccosh :: forall a. Floating a => Id a -> Id a
sinh :: Id a -> Id a
$csinh :: forall a. Floating a => Id a -> Id a
atan :: Id a -> Id a
$catan :: forall a. Floating a => Id a -> Id a
acos :: Id a -> Id a
$cacos :: forall a. Floating a => Id a -> Id a
asin :: Id a -> Id a
$casin :: forall a. Floating a => Id a -> Id a
tan :: Id a -> Id a
$ctan :: forall a. Floating a => Id a -> Id a
cos :: Id a -> Id a
$ccos :: forall a. Floating a => Id a -> Id a
sin :: Id a -> Id a
$csin :: forall a. Floating a => Id a -> Id a
logBase :: Id a -> Id a -> Id a
$clogBase :: forall a. Floating a => Id a -> Id a -> Id a
** :: Id a -> Id a -> Id a
$c** :: forall a. Floating a => Id a -> Id a -> Id a
sqrt :: Id a -> Id a
$csqrt :: forall a. Floating a => Id a -> Id a
log :: Id a -> Id a
$clog :: forall a. Floating a => Id a -> Id a
exp :: Id a -> Id a
$cexp :: forall a. Floating a => Id a -> Id a
pi :: Id a
$cpi :: forall a. Floating a => Id a
$cp1Floating :: forall a. Floating a => Fractional (Id a)
Floating, Num (Id a)
Num (Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a)
-> (Rational -> Id a)
-> Fractional (Id a)
Rational -> Id a
Id a -> Id a
Id a -> Id a -> Id a
forall a. Fractional a => Num (Id a)
forall a. Fractional a => Rational -> Id a
forall a. Fractional a => Id a -> Id a
forall a. Fractional a => Id a -> Id a -> Id a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
fromRational :: Rational -> Id a
$cfromRational :: forall a. Fractional a => Rational -> Id a
recip :: Id a -> Id a
$crecip :: forall a. Fractional a => Id a -> Id a
/ :: Id a -> Id a -> Id a
$c/ :: forall a. Fractional a => Id a -> Id a -> Id a
$cp1Fractional :: forall a. Fractional a => Num (Id a)
Fractional
             , (forall x. Id a -> Rep (Id a) x)
-> (forall x. Rep (Id a) x -> Id a) -> Generic (Id a)
forall x. Rep (Id a) x -> Id a
forall x. Id a -> Rep (Id a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Id a) x -> Id a
forall a x. Id a -> Rep (Id a) x
$cto :: forall a x. Rep (Id a) x -> Id a
$cfrom :: forall a x. Id a -> Rep (Id a) x
Generic, (forall a. Id a -> Rep1 Id a)
-> (forall a. Rep1 Id a -> Id a) -> Generic1 Id
forall a. Rep1 Id a -> Id a
forall a. Id a -> Rep1 Id 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 Id a -> Id a
$cfrom1 :: forall a. Id a -> Rep1 Id a
Generic1, Enum (Id a)
Real (Id a)
Real (Id a)
-> Enum (Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a -> (Id a, Id a))
-> (Id a -> Id a -> (Id a, Id a))
-> (Id a -> Integer)
-> Integral (Id a)
Id a -> Integer
Id a -> Id a -> (Id a, Id a)
Id a -> Id a -> Id a
forall a. Integral a => Enum (Id a)
forall a. Integral a => Real (Id a)
forall a. Integral a => Id a -> Integer
forall a. Integral a => Id a -> Id a -> (Id a, Id a)
forall a. Integral a => Id a -> Id a -> Id a
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Id a -> Integer
$ctoInteger :: forall a. Integral a => Id a -> Integer
divMod :: Id a -> Id a -> (Id a, Id a)
$cdivMod :: forall a. Integral a => Id a -> Id a -> (Id a, Id a)
quotRem :: Id a -> Id a -> (Id a, Id a)
$cquotRem :: forall a. Integral a => Id a -> Id a -> (Id a, Id a)
mod :: Id a -> Id a -> Id a
$cmod :: forall a. Integral a => Id a -> Id a -> Id a
div :: Id a -> Id a -> Id a
$cdiv :: forall a. Integral a => Id a -> Id a -> Id a
rem :: Id a -> Id a -> Id a
$crem :: forall a. Integral a => Id a -> Id a -> Id a
quot :: Id a -> Id a -> Id a
$cquot :: forall a. Integral a => Id a -> Id a -> Id a
$cp2Integral :: forall a. Integral a => Enum (Id a)
$cp1Integral :: forall a. Integral a => Real (Id a)
Integral, String -> Id a
(String -> Id a) -> IsString (Id a)
forall a. IsString a => String -> Id a
forall a. (String -> a) -> IsString a
fromString :: String -> Id a
$cfromString :: forall a. IsString a => String -> Id a
IsString, Ord (Id a)
Ord (Id a)
-> ((Id a, Id a) -> [Id a])
-> ((Id a, Id a) -> Id a -> Int)
-> ((Id a, Id a) -> Id a -> Int)
-> ((Id a, Id a) -> Id a -> Bool)
-> ((Id a, Id a) -> Int)
-> ((Id a, Id a) -> Int)
-> Ix (Id a)
(Id a, Id a) -> Int
(Id a, Id a) -> [Id a]
(Id a, Id a) -> Id a -> Bool
(Id a, Id a) -> Id a -> Int
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. Ix a => Ord (Id a)
forall a. Ix a => (Id a, Id a) -> Int
forall a. Ix a => (Id a, Id a) -> [Id a]
forall a. Ix a => (Id a, Id a) -> Id a -> Bool
forall a. Ix a => (Id a, Id a) -> Id a -> Int
unsafeRangeSize :: (Id a, Id a) -> Int
$cunsafeRangeSize :: forall a. Ix a => (Id a, Id a) -> Int
rangeSize :: (Id a, Id a) -> Int
$crangeSize :: forall a. Ix a => (Id a, Id a) -> Int
inRange :: (Id a, Id a) -> Id a -> Bool
$cinRange :: forall a. Ix a => (Id a, Id a) -> Id a -> Bool
unsafeIndex :: (Id a, Id a) -> Id a -> Int
$cunsafeIndex :: forall a. Ix a => (Id a, Id a) -> Id a -> Int
index :: (Id a, Id a) -> Id a -> Int
$cindex :: forall a. Ix a => (Id a, Id a) -> Id a -> Int
range :: (Id a, Id a) -> [Id a]
$crange :: forall a. Ix a => (Id a, Id a) -> [Id a]
$cp1Ix :: forall a. Ix a => Ord (Id a)
Ix, Semigroup (Id a)
Id a
Semigroup (Id a)
-> Id a
-> (Id a -> Id a -> Id a)
-> ([Id a] -> Id a)
-> Monoid (Id a)
[Id a] -> Id a
Id a -> Id a -> Id a
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall a. Monoid a => Semigroup (Id a)
forall a. Monoid a => Id a
forall a. Monoid a => [Id a] -> Id a
forall a. Monoid a => Id a -> Id a -> Id a
mconcat :: [Id a] -> Id a
$cmconcat :: forall a. Monoid a => [Id a] -> Id a
mappend :: Id a -> Id a -> Id a
$cmappend :: forall a. Monoid a => Id a -> Id a -> Id a
mempty :: Id a
$cmempty :: forall a. Monoid a => Id a
$cp1Monoid :: forall a. Monoid a => Semigroup (Id a)
Monoid, Integer -> Id a
Id a -> Id a
Id a -> Id a -> Id a
(Id a -> Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Id a -> Id a)
-> (Integer -> Id a)
-> Num (Id a)
forall a. Num a => Integer -> Id a
forall a. Num a => Id a -> Id a
forall a. Num a => Id a -> Id a -> Id a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Id a
$cfromInteger :: forall a. Num a => Integer -> Id a
signum :: Id a -> Id a
$csignum :: forall a. Num a => Id a -> Id a
abs :: Id a -> Id a
$cabs :: forall a. Num a => Id a -> Id a
negate :: Id a -> Id a
$cnegate :: forall a. Num a => Id a -> Id a
* :: Id a -> Id a -> Id a
$c* :: forall a. Num a => Id a -> Id a -> Id a
- :: Id a -> Id a -> Id a
$c- :: forall a. Num a => Id a -> Id a -> Id a
+ :: Id a -> Id a -> Id a
$c+ :: forall a. Num a => Id a -> Id a -> Id a
Num, Eq (Id a)
Eq (Id a)
-> (Id a -> Id a -> Ordering)
-> (Id a -> Id a -> Bool)
-> (Id a -> Id a -> Bool)
-> (Id a -> Id a -> Bool)
-> (Id a -> Id a -> Bool)
-> (Id a -> Id a -> Id a)
-> (Id a -> Id a -> Id a)
-> Ord (Id a)
Id a -> Id a -> Bool
Id a -> Id a -> Ordering
Id a -> Id a -> Id 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 (Id a)
forall a. Ord a => Id a -> Id a -> Bool
forall a. Ord a => Id a -> Id a -> Ordering
forall a. Ord a => Id a -> Id a -> Id a
min :: Id a -> Id a -> Id a
$cmin :: forall a. Ord a => Id a -> Id a -> Id a
max :: Id a -> Id a -> Id a
$cmax :: forall a. Ord a => Id a -> Id a -> Id a
>= :: Id a -> Id a -> Bool
$c>= :: forall a. Ord a => Id a -> Id a -> Bool
> :: Id a -> Id a -> Bool
$c> :: forall a. Ord a => Id a -> Id a -> Bool
<= :: Id a -> Id a -> Bool
$c<= :: forall a. Ord a => Id a -> Id a -> Bool
< :: Id a -> Id a -> Bool
$c< :: forall a. Ord a => Id a -> Id a -> Bool
compare :: Id a -> Id a -> Ordering
$ccompare :: forall a. Ord a => Id a -> Id a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Id a)
Ord
             , Num (Id a)
Ord (Id a)
Num (Id a) -> Ord (Id a) -> (Id a -> Rational) -> Real (Id a)
Id a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall a. Real a => Num (Id a)
forall a. Real a => Ord (Id a)
forall a. Real a => Id a -> Rational
toRational :: Id a -> Rational
$ctoRational :: forall a. Real a => Id a -> Rational
$cp2Real :: forall a. Real a => Ord (Id a)
$cp1Real :: forall a. Real a => Num (Id a)
Real, Fractional (Id a)
Real (Id a)
Real (Id a)
-> Fractional (Id a)
-> (forall b. Integral b => Id a -> (b, Id a))
-> (forall b. Integral b => Id a -> b)
-> (forall b. Integral b => Id a -> b)
-> (forall b. Integral b => Id a -> b)
-> (forall b. Integral b => Id a -> b)
-> RealFrac (Id a)
Id a -> b
Id a -> b
Id a -> b
Id a -> b
Id a -> (b, Id a)
forall b. Integral b => Id a -> b
forall b. Integral b => Id a -> (b, Id a)
forall a.
Real a
-> Fractional a
-> (forall b. Integral b => a -> (b, a))
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> RealFrac a
forall a. RealFrac a => Fractional (Id a)
forall a. RealFrac a => Real (Id a)
forall a b. (RealFrac a, Integral b) => Id a -> b
forall a b. (RealFrac a, Integral b) => Id a -> (b, Id a)
floor :: Id a -> b
$cfloor :: forall a b. (RealFrac a, Integral b) => Id a -> b
ceiling :: Id a -> b
$cceiling :: forall a b. (RealFrac a, Integral b) => Id a -> b
round :: Id a -> b
$cround :: forall a b. (RealFrac a, Integral b) => Id a -> b
truncate :: Id a -> b
$ctruncate :: forall a b. (RealFrac a, Integral b) => Id a -> b
properFraction :: Id a -> (b, Id a)
$cproperFraction :: forall a b. (RealFrac a, Integral b) => Id a -> (b, Id a)
$cp2RealFrac :: forall a. RealFrac a => Fractional (Id a)
$cp1RealFrac :: forall a. RealFrac a => Real (Id a)
RealFrac, Floating (Id a)
RealFrac (Id a)
RealFrac (Id a)
-> Floating (Id a)
-> (Id a -> Integer)
-> (Id a -> Int)
-> (Id a -> (Int, Int))
-> (Id a -> (Integer, Int))
-> (Integer -> Int -> Id a)
-> (Id a -> Int)
-> (Id a -> Id a)
-> (Int -> Id a -> Id a)
-> (Id a -> Bool)
-> (Id a -> Bool)
-> (Id a -> Bool)
-> (Id a -> Bool)
-> (Id a -> Bool)
-> (Id a -> Id a -> Id a)
-> RealFloat (Id a)
Int -> Id a -> Id a
Integer -> Int -> Id a
Id a -> Bool
Id a -> Int
Id a -> Integer
Id a -> (Int, Int)
Id a -> (Integer, Int)
Id a -> Id a
Id a -> Id a -> Id a
forall a. RealFloat a => Floating (Id a)
forall a. RealFloat a => RealFrac (Id a)
forall a. RealFloat a => Int -> Id a -> Id a
forall a. RealFloat a => Integer -> Int -> Id a
forall a. RealFloat a => Id a -> Bool
forall a. RealFloat a => Id a -> Int
forall a. RealFloat a => Id a -> Integer
forall a. RealFloat a => Id a -> (Int, Int)
forall a. RealFloat a => Id a -> (Integer, Int)
forall a. RealFloat a => Id a -> Id a
forall a. RealFloat a => Id a -> Id a -> Id a
forall a.
RealFrac a
-> Floating a
-> (a -> Integer)
-> (a -> Int)
-> (a -> (Int, Int))
-> (a -> (Integer, Int))
-> (Integer -> Int -> a)
-> (a -> Int)
-> (a -> a)
-> (Int -> a -> a)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> a -> a)
-> RealFloat a
atan2 :: Id a -> Id a -> Id a
$catan2 :: forall a. RealFloat a => Id a -> Id a -> Id a
isIEEE :: Id a -> Bool
$cisIEEE :: forall a. RealFloat a => Id a -> Bool
isNegativeZero :: Id a -> Bool
$cisNegativeZero :: forall a. RealFloat a => Id a -> Bool
isDenormalized :: Id a -> Bool
$cisDenormalized :: forall a. RealFloat a => Id a -> Bool
isInfinite :: Id a -> Bool
$cisInfinite :: forall a. RealFloat a => Id a -> Bool
isNaN :: Id a -> Bool
$cisNaN :: forall a. RealFloat a => Id a -> Bool
scaleFloat :: Int -> Id a -> Id a
$cscaleFloat :: forall a. RealFloat a => Int -> Id a -> Id a
significand :: Id a -> Id a
$csignificand :: forall a. RealFloat a => Id a -> Id a
exponent :: Id a -> Int
$cexponent :: forall a. RealFloat a => Id a -> Int
encodeFloat :: Integer -> Int -> Id a
$cencodeFloat :: forall a. RealFloat a => Integer -> Int -> Id a
decodeFloat :: Id a -> (Integer, Int)
$cdecodeFloat :: forall a. RealFloat a => Id a -> (Integer, Int)
floatRange :: Id a -> (Int, Int)
$cfloatRange :: forall a. RealFloat a => Id a -> (Int, Int)
floatDigits :: Id a -> Int
$cfloatDigits :: forall a. RealFloat a => Id a -> Int
floatRadix :: Id a -> Integer
$cfloatRadix :: forall a. RealFloat a => Id a -> Integer
$cp2RealFloat :: forall a. RealFloat a => Floating (Id a)
$cp1RealFloat :: forall a. RealFloat a => RealFrac (Id a)
RealFloat, b -> Id a -> Id a
NonEmpty (Id a) -> Id a
Id a -> Id a -> Id a
(Id a -> Id a -> Id a)
-> (NonEmpty (Id a) -> Id a)
-> (forall b. Integral b => b -> Id a -> Id a)
-> Semigroup (Id a)
forall b. Integral b => b -> Id a -> Id a
forall a. Semigroup a => NonEmpty (Id a) -> Id a
forall a. Semigroup a => Id a -> Id a -> Id a
forall a b. (Semigroup a, Integral b) => b -> Id a -> Id a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> Id a -> Id a
$cstimes :: forall a b. (Semigroup a, Integral b) => b -> Id a -> Id a
sconcat :: NonEmpty (Id a) -> Id a
$csconcat :: forall a. Semigroup a => NonEmpty (Id a) -> Id a
<> :: Id a -> Id a -> Id a
$c<> :: forall a. Semigroup a => Id a -> Id a -> Id a
Semigroup, Ptr b -> Int -> IO (Id a)
Ptr b -> Int -> Id a -> IO ()
Ptr (Id a) -> IO (Id a)
Ptr (Id a) -> Int -> IO (Id a)
Ptr (Id a) -> Int -> Id a -> IO ()
Ptr (Id a) -> Id a -> IO ()
Id a -> Int
(Id a -> Int)
-> (Id a -> Int)
-> (Ptr (Id a) -> Int -> IO (Id a))
-> (Ptr (Id a) -> Int -> Id a -> IO ())
-> (forall b. Ptr b -> Int -> IO (Id a))
-> (forall b. Ptr b -> Int -> Id a -> IO ())
-> (Ptr (Id a) -> IO (Id a))
-> (Ptr (Id a) -> Id a -> IO ())
-> Storable (Id a)
forall b. Ptr b -> Int -> IO (Id a)
forall b. Ptr b -> Int -> Id a -> IO ()
forall a. Storable a => Ptr (Id a) -> IO (Id a)
forall a. Storable a => Ptr (Id a) -> Int -> IO (Id a)
forall a. Storable a => Ptr (Id a) -> Int -> Id a -> IO ()
forall a. Storable a => Ptr (Id a) -> Id a -> IO ()
forall a. Storable a => Id a -> Int
forall a b. Storable a => Ptr b -> Int -> IO (Id a)
forall a b. Storable a => Ptr b -> Int -> Id a -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr (Id a) -> Id a -> IO ()
$cpoke :: forall a. Storable a => Ptr (Id a) -> Id a -> IO ()
peek :: Ptr (Id a) -> IO (Id a)
$cpeek :: forall a. Storable a => Ptr (Id a) -> IO (Id a)
pokeByteOff :: Ptr b -> Int -> Id a -> IO ()
$cpokeByteOff :: forall a b. Storable a => Ptr b -> Int -> Id a -> IO ()
peekByteOff :: Ptr b -> Int -> IO (Id a)
$cpeekByteOff :: forall a b. Storable a => Ptr b -> Int -> IO (Id a)
pokeElemOff :: Ptr (Id a) -> Int -> Id a -> IO ()
$cpokeElemOff :: forall a. Storable a => Ptr (Id a) -> Int -> Id a -> IO ()
peekElemOff :: Ptr (Id a) -> Int -> IO (Id a)
$cpeekElemOff :: forall a. Storable a => Ptr (Id a) -> Int -> IO (Id a)
alignment :: Id a -> Int
$calignment :: forall a. Storable a => Id a -> Int
sizeOf :: Id a -> Int
$csizeOf :: forall a. Storable a => Id a -> Int
Storable, Functor Id
Foldable Id
Functor Id
-> Foldable Id
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Id a -> f (Id b))
-> (forall (f :: * -> *) a. Applicative f => Id (f a) -> f (Id a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Id a -> m (Id b))
-> (forall (m :: * -> *) a. Monad m => Id (m a) -> m (Id a))
-> Traversable Id
(a -> f b) -> Id a -> f (Id 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 => Id (m a) -> m (Id a)
forall (f :: * -> *) a. Applicative f => Id (f a) -> f (Id a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> Id a -> m (Id b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Id a -> f (Id b)
sequence :: Id (m a) -> m (Id a)
$csequence :: forall (m :: * -> *) a. Monad m => Id (m a) -> m (Id a)
mapM :: (a -> m b) -> Id a -> m (Id b)
$cmapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> Id a -> m (Id b)
sequenceA :: Id (f a) -> f (Id a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Id (f a) -> f (Id a)
traverse :: (a -> f b) -> Id a -> f (Id b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Id a -> f (Id b)
$cp2Traversable :: Foldable Id
$cp1Traversable :: Functor Id
Traversable)


instance Read a => Read (Id a) where
    readsPrec :: Int -> ReadS (Id a)
readsPrec Int
d = ((a, String) -> (Id a, String))
-> [(a, String)] -> [(Id a, String)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> Id a) -> (a, String) -> (Id a, String)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first a -> Id a
forall a. a -> Id a
Id) ([(a, String)] -> [(Id a, String)])
-> (String -> [(a, String)]) -> ReadS (Id a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String -> [(a, String)]
forall a. Read a => Int -> ReadS a
readsPrec Int
d

instance Show a => Show (Id a) where
    showsPrec :: Int -> Id a -> ShowS
showsPrec Int
d = Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
d (a -> ShowS) -> (Id a -> a) -> Id a -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Id a -> a
forall a. Id a -> a
runId

instance Read1 Id where
    liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Id a)
liftReadPrec ReadPrec a
r ReadPrec [a]
_ = ReadPrec a -> ReadPrec (Id a)
coerce ReadPrec a
r
    liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Id a]
liftReadListPrec = ReadPrec a -> ReadPrec [a] -> ReadPrec [Id a]
forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
    liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Id a]
liftReadList     = (Int -> ReadS a) -> ReadS [a] -> ReadS [Id a]
forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault

instance Show1 Id where
    liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Id a -> ShowS
liftShowsPrec Int -> a -> ShowS
f [a] -> ShowS
_ = (Int -> a -> ShowS) -> Int -> Id a -> ShowS
coerce Int -> a -> ShowS
f

instance Eq1 Id where
    liftEq :: (a -> b -> Bool) -> Id a -> Id b -> Bool
liftEq = (a -> b -> Bool) -> Id a -> Id b -> Bool
coerce

instance Ord1 Id where
    liftCompare :: (a -> b -> Ordering) -> Id a -> Id b -> Ordering
liftCompare = (a -> b -> Ordering) -> Id a -> Id b -> Ordering
coerce

instance Foldable Id where
    foldMap :: (a -> m) -> Id a -> m
foldMap          = (a -> m) -> Id a -> m
coerce
    elem :: a -> Id a -> Bool
elem             = (a -> a -> Bool) -> a -> Id a -> Bool
forall a. (a -> a -> Bool) -> a -> Id a -> Bool
k a -> a -> Bool
forall a. Eq a => a -> a -> Bool
(==)
      where
        k :: (a -> a -> Bool) -> a -> Id a -> Bool
        k :: (a -> a -> Bool) -> a -> Id a -> Bool
k = (a -> a -> Bool) -> a -> Id a -> Bool
coerce
    foldl :: (b -> a -> b) -> b -> Id a -> b
foldl            = (b -> a -> b) -> b -> Id a -> b
coerce
    foldl' :: (b -> a -> b) -> b -> Id a -> b
foldl'           = (b -> a -> b) -> b -> Id a -> b
coerce
    foldl1 :: (a -> a -> a) -> Id a -> a
foldl1 a -> a -> a
_         = Id a -> a
coerce
    foldr :: (a -> b -> b) -> b -> Id a -> b
foldr a -> b -> b
f b
z (Id a
x) = a -> b -> b
f a
x b
z
    foldr' :: (a -> b -> b) -> b -> Id a -> b
foldr'           = (a -> b -> b) -> b -> Id a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr
    foldr1 :: (a -> a -> a) -> Id a -> a
foldr1 a -> a -> a
_         = Id a -> a
coerce
    length :: Id a -> Int
length Id a
_         = Int
1
    maximum :: Id a -> a
maximum          = Id a -> a
coerce
    minimum :: Id a -> a
minimum          = Id a -> a
coerce
    null :: Id a -> Bool
null Id a
_           = Bool
False
    product :: Id a -> a
product          = Id a -> a
coerce
    sum :: Id a -> a
sum              = Id a -> a
coerce
    toList :: Id a -> [a]
toList (Id a
x)    = [a
x]

instance Functor Id where
    fmap :: (a -> b) -> Id a -> Id b
fmap     = (a -> b) -> Id a -> Id b
coerce

instance Applicative Id where
    pure :: a -> Id a
pure     = a -> Id a
forall a. a -> Id a
Id
    <*> :: Id (a -> b) -> Id a -> Id b
(<*>)    = Id (a -> b) -> Id a -> Id b
coerce

instance Monad Id where
    Id a
m >>= :: Id a -> (a -> Id b) -> Id b
>>= a -> Id b
k  = a -> Id b
k (Id a -> a
forall a. Id a -> a
runId Id a
m)

instance MonadFix Id where
    mfix :: (a -> Id a) -> Id a
mfix a -> Id a
f   = a -> Id a
forall a. a -> Id a
Id ((a -> a) -> a
forall a. (a -> a) -> a
fix (Id a -> a
forall a. Id a -> a
runId (Id a -> a) -> (a -> Id a) -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Id a
f))

instance MonadZip Id where
    mzipWith :: (a -> b -> c) -> Id a -> Id b -> Id c
mzipWith = (a -> b -> c) -> Id a -> Id b -> Id c
coerce
    munzip :: Id (a, b) -> (Id a, Id b)
munzip   = Id (a, b) -> (Id a, Id b)
coerce




-- | A tuple indexed by a list of types
type Tuple = (TypedList Id :: [Type] -> Type)

{-# COMPLETE U, (:$) #-}
{-# COMPLETE U, (:!) #-}
{-# COMPLETE Empty, (:$) #-}
{-# COMPLETE Empty, (:!) #-}


-- | Constructing a type-indexed list
pattern (:$) :: forall (xs :: [Type])
              . ()
             => forall (y :: Type) (ys :: [Type])
              . (xs ~ (y ': ys)) => y -> Tuple ys -> Tuple xs
pattern $b:$ :: y -> Tuple ys -> Tuple xs
$m:$ :: forall r (xs :: [*]).
Tuple xs
-> (forall y (ys :: [*]). (xs ~ (y : ys)) => y -> Tuple ys -> r)
-> (Void# -> r)
-> r
(:$) x xs <- (Id x :* xs)
  where
    (:$) = y -> Tuple ys -> Tuple xs
forall x (xs :: [*]). x -> Tuple xs -> Tuple (x :+ xs)
(*$)
infixr 5 :$

-- | Constructing a type-indexed list
pattern (:!) :: forall (xs :: [Type])
              . ()
             => forall (y :: Type) (ys :: [Type])
              . (xs ~ (y ': ys)) => y -> Tuple ys -> Tuple xs
pattern $b:! :: y -> Tuple ys -> Tuple xs
$m:! :: forall r (xs :: [*]).
Tuple xs
-> (forall y (ys :: [*]). (xs ~ (y : ys)) => y -> Tuple ys -> r)
-> (Void# -> r)
-> r
(:!) x xs <- (forceCons -> Id x :* xs)
  where
    (:!) = y -> Tuple ys -> Tuple xs
forall x (xs :: [*]). x -> Tuple xs -> Tuple (x :+ xs)
(*!)
infixr 5 :!


-- | Grow a tuple on the left O(1).
(*$) :: x -> Tuple xs -> Tuple (x :+ xs)
*$ :: x -> Tuple xs -> Tuple (x :+ xs)
(*$) x
x Tuple xs
xs = [Any] -> Tuple (x :+ xs)
forall a b. a -> b
unsafeCoerce (x -> Any
forall a b. a -> b
unsafeCoerce x
x Any -> [Any] -> [Any]
forall a. a -> [a] -> [a]
: Tuple xs -> [Any]
forall a b. a -> b
unsafeCoerce Tuple xs
xs :: [Any])
{-# INLINE (*$) #-}
infixr 5 *$

-- | Grow a tuple on the left while evaluating arguments to WHNF O(1).
(*!) :: x -> Tuple xs -> Tuple (x :+ xs)
*! :: x -> Tuple xs -> Tuple (x :+ xs)
(*!) !x
x !Tuple xs
xs = let !r :: [Any]
r = x -> Any
forall a b. a -> b
unsafeCoerce x
x Any -> [Any] -> [Any]
forall a. a -> [a] -> [a]
: Tuple xs -> [Any]
forall a b. a -> b
unsafeCoerce Tuple xs
xs :: [Any]
              in [Any] -> Tuple (x :+ xs)
forall a b. a -> b
unsafeCoerce [Any]
r
{-# INLINE (*!) #-}
infixr 5 *!

-- | Grow a tuple on the right.
--   Note, it traverses an element list inside O(n).
($*) :: Tuple xs -> x -> Tuple (xs +: x)
$* :: Tuple xs -> x -> Tuple (xs +: x)
($*) Tuple xs
xs x
x = [Any] -> Tuple (xs +: x)
forall a b. a -> b
unsafeCoerce (Tuple xs -> [Any]
forall a b. a -> b
unsafeCoerce Tuple xs
xs [Any] -> [Any] -> [Any]
forall a. [a] -> [a] -> [a]
++ [x -> Any
forall a b. a -> b
unsafeCoerce x
x] :: [Any])
{-# INLINE ($*) #-}
infixl 5 $*

-- | Grow a tuple on the right while evaluating arguments to WHNF.
--   Note, it traverses an element list inside O(n).
(!*) :: Tuple xs -> x -> Tuple (xs +: x)
!* :: Tuple xs -> x -> Tuple (xs +: x)
(!*) !Tuple xs
xs !x
x = let !r :: [Any]
r = Any -> [Any] -> [Any]
go (x -> Any
forall a b. a -> b
unsafeCoerce x
x) (Tuple xs -> [Any]
forall a b. a -> b
unsafeCoerce Tuple xs
xs) :: [Any]
                  go :: Any -> [Any] -> [Any]
                  go :: Any -> [Any] -> [Any]
go Any
z []       = Any
z Any -> [Any] -> [Any]
`seq` [Any
z]
                  go Any
z (Any
y : [Any]
ys) = Any
y Any -> [Any] -> [Any]
`seq` Any
y Any -> [Any] -> [Any]
forall a. a -> [a] -> [a]
: Any -> [Any] -> [Any]
go Any
z [Any]
ys
              in [Any] -> Tuple (xs +: x)
forall a b. a -> b
unsafeCoerce [Any]
r
{-# INLINE (!*) #-}
infixl 5 !*


instance All Semigroup xs => Sem.Semigroup (Tuple xs) where
    Tuple xs
U <> :: Tuple xs -> Tuple xs -> Tuple xs
<> Tuple xs
U = Tuple xs
forall k (f :: k -> *) (xs :: [k]). (xs ~ '[]) => TypedList f xs
U
    (y
x :$ Tuple ys
xs) <> (y
y :$ Tuple ys
ys) = (y
x y -> y -> y
forall a. Semigroup a => a -> a -> a
<> y
y
y) y -> Tuple ys -> Tuple (y :+ ys)
forall x (xs :: [*]). x -> Tuple xs -> Tuple (x :+ xs)
*$ ( Tuple ys
xs Tuple ys -> Tuple ys -> Tuple ys
forall a. Semigroup a => a -> a -> a
<> Tuple ys
Tuple ys
ys)

instance ( RepresentableList xs
         , All Semigroup xs
         , All Monoid xs) => Mon.Monoid (Tuple xs) where
    mempty :: Tuple xs
mempty = TypeList xs -> Tuple xs
forall (ys :: [*]). All Monoid ys => TypeList ys -> Tuple ys
go (RepresentableList xs => TypeList xs
forall k (xs :: [k]). RepresentableList xs => TypeList xs
tList @xs)
      where
        go :: forall (ys :: [Type])
            . All Monoid ys => TypeList ys -> Tuple ys
        go :: TypeList ys -> Tuple ys
go TypeList ys
U         = Tuple ys
forall k (f :: k -> *) (xs :: [k]). (xs ~ '[]) => TypedList f xs
U
        go (Proxy y
_ :* TypedList Proxy ys
xs) = y
forall a. Monoid a => a
mempty y -> Tuple ys -> Tuple (y :+ ys)
forall x (xs :: [*]). x -> Tuple xs -> Tuple (x :+ xs)
*$ TypedList Proxy ys -> Tuple ys
forall (ys :: [*]). All Monoid ys => TypeList ys -> Tuple ys
go TypedList Proxy ys
xs
#if !(MIN_VERSION_base(4,11,0))
    mappend = (<>)
#endif


instance (RepresentableList xs, All Bounded xs) => Bounded (Tuple xs) where
    minBound :: Tuple xs
minBound = TypeList xs -> Tuple xs
forall (ys :: [*]). All Bounded ys => TypeList ys -> Tuple ys
go (RepresentableList xs => TypeList xs
forall k (xs :: [k]). RepresentableList xs => TypeList xs
tList @xs)
      where
        go :: forall (ys :: [Type])
            . All Bounded ys => TypeList ys -> Tuple ys
        go :: TypeList ys -> Tuple ys
go TypeList ys
U         = Tuple ys
forall k (f :: k -> *) (xs :: [k]). (xs ~ '[]) => TypedList f xs
U
        go (Proxy y
_ :* TypedList Proxy ys
xs) = y
forall a. Bounded a => a
minBound y -> Tuple ys -> Tuple (y :+ ys)
forall x (xs :: [*]). x -> Tuple xs -> Tuple (x :+ xs)
*$ TypedList Proxy ys -> Tuple ys
forall (ys :: [*]). All Bounded ys => TypeList ys -> Tuple ys
go TypedList Proxy ys
xs
    maxBound :: Tuple xs
maxBound = TypeList xs -> Tuple xs
forall (ys :: [*]). All Bounded ys => TypeList ys -> Tuple ys
go (RepresentableList xs => TypeList xs
forall k (xs :: [k]). RepresentableList xs => TypeList xs
tList @xs)
      where
        go :: forall (ys :: [Type])
            . All Bounded ys => TypeList ys -> Tuple ys
        go :: TypeList ys -> Tuple ys
go TypeList ys
U         = Tuple ys
forall k (f :: k -> *) (xs :: [k]). (xs ~ '[]) => TypedList f xs
U
        go (Proxy y
_ :* TypedList Proxy ys
xs) = y
forall a. Bounded a => a
maxBound y -> Tuple ys -> Tuple (y :+ ys)
forall x (xs :: [*]). x -> Tuple xs -> Tuple (x :+ xs)
*$ TypedList Proxy ys -> Tuple ys
forall (ys :: [*]). All Bounded ys => TypeList ys -> Tuple ys
go TypedList Proxy ys
xs

instance All Eq xs => Eq (Tuple xs) where
    == :: Tuple xs -> Tuple xs -> Bool
(==) Tuple xs
U Tuple xs
U                 = Bool
True
    (==) (Id y
x :* TypedList Id ys
tx) (Id y
y :* TypedList Id ys
ty) = Id y -> Id y -> Bool
forall (f :: * -> *) a. (Eq1 f, Eq a) => f a -> f a -> Bool
eq1 Id y
x Id y
Id y
y Bool -> Bool -> Bool
&& TypedList Id ys
tx TypedList Id ys -> TypedList Id ys -> Bool
forall a. Eq a => a -> a -> Bool
== TypedList Id ys
TypedList Id ys
ty
    /= :: Tuple xs -> Tuple xs -> Bool
(/=) Tuple xs
U Tuple xs
U                 = Bool
False
    (/=) (Id y
x :* TypedList Id ys
tx) (Id y
y :* TypedList Id ys
ty) = Bool -> Bool
not (Id y -> Id y -> Bool
forall (f :: * -> *) a. (Eq1 f, Eq a) => f a -> f a -> Bool
eq1 Id y
x Id y
Id y
y) Bool -> Bool -> Bool
|| TypedList Id ys
tx TypedList Id ys -> TypedList Id ys -> Bool
forall a. Eq a => a -> a -> Bool
/= TypedList Id ys
TypedList Id ys
ty

-- | Lexicorgaphic ordering; same as normal Haskell lists.
instance (All Eq xs, All Ord xs) => Ord (Tuple xs) where
    compare :: Tuple xs -> Tuple xs -> Ordering
compare Tuple xs
U Tuple xs
U                 = Ordering
EQ
    compare (Id y
x :* TypedList Id ys
tx) (Id y
y :* TypedList Id ys
ty) = Id y -> Id y -> Ordering
forall (f :: * -> *) a. (Ord1 f, Ord a) => f a -> f a -> Ordering
compare1 Id y
x Id y
Id y
y Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> TypedList Id ys -> TypedList Id ys -> Ordering
forall a. Ord a => a -> a -> Ordering
compare TypedList Id ys
tx TypedList Id ys
TypedList Id ys
ty

instance All Show xs => Show (Tuple xs) where
   showsPrec :: Int -> Tuple xs -> ShowS
showsPrec = String
-> (forall a. Show a => Int -> Id a -> ShowS)
-> Int
-> Tuple xs
-> ShowS
forall k (c :: k -> Constraint) (f :: k -> *) (xs :: [k]).
All c xs =>
String
-> (forall (x :: k). c x => Int -> f x -> ShowS)
-> Int
-> TypedList f xs
-> ShowS
typedListShowsPrecC @Show String
":$" forall a. Show a => Int -> Id a -> ShowS
forall (f :: * -> *) a. (Show1 f, Show a) => Int -> f a -> ShowS
showsPrec1

instance (All Read xs, RepresentableList xs) => Read (Tuple xs) where
   readPrec :: ReadPrec (Tuple xs)
readPrec = String
-> (forall a. Read a => ReadPrec (Id a))
-> TypedList Proxy xs
-> ReadPrec (Tuple xs)
forall k (c :: k -> Constraint) (f :: k -> *) (xs :: [k])
       (g :: k -> *).
All c xs =>
String
-> (forall (x :: k). c x => ReadPrec (f x))
-> TypedList g xs
-> ReadPrec (TypedList f xs)
typedListReadPrec @Read String
":$" forall a. Read a => ReadPrec (Id a)
forall (f :: * -> *) a. (Read1 f, Read a) => ReadPrec (f a)
readPrec1 (RepresentableList xs => TypedList Proxy xs
forall k (xs :: [k]). RepresentableList xs => TypeList xs
tList @xs)
   readList :: ReadS [Tuple xs]
readList = ReadS [Tuple xs]
forall a. Read a => ReadS [a]
P.readListDefault
   readListPrec :: ReadPrec [Tuple xs]
readListPrec = ReadPrec [Tuple xs]
forall a. Read a => ReadPrec [a]
P.readListPrecDefault

--------------------------------------------------------------------------------
-- internal
--------------------------------------------------------------------------------

forceCons :: Tuple xs -> Tuple xs
forceCons :: Tuple xs -> Tuple xs
forceCons Tuple xs
U            = Tuple xs
forall k (f :: k -> *) (xs :: [k]). (xs ~ '[]) => TypedList f xs
U
forceCons (Id y
x :* TypedList Id ys
xs) = y
x y -> Tuple xs -> Tuple xs
`seq` TypedList Id ys
xs TypedList Id ys -> Tuple xs -> Tuple xs
`seq` (y -> Id y
forall a. a -> Id a
Id y
x Id y -> TypedList Id ys -> Tuple xs
forall k (f :: k -> *) (xs :: [k]) (y :: k) (ys :: [k]).
(xs ~ (y : ys)) =>
f y -> TypedList f ys -> TypedList f xs
:* TypedList Id ys
xs)