From 0a9e6dfc1accf9dc0254f0c720f633dab6e71f42 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 6 Apr 2025 17:07:22 +0200 Subject: Populate accumMap --- src/Analysis/Identity.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Analysis/Identity.hs') diff --git a/src/Analysis/Identity.hs b/src/Analysis/Identity.hs index 54f7cd2..186ab71 100644 --- a/src/Analysis/Identity.hs +++ b/src/Analysis/Identity.hs @@ -2,10 +2,12 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} module Analysis.Identity ( - ValId(..), identityAnalysis, identityAnalysis', + ValId(..), + validSplitEither, ) where import Data.Foldable (toList) @@ -31,6 +33,7 @@ data ValId t where VIArr :: Int -> Vec n Int -> ValId (TArr n t) VIScal :: Int -> ValId (TScal t) VIAccum :: Int -> ValId (TAccum t) +deriving instance Show (ValId t) instance PrettyX ValId where prettyX = \case @@ -46,6 +49,11 @@ instance PrettyX ValId where VIScal i -> show i VIAccum i -> 'C' : show i +validSplitEither :: ValId (TEither a b) -> (Maybe (ValId a), Maybe (ValId b)) +validSplitEither (VIEither (Left v)) = (Just v, Nothing) +validSplitEither (VIEither (Right v)) = (Nothing, Just v) +validSplitEither (VIEither' v1 v2) = (Just v1, Just v2) + -- | Symbolic partial evaluation. identityAnalysis :: SList STy env -> Expr x env t -> Expr ValId env t identityAnalysis env term = runIdGen 0 $ do -- cgit v1.2.3-70-g09d2