[Haskell-cafe] Where's the case? or The difference between simpl and prep

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Mar 15 00:21:16 CET 2013


On Thu, Mar 14, 2013 at 10:43:14PM +0000, Simon Peyton-Jones wrote:
> |  -----Original Message-----
> |  From: Tom Ellis
> |  The -ddump-simpl output below doesn't contain a case corresponding to the
> |  seq in sum', but the -ddump-prep does.  Isn't the output from simpl the
> |  input to prep?  If so, where does the case reappear from?  If not, how are
> |  simpl and prep related?
> |  
> |  It seems to have something to do with "Str=DmdType SS" but I don't
> |  understand.  This seems to come from the IdInfo on the Id which is the
> |  binder "Test.sum'" but [1] says that this information is optional so it
> |  seems strange that such crucial information would be encoded there.
>
> Check out 
> http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/HscMain
> and the notes at the top of
> 	 http://darcs.haskell.org/ghc/compiler/coreSyn/CorePrep.lhs

Thanks Simon.  That's lovely code and easy to read.

I see that the decision between let and case is made based on the
idDemandInfo which specifies whether a value is wanted strictly or not.

I presume that the explicit case is removed in the Simpl phase because it is
easier for optimisations to work on the Demand value than explicit case
statements.

Tom



More information about the Haskell-Cafe mailing list