module InputF(module InputF) where
import Fudget
import InputMsg
import CompOps
import ListF(listF)
import Placer(placerF)
import LayoutF(orientP)
import EitherUtils(stripEither)
import Spops
import InputSP
import AuxTypes() -- synonym KeySym, for hbc
import SpEither(splitSP)
import SerCompF(mapF,toBothF)

type InF a b = F a (InputMsg b)

inputPairLF :: Orientation
-> InF a1 b1 -> InF a2 b2 -> F (a1, a2) (InputMsg (b1, b2))
inputPairLF Orientation
orient InF a1 b1
f1 InF a2 b2
f2 = forall a b. Placer -> F a b -> F a b
placerF (Orientation -> Placer
orientP Orientation
orient) forall a b. (a -> b) -> a -> b
$ forall a1 b1 a2 b2. InF a1 b1 -> InF a2 b2 -> InF (a1, a2) (b1, b2)
inputPairF InF a1 b1
f1 InF a2 b2
f2
inputListLF :: Placer -> [(a, InF b c)] -> F [(a, b)] (InputMsg [(a, c)])
inputListLF Placer
placer [(a, InF b c)]
tfs = forall a b. Placer -> F a b -> F a b
placerF Placer
placer forall a b. (a -> b) -> a -> b
$ forall a b c. Eq a => [(a, InF b c)] -> InF [(a, b)] [(a, c)]
inputListF [(a, InF b c)]
tfs

inputPairF :: InF a1 b1 -> InF a2 b2 -> InF (a1,a2) (b1,b2)
inputPairF :: forall a1 b1 a2 b2. InF a1 b1 -> InF a2 b2 -> InF (a1, a2) (b1, b2)
inputPairF InF a1 b1
f1 InF a2 b2
f2 = forall {a} {b}.
SP (Either (InputMsg a) (InputMsg b)) (InputMsg (a, b))
inputPairSP forall a b e. SP a b -> F e a -> F e b
>^^=< (InF a1 b1
f1forall {a} {b} {c} {d}.
F a b -> F c d -> F (Either a c) (Either b d)
>+<InF a2 b2
f2) forall c d e. F c d -> SP e c -> F e d
>=^^< forall {a} {b}. SP (a, b) (Either a b)
splitSP

inputListF :: (Eq a) => [(a, InF b c)] -> InF [(a, b)] [(a, c)] 
inputListF :: forall a b c. Eq a => [(a, InF b c)] -> InF [(a, b)] [(a, c)]
inputListF [(a, InF b c)]
tfs =
  forall {p1} {p2}.
Eq p1 =>
[p1] -> SP (p1, InputMsg p2) (InputMsg [(p1, p2)])
inputListSP (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(a, InF b c)]
tfs) forall a b e. SP a b -> F e a -> F e b
>^^=< forall a b c. Eq a => [(a, F b c)] -> F (a, b) (a, c)
listF [(a
t,InF b c
f)|(a
t,InF b c
f)<-[(a, InF b c)]
tfs] forall c d e. F c d -> SP e c -> F e d
>=^^< forall {b}. SP [b] b
concatSP

inputThroughF :: InF a a -> InF a a
inputThroughF :: forall a. InF a a -> InF a a
inputThroughF InF a a
f = forall {a}. Either a a -> a
stripEitherforall a b e. (a -> b) -> F e a -> F e b
>^=<(InF a a
fforall {a} {b} {c} {d}.
F a b -> F c d -> F (Either a c) (Either b d)
>+<forall {a} {b}. (a -> b) -> F a b
mapF forall a. a -> InputMsg a
InputChange)forall {a1} {b} {a2}. F a1 b -> F a2 a1 -> F a2 b
>==<forall {b}. F b (Either b b)
toBothF