Skip to content
  • Simon Peyton Jones's avatar
    Float coercions out of lets · b041525c
    Simon Peyton Jones authored
    Note [Float coercions]
    ~~~~~~~~~~~~~~~~~~~~~~
    When we find the binding
    	x = e `cast` co
    we'd like to transform it to
    	x' = e
    	x = x `cast` co		-- A trivial binding
    There's a chance that e will be a constructor application or function, or something
    like that, so moving the coerion to the usage site may well cancel the coersions
    and lead to further optimisation.  Example:
    
         data family T a :: *
         data instance T Int = T Int
    
         foo :: Int -> Int -> Int
         foo m n = ...
            where
              x = T m
              go 0 = 0
              go n = case x of { T m -> go (n-m) }
    		-- This case should optimise
    
    b041525c