Skip to content

Instantly share code, notes, and snippets.

@wz1000
wz1000 / Errors.hs
Last active January 4, 2017 14:33
Haskell Error Handling
{-# LANGUAGE TypeFamilies, DataKinds, TypeInType, KindSignatures, TypeOperators, TypeApplications, StandaloneDeriving, ApplicativeDo, GeneralizedNewtypeDeriving #-}
import GHC.Types
import Data.Monoid
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Writer
import Control.Monad.Trans
data FieldStatus = Error | Normal
@wz1000
wz1000 / hiebug.txt
Last active June 10, 2017 17:33
HIE Execute Command bug
2017-06-10 22:48:34 [ThreadId 9] - <--2--{"result":[{"arguments":[{"file":{"textDocument":{"uri":"file:///home/zubin/haskell-ide-engine/test/testdata/ApplyRefact.hs"}}},{"start_pos":{"position":{"line":3,"character":8}}}],"title":"Apply hint:Redundant bracket","command":"applyrefact:applyOne"}],"jsonrpc":"2.0","id":3}
2017-06-10 22:48:36 [ThreadId 7] - ---> {"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command":"applyrefact:applyOne","arguments":[{"file":{"textDocument":{"uri":"file:///home/zubin/haskell-ide-engine/test/testdata/ApplyRefact.hs"}}},{"start_pos":{"position":{"line":3,"character":8}}}]}}
2017-06-10 22:48:36 [ThreadId 10] - reactor:got ExecuteCommandRequest:RequestMessage {_jsonrpc = "2.0", _id = IdInt 4, _method = WorkspaceExecuteCommand, _params = ExecuteCommandParams {_command = "applyrefact:applyOne", _arguments = Just (List [Object (fromList [("file",Object (fromList [("textDocument",Object (fromList [("uri",String "file:///home/zubin/haskell-ide-engine/test/testdata
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE ConstraintKinds #-}
type Value = String
type FromJSON = Read
fromJSON :: FromJSON a => Value -> a
fromJSON = read
@wz1000
wz1000 / proposal.md
Last active February 13, 2018 18:25
GHC IDE Proposal
@wz1000
wz1000 / gist:46bb4b2121f0911bbbf4d4743fafaba8
Created May 4, 2018 07:29
.hie file discussion on #ghc
2018-02-13 23:57:02 wz1000 alanz, alexbiehl, mpickering: https://gist.github.com/wz1000/81e0bb720237e8ae6193c7ac2d28c913
2018-02-13 23:58:15 alanz wz1000, I like what you are aiming for
2018-02-13 23:58:22 alanz well, all of you
2018-02-13 23:58:23 mpickering wz1000: I just skimmed it now but if I were you I would write down something very concrete (answer all the questions at the end)
2018-02-13 23:58:33 alanz I guess I should actually pay some attention
2018-02-13 23:59:01 mpickering if you don't write down something very concrete then making progress is much more difficult as people love discussing things until they die
2018-02-13 23:59:47 wz1000 yeah, this is just some initial brainstorming
2018-02-14 00:00:03 c_wraith I'd love to be able to get more information out of ghc
2018-02-14 00:00:36 alanz I think there are also two parts to it, getting the info out, and keeping it available, as in storing it on disk or some such
2018-02-14 00:01:09 alanz Because expecting a big project's detail to be in RAM won'
data HieToken = HieToken
{ htkInfo :: TokenType
, htkSpan :: Span
, htkDetails :: Maybe TokenDetails
, htkType :: Maybe TypeIndex
}
data HieAST =
Leaf HieToken
| Node
main :: IO ()
main =
do code <- getContents
args <- getArgs
case consume options (map T.pack args) of
Succeeded (action,typ,exts) ->
outputWith action typ exts code
_ ->
error (T.unpack (textDescription (describe options [])))
main :: IO ()
main = print $ fib 41 where
fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
Node {nodeInfo = ["Module"], nodeSpan = SrcSpanPoint "" 1 1, nodeChildren =
[Leaf (HieToken {htkInfo = TkIdentifier, htkSpan = SrcSpanOneLine "/home/zubin/Documents/Haskell/Fib.hs" 1 1 5, htkDetails = Nothing, htkType = Nothing})
,Leaf (HieToken {htkInfo = TkSpace, htkSpan = SrcSpanOneLine "/home/zubin/Documents/Haskell/Fib.hs" 1 5 6 , htkDetails = Nothing, htkType = Nothing})
,Leaf (HieToken {htkInfo = TkGlyph, htkSpan = SrcSpanOneLine "/home/zubin/Documents/Haskell/Fib.hs" 1 6 8, htkDetails = Nothing, htkType = Nothing})
class C a where
f :: a -> Int
f = const 3
main :: IO ()
main = print $ fib 41 where
fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
module A where
data D = D
{ foo :: Int
, bar :: Bool
}
[1 of 1] Compiling A ( a.hs, nothing )
a.hs:1:1:
==================== Typechecker ====================