Skip to content

Commit 31ec8de

Browse files
authored
HLS integration fixes for the chainweb-data codebase (#157)
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.
1 parent 901933a commit 31ec8de

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

haskell-src/exec/Chainweb/Coins.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ import Text.Read
3737
-- | Read in the reward csv via TH for deployment purposes.
3838
--
3939
rawMinerRewards :: ByteString
40-
rawMinerRewards = $(embedFile "data/miner_rewards.csv")
40+
rawMinerRewards = $(makeRelativeToProject "data/miner_rewards.csv" >>= embedFile)
4141
{-# NOINLINE rawMinerRewards #-}
4242

4343
rawAllocations :: ByteString
44-
rawAllocations = $(embedFile "data/token_payments.csv")
44+
rawAllocations = $(makeRelativeToProject "data/token_payments.csv" >>= embedFile)
4545

4646
allocations :: [AllocationEntry]
4747
allocations = V.toList $ decodeAllocations rawAllocations

haskell-src/exec/Main.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ main = do
118118
CheckSchema _ level -> level
119119

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

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

126126
runMigrations ::
127127
P.Pool Connection ->

hie.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cradle:
2+
cabal:
3+
- path: "haskell-src"
4+
component: "lib:chainweb-data"
5+

0 commit comments

Comments
 (0)