dry-monads
dry-monads copied to clipboard
Pattern matching in class method requires `include` instead of `extend`
Describe the bug
When pattern matching inside a class method an include Dry::Monads[:maybe]
is needed, the extend Dry::Monads[:maybe]
is not enough and causes a crash.
To Reproduce
Simple script:
class Foo
include Dry::Monads[:maybe]
extend Dry::Monads[:maybe]
def self.foo
case Some(4)
in Some(a)
puts a
in None()
puts 'none'
end
end
end
Removing any include
or extend
will cause this script to fail:
- Removing
extend
causesSome(4)
to raiseNoMethodError: undefined method
Some' for Foo:Class` (makes sense) - Removing
extend
causesSome(a)
to raiseNameError: uninitialized constant Foo::Some
(?)
Expected behavior
Ideally I'd like to only have to extend Dry::Monads[:maybe]
for a class method, not both.
My environment
- Affects my production application: NO
- Ruby version: 3.1.4p223
- OS: Docker (Alpine)