danielg / ghc-mod Goto Github PK
View Code? Open in Web Editor NEWHappy Haskell Hacking for editors. DEPRECATED
License: Other
Happy Haskell Hacking for editors. DEPRECATED
License: Other
I'm getting this error:
$ ghc-mod type Sample.hs Main 4 12
Dummy:0:0:Error:ghc-mod: panic! (the 'impossible' happened)
(GHC version 7.4.2 for i386-apple-darwin):
Evaluated the place holder for a PostTcKind
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
with the test code I've boiled down to as minimal as possible (saved in Sample.hs):
foo :: Int -> Int
foo x = foo' x where
foo' :: a -> a
foo' y = y
The error seems to be caused by the type variable in the signature for foo'
in the embedded where clause, as either of the following work:
foo :: Int -> Int
foo x = foo' x where
-- foo' :: a -> a
foo' y = y
$ ghc-mod type Sample.hs Main 4 12
4 12 4 13 "t"
4 3 4 13 "t -> t"
2 1 4 13 "Int -> Int"
or
foo :: Int -> Int
foo x = foo' x where
foo' :: Int -> Int
foo' y = y
$ ghc-mod type Sample.hs Main 4 12
4 12 4 13 "Int"
4 3 4 13 "Int -> Int"
2 1 4 13 "Int -> Int"
Note that ghci has no problem with any of the above.
I am on Mac 10.6.8 with 32-bit GHC 7.4.2 and ghc-mod version 1.11.2. Please let me know if there's any other information I can provide.
I know flymake needs something to work off, but saving the file breaks the intuition of the user that it's safe to experiment then not save when it doesn't work out. could you perhaps maintain a copy of the file somewhere and save & check that?
guilty code in ghc-flymake.el
(defun ghc-flymake-init ()
(let ((after-save-hook nil))
(save-buffer))
(let ((file (file-name-nondirectory (buffer-file-name))))
(list ghc-module-command (append (ghc-module-command-args)
(list "check" file)))))
M-t is a very useful emacs default keybinding, please don't overwrite it.
When I type M-?
on an error, I now see this most of the time:
Line 61: 2 error(s), 0 warning(s)
34:
36:
I have to use C-c C-l
to get the actual error message from ghci
. I pulled and rebuild ghc-mod
earlier today.
I really like ghc-mod.
It would be cool if you could keep some small changelog that informs of the latest and greatest changes in new versions ;)
Hi,
I've encountered an issue about modules. When I use ghc-mod check par.hs
to check a source file it gives me 'Cannot find module Control.Parallel' error, while the file can be compiled by ghc par.hs
without any problems.
Hiding is done in the exposedModules
function. Why?
If I type in the Yesod Hello world example into helloworld.hs:
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings #-}
import Yesod
data HelloWorld = HelloWorld
mkYesod "HelloWorld" [parseRoutes|
/ HomeR GET
|]
instance Yesod HelloWorld
getHomeR :: Handler RepHtml
getHomeR = defaultLayout [whamlet|Hello World!|]
main :: IO ()
main = warpDebug 3000 HelloWorld
and put point immediately after a |], and type C-c C-e, I get:
ghc-mod:0:0:Probably mutual module import occurred
ghc-mod:0:0:Probably mutual module import occurred
ghc-mod:0:0:Probably mutual module import occurred
in the GHC Info buffer.
emacs 24.2, ghc-mod 1.11.2, ghc 7.6.1
If I add
(add-hook 'before-save-hook 'delete-trailing-whitespace)
to my .emacs it becomes difficult to edit, as the buffer is continuously being saved and deleting the trailing whitespace.
Would it be possible to modify ghc-save-buffer to call a hook which could have the delete-trailing-whitespace in it.
Or is it simpler to just run a separate process on the project to clean the files periodically?
Hi.
I didn't know where to post this, so I'm putting it here. I've found two mistakes on the website of ghc-mod. On the last line of http://www.mew.org/~kazu/proj/ghc-mod/en/install.html it says M-C-t, where it should be M-C-i. I've spent an amount of time until I realize this was wrong. Also, in http://www.mew.org/~kazu/proj/ghc-mod/en/, in the description of C-c> there's a ! that should not be there.
By the way, thank you for this amazing emacs mode. It makes Emacs fell like an IDE, for me it is so good that it stimulates me to use Haskell even more, and to forget about considering switching to Eclipse of Leksah. Congratulations!
vim syntastic user here. It seems that Quasi Quotes causes a syntax error.
if i run ghc-mod check on incorrect literate Haskell, the preprocessor returns 1, so ghc-mod returns 1 - this kills the emacs process and turns flymake off, which is pretty annoying, especially given that the code will be wrong a lot of the time while hacking.
example code you get this on:
here's some doco some more doco > main = putStrLn "oh no, i didn't put a newline in!"
ghc-mod version 1.10.15
I have tried this with ghc 7.0.3 and ghc 7.4 on Arch Linux with ghc-mod 1.10.* . I cannot get the ghc-mod check command to produce any output. Is this a symptom of something common. ghc-mod lint works fine.
rhino ➜ ~/projects/dojo/ninjablocks-zeromq-workers/src/channels git:(refactoring_channels) ✗ ghc-mod check T.hs
rhino ➜ ~/projects/dojo/ninjablocks-zeromq-workers/src/channels git:(refactoring_channels) ✗ ghc-mod check T2.hs
T2.hs:2:3:No instance for (Num [Char]) arising from the literal 1'Possible fix: add an instance declaration for (Num [Char])In the first argument of
(==)', namely 1'In the expression: 1 == "1"In an equation for
l': l = 1 == "1"
rhino ➜ ~/projects/dojo/ninjablocks-zeromq-workers/src/channels git:(refactoring_channels) ✗ cat T.hs
{-# LANGUAGE TemplateHaskell #-}
module T where
l=1=="1"
rhino ➜ ~/projects/dojo/ninjablocks-zeromq-workers/src/channels git:(refactoring_channels) ✗ cat T2.hs
module T2 where
l=1=="1"
If I import Bytestring qualified as B, then M-t to get the type of a function that takes a bytestring, ghc-mod will insert Bytestring rather than B.Bytestring, causing a compile failure.
Just FYI
Info.hs:50:10:
Illegal instance declaration for HasType (LHsExpr Id)' (All instance types must be of the form (T t1 ... tn) where T is not a synonym. Use -XTypeSynonymInstances if you want to disable this.) In the instance declaration for
HasType (LHsExpr Id)'
Info.hs:60:10:
Illegal instance declaration for HasType (LHsBind Id)' (All instance types must be of the form (T t1 ... tn) where T is not a synonym. Use -XTypeSynonymInstances if you want to disable this.) In the instance declaration for
HasType (LHsBind Id)'
Info.hs:64:10:
Illegal instance declaration for HasType (LPat Id)' (All instance types must be of the form (T t1 ... tn) where T is not a synonym. Use -XTypeSynonymInstances if you want to disable this.) In the instance declaration for
HasType (LPat Id)'
cabal: Error: some packages failed to install:
ghc-mod-1.10.8 failed during the building phase. The exception was:
ExitFailure 1
The following code compiles in ghc 7.2.1.
foo :: Int -> Int
foo x = x + y where
y = z where
z = 2
main :: IO ()
main = do
print $ foo 2
return ()
ghc-mod check
reports no errors, but ghc-mod lint
produces the cryptic:
%ghc-mod lint minerror.hs
minerror.hs:6:1: Parse errorError message: Parse error: ;Code: z = 2 > main :: IO () main = do print $ foo 2
Removing the second where
from foo
eliminates the parse error. I would expect the above code to either produce no error from lint, or to complain about the second where
rather than showing a parse error in an unrelated location.
Hi,
ghc-mod check
fails with following error, although it can be built with cabal.
I afraid ghc-mod is not the actual cause but I couldn't find why it happens.
$ ghc-mod check Main.hs
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
_fps_count
whilst processing object file
/Users/fujimura/.cabal/lib/bytestring-0.10.0.1/ghc-7.4.2/HSbytestring-0.10.0.1.o
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
I'm using OS X 10.8.2, Xcode 4.5.2 and latest haskell-platform.
reproducible(at least for my machine) code is here:
https://gist.github.com/4140026
haskell-emacs has a cool feature: generatng etags using hasktags program.
This allows autocompletion on the project level (not only local buffer)
How hard would it be to add it to ghc-mode ?
Sometimes I got error message "Flymake: Failed to launch syntax check process 'ghc-mod' with args (-f nil lint some_filename.hs): Wrong type argument: stringp, nil. Flymake will be switched OFF" when I press "C-x C-s".
If I invoke ghc-mod -f nil lint some_filename.hs
or ghc-mod lint some_filename.hs
in a console it returns error code 0.
my ~/.emacs
:
(add-to-list 'load-path "~/.emacs.d/ghc-mod/")
(autoload 'ghc-init "ghc" nil t)
(add-hook 'haskell-mode-hook (lambda () (ghc-init) (flymake-mode)))
Since Info.hs tries to load the entire file to get the type, ghc-show-type fails when the file contains errors. I think this is a rather big limitation, since often you want convenient type information when trying to debug some piece of code that doesn't typecheck.
Unfortunately, partially loading the file, ignoring the parts with errors, has not been implemented yet and seems to be somewhat difficult, and such a subset would probably not be unique. A different approach would be to load just the imports, since most types of locally defined functions/constants should be visible, since they are in the same buffer (assuming the programmer wrote type signatures).
In addition to that, it might be possible to have ghc-mod output type information for locally defined function when compiling succeeds and caching those on the emacs side.
With C-c C-i I can get the information of where a function was defined, and then I can browse the documentation with M-C-d. It would be good if this process was in a keybinding.
If I use a module that's defined in two places like Control.Monad.Trans, and specify the package in the cabal file, everything builds fine but ghc-mod check complains. I assume this is because it's not referring to the cabal file, so it doesn't know which packages to add. Is this a feature that's on the roadmap for implementation?
Tried to run this on the Emacs pretest 24.2.90 from http://emacsformacosx.com/builds and it gives me an error that assoc is obsolete.
➜ ghc-mod git:(master) ✗ cat Test.hs
module Test where
import Data.Attoparsec.Char8
foo = bar
➜ ghc-mod git:(master) ✗ ghc-mod check Test.hs
# no output
➜ ghc-mod git:(master) ✗ cabal install --user --disable-shared --disable-library-profiling --disable-executable-profiling attoparsec
<snip details>
➜ ghc-mod git:(master) ✗ ghc-mod check Test.hs
# ah, and now we have it
Test.hs:3:6:Not in scope: `bar'
My expected behaviour would be to complain that it can't find those modules.
(do you have a preferred setup for submitting tests? HUnit, test-framework, shell commands... ?)
Hi,
I'm using ghc 6.12.1 with Cabal library 1.8.0.2. The following happens:
$ cabal install ghc-mod
Resolving dependencies...
Configuring ghc-mod-1.11.1...
Preprocessing executables for ghc-mod-1.11.1...
Building ghc-mod-1.11.1...
[ 1 of 16] Compiling GHCChoice ( GHCChoice.hs, dist/build/ghc-mod/ghc-mod-tmp/GHCChoice.o )
[ 2 of 16] Compiling Gap ( Gap.hs, dist/build/ghc-mod/ghc-mod-tmp/Gap.o )
[ 3 of 16] Compiling ErrMsg ( ErrMsg.hs, dist/build/ghc-mod/ghc-mod-tmp/ErrMsg.o )
[ 4 of 16] Compiling Types ( Types.hs, dist/build/ghc-mod/ghc-mod-tmp/Types.o )
[ 5 of 16] Compiling GHCApi ( GHCApi.hs, dist/build/ghc-mod/ghc-mod-tmp/GHCApi.o )
[ 6 of 16] Compiling Cabal ( Cabal.hs, dist/build/ghc-mod/ghc-mod-tmp/Cabal.o )
Cabal.hs:37:56: Not in scope: `usedExtensions'
Cabal.hs:38:53: Not in scope: `defaultLanguage'
cabal: Error: some packages failed to install:
ghc-mod-1.11.1 failed during the building phase. The exception was:
ExitFailure 1
I believe that ghc-mod needs a more recent version of Cabal, but in ghc-mod's dependencies Cabal is listed as -any
.
For emacs versions which support it, probably it's better to use
(add-hook 'post-command-hook 'ghc-type-post-command-hook nil t)
in ghc-type-init instead of making local variable.
Since latter breaks several hooks, e.g.: eldoc-schedule-timer & global-hl-line.
i'm trying to sort out getting things to build for ghc 7.6
will add details as I have time
Great work! I really enjoy using ghc-mod in vi. Two requests for the vi integration, if possible:
I am wondering whether it would be possible to integrate HaRe into ghc-mod. I guess that HaRe has some rough edges right now but an optional integration into ghc-mod might get more people to work on HaRe.
ghc-comp.el contains this line of code at the top level:
(add-hook 'find-file-hook 'ghc-import-module)
This means that I cannot choose not to have this hook defined. This should be moved to the ghc-init function, so I can choose to define my own ghc-init function that does not add this hook.
Auto-complete is also hosted on github: http://github.com/m2ym/auto-complete. It conveniently shows a popup when completion is available.
Currently I'm using http://madscientist.jp/~ikegami/diary/20090215.html, which while usable, is a unextensible hack.
Would you be interested in splitting ghc-mod into a backend, which actually loads the various source files, and a frontend which queries the backend? The reason for doing this would be that the backend wouldn't need to continually restart, so ghc-mod would only have to reparse files when something in the source tree changes, making ghc-mod much more responsive.
I'm not saying this needs to be done right now; this is more of a wishlist. But I might do it, and I was wondering if that might be something you'd like.
It would be useful if the ghc-mod
executable could output the path to its emacs site files. That way, it is possible to automate the configuration of ghc-mod
in emacs by using (add-to-list 'load-path (shell-command-to-string "ghc-mod site"))
.
The command should simply output its cabal data directory. Not having to find that directory using elisp would be very useful.
if you're developing bottom up, it's very distracting to see it flash red for variables you're not yet using. A warning is fine, but it shouldn't be an outright error.
Resolving dependencies...
Configuring ghc-mod-0.6.1...
Preprocessing executables for ghc-mod-0.6.1...
Building ghc-mod-0.6.1...
[1 of 9] Compiling Types ( Types.hs, dist/build/ghc-mod/ghc-mod-tmp/Types.o )
[2 of 9] Compiling Cabal ( Cabal.hs, dist/build/ghc-mod/ghc-mod-tmp/Cabal.o )
Cabal.hs:37:23: Not in scope: `H.liftIO'
Cabal.hs:66:5: Not in scope: `H.liftIO'
Cabal.hs:71:13: Not in scope: `H.liftIO'
Cabal.hs:79:13: Not in scope: `H.liftIO'
cabal: Error: some packages failed to install:
ghc-mod-0.6.1 failed during the building phase. The exception was:
ExitFailure 1
tangboyun@tangboyun-MXC062:/tmp/ghc-mod$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.2.1
haskell-emacs has a neat feature: sorting alphabetically the import section.
How hard would it be to add it to ghc-mode ?
When using the type features of ghc-mod, it never returns any TypeClass constraints or even the right namespaces. As a result, the types are not 'usable'. For example the type of the following function
import Data.Vector.Unboxed as U
test = U.Singleton (0 :: Int)
is given as Vector Int
, but this won't compile because Vector
is not in scope at this point, only U.Vector
.
A second issue arises with TypeClass constraints. For example, let's require a simple one like so:
fractionalOrElse a b = a / b
ghc-mod reports the type as a -> a -> a
, but if we add that type annotation it fails because a
is not an instance of Fractional
. What we really need is Fractional a => a -> a-> a
. Is there anything we can do about this?
What do you think about making the completion buffer-local? The following advice does the trick for me, but I think this would also be a sane default:
(defadvice ghc-init (before dhl-ghc-mod-local-completion first () activate) "Makes ghc-mod completions buffer local." (make-local-variable 'ghc-loaded-module) (make-local-variable 'ghc-merged-keyword))
usually i build with executable and library profiling. this causes ghc-mod to fail:
rhino ➜ ~/projects/dojo/ninjablocks-zeromq-workers git:(master) ✗ ghc-mod check src/reup/ReUp.hs
ghc-mod: You can't call hscCompileCoreExpr in a profiled compiler
reinstalling without library and executable profiling does the right thing,
When I use "ghc-mod check" on my code using Template Haskell, I got "This binding for `...' shadows the existing binding" warnings. If I run ghc normally, I get no warnings.
The following URL is a code to reproduce;
https://gist.github.com/3082903
I tried to fix this problem and read source codes, but I couldn't finish it :/
ghc-mod info Ffi.hs "" foo
fails with this file as Ffi.hs:
{-# LANGUAGE ForeignFunctionInterface #-}
module HelloFFI where
import Foreign.C.Types
foreign export ccall foo :: CUInt
foo :: CUInt
foo = 123
with this message
Dummy:0:0:Error:Could not find module `HelloFFI'
It is not a module in the current program, or in any known package.
however, ghc-mod
works without the foreign
declaration and provides the correct type for foo
.
Although I'll try to fix this, I think I'm not able to fix this on my own, so any help is appreciated. Thanks!
edit: okay, it fails at Gap.setCtx
.
edit2: sigh ghci
itself fails with ghci Ffi.hs
:
[1 of 1] Compiling HelloFFI ( Ffi.hs, interpreted )
Ffi.hs:5:1:
Illegal foreign declaration: requires via-C, llvm (-fllvm) or native code generation (-fvia-C)
When checking declaration: foreign export ccall "foo" foo :: CUInt
Failed, modules loaded: none.
good news: ghci -fobject-code Ffi.hs
works. bad news: I don't know how to tell ghc-mod
about that. maybe via DynFlags
?
ghc.el try to bind the following keys
but these keys are reserved by GNU Emacs or are not expected to be overrided by some users.
The conservative or standard way to make mode-specific key bindings is to add the prefix C-c to each key bindings.
Of course I opened this issue up on ghcmod-vim first :) eagletmt/ghcmod-vim#5 (comment)
I can customize hlint by adding a HLint.hs file, but I want to have global settings. I put a script in my path that calls hlint with a --ignore option. This works well if I just invoke hlint, but it doesn't have an effect through syntastic.
➜ leafy git:(master) ✗ cat Foo.hs
module Foo where
main = putStr "foo"
with 0.3:
➜ leafy git:(master) ✗ ghc-mod check Foo.hsFoo.hs:3:0:Warning: Definition but no type signature for `main' Inferred type: main :: IO ()
Warning: output was redirected with -o, but no output will be generated because there is no Main module.
with git head:
➜ leafy git:(master) ✗ ghc-mod check Foo.hs
I have the line
import GHC(parseStaticFlags, noLoc)
and flymake is choking on it, because it's in the hidden package ghc-6.12.1. Is there a place I can customise the packages flymake sees? It's in the cabal file for the package..
I managed to make syntastic much faster with this:
let g:syntastic_haskell_checker_args = '--ghcOpt="-fno-code"'
This makes GHC type check the code without actually compiling it.
I propose to make this the default in ghc-mod itself, or even hardcode it and not make it configurable, since ghc-mod isn't really tasked with compilation at all.
plugin/ghcmod.vim invokes ghcmod#check_version on its startup. That kills the whole point of autoload feature, i.e. speed up of startup time.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.