Skip to content

Commit

Permalink
Remove public access of value
Browse files Browse the repository at this point in the history
  • Loading branch information
superfunc committed Aug 13, 2017
1 parent 91d93b4 commit 8eaf77b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ <h1 class="title">Module maybe</h1>
<li><a class="reference" href="#Maybe"
title="Maybe*[T] = object
case valid*: bool
of true: value*: T
of true: value: T
of false: nil"><wbr />Maybe<span class="attachedType" style="visibility:hidden"></span></a></li>

</ul>
Expand Down Expand Up @@ -1272,7 +1272,7 @@ <h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<dt id="Maybe"><a name="Maybe"></a><pre><span class="Identifier">Maybe</span><span class="Operator">*</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Keyword">case</span> <span class="Identifier">valid</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span>
<span class="Keyword">of</span> <span class="Identifier">true</span><span class="Other">:</span> <span class="Identifier">value</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">T</span>
<span class="Keyword">of</span> <span class="Identifier">true</span><span class="Other">:</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span>
<span class="Keyword">of</span> <span class="Identifier">false</span><span class="Other">:</span> <span class="Keyword">nil</span>
</pre></dt>
<dd>
Expand Down
6 changes: 3 additions & 3 deletions src/examples/example.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import ../maybe/maybe

# A simple adding function to use with our monads
proc adder(x: int) : Maybe[int] =
return Maybe[int](valid: true, value: x+x)
return maybe.pure(x+x)

# Initialize two maybe values
var
maybe1 = Maybe[int](valid: true, value: 5)
maybe2 = Maybe[int](valid: false)
maybe1 = maybe.pure(5)
maybe2 = maybe.nothing[int]()

# Create two results, of type Maybe[int]
# based on a chain of computations
Expand Down
2 changes: 1 addition & 1 deletion src/maybe/maybe.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type
## it is in a valid state.
Maybe*[T] = object
case valid*: bool
of true: value* : T
of true: value : T
of false: nil

proc `==`*[T](m1: Maybe[T], m2: Maybe[T]) : bool =
Expand Down

0 comments on commit 8eaf77b

Please sign in to comment.