Description
We use presimplifier to support partial applications of Categorify.expression
hidden inside a wrapper function, like this:
preApply :: (a -> b) -> a `c` b
preApply = Categorify.expression
{-# INLINE preApply #-}
The presimplifier performs inlining, which inlines preApply
and exposes Categorify.expression
, whose applications are now fully saturated.
However, this approach doesn't work for slightly non-trivial cases, for example:
preApply :: (a -> b) -> a `c` b
preApply = if True then Categorify.expression else error "oops"
{-# INLINE preApply #-}
or direct partial application:
Categorify.expression . foo
Also, running the presimplifier has the disadvantage of unwanted inlining, e.g., sometimes fromIntegral
is inlined and becomes fromInteger . toInteger
, which may lead to categorification failures (e.g., the target category C.Cat does not support categorifying toInteger
).
We should use a different approach to support (at least some) partial applications. At least Categorify.expression . foo
seems easy to support.