@@ -26,7 +26,7 @@ module Pipeline.Circuit
26
26
) where
27
27
28
28
29
- import Pipeline.Internal.Common.IFunctor (IFix7 (.. ))
29
+ import Pipeline.Internal.Common.IFunctor (IFix5 (.. ))
30
30
import Pipeline.Internal.Common.IFunctor.Modular ((:<:) (.. ))
31
31
import Pipeline.Internal.Common.Nat (IsNat , N1 , N2 ,
32
32
Nat (.. ), SNat (.. ), (:+) )
@@ -49,8 +49,8 @@ In diagram form it would look like,
49
49
> |
50
50
51
51
-}
52
- id :: (DataStore' '[f ] '[a ]) => AST. Circuit '[f ] '[a ] '[f a ] '[f ] '[ a ] '[ f a ] N1
53
- id = (IIn7 . inj) AST. Id
52
+ id :: (DataStore' '[f ] '[a ]) => AST. Circuit '[f ] '[a ] '[f ] '[a ] N1
53
+ id = (IIn5 . inj) AST. Id
54
54
55
55
{-|
56
56
Duplicates an input.
@@ -60,8 +60,8 @@ In diagram form it would look like,
60
60
> /\
61
61
62
62
-}
63
- replicate2 :: DataStore' '[f ] '[a ] => AST. Circuit '[f ] '[a ] '[f a ] '[ f , f ] '[a , a ] '[ f a , f a ] N1
64
- replicate2 = (IIn7 . inj) AST. Replicate
63
+ replicate2 :: DataStore' '[f ] '[a ] => AST. Circuit '[f ] '[a ] '[f , f ] '[a , a ] N1
64
+ replicate2 = (IIn5 . inj) AST. Replicate
65
65
66
66
{-|
67
67
Usually referred to as \"then\", this operator joins two levels of a circuit together.
@@ -77,10 +77,10 @@ A diagram representing @a \<-\> b@ or \"a then b\" can be seen below,
77
77
-}
78
78
(<->)
79
79
:: (DataStore' fs as , DataStore' gs bs , DataStore' hs cs )
80
- => AST. Circuit fs as ( Apply fs as ) gs bs ( Apply gs bs ) nfs -- ^ First circuit (@a@)
81
- -> AST. Circuit gs bs ( Apply gs bs ) hs cs ( Apply hs cs ) ngs -- ^ Second circuit (@b@)
82
- -> AST. Circuit fs as ( Apply fs as ) hs cs ( Apply hs cs ) nfs
83
- (<->) l r = IIn7 (inj (AST. Then l r))
80
+ => AST. Circuit fs as gs bs nfs -- ^ First circuit (@a@)
81
+ -> AST. Circuit gs bs hs cs ngs -- ^ Second circuit (@b@)
82
+ -> AST. Circuit fs as hs cs nfs
83
+ (<->) l r = IIn5 (inj (AST. Then l r))
84
84
infixr 4 <->
85
85
86
86
@@ -103,32 +103,24 @@ A diagram representing @a \<\> b@ or \"a next to b\" can be seen below,
103
103
, IsNat nfs
104
104
, IsNat nhs
105
105
, Length fs ~ Length as
106
- , Length fs ~ Length (Apply fs as )
107
106
, Length gs ~ Length bs
108
- , Length gs ~ Length (Apply gs bs )
109
107
, Length hs ~ Length cs
110
- , Length hs ~ Length (Apply hs cs )
111
108
, Length is ~ Length ds
112
- , Length is ~ Length (Apply is ds )
113
- , Take (Length as ) (Apply fs as :++ Apply hs cs ) ~ Apply fs as
114
109
, Take (Length as ) (as :++ cs ) ~ as
115
110
, Take (Length as ) (fs :++ hs ) ~ fs
116
- , Drop (Length as ) (Apply fs as :++ Apply hs cs ) ~ Apply hs cs
117
111
, Drop (Length as ) (as :++ cs ) ~ cs
118
112
, Drop (Length as ) (fs :++ hs ) ~ hs
119
- , AppendP gs bs ( Apply gs bs ) is ds ( Apply is ds )
113
+ , AppendP gs bs is ds
120
114
)
121
- => AST. Circuit fs as ( Apply fs as ) gs bs ( Apply gs bs ) nfs -- ^ Left circuit
122
- -> AST. Circuit hs cs ( Apply hs cs ) is ds ( Apply is ds ) nhs -- ^ Right circuit
115
+ => AST. Circuit fs as gs bs nfs -- ^ Left circuit
116
+ -> AST. Circuit hs cs is ds nhs -- ^ Right circuit
123
117
-> AST. Circuit
124
118
(fs :++ hs )
125
119
(as :++ cs )
126
- (Apply fs as :++ Apply hs cs )
127
120
(gs :++ is )
128
121
(bs :++ ds )
129
- (Apply gs bs :++ Apply is ds )
130
122
(nfs :+ nhs )
131
- (<>) l r = IIn7 (inj (AST. Beside l r))
123
+ (<>) l r = IIn5 (inj (AST. Beside l r))
132
124
infixr 5 <>
133
125
134
126
{-|
@@ -142,40 +134,40 @@ In diagram form this would look like,
142
134
-}
143
135
swap
144
136
:: (DataStore' '[f , g ] '[a , b ])
145
- => AST. Circuit '[f , g ] '[a , b ] '[f a , g b ] '[ g , f ] '[b , a ] '[ g b , f a ] N2
146
- swap = (IIn7 . inj) AST. Swap
137
+ => AST. Circuit '[f , g ] '[a , b ] '[g , f ] '[b , a ] N2
138
+ swap = (IIn5 . inj) AST. Swap
147
139
148
140
{-|
149
141
Takes two values as input and drops the left input.
150
142
-}
151
143
dropL
152
- :: (DataStore' '[f , g ] '[a , b ]) => AST. Circuit '[f , g ] '[a , b ] '[f a , g b ] '[g ] '[ b ] '[ g b ] N2
153
- dropL = (IIn7 . inj) AST. DropL
144
+ :: (DataStore' '[f , g ] '[a , b ]) => AST. Circuit '[f , g ] '[a , b ] '[g ] '[b ] N2
145
+ dropL = (IIn5 . inj) AST. DropL
154
146
155
147
{-|
156
148
Takes two values as input and drops the right input.
157
149
-}
158
150
dropR
159
- :: (DataStore' '[f , g ] '[a , b ]) => AST. Circuit '[f , g ] '[a , b ] '[f a , g b ] '[f ] '[ a ] '[ f a ] N2
160
- dropR = (IIn7 . inj) AST. DropR
151
+ :: (DataStore' '[f , g ] '[a , b ]) => AST. Circuit '[f , g ] '[a , b ] '[f ] '[a ] N2
152
+ dropR = (IIn5 . inj) AST. DropR
161
153
162
154
{-|
163
155
Maps a circuit on the inputs
164
156
-}
165
157
mapC
166
158
:: (DataStore' '[f ] '[[a ]], DataStore g [b ], Eq (g [b ]), Eq a )
167
- => AST. Circuit '[Var ] '[a ] '[Var a ] '[Var ] '[ b ] '[ Var b ] N1
168
- -> AST. Circuit '[f ] '[[a ]] '[f [ a ]] '[ g ] '[[ b ]] '[ g [b ]] N1
169
- mapC c = (IIn7 . inj) (AST. Map c)
159
+ => AST. Circuit '[Var ] '[a ] '[Var ] '[b ] N1
160
+ -> AST. Circuit '[f ] '[[a ]] '[g ] '[[b ]] N1
161
+ mapC c = (IIn5 . inj) (AST. Map c)
170
162
171
163
class (DataStore f a , Eq (f a )) => ReplicateN n f a where
172
- replicateN :: SNat n -> AST. Circuit '[f ] '[a ] '[ f a ] (Replicate n f ) (Replicate n a ) ( Apply ( Replicate n f ) ( Replicate n a )) N1
164
+ replicateN :: SNat n -> AST. Circuit '[f ] '[a ] (Replicate n f ) (Replicate n a ) N1
173
165
174
166
instance (DataStore f a , Eq a , Eq (f a )) => ReplicateN ('Succ ('Succ 'Zero)) f a where
175
167
replicateN (SSucc (SSucc SZero )) = replicate2
176
168
177
169
instance (DataStore f a , Eq a , Eq (f a )) => ReplicateN ('Succ ('Succ ('Succ 'Zero))) f a where
178
170
replicateN (SSucc n) = replicate2 <-> id <> replicateN n
179
171
180
- replicateMany :: SNat m -> AST. Circuit fs as (Apply fs as ) ( fs :++ fs ) (as :++ as ) ( Apply ( fs :++ fs ) ( as :++ as ) ) m
172
+ replicateMany :: SNat m -> AST. Circuit fs as (fs :++ fs ) (as :++ as ) m
181
173
replicateMany = undefined
0 commit comments