hello, John Meacham wrote:
I have some questions about the implementation of haskell...
what does it mean to apply 'seq' to a function? how does one place an abstraction in WHNF? it seems that the ONLY thing one can do to a function is apply it to some argument so does seq need to apply the function to a dummy argument or something? it depends on what you mean by "mean" here :-)
the thing is that not all values of a function type are abstractions... e.g. notAbstraction :: a -> b notAbstraction = notAbstraction is the definition of something of a function type that is not an abstraction. in normal circumstances you couldn't tell this apart from bot x = undefined because the only way to observe functions is to apply them, and both of those behave the same when applied. however in haskell we have "seq", which is an efficiency hack, that can tell those two apart, as seq notAbstraction 1 does not terminate while seq bot 1 terminates with result 1 so operationally when you "seq" something the interpreter starts evaluating it until WHNF is reached, updates the closure appropriately, and returns the second argument of seq. if everything terminated, this would be completely transparent, but since some expresions don't have a normal form things get a little funny.
similarly, how does seq work on polymorphic types? without knowing what the unboxed representation is for a type, it seems tricky to know how to place it in WHNF... well, one doesn't need type information to evaluate haskell programs, so i don't think there is a problem there.
hope this helped, and sorry for the long email bye iavor -- ================================================== | Iavor S. Diatchki, Ph.D. student | | Department of Computer Science and Engineering | | School of OGI at OHSU | | http://www.cse.ogi.edu/~diatchki | ==================================================