aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2017-10-31 15:59:38 +0100
committerSébastien Dailly <sebastien@chimrod.com>2017-10-31 16:02:42 +0100
commitd8ed0babfa1c03c8f1968443a465972bb3bf460c (patch)
tree60f788e3e8733a6d3606e801bc21a24e419e070e
parent01d7f77f65c3a2b83978b1f00c87b54f00647816 (diff)
Merged Evaluator types with ScTypes
-rwxr-xr-xevaluator.ml11
-rwxr-xr-xexpression.ml4
-rwxr-xr-xsheet.ml7
3 files changed, 8 insertions, 14 deletions
diff --git a/evaluator.ml b/evaluator.ml
index c17a397..f2a49d9 100755
--- a/evaluator.ml
+++ b/evaluator.ml
@@ -280,8 +280,8 @@ let repr mapper value = begin
| ScTypes.Refs.Array1 l ->
(* Guess the list type from it's first defined element *)
let Result r = extract_value (Tools.List.find_map (fun x -> x) l) in
- let format_of = Data.format_of_value r in
- let type_of = Data.type_of_value r in
+ let format_of = Data.format_of_value r
+ and type_of = Data.type_of_value r in
(* Build the list with all the elements *)
let elems, format = List.fold_left (add_elem type_of) ([], format_of) l in
Result (Data.List (format, elems))
@@ -289,13 +289,13 @@ let repr mapper value = begin
(* Guess the list type from it's first defined element *)
let Result r = extract_value (Tools.List.find_map2 (fun x -> x) l) in
- let format_of = Data.format_of_value r in
- let type_of = Data.type_of_value r in
+ let format_of = Data.format_of_value r
+ and type_of = Data.type_of_value r in
(* Build the list with all the elements *)
let elems, format = List.fold_left (fun (result, format_of) elems ->
let elems, format = List.fold_left (add_elem type_of) ([], format_of) elems in
elems::result, (Data.most_generic_format format_of format)
- ) ([], format_of) l in
+ ) ([], format_of) l in
Result (Data.Matrix (format, elems))
end
@@ -308,7 +308,6 @@ let repr mapper value = begin
end
in
let Result r = (extract value) in
-
begin match r with
| Data.Bool b -> ScTypes.Result (ScTypes.Bool b)
| Data.Num (format, n) -> ScTypes.Result (ScTypes.Num (format, n))
diff --git a/expression.ml b/expression.ml
index c61131e..31b6369 100755
--- a/expression.ml
+++ b/expression.ml
@@ -35,8 +35,8 @@ let load content = begin
with Not_found -> content in
try
let ScTypes.Result r =
- Lexing.from_string content'
- |> ExpressionParser.content ExpressionLexer.read in
+ ExpressionParser.content ExpressionLexer.read
+ @@ Lexing.from_string content' in
Basic r
with _ -> Basic (ScTypes.Str (UTF8.from_utf8string content'))
)
diff --git a/sheet.ml b/sheet.ml
index 241039e..67b1ee1 100755
--- a/sheet.ml
+++ b/sheet.ml
@@ -50,13 +50,8 @@ module Raw = struct
*)
let get_ref from t ref : ScTypes.result option ScTypes.Refs.range = begin
- let extract_values = begin function
- | ScTypes.Error e -> raise e
- | v -> v
- end in
-
ScTypes.Refs.collect ref
- |> ScTypes.Refs.map (fun coord -> Option.map extract_values (get_value coord t))
+ |> ScTypes.Refs.map (fun coord -> get_value coord t)
end