Copyright | (C) 2012-2016 University of Twente 2016-2017 Myrtle Software Ltd 2017-2018 Google Inc. 2021-2022 QBayLogic B.V. |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
Safe Haskell | None |
Language | Haskell2010 |
The X-optimization transformation.
Synopsis
- xOptimize :: HasCallStack => NormRewrite
Documentation
xOptimize :: HasCallStack => NormRewrite Source #
Remove all undefined alternatives from case expressions, replacing them
with the value of another defined alternative. If there is one defined
alternative, the entire expression is replaced with that alternative. If
there are no defined alternatives, the entire expression is replaced with
a call to errorX
.
e.g. It converts
case x of D1 a -> f a D2 -> undefined D3 -> undefined
to
let subj = x a = case subj of D1 a -> field0 in f a
where fieldN is an internal variable referring to the nth argument of a data constructor.