seq#: do we actually need it as a primitive?

Simon Peyton Jones simonpj at microsoft.com
Fri Jan 9 10:40:03 UTC 2015


I was wrong. See https://ghc.haskell.org/trac/ghc/ticket/5129#comment:17
which I have just added.

Simon

|  -----Original Message-----
|  From: Simon Peyton Jones
|  Sent: 08 January 2015 15:05
|  To: 'Roman Cheplyaka'; Edward Z. Yang; David Feuer
|  Cc: ghc-devs
|  Subject: RE: seq#: do we actually need it as a primitive?
|  
|  No (2) would not suffer from #5129.  Think of
|  
|    type IO a = State# -> (State#, a)
|    return x = \s -> (s, x)
|    (>>=) m k s = case m s of (s, r) -> k r s
|  
|  (it's a newtype actually, but this will do here).
|  
|  (2) says
|  
|  = \x -> (return $! x) >>= return
|  = \x. \s.  case return $! x s of (s1, r) -> return r s1 
|  = \x\s. x `seq` case (s,x) of (s1, r) -> return r s1
|  = \x\s. x `seq` (s,x)
|  
|  which is fine.


More information about the ghc-devs mailing list