Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/ControlMacros.carp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ Example:
(defmacro -> [:rest forms]
(thread-first-internal forms))

(doc ?->
("threads the value contained in a maybe through the following " false)
"forms iff, the Maybe is a Just."
""
"Returns Nothing if the Maybe is Maybe.Nothing.")
(defmacro ?-> [maybe :rest forms]
(list 'match maybe
(list 'Maybe.Just 'v) (list 'Maybe.Just (thread-first-internal (cons 'v forms)))
'_ (list 'Maybe.Nothing)))

(doc /->
("threads the value contained in a Result through the following" false)
"forms iff, the Result is a Success"
""
"Returns the erorr if the Result is Result.Error.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo here: erorr.

(defmacro /-> [result :rest forms]
(list 'match result
(list 'Result.Success 'v) (list 'Result.Success (thread-first-internal (cons 'v forms)))
'y 'y))

(doc --> "threads the first form through the following ones, making it the last
argument.

Expand Down