You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we consider the staged power function, we observe a fundamental difficulty of writing programs polymorphic in their stage.
staticPower_s :: Syntax r => Int -> r Int -> r Int
staticPower_s n k = if n == 0
then pure 1
else ([ k * (staticPower_s (n - 1) k) ])
Notice that the conditional and scrutinee are both statically evaluated using the non-overloaded versions of if and ap.
However, we could also use the overloaded variants and then instantiate them to Identity. The hope being that this would provide a more uniform treatment.
staticPower_s :: Syntax r => Int -> r Int -> r Int
staticPower_s n k = runIdentity $ _if (pure (==) <*> pure n <*> pure 0)
(pure (pure 1)
(pure ([ k * (staticPower_s (n - 1) k) ]))
The type of the _if :: Identity Bool -> Identity (r Int) -> Identity (r Int) -> Identity (r Int)
The text was updated successfully, but these errors were encountered:
If we consider the staged power function, we observe a fundamental difficulty of writing programs polymorphic in their stage.
Notice that the conditional and scrutinee are both statically evaluated using the non-overloaded versions of
if
andap
.However, we could also use the overloaded variants and then instantiate them to
Identity
. The hope being that this would provide a more uniform treatment.The type of the
_if :: Identity Bool -> Identity (r Int) -> Identity (r Int) -> Identity (r Int)
The text was updated successfully, but these errors were encountered: