Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/koka-lang/koka into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
daanx committed Jan 29, 2025
2 parents f08bd42 + ca1170f commit 6210e0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/std/core/maybe.kk
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ pub fun default( m : maybe<a>, nothing : a ) : a
Just(x) -> x

// Get the value of the `Just` constructor or raise an exception
pub fun unjust( m : maybe<a> ) : exn a
pub fun unjust( m : maybe<a>, ?kk-file-line: string) : exn a
match m
Just(x) -> x
Nothing -> throw("unexpected Nothing in std/core/maybe/unjust")
Nothing -> throw("unexpected Nothing in " ++ ?kk-file-line)

// Get the value of the `Just` constructor or raise an exception with `error-msg`
pub fun expect( m : maybe<a>, error-msg: string) : exn a
match m
Just(x) -> x
Nothing -> throw(error-msg)

pub fun map( m : maybe<a>, f : a -> e b ) : e maybe<b>
match m
Expand Down
10 changes: 8 additions & 2 deletions lib/std/core/maybe2.kk
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ pub fun default( m : maybe2<a,b>, nothing : (a,b) ) : (a,b)
Just2(x,y) -> (x,y)

// Get the value of the `Just` constructor or raise an exception
pub fun unjust2( m : maybe2<a,b> ) : exn (a,b)
pub fun unjust( m : maybe2<a,b>, ?kk-file-line: string) : exn (a,b)
match m
Just2(x,y) -> (x,y)
Nothing2 -> throw("unexpected Nothing2 in std/core/maybe/unjust2")
Nothing2 -> throw("unexpected Nothing2 in " ++ ?kk-file-line)

// Get the value of the `Just` constructor or raise an exception
pub fun expect( m : maybe2<a,b>, error-msg: string) : exn (a,b)
match m
Just2(x,y) -> (x,y)
Nothing2 -> throw(error-msg)

pub fun map( m : maybe2<a,b>, f : (a,b) -> e (c,d) ) : e maybe2<c,d>
match m
Expand Down

0 comments on commit 6210e0e

Please sign in to comment.