问题描述:

I'm learning Haskell by converting my OCaml programs which are themselves conversions of old Pick Basic programs. I use ncurses (am trying vty-ui in Haskell) combined with a self-written library that maintains an open session to Tk's wish as a start at eventually converting to a full GUI, but mainly just used for reports, error popups, and other user feedback.

I don't want the calling program to have to pass the I/O handles and process Id with every call. I've tried Data.Global but can't figure out how to store the process Id. On the initial call,

(hin, hout, herr, hproc) <- runInteractiveCommand "wish"

...

let gvProc = declareMVar "wish-proc" hproc

gives a compiler error "No instance for (Data.Typeable.Internal.Typeable ProcessHandle) arising from a use of "declareMVar"

If I try to put the declaration at a top level:

gvProc = declareMVar "wish-proc" ???What do I put here???

But perhaps there's a better way to accomplish what I need?

网友答案:

Your problem with Data.Global looks like a missing Typeable instance. You can fix that as follows:

{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable #-}

import Data.Typeable
import System.Process
deriving instance Typeable (ProcessHandle)
相关阅读:
Top