From 797e48d4e5a73615204001db52b8479f2572ceaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Facundo=20Dom=C3=ADnguez?= Date: Tue, 19 Dec 2023 21:48:51 +0000 Subject: [PATCH] Remove bare calls to unsafeCoerce --- inline-r/src/Language/R/HExp.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/inline-r/src/Language/R/HExp.hs b/inline-r/src/Language/R/HExp.hs index 91bcc9a3..028b402a 100644 --- a/inline-r/src/Language/R/HExp.hs +++ b/inline-r/src/Language/R/HExp.hs @@ -336,12 +336,12 @@ peekHExp s = do <*> (coerceAnySome <$> R.cdr su) R.Special -> coerce $ return Special R.Builtin -> coerce $ return Builtin - R.Char -> unsafeCoerce $ Char (Vector.unsafeFromSEXP su) - R.Logical -> unsafeCoerce $ Logical (Vector.unsafeFromSEXP su) - R.Int -> unsafeCoerce $ Int (Vector.unsafeFromSEXP su) - R.Real -> unsafeCoerce $ Real (Vector.unsafeFromSEXP su) - R.Complex -> unsafeCoerce $ Complex (Vector.unsafeFromSEXP su) - R.String -> unsafeCoerce $ String (Vector.unsafeFromSEXP su) + R.Char -> coerce $ return $ Char (Vector.unsafeFromSEXP su) + R.Logical -> coerce $ return $ Logical (Vector.unsafeFromSEXP su) + R.Int -> coerce $ return $ Int (Vector.unsafeFromSEXP su) + R.Real -> coerce $ return $ Real (Vector.unsafeFromSEXP su) + R.Complex -> coerce $ return $ Complex (Vector.unsafeFromSEXP su) + R.String -> coerce $ return $ String (Vector.unsafeFromSEXP su) R.DotDotDot -> unimplemented $ "peekHExp: " ++ show (R.typeOf s) R.Vector -> coerce $ Vector <$> (fromIntegral <$> R.trueLength (coerceAny su)) @@ -363,7 +363,7 @@ peekHExp s = do peekElemOff (castPtr $ R.unsafeSEXPToVectorPtr s) 2) <*> (coerceAny <$> R.sexp <$> peekElemOff (castPtr $ R.unsafeSEXPToVectorPtr s) 3) - R.Raw -> unsafeCoerce $ Raw (Vector.unsafeFromSEXP su) + R.Raw -> coerce $ return $ Raw (Vector.unsafeFromSEXP su) R.S4 -> coerce $ S4 <$> (coerceAnySome <$> R.tag su) _ -> unimplemented $ "peekHExp: " ++ show (R.typeOf s)