[Haskell-cafe] Throwback of inferred types

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sun Jan 20 17:06:04 EST 2008

On Sun, 2008-01-20 at 21:02 +0000, Jon Harrop wrote:
> On Sunday 20 January 2008 21:02:04 gwern0 at gmail.com wrote:
> > On 2008.01.19 19:11:13 +0100, Peter Verswyvelen <bf3 at telenet.be> scribbled 
> 1.4K characters:
> > > I would find it most useful to get type inference information on the fly,
> > > even when not all of the code compiles correctly yet.
> >
> > Does that make sense? If the code doesn't compile, then how could any
> > type-inference be trustable?
> Note that this functionality continues to be widely used in other functional 
> languages, e.g. SML, OCaml, F#. I can't think why Haskell would be any 
> different.

Really? That's pretty cool. How does it work?

Does it use Achim's suggestion of replacing expressions which fail to
type with new type vars and at runtime an error message with the type
error? Or do they use something more hacky that we could also implement


foo = 3

bar = 'c'

baz = foo + bar

So we infer:

foo :: Int
foo = 3

bar :: Char
bar = 'c'

baz :: a
baz = error "No instance for (Num Char)
             arising from a use of `+' at foo.hs:5:6-14"

That would be cool. Then I can run the bits of my program that still
work. It'd make the editor/interpreter session rather more "live". 

How close do the IDEs/emacs-modes for SML, OCaml, F# come to that? What
are we missing out on? :-)


More information about the Haskell-Cafe mailing list