Skip to content

Commit

Permalink
Renamed fn to lambda everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jan 5, 2024
1 parent d50e5e4 commit a387353
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/internet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ import language.experimental.captureChecking
case class OfflineError() extends Error(msg"an Internet connection is not available")

class Internet(val online: Boolean):
def require[ResultType](fn: Online ?=> ResultType)(using Raises[OfflineError]): ResultType =
if online then fn(using Online) else abort(OfflineError())
def require[ResultType](block: Online ?=> ResultType)(using Raises[OfflineError]): ResultType =
if online then block(using Online) else abort(OfflineError())

def appropriate[ResultType](fn: Online ?=> ResultType): Optional[ResultType] =
if online then fn(using Online) else Unset
def appropriate[ResultType](block: Online ?=> ResultType): Optional[ResultType] =
if online then block(using Online) else Unset

class Online() extends Internet(true)
object Online extends Online()

def internet[ResultType](online: Boolean)(fn: Internet ?=> ResultType): ResultType =
fn(using Internet(online))
def internet[ResultType](online: Boolean)(block: Internet ?=> ResultType): ResultType =
block(using Internet(online))

def online(using internet: Internet): Boolean = internet.online

0 comments on commit a387353

Please sign in to comment.