Conversation
bfcb723 to
a636e26
Compare
snoyberg
left a comment
There was a problem hiding this comment.
LGTM, please merge when ready
|
Hi, many thanks for trying fix this. D:\ws\haskell\stack-test>stack --version
Version 2.6.0, Git revision a636e262579753326cde8d0f38f19e137bb872a2 (dirty) (8261 commits) PRE-RELEASE x86_64 hpack-0.33.0
D:\ws\haskell\stack-test>type subpackage\src\MyLib.hs
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
module MyLib (cwd, val, val1) where
import System.Directory
import Data.Yaml (Value)
import Data.Yaml.TH (decodeFile)
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
cwd :: FilePath
cwd = $$(runIO getCurrentDirectory >>= \d-> fmap TExp (lift (d :: FilePath)))
val :: Value
val = $$(do
file <- runIO $ do
exist <- doesFileExist "config/value.yaml"
return $ if exist then "config/value.yaml"
else "subpackage/config/value.yaml"
decodeFile file :: Q (TExp Value)
)
val1 :: Value
val1 = $$(decodeFile "config/value.yaml" :: Q (TExp Value))
D:\ws\haskell\stack-test>dir config /B
No se encuentra el archivo
D:\ws\haskell\stack-test>dir subpackage\config /B
value.yaml
D:\ws\haskell\stack-test>type app\Main.hs
module Main where
import Lib
import MyLib
main :: IO ()
main = do
putStrLn $ cwd
putStrLn $ show val
putStrLn $ show val1
D:\ws\haskell\stack-test>stack run
.................
D:\ws\haskell\stack-test\subpackage
Number 2.0
Number 2.0
D:\ws\haskell\stack-test>stack repl
.............................
D:\\\\ws\haskell\stack-test\subpackage\src\MyLib.hs:24:11: error:
• Exception when trying toto run compile-time code:
InvalidYaml (Just (YamlException "Yaml file not found: config/value.yaml"))
Code: decodeFile "config/value.yaml" :: Q (TExp Value)
• In the Template Haskell splice:
$$(decodeFile "config/value.yaml" :: Q (TExp Value))
In the expression:
$$(decodeFile "config/value.yaml" :: Q (TExp Value))
In an equation for ‘val1’:
val1 = $$(decodeFile "config/value.yaml" :: Q (TExp Value))
|
24 | val1 = $$(decodeFile "config/value.yaml" :: Q (TExp Value))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, one module loaded.
<no location info>: error:
Could not load module ‘MyLib’
It is a member of the hidden package ‘subpackage-0.1.0.0’.
You can run ‘:set -package subpackage’ to expose it.
(Note: this unloads all the modules in the current scope.)
Loaded GHCi configuration from C:\\TEMP\\haskell-stack-ghci\\9dd5157a\\ghci-scri
pt
*Lib> |
|
@jneira have you read my comment #5421 (comment) stating
? |
|
@qrilka uh, my bad, i did read what i want to and not what you wrote, sorry Only note that the pr would not close the issue afaiu, as |
|
Yeah, a proper resolution is blocked by upstream but I need to check if there are other issues on this topic so maybe we could at least minimize duplication in the issue tracker :) |
|
@qrilka sure! |
Note: Documentation fixes for https://docs.haskellstack.org/en/stable/ should target the "stable" branch, not master.
Please include the following checklist in your PR:
Resolves #5421. Tested manually