Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
0ecad646
Commit
0ecad646
authored
11 months ago
by
Thibault Martin
Browse files
Options
Downloads
Patches
Plain Diff
[Kernel] Add a module in lib/utils for Result monadic operators
parent
a9a3244f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libraries/utils/result.ml
+36
-0
36 additions, 0 deletions
src/libraries/utils/result.ml
src/libraries/utils/result.mli
+35
-0
35 additions, 0 deletions
src/libraries/utils/result.mli
with
71 additions
and
0 deletions
src/libraries/utils/result.ml
0 → 100644
+
36
−
0
View file @
0ecad646
(**************************************************************************)
(* *)
(* This file is part of Frama-C. *)
(* *)
(* Copyright (C) 2007-2024 *)
(* CEA (Commissariat à l'énergie atomique et aux énergies *)
(* alternatives) *)
(* *)
(* you can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 2.1. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 2.1 *)
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
(* *)
(**************************************************************************)
include
Stdlib
.
Result
let
zip
l
r
=
match
l
,
r
with
|
Ok
l
,
Ok
r
->
Ok
(
l
,
r
)
|
Error
e
,
_
->
Error
e
|
_
,
Error
e
->
Error
e
module
Operators
=
struct
let
(
let
*
)
r
f
=
bind
r
f
let
(
let
+
)
r
f
=
map
f
r
let
(
and
*
)
l
r
=
zip
l
r
let
(
and
+
)
l
r
=
zip
l
r
end
This diff is collapsed.
Click to expand it.
src/libraries/utils/result.mli
0 → 100644
+
35
−
0
View file @
0ecad646
(**************************************************************************)
(* *)
(* This file is part of Frama-C. *)
(* *)
(* Copyright (C) 2007-2024 *)
(* CEA (Commissariat à l'énergie atomique et aux énergies *)
(* alternatives) *)
(* *)
(* you can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 2.1. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 2.1 *)
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
(* *)
(**************************************************************************)
(* Adding let binding operators to the Result module. See
https://v2.ocaml.org/manual/bindingops.html for more information. *)
include
module
type
of
Stdlib
.
Result
val
zip
:
(
'
a
,
'
e
)
result
->
(
'
b
,
'
e
)
result
->
(
'
a
*
'
b
,
'
e
)
result
module
Operators
:
sig
val
(
let
*
)
:
(
'
a
,
'
e
)
result
->
(
'
a
->
(
'
b
,
'
e
)
result
)
->
(
'
b
,
'
e
)
result
val
(
let
+
)
:
(
'
a
,
'
e
)
result
->
(
'
a
->
'
b
)
->
(
'
b
,
'
e
)
result
val
(
and
*
)
:
(
'
a
,
'
e
)
result
->
(
'
b
,
'
e
)
result
->
(
'
a
*
'
b
,
'
e
)
result
val
(
and
+
)
:
(
'
a
,
'
e
)
result
->
(
'
b
,
'
e
)
result
->
(
'
a
*
'
b
,
'
e
)
result
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment