typedflow-0.9: Typed frontend to TensorFlow and higher-order deep learning

Safe HaskellNone
LanguageHaskell2010

TypedFlow.Types

Synopsis

Documentation

data Sat a b where Source #

Constructors

Sat :: a b => Sat a b 

type DOC = Doc () Source #

type (<) i j = CmpNat i j ~ LT Source #

type family Product xs where ... Source #

Equations

Product '[] = 1 
Product (x ': xs) = x * Product xs 

type family Sum xs where ... Source #

Equations

Sum '[] = 0 
Sum (x ': xs) = x + Sum xs 

type family xs ++ ys where ... Source #

Equations

'[] ++ xs = xs 
(x ': xs) ++ ys = x ': (xs ++ ys) 

type family Tail xs where ... Source #

Equations

Tail (x ': xs) = xs 

type family Last xs where ... Source #

Equations

Last '[x] = x 
Last (x ': xs) = Last xs 

type family Init xs where ... Source #

Equations

Init '[x] = '[] 
Init (x ': xs) = x ': Init xs 

plusAssoc' :: forall x y z. ((x + y) + z) :~: (x + (y + z)) Source #

plusAssoc :: forall x y z k. (((x + y) + z) ~ (x + (y + z)) => k) -> k Source #

prodAssoc' :: forall x y z. ((x * y) * z) :~: (x * (y * z)) Source #

prodAssoc :: forall x y z k. (((x * y) * z) ~ (x * (y * z)) => k) -> k Source #

prodHomo' :: forall x y. Product (x ++ y) :~: (Product x * Product y) Source #

prodHomo :: forall x y k. (Product (x ++ y) ~ (Product x * Product y) => k) -> k Source #

knownProduct' :: forall s k. All KnownNat s => SList s -> (KnownNat (Product s) => k) -> k Source #

knownProduct :: forall s k. KnownShape s => (KnownNat (Product s) => k) -> k Source #

initLast' :: forall s k. SList s -> ((Init s ++ '[Last s]) ~ s => k) -> k Source #

initLast :: forall s k. KnownShape s => ((Init s ++ '[Last s]) ~ s => k) -> k Source #

knownLast' :: All KnownNat s => SList s -> (KnownNat (Last s) => k) -> k Source #

knownLast :: forall s k. KnownShape s => (KnownNat (Last s) => k) -> k Source #

splitApp' :: forall ys xs k. SList xs -> ((Take (PeanoLength xs) (xs ++ ys) ~ xs, Drop (PeanoLength xs) (xs ++ ys) ~ ys) => k) -> k Source #

splitApp :: forall xs ys k. KnownLen xs => ((Take (PeanoLength xs) (xs ++ ys) ~ xs, Drop (PeanoLength xs) (xs ++ ys) ~ ys) => k) -> k Source #

knownAppend' :: forall t s k. (All KnownNat s, KnownShape t) => SList s -> (KnownShape (s ++ t) => k) -> k Source #

knownAppend :: forall s t k. (KnownShape s, KnownShape t) => (KnownShape (s ++ t) => k) -> k Source #

type family Length xs where ... Source #

Equations

Length '[] = 0 
Length (x ': xs) = 1 + Length xs 

type family Reverse' xs ys where ... Source #

Equations

Reverse' '[] ys = ys 
Reverse' (x ': xs) ys = Reverse' xs (x ': ys) 

type family Reverse xs where ... Source #

Equations

Reverse xs = Reverse' xs '[] 

newtype V n a Source #

Constructors

V [a] 

Instances

Functor (V n) Source # 

Methods

fmap :: (a -> b) -> V n a -> V n b #

(<$) :: a -> V n b -> V n a #

KnownNat n => Applicative (V n) Source # 

Methods

pure :: a -> V n a #

(<*>) :: V n (a -> b) -> V n a -> V n b #

(*>) :: V n a -> V n b -> V n b #

(<*) :: V n a -> V n b -> V n a #

Foldable (V n) Source # 

Methods

fold :: Monoid m => V n m -> m #

foldMap :: Monoid m => (a -> m) -> V n a -> m #

foldr :: (a -> b -> b) -> b -> V n a -> b #

foldr' :: (a -> b -> b) -> b -> V n a -> b #

foldl :: (b -> a -> b) -> b -> V n a -> b #

foldl' :: (b -> a -> b) -> b -> V n a -> b #

foldr1 :: (a -> a -> a) -> V n a -> a #

foldl1 :: (a -> a -> a) -> V n a -> a #

toList :: V n a -> [a] #

null :: V n a -> Bool #

length :: V n a -> Int #

elem :: Eq a => a -> V n a -> Bool #

maximum :: Ord a => V n a -> a #

minimum :: Ord a => V n a -> a #

sum :: Num a => V n a -> a #

product :: Num a => V n a -> a #

Traversable (V n) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> V n a -> f (V n b) #

sequenceA :: Applicative f => V n (f a) -> f (V n a) #

mapM :: Monad m => (a -> m b) -> V n a -> m (V n b) #

sequence :: Monad m => V n (m a) -> m (V n a) #

data NP f xs where Source #

Constructors

Unit :: NP f '[] 
(:*) :: f x -> NP f xs -> NP f (x ': xs) infixr 5 

Instances

(KnownTyp Typ t, All [Nat] KnownShape ys) => KnownTensors (HTV t ys) Source # 

Methods

travTensor :: (forall s a. (KnownTyp Typ a, KnownShape s) => String -> T s a -> Gen (T s a)) -> String -> HTV t ys -> Gen (HTV t ys) Source #

newtype I a Source #

Constructors

I a 

newtype K a x Source #

Constructors

K a 

type HList = NP I Source #

pattern HSingle :: forall k f a. f a -> NP k f ((:) k a ([] k)) Source #

pattern VecSing :: forall s t. Tensor s t -> HTV t ((:) Shape s ([] Shape)) Source #

pattern VecPair :: forall s t s'. Tensor s t -> Tensor s' t -> HTV t ((:) Shape s ((:) Shape s' ([] Shape))) Source #

pattern VecTriple :: forall s t s' s3. Tensor s t -> Tensor s' t -> Tensor s3 t -> HTV t ((:) Shape s ((:) Shape s' ((:) Shape s3 ([] Shape)))) Source #

type family All (c :: k -> Constraint) (xs :: [k]) :: Constraint where ... Source #

Equations

All c '[] = () 
All c (x ': xs) = (c x, All c xs) 

class Fun c Source #

Associated Types

type Ap c (t :: k) :: l Source #

Instances

Fun k c => Fun [k] (FMap k c) Source # 

Associated Types

type Ap l (FMap k c) (c :: FMap k c -> Constraint) (t :: FMap k c) :: l Source #

Fun [k] (Snoc k x) Source # 

Associated Types

type Ap l (Snoc k x) (c :: Snoc k x -> Constraint) (t :: Snoc k x) :: l Source #

Fun [k] (Cons k x) Source # 

Associated Types

type Ap l (Cons k x) (c :: Cons k x -> Constraint) (t :: Cons k x) :: l Source #

class Cons x xs Source #

Instances

Fun [k] (Cons k x) Source # 

Associated Types

type Ap l (Cons k x) (c :: Cons k x -> Constraint) (t :: Cons k x) :: l Source #

type Ap [k] [k] (Cons k x) xs Source # 
type Ap [k] [k] (Cons k x) xs = (:) k x xs

class Snoc x xs Source #

Instances

Fun [k] (Snoc k x) Source # 

Associated Types

type Ap l (Snoc k x) (c :: Snoc k x -> Constraint) (t :: Snoc k x) :: l Source #

type Ap [k] [k] (Snoc k x) ([] k) Source # 
type Ap [k] [k] (Snoc k x) ([] k) = (:) k x ([] k)
type Ap [k] [k] (Snoc k x) ((:) k y ys) Source # 
type Ap [k] [k] (Snoc k x) ((:) k y ys) = (:) k y (Ap [k] [k] (Snoc k x) ys)

class FMap c xs Source #

Instances

Fun k c => Fun [k] (FMap k c) Source # 

Associated Types

type Ap l (FMap k c) (c :: FMap k c -> Constraint) (t :: FMap k c) :: l Source #

type Ap [k1] [k] (FMap k c) ([] k) Source # 
type Ap [k1] [k] (FMap k c) ([] k) = [] k1
type Ap [a] [k] (FMap k c) ((:) k x xs) Source # 
type Ap [a] [k] (FMap k c) ((:) k x xs) = (:) a (Ap a k c x) (Ap [a] [k] (FMap k c) xs)

newtype F g t s Source #

Flip at type level

Constructors

F 

Fields

Instances

(KnownTyp Typ t, All [Nat] KnownShape ys) => KnownTensors (HTV t ys) Source # 

Methods

travTensor :: (forall s a. (KnownTyp Typ a, KnownShape s) => String -> T s a -> Gen (T s a)) -> String -> HTV t ys -> Gen (HTV t ys) Source #

type HTV t = NP (F T t) Source #

Heterogeneous tensor vector with the same kind of elements

data Pair a b Source #

Constructors

a :& b 

type family Fst (x :: Pair a b) where ... Source #

Equations

Fst (x :& y) = x 

type family Snd (x :: Pair a b) where ... Source #

Equations

Snd (x :& y) = y 

newtype Uncurry g s Source #

Constructors

Uncurry 

Fields

type HHTV = NP (Uncurry T) Source #

hhead :: NP f (x ': xs) -> f x Source #

htail :: NP f (x ': xs) -> NP f xs Source #

htmap :: forall f ss t u. (forall s. Tensor s t -> Tensor (Ap f s) u) -> HTV t ss -> HTV u (Ap (FMap f) ss) Source #

hmap :: (forall x. f x -> g x) -> NP f xs -> NP g xs Source #

hendo :: NP Endo xs -> HList xs -> HList xs Source #

happ :: NP f xs -> NP f ys -> NP f (xs ++ ys) Source #

data Both f g x Source #

Constructors

Both (f x) (g x) 

hzip :: NP f xs -> NP g xs -> NP (Both f g) xs Source #

hzipWith :: (forall x. f x -> g x -> h x) -> NP f xs -> NP g xs -> NP h xs Source #

hfor_ :: Monad m => NP f xs -> (forall x. f x -> m a) -> m () Source #

htoList :: NP (K a) xs -> [a] Source #

hsplit' :: SPeano n -> NP f xs -> (NP f (Take n xs), NP f (Drop n xs)) Source #

hsplit :: forall xs ys f. KnownLen xs => NP f (xs ++ ys) -> (NP f xs, NP f ys) Source #

hsnoc :: NP f xs -> f x -> NP f (xs ++ '[x]) Source #

type Dim0 = Zero Source #

class KnownPeano n where Source #

Minimal complete definition

peanoInt

data SPeano n where Source #

Constructors

SZero :: SPeano Zero 
SSucc :: SPeano n -> SPeano (Succ n) 

data Vec n a where Source #

Constructors

VNil :: Vec Zero a 
VCons :: a -> Vec n a -> Vec (Succ n) a 

vecToList :: Vec n a -> [a] Source #

type family Take n xs where ... Source #

Equations

Take Zero xs = '[] 
Take (Succ n) '[] = '[] 
Take (Succ n) (x ': xs) = x ': Take n xs 

type family Drop n xs where ... Source #

Equations

Drop Zero xs = xs 
Drop (Succ n) '[] = '[] 
Drop (Succ n) (x ': xs) = Drop n xs 

type family At n xs where ... Source #

Equations

At Zero (x ': xs) = x 
At (Succ n) (x ': xs) = At n xs 

data Typ Source #

Constructors

Typ Kind NBits 

Instances

Show Typ Source # 

Methods

showsPrec :: Int -> Typ -> ShowS #

show :: Typ -> String #

showList :: [Typ] -> ShowS #

(KnownBits NBits l, KnownKind Kind k) => KnownTyp Typ (Typ k l) Source # 

Methods

typVal :: Typ Source #

(KnownTyp Typ t, All [Nat] KnownShape ys) => KnownTensors (HTV t ys) Source # 

Methods

travTensor :: (forall s a. (KnownTyp Typ a, KnownShape s) => String -> T s a -> Gen (T s a)) -> String -> HTV t ys -> Gen (HTV t ys) Source #

type Flt t = Typ Float t Source #

type Scalar t = T '[] t Source #

showTyp :: forall t. KnownTyp t => DOC Source #

type Shape = [Nat] Source #

data T shape t Source #

Constructors

T 

Instances

(KnownTyp Typ t, KnownShape shape) => KnownTensors (T shape t) Source # 

Methods

travTensor :: (forall s a. (KnownTyp Typ a, KnownShape s) => String -> T s a -> Gen (T s a)) -> String -> T shape t -> Gen (T shape t) Source #

(KnownTyp Typ t, All [Nat] KnownShape ys) => KnownTensors (HTV t ys) Source # 

Methods

travTensor :: (forall s a. (KnownTyp Typ a, KnownShape s) => String -> T s a -> Gen (T s a)) -> String -> HTV t ys -> Gen (HTV t ys) Source #

data SNat n where Source #

Constructors

SNat :: KnownNat n => Proxy n -> SNat n 

class (KnownLen s, All KnownNat s) => KnownShape s Source #

Instances

KnownShape ([] Nat) Source # 
(KnownNat x, KnownShape xs) => KnownShape ((:) Nat x xs) Source # 

class KnownTyp t where Source #

Minimal complete definition

typVal

Methods

typVal :: Typ Source #

Instances

class KnownBits t where Source #

Minimal complete definition

bitsVal

Methods

bitsVal :: NBits Source #

class KnownKind t where Source #

Minimal complete definition

kindVal

Methods

kindVal :: Kind Source #

data SList' f s where Source #

Constructors

LZ :: SList' f '[] 
LS :: forall x xs f. f x -> SList' f xs -> SList' f (x ': xs) 

type family PeanoLength xs :: Peano where ... Source #

Equations

PeanoLength '[] = Zero 
PeanoLength (x ': xs) = Succ (PeanoLength xs) 

withKnownNat :: forall k. Int -> (forall n. KnownNat n => Proxy n -> k) -> k Source #

class KnownLen s where Source #

Minimal complete definition

listLen, shapePeano, shapeSList

Instances

KnownLen a ([] a) Source # 
KnownLen a xs => KnownLen a ((:) a x xs) Source # 

Methods

listLen :: Integer Source #

shapePeano :: SPeano (PeanoLength ((a ': x) xs) s) Source #

shapeSList :: SList ((a ': x) xs) s Source #

shapeSListProxy :: KnownLen xs => proxy xs -> SList xs Source #

shapeToList :: forall s. KnownShape s => [Integer] Source #

showShape :: forall s. KnownShape s => DOC Source #

showShapeMinus :: forall s. KnownShape s => DOC Source #

Show a shape, but None is replaced by "-1"

showShapeLen :: forall s. KnownLen s => DOC Source #

rememberNat :: SNat n -> (KnownNat n => r) -> r Source #

type None = 514229 Source #

showDimM :: forall n. KnownNat n => DOC Source #

showDim :: forall n. KnownNat n => DOC Source #

str :: Show a => a -> DOC Source #

data ParamInfo Source #

Constructors

ParamInfo 

Fields

data GState Source #

Constructors

GState 

Fields

Instances

MonadState GState Gen Source # 

Methods

get :: Gen GState #

put :: GState -> Gen () #

state :: (GState -> (a, GState)) -> Gen a #

newtype Gen x Source #

Constructors

Gen 

Fields

Instances

Monad Gen Source # 

Methods

(>>=) :: Gen a -> (a -> Gen b) -> Gen b #

(>>) :: Gen a -> Gen b -> Gen b #

return :: a -> Gen a #

fail :: String -> Gen a #

Functor Gen Source # 

Methods

fmap :: (a -> b) -> Gen a -> Gen b #

(<$) :: a -> Gen b -> Gen a #

Applicative Gen Source # 

Methods

pure :: a -> Gen a #

(<*>) :: Gen (a -> b) -> Gen a -> Gen b #

(*>) :: Gen a -> Gen b -> Gen b #

(<*) :: Gen a -> Gen b -> Gen a #

MonadState GState Gen Source # 

Methods

get :: Gen GState #

put :: GState -> Gen () #

state :: (GState -> (a, GState)) -> Gen a #

peekAtAny :: String -> UntypedExpression -> Gen () Source #

Name an expression so that it is made available for session.run.

gen :: DOC -> Gen () Source #

setGen :: DOC -> Gen () Source #

withDOC :: forall a. (DOC -> DOC) -> Gen a -> Gen a Source #

type Tensor shape = T shape Source #

tuple :: [DOC] -> DOC Source #

dict :: [(String, DOC)] -> DOC Source #

funcall' :: DOC -> [DOC] -> DOC Source #

binOp :: forall s1 s2 s3 t1 t2 t3. String -> Tensor s1 t1 -> Tensor s2 t2 -> Tensor s3 t3 Source #

unOp :: forall s1 s2 t1 t2. String -> Tensor s1 t1 -> Tensor s2 t2 Source #

assign :: forall s t. T s t -> Gen (T s t) Source #

genFun :: forall b. String -> [DOC] -> Gen b -> Gen b Source #

lambda :: (T s t -> T s' t') -> Gen UntypedExpression Source #

generateFile :: String -> Gen () -> IO () Source #