aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Expr/SharingRecovery/Internal.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-10-03 23:06:05 +0200
committerTom Smeding <tom@tomsmeding.com>2025-10-03 23:06:05 +0200
commit1931c68ae2b9add3235b729b194ef4b4ce6938af (patch)
tree7c0749c70cf09e3341429c5dd3c528c4e45c0b08 /src/Data/Expr/SharingRecovery/Internal.hs
parent8bcf09ed30595c7ffcdc41211a53046fefa35a44 (diff)
Add typeOf functionsHEADmaster
Diffstat (limited to 'src/Data/Expr/SharingRecovery/Internal.hs')
-rw-r--r--src/Data/Expr/SharingRecovery/Internal.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Data/Expr/SharingRecovery/Internal.hs b/src/Data/Expr/SharingRecovery/Internal.hs
index 9f7ca7d..adf655d 100644
--- a/src/Data/Expr/SharingRecovery/Internal.hs
+++ b/src/Data/Expr/SharingRecovery/Internal.hs
@@ -125,6 +125,11 @@ instance TestEquality (NameFor typ f) where
unsafeCoerceRefl :: a :~: b -- restricted version of unsafeCoerce that only allows punting proofs
unsafeCoerceRefl = unsafeCoerce Refl
+typeOfPHOAS :: PHOASExpr typ v f t -> typ t
+typeOfPHOAS (PHOASOp ty _) = ty
+typeOfPHOAS (PHOASLam ty _ _) = ty
+typeOfPHOAS (PHOASVar ty _) = ty
+
-- | Pruned expression.
--
-- Note that variables do not, and will never, have a name: we don't bother
@@ -408,6 +413,12 @@ data BExpr typ env f t where
deriving instance (forall a. Show (typ a), forall a r. (forall b. Show (r b)) => Show (f r a))
=> Show (BExpr typ env f t)
+typeOfBExpr :: BExpr typ v f t -> typ t
+typeOfBExpr (BOp ty _) = ty
+typeOfBExpr (BLam ty _ _) = ty
+typeOfBExpr (BLet _ _ e) = typeOfBExpr e
+typeOfBExpr (BVar ty _) = ty
+
prettyBExpr :: (forall m env' a. Monad m => (forall b. Int -> BExpr typ env' f b -> m ShowS)
-> Int -> f (BExpr typ env' f) a -> m ShowS)
-> BExpr typ '[] f t -> String