<div dir="ltr"><div>Repro'd on GHC 7.8.1 and 7.6.3</div><div><br></div>Original code is: <a href="https://github.com/bitemyapp/bloodhound/">https://github.com/bitemyapp/bloodhound/</a><br><br>The code only works if I manually (out of band) run insertData (in a REPL) and then run main with the insertData invocation stripped out. If I run main with the insertData invocation included, it throws an exception (head) because the search results are empty.<div>
<br>The behavior is as if queryTweet was executing after insertData deleted the index, but before it inserted the new data.<br><br>The following is a stripped down example:<br><br>insertData :: IO ()<br>insertData = do<br>
  let encoded = encode exampleTweet<br>  _ <- deleteExampleIndex<br>  created <- createExampleIndex<br>  docCreated <- indexDocument (Server "<a href="http://localhost:9200">http://localhost:9200</a>") "twitter" "tweet" exampleTweet "1"<br>
  print "test"<br>  return ()<br>el<br>queryTweet :: IO (Either String Tweet)<br>queryTweet = do<br>  let queryFilter = BoolFilter (MustMatch (Term "user" "bitemyapp") False)<br>                    <||> IdentityFilter<br>
  let search = Search Nothing (Just queryFilter)<br>  reply <- searchByIndex testServer "twitter" search<br>  let result = eitherDecode (responseBody reply) :: Either String (SearchResult Tweet)<br>  let myTweet = fmap (hitSource . head . hits . searchHits) result<br>
  return myTweet<br><br>main :: IO ()<br>main = do<br>  _ <- insertData<br>  myTweet <- queryTweet<br>  print myTweet</div><div><br></div><div>further up the call chain, the http call is getting dispatched with http-conduit's gear, the result returned with the expression:</div>
<div><br></div><div>withManager $ httpLbs req<br></div><div><br></div><div>Included this in case it affects the semantics.</div><div><br></div><div>Can anybody help? This has stumped me for a couple hours and I couldn't get anything clueful on IRC.<br>
</div><div><br></div><div>Thanks to any that help.</div><div><br></div><div>--- Chris</div><div><br></div></div>