From d0eb9a1edfb4233d557d954f46685f25382234d8 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Tue, 29 Apr 2025 20:37:06 +0200 Subject: Reorder TLEither to after TEither --- src/CHAD/Types/ToTan.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/CHAD/Types') diff --git a/src/CHAD/Types/ToTan.hs b/src/CHAD/Types/ToTan.hs index 87c01cb..8476712 100644 --- a/src/CHAD/Types/ToTan.hs +++ b/src/CHAD/Types/ToTan.hs @@ -28,6 +28,11 @@ toTan typ primal der = case typ of (Left p, Left d') -> Left (toTan t1 p d') (Right p, Right d') -> Right (toTan t2 p d') _ -> error "Primal and cotangent disagree on Either alternative" + STLEither t1 t2 -> case (primal, der) of + (_, Nothing) -> Nothing + (Just (Left p), Just (Left d)) -> Just (Left (toTan t1 p d)) + (Just (Right p), Just (Right d)) -> Just (Right (toTan t2 p d)) + _ -> error "Primal and cotangent disagree on LEither alternative" STMaybe t -> liftA2 (toTan t) primal der STArr _ t -> case der of Nothing -> arrayMap (zeroTan t) primal @@ -40,8 +45,3 @@ toTan typ primal der = case typ of STScal sty -> case sty of STI32 -> der ; STI64 -> der ; STF32 -> der ; STF64 -> der ; STBool -> der STAccum{} -> error "Accumulators not allowed in input program" - STLEither t1 t2 -> case (primal, der) of - (_, Nothing) -> Nothing - (Just (Left p), Just (Left d)) -> Just (Left (toTan t1 p d)) - (Just (Right p), Just (Right d)) -> Just (Right (toTan t2 p d)) - _ -> error "Primal and cotangent disagree on LEither alternative" -- cgit v1.2.3-70-g09d2