Skip to content

Commit

Permalink
Work around HLS bug while embedding files
Browse files Browse the repository at this point in the history
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 committed Aug 7, 2023
1 parent 26623b6 commit 4c94ac5
Show file tree
Hide file tree
Showing 2 changed files with 4 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

0 comments on commit 4c94ac5

Please sign in to comment.