
On 07/04/10 11:19, Stephen Tetley wrote:
Hi Larry
Hugs comes with a library - FiniteMap. Maybe FiniteMaps is a spelling mistake or maybe it it a module the Wolfram Kahl didn't distribute.
Thanks Stephen, I changed the name; however, then 2 other names needed changing: lookupDftFM -> lookupWithDefaultFM zeroFM -> emptyFM However, even after those changes, I got several errors: ~/prog_dev/haskell/modular-interpreter $ ghc -fallow-overlapping-instances -fallow-undecidable-instances -fglasgow-exts -o Int Interpreter.hs Interpreter.hs:155:39: Couldn't match expected type `FiniteMap Name (InterpM Value)' against inferred type `Name' In the first argument of `addToFM', namely `n' In the first argument of `Env', namely `(addToFM n v e)' In the expression: Env (addToFM n v e) Interpreter.hs:203:14: Overlapping instances for StateMonad s (StateT Store (EnvT Env (ContT Answer (StateT [String] (ErrorT []))))) arising from a use of `liftSTFun' at Interpreter.hs:203:14-38 Matching instances: instance [overlap ok] (StateMonad s m, MonadT t m) => StateMonad s (t m) -- Defined at Interpreter.hs:(391,0)-(392,23) instance [overlap ok] (Monad m) => StateMonad s (StateT s m) -- Defined at Interpreter.hs:(301,0)-(302,43) (The choice depends on the instantiation of `s' To pick the first instance above, use -fallow-incoherent-instances when compiling the other instance declarations) In the expression: liftSTFun (updateStore p) In the definition of `updateLoc': updateLoc p = liftSTFun (updateStore p) Interpreter.hs:211:56: Couldn't match expected type `InterpM Value' against inferred type `FiniteMap Integer (InterpM Value)' In the third argument of `addToFM', namely `fm' In the second argument of `Store', namely `(addToFM i v fm)' In the expression: Store n (addToFM i v fm) Interpreter.hs:427:9: The scoped type variables `env' and `r' are bound to the same type (variable) Distinct scoped type variables must be distinct In the pattern: r :: env In the definition of `inEnv': inEnv (r :: env) (ContT c) = ContT (\ k -> do o <- rdEnv inEnv r (c (inEnv (o :: env) . k))) In the definition for method `inEnv' ~/prog_dev/haskell/modular-interpreter $ Any suggestions for workarounds would be appreciated. -regards, Larry