Sha256: eb3dad05525a63bd9afd2b52d29229eb6e16c0a48f76951b071d1f7a8f265de4
Contents?: true
Size: 928 Bytes
Versions: 6
Compression:
Stored size: 928 Bytes
Contents
require "spec_helper" include Ribimaybe::Maybe describe "Functor Instance" do let(:id) do ->(x){ x } end let(:f) do ->(x){ ->(y) { x } }.(SecureRandom.base64(1000)).extend(Composable) end let(:g) do ->(x){ ->(y) { x } }.(SecureRandom.base64(1000)).extend(Composable) end # fmap id = id describe "identity" do context "when i have nothing" do it do expect(Nothing.map(&id)).to eq(Nothing) end end context "when i have just :x" do it do expect(Just(:x).map(&id)).to eq(Just(:x)) end end end # fmap (f . g) = fmap f . fmap g describe "composition" do context "when i have nothing" do it do expect(Nothing.map(&(f * g))).to eq(Nothing.map(&g).map(&f)) end end context "when i have just :x" do it do expect(Just(:x).map(&(f * g))).to eq(Just(:x).map(&g).map(&f)) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems