Skip to content

Commit

Permalink
HLS integration fixes for the chainweb-data codebase (#157)
Browse files Browse the repository at this point in the history
This PR adds a `hie.yaml` to the project and also works around the following HLS bug:

haskell/haskell-language-server#481

That issue is actually related to stack, but seems like the cabal integration is suffering from the same in our case. There are quite a few relative-path related issues open in HLS anyway.

This commit uses the `makeRelativeToProject` function from file-embed ([As suggested by phadej under another issue](commercialhaskell/stack#5421 (comment))) in order to resolve the relative paths in a way that's independent of the build system, working around this long-standing HLS bug.

* Add a hie.yaml to the project

* Work around HLS bug while embedding files

This commit works around the following HLS bug:

haskell/haskell-language-server#481

That issue is actually related to stack, but seems like the cabal
integration is suffering from the same in our case. There are quite a
few relative-path related issue open HLS anyway.

This commit uses the `makeRelativeToProject` function from file-embed
in order to resolve the relative paths in a way that's independent of
the build system, working around this long-standing HLS bug.
  • Loading branch information
enobayram authored Aug 8, 2023
1 parent 901933a commit 31ec8de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions haskell-src/exec/Chainweb/Coins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ import Text.Read
-- | Read in the reward csv via TH for deployment purposes.
--
rawMinerRewards :: ByteString
rawMinerRewards = $(embedFile "data/miner_rewards.csv")
rawMinerRewards = $(makeRelativeToProject "data/miner_rewards.csv" >>= embedFile)
{-# NOINLINE rawMinerRewards #-}

rawAllocations :: ByteString
rawAllocations = $(embedFile "data/token_payments.csv")
rawAllocations = $(makeRelativeToProject "data/token_payments.csv" >>= embedFile)

allocations :: [AllocationEntry]
allocations = V.toList $ decodeAllocations rawAllocations
Expand Down
4 changes: 2 additions & 2 deletions haskell-src/exec/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ main = do
CheckSchema _ level -> level

migrationFiles :: [(FilePath, BS.ByteString)]
migrationFiles = $(embedDir "db-schema/migrations")
migrationFiles = $(makeRelativeToProject "db-schema/migrations" >>= embedDir)

initSql :: BS.ByteString
initSql = $(embedFile "db-schema/init.sql")
initSql = $(makeRelativeToProject "db-schema/init.sql" >>= embedFile)

runMigrations ::
P.Pool Connection ->
Expand Down
5 changes: 5 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cradle:
cabal:
- path: "haskell-src"
component: "lib:chainweb-data"

0 comments on commit 31ec8de

Please sign in to comment.