Skip to content

Commit

Permalink
Updates for Contingency changes
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jul 5, 2024
1 parent 8dc999f commit 98936e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/core/ambience-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import contingency.*
//import language.experimental.captureChecking

package workingDirectories:
given virtualMachine(using Errant[SystemPropertyError], SystemProperties): WorkingDirectory = () =>
given virtualMachine(using Tactic[SystemPropertyError], SystemProperties): WorkingDirectory = () =>
Properties.user.dir[Text]()

package homeDirectories:
given virtualMachine(using Errant[SystemPropertyError], SystemProperties): HomeDirectory = () =>
given virtualMachine(using Tactic[SystemPropertyError], SystemProperties): HomeDirectory = () =>
Properties.user.home[Text]()
10 changes: 5 additions & 5 deletions src/core/envvars.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ object Environment extends Dynamic:
def apply[VariableType](variable: Text)
(using environment: Environment,
reader: EnvironmentVariable[Label, VariableType],
environmentError: Errant[EnvironmentError])
environmentError: Tactic[EnvironmentError])
: VariableType^{environment, reader, environmentError} =

environment.variable(variable).let(reader.read).or(raise(EnvironmentError(variable))(reader.read(Text(""))))
environment.variable(variable).let(reader.read).or(raise(EnvironmentError(variable), reader.read(Text(""))))

inline def selectDynamic[VariableType](key: String)
(using environment: Environment,
reader: EnvironmentVariable[key.type, VariableType],
environmentError: Errant[EnvironmentError])
environmentError: Tactic[EnvironmentError])
: VariableType^{environment, reader, environmentError} =

environment.variable(reader.defaultName).let(reader.read(_)).or:
raise(EnvironmentError(reader.defaultName))(reader.read(Text("")))
raise(EnvironmentError(reader.defaultName), reader.read(Text("")))

@capability
trait EnvironmentVariable[AliasType <: Label, +VariableType] extends Pure:
Expand Down Expand Up @@ -113,7 +113,7 @@ object EnvironmentVariable extends EnvironmentVariable2:
given [PathType: SpecificPath] => EnvironmentVariable["editor", PathType] as editor = SpecificPath(_)
given [PathType: SpecificPath] => EnvironmentVariable["pager", PathType] as pager = SpecificPath(_)

given (using Errant[NumberError]) => EnvironmentVariable["sshAgentPid", Pid] as sshAgentPid =
given (using Tactic[NumberError]) => EnvironmentVariable["sshAgentPid", Pid] as sshAgentPid =
text => Pid(text.decodeAs[Int])

given sshAuthSock[PathType: SpecificPath]: EnvironmentVariable["sshAuthSock", PathType] = SpecificPath(_)
Expand Down
12 changes: 6 additions & 6 deletions src/core/properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object Properties extends Dynamic:
def apply[PropertyType](property: Text)
(using properties: SystemProperties,
reader: SystemProperty[String, PropertyType],
systemProperty: Errant[SystemPropertyError])
systemProperty: Tactic[SystemPropertyError])
: PropertyType^{properties, reader, systemProperty} =

properties(property).let(reader.read).or(abort(SystemPropertyError(property)))
Expand All @@ -57,13 +57,13 @@ object SystemProperty:
given javaHome[PathType: SpecificPath]: SystemProperty["java.home", PathType] = SpecificPath(_)

given javaLibraryPath[PathType: SpecificPath]
(using systemProperties: SystemProperties, systemProperty: Errant[SystemPropertyError])
(using systemProperties: SystemProperties, systemProperty: Tactic[SystemPropertyError])
: SystemProperty["java.library.path", List[PathType]] =

_.cut(systemProperties(t"path.separator").or(t":")).to(List).map(SpecificPath(_))

given javaClassPath[PathType: SpecificPath]
(using systemProperties: SystemProperties, systemProperty: Errant[SystemPropertyError])
(using systemProperties: SystemProperties, systemProperty: Tactic[SystemPropertyError])
: SystemProperty["java.class.path", List[PathType]] =

_.cut(systemProperties(t"path.separator").or(t":")).to(List).map(SpecificPath(_))
Expand All @@ -72,7 +72,7 @@ object SystemProperty:
given javaRuntimeVersion: SystemProperty["java.runtime.version", Text] = identity(_)

given javaExtDirs[PathType: SpecificPath]
(using systemProperties: SystemProperties, systemProperty: Errant[SystemPropertyError])
(using systemProperties: SystemProperties, systemProperty: Tactic[SystemPropertyError])
: SystemProperty["java.ext.dirs", List[PathType]] =

_.cut(systemProperties(t"path.separator").or(t":")).to(List).map(SpecificPath(_))
Expand Down Expand Up @@ -101,7 +101,7 @@ case class PropertyAccess[NameType <: String](property: String) extends Dynamic:
def applyDynamic[PropertyType](key: String)()
(using properties: SystemProperties,
reader: SystemProperty[NameType+"."+key.type, PropertyType],
systemProperty: Errant[SystemPropertyError])
systemProperty: Tactic[SystemPropertyError])
: PropertyType^{properties, reader, systemProperty} =

properties((property+"."+key).tt).let(reader.read(_)).or:
Expand All @@ -110,7 +110,7 @@ case class PropertyAccess[NameType <: String](property: String) extends Dynamic:
inline def apply[PropertyType]()
(using properties: SystemProperties,
reader: SystemProperty[NameType, PropertyType],
systemProperty: Errant[SystemPropertyError])
systemProperty: Tactic[SystemPropertyError])
: PropertyType^{properties, reader, systemProperty} =

properties(valueOf[NameType].tt).let(reader.read(_)).or:
Expand Down

0 comments on commit 98936e4

Please sign in to comment.