{-# LANGUAGE CPP #-}
module FileShellF(
#ifndef __NHC__
  fileShellF,fileShellF',
   textFileShellF,textFileShellF',
   showReadFileShellF,showReadFileShellF'
#endif
 ) where
import Fudgets
import FilePickPopupF
import TitleShellF(titleShellF')
import MenuBarF
#ifndef __NHC__
          (menuBarF,menu,idT,item,cmdItem,key)
#endif
import DialogueIO
import Prelude hiding (IOError)
import Data.Maybe(isJust,fromJust,fromMaybe)
import Data.Char(isSpace)

#ifndef __NHC__

textFileShellF :: [Char] -> F [Char] (InputMsg [Char]) -> F c d
textFileShellF = (ShellF -> ShellF) -> [Char] -> F [Char] (InputMsg [Char]) -> F c d
forall c d.
(ShellF -> ShellF) -> [Char] -> F [Char] (InputMsg [Char]) -> F c d
textFileShellF' ShellF -> ShellF
forall a. Customiser a
standard
textFileShellF' :: (ShellF -> ShellF) -> [Char] -> F [Char] (InputMsg [Char]) -> F c d
textFileShellF' ShellF -> ShellF
customiser = (ShellF -> ShellF)
-> ([Char] -> [Char], [Char] -> Either [Char] [Char], Maybe [Char])
-> [Char]
-> F [Char] (InputMsg [Char])
-> F c d
forall c c d.
(ShellF -> ShellF)
-> (c -> [Char], [Char] -> Either [Char] c, Maybe c)
-> [Char]
-> F c (InputMsg c)
-> F c d
fileShellF' ShellF -> ShellF
customiser ([Char] -> [Char], [Char] -> Either [Char] [Char], Maybe [Char])
forall a b a. (a -> a, b -> Either a b, Maybe [Char])
textConv
  where textConv :: (a -> a, b -> Either a b, Maybe [Char])
textConv = (a -> a
forall a. Customiser a
id,b -> Either a b
forall a b. b -> Either a b
Right,[Char] -> Maybe [Char]
forall a. a -> Maybe a
Just [Char]
"")

showReadFileShellF :: Maybe a -> [Char] -> F a (InputMsg a) -> F c d
showReadFileShellF Maybe a
empty = (ShellF -> ShellF)
-> Maybe a -> [Char] -> F a (InputMsg a) -> F c d
forall a c d.
(Show a, Read a) =>
(ShellF -> ShellF)
-> Maybe a -> [Char] -> F a (InputMsg a) -> F c d
showReadFileShellF' ShellF -> ShellF
forall a. Customiser a
standard Maybe a
empty
showReadFileShellF' :: (ShellF -> ShellF)
-> Maybe a -> [Char] -> F a (InputMsg a) -> F c d
showReadFileShellF' ShellF -> ShellF
customiser Maybe a
empty =
    (ShellF -> ShellF)
-> (a -> [Char], [Char] -> Either [Char] a, Maybe a)
-> [Char]
-> F a (InputMsg a)
-> F c d
forall c c d.
(ShellF -> ShellF)
-> (c -> [Char], [Char] -> Either [Char] c, Maybe c)
-> [Char]
-> F c (InputMsg c)
-> F c d
fileShellF' ShellF -> ShellF
customiser (a -> [Char]
forall a. Show a => a -> [Char]
show,[Char] -> Either [Char] a
forall b. Read b => [Char] -> Either [Char] b
parse,Maybe a
empty)
  where
    parse :: [Char] -> Either [Char] b
parse [Char]
contents =
      case ReadS b
forall a. Read a => ReadS a
reads [Char]
contents of
        [(b
x,[Char]
cs)] | (Char -> Bool) -> [Char] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isSpace [Char]
cs -> b -> Either [Char] b
forall a b. b -> Either a b
Right b
x
	[(b, [Char])]
_ -> [Char] -> Either [Char] b
forall a b. a -> Either a b
Left [Char]
"Syntax error in input"



fileShellF :: (c -> [Char], [Char] -> Either [Char] c, Maybe c)
-> [Char] -> F c (InputMsg c) -> F c d
fileShellF = (ShellF -> ShellF)
-> (c -> [Char], [Char] -> Either [Char] c, Maybe c)
-> [Char]
-> F c (InputMsg c)
-> F c d
forall c c d.
(ShellF -> ShellF)
-> (c -> [Char], [Char] -> Either [Char] c, Maybe c)
-> [Char]
-> F c (InputMsg c)
-> F c d
fileShellF' ShellF -> ShellF
forall a. Customiser a
standard

fileShellF' :: (ShellF -> ShellF)
-> (c -> [Char], [Char] -> Either [Char] c, Maybe c)
-> [Char]
-> F c (InputMsg c)
-> F c d
fileShellF' ShellF -> ShellF
customiser (c -> [Char], [Char] -> Either [Char] c, Maybe c)
conv [Char]
title0 F c (InputMsg c)
appF =
    F (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
        (Either FileMenuItem c)))
  Any
-> F c d
forall a b c d. F a b -> F c d
stubF (F (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
         (Either FileMenuItem c)))
   Any
 -> F c d)
-> F (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
           (Either FileMenuItem c)))
     Any
-> F c d
forall a b. (a -> b) -> a -> b
$ F (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
        (Either FileMenuItem c)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
        (Either FileMenuItem c)))
-> F (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
           (Either FileMenuItem c)))
     Any
forall a b. F a a -> F a b
loopOnlyF (F (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
         (Either FileMenuItem c)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
         (Either FileMenuItem c)))
 -> F (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
            (Either FileMenuItem c)))
      Any)
-> F (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
           (Either FileMenuItem c)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
           (Either FileMenuItem c)))
-> F (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
           (Either FileMenuItem c)))
     Any
forall a b. (a -> b) -> a -> b
$ (ShellF -> ShellF)
-> [Char]
-> F (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
        (Either FileMenuItem c))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
           (Either FileMenuItem c)))
-> F (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
           (Either FileMenuItem c)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
           (Either FileMenuItem c)))
forall c d.
(ShellF -> ShellF) -> [Char] -> F c d -> F (Either [Char] c) d
titleShellF' ShellF -> ShellF
customiser [Char]
title0 F (Either
     (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
     (Either FileMenuItem c))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] Any))
        (Either FileMenuItem c)))
forall c b a.
F (Either
     (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
     (Either FileMenuItem c))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a c)))
mainF
  where
    mainF :: F (Either
     (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
     (Either FileMenuItem c))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a c)))
mainF = [Char]
-> (c -> [Char], [Char] -> Either [Char] c, Maybe c)
-> F (Either
        (Either
           ((FileMenuItem, ([Char], Maybe [Char])), [Char])
           (Either ([Char], Click) Any))
        (Either FileMenuItem (InputMsg c)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a c)))
forall b b p p b a.
[Char]
-> (b -> [Char], [Char] -> Either [Char] b, Maybe b)
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
ctrlF [Char]
title0 (c -> [Char], [Char] -> Either [Char] c, Maybe c)
conv F (Either
     (Either
        ((FileMenuItem, ([Char], Maybe [Char])), [Char])
        (Either ([Char], Click) Any))
     (Either FileMenuItem (InputMsg c)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a c)))
-> F (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
        (Either FileMenuItem c))
     (Either
        (Either
           ((FileMenuItem, ([Char], Maybe [Char])), [Char])
           (Either ([Char], Click) Any))
        (Either FileMenuItem (InputMsg c)))
-> F (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
        (Either FileMenuItem c))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a c)))
forall a1 b a2. F a1 b -> F a2 a1 -> F a2 b
>==<
            (F (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
  (Either
     ((FileMenuItem, ([Char], Maybe [Char])), [Char])
     (Either ([Char], Click) Any))
forall c d.
F (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
  (Either
     ((FileMenuItem, ([Char], Maybe [Char])), [Char])
     (Either ([Char], Click) d))
popupsFF (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
  (Either
     ((FileMenuItem, ([Char], Maybe [Char])), [Char])
     (Either ([Char], Click) Any))
-> F (Either FileMenuItem c) (Either FileMenuItem (InputMsg c))
-> F (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
        (Either FileMenuItem c))
     (Either
        (Either
           ((FileMenuItem, ([Char], Maybe [Char])), [Char])
           (Either ([Char], Click) Any))
        (Either FileMenuItem (InputMsg c)))
forall a b c d. F a b -> F c d -> F (Either a c) (Either b d)
>+<F (Either FileMenuItem c) (Either FileMenuItem (InputMsg c))
-> F (Either FileMenuItem c) (Either FileMenuItem (InputMsg c))
forall a b. F a b -> F a b
vBoxF (Bool -> F FileMenuItem FileMenuItem
fileShellMenuBarF Bool
hasNewF FileMenuItem FileMenuItem
-> F c (InputMsg c)
-> F (Either FileMenuItem c) (Either FileMenuItem (InputMsg c))
forall a b c d. F a b -> F c d -> F (Either a c) (Either b d)
>+<F c (InputMsg c)
appF))
      where hasNew :: Bool
hasNew = case (c -> [Char], [Char] -> Either [Char] c, Maybe c)
conv of (_,_,e) -> Maybe c -> Bool
forall a. Maybe a -> Bool
isJust Maybe c
e

    popupsF :: F (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
  (Either
     ((FileMenuItem, ([Char], Maybe [Char])), [Char])
     (Either ([Char], Click) d))
popupsF = F (FileMenuItem, ([Char], Maybe [Char]))
  ((FileMenuItem, ([Char], Maybe [Char])), [Char])
filePickPopupF' F (FileMenuItem, ([Char], Maybe [Char]))
  ((FileMenuItem, ([Char], Maybe [Char])), [Char])
-> F (Either [Char] c) (Either ([Char], Click) d)
-> F (Either
        (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] c))
     (Either
        ((FileMenuItem, ([Char], Maybe [Char])), [Char])
        (Either ([Char], Click) d))
forall a b c d. F a b -> F c d -> F (Either a c) (Either b d)
>+<(F [Char] ([Char], Click)
forall msg. Graphic msg => F msg (msg, Click)
messagePopupFF [Char] ([Char], Click)
-> F c d -> F (Either [Char] c) (Either ([Char], Click) d)
forall a b c d. F a b -> F c d -> F (Either a c) (Either b d)
>+<F c d
forall hi ho. F hi ho
nullF{-confirmPopupF-})
      where
        filePickPopupF' :: F (FileMenuItem, ([Char], Maybe [Char]))
  ((FileMenuItem, ([Char], Maybe [Char])), [Char])
filePickPopupF' = [((FileMenuItem, ([Char], Maybe [Char])), [Char])]
-> F (FileMenuItem, ([Char], Maybe [Char]))
     ((FileMenuItem, ([Char], Maybe [Char])), [Char])
-> F (FileMenuItem, ([Char], Maybe [Char]))
     ((FileMenuItem, ([Char], Maybe [Char])), [Char])
forall b a. [b] -> F a b -> F a b
putsF (([Char] -> ((FileMenuItem, ([Char], Maybe [Char])), [Char]))
-> [[Char]] -> [((FileMenuItem, ([Char], Maybe [Char])), [Char])]
forall a b. (a -> b) -> [a] -> [b]
map [Char] -> ((FileMenuItem, ([Char], Maybe [Char])), [Char])
forall b a. b -> ((FileMenuItem, ([Char], Maybe a)), b)
f (Int -> [[Char]] -> [[Char]]
forall a. Int -> [a] -> [a]
take Int
1 [[Char]]
args)) F (FileMenuItem, ([Char], Maybe [Char]))
  ((FileMenuItem, ([Char], Maybe [Char])), [Char])
forall a.
F (a, ([Char], Maybe [Char])) ((a, ([Char], Maybe [Char])), [Char])
filePickPopupF
	f :: b -> ((FileMenuItem, ([Char], Maybe a)), b)
f b
x = ((FileMenuItem
Open,([Char], Maybe a)
forall a. ([Char], Maybe a)
popup),b
x)


messageF :: a
-> F hi (Either a (Either (Either a (Either a b)) b))
-> F hi (Either a (Either (Either a (Either a b)) b))
messageF = Either a (Either (Either a (Either a b)) b)
-> F hi (Either a (Either (Either a (Either a b)) b))
-> F hi (Either a (Either (Either a (Either a b)) b))
forall ho hi. ho -> F hi ho -> F hi ho
putF (Either a (Either (Either a (Either a b)) b)
 -> F hi (Either a (Either (Either a (Either a b)) b))
 -> F hi (Either a (Either (Either a (Either a b)) b)))
-> (a -> Either a (Either (Either a (Either a b)) b))
-> a
-> F hi (Either a (Either (Either a (Either a b)) b))
-> F hi (Either a (Either (Either a (Either a b)) b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either a (Either (Either a (Either a b)) b)
forall a a a b b. a -> Either a (Either (Either a (Either a b)) b)
toMessage
toFilePick :: a -> Either a (Either (Either a b) b)
toFilePick = Either (Either a b) b -> Either a (Either (Either a b) b)
forall a b. b -> Either a b
Right (Either (Either a b) b -> Either a (Either (Either a b) b))
-> (a -> Either (Either a b) b)
-> a
-> Either a (Either (Either a 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
toMessage :: a -> Either a (Either (Either a (Either a b)) b)
toMessage = Either (Either a (Either a b)) b
-> Either a (Either (Either a (Either a b)) b)
forall a b. b -> Either a b
Right (Either (Either a (Either a b)) b
 -> Either a (Either (Either a (Either a b)) b))
-> (a -> Either (Either a (Either a b)) b)
-> a
-> Either a (Either (Either a (Either a b)) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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
--toConfirm = Right . Left . Right . Left
toApp :: b -> Either a (Either a (Either a b))
toApp = Either a (Either a b) -> Either a (Either a (Either a b))
forall a b. b -> Either a b
Right (Either a (Either a b) -> Either a (Either a (Either a b)))
-> (b -> Either a (Either a b))
-> b
-> Either a (Either a (Either a 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
toTitle :: a -> Either a b
toTitle = a -> Either a b
forall a b. a -> Either a b
Left

ctrlF :: [Char]
-> (b -> [Char], [Char] -> Either [Char] b, Maybe b)
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
ctrlF [Char]
title0 (b -> [Char]
show,[Char] -> Either [Char] b
parse,Maybe b
optEmpty) = F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
forall b p p b a.
F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
start
 where
  start :: F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
start = Maybe [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
loop Maybe [Char]
forall a. Maybe a
Nothing Maybe b
forall a. Maybe a
Nothing
  changeTitle :: [Char] -> F hi (Either [Char] b) -> F hi (Either [Char] b)
changeTitle [Char]
name = Either [Char] b -> F hi (Either [Char] b) -> F hi (Either [Char] b)
forall ho hi. ho -> F hi ho -> F hi ho
putF ([Char] -> Either [Char] b
forall a b. a -> Either a b
toTitle ([Char]
title0[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
": "[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
name))
  loop :: Maybe [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
loop Maybe [Char]
filename Maybe b
document =
    Cont
  (F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b))))
  (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
forall a ho. Cont (F a ho) a
getF Cont
  (F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b))))
  (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
-> Cont
     (F (Either
           (Either ((FileMenuItem, b), [Char]) (Either p p))
           (Either FileMenuItem (InputMsg b)))
        (Either
           [Char]
           (Either
              (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
              (Either a b))))
     (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
forall a b. (a -> b) -> a -> b
$ {-either quitMsg-} ((Either ((FileMenuItem, b), [Char]) (Either p p)
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> (Either FileMenuItem (InputMsg b)
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either Either ((FileMenuItem, b), [Char]) (Either p p)
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall b p p.
Either ((FileMenuItem, b), [Char]) (Either p p)
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromPopups ((FileMenuItem
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> (InputMsg b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> Either FileMenuItem (InputMsg b)
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either FileMenuItem
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromMenu InputMsg b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromApp))
   where
    same :: F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same = Maybe [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
loop Maybe [Char]
filename Maybe b
document
    newName :: [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
newName [Char]
name Maybe b
document' = [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall hi b.
[Char] -> F hi (Either [Char] b) -> F hi (Either [Char] b)
changeTitle [Char]
name (F (Either
      (Either ((FileMenuItem, b), [Char]) (Either p p))
      (Either FileMenuItem (InputMsg b)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
         (Either a b)))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$ Maybe [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
loop ([Char] -> Maybe [Char]
forall a. a -> Maybe a
Just [Char]
name) Maybe b
document'
    errMsg :: [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
errMsg [Char]
err = [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a hi a a b b.
a
-> F hi (Either a (Either (Either a (Either a b)) b))
-> F hi (Either a (Either (Either a (Either a b)) b))
messageF [Char]
err F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same

    quitMsg :: ()
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
quitMsg () = F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
terminateProgram

    fromPopups :: Either ((FileMenuItem, b), [Char]) (Either p p)
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromPopups = (((FileMenuItem, b), [Char])
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> (Either p p
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> Either ((FileMenuItem, b), [Char]) (Either p p)
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either ((FileMenuItem, b), [Char])
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall b.
((FileMenuItem, b), [Char])
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromFilePick ((p
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> (p
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> Either p p
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either p
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall p.
p
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromMessage p
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall p.
p
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromConfirm)
    fromMessage :: p
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromMessage p
_ = F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same
    fromConfirm :: p
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromConfirm p
_ = F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same -- !!

    fromMenu :: FileMenuItem
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromMenu FileMenuItem
filecmd =
      case FileMenuItem
filecmd of
	FileMenuItem
Open -> Either
  [Char]
  (Either
     (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
     (Either a b))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall ho hi. ho -> F hi ho -> F hi ho
putF ((FileMenuItem, ([Char], Maybe [Char]))
-> Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b))
forall a a b b. a -> Either a (Either (Either a b) b)
toFilePick (FileMenuItem
Open,([Char]
"Open",Maybe [Char]
forall a. Maybe a
Nothing))) F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same
        FileMenuItem
Save -> ((b
  -> F (Either
          (Either ((FileMenuItem, b), [Char]) (Either p p))
          (Either FileMenuItem (InputMsg b)))
       (Either
          [Char]
          (Either
             (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
             (Either a b))))
 -> Maybe b
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> Maybe b
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b c. (a -> b -> c) -> b -> a -> c
flip (F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same) Maybe b
document ((b
  -> F (Either
          (Either ((FileMenuItem, b), [Char]) (Either p p))
          (Either FileMenuItem (InputMsg b)))
       (Either
          [Char]
          (Either
             (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
             (Either a b))))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$ \ b
doc ->
	        (([Char]
  -> F (Either
          (Either ((FileMenuItem, b), [Char]) (Either p p))
          (Either FileMenuItem (InputMsg b)))
       (Either
          [Char]
          (Either
             (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
             (Either a b))))
 -> Maybe [Char]
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> Maybe [Char]
-> ([Char]
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b c. (a -> b -> c) -> b -> a -> c
flip (F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
-> ([Char]
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> Maybe [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (FileMenuItem
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromMenu FileMenuItem
SaveAs)) Maybe [Char]
filename (([Char]
  -> F (Either
          (Either ((FileMenuItem, b), [Char]) (Either p p))
          (Either FileMenuItem (InputMsg b)))
       (Either
          [Char]
          (Either
             (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
             (Either a b))))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> ([Char]
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$ \ [Char]
name ->
		(b -> [Char])
-> [Char]
-> b
-> ([Char]
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall t a b.
(t -> [Char]) -> [Char] -> t -> ([Char] -> F a b) -> F a b -> F a b
saveF b -> [Char]
show [Char]
name b
doc [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
errMsg (F (Either
      (Either ((FileMenuItem, b), [Char]) (Either p p))
      (Either FileMenuItem (InputMsg b)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
         (Either a b)))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$
	        F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same
	FileMenuItem
SaveAs -> ((b
  -> F (Either
          (Either ((FileMenuItem, b), [Char]) (Either p p))
          (Either FileMenuItem (InputMsg b)))
       (Either
          [Char]
          (Either
             (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
             (Either a b))))
 -> Maybe b
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> Maybe b
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b c. (a -> b -> c) -> b -> a -> c
flip (F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same) Maybe b
document ((b
  -> F (Either
          (Either ((FileMenuItem, b), [Char]) (Either p p))
          (Either FileMenuItem (InputMsg b)))
       (Either
          [Char]
          (Either
             (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
             (Either a b))))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$ \ b
_ ->
	          Either
  [Char]
  (Either
     (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
     (Either a b))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall ho hi. ho -> F hi ho -> F hi ho
putF ((FileMenuItem, ([Char], Maybe [Char]))
-> Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b))
forall a a b b. a -> Either a (Either (Either a b) b)
toFilePick (FileMenuItem
SaveAs,([Char]
"Save",[Char] -> Maybe [Char]
forall a. a -> Maybe a
Just ([Char] -> Maybe [Char] -> [Char]
forall a. a -> Maybe a -> a
fromMaybe [Char]
"" Maybe [Char]
filename)))) F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same
	FileMenuItem
Quit -> F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
terminateProgram
	FileMenuItem
New  -> ((b
  -> F (Either
          (Either ((FileMenuItem, b), [Char]) (Either p p))
          (Either FileMenuItem (InputMsg b)))
       (Either
          [Char]
          (Either
             (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
             (Either a b))))
 -> Maybe b
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> Maybe b
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b c. (a -> b -> c) -> b -> a -> c
flip (F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (F (Either
      (Either ((FileMenuItem, b), [Char]) (Either p p))
      (Either FileMenuItem (InputMsg b)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
         (Either a b)))
 -> (b
     -> F (Either
             (Either ((FileMenuItem, b), [Char]) (Either p p))
             (Either FileMenuItem (InputMsg b)))
          (Either
             [Char]
             (Either
                (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
                (Either a b))))
 -> Maybe b
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$ [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
errMsg [Char]
"New not implemented") Maybe b
optEmpty ((b
  -> F (Either
          (Either ((FileMenuItem, b), [Char]) (Either p p))
          (Either FileMenuItem (InputMsg b)))
       (Either
          [Char]
          (Either
             (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
             (Either a b))))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$ \b
empty ->
	        [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall hi b.
[Char] -> F hi (Either [Char] b) -> F hi (Either [Char] b)
changeTitle [Char]
"Empty file" (F (Either
      (Either ((FileMenuItem, b), [Char]) (Either p p))
      (Either FileMenuItem (InputMsg b)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
         (Either a b)))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$
	        Either
  [Char]
  (Either
     (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
     (Either a b))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall ho hi. ho -> F hi ho -> F hi ho
putF (b
-> Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b))
forall b a a a. b -> Either a (Either a (Either a b))
toApp b
empty) (F (Either
      (Either ((FileMenuItem, b), [Char]) (Either p p))
      (Either FileMenuItem (InputMsg b)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
         (Either a b)))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$
		F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
start
	FileMenuItem
_ -> F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same

    terminateProgram :: F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
terminateProgram = Request
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. Request -> F a b -> F a b
hIOSuccF (Int -> Request
Exit Int
0) F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
same

    fromFilePick :: ((FileMenuItem, b), [Char])
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromFilePick ((FileMenuItem
action,b
_),[Char]
filename) =
      case FileMenuItem
action of
        FileMenuItem
Open -> ([Char] -> Either [Char] b)
-> [Char]
-> ([Char]
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> (b
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall b a b.
([Char] -> Either [Char] b)
-> [Char] -> ([Char] -> F a b) -> (b -> F a b) -> F a b
openF [Char] -> Either [Char] b
parse [Char]
filename [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
errMsg
		      (\ b
contents ->
	               Either
  [Char]
  (Either
     (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
     (Either a b))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall ho hi. ho -> F hi ho -> F hi ho
putF (b
-> Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b))
forall b a a a. b -> Either a (Either a (Either a b))
toApp b
contents) (F (Either
      (Either ((FileMenuItem, b), [Char]) (Either p p))
      (Either FileMenuItem (InputMsg b)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
         (Either a b)))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$
	               [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
newName [Char]
filename (b -> Maybe b
forall a. a -> Maybe a
Just b
contents))
        FileMenuItem
SaveAs -> (b -> [Char])
-> [Char]
-> b
-> ([Char]
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall t a b.
(t -> [Char]) -> [Char] -> t -> ([Char] -> F a b) -> F a b -> F a b
saveF b -> [Char]
show [Char]
filename (Maybe b -> b
forall a. HasCallStack => Maybe a -> a
fromJust Maybe b
document) [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
errMsg (F (Either
      (Either ((FileMenuItem, b), [Char]) (Either p p))
      (Either FileMenuItem (InputMsg b)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
         (Either a b)))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$
                  [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
newName [Char]
filename Maybe b
document
	FileMenuItem
_ -> F (Either
     (Either ((FileMenuItem, b), [Char]) (Either p p))
     (Either FileMenuItem (InputMsg b)))
  (Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b)))
forall a. HasCallStack => a
undefined -- shouldn't happen

    fromApp :: InputMsg b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
fromApp InputMsg b
inpmsg =
      case InputMsg b -> Maybe b
forall a. InputMsg a -> Maybe a
inputDone InputMsg b
inpmsg of
	Just b
doc ->
	  case Maybe [Char]
filename of
	    Just [Char]
name -> (b -> [Char])
-> [Char]
-> b
-> ([Char]
    -> F (Either
            (Either ((FileMenuItem, b), [Char]) (Either p p))
            (Either FileMenuItem (InputMsg b)))
         (Either
            [Char]
            (Either
               (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
               (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall t a b.
(t -> [Char]) -> [Char] -> t -> ([Char] -> F a b) -> F a b -> F a b
saveF b -> [Char]
show [Char]
name b
doc [Char]
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
errMsg (F (Either
      (Either ((FileMenuItem, b), [Char]) (Either p p))
      (Either FileMenuItem (InputMsg b)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
         (Either a b)))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$
	                 Maybe [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
loop Maybe [Char]
filename (b -> Maybe b
forall a. a -> Maybe a
Just b
doc)
            Maybe [Char]
Nothing   -> Either
  [Char]
  (Either
     (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
     (Either a b))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall ho hi. ho -> F hi ho -> F hi ho
putF ((FileMenuItem, ([Char], Maybe [Char]))
-> Either
     [Char]
     (Either
        (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
        (Either a b))
forall a a b b. a -> Either a (Either (Either a b) b)
toFilePick (FileMenuItem
SaveAs,([Char]
"Save",Maybe [Char]
filename))) (F (Either
      (Either ((FileMenuItem, b), [Char]) (Either p p))
      (Either FileMenuItem (InputMsg b)))
   (Either
      [Char]
      (Either
         (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
         (Either a b)))
 -> F (Either
         (Either ((FileMenuItem, b), [Char]) (Either p p))
         (Either FileMenuItem (InputMsg b)))
      (Either
         [Char]
         (Either
            (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
            (Either a b))))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
forall a b. (a -> b) -> a -> b
$
	                 Maybe [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
loop Maybe [Char]
filename (b -> Maybe b
forall a. a -> Maybe a
Just b
doc)
	Maybe b
Nothing -> Maybe [Char]
-> Maybe b
-> F (Either
        (Either ((FileMenuItem, b), [Char]) (Either p p))
        (Either FileMenuItem (InputMsg b)))
     (Either
        [Char]
        (Either
           (Either (FileMenuItem, ([Char], Maybe [Char])) (Either [Char] b))
           (Either a b)))
loop Maybe [Char]
filename (b -> Maybe b
forall a. a -> Maybe a
Just (InputMsg b -> b
forall p. InputMsg p -> p
stripInputMsg InputMsg b
inpmsg))


data FileMenuItem = New | Open | Save | SaveAs | Quit deriving (FileMenuItem -> FileMenuItem -> Bool
(FileMenuItem -> FileMenuItem -> Bool)
-> (FileMenuItem -> FileMenuItem -> Bool) -> Eq FileMenuItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileMenuItem -> FileMenuItem -> Bool
$c/= :: FileMenuItem -> FileMenuItem -> Bool
== :: FileMenuItem -> FileMenuItem -> Bool
$c== :: FileMenuItem -> FileMenuItem -> Bool
Eq)


fileShellMenuBarF :: Bool -> F FileMenuItem FileMenuItem
fileShellMenuBarF Bool
hasNew =
    Either FileMenuItem Any -> FileMenuItem
forall a b. Either a b -> a
fromLeft (Either FileMenuItem Any -> FileMenuItem)
-> F (Either FileMenuItem Any) (Either FileMenuItem Any)
-> F (Either FileMenuItem Any) FileMenuItem
forall a b e. (a -> b) -> F e a -> F e b
>^=< F (Either FileMenuItem Any) (Either FileMenuItem Any)
-> F (Either FileMenuItem Any) (Either FileMenuItem Any)
forall a b. F a b -> F a b
hBoxF (Bool -> F FileMenuItem FileMenuItem
fileMenuF Bool
hasNew F FileMenuItem FileMenuItem
-> F Any Any
-> F (Either FileMenuItem Any) (Either FileMenuItem Any)
forall a b c d. F a b -> F c d -> F (Either a c) (Either b d)
>+< F Any Any
forall hi ho. F hi ho
gcWarnF) F (Either FileMenuItem Any) FileMenuItem
-> (FileMenuItem -> Either FileMenuItem Any)
-> F FileMenuItem FileMenuItem
forall c d e. F c d -> (e -> c) -> F e d
>=^< FileMenuItem -> Either FileMenuItem Any
forall a b. a -> Either a b
Left
  where gcWarnF :: F a b
gcWarnF = Spacer -> F a b -> F a b
forall a b. Spacer -> F a b -> F a b
spacer1F (Alignment -> Alignment -> Spacer
hvAlignS Alignment
aRight Alignment
aCenter) F a b
forall hi ho. F hi ho
gcWarningF

fileMenuF :: Bool -> F FileMenuItem FileMenuItem
fileMenuF Bool
hasNew =
    Spacer
-> F FileMenuItem FileMenuItem -> F FileMenuItem FileMenuItem
forall a b. Spacer -> F a b -> F a b
spacer1F (Bool -> Bool -> Spacer
noStretchS Bool
True Bool
True Spacer -> Spacer -> Spacer
`compS` Spacer
leftS) (Menu FileMenuItem -> F FileMenuItem FileMenuItem
forall a. Eq a => Menu a -> F a a
menuBarF Menu FileMenuItem
menuBar)
  where
    menuBar :: Menu FileMenuItem
menuBar = [MenuItem FileMenuItem -> [Char] -> Item (MenuItem FileMenuItem)
forall a1 a2. Graphic a1 => a2 -> a1 -> Item a2
item MenuItem FileMenuItem
fileMenu [Char]
"File"] -- more?
    fileMenu :: MenuItem FileMenuItem
fileMenu = Transl FileMenuItem FileMenuItem
-> Menu FileMenuItem -> MenuItem FileMenuItem
forall b a. Eq b => Transl b a -> Menu b -> MenuItem a
menu Transl FileMenuItem FileMenuItem
forall b. Transl b b
idT (Menu FileMenuItem -> MenuItem FileMenuItem)
-> Menu FileMenuItem -> MenuItem FileMenuItem
forall a b. (a -> b) -> a -> b
$
               (if Bool
hasNew then (FileMenuItem -> [Char] -> Item (MenuItem FileMenuItem)
forall a1 a2. Graphic a1 => a2 -> a1 -> Item (MenuItem a2)
cmdItem FileMenuItem
New    [Char]
"New"Item (MenuItem FileMenuItem)
-> Menu FileMenuItem -> Menu FileMenuItem
forall a. a -> [a] -> [a]
:) else Menu FileMenuItem -> Menu FileMenuItem
forall a. Customiser a
id)
	       [FileMenuItem -> [Char] -> Item (MenuItem FileMenuItem)
forall a1 a2. Graphic a1 => a2 -> a1 -> Item (MenuItem a2)
cmdItem FileMenuItem
Open   [Char]
"Open..."     Item (MenuItem FileMenuItem)
-> [Char] -> Item (MenuItem FileMenuItem)
forall a. Item a -> [Char] -> Item a
`key` [Char]
"o",
		FileMenuItem -> [Char] -> Item (MenuItem FileMenuItem)
forall a1 a2. Graphic a1 => a2 -> a1 -> Item (MenuItem a2)
cmdItem FileMenuItem
Save   [Char]
"Save"        Item (MenuItem FileMenuItem)
-> [Char] -> Item (MenuItem FileMenuItem)
forall a. Item a -> [Char] -> Item a
`key` [Char]
"s",
		FileMenuItem -> [Char] -> Item (MenuItem FileMenuItem)
forall a1 a2. Graphic a1 => a2 -> a1 -> Item (MenuItem a2)
cmdItem FileMenuItem
SaveAs [Char]
"Save As..."  Item (MenuItem FileMenuItem)
-> [Char] -> Item (MenuItem FileMenuItem)
forall a. Item a -> [Char] -> Item a
`key` [Char]
"a",
		FileMenuItem -> [Char] -> Item (MenuItem FileMenuItem)
forall a1 a2. Graphic a1 => a2 -> a1 -> Item (MenuItem a2)
cmdItem FileMenuItem
Quit   [Char]
"Quit"        Item (MenuItem FileMenuItem)
-> [Char] -> Item (MenuItem FileMenuItem)
forall a. Item a -> [Char] -> Item a
`key` [Char]
"q" ]

saveF :: (t -> [Char]) -> [Char] -> t -> ([Char] -> F a b) -> F a b -> F a b
saveF t -> [Char]
showdoc [Char]
filename t
doc [Char] -> F a b
errcont F a b
cont =
  Request -> (IOError -> F a b) -> (Response -> F a b) -> F a b
forall a b.
Request -> (IOError -> F a b) -> (Response -> F a b) -> F a b
hIOerrF ([Char] -> [Char] -> Request
WriteFile [Char]
filename (t -> [Char]
showdoc t
doc))
	  ([Char] -> F a b
errcont([Char] -> F a b) -> (IOError -> [Char]) -> IOError -> F a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
.IOError -> [Char]
forall a. Show a => a -> [Char]
show)
	  (F a b -> Response -> F a b
forall a b. a -> b -> a
const F a b
cont)

openF :: ([Char] -> Either [Char] b)
-> [Char] -> ([Char] -> F a b) -> (b -> F a b) -> F a b
openF [Char] -> Either [Char] b
parse [Char]
filename [Char] -> F a b
errcont b -> F a b
cont =
  Request -> (IOError -> F a b) -> (Response -> F a b) -> F a b
forall a b.
Request -> (IOError -> F a b) -> (Response -> F a b) -> F a b
hIOerrF ([Char] -> Request
ReadFile [Char]
filename) ([Char] -> F a b
errcont([Char] -> F a b) -> (IOError -> [Char]) -> IOError -> F a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
.IOError -> [Char]
forall a. Show a => a -> [Char]
show) ((Response -> F a b) -> F a b) -> (Response -> F a b) -> F a b
forall a b. (a -> b) -> a -> b
$ \ (Str [Char]
contents) ->
  ([Char] -> F a b) -> (b -> F a b) -> Either [Char] b -> F a b
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either [Char] -> F a b
errcont b -> F a b
cont ([Char] -> Either [Char] b
parse [Char]
contents)

--messageF msg = contDynF $ (startupF [msg] messagePopupF>=^^<nullSP)
-- contDynF doesn't seem to work properly

#endif