Skip to content

Commit

Permalink
Remove capture checking
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Oct 3, 2024
1 parent c69a42f commit f041adf
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 33 deletions.
5 changes: 2 additions & 3 deletions src/core/ambience.Environment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 16,6 @@

package ambience

import language.experimental.captureChecking
import language.dynamics

import anticipation.*
Expand All @@ -36,15 35,15 @@ object Environment extends Dynamic:
(using environment: Environment,
reader: EnvironmentVariable[Label, VariableType],
environmentError: Tactic[EnvironmentError])
: VariableType^{environment, reader, environmentError} =
: VariableType =

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: Tactic[EnvironmentError])
: VariableType^{environment, reader, environmentError} =
: VariableType =

environment.variable(reader.defaultName).let(reader.read(_)).or:
raise(EnvironmentError(reader.defaultName), reader.read(Text("")))
12 changes: 6 additions & 6 deletions src/core/ambience.EnvironmentVariable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 33,35 @@ trait EnvironmentVariable[AliasType <: Label, VariableType] extends Pure:

object EnvironmentVariable extends EnvironmentVariable2:
given [PathType: SpecificPath](using systemProperties: SystemProperties)
=> (EnvironmentVariable["path", List[PathType]]^{systemProperties}) as path =
=> EnvironmentVariable["path", List[PathType]] as path =

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

given [PathType: SpecificPath](using systemProperties: SystemProperties)
=> (EnvironmentVariable["xdgDataDirs", List[PathType]]^{systemProperties}) as xdgDataDirs =
=> EnvironmentVariable["xdgDataDirs", List[PathType]] as xdgDataDirs =

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

given [PathType: SpecificPath](using systemProperties: SystemProperties)
=> (EnvironmentVariable["xdgConfigDirs", List[PathType]]^{systemProperties}) as xdgConfigDirs =
=> EnvironmentVariable["xdgConfigDirs", List[PathType]] as xdgConfigDirs =

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

given [PathType: SpecificPath as specific]
=> (EnvironmentVariable["xdgDataHome", PathType]^{specific}) as xdgDataHome =
=> EnvironmentVariable["xdgDataHome", PathType] as xdgDataHome =

SpecificPath(_)

given [PathType: SpecificPath as specific]
=> (EnvironmentVariable["xdgConfigHome", PathType]^{specific}) as xdgConfigHome =
=> EnvironmentVariable["xdgConfigHome", PathType] as xdgConfigHome =
SpecificPath(_)

given [PathType: SpecificPath]
=> (EnvironmentVariable["xdgStateHome", PathType]) as xdgStateHome =
SpecificPath(_)

given [PathType: SpecificPath as specific]
=> (EnvironmentVariable["xdgCacheHome", PathType]^{specific}) as xdgCacheHome =
=> EnvironmentVariable["xdgCacheHome", PathType] as xdgCacheHome =

SpecificPath(_)

Expand Down
2 changes: 1 addition & 1 deletion src/core/ambience.Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 34,7 @@ object Properties extends Dynamic:
(using properties: SystemProperties,
reader: SystemProperty[String, PropertyType],
systemProperty: Tactic[SystemPropertyError])
: PropertyType^{properties, reader, systemProperty} =
: PropertyType =

properties(property).let(reader.read).or(abort(SystemPropertyError(property)))

Expand Down
4 changes: 2 additions & 2 deletions src/core/ambience.PropertyAccess.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 35,7 @@ case class PropertyAccess[NameType <: String](property: String) extends Dynamic:
(using properties: SystemProperties,
reader: SystemProperty[NameType "." key.type, PropertyType],
systemProperty: Tactic[SystemPropertyError])
: PropertyType^{properties, reader, systemProperty} =
: PropertyType =

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

properties(valueOf[NameType].tt).let(reader.read(_)).or:
abort(SystemPropertyError(valueOf[NameType].tt))
1 change: 0 additions & 1 deletion src/core/ambience.SystemProperties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 19,6 @@ package ambience
import language.experimental.captureChecking

import anticipation.*
import rudiments.*
import vacuous.*

trait SystemProperties:
Expand Down
30 changes: 10 additions & 20 deletions src/core/ambience.Xdg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 25,28 @@ import rudiments.*
import vacuous.*

object Xdg:
def dataHome[PathType: SpecificPath]
(using environment: Environment, home: HomeDirectory)
: PathType/*^{PathType, environment, home}*/ =

def dataHome[PathType: SpecificPath](using environment: Environment, home: HomeDirectory)
: PathType =
safely(Environment.xdgDataHome[PathType]).or(SpecificPath(t"${home.directory()}/.local/share"))

def configHome[PathType: SpecificPath]
(using environment: Environment, home: HomeDirectory)
: PathType/*^{PathType, environment, home}*/ =

def configHome[PathType: SpecificPath](using environment: Environment, home: HomeDirectory)
: PathType =
safely(Environment.xdgConfigHome[PathType]).or(SpecificPath(t"${home.directory()}/.config"))

def cacheHome[PathType: SpecificPath]
(using environment: Environment, home: HomeDirectory)
: PathType/*^{PathType, environment, home}*/ =
def cacheHome[PathType: SpecificPath](using environment: Environment, home: HomeDirectory)
: PathType =

safely(Environment.xdgCacheHome[PathType]).or(SpecificPath(t"${home.directory()}/.cache"))

def stateHome[PathType: SpecificPath]
(using environment: Environment, home: HomeDirectory)
: PathType/*^{PathType, environment, home}*/ =
def stateHome[PathType: SpecificPath](using environment: Environment, home: HomeDirectory)
: PathType =

safely(Environment.xdgStateHome[PathType]).or(SpecificPath(t"${home.directory()}/.local/state"))

def runtimeDir[PathType: SpecificPath](using environment: Environment)
: Optional[PathType/*^{PathType, environment}*/] =

def runtimeDir[PathType: SpecificPath](using environment: Environment): Optional[PathType] =
safely(Environment.xdgRuntimeDir[PathType])

def bin[PathType: SpecificPath](using environment: Environment, home: HomeDirectory)
: PathType/*^{PathType, environment, home}*/ =

def bin[PathType: SpecificPath](using environment: Environment, home: HomeDirectory): PathType =
safely(Environment.xdgConfigHome[PathType]).or(SpecificPath(t"${home.directory()}/.local/bin"))

def dataDirs[PathType: SpecificPath](using Environment, SystemProperties): List[PathType] =
Expand Down

0 comments on commit f041adf

Please sign in to comment.