blob: 903412749722863bdebf1369185c051df9dbf957 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
(.require
[library
[lux (.except Module)
[abstract
["[0]" monad (.only Monad do)]]
[control
["<>" parser]
["[0]" try (.only Try)]
["[0]" exception (.only exception)]
[concurrency
["[0]" async (.only Async)]]]
[data
["[0]" binary (.only Binary)
["<[1]>" \\parser]]
["[0]" text (.only)
["%" \\format]]
[collection
["[0]" dictionary (.only Dictionary)]
["[0]" sequence]]
[format
["[0]" tar]]]
[tool
[compiler
[meta
[cli (.only Library Module)]]]]
[world
["[0]" file]]]])
(def Action
(type_literal (All (_ a) (Async (Try a)))))
(exception .public useless_tar_entry)
(exception .public (duplicate [library Library
module Module])
(exception.report
"Module" (%.text module)
"Library" (%.text library)))
(type .public Import
(Dictionary file.Path Binary))
(def (import_library system library import)
(-> (file.System Async) Library Import (Action Import))
(let [! async.monad]
(|> library
(at system read)
(at ! each (let [! try.monad]
(|>> (at ! each (<binary>.result tar.parser))
(at ! conjoint)
(at ! each (|>> sequence.list
(monad.mix ! (function (_ entry import)
(case entry
{tar.#Normal [path instant mode ownership content]}
(let [path (tar.from_path path)]
(case (dictionary.has' path (tar.data content) import)
{try.#Failure error}
(exception.except ..duplicate [library path])
import'
import'))
_
(exception.except ..useless_tar_entry [])))
import)))
(at ! conjoint)))))))
(def .public (import system libraries)
(-> (file.System Async) (List Library) (Action Import))
(monad.mix (is (Monad Action)
(try.with async.monad))
(..import_library system)
(dictionary.empty text.hash)
libraries))
|