From c526d939486320902edbe615fda165b8280620f9 Mon Sep 17 00:00:00 2001 From: Alexey Raga Date: Tue, 22 Nov 2022 22:50:43 +1100 Subject: [PATCH] Clean --- FSharp.Foldl/Fold.fs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FSharp.Foldl/Fold.fs b/FSharp.Foldl/Fold.fs index 616d299..e665625 100644 --- a/FSharp.Foldl/Fold.fs +++ b/FSharp.Foldl/Fold.fs @@ -11,7 +11,7 @@ module Fold = /// Creates a new fold let create (zero: 'x) (step: 'x -> 'a -> 'x) (extract: 'x -> 'b) = Fold( - (fun (x : obj) a -> box (step (x :?> 'x) a)), + (fun (x : obj) a -> (step (x :?> 'x) a) :> obj), box zero, (fun (x : obj) -> extract (x :?> 'x))) @@ -192,14 +192,14 @@ module Fold = /// Combine two folds into a fold over inputs for either of them. let choice (Fold(stepL, currentL, extractL)) (Fold(stepR, currenR, extractR)) : Fold, 'b1 * 'b2> = - let step x a = - let xL, xR = Unchecked.unbox x + let step (x : obj) a = + let xL, xR = x :?> obj * obj match a with | Choice1Of2 x -> box (stepL xL x, xR) | Choice2Of2 x -> box (xL, stepR xR x) - let extract x = - let xL, xR = Unchecked.unbox x + let extract (x : obj) = + let xL, xR = x :?> obj * obj (extractL xL), (extractR xR) Fold(step, (currentL, currenR), extract)