Skip to content

Commit 98599b6

Browse files
committed
Provide a typeclass for getting the temporary directory
1 parent 4cbc8dd commit 98599b6

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

src/core/rudiments-core.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,20 @@ def homeDirectory[PathType: Instantiable across Paths from Text]
309309

310310
directory.path[PathType]
311311

312+
def temporaryDirectory[PathType: Instantiable across Paths from Text]
313+
(using directory: TemporaryDirectory)
314+
: PathType =
315+
316+
directory.path[PathType]
317+
312318
package workingDirectories:
313319
given default: WorkingDirectory = () => System.getProperty("user.dir").nn.tt
314-
//given none(using Tactic[WorkingDirectoryError]): WorkingDirectory =
315-
// () => abort(WorkingDirectoryError())
316320

317321
package homeDirectories:
318322
given default: HomeDirectory = () => System.getProperty("user.home").nn.tt
319-
//given none(using Tactic[HomeDirectoryError]): HomeDirectory = () => abort(HomeDirectoryError())
323+
324+
package temporaryDirectories:
325+
given default: TemporaryDirectory = () => System.getProperty("java.io.tmpdir").nn.tt
320326

321327
package quickstart:
322328
erased given defaults: Quickstart = ###
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Rudiments, version 0.26.0. Copyright 2025 Jon Pretty, Propensive OÜ.
3+
4+
The primary distribution site is: https://propensive.com/
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7+
file except in compliance with the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software distributed under the
12+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
either express or implied. See the License for the specific language governing permissions
14+
and limitations under the License.
15+
*/
16+
17+
package rudiments
18+
19+
import language.experimental.captureChecking
20+
21+
import anticipation.*
22+
import prepositional.*
23+
24+
object TemporaryDirectory:
25+
given default: Quickstart => TemporaryDirectory = () => System.getProperty("java.io.tmpdir").nn.tt
26+
27+
trait TemporaryDirectory:
28+
def directory(): Text
29+
30+
def path[PathType: Instantiable across Paths from Text]: PathType =
31+
PathType(directory())

src/core/soundness+rudiments-core.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export rudiments
2525
Exit, Pid, Quickstart, unit, waive, twin, triple, is, matchable, give, pipe,
2626
tap, also, Counter, loop, Loop, &, tuple, to, WorkingDirectoryError, HomeDirectoryError,
2727
WorkingDirectory, HomeDirectory, workingDirectory, homeDirectory, Bond, binds, bound, prim, sec,
28-
ter, unwind, at, Indexable, yet, Bijection, bijection, segment, Segmentable, Digit }
28+
ter, unwind, at, Indexable, yet, Bijection, bijection, segment, Segmentable, Digit,
29+
temporaryDirectory }
2930

3031
package quickstart:
3132
export rudiments.quickstart.defaults as defaults
@@ -35,3 +36,6 @@ package workingDirectories:
3536

3637
package homeDirectories:
3738
export rudiments.homeDirectories.default as default
39+
40+
package temporaryDirectories:
41+
export rudiments.temporaryDirectories.default as default

0 commit comments

Comments
 (0)