Skip to content

Commit 8590c49

Browse files
authored
Merge pull request #65 from RileyEv/64-type-parameters
Remove duplication from type parameters
2 parents 038f3e8 + a92ddb9 commit 8590c49

File tree

16 files changed

+223
-280
lines changed

16 files changed

+223
-280
lines changed

benchmarks/BenchLinearSongAgg/SongAgg.hs

+4-16
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,8 @@ top10Task
210210
=> Circuit
211211
'[Var]
212212
'[[a]]
213-
'[Var [a]]
214213
'[NamedCSVStore]
215214
'[[a]]
216-
'[NamedCSVStore [a]]
217215
N1
218216
top10Task = functionTask f
219217
where
@@ -224,10 +222,8 @@ aggArtistsTask
224222
:: Circuit
225223
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
226224
'[[Listen] , [Listen] , [Listen]]
227-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
228225
'[Var]
229226
'[[ArtistCount]]
230-
'[Var [ArtistCount]]
231227
N3
232228
aggArtistsTask = multiInputTask f
233229
where
@@ -241,10 +237,8 @@ aggSongsTask
241237
:: Circuit
242238
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
243239
'[[Listen] , [Listen] , [Listen]]
244-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
245240
'[Var]
246241
'[[TrackCount]]
247-
'[Var [TrackCount]]
248242
N3
249243
aggSongsTask = multiInputTask f
250244
where
@@ -257,10 +251,8 @@ pipeline
257251
:: Circuit
258252
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
259253
'[[Listen] , [Listen] , [Listen]]
260-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
261254
'[NamedCSVStore , NamedCSVStore]
262255
'[[ArtistCount] , [TrackCount]]
263-
'[NamedCSVStore [ArtistCount] , NamedCSVStore [TrackCount]]
264256
N3
265257
pipeline = replicate2
266258
<> replicate2
@@ -283,10 +275,8 @@ addUser
283275
:: BasicNetwork
284276
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
285277
'[[Listen] , [Listen] , [Listen]]
286-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
287278
'[NamedCSVStore , NamedCSVStore]
288279
'[[ArtistCount] , [TrackCount]]
289-
'[NamedCSVStore [ArtistCount] , NamedCSVStore [TrackCount]]
290280
-> JobUUID
291281
-> IO ()
292282
addUser n uuid = write
@@ -301,10 +291,8 @@ getUserTop10
301291
:: BasicNetwork
302292
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
303293
'[[Listen] , [Listen] , [Listen]]
304-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
305294
'[NamedCSVStore , NamedCSVStore]
306295
'[[ArtistCount] , [TrackCount]]
307-
'[NamedCSVStore [ArtistCount] , NamedCSVStore [TrackCount]]
308296
-> JobUUID
309297
-> IO (NamedCSVStore [ArtistCount], NamedCSVStore [TrackCount])
310298
getUserTop10 n _ = do
@@ -317,8 +305,8 @@ computeResult
317305
-> JobUUID
318306
-> IO (NamedCSVStore [ArtistCount], NamedCSVStore [TrackCount])
319307
computeResult inputs jobUUID = do
320-
let (IIn7 (R (R (R (R (R (R (R (L (Task aggArtistsF)))))))))) = aggArtistsTask
321-
let (IIn7 (R (R (R (R (R (R (R (L (Task aggSongsF)))))))))) = aggSongsTask
308+
let (IIn5 (R (R (R (R (R (R (R (L (Task aggArtistsF)))))))))) = aggArtistsTask
309+
let (IIn5 (R (R (R (R (R (R (R (L (Task aggSongsF)))))))))) = aggSongsTask
322310
aggATaskUUID <- genTaskUUID
323311
aggSTaskUUID <- genTaskUUID
324312
aggArtistsEmptyVar <- empty aggATaskUUID jobUUID
@@ -329,9 +317,9 @@ computeResult inputs jobUUID = do
329317

330318
let artists = HCons' aggArtistsEmptyVar HNil'
331319
let songs = HCons' aggSongsEmptyVar HNil'
332-
let (IIn7 (R (R (R (R (R (R (R (L (Task top10ArtistsF)))))))))) =
320+
let (IIn5 (R (R (R (R (R (R (R (L (Task top10ArtistsF)))))))))) =
333321
top10Task
334-
let (IIn7 (R (R (R (R (R (R (R (L (Task top10SongsF)))))))))) =
322+
let (IIn5 (R (R (R (R (R (R (R (L (Task top10SongsF)))))))))) =
335323
top10Task
336324
top10ATaskUUID <- genTaskUUID
337325
top10STaskUUID <- genTaskUUID

benchmarks/BenchSongAgg/SongAgg.hs

-12
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,8 @@ top10Task
202202
=> Circuit
203203
'[Var]
204204
'[[a]]
205-
'[Var [a]]
206205
'[NamedCSVStore]
207206
'[[a]]
208-
'[NamedCSVStore [a]]
209207
N1
210208
top10Task = functionTask f
211209
where
@@ -216,10 +214,8 @@ aggArtistsTask
216214
:: Circuit
217215
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
218216
'[[Listen] , [Listen] , [Listen]]
219-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
220217
'[Var]
221218
'[[ArtistCount]]
222-
'[Var [ArtistCount]]
223219
N3
224220
aggArtistsTask = multiInputTask f
225221
where
@@ -232,10 +228,8 @@ aggSongsTask
232228
:: Circuit
233229
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
234230
'[[Listen] , [Listen] , [Listen]]
235-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
236231
'[Var]
237232
'[[TrackCount]]
238-
'[Var [TrackCount]]
239233
N3
240234
aggSongsTask = multiInputTask f
241235
where
@@ -248,10 +242,8 @@ pipeline
248242
:: Circuit
249243
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
250244
'[[Listen] , [Listen] , [Listen]]
251-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
252245
'[NamedCSVStore , NamedCSVStore]
253246
'[[ArtistCount] , [TrackCount]]
254-
'[NamedCSVStore [ArtistCount] , NamedCSVStore [TrackCount]]
255247
N3
256248
pipeline = replicate2
257249
<> replicate2
@@ -274,10 +266,8 @@ addUser
274266
:: BasicNetwork
275267
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
276268
'[[Listen] , [Listen] , [Listen]]
277-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
278269
'[NamedCSVStore , NamedCSVStore]
279270
'[[ArtistCount] , [TrackCount]]
280-
'[NamedCSVStore [ArtistCount] , NamedCSVStore [TrackCount]]
281271
-> JobUUID
282272
-> IO ()
283273
addUser n uuid = write
@@ -294,10 +284,8 @@ getUserTop10
294284
:: BasicNetwork
295285
'[NamedCSVStore , NamedCSVStore , NamedCSVStore]
296286
'[[Listen] , [Listen] , [Listen]]
297-
'[NamedCSVStore [Listen] , NamedCSVStore [Listen] , NamedCSVStore [Listen]]
298287
'[NamedCSVStore , NamedCSVStore]
299288
'[[ArtistCount] , [TrackCount]]
300-
'[NamedCSVStore [ArtistCount] , NamedCSVStore [TrackCount]]
301289
-> JobUUID
302290
-> IO (NamedCSVStore [ArtistCount], NamedCSVStore [TrackCount])
303291
getUserTop10 n _ = do

circuitflow.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cabal-version: 2.0
33
-- For further documentation, see http://haskell.org/cabal/users-guide/
44

55
name: circuitflow
6-
version: 0.2.0.0
6+
version: 0.3.0.0
77
-- synopsis:
88
-- description:
99
homepage: https://github.com/RileyEv/project

src/Pipeline/Circuit.hs

+24-32
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module Pipeline.Circuit
2626
) where
2727

2828

29-
import Pipeline.Internal.Common.IFunctor (IFix7 (..))
29+
import Pipeline.Internal.Common.IFunctor (IFix5 (..))
3030
import Pipeline.Internal.Common.IFunctor.Modular ((:<:) (..))
3131
import Pipeline.Internal.Common.Nat (IsNat, N1, N2,
3232
Nat (..), SNat (..), (:+))
@@ -49,8 +49,8 @@ In diagram form it would look like,
4949
> |
5050
5151
-}
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
5454

5555
{-|
5656
Duplicates an input.
@@ -60,8 +60,8 @@ In diagram form it would look like,
6060
> /\
6161
6262
-}
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
6565

6666
{-|
6767
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,
7777
-}
7878
(<->)
7979
:: (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))
8484
infixr 4 <->
8585

8686

@@ -103,32 +103,24 @@ A diagram representing @a \<\> b@ or \"a next to b\" can be seen below,
103103
, IsNat nfs
104104
, IsNat nhs
105105
, Length fs ~ Length as
106-
, Length fs ~ Length (Apply fs as)
107106
, Length gs ~ Length bs
108-
, Length gs ~ Length (Apply gs bs)
109107
, Length hs ~ Length cs
110-
, Length hs ~ Length (Apply hs cs)
111108
, Length is ~ Length ds
112-
, Length is ~ Length (Apply is ds)
113-
, Take (Length as) (Apply fs as :++ Apply hs cs) ~ Apply fs as
114109
, Take (Length as) (as :++ cs) ~ as
115110
, Take (Length as) (fs :++ hs) ~ fs
116-
, Drop (Length as) (Apply fs as :++ Apply hs cs) ~ Apply hs cs
117111
, Drop (Length as) (as :++ cs) ~ cs
118112
, Drop (Length as) (fs :++ hs) ~ hs
119-
, AppendP gs bs (Apply gs bs) is ds (Apply is ds)
113+
, AppendP gs bs is ds
120114
)
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
123117
-> AST.Circuit
124118
(fs :++ hs)
125119
(as :++ cs)
126-
(Apply fs as :++ Apply hs cs)
127120
(gs :++ is)
128121
(bs :++ ds)
129-
(Apply gs bs :++ Apply is ds)
130122
(nfs :+ nhs)
131-
(<>) l r = IIn7 (inj (AST.Beside l r))
123+
(<>) l r = IIn5 (inj (AST.Beside l r))
132124
infixr 5 <>
133125

134126
{-|
@@ -142,40 +134,40 @@ In diagram form this would look like,
142134
-}
143135
swap
144136
:: (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
147139

148140
{-|
149141
Takes two values as input and drops the left input.
150142
-}
151143
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
154146

155147
{-|
156148
Takes two values as input and drops the right input.
157149
-}
158150
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
161153

162154
{-|
163155
Maps a circuit on the inputs
164156
-}
165157
mapC
166158
:: (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)
170162

171163
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
173165

174166
instance (DataStore f a, Eq a, Eq (f a)) => ReplicateN ('Succ ('Succ 'Zero)) f a where
175167
replicateN (SSucc (SSucc SZero)) = replicate2
176168

177169
instance (DataStore f a, Eq a, Eq (f a)) => ReplicateN ('Succ ('Succ ('Succ 'Zero))) f a where
178170
replicateN (SSucc n) = replicate2 <-> id <> replicateN n
179171

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
181173
replicateMany = undefined

src/Pipeline/DataStore.hs

-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module Pipeline.DataStore
3434

3535
import Pipeline.Internal.Core.DataStore (DataStore (..),
3636
DataStore' (..), Var, emptyVar)
37-
import Pipeline.Internal.Core.UUID (JobUUID)
3837
import Pipeline.Internal.Backend.FileGen (createNewFile)
3938

4039
import Control.DeepSeq (NFData)
@@ -47,7 +46,6 @@ import Data.Csv (DefaultOrdered,
4746
encodeDefaultOrderedByName)
4847
import qualified Data.Vector as V (toList)
4948
import GHC.Generics (Generic)
50-
import System.FilePath (splitFileName, (</>))
5149

5250

5351
{-|

0 commit comments

Comments
 (0)