<div dir="ltr">Actually, I think there's at least one bug in ghc. My testing was all done on 7.8. When I tried running it on 7.10, reverse gives the out of memory error that Michael Sloan reported. Not really good, but acceptable, as you probably shouldn't be using lazy text in that situation.<div><br></div><div>Trying to use LText -> Text (which generates a type error if I try it without the interpreter) on 7.8 gets no output, but on 7.10 eventually segfaults.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 26, 2015 at 5:11 PM, Corentin Dupont <span dir="ltr"><<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Lazy text is this one? <a href="http://hackage.haskell.org/package/text-1.1.0.1/docs/Data-Text-Lazy.html" target="_blank">http://hackage.haskell.org/package/text-1.1.0.1/docs/Data-Text-Lazy.html</a><br><br></div>At first sight I'd say it's the way lazy text works with reverse that the interpreter doesn't like...<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 26, 2015 at 7:47 PM, Mike Meyer <span dir="ltr"><<a href="mailto:mwm@mired.org" target="_blank">mwm@mired.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>No answer on -beginners, so I'm trying -cafe.</div><div><br></div><div>I'm trying to run interpreted code via ClassyPrelude, and getting some results that make me suspect a bug in the Prelude's type system. Or maybe the interpreter.</div><div><br></div><div>Anyway, here's a bit of code that works as expected:</div><div><br></div><div>{-# LANGUAGE NoImplicitPrelude #-}</div><div><br></div><div>import ClassyPrelude</div><div>import Language.Haskell.Interpreter</div><div><br></div><div>main :: IO ()</div><div>main = do</div><div>  fun <- runInterpreter $ makeFun "reverse"</div><div>  case fun of</div><div>   Left e -> print e</div><div>   Right f -> readFile "/etc/motd" >>= hPut stdout . f</div><div><br></div><div><br></div><div>makeFun expr = do</div><div>  set [languageExtensions := [NoImplicitPrelude]] </div><div>  setImportsQ [("ClassyPrelude", Nothing)]</div><div>  interpret expr (as :: Text -> Text)</div><div><br></div><div><br></div><div>I don't think I can simplify this any further. It works as expected, and also works as expected, and prints out the contents of /etc/motd reversed.</div><div><br></div><div>However, if you change the type signature in the last line from Text -> Text to LText -> Ltext (to get lazy text), you get no output. But if you change the function in the first line after main from "reverse" to "id", it works.</div><div><br></div><div>So far, it might be an issue with lazy IO. However, change the type signature in the last line to LText -> Text. In this case, there is no output for either value of the expression.  I expect an error in this case, as neither id nor reverse should be able to have the type LText -> Text!</div><div><br></div><div>So, is there something I missed in either ClassyPrelude or the Interpreter? Or is this a subtle interaction, in which case can someone suggest a workaround? Or have I found a bug in one of the two?</div><div><br></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>