package hack_parallel
Parallel and shared memory library
Install
Dune Dependency
Authors
Maintainers
Sources
1.0.1.tar.gz
md5=ba7c72bc207e326b72e294fc76f6ad2c
sha512=5020d47f97bea2f88e2a40411894d03232a7f2282606926c93c7d4c96d72e94a966be852897a9b16f7e0893ba376512045abb9d93020a7c03c3def4f3d918f8e
doc/hack_parallel.hack_core/Hack_result/index.html
Module Hack_result
Source
Result
is often used to handle error messages.
'a
is a function's expected return type, and 'b
is often an error message string.
let ric_of_ticker = function
| "IBM" -> Ok "IBM.N"
| "MSFT" -> Ok "MSFT.OQ"
| "AA" -> Ok "AA.N"
| "CSCO" -> Ok "CSCO.OQ"
| _ as ticker -> Error (sprintf "can't find ric of %s" ticker)
The return type of ric_of_ticker could be string option
, but (string, string) Result.t
gives more control over the error message.
e.g. failf "Couldn't find bloogle %s" (Bloogle.to_string b)
ok_fst
is useful with List.partition_map
. Continuing the above example:
let rics, errors = List.partition_map ~f:Result.ok_fst
(List.map ~f:ric_of_ticker ["AA"; "F"; "CSCO"; "AAPL"])
ok_exn t
returns x
if t = Ok x
, and raises exn
if t = Error exn
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>