Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Display.flix
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mod Flixball.Display {

def mkIdColorMap(_b: Board): Int32 -> String -> String =
// all the ANSI colors
id -> s -> unsafe Env.handle(match (Int32.modulo(id, 12)) {
id -> s -> unsafe IO { Env.handle(match (Int32.modulo(id, 12)) {
case 0 => Chalk.magenta
case 1 => Chalk.red
case 2 => Chalk.yellow
Expand All @@ -67,7 +67,7 @@ mod Flixball.Display {
case 9 => Chalk.blueBright
case 10 => Chalk.cyanBright
case _ => Chalk.greenBright
})(s)
})(s) }

def directionStr(d: Direction): String = match d {
case North => "^"
Expand Down
16 changes: 8 additions & 8 deletions src/Utils/RegionedRandom.flix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod RegionedRandom {
/// Returns a fresh random number generator initialized with the given seed `s`.
///
pub def newWithSeed(_r: Region[r], s: Int64): RegionedRandom[r] \ r = {
RegionedRandom(checked_ecast(unsafe new Random(s)))
RegionedRandom(unsafe IO as r { new Random(s) })
}

///
Expand Down Expand Up @@ -72,54 +72,54 @@ mod RegionedRandom {
///
pub def nextBool(ran: RegionedRandom[r]): Bool \ r = {
let RegionedRandom(o) = ran;
checked_ecast(unsafe o.nextBoolean())
unsafe IO as r { o.nextBoolean() }
}

///
/// Returns the next pseudorandom 32-bit floating point number from the given random number generator `r`.
///
pub def nextFloat32(ran: RegionedRandom[r]): Float32 \ r = {
let RegionedRandom(o) = ran;
checked_ecast(unsafe o.nextFloat())
unsafe IO as r { o.nextFloat() }
}

///
/// Returns the next pseudorandom 64-bit floating point number from the given random number generator `r`.
///
pub def nextFloat64(ran: RegionedRandom[r]): Float64 \ r = {
let RegionedRandom(o) = ran;
checked_ecast(unsafe o.nextDouble())
unsafe IO as r { o.nextDouble() }
}

///
/// Returns the next pseudorandom 32-bit integer value from the given random number generator `r`.
///
pub def nextInt32(ran: RegionedRandom[r]): Int32 \ r = {
let RegionedRandom(o) = ran;
checked_ecast(unsafe o.nextInt())
unsafe IO as r { o.nextInt() }
}

///
/// Returns the next pseudorandom 64-bit integer value from the given random number generator `r`.
///
pub def nextInt64(ran: RegionedRandom[r]): Int64 \ r = {
let RegionedRandom(o) = ran;
checked_ecast(unsafe o.nextLong())
unsafe IO as r { o.nextLong() }
}

///
/// Returns the next pseudorandom Gaussian distributed 64-bit floating point number.
///
pub def nextGaussian(ran: RegionedRandom[r]): Float64 \ r = {
let RegionedRandom(o) = ran;
checked_ecast(unsafe o.nextGaussian())
unsafe IO as r { o.nextGaussian() }
}

///
/// Returns the next pseudorandom 32-bit integer value between `0` and `m` (exclusive) using the given random number generator `r`.
///
pub def nextNatWithMax(ran: RegionedRandom[r], m: Int32): Int32 \ r = {
let RegionedRandom(o) = ran;
checked_ecast(unsafe o.nextInt(m))
unsafe IO as r { o.nextInt(m) }
}
}
Loading