Skip to content

Releases: alex-lairan/monads

v1.2.2

17 Jan 13:36

Choose a tag to compare

What's Changed

New Features

  • Maybe value_or block support: You can now use value_or { default } with Maybe monads
# Just returns its value
Monads::Just.new(42).value_or { 0 }  # => 42

# Nothing calls the block
Monads::Nothing(Int32).new.value_or { 0 }  # => 0

Full Changelog: v1.2.1...v1.2.2

v1.2.1

17 Jan 13:22

Choose a tag to compare

What's Changed

Improvements

  • Updated CI: Now testing against Crystal 1.15, 1.16, 1.17, 1.18, 1.19 + nightly
  • Updated ameba to 1.6.0 for better linting

Bug Fixes

  • Fixed typo ohterother in Maybe monad
  • Fixed unused argument warning in Either fold
  • Fixed not_nil! usage in Try monad
  • Fixed operator parameter naming (rhsother)

Documentation

  • Added fold method examples to README

Full Changelog: v1.2.0...v1.2.1

v1.2.0

17 Jan 11:51

Choose a tag to compare

What's New

New Features

  • fold method for Either: Pattern match on Right/Left/LeftException with two functions
  • fold method for Maybe: Pattern match on Just/Nothing with two functions
  • Block version of fold that raises on error cases

Bug Fixes

  • Fixed parameter name warnings across Either, Maybe, and List modules

Example Usage

# Either fold
result = Monads::Right(String, Int32).new(42).fold(
  ->(x : Int32) { "success: #{x}" },
  ->(e : String) { "error: #{e}" }
)
# => "success: 42"

# Maybe fold
value = Monads::Just.new(42).fold(
  ->(x : Int32) { "value: #{x}" },
  ->{ "nothing" }
)
# => "value: 42"

Full Changelog: v1.1.0...v1.2.0

v1.1.0 - Doubly parameterized Either

17 Jan 11:51

Choose a tag to compare

What's Changed

Make Either doubly parameterized for proper type unification.

Breaking Changes

  • Right(T) is now Right(E, T) inheriting from Either(E, T)
  • Left(E) is now Left(E, T) inheriting from Either(E, T)
  • LeftException is now LeftException(T) inheriting from Either(Exception, T)

Why?

This enables functions to return Either(E, T) where both Right and Left branches can unify to the same type:

def divide(a : Int32, b : Int32) : Either(Exception, Int32)
  if b == 0
    LeftException(Int32).new(DivisionByZeroError.new)
  else
    Right(Exception, Int32).new(a // b)
  end
end

Full Changelog: v1.0.0...v1.1.0

Stable

29 Mar 17:42
47c0c91

Choose a tag to compare

Stable version compatible with Crystal 1.0

Allow Block alongside Proc

15 Apr 17:58

Choose a tag to compare

Crystal 0.32.1 Compatibility

23 Jan 21:40

Choose a tag to compare

v0.6.0

Remove return types removing warnings

Crystal 0.29.0 Compatibility

12 Jul 18:41
a1b145d

Choose a tag to compare

#53 Make Monads compatible with Crystal 0.29.0

Add Try and Task

22 May 06:53
9a8afe9

Choose a tag to compare

New Try monad

=> #47

New Task monad

=> #45

Improve List monad

Initialize list with [](*args)
=> #34

Add List#reverse
=> #41

Add Comparable
=> https://github.com/alex-lairan/monads/pull/35/files

Add List#next and Indexable
=> #36
=> #42

Add #sort and #sort_by
=> #43
=> #44

Add #permutations, #subsequences and #join
=> #40

Add #last and #empty
=> #39

Add #to_s and #inspect
=> #38

Misc

Add #| (bind) and #>> (sequence) operator
=> #46

Update readme
=> #48
=> #50 Thanks @amelie-certin

Functional paradigms naming and behaviors

06 May 07:32

Choose a tag to compare

Implement Comparable(T) to Maybe monad and remove redundant #== method.

=> #5
=> #14

Multiples methods reimplementations.
Create Monad(T) and Fonctor(T)

=> #6
=> #16
=> #19
=> #20
=> #23
=> #24
=> #27
=> #28
=> #29
=> #30
=> #31
=> #32

Use structs instead of classes

=> #9
=> #22

Rename Result to Either

=> #10

Add #inspect for Maybe monads and Either

=> #11
=> #12
=> #13

Add a CI

=> #15
=> #17
=> #18

Fix Block type introspection by using a proc

=> #25