clash-lib-1.6.6: Clash: a functional hardware description language - As a library
Copyright(C) 2012-2016 University of Twente
2016-2017 Myrtle Software Ltd
2017-2018 Google Inc.
2021-2022 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Normalize.Transformations.XOptimize

Description

The X-optimization transformation.

Synopsis

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.