Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qAddDependentFile no longer triggers recompile #313

Open
snoyberg opened this issue Sep 25, 2015 · 2 comments
Open

qAddDependentFile no longer triggers recompile #313

snoyberg opened this issue Sep 25, 2015 · 2 comments

Comments

@snoyberg
Copy link
Member

Minimal reproducing test case:

{-# LANGUAGE OverloadedStrings #-}
import IdeSession
import Data.Monoid
import Data.String

foo_hs, foo_txt1, foo_txt2 :: IsString a => a
foo_hs =
    "{-# LANGUAGE TemplateHaskell #-}\n\
    \import Language.Haskell.TH.Syntax\n\
    \main = print $(do\n\
    \    let fp = \"foo.txt\"\n\
    \    qAddDependentFile fp\n\
    \    str <- qRunIO $ readFile fp\n\
    \    lift str)"
foo_txt1 = "version1"
foo_txt2 = "version2"

wdir = do
    writeFile "foo.hs" foo_hs
    writeFile "foo.txt" foo_txt1
    return (conf, update, mupdate2)
  where
    conf = defaultSessionConfig { configLocalWorkingDir = Just "." }
    update = mempty
    mupdate2 = do
        writeFile "foo.txt" foo_txt2
        return mempty

nowdir =
    return (defaultSessionConfig, update, mupdate2)
  where
    update = updateSourceFile "foo.hs" foo_hs
          <> updateDataFile "foo.txt" foo_txt1
    mupdate2 = return $ updateDataFile "foo.txt" foo_txt2

main :: IO ()
main = do
    putStrLn "Working directory"
    go wdir

    putStrLn "===========\nNo working directory"
    go nowdir

go mtriple = do
    (conf, update, mupdate2) <- mtriple

    sess <- initSession defaultSessionInitParams conf

    updateSession sess
        (updateTargets (TargetsInclude ["foo.hs"]) <>
         updateCodeGeneration True <>
         update)
        print

    runIt sess

    putStrLn "\n\nUpdating file"
    update2 <- mupdate2
    updateSession sess update2 print
    runIt sess

runIt sess = do
    getSourceErrors sess >>= print
    ra <- runStmt sess "Main" "main"
    let loop = do
            res <- runWait ra
            case res of
                Left bs -> print bs >> loop
                Right x -> print x
    loop

I at first thought this was a problem with the working directory case, but turns out the non-working-directory case also demonstrates the issue. This was working in the past, and I thought there were test cases for it.

Originally reported in urbanslug/wai-devel#6

@rvion
Copy link

rvion commented Nov 4, 2015

Any news about this ?

@urbanslug
Copy link
Contributor

@rvion Not yet, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants