2

I'm trying to create a custom sublime-build file in MacOS Yosemite, that will execute ghci on console with my code preloaded. That will make my Haskell learning process faster and enjoyable. However, since I'm new to Haskell and Sublime Text, I have no idea what to write in the file.

I know that this code does the same for gnome-terminal:

{
    "selector": "source.haskell",
    "working_dir": "$file_path",
    "cmd": ["gnome-terminal","-x","ghci", "$file"]
}

I found the code here.

user1563544
  • 379
  • 3
  • 17
  • It's a little unclear what you're really wanting to do. Do you always want a new console to open up when you build a Haskell file? When you say you don't know what to "write in the file", which file are you referring to? The build file? A Haskell source file? – bheklilr Oct 31 '14 at 13:43
  • I refer to Sublime Text's console which is always open. And yes, I refer to the build fire, I mentioned that both in the title and the body. – user1563544 Oct 31 '14 at 16:38
  • You know that if you already have loaded the file in GHCi, you can reload it with `:r`? You could, in theory, set this up from Sublime, but I think it'd be a lot easier just to use the functionality built-in to GHCi, and it'd take just as many keystrokes to perform. And another shortcut is that the command `:` executes the last `:` prefixed command in GHCi, so you can get it down to just `: + [Enter]`. – bheklilr Oct 31 '14 at 16:43
  • You are definitely right :) I guess maybe switching back and forth between applications is a little annoying. Would feel better if the experience was seamless. – user1563544 Oct 31 '14 at 17:31
  • This is why I'd suggest SublimeHaskell and SublimeREPL. The former takes some configuration and installing some tools designed for integrating GHC with editors, but once you're up and running it's very nice. It'll typecheck your program in the background and show you the errors in the output pane, and if you have a cabal project then it can execute cabal commands for you. And it comes with autocompleting things like language extensions, installed modules, can show you types of functions in the editor, etc. I use it all the time. – bheklilr Oct 31 '14 at 17:35
  • I have installed SublimeHaskell and int's neat. The autocompletion and typecheck is nice. What would be even more awesome is hitting Cmd+B and already having ghci preloaded, so that you can test your functions seamlessly. And this seems easily achievable. Unfortunately, I don't know the syntax. – user1563544 Oct 31 '14 at 17:41

1 Answers1

1

check this: https://github.com/SublimeHaskell/SublimeHaskell

USAGE (From their Readme.md):

In short: Press Shift-Ctrl-P and type haskell to explore all commands.

When editing Haskell source files that are part of a Cabal project, automatic error highlighting and enhanced auto-completion are available.

Each time you save, any errors in your program will be listed at the bottom of the window and highlighted in the source code.

All source files in the project are scanned when the change. Any symbols that they export are provided in the auto-complete suggestions.

To use cabal-dev instead of cabal, set use_cabal_dev to true (or use command "Switch Cabal/Cabal-Dev") and specify cabal-dev absolute path. Completion list will be rescanned and build will use cabal-dev.

Stylish-haskell can be used to stylish file or selected text.

Use Ctrl-Shift-R to go to declaration and Ctrl-K-I to show symbol info with documentation. These command are also available through context menu with right-click.

Command 'SublimeHaskell: Browse module' is similar to ghci's browse command

To show inferred types use Show type (ctrl-k ctrl-h ctrl-t) command.

To insert inferred type use Insert type (ctrl-k ctrl-h ctrl-i).

You can jump between the errors and warnings with F4 and Shift-F4. To show hidden error output, use command Show error panel (ctrl-alt-e)

adRn
  • 76
  • 5