Re: [Haskell-beginners] 'cabal install hdirect' can't find hdirect

On 07/04/10 07:28, Daniel Fischer wrote:
On Sunday 04 July 2010 13:45:01 you wrote:
src/Lex.lhs:330:8: Illegal signature in pattern: Int Use -XPatternSignatures to permit it cabal: Error: some packages failed to install: hdirect-0.21.0 failed during the building phase. The exception was: exit: ExitFailure 1 ~/download/haskell/libs $ which happy /home/evansl/.cabal/bin/happy ~/download/haskell/libs $
Any ideas about how to solve this problem?
Sure. First, tell the maintainer, he might want to fix it for all.
Done.
Then, the quick fix for you, * unpack the .tar.gz * change the version in the .cabal file (my preferred method is appending a ".1" to the version number). You need that in case you want to build some library which depends on hdirect, so that cabal-install picks your bumped newer version rather than the newest version on hackage. * make it compile, e.g. by adding a field Extensions: PatternSignatures to the cabal file, or by putting a {-# LANGUAGE PatternSignatures #-} pragma to the offending file. Then run cabal install in the unpacked and modified directory. Several iterations of edit file; cabal install may be necessary.
Downloaded: http://hackage.haskell.org/packages/archive/hdirect/0.21.0/hdirect-0.21.0.ta... then unzipped and untarred it then edited hdirect.cabal by adding: Extensions: PatternSignatures Below the line: library However, still got: src/Desugar.lhs:2053:1: Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: (_, []) (_, IDL.IncludeEnd : _) (_, (IDL.IncludeStart _) : _) (_, (IDL.Pragma _) : _) ... [60 of 65] Compiling IDLToken ( src/IDLToken.lhs, dist/build/hdirect/hdirect-tmp/IDLToken.o ) [61 of 65] Compiling LexM ( src/LexM.lhs, dist/build/hdirect/hdirect-tmp/LexM.o ) [62 of 65] Compiling Lex ( src/Lex.lhs, dist/build/hdirect/hdirect-tmp/Lex.o ) src/Lex.lhs:330:8: Illegal signature in pattern: Int Use -XPatternSignatures to permit it cabal: Error: some packages failed to install: Any further help is appreciated. -regards, Larry

On 07/04/10 10:06, Larry Evans wrote:
On 07/04/10 07:28, Daniel Fischer wrote:
On Sunday 04 July 2010 13:45:01 you wrote:
src/Lex.lhs:330:8: Illegal signature in pattern: Int Use -XPatternSignatures to permit it cabal: Error: some packages failed to install: hdirect-0.21.0 failed during the building phase. The exception was: exit: ExitFailure 1 ~/download/haskell/libs $ which happy /home/evansl/.cabal/bin/happy ~/download/haskell/libs $
Any ideas about how to solve this problem?
Sure. First, tell the maintainer, he might want to fix it for all.
Done.
Then, the quick fix for you, * unpack the .tar.gz * change the version in the .cabal file (my preferred method is appending a ".1" to the version number). You need that in case you want to build some library which depends on hdirect, so that cabal-install picks your bumped newer version rather than the newest version on hackage. * make it compile, e.g. by adding a field Extensions: PatternSignatures to the cabal file, or by putting a {-# LANGUAGE PatternSignatures #-} pragma to the offending file. Then run cabal install in the unpacked and modified directory. Several iterations of edit file; cabal install may be necessary.
Downloaded:
http://hackage.haskell.org/packages/archive/hdirect/0.21.0/hdirect-0.21.0.ta...
then unzipped and untarred it then edited hdirect.cabal by adding:
Extensions: PatternSignatures
Below the line:
library
However, still got:
src/Desugar.lhs:2053:1: Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: (_, []) (_, IDL.IncludeEnd : _) (_, (IDL.IncludeStart _) : _) (_, (IDL.Pragma _) : _) ... [60 of 65] Compiling IDLToken ( src/IDLToken.lhs, dist/build/hdirect/hdirect-tmp/IDLToken.o ) [61 of 65] Compiling LexM ( src/LexM.lhs, dist/build/hdirect/hdirect-tmp/LexM.o ) [62 of 65] Compiling Lex ( src/Lex.lhs, dist/build/hdirect/hdirect-tmp/Lex.o )
src/Lex.lhs:330:8: Illegal signature in pattern: Int Use -XPatternSignatures to permit it cabal: Error: some packages failed to install:
Any further help is appreciated. [snip] However, the 2nd alternative solution:
{-# LANGUAGE PatternSignatures #-} did work. Thanks. However, during the compilations, there were many warnings about pattern matching. Also, I plan to use this with hugs. I'm not sure which haskell compiler was used. Does that matter? I'm actually trying to use: http://www.cas.mcmaster.ca/~kahl/FP/2003/Interpreter.lhs with hugs. TIA. -Larry

You don't need HDirect for this.
I've attached an early revision of Wolfram Kahl's code that I download
years ago - this is a plain Haskell version rather than a literate
file you should find it easier to use.
The file itself seems to have disappeared from the web, though maybe
it is findable through the Wayback machine.
On 4 July 2010 16:33, Larry Evans
{-# LANGUAGE PatternSignatures #-}
did work. Thanks. However, during the compilations, there were many warnings about pattern matching. Also, I plan to use this with hugs. I'm not sure which haskell compiler was used. Does that matter? I'm actually trying to use:
http://www.cas.mcmaster.ca/~kahl/FP/2003/Interpreter.lhs
with hugs.

On 07/04/10 10:50, Stephen Tetley wrote:
You don't need HDirect for this.
I've attached an early revision of Wolfram Kahl's code that I download years ago - this is a plain Haskell version rather than a literate file you should find it easier to use.
The file itself seems to have disappeared from the web, though maybe it is findable through the Wayback machine.
Thanks Stephen; however, when I tried with your interpret.hs, I got the same error I got with: http://www.cas.mcmaster.ca/~kahl/FP/2003/Interpreter.lhs that is: ={============ cut here ============== ~/prog_dev/haskell/modular-interpreter $ hugs -98 +o Interpreter.hs __ __ __ __ ____ ___ _________________________________________ || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2005 ||---|| ___|| World Wide Web: http://haskell.org/hugs || || Bugs: http://hackage.haskell.org/trac/hugs || || Version: September 2006 _________________________________________ Hugs mode: Restart with command line option +98 for Haskell 98 mode ERROR "Interpreter.hs" - Can't find imported module "FiniteMaps" Hugs> =}============ cut here ============== The only reason I though hdirect was needed was because it has a FiniteMaps module. Hmm...I looked more closely and it has a FiniteMap module. Where do can I get this FiniteMaps module? TIA. -Larry

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. In the first instance I would remove the 's' from the import line (line 32) and see what happens.

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

Hi Larry I'll take a look at getting the code to work later today. Which system - GHCi or Hugs - would you prefer to use? If you prefer GHCi, I'll replace the whole FiniteMap module with Data.Map as FiniteMap has been made obsolete by Data.Map. Best wishes Stephen

On 07/05/10 02:08, Stephen Tetley wrote:
Hi Larry
I'll take a look at getting the code to work later today.
Thanks very much.
Which system - GHCi or Hugs - would you prefer to use?
GHCi, because I tried: cabal install --hugs after download & unzip & untar: http://hackage.haskell.org/packages/archive/hdirect/0.21.0/hdirect-0.21.0.ta... but, apparently, the hugs compiler I've got cannot correctly parse some of the .lhs files downloaded :(
If you prefer GHCi, I'll replace the whole FiniteMap module with Data.Map as FiniteMap has been made obsolete by Data.Map.
That sounds best.
Best wishes
Stephen
Thank you Stephen. -regards, Larry

Hi Larry Here is the working code. The original paper uses quite a bit of heavy machinery - both continuation monads (5.6) and the Extensible Union Types (section 4), so its probably not an ideal starting point for building intuition on monad transformers or Lambda evaluators. Lennart Augustsson has some notes "Lambda calculus cooked four ways" that are good for the later. Off the top of my head, I can't think of a good source for the former. -- Code attached for "MonadTransformers and Modular Interpreters" -- Sheng Liang, Paul Hudak, Mark Jones -- -- Code written by Wolfram Kahl, 2001-03-27. -- -- Updated to work with GHC/GHCi, 2010-07-05, by me. --

On 07/05/10 08:12, Stephen Tetley wrote:
Hi Larry
Here is the working code.
[snip] Thanks very much Stephen. I just added: {-# LANGUAGE PatternSignatures #-} to get it to compile with ghci: ~/prog_dev/haskell/modular-interpreter $ ghci Interpreter.hs GHCi, version 6.8.3: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 1] Compiling Interpreter ( Interpreter.hs, interpreted ) Ok, modules loaded: Interpreter. *Interpreter>
participants (2)
-
Larry Evans
-
Stephen Tetley