UCSD-PL/refscript
{ "createdAt": "2014-04-10T17:51:20Z", "defaultBranch": "master", "description": "Refinement Types for Scripting Languages", "fullName": "UCSD-PL/refscript", "homepage": null, "language": "Haskell", "name": "refscript", "pushedAt": "2019-01-13T23:25:44Z", "stargazersCount": 69, "topics": [], "updatedAt": "2025-04-22T13:36:25Z", "url": "https://github.com/UCSD-PL/refscript"}refscript
Section titled “refscript”Refinement Types for TypeScript
Install
Section titled “Install”Dependencies
Section titled “Dependencies”Download
Section titled “Download”git clone --recursive https://github.com/UCSD-PL/refscriptcd refscriptstack setupstack buildBasic Usage
Section titled “Basic Usage”stack exec -- rsc /path/to/file.tsRegression testing
Section titled “Regression testing”stack test refscript:regressionRun Benchmarks
Section titled “Run Benchmarks”stack test refscript:benchTo run the complete set of benchmarks reported in our PLDI’16 paper, please
refer to branch pldi16.
Fast load (using ghci)
Section titled “Fast load (using ghci)”stack ghci refscript:exe:rsc*main> top "file.ts" FalseAdvanced
Section titled “Advanced”Building with profiling support (uses cabal sandboxes)
Section titled “Building with profiling support (uses cabal sandboxes)”To build with profiling support it is recommended that a new sandbox is used, as all library dependencies will have to be compiled with profiling support.
To do so, while in $ROOT/RefScript:
mv .cabal-sandbox .cabal-sandbox.backupmv cabal.sandbox.config cabal.sandbox.backup.configThen repeat the first steps of installation:
cabal sandbox initcabal sandbox add-source ../liquid-fixpointThis will create fresh .cabal-sandbox and cabal.sandbox.config
But before building, add the following option in cabal.sandbox.config:
library-profiling: Trueexecutable-profiling: TrueIn addition, in refscript.cabal replace line:
ghc-options: -W -O2with:
ghc-options: -W -O2 -prof -auto-allThen build with:
cabal install -pThis will build all depending libraries with profiling support.
To run rsc in profiling mode add flags +RTS -p in the end:
rsc input.ts +RTS -pMore detailed options can be found here.
If you’re interested in profiling the evaluation of a specific expression you can add a cost center annotation:
{-# SCC "name" #-} <expression>What this command outputs is a file called rsc.prof that contains all gathered profiling information, including information about both all functions (default cost centers) and user defined cost centers.
Editor Integration
Section titled “Editor Integration”We have some support for rsc in vim and emacs.
There is a flycheck plugin for RefScript.
-
Copy
ext/emacs/typescript-rsc.elinto your emacs PATH. -
Add this to your
init.el(require ‘typescript) (add-to-list ‘auto-mode-alist ’(“\.ts\’” . typescript-mode)) (require ‘flycheck-rsc)
Install
- Add the following to your
.vimrc
Bundle 'scrooloose/syntastic'Bundle 'panagosg7/vim-annotations'- Copy the following files
cp ext/vim/typescript/rsc.vim ~/.vim/bundle/syntastic/syntax_checkers/typescript/rsc.vimcp ext/vim/typescript/rsc.vim ~/.vim/bundle/syntastic/syntax_checkers/typescript/rsc.vimRun
:SyntasticCheck liquidrunsrscon the current buffer.
View
-
Warnings will be displayed in the usual error buffer.
-
Inferred Types will be displayed when
<F1>is pressed over an identifier.
Options
You can configure the checker in various ways in your .vimrc.
- To run after each save, for all Haskell files, add:
let g:syntastic_mode_map = { 'mode': 'active' }let g:syntastic_typescript_checkers += ['liquid']let g:syntastic_javascript_checkers += ['liquid']- To pass extra options to
rscadd:
let g:syntastic_typescript_liquid_args = '...'- Using
export let a = ...brings in the inferred type from TypeScript.