JHC: problem with transformers
Hi John, I experiment with JHC, trying to get working some code. Could you help with following code:
module Main where import Data.Map as M
g :: M.Map String Int g = M.delete "b" M.empty
main = print g
If it is compiled with: -f no-global-optimize, then incorrect C-code generated. (([N],"Prelude.error: Map.deleteFindMax: can not return the maximal element of an empty map"),Berr_18131) (([N],"Prelude.error: Map.deleteFindMin: can not return the minimal element of an empty map"),Berr_18132) ... tmp1/main_code.c:5956:21: error: variable ‘_c7’ has initializer but incomplete type tmp1/main_code.c:5959:21: error: variable ‘_c6’ has initializer but incomplete type Compiler version: jhc 0.8.2 (0.8.2-55) (the most recent from darcs) Full compiler output is in attach. PS.: This code _does_ compile if I don't use -f no-global-optimize. However, I experiment with larger code, which is only compiled if I turn this optimization off. That is why I try to stick with this option. Thanks! Dmitry
On Mon, Jul 21, 2014 at 12:30 AM, Dmitry Kulagin
PS.: This code _does_ compile if I don't use -f no-global-optimize. However, I experiment with larger code, which is only compiled if I turn this optimization off. That is why I try to stick with this option.
Hi, Interesting. I have not tested with no-global-optimize in a while, it is possible there is an optimization I accidentally depended on happening in the GRIN backend that is disabled by it. Is the main reason you are doing it is for code size? I should investigate why the code blows up for that case too. John -- John Meacham - http://notanumber.net/
Hi John,
Yes, original code seems to be pretty large. It fails to compile before
code generation. I will try tonight to get the minimal example of the case.
If I am not mistaken 'global-optimize' does not play nicely with monad
transformers.
Thanks!
On Mon, Jul 21, 2014 at 1:17 PM, John Meacham
On Mon, Jul 21, 2014 at 12:30 AM, Dmitry Kulagin
wrote: PS.: This code _does_ compile if I don't use -f no-global-optimize.
However,
I experiment with larger code, which is only compiled if I turn this optimization off. That is why I try to stick with this option.
Hi, Interesting. I have not tested with no-global-optimize in a while, it is possible there is an optimization I accidentally depended on happening in the GRIN backend that is disabled by it.
Is the main reason you are doing it is for code size? I should investigate why the code blows up for that case too.
John
-- John Meacham - http://notanumber.net/
On Mon, Jul 21, 2014 at 2:41 AM, Dmitry Kulagin
Yes, original code seems to be pretty large. It fails to compile before code generation. I will try tonight to get the minimal example of the case. If I am not mistaken 'global-optimize' does not play nicely with monad transformers.
It is possible, there are some optimizatinos that can blow up in size in certain cases. Usually I can fix them once identified. John -- John Meacham - http://notanumber.net/
Hi John, Here is the case I was talking about (transformers + 'global-optimize'):
import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Error x :: ErrorT String IO () x = lift (print "hello") >> return () main = runErrorT x
This code fails to compile with 'global-optimize' enabled: Collected Compilation... -- TypeAnalyzeMethods -- BoxifyProgram -- Boxy WorkWrap Stack: transformProgram: Simplify-SuperSimplify after Boxy WorkWrap jhc: E.TypeCheck.getType: (EPi x20202872::Jhc.Prim.IO.State_ Jhc.Prim.IO.RealWorld::*::# (EAp Jhc@.Box.*::* (EVar x20202872::Jhc.Prim.IO.State_ Jhc.Prim.IO.RealWorld::*::#)),#,Jhc@.Box.*::*) My original code (which is still too big) fails with very similar error. However, if you change line:
x = lift (print "hello") >> return ()
to:
x = lift (print "hello")
then it is compiled successfully.
Thanks!
On Mon, Jul 21, 2014 at 4:26 PM, John Meacham
On Mon, Jul 21, 2014 at 2:41 AM, Dmitry Kulagin
wrote: Yes, original code seems to be pretty large. It fails to compile before
code
generation. I will try tonight to get the minimal example of the case. If I am not mistaken 'global-optimize' does not play nicely with monad transformers.
It is possible, there are some optimizatinos that can blow up in size in certain cases. Usually I can fix them once identified.
John
-- John Meacham - http://notanumber.net/
participants (2)
-
Dmitry Kulagin -
John Meacham