-
Notifications
You must be signed in to change notification settings - Fork 25
/
impl-loader.rkt
44 lines (34 loc) · 1.05 KB
/
impl-loader.rkt
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
#lang racket
(require racket/dict
racket/port
racket/pretty)
(define settings
(make-parameter #f))
;;--------------------------------
;; Preferences reader
;;--------------------------------
(define read-preferences
(λ (fname)
(let ((port (make-parameter #f)))
(dynamic-wind
(λ () (and (file-exists? fname) (port (open-input-file fname))))
(λ () (or (and (port) (port->list read (port)))
default-preferences))
(λ () (when (port) (close-input-port (port))))))))
(define init-settings
(λ ()
(settings (make-hash (read-preferences (or (getenv "MALT_PREFERENCES") "local.cfg"))))))
;;--------------------------------
;; Config params so far
;;--------------------------------
(define tensor-implementation
(λ ()
(car (dict-ref (settings) 'tensor-implementation))))
;; Default settings
(define default-preferences
`((tensor-implementation learner)))
(when (not (settings))
(init-settings)
(println "settings=")
(pretty-print (settings)))
(provide tensor-implementation)