Hi Kyle, thank you again for your help and analysis.  In summary,
org-mode needs no patches, but inf-haskell's comint-prompt-regexp
needs updates.  I'll follow up with the inf-haskell maintainers.

----

> inf-haskell used to set comint-prompt-regexp in the body of
> inferior-haskell-mode...  This is inf-haskell's variable.
> ob-haskell shouldn't set it.

Thank you for your help in all this.  I couldn't find where the regex
was set in the org-mode source because it wasn't coming from org-mode
at all.  Putting this all together suggests that the correct fix is to
update the inf-haskell regex to handle "Prelude| " correctly in the
first place.

I believe it's possible to compress the current inf-haskell regexp
from this:

    (setq-local comint-prompt-regexp
                ;; Why the backslash in [\\._[:alnum:]]?
                "^\\*?[[:upper:]][\\._[:alnum:]]*\\(?:
\\*?[[:upper:]][\\._[:alnum:]]*\\)*\\( λ\\)?> \\|^λ?> $")

Down into this, without any significant loss of fidelity.  We really
don't care about any characters at the start of the line before the
final "> ".

    (setq-local comint-prompt-regexp "^[[:alnum:].*_() |λ]*> ")

This seems useful because, as I discovered this morning, importing
modules mangles the prompt further:

    Prelude> import Data.Time
    Prelude Data.Time> :m + Data.Time.Clock
    Prelude Data.Time Data.Time.Clock>

The testing data that this configuration correctly parsed is attached
for reference.

I'll figure out where to submit that patch to, and send it off.  It's
a single line change that shouldn't require any assignment papers.

Thanks again,
Nick
Prelude> import Data.Time
Prelude Data.Time> :m + Data.Time.Clock
Prelude Data.Time Data.Time.Clock> scanl (+) 0 [1,2,3,4]
"org-babel-haskell-eoe"
[0,1,3,6,10]
Prelude Data.Time Data.Time.Clock> "org-babel-haskell-eoe"
Prelude Data.Time Data.Time.Clock> :{
flip' :: (a -> b -> c) -> (b -> a -> c)
flip' f = \x y -> f y x
:}
"org-babel-haskell-eoe"
Prelude Data.Time Data.Time.Clock| Prelude Data.Time Data.Time.Clock| Prelude 
Data.Time Data.Time.Clock| Prelude Data.Time Data.Time.Clock> 
"org-babel-haskell-eoe"
Prelude Data.Time Data.Time.Clock> :{
sum' :: (Num a) => [a] -> a
sum' xs = foldl (\ acc x -> acc + x) 0 xs
:}
sum' [1,2,3,4] == 10
"org-babel-haskell-eoe"
Prelude Data.Time Data.Time.Clock| Prelude Data.Time Data.Time.Clock| Prelude 
Data.Time Data.Time.Clock| Prelude Data.Time Data.Time.Clock> True
Prelude Data.Time Data.Time.Clock> "org-babel-haskell-eoe"
Prelude Data.Time Data.Time.Clock> :{
sum' :: (Num a) => [a] -> a
sum' xs = foldl (\ acc x -> acc + x) 0 xs
:}
print "hi"
"org-babel-haskell-eoe"
Prelude Data.Time Data.Time.Clock| Prelude Data.Time Data.Time.Clock| Prelude 
Data.Time Data.Time.Clock| Prelude Data.Time Data.Time.Clock> "hi"
Prelude Data.Time Data.Time.Clock> "org-babel-haskell-eoe"
Prelude Data.Time Data.Time.Clock>

Reply via email to