Copyright | (c) Riley Evans 2020 |
---|---|
License | BSD 3-Clause |
Maintainer | haskell@rly.rocks |
Safe Haskell | None |
Language | Haskell2010 |
This package contains all the constructors needed to build a Circuit
.
Synopsis
- type Circuit = IFix5 CircuitF
- id :: DataStore' '[f] '[a] => Circuit '[f] '[a] '[f] '[a] N1
- replicate2 :: DataStore' '[f] '[a] => Circuit '[f] '[a] '[f, f] '[a, a] N1
- replicateN :: ReplicateN n f a => SNat n -> Circuit '[f] '[a] (Replicate n f) (Replicate n a) N1
- (<->) :: (DataStore' fs as, DataStore' gs bs, DataStore' hs cs) => Circuit fs as gs bs nfs -> Circuit gs bs hs cs ngs -> Circuit fs as hs cs nfs
- (<>) :: (DataStore' fs as, DataStore' gs bs, DataStore' hs cs, DataStore' is ds, nfs ~ Length fs, IsNat nfs, IsNat nhs, Length fs ~ Length as, Length gs ~ Length bs, Length hs ~ Length cs, Length is ~ Length ds, Take (Length as) (as :++ cs) ~ as, Take (Length as) (fs :++ hs) ~ fs, Drop (Length as) (as :++ cs) ~ cs, Drop (Length as) (fs :++ hs) ~ hs, AppendP gs bs is ds) => Circuit fs as gs bs nfs -> Circuit hs cs is ds nhs -> Circuit (fs :++ hs) (as :++ cs) (gs :++ is) (bs :++ ds) (nfs :+ nhs)
- swap :: DataStore' '[f, g] '[a, b] => Circuit '[f, g] '[a, b] '[g, f] '[b, a] N2
- dropL :: DataStore' '[f, g] '[a, b] => Circuit '[f, g] '[a, b] '[g] '[b] N2
- dropR :: DataStore' '[f, g] '[a, b] => Circuit '[f, g] '[a, b] '[f] '[a] N2
- mapC :: (DataStore' '[f] '[[a]], DataStore g [b], Eq (g [b]), Eq a) => Circuit '[Var] '[a] '[Var] '[b] N1 -> Circuit '[f] '[[a]] '[g] '[[b]] N1
Main Type
type Circuit = IFix5 CircuitF #
The core type for a Circuit. It takes 5 different type arguments
Circuit (inputsStorageTypes :: [Type -> Type]) (inputsTypes :: [Type]) (outputsStorageTypes :: [Type -> Type]) (outputsTypes :: [Type]) (nInputs :: Nat)
inputStorageTypes
is a type-list of storage types,
for example '[
.VariableStore
, CSVStore
]
inputTypes
is a type-list of the types stored in the storage,
for example '[
.Int
, [(String
, Float
)]]
outputsStorageTypes
and inputTypes
mirror the examples above, but for the outputs instead.
nInputs
is a type-level Nat
that is the length of all input lists.
Constructors
id :: DataStore' '[f] '[a] => Circuit '[f] '[a] '[f] '[a] N1 #
Passes an input through without modifying it.
In diagram form it would look like,
|
replicate2 :: DataStore' '[f] '[a] => Circuit '[f] '[a] '[f, f] '[a, a] N1 #
Duplicates an input.
In diagram form it would look like,
/\
:: (DataStore' fs as, DataStore' gs bs, DataStore' hs cs) | |
=> Circuit fs as gs bs nfs | First circuit ( |
-> Circuit gs bs hs cs ngs | Second circuit ( |
-> Circuit fs as hs cs nfs |
Usually referred to as "then", this operator joins two levels of a circuit together.
A diagram representing a <-> b
or "a then b" can be seen below,
| ... | -- Any number of inputs a | ... | -- outputs a ~ inputs b b | ... | -- Any number of outputs
:: (DataStore' fs as, DataStore' gs bs, DataStore' hs cs, DataStore' is ds, nfs ~ Length fs, IsNat nfs, IsNat nhs, Length fs ~ Length as, Length gs ~ Length bs, Length hs ~ Length cs, Length is ~ Length ds, Take (Length as) (as :++ cs) ~ as, Take (Length as) (fs :++ hs) ~ fs, Drop (Length as) (as :++ cs) ~ cs, Drop (Length as) (fs :++ hs) ~ hs, AppendP gs bs is ds) | |
=> Circuit fs as gs bs nfs | Left circuit |
-> Circuit hs cs is ds nhs | Right circuit |
-> Circuit (fs :++ hs) (as :++ cs) (gs :++ is) (bs :++ ds) (nfs :+ nhs) |
Usually referred to as "beside" or "next to", this operator joins two circuits next to each other.
A diagram representing a <> b
or "a next to b" can be seen below,
| ... | ... | -- inputs a ++ inputs b a b | ... | ... | -- outputs a ++ outputs b
swap :: DataStore' '[f, g] '[a, b] => Circuit '[f, g] '[a, b] '[g, f] '[b, a] N2 #
Swaps to input values around.
In diagram form this would look like,
\/ /\
dropL :: DataStore' '[f, g] '[a, b] => Circuit '[f, g] '[a, b] '[g] '[b] N2 #
Takes two values as input and drops the left input.
dropR :: DataStore' '[f, g] '[a, b] => Circuit '[f, g] '[a, b] '[f] '[a] N2 #
Takes two values as input and drops the right input.