@@ -197,10 +197,10 @@ bestow2R ones twos level (S4 l1 l3 l4) = case twos of
197
197
L3R lower n1 n2 n3 -> L3RL level l1 (L2RL lower n1 n2) n3
198
198
199
199
200
- npushl :: NLayered n Pair a ->
201
- S4 a n L0Exposed rexposure ->
202
- S4 a n L2Exposed rexposure
203
- npushl a (S4 l1 l3 l4) = case l1 of
200
+ naiveInjectLeft :: NLayered n Pair a ->
201
+ S4 a n L0Exposed rexposure ->
202
+ S4 a n L2Exposed rexposure
203
+ naiveInjectLeft a (S4 l1 l3 l4) = case l1 of
204
204
L1L (LH1 l, RH1 r) m1 ->
205
205
pushMU (LH2 (Pair a l), RH1 r) (S4 m1 l3 l4)
206
206
L1E -> case l3 of
@@ -219,34 +219,34 @@ npushl a (S4 l1 l3 l4) = case l1 of
219
219
L4E (Final5 p q r s b) -> S4 (L1L (LH1 a, RH1 b) L1E )
220
220
L3E (L4E (Final2 (LN (Pair p q)) (LN (Pair r s))))
221
221
222
- fix2l :: S4 a n L2Exposed rexposure ->
223
- S4 a n L0Exposed rexposure
224
- fix2l (S4 l1 l3 l4) = case l3 of
222
+ fix2ExposureLeft :: S4 a n L2Exposed rexposure ->
223
+ S4 a n L0Exposed rexposure
224
+ fix2ExposureLeft (S4 l1 l3 l4) = case l3 of
225
225
L3L (LH2 l, RH1 r) m1 m2 m3 ->
226
226
bestowL l1 (LH0 () , RH1 r) $
227
- npushl (LN l) $
227
+ naiveInjectLeft (LN l) $
228
228
push2l m1 m2 m3 l4
229
229
L3R level m1 m2 m3 -> bestowR l1 level $ case m3 of
230
230
L3LL (LH2 l, RH1 r) n1 n2 n3 ->
231
231
bestow2L m1 m2 (LH0 () , RH1 r) $
232
- npushl (LN l) $
232
+ naiveInjectLeft (LN l) $
233
233
push2l n1 n2 n3 l4
234
234
L3LE -> push2r m1 m2 L3LE $ case l4 of
235
235
L4 (LH2 l, r) rest ->
236
- L4 (LH0 () , r) (npushl (LN l) rest)
236
+ L4 (LH0 () , r) (naiveInjectLeft (LN l) rest)
237
237
L4E final -> L4E final
238
238
L3E -> S4 l1 L3E $ case l4 of
239
239
L4 (LH2 l, r) rest ->
240
- L4 (LH0 () , r) (npushl (LN l) rest)
240
+ L4 (LH0 () , r) (naiveInjectLeft (LN l) rest)
241
241
L4E final -> L4E final
242
242
243
- pushl :: a -> Queue a -> Queue a
244
- pushl a Q0 = QN (S4 L1E L3E (L4E (Final1 (L0 a))))
245
- pushl a (QN q) = QN (fix2l (npushl (L0 a) q))
243
+ injectLeft :: a -> Queue a -> Queue a
244
+ injectLeft a Q0 = QN (S4 L1E L3E (L4E (Final1 (L0 a))))
245
+ injectLeft a (QN q) = QN (fix2ExposureLeft (naiveInjectLeft (L0 a) q))
246
246
247
- npopl :: S4 a n L2Exposed rexposure ->
248
- (NLayered n Pair a , Maybe (S4 a n L0Exposed rexposure ))
249
- npopl (S4 l1 l3 l4) = case l1 of
247
+ naiveEjectLeft :: S4 a n L2Exposed rexposure ->
248
+ (NLayered n Pair a , Maybe (S4 a n L0Exposed rexposure ))
249
+ naiveEjectLeft (S4 l1 l3 l4) = case l1 of
250
250
L1L (LH1 a, RH1 r) m1 -> (a, Just rest) where
251
251
rest = pushMU (LH0 () , RH1 r) (S4 m1 l3 l4)
252
252
L1E -> case l3 of
@@ -264,43 +264,47 @@ npopl (S4 l1 l3 l4) = case l1 of
264
264
L4E (Final2 a b) -> (a, Just (S4 L1E L3E (L4E (Final1 b))))
265
265
L4E (Final1 a) -> (a, Nothing )
266
266
267
- fix0l :: S4 a n L0Exposed rexposure ->
268
- S4 a n L2Exposed rexposure
269
- fix0l (S4 l1 l3 l4) = case l3 of
270
- L3L (LH0 () , RH1 r) m1 m2 m3 -> case npopl (push2l m1 m2 m3 l4) of
271
- (LN l, Just result) -> bestowL l1 (LH2 l, RH1 r) result
272
- (LN (Pair a b), Nothing ) -> S4 l1 L3E (L4E (Final3 a b r))
267
+ fix0ExposureLeft :: S4 a n L0Exposed rexposure ->
268
+ S4 a n L2Exposed rexposure
269
+ fix0ExposureLeft (S4 l1 l3 l4) = case l3 of
270
+ L3L (LH0 () , RH1 r) m1 m2 m3 ->
271
+ case naiveEjectLeft (push2l m1 m2 m3 l4) of
272
+ (LN l, Just result) -> bestowL l1 (LH2 l, RH1 r) result
273
+ (LN (Pair a b), Nothing ) -> S4 l1 L3E (L4E (Final3 a b r))
273
274
L3R level m1 m2 m3 -> bestowR l1 level $ case m3 of
274
- L3LL (LH0 () , RH1 r) n1 n2 n3 -> case npopl (push2l n1 n2 n3 l4) of
275
- (LN l, Just result) ->
276
- bestow2L m1 m2 (LH2 l, RH1 r) result
277
- (LN (Pair a b), Nothing ) ->
278
- push2r m1 m2 L3LE (L4E (Final3 a b r))
275
+ L3LL (LH0 () , RH1 r) n1 n2 n3 ->
276
+ case naiveEjectLeft (push2l n1 n2 n3 l4) of
277
+ (LN l, Just result) ->
278
+ bestow2L m1 m2 (LH2 l, RH1 r) result
279
+ (LN (Pair a b), Nothing ) ->
280
+ push2r m1 m2 L3LE (L4E (Final3 a b r))
279
281
L3LE -> push2r m1 m2 L3LE $ case l4 of
280
- L4 (LH0 () , r) rest -> case npopl rest of
282
+ L4 (LH0 () , r) rest ->
283
+ case naiveEjectLeft rest of
284
+ (LN l, Just new) -> L4 (LH2 l, r) new
285
+ (LN (Pair a b), Nothing ) -> case r of
286
+ RH0 () -> L4E (Final2 a b)
287
+ RH2 (Pair q r) -> L4E (Final4 a b q r)
288
+ L4E final -> L4E final
289
+ L3E -> S4 l1 L3E $ case l4 of
290
+ L4 (LH0 () , r) rest ->
291
+ case naiveEjectLeft rest of
281
292
(LN l, Just new) -> L4 (LH2 l, r) new
282
293
(LN (Pair a b), Nothing ) -> case r of
283
294
RH0 () -> L4E (Final2 a b)
284
295
RH2 (Pair q r) -> L4E (Final4 a b q r)
285
- L4E final -> L4E final
286
- L3E -> S4 l1 L3E $ case l4 of
287
- L4 (LH0 () , r) rest -> case npopl rest of
288
- (LN l, Just new) -> L4 (LH2 l, r) new
289
- (LN (Pair a b), Nothing ) -> case r of
290
- RH0 () -> L4E (Final2 a b)
291
- RH2 (Pair q r) -> L4E (Final4 a b q r)
292
296
L4E final -> L4E final
293
297
294
- popl :: Queue a -> Maybe (a , Queue a )
295
- popl Q0 = Nothing
296
- popl (QN q) = case npopl (fix0l q) of
298
+ ejectLeft :: Queue a -> Maybe (a , Queue a )
299
+ ejectLeft Q0 = Nothing
300
+ ejectLeft (QN q) = case naiveEjectLeft (fix0ExposureLeft q) of
297
301
(L0 a, Nothing ) -> Just (a, Q0 )
298
302
(L0 a, Just q) -> Just (a, QN q)
299
303
300
- npushr :: NLayered n Pair a ->
301
- S4 a n lexposure R0Exposed ->
302
- S4 a n lexposure R2Exposed
303
- npushr z (S4 l1 l3 l4) = case l1 of
304
+ naiveInjectRight :: NLayered n Pair a ->
305
+ S4 a n lexposure R0Exposed ->
306
+ S4 a n lexposure R2Exposed
307
+ naiveInjectRight z (S4 l1 l3 l4) = case l1 of
304
308
L1L (LH1 l, RH1 r) m1 ->
305
309
pushUM (LH1 l, RH2 (Pair r z)) (S4 m1 l3 l4)
306
310
L1E -> case l3 of
@@ -319,34 +323,34 @@ npushr z (S4 l1 l3 l4) = case l1 of
319
323
L4E (Final5 a p q r s) -> S4 (L1L (LH1 a, RH1 z) L1E )
320
324
L3E (L4E (Final2 (LN (Pair p q)) (LN (Pair r s))))
321
325
322
- fix2r :: S4 a n lexposure R2Exposed ->
323
- S4 a n lexposure R0Exposed
324
- fix2r (S4 l1 l3 l4) = case l3 of
326
+ fix2ExposureRight :: S4 a n lexposure R2Exposed ->
327
+ S4 a n lexposure R0Exposed
328
+ fix2ExposureRight (S4 l1 l3 l4) = case l3 of
325
329
L3R (LH1 l, RH2 r) m1 m2 m3 ->
326
330
bestowR l1 (LH1 l, RH0 () ) $
327
- npushr (LN r) $
331
+ naiveInjectRight (LN r) $
328
332
push2r m1 m2 m3 l4
329
333
L3L level m1 m2 m3 -> bestowL l1 level $ case m3 of
330
334
L3RL (LH1 l, RH2 r) n1 n2 n3 ->
331
335
bestow2R m1 m2 (LH1 l, RH0 () ) $
332
- npushr (LN r) $
336
+ naiveInjectRight (LN r) $
333
337
push2r n1 n2 n3 l4
334
338
L3RE -> push2l m1 m2 L3RE $ case l4 of
335
339
L4 (l, RH2 r) rest ->
336
- L4 (l, RH0 () ) (npushr (LN r) rest)
340
+ L4 (l, RH0 () ) (naiveInjectRight (LN r) rest)
337
341
L4E final -> L4E final
338
342
L3E -> S4 l1 L3E $ case l4 of
339
343
L4 (l, RH2 r) rest ->
340
- L4 (l, RH0 () ) (npushr (LN r) rest)
344
+ L4 (l, RH0 () ) (naiveInjectRight (LN r) rest)
341
345
L4E final -> L4E final
342
346
343
- pushr :: a -> Queue a -> Queue a
344
- pushr z Q0 = QN (S4 L1E L3E (L4E (Final1 (L0 z))))
345
- pushr z (QN q) = QN (fix2r (npushr (L0 z) q))
347
+ injectRight :: a -> Queue a -> Queue a
348
+ injectRight z Q0 = QN (S4 L1E L3E (L4E (Final1 (L0 z))))
349
+ injectRight z (QN q) = QN (fix2ExposureRight (naiveInjectRight (L0 z) q))
346
350
347
- npopr :: S4 a n lexposure R2Exposed ->
348
- (NLayered n Pair a , Maybe (S4 a n lexposure R0Exposed ))
349
- npopr (S4 l1 l3 l4) = case l1 of
351
+ naiveEjectRight :: S4 a n lexposure R2Exposed ->
352
+ (NLayered n Pair a , Maybe (S4 a n lexposure R0Exposed ))
353
+ naiveEjectRight (S4 l1 l3 l4) = case l1 of
350
354
L1L (LH1 l, RH1 z) m1 -> (z, Just rest) where
351
355
rest = pushUM (LH1 l, RH0 () ) (S4 m1 l3 l4)
352
356
L1E -> case l3 of
@@ -364,35 +368,39 @@ npopr (S4 l1 l3 l4) = case l1 of
364
368
L4E (Final2 y z) -> (z, Just (S4 L1E L3E (L4E (Final1 y))))
365
369
L4E (Final1 z) -> (z, Nothing )
366
370
367
- fix0r :: S4 a n lexposure R0Exposed ->
368
- S4 a n lexposure R2Exposed
369
- fix0r (S4 l1 l3 l4) = case l3 of
370
- L3R (LH1 l, RH0 () ) m1 m2 m3 -> case npopr (push2r m1 m2 m3 l4) of
371
- (LN r, Just result) -> bestowR l1 (LH1 l, RH2 r) result
372
- (LN (Pair a b), Nothing ) -> S4 l1 L3E (L4E (Final3 l a b))
371
+ fix0ExposureRight :: S4 a n lexposure R0Exposed ->
372
+ S4 a n lexposure R2Exposed
373
+ fix0ExposureRight (S4 l1 l3 l4) = case l3 of
374
+ L3R (LH1 l, RH0 () ) m1 m2 m3 ->
375
+ case naiveEjectRight (push2r m1 m2 m3 l4) of
376
+ (LN r, Just result) -> bestowR l1 (LH1 l, RH2 r) result
377
+ (LN (Pair a b), Nothing ) -> S4 l1 L3E (L4E (Final3 l a b))
373
378
L3L level m1 m2 m3 -> bestowL l1 level $ case m3 of
374
- L3RL (LH1 l, RH0 () ) n1 n2 n3 -> case npopr (push2r n1 n2 n3 l4) of
375
- (LN r, Just result) ->
376
- bestow2R m1 m2 (LH1 l, RH2 r) result
377
- (LN (Pair a b), Nothing ) ->
378
- push2l m1 m2 L3RE (L4E (Final3 l a b))
379
+ L3RL (LH1 l, RH0 () ) n1 n2 n3 ->
380
+ case naiveEjectRight (push2r n1 n2 n3 l4) of
381
+ (LN r, Just result) ->
382
+ bestow2R m1 m2 (LH1 l, RH2 r) result
383
+ (LN (Pair a b), Nothing ) ->
384
+ push2l m1 m2 L3RE (L4E (Final3 l a b))
379
385
L3RE -> push2l m1 m2 L3RE $ case l4 of
380
- L4 (l, RH0 () ) rest -> case npopr rest of
386
+ L4 (l, RH0 () ) rest ->
387
+ case naiveEjectRight rest of
388
+ (LN r, Just new) -> L4 (l, RH2 r) new
389
+ (LN (Pair a b), Nothing ) -> case l of
390
+ LH0 () -> L4E (Final2 a b)
391
+ LH2 (Pair q r) -> L4E (Final4 q r a b)
392
+ L4E final -> L4E final
393
+ L3E -> S4 l1 L3E $ case l4 of
394
+ L4 (l, RH0 () ) rest ->
395
+ case naiveEjectRight rest of
381
396
(LN r, Just new) -> L4 (l, RH2 r) new
382
397
(LN (Pair a b), Nothing ) -> case l of
383
398
LH0 () -> L4E (Final2 a b)
384
399
LH2 (Pair q r) -> L4E (Final4 q r a b)
385
- L4E final -> L4E final
386
- L3E -> S4 l1 L3E $ case l4 of
387
- L4 (l, RH0 () ) rest -> case npopr rest of
388
- (LN r, Just new) -> L4 (l, RH2 r) new
389
- (LN (Pair a b), Nothing ) -> case l of
390
- LH0 () -> L4E (Final2 a b)
391
- LH2 (Pair q r) -> L4E (Final4 q r a b)
392
400
L4E final -> L4E final
393
401
394
- popr :: Queue a -> Maybe (a , Queue a )
395
- popr Q0 = Nothing
396
- popr (QN q) = case npopr (fix0r q) of
402
+ ejectRight :: Queue a -> Maybe (a , Queue a )
403
+ ejectRight Q0 = Nothing
404
+ ejectRight (QN q) = case naiveEjectRight (fix0ExposureRight q) of
397
405
(L0 z, Nothing ) -> Just (z, Q0 )
398
406
(L0 z, Just q) -> Just (z, QN q)
0 commit comments