module DynListLF(dynListLF) where
import Fudget
import CompOps((>+<))
import DynListF
import Dynforkmerge(DynMsg(..))
import Loops(loopThroughRightF)
import SerCompF(concatMapF)
import UserLayoutF
--import Geometry
import LayoutRequest
import LayoutSP(dynLayoutMgrF)
import LayoutF(LayoutDirection(..))

dynListLF :: Placer -> F (Int, DynFMsg a b) (Int, b)
dynListLF :: Placer -> F (Int, DynFMsg a b) (Int, b)
dynListLF Placer
lter =
  F (Either
     (Either (Path, Rect) (Either (Path, LayoutMessage) (Int, b)))
     (Int, DynFMsg a b))
  (Either
     (Either
        (Either (Path, LayoutMessage) (Int, Bool))
        (Either (Path, Rect) (Int, DynFMsg a b)))
     (Int, b))
-> F (Either
        (Either (Path, LayoutMessage) (Int, Bool))
        (Either (Path, Rect) (Int, DynFMsg a b)))
     (Either (Path, Rect) (Either (Path, LayoutMessage) (Int, b)))
-> F (Int, DynFMsg a b) (Int, b)
forall a b c d. F (Either a b) (Either c d) -> F c a -> F b d
loopThroughRightF
    ((Either
   (Either (Path, Rect) (Either (Path, LayoutMessage) (Int, b)))
   (Int, DynFMsg a b)
 -> [Either
       (Either
          (Either (Path, LayoutMessage) (Int, Bool))
          (Either (Path, Rect) (Int, DynFMsg a b)))
       (Int, b)])
-> F (Either
        (Either (Path, Rect) (Either (Path, LayoutMessage) (Int, b)))
        (Int, DynFMsg a b))
     (Either
        (Either
           (Either (Path, LayoutMessage) (Int, Bool))
           (Either (Path, Rect) (Int, DynFMsg a b)))
        (Int, b))
forall a b. (a -> [b]) -> F a b
concatMapF Either
  (Either (Path, Rect) (Either (Path, LayoutMessage) (Int, b)))
  (Int, DynFMsg a b)
-> [Either
      (Either
         (Either (Path, LayoutMessage) (Int, Bool))
         (Either (Path, Rect) (Int, DynFMsg a b)))
      (Int, b)]
forall a a b a a b.
Either (Either a (Either a b)) (a, DynMsg a b)
-> [Either
      (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b]
ctrl) (Int
-> LayoutDirection
-> Placer
-> F (Either (Path, LayoutMessage) (Int, Bool)) (Path, Rect)
dynLayoutMgrF Int
0 LayoutDirection
Forward Placer
lterF (Either (Path, LayoutMessage) (Int, Bool)) (Path, Rect)
-> F (Either (Path, Rect) (Int, DynFMsg a b))
     (Either (Path, LayoutMessage) (Int, b))
-> F (Either
        (Either (Path, LayoutMessage) (Int, Bool))
        (Either (Path, Rect) (Int, DynFMsg a b)))
     (Either (Path, Rect) (Either (Path, LayoutMessage) (Int, b)))
forall a b c d. F a b -> F c d -> F (Either a c) (Either b d)
>+<F (Int, DynFMsg a b) (Int, b)
-> F (Either (Path, Rect) (Int, DynFMsg a b))
     (Either (Path, LayoutMessage) (Int, b))
forall a b.
F a b -> F (Either (Path, Rect) a) (Either (Path, LayoutMessage) b)
userLayoutF F (Int, DynFMsg a b) (Int, b)
forall a b. F (Int, DynFMsg a b) (Int, b)
dynListF)

ctrl :: Either (Either a (Either a b)) (a, DynMsg a b)
-> [Either
      (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b]
ctrl Either (Either a (Either a b)) (a, DynMsg a b)
msg =
  case Either (Either a (Either a b)) (a, DynMsg a b)
msg of
    Right dyn :: (a, DynMsg a b)
dyn@(a
i,DynMsg a b
dynmsg) ->
      case DynMsg a b
dynmsg of
        DynCreate b
_ -> [(a, Bool)
-> Either
     (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b
forall b a b b. b -> Either (Either (Either a b) b) b
toMgrDyn (a
i,Bool
True),(a, DynMsg a b)
-> Either
     (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b
forall b a a b. b -> Either (Either a (Either a b)) b
toDyn (a, DynMsg a b)
dyn]
	DynMsg a b
DynDestroy -> [(a, Bool)
-> Either
     (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b
forall b a b b. b -> Either (Either (Either a b) b) b
toMgrDyn (a
i,Bool
False),(a, DynMsg a b)
-> Either
     (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b
forall b a a b. b -> Either (Either a (Either a b)) b
toDyn (a, DynMsg a b)
dyn]
	DynMsg a
_ -> [(a, DynMsg a b)
-> Either
     (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b
forall b a a b. b -> Either (Either a (Either a b)) b
toDyn (a, DynMsg a b)
dyn]
    Left (Left a
pp) -> [a
-> Either
     (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b
forall a a b b. a -> Either (Either a (Either a b)) b
toDynL a
pp]
    Left (Right (Left a
ll)) -> [a
-> Either
     (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b
forall a b b b. a -> Either (Either (Either a b) b) b
toMgr a
ll]
    Left (Right (Right b
x)) -> [b
-> Either
     (Either (Either a (a, Bool)) (Either a (a, DynMsg a b))) b
forall b a. b -> Either a b
out b
x]

toDyn :: b -> Either (Either a (Either a b)) b
toDyn=Either a (Either a b) -> Either (Either a (Either a b)) b
forall a b. a -> Either a b
Left(Either a (Either a b) -> Either (Either a (Either a b)) b)
-> (b -> Either a (Either a b))
-> b
-> Either (Either a (Either a b)) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either a b -> Either a (Either a b)
forall a b. b -> Either a b
Right(Either a b -> Either a (Either a b))
-> (b -> Either a b) -> b -> Either a (Either a b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> Either a b
forall a b. b -> Either a b
Right
toDynL :: a -> Either (Either a (Either a b)) b
toDynL=Either a (Either a b) -> Either (Either a (Either a b)) b
forall a b. a -> Either a b
Left(Either a (Either a b) -> Either (Either a (Either a b)) b)
-> (a -> Either a (Either a b))
-> a
-> Either (Either a (Either a b)) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either a b -> Either a (Either a b)
forall a b. b -> Either a b
Right(Either a b -> Either a (Either a b))
-> (a -> Either a b) -> a -> Either a (Either a b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either a b
forall a b. a -> Either a b
Left
toMgr :: a -> Either (Either (Either a b) b) b
toMgr=Either (Either a b) b -> Either (Either (Either a b) b) b
forall a b. a -> Either a b
Left(Either (Either a b) b -> Either (Either (Either a b) b) b)
-> (a -> Either (Either a b) b)
-> a
-> Either (Either (Either a b) b) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either a b -> Either (Either a b) b
forall a b. a -> Either a b
Left(Either a b -> Either (Either a b) b)
-> (a -> Either a b) -> a -> Either (Either a b) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either a b
forall a b. a -> Either a b
Left
toMgrDyn :: b -> Either (Either (Either a b) b) b
toMgrDyn=Either (Either a b) b -> Either (Either (Either a b) b) b
forall a b. a -> Either a b
Left(Either (Either a b) b -> Either (Either (Either a b) b) b)
-> (b -> Either (Either a b) b)
-> b
-> Either (Either (Either a b) b) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either a b -> Either (Either a b) b
forall a b. a -> Either a b
Left(Either a b -> Either (Either a b) b)
-> (b -> Either a b) -> b -> Either (Either a b) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> Either a b
forall a b. b -> Either a b
Right
out :: b -> Either a b
out=b -> Either a b
forall a b. b -> Either a b
Right