Skip to content

bossiernesto/functional_rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Functional Ruby

Ruby

Another repo for showing some functional properties for the Ruby language

Features

Taken from Functors, Applicatives, And Monads In Pictures from Haskell

Maybe

Understands functor map function

just = Maybe 2
Just(42).map { |x| x * x } 
Just(1764)
Nothing.map {|x| x * x}
Nothing

Also bind

maybe_m >>= proc {|i| i + 4}
5

And applicatives

Just do |x, y|
      x ** y
    end.apply(pure(421)).apply(pure(2))
Just(177241)
proc {|x,y| x*y} % Just(5) & Just(3) 
Just(15)

Even lifting

pure(5).lift_a2 proc {|x,y| x*y}, pure(3)
Just(15)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages