module ParSP(seqSP, parSP) where
import SP

parSP :: SP a b -> SP a b -> SP a b
parSP SP a b
sp1 SP a b
sp2 =
    case SP a b
sp1 of
      PutSP b
y SP a b
sp1' -> b -> SP a b -> SP a b
forall a b. b -> SP a b -> SP a b
PutSP b
y (SP a b -> SP a b -> SP a b
parSP SP a b
sp1' SP a b
sp2)
      GetSP a -> SP a b
xsp1 -> (a -> SP a b) -> SP a b -> SP a b
parSP1 a -> SP a b
xsp1 SP a b
sp2
      SP a b
NullSP -> SP a b
sp2

parSP1 :: (a -> SP a b) -> SP a b -> SP a b
parSP1 a -> SP a b
xsp1 SP a b
sp2 =
    case SP a b
sp2 of
      PutSP b
y SP a b
sp2' -> b -> SP a b -> SP a b
forall a b. b -> SP a b -> SP a b
PutSP b
y ((a -> SP a b) -> SP a b -> SP a b
parSP1 a -> SP a b
xsp1 SP a b
sp2')
      GetSP a -> SP a b
xsp2 -> (a -> SP a b) -> SP a b
forall a b. (a -> SP a b) -> SP a b
GetSP (\a
x -> SP a b -> SP a b -> SP a b
parSP (a -> SP a b
xsp1 a
x) (a -> SP a b
xsp2 a
x))
      SP a b
NullSP -> (a -> SP a b) -> SP a b
forall a b. (a -> SP a b) -> SP a b
GetSP a -> SP a b
xsp1

seqSP :: SP a b -> SP a b -> SP a b
seqSP SP a b
sp1 SP a b
sp2 =
    case SP a b
sp1 of
      PutSP b
y SP a b
sp1' -> b -> SP a b -> SP a b
forall a b. b -> SP a b -> SP a b
PutSP b
y (SP a b -> SP a b -> SP a b
seqSP SP a b
sp1' SP a b
sp2)
      GetSP a -> SP a b
xsp -> (a -> SP a b) -> SP a b
forall a b. (a -> SP a b) -> SP a b
GetSP (\a
x -> SP a b -> SP a b -> SP a b
seqSP (a -> SP a b
xsp a
x) SP a b
sp2)
      SP a b
NullSP -> SP a b
sp2