@@ -5,36 +5,19 @@ const vm = require ('vm');
5
5
const Future = require ( 'fluture' ) ;
6
6
const fst = require ( 'fluture-sanctuary-types' ) ;
7
7
const R = require ( 'ramda' ) ;
8
- const S_ = require ( 'sanctuary' ) ;
8
+ const { create , env } = require ( 'sanctuary' ) ;
9
9
const $ = require ( 'sanctuary-def' ) ;
10
10
const Descending = require ( 'sanctuary-descending' ) ;
11
11
const Identity = require ( 'sanctuary-identity' ) ;
12
12
const Int = require ( 'sanctuary-int' ) ;
13
13
const Z = require ( 'sanctuary-type-classes' ) ;
14
- const type = require ( 'sanctuary-type-identifiers' ) ;
15
14
16
15
17
- // env :: Array Type
18
- const env = S_ . env . concat ( fst . env , [
19
- $ . UnaryType
20
- ( 'silly-goat/Descending' )
21
- ( 'https://github.com/sanctuary-js/sanctuary-descending' )
22
- ( x => type ( x ) === 'sanctuary-descending/Descending@1' )
23
- ( descending => [ Z . extract ( descending ) ] )
24
- ( $ . Unknown ) ,
25
- $ . UnaryType
26
- ( 'silly-goat/Identity' )
27
- ( 'https://github.com/sanctuary-js/sanctuary-identity' )
28
- ( x => type ( x ) === 'sanctuary-identity/Identity@1' )
29
- ( identity => [ Z . extract ( identity ) ] )
30
- ( $ . Unknown ) ,
31
- ] ) ;
32
-
33
16
// opts :: { checkTypes :: Boolean, env :: Array Type }
34
- const opts = { checkTypes : true , env} ;
17
+ const opts = { checkTypes : true , env : env . concat ( fst . env ) } ;
35
18
36
19
// S :: Module
37
- const S = S_ . create ( opts ) ;
20
+ const S = create ( opts ) ;
38
21
39
22
// def :: String -> StrMap TypeClass -> Array Type -> Function -> Function
40
23
const def = $ . create ( opts ) ;
@@ -43,27 +26,27 @@ const def = $.create (opts);
43
26
const evaluate =
44
27
def ( 'evaluate' )
45
28
( { } )
46
- ( [ $ . String , S . EitherType ( $ . String ) ( $ . String ) ] )
29
+ ( [ $ . String , $ . Either ( $ . String ) ( $ . String ) ] )
47
30
( code => {
48
31
const logs = [ ] ;
49
32
const log = level => ( ...args ) => {
50
33
logs . push ( level + ': ' + S . joinWith ( ', ' ) ( S . map ( String ) ( args ) ) ) ;
51
34
} ;
52
- return S . map ( x => S . unlines ( logs ) + S . show ( x ) )
53
- ( S . encaseEither3 ( S . prop ( 'message' ) )
54
- ( S . curry3 ( vm . runInNewContext ) )
55
- ( code )
56
- ( { $,
57
- Descending,
58
- Future,
59
- Identity,
60
- Int,
61
- R,
62
- S,
63
- Z,
64
- console : { error : log ( 'error' ) ,
65
- log : log ( 'log' ) } } )
66
- ( { timeout : 5000 } ) ) ;
35
+ return S . bimap ( S . prop ( 'message' ) )
36
+ ( x => S . unlines ( logs ) + S . show ( x ) )
37
+ ( S . encase ( S . curry3 ( vm . runInNewContext )
38
+ ( code )
39
+ ( { $,
40
+ Descending,
41
+ Future,
42
+ Identity,
43
+ Int,
44
+ R,
45
+ S,
46
+ Z,
47
+ console : { error : log ( 'error' ) ,
48
+ log : log ( 'log' ) } } ) )
49
+ ( { timeout : 5000 } ) ) ;
67
50
} ) ;
68
51
69
52
// backticks :: String
0 commit comments