clash-lib-1.8.1: Clash: a functional hardware description language - As a library
Safe HaskellNone
LanguageHaskell2010

Clash.Normalize.Transformations.Cast

Synopsis

Documentation

argCastSpec :: HasCallStack => NormRewrite Source #

Push cast over an argument to a function into that function

This is done by specializing on the casted argument. Example: y = f (cast a) where f x = g x transforms to: y = f' a where f' x' = (\x -> g x) (cast x')

The reason d'etre for this transformation is that we hope to end up with and expression where two casts are "back-to-back" after which we can eliminate them in eliminateCastCast.

caseCast :: HasCallStack => NormRewrite Source #

Push a cast over a case into it's alternatives.

elimCastCast :: HasCallStack => NormRewrite Source #

Eliminate two back to back casts where the type going in and coming out are the same

  (cast :: b -> a) $ (cast :: a -> b) x   ==> x

letCast :: HasCallStack => NormRewrite Source #

Push a cast over a Let into it's body

splitCastWork :: HasCallStack => NormRewrite Source #

Make a cast work-free by splitting the work of to a separate binding

let x = cast (f a b)
==>
let x  = cast x'
    x' = f a b