Skip to content

Instantly share code, notes, and snippets.

@flash-gordon
Created September 7, 2019 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flash-gordon/eaaf70d120eac47fc3e07831fdaf32e3 to your computer and use it in GitHub Desktop.
Save flash-gordon/eaaf70d120eac47fc3e07831fdaf32e3 to your computer and use it in GitHub Desktop.
module Prelude
class Monadic
include Dry::Monads[:maybe, :result, :do]
def call(id, item_id)
users = [:user]
items = []
user, item = yield Maybe(users[id]).and(Maybe(items[item_id])).to_result {
'User not found'
}
Success(user: user, item: item)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment