docs icon indicating copy to clipboard operation
docs copied to clipboard

Document some best practices

Open pbiggar opened this issue 4 years ago • 2 comments

For example, handling inputs/errors at the start of the handler:

match String::toUUID param
| None -> Http::badRequest "param was not a uuid"
| Some id ->
    ... // rest of handler

pbiggar avatar Apr 26 '22 17:04 pbiggar

Is there a pattern to avoid "match hell"?

match String::toUUID param_one
| None -> Http::badRequest "param one was not a uuid"
| Some id ->
    ... // rest of handler
    match String::toUUID param_two
    | None -> Http::badRequest "param two was not a uuid"
    | Some id ->
    ... // rest of handler
    ... // etc
match MyCustonTypeSet:: [valA, valB, valC] is [id, string, int]
    | None -> Http::badRequest "Error I"
    | Some -> Http::badRequest "Error II"
    | All -> 
         ... // rest of handler

sanderjson avatar Apr 26 '22 17:04 sanderjson

Is there a pattern to avoid "match hell"?

When we add tuples there will be, but there isn't right now.

pbiggar avatar Apr 26 '22 18:04 pbiggar