How to make a CAF not a CAF in Haskell?

前端 未结 7 1055
南旧
南旧 2020-12-01 05:23

How do I make a Constant Applicative Form into, well, not a Constant Applicative Form, to stop it being retained for the lifetime of the program?

I\'ve tried this ap

7条回答
  •  無奈伤痛
    2020-12-01 05:50

    You need to hide the fact that the rhs is a CAF from the optimizer. Something like this should do it.

    twoTrues :: () -> [[[Bool]]]
    twoTrues u = map (++ (True : repeat (false u))) . trueBlock <$> [1..]
    
    {-# NOINLINE false #-}
    false :: () -> Bool
    false _ = False
    

提交回复
热议问题