{-# LANGUAGE CPP #-}
module ShowCommandF(showCommandF) where
import CompOps((>.=<), (>=.<))
import Fudget
--import Geometry(Line, Point, Rect, Size(..))
--import LayoutRequest(LayoutRequest)
--import Message(Message)
import Path(showPath)
import Debug.Trace(trace)
import Xtypes
import Command
import Event
--import ResourceIds
import Sockets
import CmdLineEnv(argFlag)
--import DialogueIO hiding (IOError)

showCommandF :: String -> (F a b) -> F a b
showCommandF :: String -> F a b -> F a b
showCommandF String
s F a b
f = F a b -> [String] -> F a b
forall a b. a -> b -> a
const (if Bool -> Bool
not (String -> Bool -> Bool
argFlag String
s Bool
False) then F a b
f else
    let showit :: (b -> String) -> String -> (Path, b) -> (Path, b)
showit b -> String
show' String
d (Path
t, b
c) =
            String -> (Path, b) -> (Path, b)
forall a. String -> a -> a
trace (String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
d String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
": " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Path -> String
showPath Path
t String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
": " String -> String -> String
forall a. [a] -> [a] -> [a]
++ b -> String
show' b
c
#ifdef __NHC__
		   ++ "\n"
#endif
		   )
                  (Path
t, b
c)
    in  ((FRequest -> String)
-> String -> (Path, FRequest) -> (Path, FRequest)
forall b. (b -> String) -> String -> (Path, b) -> (Path, b)
showit FRequest -> String
forall a. Show a => a -> String
show String
"out" ((Path, FRequest) -> (Path, FRequest)) -> F a b -> F a b
forall hi ho.
((Path, FRequest) -> (Path, FRequest)) -> F hi ho -> F hi ho
>.=< F a b
f) F a b -> (TEvent -> TEvent) -> F a b
forall hi ho. F hi ho -> (TEvent -> TEvent) -> F hi ho
>=.< (FResponse -> String) -> String -> TEvent -> TEvent
forall b. (b -> String) -> String -> (Path, b) -> (Path, b)
showit FResponse -> String
forall a. Show a => a -> String
show String
"in") [String]
x

{-
showEv e = case e of
       IOResponse (XResponse x) -> "IOResponse (XResponse ..."++show x++")"
       _ -> show e
-}

-- Hack: The following is to avoid show methods from hlib

x :: [String]
x = [Display -> String
forall a. Show a => a -> String
show (Display
forall a. a
m :: Display),
     Command -> String
forall a. Show a => a -> String
show (Command
forall a. a
m :: Command),
     Event -> String
forall a. Show a => a -> String
show (Event
forall a. a
m :: Event),
     WindowId -> String
forall a. Show a => a -> String
show (WindowId
forall a. a
m :: WindowId),
     Descriptor -> String
forall a. Show a => a -> String
show (Descriptor
forall a. a
m :: Descriptor)]

m :: a
m = String -> a
forall a. HasCallStack => String -> a
error String
"module ShowCommandF"