lol-0.4.0.0: A library for lattice cryptography.

Safe HaskellNone
LanguageHaskell2010

Crypto.Lol.Prelude

Contents

Description

\( \def\Z{\mathbb{Z}} \) \( \def\C{\mathbb{C}} \)

A substitute for the Prelude that is more suitable for Lol. This module exports most of the Numeric Prelude and other frequently used modules, plus some low-level classes, missing instances, and assorted utility functions.

Synopsis

Classes and families

class Enumerable a where Source #

Poor man's Enum.

Minimal complete definition

values

Methods

values :: [a] Source #

Instances

GFCtx k fp d => Enumerable (GF k fp d) Source # 

Methods

values :: [GF k fp d] Source #

(Reflects k q z, ToInteger z, Enum z) => Enumerable (ZqBasic k q z) Source # 

Methods

values :: [ZqBasic k q z] Source #

class (ToInteger (ModRep a), Additive a) => Mod a where Source #

Represents a quotient group modulo some integer.

Minimal complete definition

modulus

Associated Types

type ModRep a Source #

Methods

modulus :: Tagged a (ModRep a) Source #

Instances

(Mod a, Mod b) => Mod (a, b) Source #

Product ring of \(\Z_q\)s as a \(\Z_q\) (with Integer modulus)

Associated Types

type ModRep (a, b) :: * Source #

Methods

modulus :: Tagged * (a, b) (ModRep (a, b)) Source #

(Reflects k q z, ToInteger z) => Mod (ZqBasic k q z) Source # 

Associated Types

type ModRep (ZqBasic k q z) :: * Source #

Methods

modulus :: Tagged * (ZqBasic k q z) (ModRep (ZqBasic k q z)) Source #

class (Additive a, Additive b) => Subgroup a b where Source #

Represents that a is a subgroup of b.

Minimal complete definition

fromSubgroup

Methods

fromSubgroup :: a -> b Source #

Instances

(ToInteger i, RealField r, Reflects k q i, Reflects k q r) => Subgroup (ZqBasic k q i) (RRq k q r) Source # 

Methods

fromSubgroup :: ZqBasic k q i -> RRq k q r Source #

class (Additive a, Additive b) => Reduce a b where Source #

Represents that b is a quotient group of a.

Minimal complete definition

reduce

Methods

reduce :: a -> b Source #

Instances

(Reduce a b1, Reduce a b2) => Reduce a (b1, b2) Source #

Reduce into product ring.

Methods

reduce :: a -> (b1, b2) Source #

(Reflects k q z, ToInteger z, Additive (ZqBasic k q z)) => Reduce Integer (ZqBasic k q z) Source # 

Methods

reduce :: Integer -> ZqBasic k q z Source #

(Reflects k q z, ToInteger z) => Reduce z (ZqBasic k q z) Source # 

Methods

reduce :: z -> ZqBasic k q z Source #

(Reflects k q r, RealField r, Additive (RRq k q r)) => Reduce r (RRq k q r) Source # 

Methods

reduce :: r -> RRq k q r Source #

(Reduce a b, Fact m, CElt t a, CElt t b) => Reduce (Cyc t m a) (Cyc t m b) Source # 

Methods

reduce :: Cyc t m a -> Cyc t m b Source #

(Reduce a b, Tensor t, Fact m, TElt t a, TElt t b) => Reduce (UCyc t m D a) (UCyc t m D b) Source # 

Methods

reduce :: UCyc t m D a -> UCyc t m D b Source #

(Reduce a b, Tensor t, Fact m, TElt t a, TElt t b) => Reduce (UCyc t m P a) (UCyc t m P b) Source # 

Methods

reduce :: UCyc t m P a -> UCyc t m P b Source #

(Reduce z zq, Fact s, CElt t z, CElt t zq) => Reduce (Linear t z e r s) (Linear t zq e r s) Source # 

Methods

reduce :: Linear t z e r s -> Linear t zq e r s Source #

type family LiftOf b Source #

The type of representatives of b.

Instances

type LiftOf (a, b) Source # 
type LiftOf (a, b) = Integer
type LiftOf (ZqBasic k q z) Source # 
type LiftOf (ZqBasic k q z) = z
type LiftOf (RRq k q r) Source # 
type LiftOf (RRq k q r) = r
type LiftOf (Cyc t m r) Source # 
type LiftOf (Cyc t m r) = Cyc t m (LiftOf r)
type LiftOf (UCyc t m D r) Source # 
type LiftOf (UCyc t m D r) = UCyc t m D (LiftOf r)
type LiftOf (UCyc t m P r) Source # 
type LiftOf (UCyc t m P r) = UCyc t m P (LiftOf r)
type LiftOf (Linear t zp e r s) Source # 
type LiftOf (Linear t zp e r s) = Linear t (LiftOf zp) e r s

type Lift b a = (Lift' b, LiftOf b ~ a) Source #

Represents that b can be lifted to a "short" a congruent to b.

class Reduce (LiftOf b) b => Lift' b where Source #

Fun-dep version of Lift.

Minimal complete definition

lift

Methods

lift :: b -> LiftOf b Source #

Instances

(Mod a, Mod b, Lift' a, Lift' b, Reduce Integer (a, b), ToInteger (LiftOf a), ToInteger (LiftOf b)) => Lift' (a, b) Source #

Lift product ring of \(\Z_q\)s to Integer

Methods

lift :: (a, b) -> LiftOf (a, b) Source #

(Reflects k q z, ToInteger z) => Lift' (ZqBasic k q z) Source # 

Methods

lift :: ZqBasic k q z -> LiftOf (ZqBasic k q z) Source #

(Reflects k q r, Reduce r (RRq k q r), Ord r, Ring r) => Lift' (RRq k q r) Source # 

Methods

lift :: RRq k q r -> LiftOf (RRq k q r) Source #

(Lift' r, Tensor t, Fact m, TElt t r, TElt t (LiftOf r)) => Lift' (UCyc t m D r) Source # 

Methods

lift :: UCyc t m D r -> LiftOf (UCyc t m D r) Source #

(Lift' r, Tensor t, Fact m, TElt t r, TElt t (LiftOf r)) => Lift' (UCyc t m P r) Source # 

Methods

lift :: UCyc t m P r -> LiftOf (UCyc t m P r) Source #

(CElt t zp, CElt t z, (~) * z (LiftOf zp), Lift zp z, Fact s) => Lift' (Linear t zp e r s) Source #

lifts with respect to powerful basis, for best geometry

Methods

lift :: Linear t zp e r s -> LiftOf (Linear t zp e r s) Source #

class (Additive a, Additive b) => Rescale a b where Source #

Represents that a can be rescaled to b, as an "approximate" additive homomorphism.

Minimal complete definition

rescale

Methods

rescale :: a -> b Source #

Instances

(Ring b, Mod a, Reduce (ModRep a) b) => Rescale b (a, b) Source #

Rescale up to a product ring of \(\Z_q\)s

Methods

rescale :: b -> (a, b) Source #

(Ring a, Mod b, Reduce (ModRep b) a) => Rescale a (a, b) Source #

Rescale up to a product ring of \(\Z_q\)s

Methods

rescale :: a -> (a, b) Source #

(Rescale ((a, b), c) (a, b), Rescale (a, b) a, Additive a, Additive c) => Rescale ((a, b), c) a Source #

Rescale a (multi-)product ring of \(\Z_q\)s

Methods

rescale :: ((a, b), c) -> a Source #

(Rescale (a, (b, c)) (b, c), Rescale (b, c) c, Additive a, Additive c) => Rescale (a, (b, c)) c Source #

Rescale a (multi-)product ring of \(\Z_q\)s

Methods

rescale :: (a, (b, c)) -> c Source #

(Mod b, Field a, Lift b (ModRep b), Reduce (LiftOf b) a) => Rescale (a, b) a Source #

Rescale a product ring of \(\Z_q\)s

Methods

rescale :: (a, b) -> a Source #

(Mod a, Field b, Lift a (ModRep a), Reduce (LiftOf a) b) => Rescale (a, b) b Source #

Rescale a product ring of \(\Z_q\)s

Methods

rescale :: (a, b) -> b Source #

(Reflects k q z, ToInteger z, Reflects k1 q' z, Ring z) => Rescale (ZqBasic k q z) (ZqBasic k1 q' z) Source # 

Methods

rescale :: ZqBasic k q z -> ZqBasic k1 q' z Source #

(Rescale a b, Tensor t, Fact m, TElt t a, TElt t b) => Rescale (UCyc t m D a) (UCyc t m D b) Source # 

Methods

rescale :: UCyc t m D a -> UCyc t m D b Source #

(Rescale a b, Tensor t, Fact m, TElt t a, TElt t b) => Rescale (UCyc t m P a) (UCyc t m P b) Source # 

Methods

rescale :: UCyc t m P a -> UCyc t m P b Source #

class (Field src, Field tgt) => Encode src tgt where Source #

Represents that the target ring can "noisily encode" values from the source ring, in either "most significant digit" (MSD) or "least significant digit" (LSD) encodings, and provides conversion factors between the two types of encodings.

Minimal complete definition

lsdToMSD

Methods

lsdToMSD :: (src, tgt) Source #

The factor that converts an element from LSD to MSD encoding in the target field, with associated scale factor to apply to correct the resulting encoded value.

Instances

(Encode s t1, Encode s t2, Field (t1, t2)) => Encode s (t1, t2) Source #

Encode for a product ring

Methods

lsdToMSD :: (s, (t1, t2)) Source #

(Reflects k p z, Reflects k1 q z, ToInteger z, Field (ZqBasic k1 q z), Field (ZqBasic k p z)) => Encode (ZqBasic k p z) (ZqBasic k1 q z) Source # 

Methods

lsdToMSD :: (ZqBasic k p z, ZqBasic k1 q z) Source #

msdToLSD :: Encode src tgt => (src, tgt) Source #

Inverted entries of lsdToMSD.

type family CharOf fp :: k Source #

The characteristic of a ring, represented as a type.

Instances

type CharOf k (ZqBasic k p z) Source # 
type CharOf k (ZqBasic k p z) = p

Numeric

max :: Ord a => a -> a -> a Source #

The Prelude definition of max.

min :: Ord a => a -> a -> a Source #

The Prelude definition of min.

abs :: Absolute a => a -> a Source #

The sane definition of abs from Numeric rather than the default from NumericPrelude.

realToField :: (Field b, ToRational a) => a -> b Source #

The hidden NP function from Algebra.ToRational.

type ZeroTestable a = C a Source #

Sane synonym for C.

type Additive a = C a Source #

Sane synonym for C.

type Ring a = C a Source #

Sane synonym for C.

type Module a v = C a v Source #

Sane synonym for C.

type IntegralDomain a = C a Source #

Sane synonym for C.

type ToRational a = C a Source #

Sane synonym for C.

type Field a = C a Source #

Sane synonym for C.

type RealRing a = C a Source #

Sane synonym for C.

type RealField a = C a Source #

Sane synonym for C.

type Algebraic a = C a Source #

Sane synonym for C.

type Transcendental a = C a Source #

Sane synonym for C.

type RealTranscendental a = C a Source #

Sane synonym for C.

type OrdFloat a = (Ord a, Transcendental a) Source #

Convenient synonym for (Ord a, Transcendental a)

type ToInteger a = C a Source #

Sane synonym for C.

type Absolute a = C a Source #

Sane synonym for C.

type RealIntegral a = C a Source #

Sane synonym for C.

type PID a = C a Source #

Sane synonym for C.

type Polynomial a = T a Source #

Sane synonym for T.

type Matrix a = T a Source #

Sane synonym for T.

(^) :: forall a i. (Ring a, ToInteger i) => a -> i -> a Source #

Our custom exponentiation, overriding NP's version that requires Integer exponent. Copied from http://hackage.haskell.org/package/base-4.7.0.0/docs/src/GHC-Real.html#%5E

modinv :: (PID i, Eq i) => i -> i -> Maybe i Source #

Inverse of \(a\) modulo \(q\), in range \([0,q-1]\). (Argument order is infix-friendly.)

decomp :: (IntegralDomain z, Ord z) => [z] -> z -> [z] Source #

Decompose an element into a list of "centered" digits with respect to relative radices.

roundMult :: (RealField r, ToInteger i) => i -> r -> i Source #

Deterministically round to the nearest multiple of \( i \).

roundScalarCentered :: (RealField r, Random r, ToInteger i, MonadRandom mon) => i -> r -> mon i Source #

Randomly round to the nearest larger or smaller multiple of \( i \), where the round-off term has expectation zero.

divModCent Source #

Arguments

:: IntegralDomain i 
=> i

dividend \(a\)

-> i

divisor \(b\)

-> (i, i)

(quotient, remainder)

Variant of divMod in which the remainder is in the range \([-b/2,b/2)\).

data Int64 :: * #

64-bit signed integer type

Instances

Bounded Int64 
Enum Int64 
Eq Int64 

Methods

(==) :: Int64 -> Int64 -> Bool #

(/=) :: Int64 -> Int64 -> Bool #

Integral Int64 
Data Int64 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int64 -> c Int64 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int64 #

toConstr :: Int64 -> Constr #

dataTypeOf :: Int64 -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Int64) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int64) #

gmapT :: (forall b. Data b => b -> b) -> Int64 -> Int64 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Int64 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Int64 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 #

Num Int64 
Ord Int64 

Methods

compare :: Int64 -> Int64 -> Ordering #

(<) :: Int64 -> Int64 -> Bool #

(<=) :: Int64 -> Int64 -> Bool #

(>) :: Int64 -> Int64 -> Bool #

(>=) :: Int64 -> Int64 -> Bool #

max :: Int64 -> Int64 -> Int64 #

min :: Int64 -> Int64 -> Int64 #

Read Int64 
Real Int64 

Methods

toRational :: Int64 -> Rational #

Show Int64 

Methods

showsPrec :: Int -> Int64 -> ShowS #

show :: Int64 -> String #

showList :: [Int64] -> ShowS #

Ix Int64 
Lift Int64 

Methods

lift :: Int64 -> Q Exp #

Random Int64 

Methods

randomR :: RandomGen g => (Int64, Int64) -> g -> (Int64, g) #

random :: RandomGen g => g -> (Int64, g) #

randomRs :: RandomGen g => (Int64, Int64) -> g -> [Int64] #

randoms :: RandomGen g => g -> [Int64] #

randomRIO :: (Int64, Int64) -> IO Int64 #

randomIO :: IO Int64 #

Arbitrary Int64 

Methods

arbitrary :: Gen Int64 #

shrink :: Int64 -> [Int64] #

CoArbitrary Int64 

Methods

coarbitrary :: Int64 -> Gen b -> Gen b #

Storable Int64 

Methods

sizeOf :: Int64 -> Int #

alignment :: Int64 -> Int #

peekElemOff :: Ptr Int64 -> Int -> IO Int64 #

pokeElemOff :: Ptr Int64 -> Int -> Int64 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int64 #

pokeByteOff :: Ptr b -> Int -> Int64 -> IO () #

peek :: Ptr Int64 -> IO Int64 #

poke :: Ptr Int64 -> Int64 -> IO () #

Bits Int64 
FiniteBits Int64 
Default Int64 

Methods

def :: Int64 #

NFData Int64 

Methods

rnf :: Int64 -> () #

CRandom Int64 

Methods

crandom :: CryptoRandomGen g => g -> Either GenError (Int64, g) #

crandoms :: CryptoRandomGen g => g -> [Int64] #

CRandomR Int64 

Methods

crandomR :: CryptoRandomGen g => (Int64, Int64) -> g -> Either GenError (Int64, g) #

crandomRs :: CryptoRandomGen g => (Int64, Int64) -> g -> [Int64] #

C Int64 

Methods

toInteger :: Int64 -> Integer #

C Int64 

Methods

quot :: Int64 -> Int64 -> Int64 #

rem :: Int64 -> Int64 -> Int64 #

quotRem :: Int64 -> Int64 -> (Int64, Int64) #

C Int64 

Methods

toRational :: Int64 -> Rational #

C Int64 

Methods

abs :: Int64 -> Int64 #

signum :: Int64 -> Int64 #

C Int64 

Methods

extendedGCD :: Int64 -> Int64 -> (Int64, (Int64, Int64)) #

gcd :: Int64 -> Int64 -> Int64 #

lcm :: Int64 -> Int64 -> Int64 #

C Int64 
C Int64 

Methods

div :: Int64 -> Int64 -> Int64 #

mod :: Int64 -> Int64 -> Int64 #

divMod :: Int64 -> Int64 -> (Int64, Int64) #

C Int64 
C Int64 

Methods

isZero :: Int64 -> Bool #

C Int64 

Methods

zero :: Int64 #

(+) :: Int64 -> Int64 -> Int64 #

(-) :: Int64 -> Int64 -> Int64 #

negate :: Int64 -> Int64 #

Prim Int64 
GPB Int64 
Wire Int64 
TextType Int64 

Methods

tellT :: String -> Int64 -> Output #

getT :: Stream s Identity Char => String -> Parsec s () Int64 #

Mergeable Int64 
Default Int64 

Methods

defaultValue :: Int64 #

Elt Int64 

Methods

touch :: Int64 -> IO () #

zero :: Int64 #

one :: Int64 #

Unbox Int64 
CRTEmbed Int64 Source #

Embeds into the complex numbers \(\C\).

Associated Types

type CRTExt Int64 :: * Source #

Vector Vector Int64 
MVector MVector Int64 
CRTrans Maybe Int64 Source #

Returns Nothing

MessageAPI msg (msg -> Int64) Int64 

Methods

getVal :: msg -> (msg -> Int64) -> Int64 #

isSet :: msg -> (msg -> Int64) -> Bool #

(Fact m, Reflects k q Int64) => Protoable (CT m (ZqBasic k q Int64)) Source # 

Associated Types

type ProtoType (CT m (ZqBasic k q Int64)) :: * Source #

Methods

toProto :: CT m (ZqBasic k q Int64) -> ProtoType (CT m (ZqBasic k q Int64)) Source #

fromProto :: MonadError String m => ProtoType (CT m (ZqBasic k q Int64)) -> m (CT m (ZqBasic k q Int64)) Source #

(Fact m, Reflects k q Int64) => Protoable (RT m (ZqBasic k q Int64)) Source # 

Associated Types

type ProtoType (RT m (ZqBasic k q Int64)) :: * Source #

Methods

toProto :: RT m (ZqBasic k q Int64) -> ProtoType (RT m (ZqBasic k q Int64)) Source #

fromProto :: MonadError String m => ProtoType (RT m (ZqBasic k q Int64)) -> m (RT m (ZqBasic k q Int64)) Source #

data Vector Int64 
type CRTExt Int64 Source # 
data MVector s Int64 
type ProtoType (CT m (ZqBasic k q Int64)) Source # 
type ProtoType (CT m (ZqBasic k q Int64)) = Rq
type ProtoType (RT m (ZqBasic k q Int64)) Source # 
type ProtoType (RT m (ZqBasic k q Int64)) = Rq

Complex

data Complex a Source #

Newtype wrapper (with slightly different instances) for Number.Complex.

Instances

Unbox a0 => Vector Vector (Complex a0) Source # 
Unbox a0 => MVector MVector (Complex a0) Source # 
(Monad mon, Transcendental a) => CRTrans mon (Complex a) Source #

Complex numbers have CRTrans for any index \(m\)

Methods

crtInfo :: Reflects k m Int => TaggedT k * m mon (CRTInfo (Complex a)) Source #

Eq a => Eq (Complex a) Source # 

Methods

(==) :: Complex a -> Complex a -> Bool #

(/=) :: Complex a -> Complex a -> Bool #

Show a => Show (Complex a) Source # 

Methods

showsPrec :: Int -> Complex a -> ShowS #

show :: Complex a -> String #

showList :: [Complex a] -> ShowS #

Random a => Random (Complex a) Source # 

Methods

randomR :: RandomGen g => (Complex a, Complex a) -> g -> (Complex a, g) #

random :: RandomGen g => g -> (Complex a, g) #

randomRs :: RandomGen g => (Complex a, Complex a) -> g -> [Complex a] #

randoms :: RandomGen g => g -> [Complex a] #

randomRIO :: (Complex a, Complex a) -> IO (Complex a) #

randomIO :: IO (Complex a) #

Arbitrary a => Arbitrary (Complex a) Source # 

Methods

arbitrary :: Gen (Complex a) #

shrink :: Complex a -> [Complex a] #

Storable a => Storable (Complex a) Source # 

Methods

sizeOf :: Complex a -> Int #

alignment :: Complex a -> Int #

peekElemOff :: Ptr (Complex a) -> Int -> IO (Complex a) #

pokeElemOff :: Ptr (Complex a) -> Int -> Complex a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Complex a) #

pokeByteOff :: Ptr b -> Int -> Complex a -> IO () #

peek :: Ptr (Complex a) -> IO (Complex a) #

poke :: Ptr (Complex a) -> Complex a -> IO () #

NFData a => NFData (Complex a) Source # 

Methods

rnf :: Complex a -> () #

C a => C (Complex a) Source # 

Methods

(/) :: Complex a -> Complex a -> Complex a #

recip :: Complex a -> Complex a #

fromRational' :: Rational -> Complex a #

(^-) :: Complex a -> Integer -> Complex a #

Field a => C (Complex a) Source #

Custom instance replacing the one provided by numeric prelude: it always returns 0 as the remainder of a division. (The NP instance sometimes has precision issues, because it yields nonzero remainders, which is a problem for divG methods.)

Methods

div :: Complex a -> Complex a -> Complex a #

mod :: Complex a -> Complex a -> Complex a #

divMod :: Complex a -> Complex a -> (Complex a, Complex a) #

C a => C (Complex a) Source # 

Methods

(*) :: Complex a -> Complex a -> Complex a #

one :: Complex a #

fromInteger :: Integer -> Complex a #

(^) :: Complex a -> Integer -> Complex a #

C a => C (Complex a) Source # 

Methods

isZero :: Complex a -> Bool #

C a => C (Complex a) Source # 

Methods

zero :: Complex a #

(+) :: Complex a -> Complex a -> Complex a #

(-) :: Complex a -> Complex a -> Complex a #

negate :: Complex a -> Complex a #

Elt a => Elt (Complex a) Source # 

Methods

touch :: Complex a -> IO () #

zero :: Complex a #

one :: Complex a #

Unbox a0 => Unbox (Complex a0) Source # 
Transcendental a => CRTEmbed (Complex a) Source #

Self-embed

Associated Types

type CRTExt (Complex a) :: * Source #

data MVector s (Complex a0) Source # 
data MVector s (Complex a0) = MV_Complex (MVector s (a, a))
data Vector (Complex a0) Source # 
data Vector (Complex a0) = V_Complex (Vector (a, a))
type CRTExt (Complex a) Source # 
type CRTExt (Complex a) = Complex a

roundComplex :: (RealRing a, ToInteger b) => Complex a -> (b, b) Source #

Rounds the real and imaginary components to the nearest integer.

cis :: Transcendental a => a -> Complex a Source #

cis \(t\) is a complex value with magnitude 1 and phase \(t \bmod 2\cdot\pi\)).

real :: Complex a -> a Source #

Real component of a complex number.

imag :: Complex a -> a Source #

Imaginary component of a complex number.

fromReal :: Additive a => a -> Complex a Source #

Embeds a scalar as the real component of a complex number.

Factored

Miscellaneous

rescaleMod :: forall a b. (Mod a, Mod b, ModRep a ~ ModRep b, Lift a (ModRep b), Ring b) => a -> b Source #

A default implementation of rescaling for Mod types.

roundCoset :: forall zp z r. (Mod zp, z ~ ModRep zp, Lift zp z, RealField r) => zp -> r -> z Source #

Deterministically round to a nearby value in the desired coset.

fromJust' :: String -> Maybe a -> a Source #

Version of fromJust with an error message.

pureT :: Applicative f => Tagged t a -> TaggedT t f a Source #

Apply any applicative to a Tagged value.

peelT :: Tagged t (f a) -> TaggedT t f a Source #

Expose the monad of a Tagged value.

pasteT :: TaggedT t f a -> Tagged t (f a) Source #

Hide the monad of a Tagged value.

withWitness :: forall n r. (SingI n => Tagged n r) -> Sing n -> r Source #

Use a singleton as a witness to extract a value from a Tagged value.

withWitnessT :: forall n mon r. (SingI n => TaggedT n mon r) -> Sing n -> mon r Source #

Transformer version of withWitness.

module Data.Proxy

Orphan instances

Default Bool Source # 

Methods

def :: Bool #

(Default a0, Unbox a0) => Vector Vector (Maybe a0) Source # 

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Maybe a0) -> m (Vector (Maybe a0)) #

basicUnsafeThaw :: PrimMonad m => Vector (Maybe a0) -> m (Mutable Vector (PrimState m) (Maybe a0)) #

basicLength :: Vector (Maybe a0) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Maybe a0) -> Vector (Maybe a0) #

basicUnsafeIndexM :: Monad m => Vector (Maybe a0) -> Int -> m (Maybe a0) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Maybe a0) -> Vector (Maybe a0) -> m () #

elemseq :: Vector (Maybe a0) -> Maybe a0 -> b -> b #

(Default a0, Unbox a0) => MVector MVector (Maybe a0) Source # 

Methods

basicLength :: MVector s (Maybe a0) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (Maybe a0) -> MVector s (Maybe a0) #

basicOverlaps :: MVector s (Maybe a0) -> MVector s (Maybe a0) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Maybe a0)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (Maybe a0) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> Maybe a0 -> m (MVector (PrimState m) (Maybe a0)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Maybe a0) -> Int -> m (Maybe a0) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Maybe a0) -> Int -> Maybe a0 -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (Maybe a0) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (Maybe a0) -> Maybe a0 -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Maybe a0) -> MVector (PrimState m) (Maybe a0) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Maybe a0) -> MVector (PrimState m) (Maybe a0) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Maybe a0) -> Int -> m (MVector (PrimState m) (Maybe a0)) #

(Default a0, Unbox a0) => Unbox (Maybe a0) Source # 
(Random a, Random b) => Random (a, b) Source # 

Methods

randomR :: RandomGen g => ((a, b), (a, b)) -> g -> ((a, b), g) #

random :: RandomGen g => g -> ((a, b), g) #

randomRs :: RandomGen g => ((a, b), (a, b)) -> g -> [(a, b)] #

randoms :: RandomGen g => g -> [(a, b)] #

randomRIO :: ((a, b), (a, b)) -> IO (a, b) #

randomIO :: IO (a, b) #

(Field f1, Field f2) => C (f1, f2) Source #

Product ring as an (almost) field

Methods

(/) :: (f1, f2) -> (f1, f2) -> (f1, f2) #

recip :: (f1, f2) -> (f1, f2) #

fromRational' :: Rational -> (f1, f2) #

(^-) :: (f1, f2) -> Integer -> (f1, f2) #

(IntegralDomain a, IntegralDomain b) => C (a, b) Source #

Product ring as an (almost) integral domain

Methods

div :: (a, b) -> (a, b) -> (a, b) #

mod :: (a, b) -> (a, b) -> (a, b) #

divMod :: (a, b) -> (a, b) -> ((a, b), (a, b)) #

(Ring r1, Ring r2) => C (r1, r2) Source #

Pair as product ring

Methods

(*) :: (r1, r2) -> (r1, r2) -> (r1, r2) #

one :: (r1, r2) #

fromInteger :: Integer -> (r1, r2) #

(^) :: (r1, r2) -> Integer -> (r1, r2) #

MonadRandom m => MonadRandom (TaggedT k * tag m) Source # 

Methods

getRandom :: Random a => TaggedT k * tag m a #

getRandoms :: Random a => TaggedT k * tag m [a] #

getRandomR :: Random a => (a, a) -> TaggedT k * tag m a #

getRandomRs :: Random a => (a, a) -> TaggedT k * tag m [a] #

NFData (m a) => NFData (TaggedT k k1 s m a) Source # 

Methods

rnf :: TaggedT k k1 s m a -> () #