Skip to content

Instantly share code, notes, and snippets.

@jneira
Created September 2, 2020 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jneira/c65f2d10e1e5bc177361ff23a3fb268d to your computer and use it in GitHub Desktop.
Save jneira/c65f2d10e1e5bc177361ff23a3fb268d to your computer and use it in GitHub Desktop.
hls hlint plugin: vfs vs temp
module Lib where
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Function
import Data.Ord
test :: BS.ByteString
test = BS.pack "Hello Haskell"
-- | My function docs
-- > test2 [1,2,3]
test2 :: [a]
test2 = ([])
data BST a = Node a (BST a) (BST a) | Empty
deriving (Show)
label :: BST a -> BST (Int,a)
label tree = rec tree 0
where rec (Node a left right) i = Node (i,a) (rec left (i+1)) (rec right (i+1))
rec Empty _ = Empty
getChildren :: BST a -> [BST a]
getChildren Empty = []
getChildren (Node _ Empty Empty) =
[]
getChildren (Node _ left Empty) =
[left]
getChildren (Node _ Empty right) =
[right]
getChildren (Node _ left right) =
[left,right]
nodeValue :: BST a -> [a]
nodeValue (Node val _ _ ) = [val]
nodeValue _ = []
bfs :: BST a -> [a]
bfs x = go [x]
where
go :: [BST a] -> [a]
go [] = []
go xs = concatMap nodeValue xs ++ go (concatMap getChildren xs)
2020-09-02 15:44:11.6260436 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":6,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/cabal-test/src/Lib.hs"},"position":{"line":13,"character":10}}}
2020-09-02 15:44:11.6260436 [ThreadId 379] - GhcIde.hover entered (ideLogger)
2020-09-02 15:44:11.6260436 [ThreadId 379] - Hover request at position 14:11 in file: d:\dev\ws\haskell\cabal-test\src\Lib.hs
2020-09-02 15:44:11.6260436 [ThreadId 376] - finish: C:GetHieFile (took 0.00s)
2020-09-02 15:44:11.6270474 [ThreadId 376] - finish: C:GetDocMap (took 0.00s)
2020-09-02 15:44:11.6270474 [ThreadId 6] - <--2--{"result":{"contents":{"kind":"markdown","value":"\n```haskell\n[]\n```\n\n*Defined in `GHC.Types'*\n\n\n*\t*\t*\n\n```haskell\n_ :: [a]\n```\n"},"range":{"start":{"line":13,"character":9},"end":{"line":13,"character":11}}},"jsonrpc":"2.0","id":6}
2020-09-02 15:44:11.8818663 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":7,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/cabal-test/src/Lib.hs"},"range":{"start":{"line":13,"character":8},"end":{"line":13,"character":12}},"context":{"diagnostics":[{"range":{"start":{"line":13,"character":8},"end":{"line":13,"character":12}},"message":"D:\\dev\\ws\\haskell\\cabal-test\\src\\Lib.hs:14:9-12: Warning: Redundant bracket\nFound:\n ([])\nPerhaps:\n []\n","severity":3,"code":"Redundant bracket","source":"hlint"}],"only":["quickfix"]}}}
2020-09-02 15:44:11.8828627 [ThreadId 376] - finish: CodeAction (took 0.00s)
2020-09-02 15:44:11.8828627 [ThreadId 376] - finish: CodeAction:PackageExports (took 0.00s)
2020-09-02 15:44:11.8848673 [ThreadId 376] - finish: C:TypeCheck (took 0.00s)
2020-09-02 15:44:11.8848673 [ThreadId 376] - finish: C:GetModSummary (took 0.00s)
2020-09-02 15:44:11.893862 [ThreadId 6] - <--2--{"result":[{"command":{"command":"6036:hlint:applyOne","arguments":[{"hintTitle":"Redundant bracket","start_pos":{"line":13,"character":8},"file":"file:///d%3A/dev/ws/haskell/cabal-test/src/Lib.hs"}],"title":"Apply hint:D:\\dev\\ws\\haskell\\cabal-test\\src\\Lib.hs:14:9-12: Warning: Redundant bracket"},"kind":"quickfix","diagnostics":[{"severity":3,"range":{"start":{"line":13,"character":8},"end":{"line":13,"character":12}},"code":"Redundant bracket","source":"hlint","message":"D:\\dev\\ws\\haskell\\cabal-test\\src\\Lib.hs:14:9-12: Warning: Redundant bracket\nFound:\n ([])\nPerhaps:\n []\n"}],"title":"Apply hint:D:\\dev\\ws\\haskell\\cabal-test\\src\\Lib.hs:14:9-12: Warning: Redundant bracket"}],"jsonrpc":"2.0","id":7}
2020-09-02 15:44:20.7522652 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":8,"method":"workspace/executeCommand","params":{"command":"6036:hlint:applyOne","arguments":[{"hintTitle":"Redundant bracket","start_pos":{"line":13,"character":8},"file":"file:///d%3A/dev/ws/haskell/cabal-test/src/Lib.hs"}]}}
2020-09-02 15:44:20.7542647 [ThreadId 385] - haskell-lsp:persistFileVFS: Writing virtual file: uri = NormalizedUri (-870452232) "file:///D:/dev/ws/haskell/cabal-test/src/Lib.hs", virtual file = "C:\\TEMP\\haskell-lsp-7668f470296565da\\Lib.hs-00000--870452232.hs"
2020-09-02 15:44:20.761266 [ThreadId 376] - hlint:getIdeas:file:NormalizedFilePath "C:\\TEMP\\haskell-lsp-7668f470296565da\\Lib.hs-00000--870452232.hs"
2020-09-02 15:44:20.7622652 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"token":1},"method":"window/workDoneProgress/create","id":66}
2020-09-02 15:44:20.7622652 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":true,"title":"Applying hint: Redundant bracket"},"token":1},"method":"$/progress"}
2020-09-02 15:44:20.766267 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":66,"result":null}
2020-09-02 15:44:20.766267 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":66,\"result\":null}"
2020-09-02 15:44:21.112283 [ThreadId 389] - Consulting the cradle for "C:\\TEMP\\haskell-lsp-7668f470296565da\\Lib.hs-00000--870452232.hs"
Output from setting up the cradle Cradle {cradleRootDir = "d:\\dev\\ws\\haskell\\cabal-test", cradleOptsProg = CradleAction: Cabal}
2020-09-02 15:44:21.1252627 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"token":2},"method":"window/workDoneProgress/create","id":67}
2020-09-02 15:44:21.1252627 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":false,"title":"Setting up project cabal-test"},"token":2},"method":"$/progress"}
2020-09-02 15:44:21.1272621 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":67,"result":null}
2020-09-02 15:44:21.1272621 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":67,\"result\":null}"
> Resolving dependencies...
> cabal: Cannot open a repl for the package C, it is not in this project (either
> directly or indirectly). If you want to add it to the project then edit the
> cabal.project file.
>
2020-09-02 15:44:26.9742627 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":2},"method":"$/progress"}
2020-09-02 15:44:26.9742627 [ThreadId 389] - Session loading result: Left [CradleError {cradleErrorDependencies = ["cabal-test.cabal","cabal.project","cabal.project.local"], cradleErrorExitCode = ExitFailure 1, cradleErrorStderr = ["Failed to parse result of calling cabal","Resolving dependencies...\n","cabal: Cannot open a repl for the package C, it is not in this project (either\ndirectly or indirectly). If you want to add it to the project then edit the\ncabal.project file.\n\n",""]}]
2020-09-02 15:44:26.9752683 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///C:/TEMP/haskell-lsp-7668f470296565da/Lib.hs-00000--870452232.hs","diagnostics":[{"severity":1,"range":{"start":{"line":0,"character":0},"end":{"line":1,"character":0}},"source":"cradle","message":"Failed to parse result of calling cabal\nResolving dependencies...\n\ncabal: Cannot open a repl for the package C, it is not in this project (either\ndirectly or indirectly). If you want to add it to the project then edit the\ncabal.project file.\n\n\n\n"}]},"method":"textDocument/publishDiagnostics"}
2020-09-02 15:44:26.9752683 [ThreadId 386] - applyHint:apply=[]
2020-09-02 15:44:26.9752683 [ThreadId 398] - finish: applyHint (took 6.21s)
2020-09-02 15:44:26.9822689 [ThreadId 408] - finish: InitialLoad (took 0.01s)
2020-09-02 15:44:27.0172635 [ThreadId 408] - finish: hlint (took 0.00s)
2020-09-02 15:44:27.0172635 [ThreadId 386] - hlint:applyHint:diff=WorkspaceEdit {_changes = Nothing, _documentChanges = Just (List [TextDocumentEdit {_textDocument = VersionedTextDocumentIdentifier {_uri = Uri {getUri = "file:///D:/dev/ws/haskell/cabal-test/src/Lib.hs"}, _version = Just 0}, _edits = List [TextEdit {_range = Range {_start = Position {_line = 0, _character = 0}, _end = Position {_line = 8, _character = 1}}, _newText = "module Lib where\nimport qualified Data.ByteString.Char8 as BS\nimport Data.List\nimport Data.Function\nimport Data.Ord\n\ntest :: BS.ByteString\ntest = BS.pack \"Hello Haskell\"\n"},TextEdit {_range = Range {_start = Position {_line = 11, _character = 0}, _end = Position {_line = 43, _character = 15}}, _newText = "\ntest2 :: [a]\ntest2 = ([])\n\ndata BST a = Node a (BST a) (BST a) | Empty\n deriving (Show)\n\nlabel :: BST a -> BST (Int,a)\nlabel tree = rec tree 0\n where rec (Node a left right) i = Node (i,a) (rec left (i+1)) (rec right (i+1))\n rec Empty _ = Empty\n\ngetChildren :: BST a -> [BST a]\ngetChildren Empty = []\ngetChildren (Node _ Empty Empty) =\n []\ngetChildren (Node _ left Empty) =\n [left]\n\ngetChildren (Node _ Empty right) =\n [right]\ngetChildren (Node _ left right) =\n [left,right]\n\nnodeValue :: BST a -> [a]\nnodeValue (Node val _ _ ) = [val]\nnodeValue _ = []\n\nbfs :: BST a -> [a]\nbfs x = go [x]\n where\n go :: [BST a] -> [a]\n go [] = []"}]}])}
2020-09-02 15:44:27.0702611 [ThreadId 386] - hlint:applyOneCmd:file=NormalizedFilePath "D:\\dev\\ws\\haskell\\cabal-test\\src\\Lib.hs"
2020-09-02 15:44:27.0702611 [ThreadId 386] - hlint:applyOneCmd:res=Right (WorkspaceEdit {_changes = Nothing, _documentChanges = Just (List [TextDocumentEdit {_textDocument = VersionedTextDocumentIdentifier {_uri = Uri {getUri = "file:///D:/dev/ws/haskell/cabal-test/src/Lib.hs"}, _version = Just 0}, _edits = List [TextEdit {_range = Range {_start = Position {_line = 0, _character = 0}, _end = Position {_line = 8, _character = 1}}, _newText = "module Lib where\nimport qualified Data.ByteString.Char8 as BS\nimport Data.List\nimport Data.Function\nimport Data.Ord\n\ntest :: BS.ByteString\ntest = BS.pack \"Hello Haskell\"\n"},TextEdit {_range = Range {_start = Position {_line = 11, _character = 0}, _end = Position {_line = 43, _character = 15}}, _newText = "\ntest2 :: [a]\ntest2 = ([])\n\ndata BST a = Node a (BST a) (BST a) | Empty\n deriving (Show)\n\nlabel :: BST a -> BST (Int,a)\nlabel tree = rec tree 0\n where rec (Node a left right) i = Node (i,a) (rec left (i+1)) (rec right (i+1))\n rec Empty _ = Empty\n\ngetChildren :: BST a -> [BST a]\ngetChildren Empty = []\ngetChildren (Node _ Empty Empty) =\n []\ngetChildren (Node _ left Empty) =\n [left]\n\ngetChildren (Node _ Empty right) =\n [right]\ngetChildren (Node _ left right) =\n [left,right]\n\nnodeValue :: BST a -> [a]\nnodeValue (Node val _ _ ) = [val]\nnodeValue _ = []\n\nbfs :: BST a -> [a]\nbfs x = go [x]\n where\n go :: [BST a] -> [a]\n go [] = []"}]}])})
2020-09-02 15:44:27.0702611 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":1},"method":"$/progress"}
2020-09-02 15:44:27.0712618 [ThreadId 6] - <--2--{"result":null,"jsonrpc":"2.0","id":8}
2020-09-02 15:44:27.0712618 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"edit":{"documentChanges":[{"edits":[{"range":{"start":{"line":0,"character":0},"end":{"line":8,"character":1}},"newText":"module Lib where\nimport qualified Data.ByteString.Char8 as BS\nimport Data.List\nimport Data.Function\nimport Data.Ord\n\ntest :: BS.ByteString\ntest = BS.pack \"Hello Haskell\"\n"},{"range":{"start":{"line":11,"character":0},"end":{"line":43,"character":15}},"newText":"\ntest2 :: [a]\ntest2 = ([])\n\ndata BST a = Node a (BST a) (BST a) | Empty\n deriving (Show)\n\nlabel :: BST a -> BST (Int,a)\nlabel tree = rec tree 0\n where rec (Node a left right) i = Node (i,a) (rec left (i+1)) (rec right (i+1))\n rec Empty _ = Empty\n\ngetChildren :: BST a -> [BST a]\ngetChildren Empty = []\ngetChildren (Node _ Empty Empty) =\n []\ngetChildren (Node _ left Empty) =\n [left]\n\ngetChildren (Node _ Empty right) =\n [right]\ngetChildren (Node _ left right) =\n [left,right]\n\nnodeValue :: BST a -> [a]\nnodeValue (Node val _ _ ) = [val]\nnodeValue _ = []\n\nbfs :: BST a -> [a]\nbfs x = go [x]\n where\n go :: [BST a] -> [a]\n go [] = []"}],"textDocument":{"uri":"file:///D:/dev/ws/haskell/cabal-test/src/Lib.hs","version":0}}]}},"method":"workspace/applyEdit","id":68}
2020-09-02 15:44:27.0972652 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":9,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/cabal-test/src/Lib.hs"},"range":{"start":{"line":7,"character":30},"end":{"line":7,"character":30}},"context":{"diagnostics":[]}}}
2020-09-02 15:44:27.0982623 [ThreadId 408] - finish: CodeAction (took 0.00s)
2020-09-02 15:44:27.0982623 [ThreadId 408] - finish: CodeAction:PackageExports (took 0.00s)
2020-09-02 15:44:27.0992645 [ThreadId 408] - finish: C:TypeCheck (took 0.00s)
2020-09-02 15:44:27.0992645 [ThreadId 6] - <--2--{"result":[],"jsonrpc":"2.0","id":9}
2020-09-02 15:44:27.0992645 [ThreadId 408] - finish: C:GetModSummary (took 0.00s)
2020-09-02 15:44:27.1202614 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":68,"result":{"applied":true}}
2020-09-02 15:44:27.1212641 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":68,\"result\":{\"applied\":true}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment