module Data.Graph.Inductive.Internal.Thread(
Split, SplitM, Thread, Collect,
threadList', threadList, threadMaybe', threadMaybe, splitPar, splitParM
) where
type Split t i r = i -> t -> (r,t)
type Thread t i r = (t,Split t i r)
type Collect r c = (r -> c -> c,c)
threadList' :: Collect r c -> Split t i r -> [i] -> t -> (c,t)
threadList' :: forall r c t i. Collect r c -> Split t i r -> [i] -> t -> (c, t)
threadList' (r -> c -> c
_,c
c) Split t i r
_ [] t
t = (c
c,t
t)
threadList' (r -> c -> c
f,c
c) Split t i r
split (i
i:[i]
is) t
t = forall r c t i. Collect r c -> Split t i r -> [i] -> t -> (c, t)
threadList' (r -> c -> c
f,r -> c -> c
f r
r c
c) Split t i r
split [i]
is t
t'
where (r
r,t
t') = Split t i r
split i
i t
t
threadList :: Collect r c -> Split t i r -> [i] -> t -> (c,t)
threadList :: forall r c t i. Collect r c -> Split t i r -> [i] -> t -> (c, t)
threadList (r -> c -> c
_,c
c) Split t i r
_ [] t
t = (c
c,t
t)
threadList (r -> c -> c
f,c
c) Split t i r
split (i
i:[i]
is) t
t = (r -> c -> c
f r
r c
c',t
t'')
where (r
r,t
t') = Split t i r
split i
i t
t
(c
c',t
t'') = forall r c t i. Collect r c -> Split t i r -> [i] -> t -> (c, t)
threadList (r -> c -> c
f,c
c) Split t i r
split [i]
is t
t'
type SplitM t i r = Split t i (Maybe r)
threadMaybe' :: (r->a)->Split t i r->Split t j (Maybe i)->Split t j (Maybe a)
threadMaybe' :: forall r a t i j.
(r -> a)
-> Split t i r -> Split t j (Maybe i) -> Split t j (Maybe a)
threadMaybe' r -> a
f Split t i r
cont Split t j (Maybe i)
split j
j t
t =
case Maybe i
mi of Just i
i -> (forall a. a -> Maybe a
Just (r -> a
f r
r),t
t'') where (r
r,t
t'') = Split t i r
cont i
i t
t'
Maybe i
Nothing -> (forall a. Maybe a
Nothing,t
t')
where (Maybe i
mi,t
t') = Split t j (Maybe i)
split j
j t
t
threadMaybe :: (i -> r -> a) -> Split t i r -> SplitM t j i -> SplitM t j a
threadMaybe :: forall i r a t j.
(i -> r -> a) -> Split t i r -> SplitM t j i -> SplitM t j a
threadMaybe i -> r -> a
f Split t i r
cont SplitM t j i
split j
j t
t =
case Maybe i
mi of Just i
i -> (forall a. a -> Maybe a
Just (i -> r -> a
f i
i r
r),t
t'') where (r
r,t
t'') = Split t i r
cont i
i t
t'
Maybe i
Nothing -> (forall a. Maybe a
Nothing,t
t')
where (Maybe i
mi,t
t') = SplitM t j i
split j
j t
t
splitPar :: Split t i r -> Split u j s -> Split (t,u) (i,j) (r,s)
splitPar :: forall t i r u j s.
Split t i r -> Split u j s -> Split (t, u) (i, j) (r, s)
splitPar Split t i r
split Split u j s
split' (i
i,j
j) (t
t,u
u) = ((r
r,s
s),(t
t',u
u'))
where (r
r,t
t') = Split t i r
split i
i t
t
(s
s,u
u') = Split u j s
split' j
j u
u
splitParM :: SplitM t i r -> Split u j s -> SplitM (t,u) (i,j) (r,s)
splitParM :: forall t i r u j s.
SplitM t i r -> Split u j s -> SplitM (t, u) (i, j) (r, s)
splitParM SplitM t i r
splitm Split u j s
split (i
i,j
j) (t
t,u
u) =
case Maybe r
mr of Just r
r -> (forall a. a -> Maybe a
Just (r
r,s
s),(t
t',u
u'))
Maybe r
Nothing -> (forall a. Maybe a
Nothing,(t
t',u
u))
where (Maybe r
mr,t
t') = SplitM t i r
splitm i
i t
t
(s
s,u
u') = Split u j s
split j
j u
u