Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed Apr 27, 2019
1 parent 68b33d3 commit 6a7ddfb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 41 deletions.
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
"hubot": "3.0.1",
"hubot-gitter2": "1.0.0",
"ramda": "*",
"sanctuary": "1.1.0",
"sanctuary-def": "0.19.0",
"sanctuary-descending": "1.1.0",
"sanctuary-identity": "1.1.0",
"sanctuary": "2.0.0",
"sanctuary-def": "0.20.0",
"sanctuary-descending": "1.2.0",
"sanctuary-either": "1.2.0",
"sanctuary-identity": "1.2.0",
"sanctuary-int": "*",
"sanctuary-type-classes": "10.0.0",
"sanctuary-maybe": "1.2.0",
"sanctuary-pair": "1.2.0",
"sanctuary-show": "1.0.0",
"sanctuary-type-classes": "11.0.0",
"sanctuary-type-identifiers": "2.0.1"
},
"devDependencies": {
Expand Down
55 changes: 19 additions & 36 deletions scripts/eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,19 @@ const vm = require ('vm');
const Future = require ('fluture');
const fst = require ('fluture-sanctuary-types');
const R = require ('ramda');
const S_ = require ('sanctuary');
const {create, env} = require ('sanctuary');
const $ = require ('sanctuary-def');
const Descending = require ('sanctuary-descending');
const Identity = require ('sanctuary-identity');
const Int = require ('sanctuary-int');
const Z = require ('sanctuary-type-classes');
const type = require ('sanctuary-type-identifiers');


// env :: Array Type
const env = S_.env.concat (fst.env, [
$.UnaryType
('silly-goat/Descending')
('https://github.com/sanctuary-js/sanctuary-descending')
(x => type (x) === 'sanctuary-descending/Descending@1')
(descending => [Z.extract (descending)])
($.Unknown),
$.UnaryType
('silly-goat/Identity')
('https://github.com/sanctuary-js/sanctuary-identity')
(x => type (x) === 'sanctuary-identity/Identity@1')
(identity => [Z.extract (identity)])
($.Unknown),
]);

// opts :: { checkTypes :: Boolean, env :: Array Type }
const opts = {checkTypes: true, env};
const opts = {checkTypes: true, env: env.concat (fst.env)};

// S :: Module
const S = S_.create (opts);
const S = create (opts);

// def :: String -> StrMap TypeClass -> Array Type -> Function -> Function
const def = $.create (opts);
Expand All @@ -43,27 +26,27 @@ const def = $.create (opts);
const evaluate =
def ('evaluate')
({})
([$.String, S.EitherType ($.String) ($.String)])
([$.String, $.Either ($.String) ($.String)])
(code => {
const logs = [];
const log = level => (...args) => {
logs.push (level + ': ' + S.joinWith (', ') (S.map (String) (args)));
};
return S.map (x => S.unlines (logs) + S.show (x))
(S.encaseEither3 (S.prop ('message'))
(S.curry3 (vm.runInNewContext))
(code)
({$,
Descending,
Future,
Identity,
Int,
R,
S,
Z,
console: {error: log ('error'),
log: log ('log')}})
({timeout: 5000}));
return S.bimap (S.prop ('message'))
(x => S.unlines (logs) + S.show (x))
(S.encase (S.curry3 (vm.runInNewContext)
(code)
({$,
Descending,
Future,
Identity,
Int,
R,
S,
Z,
console: {error: log ('error'),
log: log ('log')}}))
({timeout: 5000}));
});

// backticks :: String
Expand Down

0 comments on commit 6a7ddfb

Please sign in to comment.