• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    Haskell
  • Created almost 12 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ide-backend drives the GHC API to build, query, and run your code

ide-backend

Build Status

ide-backend drives the GHC API to build, query, and run your code. It handles the tricky bits of driving the GHC API for use with integrated development environments. It was originally developed for the School of Haskell and FP Haskell Center, and is now an open source project. With stack-ide, IDEs and text editors can talk to ide-backend with a JSON protocol.

Installation

stack is required to build ide-backend. Once you have stack, run stack install.

Running the tests

To run the tests, stack build ide-backend-server && stack test. This won't run a complete test, as it will only use your current GHC version, but that should be sufficient for most development. We can leave it to travis to try multiple GHC versions.

Note: Hopefully soon this will merely be stack test. See this issue.

Hello World

The following simple example demonstrates basic usage of ide-backend.

{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as S8
import           Data.Monoid           ((<>))
import           IdeSession

main :: IO ()
main = do
    -- Initialization and providing some code
    config <- sessionConfigFromEnv
    sess <- initSession defaultSessionInitParams config
        { configLocalWorkingDir = Nothing }
    let upd = updateSourceFile "Main.hs" "main = putStrLn \"Hello World\""
           <> updateCodeGeneration True
           <> updateGhcOpts ["-Wall"]
    updateSession sess upd print -- print is used for progress updates

    -- Print errors and warnings
    errs <- getSourceErrors sess
    mapM_ print errs

    -- Run the code
    ra <- runStmt sess "Main" "main"
    let loop = do
            res <- runWait ra
            case res of
                Left bs -> S8.putStr bs >> loop
                Right rr -> putStrLn $ "Run result: " ++ show rr
    loop

    -- Get some type information
    expTypes <- getExpTypes sess
    print $ expTypes "Main" SourceSpan
        { spanFilePath = "Main.hs"
        , spanFromLine = 1
        , spanFromColumn = 8
        , spanToLine = 1
        , spanToColumn = 9
        }

    -- Autocompletion
    autoCompletion <- getAutocompletion sess
    print $ autoCompletion "Main" "putS"

To run this, use stack runghc example.hs. The output should look something like:

[1 of 1] Compiling Main
SourceError {errorKind = KindWarning, errorSpan = Main.hs@1:1-1:30, errorMsg = "Top-level binding with no type signature: main :: IO ()"}
Hello World
Run result: RunOk
[(Main.hs@1:8-1:16,"String -> IO ()"),(Main.hs@1:8-1:30,"IO ()")]
[putStr (VarName) defined in base-4.8.0.0:System.IO at <no location info> (home base-4.8.0.0:System.IO) (imported from base-4.8.0.0:Prelude at Main.hs@1:1-1:1),putStrLn (VarName) :: String -> IO () defined in base-4.8.0.0:System.IO at <no location info> (home base-4.8.0.0:System.IO) (imported from base-4.8.0.0:Prelude at Main.hs@1:1-1:1)]

More Repositories

1

mezzohaskell

Community-driven book on intermediate Haskell
298
star
2

inline-c

Haskell
284
star
3

terraform-aws-foundation

Establish a solid Foundation on AWS with these modules for Terraform
HCL
204
star
4

unliftio

The MonadUnliftIO typeclass for unlifting monads to IO
Haskell
150
star
5

safe-exceptions

Safe, consistent, and easy exception handling
Haskell
132
star
6

minghc

DEPRECATED: Windows installer for GHC including msys
Haskell
108
star
7

typed-process

Alternative API for processes, featuring more type safety
Haskell
106
star
8

weigh

Measure allocations of a Haskell functions/values
Haskell
92
star
9

amber

Manage secret values in-repo via public key cryptography
Rust
83
star
10

applied-haskell

80
star
11

pid1

Do signal handling and orphan reaping for Unix PID1 init processes
Haskell
76
star
12

ghc-prof-flamegraph

Haskell
75
star
13

haskell-scratch

Base Docker image which includes minimal shared libraries for GHC-compiled executables
Makefile
67
star
14

http-reverse-proxy

Reverse proxy HTTP requests, either over raw sockets or with WAI
Haskell
54
star
15

rdr2tls

Haskell web service that redirects all traffic from HTTP to HTTPS
Haskell
52
star
16

ghcjs-react

React bindings for GHCJS
JavaScript
48
star
17

odbc

Haskell ODBC binding with SQL Server support
Haskell
44
star
18

streaming-commons

Common lower-level functions needed by various streaming data libraries
Haskell
36
star
19

schoolofhaskell

Haskell
34
star
20

cache-s3

Haskell
34
star
21

halogen-form

Formlets for halogen
PureScript
30
star
22

say

Send textual messages to a Handle in a thread-friendly way
Haskell
29
star
23

optparse-simple

Simple helper functions to work with optparse-applicative
Haskell
29
star
24

haskell-ide

Repo for collaborating on various shared Haskell IDE components.
Haskell
29
star
25

stackage-cli

Haskell
28
star
26

devops-helpers

Devops helper scripts
Shell
28
star
27

wai-middleware-auth

Authentication middleware that secures WAI application
Haskell
23
star
28

safe-decimal

Haskell
22
star
29

pid1-rs

pid1 handling library for proper signal and zombie reaping of the PID1 process
Rust
22
star
30

stackage-view

JavaScript
21
star
31

best-practices

Documentation for best practices followed at FP Complete
21
star
32

inline-c-cpp

Haskell
19
star
33

sift

Sift through Haskell code for analysis purposes
Haskell
18
star
34

schoolofhaskell.com

Haskell
16
star
35

haskell-multi-docker-example

Haskell
15
star
36

mutable-containers

Abstactions and concrete implementations of mutable containers
14
star
37

monad-unlift

Typeclasses for representing monad (transformer) morphisms
Haskell
14
star
38

stack-docker-image-build

Generate Docker images containing additional packages
Haskell
14
star
39

simple-file-mirror

A dumb tool to mirror changes in a directory between hosts
Haskell
12
star
40

inline-c-nag

Haskell
11
star
41

stream

Streaming data library built around first-class stream fusion for high efficiency
Haskell
11
star
42

yesod-ghcjs

Haskell
10
star
43

th-utilities

Collection of useful functions for use with Template Haskell
Haskell
10
star
44

stackage-curator

DEPRECATED Tools for curating Stackage package sets and building reusable package databases
Haskell
10
star
45

rust-aws-devops

A very small DevOps tool to demo using Rust with AWS
Rust
10
star
46

haskell-filesystem

Contains the system-filepath and system-fileio packages
Haskell
9
star
47

fpco-salt-formula

SaltStack
9
star
48

hackage-mirror

8
star
49

wai-middleware-consul

Haskell
8
star
50

stackage-update

Update your package index incrementally (requires git)
Haskell
8
star
51

fsnotify-conduit

Get filesystem notifications as a stream of events
Haskell
8
star
52

packer-windows

The example code repo to accompany the (yet to be released) blog post on building Windows server images using Packer
PowerShell
8
star
53

flush-queue

Haskell
8
star
54

conduit-combinators

Commonly used conduit functions, for both chunked and unchunked data
8
star
55

fuzzcheck

A library for testing monadic code in the spirit of QuickCheck
Haskell
8
star
56

monad-logger-syslog

monad-logger for syslog
Haskell
7
star
57

bootstrap-salt-formula

SaltStack
6
star
58

ghcjs-from-typescript

Haskell
6
star
59

serial-bench

Ridiculously oversimplified serialization benchmark.
HTML
5
star
60

docker-static-haskell

Docker images based on Alpine for compiling static Haskell executables
5
star
61

stackage-upload

A more secure version of cabal upload which uses HTTPS
Haskell
4
star
62

openconnect-gateway

Docker image and helper scripts to run a VPN gateway with OpenConnect
Shell
4
star
63

executable-hash

Provides the SHA1 hash of the program executable
Haskell
4
star
64

stackage-install

Secure download of packages for cabal-install
Haskell
4
star
65

simple-poll

Haskell
4
star
66

alpine-haskell-stack

Just
4
star
67

monad-logger-json

Functions for logging ToJSON instances with monad-logger
Haskell
4
star
68

demos

Haskell
3
star
69

ghc-rc-stackage

Helper repo for testing GHC release candidates against the Stackage package set
Shell
3
star
70

wai-middleware-ldap

Haskell
3
star
71

stackage-sandbox

Haskell
3
star
72

replace-process

Replace the current process with a different executable
Haskell
3
star
73

strict-concurrency

Mirror of strict-concurrency Darcs repository by Don Stewart
Haskell
3
star
74

kube-test-suite

Validation test suite for kubernetes clusters
Haskell
3
star
75

qapla

Haskell
2
star
76

spiderweb

Link check, capture, and serve sites statically
Haskell
2
star
77

fphc

Issue tracker for FP Haskell Center
2
star
78

wai-middleware-crowd

Middleware and utilities for using Atlassian Crowd authentication
Haskell
2
star
79

stackage-dot

Haskell
2
star
80

hauth

Header Authentication Library for Haskell
Haskell
2
star
81

stackage-setup

Haskell
2
star
82

libraries

FP Complete libraries mega-repo
Haskell
2
star
83

snoc-vector

Vectors with cheap append operations
Haskell
2
star
84

helm-charts

FPCO Helm charts
Smarty
2
star
85

ghc-events-time

Haskell
2
star
86

stackage-cabal

Haskell
2
star
87

chunked-data

Typeclasses for dealing with various chunked data representations
2
star
88

build-profile

Haskell
2
star
89

dockerfile-argocd-deploy

Dockerfile for image containing tools for CI jobs to deploy to Kubernetes using ArgoCD
Dockerfile
1
star
90

simple-mega-repo

Haskell
1
star
91

hackage-upload-analyzer

Performs batch analysis of Hackage upload logs, generating an HTML file with the results.
Haskell
1
star
92

text-stream-decode

Streaming decoding functions for UTF encodings.
Haskell
1
star
93

fpco-cereal

Haskell
1
star
94

nrelic

New Relic GCStats metrics (demo)
Haskell
1
star
95

piggies

Haskell
1
star
96

pretty-time

Rendering of time values in various user-friendly formats.
Haskell
1
star
97

soh-static

School of Haskell static archive
HTML
1
star
98

coredump-uploader

Shell
1
star
99

stack-templates

fpco stack templates
1
star
100

rest-client

Haskell
1
star