[Haskell-beginners] type constructors

Jason Dusek jason.dusek at gmail.com
Sat Aug 1 14:43:10 EDT 2009


2009/08/01 Michael P Mossey <mpm at alumni.caltech.edu>:
> This is surprising to a conventional programmer. But does this
> naturally relate to other features of Haskell. Perhaps
> laziness? (I.e. data of type Foo doesn't always need a type b
> so it just doesn't have one until it needs one.)

  Laziness is a runtime thing; type constraints are compile
  time. So "...doesn't have one until it needs one." isn't right
  -- `t3` will *never* have a type for `b` in the program
  snippet above. If you add more code (create a different
  context) then you might constrain `b` more and lead to a more
  definite type. The type is always a static type, though --
  types don't get more specific as the program runs.

--
Jason Dusek


More information about the Beginners mailing list