Case expressions in STG

Tom Ellis tom-lists-ghc-devs at jaguarpaw.co.uk
Thu Jun 19 07:27:02 UTC 2014


On Wed, Jun 18, 2014 at 07:40:26PM -0400, William Knop wrote:
> f = \x -> x
> g = \x -> (x,1)
> h = \x -> fst (g x)
> i = \x -> case f of
>   f -> True
>   _ -> False
> 
> i f => True
> i h => ?
> 
> If g isn't inlined into h and fst optimized out, wouldn't the head normal
> form of f and h be different, and the comparison fail even though it
> shouldn't?  Or should it?  I've taken function equality to be "f and g are
> equal iff f x == g x, for all x."

You mean 'i = \x -> case x of' ...

Anyway, I'm not suggesting using case to *compare* functions, simply force
their thunk before proceeding with a single default alternative.

Tom


More information about the ghc-devs mailing list