[jhc] Typechecker hiccup?

John Meacham john at repetae.net
Tue Jul 17 18:32:44 EDT 2007


On Tue, Jul 17, 2007 at 10:20:01PM +0000, Samuel J. J. Bronson wrote:
> I just tried to compile this program (based on figure one in "The GRIN Project:
> A Highly Optimising Back End for Lazy Functional Languages"):
> 
> 
> {-# OPTIONS_JHC -N -fffi #-}
> 
> import Jhc.Basics
> import Jhc.Int
> import Jhc.Num
> import Jhc.Order
> 
> default (Integer, Double)
> 
> main = sum (upto 1 10)
> 
> upto m n | m > n     = []
>          | otherwise = m : upto (m+1) n
> 
> sum []     = 0
> sum (x:xs) = x + sum xs
> 
> 
> And I got a stupid error about a missing "put" method for IORef. It seems that
> the typechecker isn't getting rid of all the MetaVars in this program...

hmm.. main not being an actual IO action doesn't behave too well with
overloading. (I really should make it just fail without an explicit
option saying you want to evaluate an expression)

what if you change main to

main = print (sum (upto 1 10))

it would be nice if main were specialized to IO foo also. like

main = return ()

will fail because it doesn't know to unify it with 'IO a'. though, I
wouldn't want to do this in the typechecker, but rather when the entry
point is created after E conversion.

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the jhc mailing list