Sha256: 6a1de89c233fc5911133b952be4c14078d951624f05dac117f9b1f3071f547f4
Contents?: true
Size: 727 Bytes
Versions: 3
Compression:
Stored size: 727 Bytes
Contents
require "spec_helper" some = Some("test") upcase = lambda { |v| Some(v.upcase) } empty = lambda { |v| None } describe "Option" do describe "when applying the 3 monadic axioms" do describe "left identity" do it "obeys (return x) >>= f == f x" do some.flat_map(&upcase).must_equal(upcase.call(some.get)) end end describe "right identity" do it "obeys m >>= return == m" do some.flat_map { |v| Some(v) }.must_equal(some) end end describe "composition" do it "obeys (m >>= f) >>= g == m >>= (\\x -> f x >>= g)" do some.flat_map(&upcase).flat_map(&empty). must_equal(some.flat_map(&empty).flat_map(&upcase)) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
option-1.0.0 | spec/acceptance_spec.rb |
option-0.6.0 | spec/acceptance_spec.rb |
option-0.5.0 | spec/acceptance_spec.rb |