module MoreFileF(
  moreFileShellF,
  moreShellF,moreShellF',
  moreFileF
) where
import MoreF(moreF')
import Command
import CompOps((>==<), (>=^<), (>^=<), (>=^^<))
import Shells(unmappedShellF, unmappedSimpleShellF)
import Fudget
import FRequest
import ReadFileF(readFileF)
--import Message(Message(..))
import SpEither(toBothSP)
import Spops(concmapSP)
--import Xtypes
import EitherUtils(stripEither)
import FDefaults
import InputMsg(InputMsg)
import DialogueIO() -- instances, for hbc


moreShellF' :: Customiser TextF -> String -> F [String] (InputMsg (Int, String))
moreShellF' Customiser TextF
pmod String
name = forall {i} {o}. String -> F i o -> F i o
unmappedSimpleShellF String
name forall a b. (a -> b) -> a -> b
$ Customiser TextF -> F [String] (InputMsg (Int, String))
moreF' Customiser TextF
pmod
moreShellF :: String -> F [String] (InputMsg (Int, String))
moreShellF = Customiser TextF -> String -> F [String] (InputMsg (Int, String))
moreShellF' forall a. Customiser a
standard

moreFileF :: F String (InputMsg (Int, String))
moreFileF :: F String (InputMsg (Int, String))
moreFileF = Customiser TextF -> F String (InputMsg (Int, String))
moreFileF' forall a. Customiser a
standard
moreFileF' :: Customiser TextF -> F String (InputMsg (Int, String))
moreFileF' Customiser TextF
pmod = Customiser TextF -> F [String] (InputMsg (Int, String))
moreF' Customiser TextF
pmod forall c d e. F c d -> (e -> c) -> F e d
>=^< forall {a}. Show a => (String, Either a String) -> [String]
contents forall {a1} {b} {a2}. F a1 b -> F a2 a1 -> F a2 b
>==< F String (String, Either IOError String)
readFileF

moreFileShellF :: F String (InputMsg (Int, String))
moreFileShellF =
  let startcmds :: [FRequest]
startcmds = [XCommand -> FRequest
XCmd forall a b. (a -> b) -> a -> b
$ String -> XCommand
StoreName String
"More Fudget"]
      titleK :: K String ho
titleK = forall hi ho. KSP hi ho -> K hi ho
K{-kk-} forall a b. (a -> b) -> a -> b
$ forall {t} {b}. (t -> [b]) -> SP t b
concmapSP forall {a} {b}. Message a String -> [Message FRequest b]
changeName  -- titleK never outputs anything
  in forall {a}. Either a a -> a
stripEither forall a b e. (a -> b) -> F e a -> F e b
>^=< forall {t :: * -> *} {a} {b} {c} {d}.
Foldable t =>
t FRequest -> K a b -> F c d -> F (Either a c) (Either b d)
unmappedShellF [FRequest]
startcmds forall {ho}. K String ho
titleK F String (InputMsg (Int, String))
moreFileF forall c d e. F c d -> SP e c -> F e d
>=^^< forall {b}. SP b (Either b b)
toBothSP

contents :: (String, Either a String) -> [String]
contents (String
name,Either a String
file) =
  case Either a String
file of
    Right String
s -> String -> [String]
lines String
s
    Left a
err -> [String
nameforall a. [a] -> [a] -> [a]
++String
": "forall a. [a] -> [a] -> [a]
++forall a. Show a => a -> String
show a
err] -- missing Show instance for IOError
    --Left err -> [name++": error"]

changeName :: Message a String -> [Message FRequest b]
changeName Message a String
msg =
  case Message a String
msg of
    High String
name -> [forall a b. a -> Message a b
Low forall a b. (a -> b) -> a -> b
$ XCommand -> FRequest
XCmd forall a b. (a -> b) -> a -> b
$ String -> XCommand
StoreName String
name, forall a b. a -> Message a b
Low forall a b. (a -> b) -> a -> b
$ XCommand -> FRequest
XCmd XCommand
MapRaised]
    Message a String
_ -> []