Skip to content

Commit

Permalink
Remove return types removing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-lairan committed Jan 23, 2020
1 parent 6d9805a commit 5b77aa0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/monads/either.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ module Monads
Right.new(value)
end

abstract def value_or(element : U) : T | U forall U
abstract def value_or(element : U) forall U
abstract def or(monad : Either)
abstract def <=>(other : Right)
abstract def <=>(other : Left)
abstract def map_or(default : U, lambda : T -> U) : U forall U
abstract def map_or(default : U, lambda : T -> U) forall U
end

struct Right(T) < Either(Nil, T)
Expand Down Expand Up @@ -71,7 +71,7 @@ module Monads
lambda.call(self.value!)
end

def map_or(default : U, lambda : T -> U) : U forall U
def map_or(default : U, lambda : T -> U) forall U
lambda.call(value!)
end
end
Expand Down Expand Up @@ -101,7 +101,7 @@ module Monads
self
end

def map_or(default : U, lambda : _ -> _) : U forall U
def map_or(default : U, lambda : _ -> _) forall U
default
end
end
Expand Down Expand Up @@ -152,7 +152,7 @@ module Monads
self
end

def map_or(default : U, lambda : _ -> _) : U forall U
def map_or(default : U, lambda : _ -> _) forall U
default
end
end
Expand Down Expand Up @@ -207,7 +207,7 @@ module Monads
self
end

def map_or(default : U, lambda : _ -> _) : U forall U
def map_or(default : U, lambda : _ -> _) forall U
default
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/monads/functor.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Monads
abstract struct Functor(T)
abstract def fmap(lambda : T -> U) : Functor(U)
abstract def fmap(lambda : T -> U)
end
end
18 changes: 9 additions & 9 deletions src/monads/maybe.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Monads
!just?
end

def self.return(v : T) : Just(T)
def self.return(v : T)
Just.new(v)
end

Expand All @@ -23,9 +23,9 @@ module Monads
abstract def <=>(other : Nothing)
abstract def <=>(other : Just)
abstract def to_s
abstract def or(default : Maybe) : Maybe
abstract def value_or(default : U) : T | U forall U
abstract def map_or(default : U, lambda : T -> U) : U forall U
abstract def or(default : Maybe)
abstract def value_or(default : U) forall U
abstract def map_or(default : U, lambda : T -> U) forall U
end

struct Just(T) < Maybe(T)
Expand All @@ -36,7 +36,7 @@ module Monads
@data
end

def fmap(lambda : T -> U) : Just(U) forall U
def fmap(lambda : T -> U) forall U
Just.new(lambda.call(@data))
end

Expand All @@ -56,7 +56,7 @@ module Monads
1
end

def bind(lambda : T -> Maybe(_)) : Maybe
def bind(lambda : T -> Maybe(_))
lambda.call(value!)
end

Expand All @@ -68,7 +68,7 @@ module Monads
Just.new(value!)
end

def or(lambda : -> _) : Maybe(T)
def or(lambda : -> _)
Just.new(value!)
end

Expand All @@ -78,7 +78,7 @@ module Monads
end

struct Nothing(T) < Maybe(T)
def fmap(lambda : _ -> U) : Nothing forall U
def fmap(lambda : _ -> U) forall U
Nothing(U).new
end

Expand All @@ -98,7 +98,7 @@ module Monads
-1
end

def bind(lambda : _ -> Maybe(U)) : Maybe forall U
def bind(lambda : _ -> Maybe(U)) forall U
Nothing(U).new
end

Expand Down
2 changes: 1 addition & 1 deletion src/monads/monad.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Monads
raise NotImplementedError.new("implement `#{Monad(T)}::return` method")
end

abstract def bind(lambda : T -> Monad(U)) : Monad(U) forall U
abstract def bind(lambda : T -> Monad(U)) forall U

def |(other : _ -> Monad(U)) forall U
self.bind(other)
Expand Down

0 comments on commit 5b77aa0

Please sign in to comment.