diff --git a/CHANGES.md b/CHANGES.md
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,7 +1,157 @@
 # Changes
 
-## NEXT 0.8.10.1
+## Next
 
+## 0.9.14.1.1 (2026-06-04)
+
+- Stop shadowing reflected signatures with assumed signatures
+  [#2675](https://github.com/ucsd-progsys/liquidhaskell/pull/2675)
+- Allow parenthesis in arguments to type aliases. Require type aliases to start with upper-case
+  [#2674](https://github.com/ucsd-progsys/liquidhaskell/pull/2674)
+- Add `--save-bfq-on-error` flag for liquidhaskell and include it in CI
+  [#2648](https://github.com/ucsd-progsys/liquidhaskell/pull/2648)
+- Migrate from cmdargs to base:System.Console.GetOpt
+  [#2672](https://github.com/ucsd-progsys/liquidhaskell/pull/2672)
+  [#2677](https://github.com/ucsd-progsys/liquidhaskell/pull/2677)
+  [#2678](https://github.com/ucsd-progsys/liquidhaskell/pull/2678)
+- Avoid name resolution errors in define annotations
+  [#2604](https://github.com/ucsd-progsys/liquidhaskell/pull/2667)
+
+## 0.9.14.1 (2026-05-06)
+
+- Upgrade to GHC 9.14.1 [#2604](https://github.com/ucsd-progsys/liquidhaskell/pull/2604)
+- Expand defines in define bodies, allowing defines to reference other defines [#2666](https://github.com/ucsd-progsys/liquidhaskell/pull/2666)
+- Add `--modern` flag that bundles recommended defaults for new projects [#2637](https://github.com/ucsd-progsys/liquidhaskell/pull/2637)
+- Rename `--exact-data-cons` to `--adt` and remove `--no-adt` [#2642](https://github.com/ucsd-progsys/liquidhaskell/pull/2642)
+- Strengthen data constructor specs independently of `--adt` [#2628](https://github.com/ucsd-progsys/liquidhaskell/pull/2628)
+- Always strengthen environment of case alternatives during constraint generation [#2642](https://github.com/ucsd-progsys/liquidhaskell/pull/2642)
+- Only produce selectors for data constructors in use [#2642](https://github.com/ucsd-progsys/liquidhaskell/pull/2642)
+- Reject conflicting selector types across constructors [#2642](https://github.com/ucsd-progsys/liquidhaskell/pull/2642)
+- Add `--warn-on-term-holes` flag for typed holes support [#2486](https://github.com/ucsd-progsys/liquidhaskell/pull/2486)
+- Add PLE sort-compatibility check for measure application [#2663](https://github.com/ucsd-progsys/liquidhaskell/pull/2663)
+- Add Core pass to eliminate `(?)` operator after ANF [#2664](https://github.com/ucsd-progsys/liquidhaskell/pull/2664)
+- Remove refinement type signature of `(?)` and document it [#2664](https://github.com/ucsd-progsys/liquidhaskell/pull/2664)
+- Add support for fractional literals in the logic [#2619](https://github.com/ucsd-progsys/liquidhaskell/pull/2619)
+- Add `Bool` embed always, regardless of imports [#2642](https://github.com/ucsd-progsys/liquidhaskell/pull/2642)
+- Preserve dead bindings by marking Ids as exported [#2661](https://github.com/ucsd-progsys/liquidhaskell/pull/2661)
+- Keep dependent binds in scope regardless of their types [#2627](https://github.com/ucsd-progsys/liquidhaskell/pull/2627)
+- Fix LHAssumptions module lookup with `-plugin-package` [#2665](https://github.com/ucsd-progsys/liquidhaskell/pull/2665)
+- Fix spurious invariant propagation for measures on type synonyms [#2660](https://github.com/ucsd-progsys/liquidhaskell/pull/2660)
+- Fix polymorphic kvar type variable mismatch [#2649](https://github.com/ucsd-progsys/liquidhaskell/issues/2649) [#2651](https://github.com/ucsd-progsys/liquidhaskell/pull/2651)
+- Fix shifted argument binding when lambda has fewer args than predicate [#2657](https://github.com/ucsd-progsys/liquidhaskell/pull/2657)
+- Propagate abstract refinement predicates on parenthesized types [#2657](https://github.com/ucsd-progsys/liquidhaskell/pull/2657)
+- Improve error messages for predicate arity mismatch and misplaced abstract refinement arguments [#2657](https://github.com/ucsd-progsys/liquidhaskell/pull/2657)
+- Add constraint IDs to termination check error messages [#2659](https://github.com/ucsd-progsys/liquidhaskell/pull/2659)
+- Add an indication of precedence to checkBind errors [#2631](https://github.com/ucsd-progsys/liquidhaskell/pull/2631)
+- Remove stack support (stack.yaml removed) [#2616](https://github.com/ucsd-progsys/liquidhaskell/pull/2616)
+
+## 0.9.12.2.1 (2026-01-14)
+
+- Disable LH when collecting Haddock comments and the noBackend is set [#2611](https:://github.com/ucsd-progsys/liquidhaskell/pull/2611)
+- Make assume reflect error sensitive to dflags [#2607](https:://github.com/ucsd-progsys/liquidhaskell/pull/2607)
+- Add a flag to dump the a-normalized core [#2605](https:://github.com/ucsd-progsys/liquidhaskell/pull/2605)
+- Show solutions of non-cut kvars in error messages [#2596](https:://github.com/ucsd-progsys/liquidhaskell/pull/2596)
+- Remove question marks as a distinction of predicates from other expressions [#2595](https:://github.com/ucsd-progsys/liquidhaskell/pull/2595)
+- Require braces when declaring qualifier [#2594](https:://github.com/ucsd-progsys/liquidhaskell/pull/2594)
+- Retire implementation of gradual refinement types [#2588](https:://github.com/ucsd-progsys/liquidhaskell/pull/2588)
+- Remove old versions of PLE [#2587](https:://github.com/ucsd-progsys/liquidhaskell/pull/2587)
+- Add new syntax for indexed types (Ix instead of Prop) [#2586](https:://github.com/ucsd-progsys/liquidhaskell/pull/2586)
+- Handle `ByteArray#` as int in the logic [#2581](https:://github.com/ucsd-progsys/liquidhaskell/pull/2581)
+- Do not ignore user qualifiers when using `--reflection` [#2580](https:://github.com/ucsd-progsys/liquidhaskell/pull/2580)
+- Add set cardinality support when using cvc5 [#2577](https:://github.com/ucsd-progsys/liquidhaskell/pull/2577)
+- Support the finite field theory when using cvc5 [#2571](https:://github.com/ucsd-progsys/liquidhaskell/pull/2571) [#2614](https:://github.com/ucsd-progsys/liquidhaskell/pull/2614)
+- Allow to qualify predicate aliases [#2566](https:://github.com/ucsd-progsys/liquidhaskell/pull/2566)
+- Implement stratified types [#2559](https:://github.com/ucsd-progsys/liquidhaskell/pull/2559)
+- Resolve occurrences of imported opaquely-reflected functions [#2548](https:://github.com/ucsd-progsys/liquidhaskell/pull/2548)
+- Allow to qualify type aliases [#2550](https:://github.com/ucsd-progsys/liquidhaskell/pull/2550)
+- Print the amount of checked constraints when verification fails [#2545](https:://github.com/ucsd-progsys/liquidhaskell/pull/2545)
+- Fix SMT crashes on reflected functions on polymorphic data types [#2542](https://github.com/ucsd-progsys/liquidhaskell/pull/2542)
+- Look for cvc5 before cvc4 [#2513](https://github.com/ucsd-progsys/liquidhaskell/pull/2513)
+- Change `--cores` default to 1 [#2564](https://github.com/ucsd-progsys/liquidhaskell/pull/2564)
+
+## 0.9.12.2 (2025-03-22)
+
+- Simplify kvar solutions in fqout files [liquid-fixpoint#741](https://github.com/ucsd-progsys/liquid-fixpoint/pull/741).
+- Upgrade ghc to 9.12.2 [#2474](https://github.com/ucsd-progsys/liquidhaskell/pull/2474).
+
+## 0.9.10.1.2 (2025-03-06)
+
+- Implement opaque reflection, a feature to allow reflecting functions which
+  call to non-reflected functions [#2323](https://github.com/ucsd-progsys/liquidhaskell/pull/2323).
+- Implement reflection from interface files, which can reflect functions from
+  their unfoldings [#2326](https://github.com/ucsd-progsys/liquidhaskell/pull/2326).
+  The feature is limited at the moment by the constraints that affect reflecting
+  functions in general. But we hope it becomes more interesting as reflection is
+  made more flexible.
+- Operators in the logic cannot be shadowed locally anymore since
+  [#2327](https://github.com/ucsd-progsys/liquidhaskell/pull/2327).
+- Added a flag `--dump-pre-normalized-core` to show core before A normalization
+  and constraint generation [#2336](https://github.com/ucsd-progsys/liquidhaskell/pull/2336).
+- Augmented the context of error messages [#2350](https://github.com/ucsd-progsys/liquidhaskell/pull/2350).
+- Add a new flag `--etabeta` to reason with lambdas in PLE [#2356](https://github.com/ucsd-progsys/liquidhaskell/pull/2356)
+- Add a new flag `--dependentcase` to expand support for higher-order reasoning [#2384](https://github.com/ucsd-progsys/liquidhaskell/pull/2384)
+- Add support for reflecting lambda expressions [#2465](https://github.com/ucsd-progsys/liquidhaskell/pull/2465).
+- Enabling the LiquidHaskell plugin now enables `-fno-ignore-interface-pragmas` ([#2326](https://github.com/ucsd-progsys/liquidhaskell/pull/2326))
+  and `-dkeep-comments` ([#2367](https://github.com/ucsd-progsys/liquidhaskell/pull/2367)).
+- LiquidHaskell earned a new `--minimal` verbosity level as default that prints the banner with the
+  amount of constraints checked ([#2395](https://github.com/ucsd-progsys/liquidhaskell/pull/2395)).
+  This banner is now suppressed when the verbosity is set to `--quiet` ([#2391](https://github.com/ucsd-progsys/liquidhaskell/pull/2391)).
+- Avoid reparsing and retypechecking when verifying modules [#2389](https://github.com/ucsd-progsys/liquidhaskell/pull/2389).
+- Name resolution is done only when verifying a module. It is no longer done when
+  importing it [#2169](https://github.com/ucsd-progsys/liquidhaskell/issues/2169). One
+  side effect of this change is that LH can now pick up names in scope using import aliases
+  in most places (but see [#2481](https://github.com/ucsd-progsys/liquidhaskell/issues/2481)).
+- Allow to link Haskell definitions with logical primitives via `define` declarations [#2463](https://github.com/ucsd-progsys/liquidhaskell/pull/2463).
+- CVC5 solver is now supported for all logical theories, including Sets/Bags [#2483](https://github.com/ucsd-progsys/liquidhaskell/pull/2483)
+
+## 0.9.10.1 (2024-08-21)
+
+- Add support for GHC 9.10.1.
+
+## 0.9.8.2 (2024-08-21)
+
+- Support for GHC 9.8.2.
+- Implement assume-reflect, a feature to assume the reflection of functions in dependencies [2313](https://github.com/ucsd-progsys/liquidhaskell/pull/2313).
+- Fixed the polymorphism-related crash in liquid-fixpoint caused by a restrictive theory encoding [#2272](https://github.com/ucsd-progsys/liquidhaskell/issues/2272).
+
+## 0.9.8.1 (2024-02-05)
+
+- Set support for GHC 9.8.1 [#2248](https://github.com/ucsd-progsys/liquidhaskell/pull/2248)
+- Embedded files `include/CoreToLogic.lg` and `syntax/liquid.css` in the source code [#2265](https://github.com/ucsd-progsys/liquidhaskell/issues/2265)
+
+## 0.9.6.3.1 (2024-03-07)
+
+- Avoid enabling plugins in ghc-options (workaround for #9375)
+
+## 0.9.6.3 (2024-01-29)
+
+- Set support for GHC 9.6.3
+
+## 0.9.4.7.0
+
+- Set support for GHC 9.4.7
+
+## 0.9.2.8.0
+
+- Support for GHC 9.2.8
+- Fix A normalization when type binder and lets are mixed in the input (#2236)
+- Move KMeansHelper from liquid-prelude to tests
+
+## 0.9.2.5
+
+- Introduce package liquidhaskell-boot and eliminate wrapper packages for boot libraries
+- List all definitions used from the GHC API
+- Allow LH to verify modules in parallel (remove withArgs call)
+- Remove some calls to HashMap.toList which caused some non-determinisms in different machines
+- Implement a Haskell script to plot performance without gnuplot
+
+## 0.9.0.2
+
+- **breaking change** Remove the implicit types mechanism and corresponding tests
+- **breaking change** Remove the `decrease` keyword and mechanism in favor of the terminating expressions syntax (`/ [a,b]`)
+
+## 0.8.10.1
+
 - Support for GHC 8.10.1
 - LiquidHaskell is now available as a GHC Plugin
 
@@ -24,36 +174,36 @@
 - Support for GHC 8.2.2
 
 - Support for GADTs and TypeFamilies, see
-	- `tests/{pos,neg}/ExactGADT*.hs`
+        - `tests/{pos,neg}/ExactGADT*.hs`
 
 - Add support for Bags/Multisets, see
-	- `tests/pos/bag.hs`
-	- `tests/neg/bag.hs`
-	- `tests/pos/ListISort-bag.hs`
+        - `tests/pos/bag.hs`
+        - `tests/neg/bag.hs`
+        - `tests/pos/ListISort-bag.hs`
 
 - Add support for *inductive predicates* see
-	- `tests/pos/IndEven.hs`
-	- `tests/pos/IndPerm.hs`
-	- `tests/pos/IndStar.hs`
+        - `tests/pos/IndEven.hs`
+        - `tests/pos/IndPerm.hs`
+        - `tests/pos/IndStar.hs`
 
 ## 0.8.0.1
 
-- Support for GHC 8.0.2 
+- Support for GHC 8.0.2
 
 ## 0.7.0.1
 
 - **DELETED** the gsDcons and generally carrying DataConP beyond Bare; this _may_ cause
   problems with `target` as I removed the `dconEnv` field in `TargetState`. Is it live?
-  To restore: have to apply the substitution syms/su in Bare.hs ALSO to gsDconsP (after 
+  To restore: have to apply the substitution syms/su in Bare.hs ALSO to gsDconsP (after
   restoring the gsDconsP field to [(DataCon, DataConP)])
 
 
-- **breaking change** Remove the `Bool` vs. `Prop` distinction. This means that: 
+- **breaking change** Remove the `Bool` vs. `Prop` distinction. This means that:
 
-    * signatures that use(d) `Prop` as a type, e.g. 
+    * signatures that use(d) `Prop` as a type, e.g.
       `foo :: Int -> Prop` should just be `foo :: Int -> Bool`.
 
-    * refinements that use(d) `Prop v` e.g. 
+    * refinements that use(d) `Prop v` e.g.
       `isNull :: xs:[a] -> {v:Bool | Prop v <=> len xs > 0}`
       should just be `isNull :: xs:[a] -> {v:Bool | v <=> len xs > 0}`.
 
@@ -81,7 +231,7 @@
 
 - Fixed a bug in the specification for `Data.Traversable.sequence`
 - Make interpreted mul and div the default, when `solver = z3`
-- Use `--higherorder` to allow higher order binders into the fixpoint environment 
+- Use `--higherorder` to allow higher order binders into the fixpoint environment
 
 ## 0.5.0.0
 
@@ -105,8 +255,8 @@
 
 - Logical constraints: add extra subtyping constraints to signatures, e.g.
 
-    {-@ 
-    (.) :: forall <p :: b -> c -> Prop, q :: a -> b -> Prop, r :: a -> c -> Prop>. 
+    {-@
+    (.) :: forall <p :: b -> c -> Prop, q :: a -> b -> Prop, r :: a -> c -> Prop>.
            {x::a, w::b<q x> |- c<p w> <: c<r x>}
            (y:b -> c<p y>)
         -> (z:a -> b<q z>)
@@ -136,7 +286,7 @@
 LiquidHaskell now *requires* ghc-7.8.3.
 
 - Termination
-LiquidHaskell will now attempt to prove all recursive functions terminating. It tries to prove that some parameter (or combination thereof) decreases at each recursive callsite. By default, this will be the first parameter with an associated size measure (see Size Measures), but can be overridden with the `Decreases` annotation or a termination expression (see Termination Expressions). 
+LiquidHaskell will now attempt to prove all recursive functions terminating. It tries to prove that some parameter (or combination thereof) decreases at each recursive callsite. By default, this will be the first parameter with an associated size measure (see Size Measures), but can be overridden with the `Decreases` annotation or a termination expression (see Termination Expressions).
 
 If proving termination is too big of burden, it can be disabled on a per-module basis with the `--no-termination` flag, or on a per-function basis with the `Lazy` annotation.
 
@@ -207,7 +357,7 @@
 We have greatly improved our parser to require fewer parentheses! Yay!
 
 - Emacs/Vim Support
-LiquidHaskell now comes with syntax checkers for [flycheck](https://github.com/flycheck/flycheck) in Emacs and [syntastic](https://github.com/scrooloose/syntastic) in Vim. 
+LiquidHaskell now comes with syntax checkers for [flycheck](https://github.com/flycheck/flycheck) in Emacs and [syntastic](https://github.com/scrooloose/syntastic) in Vim.
 
 - Incremental Checking
 LiquidHaskell has a new `--diffcheck` flag that will only check binders that have changed since the last run, which can drastically improve verification times.
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,27 +1,407 @@
 ![LiquidHaskell](/resources/logo.png)
 
 
+[![Hackage](https://img.shields.io/hackage/v/liquidhaskell.svg)](https://hackage.haskell.org/package/liquidhaskell) [![Build Status](https://img.shields.io/circleci/project/ucsd-progsys/liquidhaskell/develop.svg)]([https://circleci.com/gh/ucsd-progsys/liquidhaskell](https://app.circleci.com/pipelines/github/ucsd-progsys/liquidhaskell?branch=develop))
 
-[![Hackage](https://img.shields.io/hackage/v/liquidhaskell.svg)](https://hackage.haskell.org/package/liquidhaskell) [![Hackage-Deps](https://img.shields.io/hackage-deps/v/liquidhaskell.svg)](http://packdeps.haskellers.com/feed?needle=liquidhaskell) [![Build Status](https://img.shields.io/circleci/project/ucsd-progsys/liquidhaskell/master.svg)](https://circleci.com/gh/ucsd-progsys/liquidhaskell)
-[![Windows build status](https://ci.appveyor.com/api/projects/status/78y7uusjcgor5p16/branch/develop?svg=true)](https://ci.appveyor.com/project/varosi/liquidhaskell-nlhra/branch/develop)
+This is the **development** site of the LiquidHaskell formal verification tool.
 
-## Quick Links
+If you're a LiquidHaskell **user** (or just curious), you probably want to go to [the documentation website](https://ucsd-progsys.github.io/liquidhaskell/) instead.
 
-* [Try LiquidHaskell in your browser](http://goto.ucsd.edu:8090/index.html)
-* [Splash page with examples and link to blog](https://ucsd-progsys.github.io/liquidhaskell-blog/)
-* [120 minute workshop with more examples](http://ucsd-progsys.github.io/lh-workshop/01-index.html)
-* [Long ish Tutorial](http://ucsd-progsys.github.io/liquidhaskell-tutorial/)
+## Trying it from Hackage
 
-## Documentation
+Assuming the [Z3](https://github.com/Z3Prover/z3) SMT solver version `4.8.17` or
+newer is installed and available in your `PATH`, you can run
 
-* [LH Documentation](http://ucsd-progsys.github.io/liquidhaskell/) 
-* [Edit here](/docs/mkDocs)
+```
+cabal install --lib liquidhaskell liquid-prelude liquid-vector --package-env . --force-reinstalls
+ghc -fplugin=LiquidHaskell FILE.hs
+```
 
-## Questions
+`--package-env .` creates a `.ghc.environment*` file in the current folder that makes
+`ghc` find the `LiquidHaskell` plugin only when invoking it from there.
+Otherwise, global user configuration would be affected.
 
-If you have any questions
+Note that the installation step is influenced by the dependencies that are
+already installed in your system, so different results may be obtained by
+different users.
 
-* Join the Liquid Haskell [slack channel](https://join.slack.com/t/liquidhaskell/shared_invite/enQtMjY4MTk3NDkwODE3LTFmZGFkNGEzYWRkNDJmZDQ0ZGU1MzBiZWZiZDhhNmY3YTJiMjUzYTRlNjMyZDk1NDU3ZGIxYzhlOTIzN2UxNWE)
-* Mail the [users mailing list](https://groups.google.com/forum/#!forum/liquidhaskell)
-* Create a github issue
+## Trying it from GitHub
 
+The github repo builds with GHC `9.14.1`, cabal-install `3.16.1.0`, and `z3` `9.8.17` or newer, all of
+which must be in your `PATH`.
+
+```
+git clone https://github.com/ucsd-progsys/liquidhaskell.git
+cd liquidhaskell
+git submodule update --init
+cabal build liquidhaskell liquid-prelude liquid-vector
+
+cabal exec -- ghc -fplugin=LiquidHaskell FILE.hs
+```
+
+## Asking for Help
+
+If you have questions or you just need help, you can always reach out on our [zulip space](https://liquidhaskell.zulipchat.com/), [google groups mailing list](https://groups.google.com/forum/#!forum/liquidhaskell), [GitHub issue tracker](https://github.com/ucsd-progsys/liquidhaskell/issues), or by emailing [Ranjit Jhala](https://github.com/ranjitjhala), [Niki Vazou](https://github.com/nikivazou).
+
+# Contributing
+
+This is an open-source project, and we love getting feedback (and patches)!
+
+## Reporting a Bug
+
+If something doesn't work as it should, please consider opening a [github issue](https://github.com/ucsd-progsys/liquidhaskell/issues)
+to let us know. If possible, try to:
+
+* Try to use a descriptive title;
+* State as clearly as possible what is the problem you are facing;
+* Provide a small Haskell file producing the issue;
+* Write down the expected behaviour vs the actual behaviour;
+* Please, let us know which liquidhaskell version you are using.
+
+## Your first Pull Request
+
+We are thrilled to get PRs! Please follow these guidelines, as doing so will increase the chances of
+having your PR accepted:
+
+* The main LH repo [lives here](https://github.com/ucsd-progsys/liquidhaskell)
+* Please create pull requests against the `develop` branch.
+* Please be sure to include test cases that illustrate the effect of the PR
+    - e.g. show new features that that are supported or how it fixes some previous issue
+* If you're making user-visible changes, please also add documentation
+    - e.g. [options.md](docs/mkDocs/docs/options.md), [specifications.md](docs/mkDocs/docs/specifications.md), the [main tutorial](https:///github.com/ucsd-progsys/intro-refinement-types) (as relevant)
+
+Pull requests don't just have to be about code: documentation can often be improved too!
+
+# General Development Guide
+
+For those diving into the implementation of LiquidHaskell, here are a few tips:
+
+## Faster recompilation
+
+When changing the `liquidhaskell-boot` library, sometimes we don't want
+to rebuild `liquidhaskell` or `liquid-vector` when testing the changes.
+In these cases we can set the environment variable `LIQUID_DEV_MODE=true`
+when running `cabal` to skip rebuilding those packages.
+
+DANGER: Note that this can give an invalid result if the changes to
+`liquidhaskell-boot` do require rebuilding other `liquid*` packages.
+
+## How To Run Regression Tests
+
+For documentation on the `test-driver` executable itself, please refer to the
+`README.md` in `tests/` or run `cabal run tests:test-driver -- --help`
+
+You can run *all* the tests by
+
+    $ ./scripts/test/test_plugin.sh
+
+You can run a bunch of particular test-groups instead by
+
+    $ ./scripts/test/test_plugin.sh <test-group-name1> <test-group-name2> ...
+
+and you can list all the possible test options with
+
+    $ ./scripts/test/test_plugin.sh --help
+
+or get a list of just the test groups, one per line, with
+
+    $ ./scripts/test/test_plugin.sh --show-all
+
+To pass in specific parameters, you can invoke cabal directly with
+
+    $ cabal build tests:<test-group-name> --ghc-options=-fplugin-opt=LiquidHaskell:--no-termination
+
+For example:
+
+    $ cabal build tests:unit-neg --ghc-options=-fplugin-opt=LiquidHaskell:--no-termination
+
+Another useful option is to change the underlying solver:
+
+    $ cabal build tests:unit-pos --ghc-options=-fplugin-opt=LiquidHaskell:--smtsolver=cvc5
+
+You can also modify the number of used threads, depending on cores etc.
+
+You can directly extend and run the tests by modifying the files in
+
+    tests/harness/
+
+### Parallelism in Tests
+
+Tests run in parallel, unless the flag `--measure-timings` is specified to `test_plugin.sh`.
+
+### How to add a new test
+
+Select a folder where to add the test, for instance `tests/ple/pos` and add a
+new file `MyTest.hs` with the test module. Then add the module to the
+corresponding executable in `tests/tests.cabal`.
+
+## How to create performance comparison charts
+
+Firstly, make sure to remove previous compilation artifacts of tests before measuring performance,
+or GHC will skip running Liquid Haskell on modules that don't need recompilation. Unfortunately,
+using `-fforce-recomp` is not ideal (see [#2565](https://github.com/ucsd-progsys/liquidhaskell/pull/2565)
+for more details). At the time of writing, previous compilation artifacts of tests can be removed with
+
+```bash
+find dist-newstyle -name "tests-*" -o -name "prover-ple-lib-*" | xargs rm -r
+```
+
+When `liquidhaskell` tests run, we can collect timing information with
+
+    $ ./scripts/test/test_plugin.sh --measure-timings
+
+Measures will be collected in `.dump-timings` files under `dist-newstyle` directory. These can be
+converted to json data with
+
+```bash
+cabal build ghc-timings
+cabal exec ghc-timings dist-newstyle
+```
+
+which will produce `tmp/*.json` files.
+
+Then a csv report can be generated from the json files with
+```
+cabal run benchmark-timings -- tmp/*.json --phase LiquidHaskellCPU -o summary.csv
+```
+On each line, the report will contain the CPU time taken by each test.
+Use `--phase LiquidHaskell` to get the wall-clock time instead. Although in that
+case you need to use the `--measure-timings-j1` option when running the tests,
+which validates modules one at a time.
+
+Comparison charts in `svg` format can be generated by invoking
+
+```
+cabal run plot-performance -- -b path_to_before_summary.csv -a path_to_after_summary.csv -s 50
+```
+
+This will generate two files `top.svg` and `bot.svg` containing the top 50 speedups and slowdowns
+over the entire test set, both enabled by the `-s` option) in the current directory. Alternatively,
+a subset of the tests can be selected by a prefix of their names with `-f <prefix>`, for instance
+`-f benchmarks`. `-f` will generate a file `filtered.svg` containing the comparisons of the selected tests.
+The `-f` and `-s` options can be used/omitted independently. If both are omitted, a single `perf.svg`
+will be produced covering the full input test set. Additionally, their effects can be combined by providing a third `-c`
+option (this  will produce 2 files `filtered-top.svg` and `filtered-bot.svg` instead of 3). An optional key `-o` can be
+supplied to specify an output directory for the generated files.
+
+There is also a legacy script `scripts/plot-performance/chart_perf.sh` that can be used to generate comparison charts
+in both `svg` and `png` formats. It requires [gnuplot](http://www.gnuplot.info/) to run and assumes both files contain
+the same test set. The following command will produce two files `perf.svg` and `perf.png` in the current directory.
+
+    $ scripts/plot-performance/chart_perf.sh path_to_before_summary.csv path_to_after_summary.csv
+
+The current formatting is optimized for comparing some subsets of the full test run, typically just the benchmarks alone.
+If one wishes to save time or is not interested in top speedups/slowdowns, the benchmark subset can be obtained by running
+
+    $ scripts/test/test_plugin.sh \
+        benchmark-stitch-lh \
+        benchmark-bytestring \
+        benchmark-vector-algorithms \
+        benchmark-cse230 \
+        benchmark-esop2013 \
+        benchmark-icfp15-pos \
+        benchmark-icfp15-neg
+
+## Miscelaneous tasks
+
+* **Profiling** See the instructions in [scripts/profiling-driver/ProfilingDriver.hs](scripts/profiling-driver/ProfilingDriver.hs).
+* **Getting stack traces on exceptions** See `-xc` flag in the [GHC user's guide][ghc-users-guide].
+* **Working with submodules** See `man gitsubmodules` or the [git documentation site][git-documentation].
+
+[ghc-users-guide]: https://downloads.haskell.org/ghc/latest/docs/users_guide/
+[git-documentation]: https://git-scm.com/doc
+
+## GHC support policy
+
+LH supports only one version of GHC at any given time. This is because LH depends heavily on the `ghc` library
+and there is currently no distinction between public API's and API's internal to GHC. There are currently no
+release notes for the `ghc` library and breaking changes happen without notice and without deprecation
+periods. Supporting only one GHC version saves developer time because it obviates the need for `#ifdef`'s
+throughout the codebase, or for an compatibility layer that becomes increasingly difficult to write as we
+attempt to support more GHC versions. Porting to newer GHC versions takes less time, the code is easier to
+read and there is less code duplication.
+
+Users of older versions of GHC can still use older versions of LH.
+
+## The GHC.API module
+
+In order to minimize the effort in porting LH to new releases of GHC, we need a way to abstract over breaking
+changes in the `ghc` library, which might change substantially with every major GHC release. This is
+accomplished by the [GHC.API][] module. The idea is that **rather than importing multiple `ghc` modules,
+LH developers must import this single module in order to write future-proof code**. This is especially
+important for versions of the compiler greater than 9, where the module hierarchy changed substantially,
+and using the [GHC.API][] makes it easier to support new versions of GHC when they are released.
+
+### Fragile import strategy
+
+```haskell
+import Predicate
+import TyCoRep
+
+...
+
+-- This will break if 'isEqPrimPred' is (re)moved or the import hierarchy changes.
+foo :: Type -> Bool
+foo = isEqPrimPred
+```
+
+### Recommended import strategy
+
+```haskell
+import qualified Language.Haskell.Liquid.GHC.API as GHC
+
+...
+
+foo :: GHC.Type -> Bool
+foo = GHC.isEqPrimPred -- OK.
+```
+
+# GHC Plugin Development Guide
+
+This code commentary describes the current architecture for the GHC [Plugin][] that enables LiquidHaskell
+to check files as part of the normal compilation process. For the sake of this commentary, we refer to
+the code provided as part of the `release/0.8.10.2` branch, commit `9a2f8284c5fe5b18ed0410e842acd3329a629a6b`.
+
+## GHC.Interface vs GHC.Plugin
+
+The module [GHC.Plugin][] is the main entrypoint for all the plugin functionalities. Whenever possible, this
+module is reusing common functionalities from the [GHC.Interface][], which is the original module used to
+interface LH with the old executable. Generally speaking, the [GHC.Interface][] module is considered "legacy"
+and it's rarely what one wants to modify. It will probably be removed at some point.
+
+## Plugin architecture
+
+Broadly speaking, the Plugin is organised this way: In the [typechecking phase][], we typecheck and desugar
+each module via the GHC API in order to extract the unoptimised [core binds][] that are needed by
+LH to work correctly. This is due to a tension in the design space; from one side LH needs access to the
+"raw" core binds (binds where primitives types are not unboxed in the presence of a PRAGMA annotation,
+for example) but yet the user can specify any arbitrary optimisation settings during compilation and we do
+not want to betray the principle of least expectation by silently compiling the code with `-O0`. Practically
+speaking, this introduces some overhead and is far from ideal, but for now it allows us to iterate quickly.
+This phase is also responsible for:
+
+* Extracting the [BareSpec][]s associated to any of the dependent modules;
+* Producing the [LiftedSpec][] for the currently-compiled module;
+* Storing the [LiftedSpec][] into an interface annotation for later retrieval;
+* Checking and verifying the module using LH's existing API.
+
+The reason why we do everything in the [typechecking phase][] is also to allow integrations with tools like
+[ghcide][]. There are a number of differences between the plugin and the operations performed as part of the
+[GHC.Interface][], which we are going to outline in the next section.
+
+## Differences with the GHC.Interface
+
+- The [GHC.Interface][] pre-processes the input files and calls into [configureGhcTargets][] trying to
+  build a dependency graph by discovering dependencies the target files might require. Then, from this
+  list any file in the include directory is filtered out, as well as any module which has
+  a "fresh" `.bspec` file on disk, to save time during checking. In the [GHC.Plugin][] module though
+  we don't do this and for us, essentially, each input file is considered a target, where we exploit the
+  fact GHC will skip recompilation if unnecessary. This also implies that while the [GHC.Interface][] calls
+  into [processTargetModule][] only for target files, the [GHC.Plugin][] has a single, flat function simply
+  called [processModule][] that essentially does the same as `GHC.Interface.processModule` and
+  `GHC.Interface.processTargetModule` fused together.
+
+- While the [GHC.Interface][] sometimes "assembles" a [BareSpec][] by `mappend`ing the `commSpec` (i.e. comment spec)
+  with the [LiftedSpec][] fetched from disk, if any, the Plugin doesn't do this but rather piggybacks on the
+  [SpecFinder][] (described later) to fetch dependencies' specs.
+
+- There is a difference in how we process LIQUID pragmas. In particular, for the executable they seems to
+  be accumulated "in bulk" i.e. if we are refining a *target* module `A` that depends on `B`, `B` seems to
+  inherit whichever flags we were using in the *target* module `A`. Conversely, the source plugin is "stateless"
+  when it comes to LIQUID options, i.e. it doesn't have memory of _past_ options, what it counts when compiling
+  a module `B` is the _global_ options and _any_ option this module defines. The analogy is exactly the
+  same as with GHC language extensions, they have either global scope (i.e. `default-extensions` in the
+  cabal manifest) or local scope (i.e. `{-# LANGUAGE ... #-}`).
+
+## Finding specs for existing modules
+
+This is all done by a specialised module called the [SpecFinder][]. The main exported function is
+[findRelevantSpecs][] which, given a list of `Module`s, tries to retrieve the `LiftedSpec`s associated with
+them. Typically this is done by looking into the interface files of the input modules, trying to deserialise
+any `LiftedSpec` from the interface file's annotations.
+
+# General Development FAQs
+
+## A new version of GHC is out. How do I support it?
+
+Typically the first thing you might want to do is to run a "clean" `cabal build` using
+the latest compiler and "check the damage". If you are lucky, everything works out of the box, otherwise
+compilation might fail with an error, typically because some `ghc` API function has been removed/moved/renamed.
+The way to fix it is to modify the [GHC.API][] shim module and perform any required change, likely by
+conditionally compiling some code in a `CPP` block. For minor changes, it's usually enough to perform small
+changes, but for more tricky migrations it might be necessary to backport some GHC code, or create some
+patter synonym to deal with changes in type constructors.
+
+## Is there a way to run the testsuite for different versions of GHC?
+
+Currently, no. Only one version of GHC is supported and that is the one
+that can be tested with `./scripts/test/test_plugin.sh`.
+
+[GHC.API]:             liquidhaskell-boot/src-ghc/Liquid/GHC/API.hs
+[Plugin]:              liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Plugin.hs
+[GHC.Plugin]:          liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Plugin.hs
+[GHC.Interface]:       liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Interface.hs
+[SpecFinder]:          liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Plugin/SpecFinder.hs
+[LiftedSpec]:          liquidhaskell-boot/src/Language/Haskell/Liquid/Types/Specs.hs#L559
+[TargetSrc]:           liquidhaskell-boot/src/Language/Haskell/Liquid/Types/Specs.hs#L158
+[typechecking phase]:  liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Plugin.hs#L211-L226
+[ghcide]:              https://github.com/haskell/ghcide
+[findRelevantSpecs]:   liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Plugin/SpecFinder.hs#L65
+[core binds]:          https://hackage.haskell.org/package/ghc-9.6.3/docs/GHC-Core.html#t:CoreBind
+[configureGhcTargets]: liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Interface.hs#L254
+[processTargetModule]: liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Interface.hs#L483
+[processModule]:       liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Plugin.hs#L509
+
+# Module Verification Process
+
+The following graph summarizes the verification process of a module by showing
+its specification life cycle.
+See [Specs.hs](./liquidhaskell-boot/src/Language/Haskell/Liquid/Types/Specs.hs)
+for detailed documentation on the specification stages.
+There are many moving parts hidden within each graph link,
+but some places worth noticing here are
+[Liquid.hs](./liquidhaskell-boot/src/Language/Haskell/Liquid/Liquid.hs)
+—which implements constraint generation— and
+[SpecFinder.hs](./liquidhaskell-boot/src/Language/Haskell/Liquid/Liquid.hs)
+—that deals with the gathering of dependencies and `LHAssumptions`—.
+
+```mermaid
+flowchart LR
+  subgraph Liquid Haskell
+
+    subgraph Inputs
+      direction TB
+      LiftedDeps[
+        Dependencies of A
+        LifttedSpecs
+        ]
+      CoreBinds[CoreBinds]
+      Bare[BarseSpec]
+    end
+
+    subgraph Outputs
+      direction TB
+      T[TargetSpec] --> Constraints[Verification
+                                    Constraints]
+      L[LiftedSpec]
+    end
+
+    Inputs --> Outputs
+
+  end
+
+  A>DepsOfA_LHAssumptions] --> LiftedDeps
+  Deps>DepsOfA.hi] --> LiftedDeps
+  Mod(A.hs) --> CoreBinds & Bare
+  Constraints -->|checked by| fixpoint([liquid-fixpoint])
+  L ---> |if verified:
+           serialize| File>A.hi]
+```
+
+Reference:
+[Implementing a GHC Plugin for Liquid Haskell](https://well-typed.com/blog/2020/08/implementing-a-ghc-plugin-for-liquid-haskell/).
+
+# Sponsors
+
+### [![Zulip logo](https://static.zulipchat.com/static/images/logo/zulip-icon-128x128.png)](https://zulip.com)
+**[Zulip](https://zulip.com)** — Zulip Cloud Standard generously provided free of charge.
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,12 +1,6 @@
-import Distribution.Simple
-
-
+module Main where
 
-main = defaultMain
+import Language.Haskell.Liquid.Cabal (liquidHaskellMain)
 
--- 
--- --- main = defaultMainWithHooks fixpointHooks 
---  
--- fixpointHooks   = defaultUserHooks { postInst = cpFix }
---    where 
---      cpFix _ _ _ lbi = putStrLn $ "CPFIXSAYS: " ++ show lbi  
+main :: IO ()
+main = liquidHaskellMain
diff --git a/devel/Paths_liquidhaskell.hs b/devel/Paths_liquidhaskell.hs
deleted file mode 100644
--- a/devel/Paths_liquidhaskell.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-# LANGUAGE TemplateHaskell #-}
-
-module Paths_liquidhaskell where
-
-import Language.Haskell.TH
-import System.Directory
-import System.FilePath
-import Data.Version (Version, makeVersion)
-
-getDataFileName :: FilePath -> IO FilePath
-getDataFileName f = do
-  let loc = $(do { loc <- location; f <- runIO (canonicalizePath (loc_filename loc)); litE (stringL f); })
-  let root = takeDirectory (takeDirectory loc)
-  return (root </> f)
-
--- | dummy version (devel only)
-version :: Version
-version = makeVersion [0,0,0,0]
diff --git a/exe/Liquid.hs b/exe/Liquid.hs
deleted file mode 100644
--- a/exe/Liquid.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-import Language.Haskell.Liquid.Liquid (liquid)
-import System.Environment             (getArgs)
--- import GhcTest 
-
-main :: IO a
-main = liquid =<< getArgs
diff --git a/include/710/Data/Traversable.spec b/include/710/Data/Traversable.spec
deleted file mode 100644
--- a/include/710/Data/Traversable.spec
+++ /dev/null
@@ -1,3 +0,0 @@
-module spec Data.Traversable where
-
-Data.Traversable.sequence :: Data.Traversable.Traversable t => forall m a. GHC.Base.Monad m => xs:t (m a) -> m ({v:t a | len v = len xs})
diff --git a/include/Bot.hquals b/include/Bot.hquals
deleted file mode 100644
--- a/include/Bot.hquals
+++ /dev/null
@@ -1,8 +0,0 @@
-//BOT: Do not delete EVER!
-
-qualif Bot(v:@(0))    : 0 = 1 
-qualif Bot(v:obj)     : 0 = 1 
-qualif Bot(v:a)       : 0 = 1 
-qualif Bot(v:bool)    : 0 = 1 
-qualif Bot(v:int)     : 0 = 1 
-
diff --git a/include/Control/Exception.spec b/include/Control/Exception.spec
deleted file mode 100644
--- a/include/Control/Exception.spec
+++ /dev/null
@@ -1,5 +0,0 @@
-module spec Control.Exception where
-
-// Useless as compiled into GHC primitive, which is ignored
-assume assert :: {v:Bool | v } -> a -> a
-
diff --git a/include/Control/Parallel/Strategies.spec b/include/Control/Parallel/Strategies.spec
deleted file mode 100644
--- a/include/Control/Parallel/Strategies.spec
+++ /dev/null
@@ -1,3 +0,0 @@
-module spec Control.Parallel.Strategies where
-
-assume withStrategy :: Control.Parallel.Strategies.Strategy a -> x:a -> {v:a | v == x}
diff --git a/include/CoreToLogic.lg b/include/CoreToLogic.lg
deleted file mode 100644
--- a/include/CoreToLogic.lg
+++ /dev/null
@@ -1,47 +0,0 @@
-define Data.Set.Base.singleton x      = (Set_sng x)
-define Data.Set.Base.union x y        = (Set_cup x y)
-define Data.Set.Base.intersection x y = (Set_cap x y)
-define Data.Set.Base.difference x y   = (Set_dif x y)
-define Data.Set.Base.empty            = (Set_empty 0)
-define Data.Set.Base.null x           = (Set_emp x)
-define Data.Set.Base.member x xs      = (Set_mem x xs)
-define Data.Set.Base.isSubsetOf x y   = (Set_sub x y)
-define Data.Set.Base.fromList xs      = (listElts xs)
-
-define Data.Set.Internal.singleton x      = (Set_sng x)
-define Data.Set.Internal.union x y        = (Set_cup x y)
-define Data.Set.Internal.intersection x y = (Set_cap x y)
-define Data.Set.Internal.difference x y   = (Set_dif x y)
-define Data.Set.Internal.empty            = (Set_empty 0)
-define Data.Set.Internal.null x           = (Set_emp x)
-define Data.Set.Internal.member x xs      = (Set_mem x xs)
-define Data.Set.Internal.isSubsetOf x y   = (Set_sub x y)
-define Data.Set.Internal.fromList xs      = (listElts xs)
-
-define GHC.Real.fromIntegral x = (x)
-
-define GHC.Types.True                 = (true)
-define GHC.Real.div x y               = (x / y)
-define GHC.Real.mod x y               = (x mod y)
-define GHC.Base.$ f x                 = (f x)
-
-define Language.Haskell.Liquid.Bag.get k m   = (Map_select m k)
-define Language.Haskell.Liquid.Bag.put k m   = (Map_store m k (1 + (Map_select m k)))
-define Language.Haskell.Liquid.Bag.union m n = (Map_union  m n)
-define Language.Haskell.Liquid.Bag.empty     = (Map_default 0)
-
-define Data.Map.Base.insert k v m     = (Map_store m k v)
-define Data.Map.Base.select k v       = (Map_select m k)
-
-define Language.Haskell.Liquid.String.stringEmp = (stringEmp)
-define Data.RString.RString.stringEmp = (stringEmp)
-define String.stringEmp  = (stringEmp)
-define Main.mempty       = (mempty)
-define Language.Haskell.Liquid.ProofCombinators.cast x y = (y)
-define ProofCombinators.cast x y = (y)
-define Control.Parallel.Strategies.withStrategy s x = (x)
-
-define ProofCombinators.cast x y = (y)
-define Language.Haskell.Liquid.Equational.eq x y = (y)
-
-define GHC.CString.unpackCString# x = x
diff --git a/include/Data/Bits.spec b/include/Data/Bits.spec
deleted file mode 100644
--- a/include/Data/Bits.spec
+++ /dev/null
@@ -1,6 +0,0 @@
-module spec Data.Bits where
-
-// TODO: cannot use this because `Bits` is not a `Num`
-// Data.Bits.shiftR :: (Data.Bits.Bits a) => x:a -> d:Nat 
-//                  -> {v:a | ((d=1) => (x <= 2*v + 1 && 2*v <= x)) }
-
diff --git a/include/Data/ByteString.spec b/include/Data/ByteString.spec
deleted file mode 100644
--- a/include/Data/ByteString.spec
+++ /dev/null
@@ -1,375 +0,0 @@
-module spec Data.ByteString where
-
-import Data.String
-
-measure bslen :: Data.ByteString.ByteString -> { n : Int | 0 <= n }
-
-invariant { bs : Data.ByteString.ByteString  | 0 <= bslen bs }
-
-invariant { bs : Data.ByteString.ByteString | bslen bs == stringlen bs }
-
-empty :: { bs : Data.ByteString.ByteString | bslen bs == 0 }
-
-singleton :: _ -> { bs : Data.ByteString.ByteString | bslen bs == 1 }
-
-pack :: w8s : [_]
-     -> { bs : Data.ByteString.ByteString | bslen bs == len w8s }
-
-unpack :: bs : Data.ByteString.ByteString
-       -> { w8s : [_] | len w8s == bslen bs }
-
-cons :: _
-     -> i : Data.ByteString.ByteString
-     -> { o : Data.ByteString.ByteString | bslen o == bslen i + 1 }
-
-snoc :: i : Data.ByteString.ByteString
-     -> _
-     -> { o : Data.ByteString.ByteString | bslen o == bslen i + 1 }
-
-append :: l : Data.ByteString.ByteString
-       -> r : Data.ByteString.ByteString
-       -> { o : Data.ByteString.ByteString | bslen o == bslen l + bslen r }
-
-head :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> _
-
-unsnoc :: i:Data.ByteString.ByteString 
-       -> (Maybe ({ o : Data.ByteString.ByteString | bslen o == bslen i - 1 }, _))
-
-last :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> _
-
-tail :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> _
-
-init 
-  :: {i:Data.ByteString.ByteString | 1 <= bslen i } 
-  -> {o:Data.ByteString.ByteString | bslen o == bslen i - 1 }
-
-null 
-  :: bs : Data.ByteString.ByteString
-  -> { b : GHC.Types.Bool | b <=> bslen bs == 0 }
-
-length :: bs : Data.ByteString.ByteString -> { n : Int | bslen bs == n }
-
-map 
-  :: (_ -> _)
-  -> i : Data.ByteString.ByteString
-  -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-reverse 
-  :: i : Data.ByteString.ByteString
-  -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-intersperse 
-  :: _
-  -> i : Data.ByteString.ByteString
-  -> { o : Data.ByteString.ByteString | (bslen i == 0 <=> bslen o == 0) && (1 <= bslen i <=> bslen o == 2 * bslen i - 1) }
-
-intercalate 
-  :: l : Data.ByteString.ByteString
-  -> rs : [Data.ByteString.ByteString]
-  -> { o : Data.ByteString.ByteString | len rs == 0 ==> bslen o == 0 }
-
-transpose 
-  :: is : [Data.ByteString.ByteString]
-  -> { os : [{ bs : Data.ByteString.ByteString | bslen bs <= len is }] | len is == 0 ==> len os == 0}
-
-foldl1 
-  :: (_ -> _ -> _)
-  -> { bs : Data.ByteString.ByteString | 1 <= bslen bs }
-  -> _
-
-foldl1' 
-  :: (_ -> _ -> _)
-  -> { bs : Data.ByteString.ByteString | 1 <= bslen bs }
-  -> _
-
-foldr1 
-  :: (_ -> _ -> _)
-  -> { bs : Data.ByteString.ByteString | 1 <= bslen bs }
-  -> _
-
-foldr1' 
-  :: (_ -> _ -> _)
-  -> { bs : Data.ByteString.ByteString | 1 <= bslen bs }
-  -> _
-
-concat 
-  :: is : [Data.ByteString.ByteString] 
-  -> { o : Data.ByteString.ByteString | (len is == 0) ==> (bslen o == 0) }
-
-concatMap 
-  :: (_ -> Data.ByteString.ByteString)
-  -> i : Data.ByteString.ByteString
-  -> { o : Data.ByteString.ByteString | bslen i == 0 ==> bslen o == 0 }
-
-any 
-  :: (_ -> GHC.Types.Bool)
-  -> bs : Data.ByteString.ByteString
-  -> { b : GHC.Types.Bool | bslen bs == 0 ==> not b }
-
-all 
-  :: (_ -> GHC.Types.Bool)
-  -> bs : Data.ByteString.ByteString
-  -> { b : GHC.Types.Bool | bslen bs == 0 ==> b }
-
-maximum :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> _
-
-minimum :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> _
-
-scanl :: (_ -> _ -> _)
-      -> _
-      -> i : Data.ByteString.ByteString
-      -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-scanl1 :: (_ -> _ -> _)
-       -> i : { i : Data.ByteString.ByteString | 1 <= bslen i }
-       -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-scanr
-    :: (_ -> _ -> _)
-    -> _
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-scanr1
-    :: (_ -> _ -> _)
-    -> i : { i : Data.ByteString.ByteString | 1 <= bslen i }
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-mapAccumL
-    :: (acc -> _ -> (acc, _))
-    -> acc
-    -> i : Data.ByteString.ByteString
-    -> (acc, { o : Data.ByteString.ByteString | bslen o == bslen i })
-
-mapAccumR
-    :: (acc -> _ -> (acc, _))
-    -> acc
-    -> i : Data.ByteString.ByteString
-    -> (acc, { o : Data.ByteString.ByteString | bslen o == bslen i })
-
-replicate
-    :: n : Int
-    -> _
-    -> { bs : Data.ByteString.ByteString | bslen bs == n }
-
-unfoldrN
-    :: n : Int
-    -> (a -> Maybe (_, a))
-    -> a
-    -> ({ bs : Data.ByteString.ByteString | bslen bs <= n }, Maybe a)
-
-take
-    :: n : Int
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | (n <= 0 <=> bslen o == 0) &&
-                                          ((0 <= n && n <= bslen i) <=> bslen o == n) &&
-                                          (bslen i <= n <=> bslen o = bslen i) }
-
-drop
-    :: n : Int
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | (n <= 0 <=> bslen o == bslen i) &&
-                                          ((0 <= n && n <= bslen i) <=> bslen o == bslen i - n) &&
-                                          (bslen i <= n <=> bslen o == 0) }
-
-splitAt
-    :: n : Int
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | (n <= 0 <=> bslen l == 0) &&
-                                            ((0 <= n && n <= bslen i) <=> bslen l == n) &&
-                                            (bslen i <= n <=> bslen l == bslen i) }
-       , { r : Data.ByteString.ByteString | (n <= 0 <=> bslen r == bslen i) &&
-                                            ((0 <= n && n <= bslen i) <=> bslen r == bslen i - n) &&
-                                            (bslen i <= n <=> bslen r == 0) }
-       )
-
-takeWhile
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o <= bslen i }
-
-dropWhile
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o <= bslen i }
-
-span
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       )
-
-spanEnd
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       )
-
-break
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       )
-
-breakEnd
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       )
-
-group
-    :: i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | 1 <= bslen o && bslen o <= bslen i }]
-
-groupBy
-    :: (_ -> _ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | 1 <= bslen o && bslen o <= bslen i }]
-
-inits
-    :: i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-tails
-    :: i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-split
-    :: _
-    -> i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-splitWith
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-isPrefixOf
-    :: l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen l >= bslen r ==> not b }
-
-isSuffixOf
-    :: l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen l > bslen r ==> not b }
-
-isInfixOf
-    :: l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen l > bslen r ==> not b }
-
-breakSubstring
-    :: il : Data.ByteString.ByteString
-    -> ir : Data.ByteString.ByteString
-    -> ( { ol : Data.ByteString.ByteString | bslen ol <= bslen ir && (bslen il > bslen ir ==> bslen ol == bslen ir)}
-       , { or : Data.ByteString.ByteString | bslen or <= bslen ir && (bslen il > bslen ir ==> bslen or == 0) }
-       )
-
-elem
-    :: _
-    -> bs : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen bs == 0 ==> not b }
-
-notElem
-    :: _
-    -> bs : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen bs == 0 ==> b }
-
-find
-    :: (_ -> GHC.Types.Bool)
-    -> bs : Data.ByteString.ByteString
-    -> (Maybe { w8 : _ | bslen bs /= 0 })
-
-filter
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o <= bslen i }
-
-partition
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       )
-
-index :: bs : Data.ByteString.ByteString -> { n : Int | 0 <= n && n < bslen bs } -> _
-
-elemIndex
-    :: _
-    -> bs : Data.ByteString.ByteString
-    -> (Maybe { n : Int | 0 <= n && n < bslen bs })
-
-elemIndices
-    :: _
-    -> bs : Data.ByteString.ByteString
-    -> [{ n : Int | 0 <= n && n < bslen bs }]
-
-elemIndexEnd
-    :: _
-    -> bs : Data.ByteString.ByteString
-    -> (Maybe { n : Int | 0 <= n && n < bslen bs })
-
-findIndex
-    :: (_ -> GHC.Types.Bool)
-    -> bs : Data.ByteString.ByteString
-    -> (Maybe { n : Int | 0 <= n && n < bslen bs })
-
-findIndices
-    :: (_ -> GHC.Types.Bool)
-    -> bs : Data.ByteString.ByteString
-    -> [{ n : Int | 0 <= n && n < bslen bs }]
-
-count
-    :: _
-    -> bs : Data.ByteString.ByteString
-    -> { n : Int | 0 <= n && n < bslen bs }
-
-zip
-    :: l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { o : [(_, _)] | len o <= bslen l && len o <= bslen r }
-
-zipWith
-    :: (_ -> _ -> a)
-    -> l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { o : [a] | len o <= bslen l && len o <= bslen r }
-
-unzip
-    :: i : [(_, _)]
-    -> ( { l : Data.ByteString.ByteString | bslen l == len i }
-       , { r : Data.ByteString.ByteString | bslen r == len i }
-       )
-
-sort
-    :: i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-copy
-    :: i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-hGet
-    :: _
-    -> n : { n : Int | 0 <= n }
-    -> (IO { bs : Data.ByteString.ByteString | bslen bs == n || bslen bs == 0 })
-
-hGetSome
-    :: _
-    -> n : { n : Int | 0 <= n }
-    -> (IO { bs : Data.ByteString.ByteString | bslen bs <= n })
-
-hGetNonBlocking
-    :: _
-    -> n : { n : Int | 0 <= n }
-    -> (IO { bs : Data.ByteString.ByteString | bslen bs <= n })
-
-uncons
-    :: i : Data.ByteString.ByteString
-    -> (Maybe (_, { o : Data.ByteString.ByteString | bslen o == bslen i - 1 }))
-    
diff --git a/include/Data/ByteString/Char8.spec b/include/Data/ByteString/Char8.spec
deleted file mode 100644
--- a/include/Data/ByteString/Char8.spec
+++ /dev/null
@@ -1,402 +0,0 @@
-module spec Data.ByteString.Char8 where
-
-import Data.ByteString 
-
-assume empty :: { bs : Data.ByteString.ByteString | bslen bs == 0 }
-
-assume singleton
-    :: Char -> { bs : Data.ByteString.ByteString | bslen bs == 1 }
-
-assume pack
-    :: w8s : [Char]
-    -> { bs : Data.ByteString.ByteString | bslen bs == len w8s }
-
-assume unpack
-    :: bs : Data.ByteString.ByteString
-    -> { w8s : [Char] | len w8s == bslen bs }
-
-assume cons
-    :: Char
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i + 1 }
-
-assume snoc
-    :: i : Data.ByteString.ByteString
-    -> Char
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i + 1 }
-
-assume append
-    :: l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen l + bslen r }
-
-head :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> Char
-
-assume uncons
-    :: i : Data.ByteString.ByteString
-    -> Maybe (Char, { o : Data.ByteString.ByteString | bslen o == bslen i - 1 })
-
-assume unsnoc
-    :: i : Data.ByteString.ByteString
-    -> Maybe ({ o : Data.ByteString.ByteString | bslen o == bslen i - 1 }, Char)
-
-assume last :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> Char
-
-assume tail :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> Char
-
-assume init :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> Char
-
-assume null
-    :: bs : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | b <=> bslen bs == 0 }
-
-assume length :: bs : Data.ByteString.ByteString -> { n : Int | bslen bs == n }
-
-assume map
-    :: (Char -> Char)
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-assume reverse
-    :: i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-assume intersperse
-    :: Char
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | (bslen i == 0 <=> bslen o == 0) && (1 <= bslen i <=> bslen o == 2 * bslen i - 1) }
-
-assume intercalate
-    :: l : Data.ByteString.ByteString
-    -> rs : [Data.ByteString.ByteString]
-    -> { o : Data.ByteString.ByteString | len rs == 0 ==> bslen o == 0 }
-
-assume transpose
-    :: is : [Data.ByteString.ByteString]
-    -> { os : [{ bs : Data.ByteString.ByteString | bslen bs <= len is }] | len is == 0 ==> len os == 0}
-
-foldl1
-    :: (Char -> Char -> Char)
-    -> { bs : Data.ByteString.ByteString | 1 <= bslen bs }
-    -> Char
-
-foldl1'
-    :: (Char -> Char -> Char)
-    -> { bs : Data.ByteString.ByteString | 1 <= bslen bs }
-    -> Char
-
-foldr1
-    :: (Char -> Char -> Char)
-    -> { bs : Data.ByteString.ByteString | 1 <= bslen bs }
-    -> Char
-
-foldr1'
-    :: (Char -> Char -> Char)
-    -> { bs : Data.ByteString.ByteString | 1 <= bslen bs }
-    -> Char
-
-assume concat
-    :: is : [Data.ByteString.ByteString]
-    -> { o : Data.ByteString.ByteString | len is == 0 ==> bslen o }
-
-assume concatMap
-    :: (Char -> Data.ByteString.ByteString)
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen i == 0 ==> bslen o == 0 }
-
-assume any :: (Char -> GHC.Types.Bool)
-    -> bs : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen bs == 0 ==> not b }
-
-assume all :: (Char -> GHC.Types.Bool)
-    -> bs : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen bs == 0 ==> b }
-
-maximum
-    :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> Char
-
-minimum
-    :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> Char
-
-assume scanl
-    :: (Char -> Char -> Char)
-    -> Char
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-assume scanl1
-    :: (Char -> Char -> Char)
-    -> i : { i : Data.ByteString.ByteString | 1 <= bslen i }
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-assume scanr
-    :: (Char -> Char -> Char)
-    -> Char
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-assume scanr1
-    :: (Char -> Char -> Char)
-    -> i : { i : Data.ByteString.ByteString | 1 <= bslen i }
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-assume mapAccumL
-    :: (acc -> Char -> (acc, Char))
-    -> acc
-    -> i : Data.ByteString.ByteString
-    -> (acc, { o : Data.ByteString.ByteString | bslen o == bslen i })
-
-assume mapAccumR
-    :: (acc -> Char -> (acc, Char))
-    -> acc
-    -> i : Data.ByteString.ByteString
-    -> (acc, { o : Data.ByteString.ByteString | bslen o == bslen i })
-
-assume replicate
-    :: n : Int
-    -> Char
-    -> { bs : Data.ByteString.ByteString | bslen bs == n }
-
-assume unfoldrN
-    :: n : Int
-    -> (a -> Maybe (Char, a))
-    -> a
-    -> ({ bs : Data.ByteString.ByteString | bslen bs <= n }, Maybe a)
-
-assume take
-    :: n : Int
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | (n <= 0 <=> bslen o == 0) &&
-                                          ((0 <= n && n <= bslen i) <=> bslen o == n) &&
-                                          (bslen i <= n <=> bslen o = bslen i) }
-
-assume drop
-    :: n : Int
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | (n <= 0 <=> bslen o == bslen i) &&
-                                          ((0 <= n && n <= bslen i) <=> bslen o == bslen i - n) &&
-                                          (bslen i <= n <=> bslen o == 0) }
-
-assume splitAt
-    :: n : Int
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | (n <= 0 <=> bslen l == 0) &&
-                                            ((0 <= n && n <= bslen i) <=> bslen l == n) &&
-                                            (bslen i <= n <=> bslen l == bslen i) }
-       , { r : Data.ByteString.ByteString | (n <= 0 <=> bslen r == bslen i) &&
-                                            ((0 <= n && n <= bslen i) <=> bslen r == bslen i - n) &&
-                                            (bslen i <= n <=> bslen r == 0) }
-       )
-
-assume takeWhile
-    :: (Char -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o <= bslen i }
-
-assume dropWhile
-    :: (Char -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o <= bslen i }
-
-assume span
-    :: (Char -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       )
-
-assume spanEnd
-    :: (Char -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       )
-
-assume break
-    :: (Char -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       )
-
-assume breakEnd
-    :: (Char -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       )
-
-assume group
-    :: i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | 1 <= bslen o && bslen o <= bslen i }]
-
-assume groupBy
-    :: (Char -> Char -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | 1 <= bslen o && bslen o <= bslen i }]
-
-assume inits
-    :: i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-assume tails
-    :: i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-assume split
-    :: Char
-    -> i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-assume splitWith
-    :: (Char -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-assume lines
-    :: i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-assume words
-    :: i : Data.ByteString.ByteString
-    -> [{ o : Data.ByteString.ByteString | bslen o <= bslen i }]
-
-assume unlines
-    :: is : [Data.ByteString.ByteString]
-    -> { o : Data.ByteString.ByteString | (len is == 0 <=> bslen o == 0) && bslen o >= len is }
-
-assume unwords
-    :: is : [Data.ByteString.ByteString]
-    -> { o : Data.ByteString.ByteString | (len is == 0 ==> bslen o == 0) && (1 <= len is ==> bslen o >= len is - 1) }
-
-assume isPrefixOf
-    :: l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen l >= bslen r ==> not b }
-
-assume isSuffixOf
-    :: l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen l > bslen r ==> not b }
-
-assume isInfixOf
-    :: l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen l > bslen r ==> not b }
-
-assume breakSubstring
-    :: il : Data.ByteString.ByteString
-    -> ir : Data.ByteString.ByteString
-    -> ( { ol : Data.ByteString.ByteString | bslen ol <= bslen ir && (bslen il > bslen ir ==> bslen ol == bslen ir)}
-       , { or : Data.ByteString.ByteString | bslen or <= bslen ir && (bslen il > bslen ir ==> bslen or == 0) }
-       )
-
-assume elem
-    :: Char
-    -> bs : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen bs == 0 ==> not b }
-
-assume notElem
-    :: Char
-    -> bs : Data.ByteString.ByteString
-    -> { b : GHC.Types.Bool | bslen bs == 0 ==> b }
-
-assume find
-    :: (Char -> GHC.Types.Bool)
-    -> bs : Data.ByteString.ByteString
-    -> Maybe { w8 : Char | bslen bs /= 0 }
-
-assume filter
-    :: (Char -> GHC.Types.Bool)
-    -> i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o <= bslen i }
-
-index
-    :: bs : Data.ByteString.ByteString
-    -> { n : Int | 0 <= n && n < bslen bs }
-    -> Char
-
-assume elemIndex
-    :: Char
-    -> bs : Data.ByteString.ByteString
-    -> Maybe { n : Int | 0 <= n && n < bslen bs }
-
-assume elemIndices
-    :: Char
-    -> bs : Data.ByteString.ByteString
-    -> [{ n : Int | 0 <= n && n < bslen bs }]
-
-assume elemIndexEnd
-    :: Char
-    -> bs : Data.ByteString.ByteString
-    -> Maybe { n : Int | 0 <= n && n < bslen bs }
-
-assume findIndex
-    :: (Char -> GHC.Types.Bool)
-    -> bs : Data.ByteString.ByteString
-    -> Maybe { n : Int | 0 <= n && n < bslen bs }
-
-assume findIndices
-    :: (Char -> GHC.Types.Bool)
-    -> bs : Data.ByteString.ByteString
-    -> [{ n : Int | 0 <= n && n < bslen bs }]
-
-assume count
-    :: Char
-    -> bs : Data.ByteString.ByteString
-    -> { n : Int | 0 <= n && n < bslen bs }
-
-assume zip
-    :: l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { o : [(Char, Char)] | len o <= bslen l && len o <= bslen r }
-
-assume zipWith
-    :: (Char -> Char -> a)
-    -> l : Data.ByteString.ByteString
-    -> r : Data.ByteString.ByteString
-    -> { o : [a] | len o <= bslen l && len o <= bslen r }
-
-assume unzip
-    :: i : [(Char, Char)]
-    -> ( { l : Data.ByteString.ByteString | bslen l == len i }
-       , { r : Data.ByteString.ByteString | bslen r == len i }
-       )
-
-assume sort
-    :: i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-assume readInt
-    :: i : Data.ByteString.ByteString
-    -> Maybe { p : (Int, { o : Data.ByteString.ByteString | bslen o < bslen i}) | bslen i /= 0 }
-
-assume readInteger
-    :: i : Data.ByteString.ByteString
-    -> Maybe { p : (Integer, { o : Data.ByteString.ByteString | bslen o < bslen i}) | bslen i /= 0 }
-
-assume copy
-    :: i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i }
-
-assume hGet
-    :: System.IO.Handle
-    -> n : { n : Int | 0 <= n }
-    -> IO { bs : Data.ByteString.ByteString | bslen bs == n || bslen bs == 0 }
-
-assume hGetSome
-    :: System.IO.Handle
-    -> n : { n : Int | 0 <= n }
-    -> IO { bs : Data.ByteString.ByteString | bslen bs <= n }
-
-assume hGetNonBlocking
-    :: System.IO.Handle
-    -> n : { n : Int | 0 <= n }
-    -> IO { bs : Data.ByteString.ByteString | bslen bs <= n }
-
-// assume partition
-    // :: (Char -> GHC.Types.Bool)
-    // -> i : Data.ByteString.ByteString
-    // -> ( { l : Data.ByteString.ByteString | bslen l <= bslen i }
-       // , { r : Data.ByteString.ByteString | bslen r <= bslen i }
-       // )
diff --git a/include/Data/ByteString/Lazy.spec b/include/Data/ByteString/Lazy.spec
deleted file mode 100644
--- a/include/Data/ByteString/Lazy.spec
+++ /dev/null
@@ -1,338 +0,0 @@
-module spec Data.ByteString.Lazy where
-
-import Data.String
-import Data.ByteString
-
-measure bllen :: Data.ByteString.Lazy.ByteString -> { n : GHC.Int.Int64 | 0 <= n }
-
-invariant { bs : Data.ByteString.Lazy.ByteString | 0 <= bllen bs }
-
-invariant { bs : Data.ByteString.Lazy.ByteString | bllen bs == stringlen bs }
-
-assume empty :: { bs : Data.ByteString.Lazy.ByteString | bllen bs == 0 }
-
-assume singleton
-    :: _ -> { bs : Data.ByteString.Lazy.ByteString | bllen bs == 1 }
-
-assume pack
-    :: w8s : [_]
-    -> { bs : _ | bllen bs == len w8s }
-
-assume unpack
-    :: bs : Data.ByteString.Lazy.ByteString
-    -> { w8s : [_] | len w8s == bllen bs }
-
-assume fromStrict
-    :: i : Data.ByteString.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o == bslen i }
-
-assume toStrict
-    :: i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.ByteString | bslen o == bllen i }
-
-assume fromChunks
-    :: i : [Data.ByteString.ByteString]
-    -> { o : Data.ByteString.Lazy.ByteString | len i == 0 <=> bllen o == 0 }
-
-assume toChunks
-    :: i : Data.ByteString.Lazy.ByteString
-    -> { os : [{ o : Data.ByteString.ByteString | bslen o <= bllen i}] | len os == 0 <=> bllen i == 0 }
-
-assume cons
-    :: _
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o == bllen i + 1 }
-
-assume snoc
-    :: i : Data.ByteString.Lazy.ByteString
-    -> _
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o == bllen i + 1 }
-
-assume append
-    :: l : Data.ByteString.Lazy.ByteString
-    -> r : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o == bllen l + bllen r }
-
-assume head
-    :: { bs : Data.ByteString.Lazy.ByteString | 1 <= bllen bs }
-    -> _
-
-assume uncons
-    :: i : Data.ByteString.Lazy.ByteString
-    -> Maybe (_, { o : Data.ByteString.Lazy.ByteString | bllen o == bllen i - 1 })
-
-assume unsnoc
-    :: i : Data.ByteString.Lazy.ByteString
-    -> Maybe ({ o : Data.ByteString.Lazy.ByteString | bllen o == bllen i - 1 }, _)
-
-assume last :: { bs : Data.ByteString.Lazy.ByteString | 1 <= bllen bs } -> _
-
-assume tail :: { bs : Data.ByteString.Lazy.ByteString | 1 <= bllen bs } -> _
-
-assume init :: { bs : Data.ByteString.Lazy.ByteString | 1 <= bllen bs } -> _
-
-assume null :: bs : Data.ByteString.Lazy.ByteString -> { b : GHC.Types.Bool | b <=> bllen bs == 0 }
-
-assume length
-    :: bs : Data.ByteString.Lazy.ByteString -> { n : GHC.Int.Int64 | bllen bs == n }
-
-assume map
-    :: (_ -> _)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o == bllen i }
-
-assume reverse
-    :: i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o == bllen i }
-
-assume intersperse
-    :: _
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | (bllen i == 0 <=> bllen o == 0) && (1 <= bllen i <=> bllen o == 2 * bllen i - 1) }
-
-assume intercalate
-    :: l : Data.ByteString.Lazy.ByteString
-    -> rs : [Data.ByteString.Lazy.ByteString]
-    -> { o : Data.ByteString.Lazy.ByteString | len rs == 0 ==> bllen o == 0 }
-
-assume transpose
-    :: is : [Data.ByteString.Lazy.ByteString]
-    -> { os : [{ bs : Data.ByteString.Lazy.ByteString | bllen bs <= len is }] | len is == 0 ==> len os == 0}
-
-assume foldl1
-    :: (_ -> _ -> _)
-    -> { bs : Data.ByteString.Lazy.ByteString | 1 <= bllen bs }
-    -> _
-
-assume foldl1'
-    :: (_ -> _ -> _)
-    -> { bs : Data.ByteString.Lazy.ByteString | 1 <= bllen bs }
-    -> _
-
-assume foldr1
-    :: (_ -> _ -> _)
-    -> { bs : Data.ByteString.Lazy.ByteString | 1 <= bllen bs }
-    -> _
-
-assume concat
-    :: is : [Data.ByteString.Lazy.ByteString]
-    -> { o : Data.ByteString.Lazy.ByteString | (len is == 0) ==> (bllen o == 0) }
-
-assume concatMap
-    :: (_ -> Data.ByteString.Lazy.ByteString)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen i == 0 ==> bllen o == 0 }
-
-assume any :: (_ -> GHC.Types.Bool)
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> { b : GHC.Types.Bool | bllen bs == 0 ==> not b }
-
-assume all :: (_ -> GHC.Types.Bool)
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> { b : GHC.Types.Bool | bllen bs == 0 ==> b }
-
-assume maximum :: { bs : Data.ByteString.Lazy.ByteString | 1 <= bllen bs } -> _
-
-assume minimum :: { bs : Data.ByteString.Lazy.ByteString | 1 <= bllen bs } -> _
-
-assume scanl
-    :: (_ -> _ -> _)
-    -> _
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o == bllen i }
-
-assume mapAccumL
-    :: (acc -> _ -> (acc, _))
-    -> acc
-    -> i : Data.ByteString.Lazy.ByteString
-    -> (acc, { o : Data.ByteString.Lazy.ByteString | bllen o == bllen i })
-
-assume mapAccumR
-    :: (acc -> _ -> (acc, _))
-    -> acc
-    -> i : Data.ByteString.Lazy.ByteString
-    -> (acc, { o : Data.ByteString.Lazy.ByteString | bllen o == bllen i })
-
-assume replicate
-    :: n : GHC.Int.Int64
-    -> _
-    -> { bs : Data.ByteString.Lazy.ByteString | bllen bs == n }
-
-assume take
-    :: n : GHC.Int.Int64
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | (n <= 0 ==> bllen o == 0) &&
-                                               ((0 <= n && n <= bllen i) <=> bllen o == n) &&
-                                               (bllen i <= n <=> bllen o = bllen i) }
-
-assume drop
-    :: n : GHC.Int.Int64
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | (n <= 0 <=> bllen o == bllen i) &&
-                                               ((0 <= n && n <= bllen i) <=> bllen o == bllen i - n) &&
-                                               (bllen i <= n <=> bllen o == 0) }
-
-assume splitAt
-    :: n : GHC.Int.Int64
-    -> i : Data.ByteString.Lazy.ByteString
-    -> ( { l : Data.ByteString.Lazy.ByteString | (n <= 0 <=> bllen l == 0) &&
-                                                 ((0 <= n && n <= bllen i) <=> bllen l == n) &&
-                                                 (bllen i <= n <=> bllen l == bllen i) }
-       , { r : Data.ByteString.Lazy.ByteString | (n <= 0 <=> bllen r == bllen i) &&
-                                                 ((0 <= n && n <= bllen i) <=> bllen r == bllen i - n) &&
-                                                 (bllen i <= n <=> bllen r == 0) }
-       )
-
-assume takeWhile
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o <= bllen i }
-
-assume dropWhile
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o <= bllen i }
-
-assume span
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> ( { l : Data.ByteString.Lazy.ByteString | bllen l <= bllen i }
-       , { r : Data.ByteString.Lazy.ByteString | bllen r <= bllen i }
-       )
-
-assume break
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> ( { l : Data.ByteString.Lazy.ByteString | bllen l <= bllen i }
-       , { r : Data.ByteString.Lazy.ByteString | bllen r <= bllen i }
-       )
-
-assume group
-    :: i : Data.ByteString.Lazy.ByteString
-    -> [{ o : Data.ByteString.Lazy.ByteString | 1 <= bllen o && bllen o <= bllen i }]
-
-assume groupBy
-    :: (_ -> _ -> GHC.Types.Bool)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> [{ o : Data.ByteString.Lazy.ByteString | 1 <= bllen o && bllen o <= bllen i }]
-
-assume inits
-    :: i : Data.ByteString.Lazy.ByteString
-    -> [{ o : Data.ByteString.Lazy.ByteString | bllen o <= bllen i }]
-
-assume tails
-    :: i : Data.ByteString.Lazy.ByteString
-    -> [{ o : Data.ByteString.Lazy.ByteString | bllen o <= bllen i }]
-
-assume split
-    :: _
-    -> i : Data.ByteString.Lazy.ByteString
-    -> [{ o : Data.ByteString.Lazy.ByteString | bllen o <= bllen i }]
-
-assume splitWith
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> [{ o : Data.ByteString.Lazy.ByteString | bllen o <= bllen i }]
-
-assume isPrefixOf
-    :: l : Data.ByteString.Lazy.ByteString
-    -> r : Data.ByteString.Lazy.ByteString
-    -> { b : GHC.Types.Bool | bllen l >= bllen r ==> not b }
-
-assume isSuffixOf
-    :: l : Data.ByteString.Lazy.ByteString
-    -> r : Data.ByteString.Lazy.ByteString
-    -> { b : GHC.Types.Bool | bllen l >= bllen r ==> not b }
-
-assume elem
-    :: _
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> { b : GHC.Types.Bool | (bllen bs == 0) ==> not b }
-
-assume notElem
-    :: _
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> { b : GHC.Types.Bool | (bllen bs == 0) ==> b }
-
-assume find
-    :: (_ -> GHC.Types.Bool)
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> Maybe { w8 : _ | bllen bs /= 0 }
-
-assume filter
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o <= bllen i }
-
-assume partition
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.ByteString.Lazy.ByteString
-    -> ( { l : Data.ByteString.Lazy.ByteString | bllen l <= bllen i }
-       , { r : Data.ByteString.Lazy.ByteString | bllen r <= bllen i }
-       )
-
-assume index
-    :: bs : Data.ByteString.Lazy.ByteString
-    -> { n : GHC.Int.Int64 | 0 <= n && n < bllen bs }
-    -> _
-
-assume elemIndex
-    :: _
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> Maybe { n : GHC.Int.Int64 | 0 <= n && n < bllen bs }
-
-assume elemIndices
-    :: _
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> [{ n : GHC.Int.Int64 | 0 <= n && n < bllen bs }]
-
-assume elemIndexEnd
-    :: _
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> Maybe { n : GHC.Int.Int64 | 0 <= n && n < bllen bs }
-
-assume findIndex
-    :: (_ -> GHC.Types.Bool)
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> Maybe { n : GHC.Int.Int64 | 0 <= n && n < bllen bs }
-
-assume findIndices
-    :: (_ -> GHC.Types.Bool)
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> [{ n : GHC.Int.Int64 | 0 <= n && n < bllen bs }]
-
-assume count
-    :: _
-    -> bs : Data.ByteString.Lazy.ByteString
-    -> { n : GHC.Int.Int64 | 0 <= n && n < bllen bs }
-
-assume zip
-    :: l : Data.ByteString.Lazy.ByteString
-    -> r : Data.ByteString.Lazy.ByteString
-    -> { o : [(_, _)] | len o <= bllen l && len o <= bllen r }
-
-assume zipWith
-    :: (_ -> _ -> a)
-    -> l : Data.ByteString.Lazy.ByteString
-    -> r : Data.ByteString.Lazy.ByteString
-    -> { o : [a] | len o <= bllen l && len o <= bllen r }
-
-assume unzip
-    :: i : [(_, _)]
-    -> ( { l : Data.ByteString.Lazy.ByteString | bllen l == len i }
-       , { r : Data.ByteString.Lazy.ByteString | bllen r == len i }
-       )
-
-assume copy
-    :: i : Data.ByteString.Lazy.ByteString
-    -> { o : Data.ByteString.Lazy.ByteString | bllen o == bllen i }
-
-assume hGet
-    :: _
-    -> n : { n : Int | 0 <= n }
-    -> IO { bs : Data.ByteString.Lazy.ByteString | bllen bs == n || bllen bs == 0 }
-
-assume hGetNonBlocking
-    :: _
-    -> n : { n : Int | 0 <= n }
-    -> IO { bs : Data.ByteString.Lazy.ByteString | bllen bs <= n }
diff --git a/include/Data/ByteString/Short.spec b/include/Data/ByteString/Short.spec
deleted file mode 100644
--- a/include/Data/ByteString/Short.spec
+++ /dev/null
@@ -1,25 +0,0 @@
-module spec Data.ByteString.Short where
-
-import Data.String
-
-measure sbslen :: Data.ByteString.Short.ShortByteString -> { n : Int | 0 <= n }
-
-invariant { bs : Data.ByteString.Short.ShortByteString  | 0 <= sbslen bs }
-
-invariant { bs : Data.ByteString.Short.ShortByteString | sbslen bs == stringlen bs }
-
-toShort :: i : Data.ByteString.ByteString -> { o : Data.ByteString.Short.ShortByteString | sbslen o == bslen i }
-
-fromShort :: o : Data.ByteString.Short.ShortByteString -> { i : Data.ByteString.ByteString | bslen i == sbslen o }
-
-pack :: w8s : [Data.Word.Word8] -> { bs : Data.ByteString.Short.ShortByteString | sbslen bs == len w8s }
-
-unpack :: bs : Data.ByteString.Short.ShortByteString -> { w8s : [Data.Word.Word8] | len w8s == sbslen bs }
-
-empty :: { bs : Data.ByteString.Short.ShortByteString | sbslen bs == 0 }
-
-null :: bs : Data.ByteString.Short.ShortByteString -> { b : GHC.Types.Bool | b <=> sbslen bs == 0 }
-
-length :: bs : Data.ByteString.Short.ShortByteString -> { n : Int | sbslen bs == n }
-
-index :: bs : Data.ByteString.Short.ShortByteString -> { n : Int | 0 <= n && n < sbslen bs } -> Data.Word.Word8
diff --git a/include/Data/ByteString/Unsafe.spec b/include/Data/ByteString/Unsafe.spec
deleted file mode 100644
--- a/include/Data/ByteString/Unsafe.spec
+++ /dev/null
@@ -1,29 +0,0 @@
-module spec Data.ByteString.Unsafe where
-
-unsafeHead
-    :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> _ 
-
-unsafeTail
-    :: bs : { v : Data.ByteString.ByteString | bslen v > 0 }
-    -> { v : Data.ByteString.ByteString | bslen v = bslen bs - 1 }
-
-unsafeInit
-    :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> _ 
-
-unsafeLast
-    :: { bs : Data.ByteString.ByteString | 1 <= bslen bs } -> _ 
-
-unsafeIndex
-    :: bs : Data.ByteString.ByteString
-    -> { n : Int | 0 <= n && n < bslen bs }
-    -> _ 
-
-unsafeTake
-    :: n : { n : Int | 0 <= n }
-    -> i : { i : Data.ByteString.ByteString | n <= bslen i }
-    -> { o : Data.ByteString.ByteString | bslen o == n }
-
-unsafeDrop
-    :: n : { n : Int | 0 <= n }
-    -> i : { i : Data.ByteString.ByteString | n <= bslen i }
-    -> { o : Data.ByteString.ByteString | bslen o == bslen i - n }
diff --git a/include/Data/Char.spec b/include/Data/Char.spec
deleted file mode 100644
--- a/include/Data/Char.spec
+++ /dev/null
@@ -1,1 +0,0 @@
-module spec Data.Chare where
diff --git a/include/Data/Either.spec b/include/Data/Either.spec
deleted file mode 100644
--- a/include/Data/Either.spec
+++ /dev/null
@@ -1,5 +0,0 @@
-module spec Data.Either where
-
-measure isLeft :: Data.Either.Either a b -> Bool
-  isLeft (Left x)  = true
-  isLeft (Right x) = false
diff --git a/include/Data/Foldable.spec b/include/Data/Foldable.spec
deleted file mode 100644
--- a/include/Data/Foldable.spec
+++ /dev/null
@@ -1,5 +0,0 @@
-module spec Data.Foldable where
-
-import GHC.Base
-
-length :: Data.Foldable.Foldable f => forall a. xs:f a -> {v:Nat | v = len xs}
diff --git a/include/Data/Int.spec b/include/Data/Int.spec
deleted file mode 100644
--- a/include/Data/Int.spec
+++ /dev/null
@@ -1,8 +0,0 @@
-module spec Data.Int where
-
-embed Data.Int.Int8  as int
-embed Data.Int.Int16 as int
-embed Data.Int.Int32 as int
-embed Data.Int.Int64 as int
-
-// type Nat64 = {v:Data.Int.Int64 | v >= 0}
diff --git a/include/Data/OldList.spec b/include/Data/OldList.spec
deleted file mode 100644
--- a/include/Data/OldList.spec
+++ /dev/null
@@ -1,11 +0,0 @@
-module spec Data.OldList where
-
-import GHC.Base
-import GHC.List
-import GHC.Types
-
-assume groupBy :: (a -> a -> GHC.Types.Bool) -> [a] -> [{v:[a] | len(v) > 0}]
-
-assume transpose :: [[a]] -> [{v:[a] | (len v) > 0}]
-
-
diff --git a/include/Data/Set.spec b/include/Data/Set.spec
deleted file mode 100644
--- a/include/Data/Set.spec
+++ /dev/null
@@ -1,59 +0,0 @@
-module spec Data.Set where
-
-embed Data.Set.Internal.Set as Set_Set
-
-// ----------------------------------------------------------------------------------------------
-// -- | Logical Set Operators: Interpreted "natively" by the SMT solver -------------------------
-// ----------------------------------------------------------------------------------------------
-
-
-// union
-measure Set_cup  :: (Data.Set.Internal.Set a) -> (Data.Set.Internal.Set a) -> (Data.Set.Internal.Set a)
-
-// intersection
-measure Set_cap  :: (Data.Set.Internal.Set a) -> (Data.Set.Internal.Set a) -> (Data.Set.Internal.Set a)
-
-// difference
-measure Set_dif   :: (Data.Set.Internal.Set a) -> (Data.Set.Internal.Set a) -> (Data.Set.Internal.Set a)
-
-// singleton
-measure Set_sng   :: a -> (Data.Set.Internal.Set a)
-
-// emptiness test
-measure Set_emp   :: (Data.Set.Internal.Set a) -> GHC.Types.Bool
-
-// empty set
-measure Set_empty :: forall a. GHC.Types.Int -> (Data.Set.Internal.Set a)
-
-// membership test
-measure Set_mem  :: a -> (Data.Set.Internal.Set a) -> GHC.Types.Bool
-
-// inclusion test
-measure Set_sub  :: (Data.Set.Internal.Set a) -> (Data.Set.Internal.Set a) -> GHC.Types.Bool
-
-// ---------------------------------------------------------------------------------------------
-// -- | Refined Types for Data.Set Operations --------------------------------------------------
-// ---------------------------------------------------------------------------------------------
-
-isSubsetOf    :: (GHC.Classes.Ord a) => x:(Data.Set.Internal.Set a) -> y:(Data.Set.Internal.Set a) -> {v:GHC.Types.Bool | v <=> Set_sub x y}
-member        :: (GHC.Classes.Ord a) => x:a -> xs:(Data.Set.Internal.Set a) -> {v:GHC.Types.Bool | v <=> Set_mem x xs}
-null          :: (GHC.Classes.Ord a) => xs:(Data.Set.Internal.Set a) -> {v:GHC.Types.Bool | v <=> Set_emp xs}
-
-empty         :: {v:(Data.Set.Internal.Set a) | Set_emp v}
-singleton     :: x:a -> {v:(Data.Set.Internal.Set a) | v = (Set_sng x)}
-insert        :: (GHC.Classes.Ord a) => x:a -> xs:(Data.Set.Internal.Set a) -> {v:(Data.Set.Internal.Set a) | v = Set_cup xs (Set_sng x)}
-delete        :: (GHC.Classes.Ord a) => x:a -> xs:(Data.Set.Internal.Set a) -> {v:(Data.Set.Internal.Set a) | v = Set_dif xs (Set_sng x)}
-
-union         :: GHC.Classes.Ord a => xs:(Data.Set.Internal.Set a) -> ys:(Data.Set.Internal.Set a) -> {v:(Data.Set.Internal.Set a) | v = Set_cup xs ys}
-intersection  :: GHC.Classes.Ord a => xs:(Data.Set.Internal.Set a) -> ys:(Data.Set.Internal.Set a) -> {v:(Data.Set.Internal.Set a) | v = Set_cap xs ys}
-difference    :: GHC.Classes.Ord a => xs:(Data.Set.Internal.Set a) -> ys:(Data.Set.Internal.Set a) -> {v:(Data.Set.Internal.Set a) | v = Set_dif xs ys}
-
-fromList :: GHC.Classes.Ord a => xs:[a] -> {v:Data.Set.Internal.Set a | v = listElts xs}
-
-// ---------------------------------------------------------------------------------------------
-// -- | The set of elements in a list ----------------------------------------------------------
-// ---------------------------------------------------------------------------------------------
-
-measure listElts :: [a] -> (Data.Set.Internal.Set a)
-listElts([])   = {v | (Set_emp v)}
-listElts(x:xs) = {v | v = Set_cup (Set_sng x) (listElts xs) }
diff --git a/include/Data/String.spec b/include/Data/String.spec
deleted file mode 100644
--- a/include/Data/String.spec
+++ /dev/null
@@ -1,8 +0,0 @@
-module spec Data.String where
-
-measure stringlen :: a -> GHC.Types.Int
-
-Data.String.fromString
-    ::  forall a. Data.String.IsString a
-    =>  i : [GHC.Types.Char]
-    ->  { o : a | i ~~ o && len i == stringlen o }
diff --git a/include/Data/Text.spec b/include/Data/Text.spec
deleted file mode 100644
--- a/include/Data/Text.spec
+++ /dev/null
@@ -1,289 +0,0 @@
-module spec Data.Text where
-
-import Data.String
-
-measure tlen :: Data.Text.Text -> { n : Int | 0 <= n }
-
-invariant { t : Data.Text.Text  | 0 <= tlen t }
-
-invariant { t : Data.Text.Text | tlen t == stringlen t }
-
-empty :: { t : Data.Text.Text | tlen t == 0 }
-
-singleton :: _ -> { t : Data.Text.Text | tlen t == 1 }
-
-pack :: str : [_]
-     -> { t : Data.Text.Text | tlen t == len str }
-
-unpack :: t : Data.Text.Text
-       -> { str : [_] | len str == tlen t }
-
-cons :: _
-     -> i : Data.Text.Text
-     -> { o : Data.Text.Text | tlen o == tlen i + 1 }
-
-snoc :: i : Data.Text.Text
-     -> _
-     -> { o : Data.Text.Text | tlen o == tlen i + 1 }
-
-append :: l : Data.Text.Text
-       -> r : Data.Text.Text
-       -> { o : Data.Text.Text | tlen o == tlen l + tlen r }
-
-head :: { t : Data.Text.Text | 1 <= tlen t } -> _
-
-unsnoc :: i:Data.Text.Text
-       -> (Maybe ({ o : Data.Text.Text | tlen o == tlen i - 1 }, _))
-
-last :: { t : Data.Text.Text | 1 <= tlen t } -> _
-
-tail :: { t : Data.Text.Text | 1 <= tlen t } -> _
-
-init
-  :: {i:Data.Text.Text | 1 <= tlen i }
-  -> {o:Data.Text.Text | tlen o == tlen i - 1 }
-
-null
-  :: t : Data.Text.Text
-  -> { b : GHC.Types.Bool | b <=> tlen t == 0 }
-
-length :: t : Data.Text.Text -> { n : Int | tlen t == n }
-
-map
-  :: (_ -> _)
-  -> i : Data.Text.Text
-  -> { o : Data.Text.Text | tlen o == tlen i }
-
-reverse
-  :: i : Data.Text.Text
-  -> { o : Data.Text.Text | tlen o == tlen i }
-
-intersperse
-  :: _
-  -> i : Data.Text.Text
-  -> { o : Data.Text.Text | (tlen i == 0 <=> tlen o == 0) && (1 <= tlen i <=> tlen o == 2 * tlen i - 1) }
-
-intercalate
-  :: l : Data.Text.Text
-  -> rs : [Data.Text.Text]
-  -> { o : Data.Text.Text | len rs == 0 ==> tlen o == 0 }
-
-transpose
-  :: is : [Data.Text.Text]
-  -> { os : [{ t : Data.Text.Text | tlen t <= len is }] | len is == 0 ==> len os == 0}
-
-foldl1
-  :: (_ -> _ -> _)
-  -> { t : Data.Text.Text | 1 <= tlen t }
-  -> _
-
-foldl1'
-  :: (_ -> _ -> _)
-  -> { t : Data.Text.Text | 1 <= tlen t }
-  -> _
-
-foldr1
-  :: (_ -> _ -> _)
-  -> { t : Data.Text.Text | 1 <= tlen t }
-  -> _
-
-concat
-  :: is : [Data.Text.Text]
-  -> { o : Data.Text.Text | (len is == 0) ==> (tlen o == 0) }
-
-concatMap
-  :: (_ -> Data.Text.Text)
-  -> i : Data.Text.Text
-  -> { o : Data.Text.Text | tlen i == 0 ==> tlen o == 0 }
-
-any
-  :: (_ -> GHC.Types.Bool)
-  -> t : Data.Text.Text
-  -> { b : GHC.Types.Bool | tlen t == 0 ==> not b }
-
-all
-  :: (_ -> GHC.Types.Bool)
-  -> t : Data.Text.Text
-  -> { b : GHC.Types.Bool | tlen t == 0 ==> b }
-
-maximum :: { t : Data.Text.Text | 1 <= tlen t } -> _
-
-minimum :: { t : Data.Text.Text | 1 <= tlen t } -> _
-
-scanl :: (_ -> _ -> _)
-      -> _
-      -> i : Data.Text.Text
-      -> { o : Data.Text.Text | tlen o == tlen i }
-
-scanl1 :: (_ -> _ -> _)
-       -> i : { i : Data.Text.Text | 1 <= tlen i }
-       -> { o : Data.Text.Text | tlen o == tlen i }
-
-scanr
-    :: (_ -> _ -> _)
-    -> _
-    -> i : Data.Text.Text
-    -> { o : Data.Text.Text | tlen o == tlen i }
-
-scanr1
-    :: (_ -> _ -> _)
-    -> i : { i : Data.Text.Text | 1 <= tlen i }
-    -> { o : Data.Text.Text | tlen o == tlen i }
-
-mapAccumL
-    :: (acc -> _ -> (acc, _))
-    -> acc
-    -> i : Data.Text.Text
-    -> (acc, { o : Data.Text.Text | tlen o == tlen i })
-
-mapAccumR
-    :: (acc -> _ -> (acc, _))
-    -> acc
-    -> i : Data.Text.Text
-    -> (acc, { o : Data.Text.Text | tlen o == tlen i })
-
-replicate
-    :: n : Int
-    -> _
-    -> { t : Data.Text.Text | tlen t == n }
-
-unfoldrN
-    :: n : Int
-    -> (a -> Maybe (_, a))
-    -> a
-    -> { t : Data.Text.Text | tlen t <= n }
-
-take
-    :: n : Int
-    -> i : Data.Text.Text
-    -> { o : Data.Text.Text | (n <= 0 <=> tlen o == 0) &&
-                                          ((0 <= n && n <= tlen i) <=> tlen o == n) &&
-                                          (tlen i <= n <=> tlen o = tlen i) }
-
-drop
-    :: n : Int
-    -> i : Data.Text.Text
-    -> { o : Data.Text.Text | (n <= 0 <=> tlen o == tlen i) &&
-                                          ((0 <= n && n <= tlen i) <=> tlen o == tlen i - n) &&
-                                          (tlen i <= n <=> tlen o == 0) }
-
-splitAt
-    :: n : Int
-    -> i : Data.Text.Text
-    -> ( { l : Data.Text.Text | (n <= 0 <=> tlen l == 0) &&
-                                            ((0 <= n && n <= tlen i) <=> tlen l == n) &&
-                                            (tlen i <= n <=> tlen l == tlen i) }
-       , { r : Data.Text.Text | (n <= 0 <=> tlen r == tlen i) &&
-                                            ((0 <= n && n <= tlen i) <=> tlen r == tlen i - n) &&
-                                            (tlen i <= n <=> tlen r == 0) }
-       )
-
-takeWhile
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.Text.Text
-    -> { o : Data.Text.Text | tlen o <= tlen i }
-
-dropWhile
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.Text.Text
-    -> { o : Data.Text.Text | tlen o <= tlen i }
-
-span
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.Text.Text
-    -> ( { l : Data.Text.Text | tlen l <= tlen i }
-       , { r : Data.Text.Text | tlen r <= tlen i }
-       )
-
-break
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.Text.Text
-    -> ( { l : Data.Text.Text | tlen l <= tlen i }
-       , { r : Data.Text.Text | tlen r <= tlen i }
-       )
-
-group
-    :: i : Data.Text.Text
-    -> [{ o : Data.Text.Text | 1 <= tlen o && tlen o <= tlen i }]
-
-groupBy
-    :: (_ -> _ -> GHC.Types.Bool)
-    -> i : Data.Text.Text
-    -> [{ o : Data.Text.Text | 1 <= tlen o && tlen o <= tlen i }]
-
-inits
-    :: i : Data.Text.Text
-    -> [{ o : Data.Text.Text | tlen o <= tlen i }]
-
-tails
-    :: i : Data.Text.Text
-    -> [{ o : Data.Text.Text | tlen o <= tlen i }]
-
-split
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.Text.Text
-    -> [{ o : Data.Text.Text | tlen o <= tlen i }]
-
-isPrefixOf
-    :: l : Data.Text.Text
-    -> r : Data.Text.Text
-    -> { b : GHC.Types.Bool | tlen l >= tlen r ==> not b }
-
-isSuffixOf
-    :: l : Data.Text.Text
-    -> r : Data.Text.Text
-    -> { b : GHC.Types.Bool | tlen l > tlen r ==> not b }
-
-isInfixOf
-    :: l : Data.Text.Text
-    -> r : Data.Text.Text
-    -> { b : GHC.Types.Bool | tlen l > tlen r ==> not b }
-
-find
-    :: (_ -> GHC.Types.Bool)
-    -> t : Data.Text.Text
-    -> (Maybe { char : _ | tlen t /= 0 })
-
-filter
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.Text.Text
-    -> { o : Data.Text.Text | tlen o <= tlen i }
-
-partition
-    :: (_ -> GHC.Types.Bool)
-    -> i : Data.Text.Text
-    -> ( { l : Data.Text.Text | tlen l <= tlen i }
-       , { r : Data.Text.Text | tlen r <= tlen i }
-       )
-
-index :: t : Data.Text.Text -> { n : Int | 0 <= n && n < tlen t } -> _
-
-findIndex
-    :: (_ -> GHC.Types.Bool)
-    -> t : Data.Text.Text
-    -> (Maybe { n : Int | 0 <= n && n < tlen t })
-
-count
-    :: _
-    -> t : Data.Text.Text
-    -> { n : Int | 0 <= n && n < tlen t }
-
-zip
-    :: l : Data.Text.Text
-    -> r : Data.Text.Text
-    -> { o : [(_, _)] | len o <= tlen l && len o <= tlen r }
-
-zipWith
-    :: (_ -> _ -> Char)
-    -> l : Data.Text.Text
-    -> r : Data.Text.Text
-    -> { o : Text | tlen o <= tlen l && tlen o <= tlen r }
-
-copy
-    :: i : Data.Text.Text
-    -> { o : Data.Text.Text | tlen o == tlen i }
-
-uncons
-    :: i : Data.Text.Text
-    -> (Maybe (_, { o : Data.Text.Text | tlen o == tlen i - 1 }))
-
diff --git a/include/Data/Text/Fusion.spec b/include/Data/Text/Fusion.spec
deleted file mode 100644
--- a/include/Data/Text/Fusion.spec
+++ /dev/null
@@ -1,25 +0,0 @@
-module spec Data.Text.Fusion where
-
-import Data.Text.Fusion.Common
-
-stream        :: t:Data.Text.Internal.Text
-              -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) = (tlength t)}
-reverseStream :: t:Data.Text.Internal.Text
-              -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) = (tlength t)}
-unstream      :: s:Data.Text.Fusion.Internal.Stream Char
-              -> {v:Data.Text.Internal.Text | (tlength v) = (slen s)}
-
-findIndex :: (GHC.Types.Char -> GHC.Types.Bool)
-          -> s:Data.Text.Fusion.Internal.Stream Char
-          -> (Data.Maybe.Maybe {v:Nat | v < (slen s)})
-
-mapAccumL :: (a -> GHC.Types.Char -> (a,GHC.Types.Char))
-          -> a
-          -> s:Data.Text.Fusion.Internal.Stream Char
-          -> (a, {v:Data.Text.Internal.Text | (tlength v) = (slen s)})
-
-
-length  :: s:Data.Text.Fusion.Internal.Stream Char
-        -> {v:GHC.Types.Int | v = (slen s)}
-reverse :: s:Data.Text.Fusion.Internal.Stream Char
-        -> {v:Data.Text.Internal.Text | (tlength v) = (slen s)}
diff --git a/include/Data/Text/Fusion/Common.spec b/include/Data/Text/Fusion/Common.spec
deleted file mode 100644
--- a/include/Data/Text/Fusion/Common.spec
+++ /dev/null
@@ -1,52 +0,0 @@
-module spec Data.Text.Fusion.Common where
-
-measure slen :: Data.Text.Fusion.Internal.Stream a
-             -> GHC.Types.Int
-
-cons :: GHC.Types.Char
-     -> s:Data.Text.Fusion.Internal.Stream Char
-     -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) = (1 + (slen s))}
-
-snoc :: s:Data.Text.Fusion.Internal.Stream Char
-     -> GHC.Types.Char
-     -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) = (1 + (slen s))}
-
-compareLengthI :: s:Data.Text.Fusion.Internal.Stream Char
-               -> l:GHC.Types.Int
-               -> {v:GHC.Types.Ordering | ((v = GHC.Types.EQ) <=> ((slen s) = l))}
-
-isSingleton :: s:Data.Text.Fusion.Internal.Stream Char
-            -> {v:GHC.Types.Bool | (v <=> ((slen s) = 1))}
-
-singleton   :: GHC.Types.Char
-            -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) = 1}
-
-streamList   :: l:[a]
-             -> {v:Data.Text.Fusion.Internal.Stream a | (slen v) = (len l)}
-
-unstreamList :: s:Data.Text.Fusion.Internal.Stream a
-             -> {v:[a] | (len v) = (slen s)}
-
-map :: (GHC.Types.Char -> GHC.Types.Char)
-    -> s:Data.Text.Fusion.Internal.Stream Char
-    -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) = (slen s)}
-
-filter :: (GHC.Types.Char -> GHC.Types.Bool)
-       -> s:Data.Text.Fusion.Internal.Stream Char
-       -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) <= (slen s)}
-
-intersperse :: GHC.Types.Char
-            -> s:Data.Text.Fusion.Internal.Stream Char
-            -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) > (slen s)}
-
-replicateCharI :: l:GHC.Types.Int
-               -> GHC.Types.Char
-               -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) = l}
-
-toCaseFold :: s:Data.Text.Fusion.Internal.Stream Char
-           -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) >= (slen s)}
-
-toUpper    :: s:Data.Text.Fusion.Internal.Stream Char
-           -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) >= (slen s)}
-toLower    :: s:Data.Text.Fusion.Internal.Stream Char
-           -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) >= (slen s)}
diff --git a/include/Data/Text/Lazy/Fusion.spec b/include/Data/Text/Lazy/Fusion.spec
deleted file mode 100644
--- a/include/Data/Text/Lazy/Fusion.spec
+++ /dev/null
@@ -1,8 +0,0 @@
-module spec Data.Text.Lazy.Fusion where
-
-stream :: t:Data.Text.Lazy.Internal.Text
-       -> {v:Data.Text.Fusion.Internal.Stream Char | (slen v) = (ltlength t)}
-unstream :: s:Data.Text.Fusion.Internal.Stream Char
-         -> {v:Data.Text.Lazy.Internal.Text | (ltlength v) = (slen s)}
-length :: s:Data.Text.Fusion.Internal.Stream Char
-       -> {v:GHC.Int.Int64 | v = (slen s)}
diff --git a/include/Data/Time.spec b/include/Data/Time.spec
deleted file mode 100644
--- a/include/Data/Time.spec
+++ /dev/null
@@ -1,3 +0,0 @@
-module spec Data.Time where
-
-import Data.Time.Calendar
diff --git a/include/Data/Tuple.spec b/include/Data/Tuple.spec
deleted file mode 100644
--- a/include/Data/Tuple.spec
+++ /dev/null
@@ -1,4 +0,0 @@
-module spec Data.Tuple where
-
-fst :: {f:(x:(a,b) -> {v:a | v = (fst x)}) | f == fst }
-snd :: {f:(x:(a,b) -> {v:b | v = (snd x)}) | f == snd }
diff --git a/include/Data/Vector.hquals b/include/Data/Vector.hquals
deleted file mode 100644
--- a/include/Data/Vector.hquals
+++ /dev/null
@@ -1,13 +0,0 @@
-qualif VecEmpty(v: Data.Vector.Vector a)    : (vlen v)  =  0 
-qualif VecEmpty(v: Data.Vector.Vector a)    : (vlen v)  >  0 
-qualif VecEmpty(v: Data.Vector.Vector a)    : (vlen v)  >= 0 
-
-qualif Vlen(v:int, x: Data.Vector.Vector a) : (v  =  vlen x)
-qualif Vlen(v:int, x: Data.Vector.Vector a) : (v <=  vlen x) 
-qualif Vlen(v:int, x: Data.Vector.Vector a) : (v  <  vlen x) 
-
-qualif CmpVlen(v:Data.Vector.Vector a, x:Data.Vector.Vector b) : (vlen v <  vlen x) 
-qualif CmpVlen(v:Data.Vector.Vector a, x:Data.Vector.Vector b) : (vlen v <= vlen x) 
-qualif CmpVlen(v:Data.Vector.Vector a, x:Data.Vector.Vector b) : (vlen v >  vlen x) 
-qualif CmpVlen(v:Data.Vector.Vector a, x:Data.Vector.Vector b) : (vlen v >= vlen x) 
-qualif CmpVlen(v:Data.Vector.Vector a, x:Data.Vector.Vector b) : (vlen v =  vlen x) 
diff --git a/include/Data/Vector.spec b/include/Data/Vector.spec
deleted file mode 100644
--- a/include/Data/Vector.spec
+++ /dev/null
@@ -1,26 +0,0 @@
-module spec Data.Vector where
-
-import GHC.Base
-
-data variance Data.Vector.Vector covariant
-
-
-measure vlen    :: forall a. (Data.Vector.Vector a) -> Int
-
-invariant       {v: Data.Vector.Vector a | 0 <= vlen v } 
-
-!           :: forall a. x:(Data.Vector.Vector a) -> vec:{v:Nat | v < vlen x } -> a 
-
-unsafeIndex :: forall a. x:(Data.Vector.Vector a) -> vec:{v:Nat | v < vlen x } -> a 
-
-fromList  :: forall a. x:[a] -> {v: Data.Vector.Vector a  | vlen v = len x }
-
-length    :: forall a. x:(Data.Vector.Vector a) -> {v : Nat | v = vlen x }
-
-replicate :: n:Nat -> a -> {v:Data.Vector.Vector a | vlen v = n} 
-
-imap :: (Nat -> a -> b) -> x:(Data.Vector.Vector a) -> {y:Data.Vector.Vector b | vlen y = vlen x }
-
-map :: (a -> b) -> x:(Data.Vector.Vector a) -> {y:Data.Vector.Vector b | vlen y = vlen x }
-
-head :: forall a. {xs: Data.Vector.Vector a | vlen xs > 0} -> a 
diff --git a/include/Data/Word.spec b/include/Data/Word.spec
deleted file mode 100644
--- a/include/Data/Word.spec
+++ /dev/null
@@ -1,10 +0,0 @@
-module spec Data.Word where
-
-embed Data.Word.Word   as int
-embed Data.Word.Word8  as int
-embed Data.Word.Word16 as int
-embed Data.Word.Word32 as int
-embed Data.Word.Word64 as int
-
-invariant {v : Data.Word.Word32 | 0 <= v }
-invariant {v : Data.Word.Word16 | 0 <= v }
diff --git a/include/Data/Word8.spec b/include/Data/Word8.spec
deleted file mode 100644
--- a/include/Data/Word8.spec
+++ /dev/null
@@ -1,5 +0,0 @@
-module spec Data.Word8 where
-
-import GHC.Word
-
-invariant {v:GHC.Word.Word8 | 0 <= v }
diff --git a/include/Foreign/C/String.spec b/include/Foreign/C/String.spec
deleted file mode 100644
--- a/include/Foreign/C/String.spec
+++ /dev/null
@@ -1,11 +0,0 @@
-module spec Foreign.C.String where
-
-import Foreign.Ptr
-
-type CStringLen    = ((GHC.Ptr.Ptr Foreign.C.Types.CChar), Nat)<{\p v -> (v <= (plen p))}>
-type CStringLenN N = ((GHC.Ptr.Ptr Foreign.C.Types.CChar), {v:Nat | v = N})<{\p v -> (v <= (plen p))}>
-
-// measure cStringLen :: Foreign.C.String.CStringLen -> GHC.Types.Int
-
-measure cStringLen :: ((GHC.Ptr.Ptr Foreign.C.Types.CChar), GHC.Types.Int) -> GHC.Types.Int 
-  cStringLen (c, n) = n
diff --git a/include/Foreign/C/Types.spec b/include/Foreign/C/Types.spec
deleted file mode 100644
--- a/include/Foreign/C/Types.spec
+++ /dev/null
@@ -1,7 +0,0 @@
-module spec Foreign.C.Types where
-
-import GHC.Word
-
-embed Foreign.C.Types.CInt   as int
-embed Foreign.C.Types.CSize  as int
-embed Foreign.C.Types.CULong as int
diff --git a/include/Foreign/ForeignPtr.spec b/include/Foreign/ForeignPtr.spec
deleted file mode 100644
--- a/include/Foreign/ForeignPtr.spec
+++ /dev/null
@@ -1,16 +0,0 @@
-module spec Foreign.ForeignPtr where
-
-import GHC.ForeignPtr
-import Foreign.Ptr
-
-Foreign.ForeignPtr.withForeignPtr :: forall a b. fp:(GHC.ForeignPtr.ForeignPtr a) 
-  -> ((PtrN a (fplen fp)) -> GHC.Types.IO b) 
-  -> (GHC.Types.IO b)
-
-GHC.ForeignPtr.newForeignPtr_     :: p:(GHC.Ptr.Ptr a) -> (GHC.Types.IO (ForeignPtrN a (plen p)))
-Foreign.Concurrent.newForeignPtr  :: p:(PtrV a) -> GHC.Types.IO () -> (GHC.Types.IO (ForeignPtrN a (plen p)))
-Foreign.ForeignPtr.newForeignPtr ::  _ -> p:(PtrV a) -> (GHC.Types.IO (ForeignPtrN a (plen p)))
-
-
-// this uses `sizeOf (undefined :: a)`, so the ForeignPtr does not necessarily have length `n`
-// Foreign.ForeignPtr.Imp.mallocForeignPtrArray :: (Foreign.Storable.Storable a) => n:Nat -> IO (ForeignPtrN a n)
diff --git a/include/Foreign/Marshal/Alloc.spec b/include/Foreign/Marshal/Alloc.spec
deleted file mode 100644
--- a/include/Foreign/Marshal/Alloc.spec
+++ /dev/null
@@ -1,3 +0,0 @@
-module spec Foreign.Marshal.Alloc where
-
-Foreign.Marshal.Alloc.allocaBytes :: n:Nat -> (PtrN a n -> IO b) -> IO b
diff --git a/include/Foreign/Marshal/Array.spec b/include/Foreign/Marshal/Array.spec
deleted file mode 100644
--- a/include/Foreign/Marshal/Array.spec
+++ /dev/null
@@ -1,3 +0,0 @@
-module spec Foreign.Marshal.Array where
-
-Foreign.Marshal.Array.allocaArray :: Foreign.Storable.Storable a => n:Int -> ((PtrN a n) -> IO b) -> IO b
diff --git a/include/Foreign/Ptr.spec b/include/Foreign/Ptr.spec
deleted file mode 100644
--- a/include/Foreign/Ptr.spec
+++ /dev/null
@@ -1,5 +0,0 @@
-module spec Foreign.Ptr where
-
-import GHC.Ptr
-
-
diff --git a/include/Foreign/Storable.spec b/include/Foreign/Storable.spec
deleted file mode 100644
--- a/include/Foreign/Storable.spec
+++ /dev/null
@@ -1,30 +0,0 @@
-module spec Foreign.Storable where
-
-import Foreign.Ptr
-
-// DON'T do this, we can't import HS files from SPEC files
-// import Language.Haskell.Liquid.Foreign
-
-predicate PValid P N         = ((0 <= N) && (N < (plen P)))   
-
-Foreign.Storable.poke        :: (Foreign.Storable.Storable a)
-                             => {v: (GHC.Ptr.Ptr a) | 0 < (plen v)}
-                             -> a
-                             -> (GHC.Types.IO ())
-
-Foreign.Storable.peek        :: (Foreign.Storable.Storable a)
-                             => p:{v: (GHC.Ptr.Ptr a) | 0 < (plen v)}
-                             -> (GHC.Types.IO {v:a | v = (deref p)})
-
-Foreign.Storable.peekByteOff :: (Foreign.Storable.Storable a)
-                             => forall b. p:(GHC.Ptr.Ptr b)
-                             -> {v:GHC.Types.Int | (PValid p v)}
-                             -> (GHC.Types.IO a)
-
-Foreign.Storable.pokeByteOff :: (Foreign.Storable.Storable a)
-                             => forall b. p:(GHC.Ptr.Ptr b)
-                             -> {v:GHC.Types.Int | (PValid p v)}
-                             -> a
-                             -> GHC.Types.IO ()
-
-
diff --git a/include/GHC/Base.hquals b/include/GHC/Base.hquals
deleted file mode 100644
--- a/include/GHC/Base.hquals
+++ /dev/null
@@ -1,30 +0,0 @@
-//qualif NonNull(v: [a])        : (? (nonnull([v])))
-//qualif Null(v: [a])           : (~ (? (nonnull([v]))))
-//qualif EqNull(v:Bool, ~A: [a]): (v <=> (? (nonnull([~A]))))
-
-// qualif IsEmp(v:GHC.Types.Bool, ~A: [a]) : ((v) <=> len([~A]) [ > ;  = ] 0)
-// qualif ListZ(v: [a])          : len([v]) [ = ; >= ; > ] 0 
-// qualif CmpLen(v:[a], ~A:[b])  : len([v]) [= ; >=; >; <=; <] len([~A]) 
-// qualif EqLen(v:int, ~A: [a])  : v = len([~A]) 
-// qualif LenEq(v:[a], ~A: int)  : ~A = len([v]) 
-// qualif LenAcc(v:int, ~A:[a], ~B: int): v = len([~A]) + ~B
-// qualif LenDiff(v:[a], ~A:int): len([v]) = (~A [ +; - ] 1)
-
-qualif IsEmp(v:GHC.Types.Bool, xs: [a]) : (v <=> (len xs > 0))
-qualif IsEmp(v:GHC.Types.Bool, xs: [a]) : (v <=> (len xs = 0))
-
-qualif ListZ(v: [a])          : (len([v]) =  0) 
-qualif ListZ(v: [a])          : (len([v]) >= 0) 
-qualif ListZ(v: [a])          : (len([v]) >  0) 
-
-qualif CmpLen(v:[a], xs:[b])  : (len([v]) =  len([xs])) 
-qualif CmpLen(v:[a], xs:[b])  : (len([v]) >= len([xs])) 
-qualif CmpLen(v:[a], xs:[b])  : (len([v]) >  len([xs])) 
-qualif CmpLen(v:[a], xs:[b])  : (len([v]) <= len([xs])) 
-qualif CmpLen(v:[a], xs:[b])  : (len([v]) <  len([xs])) 
-
-qualif EqLen(v:int, xs: [a])  : (v = len([xs])) 
-qualif LenEq(v:[a], x: int)   : (x = len([v])) 
-qualif LenDiff(v:[a], x:int)  : (len([v]) = x + 1)
-qualif LenDiff(v:[a], x:int)  : (len([v]) = x - 1)
-qualif LenAcc(v:int, xs:[a], n: int): (v = len([xs]) + n)
diff --git a/include/GHC/Base.spec b/include/GHC/Base.spec
deleted file mode 100644
--- a/include/GHC/Base.spec
+++ /dev/null
@@ -1,79 +0,0 @@
-module spec GHC.Base where
-
-import GHC.CString
-import GHC.Prim
-import GHC.Classes
-import GHC.Types
-
-embed GHC.Types.Int      as int
-embed GHC.Types.Bool     as bool
-
-measure autolen :: forall a. a -> GHC.Types.Int
-class measure len :: forall f a. f a -> GHC.Types.Int
-instance measure len :: forall a. [a] -> GHC.Types.Int
-  len []     = 0
-  len (y:ys) = 1 + len ys
-
-// measure null :: [a] -> Bool
-// null []     = true 
-// null (y:ys) = false
-
-measure fst :: (a, b) -> a
-  fst (a, b) = a
-
-measure snd :: (a, b) -> b
-  snd (a, b) = b
-
-qualif Fst(__v:a, __y:b): (__v = (fst __y))
-qualif Snd(__v:a, __y:b): (__v = (snd __y))
-
-measure isJust :: Maybe a -> Bool
-  isJust (Just x)  = true
-  isJust (Nothing) = false
-
-measure fromJust :: Maybe a -> a
-  fromJust (Just x) = x
-
-
-invariant {v: [a] | len v >= 0 }
-map       :: (a -> b) -> xs:[a] -> {v: [b] | len v == len xs}
-(++)      :: xs:[a] -> ys:[a] -> {v:[a] | len v == len xs + len ys}
-
-($)       :: (a -> b) -> a -> b
-id        :: x:a -> {v:a | v = x}
-
-// data variance Text.ParserCombinators.ReadPrec.ReadPrec contravariant
-
-//qualif NonNull(v: [a])        : (? (nonnull v ))
-//qualif Null(v: [a])           : (~ (? (nonnull v )))
-//qualif EqNull(v:Bool, ~A: [a]): (v <=> (? (nonnull([~A]))))
-
-// qualif IsEmp(v:GHC.Types.Bool, ~A: [a]) : ((v) <=> len([~A]) [ > ;  = ] 0)
-// qualif ListZ(v: [a])          : len v  [ = ; >= ; > ] 0 
-// qualif CmpLen(v:[a], ~A:[b])  : len v  [= ; >=; >; <=; <] len([~A]) 
-// qualif EqLen(v:int, ~A: [a])  : v = len([~A]) 
-// qualif LenEq(v:[a], ~A: int)  : ~A = len v  
-// qualif LenAcc(v:int, ~A:[a], ~B: int): v = len([~A]) + ~B
-// qualif LenDiff(v:[a], ~A:int): len v  = (~A [ +; - ] 1)
-
-qualif IsEmp(v:GHC.Types.Bool, xs: [a]) : (v <=> (len xs > 0))
-qualif IsEmp(v:GHC.Types.Bool, xs: [a]) : (v <=> (len xs = 0))
-
-qualif ListZ(v: [a])          : (len v =  0) 
-qualif ListZ(v: [a])          : (len v >= 0) 
-qualif ListZ(v: [a])          : (len v >  0) 
-
-qualif CmpLen(v:[a], xs:[b])  : (len v  =  len xs ) 
-qualif CmpLen(v:[a], xs:[b])  : (len v  >= len xs ) 
-qualif CmpLen(v:[a], xs:[b])  : (len v  >  len xs ) 
-qualif CmpLen(v:[a], xs:[b])  : (len v  <= len xs ) 
-qualif CmpLen(v:[a], xs:[b])  : (len v  <  len xs ) 
-
-qualif EqLen(v:int, xs: [a])  : (v = len xs ) 
-qualif LenEq(v:[a], x: int)   : (x = len v ) 
-
-qualif LenDiff(v:[a], x:int)  : (len v  = x + 1)
-qualif LenDiff(v:[a], x:int)  : (len v  = x - 1)
-qualif LenAcc(v:int, xs:[a], n: int): (v = len xs  + n)
-
-
diff --git a/include/GHC/CString.spec b/include/GHC/CString.spec
deleted file mode 100644
--- a/include/GHC/CString.spec
+++ /dev/null
@@ -1,11 +0,0 @@
-module spec GHC.CString where
-
-import GHC.Prim
-
-measure strLen :: GHC.Base.String -> GHC.Types.Int
-
-embed GHC.Types.Char as Char
-
-GHC.CString.unpackCString#
-  :: x:GHC.Prim.Addr#
-  -> {v:[Char] | v ~~ x && len v == strLen x}
diff --git a/include/GHC/Classes.spec b/include/GHC/Classes.spec
deleted file mode 100644
--- a/include/GHC/Classes.spec
+++ /dev/null
@@ -1,29 +0,0 @@
-module spec GHC.Classes where
-
-import GHC.Types
-
-not     :: x:GHC.Types.Bool -> {v:GHC.Types.Bool | ((v) <=> ~(x))}
-(&&)    :: x:GHC.Types.Bool -> y:GHC.Types.Bool
-        -> {v:GHC.Types.Bool | ((v) <=> ((x) && (y)))}
-(||)    :: x:GHC.Types.Bool -> y:GHC.Types.Bool
-        -> {v:GHC.Types.Bool | ((v) <=> ((x) || (y)))}
-(==)    :: (GHC.Classes.Eq  a) => x:a -> y:a
-        -> {v:GHC.Types.Bool | ((v) <=> x = y)}
-(/=)    :: (GHC.Classes.Eq  a) => x:a -> y:a
-        -> {v:GHC.Types.Bool | ((v) <=> x != y)}
-(>)     :: (GHC.Classes.Ord a) => x:a -> y:a
-        -> {v:GHC.Types.Bool | ((v) <=> x > y)}
-(>=)    :: (GHC.Classes.Ord a) => x:a -> y:a
-        -> {v:GHC.Types.Bool | ((v) <=> x >= y)}
-(<)     :: (GHC.Classes.Ord a) => x:a -> y:a
-        -> {v:GHC.Types.Bool | ((v) <=> x < y)}
-(<=)    :: (GHC.Classes.Ord a) => x:a -> y:a
-        -> {v:GHC.Types.Bool | ((v) <=> x <= y)}
-
-compare :: (GHC.Classes.Ord a) => x:a -> y:a
-        -> {v:GHC.Types.Ordering | (((v = GHC.Types.EQ) <=> (x = y)) &&
-                                    ((v = GHC.Types.LT) <=> (x < y)) &&
-                                    ((v = GHC.Types.GT) <=> (x > y))) }
-
-max :: (GHC.Classes.Ord a) => x:a -> y:a -> {v:a | v = (if x > y then x else y) }
-min :: (GHC.Classes.Ord a) => x:a -> y:a -> {v:a | v = (if x < y then x else y) }
diff --git a/include/GHC/Exts.spec b/include/GHC/Exts.spec
deleted file mode 100644
--- a/include/GHC/Exts.spec
+++ /dev/null
@@ -1,10 +0,0 @@
-module spec GHC.Exts where
-
-// embed GHC.Exts.Int#     as int
-// embed GHC.Exts.Word#    as int
-// embed GHC.Exts.Addr#    as Str
-// embed GHC.Exts.Double#  as real
-// embed GHC.Exts.Char#    as Char
-
-
-
diff --git a/include/GHC/ForeignPtr.spec b/include/GHC/ForeignPtr.spec
deleted file mode 100644
--- a/include/GHC/ForeignPtr.spec
+++ /dev/null
@@ -1,9 +0,0 @@
-module spec GHC.ForeignPtr where
-
-measure fplen :: GHC.ForeignPtr.ForeignPtr a -> GHC.Types.Int
-
-type ForeignPtrV a   = {v: GHC.ForeignPtr.ForeignPtr a | 0 <= fplen v}
-type ForeignPtrN a N = {v: GHC.ForeignPtr.ForeignPtr a | 0 <= fplen v && fplen v == N }
-
-mallocPlainForeignPtrBytes :: n:{v:GHC.Types.Int  | v >= 0 } -> (GHC.Types.IO (ForeignPtrN a n))
-
diff --git a/include/GHC/IO/Handle.spec b/include/GHC/IO/Handle.spec
deleted file mode 100644
--- a/include/GHC/IO/Handle.spec
+++ /dev/null
@@ -1,10 +0,0 @@
-module spec GHC.IO.Handle where
-
-hGetBuf :: GHC.IO.Handle.Handle -> GHC.Ptr.Ptr a -> n:Nat
-        -> (GHC.Types.IO {v:Nat | v <= n})
-
-hGetBufNonBlocking :: GHC.IO.Handle.Handle -> GHC.Ptr.Ptr a -> n:Nat
-                   -> (GHC.Types.IO {v:Nat | v <= n})
-
-hFileSize :: GHC.IO.Handle.Handle
-          -> (GHC.Types.IO {v:GHC.Integer.Type.Integer | v >= 0})
diff --git a/include/GHC/Int.spec b/include/GHC/Int.spec
deleted file mode 100644
--- a/include/GHC/Int.spec
+++ /dev/null
@@ -1,8 +0,0 @@
-module spec GHC.Int where
-
-embed GHC.Int.Int8  as int
-embed GHC.Int.Int16 as int
-embed GHC.Int.Int32 as int
-embed GHC.Int.Int64 as int
-
-type Nat64 = {v:GHC.Int.Int64 | v >= 0}
diff --git a/include/GHC/List.spec b/include/GHC/List.spec
deleted file mode 100644
--- a/include/GHC/List.spec
+++ /dev/null
@@ -1,60 +0,0 @@
-module spec GHC.List where 
-
-head         :: xs:{v: [a] | len v > 0} -> {v:a | v = head xs}
-tail         :: xs:{v: [a] | len v > 0} -> {v: [a] | len(v) = (len(xs) - 1) && v = tail xs}
-
-last         :: xs:{v: [a] | len v > 0} -> a
-init         :: xs:{v: [a] | len v > 0} -> {v: [a] | len(v) = len(xs) - 1}
-null         :: xs:[a] -> {v: GHC.Types.Bool | ((v) <=> len(xs) = 0) }
-length       :: xs:[a] -> {v: GHC.Types.Int | v = len(xs)}
-filter       :: (a -> GHC.Types.Bool) -> xs:[a] -> {v: [a] | len(v) <= len(xs)}
-scanl        :: (a -> b -> a) -> a -> xs:[b] -> {v: [a] | len(v) = 1 + len(xs) }
-scanl1       :: (a -> a -> a) -> xs:{v: [a] | len(v) > 0} -> {v: [a] | len(v) = len(xs) }
-foldr1       :: (a -> a -> a) -> xs:{v: [a] | len(v) > 0} -> a
-scanr        :: (a -> b -> b) -> b -> xs:[a] -> {v: [b] | len(v) = 1 + len(xs) }
-scanr1       :: (a -> a -> a) -> xs:{v: [a] | len(v) > 0} -> {v: [a] | len(v) = len(xs) }
-
-lazy GHC.List.iterate
-iterate :: (a -> a) -> a -> [a]
-
-repeat :: a -> [a]
-lazy GHC.List.repeat
-
-replicate    :: n:Nat -> x:a -> {v: [{v:a | v = x}] | len(v) = n}
-
-cycle        :: {v: [a] | len(v) > 0 } -> [a]
-lazy cycle
-
-takeWhile    :: (a -> GHC.Types.Bool) -> xs:[a] -> {v: [a] | len(v) <= len(xs)}
-dropWhile    :: (a -> GHC.Types.Bool) -> xs:[a] -> {v: [a] | len(v) <= len(xs)}
-
-take :: n:GHC.Types.Int
-     -> xs:[a]
-     -> {v:[a] | if n >= 0 then (len v = (if (len xs) < n then (len xs) else n)) else (len v = 0)}
-drop :: n:GHC.Types.Int
-     -> xs:[a]
-     -> {v:[a] | (if (n >= 0) then (len(v) = (if (len(xs) < n) then 0 else len(xs) - n)) else ((len v) = (len xs)))}
-
-splitAt :: n:_ -> x:[a] -> ({v:[a] | (if (n >= 0) then (if (len x) < n then (len v) = (len x) else (len v) = n) else ((len v) = 0))},[a])<{\x1 x2 -> (len x2) = (len x) - (len x1)}>
-span    :: (a -> GHC.Types.Bool) 
-        -> xs:[a] 
-        -> ({v:[a]|((len v)<=(len xs))}, {v:[a]|((len v)<=(len xs))})
-
-break :: (a -> GHC.Types.Bool) -> xs:[a] -> ([a],[a])<{\x y -> (len xs) = (len x) + (len y)}>
-
-reverse      :: xs:[a] -> {v: [a] | len(v) = len(xs)}
-
-include <len.hquals>
-
-GHC.List.!!         :: xs:[a] -> {v: _ | ((0 <= v) && (v < len(xs)))} -> a
-
-
-zip :: xs : [a] -> ys:[b]
-            -> {v : [(a, b)] | ((((len v) <= (len xs)) && ((len v) <= (len ys)))
-            && (((len xs) = (len ys)) => ((len v) = (len xs))) )}
-
-zipWith :: (a -> b -> c) 
-        -> xs : [a] -> ys:[b] 
-        -> {v : [c] | (((len v) <= (len xs)) && ((len v) <= (len ys)))}
-
-errorEmptyList :: {v: _ | false} -> a
diff --git a/include/GHC/Num.spec b/include/GHC/Num.spec
deleted file mode 100644
--- a/include/GHC/Num.spec
+++ /dev/null
@@ -1,9 +0,0 @@
-module spec GHC.Num where
-
-embed GHC.Integer.Type.Integer as int 
-
-GHC.Num.fromInteger :: (GHC.Num.Num a) => x:GHC.Integer.Type.Integer -> {v:a | v = x }
-
-GHC.Num.negate :: (GHC.Num.Num a)
-               => x:a
-               -> {v:a | v = -x}
diff --git a/include/GHC/Prim.spec b/include/GHC/Prim.spec
deleted file mode 100644
--- a/include/GHC/Prim.spec
+++ /dev/null
@@ -1,8 +0,0 @@
-module spec GHC.Prim where 
-
-embed GHC.Prim.Int#     as int
-embed GHC.Prim.Addr#    as Str
-embed GHC.Prim.Char#    as Char
-embed GHC.Prim.Double# as real
-embed GHC.Prim.Float#  as real
-embed GHC.Prim.Word#    as int
diff --git a/include/GHC/Ptr.spec b/include/GHC/Ptr.spec
deleted file mode 100644
--- a/include/GHC/Ptr.spec
+++ /dev/null
@@ -1,24 +0,0 @@
-module spec GHC.Ptr where
-
-measure pbase     :: GHC.Ptr.Ptr a -> GHC.Types.Int
-measure plen      :: GHC.Ptr.Ptr a -> GHC.Types.Int
-measure isNullPtr :: GHC.Ptr.Ptr a -> Bool 
-
-invariant {v:Foreign.Ptr.Ptr a | 0 <= plen  v }
-invariant {v:Foreign.Ptr.Ptr a | 0 <= pbase v }
-
-type PtrN a N = {v: PtrV a        | plen v == N }
-type PtrV a   = {v: GHC.Ptr.Ptr a | 0 <= plen v }
-
-GHC.Ptr.castPtr :: p:(PtrV a) -> (PtrN b (plen p))
-
-GHC.Ptr.plusPtr :: base:(PtrV a)
-                -> off:{v:GHC.Types.Int | v <= plen base }
-                -> {v:(PtrV b) | pbase v = pbase base && plen v = plen base - off}
-
-GHC.Ptr.minusPtr :: q:(PtrV a)
-                 -> p:{v:(PtrV b) | pbase v == pbase q && plen v >= plen q}
-                 -> {v:Nat | v == plen p - plen q}
-
-measure deref     :: GHC.Ptr.Ptr a -> a
-
diff --git a/include/GHC/Read.spec b/include/GHC/Read.spec
deleted file mode 100644
--- a/include/GHC/Read.spec
+++ /dev/null
@@ -1,5 +0,0 @@
-module spec GHC.Read where
-
-type ParsedString XS =  {v:_ | (if ((len XS) > 0) then ((len v) < (len XS)) else ((len v) = 0))}
-
-GHC.Read.lex :: xs:_ -> [((ParsedString xs), (ParsedString xs))]
diff --git a/include/GHC/Real.spec b/include/GHC/Real.spec
deleted file mode 100644
--- a/include/GHC/Real.spec
+++ /dev/null
@@ -1,37 +0,0 @@
-module spec GHC.Real where
-
-(GHC.Real.^) :: (GHC.Num.Num a, GHC.Real.Integral b) => a:a -> n:b -> {v:a | v == 0 <=> a == 0 }
-
-GHC.Real.fromIntegral    :: (GHC.Real.Integral a, GHC.Num.Num b) => x:a -> {v:b|v=x}
-
-class (GHC.Num.Num a) => GHC.Real.Fractional a where
-  (GHC.Real./)   :: x:a -> y:{v:a | v /= 0} -> {v:a | v == x / y}
-  GHC.Real.recip :: a -> a
-  GHC.Real.fromRational :: GHC.Real.Ratio Integer -> a
-
-class (GHC.Real.Real a, GHC.Enum.Enum a) => GHC.Real.Integral a where
-  GHC.Real.quot :: x:a -> y:{v:a | v /= 0} -> {v:a | (v = (x / y)) &&
-                                                     ((x >= 0 && y >= 0) => v >= 0) &&
-                                                     ((x >= 0 && y >= 1) => v <= x) }
-  GHC.Real.rem :: x:a -> y:{v:a | v /= 0} -> {v:a | ((v >= 0) && (v < y))}
-  GHC.Real.mod :: x:a -> y:{v:a | v /= 0} -> {v:a | v = x mod y && ((0 <= x && 0 < y) => (0 <= v && v < y))}
-
-  GHC.Real.div :: x:a -> y:{v:a | v /= 0} -> {v:a | (v = (x / y)) &&
-                                                    ((x >= 0 && y >= 0) => v >= 0) &&
-                                                    ((x >= 0 && y >= 1) => v <= x) && 
-                                                    ((1 < y)            => v < x ) && 
-                                                    ((y >= 1)           => v <= x)  
-                                                    }
-  GHC.Real.quotRem :: x:a -> y:{v:a | v /= 0} -> ( {v:a | (v = (x / y)) &&
-                                                          ((x >= 0 && y >= 0) => v >= 0) &&
-                                                          ((x >= 0 && y >= 1) => v <= x)}
-                                                 , {v:a | ((v >= 0) && (v < y))})
-  GHC.Real.divMod :: x:a -> y:{v:a | v /= 0} -> ( {v:a | (v = (x / y)) &&
-                                                         ((x >= 0 && y >= 0) => v >= 0) &&
-                                                         ((x >= 0 && y >= 1) => v <= x) }
-                                                , {v:a | v = x mod y && ((0 <= x && 0 < y) => (0 <= v && v < y))}
-                                                )
-  GHC.Real.toInteger :: x:a -> {v:GHC.Integer.Type.Integer | v = x}
-
-// fixpoint can't handle (x mod y), only (x mod c) so we need to be more clever here
-// mod :: x:a -> y:a -> {v:a | v = (x mod y) }
diff --git a/include/GHC/Types.spec b/include/GHC/Types.spec
deleted file mode 100644
--- a/include/GHC/Types.spec
+++ /dev/null
@@ -1,41 +0,0 @@
-module spec GHC.Types where
-
-embed GHC.Prim.Int#     as int
-embed GHC.Prim.Addr#    as Str
-embed GHC.Prim.Char#    as Char
-embed GHC.Types.Double# as real
-embed GHC.Types.Float# as real
-embed GHC.Types.Word    as int 
-
-// TODO: Drop prefix below
-// GHC.Types.EQ :: {v:GHC.Types.Ordering | v = (cmp v) }
-// GHC.Types.LT :: {v:GHC.Types.Ordering | v = (cmp v) }
-// GHC.Types.GT :: {v:GHC.Types.Ordering | v = (cmp v) }
-
-// measure cmp :: GHC.Types.Ordering -> GHC.Types.Ordering
-// cmp GHC.Types.EQ = { v | v = GHC.Types.EQ }
-// cmp GHC.Types.LT = { v | v = GHC.Types.LT }
-// cmp GHC.Types.GT = { v | v = GHC.Types.GT }
-
-
-GHC.Types.True  :: {v:GHC.Types.Bool | v     }
-GHC.Types.False :: {v:GHC.Types.Bool | (~ v) }
-
-GHC.Types.isTrue#  :: n:_ -> {v:GHC.Types.Bool | (n = 1 <=> v)}
-
-GHC.Types.W# :: w:_ -> {v:GHC.Types.Word | v == w }
-
-assume GHC.Types.D# :: x:GHC.Prim.Double# -> {v: GHC.Types.Double | v = (x :: real) }
-assume GHC.Types.F# :: x:GHC.Prim.Float# -> {v: GHC.Types.Float | v = (x :: real) }
-assume GHC.Types.I# :: x:GHC.Prim.Int# -> {v: GHC.Types.Int | v = (x :: int) }
-assume GHC.Types.C# :: x:GHC.Prim.Char# -> {v: GHC.Types.Char | v = (x :: Char) }
-
-assume GHC.Prim.+#  :: x:GHC.Prim.Int# -> y:GHC.Prim.Int# -> {v: GHC.Prim.Int# | v = x + y}
-assume GHC.Prim.-#  :: x:GHC.Prim.Int# -> y:GHC.Prim.Int# -> {v: GHC.Prim.Int# | v = x - y}
-assume GHC.Prim.==# :: x:GHC.Prim.Int# -> y:GHC.Prim.Int# -> {v:GHC.Prim.Int# | v = 1 <=> x = y}
-assume GHC.Prim.>=# :: x:GHC.Prim.Int# -> y:GHC.Prim.Int# -> {v:GHC.Prim.Int# | v = 1 <=> x >= y}
-assume GHC.Prim.<=# :: x:GHC.Prim.Int# -> y:GHC.Prim.Int# -> {v:GHC.Prim.Int# | v = 1 <=> x <= y}
-assume GHC.Prim.<#  :: x:GHC.Prim.Int# -> y:GHC.Prim.Int# -> {v:GHC.Prim.Int# | v = 1 <=> x < y}
-assume GHC.Prim.>#  :: x:GHC.Prim.Int# -> y:GHC.Prim.Int# -> {v:GHC.Prim.Int# | v = 1 <=> x > y}
-
-measure addrLen :: GHC.Prim.Addr# -> GHC.Types.Int
diff --git a/include/GHC/Word.spec b/include/GHC/Word.spec
deleted file mode 100644
--- a/include/GHC/Word.spec
+++ /dev/null
@@ -1,7 +0,0 @@
-module spec GHC.Word where
-
-embed GHC.Word.Word   as int
-embed GHC.Word.Word8  as int
-embed GHC.Word.Word16 as int
-embed GHC.Word.Word32 as int
-embed GHC.Word.Word64 as int
diff --git a/include/KMeansHelper.hs b/include/KMeansHelper.hs
deleted file mode 100644
--- a/include/KMeansHelper.hs
+++ /dev/null
@@ -1,78 +0,0 @@
-module KMeansHelper where
-
-import Prelude hiding (zipWith)
-import Data.List (sort, span, minimumBy)
-import Data.Function (on)
-import Data.Ord (comparing)
-import Language.Haskell.Liquid.Prelude (liquidAssert, liquidError)
-
-
--- | Fixed-Length Lists
-
-{-@ type List a N = {v : [a] | (len v) = N} @-}
-
-
--- | N Dimensional Points
-
-{-@ type Point N = List Double N @-}
-
-{-@ type NonEmptyList a = {v : [a] | (len v) > 0} @-}
-
--- | Clustering 
-
-{-@ type Clustering a  = [(NonEmptyList a)] @-}
-
-------------------------------------------------------------------
--- | Grouping By a Predicate -------------------------------------
-------------------------------------------------------------------
-
-{-@ groupBy       :: (a -> a -> Bool) -> [a] -> (Clustering a) @-}
-groupBy _  []     =  []
-groupBy eq (x:xs) =  (x:ys) : groupBy eq zs
-  where (ys,zs)   = span (eq x) xs
-
-------------------------------------------------------------------
--- | Partitioning By a Size --------------------------------------
-------------------------------------------------------------------
-
-{-@ type PosInt = {v: Int | v > 0 } @-}
-
-{-@ partition           :: size:PosInt -> xs:[a] -> (Clustering a) / [len xs] @-}
-
-partition size []       = []
-partition size ys@(_:_) = zs : partition size zs'
-  where
-    zs                  = take size ys
-    zs'                 = drop size ys
-
------------------------------------------------------------------------
--- | Safe Zipping -----------------------------------------------------
------------------------------------------------------------------------
-
-{-@ zipWith :: (a -> b -> c) -> xs:[a] -> (List b (len xs)) -> (List c (len xs)) @-}
-zipWith f (a:as) (b:bs) = f a b : zipWith f as bs
-zipWith _ [] []         = []
-
--- Other cases only for exposition
-zipWith _ (_:_) []      = liquidError "Dead Code"
-zipWith _ [] (_:_)      = liquidError "Dead Code"
-
------------------------------------------------------------------------
--- | "Matrix" Transposition -------------------------------------------
------------------------------------------------------------------------
-
-{-@ type Matrix a Rows Cols  = (List (List a Cols) Rows) @-}
-
-{-@ transpose                :: c:Int -> r:PosInt -> Matrix a r c -> Matrix a c r @-}
-
-transpose                    :: Int -> Int -> [[a]] -> [[a]]
-transpose 0 _ _              = []
-transpose c r ((x:xs) : xss) = (x : map head xss) : transpose (c-1) r (xs : map tail xss)
-
--- Or, with comprehensions
--- transpose c r ((x:xs):xss) = (x : [ xs' | (x':_) <- xss ]) : transpose (c-1) r (xs : [xs' | (_ : xs') <- xss])
-
--- Not needed, just for exposition
-transpose c r ([] : _)       = liquidError "dead code"
-transpose c r []             = liquidError "dead code"
-
diff --git a/include/Language/Haskell/Liquid/Bag.hs b/include/Language/Haskell/Liquid/Bag.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/Bag.hs
+++ /dev/null
@@ -1,53 +0,0 @@
-module Language.Haskell.Liquid.Bag where
-
-import qualified Data.Map      as M
-
-{-@ embed   Data.Map.Map as Map_t                                         @-}
-
-{-@ measure Map_default :: Int -> Bag a                                   @-}
-{-@ measure Map_union   :: Bag a -> Bag a -> Bag a                        @-}
-{-@ measure Map_select  :: Data.Map.Map k v -> k -> v                     @-}
-{-@ measure Map_store   :: Data.Map.Map k v -> k -> v -> Data.Map.Map k v @-}
-{-@ measure bagSize     :: Bag k -> Int                                   @-}
-
--- if I just write measure fromList the measure definition is not imported
-{-@ measure fromList :: [k] -> Bag k
-fromList ([])   = (Map_default 0)
-fromList (x:xs) = Map_store (fromList xs) x (1 + (Map_select (fromList xs) x))
-@-}
-
-
-type Bag a = M.Map a Int
-
-{-@ assume empty :: {v:Bag k | v = Map_default 0} @-}
-empty :: Bag k
-empty = M.empty
-
-{-@ assume bagSize :: b:Bag k -> {i:Nat | i == bagSize b} @-}
-bagSize :: Bag k -> Int 
-bagSize b = sum (M.elems b) 
-
-{-@ fromList :: (Ord k) => xs:[k] -> {v:Bag k | v == fromList xs } @-} 
-fromList :: (Ord k) => [k] -> Bag k 
-fromList []     = empty
-fromList (x:xs) = put x (fromList xs)
-
-{-@ assume get :: (Ord k) => k:k -> b:Bag k -> {v:Nat | v = Map_select b k}  @-}
-get :: (Ord k) => k -> Bag k -> Int
-get k m = M.findWithDefault 0 k m
-
-{-@ assume put :: (Ord k) => k:k -> b:Bag k -> {v:Bag k | v = Map_store b k (1 + (Map_select b k))} @-}
-put :: (Ord k) => k -> Bag k -> Bag k
-put k m = M.insert k (1 + get k m) m
-
-{-@ assume union :: (Ord k) => m1:Bag k -> m2:Bag k -> {v:Bag k | v = Map_union m1 m2} @-}
-union :: (Ord k) => Bag k -> Bag k -> Bag k
-union m1 m2 = M.union m1 m2
-
-{-@ thm_emp :: x:k -> xs:Bag k ->  { Language.Haskell.Liquid.Bag.empty /= put x xs }  @-}
-thm_emp :: (Ord k) => k -> Bag k -> ()  
-thm_emp x xs = const () (get x xs)
-
-{-@ assume thm_size :: xs:[k] ->  { bagSize (fromList xs) == len xs }  @-}
-thm_size :: (Ord k) => [k] -> ()  
-thm_size _ = () 
diff --git a/include/Language/Haskell/Liquid/Equational.hs b/include/Language/Haskell/Liquid/Equational.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/Equational.hs
+++ /dev/null
@@ -1,55 +0,0 @@
-module Language.Haskell.Liquid.Equational where 
-
--------------------------------------------------------------------------------
--- | Proof is just unit
--------------------------------------------------------------------------------
-
-type Proof = ()
-
--------------------------------------------------------------------------------
--- | Casting expressions to Proof using the "postfix" `*** QED` 
--------------------------------------------------------------------------------
-
-data QED = QED 
-
-infixl 2 ***
-(***) :: a -> QED -> Proof
-_ *** QED = () 
-
--------------------------------------------------------------------------------
--- | Equational Reasoning operators 
--- | The `eq` operator is inlined in the logic, so can be used in reflected 
--- | functions while ignoring the equality steps. 
--------------------------------------------------------------------------------
-
-infixl 3 ==., `eq` 
-
-
-{-@ (==.) :: x:a -> y:{a | x == y} -> {v:a | v == y && v == x} @-}
-(==.) :: a -> a -> a 
-_ ==. x = x 
-{-# INLINE (==.) #-} 
-
-
-{-@ eq :: x:a -> y:{a | x == y} -> {v:a | v == y && v == x} @-}
-eq :: a -> a -> a 
-_ `eq` x = x 
-{-# INLINE eq #-} 
-
--------------------------------------------------------------------------------
--- | Explanations
--------------------------------------------------------------------------------
-
-infixl 3 ?
-
-{-@ (?) :: forall a b <pa :: a -> Bool>. a<pa> -> b -> a<pa> @-}
-(?) :: a -> b -> a 
-x ? _ = x 
-{-# INLINE (?)   #-} 
-
--------------------------------------------------------------------------------
--- | Using proofs as theorems 
--------------------------------------------------------------------------------
-
-withTheorem :: a -> Proof -> a 
-withTheorem z _ = z 
diff --git a/include/Language/Haskell/Liquid/Foreign.hs b/include/Language/Haskell/Liquid/Foreign.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/Foreign.hs
+++ /dev/null
@@ -1,64 +0,0 @@
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-{-# LANGUAGE MagicHash #-}
-
-{- OPTIONS_GHC -cpp #-}
-{- OPTIONS_GHC -cpp -fglasgow-exts -}
-
-module Language.Haskell.Liquid.Foreign where
-
-import Foreign.C.Types          (CSize(..))
-import Foreign.Ptr
-import Foreign.ForeignPtr
-import GHC.Base
-
-import Data.Word (Word64) -- Necessary to bring in scope the evidence that Word64 = int
-
--- TODO: shouldn't have to re-import these (tests/pos/imp0.hs)
-{- import Foreign.C.Types    -}
-{- import Foreign.Ptr        -}
-{- import Foreign.ForeignPtr -}
-{- import GHC.Base           -}
-
-
-
------------------------------------------------------------------------------------------------
-
-{-# NOINLINE intCSize #-}
-{-@ assume intCSize :: x:Int -> {v: CSize | v = x } @-}
-intCSize :: Int -> CSize
-intCSize = fromIntegral
-
-{-# NOINLINE cSizeInt #-}
-{-@ assume cSizeInt :: x:CSize -> {v: Int | v = x } @-}
-cSizeInt :: CSize -> Int
-cSizeInt = fromIntegral
-
-
-{-@ assume mkPtr :: x:GHC.Prim.Addr# -> {v: (Ptr b) | ((plen v) = (addrLen x) && ((plen v) >= 0)) } @-}
-mkPtr   :: Addr# -> Ptr b
-mkPtr = undefined -- Ptr x
-
-
-{-@ assume isNullPtr :: p:(Ptr a) -> {v:Bool | (v <=> (isNullPtr p)) } @-}
-isNullPtr :: Ptr a -> Bool
-isNullPtr p = (p == nullPtr)
-{-# INLINE isNullPtr #-}
-
-{-@ fpLen :: p:(ForeignPtr a) -> {v:Int | v = (fplen p) } @-}
-fpLen :: ForeignPtr a -> Int
-fpLen = undefined
-
-{-@ pLen :: p:(Ptr a) -> {v:Int | v = (plen p) } @-}
-pLen :: Ptr a -> Int
-pLen = undefined
-
-{-@ deref :: p:Ptr a -> {v:a | v = (deref p)} @-}
-deref :: Ptr a -> a
-deref = undefined
-
-{-@ eqPtr :: p:PtrV a
-          -> q:{v:PtrV a | (((pbase v) = (pbase p)) && ((plen v) <= (plen p)))}
-          -> {v:Bool | (v <=> ((plen p) = (plen q)))}
-  @-}
-eqPtr :: Ptr a -> Ptr a -> Bool
-eqPtr = undefined
diff --git a/include/Language/Haskell/Liquid/List.hs b/include/Language/Haskell/Liquid/List.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/List.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Language.Haskell.Liquid.List (transpose) where
-
-{-@ lazy transpose @-}
-transpose                  :: Int -> [[a]] -> [[a]]
-transpose _ []             = []
-transpose n ([]   : xss)   = transpose n xss
-transpose n ((x:xs) : xss) = (x : [h | (h:_) <- xss]) : transpose (n - 1) (xs : [ t | (_:t) <- xss])
diff --git a/include/Language/Haskell/Liquid/Prelude.hs b/include/Language/Haskell/Liquid/Prelude.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/Prelude.hs
+++ /dev/null
@@ -1,142 +0,0 @@
-{-# LANGUAGE MagicHash      #-}
-
-module Language.Haskell.Liquid.Prelude where
-
--------------------------------------------------------------------
---------------------------- Arithmetic ----------------------------
--------------------------------------------------------------------
-
-{-@ assume plus   :: x:{v:Int | true } -> y:{v:Int | true} -> {v:Int | v = x + y}  @-}
-{-@ assume minus  :: x:{v:Int | true } -> y:{v:Int | true} -> {v:Int | v = x - y} @-}
-{-@ assume times  :: x:Int -> y:Int -> Int                           @-}
-{-@ assume eq     :: x:Int -> y:Int -> {v:Bool | ((v) <=> x = y)}  @-}
-{-@ assume neq    :: x:Int -> y:Int -> {v:Bool | ((v) <=> x != y)} @-}
-{-@ assume leq    :: x:Int -> y:Int -> {v:Bool | ((v) <=> x <= y)} @-}
-{-@ assume geq    :: x:Int -> y:Int -> {v:Bool | ((v) <=> x >= y)} @-}
-{-@ assume lt     :: x:Int -> y:Int -> {v:Bool | ((v) <=> x < y)}  @-}
-{-@ assume gt     :: x:Int -> y:Int -> {v:Bool | ((v) <=> x > y)}  @-}
-
-{-# NOINLINE plus #-}
-plus :: Int -> Int -> Int
-plus x y = x + y
-
-{-# NOINLINE minus #-}
-minus :: Int -> Int -> Int
-minus x y = x - y
-
-{-# NOINLINE times #-}
-times :: Int -> Int -> Int
-times x y = x * y
-
--------------------------------------------------------------------
---------------------------- Comparisons ---------------------------
--------------------------------------------------------------------
-
-{-# NOINLINE eq #-}
-eq :: Int -> Int -> Bool
-eq x y = x == y
-
-{-# NOINLINE neq #-}
-neq :: Int -> Int -> Bool
-neq x y = not (x == y)
-
-{-# NOINLINE leq #-}
-leq :: Int -> Int -> Bool
-leq x y = x <= y
-
-{-# NOINLINE geq #-}
-geq :: Int -> Int -> Bool
-geq x y = x >= y
-
-{-# NOINLINE lt #-}
-lt :: Int -> Int -> Bool
-lt x y = x < y
-
-{-# NOINLINE gt #-}
-gt :: Int -> Int -> Bool
-gt x y = x > y
-
--------------------------------------------------------------------
------------------------- Specifications ---------------------------
--------------------------------------------------------------------
-
-
-{-@ ignore liquidAssertB @-}
-{-@ assume liquidAssertB :: x:{v:Bool | v} -> {v: Bool | v} @-}
-{-# NOINLINE liquidAssertB #-}
-liquidAssertB :: Bool -> Bool
-liquidAssertB b = b
-
-{-@ assume liquidAssert :: {v:Bool | v} -> a -> a  @-}
-{-# NOINLINE liquidAssert #-}
-liquidAssert :: Bool -> a -> a
-liquidAssert _ x = x
-
-{-@ ignore liquidAssume @-}
-{-@ assume liquidAssume :: b:Bool -> a -> {v: a | b}  @-}
-{-# NOINLINE liquidAssume #-}
-liquidAssume :: Bool -> a -> a
-liquidAssume b x = if b then x else error "liquidAssume fails"
-
-{-@ ignore liquidAssumeB @-}
-{-@ assume liquidAssumeB :: forall <p :: a -> Bool>. (a<p> -> {v:Bool| v}) -> a -> a<p> @-}
-liquidAssumeB :: (a -> Bool) -> a -> a
-liquidAssumeB p x | p x = x
-                  | otherwise = error "liquidAssumeB fails"
-
-
-{-@ ignore unsafeError @-}
-{-# NOINLINE unsafeError #-}
-unsafeError :: String -> a
-unsafeError = error
-
-
-{-@ liquidError :: {v:String | 0 = 1} -> a  @-}
-{-# NOINLINE liquidError #-}
-liquidError :: String -> a
-liquidError = error
-
-{-@ assume crash  :: forall a . x:{v:Bool | v} -> a @-}
-{-# NOINLINE crash #-}
-crash :: Bool -> a
-crash = undefined
-
-{-# NOINLINE force #-}
-force :: Bool
-force = True
-
-{-# NOINLINE choose #-}
-choose :: Int -> Int
-choose = undefined
-
--------------------------------------------------------------------
------------ Modular Arithmetic Wrappers ---------------------------
--------------------------------------------------------------------
-
--- tedium because fixpoint doesn't want to deal with (x mod y) only (x mod c)
-{-@ assume isEven :: x:Int -> {v:Bool | ((v) <=> ((x mod 2) = 0))} @-}
-{-# NOINLINE isEven #-}
-isEven   :: Int -> Bool
-isEven x = x `mod` 2 == 0
-
-{-@ assume isOdd :: x:Int -> {v:Bool | ((v) <=> ((x mod 2) = 1))} @-}
-{-# NOINLINE isOdd #-}
-isOdd   :: Int -> Bool
-isOdd x = x `mod` 2 == 1
-
------------------------------------------------------------------------------------------------
-
-{-@ safeZipWith :: (a -> b -> c) -> xs : [a] -> ys:{v:[b] | len v = len xs} 
-                -> {v : [c] | len v = len xs } @-}
-safeZipWith :: (a->b->c) -> [a]->[b]->[c]
-safeZipWith f (a:as) (b:bs) = f a b : safeZipWith f as bs
-safeZipWith _ []     []     = []
-safeZipWith _ _ _ = error "safeZipWith: cannot happen!"
-
-{-@ (==>) :: p:Bool -> q:Bool -> {v:Bool | v <=> (p =>  q)} @-}
-infixr 8 ==>
-(==>) :: Bool -> Bool -> Bool
-False ==> False = True
-False ==> True  = True
-True  ==> True  = True
-True  ==> False = False
diff --git a/include/Language/Haskell/Liquid/Prelude.pred b/include/Language/Haskell/Liquid/Prelude.pred
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/Prelude.pred
+++ /dev/null
@@ -1,22 +0,0 @@
-assume (>) :: forall a. forAll p1:a p2:a. (Ord a^True) => a^p1 -> a^p2 -> Bool
-assume (<) :: forall a. forAll p1:a p2:a. (Ord a^True) => a^p1 -> a^p2 -> Bool
-assume (>=) :: forall a. forAll p1:a p2:a. (Ord a^True) => a^p1 -> a^p2 -> Bool
-assume (<=) :: forall a. forAll p1:a p2:a. (Ord a^True) => a^p1 -> a^p2 -> Bool
-assume (==) :: forall a. forAll p1:a p2:a. (Ord a^True) => a^p1 -> a^p2 -> Bool
-assume (+) :: forall a. forAll p1:a p2:a. (Ord a^True) => a^p1 -> a^p2 -> a^True
-assume (*) :: forall a. forAll p1:a p2:a. (Ord a^True) => a^p1 -> a^p2 -> a^True
-assume (-) :: forall a. forAll p1:a p2:a. (Ord a^True) => a^p1 -> a^p2 -> a^True
-assume ($) :: forall a b. forAll q1:a q2:b. (a^q1 -> b^q2) -> a^q1 -> b^q2
-assume (.) :: forall b c a. forAll q1:a q2:b q3:c. (b^q2 -> c^q3) -> (a^q1 -> b^q2) -> a^q1 -> c^q3
-assume filter :: forall a. forAll p1:a. (a^p1 -> Bool) -> [a^p1]-> [a^p1]
-assume snd :: forall a b. forAll p1:a p2:b. (a^p1, b^p2)-> b^p2
-assume map :: forall a b. forAll q1:a q2:b. (a^q1 -> b^q2) -> [a^q1]-> [b^q2]
-assume (++) :: forall a. forAll q:a. [a^q]-> [a^q]-> [a^q]
-assume concat :: forall a. forAll q:a. [[a^q]]-> [a^q]
-assume foldl :: forall a b. forAll q1:a q2:b. (a^q1 -> b^q2 -> a^q1) -> a^q1 -> [b^q2]-> a^q1
-assume foldr :: forall a b. forAll q1:a q2:b. (a^q1 -> b^q2 -> b^q2) -> b^q2 -> [a^q1]-> b^q2
-assume (,) :: forall a b. forAll q1:a q2:b. a^q1 -> b^q2 ->(a^q1, b^q2)
-assume Prelude.error :: forall a. forAll q2:a. [Char]-> a^q2
-assume Prelude.head :: forall a. forAll q:a. [a^q]-> a^q
-assume Prelude.tail :: forall a. forAll q:a. [a^q]-> [a^q]
-assume Prelude.enumFromTo :: forall a. forAll q:a. (Enum a^ True) => a^q -> a^q -> [a^q]
diff --git a/include/Language/Haskell/Liquid/ProofCombinators.hs b/include/Language/Haskell/Liquid/ProofCombinators.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/ProofCombinators.hs
+++ /dev/null
@@ -1,183 +0,0 @@
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE TypeFamilies          #-}
-{-# LANGUAGE IncoherentInstances   #-}
-
-module Language.Haskell.Liquid.ProofCombinators (
-
-  -- ATTENTION! `Admit` and `(==!)` are UNSAFE: they should not belong the final proof term
-
-  -- * Proof is just a () alias
-  Proof
-  , toProof 
-
-  -- * Proof constructors
-  , trivial, unreachable, (***), QED(..)
-
-  -- * Proof certificate constructors
-  , (?)
-
-  -- * These two operators check all intermediate equalities
-  , (===) -- proof of equality is implicit eg. x === y
-  , (=<=) -- proof of equality is implicit eg. x <= y
-  , (=>=)  -- proof of equality is implicit eg. x =>= y 
-
-  -- * This operator does not check intermediate equalities
-  , (==.) 
-
-  -- Uncheck operator used only for proof debugging
-  , (==!) -- x ==! y always succeeds
-
-  -- * Combining Proofs
-  , (&&&)
-  , withProof 
-  , impossible 
-
-
-) where
-
--------------------------------------------------------------------------------
--- | Proof is just a () alias -------------------------------------------------
--------------------------------------------------------------------------------
-
-type Proof = ()
-
-toProof :: a -> Proof
-toProof _ = ()
-
--------------------------------------------------------------------------------
--- | Proof Construction -------------------------------------------------------
--------------------------------------------------------------------------------
-
--- | trivial is proof by SMT
-
-trivial :: Proof
-trivial =  ()
-
--- {-@ unreachable :: {v : Proof | False } @-}
-unreachable :: Proof
-unreachable =  ()
-
--- All proof terms are deleted at runtime.
-{- RULE "proofs are irrelevant" forall (p :: Proof). p = () #-}
-
--- | proof casting
--- | `x *** QED`: x is a proof certificate* strong enough for SMT to prove your theorem
--- | `x *** Admit`: x is an unfinished proof
-
-infixl 3 ***
-{-@ assume (***) :: a -> p:QED -> { if (isAdmit p) then false else true } @-}
-(***) :: a -> QED -> Proof
-_ *** _ = ()
-
-data QED = Admit | QED
-
-{-@ measure isAdmit :: QED -> Bool @-}
-{-@ Admit :: {v:QED | isAdmit v } @-}
-
-
--------------------------------------------------------------------------------
--- | * Checked Proof Certificates ---------------------------------------------
--------------------------------------------------------------------------------
-
--- Any (refined) carries proof certificates.
--- For example 42 :: {v:Int | v == 42} is a certificate that
--- the value 42 is equal to 42.
--- But, this certificate will not really be used to proof any fancy theorems.
-
--- Below we provide a number of equational operations
--- that constuct proof certificates.
-
--- | Implicit equality
-
--- x === y returns the proof certificate that
--- result value is equal to both x and y
--- when y == x (as assumed by the operator's precondition)
-
-infixl 3 ===
-{-@ (===) :: x:a -> y:{a | y == x} -> {v:a | v == x && v == y} @-}
-(===) :: a -> a -> a
-_ === y  = y
-
-infixl 3 =<=
-{-@ (=<=) :: x:a -> y:{a | x <= y} -> {v:a | v == y} @-}
-(=<=) :: a -> a -> a
-_ =<= y  = y
-
-infixl 3 =>=
-{-@ (=>=) :: x:a -> y:{a | x >= y}  -> {v:a | v == y} @-}
-(=>=) :: a -> a -> a
-_ =>= y  = y
-
--------------------------------------------------------------------------------
--- | `?` is basically Haskell's $ and is used for the right precedence
--- | `?` lets you "add" some fact into a proof term
--------------------------------------------------------------------------------
-
-infixl 3 ?
-
-{-@ (?) :: forall a b <pa :: a -> Bool, pb :: b -> Bool>. a<pa> -> b<pb> -> a<pa> @-}
-(?) :: a -> b -> a 
-x ? _ = x 
-{-# INLINE (?)   #-} 
-
--------------------------------------------------------------------------------
--- | Assumed equality
--- 	`x ==! y `
---   returns the admitted proof certificate that result value is equals x and y
--------------------------------------------------------------------------------
-
-infixl 3 ==!
-{-@ assume (==!) :: x:a -> y:a -> {v:a | v == x && v == y} @-}
-(==!) :: a -> a -> a
-(==!) _ y = y
-
-
--- | To summarize:
---
--- 	- (==!) is *only* for proof debugging
---	- (===) does not require explicit proof term
--- 	- (?)   lets you insert "lemmas" as other `Proof` values
-
--------------------------------------------------------------------------------
--- | * Unchecked Proof Certificates -------------------------------------------
--------------------------------------------------------------------------------
-
--- | The above operators check each intermediate proof step.
---   The operator `==.` below accepts an optional proof term
---   argument, but does not check intermediate steps.
---   TODO: What is it USEFUL FOR?
-
-infixl 3 ==.
-
-{-# DEPRECATED (==.) "Use (===) instead" #-}
-
-{-# INLINE (==.) #-} 
-(==.) :: a -> a -> a 
-_ ==. x = x 
-
--------------------------------------------------------------------------------
--- | * Combining Proof Certificates -------------------------------------------
--------------------------------------------------------------------------------
-
-(&&&) :: Proof -> Proof -> Proof
-x &&& _ = x
-
-
-{-@ withProof :: x:a -> b -> {v:a | v = x} @-}
-withProof :: a -> b -> a
-withProof x _ = x
-
-{-@ impossible :: {v:a | false} -> b @-}
-impossible :: a -> b
-impossible _ = undefined
-
--------------------------------------------------------------------------------
--- | Convenient Syntax for Inductive Propositions 
--------------------------------------------------------------------------------
-
-{-@ measure prop :: a -> b           @-}
-{-@ type Prop E = {v:_ | prop v = E} @-}
-
-
-
diff --git a/include/Language/Haskell/Liquid/RTick.hs b/include/Language/Haskell/Liquid/RTick.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/RTick.hs
+++ /dev/null
@@ -1,440 +0,0 @@
-
---
--- Liquidate your assets: reasoning about resource usage in Liquid Haskell.
--- Martin A.T. Handley, Niki Vazou, and Graham Hutton.
---
-
-{-@ LIQUID "--reflection" @-}
-
-module Language.Haskell.Liquid.RTick
-  (
-
-  -- Tick datatype:
-    Tick(..)
-  -- Primitive resource operators:
-  , fmap
-  , pure
-  , (<*>)
-  , liftA2
-  , return
-  , (>>=)
-  , (=<<)
-  , eqBind
-  , leqBind
-  , geqBind
-  , ap
-  , liftM
-  , liftM2
-  -- Resource modifiers:
-  , step
-  , wait      -- step 1       . return
-  , waitN     -- step (n > 0) . return
-  , go        -- step (-1)    . return
-  , goN       -- step (n < 0) . return
-  , wmap      -- step 1       . fmap f
-  , wmapN     -- step (n > 0) . fmap f
-  , gmap      -- step (-1)    . fmap f
-  , gmapN     -- step (n < 0) . fmap f
-  , (</>)     -- step 1       . (f <*>)
-  , (<//>)    -- step 2       . (f <*>)
-  , (<\>)     -- step (-1)    . (f <*>)
-  , (<\\>)    -- step (-2)    . (f <*>)
-  , (>/=)     -- step 1       . (>>= f)
-  , (=/<)     -- step 1       . (>>= f)
-  , (>//=)    -- step 2       . (>>= f)
-  , (=//<)    -- step 2       . (>>= f)
-  , (>\=)     -- step (-1)    . (>>= f)
-  , (=\<)     -- step (-1)    . (>>= f)
-  , (>\\=)    -- step (-2)    . (>>= f)
-  , (=\\<)    -- step (-2)    . (>>= f)
-  -- Memoisation:
-  , pay
-  , zipWithM
-
-
-  ) where
-
-import Prelude hiding ( Functor(..), Applicative(..), Monad(..), (=<<) )
-
-import qualified Control.Applicative as A
-import qualified Control.Monad       as M
-import qualified Data.Functor        as F
-
---
--- The 'Tick' datatype and its corresponding resource modifiers.
---
--- See 'ResourceModifiers.hs' for proofs that all resource modifiers
--- can be defined using 'return', '(>>=) 'and 'step'.
---
-
--------------------------------------------------------------------------------
--- | 'Tick' datatype for recording resource usage:
--------------------------------------------------------------------------------
-
-{-@ data Tick a = Tick { tcost :: Int, tval :: a } @-}
-data Tick a = Tick { tcost :: Int, tval :: a }
-
--------------------------------------------------------------------------------
--- | Primitive resource operators:
--------------------------------------------------------------------------------
-
-instance F.Functor Tick where
-  fmap = fmap
-
-{-@ reflect fmap @-}
-{-@ fmap :: f:(a -> b) -> t1:Tick a
-    -> { t:Tick b | Tick (tcost t1) (f (tval t1)) == t }
-@-}
-fmap :: (a -> b) -> Tick a -> Tick b
-fmap f (Tick m x) = Tick m (f x)
-
-instance A.Applicative Tick where
-  pure  = pure
-  (<*>) = (<*>)
-
-{-@ reflect pure @-}
-{-@ pure :: x:a -> { t:Tick a | x == tval t && 0 == tcost t } @-}
-pure :: a -> Tick a
-pure x = Tick 0 x
-
-{-@ reflect <*> @-}
-{-@ (<*>) :: t1:Tick (a -> b) -> t2:Tick a
-    -> { t:Tick b | (tval t1) (tval t2) == tval  t &&
-                    tcost t1 + tcost t2 == tcost t }
-@-}
-infixl 4 <*>
-(<*>) :: Tick (a -> b) -> Tick a -> Tick b
-Tick m f <*> Tick n x = Tick (m + n) (f x)
-
-{-@ reflect liftA2 @-}
-{-@ liftA2 :: f:(a -> b -> c) -> t1:Tick a -> t2:Tick b
-    -> { t:Tick c | f (tval t1) (tval t2) == tval  t &&
-                      tcost t1 + tcost t2 == tcost t }
-@-}
-liftA2 :: (a -> b -> c) -> Tick a -> Tick b -> Tick c
-liftA2 f (Tick m x) (Tick n y) = Tick (m + n) (f x y)
-
-instance M.Monad Tick where
-  return = return
-  (>>=)  = (>>=)
-
-{-@ reflect return @-}
-{-@ return :: x:a -> { t:Tick a | x == tval t && 0 == tcost t } @-}
-return :: a -> Tick a
-return x = Tick 0 x
-
-{-@ reflect >>= @-}
-{-@ (>>=) :: t1:Tick a -> f:(a -> Tick b)
-    -> { t:Tick b | tval (f (tval t1))  == tval  t &&
-         tcost t1 + tcost (f (tval t1)) == tcost t }
-@-}
-infixl 4 >>=
-(>>=) :: Tick a -> (a -> Tick b) -> Tick b
-Tick m x >>= f = let Tick n y = f x in Tick (m + n) y
-
-{-@ reflect =<< @-}
-{-@ (=<<) :: f:(a -> Tick b) -> t1:Tick a
-    -> { t:Tick b | tval (f (tval t1))  == tval  t &&
-         tcost t1 + tcost (f (tval t1)) == tcost t }
-@-}
-infixl 4 =<<
-(=<<) :: (a -> Tick b) -> Tick a -> Tick b
-f =<< Tick m x = let Tick n y = f x in Tick (m + n) y
-
-{-@ reflect ap @-}
-{-@ ap :: t1:(Tick (a -> b)) -> t2:Tick a
-    -> { t:Tick b | (tval t1) (tval t2) == tval  t &&
-                    tcost t1 + tcost t2 == tcost t }
-@-}
-ap :: Tick (a -> b) -> Tick a -> Tick b
-ap (Tick m f) (Tick n x) = Tick (m + n) (f x)
-
-{-@ reflect liftM @-}
-{-@ liftM :: f:(a -> b) -> t1:Tick a -> { t:Tick b | tcost t1 == tcost t } @-}
-liftM :: (a -> b) -> Tick a -> Tick b
-liftM f (Tick m x) = Tick m (f x)
-
-{-@ reflect liftM2 @-}
-{-@ liftM2 :: f:(a -> b -> c) -> t1:Tick a -> t2:Tick b
-    -> { t:Tick c | f (tval t1) (tval t2) == tval  t &&
-                      tcost t1 + tcost t2 == tcost t }
-@-}
-liftM2 :: (a -> b -> c) -> Tick a -> Tick b -> Tick c
-liftM2 f (Tick m x) (Tick n y) = Tick (m + n) (f x y)
-
--------------------------------------------------------------------------------
-
-{-@ reflect eqBind @-}
-{-@ eqBind :: n:Int -> t1:Tick a
-    -> f:(a -> { tf:Tick b | n == tcost tf })
-    -> { t:Tick b | tval (f (tval t1))  == tval  t &&
-                           tcost t1 + n == tcost t }
-@-}
-eqBind :: Int -> Tick a -> (a -> Tick b) -> Tick b
-eqBind _ (Tick m x) f = let Tick n y = f x in Tick (m + n) y
-
-{-@ reflect leqBind @-}
-{-@ leqBind :: n:Int -> t1:Tick a
-    -> f:(a -> { tf:Tick b | n >= tcost tf })
-    -> { t:Tick b | tcost t1 + n >= tcost t }
-@-}
-leqBind :: Int -> Tick a -> (a -> Tick b) -> Tick b
-leqBind _ (Tick m x) f = let Tick n y = f x in Tick (m + n) y
-
-{-@ reflect geqBind @-}
-{-@ geqBind :: n:Int -> t1:Tick a
-    -> f:(a -> { tf:Tick b | n <= tcost tf })
-    -> { t2:Tick b | tcost t1 + n <= tcost t2 }
-@-}
-geqBind :: Int -> Tick a -> (a -> Tick b) -> Tick b
-geqBind _ (Tick m x) f = let Tick n y = f x in Tick (m + n) y
-
--------------------------------------------------------------------------------
--- | Resource modifiers:
--------------------------------------------------------------------------------
-
-{-@ reflect step @-}
-{-@ step :: m:Int -> t1:Tick a
-    -> { t:Tick a | tval t1 == tval t && m + tcost t1 == tcost t }
-@-}
-step :: Int -> Tick a -> Tick a
-step m (Tick n x) = Tick (m + n) x
-
---
--- @wait := step 1 . return@.
---
-{-@ reflect wait @-}
-{-@ wait :: x:a -> { t:Tick a | x == tval t && 1 == tcost t } @-}
-wait :: a -> Tick a
-wait x = Tick 1 x
-
---
--- @waitN (n > 0) := step n . return@.
---
-{-@ reflect waitN @-}
-{-@ waitN :: n:Nat -> x:a
-    -> { t:Tick a | x == tval t && n == tcost t }
-@-}
-waitN :: Int -> a -> Tick a
-waitN n x = Tick n x
-
---
--- @go := step (-1) . return@.
---
-{-@ reflect go @-}
-{-@ go :: x:a -> { t:Tick a | x == tval t && (-1) == tcost t } @-}
-go :: a -> Tick a
-go x = Tick (-1) x
-
---
--- @goN (n > 0) := step (-n) . return@.
---
-{-@ reflect goN @-}
-{-@ goN :: { n:Nat | n > 0 } -> x:a
-    -> { t:Tick a | x == tval t && (-n) == tcost t }
-@-}
-goN :: Int -> a -> Tick a
-goN n x = Tick (-n) x
-
---
--- @wmap f := step 1 . fmap f@.
---
-{-@ reflect wmap @-}
-{-@ wmap :: f:(a -> b) -> t1:Tick a
-    -> { t:Tick b | Tick (1 + tcost t1) (f (tval t1)) == t }
-@-}
-wmap :: (a -> b) -> Tick a -> Tick b
-wmap f (Tick m x) = Tick (1 + m) (f x)
-
---
--- @wmapN (n > 0) f := step n . fmap f@.
---
-{-@ reflect wmapN @-}
-{-@ wmapN :: { m:Nat | m > 0 } -> f:(a -> b) -> t1:Tick a
-    -> { t:Tick b | Tick (m + tcost t1) (f (tval t1)) == t }
-@-}
-wmapN :: Int -> (a -> b) -> Tick a -> Tick b
-wmapN m f (Tick n x) = Tick (m + n) (f x)
-
---
--- @gmap f := step (-1) . fmap f@.
---
-{-@ reflect gmap @-}
-{-@ gmap :: f:(a -> b) -> t1:Tick a
-    -> { t:Tick b | Tick (tcost t1 - 1) (f (tval t1)) == t }
-@-}
-gmap :: (a -> b) -> Tick a -> Tick b
-gmap f (Tick m x) = Tick (m - 1) (f x)
-
---
--- @gmapN (n > 0) f := step (-n) . fmap f@.
---
-{-@ reflect gmapN @-}
-{-@ gmapN :: { m:Nat | m > 0 } -> f:(a -> b) -> t1:Tick a
-    -> { t:Tick b | Tick (tcost t1 - m) (f (tval t1)) == t }
-@-}
-gmapN :: Int -> (a -> b) -> Tick a -> Tick b
-gmapN m f (Tick n x) = Tick (n - m) (f x)
-
---
--- \"wapp\": @(f </>) := step 1 . (f <*>)@.
---
-{-@ reflect </> @-}
-{-@ (</>) :: t1:(Tick (a -> b)) -> t2:Tick a
-    -> { t:Tick b | (tval t1) (tval t2) == tval  t &&
-                1 + tcost t1 + tcost t2 == tcost t }
-@-}
-infixl 4 </>
-(</>) :: Tick (a -> b) -> Tick a -> Tick b
-Tick m f </> Tick n x = Tick (1 + m + n) (f x)
-
---
--- \"wwapp\": @(f <//>) := step 2 . (f <*>)@.
---
-{-@ reflect <//> @-}
-{-@ (<//>) :: t1:(Tick (a -> b)) -> t2:Tick a
-    -> { t:Tick b | (tval t1) (tval t2) == tval  t &&
-                2 + tcost t1 + tcost t2 == tcost t }
-@-}
-infixl 4 <//>
-(<//>) :: Tick (a -> b) -> Tick a -> Tick b
-Tick m f <//> Tick n x = Tick (2 + m + n) (f x)
-
---
--- \"gapp\": @(f <\>) := step (-1) . (f <*>)@.
---
-{-@ reflect <\> @-}
-{-@ (<\>) :: t1:(Tick (a -> b)) -> t2:Tick a
-    -> { t:Tick b | (tval t1) (tval t2) == tval  t &&
-                tcost t1 + tcost t2 - 1 == tcost t }
-@-}
-infixl 4 <\>
-(<\>) :: Tick (a -> b) -> Tick a -> Tick b
-Tick m f <\> Tick n x = Tick (m + n - 1) (f x)
-
---
--- \"ggapp\": @(f <\\>) := step (-2) . (f <*>)@.
---
-{-@ reflect <\\> @-}
-{-@ (<\\>) :: t1:(Tick (a -> b)) -> t2:Tick a
-    -> { t:Tick b | (tval t1) (tval t2) == tval  t &&
-                tcost t1 + tcost t2 - 2 == tcost t }
-@-}
-infixl 4 <\\>
-(<\\>) :: Tick (a -> b) -> Tick a -> Tick b
-Tick m f <\\> Tick n x = Tick (m + n - 2) (f x)
-
---
--- \"wbind\": @(>/= f) := step 1 . (>>= f)@.
---
-{-@ reflect >/= @-}
-{-@ (>/=) :: t1:Tick a -> f:(a -> Tick b)
-    -> { t:Tick b | (tval (f (tval t1))      == tval  t) &&
-         (1 + tcost t1 + tcost (f (tval t1))) == tcost t }
-@-}
-infixl 4 >/=
-(>/=) :: Tick a -> (a -> Tick b) -> Tick b
-Tick m x >/= f = let Tick n y = f x in Tick (1 + m + n) y
-
---
--- \"wbind\": @(f =/<) := step 1 . (f =<<)@.
---
-{-@ reflect =/< @-}
-{-@ (=/<) :: f:(a -> Tick b) -> t1:Tick a
-    -> { t:Tick b | tval (f (tval t1))      == tval  t &&
-         1 + tcost t1 + tcost (f (tval t1)) == tcost t }
-@-}
-infixl 4 =/<
-(=/<) :: (a -> Tick b) -> Tick a -> Tick b
-f =/< Tick m x = let Tick n y = f x in Tick (1 + m + n) y
-
---
--- \"wwbind\": @(>//= f) := step 2 . (>>= f)@.
---
-{-@ reflect >//= @-}
-{-@ (>//=) :: t1:Tick a -> f:(a -> Tick b)
-    -> { t:Tick b | tval (f (tval t1))      == tval  t &&
-         2 + tcost t1 + tcost (f (tval t1)) == tcost t }
-@-}
-infixl 4 >//=
-(>//=) :: Tick a -> (a -> Tick b) -> Tick b
-Tick m x >//= f = let Tick n y = f x in Tick (2 + m + n) y
-
---
--- \"wwbind\": @(f =//<) := step 2 . (f =<<)@.
---
-{-@ reflect =//< @-}
-{-@ (=//<) :: f:(a -> Tick b) -> t1:Tick a
-    -> { t:Tick b | tval (f (tval t1))      == tval  t &&
-         2 + tcost t1 + tcost (f (tval t1)) == tcost t }
-@-}
-infixl 4 =//<
-(=//<) :: (a -> Tick b) -> Tick a -> Tick b
-f =//< Tick m x = let Tick n y = f x in Tick (2 + m + n) y
-
---
--- \"gbind\": @(>\= f) := step (-1) . (>>= f)@.
---
-{-@ reflect >\= @-}
-{-@ (>\=) :: t1:Tick a -> f:(a -> Tick b)
-    -> { t:Tick b | tval (f (tval t1))      == tval  t &&
-         tcost t1 + tcost (f (tval t1)) - 1 == tcost t }
-@-}
-infixl 4 >\=
-(>\=) :: Tick a -> (a -> Tick b) -> Tick b
-Tick m x >\= f = let Tick n y = f x in Tick (m + n - 1) y
-
---
--- \"gbind\": @(f =\<) := step (-1) . (f =<<)@.
---
-{-@ reflect =\< @-}
-{-@ (=\<) :: f:(a -> Tick b) -> t1:Tick a
-    -> { t:Tick b | tval (f (tval t1))      == tval  t &&
-         tcost t1 + tcost (f (tval t1)) - 1 == tcost t }
-@-}
-infixl 4 =\<
-(=\<) :: (a -> Tick b) -> Tick a -> Tick b
-f =\< Tick m x = let Tick n y = f x in Tick (m + n - 1) y
-
---
--- \"ggbind\": @(>\= f) := step (-2) . (>>= f)@.
---
-{-@ reflect >\\= @-}
-{-@ (>\\=) :: t1:Tick a -> f:(a -> Tick b)
-    -> { t:Tick b | tval (f (tval t1))      == tval  t &&
-         tcost t1 + tcost (f (tval t1)) - 2 == tcost t }
-@-}
-infixl 4 >\\=
-(>\\=) :: Tick a -> (a -> Tick b) -> Tick b
-Tick m x >\\= f = let Tick n y = f x in Tick (m + n - 2) y
-
---
--- \"ggbind\": @(f =\\<) := step (-2) . (f =<<)@.
---
-{-@ reflect =\\< @-}
-{-@ (=\\<) :: f:(a -> Tick b) -> t1:Tick a
-    -> { t:Tick b | tval (f (tval t1))      == tval  t &&
-         tcost t1 + tcost (f (tval t1)) - 2 == tcost t }
-@-}
-infixl 4 =\\<
-(=\\<) :: (a -> Tick b) -> Tick a -> Tick b
-f =\\< Tick m x = let Tick n y = f x in Tick (m + n - 2) y
-
--------------------------------------------------------------------------------
--- | Memoisation:
--------------------------------------------------------------------------------
-
-{-@ reflect pay @-}
-{-@ pay :: m:Int
-    -> { t1:Tick a | m <= tcost t1 }
-    -> { t:Tick ({ t2 : Tick a | tcost t1 - m == tcost t2 }) | m == tcost t }
-@-}
-pay :: Int -> Tick a -> Tick (Tick a)
-pay m (Tick n x) = Tick m (Tick (n - m) x)
-
-
-{-@ reflect zipWithM @-}
-{-@ zipWithM :: f:(a -> b -> Tick c) -> x:Tick a -> y:Tick b
--> {t:Tick c | tcost t == tcost x + tcost y + tcost (f (tval x) (tval y))} @-}
-zipWithM :: (a -> b -> Tick c) -> Tick a -> Tick b -> Tick c
-zipWithM f (Tick c1 x1) (Tick c2 x2) = let Tick c x = f x1 x2 in Tick (c + c1 + c2) x
diff --git a/include/Language/Haskell/Liquid/RTick/Combinators.hs b/include/Language/Haskell/Liquid/RTick/Combinators.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/RTick/Combinators.hs
+++ /dev/null
@@ -1,366 +0,0 @@
-
---
--- Liquidate your assets: reasoning about resource usage in Liquid Haskell.
---
-
-{-@ LIQUID "--reflection" @-}
-
-module Language.Haskell.Liquid.RTick.Combinators
-  (
-
-  -- Basic:
-    Proof         -- Simply the unit type.
-  , QED(..)       -- 'ASS': Signify the end of an /unfinished/ proof.
-                  -- 'QED': Signify the end of a /complete/ proof.
-  , (&&&)         -- Combine proofs.
-  , (***)         -- Discard final result at the end of a proof.
-  , (?)           -- Appeal to an external theorem.
-  , isAss         -- Check whether a proof is complete.
-  , toProof       -- Cast to proof.
-  , trivial       -- Trivial proof.
-  , withTheorem   -- Appeal to an external theorem.
-  -- Equational:
-  , (==.)         -- Equality.
-  , (==?)         -- Equality (assumption).
-  , eq            -- Equality. Note: 'eq' is inlined in the logic.
-  -- Inequational:
-  , (<.)          -- Less than.
-  , (<?)          -- Less than (assumption).
-  , (<=.)         -- Less than or equal.
-  , (<=?)         -- Less than or equal (assumption).
-  , (>.)          -- Greater than.
-  , (>?)          -- Greater than (assumption).
-  , (>=.)         -- Greater than or equal.
-  , (>=?)         -- Greater than or equal (assumption).
-  , (<=>.)        -- Cost equivalence.
-  , (<=>?)        -- Cost equivalence (assumption)
-  , (>~>.)        -- Improvement.
-  , (>~>?)        -- Improvement (assumption).
-  , (.>==)        -- Quantified improvement.
-  , (?>==)        -- Quantified improvement (assumption).
-  , (<~<.)        -- Diminishment.
-  , (<~<?)        -- Diminishment (assumption).
-  , (.<==)        -- Quantified diminishment.
-  , (?<==)        -- Quantified diminishment (assumption).
-  -- Cost separators:
-  , (==>.)        -- Quantified improvement.
-  , (==>?)        -- Quantified improvement (assumption).
-  , (==<.)        -- Quantified diminishment.
-  , (==<?)        -- Quantified diminishment (assumption).
-  , (==!)
-  , assert
-  ) where
-
-import Language.Haskell.Liquid.RTick ( Tick(..) )
-
---
--- Proof combinators for extrinsic cost analysis.
---
-
--------------------------------------------------------------------------------
--- | Basic:
--------------------------------------------------------------------------------
-
-{-@ assert :: b:{Bool | b} -> {b} @-}
-assert :: Bool -> Proof
-assert _ = ()
-
--- unchecked
-(==!) :: a -> a -> a
-_ ==! x = x
-
-
-type Proof = ()
-data QED   = QED | ASS
-
-{-@ toProof :: a -> Proof @-}
-toProof :: a -> Proof
-toProof _ = ()
-{-# INLINE toProof #-}
-
-{-@ trivial :: Proof @-}
-trivial :: Proof
-trivial = ()
-{-# INLINE trivial #-}
-
-{-@ measure isAss @-}
-isAss :: QED -> Bool
-isAss ASS = True
-isAss QED = False
-
-{-@ assume (***) :: a -> qed:QED -> { if (isAss qed) then false else true } @-}
-infixl 1 ***
-(***) :: a -> QED -> Proof
-_ *** _ = ()
-{-# INLINE (***) #-}
-
-{-@ (?) :: x:a -> Proof -> { v:a | x == v } @-}
-infixl 3 ?
-(?) :: a -> Proof -> a
-x ? _ = x
-{-# INLINE (?) #-}
-
-{-@ (&&&) :: Proof -> Proof -> Proof @-}
-infixl 3 &&&
-(&&&) :: Proof -> Proof -> Proof
-x &&& _ = x
-{-# INLINE (&&&) #-}
-
-{-@ withTheorem :: x:a -> Proof -> { v:a | x == v } @-}
-withTheorem :: a -> Proof -> a
-withTheorem x _ = x
-{-# INLINE withTheorem #-}
-
--------------------------------------------------------------------------------
--- | Equational:
--------------------------------------------------------------------------------
-
---
--- Equality.
---
-{-@ (==.) :: x:a -> { y:a | x == y } -> { v:a | x == v && y == v } @-}
-infixl 3 ==.
-(==.) :: a -> a -> a
-_ ==. x = x
-{-# INLINE (==.) #-}
-
-{-@ assume (==?) :: x:a -> y:a -> { v:a | x == v && y == v } @-}
-infixl 3 ==?
-(==?) :: a -> a -> a
-_ ==? x = x
-{-# INLINE (==?) #-}
-
---
--- Equality. Note: 'eq' is inlined in the logic, so can be used in
--- reflected functions.
---
-{-@ eq :: x:a -> { y:a | x == y } -> { v:a | x == v && y == v } @-}
-eq :: a -> a -> a
-_ `eq` x = x
-{-# INLINE eq #-}
-
--------------------------------------------------------------------------------
--- | Inequational:
--------------------------------------------------------------------------------
-
---
--- Less than.
---
-{-@ (<.) :: m:a -> { n:a | m < n } -> { o:a | o == n } @-}
-infixl 3 <.
-(<.) :: a -> a -> a
-_ <. n = n
-{-# INLINE (<.) #-}
-
-{-@ assume (<?) :: m:a -> n:a -> { o:a | o == n && m < n } @-}
-infixl 3 <?
-(<?) :: a -> a -> a
-_ <? n = n
-{-# INLINE (<?) #-}
-
---
--- Less than or equal.
---
-{-@ (<=.) :: m:a -> { n:a | m <= n } -> { o:a | o == n } @-}
-infixl 3 <=.
-(<=.) :: a -> a -> a
-_ <=. n = n
-{-# INLINE (<=.) #-}
-
-{-@ assume (<=?) :: m:a -> n:a -> { o:a | o == n && m <= n } @-}
-infixl 3 <=?
-(<=?) :: a -> a -> a
-_ <=? n = n
-{-# INLINE (<=?) #-}
-
---
--- Greater than.
---
-{-@ (>.) :: m:a -> { n:a | m > n } -> { o:a | o == n } @-}
-infixl 3 >.
-(>.) :: a -> a -> a
-_ >. y = y
-{-# INLINE (>.) #-}
-
-{-@ assume (>?) :: m:a -> n:a -> { o:a | o == n && m > n } @-}
-infixl 3 >?
-(>?) :: a -> a -> a
-_ >? y = y
-{-# INLINE (>?) #-}
-
---
--- Greater than or equal.
---
-{-@ (>=.) :: m:a -> { n:a | m >= n } -> { o:a | o == n } @-}
-infixl 3 >=.
-(>=.) :: a -> a -> a
-_ >=. n = n
-{-# INLINE (>=.) #-}
-
-{-@ assume (>=?) :: m:a -> n:a -> { o:a | o == n && m >= n } @-}
-infixl 3 >=?
-(>=?) :: a -> a -> a
-_ >=? n = n
-{-# INLINE (>=?) #-}
-
---
--- Cost equivalence.
---
-{-@ predicate COSTEQ T1 T2 = tval T1 == tval T2 && tcost T1 == tcost T2 @-}
-
-{-@ (<=>.)
-  :: t1:Tick a
-  -> { t2:Tick a | COSTEQ t1 t2 }
-  -> { t3:Tick a | COSTEQ t1 t2 && COSTEQ t1 t3 && COSTEQ t2 t3 }
-@-}
-infixl 3 <=>.
-(<=>.) :: Tick a -> Tick a -> Tick a
-(<=>.) _ t2 = t2
-{-# INLINE (<=>.) #-}
-
-{-@ assume (<=>?)
-  :: t1:Tick a -> t2:Tick a
-  -> { t3:Tick a | COSTEQ t1 t2 && COSTEQ t1 t3 && t2 == t3 }
-@-}
-infixl 3 <=>?
-(<=>?) :: Tick a -> Tick a -> Tick a
-(<=>?) _ t2 = t2
-{-# INLINE (<=>?) #-}
-
---
--- Improvement.
---
-{-@ predicate IMP T1 T2 = tval T1 == tval T2 && tcost T1 >= tcost T2 @-}
-
-{-@ (>~>.)
-  :: t1:Tick a
-  -> { t2:Tick a | IMP t1 t2 }
-  -> { t3:Tick a | IMP t1 t2 && IMP t1 t3 && t2 == t3 }
-@-}
-infixl 3 >~>.
-(>~>.) :: Tick a -> Tick a -> Tick a
-(>~>.) _ t2 = t2
-{-# INLINE (>~>.) #-}
-
-{-@ assume (>~>?)
-  :: t1:Tick a -> t2:Tick a
-  -> { t3:Tick a | IMP t1 t2 && IMP t1 t3 && t2 == t3 }
-@-}
-infixl 3 >~>?
-(>~>?) :: Tick a -> Tick a -> Tick a
-(>~>?) _ t2 = t2
-{-# INLINE (>~>?) #-}
-
---
--- Quantified improvement.
---
-{-@ predicate QIMP T1 N T2 = tval T1 == tval T2 && tcost T1 == tcost T2 + N @-}
-
-{-@ (.>==)
-  :: t1:Tick a
-  -> n:Int
-  -> { t2:Tick a | QIMP t1 n t2 }
-  -> { t3:Tick a | QIMP t1 n t2 && QIMP t1 n t3 && t2 == t3 }
-@-}
-infixl 3 .>==
-(.>==) :: Tick a -> Int -> Tick a -> Tick a
-(.>==) _ _ t2 = t2
-{-# INLINE (.>==) #-}
-
-{-@ assume (?>==)
-  :: t1:Tick a -> n:Nat -> t2:Tick a
-  -> { t3:Tick a | QIMP t1 n t2 && QIMP t1 n t3 && t2 == t3 }
-@-}
-infixl 3 ?>==
-(?>==) :: Tick a -> Int -> Tick a -> Tick a
-(?>==) _ _ t2 = t2
-{-# INLINE (?>==) #-}
-
---
--- Diminishment.
---
-{-@ predicate DIM T1 T2 = tval T1 == tval T2 && tcost T1 <= tcost T2 @-}
-
-{-@ (<~<.)
-  :: t1:Tick a
-  -> { t2:Tick a | DIM t1 t2 }
-  -> { t3:Tick a | DIM t1 t2 && DIM t1 t3 && t2 == t3 }
-@-}
-infixl 3 <~<.
-(<~<.) :: Tick a -> Tick a -> Tick a
-(<~<.) _ t2 = t2
-{-# INLINE (<~<.) #-}
-
-{-@ assume (<~<?)
-  :: t1:Tick a -> t2:Tick a
-  -> { t3:Tick a | DIM t1 t2 && DIM t1 t3 && t2 == t3 }
-@-}
-infixl 3 <~<?
-(<~<?) :: Tick a -> Tick a -> Tick a
-(<~<?) _ t2 = t2
-{-# INLINE (<~<?) #-}
-
---
--- Quantified diminishment.
---
-{-@ predicate QDIM T1 N T2 = tval T1 == tval T2 && tcost T1 + N == tcost T2 @-}
-
-{-@ (.<==)
-  :: t1:Tick a
-  -> n:Nat
-  -> { t2:Tick a | QDIM t1 n t2 }
-  -> { t3:Tick a | QDIM t1 n t2 && QDIM t1 n t3 && t2 == t3 }
-@-}
-infixl 3 .<==
-(.<==) :: Tick a -> Int -> Tick a -> Tick a
-(.<==) _ _ t2 = t2
-{-# INLINE (.<==) #-}
-
-{-@ assume (?<==)
-  :: t1:Tick a -> n:Nat -> t2:Tick a
-  -> { t3:Tick a | QDIM t1 n t2 && QDIM t1 n t3 && t2 == t3 }
-@-}
-infixl 3 ?<==
-(?<==) :: Tick a -> Int -> Tick a -> Tick a
-(?<==) _ _ t2 = t2
-{-# INLINE (?<==) #-}
-
--------------------------------------------------------------------------------
--- | Cost separators:
--------------------------------------------------------------------------------
-
---
--- Quantified improvement.
---
-{-@ (==>.) :: (a -> b) -> a -> b @-}
-infixl 3 ==>.
-(==>.) :: (a -> b) -> a -> b
-f ==>. a = f a
-{-# INLINE (==>.) #-}
-
---
--- Quantified improvement (assumption).
---
-{-@ (==>?) :: (a -> b) -> a -> b @-}
-infixl 3 ==>?
-(==>?) :: (a -> b) -> a -> b
-f ==>? a = f a
-{-# INLINE (==>?) #-}
-
---
--- Quantified diminishment.
---
-{-@ (==<.) :: (a -> b) -> a -> b @-}
-infixl 3 ==<.
-(==<.) :: (a -> b) -> a -> b
-f ==<. a = f a
-{-# INLINE (==<.) #-}
-
---
--- Quantified diminishment (assumption).
---
-{-@ (==<?) :: (a -> b) -> a -> b @-}
-infixl 3 ==<?
-(==<?) :: (a -> b) -> a -> b
-f ==<? a = f a
-{-# INLINE (==<?) #-}
diff --git a/include/Language/Haskell/Liquid/String.hs b/include/Language/Haskell/Liquid/String.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/String.hs
+++ /dev/null
@@ -1,62 +0,0 @@
--- Support for Strings for SMT 
-
-{-# LANGUAGE OverloadedStrings   #-}
-
-module Language.Haskell.Liquid.String where
-
-import qualified Data.ByteString as BS
-import qualified Data.String     as ST
-
-{-@ embed SMTString as Str @-}
-
-data SMTString = S BS.ByteString 
-  deriving (Eq, Show)
-
-{-@ invariant {s:SMTString | 0 <= stringLen s } @-}
-
-{-@ measure stringEmp    :: SMTString @-}
-{-@ measure stringLen    :: SMTString -> Int @-}
-{-@ measure subString    :: SMTString -> Int -> Int -> SMTString @-}
-{-@ measure concatString :: SMTString -> SMTString -> SMTString @-}
-{-@ measure fromString   :: String -> SMTString @-}
-{-@ measure takeString   :: Int -> SMTString -> SMTString @-}
-{-@ measure dropString   :: Int -> SMTString -> SMTString @-}
-
-----------------------------------
-
-{-@ assume concatString :: x:SMTString -> y:SMTString 
-                 -> {v:SMTString | v == concatString x y && stringLen v == stringLen x + stringLen y } @-}
-concatString :: SMTString -> SMTString -> SMTString
-concatString (S s1) (S s2) = S (s1 `BS.append` s2)
-
-{-@ assume stringEmp :: {v:SMTString | v == stringEmp  && stringLen v == 0 } @-}
-stringEmp :: SMTString
-stringEmp = S (BS.empty)
-
-stringLen :: SMTString -> Int  
-{-@ assume stringLen :: x:SMTString -> {v:Nat | v == stringLen x} @-}
-stringLen (S s) = BS.length s 
-
-
-{-@ assume subString  :: s:SMTString -> offset:Int -> ln:Int -> {v:SMTString | v == subString s offset ln } @-}
-subString :: SMTString -> Int -> Int -> SMTString 
-subString (S s) o l = S (BS.take l $ BS.drop o s) 
-
-
-{-@ assume takeString :: i:Nat -> xs:{SMTString | i <= stringLen xs } -> {v:SMTString | stringLen v == i && v == takeString i xs } @-} 
-takeString :: Int -> SMTString -> SMTString
-takeString i (S s) = S (BS.take i s)
-
-{-@ assume dropString :: i:Nat -> xs:{SMTString | i <= stringLen xs } -> {v:SMTString | stringLen v == stringLen xs - i && v == dropString i xs } @-} 
-dropString :: Int -> SMTString -> SMTString
-dropString i (S s) = S (BS.drop i s)
-
-
-{-@ assume fromString :: i:String -> {o:SMTString | i == o && o == fromString i} @-}
-fromString :: String -> SMTString
-fromString = S . ST.fromString 
-
-
-{-@ assume isNullString :: i:SMTString -> {b:Bool | b <=> stringLen i == 0 } @-} 
-isNullString :: SMTString -> Bool 
-isNullString (S s) = BS.length s == 0 
diff --git a/include/Language/Haskell/Liquid/Synthesize/Error.hs b/include/Language/Haskell/Liquid/Synthesize/Error.hs
deleted file mode 100644
--- a/include/Language/Haskell/Liquid/Synthesize/Error.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Language.Haskell.Liquid.Synthesize.Error where 
-
-{-@ err :: { v: Int | false } -> a @-}
-err :: Int -> a
-err s = undefined
diff --git a/include/NotReal.spec b/include/NotReal.spec
deleted file mode 100644
--- a/include/NotReal.spec
+++ /dev/null
@@ -1,11 +0,0 @@
-module spec Prelude where
-
-import GHC.Num
-assume GHC.Num.* :: (GHC.Num.Num a) => x:a -> y:a 
-                 -> {v:a | ((((((x = 0) || (y = 0)) => (v = 0))) 
-                         && (((x > 0) && (y > 0)) => ((v >= x) && (v >= y))))
-                         && (((x > 1) && (y > 1)) => ((v > x) && (v > y))))
-                    }
-
-
-GHC.Real./       :: (GHC.Real.Fractional a) => x:a -> y:{v:a | v != 0.0} -> a
diff --git a/include/PatErr.spec b/include/PatErr.spec
deleted file mode 100644
--- a/include/PatErr.spec
+++ /dev/null
@@ -1,7 +0,0 @@
-module spec Prelude where
-
-assume Control.Exception.Base.patError :: {v:GHC.Prim.Addr# | 5 <4 } -> a
-assume Control.Exception.Base.irrefutPatError :: {v:GHC.Prim.Addr# | 5 < 4 } -> a
-assume Control.Exception.Base.recSelError :: {v:GHC.Prim.Addr# | 5 < 4 } -> a
-assume Control.Exception.Base.nonExhaustiveGuardsError :: {v:GHC.Prim.Addr# | 5 < 4 } -> a
-assume Control.Exception.Base.noMethodBindingError :: {v:GHC.Prim.Addr# | 5 < 4 } -> a
diff --git a/include/Prelude.hquals b/include/Prelude.hquals
deleted file mode 100644
--- a/include/Prelude.hquals
+++ /dev/null
@@ -1,44 +0,0 @@
-//BOT: Do not delete EVER!
-
-qualif Bot(v:@(0))    : (0 = 1)
-qualif Bot(v:obj)     : (0 = 1)
-qualif Bot(v:a)       : (0 = 1)
-qualif Bot(v:bool)    : (0 = 1)
-qualif Bot(v:int)     : (0 = 1)
-
-qualif CmpZ(v:a)      : (v <  0)
-qualif CmpZ(v:a)      : (v <= 0)
-qualif CmpZ(v:a)      : (v >  0)
-qualif CmpZ(v:a)      : (v >= 0)
-qualif CmpZ(v:a)      : (v  = 0)
-qualif CmpZ(v:a)      : (v != 0)
-
-qualif Cmp(v:a, x:a)  : (v <  x)
-qualif Cmp(v:a, x:a)  : (v <= x)
-qualif Cmp(v:a, x:a)  : (v >  x)
-qualif Cmp(v:a, x:a)  : (v >= x)
-qualif Cmp(v:a, x:a)  : (v  = x)
-qualif Cmp(v:a, x:a)  : (v != x)
-
-// qualif CmpZ(v:a)        : v [ < ; <= ; > ; >= ; = ; != ] 0
-// qualif Cmp(v:a,x:a)     : v [ < ; <= ; > ; >= ; = ; != ] x
-// qualif Cmp(v:int,x:int) : v [ < ; <= ; > ; >= ; = ; != ] x
-
-
-qualif One(v:int)     : v = 1
-qualif True1(v:GHC.Types.Bool)   : (v)
-qualif False1(v:GHC.Types.Bool)  : (~ v)
-
-constant papp1 : func(1, [Pred @(0); @(0); bool])
-qualif Papp(v:a,p:Pred a) : (papp1(p, v))
-
-constant papp2 : func(4, [Pred @(0) @(1); @(2); @(3); bool])
-qualif Papp2(v:a,x:b,p:Pred a b) : (papp2(p, v, x))
-
-qualif Papp3(v:a,x:b, y:c, p:Pred a b c) : (papp3(p, v, x, y))
-constant papp3 : func(6, [Pred @(0) @(1) @(2); @(3); @(4); @(5); bool])
-
-// qualif Papp4(v:a,x:b, y:c, z:d, p:Pred a b c d) : papp4(p, v, x, y, z)
-constant papp4 : func(8, [Pred @(0) @(1) @(2) @(6); @(3); @(4); @(5); @(7); bool])
-
-constant runFun : func(2, [Arrow @(0) @(1); @(0); @(1)])
diff --git a/include/Prelude.spec b/include/Prelude.spec
deleted file mode 100644
--- a/include/Prelude.spec
+++ /dev/null
@@ -1,88 +0,0 @@
-module spec Prelude where
-
-import GHC.Base
-import GHC.Int
-import GHC.List
-import GHC.Num
-import GHC.Real
-import GHC.Word
-
-import Data.Foldable
-import Data.Maybe
-import Data.Tuple
-import GHC.Exts
-import GHC.Err 
-
-
-// GHC.Types.D# :: x:_ -> {v:_ | v = x}
-
-GHC.Err.error :: {v:_ | false} -> a 
-
-assume GHC.Base.. :: forall <p :: b -> c -> Bool, q :: a -> b -> Bool, r :: a -> c -> Bool>. 
-                     {xcmp::a, wcmp::b<q xcmp> |- c<p wcmp> <: c<r xcmp>}
-                     (ycmp:b -> c<p ycmp>)
-                  -> (zcmp:a -> b<q zcmp>)
-                  ->  xcmp:a -> c<r xcmp>
-assume GHC.Integer.smallInteger :: x:GHC.Prim.Int# -> { v:GHC.Integer.Type | v = (x :: int) }
-
-assume GHC.Num.+ :: (GHC.Num.Num a) => x:a -> y:a -> {v:a | v = x + y }
-assume GHC.Num.- :: (GHC.Num.Num a) => x:a -> y:a -> {v:a | v = x - y }
-
-embed GHC.Types.Double  as real
-embed GHC.Types.Float   as real
-embed Integer           as int
-
-type GeInt N = {v: GHC.Types.Int | v >= N }
-type LeInt N = {v: GHC.Types.Int | v <= N }
-type Nat     = {v: GHC.Types.Int | v >= 0 }
-type Even    = {v: GHC.Types.Int | (v mod 2) = 0 }
-type Odd     = {v: GHC.Types.Int | (v mod 2) = 1 }
-type BNat N  = {v: Nat           | v <= N }    
-type TT      = {v: GHC.Types.Bool | v}
-type FF      = {v: GHC.Types.Bool | not v}
-type String  = [GHC.Types.Char]
-
-predicate Max V X Y = if X > Y then V = X else V = Y
-predicate Min V X Y = if X < Y then V = X else V = Y
-
-type IncrListD a  = [a]<{\x y -> (x+D) <= y}>
-
-//BOT: Do not delete EVER!
-
-qualif Bot(v:@(0))    : (0 = 1)
-qualif Bot(v:obj)     : (0 = 1)
-qualif Bot(v:a)       : (0 = 1)
-qualif Bot(v:bool)    : (0 = 1)
-qualif Bot(v:int)     : (0 = 1)
-
-qualif CmpZ(v:a)      : (v <  0)
-qualif CmpZ(v:a)      : (v <= 0)
-qualif CmpZ(v:a)      : (v >  0)
-qualif CmpZ(v:a)      : (v >= 0)
-qualif CmpZ(v:a)      : (v  = 0)
-qualif CmpZ(v:a)      : (v != 0)
-
-qualif Cmp(v:a, x:a)  : (v <  x)
-qualif Cmp(v:a, x:a)  : (v <= x)
-qualif Cmp(v:a, x:a)  : (v >  x)
-qualif Cmp(v:a, x:a)  : (v >= x)
-qualif Cmp(v:a, x:a)  : (v  = x)
-qualif Cmp(v:a, x:a)  : (v != x)
-
-qualif One(v:int)     : v = 1
-qualif True1(v:GHC.Types.Bool)   : (v)
-qualif False1(v:GHC.Types.Bool)  : (~ v)
-
-// REBARE constant papp1 : func(1, [Pred @(0); @(0); bool])
-qualif Papp(v:a, p:Pred a) : (papp1 p v)
-
-// REBARE constant papp2 : func(4, [Pred @(0) @(1); @(2); @(3); bool])
-qualif Papp2(v:a, x:b, p:Pred a b) : (papp2 p v x)
-
-// REBARE constant papp3 : func(6, [Pred @(0) @(1) @(2); @(3); @(4); @(5); bool])
-qualif Papp3(v:a, x:b, y:c, p:Pred a b c) : (papp3 p v x y)
-
-// qualif Papp4(v:a,x:b, y:c, z:d, p:Pred a b c d) : papp4(p, v, x, y, z)
-// REBARE constant papp4 : func(8, [Pred @(0) @(1) @(2) @(6); @(3); @(4); @(5); @(7); bool])
-
-// REBARE constant runFun : func(2, [Arrow @(0) @(1); @(0); @(1)])
diff --git a/include/Real.spec b/include/Real.spec
deleted file mode 100644
--- a/include/Real.spec
+++ /dev/null
@@ -1,9 +0,0 @@
-module spec Prelude where
-
-import GHC.Num
-
-assume GHC.Num.* :: (GHC.Num.Num a) => x:a -> y:a -> {v:a | v = x * y} 
-
-
-
-// GHC.Real./       :: forall a. (GHC.Real.Fractional a) => x:a -> y:{v:a | v != 0.0} -> {v: a | v = (x / y) }
diff --git a/include/System/IO.spec b/include/System/IO.spec
deleted file mode 100644
--- a/include/System/IO.spec
+++ /dev/null
@@ -1,3 +0,0 @@
-module spec System.IO where
-
-import GHC.IO.Handle
diff --git a/include/len.hquals b/include/len.hquals
deleted file mode 100644
--- a/include/len.hquals
+++ /dev/null
@@ -1,7 +0,0 @@
-
-// Qualifiers about complex length relationships
-// qualif LenSum(v:[a], ~A:[b], ~B:[c]): len([v]) = (len([~A]) [ +; - ] len([~B]))
-
-qualif LenSum(v:[a], xs:[b], ys:[c]): len([v]) = (len([xs]) + len([ys]))
-qualif LenSum(v:[a], xs:[b], ys:[c]): len([v]) = (len([xs]) - len([ys]))
-
diff --git a/liquidhaskell.cabal b/liquidhaskell.cabal
--- a/liquidhaskell.cabal
+++ b/liquidhaskell.cabal
@@ -1,6 +1,6 @@
 cabal-version:      2.4
 name:               liquidhaskell
-version:            0.8.10.2
+version:            0.9.14.1.1
 synopsis:           Liquid Types for Haskell
 description:        Liquid Types for Haskell.
 license:            BSD-3-Clause
@@ -10,348 +10,82 @@
 maintainer:         Ranjit Jhala <jhala@cs.ucsd.edu>
 category:           Language
 homepage:           https://github.com/ucsd-progsys/liquidhaskell
-build-type:         Simple
-tested-with:        GHC == 8.6.5, GHC == 8.10.1
-extra-source-files: CHANGES.md
-                    README.md
-                    devel/Paths_liquidhaskell.hs
-                    tests/pos/*.hs
-                    tests/neg/*.hs
-                    tests/import/lib/*.hs
-                    tests/import/client/*.hs
-                    tests/errors/*.hs
-                    tests/pos/*.hquals
-                    tests/ffi-include/foo.c
-                    tests/ffi-include/foo.h
-data-files:         include/*.hquals
-                    include/*.hs
-                    include/*.spec
-                    include/CoreToLogic.lg
-                    include/Control/*.spec
-                    include/Control/Parallel/*.spec
-                    include/Data/*.hquals
-                    include/Data/*.spec
-                    include/Data/Text/*.spec
-                    include/Data/Text/Fusion/*.spec
-                    include/Data/Text/Lazy/*.spec
-                    include/Data/ByteString/*.spec
-                    include/Foreign/*.spec
-                    include/Foreign/C/*.spec
-                    include/Foreign/Marshal/*.spec
-                    include/GHC/*.hquals
-                    include/GHC/*.spec
-                    include/GHC/IO/*.spec
-                    include/Language/Haskell/Liquid/*.hs
-                    include/Language/Haskell/Liquid/Synthesize/*.hs
-                    include/Language/Haskell/Liquid/*.pred
-                    include/System/*.spec
-                    include/710/Data/*.spec
-                    syntax/liquid.css
-                    -- Remove the lines above once we switch to the source plugin.
-                    include/*.hs
-                    include/Language/Haskell/Liquid/*.hs
-                    include/Language/Haskell/Liquid/*.pred
-
-                    -- Needed for the mirror-modules helper
-                    mirror-modules/templates/MirrorModule.mustache
+build-type:         Custom
+tested-with:        GHC == 9.14.1
+extra-doc-files: CHANGES.md
+                 README.md
 
 source-repository head
   type:     git
   location: https://github.com/ucsd-progsys/liquidhaskell/
 
-flag include
-  default:     False
-  description: use in-tree include directory
-
-flag deterministic-profiling
-  default:     False
-  description: Support building against GHC with <https://phabricator.haskell.org/D4388>
-               backported
-
-flag no-plugin
+flag devel
   default:     False
   manual:      True
-  description: Use the legacy executable for testing.
+  description: Enable more warnings and fail compilation when warnings occur.
+               Turn this flag on in CI.
 
-flag mirror-modules-helper
-  default:     False
-  manual:      True
-  description: Build the "mirror-modules" helper executable.
+custom-setup
+  setup-depends: Cabal<4, base<5, liquidhaskell-boot
 
 library
-  autogen-modules:    Paths_liquidhaskell
-  exposed-modules:    Gradual.Concretize
-                      Gradual.GUI
-                      Gradual.GUI.Annotate
-                      Gradual.GUI.Misc
-                      Gradual.GUI.Types
-                      Gradual.Misc
-                      Gradual.PrettyPrinting
-                      Gradual.Refinements
-                      Gradual.Trivial
-                      Gradual.Types
-                      Gradual.Uniquify
-                      Language.Haskell.Liquid.Cabal
-                      Language.Haskell.Liquid.Bare
-                      Language.Haskell.Liquid.Bare.Axiom
-                      Language.Haskell.Liquid.Bare.Check
-                      Language.Haskell.Liquid.Bare.Class
-                      Language.Haskell.Liquid.Bare.DataType
-                      Language.Haskell.Liquid.Bare.Expand
-                      Language.Haskell.Liquid.Bare.Laws
-                      Language.Haskell.Liquid.Bare.Measure
-                      Language.Haskell.Liquid.Bare.Misc
-                      Language.Haskell.Liquid.Bare.Plugged
-                      Language.Haskell.Liquid.Bare.Resolve
-                      Language.Haskell.Liquid.Bare.ToBare
-                      Language.Haskell.Liquid.Bare.Types
-                      Language.Haskell.Liquid.Constraint.Constraint
-                      Language.Haskell.Liquid.Constraint.Env
-                      Language.Haskell.Liquid.Constraint.Fresh
-                      Language.Haskell.Liquid.Constraint.Generate
-                      Language.Haskell.Liquid.Constraint.Init
-                      Language.Haskell.Liquid.Constraint.Monad
-                      Language.Haskell.Liquid.Constraint.Qualifier
-                      Language.Haskell.Liquid.Constraint.Split
-                      Language.Haskell.Liquid.Constraint.ToFixpoint
-                      Language.Haskell.Liquid.Constraint.Types
-                      Language.Haskell.Liquid.GHC.API
-                      Language.Haskell.Liquid.GHC.GhcMonadLike
-                      Language.Haskell.Liquid.GHC.Interface
-                      Language.Haskell.Liquid.GHC.Logging
-                      Language.Haskell.Liquid.GHC.Misc
-                      Language.Haskell.Liquid.GHC.Play
-                      Language.Haskell.Liquid.GHC.Resugar
-                      Language.Haskell.Liquid.GHC.SpanStack
-                      Language.Haskell.Liquid.GHC.Types
-                      Language.Haskell.Liquid.GHC.TypeRep
-                      Language.Haskell.Liquid.Interactive.Handler
-                      Language.Haskell.Liquid.Interactive.Types
-                      Language.Haskell.Liquid.LawInstances
-                      Language.Haskell.Liquid.Liquid
-                      Language.Haskell.Liquid.Measure
-                      Language.Haskell.Liquid.Misc
-                      Language.Haskell.Liquid.Parse
-                      Language.Haskell.Liquid.Synthesize.GHC
-                      Language.Haskell.Liquid.Synthesize.Termination
-                      Language.Haskell.Liquid.Synthesize.Monad
-                      Language.Haskell.Liquid.Synthesize.Misc
-                      Language.Haskell.Liquid.Synthesize.Generate
-                      Language.Haskell.Liquid.Synthesize.Check
-                      Language.Haskell.Liquid.Synthesize.Env
-                      Language.Haskell.Liquid.Termination.Structural
-                      Language.Haskell.Liquid.Transforms.ANF
-                      Language.Haskell.Liquid.Transforms.CoreToLogic
-                      Language.Haskell.Liquid.Transforms.Rec
-                      Language.Haskell.Liquid.Transforms.RefSplit
-                      Language.Haskell.Liquid.Transforms.Rewrite
-                      Language.Haskell.Liquid.Transforms.Simplify
-                      Language.Haskell.Liquid.Types
-                      Language.Haskell.Liquid.Types.Bounds
-                      Language.Haskell.Liquid.Types.Dictionaries
-                      Language.Haskell.Liquid.Types.Equality
-                      Language.Haskell.Liquid.Types.Errors
-                      Language.Haskell.Liquid.Types.Fresh
-                      Language.Haskell.Liquid.Types.Generics
-                      Language.Haskell.Liquid.Types.Literals
-                      Language.Haskell.Liquid.Types.Meet
-                      Language.Haskell.Liquid.Types.Names
-                      Language.Haskell.Liquid.Types.PredType
-                      Language.Haskell.Liquid.Types.PrettyPrint
-                      Language.Haskell.Liquid.Types.RefType
-                      Language.Haskell.Liquid.Types.Specs
-                      Language.Haskell.Liquid.Types.Types
-                      Language.Haskell.Liquid.Types.Variance
-                      Language.Haskell.Liquid.Types.Visitors
-                      Language.Haskell.Liquid.Synthesize
-                      Language.Haskell.Liquid.UX.ACSS
-                      Language.Haskell.Liquid.UX.Annotate
-                      Language.Haskell.Liquid.UX.CTags
-                      Language.Haskell.Liquid.UX.CmdLine
-                      Language.Haskell.Liquid.UX.Config
-                      Language.Haskell.Liquid.UX.DiffCheck
-                      Language.Haskell.Liquid.UX.Errors
-                      Language.Haskell.Liquid.UX.QuasiQuoter
-                      Language.Haskell.Liquid.UX.Tidy
-                      Language.Haskell.Liquid.WiredIn
-                      LiquidHaskell
-                      Paths_liquidhaskell
-
-  -- FIXME: Temporary measure to ensure that if the source plugin is available, then:
-  --   1. we compile it;
-  --   2. We don't rely on the \"liquid-prelude\" Haskell files previously shipped as part of LH itself.
-  -- Once the source plugin is out, we should also removed the duplicate \"liquid-prelude\" files from
-  -- the \"include\" directory.
-
-  if impl(ghc >= 8.10)
-      exposed-modules:    Language.Haskell.Liquid.GHC.Plugin
-                          Language.Haskell.Liquid.GHC.Plugin.Tutorial
-      other-modules:      Language.Haskell.Liquid.GHC.Plugin.SpecFinder
-                          Language.Haskell.Liquid.GHC.Plugin.Types
-                          Language.Haskell.Liquid.GHC.Plugin.Util
-      hs-source-dirs:     src
-  else
-      hs-source-dirs:     src include
-      exposed-modules:    Language.Haskell.Liquid.RTick
-                          Language.Haskell.Liquid.Prelude
-                          Language.Haskell.Liquid.Foreign
-                          Language.Haskell.Liquid.RTick.Combinators
-                          Language.Haskell.Liquid.String
-                          Language.Haskell.Liquid.List
-                          Language.Haskell.Liquid.Equational
-                          Language.Haskell.Liquid.Bag
-                          Language.Haskell.Liquid.ProofCombinators
-                          KMeansHelper
+  exposed-modules:    LiquidHaskell
+                      GHC.Classes_LHAssumptions
+                      GHC.CString_LHAssumptions
+                      GHC.Types_LHAssumptions
 
-  build-depends:      base                 >= 4.11.1.0 && < 5
-                    , Diff                 >= 0.3 && < 0.4
-                    , aeson
-                    , binary
-                    , bytestring           >= 0.10
-                    , Cabal                < 3.3
-                    , cereal
-                    , cmdargs              >= 0.10
-                    , containers           >= 0.5
-                    , data-default         >= 0.5
-                    , deepseq              >= 1.3
-                    , directory            >= 1.2
-                    , filepath             >= 1.3
-                    , fingertree           >= 0.1
-                    , ghc
-                    , ghc-boot
-                    , ghc-paths            >= 0.1
-                    , ghc-prim
-                    , gitrev
-                    , hashable             >= 1.3
-                    , hscolour             >= 1.22
-                    , liquid-fixpoint      >= 0.8.10.1
-                    , mtl                  >= 2.1
-                    , optics               >= 0.2
-                    , optparse-applicative < 0.16.0.0
-                    , optparse-simple
-                    , githash
-                    , parsec               >= 3.1
-                    , pretty               >= 1.1
-                    , split
-                    , syb                  >= 0.4.4
-                    , template-haskell     >= 2.9
-                    , temporary            >= 1.2
-                    , text                 >= 1.2
-                    , time                 >= 1.4
-                    , time
-                    , transformers         >= 0.3
-                    , unordered-containers >= 0.2
-                    , vector               >= 0.10
-                    , extra
-  default-language:   Haskell98
-  default-extensions: PatternGuards, RecordWildCards, DoAndIfThenElse
-  ghc-options:        -W -fwarn-missing-signatures
+                      Data.Bits_LHAssumptions
+                      Data.Either_LHAssumptions
+                      Data.Foldable_LHAssumptions
+                      Data.Int_LHAssumptions
+                      Data.List_LHAssumptions
+                      Data.Maybe_LHAssumptions
+                      Data.String_LHAssumptions
+                      Data.Tuple_LHAssumptions
+                      Data.Word_LHAssumptions
+                      Foreign.C.String_LHAssumptions
+                      Foreign.C.Types_LHAssumptions
+                      Foreign.Concurrent_LHAssumptions
+                      Foreign.Marshal.Alloc_LHAssumptions
+                      Foreign.ForeignPtr_LHAssumptions
+                      Foreign.Ptr_LHAssumptions
+                      Foreign.Storable_LHAssumptions
+                      GHC.Base_LHAssumptions
+                      GHC.Exts_LHAssumptions
+                      GHC.Float_LHAssumptions
+                      GHC.ForeignPtr_LHAssumptions
+                      GHC.Int_LHAssumptions
+                      GHC.IO.Handle_LHAssumptions
+                      GHC.List_LHAssumptions
+                      GHC.Num_LHAssumptions
+                      GHC.Num.Integer_LHAssumptions
+                      GHC.Maybe_LHAssumptions
+                      GHC.Ptr_LHAssumptions
+                      GHC.Real_LHAssumptions
+                      GHC.Word_LHAssumptions
+                      Liquid.Prelude.Real_LHAssumptions
+                      Liquid.Prelude.Totality_LHAssumptions
+                      Prelude_LHAssumptions
 
-  if flag(include)
-    hs-source-dirs: devel
+                      Data.ByteString_LHAssumptions
+                      Data.ByteString.Char8_LHAssumptions
+                      Data.ByteString.Lazy.Char8_LHAssumptions
+                      Data.ByteString.Lazy_LHAssumptions
+                      Data.ByteString.Short_LHAssumptions
+                      Data.ByteString.Unsafe_LHAssumptions
 
-  if flag(deterministic-profiling)
-    cpp-options: -DDETERMINISTIC_PROFILING
+                      Data.Set_LHAssumptions
 
-  if impl(ghc < 8.10) || flag(no-plugin)
-    cpp-options: -DLIQUID_NO_PLUGIN
+  hs-source-dirs:     src
 
--- This is the (legacy) 'liquid' executable which uses the old GHC Interface.
-executable liquid
-  main-is:            exe/Liquid.hs
-  build-depends:      base >= 4.9.1.0 && < 5, liquidhaskell
+  build-depends:      base                 >= 4.11.1.0 && < 5,
+                      liquidhaskell-boot   == 0.9.14.1.1,
+                      bytestring,
+                      containers,
+                      ghc-prim
   default-language:   Haskell98
-  default-extensions: PatternGuards
-  ghc-options:        -W -threaded -fdefer-typed-holes
-
-
-test-suite test
-  type:             exitcode-stdio-1.0
-  main-is:          test.hs
-  other-modules:    Paths_liquidhaskell
-  hs-source-dirs:   tests
-  build-depends:    base                 >= 4.8.1.0 && < 5
-                  , containers           >= 0.5
-                  , directory            >= 1.2
-                  , filepath             >= 1.3
-                  , mtl                  >= 2.1
-                  , optparse-applicative >= 0.11
-                  , process              >= 1.2
-                  , stm                  >= 2.4
-                  , string-conv          >= 0.1
-                  , tagged               >= 0.7.3
-                  , tasty                >= 0.10 && < 1.3
-                  , tasty-ant-xml
-                  , tasty-golden         >= 2.0.0
-                  , tasty-hunit          >= 0.9
-                  , tasty-rerun          >= 1.1
-                  , text
-                  , transformers         >= 0.3
-  default-language: Haskell98
-  ghc-options:      -W -threaded
-  if !flag(no-plugin)
-    cpp-options: -DUSE_NEW_EXECUTABLE
-
-test-suite liquidhaskell-parser
-  type:             exitcode-stdio-1.0
-  main-is:          Parser.hs
-  other-modules:    Paths_liquidhaskell
-  hs-source-dirs:   tests
-  build-depends:    base            >= 4.8.1.0 && < 5
-                  , liquid-fixpoint >= 0.8.10.1
-                  , liquidhaskell
-                  , parsec
-                  , syb
-                  , tasty           >= 0.10
-                  , tasty-ant-xml
-                  , tasty-hunit     >= 0.9
-  default-language: Haskell2010
-  ghc-options:      -W
-
-test-suite synthesis
-  type:             exitcode-stdio-1.0
-  main-is:          Synthesis.hs
-  other-modules:    Paths_liquidhaskell
-  hs-source-dirs:   tests
-  build-depends:    base            >= 4.8.1.0 && < 5
-                  , liquid-fixpoint >= 0.8.10.1
-                  , liquidhaskell
-                  , tasty           >= 0.7
-                  , tasty-hunit
-                  , process
-                  , filepath
-                  , text
-                  , directory
-                  , ghc
-                  , extra
-  default-language: Haskell2010
-  ghc-options:      -W
-
-
--- This executable can be used to generate modules for mirror-packages.
-executable mirror-modules
-  main-is:        Main.hs
-  hs-source-dirs: mirror-modules
-
-  other-modules: CLI
-                 Paths_liquidhaskell
+  ghc-options:        -Wall
 
-  if flag(mirror-modules-helper)
-    build-depends: base >= 4.9.1.0 && < 5
-                 , shelly < 1.10
-                 , text < 1.3
-                 , filepath < 1.5
-                 , containers < 0.7
-                 , mustache < 2.4
-                 , optparse-applicative < 0.16.1.0
-    buildable: True
-  else
-    buildable: False
+  if flag(devel)
+    ghc-options:      -Werror
 
-  default-language:   Haskell2010
-  default-extensions:
-    OverloadedStrings
-    RecordWildCards
-    MultiWayIf
-    LambdaCase
-  ghc-options:        -W -threaded
diff --git a/mirror-modules/CLI.hs b/mirror-modules/CLI.hs
deleted file mode 100644
--- a/mirror-modules/CLI.hs
+++ /dev/null
@@ -1,59 +0,0 @@
-module CLI (
-    CLI (..)
-  , Flag(..)
-  , parseCLI
-  ) where
-
-
-import Options.Applicative
-import qualified Data.Text as T
-
-
--- Flags
-data OverrideFiles
-
--- The @Flag@ datatype.
-
-newtype Flag ix = Flag { unFlag :: Bool }
-
-data CLI = CLI {
-    overrideFiles       :: Flag OverrideFiles
-  , modulesList         :: FilePath
-  -- ^ A path to a list of modules to create.
-  , mirrorPackageName   :: T.Text
-  , moduleHierarchyRoot :: FilePath
-  -- ^ A path to the root of the module hierarchy for the package we would like to target.
-  }
-
-parseCLI :: Parser CLI
-parseCLI = CLI <$> parseOverrideFiles
-               <*> parseModulesList
-               <*> parsePackageName
-               <*> parseModuleRoot
-
-parseOverrideFiles :: Parser (Flag OverrideFiles)
-parseOverrideFiles =
-  Flag <$> switch (  long "unsafe-override-files"
-                  <> help "Overrides an Haskell module if already present in the folder."
-                  )
-
-parseModulesList :: Parser FilePath
-parseModulesList =
-  strOption (  short 'l'
-            <> long "modules-list"
-            <> help "The path to a file containing a newline-separated list of modules to mirror."
-            )
-
-parsePackageName :: Parser T.Text
-parsePackageName = T.pack <$>
-  strOption (  short 'p'
-            <> long "mirror-package-name"
-            <> help "The name of the mirror package we are targeting. (example: liquid-foo)"
-            )
-
-parseModuleRoot :: Parser FilePath
-parseModuleRoot =
-  strOption (  short 'i'
-            <> long "target"
-            <> help "The path to the root of the module hierarchy for the target package. (example: liquid-foo/src)"
-            )
diff --git a/mirror-modules/Main.hs b/mirror-modules/Main.hs
deleted file mode 100644
--- a/mirror-modules/Main.hs
+++ /dev/null
@@ -1,90 +0,0 @@
-
-module Main where
-
-import           CLI
-import           Options.Applicative
-
-import           Control.Monad
-
-import qualified Data.Text                               as T
-import qualified Data.Set                                as S
-import qualified Data.Map.Strict                         as M
-import           Data.Set                                 ( Set )
-import           Data.Function                            ( (&) )
-
-import           System.FilePath
-import           Shelly                                  as Sh hiding ((</>))
-
-import           Text.Mustache                           (substitute, automaticCompile)
-
-import Paths_liquidhaskell
-
---
--- Utility functions
---
-
-findExistingModules :: CLI -> Sh (Set T.Text)
-findExistingModules cli = do
-  allFiles <- Sh.findWhen (\f -> pure $ takeExtension f == ".hs") (moduleHierarchyRoot cli)
-  pure . S.fromList . map transform $ allFiles
-  where
-    -- Transform an input file by:
-    -- * Stripping the path;
-    -- * Replacing slashes with dots;
-    -- * Remove the final \".hs"\ extension.
-    transform :: FilePath -> T.Text
-    transform f = f & dropExtension
-                    & T.pack
-                    & T.replace (T.pack $ moduleHierarchyRoot cli) mempty
-                    & T.replace "/" "."
-                    & T.replace "/" "."
-
--- Extracts the name of the mirrored package by dropping the \"liquid-\" prefix.
-mirroredPackage :: CLI -> T.Text
-mirroredPackage = T.tail . snd . T.breakOn "-" . mirrorPackageName
-
---
--- The main workhorse
---
-
-mirrorModules :: CLI -> IO ()
-mirrorModules cli@CLI{..} = shelly $ silently $ do
-  dataDir         <- liftIO getDataDir
-  inputModules    <- S.fromList . map T.strip . T.words <$> readfile modulesList
-  existingModules <- findExistingModules cli
-
-  -- If the user decided to completely override existing files, simply return all the input modules.
-  let notMirrored = if | unFlag overrideFiles -> inputModules
-                       | otherwise            -> inputModules `S.difference` existingModules
-
-
-  -- Use a template to automatically generate the module.
-  let searchSpace = [dataDir </> "mirror-modules/templates"]
-      templateName = "MirrorModule.mustache"
-
-  compiled <- liftIO $ automaticCompile searchSpace templateName
-  case compiled of
-    Left err       -> errorExit (T.pack . show $ err)
-    Right template -> do
-      forM_ notMirrored $ \toMirror -> do
-        let ctx = M.fromList [("packageName" :: String, mirroredPackage cli), ("moduleName", toMirror)]
-        let newModule = substitute template ctx
-
-        let pathToModule = moduleHierarchyRoot </> T.unpack (T.replace "." "/" toMirror) <> ".hs"
-        parentFolder <- T.strip <$> run "dirname" [T.pack pathToModule]
-
-        -- Create the parent folder, if necessary.
-        mkdir_p (T.unpack parentFolder)
-
-        -- Write the module.
-        writefile pathToModule newModule
-
-      echo $ "Mirrored " <> T.pack (show . length $ notMirrored) <> " modules."
-
-main :: IO ()
-main = mirrorModules =<< execParser opts
-  where
-    opts = info (parseCLI <**> helper)
-      ( fullDesc
-     <> progDesc "Create modules to be used in mirror packages."
-     <> header "mirror-modules - Generate modules in mirror packages." )
diff --git a/mirror-modules/templates/MirrorModule.mustache b/mirror-modules/templates/MirrorModule.mustache
deleted file mode 100644
--- a/mirror-modules/templates/MirrorModule.mustache
+++ /dev/null
@@ -1,3 +0,0 @@
-module {{ moduleName }} (module Exports) where
-
-import "{{ packageName }}" {{ moduleName }} as Exports
diff --git a/src/Data/Bits_LHAssumptions.hs b/src/Data/Bits_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/Bits_LHAssumptions.hs
@@ -0,0 +1,8 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+module Data.Bits_LHAssumptions where
+
+{-@
+//  TODO: cannot use this because `Bits` is not a `Num`
+//  Data.Bits.shiftR :: (Data.Bits.Bits a) => x:a -> d:Nat
+//                   -> {v:a | ((d=1) => (x <= 2*v + 1 && 2*v <= x)) }
+@-}
diff --git a/src/Data/ByteString/Char8_LHAssumptions.hs b/src/Data/ByteString/Char8_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/ByteString/Char8_LHAssumptions.hs
@@ -0,0 +1,287 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.ByteString.Char8_LHAssumptions where
+
+import Data.ByteString_LHAssumptions()
+import Data.ByteString
+import Data.ByteString.Char8
+import GHC.Types
+
+{-@
+
+assume Data.ByteString.Char8.singleton
+    :: GHC.Types.Char -> { bs : ByteString | bslen bs == 1 }
+
+assume Data.ByteString.Char8.pack
+    :: w8s : [GHC.Types.Char]
+    -> { bs : ByteString | bslen bs == len w8s }
+
+assume Data.ByteString.Char8.unpack
+    :: bs : ByteString
+    -> { w8s : [GHC.Types.Char] | len w8s == bslen bs }
+
+assume Data.ByteString.Char8.cons
+    :: GHC.Types.Char
+    -> i : ByteString
+    -> { o : ByteString | bslen o == bslen i + 1 }
+
+assume Data.ByteString.Char8.snoc
+    :: i : ByteString
+    -> GHC.Types.Char
+    -> { o : ByteString | bslen o == bslen i + 1 }
+
+assume Data.ByteString.Char8.head :: { bs : ByteString | 1 <= bslen bs } -> GHC.Types.Char
+
+assume Data.ByteString.Char8.uncons
+    :: i : ByteString
+    -> Maybe (GHC.Types.Char, { o : ByteString | bslen o == bslen i - 1 })
+
+assume Data.ByteString.Char8.unsnoc
+    :: i : ByteString
+    -> Maybe ({ o : ByteString | bslen o == bslen i - 1 }, GHC.Types.Char)
+
+assume Data.ByteString.Char8.last :: { bs : ByteString | 1 <= bslen bs } -> GHC.Types.Char
+
+assume Data.ByteString.Char8.map
+    :: (GHC.Types.Char -> GHC.Types.Char)
+    -> i : ByteString
+    -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.Char8.intersperse
+    :: GHC.Types.Char
+    -> i : ByteString
+    -> { o : ByteString | (bslen i == 0 <=> bslen o == 0) && (1 <= bslen i <=> bslen o == 2 * bslen i - 1) }
+
+assume Data.ByteString.Char8.foldl1
+    :: (GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Char)
+    -> { bs : ByteString | 1 <= bslen bs }
+    -> Char
+
+assume Data.ByteString.Char8.foldl1'
+    :: (GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Char)
+    -> { bs : ByteString | 1 <= bslen bs }
+    -> GHC.Types.Char
+
+assume Data.ByteString.Char8.foldr1
+    :: (GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Char)
+    -> { bs : ByteString | 1 <= bslen bs }
+    -> Char
+
+assume Data.ByteString.Char8.foldr1'
+    :: (GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Char)
+    -> { bs : ByteString | 1 <= bslen bs }
+    -> GHC.Types.Char
+
+assume Data.ByteString.Char8.concatMap
+    :: (GHC.Types.Char -> ByteString)
+    -> i : ByteString
+    -> { o : ByteString | bslen i == 0 ==> bslen o == 0 }
+
+assume Data.ByteString.Char8.any :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> bs : ByteString
+    -> { b : GHC.Types.Bool | bslen bs == 0 ==> not b }
+
+assume Data.ByteString.Char8.all :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> bs : ByteString
+    -> { b : GHC.Types.Bool | bslen bs == 0 ==> b }
+
+assume Data.ByteString.Char8.maximum
+    :: { bs : ByteString | 1 <= bslen bs } -> GHC.Types.Char
+
+assume Data.ByteString.Char8.minimum
+    :: { bs : ByteString | 1 <= bslen bs } -> GHC.Types.Char
+
+assume Data.ByteString.Char8.scanl
+    :: (GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Char)
+    -> GHC.Types.Char
+    -> i : ByteString
+    -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.Char8.scanl1
+    :: (GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Char)
+    -> i : { i : ByteString | 1 <= bslen i }
+    -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.Char8.scanr
+    :: (GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Char)
+    -> GHC.Types.Char
+    -> i : ByteString
+    -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.Char8.scanr1
+    :: (GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Char)
+    -> i : { i : ByteString | 1 <= bslen i }
+    -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.Char8.mapAccumL
+    :: (acc -> GHC.Types.Char -> (acc, GHC.Types.Char))
+    -> acc
+    -> i : ByteString
+    -> (acc, { o : ByteString | bslen o == bslen i })
+
+assume Data.ByteString.Char8.mapAccumR
+    :: (acc -> GHC.Types.Char -> (acc, GHC.Types.Char))
+    -> acc
+    -> i : ByteString
+    -> (acc, { o : ByteString | bslen o == bslen i })
+
+assume Data.ByteString.Char8.replicate
+    :: n : Int
+    -> GHC.Types.Char
+    -> { bs : ByteString | bslen bs == n }
+
+assume Data.ByteString.Char8.unfoldrN
+    :: n : Int
+    -> (a -> Maybe (GHC.Types.Char, a))
+    -> a
+    -> ({ bs : ByteString | bslen bs <= n }, Maybe a)
+
+assume Data.ByteString.Char8.takeWhile
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> i : ByteString
+    -> { o : ByteString | bslen o <= bslen i }
+
+assume Data.ByteString.Char8.dropWhile
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> i : ByteString
+    -> { o : ByteString | bslen o <= bslen i }
+
+assume Data.ByteString.Char8.span
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bslen l <= bslen i }
+       , { r : ByteString | bslen r <= bslen i }
+       )
+
+assume Data.ByteString.Char8.spanEnd
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bslen l <= bslen i }
+       , { r : ByteString | bslen r <= bslen i }
+       )
+
+assume Data.ByteString.Char8.break
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bslen l <= bslen i }
+       , { r : ByteString | bslen r <= bslen i }
+       )
+
+assume Data.ByteString.Char8.breakEnd
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bslen l <= bslen i }
+       , { r : ByteString | bslen r <= bslen i }
+       )
+
+assume Data.ByteString.Char8.groupBy
+    :: (GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Bool)
+    -> i : ByteString
+    -> [{ o : ByteString | 1 <= bslen o && bslen o <= bslen i }]
+
+assume Data.ByteString.Char8.split
+    :: GHC.Types.Char
+    -> i : ByteString
+    -> [{ o : ByteString | bslen o <= bslen i }]
+
+assume Data.ByteString.Char8.splitWith
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> i : ByteString
+    -> [{ o : ByteString | bslen o <= bslen i }]
+
+assume Data.ByteString.Char8.lines
+    :: i : ByteString
+    -> [{ o : ByteString | bslen o <= bslen i }]
+
+assume Data.ByteString.Char8.words
+    :: i : ByteString
+    -> [{ o : ByteString | bslen o <= bslen i }]
+
+assume Data.ByteString.Char8.unlines
+    :: is : [ByteString]
+    -> { o : ByteString | (len is == 0 <=> bslen o == 0) && bslen o >= len is }
+
+assume Data.ByteString.Char8.unwords
+    :: is : [ByteString]
+    -> { o : ByteString | (len is == 0 ==> bslen o == 0) && (1 <= len is ==> bslen o >= len is - 1) }
+
+assume Data.ByteString.Char8.elem
+    :: GHC.Types.Char
+    -> bs : ByteString
+    -> { b : GHC.Types.Bool | bslen bs == 0 ==> not b }
+
+assume Data.ByteString.Char8.notElem
+    :: GHC.Types.Char
+    -> bs : ByteString
+    -> { b : GHC.Types.Bool | bslen bs == 0 ==> b }
+
+assume Data.ByteString.Char8.find
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> bs : ByteString
+    -> Maybe { w8 : GHC.Types.Char | bslen bs /= 0 }
+
+assume Data.ByteString.Char8.filter
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> i : ByteString
+    -> { o : ByteString | bslen o <= bslen i }
+
+assume Data.ByteString.Char8.index
+    :: bs : ByteString
+    -> { n : Int | 0 <= n && n < bslen bs }
+    -> GHC.Types.Char
+
+assume Data.ByteString.Char8.elemIndex
+    :: GHC.Types.Char
+    -> bs : ByteString
+    -> Maybe { n : Int | 0 <= n && n < bslen bs }
+
+assume Data.ByteString.Char8.elemIndices
+    :: GHC.Types.Char
+    -> bs : ByteString
+    -> [{ n : Int | 0 <= n && n < bslen bs }]
+
+assume Data.ByteString.Char8.elemIndexEnd
+    :: GHC.Types.Char
+    -> bs : ByteString
+    -> Maybe { n : Int | 0 <= n && n < bslen bs }
+
+assume Data.ByteString.Char8.findIndex
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> bs : ByteString
+    -> Maybe { n : Int | 0 <= n && n < bslen bs }
+
+assume Data.ByteString.Char8.findIndices
+    :: (GHC.Types.Char -> GHC.Types.Bool)
+    -> bs : ByteString
+    -> [{ n : Int | 0 <= n && n < bslen bs }]
+
+assume Data.ByteString.Char8.count
+    :: GHC.Types.Char
+    -> bs : ByteString
+    -> { n : Int | 0 <= n && n < bslen bs }
+
+assume Data.ByteString.Char8.zip
+    :: l : ByteString
+    -> r : ByteString
+    -> { o : [(GHC.Types.Char, GHC.Types.Char)] | len o <= bslen l && len o <= bslen r }
+
+assume Data.ByteString.Char8.zipWith
+    :: (GHC.Types.Char -> GHC.Types.Char -> a)
+    -> l : ByteString
+    -> r : ByteString
+    -> { o : [a] | len o <= bslen l && len o <= bslen r }
+
+assume Data.ByteString.Char8.unzip
+    :: i : [(GHC.Types.Char, GHC.Types.Char)]
+    -> ( { l : ByteString | bslen l == len i }
+       , { r : ByteString | bslen r == len i }
+       )
+
+assume readInt
+    :: i : ByteString
+    -> Maybe { p : (Int, { o : ByteString | bslen o < bslen i}) | bslen i /= 0 }
+
+assume readInteger
+    :: i : ByteString
+    -> Maybe { p : (Integer, { o : ByteString | bslen o < bslen i}) | bslen i /= 0 }
+@-}
diff --git a/src/Data/ByteString/Lazy/Char8_LHAssumptions.hs b/src/Data/ByteString/Lazy/Char8_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/ByteString/Lazy/Char8_LHAssumptions.hs
@@ -0,0 +1,257 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.ByteString.Lazy.Char8_LHAssumptions where
+
+import Data.ByteString.Lazy hiding (hGetNonBlocking, scanl)
+import Data.ByteString.Lazy.Char8
+import Data.ByteString.Lazy_LHAssumptions()
+import Data.Int
+
+{-@
+assume Data.ByteString.Lazy.Char8.last :: { bs : ByteString | 1 <= bllen bs } -> Char
+
+assume Data.ByteString.Lazy.Char8.singleton
+    :: Char -> { bs : ByteString | bllen bs == 1 }
+
+assume Data.ByteString.Lazy.Char8.pack
+    :: w8s : [Char]
+    -> { bs : ByteString | bllen bs == len w8s }
+
+assume Data.ByteString.Lazy.Char8.unpack
+    :: bs : ByteString
+    -> { w8s : [Char] | len w8s == bllen bs }
+
+assume Data.ByteString.Lazy.Char8.cons
+    :: Char
+    -> i : ByteString
+    -> { o : ByteString | bllen o == bllen i + 1 }
+
+assume Data.ByteString.Lazy.Char8.snoc
+    :: i : ByteString
+    -> Char
+    -> { o : ByteString | bllen o == bllen i + 1 }
+
+assume Data.ByteString.Lazy.Char8.head
+    :: { bs : ByteString | 1 <= bllen bs }
+    -> Char
+
+assume Data.ByteString.Lazy.Char8.uncons
+    :: i : ByteString
+    -> Maybe (Char, { o : ByteString | bllen o == bllen i - 1 })
+
+assume Data.ByteString.Lazy.Char8.unsnoc
+    :: i : ByteString
+    -> Maybe ({ o : ByteString | bllen o == bllen i - 1 }, Char)
+
+assume Data.ByteString.Lazy.Char8.map
+    :: (Char -> Char)
+    -> i : ByteString
+    -> { o : ByteString | bllen o == bllen i }
+
+assume Data.ByteString.Lazy.Char8.intersperse
+    :: Char
+    -> i : ByteString
+    -> { o : ByteString | (bllen i == 0 <=> bllen o == 0) && (1 <= bllen i <=> bllen o == 2 * bllen i - 1) }
+
+assume Data.ByteString.Lazy.Char8.foldl1
+    :: (Char -> Char -> Char)
+    -> { bs : ByteString | 1 <= bllen bs }
+    -> Char
+
+assume Data.ByteString.Lazy.Char8.foldl1'
+    :: (Char -> Char -> Char)
+    -> { bs : ByteString | 1 <= bllen bs }
+    -> Char
+
+assume Data.ByteString.Lazy.Char8.foldr1
+    :: (Char -> Char -> Char)
+    -> { bs : ByteString | 1 <= bllen bs }
+    -> Char
+
+assume Data.ByteString.Lazy.Char8.concatMap
+    :: (Char -> ByteString)
+    -> i : ByteString
+    -> { o : ByteString | bllen i == 0 ==> bllen o == 0 }
+
+assume Data.ByteString.Lazy.Char8.any :: (Char -> Bool)
+    -> bs : ByteString
+    -> { b : Bool | bllen bs == 0 ==> not b }
+
+assume Data.ByteString.Lazy.Char8.all :: (Char -> Bool)
+    -> bs : ByteString
+    -> { b : Bool | bllen bs == 0 ==> b }
+
+assume Data.ByteString.Lazy.Char8.maximum :: { bs : ByteString | 1 <= bllen bs } -> Char
+
+assume Data.ByteString.Lazy.Char8.minimum :: { bs : ByteString | 1 <= bllen bs } -> Char
+
+assume Data.ByteString.Lazy.Char8.scanl
+    :: (Char -> Char -> Char)
+    -> Char
+    -> i : ByteString
+    -> { o : ByteString | bllen o == bllen i }
+
+assume Data.ByteString.Lazy.Char8.scanl1
+    :: (Char -> Char -> Char)
+    -> i : { i : ByteString | 1 <= bllen i }
+    -> { o : ByteString | bllen o == bllen i }
+
+assume Data.ByteString.Lazy.Char8.scanr
+    :: (Char -> Char -> Char)
+    -> Char
+    -> i : ByteString
+    -> { o : ByteString | bllen o == bllen i }
+
+assume Data.ByteString.Lazy.Char8.scanr1
+    :: (Char -> Char -> Char)
+    -> i : { i : ByteString | 1 <= bllen i }
+    -> { o : ByteString | bllen o == bllen i }
+
+assume Data.ByteString.Lazy.Char8.mapAccumL
+    :: (acc -> Char -> (acc, Char))
+    -> acc
+    -> i : ByteString
+    -> (acc, { o : ByteString | bllen o == bllen i })
+
+assume Data.ByteString.Lazy.Char8.mapAccumR
+    :: (acc -> Char -> (acc, Char))
+    -> acc
+    -> i : ByteString
+    -> (acc, { o : ByteString | bllen o == bllen i })
+
+assume Data.ByteString.Lazy.Char8.replicate
+    :: n : Int64
+    -> Char
+    -> { bs : ByteString | bllen bs == n }
+
+assume Data.ByteString.Lazy.Char8.takeWhile
+    :: (Char -> Bool)
+    -> i : ByteString
+    -> { o : ByteString | bllen o <= bllen i }
+
+assume Data.ByteString.Lazy.Char8.dropWhile
+    :: (Char -> Bool)
+    -> i : ByteString
+    -> { o : ByteString | bllen o <= bllen i }
+
+assume Data.ByteString.Lazy.Char8.span
+    :: (Char -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bllen l <= bllen i }
+       , { r : ByteString | bllen r <= bllen i }
+       )
+
+assume Data.ByteString.Lazy.Char8.break
+    :: (Char -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bllen l <= bllen i }
+       , { r : ByteString | bllen r <= bllen i }
+       )
+
+assume Data.ByteString.Lazy.Char8.groupBy
+    :: (Char -> Char -> Bool)
+    -> i : ByteString
+    -> [{ o : ByteString | 1 <= bllen o && bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.Char8.split
+    :: Char
+    -> i : ByteString
+    -> [{ o : ByteString | bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.Char8.splitWith
+    :: (Char -> Bool)
+    -> i : ByteString
+    -> [{ o : ByteString | bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.Char8.lines
+    :: i : ByteString
+    -> [{ o : ByteString | bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.Char8.words
+    :: i : ByteString
+    -> [{ o : ByteString | bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.Char8.unlines
+    :: is : [ByteString]
+    -> { o : ByteString | (len is == 0 <=> bllen o == 0) && bllen o >= len is }
+
+assume Data.ByteString.Lazy.Char8.unwords
+    :: is : [ByteString]
+    -> { o : ByteString | (len is == 0 ==> bllen o == 0) && (1 <= len is ==> bllen o >= len is - 1) }
+
+assume Data.ByteString.Lazy.Char8.elem
+    :: Char
+    -> bs : ByteString
+    -> { b : Bool | bllen bs == 0 ==> not b }
+
+assume Data.ByteString.Lazy.Char8.notElem
+    :: Char
+    -> bs : ByteString
+    -> { b : Bool | bllen bs == 0 ==> b }
+
+assume Data.ByteString.Lazy.Char8.find
+    :: (Char -> Bool)
+    -> bs : ByteString
+    -> Maybe { w8 : Char | bllen bs /= 0 }
+
+assume Data.ByteString.Lazy.Char8.filter
+    :: (Char -> Bool)
+    -> i : ByteString
+    -> { o : ByteString | bllen o <= bllen i }
+
+assume Data.ByteString.Lazy.Char8.index
+    :: bs : ByteString
+    -> { n : Int64 | 0 <= n && n < bllen bs }
+    -> Char
+
+assume Data.ByteString.Lazy.Char8.elemIndex
+    :: Char
+    -> bs : ByteString
+    -> Maybe { n : Int64 | 0 <= n && n < bllen bs }
+
+assume Data.ByteString.Lazy.Char8.elemIndices
+    :: Char
+    -> bs : ByteString
+    -> [{ n : Int64 | 0 <= n && n < bllen bs }]
+
+assume Data.ByteString.Lazy.Char8.findIndex
+    :: (Char -> Bool)
+    -> bs : ByteString
+    -> Maybe { n : Int64 | 0 <= n && n < bllen bs }
+
+assume Data.ByteString.Lazy.Char8.findIndices
+    :: (Char -> Bool)
+    -> bs : ByteString
+    -> [{ n : Int64 | 0 <= n && n < bllen bs }]
+
+assume Data.ByteString.Lazy.Char8.count
+    :: Char
+    -> bs : ByteString
+    -> { n : Int64 | 0 <= n && n < bllen bs }
+
+assume Data.ByteString.Lazy.Char8.zip
+    :: l : ByteString
+    -> r : ByteString
+    -> { o : [(Char, Char)] | len o <= bllen l && len o <= bllen r }
+
+assume Data.ByteString.Lazy.Char8.zipWith
+    :: (Char -> Char -> a)
+    -> l : ByteString
+    -> r : ByteString
+    -> { o : [a] | len o <= bllen l && len o <= bllen r }
+
+assume Data.ByteString.Lazy.Char8.unzip
+    :: i : [(Char, Char)]
+    -> ( { l : ByteString | bllen l == len i }
+       , { r : ByteString | bllen r == len i }
+       )
+
+assume readInt
+    :: i : ByteString
+    -> Maybe { p : (Int, { o : ByteString | bllen o < bllen i}) | bllen i /= 0 }
+
+assume readInteger
+    :: i : ByteString
+    -> Maybe { p : (Integer, { o : ByteString | bllen o < bllen i}) | bllen i /= 0 }
+
+@-}
diff --git a/src/Data/ByteString/Lazy_LHAssumptions.hs b/src/Data/ByteString/Lazy_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/ByteString/Lazy_LHAssumptions.hs
@@ -0,0 +1,346 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.ByteString.Lazy_LHAssumptions where
+
+import qualified Data.ByteString
+import Data.ByteString_LHAssumptions()
+import Data.ByteString.Lazy
+import Data.Int
+import Data.String_LHAssumptions()
+import GHC.Int_LHAssumptions()
+
+{-@
+measure bllen :: ByteString -> { n : Int64 | 0 <= n }
+
+invariant { bs : ByteString | 0 <= bllen bs }
+
+invariant { bs : ByteString | bllen bs == stringlen bs }
+
+assume empty :: { bs : ByteString | bllen bs == 0 }
+
+assume singleton
+    :: _ -> { bs : ByteString | bllen bs == 1 }
+
+assume pack
+    :: w8s : [_]
+    -> { bs : _ | bllen bs == len w8s }
+
+assume unpack
+    :: bs : ByteString
+    -> { w8s : [_] | len w8s == bllen bs }
+
+assume fromStrict
+    :: i : Data.ByteString.ByteString
+    -> { o : ByteString | bllen o == bslen i }
+
+assume toStrict
+    :: i : ByteString
+    -> { o : Data.ByteString.ByteString | bslen o == bllen i }
+
+assume fromChunks
+    :: i : [Data.ByteString.ByteString]
+    -> { o : ByteString | len i == 0 <=> bllen o == 0 }
+
+assume toChunks
+    :: i : ByteString
+    -> { os : [{ o : Data.ByteString.ByteString | bslen o <= bllen i}] | len os == 0 <=> bllen i == 0 }
+
+assume Data.ByteString.Lazy.cons
+    :: _
+    -> i : ByteString
+    -> { o : ByteString | bllen o == bllen i + 1 }
+
+assume Data.ByteString.Lazy.snoc
+    :: i : ByteString
+    -> _
+    -> { o : ByteString | bllen o == bllen i + 1 }
+
+assume Data.ByteString.Lazy.append
+    :: l : ByteString
+    -> r : ByteString
+    -> { o : ByteString | bllen o == bllen l + bllen r }
+
+assume Data.ByteString.Lazy.head
+    :: { bs : ByteString | 1 <= bllen bs }
+    -> _
+
+assume Data.ByteString.Lazy.uncons
+    :: i : ByteString
+    -> Maybe (_, { o : ByteString | bllen o == bllen i - 1 })
+
+assume Data.ByteString.Lazy.unsnoc
+    :: i : ByteString
+    -> Maybe ({ o : ByteString | bllen o == bllen i - 1 }, _)
+
+assume Data.ByteString.Lazy.last :: { bs : ByteString | 1 <= bllen bs } -> _
+
+assume Data.ByteString.Lazy.tail :: { bs : ByteString | 1 <= bllen bs } -> _
+
+assume Data.ByteString.Lazy.init :: { bs : ByteString | 1 <= bllen bs } -> _
+
+assume Data.ByteString.Lazy.null :: bs : ByteString -> { b : Bool | b <=> bllen bs == 0 }
+
+assume Data.ByteString.Lazy.length
+    :: bs : ByteString -> { n : Int64 | bllen bs == n }
+
+assume Data.ByteString.Lazy.map
+    :: (_ -> _)
+    -> i : ByteString
+    -> { o : ByteString | bllen o == bllen i }
+
+assume Data.ByteString.Lazy.reverse
+    :: i : ByteString
+    -> { o : ByteString | bllen o == bllen i }
+
+assume Data.ByteString.Lazy.intersperse
+    :: _
+    -> i : ByteString
+    -> { o : ByteString | (bllen i == 0 <=> bllen o == 0) && (1 <= bllen i <=> bllen o == 2 * bllen i - 1) }
+
+assume Data.ByteString.Lazy.intercalate
+    :: l : ByteString
+    -> rs : [ByteString]
+    -> { o : ByteString | len rs == 0 ==> bllen o == 0 }
+
+assume Data.ByteString.Lazy.transpose
+    :: is : [ByteString]
+    -> { os : [{ bs : ByteString | bllen bs <= len is }] | len is == 0 ==> len os == 0}
+
+assume Data.ByteString.Lazy.foldl1
+    :: (_ -> _ -> _)
+    -> { bs : ByteString | 1 <= bllen bs }
+    -> _
+
+assume Data.ByteString.Lazy.foldl1'
+    :: (_ -> _ -> _)
+    -> { bs : ByteString | 1 <= bllen bs }
+    -> _
+
+assume Data.ByteString.Lazy.foldr1
+    :: (_ -> _ -> _)
+    -> { bs : ByteString | 1 <= bllen bs }
+    -> _
+
+assume Data.ByteString.Lazy.concat
+    :: is : [ByteString]
+    -> { o : ByteString | (len is == 0) ==> (bllen o == 0) }
+
+assume Data.ByteString.Lazy.concatMap
+    :: (_ -> ByteString)
+    -> i : ByteString
+    -> { o : ByteString | bllen i == 0 ==> bllen o == 0 }
+
+assume Data.ByteString.Lazy.any :: (_ -> Bool)
+    -> bs : ByteString
+    -> { b : Bool | bllen bs == 0 ==> not b }
+
+assume Data.ByteString.Lazy.all :: (_ -> Bool)
+    -> bs : ByteString
+    -> { b : Bool | bllen bs == 0 ==> b }
+
+assume Data.ByteString.Lazy.maximum :: { bs : ByteString | 1 <= bllen bs } -> _
+
+assume Data.ByteString.Lazy.minimum :: { bs : ByteString | 1 <= bllen bs } -> _
+
+assume Data.ByteString.Lazy.scanl
+    :: (_ -> _ -> _)
+    -> _
+    -> i : ByteString
+    -> { o : ByteString | bllen o == bllen i }
+
+assume Data.ByteString.Lazy.mapAccumL
+    :: (acc -> _ -> (acc, _))
+    -> acc
+    -> i : ByteString
+    -> (acc, { o : ByteString | bllen o == bllen i })
+
+assume Data.ByteString.Lazy.mapAccumR
+    :: (acc -> _ -> (acc, _))
+    -> acc
+    -> i : ByteString
+    -> (acc, { o : ByteString | bllen o == bllen i })
+
+assume Data.ByteString.Lazy.replicate
+    :: n : Int64
+    -> _
+    -> { bs : ByteString | bllen bs == n }
+
+assume Data.ByteString.Lazy.take
+    :: n : Int64
+    -> i : ByteString
+    -> { o : ByteString | (n <= 0 ==> bllen o == 0) &&
+                                               ((0 <= n && n <= bllen i) <=> bllen o == n) &&
+                                               (bllen i <= n <=> bllen o = bllen i) }
+
+assume Data.ByteString.Lazy.drop
+    :: n : Int64
+    -> i : ByteString
+    -> { o : ByteString | (n <= 0 <=> bllen o == bllen i) &&
+                                               ((0 <= n && n <= bllen i) <=> bllen o == bllen i - n) &&
+                                               (bllen i <= n <=> bllen o == 0) }
+
+assume Data.ByteString.Lazy.splitAt
+    :: n : Int64
+    -> i : ByteString
+    -> ( { l : ByteString | (n <= 0 <=> bllen l == 0) &&
+                                                 ((0 <= n && n <= bllen i) <=> bllen l == n) &&
+                                                 (bllen i <= n <=> bllen l == bllen i) }
+       , { r : ByteString | (n <= 0 <=> bllen r == bllen i) &&
+                                                 ((0 <= n && n <= bllen i) <=> bllen r == bllen i - n) &&
+                                                 (bllen i <= n <=> bllen r == 0) }
+       )
+
+assume Data.ByteString.Lazy.takeWhile
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> { o : ByteString | bllen o <= bllen i }
+
+assume Data.ByteString.Lazy.dropWhile
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> { o : ByteString | bllen o <= bllen i }
+
+assume Data.ByteString.Lazy.span
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bllen l <= bllen i }
+       , { r : ByteString | bllen r <= bllen i }
+       )
+
+assume Data.ByteString.Lazy.break
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bllen l <= bllen i }
+       , { r : ByteString | bllen r <= bllen i }
+       )
+
+assume Data.ByteString.Lazy.group
+    :: i : ByteString
+    -> [{ o : ByteString | 1 <= bllen o && bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.groupBy
+    :: (_ -> _ -> Bool)
+    -> i : ByteString
+    -> [{ o : ByteString | 1 <= bllen o && bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.inits
+    :: i : ByteString
+    -> [{ o : ByteString | bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.tails
+    :: i : ByteString
+    -> [{ o : ByteString | bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.split
+    :: _
+    -> i : ByteString
+    -> [{ o : ByteString | bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.splitWith
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> [{ o : ByteString | bllen o <= bllen i }]
+
+assume Data.ByteString.Lazy.isPrefixOf
+    :: l : ByteString
+    -> r : ByteString
+    -> { b : Bool | bllen l >= bllen r ==> not b }
+
+assume Data.ByteString.Lazy.isSuffixOf
+    :: l : ByteString
+    -> r : ByteString
+    -> { b : Bool | bllen l >= bllen r ==> not b }
+
+assume Data.ByteString.Lazy.elem
+    :: _
+    -> bs : ByteString
+    -> { b : Bool | (bllen bs == 0) ==> not b }
+
+assume Data.ByteString.Lazy.notElem
+    :: _
+    -> bs : ByteString
+    -> { b : Bool | (bllen bs == 0) ==> b }
+
+assume Data.ByteString.Lazy.find
+    :: (_ -> Bool)
+    -> bs : ByteString
+    -> Maybe { w8 : _ | bllen bs /= 0 }
+
+assume Data.ByteString.Lazy.filter
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> { o : ByteString | bllen o <= bllen i }
+
+assume Data.ByteString.Lazy.partition
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bllen l <= bllen i }
+       , { r : ByteString | bllen r <= bllen i }
+       )
+
+assume Data.ByteString.Lazy.index
+    :: bs : ByteString
+    -> { n : Int64 | 0 <= n && n < bllen bs }
+    -> _
+
+assume Data.ByteString.Lazy.elemIndex
+    :: _
+    -> bs : ByteString
+    -> Maybe { n : Int64 | 0 <= n && n < bllen bs }
+
+assume Data.ByteString.Lazy.elemIndices
+    :: _
+    -> bs : ByteString
+    -> [{ n : Int64 | 0 <= n && n < bllen bs }]
+
+assume Data.ByteString.Lazy.elemIndexEnd
+    :: _
+    -> bs : ByteString
+    -> Maybe { n : Int64 | 0 <= n && n < bllen bs }
+
+assume Data.ByteString.Lazy.findIndex
+    :: (_ -> Bool)
+    -> bs : ByteString
+    -> Maybe { n : Int64 | 0 <= n && n < bllen bs }
+
+assume Data.ByteString.Lazy.findIndices
+    :: (_ -> Bool)
+    -> bs : ByteString
+    -> [{ n : Int64 | 0 <= n && n < bllen bs }]
+
+assume Data.ByteString.Lazy.count
+    :: _
+    -> bs : ByteString
+    -> { n : Int64 | 0 <= n && n < bllen bs }
+
+assume Data.ByteString.Lazy.zip
+    :: l : ByteString
+    -> r : ByteString
+    -> { o : [(_, _)] | len o <= bllen l && len o <= bllen r }
+
+assume Data.ByteString.Lazy.zipWith
+    :: (_ -> _ -> a)
+    -> l : ByteString
+    -> r : ByteString
+    -> { o : [a] | len o <= bllen l && len o <= bllen r }
+
+assume Data.ByteString.Lazy.unzip
+    :: i : [(_, _)]
+    -> ( { l : ByteString | bllen l == len i }
+       , { r : ByteString | bllen r == len i }
+       )
+
+assume Data.ByteString.Lazy.copy
+    :: i : ByteString
+    -> { o : ByteString | bllen o == bllen i }
+
+assume Data.ByteString.Lazy.hGet
+    :: _
+    -> n : { n : Int | 0 <= n }
+    -> IO { bs : ByteString | bllen bs == n || bllen bs == 0 }
+
+assume Data.ByteString.Lazy.hGetNonBlocking
+    :: _
+    -> n : { n : Int | 0 <= n }
+    -> IO { bs : ByteString | bllen bs <= n }
+@-}
diff --git a/src/Data/ByteString/Short_LHAssumptions.hs b/src/Data/ByteString/Short_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/ByteString/Short_LHAssumptions.hs
@@ -0,0 +1,33 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.ByteString.Short_LHAssumptions where
+
+import Data.ByteString (ByteString)
+import Data.ByteString_LHAssumptions()
+import Data.ByteString.Short
+import Data.String_LHAssumptions()
+import Data.Word
+
+{-@
+measure sbslen :: ShortByteString -> { n : Int | 0 <= n }
+
+invariant { bs : ShortByteString  | 0 <= sbslen bs }
+
+invariant { bs : ShortByteString | sbslen bs == stringlen bs }
+
+assume toShort :: i : ByteString -> { o : ShortByteString | sbslen o == bslen i }
+
+assume fromShort :: o : ShortByteString -> { i : ByteString | bslen i == sbslen o }
+
+assume pack :: w8s : [Word8] -> { bs : ShortByteString | sbslen bs == len w8s }
+
+assume unpack :: bs : ShortByteString -> { w8s : [Word8] | len w8s == sbslen bs }
+
+assume empty :: { bs : ShortByteString | sbslen bs == 0 }
+
+assume Data.ByteString.Short.null :: bs : ShortByteString -> { b : Bool | b <=> sbslen bs == 0 }
+
+assume Data.ByteString.Short.length :: bs : ShortByteString -> { n : Int | sbslen bs == n }
+
+assume index :: bs : ShortByteString -> { n : Int | 0 <= n && n < sbslen bs } -> Word8
+@-}
diff --git a/src/Data/ByteString/Unsafe_LHAssumptions.hs b/src/Data/ByteString/Unsafe_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/ByteString/Unsafe_LHAssumptions.hs
@@ -0,0 +1,38 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.ByteString.Unsafe_LHAssumptions where
+
+import Data.ByteString
+import Data.ByteString.Unsafe
+import Data.ByteString_LHAssumptions()
+import GHC.Types_LHAssumptions()
+
+{-@
+assume Data.ByteString.Unsafe.unsafeHead
+    :: { bs : ByteString | 1 <= bslen bs } -> _
+
+assume Data.ByteString.Unsafe.unsafeTail
+    :: bs : { v : ByteString | bslen v > 0 }
+    -> { v : ByteString | bslen v = bslen bs - 1 }
+
+assume Data.ByteString.Unsafe.unsafeInit
+    :: { bs : ByteString | 1 <= bslen bs } -> _
+
+assume Data.ByteString.Unsafe.unsafeLast
+    :: { bs : ByteString | 1 <= bslen bs } -> _
+
+assume Data.ByteString.Unsafe.unsafeIndex
+    :: bs : ByteString
+    -> { n : Int | 0 <= n && n < bslen bs }
+    -> _
+
+assume Data.ByteString.Unsafe.unsafeTake
+    :: n : { n : Int | 0 <= n }
+    -> i : { i : ByteString | n <= bslen i }
+    -> { o : ByteString | bslen o == n }
+
+assume Data.ByteString.Unsafe.unsafeDrop
+    :: n : { n : Int | 0 <= n }
+    -> i : { i : ByteString | n <= bslen i }
+    -> { o : ByteString | bslen o == bslen i - n }
+@-}
diff --git a/src/Data/ByteString_LHAssumptions.hs b/src/Data/ByteString_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/ByteString_LHAssumptions.hs
@@ -0,0 +1,380 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.ByteString_LHAssumptions where
+
+import Data.ByteString
+import Data.String_LHAssumptions()
+import GHC.Word
+
+{-@
+measure bslen :: ByteString -> { n : Int | 0 <= n }
+
+invariant { bs : ByteString  | 0 <= bslen bs }
+
+invariant { bs : ByteString | bslen bs == stringlen bs }
+
+assume empty :: { bs : ByteString | bslen bs == 0 }
+
+assume Data.ByteString.singleton :: _ -> { bs : ByteString | bslen bs == 1 }
+
+assume Data.ByteString.pack :: w8s : [_]
+     -> { bs : ByteString | bslen bs == len w8s }
+
+assume Data.ByteString.unpack :: bs : ByteString
+       -> { w8s : [_] | len w8s == bslen bs }
+
+assume Data.ByteString.cons :: _
+     -> i : ByteString
+     -> { o : ByteString | bslen o == bslen i + 1 }
+
+assume Data.ByteString.snoc :: i : ByteString
+     -> _
+     -> { o : ByteString | bslen o == bslen i + 1 }
+
+assume Data.ByteString.append :: l : ByteString
+       -> r : ByteString
+       -> { o : ByteString | bslen o == bslen l + bslen r }
+
+assume Data.ByteString.head :: { bs : ByteString | 1 <= bslen bs } -> _
+
+assume Data.ByteString.unsnoc :: i:ByteString
+       -> (Maybe ({ o : ByteString | bslen o == bslen i - 1 }, _))
+
+assume Data.ByteString.last :: { bs : ByteString | 1 <= bslen bs } -> _
+
+assume Data.ByteString.tail :: { bs : ByteString | 1 <= bslen bs } -> _
+
+assume Data.ByteString.init
+  :: {i:ByteString | 1 <= bslen i }
+  -> {o:ByteString | bslen o == bslen i - 1 }
+
+assume Data.ByteString.null
+  :: bs : ByteString
+  -> { b : Bool | b <=> bslen bs == 0 }
+
+assume Data.ByteString.length :: bs : ByteString -> { n : Int | bslen bs == n }
+
+assume Data.ByteString.map
+  :: (_ -> _)
+  -> i : ByteString
+  -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.reverse
+  :: i : ByteString
+  -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.intersperse
+  :: _
+  -> i : ByteString
+  -> { o : ByteString | (bslen i == 0 <=> bslen o == 0) && (1 <= bslen i <=> bslen o == 2 * bslen i - 1) }
+
+assume Data.ByteString.intercalate
+  :: l : ByteString
+  -> rs : [ByteString]
+  -> { o : ByteString | len rs == 0 ==> bslen o == 0 }
+
+assume Data.ByteString.transpose
+  :: is : [ByteString]
+  -> { os : [{ bs : ByteString | bslen bs <= len is }] | len is == 0 ==> len os == 0}
+
+assume Data.ByteString.foldl1
+  :: (_ -> _ -> _)
+  -> { bs : ByteString | 1 <= bslen bs }
+  -> _
+
+assume Data.ByteString.foldl1'
+  :: (_ -> _ -> _)
+  -> { bs : ByteString | 1 <= bslen bs }
+  -> _
+
+assume Data.ByteString.foldr1
+  :: (_ -> _ -> _)
+  -> { bs : ByteString | 1 <= bslen bs }
+  -> _
+
+assume Data.ByteString.foldr1'
+  :: (_ -> _ -> _)
+  -> { bs : ByteString | 1 <= bslen bs }
+  -> _
+
+assume Data.ByteString.concat
+  :: is : [ByteString]
+  -> { o : ByteString | (len is == 0) ==> (bslen o == 0) }
+
+assume Data.ByteString.concatMap
+  :: (_ -> ByteString)
+  -> i : ByteString
+  -> { o : ByteString | bslen i == 0 ==> bslen o == 0 }
+
+assume Data.ByteString.any
+  :: (_ -> Bool)
+  -> bs : ByteString
+  -> { b : Bool | bslen bs == 0 ==> not b }
+
+assume Data.ByteString.all
+  :: (_ -> Bool)
+  -> bs : ByteString
+  -> { b : Bool | bslen bs == 0 ==> b }
+
+assume Data.ByteString.maximum :: { bs : ByteString | 1 <= bslen bs } -> _
+
+assume Data.ByteString.minimum :: { bs : ByteString | 1 <= bslen bs } -> _
+
+assume Data.ByteString.scanl :: (_ -> _ -> _)
+      -> _
+      -> i : ByteString
+      -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.scanl1 :: (_ -> _ -> _)
+       -> i : { i : ByteString | 1 <= bslen i }
+       -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.scanr
+    :: (_ -> _ -> _)
+    -> _
+    -> i : ByteString
+    -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.scanr1
+    :: (_ -> _ -> _)
+    -> i : { i : ByteString | 1 <= bslen i }
+    -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.mapAccumL
+    :: (acc -> _ -> (acc, _))
+    -> acc
+    -> i : ByteString
+    -> (acc, { o : ByteString | bslen o == bslen i })
+
+assume Data.ByteString.mapAccumR
+    :: (acc -> _ -> (acc, _))
+    -> acc
+    -> i : ByteString
+    -> (acc, { o : ByteString | bslen o == bslen i })
+
+assume Data.ByteString.replicate
+    :: n : Int
+    -> _
+    -> { bs : ByteString | bslen bs == n }
+
+assume Data.ByteString.unfoldrN
+    :: n : Int
+    -> (a -> Maybe (_, a))
+    -> a
+    -> ({ bs : ByteString | bslen bs <= n }, Maybe a)
+
+assume Data.ByteString.take
+    :: n : Int
+    -> i : ByteString
+    -> { o : ByteString | (n <= 0 <=> bslen o == 0) &&
+                                          ((0 <= n && n <= bslen i) <=> bslen o == n) &&
+                                          (bslen i <= n <=> bslen o = bslen i) }
+
+assume Data.ByteString.drop
+    :: n : Int
+    -> i : ByteString
+    -> { o : ByteString | (n <= 0 <=> bslen o == bslen i) &&
+                                          ((0 <= n && n <= bslen i) <=> bslen o == bslen i - n) &&
+                                          (bslen i <= n <=> bslen o == 0) }
+
+assume Data.ByteString.splitAt
+    :: n : Int
+    -> i : ByteString
+    -> ( { l : ByteString | (n <= 0 <=> bslen l == 0) &&
+                                            ((0 <= n && n <= bslen i) <=> bslen l == n) &&
+                                            (bslen i <= n <=> bslen l == bslen i) }
+       , { r : ByteString | (n <= 0 <=> bslen r == bslen i) &&
+                                            ((0 <= n && n <= bslen i) <=> bslen r == bslen i - n) &&
+                                            (bslen i <= n <=> bslen r == 0) }
+       )
+
+assume Data.ByteString.takeWhile
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> { o : ByteString | bslen o <= bslen i }
+
+assume Data.ByteString.dropWhile
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> { o : ByteString | bslen o <= bslen i }
+
+assume Data.ByteString.span
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bslen l <= bslen i }
+       , { r : ByteString | bslen r <= bslen i }
+       )
+
+assume Data.ByteString.spanEnd
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bslen l <= bslen i }
+       , { r : ByteString | bslen r <= bslen i }
+       )
+
+assume Data.ByteString.break
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bslen l <= bslen i }
+       , { r : ByteString | bslen r <= bslen i }
+       )
+
+assume Data.ByteString.breakEnd
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bslen l <= bslen i }
+       , { r : ByteString | bslen r <= bslen i }
+       )
+
+assume Data.ByteString.group
+    :: i : ByteString
+    -> [{ o : ByteString | 1 <= bslen o && bslen o <= bslen i }]
+
+assume Data.ByteString.groupBy
+    :: (_ -> _ -> Bool)
+    -> i : ByteString
+    -> [{ o : ByteString | 1 <= bslen o && bslen o <= bslen i }]
+
+assume Data.ByteString.inits
+    :: i : ByteString
+    -> [{ o : ByteString | bslen o <= bslen i }]
+
+assume Data.ByteString.tails
+    :: i : ByteString
+    -> [{ o : ByteString | bslen o <= bslen i }]
+
+assume Data.ByteString.split
+    :: _
+    -> i : ByteString
+    -> [{ o : ByteString | bslen o <= bslen i }]
+
+assume Data.ByteString.splitWith
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> [{ o : ByteString | bslen o <= bslen i }]
+
+assume Data.ByteString.isPrefixOf
+    :: l : ByteString
+    -> r : ByteString
+    -> { b : Bool | bslen l >= bslen r ==> not b }
+
+assume Data.ByteString.isSuffixOf
+    :: l : ByteString
+    -> r : ByteString
+    -> { b : Bool | bslen l > bslen r ==> not b }
+
+assume Data.ByteString.isInfixOf
+    :: l : ByteString
+    -> r : ByteString
+    -> { b : Bool | bslen l > bslen r ==> not b }
+
+assume Data.ByteString.breakSubstring
+    :: il : ByteString
+    -> ir : ByteString
+    -> ( { ol : ByteString | bslen ol <= bslen ir && (bslen il > bslen ir ==> bslen ol == bslen ir)}
+       , { or : ByteString | bslen or <= bslen ir && (bslen il > bslen ir ==> bslen or == 0) }
+       )
+
+assume Data.ByteString.elem
+    :: _
+    -> bs : ByteString
+    -> { b : Bool | bslen bs == 0 ==> not b }
+
+assume Data.ByteString.notElem
+    :: _
+    -> bs : ByteString
+    -> { b : Bool | bslen bs == 0 ==> b }
+
+assume Data.ByteString.find
+    :: (_ -> Bool)
+    -> bs : ByteString
+    -> (Maybe { w8 : _ | bslen bs /= 0 })
+
+assume Data.ByteString.filter
+    :: (_ -> Bool)
+    -> i : ByteString
+    -> { o : ByteString | bslen o <= bslen i }
+
+assume Data.ByteString.partition
+    :: (Word8 -> Bool)
+    -> i : ByteString
+    -> ( { l : ByteString | bslen l <= bslen i }
+       , { r : ByteString | bslen r <= bslen i }
+       )
+
+assume Data.ByteString.index :: bs : ByteString -> { n : Int | 0 <= n && n < bslen bs } -> _
+
+assume Data.ByteString.elemIndex
+    :: _
+    -> bs : ByteString
+    -> (Maybe { n : Int | 0 <= n && n < bslen bs })
+
+assume Data.ByteString.elemIndices
+    :: _
+    -> bs : ByteString
+    -> [{ n : Int | 0 <= n && n < bslen bs }]
+
+assume Data.ByteString.elemIndexEnd
+    :: _
+    -> bs : ByteString
+    -> (Maybe { n : Int | 0 <= n && n < bslen bs })
+
+assume Data.ByteString.findIndex
+    :: (_ -> Bool)
+    -> bs : ByteString
+    -> (Maybe { n : Int | 0 <= n && n < bslen bs })
+
+assume Data.ByteString.findIndices
+    :: (_ -> Bool)
+    -> bs : ByteString
+    -> [{ n : Int | 0 <= n && n < bslen bs }]
+
+assume Data.ByteString.count
+    :: _
+    -> bs : ByteString
+    -> { n : Int | 0 <= n && n < bslen bs }
+
+assume Data.ByteString.zip
+    :: l : ByteString
+    -> r : ByteString
+    -> { o : [(_, _)] | len o <= bslen l && len o <= bslen r }
+
+assume Data.ByteString.zipWith
+    :: (_ -> _ -> a)
+    -> l : ByteString
+    -> r : ByteString
+    -> { o : [a] | len o <= bslen l && len o <= bslen r }
+
+assume Data.ByteString.unzip
+    :: i : [(_, _)]
+    -> ( { l : ByteString | bslen l == len i }
+       , { r : ByteString | bslen r == len i }
+       )
+
+assume Data.ByteString.sort
+    :: i : ByteString
+    -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.copy
+    :: i : ByteString
+    -> { o : ByteString | bslen o == bslen i }
+
+assume Data.ByteString.hGet
+    :: _
+    -> n : { n : Int | 0 <= n }
+    -> (IO { bs : ByteString | bslen bs == n || bslen bs == 0 })
+
+assume Data.ByteString.hGetSome
+    :: _
+    -> n : { n : Int | 0 <= n }
+    -> (IO { bs : ByteString | bslen bs <= n })
+
+assume Data.ByteString.hGetNonBlocking
+    :: _
+    -> n : { n : Int | 0 <= n }
+    -> (IO { bs : ByteString | bslen bs <= n })
+
+assume Data.ByteString.uncons
+    :: i : ByteString
+    -> (Maybe (_, { o : ByteString | bslen o == bslen i - 1 }))
+@-}
diff --git a/src/Data/Either_LHAssumptions.hs b/src/Data/Either_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/Either_LHAssumptions.hs
@@ -0,0 +1,11 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.Either_LHAssumptions where
+
+import GHC.Types_LHAssumptions()
+
+{-@
+measure isLeft :: Either a b -> Bool
+  isLeft (Left x)  = true
+  isLeft (Right x) = false
+@-}
diff --git a/src/Data/Foldable_LHAssumptions.hs b/src/Data/Foldable_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/Foldable_LHAssumptions.hs
@@ -0,0 +1,12 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.Foldable_LHAssumptions where
+
+import Data.Foldable
+import GHC.Types_LHAssumptions()
+import Prelude hiding (length, null)
+
+{-@
+assume length :: Foldable f => forall a. xs:f a -> {v:Nat | v = len xs}
+assume null   :: Foldable f => forall a. v:(f a) -> {b:Bool | (b <=> len v = 0) && (not b <=> len v > 0)}
+@-}
diff --git a/src/Data/Int_LHAssumptions.hs b/src/Data/Int_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/Int_LHAssumptions.hs
@@ -0,0 +1,4 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+module Data.Int_LHAssumptions where
+
+import GHC.Int_LHAssumptions()
diff --git a/src/Data/List_LHAssumptions.hs b/src/Data/List_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/List_LHAssumptions.hs
@@ -0,0 +1,9 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+module Data.List_LHAssumptions where
+
+-- TODO: For some reason, the specifications of GHC.List have
+-- a role when verifying functions from Data.List. e.g
+-- basic/pos/AssmReflFilter.hs
+--
+-- Needs to be investigated.
+import GHC.List_LHAssumptions()
diff --git a/src/Data/Maybe_LHAssumptions.hs b/src/Data/Maybe_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/Maybe_LHAssumptions.hs
@@ -0,0 +1,21 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.Maybe_LHAssumptions where
+
+import Data.Maybe
+import GHC.Types_LHAssumptions ()
+
+{-@
+assume maybe :: v:b -> (a -> b) -> u:(Maybe a) -> {w:b | not (isJust u) => w == v}
+assume isNothing :: v:(Maybe a) -> {b:Bool | not (isJust v) == b}
+assume fromMaybe :: v:a -> u:(Maybe a) -> {x:a | not (isJust u) => x == v}
+
+assume isJust :: v:(Maybe a) -> {b:Bool | b == isJust v}
+measure isJust :: Maybe a -> Bool
+  isJust (Just x)  = true
+  isJust (Nothing) = false
+
+assume fromJust :: {v:(Maybe a) | isJust v} -> a
+measure fromJust :: Maybe a -> a
+  fromJust (Just x) = x
+@-}
diff --git a/src/Data/Set_LHAssumptions.hs b/src/Data/Set_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/Set_LHAssumptions.hs
@@ -0,0 +1,53 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.Set_LHAssumptions where
+
+import Data.Set
+import GHC.Types_LHAssumptions()
+import Prelude hiding (null)
+
+{-@
+
+embed Set as Set_Set
+
+//  ---------------------------------------------------------------------------------------------
+//  -- | Refined Types for Data.Set Operations --------------------------------------------------
+//  ---------------------------------------------------------------------------------------------
+
+assume isSubsetOf    :: (Ord a) => x:(Set a) -> y:(Set a) -> {v:Bool | v <=> Set_sub x y}
+assume member        :: Ord a => x:a -> xs:(Set a) -> {v:Bool | v <=> Set_mem x xs}
+assume null          :: Ord a => xs:(Set a) -> {v:Bool | v <=> Set_emp xs}
+assume size          :: xs:(Set a) -> {v:Nat | v = Set_card xs}
+
+assume empty         :: {v:(Set a) | Set_emp v}
+assume singleton     :: x:a -> {v:(Set a) | v = (Set_sng x)}
+assume insert        :: Ord a => x:a -> xs:(Set a) -> {v:(Set a) | v = Set_cup xs (Set_sng x)}
+assume delete        :: (Ord a) => x:a -> xs:(Set a) -> {v:(Set a) | v = Set_dif xs (Set_sng x)}
+
+assume union         :: Ord a => xs:(Set a) -> ys:(Set a) -> {v:(Set a) | v = Set_cup xs ys}
+assume intersection  :: Ord a => xs:(Set a) -> ys:(Set a) -> {v:(Set a) | v = Set_cap xs ys}
+assume difference    :: Ord a => xs:(Set a) -> ys:(Set a) -> {v:(Set a) | v = Set_dif xs ys}
+
+assume fromList :: Ord a => xs:[a] -> {v:Set a | v = listElts xs}
+assume toList   :: Ord a => s:Set a -> {xs:[a] | s = listElts xs}
+
+//  ---------------------------------------------------------------------------------------------
+//  -- | The set of elements in a list ----------------------------------------------------------
+//  ---------------------------------------------------------------------------------------------
+
+measure listElts :: [a] -> Set a
+  listElts []     = {v | (Set_emp v)}
+  listElts (x:xs) = {v | v = Set_cup (Set_sng x) (listElts xs) }
+
+define singleton x      = (Set_sng x)
+define union x y        = (Set_cup x y)
+define intersection x y = (Set_cap x y)
+define difference x y   = (Set_dif x y)
+define empty            = (Set_empty 0)
+define null x           = (Set_emp x)
+define size x           = (Set_card x)
+define member x xs      = (Set_mem x xs)
+define isSubsetOf x y   = (Set_sub x y)
+define fromList xs      = (Data.Set_LHAssumptions.listElts xs)
+
+@-}
diff --git a/src/Data/String_LHAssumptions.hs b/src/Data/String_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/String_LHAssumptions.hs
@@ -0,0 +1,15 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.String_LHAssumptions where
+
+import Data.String
+import GHC.Types_LHAssumptions()
+
+{-@
+measure stringlen :: a -> Int
+
+assume fromString
+    ::  forall a. IsString a
+    =>  i : [Char]
+    ->  { o : a | i ~~ o && len i == stringlen o }
+@-}
diff --git a/src/Data/Tuple_LHAssumptions.hs b/src/Data/Tuple_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/Tuple_LHAssumptions.hs
@@ -0,0 +1,19 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Data.Tuple_LHAssumptions where
+
+import Data.Tuple
+
+{-@
+assume fst :: {f:(x:(a,b) -> {v:a | v = (fst x)}) | f == fst }
+assume snd :: {f:(x:(a,b) -> {v:b | v = (snd x)}) | f == snd }
+
+measure fst :: (a, b) -> a
+  fst (a, b) = a
+
+measure snd :: (a, b) -> b
+  snd (a, b) = b
+
+qualif Fst(__v:a, __y:b) { __v = (fst __y) }
+qualif Snd(__v:a, __y:b) { __v = (snd __y) }
+@-}
diff --git a/src/Data/Word_LHAssumptions.hs b/src/Data/Word_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/Word_LHAssumptions.hs
@@ -0,0 +1,4 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+module Data.Word_LHAssumptions where
+
+import GHC.Word_LHAssumptions()
diff --git a/src/Foreign/C/String_LHAssumptions.hs b/src/Foreign/C/String_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Foreign/C/String_LHAssumptions.hs
@@ -0,0 +1,19 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Foreign.C.String_LHAssumptions where
+
+import Foreign.C.Types
+import Foreign.Ptr_LHAssumptions()
+import GHC.Ptr
+import GHC.Types_LHAssumptions()
+
+{-@
+type CStringLen    = ((Ptr CChar), Nat)<{\p v -> (v <= (plen p))}>
+type CStringLenN N = ((Ptr CChar), {v:Nat | v = N})<{\p v -> (v <= (plen p))}>
+
+// measure cStringLen :: CStringLen -> Int
+measure cStringLen :: ((Ptr CChar), Int) -> Int
+
+// measure cStringLen :: ((Ptr CChar), Int) -> Int
+// cStringLen (c, n) = n
+@-}
diff --git a/src/Foreign/C/Types_LHAssumptions.hs b/src/Foreign/C/Types_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Foreign/C/Types_LHAssumptions.hs
@@ -0,0 +1,14 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Foreign.C.Types_LHAssumptions where
+
+import Foreign.C.Types
+import GHC.Int_LHAssumptions()
+
+{-@
+
+embed CInt   as int
+embed CSize  as int
+embed CULong as int
+
+@-}
diff --git a/src/Foreign/Concurrent_LHAssumptions.hs b/src/Foreign/Concurrent_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Foreign/Concurrent_LHAssumptions.hs
@@ -0,0 +1,10 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Foreign.Concurrent_LHAssumptions where
+
+import Foreign.Concurrent
+import GHC.ForeignPtr_LHAssumptions()
+
+{-@
+assume newForeignPtr  :: p:(PtrV a) -> IO () -> (IO (ForeignPtrN a (plen p)))
+@-}
diff --git a/src/Foreign/ForeignPtr_LHAssumptions.hs b/src/Foreign/ForeignPtr_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Foreign/ForeignPtr_LHAssumptions.hs
@@ -0,0 +1,21 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Foreign.ForeignPtr_LHAssumptions where
+
+import Foreign.Concurrent_LHAssumptions()
+import Foreign.ForeignPtr
+import GHC.ForeignPtr
+import GHC.ForeignPtr_LHAssumptions()
+
+{-@
+
+assume withForeignPtr :: forall a b. fp:(ForeignPtr a)
+  -> ((PtrN a (fplen fp)) -> IO b)
+  -> IO b
+
+assume newForeignPtr ::  _ -> p:(PtrV a) -> (IO (ForeignPtrN a (plen p)))
+
+
+//  this uses `sizeOf (undefined :: a)`, so the ForeignPtr does not necessarily have length `n`
+//  Foreign.ForeignPtr.Imp.mallocForeignPtrArray :: (Foreign.Storable.Storable a) => n:Nat -> IO (ForeignPtrN a n)
+@-}
diff --git a/src/Foreign/Marshal/Alloc_LHAssumptions.hs b/src/Foreign/Marshal/Alloc_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Foreign/Marshal/Alloc_LHAssumptions.hs
@@ -0,0 +1,11 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Foreign.Marshal.Alloc_LHAssumptions where
+
+import GHC.Types_LHAssumptions()
+import GHC.Ptr_LHAssumptions()
+import Foreign.Marshal.Alloc
+
+{-@
+assume allocaBytes :: n:Nat -> (PtrN a n -> IO b) -> IO b
+@-}
diff --git a/src/Foreign/Ptr_LHAssumptions.hs b/src/Foreign/Ptr_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Foreign/Ptr_LHAssumptions.hs
@@ -0,0 +1,13 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Foreign.Ptr_LHAssumptions where
+
+import Foreign.Ptr
+import GHC.Ptr_LHAssumptions ()
+
+{-@
+
+invariant {v:Ptr a | 0 <= plen  v }
+invariant {v:Ptr a | 0 <= pbase v }
+
+@-}
diff --git a/src/Foreign/Storable_LHAssumptions.hs b/src/Foreign/Storable_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Foreign/Storable_LHAssumptions.hs
@@ -0,0 +1,31 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Foreign.Storable_LHAssumptions where
+
+import GHC.Ptr_LHAssumptions()
+import Foreign.Storable
+import GHC.Ptr
+
+{-@
+predicate PValid P N         = ((0 <= N) && (N < (plen P)))
+
+assume poke        :: (Storable a)
+                             => {v: (Ptr a) | 0 < (plen v)}
+                             -> a
+                             -> (IO ())
+
+assume peek        :: (Storable a)
+                             => p:{v: (Ptr a) | 0 < (plen v)}
+                             -> (IO {v:a | v = (deref p)})
+
+assume peekByteOff :: (Storable a)
+                             => forall b. p:(Ptr b)
+                             -> {v:Int | (PValid p v)}
+                             -> (IO a)
+
+assume pokeByteOff :: (Storable a)
+                             => forall b. p:(Ptr b)
+                             -> {v:Int | (PValid p v)}
+                             -> a
+                             -> IO ()
+@-}
diff --git a/src/GHC/Base_LHAssumptions.hs b/src/GHC/Base_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Base_LHAssumptions.hs
@@ -0,0 +1,64 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Base_LHAssumptions where
+
+import GHC.Base (assert)
+import GHC.CString_LHAssumptions()
+import GHC.Exts_LHAssumptions()
+import GHC.Types_LHAssumptions()
+import Data.Tuple_LHAssumptions()
+
+{-@ LIQUID "--higherorder" @-}
+{-@ reflect comp @-}
+{-@ assume reflect . as comp @-}
+comp :: (b -> c) -> (a -> b) -> a -> c
+comp f g x = f (g x)
+
+
+{-@
+
+assume . :: forall <p :: b -> c -> Bool, q :: a -> b -> Bool, r :: a -> c -> Bool>.
+                   {xcmp::a, wcmp::b<q xcmp> |- c<p wcmp> <: c<r xcmp>}
+                   (ycmp:b -> c<p ycmp>)
+                -> (zcmp:a -> b<q zcmp>)
+                ->  xcmp:a -> c<r xcmp>
+
+measure autolen :: forall a. a -> Int
+
+//  Useless as compiled into GHC primitive, which is ignored
+assume assert :: {v:Bool | v } -> a -> a
+
+instance measure len :: forall a. [a] -> Int
+  len []     = 0
+  len (y:ys) = 1 + len ys
+
+invariant {v: [a] | len v >= 0 }
+assume map       :: (a -> b) -> xs:[a] -> {v: [b] | len v == len xs}
+assume ++        :: xs:[a] -> ys:[a] -> {v:[a] | len v == len xs + len ys}
+
+assume $         :: (a -> b) -> a -> b
+define $             f          x = (f x)
+
+assume id        :: x:a -> {v:a | v = x}
+
+qualif IsEmp(v:Bool, xs: [a])  { v <=> (len xs > 0) }
+qualif IsEmp(v:Bool, xs: [a])  { v <=> (len xs = 0) }
+
+qualif ListZ(v: [a])           { len v =  0 }
+qualif ListZ(v: [a])           { len v >= 0 }
+qualif ListZ(v: [a])           { len v >  0 }
+
+qualif CmpLen(v:[a], xs:[b])   { len v  =  len xs  }
+qualif CmpLen(v:[a], xs:[b])   { len v  >= len xs  }
+qualif CmpLen(v:[a], xs:[b])   { len v  >  len xs  }
+qualif CmpLen(v:[a], xs:[b])   { len v  <= len xs  }
+qualif CmpLen(v:[a], xs:[b])   { len v  <  len xs  }
+
+qualif EqLen(v:int, xs: [a])   { v = len xs  }
+qualif LenEq(v:[a], x: int)    { x = len v  }
+
+qualif LenDiff(v:[a], x:int)   { len v  = x + 1 }
+qualif LenDiff(v:[a], x:int)   { len v  = x - 1 }
+qualif LenAcc(v:int, xs:[a], n: int) { v = len xs  + n }
+
+@-}
diff --git a/src/GHC/CString_LHAssumptions.hs b/src/GHC/CString_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/CString_LHAssumptions.hs
@@ -0,0 +1,19 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# LANGUAGE MagicHash #-}
+{-# OPTIONS_GHC -Wno-missing-signatures #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.CString_LHAssumptions() where
+
+import GHC.CString
+import GHC.Prim
+import GHC.Types_LHAssumptions()
+
+_f = unpackCString#
+
+{-@
+assume GHC.CString.unpackCString#
+  :: x:Addr#
+  -> {v:[Char] | v ~~ x && len v == strLen x}
+
+define unpackCString# x = x
+@-}
diff --git a/src/GHC/Classes_LHAssumptions.hs b/src/GHC/Classes_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Classes_LHAssumptions.hs
@@ -0,0 +1,37 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Classes_LHAssumptions where
+
+import GHC.Types_LHAssumptions()
+
+{-@
+
+assume not :: x:Bool -> {v:Bool | ((v) <=> ~(x))}
+define not    x                         = (~ x)
+
+assume &&    :: x:Bool -> y:Bool
+        -> {v:Bool | ((v) <=> ((x) && (y)))}
+assume ||    :: x:Bool -> y:Bool
+        -> {v:Bool | ((v) <=> ((x) || (y)))}
+assume ==    :: (Eq  a) => x:a -> y:a
+        -> {v:Bool | ((v) <=> x = y)}
+assume /=    :: (Eq  a) => x:a -> y:a
+        -> {v:Bool | ((v) <=> x != y)}
+assume >     :: (Ord a) => x:a -> y:a
+        -> {v:Bool | ((v) <=> x > y)}
+assume >=    :: (Ord a) => x:a -> y:a
+        -> {v:Bool | ((v) <=> x >= y)}
+assume <     :: (Ord a) => x:a -> y:a
+        -> {v:Bool | ((v) <=> x < y)}
+assume <=    :: (Ord a) => x:a -> y:a
+        -> {v:Bool | ((v) <=> x <= y)}
+
+assume compare :: (Ord a) => x:a -> y:a
+        -> {v:Ordering | (((v = EQ) <=> (x = y)) &&
+                                    ((v = LT) <=> (x < y)) &&
+                                    ((v = GT) <=> (x > y))) }
+
+assume max :: (Ord a) => x:a -> y:a -> {v:a | v = (if x > y then x else y) }
+assume min :: (Ord a) => x:a -> y:a -> {v:a | v = (if x < y then x else y) }
+
+@-}
diff --git a/src/GHC/Exts_LHAssumptions.hs b/src/GHC/Exts_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Exts_LHAssumptions.hs
@@ -0,0 +1,19 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Exts_LHAssumptions where
+
+import GHC.Base
+import GHC.Prim
+import GHC.Types_LHAssumptions()
+
+{-@
+
+assume GHC.Prim.+#  :: x:Int# -> y:Int# -> {v: Int# | v = x + y}
+assume GHC.Prim.-#  :: x:Int# -> y:Int# -> {v: Int# | v = x - y}
+assume GHC.Prim.==# :: x:Int# -> y:Int# -> {v:Int# | v = 1 <=> x = y}
+assume GHC.Prim.>=# :: x:Int# -> y:Int# -> {v:Int# | v = 1 <=> x >= y}
+assume GHC.Prim.<=# :: x:Int# -> y:Int# -> {v:Int# | v = 1 <=> x <= y}
+assume GHC.Prim.<#  :: x:Int# -> y:Int# -> {v:Int# | v = 1 <=> x < y}
+assume GHC.Prim.>#  :: x:Int# -> y:Int# -> {v:Int# | v = 1 <=> x > y}
+
+@-}
diff --git a/src/GHC/Float_LHAssumptions.hs b/src/GHC/Float_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Float_LHAssumptions.hs
@@ -0,0 +1,31 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Float_LHAssumptions(Floating(..)) where
+
+import GHC.Float
+
+{-@
+class Fractional a => Floating a where
+  pi       :: a
+  exp      :: a -> {y:a | y > 0}
+  log      :: {x:a | x > 0} -> a
+  sqrt     :: {x:a | x >= 0} -> {y:a | y >= 0}
+  (**)     :: x:a -> {y:a | x = 0 => y >= 0} -> a
+  logBase  :: {b:a | b > 0 && b /= 1} -> {x:a | x > 0} -> a
+  sin      :: a -> {y:a | -1 <= y && y <= 1}
+  cos      :: a -> {y:a | -1 <= y && y <= 1}
+  tan      :: a -> a
+  asin     :: {x:a | -1 <= x && x <= 1} -> a
+  acos     :: {x:a | -1 <= x && x <= 1} -> a
+  atan     :: a -> a
+  sinh     :: a -> a
+  cosh     :: a -> {y:a | y >= 1}
+  tanh     :: a -> {y:a | -1 < y && y < 1}
+  asinh    :: a -> a
+  acosh    :: {y:a | y >= 1} -> a
+  atanh    :: {y:a | -1 < y && y < 1} -> a
+  log1p    :: a -> a
+  expm1    :: a -> a
+  log1pexp :: a -> a
+  log1mexp :: a -> a
+@-}
diff --git a/src/GHC/ForeignPtr_LHAssumptions.hs b/src/GHC/ForeignPtr_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/ForeignPtr_LHAssumptions.hs
@@ -0,0 +1,17 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.ForeignPtr_LHAssumptions where
+
+import GHC.ForeignPtr
+import GHC.Ptr
+import GHC.Ptr_LHAssumptions()
+
+{-@
+measure fplen :: ForeignPtr a -> Int
+
+type ForeignPtrV a   = {v: ForeignPtr a | 0 <= fplen v}
+type ForeignPtrN a N = {v: ForeignPtr a | 0 <= fplen v && fplen v == N }
+
+assume newForeignPtr_ :: p:(Ptr a) -> (IO (ForeignPtrN a (plen p)))
+assume mallocPlainForeignPtrBytes :: n:{v:Int  | v >= 0 } -> (IO (ForeignPtrN a n))
+@-}
diff --git a/src/GHC/IO/Handle_LHAssumptions.hs b/src/GHC/IO/Handle_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/IO/Handle_LHAssumptions.hs
@@ -0,0 +1,18 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.IO.Handle_LHAssumptions where
+
+import GHC.IO.Handle
+import GHC.Ptr
+import GHC.Types_LHAssumptions()
+
+{-@
+assume hGetBuf :: Handle -> Ptr a -> n:Nat
+        -> (IO {v:Nat | v <= n})
+
+assume hGetBufNonBlocking :: Handle -> Ptr a -> n:Nat
+                   -> (IO {v:Nat | v <= n})
+
+assume hFileSize :: Handle
+          -> (IO {v:Integer | v >= 0})
+@-}
diff --git a/src/GHC/Int_LHAssumptions.hs b/src/GHC/Int_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Int_LHAssumptions.hs
@@ -0,0 +1,14 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Int_LHAssumptions where
+
+import GHC.Int
+
+{-@
+embed Int8  as int
+embed Int16 as int
+embed Int32 as int
+embed Int64 as int
+
+type Nat64 = {v:Int64 | v >= 0}
+@-}
diff --git a/src/GHC/List_LHAssumptions.hs b/src/GHC/List_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/List_LHAssumptions.hs
@@ -0,0 +1,70 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.List_LHAssumptions where
+
+import GHC.List
+import GHC.Types_LHAssumptions()
+import Prelude hiding (foldr1, length, null)
+
+{-@
+assume head         :: xs:{v: [a] | len v > 0} -> {v:a | v = head xs}
+assume tail         :: xs:{v: [a] | len v > 0} -> {v: [a] | len(v) = (len(xs) - 1) && v = tail xs}
+
+assume last         :: xs:{v: [a] | len v > 0} -> a
+assume init         :: xs:{v: [a] | len v > 0} -> {v: [a] | len(v) = len(xs) - 1}
+assume null         :: xs:[a] -> {v: Bool | ((v) <=> len(xs) = 0) }
+assume length       :: xs:[a] -> {v: Int | v = len(xs)}
+assume filter       :: (a -> Bool) -> xs:[a] -> {v: [a] | len(v) <= len(xs)}
+assume scanl        :: (a -> b -> a) -> a -> xs:[b] -> {v: [a] | len(v) = 1 + len(xs) }
+assume scanl1       :: (a -> a -> a) -> xs:{v: [a] | len(v) > 0} -> {v: [a] | len(v) = len(xs) }
+assume foldr1       :: (a -> a -> a) -> xs:{v: [a] | len(v) > 0} -> a
+assume scanr        :: (a -> b -> b) -> b -> xs:[a] -> {v: [b] | len(v) = 1 + len(xs) }
+assume scanr1       :: (a -> a -> a) -> xs:{v: [a] | len(v) > 0} -> {v: [a] | len(v) = len(xs) }
+
+lazy iterate
+assume iterate :: (a -> a) -> a -> [a]
+
+assume repeat :: a -> [a]
+lazy repeat
+
+assume replicate    :: n:Nat -> x:a -> {v: [{v:a | v = x}] | len(v) = n}
+
+assume cycle        :: {v: [a] | len(v) > 0 } -> [a]
+lazy cycle
+
+assume takeWhile    :: (a -> Bool) -> xs:[a] -> {v: [a] | len(v) <= len(xs)}
+assume dropWhile    :: (a -> Bool) -> xs:[a] -> {v: [a] | len(v) <= len(xs)}
+
+assume take :: n:Int
+     -> xs:[a]
+     -> {v:[a] | if n >= 0 then (len v = (if (len xs) < n then (len xs) else n)) else (len v = 0)}
+assume drop :: n:Int
+     -> xs:[a]
+     -> {v:[a] | (if (n >= 0) then (len(v) = (if (len(xs) < n) then 0 else len(xs) - n)) else ((len v) = (len xs)))}
+
+assume splitAt :: n:_ -> x:[a] -> ({v:[a] | (if (n >= 0) then (if (len x) < n then (len v) = (len x) else (len v) = n) else ((len v) = 0))},[a])<{\x1 x2 -> (len x2) = (len x) - (len x1)}>
+assume span    :: (a -> Bool)
+        -> xs:[a]
+        -> ({v:[a]|((len v)<=(len xs))}, {v:[a]|((len v)<=(len xs))})
+
+assume break :: (a -> Bool) -> xs:[a] -> ([a],[a])<{\x y -> (len xs) = (len x) + (len y)}>
+
+assume reverse      :: xs:[a] -> {v: [a] | len(v) = len(xs)}
+
+//  Copy-pasted from len.hquals
+qualif LenSum(v:[a], xs:[b], ys:[c]) { len([v]) = (len([xs]) + len([ys])) }
+qualif LenSum(v:[a], xs:[b], ys:[c]) { len([v]) = (len([xs]) - len([ys])) }
+
+assume !! :: xs:[a] -> {v: _ | ((0 <= v) && (v < len(xs)))} -> a
+
+
+assume zip :: xs : [a] -> ys:[b]
+            -> {v : [(a, b)] | ((((len v) <= (len xs)) && ((len v) <= (len ys)))
+            && (((len xs) = (len ys)) => ((len v) = (len xs))) )}
+
+assume zipWith :: (a -> b -> c)
+        -> xs : [a] -> ys:[b]
+        -> {v : [c] | (((len v) <= (len xs)) && ((len v) <= (len ys)))}
+
+assume errorEmptyList :: {v: _ | false} -> a
+@-}
diff --git a/src/GHC/Maybe_LHAssumptions.hs b/src/GHC/Maybe_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Maybe_LHAssumptions.hs
@@ -0,0 +1,6 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+module GHC.Maybe_LHAssumptions where
+
+{-@
+data Maybe a = Nothing | Just a
+@-}
diff --git a/src/GHC/Num/Integer_LHAssumptions.hs b/src/GHC/Num/Integer_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Num/Integer_LHAssumptions.hs
@@ -0,0 +1,16 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# LANGUAGE MagicHash #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Num.Integer_LHAssumptions() where
+
+import GHC.Prim
+import GHC.Num
+import GHC.Types_LHAssumptions()
+
+{-@
+assume IS :: x:Int# -> {v: Integer | v = (x :: int) }
+
+define IS x = (x)
+
+embed Integer as int
+@-}
diff --git a/src/GHC/Num_LHAssumptions.hs b/src/GHC/Num_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Num_LHAssumptions.hs
@@ -0,0 +1,21 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Num_LHAssumptions where
+
+import GHC.Num
+import GHC.Num.Integer_LHAssumptions()
+
+{-@
+assume fromInteger :: x:Integer -> {v:a | v = x }
+
+assume negate :: (Num a)
+               => x:a
+               -> {v:a | v = -x}
+
+assume abs :: (Num a) => x:a -> {y:a | (x >= 0 ==> y = x) && (x < 0 ==> y = -x) }
+
+define abs x = if x >=0 then x else -x
+
+assume + :: x:a -> y:a -> {v:a | v = x + y }
+assume - :: (Num a) => x:a -> y:a -> {v:a | v = x - y }
+@-}
diff --git a/src/GHC/Ptr_LHAssumptions.hs b/src/GHC/Ptr_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Ptr_LHAssumptions.hs
@@ -0,0 +1,27 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Ptr_LHAssumptions where
+
+import GHC.Ptr
+import GHC.Types_LHAssumptions()
+
+{-@
+measure pbase     :: Ptr a -> Int
+measure plen      :: Ptr a -> Int
+measure isNullPtr :: Ptr a -> Bool
+
+type PtrN a N = {v: PtrV a        | plen v == N }
+type PtrV a   = {v: Ptr a | 0 <= plen v }
+
+assume castPtr :: p:(PtrV a) -> (PtrN b (plen p))
+
+assume plusPtr :: base:(PtrV a)
+                -> off:{v:Int | v <= plen base }
+                -> {v:(PtrV b) | pbase v = pbase base && plen v = plen base - off}
+
+assume minusPtr :: q:(PtrV a)
+                 -> p:{v:(PtrV b) | pbase v == pbase q && plen v >= plen q}
+                 -> {v:Nat | v == plen p - plen q}
+
+measure deref     :: Ptr a -> a
+@-}
diff --git a/src/GHC/Real_LHAssumptions.hs b/src/GHC/Real_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Real_LHAssumptions.hs
@@ -0,0 +1,61 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+-- Reexports are necessary for LH to expose specs of type classes
+module GHC.Real_LHAssumptions(Integral(..), Fractional(..)) where
+
+import GHC.Real
+import GHC.Types_LHAssumptions()
+import GHC.Num_LHAssumptions()
+
+{-@
+assume (^) :: x:a -> y:{n:b | n >= 0} -> {z:a | (y == 0 => z == 1) && ((x == 0 && y /= 0) <=> z == 0)}
+
+assume fromIntegral    :: x:a -> {v:b|v=x}
+
+class Num a => Fractional a where
+  (/)   :: x:a -> y:{v:a | v /= 0} -> {v:a | v == x / y}
+  recip :: a -> a
+  fromRational :: Ratio Integer -> a
+
+class (Real a, Enum a) => Integral a where
+  quot :: x:a -> y:{v:a | v /= 0} -> {v:a | (v = (x / y)) &&
+                                                     ((x >= 0 && y >= 0) => v >= 0) &&
+                                                     ((x >= 0 && y >= 1) => v <= x) }
+  rem :: x:a -> y:{v:a | v /= 0} -> {v:a | ((v >= 0) && (v < y))}
+  mod :: x:a -> y:{v:a | v /= 0} -> {v:a | v = x mod y && ((0 <= x && 0 < y) => (0 <= v && v < y))}
+
+  div :: x:a -> y:{v:a | v /= 0} -> {v:a | (v = div x y) &&
+                                                    ((x >= 0 && y >= 0) => v >= 0) &&
+                                                    ((x >= 0 && y >= 1) => v <= x) &&
+                                                    ((1 < y && x >= 0)  => v < x) &&
+                                                    ((1 < y && x < 0)   => v > x) &&
+                                                    ((y >= 1 && x >= 0)  => v <= x) &&
+                                                    ((x < 0 && y > 0)   => v <= 0) &&
+                                                    ((x > 0 && y < 0)   => v <= 0) &&
+                                                    ((x < 0 && y < 0)   => v >= 0)
+                                                    }
+  quotRem :: x:a -> y:{v:a | v /= 0} -> ( {v:a | (v = (x / y)) &&
+                                                          ((x >= 0 && y >= 0) => v >= 0) &&
+                                                          ((x >= 0 && y >= 1) => v <= x)}
+                                                 , {v:a | ((v >= 0) && (v < y))})
+  divMod :: x:a -> y:{v:a | v /= 0} -> ( {v:a | (v = (x / y)) &&
+                                                         ((x >= 0 && y >= 0) => v >= 0) &&
+                                                         ((x >= 0 && y >= 1) => v <= x) }
+                                                , {v:a | v = x mod y && ((0 <= x && 0 < y) => (0 <= v && v < y))}
+                                                )
+  toInteger :: x:a -> {v:Integer | v = x}
+
+//  fixpoint can't handle (x mod y), only (x mod c) so we need to be more clever here
+//  mod :: x:a -> y:a -> {v:a | v = (x mod y) }
+
+define div x y        = (x / y)
+define mod x y        = (x mod y)
+define quot x y =  if x >= 0
+                   then (if y >= 0 then x / y else -(x / abs y))
+                   else -(abs x / y)
+define rem x y = if x >= 0
+                 then (if y >= 0 then x mod y else x mod (abs y))
+                 else - ((abs x) mod y)
+define fromIntegral x = (x)
+
+@-}
diff --git a/src/GHC/Types_LHAssumptions.hs b/src/GHC/Types_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Types_LHAssumptions.hs
@@ -0,0 +1,58 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# LANGUAGE MagicHash #-}
+{-# OPTIONS_GHC -Wno-missing-signatures #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Types_LHAssumptions() where
+
+import GHC.Prim
+import GHC.Types
+
+-- This definition is needed to make the listed data constructors
+-- visible to LH
+_f = (D#, F#, W#)
+
+{-@
+//  Boxed types
+embed Double  as real
+embed Double#  as real
+embed Float   as real
+embed Float#   as real
+embed Word    as int
+embed Word#    as int
+embed Word64#  as int
+embed Int     as int
+embed Int#     as int
+embed Char    as Char
+embed Char#    as Char
+embed Addr#    as Str
+embed ByteArray# as int
+
+embed Integer as int
+
+assume True    :: {v:Bool | v     }
+assume False   :: {v:Bool | (~ v) }
+assume GHC.Types.isTrue# :: n:_ -> {v:Bool | (n = 1 <=> v)}
+
+define True = (true)
+
+assume GHC.Types.D# :: x:Double# -> {v: Double | v = (x :: real) }
+assume GHC.Types.F# :: x:Float# -> {v: Float | v = (x :: real) }
+assume GHC.Types.I# :: x:Int# -> {v: Int | v = (x :: int) }
+assume GHC.Types.C# :: x:Char# -> {v: Char | v = (x :: Char) }
+assume GHC.Types.W# :: w:Word# -> {v:Word | v == w }
+
+measure addrLen :: GHC.Prim.Addr# -> Int
+
+type GeInt N = {v: Int | v >= N }
+type LeInt N = {v: Int | v <= N }
+type Nat     = {v: Int | v >= 0 }
+type Even    = {v: Int | (v mod 2) = 0 }
+type Odd     = {v: Int | (v mod 2) = 1 }
+type BNat N  = {v: Nat           | v <= N }
+type TT      = {v: Bool | v}
+type FF      = {v: Bool | not v}
+type String  = [Char]
+
+class measure len :: forall f a. f a -> Int
+
+@-}
diff --git a/src/GHC/Word_LHAssumptions.hs b/src/GHC/Word_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/GHC/Word_LHAssumptions.hs
@@ -0,0 +1,16 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module GHC.Word_LHAssumptions where
+
+import GHC.Word
+
+{-@
+embed Word   as int
+embed Word8  as int
+embed Word16 as int
+embed Word32 as int
+embed Word64 as int
+
+invariant {v : Word32 | 0 <= v }
+invariant {v : Word16 | 0 <= v }
+@-}
diff --git a/src/Gradual/Concretize.hs b/src/Gradual/Concretize.hs
deleted file mode 100644
--- a/src/Gradual/Concretize.hs
+++ /dev/null
@@ -1,85 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances  #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE TupleSections         #-}
-
-module Gradual.Concretize (Gradual(..)) where
-
-import Gradual.Types 
-import Language.Fixpoint.Types
-import Gradual.Misc
-
-import qualified Data.HashMap.Strict       as M
--- import Debug.Trace 
-
-class Gradual a where
-  concretize :: GMap GWInfo -> a -> [(GSub GWInfo, a)]
-  concretize _ x = [(mempty, x)]
-
-instance Gradual (SInfo a) where
-  concretize i sinfo = (\su -> (su,
-     sinfo {bs = gsubst (bs sinfo,su) (bs sinfo), cm = gsubst (bs sinfo,su) (cm sinfo)} 
-    )) <$> (M.fromList <$> flatten (M.toList i))
-
-
-class GSubable a where
-  gsubst :: (BindEnv, GSub GWInfo) -> a -> a 
-  gsubst _ x = x 
-
-instance GSubable BindEnv where
-  gsubst i benv = bindEnvFromList (mapThd3 (gsubst i) <$> bindEnvToList benv)
-
-instance GSubable (SimpC a) where
-  gsubst (benv,i) c = c {_crhs = substGrad x i (_crhs c)}
-    where
-      x = fst $ lookupBindEnv (cbind c) benv
-
-instance (GSubable v) => GSubable (M.HashMap SubcId v) where
-  gsubst i m = M.map (gsubst i) m
-
-instance GSubable SortedReft where
-  gsubst i (RR s r) = RR s $ gsubst i r 
-
-instance GSubable Reft where
-  gsubst (_,i) (Reft (x,p)) = Reft . (x,) $ substGrad x i p
-
--- instance GSubable Expr where
---   gsubst i p = substGrad dummySymbol i p
-
-substGrad :: Symbol -> GSub GWInfo -> Expr -> Expr
-substGrad x m (PGrad k su _ e) 
-  = case M.lookup k m of 
-      Just (i, ek) -> pAnd [subst su $ subst1 ek (gsym i, EVar x), e] 
-                      -- in trace ("SUBSTITUTED: STATIC = " ++ showFix e ++ 
-                      --           "\t GRADUAL = " ++ showFix ee ++
-                      --           "\t INIT = " ++ showFix ek) ee
-      Nothing      -> PTrue  
-substGrad x m (PAnd es)        
-  = PAnd (substGrad x m <$> es)
-substGrad _ _ e
-  = e 
-
-
-{- 
-instance Gradual i Expr where
-  concretize i (PGrad k su _ _) = subst su <$> (snd $ M.lookupDefault err k i) 
-    where
-      err = (undefined, [PTrue]) -- error ("Gradual Not found: " ++ show k)
-  concretize i (PAnd ps) = PAnd <$> expand (concretize i) ps 
-  concretize _ p = [p]
-
-
-instance Gradual i BindEnv where
-  concretize i benv = bindEnvFromList <$> expand3 (concretize i) (bindEnvToList benv)
-
-instance Fixpoint a => Gradual i (SimpC a) where
-  concretize i c = [c{_crhs = rhs} | rhs <- concretize i (_crhs c)]
-
-instance (Gradual i v) => Gradual i (M.HashMap SubcId v) where
-  concretize i m = M.fromList <$> expand2 (concretize i) (M.toList m)
-
-instance Gradual i SortedReft where
-  concretize i (RR s r) = RR s <$> concretize i r 
-
-instance Gradual i Reft where
-  concretize i (Reft (x,e)) = (Reft . (x,)) <$> concretize i e  
--}
diff --git a/src/Gradual/GUI.hs b/src/Gradual/GUI.hs
deleted file mode 100644
--- a/src/Gradual/GUI.hs
+++ /dev/null
@@ -1,70 +0,0 @@
-module Gradual.GUI (render) where
-
-import Language.Haskell.Liquid.UX.Annotate (tokeniseWithLoc)
-import Language.Fixpoint.Types (KVar, Expr)
-import Language.Fixpoint.Utils.Files
-
-import Gradual.Types 
-import Gradual.PrettyPrinting 
-import Gradual.GUI.Annotate 
-import Gradual.GUI.Types 
-import Gradual.GUI.Misc 
-
-import qualified Data.HashMap.Strict as M
-
-render :: GConfig -> GSpan -> [[GSub a]] -> IO () 
-render cfg gspan sols = do 
-  tokens <- tokeniseWithLoc <$> readFile (gtarget cfg)
-  let fname = makeFileName cfg
-  let sol1  = mconcat (head <$> sols)
-  let deps  = gSpanToDeps sol1 gspan
-  let pkeys = makePKeys sols 
-  let src   = initSrc deps pkeys sols 
-  writeFile fname $! (renderHtml fname src tokens deps)
-  putStrLn ("Output written in " ++ fname)
-
-makeFileName :: GConfig -> String 
-makeFileName cfg = extFileName Html $ gtarget cfg
-
-
-initSrc :: Dependencies v -> PKeys -> [[GSub a]] -> String 
-initSrc deps pkeys sols = unlines
-  [ initDependents kmap 
-  , initValues sols pkeys
-  , initCurrentstatus pkeys
-  , initDepzise deps 
-  ]
-  where
-    kmap = map (kVarId deps) <$> pkeys
-
-initValues :: [[GSub a]] -> PKeys -> String 
-initValues sols pkeys = script $ concat $ zipWith go pkeys sols
-  where
-   go :: [KVar] -> [GSub a] -> String 
-   go keys sols = "values.push(" ++ show (go' keys <$> sols) ++ ");\n"
-
-   go' :: [KVar] -> GSub a -> [String] 
-   go' keys sol = map (\k -> renderSol $ M.lookup k sol) keys 
-
-   renderSol :: Maybe (a, Expr) -> String 
-   renderSol Nothing  = "NA"
-   renderSol (Just e) = pretty $ snd e
-
-initDependents :: [[(Int,Int)]] -> String
-initDependents xs = script $ concatMap go xs
-  where
-    go is = "dependents.push(" ++ "[" 
-              ++ concat [ "'content-" ++ show i ++ "-" ++ show j ++ "'" | (i,j)<-is] 
-              ++ "]" ++ ");\n"
-
-initCurrentstatus :: [a] -> String
-initCurrentstatus ps = script $ 
-  concat (replicate (length ps) "currentstatus.push(0);\n") 
-
-
-initDepzise ::  Dependencies v -> String
-initDepzise deps = script $
-  concatMap (\i -> "depzise.push(" ++ show i ++ ");\n") ns 
-  where
-    ns = map (length . snd) deps
-
diff --git a/src/Gradual/GUI/Annotate.hs b/src/Gradual/GUI/Annotate.hs
deleted file mode 100644
--- a/src/Gradual/GUI/Annotate.hs
+++ /dev/null
@@ -1,155 +0,0 @@
-module Gradual.GUI.Annotate (renderHtml) where 
-
-import Language.Haskell.Liquid.GHC.Misc   (Loc(..))
-import Language.Fixpoint.Misc (thd3)
-import Language.Fixpoint.Types.Spans hiding (Loc)
-
--- import GHC                     ( SrcSpan (..)
---                                           , srcSpanStartCol, srcSpanEndCol, srcSpanStartLine, srcSpanEndLine)
-import qualified Language.Haskell.HsColour.CSS as CSS
-
-
-import Gradual.GUI.Types 
-
-import qualified Data.List as L
-
-pretag :: String
-pretag = "<div class='dropdown'><span class='dropbtn'>"
-
-
-posttag :: Int -> Int -> String -> String 
-posttag i j val
-  = "</span><div class='dropdown-content' name='select-" ++ show i ++ "-" ++ show j ++ "' id='select-" ++ show i ++ "-" ++ show j ++ "'>"
-  ++ "<button type='button' onclick=\"showPrev("++ name ++ ")\"> << </button>" 
-  ++ "<div id=" ++ name ++ ">"
-  ++ val
-  ++ "</div>" 
-  ++ "<button type='button' onclick=\"showNext("++ name ++ ")\"> >> </button>" 
-  -- ++ "undefined"
-  ++ "</div>"
-  ++ "</div>"
-  where
-    name = "'content-" ++ show i ++ "-" ++ show j ++ "'"
-
-
-tag :: Loc -> [(String, Loc)] -> (Int, Int, SrcSpan, String) -> [(String, Loc)]
-tag eof toks (i, j, sp, v) = go False toks 
-  where
-    go True [] = [("</span>"++ posttag i j v, eof)]
-    go _    [] = []
-    go b    ((s,l):rest)
-      | l `inLoc` sp, not b 
-      = (pretag ++ "<span class='"++ sourceName i++ "'>" ++ s , l):go True rest 
-      | not (l `inLoc` sp), b 
-      = ("</span>"++ posttag i j v ++ s, l):rest 
-      | otherwise 
-      = (s,l):go b rest 
-
-_highlight :: String -> Loc -> [(String, Loc)] -> SrcSpan -> [(String, Loc)] 
-_highlight color eof toks sp = go False toks 
-  where
-    go True [] = [("</span>", eof)]
-    go _    [] = []
-    go b    ((s,l):rest)
-      | l `inLoc` sp, not b 
-      = ("<span id=\"background-color: " ++ color ++ "\">" ++s, l):go True rest 
-      | not (l `inLoc` sp), b 
-      = ("</span>" ++ s, l):rest 
-      | otherwise 
-      = (s,l):go b rest 
-
-inLoc :: Loc -> SrcSpan -> Bool 
-inLoc l (SS start end) 
-  = L (sline, scol) <= l && l <= L (eline, ecol)
-  where
-    (_,sline, scol) = sourcePosElts start
-    (_,eline, ecol) = sourcePosElts end
-
-
-renderHtml :: FilePath -> String -> LocTokens -> SDeps -> String 
-renderHtml html initSrc tokens deps 
-  = topAndTail initSrc html $! body
-  where 
-    eof  = thd3 $ last tokens
-    body = formButton 1 $ CSS.pre $ concat $ map fst taggedTokens
-    taggedTokens = foldl (tag eof) 
-                      [(CSS.renderToken (x, y), z) | (x,y,z) <- tokens] 
-                      (srcDeps deps)
-
-formButton :: Int -> String -> String 
-formButton i str@(_:_:rest) 
-  | L.isPrefixOf "??" str
-  = bform i ++ formButton (i+1) rest
-formButton i (x:rest)
-  = x:formButton i rest
-formButton _ []
-  = []  
-
-
-
-classbuttonName :: Int -> String 
-classbuttonName i = "classbutton-" ++ show i 
-
-
-sourceName :: Int -> String 
-sourceName i = "src-" ++ show i 
-
-bform :: Int -> String
-bform i = 
-  "<button type='button' id='button-" ++ show i ++ 
-  "' onclick='gradualClick("++ show i ++ ")'" ++ 
-  " class='" ++ classbuttonName i ++ "'>??</button>"
-
-
-topAndTail :: String -> String -> String -> String
-topAndTail initSrc title body = htmlHeader initSrc title ++ body ++ htmlClose
-
-
--- ATTENTION: these colors should match with ones in util.js
--- TODO: use spec
-colours :: [(Int, String)]
-colours = 
-  [ (1, "#E59EFF")
-  , (2, "#FF9EE9")
-  , (3, "#FF9EB8")
-  , (4, "#FFB49E")
-  , (5, "#FFE59E")
-  , (6, "#E9FF9E")]
-
-bottonsCss :: String 
-bottonsCss = concatMap bottonCss colours 
-
-bottonCss :: (Int, String) -> String 
-bottonCss (i, color)= unlines 
-  [ "<style>"
-  , "." ++ classbuttonName i ++ "{"
-  , "background-color: " ++ color ++ ";"
-  , "cursor: pointer;"
-  , "type: button;}"
-  , ""
-  , "." ++ sourceName i ++ "{"
-  , "background-color: #f0f0f0;}"
-  , "</style>"
-  ]
-
-htmlHeader :: String -> String -> String
-htmlHeader initSrc title = unlines
-  [ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">"
-  , "<html>"
-  , "<head>"
-  , "<title>" ++ title ++ "</title>"
-  , "</head>"
-  , "<style type='text/css'>"
-  , " form {display:inline; margin:0px; padding:0px; }"
-  , "</style>"
-  , "<script src='http://goto.ucsd.edu/~nvazou/gradual/util.js'></script>"
-  , initSrc
-  , "<link type='text/css' rel='stylesheet' href='http://goto.ucsd.edu/~nvazou/gradual/liquid.css' />"
-  , bottonsCss
-  , "<body>"
-  , "<hr>"
-  , "Interactive Solution based on Gradual Typing"
-  ]
-
-htmlClose :: String
-htmlClose  = "\n</body>\n</html>"  
diff --git a/src/Gradual/GUI/Misc.hs b/src/Gradual/GUI/Misc.hs
deleted file mode 100644
--- a/src/Gradual/GUI/Misc.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module Gradual.GUI.Misc where 
-
-script :: String -> String
-script src = "<script>" ++ src ++ "</script>\n"
diff --git a/src/Gradual/GUI/Types.hs b/src/Gradual/GUI/Types.hs
deleted file mode 100644
--- a/src/Gradual/GUI/Types.hs
+++ /dev/null
@@ -1,71 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-
-module Gradual.GUI.Types where
-
-import Language.Haskell.HsColour.Classify (TokenType)
-import Language.Haskell.Liquid.GHC.Misc   (Loc(..))
-
-import qualified Data.HashMap.Strict       as M
-import Language.Fixpoint.Types.Refinements hiding (L)
-import Language.Fixpoint.Types.Spans hiding (Loc(..))
-import Language.Fixpoint.Types (symbolString, Symbol) 
-import qualified Data.List as L 
-import qualified Data.Char as C 
-import Data.Maybe (fromJust, fromMaybe)
-
-
-import Gradual.Types 
-import Gradual.PrettyPrinting 
-
-
-data Unique  = Unique {uId :: Int, uLoc :: SrcSpan, uName :: Symbol} 
-type LocTokens = [(TokenType, String, Loc)]
-type Deps      = Dependencies () --  [(Int, [SrcSpan])] 
-type SDeps     = Dependencies String
-type Dependencies val = [(Unique, [(Unique,val)])]
-type PKeys    = [[KVar]]
-
-makePKeys :: [[GSub a]] -> PKeys 
-makePKeys sols = M.keys <$> head <$> sols
-
-instance Show Unique where
-  show u = show (uLoc u)
-
-kVarId :: Dependencies v -> KVar -> (Int, Int)
-kVarId deps k = fromMaybe (0,0) $ L.lookup (kv k) 
-                  [(uName x,(uId ui, uId x)) | (ui, xs) <- deps, (x,_) <- xs]
-
-srcDeps :: Dependencies v -> [(Int, Int, SrcSpan, v)]
-srcDeps deps = [(uId ui, uId x, uLoc x, v) | (ui, xs) <- deps , (x,v) <- xs]
-
-
-gSpanToDeps :: GSub a -> GSpan -> SDeps 
-gSpanToDeps sol gm = [(Unique i (kVarSpan $ kv k) (kv k), mapValues ks) 
-                        | ((k,ks),i) <- zip gml [1..]] 
-  where
-    mapValues ks = [(Unique i s $ kv k, lookSol k) | ((k,Just s), i) <- zip ks [1..]]
-    gml          = L.sortBy (\(k1,_) (k2,_) -> compare (kVarSpan $ kv k1) (kVarSpan $ kv k2)) 
-                            $ M.toList gm
-    lookSol k    = fromMaybe "NA" (pretty . snd <$> M.lookup k sol) 
-
-
-
-kVarSpan :: Symbol -> SrcSpan
-kVarSpan k = SS lc lc
-  where
-    L (l, c) = symbolLoc k
-    fn  = takeFileName $ symbolString k
-    lc = toSourcePos (fn, l, c) 
-
-takeFileName :: String -> String 
-takeFileName ('$':xs) = takeWhile (/= ' ') xs 
-takeFileName _ = ""
-
-symbolLoc :: Symbol -> Loc
-symbolLoc x = L (read line, read col)
-  where
-    (line, rest) = spanAfter C.isDigit "line " (symbolString x)
-    (col, _)     = spanAfter C.isDigit "column " rest
-    spanAfter p str input = L.span p $ fromJust $ L.stripPrefix str $ 
-                             head  $ filter (L.isPrefixOf str) $ L.tails input
diff --git a/src/Gradual/Misc.hs b/src/Gradual/Misc.hs
deleted file mode 100644
--- a/src/Gradual/Misc.hs
+++ /dev/null
@@ -1,69 +0,0 @@
-{-# LANGUAGE TupleSections         #-}
-
-module Gradual.Misc where 
-
-import Control.Monad (filterM)
-
--------------------------------------------------------------------------------
--- | Mapping ------------------------------------------------------------------
--------------------------------------------------------------------------------
-
-mapThd3 :: (c -> d) -> (a, b, c) -> (a, b, d)
-mapThd3 f (x, y, z) = (x, y, f z)
-
-mapSndM :: Functor m => (b -> m c) -> (a,b) -> m (a, c)
-mapSndM f (x,y) = (x,) <$> f y
-
-
-mapMWithLog :: String -> (a -> IO b) -> [a] -> IO [b]
-mapMWithLog msg f xs = go 1 xs 
-  where
-    n = length xs 
-
-    go _ [] = return []
-    go i (x:xs) = do 
-      putStrLn (msg ++ " [" ++ show i ++ "/" ++ show n ++ "]...") 
-      r  <- f x 
-      rs <- go (i+1) xs 
-      return (r:rs)
-
--------------------------------------------------------------------------------
--- | Powersets ----------------------------------------------------------------
--------------------------------------------------------------------------------
-
-powersetUpTo :: Int -> [a] -> [[a]]
-powersetUpTo 0 _  = [] 
-powersetUpTo 1 xs = (:[]) <$> xs
-powersetUpTo i xs = filter ((i >=) . length) $ filterM (const [False, True]) xs
-
--------------------------------------------------------------------------------
--- | Combining ----------------------------------------------------------------
--------------------------------------------------------------------------------
-
-
-flatten :: [(k,(i,[v]))] -> [[(k,(i, v))]]
-flatten kvs = allCombinations ((\(k,(i,vs)) -> ((k,) . (i,)) <$> vs)<$> kvs)
-
-expand :: (a -> [a]) -> [a] -> [[a]]
-expand f xs = allCombinations (f <$> xs)
-
-expand2 :: (b -> [b]) -> [(a, b)] -> [[(a,b)]]
-expand2 f xs = zip x1s <$> allCombinations x2s
-  where
-    (x1s,x2s) = unzip ((\(x,y) -> (x,f y)) <$> xs)
-
-expand3 :: (c -> [c]) -> [(a,b,c)] -> [[(a,b,c)]]
-expand3 f xs = zip3 x1s x2s <$> allCombinations x3s
-  where
-    (x1s,x2s,x3s) = unzip3 ((\(x,y,z) -> (x,y,f z)) <$> xs)
-
-{-@ allCombinations :: xss:[[a]] -> [{v:[a]| len v == len xss}] @-}
-allCombinations :: [[a]] -> [[a]]
-allCombinations xs = assert (and . map (((length xs) == ) . length)) $ go xs
-  where
-   go []          = [[]]
-   go [[]]        = []
-   go ([]:_)      = []
-   go ((x:xs):ys) = ((x:) <$> go ys) ++ go (xs:ys)
-
-   assert b x = if b x then x else error "allCombinations: assertion violation"
diff --git a/src/Gradual/PrettyPrinting.hs b/src/Gradual/PrettyPrinting.hs
deleted file mode 100644
--- a/src/Gradual/PrettyPrinting.hs
+++ /dev/null
@@ -1,49 +0,0 @@
-module Gradual.PrettyPrinting where
-
-import Language.Fixpoint.Types
-import Language.Haskell.Liquid.GHC.Misc
-
-
-class Pretty a where
-  pretty :: a -> String 
-
-instance Pretty Expr where
-  pretty = showpp . simplifyExpr 
-
-instance Pretty KVar where
-  pretty (KV x) = pretty x  
-
-instance Pretty Symbol where
-  pretty = show . dropModuleNames. tidySymbol
-
-instance (Pretty a, Pretty b) => Pretty (a, b) where 
-  pretty (x,y) = pretty x ++ " |-> " ++ pretty y 
-
-instance (Pretty a) => Pretty [a] where 
-  pretty xs = unlines $ map pretty xs 
-
-simplifyExpr :: Expr -> Expr
-simplifyExpr = go 
-  where
-    go (ECst e _)   = go e
-    go (EApp e1 e2) 
-      | EVar x <- go e1 
-      , x `elem` [applyName, toIntName, setToIntName, bitVecToIntName, mapToIntName, realToIntName] 
-      = go e2 
-    go (EApp e1 e2)
-      = EApp (go e1) (go e2)
-    go (ENeg e)     = ENeg (go e)
-    go (EBin b e1 e2) = EBin b (go e1) (go e2)
-    go (EIte e e1 e2) = EIte (go e) (go e1) (go e2)
-    go (PAnd es)      = PAnd (go <$> es)
-    go (POr es)       = POr (go <$> es)
-    go (PNot e)       = PNot (go e)
-    go (PImp e1 e2)   = PImp (go e1) (go e2)
-    go (PIff e1 e2)   = PIff (go e1) (go e2)
-    go (PAtom a e1 e2) = PAtom a  (go e1) (go e2)
-    go (PAll a e) = PAll a (go e)
-    go (PExist a e) = PExist a (go e)
-    go (ETApp e a) = ETApp (go e) a
-    go (ELam a e) = ELam a (go e)
-    go (EVar x)   = EVar (dropModuleNames $ tidySymbol x)
-    go e            = e 
diff --git a/src/Gradual/Refinements.hs b/src/Gradual/Refinements.hs
deleted file mode 100644
--- a/src/Gradual/Refinements.hs
+++ /dev/null
@@ -1,66 +0,0 @@
-module Gradual.Refinements (makeGMap) where
-
-import Gradual.Types
-import Gradual.Misc 
--- import Gradual.PrettyPrinting
-
-import Language.Fixpoint.Types
-import Language.Fixpoint.Types.Config
-import Language.Fixpoint.Solver.Monad
-import Language.Fixpoint.Solver.Solve (solverInfo)
-import Language.Fixpoint.Utils.Files 
-import Language.Fixpoint.SortCheck (exprSort_maybe)
-
-
-import Control.Monad (filterM)
--- import Control.Monad.IO.Class
-
-makeGMap :: GConfig -> Config -> SInfo a -> [(KVar, (GWInfo, [Expr]))] -> IO (GMap GWInfo)
-makeGMap gcfg cfg sinfo mes = toGMap <$> runSolverM cfg' sI act 
-  where
-    sI   = solverInfo cfg' sinfo
-    act  = mapM (concretize gcfg) mes
-    cfg' = cfg { srcFile = srcFile cfg `withExt` Pred 
-               , gradual = True -- disable mbqi
-           }
-
-concretize :: GConfig -> (KVar, (GWInfo, [Expr])) -> SolveM (KVar, (GWInfo,[Expr]))
-concretize cfg (kv, (info, es))
-  = (\es' -> (kv,(info,es'))) <$> 
-     filterM (isGoodInstance info) 
-             (PTrue:(pAnd <$> powersetUpTo (depth cfg) es))
-
-isGoodInstance :: GWInfo -> Expr -> SolveM Bool 
-isGoodInstance info e 
-  | isSensible e -- heuristic to delete stupit instantiations
-  = (&&) <$> (isLocal info e) <*> (isMoreSpecific info e) 
-  | otherwise 
-  = return False 
-
-isSensible :: Expr -> Bool 
-isSensible (PIff _ (PAtom _ e1 e2))
-  | e1 == e2 
-  = False 
-isSensible (PAtom cmp e _)
-  | cmp `elem` [Gt,Ge,Lt,Le]
-  , Just s <- exprSort_maybe e 
-  , boolSort == s
-  = False 
-isSensible _ 
-  = True 
-
-isLocal :: GWInfo -> Expr -> SolveM Bool 
-isLocal i e = isValid (PExist [(gsym i, gsort i)] e)
-
-isMoreSpecific :: GWInfo -> Expr -> SolveM Bool
-isMoreSpecific i e = isValid (pAnd [e, gexpr i] `PImp` gexpr i)
-
-
-isValid :: Expr -> SolveM Bool
-isValid e 
-  | isContraPred e = return False 
-  | isTautoPred  e = return True 
-  | PImp (PAnd es) e2 <- e 
-  , e2 `elem` es    = return True    
-isValid e = not <$> checkSat (PNot e)
-
diff --git a/src/Gradual/Trivial.hs b/src/Gradual/Trivial.hs
deleted file mode 100644
--- a/src/Gradual/Trivial.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Gradual.Trivial (simplify) where
-
-import Language.Fixpoint.Types  hiding (simplify)
-import qualified Data.HashMap.Strict       as M
-
-
-simplify :: SInfo a -> SInfo a 
-simplify sinfo = sinfo {cm = M.map f (cm sinfo)}
-  where
-    f c | PGrad _ _ _ e <- _crhs c 
-      = c { _crhs = e} 
-    f c = c 
diff --git a/src/Gradual/Types.hs b/src/Gradual/Types.hs
deleted file mode 100644
--- a/src/Gradual/Types.hs
+++ /dev/null
@@ -1,38 +0,0 @@
-module Gradual.Types where
-
-
-import qualified Language.Haskell.Liquid.UX.Config as C
-import Language.Fixpoint.Types
-
-import qualified Data.HashMap.Strict as M
-
-data GConfig = GConfig {gtarget :: String, depth :: Int, pId :: Int, pNumber :: Int}
-
-defConfig :: GConfig
-defConfig = GConfig "" 0 0 0 
-
-setPId :: GConfig -> Int -> GConfig
-setPId cfg i = cfg {pId = i}
-
-makeGConfig :: C.Config -> GConfig
-makeGConfig cfg = defConfig {depth = C.gdepth cfg, gtarget = head $ C.files cfg}
-
-
-
-type GSub a = M.HashMap KVar (a, Expr)
-type GMap a = M.HashMap KVar (a, [Expr])
-type GSpan  = M.HashMap KVar [(KVar, Maybe SrcSpan)] 
-
-toGMap :: [(KVar, (a, [Expr]))] -> GMap a
-toGMap = M.fromList 
-
-fromGMap :: GMap a -> [(KVar, (a, [Expr]))]
-fromGMap = M.toList
-
-
-fromGSub :: GSub a -> [(KVar, (a, Expr))]
-fromGSub = M.toList
-
-
-removeInfo :: GMap a -> GMap ()
-removeInfo = M.map (\(_,x) -> ((),x))
diff --git a/src/Gradual/Uniquify.hs b/src/Gradual/Uniquify.hs
deleted file mode 100644
--- a/src/Gradual/Uniquify.hs
+++ /dev/null
@@ -1,263 +0,0 @@
-{-# LANGUAGE FlexibleContexts           #-}
-{-# LANGUAGE FlexibleInstances          #-}
-{-# LANGUAGE NoMonomorphismRestriction  #-}
-{-# LANGUAGE OverloadedStrings          #-}
-{-# LANGUAGE UndecidableInstances       #-}
-{-# LANGUAGE MultiParamTypeClasses      #-}
-{-# LANGUAGE TypeOperators              #-}
-{-# LANGUAGE GADTs                      #-}
-{-# LANGUAGE PatternGuards              #-}
-{-# LANGUAGE DeriveGeneric              #-}
-{-# LANGUAGE DeriveDataTypeable         #-}
-{-# LANGUAGE TupleSections              #-}
-
-module Gradual.Uniquify (uniquify) where
-
-import Language.Fixpoint.Types.Refinements
-import Language.Fixpoint.Types.Constraints
-import Language.Fixpoint.Types.PrettyPrint
-import Language.Fixpoint.Types.Environments
-import Language.Fixpoint.Types.Visitor
-import Language.Fixpoint.Types.Spans
-import Language.Fixpoint.Types.Names        (gradIntSymbol)
-
-import Control.DeepSeq
-
-import qualified Data.HashMap.Strict       as M
-import qualified Data.List                 as L
-
-import Control.Monad.State.Lazy
-
-import Gradual.Types (GSpan)
-
--------------------------------------------------------------------------------
--- |  Make each gradual appearance unique -------------------------------------
--------------------------------------------------------------------------------
-
-uniquify :: (NFData a, Fixpoint a, Loc a) => SInfo a -> (GSpan, SInfo a)
-
-uniquify fi = (km', fi{cm = cm', ws = ws', bs = bs'})
-  where
-  (cm', km, bs') = uniquifyCS (bs fi) (cm fi)
-  ws'            = expandWF km (ws fi)
-  km'            = M.union km $ M.map (const []) $ M.filter isGradual (ws fi)
-
-uniquifyCS :: (NFData a, Fixpoint a, Loc a)
-           => BindEnv
-           -> M.HashMap SubcId (SimpC a)
-           -> (M.HashMap SubcId (SimpC a), GSpan, BindEnv)
-uniquifyCS bs cs = (x, km, benv st)
-  where
-    (x, st) = runState (uniq cs) (initUniqueST bs)
-    km      = kmap st
-
-class Unique a where
-   uniq :: a -> UniqueM a
-
-instance Unique a => Unique (M.HashMap SubcId a) where
-  uniq m = M.fromList <$> mapM (\(i,x) -> (i,) <$> uniq x) (M.toList m)
-
-instance Loc a => Unique (SimpC a) where
-  uniq cs = do
-    updateLoc $ srcSpan $ _cinfo cs
-    rhs <- uniq (_crhs cs)
-    env <- uniq (_cenv cs)
-    return cs{_crhs = rhs, _cenv = env}
-
-instance Unique IBindEnv where
-  uniq env = withCache (fromListIBindEnv <$> mapM uniq (elemsIBindEnv env))
-
-instance Unique BindId where
-  uniq i = do
-    bs <- benv <$> get
-    let (x, t) = lookupBindEnv i bs
-    resetChange
-    t' <- uniq t
-    hasChanged <- change <$> get
-    if hasChanged
-      then do let (i', bs') = insertBindEnv x t' bs
-              updateBEnv i bs'
-              return i'
-      else return i
-
-instance Unique SortedReft where
-  uniq (RR s r) = RR s <$> uniq r
-
-instance Unique Reft where
-  uniq (Reft (x,e)) = (Reft . (x,)) <$> uniq e
-
-instance Unique Expr where
-  uniq = mapMExpr go
-   where
-    go (PGrad k su i e) = do
-      k'  <- freshK k
-      src <- uloc <$> get
-      return $ PGrad k' su (i{gused = src}) e
-    go e              = return e
-
--------------------------------------------------------------------------------
--- | The Unique Monad ---------------------------------------------------------
--------------------------------------------------------------------------------
-
-type UniqueM = State UniqueST
-data UniqueST
-  = UniqueST { freshId :: Integer
-             , kmap    :: GSpan
-             , change  :: Bool
-             , cache   :: M.HashMap KVar KVar
-             , uloc    :: Maybe SrcSpan
-             , ubs     :: [BindId]
-             , benv    :: BindEnv
-             }
-
-
-
-updateLoc :: SrcSpan -> UniqueM ()
-updateLoc x = modify $ \s -> s{uloc = Just x}
-
-withCache :: UniqueM a -> UniqueM a
-withCache act = do
-  emptyCache
-  a <- act
-  emptyCache
-  return a
-
-emptyCache :: UniqueM ()
-emptyCache = modify $ \s -> s{cache = mempty}
-
-
-updateBEnv :: BindId -> BindEnv -> UniqueM ()
-updateBEnv i bs = modify $ \s -> s{benv = bs, ubs = i:(ubs s)}
-
-setChange :: UniqueM ()
-setChange = modify $ \s -> s{change = True}
-
-resetChange :: UniqueM ()
-resetChange = modify $ \s -> s{change = False}
-
-initUniqueST :: BindEnv ->  UniqueST
-initUniqueST = UniqueST 0 mempty False mempty Nothing mempty
-
-freshK, freshK', freshK'' :: KVar -> UniqueM KVar
-freshK k  = do
-  setChange
-  cached <- cache <$> get
-  case M.lookup k cached of
-    {- OPTIMIZATION: Only create one fresh occurrence of ? per constraint environment. -}
-    Just k' -> return  k'
-    Nothing -> freshK'' k
-
--- M.HashMap KVar [(KVar, Maybe SrcSpan)]
-
-freshK'' k = do 
-  curr <- kmap <$> get 
-  loc  <- uloc <$> get 
-  case M.lookup k curr of 
-    Nothing -> freshK' k 
-    Just xs -> do spans <- existingSpan k loc xs 
-                  case spans of 
-                    Just k' -> return k' 
-                    Nothing -> freshK' k 
-
-
-{-
-Interesting Relative Positions
-
-           [.......]
-Ouside     |  [..]
-Inside   [............]
-Smaller    [..............] 
-Greater      [....]
-
--}
-
-data RelativePos a
-  = Outside  a 
-  | Inside   a 
-  | Smaller  a 
-  | Greater  a
-  | NoRelative
-
-existingSpan :: KVar -> Maybe SrcSpan -> [(KVar, Maybe SrcSpan)] -> UniqueM (Maybe KVar)
-existingSpan _ Nothing _ = return Nothing 
-existingSpan k (Just span) kspans
-  = case go kspans of 
-      Inside  (k',_)  -> updateK k k' span                 >> (return $ Just k')
-      Outside (k',sp) -> updateLoc sp                      >> (return $ Just k')
-      Smaller (k',sp) -> updateK k k' (sp `spanDiff` span) >> (return $ Just k')
-      Greater (k',sp) -> updateLoc    (sp `spanDiff` span) >> (return $ Just k')
-      NoRelative    -> return Nothing
-
-  where
-    go []                    = NoRelative
-    go ((_,Nothing):sps)     = go sps
-    go ((x,Just sp):sps) 
-      | span `inSpan` sp    = Inside  (x, sp) 
-      | sp `inSpan` span    = Outside (x, sp) 
-      | span `isSmaller` sp = Smaller (x, sp)
-      | sp `isSmaller` span = Greater (x, sp)
-      | otherwise           = go sps 
-
-
-
-spanDiff :: SrcSpan -> SrcSpan -> SrcSpan
-spanDiff (SS _ end1) (SS _ end2) = SS (toSourcePos (f,l,c-1)) end2
-  where (f,l,c) = sourcePosElts end1
-
-inSpan :: SrcSpan -> SrcSpan -> Bool 
-inSpan (SS start1 end1) (SS start2 end2) 
-  = start1' > start2' && end1' <= end2'
-  where
-    [start1',start2',end1',end2'] = sourcePosElts <$> [start1,start2,end1,end2]  
-
-
-isSmaller :: SrcSpan -> SrcSpan -> Bool 
-isSmaller (SS start1 end1) (SS start2 end2) 
-  = start1' == start2' && end1' <= end2'
-  where
-    [start1',start2',end1',end2'] = sourcePosElts <$> [start1,start2,end1,end2]  
-
-
-freshK' k = do
-  i <- freshId <$> get
-  modify $ (\s -> s{freshId = i + 1})
-  let k' = KV $ gradIntSymbol i
-  addK k k'
-  addCache k k'
-  return k'
-
-
-updateK :: KVar -> KVar -> SrcSpan -> UniqueM ()
-updateK k k' sp = 
-  modify $ (\s -> s{kmap = M.mapWithKey f (kmap s)})
-  where
-    f key val 
-      | key == k  = (\(kk,vv) -> if kk == k' then (kk,Just sp) else (kk,vv)) <$> val 
-      | otherwise = val 
-
-addK :: KVar -> KVar -> UniqueM ()
-addK key val =
-  modify $ (\s -> s{kmap = M.insertWith (++) key [(val, uloc s)] (kmap s)})
-
-addCache :: KVar -> KVar -> UniqueM ()
-addCache k k' = modify $ \s -> s{cache = M.insert k k' (cache s)}
-
--------------------------------------------------------------------------------
--- | expandWF -----------------------------------------------------------------
--------------------------------------------------------------------------------
-
-expandWF :: (NFData a, Fixpoint a)
-         => GSpan
-         -> M.HashMap KVar (WfC a)
-         -> M.HashMap KVar (WfC a)
-expandWF km ws
-  = M.fromList $
-       ([(k, updateKVar k src w) | (i, w) <- gws, (kw, ks) <- km', kw == i, (k, src) <- ks]
-        ++ kws)
-  where
-    (gws, kws)       = L.partition (isGWfc . snd) $ M.toList ws
-    km'              = M.toList km
-    updateKVar k src wfc = wfc { wrft = (\(v,s,_) -> (v,s,k)) $ wrft wfc
-                               , wloc = (wloc wfc){gused = src}
-                               }
-
diff --git a/src/Language/Haskell/Liquid/Bare.hs b/src/Language/Haskell/Liquid/Bare.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare.hs
+++ /dev/null
@@ -1,1093 +0,0 @@
-{-# LANGUAGE FlexibleContexts          #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE RecordWildCards           #-}
-{-# LANGUAGE ViewPatterns              #-}
-{-# LANGUAGE PartialTypeSignatures     #-}
-{-# LANGUAGE OverloadedStrings         #-}
-
--- | This module contains the functions that convert /from/ descriptions of
---   symbols, names and types (over freshly parsed /bare/ Strings),
---   /to/ representations connected to GHC 'Var's, 'Name's, and 'Type's.
---   The actual /representations/ of bare and real (refinement) types are all
---   in 'RefType' -- they are different instances of 'RType'.
-
-module Language.Haskell.Liquid.Bare (
-  -- * Creating a TargetSpec
-  -- $creatingTargetSpecs
-    makeTargetSpec
-
-  -- * Loading and Saving lifted specs from/to disk
-  , loadLiftedSpec
-  , saveLiftedSpec
-  ) where
-
-import           Prelude                                    hiding (error)
-import           Optics
-import           Control.Monad                              (unless)
-import qualified Control.Exception                          as Ex
-import qualified Data.Binary                                as B
-import qualified Data.Maybe                                 as Mb
-import qualified Data.List                                  as L
-import qualified Data.HashMap.Strict                        as M
-import qualified Data.HashSet                               as S
-import           Text.PrettyPrint.HughesPJ                  hiding (first, (<>)) -- (text, (<+>))
-import           System.FilePath                            (dropExtension)
-import           System.Directory                           (doesFileExist)
-import           System.Console.CmdArgs.Verbosity           (whenLoud)
-import           Language.Fixpoint.Utils.Files              as Files
-import           Language.Fixpoint.Misc                     as Misc 
-import           Language.Fixpoint.Types                    hiding (dcFields, DataDecl, Error, panic)
-import qualified Language.Fixpoint.Types                    as F
-import qualified Language.Haskell.Liquid.Misc               as Misc -- (nubHashOn)
-import qualified Language.Haskell.Liquid.GHC.Misc           as GM
-import qualified Language.Haskell.Liquid.GHC.API            as Ghc 
-import           Language.Haskell.Liquid.GHC.Types          (StableName)
-import           Language.Haskell.Liquid.Types
-import           Language.Haskell.Liquid.WiredIn
-import qualified Language.Haskell.Liquid.Measure            as Ms
-import qualified Language.Haskell.Liquid.Bare.Types         as Bare 
-import qualified Language.Haskell.Liquid.Bare.Resolve       as Bare 
-import qualified Language.Haskell.Liquid.Bare.DataType      as Bare 
-import qualified Language.Haskell.Liquid.Bare.Expand        as Bare 
-import qualified Language.Haskell.Liquid.Bare.Measure       as Bare 
-import qualified Language.Haskell.Liquid.Bare.Plugged       as Bare 
-import qualified Language.Haskell.Liquid.Bare.Axiom         as Bare 
-import qualified Language.Haskell.Liquid.Bare.ToBare        as Bare 
-import qualified Language.Haskell.Liquid.Bare.Class         as Bare 
-import qualified Language.Haskell.Liquid.Bare.Check         as Bare 
-import qualified Language.Haskell.Liquid.Bare.Laws          as Bare 
-import qualified Language.Haskell.Liquid.Transforms.CoreToLogic as CoreToLogic 
-import           Control.Arrow                    (second)
-
---------------------------------------------------------------------------------
--- | De/Serializing Spec files
---------------------------------------------------------------------------------
-
-loadLiftedSpec :: Config -> FilePath -> IO (Maybe Ms.BareSpec)
-loadLiftedSpec cfg srcF
-  | noLiftedImport cfg = putStrLn "No LIFTED Import" >> return Nothing 
-  | otherwise          = do
-      let specF = extFileName BinSpec srcF
-      ex  <- doesFileExist specF
-      whenLoud $ putStrLn $ "Loading Binary Lifted Spec: " ++ specF ++ " " ++ "for source-file: " ++ show srcF ++ " " ++ show ex
-      lSp <- if ex 
-               then Just <$> B.decodeFile specF 
-               else (warnMissingLiftedSpec srcF specF >> return Nothing)
-      Ex.evaluate lSp
-
-warnMissingLiftedSpec :: FilePath -> FilePath -> IO () 
-warnMissingLiftedSpec srcF specF = do 
-  incDir <- Misc.getIncludeDir 
-  unless (Misc.isIncludeFile incDir srcF)
-    $ Ex.throw (errMissingSpec srcF specF) 
-
-errMissingSpec :: FilePath -> FilePath -> UserError 
-errMissingSpec srcF specF = ErrNoSpec Ghc.noSrcSpan (text srcF) (text specF)
-
--- saveLiftedSpec :: FilePath -> ModName -> Ms.BareSpec -> IO ()
-saveLiftedSpec :: FilePath -> Ms.BareSpec -> IO () 
-saveLiftedSpec srcF lspec = do
-  ensurePath specF
-  B.encodeFile specF lspec
-  -- print (errorP "DIE" "HERE" :: String) 
-  where
-    specF = extFileName BinSpec srcF
-
-{- $creatingTargetSpecs
-
-/Liquid Haskell/ operates on 'TargetSpec's, so this module provides a single function called
-'makeTargetSpec' to produce a 'TargetSpec', alongside the 'LiftedSpec'. The former will be used by
-functions like 'liquid' or 'liquidOne' to verify our program is correct, the latter will be serialised
-to disk so that we can retrieve it later without having to re-check the relevant Haskell file.
--}
-
--- | 'makeTargetSpec' constructs the 'TargetSpec' and then validates it. Upon success, the 'TargetSpec'
--- and the 'LiftedSpec' are returned. We perform error checking in \"two phases\": during the first phase,
--- we check for errors and warnings in the input 'BareSpec' and the dependencies. During this phase we ideally
--- want to short-circuit in case the validation failure is found in one of the dependencies (to avoid
--- printing potentially endless failures).
--- The second phase involves creating the 'TargetSpec', and returning either the full list of diagnostics
--- (errors and warnings) in case things went wrong, or the final 'TargetSpec' and 'LiftedSpec' together
--- with a list of 'Warning's, which shouldn't abort the compilation (modulo explicit request from the user,
--- to treat warnings and errors).
-makeTargetSpec :: Config
-               -> LogicMap
-               -> TargetSrc
-               -> BareSpec
-               -> TargetDependencies
-               -> Either Diagnostics ([Warning], TargetSpec, LiftedSpec)
-makeTargetSpec cfg lmap targetSrc bareSpec dependencies = do
-  let depsDiagnostics     = mapM (uncurry Bare.checkBareSpec) legacyDependencies
-  let bareSpecDiagnostics = Bare.checkBareSpec (giTargetMod targetSrc) legacyBareSpec
-  case depsDiagnostics >> bareSpecDiagnostics of
-   Left d | noErrors d -> secondPhase (allWarnings d)
-   Left d              -> Left  d
-   Right ()            -> secondPhase mempty
-  where
-    secondPhase :: [Warning] -> Either Diagnostics ([Warning], TargetSpec, LiftedSpec)
-    secondPhase phaseOneWarns = do
-      (warns, ghcSpec) <- makeGhcSpec cfg (review targetSrcIso targetSrc) lmap (allSpecs legacyBareSpec)
-      let (targetSpec, liftedSpec) = view targetSpecGetter ghcSpec
-      pure (phaseOneWarns <> warns, targetSpec, liftedSpec)
-
-    toLegacyDep :: (StableModule, LiftedSpec) -> (ModName, Ms.BareSpec)
-    toLegacyDep (sm, ls) = (ModName SrcImport (Ghc.moduleName . unStableModule $ sm), unsafeFromLiftedSpec ls)
-
-    toLegacyTarget :: Ms.BareSpec -> (ModName, Ms.BareSpec)
-    toLegacyTarget validatedSpec = (giTargetMod targetSrc, validatedSpec)
-
-    legacyDependencies :: [(ModName, Ms.BareSpec)]
-    legacyDependencies = map toLegacyDep . M.toList . getDependencies $ dependencies
-
-    allSpecs :: Ms.BareSpec -> [(ModName, Ms.BareSpec)]
-    allSpecs validSpec = toLegacyTarget validSpec : legacyDependencies
-
-    legacyBareSpec :: Spec LocBareType F.LocSymbol
-    legacyBareSpec = review bareSpecIso bareSpec
-
--------------------------------------------------------------------------------------
--- | @makeGhcSpec@ invokes @makeGhcSpec0@ to construct the @GhcSpec@ and then
---   validates it using @checkGhcSpec@.
--------------------------------------------------------------------------------------
-makeGhcSpec :: Config
-            -> GhcSrc
-            -> LogicMap
-            -> [(ModName, Ms.BareSpec)]
-            -> Either Diagnostics ([Warning], GhcSpec)
--------------------------------------------------------------------------------------
-makeGhcSpec cfg src lmap validatedSpecs = do
-  case diagnostics of
-    Left e | noErrors e -> pure (allWarnings e, sp)
-    Left e              -> Left e
-    Right ()            -> pure (mempty, sp)
-  where
-    diagnostics = Bare.checkTargetSpec (map snd validatedSpecs)
-                                       (view targetSrcIso src)
-                                       renv
-                                       cbs
-                                       (fst . view targetSpecGetter $ sp)
-    sp          = makeGhcSpec0 cfg src lmap validatedSpecs
-    renv        = ghcSpecEnv sp
-    cbs         = _giCbs src
-
-ghcSpecEnv :: GhcSpec -> SEnv SortedReft
-ghcSpecEnv sp = fromListSEnv binds
-  where
-    emb       = gsTcEmbeds (_gsName sp)
-    binds     = concat 
-                 [ [(x,        rSort t) | (x, Loc _ _ t) <- gsMeas     (_gsData sp)]
-                 , [(symbol v, rSort t) | (v, Loc _ _ t) <- gsCtors    (_gsData sp)]
-                 , [(symbol v, vSort v) | v              <- gsReflects (_gsRefl sp)]
-                 , [(x,        vSort v) | (x, v)         <- gsFreeSyms (_gsName sp), Ghc.isConLikeId v ]
-                 , [(x, RR s mempty)    | (x, s)         <- wiredSortedSyms       ]
-                 , [(x, RR s mempty)    | (x, s)         <- _gsImps sp       ]
-                 ]
-    vSort     = Bare.varSortedReft emb
-    rSort     = rTypeSortedReft    emb
-
-
--------------------------------------------------------------------------------------
--- | @makeGhcSpec0@ slurps up all the relevant information needed to generate 
---   constraints for a target module and packages them into a @GhcSpec@ 
---   See [NOTE] LIFTING-STAGES to see why we split into lSpec0, lSpec1, etc.
---   essentially, to get to the `BareRTEnv` as soon as possible, as thats what
---   lets us use aliases inside data-constructor definitions.
--------------------------------------------------------------------------------------
-makeGhcSpec0 :: Config -> GhcSrc ->  LogicMap -> [(ModName, Ms.BareSpec)] -> GhcSpec
--------------------------------------------------------------------------------------
-makeGhcSpec0 cfg src lmap mspecs = SP 
-  { _gsConfig = cfg 
-  , _gsImps   = makeImports mspecs
-  , _gsSig    = addReflSigs refl sig 
-  , _gsRefl   = refl 
-  , _gsLaws   = laws 
-  , _gsData   = sData 
-  , _gsQual   = qual 
-  , _gsName   = makeSpecName env     tycEnv measEnv   name 
-  , _gsVars   = makeSpecVars cfg src mySpec env measEnv
-  , _gsTerm   = makeSpecTerm cfg     mySpec env       name    
-  , _gsLSpec  = finalLiftedSpec
-              { impSigs   = makeImports mspecs
-              , expSigs   = [ (F.symbol v, F.sr_sort $ Bare.varSortedReft embs v) | v <- gsReflects refl ]
-              , dataDecls = dataDecls mySpec2
-              , measures  = Ms.measures mySpec
-                -- We want to export measures in a 'LiftedSpec', especially if they are
-                -- required to check termination of some 'liftedSigs' we export. Due to the fact
-                -- that 'lSpec1' doesn't contain the measures that we compute via 'makeHaskellMeasures',
-                -- we take them from 'mySpec', which has those.
-              , asmSigs = Ms.asmSigs finalLiftedSpec ++ Ms.asmSigs mySpec
-                -- Export all the assumptions (not just the ones created out of reflection) in
-                -- a 'LiftedSpec'.
-              , imeasures = Ms.imeasures finalLiftedSpec ++ Ms.imeasures mySpec
-                -- Preserve user-defined 'imeasures'.
-              , dvariance = Ms.dvariance finalLiftedSpec ++ Ms.dvariance mySpec
-                -- Preserve user-defined 'dvariance'.
-              , rinstance = Ms.rinstance finalLiftedSpec ++ Ms.rinstance mySpec
-                -- Preserve rinstances.
-              }
-  }
-  where
-    finalLiftedSpec = makeLiftedSpec src env refl sData sig qual myRTE lSpec1
-    -- build up spec components 
-    myRTE    = myRTEnv       src env sigEnv rtEnv  
-    qual     = makeSpecQual cfg env tycEnv measEnv rtEnv specs 
-    sData    = makeSpecData  src env sigEnv measEnv sig specs 
-    refl     = makeSpecRefl  cfg src measEnv specs env name sig tycEnv 
-    laws     = makeSpecLaws env sigEnv (gsTySigs sig ++ gsAsmSigs sig) measEnv specs 
-    sig      = makeSpecSig cfg name specs env sigEnv   tycEnv measEnv (_giCbs src)
-    measEnv  = makeMeasEnv      env tycEnv sigEnv       specs 
-    -- build up environments
-    specs    = M.insert name mySpec iSpecs2
-    mySpec   = mySpec2 <> lSpec1 
-    lSpec1   = lSpec0 <> makeLiftedSpec1 cfg src tycEnv lmap mySpec1 
-    sigEnv   = makeSigEnv  embs tyi (_gsExports src) rtEnv 
-    tyi      = Bare.tcTyConMap   tycEnv 
-    tycEnv   = makeTycEnv   cfg name env embs mySpec2 iSpecs2 
-    mySpec2  = Bare.qualifyExpand env name rtEnv l [] mySpec1    where l = F.dummyPos "expand-mySpec2"
-    iSpecs2  = Bare.qualifyExpand env name rtEnv l [] iSpecs0    where l = F.dummyPos "expand-iSpecs2"
-    rtEnv    = Bare.makeRTEnv env name mySpec1 iSpecs0 lmap  
-    mySpec1  = mySpec0 <> lSpec0    
-    lSpec0   = makeLiftedSpec0 cfg src embs lmap mySpec0 
-    embs     = makeEmbeds          src env ((name, mySpec0) : M.toList iSpecs0)
-    -- extract name and specs
-    env      = Bare.makeEnv cfg src lmap mspecs  
-    (mySpec0, iSpecs0) = splitSpecs name mspecs 
-    -- check barespecs 
-    name     = F.notracepp ("ALL-SPECS" ++ zzz) $ _giTargetMod  src 
-    zzz      = F.showpp (fst <$> mspecs)
-
-splitSpecs :: ModName -> [(ModName, Ms.BareSpec)] -> (Ms.BareSpec, Bare.ModSpecs) 
-splitSpecs name specs = (mySpec, iSpecm) 
-  where 
-    mySpec            = mconcat (snd <$> mySpecs)
-    (mySpecs, iSpecs) = L.partition ((name ==) . fst) specs 
-    iSpecm            = fmap mconcat . Misc.group $ iSpecs
-
-
-makeImports :: [(ModName, Ms.BareSpec)] -> [(F.Symbol, F.Sort)]
-makeImports specs = concatMap (expSigs . snd) specs'
-  where specs' = filter (isSrcImport . fst) specs
-
-
-makeEmbeds :: GhcSrc -> Bare.Env -> [(ModName, Ms.BareSpec)] -> F.TCEmb Ghc.TyCon 
-makeEmbeds src env 
-  = Bare.addClassEmbeds (_gsCls src) (_gsFiTcs src) 
-  . mconcat 
-  . map (makeTyConEmbeds env)
-
-makeTyConEmbeds :: Bare.Env -> (ModName, Ms.BareSpec) -> F.TCEmb Ghc.TyCon
-makeTyConEmbeds env (name, spec) 
-  = F.tceFromList [ (tc, t) | (c,t) <- F.tceToList (Ms.embeds spec), tc <- symTc c ]
-    where
-      symTc = Mb.maybeToList . Bare.maybeResolveSym env name "embed-tycon" 
-
---------------------------------------------------------------------------------
--- | [NOTE]: REFLECT-IMPORTS
---
--- 1. MAKE the full LiftedSpec, which will eventually, contain:
---      makeHaskell{Inlines, Measures, Axioms, Bounds}
--- 2. SAVE the LiftedSpec, which will be reloaded
--- 
---   This step creates the aliases and inlines etc. It must be done BEFORE
---   we compute the `SpecType` for (all, including the reflected binders),
---   as we need the inlines and aliases to properly `expand` the SpecTypes.
---------------------------------------------------------------------------------
-makeLiftedSpec1 :: Config -> GhcSrc -> Bare.TycEnv -> LogicMap -> Ms.BareSpec 
-                -> Ms.BareSpec
-makeLiftedSpec1 _ src tycEnv lmap mySpec = mempty
-  { Ms.measures  = Bare.makeHaskellMeasures src tycEnv lmap mySpec }
-
---------------------------------------------------------------------------------
--- | [NOTE]: LIFTING-STAGES 
--- 
--- We split the lifting up into stage:
--- 0. Where we only lift inlines,
--- 1. Where we lift reflects, measures, and normalized tySigs
--- 
--- This is because we need the inlines to build the @BareRTEnv@ which then
--- does the alias @expand@ business, that in turn, lets us build the DataConP,
--- i.e. the refined datatypes and their associate selectors, projectors etc,
--- that are needed for subsequent stages of the lifting.
---------------------------------------------------------------------------------
-makeLiftedSpec0 :: Config -> GhcSrc -> F.TCEmb Ghc.TyCon -> LogicMap -> Ms.BareSpec 
-                -> Ms.BareSpec
-makeLiftedSpec0 cfg src embs lmap mySpec = mempty
-  { Ms.ealiases  = lmapEAlias . snd <$> Bare.makeHaskellInlines src embs lmap mySpec 
-  , Ms.reflects  = Ms.reflects mySpec
-  , Ms.dataDecls = Bare.makeHaskellDataDecls cfg name mySpec tcs  
-  , Ms.embeds    = Ms.embeds mySpec
-  -- We do want 'embeds' to survive and to be present into the final 'LiftedSpec'. The
-  -- caveat is to decide which format is more appropriate. We obviously cannot store
-  -- them as a 'TCEmb TyCon' as serialising a 'TyCon' would be fairly exponsive. This
-  -- needs more thinking.
-  , Ms.cmeasures = Ms.cmeasures mySpec
-  -- We do want 'cmeasures' to survive and to be present into the final 'LiftedSpec'. The
-  -- caveat is to decide which format is more appropriate. This needs more thinking.
-  }
-  where 
-    tcs          = uniqNub (_gsTcs src ++ refTcs)
-    refTcs       = reflectedTyCons cfg embs cbs  mySpec
-    cbs          = _giCbs       src
-    name         = _giTargetMod src
-
-uniqNub :: (Ghc.Uniquable a) => [a] -> [a]
-uniqNub xs = M.elems $ M.fromList [ (index x, x) | x <- xs ]
-  where
-    index  = Ghc.getKey . Ghc.getUnique
-
--- | 'reflectedTyCons' returns the list of `[TyCon]` that must be reflected but
---   which are defined *outside* the current module e.g. in Base or somewhere
---   that we don't have access to the code.
-
-reflectedTyCons :: Config -> TCEmb Ghc.TyCon -> [Ghc.CoreBind] -> Ms.BareSpec -> [Ghc.TyCon]
-reflectedTyCons cfg embs cbs spec
-  | exactDCFlag cfg = filter (not . isEmbedded embs)
-                    $ concatMap varTyCons
-                    $ reflectedVars spec cbs
-  | otherwise       = []
-
--- | We cannot reflect embedded tycons (e.g. Bool) as that gives you a sort
---   conflict: e.g. what is the type of is-True? does it take a GHC.Types.Bool
---   or its embedding, a bool?
-isEmbedded :: TCEmb Ghc.TyCon -> Ghc.TyCon -> Bool
-isEmbedded embs c = F.tceMember c embs
-
-varTyCons :: Ghc.Var -> [Ghc.TyCon]
-varTyCons = specTypeCons . ofType . Ghc.varType
-
-specTypeCons           :: SpecType -> [Ghc.TyCon]
-specTypeCons           = foldRType tc []
-  where
-    tc acc t@(RApp {}) = (rtc_tc $ rt_tycon t) : acc
-    tc acc _           = acc
-
-reflectedVars :: Ms.BareSpec -> [Ghc.CoreBind] -> [Ghc.Var]
-reflectedVars spec cbs = (fst <$> xDefs)
-  where
-    xDefs              = Mb.mapMaybe (`GM.findVarDef` cbs) reflSyms
-    reflSyms           = fmap val . S.toList . Ms.reflects $ spec
-
-------------------------------------------------------------------------------------------
-makeSpecVars :: Config -> GhcSrc -> Ms.BareSpec -> Bare.Env -> Bare.MeasEnv -> GhcSpecVars 
-------------------------------------------------------------------------------------------
-makeSpecVars cfg src mySpec env measEnv = SpVar 
-  { gsTgtVars    =   map (resolveStringVar  env name)              (checks     cfg) 
-  , gsIgnoreVars = S.map (Bare.lookupGhcVar env name "gs-ignores") (Ms.ignores mySpec) 
-  , gsLvars      = S.map (Bare.lookupGhcVar env name "gs-lvars"  ) (Ms.lvars   mySpec)
-  , gsCMethods   = snd3 <$> Bare.meMethods measEnv 
-  }
-  where name     = _giTargetMod src 
-
-qualifySymbolic :: (F.Symbolic a) => ModName -> a -> F.Symbol 
-qualifySymbolic name s = GM.qualifySymbol (F.symbol name) (F.symbol s)
-
-resolveStringVar :: Bare.Env -> ModName -> String -> Ghc.Var
-resolveStringVar env name s = Bare.lookupGhcVar env name "resolve-string-var" lx
-  where 
-    lx                      = dummyLoc (qualifySymbolic name s)
-
-------------------------------------------------------------------------------------------
-makeSpecQual :: Config -> Bare.Env -> Bare.TycEnv -> Bare.MeasEnv -> BareRTEnv -> Bare.ModSpecs 
-             -> GhcSpecQual 
-------------------------------------------------------------------------------------------
-makeSpecQual _cfg env tycEnv measEnv _rtEnv specs = SpQual 
-  { gsQualifiers = filter okQual quals 
-  , gsRTAliases  = [] -- makeSpecRTAliases env rtEnv -- TODO-REBARE
-  } 
-  where 
-    quals        = concatMap (makeQualifiers env tycEnv) (M.toList specs) 
-    -- mSyms        = F.tracepp "MSYMS" $ M.fromList (Bare.meSyms measEnv ++ Bare.meClassSyms measEnv)
-    okQual q     = F.notracepp ("okQual: " ++ F.showpp q) 
-                   $ all (`S.member` mSyms) (F.syms q)
-    mSyms        = F.notracepp "MSYMS" . S.fromList 
-                   $  (fst <$> wiredSortedSyms) 
-                   ++ (fst <$> Bare.meSyms measEnv) 
-                   ++ (fst <$> Bare.meClassSyms measEnv)
-
-makeQualifiers :: Bare.Env -> Bare.TycEnv -> (ModName, Ms.Spec ty bndr) -> [F.Qualifier]
-makeQualifiers env tycEnv (mod, spec) 
-  = fmap        (Bare.qualifyTopDummy env        mod) 
-  . Mb.mapMaybe (resolveQParams       env tycEnv mod)
-  $ Ms.qualifiers spec 
-
-
--- | @resolveQualParams@ converts the sorts of parameters from, e.g. 
---     'Int' ===> 'GHC.Types.Int' or 
---     'Ptr' ===> 'GHC.Ptr.Ptr'  
---   It would not be required if _all_ qualifiers are scraped from 
---   function specs, but we're keeping it around for backwards compatibility.
-
-resolveQParams :: Bare.Env -> Bare.TycEnv -> ModName -> F.Qualifier -> Maybe F.Qualifier 
-resolveQParams env tycEnv name q = do 
-     qps   <- mapM goQP (F.qParams q) 
-     return $ q { F.qParams = qps } 
-  where 
-    goQP qp          = do { s <- go (F.qpSort qp) ; return qp { F.qpSort = s } } 
-    go               :: F.Sort -> Maybe F.Sort   
-    go (FAbs i s)    = FAbs i <$> go s
-    go (FFunc s1 s2) = FFunc  <$> go s1 <*> go s2
-    go (FApp  s1 s2) = FApp   <$> go s1 <*> go s2
-    go (FTC c)       = qualifyFTycon env tycEnv name c 
-    go s             = Just s 
-
-qualifyFTycon :: Bare.Env -> Bare.TycEnv -> ModName -> F.FTycon -> Maybe F.Sort 
-qualifyFTycon env tycEnv name c 
-  | isPrimFTC           = Just (FTC c) 
-  | otherwise           = tyConSort embs . F.atLoc tcs <$> ty 
-  where       
-    ty                  = Bare.maybeResolveSym env name "qualify-FTycon" tcs                
-    isPrimFTC           = (F.val tcs) `elem` F.prims 
-    tcs                 = F.fTyconSymbol c
-    embs                = Bare.tcEmbs tycEnv 
-
-tyConSort :: F.TCEmb Ghc.TyCon -> F.Located Ghc.TyCon -> F.Sort 
-tyConSort embs lc = Mb.maybe s0 fst (F.tceLookup c embs)
-  where 
-    c             = F.val lc
-    s0            = tyConSortRaw lc
-
-tyConSortRaw :: F.Located Ghc.TyCon -> F.Sort 
-tyConSortRaw = FTC . F.symbolFTycon . fmap F.symbol 
-
-------------------------------------------------------------------------------------------
-makeSpecTerm :: Config -> Ms.BareSpec -> Bare.Env -> ModName -> GhcSpecTerm 
-------------------------------------------------------------------------------------------
-makeSpecTerm cfg mySpec env name = SpTerm 
-  { gsLazy       = S.insert dictionaryVar (lazies `mappend` sizes)
-  , gsFail       = makeFail     env name mySpec 
-  , gsStTerm     = sizes
-  , gsAutosize   = autos 
-  , gsDecr       = makeDecrs env name mySpec
-  , gsNonStTerm  = mempty 
-  }
-  where  
-    lazies       = makeLazy     env name mySpec
-    autos        = makeAutoSize env name mySpec
-    strT         = not (structuralTerm cfg) 
-    sizes 
-     | strT      = makeSize env name mySpec 
-     | otherwise = mempty 
-
--- formerly, makeHints
-makeDecrs :: Bare.Env -> ModName -> Ms.BareSpec -> [(Ghc.Var, [Int])] 
-makeDecrs env name mySpec = 
-  [ (v, z) | (lx, z) <- Ms.decr mySpec
-           , let v    = Bare.lookupGhcVar env name "decreasing" lx
-  ]
-
-makeLazy :: Bare.Env -> ModName -> Ms.BareSpec -> S.HashSet Ghc.Var
-makeLazy env name spec = 
-  S.map (Bare.lookupGhcVar env name "Var") (Ms.lazy spec)
-
-makeFail :: Bare.Env -> ModName -> Ms.BareSpec -> S.HashSet (Located Ghc.Var)
-makeFail env name spec = 
-  S.map (\x -> x{ val = Bare.lookupGhcVar env name "Var" x}) (Ms.fails spec)
-
-makeRewrite :: Bare.Env -> ModName -> Ms.BareSpec -> S.HashSet (Located Ghc.Var)
-makeRewrite env name spec = 
-  S.map (\x -> x{ val = Bare.lookupGhcVar env name "Var" x}) (Ms.rewrites spec)
-
-makeRewriteWith :: Bare.Env -> ModName -> Ms.BareSpec -> M.HashMap Ghc.Var [Ghc.Var]
-makeRewriteWith env name spec = 
-  M.fromList [ (lu x, lu <$> xs) | (x,xs) <- M.toList $ Ms.rewriteWith spec]
-    where lu = Bare.lookupGhcVar env name "Var"  
-
-
-makeAutoSize :: Bare.Env -> ModName -> Ms.BareSpec -> S.HashSet Ghc.TyCon
-makeAutoSize env name spec =
-  S.map (Bare.lookupGhcTyCon env name "TyCon") (Ms.autosize spec) 
-
-makeSize :: Bare.Env -> ModName -> Ms.BareSpec -> S.HashSet Ghc.Var
-makeSize env name spec = 
-  S.map (Bare.lookupGhcVar env name "Var") (S.fromList lzs)
-  where
-    lzs = Mb.catMaybes (getSizeFuns <$> Ms.dataDecls spec)
-    getSizeFuns decl
-      | Just x       <- tycSFun decl
-      , SymSizeFun f <- x
-      = Just f
-      | otherwise
-      = Nothing
-
-------------------------------------------------------------------------------------------
-makeSpecLaws :: Bare.Env -> Bare.SigEnv -> [(Ghc.Var,LocSpecType)] -> Bare.MeasEnv -> Bare.ModSpecs 
-             -> GhcSpecLaws 
-------------------------------------------------------------------------------------------
-makeSpecLaws env sigEnv sigs menv specs = SpLaws 
-  { gsLawDefs = second (map (\(_,x,y) -> (x,y))) <$> Bare.meCLaws menv  
-  , gsLawInst = Bare.makeInstanceLaws env sigEnv sigs specs
-  }
-
-------------------------------------------------------------------------------------------
-makeSpecRefl :: Config -> GhcSrc -> Bare.MeasEnv -> Bare.ModSpecs -> Bare.Env -> ModName -> GhcSpecSig -> Bare.TycEnv 
-             -> GhcSpecRefl 
-------------------------------------------------------------------------------------------
-makeSpecRefl cfg src menv specs env name sig tycEnv = SpRefl 
-  { gsLogicMap   = lmap 
-  , gsAutoInst   = makeAutoInst env name mySpec 
-  , gsImpAxioms  = concatMap (Ms.axeqs . snd) (M.toList specs)
-  , gsMyAxioms   = F.notracepp "gsMyAxioms" myAxioms 
-  , gsReflects   = F.notracepp "gsReflects" (lawMethods ++ filter (isReflectVar rflSyms) sigVars ++ wReflects)
-  , gsHAxioms    = F.notracepp "gsHAxioms" xtes 
-  , gsWiredReft  = wReflects
-  , gsRewrites   = makeRewrite env name mySpec
-  , gsRewritesWith = makeRewriteWith env name mySpec
-  }
-  where
-    wReflects    = Bare.wiredReflects cfg env name sig
-    lawMethods   = F.notracepp "Law Methods" $ concatMap Ghc.classMethods (fst <$> Bare.meCLaws menv) 
-    mySpec       = M.lookupDefault mempty name specs 
-    xtes         = Bare.makeHaskellAxioms cfg src env tycEnv name lmap sig mySpec
-    myAxioms     = [ Bare.qualifyTop env name (F.loc lt) (e {eqName = symbol x}) | (x, lt, e) <- xtes]  
-    rflSyms      = S.fromList (getReflects specs)
-    sigVars      = F.notracepp "SIGVARS" $ (fst3 <$> xtes)            -- reflects
-                                        ++ (fst  <$> gsAsmSigs sig)   -- assumes
-                                        ++ (fst  <$> gsRefSigs sig)
-                                      -- ++ (fst  <$> gsTySigs  sig)   -- measures 
-
-    lmap         = Bare.reLMap env
-
-isReflectVar :: S.HashSet F.Symbol -> Ghc.Var -> Bool 
-isReflectVar reflSyms v = S.member vx reflSyms
-  where
-    vx                  = GM.dropModuleNames (symbol v)
-
-getReflects :: Bare.ModSpecs -> [Symbol]
-getReflects  = fmap val . S.toList . S.unions . fmap (names . snd) . M.toList
-  where
-    names  z = S.unions [ Ms.reflects z, Ms.inlines z, Ms.hmeas z ]
-    
-------------------------------------------------------------------------------------------
--- | @updateReflSpecSig@ uses the information about reflected functions to update the 
---   "assumed" signatures. 
-------------------------------------------------------------------------------------------
-addReflSigs :: GhcSpecRefl -> GhcSpecSig -> GhcSpecSig
-------------------------------------------------------------------------------------------
-addReflSigs refl sig = sig { gsRefSigs = reflSigs, gsAsmSigs = wreflSigs ++ filter notReflected (gsAsmSigs sig) }
-  where 
-    (wreflSigs, reflSigs)   = L.partition ((`elem` gsWiredReft refl) . fst) 
-                                 [ (x, t) | (x, t, _) <- gsHAxioms refl ]   
-    reflected       = fst <$> (wreflSigs ++ reflSigs)
-    notReflected xt = fst xt `notElem` reflected
-
-makeAutoInst :: Bare.Env -> ModName -> Ms.BareSpec -> M.HashMap Ghc.Var (Maybe Int)
-makeAutoInst env name spec = Misc.hashMapMapKeys (Bare.lookupGhcVar env name "Var") (Ms.autois spec)
-
-----------------------------------------------------------------------------------------
-makeSpecSig :: Config -> ModName -> Bare.ModSpecs -> Bare.Env -> Bare.SigEnv -> Bare.TycEnv -> Bare.MeasEnv -> [Ghc.CoreBind]
-            -> GhcSpecSig 
-----------------------------------------------------------------------------------------
-makeSpecSig cfg name specs env sigEnv tycEnv measEnv cbs = SpSig 
-  { gsTySigs   = F.notracepp "gsTySigs"  tySigs 
-  , gsAsmSigs  = F.notracepp "gsAsmSigs" asmSigs
-  , gsRefSigs  = [] 
-  , gsDicts    = dicts 
-  , gsMethods  = if noclasscheck cfg then [] else Bare.makeMethodTypes dicts (Bare.meClasses  measEnv) cbs 
-  , gsInSigs   = mempty -- TODO-REBARE :: ![(Var, LocSpecType)]  
-  , gsNewTypes = makeNewTypes env sigEnv allSpecs 
-  , gsTexprs   = [ (v, t, es) | (v, t, Just es) <- mySigs ] 
-  }
-  where 
-    dicts      = Bare.makeSpecDictionaries env sigEnv specs  
-    mySpec     = M.lookupDefault mempty name specs
-    asmSigs    = Bare.tcSelVars tycEnv 
-              ++ makeAsmSigs env sigEnv name specs 
-              ++ [ (x,t) | (_, x, t) <- concat $ map snd (Bare.meCLaws measEnv)]
-    tySigs     = strengthenSigs . concat $ 
-                  [ [(v, (0, t)) | (v, t,_) <- mySigs                         ]   -- NOTE: these weights are to priortize 
-                  , [(v, (1, t)) | (v, t  ) <- makeMthSigs measEnv            ]   -- user defined sigs OVER auto-generated 
-                  , [(v, (2, t)) | (v, t  ) <- makeInlSigs env rtEnv allSpecs ]   -- during the strengthening, i.e. to KEEP 
-                  , [(v, (3, t)) | (v, t  ) <- makeMsrSigs env rtEnv allSpecs ]   -- the binders used in USER-defined sigs 
-                  ]                                                               -- as they appear in termination metrics
-    mySigs     = F.notracepp "MAKE-TYSIGS" $ makeTySigs  env sigEnv name mySpec
-    allSpecs   = M.toList specs 
-    rtEnv      = Bare.sigRTEnv sigEnv 
-    -- hmeas      = makeHMeas    env allSpecs 
-
-strengthenSigs :: [(Ghc.Var, (Int, LocSpecType))] ->[(Ghc.Var, LocSpecType)]
-strengthenSigs sigs = go <$> Misc.groupList sigs 
-  where
-    go (v, ixs)     = (v,) $ L.foldl1' (flip meetLoc) (F.notracepp ("STRENGTHEN-SIGS: " ++ F.showpp v) (prio ixs))
-    prio            = fmap snd . Misc.sortOn fst 
-    meetLoc         :: LocSpecType -> LocSpecType -> LocSpecType
-    meetLoc t1 t2   = t1 {val = val t1 `F.meet` val t2}
-
-makeMthSigs :: Bare.MeasEnv -> [(Ghc.Var, LocSpecType)]
-makeMthSigs measEnv = [ (v, t) | (_, v, t) <- Bare.meMethods measEnv ]
-
-makeInlSigs :: Bare.Env -> BareRTEnv -> [(ModName, Ms.BareSpec)] -> [(Ghc.Var, LocSpecType)] 
-makeInlSigs env rtEnv 
-  = makeLiftedSigs rtEnv CoreToLogic.inlineSpecType 
-  . makeFromSet "hinlines" Ms.inlines env 
-
-makeMsrSigs :: Bare.Env -> BareRTEnv -> [(ModName, Ms.BareSpec)] -> [(Ghc.Var, LocSpecType)] 
-makeMsrSigs env rtEnv 
-  = makeLiftedSigs rtEnv CoreToLogic.measureSpecType 
-  . makeFromSet "hmeas" Ms.hmeas env 
-
-makeLiftedSigs :: BareRTEnv -> (Ghc.Var -> SpecType) -> [Ghc.Var] -> [(Ghc.Var, LocSpecType)]
-makeLiftedSigs rtEnv f xs 
-  = [(x, lt) | x <- xs
-             , let lx = GM.locNamedThing x
-             , let lt = expand $ lx {val = f x}
-    ]
-  where
-    expand   = Bare.specExpandType rtEnv 
-
-makeFromSet :: String -> (Ms.BareSpec -> S.HashSet LocSymbol) -> Bare.Env -> [(ModName, Ms.BareSpec)] 
-            -> [Ghc.Var] 
-makeFromSet msg f env specs = concat [ mk n xs | (n, s) <- specs, let xs = S.toList (f s)] 
-  where 
-    mk name                 = Mb.mapMaybe (Bare.maybeResolveSym env name msg) 
-
-makeTySigs :: Bare.Env -> Bare.SigEnv -> ModName -> Ms.BareSpec 
-           -> [(Ghc.Var, LocSpecType, Maybe [Located F.Expr])]
-makeTySigs env sigEnv name spec 
-              = [ (x, cook x bt, z) | (x, bt, z) <- rawSigs ]
-  where 
-    rawSigs   = Bare.resolveLocalBinds env expSigs 
-    expSigs   = makeTExpr  env name bareSigs rtEnv spec 
-    bareSigs  = bareTySigs env name                spec 
-    rtEnv     = Bare.sigRTEnv sigEnv 
-    cook x bt = Bare.cookSpecType env sigEnv name (Bare.HsTV x) bt 
-
-bareTySigs :: Bare.Env -> ModName -> Ms.BareSpec -> [(Ghc.Var, LocBareType)]
-bareTySigs env name spec = checkDuplicateSigs 
-  [ (v, t) | (x, t) <- Ms.sigs spec ++ Ms.localSigs spec  
-           , let v   = F.notracepp "LOOKUP-GHC-VAR" $ Bare.lookupGhcVar env name "rawTySigs" x 
-  ] 
-
--- checkDuplicateSigs :: [(Ghc.Var, LocSpecType)] -> [(Ghc.Var, LocSpecType)] 
-checkDuplicateSigs :: (Symbolic x) => [(x, F.Located t)] -> [(x, F.Located t)]
-checkDuplicateSigs xts = case Misc.uniqueByKey symXs  of
-  Left (k, ls) -> uError (errDupSpecs (pprint k) (GM.sourcePosSrcSpan <$> ls))
-  Right _      -> xts 
-  where
-    symXs = [ (F.symbol x, F.loc t) | (x, t) <- xts ]
-
-
-makeAsmSigs :: Bare.Env -> Bare.SigEnv -> ModName -> Bare.ModSpecs -> [(Ghc.Var, LocSpecType)]
-makeAsmSigs env sigEnv myName specs = 
-  [ (x, t) | (name, x, bt) <- rawAsmSigs env myName specs
-           , let t = Bare.cookSpecType env sigEnv name (Bare.LqTV x) bt
-  ] 
-
-rawAsmSigs :: Bare.Env -> ModName -> Bare.ModSpecs -> [(ModName, Ghc.Var, LocBareType)]
-rawAsmSigs env myName specs = 
-  [ (m, v, t) | (v, sigs) <- allAsmSigs env myName specs 
-              , let (m, t) = myAsmSig v sigs 
-  ] 
-    
-myAsmSig :: Ghc.Var -> [(Bool, ModName, LocBareType)] -> (ModName, LocBareType)
-myAsmSig v sigs = Mb.fromMaybe errImp (Misc.firstMaybes [mbHome, mbImp]) 
-  where 
-    mbHome      = takeUnique err                  sigsHome 
-    mbImp       = takeUnique err (Misc.firstGroup sigsImp) -- see [NOTE:Prioritize-Home-Spec] 
-    sigsHome    = [(m, t)      | (True,  m, t) <- sigs ]
-    sigsImp     = F.notracepp ("SIGS-IMP: " ++ F.showpp v)
-                  [(d, (m, t)) | (False, m, t) <- sigs, let d = nameDistance vName m]
-    err ts      = ErrDupSpecs (Ghc.getSrcSpan v) (F.pprint v) (GM.sourcePosSrcSpan . F.loc . snd <$> ts) :: UserError
-    errImp      = impossible Nothing "myAsmSig: cannot happen as sigs is non-null"
-    vName       = GM.takeModuleNames (F.symbol v)
-
-makeTExpr :: Bare.Env -> ModName -> [(Ghc.Var, LocBareType)] -> BareRTEnv -> Ms.BareSpec 
-          -> [(Ghc.Var, LocBareType, Maybe [Located F.Expr])]
-makeTExpr env name tySigs rtEnv spec 
-                = F.notracepp "MAKE-TEXPRS" 
-                  [ (v, t, qual t <$> es) | (v, (t, es)) <- M.toList vSigExprs ] 
-  where 
-    qual t es   = qualifyTermExpr env name rtEnv t <$> es
-    vSigExprs   = Misc.hashMapMapWithKey (\v t -> (t, M.lookup v vExprs)) vSigs 
-    vExprs      = M.fromList (makeVarTExprs env name spec) 
-    vSigs       = M.fromList tySigs 
-                    
-qualifyTermExpr :: Bare.Env -> ModName -> BareRTEnv -> LocBareType -> Located F.Expr 
-                -> Located F.Expr 
-qualifyTermExpr env name rtEnv t le 
-        = F.atLoc le (Bare.qualifyExpand env name rtEnv l bs e)
-  where 
-    l   = F.loc le 
-    e   = F.val le 
-    bs  = ty_binds . toRTypeRep . val $ t 
-
-makeVarTExprs :: Bare.Env -> ModName -> Ms.BareSpec -> [(Ghc.Var, [Located F.Expr])]
-makeVarTExprs env name spec = 
-  [ (Bare.lookupGhcVar env name "Var" x, es) 
-      | (x, es) <- Ms.termexprs spec           ]
-----------------------------------------------------------------------------------------
--- [NOTE:Prioritize-Home-Spec] Prioritize spec for THING defined in 
--- `Foo.Bar.Baz.Quux.x` over any other specification, IF GHC's 
--- fully qualified name for THING is `Foo.Bar.Baz.Quux.x`. 
---
--- For example, see tests/names/neg/T1078.hs for example, 
--- which assumes a spec for `head` defined in both 
--- 
---   (1) Data/ByteString.spec
---   (2) Data/ByteString/Char8.spec 
--- 
--- We end up resolving the `head` in (1) to the @Var@ `Data.ByteString.Char8.head` 
--- even though there is no exact match, just to account for re-exports of "internal"
--- modules and such (see `Resolve.matchMod`). However, we should pick the closer name
--- if its available.
-----------------------------------------------------------------------------------------
-nameDistance :: F.Symbol -> ModName -> Int 
-nameDistance vName tName 
-  | vName == F.symbol tName = 0 
-  | otherwise               = 1
-
-
-takeUnique :: Ex.Exception e => ([a] -> e) -> [a] -> Maybe a
-takeUnique _ []  = Nothing 
-takeUnique _ [x] = Just x 
-takeUnique f xs  = Ex.throw (f xs) 
-
-allAsmSigs :: Bare.Env -> ModName -> Bare.ModSpecs -> [(Ghc.Var, [(Bool, ModName, LocBareType)])]
-allAsmSigs env myName specs = Misc.groupList
-  [ (v, (must, name, t))  
-      | (name, spec) <- M.toList specs
-      , (must, x, t) <- getAsmSigs myName name spec
-      , v            <- Mb.maybeToList (resolveAsmVar env name must x) 
-  ] 
-
-resolveAsmVar :: Bare.Env -> ModName -> Bool -> LocSymbol -> Maybe Ghc.Var 
-resolveAsmVar env name True  lx = Just $ Bare.lookupGhcVar env name "resolveAsmVar-True"  lx
-resolveAsmVar env name False lx = Bare.maybeResolveSym     env name "resolveAsmVar-False" lx  
-
-getAsmSigs :: ModName -> ModName -> Ms.BareSpec -> [(Bool, LocSymbol, LocBareType)]  
-getAsmSigs myName name spec 
-  | myName == name = [ (True,  x,  t) | (x, t) <- Ms.asmSigs spec ] -- MUST    resolve, or error
-  | otherwise      = [ (False, x', t) | (x, t) <- Ms.asmSigs spec 
-                                                  ++ Ms.sigs spec
-                                      , let x' = qSym x           ]  -- MAY-NOT resolve
-  where 
-    qSym           = fmap (GM.qualifySymbol ns) 
-    ns             = F.symbol name
-
--- TODO-REBARE: grepClassAssumes
-_grepClassAssumes :: [RInstance t] -> [(Located F.Symbol, t)]
-_grepClassAssumes  = concatMap go
-  where
-    go    xts              = Mb.mapMaybe goOne (risigs xts)
-    goOne (x, RIAssumed t) = Just (fmap (F.symbol . (".$c" ++ ) . F.symbolString) x, t)
-    goOne (_, RISig _)     = Nothing
-
-makeSigEnv :: F.TCEmb Ghc.TyCon -> Bare.TyConMap -> S.HashSet StableName -> BareRTEnv -> Bare.SigEnv 
-makeSigEnv embs tyi exports rtEnv = Bare.SigEnv
-  { sigEmbs     = embs 
-  , sigTyRTyMap = tyi 
-  , sigExports  = exports 
-  , sigRTEnv    = rtEnv
-  } 
-
-makeNewTypes :: Bare.Env -> Bare.SigEnv -> [(ModName, Ms.BareSpec)] -> [(Ghc.TyCon, LocSpecType)]
-makeNewTypes env sigEnv specs = 
-  [ ct | (name, spec) <- specs
-       , d            <- Ms.newtyDecls spec
-       , ct           <- makeNewType env sigEnv name d 
-  ] 
-
-makeNewType :: Bare.Env -> Bare.SigEnv -> ModName -> DataDecl -> [(Ghc.TyCon, LocSpecType)]
-makeNewType env sigEnv name d 
- | Just tc <- tcMb            = [(tc, t)] 
- | otherwise                  = []
-  where 
-    tcMb                      = Bare.lookupGhcDnTyCon env name "makeNewType" tcName
-    tcName                    = tycName d
-    t                         = Bare.cookSpecType env sigEnv name Bare.GenTV bt
-    bt                        = getTy tcName (tycSrcPos d) (tycDCons d)
-    getTy _ l [c]
-      | [(_, t)] <- dcFields c = Loc l l t
-    getTy n l _                = Ex.throw (err n l) 
-    err n l                    = ErrOther (GM.sourcePosSrcSpan l) ("Bad new type declaration:" <+> F.pprint n) :: UserError
-
-------------------------------------------------------------------------------------------
-makeSpecData :: GhcSrc -> Bare.Env -> Bare.SigEnv -> Bare.MeasEnv -> GhcSpecSig -> Bare.ModSpecs
-             -> GhcSpecData
-------------------------------------------------------------------------------------------
-makeSpecData src env sigEnv measEnv sig specs = SpData 
-  { gsCtors      = -- F.notracepp "GS-CTORS" 
-                   [ (x, tt) 
-                       | (x, t) <- Bare.meDataCons measEnv
-                       , let tt  = Bare.plugHoles sigEnv name (Bare.LqTV x) t 
-                   ]
-  , gsMeas       = [ (F.symbol x, uRType <$> t) | (x, t) <- measVars ] 
-  , gsMeasures   = Bare.qualifyTopDummy env name <$> (ms1 ++ ms2)
-  , gsInvariants = Misc.nubHashOn (F.loc . snd) invs 
-  , gsIaliases   = concatMap (makeIAliases env sigEnv) (M.toList specs)
-  , gsUnsorted   = usI ++ (concatMap msUnSorted $ concatMap measures specs)
-  }
-  where
-    measVars     = Bare.meSyms      measEnv -- ms'
-                ++ Bare.meClassSyms measEnv -- cms' 
-                ++ Bare.varMeasures env
-    measuresSp   = Bare.meMeasureSpec measEnv  
-    ms1          = M.elems (Ms.measMap measuresSp)
-    ms2          =          Ms.imeas   measuresSp
-    mySpec       = M.lookupDefault mempty name specs
-    name         = _giTargetMod      src
-    (minvs,usI)  = makeMeasureInvariants env name sig mySpec
-    invs         = minvs ++ concat (makeInvariants env sigEnv <$> M.toList specs)
-
-makeIAliases :: Bare.Env -> Bare.SigEnv -> (ModName, Ms.BareSpec) -> [(LocSpecType, LocSpecType)]
-makeIAliases env sigEnv (name, spec)
-  = [ z | Right z <- mkIA <$> Ms.ialiases spec ]
-  where 
-    -- mkIA :: (LocBareType, LocBareType) -> Either _ (LocSpecType, LocSpecType)
-    mkIA (t1, t2) = (,) <$> mkI t1 <*> mkI t2
-    mkI           = Bare.cookSpecTypeE env sigEnv name Bare.GenTV 
-
-makeInvariants :: Bare.Env -> Bare.SigEnv -> (ModName, Ms.BareSpec) -> [(Maybe Ghc.Var, Located SpecType)]
-makeInvariants env sigEnv (name, spec) = 
-  [ (Nothing, t) 
-    | (_, bt) <- Ms.invariants spec 
-    , Bare.knownGhcType env name bt
-    , let t = Bare.cookSpecType env sigEnv name Bare.GenTV bt
-  ]
-
-makeMeasureInvariants :: Bare.Env -> ModName -> GhcSpecSig -> Ms.BareSpec 
-                      -> ([(Maybe Ghc.Var, LocSpecType)], [UnSortedExpr])
-makeMeasureInvariants env name sig mySpec 
-  = mapSnd Mb.catMaybes $ 
-    unzip (measureTypeToInv env name <$> [(x, (y, ty)) | x <- xs, (y, ty) <- sigs
-                                         , isSymbolOfVar (val x) y ])
-  where 
-    sigs = gsTySigs sig 
-    xs   = S.toList (Ms.hmeas  mySpec) 
-
-isSymbolOfVar :: Symbol -> Ghc.Var -> Bool
-isSymbolOfVar x v = x == symbol' v
-  where
-    symbol' :: Ghc.Var -> Symbol
-    symbol' = GM.dropModuleNames . symbol . Ghc.getName
-
-measureTypeToInv :: Bare.Env -> ModName -> (LocSymbol, (Ghc.Var, LocSpecType)) -> ((Maybe Ghc.Var, LocSpecType), Maybe UnSortedExpr)
-measureTypeToInv env name (x, (v, t)) 
-  = notracepp "measureTypeToInv" $ ((Just v, t {val = Bare.qualifyTop env name (F.loc x) mtype}), usorted)
-  where
-    trep = toRTypeRep (val t)
-    ts   = ty_args  trep
-    args = ty_binds trep
-    res  = ty_res   trep
-    z    = last args
-    tz   = last ts
-    usorted = if isSimpleADT tz then Nothing else ((mapFst (:[])) <$> mkReft (dummyLoc $ F.symbol v) z tz res)
-    mtype
-      | null ts 
-      = uError $ ErrHMeas (GM.sourcePosSrcSpan $ loc t) (pprint x) "Measure has no arguments!"
-      | otherwise 
-      = mkInvariant x z tz res 
-    isSimpleADT (RApp _ ts _ _) = all isRVar ts 
-    isSimpleADT _               = False 
-
-mkInvariant :: LocSymbol -> Symbol -> SpecType -> SpecType -> SpecType
-mkInvariant x z t tr = strengthen (top <$> t) (MkUReft reft mempty)
-      where
-        reft  = Mb.maybe mempty Reft mreft
-        mreft = mkReft x z t tr 
-
-
-mkReft :: LocSymbol -> Symbol -> SpecType -> SpecType -> Maybe (Symbol, Expr)
-mkReft x z _t tr 
-  | Just q <- stripRTypeBase tr
-  = let Reft (v, p) = toReft q
-        su          = mkSubst [(v, mkEApp x [EVar v])]
-        p'          = pAnd $ filter (\e -> z `notElem` syms e) $ conjuncts p
-    in  Just (v, subst su p')
-mkReft _ _ _ _  
-  = Nothing 
-
-
--- REBARE: formerly, makeGhcSpec3
--------------------------------------------------------------------------------------------
-makeSpecName :: Bare.Env -> Bare.TycEnv -> Bare.MeasEnv -> ModName -> GhcSpecNames
--------------------------------------------------------------------------------------------
-makeSpecName env tycEnv measEnv name = SpNames 
-  { gsFreeSyms = Bare.reSyms env 
-  , gsDconsP   = [ F.atLoc dc (dcpCon dc) | dc <- datacons ++ cls ] 
-  , gsTconsP   = Bare.qualifyTopDummy env name <$> tycons                
-  -- , gsLits = mempty                                              -- TODO-REBARE, redundant with gsMeas
-  , gsTcEmbeds = Bare.tcEmbs     tycEnv   
-  , gsADTs     = Bare.tcAdts     tycEnv 
-  , gsTyconEnv = Bare.tcTyConMap tycEnv  
-  }
-  where 
-    datacons, cls :: [DataConP]
-    datacons   = Bare.tcDataCons tycEnv 
-    cls        = F.notracepp "meClasses" $ Bare.meClasses measEnv 
-    tycons     = Bare.tcTyCons   tycEnv 
-
-
--- REBARE: formerly, makeGhcCHOP1
--------------------------------------------------------------------------------------------
-makeTycEnv :: Config -> ModName -> Bare.Env -> TCEmb Ghc.TyCon -> Ms.BareSpec -> Bare.ModSpecs 
-           -> Bare.TycEnv 
--------------------------------------------------------------------------------------------
-makeTycEnv cfg myName env embs mySpec iSpecs = Bare.TycEnv 
-  { tcTyCons      = tycons                  
-  , tcDataCons    = val <$> datacons 
-  , tcSelMeasures = dcSelectors             
-  , tcSelVars     = recSelectors            
-  , tcTyConMap    = tyi                     
-  , tcAdts        = adts                    
-  , tcDataConMap  = dm
-  , tcEmbs        = embs
-  , tcName        = myName
-  }
-  where 
-    (tcDds, dcs)  = Misc.concatUnzip $ Bare.makeConTypes env <$> specs 
-    specs         = (myName, mySpec) : M.toList iSpecs
-    tcs           = Misc.snd3 <$> tcDds 
-    tyi           = Bare.qualifyTopDummy env myName (makeTyConInfo embs fiTcs tycons)
-    -- tycons        = F.tracepp "TYCONS" $ Misc.replaceWith tcpCon tcs wiredTyCons
-    -- datacons      =  Bare.makePluggedDataCons embs tyi (Misc.replaceWith (dcpCon . val) (F.tracepp "DATACONS" $ concat dcs) wiredDataCons)
-    tycons        = tcs ++ knownWiredTyCons env myName 
-    datacons      = Bare.makePluggedDataCon embs tyi <$> (concat dcs ++ knownWiredDataCons env myName)
-    tds           = [(name, tcpCon tcp, dd) | (name, tcp, Just dd) <- tcDds]
-    adts          = Bare.makeDataDecls cfg embs myName tds       datacons
-    dm            = Bare.dataConMap adts
-    dcSelectors   = concatMap (Bare.makeMeasureSelectors cfg dm) datacons
-    recSelectors  = Bare.makeRecordSelectorSigs env myName       datacons
-    fiTcs         = _gsFiTcs (Bare.reSrc env)
-   
-knownWiredDataCons :: Bare.Env -> ModName -> [Located DataConP] 
-knownWiredDataCons env name = filter isKnown wiredDataCons 
-  where 
-    isKnown                 = Bare.knownGhcDataCon env name . GM.namedLocSymbol . dcpCon . val
-
-knownWiredTyCons :: Bare.Env -> ModName -> [TyConP] 
-knownWiredTyCons env name = filter isKnown wiredTyCons 
-  where 
-    isKnown               = Bare.knownGhcTyCon env name . GM.namedLocSymbol . tcpCon 
-
-
--- REBARE: formerly, makeGhcCHOP2
--------------------------------------------------------------------------------------------
-makeMeasEnv :: Bare.Env -> Bare.TycEnv -> Bare.SigEnv -> Bare.ModSpecs -> Bare.MeasEnv 
--------------------------------------------------------------------------------------------
-makeMeasEnv env tycEnv sigEnv specs = Bare.MeasEnv 
-  { meMeasureSpec = measures 
-  , meClassSyms   = cms' 
-  , meSyms        = ms' 
-  , meDataCons    = cs' 
-  , meClasses     = cls
-  , meMethods     = mts ++ dms 
-  , meCLaws       = laws
-  }
-  where 
-    measures      = mconcat (Ms.mkMSpec' dcSelectors : (Bare.makeMeasureSpec env sigEnv name <$> M.toList specs))
-    (cs, ms)      = Bare.makeMeasureSpec'     measures
-    cms           = Bare.makeClassMeasureSpec measures
-    cms'          = [ (x, Loc l l' $ cSort t)  | (Loc l l' x, t) <- cms ]
-    ms'           = [ (F.val lx, F.atLoc lx t) | (lx, t) <- ms
-                                               , Mb.isNothing (lookup (val lx) cms') ]
-    cs'           = [ (v, txRefs v t) | (v, t) <- Bare.meetDataConSpec embs cs (datacons ++ cls)]
-    txRefs v t    = Bare.txRefSort tyi embs (const t <$> GM.locNamedThing v) 
-    -- unpacking the environment
-    tyi           = Bare.tcTyConMap    tycEnv 
-    dcSelectors   = Bare.tcSelMeasures tycEnv 
-    datacons      = Bare.tcDataCons    tycEnv 
-    embs          = Bare.tcEmbs        tycEnv 
-    name          = Bare.tcName        tycEnv
-    dms           = Bare.makeDefaultMethods env mts  
-    (cls, mts)    = Bare.makeClasses        env sigEnv name specs
-    laws          = Bare.makeCLaws env sigEnv name specs
-
------------------------------------------------------------------------------------------
--- | @makeLiftedSpec@ is used to generate the BareSpec object that should be serialized 
---   so that downstream files that import this target can access the lifted definitions, 
---   e.g. for measures, reflected functions etc.
------------------------------------------------------------------------------------------
-makeLiftedSpec :: GhcSrc -> Bare.Env 
-               -> GhcSpecRefl -> GhcSpecData -> GhcSpecSig -> GhcSpecQual -> BareRTEnv 
-               -> Ms.BareSpec -> Ms.BareSpec 
------------------------------------------------------------------------------------------
-makeLiftedSpec src _env refl sData sig qual myRTE lSpec0 = lSpec0 
-  { Ms.asmSigs    = F.notracepp   "LIFTED-ASM-SIGS" $ xbs -- ++ mkSigs (gsAsmSigs sig)
-  , Ms.reflSigs   = F.notracepp "REFL-SIGS"         xbs
-  , Ms.sigs       = F.notracepp   "LIFTED-SIGS"     $        mkSigs (gsTySigs sig)  
-  , Ms.invariants = [ ((varLocSym <$> x), Bare.specToBare <$> t) 
-                       | (x, t) <- gsInvariants sData 
-                       , isLocInFile srcF t
-                    ]
-  , Ms.axeqs      = gsMyAxioms refl 
-  , Ms.aliases    = F.notracepp "MY-ALIASES" $ M.elems . typeAliases $ myRTE
-  , Ms.ealiases   = M.elems . exprAliases $ myRTE 
-  , Ms.qualifiers = filter (isLocInFile srcF) (gsQualifiers qual)
-  }
-  where
-    mkSigs xts    = [ toBare (x, t) | (x, t) <- xts
-                    ,  S.member x sigVars && (isExportedVar (view targetSrcIso src) x) 
-                    ] 
-    toBare (x, t) = (varLocSym x, Bare.specToBare <$> t)
-    xbs           = toBare <$> reflTySigs 
-    sigVars       = S.difference defVars reflVars
-    defVars       = S.fromList (_giDefVars src)
-    reflTySigs    = [(x, t) | (x,t,_) <- gsHAxioms refl, x `notElem` gsWiredReft refl]
-    reflVars      = S.fromList (fst <$> reflTySigs)
-    -- myAliases fld = M.elems . fld $ myRTE 
-    srcF          = _giTarget src 
-
--- | Returns 'True' if the input determines a location within the input file. Due to the fact we might have
--- Haskell sources which have \"companion\" specs defined alongside them, we also need to account for this
--- case, by stripping out the extensions and check that the LHS is a Haskell source and the RHS a spec file.
-isLocInFile :: (F.Loc a) => FilePath -> a ->  Bool 
-isLocInFile f lx = f == lifted || isCompanion
-  where
-    lifted :: FilePath
-    lifted = locFile lx
-
-    isCompanion :: Bool
-    isCompanion =
-      (==) (dropExtension f) (dropExtension lifted)
-       &&  isExtFile Hs f
-       &&  isExtFile Files.Spec lifted
-
-locFile :: (F.Loc a) => a -> FilePath 
-locFile = Misc.fst3 . F.sourcePosElts . F.sp_start . F.srcSpan
-
-varLocSym :: Ghc.Var -> LocSymbol
-varLocSym v = F.symbol <$> GM.locNamedThing v
-
--- makeSpecRTAliases :: Bare.Env -> BareRTEnv -> [Located SpecRTAlias]
--- makeSpecRTAliases _env _rtEnv = [] -- TODO-REBARE 
-
-
---------------------------------------------------------------------------------
--- | @myRTEnv@ slices out the part of RTEnv that was generated by aliases defined 
---   in the _target_ file, "cooks" the aliases (by conversion to SpecType), and 
---   then saves them back as BareType.
---------------------------------------------------------------------------------
-myRTEnv :: GhcSrc -> Bare.Env -> Bare.SigEnv -> BareRTEnv -> BareRTEnv 
-myRTEnv src env sigEnv rtEnv = mkRTE tAs' eAs 
-  where 
-    tAs'                     = normalizeBareAlias env sigEnv name <$> tAs
-    tAs                      = myAliases typeAliases 
-    eAs                      = myAliases exprAliases 
-    myAliases fld            = filter (isLocInFile srcF) . M.elems . fld $ rtEnv 
-    srcF                     = _giTarget    src
-    name                     = _giTargetMod src
-  
-mkRTE :: [Located (RTAlias x a)] -> [Located (RTAlias F.Symbol F.Expr)] -> RTEnv x a 
-mkRTE tAs eAs   = RTE 
-  { typeAliases = M.fromList [ (aName a, a) | a <- tAs ] 
-  , exprAliases = M.fromList [ (aName a, a) | a <- eAs ] 
-  } 
-  where aName   = rtName . F.val  
-
-normalizeBareAlias :: Bare.Env -> Bare.SigEnv -> ModName -> Located BareRTAlias 
-                   -> Located BareRTAlias 
-normalizeBareAlias env sigEnv name lx = fixRTA <$> lx
-  where 
-    fixRTA  :: BareRTAlias -> BareRTAlias 
-    fixRTA  = mapRTAVars fixArg . fmap fixBody 
-
-    fixArg  :: Symbol -> Symbol 
-    fixArg  = F.symbol . GM.symbolTyVar 
-      
-    fixBody :: BareType -> BareType 
-    fixBody = Bare.specToBare 
-            . F.val 
-            . Bare.cookSpecType env sigEnv name Bare.RawTV 
-            . F.atLoc lx
-
diff --git a/src/Language/Haskell/Liquid/Bare/Axiom.hs b/src/Language/Haskell/Liquid/Bare/Axiom.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Axiom.hs
+++ /dev/null
@@ -1,258 +0,0 @@
-{-# LANGUAGE OverloadedStrings    #-}
-{-# LANGUAGE FlexibleContexts     #-}
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-
--- | This module contains the code that DOES reflection; i.e. converts Haskell
---   definitions into refinements.
-
-module Language.Haskell.Liquid.Bare.Axiom ( makeHaskellAxioms, wiredReflects ) where
-
-import Prelude hiding (error)
-import Prelude hiding (mapM)
-import qualified Control.Exception         as Ex
-
--- import           Control.Monad.Except      hiding (forM, mapM)
--- import           Control.Monad.State       hiding (forM, mapM)
-import qualified Text.PrettyPrint.HughesPJ as PJ -- (text)
-import qualified Data.HashSet              as S
-import qualified Data.Maybe                as Mb 
-import Control.Monad.Trans.State.Lazy (runState, get, put)
-
-import           Language.Fixpoint.Misc
-import qualified Language.Haskell.Liquid.Measure as Ms
-import qualified Language.Fixpoint.Types as F
-import qualified Language.Haskell.Liquid.GHC.API as Ghc 
-import qualified Language.Haskell.Liquid.GHC.Misc as GM 
-import           Language.Haskell.Liquid.Types.RefType
-import           Language.Haskell.Liquid.Transforms.CoreToLogic
-import           Language.Haskell.Liquid.GHC.Misc
-import           Language.Haskell.Liquid.Types
-
-import           Language.Haskell.Liquid.Bare.Resolve as Bare
-import           Language.Haskell.Liquid.Bare.Types   as Bare
-
-
-import IdInfo
-import BasicTypes
-
------------------------------------------------------------------------------------------------
-makeHaskellAxioms :: Config -> GhcSrc -> Bare.Env -> Bare.TycEnv -> ModName -> LogicMap -> GhcSpecSig -> Ms.BareSpec 
-                  -> [(Ghc.Var, LocSpecType, F.Equation)]
------------------------------------------------------------------------------------------------
-makeHaskellAxioms cfg src env tycEnv name lmap spSig spec 
-  = fmap (makeAxiom env tycEnv name lmap) 
-         (wiredDefs cfg env name spSig ++ getReflectDefs src spSig spec) 
-
-getReflectDefs :: GhcSrc -> GhcSpecSig -> Ms.BareSpec 
-               -> [(LocSymbol, Maybe SpecType, Ghc.Var, Ghc.CoreExpr)]
-getReflectDefs src sig spec = findVarDefType cbs sigs <$> xs
-  where
-    sigs                    = gsTySigs sig 
-    xs                      = S.toList (Ms.reflects spec)
-    cbs                     = _giCbs src
-
-findVarDefType :: [Ghc.CoreBind] -> [(Ghc.Var, LocSpecType)] -> LocSymbol
-               -> (LocSymbol, Maybe SpecType, Ghc.Var, Ghc.CoreExpr)
-findVarDefType cbs sigs x = case findVarDef (val x) cbs of
-  Just (v, e) -> if Ghc.isExportedId v
-                   then (x, val <$> lookup v sigs, v, e)
-                   else Ex.throw $ mkError x ("Lifted functions must be exported; please export " ++ show v)
-  Nothing     -> Ex.throw $ mkError x "Cannot lift haskell function"
-
---------------------------------------------------------------------------------
-makeAxiom :: Bare.Env -> Bare.TycEnv -> ModName -> LogicMap 
-          -> (LocSymbol, Maybe SpecType, Ghc.Var, Ghc.CoreExpr)
-          -> (Ghc.Var, LocSpecType, F.Equation)
---------------------------------------------------------------------------------
-makeAxiom env tycEnv name lmap (x, mbT, v, def) 
-            = (v, t, e)
-  where 
-    t       = Bare.qualifyTop env name (F.loc t0) t0 
-    (t0, e) = makeAssumeType embs lmap dm x mbT v def
-    embs    = Bare.tcEmbs       tycEnv 
-    dm      = Bare.tcDataConMap tycEnv 
-
-mkError :: LocSymbol -> String -> Error
-mkError x str = ErrHMeas (sourcePosSrcSpan $ loc x) (pprint $ val x) (PJ.text str)
-
-makeAssumeType
-  :: F.TCEmb Ghc.TyCon -> LogicMap -> DataConMap -> LocSymbol -> Maybe SpecType
-  -> Ghc.Var -> Ghc.CoreExpr
-  -> (LocSpecType, F.Equation)
-makeAssumeType tce lmap dm x mbT v def
-  = (x {val = aty at `strengthenRes` F.subst su ref},  F.mkEquation (val x) xts (F.subst su le) out)
-  where
-    t     = Mb.fromMaybe (ofType τ) mbT
-    τ     = Ghc.varType v
-    at    = axiomType x t
-    out   = rTypeSort tce $ ares at 
-    xArgs = (F.EVar . fst) <$> aargs at
-    _msg  = unwords [showpp x, showpp mbT]
-    le    = case runToLogicWithBoolBinds bbs tce lmap dm mkErr (coreToLogic  def') of
-              Right e -> e
-              Left  e -> panic Nothing (show e)
-    ref        = F.Reft (F.vv_, F.PAtom F.Eq (F.EVar F.vv_) le)
-    mkErr s    = ErrHMeas (sourcePosSrcSpan $ loc x) (pprint $ val x) (PJ.text s)
-    bbs        = filter isBoolBind xs
-    (xs, def') = grabBody (Ghc.expandTypeSynonyms τ) $ normalize def
-    su         = F.mkSubst  $ zip (F.symbol     <$> xs) xArgs
-                           ++ zip (simplesymbol <$> xs) xArgs
-    xts        = [(F.symbol x, rTypeSortExp tce t) | (x, t) <- aargs at]
-
-rTypeSortExp :: F.TCEmb Ghc.TyCon -> SpecType -> F.Sort
-rTypeSortExp tce = typeSort tce . Ghc.expandTypeSynonyms . toType
-
-grabBody :: Ghc.Type -> Ghc.CoreExpr -> ([Ghc.Var], Ghc.CoreExpr)
-grabBody (Ghc.ForAllTy _ t) e 
-  = grabBody t e 
-grabBody (Ghc.FunTy { Ghc.ft_arg = tx, Ghc.ft_res = t}) e | Ghc.isClassPred tx 
-  = grabBody t e 
-grabBody (Ghc.FunTy { Ghc.ft_res = t}) (Ghc.Lam x e) 
-  = (x:xs, e') where (xs, e') = grabBody t e
-grabBody t (Ghc.Tick _ e) 
-  = grabBody t e
-grabBody t@(Ghc.FunTy {}) e               
-  = (txs++xs, e') 
-   where (ts,tr)  = splitFun t 
-         (xs, e') = grabBody tr (foldl Ghc.App e (Ghc.Var <$> txs))
-         txs      = [ stringVar ("ls" ++ show i) t |  (t,i) <- zip ts [1..]]
-grabBody _ e              
-  = ([], e)
-
-splitFun :: Ghc.Type -> ([Ghc.Type], Ghc.Type)
-splitFun = go [] 
-  where go acc (Ghc.FunTy { Ghc.ft_arg = tx, Ghc.ft_res = t}) = go (tx:acc) t 
-        go acc t                                              = (reverse acc, t)
-
-
-isBoolBind :: Ghc.Var -> Bool
-isBoolBind v = isBool (ty_res $ toRTypeRep ((ofType $ Ghc.varType v) :: RRType ()))
-
-strengthenRes :: SpecType -> F.Reft -> SpecType
-strengthenRes t r = go t 
-  where 
-    go (RAllT a t r)   = RAllT a (go t) r  
-    go (RAllP p t)     = RAllP p $ go t
-    go (RFun x tx t r) = RFun x tx (go t) r 
-    go t               =  t `strengthen` F.ofReft r 
-
-class Subable a where
-  subst :: (Ghc.Var, Ghc.CoreExpr) -> a -> a
-
-instance Subable Ghc.Var where
-  subst (x, ex) z 
-    | x == z, Ghc.Var y <- ex = y
-    | otherwise           = z
-
-instance Subable Ghc.CoreExpr where
-  subst (x, ex) (Ghc.Var y)
-    | x == y    = ex
-    | otherwise = Ghc.Var y
-  subst su (Ghc.App f e)
-    = Ghc.App (subst su f) (subst su e)
-  subst su (Ghc.Lam x e)
-    = Ghc.Lam x (subst su e)
-  subst su (Ghc.Case e x t alts)
-    = Ghc.Case (subst su e) x t (subst su <$> alts)
-  subst su (Ghc.Let (Ghc.Rec xes) e)
-    = Ghc.Let (Ghc.Rec (mapSnd (subst su) <$> xes)) (subst su e)
-  subst su (Ghc.Let (Ghc.NonRec x ex) e)
-    = Ghc.Let (Ghc.NonRec x (subst su ex)) (subst su e)
-  subst su (Ghc.Cast e t)
-    = Ghc.Cast (subst su e) t
-  subst su (Ghc.Tick t e)
-    = Ghc.Tick t (subst su e)
-  subst _ e 
-    = e 
-
-instance Subable Ghc.CoreAlt where
-  subst su (c, xs, e) = (c, xs, subst su e)
-
-data AxiomType = AT { aty :: SpecType, aargs :: [(F.Symbol, SpecType)], ares :: SpecType }
-
--- | Specification for Haskell function
-axiomType :: LocSymbol -> SpecType -> AxiomType
-axiomType s t = AT to (reverse xts) res  
-  where
-    (to, (_,xts, Just res)) = runState (go t) (1,[], Nothing)
-    go (RAllT a t r) = RAllT a <$> go t <*> return r 
-    go (RAllP p t) = RAllP p <$> go t 
-    go (RFun x tx t r) | isClassType tx = (\t' -> RFun x tx t' r) <$> go t
-    go (RFun x tx t r) = do 
-      (i,bs,res) <- get 
-      let x' = unDummy x i 
-      put (i+1, (x', tx):bs,res)
-      t' <- go t 
-      return $ RFun x' tx t' r 
-    go t = do 
-      (i,bs,_) <- get 
-      let ys = reverse $ map fst bs
-      let t' = strengthen t (singletonApp s ys)
-      put (i, bs, Just t')
-      return t' 
-
-unDummy :: F.Symbol -> Int -> F.Symbol
-unDummy x i
-  | x /= F.dummySymbol = x
-  | otherwise          = F.symbol ("lq" ++ show i)
-
-singletonApp :: F.Symbolic a => LocSymbol -> [a] -> UReft F.Reft
-singletonApp s ys = MkUReft r mempty
-  where
-    r             = F.exprReft (F.mkEApp s (F.eVar <$> ys))
-
-
--------------------------------------------------------------------------------
--- | Hardcode imported reflected functions ------------------------------------
--------------------------------------------------------------------------------
-
-
-wiredReflects :: Config -> Bare.Env -> ModName -> GhcSpecSig 
-              -> [Ghc.Var]
-wiredReflects cfg env name sigs = [v | (_, _, v, _) <- wiredDefs cfg env name sigs ]
-
-
-wiredDefs :: Config -> Bare.Env -> ModName -> GhcSpecSig 
-          -> [(LocSymbol, Maybe SpecType, Ghc.Var, Ghc.CoreExpr)]
-wiredDefs cfg env name spSig
-  | reflection cfg 
-  = [ functionCompositionDef ]
-  | otherwise
-  = []
-  where 
-    functionCompositionDef = (x, fmap F.val $ lookup v (gsTySigs spSig), v, makeCompositionExpression v)
-    x = F.dummyLoc functionComposisionSymbol
-    v = Bare.lookupGhcVar env name "wiredAxioms" x
-
--------------------------------------------------------------------------------
--- | Expression Definitions of Prelude Functions ------------------------------
--- | NV: Currently Just Hacking Composition       -----------------------------
--------------------------------------------------------------------------------
-
-
-makeCompositionExpression :: Ghc.Id -> Ghc.CoreExpr 
-makeCompositionExpression x 
-  =  go $ Ghc.varType $ F.notracepp ( -- tracing to find  the body of . from the inline spec, 
-                                      -- replace F.notrace with F.trace to print 
-      "\nv = " ++ GM.showPpr x ++ 
-      "\n realIdUnfolding = " ++ GM.showPpr (Ghc.realIdUnfolding x) ++ 
-      "\n maybeUnfoldingTemplate . realIdUnfolding = " ++ GM.showPpr (Ghc.maybeUnfoldingTemplate $ Ghc.realIdUnfolding x ) ++ 
-      "\n inl_src . inlinePragInfo . Ghc.idInfo = "    ++ GM.showPpr (inl_src $ inlinePragInfo $ Ghc.idInfo x) ++ 
-      "\n inl_inline . inlinePragInfo . Ghc.idInfo = " ++ GM.showPpr (inl_inline $ inlinePragInfo $ Ghc.idInfo x) ++ 
-      "\n inl_sat . inlinePragInfo . Ghc.idInfo = "    ++ GM.showPpr (inl_sat $ inlinePragInfo $ Ghc.idInfo x) ++ 
-      "\n inl_act . inlinePragInfo . Ghc.idInfo = "    ++ GM.showPpr (inl_act $ inlinePragInfo $ Ghc.idInfo x) ++ 
-      "\n inl_rule . inlinePragInfo . Ghc.idInfo = "   ++ GM.showPpr (inl_rule $ inlinePragInfo $ Ghc.idInfo x) ++ 
-      "\n inl_rule rule = " ++ GM.showPpr (inl_rule $ inlinePragInfo $ Ghc.idInfo x) ++ 
-      "\n inline spec = " ++ GM.showPpr (inl_inline $ inlinePragInfo $ Ghc.idInfo x)  
-     ) x 
-   where  
-    go (Ghc.ForAllTy a (Ghc.ForAllTy b (Ghc.ForAllTy c (Ghc.FunTy { Ghc.ft_arg = tf, Ghc.ft_res = Ghc.FunTy { Ghc.ft_arg = tg, Ghc.ft_res = tx}}))))
-      = let f = stringVar "f" tf 
-            g = stringVar "g" tg
-            x = stringVar "x" tx 
-        in Ghc.Lam (Ghc.binderVar a) $ 
-           Ghc.Lam (Ghc.binderVar b) $ 
-           Ghc.Lam (Ghc.binderVar c) $ 
-           Ghc.Lam f $ Ghc.Lam g $ Ghc.Lam x $ Ghc.App (Ghc.Var f) (Ghc.App (Ghc.Var g) (Ghc.Var x))
-    go _ = error "Axioms.go"
diff --git a/src/Language/Haskell/Liquid/Bare/Check.hs b/src/Language/Haskell/Liquid/Bare/Check.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Check.hs
+++ /dev/null
@@ -1,727 +0,0 @@
-{-# LANGUAGE ParallelListComp    #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE FlexibleContexts    #-}
-{-# LANGUAGE TupleSections       #-}
-{-# LANGUAGE RecordWildCards     #-}
-{-# LANGUAGE OverloadedStrings   #-}
-
-module Language.Haskell.Liquid.Bare.Check 
-  ( checkTargetSpec
-  , checkBareSpec
-  ) where
-
-import           Language.Haskell.Liquid.Constraint.ToFixpoint
-import           Language.Haskell.Liquid.GHC.API          as Ghc hiding (Located) 
-import           Control.Applicative                       ((<|>))
-import           Control.Arrow                             ((&&&))
-import           Data.Maybe
-import           Data.Function                             (on)
-import           Text.PrettyPrint.HughesPJ                 hiding ((<>))
-import qualified Data.List                                 as L
-import qualified Data.HashMap.Strict                       as M
-import qualified Data.HashSet                              as S
-import           Data.Hashable
-import qualified Language.Fixpoint.Misc                    as Misc  
-import           Language.Fixpoint.SortCheck               (checkSorted, checkSortedReftFull, checkSortFull)
-import qualified Language.Fixpoint.Types                   as F 
-import qualified Language.Haskell.Liquid.GHC.Misc          as GM 
-import           Language.Haskell.Liquid.Misc              (condNull, snd4)
-import           Language.Haskell.Liquid.Types
-import           Language.Haskell.Liquid.WiredIn
-import           Language.Haskell.Liquid.LawInstances      (checkLawInstances)
-
-import qualified Language.Haskell.Liquid.Measure           as Ms
-import qualified Language.Haskell.Liquid.Bare.Types        as Bare 
-import qualified Language.Haskell.Liquid.Bare.Resolve      as Bare 
-
-
-----------------------------------------------------------------------------------------------
--- | Checking BareSpec ------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-checkBareSpec :: ModName -> Ms.BareSpec -> Either Diagnostics ()
-checkBareSpec _ sp
-  | allChecks == emptyDiagnostics = Right ()
-  | otherwise = Left allChecks
-  where
-    allChecks = mconcat [ checkUnique   "measure"    measures
-                        , checkUnique   "field"      fields
-                        , checkDisjoints             [ inlines
-                                                     , hmeasures
-                                                     , S.fromList measures
-                                                     , reflects
-                                                     , S.fromList fields
-                                                     ]
-                        ]
-    inlines   = Ms.inlines    sp
-    hmeasures = Ms.hmeas      sp
-    reflects  = Ms.reflects   sp
-    measures  = msName    <$> Ms.measures sp
-    fields    = concatMap dataDeclFields (Ms.dataDecls sp)
-
-dataDeclFields :: DataDecl -> [F.LocSymbol]
-dataDeclFields = filter (not . GM.isTmpSymbol . F.val) 
-               . Misc.hashNubWith val 
-               . concatMap dataCtorFields 
-               . tycDCons
-
-dataCtorFields :: DataCtor -> [F.LocSymbol]
-dataCtorFields c 
-  | isGadt c  = [] 
-  | otherwise = F.atLoc c <$> [ f | (f,_) <- dcFields c ]
-
-isGadt :: DataCtor -> Bool 
-isGadt = isJust . dcResult 
-
-checkUnique :: String -> [F.LocSymbol] -> Diagnostics
-checkUnique _ = mkDiagnostics mempty . checkUnique' F.val GM.fSrcSpan 
-
-checkUnique' :: (PPrint a, Eq a, Hashable a) 
-             => (t -> a) -> (t -> Ghc.SrcSpan) -> [t] -> [Error]
-checkUnique' nameF locF ts = [ErrDupSpecs l (pprint n) ls | (n, ls@(l:_)) <- dups] 
--- mkErr <$> dups
-  where
-    -- mkErr (n, ls@(l:_))    = ErrDupSpecs l (pprint n) ls
-    dups                   = [ z      | z@(_, _:_:_) <- Misc.groupList nts       ] 
-    nts                    = [ (n, l) | t <- ts, let n = nameF t, let l = locF t ]
-
-checkDisjoints :: [S.HashSet F.LocSymbol] -> Diagnostics
-checkDisjoints []     = emptyDiagnostics
-checkDisjoints [_]    = emptyDiagnostics
-checkDisjoints (s:ss) = checkDisjoint s (S.unions ss) <> checkDisjoints ss
-
-checkDisjoint :: S.HashSet F.LocSymbol -> S.HashSet F.LocSymbol -> Diagnostics
-checkDisjoint s1 s2 = checkUnique "disjoint" (S.toList s1 ++ S.toList s2)
-
-----------------------------------------------------------------------------------------------
--- | Checking TargetSpec
-----------------------------------------------------------------------------------------------
-
-checkTargetSpec :: [Ms.BareSpec]
-                -> TargetSrc
-                -> F.SEnv F.SortedReft
-                -> [CoreBind]
-                -> TargetSpec
-                -> Either Diagnostics ()
-checkTargetSpec specs src env cbs sp
-  | diagnostics == emptyDiagnostics = Right ()
-  | otherwise                       = Left diagnostics
-  where
-    diagnostics      :: Diagnostics
-    diagnostics      =  foldMap (checkBind allowHO bsc "measure"      emb tcEnv env) (gsMeas       (gsData sp))
-                     <> condNull noPrune
-                        (foldMap (checkBind allowHO bsc "constructor"  emb tcEnv env) (txCtors $ gsCtors      (gsData sp)))
-                     <> foldMap (checkBind allowHO bsc "assume"       emb tcEnv env) (gsAsmSigs    (gsSig sp))
-                     <> foldMap (checkBind allowHO bsc "reflect"      emb tcEnv env) (gsRefSigs    (gsSig sp))
-                     <> checkTySigs         allowHO bsc cbs            emb tcEnv env                (gsSig sp)
-                     -- ++ mapMaybe (checkTerminationExpr             emb       env) (gsTexprs     (gsSig  sp))
-                     <> foldMap (checkBind allowHO bsc "class method" emb tcEnv env) (clsSigs      (gsSig sp))
-                     <> foldMap (checkInv allowHO bsc emb tcEnv env)                 (gsInvariants (gsData sp))
-                     <> checkIAl allowHO bsc emb tcEnv env                            (gsIaliases   (gsData sp))
-                     <> checkMeasures emb env ms
-                     <> checkClassMeasures                                        (gsMeasures (gsData sp))
-                     <> checkClassMethods (gsCls src) (gsCMethods (gsVars sp)) (gsTySigs     (gsSig sp))
-                     <> foldMap checkMismatch sigs
-                     <> checkDuplicate                                            (gsTySigs     (gsSig sp))
-                     -- TODO-REBARE ++ checkQualifiers env                                       (gsQualifiers (gsQual sp))
-                     <> checkDuplicate                                            (gsAsmSigs    (gsSig sp))
-                     <> checkDupIntersect                                         (gsTySigs (gsSig sp)) (gsAsmSigs (gsSig sp))
-                     <> checkRTAliases "Type Alias" env            tAliases
-                     <> checkRTAliases "Pred Alias" env            eAliases
-                     -- ++ _checkDuplicateFieldNames                   (gsDconsP sp)
-                     -- NV TODO: allow instances of refined classes to be refined
-                     -- but make sure that all the specs are checked.
-                     -- ++ checkRefinedClasses                        rClasses rInsts
-                     <> checkSizeFun emb env                                      (gsTconsP (gsName sp))
-                     <> checkPlugged (catMaybes [ fmap (F.dropSym 2 $ GM.simplesymbol x,) (getMethodType t) | (x, t) <- gsMethods (gsSig sp) ])
-                     <> checkLawInstances (gsLaws sp)
-                     <> checkRewrites sp
-
-    _rClasses         = concatMap (Ms.classes  ) specs
-    _rInsts           = concatMap (Ms.rinstance) specs
-    tAliases          = concat [Ms.aliases sp  | sp <- specs]
-    eAliases          = concat [Ms.ealiases sp | sp <- specs]
-    emb              = gsTcEmbeds (gsName sp)
-    tcEnv            = gsTyconEnv (gsName sp)
-    ms               = gsMeasures (gsData sp)
-    clsSigs sp       = [ (v, t) | (v, t) <- gsTySigs sp, isJust (isClassOpId_maybe v) ]
-    sigs             = gsTySigs (gsSig sp) ++ gsAsmSigs (gsSig sp) ++ gsCtors (gsData sp)
-    allowHO          = higherOrderFlag sp
-    bsc              = bscope (getConfig sp)
-    noPrune          = not (pruneFlag sp)
-    txCtors ts       = [(v, fmap (fmap (fmap (F.filterUnMatched temps))) t) | (v, t) <- ts]
-    temps            = F.makeTemplates $ gsUnsorted $ gsData sp
-    -- env'             = L.foldl' (\e (x, s) -> insertSEnv x (RR s mempty) e) env wiredSortedSyms
-
-
-
-
-
-checkPlugged :: PPrint v => [(v, LocSpecType)] -> Diagnostics
-checkPlugged xs = mkDiagnostics mempty (map mkErr (filter (hasHoleTy . val . snd) xs))
-  where
-    mkErr (x,t) = ErrBadData (GM.sourcePosSrcSpan $ loc t) (pprint x) msg
-    msg        = "Cannot resolve type hole `_`. Use explicit type instead."
-
-
---------------------------------------------------------------------------------
-checkTySigs :: Bool
-            -> BScope
-            -> [CoreBind]
-            -> F.TCEmb TyCon
-            -> Bare.TyConMap
-            -> F.SEnv F.SortedReft
-            -> GhcSpecSig
-            -> Diagnostics
---------------------------------------------------------------------------------
-checkTySigs allowHO bsc cbs emb tcEnv env sig
-                   = mconcat (map (check env) topTs)
-                     -- (mapMaybe   (checkT env) [ (x, t)     | (x, (t, _)) <- topTs])
-                     -- ++ (mapMaybe   (checkE env) [ (x, t, es) | (x, (t, Just es)) <- topTs])
-                  <> coreVisitor checkVisitor env emptyDiagnostics cbs
-  where
-    check env      = checkSigTExpr allowHO bsc emb tcEnv env
-    locTm          = M.fromList locTs
-    (locTs, topTs) = Bare.partitionLocalBinds vtes
-    vtes           = [ (x, (t, es)) | (x, t) <- gsTySigs sig, let es = M.lookup x vExprs]
-    vExprs         = M.fromList  [ (x, es) | (x, _, es) <- gsTexprs sig ]
-
-    checkVisitor  :: CoreVisitor (F.SEnv F.SortedReft) Diagnostics
-    checkVisitor   = CoreVisitor
-                       { envF  = \env v     -> F.insertSEnv (F.symbol v) (vSort v) env
-                       , bindF = \env acc v -> errs env v <> acc
-                       , exprF = \_   acc _ -> acc
-                       }
-    vSort            = Bare.varSortedReft emb
-    errs env v       = case M.lookup v locTm of 
-                         Nothing -> emptyDiagnostics
-                         Just t  -> check env (v, t) 
-
-checkSigTExpr :: Bool -> BScope -> F.TCEmb TyCon -> Bare.TyConMap -> F.SEnv F.SortedReft
-              -> (Var, (LocSpecType, Maybe [Located F.Expr]))
-              -> Diagnostics
-checkSigTExpr allowHO bsc emb tcEnv env (x, (t, es)) = mbErr1 <> mbErr2
-   where
-    mbErr1 = checkBind allowHO bsc empty emb tcEnv env (x, t)
-    mbErr2 = maybe emptyDiagnostics (checkTerminationExpr emb env . (x, t,)) es
-
-_checkQualifiers :: F.SEnv F.SortedReft -> [F.Qualifier] -> [Error]
-_checkQualifiers = mapMaybe . checkQualifier
-
-checkQualifier       :: F.SEnv F.SortedReft -> F.Qualifier -> Maybe Error
-checkQualifier env q =  mkE <$> checkSortFull (F.srcSpan q) γ F.boolSort  (F.qBody q)
-  where 
-    γ                = L.foldl' (\e (x, s) -> F.insertSEnv x (F.RR s mempty) e) env (F.qualBinds q ++ wiredSortedSyms)
-    mkE              = ErrBadQual (GM.fSrcSpan q) (pprint $ F.qName q)
-
--- | Used for termination checking. If we have no \"len\" defined /yet/ (for example we are checking
--- 'GHC.Prim') then we want to skip this check.
-checkSizeFun :: F.TCEmb TyCon -> F.SEnv F.SortedReft -> [TyConP] -> Diagnostics
-checkSizeFun emb env tys = mkDiagnostics mempty (map mkError (mapMaybe go tys))
-  where
-    mkError ((f, tcp), msg)  = ErrTyCon (GM.sourcePosSrcSpan $ tcpLoc tcp)
-                                 (text "Size function" <+> pprint (f x)
-                                                       <+> text "should have type int, but it was "
-                                                       <+> pprint (tcpCon tcp)
-                                                       <+> text "."
-                                                       $+$   msg)
-                                 (pprint (tcpCon tcp))
-    go tcp = case tcpSizeFun tcp of
-               Nothing                   -> Nothing
-               Just f | isWiredInLenFn f -> Nothing -- Skip the check.
-               Just f                    -> checkWFSize (szFun f) tcp
-
-    checkWFSize f tcp = ((f, tcp),) <$> checkSortFull (F.srcSpan tcp) (F.insertSEnv x (mkTySort (tcpCon tcp)) env) F.intSort (f x)
-    x                 = "x" :: F.Symbol
-    mkTySort tc       = rTypeSortedReft emb (ofType $ TyConApp tc (TyVarTy <$> tyConTyVars tc) :: RRType ())
-
-    isWiredInLenFn :: SizeFun -> Bool
-    isWiredInLenFn IdSizeFun           = False
-    isWiredInLenFn (SymSizeFun locSym) = isWiredIn locSym
-
-_checkRefinedClasses :: [RClass LocBareType] -> [RInstance LocBareType] -> [Error]
-_checkRefinedClasses definitions instances
-  = mkError <$> duplicates
-  where
-    duplicates
-      = mapMaybe checkCls (rcName <$> definitions)
-    checkCls cls
-      = case findConflicts cls of
-          []        -> Nothing
-          conflicts -> Just (cls, conflicts)
-    findConflicts cls
-      = filter ((== cls) . riclass) instances
-    mkError (cls, conflicts)
-      = ErrRClass (GM.sourcePosSrcSpan $ loc $ btc_tc cls)
-                  (pprint cls) (ofConflict <$> conflicts)
-    ofConflict
-      = GM.sourcePosSrcSpan . loc . btc_tc . riclass &&& pprint . ritype
-
-_checkDuplicateFieldNames :: [(DataCon, DataConP)]  -> [Error]
-_checkDuplicateFieldNames = mapMaybe go
-  where
-    go (d, dts)          = checkNoDups (dcpLoc dts) d (fst <$> dcpTyArgs dts)
-    checkNoDups l d xs   = mkErr l d <$> _firstDuplicate xs
-
-    mkErr l d x = ErrBadData (GM.sourcePosSrcSpan l)
-                             (pprint d)
-                             (text "Multiple declarations of record selector" <+> pprintSymbol x)
-
-_firstDuplicate :: Ord a => [a] -> Maybe a
-_firstDuplicate = go . L.sort
-  where
-    go (y:x:xs) | x == y    = Just x
-                | otherwise = go (x:xs)
-    go _                    = Nothing
-
-checkInv :: Bool
-         -> BScope
-         -> F.TCEmb TyCon
-         -> Bare.TyConMap
-         -> F.SEnv F.SortedReft
-         -> (Maybe Var, LocSpecType)
-         -> Diagnostics
-checkInv allowHO bsc emb tcEnv env (_, t) = checkTy allowHO bsc err emb tcEnv env t
-  where
-    err              = ErrInvt (GM.sourcePosSrcSpan $ loc t) (val t)
-
-checkIAl :: Bool
-         -> BScope
-         -> F.TCEmb TyCon
-         -> Bare.TyConMap
-         -> F.SEnv F.SortedReft
-         -> [(LocSpecType, LocSpecType)]
-         -> Diagnostics
-checkIAl allowHO bsc emb tcEnv env = mconcat . map (checkIAlOne allowHO bsc emb tcEnv env)
-
-checkIAlOne :: Bool
-            -> BScope
-            -> F.TCEmb TyCon
-            -> Bare.TyConMap
-            -> F.SEnv F.SortedReft
-            -> (LocSpecType, LocSpecType)
-            -> Diagnostics
-checkIAlOne allowHO bsc emb tcEnv env (t1, t2) = mconcat $ checkEq : (tcheck <$> [t1, t2])
-  where
-    tcheck t = checkTy allowHO bsc (err t) emb tcEnv env t
-    err    t = ErrIAl (GM.sourcePosSrcSpan $ loc t) (val t)
-    t1'      :: RSort
-    t1'      = toRSort $ val t1
-    t2'      :: RSort
-    t2'      = toRSort $ val t2
-    checkEq  = if t1' == t2' then emptyDiagnostics else mkDiagnostics mempty [errmis]
-    errmis   = ErrIAlMis (GM.sourcePosSrcSpan $ loc t1) (val t1) (val t2) emsg
-    emsg     = pprint t1 <+> text "does not match with" <+> pprint t2
-
-
--- FIXME: Should _ be removed if it isn't used?
-checkRTAliases :: String -> t -> [Located (RTAlias s a)] -> Diagnostics
-checkRTAliases msg _ as = err1s
-  where
-    err1s               = checkDuplicateRTAlias msg as
-
-checkBind :: (PPrint v)
-          => Bool
-          -> BScope
-          -> Doc
-          -> F.TCEmb TyCon
-          -> Bare.TyConMap
-          -> F.SEnv F.SortedReft
-          -> (v, LocSpecType)
-          -> Diagnostics
-checkBind allowHO bsc s emb tcEnv env (v, t) = checkTy allowHO bsc msg emb tcEnv env t
-  where
-    msg                      = ErrTySpec (GM.fSrcSpan t) (Just s) (pprint v) (val t)
-
-
-checkTerminationExpr :: (Eq v, PPrint v)
-                     => F.TCEmb TyCon
-                     -> F.SEnv F.SortedReft
-                     -> (v, LocSpecType, [F.Located F.Expr])
-                     -> Diagnostics
-checkTerminationExpr emb env (v, Loc l _ t, les)
-            = (mkErr "ill-sorted" $ go les) <> (mkErr "non-numeric" $ go' les)
-  where
-    -- es      = val <$> les
-    mkErr :: Doc -> Maybe (F.Expr, Doc) -> Diagnostics
-    mkErr _ Nothing = emptyDiagnostics
-    mkErr k (Just e) =
-      mkDiagnostics mempty [uncurry (\ e d -> ErrTermSpec (GM.sourcePosSrcSpan l) (pprint v) k e t d) e]
-    -- mkErr   = uncurry (\ e d -> ErrTermSpec (GM.sourcePosSrcSpan l) (pprint v) (text "ill-sorted" ) e t d)
-    -- mkErr'  = uncurry (\ e d -> ErrTermSpec (GM.sourcePosSrcSpan l) (pprint v) (text "non-numeric") e t d)
-
-    go :: [F.Located F.Expr] -> Maybe (F.Expr, Doc)
-    go      = L.foldl' (\err e -> err <|> (val e,) <$> checkSorted (F.srcSpan e) env' (val e))     Nothing
-
-    go' :: [F.Located F.Expr] -> Maybe (F.Expr, Doc)
-    go'     = L.foldl' (\err e -> err <|> (val e,) <$> checkSorted (F.srcSpan e) env' (cmpZero e)) Nothing
-
-    env'    = F.sr_sort <$> L.foldl' (\e (x,s) -> F.insertSEnv x s e) env xts
-    xts     = concatMap mkClass $ zip (ty_binds trep) (ty_args trep)
-    trep    = toRTypeRep t
-
-    mkClass (_, RApp c ts _ _) | isClass c = classBinds emb (rRCls c ts)
-    mkClass (x, t)                         = [(x, rSort t)]
-
-    rSort   = rTypeSortedReft emb
-    cmpZero e = F.PAtom F.Le (F.expr (0 :: Int)) (val e)
-
-checkTy :: Bool
-        -> BScope
-        -> (Doc -> Error)
-        -> F.TCEmb TyCon
-        -> Bare.TyConMap
-        -> F.SEnv F.SortedReft
-        -> LocSpecType
-        -> Diagnostics
-checkTy allowHO bsc mkE emb tcEnv env t =
-  case checkRType allowHO bsc emb env (Bare.txRefSort tcEnv emb t) of
-    Nothing -> emptyDiagnostics
-    Just d  -> mkDiagnostics mempty [mkE d]
-  where
-    _msg =  "CHECKTY: " ++ showpp (val t)
-
-checkDupIntersect     :: [(Var, LocSpecType)] -> [(Var, LocSpecType)] -> Diagnostics
-checkDupIntersect xts asmSigs =
-  mkDiagnostics (map mkWrn {- trace msg -} dups) mempty
-  where
-    mkWrn (x, t)   = mkWarning (GM.sourcePosSrcSpan $ loc t) (pprWrn x)
-    dups           = L.intersectBy ((==) `on` fst) asmSigs xts
-    pprWrn v       = text $ "Assume Overwrites Specifications for " ++ show v
-    -- msg              = "CHECKDUPINTERSECT:" ++ msg1 ++ msg2
-    -- msg1             = "\nCheckd-SIGS:\n" ++ showpp (M.fromList xts)
-    -- msg2             = "\nAssume-SIGS:\n" ++ showpp (M.fromList asmSigs)
-
-
-checkDuplicate :: [(Var, LocSpecType)] -> Diagnostics
-checkDuplicate = mkDiagnostics mempty . checkUnique' fst (GM.fSrcSpan . snd)
-
-checkClassMethods :: Maybe [ClsInst] -> [Var] ->  [(Var, LocSpecType)] -> Diagnostics
-checkClassMethods Nothing      _   _   = emptyDiagnostics
-checkClassMethods (Just clsis) cms xts =
-  mkDiagnostics mempty [ErrMClass (GM.sourcePosSrcSpan $ loc t) (pprint x)| (x,t) <- dups ]
-  where
-    dups = F.notracepp "DPS" $ filter ((`elem` ms) . fst) xts'
-    ms   = F.notracepp "MS"  $ concatMap (classMethods . is_cls) clsis
-    xts' = F.notracepp "XTS" $ filter (not . (`elem` cls) . fst) xts
-    cls  = F.notracepp "CLS" cms
-
--- checkDuplicate xts = mkErr <$> dups
-  -- where
-    -- mkErr (x, ts) = ErrDupSpecs (getSrcSpan x) (pprint x) (GM.fSrcSpan <$> ts)
-    -- dups          = [z | z@(_, _:_:_) <- M.toList $ group xts ]
-
-checkDuplicateRTAlias :: String -> [Located (RTAlias s a)] -> Diagnostics
-checkDuplicateRTAlias s tas = mkDiagnostics mempty (map mkErr dups)
-  where
-    mkErr xs@(x:_)          = ErrDupAlias (GM.fSrcSpan x)
-                                          (text s)
-                                          (pprint . rtName . val $ x)
-                                          (GM.fSrcSpan <$> xs)
-    mkErr []                = panic Nothing "mkError: called on empty list"
-    dups                    = [z | z@(_:_:_) <- L.groupBy ((==) `on` (rtName . val)) tas]
-
-
-checkMismatch        :: (Var, LocSpecType) -> Diagnostics
-checkMismatch (x, t) = if ok then emptyDiagnostics else mkDiagnostics mempty [err]
-  where
-    ok               = tyCompat x (val t')
-    err              = errTypeMismatch x t'
-    t'               = dropImplicits <$> t
-
-tyCompat :: Var -> RType RTyCon RTyVar r -> Bool
-tyCompat x t         = lqT == hsT
-  where
-    lqT :: RSort     = toRSort t
-    hsT :: RSort     = ofType (varType x)
-    _msg             = "TY-COMPAT: " ++ GM.showPpr x ++ ": hs = " ++ F.showpp hsT ++ " :lq = " ++ F.showpp lqT
-
-errTypeMismatch     :: Var -> Located SpecType -> Error
-errTypeMismatch x t = ErrMismatch lqSp (pprint x) (text "Checked")  d1 d2 Nothing hsSp
-  where
-    d1              = pprint $ varType x
-    d2              = pprint $ toType $ val t
-    lqSp            = GM.fSrcSpan t
-    hsSp            = getSrcSpan x
-
-------------------------------------------------------------------------------------------------
--- | @checkRType@ determines if a type is malformed in a given environment ---------------------
-------------------------------------------------------------------------------------------------
-checkRType :: Bool -> BScope -> F.TCEmb TyCon -> F.SEnv F.SortedReft -> LocSpecType -> Maybe Doc
-------------------------------------------------------------------------------------------------
-checkRType allowHO bsc emb env lt
-  =   checkAppTys t
-  <|> checkAbstractRefs t
-  <|> efoldReft farg bsc cb (tyToBind emb) (rTypeSortedReft emb) f insertPEnv env Nothing t
-  where
-    t                  = val lt
-    cb c ts            = classBinds emb (rRCls c ts)
-    farg _ t           = allowHO || isBase t  -- NOTE: this check should be the same as the one in addCGEnv
-    f env me r err     = err <|> checkReft (F.srcSpan lt) env emb me r
-    insertPEnv p γ     = insertsSEnv γ (Misc.mapSnd (rTypeSortedReft emb) <$> pbinds p)
-    pbinds p           = (pname p, pvarRType p :: RSort) : [(x, tx) | (tx, x, _) <- pargs p]
-
-tyToBind :: F.TCEmb TyCon -> RTVar RTyVar RSort  -> [(F.Symbol, F.SortedReft)]
-tyToBind emb = go . ty_var_info
-  where
-    go (RTVInfo {..})   = [(rtv_name, rTypeSortedReft emb rtv_kind)]
-    go (RTVNoInfo {..}) = []
-
-checkAppTys :: RType RTyCon t t1 -> Maybe Doc
-checkAppTys = go
-  where
-    go (RAllT _ t _)    = go t
-    go (RAllP _ t)      = go t
-    go (RApp rtc ts _ _)
-      = checkTcArity rtc (length ts) <|>
-        L.foldl' (\merr t -> merr <|> go t) Nothing ts
-    go (RImpF _ t1 t2 _)= go t1 <|> go t2
-    go (RFun _ t1 t2 _) = go t1 <|> go t2
-    go (RVar _ _)       = Nothing
-    go (RAllE _ t1 t2)  = go t1 <|> go t2
-    go (REx _ t1 t2)    = go t1 <|> go t2
-    go (RAppTy t1 t2 _) = go t1 <|> go t2
-    go (RRTy _ _ _ t)   = go t
-    go (RExprArg _)     = Just $ text "Logical expressions cannot appear inside a Haskell type"
-    go (RHole _)        = Nothing
-
-checkTcArity :: RTyCon -> Arity -> Maybe Doc
-checkTcArity (RTyCon { rtc_tc = tc }) givenArity
-  | expectedArity < givenArity
-    = Just $ text "Type constructor" <+> pprint tc
-        <+> text "expects a maximum" <+> pprint expectedArity
-        <+> text "arguments but was given" <+> pprint givenArity
-        <+> text "arguments"
-  | otherwise
-    = Nothing
-  where
-    expectedArity = tyConRealArity tc
-
-
-checkAbstractRefs
-  :: (PPrint t, F.Reftable t, SubsTy RTyVar RSort t, F.Reftable (RTProp RTyCon RTyVar (UReft t))) =>
-     RType RTyCon RTyVar (UReft t) -> Maybe Doc
-checkAbstractRefs t = go t
-  where
-    penv = mkPEnv t
-
-    go t@(RAllT _ t1 r)   = check (toRSort t :: RSort) r <|>  go t1
-    go (RAllP _ t)        = go t
-    go t@(RApp c ts rs r) = check (toRSort t :: RSort) r <|>  efold go ts <|> go' c rs
-    go t@(RImpF _ t1 t2 r)= check (toRSort t :: RSort) r <|> go t1 <|> go t2
-    go t@(RFun _ t1 t2 r) = check (toRSort t :: RSort) r <|> go t1 <|> go t2
-    go t@(RVar _ r)       = check (toRSort t :: RSort) r
-    go (RAllE _ t1 t2)    = go t1 <|> go t2
-    go (REx _ t1 t2)      = go t1 <|> go t2
-    go t@(RAppTy t1 t2 r) = check (toRSort t :: RSort) r <|> go t1 <|> go t2
-    go (RRTy xts _ _ t)   = efold go (snd <$> xts) <|> go t
-    go (RExprArg _)       = Nothing
-    go (RHole _)          = Nothing
-
-    go' c rs = L.foldl' (\acc (x, y) -> acc <|> checkOne' x y) Nothing (zip rs (rTyConPVs c))
-
-    checkOne' (RProp xs (RHole _)) p
-      | or [s1 /= s2 | ((_, s1), (s2, _, _)) <- zip xs (pargs p)]
-      = Just $ text "Wrong Arguments in" <+> pprint p
-      | length xs /= length (pargs p)
-      = Just $ text "Wrong Number of Arguments in" <+> pprint p
-      | otherwise
-      = Nothing
-    checkOne' (RProp xs t) p
-      | pvType p /= toRSort t
-      = Just $ text "Unexpected Sort in" <+> pprint p
-      | or [s1 /= s2 | ((_, s1), (s2, _, _)) <- zip xs (pargs p)]
-      = Just $ text "Wrong Arguments in" <+> pprint p
-      | length xs /= length (pargs p)
-      = Just $ text "Wrong Number of Arguments in" <+> pprint p
-      | otherwise
-      = go t
-
-
-    efold f = L.foldl' (\acc x -> acc <|> f x) Nothing
-
-    check s (MkUReft _ (Pr ps)) = L.foldl' (\acc pp -> acc <|> checkOne s pp) Nothing ps
-
-    checkOne s p | pvType' p /= s
-                 = Just $ text "Incorrect Sort:\n\t"
-                       <+> text "Abstract refinement with type"
-                       <+> pprint (pvType' p)
-                       <+> text "is applied to"
-                       <+> pprint s
-                       <+> text "\n\t In" <+> pprint p
-                 | otherwise
-                 = Nothing
-
-    mkPEnv (RAllT _ t _) = mkPEnv t
-    mkPEnv (RAllP p t)   = p:mkPEnv t
-    mkPEnv _             = []
-    pvType' p          = Misc.safeHead (showpp p ++ " not in env of " ++ showpp t) [pvType q | q <- penv, pname p == pname q]
-
-
-checkReft                    :: (PPrint r, F.Reftable r, SubsTy RTyVar (RType RTyCon RTyVar ()) r, F.Reftable (RTProp RTyCon RTyVar (UReft r)))
-                             => F.SrcSpan -> F.SEnv F.SortedReft -> F.TCEmb TyCon -> Maybe (RRType (UReft r)) -> UReft r -> Maybe Doc
-checkReft _ _   _   Nothing _   = Nothing -- TODO:RPropP/Ref case, not sure how to check these yet.
-checkReft sp env emb (Just t) _ = (\z -> dr $+$ z) <$> checkSortedReftFull sp env r
-  where
-    r                           = rTypeSortedReft emb t
-    dr                          = text "Sort Error in Refinement:" <+> pprint r
-
--- DONT DELETE the below till we've added pred-checking as well
--- checkReft env emb (Just t) _ = checkSortedReft env xs (rTypeSortedReft emb t)
---    where xs                  = fromMaybe [] $ params <$> stripRTypeBase t
-
--- checkSig env (x, t)
---   = case filter (not . (`S.member` env)) (freeSymbols t) of
---       [] -> TrueNGUAGE ScopedTypeVariables #-}
---       ys -> errorstar (msg ys)
---     where
---       msg ys = printf "Unkown free symbols: %s in specification for %s \n%s\n" (showpp ys) (showpp x) (showpp t)
-
----------------------------------------------------------------------------------------------------
--- | @checkMeasures@ determines if a measure definition is wellformed -----------------------------
----------------------------------------------------------------------------------------------------
-checkMeasures :: F.TCEmb TyCon -> F.SEnv F.SortedReft -> [Measure SpecType DataCon] -> Diagnostics
----------------------------------------------------------------------------------------------------
-checkMeasures emb env = foldMap (checkMeasure emb env)
-
-checkMeasure :: F.TCEmb TyCon -> F.SEnv F.SortedReft -> Measure SpecType DataCon -> Diagnostics
-checkMeasure emb γ (M name@(Loc src _ n) sort body _ _)
-  = mkDiagnostics mempty [ txerror e | Just e <- checkMBody γ emb name sort <$> body ]
-  where
-    txerror = ErrMeas (GM.sourcePosSrcSpan src) (pprint n)
-
-checkMBody :: (PPrint r, F.Reftable r,SubsTy RTyVar RSort r, F.Reftable (RTProp RTyCon RTyVar r))
-           => F.SEnv F.SortedReft
-           -> F.TCEmb TyCon
-           -> t
-           -> SpecType
-           -> Def (RRType r) DataCon
-           -> Maybe Doc
-checkMBody γ emb _ sort (Def m c _ bs body) = checkMBody' emb sort γ' sp body
-  where
-    sp    = F.srcSpan m
-    γ'    = L.foldl' (\γ (x, t) -> F.insertSEnv x t γ) γ xts
-    xts   = zip (fst <$> bs) $ rTypeSortedReft emb . subsTyVars_meet su <$> filter (not . isClassType) (ty_args trep)
-    trep  = toRTypeRep ct
-    su    = checkMBodyUnify (ty_res trep) (last txs)
-    txs   = snd4 $ bkArrowDeep sort
-    ct    = ofType $ dataConUserType c :: SpecType
-
-checkMBodyUnify
-  :: RType t t2 t1 -> RType c tv r -> [(t2,RType c tv (),RType c tv r)]
-checkMBodyUnify                 = go
-  where
-    go (RVar tv _) t            = [(tv, toRSort t, t)]
-    go t@(RApp {}) t'@(RApp {}) = concat $ zipWith go (rt_args t) (rt_args t')
-    go _ _                      = []
-
-checkMBody' :: (PPrint r, F.Reftable r,SubsTy RTyVar RSort r, F.Reftable (RTProp RTyCon RTyVar r))
-            => F.TCEmb TyCon
-            -> RType RTyCon RTyVar r
-            -> F.SEnv F.SortedReft
-            -> F.SrcSpan 
-            -> Body
-            -> Maybe Doc
-checkMBody' emb sort γ sp body = case body of
-    E e   -> checkSortFull sp γ (rTypeSort emb sort') e
-    P p   -> checkSortFull sp γ F.boolSort  p
-    R s p -> checkSortFull sp (F.insertSEnv s sty γ) F.boolSort p
-  where
-    sty   = rTypeSortedReft emb sort'
-    sort' = dropNArgs 1 sort
-
-dropNArgs :: Int -> RType RTyCon RTyVar r -> RType RTyCon RTyVar r
-dropNArgs i t = fromRTypeRep $ trep {ty_binds = xs, ty_args = ts, ty_refts = rs}
-  where
-    xs   = drop i $ ty_binds trep
-    ts   = drop i $ ty_args  trep
-    rs   = drop i $ ty_refts trep
-    trep = toRTypeRep t
-
-
-getRewriteErrors :: (Var, Located SpecType) -> [TError t]
-getRewriteErrors (rw, t)
-  | null $ refinementEQs t
-  = [ErrRewrite (GM.fSrcSpan t) $ text $
-                "Unable to use "
-                ++ show rw
-                ++ " as a rewrite because it does not prove an equality, or the equality it proves is trivial." ]
-  | otherwise
-  = refErrs ++ if cannotInstantiate then
-        [ErrRewrite (GM.fSrcSpan t) $
-        text $ "Could not generate any rewrites from equality. Likely causes: "
-        ++ "\n - There are free (uninstantiatable) variables on both sides of the "
-        ++ "equality\n - The rewrite would diverge"]
-        else []
-    where
-        refErrs = map getInnerRefErr (filter (hasInnerRefinement . fst) (zip tyArgs syms))
-        allowedRWs = [ (lhs, rhs) | (lhs , rhs) <- refinementEQs t
-                 , canRewrite (S.fromList syms) lhs rhs ||
-                   canRewrite (S.fromList syms) rhs lhs
-                 ]
-        cannotInstantiate = null allowedRWs
-        tyArgs = ty_args  tRep
-        syms   = ty_binds tRep
-        tRep   = toRTypeRep $ val t
-        getInnerRefErr (_, sym) =
-          ErrRewrite (GM.fSrcSpan t) $ text $
-          "Unable to use "
-          ++ show rw
-          ++ " as a rewrite. Functions whose parameters have inner refinements cannot be used as rewrites, but parameter "
-          ++ show sym
-          ++ " contains an inner refinement."
-
-
-isRefined :: F.Reftable r => RType c tv r -> Bool
-isRefined ty
-  | Just r <- stripRTypeBase ty = not $ F.isTauto r
-  | otherwise = False
-
-hasInnerRefinement :: F.Reftable r => RType c tv r -> Bool
-hasInnerRefinement (RFun _ rIn rOut _) =
-  isRefined rIn || isRefined rOut
-hasInnerRefinement (RImpF _ rIn rOut _) =
-  isRefined rIn || isRefined rOut
-hasInnerRefinement (RAllT _ ty  _) =
-  isRefined ty
-hasInnerRefinement (RAllP _ ty) =
-  isRefined ty
-hasInnerRefinement (RApp _ args _ _) =
-  any isRefined args
-hasInnerRefinement (RAllE _ allarg ty) =
-  isRefined allarg || isRefined ty
-hasInnerRefinement (REx _ allarg ty) =
-  isRefined allarg || isRefined ty
-hasInnerRefinement (RAppTy arg res _) =
-  isRefined arg || isRefined res
-hasInnerRefinement (RRTy env _ _ ty) =
-  isRefined ty || any (isRefined . snd) env
-hasInnerRefinement _ = False
-
-checkRewrites :: TargetSpec -> Diagnostics
-checkRewrites targetSpec = mkDiagnostics mempty (concatMap getRewriteErrors rwSigs)
-  where
-    rwSigs = filter ((`S.member` rws) . fst) sigs
-    refl   = gsRefl targetSpec
-    sig    = gsSig targetSpec
-    sigs   = gsTySigs sig ++ gsAsmSigs sig
-    rws    = S.union (S.map val $ gsRewrites refl)
-                   (S.fromList $ concat $ M.elems (gsRewritesWith refl))
-
-
-checkClassMeasures :: [Measure SpecType DataCon] -> Diagnostics
-checkClassMeasures ms = mkDiagnostics mempty (mapMaybe checkOne byTyCon)
-  where
-  byName = L.groupBy ((==) `on` (val . msName)) ms
-
-  byTyCon = concatMap (L.groupBy ((==) `on` (dataConTyCon . ctor . head . msEqns)))
-                      byName
-
-  checkOne []     = impossible Nothing "checkClassMeasures.checkOne on empty measure group"
-  checkOne [_]    = Nothing
-  checkOne (m:ms) = Just (ErrDupIMeas (GM.fSrcSpan (msName m))
-                                      (pprint (val (msName m)))
-                                      (pprint ((dataConTyCon . ctor . head . msEqns) m))
-                                      (GM.fSrcSpan <$> (m:ms)))
-
-
-
diff --git a/src/Language/Haskell/Liquid/Bare/Class.hs b/src/Language/Haskell/Liquid/Bare/Class.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Class.hs
+++ /dev/null
@@ -1,276 +0,0 @@
-{-# LANGUAGE FlexibleContexts  #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE ParallelListComp  #-}
-{-# LANGUAGE TupleSections     #-}
-{-# LANGUAGE BangPatterns      #-}
-
-module Language.Haskell.Liquid.Bare.Class 
-  ( makeClasses
-  , makeCLaws
-  , makeSpecDictionaries
-  , makeDefaultMethods
-  , makeMethodTypes
-  ) 
-  where
-
-import           Data.Bifunctor 
-import qualified Data.Maybe                                 as Mb
-import qualified Data.List                                  as L
-import qualified Data.HashMap.Strict                        as M
-
-import qualified Language.Fixpoint.Misc                     as Misc
-import qualified Language.Fixpoint.Types                    as F
-import qualified Language.Fixpoint.Types.Visitor            as F
-
-import           Language.Haskell.Liquid.Types.Dictionaries
-import qualified Language.Haskell.Liquid.GHC.Misc           as GM
-import qualified Language.Haskell.Liquid.GHC.API            as Ghc
-import           Language.Haskell.Liquid.Misc
-import           Language.Haskell.Liquid.Types.RefType
-import           Language.Haskell.Liquid.Types              hiding (freeTyVars)
-
-import qualified Language.Haskell.Liquid.Measure            as Ms
-import           Language.Haskell.Liquid.Bare.Types         as Bare 
-import           Language.Haskell.Liquid.Bare.Resolve       as Bare
-import           Language.Haskell.Liquid.Bare.Expand        as Bare
-import           Language.Haskell.Liquid.Bare.Misc         as Bare
-
-import           Text.PrettyPrint.HughesPJ (text)
-import qualified Control.Exception                 as Ex
-
-
-
--------------------------------------------------------------------------------
-makeMethodTypes :: DEnv Ghc.Var LocSpecType -> [DataConP] -> [Ghc.CoreBind] -> [(Ghc.Var, MethodType LocSpecType)]
--------------------------------------------------------------------------------
-makeMethodTypes (DEnv m) cls cbs 
-  = [(x, MT (addCC x . fromRISig <$> methodType d x m) (addCC x <$> classType (splitDictionary e) x)) | (d,e) <- ds, x <- grepMethods e]
-    where 
-      grepMethods = filter GM.isMethod . freeVars mempty
-      ds = filter (GM.isDictionary . fst) (concatMap unRec cbs)
-      unRec (Ghc.Rec xes) = xes
-      unRec (Ghc.NonRec x e) = [(x,e)]
-
-      classType Nothing _ = Nothing
-      classType (Just (d, ts, _)) x = 
-        case filter ((==d) . Ghc.dataConWorkId . dcpCon) cls of 
-          (di:_) -> fmap ((dcpLoc di `F.atLoc`) . subst (zip (dcpFreeTyVars di) ts)) $ L.lookup (mkSymbol x) (dcpTyArgs di)
-          _      -> Nothing 
-
-      methodType d x m = ihastype (M.lookup d m) x
-
-      ihastype Nothing _    = Nothing
-      ihastype (Just xts) x = M.lookup (mkSymbol x) xts
-
-      mkSymbol x = F.dropSym 2 $ GM.simplesymbol x
-
-      subst [] t = t 
-      subst ((a,ta):su) t = subsTyVar_meet' (a,ofType ta) (subst su t)
-
-addCC :: Ghc.Var -> LocSpecType -> LocSpecType
-addCC x zz@(Loc l l' st0) 
-  = Loc l l' 
-  . addForall hst  
-  . mkArrow [] ps' [] [] 
-  . makeCls cs' 
-  . mapExprReft (\_ -> F.applyCoSub coSub) 
-  . subts su 
-  $ st  
-  where
-    hst           = ofType (Ghc.expandTypeSynonyms t0) :: SpecType
-    t0            = Ghc.varType x 
-    tyvsmap       = case Bare.runMapTyVars t0 st err of
-                          Left e  -> Ex.throw e 
-                          Right s -> Bare.vmap s
-    su            = [(y, rTyVar x)           | (x, y) <- tyvsmap]
-    su'           = [(y, RVar (rTyVar x) ()) | (x, y) <- tyvsmap] :: [(RTyVar, RSort)]
-    coSub         = M.fromList [(F.symbol y, F.FObj (F.symbol x)) | (y, x) <- su]
-    ps'           = fmap (subts su') <$> ps
-    cs'           = [(F.dummySymbol, RApp c ts [] mempty) | (c, ts) <- cs ] 
-    (_,_,cs,_)    = bkUnivClass (F.notracepp "hs-spec" $ ofType (Ghc.expandTypeSynonyms t0) :: SpecType)
-    (_,ps,_ ,st)  = bkUnivClass (F.notracepp "lq-spec" st0)
-
-    makeCls cs t  = foldr (uncurry rFun) t cs
-    err hsT lqT   = ErrMismatch (GM.fSrcSpan zz) (pprint x) 
-      (text "makeMethodTypes")
-      (pprint $ Ghc.expandTypeSynonyms t0)
-      (pprint $ toRSort st0)
-      (Just (hsT, lqT))
-      (Ghc.getSrcSpan x) 
-
-    addForall (RAllT v t r) tt@(RAllT v' _ _)
-      | v == v'
-      = tt
-      | otherwise 
-      = RAllT (updateRTVar v) (addForall t tt) r
-    addForall (RAllT v t r) t' 
-      = RAllT (updateRTVar v) (addForall t t') r 
-    addForall (RAllP _ t) t' 
-      = addForall t t'
-    addForall _ (RAllP p t')
-      = RAllP (fmap (subts su') p) t' 
-    addForall (RFun _ t1 t2 _) (RFun x t1' t2' r)
-      = RFun x (addForall t1 t1') (addForall t2 t2') r  
-    addForall _ t 
-      = t 
-
-
-splitDictionary :: Ghc.CoreExpr -> Maybe (Ghc.Var, [Ghc.Type], [Ghc.Var])
-splitDictionary = go [] [] 
-  where 
-    go ts xs (Ghc.App e (Ghc.Tick _ a)) = go ts xs (Ghc.App e a)
-    go ts xs (Ghc.App e (Ghc.Type t))   = go (t:ts) xs e 
-    go ts xs (Ghc.App e (Ghc.Var x))    = go ts (x:xs) e 
-    go ts xs (Ghc.Tick _ t) = go ts xs t 
-    go ts xs (Ghc.Var x) = Just (x, reverse ts, reverse xs)
-    go _ _ _ = Nothing
-
-
--------------------------------------------------------------------------------
-makeCLaws :: Bare.Env -> Bare.SigEnv -> ModName -> Bare.ModSpecs 
-            -> [(Ghc.Class, [(ModName, Ghc.Var, LocSpecType)])]
--------------------------------------------------------------------------------
-makeCLaws env sigEnv myName specs = 
-  [ (Mb.fromMaybe (msg tc) (Ghc.tyConClass_maybe tc), snd cls) | (name, spec) <- M.toList specs
-          , cls          <- Ms.claws spec
-          , tc           <- Mb.maybeToList (classTc cls) 
-          , cls          <- Mb.maybeToList (mkClass env sigEnv myName name cls tc)
-    ]
-  where
-    msg tc  = error ("Not a type class: " ++ F.showpp tc)
-    classTc = Bare.maybeResolveSym env myName "makeClass" . btc_tc . rcName 
-
-
-
--------------------------------------------------------------------------------
-makeClasses :: Bare.Env -> Bare.SigEnv -> ModName -> Bare.ModSpecs 
-            -> ([DataConP], [(ModName, Ghc.Var, LocSpecType)])
--------------------------------------------------------------------------------
-makeClasses env sigEnv myName specs = 
-  second mconcat . unzip 
-  $ [ cls | (name, spec) <- M.toList specs
-          , cls          <- Ms.classes spec
-          , tc           <- Mb.maybeToList (classTc cls) 
-          , cls          <- Mb.maybeToList (mkClass env sigEnv myName name cls tc)
-    ]
-  where
-    classTc = Bare.maybeResolveSym env myName "makeClass" . btc_tc . rcName 
-
-mkClass :: Bare.Env -> Bare.SigEnv -> ModName -> ModName -> RClass LocBareType -> Ghc.TyCon 
-        -> Maybe (DataConP, [(ModName, Ghc.Var, LocSpecType)])
-mkClass env sigEnv _myName name (RClass cc ss as ms) 
-  = Bare.failMaybe env name 
-  . mkClassE env sigEnv _myName name (RClass cc ss as ms) 
-
-mkClassE :: Bare.Env -> Bare.SigEnv -> ModName -> ModName -> RClass LocBareType -> Ghc.TyCon 
-         -> Either UserError (DataConP, [(ModName, Ghc.Var, LocSpecType)])
-mkClassE env sigEnv _myName name (RClass cc ss as ms) tc = do 
-    ss'    <- mapM (mkConstr   env sigEnv name) ss 
-    meths  <- mapM (makeMethod env sigEnv name) ms'
-    let vts = [ (m, v, t) | (m, kv, t) <- meths, v <- Mb.maybeToList (plugSrc kv) ]
-    let sts = [(val s, unClass $ val t) | (s, _) <- ms | (_, _, t) <- meths]
-    let dcp = DataConP l dc αs [] (val <$> ss') (reverse sts) t False (F.symbol name) l'
-    return  $ F.notracepp msg (dcp, vts)
-  where
-    c      = btc_tc cc
-    l      = loc  c
-    l'     = locE c
-    msg    = "MKCLASS: " ++ F.showpp (cc, as, αs) 
-    (dc:_) = Ghc.tyConDataCons tc
-    αs     = bareRTyVar <$> as
-    as'    = [rVar $ GM.symbolTyVar $ F.symbol a | a <- as ]
-    ms'    = [ (s, rFun "" (RApp cc (flip RVar mempty <$> as) [] mempty) <$> t) | (s, t) <- ms]
-    t      = rCls tc as'
-
-mkConstr :: Bare.Env -> Bare.SigEnv -> ModName -> LocBareType -> Either UserError LocSpecType     
-mkConstr env sigEnv name = fmap (fmap dropUniv) . Bare.cookSpecTypeE env sigEnv name Bare.GenTV 
-  where 
-    dropUniv t           = t' where (_, _, t') = bkUniv t
-
-   --FIXME: cleanup this code
-unClass :: SpecType -> SpecType 
-unClass = snd . bkClass . thrd3 . bkUniv
-
-makeMethod :: Bare.Env -> Bare.SigEnv -> ModName -> (LocSymbol, LocBareType) 
-         -> Either UserError (ModName, PlugTV Ghc.Var, LocSpecType)
-makeMethod env sigEnv name (lx, bt) = (name, mbV,) <$> Bare.cookSpecTypeE env sigEnv name mbV bt
-  where 
-    mbV = case Bare.maybeResolveSym env name "makeMethod" lx of 
-            Just v  -> Bare.LqTV v 
-            Nothing -> Bare.GenTV 
-
--------------------------------------------------------------------------------
-makeSpecDictionaries :: Bare.Env -> Bare.SigEnv -> ModSpecs -> DEnv Ghc.Var LocSpecType 
--------------------------------------------------------------------------------
-makeSpecDictionaries env sigEnv specs
-  = dfromList 
-  . concat 
-  . fmap (makeSpecDictionary env sigEnv) 
-  $ M.toList specs
-
-makeSpecDictionary :: Bare.Env -> Bare.SigEnv -> (ModName, Ms.BareSpec)
-                   -> [(Ghc.Var, M.HashMap F.Symbol (RISig LocSpecType))]
-makeSpecDictionary env sigEnv (name, spec)
-  = Mb.catMaybes 
-  . resolveDictionaries env name 
-  . fmap (makeSpecDictionaryOne env sigEnv name) 
-  . Ms.rinstance 
-  $ spec
-
-makeSpecDictionaryOne :: Bare.Env -> Bare.SigEnv -> ModName 
-                      -> RInstance LocBareType 
-                      -> (F.Symbol, M.HashMap F.Symbol (RISig LocSpecType))
-makeSpecDictionaryOne env sigEnv name (RI x t xts)
-         = makeDictionary $ F.notracepp "RI" $ RI x ts [(x, mkLSpecIType t) | (x, t) <- xts ] 
-  where
-    ts      = mkTy' <$> t
-    as      = concatMap (univs . val) ts
-    univs t = (\(RTVar tv _, _) -> tv) <$> as where (as, _, _) = bkUniv t 
-
-    mkTy' :: LocBareType -> LocSpecType
-    mkTy' = Bare.cookSpecType env sigEnv name Bare.GenTV
-    mkTy :: LocBareType -> LocSpecType
-    mkTy = fmap (mapUnis tidy) . Bare.cookSpecType env sigEnv name 
-               Bare.GenTV -- (Bare.HsTV (Bare.lookupGhcVar env name "rawDictionaries" x))
-    mapUnis f t = mkUnivs (f as) ps t0 where (as, ps, t0) = bkUniv t
-
-    tidy vs = l ++ r 
-      where (l,r) = L.partition (\(RTVar tv _,_) -> tv `elem` as) vs 
-
-    mkLSpecIType :: RISig LocBareType -> RISig LocSpecType
-    mkLSpecIType t = fmap mkTy t
-
-resolveDictionaries :: Bare.Env -> ModName -> [(F.Symbol, M.HashMap F.Symbol (RISig LocSpecType))] 
-                    -> [Maybe (Ghc.Var, M.HashMap F.Symbol (RISig LocSpecType))]
-resolveDictionaries env name = fmap lookupVar 
-                             . concat 
-                             . fmap addInstIndex 
-                             . Misc.groupList 
-  where
-    lookupVar (x, inst)      = (, inst) <$> Bare.maybeResolveSym env name "resolveDict" (F.dummyLoc x)
-
--- formerly, addIndex
--- GHC internal postfixed same name dictionaries with ints
-addInstIndex            :: (F.Symbol, [a]) -> [(F.Symbol, a)]
-addInstIndex (x, is) = go 0 (reverse is)
-  where 
-    go _ []          = []
-    go _ [i]         = [(x, i)]
-    go j (i:is)      = (F.symbol (F.symbolString x ++ show j),i) : go (j+1) is
-
-----------------------------------------------------------------------------------
-makeDefaultMethods :: Bare.Env -> [(ModName, Ghc.Var, LocSpecType)] 
-                   -> [(ModName, Ghc.Var, LocSpecType)]
-----------------------------------------------------------------------------------
-makeDefaultMethods env mts = [ (mname, dm, t) 
-                                 | (mname, m, t) <- mts
-                                 , dm            <- lookupDefaultVar env mname m ]  
-
-lookupDefaultVar :: Bare.Env -> ModName -> Ghc.Var -> [Ghc.Var] 
-lookupDefaultVar env name v = Mb.maybeToList 
-                            . Bare.maybeResolveSym env name "default-method" 
-                            $ dmSym
-  where 
-    dmSym                   = F.atLoc v (GM.qualifySymbol mSym dnSym)
-    dnSym                   = F.mappendSym "$dm" nSym
-    (mSym, nSym)            = GM.splitModuleName (F.symbol v) 
diff --git a/src/Language/Haskell/Liquid/Bare/DataType.hs b/src/Language/Haskell/Liquid/Bare/DataType.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/DataType.hs
+++ /dev/null
@@ -1,690 +0,0 @@
-{-# LANGUAGE FlexibleContexts  #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE TupleSections     #-}
-
-module Language.Haskell.Liquid.Bare.DataType
-  ( dataConMap
-
-  -- * Names for accessing Data Constuctors 
-  , makeDataConChecker
-  , makeDataConSelector 
-  , addClassEmbeds
-
-  -- * Constructors
-  , makeDataDecls
-  , makeConTypes
-  , makeRecordSelectorSigs
-  , meetDataConSpec
-  -- , makeTyConEmbeds
-
-  ) where
-
-import           Prelude                                hiding (error)
-
--- import           Text.Parsec
--- import           Var
--- import           Data.Maybe
--- import           Language.Haskell.Liquid.GHC.TypeRep
-
-import qualified Control.Exception                      as Ex
-import qualified Data.List                              as L
-import qualified Data.HashMap.Strict                    as M
-import qualified Data.HashSet                           as S
-import qualified Data.Maybe                             as Mb 
-
--- import qualified Language.Fixpoint.Types.Visitor        as V
-import qualified Language.Fixpoint.Types                as F
-import qualified Language.Haskell.Liquid.GHC.Misc       as GM 
-import qualified Language.Haskell.Liquid.GHC.API        as Ghc 
-import           Language.Haskell.Liquid.Types.PredType (dataConPSpecType)
-import qualified Language.Haskell.Liquid.Types.RefType  as RT
-import           Language.Haskell.Liquid.Types.Types
-import           Language.Haskell.Liquid.Types.Meet
-import qualified Language.Fixpoint.Misc                 as Misc
-import qualified Language.Haskell.Liquid.Misc           as Misc
-import           Language.Haskell.Liquid.Types.Variance
-import           Language.Haskell.Liquid.WiredIn
-
-import qualified Language.Haskell.Liquid.Measure        as Ms
-import qualified Language.Haskell.Liquid.Bare.Types     as Bare  
-import qualified Language.Haskell.Liquid.Bare.Resolve   as Bare 
-
--- import qualified Language.Haskell.Liquid.Bare.Misc      as GM
--- import           Language.Haskell.Liquid.Bare.Env
--- import           Language.Haskell.Liquid.Bare.Lookup
--- import           Language.Haskell.Liquid.Bare.OfType
-
-import           Text.Printf                     (printf)
-import           Text.PrettyPrint.HughesPJ       ((<+>))
--- import           Debug.Trace (trace)
-
---------------------------------------------------------------------------------
--- | 'DataConMap' stores the names of those ctor-fields that have been declared
---   as SMT ADTs so we don't make up new names for them.
---------------------------------------------------------------------------------
-dataConMap :: [F.DataDecl] -> Bare.DataConMap
-dataConMap ds = M.fromList $ do
-  d     <- ds
-  c     <- F.ddCtors d
-  let fs = F.symbol <$> F.dcFields c
-  zip ((F.symbol c,) <$> [1..]) fs
-
-
---------------------------------------------------------------------------------
--- | 'makeDataConChecker d' creates the measure for `is$d` which tests whether
---   a given value was created by 'd'. e.g. is$Nil or is$Cons.
---------------------------------------------------------------------------------
-makeDataConChecker :: Ghc.DataCon -> F.Symbol
---------------------------------------------------------------------------------
-makeDataConChecker = F.testSymbol . F.symbol 
-
---------------------------------------------------------------------------------
--- | 'makeDataConSelector d' creates the selector `select$d$i`
---   which projects the i-th field of a constructed value.
---   e.g. `select$Cons$1` and `select$Cons$2` are respectively
---   equivalent to `head` and `tail`.
---------------------------------------------------------------------------------
-makeDataConSelector :: Maybe Bare.DataConMap -> Ghc.DataCon -> Int -> F.Symbol
-makeDataConSelector dmMb d i = M.lookupDefault def (F.symbol d, i) dm
-  where 
-    dm                       = Mb.fromMaybe M.empty dmMb 
-    def                      = makeDataConSelector' d i
- 
-
-makeDataConSelector' :: Ghc.DataCon -> Int -> F.Symbol
-makeDataConSelector' d i
-  = symbolMeasure "$select" (dcSymbol d) (Just i)
-
-dcSymbol :: Ghc.DataCon -> F.Symbol
-dcSymbol = {- simpleSymbolVar -} F.symbol . Ghc.dataConWorkId
-
-symbolMeasure :: String -> F.Symbol -> Maybe Int -> F.Symbol
-symbolMeasure f d iMb = foldr1 F.suffixSymbol (dcPrefix : F.symbol f : d : rest)
-  where
-    rest          = maybe [] (Misc.singleton . F.symbol . show) iMb
-
-
---------------------------------------------------------------------------------
--- | makeClassEmbeds: sort-embeddings for numeric, and family-instance tycons
---------------------------------------------------------------------------------
-addClassEmbeds :: Maybe [Ghc.ClsInst] -> [Ghc.TyCon] -> F.TCEmb Ghc.TyCon 
-               -> F.TCEmb Ghc.TyCon
-addClassEmbeds instenv fiTcs = makeFamInstEmbeds fiTcs . makeNumEmbeds instenv
-
---------------------------------------------------------------------------------
--- | makeFamInstEmbeds : embed family instance tycons, see [NOTE:FamInstEmbeds]
---------------------------------------------------------------------------------
---     Query.R$58$EntityFieldBlobdog
---   with the actual family instance  types that have numeric instances as int [Check!]
---------------------------------------------------------------------------------
-makeFamInstEmbeds :: [Ghc.TyCon] -> F.TCEmb Ghc.TyCon -> F.TCEmb Ghc.TyCon
-makeFamInstEmbeds cs0 embs = L.foldl' embed embs famInstSorts
-  where
-    famInstSorts          = F.notracepp "famInstTcs"
-                            [ (c, RT.typeSort embs ty)
-                                | c   <- cs
-                                , ty  <- Mb.maybeToList (RT.famInstTyConType c) ]
-    embed embs (c, t)     = F.tceInsert c t F.NoArgs embs
-    cs                    = F.notracepp "famInstTcs-all" cs0
-
-{- 
-famInstTyConType :: Ghc.TyCon -> Maybe Ghc.Type
-famInstTyConType c = case Ghc.tyConFamInst_maybe c of
-    Just (c', ts) -> F.tracepp ("famInstTyConType: " ++ F.showpp (c, Ghc.tyConArity c, ts)) 
-                     $ Just (famInstType (Ghc.tyConArity c) c' ts)
-    Nothing       -> Nothing
-
-famInstType :: Int -> Ghc.TyCon -> [Ghc.Type] -> Ghc.Type
-famInstType n c ts = Ghc.mkTyConApp c (take (length ts - n) ts)
--}
-
-{- | [NOTE:FamInstEmbeds] GHC represents family instances in two ways: 
-
-     (1) As an applied type, 
-     (2) As a special tycon.
-     
-     For example, consider `tests/pos/ExactGADT4.hs`:
-
-        class PersistEntity record where
-          data EntityField record :: * -> *
-
-        data Blob = B { xVal :: Int, yVal :: Int }
-
-        instance PersistEntity Blob where
-           data EntityField Blob dog where
-             BlobXVal :: EntityField Blob Int
-             BlobYVal :: EntityField Blob Int
-
-     here, the type of the constructor `BlobXVal` can be represented as:
-
-     (1) EntityField Blob Int,
-
-     or
-
-     (2) R$58$EntityFieldBlobdog Int
-
-     PROBLEM: For various reasons, GHC will use _both_ representations interchangeably,
-     which messes up our sort-checker.
-
-     SOLUTION: To address the above, we create an "embedding"
-
-        R$58$EntityFieldBlobdog :-> EntityField Blob
-
-     So that all occurrences of the (2) are treated as (1) by the sort checker.
-
- -}
-
---------------------------------------------------------------------------------
--- | makeNumEmbeds: embed types that have numeric instances as int [Check!]
---------------------------------------------------------------------------------
-makeNumEmbeds :: Maybe [Ghc.ClsInst] -> F.TCEmb Ghc.TyCon -> F.TCEmb Ghc.TyCon
-makeNumEmbeds Nothing x   = x
-makeNumEmbeds (Just is) x = L.foldl' makeNumericInfoOne x is
-
-makeNumericInfoOne :: F.TCEmb Ghc.TyCon -> Ghc.ClsInst -> F.TCEmb Ghc.TyCon
-makeNumericInfoOne m is
-  | isFracCls cls, Just tc <- instanceTyCon is
-  = F.tceInsertWith (flip mappendSortFTC) tc (ftc tc True True) F.NoArgs m
-  | isNumCls  cls, Just tc <- instanceTyCon is
-  = F.tceInsertWith (flip mappendSortFTC) tc (ftc tc True False) F.NoArgs m
-  | otherwise
-  = m
-  where
-    cls         = Ghc.classTyCon (Ghc.is_cls is)
-    ftc c f1 f2 = F.FTC (F.symbolNumInfoFTyCon (dummyLoc $ RT.tyConName c) f1 f2)
-
-mappendSortFTC :: F.Sort -> F.Sort -> F.Sort
-mappendSortFTC (F.FTC x) (F.FTC y) = F.FTC (F.mappendFTC x y)
-mappendSortFTC s         (F.FTC _) = s
-mappendSortFTC (F.FTC _) s         = s
-mappendSortFTC s1        s2        = panic Nothing ("mappendSortFTC: s1 = " ++ showpp s1 ++ " s2 = " ++ showpp s2)
-
-instanceTyCon :: Ghc.ClsInst -> Maybe Ghc.TyCon
-instanceTyCon = go . Ghc.is_tys
-  where
-    go [Ghc.TyConApp c _] = Just c
-    go _                  = Nothing
-
---------------------------------------------------------------------------------
--- | Create Fixpoint DataDecl from LH DataDecls --------------------------------
---------------------------------------------------------------------------------
-
--- | A 'DataPropDecl' is associated with a (`TyCon` and) `DataDecl`, and defines the
---   sort of relation that is established by terms of the given `TyCon`.
---   A 'DataPropDecl' say, 'pd' is associated with a 'dd' of type 'DataDecl' when
---   'pd' is the `SpecType` version of the `BareType` given by `tycPropTy dd`.
-
-type DataPropDecl = (DataDecl, Maybe SpecType)
-
-makeDataDecls :: Config -> F.TCEmb Ghc.TyCon -> ModName
-              -> [(ModName, Ghc.TyCon, DataPropDecl)]
-              -> [Located DataConP]
-              -> [F.DataDecl]
-makeDataDecls cfg tce name tds ds
-  | makeDecls = [ makeFDataDecls tce tc dd ctors
-                | (tc, (dd, ctors)) <- groupDataCons tds' (F.notracepp "makeDataDecls" ds)
-                , tc /= Ghc.listTyCon
-                ]
-  | otherwise = []
-  where
-    makeDecls = exactDCFlag cfg && not (noADT cfg)
-    tds'      = resolveTyCons name tds
-
--- [NOTE:Orphan-TyCons]
-
-{- | 'resolveTyCons' will prune duplicate 'TyCon' definitions, as follows:
-
-      Let the "home" of a 'TyCon' be the module where it is defined.
-      There are three kinds of 'DataDecl' definitions:
-
-      1. A  "home"-definition is one that belongs to its home module,
-      2. An "orphan"-definition is one that belongs to some non-home module.
-
-      A 'DataUser' definition MUST be a "home" definition
-          - otherwise you can avoid importing the definition
-            and hence, unsafely pass its invariants!
-
-      So, 'resolveTyConDecls' implements the following protocol:
-
-      (a) If there is a "Home" definition,
-          then use it, and IGNORE others.
-
-      (b) If there are ONLY "orphan" definitions,
-          then pick the one from module being analyzed.
-
-      We COULD relax to allow for exactly one orphan `DataUser` definition
-      which is the one that should be selected, but that seems like a
-      slippery slope, as you can avoid importing the definition
-      and hence, unsafely pass its invariants! (Feature not bug?)
-
--}
-resolveTyCons :: ModName -> [(ModName, Ghc.TyCon, DataPropDecl)]
-              -> [(Ghc.TyCon, (ModName, DataPropDecl))]
-resolveTyCons m mtds = [(tc, (m, d)) | (tc, mds) <- M.toList tcDecls
-                                     , (m, d)    <- Mb.maybeToList $ resolveDecls m tc mds ]
-  where
-    tcDecls          = Misc.group [ (tc, (m, d)) | (m, tc, d) <- mtds ]
-
--- | See [NOTE:Orphan-TyCons], the below function tells us which of (possibly many)
---   DataDecls to use.
-resolveDecls :: ModName -> Ghc.TyCon -> Misc.ListNE (ModName, DataPropDecl)
-             -> Maybe (ModName, DataPropDecl)
-resolveDecls mName tc mds  = F.notracepp msg $ Misc.firstMaybes $ (`L.find` mds) <$> [ isHomeDef , isMyDef]
-  where
-    msg                    = "resolveDecls" ++ F.showpp (mName, tc)
-    isMyDef                = (mName ==)             . fst
-    isHomeDef              = (tcHome ==) . F.symbol . fst
-    tcHome                 = GM.takeModuleNames (F.symbol tc)
-
-groupDataCons :: [(Ghc.TyCon, (ModName, DataPropDecl))]
-              -> [Located DataConP]
-              -> [(Ghc.TyCon, (DataPropDecl, [(Ghc.DataCon, DataConP)]))]
-groupDataCons tds ds = [ (tc, (d, dds')) | (tc, ((m, d), dds)) <- tcDataCons
-                                         , let dds' = filter (isResolvedDataConP m . snd) dds
-                       ]
-  where
-    tcDataCons       = M.toList $ M.intersectionWith (,) declM ctorM
-    declM            = M.fromList tds
-    ctorM            = Misc.group [(Ghc.dataConTyCon d, (d, dcp)) | Loc _ _ dcp <- ds, let d = dcpCon dcp]
-
-isResolvedDataConP :: ModName -> DataConP -> Bool
-isResolvedDataConP m dp = F.symbol m == dcpModule dp
-
-makeFDataDecls :: F.TCEmb Ghc.TyCon -> Ghc.TyCon -> DataPropDecl -> [(Ghc.DataCon, DataConP)]
-               -> F.DataDecl
-makeFDataDecls tce tc dd ctors = makeDataDecl tce tc (fst dd) ctors
-                               -- ++ maybeToList (makePropDecl tce tc dd) -- TODO: AUTO-INDPRED
-
-makeDataDecl :: F.TCEmb Ghc.TyCon -> Ghc.TyCon -> DataDecl -> [(Ghc.DataCon, DataConP)]
-             -> F.DataDecl
-makeDataDecl tce tc dd ctors
-  = F.DDecl
-      { F.ddTyCon = ftc
-      , F.ddVars  = length                $  GM.tyConTyVarsDef tc
-      , F.ddCtors = makeDataCtor tce ftc <$> ctors
-      }
-  where
-    ftc = F.symbolFTycon (tyConLocSymbol tc dd)
-
-tyConLocSymbol :: Ghc.TyCon -> DataDecl -> LocSymbol
-tyConLocSymbol tc dd = F.atLoc (tycName dd) (F.symbol tc)
-
--- [NOTE:ADT] We need to POST-PROCESS the 'Sort' so that:
--- 1. The poly tyvars are replaced with debruijn
---    versions e.g. 'List a_a1m' becomes 'List @(1)'
--- 2. The "self" type is replaced with just itself
---    (i.e. without any type applications.)
-
-makeDataCtor :: F.TCEmb Ghc.TyCon -> F.FTycon -> (Ghc.DataCon, DataConP) -> F.DataCtor
-makeDataCtor tce c (d, dp) = F.DCtor
-  { F.dcName    = GM.namedLocSymbol d
-  , F.dcFields  = makeDataFields tce c as xts
-  }
-  where
-    as          = dcpFreeTyVars dp
-    xts         = [ (fld x, t) | (x, t) <- reverse (dcpTyArgs dp) ]
-    fld         = F.atLoc dp . fieldName d dp
-
-fieldName :: Ghc.DataCon -> DataConP -> F.Symbol -> F.Symbol
-fieldName d dp x
-  | dcpIsGadt dp = F.suffixSymbol (F.symbol d) x
-  | otherwise    = x
-
-makeDataFields :: F.TCEmb Ghc.TyCon -> F.FTycon -> [RTyVar] -> [(F.LocSymbol, SpecType)]
-               -> [F.DataField]
-makeDataFields tce _c as xts = [ F.DField x (fSort t) | (x, t) <- xts]
-  where
-    su    = zip (F.symbol <$> as) [0..]
-    fSort = F.substVars su . F.mapFVar (+ (length as)) . RT.rTypeSort tce
-
-{- 
-muSort :: F.FTycon -> Int -> F.Sort -> F.Sort
-muSort c n  = V.mapSort tx
-  where
-    ct      = F.fTyconSort c
-    me      = F.fTyconSelfSort c n
-    tx t    = if t == me then ct else t
--}
-
---------------------------------------------------------------------------------
-meetDataConSpec :: F.TCEmb Ghc.TyCon -> [(Ghc.Var, SpecType)] -> [DataConP] 
-                -> [(Ghc.Var, SpecType)]
---------------------------------------------------------------------------------
-meetDataConSpec emb xts dcs  = M.toList $ snd <$> L.foldl' upd dcm0 xts
-  where
-    dcm0                     = M.fromList (dataConSpec' dcs)
-    upd dcm (x, t)           = M.insert x (Ghc.getSrcSpan x, tx') dcm
-                                where
-                                  tx' = maybe t (meetX x t) (M.lookup x dcm)
-    meetX x t (sp', t')      = F.notracepp (_msg x t t') $ meetVarTypes emb (pprint x) (Ghc.getSrcSpan x, t) (sp', t') 
-    _msg x t t'              = "MEET-VAR-TYPES: " ++ showpp (x, t, t')
-
-dataConSpec' :: [DataConP] -> [(Ghc.Var, (Ghc.SrcSpan, SpecType))]
-dataConSpec' = concatMap tx 
-  where
-    tx dcp   =  [ (x, res) | (x, t0) <- dataConPSpecType dcp
-                          , let t    = RT.expandProductType x t0  
-                          , let res  = (GM.fSrcSpan dcp, t)
-                ]
---------------------------------------------------------------------------------
--- | Bare Predicate: DataCon Definitions ---------------------------------------
---------------------------------------------------------------------------------
-makeConTypes :: Bare.Env -> (ModName, Ms.BareSpec) 
-             -> ([(ModName, TyConP, Maybe DataPropDecl)], [[Located DataConP]])
-makeConTypes env (name, spec) 
-         = unzip  [ ofBDataDecl env name x y | (x, y) <- gvs ] 
-  where 
-    gvs  = groupVariances dcs' vdcs
-    dcs' = canonizeDecls env name dcs
-    dcs  = Ms.dataDecls spec 
-    vdcs = Ms.dvariance spec 
-
--- | 'canonizeDecls ds' returns a subset of 'ds' with duplicates, e.g. arising
---   due to automatic lifting (via 'makeHaskellDataDecls'). We require that the
---   lifted versions appear LATER in the input list, and always use those
---   instead of the unlifted versions.
-
-canonizeDecls :: Bare.Env -> ModName -> [DataDecl] -> [DataDecl]
-canonizeDecls env name ds =
-  case Misc.uniqueByKey' selectDD kds of
-    Left  decls  -> err    decls
-    Right decls  -> decls
-  where
-    kds          = [ (k, d) | d <- ds, k <- Mb.maybeToList (dataDeclKey env name d) ] 
-    err ds@(d:_) = uError (errDupSpecs (pprint $ tycName d)(GM.fSrcSpan <$> ds))
-    err _        = impossible Nothing "canonizeDecls"
-
-dataDeclKey :: Bare.Env -> ModName -> DataDecl -> Maybe F.Symbol 
--- dataDeclKey env name = fmap F.symbol . Bare.lookupGhcDnTyCon env name "canonizeDecls" . tycName
-dataDeclKey env name d = do 
-  tc    <- Bare.lookupGhcDnTyCon env name "canonizeDecls" (tycName d)
-  _     <- checkDataCtors env name tc (tycDCons d)   
-  return (F.symbol tc)
-
-checkDataCtors :: Bare.Env -> ModName -> Ghc.TyCon -> [DataCtor] -> Maybe [DataCtor] 
-checkDataCtors env name c = mapM (checkDataCtor2 env name c dcs . checkDataCtor1) 
-  where 
-    dcs                   = S.fromList . fmap F.symbol $ Ghc.tyConDataCons c
-
-checkDataCtor2 :: Bare.Env -> ModName -> Ghc.TyCon -> S.HashSet F.Symbol -> DataCtor 
-               -> Maybe DataCtor 
-checkDataCtor2 env name c dcs d = do
-  let dn = dcName d
-  ctor  <- Bare.failMaybe env name (Bare.resolveLocSym env name "checkDataCtor2" dn :: Either UserError Ghc.DataCon) 
-  let x  = F.symbol ctor 
-  if S.member x dcs 
-    then Just d
-    else Ex.throw (errInvalidDataCon c dn)
-
-checkDataCtor1 :: DataCtor -> DataCtor 
-checkDataCtor1 d 
-  | x : _ <- dups = uError (err lc x :: UserError)
-  | otherwise     = d 
-    where
-      lc          = dcName   d 
-      xts         = dcFields d
-      dups        = [ x | (x, ts) <- Misc.groupList xts, 2 <= length ts ]
-      err lc x    = ErrDupField (GM.sourcePosSrcSpan $ loc lc) (pprint $ val lc) (pprint x)
-
-
-
-selectDD :: (a, [DataDecl]) -> Either [DataDecl] DataDecl
-selectDD (_,[d]) = Right d
-selectDD (_, ds) = case [ d | d <- ds, tycKind d == DataReflected ] of
-                     [d] -> Right d
-                     _   -> Left  ds
-
-groupVariances :: [DataDecl]
-               -> [(LocSymbol, [Variance])]
-               -> [(Maybe DataDecl, Maybe (LocSymbol, [Variance]))]
-groupVariances dcs vdcs     =  merge (L.sort dcs) (L.sortBy (\x y -> compare (fst x) (fst y)) vdcs)
-  where
-    merge (d:ds) (v:vs)
-      | F.symbol d == sym v = (Just d, Just v)  : merge ds vs
-      | F.symbol d <  sym v = (Just d, Nothing) : merge ds (v:vs)
-      | otherwise           = (Nothing, Just v) : merge (d:ds) vs
-    merge []     vs         = ((Nothing,) . Just) <$> vs
-    merge ds     []         = ((,Nothing) . Just) <$> ds
-    sym                     = val . fst
-
-
--- | 'checkDataDecl' checks that the supplied DataDecl is indeed a refinement
---   of the GHC TyCon. We just check that the right tyvars are supplied
---   as errors in the names and types of the constructors will be caught
---   elsewhere. [e.g. tests/errors/BadDataDecl.hs]
-
-checkDataDecl :: Ghc.TyCon -> DataDecl -> Bool
-checkDataDecl c d = F.notracepp _msg (isGADT || cN == dN || null (tycDCons d))
-  where
-    _msg          = printf "checkDataDecl: D = %s, c = %s, cN = %d, dN = %d" (show d) (show c) cN dN
-    cN            = length (GM.tyConTyVarsDef c)
-    dN            = length (tycTyVars         d)
-    isGADT        = Ghc.isGadtSyntaxTyCon c
-
-getDnTyCon :: Bare.Env -> ModName -> DataName -> Ghc.TyCon
-getDnTyCon env name dn = Mb.fromMaybe ugh (Bare.lookupGhcDnTyCon env name "ofBDataDecl-1" dn)
-  where 
-    ugh                = impossible Nothing "getDnTyCon"
-
--- FIXME: ES: why the maybes?
-ofBDataDecl :: Bare.Env -> ModName -> Maybe DataDecl -> (Maybe (LocSymbol, [Variance]))
-            -> ( (ModName, TyConP, Maybe DataPropDecl), [Located DataConP])
-ofBDataDecl env name (Just dd@(DataDecl tc as ps cts pos sfun pt _)) maybe_invariance_info
-  | not (checkDataDecl tc' dd)
-  = uError err
-  | otherwise
-  = ((name, tcp, Just (dd { tycDCons = cts }, pd)), Loc lc lc' <$> cts')
-  where
-    πs         = Bare.ofBPVar env name pos <$> ps
-    tc'        = getDnTyCon env name tc
-    -- cts        = checkDataCtors env name tc' cts0
-    cts'       = ofBDataCtor env name lc lc' tc' αs ps πs <$> cts
-    pd         = Bare.ofBareType env name lc (Just []) <$> pt
-    tys        = [t | dcp <- cts', (_, t) <- dcpTyArgs dcp]
-    initmap    = zip (RT.uPVar <$> πs) [0..]
-    varInfo    = L.nub $  concatMap (getPsSig initmap True) tys
-    defPs      = varSignToVariance varInfo <$> [0 .. (length πs - 1)]
-    (tvi, pvi) = f defPs
-    tcp          = TyConP lc tc' αs πs tvi pvi sfun
-    err          = ErrBadData (GM.fSrcSpan tc) (pprint tc) "Mismatch in number of type variables" :: UserError
-    αs           = RTV . GM.symbolTyVar <$> as
-    n            = length αs
-    Loc lc lc' _ = dataNameSymbol tc
-    f defPs      = case maybe_invariance_info of
-                     Nothing     -> ([], defPs)
-                     Just (_,is) -> (take n is, if null (drop n is) then defPs else (drop n is))
-
-ofBDataDecl env name Nothing (Just (tc, is))
-  = ((name, TyConP srcpos tc' [] [] tcov tcontr Nothing, Nothing), [])
-  where
-    tc'            = Bare.lookupGhcTyCon env name "ofBDataDecl-2" tc
-    (tcov, tcontr) = (is, [])
-    srcpos         = F.dummyPos "LH.DataType.Variance"
-
-ofBDataDecl _ _ Nothing Nothing
-  = panic Nothing "Bare.DataType.ofBDataDecl called on invalid inputs"
-
--- TODO:EFFECTS:ofBDataCon
-ofBDataCtor :: Bare.Env 
-            -> ModName
-            -> F.SourcePos
-            -> F.SourcePos
-            -> Ghc.TyCon
-            -> [RTyVar]
-            -> [PVar BSort]
-            -> [PVar RSort]
-            -> DataCtor
-            -> DataConP
-ofBDataCtor env name l l' tc αs ps πs _ctor@(DataCtor c as _ xts res) = DataConP 
-  { dcpLoc        = l                
-  , dcpCon        = c'                
-  , dcpFreeTyVars = RT.symbolRTyVar <$> as 
-  , dcpFreePred   = πs                 
-  , dcpTyConstrs  = cs                
-  , dcpTyArgs     = zts                 
-  , dcpTyRes      = ot                
-  , dcpIsGadt     = isGadt                
-  , dcpModule     = F.symbol name          
-  , dcpLocE       = l'
-  } 
-  where
-    c'            = Bare.lookupGhcDataCon env name "ofBDataCtor" c
-    ts'           = Bare.ofBareType env name l (Just ps) <$> ts
-    res'          = Bare.ofBareType env name l (Just ps) <$> res
-    t0'           = dataConResultTy c' αs t0 res'
-    _cfg          = getConfig env 
-    (yts, ot)     = -- F.tracepp ("dataConTys: " ++ F.showpp (c, αs)) $ 
-                      qualifyDataCtor (not isGadt) name dLoc (zip xs ts', t0')
-    zts           = zipWith (normalizeField c') [1..] (reverse yts)
-    usedTvs       = S.fromList (ty_var_value <$> concatMap RT.freeTyVars (t0':ts'))
-    cs            = [ p | p <- RT.ofType <$> Ghc.dataConTheta c', keepPredType usedTvs p ]
-    (xs, ts)      = unzip xts
-    t0            = case RT.famInstTyConType tc of
-                      Nothing -> F.notracepp "dataConResult-3: " $ RT.gApp tc αs πs
-                      Just ty -> RT.ofType ty
-    isGadt        = Mb.isJust res
-    dLoc          = F.Loc l l' ()
-
-
-
-
-errInvalidDataCon :: Ghc.TyCon -> LocSymbol -> UserError
-errInvalidDataCon c d = ErrBadGADT sp v msg
-  where
-    v                 = pprint (val d)
-    sp                = GM.sourcePosSrcSpan (loc d)
-    msg               = ppTicks c <+> "is not the type constructed by" <+> ppTicks v
-
-varSignToVariance :: Eq a => [(a, Bool)] -> a -> Variance
-varSignToVariance varsigns i = case filter (\p -> fst p == i) varsigns of
-                                []       -> Invariant
-                                [(_, b)] -> if b then Covariant else Contravariant
-                                _        -> Bivariant
-
-getPsSig :: [(UsedPVar, a)] -> Bool -> SpecType -> [(a, Bool)]
-getPsSig m pos (RAllT _ t r)
-  = addps m pos r ++  getPsSig m pos t
-getPsSig m pos (RApp _ ts rs r)
-  = addps m pos r ++ concatMap (getPsSig m pos) ts
-    ++ concatMap (getPsSigPs m pos) rs
-getPsSig m pos (RVar _ r)
-  = addps m pos r
-getPsSig m pos (RAppTy t1 t2 r)
-  = addps m pos r ++ getPsSig m pos t1 ++ getPsSig m pos t2
-getPsSig m pos (RFun _ t1 t2 r)
-  = addps m pos r ++ getPsSig m pos t2 ++ getPsSig m (not pos) t1
-getPsSig m pos (RHole r)
-  = addps m pos r
-getPsSig _ _ z
-  = panic Nothing $ "getPsSig" ++ show z
-
-getPsSigPs :: [(UsedPVar, a)] -> Bool -> SpecProp -> [(a, Bool)]
-getPsSigPs m pos (RProp _ (RHole r)) = addps m pos r
-getPsSigPs m pos (RProp _ t) = getPsSig m pos t
-
-addps :: [(UsedPVar, a)] -> b -> UReft t -> [(a, b)]
-addps m pos (MkUReft _ ps) = (flip (,)) pos . f  <$> pvars ps
-  where 
-    f = Mb.fromMaybe (panic Nothing "Bare.addPs: notfound") . (`L.lookup` m) . RT.uPVar
-
-keepPredType :: S.HashSet RTyVar -> SpecType -> Bool
-keepPredType tvs p
-  | Just (tv, _) <- eqSubst p = S.member tv tvs
-  | otherwise                 = True
-
-
--- | This computes the result of a `DataCon` application.
---   For 'isVanillaDataCon' we can just use the `TyCon`
---   applied to the relevant tyvars.
-dataConResultTy :: Ghc.DataCon
-                -> [RTyVar]         -- ^ DataConP ty-vars
-                -> SpecType         -- ^ vanilla result type
-                -> Maybe SpecType   -- ^ user-provided result type
-                -> SpecType
-dataConResultTy _ _ _ (Just t) = t
-dataConResultTy c _ t _
-  | Ghc.isVanillaDataCon c     = F.notracepp ("dataConResultTy-1 : " ++ F.showpp c) $ t
-  | otherwise                  = F.notracepp ("dataConResultTy-2 : " ++ F.showpp c) $ RT.ofType ct
-  where
-    (_,_,_,_,_,ct)             = Ghc.dataConFullSig c
-    -- _tr0                    = Ghc.dataConRepType c
-    -- _tr1                    = Ghc.varType (Ghc.dataConWorkId c)
-    -- _tr2                    = Ghc.varType (Ghc.dataConWrapId c)
-
-eqSubst :: SpecType -> Maybe (RTyVar, SpecType)
-eqSubst (RApp c [_, _, (RVar a _), t] _ _)
-  | rtc_tc c == Ghc.eqPrimTyCon = Just (a, t)
-eqSubst _                       = Nothing
-
-normalizeField :: Ghc.DataCon -> Int -> (F.Symbol, a) -> (F.Symbol, a)
-normalizeField c i (x, t)
-  | isTmp x   = (xi, t)
-  | otherwise = (x , t)
-  where
-    isTmp     = F.isPrefixOfSym F.tempPrefix
-    xi        = makeDataConSelector Nothing c i
-
--- | `qualifyDataCtor` qualfies the field names for each `DataCtor` to
---   ensure things work properly when exported.
-type CtorType = ([(F.Symbol, SpecType)], SpecType)
-
-qualifyDataCtor :: Bool -> ModName -> F.Located a -> CtorType -> CtorType
-qualifyDataCtor qualFlag name l ct@(xts, t)
- | qualFlag  = (xts', t')
- | otherwise = ct
- where
-   t'        = F.subst su <$> t
-   xts'      = [ (qx, F.subst su t)       | (qx, t, _) <- fields ]
-   su        = F.mkSubst [ (x, F.eVar qx) | (qx, _, Just x) <- fields ]
-   fields    = [ (qx, t, mbX) | (x, t) <- xts, let (mbX, qx) = qualifyField name (F.atLoc l x) ]
-
-qualifyField :: ModName -> LocSymbol -> (Maybe F.Symbol, F.Symbol)
-qualifyField name lx
- | needsQual = (Just x, F.notracepp msg $ qualifyModName name x) 
- | otherwise = (Nothing, x)
- where
-   msg       = "QUALIFY-NAME: " ++ show x ++ " in module " ++ show (F.symbol name)
-   x         = val lx
-   needsQual = not (isWiredIn lx)
-
-checkRecordSelectorSigs :: [(Ghc.Var, LocSpecType)] -> [(Ghc.Var, LocSpecType)]
-checkRecordSelectorSigs vts = [ (v, take1 v ts) | (v, ts) <- Misc.groupList vts ] 
-  where 
-    take1 v ts              = case Misc.nubHashOn (showpp . val) ts of 
-                                [t]    -> t 
-                                (t:ts) -> Ex.throw (ErrDupSpecs (GM.fSrcSpan t) (pprint v) (GM.fSrcSpan <$> ts) :: Error)
-                                _      -> impossible Nothing "checkRecordSelectorSigs"
-
-makeRecordSelectorSigs :: Bare.Env -> ModName -> [Located DataConP] -> [(Ghc.Var, LocSpecType)]
-makeRecordSelectorSigs env name = checkRecordSelectorSigs . concatMap makeOne
-  where
-  makeOne (Loc l l' dcp)
-    | null fls                    --    no field labels
-    || any (isFunTy . snd) args && not (higherOrderFlag env)   -- OR function-valued fields
-    || dcpIsGadt dcp              -- OR GADT style datcon
-    = []
-    | otherwise 
-    = [ (v, t) | (Just v, t) <- zip fs ts ] 
-    where
-      dc  = dcpCon dcp
-      fls = Ghc.dataConFieldLabels dc
-      fs  = Bare.lookupGhcNamedVar env name . Ghc.flSelector <$> fls 
-      ts :: [ LocSpecType ]
-      ts = [ Loc l l' (mkArrow (zip (makeRTVar <$> dcpFreeTyVars dcp) (repeat mempty)) []
-                                 [] [(z, res, mempty)]
-                                 (dropPreds (F.subst su t `RT.strengthen` mt)))
-             | (x, t) <- reverse args -- NOTE: the reverse here is correct
-             , let vv = rTypeValueVar t
-               -- the measure singleton refinement, eg `v = getBar foo`
-             , let mt = RT.uReft (vv, F.PAtom F.Eq (F.EVar vv) (F.EApp (F.EVar x) (F.EVar z)))
-             ]
-  
-      su   = F.mkSubst [ (x, F.EApp (F.EVar x) (F.EVar z)) | x <- fst <$> args ]
-      args = dcpTyArgs dcp
-      z    = F.notracepp ("makeRecordSelectorSigs:" ++ show args) "lq$recSel"
-      res  = dropPreds (dcpTyRes dcp)
-  
-      -- FIXME: this is clearly imprecise, but the preds in the DataConP seem
-      -- to be malformed. If we leave them in, tests/pos/kmp.hs fails with
-      -- a malformed predicate application. Niki, help!!
-      dropPreds = fmap (\(MkUReft r _ps) -> MkUReft r mempty)
diff --git a/src/Language/Haskell/Liquid/Bare/Expand.hs b/src/Language/Haskell/Liquid/Bare/Expand.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Expand.hs
+++ /dev/null
@@ -1,764 +0,0 @@
--- | This module has the code for applying refinement (and) type aliases 
---   and the pipeline for "cooking" a @BareType@ into a @SpecType@. 
---   TODO: _only_ export `makeRTEnv`, `cookSpecType` and maybe `qualifyExpand`...
-
-{-# LANGUAGE TupleSections         #-}
-{-# LANGUAGE TypeSynonymInstances  #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE PartialTypeSignatures #-}
-{-# LANGUAGE OverloadedStrings     #-}
-
-
-module Language.Haskell.Liquid.Bare.Expand 
-  ( -- * Create alias expansion environment
-    makeRTEnv 
-
-    -- * Expand and Qualify 
-  , qualifyExpand 
-
-    -- * Converting BareType to SpecType
-  , cookSpecType
-  , cookSpecTypeE
-  , specExpandType
-
-    -- * Re-exported for data-constructors
-  , plugHoles
-  ) where
-
-import Prelude hiding (error)
-import Data.Graph hiding (Graph)
-import Data.Maybe
-
-import           Control.Monad.State
-import qualified Control.Exception         as Ex
-import qualified Data.HashMap.Strict       as M
-import qualified Data.Char                 as Char
-import qualified Data.List                 as L
-import qualified Text.Printf               as Printf 
-import qualified Text.PrettyPrint.HughesPJ as PJ
-
-import qualified Language.Fixpoint.Types               as F 
--- import qualified Language.Fixpoint.Types.Visitor       as F 
-import qualified Language.Fixpoint.Misc                as Misc 
-import           Language.Fixpoint.Types (Expr(..)) -- , Symbol, symbol) 
-import qualified Language.Haskell.Liquid.GHC.Misc      as GM 
-import qualified Language.Haskell.Liquid.GHC.API       as Ghc 
-import qualified Language.Haskell.Liquid.Types.RefType as RT 
-import           Language.Haskell.Liquid.Types         hiding (fresh)
-import qualified Language.Haskell.Liquid.Misc          as Misc 
-import qualified Language.Haskell.Liquid.Measure       as Ms
-import qualified Language.Haskell.Liquid.Bare.Resolve  as Bare
-import qualified Language.Haskell.Liquid.Bare.Types    as Bare
-import qualified Language.Haskell.Liquid.Bare.Plugged  as Bare
-
---------------------------------------------------------------------------------
--- | `makeRTEnv` initializes the env needed to `expand` refinements and types,
---   that is, the below needs to be called *before* we use `Expand.expand`
---------------------------------------------------------------------------------
-makeRTEnv :: Bare.Env -> ModName -> Ms.BareSpec -> Bare.ModSpecs -> LogicMap 
-          -> BareRTEnv 
---------------------------------------------------------------------------------
-makeRTEnv env m mySpec iSpecs lmap 
-          = renameRTArgs $ makeRTAliases tAs $ makeREAliases eAs
-  where
-    tAs   = [ t                   | (_, s)  <- specs, t <- Ms.aliases  s ]
-    eAs   = [ specREAlias env m e | (m, s)  <- specs, e <- Ms.ealiases s ]
-         ++ [ specREAlias env m e | (_, xl) <- M.toList (lmSymDefs lmap)
-                                  , let e    = lmapEAlias xl             ]
-    specs = (m, mySpec) : M.toList iSpecs
-
--- | We apply @renameRTArgs@ *after* expanding each alias-definition, to 
---   ensure that the substitutions work properly (i.e. don't miss expressions 
---   hidden inside @RExprArg@ or as strange type parameters. 
-renameRTArgs :: BareRTEnv -> BareRTEnv 
-renameRTArgs rte = RTE 
-  { typeAliases = M.map (fmap ( renameTys . renameVV . renameRTVArgs)) (typeAliases rte) 
-  , exprAliases = M.map (fmap (                        renameRTVArgs)) (exprAliases rte) 
-  } 
-
-makeREAliases :: [Located (RTAlias F.Symbol F.Expr)] -> BareRTEnv 
-makeREAliases = graphExpand buildExprEdges f mempty 
-  where
-    f rtEnv xt = setREAlias rtEnv (expandLoc rtEnv xt)
-
-
--- | @renameTys@ ensures that @RTAlias@ type parameters have distinct names 
---   to avoid variable capture e.g. as in T1556.hs
-renameTys :: RTAlias F.Symbol BareType -> RTAlias F.Symbol BareType 
-renameTys rt = rt { rtTArgs = ys, rtBody = subts (rtBody rt) (zip xs ys) }
-  where 
-    xs    = rtTArgs rt 
-    ys    = (`F.suffixSymbol` rtName rt) <$> xs
-    subts = foldl (flip subt)
-
-
-renameVV :: RTAlias F.Symbol BareType -> RTAlias F.Symbol BareType 
-renameVV rt = rt { rtBody = RT.shiftVV (rtBody rt) (F.vv (Just 0)) }
-
--- | @renameRTVArgs@ ensures that @RTAlias@ value parameters have distinct names 
---   to avoid variable capture e.g. as in tests-names-pos-Capture01.hs
-renameRTVArgs :: (F.PPrint a, F.Subable a) => RTAlias x a -> RTAlias x a 
-renameRTVArgs rt = rt { rtVArgs = newArgs
-                      , rtBody  = F.notracepp msg $ F.subst su (rtBody rt) 
-                      } 
-  where 
-    msg          = "renameRTVArgs: " ++ F.showpp su
-    su           = F.mkSubst (zip oldArgs (F.eVar <$> newArgs)) 
-    newArgs      = zipWith rtArg (rtVArgs rt) [0..]
-    oldArgs      = rtVArgs rt
-    rtArg x i    = F.suffixSymbol x (F.intSymbol "rta" i) 
-
-makeRTAliases :: [Located (RTAlias F.Symbol BareType)] -> BareRTEnv -> BareRTEnv  
-makeRTAliases lxts rte = graphExpand buildTypeEdges f rte lxts 
-  where
-    f rtEnv xt         = setRTAlias rtEnv (expandLoc rtEnv xt)
-
-specREAlias :: Bare.Env -> ModName -> Located (RTAlias F.Symbol F.Expr) -> Located (RTAlias F.Symbol F.Expr) 
-specREAlias env m la = F.atLoc la $ a { rtBody = Bare.qualify env m (loc la) (rtVArgs a) (rtBody a) } 
-  where 
-    a     = val la 
-
---------------------------------------------------------------------------------------------------------------
-
-graphExpand :: (PPrint t)
-            => (AliasTable x t -> t -> [F.Symbol])         -- ^ dependencies
-            -> (thing -> Located (RTAlias x t) -> thing) -- ^ update
-            -> thing                                     -- ^ initial
-            -> [Located (RTAlias x t)]                   -- ^ vertices
-            -> thing                                     -- ^ final 
-graphExpand buildEdges expBody env lxts 
-           = L.foldl' expBody env (genExpandOrder table' graph)
-  where 
-    -- xts    = val <$> lxts
-    table  = buildAliasTable lxts
-    graph  = buildAliasGraph (buildEdges table) lxts
-    table' = checkCyclicAliases table graph
-
-setRTAlias :: RTEnv x t -> Located (RTAlias x t) -> RTEnv x t 
-setRTAlias env a = env { typeAliases =  M.insert n a (typeAliases env) } 
-  where 
-    n            = rtName (val a)  
-
-setREAlias :: RTEnv x t -> Located (RTAlias F.Symbol F.Expr) -> RTEnv x t 
-setREAlias env a = env { exprAliases = M.insert n a (exprAliases env) } 
-  where 
-    n            = rtName (val a)
-
-
-
---------------------------------------------------------------------------------
-type AliasTable x t = M.HashMap F.Symbol (Located (RTAlias x t))
-
-buildAliasTable :: [Located (RTAlias x t)] -> AliasTable x t
-buildAliasTable = M.fromList . map (\rta -> (rtName (val rta), rta))
-
-fromAliasSymbol :: AliasTable x t -> F.Symbol -> Located (RTAlias x t)
-fromAliasSymbol table sym
-  = fromMaybe err (M.lookup sym table)
-  where
-    err = panic Nothing ("fromAliasSymbol: Dangling alias symbol: " ++ show sym)
-
-type Graph t = [Node t]
-type Node  t = (t, t, [t])
-
-buildAliasGraph :: (PPrint t) => (t -> [F.Symbol]) -> [Located (RTAlias x t)] 
-                -> Graph F.Symbol
-buildAliasGraph buildEdges = map (buildAliasNode buildEdges)
-
-buildAliasNode :: (PPrint t) => (t -> [F.Symbol]) -> Located (RTAlias x t) 
-               -> Node F.Symbol
-buildAliasNode f la = (rtName a, rtName a, f (rtBody a))
-  where 
-    a               = val la 
-
-checkCyclicAliases :: AliasTable x t -> Graph F.Symbol -> AliasTable x t 
-checkCyclicAliases table graph
-  = case mapMaybe go (stronglyConnComp graph) of
-      []   -> table 
-      sccs -> Ex.throw (cycleAliasErr table <$> sccs)
-    where
-      go (CyclicSCC vs) = Just vs
-      go (AcyclicSCC _) = Nothing
-
-cycleAliasErr :: AliasTable x t -> [F.Symbol] -> Error
-cycleAliasErr _ []          = panic Nothing "checkCyclicAliases: No type aliases in reported cycle"
-cycleAliasErr t scc@(rta:_) = ErrAliasCycle { pos    = fst (locate rta)
-                                            , acycle = map locate scc }
-  where
-    locate sym = ( GM.fSrcSpan $ fromAliasSymbol t sym
-                 , pprint sym )
-
-
-genExpandOrder :: AliasTable x t -> Graph F.Symbol -> [Located (RTAlias x t)]
-genExpandOrder table graph
-  = map (fromAliasSymbol table) symOrder
-  where
-    (digraph, lookupVertex, _)
-      = graphFromEdges graph
-    symOrder
-      = map (Misc.fst3 . lookupVertex) $ reverse $ topSort digraph
-
---------------------------------------------------------------------------------
-
-ordNub :: Ord a => [a] -> [a]
-ordNub = map head . L.group . L.sort
-
-buildTypeEdges :: (F.Symbolic c) => AliasTable x t -> RType c tv r -> [F.Symbol]
-buildTypeEdges table = ordNub . go
-  where
-    -- go :: t -> [Symbol]
-    go (RApp c ts rs _) = go_alias (F.symbol c) ++ concatMap go ts ++ concatMap go (mapMaybe go_ref rs)
-    go (RImpF _ t1 t2 _) = go t1 ++ go t2
-    go (RFun _ t1 t2 _) = go t1 ++ go t2
-    go (RAppTy t1 t2 _) = go t1 ++ go t2
-    go (RAllE _ t1 t2)  = go t1 ++ go t2
-    go (REx _ t1 t2)    = go t1 ++ go t2
-    go (RAllT _ t _)    = go t
-    go (RAllP _ t)      = go t
-    go (RVar _ _)       = []
-    go (RExprArg _)     = []
-    go (RHole _)        = []
-    go (RRTy env _ _ t) = concatMap (go . snd) env ++ go t
-    go_alias c          = [c | M.member c table]
-    go_ref (RProp _ (RHole _)) = Nothing
-    go_ref (RProp  _ t) = Just t
-
-buildExprEdges :: M.HashMap F.Symbol a -> F.Expr -> [F.Symbol]
-buildExprEdges table  = ordNub . go
-  where
-    go :: F.Expr -> [F.Symbol]
-    go (EApp e1 e2)   = go e1 ++ go e2
-    go (ENeg e)       = go e
-    go (EBin _ e1 e2) = go e1 ++ go e2
-    go (EIte _ e1 e2) = go e1 ++ go e2
-    go (ECst e _)     = go e
-    go (ESym _)       = []
-    go (ECon _)       = []
-    go (EVar v)       = go_alias v
-    go (PAnd ps)       = concatMap go ps
-    go (POr ps)        = concatMap go ps
-    go (PNot p)        = go p
-    go (PImp p q)      = go p ++ go q
-    go (PIff p q)      = go p ++ go q
-    go (PAll _ p)      = go p
-    go (ELam _ e)      = go e
-    go (ECoerc _ _ e)  = go e
-    go (PAtom _ e1 e2) = go e1 ++ go e2
-    go (ETApp e _)     = go e
-    go (ETAbs e _)     = go e
-    go (PKVar _ _)     = []
-    go (PExist _ e)    = go e
-    go (PGrad _ _ _ e) = go e
-    go_alias f         = [f | M.member f table ]
-
-
-----------------------------------------------------------------------------------
--- | Using the `BareRTEnv` to do alias-expansion 
-----------------------------------------------------------------------------------
-class Expand a where 
-  expand :: BareRTEnv -> F.SourcePos -> a -> a 
-
-----------------------------------------------------------------------------------
--- | @qualifyExpand@ first qualifies names so that we can successfully resolve 
---   them during expansion. 
-----------------------------------------------------------------------------------
-qualifyExpand :: (Expand a, Bare.Qualify a) 
-              => Bare.Env -> ModName -> BareRTEnv -> F.SourcePos -> [F.Symbol] -> a -> a 
-----------------------------------------------------------------------------------
-qualifyExpand env name rtEnv l bs
-  = expand rtEnv l  
-  . Bare.qualify env name l bs
-
-----------------------------------------------------------------------------------
-expandLoc :: (Expand a) => BareRTEnv -> Located a -> Located a 
-expandLoc rtEnv lx = expand rtEnv (F.loc lx) <$> lx 
-
-instance Expand Expr where 
-  expand = expandExpr 
-
-instance Expand F.Reft where
-  expand rtEnv l (F.Reft (v, ra)) = F.Reft (v, expand rtEnv l ra) 
-
-instance Expand RReft where
-  expand rtEnv l = fmap (expand rtEnv l)
-
-expandReft :: (Expand r) => BareRTEnv -> F.SourcePos -> RType c tv r -> RType c tv r 
-expandReft rtEnv l = fmap (expand rtEnv l)
--- expandReft rtEnv l = emapReft (expand rtEnv l)
-
-
--- | @expand@ on a SpecType simply expands the refinements, 
---   i.e. *does not* apply the type aliases, but just the 
---   1. predicate aliases, 
---   2. inlines,
---   3. stuff from @LogicMap@
-
-instance Expand SpecType where
-  expand = expandReft 
-
--- | @expand@ on a BareType actually applies the type- and expression- aliases.
-instance Expand BareType where 
-  expand rtEnv l 
-    = expandReft     rtEnv l -- apply expression aliases 
-    . expandBareType rtEnv l -- apply type       aliases 
-
-instance Expand (RTAlias F.Symbol Expr) where 
-  expand rtEnv l x = x { rtBody = expand rtEnv l (rtBody x) } 
-
-instance Expand BareRTAlias where 
-  expand rtEnv l x = x { rtBody = expand rtEnv l (rtBody x) } 
-
-instance Expand Body where 
-  expand rtEnv l (P   p) = P   (expand rtEnv l p) 
-  expand rtEnv l (E   e) = E   (expand rtEnv l e)
-  expand rtEnv l (R x p) = R x (expand rtEnv l p)
-
-instance Expand DataCtor where 
-  expand rtEnv l c = c
-    { dcTheta  = expand rtEnv l (dcTheta c) 
-    , dcFields = [(x, expand rtEnv l t) | (x, t) <- dcFields c ] 
-    , dcResult = expand rtEnv l (dcResult c)
-    }
- 
-instance Expand DataDecl where 
-  expand rtEnv l d = d 
-    { tycDCons  = expand rtEnv l (tycDCons  d)
-    , tycPropTy = expand rtEnv l (tycPropTy d) 
-    } 
-
-instance Expand BareMeasure where 
-  expand rtEnv l m = m 
-    { msSort = expand rtEnv l (msSort m) 
-    , msEqns = expand rtEnv l (msEqns m)
-    } 
-
-instance Expand BareDef where 
-  expand rtEnv l d = d 
-    { dsort = expand rtEnv l (dsort d) 
-    , binds = [ (x, expand rtEnv l t) | (x, t) <- binds d] 
-    , body  = expand rtEnv l (body  d) 
-    } 
-
-instance Expand Ms.BareSpec where 
-  expand = expandBareSpec
-
-instance Expand a => Expand (F.Located a) where 
-  expand rtEnv _ = expandLoc rtEnv 
-
-instance Expand a => Expand (F.LocSymbol, a) where 
-  expand rtEnv l (x, y) = (x, expand rtEnv l y)
-
-instance Expand a => Expand (Maybe a) where 
-  expand rtEnv l = fmap (expand rtEnv l) 
-
-instance Expand a => Expand [a] where 
-  expand rtEnv l = fmap (expand rtEnv l) 
-
-instance Expand a => Expand (M.HashMap k a) where 
-  expand rtEnv l = fmap (expand rtEnv l) 
-
-expandBareSpec :: BareRTEnv -> F.SourcePos -> Ms.BareSpec -> Ms.BareSpec
-expandBareSpec rtEnv l sp = sp 
-  { measures   = expand rtEnv l (measures   sp) 
-  , asmSigs    = expand rtEnv l (asmSigs    sp)
-  , sigs       = expand rtEnv l (sigs       sp)
-  , localSigs  = expand rtEnv l (localSigs  sp)
-  , reflSigs   = expand rtEnv l (reflSigs   sp)
-  , ialiases   = [ (f x, f y) | (x, y) <- ialiases sp ]
-  , dataDecls  = expand rtEnv l (dataDecls  sp)
-  , newtyDecls = expand rtEnv l (newtyDecls sp)
-  } 
-  where f      = expand rtEnv l 
-  
-expandBareType :: BareRTEnv -> F.SourcePos -> BareType -> BareType 
-expandBareType rtEnv _ = go 
-  where
-    go (RApp c ts rs r)  = case lookupRTEnv c rtEnv of 
-                             Just rta -> expandRTAliasApp (GM.fSourcePos c) rta (go <$> ts) r 
-                             Nothing  -> RApp c (go <$> ts) (goRef <$> rs) r 
-    go (RAppTy t1 t2 r)  = RAppTy (go t1) (go t2) r
-    go (RImpF x t1 t2 r) = RImpF x (go t1) (go t2) r 
-    go (RFun  x t1 t2 r) = RFun  x (go t1) (go t2) r 
-    go (RAllT a t r)     = RAllT a (go t) r
-    go (RAllP a t)       = RAllP a (go t) 
-    go (RAllE x t1 t2)   = RAllE x (go t1) (go t2)
-    go (REx x t1 t2)     = REx   x (go t1) (go t2)
-    go (RRTy e r o t)    = RRTy  e r o     (go t)
-    go t@(RHole {})      = t 
-    go t@(RVar {})       = t 
-    go t@(RExprArg {})   = t 
-    goRef (RProp ss t)   = RProp ss (go t)
-
-lookupRTEnv :: BTyCon -> BareRTEnv -> Maybe (Located BareRTAlias)
-lookupRTEnv c rtEnv = M.lookup (F.symbol c) (typeAliases rtEnv)
-
-expandRTAliasApp :: F.SourcePos -> Located BareRTAlias -> [BareType] -> RReft -> BareType 
-expandRTAliasApp l (Loc la _ rta) args r = case isOK of 
-  Just e     -> Ex.throw e
-  Nothing    -> F.subst esu . (`RT.strengthen` r) . RT.subsTyVars_meet tsu $ rtBody rta
-  where
-    tsu       = zipWith (\α t -> (α, toRSort t, t)) αs ts
-    esu       = F.mkSubst $ zip (F.symbol <$> εs) es
-    es        = exprArg l msg <$> es0
-    (ts, es0) = splitAt nαs args
-    (αs, εs)  = (BTV <$> rtTArgs rta, rtVArgs rta)
-    targs     = takeWhile (not . isRExprArg) args
-    eargs     = dropWhile (not . isRExprArg) args
-
-    -- ERROR Checking Code
-    msg       = "EXPAND-RTALIAS-APP: " ++ F.showpp (rtName rta)
-    nαs       = length αs
-    nεs       = length εs 
-    nargs     = length args 
-    ntargs    = length targs
-    neargs    = length eargs
-    err       = errRTAliasApp l la rta 
-    isOK :: Maybe Error
-    isOK
-      | nargs /= ntargs + neargs
-      = err $ PJ.hsep ["Expects", pprint nαs, "type arguments and then", pprint nεs, "expression arguments, but is given", pprint nargs]
-      | nargs /= nαs + nεs
-      = err $ PJ.hsep ["Expects", pprint nαs, "type arguments and "    , pprint nεs, "expression arguments, but is given", pprint nargs]
-      | nαs /= ntargs, not (null eargs)
-      = err $ PJ.hsep ["Expects", pprint nαs, "type arguments before expression arguments"]
-      | otherwise
-      = Nothing
-
-isRExprArg :: RType c tv r -> Bool
-isRExprArg (RExprArg _) = True 
-isRExprArg _            = False 
-
-errRTAliasApp :: F.SourcePos -> F.SourcePos -> BareRTAlias -> PJ.Doc -> Maybe Error 
-errRTAliasApp l la rta = Just . ErrAliasApp  sp name sp' 
-  where 
-    name            = pprint              (rtName rta)
-    sp              = GM.sourcePosSrcSpan l
-    sp'             = GM.sourcePosSrcSpan la 
-
-
-
---------------------------------------------------------------------------------
--- | exprArg converts a tyVar to an exprVar because parser cannot tell
---   this function allows us to treating (parsed) "types" as "value"
---   arguments, e.g. type Matrix a Row Col = List (List a Row) Col
---   Note that during parsing, we don't necessarily know whether a
---   string is a type or a value expression. E.g. in tests/pos/T1189.hs,
---   the string `Prop (Ev (plus n n))` where `Prop` is the alias:
---     {-@ type Prop E = {v:_ | prop v = E} @-}
---   the parser will chomp in `Ev (plus n n)` as a `BareType` and so
---   `exprArg` converts that `BareType` into an `Expr`.
---------------------------------------------------------------------------------
-exprArg :: F.SourcePos -> String -> BareType -> Expr
-exprArg l msg = F.notracepp ("exprArg: " ++ msg) . go 
-  where 
-    go :: BareType -> Expr
-    go (RExprArg e)     = val e
-    go (RVar x _)       = EVar (F.symbol x)
-    go (RApp x [] [] _) = EVar (F.symbol x)
-    go (RApp f ts [] _) = F.mkEApp (F.symbol <$> btc_tc f) (go <$> ts)
-    go (RAppTy t1 t2 _) = F.EApp (go t1) (go t2)
-    go z                = panic sp $ Printf.printf "Unexpected expression parameter: %s in %s" (show z) msg
-    sp                  = Just (GM.sourcePosSrcSpan l)
-
-
-----------------------------------------------------------------------------------------
--- | @cookSpecType@ is the central place where a @BareType@ gets processed, 
---   in multiple steps, into a @SpecType@. See [NOTE:Cooking-SpecType] for 
---   details of each of the individual steps.
-----------------------------------------------------------------------------------------
-cookSpecType :: Bare.Env -> Bare.SigEnv -> ModName -> Bare.PlugTV Ghc.Var -> LocBareType 
-             -> LocSpecType 
-cookSpecType env sigEnv name x bt
-         = either Ex.throw id (cookSpecTypeE env sigEnv name x bt)
-  where 
-    _msg = "cookSpecType: " ++ GM.showPpr (z, Ghc.varType <$> z)
-    z    = Bare.plugSrc x 
-
-
------------------------------------------------------------------------------------------
-cookSpecTypeE :: Bare.Env -> Bare.SigEnv -> ModName -> Bare.PlugTV Ghc.Var -> LocBareType 
-              -> Either UserError LocSpecType 
------------------------------------------------------------------------------------------
-cookSpecTypeE env sigEnv name x bt
-  = id 
-  . fmap (plugHoles sigEnv name x)
-  . fmap (fmap (addTyConInfo   embs tyi))
-  . fmap (Bare.txRefSort tyi embs)     
-  . fmap (fmap txExpToBind)      -- What does this function DO
-  . fmap (specExpandType rtEnv)                        
-  . fmap (fmap (generalizeWith x))
-  . fmap (maybePlug       sigEnv name x)
-  . fmap (Bare.qualifyTop    env name l) 
-  . bareSpecType       env name 
-  . bareExpandType     rtEnv
-  $ bt 
-  where 
-    _msg i = "cook-" ++ show i ++ " : " ++ F.showpp x
-    rtEnv  = Bare.sigRTEnv    sigEnv
-    embs   = Bare.sigEmbs     sigEnv 
-    tyi    = Bare.sigTyRTyMap sigEnv
-    l      = F.loc bt
-
--- | We don't want to generalize type variables that maybe bound in the 
---   outer scope, e.g. see tests/basic/pos/LocalPlug00.hs 
-
-generalizeWith :: Bare.PlugTV Ghc.Var -> SpecType -> SpecType 
-generalizeWith (Bare.HsTV v) t = generalizeVar v t 
-generalizeWith  Bare.RawTV   t = t 
-generalizeWith _             t = RT.generalize t 
-
-generalizeVar :: Ghc.Var -> SpecType -> SpecType 
-generalizeVar v t = mkUnivs (zip as (repeat mempty)) [] t 
-  where 
-    as            = filter isGen (freeTyVars t)
-    (vas,_)       = Ghc.splitForAllTys (GM.expandVarType v) 
-    isGen (RTVar (RTV a) _) = a `elem` vas 
-
--- splitForAllTys :: Type -> ([TyVar], Type)
--- 
--- generalize :: (Eq tv) => RType c tv r -> RType c tv r
--- generalize t = mkUnivs (freeTyVars t) [] [] t 
-
-
-bareExpandType :: BareRTEnv -> LocBareType -> LocBareType 
-bareExpandType = expandLoc 
-
-specExpandType :: BareRTEnv -> LocSpecType -> LocSpecType
-specExpandType = expandLoc 
-
-bareSpecType :: Bare.Env -> ModName -> LocBareType -> Either UserError LocSpecType 
-bareSpecType env name bt = case Bare.ofBareTypeE env name (F.loc bt) Nothing (val bt) of 
-  Left e  -> Left e 
-  Right t -> Right (F.atLoc bt t)
-
-maybePlug :: Bare.SigEnv -> ModName -> Bare.PlugTV Ghc.Var -> LocSpecType -> LocSpecType 
-maybePlug sigEnv name kx = case Bare.plugSrc kx of 
-                             Nothing -> id  
-                             Just _  -> plugHoles sigEnv name kx 
-
-plugHoles :: Bare.SigEnv -> ModName -> Bare.PlugTV Ghc.Var -> LocSpecType -> LocSpecType 
-plugHoles sigEnv name = Bare.makePluggedSig name embs tyi exports
-  where 
-    embs              = Bare.sigEmbs     sigEnv 
-    tyi               = Bare.sigTyRTyMap sigEnv 
-    exports           = Bare.sigExports  sigEnv 
-
-{- [NOTE:Cooking-SpecType] 
-    A @SpecType@ is _raw_ when it is obtained directly from a @BareType@, i.e. 
-    just by replacing all the @BTyCon@ with @RTyCon@. Before it can be used 
-    for constraint generation, we need to _cook_ it via the following transforms:
-
-    A @SigEnv@ should contain _all_ the information needed to do the below steps.
-
-    - expand               : resolving all type/refinement etc. aliases 
-    - ofType               : convert BareType -> SpecType
-    - plugged              : filling in any remaining "holes"
-    - txRefSort            : filling in the abstract-refinement predicates etc. (YUCK) 
-    - resolve              : renaming / qualifying symbols?
-    - expand (again)       : as the "resolve" step can rename variables to trigger more aliases (e.g. member -> Data.Set.Internal.Member -> Set_mem)
-    - generalize           : (universally) quantify free type variables 
-    - strengthen-measures  : ?
-    - strengthen-inline(?) : ? 
-
--}
-
------------------------------------------------------------------------------------------------
--- | From BareOLD.Expand 
------------------------------------------------------------------------------------------------
-
-
-{- TODO-REBARE 
-instance Expand ty => Expand (Def ty ctor) where
-  expand z (Def f xts c t bxts b) =
-    Def f <$> expand z xts
-          <*> pure c
-          <*> expand z t
-          <*> expand z bxts
-          <*> expand z b
-
-instance Expand ty => Expand (Measure ty ctor) where
-  expand z (M n t ds k) =
-    M n <$> expand z t <*> expand z ds <*> pure k
-
-instance Expand DataConP where
-  expand z d = do
-    tyRes'    <- expand z (tyRes     d)
-    tyConsts' <- expand z (tyConstrs d)
-    tyArgs'   <- expand z (tyArgs    d)
-    return d { tyRes =  tyRes', tyConstrs = tyConsts', tyArgs = tyArgs' }
--}
-
---------------------------------------------------------------------------------
--- | @expandExpr@ applies the aliases and inlines in @BareRTEnv@ to its argument 
---   @Expr@. It must first @resolve@ the symbols in the refinement to see if 
---   they correspond to alias definitions. However, we ensure that we do not 
---   resolve bound variables (e.g. those bound in output refinements by input 
---   parameters), and we use the @bs@ parameter to pass in the bound symbols.
---------------------------------------------------------------------------------
-expandExpr :: BareRTEnv -> F.SourcePos -> Expr -> Expr
-expandExpr rtEnv l      = go
-  where
-    go e@(EApp _ _)     = expandEApp rtEnv l (F.splitEApp e)
-    go (EVar x)         = expandSym  rtEnv l x
-    go (ENeg e)         = ENeg       (go e)
-    go (ECst e s)       = ECst       (go e) s 
-    go (PAnd ps)        = PAnd       (go <$> ps)
-    go (POr ps)         = POr        (go <$> ps)
-    go (PNot p)         = PNot       (go p)
-    go (PAll xs p)      = PAll xs    (go p)
-    go (PExist xs p)    = PExist xs  (go p)
-    go (ELam xt e)      = ELam xt    (go e)
-    go (ECoerc a t e)   = ECoerc a t (go e)
-    go (ETApp e s)      = ETApp      (go e) s 
-    go (ETAbs e s)      = ETAbs      (go e) s 
-    go (EBin op e1 e2)  = EBin op    (go e1) (go e2)
-    go (PImp    e1 e2)  = PImp       (go e1) (go e2)
-    go (PIff    e1 e2)  = PIff       (go e1) (go e2)
-    go (PAtom b e1 e2)  = PAtom b    (go e1) (go e2)
-    go (EIte  p e1 e2)  = EIte (go p)(go e1) (go e2)
-    go (PGrad k su i e) = PGrad k su i (go e)
-    go e@(PKVar _ _)    = e
-    go e@(ESym _)       = e
-    go e@(ECon _)       = e
-
-expandSym :: BareRTEnv -> F.SourcePos -> F.Symbol -> Expr
-expandSym rtEnv l s' = expandEApp rtEnv l (EVar s', [])
-
--- REBARE :: expandSym' :: Symbol -> BareM Symbol
--- REBARE :: expandSym' s = do
-  -- REBARE :: axs <- gets axSyms
-  -- REBARE :: let s' = dropModuleNamesAndUnique s
-  -- REBARE :: return $ if M.member s' axs then s' else s
-
-expandEApp :: BareRTEnv -> F.SourcePos -> (Expr, [Expr]) -> Expr
-expandEApp rtEnv l (EVar f, es) = case mBody of
-    Just re -> expandApp l   re       es' 
-    Nothing -> F.eApps       (EVar f) es' 
-  where
-    eAs     = exprAliases rtEnv
-    mBody   = Misc.firstMaybes [M.lookup f eAs, M.lookup (GM.dropModuleUnique f) eAs]
-    es'     = expandExpr rtEnv l <$> es
-    _f0     = GM.dropModuleNamesAndUnique f
-
-expandEApp _ _ (f, es) = F.eApps f es
-
---------------------------------------------------------------------------------
--- | Expand Alias Application --------------------------------------------------
---------------------------------------------------------------------------------
-expandApp :: F.Subable ty => F.SourcePos -> Located (RTAlias F.Symbol ty) -> [Expr] -> ty
-expandApp l lre es
-  | Just su <- args = F.subst su (rtBody re)
-  | otherwise       = Ex.throw err
-  where
-    re              = F.val lre
-    args            = F.mkSubst <$> Misc.zipMaybe (rtVArgs re) es
-    err             :: UserError 
-    err             = ErrAliasApp sp alias sp' msg
-    sp              = GM.sourcePosSrcSpan l
-    alias           = pprint           (rtName re)
-    sp'             = GM.fSrcSpan lre -- sourcePosSrcSpan (rtPos re)
-    msg             =  "expects" PJ.<+> pprint (length $ rtVArgs re)
-                   PJ.<+> "arguments but it is given"
-                   PJ.<+> pprint (length es)
-
-
--------------------------------------------------------------------------------
--- | Replace Predicate Arguments With Existentials ----------------------------
--------------------------------------------------------------------------------
-txExpToBind   :: SpecType -> SpecType
--------------------------------------------------------------------------------
-txExpToBind t = evalState (expToBindT t) (ExSt 0 M.empty πs)
-  where 
-    πs        = M.fromList [(pname p, p) | p <- ty_preds $ toRTypeRep t ]
-
-data ExSt = ExSt { fresh :: Int
-                 , emap  :: M.HashMap F.Symbol (RSort, F.Expr)
-                 , pmap  :: M.HashMap F.Symbol RPVar
-                 }
-
--- | TODO: Niki please write more documentation for this, maybe an example?
---   I can't really tell whats going on... (RJ)
-
-expToBindT :: SpecType -> State ExSt SpecType
-expToBindT (RVar v r)
-  = expToBindRef r >>= addExists . RVar v
-expToBindT (RFun x t1 t2 r)
-  = do t1' <- expToBindT t1
-       t2' <- expToBindT t2
-       expToBindRef r >>= addExists . RFun x t1' t2'
-expToBindT (RAllT a t r)
-  = do t' <- expToBindT t 
-       expToBindRef r >>= addExists . RAllT a t' 
-expToBindT (RAllP p t)
-  = liftM (RAllP p) (expToBindT t)
-expToBindT (RApp c ts rs r)
-  = do ts' <- mapM expToBindT ts
-       rs' <- mapM expToBindReft rs
-       expToBindRef r >>= addExists . RApp c ts' rs'
-expToBindT (RAppTy t1 t2 r)
-  = do t1' <- expToBindT t1
-       t2' <- expToBindT t2
-       expToBindRef r >>= addExists . RAppTy t1' t2'
-expToBindT (RRTy xts r o t)
-  = do xts' <- zip xs <$> mapM expToBindT ts
-       r'   <- expToBindRef r
-       t'   <- expToBindT t
-       return $ RRTy xts' r' o t'
-  where
-     (xs, ts) = unzip xts
-expToBindT t
-  = return t
-
-expToBindReft              :: SpecProp -> State ExSt SpecProp
-expToBindReft (RProp s (RHole r)) = rPropP s <$> expToBindRef r
-expToBindReft (RProp s t)  = RProp s  <$> expToBindT t
-
-
-getBinds :: State ExSt (M.HashMap F.Symbol (RSort, F.Expr))
-getBinds
-  = do bds <- emap <$> get
-       modify $ \st -> st{emap = M.empty}
-       return bds
-
-addExists :: SpecType -> State ExSt SpecType
-addExists t = liftM (M.foldlWithKey' addExist t) getBinds
-
-addExist :: SpecType -> F.Symbol -> (RSort, F.Expr) -> SpecType
-addExist t x (tx, e) = REx x t' t
-  where 
-    t'               = (ofRSort tx) `strengthen` uTop r
-    r                = F.exprReft e
-
-expToBindRef :: UReft r -> State ExSt (UReft r)
-expToBindRef (MkUReft r (Pr p))
-  = mapM expToBind p >>= return . (MkUReft r) . Pr
-
-expToBind :: UsedPVar -> State ExSt UsedPVar
-expToBind p = do 
-  res <- liftM (M.lookup (pname p)) (pmap <$> get)
-  case res of 
-    Nothing -> 
-      panic Nothing ("expToBind: " ++ show p) 
-    Just π  -> do
-      let pargs0 = zip (pargs p) (Misc.fst3 <$> pargs π)
-      pargs' <- mapM expToBindParg pargs0
-      return $ p { pargs = pargs' }
-
-expToBindParg :: (((), F.Symbol, F.Expr), RSort) -> State ExSt ((), F.Symbol, F.Expr)
-expToBindParg ((t, s, e), s') = liftM ((,,) t s) (expToBindExpr e s')
-
-expToBindExpr :: F.Expr ->  RSort -> State ExSt F.Expr
-expToBindExpr e@(EVar s) _ 
-  | Char.isLower $ F.headSym $ F.symbol s
-  = return e
-expToBindExpr e t
-  = do s <- freshSymbol
-       modify $ \st -> st{emap = M.insert s (t, e) (emap st)}
-       return $ EVar s
-
-freshSymbol :: State ExSt F.Symbol
-freshSymbol
-  = do n <- fresh <$> get
-       modify $ \s -> s {fresh = n+1}
-       return $ F.symbol $ "ex#" ++ show n
-
diff --git a/src/Language/Haskell/Liquid/Bare/Laws.hs b/src/Language/Haskell/Liquid/Bare/Laws.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Laws.hs
+++ /dev/null
@@ -1,54 +0,0 @@
-module Language.Haskell.Liquid.Bare.Laws ( makeInstanceLaws ) where
-
-import qualified Data.Maybe                                 as Mb
-import qualified Data.List                                  as L
-import qualified Data.HashMap.Strict                        as M
-import           Control.Monad (join)
-
-import qualified Language.Haskell.Liquid.Measure            as Ms
-import qualified Language.Fixpoint.Types                    as F
-import qualified Language.Haskell.Liquid.GHC.Misc           as GM
-import           Language.Haskell.Liquid.Bare.Types         as Bare 
-import           Language.Haskell.Liquid.Bare.Resolve       as Bare
-import           Language.Haskell.Liquid.Bare.Expand        as Bare
-import           Language.Haskell.Liquid.Types
-import           Language.Haskell.Liquid.GHC.API            
-
-
-
-makeInstanceLaws :: Bare.Env -> Bare.SigEnv -> [(Var,LocSpecType)] 
-                -> Bare.ModSpecs -> [LawInstance]
-makeInstanceLaws env sigEnv sigs specs 
-  = [makeInstanceLaw env sigEnv sigs name rilaw 
-              | (name, spec) <- M.toList specs
-              , rilaw <- Ms.ilaws spec ]
-
-
-makeInstanceLaw :: Bare.Env -> Bare.SigEnv -> [(Var,LocSpecType)] -> ModName  
-                -> RILaws LocBareType -> LawInstance
-makeInstanceLaw env sigEnv sigs name rilaw = LawInstance
-  { lilName   = Mb.fromMaybe errmsg tc
-  , liSupers  = mkTy <$> rilSupers rilaw 
-  , lilTyArgs = mkTy <$> rilTyArgs rilaw
-  , lilEqus   = [(mkVar l, mkTypedVar r) | (l,r)<- rilEqus rilaw ]  
-  , lilPos    = GM.sourcePosSrcSpan $ loc $ rilPos rilaw
-  } 
-  where
-    tc    :: Maybe Class 
-    tc     = classTc (rilName rilaw)
-    errmsg = error ("Not a type class: " ++ F.showpp tc)
-
-    classTc = join . fmap tyConClass_maybe . Bare.maybeResolveSym env name "makeClass" . btc_tc  
-
-    mkTy :: LocBareType -> LocSpecType
-    mkTy = Bare.cookSpecType env sigEnv name Bare.GenTV 
-    mkVar :: LocSymbol -> VarOrLocSymbol 
-    mkVar x = case Bare.maybeResolveSym env name "makeInstanceLaw" x of 
-                Just v -> Left v 
-                _      -> Right x 
-
-    mkTypedVar :: LocSymbol -> (VarOrLocSymbol, Maybe LocSpecType)
-    mkTypedVar l = case mkVar l of 
-                     Left x -> (Left x, Just $ Mb.fromMaybe (dummyLoc $ ofType $ varType x) (L.lookup x sigs))
-                     Right x -> (Right x, Nothing)
-
diff --git a/src/Language/Haskell/Liquid/Bare/Measure.hs b/src/Language/Haskell/Liquid/Bare/Measure.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Measure.hs
+++ /dev/null
@@ -1,492 +0,0 @@
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE RecordWildCards  #-}
-{-# LANGUAGE TupleSections    #-}
-
--- | This module contains (most of) the code needed to lift Haskell entitites,
---   . code- (CoreBind), and data- (Tycon) definitions into the spec level.
-
-module Language.Haskell.Liquid.Bare.Measure
-  ( makeHaskellMeasures
-  , makeHaskellInlines
-  , makeHaskellDataDecls
-  , makeMeasureSelectors
-  , makeMeasureSpec
-  , makeMeasureSpec'
-  , varMeasures
-  , makeClassMeasureSpec
-  -- , makeHaskellBounds
-  ) where
-
-import Data.Default
-import qualified Control.Exception as Ex
-import Prelude hiding (mapM, error)
-import Data.Bifunctor
-import qualified Data.Maybe as Mb
-import Text.PrettyPrint.HughesPJ (text)
--- import Text.Printf     (printf)
-
-import qualified Data.HashMap.Strict as M
-import qualified Data.HashSet        as S
-
-import           Language.Fixpoint.SortCheck (isFirstOrder)
-import qualified Language.Fixpoint.Types as F
-import           Language.Haskell.Liquid.Transforms.CoreToLogic
-import qualified Language.Fixpoint.Misc                as Misc
-import qualified Language.Haskell.Liquid.Misc          as Misc
-import           Language.Haskell.Liquid.Misc             ((.||.))
-import qualified Language.Haskell.Liquid.GHC.API       as Ghc 
-import qualified Language.Haskell.Liquid.GHC.Misc      as GM
-import qualified Language.Haskell.Liquid.Types.RefType as RT
-import           Language.Haskell.Liquid.Types
--- import           Language.Haskell.Liquid.Types.Bounds
-import qualified Language.Haskell.Liquid.Measure       as Ms
-
-import qualified Language.Haskell.Liquid.Bare.Types    as Bare 
-import qualified Language.Haskell.Liquid.Bare.Resolve  as Bare 
-import qualified Language.Haskell.Liquid.Bare.Expand   as Bare 
-import qualified Language.Haskell.Liquid.Bare.DataType as Bare 
-import qualified Language.Haskell.Liquid.Bare.ToBare   as Bare 
-
---------------------------------------------------------------------------------
-makeHaskellMeasures :: GhcSrc -> Bare.TycEnv -> LogicMap -> Ms.BareSpec
-                    -> [Measure (Located BareType) LocSymbol]
---------------------------------------------------------------------------------
-makeHaskellMeasures src tycEnv lmap spec 
-          = Bare.measureToBare <$> ms
-  where 
-    ms    = makeMeasureDefinition tycEnv lmap cbs <$> mSyms 
-    cbs   = nonRecCoreBinds   (_giCbs src) 
-    mSyms = S.toList (Ms.hmeas spec)
-  
-makeMeasureDefinition :: Bare.TycEnv -> LogicMap -> [Ghc.CoreBind] -> LocSymbol 
-                      -> Measure LocSpecType Ghc.DataCon
-makeMeasureDefinition tycEnv lmap cbs x = 
-  case GM.findVarDef (val x) cbs of
-    Nothing       -> Ex.throw $ errHMeas x "Cannot extract measure from haskell function"
-    Just (v, def) -> Ms.mkM vx vinfo mdef MsLifted (makeUnSorted (Ghc.varType v) mdef) 
-                     where 
-                       vx           = F.atLoc x (F.symbol v)
-                       mdef         = coreToDef' tycEnv lmap vx v def
-                       vinfo        = GM.varLocInfo logicType v
-
-makeUnSorted :: Ghc.Type -> [Def LocSpecType Ghc.DataCon] -> UnSortedExprs
-makeUnSorted t defs
-  | isMeasureType ta 
-  = mempty
-  | otherwise
-  = map defToUnSortedExpr defs
-  where
-    ta = go $ Ghc.expandTypeSynonyms t
-
-    go (Ghc.ForAllTy _ t) = go t 
-    go (Ghc.FunTy { Ghc.ft_arg = p, Ghc.ft_res = t}) | Ghc.isClassPred p = go t 
-    go (Ghc.FunTy { Ghc.ft_arg = t }) = t 
-    go t                  = t -- this should never happen!
-
-    isMeasureType (Ghc.TyConApp _ ts) = all Ghc.isTyVarTy ts
-    isMeasureType _                   = False  
-
-    defToUnSortedExpr def = (xx:(fst <$> binds def), 
-                             Ms.bodyPred (F.mkEApp (measure def) [F.expr xx]) (body def)) 
-
-    xx = F.vv $ Just 10000
-
-coreToDef' :: Bare.TycEnv -> LogicMap -> LocSymbol -> Ghc.Var -> Ghc.CoreExpr 
-           -> [Def LocSpecType Ghc.DataCon] 
-coreToDef' tycEnv lmap vx v def = 
-  case runToLogic embs lmap dm (errHMeas vx) (coreToDef vx v def) of
-    Right l -> l
-    Left e  -> Ex.throw e
-  where 
-    embs    = Bare.tcEmbs       tycEnv 
-    dm      = Bare.tcDataConMap tycEnv  
-
-errHMeas :: LocSymbol -> String -> Error
-errHMeas x str = ErrHMeas (GM.sourcePosSrcSpan $ loc x) (pprint $ val x) (text str)
-
---------------------------------------------------------------------------------
-makeHaskellInlines :: GhcSrc -> F.TCEmb Ghc.TyCon -> LogicMap -> Ms.BareSpec 
-                   -> [(LocSymbol, LMap)]
---------------------------------------------------------------------------------
-makeHaskellInlines src embs lmap spec 
-         = makeMeasureInline embs lmap cbs <$> inls 
-  where
-    cbs  = nonRecCoreBinds (_giCbs src) 
-    inls = S.toList        (Ms.inlines spec)
-
-makeMeasureInline :: F.TCEmb Ghc.TyCon -> LogicMap -> [Ghc.CoreBind] -> LocSymbol
-                  -> (LocSymbol, LMap)
-makeMeasureInline embs lmap cbs x = 
-  case GM.findVarDef (val x) cbs of 
-    Nothing       -> Ex.throw $ errHMeas x "Cannot inline haskell function"
-    Just (v, def) -> (vx, coreToFun' embs Nothing lmap vx v def ok)
-                     where 
-                       vx         = F.atLoc x (F.symbol v)
-                       ok (xs, e) = LMap vx (F.symbol <$> xs) (either id id e)
-
--- | @coreToFun'@ takes a @Maybe DataConMap@: we need a proper map when lifting 
---   measures and reflects (which have case-of, and hence, need the projection symbols),
---   but NOT when lifting inlines (which do not have case-of). 
---   For details, see [NOTE:Lifting-Stages] 
-
-coreToFun' :: F.TCEmb Ghc.TyCon -> Maybe Bare.DataConMap -> LogicMap -> LocSymbol -> Ghc.Var -> Ghc.CoreExpr
-           -> (([Ghc.Var], Either F.Expr F.Expr) -> a) -> a
-coreToFun' embs dmMb lmap x v def ok = either Ex.throw ok act 
-  where 
-    act  = runToLogic embs lmap dm err xFun 
-    xFun = coreToFun x v def  
-    err  = errHMeas x  
-    dm   = Mb.fromMaybe mempty dmMb 
-
-
-nonRecCoreBinds :: [Ghc.CoreBind] -> [Ghc.CoreBind]
-nonRecCoreBinds            = concatMap go 
-  where 
-    go cb@(Ghc.NonRec _ _) = [cb]
-    go    (Ghc.Rec xes)    = [Ghc.NonRec x e | (x, e) <- xes]
-
--------------------------------------------------------------------------------
-makeHaskellDataDecls :: Config -> ModName -> Ms.BareSpec -> [Ghc.TyCon] 
-                     -> [DataDecl]
---------------------------------------------------------------------------------
-makeHaskellDataDecls cfg name spec tcs
-  | exactDCFlag cfg = Mb.mapMaybe tyConDataDecl
-                    -- . F.tracepp "makeHaskellDataDecls-3"
-                    . zipMap   (hasDataDecl name spec . fst)
-                    -- . F.tracepp "makeHaskellDataDecls-2"
-                    . liftableTyCons
-                    -- . F.tracepp "makeHaskellDataDecls-1"
-                    . filter isReflectableTyCon
-                    $ tcs
-  | otherwise       = []
-
-
-isReflectableTyCon :: Ghc.TyCon -> Bool
-isReflectableTyCon  = Ghc.isFamInstTyCon .||. Ghc.isVanillaAlgTyCon
-
-liftableTyCons :: [Ghc.TyCon] -> [(Ghc.TyCon, DataName)]
-liftableTyCons 
-  = F.notracepp "LiftableTCs 3"
-  . zipMapMaybe (tyConDataName True)
-  . F.notracepp "LiftableTCs 2"
-  . filter   (not . Ghc.isBoxedTupleTyCon)
-  . F.notracepp "LiftableTCs 1"
-  -- . (`sortDiff` wiredInTyCons)
-  -- . F.tracepp "LiftableTCs 0"
-
-zipMap :: (a -> b) -> [a] -> [(a, b)]
-zipMap f xs = zip xs (map f xs)
-
-zipMapMaybe :: (a -> Maybe b) -> [a] -> [(a, b)]
-zipMapMaybe f = Mb.mapMaybe (\x -> (x, ) <$> f x)
-
-hasDataDecl :: ModName -> Ms.BareSpec -> Ghc.TyCon -> HasDataDecl
-hasDataDecl mod spec
-                 = \tc -> F.notracepp (msg tc) $ M.lookupDefault def (tcName tc) decls
-  where
-    msg tc       = "hasDataDecl " ++ show (tcName tc)
-    def          = NoDecl Nothing
-    tcName       = fmap (qualifiedDataName mod) . tyConDataName True
-    dcName       =       qualifiedDataName mod  . tycName
-    decls        = M.fromList [ (Just dn, hasDecl d)
-                                | d     <- Ms.dataDecls spec
-                                , let dn = dcName d]
-
-qualifiedDataName :: ModName -> DataName -> DataName
-qualifiedDataName mod (DnName lx) = DnName (qualifyModName mod <$> lx)
-qualifiedDataName mod (DnCon  lx) = DnCon  (qualifyModName mod <$> lx)
-
-{-tyConDataDecl :: {tc:TyCon | isAlgTyCon tc} -> Maybe DataDecl @-}
-tyConDataDecl :: ((Ghc.TyCon, DataName), HasDataDecl) -> Maybe DataDecl
-tyConDataDecl (_, HasDecl)
-  = Nothing
-tyConDataDecl ((tc, dn), NoDecl szF)
-  = Just $ DataDecl
-      { tycName   = dn
-      , tycTyVars = F.symbol <$> GM.tyConTyVarsDef tc
-      , tycPVars  = []
-      , tycDCons  = decls tc
-      , tycSrcPos = GM.getSourcePos tc
-      , tycSFun   = szF
-      , tycPropTy = Nothing
-      , tycKind   = DataReflected
-      }
-      where decls = map dataConDecl . Ghc.tyConDataCons
-
-tyConDataName :: Bool -> Ghc.TyCon -> Maybe DataName
-tyConDataName full tc
-  | vanillaTc  = Just (DnName ((post . F.symbol) <$> GM.locNamedThing tc))
-  | d:_ <- dcs = Just (DnCon  ((post . F.symbol) <$> GM.locNamedThing d ))
-  | otherwise  = Nothing
-  where
-    post       = if full then id else GM.dropModuleNamesAndUnique
-    vanillaTc  = Ghc.isVanillaAlgTyCon tc
-    dcs        = Misc.sortOn F.symbol (Ghc.tyConDataCons tc)
-
-dataConDecl :: Ghc.DataCon -> DataCtor
-dataConDecl d     = {- F.notracepp msg $ -} DataCtor dx (F.symbol <$> as) [] xts outT
-  where
-    isGadt        = not (Ghc.isVanillaDataCon d)
-    -- msg           = printf "dataConDecl (gadt = %s)" (show isGadt)
-    xts           = [(Bare.makeDataConSelector Nothing d i, RT.bareOfType t) | (i, t) <- its ]
-    dx            = F.symbol <$> GM.locNamedThing d
-    its           = zip [1..] ts
-    (as,_ps,ts,t)  = Ghc.dataConSig d
-    outT          = Just (RT.bareOfType t :: BareType) 
-    _outT :: Maybe BareType
-    _outT
-      | isGadt    = Just (RT.bareOfType t)
-      | otherwise = Nothing
-
-
-
-
-
---------------------------------------------------------------------------------
--- | 'makeMeasureSelectors' converts the 'DataCon's and creates the measures for
---   the selectors and checkers that then enable reflection.
---------------------------------------------------------------------------------
-
-makeMeasureSelectors :: Config -> Bare.DataConMap -> Located DataConP -> [Measure SpecType Ghc.DataCon]
-makeMeasureSelectors cfg dm (Loc l l' c)
-  = (Misc.condNull (exactDCFlag cfg) $ checker : Mb.catMaybes (go' <$> fields)) --  internal measures, needed for reflection
- ++ (Misc.condNull (autofields)      $           Mb.catMaybes (go  <$> fields)) --  user-visible measures.
-  where
-    dc         = dcpCon    c 
-    isGadt     = dcpIsGadt c 
-    xts        = dcpTyArgs c
-    autofields = not (isGadt)
-    go ((x, t), i)
-      -- do not make selectors for functional fields
-      | isFunTy t && not (higherOrderFlag cfg)
-      = Nothing
-      | otherwise
-      = Just $ makeMeasureSelector (Loc l l' x) (projT i) dc n i
-
-    go' ((_,t), i)
-      -- do not make selectors for functional fields
-      | isFunTy t && not (higherOrderFlag cfg)
-      = Nothing
-      | otherwise
-      = Just $ makeMeasureSelector (Loc l l' (Bare.makeDataConSelector (Just dm) dc i)) (projT i) dc n i
-
-    fields   = zip (reverse xts) [1..]
-    n        = length xts
-    checker  = makeMeasureChecker (Loc l l' (Bare.makeDataConChecker dc)) checkT dc n
-    projT i  = dataConSel dc n (Proj i)
-    checkT   = dataConSel dc n Check
-
-dataConSel :: Ghc.DataCon -> Int -> DataConSel -> SpecType
-dataConSel dc n Check    = mkArrow (zip as (repeat mempty)) [] [] [xt] bareBool
-  where
-    (as, _, xt)          = {- traceShow ("dataConSel: " ++ show dc) $ -} bkDataCon dc n
-
-dataConSel dc n (Proj i) = mkArrow (zip as (repeat mempty)) [] [] [xt] (mempty <$> ti)
-  where
-    ti                   = Mb.fromMaybe err $ Misc.getNth (i-1) ts
-    (as, ts, xt)         = {- F.tracepp ("bkDatacon dc = " ++ F.showpp (dc, n)) $ -} bkDataCon dc n
-    err                  = panic Nothing $ "DataCon " ++ show dc ++ "does not have " ++ show i ++ " fields"
-
--- bkDataCon :: DataCon -> Int -> ([RTVar RTyVar RSort], [SpecType], (Symbol, SpecType, RReft))
-bkDataCon :: (F.Reftable (RTProp RTyCon RTyVar r), PPrint r, F.Reftable r) => Ghc.DataCon -> Int -> ([RTVar RTyVar RSort], [RRType r], (F.Symbol, RRType r, r))
-bkDataCon dc nFlds  = (as, ts, (F.dummySymbol, t, mempty))
-  where
-    ts                = RT.ofType <$> Misc.takeLast nFlds _ts
-    t                 = -- Misc.traceShow ("bkDataConResult" ++ GM.showPpr (dc, _t, _t0)) $
-                          RT.ofType  $ Ghc.mkTyConApp tc tArgs'
-    as                = makeRTVar . RT.rTyVar <$> (αs ++ αs')
-    ((αs,αs',_,_,_ts,_t), _t0) = hammer dc
-    tArgs'            = take (nArgs - nVars) tArgs ++ (Ghc.mkTyVarTy <$> αs)
-    nVars             = length αs
-    nArgs             = length tArgs
-    (tc, tArgs)       = Mb.fromMaybe err (Ghc.splitTyConApp_maybe _t)
-    err               = GM.namedPanic dc ("Cannot split result type of DataCon " ++ show dc)
-    hammer dc         = (Ghc.dataConFullSig dc, Ghc.varType . Ghc.dataConWorkId $ dc)
-
-data DataConSel = Check | Proj Int
-
-bareBool :: SpecType
-bareBool = RApp (RTyCon Ghc.boolTyCon [] def) [] [] mempty
-
-
-{- | NOTE:Use DataconWorkId
-
-      dcWorkId :: forall a1 ... aN. (a1 ~ X1 ...) => T1 -> ... -> Tn -> T
-      checkT   :: forall as. T -> Bool
-      projT t  :: forall as. T -> t
-
--}
-
-makeMeasureSelector :: (Show a1) => LocSymbol -> SpecType -> Ghc.DataCon -> Int -> a1 -> Measure SpecType Ghc.DataCon
-makeMeasureSelector x s dc n i = M { msName = x, msSort = s, msEqns = [eqn], msKind = MsSelector, msUnSorted = mempty}
-  where
-    eqn                        = Def x dc Nothing args (E (F.EVar $ mkx i))
-    args                       = ((, Nothing) . mkx) <$> [1 .. n]
-    mkx j                      = F.symbol ("xx" ++ show j)
-
-makeMeasureChecker :: LocSymbol -> SpecType -> Ghc.DataCon -> Int -> Measure SpecType Ghc.DataCon
-makeMeasureChecker x s0 dc n = M { msName = x, msSort = s, msEqns = eqn : (eqns <$> filter (/= dc) dcs), msKind = MsChecker, msUnSorted = mempty }
-  where
-    s       = F.notracepp ("makeMeasureChecker: " ++ show x) s0
-    eqn     = Def x dc Nothing (((, Nothing) . mkx) <$> [1 .. n])       (P F.PTrue)
-    eqns d  = Def x d  Nothing (((, Nothing) . mkx) <$> [1 .. nArgs d]) (P F.PFalse)
-    nArgs d = length (Ghc.dataConOrigArgTys d)
-    mkx j   = F.symbol ("xx" ++ show j)
-    dcs     = Ghc.tyConDataCons (Ghc.dataConTyCon dc)
-
-
-----------------------------------------------------------------------------------------------
-makeMeasureSpec' :: MSpec SpecType Ghc.DataCon -> ([(Ghc.Var, SpecType)], [(LocSymbol, RRType F.Reft)])
-----------------------------------------------------------------------------------------------
-makeMeasureSpec' mspec0 = (ctorTys, measTys) 
-  where 
-    ctorTys             = Misc.mapSnd RT.uRType <$> ctorTys0
-    (ctorTys0, measTys) = Ms.dataConTypes mspec 
-    mspec               = first (mapReft ur_reft) mspec0
-
-----------------------------------------------------------------------------------------------
-makeMeasureSpec :: Bare.Env -> Bare.SigEnv -> ModName -> (ModName, Ms.BareSpec) -> Ms.MSpec SpecType Ghc.DataCon
-----------------------------------------------------------------------------------------------
-makeMeasureSpec env sigEnv myName (name, spec) 
-  = mkMeasureDCon env               name 
-  . mkMeasureSort env               name 
-  . first val 
-  . bareMSpec     env sigEnv myName name 
-  $ spec 
-
-bareMSpec :: Bare.Env -> Bare.SigEnv -> ModName -> ModName -> Ms.BareSpec -> Ms.MSpec LocBareType LocSymbol 
-bareMSpec env sigEnv myName name spec = Ms.mkMSpec ms cms ims 
-  where
-    cms        = F.notracepp "CMS" $ filter inScope1 $             Ms.cmeasures spec
-    ms         = F.notracepp "UMS" $ filter inScope2 $ expMeas <$> Ms.measures  spec
-    ims        = F.notracepp "IMS" $ filter inScope2 $ expMeas <$> Ms.imeasures spec
-    expMeas    = expandMeasure env name  rtEnv
-    rtEnv      = Bare.sigRTEnv          sigEnv
-    force      = name == myName 
-    inScope1 z = F.notracepp ("inScope1: " ++ F.showpp (msName z)) $ (force ||  okSort z)
-    inScope2 z = F.notracepp ("inScope2: " ++ F.showpp (msName z)) $ (force || (okSort z && okCtors z))
-    okSort     = Bare.knownGhcType env name . msSort 
-    okCtors    = all (Bare.knownGhcDataCon env name . ctor) . msEqns 
-
-mkMeasureDCon :: Bare.Env -> ModName -> Ms.MSpec t LocSymbol -> Ms.MSpec t Ghc.DataCon
-mkMeasureDCon env name m = mkMeasureDCon_ m [ (val n, symDC n) | n <- measureCtors m ]
-  where 
-    symDC                = Bare.lookupGhcDataCon env name "measure-datacon"
-
-mkMeasureDCon_ :: Ms.MSpec t LocSymbol -> [(F.Symbol, Ghc.DataCon)] -> Ms.MSpec t Ghc.DataCon
-mkMeasureDCon_ m ndcs = m' {Ms.ctorMap = cm'}
-  where
-    m'                = fmap (tx.val) m
-    cm'               = Misc.hashMapMapKeys (F.symbol . tx) $ Ms.ctorMap m'
-    tx                = Misc.mlookup (M.fromList ndcs)
-
-measureCtors ::  Ms.MSpec t LocSymbol -> [LocSymbol]
-measureCtors = Misc.sortNub . fmap ctor . concat . M.elems . Ms.ctorMap
-
-mkMeasureSort :: Bare.Env -> ModName -> Ms.MSpec BareType LocSymbol 
-              -> Ms.MSpec SpecType LocSymbol
-mkMeasureSort env name (Ms.MSpec c mm cm im) = 
-  Ms.MSpec (map txDef <$> c) (tx <$> mm) (tx <$> cm) (tx <$> im) 
-    where
-      ofMeaSort :: F.SourcePos -> BareType -> SpecType
-      ofMeaSort l = Bare.ofBareType env name l Nothing 
-
-      tx :: Measure BareType ctor -> (Measure SpecType ctor)
-      tx (M n s eqs k u) = M n (ofMeaSort l s) (txDef <$> eqs) k u where l = GM.fSourcePos n
-
-      txDef :: Def BareType ctor -> (Def SpecType ctor)
-      txDef d = first (ofMeaSort l) d                              where l = GM.fSourcePos (measure d) 
-
-
-  
---------------------------------------------------------------------------------
--- | Expand Measures -----------------------------------------------------------
---------------------------------------------------------------------------------
--- type BareMeasure = Measure LocBareType LocSymbol
-
-expandMeasure :: Bare.Env -> ModName -> BareRTEnv -> BareMeasure -> BareMeasure
-expandMeasure env name rtEnv m = m 
-  { msSort = RT.generalize                   <$> msSort m
-  , msEqns = expandMeasureDef env name rtEnv <$> msEqns m 
-  }
-
-expandMeasureDef :: Bare.Env -> ModName -> BareRTEnv -> Def t LocSymbol -> Def t LocSymbol
-expandMeasureDef env name rtEnv d = d 
-  { body  = F.notracepp msg $ Bare.qualifyExpand env name rtEnv l bs (body d) }
-  where 
-    l     = loc (measure d) 
-    bs    = fst <$> binds d 
-    msg   = "QUALIFY-EXPAND-BODY" ++ F.showpp (bs, body d) 
-
-------------------------------------------------------------------------------
-varMeasures :: (Monoid r) => Bare.Env -> [(F.Symbol, Located (RRType r))]
-------------------------------------------------------------------------------
-varMeasures env = 
-  [ (F.symbol v, varSpecType v) 
-      | v <- knownVars env 
-      , GM.isDataConId v
-      , isSimpleType (Ghc.varType v) ]
-
-knownVars :: Bare.Env -> [Ghc.Var]
-knownVars env = [ v | (_, xThings)   <- M.toList (Bare._reTyThings env) 
-                    , (_,Ghc.AnId v) <- xThings 
-                ]
-
-varSpecType :: (Monoid r) => Ghc.Var -> Located (RRType r)
-varSpecType = fmap (RT.ofType . Ghc.varType) . GM.locNamedThing
-
-isSimpleType :: Ghc.Type -> Bool
-isSimpleType = isFirstOrder . RT.typeSort mempty
-
-makeClassMeasureSpec :: MSpec (RType c tv (UReft r2)) t
-                     -> [(LocSymbol, CMeasure (RType c tv r2))]
-makeClassMeasureSpec (Ms.MSpec {..}) = tx <$> M.elems cmeasMap
-  where
-    tx (M n s _ _ _) = (n, CM n (mapReft ur_reft s))
-
-
-{- 
-expandMeasureBody :: Bare.Env -> ModName -> BareRTEnv -> SourcePos -> Body -> Body
-expandMeasureBody env name rtEnv l (P   p) = P   (Bare.expandQualify env name rtEnv l p) 
-expandMeasureBody env name rtEnv l (R x p) = R x (Bare.expandQualify env name rtEnv l p) 
-expandMeasureBody env name rtEnv l (E   e) = E   (Bare.expandQualify env name rtEnv l e) 
-
-
-makeHaskellBounds :: F.TCEmb TyCon -> CoreProgram -> S.HashSet (Var, LocSymbol) -> BareM RBEnv  -- TODO-REBARE
-makeHaskellBounds embs cbs xs = do
-  lmap <- gets logicEnv
-  M.fromList <$> mapM (makeHaskellBound embs lmap cbs) (S.toList xs)
-
-makeHaskellBound :: F.TCEmb TyCon
-                 -> LogicMap
-                 -> [Bind Var]
-                 -> (Var, Located Symbol)
-                 -> BareM (LocSymbol, RBound)
-makeHaskellBound embs lmap  cbs (v, x) =
-  case filter ((v  `elem`) . GM.binders) cbs of
-    (NonRec v def:_)   -> toBound v x <$> coreToFun' embs lmap x v def return
-    (Rec [(v, def)]:_) -> toBound v x <$> coreToFun' embs lmap x v def return
-    _                  -> throwError $ errHMeas x "Cannot make bound of haskell function"
-
-
-
-toBound :: Var -> LocSymbol -> ([Var], Either F.Expr F.Expr) -> (LocSymbol, RBound)
-toBound v x (vs, Left p) = (x', Bound x' fvs ps xs p)
-  where
-    x'         = capitalizeBound x
-    (ps', xs') = L.partition (hasBoolResult . varType) vs
-    (ps , xs)  = (txp <$> ps', txx <$> xs')
-    txp v      = (dummyLoc $ simpleSymbolVar v, RT.ofType $ varType v)
-    txx v      = (dummyLoc $ symbol v,          RT.ofType $ varType v)
-    fvs        = (((`RVar` mempty) . RTV) <$> fst (splitForAllTys $ varType v)) :: [RSort]
-
-toBound v x (vs, Right e) = toBound v x (vs, Left e)
-
-capitalizeBound :: Located Symbol -> Located Symbol
-capitalizeBound = fmap (symbol . toUpperHead . symbolString)
-  where
-    toUpperHead []     = []
-    toUpperHead (x:xs) = toUpper x:xs
-
--}
-
diff --git a/src/Language/Haskell/Liquid/Bare/Misc.hs b/src/Language/Haskell/Liquid/Bare/Misc.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Misc.hs
+++ /dev/null
@@ -1,184 +0,0 @@
-{-# LANGUAGE FlexibleContexts         #-}
-
-module Language.Haskell.Liquid.Bare.Misc 
-  ( freeSymbols
-  , joinVar
-  , mkVarExpr
-  , vmap
-  , runMapTyVars
-  , matchKindArgs
-  , symbolRTyVar
-  , simpleSymbolVar
-  , hasBoolResult
-  , isKind
-  ) where
-
-import           Prelude                               hiding (error)
-
-import           Language.Haskell.Liquid.GHC.API       as Ghc  hiding (Located)
-
-import           Control.Monad.Except                  (MonadError, throwError)
-import           Control.Monad.State
-import qualified Data.Maybe                            as Mb --(fromMaybe, isNothing)
-
-import qualified Text.PrettyPrint.HughesPJ             as PJ 
-import qualified Data.List                             as L
-import qualified Data.HashMap.Strict                   as M
-import           Language.Fixpoint.Misc                as Misc -- (singleton, sortNub)
-import qualified Language.Fixpoint.Types as F
-import           Language.Haskell.Liquid.GHC.Misc
-import           Language.Haskell.Liquid.Types.RefType
-import           Language.Haskell.Liquid.Types.Types
-
--- import           Language.Haskell.Liquid.Bare.Env
-
--- import           Language.Haskell.Liquid.WiredIn       (dcPrefix)
-
-
--- TODO: This is where unsorted stuff is for now. Find proper places for what follows.
-
-{- 
--- WTF does this function do?
-makeSymbols :: (Id -> Bool) -> [Id] -> [F.Symbol] -> BareM [(F.Symbol, Var)]
-makeSymbols f vs xs
-  = do svs <- M.toList <$> gets varEnv
-       return $ L.nub ([ (x,v') | (x,v) <- svs, x `elem` xs, let (v',_,_) = joinVar vs (v,x,x)]
-                   ++  [ (F.symbol v, v) | v <- vs, f v, isDataConId v, hasBasicArgs $ varType v ])
-    where
-      -- arguments should be basic so that autogenerated singleton types are well formed
-      hasBasicArgs (ForAllTy _ t) = hasBasicArgs t
-      hasBasicArgs (FunTy _ tx t)   = isBaseTy tx && hasBasicArgs t
-      hasBasicArgs _              = True
-
--} 
-
-freeSymbols :: (F.Reftable r, F.Reftable r1, F.Reftable r2, TyConable c, TyConable c1, TyConable c2)
-            => [F.Symbol]
-            -> [(a1, Located (RType c2 tv2 r2))]
-            -> [(a, Located (RType c1 tv1 r1))]
-            -> [(Located (RType c tv r))]
-            -> [LocSymbol]
-freeSymbols xs' xts yts ivs =  [ lx | lx <- Misc.sortNub $ zs ++ zs' ++ zs'' , not (M.member (val lx) knownM) ]
-  where
-    knownM                  = M.fromList [ (x, ()) | x <- xs' ]
-    zs                      = concatMap freeSyms (snd <$> xts)
-    zs'                     = concatMap freeSyms (snd <$> yts)
-    zs''                    = concatMap freeSyms ivs
-
-
-
-freeSyms :: (F.Reftable r, TyConable c) => Located (RType c tv r) -> [LocSymbol]
-freeSyms ty    = [ F.atLoc ty x | x <- tySyms ]
-  where
-    tySyms     = Misc.sortNub $ concat $ efoldReft (\_ _ -> True) False (\_ _ -> []) (\_ -> []) (const ()) f (const id) F.emptySEnv [] (val ty)
-    f γ _ r xs = let F.Reft (v, _) = F.toReft r in
-                 [ x | x <- F.syms r, x /= v, not (x `F.memberSEnv` γ)] : xs
-
--------------------------------------------------------------------------------
--- Renaming Type Variables in Haskell Signatures ------------------------------
--------------------------------------------------------------------------------
-runMapTyVars :: Type -> SpecType -> (PJ.Doc -> PJ.Doc -> Error) -> Either Error MapTyVarST
-runMapTyVars τ t err = execStateT (mapTyVars τ t) (MTVST [] err) 
-
-data MapTyVarST = MTVST
-  { vmap   :: [(Var, RTyVar)]
-  , errmsg :: PJ.Doc -> PJ.Doc -> Error
-  }
-
-mapTyVars :: Type -> SpecType -> StateT MapTyVarST (Either Error) ()
-mapTyVars t (RImpF _ _ t' _)
-   = mapTyVars t t'
-mapTyVars (FunTy { ft_arg = τ, ft_res = τ'}) t 
-  | isClassPred τ
-  = mapTyVars τ' t
-mapTyVars (FunTy { ft_arg = τ, ft_res = τ'}) (RFun _ t t' _)
-   = mapTyVars τ t >> mapTyVars τ' t'
-mapTyVars τ (RAllT _ t _)
-  = mapTyVars τ t
-mapTyVars (TyConApp _ τs) (RApp _ ts _ _)
-   = zipWithM_ mapTyVars τs (matchKindArgs' τs ts)
-mapTyVars (TyVarTy α) (RVar a _)
-   = do s  <- get
-        s' <- mapTyRVar α a s
-        put s'
-mapTyVars τ (RAllP _ t)
-  = mapTyVars τ t
-mapTyVars τ (RAllE _ _ t)
-  = mapTyVars τ t
-mapTyVars τ (RRTy _ _ _ t)
-  = mapTyVars τ t
-mapTyVars τ (REx _ _ t)
-  = mapTyVars τ t
-mapTyVars _ (RExprArg _)
-  = return ()
-mapTyVars (AppTy τ τ') (RAppTy t t' _)
-  = do  mapTyVars τ t
-        mapTyVars τ' t'
-mapTyVars _ (RHole _)
-  = return ()
-mapTyVars k _ | isKind k
-  = return ()
-mapTyVars (ForAllTy _ τ) t
-  = mapTyVars τ t
-mapTyVars hsT lqT
-  = do err <- errmsg <$> get
-       throwError (err (F.pprint hsT) (F.pprint lqT)) 
-
-isKind :: Kind -> Bool
-isKind = classifiesTypeWithValues -- TODO:GHC-863 isStarKind k --  typeKind k
-
-
-mapTyRVar :: MonadError Error m
-          => Var -> RTyVar -> MapTyVarST -> m MapTyVarST
-mapTyRVar α a s@(MTVST αas err)
-  = case lookup α αas of
-      Just a' | a == a'   -> return s
-              | otherwise -> throwError (err (F.pprint a) (F.pprint a'))
-      Nothing             -> return $ MTVST ((α,a):αas) err
-
-matchKindArgs' :: [Type] -> [SpecType] -> [SpecType]
-matchKindArgs' ts1 ts2 = reverse $ go (reverse ts1) (reverse ts2)
-  where
-    go (_:ts1) (t2:ts2) = t2:go ts1 ts2
-    go ts      []       | all isKind ts
-                        = (ofType <$> ts) :: [SpecType]
-    go _       ts       = ts
-
-
-matchKindArgs :: [SpecType] -> [SpecType] -> [SpecType]
-matchKindArgs ts1 ts2 = reverse $ go (reverse ts1) (reverse ts2)
-  where
-    go (_:ts1) (t2:ts2) = t2:go ts1 ts2
-    go ts      []       = ts
-    go _       ts       = ts
-
-mkVarExpr :: Id -> F.Expr
-mkVarExpr v
-  | isFunVar v = F.mkEApp (varFunSymbol v) []
-  | otherwise  = F.eVar v -- EVar (symbol v)
-
-varFunSymbol :: Id -> Located F.Symbol
-varFunSymbol = dummyLoc . F.symbol . idDataCon
-
-isFunVar :: Id -> Bool
-isFunVar v   = isDataConId v && not (null αs) && Mb.isNothing tf
-  where
-    (αs, t)  = splitForAllTys $ varType v
-    tf       = splitFunTy_maybe t
-
--- the Vars we lookup in GHC don't always have the same tyvars as the Vars
--- we're given, so return the original var when possible.
--- see tests/pos/ResolvePred.hs for an example
-joinVar :: [Var] -> (Var, s, t) -> (Var, s, t)
-joinVar vs (v,s,t) = case L.find ((== showPpr v) . showPpr) vs of
-                       Just v' -> (v',s,t)
-                       Nothing -> (v,s,t)
-
-simpleSymbolVar :: Var -> F.Symbol
-simpleSymbolVar  = dropModuleNames . F.symbol . showPpr . getName
-
-hasBoolResult :: Type -> Bool
-hasBoolResult (ForAllTy _ t) = hasBoolResult t
-hasBoolResult (FunTy { ft_res = t} )    | eqType boolTy t = True
-hasBoolResult (FunTy { ft_res = t} )    = hasBoolResult t
-hasBoolResult _              = False
diff --git a/src/Language/Haskell/Liquid/Bare/Plugged.hs b/src/Language/Haskell/Liquid/Bare/Plugged.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Plugged.hs
+++ /dev/null
@@ -1,277 +0,0 @@
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE TupleSections         #-}
-{-# LANGUAGE PartialTypeSignatures #-}
-
-module Language.Haskell.Liquid.Bare.Plugged 
-  ( makePluggedSig
-  , makePluggedDataCon
-  ) where
-
-import Prelude hiding (error)
-import Data.Generics.Aliases (mkT)
-import Data.Generics.Schemes (everywhere)
-
-import           Text.PrettyPrint.HughesPJ
-import qualified Control.Exception                 as Ex
-import qualified Data.HashMap.Strict               as M
-import qualified Data.HashSet                      as S
-import qualified Data.Maybe                        as Mb 
-import qualified Data.List                         as L 
-import qualified Language.Fixpoint.Types           as F
-import qualified Language.Fixpoint.Types.Visitor   as F
-import qualified Language.Haskell.Liquid.GHC.Misc  as GM 
-import qualified Language.Haskell.Liquid.GHC.API   as Ghc 
-import           Language.Haskell.Liquid.GHC.Types (StableName, mkStableName)
-import           Language.Haskell.Liquid.Types.RefType ()
-import           Language.Haskell.Liquid.Types
-import qualified Language.Haskell.Liquid.Misc       as Misc 
-import qualified Language.Haskell.Liquid.Bare.Types as Bare
-import qualified Language.Haskell.Liquid.Bare.Misc  as Bare
-
----------------------------------------------------------------------------------------
--- [NOTE: Plug-Holes-TyVars] We have _two_ versions of `plugHoles:
--- * `HsTyVars` ensures that the returned signature uses the GHC type variables;
---   We need this as these tyvars can appear in the SOURCE (as type annotations, or
---   as the types of lambdas) and renaming them will cause problems; 
--- * `LqTyVars` ensures that the returned signatuer uses the LIQUID type variables; 
---   We need this e.g. for class specifications where we cannot change the tyvars 
---   used inside method signatures as that messes up the type for the data-constructor 
---   for the dictionary (as we need to use the same tyvars as are "bound" in the class 
---   definition).
--- In short, use `HsTyVars` when we also have to analyze the binder's SOURCE; and 
--- otherwise, use `LqTyVars`.
----------------------------------------------------------------------------------------
-
---------------------------------------------------------------------------------
--- | NOTE: Be *very* careful with the use functions from RType -> GHC.Type,
---   e.g. toType, in this module as they cannot handle LH type holes. Since
---   this module is responsible for plugging the holes we obviously cannot
---   assume, as in e.g. L.H.L.Constraint.* that they do not appear.
---------------------------------------------------------------------------------
-makePluggedSig :: ModName -> F.TCEmb Ghc.TyCon -> TyConMap -> S.HashSet StableName
-               -> Bare.PlugTV Ghc.Var -> LocSpecType
-               -> LocSpecType
-
-makePluggedSig name embs tyi exports kx t 
-  | Just x <- kxv = mkPlug x 
-  | otherwise     = t
-  where 
-    kxv           = Bare.plugSrc kx
-    mkPlug x      = plugHoles kx embs tyi  r τ t
-      where
-        τ         = Ghc.expandTypeSynonyms (Ghc.varType x)
-        r         = maybeTrue x name exports
-    -- x = case kx of { Bare.HsTV x -> x ; Bare.LqTV x -> x }
-
-
--- makePluggedDataCon = makePluggedDataCon_old 
--- plugHoles          = plugHoles_old 
--- makePluggedDataCon = makePluggedDataCon_new 
-
--- plugHoles _         = plugHoles_old
-
-plugHoles :: (Ghc.NamedThing a, PPrint a, Show a) 
-          => Bare.PlugTV a
-          -> F.TCEmb Ghc.TyCon
-          -> Bare.TyConMap
-          -> (SpecType -> RReft -> RReft)
-          -> Ghc.Type
-          -> LocSpecType
-          -> LocSpecType
-plugHoles (Bare.HsTV x) a b = plugHoles_old a b x 
-plugHoles (Bare.LqTV x) a b = plugHoles_new a b x 
-plugHoles _             _ _ = \_ _ t -> t
-
-
-makePluggedDataCon :: F.TCEmb Ghc.TyCon -> Bare.TyConMap -> Located DataConP -> Located DataConP
-makePluggedDataCon embs tyi ldcp 
-  | mismatchFlds      = Ex.throw (err "fields")
-  | mismatchTyVars    = Ex.throw (err "type variables")
-  | otherwise         = F.atLoc ldcp $ F.notracepp "makePluggedDataCon" $ dcp 
-                          { dcpFreeTyVars = dcVars
-                          , dcpTyArgs     = reverse tArgs 
-                          , dcpTyRes      = tRes 
-                          }
-  where 
-    (tArgs, tRes)     = plugMany       embs tyi ldcp (das, dts, dt) (dcVars, dcArgs, dcpTyRes dcp)
-    (das, _, dts, dt) = {- F.notracepp ("makePluggedDC: " ++ F.showpp dc) $ -} Ghc.dataConSig dc
-    dcArgs            = filter (not . isClassType . snd) $ reverse (dcpTyArgs dcp)
-    dcVars            = if isGADT 
-                          then padGADVars $ L.nub (dcpFreeTyVars dcp ++ (concatMap (map ty_var_value . freeTyVars) (dcpTyRes dcp:(snd <$> dcArgs))))
-                          else dcpFreeTyVars dcp 
-    dc                = dcpCon        dcp
-    dcp               = val           ldcp 
-
-    isGADT            = Ghc.isGadtSyntaxTyCon $ Ghc.dataConTyCon dc
-
-    -- hack to match LH and GHC GADT vars, since it is unclear how ghc generates free vars 
-    padGADVars vs = (RTV <$> take (length das - length vs) das) ++ vs
-
-    mismatchFlds      = length dts /= length dcArgs 
-    mismatchTyVars    = length das /= length dcVars 
-    err things        = ErrBadData (GM.fSrcSpan dcp) (pprint dc) ("GHC and Liquid specifications have different numbers of" <+> things) :: UserError
-
-
--- | @plugMany@ is used to "simultaneously" plug several different types, 
---   e.g. as arise in the fields of a data constructor. To do so we create 
---   a single "function type" that is then passed into @plugHoles@. 
---   We also pass in the type parameters as dummy arguments, because, e.g. 
---   we want @plugMany@ on the two types
---  
---      forall a. a -> a -> Bool 
---      forall b. _ -> _ -> _ 
--- 
---   to return something like 
--- 
---      forall b. b -> b -> Bool
--- 
---   and not, forall b. a -> a -> Bool.
-
-plugMany :: F.TCEmb Ghc.TyCon -> Bare.TyConMap 
-         -> Located DataConP            
-         -> ([Ghc.Var], [Ghc.Type],             Ghc.Type)   -- ^ hs type 
-         -> ([RTyVar] , [(F.Symbol, SpecType)], SpecType)   -- ^ lq type 
-         -> ([(F.Symbol, SpecType)], SpecType)              -- ^ plugged lq type
-plugMany embs tyi ldcp (hsAs, hsArgs, hsRes) (lqAs, lqArgs, lqRes) 
-                     = F.notracepp msg (drop nTyVars (zip xs ts), t) 
-  where 
-    (_,(xs,ts,_), t) = bkArrow (val pT) 
-    pT               = plugHoles (Bare.LqTV dcName) embs tyi (const killHoles) hsT (F.atLoc ldcp lqT)
-    hsT              = foldr (Ghc.mkFunTy Ghc.VisArg) hsRes hsArgs' 
-    lqT              = foldr (uncurry rFun) lqRes lqArgs' 
-    hsArgs'          = [ Ghc.mkTyVarTy a               | a <- hsAs] ++ hsArgs 
-    lqArgs'          = [(F.dummySymbol, RVar a mempty) | a <- lqAs] ++ lqArgs 
-    nTyVars          = length hsAs -- == length lqAs
-    dcName           = Ghc.dataConName . dcpCon . val $ ldcp
-    msg              = "plugMany: " ++ F.showpp (dcName, hsT, lqT)
-
-plugHoles_old, plugHoles_new 
-  :: (Ghc.NamedThing a, PPrint a, Show a)
-  => F.TCEmb Ghc.TyCon
-  -> Bare.TyConMap 
-  -> a
-  -> (SpecType -> RReft -> RReft)
-  -> Ghc.Type
-  -> LocSpecType
-  -> LocSpecType
-  
--- NOTE: this use of toType is safe as rt' is derived from t.
-plugHoles_old tce tyi x f t0 zz@(Loc l l' st0) 
-    = Loc l l' 
-    . mkArrow (zip (updateRTVar <$> αs') rs) ps' [] [] 
-    . makeCls cs' 
-    . goPlug tce tyi err f (subts su rt) 
-    . mapExprReft (\_ -> F.applyCoSub coSub) 
-    . subts su 
-    $ st 
-  where 
-    tyvsmap      = case Bare.runMapTyVars (toType rt) st err of
-                          Left e  -> Ex.throw e 
-                          Right s -> Bare.vmap s
-    su           = [(y, rTyVar x)           | (x, y) <- tyvsmap]
-    su'          = [(y, RVar (rTyVar x) ()) | (x, y) <- tyvsmap] :: [(RTyVar, RSort)]
-    coSub        = M.fromList [(F.symbol y, F.FObj (F.symbol x)) | (y, x) <- su]
-    ps'          = fmap (subts su') <$> ps
-    cs'          = [(F.dummySymbol, RApp c ts [] mempty) | (c, ts) <- cs ] 
-    (αs', rs)    = unzip αs
-    (αs,_,cs,rt) = bkUnivClass (F.notracepp "hs-spec" $ ofType (Ghc.expandTypeSynonyms t0) :: SpecType)
-    (_,ps,_ ,st) = bkUnivClass (F.notracepp "lq-spec" st0)
-
-    makeCls cs t = foldr (uncurry rFun) t cs
-    err hsT lqT  = ErrMismatch (GM.fSrcSpan zz) (pprint x) 
-                          (text "Plugged Init types old")
-                          (pprint $ Ghc.expandTypeSynonyms t0)
-                          (pprint $ toRSort st0)
-                          (Just (hsT, lqT))
-                          (Ghc.getSrcSpan x) 
-
-
-plugHoles_new tce tyi x f t0 zz@(Loc l l' st0) 
-    = Loc l l' 
-    . mkArrow (zip (updateRTVar <$> as'') rs) ps [] [] 
-    . makeCls cs' 
-    . goPlug tce tyi err f rt' 
-    $ st 
-  where 
-    rt'          = tx rt
-    as''         = subRTVar su <$> as'
-    (as',rs)     = unzip as 
-    cs'          = [ (F.dummySymbol, ct) | (c, t) <- cs, let ct = tx (RApp c t [] mempty) ]
-    tx           = subts su
-    su           = case Bare.runMapTyVars (toType rt) st err of
-                          Left e  -> Ex.throw e 
-                          Right s -> [ (rTyVar x, y) | (x, y) <- Bare.vmap s]
-    (as,_,cs,rt) = bkUnivClass (ofType (Ghc.expandTypeSynonyms t0) :: SpecType)
-    (_,ps,_ ,st) = bkUnivClass st0
-
-    makeCls cs t = foldr (uncurry rFun) t cs
-    err hsT lqT  = ErrMismatch (GM.fSrcSpan zz) (pprint x) 
-                          (text "Plugged Init types new")
-                          (pprint $ Ghc.expandTypeSynonyms t0)
-                          (pprint $ toRSort st0)
-                          (Just (hsT, lqT))
-                          (Ghc.getSrcSpan x) 
-
-subRTVar :: [(RTyVar, RTyVar)] -> SpecRTVar -> SpecRTVar 
-subRTVar su a@(RTVar v i) = Mb.maybe a (`RTVar` i) (lookup v su)
-
-goPlug :: F.TCEmb Ghc.TyCon -> Bare.TyConMap -> (Doc -> Doc -> Error) -> (SpecType -> RReft -> RReft) -> SpecType -> SpecType
-       -> SpecType
-goPlug tce tyi err f = go 
-  where
-    go t (RHole r) = (addHoles t') { rt_reft = f t r }
-      where
-        t'         = everywhere (mkT $ addRefs tce tyi) t
-        addHoles   = everywhere (mkT $ addHole)
-        -- NOTE: make sure we only add holes to RVar and RApp (NOT RFun)
-        addHole :: SpecType -> SpecType
-        addHole t@(RVar v _)       = RVar v (f t (uReft ("v", hole)))
-        addHole t@(RApp c ts ps _) = RApp c ts ps (f t (uReft ("v", hole)))
-        addHole t                  = t
-
-    go (RVar _ _)       v@(RVar _ _)       = v
-    go t'               (RImpF x i o r)    = RImpF x i  (go t' o)             r
-    go (RFun _ i o _)   (RFun x i' o' r)   = RFun x     (go i i')   (go o o') r
-    go (RAllT _ t _)    (RAllT a t' r)     = RAllT a    (go t t') r
-    go (RAllT a t r)    t'                 = RAllT a    (go t t') r
-    go t                (RAllP p t')       = RAllP p    (go t t')
-    go t                (RAllE b a t')     = RAllE b a  (go t t')
-    go t                (REx b x t')       = REx b x    (go t t')
-    go t                (RRTy e r o t')    = RRTy e r o (go t t')
-    go (RAppTy t1 t2 _) (RAppTy t1' t2' r) = RAppTy     (go t1 t1') (go t2 t2') r
-    -- zipWithDefM: if ts and ts' have different length then the liquid and haskell types are different.
-    -- keep different types for now, as a pretty error message will be created at Bare.Check
-    go (RApp _ ts _ _)  (RApp c ts' p r)   
-      | length ts == length ts'            = RApp c     (Misc.zipWithDef go ts $ Bare.matchKindArgs ts ts') p r
-    go hsT lqT                             = Ex.throw (err (F.pprint hsT) (F.pprint lqT))
-
-    -- otherwise                          = Ex.throw err 
-    -- If we reach the default case, there's probably an error, but we defer
-    -- throwing it as checkGhcSpec does a much better job of reporting the
-    -- problem to the user.
-    -- go st               _                 = st
-
-addRefs :: F.TCEmb Ghc.TyCon -> TyConMap -> SpecType -> SpecType
-addRefs tce tyi (RApp c ts _ r) = RApp c' ts ps r
-  where
-    RApp c' _ ps _ = addTyConInfo tce tyi (RApp c ts [] r)
-addRefs _ _ t  = t
-
-maybeTrue :: Ghc.NamedThing a => a -> ModName -> S.HashSet StableName -> SpecType -> RReft -> RReft
-maybeTrue x target exports t r
-  | not (isFunTy t) && (Ghc.isInternalName name || inTarget && notExported)
-  = r
-  | otherwise
-  = killHoles r
-  where
-    inTarget    = Ghc.moduleName (Ghc.nameModule name) == getModName target
-    name        = Ghc.getName x
-    notExported = not (mkStableName (Ghc.getName x) `S.member` exports)
-
--- killHoles r@(U (Reft (v, rs)) _ _) = r { ur_reft = Reft (v, filter (not . isHole) rs) }
-
-killHoles :: RReft -> RReft
-killHoles ur = ur { ur_reft = tx $ ur_reft ur }
-  where
-    tx r = {- traceFix ("killholes: r = " ++ showFix r) $ -} F.mapPredReft dropHoles r
-    dropHoles    = F.pAnd . filter (not . isHole) . F.conjuncts
diff --git a/src/Language/Haskell/Liquid/Bare/Resolve.hs b/src/Language/Haskell/Liquid/Bare/Resolve.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Resolve.hs
+++ /dev/null
@@ -1,1067 +0,0 @@
--- | This module has the code that uses the GHC definitions to:
---   1. MAKE a name-resolution environment,
---   2. USE the environment to translate plain symbols into Var, TyCon, etc. 
-
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE TypeSynonymInstances  #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE LambdaCase            #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE PartialTypeSignatures #-}
-{-# LANGUAGE ConstraintKinds       #-}
-{-# LANGUAGE TupleSections         #-}
-
-module Language.Haskell.Liquid.Bare.Resolve 
-  ( -- * Creating the Environment
-    makeEnv 
-
-    -- * Resolving symbols 
-  , ResolveSym (..)
-  , Qualify (..)
-  , qualifyTop, qualifyTopDummy
-  
-  -- * Looking up names
-  , maybeResolveSym 
-  , lookupGhcDataCon 
-  , lookupGhcDnTyCon 
-  , lookupGhcTyCon 
-  , lookupGhcVar 
-  , lookupGhcNamedVar 
-
-  -- * Checking if names exist
-  , knownGhcVar 
-  , knownGhcTyCon 
-  , knownGhcDataCon 
-  , knownGhcType 
-
-  -- * Misc 
-  , srcVars 
-
-  -- * Conversions from Bare
-  , ofBareTypeE
-  , ofBareType
-  , ofBPVar
-
-  -- * Post-processing types
-  , txRefSort
-  , errResolve
-
-  -- * Fixing local variables
-  , resolveLocalBinds 
-  , partitionLocalBinds 
-  ) where 
-
-import qualified Control.Exception                 as Ex 
-import qualified Data.List                         as L 
-import qualified Data.HashSet                      as S 
-import qualified Data.Maybe                        as Mb
-import qualified Data.HashMap.Strict               as M
-import qualified Data.Text                         as T
-import qualified Text.PrettyPrint.HughesPJ         as PJ 
-
-import qualified Language.Fixpoint.Utils.Files         as F 
-import qualified Language.Fixpoint.Types               as F 
-import qualified Language.Fixpoint.Types.Visitor       as F 
-import qualified Language.Fixpoint.Misc                as Misc 
-import qualified Language.Haskell.Liquid.GHC.API       as Ghc 
-import qualified Language.Haskell.Liquid.GHC.Misc      as GM 
-import qualified Language.Haskell.Liquid.Misc          as Misc 
-import qualified Language.Haskell.Liquid.Types.RefType as RT
-import qualified Language.Haskell.Liquid.Types.Errors  as Errors 
-import           Language.Haskell.Liquid.Types.Types   
-import           Language.Haskell.Liquid.Measure       (BareSpec)
-import           Language.Haskell.Liquid.Types.Specs   hiding (BareSpec)
-import           Language.Haskell.Liquid.Types.Visitors 
-import           Language.Haskell.Liquid.Bare.Types 
-import           Language.Haskell.Liquid.Bare.Misc   
-import           Language.Haskell.Liquid.WiredIn 
-
-myTracepp :: (F.PPrint a) => String -> a -> a
-myTracepp = F.notracepp 
-
--------------------------------------------------------------------------------
--- | Creating an environment 
--------------------------------------------------------------------------------
-makeEnv :: Config -> GhcSrc -> LogicMap -> [(ModName, BareSpec)] -> Env 
-makeEnv cfg src lmap specs = RE 
-  { reLMap      = lmap
-  , reSyms      = syms 
-  , _reSubst    = makeVarSubst   src 
-  , _reTyThings = makeTyThingMap src 
-  , reQualImps  = _gsQualImps     src
-  , reAllImps   = _gsAllImps      src
-  , reLocalVars = makeLocalVars  src 
-  , reSrc       = src
-  , reGlobSyms  = S.fromList     globalSyms 
-  , reCfg       = cfg
-  } 
-  where 
-    globalSyms  = concatMap getGlobalSyms specs
-    syms        = [ (F.symbol v, v) | v <- vars ] 
-    vars        = srcVars src
-
-getGlobalSyms :: (ModName, BareSpec) -> [F.Symbol]
-getGlobalSyms (_, spec) 
-  = filter (not . GM.isQualifiedSym) 
-       $ (mbName <$> measures  spec) 
-      ++ (mbName <$> cmeasures spec)
-      ++ (mbName <$> imeasures spec)
-  where 
-    mbName = F.val . msName
-
-makeLocalVars :: GhcSrc -> LocalVars 
-makeLocalVars = localVarMap . localBinds . _giCbs
-
--- TODO: rewrite using CoreVisitor
-localBinds :: [Ghc.CoreBind] -> [Ghc.Var]
-localBinds                    = concatMap (bgo S.empty) 
-  where
-    add  x g                  = maybe g (`S.insert` g) (localKey x) 
-    adds b g                  = foldr add g (Ghc.bindersOf b) 
-    take x g                  = maybe [] (\k -> if S.member k g then [] else [x]) (localKey x)
-    pgo g (x, e)              = take x g ++ go (add x g) e
-    bgo g (Ghc.NonRec x e)    = pgo g (x, e) 
-    bgo g (Ghc.Rec xes)       = concatMap (pgo g) xes 
-    go  g (Ghc.App e a)       = concatMap (go  g) [e, a]
-    go  g (Ghc.Lam _ e)       = go g e
-    go  g (Ghc.Let b e)       = bgo g b ++ go (adds b g) e 
-    go  g (Ghc.Tick _ e)      = go g e
-    go  g (Ghc.Cast e _)      = go g e
-    go  g (Ghc.Case e _ _ cs) = go g e ++ concatMap (go g . Misc.thd3) cs
-    go  _ (Ghc.Var _)         = []
-    go  _ _                   = []
-
-localVarMap :: [Ghc.Var] -> LocalVars
-localVarMap vs = 
-  Misc.group [ (x, (i, v)) | v    <- vs
-                           , x    <- Mb.maybeToList (localKey v) 
-                           , let i = F.srcLine v 
-             ]
-
-localKey   :: Ghc.Var -> Maybe F.Symbol
-localKey v 
-  | isLocal m = Just x 
-  | otherwise = Nothing
-  where 
-    (m, x)    = splitModuleNameExact . GM.dropModuleUnique . F.symbol $ v 
-
-makeVarSubst :: GhcSrc -> F.Subst 
-makeVarSubst src = F.mkSubst unqualSyms 
-  where 
-    unqualSyms   = [ (x, mkVarExpr v) 
-                       | (x, mxs) <- M.toList       (makeSymMap src) 
-                       , v        <- Mb.maybeToList (okUnqualified me mxs) 
-                       , not (isWiredInName x)
-                   ] 
-    me           = F.symbol (_giTargetMod src) 
-
--- | @okUnqualified mod mxs@ takes @mxs@ which is a list of modulenames-var 
---   pairs all of which have the same unqualified symbol representation. 
---   The function returns @Just v@ if 
---   1. that list is a singleton i.e. there is a UNIQUE unqualified version, OR
---   2. there is a version whose module equals @me@.
-
-okUnqualified :: F.Symbol -> [(F.Symbol, a)] -> Maybe a 
-okUnqualified _ [(_, x)] = Just x 
-okUnqualified me mxs     = go mxs 
-  where 
-    go []                = Nothing 
-    go ((m,x) : rest)    
-      | me == m          = Just x 
-      | otherwise        = go rest 
-
-
-makeSymMap :: GhcSrc -> M.HashMap F.Symbol [(F.Symbol, Ghc.Var)]
-makeSymMap src = Misc.group [ (sym, (m, x)) 
-                                | x           <- srcVars src
-                                , let (m, sym) = qualifiedSymbol x ]
-
-makeTyThingMap :: GhcSrc -> TyThingMap 
-makeTyThingMap src =
-  Misc.group [ (x, (m, t))  | t         <- srcThings src
-                            , tSym      <- Mb.maybeToList (tyThingSymbol t)
-                            , let (m, x) = qualifiedSymbol tSym 
-                            , not (isLocal m)
-             ] 
-
-tyThingSymbol :: Ghc.TyThing -> Maybe F.Symbol 
-tyThingSymbol (Ghc.AnId     x) = Just (F.symbol x)
-tyThingSymbol (Ghc.ATyCon   c) = Just (F.symbol c)
-tyThingSymbol (Ghc.AConLike d) = conLikeSymbol d 
-tyThingSymbol _tt              = Nothing -- panic Nothing ("TODO: tyThingSymbol" ++ showPpr tt)
-
-
-conLikeSymbol :: Ghc.ConLike -> Maybe F.Symbol 
-conLikeSymbol (Ghc.RealDataCon d) = Just (F.symbol d) 
-conLikeSymbol _z                   = Nothing -- panic Nothing ("TODO: conLikeSymbol -- " ++ showPpr z)
-
-
-
-
-isLocal :: F.Symbol -> Bool
-isLocal = isEmptySymbol 
-
-qualifiedSymbol :: (F.Symbolic a) => a -> (F.Symbol, F.Symbol)
-qualifiedSymbol = splitModuleNameExact . F.symbol 
-
-isEmptySymbol :: F.Symbol -> Bool 
-isEmptySymbol x = F.lengthSym x == 0 
-
-srcThings :: GhcSrc -> [Ghc.TyThing] 
-srcThings src = myTracepp "SRCTHINGS" 
-              $ Misc.hashNubWith F.showpp (_gsTyThings src ++ mySrcThings src) 
-
-mySrcThings :: GhcSrc -> [Ghc.TyThing] 
-mySrcThings src = [ Ghc.AnId   x | x <- vars ] 
-               ++ [ Ghc.ATyCon c | c <- tcs  ] 
-               ++ [ aDataCon   d | d <- dcs  ] 
-  where 
-    vars        = Misc.sortNub $ dataConVars dcs ++ srcVars  src
-    dcs         = Misc.sortNub $ concatMap Ghc.tyConDataCons tcs 
-    tcs         = Misc.sortNub $ srcTyCons src  
-    aDataCon    = Ghc.AConLike . Ghc.RealDataCon 
-
-srcTyCons :: GhcSrc -> [Ghc.TyCon]
-srcTyCons src = concat 
-  [ _gsTcs     src 
-  , _gsFiTcs   src 
-  , _gsPrimTcs src
-  , srcVarTcs src 
-  ]
-
-srcVarTcs :: GhcSrc -> [Ghc.TyCon]
-srcVarTcs = varTyCons . srcVars 
-
-varTyCons :: [Ghc.Var] -> [Ghc.TyCon]
-varTyCons = concatMap (typeTyCons . Ghc.dropForAlls . Ghc.varType) 
-
-typeTyCons :: Ghc.Type -> [Ghc.TyCon]
-typeTyCons t = tops t ++ inners t 
-  where 
-    tops     = Mb.maybeToList . Ghc.tyConAppTyCon_maybe
-    inners   = concatMap typeTyCons . snd . Ghc.splitAppTys 
-
--- | We prioritize the @Ghc.Var@ in @srcVars@ because @_giDefVars@ and @gsTyThings@ 
---   have _different_ values for the same binder, with different types where the 
---   type params are alpha-renamed. However, for absref, we need _the same_ 
---   type parameters as used by GHC as those are used inside the lambdas and
---   other bindings in the code. See also [NOTE: Plug-Holes-TyVars] and 
---      tests-absref-pos-Papp00.hs 
-
-srcVars :: GhcSrc -> [Ghc.Var]
-srcVars src = filter Ghc.isId .  fmap Misc.thd3 . Misc.fstByRank $ concat 
-  [ key "SRC-VAR-DEF" 0 <$> _giDefVars src 
-  , key "SRC-VAR-DER" 1 <$> S.toList (_giDerVars src)
-  , key "SRC-VAR-IMP" 2 <$> _giImpVars src 
-  , key "SRC-VAR-USE" 3 <$> _giUseVars src 
-  , key "SRC-VAR-THN" 4 <$> [ x | Ghc.AnId x <- _gsTyThings src ]
-  ]
-  where 
-    key :: String -> Int -> Ghc.Var -> (Int, F.Symbol, Ghc.Var)
-    key _ i x  = (i, F.symbol x, {- dump s -} x) 
-    _dump msg x = fst . myTracepp msg $ (x, RT.ofType (Ghc.expandTypeSynonyms (Ghc.varType x)) :: SpecType)
-
-dataConVars :: [Ghc.DataCon] -> [Ghc.Var]
-dataConVars dcs = concat 
-  [ Ghc.dataConWorkId <$> dcs 
-  , Ghc.dataConWrapId <$> dcs 
-  ] 
-
--------------------------------------------------------------------------------
--- | Qualify various names 
--------------------------------------------------------------------------------
-qualifyTop :: (Qualify a) => Env -> ModName -> F.SourcePos -> a -> a 
-qualifyTop env name l = qualify env name l []
-
-qualifyTopDummy :: (Qualify a) => Env -> ModName -> a -> a 
-qualifyTopDummy env name = qualifyTop env name dummySourcePos
-
-dummySourcePos :: F.SourcePos 
-dummySourcePos = F.loc (F.dummyLoc ())
-
-class Qualify a where 
-  qualify :: Env -> ModName -> F.SourcePos -> [F.Symbol] -> a -> a 
-
-instance Qualify TyConMap where 
-  qualify env name l bs tyi = tyi 
-    { tcmTyRTy = tx <$> tcmTyRTy tyi 
-    , tcmFIRTy = tx <$> tcmFIRTy tyi 
-    } 
-    where 
-      tx :: (Qualify a) => a -> a 
-      tx = qualify env name l bs 
-
-instance Qualify TyConP where 
-  qualify env name _ bs tcp = tcp { tcpSizeFun = qualify env name (tcpLoc tcp) bs <$> tcpSizeFun tcp }
-
-instance Qualify SizeFun where 
-  qualify env name _ bs (SymSizeFun lx) = SymSizeFun (qualify env name (F.loc lx) bs lx)
-  qualify _   _    _ _  sf              = sf
-
-instance Qualify F.Equation where 
-  qualify _env _name _l _bs x = x -- TODO-REBARE 
--- REBARE: qualifyAxiomEq :: Bare.Env -> Var -> Subst -> AxiomEq -> AxiomEq
--- REBARE: qualifyAxiomEq v su eq = subst su eq { eqName = symbol v}
-
-instance Qualify F.Symbol where 
-  qualify env name l bs x = qualifySymbol env name l bs x 
-
-qualifySymbol :: Env -> ModName -> F.SourcePos -> [F.Symbol] -> F.Symbol -> F.Symbol                                                   
-qualifySymbol env name l bs x
-  | isSpl     = x 
-  | otherwise = case resolveLocSym env name "Symbol" (F.Loc l l x) of 
-                  Left  _ -> x 
-                  Right v -> v 
-  where 
-    isSpl     = isSplSymbol env bs x
-
-isSplSymbol :: Env -> [F.Symbol] -> F.Symbol -> Bool 
-isSplSymbol env bs x 
-  =  isWiredInName x 
-  || elem x bs 
-  || S.member x (reGlobSyms env) 
-
-instance (Qualify a) => Qualify (Located a) where 
-  qualify env name l bs = fmap (qualify env name l bs) 
-
-instance (Qualify a) => Qualify [a] where
-  qualify env name l bs = fmap (qualify env name l bs)
-
-instance (Qualify a) => Qualify (Maybe a) where 
-  qualify env name l bs = fmap (qualify env name l bs) 
-
-instance Qualify Body where 
-  qualify env name l bs (P   p) = P   (qualify env name l bs p) 
-  qualify env name l bs (E   e) = E   (qualify env name l bs e)
-  qualify env name l bs (R x p) = R x (qualify env name l bs p)
-
-instance Qualify TyConInfo where 
-  qualify env name l bs tci = tci { sizeFunction = qualify env name l bs <$> sizeFunction tci }
-
-instance Qualify RTyCon where 
-  qualify env name l bs rtc = rtc { rtc_info = qualify env name l bs (rtc_info rtc) }
-
-instance Qualify (Measure SpecType Ghc.DataCon) where 
-  qualify env name _ bs m = m -- FIXME substEnv env name bs $ 
-    { msName = qualify env name l bs     lname 
-    , msEqns = qualify env name l bs <$> msEqns m 
-    }
-    where 
-      l      = F.loc  lname
-      lname  = msName m
-
-
-instance Qualify (Def ty ctor) where 
-  qualify env name l bs d = d 
-    { body  = qualify env name l (bs ++ bs') (body d) } 
-    where 
-      bs'   = fst <$> binds d
-
-instance Qualify BareMeasure where 
-  qualify env name l bs m = m 
-    { msEqns = qualify env name l bs (msEqns m)
-    } 
-
-instance Qualify DataCtor where 
-  qualify env name l bs c = c
-    { dcTheta  = qualify env name l bs (dcTheta  c) 
-    , dcFields = qualify env name l bs (dcFields c) 
-    , dcResult = qualify env name l bs (dcResult c)
-    }
- 
-instance Qualify DataDecl where 
-  qualify env name l bs d = d 
-    { tycDCons  = qualify env name l bs (tycDCons  d)
-    , tycPropTy = qualify env name l bs (tycPropTy d) 
-    } 
-
-instance Qualify ModSpecs where 
-  qualify env name l bs = Misc.hashMapMapWithKey (\_ -> qualify env name l bs) 
-
-instance Qualify b => Qualify (a, b) where 
-  qualify env name l bs (x, y) = (x, qualify env name l bs y)
-
-instance Qualify BareSpec where 
-  qualify = qualifyBareSpec 
-
-qualifyBareSpec :: Env -> ModName -> F.SourcePos -> [F.Symbol] -> BareSpec -> BareSpec 
-qualifyBareSpec env name l bs sp = sp 
-  { measures   = qualify env name l bs (measures   sp) 
-  , asmSigs    = qualify env name l bs (asmSigs    sp)
-  , sigs       = qualify env name l bs (sigs       sp)
-  , localSigs  = qualify env name l bs (localSigs  sp)
-  , reflSigs   = qualify env name l bs (reflSigs   sp)
-  , dataDecls  = qualify env name l bs (dataDecls  sp)
-  , newtyDecls = qualify env name l bs (newtyDecls sp)
-  , ialiases   = [ (f x, f y) | (x, y) <- ialiases sp ]
-  } 
-  where f      = qualify env name l bs 
-
-instance Qualify F.Expr where 
-  qualify = substEnv 
-
-instance Qualify RReft where 
-  qualify = substEnv
-
-instance Qualify F.Qualifier where 
-  qualify env name _ bs q = q { F.qBody = qualify env name (F.qPos q) bs' (F.qBody q) } 
-    where 
-      bs'                 = bs ++ (F.qpSym <$> F.qParams q)
-
-substEnv :: (F.Subable a) => Env -> ModName -> F.SourcePos -> [F.Symbol] -> a -> a 
-substEnv env name l bs = F.substa (qualifySymbol env name l bs) 
-
-instance Qualify SpecType where 
-  qualify x1 x2 x3 x4 x5 = emapReft (substFreeEnv x1 x2 x3) x4 x5            
-
-instance Qualify BareType where 
-  qualify x1 x2 x3 x4 x5 = emapReft (substFreeEnv x1 x2 x3) x4 x5 
-
-substFreeEnv :: (F.Subable a) => Env -> ModName -> F.SourcePos -> [F.Symbol] -> a -> a 
-substFreeEnv env name l bs = F.substf (F.EVar . qualifySymbol env name l bs) 
-
--------------------------------------------------------------------------------
-lookupGhcNamedVar :: (Ghc.NamedThing a, F.Symbolic a) => Env -> ModName -> a -> Maybe Ghc.Var
--------------------------------------------------------------------------------
-lookupGhcNamedVar env name z = maybeResolveSym  env name "Var" lx
-  where 
-    lx                       = GM.namedLocSymbol z
-
-lookupGhcVar :: Env -> ModName -> String -> LocSymbol -> Ghc.Var 
-lookupGhcVar env name kind lx = 
-  case resolveLocSym env name kind lx of 
-    Right v -> Mb.fromMaybe v       (lookupLocalVar env lx [v]) 
-    Left  e -> Mb.fromMaybe (err e) (lookupLocalVar env lx []) 
-  where
-    -- err e   = Misc.errorP "error-lookupGhcVar" (F.showpp (e, F.loc lx, lx))
-    err     = Ex.throw
-
--- | @lookupLocalVar@ takes as input the list of "global" (top-level) vars 
---   that also match the name @lx@; we then pick the "closest" definition. 
---   See tests/names/LocalSpec.hs for a motivating example. 
-
-lookupLocalVar :: Env -> LocSymbol -> [Ghc.Var] -> Maybe Ghc.Var
-lookupLocalVar env lx gvs = Misc.findNearest lxn kvs
-  where 
-    _msg                  = "LOOKUP-LOCAL: " ++ F.showpp (F.val lx, lxn, kvs)
-    kvs                   = gs ++ M.lookupDefault [] x (reLocalVars env) 
-    gs                    = [(F.srcLine v, v) | v <- gvs]
-    lxn                   = F.srcLine lx  
-    (_, x)                = unQualifySymbol (F.val lx)
-
-
-lookupGhcDataCon :: Env -> ModName -> String -> LocSymbol -> Ghc.DataCon 
-lookupGhcDataCon = strictResolveSym 
-
-lookupGhcTyCon :: Env -> ModName -> String -> LocSymbol -> Ghc.TyCon 
-lookupGhcTyCon env name k lx = myTracepp ("LOOKUP-TYCON: " ++ F.showpp (val lx)) 
-                               $ strictResolveSym env name k lx
-
-lookupGhcDnTyCon :: Env -> ModName -> String -> DataName -> Maybe Ghc.TyCon
-lookupGhcDnTyCon env name msg = failMaybe env name . lookupGhcDnTyConE env name msg
-
-lookupGhcDnTyConE :: Env -> ModName -> String -> DataName -> Either UserError Ghc.TyCon
-lookupGhcDnTyConE env name msg (DnCon  s) 
-  = lookupGhcDnCon env name msg s
-lookupGhcDnTyConE env name msg (DnName s) 
-  = case resolveLocSym env name msg s of 
-      Right r -> Right r 
-      Left  e -> case lookupGhcDnCon  env name msg s of 
-                   Right r -> Right r 
-                   Left  _ -> Left  e
-
-lookupGhcDnCon :: Env -> ModName -> String -> LocSymbol -> Either UserError Ghc.TyCon 
-lookupGhcDnCon env name msg = fmap Ghc.dataConTyCon . resolveLocSym env name msg
-
--------------------------------------------------------------------------------
--- | Checking existence of names 
--------------------------------------------------------------------------------
-knownGhcType :: Env ->  ModName -> LocBareType -> Bool
-knownGhcType env name (F.Loc l _ t) = 
-  case ofBareTypeE env name l Nothing t of 
-    Left e  -> myTracepp ("knownType: " ++ F.showpp (t, e)) $ False 
-    Right _ -> True 
-
-
-
-_rTypeTyCons :: (Ord c) => RType c tv r -> [c]
-_rTypeTyCons           = Misc.sortNub . foldRType f []   
-  where 
-    f acc t@(RApp {}) = rt_tycon t : acc 
-    f acc _           = acc
-
--- Aargh. Silly that each of these is the SAME code, only difference is the type.
-
-knownGhcVar :: Env -> ModName -> LocSymbol -> Bool 
-knownGhcVar env name lx = Mb.isJust v 
-  where 
-    v :: Maybe Ghc.Var -- This annotation is crucial
-    v = myTracepp ("knownGhcVar " ++ F.showpp lx) 
-      $ maybeResolveSym env name "known-var" lx 
-
-knownGhcTyCon :: Env -> ModName -> LocSymbol -> Bool 
-knownGhcTyCon env name lx = myTracepp  msg $ Mb.isJust v 
-  where 
-    msg = ("knownGhcTyCon: "  ++ F.showpp lx)
-    v :: Maybe Ghc.TyCon -- This annotation is crucial
-    v = maybeResolveSym env name "known-tycon" lx 
-
-knownGhcDataCon :: Env -> ModName -> LocSymbol -> Bool 
-knownGhcDataCon env name lx = Mb.isJust v 
-  where 
-    v :: Maybe Ghc.DataCon -- This annotation is crucial
-    v = myTracepp ("knownGhcDataCon" ++ F.showpp lx) 
-      $ maybeResolveSym env name "known-datacon" lx 
-
--------------------------------------------------------------------------------
--- | Using the environment 
--------------------------------------------------------------------------------
-class ResolveSym a where 
-  resolveLocSym :: Env -> ModName -> String -> LocSymbol -> Either UserError a 
-
-instance ResolveSym Ghc.Var where 
-  resolveLocSym = resolveWith "variable" $ \case 
-                    Ghc.AnId x -> Just x 
-                    _          -> Nothing
-
-instance ResolveSym Ghc.TyCon where 
-  resolveLocSym = resolveWith "type constructor" $ \case 
-                    Ghc.ATyCon x             -> Just x
-                    _                        -> Nothing
-
-instance ResolveSym Ghc.DataCon where 
-  resolveLocSym = resolveWith "data constructor" $ \case 
-                    Ghc.AConLike (Ghc.RealDataCon x) -> Just x 
-                    _                                -> Nothing
-
-
-{- Note [ResolveSym for Symbol]
-
-In case we need to resolve (aka qualify) a 'Symbol', we need to do some extra work. Generally speaking,
-all these 'ResolveSym' instances perform a lookup into a 'Map' keyed by the 'Symbol' in
-order to find a 'TyThing'. More specifically such map is known as the 'TyThingMap':
-
-type TyThingMap = M.HashMap F.Symbol [(F.Symbol, Ghc.TyThing)]
-
-This means, in practice, that we might have more than one result indexed by a given 'Symbol', and we need
-to make a choice. The function 'rankedThings' does this. By default, we try to extract only /identifiers/
-(i.e. a GHC's 'Id') out of an input 'TyThing', but in the case of test \"T1688\", something different happened.
-By tracing calls to 'rankedThings' (called by 'resolveLocSym') there were cases where we had something like
-this as our input TyThingMap:
-
-[
- 1 : T1688Lib : Data constructor T1688Lib.Lambda,
- 1 : T1688Lib : Identifier T1688Lib.Lambda
-]
-
-Here name resolution worked because 'resolveLocSym' used the 'ResolveSym' instance defined for 'GHC.Var' that
-looks only for 'Id's (contained inside 'Identifier's, and we had one). In some other cases, though,
-'resolveLocSym' got called with only this:
-
-[1 : T1688Lib : Data constructor T1688Lib.Lambda]
-
-This would /not/ yield a match, despite the fact a \"Data constructor\" in principle /does/ contain an 'Id'
-(it can be extracted out of a 'RealDataCon' by calling 'dataConWorkId'). In the case of test T1688, such
-failed lookup caused the 'Symbol' to /not/ qualify, which in turn caused the symbols inside the type synonym:
-
-ProofOf( Step (App (Lambda x e) v) e)
-
-To not qualify. Finally, by the time 'expand' was called, the 'ProofOf' type alias would be replaced with
-the correct refinement, but the unqualified 'Symbol's would now cause a test failure when refining the client
-module.
-
-It's not clear to me (Alfredo) why 'resolveLocSym' is called multiple times within the same module with
-different inputs, but it definitely makes sense to allow for the special case here, at least for 'Symbol's.
-
-Probably finding the /root cause/ would entail partially rewriting the name resoultion engine.
-
--}
-
-
-instance ResolveSym F.Symbol where
-  resolveLocSym env name _ lx =
-    -- If we can't resolve the input 'Symbol' from an 'Id', try again
-    -- by grabbing the 'Id' of an 'AConLike', if any.
-    -- See Note [ResolveSym for Symbol].
-    let resolved =  resolveLocSym env name "Var" lx
-                 <> resolveWith "variable" lookupVarInsideRealDataCon env name "Var" lx
-    in case resolved of
-      Left _               -> Right (val lx)
-      Right (v :: Ghc.Var) -> Right (F.symbol v)
-    where
-      lookupVarInsideRealDataCon :: Ghc.TyThing -> Maybe Ghc.Var
-      lookupVarInsideRealDataCon = \case
-        Ghc.AConLike (Ghc.RealDataCon x) -> Just (Ghc.dataConWorkId x)
-        _                                -> Nothing
-
-
-
-resolveWith :: (PPrint a) => PJ.Doc -> (Ghc.TyThing -> Maybe a) -> Env -> ModName -> String -> LocSymbol 
-            -> Either UserError a 
-resolveWith kind f env name str lx =
-  -- case Mb.mapMaybe f things of 
-  case rankedThings f things of
-    []  -> Left  (errResolve kind str lx) 
-    [x] -> Right x 
-    xs  -> Left $ ErrDupNames sp (pprint (F.val lx)) (pprint <$> xs)
-  where
-    -- oThings = Mb.mapMaybe (\(x, y) -> (x,) <$> f y) things
-    _xSym   = (F.val lx)
-    sp      = GM.fSrcSpanSrcSpan (F.srcSpan lx)
-    things  = myTracepp msg $ lookupTyThing env name lx 
-    msg     = "resolveWith: " ++ str ++ " " ++ F.showpp (val lx)
-
-
-rankedThings :: (Misc.EqHash k) => (a -> Maybe b) -> [(k, a)] -> [b]
-rankedThings f ias = case Misc.sortOn fst (Misc.groupList ibs) of 
-                       (_,ts):_ -> ts
-                       []       -> []
-  where 
-    ibs            = Mb.mapMaybe (\(k, x) -> (k,) <$> f x) ias
-
--------------------------------------------------------------------------------
--- | @lookupTyThing@ is the central place where we lookup the @Env@ to find 
---   any @Ghc.TyThing@ that match that name. The code is a bit hairy as we
---   have various heuristics to approximiate how GHC resolves names. e.g. 
---   see tests-names-pos-*.hs, esp. vector04.hs where we need the name `Vector` 
---   to resolve to `Data.Vector.Vector` and not `Data.Vector.Generic.Base.Vector`... 
--------------------------------------------------------------------------------
-lookupTyThing :: Env -> ModName -> LocSymbol -> [((Int, F.Symbol), Ghc.TyThing)]
--------------------------------------------------------------------------------
-lookupTyThing env name lsym = [ (k, t) | (k, ts) <- ordMatches, t <- ts] 
-                              
-  where 
-    ordMatches             = Misc.sortOn fst (Misc.groupList matches)
-    matches                = myTracepp ("matches-" ++ msg)
-                             [ ((k, m), t) | (m, t) <- lookupThings env x
-                                           , k      <- myTracepp msg $ mm nameSym m mods ]
-    msg                    = "lookupTyThing: " ++ F.showpp (lsym, x, mods)
-    (x, mods)              = symbolModules env (F.val lsym)
-    nameSym                = F.symbol name
-    allowExt               = allowExtResolution env lsym 
-    mm name m mods         = myTracepp ("matchMod: " ++ F.showpp (lsym, name, m, mods, allowExt)) $ 
-                               matchMod env name m allowExt mods 
-
--- | [NOTE:External-Resolution] @allowExtResolution@ determines whether a @LocSymbol@ 
---   can be resolved by a @TyThing@ that is _outside_ the module corresponding to @LocSymbol@. 
---   We need to allow this, e.g. to resolve names like @Data.Set.Set@ with @Data.Set.Internal.Set@, 
---   but should do so ONLY when the LocSymbol comes from a "hand-written" .spec file or 
---   something from the LH prelude. Other names, e.g. from "machine-generated" .bspec files 
---   should already be FULLY-qualified to to their actual definition (e.g. Data.Set.Internal.Set) 
---   and so we should DISALLOW external-resolution in such cases.
-
-allowExtResolution :: Env -> LocSymbol -> Bool 
-allowExtResolution env lx = case fileMb of 
-  Nothing   -> True 
-  Just f    -> myTracepp ("allowExt: " ++ show (f, tgtFile)) 
-                 $ f == tgtFile || Misc.isIncludeFile incDir f || F.isExtFile F.Spec f 
-  where 
-    tgtFile = _giTarget (reSrc env)
-    incDir  = _giIncDir (reSrc env)
-    fileMb  = Errors.srcSpanFileMb (GM.fSrcSpan lx) 
-
-lookupThings :: Env -> F.Symbol -> [(F.Symbol, Ghc.TyThing)] 
-lookupThings env x = myTracepp ("lookupThings: " ++ F.showpp x) 
-                   $ Misc.fromFirstMaybes [] (get <$> [x, GM.stripParensSym x])
-  where 
-    get z          = M.lookup z (_reTyThings env)
-
-matchMod :: Env -> F.Symbol -> F.Symbol -> Bool -> Maybe [F.Symbol] -> [Int]
-matchMod env tgtName defName allowExt = go 
-  where 
-    go Nothing               -- Score UNQUALIFIED names 
-     | defName == tgtName = [0]                       -- prioritize names defined in *this* module 
-     | otherwise          = [matchImp env defName 1]  -- prioritize directly imported modules over 
-                                                      -- names coming from elsewhere, with a 
-
-    go (Just ms)             -- Score QUALIFIED names
-     |  isEmptySymbol defName 
-     && ms == [tgtName]   = [0]                       -- local variable, see tests-names-pos-local00.hs
-     | ms == [defName]    = [1]
-     | allowExt && isExt  = [matchImp env defName 2]  -- to allow matching re-exported names e.g. Data.Set.union for Data.Set.Internal.union
-     | otherwise          = []
-     where 
-       isExt              = any (`isParentModuleOf` defName) ms
-
--- | Returns 'True' if the 'Symbol' given as a first argument represents a parent module for the second.
---
--- >>> L.symbolic "Data.Text" `isParentModuleOf` L.symbolic "Data.Text.Internal"
--- True
---
--- Invariants:
---
--- * The empty 'Symbol' is always considered the module prefix of the second,
---   in compliance with 'isPrefixOfSym' (AND: why?)
--- * If the parent \"hierarchy\" is smaller than the children's one, this is clearly not a parent module.
-isParentModuleOf :: F.Symbol -> F.Symbol -> Bool
-isParentModuleOf parentModule childModule
-  | isEmptySymbol parentModule = True
-  | otherwise                  =
-    length parentHierarchy <= length childHierarchy && all (uncurry (==)) (zip parentHierarchy childHierarchy)
-  where
-    parentHierarchy :: [T.Text]
-    parentHierarchy = T.splitOn "." . F.symbolText $ parentModule
-
-    childHierarchy :: [T.Text]
-    childHierarchy = T.splitOn "." . F.symbolText $ childModule
-
-
-symbolModules :: Env -> F.Symbol -> (F.Symbol, Maybe [F.Symbol])
-symbolModules env s = (x, glerb <$> modMb) 
-  where 
-    (modMb, x)      = unQualifySymbol s 
-    glerb m         = M.lookupDefault [m] m qImps 
-    qImps           = qiNames (reQualImps env)  
-
--- | @matchImp@ lets us prioritize @TyThing@ defined in directly imported modules over 
---   those defined elsewhere. Specifically, in decreasing order of priority we have 
---   TyThings that we:
---   * DIRECTLY     imported WITHOUT qualification 
---   * TRANSITIVELY imported (e.g. were re-exported by SOME imported module)
---   * QUALIFIED    imported (so qualify the symbol to get this result!) 
- 
-matchImp :: Env -> F.Symbol -> Int -> Int 
-matchImp env defName i   
-  | isUnqualImport = i      
-  | isQualImport   = i + 2  
-  | otherwise      = i + 1  
-  where
-    isUnqualImport = S.member defName (reAllImps env) && not isQualImport 
-    isQualImport   = S.member defName (qiModules (reQualImps env))
-
-
--- | `unQualifySymbol name sym` splits `sym` into a pair `(mod, rest)` where 
---   `mod` is the name of the module, derived from `sym` if qualified.
-unQualifySymbol :: F.Symbol -> (Maybe F.Symbol, F.Symbol)
-unQualifySymbol sym 
-  | GM.isQualifiedSym sym = Misc.mapFst Just (splitModuleNameExact sym) 
-  | otherwise             = (Nothing, sym) 
-
-splitModuleNameExact :: F.Symbol -> (F.Symbol, F.Symbol)
-splitModuleNameExact x' = myTracepp ("splitModuleNameExact for " ++ F.showpp x) 
-                          (GM.takeModuleNames x, GM.dropModuleNames x)
-  where
-    x = GM.stripParensSym x' 
-
-errResolve :: PJ.Doc -> String -> LocSymbol -> UserError 
-errResolve k msg lx = ErrResolve (GM.fSrcSpan lx) k (F.pprint (F.val lx)) (PJ.text msg) 
-
--- symbolicString :: F.Symbolic a => a -> String
--- symbolicString = F.symbolString . F.symbol
-
--- | @strictResolve@ wraps the plain @resolve@ to throw an error 
---   if the name being searched for is unknown.
-strictResolveSym :: (ResolveSym a) => Env -> ModName -> String -> LocSymbol -> a 
-strictResolveSym env name kind x = case resolveLocSym env name kind x of 
-  Left  err -> Misc.errorP "error-strictResolveSym" (F.showpp err) -- uError err 
-  Right val -> val 
-
--- | @maybeResolve@ wraps the plain @resolve@ to return @Nothing@ 
---   if the name being searched for is unknown.
-maybeResolveSym :: (ResolveSym a) => Env -> ModName -> String -> LocSymbol -> Maybe a 
-maybeResolveSym env name kind x = case resolveLocSym env name kind x of 
-  Left  _   -> Nothing 
-  Right val -> Just val 
-  
--------------------------------------------------------------------------------
--- | @ofBareType@ and @ofBareTypeE@ should be the _only_ @SpecType@ constructors
--------------------------------------------------------------------------------
-ofBareType :: Env -> ModName -> F.SourcePos -> Maybe [PVar BSort] -> BareType -> SpecType 
-ofBareType env name l ps t = either fail id (ofBareTypeE env name l ps t)
-  where 
-    fail                   = Ex.throw 
-    -- fail                   = Misc.errorP "error-ofBareType" . F.showpp 
-
-ofBareTypeE :: Env -> ModName -> F.SourcePos -> Maybe [PVar BSort] -> BareType -> Either UserError SpecType 
-ofBareTypeE env name l ps t = ofBRType env name (resolveReft env name l ps t) l t 
-
-resolveReft :: Env -> ModName -> F.SourcePos -> Maybe [PVar BSort] -> BareType -> [F.Symbol] -> RReft -> RReft 
-resolveReft env name l ps t bs
-        = qualify env name l bs 
-        . txParam l RT.subvUReft (RT.uPVar <$> πs) t
-        . fixReftTyVars t       -- same as fixCoercions 
-  where 
-    πs  = Mb.fromMaybe tπs ps  
-    tπs = ty_preds (toRTypeRep t) 
-     
-fixReftTyVars :: BareType -> RReft -> RReft 
-fixReftTyVars bt  = coSubRReft coSub 
-  where
-    coSub         = M.fromList [ (F.symbol a, F.FObj (specTvSymbol a)) | a <- tvs ]
-    tvs           = RT.allTyVars bt
-    specTvSymbol  = F.symbol . RT.bareRTyVar
-
-coSubRReft :: F.CoSub -> RReft -> RReft 
-coSubRReft su r = r { ur_reft = coSubReft su (ur_reft r) } 
-
-coSubReft :: F.CoSub -> F.Reft -> F.Reft 
-coSubReft su (F.Reft (x, e)) = F.Reft (x, F.applyCoSub su e)
-
-
-ofBSort :: Env -> ModName -> F.SourcePos -> BSort -> RSort 
-ofBSort env name l t = either (Misc.errorP "error-ofBSort" . F.showpp) id (ofBSortE env name l t)
-
-ofBSortE :: Env -> ModName -> F.SourcePos -> BSort -> Either UserError RSort 
-ofBSortE env name l t = ofBRType env name (const id) l t 
-  
-ofBPVar :: Env -> ModName -> F.SourcePos -> BPVar -> RPVar
-ofBPVar env name l = fmap (ofBSort env name l) 
-
---------------------------------------------------------------------------------
-txParam :: F.SourcePos -> ((UsedPVar -> UsedPVar) -> t) -> [UsedPVar] -> RType c tv r -> t
-txParam l f πs t = f (txPvar l (predMap πs t))
-
-txPvar :: F.SourcePos -> M.HashMap F.Symbol UsedPVar -> UsedPVar -> UsedPVar
-txPvar l m π = π { pargs = args' }
-  where
-    args' | not (null (pargs π)) = zipWith (\(_,x ,_) (t,_,y) -> (t, x, y)) (pargs π') (pargs π)
-          | otherwise            = pargs π'
-    π'    = Mb.fromMaybe err $ M.lookup (pname π) m
-    err   = uError $ ErrUnbPred sp (pprint π)
-    sp    = GM.sourcePosSrcSpan l 
-
-predMap :: [UsedPVar] -> RType c tv r -> M.HashMap F.Symbol UsedPVar
-predMap πs t = M.fromList [(pname π, π) | π <- πs ++ rtypePredBinds t]
-
-rtypePredBinds :: RType c tv r -> [UsedPVar]
-rtypePredBinds = map RT.uPVar . ty_preds . toRTypeRep
-
-
-
---------------------------------------------------------------------------------
-type Expandable r = ( PPrint r
-                    , F.Reftable r
-                    , SubsTy RTyVar (RType RTyCon RTyVar ()) r
-                    , F.Reftable (RTProp RTyCon RTyVar r))
-
-ofBRType :: (Expandable r) => Env -> ModName -> ([F.Symbol] -> r -> r) -> F.SourcePos -> BRType r 
-         -> Either UserError (RRType r)
-ofBRType env name f l t  = go [] t 
-  where
-    goReft bs r             = return (f bs r) 
-    goRImpF bs x t1 t2 r    = RImpF x <$> (rebind x <$> go bs t1) <*> go (x:bs) t2 <*> goReft bs r
-    goRFun  bs x t1 t2 r    = RFun  x <$> (rebind x <$> go bs t1) <*> go (x:bs) t2 <*> goReft bs r
-    rebind x t              = F.subst1 t (x, F.EVar $ rTypeValueVar t)
-    go bs (RAppTy t1 t2 r)  = RAppTy <$> go bs t1 <*> go bs t2 <*> goReft bs r
-    go bs (RApp tc ts rs r) = goRApp bs tc ts rs r 
-    go bs (RImpF x t1 t2 r) = goRImpF bs x t1 t2 r 
-    go bs (RFun  x t1 t2 r) = goRFun  bs x t1 t2 r 
-    go bs (RVar a r)        = RVar (RT.bareRTyVar a) <$> goReft bs r
-    go bs (RAllT a t r)     = RAllT a' <$> go bs t <*> goReft bs r 
-      where a'              = dropTyVarInfo (mapTyVarValue RT.bareRTyVar a) 
-    go bs (RAllP a t)       = RAllP a' <$> go bs t 
-      where a'              = ofBPVar env name l a 
-    go bs (RAllE x t1 t2)   = RAllE x  <$> go bs t1    <*> go bs t2
-    go bs (REx x t1 t2)     = REx   x  <$> go bs t1    <*> go (x:bs) t2
-    go bs (RRTy xts r o t)  = RRTy  <$> xts' <*> (goReft bs r) <*> (pure o) <*> go bs t
-      where xts'            = mapM (Misc.mapSndM (go bs)) xts
-    go bs (RHole r)         = RHole    <$> goReft bs r
-    go bs (RExprArg le)     = return    $ RExprArg (qualify env name l bs le) 
-    goRef bs (RProp ss (RHole r)) = rPropP <$> (mapM goSyms ss) <*> goReft bs r
-    goRef bs (RProp ss t)         = RProp  <$> (mapM goSyms ss) <*> go bs t
-    goSyms (x, t)                 = (x,) <$> ofBSortE env name l t 
-    goRApp bs tc ts rs r          = bareTCApp <$> goReft bs r <*> lc' <*> mapM (goRef bs) rs <*> mapM (go bs) ts
-      where
-        lc'                    = F.atLoc lc <$> matchTyCon env name lc (length ts)
-        lc                     = btc_tc tc
-    -- goRApp _ _ _ _             = impossible Nothing "goRApp failed through to final case"
-
-{- 
-    -- TODO-REBARE: goRImpF bounds _ (RApp c ps' _ _) t _
-    -- TODO-REBARE:  | Just bnd <- M.lookup (btc_tc c) bounds
-    -- TODO-REBARE:   = do let (ts', ps) = splitAt (length $ tyvars bnd) ps'
-    -- TODO-REBARE:        ts <- mapM go ts'
-    -- TODO-REBARE:        makeBound bnd ts [x | RVar (BTV x) _ <- ps] <$> go t
-    -- TODO-REBARE: goRFun bounds _ (RApp c ps' _ _) t _
-    -- TODO-REBARE: | Just bnd <- M.lookup (btc_tc c) bounds
-    -- TODO-REBARE: = do let (ts', ps) = splitAt (length $ tyvars bnd) ps'
-    -- TODO-REBARE: ts <- mapM go ts'
-    -- TODO-REBARE: makeBound bnd ts [x | RVar (BTV x) _ <- ps] <$> go t
-
-  -- TODO-REBARE: ofBareRApp env name t@(F.Loc _ _ !(RApp tc ts _ r))
-  -- TODO-REBARE: | Loc l _ c <- btc_tc tc
-  -- TODO-REBARE: , Just rta <- M.lookup c aliases
-  -- TODO-REBARE: = appRTAlias l rta ts =<< resolveReft r
-
--}
-
-matchTyCon :: Env -> ModName -> LocSymbol -> Int -> Either UserError Ghc.TyCon
-matchTyCon env name lc@(Loc _ _ c) arity
-  | isList c && arity == 1  = Right Ghc.listTyCon
-  | isTuple c               = Right tuplTc 
-  | otherwise               = resolveLocSym env name msg lc 
-  where 
-    msg                     = "matchTyCon: " ++ F.showpp c
-    tuplTc                  = Ghc.tupleTyCon Ghc.Boxed arity 
-
-
-bareTCApp :: (Expandable r) 
-          => r
-          -> Located Ghc.TyCon
-          -> [RTProp RTyCon RTyVar r]
-          -> [RType RTyCon RTyVar r]
-          -> (RType RTyCon RTyVar r)
-bareTCApp r (Loc l _ c) rs ts | Just rhs <- Ghc.synTyConRhs_maybe c
-  = if (GM.kindTCArity c < length ts) 
-      then Ex.throw err -- error (F.showpp err)
-      else tyApp (RT.subsTyVars_meet su $ RT.ofType rhs) (drop nts ts) rs r
-    where
-       tvs = [ v | (v, b) <- zip (GM.tyConTyVarsDef c) (Ghc.tyConBinders c), GM.isAnonBinder b]
-       su  = zipWith (\a t -> (RT.rTyVar a, toRSort t, t)) tvs ts
-       nts = length tvs
-
-       err :: UserError
-       err = ErrAliasApp (GM.sourcePosSrcSpan l) (pprint c) (Ghc.getSrcSpan c)
-                         (PJ.hcat [ PJ.text "Expects"
-                                  , pprint (GM.realTcArity c) 
-                                  , PJ.text "arguments, but is given" 
-                                  , pprint (length ts) ] )
--- TODO expandTypeSynonyms here to
-bareTCApp r (Loc _ _ c) rs ts | Ghc.isFamilyTyCon c && isTrivial t
-  = expandRTypeSynonyms (t `RT.strengthen` r)
-  where t = RT.rApp c ts rs mempty
-
-bareTCApp r (Loc _ _ c) rs ts
-  = RT.rApp c ts rs r
-
-
-tyApp :: F.Reftable r => RType c tv r -> [RType c tv r] -> [RTProp c tv r] -> r 
-      -> RType c tv r
-tyApp (RApp c ts rs r) ts' rs' r' = RApp c (ts ++ ts') (rs ++ rs') (r `F.meet` r')
-tyApp t                []  []  r  = t `RT.strengthen` r
-tyApp _                 _  _   _  = panic Nothing $ "Bare.Type.tyApp on invalid inputs"
-
-expandRTypeSynonyms :: (Expandable r) => RRType r -> RRType r
-expandRTypeSynonyms = RT.ofType . Ghc.expandTypeSynonyms . RT.toType
-
-{- 
-expandRTypeSynonyms :: (Expandable r) => RRType r -> RRType r
-expandRTypeSynonyms t
-  | rTypeHasHole t = t 
-  | otherwise      = expandRTypeSynonyms' t
-
-rTypeHasHole :: RType c tv r -> Bool
-rTypeHasHole = foldRType f False
-  where 
-    f _ (RHole _) = True
-    f b _         = b
--}
-
-------------------------------------------------------------------------------------------
--- | Is this the SAME as addTyConInfo? No. `txRefSort`
--- (1) adds the _real_ sorts to RProp,
--- (2) gathers _extra_ RProp at turns them into refinements,
---     e.g. tests/pos/multi-pred-app-00.hs
-------------------------------------------------------------------------------------------
-
-txRefSort :: TyConMap -> F.TCEmb Ghc.TyCon -> LocSpecType -> LocSpecType
-txRefSort tyi tce t = F.atLoc t $ mapBot (addSymSort (GM.fSrcSpan t) tce tyi) (val t)
-
-addSymSort :: Ghc.SrcSpan -> F.TCEmb Ghc.TyCon -> TyConMap -> SpecType -> SpecType 
-addSymSort sp tce tyi (RApp rc@(RTyCon {}) ts rs r)
-  = RApp rc ts (zipWith3 (addSymSortRef sp rc) pvs rargs [1..]) r'
-  where
-    (_, pvs)           = RT.appRTyCon tce tyi rc ts
-    -- pvs             = rTyConPVs rc'
-    (rargs, rrest)     = splitAt (length pvs) rs
-    r'                 = L.foldl' go r rrest
-    go r (RProp _ (RHole r')) = r' `F.meet` r
-    go r (RProp  _ t' )       = let r' = Mb.fromMaybe mempty (stripRTypeBase t') in r `F.meet` r'
-
-addSymSort _ _ _ t
-  = t
-
-addSymSortRef :: (PPrint s) => Ghc.SrcSpan -> s -> RPVar -> SpecProp -> Int -> SpecProp 
-addSymSortRef sp rc p r i
-  | isPropPV p
-  = addSymSortRef' sp rc i p r
-  | otherwise
-  = panic Nothing "addSymSortRef: malformed ref application"
-              
-addSymSortRef' :: (PPrint s) => Ghc.SrcSpan -> s -> Int -> RPVar -> SpecProp -> SpecProp 
-addSymSortRef' _ _ _ p (RProp s (RVar v r)) | isDummy v
-  = RProp xs t
-    where
-      t  = ofRSort (pvType p) `RT.strengthen` r
-      xs = spliceArgs "addSymSortRef 1" s p
-
-addSymSortRef' sp rc i p (RProp _ (RHole r@(MkUReft _ (Pr [up]))))
-  | length xs == length ts
-  = RProp xts (RHole r)
-  | otherwise
-  = -- Misc.errorP "ZONK" $ F.showpp (rc, pname up, i, length xs, length ts)
-    uError $ ErrPartPred sp (pprint rc) (pprint $ pname up) i (length xs) (length ts)
-    where
-      xts = Misc.safeZipWithError "addSymSortRef'" xs ts
-      xs  = Misc.snd3 <$> pargs up
-      ts  = Misc.fst3 <$> pargs p
-
-addSymSortRef' _ _ _ _ (RProp s (RHole r))
-  = RProp s (RHole r)
-
-addSymSortRef' _ _ _ p (RProp s t)
-  = RProp xs t
-    where
-      xs = spliceArgs "addSymSortRef 2" s p
-
-spliceArgs :: String  -> [(F.Symbol, b)] -> PVar t -> [(F.Symbol, t)]
-spliceArgs msg s p = go (fst <$> s) (pargs p)
-  where
-    go []     []           = []
-    go []     ((s,x,_):as) = (x, s):go [] as
-    go (x:xs) ((s,_,_):as) = (x,s):go xs as
-    go xs     []           = panic Nothing $ "spliceArgs: " ++ msg ++ "on XS=" ++ show xs
-
----------------------------------------------------------------------------------
--- RJ: formerly, `replaceLocalBinds` AFAICT
--- | @resolveLocalBinds@ resolves that the "free" variables that appear in the 
---   type-sigs for non-toplevel binders (that correspond to other locally bound)
---   source variables that are visible at that at non-top-level scope. 
---   e.g. tests-names-pos-local02.hs  
----------------------------------------------------------------------------------
-resolveLocalBinds :: Env -> [(Ghc.Var, LocBareType, Maybe [Located F.Expr])] 
-                  -> [(Ghc.Var, LocBareType, Maybe [Located F.Expr])]
----------------------------------------------------------------------------------
-resolveLocalBinds env xtes = [ (x,t,es) | (x, (t, es)) <- topTs ++ replace locTs ]
-  where 
-    (locTs, topTs)         = partitionLocalBinds [ (x, (t, es)) | (x, t, es) <- xtes] 
-    replace                = M.toList . replaceSigs . M.fromList 
-    replaceSigs sigm       = coreVisitor replaceVisitor M.empty sigm cbs 
-    cbs                    = _giCbs (reSrc env)
-
-replaceVisitor :: CoreVisitor SymMap SigMap 
-replaceVisitor = CoreVisitor 
-  { envF  = addBind
-  , bindF = updSigMap
-  , exprF = \_ m _ -> m 
-  }
-
-addBind :: SymMap -> Ghc.Var -> SymMap 
-addBind env v = case localKey v of 
-  Just vx -> M.insert vx (F.symbol v) env 
-  Nothing -> env
-    
-updSigMap :: SymMap -> SigMap -> Ghc.Var -> SigMap 
-updSigMap env m v = case M.lookup v m of 
-  Nothing  -> m 
-  Just tes -> M.insert v (myTracepp ("UPD-LOCAL-SIG " ++ GM.showPpr v) $ renameLocalSig env tes) m
-
-renameLocalSig :: SymMap -> (LocBareType, Maybe [Located F.Expr]) 
-               -> (LocBareType, Maybe [Located F.Expr])  
-renameLocalSig env (t, es) = (F.substf tSub t, F.substf esSub es) 
-  where 
-    tSub                   = F.EVar . qualifySymMap env 
-    esSub                  = tSub `F.substfExcept` xs
-    xs                     = ty_binds (toRTypeRep (F.val t)) 
-
-qualifySymMap :: SymMap -> F.Symbol -> F.Symbol 
-qualifySymMap env x = M.lookupDefault x x env 
-
-type SigMap = M.HashMap Ghc.Var  (LocBareType, Maybe [Located F.Expr])
-type SymMap = M.HashMap F.Symbol F.Symbol
-
----------------------------------------------------------------------------------
-partitionLocalBinds :: [(Ghc.Var, a)] -> ([(Ghc.Var, a)], [(Ghc.Var, a)])
----------------------------------------------------------------------------------
-partitionLocalBinds = L.partition (Mb.isJust . localKey . fst)
diff --git a/src/Language/Haskell/Liquid/Bare/ToBare.hs b/src/Language/Haskell/Liquid/Bare/ToBare.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/ToBare.hs
+++ /dev/null
@@ -1,90 +0,0 @@
--- | This module contains functions that convert things
---   to their `Bare` versions, e.g. SpecType -> BareType etc.
-
-module Language.Haskell.Liquid.Bare.ToBare
-  ( -- * Types
-    specToBare
-
-    -- * Measures
-  , measureToBare
-  )
-  where
-
-import           DataCon
-import           Data.Bifunctor
-
-import           Language.Fixpoint.Misc (mapSnd)
-import qualified Language.Fixpoint.Types as F
-import           Language.Haskell.Liquid.GHC.Misc
-import           Language.Haskell.Liquid.Types
--- import           Language.Haskell.Liquid.Measure
--- import           Language.Haskell.Liquid.Types.RefType
-
---------------------------------------------------------------------------------
-specToBare :: SpecType -> BareType
---------------------------------------------------------------------------------
-specToBare = txRType specToBareTC specToBareTV
-
--- specToBare t = F.tracepp ("specToBare t2 = " ++ F.showpp t2)  t1
-  -- where
-    -- t1       = bareOfType . toType $ t
-    -- t2       = _specToBare           t
-
-
---------------------------------------------------------------------------------
-measureToBare :: SpecMeasure -> BareMeasure
---------------------------------------------------------------------------------
-measureToBare = bimap (fmap specToBare) dataConToBare
-
-dataConToBare :: DataCon -> LocSymbol
-dataConToBare d = (dropModuleNames . F.symbol) <$> locNamedThing d
-  where
-    _msg  = "dataConToBare dc = " ++ show d ++ " v = " ++ show v ++ " vx = " ++ show vx
-    v     = dataConWorkId d
-    vx    = F.symbol v
-
-specToBareTC :: RTyCon -> BTyCon
-specToBareTC = tyConBTyCon . rtc_tc
-
-specToBareTV :: RTyVar -> BTyVar
-specToBareTV (RTV α) = BTV (F.symbol α)
-
-txRType :: (c1 -> c2) -> (tv1 -> tv2) -> RType c1 tv1 r -> RType c2 tv2 r
-txRType cF vF = go
-  where
-    -- go :: RType c1 tv1 r -> RType c2 tv2 r
-    go (RVar α r)          = RVar  (vF α) r
-    go (RAllT α t r)       = RAllT (goRTV α) (go t) r
-    go (RAllP π t)         = RAllP (goPV  π) (go t)
-    go (RImpF x t t' r)     = RImpF  x         (go t) (go t') r
-    go (RFun x t t' r)     = RFun  x         (go t) (go t') r
-    go (RAllE x t t')      = RAllE x         (go t) (go t')
-    go (REx x t t')        = REx   x         (go t) (go t')
-    go (RAppTy t t' r)     = RAppTy          (go t) (go t') r
-    go (RApp c ts rs r)    = RApp  (cF c)    (go <$> ts) (goRTP <$> rs) r
-    go (RRTy xts r o t)    = RRTy  (mapSnd go <$> xts) r o (go t)
-    go (RExprArg e)        = RExprArg e
-    go (RHole r)           = RHole r
-
-    -- go' :: RType c1 tv1 () -> RType c2 tv2 ()
-    go' = txRType cF vF
-
-    -- goRTP :: RTProp c1 tv1 r -> RTProp c2 tv2 r
-    goRTP (RProp s (RHole r)) = RProp (mapSnd go' <$> s) (RHole r)
-    goRTP (RProp s t)         = RProp (mapSnd go' <$> s) (go t)
-
-    -- goRTV :: RTVU c1 tv1 -> RTVU c2 tv2
-    goRTV = txRTV cF vF
-
-    -- goPV :: PVU c1 tv1 -> PVU c2 tv2
-    goPV = txPV cF vF
-
-txRTV :: (c1 -> c2) -> (tv1 -> tv2) -> RTVU c1 tv1 -> RTVU c2 tv2
-txRTV cF vF (RTVar α z) = RTVar (vF α) (txRType cF vF <$> z)
-
-txPV :: (c1 -> c2) -> (tv1 -> tv2) -> PVU c1 tv1 -> PVU c2 tv2
-txPV cF vF (PV x k y txes) = PV x k' y txes'
-  where
-    txes'                  = [ (tx t, x, e) | (t, x, e) <- txes]
-    k'                     = tx <$> k
-    tx                     = txRType cF vF
diff --git a/src/Language/Haskell/Liquid/Bare/Types.hs b/src/Language/Haskell/Liquid/Bare/Types.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Bare/Types.hs
+++ /dev/null
@@ -1,156 +0,0 @@
--- | This module has the code that uses the GHC definitions to:
---   1. MAKE a name-resolution environment,
---   2. USE the environment to translate plain symbols into Var, TyCon, etc. 
-
-module Language.Haskell.Liquid.Bare.Types 
-  ( -- * Name resolution environment 
-    Env (..)
-  , TyThingMap 
-  , ModSpecs
-  , LocalVars 
-
-    -- * Tycon and Datacon processing environment
-  , TycEnv (..) 
-  , DataConMap
-  , RT.TyConMap
-
-    -- * Signature processing environment 
-  , SigEnv (..)
-
-    -- * Measure related environment 
-  , MeasEnv (..)
-
-    -- * Misc 
-  , PlugTV (..)
-  , plugSrc
-  , varRSort 
-  , varSortedReft
-  , failMaybe
-  ) where 
-
-import qualified Control.Exception                     as Ex 
-import qualified Text.PrettyPrint.HughesPJ             as PJ 
-import qualified Data.HashSet                          as S
-import qualified Data.HashMap.Strict                   as M
-import qualified Language.Fixpoint.Types               as F 
-import qualified Language.Haskell.Liquid.Measure       as Ms
-import qualified Language.Haskell.Liquid.Types.RefType as RT 
-import           Language.Haskell.Liquid.Types.Types
-import           Language.Haskell.Liquid.Types.Specs   hiding (BareSpec)
-import           Language.Haskell.Liquid.GHC.API       as Ghc hiding (Located) 
-import           Language.Haskell.Liquid.GHC.Types     (StableName)
-
-
-type ModSpecs = M.HashMap ModName Ms.BareSpec
-
--------------------------------------------------------------------------------
--- | See [NOTE: Plug-Holes-TyVars] for a rationale for @PlugTV@ 
--------------------------------------------------------------------------------
-
-data PlugTV v 
-  = HsTV v  -- ^ Use tyvars from GHC specification (in the `v`) 
-  | LqTV v  -- ^ Use tyvars from Liquid specification
-  | GenTV   -- ^ Generalize ty-vars 
-  | RawTV   -- ^ Do NOT generalize ty-vars (e.g. for type-aliases)
-  deriving (Show)
-
-
-instance (Show v, F.PPrint v) => F.PPrint (PlugTV v) where 
-  pprintTidy _ = PJ.text . show 
-   
-plugSrc ::  PlugTV v -> Maybe v 
-plugSrc (HsTV v) = Just v 
-plugSrc (LqTV v) = Just v 
-plugSrc _        = Nothing
-
--------------------------------------------------------------------------------
--- | Name resolution environment 
--------------------------------------------------------------------------------
-data Env = RE 
-  { reLMap      :: !LogicMap
-  , reSyms      :: ![(F.Symbol, Ghc.Var)]    -- ^ see "syms" in old makeGhcSpec'
-  , _reSubst    :: !F.Subst                  -- ^ see "su"   in old makeGhcSpec'
-  , _reTyThings :: !TyThingMap 
-  , reCfg       :: !Config
-  , reQualImps  :: !QImports                 -- ^ qualified imports
-  , reAllImps   :: !(S.HashSet F.Symbol)     -- ^ all imported modules
-  , reLocalVars :: !LocalVars                -- ^ lines at which local variables are defined.
-  , reGlobSyms  :: !(S.HashSet F.Symbol)     -- ^ global symbols, typically unlifted measures like 'len', 'fromJust'
-  , reSrc       :: !GhcSrc                   -- ^ all source info
-  }
-
-instance HasConfig Env where 
-  getConfig = reCfg 
-
--- | @LocalVars@ is a map from names to lists of pairs of @Ghc.Var@ and 
---   the lines at which they were defined. 
-type LocalVars = M.HashMap F.Symbol [(Int, Ghc.Var)]
-
--------------------------------------------------------------------------------
--- | A @TyThingMap@ is used to resolve symbols into GHC @TyThing@ and, 
---   from there into Var, TyCon, DataCon, etc.
--------------------------------------------------------------------------------
-type TyThingMap = M.HashMap F.Symbol [(F.Symbol, Ghc.TyThing)]
-
--------------------------------------------------------------------------------
--- | A @SigEnv@ contains the needed to process type signatures 
--------------------------------------------------------------------------------
-data SigEnv = SigEnv 
-  { sigEmbs       :: !(F.TCEmb Ghc.TyCon) 
-  , sigTyRTyMap   :: !RT.TyConMap 
-  , sigExports    :: !(S.HashSet StableName)
-  , sigRTEnv      :: !BareRTEnv
-  }
-
--------------------------------------------------------------------------------
--- | A @TycEnv@ contains the information needed to process Type- and Data- Constructors 
--------------------------------------------------------------------------------
-data TycEnv = TycEnv 
-  { tcTyCons      :: ![TyConP]
-  , tcDataCons    :: ![DataConP]
-  , tcSelMeasures :: ![Measure SpecType Ghc.DataCon]
-  , tcSelVars     :: ![(Ghc.Var, LocSpecType)]
-  , tcTyConMap    :: !RT.TyConMap 
-  , tcAdts        :: ![F.DataDecl]
-  , tcDataConMap  :: !DataConMap 
-  , tcEmbs        :: !(F.TCEmb Ghc.TyCon)
-  , tcName        :: !ModName
-  }
-
-type DataConMap = M.HashMap (F.Symbol, Int) F.Symbol
-
--------------------------------------------------------------------------------
--- | Intermediate representation for Measure information 
--------------------------------------------------------------------------------
--- REBARE: used to be output of makeGhcSpecCHOP2
-data MeasEnv = MeasEnv 
-  { meMeasureSpec :: !(MSpec SpecType Ghc.DataCon)          
-  , meClassSyms   :: ![(F.Symbol, Located (RRType F.Reft))] 
-  , meSyms        :: ![(F.Symbol, Located (RRType F.Reft))]
-  , meDataCons    :: ![(Ghc.Var,  LocSpecType)]           
-  , meClasses     :: ![DataConP]                           
-  , meMethods     :: ![(ModName, Ghc.Var, LocSpecType)]  
-  , meCLaws       :: !([(Ghc.Class, [(ModName, Ghc.Var, LocSpecType)])])  
-  }
-
--------------------------------------------------------------------------------
--- | Converting @Var@ to @Sort@
--------------------------------------------------------------------------------
-varSortedReft :: F.TCEmb Ghc.TyCon -> Ghc.Var -> F.SortedReft 
-varSortedReft emb = RT.rTypeSortedReft emb . varRSort 
-
-varRSort  :: Ghc.Var -> RSort
-varRSort  = RT.ofType . Ghc.varType
-
--------------------------------------------------------------------------------
--- | Handling failed resolution 
--------------------------------------------------------------------------------
-failMaybe :: Env -> ModName -> Either UserError r -> Maybe r
-failMaybe env name res = case res of 
-  Right r -> Just r 
-  Left  e -> if isTargetModName env name 
-              then Ex.throw e
-              else Nothing 
-
-isTargetModName :: Env -> ModName -> Bool 
-isTargetModName env name = name == _giTargetMod (reSrc env) 
diff --git a/src/Language/Haskell/Liquid/Cabal.hs b/src/Language/Haskell/Liquid/Cabal.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Cabal.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{- | This module provides a drop-in replacement for Cabal's 'defaultMain', to be used inside 'Setup.hs'
-     modules of packages that wants to use the \"dev mode\". For more information, visit the documentation,
-     especially the \"Developers' guide\".
--}
-
-{-# LANGUAGE LambdaCase #-}
-module Language.Haskell.Liquid.Cabal (liquidHaskellMain) where
-
-import Distribution.Simple
-import System.Environment
-
-liquidHaskellMain :: IO ()
-liquidHaskellMain = do
-  mbDevMode <- lookupEnv "LIQUID_DEV_MODE"
-  defaultMainWithHooks (devModeHooks mbDevMode)
-
-devModeHooks :: Maybe String -> UserHooks
-devModeHooks = \case
-  Nothing               -> simpleUserHooks
-  Just x | x == "false" -> simpleUserHooks
-  Just _                -> simpleUserHooks { buildHook = \_ _ _ _ -> return () }
diff --git a/src/Language/Haskell/Liquid/Constraint/Constraint.hs b/src/Language/Haskell/Liquid/Constraint/Constraint.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/Constraint.hs
+++ /dev/null
@@ -1,59 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-
--- TODO: what exactly is the purpose of this module? What do these functions do?
-
-module Language.Haskell.Liquid.Constraint.Constraint (
-  constraintToLogic
-, addConstraints
-) where
-
-import Prelude hiding (error)
-import Data.Maybe
-import Language.Haskell.Liquid.Types
-import Language.Haskell.Liquid.Constraint.Types
-import Language.Haskell.Liquid.Constraint.Env
-import Language.Fixpoint.Types
-
---------------------------------------------------------------------------------
-addConstraints :: CGEnv -> [(Symbol, SpecType)] -> CGEnv
---------------------------------------------------------------------------------
-addConstraints γ t = γ {lcs = mappend (t2c t) (lcs γ)}
-  where
-    t2c z          = LC [z]
-
---------------------------------------------------------------------------------
-constraintToLogic :: REnv -> LConstraint -> Expr
---------------------------------------------------------------------------------
-constraintToLogic γ (LC ts) = pAnd (constraintToLogicOne γ <$> ts)
-
--- RJ: The code below is atrocious. Please fix it!
-constraintToLogicOne :: (Reftable r) => REnv -> [(Symbol, RRType r)] -> Expr
-constraintToLogicOne γ binds
-  = pAnd [subConstraintToLogicOne
-          (zip xs xts)
-          (last xs,
-          (last (fst <$> xts), r))
-          | xts <- xss]
-  where
-   xts      = init binds
-   (xs, ts) = unzip xts
-   r        = snd $ last binds
-   xss      = combinations ((\t -> [(x, t) | x <- localBindsOfType t γ]) <$> ts)
-
-subConstraintToLogicOne :: (Foldable t, Reftable r, Reftable r1)
-                        => t (Symbol, (Symbol, RType t1 t2 r))
-                        -> (Symbol, (Symbol, RType t3 t4 r1)) -> Expr
-subConstraintToLogicOne xts (x', (x, t)) = PImp (pAnd rs) r
-  where
-        (rs , su) = foldl go ([], []) xts
-        ([r], _ ) = go ([], su) (x', (x, t))
-        go (acc, su) (x', (x, t)) = let (Reft(v, p)) = toReft (fromMaybe mempty (stripRTypeBase t))
-                                        su'          = (x', EVar x):(v, EVar x) : su
-                                    in
-                                     (subst (mkSubst su') p : acc, su')
-
-combinations :: [[a]] -> [[a]]
-combinations []           = [[]]
-combinations ([]:_)       = []
-combinations ((y:ys):yss) = [y:xs | xs <- combinations yss] ++ combinations (ys:yss)
diff --git a/src/Language/Haskell/Liquid/Constraint/Env.hs b/src/Language/Haskell/Liquid/Constraint/Env.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/Env.hs
+++ /dev/null
@@ -1,301 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables       #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE FlexibleContexts          #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE BangPatterns              #-}
-{-# LANGUAGE PatternGuards             #-}
-{-# LANGUAGE DeriveFunctor             #-}
-{-# LANGUAGE MultiParamTypeClasses     #-}
-{-# LANGUAGE OverloadedStrings         #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE ImplicitParams            #-}
-{-# LANGUAGE PartialTypeSignatures     #-}
-
--- | This module defines the representation for Environments needed
---   during constraint generation.
-
-module Language.Haskell.Liquid.Constraint.Env (
-
-  -- * Insert
-    (+++=)
-  -- , (++=)
-  , (+=)
-  , extendEnvWithVV
-  , addBinders
-  , addSEnv
-  , addEEnv
-  , (-=)
-  , globalize
-
-  -- * Construction
-  , fromListREnv
-  , toListREnv
-  , insertREnv -- TODO: remove this ASAP
-
-  -- * Query
-  , localBindsOfType
-  , lookupREnv
-  , (?=)
-
-  -- * Pruning refinements (TODO: move!)
- , rTypeSortedReft'
-
-  -- * Extend CGEnv
- , setLocation, setBind, setRecs, setTRec
-
-  -- * Lookup CGEnv
- , getLocation
-
-) where
-
-
--- import Name (getSrcSpan)
-import Prelude hiding (error)
-import CoreSyn (CoreExpr)
-import SrcLoc
-import Var
--- import Outputable
--- import FastString (fsLit)
-import Control.Monad.State
-
--- import           GHC.Err.Located hiding (error)
-import           GHC.Stack
-
-import           Control.Arrow           (first)
-import           Data.Maybe              -- (fromMaybe)
-import qualified Data.List               as L
-import qualified Data.HashSet            as S
-import qualified Data.HashMap.Strict     as M
-import qualified Language.Fixpoint.Types as F
-
-
-import           Language.Fixpoint.SortCheck (pruneUnsortedReft)
-
-
-
-import           Language.Haskell.Liquid.Types.RefType
-import qualified Language.Haskell.Liquid.GHC.SpanStack as Sp
-import           Language.Haskell.Liquid.Types            hiding (binds, Loc, loc, freeTyVars, Def)
-import           Language.Haskell.Liquid.Constraint.Types
-import           Language.Haskell.Liquid.Constraint.Fresh ()
-import           Language.Haskell.Liquid.Transforms.RefSplit
-import qualified Language.Haskell.Liquid.UX.CTags       as Tg
-
--- import Debug.Trace (trace)
---------------------------------------------------------------------------------
--- | Refinement Type Environments ----------------------------------------------
---------------------------------------------------------------------------------
-
--- updREnvLocal :: REnv -> (_ -> _) -> REnv
-updREnvLocal :: REnv
-             -> (M.HashMap F.Symbol SpecType -> M.HashMap F.Symbol SpecType)
-             -> REnv
-updREnvLocal rE f      = rE { reLocal = f (reLocal rE) }
-
--- RJ: REnv-Split-Bug?
-filterREnv :: (SpecType -> Bool) -> REnv -> REnv
-filterREnv f rE        = rE `updREnvLocal` (M.filter f)
-
-fromListREnv :: [(F.Symbol, SpecType)] -> [(F.Symbol, SpecType)] -> REnv
-fromListREnv gXts lXts = REnv
-  { reGlobal = M.fromList gXts
-  , reLocal  = M.fromList lXts
-  }
-
--- RJ: REnv-Split-Bug?
-deleteREnv :: F.Symbol -> REnv -> REnv
-deleteREnv x rE = rE `updREnvLocal` (M.delete x)
-
-insertREnv :: F.Symbol -> SpecType -> REnv -> REnv
-insertREnv x y rE = {- trace ("insertREnv: " ++ show x) $ -} rE `updREnvLocal` (M.insert x y)
-
-lookupREnv :: F.Symbol -> REnv -> Maybe SpecType
-lookupREnv x rE = msum $ M.lookup x <$> renvMaps rE
-
-memberREnv :: F.Symbol -> REnv -> Bool
-memberREnv x rE = or   $ M.member x <$> renvMaps rE
-
-globalREnv :: REnv -> REnv
-globalREnv (REnv gM lM) = REnv gM' M.empty
-  where
-    gM'  = M.unionWith (\_ t -> t) gM lM
-
-renvMaps :: REnv -> [M.HashMap F.Symbol SpecType]
-renvMaps rE = [reLocal rE, reGlobal rE]
-
---------------------------------------------------------------------------------
-localBindsOfType :: RRType r  -> REnv -> [F.Symbol]
---------------------------------------------------------------------------------
-localBindsOfType tx γ = fst <$> localsREnv (filterREnv ((== toRSort tx) . toRSort) γ)
-
--- RJ: REnv-Split-Bug?
-localsREnv :: REnv -> [(F.Symbol, SpecType)]
-localsREnv = M.toList . reLocal
-
-globalsREnv :: REnv -> [(F.Symbol, SpecType)]
-globalsREnv = M.toList . reGlobal
-
-toListREnv :: REnv -> [(F.Symbol, SpecType)]
-toListREnv re = globalsREnv re ++ localsREnv re
-
---------------------------------------------------------------------------------
-extendEnvWithVV :: CGEnv -> SpecType -> CG CGEnv
---------------------------------------------------------------------------------
-extendEnvWithVV γ t
-  | F.isNontrivialVV vv && not (vv `memberREnv` (renv γ))
-  = γ += ("extVV", vv, t)
-  | otherwise
-  = return γ
-  where
-    vv = rTypeValueVar t
-
-addBinders :: CGEnv -> F.Symbol -> [(F.Symbol, SpecType)] -> CG CGEnv
-addBinders γ0 x' cbs   = foldM (++=) (γ0 -= x') [("addBinders", x, t) | (x, t) <- cbs]
-
-addBind :: SrcSpan -> F.Symbol -> F.SortedReft -> CG ((F.Symbol, F.Sort), F.BindId)
-addBind l x r = do
-  st          <- get
-  let (i, bs') = F.insertBindEnv x r (binds st)
-  put          $ st { binds = bs' } { bindSpans = M.insert i l (bindSpans st) }
-  return ((x, F.sr_sort r), {- traceShow ("addBind: " ++ showpp x) -} i)
-
-addClassBind :: CGEnv -> SrcSpan -> SpecType -> CG [((F.Symbol, F.Sort), F.BindId)]
-addClassBind γ l = mapM (uncurry (addBind l)) . classBinds (emb γ)
-
-{- see tests/pos/polyfun for why you need everything in fixenv -}
-addCGEnv :: (SpecType -> SpecType) -> CGEnv -> (String, F.Symbol, SpecType) -> CG CGEnv
-addCGEnv tx γ (eMsg, x, REx y tyy tyx) = do
-  y' <- fresh
-  γ' <- addCGEnv tx γ (eMsg, y', tyy)
-  addCGEnv tx γ' (eMsg, x, tyx `F.subst1` (y, F.EVar y'))
-
-addCGEnv tx γ (eMsg, x, RAllE yy tyy tyx)
-  = addCGEnv tx γ (eMsg, x, t)
-  where
-    xs            = localBindsOfType tyy (renv γ)
-    t             = L.foldl' F.meet ttrue [ tyx' `F.subst1` (yy, F.EVar x) | x <- xs]
-    (tyx', ttrue) = splitXRelatedRefs yy tyx
-
-addCGEnv tx γ (_, x, t') = do
-  idx   <- fresh
-  -- allowHOBinders <- allowHO <$> get
-  let t  = tx $ normalize idx t'
-  let l  = getLocation γ
-  let γ' = γ { renv = insertREnv x t (renv γ) }
-  tem   <- getTemplates 
-  is    <- (:) <$> addBind l x (rTypeSortedReft' γ' tem t) <*> addClassBind γ' l t
-  return $ γ' { fenv = insertsFEnv (fenv γ) is }
-
-rTypeSortedReft' :: (PPrint r, F.Reftable r, SubsTy RTyVar RSort r, F.Reftable (RTProp RTyCon RTyVar r))
-    => CGEnv -> F.Templates -> RRType r -> F.SortedReft
-rTypeSortedReft' γ t 
-  = pruneUnsortedReft (feEnv $ fenv γ) t . f
-   where
-   f         = rTypeSortedReft (emb γ)
-
-
-normalize :: Integer -> SpecType -> SpecType
-normalize idx = normalizeVV idx . normalizePds
-
-normalizeVV :: Integer -> SpecType -> SpecType
-normalizeVV idx t@(RApp _ _ _ _)
-  | not (F.isNontrivialVV (rTypeValueVar t))
-  = shiftVV t (F.vv $ Just idx)
-
-normalizeVV _ t
-  = t
-
---------------------------------------------------------------------------------
-(+=) :: CGEnv -> (String, F.Symbol, SpecType) -> CG CGEnv
---------------------------------------------------------------------------------
-γ += (eMsg, x, r)
-  | x == F.dummySymbol
-  = return γ
-  -- // | x `memberREnv` (renv γ)
-  -- // = _dupBindErr x γ
-  | otherwise
-  =  γ ++= (eMsg, x, r)
-
-_dupBindError :: String -> F.Symbol -> CGEnv -> SpecType -> a
-_dupBindError eMsg x γ r = panic Nothing s
-  where
-    s = unlines [ eMsg ++ " Duplicate binding for " ++ F.symbolString x
-                , "   New: " ++ showpp r
-                , "   Old: " ++ showpp (x `lookupREnv` (renv γ)) ]
-
---------------------------------------------------------------------------------
-globalize :: CGEnv -> CGEnv
---------------------------------------------------------------------------------
-globalize γ = γ {renv = globalREnv (renv γ)}
-
---------------------------------------------------------------------------------
-(++=) :: CGEnv -> (String, F.Symbol, SpecType) -> CG CGEnv
---------------------------------------------------------------------------------
-(++=) γ (eMsg, x, t)
-  = addCGEnv (addRTyConInv (M.unionWith mappend (invs γ) (ial γ))) γ (eMsg, x, t)
-
---------------------------------------------------------------------------------
-addSEnv :: CGEnv -> (String, F.Symbol, SpecType) -> CG CGEnv
---------------------------------------------------------------------------------
-addSEnv γ = addCGEnv (addRTyConInv (invs γ)) γ
-
-addEEnv :: CGEnv -> (F.Symbol, SpecType) -> CG CGEnv
-addEEnv γ (x,t')= do
-  idx   <- fresh
-  -- allowHOBinders <- allowHO <$> get
-  let t  = addRTyConInv (invs γ) $ normalize idx t'
-  let l  = getLocation γ
-  let γ' = γ { renv = insertREnv x t (renv γ) }
-  tem   <- getTemplates
-  is    <- (:) <$> addBind l x (rTypeSortedReft' γ' tem t) <*> addClassBind γ' l t
-  modify (\s -> s { ebinds = ebinds s ++ (snd <$> is)})
-  return $ γ' { fenv = insertsFEnv (fenv γ) is }
-
-
-(+++=) :: (CGEnv, String) -> (F.Symbol, CoreExpr, SpecType) -> CG CGEnv
-(γ, _) +++= (x, e, t) = (γ {lcb = M.insert x e (lcb γ) }) += ("+++=", x, t)
-
-(-=) :: CGEnv -> F.Symbol -> CGEnv
-γ -= x =  γ { renv = deleteREnv x (renv γ)
-            , lcb  = M.delete   x (lcb  γ)
-            -- , fenv = removeFEnv x (fenv γ)
-            }
-
-(?=) :: (?callStack :: CallStack) => CGEnv -> F.Symbol -> Maybe SpecType
-γ ?= x  = lookupREnv x (renv γ)
-
-------------------------------------------------------------------------
-setLocation :: CGEnv -> Sp.Span -> CGEnv
-------------------------------------------------------------------------
-setLocation γ p = γ { cgLoc = Sp.push p $ cgLoc γ }
-
-------------------------------------------------------------------------
-setBind :: CGEnv -> Var -> CGEnv
-------------------------------------------------------------------------
-setBind γ x = γ `setLocation` Sp.Var x `setBind'` x
-
-setBind' :: CGEnv -> Tg.TagKey -> CGEnv
-setBind' γ k
-  | Tg.memTagEnv k (tgEnv γ) = γ { tgKey = Just k }
-  | otherwise                = γ
-
-------------------------------------------------------------------------
-setRecs :: CGEnv -> [Var] -> CGEnv
-------------------------------------------------------------------------
-setRecs γ xs   = γ { recs = L.foldl' (flip S.insert) (recs γ) xs }
-
-------------------------------------------------------------------------
-setTRec :: CGEnv -> [(Var, SpecType)] -> CGEnv
-------------------------------------------------------------------------
-setTRec γ xts  = γ' {trec = Just $ M.fromList xts' `M.union` trec'}
-  where
-    γ'         = γ `setRecs` (fst <$> xts)
-    trec'      = fromMaybe M.empty $ trec γ
-    xts'       = first F.symbol <$> xts
-
-------------------------------------------------------------------------
-getLocation :: CGEnv -> SrcSpan
-------------------------------------------------------------------------
-getLocation = Sp.srcSpan . cgLoc
diff --git a/src/Language/Haskell/Liquid/Constraint/Fresh.hs b/src/Language/Haskell/Liquid/Constraint/Fresh.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/Fresh.hs
+++ /dev/null
@@ -1,158 +0,0 @@
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TupleSections         #-}
-{-# LANGUAGE TypeSynonymInstances  #-}
-{-# LANGUAGE UndecidableInstances  #-}
-{-# LANGUAGE BangPatterns          #-}
-{-# LANGUAGE ConstraintKinds       #-}
-
-module Language.Haskell.Liquid.Constraint.Fresh
-  ( -- module Language.Haskell.Liquid.Types.Fresh
-    -- , 
-    refreshArgsTop
-  , freshTy_type
-  , freshTy_expr
-  , trueTy
-  , addKuts
-  )
-  where
-
--- import           Data.Maybe                    (catMaybes) -- , fromJust, isJust)
--- import           Data.Bifunctor
--- import qualified Data.List                      as L
-import qualified Data.HashMap.Strict            as M
-import qualified Data.HashSet                   as S
-import           Data.Hashable
-import           Control.Monad.State            (gets, get, put, modify)
-import           Control.Monad                  (when, (>=>))
-import           Prelude                        hiding (error)
-
-import           CoreUtils  (exprType)
-import           Type       (Type)
-import           CoreSyn
-import           Var        (varType, isTyVar, Var)
-
-import           Language.Fixpoint.Misc  ((=>>))
-import qualified Language.Fixpoint.Types as F
-import           Language.Fixpoint.Types.Visitor (kvars)
-import           Language.Haskell.Liquid.Types
--- import           Language.Haskell.Liquid.Types.RefType
--- import           Language.Haskell.Liquid.Types.Fresh
-import           Language.Haskell.Liquid.Constraint.Types
-import qualified Language.Haskell.Liquid.GHC.Misc as GM 
-
---------------------------------------------------------------------------------
--- | This is all hardwiring stuff to CG ----------------------------------------
---------------------------------------------------------------------------------
-instance Freshable CG Integer where
-  fresh = do s <- get
-             let n = freshIndex s
-             put $ s { freshIndex = n + 1 }
-             return n
-
---------------------------------------------------------------------------------
-refreshArgsTop :: (Var, SpecType) -> CG SpecType
---------------------------------------------------------------------------------
-refreshArgsTop (x, t)
-  = do (t', su) <- refreshArgsSub t
-       modify $ \s -> s {termExprs = M.adjust (F.subst su <$>) x $ termExprs s}
-       return t'
-
---------------------------------------------------------------------------------
--- | Generation: Freshness -----------------------------------------------------
---------------------------------------------------------------------------------
-
--- | Right now, we generate NO new pvars. Rather than clutter code
---   with `uRType` calls, put it in one place where the above
---   invariant is /obviously/ enforced.
---   Constraint generation should ONLY use @freshTy_type@ and @freshTy_expr@
-
-freshTy_type        :: KVKind -> CoreExpr -> Type -> CG SpecType
-freshTy_type k e τ  =  F.notracepp ("freshTy_type: " ++ F.showpp k ++ GM.showPpr e) 
-                   <$> freshTy_reftype k (ofType τ)
-
-freshTy_expr        :: KVKind -> CoreExpr -> Type -> CG SpecType
-freshTy_expr k e _  = freshTy_reftype k $ exprRefType e
-
-freshTy_reftype     :: KVKind -> SpecType -> CG SpecType
-freshTy_reftype k _t = (fixTy t >>= refresh) =>> addKVars k
-  where
-    t                = {- F.tracepp ("freshTy_reftype:" ++ show k) -} _t
-
--- | Used to generate "cut" kvars for fixpoint. Typically, KVars for recursive
---   definitions, and also to update the KVar profile.
-addKVars        :: KVKind -> SpecType -> CG ()
-addKVars !k !t  = do
-    cfg <- getConfig  <$> gets ghcI
-    when (True)        $ modify $ \s -> s { kvProf = updKVProf k ks (kvProf s) }
-    when (isKut cfg k) $ addKuts k t
-  where
-    ks         = F.KS $ S.fromList $ specTypeKVars t
-
-isKut :: Config -> KVKind -> Bool
-isKut _  (RecBindE _) = True
-isKut cfg ProjectE    = not (higherOrderFlag cfg) -- see ISSUE 1034, tests/pos/T1034.hs
-isKut _    _          = False
-
-addKuts :: (PPrint a) => a -> SpecType -> CG ()
-addKuts _x t = modify $ \s -> s { kuts = mappend (F.KS ks) (kuts s)   }
-  where
-     ks'     = S.fromList $ specTypeKVars t
-     ks
-       | S.null ks' = ks'
-       | otherwise  = {- F.tracepp ("addKuts: " ++ showpp _x) -} ks'
-
-specTypeKVars :: SpecType -> [F.KVar]
-specTypeKVars = foldReft False (\ _ r ks -> (kvars $ ur_reft r) ++ ks) []
-
---------------------------------------------------------------------------------
-trueTy  :: Type -> CG SpecType
---------------------------------------------------------------------------------
-trueTy = ofType' >=> true
-
-ofType' :: Type -> CG SpecType
-ofType' = fixTy . ofType
-
-fixTy :: SpecType -> CG SpecType
-fixTy t = do tyi   <- tyConInfo  <$> get
-             tce   <- tyConEmbed <$> get
-             return $ addTyConInfo tce tyi t
-
-exprRefType :: CoreExpr -> SpecType
-exprRefType = exprRefType_ M.empty
-
-exprRefType_ :: M.HashMap Var SpecType -> CoreExpr -> SpecType
-exprRefType_ γ (Let b e)
-  = exprRefType_ (bindRefType_ γ b) e
-
-exprRefType_ γ (Lam α e) | isTyVar α
-  = RAllT (makeRTVar $ rTyVar α) (exprRefType_ γ e) mempty
-
-exprRefType_ γ (Lam x e)
-  = rFun (F.symbol x) (ofType $ varType x) (exprRefType_ γ e)
-
-exprRefType_ γ (Tick _ e)
-  = exprRefType_ γ e
-
-exprRefType_ γ (Var x)
-  = M.lookupDefault (ofType $ varType x) x γ
-
-exprRefType_ _ e
-  = ofType $ exprType e
-
-bindRefType_ :: M.HashMap Var SpecType -> Bind Var -> M.HashMap Var SpecType
-bindRefType_ γ (Rec xes)
-  = extendγ γ [(x, exprRefType_ γ e) | (x,e) <- xes]
-
-bindRefType_ γ (NonRec x e)
-  = extendγ γ [(x, exprRefType_ γ e)]
-
-extendγ :: (Eq k, Foldable t, Hashable k)
-        => M.HashMap k v
-        -> t (k, v)
-        -> M.HashMap k v
-extendγ γ xts
-  = foldr (\(x,t) m -> M.insert x t m) γ xts
diff --git a/src/Language/Haskell/Liquid/Constraint/Generate.hs b/src/Language/Haskell/Liquid/Constraint/Generate.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/Generate.hs
+++ /dev/null
@@ -1,1467 +0,0 @@
-{-# LANGUAGE CPP                       #-}
-{-# LANGUAGE DeriveFoldable            #-}
-{-# LANGUAGE DeriveTraversable         #-}
-{-# LANGUAGE StandaloneDeriving        #-}
-{-# LANGUAGE ScopedTypeVariables       #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE FlexibleContexts          #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE BangPatterns              #-}
-{-# LANGUAGE PatternGuards             #-}
-{-# LANGUAGE DeriveFunctor             #-}
-{-# LANGUAGE MultiParamTypeClasses     #-}
-{-# LANGUAGE OverloadedStrings         #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE ImplicitParams            #-}
-
--- | This module defines the representation of Subtyping and WF Constraints,
---   and the code for syntax-directed constraint generation.
-
-module Language.Haskell.Liquid.Constraint.Generate ( generateConstraints, generateConstraintsWithEnv, caseEnv, consE ) where
-
-#if !MIN_VERSION_base(4,14,0)
-import Control.Monad.Fail
-#endif
-
-import           Outputable                                    (Outputable)
-import           Prelude                                       hiding (error)
-import           GHC.Stack
-import           CoreUtils                                     (exprType)
-import           MkCore
-import           Coercion
-import           DataCon
-import           Pair
-import           CoreSyn
-import           SrcLoc                                 hiding (Located)
-import           Type
-import           VarEnv (mkRnEnv2, emptyInScopeSet)
-import           TyCon
-import           CoAxiom
-import           PrelNames
-import           Language.Haskell.Liquid.GHC.API               as Ghc hiding (exprType)
-import           Language.Haskell.Liquid.GHC.TypeRep           ()
-import           IdInfo
-import           Unify
-import           UniqSet (mkUniqSet)
-import           Text.PrettyPrint.HughesPJ hiding ((<>)) 
-import           Control.Monad.State
-import           Data.Maybe                                    (fromMaybe, catMaybes, isJust)
-import qualified Data.HashMap.Strict                           as M
-import qualified Data.HashSet                                  as S
-import qualified Data.List                                     as L
-import qualified Data.Foldable                                 as F
-import qualified Data.Traversable                              as T
-import qualified Data.Functor.Identity
-import           Language.Fixpoint.Misc
-import           Language.Fixpoint.Types.Visitor
-import qualified Language.Fixpoint.Types                       as F
-import qualified Language.Fixpoint.Types.Visitor               as F
-import           Language.Haskell.Liquid.Constraint.Fresh
-import           Language.Haskell.Liquid.Constraint.Init
-import           Language.Haskell.Liquid.Constraint.Env
-import           Language.Haskell.Liquid.Constraint.Monad
-import           Language.Haskell.Liquid.Constraint.Split
-import           Language.Haskell.Liquid.Types.Dictionaries
-import           Language.Haskell.Liquid.GHC.Play          (isHoleVar) 
-import qualified Language.Haskell.Liquid.GHC.Resugar           as Rs
-import qualified Language.Haskell.Liquid.GHC.SpanStack         as Sp
-import qualified Language.Haskell.Liquid.GHC.Misc         as GM -- ( isInternal, collectArguments, tickSrcSpan, showPpr )
-import           Language.Haskell.Liquid.Misc
-import           Language.Haskell.Liquid.Constraint.Types
-import           Language.Haskell.Liquid.Constraint.Constraint
-import           Language.Haskell.Liquid.Transforms.Rec
-import           Language.Haskell.Liquid.Transforms.CoreToLogic (weakenResult)
-import           Language.Haskell.Liquid.Bare.DataType (makeDataConChecker)
-
-import           Language.Haskell.Liquid.Types hiding (binds, Loc, loc, Def)
-
---------------------------------------------------------------------------------
--- | Constraint Generation: Toplevel -------------------------------------------
---------------------------------------------------------------------------------
-generateConstraints      :: TargetInfo -> CGInfo
---------------------------------------------------------------------------------
-generateConstraints info = {-# SCC "ConsGen" #-} execState act $ initCGI cfg info
-  where
-    act                  = do { γ <- initEnv info; consAct γ cfg info }
-    cfg                  = getConfig   info
-
-generateConstraintsWithEnv :: TargetInfo -> CGInfo -> CGEnv -> CGInfo
---------------------------------------------------------------------------------
-generateConstraintsWithEnv info cgi γ = {-# SCC "ConsGenEnv" #-} execState act cgi
-  where
-    act                  = consAct γ cfg info
-    cfg                  = getConfig   info
-
-consAct :: CGEnv -> Config -> TargetInfo -> CG ()
-consAct γ cfg info = do
-  let sSpc = gsSig . giSpec $ info  
-  let gSrc = giSrc info
-  when (gradual cfg) (mapM_ (addW . WfC γ . val . snd) (gsTySigs sSpc ++ gsAsmSigs sSpc))
-  foldM_ (consCBTop cfg info) γ (giCbs gSrc)
-  mapM (consClass γ) (gsMethods $ gsSig $ giSpec info) 
-  hcs <- hsCs  <$> get
-  hws <- hsWfs <$> get
-  fcs <- concat <$> mapM splitC hcs
-  fws <- concat <$> mapM splitW hws
-  modify $ \st -> st { fEnv     = feEnv (fenv γ)
-                     , cgLits   = litEnv   γ
-                     , cgConsts = (cgConsts st) `mappend` (constEnv γ)
-                     , fixCs    = fcs
-                     , fixWfs   = fws }
-
-
-
---------------------------------------------------------------------------------
--- | Ensure that the instance type is a subtype of the class type --------------
---------------------------------------------------------------------------------
-
-consClass :: CGEnv -> (Var, MethodType LocSpecType) -> CG ()
-consClass γ (x,mt) 
-  | Just ti <- tyInstance mt 
-  , Just tc <- tyClass    mt 
-  = addC (SubC (γ `setLocation` Sp.Span (GM.fSrcSpan (F.loc ti))) (val ti) (val tc)) ("cconsClass for " ++ GM.showPpr x)
-consClass _ _ 
-  = return () 
-
---------------------------------------------------------------------------------
--- | TERMINATION TYPE ----------------------------------------------------------
---------------------------------------------------------------------------------
-makeDecrIndex :: (Var, Template SpecType, [Var]) -> CG [Int]
-makeDecrIndex (x, Assumed t, args)
-  = do dindex <- makeDecrIndexTy x t args
-       case dindex of
-         Left _  -> return []
-         Right i -> return i
-makeDecrIndex (x, Asserted t, args)
-  = do dindex <- makeDecrIndexTy x t args
-       case dindex of
-         Left msg -> addWarning msg >> return []
-         Right i  -> return i
-makeDecrIndex _ = return []
-
-makeDecrIndexTy :: Var -> SpecType -> [Var] -> CG (Either (TError t) [Int])
-makeDecrIndexTy x t args
-  = do spDecr <- specDecr <$> get
-       autosz <- autoSize <$> get
-       hint   <- checkHint' autosz (L.lookup x spDecr)
-       case dindex autosz of
-         Nothing -> return $ Left msg
-         Just i  -> return $ Right $ fromMaybe [i] hint
-    where
-       ts         = ty_args trep
-       tvs        = zip ts args
-       checkHint' = \autosz -> checkHint x ts (isDecreasing autosz cenv)
-       dindex     = \autosz -> L.findIndex (p autosz) tvs
-       p autosz (t, v) = isDecreasing autosz cenv t && not (isIdTRecBound v)
-       msg        = ErrTermin (getSrcSpan x) [F.pprint x] (text "No decreasing parameter")
-       cenv       = makeNumEnv ts
-       trep       = toRTypeRep $ unOCons t
-
-
-recType :: F.Symbolic a
-        => S.HashSet TyCon
-        -> (([a], [Int]), (t, [Int], SpecType))
-        -> SpecType
-recType _ ((_, []), (_, [], t))
-  = t
-
-recType autoenv ((vs, indexc), (_, index, t))
-  = makeRecType autoenv t v dxt index
-  where v    = (vs !!)  <$> indexc
-        dxt  = (xts !!) <$> index
-        xts  = zip (ty_binds trep) (ty_args trep)
-        trep = toRTypeRep $ unOCons t
-
-checkIndex :: (NamedThing t, PPrint t, PPrint a)
-           => (t, [a], Template (RType c tv r), [Int])
-           -> CG [Maybe (RType c tv r)]
-checkIndex (x, vs, t, index)
-  = do mapM_ (safeLogIndex msg1 vs) index
-       mapM  (safeLogIndex msg2 ts) index
-    where
-       loc   = getSrcSpan x
-       ts    = ty_args $ toRTypeRep $ unOCons $ unTemplate t
-       msg1  = ErrTermin loc [xd] ("No decreasing" <+> F.pprint index <-> "-th argument on" <+> xd <+> "with" <+> (F.pprint vs))
-       msg2  = ErrTermin loc [xd] "No decreasing parameter"
-       xd    = F.pprint x
-
-makeRecType :: (Enum a1, Eq a1, Num a1, F.Symbolic a)
-            => S.HashSet TyCon
-            -> SpecType
-            -> [a]
-            -> [(F.Symbol, SpecType)]
-            -> [a1]
-            -> SpecType
-makeRecType autoenv t vs dxs is
-  = mergecondition t $ fromRTypeRep $ trep {ty_binds = xs', ty_args = ts'}
-  where
-    (xs', ts') = unzip $ replaceN (last is) (safeFromLeft "makeRecType" $ makeDecrType autoenv vdxs) xts
-    vdxs       = zip vs dxs
-    xts        = zip (ty_binds trep) (ty_args trep)
-    trep       = toRTypeRep $ unOCons t
-
-unOCons :: RType c tv r -> RType c tv r
-unOCons (RAllT v t r)      = RAllT v (unOCons t) r 
-unOCons (RAllP p t)        = RAllP p $ unOCons t
-unOCons (RFun x tx t r)    = RFun x (unOCons tx) (unOCons t) r
-unOCons (RRTy _ _ OCons t) = unOCons t
-unOCons t                  = t
-
-mergecondition :: RType c tv r -> RType c tv r -> RType c tv r
-mergecondition (RAllT _ t1 _) (RAllT v t2 r2)          = RAllT v (mergecondition t1 t2) r2 
-mergecondition (RAllP _ t1) (RAllP p t2)               = RAllP p (mergecondition t1 t2)
-mergecondition (RRTy xts r OCons t1) t2                = RRTy xts r OCons (mergecondition t1 t2)
-mergecondition (RFun _ t11 t12 _) (RFun x2 t21 t22 r2) = RFun x2 (mergecondition t11 t21) (mergecondition t12 t22) r2
-mergecondition _ t                                     = t
-
-safeLogIndex :: Error -> [a] -> Int -> CG (Maybe a)
-safeLogIndex err ls n
-  | n >= length ls = addWarning err >> return Nothing
-  | otherwise      = return $ Just $ ls !! n
-
-checkHint :: (NamedThing a, PPrint a, PPrint a1)
-          => a -> [a1] -> (a1 -> Bool) -> Maybe [Int] -> CG (Maybe [Int])
-checkHint _ _ _ Nothing
-  = return Nothing
-
-checkHint x _ _ (Just ns) | L.sort ns /= ns
-  = addWarning (ErrTermin loc [dx] (text "The hints should be increasing")) >> return Nothing
-  where
-    loc = getSrcSpan x
-    dx  = F.pprint x
-
-checkHint x ts f (Just ns)
-  = (mapM (checkValidHint x ts f) ns) >>= (return . Just . catMaybes)
-
-checkValidHint :: (NamedThing a, PPrint a, PPrint a1)
-               => a -> [a1] -> (a1 -> Bool) -> Int -> CG (Maybe Int)
-checkValidHint x ts f n
-  | n < 0 || n >= length ts = addWarning err >> return Nothing
-  | f (ts L.!! n)           = return $ Just n
-  | otherwise               = addWarning err >> return Nothing
-  where
-    err = ErrTermin loc [xd] (vcat [ "Invalid Hint" <+> F.pprint (n+1) <+> "for" <+> xd
-                                   , "in"
-                                   , F.pprint ts ])
-    loc = getSrcSpan x
-    xd  = F.pprint x
-
---------------------------------------------------------------------------------
-consCBLet :: CGEnv -> CoreBind -> CG CGEnv
---------------------------------------------------------------------------------
-consCBLet γ cb = do
-  oldtcheck <- tcheck <$> get
-  isStr     <- doTermCheck (getConfig γ) cb
-  -- TODO: yuck.
-  modify $ \s -> s { tcheck = oldtcheck && isStr }
-  γ' <- consCB (oldtcheck && isStr) isStr γ cb
-  modify $ \s -> s{tcheck = oldtcheck}
-  return γ'
-
---------------------------------------------------------------------------------
--- | Constraint Generation: Corebind -------------------------------------------
---------------------------------------------------------------------------------
-consCBTop :: Config -> TargetInfo -> CGEnv -> CoreBind -> CG CGEnv
---------------------------------------------------------------------------------
-consCBTop cfg info γ cb
-  | all (trustVar cfg info) xs
-  = foldM addB γ xs
-    where
-       xs   = bindersOf cb
-       tt   = trueTy . varType
-       addB γ x = tt x >>= (\t -> γ += ("derived", F.symbol x, t))
-
-consCBTop _ _ γ cb
-  = do oldtcheck <- tcheck <$> get
-       -- lazyVars  <- specLazy <$> get
-       isStr     <- doTermCheck (getConfig γ) cb
-       modify $ \s -> s { tcheck = oldtcheck && isStr}
-       -- remove invariants that came from the cb definition
-       let (γ', i) = removeInvariant γ cb                 --- DIFF
-       γ'' <- consCB (oldtcheck && isStr) isStr (γ'{cgVar = topBind cb}) cb
-       modify $ \s -> s { tcheck = oldtcheck}
-       return $ restoreInvariant γ'' i                    --- DIFF
-    where
-      topBind (NonRec v _)  = Just v
-      topBind (Rec [(v,_)]) = Just v
-      topBind _             = Nothing
-
-trustVar :: Config -> TargetInfo -> Var -> Bool
-trustVar cfg info x = not (checkDerived cfg) && derivedVar (giSrc info) x
-
-derivedVar :: TargetSrc -> Var -> Bool
-derivedVar src x = S.member x (giDerVars src)
-
-doTermCheck :: Config -> Bind Var -> CG Bool
-doTermCheck cfg bind = do 
-  lazyVs    <- specLazy   <$> get 
-  termVs    <- specTmVars <$> get
-  let skip   = any (\x -> S.member x lazyVs || GM.isInternal x) xs
-  let chk    = not (structuralTerm cfg) || any (\x -> S.member x termVs) xs
-  return     $ chk && not skip
-  where 
-    xs       = bindersOf bind
-
--- nonStructTerm && not skip
-
--- RJ: AAAAAAARGHHH!!!!!! THIS CODE IS HORRIBLE!!!!!!!!!
-consCBSizedTys :: CGEnv -> [(Var, CoreExpr)] -> CG CGEnv
-consCBSizedTys γ xes
-  = do xets     <- forM xes $ \(x, e) -> liftM (x, e,) (varTemplate γ (x, Just e))
-       autoenv  <- autoSize <$> get
-       ts       <- mapM (T.mapM refreshArgs) $ (thd3 <$> xets)
-       let vs    = zipWith collectArgs ts es
-       is       <- mapM makeDecrIndex (zip3 xs ts vs) >>= checkSameLens
-       let xeets = (\vis -> [(vis, x) | x <- zip3 xs is $ map unTemplate ts]) <$> (zip vs is)
-       (L.transpose <$> mapM checkIndex (zip4 xs vs ts is)) >>= checkEqTypes
-       let rts   = (recType autoenv <$>) <$> xeets
-       let xts   = zip xs ts
-       γ'       <- foldM extender γ xts
-       let γs    = zipWith makeRecInvariants [γ' `setTRec` zip xs rts' | rts' <- rts] (filter (not . GM.isPredVar) <$> vs)
-       let xets' = zip3 xs es ts
-       mapM_ (uncurry $ consBind True) (zip γs xets')
-       return γ'
-  where
-       (xs, es)       = unzip xes
-       dxs            = F.pprint <$> xs
-       collectArgs    = GM.collectArguments . length . ty_binds . toRTypeRep . unOCons . unTemplate
-       checkEqTypes :: [[Maybe SpecType]] -> CG [[SpecType]]
-       checkEqTypes x = mapM (checkAll err1 toRSort) (catMaybes <$> x)
-       checkSameLens  = checkAll err2 length
-       err1           = ErrTermin loc dxs $ text "The decreasing parameters should be of same type"
-       err2           = ErrTermin loc dxs $ text "All Recursive functions should have the same number of decreasing parameters"
-       loc            = getSrcSpan (head xs)
-
-       checkAll _   _ []            = return []
-       checkAll err f (x:xs)
-         | all (==(f x)) (f <$> xs) = return (x:xs)
-         | otherwise                = addWarning err >> return []
-
-consCBWithExprs :: CGEnv -> [(Var, CoreExpr)] -> CG CGEnv
-consCBWithExprs γ xes
-  = do xets     <- forM xes $ \(x, e) -> liftM (x, e,) (varTemplate γ (x, Just e))
-       texprs    <- termExprs <$> get
-       let xtes   = catMaybes $ (`lookup` texprs) <$> xs
-       let ts    = safeFromAsserted err . thd3 <$> xets
-       ts'      <- mapM refreshArgs ts
-       let xts   = zip xs (Asserted <$> ts')
-       γ'       <- foldM extender γ xts
-       let γs    = makeTermEnvs γ' xtes xes ts ts'
-       let xets' = zip3 xs es (Asserted <$> ts')
-       mapM_ (uncurry $ consBind True) (zip γs xets')
-       return γ'
-  where (xs, es) = unzip xes
-        lookup k m | Just x <- M.lookup k m = Just (k, x)
-                   | otherwise              = Nothing
-        err      = "Constant: consCBWithExprs"
-
-makeTermEnvs :: CGEnv -> [(Var, [F.Located F.Expr])] -> [(Var, CoreExpr)]
-             -> [SpecType] -> [SpecType]
-             -> [CGEnv]
-makeTermEnvs γ xtes xes ts ts' = setTRec γ . zip xs <$> rts
-  where
-    vs   = zipWith collectArgs ts es
-    ys   = (fst4 . bkArrowDeep) <$> ts
-    ys'  = (fst4 . bkArrowDeep) <$> ts'
-    sus' = zipWith mkSub ys ys'
-    sus  = zipWith mkSub ys ((F.symbol <$>) <$> vs)
-    ess  = (\x -> (safeFromJust (err x) $ (x `L.lookup` xtes))) <$> xs
-    tes  = zipWith (\su es -> F.subst su <$> es)  sus ess
-    tes' = zipWith (\su es -> F.subst su <$> es)  sus' ess
-    rss  = zipWith makeLexRefa tes' <$> (repeat <$> tes)
-    rts  = zipWith (addObligation OTerm) ts' <$> rss
-    (xs, es)     = unzip xes
-    mkSub ys ys' = F.mkSubst [(x, F.EVar y) | (x, y) <- zip ys ys']
-    collectArgs  = GM.collectArguments . length . ty_binds . toRTypeRep
-    err x        = "Constant: makeTermEnvs: no terminating expression for " ++ GM.showPpr x
-
-addObligation :: Oblig -> SpecType -> RReft -> SpecType
-addObligation o t r  = mkArrow αs πs yts xts $ RRTy [] r o t2
-  where
-    (αs, πs, t1) = bkUniv t
-    ((xs',ts',rs'),(xs, ts, rs), t2) = bkArrow t1
-    xts              = zip3 xs ts rs
-    yts              = zip3 xs' ts' rs'
-
---------------------------------------------------------------------------------
-consCB :: Bool -> Bool -> CGEnv -> CoreBind -> CG CGEnv
---------------------------------------------------------------------------------
--- do termination checking
-consCB True _ γ (Rec xes)
-  = do texprs <- termExprs <$> get
-       modify $ \i -> i { recCount = recCount i + length xes }
-       let xxes = catMaybes $ (`lookup` texprs) <$> xs
-       if null xxes
-         then consCBSizedTys γ xes
-         else check xxes <$> consCBWithExprs γ xes
-    where
-      xs = fst (unzip xes)
-      check ys r | length ys == length xs = r
-                 | otherwise              = panic (Just loc) $ msg
-      msg        = "Termination expressions must be provided for all mutually recursive binders"
-      loc        = getSrcSpan (head xs)
-      lookup k m = (k,) <$> M.lookup k m
-
--- don't do termination checking, but some strata checks?
-consCB _ False γ (Rec xes)
-  = do xets     <- forM xes $ \(x, e) -> (x, e,) <$> varTemplate γ (x, Just e)
-       modify     $ \i -> i { recCount = recCount i + length xes }
-       let xts    = [(x, to) | (x, _, to) <- xets]
-       γ'        <- foldM extender (γ `setRecs` (fst <$> xts)) xts
-       mapM_ (consBind True γ') xets
-       return γ'
-
--- don't do termination checking, and don't do any strata checks either?
-consCB _ _ γ (Rec xes)
-  = do xets   <- forM xes $ \(x, e) -> liftM (x, e,) (varTemplate γ (x, Just e))
-       modify $ \i -> i { recCount = recCount i + length xes }
-       let xts = [(x, to) | (x, _, to) <- xets]
-       γ'     <- foldM extender (γ `setRecs` (fst <$> xts)) xts
-       mapM_ (consBind True γ') xets
-       return γ'
-
--- | NV: Dictionaries are not checked, because
--- | class methods' preconditions are not satisfied
-consCB _ _ γ (NonRec x _) | isDictionary x
-  = do t  <- trueTy (varType x)
-       extender γ (x, Assumed t)
-    where
-       isDictionary = isJust . dlookup (denv γ)
-
-
-consCB _ _ γ (NonRec x _ ) | isHoleVar x && typedHoles (getConfig γ)
-  = return γ 
-
-consCB _ _ γ (NonRec x def)
-  | Just (w, τ) <- grepDictionary def
-  , Just d      <- dlookup (denv γ) w
-  = do t        <- mapM trueTy τ
-       mapM addW (WfC γ <$> t)
-       let xts   = dmap (fmap (f t)) d
-       let  γ'   = γ { denv = dinsert (denv γ) x xts }
-       t        <- trueTy (varType x)
-       extender γ' (x, Assumed t)
-   where
-    f [t']    (RAllT α te _) = subsTyVar_meet' (ty_var_value α, t') te
-    f (t':ts) (RAllT α te _) = f ts $ subsTyVar_meet' (ty_var_value α, t') te
-    f _ _ = impossible Nothing "consCB on Dictionary: this should not happen"
-
-consCB _ _ γ (NonRec x e)
-  = do to  <- varTemplate γ (x, Nothing)
-       to' <- consBind False γ (x, e, to) >>= (addPostTemplate γ)
-       extender γ (x, makeSingleton γ (simplify e) <$> to')
-
-grepDictionary :: CoreExpr -> Maybe (Var, [Type])
-grepDictionary = go [] 
-  where 
-    go ts (App (Var w) (Type t)) = Just (w, reverse (t:ts))
-    go ts (App e (Type t))       = go (t:ts) e
-    go ts (App e (Var _))        = go ts e
-    go _ _                       = Nothing
-
---------------------------------------------------------------------------------
-consBind :: Bool -> CGEnv -> (Var, CoreExpr, Template SpecType) -> CG (Template SpecType)
---------------------------------------------------------------------------------
-consBind _ _ (x, _, Assumed t)
-  | RecSelId {} <- idDetails x -- don't check record selectors with assumed specs
-  = return $ F.notracepp ("TYPE FOR SELECTOR " ++ show x) $ Assumed t
-
-consBind isRec γ (x, e, Asserted spect)
-  = do let γ'       = γ `setBind` x
-           (_,πs,_) = bkUniv spect
-       γπ    <- foldM addPToEnv γ' πs
-
-       -- take implcits out of the function's SpecType and into the env
-       let tyr = toRTypeRep spect
-       let spect' = fromRTypeRep (tyr { ty_ebinds = [], ty_eargs = [], ty_erefts = [] })
-       γπ <- foldM (+=) γπ $ (\(y,t)->("implicitError",y,t)) <$> zip (ty_ebinds tyr) (ty_eargs tyr)
-
-       cconsE γπ e (weakenResult x spect')
-       when (F.symbol x `elemHEnv` holes γ) $
-         -- have to add the wf constraint here for HOLEs so we have the proper env
-         addW $ WfC γπ $ fmap killSubst spect
-       addIdA x (defAnn isRec spect)
-       return $ Asserted spect
-
-consBind isRec γ (x, e, Internal spect)
-  = do let γ'       = γ `setBind` x
-           (_,πs,_) = bkUniv spect
-       γπ    <- foldM addPToEnv γ' πs
-       let γπ' = γπ {cerr = Just $ ErrHMeas (getLocation γπ) (pprint x) (text explanation)}
-       cconsE γπ' e spect
-       when (F.symbol x `elemHEnv` holes γ) $
-         -- have to add the wf constraint here for HOLEs so we have the proper env
-         addW $ WfC γπ $ fmap killSubst spect
-       addIdA x (defAnn isRec spect)
-       return $ Internal spect
-  where
-    explanation = "Cannot give singleton type to the function definition."
-
-consBind isRec γ (x, e, Assumed spect)
-  = do let γ' = γ `setBind` x
-       γπ    <- foldM addPToEnv γ' πs
-       cconsE γπ e =<< true spect
-       addIdA x (defAnn isRec spect)
-       return $ Asserted spect
-    where πs   = ty_preds $ toRTypeRep spect
-
-consBind isRec γ (x, e, Unknown)
-  = do t'    <- consE (γ `setBind` x) e
-       t     <- topSpecType x t'
-       addIdA x (defAnn isRec t)
-       when (isExportedId x) (addKuts x t)
-       return $ Asserted t
-
-killSubst :: RReft -> RReft
-killSubst = fmap killSubstReft
-
-killSubstReft :: F.Reft -> F.Reft
-killSubstReft = trans kv () ()
-  where
-    kv    = defaultVisitor { txExpr = ks }
-    ks _ (F.PKVar k _) = F.PKVar k mempty
-    ks _ p             = p
-
-defAnn :: Bool -> t -> Annot t
-defAnn True  = AnnRDf
-defAnn False = AnnDef
-
-addPToEnv :: CGEnv
-          -> PVar RSort -> CG CGEnv
-addPToEnv γ π
-  = do γπ <- γ += ("addSpec1", pname π, pvarRType π)
-       foldM (+=) γπ [("addSpec2", x, ofRSort t) | (t, x, _) <- pargs π]
-
-extender :: F.Symbolic a => CGEnv -> (a, Template SpecType) -> CG CGEnv
-extender γ (x, Asserted t)
-  = case lookupREnv (F.symbol x) (assms γ) of
-      Just t' -> γ += ("extender", F.symbol x, t')
-      _       -> γ += ("extender", F.symbol x, t)
-extender γ (x, Assumed t)
-  = γ += ("extender", F.symbol x, t)
-extender γ _
-  = return γ
-
-data Template a
-  = Asserted a
-  | Assumed a
-  | Internal a
-  | Unknown
-  deriving (Functor, F.Foldable, T.Traversable)
-
-deriving instance (Show a) => (Show (Template a))
-
-instance PPrint a => PPrint (Template a) where
-  pprintTidy k (Asserted t) = "Asserted" <+> pprintTidy k t
-  pprintTidy k (Assumed  t) = "Assumed"  <+> pprintTidy k t
-  pprintTidy k (Internal t) = "Internal" <+> pprintTidy k t
-  pprintTidy _ Unknown      = "Unknown"
-
-unTemplate :: Template t -> t
-unTemplate (Asserted t) = t
-unTemplate (Assumed t)  = t
-unTemplate (Internal t) = t
-unTemplate _            = panic Nothing "Constraint.Generate.unTemplate called on `Unknown`"
-
-addPostTemplate :: CGEnv
-                -> Template SpecType
-                -> CG (Template SpecType)
-addPostTemplate γ (Asserted t) = Asserted <$> addPost γ t
-addPostTemplate γ (Assumed  t) = Assumed  <$> addPost γ t
-addPostTemplate γ (Internal t) = Internal  <$> addPost γ t
-addPostTemplate _ Unknown      = return Unknown
-
-safeFromAsserted :: [Char] -> Template t -> t
-safeFromAsserted _ (Asserted t) = t
-safeFromAsserted msg _ = panic Nothing $ "safeFromAsserted:" ++ msg
-
--- | @varTemplate@ is only called with a `Just e` argument when the `e`
--- corresponds to the body of a @Rec@ binder.
-varTemplate :: CGEnv -> (Var, Maybe CoreExpr) -> CG (Template SpecType)
-varTemplate γ (x, eo) = varTemplate' γ (x, eo) >>= mapM (topSpecType x)
-
--- | @lazVarTemplate@ is like `varTemplate` but for binders that are *not*
---   termination checked and hence, the top-level refinement / KVar is
---   stripped out. e.g. see tests/neg/T743.hs
--- varTemplate :: CGEnv -> (Var, Maybe CoreExpr) -> CG (Template SpecType)
--- lazyVarTemplate γ (x, eo) = dbg <$> (topRTypeBase <$>) <$> varTemplate' γ (x, eo)
---   where
---    dbg   = traceShow ("LAZYVAR-TEMPLATE: " ++ show x)
-
-varTemplate' :: CGEnv -> (Var, Maybe CoreExpr) -> CG (Template SpecType)
-varTemplate' γ (x, eo)
-  = case (eo, lookupREnv (F.symbol x) (grtys γ), lookupREnv (F.symbol x) (assms γ), lookupREnv (F.symbol x) (intys γ)) of
-      (_, Just t, _, _) -> Asserted <$> refreshArgsTop (x, t)
-      (_, _, _, Just t) -> Internal <$> refreshArgsTop (x, t)
-      (_, _, Just t, _) -> Assumed  <$> refreshArgsTop (x, t)
-      (Just e, _, _, _) -> do t  <- freshTy_expr (RecBindE x) e (exprType e)
-                              addW (WfC γ t)
-                              Asserted <$> refreshArgsTop (x, t)
-      (_,      _, _, _) -> return Unknown
-
--- | @topSpecType@ strips out the top-level refinement of "derived var"
-topSpecType :: Var -> SpecType -> CG SpecType
-topSpecType x t = do
-  info  <- ghcI <$> get
-  return $ if derivedVar (giSrc info) x then topRTypeBase t else t
-
---------------------------------------------------------------------------------
--- | Bidirectional Constraint Generation: CHECKING -----------------------------
---------------------------------------------------------------------------------
-cconsE :: CGEnv -> CoreExpr -> SpecType -> CG ()
---------------------------------------------------------------------------------
-cconsE g e t = do
-  -- NOTE: tracing goes here
-  -- traceM $ printf "cconsE:\n  expr = %s\n  exprType = %s\n  lqType = %s\n" (showPpr e) (showPpr (exprType e)) (showpp t)
-  cconsE' g e t
-
---------------------------------------------------------------------------------
-cconsE' :: CGEnv -> CoreExpr -> SpecType -> CG ()
---------------------------------------------------------------------------------
-cconsE' γ e t
-  | Just (Rs.PatSelfBind _x e') <- Rs.lift e
-  = cconsE' γ e' t
-
-  | Just (Rs.PatSelfRecBind x e') <- Rs.lift e
-  = let γ' = γ { grtys = insertREnv (F.symbol x) t (grtys γ)}
-    in void $ consCBLet γ' (Rec [(x, e')])
-
-cconsE' γ e@(Let b@(NonRec x _) ee) t
-  = do sp <- specLVars <$> get
-       if (x `S.member` sp)
-         then cconsLazyLet γ e t
-         else do γ'  <- consCBLet γ b
-                 cconsE γ' ee t
-
-cconsE' γ e (RAllP p t)
-  = cconsE γ' e t''
-  where
-    t'         = replacePredsWithRefs su <$> t
-    su         = (uPVar p, pVartoRConc p)
-    (css, t'') = splitConstraints t'
-    γ'         = L.foldl' addConstraints γ css
-
-cconsE' γ (Let b e) t
-  = do γ'  <- consCBLet γ b
-       cconsE γ' e t
-
-cconsE' γ (Case e x _ cases) t
-  = do γ'  <- consCBLet γ (NonRec x e)
-       forM_ cases $ cconsCase γ' x t nonDefAlts
-    where
-       nonDefAlts = [a | (a, _, _) <- cases, a /= DEFAULT]
-       _msg = "cconsE' #nonDefAlts = " ++ show (length (nonDefAlts))
-
-cconsE' γ (Lam α e) (RAllT α' t r) | isTyVar α
-  = do γ' <- updateEnvironment γ α
-       addForAllConstraint γ' α e (RAllT α' t r)
-       cconsE γ' e $ subsTyVar_meet' (ty_var_value α', rVar α) t
-
-cconsE' γ (Lam x e) (RFun y ty t r)
-  | not (isTyVar x)
-  = do γ' <- γ += ("cconsE", x', ty)
-       cconsE γ' e t'
-       addFunctionConstraint γ x e (RFun x' ty t' r')
-       addIdA x (AnnDef ty)
-  where
-    x'  = F.symbol x
-    t'  = t `F.subst1` (y, F.EVar x')
-    r'  = r `F.subst1` (y, F.EVar x')
-
-cconsE' γ (Tick tt e) t
-  = cconsE (γ `setLocation` (Sp.Tick tt)) e t
-
-cconsE' γ (Cast e co) t
-  -- See Note [Type classes with a single method]
-  | Just f <- isClassConCo co
-  = cconsE γ (f e) t
-
-cconsE' γ e@(Cast e' c) t
-  = do t' <- castTy γ (exprType e) e' c
-       addC (SubC γ (F.notracepp ("Casted Type for " ++ GM.showPpr e ++ "\n init type " ++ showpp t) t') t) ("cconsE Cast: " ++ GM.showPpr e)
-
-cconsE' γ (Var x) t | isHoleVar x && typedHoles (getConfig γ)
-  = addHole x t γ 
-
-cconsE' γ e t
-  = do  te  <- consE γ e
-        te' <- instantiatePreds γ e te >>= addPost γ
-        addC (SubC γ te' t) ("cconsE: " ++ "\n t = " ++ showpp t ++ "\n te = " ++ showpp te ++ GM.showPpr e)
-
-lambdaSingleton :: CGEnv -> F.TCEmb TyCon -> Var -> CoreExpr -> UReft F.Reft
-lambdaSingleton γ tce x e
-  | higherOrderFlag γ, Just e' <- lamExpr γ e
-  = uTop $ F.exprReft $ F.ELam (F.symbol x, sx) e'
-  where
-    sx = typeSort tce $ Ghc.expandTypeSynonyms $ varType x
-lambdaSingleton _ _ _ _
-  = mempty
-
-addForAllConstraint :: CGEnv -> Var -> CoreExpr -> SpecType -> CG ()
-addForAllConstraint γ _ _ (RAllT a t r)
-  | F.isTauto r 
-  = return ()
-  | otherwise
-  = do t'       <- true t
-       let truet = RAllT a $ unRAllP t'
-       addC (SubC γ (truet mempty) $ truet r) "forall constraint true"
-  where unRAllP (RAllT a t r) = RAllT a (unRAllP t) r  
-        unRAllP (RAllP _ t)   = unRAllP t 
-        unRAllP t             = t 
-addForAllConstraint γ _ _ _
-  = impossible (Just $ getLocation γ) "addFunctionConstraint: called on non function argument"
-
-  
-addFunctionConstraint :: CGEnv -> Var -> CoreExpr -> SpecType -> CG ()
-addFunctionConstraint γ x e (RFun y ty t r)
-  = do ty'      <- true ty
-       t'       <- true t
-       let truet = RFun y ty' t'
-       case (lamExpr γ e, higherOrderFlag γ) of
-          (Just e', True) -> do tce    <- tyConEmbed <$> get
-                                let sx  = typeSort tce $ varType x
-                                let ref = uTop $ F.exprReft $ F.ELam (F.symbol x, sx) e'
-                                addC (SubC γ (truet ref) $ truet r)    "function constraint singleton"
-          _ -> addC (SubC γ (truet mempty) $ truet r) "function constraint true"
-addFunctionConstraint γ _ _ _
-  = impossible (Just $ getLocation γ) "addFunctionConstraint: called on non function argument"
-
-splitConstraints :: TyConable c
-                 => RType c tv r -> ([[(F.Symbol, RType c tv r)]], RType c tv r)
-splitConstraints (RRTy cs _ OCons t)
-  = let (css, t') = splitConstraints t in (cs:css, t')
-splitConstraints (RFun x tx@(RApp c _ _ _) t r) | isClass c
-  = let (css, t') = splitConstraints t in (css, RFun x tx t' r)
-splitConstraints t
-  = ([], t)
-
--------------------------------------------------------------------
--- | @instantiateGhosts@ peels away implicit argument binders,
--- instantiates them with fresh variables, and adds those variables
--- to the context as @ebind@s TODO: the second half
--------------------------------------------------------------------
-instantiateGhosts :: CGEnv
-                 -> SpecType
-                 -> CG (Bool, CGEnv, SpecType)
-instantiateGhosts γ t | not (null yts)
-  = do ys' <- mapM (const fresh) ys
-       γ'  <- foldM addEEnv γ (zip ys' ts)
-
-       let su = F.mkSubst $ zip ys (F.EVar <$> ys')
-       return (True, γ', F.subst su te')
-  where (yts, te') = bkImplicit t
-        (ys, ts)   = unzip yts
-
-instantiateGhosts γ t = return (False, γ, t)
-
-bkImplicit :: RType c tv r
-           -> ( [(F.Symbol, RType c tv r)]
-              , RType c tv r)
-bkImplicit (RImpF x tx t _) = ((x,tx):acc, t')
-  where (acc,t') = bkImplicit t
-bkImplicit t = ([],t)
-
--------------------------------------------------------------------
--- | @instantiatePreds@ peels away the universally quantified @PVars@
---   of a @RType@, generates fresh @Ref@ for them and substitutes them
---   in the body.
--------------------------------------------------------------------
-instantiatePreds :: CGEnv
-                 -> CoreExpr
-                 -> SpecType
-                 -> CG SpecType
-instantiatePreds γ e (RAllP π t)
-  = do r     <- freshPredRef γ e π
-       instantiatePreds γ e $ replacePreds "consE" t [(π, r)]
-
-instantiatePreds _ _ t0
-  = return t0
-
-
--------------------------------------------------------------------
-cconsLazyLet :: CGEnv
-             -> CoreExpr
-             -> SpecType
-             -> CG ()
-cconsLazyLet γ (Let (NonRec x ex) e) t
-  = do tx <- trueTy (varType x)
-       γ' <- (γ, "Let NonRec") +++= (x', ex, tx)
-       cconsE γ' e t
-    where
-       x' = F.symbol x
-
-cconsLazyLet _ _ _
-  = panic Nothing "Constraint.Generate.cconsLazyLet called on invalid inputs"
-
---------------------------------------------------------------------------------
--- | Bidirectional Constraint Generation: SYNTHESIS ----------------------------
---------------------------------------------------------------------------------
-consE :: CGEnv -> CoreExpr -> CG SpecType
---------------------------------------------------------------------------------
-consE γ e
-  | patternFlag γ
-  , Just p <- Rs.lift e
-  = consPattern γ (F.notracepp "CONSE-PATTERN: " p) (exprType e)
-
--- NV CHECK 3 (unVar and does this hack even needed?)
--- NV (below) is a hack to type polymorphic axiomatized functions
--- no need to check this code with flag, the axioms environment with
--- is empty if there is no axiomatization. 
-
--- [NOTE: PLE-OPT] We *disable* refined instantiation for 
--- reflected functions inside proofs.
-consE γ (Var x)
-  = do t <- varRefType γ x
-       addLocA (Just x) (getLocation γ) (varAnn γ x t)
-       return t
-
-consE _ (Lit c)
-  = refreshVV $ uRType $ literalFRefType c
-
-consE γ e'@(App e a@(Type τ))
-  = do RAllT α te _ <- checkAll ("Non-all TyApp with expr", e) γ <$> consE γ e
-       t            <- if not (nopolyinfer (getConfig γ)) && isPos α && isGenericVar (ty_var_value α) te 
-                         then freshTy_type TypeInstE e τ 
-                         else trueTy τ
-       addW          $ WfC γ t
-       t'           <- refreshVV t
-       tt0          <- instantiatePreds γ e' (subsTyVar_meet' (ty_var_value α, t') te)
-       let tt        = makeSingleton γ (simplify e') $ subsTyReft γ (ty_var_value α) τ tt0
-       case rTVarToBind α of
-         Just (x, _) -> return $ maybe (checkUnbound γ e' x tt a) (F.subst1 tt . (x,)) (argType τ)
-         Nothing     -> return tt
-  where 
-    isPos α = not (extensionality (getConfig γ)) || rtv_is_pol (ty_var_info α)
-
-consE γ e'@(App e a) | Just aDict <- getExprDict γ a
-  = case dhasinfo (dlookup (denv γ) aDict) (getExprFun γ e) of
-      Just riSig -> return $ fromRISig riSig
-      _          -> do
-        ([], πs, te) <- bkUniv <$> consE γ e
-        te'          <- instantiatePreds γ e' $ foldr RAllP te πs
-        (γ', te''')  <- dropExists γ te'
-        te''         <- dropConstraints γ te'''
-        updateLocA {- πs -}  (exprLoc e) te''
-        let RFun x tx t _ = checkFun ("Non-fun App with caller ", e') γ te''
-        cconsE γ' a tx
-        addPost γ'        $ maybe (checkUnbound γ' e' x t a) (F.subst1 t . (x,)) (argExpr γ a)
-
-consE γ e'@(App e a)
-  = do ([], πs, te) <- bkUniv <$> consE γ ({- GM.tracePpr ("APP-EXPR: " ++ GM.showPpr (exprType e)) -} e)
-       te'          <- instantiatePreds γ e' $ foldr RAllP te πs
-       (γ', te''')  <- dropExists γ te'
-       te''         <- dropConstraints γ te'''
-       updateLocA (exprLoc e) te''
-       (hasGhost, γ'', te''')     <- instantiateGhosts γ' te''
-       let RFun x tx t _ = checkFun ("Non-fun App with caller ", e') γ te'''
-       cconsE γ'' a tx
-       tout <- makeSingleton γ'' (simplify e') <$> (addPost γ'' $ maybe (checkUnbound γ'' e' x t a) (F.subst1 t . (x,)) (argExpr γ $ simplify a))
-       if hasGhost
-          then do
-           tk   <- freshTy_type ImplictE e' $ exprType e'
-           addW $ WfC γ tk
-           addC (SubC γ'' tout tk) ""
-           return tk
-          else return tout
-
-consE γ (Lam α e) | isTyVar α
-  = do γ' <- updateEnvironment γ α
-       t' <- consE γ' e
-       return $ RAllT (makeRTVar $ rTyVar α) t' mempty
-
-consE γ  e@(Lam x e1)
-  = do tx      <- freshTy_type LamE (Var x) τx
-       γ'      <- γ += ("consE", F.symbol x, tx)
-       t1      <- consE γ' e1
-       addIdA x $ AnnDef tx
-       addW     $ WfC γ tx
-       tce     <- tyConEmbed <$> get
-       return   $ RFun (F.symbol x) tx t1 $ lambdaSingleton γ tce x e1
-    where
-      FunTy { ft_arg = τx } = exprType e
-
-consE γ e@(Let _ _)
-  = cconsFreshE LetE γ e
-
-consE γ e@(Case _ _ _ [_])
-  | Just p@(Rs.PatProject {}) <- Rs.lift e
-  = consPattern γ p (exprType e)
-
-consE γ e@(Case _ _ _ cs)
-  = cconsFreshE (caseKVKind cs) γ e
-
-consE γ (Tick tt e)
-  = do t <- consE (setLocation γ (Sp.Tick tt)) e
-       addLocA Nothing (GM.tickSrcSpan tt) (AnnUse t)
-       return t
-
--- See Note [Type classes with a single method]
-consE γ (Cast e co)
-  | Just f <- isClassConCo co
-  = consE γ (f e)
-
-consE γ e@(Cast e' c)
-  = castTy γ (exprType e) e' c
-
-consE _ e@(Coercion _)
-   = trueTy $ exprType e
-
-consE _ e@(Type t)
-  = panic Nothing $ "consE cannot handle type " ++ GM.showPpr (e, t)
-
-caseKVKind ::[Alt Var] -> KVKind
-caseKVKind [(DataAlt _, _, Var _)] = ProjectE
-caseKVKind cs                      = CaseE (length cs)
-
-updateEnvironment :: CGEnv  -> TyVar -> CG CGEnv
-updateEnvironment γ a
-  | isValKind (tyVarKind a)
-  = γ += ("varType", F.symbol $ varName a, kindToRType $ tyVarKind a)
-  | otherwise
-  = return γ
-
-getExprFun :: CGEnv -> CoreExpr -> Var
-getExprFun γ e          = go e
-  where
-    go (App x (Type _)) = go x
-    go (Var x)          = x
-    go _                = panic (Just (getLocation γ)) msg
-    msg                 = "getFunName on \t" ++ GM.showPpr e
-
--- | `exprDict e` returns the dictionary `Var` inside the expression `e`
-getExprDict :: CGEnv -> CoreExpr -> Maybe Var
-getExprDict γ           =  go
-  where
-    go (Var x)          = case dlookup (denv γ) x of {Just _ -> Just x; Nothing -> Nothing}
-    go (Tick _ e)       = go e
-    go (App a (Type _)) = go a
-    go _                = Nothing
-
---------------------------------------------------------------------------------
--- | With GADTs and reflection, refinements can contain type variables, 
---   as 'coercions' (see ucsd-progsys/#1424). At application sites, we 
---   must also substitute those from the refinements (not just the types).
---      https://github.com/ucsd-progsys/liquidhaskell/issues/1424
--- 
---   see: tests/ple/{pos,neg}/T1424.hs
---
---------------------------------------------------------------------------------
-
-subsTyReft :: CGEnv -> RTyVar -> Type -> SpecType -> SpecType 
-subsTyReft γ a t = mapExprReft (\_ -> F.applyCoSub coSub) 
-  where 
-    coSub        = M.fromList [(F.symbol a, typeSort (emb γ) t)]
-
---------------------------------------------------------------------------------
--- | Type Synthesis for Special @Pattern@s -------------------------------------
---------------------------------------------------------------------------------
-consPattern :: CGEnv -> Rs.Pattern -> Type -> CG SpecType
-
-{- [NOTE] special type rule for monadic-bind application
-
-    G |- e1 ~> m tx     G, x:tx |- e2 ~> m t
-    -----------------------------------------
-          G |- (e1 >>= \x -> e2) ~> m t
- -}
-
-consPattern γ (Rs.PatBind e1 x e2 _ _ _ _ _) _ = do
-  tx <- checkMonad (msg, e1) γ <$> consE γ e1
-  γ' <- γ += ("consPattern", F.symbol x, tx)
-  addIdA x (AnnDef tx)
-  mt <- consE γ' e2
-  return mt
-  where
-    msg = "This expression has a refined monadic type; run with --no-pattern-inline: "
-
-{- [NOTE] special type rule for monadic-return
-
-           G |- e ~> et
-    ------------------------
-      G |- return e ~ m et
- -}
-consPattern γ (Rs.PatReturn e m _ _ _) t = do
-  et    <- F.notracepp "Cons-Pattern-Ret" <$> consE γ e
-  mt    <- trueTy  m
-  tt    <- trueTy  t
-  return (mkRAppTy mt et tt) -- /// {-    $ RAppTy mt et mempty -}
-
-{- [NOTE] special type rule for field projection, is
-          t  = G(x)       ti = Proj(t, i)
-    -----------------------------------------
-      G |- case x of C [y1...yn] -> yi : ti
- -}
-
-consPattern γ (Rs.PatProject xe _ τ c ys i) _ = do
-  let yi = ys !! i
-  t    <- (addW . WfC γ) <<= freshTy_type ProjectE (Var yi) τ
-  γ'   <- caseEnv γ xe [] (DataAlt c) ys (Just [i])
-  ti   <- {- γ' ??= yi -} varRefType γ' yi
-  addC (SubC γ' ti t) "consPattern:project"
-  return t
-
-consPattern γ (Rs.PatSelfBind _ e) _ =
-  consE γ e
-
-consPattern γ p@(Rs.PatSelfRecBind {}) _ =
-  cconsFreshE LetE γ (Rs.lower p)
-
-mkRAppTy :: SpecType -> SpecType -> SpecType -> SpecType 
-mkRAppTy mt et (RAppTy _ _ _)    = RAppTy mt et mempty 
-mkRAppTy _  et (RApp c [_] [] _) = RApp c [et] [] mempty 
-mkRAppTy _  _  _                 = panic Nothing $ "Unexpected return-pattern" 
-
-checkMonad :: (Outputable a) => (String, a) -> CGEnv -> SpecType -> SpecType
-checkMonad x g = go . unRRTy
- where
-   go (RApp _ ts [] _)
-     | length ts > 0 = last ts
-   go (RAppTy _ t _) = t
-   go t              = checkErr x g t
-
-unRRTy :: SpecType -> SpecType
-unRRTy (RRTy _ _ _ t) = unRRTy t
-unRRTy t              = t
-
---------------------------------------------------------------------------------
-castTy  :: CGEnv -> Type -> CoreExpr -> Coercion -> CG SpecType
-castTy' :: CGEnv -> Type -> CoreExpr -> CG SpecType
---------------------------------------------------------------------------------
-castTy γ t e (AxiomInstCo ca _ _)
-  = fromMaybe <$> castTy' γ t e <*> lookupNewType (coAxiomTyCon ca)
-
-castTy γ t e (SymCo (AxiomInstCo ca _ _))
-  = do mtc <- lookupNewType (coAxiomTyCon ca)
-       case mtc of
-        Just tc -> cconsE γ e tc
-        Nothing -> return ()
-       castTy' γ t e
-
-castTy γ t e _
-  = castTy' γ t e
-
-
-castTy' γ τ (Var x)
-  = do t <- trueTy τ
-       -- tx <- varRefType γ x -- NV HERE: the refinements of the var x do not get into the 
-       --                      -- environment. Check 
-       let ce = eCoerc (typeSort (emb γ) $ Ghc.expandTypeSynonyms $ varType x) 
-                       (typeSort (emb γ) τ) 
-                       $ F.expr x  
-       return ((t `strengthen` (uTop $ F.uexprReft $ ce)) {- `F.meet` tx -})
-  where eCoerc s t e 
-         | s == t    = e
-         | otherwise = F.ECoerc s t e 
-
-castTy' γ t (Tick _ e)
-  = castTy' γ t e
-
-castTy' _ _ e
-  = panic Nothing $ "castTy cannot handle expr " ++ GM.showPpr e
-
-{-
-showCoercion :: Coercion -> String
-showCoercion (AxiomInstCo co1 co2 co3)
-  = "AxiomInstCo " ++ showPpr co1 ++ "\t\t " ++ showPpr co2 ++ "\t\t" ++ showPpr co3 ++ "\n\n" ++
-    "COAxiom Tycon = "  ++ showPpr (coAxiomTyCon co1) ++ "\nBRANCHES\n" ++ concatMap showBranch bs
-  where
-    bs = fromBranchList $ co_ax_branches co1
-    showBranch ab = "\nCoAxiom \nLHS = " ++ showPpr (coAxBranchLHS ab) ++
-                    "\nRHS = " ++ showPpr (coAxBranchRHS ab)
-showCoercion (SymCo c)
-  = "Symc :: " ++ showCoercion c
-showCoercion c
-  = "Coercion " ++ showPpr c
--}
-
-isClassConCo :: Coercion -> Maybe (Expr Var -> Expr Var)
--- See Note [Type classes with a single method]
-isClassConCo co
-  | Pair t1 t2 <- coercionKind co
-  , isClassPred t2
-  , (tc,ts) <- splitTyConApp t2
-  , [dc]    <- tyConDataCons tc
-  , [tm]    <- dataConOrigArgTys dc
-               -- tcMatchTy because we have to instantiate the class tyvars
-  , Just _  <- ruleMatchTyX (mkUniqSet $ tyConTyVars tc) (mkRnEnv2 emptyInScopeSet) emptyTvSubstEnv tm t1
-  = Just (\e -> mkCoreConApps dc $ map Type ts ++ [e])
-
-  | otherwise
-  = Nothing
-  where
-    ruleMatchTyX =ruleMatchTyKiX -- TODO: is this correct?
-
-----------------------------------------------------------------------
--- Note [Type classes with a single method]
-----------------------------------------------------------------------
--- GHC 7.10 encodes type classes with a single method as newtypes and
--- `cast`s between the method and class type instead of applying the
--- class constructor. Just rewrite the core to what we're used to
--- seeing..
---
--- specifically, we want to rewrite
---
---   e `cast` ((a -> b) ~ C)
---
--- to
---
---   D:C e
---
--- but only when
---
---   D:C :: (a -> b) -> C
-
---------------------------------------------------------------------------------
--- | @consFreshE@ is used to *synthesize* types with a **fresh template**.
---   e.g. at joins, recursive binders, polymorphic instantiations etc. It is
---   the "portal" that connects `consE` (synthesis) and `cconsE` (checking)
---------------------------------------------------------------------------------
-cconsFreshE :: KVKind -> CGEnv -> CoreExpr -> CG SpecType
-cconsFreshE kvkind γ e = do
-  t   <- freshTy_type kvkind e $ exprType e
-  addW $ WfC γ t
-  cconsE γ e t
-  return t
---------------------------------------------------------------------------------
-
-checkUnbound :: (Show a, Show a2, F.Subable a)
-             => CGEnv -> CoreExpr -> F.Symbol -> a -> a2 -> a
-checkUnbound γ e x t a
-  | x `notElem` (F.syms t) = t
-  | otherwise              = panic (Just $ getLocation γ) msg
-  where
-    msg = unlines [ "checkUnbound: " ++ show x ++ " is elem of syms of " ++ show t
-                  , "In", GM.showPpr e, "Arg = " , show a ]
-
-
-dropExists :: CGEnv -> SpecType -> CG (CGEnv, SpecType)
-dropExists γ (REx x tx t) =         (, t) <$> γ += ("dropExists", x, tx)
-dropExists γ t            = return (γ, t)
-
-dropConstraints :: CGEnv -> SpecType -> CG SpecType
-dropConstraints γ (RFun x tx@(RApp c _ _ _) t r) | isClass c
-  = (flip (RFun x tx)) r <$> dropConstraints γ t
-dropConstraints γ (RRTy cts _ OCons t)
-  = do γ' <- foldM (\γ (x, t) -> γ `addSEnv` ("splitS", x,t)) γ xts
-       addC (SubC  γ' t1 t2)  "dropConstraints"
-       dropConstraints γ t
-  where
-    (xts, t1, t2) = envToSub cts
-
-dropConstraints _ t = return t
-
--------------------------------------------------------------------------------------
-cconsCase :: CGEnv -> Var -> SpecType -> [AltCon] -> (AltCon, [Var], CoreExpr) -> CG ()
--------------------------------------------------------------------------------------
-cconsCase γ x t acs (ac, ys, ce)
-  = do cγ <- caseEnv γ x acs ac ys mempty
-       cconsE cγ ce t
-
-{- 
-
-case x :: List b of 
-  Emp -> e 
-
-  Emp :: tdc          forall a. {v: List a | cons v === 0} 
-  x   :: xt           List b 
-  ys  == binders      [] 
-
--}
--------------------------------------------------------------------------------------
-caseEnv   :: CGEnv -> Var -> [AltCon] -> AltCon -> [Var] -> Maybe [Int] -> CG CGEnv
--------------------------------------------------------------------------------------
-caseEnv γ x _   (DataAlt c) ys pIs = do 
-
-  let (x' : ys')   = F.symbol <$> (x:ys)
-  xt0             <- checkTyCon ("checkTycon cconsCase", x) γ <$> γ ??= x
-  let xt           = shiftVV xt0 x'
-  tdc             <- (γ ??= (dataConWorkId c) >>= refreshVV)
-  let (rtd,yts',_) = unfoldR tdc xt ys
-  yts             <- projectTypes pIs yts'
-  let ys''         = F.symbol <$> filter (not . GM.isEvVar) ys
-  let r1           = dataConReft   c   ys''
-  let r2           = dataConMsReft rtd ys''
-  let xt           = (xt0 `F.meet` rtd) `strengthen` (uTop (r1 `F.meet` r2))
-  let cbs          = safeZip "cconsCase" (x':ys') (xt0 : yts)
-  cγ'             <- addBinders γ   x' cbs
-  addBinders cγ' x' [(x', xt)]
-  
-caseEnv γ x acs a _ _ = do 
-  let x'  = F.symbol x
-  xt'    <- (`strengthen` uTop (altReft γ acs a)) <$> (γ ??= x)
-  cγ     <- addBinders γ x' [(x', xt')]
-  return cγ
-
---------------------------------------------------------------------------------
--- | `projectTypes` masks (i.e. true's out) all types EXCEPT those
---   at given indices; it is used to simplify the environment used
---   when projecting out fields of single-ctor datatypes.
---------------------------------------------------------------------------------
-projectTypes :: Maybe [Int] -> [SpecType] -> CG [SpecType]
-projectTypes Nothing   ts = return ts
-projectTypes (Just is) ts = mapM (projT is) (zip [0..] ts)
-  where
-    projT is (j, t)
-      | j `elem` is       = return t
-      | otherwise         = true t
-
-altReft :: CGEnv -> [AltCon] -> AltCon -> F.Reft
-altReft _ _ (LitAlt l)   = literalFReft l
-altReft γ acs DEFAULT    = mconcat ([notLiteralReft l | LitAlt l <- acs] ++ [notDataConReft d | DataAlt d <- acs])
-  where
-    notLiteralReft   = maybe mempty F.notExprReft . snd . literalConst (emb γ)
-    notDataConReft d | exactDC (getConfig γ)
-                     = F.Reft (F.vv_, F.PNot (F.EApp (F.EVar $ makeDataConChecker d) (F.EVar F.vv_)))
-                     | otherwise = mempty
-altReft _ _ _        = panic Nothing "Constraint : altReft"
-
-unfoldR :: SpecType -> SpecType -> [Var] -> (SpecType, [SpecType], SpecType)
-unfoldR td (RApp _ ts rs _) ys = (t3, tvys ++ yts, ignoreOblig rt)
-  where
-        tbody              = instantiatePvs (instantiateTys td ts) (reverse rs)
-        -- TODO: if we ever want to support applying implicits explicitly, will need to rejigger
-        ((_,_,_),(ys0,yts',_), rt) = safeBkArrow (F.notracepp msg $ instantiateTys tbody tvs')
-        msg                = "INST-TY: " ++ F.showpp (td, ts, tbody, ys, tvs') 
-        yts''              = zipWith F.subst sus (yts'++[rt])
-        (t3,yts)           = (last yts'', init yts'')
-        sus                = F.mkSubst <$> (L.inits [(x, F.EVar y) | (x, y) <- zip ys0 ys'])
-        (αs, ys')          = mapSnd (F.symbol <$>) $ L.partition isTyVar ys
-        tvs' :: [SpecType]
-        tvs'               = rVar <$> αs
-        tvys               = ofType . varType <$> αs
-
-unfoldR _  _                _  = panic Nothing "Constraint.hs : unfoldR"
-
-instantiateTys :: SpecType -> [SpecType] -> SpecType
-instantiateTys = L.foldl' go
-  where 
-    go (RAllT α tbody _) t = subsTyVar_meet' (ty_var_value α, t) tbody
-    go _ _                 = panic Nothing "Constraint.instantiateTy"
-
-instantiatePvs :: SpecType -> [SpecProp] -> SpecType
-instantiatePvs           = L.foldl' go
-  where 
-    go (RAllP p tbody) r = replacePreds "instantiatePv" tbody [(p, r)]
-    go t               _ = errorP "" ("Constraint.instantiatePvs: t = " ++ showpp t)
-
-checkTyCon :: (Outputable a) => (String, a) -> CGEnv -> SpecType -> SpecType
-checkTyCon _ _ t@(RApp _ _ _ _) = t
-checkTyCon x g t                = checkErr x g t
-
-checkFun :: (Outputable a) => (String, a) -> CGEnv -> SpecType -> SpecType
-checkFun _ _ t@(RFun _ _ _ _) = t
-checkFun x g t                = checkErr x g t
-
-checkAll :: (Outputable a) => (String, a) -> CGEnv -> SpecType -> SpecType
-checkAll _ _ t@(RAllT _ _ _)  = t
-checkAll x g t                = checkErr x g t
-
-checkErr :: (Outputable a) => (String, a) -> CGEnv -> SpecType -> SpecType
-checkErr (msg, e) γ t         = panic (Just sp) $ msg ++ GM.showPpr e ++ ", type: " ++ showpp t
-  where
-    sp                        = getLocation γ
-
-varAnn :: CGEnv -> Var -> t -> Annot t
-varAnn γ x t
-  | x `S.member` recs γ      = AnnLoc (getSrcSpan x)
-  | otherwise                = AnnUse t
-
------------------------------------------------------------------------
--- | Helpers: Creating Fresh Refinement -------------------------------
------------------------------------------------------------------------
-freshPredRef :: CGEnv -> CoreExpr -> PVar RSort -> CG SpecProp
-freshPredRef γ e (PV _ (PVProp τ) _ as)
-  = do t    <- freshTy_type PredInstE e (toType τ)
-       args <- mapM (\_ -> fresh) as
-       let targs = [(x, s) | (x, (s, y, z)) <- zip args as, (F.EVar y) == z ]
-       γ' <- foldM (+=) γ [("freshPredRef", x, ofRSort τ) | (x, τ) <- targs]
-       addW $ WfC γ' t
-       return $ RProp targs t
-
-freshPredRef _ _ (PV _ PVHProp _ _)
-  = todo Nothing "EFFECTS:freshPredRef"
-
-
---------------------------------------------------------------------------------
--- | Helpers: Creating Refinement Types For Various Things ---------------------
---------------------------------------------------------------------------------
-argType :: Type -> Maybe F.Expr
-argType (LitTy (NumTyLit i))
-  = mkI i
-argType (LitTy (StrTyLit s))
-  = mkS $ bytesFS s
-argType (TyVarTy x)
-  = Just $ F.EVar $ F.symbol $ varName x
-argType t
-  | F.symbol (GM.showPpr t) == anyTypeSymbol
-  = Just $ F.EVar anyTypeSymbol
-argType _
-  = Nothing
-
-
-argExpr :: CGEnv -> CoreExpr -> Maybe F.Expr
-argExpr _ (Var v)     = Just $ F.eVar v
-argExpr γ (Lit c)     = snd  $ literalConst (emb γ) c
-argExpr γ (Tick _ e)  = argExpr γ e
-argExpr γ (App e (Type _)) = argExpr γ e 
-argExpr _ _           = Nothing
-
-
--- NIKI TODO: merge arg/lam/fun-Expr
-lamExpr :: CGEnv -> CoreExpr -> Maybe F.Expr
-lamExpr _ (Var v)     =  Just $ F.eVar v
-lamExpr γ (Lit c)     = snd  $ literalConst (emb γ) c
-lamExpr γ (Tick _ e)  = lamExpr γ e
-lamExpr γ (App e (Type _)) = lamExpr γ e
-lamExpr γ (App e1 e2) = case (lamExpr γ e1, lamExpr γ e2) of
-                              (Just p1, Just p2) | not (GM.isPredExpr e2) -- (isClassPred $ exprType e2)
-                                                 -> Just $ F.EApp p1 p2
-                              (Just p1, Just _ ) -> Just p1
-                              _  -> Nothing
-lamExpr γ (Let (NonRec x ex) e) = case (lamExpr γ ex, lamExpr γ e) of
-                                       (Just px, Just p) -> Just (p `F.subst1` (F.symbol x, px))
-                                       _  -> Nothing
-lamExpr γ (Lam x e)   = case lamExpr γ e of
-                            Just p -> Just $ F.ELam (F.symbol x, typeSort (emb γ) $ Ghc.expandTypeSynonyms $ varType x) p
-                            _ -> Nothing
-lamExpr _ _           = Nothing
-
---------------------------------------------------------------------------------
-(??=) :: (?callStack :: CallStack) => CGEnv -> Var -> CG SpecType
---------------------------------------------------------------------------------
-γ ??= x = case M.lookup x' (lcb γ) of
-            Just e  -> consE (γ -= x') e
-            Nothing -> refreshTy tx
-          where
-            x' = F.symbol x
-            tx = fromMaybe tt (γ ?= x')
-            tt = ofType $ varType x
-
-
---------------------------------------------------------------------------------
-varRefType :: (?callStack :: CallStack) => CGEnv -> Var -> CG SpecType
---------------------------------------------------------------------------------
-varRefType γ x = do
-  xt <- varRefType' γ x <$> (γ ??= x)
-  return xt -- F.tracepp (printf "varRefType x = [%s]" (showpp x))
-
-varRefType' :: CGEnv -> Var -> SpecType -> SpecType
-varRefType' γ x t'
-  | Just tys <- trec γ, Just tr  <- M.lookup x' tys
-  = strengthen tr xr
-  | otherwise
-  = strengthen t' xr
-  where
-    xr = singletonReft x
-    x' = F.symbol x
-    strengthen
-      | higherOrderFlag γ
-      = strengthenMeet
-      | otherwise
-      = strengthenTop
-
--- | create singleton types for function application
-makeSingleton :: CGEnv -> CoreExpr -> SpecType -> SpecType
-makeSingleton γ e t
-  | higherOrderFlag γ, App f x <- simplify e
-  = case (funExpr γ f, argForAllExpr x) of
-      (Just f', Just x')
-                 | not (GM.isPredExpr x) -- (isClassPred $ exprType x)
-                 -> strengthenMeet t (uTop $ F.exprReft (F.EApp f' x'))
-      (Just f', Just _)
-                 -> strengthenMeet t (uTop $ F.exprReft f')
-      _ -> t
-  | rankNTypes (getConfig γ)
-  = case argExpr γ (simplify e) of 
-       Just e' -> strengthenMeet t $ (uTop $ F.exprReft e')
-       _       -> t  
-  | otherwise
-  = t
-  where 
-    argForAllExpr (Var x)
-      | rankNTypes (getConfig γ)
-      , Just e <- M.lookup x (forallcb γ)
-      = Just e 
-    argForAllExpr e
-      = argExpr γ e
-
-
-
-funExpr :: CGEnv -> CoreExpr -> Maybe F.Expr
-
-funExpr _ (Var v) 
-  = Just $ F.EVar (F.symbol v)
-
-funExpr γ (App e1 e2)
-  = case (funExpr γ e1, argExpr γ e2) of
-      (Just e1', Just e2') | not (GM.isPredExpr e2) -- (isClassPred $ exprType e2)
-                           -> Just (F.EApp e1' e2')
-      (Just e1', Just _)
-                           -> Just e1'
-      _                    -> Nothing
-
-funExpr _ _
-  = Nothing
-
-simplify :: CoreExpr -> CoreExpr
-simplify (Tick _ e)       = simplify e
-simplify (App e (Type _)) = simplify e
-simplify (App e1 e2)      = App (simplify e1) (simplify e2)
-simplify (Lam x e) | isTyVar x = simplify e 
-simplify e                = e
-
-
-singletonReft :: (F.Symbolic a) => a -> UReft F.Reft
-singletonReft = uTop . F.symbolReft . F.symbol
-
--- | RJ: `nomeet` replaces `strengthenS` for `strengthen` in the definition
---   of `varRefType`. Why does `tests/neg/strata.hs` fail EVEN if I just replace
---   the `otherwise` case? The fq file holds no answers, both are sat.
-strengthenTop :: (PPrint r, F.Reftable r) => RType c tv r -> r -> RType c tv r
-strengthenTop (RApp c ts rs r) r'  = RApp c ts rs $ F.meet r r'
-strengthenTop (RVar a r) r'        = RVar a       $ F.meet r r'
-strengthenTop (RFun b t1 t2 r) r'  = RFun b t1 t2 $ F.meet r r'
-strengthenTop (RAppTy t1 t2 r) r'  = RAppTy t1 t2 $ F.meet r r'
-strengthenTop (RAllT a t r)    r'  = RAllT a t    $ F.meet r r'
-strengthenTop t _                  = t
-
--- TODO: this is almost identical to RT.strengthen! merge them!
-strengthenMeet :: (PPrint r, F.Reftable r) => RType c tv r -> r -> RType c tv r
-strengthenMeet (RApp c ts rs r) r'  = RApp c ts rs (r `F.meet` r')
-strengthenMeet (RVar a r) r'        = RVar a       (r `F.meet` r')
-strengthenMeet (RFun b t1 t2 r) r'  = RFun b t1 t2 (r `F.meet` r')
-strengthenMeet (RAppTy t1 t2 r) r'  = RAppTy t1 t2 (r `F.meet` r')
-strengthenMeet (RAllT a t r) r'     = RAllT a (strengthenMeet t r') (r `F.meet` r')
-strengthenMeet t _                  = t
-
--- topMeet :: (PPrint r, F.Reftable r) => r -> r -> r
--- topMeet r r' = r `F.meet` r'
-
---------------------------------------------------------------------------------
--- | Cleaner Signatures For Rec-bindings ---------------------------------------
---------------------------------------------------------------------------------
-exprLoc                         :: CoreExpr -> Maybe SrcSpan
-exprLoc (Tick tt _)             = Just $ GM.tickSrcSpan tt
-exprLoc (App e a) | isType a    = exprLoc e
-exprLoc _                       = Nothing
-
-isType :: Expr CoreBndr -> Bool
-isType (Type _)                 = True
-isType a                        = eqType (exprType a) predType
-
--- | @isGenericVar@ determines whether the @RTyVar@ has no class constraints
-isGenericVar :: RTyVar -> SpecType -> Bool
-isGenericVar α t =  all (\(c, α') -> (α'/=α) || isGenericClass c ) (classConstrs t)
-  where 
-    classConstrs t = [(c, ty_var_value α')
-                        | (c, ts) <- tyClasses t
-                        , t'      <- ts
-                        , α'      <- freeTyVars t']
-    isGenericClass c = className c `elem` [ordClassName, eqClassName] -- , functorClassName, monadClassName]
-
--- instance MonadFail CG where 
---  fail msg = panic Nothing msg
-
-instance MonadFail Data.Functor.Identity.Identity where 
-  fail msg = panic Nothing msg
diff --git a/src/Language/Haskell/Liquid/Constraint/Init.hs b/src/Language/Haskell/Liquid/Constraint/Init.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/Init.hs
+++ /dev/null
@@ -1,311 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables       #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE FlexibleContexts          #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE MultiParamTypeClasses     #-}
-{-# LANGUAGE OverloadedStrings         #-}
-
--- | This module defines the representation of Subtyping and WF Constraints,
---   and the code for syntax-directed constraint generation.
-
-module Language.Haskell.Liquid.Constraint.Init (
-    initEnv ,
-    initCGI,
-    ) where
-
-import           Prelude                                       hiding (error, undefined)
-import           Coercion
-import           DataCon
-import           CoreSyn
-import           Type
-import           TyCon
-import           Var
-import           Id                                           -- hiding (isExportedId)
-import           Name        hiding (varName)
-import           Control.Monad.State
-import           Data.Maybe                                    (isNothing, fromMaybe, catMaybes)
-import qualified Data.HashMap.Strict                           as M
-import qualified Data.HashSet                                  as S
-import qualified Data.List                                     as L
-import           Data.Bifunctor
-import qualified Language.Fixpoint.Types                       as F
-
-import qualified Language.Haskell.Liquid.UX.CTags              as Tg
-import           Language.Haskell.Liquid.Constraint.Fresh
-import           Language.Haskell.Liquid.Constraint.Env
-import           Language.Haskell.Liquid.WiredIn               (dictionaryVar)
-import qualified Language.Haskell.Liquid.GHC.SpanStack         as Sp
-import           Language.Haskell.Liquid.GHC.Misc             ( idDataConM, hasBaseTypeVar, isDataConId) -- dropModuleNames, simplesymbol)
-import           Language.Haskell.Liquid.Misc
-import           Language.Fixpoint.Misc
-import           Language.Haskell.Liquid.Constraint.Types
-
-import           Language.Haskell.Liquid.Types hiding (binds, Loc, loc, freeTyVars, Def)
-
---------------------------------------------------------------------------------
-initEnv :: TargetInfo -> CG CGEnv
---------------------------------------------------------------------------------
-initEnv info
-  = do let tce   = gsTcEmbeds (gsName sp)
-       let fVars = giImpVars (giSrc info)
-       let dcs   = filter isConLikeId (snd <$> gsFreeSyms (gsName sp))
-       let dcs'  = filter isConLikeId fVars
-       defaults <- forM fVars $ \x -> liftM (x,) (trueTy $ varType x)
-       dcsty    <- forM dcs   makeDataConTypes
-       dcsty'   <- forM dcs'  makeDataConTypes
-       (hs,f0)  <- refreshHoles $ grty info                           -- asserted refinements     (for defined vars)
-       f0''     <- refreshArgs' =<< grtyTop info                      -- default TOP reftype      (for exported vars without spec)
-       let f0'   = if notruetypes $ getConfig sp then [] else f0''
-       f1       <- refreshArgs'   defaults                            -- default TOP reftype      (for all vars)
-       f1'      <- refreshArgs' $ makeExactDc dcsty                   -- data constructors
-       f2       <- refreshArgs' $ assm info                           -- assumed refinements      (for imported vars)
-       f3'      <- refreshArgs' =<< recSelectorsTy info                      -- assumed refinements      (for record selectors)
-       f3       <- addPolyInfo' <$> (refreshArgs' $ vals gsAsmSigs (gsSig sp))                 -- assumed refinedments     (with `assume`)
-       f40      <- makeExactDc <$> (refreshArgs' $ vals gsCtors (gsData sp)) -- constructor refinements  (for measures)
-       f5       <- refreshArgs' $ vals gsInSigs (gsSig sp)                   -- internal refinements     (from Haskell measures)
-       fi       <- refreshArgs' $ catMaybes $ [(x,) . val <$> getMethodType mt | (x, mt) <- gsMethods $ gsSig $ giSpec info ]
-       (invs1, f41) <- mapSndM refreshArgs' $ makeAutoDecrDataCons dcsty  (gsAutosize (gsTerm sp)) dcs
-       (invs2, f42) <- mapSndM refreshArgs' $ makeAutoDecrDataCons dcsty' (gsAutosize (gsTerm sp)) dcs'
-       let f4    = mergeDataConTypes tce (mergeDataConTypes tce f40 (f41 ++ f42)) (filter (isDataConId . fst) f2)
-       let tx    = mapFst F.symbol . addRInv ialias . predsUnify sp
-       f6       <- (map tx . addPolyInfo') <$> (refreshArgs' $ vals gsRefSigs (gsSig sp))  
-       let bs    = (tx <$> ) <$> [f0 ++ f0' ++ fi, f1 ++ f1', f2, f3 ++ f3', f4, f5]
-       modify $ \s -> s { dataConTys = f4 }
-       lt1s     <- F.toListSEnv . cgLits <$> get
-       let lt2s  = [ (F.symbol x, rTypeSort tce t) | (x, t) <- f1' ]
-       let tcb   = mapSnd (rTypeSort tce) <$> concat bs
-       let cbs   = giCbs . giSrc $ info
-       rTrue   <- mapM (mapSndM true) f6 
-       let γ0    = measEnv sp (head bs) cbs tcb lt1s lt2s (f6 ++ bs!!3) (bs!!5) hs info
-       γ  <- globalize <$> foldM (+=) γ0 ( [("initEnv", x, y) | (x, y) <- concat $ (rTrue:tail bs)])
-       return γ {invs = is (invs1 ++ invs2)}
-  where
-    sp           = giSpec info
-    ialias       = mkRTyConIAl (gsIaliases (gsData sp))
-    vals f       = map (mapSnd val) . f
-    mapSndM f    = \(x,y) -> ((x,) <$> f y)
-    makeExactDc dcs = if exactDCFlag info then map strengthenDataConType dcs else dcs
-    is autoinv   = mkRTyConInv    (gsInvariants (gsData sp) ++ ((Nothing,) <$> autoinv))
-    addPolyInfo' = if reflection (getConfig info) then map (mapSnd addPolyInfo) else id 
-
-addPolyInfo :: SpecType -> SpecType
-addPolyInfo t = mkUnivs (go <$> as) ps t' 
-  where 
-    (as, ps, t') = bkUniv t 
-    pos          = tyVarsPosition t' 
-    go (a,r) = if {- ty_var_value a `elem` ppos pos && -}  ty_var_value a `notElem` pneg pos 
-               then (setRtvPol a False,r)  
-               else (a,r) 
-
-makeDataConTypes :: Var -> CG (Var, SpecType)
-makeDataConTypes x = (x,) <$> (trueTy $ varType x)
-
-makeAutoDecrDataCons :: [(Id, SpecType)] -> S.HashSet TyCon -> [Id] -> ([LocSpecType], [(Id, SpecType)])
-makeAutoDecrDataCons dcts specenv dcs
-  = (simplify invs, tys)
-  where
-    (invs, tys) = unzip $ concatMap go tycons
-    tycons      = L.nub $ catMaybes $ map idTyCon dcs
-
-    go tycon
-      | S.member tycon specenv =  zipWith (makeSizedDataCons dcts) (tyConDataCons tycon) [0..]
-    go _
-      = []
-
-    simplify invs = dummyLoc . (`strengthen` invariant) .  fmap (\_ -> mempty) <$> L.nub invs
-    invariant = MkUReft (F.Reft (F.vv_, F.PAtom F.Ge (lenOf F.vv_) (F.ECon $ F.I 0)) ) mempty
-
-idTyCon :: Id -> Maybe TyCon
-idTyCon = fmap dataConTyCon . idDataConM
-
-lenOf :: F.Symbol -> F.Expr
-lenOf x = F.mkEApp lenLocSymbol [F.EVar x]
-
-makeSizedDataCons :: [(Id, SpecType)] -> DataCon -> Integer -> (RSort, (Id, SpecType))
-makeSizedDataCons dcts x' n = (toRSort $ ty_res trep, (x, fromRTypeRep trep{ty_res = tres}))
-    where
-      x      = dataConWorkId x'
-      t      = fromMaybe (impossible Nothing "makeSizedDataCons: this should never happen") $ L.lookup x dcts
-      trep   = toRTypeRep t
-      tres   = ty_res trep `strengthen` MkUReft (F.Reft (F.vv_, F.PAtom F.Eq (lenOf F.vv_) computelen)) mempty
-
-      recarguments = filter (\(t,_) -> (toRSort t == toRSort tres)) (zip (ty_args trep) (ty_binds trep))
-      computelen   = foldr (F.EBin F.Plus) (F.ECon $ F.I n) (lenOf .  snd <$> recarguments)
-
-mergeDataConTypes ::  F.TCEmb TyCon -> [(Var, SpecType)] -> [(Var, SpecType)] -> [(Var, SpecType)]
-mergeDataConTypes tce xts yts = merge (L.sortBy f xts) (L.sortBy f yts)
-  where
-    f (x,_) (y,_) = compare x y
-    merge [] ys = ys
-    merge xs [] = xs
-    merge (xt@(x, tx):xs) (yt@(y, ty):ys)
-      | x == y    = (x, mXY x tx y ty) : merge xs ys
-      | x <  y    = xt : merge xs (yt : ys)
-      | otherwise = yt : merge (xt : xs) ys
-    mXY x tx y ty = meetVarTypes tce (F.pprint x) (getSrcSpan x, tx) (getSrcSpan y, ty)
-
-refreshArgs' :: [(a, SpecType)] -> CG [(a, SpecType)]
-refreshArgs' = mapM (mapSndM refreshArgs)
-
-
--- | TODO: All this *should* happen inside @Bare@ but appears
---   to happen after certain are signatures are @fresh@-ed,
---   which is why they are here.
-
--- NV : still some sigs do not get TyConInfo
-
-predsUnify :: TargetSpec -> (Var, RRType RReft) -> (Var, RRType RReft)
-predsUnify sp = second (addTyConInfo tce tyi) -- needed to eliminate some @RPropH@
-  where
-    tce            = gsTcEmbeds (gsName sp)
-    tyi            = gsTyconEnv (gsName sp)
-
-
---------------------------------------------------------------------------------
-measEnv :: TargetSpec
-        -> [(F.Symbol, SpecType)]
-        -> [CoreBind]
-        -> [(F.Symbol, F.Sort)]
-        -> [(F.Symbol, F.Sort)]
-        -> [(F.Symbol, F.Sort)]
-        -> [(F.Symbol, SpecType)]
-        -> [(F.Symbol, SpecType)]
-        -> [F.Symbol]
-        -> TargetInfo
-        -> CGEnv
---------------------------------------------------------------------------------
-measEnv sp xts cbs _tcb lt1s lt2s asms itys hs info = CGE
-  { cgLoc    = Sp.empty
-  , renv     = fromListREnv (second val <$> gsMeas (gsData sp)) []
-  , syenv    = F.fromListSEnv (gsFreeSyms (gsName sp))
-  , litEnv   = F.fromListSEnv lts
-  , constEnv = F.fromListSEnv lt2s
-  , fenv     = initFEnv $ filterHO (tcb' ++ lts ++ (second (rTypeSort tce . val) <$> gsMeas (gsData sp)))
-  , denv     = dmapty val $ gsDicts (gsSig sp)
-  , recs     = S.empty
-  , invs     = mempty
-  , rinvs    = mempty
-  , ial      = mkRTyConIAl (gsIaliases (gsData sp))
-  , grtys    = fromListREnv xts  []
-  , assms    = fromListREnv asms []
-  , intys    = fromListREnv itys []
-  , emb      = tce
-  , tgEnv    = Tg.makeTagEnv cbs
-  , tgKey    = Nothing
-  , trec     = Nothing
-  , lcb      = M.empty
-  , forallcb = M.empty
-  , holes    = fromListHEnv hs
-  , lcs      = mempty
-  , cerr     = Nothing
-  , cgInfo   = info
-  , cgVar    = Nothing
-  }
-  where
-      tce         = gsTcEmbeds (gsName sp)
-      filterHO xs = if higherOrderFlag sp then xs else filter (F.isFirstOrder . snd) xs
-      lts         = lt1s ++ lt2s
-      tcb'        = []
-
-
-assm :: TargetInfo -> [(Var, SpecType)]
-assm = assmGrty (giImpVars . giSrc)
-
-grty :: TargetInfo -> [(Var, SpecType)]
-grty = assmGrty (giDefVars . giSrc) 
-
-assmGrty :: (TargetInfo -> [Var]) -> TargetInfo -> [(Var, SpecType)]
-assmGrty f info = [ (x, val t) | (x, t) <- sigs, x `S.member` xs ]
-  where
-    xs          = S.fromList . f             $ info
-    sigs        = gsTySigs  . gsSig . giSpec $ info
-
-
-recSelectorsTy :: TargetInfo -> CG [(Var, SpecType)]
-recSelectorsTy info = forM topVs $ \v -> (v,) <$> trueTy (varType v)
-  where
-    topVs        = filter isTop $ giDefVars (giSrc info)
-    isTop v      = isExportedVar (giSrc info) v && not (v `S.member` sigVs) &&  isRecordSelector v
-    sigVs        = S.fromList [v | (v,_) <- gsTySigs sp ++ gsAsmSigs sp ++ gsRefSigs sp ++ gsInSigs sp]
-    sp           = gsSig . giSpec $ info
-    
-
-
-grtyTop :: TargetInfo -> CG [(Var, SpecType)]
-grtyTop info     = forM topVs $ \v -> (v,) <$> trueTy (varType v)
-  where
-    topVs        = filter isTop $ giDefVars (giSrc info)
-    isTop v      = isExportedVar (giSrc info) v && not (v `S.member` sigVs) && not (isRecordSelector v)
-    sigVs        = S.fromList [v | (v,_) <- gsTySigs sp ++ gsAsmSigs sp ++ gsRefSigs sp ++ gsInSigs sp]
-    sp           = gsSig . giSpec $ info
-
-
-infoLits :: (TargetSpec -> [(F.Symbol, LocSpecType)]) -> (F.Sort -> Bool) -> TargetInfo -> F.SEnv F.Sort
-infoLits litF selF info = F.fromListSEnv $ cbLits ++ measLits
-  where
-    cbLits    = filter (selF . snd) $ coreBindLits tce info
-    measLits  = filter (selF . snd) $ mkSort <$> litF spc
-    spc       = giSpec info
-    tce       = gsTcEmbeds (gsName spc)
-    mkSort    = mapSnd (F.sr_sort . rTypeSortedReft tce . val)
-
-initCGI :: Config -> TargetInfo -> CGInfo
-initCGI cfg info = CGInfo {
-    fEnv       = F.emptySEnv
-  , hsCs       = []
-  , hsWfs      = []
-  , fixCs      = []
-  , fixWfs     = []
-  , freshIndex = 0
-  , dataConTys = []
-  , binds      = F.emptyBindEnv
-  , ebinds     = []
-  , annotMap   = AI M.empty
-  , holesMap   = M.empty
-  , newTyEnv   = M.fromList (mapSnd val <$> gsNewTypes (gsSig spc))
-  , tyConInfo  = tyi
-  , tyConEmbed = tce
-  , kuts       = mempty
-  , kvPacks    = mempty
-  , cgLits     = infoLits (gsMeas . gsData) (const True) info
-  , cgConsts   = infoLits (gsMeas . gsData) notFn        info
-  , cgADTs     = gsADTs nspc
-  , termExprs  = M.fromList [(v, es) | (v, _, es) <- gsTexprs (gsSig spc) ]
-  , specDecr   = gsDecr  tspc
-  , specLVars  = gsLvars (gsVars spc)
-  , specLazy   = dictionaryVar `S.insert` (gsLazy tspc)
-  , specTmVars = gsNonStTerm tspc
-  , tcheck     = terminationCheck cfg
-  , pruneRefs  = pruneUnsorted cfg
-  , logErrors  = []
-  , kvProf     = emptyKVProf
-  , recCount   = 0
-  , bindSpans  = M.empty
-  , autoSize   = gsAutosize tspc
-  , allowHO    = higherOrderFlag cfg
-  , ghcI       = info
-  , unsorted   = F.notracepp "UNSORTED" $ F.makeTemplates $ gsUnsorted $ gsData spc
-  }
-  where
-    tce        = gsTcEmbeds nspc 
-    tspc       = gsTerm spc
-    spc        = giSpec info
-    tyi        = gsTyconEnv nspc
-    nspc       = gsName spc
-    notFn      = isNothing . F.functionSort
-
-coreBindLits :: F.TCEmb TyCon -> TargetInfo -> [(F.Symbol, F.Sort)]
-coreBindLits tce info
-  = sortNub      $ [ (F.symbol x, F.strSort) | (_, Just (F.ESym x)) <- lconsts ]    -- strings
-                ++ [ (dconToSym dc, dconToSort dc) | dc <- dcons ]                  -- data constructors
-  where
-    src         = giSrc info
-    lconsts      = literalConst tce <$> literals (giCbs src)
-    dcons        = filter isDCon freeVs
-    freeVs       = giImpVars src ++ freeSyms
-    freeSyms     = fmap snd . gsFreeSyms . gsName . giSpec $ info
-    dconToSort   = typeSort tce . expandTypeSynonyms . varType
-    dconToSym    = F.symbol . idDataCon
-    isDCon x     = isDataConId x && not (hasBaseTypeVar x)
diff --git a/src/Language/Haskell/Liquid/Constraint/Monad.hs b/src/Language/Haskell/Liquid/Constraint/Monad.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/Monad.hs
+++ /dev/null
@@ -1,150 +0,0 @@
--- | This module contains various functions that add/update in the CG monad.
-
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE BangPatterns              #-}
-{-# LANGUAGE PatternGuards             #-}
-{-# LANGUAGE OverloadedStrings         #-}
-{-# LANGUAGE ImplicitParams            #-}
-{-# LANGUAGE FlexibleContexts          #-}
-
-module Language.Haskell.Liquid.Constraint.Monad  where
-
-import           Var
-import           Name (getSrcSpan)
-import           SrcLoc
-import           Outputable hiding (showPpr, panic, (<>), showSDoc, text)
-
-import qualified TyCon as TC
-
-import qualified Data.HashMap.Strict as M
-import qualified Data.Text           as T
-
-import           Control.Monad
-import           Control.Monad.State (get, modify)
-import           Language.Haskell.Liquid.Types hiding (loc)
-import           Language.Haskell.Liquid.Constraint.Types
-import           Language.Haskell.Liquid.Constraint.Env
-import           Language.Fixpoint.Misc hiding (errorstar)
-import           Language.Haskell.Liquid.GHC.Misc -- (concatMapM)
-import           Language.Haskell.Liquid.GHC.SpanStack (srcSpan)
-
---------------------------------------------------------------------------------
--- | `addC` adds a subtyping constraint into the global pool.
---------------------------------------------------------------------------------
-addC :: SubC -> String -> CG ()
---------------------------------------------------------------------------------
-addC c@(SubC γ t1 t2) _msg
-  | toType t1 /= toType t2
-  = panic (Just $ getLocation γ) $ "addC: malformed constraint:\n" ++ _msg ++ showpp t1 ++ "\n <: \n" ++ showpp t2 
-  | otherwise
-  = modify $ \s -> s { hsCs  = c : (hsCs s) }
- 
-
-addC c _msg
-  = modify $ \s -> s { hsCs  = c : hsCs s }
-
---------------------------------------------------------------------------------
--- | addPost: RJ: what DOES this function do?
---------------------------------------------------------------------------------
-addPost :: CGEnv -> SpecType -> CG SpecType
---------------------------------------------------------------------------------
-addPost γ (RRTy e r OInv t)
-  = do γ' <- foldM (\γ (x, t) -> γ `addSEnv` ("addPost", x,t)) γ e
-       addC (SubR γ' OInv r) "precondition-oinv" >> return t
-
-addPost γ (RRTy e r OTerm t)
-  = do γ' <- foldM (\γ (x, t) -> γ += ("addPost", x, t)) γ e
-       addC (SubR γ' OTerm r) "precondition-oterm" >> return t
-
-addPost γ (RRTy cts _ OCons t)
-  = do γ' <- foldM (\γ (x, t) -> γ `addSEnv` ("splitS", x,t)) γ xts
-       addC (SubC  γ' t1 t2)  "precondition-ocons"
-       addPost γ t
-  where
-    (xts, t1, t2) = envToSub cts
-addPost _ t 
-  = return t 
-
---------------------------------------------------------------------------------
--- | Add Well formedness Constraint
---------------------------------------------------------------------------------
-addW   :: WfC -> CG ()
---------------------------------------------------------------------------------
-addW !w = modify $ \s -> s { hsWfs = w : (hsWfs s) }
-
---------------------------------------------------------------------------------
--- | Add a warning
---------------------------------------------------------------------------------
-addWarning   :: Error -> CG ()
---------------------------------------------------------------------------------
-addWarning w = modify $ \s -> s { logErrors = w : logErrors s }
-
--- | Add Identifier Annotations, used for annotation binders (i.e. at binder sites)
-addIdA            :: Var -> Annot SpecType -> CG ()
-addIdA !x !t      = modify $ \s -> s { annotMap = upd $ annotMap s }
-  where
-    l             = getSrcSpan x
-    upd m@(AI _)  = if boundRecVar l m then m else addA l (Just x) t m
-
-boundRecVar :: SrcSpan -> AnnInfo (Annot a) -> Bool
-boundRecVar l (AI m) = not $ null [t | (_, AnnRDf t) <- M.lookupDefault [] l m]
-
-
--- | Used for annotating reads (i.e. at Var x sites)
-
-addLocA :: Maybe Var -> SrcSpan -> Annot SpecType -> CG ()
-addLocA !xo !l !t
-  = modify $ \s -> s { annotMap = addA l xo t $ annotMap s }
-
-
--- | Used for annotating holes 
-
-addHole :: Var -> SpecType -> CGEnv -> CG () 
-addHole x t γ 
-  | typedHoles (getConfig γ) = 
-      do  st <- get 
-          modify $ \s -> s {holesMap = M.insert x (hinfo (st, γ)) $ holesMap s}
-          -- addWarning $ ErrHole loc ("hole found") (reGlobal env <> reLocal env) x' t 
-  | otherwise = return ()
-    where 
-      hinfo = HoleInfo t loc env
-      loc   = srcSpan $ cgLoc γ
-      env   = mconcat [renv γ, grtys γ, assms γ, intys γ]
-
---------------------------------------------------------------------------------
--- | Update annotations for a location, due to (ghost) predicate applications
---------------------------------------------------------------------------------
-updateLocA :: Maybe SrcSpan -> SpecType -> CG ()
---------------------------------------------------------------------------------
-updateLocA (Just l) t = addLocA Nothing l (AnnUse t)
-updateLocA _        _ = return ()
---------------------------------------------------------------------------------
-
---------------------------------------------------------------------------------
-addA :: (Outputable a) => SrcSpan -> Maybe a -> b -> AnnInfo b -> AnnInfo b
---------------------------------------------------------------------------------
-addA !l xo@(Just _) !t (AI m)
-  | isGoodSrcSpan l
-  = AI $ inserts l (T.pack . showPpr <$> xo, t) m
-addA !l xo@Nothing  !t (AI m)
-  | l `M.member` m                  -- only spans known to be variables
-  = AI $ inserts l (T.pack . showPpr <$> xo, t) m
-addA _ _ _ !a
-  = a
-
-
-lookupNewType :: TC.TyCon -> CG (Maybe SpecType)
-lookupNewType tc
-  = M.lookup tc . newTyEnv <$> get
-
-
---------------------------------------------------------------------------------
-{-@ envToSub :: {v:[(a, b)] | 2 <= len v} -> ([(a, b)], b, b) @-}
-envToSub :: [(a, b)] -> ([(a, b)], b, b)
---------------------------------------------------------------------------------
-envToSub = go []
-  where
-    go _   []              = impossible Nothing "This cannot happen: envToSub on 0 elems"
-    go _   [(_,_)]         = impossible Nothing "This cannot happen: envToSub on 1 elem"
-    go ack [(_,l), (_, r)] = (reverse ack, l, r)
-    go ack (x:xs)          = go (x:ack) xs
diff --git a/src/Language/Haskell/Liquid/Constraint/Qualifier.hs b/src/Language/Haskell/Liquid/Constraint/Qualifier.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/Qualifier.hs
+++ /dev/null
@@ -1,244 +0,0 @@
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE ViewPatterns          #-}
-{-# LANGUAGE PartialTypeSignatures #-}
-{-# LANGUAGE FlexibleContexts      #-}
-
-
-module Language.Haskell.Liquid.Constraint.Qualifier
-  ( giQuals 
-  , useSpcQuals
-  )
-  where
-
-import           Prelude hiding (error)
-import           Data.List                (delete, nub)
-import           Data.Maybe               (isJust, catMaybes, fromMaybe, isNothing)
-import qualified Data.HashSet        as S
-import qualified Data.HashMap.Strict as M
-import           Debug.Trace (trace)
-import           TyCon
-import           Var (Var)
-import           Language.Fixpoint.Types                  hiding (panic, mkQual)
-import qualified Language.Fixpoint.Types.Config as FC
-import           Language.Fixpoint.SortCheck
-import           Language.Haskell.Liquid.Types.RefType
-import           Language.Haskell.Liquid.GHC.Misc         (getSourcePos)
-import           Language.Haskell.Liquid.Misc             (condNull)
-import           Language.Haskell.Liquid.Types.PredType
-
-import           Language.Haskell.Liquid.Types
-
-
---------------------------------------------------------------------------------
-giQuals :: TargetInfo -> SEnv Sort -> [Qualifier]
---------------------------------------------------------------------------------
-giQuals info lEnv
-  =  notracepp ("GI-QUALS: " ++ showpp lEnv)
-  $  condNull (useSpcQuals info) (gsQualifiers . gsQual . giSpec $ info)
-  ++ condNull (useSigQuals info) (sigQualifiers  info lEnv)
-  ++ condNull (useAlsQuals info) (alsQualifiers  info lEnv)
-
--- --------------------------------------------------------------------------------
--- qualifiers :: GhcInfo -> SEnv Sort -> [Qualifier]
--- --------------------------------------------------------------------------------
--- qualifiers info env = spcQs ++ genQs
-  -- where
-    -- spcQs           = gsQualifiers spc
-    -- genQs           = specificationQualifiers info env
-    -- n               = maxParams (getConfig spc)
-    -- spc             = spec info
-
-maxQualParams :: (HasConfig t) => t -> Int
-maxQualParams = maxParams . getConfig
-
--- | Use explicitly given qualifiers .spec or source (.hs, .lhs) files
-useSpcQuals :: (HasConfig t) => t -> Bool
-useSpcQuals i = useQuals i && not (useAlsQuals i)
-
--- | Scrape qualifiers from function signatures (incr :: x:Int -> {v:Int | v > x})
-useSigQuals :: (HasConfig t) => t -> Bool
-useSigQuals i = useQuals i && not (useAlsQuals i)
-
--- | Scrape qualifiers from refinement type aliases (type Nat = {v:Int | 0 <= 0})
-useAlsQuals :: (HasConfig t) => t -> Bool
-useAlsQuals i = useQuals i && i `hasOpt` higherOrderFlag && not (needQuals i)
-
-useQuals :: (HasConfig t) => t -> Bool
-useQuals = not . (FC.All == ) . eliminate . getConfig
-
-needQuals :: (HasConfig t) => t -> Bool
-needQuals = (FC.None == ) . eliminate . getConfig
-
---------------------------------------------------------------------------------
-alsQualifiers :: TargetInfo -> SEnv Sort -> [Qualifier]
---------------------------------------------------------------------------------
-alsQualifiers info lEnv
-  = [ q | a <- gsRTAliases . gsQual . giSpec $ info
-        , q <- refTypeQuals lEnv (loc a) tce (rtBody (val a))
-        , length (qParams q) <= k + 1
-        , validQual lEnv q
-    ]
-    where
-      k   = maxQualParams info
-      tce = gsTcEmbeds . gsName . giSpec $ info
-
-validQual :: SEnv Sort -> Qualifier -> Bool
-validQual lEnv q = isJust $ checkSortExpr (srcSpan q) env (qBody q)
-  where
-    env          = unionSEnv lEnv qEnv
-    qEnv         = M.fromList (qualBinds q)
-
-
---------------------------------------------------------------------------------
-sigQualifiers :: TargetInfo -> SEnv Sort -> [Qualifier]
---------------------------------------------------------------------------------
-sigQualifiers info lEnv
-  = [ q | (x, t) <- specBinders info
-        , x `S.member` qbs
-        , q <- refTypeQuals lEnv (getSourcePos x) tce (val t)
-        -- NOTE: large qualifiers are VERY expensive, so we only mine
-        -- qualifiers up to a given size, controlled with --max-params
-        , length (qParams q) <= k + 1
-    ]
-    where
-      k   = maxQualParams info
-      tce = gsTcEmbeds . gsName . giSpec $ info
-      qbs = qualifyingBinders info
-
-qualifyingBinders :: TargetInfo -> S.HashSet Var
-qualifyingBinders info = S.difference sTake sDrop
-  where
-    sTake              = S.fromList $ giDefVars src ++ giUseVars src ++ scrapeVars cfg src 
-    sDrop              = S.fromList $ specAxiomVars info
-    cfg                = getConfig info 
-    src                = giSrc     info 
-    
--- NOTE: this mines extra, useful qualifiers but causes
--- a significant increase in running time, so we hide it
--- behind `--scrape-imports` and `--scrape-used-imports`
-scrapeVars :: Config -> TargetSrc -> [Var]
-scrapeVars cfg src 
-  | cfg `hasOpt` scrapeUsedImports = giUseVars src 
-  | cfg `hasOpt` scrapeImports     = giImpVars src 
-  | otherwise                      = []
-
-specBinders :: TargetInfo -> [(Var, LocSpecType)]
-specBinders info = mconcat
-  [ gsTySigs  (gsSig  sp)
-  , gsAsmSigs (gsSig  sp)
-  , gsRefSigs (gsSig  sp)
-  , gsCtors   (gsData sp)
-  , if info `hasOpt` scrapeInternals then gsInSigs (gsSig sp) else []
-  ]
-  where
-    sp  = giSpec info
-
-specAxiomVars :: TargetInfo -> [Var]
-specAxiomVars =  gsReflects . gsRefl . giSpec
-
--- GRAVEYARD: scraping quals from imports kills the system with too much crap
--- specificationQualifiers info = {- filter okQual -} qs
---   where
---     qs                       = concatMap refTypeQualifiers ts
---     refTypeQualifiers        = refTypeQuals $ tcEmbeds spc
---     ts                       = val <$> t1s ++ t2s
---     t1s                      = [t | (x, t) <- tySigs spc, x `S.member` definedVars]
---     t2s                      = [] -- [t | (_, t) <- ctor spc                            ]
---     definedVars              = S.fromList $ defVars info
---     spc                      = spec info
---
--- okQual                       = not . any isPred . map snd . q_params
---   where
---     isPred (FApp tc _)       = tc == stringFTycon "Pred"
---     isPred _                 = False
-
-
--- TODO: rewrite using foldReft'
---------------------------------------------------------------------------------
-refTypeQuals :: SEnv Sort -> SourcePos -> TCEmb TyCon -> SpecType -> [Qualifier]
---------------------------------------------------------------------------------
-refTypeQuals lEnv l tce t0    = go emptySEnv t0
-  where
-    scrape                    = refTopQuals lEnv l tce t0
-    add x t γ                 = insertSEnv x (rTypeSort tce t) γ
-    goBind x t γ t'           = go (add x t γ) t'
-    go γ t@(RVar _ _)         = scrape γ t
-    go γ (RAllT _ t _)        = go γ t
-    go γ (RAllP p t)          = go (insertSEnv (pname p) (rTypeSort tce $ (pvarRType p :: RSort)) γ) t
-    go γ t@(RAppTy t1 t2 _)   = go γ t1 ++ go γ t2 ++ scrape γ t
-    go γ (RFun x t t' _)      = go γ t ++ goBind x t γ t'
-    go γ t@(RApp c ts rs _)   = scrape γ t ++ concatMap (go γ') ts ++ goRefs c γ' rs
-                                where γ' = add (rTypeValueVar t) t γ
-    go γ (RAllE x t t')       = go γ t ++ goBind x t γ t'
-    go γ (REx x t t')         = go γ t ++ goBind x t γ t'
-    go _ _                    = []
-    goRefs c g rs             = concat $ zipWith (goRef g) rs (rTyConPVs c)
-    goRef _ (RProp _ (RHole _)) _ = []
-    goRef g (RProp s t)  _    = go (insertsSEnv g s) t
-    insertsSEnv               = foldr (\(x, t) γ -> insertSEnv x (rTypeSort tce t) γ)
-
-
-refTopQuals :: (PPrint t, Reftable t, SubsTy RTyVar RSort t, Reftable (RTProp RTyCon RTyVar (UReft t)))
-            => SEnv Sort
-            -> SourcePos
-            -> TCEmb TyCon
-            -> RType RTyCon RTyVar r
-            -> SEnv Sort
-            -> RRType (UReft t)
-            -> [Qualifier]
-refTopQuals lEnv l tce t0 γ t
-  = [ mkQ v so pa  | let (RR so (Reft (v, ra))) = rTypeSortedReft tce t
-                   , pa                        <- conjuncts ra
-                   , not $ isHole    pa
-                   , not $ isGradual pa
-                   , notracepp ("refTopQuals: " ++ showpp pa) 
-                     $ isNothing $ checkSorted (srcSpan l) (insertSEnv v so γ') pa
-    ]
-    ++
-    [ mkP s e | let (MkUReft _ (Pr ps)) = fromMaybe (msg t) $ stripRTypeBase t
-              , p                      <- findPVar (ty_preds $ toRTypeRep t0) <$> ps
-              , (s, _, e)              <- pargs p
-    ]
-    where
-      mkQ   = mkQual  lEnv l     t0 γ
-      mkP   = mkPQual lEnv l tce t0 γ
-      msg t = panic Nothing $ "Qualifier.refTopQuals: no typebase" ++ showpp t
-      γ'    = unionSEnv' γ lEnv
-
-mkPQual :: (PPrint r, Reftable r, SubsTy RTyVar RSort r, Reftable (RTProp RTyCon RTyVar r))
-        => SEnv Sort
-        -> SourcePos
-        -> TCEmb TyCon
-        -> t
-        -> SEnv Sort
-        -> RRType r
-        -> Expr
-        -> Qualifier
-mkPQual lEnv l tce t0 γ t e = mkQual lEnv l t0 γ' v so pa
-  where
-    v                      = "vv"
-    so                     = rTypeSort tce t
-    γ'                     = insertSEnv v so γ
-    pa                     = PAtom Eq (EVar v) e
-
-mkQual :: SEnv Sort
-       -> SourcePos
-       -> t
-       -> SEnv Sort
-       -> Symbol
-       -> Sort
-       -> Expr
-       -> Qualifier
-mkQual lEnv l _ γ v so p   = mkQ "Auto" ((v, so) : xts) p l
-  where
-    xs   = delete v $ nub $ syms p
-    xts  = catMaybes $ zipWith (envSort l lEnv γ) xs [0..]
-
-envSort :: SourcePos -> SEnv Sort -> SEnv Sort -> Symbol -> Integer -> Maybe (Symbol, Sort)
-envSort l lEnv tEnv x i
-  | Just t <- lookupSEnv x tEnv = Just (x, t)
-  | Just _ <- lookupSEnv x lEnv = Nothing
-  | otherwise                   = Just (x, ai)
-  where
-    ai             = trace msg $ fObj $ Loc l l $ tempSymbol "LHTV" i
-    msg            = "Unknown symbol in qualifier: " ++ show x
diff --git a/src/Language/Haskell/Liquid/Constraint/Split.hs b/src/Language/Haskell/Liquid/Constraint/Split.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/Split.hs
+++ /dev/null
@@ -1,446 +0,0 @@
-{-# LANGUAGE ImplicitParams        #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PartialTypeSignatures #-}
-{-# LANGUAGE FlexibleContexts      #-}
-
---------------------------------------------------------------------------------
--- | Constraint Splitting ------------------------------------------------------
---------------------------------------------------------------------------------
-
-module Language.Haskell.Liquid.Constraint.Split (
-
-  -- * Split Subtyping Constraints
-    splitC
-
-  -- * Split Well-formedness Constraints
-  , splitW
-
-  -- * ???
-  , envToSub
-
-  -- * Panic
-  , panicUnbound
-  ) where
-
-import           Prelude hiding (error)
-
-
-
-import           Text.PrettyPrint.HughesPJ hiding (first, parens)
-
-import           Data.Maybe          (fromMaybe) 
-import           Control.Monad
-import           Control.Monad.State (get)
-import qualified Control.Exception as Ex
-
-import qualified Language.Fixpoint.Types            as F
-import           Language.Fixpoint.Misc hiding (errorstar)
-import           Language.Fixpoint.SortCheck (pruneUnsortedReft)
-
-import           Language.Haskell.Liquid.Misc -- (concatMapM)
-import qualified Language.Haskell.Liquid.UX.CTags       as Tg
-import           Language.Haskell.Liquid.Types hiding (loc)
-
-
-import           Language.Haskell.Liquid.Constraint.Types
-import           Language.Haskell.Liquid.Constraint.Env
-import           Language.Haskell.Liquid.Constraint.Constraint
-import           Language.Haskell.Liquid.Constraint.Monad (envToSub)
-
---------------------------------------------------------------------------------
-splitW ::  WfC -> CG [FixWfC]
---------------------------------------------------------------------------------
-splitW (WfC γ t@(RFun x t1 t2 _))
-  =  do ws'  <- splitW (WfC γ t1)
-        γ'   <- γ += ("splitW", x, t1)
-        ws   <- bsplitW γ t
-        ws'' <- splitW (WfC γ' t2)
-        return $ ws ++ ws' ++ ws''
-
-splitW (WfC γ t@(RImpF x t1 t2 _))
-  =  do ws'  <- splitW (WfC γ t1)
-        γ'   <- γ += ("splitW", x, t1)
-        ws   <- bsplitW γ t
-        ws'' <- splitW (WfC γ' t2)
-        return $ ws ++ ws' ++ ws''
-
-
-splitW (WfC γ t@(RAppTy t1 t2 _))
-  =  do ws   <- bsplitW γ t
-        ws'  <- splitW (WfC γ t1)
-        ws'' <- splitW (WfC γ t2)
-        return $ ws ++ ws' ++ ws''
-
-splitW (WfC γ t'@(RAllT a t _))
-  = do γ'  <- updateEnv γ a
-       ws  <- bsplitW γ t'
-       ws' <- splitW (WfC γ' t)
-       return $ ws ++ ws'
-
-splitW (WfC γ (RAllP _ r))
-  = splitW (WfC γ r)
-
-splitW (WfC γ t@(RVar _ _))
-  = bsplitW γ t
-
-splitW (WfC γ t@(RApp _ ts rs _))
-  =  do ws    <- bsplitW γ t
-        γ'    <- if bscope (getConfig γ) then γ `extendEnvWithVV` t else return γ
-        ws'   <- concat <$> mapM (splitW . WfC γ') ts
-        ws''  <- concat <$> mapM (rsplitW γ)       rs
-        return $ ws ++ ws' ++ ws''
-
-splitW (WfC γ (RAllE x tx t))
-  = do  ws  <- splitW (WfC γ tx)
-        γ'  <- γ += ("splitW1", x, tx)
-        ws' <- splitW (WfC γ' t)
-        return $ ws ++ ws'
-
-splitW (WfC γ (REx x tx t))
-  = do  ws  <- splitW (WfC γ tx)
-        γ'  <- γ += ("splitW2", x, tx)
-        ws' <- splitW (WfC γ' t)
-        return $ ws ++ ws'
-
-splitW (WfC γ (RRTy _ _ _ t))
-  = splitW (WfC γ t) 
-
-splitW (WfC _ t)
-  = panic Nothing $ "splitW cannot handle: " ++ showpp t
-
-rsplitW :: CGEnv
-        -> Ref RSort SpecType
-        -> CG [FixWfC]
-rsplitW _ (RProp _ (RHole _)) =
-  panic Nothing "Constrains: rsplitW for RProp _ (RHole _)"
-
-rsplitW γ (RProp ss t0) = do
-  γ' <- foldM (+=) γ [("rsplitW", x, ofRSort s) | (x, s) <- ss]
-  splitW $ WfC γ' t0
-
-
-bsplitW :: CGEnv -> SpecType -> CG [FixWfC]
-bsplitW γ t =
-  do temp  <- getTemplates
-     isHO  <- allowHO   <$> get
-     return $ bsplitW' γ t temp isHO
-
-bsplitW' :: (PPrint r, F.Reftable r, SubsTy RTyVar RSort r, F.Reftable (RTProp RTyCon RTyVar r))
-         => CGEnv -> RRType r -> F.Templates -> Bool -> [F.WfC Cinfo]
-bsplitW' γ t temp isHO
-  | isHO || F.isNonTrivial r'
-  = F.wfC (feBinds $ fenv γ) r' ci
-  | otherwise
-  = []
-  where
-    r'                = rTypeSortedReft' γ temp t
-    ci                = Ci (getLocation γ) Nothing (cgVar γ)
-
-splitfWithVariance :: Applicative f
-                   => (t -> t -> f [a]) -> t -> t -> Variance -> f [a]
-splitfWithVariance f t1 t2 Invariant     = (++) <$> f t1 t2 <*> f t2 t1
-splitfWithVariance f t1 t2 Bivariant     = (++) <$> f t1 t2 <*> f t2 t1
-splitfWithVariance f t1 t2 Covariant     = f t1 t2
-splitfWithVariance f t1 t2 Contravariant = f t2 t1
-
-updateEnv :: CGEnv -> RTVar RTyVar (RType RTyCon RTyVar b0) -> CG CGEnv
-updateEnv γ a
-  | Just (x, s) <- rTVarToBind a
-  = γ += ("splitS RAllT", x, fmap (const mempty) s)
-  | otherwise
-  = return γ
-
-------------------------------------------------------------
-splitC :: SubC -> CG [FixSubC]
-------------------------------------------------------------
-
-splitC (SubC γ (REx x tx t1) (REx x2 _ t2)) | x == x2
-  = do γ' <- γ += ("addExBind 0", x, forallExprRefType γ tx)
-       splitC (SubC γ' t1 t2)
-
-splitC (SubC γ t1 (REx x tx t2))
-  = do y <- fresh
-       γ' <- γ += ("addExBind 1", y, forallExprRefType γ tx)
-       splitC (SubC γ' t1 (F.subst1 t2 (x, F.EVar y)))
-
--- existential at the left hand side is treated like forall
-splitC (SubC γ (REx x tx t1) t2)
-  = do -- let tx' = traceShow ("splitC: " ++ showpp z) tx
-       y <- fresh
-       γ' <- γ += ("addExBind 2", y, forallExprRefType γ tx)
-       splitC (SubC γ' (F.subst1 t1 (x, F.EVar y)) t2)
-
-splitC (SubC γ (RAllE x tx t1) (RAllE x2 _ t2)) | x == x2
-  = do γ' <- γ += ("addAllBind 3", x, forallExprRefType γ tx)
-       splitC (SubC γ' t1 t2)
-
-splitC (SubC γ (RAllE x tx t1) t2)
-  = do y  <- fresh
-       γ' <- γ += ("addAABind 1", y, forallExprRefType γ tx)
-       splitC (SubC γ' (t1 `F.subst1` (x, F.EVar y)) t2)
-
-splitC (SubC γ t1 (RAllE x tx t2))
-  = do y  <- fresh
-       γ' <- γ += ("addAllBind 2", y, forallExprRefType γ tx)
-       splitC (SubC γ' t1 (F.subst1 t2 (x, F.EVar y)))
-
-splitC (SubC γ (RRTy env _ OCons t1) t2)
-  = do γ' <- foldM (\γ (x, t) -> γ `addSEnv` ("splitS", x,t)) γ xts
-       c1 <- splitC (SubC γ' t1' t2')
-       c2 <- splitC (SubC γ  t1  t2 )
-       return $ c1 ++ c2
-  where
-    (xts, t1', t2') = envToSub env
-
-splitC (SubC γ (RRTy e r o t1) t2)
-  = do γ' <- foldM (\γ (x, t) -> γ `addSEnv` ("splitS", x,t)) γ e
-       c1 <- splitC (SubR γ' o  r)
-       c2 <- splitC (SubC γ t1 t2)
-       return $ c1 ++ c2
-
-splitC (SubC γ (RFun x1 t1 t1' r1) (RFun x2 t2 t2' r2))
-  =  do cs'      <- splitC  (SubC γ t2 t1)
-        γ'       <- γ+= ("splitC", x2, t2)
-        cs       <- bsplitC γ (RFun x1 t1 t1' (r1 `F.subst1` (x1, F.EVar x2)))
-                              (RFun x2 t2 t2'  r2)
-        let t1x2' = t1' `F.subst1` (x1, F.EVar x2)
-        cs''     <- splitC  (SubC γ' t1x2' t2')
-        return    $ cs ++ cs' ++ cs''
-
-splitC (SubC γ (RImpF x1 t1 t1' r1) (RImpF x2 t2 t2' r2))
-  =  do cs'      <- splitC  (SubC γ t2 t1)
-        γ'       <- γ+= ("splitC", x2, t2)
-        cs       <- bsplitC γ (RImpF x1 t1 t1' (r1 `F.subst1` (x1, F.EVar x2)))
-                              (RImpF x2 t2 t2'  r2)
-        let t1x2' = t1' `F.subst1` (x1, F.EVar x2)
-        cs''     <- splitC  (SubC γ' t1x2' t2')
-        return    $ cs ++ cs' ++ cs''
-
-
-splitC (SubC γ t1@(RAppTy r1 r1' _) t2@(RAppTy r2 r2' _))
-  =  do cs    <- bsplitC γ t1 t2
-        cs'   <- splitC  (SubC γ r1 r2)
-        cs''  <- splitC  (SubC γ r1' r2')
-        cs''' <- splitC  (SubC γ r2' r1')
-        return $ cs ++ cs' ++ cs'' ++ cs'''
-
-splitC (SubC γ t1 (RAllP p t))
-  = splitC $ SubC γ t1 t'
-  where
-    t' = fmap (replacePredsWithRefs su) t
-    su = (uPVar p, pVartoRConc p)
-
-splitC (SubC γ t1@(RAllP _ _) t2)
-  = panic (Just $ getLocation γ) $ "Predicate in lhs of constraint:" ++ showpp t1 ++ "\n<:\n" ++ showpp t2
-
-splitC (SubC γ t1'@(RAllT α1 t1 _) t2'@(RAllT α2 t2 _))
-  |  α1 ==  α2
-  = do γ'  <- updateEnv γ α2
-       cs  <- bsplitC γ t1' t2'
-       cs' <- splitC $ SubC γ' t1 (F.subst su t2)
-       return (cs ++ cs')
-  | otherwise
-  = do γ'  <- updateEnv γ α2
-       cs  <- bsplitC γ t1' t2'
-       cs' <- splitC $ SubC γ' t1 (F.subst su t2'')
-       return (cs ++ cs')
-  where
-    t2'' = subsTyVar_meet' (ty_var_value α2, RVar (ty_var_value α1) mempty) t2
-    su = case (rTVarToBind α1, rTVarToBind α2) of
-          (Just (x1, _), Just (x2, _)) -> F.mkSubst [(x1, F.EVar x2)]
-          _                            -> F.mkSubst []
-
-splitC (SubC _ (RApp c1 _ _ _) (RApp c2 _ _ _)) | isClass c1 && c1 == c2
-  = return []
-
-splitC (SubC γ t1@(RApp _ _ _ _) t2@(RApp _ _ _ _))
-  = do (t1',t2') <- unifyVV t1 t2
-       cs    <- bsplitC γ t1' t2'
-       γ'    <- if (bscope (getConfig γ)) then γ `extendEnvWithVV` t1' else return γ
-       let RApp c t1s r1s _ = t1'
-       let RApp _ t2s r2s _ = t2'
-       let isapplied = True -- TC.tyConArity (rtc_tc c) == length t1s
-       let tyInfo = rtc_info c
-       csvar  <-  splitsCWithVariance           γ' t1s t2s $ varianceTyArgs tyInfo
-       csvar' <- rsplitsCWithVariance isapplied γ' r1s r2s $ variancePsArgs tyInfo
-       return $ cs ++ csvar ++ csvar'
-
-splitC (SubC γ t1@(RVar a1 _) t2@(RVar a2 _))
-  | a1 == a2
-  = bsplitC γ t1 t2
-
-splitC (SubC γ t1 t2)
-  = panic (Just $ getLocation γ) $ "(Another Broken Test!!!) splitc unexpected:\n" ++ traceTy t1 ++ "\n  <:\n" ++ traceTy t2
-
-splitC (SubR γ o r)
-  = do ts     <- getTemplates
-       let r1' = pruneUnsortedReft γ'' ts r1
-       return $ F.subC γ' r1' r2 Nothing tag ci
-  where
-    γ'' = feEnv $ fenv γ
-    γ'  = feBinds $ fenv γ
-    r1  = F.RR F.boolSort rr
-    r2  = F.RR F.boolSort $ F.Reft (vv, F.EVar vv)
-    vv  = "vvRec"
-    ci  = Ci src err (cgVar γ)
-    err = Just $ ErrAssType src o (text $ show o ++ "type error") g (rHole rr)
-    rr  = F.toReft r
-    tag = getTag γ
-    src = getLocation γ
-    g   = reLocal $ renv γ
-
-traceTy :: SpecType -> String 
-traceTy (RVar v _)      = parens ("RVar " ++ showpp v)
-traceTy (RApp c ts _ _) = parens ("RApp " ++ showpp c ++ unwords (traceTy <$> ts)) 
-traceTy (RAllP _ t)     = parens ("RAllP " ++ traceTy t)
-traceTy (RAllT _ t _)   = parens ("RAllT " ++ traceTy t)
-traceTy (RImpF _ t t' _) = parens ("RImpF " ++ parens (traceTy t) ++ parens (traceTy t'))
-traceTy (RFun _ t t' _) = parens ("RFun " ++ parens (traceTy t) ++ parens (traceTy t'))
-traceTy (RAllE _ tx t)  = parens ("RAllE " ++ parens (traceTy tx) ++ parens (traceTy t))
-traceTy (REx _ tx t)    = parens ("REx " ++ parens (traceTy tx) ++ parens (traceTy t))
-traceTy (RExprArg _)    = "RExprArg"
-traceTy (RAppTy t t' _) = parens ("RAppTy " ++ parens (traceTy t) ++ parens (traceTy t'))
-traceTy (RHole _)       = "rHole"
-traceTy (RRTy _ _ _ t)  = parens ("RRTy " ++ traceTy t)
-
-parens :: String -> String
-parens s = "(" ++ s ++ ")"
-
-rHole :: F.Reft -> SpecType
-rHole = RHole . uTop
-
-
-splitsCWithVariance :: CGEnv
-                    -> [SpecType]
-                    -> [SpecType]
-                    -> [Variance]
-                    -> CG [FixSubC]
-splitsCWithVariance γ t1s t2s variants
-  = concatMapM (\(t1, t2, v) -> splitfWithVariance (\s1 s2 -> (splitC (SubC γ s1 s2))) t1 t2 v) (zip3 t1s t2s variants)
-
-rsplitsCWithVariance :: Bool
-                     -> CGEnv
-                     -> [SpecProp]
-                     -> [SpecProp]
-                     -> [Variance]
-                     -> CG [FixSubC]
-rsplitsCWithVariance False _ _ _ _
-  = return []
-
-rsplitsCWithVariance _ γ t1s t2s variants
-  = concatMapM (\(t1, t2, v) -> splitfWithVariance (rsplitC γ) t1 t2 v) (zip3 t1s t2s variants)
-
-bsplitC :: CGEnv
-        -> SpecType
-        -> SpecType
-        -> CG [F.SubC Cinfo]
-bsplitC γ t1 t2 = do
-  temp   <- getTemplates
-  isHO   <- allowHO   <$> get
-  t1'    <- addLhsInv γ <$> refreshVV t1
-  return  $ bsplitC' γ t1' t2 temp isHO
-
-addLhsInv :: CGEnv -> SpecType -> SpecType
-addLhsInv γ t = addRTyConInv (invs γ) t `strengthen` r
-  where
-    r         = (mempty :: UReft F.Reft) { ur_reft = F.Reft (F.dummySymbol, p) }
-    p         = constraintToLogic rE' (lcs γ)
-    rE'       = insertREnv v t (renv γ)
-    v         = rTypeValueVar t
-
-
-bsplitC' :: CGEnv -> SpecType -> SpecType -> F.Templates -> Bool -> [F.SubC Cinfo]
-bsplitC' γ t1 t2 tem isHO
- | isHO
- = F.subC γ' r1'  r2' Nothing tag ci
- | F.isFunctionSortedReft r1' && F.isNonTrivial r2'
- = F.subC γ' (r1' {F.sr_reft = mempty}) r2' Nothing tag ci
- | F.isNonTrivial r2'
- = F.subC γ' r1'  r2' Nothing tag ci
- | otherwise
- = []
-  where
-    γ'  = feBinds $ fenv γ
-    r1' = rTypeSortedReft' γ tem t1
-    r2' = rTypeSortedReft' γ tem t2
-    ci  = Ci src err (cgVar γ)
-    tag = getTag γ
-    -- err = Just $ ErrSubType src "subtype" g t1 t2
-    err = Just $ fromMaybe (ErrSubType src (text "subtype") g t1 t2) (cerr γ)
-    src = getLocation γ
-    g   = reLocal $ renv γ
-
-unifyVV :: SpecType -> SpecType -> CG (SpecType, SpecType)
-unifyVV t1@(RApp _ _ _ _) t2@(RApp _ _ _ _)
-  = do vv     <- (F.vv . Just) <$> fresh
-       return  $ (shiftVV t1 vv,  (shiftVV t2 vv) )
-
-unifyVV _ _
-  = panic Nothing $ "Constraint.Generate.unifyVV called on invalid inputs"
-
-rsplitC :: CGEnv
-        -> SpecProp
-        -> SpecProp
-        -> CG [FixSubC]
-rsplitC _ _ (RProp _ (RHole _))
-  = panic Nothing "RefTypes.rsplitC on RProp _ (RHole _)"
-
-rsplitC _ (RProp _ (RHole _)) _
-  = panic Nothing "RefTypes.rsplitC on RProp _ (RHole _)"
-
-rsplitC γ (RProp s1 r1) (RProp s2 r2)
-  = do γ'  <-  foldM (+=) γ [("rsplitC1", x, ofRSort s) | (x, s) <- s2]
-       splitC (SubC γ' (F.subst su r1) r2)
-  where su = F.mkSubst [(x, F.EVar y) | ((x,_), (y,_)) <- zip s1 s2]
-
-
---------------------------------------------------------------------------------
--- | Reftypes from F.Fixpoint Expressions --------------------------------------
---------------------------------------------------------------------------------
-forallExprRefType     :: CGEnv -> SpecType -> SpecType
-forallExprRefType γ t = t `strengthen` (uTop r')
-  where
-    r'                = fromMaybe mempty $ forallExprReft γ r
-    r                 = F.sr_reft $ rTypeSortedReft (emb γ) t
-
-forallExprReft :: CGEnv -> F.Reft -> Maybe F.Reft
-forallExprReft γ r =
-  do e <- F.isSingletonReft r
-     forallExprReft_ γ $ F.splitEApp e
-
-forallExprReft_ :: CGEnv -> (F.Expr, [F.Expr]) -> Maybe F.Reft
-forallExprReft_ γ (F.EVar x, [])
-  = case forallExprReftLookup γ x of
-      Just (_,_,_,t)  -> Just $ F.sr_reft $ rTypeSortedReft (emb γ) t
-      Nothing         -> Nothing
-
-forallExprReft_ γ (F.EVar f, es)
-  = case forallExprReftLookup γ f of
-      Just (xs,_,_,t) -> let su = F.mkSubst $ safeZip "fExprRefType" xs es in
-                       Just $ F.subst su $ F.sr_reft $ rTypeSortedReft (emb γ) t
-      Nothing       -> Nothing
-
-forallExprReft_ _ _
-  = Nothing
-
--- forallExprReftLookup :: CGEnv -> F.Symbol -> Int
-forallExprReftLookup :: CGEnv
-                     -> F.Symbol
-                     -> Maybe ([F.Symbol], [SpecType], [RReft], SpecType)
-forallExprReftLookup γ x = snap <$> F.lookupSEnv x (syenv γ)
-  where
-    snap     = mapFourth4 ignoreOblig . (\(_,(a,b,c),t)->(a,b,c,t)) . bkArrow . thd3 . bkUniv . lookup
-    lookup z = fromMaybe (panicUnbound γ z) (γ ?= F.symbol z)
-
-
---------------------------------------------------------------------------------
-getTag :: CGEnv -> F.Tag
---------------------------------------------------------------------------------
-getTag γ = maybe Tg.defaultTag (`Tg.getTag` tgEnv γ) (tgKey γ)
-
-
---------------------------------------------------------------------------------
--- | Constraint Generation Panic -----------------------------------------------
---------------------------------------------------------------------------------
-panicUnbound :: (PPrint x) => CGEnv -> x -> a
-panicUnbound γ x = Ex.throw $ (ErrUnbound (getLocation γ) (F.pprint x) :: Error)
diff --git a/src/Language/Haskell/Liquid/Constraint/ToFixpoint.hs b/src/Language/Haskell/Liquid/Constraint/ToFixpoint.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/ToFixpoint.hs
+++ /dev/null
@@ -1,287 +0,0 @@
-{-# LANGUAGE FlexibleContexts          #-}
-module Language.Haskell.Liquid.Constraint.ToFixpoint
-  ( cgInfoFInfo
-  , fixConfig
-  , refinementEQs
-  , canRewrite
-  ) where
-
-import           Prelude hiding (error)
-import qualified Language.Haskell.Liquid.GHC.API as Ghc
-import qualified Language.Fixpoint.Types.Config as FC
-import           System.Console.CmdArgs.Default (def)
-import qualified Language.Fixpoint.Types        as F
-import           Language.Fixpoint.Solver.Rewrite (unify)
-import           Language.Haskell.Liquid.Constraint.Types
-import qualified Language.Haskell.Liquid.Types.RefType as RT
-import           Language.Haskell.Liquid.Constraint.Qualifier
-import           Control.Monad (guard)
-import qualified Data.Maybe as Mb 
-
--- AT: Move to own module?
--- imports for AxiomEnv
-import qualified Language.Haskell.Liquid.UX.Config as Config
-import           Language.Haskell.Liquid.UX.DiffCheck (coreDeps, dependsOn)
-import qualified Language.Haskell.Liquid.GHC.Misc  as GM -- (simplesymbol)
-import qualified Data.List                         as L
-import qualified Data.HashMap.Strict               as M
-import qualified Data.HashSet                      as S
--- import           Language.Fixpoint.Misc
-import qualified Language.Haskell.Liquid.Misc      as Misc
-import           Var
-import           TyCon                             (TyCon)
-
-import           Language.Haskell.Liquid.Types hiding     ( binds )
-
-fixConfig :: FilePath -> Config -> FC.Config
-fixConfig tgt cfg = def
-  { FC.solver                   = Mb.fromJust (smtsolver cfg)
-  , FC.linear                   = linear            cfg
-  , FC.eliminate                = eliminate         cfg
-  , FC.nonLinCuts               = not (higherOrderFlag cfg) -- eliminate cfg /= FC.All
-  , FC.save                     = saveQuery         cfg
-  , FC.srcFile                  = tgt
-  , FC.cores                    = cores             cfg
-  , FC.minPartSize              = minPartSize       cfg
-  , FC.maxPartSize              = maxPartSize       cfg
-  , FC.elimStats                = elimStats         cfg
-  , FC.elimBound                = elimBound         cfg
-  , FC.allowHO                  = higherOrderFlag   cfg
-  , FC.allowHOqs                = higherorderqs     cfg
-  , FC.smtTimeout               = smtTimeout        cfg 
-  , FC.stringTheory             = stringTheory      cfg
-  , FC.gradual                  = gradual           cfg
-  , FC.ginteractive             = ginteractive       cfg
-  , FC.noslice                  = noslice           cfg
-  , FC.rewriteAxioms            = Config.allowPLE   cfg
-  , FC.etaElim                  = not (exactDC cfg) && extensionality cfg -- SEE: https://github.com/ucsd-progsys/liquidhaskell/issues/1601
-  , FC.extensionality           = extensionality    cfg 
-  , FC.oldPLE                   = oldPLE cfg
-  , FC.maxRWOrderingConstraints = maxRWOrderingConstraints cfg
-  , FC.rwTerminationCheck       = rwTerminationCheck cfg
-  }
-
-
-cgInfoFInfo :: TargetInfo -> CGInfo -> IO (F.FInfo Cinfo)
-cgInfoFInfo info cgi = return (targetFInfo info cgi)
-
-targetFInfo :: TargetInfo -> CGInfo -> F.FInfo Cinfo
-targetFInfo info cgi = mappend (mempty { F.ae = ax }) fi
-  where
-    fi               = F.fi cs ws bs ls consts ks qs bi aHO aHOqs es mempty adts ebs
-    cs               = fixCs    cgi
-    ws               = fixWfs   cgi
-    bs               = binds    cgi
-    ebs              = ebinds   cgi
-    ls               = fEnv     cgi
-    consts           = cgConsts cgi
-    ks               = kuts     cgi
-    adts             = cgADTs   cgi
-    qs               = giQuals info (fEnv cgi)
-    bi               = (\x -> Ci x Nothing Nothing) <$> bindSpans cgi
-    aHO              = allowHO cgi
-    aHOqs            = higherOrderFlag info
-    es               = [] -- makeAxioms info
-    ax               = makeAxiomEnvironment info (dataConTys cgi) (F.cm fi)
-    -- msg              = show . map F.symbol . M.keys . tyConInfo
-
-makeAxiomEnvironment :: TargetInfo -> [(Var, SpecType)] -> M.HashMap F.SubcId (F.SubC Cinfo) -> F.AxiomEnv
-makeAxiomEnvironment info xts fcs
-  = F.AEnv eqs  
-           (concatMap makeSimplify xts)
-           (doExpand sp cfg <$> fcs)
-           (makeRewrites info <$> fcs)
-  where
-    eqs      = if (oldPLE cfg) 
-                then (makeEquations sp ++ map (uncurry $ specTypeEq emb) xts)
-                else axioms  
-    emb      = gsTcEmbeds (gsName sp)
-    cfg      = getConfig  info
-    sp       = giSpec     info
-    axioms   = gsMyAxioms refl ++ gsImpAxioms refl 
-    refl     = gsRefl sp
-
-
-makeRewrites :: TargetInfo -> F.SubC Cinfo -> [F.AutoRewrite]
-makeRewrites info sub = concatMap (makeRewriteOne tce)  $ filter ((`S.member` rws) . fst) sigs
-  where
-    tce        = gsTcEmbeds (gsName spec)
-    spec       = giSpec info
-    sig        = gsSig spec
-    sigs       = gsTySigs sig ++ gsAsmSigs sig
-    isGlobalRw = Mb.maybe False (`elem` globalRws) (subVar sub)
-
-    rws        =
-      if isGlobalRw
-      then S.empty
-      else S.difference
-        (S.union localRws globalRws)
-        (Mb.maybe S.empty forbiddenRWs (subVar sub))
-
-    allDeps         = coreDeps $ giCbs $ giSrc info
-    forbiddenRWs sv =
-      S.insert sv $ dependsOn allDeps [sv]
-
-    localRws = Mb.fromMaybe S.empty $ do
-      var    <- subVar sub
-      usable <- M.lookup var $ gsRewritesWith $ gsRefl spec
-      return $ S.fromList usable
-    globalRws  = S.map val $ gsRewrites $ gsRefl spec
-
-canRewrite :: S.HashSet F.Symbol -> F.Expr -> F.Expr -> Bool
-canRewrite freeVars from to = noFreeSyms && doesNotDiverge
-  where
-    fromSyms           = S.intersection freeVars (S.fromList $ F.syms from)
-    toSyms             = S.intersection freeVars (S.fromList $ F.syms to)
-    noFreeSyms         = S.null $ S.difference toSyms fromSyms
-    doesNotDiverge     = Mb.isNothing (unify (S.toList freeVars) from to)
-                      || Mb.isJust (unify (S.toList freeVars) to from)
-
-refinementEQs :: LocSpecType -> [(F.Expr, F.Expr)]
-refinementEQs t =
-  case stripRTypeBase tres of
-    Just r ->
-      [ (lhs, rhs) | (F.EEq lhs rhs) <- F.splitPAnd $ F.reftPred (F.toReft r) ]
-    Nothing ->
-      []
-  where
-    tres = ty_res tRep
-    tRep = toRTypeRep $ val t 
-  
-makeRewriteOne :: (F.TCEmb TyCon) -> (Var,LocSpecType) -> [F.AutoRewrite]
-makeRewriteOne tce (_,t)
-  = [rw | (lhs, rhs) <- refinementEQs t , rw <- rewrites lhs rhs ]
-  where
-
-    rewrites :: F.Expr -> F.Expr -> [F.AutoRewrite]
-    rewrites lhs rhs =
-         (guard (canRewrite freeVars lhs rhs) >> [F.AutoRewrite xs lhs rhs])
-      ++ (guard (canRewrite freeVars rhs lhs) >> [F.AutoRewrite xs rhs lhs])
-
-    freeVars = S.fromList (ty_binds tRep)
-
-    xs = do
-      (sym, arg) <- zip (ty_binds tRep) (ty_args tRep)
-      let e = maybe F.PTrue (F.reftPred . F.toReft) (stripRTypeBase arg)
-      return $ F.RR (rTypeSort tce arg) (F.Reft (sym, e))
-       
-    tRep = toRTypeRep $ val t 
-
-_isClassOrDict :: Id -> Bool
-_isClassOrDict x = F.tracepp ("isClassOrDict: " ++ F.showpp x) 
-                    $ (hasClassArg x || GM.isDictionary x || Mb.isJust (Ghc.isClassOpId_maybe x))
-
-hasClassArg :: Id -> Bool
-hasClassArg x = F.tracepp msg $ (GM.isDataConId x && any Ghc.isClassPred (t:ts))
-  where 
-    msg       = "hasClassArg: " ++ showpp (x, t:ts)
-    (ts, t)   = Ghc.splitFunTys . snd . Ghc.splitForAllTys . Ghc.varType $ x
-
-
-doExpand :: TargetSpec -> Config -> F.SubC Cinfo -> Bool
-doExpand sp cfg sub = Config.allowGlobalPLE cfg
-                   || (Config.allowLocalPLE cfg && maybe False (isPLEVar sp) (subVar sub))
-
--- [TODO:missing-sorts] data-constructors often have unelaboratable 'define' so either
--- 1. Make `elaborate` robust so it doesn't crash and returns maybe or
--- 2. Make the `ctor` well-sorted or 
--- 3. Don't create `define` for the ctor. 
--- Unfortunately 3 breaks a bunch of tests...
-
-specTypeEq :: F.TCEmb TyCon -> Var -> SpecType -> F.Equation
-specTypeEq emb f t = F.mkEquation (F.symbol f) xts body tOut
-  where
-    xts            = Misc.safeZipWithError "specTypeEq" xs (RT.rTypeSort emb <$> ts)
-    body           = specTypeToResultRef bExp t
-    tOut           = RT.rTypeSort emb (ty_res tRep)
-    tRep           = toRTypeRep t
-    xs             = ty_binds tRep
-    ts             = ty_args  tRep
-    bExp           = F.eApps (F.eVar f) (F.EVar <$> xs)
-
-makeSimplify :: (Var, SpecType) -> [F.Rewrite]
-makeSimplify (x, t)
-  | not (GM.isDataConId x)
-  = [] 
-  | otherwise 
-  = go $ specTypeToResultRef (F.eApps (F.EVar $ F.symbol x) (F.EVar <$> ty_binds (toRTypeRep t))) t
-  where
-    go (F.PAnd es) = concatMap go es
-
-    go (F.PAtom eq (F.EApp (F.EVar f) dc) bd)
-      | eq `elem` [F.Eq, F.Ueq]
-      , (F.EVar dc, xs) <- F.splitEApp dc
-      , dc == F.symbol x 
-      , all isEVar xs
-      = [F.SMeasure f dc (fromEVar <$> xs) bd]
-
-    go (F.PIff (F.EApp (F.EVar f) dc) bd)
-      | (F.EVar dc, xs) <- F.splitEApp dc
-      , dc == F.symbol x 
-      , all isEVar xs
-      = [F.SMeasure f dc (fromEVar <$> xs) bd]
-
-    go _ = []
-
-    isEVar (F.EVar _) = True
-    isEVar _ = False
-
-    fromEVar (F.EVar x) = x
-    fromEVar _ = impossible Nothing "makeSimplify.fromEVar"
-
-makeEquations :: TargetSpec -> [F.Equation]
-makeEquations sp = [ F.mkEquation f xts (equationBody (F.EVar f) xArgs e mbT) t
-                      | F.Equ f xts e t _ <- axioms 
-                      , let xArgs          = F.EVar . fst <$> xts
-                      , let mbT            = if null xArgs then Nothing else M.lookup f sigs
-                   ]
-  where
-    axioms       = gsMyAxioms refl ++ gsImpAxioms refl 
-    refl         = gsRefl sp
-    sigs         = M.fromList [ (GM.simplesymbol v, t) | (v, t) <- gsTySigs (gsSig sp) ]
-
-equationBody :: F.Expr -> [F.Expr] -> F.Expr -> Maybe LocSpecType -> F.Expr
-equationBody f xArgs e mbT
-  | Just t <- mbT = F.pAnd [eBody, rBody t]
-  | otherwise     = eBody
-  where
-    eBody         = F.PAtom F.Eq (F.eApps f xArgs) e
-    rBody t       = specTypeToLogic xArgs (F.eApps f xArgs) (val t)
-
--- NV Move this to types?
--- sound but imprecise approximation of a type in the logic
-specTypeToLogic :: [F.Expr] -> F.Expr -> SpecType -> F.Expr
-specTypeToLogic es e t
-  | ok        = F.subst su (F.PImp (F.pAnd args) res)
-  | otherwise = F.PTrue
-  where
-    res       = specTypeToResultRef e t
-    args      = zipWith mkExpr (mkReft <$> ts) es
-    mkReft t  =  F.toReft $ Mb.fromMaybe mempty (stripRTypeBase t)
-    mkExpr (F.Reft (v, ev)) e = F.subst1 ev (v, e)
-
-
-    ok      = okLen && okClass && okArgs
-    okLen   = length xs == length xs
-    okClass = all (F.isTauto . snd) cls
-    okArgs  = all okArg ts
-
-    okArg (RVar _ _)       = True
-    okArg t@(RApp _ _ _ _) = F.isTauto (t{rt_reft = mempty})
-    okArg _                = False
-
-
-    su           = F.mkSubst $ zip xs es
-    (cls, nocls) = L.partition (isClassType.snd) $ zip (ty_binds trep) (ty_args trep)
-                 :: ([(F.Symbol, SpecType)], [(F.Symbol, SpecType)])
-    (xs, ts)     = unzip nocls :: ([F.Symbol], [SpecType])
-
-    trep = toRTypeRep t
-
-
-specTypeToResultRef :: F.Expr -> SpecType -> F.Expr
-specTypeToResultRef e t
-  = mkExpr $ F.toReft $ Mb.fromMaybe mempty (stripRTypeBase $ ty_res trep)
-  where
-    mkExpr (F.Reft (v, ev)) = F.subst1 ev (v, e)
-    trep                   = toRTypeRep t
diff --git a/src/Language/Haskell/Liquid/Constraint/Types.hs b/src/Language/Haskell/Liquid/Constraint/Types.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Constraint/Types.hs
+++ /dev/null
@@ -1,442 +0,0 @@
-{-# LANGUAGE OverloadedStrings    #-}
-{-# LANGUAGE FlexibleContexts     #-}
-{-# LANGUAGE TupleSections        #-}
-{-# LANGUAGE EmptyDataDecls       #-}
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-
-
-module Language.Haskell.Liquid.Constraint.Types
-  ( -- * Constraint Generation Monad
-    CG
-
-    -- * Constraint information
-  , CGInfo (..)
-
-    -- * Constraint Generation Environment
-  , CGEnv (..)
-
-    -- * Logical constraints (FIXME: related to bounds?)
-  , LConstraint (..)
-
-    -- * Fixpoint environment
-  , FEnv (..)
-  , initFEnv
-  , insertsFEnv
-  -- , removeFEnv
-
-   -- * Hole Environment
-  , HEnv
-  , fromListHEnv
-  , elemHEnv
-
-   -- * Subtyping Constraints
-  , SubC (..)
-  , FixSubC
-
-  , subVar
-
-   -- * Well-formedness Constraints
-  , WfC (..)
-  , FixWfC
-
-   -- * Invariants
-  , RTyConInv
-  , mkRTyConInv
-  , addRTyConInv
-  , addRInv
-
-  -- * Aliases?
-  , RTyConIAl
-  , mkRTyConIAl
-
-  , removeInvariant, restoreInvariant, makeRecInvariants
-
-  , getTemplates
-  ) where
-
-import Prelude hiding (error)
-import           CoreSyn
-import           Type (TyThing( AnId ))
-import           Var
-import           SrcLoc
-import           Unify (tcUnifyTy)
-import qualified TyCon   as TC
-import qualified DataCon as DC
-import           Text.PrettyPrint.HughesPJ hiding ((<>)) 
-import qualified Data.HashMap.Strict as M
-import qualified Data.HashSet        as S
-import qualified Data.List           as L
-import           Control.DeepSeq
-import           Data.Maybe               (catMaybes, isJust)
-import           Control.Monad.State
-
-import           Language.Haskell.Liquid.GHC.SpanStack
-import           Language.Haskell.Liquid.Misc           (thrd3)
-import           Language.Haskell.Liquid.WiredIn        (wiredSortedSyms)
-import qualified Language.Fixpoint.Types            as F
-import           Language.Fixpoint.Misc
-
-import qualified Language.Haskell.Liquid.UX.CTags      as Tg
-
-import           Language.Haskell.Liquid.Types hiding   (binds)
-
-type CG = State CGInfo
-
-data CGEnv = CGE
-  { cgLoc    :: !SpanStack         -- ^ Location in original source file
-  , renv     :: !REnv              -- ^ SpecTypes for Bindings in scope
-  , syenv    :: !(F.SEnv Var)      -- ^ Map from free Symbols (e.g. datacons) to Var
-  , denv     :: !RDEnv             -- ^ Dictionary Environment
-  , litEnv   :: !(F.SEnv F.Sort)   -- ^ Global  literals
-  , constEnv :: !(F.SEnv F.Sort)   -- ^ Distinct literals
-  , fenv   :: !FEnv              -- ^ Fixpoint Environment
-  , recs   :: !(S.HashSet Var)   -- ^ recursive defs being processed (for annotations)
-  , invs   :: !RTyConInv         -- ^ Datatype invariants
-  , rinvs  :: !RTyConInv         -- ^ Datatype recursive invariants: ignored in the base case assumed in rec call
-  , ial    :: !RTyConIAl         -- ^ Datatype checkable invariants
-  , grtys  :: !REnv              -- ^ Top-level variables with (assert)-guarantees to verify
-  , assms  :: !REnv              -- ^ Top-level variables with assumed types
-  , intys  :: !REnv              -- ^ Top-level variables with auto generated internal types
-  , emb    :: F.TCEmb TC.TyCon   -- ^ How to embed GHC Tycons into fixpoint sorts
-  , tgEnv  :: !Tg.TagEnv          -- ^ Map from top-level binders to fixpoint tag
-  , tgKey  :: !(Maybe Tg.TagKey)                     -- ^ Current top-level binder
-  , trec   :: !(Maybe (M.HashMap F.Symbol SpecType)) -- ^ Type of recursive function with decreasing constraints
-  , lcb    :: !(M.HashMap F.Symbol CoreExpr)         -- ^ Let binding that have not been checked (c.f. LAZYVARs)
-  , forallcb :: !(M.HashMap Var F.Expr)              -- ^ Polymorhic let bindings 
-  , holes  :: !HEnv                                  -- ^ Types with holes, will need refreshing
-  , lcs    :: !LConstraint                           -- ^ Logical Constraints
-  , cerr   :: !(Maybe (TError SpecType))             -- ^ error that should be reported at the user
-  , cgInfo :: !TargetInfo                            -- ^ top-level TargetInfo
-  , cgVar  :: !(Maybe Var)                           -- ^ top level function being checked
-  } -- deriving (Data, Typeable)
-
-instance HasConfig CGEnv where
-  getConfig = getConfig . cgInfo
-
-data LConstraint = LC [[(F.Symbol, SpecType)]]
-
-instance Monoid LConstraint where
-  mempty  = LC []
-  mappend = (<>)
-
-instance Semigroup LConstraint where
-  LC cs1 <> LC cs2 = LC (cs1 ++ cs2)
-
-instance PPrint CGEnv where
-  pprintTidy k = pprintTidy k . renv
-
-instance Show CGEnv where
-  show = showpp
-
---------------------------------------------------------------------------------
--- | Subtyping Constraints -----------------------------------------------------
---------------------------------------------------------------------------------
-
--- RJ: what is the difference between these two?
-
-data SubC     = SubC { senv  :: !CGEnv
-                     , lhs   :: !SpecType
-                     , rhs   :: !SpecType
-                     }
-              | SubR { senv  :: !CGEnv
-                     , oblig :: !Oblig
-                     , ref   :: !RReft
-                     }
-
-data WfC      = WfC  !CGEnv !SpecType
-              -- deriving (Data, Typeable)
-
-type FixSubC  = F.SubC Cinfo
-type FixWfC   = F.WfC Cinfo
-
-
-subVar :: FixSubC -> Maybe Var
-subVar = ci_var . F.sinfo
-
-instance PPrint SubC where
-  pprintTidy k c@(SubC {}) = pprintTidy k (senv c)
-                             $+$ ("||-" <+> vcat [ pprintTidy k (lhs c)
-                                                 , "<:"
-                                                 , pprintTidy k (rhs c) ] )
-  pprintTidy k c@(SubR {}) = pprintTidy k (senv c)
-                             $+$ ("||-" <+> vcat [ pprintTidy k (ref c)
-                                                 , parens (pprintTidy k (oblig c))])
-
-
-instance PPrint WfC where
-  pprintTidy k (WfC _ r) = {- pprintTidy k w <> text -} "<...> |-" <+> pprintTidy k r
-
-
---------------------------------------------------------------------------------
--- | Generation: Types ---------------------------------------------------------
---------------------------------------------------------------------------------
-data CGInfo = CGInfo 
-  { fEnv       :: !(F.SEnv F.Sort)             -- ^ top-level fixpoint env
-  , hsCs       :: ![SubC]                      -- ^ subtyping constraints over RType
-  , hsWfs      :: ![WfC]                       -- ^ wellformedness constraints over RType
-  , fixCs      :: ![FixSubC]                   -- ^ subtyping over Sort (post-splitting)
-  , fixWfs     :: ![FixWfC]                    -- ^ wellformedness constraints over Sort (post-splitting)
-  , freshIndex :: !Integer                     -- ^ counter for generating fresh KVars
-  , binds      :: !F.BindEnv                   -- ^ set of environment binders
-  , ebinds     :: ![F.BindId]                  -- ^ existentials
-  , annotMap   :: !(AnnInfo (Annot SpecType))  -- ^ source-position annotation map
-  , holesMap   :: !(M.HashMap Var (HoleInfo (CGInfo, CGEnv) SpecType))    -- ^ information for ghc hole expressions
-  , tyConInfo  :: !TyConMap                    -- ^ information about type-constructors
-  , specDecr   :: ![(Var, [Int])]              -- ^ ^ Lexicographic order of decreasing args (DEPRECATED) 
-  , newTyEnv   :: !(M.HashMap TC.TyCon SpecType)        -- ^ Mapping of new type type constructors with their refined types.
-  , termExprs  :: !(M.HashMap Var [F.Located F.Expr])   -- ^ Terminating Metrics for Recursive functions
-  , specLVars  :: !(S.HashSet Var)             -- ^ Set of variables to ignore for termination checking
-  , specLazy   :: !(S.HashSet Var)             -- ^ "Lazy binders", skip termination checking
-  , specTmVars :: !(S.HashSet Var)             -- ^ Binders that FAILED struct termination check that MUST be checked 
-  , autoSize   :: !(S.HashSet TC.TyCon)        -- ^ ? FIX THIS
-  , tyConEmbed :: !(F.TCEmb TC.TyCon)          -- ^ primitive Sorts into which TyCons should be embedded
-  , kuts       :: !F.Kuts                      -- ^ Fixpoint Kut variables (denoting "back-edges"/recursive KVars)
-  , kvPacks    :: ![S.HashSet F.KVar]          -- ^ Fixpoint "packs" of correlated kvars
-  , cgLits     :: !(F.SEnv F.Sort)             -- ^ Global symbols in the refinement logic
-  , cgConsts   :: !(F.SEnv F.Sort)             -- ^ Distinct constant symbols in the refinement logic
-  , cgADTs     :: ![F.DataDecl]                -- ^ ADTs extracted from Haskell 'data' definitions
-  , tcheck     :: !Bool                        -- ^ Check Termination (?)
-  , pruneRefs  :: !Bool                        -- ^ prune unsorted refinements
-  , logErrors  :: ![Error]                     -- ^ Errors during constraint generation
-  , kvProf     :: !KVProf                      -- ^ Profiling distribution of KVars
-  , recCount   :: !Int                         -- ^ number of recursive functions seen (for benchmarks)
-  , bindSpans  :: M.HashMap F.BindId SrcSpan   -- ^ Source Span associated with Fixpoint Binder
-  , allowHO    :: !Bool
-  , ghcI       :: !TargetInfo
-  , dataConTys :: ![(Var, SpecType)]           -- ^ Refined Types of Data Constructors
-  , unsorted   :: !F.Templates                 -- ^ Potentially unsorted expressions
-  }
-
-
-getTemplates :: CG F.Templates
-getTemplates = do 
-  fg     <- pruneRefs <$> get
-  ts     <- unsorted  <$> get
-  return $ if fg then F.anything else ts 
-       
-
-instance PPrint CGInfo where
-  pprintTidy = pprCGInfo
-
-pprCGInfo :: F.Tidy -> CGInfo -> Doc
-pprCGInfo _k _cgi
-  =  "*********** Constraint Information (omitted) *************"
-  -- -$$ (text "*********** Haskell SubConstraints ***********")
-  -- -$$ (pprintLongList $ hsCs  cgi)
-  -- -$$ (text "*********** Haskell WFConstraints ************")
-  -- -$$ (pprintLongList $ hsWfs cgi)
-  -- -$$ (text "*********** Fixpoint SubConstraints **********")
-  -- -$$ (F.toFix  $ fixCs cgi)
-  -- -$$ (text "*********** Fixpoint WFConstraints ************")
-  -- -$$ (F.toFix  $ fixWfs cgi)
-  -- -$$ (text "*********** Fixpoint Kut Variables ************")
-  -- -$$ (F.toFix  $ kuts cgi)
-  -- -$$ "*********** Literals in Source     ************"
-  -- -$$ F.pprint (cgLits _cgi)
-  -- -$$ (text "*********** KVar Distribution *****************")
-  -- -$$ (pprint $ kvProf cgi)
-  -- -$$ (text "Recursive binders:" <+> pprint (recCount cgi))
-
-
---------------------------------------------------------------------------------
--- | Helper Types: HEnv --------------------------------------------------------
---------------------------------------------------------------------------------
-
-newtype HEnv = HEnv (S.HashSet F.Symbol)
-
-fromListHEnv :: [F.Symbol] -> HEnv
-fromListHEnv = HEnv . S.fromList
-
-elemHEnv :: F.Symbol -> HEnv -> Bool
-elemHEnv x (HEnv s) = x `S.member` s
-
---------------------------------------------------------------------------------
--- | Helper Types: Invariants --------------------------------------------------
---------------------------------------------------------------------------------
-data RInv = RInv { _rinv_args :: [RSort]   -- empty list means that the invariant is generic
-                                           -- for all type arguments
-                 , _rinv_type :: SpecType
-                 , _rinv_name :: Maybe Var
-                 } deriving Show
-
-type RTyConInv = M.HashMap RTyCon [RInv]
-type RTyConIAl = M.HashMap RTyCon [RInv]
-
---------------------------------------------------------------------------------
-mkRTyConInv    :: [(Maybe Var, F.Located SpecType)] -> RTyConInv
---------------------------------------------------------------------------------
-mkRTyConInv ts = group [ (c, RInv (go ts) t v) | (v, t@(RApp c ts _ _)) <- strip <$> ts]
-  where
-    strip = mapSnd (thrd3 . bkUniv . val)
-    go ts | generic (toRSort <$> ts) = []
-          | otherwise                = toRSort <$> ts
-
-    generic ts = let ts' = L.nub ts in
-                 all isRVar ts' && length ts' == length ts
-
-mkRTyConIAl :: [(a, F.Located SpecType)] -> RTyConInv
-mkRTyConIAl    = mkRTyConInv . fmap ((Nothing,) . snd)
-
-addRTyConInv :: RTyConInv -> SpecType -> SpecType
-addRTyConInv m t
-  = case lookupRInv t m of
-      Nothing -> t
-      Just ts -> L.foldl' conjoinInvariantShift t ts
-
-lookupRInv :: SpecType -> RTyConInv -> Maybe [SpecType]
-lookupRInv (RApp c ts _ _) m
-  = case M.lookup c m of
-      Nothing   -> Nothing
-      Just invs -> Just (catMaybes $ goodInvs ts <$> invs)
-lookupRInv _ _
-  = Nothing
-
-goodInvs :: [SpecType] -> RInv -> Maybe SpecType
-goodInvs _ (RInv []  t _)
-  = Just t
-goodInvs ts (RInv ts' t _)
-  | and (zipWith unifiable ts' (toRSort <$> ts))
-  = Just t
-  | otherwise
-  = Nothing
-
-
-unifiable :: RSort -> RSort -> Bool
-unifiable t1 t2 = isJust $ tcUnifyTy (toType t1) (toType t2)
-
-addRInv :: RTyConInv -> (Var, SpecType) -> (Var, SpecType)
-addRInv m (x, t)
-  | x `elem` ids , Just invs <- lookupRInv (res t) m
-  = (x, addInvCond t (mconcat $ catMaybes (stripRTypeBase <$> invs)))
-  | otherwise
-  = (x, t)
-   where
-     ids = [id | tc <- M.keys m
-               , dc <- TC.tyConDataCons $ rtc_tc tc
-               , AnId id <- DC.dataConImplicitTyThings dc]
-     res = ty_res . toRTypeRep
-
-conjoinInvariantShift :: SpecType -> SpecType -> SpecType
-conjoinInvariantShift t1 t2
-  = conjoinInvariant t1 (shiftVV t2 (rTypeValueVar t1))
-
-conjoinInvariant :: SpecType -> SpecType -> SpecType
-conjoinInvariant (RApp c ts rs r) (RApp ic its _ ir)
-  | c == ic && length ts == length its
-  = RApp c (zipWith conjoinInvariantShift ts its) rs (r `F.meet` ir)
-
-conjoinInvariant t@(RApp _ _ _ r) (RVar _ ir)
-  = t { rt_reft = r `F.meet` ir }
-
-conjoinInvariant t@(RVar _ r) (RVar _ ir)
-  = t { rt_reft = r `F.meet` ir }
-
-conjoinInvariant t _
-  = t
-
-removeInvariant  :: CGEnv -> CoreBind -> (CGEnv, RTyConInv)
-removeInvariant γ cbs
-  = (γ { invs  = M.map (filter f) (invs γ)
-       , rinvs = M.map (filter (not . f)) (invs γ)}
-    , invs γ)
-  where
-    f i | Just v  <- _rinv_name i, v `elem` binds cbs
-        = False
-        | otherwise
-        = True
-    binds (NonRec x _) = [x]
-    binds (Rec xes)    = fst $ unzip xes
-
-restoreInvariant :: CGEnv -> RTyConInv -> CGEnv
-restoreInvariant γ is = γ {invs = is}
-
-makeRecInvariants :: CGEnv -> [Var] -> CGEnv
-makeRecInvariants γ [x] = γ {invs = M.unionWith (++) (invs γ) is}
-  where
-    is  =  M.map (map f . filter (isJust . (varType x `tcUnifyTy`) . toType . _rinv_type)) (rinvs γ)
-    f i = i{_rinv_type = guard $ _rinv_type i}
-
-    guard (RApp c ts rs r)
-      | Just f <- szFun <$> sizeFunction (rtc_info c)
-      = RApp c ts rs (MkUReft (ref f $ F.toReft r) mempty)
-      | otherwise
-      = RApp c ts rs mempty
-    guard t
-      = t
-
-    ref f (F.Reft(v, rr))
-      = F.Reft (v, F.PImp (F.PAtom F.Lt (f v) (f $ F.symbol x)) rr)
-
-makeRecInvariants γ _ = γ
-
---------------------------------------------------------------------------------
--- | Fixpoint Environment ------------------------------------------------------
---------------------------------------------------------------------------------
-
-data FEnv = FE
-  { feBinds :: !F.IBindEnv        -- ^ Integer Keys for Fixpoint Environment
-  , feEnv   :: !(F.SEnv F.Sort)   -- ^ Fixpoint Environment
-  , feIdEnv :: !(F.SEnv F.BindId) -- ^ Map from Symbol to current BindId
-  }
-
-insertFEnv :: FEnv -> ((F.Symbol, F.Sort), F.BindId) -> FEnv
-insertFEnv (FE benv env ienv) ((x, t), i)
-  = FE (F.insertsIBindEnv [i] benv)
-       (F.insertSEnv x t      env)
-       (F.insertSEnv x i      ienv)
-
-insertsFEnv :: FEnv -> [((F.Symbol, F.Sort), F.BindId)] -> FEnv
-insertsFEnv = L.foldl' insertFEnv
-
-initFEnv :: [(F.Symbol, F.Sort)] -> FEnv
-initFEnv xts = FE benv0 env0 ienv0
-  where
-    benv0    = F.emptyIBindEnv
-    env0     = F.fromListSEnv (wiredSortedSyms ++ xts)
-    ienv0    = F.emptySEnv
-
---------------------------------------------------------------------------------
--- | Forcing Strictness --------------------------------------------------------
---------------------------------------------------------------------------------
-instance NFData RInv where
-  rnf (RInv x y z) = rnf x `seq` rnf y `seq` rnf z
-
-instance NFData CGEnv where
-  rnf (CGE x1 _ x3 _ x4 x5 x55 x6 x7 x8 x9 _ _ _ x10 _ _ _ _ _ _ _ _ _ _)
-    = x1 `seq` {- rnf x2 `seq` -} seq x3
-         `seq` rnf x5
-         `seq` rnf x55
-         `seq` rnf x6
-         `seq` x7
-         `seq` rnf x8
-         `seq` rnf x9
-         `seq` rnf x10
-         `seq` rnf x4
-
-instance NFData FEnv where
-  rnf (FE x1 x2 x3) = rnf x1 `seq` rnf x2 `seq` rnf x3
-
-instance NFData SubC where
-  rnf (SubC x1 x2 x3)
-    = rnf x1 `seq` rnf x2 `seq` rnf x3
-  rnf (SubR x1 _ x2)
-    = rnf x1 `seq` rnf x2
-
-instance NFData WfC where
-  rnf (WfC x1 x2)
-    = rnf x1 `seq` rnf x2
-
-instance NFData CGInfo where
-  rnf x = ({-# SCC "CGIrnf1" #-}  rnf (hsCs x))       `seq`
-          ({-# SCC "CGIrnf2" #-}  rnf (hsWfs x))      `seq`
-          ({-# SCC "CGIrnf3" #-}  rnf (fixCs x))      `seq`
-          ({-# SCC "CGIrnf4" #-}  rnf (fixWfs x))     `seq`
-          ({-# SCC "CGIrnf6" #-}  rnf (freshIndex x)) `seq`
-          ({-# SCC "CGIrnf7" #-}  rnf (binds x))      `seq`
-          ({-# SCC "CGIrnf8" #-}  rnf (annotMap x))   `seq`
-          ({-# SCC "CGIrnf10" #-} rnf (kuts x))       `seq`
-          ({-# SCC "CGIrnf10" #-} rnf (kvPacks x))    `seq`
-          ({-# SCC "CGIrnf10" #-} rnf (cgLits x))     `seq`
-          ({-# SCC "CGIrnf10" #-} rnf (cgConsts x))   `seq`
-          ({-# SCC "CGIrnf10" #-} rnf (kvProf x))
diff --git a/src/Language/Haskell/Liquid/GHC/API.hs b/src/Language/Haskell/Liquid/GHC/API.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/API.hs
+++ /dev/null
@@ -1,232 +0,0 @@
--- | This module re-exports a bunch of the GHC API.
-
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE PatternSynonyms #-}
-{-# LANGUAGE ViewPatterns #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE BangPatterns #-}
-
-module Language.Haskell.Liquid.GHC.API (
-    module Ghc
-
-#ifdef MIN_VERSION_GLASGOW_HASKELL
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,5,0) && !MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)
-  , VarBndr
-  , AnonArgFlag(..)
-  , pattern Bndr
-  , pattern FunTy
-  , pattern AnonTCB
-  , pattern LitString
-  , pattern LitFloat
-  , pattern LitDouble
-  , pattern LitChar
-  , ft_af, ft_arg, ft_res
-  , bytesFS
-  , mkFunTy
-  , isEvVarType
-  , isEqPrimPred
-#endif
-#endif
-
-  , tyConRealArity
-  , dataConExTyVars
-
-  ) where
-
-import Avail          as Ghc
-import GHC            as Ghc hiding (Warning)
-import ConLike        as Ghc
-import Var            as Ghc
-import Module         as Ghc
-import DataCon        as Ghc
-import TysWiredIn     as Ghc
-import BasicTypes     as Ghc
-import CoreSyn        as Ghc hiding (AnnExpr, AnnExpr' (..), AnnRec, AnnCase)
-import NameSet        as Ghc
-import InstEnv        as Ghc
-import Literal        as Ghc
-import TcType         as Ghc (isClassPred)
-import Class          as Ghc
-import Unique         as Ghc
-import RdrName        as Ghc
-import SrcLoc         as Ghc
-import Name           as Ghc hiding (varName)
-import TysPrim        as Ghc
-import HscTypes       as Ghc
-import HscMain        as Ghc
-import Id             as Ghc hiding (lazySetIdInfo, setIdExported, setIdNotExported)
-import ErrUtils       as Ghc
-import DynFlags       as Ghc
-
---
--- Compatibility layer for different GHC versions.
---
-
---
--- Specific imports for GHC 8.6.5
---
-#ifdef MIN_VERSION_GLASGOW_HASKELL
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,5,0) && !MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)
-
-import                   Binary
-import                   Data.ByteString (ByteString)
-import                   Data.Data (Data)
-import                   Outputable
-import Kind              as Ghc (classifiesTypeWithValues)
-import FastString        as Ghc hiding (bytesFS, LitString)
-import TyCoRep           as Ghc hiding (Type (FunTy), mkFunTy)
-import TyCon             as Ghc hiding (TyConBndrVis(AnonTCB))
-import Type              as Ghc hiding (typeKind, mkFunTy)
-import qualified Type    as Ghc
-import qualified TyCoRep as Ty
-import qualified Literal as Lit
-import qualified TyCon   as Ty
-import qualified Var     as Var
-import qualified GHC.Real
-
-#endif
-#endif
-
---
--- Specific imports for GHC 8.10
---
-#ifdef MIN_VERSION_GLASGOW_HASKELL
-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)
-import Type           as Ghc hiding (typeKind , isPredTy)
-import TyCon          as Ghc
-import TyCoRep        as Ghc
-import FastString     as Ghc
-import Predicate      as Ghc (isEqPred, getClassPredTys_maybe, isEvVarType, isEqPrimPred)
-import Data.Foldable  (asum)
-#endif
-#endif
-
---
--- GHC-specific functions and pattern synonyms
---
-#ifdef MIN_VERSION_GLASGOW_HASKELL
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,5,0) && !MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)
-
--- | The non-dependent version of 'ArgFlag'.
-
--- Appears here partly so that it's together with its friend ArgFlag,
--- but also because it is used in IfaceType, rather early in the
--- compilation chain
--- See Note [AnonArgFlag vs. ForallVisFlag]
-data AnonArgFlag
-  = VisArg    -- ^ Used for @(->)@: an ordinary non-dependent arrow.
-              --   The argument is visible in source code.
-  | InvisArg  -- ^ Used for @(=>)@: a non-dependent predicate arrow.
-              --   The argument is invisible in source code.
-  deriving (Eq, Ord, Data)
-
-instance Outputable AnonArgFlag where
-  ppr VisArg   = text "[vis]"
-  ppr InvisArg = text "[invis]"
-
-instance Binary AnonArgFlag where
-  put_ bh VisArg   = putByte bh 0
-  put_ bh InvisArg = putByte bh 1
-
-  get bh = do
-    h <- getByte bh
-    case h of
-      0 -> return VisArg
-      _ -> return InvisArg
-
-bytesFS :: FastString -> ByteString
-bytesFS = fastStringToByteString
-
-mkFunTy :: AnonArgFlag -> Type -> Type -> Type
-mkFunTy _ = Ty.FunTy
-
-pattern Bndr :: var -> argf -> Var.TyVarBndr var argf
-pattern Bndr var argf <- TvBndr var argf where
-    Bndr var argf = TvBndr var argf
-
-type VarBndr = TyVarBndr
-
-pattern FunTy :: AnonArgFlag -> Type -> Type -> Type
-pattern FunTy { ft_af, ft_arg, ft_res } <- ((VisArg,) -> (ft_af, Ty.FunTy ft_arg ft_res)) where
-    FunTy _ft_af ft_arg ft_res = Ty.FunTy ft_arg ft_res
-
-pattern AnonTCB :: AnonArgFlag -> Ty.TyConBndrVis
-pattern AnonTCB af <- ((VisArg,) -> (af, Ty.AnonTCB)) where
-    AnonTCB _af = Ty.AnonTCB
-
-pattern LitString :: ByteString -> Lit.Literal
-pattern LitString bs <- Lit.MachStr bs where
-    LitString bs = Lit.MachStr bs
-
-pattern LitFloat :: GHC.Real.Ratio Integer -> Lit.Literal
-pattern LitFloat f <- Lit.MachFloat f where
-    LitFloat f = Lit.MachFloat f
-
-pattern LitDouble :: GHC.Real.Ratio Integer -> Lit.Literal
-pattern LitDouble d <- Lit.MachDouble d where
-    LitDouble d = Lit.MachDouble d
-
-pattern LitChar :: Char -> Lit.Literal
-pattern LitChar c <- Lit.MachChar c where
-    LitChar c = Lit.MachChar c
-
--- See NOTE [tyConRealArity].
-tyConRealArity :: TyCon -> Int
-tyConRealArity = tyConArity
-
--- See NOTE [isEvVarType].
-isEvVarType :: Type -> Bool
-isEvVarType = Ghc.isPredTy
-
-isEqPrimPred :: Type -> Bool
-isEqPrimPred = Ghc.isPredTy
-
-#endif
-
-{- | [NOTE:tyConRealArity]
-
-The semantics of 'tyConArity' changed between GHC 8.6.5 and GHC 8.10, mostly due to the
-Visible Dependent Quantification (VDQ). As a result, given the following:
-
-data family EntityField record :: * -> *
-
-Calling `tyConArity` on this would yield @2@ for 8.6.5 but @1@ an 8.10, so we try to backport
-the old behaviour in 8.10 by \"looking\" at the 'Kind' of the input 'TyCon' and trying to recursively
-split the type apart with either 'splitFunTy_maybe' or 'splitForAllTy_maybe'.
-
--}
-
-{- | [NOTE:isEvVarType]
-
-For GHC < 8.10.1 'isPredTy' is effectively the same as the new 'isEvVarType', which covers the cases
-for coercion types and \"normal\" type coercions. The 8.6.5 version of 'isPredTy' had a special case to
-handle a 'TyConApp' in the case of type equality (i.e. ~ ) which was removed in the implementation
-for 8.10.1, which essentially calls 'tcIsConstraintKind' straight away.
--}
-
---
--- Support for GHC >= 8.10.0
---
-
-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)
-
--- See NOTE [tyConRealArity].
-tyConRealArity :: TyCon -> Int
-tyConRealArity tc = go 0 (tyConKind tc)
-  where
-    go :: Int -> Kind -> Int
-    go !acc k =
-      case asum [fmap snd (splitFunTy_maybe k), fmap snd (splitForAllTy_maybe k)] of
-        Nothing -> acc
-        Just ks -> go (acc + 1) ks
-
-dataConExTyVars :: DataCon -> [TyVar]
-dataConExTyVars = dataConExTyCoVars
-
-#endif
-
---
--- End of compatibility shim.
---
-#endif
diff --git a/src/Language/Haskell/Liquid/GHC/GhcMonadLike.hs b/src/Language/Haskell/Liquid/GHC/GhcMonadLike.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/GhcMonadLike.hs
+++ /dev/null
@@ -1,293 +0,0 @@
-{-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances #-}
--- | This module introduces a \"lighter\" "GhcMonad" typeclass which doesn't require an instance of
--- 'ExceptionMonad', and can therefore be used for both 'CoreM' and 'Ghc'.
---
-
-module Language.Haskell.Liquid.GHC.GhcMonadLike (
-  -- * Types and type classes
-    HasHscEnv
-  , GhcMonadLike
-  , ModuleInfo
-  , TypecheckedModule(..)
-
-  -- * Functions and typeclass methods
-
-  , askHscEnv
-  , getModuleGraph
-  , getModSummary
-  , lookupModSummary
-  , lookupGlobalName
-  , lookupName
-  , modInfoLookupName
-  , moduleInfoTc
-  , parseModule
-  , typecheckModule
-  , desugarModule
-  , findModule
-  , lookupModule
-  ) where
-
-import Control.Monad
-import Control.Monad.IO.Class
-import Control.Exception (throwIO)
-
-import Data.IORef (readIORef)
-
-import qualified Language.Haskell.Liquid.GHC.API   as Ghc
-import           Language.Haskell.Liquid.GHC.API   hiding ( ModuleInfo
-                                                          , findModule
-                                                          , desugarModule
-                                                          , typecheckModule
-                                                          , parseModule
-                                                          , lookupName
-                                                          , lookupGlobalName
-                                                          , getModSummary
-                                                          , getModuleGraph
-                                                          , modInfoLookupName
-                                                          , lookupModule
-                                                          , TypecheckedModule
-                                                          , tm_parsed_module
-                                                          , tm_renamed_source
-                                                          )
-import qualified CoreMonad
-import qualified EnumSet
-import TcRnMonad
-import Outputable
-import UniqFM
-import Maybes
-import Panic
-import GhcMake
-import Finder
-import Exception (ExceptionMonad)
-
-import Optics
-
-class HasHscEnv m where
-  askHscEnv :: m HscEnv
-
-instance HasHscEnv CoreMonad.CoreM where
-  askHscEnv = CoreMonad.getHscEnv
-
-instance HasHscEnv Ghc where
-  askHscEnv = getSession
-
-instance HasHscEnv (IfM lcl) where
-  askHscEnv = getTopEnv
-
-instance HasHscEnv TcM where
-  askHscEnv = env_top <$> getEnv
-
-instance HasHscEnv Hsc where
-  askHscEnv = Hsc $ \e w -> pure (e, w)
-
-instance (ExceptionMonad m, HasHscEnv m) => HasHscEnv (GhcT m) where
-  askHscEnv = getSession
-
--- | A typeclass which is /very/ similar to the existing 'GhcMonad', but it doesn't impose a
--- 'ExceptionMonad' constraint.
-class (Functor m, MonadIO m, HasHscEnv m, HasDynFlags m) => GhcMonadLike m
-
-instance GhcMonadLike CoreMonad.CoreM
-instance GhcMonadLike Ghc
-instance GhcMonadLike (IfM lcl)
-instance GhcMonadLike TcM
-instance GhcMonadLike Hsc
-instance (ExceptionMonad m, GhcMonadLike m) => GhcMonadLike (GhcT m)
-
--- NOTE(adn) Taken from the GHC API, adapted to work for a 'GhcMonadLike' monad.
-getModuleGraph :: GhcMonadLike m => m ModuleGraph
-getModuleGraph = liftM hsc_mod_graph askHscEnv
-
--- NOTE(adn) Taken from the GHC API, adapted to work for a 'GhcMonadLike' monad.
-getModSummary :: GhcMonadLike m => ModuleName -> m ModSummary
-getModSummary mdl = do
-   mg <- liftM hsc_mod_graph askHscEnv
-   let mods_by_name = [ ms | ms <- mgModSummaries mg
-                      , ms_mod_name ms == mdl
-                      , not (isBootSummary ms) ]
-   case mods_by_name of
-     [] -> do dflags <- getDynFlags
-              liftIO $ throwIO $ mkApiErr dflags (text "Module not part of module graph")
-     [ms] -> return ms
-     multiple -> do dflags <- getDynFlags
-                    liftIO $ throwIO $ mkApiErr dflags (text "getModSummary is ambiguous: " <+> ppr multiple)
-
-lookupModSummary :: GhcMonadLike m => ModuleName -> m (Maybe ModSummary)
-lookupModSummary mdl = do
-   mg <- liftM hsc_mod_graph askHscEnv
-   let mods_by_name = [ ms | ms <- mgModSummaries mg
-                      , ms_mod_name ms == mdl
-                      , not (isBootSummary ms) ]
-   case mods_by_name of
-     [ms] -> pure (Just ms)
-     _    -> pure Nothing
-
--- NOTE(adn) Taken from the GHC API, adapted to work for a 'GhcMonadLike' monad.
-lookupGlobalName :: GhcMonadLike m => Name -> m (Maybe TyThing)
-lookupGlobalName name = do
-  hsc_env <- askHscEnv
-  liftIO $ lookupTypeHscEnv hsc_env name
-
--- NOTE(adn) Taken from the GHC API, adapted to work for a 'GhcMonadLike' monad.
-lookupName :: GhcMonadLike m => Name -> m (Maybe TyThing)
-lookupName name = do
-  hsc_env <- askHscEnv
-  liftIO $ hscTcRcLookupName hsc_env name
-
--- | Our own simplified version of 'ModuleInfo' to overcome the fact we cannot construct the \"original\"
--- one as the constructor is not exported, and 'getHomeModuleInfo' and 'getPackageModuleInfo' are not
--- exported either, so we had to backport them as well.
-data ModuleInfo = ModuleInfo { minf_type_env :: UniqFM TyThing }
-
-modInfoLookupName :: GhcMonadLike m 
-                  => ModuleInfo 
-                  -> Name
-                  -> m (Maybe TyThing)
-modInfoLookupName minf name = do
-  hsc_env <- askHscEnv
-  case lookupTypeEnv (minf_type_env minf) name of
-    Just tyThing -> return (Just tyThing)
-    Nothing      -> do
-      eps   <- liftIO $ readIORef (hsc_EPS hsc_env)
-      return $! lookupType (hsc_dflags hsc_env) (hsc_HPT hsc_env) (eps_PTE eps) name
-
-moduleInfoTc :: GhcMonadLike m => ModSummary -> TcGblEnv -> m ModuleInfo
-moduleInfoTc ms tcGblEnv = do
-  hsc_env <- askHscEnv
-  let hsc_env_tmp = hsc_env { hsc_dflags = ms_hspp_opts ms }
-  details <- md_types <$> liftIO (makeSimpleDetails hsc_env_tmp tcGblEnv)
-  pure ModuleInfo { minf_type_env = details }
-
---
--- Parsing, typechecking and desugaring a module
---
-parseModule :: GhcMonadLike m => ModSummary -> m ParsedModule
-parseModule ms = do
-  hsc_env <- askHscEnv
-  let hsc_env_tmp = hsc_env { hsc_dflags = ms_hspp_opts ms }
-  hpm <- liftIO $ hscParse hsc_env_tmp ms
-  return (ParsedModule ms (hpm_module hpm) (hpm_src_files hpm)
-                           (hpm_annotations hpm))
-
--- | Our own simplified version of 'TypecheckedModule'.
-data TypecheckedModule = TypecheckedModule { 
-    tm_parsed_module  :: ParsedModule
-  , tm_renamed_source :: Maybe RenamedSource
-  , tm_mod_summary    :: ModSummary
-  , tm_gbl_env        :: TcGblEnv
-  }
-
-typecheckModule :: GhcMonadLike m => ParsedModule -> m TypecheckedModule
-typecheckModule pmod = do
-  -- Suppress all the warnings, so that they won't be printed (which would result in them being
-  -- printed twice, one by GHC and once here).
-  let ms = pm_mod_summary pmod
-  hsc_env <- askHscEnv
-  let dynFlags' = ms_hspp_opts ms
-  let hsc_env_tmp = hsc_env { hsc_dflags = dynFlags' { warningFlags = EnumSet.empty } }
-  (tc_gbl_env, rn_info)
-        <- liftIO $ hscTypecheckRename hsc_env_tmp ms $
-                       HsParsedModule { hpm_module = parsedSource pmod,
-                                        hpm_src_files = pm_extra_src_files pmod,
-                                        hpm_annotations = pm_annotations pmod }
-  return TypecheckedModule {
-      tm_parsed_module  = pmod
-    , tm_renamed_source = rn_info
-    , tm_mod_summary    = ms
-    , tm_gbl_env        = tc_gbl_env
-    }
-
-{- | [NOTE:ghc810]
-Something changed in the GHC bowels such that the 'hscTarget' that the 'ModSummary' was inheriting
-was /not/ the one we were setting in 'configureDynFlags'. This is important, because if the 'hscTarget'
-is not 'HscInterpreted' or 'HscNothing', the call to 'targetRetainsAllBindings' will yield 'False'. This
-function is used internally by GHC to do dead-code-elimination and to mark functions as "exported" or not.
-Therefore, the 'CoreBind's passed to LiquidHaskell would be different between GHC 8.6.5 and GHC 8.10.
--}
-
-class IsTypecheckedModule t where
-  tmParsedModule :: Lens'  t ParsedModule
-  tmModSummary   :: Lens'  t ModSummary
-  tmGblEnv       :: Getter t TcGblEnv
-
-instance IsTypecheckedModule TypecheckedModule where
-  tmParsedModule = lens tm_parsed_module (\s x -> s { tm_parsed_module = x })
-  tmModSummary   = lens tm_mod_summary   (\s x -> s { tm_mod_summary = x })
-  tmGblEnv       = to tm_gbl_env
-
-instance IsTypecheckedModule Ghc.TypecheckedModule where
-  tmParsedModule = lens Ghc.tm_parsed_module (\s x -> s { Ghc.tm_parsed_module = x })
-  tmModSummary   = lens (pm_mod_summary . Ghc.tm_parsed_module)
-                        (\s x -> over tmParsedModule (\pm -> pm { Ghc.pm_mod_summary = x }) s )
-  tmGblEnv       = to (fst . Ghc.tm_internals_)
-
--- | Desugar a typechecked module.
-desugarModule :: (GhcMonadLike m, IsTypecheckedModule t) => ModSummary -> t -> m ModGuts
-desugarModule originalModSum typechecked = do
-  -- See [NOTE:ghc810] on why we override the dynFlags here before calling 'desugarModule'.
-  dynFlags          <- getDynFlags
-  let modSum         = originalModSum { ms_hspp_opts = dynFlags }
-  let parsedMod'     = (view tmParsedModule typechecked) { pm_mod_summary = modSum }
-  let typechecked'   = set tmParsedModule parsedMod' typechecked
-
-  hsc_env <- askHscEnv
-  let hsc_env_tmp = hsc_env { hsc_dflags = ms_hspp_opts (view tmModSummary typechecked') }
-  liftIO $ hscDesugar hsc_env_tmp (view tmModSummary typechecked') (view tmGblEnv typechecked')
-
--- | Takes a 'ModuleName' and possibly a 'UnitId', and consults the
--- filesystem and package database to find the corresponding 'Module',
--- using the algorithm that is used for an @import@ declaration.
-findModule :: GhcMonadLike m => ModuleName -> Maybe FastString -> m Module
-findModule mod_name maybe_pkg = do
-  hsc_env <- askHscEnv
-  let
-    dflags   = hsc_dflags hsc_env
-    this_pkg = thisPackage dflags
-  --
-  case maybe_pkg of
-    Just pkg | fsToUnitId pkg /= this_pkg && pkg /= fsLit "this" -> liftIO $ do
-      res <- findImportedModule hsc_env mod_name maybe_pkg
-      case res of
-        Found _ m -> return m
-        err       -> throwOneError $ noModError dflags noSrcSpan mod_name err
-    _otherwise -> do
-      home <- lookupLoadedHomeModule mod_name
-      case home of
-        Just m  -> return m
-        Nothing -> liftIO $ do
-           res <- findImportedModule hsc_env mod_name maybe_pkg
-           case res of
-             Found loc m | moduleUnitId m /= this_pkg -> return m
-                         | otherwise -> modNotLoadedError dflags m loc
-             err -> throwOneError $ noModError dflags noSrcSpan mod_name err
-
-
-lookupLoadedHomeModule :: GhcMonadLike m => ModuleName -> m (Maybe Module)
-lookupLoadedHomeModule mod_name = do
-  hsc_env <- askHscEnv
-  case lookupHpt (hsc_HPT hsc_env) mod_name of
-    Just mod_info      -> return (Just (mi_module (hm_iface mod_info)))
-    _not_a_home_module -> return Nothing
-
-
-modNotLoadedError :: DynFlags -> Module -> ModLocation -> IO a
-modNotLoadedError dflags m loc = throwGhcExceptionIO $ CmdLineError $ showSDoc dflags $
-   text "module is not loaded:" <+>
-   quotes (ppr (moduleName m)) <+>
-   parens (text (expectJust "modNotLoadedError" (ml_hs_file loc)))
-
-
-lookupModule :: GhcMonadLike m => ModuleName -> Maybe FastString -> m Module
-lookupModule mod_name (Just pkg) = findModule mod_name (Just pkg)
-lookupModule mod_name Nothing = do
-  hsc_env <- askHscEnv
-  home <- lookupLoadedHomeModule mod_name
-  case home of
-    Just m  -> return m
-    Nothing -> liftIO $ do
-      res <- findExposedPackageModule hsc_env mod_name Nothing
-      case res of
-        Found _ m -> return m
-        err       -> throwOneError $ noModError (hsc_dflags hsc_env) noSrcSpan mod_name err
diff --git a/src/Language/Haskell/Liquid/GHC/Interface.hs b/src/Language/Haskell/Liquid/GHC/Interface.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Interface.hs
+++ /dev/null
@@ -1,952 +0,0 @@
-{-# LANGUAGE NoMonomorphismRestriction  #-}
-{-# LANGUAGE TypeSynonymInstances       #-}
-{-# LANGUAGE FlexibleContexts           #-}
-{-# LANGUAGE FlexibleInstances          #-}
-{-# LANGUAGE LambdaCase                 #-}
-{-# LANGUAGE TupleSections              #-}
-{-# LANGUAGE ScopedTypeVariables        #-}
-{-# LANGUAGE OverloadedStrings          #-}
-{-# LANGUAGE PartialTypeSignatures      #-}
-{-# LANGUAGE ViewPatterns               #-}
-
-module Language.Haskell.Liquid.GHC.Interface (
-
-  -- * Determine the build-order for target files
-   realTargets
-
-  , getInterfaceDynFlags
-
-  -- * Extract all information needed for verification
-  , getTargetInfos
-  , runLiquidGhc
-
-  -- * Printer
-  , pprintCBs
-
-  -- * predicates
-  -- , isExportedVar
-  -- , exportedVars
-
-  -- * Internal exports (provisional)
-  , extractSpecComments
-  , extractSpecQuotes'
-  , makeLogicMap
-  , classCons
-  , derivedVars
-  , importVars
-  , makeGhcSrc
-  , allImports
-  , qualifiedImports
-  , modSummaryHsFile
-  , makeFamInstEnv
-  , findAndParseSpecFiles
-  , parseSpecFile
-  , noTerm
-  , clearSpec
-  , checkFilePragmas
-  , keepRawTokenStream
-  , ignoreInline
-  , lookupTyThings
-  , availableTyCons
-  , availableVars
-  , updLiftedSpec
-  , loadDependenciesOf
-  ) where
-
-import Prelude hiding (error)
-
-import qualified Outputable as O
-import GHC hiding (Target, Located, desugarModule)
-import qualified GHC
-import GHC.Paths (libdir)
-import GHC.Serialized
-
-import qualified Language.Haskell.Liquid.GHC.API as Ghc
-import Annotations
-import Avail
-import Class
-import CoreMonad
-import CoreSyn
-import DataCon
-import Digraph
-import DriverPhases
-import DriverPipeline
-import DynFlags
-import Finder
-import HscTypes hiding (Target)
-import IdInfo
-import InstEnv
-import Module
-import Panic (throwGhcExceptionIO)
--- import Serialized
-import TcRnTypes
-import Var
--- import NameSet
-import FastString
-import FamInstEnv
-import FamInst
-import qualified TysPrim
-import GHC.LanguageExtensions
-
-import Control.Exception
-import Control.Monad
-
-import Data.Bifunctor
-import Data.Data
-import Data.List hiding (intersperse)
-import Data.Maybe
-
-import Data.Generics.Aliases (mkT)
-import Data.Generics.Schemes (everywhere)
-
-import qualified Data.HashSet        as S
-import qualified Data.Map            as M
-import qualified Data.HashMap.Strict as HM
-
-import System.Console.CmdArgs.Verbosity hiding (Loud)
-import System.Directory
-import System.FilePath
-import System.IO.Temp
-import Text.Parsec.Pos
-import Text.PrettyPrint.HughesPJ        hiding (first, (<>))
-import Language.Fixpoint.Types          hiding (panic, Error, Result, Expr)
-import qualified Language.Fixpoint.Misc as Misc
-import Language.Haskell.Liquid.Bare
-import Language.Haskell.Liquid.GHC.Misc
-import Language.Haskell.Liquid.GHC.Types (MGIModGuts(..), miModGuts)
-import Language.Haskell.Liquid.GHC.Play
-import qualified Language.Haskell.Liquid.GHC.GhcMonadLike as GhcMonadLike
-import Language.Haskell.Liquid.GHC.GhcMonadLike (GhcMonadLike, askHscEnv)
-import Language.Haskell.Liquid.WiredIn (isDerivedInstance) 
-import qualified Language.Haskell.Liquid.Measure  as Ms
-import qualified Language.Haskell.Liquid.Misc     as Misc
-import Language.Haskell.Liquid.Parse
-import Language.Haskell.Liquid.Transforms.ANF
-import Language.Haskell.Liquid.Types hiding (Spec)
--- import Language.Haskell.Liquid.Types.PrettyPrint
--- import Language.Haskell.Liquid.Types.Visitors
-import Language.Haskell.Liquid.UX.CmdLine
-import Language.Haskell.Liquid.UX.QuasiQuoter
-import Language.Haskell.Liquid.UX.Tidy
-import Language.Fixpoint.Utils.Files
-
-import Optics
-
-import qualified Debug.Trace as Debug 
-
-
---------------------------------------------------------------------------------
-{- | @realTargets mE cfg targets@ uses `Interface.configureGhcTargets` to 
-     return a list of files
-
-       [i1, i2, ... ] ++ [f1, f2, ...]
-
-     1. Where each file only (transitively imports) PRECEDIING ones; 
-     2. `f1..` are a permutation of the original `targets`;
-     3. `i1..` either don't have "fresh" .bspec files. 
-
- -}
---------------------------------------------------------------------------------
-realTargets :: Maybe HscEnv -> Config -> [FilePath] -> IO [FilePath] 
-realTargets  mbEnv cfg tgtFs 
-  | noCheckImports cfg = return tgtFs
-  | otherwise          = do 
-    incDir   <- Misc.getIncludeDir 
-    allFs    <- orderTargets mbEnv cfg tgtFs
-    let srcFs = filter (not . Misc.isIncludeFile incDir) allFs
-    realFs   <- filterM check srcFs
-    dir      <- getCurrentDirectory
-    return      (makeRelative dir <$> realFs)
-  where 
-    check f    = not <$> skipTarget tgts f 
-    tgts       = S.fromList tgtFs
-
-getInterfaceDynFlags :: Maybe HscEnv -> Config -> IO DynFlags
-getInterfaceDynFlags mbEnv cfg = runLiquidGhc mbEnv cfg $ getSessionDynFlags
-
-orderTargets :: Maybe HscEnv -> Config -> [FilePath] -> IO [FilePath] 
-orderTargets mbEnv cfg tgtFiles = runLiquidGhc mbEnv cfg $ do 
-  homeModules <- configureGhcTargets tgtFiles
-  return         (modSummaryHsFile <$> mgModSummaries homeModules)
-
-
-skipTarget :: S.HashSet FilePath -> FilePath -> IO Bool
-skipTarget tgts f 
-  | S.member f tgts = return False          -- Always check target file 
-  | otherwise       = hasFreshBinSpec f     -- But skip an import with fresh .bspec
-
-hasFreshBinSpec :: FilePath -> IO Bool
-hasFreshBinSpec srcF = do 
-  let specF = extFileName BinSpec srcF
-  srcMb    <- Misc.lastModified srcF 
-  specMb   <- Misc.lastModified specF 
-  case (srcMb, specMb) of 
-    (Just srcT, Just specT) -> return (srcT < specT)
-    _                       -> return False
-
-
-
---------------------------------------------------------------------------------
--- | GHC Interface Pipeline ----------------------------------------------------
---------------------------------------------------------------------------------
-
-getTargetInfos :: Maybe HscEnv -> Config -> [FilePath] -> IO ([TargetInfo], HscEnv)
-getTargetInfos hscEnv cfg tgtFiles' = do
-  tgtFiles <- mapM canonicalizePath tgtFiles'
-  _        <- mapM checkFilePresent tgtFiles
-  _        <- mapM_ createTempDirectoryIfMissing tgtFiles
-  logicMap <- liftIO makeLogicMap
-  runLiquidGhc hscEnv cfg (getTargetInfos' cfg logicMap tgtFiles)
-
-checkFilePresent :: FilePath -> IO ()
-checkFilePresent f = do
-  b <- doesFileExist f
-  unless b $ panic Nothing ("Cannot find file: " ++ f)
-
-getTargetInfos' :: Config -> LogicMap -> [FilePath] -> Ghc ([TargetInfo], HscEnv)
-getTargetInfos' cfg logicMap tgtFiles = do
-  _           <- compileCFiles cfg
-  homeModules <- configureGhcTargets tgtFiles
-  depGraph    <- buildDepGraph homeModules
-  ghcInfos    <- processModules cfg logicMap tgtFiles depGraph homeModules
-  hscEnv      <- getSession
-  return (ghcInfos, hscEnv)
-
-createTempDirectoryIfMissing :: FilePath -> IO ()
-createTempDirectoryIfMissing tgtFile = Misc.tryIgnore "create temp directory" $
-  createDirectoryIfMissing False $ tempDirectory tgtFile
-
---------------------------------------------------------------------------------
--- | GHC Configuration & Setup -------------------------------------------------
---------------------------------------------------------------------------------
-runLiquidGhc :: Maybe HscEnv -> Config -> Ghc a -> IO a
-runLiquidGhc hscEnv cfg act =
-  withSystemTempDirectory "liquid" $ \tmp ->
-    runGhc (Just libdir) $ do
-      maybe (return ()) setSession hscEnv
-      df <- configureDynFlags cfg tmp
-      prettyPrintGhcErrors df act
-
-updateIncludePaths :: DynFlags -> [FilePath] -> IncludeSpecs 
-updateIncludePaths df ps = addGlobalInclude (includePaths df) ps 
-
-configureDynFlags :: Config -> FilePath -> Ghc DynFlags
-configureDynFlags cfg tmp = do
-  df <- getSessionDynFlags
-  (df',_,_) <- parseDynamicFlags df $ map noLoc $ ghcOptions cfg
-  loud <- liftIO isLoud
-  let df'' = df' { importPaths  = nub $ idirs cfg ++ importPaths df'
-                 , libraryPaths = nub $ idirs cfg ++ libraryPaths df'
-                 , includePaths = updateIncludePaths df' (idirs cfg) -- addGlobalInclude (includePaths df') (idirs cfg) 
-                 , packageFlags = ExposePackage ""
-                                                (PackageArg "ghc-prim")
-                                                (ModRenaming True [])
-                                : (packageFlags df')
-
-                 , debugLevel   = 1               -- insert SourceNotes
-                 -- , profAuto     = ProfAutoCalls
-                 , ghcLink      = LinkInMemory
-                 , hscTarget    = HscInterpreted
-                 , ghcMode      = CompManager
-                 -- prevent GHC from printing anything, unless in Loud mode
-                 , log_action   = if loud
-                                    then defaultLogAction
-                                    else \_ _ _ _ _ _ -> return ()
-                 -- redirect .hi/.o/etc files to temp directory
-                 , objectDir    = Just tmp
-                 , hiDir        = Just tmp
-                 , stubDir      = Just tmp
-                 } `gopt_set` Opt_ImplicitImportQualified
-                   `gopt_set` Opt_PIC
-                   `gopt_set` Opt_DeferTypedHoles
-                   `xopt_set` MagicHash
-                   `xopt_set` DeriveGeneric
-                   `xopt_set` StandaloneDeriving
-  _ <- setSessionDynFlags df''
-  return df''
-
-configureGhcTargets :: [FilePath] -> Ghc ModuleGraph
-configureGhcTargets tgtFiles = do
-  targets         <- mapM (`guessTarget` Nothing) tgtFiles
-  _               <- setTargets targets
-  moduleGraph     <- depanal [] False -- see [NOTE:DROP-BOOT-FILES]
-
-  let homeModules  = filter (not . isBootSummary) $
-                     flattenSCCs $ topSortModuleGraph False moduleGraph Nothing
-  let homeNames    = moduleName . ms_mod <$> homeModules
-  _               <- setTargetModules homeNames
-  liftIO $ whenLoud $ print    ("Module Dependencies", homeNames)
-  return $ mkModuleGraph homeModules
-
-setTargetModules :: [ModuleName] -> Ghc ()
-setTargetModules modNames = setTargets $ mkTarget <$> modNames
-  where
-    mkTarget modName = GHC.Target (TargetModule modName) True Nothing
-
-compileCFiles :: Config -> Ghc ()
-compileCFiles cfg = do
-  df  <- getSessionDynFlags
-  _   <- setSessionDynFlags $
-           df { includePaths = updateIncludePaths df (idirs cfg) 
-              , importPaths  = nub $ idirs cfg ++ importPaths df
-              , libraryPaths = nub $ idirs cfg ++ libraryPaths df }
-  hsc <- getSession
-  os  <- mapM (\x -> liftIO $ compileFile hsc StopLn (x,Nothing)) (nub $ cFiles cfg)
-  df  <- getSessionDynFlags
-  void $ setSessionDynFlags $ df { ldInputs = nub $ map (FileOption "") os ++ ldInputs df }
-
-{- | [NOTE:DROP-BOOT-FILES] Drop hs-boot files from the graph.
-      We do it manually rather than using the flag to topSortModuleGraph
-      because otherwise the order of mutually recursive modules depends
-      on the modulename, e.g. given
-
-      Bar.hs --> Foo.hs --> Bar.hs-boot
-
-      we'll get
-      
-      [Bar.hs, Foo.hs]
-    
-      which is backwards..
- -}
---------------------------------------------------------------------------------
--- Home Module Dependency Graph ------------------------------------------------
---------------------------------------------------------------------------------
-
-type DepGraph = Graph DepGraphNode
-type DepGraphNode = Node Module ()
-
-reachableModules :: DepGraph -> Module -> [Module]
-reachableModules depGraph mod =
-  node_key <$> tail (reachableG depGraph (DigraphNode () mod []))
-
-buildDepGraph :: ModuleGraph -> Ghc DepGraph
-buildDepGraph homeModules =
-  graphFromEdgedVerticesOrd <$> mapM mkDepGraphNode (mgModSummaries homeModules)
-
-mkDepGraphNode :: ModSummary -> Ghc DepGraphNode
-mkDepGraphNode modSummary = 
-  DigraphNode () (ms_mod modSummary) <$> (filterM isHomeModule =<< modSummaryImports modSummary)
-
-isHomeModule :: GhcMonadLike m => Module -> m Bool
-isHomeModule mod = do
-  homePkg <- thisPackage <$> getDynFlags
-  return   $ moduleUnitId mod == homePkg
-
-modSummaryImports :: GhcMonadLike m => ModSummary -> m [Module]
-modSummaryImports modSummary =
-  mapM (importDeclModule (ms_mod modSummary))
-       (ms_textual_imps modSummary)
-
-importDeclModule :: GhcMonadLike m => Module -> (Maybe FastString,  GHC.Located ModuleName) -> m Module
-importDeclModule fromMod (pkgQual, locModName) = do
-  hscEnv <- askHscEnv
-  let modName = unLoc locModName
-  result <- liftIO $ findImportedModule hscEnv modName pkgQual
-  case result of
-    Finder.Found _ mod -> return mod
-    _ -> do
-      dflags <- getDynFlags
-      liftIO $ throwGhcExceptionIO $ ProgramError $
-        O.showPpr dflags (moduleName fromMod) ++ ": " ++
-        O.showSDoc dflags (cannotFindModule dflags modName result)
-
---------------------------------------------------------------------------------
--- | Extract Ids ---------------------------------------------------------------
---------------------------------------------------------------------------------
-
-classCons :: Maybe [ClsInst] -> [Id]
-classCons Nothing   = []
-classCons (Just cs) = concatMap (dataConImplicitIds . head . tyConDataCons . classTyCon . is_cls) cs
-
-derivedVars :: Config -> MGIModGuts -> [Var]  
-derivedVars cfg mg  = concatMap (dFunIdVars cbs . is_dfun) derInsts 
-  where 
-    derInsts        
-      | checkDer    = insts 
-      | otherwise   = filter isDerivedInstance insts
-    insts           = mgClsInstances mg 
-    checkDer        = checkDerived cfg
-    cbs             = mgi_binds mg
-               
-
-mgClsInstances :: MGIModGuts -> [ClsInst]
-mgClsInstances = fromMaybe [] . mgi_cls_inst 
-
-dFunIdVars :: CoreProgram -> DFunId -> [Id]
-dFunIdVars cbs fd  = notracepp msg $ concatMap bindersOf cbs' ++ deps
-  where
-    msg            = "DERIVED-VARS-OF: " ++ showpp fd
-    cbs'           = filter f cbs
-    f (NonRec x _) = eqFd x
-    f (Rec xes)    = any eqFd (fst <$> xes)
-    eqFd x         = varName x == varName fd
-    deps           = concatMap unfoldDep unfolds
-    unfolds        = unfoldingInfo . idInfo <$> concatMap bindersOf cbs'
-
-unfoldDep :: Unfolding -> [Id]
-unfoldDep (DFunUnfolding _ _ e)       = concatMap exprDep e
-unfoldDep CoreUnfolding {uf_tmpl = e} = exprDep e
-unfoldDep _                           = []
-
-exprDep :: CoreExpr -> [Id]
-exprDep = freeVars S.empty
-
-importVars :: CoreProgram -> [Id]
-importVars = freeVars S.empty
-
-_definedVars :: CoreProgram -> [Id]
-_definedVars = concatMap defs
-  where
-    defs (NonRec x _) = [x]
-    defs (Rec xes)    = map fst xes
-
---------------------------------------------------------------------------------
--- | Per-Module Pipeline -------------------------------------------------------
---------------------------------------------------------------------------------
-
-type SpecEnv = ModuleEnv (ModName, Ms.BareSpec)
-
-processModules :: Config -> LogicMap -> [FilePath] -> DepGraph -> ModuleGraph -> Ghc [TargetInfo]
-processModules cfg logicMap tgtFiles depGraph homeModules = do
-  -- DO NOT DELETE: liftIO $ putStrLn $ "Process Modules: TargetFiles = " ++ show tgtFiles
-  catMaybes . snd <$> Misc.mapAccumM go emptyModuleEnv (mgModSummaries homeModules)
-  where                                             
-    go = processModule cfg logicMap (S.fromList tgtFiles) depGraph
-
-processModule :: Config -> LogicMap -> S.HashSet FilePath -> DepGraph -> SpecEnv -> ModSummary
-              -> Ghc (SpecEnv, Maybe TargetInfo)
-processModule cfg logicMap tgtFiles depGraph specEnv modSummary = do
-  let mod              = ms_mod modSummary
-  -- DO-NOT-DELETE _                <- liftIO $ whenLoud $ putStrLn $ "Process Module: " ++ showPpr (moduleName mod)
-  file                <- liftIO $ canonicalizePath $ modSummaryHsFile modSummary
-  let isTarget         = file `S.member` tgtFiles
-  _                   <- loadDependenciesOf $ moduleName mod
-  parsed              <- parseModule $ keepRawTokenStream modSummary
-  let specComments     = extractSpecComments (pm_annotations parsed)
-  typechecked         <- typecheckModule $ ignoreInline parsed
-  let specQuotes       = extractSpecQuotes typechecked
-  _                   <- loadModule' typechecked
-  (modName, commSpec) <- either throw return $ hsSpecificationP (moduleName mod) specComments specQuotes
-
-  liftedSpec          <- liftIO $ if isTarget || null specComments then return Nothing else loadLiftedSpec cfg file 
-  let bareSpec         = updLiftedSpec commSpec liftedSpec
-  _                   <- checkFilePragmas $ Ms.pragmas bareSpec
-  let specEnv'         = extendModuleEnv specEnv mod (modName, noTerm bareSpec)
-  (specEnv', ) <$> if isTarget
-                     then Just <$> processTargetModule cfg logicMap depGraph specEnv file typechecked bareSpec
-                     else return Nothing
-
-updLiftedSpec :: Ms.BareSpec -> Maybe Ms.BareSpec -> Ms.BareSpec 
-updLiftedSpec s1 Nothing   = s1 
-updLiftedSpec s1 (Just s2) = (clearSpec s1) `mappend` s2 
-
-clearSpec :: Ms.BareSpec -> Ms.BareSpec
-clearSpec s = s { sigs = [], asmSigs = [], aliases = [], ealiases = [], qualifiers = [], dataDecls = [] }
-
-keepRawTokenStream :: ModSummary -> ModSummary
-keepRawTokenStream modSummary = modSummary
-  { ms_hspp_opts = ms_hspp_opts modSummary `gopt_set` Opt_KeepRawTokenStream }
-
-loadDependenciesOf :: GhcMonad m => ModuleName -> m ()
-loadDependenciesOf modName = do
-  loadResult <- load $ LoadDependenciesOf modName
-  when (failed loadResult) $ liftIO $ throwGhcExceptionIO $ ProgramError $
-   "Failed to load dependencies of module " ++ showPpr modName
-
-loadModule' :: TypecheckedModule -> Ghc TypecheckedModule
-loadModule' tm = loadModule tm'
-  where
-    pm   = tm_parsed_module tm
-    ms   = pm_mod_summary pm
-    df   = ms_hspp_opts ms
-    df'  = df { hscTarget = HscNothing, ghcLink = NoLink }
-    ms'  = ms { ms_hspp_opts = df' }
-    pm'  = pm { pm_mod_summary = ms' }
-    tm'  = tm { tm_parsed_module = pm' }
-
-
-processTargetModule :: Config -> LogicMap -> DepGraph -> SpecEnv -> FilePath -> TypecheckedModule -> Ms.BareSpec
-                    -> Ghc TargetInfo
-processTargetModule cfg0 logicMap depGraph specEnv file typechecked bareSpec = do
-  cfg          <- liftIO $ withPragmas cfg0 file (Ms.pragmas bareSpec)
-  let modSum    = pm_mod_summary (tm_parsed_module typechecked)
-  ghcSrc       <- makeGhcSrc    cfg file     typechecked modSum
-  dependencies <- makeDependencies cfg depGraph specEnv modSum bareSpec
-
-  let targetSrc = view targetSrcIso ghcSrc
-  dynFlags <- getDynFlags
-
-  case makeTargetSpec cfg logicMap targetSrc (view bareSpecIso bareSpec) dependencies of
-    Left diagnostics -> do
-      mapM_ (liftIO . printWarning dynFlags) (allWarnings diagnostics)
-      throw (allErrors diagnostics)
-    Right (warns, targetSpec, liftedSpec) -> do
-      mapM_ (liftIO . printWarning dynFlags) warns
-      -- The call below is temporary, we should really load & save directly 'LiftedSpec's.
-      _          <- liftIO $ saveLiftedSpec (_giTarget ghcSrc) (unsafeFromLiftedSpec liftedSpec)
-      return      $ TargetInfo targetSrc targetSpec
-
----------------------------------------------------------------------------------------
--- | @makeGhcSrc@ builds all the source-related information needed for consgen 
----------------------------------------------------------------------------------------
-
-makeGhcSrc :: Config -> FilePath -> TypecheckedModule -> ModSummary -> Ghc GhcSrc 
-makeGhcSrc cfg file typechecked modSum = do
-  modGuts'          <- GhcMonadLike.desugarModule modSum typechecked
-
-  let modGuts        = makeMGIModGuts modGuts'
-  hscEnv            <- getSession
-  coreBinds         <- liftIO $ anormalize cfg hscEnv modGuts'
-  _                 <- liftIO $ whenNormal $ Misc.donePhase Misc.Loud "A-Normalization"
-  let dataCons       = concatMap (map dataConWorkId . tyConDataCons) (mgi_tcs modGuts)
-  (fiTcs, fiDcs)    <- makeFamInstEnv <$> liftIO (getFamInstances hscEnv)
-  things            <- lookupTyThings hscEnv modSum (fst $ tm_internals_ typechecked)
-
-  availableTcs      <- availableTyCons hscEnv modSum (fst $ tm_internals_ typechecked) (mg_exports modGuts')
-
-  let impVars        = importVars coreBinds ++ classCons (mgi_cls_inst modGuts)
-  incDir            <- liftIO $ Misc.getIncludeDir
-
-  --liftIO $ do
-  --  print $ "_gsTcs   => " ++ show (nub $ (mgi_tcs      modGuts) ++ availableTcs)
-  --  print $ "_gsFiTcs => " ++ show fiTcs
-  --  print $ "_gsFiDcs => " ++ show fiDcs
-  --  print $ "dataCons => " ++ show dataCons
-  --  print $ "defVars  => " ++ show (dataCons ++ (letVars coreBinds))
-
-  return $ Src 
-    { _giIncDir    = incDir 
-    , _giTarget    = file
-    , _giTargetMod = ModName Target (moduleName (ms_mod modSum))
-    , _giCbs       = coreBinds
-    , _giImpVars   = impVars 
-    , _giDefVars   = dataCons ++ (letVars coreBinds) 
-    , _giUseVars   = readVars coreBinds
-    , _giDerVars   = S.fromList (derivedVars cfg modGuts) 
-    , _gsExports   = mgi_exports  modGuts 
-    , _gsTcs       = nub $ (mgi_tcs      modGuts) ++ availableTcs
-    , _gsCls       = mgi_cls_inst modGuts 
-    , _gsFiTcs     = fiTcs 
-    , _gsFiDcs     = fiDcs
-    , _gsPrimTcs   = TysPrim.primTyCons
-    , _gsQualImps  = qualifiedImports (maybe mempty (view _2) (tm_renamed_source typechecked))
-    , _gsAllImps   = allImports       (maybe mempty (view _2) (tm_renamed_source typechecked))
-    , _gsTyThings  = [ t | (_, Just t) <- things ] 
-    }
-
-_impThings :: [Var] -> [TyThing] -> [TyThing]
-_impThings vars  = filter ok
-  where
-    vs          = S.fromList vars 
-    ok (AnId x) = S.member x vs  
-    ok _        = True 
-
-allImports :: [LImportDecl GhcRn] -> S.HashSet Symbol 
-allImports = \case
-  []-> Debug.trace "WARNING: Missing RenamedSource" mempty 
-  imps -> S.fromList (symbol . unLoc . ideclName . unLoc <$> imps)
-
-qualifiedImports :: [LImportDecl GhcRn] -> QImports 
-qualifiedImports = \case
-  []   -> Debug.trace "WARNING: Missing RenamedSource" (qImports mempty) 
-  imps -> qImports [ (qn, n) | i         <- imps
-                                          , let decl   = unLoc i
-                                          , let m      = unLoc (ideclName decl)  
-                                          , qm        <- maybeToList (unLoc <$> ideclAs decl) 
-                                          , let [n,qn] = symbol <$> [m, qm] 
-                                          ]
-
-qImports :: [(Symbol, Symbol)] -> QImports 
-qImports qns  = QImports 
-  { qiNames   = Misc.group qns 
-  , qiModules = S.fromList (snd <$> qns) 
-  }
-
-
----------------------------------------------------------------------------------------
--- | @lookupTyThings@ grabs all the @Name@s and associated @TyThing@ known to GHC 
---   for this module; we will use this to create our name-resolution environment 
---   (see `Bare.Resolve`)                                          
----------------------------------------------------------------------------------------
-lookupTyThings :: GhcMonadLike m => HscEnv -> ModSummary -> TcGblEnv -> m [(Name, Maybe TyThing)]
-lookupTyThings hscEnv modSum tcGblEnv = forM names (lookupTyThing hscEnv modSum tcGblEnv)
-  where
-    names :: [Ghc.Name] 
-    names  = fmap Ghc.gre_name . Ghc.globalRdrEnvElts $ tcg_rdr_env tcGblEnv
-
--- | Lookup a single 'Name' in the GHC environment, yielding back the 'Name' alongside the 'TyThing',
--- if one is found.
-lookupTyThing :: GhcMonadLike m => HscEnv -> ModSummary -> TcGblEnv -> Name -> m (Name, Maybe TyThing)
-lookupTyThing hscEnv modSum tcGblEnv n = do
-  mi  <- GhcMonadLike.moduleInfoTc modSum tcGblEnv
-  tt1 <-          GhcMonadLike.lookupName      n
-  tt2 <- liftIO $ Ghc.hscTcRcLookupName hscEnv n
-  tt3 <-          GhcMonadLike.modInfoLookupName mi n
-  tt4 <-          GhcMonadLike.lookupGlobalName n
-  return (n, Misc.firstMaybes [tt1, tt2, tt3, tt4])
-
-availableTyThings :: GhcMonadLike m => HscEnv -> ModSummary -> TcGblEnv -> [AvailInfo] -> m [TyThing]
-availableTyThings hscEnv modSum tcGblEnv avails = fmap (catMaybes . mconcat) $ forM avails $ \a -> do
-  results <- case a of
-    Avail n        -> pure <$> lookupTyThing hscEnv modSum tcGblEnv n
-    AvailTC n ns _ -> forM (n : ns) $ lookupTyThing hscEnv modSum tcGblEnv
-  pure . map snd $ results
-
--- | Returns all the available (i.e. exported) 'TyCon's (type constructors) for the input 'Module'.
-availableTyCons :: GhcMonadLike m => HscEnv -> ModSummary -> TcGblEnv -> [AvailInfo] -> m [GHC.TyCon]
-availableTyCons hscEnv modSum tcGblEnv avails = 
-  fmap (\things -> [tyCon | (ATyCon tyCon) <- things]) (availableTyThings hscEnv modSum tcGblEnv avails)
-
--- | Returns all the available (i.e. exported) 'Var's for the input 'Module'.
-availableVars :: GhcMonadLike m => HscEnv -> ModSummary -> TcGblEnv -> [AvailInfo] -> m [Ghc.Var]
-availableVars hscEnv modSum tcGblEnv avails = 
-  fmap (\things -> [var | (AnId var) <- things]) (availableTyThings hscEnv modSum tcGblEnv avails)
-
--- lookupName        :: GhcMonad m => Name -> m (Maybe TyThing) 
--- hscTcRcLookupName :: HscEnv -> Name -> IO (Maybe TyThing)
--- modInfoLookupName :: GhcMonad m => ModuleInfo -> Name -> m (Maybe TyThing)  
--- lookupGlobalName  :: GhcMonad m => Name -> m (Maybe TyThing)  
-
-_dumpTypeEnv :: TypecheckedModule -> IO () 
-_dumpTypeEnv tm = do 
-  print "DUMP-TYPE-ENV"
-  print (showpp <$> tcmTyThings tm)
-
-tcmTyThings :: TypecheckedModule -> Maybe [Name] 
-tcmTyThings 
-  = id 
-  -- typeEnvElts 
-  -- . tcg_type_env . fst 
-  -- . md_types . snd
-  -- . tm_internals_
-  . modInfoTopLevelScope
-  . tm_checked_module_info
-
-
-_dumpRdrEnv :: HscEnv -> MGIModGuts -> IO () 
-_dumpRdrEnv _hscEnv modGuts = do 
-  print "DUMP-RDR-ENV" 
-  print (mgNames modGuts)
-  -- print (hscNames hscEnv) 
-  -- print (mgDeps modGuts) 
-  where 
-    _mgDeps   = Ghc.dep_mods . mgi_deps 
-    _hscNames = fmap showPpr . Ghc.ic_tythings . Ghc.hsc_IC
-
-mgNames :: MGIModGuts -> [Ghc.Name] 
-mgNames  = fmap Ghc.gre_name . Ghc.globalRdrEnvElts .  mgi_rdr_env 
-
----------------------------------------------------------------------------------------
--- | @makeDependencies@ loads BareSpec for target and imported modules 
--- /IMPORTANT(adn)/: We \"cheat\" a bit by creating a 'Module' out the 'ModuleName' we 
--- parse from the spec, and convert the former into a 'StableModule' for the purpose
--- of dependency tracking. This means, in practice, that all the \"wired-in-prelude\"
--- specs will share the same `UnitId`, which for the sake of the executable is an
--- acceptable compromise, as long as we don't create duplicates.
----------------------------------------------------------------------------------------
-makeDependencies :: Config -> DepGraph -> SpecEnv -> ModSummary -> Ms.BareSpec 
-                 -> Ghc TargetDependencies
-makeDependencies cfg depGraph specEnv modSum _ = do 
-  let paths     = S.fromList $ idirs cfg ++ importPaths (ms_hspp_opts modSum)
-  _            <- liftIO $ whenLoud $ putStrLn $ "paths = " ++ show paths
-  let reachable = reachableModules depGraph (ms_mod modSum)
-  specSpecs    <- findAndParseSpecFiles cfg paths modSum reachable
-  let homeSpecs = cachedBareSpecs specEnv reachable
-
-  -- NOTE:(adn) Unfortunately for the executable we might have 3 different 'Prelude' specs
-  -- (one for the Prelude functions, one for the Real/NonReal and one for the PatErr, so we
-  -- cannot really assume all the module names will be disjointed. As a result we have to
-  -- hack our way around this by replacing the 'UnitId' with some unique enumeration, at
-  -- least unique in this local scope.
-
-  let combine ix (mn, sp) = ((mn, ix), sp)
-  let impSpecs  = map (bimap mkStableModule (view liftedSpecGetter)) (zipWith combine [0..] (specSpecs ++ homeSpecs))
-
-  return        $ TargetDependencies $ HM.fromList impSpecs
-  where
-    mkStableModule :: (ModName, Int) -> StableModule
-    mkStableModule (modName, ix) = 
-      toStableModule (Module (fakeUnitId (moduleUnitId targetModule) ix) (getModName modName))
-
-    fakeUnitId :: UnitId -> Int -> UnitId
-    fakeUnitId uid ix = stringToUnitId $ unitIdString uid ++ show ix
-
-    targetModule :: Module
-    targetModule = ms_mod modSum
-
-modSummaryHsFile :: ModSummary -> FilePath
-modSummaryHsFile modSummary =
-  fromMaybe
-    (panic Nothing $
-      "modSummaryHsFile: missing .hs file for " ++
-      showPpr (ms_mod modSummary))
-    (ml_hs_file $ ms_location modSummary)
-
-cachedBareSpecs :: SpecEnv -> [Module] -> [(ModName, Ms.BareSpec)]
-cachedBareSpecs specEnv mods = lookupBareSpec <$> mods
-  where
-    lookupBareSpec m         = fromMaybe (err m) (lookupModuleEnv specEnv m)
-    err m                    = impossible Nothing ("lookupBareSpec: missing module " ++ showPpr m)
-
-checkFilePragmas :: GhcMonadLike m => [Located String] -> m ()
-checkFilePragmas = Misc.applyNonNull (return ()) throw . mapMaybe err
-  where
-    err pragma
-      | check (val pragma) = Just (ErrFilePragma $ fSrcSpan pragma :: Error)
-      | otherwise          = Nothing
-    check pragma           = any (`isPrefixOf` pragma) bad
-    bad =
-      [ "-i", "--idirs"
-      , "-g", "--ghc-option"
-      , "--c-files", "--cfiles"
-      ]
-
---------------------------------------------------------------------------------
--- | Family instance information
---------------------------------------------------------------------------------
-makeFamInstEnv :: [FamInst] -> ([GHC.TyCon], [(Symbol, DataCon)])
-makeFamInstEnv famInsts =
-  let fiTcs = [ tc            | FamInst { fi_flavor = DataFamilyInst tc } <- famInsts ]
-      fiDcs = [ (symbol d, d) | tc <- fiTcs, d <- tyConDataCons tc ]
-  in (fiTcs, fiDcs)
-
-getFamInstances :: HscEnv -> IO [FamInst]
-getFamInstances env = do
-  (_, Just (pkg_fie, home_fie)) <- runTcInteractive env tcGetFamInstEnvs
-  return $ famInstEnvElts home_fie ++ famInstEnvElts pkg_fie
- 
---------------------------------------------------------------------------------
--- | Extract Specifications from GHC -------------------------------------------
---------------------------------------------------------------------------------
-extractSpecComments :: ApiAnns -> [(SourcePos, String)]
-extractSpecComments = mapMaybe extractSpecComment
-                    . concat
-                    . M.elems
-                    . snd
-
-
--- | 'extractSpecComment' pulls out the specification part from a full comment
---   string, i.e. if the string is of the form:
---   1. '{-@ S @-}' then it returns the substring 'S',
---   2. '{-@ ... -}' then it throws a malformed SPECIFICATION ERROR, and
---   3. Otherwise it is just treated as a plain comment so we return Nothing.
-extractSpecComment :: GHC.Located AnnotationComment -> Maybe (SourcePos, String)
-
-extractSpecComment (GHC.L sp (AnnBlockComment text))
-  | isPrefixOf "{-@" text && isSuffixOf "@-}" text          -- valid   specification
-  = Just (offsetPos, take (length text - 6) $ drop 3 text)
-  | isPrefixOf "{-@" text                                   -- invalid specification
-  = uError $ ErrParseAnn sp "A valid specification must have a closing '@-}'."
-  where
-    offsetPos = incSourceColumn (srcSpanSourcePos sp) 3
-extractSpecComment _ = Nothing
-
-extractSpecQuotes :: TypecheckedModule -> [BPspec]
-extractSpecQuotes = 
-  extractSpecQuotes' (ms_mod . pm_mod_summary . tm_parsed_module) 
-                     (tcg_anns . fst . tm_internals_)
-
-extractSpecQuotes' :: (a -> Module) -> (a -> [Annotation]) -> a -> [BPspec]
-extractSpecQuotes' thisModule getAnns a = mapMaybe extractSpecQuote anns
-  where
-    anns = map ann_value $
-           filter (isOurModTarget . ann_target) $
-           getAnns a
-
-    isOurModTarget (ModuleTarget mod1) = mod1 == thisModule a
-    isOurModTarget _ = False
-
-extractSpecQuote :: AnnPayload -> Maybe BPspec
-extractSpecQuote payload = 
-  case fromSerialized deserializeWithData payload of
-    Nothing -> Nothing
-    Just qt -> Just $ refreshSymbols $ liquidQuoteSpec qt
-
-refreshSymbols :: Data a => a -> a
-refreshSymbols = everywhere (mkT refreshSymbol)
-
-refreshSymbol :: Symbol -> Symbol
-refreshSymbol = symbol . symbolText
-
---------------------------------------------------------------------------------
--- | Finding & Parsing Files ---------------------------------------------------
---------------------------------------------------------------------------------
-
--- | Handle Spec Files ---------------------------------------------------------
-
-findAndParseSpecFiles :: GhcMonadLike m
-                      => Config
-                      -> S.HashSet FilePath
-                      -> ModSummary
-                      -> [Module]
-                      -> m [(ModName, Ms.BareSpec)]
-findAndParseSpecFiles cfg paths modSummary reachable = do
-  modGraph <- GhcMonadLike.getModuleGraph
-  impSumms <- mapM GhcMonadLike.getModSummary (moduleName <$> reachable)
-  imps''   <- nub . concat <$> mapM modSummaryImports (modSummary : impSumms)
-  imps'    <- filterM ((not <$>) . isHomeModule) imps''
-  let imps  = m2s <$> imps'
-  fs'      <- liftIO $ moduleFiles modGraph Spec paths imps
-  -- liftIO  $ whenLoud  $ print ("moduleFiles-imps'': "  ++ show (m2s <$> imps''))
-  -- liftIO  $ whenLoud  $ print ("moduleFiles-imps' : "  ++ show (m2s <$> imps'))
-  -- liftIO  $ whenLoud  $ print ("moduleFiles-imps  : "  ++ show imps)
-  -- liftIO  $ whenLoud  $ print ("moduleFiles-Paths : "  ++ show paths)
-  -- liftIO  $ whenLoud  $ print ("moduleFiles-Specs : "  ++ show fs')
-  patSpec  <- liftIO $ getPatSpec  modGraph paths $ totalityCheck cfg
-  rlSpec   <- liftIO $ getRealSpec modGraph paths $ not (linear cfg)
-  let fs    = patSpec ++ rlSpec ++ fs'
-  liftIO $ transParseSpecs modGraph paths mempty mempty fs
-  where
-    m2s = moduleNameString . moduleName
-
-getPatSpec :: ModuleGraph -> S.HashSet FilePath -> Bool -> IO [FilePath]
-getPatSpec modGraph paths totalitycheck
- | totalitycheck = moduleFiles modGraph Spec paths [patErrorName]
- | otherwise     = return []
- where
-  patErrorName   = "PatErr"
-
-getRealSpec :: ModuleGraph -> S.HashSet FilePath -> Bool -> IO [FilePath]
-getRealSpec modGraph paths freal
-  | freal     = moduleFiles modGraph Spec paths [realSpecName]
-  | otherwise = moduleFiles modGraph Spec paths [notRealSpecName]
-  where
-    realSpecName    = "Real"
-    notRealSpecName = "NotReal"
-
-transParseSpecs :: ModuleGraph
-                -> S.HashSet FilePath
-                -> S.HashSet FilePath 
-                -> [(ModName, Ms.BareSpec)]
-                -> [FilePath]
-                -> IO [(ModName, Ms.BareSpec)]
-transParseSpecs _ _ _ specs [] = return specs
-transParseSpecs modGraph paths seenFiles specs newFiles = do
-  -- liftIO $ print ("TRANS-PARSE-SPECS", seenFiles, newFiles)
-  newSpecs      <- liftIO $ mapM parseSpecFile newFiles
-  impFiles      <- moduleFiles modGraph Spec paths $ specsImports newSpecs
-  let seenFiles' = seenFiles `S.union` S.fromList newFiles
-  let specs'     = specs ++ map (second noTerm) newSpecs
-  let newFiles'  = filter (not . (`S.member` seenFiles')) impFiles
-  transParseSpecs modGraph paths seenFiles' specs' newFiles'
-  where
-    specsImports ss = nub $ concatMap (map symbolString . Ms.imports . snd) ss
-
-noTerm :: Ms.BareSpec -> Ms.BareSpec
-noTerm spec = spec { Ms.decr = mempty, Ms.lazy = mempty, Ms.termexprs = mempty }
-
-parseSpecFile :: FilePath -> IO (ModName, Ms.BareSpec)
-parseSpecFile file = either throw return . specSpecificationP file =<< Misc.sayReadFile file
-
--- Find Hquals Files -----------------------------------------------------------
-
--- _moduleHquals :: MGIModGuts
---              -> [FilePath]
---              -> FilePath
---              -> [String]
---              -> [FilePath]
---              -> Ghc [FilePath]
--- _moduleHquals mgi paths target imps incs = do
---   hqs   <- specIncludes Hquals paths incs
---   hqs'  <- moduleFiles Hquals paths (mgi_namestring mgi : imps)
---   hqs'' <- liftIO $ filterM doesFileExist [extFileName Hquals target]
---   return $ Misc.sortNub $ hqs'' ++ hqs ++ hqs'
-
--- Find Files for Modules ------------------------------------------------------
-
-moduleFiles :: ModuleGraph -> Ext -> S.HashSet FilePath -> [String] -> IO [FilePath]
-moduleFiles modGraph ext paths names = catMaybes <$> mapM (moduleFile modGraph ext paths) names
-
-moduleFile :: ModuleGraph -> Ext -> S.HashSet FilePath -> String -> IO (Maybe FilePath)
-moduleFile modGraph ext (S.toList -> paths) name
-  | ext `elem` [Hs, LHs] = do
-    let graph = mgModSummaries modGraph
-    case find (\m -> not (isBootSummary m) &&
-                     name == moduleNameString (ms_mod_name m)) graph of
-      Nothing -> getFileInDirs (extModuleName name ext) paths
-      Just ms -> return $ normalise <$> ml_hs_file (ms_location ms)
-  | otherwise = getFileInDirs (extModuleName name ext) paths
-
---------------------------------------------------------------------------------
--- Assemble Information for Spec Extraction ------------------------------------
---------------------------------------------------------------------------------
-
-makeMGIModGuts :: ModGuts -> MGIModGuts
-makeMGIModGuts modGuts = miModGuts deriv modGuts
-  where
-    deriv   = Just $ instEnvElts $ mg_inst_env modGuts
-
-makeLogicMap :: IO LogicMap
-makeLogicMap = do
-  lg    <- Misc.getCoreToLogicPath
-  lspec <- Misc.sayReadFile lg
-  case parseSymbolToLogic lg lspec of 
-    Left e   -> throw e 
-    Right lm -> return (lm <> listLMap)
-
-listLMap :: LogicMap -- TODO-REBARE: move to wiredIn
-listLMap  = toLogicMap [ (dummyLoc nilName , []     , hNil)
-                       , (dummyLoc consName, [x, xs], hCons (EVar <$> [x, xs])) ]
-  where
-    x     = "x"
-    xs    = "xs"
-    hNil  = mkEApp (dcSym Ghc.nilDataCon ) []
-    hCons = mkEApp (dcSym Ghc.consDataCon)
-    dcSym = dummyLoc . dropModuleUnique . symbol
-
-
-
---------------------------------------------------------------------------------
--- | Pretty Printing -----------------------------------------------------------
---------------------------------------------------------------------------------
-
-instance PPrint TargetSpec where
-  pprintTidy k spec = vcat
-    [ "******* Target Variables ********************"
-    , pprintTidy k $ gsTgtVars (gsVars spec)
-    , "******* Type Signatures *********************"
-    , pprintLongList k (gsTySigs (gsSig spec))
-    , "******* Assumed Type Signatures *************"
-    , pprintLongList k (gsAsmSigs (gsSig spec))
-    , "******* DataCon Specifications (Measure) ****"
-    , pprintLongList k (gsCtors (gsData spec))
-    , "******* Measure Specifications **************"
-    , pprintLongList k (gsMeas (gsData spec))       ]
-
-instance PPrint TargetInfo where
-  pprintTidy k info = vcat
-    [ -- "*************** Imports *********************"
-      -- , intersperse comma $ text <$> imports info
-      -- , "*************** Includes ********************"
-      -- , intersperse comma $ text <$> includes info
-      "*************** Imported Variables **********"
-    , pprDoc $ _giImpVars (review targetSrcIso $ giSrc info)
-    , "*************** Defined Variables ***********"
-    , pprDoc $ _giDefVars (review targetSrcIso $ giSrc info)
-    , "*************** Specification ***************"
-    , pprintTidy k $ giSpec info
-    , "*************** Core Bindings ***************"
-    , pprintCBs $ _giCbs (review targetSrcIso $ giSrc info) ]
-
--- RJ: the silly guards below are to silence the unused-var checker
-pprintCBs :: [CoreBind] -> Doc
-pprintCBs
-  | otherwise = pprintCBsTidy
-  | otherwise = pprintCBsVerbose
-  where
-    pprintCBsTidy    = pprDoc . tidyCBs
-    pprintCBsVerbose = text . O.showSDocDebug unsafeGlobalDynFlags . O.ppr . tidyCBs
-
-instance Show TargetInfo where
-  show = showpp
-
-instance PPrint TargetVars where
-  pprintTidy _ AllVars   = text "All Variables"
-  pprintTidy k (Only vs) = text "Only Variables: " <+> pprintTidy k vs
-
-------------------------------------------------------------------------
--- Dealing with Errors ---------------------------------------------------
-------------------------------------------------------------------------
-
-instance Result SourceError where
-  result = (`Crash` "Invalid Source") . sourceErrors ""
diff --git a/src/Language/Haskell/Liquid/GHC/Logging.hs b/src/Language/Haskell/Liquid/GHC/Logging.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Logging.hs
+++ /dev/null
@@ -1,65 +0,0 @@
-{- | This module exposes variations over the standard GHC's logging functions to work with the 'Doc'
-     type from the \"pretty\" package. We would like LiquidHaskell to emit diagnostic messages using the very
-     same GHC machinery, so that IDE-like programs (e.g. \"ghcid\", \"ghcide\" etc) would be able to
-     correctly show errors and warnings to the users, in ther editors.
-
-     Unfortunately, this is not possible to do out of the box because LiquidHaskell uses the 'Doc' type from
-     the \"pretty\" package but GHC uses (for historical reasons) its own version. Due to the fact none of
-     the constructors are exported, we simply cannot convert between the two types effortlessly, but we have
-     to pay the price of a pretty-printing \"roundtrip\".
--}
-
-module Language.Haskell.Liquid.GHC.Logging (
-    fromPJDoc
-  , putLogMsg
-  , putWarnMsg
-  , putErrMsg
-  , putErrMsg'
-  , mkLongErrAt
-  ) where
-
-import Data.Maybe
-
-import qualified TcRnMonad as GHC
-
-import qualified Language.Haskell.Liquid.GHC.API as GHC
-import qualified Text.PrettyPrint.HughesPJ as PJ
-import qualified Outputable as O
-
--- Unfortunately we need the import below to bring in scope 'PPrint' instances.
-import Language.Haskell.Liquid.Types.Errors ()
-
-fromPJDoc :: PJ.Doc -> O.SDoc
-fromPJDoc = O.text . PJ.render
-
--- | Like the original 'putLogMsg', but internally converts the input 'Doc' (from the \"pretty\" library)
--- into GHC's internal 'SDoc'.
-putLogMsg :: GHC.DynFlags
-          -> GHC.WarnReason
-          -> GHC.Severity
-          -> GHC.SrcSpan
-          -> Maybe O.PprStyle
-          -> PJ.Doc
-          -> IO ()
-putLogMsg dynFlags reason sev srcSpan mbStyle =
-  GHC.putLogMsg dynFlags reason sev srcSpan style' . O.text . PJ.render
-  where
-    style' :: O.PprStyle
-    style' = fromMaybe (O.defaultErrStyle dynFlags) mbStyle
-
-putWarnMsg :: GHC.DynFlags -> GHC.SrcSpan -> PJ.Doc -> IO ()
-putWarnMsg dynFlags srcSpan doc =
-  putLogMsg dynFlags GHC.NoReason GHC.SevWarning srcSpan (Just $ O.defaultErrStyle dynFlags) doc
-
-putErrMsg :: GHC.DynFlags -> GHC.SrcSpan -> PJ.Doc -> IO ()
-putErrMsg dynFlags srcSpan doc = putLogMsg dynFlags GHC.NoReason GHC.SevError srcSpan Nothing doc
-
--- | Like 'putErrMsg', but it uses GHC's internal 'Doc'. This can be very convenient when logging things
--- which comes directly from GHC rather than LiquidHaskell.
-putErrMsg' :: GHC.DynFlags -> GHC.SrcSpan -> O.SDoc -> IO ()
-putErrMsg' dynFlags srcSpan =
-  GHC.putLogMsg dynFlags GHC.NoReason GHC.SevError srcSpan (O.defaultErrStyle dynFlags)
-
--- | Like GHC's 'mkLongErrAt', but it builds the final 'ErrMsg' out of two \"HughesPJ\"'s 'Doc's.
-mkLongErrAt :: GHC.SrcSpan -> PJ.Doc -> PJ.Doc -> GHC.TcRn GHC.ErrMsg
-mkLongErrAt srcSpan msg extra = GHC.mkLongErrAt srcSpan (fromPJDoc msg) (fromPJDoc extra)
diff --git a/src/Language/Haskell/Liquid/GHC/Misc.hs b/src/Language/Haskell/Liquid/GHC/Misc.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Misc.hs
+++ /dev/null
@@ -1,781 +0,0 @@
-{-# LANGUAGE CPP                       #-}
-{-# LANGUAGE OverloadedStrings         #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE GADTs                     #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE RankNTypes                #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE UndecidableInstances      #-}
-{-# LANGUAGE ViewPatterns              #-}
-{-# LANGUAGE PatternSynonyms           #-}
-
--- | This module contains a wrappers and utility functions for
--- accessing GHC module information. It should NEVER depend on
--- ANY module inside the Language.Haskell.Liquid.* tree.
-
-module Language.Haskell.Liquid.GHC.Misc where
-
-import           Data.String
-import qualified Data.List as L
-import           PrelNames                                  (fractionalClassKeys)
-import           Debug.Trace
-
-import qualified CoreUtils
-import qualified DataCon                                    -- (dataConInstArgTys, isTupleDataCon)
-import           Prelude                                    hiding (error)
-import           CoreSyn                                    hiding (Expr, sourceName)
-import qualified CoreSyn                                    as Core
-import           CostCentre
-import           Language.Haskell.Liquid.GHC.API            as Ghc hiding (L, sourceName)
-import           Bag
-import           CoreLint
-import           CoreMonad
-
-import           Text.Parsec.Pos                            (incSourceColumn, sourceName, sourceLine, sourceColumn, newPos)
-
-import           Finder                                     (findImportedModule, cannotFindModule)
-import           Panic                                      (throwGhcException)
-import           TcRnDriver
--- import           TcRnTypes
-
-
-import           IdInfo
-import qualified TyCon                                      as TC
-import           Data.Char                                  (isLower, isSpace, isUpper)
-import           Data.Maybe                                 (isJust, fromMaybe, fromJust)
-import           Data.Hashable
-import qualified Data.HashSet                               as S
-
-import qualified Data.Text.Encoding.Error                   as TE
-import qualified Data.Text.Encoding                         as T
-import qualified Data.Text                                  as T
-import           Control.Arrow                              (second)
-import           Control.Monad                              ((>=>))
-import           Outputable                                 (Outputable (..), text, ppr)
-import qualified Outputable                                 as Out
-import qualified Text.PrettyPrint.HughesPJ                  as PJ
-import           Language.Fixpoint.Types                    hiding (L, panic, Loc (..), SrcSpan, Constant, SESearch (..))
-import qualified Language.Fixpoint.Types                    as F
-import           Language.Fixpoint.Misc                     (safeHead) -- , safeLast, safeInit)
-import           Language.Haskell.Liquid.Misc               (keyDiff) 
-import           Control.DeepSeq
-import           Language.Haskell.Liquid.Types.Errors
-
-
-isAnonBinder :: TC.TyConBinder -> Bool
-isAnonBinder (Bndr _ (AnonTCB _)) = True
-isAnonBinder (Bndr _ _)           = False
-
-mkAlive :: Var -> Id
-mkAlive x
-  | isId x && isDeadOcc (idOccInfo x)
-  = setIdInfo x (setOccInfo (idInfo x) noOccInfo)
-  | otherwise
-  = x
-
-
---------------------------------------------------------------------------------
--- | Encoding and Decoding Location --------------------------------------------
---------------------------------------------------------------------------------
-srcSpanTick :: Module -> SrcSpan -> Tickish a
-srcSpanTick m sp = ProfNote (AllCafsCC m sp) False True
-
-tickSrcSpan ::  Outputable a => Tickish a -> SrcSpan
-tickSrcSpan (ProfNote cc _ _) = cc_loc cc
-tickSrcSpan (SourceNote ss _) = RealSrcSpan ss
-tickSrcSpan _                 = noSrcSpan
-
---------------------------------------------------------------------------------
--- | Generic Helpers for Accessing GHC Innards ---------------------------------
---------------------------------------------------------------------------------
-
--- FIXME: reusing uniques like this is really dangerous
-stringTyVar :: String -> TyVar
-stringTyVar s = mkTyVar name liftedTypeKind
-  where 
-    name      = mkInternalName (mkUnique 'x' 24)  occ noSrcSpan
-    occ       = mkTyVarOcc s
-
--- FIXME: reusing uniques like this is really dangerous
-stringVar :: String -> Type -> Var
-stringVar s t = mkLocalVar VanillaId name t vanillaIdInfo
-   where
-      name = mkInternalName (mkUnique 'x' 25) occ noSrcSpan
-      occ  = mkVarOcc s
-
-stringTyCon :: Char -> Int -> String -> TyCon
-stringTyCon = stringTyConWithKind anyTy
-
--- FIXME: reusing uniques like this is really dangerous
-stringTyConWithKind :: Kind -> Char -> Int -> String -> TyCon
-stringTyConWithKind k c n s = TC.mkKindTyCon name [] k [] name
-  where
-    name          = mkInternalName (mkUnique c n) occ noSrcSpan
-    occ           = mkTcOcc s
-
-hasBaseTypeVar :: Var -> Bool
-hasBaseTypeVar = isBaseType . varType
-
--- same as Constraint isBase
-isBaseType :: Type -> Bool
-isBaseType (ForAllTy _ _)  = False
-isBaseType (FunTy { ft_arg = t1, ft_res = t2}) = isBaseType t1 && isBaseType t2
-isBaseType (TyVarTy _)     = True
-isBaseType (TyConApp _ ts) = all isBaseType ts
-isBaseType (AppTy t1 t2)   = isBaseType t1 && isBaseType t2
-isBaseType _               = False
-
-isTmpVar :: Var -> Bool 
-isTmpVar = isTmpSymbol . dropModuleNamesAndUnique . symbol 
-
-isTmpSymbol    :: Symbol -> Bool
-isTmpSymbol x  = any (`isPrefixOfSym` x) [anfPrefix, tempPrefix, "ds_"]
-
-validTyVar :: String -> Bool
-validTyVar s@(c:_) = isLower c && all (not . isSpace) s
-validTyVar _       = False
-
-tvId :: TyVar -> String
-tvId α = {- traceShow ("tvId: α = " ++ show α) $ -} showPpr α ++ show (varUnique α)
-
-tidyCBs :: [CoreBind] -> [CoreBind]
-tidyCBs = map unTick
-
-unTick :: CoreBind -> CoreBind
-unTick (NonRec b e) = NonRec b (unTickExpr e)
-unTick (Rec bs)     = Rec $ map (second unTickExpr) bs
-
-unTickExpr :: CoreExpr -> CoreExpr
-unTickExpr (App e a)          = App (unTickExpr e) (unTickExpr a)
-unTickExpr (Lam b e)          = Lam b (unTickExpr e)
-unTickExpr (Let b e)          = Let (unTick b) (unTickExpr e)
-unTickExpr (Case e b t as)    = Case (unTickExpr e) b t (map unTickAlt as)
-    where unTickAlt (a, b, e) = (a, b, unTickExpr e)
-unTickExpr (Cast e c)         = Cast (unTickExpr e) c
-unTickExpr (Tick _ e)         = unTickExpr e
-unTickExpr x                  = x
-
-isFractionalClass :: Class -> Bool
-isFractionalClass clas = classKey clas `elem` fractionalClassKeys
-
---------------------------------------------------------------------------------
--- | Pretty Printers -----------------------------------------------------------
---------------------------------------------------------------------------------
-notracePpr :: Outputable a => String -> a -> a
-notracePpr _ x = x
-
-tracePpr :: Outputable a => String -> a -> a
-tracePpr s x = trace ("\nTrace: [" ++ s ++ "] : " ++ showPpr x) x
-
-pprShow :: Show a => a -> Out.SDoc
-pprShow = text . show
-
-
-toFixSDoc :: Fixpoint a => a -> PJ.Doc
-toFixSDoc = PJ.text . PJ.render . toFix
-
-sDocDoc :: Out.SDoc -> PJ.Doc
-sDocDoc   = PJ.text . showSDoc
-
-pprDoc :: Outputable a => a -> PJ.Doc
-pprDoc    = sDocDoc . ppr
-
--- Overriding Outputable functions because they now require DynFlags!
-showPpr :: Outputable a => a -> String
-showPpr       = showSDoc . ppr
-
--- FIXME: somewhere we depend on this printing out all GHC entities with
--- fully-qualified names...
-showSDoc :: Out.SDoc -> String
-showSDoc sdoc = Out.renderWithStyle unsafeGlobalDynFlags sdoc (Out.mkUserStyle unsafeGlobalDynFlags myQualify {- Out.alwaysQualify -} Out.AllTheWay)
-
-myQualify :: Out.PrintUnqualified
-myQualify = Out.neverQualify { Out.queryQualifyName = Out.alwaysQualifyNames }
--- { Out.queryQualifyName = \_ _ -> Out.NameNotInScope1 }
-
-showSDocDump :: Out.SDoc -> String
-showSDocDump  = Out.showSDocDump unsafeGlobalDynFlags
-
-instance Outputable a => Outputable (S.HashSet a) where
-  ppr = ppr . S.toList
-
-typeUniqueString :: Outputable a => a -> String
-typeUniqueString = {- ("sort_" ++) . -} showSDocDump . ppr
-
-
---------------------------------------------------------------------------------
--- | Manipulating Source Spans -------------------------------------------------
---------------------------------------------------------------------------------
-
-newtype Loc    = L (Int, Int) deriving (Eq, Ord, Show)
-
-instance Hashable Loc where
-  hashWithSalt i (L z) = hashWithSalt i z
-
---instance (Uniquable a) => Hashable a where
-
-instance Hashable SrcSpan where
-  hashWithSalt i (UnhelpfulSpan s) = hashWithSalt i (uniq s)
-  hashWithSalt i (RealSrcSpan s)   = hashWithSalt i (srcSpanStartLine s, srcSpanStartCol s, srcSpanEndCol s)
-
-fSrcSpan :: (F.Loc a) => a -> SrcSpan
-fSrcSpan = fSrcSpanSrcSpan . F.srcSpan
-
-fSourcePos :: (F.Loc a) => a -> F.SourcePos 
-fSourcePos = F.sp_start . F.srcSpan 
-
-fSrcSpanSrcSpan :: F.SrcSpan -> SrcSpan
-fSrcSpanSrcSpan (F.SS p p') = sourcePos2SrcSpan p p'
-
-srcSpanFSrcSpan :: SrcSpan -> F.SrcSpan
-srcSpanFSrcSpan sp = F.SS p p'
-  where
-    p              = srcSpanSourcePos sp
-    p'             = srcSpanSourcePosE sp
-
-sourcePos2SrcSpan :: SourcePos -> SourcePos -> SrcSpan
-sourcePos2SrcSpan p p' = RealSrcSpan $ realSrcSpan f l c l' c'
-  where
-    (f, l,  c)         = F.sourcePosElts p
-    (_, l', c')        = F.sourcePosElts p'
-
-sourcePosSrcSpan   :: SourcePos -> SrcSpan
-sourcePosSrcSpan p = sourcePos2SrcSpan p (incSourceColumn p 1)
-
-sourcePosSrcLoc    :: SourcePos -> SrcLoc
-sourcePosSrcLoc p = mkSrcLoc (fsLit file) line col
-  where
-    file          = sourceName p
-    line          = sourceLine p
-    col           = sourceColumn p
-
-srcSpanSourcePos :: SrcSpan -> SourcePos
-srcSpanSourcePos (UnhelpfulSpan _) = dummyPos "<no source information>"
-srcSpanSourcePos (RealSrcSpan s)   = realSrcSpanSourcePos s
-
-srcSpanSourcePosE :: SrcSpan -> SourcePos
-srcSpanSourcePosE (UnhelpfulSpan _) = dummyPos "<no source information>"
-srcSpanSourcePosE (RealSrcSpan s)   = realSrcSpanSourcePosE s
-
-srcSpanFilename :: SrcSpan -> String
-srcSpanFilename    = maybe "" unpackFS . srcSpanFileName_maybe
-
-srcSpanStartLoc :: RealSrcSpan -> Loc
-srcSpanStartLoc l  = L (srcSpanStartLine l, srcSpanStartCol l)
-
-srcSpanEndLoc :: RealSrcSpan -> Loc
-srcSpanEndLoc l    = L (srcSpanEndLine l, srcSpanEndCol l)
-
-
-oneLine :: RealSrcSpan -> Bool
-oneLine l          = srcSpanStartLine l == srcSpanEndLine l
-
-lineCol :: RealSrcSpan -> (Int, Int)
-lineCol l          = (srcSpanStartLine l, srcSpanStartCol l)
-
-realSrcSpanSourcePos :: RealSrcSpan -> SourcePos
-realSrcSpanSourcePos s = newPos file line col
-  where
-    file               = unpackFS $ srcSpanFile s
-    line               = srcSpanStartLine       s
-    col                = srcSpanStartCol        s
-
-
-realSrcSpanSourcePosE :: RealSrcSpan -> SourcePos
-realSrcSpanSourcePosE s = newPos file line col
-  where
-    file                = unpackFS $ srcSpanFile s
-    line                = srcSpanEndLine       s
-    col                 = srcSpanEndCol        s
-
-getSourcePos :: NamedThing a => a -> SourcePos
-getSourcePos = srcSpanSourcePos  . getSrcSpan
-
-getSourcePosE :: NamedThing a => a -> SourcePos
-getSourcePosE = srcSpanSourcePosE . getSrcSpan
-
-locNamedThing :: NamedThing a => a -> F.Located a
-locNamedThing x = F.Loc l lE x
-  where
-    l          = getSourcePos  x
-    lE         = getSourcePosE x
-
-instance F.Loc Var where 
-  srcSpan v = SS (getSourcePos v) (getSourcePosE v) 
-
-namedLocSymbol :: (F.Symbolic a, NamedThing a) => a -> F.Located F.Symbol
-namedLocSymbol d = F.symbol <$> locNamedThing d
-
-varLocInfo :: (Type -> a) -> Var -> F.Located a
-varLocInfo f x = f . varType <$> locNamedThing x
-
-namedPanic :: (NamedThing a) => a -> String -> b
-namedPanic x msg = panic (Just (getSrcSpan x)) msg
-
---------------------------------------------------------------------------------
--- | Manipulating CoreExpr -----------------------------------------------------
---------------------------------------------------------------------------------
-
-collectArguments :: Int -> CoreExpr -> [Var]
-collectArguments n e = if length xs > n then take n xs else xs
-  where
-    (vs', e')        = collectValBinders' $ snd $ collectTyBinders e
-    vs               = fst $ collectBinders $ ignoreLetBinds e'
-    xs               = vs' ++ vs
-
-{-
-collectTyBinders :: CoreExpr -> ([Var], CoreExpr)
-collectTyBinders expr
-  = go [] expr
-  where
-    go tvs (Lam b e) | isTyVar b = go (b:tvs) e
-    go tvs e                     = (reverse tvs, e)
--}
-
-collectValBinders' :: Core.Expr Var -> ([Var], Core.Expr Var)
-collectValBinders' = go []
-  where
-    go tvs (Lam b e) | isTyVar b = go tvs     e
-    go tvs (Lam b e) | isId    b = go (b:tvs) e
-    go tvs (Tick _ e)            = go tvs e
-    go tvs e                     = (reverse tvs, e)
-
-ignoreLetBinds :: Core.Expr t -> Core.Expr t
-ignoreLetBinds (Let (NonRec _ _) e')
-  = ignoreLetBinds e'
-ignoreLetBinds e
-  = e
-
---------------------------------------------------------------------------------
--- | Predicates on CoreExpr and DataCons ---------------------------------------
---------------------------------------------------------------------------------
-
-isTupleId :: Id -> Bool
-isTupleId = maybe False DataCon.isTupleDataCon . idDataConM
-
-idDataConM :: Id -> Maybe DataCon
-idDataConM x = case idDetails x of
-  DataConWorkId d -> Just d
-  DataConWrapId d -> Just d
-  _               -> Nothing 
-
-isDataConId :: Id -> Bool
-isDataConId = isJust . idDataConM
-
-getDataConVarUnique :: Var -> Unique
-getDataConVarUnique v
-  | isId v && isDataConId v = getUnique (idDataCon v)
-  | otherwise               = getUnique v
-
-isDictionaryExpression :: Core.Expr Id -> Maybe Id
-isDictionaryExpression (Tick _ e) = isDictionaryExpression e
-isDictionaryExpression (Var x)    | isDictionary x = Just x
-isDictionaryExpression _          = Nothing
-
-realTcArity :: TyCon -> Arity
-realTcArity = tyConArity
-
-{-
-  tracePpr ("realTcArity of " ++ showPpr c
-     ++ "\n tyConKind = " ++ showPpr (tyConKind c)
-     ++ "\n kindArity = " ++ show (kindArity (tyConKind c))
-     ++ "\n kindArity' = " ++ show (kindArity' (tyConKind c)) -- this works for TypeAlias
-     ) $ kindArity' (tyConKind c)
--}
-
-kindTCArity :: TyCon -> Arity
-kindTCArity = go . tyConKind
-  where
-    go (FunTy { ft_res = res}) = 1 + go res
-    go _               = 0
-
-
-kindArity :: Kind -> Arity
-kindArity (ForAllTy _ res)
-  = 1 + kindArity res
-kindArity _
-  = 0
-
-uniqueHash :: Uniquable a => Int -> a -> Int
-uniqueHash i = hashWithSalt i . getKey . getUnique
-
--- slightly modified version of DynamicLoading.lookupRdrNameInModule
-lookupRdrName :: HscEnv -> ModuleName -> RdrName -> IO (Maybe Name)
-lookupRdrName hsc_env mod_name rdr_name = do
-    -- First find the package the module resides in by searching exposed packages and home modules
-    found_module <- findImportedModule hsc_env mod_name Nothing
-    case found_module of
-        Found _ mod -> do
-            -- Find the exports of the module
-            (_, mb_iface) <- getModuleInterface hsc_env mod
-            case mb_iface of
-                Just iface -> do
-                    -- Try and find the required name in the exports
-                    let decl_spec = ImpDeclSpec { is_mod = mod_name, is_as = mod_name
-                                                , is_qual = False, is_dloc = noSrcSpan }
-                        provenance = Just $ ImpSpec decl_spec ImpAll
-                        env = case mi_globals iface of
-                                Nothing -> mkGlobalRdrEnv (gresFromAvails provenance (mi_exports iface))
-                                Just e -> e
-                    case lookupGRE_RdrName rdr_name env of
-                        [gre] -> return (Just (gre_name gre))
-                        []    -> return Nothing
-                        _     -> Out.panic "lookupRdrNameInModule"
-                Nothing -> throwCmdLineErrorS dflags $ Out.hsep [Out.ptext (sLit "Could not determine the exports of the module"), ppr mod_name]
-        err -> throwCmdLineErrorS dflags $ cannotFindModule dflags mod_name err
-  where dflags = hsc_dflags hsc_env
-        throwCmdLineErrorS dflags = throwCmdLineError . Out.showSDoc dflags
-        throwCmdLineError = throwGhcException . CmdLineError
-
--- qualImportDecl :: ModuleName -> ImportDecl name
--- qualImportDecl mn = (simpleImportDecl mn) { ideclQualified = True }
-
-ignoreInline :: ParsedModule -> ParsedModule
-ignoreInline x = x {pm_parsed_source = go <$> pm_parsed_source x}
-  where 
-    go :: HsModule GhcPs -> HsModule GhcPs
-    go  x      = x {hsmodDecls = filter go' (hsmodDecls x) }
-    go' :: LHsDecl GhcPs -> Bool
-    go' x 
-      | SigD _ (InlineSig {}) <-  unLoc x = False
-      | otherwise                         = True
-
---------------------------------------------------------------------------------
--- | Symbol Conversions --------------------------------------------------------
---------------------------------------------------------------------------------
-
-symbolTyConWithKind :: Kind -> Char -> Int -> Symbol -> TyCon
-symbolTyConWithKind k x i n = stringTyConWithKind k x i (symbolString n)
-
-symbolTyCon :: Char -> Int -> Symbol -> TyCon
-symbolTyCon x i n = stringTyCon x i (symbolString n)
-
-symbolTyVar :: Symbol -> TyVar
-symbolTyVar = stringTyVar . symbolString
-
-localVarSymbol ::  Var -> Symbol
-localVarSymbol v
-  | us `isSuffixOfSym` vs = vs
-  | otherwise             = suffixSymbol vs us
-  where
-    us                    = symbol $ showPpr $ getDataConVarUnique v
-    vs                    = exportedVarSymbol v 
-
-exportedVarSymbol :: Var -> Symbol
-exportedVarSymbol x = notracepp msg . symbol . getName $ x            
-  where 
-    msg = "exportedVarSymbol: " ++ showPpr x 
-
-qualifiedNameSymbol :: Name -> Symbol
-qualifiedNameSymbol n = symbol $ concatFS [modFS, occFS, uniqFS]
-  where
-  _msg   = showSDoc (ppr n) -- getOccString n
-  modFS = case nameModule_maybe n of
-            Nothing -> fsLit ""
-            Just m  -> concatFS [moduleNameFS (moduleName m), fsLit "."]
-
-  occFS = occNameFS (getOccName n)
-  uniqFS
-    | isSystemName n
-    = concatFS [fsLit "_",  fsLit (showPpr (getUnique n))]
-    | otherwise
-    = fsLit ""
-
-instance Symbolic FastString where
-  symbol = symbol . fastStringText
-
-fastStringText :: FastString -> T.Text
-fastStringText = T.decodeUtf8With TE.lenientDecode . bytesFS
-
-tyConTyVarsDef :: TyCon -> [TyVar]
-tyConTyVarsDef c
-  | noTyVars c = []
-  | otherwise  = TC.tyConTyVars c
-  --where
-  --  none         = tracepp ("tyConTyVarsDef: " ++ show c) (noTyVars c)
-
-noTyVars :: TyCon -> Bool
-noTyVars c =  (TC.isPrimTyCon c || isFunTyCon c || TC.isPromotedDataCon c)
-
---------------------------------------------------------------------------------
--- | Symbol Instances
---------------------------------------------------------------------------------
-
-instance Symbolic TyCon where
-  symbol = symbol . getName
-
-instance Symbolic Class where
-  symbol = symbol . getName
-
-instance Symbolic Name where
-  symbol = symbol . qualifiedNameSymbol
-
--- | [NOTE:REFLECT-IMPORTS] we **eschew** the `unique` suffix for exported vars,
--- to make it possible to lookup names from symbols _across_ modules;
--- anyways exported names are top-level and you shouldn't have local binders
--- that shadow them. However, we **keep** the `unique` suffix for local variables,
--- as otherwise there are spurious, but extremely problematic, name collisions
--- in the fixpoint environment.
-
-instance Symbolic Var where   -- TODO:reflect-datacons varSymbol
-  symbol v
-    | isExportedId v = exportedVarSymbol v
-    | otherwise      = localVarSymbol    v
-
-
-instance Hashable Var where
-  hashWithSalt = uniqueHash
-
-instance Hashable TyCon where
-  hashWithSalt = uniqueHash
-
-instance Hashable DataCon where
-  hashWithSalt = uniqueHash
-
-instance Fixpoint Var where
-  toFix = pprDoc
-
-instance Fixpoint Name where
-  toFix = pprDoc
-
-instance Fixpoint Type where
-  toFix = pprDoc
-
-instance Show Name where
-  show = symbolString . symbol
-
-instance Show Var where
-  show = show . getName
-
-instance Show Class where
-  show = show . getName
-
-instance Show TyCon where
-  show = show . getName
-
-instance NFData Class where
-  rnf t = seq t ()
-
-instance NFData TyCon where
-  rnf t = seq t ()
-
-instance NFData Type where
-  rnf t = seq t ()
-
-instance NFData Var where
-  rnf t = seq t ()
-
---------------------------------------------------------------------------------
--- | Manipulating Symbols ------------------------------------------------------
---------------------------------------------------------------------------------
-
-splitModuleName :: Symbol -> (Symbol, Symbol)
-splitModuleName x = (takeModuleNames x, dropModuleNamesAndUnique x)
-
-dropModuleNamesAndUnique :: Symbol -> Symbol
-dropModuleNamesAndUnique = dropModuleUnique . dropModuleNames
-
-dropModuleNames  :: Symbol -> Symbol
-dropModuleNames = dropModuleNamesCorrect 
-{- 
-dropModuleNames = mungeNames lastName sepModNames "dropModuleNames: "
- where
-   lastName msg = symbol . safeLast msg
--}
-
-dropModuleNamesCorrect  :: Symbol -> Symbol
-dropModuleNamesCorrect = F.symbol . go . F.symbolText
-  where
-    go s = case T.uncons s of
-             Just (c,tl) -> if isUpper c  && T.any (== '.') tl
-                              then go $ snd $ fromJust $ T.uncons $ T.dropWhile (/= '.') s
-                              else s
-             Nothing -> s
-
-takeModuleNames  :: Symbol -> Symbol
-takeModuleNames  = F.symbol . go [] . F.symbolText
-  where
-    go acc s = case T.uncons s of
-                Just (c,tl) -> if isUpper c && T.any (== '.') tl
-                                 then go (getModule s:acc) $ snd $ fromJust $ T.uncons $ T.dropWhile (/= '.') s
-                                 else T.intercalate "." (reverse acc) 
-                Nothing -> T.intercalate "." (reverse acc) 
-    getModule s = T.takeWhile (/= '.') s
-
-{- 
-takeModuleNamesOld  = mungeNames initName sepModNames "takeModuleNames: "
-  where
-    initName msg = symbol . T.intercalate "." . safeInit msg
--}
-dropModuleUnique :: Symbol -> Symbol
-dropModuleUnique = mungeNames headName sepUnique   "dropModuleUnique: "
-  where
-    headName msg = symbol . safeHead msg
-
-cmpSymbol :: Symbol -> Symbol -> Bool
-cmpSymbol coreSym logicSym
-  =  (dropModuleUnique coreSym == dropModuleNamesAndUnique logicSym)
-  || (dropModuleUnique coreSym == dropModuleUnique         logicSym)
-
-sepModNames :: T.Text
-sepModNames = "."
-
-sepUnique :: T.Text
-sepUnique = "#"
-
-mungeNames :: (String -> [T.Text] -> Symbol) -> T.Text -> String -> Symbol -> Symbol
-mungeNames _ _ _ ""  = ""
-mungeNames f d msg s'@(symbolText -> s)
-  | s' == tupConName = tupConName
-  | otherwise        = f (msg ++ T.unpack s) $ T.splitOn d $ stripParens s
-
-qualifySymbol :: Symbol -> Symbol -> Symbol
-qualifySymbol (symbolText -> m) x'@(symbolText -> x)
-  | isQualified x  = x'
-  | isParened x    = symbol (wrapParens (m `mappend` "." `mappend` stripParens x))
-  | otherwise      = symbol (m `mappend` "." `mappend` x)
-
-isQualifiedSym :: Symbol -> Bool
-isQualifiedSym (symbolText -> x) = isQualified x 
-
-isQualified :: T.Text -> Bool
-isQualified y = "." `T.isInfixOf` y
-
-wrapParens :: (IsString a, Monoid a) => a -> a
-wrapParens x  = "(" `mappend` x `mappend` ")"
-
-isParened :: T.Text -> Bool
-isParened xs  = xs /= stripParens xs
-
-isDictionary :: Symbolic a => a -> Bool
-isDictionary = isPrefixOfSym "$f" . dropModuleNames . symbol
-
-isMethod :: Symbolic a => a -> Bool
-isMethod = isPrefixOfSym "$c" . dropModuleNames . symbol
-
-isInternal :: Symbolic a => a -> Bool
-isInternal   = isPrefixOfSym "$"  . dropModuleNames . symbol
-
-isWorker :: Symbolic a => a -> Bool 
-isWorker s = notracepp ("isWorkerSym: s = " ++ ss) $ "$W" `L.isInfixOf` ss 
-  where 
-    ss     = symbolString (symbol s)
-
-
-
-stripParens :: T.Text -> T.Text
-stripParens t = fromMaybe t (strip t)
-  where
-    strip = T.stripPrefix "(" >=> T.stripSuffix ")"
-
-stripParensSym :: Symbol -> Symbol
-stripParensSym (symbolText -> t) = symbol (stripParens t)
-
-desugarModule :: TypecheckedModule -> Ghc DesugaredModule
-desugarModule tcm = do
-  let ms = pm_mod_summary $ tm_parsed_module tcm
-  -- let ms = modSummary tcm
-  let (tcg, _) = tm_internals_ tcm
-  hsc_env <- getSession
-  let hsc_env_tmp = hsc_env { hsc_dflags = ms_hspp_opts ms }
-  guts <- liftIO $ hscDesugar{- WithLoc -} hsc_env_tmp ms tcg
-  return DesugaredModule { dm_typechecked_module = tcm, dm_core_module = guts }
-
---------------------------------------------------------------------------------
--- | GHC Compatibility Layer ---------------------------------------------------
---------------------------------------------------------------------------------
-
-gHC_VERSION :: String
-gHC_VERSION = show __GLASGOW_HASKELL__
-
-symbolFastString :: Symbol -> FastString
-symbolFastString = mkFastStringByteString . T.encodeUtf8 . symbolText
-
-lintCoreBindings :: [Var] -> CoreProgram -> (Bag MsgDoc, Bag MsgDoc)
-lintCoreBindings = CoreLint.lintCoreBindings (defaultDynFlags undefined (undefined "LlvmTargets")) CoreDoNothing
-
-synTyConRhs_maybe :: TyCon -> Maybe Type
-synTyConRhs_maybe = TC.synTyConRhs_maybe
-
-tcRnLookupRdrName :: HscEnv -> Ghc.Located RdrName -> IO (Messages, Maybe [Name])
-tcRnLookupRdrName = TcRnDriver.tcRnLookupRdrName
-
-showCBs :: Bool -> [CoreBind] -> String
-showCBs untidy
-  | untidy    = Out.showSDocDebug unsafeGlobalDynFlags . ppr . tidyCBs
-  | otherwise = showPpr
-
-
-ignoreCoreBinds :: S.HashSet Var -> [CoreBind] -> [CoreBind]
-ignoreCoreBinds vs cbs 
-  | S.null vs         = cbs 
-  | otherwise         = concatMap go cbs
-  where
-    go :: CoreBind -> [CoreBind]
-    go b@(NonRec x _) 
-      | S.member x vs = [] 
-      | otherwise     = [b] 
-    go (Rec xes)      = [Rec (filter ((`notElem` vs) . fst) xes)]
-
-
-findVarDef :: Symbol -> [CoreBind] -> Maybe (Var, CoreExpr)
-findVarDef x cbs = case xCbs of
-                     (NonRec v def   : _ ) -> Just (v, def)
-                     (Rec [(v, def)] : _ ) -> Just (v, def)
-                     _                     -> Nothing
-  where
-    xCbs            = [ cb | cb <- concatMap unRec cbs, x `elem` coreBindSymbols cb ]
-    unRec (Rec xes) = [NonRec x es | (x,es) <- xes]
-    unRec nonRec    = [nonRec]
-
-
-coreBindSymbols :: CoreBind -> [Symbol]
-coreBindSymbols = map (dropModuleNames . simplesymbol) . binders
-
-simplesymbol :: (NamedThing t) => t -> Symbol
-simplesymbol = symbol . getName
-
-binders :: Bind a -> [a]
-binders (NonRec z _) = [z]
-binders (Rec xes)    = fst <$> xes
-
-expandVarType :: Var -> Type
-expandVarType = expandTypeSynonyms . varType
---------------------------------------------------------------------------------
--- | The following functions test if a `CoreExpr` or `CoreVar` are just types
---   in disguise, e.g. have `PredType` (in the GHC sense of the word), and so
---   shouldn't appear in refinements.
---------------------------------------------------------------------------------
-isPredExpr :: CoreExpr -> Bool
-isPredExpr = isPredType . CoreUtils.exprType
-
-isPredVar :: Var -> Bool
-isPredVar v = F.notracepp msg . isPredType . varType $ v
-  where
-    msg     =  "isGoodCaseBind v = " ++ show v
-
-isPredType :: Type -> Bool
-isPredType = anyF [ isClassPred, isEqPred, isEqPrimPred ]
-
-anyF :: [a -> Bool] -> a -> Bool
-anyF ps x = or [ p x | p <- ps ]
-
-
--- | 'defaultDataCons t ds' returns the list of '(dc, types)' pairs,
---   corresponding to the _missing_ cases, i.e. _other_ than those in 'ds',
---   that are being handled by DEFAULT.
-defaultDataCons :: Type -> [AltCon] -> Maybe [(DataCon, [TyVar], [Type])]
-defaultDataCons (TyConApp tc argτs) ds = do 
-  allDs     <- TC.tyConDataCons_maybe tc
-  let seenDs = [d | DataAlt d <- ds ]
-  let defDs  = keyDiff showPpr allDs seenDs 
-  return [ (d, Ghc.dataConExTyVars d, DataCon.dataConInstArgTys d argτs) | d <- defDs ] 
-
-defaultDataCons _ _ = 
-  Nothing
-
-
-
-isEvVar :: Id -> Bool 
-isEvVar x = isPredVar x || isTyVar x || isCoVar x
diff --git a/src/Language/Haskell/Liquid/GHC/Play.hs b/src/Language/Haskell/Liquid/GHC/Play.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Play.hs
+++ /dev/null
@@ -1,155 +0,0 @@
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE PatternSynonyms           #-}
-
-module Language.Haskell.Liquid.GHC.Play where
-
-import Prelude hiding (error)
-import GHC
-import CoreSyn
-import Var
-import DataCon
-
-import TyCon
-import PrelNames (isStringClassName)
-
-import           Control.Arrow       ((***))
-import qualified Data.HashMap.Strict as M
-import qualified Data.List           as L
-
-import Language.Haskell.Liquid.GHC.API as Ghc hiding (substTysWith)
-import Language.Haskell.Liquid.GHC.Misc ()
-import Language.Haskell.Liquid.Types.Errors
-
-
-isRecursivenewTyCon :: TyCon -> Bool 
-isRecursivenewTyCon c 
-  | not (isNewTyCon c)
-  = False 
-isRecursivenewTyCon c 
-  = go t 
-  where 
-    t = snd $ newTyConRhs c
-    go (AppTy t1 t2)    = go t1 || go t2 
-    go (TyConApp c' ts) = c == c' || any go ts 
-    go (ForAllTy _ t1)  = go t1 
-    go (FunTy _ t1 t2)  = go t1 || go t2
-    go (CastTy t1 _)    = go t1 
-    go _                = False   
-  
-
-isHoleVar :: Var -> Bool 
-isHoleVar x = L.isPrefixOf "_" (show x)
-
-dataConImplicitIds :: DataCon -> [Id]
-dataConImplicitIds dc = [ x | AnId x <- dataConImplicitTyThings dc]
-
-class Subable a where
-  sub   :: M.HashMap CoreBndr CoreExpr -> a -> a
-  subTy :: M.HashMap TyVar Type -> a -> a
-
-instance Subable CoreExpr where
-  sub s (Var v)        = M.lookupDefault (Var v) v s
-  sub _ (Lit l)        = Lit l
-  sub s (App e1 e2)    = App (sub s e1) (sub s e2)
-  sub s (Lam b e)      = Lam b (sub s e)
-  sub s (Let b e)      = Let (sub s b) (sub s e)
-  sub s (Case e b t a) = Case (sub s e) (sub s b) t (map (sub s) a)
-  sub s (Cast e c)     = Cast (sub s e) c
-  sub s (Tick t e)     = Tick t (sub s e)
-  sub _ (Type t)       = Type t
-  sub _ (Coercion c)   = Coercion c
-
-  subTy s (Var v)      = Var (subTy s v)
-  subTy _ (Lit l)      = Lit l
-  subTy s (App e1 e2)  = App (subTy s e1) (subTy s e2)
-  subTy s (Lam b e)    | isTyVar b = Lam v' (subTy s e)
-   where v' = case M.lookup b s of
-               Just (TyVarTy v) -> v
-               _                -> b
-
-  subTy s (Lam b e)      = Lam (subTy s b) (subTy s e)
-  subTy s (Let b e)      = Let (subTy s b) (subTy s e)
-  subTy s (Case e b t a) = Case (subTy s e) (subTy s b) (subTy s t) (map (subTy s) a)
-  subTy s (Cast e c)     = Cast (subTy s e) (subTy s c)
-  subTy s (Tick t e)     = Tick t (subTy s e)
-  subTy s (Type t)       = Type (subTy s t)
-  subTy s (Coercion c)   = Coercion (subTy s c)
-
-instance Subable Coercion where
-  sub _ c                = c
-  subTy _ _              = panic Nothing "subTy Coercion"
-
-instance Subable (Alt Var) where
- sub s (a, b, e)   = (a, map (sub s) b,   sub s e)
- subTy s (a, b, e) = (a, map (subTy s) b, subTy s e)
-
-instance Subable Var where
- sub s v   | M.member v s = subVar $ s M.! v
-           | otherwise    = v
- subTy s v = setVarType v (subTy s (varType v))
-
-subVar :: Expr t -> Id
-subVar (Var x) = x
-subVar  _      = panic Nothing "sub Var"
-
-instance Subable (Bind Var) where
- sub s (NonRec x e)   = NonRec (sub s x) (sub s e)
- sub s (Rec xes)      = Rec ((sub s *** sub s) <$> xes)
-
- subTy s (NonRec x e) = NonRec (subTy s x) (subTy s e)
- subTy s (Rec xes)    = Rec ((subTy s  *** subTy s) <$> xes)
-
-instance Subable Type where
- sub _ e   = e
- subTy     = substTysWith
-
-substTysWith :: M.HashMap Var Type -> Type -> Type
-substTysWith s tv@(TyVarTy v)    = M.lookupDefault tv v s
-substTysWith s (FunTy aaf t1 t2) = FunTy aaf (substTysWith s t1) (substTysWith s t2)
-substTysWith s (ForAllTy v t)    = ForAllTy v (substTysWith (M.delete (binderVar v) s) t)
-substTysWith s (TyConApp c ts)   = TyConApp c (map (substTysWith s) ts)
-substTysWith s (AppTy t1 t2)     = AppTy (substTysWith s t1) (substTysWith s t2)
-substTysWith _ (LitTy t)         = LitTy t
-substTysWith s (CastTy t c)      = CastTy (substTysWith s t) c
-substTysWith _ (CoercionTy c)    = CoercionTy c 
-
-substExpr :: M.HashMap Var Var -> CoreExpr -> CoreExpr
-substExpr s = go 
-  where
-    subsVar v                = M.lookupDefault v v s
-    go (Var v)               = Var $ subsVar v
-    go (Lit l)               = Lit l 
-    go (App e1 e2)           = App (go e1) (go e2) 
-    go (Lam x e)             = Lam (subsVar x) (go e)
-    go (Let (NonRec x ex) e) = Let (NonRec (subsVar x) (go ex)) (go e) 
-    go (Let (Rec xes) e)     = Let (Rec [(subsVar x, go e) | (x,e) <- xes]) (go e)
-    go (Case e b t alts)     = Case (go e) (subsVar b) t [(c, subsVar <$> xs, go e) | (c, xs, e) <- alts]
-    go (Cast e c)            = Cast (go e) c 
-    go (Tick t e)            = Tick t (go e)
-    go (Type t)              = Type t 
-    go (Coercion c)          = Coercion c 
-
-mapType :: (Type -> Type) -> Type -> Type
-mapType f = go
-  where
-    go t@(TyVarTy _)      = f t
-    go (AppTy t1 t2)      = f $ AppTy (go t1) (go t2)
-    go (TyConApp c ts)    = f $ TyConApp c (go <$> ts)
-    go (FunTy aaf t1 t2)  = f $ FunTy aaf (go t1) (go t2)
-    go (ForAllTy v t)     = f $ ForAllTy v (go t)
-    go t@(LitTy _)        = f t
-    go (CastTy t c)       = CastTy (go t) c
-    go (CoercionTy c)     = f $ CoercionTy c 
-
-
-stringClassArg :: Type -> Maybe Type
-stringClassArg t | isFunTy t 
-  = Nothing
-stringClassArg t
-  = case (tyConAppTyCon_maybe t, tyConAppArgs_maybe t) of
-      (Just c, Just [t]) | isStringClassName == tyConName c
-           -> Just t
-      _    -> Nothing
diff --git a/src/Language/Haskell/Liquid/GHC/Plugin.hs b/src/Language/Haskell/Liquid/GHC/Plugin.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Plugin.hs
+++ /dev/null
@@ -1,518 +0,0 @@
--- | This module provides a GHC 'Plugin' that allows LiquidHaskell to be hooked directly into GHC's
--- compilation pipeline, facilitating its usage and adoption.
-
-{-# LANGUAGE MultiWayIf                 #-}
-{-# LANGUAGE TypeFamilies               #-}
-{-# LANGUAGE FlexibleInstances          #-}
-{-# LANGUAGE ScopedTypeVariables        #-}
-{-# LANGUAGE BangPatterns               #-}
-{-# LANGUAGE DeriveDataTypeable         #-}
-{-# LANGUAGE LambdaCase                 #-}
-{-# LANGUAGE OverloadedStrings          #-}
-{-# LANGUAGE RecordWildCards            #-}
-{-# LANGUAGE TupleSections              #-}
-{-# LANGUAGE TypeApplications           #-}
-{-# LANGUAGE ViewPatterns               #-}
-
-module Language.Haskell.Liquid.GHC.Plugin (
-
-  plugin
-
-  ) where
-
-import qualified Outputable                              as O
-import           GHC                               hiding ( Target
-                                                          , Located
-                                                          , desugarModule
-                                                          )
-
-import           Plugins                                 as GHC
-import           TcRnTypes                               as GHC
-import           TcRnMonad                               as GHC
-
-import qualified Language.Haskell.Liquid.GHC.Misc        as LH
-import qualified Language.Haskell.Liquid.UX.CmdLine      as LH
-import qualified Language.Haskell.Liquid.GHC.Interface   as LH
-import qualified Language.Haskell.Liquid.Liquid          as LH
-import qualified Language.Haskell.Liquid.Types.PrettyPrint as LH (reportErrors)
-import qualified Language.Haskell.Liquid.GHC.Logging     as LH   (fromPJDoc)
-
-import           Language.Haskell.Liquid.GHC.Plugin.Types
-import           Language.Haskell.Liquid.GHC.Plugin.Util as Util
-import           Language.Haskell.Liquid.GHC.Plugin.SpecFinder
-                                                         as SpecFinder
-
-import           Language.Haskell.Liquid.GHC.Types       (MGIModGuts(..), miModGuts)
-import qualified Language.Haskell.Liquid.GHC.GhcMonadLike
-                                                         as GhcMonadLike
-import           Language.Haskell.Liquid.GHC.GhcMonadLike ( GhcMonadLike
-                                                          , askHscEnv
-                                                          )
-import           CoreMonad
-import           DataCon
-import           DynFlags
-import           HscTypes                          hiding ( Target )
-import           InstEnv
-import           Module
-import           FamInstEnv
-import qualified TysPrim
-import           GHC.LanguageExtensions
-
-import           Control.Monad
-import           Control.Exception                        (evaluate)
-
-import           Data.Coerce
-import           Data.List                               as L
-                                                   hiding ( intersperse )
-import           Data.IORef
-import qualified Data.Set                                as S
-import           Data.Set                                 ( Set )
-
-
-import qualified Data.HashSet                            as HS
-import qualified Data.HashMap.Strict                     as HM
-
-import           System.IO.Unsafe                         ( unsafePerformIO )
-import           Language.Fixpoint.Types           hiding ( panic
-                                                          , Error
-                                                          , Result
-                                                          , Expr
-                                                          )
-
-import qualified Language.Haskell.Liquid.Measure         as Ms
-import           Language.Haskell.Liquid.Parse
-import           Language.Haskell.Liquid.Transforms.ANF
-import           Language.Haskell.Liquid.Types     hiding ( getConfig )
-import           Language.Haskell.Liquid.Bare
-import           Language.Haskell.Liquid.UX.CmdLine
-
-import           Optics
-
-
----------------------------------------------------------------------------------
--- | State and configuration management -----------------------------------------
----------------------------------------------------------------------------------
-
--- | A reference to cache the LH's 'Config' and produce it only /once/, during the dynFlags hook.
-cfgRef :: IORef Config
-cfgRef = unsafePerformIO $ newIORef defConfig
-{-# NOINLINE cfgRef #-}
-
--- | Set to 'True' to enable debug logging.
-debugLogs :: Bool
-debugLogs = False
-
----------------------------------------------------------------------------------
--- | Useful functions -----------------------------------------------------------
----------------------------------------------------------------------------------
-
--- | Reads the 'Config' out of a 'IORef'.
-getConfig :: IO Config
-getConfig = readIORef cfgRef
-
--- | Combinator which conditionally print on the screen based on the value of 'debugLogs'.
-debugLog :: MonadIO m => String -> m ()
-debugLog msg = when debugLogs $ liftIO (putStrLn msg)
-
----------------------------------------------------------------------------------
--- | The Plugin entrypoint ------------------------------------------------------
----------------------------------------------------------------------------------
-
-plugin :: GHC.Plugin
-plugin = GHC.defaultPlugin {
-    typeCheckResultAction = typecheckHook
-  , dynflagsPlugin        = customDynFlags
-  , pluginRecompile       = purePlugin
-  }
-
---------------------------------------------------------------------------------
--- | GHC Configuration & Setup -------------------------------------------------
---------------------------------------------------------------------------------
-
--- | Overrides the default 'DynFlags' options. Specifically, we need the GHC
--- lexer not to throw away block comments, as this is where the LH spec comments
--- would live. This is why we set the 'Opt_KeepRawTokenStream' option.
-customDynFlags :: [CommandLineOption] -> DynFlags -> IO DynFlags
-customDynFlags opts dflags = do
-  cfg <- liftIO $ LH.getOpts opts
-  writeIORef cfgRef cfg
-  configureDynFlags dflags
-
-configureDynFlags :: DynFlags -> IO DynFlags
-configureDynFlags df =
-  pure $ df `gopt_set` Opt_ImplicitImportQualified
-            `gopt_set` Opt_PIC
-            `gopt_set` Opt_DeferTypedHoles
-            `gopt_set` Opt_KeepRawTokenStream
-            `xopt_set` MagicHash
-            `xopt_set` DeriveGeneric
-            `xopt_set` StandaloneDeriving
-
---------------------------------------------------------------------------------
--- | \"Unoptimising\" things ----------------------------------------------------
---------------------------------------------------------------------------------
-
--- | LiquidHaskell requires the unoptimised core binds in order to work correctly, but at the same time the
--- user can invoke GHC with /any/ optimisation flag turned out. This is why we grab the core binds by
--- desugaring the module during /parsing/ (before that's already too late) and we cache the core binds for
--- the rest of the program execution.
-class Unoptimise a where
-  type UnoptimisedTarget a :: *
-  unoptimise :: a -> UnoptimisedTarget a
-
-instance Unoptimise DynFlags where
-  type UnoptimisedTarget DynFlags = DynFlags
-  unoptimise df = updOptLevel 0 df
-    { debugLevel   = 1
-    , ghcLink      = LinkInMemory
-    , hscTarget    = HscInterpreted
-    , ghcMode      = CompManager
-    }
-
-instance Unoptimise ModSummary where
-  type UnoptimisedTarget ModSummary = ModSummary
-  unoptimise modSummary = modSummary { ms_hspp_opts = unoptimise (ms_hspp_opts modSummary) }
-
-instance Unoptimise (DynFlags, HscEnv) where
-  type UnoptimisedTarget (DynFlags, HscEnv) = HscEnv
-  unoptimise (unoptimise -> df, env) = env { hsc_dflags = df }
-
---------------------------------------------------------------------------------
--- | Typechecking phase --------------------------------------------------------
---------------------------------------------------------------------------------
-
--- | We hook at this stage of the pipeline in order to call \"liquidhaskell\". This
--- might seems counterintuitive as LH works on a desugared module. However, there
--- are a bunch of reasons why we do this:
---
--- 1. Tools like \"ghcide\" works by running the compilation pipeline up until
---    this stage, which means that we won't be able to report errors and warnings
---    if we call /LH/ any later than here;
---
--- 2. Although /LH/ works on \"Core\", it requires the _unoptimised_ \"Core\" that we
---    grab from parsing (again) the module by using the GHC API, so we are really
---    independent from the \"normal\" compilation pipeline.
---
-typecheckHook :: [CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv
-typecheckHook _ (unoptimise -> modSummary) tcGblEnv = do
-  debugLog $ "We are in module: " <> show (toStableModule thisModule)
-
-  parsed        <- GhcMonadLike.parseModule (LH.keepRawTokenStream cleanedSummary)
-  let comments  = LH.extractSpecComments (pm_annotations parsed)
-  typechecked     <- GhcMonadLike.typecheckModule (LH.ignoreInline parsed)
-  env             <- askHscEnv
-  resolvedNames   <- LH.lookupTyThings env modSummary tcGblEnv
-  availTyCons     <- LH.availableTyCons env modSummary tcGblEnv (tcg_exports tcGblEnv)
-  availVars       <- LH.availableVars env modSummary tcGblEnv (tcg_exports tcGblEnv)
-
-  unoptimisedGuts <- GhcMonadLike.desugarModule modSummary typechecked
-
-  let tcData = mkTcData (tcg_rn_imports tcGblEnv) resolvedNames availTyCons availVars
-  let pipelineData = PipelineData (toUnoptimised unoptimisedGuts) tcData (map SpecComment comments)
-
-  liquidHaskellCheck pipelineData modSummary tcGblEnv
-
-  where
-    thisModule :: Module
-    thisModule = tcg_mod tcGblEnv
-
-    cleanedSummary :: ModSummary
-    cleanedSummary =
-        modSummary { ms_hspp_opts = (ms_hspp_opts modSummary) { cachedPlugins = []
-                                                              , staticPlugins = []
-                                                              }
-                   }
-
--- | Partially calls into LiquidHaskell's GHC API.
-liquidHaskellCheck :: PipelineData -> ModSummary -> TcGblEnv -> TcM TcGblEnv
-liquidHaskellCheck pipelineData modSummary tcGblEnv = do
-  cfg <- liftIO getConfig
-
-  -- The 'specQuotes' contain stuff we need from imported modules, extracted
-  -- from the annotations in their interface files.
-  let specQuotes :: [BPspec]
-      specQuotes = LH.extractSpecQuotes' tcg_mod tcg_anns tcGblEnv
-
-  -- Here, we are calling Liquid Haskell's parser, acting on the unparsed
-  -- spec comments stored in the pipeline data, supported by the specQuotes
-  -- obtained from the imported modules.
-  inputSpec :: BareSpec <- getLiquidSpec thisModule (pdSpecComments pipelineData) specQuotes
-
-  debugLog $ " Input spec: \n" ++ show inputSpec
-  debugLog $ "Relevant ===> \n" ++ (unlines $ map renderModule $ (S.toList $ relevantModules modGuts))
-
-  logicMap :: LogicMap <- liftIO $ LH.makeLogicMap
-
-  -- debugLog $ "Logic map:\n" ++ show logicMap
-
-  let lhContext = LiquidHaskellContext {
-        lhGlobalCfg       = cfg
-      , lhInputSpec       = inputSpec
-      , lhModuleLogicMap  = logicMap
-      , lhModuleSummary   = modSummary
-      , lhModuleTcData    = pdTcData pipelineData
-      , lhModuleGuts      = pdUnoptimisedCore pipelineData
-      , lhRelevantModules = relevantModules modGuts
-      }
-
-  ProcessModuleResult{..} <- processModule lhContext
-
-  -- Call into the existing Liquid interface
-  out <- liftIO $ LH.checkTargetInfo pmrTargetInfo
-
-  -- Report the outcome of the checking
-  LH.reportResult errorLogger cfg [giTarget (giSrc pmrTargetInfo)] out
-  case o_result out of
-    Safe _stats -> pure ()
-    _           -> failM
-
-  let serialisedSpec = Util.serialiseLiquidLib pmrClientLib thisModule
-  debugLog $ "Serialised annotation ==> " ++ (O.showSDocUnsafe . O.ppr $ serialisedSpec)
-
-  pure $ tcGblEnv { tcg_anns = serialisedSpec : tcg_anns tcGblEnv }
-  where
-    thisModule :: Module
-    thisModule = tcg_mod tcGblEnv
-
-    modGuts :: ModGuts
-    modGuts = fromUnoptimised . pdUnoptimisedCore $ pipelineData
-
-    errorLogger :: OutputResult -> TcM ()
-    errorLogger outputResult = do
-      errs <- forM (LH.orMessages outputResult) $ \(spn, e) -> mkLongErrAt spn (LH.fromPJDoc e) O.empty
-      GHC.reportErrors errs
-
-
---------------------------------------------------------------------------------
--- | Working with bare & lifted specs ------------------------------------------
---------------------------------------------------------------------------------
-
-loadDependencies :: forall m. GhcMonadLike m
-                 => Config
-                 -- ^ The 'Config' associated to the /current/ module being compiled.
-                 -> ExternalPackageState
-                 -> HomePackageTable
-                 -> Module
-                 -> [Module]
-                 -> m TargetDependencies
-loadDependencies currentModuleConfig eps hpt thisModule mods = do
-  results   <- SpecFinder.findRelevantSpecs eps hpt mods
-  deps      <- foldlM processResult mempty (reverse results)
-  redundant <- configToRedundantDependencies currentModuleConfig
-
-  debugLog $ "Redundant dependencies ==> " ++ show redundant
-
-  pure $ foldl' (flip dropDependency) deps redundant
-  where
-    processResult :: TargetDependencies -> SpecFinderResult -> m TargetDependencies
-    processResult !acc (SpecNotFound mdl) = do
-      debugLog $ "[T:" ++ renderModule thisModule
-              ++ "] Spec not found for " ++ renderModule mdl
-      pure acc
-    processResult _ (SpecFound originalModule location _) = do
-      dynFlags <- getDynFlags
-      debugLog $ "[T:" ++ show (moduleName thisModule)
-              ++ "] Spec found for " ++ renderModule originalModule ++ ", at location " ++ show location
-      Util.pluginAbort (O.showSDoc dynFlags $ O.text "A BareSpec was returned as a dependency, this is not allowed, in " O.<+> O.ppr thisModule)
-    processResult !acc (LibFound originalModule location lib) = do
-      debugLog $ "[T:" ++ show (moduleName thisModule)
-              ++ "] Lib found for " ++ renderModule originalModule ++ ", at location " ++ show location
-      pure $ TargetDependencies {
-          getDependencies = HM.insert (toStableModule originalModule) (libTarget lib) (getDependencies $ acc <> libDeps lib)
-        }
-
--- | The collection of dependencies and usages modules which are relevant for liquidHaskell
-relevantModules :: ModGuts -> Set Module
-relevantModules modGuts = used `S.union` dependencies
-  where
-    dependencies :: Set Module
-    dependencies = S.fromList $ map (toModule . fst) . filter (not . snd) . dep_mods $ deps
-
-    deps :: Dependencies
-    deps = mg_deps modGuts
-
-    thisModule :: Module
-    thisModule = mg_module modGuts
-
-    toModule :: ModuleName -> Module
-    toModule = Module (moduleUnitId thisModule)
-
-    used :: Set Module
-    used = S.fromList $ foldl' collectUsage mempty . mg_usages $ modGuts
-      where
-        collectUsage :: [Module] -> Usage -> [Module]
-        collectUsage acc = \case
-          UsagePackageModule     { usg_mod      = modl    } -> modl : acc
-          UsageHomeModule        { usg_mod_name = modName } -> toModule modName : acc
-          UsageMergedRequirement { usg_mod      = modl    } -> modl : acc
-          _ -> acc
-
-
-data LiquidHaskellContext = LiquidHaskellContext {
-    lhGlobalCfg        :: Config
-  , lhInputSpec        :: BareSpec
-  , lhModuleLogicMap   :: LogicMap
-  , lhModuleSummary    :: ModSummary
-  , lhModuleTcData     :: TcData
-  , lhModuleGuts       :: Unoptimised ModGuts
-  , lhRelevantModules  :: Set Module
-  }
-
---------------------------------------------------------------------------------
--- | Per-Module Pipeline -------------------------------------------------------
---------------------------------------------------------------------------------
-
-data ProcessModuleResult = ProcessModuleResult {
-    pmrClientLib  :: LiquidLib
-  -- ^ The \"client library\" we will serialise on disk into an interface's 'Annotation'.
-  , pmrTargetInfo :: TargetInfo
-  -- ^ The 'GhcInfo' for the current 'Module' that LiquidHaskell will process.
-  }
-
--- | Parse the spec comments from one module, supported by the
--- spec quotes from the imported module. Also looks for
--- "companion specs" for the current module and merges them in
--- if it finds one.
-getLiquidSpec :: Module -> [SpecComment] -> [BPspec] -> TcM BareSpec
-getLiquidSpec thisModule specComments specQuotes = do
-
-  let commSpecE :: Either [Error] (ModName, Spec LocBareType LocSymbol)
-      commSpecE = hsSpecificationP (moduleName thisModule) (coerce specComments) specQuotes
-  case commSpecE of
-    Left errors -> do
-      LH.reportErrors Full errors
-      failM
-    Right (view bareSpecIso . snd -> commSpec) -> do
-      res <- SpecFinder.findCompanionSpec thisModule
-      case res of
-        SpecFound _ _ companionSpec -> do
-          debugLog $ "Companion spec found for " ++ renderModule thisModule
-          pure $ commSpec <> companionSpec
-        _ -> pure commSpec
-
-processModule :: LiquidHaskellContext -> TcM ProcessModuleResult
-processModule LiquidHaskellContext{..} = do
-  debugLog ("Module ==> " ++ renderModule thisModule)
-  hscEnv              <- askHscEnv
-
-  let bareSpec        = lhInputSpec
-  -- /NOTE/: For the Plugin to work correctly, we shouldn't call 'canonicalizePath', because otherwise
-  -- this won't trigger the \"external name resolution\" as part of 'Language.Haskell.Liquid.Bare.Resolve'
-  -- (cfr. 'allowExtResolution').
-  let file            = LH.modSummaryHsFile lhModuleSummary
-
-  _                   <- LH.checkFilePragmas $ Ms.pragmas (review bareSpecIso bareSpec)
-
-  moduleCfg           <- liftIO $ withPragmas lhGlobalCfg file (Ms.pragmas $ review bareSpecIso bareSpec)
-  eps                 <- liftIO $ readIORef (hsc_EPS hscEnv)
-
-  dependencies       <- loadDependencies moduleCfg
-                                         eps
-                                         (hsc_HPT hscEnv)
-                                         thisModule
-                                         (S.toList lhRelevantModules)
-
-  debugLog $ "Found " <> show (HM.size $ getDependencies dependencies) <> " dependencies:"
-  when debugLogs $
-    forM_ (HM.keys . getDependencies $ dependencies) $ debugLog . moduleStableString . unStableModule
-
-  debugLog $ "mg_exports => " ++ (O.showSDocUnsafe $ O.ppr $ mg_exports modGuts)
-  debugLog $ "mg_tcs => " ++ (O.showSDocUnsafe $ O.ppr $ mg_tcs modGuts)
-
-  targetSrc  <- makeTargetSrc moduleCfg file lhModuleTcData modGuts hscEnv
-  dynFlags <- getDynFlags
-
-  -- See https://github.com/ucsd-progsys/liquidhaskell/issues/1711
-  -- Due to the fact the internals can throw exceptions from pure code at any point, we need to
-  -- call 'evaluate' to force any exception and catch it, if we can.
-
-  result <-
-    (liftIO $ evaluate (makeTargetSpec moduleCfg lhModuleLogicMap targetSrc bareSpec dependencies))
-      `gcatch` (\(e :: UserError) -> LH.reportErrors Full [e] >> failM)
-      `gcatch` (\(e :: Error)     -> LH.reportErrors Full [e] >> failM)
-
-  case result of
-    -- Print warnings and errors, aborting the compilation.
-    Left diagnostics -> do
-      liftIO $ mapM_ (printWarning dynFlags)    (allWarnings diagnostics)
-      LH.reportErrors Full (allErrors diagnostics)
-      failM
-
-    Right (warnings, targetSpec, liftedSpec) -> do
-      liftIO $ mapM_ (printWarning dynFlags) warnings
-      let targetInfo = TargetInfo targetSrc targetSpec
-
-      debugLog $ "bareSpec ==> "   ++ show bareSpec
-      debugLog $ "liftedSpec ==> " ++ show liftedSpec
-
-      let clientLib  = mkLiquidLib liftedSpec & addLibDependencies dependencies
-
-      let result = ProcessModuleResult {
-            pmrClientLib  = clientLib
-          , pmrTargetInfo = targetInfo
-          }
-
-      pure result
-
-  where
-    modGuts    = fromUnoptimised lhModuleGuts
-    thisModule = mg_module modGuts
-
----------------------------------------------------------------------------------------
--- | @makeGhcSrc@ builds all the source-related information needed for consgen
----------------------------------------------------------------------------------------
-
-makeTargetSrc :: GhcMonadLike m
-              => Config
-              -> FilePath
-              -> TcData
-              -> ModGuts
-              -> HscEnv
-              -> m TargetSrc
-makeTargetSrc cfg file tcData modGuts hscEnv = do
-  coreBinds      <- liftIO $ anormalize cfg hscEnv modGuts
-
-  -- The type constructors for a module are the (nubbed) union of the ones defined and
-  -- the ones exported. This covers the case of \"wrapper modules\" that simply re-exports
-  -- everything from the imported modules.
-  let availTcs    = tcAvailableTyCons tcData
-  let allTcs      = L.nub $ (mgi_tcs mgiModGuts ++ availTcs)
-
-  let dataCons       = concatMap (map dataConWorkId . tyConDataCons) allTcs
-  let (fiTcs, fiDcs) = LH.makeFamInstEnv (getFamInstances modGuts)
-  let things         = tcResolvedNames tcData
-  let impVars        = LH.importVars coreBinds ++ LH.classCons (mgi_cls_inst mgiModGuts)
-
-  debugLog $ "_gsTcs   => " ++ show allTcs
-  debugLog $ "_gsFiTcs => " ++ show fiTcs
-  debugLog $ "_gsFiDcs => " ++ show fiDcs
-  debugLog $ "dataCons => " ++ show dataCons
-  debugLog $ "defVars  => " ++ show (L.nub $ dataCons ++ (letVars coreBinds) ++ tcAvailableVars tcData)
-
-  return $ TargetSrc
-    { giIncDir    = mempty
-    , giTarget    = file
-    , giTargetMod = ModName Target (moduleName (mg_module modGuts))
-    , giCbs       = coreBinds
-    , giImpVars   = impVars
-    , giDefVars   = L.nub $ dataCons ++ (letVars coreBinds) ++ tcAvailableVars tcData
-    , giUseVars   = readVars coreBinds
-    , giDerVars   = HS.fromList (LH.derivedVars cfg mgiModGuts)
-    , gsExports   = mgi_exports  mgiModGuts
-    , gsTcs       = allTcs
-    , gsCls       = mgi_cls_inst mgiModGuts
-    , gsFiTcs     = fiTcs
-    , gsFiDcs     = fiDcs
-    , gsPrimTcs   = TysPrim.primTyCons
-    , gsQualImps  = tcQualifiedImports tcData
-    , gsAllImps   = tcAllImports       tcData
-    , gsTyThings  = [ t | (_, Just t) <- things ]
-    }
-  where
-    mgiModGuts :: MGIModGuts
-    mgiModGuts = miModGuts deriv modGuts
-      where
-        deriv   = Just $ instEnvElts $ mg_inst_env modGuts
-
-getFamInstances :: ModGuts -> [FamInst]
-getFamInstances guts = famInstEnvElts (mg_fam_inst_env guts)
diff --git a/src/Language/Haskell/Liquid/GHC/Plugin/SpecFinder.hs b/src/Language/Haskell/Liquid/GHC/Plugin/SpecFinder.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Plugin/SpecFinder.hs
+++ /dev/null
@@ -1,152 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE MultiWayIf #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE RankNTypes   #-}
-
-module Language.Haskell.Liquid.GHC.Plugin.SpecFinder
-    ( findRelevantSpecs
-    , findCompanionSpec
-    , SpecFinderResult(..)
-    , SearchLocation(..)
-    , configToRedundantDependencies
-    ) where
-
-import           Language.Haskell.Liquid.GHC.GhcMonadLike as GhcMonadLike ( GhcMonadLike
-                                                                          , lookupModSummary
-                                                                          , askHscEnv
-                                                                          )
-import           Language.Haskell.Liquid.GHC.Plugin.Util  ( pluginAbort, deserialiseLiquidLib )
-import           Language.Haskell.Liquid.GHC.Plugin.Types
-import           Language.Haskell.Liquid.Types.Types
-import           Language.Haskell.Liquid.Types.Specs     hiding (Spec)
-import qualified Language.Haskell.Liquid.Misc            as Misc
-import           Language.Haskell.Liquid.Parse            ( specSpecificationP )
-import           Language.Fixpoint.Utils.Files            ( Ext(Spec), withExt )
-
-import           Optics
-import qualified Outputable                              as O
-import           GHC                                     hiding (lookupModule)
-import           HscTypes
-import           CoreMonad                                ( getDynFlags )
-import           Finder                                   ( findExposedPackageModule
-                                                          )
-
-import           Data.Bifunctor
-import           Data.Foldable
-import           Data.Maybe
-
-import           Control.Exception
-import           Control.Monad.IO.Class
-import           Control.Monad.Trans                      ( lift )
-import           Control.Monad.Trans.Maybe
-
-type SpecFinder m = GhcMonadLike m => Module -> MaybeT m SpecFinderResult
-
--- | The result of searching for a spec.
-data SpecFinderResult = 
-    SpecNotFound Module
-  | SpecFound Module SearchLocation BareSpec
-  | LibFound  Module SearchLocation LiquidLib
-
-data SearchLocation =
-    InterfaceLocation
-  -- ^ The spec was loaded from the annotations of an interface.
-  | DiskLocation
-  -- ^ The spec was loaded from disk (e.g. 'Prelude.spec' or similar)
-  deriving Show
-
--- | Load any relevant spec in the input 'SpecEnv', by updating it. The update will happen only if necessary,
--- i.e. if the spec is not already present.
-findRelevantSpecs :: forall m. GhcMonadLike m 
-                  => ExternalPackageState
-                  -> HomePackageTable
-                  -> [Module]
-                  -- ^ Any relevant module fetched during dependency-discovery.
-                  -> m [SpecFinderResult]
-findRelevantSpecs eps hpt mods = do
-  res  <- foldlM loadRelevantSpec mempty mods
-  pure res
-  where
-
-    loadRelevantSpec :: [SpecFinderResult] -> Module -> m [SpecFinderResult]
-    loadRelevantSpec !acc currentModule = do
-      res <- runMaybeT $ lookupInterfaceAnnotations eps hpt currentModule
-      pure $ case res of
-        Nothing         -> SpecNotFound currentModule : acc
-        Just specResult -> specResult : acc
-
--- | If this module has a \"companion\" '.spec' file sitting next to it, this 'SpecFinder'
--- will try loading it.
-findCompanionSpec :: GhcMonadLike m => Module -> m SpecFinderResult
-findCompanionSpec m = do
-  res <- runMaybeT $ lookupCompanionSpec m
-  case res of
-    Nothing -> pure $ SpecNotFound m
-    Just s  -> pure s
-
--- | Load a spec by trying to parse the relevant \".spec\" file from the filesystem.
-lookupInterfaceAnnotations :: ExternalPackageState -> HomePackageTable -> SpecFinder m
-lookupInterfaceAnnotations eps hpt thisModule = do
-  lib <- MaybeT $ pure $ deserialiseLiquidLib thisModule eps hpt
-  pure $ LibFound thisModule InterfaceLocation lib
-
--- | If this module has a \"companion\" '.spec' file sitting next to it, this 'SpecFinder'
--- will try loading it.
-lookupCompanionSpec :: SpecFinder m
-lookupCompanionSpec thisModule = do
-
-  modSummary <- MaybeT $ GhcMonadLike.lookupModSummary (moduleName thisModule)
-  file       <- MaybeT $ pure (ml_hs_file . ms_location $ modSummary)
-  parsed     <- MaybeT $ do
-    mbSpecContent <- liftIO $ try (Misc.sayReadFile (specFile file))
-    case mbSpecContent of
-      Left (_e :: SomeException) -> pure Nothing
-      Right raw -> pure $ Just $ specSpecificationP (specFile file) raw
-
-  case parsed of
-    Left parsingError -> do
-      dynFlags <- lift getDynFlags
-      let errMsg = O.text "Error when parsing " 
-             O.<+> O.text (specFile file) O.<+> O.text ":"
-             O.<+> O.text (show parsingError)
-      lift $ pluginAbort (O.showSDoc dynFlags errMsg)
-    Right (_, spec) -> do
-      let bareSpec = view bareSpecIso spec
-      pure $ SpecFound thisModule DiskLocation bareSpec
-  where
-    specFile :: FilePath -> FilePath
-    specFile fp = withExt fp Spec
-
--- | Returns a list of 'StableModule's which can be filtered out of the dependency list, because they are
--- selectively \"toggled\" on and off by the LiquidHaskell's configuration, which granularity can be
--- /per module/.
-configToRedundantDependencies :: forall m. GhcMonadLike m => Config -> m [StableModule]
-configToRedundantDependencies cfg = do
-  env <- askHscEnv
-  catMaybes <$> mapM (lookupModule env . first ($ cfg)) configSensitiveDependencies
-  where
-    lookupModule :: HscEnv -> (Bool, ModuleName) -> m (Maybe StableModule)
-    lookupModule env (fetchModule, modName)
-      | fetchModule = liftIO $ lookupLiquidBaseModule env modName
-      | otherwise   = pure Nothing
-
-    lookupLiquidBaseModule :: HscEnv -> ModuleName -> IO (Maybe StableModule)
-    lookupLiquidBaseModule env mn = do
-      res <- liftIO $ findExposedPackageModule env mn (Just "liquid-base")
-      case res of
-        Found _ mdl -> pure $ Just (toStableModule mdl)
-        _           -> pure Nothing
-
--- | Static associative map of the 'ModuleName' that needs to be filtered from the final 'TargetDependencies'
--- due to some particular configuration options.
---
--- Modify this map to add any extra special case. Remember that the semantic is not which module will be
--- /added/, but rather which one will be /removed/ from the final list of dependencies.
---
-configSensitiveDependencies :: [(Config -> Bool, ModuleName)]
-configSensitiveDependencies = [
-    (not . totalityCheck, mkModuleName "Liquid.Prelude.Totality")
-  , (not . linear, mkModuleName "Liquid.Prelude.NotReal")
-  , (linear, mkModuleName "Liquid.Prelude.Real")
-  ]
diff --git a/src/Language/Haskell/Liquid/GHC/Plugin/Tutorial.hs b/src/Language/Haskell/Liquid/GHC/Plugin/Tutorial.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Plugin/Tutorial.hs
+++ /dev/null
@@ -1,236 +0,0 @@
-
-module Language.Haskell.Liquid.GHC.Plugin.Tutorial (
-
-  -- * Introduction and Requirements
-  -- $introduction
-
-  -- * Your first package
-  -- $firstPackage
-
-  -- * Using GHCi
-  -- $usingGHCi
-
-  -- * Passing options
-  -- $passingOptions
-
-  -- * Understanding LiquidHaskell Spec resolution strategies
-  -- $specResolutionStrategies
-
-  -- * Providing specifications for existing packages
-  -- $specForExisting
-
-) where
-
-{- $introduction
-
-This tutorial describes the general approach of using LiquidHaskell using the new compiler plugin. Due
-to some recent changes and improvements to the compiler plugin API (which LiquidHaskell requires) the
-__minimum supported version of GHC is 8.10.1.__
-
--}
-
-{- $firstPackage
-
-Generally speaking, in order to integrate LiquidHaskell (/LH/ for brevity from now on) with your existing
-(or brand new) project, we need a few things:
-
-* We need to tell GHC that we want to __use the LH plugin__, and it can be done by adding the
-  @-fplugin=LiquidHaskell@ option in the @ghc-options@ of your Cabal manifest;
-
-* We need to tell LH where to find the /specs/ (i.e. the refinements) for the types in @base@. To do this,
-  we need to depend on a special, __drop-in replacement__ for @base@ called @liquid-base@.
-
-If we do all the above, our Cabal manifest should look similar to this:
-
-@
-cabal-version: 1.12
-
-name:           toy-package-a
-version:        0.1.0.0
-description:    This is a toy example.
-homepage:
-bug-reports:
-author:         Author name here
-maintainer:     example@example.com
-copyright:      2019 Author name here
-license:        BSD3
-license-file:   LICENSE
-build-type:     Simple
-
-library
-  exposed-modules:
-      Toy.A
-  hs-source-dirs:
-      src
-  build-depends:
-        liquid-base                    -- Add this!
-      , liquidhaskell
-  default-language: Haskell2010
-  ghc-options: -fplugin=LiquidHaskell  -- Add this!
-@
-
-Let's now define a very simple module called 'Toy.A':
-
-@
-module Toy.A ( notThree, one, two) where
-
-\{\-\@ one :: {v:Int | v = 1 } \@\-\}
-one :: Int
-one = 1
-
-\{\-\@ assume notThree :: {v : Nat | v != 3 } \@\-\}
-notThree :: Int
-notThree = 4
-
-\{\-\@ two :: Nat \@\-\}
-two :: Int
-two = one + one
-@
-
-Now, if we build the package with (for example) @cabal v2-build toy-package-a@, we should see something
-like this:
-
-@
-Resolving dependencies...
-Build profile: -w ghc-8.10.1 -O1
-In order, the following will be built (use -v for more details):
- - toy-package-a-0.1.0.0 (lib) (configuration changed)
-Configuring library for toy-package-a-0.1.0.0..
-Warning: The 'license-file' field refers to the file 'LICENSE' which does not
-exist.
-Preprocessing library for toy-package-a-0.1.0.0..
-Building library for toy-package-a-0.1.0.0..
-
-[3 of 3] Compiling Toy.A            ( src\/Toy\/A.hs, ... )
-
-**** LIQUID: SAFE (7 constraints checked) **************************************
-@
-
-The \"SAFE\" banner here is LH's way of saying "all is well". What happens if we try to violate a
-refinement? Let's find out. If change @one@ to look like this:
-
-@
-{-@ one :: {v:Int | v = 1 } @-}
-one :: Int
-one = 2
-@
-
-Upon next recompilation, GHC (or rather, /LH/) will bark at us:
-
-@
-Building library for toy-package-a-0.1.0.0..
-[3 of 3] Compiling Toy.A            ( src\/Toy\/A.hs, ... )
-
-**** LIQUID: UNSAFE ************************************************************
-
-src\/Toy\/A.hs:36:1: error:
-    Liquid Type Mismatch
-    .
-    The inferred type
-      VV : {v : GHC.Types.Int | v == 2}
-    .
-    is not a subtype of the required type
-      VV : {VV : GHC.Types.Int | VV == 1}
-    .
-   |
-36 | one = 2
-   | ^^^^^^^
-@
-
--}
-
-{- $passingOptions
-
-Passing options to /LH/ is possible and works using the standard mechanism the plugin system already provides.
-For example let's image we want to skip verification of our 'Toy.A' module. At this point, we have two options:
-
-1. We can add the option directly in the module, as a \"pragma\":
-
-    @
-    \{\-\@ LIQUID "--compilespec" \@\-\}
-    module Toy.A ( notThree, one, two) where
-    ...
-    @
-
-2. We can add this \"globally\" (if that's really what we want), like this:
-
-    @
-    cabal-version: 1.12
-    name:           toy-package-a
-      ..
-      default-language: Haskell2010
-      ghc-options: -fplugin=LiquidHaskell -fplugin-opt=LiquidHaskell:--compilespec
-    @
-
--}
-
-{- $usingGHCi
-
-Using GHCi is supported out of the box, and it will work as expected.
-
--}
-
-{- $specResolutionStrategies
-
-Let's revisit our 'Toy.A' module. There are two different ways to annotate an existing Haskell module,
-and they are the following:
-
-1. __(Recommended)__ Add the /LH/ annotations directly inside the Haskell file (like in the example above).
-   This has the advantage that any changes to the annotations trigger recompilation, and ensure the specs
-   will never get stale and go out-of-sync. The disadvantage of this approach is that it can clutter quite a
-   bit the target 'Module'.
-
-2. Add the specifications as a separate __companion__ @.spec@ file to be placed alongside the Haskell one.
-   To rehash the example above, we could have also added a new @Toy/A.spec@ file living in the same folder
-   of our @A.hs@ file, with a content like this:
-
-   @
-   module spec Toy.A where
-
-   one :: {v:Int | v = 1 }
-   assume notThree :: {v : Nat | v != 3 }
-   two :: Nat
-   @
-
-   This has the advantage of being more compartmentalised, but it's also a weakness as it might not be
-   immediately obvious that a Haskell module has associated refinements.
-
--}
-
-{- $specForExisting
-
-If you have control over the package or project you would like to annotate with /LH/ refinements, all is well.
-But what about packages you don't own or maintain? Typically, one solution would be to convince the
-project's maintainers to get on board and to add /LH/ annotations to the code themselves, but this might not
-be so easy, for a number of reasons:
-
-* The package you are trying to \"refine\" is not maintained anymore, or the maintainer is very difficult
-  to reach;
-
-* The package is fairly important in the Haskell ecosystem and making changes to it might not be so easy,
-  especially for packages which come as part of a GHC installation (think @base@, for example).
-
-The designed workflow in these cases is to create a __brand new package__ (that we can call \"mirror\" package),
-which would re-export /everything/ from the \"mirrored\" package while adding all the required /LH/
-annotations. This is what we have done for things like @base@, @ghc-prim@ and @containers@, for example, by
-providing @liquid-containers@, @liquid-ghc-prim@ and @liquid-base@, the latter being what we have used in
-the tutorial to get started.
-
-There are some very simple guidelines to drive this process:
-
-1. Typically you want to clearly identify this package as part of the /LH ecosystem/ by using an
-   appropriate prefix for your package name, something like @liquid-foo@ where @foo@ is the original
-   package you are adding annotations for;
-
-2. You need to abide to a set of PVP rules, like tracking the version of the upstream package first and
-   in case of changes to either the LH language or the specs in the mirror package, bump the last two
-   digits of the version scheme, in a format like this:
-
-   @liquid-\<package-name\>-A.B.C.D.X.Y@
-
-   Where @A.B.C.D@ would be used to track the upstream package version and @X.Y@ would enumerate the
-   versions of this mirror package. Bumping @X@ would signify there was a breaking change in the /LH/
-   language that required a new release of this plugin, whereas bumping @Y@ would mean something changed
-   in the __specs__ provided as part of this mirror package (e.g. more refinements were added, bugs were
-   fixed etc).
--}
diff --git a/src/Language/Haskell/Liquid/GHC/Plugin/Types.hs b/src/Language/Haskell/Liquid/GHC/Plugin/Types.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Plugin/Types.hs
+++ /dev/null
@@ -1,231 +0,0 @@
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE StandaloneDeriving #-}
-{-# LANGUAGE LambdaCase #-}
-{-# LANGUAGE GADTs #-}
-{-# LANGUAGE EmptyDataDecls #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE NamedFieldPuns #-}
-{-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DeriveGeneric #-}
-
-module Language.Haskell.Liquid.GHC.Plugin.Types
-    ( SpecComment(..)
-
-    -- * Dealing with specs and their dependencies
-    , LiquidLib
-    , mkLiquidLib
-    , libTarget
-    , libDeps
-    , allDeps
-    , addLibDependencies
-
-    -- * Caching specs into interfaces
-    , CachedSpec
-    , toCached
-    , cachedSpecStableModuleId
-    , cachedSpecModule
-    , fromCached
-
-    -- * Merging specs together
-    , InputSpec
-    , CompanionSpec
-    , LiquidSpec
-    , downcastSpec
-    , mkInputSpec
-    , mkCompanionSpec
-    , mergeInputWithCompanion
-
-    -- * Carrying data across stages of the compilation pipeline
-    , PipelineData(..)
-
-    -- * Acquiring and manipulating data from the typechecking phase
-    , TcData
-    , tcAllImports
-    , tcQualifiedImports
-    , tcResolvedNames
-    , tcAvailableTyCons
-    , tcAvailableVars
-    , mkTcData
-
-    -- * Wrapper type to talk about unoptimised things
-    , Unoptimised(fromUnoptimised)
-    , toUnoptimised
-    ) where
-
-import           Data.Binary                             as B
-import           Data.Data                                ( Data )
-import           Data.Foldable
-import           Outputable                        hiding ( (<>) )
-import           GHC.Generics                      hiding ( moduleName )
-import           HscTypes                                 (ModGuts)
-import           GHC                                      ( Name
-                                                          , TyThing
-                                                          , TyCon
-                                                          , LImportDecl
-                                                          , GhcRn
-                                                          )
-import           Var                                      ( Var )
-import           Module                                   ( Module, moduleStableString )
-
-import qualified Data.HashSet        as HS
-import           Data.Hashable
-
-import           Language.Fixpoint.Types.Spans
-import           Language.Haskell.Liquid.Types.Specs
-import qualified Language.Haskell.Liquid.GHC.Interface   as LH
-import           Language.Fixpoint.Types.Names            ( Symbol )
-
-
-data LiquidLib = LiquidLib
-  {  llTarget :: LiftedSpec
-  -- ^ The target /LiftedSpec/.
-  ,  llDeps   :: TargetDependencies
-  -- ^ The specs which were necessary to produce the target 'BareSpec'.
-  } deriving (Show, Generic)
-
-instance B.Binary LiquidLib
-
--- | Creates a new 'LiquidLib' with no dependencies.
-mkLiquidLib :: LiftedSpec -> LiquidLib
-mkLiquidLib s = LiquidLib s mempty
-
--- | Adds a set of dependencies to the input 'LiquidLib'.
-addLibDependencies :: TargetDependencies -> LiquidLib -> LiquidLib
-addLibDependencies deps lib = lib { llDeps = deps <> (llDeps lib) }
-
--- | Returns the target 'LiftedSpec' of this 'LiquidLib'.
-libTarget :: LiquidLib -> LiftedSpec
-libTarget = llTarget
-
--- | Returns all the dependencies of this 'LiquidLib'.
-libDeps :: LiquidLib -> TargetDependencies
-libDeps = llDeps
-
--- | Extracts all the dependencies from a collection of 'LiquidLib's.
-allDeps :: Foldable f => f LiquidLib -> TargetDependencies
-allDeps = foldl' (\acc lib -> acc <> llDeps lib) mempty
-
--- | A cached spec which can be serialised into an interface.
-data CachedSpec = CachedSpec StableModule LiftedSpec deriving (Show, Generic)
-
-instance Binary CachedSpec
-
-instance Eq CachedSpec where
-    (CachedSpec id1 _) == (CachedSpec id2 _) = id1 == id2
-
-instance Hashable CachedSpec where
-    hashWithSalt s (CachedSpec (StableModule mdl) _) =
-      hashWithSalt s (moduleStableString mdl)
-
--- | Converts the input 'BareSpec' into a 'CachedSpec', inforcing the invariant that termination checking
--- needs to be disabled as this is now considered safe to use for \"clients\".
-toCached :: Module -> LiftedSpec -> CachedSpec
-toCached mdl liftedSpec = CachedSpec (toStableModule mdl) liftedSpec
-
-cachedSpecStableModuleId :: CachedSpec -> String
-cachedSpecStableModuleId (CachedSpec (StableModule m) _) = moduleStableString m
-
-cachedSpecModule :: CachedSpec -> Module
-cachedSpecModule (CachedSpec (StableModule m) _) = m
-
-fromCached :: CachedSpec -> (StableModule, LiftedSpec)
-fromCached (CachedSpec sm s) = (sm, s)
-
----
---- A Liquid spec and its (many) flavours
----
-
-data InputSpec
-data CompanionSpec
-
-data LiquidSpec t where
-    MkInputSpec     :: BareSpec   -> LiquidSpec InputSpec
-    MkCompanionSpec :: BareSpec   -> LiquidSpec CompanionSpec
-
-deriving instance Show (LiquidSpec InputSpec)
-deriving instance Show (LiquidSpec CompanionSpec)
-
-mkInputSpec :: BareSpec -> LiquidSpec InputSpec
-mkInputSpec = MkInputSpec
-
-mkCompanionSpec :: BareSpec -> LiquidSpec CompanionSpec
-mkCompanionSpec = MkCompanionSpec
-
-downcastSpec :: LiquidSpec t -> BareSpec
-downcastSpec = \case
-  MkInputSpec s    -> s
-  MkCompanionSpec s -> s
-
--- | Merges a 'InputSpec' with its 'CompanionSpec'. Here duplicates are not checked as it's
--- user's responsibility to make sure there are no duplicates between the in-module annotations and the
--- companion spec.
-mergeInputWithCompanion :: LiquidSpec InputSpec -> LiquidSpec CompanionSpec -> LiquidSpec InputSpec
-mergeInputWithCompanion (MkInputSpec s1) (MkCompanionSpec s2) = MkInputSpec (s1 <> s2)
-
--- | Just a small wrapper around the 'SourcePos' and the text fragment of a LH spec comment.
-newtype SpecComment =
-    SpecComment (SourcePos, String)
-    deriving (Show, Data)
-
-newtype Unoptimised a = Unoptimised { fromUnoptimised :: a }
-
-toUnoptimised :: a -> Unoptimised a
-toUnoptimised = Unoptimised
-
---
--- Passing data between stages of the pipeline
---
--- The plugin architecture doesn't provide a default system to \"thread\" data across stages of the
--- compilation pipeline, which means that plugin implementors have two choices:
---
--- 1. Serialise any data they want to carry around inside annotations, but this can be potentially costly;
--- 2. Pass data inside IORefs.
-
-data PipelineData = PipelineData {
-    pdUnoptimisedCore :: Unoptimised ModGuts
-  , pdTcData :: TcData
-  , pdSpecComments :: [SpecComment]
-  }
-
--- | Data which can be \"safely\" passed to the \"Core\" stage of the pipeline.
--- The notion of \"safely\" here is a bit vague: things like imports are somewhat
--- guaranteed not to change, but things like identifiers might, so they shouldn't
--- land here.
-data TcData = TcData {
-    tcAllImports       :: HS.HashSet Symbol
-  , tcQualifiedImports :: QImports
-  , tcResolvedNames    :: [(Name, Maybe TyThing)]
-  , tcAvailableTyCons  :: [GHC.TyCon]
-  -- ^ Sometimes we might be in a situation where we have \"wrapper\" modules that
-  -- simply re-exports everything from the original module, and therefore when LH
-  -- tries to resolve the GHC identifier associated to a data constructor in scope
-  -- (from the call to 'lookupTyThings') we might not be able to find a match because
-  -- the 'mg_tcs' for the input 'ModGuts' is empty (because the type constructor are not
-  -- defined in the /wrapper/ module, but rather in the /wrapped/ module itself). This is
-  -- why we look at the 'ModGuts' 's 'AvailInfo' to extract any re-exported 'TyCon' out of that.
-  , tcAvailableVars    :: [Var]
-  -- ^ Ditto as for 'reflectedTyCons', but for identifiers.
-  }
-
-instance Outputable TcData where
-    ppr (TcData{..}) =
-          text "TcData { imports     = " <+> text (show $ HS.toList tcAllImports)
-      <+> text "       , qImports    = " <+> text (show tcQualifiedImports)
-      <+> text "       , names       = " <+> ppr tcResolvedNames
-      <+> text "       , availTyCons = " <+> ppr tcAvailableTyCons
-      <+> text " }"
-
--- | Constructs a 'TcData' out of a 'TcGblEnv'.
-mkTcData :: [LImportDecl GhcRn]
-         -> [(Name, Maybe TyThing)]
-         -> [TyCon]
-         -> [Var]
-         -> TcData
-mkTcData imps resolvedNames availTyCons availVars = TcData {
-    tcAllImports       = LH.allImports       imps
-  , tcQualifiedImports = LH.qualifiedImports imps
-  , tcResolvedNames    = resolvedNames
-  , tcAvailableTyCons  = availTyCons
-  , tcAvailableVars    = availVars
-  }
diff --git a/src/Language/Haskell/Liquid/GHC/Plugin/Util.hs b/src/Language/Haskell/Liquid/GHC/Plugin/Util.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Plugin/Util.hs
+++ /dev/null
@@ -1,106 +0,0 @@
-{-# LANGUAGE TypeApplications #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-module Language.Haskell.Liquid.GHC.Plugin.Util (
-        partitionMaybe
-      , extractSpecComments
-
-      -- * Serialising and deserialising things from/to specs.
-      , serialiseLiquidLib
-      , deserialiseLiquidLib
-
-      -- * Aborting the plugin execution
-      , pluginAbort
-      ) where
-
-import           GhcPlugins                              as GHC
-import           UniqDFM
-import           IfaceSyn
-import           Panic                                    ( throwGhcExceptionIO, GhcException(..) )
-import           Data.Foldable                            ( asum )
-
-import           Control.Monad.IO.Class
-import           Control.Monad
-
-import qualified Data.Binary                             as B
-import           Data.Binary                              ( Binary )
-import qualified Data.ByteString.Lazy                    as B
-import           Data.Typeable
-import           Data.Maybe                               ( listToMaybe )
-import           Data.Data
-import           Data.Either                              ( partitionEithers )
-
-import           Language.Haskell.Liquid.GHC.Plugin.Types ( SpecComment
-                                                          , LiquidLib
-                                                          )
-
-
-pluginAbort :: MonadIO m => String -> m a
-pluginAbort = liftIO . throwGhcExceptionIO . ProgramError
-
--- | Courtesy of [inspection testing](https://github.com/nomeata/inspection-testing/blob/master/src/Test/Inspection/Plugin.hs)
-partitionMaybe :: (a -> Maybe b) -> [a] -> ([a], [b])
-partitionMaybe f = partitionEithers . map (\x -> maybe (Left x) Right (f x))
-
--- | Extracts the spec comments from the Core 'Annotation's. It returns a
--- "cleaned" 'ModGuts' which doesn't contain the deserialised 'Annotation's.
--- This also means that these 'Annotation's /won't/ land into an interface file,
--- and we won't be able to retrieve them back later on.
-extractSpecComments :: ModGuts -> (ModGuts, [SpecComment])
-extractSpecComments = extractModuleAnnotations
-
--- | Tries to deserialise the 'Annotation's in the input 'ModGuts', pruning the latter
--- upon successful deserialisation.
-extractModuleAnnotations :: forall a. (Typeable a, Data a) => ModGuts -> (ModGuts, [a])
-extractModuleAnnotations guts = (guts', extracted)
-  where
-    thisModule = mg_module guts
-    (anns_clean, extracted) = partitionMaybe tryDeserialise (mg_anns guts)
-    guts' = guts { mg_anns = anns_clean }
-
-    tryDeserialise :: Annotation -> Maybe a
-    tryDeserialise (Annotation (ModuleTarget m) payload)
-        | thisModule == m = fromSerialized deserializeWithData payload
-        | otherwise       = Nothing
-    tryDeserialise (Annotation (NamedTarget _) payload) --NOTE(adn) What is the correct behaviour here?
-        | Just a <- fromSerialized deserializeWithData payload
-        = Just a
-    tryDeserialise _
-        = Nothing
-
---
--- Serialising and deserialising Specs
---
-
-deserialiseBinaryObject :: forall a. (Typeable a, Binary a)
-                        => Module
-                        -> ExternalPackageState
-                        -> HomePackageTable
-                        -> Maybe a
-deserialiseBinaryObject thisModule eps hpt = asum [extractFromHpt, extractFromEps]
-  where
-    extractFromEps :: Maybe a
-    extractFromEps = listToMaybe $ findAnns deserialise (eps_ann_env eps) (ModuleTarget thisModule)
-
-    extractFromHpt :: Maybe a
-    extractFromHpt = do
-      modInfo <- lookupUDFM hpt (moduleName thisModule)
-      guard (thisModule == (mi_module . hm_iface $ modInfo))
-      xs <- mapM (fromSerialized deserialise . ifAnnotatedValue) (mi_anns . hm_iface $ modInfo)
-      listToMaybe xs
-
-    deserialise :: [B.Word8] -> a
-    deserialise payload = B.decode (B.pack payload)
-
-serialiseBinaryObject :: forall a. (Binary a, Typeable a) => a -> Module -> Annotation
-serialiseBinaryObject obj thisModule = serialised
-  where
-    serialised :: Annotation
-    serialised = Annotation (ModuleTarget thisModule) (toSerialized (B.unpack . B.encode) obj)
-
--- | Serialise a 'LiquidLib', removing the termination checks from the target.
-serialiseLiquidLib :: LiquidLib -> Module -> Annotation
-serialiseLiquidLib lib = serialiseBinaryObject @LiquidLib lib
-
-deserialiseLiquidLib :: Module -> ExternalPackageState -> HomePackageTable -> Maybe LiquidLib
-deserialiseLiquidLib thisModule = deserialiseBinaryObject @LiquidLib thisModule
diff --git a/src/Language/Haskell/Liquid/GHC/Resugar.hs b/src/Language/Haskell/Liquid/GHC/Resugar.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Resugar.hs
+++ /dev/null
@@ -1,170 +0,0 @@
-{-# LANGUAGE CPP                       #-}
-{-# LANGUAGE OverloadedStrings         #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE GADTs                     #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE RankNTypes                #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE UndecidableInstances      #-}
-
--- | This module contains functions for "resugaring" low-level GHC `CoreExpr`
---   into high-level patterns, that can receive special case handling in
---   different phases (e.g. ANF, Constraint Generation, etc.)
-
-module Language.Haskell.Liquid.GHC.Resugar (
-  -- * High-level Source Patterns
-    Pattern (..)
-
-  -- * Lift a CoreExpr into a Pattern
-  , lift
-
-  -- * Lower a pattern back into a CoreExpr
-  , lower
-  ) where
-
-import           DataCon      (DataCon)
-import           CoreSyn
-import           Type
-import qualified MkCore
-import qualified PrelNames as PN
-import           Name         (Name, getName)
-import qualified Data.List as L
-import qualified Language.Haskell.Liquid.GHC.Misc as GM
-import qualified Language.Fixpoint.Types          as F 
-import qualified Text.PrettyPrint.HughesPJ        as PJ 
--- import           Debug.Trace
-
---------------------------------------------------------------------------------
--- | Data type for high-level patterns -----------------------------------------
---------------------------------------------------------------------------------
-
-data Pattern
-  = PatBind
-      { patE1  :: !CoreExpr
-      , patX   :: !Var
-      , patE2  :: !CoreExpr
-      , patM   :: !Type
-      , patDct :: !CoreExpr
-      , patTyA :: !Type
-      , patTyB :: !Type
-      , patFF  :: !Var
-      }                      -- ^ e1 >>= \x -> e2
-
-  | PatReturn                -- return @ m @ t @ $dT @ e
-     { patE    :: !CoreExpr  -- ^ e
-     , patM    :: !Type      -- ^ m
-     , patDct  :: !CoreExpr  -- ^ $dT
-     , patTy   :: !Type      -- ^ t
-     , patRet  :: !Var       -- ^ "return"
-     }
-
-  | PatProject               -- (case xe as x of C [x1,...,xn] -> xi) : ty
-    { patXE    :: !Var       -- ^ xe
-    , patX     :: !Var       -- ^ x
-    , patTy    :: !Type      -- ^ ty
-    , patCtor  :: !DataCon   -- ^ C
-    , patBinds :: ![Var]     -- ^ [x1,...,xn]
-    , patIdx   :: !Int       -- ^ i :: NatLT {len patBinds}
-    }
-
-  | PatSelfBind              -- let x = e in x
-    { patX     :: !Var       -- ^ x
-    , patE     :: !CoreExpr  -- ^ e
-    }
-
-  | PatSelfRecBind           -- letrec x = e in x
-    { patX     :: !Var       -- ^ x
-    , patE     :: !CoreExpr  -- ^ e
-    }
-
-instance F.PPrint Pattern where 
-  pprintTidy  = ppPat
-
-ppPat :: F.Tidy -> Pattern -> PJ.Doc 
-ppPat k (PatReturn e m d t rv) = 
-  "PatReturn: " 
-  PJ.$+$ 
-  F.pprintKVs k
-    [ ("rv" :: PJ.Doc, GM.pprDoc rv) 
-    , ("e " :: PJ.Doc, GM.pprDoc e) 
-    , ("m " :: PJ.Doc, GM.pprDoc m) 
-    , ("$d" :: PJ.Doc, GM.pprDoc d) 
-    , ("t " :: PJ.Doc, GM.pprDoc t) 
-    ] 
-ppPat _ _  = "TODO: PATTERN" 
-    
-
-_mbId :: CoreExpr -> Maybe Var
-_mbId (Var x)    = Just x
-_mbId (Tick _ e) = _mbId e
-_mbId _          = Nothing
-
---------------------------------------------------------------------------------
--- | Lift expressions into High-level patterns ---------------------------------
---------------------------------------------------------------------------------
-lift :: CoreExpr -> Maybe Pattern
---------------------------------------------------------------------------------
-lift e = exprArgs e (collectArgs e)
-
-exprArgs :: CoreExpr -> (CoreExpr, [CoreExpr]) -> Maybe Pattern
-exprArgs _e (Var op, [Type m, d, Type a, Type b, e1, Lam x e2])
-  | op `is` PN.bindMName
-  = Just (PatBind e1 x e2 m d a b op)
-
-exprArgs (Case (Var xe) x t [(DataAlt c, ys, Var y)]) _
-  | Just i <- y `L.elemIndex` ys
-  = Just (PatProject xe x t c ys i)
-
-
-{- TEMPORARILY DISABLED: TODO-REBARE; in reality it hasn't been working AT ALL 
-   since at least the GHC 8.2.1 port (?) because the TICKs get in the way 
-   of recognizing the pattern? Anyways, messes up 
-
-     tests/pattern/pos/Return00.hs  
-
-   because we treat _all_ types of the form `m a` as "invariant" in the parameter `a`.
-   Looks like the above tests only pass in earlier LH versions because this pattern 
-   was NOT getting tickled!
-
-exprArgs _e (Var op, [Type m, d, Type t, e])
-  | op `is` PN.returnMName
-  = Just (PatReturn e m d t op)
--}
-
-{- TEMPORARILY DISBLED
-
-exprArgs (Let (NonRec x e) e') _
-  | Just y <- _mbId e', x == y
-  = Just (PatSelfBind x e)
-
-exprArgs (Let (Rec [(x, e)]) e') _
-  | Just y <- _mbId e', x == y
-  = Just (PatSelfRecBind x e)
-
--}
-exprArgs _ _
-  = Nothing
-
-is :: Var -> Name -> Bool
-is v n = n == getName v
-
---------------------------------------------------------------------------------
--- | Lower patterns back into expressions --------------------------------------
---------------------------------------------------------------------------------
-lower :: Pattern -> CoreExpr
---------------------------------------------------------------------------------
-lower (PatBind e1 x e2 m d a b op)
-  = MkCore.mkCoreApps (Var op) [Type m, d, Type a, Type b, e1, Lam x e2]
-
-lower (PatReturn e m d t op)
-  = MkCore.mkCoreApps (Var op) [Type m, d, Type t, e]
-
-lower (PatProject xe x t c ys i)
-  = Case (Var xe) x t [(DataAlt c, ys, Var yi)] where yi = ys !! i
-
-lower (PatSelfBind x e)
-  = Let (NonRec x e) (Var x)
-
-lower (PatSelfRecBind x e)
-  = Let (Rec [(x, e)]) (Var x)
diff --git a/src/Language/Haskell/Liquid/GHC/SpanStack.hs b/src/Language/Haskell/Liquid/GHC/SpanStack.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/SpanStack.hs
+++ /dev/null
@@ -1,78 +0,0 @@
-{-# LANGUAGE BangPatterns #-}
-
-module Language.Haskell.Liquid.GHC.SpanStack
-   ( -- * Stack of positions
-     Span (..)
-   , SpanStack
-
-     -- * Creating Stacks
-   , empty, push
-
-     -- * Using Stacks
-   , srcSpan
-
-     -- * Creating general spans
-   , showSpan
-   ) where
-
-import           Prelude                   hiding (error)
-import           SrcLoc
-import qualified Var
-import           CoreSyn                   hiding (Tick, Var)
-import           Name                             (getSrcSpan)
-import           FastString                       (fsLit)
-import           Data.Maybe                       (listToMaybe, fromMaybe)
-import           Language.Haskell.Liquid.GHC.Misc (tickSrcSpan, showPpr)
-
--- | Opaque type for a stack of spans
-newtype SpanStack = SpanStack { unStack :: [(Span, SrcSpan)] }
-
---------------------------------------------------------------------------------
-empty :: SpanStack
---------------------------------------------------------------------------------
-empty = SpanStack []
-
---------------------------------------------------------------------------------
-push :: Span -> SpanStack -> SpanStack
---------------------------------------------------------------------------------
-push !s stk -- @(SpanStack stk)
-  | Just sp <- spanSrcSpan s = SpanStack ((s, sp) : unStack stk)
-  | otherwise                = stk
-
--- | A single span
-data Span
-  = Var  !Var.Var           -- ^ binder for whom we are generating constraint
-  | Tick !(Tickish Var.Var) -- ^ nearest known Source Span
-  | Span SrcSpan
-
-instance Show Span where
-  show (Var x)   = show x
-  show (Tick tt) = showPpr tt
-  show (Span s)  = show s 
-
---------------------------------------------------------------------------------
-srcSpan :: SpanStack -> SrcSpan
---------------------------------------------------------------------------------
-srcSpan s  = fromMaybe noSpan (mbSrcSpan s)
-  where
-    noSpan = showSpan "Yikes! No source information"
-
-mbSrcSpan :: SpanStack -> Maybe SrcSpan
-mbSrcSpan = fmap snd . listToMaybe  . unStack
-
-spanSrcSpan :: Span -> Maybe SrcSpan
-spanSrcSpan      = maybeSpan Nothing . go
-  where
-    go (Var x)   = getSrcSpan x
-    go (Tick tt) = tickSrcSpan tt
-    go (Span s)  = s 
-
-maybeSpan :: Maybe SrcSpan -> SrcSpan -> Maybe SrcSpan
-maybeSpan d sp
-  | isGoodSrcSpan sp = Just sp
-  | otherwise        = d
-
---------------------------------------------------------------------------------
-showSpan :: (Show a) => a -> SrcSpan
---------------------------------------------------------------------------------
-showSpan = mkGeneralSrcSpan . fsLit . show
diff --git a/src/Language/Haskell/Liquid/GHC/TypeRep.hs b/src/Language/Haskell/Liquid/GHC/TypeRep.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/TypeRep.hs
+++ /dev/null
@@ -1,187 +0,0 @@
-{-# LANGUAGE CPP                       #-}
-{-# LANGUAGE OverloadedStrings         #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE GADTs                     #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE RankNTypes                #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE UndecidableInstances      #-}
-{-# LANGUAGE ViewPatterns              #-}
-{-# LANGUAGE PatternSynonyms           #-}
-{-# LANGUAGE StandaloneDeriving        #-}
-
--- | This module contains a wrappers and utility functions for
--- accessing GHC module information. It should NEVER depend on
-module Language.Haskell.Liquid.GHC.TypeRep (
-  mkTyArg, 
-
-  showTy
-  ) where
-
-import Coercion
-import CoAxiom
-
-import           Language.Haskell.Liquid.GHC.Misc (showPpr)
-import           Language.Haskell.Liquid.GHC.API as Ghc hiding (mkTyArg)
-import           Language.Fixpoint.Types (symbol)
-
--- e368f3265b80aeb337fbac3f6a70ee54ab14edfd
-
-mkTyArg :: TyVar -> TyVarBinder
-mkTyArg v = Bndr v Required
-
-instance Eq Type where
-  t1 == t2 = eqType' t1 t2
-
-eqType' :: Type -> Type -> Bool 
-eqType' (LitTy l1) (LitTy l2) 
-  = l1 == l2  
-eqType' (CoercionTy c1) (CoercionTy c2) 
-  = c1 == c2  
-eqType'(CastTy t1 c1) (CastTy t2 c2) 
-  = eqType' t1 t2 && c1 == c2 
-eqType' (FunTy a1 t11 t12) (FunTy a2 t21 t22)
-  = a1 == a2 && eqType' t11 t21 && eqType' t12 t22  
-eqType' (ForAllTy (Bndr v1 _) t1) (ForAllTy (Bndr v2 _) t2) 
-  = eqType' t1 (subst v2 (TyVarTy v1) t2) 
-eqType' (TyVarTy v1) (TyVarTy v2) 
-  = v1 == v2 
-eqType' (AppTy t11 t12) (AppTy t21 t22) 
-  = eqType' t11 t21 && eqType' t12 t22  
-eqType' (TyConApp c1 ts1) (TyConApp c2 ts2) 
-  = c1 == c2 && and (zipWith eqType' ts1 ts2) 
-eqType' _ _ 
-  = False 
-
-
-deriving instance (Eq tyvar, Eq argf) => Eq (VarBndr tyvar argf)
-
-instance Eq Coercion where
-  _ == _ = True 
-
-
-showTy :: Type -> String 
-showTy (TyConApp c ts) = "(RApp   " ++ showPpr c ++ " " ++ sep' ", " (showTy <$> ts) ++ ")"
-showTy (AppTy t1 t2)   = "(TAppTy " ++ (showTy t1 ++ " " ++ showTy t2) ++ ")" 
-showTy (TyVarTy v)   = "(RVar " ++ show (symbol v)  ++ ")" 
-showTy (ForAllTy (Bndr v _) t)  = "ForAllTy " ++ show (symbol v) ++ ". (" ++  showTy t ++ ")"
-showTy (FunTy af t1 t2) = "FunTy " ++ showPpr af ++ " " ++ showTy t1 ++ ". (" ++  showTy t2 ++ ")"
-showTy (CastTy _ _)    = "CastTy"
-showTy (CoercionTy _)  = "CoercionTy"
-showTy (LitTy _)       = "LitTy"
-
-sep' :: String -> [String] -> String
-sep' _ [x] = x
-sep' _ []  = []
-sep' s (x:xs) = x ++ s ++ sep' s xs 
-
-
-
--------------------------------------------------------------------------------
--- | GHC Type Substitutions ---------------------------------------------------
--------------------------------------------------------------------------------
-
-class SubstTy a where
-  subst :: TyVar -> Type -> a -> a
-  subst _ _ = id  
-
-instance SubstTy Type where
-  subst = substType
-
-substType :: TyVar -> Type -> Type -> Type
-substType x tx (TyConApp c ts) 
-  = TyConApp c (subst x tx <$> ts)
-substType x tx (AppTy t1 t2)   
-  = AppTy (subst x tx t1) (subst x tx t2) 
-substType x tx (TyVarTy y)   
-  | symbol x == symbol y
-  = tx 
-  | otherwise
-  = TyVarTy y 
-substType x tx (FunTy aaf t1 t2)
-  = FunTy aaf (subst x tx t1) (subst x tx t2)
-substType x tx f@(ForAllTy b@(Bndr y _) t)  
-  | symbol x == symbol y 
-  = f
-  | otherwise 
-  = ForAllTy b (subst x tx t)
-substType x tx (CastTy t c)    
-  = CastTy (subst x tx t) (subst x tx c)
-substType x tx (CoercionTy c)  
-  = CoercionTy $ subst x tx c 
-substType _ _  (LitTy l)
-  = LitTy l  
-
-
-instance SubstTy Coercion where
-  subst = substCoercion
-
-substCoercion :: TyVar -> Type -> Coercion -> Coercion
-substCoercion x tx (TyConAppCo r c cs)
-  = TyConAppCo (subst x tx r) c (subst x tx <$> cs)
-substCoercion x tx (AppCo c1 c2)
-  = AppCo (subst x tx c1) (subst x tx c2)
-substCoercion x tx (FunCo r c1 c2)
-  = FunCo r (subst x tx c1) (subst x tx c2)
-substCoercion x tx (ForAllCo y c1 c2)
-  | symbol x == symbol y 
-  = (ForAllCo y c1 c2)
-  | otherwise 
-  = ForAllCo y (subst x tx c1) (subst x tx c2)
-substCoercion _ _ (CoVarCo y)
-  = CoVarCo y 
-substCoercion x tx (AxiomInstCo co bi cs)
-  = AxiomInstCo (subst x tx co) bi (subst x tx <$> cs)  
-substCoercion x tx (UnivCo y r t1 t2)
-  = UnivCo (subst x tx y) (subst x tx r) (subst x tx t1) (subst x tx t2)
-substCoercion x tx (SymCo c)
-  = SymCo (subst x tx c)
-substCoercion x tx (TransCo c1 c2)
-  = TransCo (subst x tx c1) (subst x tx c2)
-substCoercion x tx (AxiomRuleCo ca cs)
-  = AxiomRuleCo (subst x tx ca)  (subst x tx <$> cs)  
-substCoercion x tx (NthCo r i c)
-  = NthCo r i (subst x tx c)
-substCoercion x tx (LRCo i c)
-  = LRCo i (subst x tx c)
-substCoercion x tx (InstCo c1 c2)
-  = InstCo (subst x tx c1) (subst x tx c2)
-substCoercion x tx (KindCo c)
-  = KindCo (subst x tx c)
-substCoercion x tx (SubCo c)
-  = SubCo (subst x tx c)
-#ifdef MIN_VERSION_GLASGOW_HASKELL
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,5,0) && !MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)
-substCoercion x tx (Refl r t)
-  = Refl (subst x tx r) (subst x tx t)
-substCoercion x tx (CoherenceCo c1 c2)
-  = CoherenceCo (subst x tx c1) (subst x tx c2)
-#endif
-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)
-substCoercion x tx (Refl t)
-  = Refl (subst x tx t)
-substCoercion x tx (GRefl r t co) -- FIXME(adn) Is this a correct substitution?
-  = GRefl r (subst x tx t) co     -- FIXME(adn) Is this a correct substitution?
-substCoercion _x _tx (HoleCo cH)
-  = HoleCo cH                     -- FIXME(adn) Is this a correct substitution?
-#endif
-#endif
-
-instance SubstTy Role where
-instance SubstTy (CoAxiom Branched) where
-
-instance SubstTy UnivCoProvenance where
-  subst x tx (PhantomProv c)
-    = PhantomProv $ subst x tx c 
-  subst x tx (ProofIrrelProv c)
-    = ProofIrrelProv $ subst x tx c 
-  subst _ _ ch 
-    = ch 
-
-instance SubstTy CoAxiomRule where
-  subst x tx (CoAxiomRule n rs r ps) 
-    = CoAxiomRule n (subst x tx <$> rs) (subst x tx r) (\eq -> subst x tx (ps (subst x tx eq)))
-
-instance (SubstTy a, Functor m) => SubstTy (m a) where
-  subst x tx xs = subst x tx <$> xs
diff --git a/src/Language/Haskell/Liquid/GHC/Types.hs b/src/Language/Haskell/Liquid/GHC/Types.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/GHC/Types.hs
+++ /dev/null
@@ -1,80 +0,0 @@
-{-# LANGUAGE DeriveGeneric #-}
-module Language.Haskell.Liquid.GHC.Types where
-
-import           Data.HashSet (HashSet, fromList)
-import           Data.Hashable
-import           FamInstEnv
-import           GHC.Generics hiding (moduleName)
-import           Language.Haskell.Liquid.GHC.API
-
--- | A 'StableName' is virtually isomorphic to a GHC's 'Name' but crucially we don't use
--- the 'Eq' instance defined on a 'Name' because it's 'Unique'-based. In particular, GHC
--- doesn't guarantee that if we load an interface multiple times we would get the same 'Unique' for the
--- same 'Name', and this is a problem when we rely on 'Name's to be the same when we call 'isExportedVar',
--- which used to use a 'NameSet' derived from the '[AvailInfo]'. As the name implies, a 'NameSet' uses a
--- 'Name's 'Unique' for duplicate detection and indexing, and this would lead to 'Var's being resolved to
--- a 'Name' which is basically the same, but it has a /different/ 'Unique', and that would cause the lookup
--- inside the 'NameSet' to fail.
-newtype StableName =
-  MkStableName { unStableName :: Name }
-  deriving Generic
-
-instance Show StableName where
-  show (MkStableName n) = nameStableString n
-
-instance Hashable StableName where
-  hashWithSalt s (MkStableName n) = hashWithSalt s (nameStableString n)
-
-instance Eq StableName where
-  (MkStableName n1) == (MkStableName n2) = -- n1 `stableNameCmp` n2 == EQ
-    let sameOccName = (occNameString $ nameOccName n1) == (occNameString $ nameOccName n2)
-        sameModule  = nameModule  n1 == nameModule  n2
-        sameSrcLoc  = nameSrcLoc  n1 == nameSrcLoc  n2
-        sameSrcSpan = nameSrcSpan n1 == nameSrcSpan n2
-    in sameOccName && sameModule && sameSrcLoc  && sameSrcSpan
-
--- | Creates a new 'StableName' out of a 'Name'.
-mkStableName :: Name -> StableName
-mkStableName = MkStableName
-
--- | Converts a list of 'AvailInfo' into a \"StableNameSet\", similarly to what 'availsToNameSet' would do.
-availsToStableNameSet :: [AvailInfo] -> HashSet StableName
-availsToStableNameSet avails = foldr add mempty avails
-      where add av acc = acc <> fromList (map mkStableName (availNames av))
-
---------------------------------------------------------------------------------
--- | Datatype For Holding GHC ModGuts ------------------------------------------
---------------------------------------------------------------------------------
-data MGIModGuts = MI 
-  { mgi_binds     :: !CoreProgram
-  , mgi_module    :: !Module
-  , mgi_deps      :: !Dependencies
-  , mgi_dir_imps  :: ![ModuleName]
-  , mgi_rdr_env   :: !GlobalRdrEnv
-  , mgi_tcs       :: ![TyCon]
-  , mgi_fam_insts :: ![FamInst]
-  , mgi_exports   :: !(HashSet StableName)
-  , mgi_cls_inst  :: !(Maybe [ClsInst])
-  }
-
-miModGuts :: Maybe [ClsInst] -> ModGuts -> MGIModGuts
-miModGuts cls mg  = MI 
-  { mgi_binds     = mg_binds mg
-  , mgi_module    = mg_module mg
-  , mgi_deps      = mg_deps mg
-  , mgi_dir_imps  = mg_dir_imps mg
-  , mgi_rdr_env   = mg_rdr_env mg
-  , mgi_tcs       = mg_tcs mg
-  , mgi_fam_insts = mg_fam_insts mg
-  , mgi_exports   = availsToStableNameSet $ mg_exports mg
-  , mgi_cls_inst  = cls
-  }
-
-nameSetToStableNameSet :: NameSet -> HashSet StableName
-nameSetToStableNameSet = fromList . map mkStableName . nameSetElemsStable
-
-mg_dir_imps :: ModGuts -> [ModuleName]
-mg_dir_imps m = fst <$> (dep_mods $ mg_deps m)
-
-mgi_namestring :: MGIModGuts -> String
-mgi_namestring = moduleNameString . moduleName . mgi_module
diff --git a/src/Language/Haskell/Liquid/Interactive/Handler.hs b/src/Language/Haskell/Liquid/Interactive/Handler.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Interactive/Handler.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-module Language.Haskell.Liquid.Interactive.Handler (
-    -- * Initial state for server
-    initial
-
-    -- * Command handler
-  , handler
-  ) where
-
-import Prelude hiding (error)
-import Control.Concurrent.MVar
-import Language.Haskell.Liquid.Interactive.Types
-import Language.Haskell.Liquid.Liquid
-
-------------------------------------------------------------------------------
-handler :: MVar State -> Command -> IO Response
-------------------------------------------------------------------------------
-handler r = modifyMVar r . runLiquid'
-
-runLiquid' :: Command -> State -> IO (State, Response)
-runLiquid' cfg s = do
-  let mE    = sMbEnv s
-  let n     = sCount s
-  (c, mE') <- runLiquid mE cfg
-  let s'    = State (n + 1) mE'
-  return      (s', (status c, n))
-
-------------------------------------------------------------------------------
-initial :: State
-------------------------------------------------------------------------------
-initial = State 0 Nothing
diff --git a/src/Language/Haskell/Liquid/Interactive/Types.hs b/src/Language/Haskell/Liquid/Interactive/Types.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Interactive/Types.hs
+++ /dev/null
@@ -1,57 +0,0 @@
-{-# LANGUAGE DeriveGeneric      #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE FlexibleInstances  #-}
-
-module Language.Haskell.Liquid.Interactive.Types
-  (
-    -- * Commands
-    Command
-
-    -- * Response
-  , Response
-
-  , status
-
-    -- * State
-  , State (..)
-
-  ) where
-
-import Prelude        hiding (error)
-import Data.Serialize        ( Serialize )
-import GHC.Generics
-import System.Console.CmdArgs
-import System.Exit
-import Language.Haskell.Liquid.Types (Config (..))
-import Language.Haskell.Liquid.Liquid
-import Language.Fixpoint.Types ()
-
--------------------------------------------------------------------------------
--- | State --------------------------------------------------------------------
--------------------------------------------------------------------------------
-
-data State = State { sCount  :: Int
-                   , sMbEnv :: MbEnv
-                   }
-
--------------------------------------------------------------------------------
--- | Command ------------------------------------------------------------------
--------------------------------------------------------------------------------
-
-type Command = Config
-
--------------------------------------------------------------------------------
--- | Response -----------------------------------------------------------------
--------------------------------------------------------------------------------
-
-data Status = ResOk
-            | ResFail Int
-               deriving ( Generic, Data, Typeable, Show )
-
-type Response = (Status, Int)
-
-instance Serialize Status
-
-status :: ExitCode -> Status
-status ExitSuccess     = ResOk
-status (ExitFailure n) = ResFail n
diff --git a/src/Language/Haskell/Liquid/LawInstances.hs b/src/Language/Haskell/Liquid/LawInstances.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/LawInstances.hs
+++ /dev/null
@@ -1,101 +0,0 @@
-{-# LANGUAGE FlexibleContexts #-}
-module Language.Haskell.Liquid.LawInstances ( checkLawInstances ) where
-
-import qualified Data.List                                  as L
-import qualified Data.Maybe                                 as Mb
-import           Text.PrettyPrint.HughesPJ                  hiding ((<>))
-
-import           Language.Haskell.Liquid.Types
-import           Language.Haskell.Liquid.Types.Equality
-import           Language.Haskell.Liquid.GHC.API
-import qualified Language.Fixpoint.Types                     as F
-
-checkLawInstances :: GhcSpecLaws -> Diagnostics
-checkLawInstances speclaws = foldMap go (gsLawInst speclaws)
-  where go l = checkOneInstance (lilName l) (Mb.fromMaybe [] $ L.lookup (lilName l) (gsLawDefs speclaws)) l
-
-checkOneInstance :: Class -> [(Var, LocSpecType)] -> LawInstance -> Diagnostics
-checkOneInstance c laws li
-  = checkExtra c li ((fst <$> laws) ++ classMethods c) (lilEqus li) <> foldMap (\l -> checkOneLaw c l li) laws
-
-checkExtra :: Class
-           -> LawInstance
-           -> [Var]
-           -> [(VarOrLocSymbol, (VarOrLocSymbol, Maybe LocSpecType))]
-           -> Diagnostics
-checkExtra c li _laws insts =
-    let allMsgs = {- (msgExtra <$> extra) ++ -} (msgUnfoundLaw <$> unfoundLaws) ++ (msgUnfoundInstance <$> unfoundInstances)
-    in mkDiagnostics mempty (mkError <$> allMsgs)
-    where
-        unfoundInstances = [ x | (_, (Right x,_)) <- insts]
-        unfoundLaws = [ x | (Right x, _) <- insts]
-        _extra = [] -- this breaks on extra super requirements [ (x,i) | (Left x, (Left i, _)) <- insts, not (x `L.elem` laws)] 
-        mkError = ErrILaw (lilPos li) (pprint c) (pprint $ lilTyArgs li)
-        _msgExtra (x,_)      = pprint x <+> text "is not a defined law."
-        msgUnfoundLaw i      = pprint i <+> text "is not a defined law."
-        msgUnfoundInstance i = pprint i <+> text "is not a defined instance."
-
-checkOneLaw :: Class -> (Var, LocSpecType) -> LawInstance -> Diagnostics
-checkOneLaw c (x, t) li
-  | Just (Left _, Just ti) <- lix
-  = unify mkError c li t ti
-  | Just (Right _l, _) <- lix
-  = mkDiagnostics mempty [mkError (text "is not found.")]
-  | otherwise
-  = mkDiagnostics mempty [mkError (text "is not defined.")]
-  where
-    lix = L.lookup (Left x) (lilEqus li)
-    mkError txt = ErrILaw (lilPos li) (pprint c) (pprintXs $ lilTyArgs li)
-                          (text "The instance for the law" <+> pprint x <+> txt)
-    pprintXs [l] = pprint l
-    pprintXs xs  = pprint xs
-
-unify :: (Doc -> Error) -> Class -> LawInstance -> LocSpecType -> LocSpecType -> Diagnostics
-unify mkError c li t1 t2
-  = if t11 =*= t22 then emptyDiagnostics else err
-  where
-    err = mkDiagnostics mempty [mkError (text "is invalid:\nType" <+> pprint t1 <+> text "\nis different than\n" <+> pprint t2
-       --  text "\nesubt1 = " <+> pprint esubst1  
-       -- text "\nesubt = " <+> pprint esubst  
-       -- text "\ncompared\n" <+> pprint t11 <+> text "\nWITH\n" <+> pprint t22 
-           )]
-
-    t22 = fromRTypeRep (trep2 {ty_vars = [], ty_binds = fst <$> args2, ty_args = snd <$> args2, ty_refts = drop (length tc2) (ty_refts trep2)})
-    t11 = fromRTypeRep (trep1 { ty_vars = []
-                              , ty_binds = fst <$> args2
-                              , ty_args = (tx . snd) <$> args1
-                              , ty_refts = F.subst esubst <$> drop (length tc1) (ty_refts trep1)
-                              , ty_res = tx $ ty_res trep1})
-    tx = subtsSpec tsubst . F.subst esubst
-    subtsSpec = subts :: ([(TyVar, Type)] -> SpecType -> SpecType)
-
-    trep1 = toRTypeRep $ val t1 
-    trep2 = toRTypeRep $ val t2 
-    (tc1, args1) = splitTypeConstraints $ zip (ty_binds trep1) (ty_args trep1)
-    (tc2, args2) = splitTypeConstraints $ zip (ty_binds trep2) (ty_args trep2)
-    esubst = F.mkSubst (esubst1
-                 ++  [(F.symbol x, F.EVar (F.symbol y)) | (Left x, (Left y, _)) <- lilEqus li]
-                     )
-    esubst1 = zip  (fst <$> args1) ((F.EVar . fst) <$> args2)
-
-    tsubst = reverse $ zip ((\(RTV v) -> v) <$> (findTyVars tc1 ++ (ty_var_value <$> concat argVars)))
-                 (toType <$> (argBds ++ (((`RVar` mempty) . ty_var_value) <$> (fst <$> ty_vars trep2))))
-
-    (argVars, argBds) = unzip (splitForall [] . val <$> lilTyArgs li)
-
-    splitForall vs (RAllT v t _) = splitForall (v:vs) t 
-    splitForall vs  t            = (vs, t) 
-
-    findTyVars (((_x, RApp cc as _ _):_ts)) | rtc_tc cc == classTyCon c 
-      = [v | RVar v _ <- as ]
-    findTyVars (_:ts) = findTyVars ts 
-    findTyVars [] = [] 
-
-
-splitTypeConstraints :: [(F.Symbol, SpecType)] -> ([(F.Symbol, SpecType)], [(F.Symbol, SpecType)])
-splitTypeConstraints = go []  
-  where  
-    go cs (b@(_x, RApp c _ _ _):ts) 
-      | isClass c
-      = go (b:cs) ts 
-    go cs r = (reverse cs, map (\(x, t) -> (x, shiftVV t x)) r)
diff --git a/src/Language/Haskell/Liquid/Liquid.hs b/src/Language/Haskell/Liquid/Liquid.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Liquid.hs
+++ /dev/null
@@ -1,310 +0,0 @@
-{-# LANGUAGE NamedFieldPuns      #-}
-{-# LANGUAGE TupleSections       #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE RecordWildCards     #-}
-
-{-@ LIQUID "--diff"     @-}
-
-module Language.Haskell.Liquid.Liquid (
-   -- * Executable command
-    liquid
-
-   -- * Single query
-  , runLiquid
-
-   -- * Ghci State
-  , MbEnv
-
-   -- * Liquid Constraint Generation 
-  , liquidConstraints
-
-   -- * Checking a single module
-  , checkTargetInfo
-  ) where
-
-import           Prelude hiding (error)
-import           Data.Bifunctor
-import qualified Data.HashSet as S 
-import           System.Exit
-import           Text.PrettyPrint.HughesPJ
-import           Var                              (Var)
-import           CoreSyn
-import           HscTypes                         (SourceError)
-import           GHC (HscEnv)
-import           System.Console.CmdArgs.Verbosity (whenLoud, whenNormal)
-import           Control.Monad (when, unless)
-import qualified Data.Maybe as Mb
-import qualified Data.List  as L 
-import qualified Control.Exception as Ex
-import qualified Language.Haskell.Liquid.UX.DiffCheck as DC
-import           Language.Haskell.Liquid.Misc
-import           Language.Fixpoint.Misc
-import           Language.Fixpoint.Solver
-import qualified Language.Fixpoint.Types as F
-import           Language.Haskell.Liquid.Types
-import           Language.Haskell.Liquid.Synthesize (synthesize)
-import           Language.Haskell.Liquid.UX.Errors
-import           Language.Haskell.Liquid.UX.CmdLine
-import           Language.Haskell.Liquid.UX.Tidy
-import           Language.Haskell.Liquid.GHC.Misc (showCBs, ignoreCoreBinds) -- howPpr)
-import           Language.Haskell.Liquid.GHC.Interface
-import           Language.Haskell.Liquid.Constraint.Generate
-import           Language.Haskell.Liquid.Constraint.ToFixpoint
-import           Language.Haskell.Liquid.Constraint.Types
-import           Language.Haskell.Liquid.UX.Annotate (mkOutput)
-import qualified Language.Haskell.Liquid.Termination.Structural as ST
-import qualified Language.Haskell.Liquid.GHC.Misc          as GM 
-
-type MbEnv = Maybe HscEnv
-
---------------------------------------------------------------------------------
-liquid :: [String] -> IO b
---------------------------------------------------------------------------------
-liquid args = do 
-  cfg     <- getOpts args 
-  printLiquidHaskellBanner
-  (ec, _) <- runLiquid Nothing cfg
-  exitWith ec
-
---------------------------------------------------------------------------------
-liquidConstraints :: Config -> IO (Either [CGInfo] ExitCode) 
---------------------------------------------------------------------------------
-liquidConstraints cfg = do 
-  z <- actOrDie $ second Just <$> getTargetInfos Nothing cfg (files cfg)
-  case z of
-    Left e -> do
-      exitWithResult cfg (files cfg) $ mempty { o_result = e }
-      return $ Right $ resultExit e 
-    Right (gs, _) -> 
-      return $ Left $ map generateConstraints gs
-
---------------------------------------------------------------------------------
-runLiquid :: MbEnv -> Config -> IO (ExitCode, MbEnv)
---------------------------------------------------------------------------------
-runLiquid mE cfg  = do 
-  reals <- realTargets mE cfg (files cfg)
-  whenNormal $ putStrLn $ showpp (text "Targets:" <+> vcat (text <$> reals))
-  checkTargets cfg mE reals
-
-checkTargets :: Config -> MbEnv -> [FilePath] -> IO (ExitCode, MbEnv)
-checkTargets cfg  = go 
-  where
-    go env []     = return (ExitSuccess, env)
-    go env (f:fs) = do whenLoud $ colorPhaseLn Loud ("[Checking: " ++ f ++ "]") ""
-                       (ec, env') <- runLiquidTargets env cfg [f] 
-                       case ec of 
-                         ExitSuccess -> go env' fs
-                         _           -> return (ec, env')
-
-
---------------------------------------------------------------------------------
--- | @runLiquid@ checks a *target-list* of files, ASSUMING that we have 
---   already  run LH on ALL the (transitive) home imports -- i.e. other 
---   imports files for which we have source -- in order to build the .bspec 
---   files for those specs.
---------------------------------------------------------------------------------
-runLiquidTargets :: MbEnv -> Config -> [FilePath] -> IO (ExitCode, MbEnv)
---------------------------------------------------------------------------------
-runLiquidTargets mE cfg targetFiles = do
-  z <- actOrDie $ second Just <$> getTargetInfos mE cfg targetFiles
-  case z of
-    Left e -> do
-      exitWithResult cfg targetFiles $ mempty { o_result = e }
-      return (resultExit e, mE)
-    Right (gs, mE') -> do
-      d <- checkMany cfg mempty gs
-      return (ec d, mE')
-  where
-    ec = resultExit . o_result
-
---------------------------------------------------------------------------------
-checkMany :: Config -> Output Doc -> [TargetInfo] -> IO (Output Doc)
---------------------------------------------------------------------------------
-checkMany cfg d (g:gs) = do
-  d' <- checkOne cfg g
-  checkMany cfg (d `mappend` d') gs
-
-checkMany _ d [] =
-  return d
-
---------------------------------------------------------------------------------
-checkOne :: Config -> TargetInfo -> IO (Output Doc)
---------------------------------------------------------------------------------
-checkOne cfg g = do
-  z <- actOrDie $ liquidOne g
-  case z of
-    Left  e -> do
-      let out = mempty { o_result = e }
-      exitWithResult cfg [giTarget (giSrc g)] out
-      pure out
-    Right r -> return r
-
-
-actOrDie :: IO a -> IO (Either ErrorResult a)
-actOrDie act =
-    (Right <$> act)
-      `Ex.catch` (\(e :: SourceError) -> handle e)
-      `Ex.catch` (\(e :: Error)       -> handle e)
-      `Ex.catch` (\(e :: UserError)   -> handle e)
-      `Ex.catch` (\(e :: [Error])     -> handle e)
-
-handle :: (Result a) => a -> IO (Either ErrorResult b)
-handle = return . Left . result
-
---------------------------------------------------------------------------------
-liquidOne :: TargetInfo -> IO (Output Doc)
---------------------------------------------------------------------------------
-liquidOne info = do
-  out' <- checkTargetInfo info
-  unless (compileSpec cfg) $ DC.saveResult tgt out'
-  exitWithResult cfg [tgt] out'
-  pure out'
-  where
-    cfg  = getConfig info
-    tgt  = giTarget (giSrc info)
-
---------------------------------------------------------------------------------
-checkTargetInfo :: TargetInfo -> IO (Output Doc)
---------------------------------------------------------------------------------
-checkTargetInfo info
-  | compileSpec cfg = do 
-    donePhase Loud "Only compiling specifications [skipping verification]"
-    pure mempty { o_result = F.Safe mempty }
-  | otherwise = do
-    whenNormal $ donePhase Loud "Extracted Core using GHC"
-    -- whenLoud  $ do putStrLn $ showpp info
-                 -- putStrLn "*************** Original CoreBinds ***************************"
-                 -- putStrLn $ render $ pprintCBs (cbs info)
-    whenNormal $ donePhase Loud "Transformed Core"
-    whenLoud  $ do donePhase Loud "transformRecExpr"
-                   putStrLn "*************** Transform Rec Expr CoreBinds *****************"
-                   putStrLn $ showCBs (untidyCore cfg) cbs'
-                   -- putStrLn $ render $ pprintCBs cbs'
-                   -- putStrLn $ showPpr cbs'
-    edcs <- newPrune cfg cbs' tgt info
-    liquidQueries cfg tgt info edcs
-  where 
-    cfg  = getConfig info
-    tgt  = giTarget (giSrc info)
-    cbs' = giCbs (giSrc info)
-
-newPrune :: Config -> [CoreBind] -> FilePath -> TargetInfo -> IO (Either [CoreBind] [DC.DiffCheck])
-newPrune cfg cbs tgt info
-  | not (null vs) = return . Right $ [DC.thin cbs sp vs]
-  | timeBinds cfg = return . Right $ [DC.thin cbs sp [v] | v <- expVars]
-  | diffcheck cfg = maybeEither cbs <$> DC.slice tgt cbs sp
-  | otherwise     = return $ Left (ignoreCoreBinds ignores cbs)
-  where
-    ignores       = gsIgnoreVars (gsVars sp)
-    vs            = gsTgtVars    (gsVars sp)
-    sp            = giSpec       info
-    expVars       = exportedVars (giSrc info)
-
-exportedVars :: TargetSrc -> [Var]
-exportedVars src = filter (isExportedVar src) (giDefVars src)
-
-maybeEither :: a -> Maybe b -> Either a [b]
-maybeEither d Nothing  = Left d
-maybeEither _ (Just x) = Right [x]
-
-liquidQueries :: Config -> FilePath -> TargetInfo -> Either [CoreBind] [DC.DiffCheck] -> IO (Output Doc)
-liquidQueries cfg tgt info (Left cbs')
-  = liquidQuery cfg tgt info (Left cbs')
-liquidQueries cfg tgt info (Right dcs)
-  = mconcat <$> mapM (liquidQuery cfg tgt info . Right) dcs
-
-liquidQuery   :: Config -> FilePath -> TargetInfo -> Either [CoreBind] DC.DiffCheck -> IO (Output Doc)
-liquidQuery cfg tgt info edc = do
-  let names   = either (const Nothing) (Just . map show . DC.checkedVars)   edc
-  let oldOut  = either (const mempty)  DC.oldOutput                         edc
-  let info1   = either (const info)    (\z -> info {giSpec = DC.newSpec z}) edc
-  let cbs''   = either id              DC.newBinds                          edc
-  let info2   = info1 { giSrc = (giSrc info1) {giCbs = cbs''}}
-  let info3   = updTargetInfoTermVars info2 
-  let cgi     = {-# SCC "generateConstraints" #-} generateConstraints $! info3 
-  when False (dumpCs cgi)
-  -- whenLoud $ mapM_ putStrLn [ "****************** CGInfo ********************"
-                            -- , render (pprint cgi)                            ]
-  out        <- timedAction names $ solveCs cfg tgt cgi info3 names
-  return      $ mconcat [oldOut, out]
-
-updTargetInfoTermVars    :: TargetInfo -> TargetInfo 
-updTargetInfoTermVars i  = updInfo i  (ST.terminationVars i) 
-  where 
-    updInfo   info vs = info { giSpec = updSpec   (giSpec info) vs }
-    updSpec   sp   vs = sp   { gsTerm = updSpTerm (gsTerm sp)   vs }
-    updSpTerm gsT  vs = gsT  { gsNonStTerm = S.fromList vs         } 
-      
-dumpCs :: CGInfo -> IO ()
-dumpCs cgi = do
-  putStrLn "***************************** SubCs *******************************"
-  putStrLn $ render $ pprintMany (hsCs cgi)
-  putStrLn "***************************** FixCs *******************************"
-  putStrLn $ render $ pprintMany (fixCs cgi)
-  putStrLn "***************************** WfCs ********************************"
-  putStrLn $ render $ pprintMany (hsWfs cgi)
-
-pprintMany :: (PPrint a) => [a] -> Doc
-pprintMany xs = vcat [ F.pprint x $+$ text " " | x <- xs ]
-
-solveCs :: Config -> FilePath -> CGInfo -> TargetInfo -> Maybe [String] -> IO (Output Doc)
-solveCs cfg tgt cgi info names = do
-  finfo            <- cgInfoFInfo info cgi
-  let fcfg          = fixConfig tgt cfg
-  F.Result r0 sol _ <- solve fcfg finfo
-  let failBs        = gsFail $ gsTerm $ giSpec info
-  let (r,rf)        = splitFails (S.map val failBs) r0 
-  let resErr        = applySolution sol . cinfoError . snd <$> r
-  -- resModel_        <- fmap (e2u cfg sol) <$> getModels info cfg resErr
-  let resModel_     = e2u cfg sol <$> resErr
-  let resModel'     = resModel_  `addErrors` (e2u cfg sol <$> logErrors cgi)
-                                 `addErrors` makeFailErrors (S.toList failBs) rf 
-                                 `addErrors` makeFailUseErrors (S.toList failBs) (giCbs $ giSrc info)
-  let lErrors       = applySolution sol <$> logErrors cgi
-  hErrors          <- if (typedHoles cfg) 
-                        then synthesize tgt fcfg (cgi{holesMap = applySolution sol <$> holesMap  cgi}) 
-                        else return [] 
-  let resModel      = resModel' `addErrors` (e2u cfg sol <$> (lErrors ++ hErrors)) 
-  let out0          = mkOutput cfg resModel sol (annotMap cgi)
-  return            $ out0 { o_vars    = names    }
-                           { o_result  = resModel }
-
-
-e2u :: Config -> F.FixSolution -> Error -> UserError
-e2u cfg s = fmap F.pprint . tidyError cfg s
-
--- writeCGI tgt cgi = {-# SCC "ConsWrite" #-} writeFile (extFileName Cgi tgt) str
---   where
---     str          = {-# SCC "PPcgi" #-} showpp cgi
-
-
-makeFailUseErrors :: [F.Located Var] -> [CoreBind] -> [UserError]
-makeFailUseErrors fbs cbs = [ mkError x bs | x <- fbs
-                                          , let bs = clients (val x)
-                                          , not (null bs) ]  
-  where 
-    mkError x bs = ErrFailUsed (GM.sourcePosSrcSpan $ loc x) (pprint $ val x) (pprint <$> bs)
-    clients x    = map fst $ filter (elem x . snd) allClients
-
-    allClients = concatMap go cbs 
-
-    go :: CoreBind -> [(Var,[Var])]
-    go (NonRec x e) = [(x, readVars e)] 
-    go (Rec xes)    = [(x,cls) | x <- map fst xes] where cls = concatMap readVars (snd <$> xes)
-
-makeFailErrors :: [F.Located Var] -> [Cinfo] -> [UserError]
-makeFailErrors bs cis = [ mkError x | x <- bs, notElem (val x) vs ]  
-  where 
-    mkError  x = ErrFail (GM.sourcePosSrcSpan $ loc x) (pprint $ val x)
-    vs         = [v | Just v <- (ci_var <$> cis) ]
-
-splitFails :: S.HashSet Var -> F.FixResult (a, Cinfo) -> (F.FixResult (a, Cinfo),  [Cinfo])
-splitFails _ r@(F.Crash _ _) = (r,mempty)
-splitFails _ r@(F.Safe _)    = (r,mempty)
-splitFails fs (F.Unsafe s xs)  = (mkRes r, snd <$> rfails)
-  where 
-    (rfails,r) = L.partition (Mb.maybe False (`S.member` fs) . ci_var . snd) xs 
-    mkRes [] = F.Safe s
-    mkRes ys = F.Unsafe s ys 
-
-  
diff --git a/src/Language/Haskell/Liquid/Measure.hs b/src/Language/Haskell/Liquid/Measure.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Measure.hs
+++ /dev/null
@@ -1,249 +0,0 @@
-{-# LANGUAGE FlexibleInstances      #-}
-{-# LANGUAGE FlexibleContexts       #-}
-{-# LANGUAGE UndecidableInstances   #-}
-{-# LANGUAGE OverloadedStrings      #-}
-{-# LANGUAGE ConstraintKinds        #-}
-{-# LANGUAGE DeriveGeneric          #-}
-
-module Language.Haskell.Liquid.Measure (
-  -- * Specifications
-    Spec (..)
-  , MSpec (..)
-
-  -- * Type Aliases
-  , BareSpec
-  , BareMeasure
-  , SpecMeasure
-
-  -- * Constructors
-  , mkM, mkMSpec, mkMSpec'
-  , dataConTypes
-  , defRefType
-  , bodyPred
-  ) where
-
-import           DataCon
-import           GHC                                    hiding (Located)
-import           Outputable                             (Outputable)
-import           Prelude                                hiding (error)
-import           Text.PrettyPrint.HughesPJ              hiding ((<>)) 
--- import           Data.Binary                            as B
--- import           GHC.Generics
-import qualified Data.HashMap.Strict                    as M
-import qualified Data.List                              as L
-import qualified Data.Maybe                             as Mb -- (fromMaybe, isNothing)
-
-import           Language.Fixpoint.Misc
-import           Language.Fixpoint.Types                hiding (panic, R, DataDecl, SrcSpan, LocSymbol)
-import           Language.Haskell.Liquid.GHC.API        as Ghc hiding (Expr)
-import           Language.Haskell.Liquid.GHC.Misc
--- import qualified Language.Haskell.Liquid.Misc as Misc
-import           Language.Haskell.Liquid.Types.Types    -- hiding (GhcInfo(..), GhcSpec (..))
-import           Language.Haskell.Liquid.Types.RefType
--- import           Language.Haskell.Liquid.Types.Variance
--- import           Language.Haskell.Liquid.Types.Bounds
-import           Language.Haskell.Liquid.Types.Specs hiding (BareSpec)
-import           Language.Haskell.Liquid.UX.Tidy
-
--- /FIXME/: This needs to be removed once the port to the new API is complete.
-type BareSpec = Spec LocBareType LocSymbol
-
-mkM ::  LocSymbol -> ty -> [Def ty bndr] -> MeasureKind -> UnSortedExprs -> Measure ty bndr
-mkM name typ eqns kind u
-  | all ((name ==) . measure) eqns
-  = M name typ eqns kind u
-  | otherwise
-  = panic Nothing $ "invalid measure definition for " ++ show name
-
-mkMSpec' :: Symbolic ctor => [Measure ty ctor] -> MSpec ty ctor
-mkMSpec' ms = MSpec cm mm M.empty []
-  where
-    cm     = groupMap (symbol . ctor) $ concatMap msEqns ms
-    mm     = M.fromList [(msName m, m) | m <- ms ]
-
-mkMSpec :: [Measure t LocSymbol] -> [Measure t ()] -> [Measure t LocSymbol] -> MSpec t LocSymbol
-mkMSpec ms cms ims = MSpec cm mm cmm ims
-  where
-    cm     = groupMap (val . ctor) $ concatMap msEqns (ms'++ims)
-    mm     = M.fromList [(msName m, m) | m <- ms' ]
-    cmm    = M.fromList [(msName m, m) | m <- cms ]
-    ms'    = checkDuplicateMeasure ms
-
-
-checkDuplicateMeasure :: [Measure ty ctor] -> [Measure ty ctor]
-checkDuplicateMeasure ms
-  = case M.toList dups of
-      []         -> ms
-      (m,ms):_   -> uError $ err m (msName <$> ms)
-    where
-      gms        = group [(msName m , m) | m <- ms]
-      dups       = M.filter ((1 <) . length) gms
-      err m ms   = ErrDupMeas (fSrcSpan m) (pprint (val m)) (fSrcSpan <$> ms)
-
-
-dataConTypes :: MSpec (RRType Reft) DataCon -> ([(Var, RRType Reft)], [(LocSymbol, RRType Reft)])
-dataConTypes  s = (ctorTys, measTys)
-  where
-    measTys     = [(msName m, msSort m) | m <- M.elems (measMap s) ++ imeas s]
-    ctorTys     = concatMap makeDataConType (notracepp "HOHOH" . snd <$> M.toList (ctorMap s))
-
-makeDataConType :: [Def (RRType Reft) DataCon] -> [(Var, RRType Reft)]
-makeDataConType []
-  = []
-makeDataConType ds | Mb.isNothing (dataConWrapId_maybe dc)
-  = notracepp _msg [(woId, notracepp _msg $ combineDCTypes "cdc0" t ts)]
-  where
-    dc   = ctor (head ds)
-    woId = dataConWorkId dc
-    t    = varType woId
-    ts   = defRefType t <$> ds
-    _msg  = "makeDataConType0" ++ showpp (woId, t, ts)
-
-makeDataConType ds
-  = [(woId, extend loci woRType wrRType), (wrId, extend loci wrRType woRType)]
-  where
-    (wo, wr) = L.partition isWorkerDef ds
-    dc       = ctor $ head ds
-    loci     = loc $ measure $ head ds
-    woId     = dataConWorkId dc
-    wot      = varType woId
-    wrId     = dataConWrapId dc
-    wrt      = varType wrId
-    wots     = defRefType wot <$> wo
-    wrts     = defRefType wrt <$> wr
-
-    wrRType  = combineDCTypes "cdc1" wrt wrts
-    woRType  = combineDCTypes "cdc2" wot wots
-
-
-    isWorkerDef def
-      -- types are missing for arguments, so definition came from a logical measure
-      -- and it is for the worker datacon
-      | any Mb.isNothing (snd <$> binds def)
-      = True
-      | otherwise
-      = length (binds def) == length (fst $ splitFunTys $ snd $ splitForAllTys wot)
-
-
-extend :: SourcePos
-       -> RType RTyCon RTyVar Reft
-       -> RRType Reft
-       -> RType RTyCon RTyVar Reft
-extend lc t1' t2
-  | Just su <- mapArgumens lc t1 t2
-  = t1 `strengthenResult` subst su (Mb.fromMaybe mempty (stripRTypeBase $ resultTy t2))
-  | otherwise
-  = t1
-  where
-    t1 = noDummySyms t1'
-
-
-resultTy :: RType c tv r -> RType c tv r
-resultTy = ty_res . toRTypeRep
-
-strengthenResult :: Reftable r => RType c tv r -> r -> RType c tv r
-strengthenResult t r = fromRTypeRep $ rep {ty_res = ty_res rep `strengthen` r}
-  where
-    rep              = toRTypeRep t
-
-
-noDummySyms :: (OkRT c tv r) => RType c tv r -> RType c tv r
-noDummySyms t
-  | any isDummy (ty_binds rep)
-  = subst su $ fromRTypeRep $ rep{ty_binds = xs'}
-  | otherwise
-  = t
-  where
-    rep = toRTypeRep t
-    xs' = zipWith (\_ i -> symbol ("x" ++ show i)) (ty_binds rep) [1..]
-    su  = mkSubst $ zip (ty_binds rep) (EVar <$> xs')
-
-combineDCTypes :: String -> Type -> [RRType Reft] -> RRType Reft
-combineDCTypes _msg t ts = L.foldl' strengthenRefTypeGen (ofType t) ts
-
-mapArgumens :: SourcePos -> RRType Reft -> RRType Reft -> Maybe Subst
-mapArgumens lc t1 t2 = go xts1' xts2'
-  where
-    xts1 = zip (ty_binds rep1) (ty_args rep1)
-    xts2 = zip (ty_binds rep2) (ty_args rep2)
-    rep1 = toRTypeRep t1
-    rep2 = toRTypeRep t2
-
-    xts1' = dropWhile canDrop xts1
-    xts2' = dropWhile canDrop xts2
-
-    canDrop (_, t) = isClassType t || isEqType t
-
-    go xs ys
-      | length xs == length ys && and (zipWith (==) (toRSort . snd <$> xts1') (toRSort . snd <$> xts2'))
-      = Just $ mkSubst $ zipWith (\y x -> (fst x, EVar $ fst y)) xts1' xts2'
-      | otherwise
-      = panic (Just $ sourcePosSrcSpan lc) ("The types for the wrapper and worker data constructors cannot be merged\n"
-          ++ show t1 ++ "\n" ++ show t2 )
-
--- should constructors have implicits? probably not
-defRefType :: Type -> Def (RRType Reft) DataCon -> RRType Reft
-defRefType tdc (Def f dc mt xs body)
-                    = generalize $ mkArrow as' [] [] xts t'
-  where
-    xts             = stitchArgs (fSrcSpan f) dc xs ts 
-    t'              = refineWithCtorBody dc f body t
-    t               = Mb.fromMaybe (ofType tr) mt
-    (αs, ts, tr)    = splitType tdc
-    as              = if Mb.isJust mt then [] else makeRTVar . rTyVar <$> αs
-    as'             = zip as (repeat mempty)
-
-splitType :: Type -> ([TyVar],[Type], Type)
-splitType t  = (αs, ts, tr)
-  where
-    (αs, tb) = splitForAllTys t
-    (ts, tr) = splitFunTys tb
-
-stitchArgs :: (Monoid t1, PPrint a)
-           => SrcSpan
-           -> a
-           -> [(Symbol, Maybe (RRType Reft))]
-           -> [Type]
-           -> [(Symbol, RRType Reft, t1)]
-stitchArgs sp dc allXs allTs
-  | nXs == nTs         = (g (dummySymbol, Nothing) . ofType <$> pts)
-                      ++ zipWith g xs (ofType <$> ts)
-  | otherwise          = panicFieldNumMismatch sp dc nXs nTs
-    where
-      (pts, ts)        = L.partition (\t -> notracepp ("isPredTy: " ++ showpp t) $ Ghc.isEvVarType t) allTs
-      (_  , xs)        = L.partition (coArg . snd) allXs
-      nXs              = length xs
-      nTs              = length ts
-      g (x, Just t) _  = (x, t, mempty)
-      g (x, _)      t  = (x, t, mempty)
-      coArg Nothing    = False
-      coArg (Just t)   = Ghc.isEvVarType . toType $ t
-
-panicFieldNumMismatch :: (PPrint a, PPrint a1, PPrint a3)
-                      => SrcSpan -> a3 -> a1 -> a -> a2
-panicFieldNumMismatch sp dc nXs nTs  = panicDataCon sp dc msg
-  where
-    msg = "Requires" <+> pprint nTs <+> "fields but given" <+> pprint nXs
-
-panicDataCon :: PPrint a1 => SrcSpan -> a1 -> Doc -> a
-panicDataCon sp dc d
-  = panicError $ ErrDataCon sp (pprint dc) d
-
-refineWithCtorBody :: Outputable a
-                   => a
-                   -> LocSymbol
-                   -> Body
-                   -> RType c tv Reft
-                   -> RType c tv Reft
-refineWithCtorBody dc f body t =
-  case stripRTypeBase t of
-    Just (Reft (v, _)) ->
-      strengthen t $ Reft (v, bodyPred (mkEApp f [eVar v]) body)
-    Nothing ->
-      panic Nothing $ "measure mismatch " ++ showpp f ++ " on con " ++ showPpr dc
-
-
-bodyPred ::  Expr -> Body -> Expr
-bodyPred fv (E e)    = PAtom Eq fv e
-bodyPred fv (P p)    = PIff  fv p
-bodyPred fv (R v' p) = subst1 p (v', fv)
diff --git a/src/Language/Haskell/Liquid/Misc.hs b/src/Language/Haskell/Liquid/Misc.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Misc.hs
+++ /dev/null
@@ -1,390 +0,0 @@
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE DoAndIfThenElse #-}
-
-module Language.Haskell.Liquid.Misc where
-
-import Prelude hiding (error)
-import Control.Monad.State
-
-import Control.Arrow (first)
-import System.FilePath
-import System.Directory   (getModificationTime, doesFileExist)
-import System.Environment (getExecutablePath)
-
-import qualified Control.Exception     as Ex --(evaluate, catch, IOException)
-import qualified Data.HashSet          as S
-import qualified Data.HashMap.Strict   as M
-import qualified Data.List             as L
-import           Data.Maybe
-import           Data.Tuple
-import           Data.Hashable
-import           Data.Time
-import           Data.Function (on)
-import qualified Data.ByteString       as B
-import           Data.ByteString.Char8 (pack, unpack)
-import qualified Text.PrettyPrint.HughesPJ as PJ -- (char, Doc)
-import           Text.Printf
-import           Language.Fixpoint.Misc
-import           Paths_liquidhaskell
-
-type Nat = Int
-
-(.&&.), (.||.) :: (a -> Bool) -> (a -> Bool) -> a -> Bool
-(.&&.) = up (&&)
-(.||.) = up (||)
-
-up :: (b -> c -> d) -> (a -> b) -> (a -> c) -> (a -> d)
-up o f g x = f x `o` g x
-
-timedAction :: (Show msg) => Maybe msg -> IO a -> IO a
-timedAction label io = do
-  t0 <- getCurrentTime
-  a <- io
-  t1 <- getCurrentTime
-  let time = realToFrac (t1 `diffUTCTime` t0) :: Double
-  case label of
-    Just x  -> printf "Time (%.2fs) for action %s \n" time (show x)
-    Nothing -> return ()
-  return a
-
-(!?) :: [a] -> Int -> Maybe a
-[]     !? _ = Nothing
-(x:_)  !? 0 = Just x
-(_:xs) !? n = xs !? (n-1)
-
-safeFromJust :: String -> Maybe t -> t
-safeFromJust _  (Just x) = x
-safeFromJust err _       = errorstar err
-
-safeFromLeft :: String -> Either a b -> a 
-safeFromLeft _   (Left l) = l 
-safeFromLeft err _        = errorstar err 
-
-
-takeLast :: Int -> [a] -> [a]
-takeLast n xs = drop (m - n) xs
-  where
-    m         = length xs
-
-getNth :: Int -> [a] -> Maybe a
-getNth 0 (x:_)  = Just x
-getNth n (_:xs) = getNth (n-1) xs
-getNth _ _      = Nothing
-
-fst4 :: (t, t1, t2, t3) -> t
-fst4 (a,_,_,_) = a
-
-snd4 :: (t, t1, t2, t3) -> t1
-snd4 (_,b,_,_) = b
-
-thrd3 :: (t1, t2, t3) -> t3
-thrd3 (_,_,c) = c
-
-
-mapFourth4 :: (t -> t4) -> (t1, t2, t3, t) -> (t1, t2, t3, t4)
-mapFourth4 f (x, y, z, w) = (x, y, z, f w)
-
-addFst3 :: t -> (t1, t2) -> (t, t1, t2)
-addFst3   a (b, c) = (a, b, c)
-
-addThd3 :: t2 -> (t, t1) -> (t, t1, t2)
-addThd3   c (a, b) = (a, b, c)
-
-dropFst3 :: (t, t1, t2) -> (t1, t2)
-dropFst3 (_, x, y) = (x, y)
-
-dropThd3 :: (t1, t2, t) -> (t1, t2)
-dropThd3 (x, y, _) = (x, y)
-
-replaceN :: (Enum a, Eq a, Num a) => a -> t -> [t] -> [t]
-replaceN n y ls = [if i == n then y else x | (x, i) <- zip ls [0..]]
-
-fourth4 :: (t, t1, t2, t3) -> t3
-fourth4 (_,_,_,x) = x
-
-third4 :: (t, t1, t2, t3) -> t2
-third4  (_,_,x,_) = x
-
-mapSndM :: (Applicative m) => (b -> m c) -> (a, b) -> m (a, c)
--- mapSndM f (x, y) = return . (x,) =<< f y
-mapSndM f (x, y) = (x, ) <$> f y
-
-firstM :: Functor f => (t -> f a) -> (t, t1) -> f (a, t1)
-firstM  f (a,b) = (,b) <$> f a
-
-secondM :: Functor f => (t -> f a) -> (t1, t) -> f (t1, a)
-secondM f (a,b) = (a,) <$> f b
-
-first3M :: Functor f => (t -> f a) -> (t, t1, t2) -> f (a, t1, t2)
-first3M  f (a,b,c) = (,b,c) <$> f a
-
-second3M :: Functor f => (t -> f a) -> (t1, t, t2) -> f (t1, a, t2)
-second3M f (a,b,c) = (a,,c) <$> f b
-
-third3M :: Functor f => (t -> f a) -> (t1, t2, t) -> f (t1, t2, a)
-third3M  f (a,b,c) = (a,b,) <$> f c
-
-third3 :: (t -> t3) -> (t1, t2, t) -> (t1, t2, t3)
-third3 f (a,b,c) = (a,b,f c)
-
-zip4 :: [t] -> [t1] -> [t2] -> [t3] -> [(t, t1, t2, t3)]
-zip4 (x1:xs1) (x2:xs2) (x3:xs3) (x4:xs4) = (x1, x2, x3, x4) : zip4 xs1 xs2 xs3 xs4
-zip4 _ _ _ _                             = []
-
-isIncludeFile :: FilePath -> FilePath -> Bool 
-isIncludeFile incDir src = -- do 
-  -- incDir <- getIncludeDir 
-  -- return 
-  (incDir `L.isPrefixOf` src)
-
-getIncludeDir :: IO FilePath
-getIncludeDir      = dropFileName <$> getDataFileName ("include" </> "Prelude.spec")
-
-getCssPath :: IO FilePath
-getCssPath         = getDataFileName $ "syntax" </> "liquid.css"
-
-getCoreToLogicPath :: IO FilePath
-getCoreToLogicPath = do
-    let fileName = "CoreToLogic.lg"
-
-    -- Try to find it first at executable path
-    exePath <- dropFileName <$> getExecutablePath
-    let atExe = exePath </> fileName
-    exists <- doesFileExist atExe
-    
-    if exists then 
-      return atExe
-    else 
-      fmap (</> fileName) getIncludeDir
-
-
-{-@ type ListN a N = {v:[a] | len v = N} @-}
-{-@ type ListL a L = ListN a (len L) @-}
-
-zipMaybe :: [a] -> [b] -> Maybe [(a, b)]
-zipMaybe xs ys
-  | length xs == length ys = Just (zip xs ys)
-  | otherwise              = Nothing
-
-{-@ safeZipWithError :: _ -> xs:[a] -> ListL b xs -> ListL (a,b) xs / [xs] @-}
-safeZipWithError :: String -> [t] -> [t1] -> [(t, t1)]
-safeZipWithError msg (x:xs) (y:ys) = (x,y) : safeZipWithError msg xs ys
-safeZipWithError _   []     []     = []
-safeZipWithError msg _      _      = errorstar msg
-
-safeZip3WithError :: String -> [t] -> [t1] -> [t2] -> [(t, t1, t2)]
-safeZip3WithError msg (x:xs) (y:ys) (z:zs) = (x,y,z) : safeZip3WithError msg xs ys zs
-safeZip3WithError _   []     []     []     = []
-safeZip3WithError msg _      _      _      = errorstar msg
-
-mapNs :: (Eq a, Num a, Foldable t) => t a -> (a1 -> a1) -> [a1] -> [a1]
-mapNs ns f xs = foldl (\xs n -> mapN n f xs) xs ns
-
-mapN :: (Eq a, Num a) => a -> (a1 -> a1) -> [a1] -> [a1]
-mapN 0 f (x:xs) = f x : xs
-mapN n f (x:xs) = x : mapN (n-1) f xs
-mapN _ _ []     = []
-
-zipWithDefM :: Monad m => (a -> a -> m a) -> [a] -> [a] -> m [a]
-zipWithDefM _ []     []     = return []
-zipWithDefM _ xs     []     = return xs
-zipWithDefM _ []     ys     = return ys
-zipWithDefM f (x:xs) (y:ys) = (:) <$> f x y <*> zipWithDefM f xs ys
-
-zipWithDef :: (a -> a -> a) -> [a] -> [a] -> [a]
-zipWithDef _ []     []     = []
-zipWithDef _ xs     []     = xs
-zipWithDef _ []     ys     = ys
-zipWithDef f (x:xs) (y:ys) = f x y : zipWithDef f xs ys
-
-
---------------------------------------------------------------------------------
--- Originally part of Fixpoint's Misc:
---------------------------------------------------------------------------------
-
-single :: t -> [t]
-single x = [x]
-
-mapFst3 :: (t -> t1) -> (t, t2, t3) -> (t1, t2, t3)
-mapFst3 f (x, y, z) = (f x, y, z)
-
-mapSnd3 :: (t -> t2) -> (t1, t, t3) -> (t1, t2, t3)
-mapSnd3 f (x, y, z) = (x, f y, z)
-
-mapThd3 :: (t -> t3) -> (t1, t2, t) -> (t1, t2, t3)
-mapThd3 f (x, y, z) = (x, y, f z)
-
-firstMaybes :: [Maybe a] -> Maybe a
-firstMaybes = listToMaybe . catMaybes
-
-fromFirstMaybes :: a -> [Maybe a] -> a
-fromFirstMaybes x = fromMaybe x . firstMaybes 
--- fromFirstMaybes x = fromMaybe x . listToMaybe . catMaybes
-
-hashMapMapWithKey   :: (k -> v1 -> v2) -> M.HashMap k v1 -> M.HashMap k v2
-hashMapMapWithKey f = fromJust . M.traverseWithKey (\k v -> Just (f k v))
-
-hashMapMapKeys   :: (Eq k2, Hashable k2) => (k1 -> k2) -> M.HashMap k1 v -> M.HashMap k2 v
-hashMapMapKeys f = M.fromList . fmap (first f) . M.toList
-
-concatMapM :: (Monad m, Traversable t) => (a -> m [b]) -> t a -> m [b]
-concatMapM f = fmap concat . mapM f
-
-replaceSubset :: (Eq k, Hashable k) => [(k, a)] -> [(k, a)] -> [(k, a)]
-replaceSubset kvs kvs' = M.toList (L.foldl' upd m0 kvs')
-  where 
-    m0                = M.fromList kvs 
-    upd m (k, v') 
-      | M.member k m  = M.insert k v' m 
-      | otherwise     = m 
-
-replaceWith :: (Eq a, Hashable a) => (b -> a) -> [b] -> [b] -> [b]
-replaceWith f xs ys = snd <$> replaceSubset xs' ys' 
-  where 
-    xs'             = [ (f x, x) | x <- xs ] 
-    ys'             = [ (f y, y) | y <- ys ] 
-
-
-
-
-firstElems ::  [(B.ByteString, B.ByteString)] -> B.ByteString -> Maybe (Int, B.ByteString, (B.ByteString, B.ByteString))
-firstElems seps str
-  = case splitters seps str of
-      [] -> Nothing
-      is -> Just $ L.minimumBy (compare `on` fst3) is
-
-splitters :: [(B.ByteString, t)]
-          -> B.ByteString -> [(Int, t, (B.ByteString, B.ByteString))]
-splitters seps str
-  = [(i, c', z) | (c, c') <- seps
-                , let z   = B.breakSubstring c str
-                , let i   = B.length (fst z)
-                , i < B.length str                 ]
-
-bchopAlts :: [(B.ByteString, B.ByteString)] -> B.ByteString -> [B.ByteString]
-bchopAlts seps  = go
-  where
-    go  s               = maybe [s] go' (firstElems seps s)
-    go' (_,c',(s0, s1)) = if B.length s2 == B.length s1 then [B.concat [s0,s1]] else s0 : s2' : go s3'
-                          where (s2, s3) = B.breakSubstring c' s1
-                                s2'      = B.append s2 c'
-                                s3'      = B.drop (B.length c') s3
-
-chopAlts :: [(String, String)] -> String -> [String]
-chopAlts seps str = unpack <$> bchopAlts [(pack c, pack c') | (c, c') <- seps] (pack str)
-
-sortDiff :: (Ord a) => [a] -> [a] -> [a]
-sortDiff x1s x2s             = go (sortNub x1s) (sortNub x2s)
-  where
-    go xs@(x:xs') ys@(y:ys')
-      | x <  y               = x : go xs' ys
-      | x == y               = go xs' ys'
-      | otherwise            = go xs ys'
-    go xs []                 = xs
-    go [] _                  = []
-
-(<->) :: PJ.Doc -> PJ.Doc -> PJ.Doc
-x <-> y = x PJ.<> y
-
-angleBrackets :: PJ.Doc -> PJ.Doc
-angleBrackets p = PJ.char '<' <-> p <-> PJ.char '>'
-
-mkGraph :: (Eq a, Eq b, Hashable a, Hashable b) => [(a, b)] -> M.HashMap a (S.HashSet b)
-mkGraph = fmap S.fromList . group
-
-tryIgnore :: String -> IO () -> IO ()
-tryIgnore s a = 
-  Ex.catch a $ \e -> do
-    let err = show (e :: Ex.IOException)
-    writeLoud ("Warning: Couldn't do " ++ s ++ ": " ++ err)
-    return ()
-
-
-condNull :: Monoid m => Bool -> m -> m
-condNull c xs = if c then xs else mempty
-
-firstJust :: (a -> Maybe b) -> [a] -> Maybe b
-firstJust f xs = listToMaybe $ mapMaybe f xs
-
-intToString :: Int -> String
-intToString 1 = "1st"
-intToString 2 = "2nd"
-intToString 3 = "3rd"
-intToString n = show n ++ "th"
-
-mapAccumM :: (Monad m, Traversable t) => (a -> b -> m (a, c)) -> a -> t b -> m (a, t c)
-mapAccumM f acc0 xs =
-  swap <$> runStateT (traverse (StateT . (\x acc -> swap <$> f acc x)) xs) acc0
-
-ifM :: (Monad m) => m Bool -> m b -> m b -> m b
-ifM b x y = b >>= \z -> if z then x else y
-
-nubHashOn :: (Eq k, Hashable k) => (a -> k) -> [a] -> [a]
-nubHashOn f = map head . M.elems . groupMap f
-
-nubHashLast :: (Eq k, Hashable k) => (a -> k) -> [a] -> [a]
-nubHashLast f xs = M.elems $ M.fromList [ (f x, x) | x <- xs ]
-
-nubHashLastM :: (Eq k, Hashable k, Monad m) => (a -> m k) -> [a] -> m [a]
-nubHashLastM f xs =  M.elems . M.fromList . (`zip` xs) <$> mapM f xs
-
-uniqueByKey :: (Eq k, Hashable k) => [(k, v)] -> Either (k, [v]) [v]
-uniqueByKey = uniqueByKey' tx
-  where
-    tx (_, [v]) = Right v
-    tx (k, vs)  = Left  (k, vs)
-
-uniqueByKey' :: (Eq k, Hashable k) => ((k, [v]) -> Either e v) -> [(k, v)] -> Either e [v]
-uniqueByKey' tx = sequence . map tx . groupList
-
-
-join :: (Eq b, Hashable b) => [(a, b)] -> [(b, c)] -> [(a, c)]
-join aBs bCs = [ (a, c) | (a, b) <- aBs, c <- b2cs b ]
-  where
-    bM       = M.fromList bCs
-    b2cs b   = maybeToList (M.lookup b bM)
-
-
-fstByRank :: (Ord r, Hashable k, Eq k) => [(r, k, v)] -> [(r, k, v)]
-fstByRank rkvs = [ (r, k, v) | (k, rvs) <- krvss, let (r, v) = getFst rvs ]
-  where
-    getFst     = head . sortOn fst
-    krvss      = groupList [ (k, (r, v)) | (r, k, v) <- rkvs ]
-
-sortOn :: (Ord b) => (a -> b) -> [a] -> [a]
-sortOn f = L.sortBy (compare `on` f)
-
-firstGroup :: (Eq k, Ord k, Hashable k) => [(k, a)] -> [a] 
-firstGroup kvs = case groupList kvs of 
-  []   -> [] 
-  kvss -> snd . head . sortOn fst $ kvss 
-
-{- mapEither :: (a -> Either b c) -> [a] -> ([b], [c])
-mapEither f []     = ([], [])
-mapEither f (x:xs) = case f x of 
-                       Left y  -> (y:ys, zs)
-                       Right z -> (ys, z:zs)
-                     where 
-                       (ys, zs) = mapEither f xs 
--}
-
-keyDiff :: (Eq k, Hashable k) => (a -> k) -> [a] -> [a] -> [a]
-keyDiff f x1s x2s = M.elems (M.difference (m x1s) (m x2s))
-  where 
-    m xs          = M.fromList [(f x, x) | x <- xs] 
-
-concatUnzip :: [([a], [b])] -> ([a], [b])
-concatUnzip xsyss = (concatMap fst xsyss, concatMap snd xsyss)
-
-
-sayReadFile :: FilePath -> IO String 
-sayReadFile f = do 
-  -- print ("SAY-READ-FILE: " ++ f)
-  res <- readFile f 
-  Ex.evaluate res
-
-lastModified :: FilePath -> IO (Maybe UTCTime) 
-lastModified f = do 
-  ex  <- doesFileExist f
-  if ex then Just <$> getModificationTime f
-        else return   Nothing
diff --git a/src/Language/Haskell/Liquid/Parse.hs b/src/Language/Haskell/Liquid/Parse.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Parse.hs
+++ /dev/null
@@ -1,1667 +0,0 @@
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE FlexibleContexts          #-}
-{-# LANGUAGE UndecidableInstances      #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE OverloadedStrings         #-}
-{-# LANGUAGE DeriveDataTypeable        #-}
-
-module Language.Haskell.Liquid.Parse
-  ( hsSpecificationP
-  , specSpecificationP
-  , singleSpecP
-  , BPspec
-  , Pspec(..)
-  , parseSymbolToLogic
-  )
-  where
-
-import           Control.Arrow                          (second)
-import           Control.Monad
-import           Data.String
-import           Prelude                                hiding (error)
-import           Text.Parsec
-import           Text.Parsec.Error                      (newErrorMessage, Message (..))
-import           Text.Parsec.Pos
-
--- import           Text.Parsec.Char                       (newline) 
-import qualified Text.Parsec.Token                      as Token
-import qualified Data.Text                              as T
-import qualified Data.HashMap.Strict                    as M
-import qualified Data.HashSet                           as S
--- import           Data.Monoid
-import           Data.Data
-import qualified Data.Maybe                             as Mb -- (isNothing, fromMaybe)
-import           Data.Char                              (isSpace, isAlpha, isUpper, isAlphaNum, isDigit)
-import           Data.List                              (foldl', partition)
-import           GHC                                    (ModuleName, mkModuleName)
-import qualified Text.PrettyPrint.HughesPJ              as PJ 
-import           Text.PrettyPrint.HughesPJ.Compat       ((<+>)) 
-import           Language.Fixpoint.Types                hiding (panic, SVar, DDecl, DataDecl, DataCtor (..), Error, R, Predicate)
-import           Language.Haskell.Liquid.GHC.Misc
-import           Language.Haskell.Liquid.Types          
-import qualified Language.Fixpoint.Misc                 as Misc      
-import qualified Language.Haskell.Liquid.Misc           as Misc
-import qualified Language.Haskell.Liquid.Measure        as Measure
-import           Language.Fixpoint.Parse                hiding (stringLiteral, dataDeclP, angles, refBindP, refP, refDefP)
-
-import Control.Monad.State
-
--- import Debug.Trace
-
---------------------------------------------------------------------------------
--- | Top Level Parsing API -----------------------------------------------------
---------------------------------------------------------------------------------
-
--- | Used to parse .hs and .lhs files (via ApiAnnotations)
-
--------------------------------------------------------------------------------
-hsSpecificationP :: ModuleName
-                 -> [(SourcePos, String)]
-                 -> [BPspec]
-                 -> Either [Error] (ModName, Measure.BareSpec)
--------------------------------------------------------------------------------
-hsSpecificationP modName specComments specQuotes =
-  case go ([], []) initPStateWithList $ reverse specComments of
-    ([], specs) ->
-      Right $ mkSpec (ModName SrcImport modName) (specs ++ specQuotes)
-    (errs, _) ->
-      Left errs
-  where
-    go :: ([Error], [BPspec])   -- accumulated errors and parsed specs (in reverse order)
-       -> PState                -- parser state (primarily infix operator priorities)
-       -> [(SourcePos, String)] -- remaining unparsed spec comments
-       -> ([Error], [BPspec])   -- final errors and parsed specs
-    go (errs, specs) _ []
-      = (reverse errs, reverse specs)
-    go (errs, specs) pstate ((pos, specComment):xs)
-      = -- 'specP' parses a single spec comment, i.e., a single LH directive
-        case parseWithError pstate specP pos specComment of
-          Left err        -> go (err:errs, specs) pstate xs
-          Right (st,spec) -> go (errs,spec:specs) st xs
-
--- | Used to parse .spec files
-
-initPStateWithList :: PState
-initPStateWithList 
-  = (initPState composeFun)
-               { empList    = Just (EVar ("GHC.Types.[]" :: Symbol))
-               , singList   = Just (\e -> EApp (EApp (EVar ("GHC.Types.:"  :: Symbol)) e) (EVar ("GHC.Types.[]" :: Symbol)))
-               }
-  where composeFun = Just $ EVar functionComposisionSymbol
-
---------------------------------------------------------------------------
-specSpecificationP  :: SourceName -> String -> Either Error (ModName, Measure.BareSpec)
---------------------------------------------------------------------------
-specSpecificationP f s = mapRight snd $  parseWithError initPStateWithList specificationP (newPos f 1 1) s
-
-specificationP :: Parser (ModName, Measure.BareSpec)
-specificationP = do 
-  reserved "module"
-  reserved "spec"
-  name   <- symbolP
-  reserved "where"
-  xs     <- if True then grabs (specP <* whiteSpace) else sepBy specP newline
-  return $ mkSpec (ModName SpecImport $ mkModuleName $ symbolString name) xs
-
--- debugP = grabs (specP <* whiteSpace)
-
--------------------------------------------------------------------------------
-singleSpecP :: SourcePos -> String -> Either Error BPspec
--------------------------------------------------------------------------------
-singleSpecP pos = mapRight snd . parseWithError initPStateWithList specP pos
-
-mapRight :: (a -> b) -> Either l a -> Either l b
-mapRight f (Right x) = Right $ f x
-mapRight _ (Left x)  = Left x
-
----------------------------------------------------------------------------
-parseWithError :: PState -> Parser a -> SourcePos -> String -> Either Error (PState, a)
----------------------------------------------------------------------------
-parseWithError pstate parser p s =
-  case runState (runParserT doParse 0 (sourceName p) s) pstate of
-    (Left e, _)            -> Left  $ parseErrorError e
-    (Right (r, "", _), st) -> Right (st, r)
-    (Right (_, rem, _), _) -> Left  $ parseErrorError $ remParseError p s rem
-  where
-    -- See http://stackoverflow.com/questions/16209278/parsec-consume-all-input
-    doParse = setPosition p >> remainderP (whiteSpace *> parser <* (whiteSpace >> eof))
-
-
----------------------------------------------------------------------------
-parseErrorError     :: ParseError -> Error
----------------------------------------------------------------------------
-parseErrorError e = ErrParse sp msg e
-  where
-    pos             = errorPos e
-    sp              = sourcePosSrcSpan pos
-    msg             = "Error Parsing Specification from:" <+> PJ.text (sourceName pos)
-
----------------------------------------------------------------------------
-remParseError       :: SourcePos -> String -> String -> ParseError
----------------------------------------------------------------------------
-remParseError p s r = newErrorMessage msg $ newPos (sourceName p) line col
-  where
-    msg             = Message "Leftover while parsing"
-    (line, col)     = remLineCol p s r
-
-remLineCol             :: SourcePos -> String -> String -> (Int, Int)
-remLineCol pos src rem = (line + offLine, col + offCol)
-  where
-    line               = 1 + srcLine - remLine
-    srcLine            = length srcLines
-    remLine            = length remLines
-    offLine            = sourceLine pos - 1
-    col                = 1 + srcCol - remCol
-    srcCol             = length $ srcLines !! (line - 1)
-    remCol             = length $ head remLines
-    offCol             = if line == 1 then sourceColumn pos - 1 else 0
-    srcLines           = lines  src
-    remLines           = lines  rem
-
-
-
---------------------------------------------------------------------------------
--- Parse to Logic  -------------------------------------------------------------
---------------------------------------------------------------------------------
-
-parseSymbolToLogic :: SourceName -> String -> Either Error LogicMap
-parseSymbolToLogic f = mapRight snd . parseWithError initPStateWithList toLogicP (newPos f 1 1)
-
-toLogicP :: Parser LogicMap
-toLogicP
-  = toLogicMap <$> many toLogicOneP
-
-toLogicOneP :: Parser  (LocSymbol, [Symbol], Expr)
-toLogicOneP
-  = do reserved "define"
-       (x:xs) <- many1 (locParserP symbolP)
-       reservedOp "="
-       e      <- exprP
-       return (x, val <$> xs, e)
-
-
-defineP :: Parser (LocSymbol, Symbol)
-defineP = do v <- locParserP binderP
-             spaces
-             reservedOp "="
-             spaces
-             x <- binderP
-             return (v, x)
-
---------------------------------------------------------------------------------
--- Lexer Tokens ----------------------------------------------------------------
---------------------------------------------------------------------------------
-
-dot :: Parser String
-dot = Token.dot lexer
-
-angles :: Parser a -> Parser a
-angles = Token.angles lexer
-
-stringLiteral :: Parser String
-stringLiteral = Token.stringLiteral lexer
-
---------------------------------------------------------------------------------
--- | BareTypes -----------------------------------------------------------------
---------------------------------------------------------------------------------
-
-{- | [NOTE:BARETYPE-PARSE] Fundamentally, a type is of the form
-
-      comp -> comp -> ... -> comp
-
-So
-
-  bt = comp
-     | comp '->' bt
-
-  comp = circle
-       | '(' bt ')'
-
-  circle = the ground component of a baretype, sans parens or "->" at the top level
-
-Each 'comp' should have a variable to refer to it,
-either a parser-assigned one or given explicitly. e.g.
-
-  xs : [Int]
-
--}
-
-data ParamComp = PC { _pci :: PcScope
-                    , _pct :: BareType }
-                    deriving (Show)
-
-data PcScope = PcImplicit Symbol
-             | PcExplicit Symbol
-             | PcNoSymbol
-             deriving (Eq,Show)
-
-nullPC :: BareType -> ParamComp
-nullPC bt = PC PcNoSymbol bt
-
-btP :: Parser ParamComp
-btP = do
-  c@(PC sb _) <- compP
-  case sb of
-    PcNoSymbol   -> return c
-    PcImplicit b -> parseFun c b
-    PcExplicit b -> parseFun c b
-  <?> "btP"
-  where
-    parseFun c@(PC sb t1) b  =
-      ((do
-            reservedOp "->"
-            PC _ t2 <- btP
-            return (PC sb (rFun b t1 t2)))
-        <|>
-         (do
-            reservedOp "~>"
-            PC _ t2 <- btP
-            return (PC sb (rImpF b t1 t2)))
-        <|>
-         (do
-            reservedOp "=>"
-            PC _ t2 <- btP
-            -- TODO:AZ return an error if s == PcExplicit
-            return $ PC sb $ foldr (rFun dummySymbol) t2 (getClasses t1))
-         <|> 
-          (do 
-             spaces 
-             b <- locParserP infixSymbolP
-             spaces
-             PC _ t2 <- btP 
-             return $ PC sb $ (RApp (mkBTyCon b) [t1,t2] [] mempty))
-         <|> return c)
-
-
-compP :: Parser ParamComp
-compP = circleP <* whiteSpace <|> parens btP <?> "compP"
-
-circleP :: Parser ParamComp
-circleP
-  =  nullPC <$> (reserved "forall" >> bareAllP)
- <|> holePC                                 -- starts with '_'
- <|> namedCircleP                           -- starts with lower
- <|> bareTypeBracesP                        -- starts with '{'
- <|> unnamedCircleP
- <|> anglesCircleP                          -- starts with '<'
- <|> nullPC <$> (dummyP (bbaseP <* spaces)) -- starts with '_' or '[' or '(' or lower or "'" or upper
- <?> "circleP"
-
-anglesCircleP :: Parser ParamComp
-anglesCircleP
-  = angles $ do
-      PC sb t <- parens btP
-      p       <- monoPredicateP
-      return   $ PC sb (t `strengthen` MkUReft mempty p)
-
-holePC :: Parser ParamComp
-holePC = do
-  h <- holeP
-  b <- dummyBindP
-  return (PC (PcImplicit b) h)
-
-namedCircleP :: Parser ParamComp
-namedCircleP = do
-  lb <- locParserP lowerIdP
-  (do _ <- colon
-      let b = val lb
-      PC (PcExplicit b) <$> bareArgP b
-    <|> do
-      b <- dummyBindP
-      PC (PcImplicit b) <$> dummyP (lowerIdTail (val lb))
-    )
-
-unnamedCircleP :: Parser ParamComp
-unnamedCircleP = do
-  lb <- locParserP dummyBindP
-  let b = val lb
-  t1 <- bareArgP b
-  return $ PC (PcImplicit b) t1
-
--- ---------------------------------------------------------------------
-
--- | The top-level parser for "bare" refinement types. If refinements are
--- not supplied, then the default "top" refinement is used.
-
-bareTypeP :: Parser BareType
-bareTypeP = do
-  PC _ v <- btP
-  return v
-
-bareTypeBracesP :: Parser ParamComp
-bareTypeBracesP = do
-  t <-  try (braces (
-            (try (do
-               ct <- constraintP
-               return $ Right ct
-                     ))
-           <|>
-            (do
-                    x  <- symbolP
-                    _ <- colon
-                    -- NOSUBST i  <- freshIntP
-                    t  <- bbaseP
-                    reservedOp "|"
-                    ra <- refasHoleP <* spaces
-                    -- xi is a unique var based on the name in x.
-                    -- su replaces any use of x in the balance of the expression with the unique val
-                    -- NOSUBST let xi = intSymbol x i
-                    -- NOSUBST let su v = if v == x then xi else v
-                    return $ Left $ PC (PcExplicit x) $ t (Reft (x, ra)) )
-            )) <|> try (helper holeOrPredsP) <|> helper predP
-  case t of
-    Left l -> return l
-    Right ct -> do
-      PC _sb tt <- btP
-      return $ nullPC $ rrTy ct tt
-  where
-    holeOrPredsP
-      = (reserved "_" >> return hole)
-     <|> try (pAnd <$> brackets (sepBy predP semi))
-    helper p = braces $ do
-      t <- ((RHole . uTop . Reft . ("VV",)) <$> (p <* spaces))
-      return (Left $ nullPC t)
-
-
-bareArgP :: Symbol -> Parser BareType
-bareArgP vvv
-  =  refDefP vvv refasHoleP bbaseP    -- starts with '{'
- <|> holeP                            -- starts with '_'
- <|> (dummyP (bbaseP <* spaces))
- <|> parens bareTypeP                 -- starts with '('
-                                      -- starts with '_', '[', '(', lower, upper
- <?> "bareArgP"
-
-bareAtomP :: (Parser Expr -> Parser (Reft -> BareType) -> Parser BareType)
-          -> Parser BareType
-bareAtomP ref
-  =  ref refasHoleP bbaseP
- <|> holeP
- <|> (dummyP (bbaseP <* spaces))
- <?> "bareAtomP"
-
-bareAtomBindP :: Parser BareType
-bareAtomBindP = bareAtomP refBindBindP
-
-
--- Either
---  { x : t | ra }
--- or
---  { ra }
-refBindBindP :: Parser Expr
-             -> Parser (Reft -> BareType)
-             -> Parser BareType
-refBindBindP rp kindP'
-  = braces (
-      ((do
-              x  <- symbolP
-              _ <- colon
-              -- NOSUBST i  <- freshIntP
-              t  <- kindP'
-              reservedOp "|"
-              ra <- rp <* spaces
-              -- xi is a unique var based on the name in x.
-              -- su replaces any use of x in the balance of the expression with the unique val
-              -- NOSUBST let xi = intSymbol x i
-              -- NOSUBST let su v = if v == x then xi else v
-              return $ {- substa su $ NOSUBST -} t (Reft (x, ra)) ))
-     <|> ((RHole . uTop . Reft . ("VV",)) <$> (rp <* spaces))
-     <?> "refBindBindP"
-   )
-
-
-refDefP :: Symbol
-        -> Parser Expr
-        -> Parser (Reft -> BareType)
-        -> Parser BareType
-refDefP vv rp kindP' = braces $ do
-  x       <- optBindP vv
-  -- NOSUBST i       <- freshIntP
-  t       <- try (kindP' <* reservedOp "|") <|> return (RHole . uTop) <?> "refDefP"
-  ra      <- (rp <* spaces)
-  -- xi is a unique var based on the name in x.
-  -- su replaces any use of x in the balance of the expression with the unique val
-  -- NOSUBST let xi   = intSymbol x i
-  -- NOSUBST let su v = if v == x then xi else v
-  return   $ {- substa su $ NOSUBST -} t (Reft (x, ra))
-       -- substa su . t . Reft . (x,) <$> (rp <* spaces))
-      --  <|> ((RHole . uTop . Reft . ("VV",)) <$> (rp <* spaces))
-
-refP :: Parser (Reft -> BareType) -> Parser BareType
-refP = refBindBindP refaP
-
--- "sym :" or return the devault sym
-optBindP :: Symbol -> Parser Symbol
-optBindP x = try bindP <|> return x
-
-holeP :: Parser BareType
-holeP    = reserved "_" >> spaces >> return (RHole $ uTop $ Reft ("VV", hole))
-
-holeRefP :: Parser (Reft -> BareType)
-holeRefP = reserved "_" >> spaces >> return (RHole . uTop)
-
--- NOPROP refasHoleP :: Parser Expr
--- NOPROP refasHoleP  = try refaP
--- NOPROP          <|> (reserved "_" >> return hole)
-
-refasHoleP :: Parser Expr
-refasHoleP
-  =  (reserved "_" >> return hole)
- <|> refaP
- <?> "refasHoleP"
-
--- FIXME: the use of `blanks = oneOf " \t"` here is a terrible and fragile hack
--- to avoid parsing:
---
---   foo :: a -> b
---   bar :: a
---
--- as `foo :: a -> b bar`..
-bbaseP :: Parser (Reft -> BareType)
-bbaseP
-  =  holeRefP  -- Starts with '_'
- <|> liftM2 bLst (brackets (maybeP bareTypeP)) predicatesP
- <|> liftM2 bTup (parens $ sepBy (maybeBind bareTypeP) comma) predicatesP
- <|> try parseHelper  -- starts with lower
- <|> liftM4 bCon bTyConP predicatesP (sepBy bareTyArgP blanks) mmonoPredicateP
-           -- starts with "'" or upper case char
- <?> "bbaseP"
- where
-   parseHelper = do
-     l <- lowerIdP
-     lowerIdTail l
-
-maybeBind :: Parser a -> Parser (Maybe Symbol, a)
-maybeBind p = do {bd <- maybeP' bbindP; ty <- p ; return (bd, ty)}
-  where
-    maybeP' p = try (Just <$> p)
-             <|> return Nothing
-
-lowerIdTail :: Symbol -> Parser (Reft -> BareType)
-lowerIdTail l =
-     (    (liftM2 bAppTy (return $ bTyVar l) (sepBy1 bareTyArgP blanks))
-      <|> (liftM2 bRVar  (return $ bTyVar l) monoPredicateP))
-
-bTyConP :: Parser BTyCon
-bTyConP
-  =  (reservedOp "'" >> (mkPromotedBTyCon <$> locUpperIdP))
- <|> mkBTyCon <$> locUpperIdP
- <|> (reserved "*" >> (return $ mkBTyCon (dummyLoc $ symbol ("*" :: String))))
- <?> "bTyConP"
-
-mkPromotedBTyCon :: LocSymbol -> BTyCon
-mkPromotedBTyCon x = BTyCon x False True -- (consSym '\'' <$> x) False True
-
-classBTyConP :: Parser BTyCon
-classBTyConP = mkClassBTyCon <$> locUpperIdP
-
-mkClassBTyCon :: LocSymbol -> BTyCon
-mkClassBTyCon x = BTyCon x True False
-
-bbaseNoAppP :: Parser (Reft -> BareType)
-bbaseNoAppP
-  =  holeRefP
- <|> liftM2 bLst (brackets (maybeP bareTypeP)) predicatesP
- <|> liftM2 bTup (parens $ sepBy (maybeBind bareTypeP) comma) predicatesP
- <|> try (liftM4 bCon bTyConP predicatesP (return []) (return mempty))
- <|> liftM2 bRVar (bTyVar <$> lowerIdP) monoPredicateP
- <?> "bbaseNoAppP"
-
-maybeP :: ParsecT s u m a -> ParsecT s u m (Maybe a)
-maybeP p = liftM Just p <|> return Nothing
-
-bareTyArgP :: Parser BareType
-bareTyArgP
-  =  (RExprArg . fmap expr <$> locParserP integer)
- <|> try (braces $ RExprArg <$> locParserP exprP)
- <|> try bareAtomNoAppP
- <|> try (parens bareTypeP)
- <?> "bareTyArgP"
-
-bareAtomNoAppP :: Parser BareType
-bareAtomNoAppP
-  =  refP bbaseNoAppP
- <|> (dummyP (bbaseNoAppP <* blanks))
- <?> "bareAtomNoAppP"
-
-
-constraintP :: Parser BareType
-constraintP
-  = do xts <- constraintEnvP
-       t1  <- bareTypeP
-       reservedOp "<:"
-       t2  <- bareTypeP
-       return $ fromRTypeRep $ RTypeRep [] [] []
-                                        [] [] 
-                                        ((val . fst <$> xts) ++ [dummySymbol])
-                                        (replicate (length xts + 1) mempty)
-                                        ((snd <$> xts) ++ [t1]) t2
-
-constraintEnvP :: Parser [(LocSymbol, BareType)]
-constraintEnvP
-   =  try (do xts <- sepBy tyBindNoLocP comma
-              reservedOp "|-"
-              return xts)
-  <|> return []
-  <?> "constraintEnvP"
-
-rrTy :: Monoid r => RType c tv r -> RType c tv r -> RType c tv r
-rrTy ct = RRTy (xts ++ [(dummySymbol, tr)]) mempty OCons
-  where
-    tr   = ty_res trep
-    xts  = zip (ty_binds trep) (ty_args trep)
-    trep = toRTypeRep ct
-
---  "forall <z w> . TYPE"
--- or
---  "forall x y <z :: Nat, w :: Int> . TYPE"
-bareAllP :: Parser BareType
-bareAllP = do
-  as <- tyVarDefsP
-  ps <- angles inAngles
-        <|> (return [])
-  dot
-  t <- bareTypeP
-  return $ foldr rAllT (foldr RAllP t ps) (makeRTVar <$> as)
-  where
-    rAllT a t = RAllT a t mempty
-    inAngles =
-      (
-       (try  (sepBy  predVarDefP comma))
-       )
-
-tyVarDefsP :: Parser [BTyVar]
-tyVarDefsP
-  = (parens $ many (bTyVar <$> tyKindVarIdP))
- <|> many (bTyVar <$> tyVarIdP)
- <?> "tyVarDefsP"
-
--- TODO:AZ use something from Token instead
-tyVarIdP :: Parser Symbol
-tyVarIdP = symbol <$> condIdP (lower <|> char '_') alphanums isNotReserved -- (isSmall . head)
-  where
-    alphanums = S.fromList $ ['a'..'z'] ++ ['0'..'9']
-
-tyKindVarIdP :: Parser Symbol
-tyKindVarIdP = do
-   tv <- tyVarIdP
-   (  (do reservedOp "::"; _ <- kindP; return tv)
-    <|> return tv)
-
-kindP :: Parser BareType
-kindP = bareAtomBindP
-
-predVarDefsP :: Parser [PVar BSort]
-predVarDefsP
-  =  (angles $ sepBy1 predVarDefP comma)
- <|> return []
- <?> "predVarDefP"
-
-predVarDefP :: Parser (PVar BSort)
-predVarDefP
-  = bPVar <$> predVarIdP <*> dcolon <*> propositionSortP
-
-predVarIdP :: Parser Symbol
-predVarIdP
-  = symbol <$> tyVarIdP
-
-bPVar :: Symbol -> t -> [(Symbol, t1)] -> PVar t1
-bPVar p _ xts  = PV p (PVProp τ) dummySymbol τxs
-  where
-    (_, τ) = safeLast "bPVar last" xts
-    τxs    = [ (τ, x, EVar x) | (x, τ) <- init xts ]
-    safeLast _ xs@(_:_) = last xs
-    safeLast msg _      = panic Nothing $ "safeLast with empty list " ++ msg
-
-propositionSortP :: Parser [(Symbol, BSort)]
-propositionSortP = map (Misc.mapSnd toRSort) <$> propositionTypeP
-
-propositionTypeP :: Parser [(Symbol, BareType)]
-propositionTypeP = either parserFail return =<< (mkPropositionType <$> bareTypeP)
-
-mkPropositionType :: BareType -> Either String [(Symbol, BareType)]
-mkPropositionType t
-  | isOk      = Right $ zip (ty_binds tRep) (ty_args tRep)
-  | otherwise = Left err
-  where
-    isOk      = isPropBareType (ty_res tRep)
-    tRep      = toRTypeRep t
-    err       = "Proposition type with non-Bool output: " ++ showpp t
-
-xyP :: Parser x -> Parser a -> Parser y -> Parser (x, y)
-xyP lP sepP rP = (\x _ y -> (x, y)) <$> lP <*> (spaces >> sepP) <*> rP
-
-dummyBindP :: Parser Symbol
-dummyBindP = tempSymbol "db" <$> freshIntP
-
-isPropBareType :: RType BTyCon t t1 -> Bool
-isPropBareType  = isPrimBareType boolConName
-
-isPrimBareType :: Symbol -> RType BTyCon t t1 -> Bool
-isPrimBareType n (RApp tc [] _ _) = val (btc_tc tc) == n
-isPrimBareType _ _                = False
-
-getClasses :: RType BTyCon t t1 -> [RType BTyCon t t1]
-getClasses (RApp tc ts ps r)
-  | isTuple tc
-  = concatMap getClasses ts
-  | otherwise
-  = [RApp (tc { btc_class = True }) ts ps r]
-getClasses t
-  = [t]
-
-dummyP ::  Monad m => m (Reft -> b) -> m b
-dummyP fm
-  = fm `ap` return dummyReft
-
-symsP :: (IsString tv, Monoid r)
-      => Parser [(Symbol, RType c tv r)]
-symsP
-  = do reservedOp "\\"
-       ss <- sepBy symbolP spaces
-       reservedOp "->"
-       return $ (, dummyRSort) <$> ss
- <|> return []
- <?> "symsP"
-
-dummyRSort :: (IsString tv, Monoid r) => RType c tv r
-dummyRSort
-  = RVar "dummy" mempty
-
-predicatesP :: (IsString tv, Monoid r)
-            => Parser [Ref (RType c tv r) BareType]
-predicatesP
-   =  (angles $ sepBy1 predicate1P comma)
-  <|> return []
-  <?> "predicatesP"
-
-predicate1P :: (IsString tv, Monoid r)
-            => Parser (Ref (RType c tv r) BareType)
-predicate1P
-   =  try (RProp <$> symsP <*> refP bbaseP)
-  <|> (rPropP [] . predUReft <$> monoPredicate1P)
-  <|> (braces $ bRProp <$> symsP' <*> refaP)
-  <?> "predicate1P"
-   where
-    symsP'       = do ss    <- symsP
-                      fs    <- mapM refreshSym (fst <$> ss)
-                      return $ zip ss fs
-    refreshSym s = intSymbol s <$> freshIntP
-
-mmonoPredicateP :: Parser Predicate
-mmonoPredicateP
-   = try (angles $ angles monoPredicate1P)
-  <|> return mempty
-  <?> "mmonoPredicateP"
-
-monoPredicateP :: Parser Predicate
-monoPredicateP
-   = try (angles monoPredicate1P)
-  <|> return mempty
-  <?> "monoPredicateP"
-
-monoPredicate1P :: Parser Predicate
-monoPredicate1P
-   =  (reserved "True" >> return mempty)
-  <|> (pdVar <$> parens predVarUseP)
-  <|> (pdVar <$>        predVarUseP)
-  <?> "monoPredicate1P"
-
-predVarUseP :: IsString t
-            => Parser (PVar t)
-predVarUseP
-  = do (p, xs) <- funArgsP
-       return   $ PV p (PVProp dummyTyId) dummySymbol [ (dummyTyId, dummySymbol, x) | x <- xs ]
-
-funArgsP :: Parser (Symbol, [Expr])
-funArgsP  = try realP <|> empP <?> "funArgsP"
-  where
-    empP  = (,[]) <$> predVarIdP
-    realP = do (EVar lp, xs) <- splitEApp <$> funAppP
-               return (lp, xs)
-
-boundP :: Parser (Bound (Located BareType) Expr)
-boundP = do
-  name   <- locParserP upperIdP
-  reservedOp "="
-  vs     <- bvsP
-  params <- many (parens tyBindP)
-  args   <- bargsP
-  body   <- predP
-  return $ Bound name vs params args body
- where
-    bargsP =     ( do reservedOp "\\"
-                      xs <- many (parens tyBindP)
-                      reservedOp  "->"
-                      return xs
-                 )
-           <|> return []
-           <?> "bargsP"
-    bvsP   =     ( do reserved "forall"
-                      xs <- many (locParserP (bTyVar <$> symbolP))
-                      reservedOp  "."
-                      return (fmap (`RVar` mempty) <$> xs)
-                 )
-           <|> return []
-
-
-infixGenP :: Assoc -> Parser ()
-infixGenP assoc = do
-   spaces
-   p <- maybeDigit
-   spaces
-   s <- infixIdP
-   spaces
-   addOperatorP (FInfix p s Nothing assoc)
-
-
-infixP :: Parser ()
-infixP = infixGenP AssocLeft
-
-infixlP :: Parser ()
-infixlP = infixGenP AssocLeft
-
-infixrP :: Parser ()
-infixrP = infixGenP AssocRight
-
-maybeDigit :: Parser (Maybe Int)
-maybeDigit
-  = try (satisfy isDigit >>= return . Just . read . (:[]))
-  <|> return Nothing
-
-------------------------------------------------------------------------
------------------------ Wrapped Constructors ---------------------------
-------------------------------------------------------------------------
-
-bRProp :: [((Symbol, τ), Symbol)]
-       -> Expr -> Ref τ (RType c BTyVar (UReft Reft))
-bRProp []    _    = panic Nothing "Parse.bRProp empty list"
-bRProp syms' expr = RProp ss $ bRVar (BTV dummyName) mempty r
-  where
-    (ss, (v, _))  = (init syms, last syms)
-    syms          = [(y, s) | ((_, s), y) <- syms']
-    su            = mkSubst [(x, EVar y) | ((x, _), y) <- syms']
-    r             = su `subst` Reft (v, expr)
-
-bRVar :: tv -> Predicate -> r -> RType c tv (UReft r)
-bRVar α p r = RVar α (MkUReft r p)
-
-bLst :: Maybe (RType BTyCon tv (UReft r))
-     -> [RTProp BTyCon tv (UReft r)]
-     -> r
-     -> RType BTyCon tv (UReft r)
-bLst (Just t) rs r        = RApp (mkBTyCon $ dummyLoc listConName) [t] rs (reftUReft r)
-bLst (Nothing) rs r       = RApp (mkBTyCon $ dummyLoc listConName) []  rs (reftUReft r)
-
-bTup :: (PPrint r, Reftable r, Reftable (RType BTyCon BTyVar (UReft r)), Reftable (RTProp BTyCon BTyVar (UReft r)))
-     => [(Maybe Symbol, RType BTyCon BTyVar (UReft r))]
-     -> [RTProp BTyCon BTyVar (UReft r)]
-     -> r
-     -> RType BTyCon BTyVar (UReft r)
-bTup [(_,t)] _ r
-  | isTauto r  = t
-  | otherwise  = t `strengthen` (reftUReft r)
-bTup ts rs r
-  | all Mb.isNothing (fst <$> ts) || length ts < 2
-  = RApp (mkBTyCon $ dummyLoc tupConName) (snd <$> ts) rs (reftUReft r)
-  | otherwise
-  = RApp (mkBTyCon $ dummyLoc tupConName) ((top . snd) <$> ts) rs' (reftUReft r)
-  where
-    args       = [(Mb.fromMaybe dummySymbol x, mapReft mempty t) | (x,t) <- ts]
-    makeProp i = RProp (take i args) ((snd <$> ts)!!i)
-    rs'        = makeProp <$> [1..(length ts-1)]
-
-
--- Temporarily restore this hack benchmarks/esop2013-submission/Array.hs fails
--- w/o it
--- TODO RApp Int [] [p] true should be syntactically different than RApp Int [] [] p
--- bCon b s [RProp _ (RHole r1)] [] _ r = RApp b [] [] $ r1 `meet` (MkUReft r mempty s)
-bCon :: c
-     -> [RTProp c tv (UReft r)]
-     -> [RType c tv (UReft r)]
-     -> Predicate
-     -> r
-     -> RType c tv (UReft r)
-bCon b rs ts p r = RApp b ts rs $ MkUReft r p
-
-bAppTy :: (Foldable t, PPrint r, Reftable r)
-       => tv -> t (RType c tv (UReft r)) -> r -> RType c tv (UReft r)
-bAppTy v ts r  = ts' `strengthen` reftUReft r
-  where
-    ts'        = foldl' (\a b -> RAppTy a b mempty) (RVar v mempty) ts
-
-reftUReft :: r -> UReft r
-reftUReft r    = MkUReft r mempty
-
-predUReft :: Monoid r => Predicate -> UReft r
-predUReft p    = MkUReft dummyReft p
-
-dummyReft :: Monoid a => a
-dummyReft      = mempty
-
-dummyTyId :: IsString a => a
-dummyTyId      = ""
-
-------------------------------------------------------------------
---------------------------- Measures -----------------------------
-------------------------------------------------------------------
-
-type BPspec = Pspec LocBareType LocSymbol
-
--- | The AST for a single parsed spec.
-data Pspec ty ctor
-  = Meas    (Measure ty ctor)                             -- ^ 'measure' definition
-  | Assm    (LocSymbol, ty)                               -- ^ 'assume' signature (unchecked)
-  | Asrt    (LocSymbol, ty)                               -- ^ 'assert' signature (checked)
-  | LAsrt   (LocSymbol, ty)                               -- ^ 'local' assertion -- RJ: what is this
-  | Asrts   ([LocSymbol], (ty, Maybe [Located Expr]))     -- ^ RJ: what is this
-  | Impt    Symbol                                        -- ^ 'import' a specification module
-  | DDecl   DataDecl                                      -- ^ refined 'data'    declaration 
-  | NTDecl  DataDecl                                      -- ^ refined 'newtype' declaration
-  | Class   (RClass ty)                                   -- ^ refined 'class' definition
-  | CLaws   (RClass ty)                                   -- ^ 'class laws' definition
-  | ILaws   (RILaws ty)
-  | RInst   (RInstance ty)                                -- ^ refined 'instance' definition
-  | Incl    FilePath                                      -- ^ 'include' a path -- TODO: deprecate 
-  | Invt    ty                                            -- ^ 'invariant' specification
-  | Using  (ty, ty)                                       -- ^ 'using' declaration (for local invariants on a type) 
-  | Alias   (Located (RTAlias Symbol BareType))           -- ^ 'type' alias declaration  
-  | EAlias  (Located (RTAlias Symbol Expr))               -- ^ 'predicate' alias declaration
-  | Embed   (LocSymbol, FTycon, TCArgs)                   -- ^ 'embed' declaration
-  | Qualif  Qualifier                                     -- ^ 'qualif' definition
-  | Decr    (LocSymbol, [Int])                            -- ^ 'decreasing' annotation -- TODO: deprecate
-  | LVars   LocSymbol                                     -- ^ 'lazyvar' annotation, defer checks to *use* sites
-  | Lazy    LocSymbol                                     -- ^ 'lazy' annotation, skip termination check on binder
-  | Fail    LocSymbol                                     -- ^ 'fail' annotation, the binder should be unsafe
-  | Rewrite LocSymbol                                     -- ^ 'rewrite' annotation, the binder generates a rewrite rule
-  | Rewritewith (LocSymbol,[LocSymbol])                     -- ^ 'rewritewith' annotation, the first binder is using the rewrite rules of the second list
-  | Insts   (LocSymbol, Maybe Int)                        -- ^ 'auto-inst' or 'ple' annotation; use ple locally on binder 
-  | HMeas   LocSymbol                                     -- ^ 'measure' annotation; lift Haskell binder as measure
-  | Reflect LocSymbol                                     -- ^ 'reflect' annotation; reflect Haskell binder as function in logic
-  | Inline  LocSymbol                                     -- ^ 'inline' annotation;  inline (non-recursive) binder as an alias
-  | Ignore  LocSymbol                                     -- ^ 'ignore' annotation; skip all checks inside this binder
-  | ASize   LocSymbol                                     -- ^ 'autosize' annotation; automatically generate size metric for this type
-  | HBound  LocSymbol                                     -- ^ 'bound' annotation; lift Haskell binder as an abstract-refinement "bound"
-  | PBound  (Bound ty Expr)                               -- ^ 'bound' definition
-  | Pragma  (Located String)                              -- ^ 'LIQUID' pragma, used to save configuration options in source files
-  | CMeas   (Measure ty ())                               -- ^ 'class measure' definition
-  | IMeas   (Measure ty ctor)                             -- ^ 'instance measure' definition
-  | Varia   (LocSymbol, [Variance])                       -- ^ 'variance' annotations, marking type constructor params as co-, contra-, or in-variant
-  | BFix    ()                                            -- ^ fixity annotation
-  | Define  (LocSymbol, Symbol)                           -- ^ 'define' annotation for specifying aliases c.f. `include-CoreToLogic.lg`
-  deriving (Data, Typeable)
-
-instance (PPrint ty, PPrint ctor) => PPrint (Pspec ty ctor) where 
-  pprintTidy = ppPspec 
-
-splice :: PJ.Doc -> [PJ.Doc] -> PJ.Doc
-splice sep = PJ.hcat . PJ.punctuate sep
-
-ppAsserts :: (PPrint t) => Tidy -> [LocSymbol] -> t -> Maybe [Located Expr] -> PJ.Doc
-ppAsserts k lxs t les 
-  = PJ.hcat [ splice ", " (pprintTidy k <$> (val <$> lxs))
-            , " :: " 
-            , pprintTidy k t   
-            , ppLes les 
-            ]
-  where 
-    ppLes Nothing    = ""
-    ppLes (Just les) = "/" <+> pprintTidy k (val <$> les)
-
-ppPspec :: (PPrint t, PPrint c) => Tidy -> Pspec t c -> PJ.Doc
-ppPspec k (Meas m)        
-  = "measure" <+> pprintTidy k m 
-ppPspec k (Assm (lx, t))  
-  = "assume"  <+> pprintTidy k (val lx) <+> "::" <+> pprintTidy k t 
-ppPspec k (Asrt (lx, t))  
-  = "assert"  <+> pprintTidy k (val lx) <+> "::" <+> pprintTidy k t 
-ppPspec k (LAsrt (lx, t)) 
-  = "local assert"  <+> pprintTidy k (val lx) <+> "::" <+> pprintTidy k t 
-ppPspec k (Asrts (lxs, (t, les))) 
-  = ppAsserts k lxs t les
-ppPspec k (Impt  x) 
-  = "import" <+> pprintTidy k x 
-ppPspec k (DDecl d) 
-  = pprintTidy k d 
-ppPspec k (NTDecl d) 
-  = "newtype" <+> pprintTidy k d 
-ppPspec _ (Incl f) 
-  = "include" <+> "<" PJ.<> PJ.text f PJ.<> ">"
-ppPspec k (Invt t)
-  = "invariant" <+> pprintTidy k t 
-ppPspec k (Using (t1, t2)) 
-  = "using" <+> pprintTidy k t1 <+> "as" <+> pprintTidy k t2
-ppPspec k (Alias   (Loc _ _ rta)) 
-  = "type" <+> pprintTidy k rta 
-ppPspec k (EAlias  (Loc _ _ rte)) 
-  = "predicate" <+> pprintTidy k rte 
-ppPspec k (Embed   (lx, tc, NoArgs)) 
-  = "embed" <+> pprintTidy k (val lx)         <+> "as" <+> pprintTidy k tc 
-ppPspec k (Embed   (lx, tc, WithArgs)) 
-  = "embed" <+> pprintTidy k (val lx) <+> "*" <+> "as" <+> pprintTidy k tc 
-ppPspec k (Qualif  q)              
-  = pprintTidy k q 
-ppPspec k (Decr (lx, ns))        
-  = "decreasing" <+> pprintTidy k (val lx) <+> pprintTidy k ns
-ppPspec k (LVars   lx) 
-  = "lazyvar" <+> pprintTidy k (val lx) 
-ppPspec k (Lazy   lx) 
-  = "lazy" <+> pprintTidy k (val lx) 
-ppPspec k (Rewrite   lx) 
-  = "rewrite" <+> pprintTidy k (val lx) 
-ppPspec k (Rewritewith (lx, lxs)) 
-  = "rewriteWith" <+> pprintTidy k (val lx) <+> pprintTidy k (val <$> lxs) 
-ppPspec k (Fail   lx) 
-  = "fail" <+> pprintTidy k (val lx) 
-ppPspec k (Insts   (lx, mbN)) 
-  = "automatic-instances" <+> pprintTidy k (val lx) <+> maybe "" (("with" <+>) . pprintTidy k) mbN 
-ppPspec k (HMeas   lx) 
-  = "measure" <+> pprintTidy k (val lx) 
-ppPspec k (Reflect lx) 
-  = "reflect" <+> pprintTidy k (val lx) 
-ppPspec k (Inline  lx) 
-  = "inline" <+> pprintTidy k (val lx) 
-ppPspec k (Ignore  lx) 
-  = "ignore" <+> pprintTidy k (val lx) 
-ppPspec k (HBound  lx) 
-  = "bound" <+> pprintTidy k (val lx) 
-ppPspec k (ASize   lx) 
-  = "autosize" <+> pprintTidy k (val lx) 
-ppPspec k (PBound  bnd) 
-  = pprintTidy k bnd 
-ppPspec _ (Pragma  (Loc _ _ s)) 
-  = "LIQUID" <+> PJ.text s 
-ppPspec k (CMeas   m) 
-  = "class measure" <+> pprintTidy k m
-ppPspec k (IMeas   m) 
-  = "instance  measure" <+> pprintTidy k m
-ppPspec k (Class   cls) 
-  = pprintTidy k cls 
-ppPspec k (CLaws  cls) 
-  = pprintTidy k cls 
-ppPspec k (RInst   inst) 
-  = pprintTidy k inst 
-ppPspec k (Varia   (lx, vs))  
-  = "data variance" <+> pprintTidy k (val lx) <+> splice " " (pprintTidy k <$> vs) 
-ppPspec _ (BFix    _)           -- 
-  = "fixity"
-ppPspec k (Define  (lx, y))     
-  = "define" <+> pprintTidy k (val lx) <+> "=" <+> pprintTidy k y 
-ppPspec _ (ILaws {}) 
-  = "TBD-INSTANCE-LAWS"
-
-
--- | For debugging
-{-instance Show (Pspec a b) where
-  show (Meas   _) = "Meas"
-  show (Assm   _) = "Assm"
-  show (Asrt   _) = "Asrt"
-  show (LAsrt  _) = "LAsrt"
-  show (Asrts  _) = "Asrts"
-  show (Impt   _) = "Impt"
-  shcl  _) = "DDecl"
-  show (NTDecl _) = "NTDecl"
-  show (Incl   _) = "Incl"
-  show (Invt   _) = "Invt"
-  show (Using _) = "Using"
-  show (Alias  _) = "Alias"
-  show (EAlias _) = "EAlias"
-  show (Embed  _) = "Embed"
-  show (Qualif _) = "Qualif"
-  show (Decr   _) = "Decr"
-  show (LVars  _) = "LVars"
-  show (Lazy   _) = "Lazy"
-  -- show (Axiom  _) = "Axiom"
-  show (Insts  _) = "Insts"
-  show (Reflect _) = "Reflect"
-  show (HMeas  _) = "HMeas"
-  show (HBound _) = "HBound"
-  show (Inline _) = "Inline"
-  show (Pragma _) = "Pragma"
-  show (CMeas  _) = "CMeas"
-  show (IMeas  _) = "IMeas"
-  show (Class  _) = "Class"
-  show (Varia  _) = "Varia"
-  show (PBound _) = "Bound"
-  show (RInst  _) = "RInst"
-  show (ASize  _) = "ASize"
-  show (BFix   _) = "BFix"
-  show (Define _) = "Define"-}
-
-qualifySpec :: Symbol -> Spec ty bndr -> Spec ty bndr
-qualifySpec name sp = sp { sigs      = [ (tx x, t)  | (x, t)  <- sigs sp]
-                         -- , asmSigs   = [ (tx x, t)  | (x, t)  <- asmSigs sp]
-                         }
-  where
-    tx :: Located Symbol -> Located Symbol
-    tx = fmap (qualifySymbol name)
-
--- | Turns a list of parsed specifications into a "bare spec".
---
--- This is primarily a rearrangement, as the bare spec is a record containing
--- different kinds of spec directives in different positions, whereas the input
--- list is a mixed list.
---
--- In addition, the sigs of the spec (these are asserted/checked LH type
--- signatues) are being qualified, i.e., the binding occurrences are prefixed
--- with the module name.
---
--- Andres: It is unfortunately totally unclear to me what the justification
--- for the qualification is, and in particular, why it is being done for
--- the asserted signatures only. My trust is not exactly improved by the
--- commented out line in 'qualifySpec'.
---
-mkSpec :: ModName -> [BPspec] -> (ModName, Measure.Spec LocBareType LocSymbol)
-mkSpec name xs         = (name,) $ qualifySpec (symbol name) Measure.Spec
-  { Measure.measures   = [m | Meas   m <- xs]
-  , Measure.asmSigs    = [a | Assm   a <- xs]
-  , Measure.sigs       = [a | Asrt   a <- xs]
-                      ++ [(y, t) | Asrts (ys, (t, _)) <- xs, y <- ys]
-  , Measure.localSigs  = []
-  , Measure.reflSigs   = []
-  , Measure.impSigs    = []
-  , Measure.expSigs    = [] 
-  , Measure.invariants = [(Nothing, t) | Invt   t <- xs]
-  , Measure.ialiases   = [t | Using t <- xs]
-  , Measure.imports    = [i | Impt   i <- xs]
-  , Measure.dataDecls  = [d | DDecl  d <- xs] ++ [d | NTDecl d <- xs]
-  , Measure.newtyDecls = [d | NTDecl d <- xs]
-  , Measure.includes   = [q | Incl   q <- xs]
-  , Measure.aliases    = [a | Alias  a <- xs]
-  , Measure.ealiases   = [e | EAlias e <- xs]
-  , Measure.embeds     = tceFromList [(c, (fTyconSort tc, a)) | Embed (c, tc, a) <- xs]
-  , Measure.qualifiers = [q | Qualif q <- xs]
-  , Measure.decr       = [d | Decr d   <- xs]
-  , Measure.lvars      = S.fromList [d | LVars d  <- xs]
-  , Measure.autois     = M.fromList [s | Insts s <- xs]
-  , Measure.pragmas    = [s | Pragma s <- xs]
-  , Measure.cmeasures  = [m | CMeas  m <- xs]
-  , Measure.imeasures  = [m | IMeas  m <- xs]
-  , Measure.classes    = [c | Class  c <- xs]
-  , Measure.claws      = [c | CLaws  c <- xs]
-  , Measure.dvariance  = [v | Varia  v <- xs]
-  , Measure.rinstance  = [i | RInst  i <- xs]
-  , Measure.ilaws      = [i | ILaws  i <- xs]
-  , Measure.termexprs  = [(y, es) | Asrts (ys, (_, Just es)) <- xs, y <- ys]
-  , Measure.lazy       = S.fromList [s | Lazy   s <- xs]
-  , Measure.fails      = S.fromList [s | Fail   s <- xs]
-  , Measure.rewrites   = S.fromList [s | Rewrite s <- xs]
-  , Measure.rewriteWith = M.fromList [s | Rewritewith s <- xs]
-  , Measure.bounds     = M.fromList [(bname i, i) | PBound i <- xs]
-  , Measure.reflects   = S.fromList [s | Reflect s <- xs]
-  , Measure.hmeas      = S.fromList [s | HMeas  s <- xs]
-  , Measure.inlines    = S.fromList [s | Inline s <- xs]
-  , Measure.ignores    = S.fromList [s | Ignore s <- xs]
-  , Measure.autosize   = S.fromList [s | ASize  s <- xs]
-  , Measure.hbounds    = S.fromList [s | HBound s <- xs]
-  , Measure.defs       = M.fromList [d | Define d <- xs]
-  , Measure.axeqs      = []
-  }
-
--- | Parse a single top level liquid specification
-specP :: Parser BPspec
-specP
-  =     (fallbackSpecP "assume"     (liftM Assm    tyBindP  ))
-    <|> (fallbackSpecP "assert"     (liftM Asrt    tyBindP  ))
-    <|> (fallbackSpecP "autosize"   (liftM ASize   asizeP   ))
-    <|> (reserved "local"         >> liftM LAsrt   tyBindP  )
-
-    -- TODO: These next two are synonyms, kill one
-    <|> (fallbackSpecP "axiomatize" (liftM Reflect axiomP   ))
-    <|> (fallbackSpecP "reflect"    (liftM Reflect axiomP   ))
-
-    <|> (fallbackSpecP "measure"    hmeasureP)
-
-    <|> (fallbackSpecP "define"     (liftM Define  defineP  ))
-    <|> (reserved "infixl"        >> liftM BFix    infixlP  )
-    <|> (reserved "infixr"        >> liftM BFix    infixrP  )
-    <|> (reserved "infix"         >> liftM BFix    infixP   )
-    <|> (fallbackSpecP "inline"     (liftM Inline  inlineP  ))
-    <|> (fallbackSpecP "ignore"     (liftM Ignore  inlineP  ))
-
-    <|> (fallbackSpecP "bound"    (((liftM PBound  boundP   )
-                                <|> (liftM HBound  hboundP  ))))
-    <|> (reserved "class"
-         >> ((reserved "measure"  >> liftM CMeas  cMeasureP )
-         <|> (reserved "laws"     >> liftM CLaws  classP)
-         <|> liftM Class  classP                            ))
-    <|> (reserved "instance"
-         >> ((reserved "measure"  >> liftM IMeas  iMeasureP )
-         <|> (reserved "laws"     >> liftM ILaws instanceLawP)
-         <|> liftM RInst  instanceP ))
-
-    <|> (reserved "import"        >> liftM Impt   symbolP   )
-
-    <|> (reserved "data"
-        >> ((reserved "variance"  >> liftM Varia  datavarianceP)
-                                 <|> liftM DDecl  dataDeclP ))
-
-    <|> (reserved "newtype"       >> liftM NTDecl dataDeclP )
-    <|> (reserved "include"       >> liftM Incl   filePathP )
-    <|> (fallbackSpecP "invariant"  (liftM Invt   invariantP))
-    <|> (reserved "using"         >> liftM Using invaliasP )
-    <|> (reserved "type"          >> liftM Alias  aliasP    )
-
-    -- TODO: Next two are basically synonyms
-    <|> (fallbackSpecP "predicate"  (liftM EAlias ealiasP   ))
-    <|> (fallbackSpecP "expression" (liftM EAlias ealiasP   ))
-
-    <|> (fallbackSpecP "embed"      (liftM Embed  embedP    ))
-    <|> (fallbackSpecP "qualif"     (liftM Qualif (qualifierP sortP)))
-    <|> (reserved "decrease"      >> liftM Decr   decreaseP )
-    <|> (reserved "lazyvar"       >> liftM LVars  lazyVarP  )
-
-    <|> (reserved "lazy"          >> liftM Lazy   lazyVarP  )
-    <|> (reserved "rewrite"       >> liftM Rewrite   rewriteVarP )
-    <|> (reserved "rewriteWith"   >> liftM Rewritewith   rewriteWithP )
-    <|> (reserved "fail"          >> liftM Fail   failVarP  )
-    <|> (reserved "ple"           >> liftM Insts autoinstP  )
-    <|> (reserved "automatic-instances" >> liftM Insts autoinstP  )
-    <|> (reserved "LIQUID"        >> liftM Pragma pragmaP   )
-    <|> {- DEFAULT -}                liftM Asrts  tyBindsP
-    <?> "specP"
-
--- | Try the given parser on the tail after matching the reserved word, and if
--- it fails fall back to parsing it as a haskell signature for a function with
--- the same name.
-fallbackSpecP :: String -> Parser BPspec -> Parser BPspec
-fallbackSpecP kw p = do
-  (Loc l1 l2 _) <- locParserP (reserved kw)
-  (p <|> liftM Asrts (tyBindsRemP (Loc l1 l2 (symbol kw)) ))
-
--- | Same as tyBindsP, except the single initial symbol has already been matched
-tyBindsRemP :: LocSymbol -> Parser ([LocSymbol], (Located BareType, Maybe [Located Expr]))
-tyBindsRemP sym = do
-  dcolon
-  tb <- termBareTypeP
-  return ([sym],tb)
-
-pragmaP :: Parser (Located String)
-pragmaP = locParserP stringLiteral
-
-autoinstP :: Parser (LocSymbol, Maybe Int)
-autoinstP = do x <- locParserP binderP
-               spaces
-               i <- maybeP (reserved "with" >> integer)
-               return (x, fromIntegral <$> i)
-
-lazyVarP :: Parser LocSymbol
-lazyVarP = locParserP binderP
-
-
-rewriteVarP :: Parser LocSymbol
-rewriteVarP = locParserP binderP
-
-rewriteWithP :: Parser (LocSymbol, [LocSymbol])
-rewriteWithP = do s  <- locParserP binderP 
-                  spaces
-                  ss <- brackets $ sepBy1 (locParserP binderP) comma
-                  spaces
-                  return (s, ss)
-
-failVarP :: Parser LocSymbol
-failVarP = locParserP binderP
-
-axiomP :: Parser LocSymbol
-axiomP = locParserP binderP
-
-hboundP :: Parser LocSymbol
-hboundP = locParserP binderP
-
-inlineP :: Parser LocSymbol
-inlineP = locParserP binderP
-
-asizeP :: Parser LocSymbol
-asizeP = locParserP binderP
-
-decreaseP :: Parser (LocSymbol, [Int])
-decreaseP = Misc.mapSnd f <$> liftM2 (,) (locParserP binderP) (spaces >> many integer)
-  where
-    f     = ((\n -> fromInteger n - 1) <$>)
-
-filePathP     :: Parser FilePath
-filePathP     = angles $ many1 pathCharP
-  where
-    pathCharP = choice $ char <$> pathChars
-    pathChars = ['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'] ++ ['.', '/']
-
-datavarianceP :: Parser (Located Symbol, [Variance])
-datavarianceP = liftM2 (,) locUpperIdP (spaces >> many varianceP)
-
-varianceP :: Parser Variance
-varianceP = (reserved "bivariant"     >> return Bivariant)
-        <|> (reserved "invariant"     >> return Invariant)
-        <|> (reserved "covariant"     >> return Covariant)
-        <|> (reserved "contravariant" >> return Contravariant)
-        <?> "Invalid variance annotation\t Use one of bivariant, invariant, covariant, contravariant"
-
-tyBindsP :: Parser ([LocSymbol], (Located BareType, Maybe [Located Expr]))
-tyBindsP = do 
-  (xs, z) <- xyP (sepBy (locParserP binderP) comma) dcolon termBareTypeP
-  when (null xs) (parserFail $ "Type signature " ++ show z ++ " must have non-empty list of binders!") 
-  return (xs, z)
-
-
-tyBindNoLocP :: Parser (LocSymbol, BareType)
-tyBindNoLocP = second val <$> tyBindP
-
-
-tyBindP    :: Parser (LocSymbol, Located BareType)
-tyBindP    = xyP xP dcolon tP
-  where
-    xP     = locParserP binderP
-    tP     = locParserP genBareTypeP
-
-termBareTypeP :: Parser (Located BareType, Maybe [Located Expr])
-termBareTypeP = do
-  t <- locParserP genBareTypeP
-  (termTypeP t
-    <|> return (t, Nothing))
-
-termTypeP :: Located BareType ->Parser (Located BareType, Maybe [Located Expr])
-termTypeP t
-  = do
-       reservedOp "/"
-       es <- brackets $ sepBy (locParserP exprP) comma
-       return (t, Just es)
-
--- -------------------------------------
-
-invariantP :: Parser (Located BareType)
-invariantP = locParserP genBareTypeP
-
-invaliasP :: Parser (Located BareType, Located BareType)
-invaliasP
-  = do t  <- locParserP genBareTypeP
-       reserved "as"
-       ta <- locParserP genBareTypeP
-       return (t, ta)
-
-genBareTypeP :: Parser BareType
-genBareTypeP = bareTypeP
-
-embedP :: Parser (Located Symbol, FTycon, TCArgs)
-embedP = do 
-  x <- locUpperIdP 
-  a <- try (reserved "*" >> return WithArgs) <|> return NoArgs 
-  _ <- spaces >> reserved "as"
-  t <- fTyConP   
-  return (x, t, a)
-  --  = xyP locUpperIdP symbolTCArgs (reserved "as") fTyConP
-
-
-aliasP :: Parser (Located (RTAlias Symbol BareType))
-aliasP  = rtAliasP id     bareTypeP
-
-ealiasP :: Parser (Located (RTAlias Symbol Expr))
-ealiasP = try (rtAliasP symbol predP)
-      <|> rtAliasP symbol exprP
-      <?> "ealiasP"
-
-rtAliasP :: (Symbol -> tv) -> Parser ty -> Parser (Located (RTAlias tv ty))
-rtAliasP f bodyP
-  -- TODO:AZ pretty sure that all the 'spaces' can be removed below, given
-  --         proper use of reserved and reservedOp now
-  = do pos  <- getPosition
-       name <- upperIdP
-       spaces
-       args <- sepBy aliasIdP blanks
-       whiteSpace >> reservedOp "=" >> whiteSpace
-       body <- bodyP
-       posE <- getPosition
-       let (tArgs, vArgs) = partition (isSmall . headSym) args
-       return $ Loc pos posE (RTA name (f <$> tArgs) vArgs body)
-
-aliasIdP :: Parser Symbol
-aliasIdP = condIdP (letter <|> char '_') alphaNums (isAlpha . head)
-           where
-             alphaNums = S.fromList $ ['A' .. 'Z'] ++ ['a'..'z'] ++ ['0'..'9']
-
-hmeasureP :: Parser BPspec
-hmeasureP = do
-  b <- locParserP binderP
-  spaces
-  ((do dcolon
-       ty <- locParserP genBareTypeP
-       whiteSpace
-       eqns <- grabs $ measureDefP (rawBodyP <|> tyBodyP ty)
-       return (Meas $ Measure.mkM b ty eqns MsMeasure mempty))
-    <|> (return (HMeas b))
-    )
-
-measureP :: Parser (Measure (Located BareType) LocSymbol)
-measureP = do 
-  (x, ty) <- tyBindP
-  whiteSpace
-  eqns    <- grabs $ measureDefP (rawBodyP <|> tyBodyP ty)
-  return   $ Measure.mkM x ty eqns MsMeasure mempty
-
--- | class measure
-cMeasureP :: Parser (Measure (Located BareType) ())
-cMeasureP
-  = do (x, ty) <- tyBindP
-       return $ Measure.mkM x ty [] MsClass mempty 
-
-iMeasureP :: Parser (Measure (Located BareType) LocSymbol)
-iMeasureP = measureP
-
-
-oneClassArg :: Parser [Located BareType]
-oneClassArg
-  = sing <$> locParserP (rit <$> classBTyConP <*> (map val <$> classParams))
-  where
-    rit t as    = RApp t ((`RVar` mempty) <$> as) [] mempty
-    classParams =  (reserved "where" >> return [])
-               <|> ((:) <$> (fmap bTyVar <$> locLowerIdP) <*> classParams)
-    sing x      = [x]
-
-instanceLawP :: Parser (RILaws (Located BareType))
-instanceLawP
-  = do l1   <- getPosition
-       sups <- supersP
-       c    <- classBTyConP
-       spaces
-       tvs  <- manyTill (locParserP bareTypeP) (try $ reserved "where")
-       spaces
-       ms   <- grabs eqBinderP
-       spaces
-       l2   <- getPosition
-       return $ RIL c sups tvs ms (Loc l1 l2 ())
-  where
-    superP   = locParserP (toRCls <$> bareAtomBindP)
-    supersP  = try (((parens (superP `sepBy1` comma)) <|> fmap pure superP)
-                       <* reservedOp "=>")
-               <|> return []
-    toRCls x = x
-
-    eqBinderP = xyP xP (spaces >> string "=" <* spaces) (xP <* spaces)
-      
-    xP = locParserP binderP
-    
-
-instanceP :: Parser (RInstance (Located BareType))
-instanceP
-  = do _    <- supersP
-       c    <- classBTyConP
-       spaces
-       tvs  <- (try oneClassArg) <|> (manyTill iargsP (try $ reserved "where"))
-       ms   <- sepBy riMethodSigP semi
-       spaces
-       return $ RI c tvs ms
-  where
-    superP   = locParserP (toRCls <$> bareAtomBindP)
-    supersP  = try (((parens (superP `sepBy1` comma)) <|> fmap pure superP)
-                       <* reservedOp "=>")
-               <|> return []
-    toRCls x = x
-
-    iargsP   =   (mkVar . bTyVar <$> tyVarIdP)
-            <|> (parens $ locParserP $ bareTypeP)
-
-
-    mkVar v  = dummyLoc $ RVar v mempty
-
-
-riMethodSigP :: Parser (LocSymbol, RISig (Located BareType))
-riMethodSigP
-  = try (do reserved "assume"
-            (x, t) <- tyBindP
-            return (x, RIAssumed t) )
- <|> do (x, t) <- tyBindP
-        return (x, RISig t)
- <?> "riMethodSigP"
-
-classP :: Parser (RClass (Located BareType))
-classP
-  = do sups <- supersP
-       c    <- classBTyConP
-       spaces
-       tvs  <- manyTill (bTyVar <$> tyVarIdP) (try $ reserved "where")
-       ms   <- try (grabs tyBindP) -- <|> sepBy tyBindP semi
-       spaces
-       return $ RClass c sups tvs ms
-  where
-    superP   = locParserP (toRCls <$> bareAtomBindP)
-    supersP  = try (((parens (superP `sepBy1` comma)) <|> fmap pure superP)
-                       <* reservedOp "=>")
-               <|> return []
-    toRCls x = x
-
-rawBodyP :: Parser Body
-rawBodyP
-  = braces $ do
-      v <- symbolP
-      reservedOp "|"
-      p <- predP <* spaces
-      return $ R v p
-
-tyBodyP :: Located BareType -> Parser Body
-tyBodyP ty
-  = case outTy (val ty) of
-      Just bt | isPropBareType bt
-                -> P <$> predP
-      _         -> E <$> exprP
-    where outTy (RAllT _ t _)  = outTy t
-          outTy (RAllP _ t)    = outTy t
-          outTy (RImpF _ _ t _)= Just t
-          outTy (RFun _ _ t _) = Just t
-          outTy _              = Nothing
-
-locUpperIdP' :: Parser (Located Symbol)
-locUpperIdP' = locParserP upperIdP'
-
-upperIdP' :: Parser Symbol
-upperIdP' = try (symbol <$> condIdP' (isUpper . head))
-        <|> (symbol <$> infixCondIdP')
-
--- TODO:AZ this looks dodgy, rather use reserved, reservedOp
-condIdP'  :: (String -> Bool) -> Parser Symbol
-condIdP' f
-  = do c  <- letter
-       let isAlphaNumOr' c = isAlphaNum c || ('\''== c)
-       cs <- many (satisfy isAlphaNumOr')
-       blanks
-       if f (c:cs) then return (symbol $ T.pack $ c:cs) else parserZero
-
-infixCondIdP' :: Parser Symbol
-infixCondIdP'
-  = do sym <- parens $ do
-         c1 <- colon
-         -- This is the same thing as 'startsVarSymASCII' from ghc-boot-th,
-         -- but LH can't use that at the moment since it requires GHC 7.10.
-         let isASCIISymbol = (`elem` ("!#$%&*+./<=>?@\\^|~-" :: String))
-         ss <- many (satisfy isASCIISymbol)
-         c2 <- colon
-         return $ symbol $ T.pack $ c1 ++ ss ++ c2
-       blanks
-       return sym
-
--- | LHS of the thing being defined
-binderP :: Parser Symbol
-binderP    = pwr    <$> parens (idP bad)
-         <|> symbol <$> idP badc
-  where
-    idP p  = many1 (satisfy (not . p))
-    badc c = (c == ':') || (c == ',') || bad c
-    bad c  = isSpace c || c `elem` ("(,)[]" :: String)
-    pwr s  = symbol $ "(" `mappend` s `mappend` ")"
-
-
-grabs :: ParsecT s u m a -> ParsecT s u m [a]
-grabs p = try (liftM2 (:) p (grabs p))
-       <|> return []
-
-measureDefP :: Parser Body -> Parser (Def (Located BareType) LocSymbol)
-measureDefP bodyP
-  = do mname   <- locParserP symbolP
-       (c, xs) <- measurePatP
-       whiteSpace >> reservedOp "=" >> whiteSpace
-       body    <- bodyP
-       whiteSpace
-       let xs'  = (symbol . val) <$> xs
-       return   $ Def mname (symbol <$> c) Nothing ((, Nothing) <$> xs') body
-
-measurePatP :: Parser (LocSymbol, [LocSymbol])
-measurePatP
-  =  parens (try conPatP <|> try consPatP <|> nilPatP <|> tupPatP)
- <|> nullaryConPatP
- <?> "measurePatP"
-
-tupPatP :: Parser (Located Symbol, [Located Symbol])
-tupPatP  = mkTupPat  <$> sepBy1 locLowerIdP comma
-
-conPatP :: Parser (Located Symbol, [Located Symbol])
-conPatP  = (,)       <$> locParserP dataConNameP <*> sepBy locLowerIdP whiteSpace
-
-consPatP :: IsString a
-         => Parser (Located a, [Located Symbol])
-consPatP = mkConsPat <$> locLowerIdP  <*> colon <*> locLowerIdP
-
-nilPatP :: IsString a
-        => Parser (Located a, [t])
-nilPatP  = mkNilPat  <$> brackets whiteSpace
-
-nullaryConPatP :: Parser (Located Symbol, [t])
-nullaryConPatP = nilPatP <|> ((,[]) <$> locParserP dataConNameP)
-                 <?> "nullaryConPatP"
-
-mkTupPat :: Foldable t => t a -> (Located Symbol, t a)
-mkTupPat zs     = (tupDataCon (length zs), zs)
-
-mkNilPat :: IsString a => t -> (Located a, [t1])
-mkNilPat _      = (dummyLoc "[]", []    )
-
-mkConsPat :: IsString a => t1 -> t -> t1 -> (Located a, [t1])
-mkConsPat x _ y = (dummyLoc ":" , [x, y])
-
-tupDataCon :: Int -> Located Symbol
-tupDataCon n    = dummyLoc $ symbol $ "(" <> replicate (n - 1) ',' <> ")"
-
-
--------------------------------------------------------------------------------
---------------------------------- Predicates ----------------------------------
--------------------------------------------------------------------------------
-
-dataConFieldsP :: Parser [(Symbol, BareType)]
-dataConFieldsP
-   =  braces (sepBy predTypeDDP comma)
-  <|> sepBy dataConFieldP spaces
-  <?> "dataConFieldP"
-
-dataConFieldP :: Parser (Symbol, BareType)
-dataConFieldP
-   =  parens (try predTypeDDP <|> dbTypeP)
-  <|> dbTypeP
-  <?> "dataConFieldP"
-  where
-    dbTypeP = (,) <$> dummyBindP <*> bareTypeP
-
-predTypeDDP :: Parser (Symbol, BareType)
-predTypeDDP = (,) <$> bbindP <*> bareTypeP
-
-bbindP   :: Parser Symbol
-bbindP   = lowerIdP <* dcolon
-
-dataConP :: [Symbol] -> Parser DataCtor
-dataConP as = do
-  x   <- locParserP dataConNameP
-  spaces
-  xts <- dataConFieldsP
-  return $ DataCtor x as [] xts Nothing
-
-adtDataConP :: [Symbol] -> Parser DataCtor
-adtDataConP as = do
-  x     <- locParserP dataConNameP
-  dcolon
-  tr    <- toRTypeRep <$> bareTypeP
-  return $ DataCtor x (tRepVars as tr) [] (tRepFields tr) (Just $ ty_res tr)
-
-tRepVars :: Symbolic a => [Symbol] -> RTypeRep c a r -> [Symbol]
-tRepVars as tr = case fst <$> ty_vars tr of 
-  [] -> as 
-  vs -> symbol . ty_var_value <$> vs 
-
-tRepFields :: RTypeRep c tv r -> [(Symbol, RType c tv r)]
-tRepFields tr = zip (ty_binds tr) (ty_args tr)
-
-dataConNameP :: Parser Symbol
-dataConNameP
-  =  try upperIdP
- <|> pwr <$> parens (idP bad)
- <?> "dataConNameP"
-  where
-     idP p  = many1 (satisfy (not . p))
-     bad c  = isSpace c || c `elem` ("(,)" :: String)
-     pwr s  = symbol $ "(" <> s <> ")"
-
-dataSizeP :: Parser (Maybe SizeFun)
-dataSizeP
-  = brackets (Just . SymSizeFun <$> locLowerIdP)
-  <|> return Nothing
-
-dataDeclP :: Parser DataDecl
-dataDeclP = do
-  pos <- getPosition
-  x   <- locUpperIdP'
-  spaces
-  fsize <- dataSizeP
-  (dataDeclBodyP pos x fsize <|> return (emptyDecl x pos fsize))
-
-emptyDecl :: LocSymbol -> SourcePos -> Maybe SizeFun -> DataDecl
-emptyDecl x pos fsize@(Just _)
-  = DataDecl (DnName x) [] [] [] pos fsize Nothing DataUser
-emptyDecl x pos _
-  = uError (ErrBadData (sourcePosSrcSpan pos) (pprint (val x)) msg)
-  where
-    msg = "You should specify either a default [size] or one or more fields in the data declaration"
-
-dataDeclBodyP :: SourcePos -> LocSymbol -> Maybe SizeFun -> Parser DataDecl
-dataDeclBodyP pos x fsize = do
-  vanilla    <- null <$> sepBy locUpperIdP blanks
-  as         <- sepBy noWhere blanks
-  ps         <- predVarDefsP
-  (pTy, dcs) <- dataCtorsP as
-  let dn      = dataDeclName pos x vanilla dcs
-  whiteSpace
-  return      $ DataDecl dn as ps dcs pos fsize pTy DataUser
-
-dataDeclName :: SourcePos -> LocSymbol -> Bool -> [DataCtor] -> DataName
-dataDeclName _ x True  _     = DnName x               -- vanilla data    declaration
-dataDeclName _ _ False (d:_) = DnCon  (dcName d)      -- family instance declaration
-dataDeclName p x _  _        = uError (ErrBadData (sourcePosSrcSpan p) (pprint (val x)) msg)
-  where
-    msg                  = "You should specify at least one data constructor for a family instance"
-
-dataCtorsP :: [Symbol] -> Parser (Maybe BareType, [DataCtor])
-dataCtorsP as = do
-  (pTy, dcs) <-     (reservedOp "="     >> ((Nothing, ) <$>                 sepBy (dataConP    as) (reservedOp "|")))
-                <|> (reserved   "where" >> ((Nothing, ) <$>                 sepBy (adtDataConP as) (reservedOp "|")))
-                <|> (                      ((,)         <$> dataPropTyP <*> sepBy (adtDataConP as) (reservedOp "|")))
-  return (pTy, Misc.sortOn (val . dcName) dcs)
-
-noWhere :: Parser Symbol
-noWhere = 
-  try $ do
-  s <- tyVarIdP
-  if s == "where"
-    then parserZero
-    else return s
-
-dataPropTyP :: Parser (Maybe BareType)
-dataPropTyP = Just <$> between dcolon (reserved "where") bareTypeP
-
----------------------------------------------------------------------
--- | Parsing Qualifiers ---------------------------------------------
----------------------------------------------------------------------
-
-fTyConP :: Parser FTycon
-fTyConP
-  =   (reserved "int"     >> return intFTyCon)
-  <|> (reserved "Integer" >> return intFTyCon)
-  <|> (reserved "Int"     >> return intFTyCon)
-  <|> (reserved "real"    >> return realFTyCon)
-  <|> (reserved "bool"    >> return boolFTyCon)
-  <|> (symbolFTycon      <$> locUpperIdP)
-  <?> "fTyConP"
diff --git a/src/Language/Haskell/Liquid/Synthesize.hs b/src/Language/Haskell/Liquid/Synthesize.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Synthesize.hs
+++ /dev/null
@@ -1,186 +0,0 @@
-{-# LANGUAGE FlexibleInstances    #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE FlexibleContexts #-}
-
-module Language.Haskell.Liquid.Synthesize (
-    synthesize
-  ) where
-
-import           Language.Haskell.Liquid.Types
-import           Language.Haskell.Liquid.Constraint.Types
-import           Language.Haskell.Liquid.Constraint.Generate 
-import qualified Language.Haskell.Liquid.Types.RefType as R
-import           Language.Haskell.Liquid.Synthesize.Termination
-import           Language.Haskell.Liquid.Synthesize.Generate
-import           Language.Haskell.Liquid.Synthesize.GHC hiding (SSEnv)
-import           Language.Haskell.Liquid.Synthesize.Monad
-import           Language.Haskell.Liquid.Synthesize.Misc hiding (notrace)
-import           Language.Haskell.Liquid.Constraint.Fresh (trueTy)
-import qualified Language.Fixpoint.Smt.Interface as SMT
-import           Language.Fixpoint.Types hiding (SEnv, SVar, Error)
-import qualified Language.Fixpoint.Types        as F 
-import qualified Language.Fixpoint.Types.Config as F
-import           Language.Haskell.Liquid.Synthesize.Env
-
-import           CoreSyn (CoreExpr)
-import qualified CoreSyn as GHC
-import           Var 
-import           TyCon
-import           DataCon
-import           Text.PrettyPrint.HughesPJ (text, ($+$))
-import           Control.Monad.State.Lazy
-import qualified Data.HashMap.Strict as M 
-import           Data.Maybe
-import           CoreUtils (exprType)
-import           TyCoRep
-
-synthesize :: FilePath -> F.Config -> CGInfo -> IO [Error]
-synthesize tgt fcfg cginfo = 
-  mapM go (M.toList $ holesMap cginfo)
-  where 
-    measures = map (val . msName) ((gsMeasures . gsData . giSpec . ghcI) cginfo)
-    go (x, HoleInfo _ loc env (cgi,cge)) = do 
-      let topLvlBndr = fromMaybe (error "Top-level binder not found") (cgVar cge)
-          typeOfTopLvlBnd = fromMaybe (error "Type: Top-level symbol not found") (M.lookup (symbol topLvlBndr) (reGlobal env))
-          coreProgram = giCbs $ giSrc $ ghcI cgi
-          (uniVars, _) = getUniVars coreProgram topLvlBndr
-          fromREnv' = filterREnv (reLocal env)
-          fromREnv'' = M.fromList (filter (rmClassVars . toType . snd) (M.toList fromREnv'))
-          rmClassVars t = case t of { TyConApp c _ -> not . isClassTyCon $ c; _ -> True }
-          fromREnv  = M.fromList (rmMeasures measures (M.toList fromREnv''))
-          isForall t = case t of { ForAllTy{} -> True; _ -> False}
-          rEnvForalls = M.fromList (filter (isForall . toType . snd) (M.toList fromREnv))
-          fs = map (snd . snd) $ M.toList (symbolToVar coreProgram topLvlBndr rEnvForalls)
-
-          ssenv0 = symbolToVar coreProgram topLvlBndr fromREnv
-          (senv1, foralls') = initSSEnv typeOfTopLvlBnd cginfo ssenv0
-      
-      ctx <- SMT.makeContext fcfg tgt
-      state0 <- initState ctx fcfg cgi cge env topLvlBndr (reverse uniVars) M.empty
-      let foralls = foralls' ++ fs
-      fills <- synthesize' ctx cgi senv1 typeOfTopLvlBnd topLvlBndr typeOfTopLvlBnd foralls state0
-
-      return $ ErrHole loc (
-        if not (null fills)
-          then text "\n Hole Fills:" $+$ pprintMany (map (coreToHs typeOfTopLvlBnd topLvlBndr . fromAnf) fills)
-          else mempty) mempty (symbol x) typeOfTopLvlBnd 
-
-
-synthesize' :: SMT.Context -> CGInfo -> SSEnv -> SpecType ->  Var -> SpecType -> [Var] -> SState -> IO [CoreExpr]
-synthesize' ctx cgi senv tx xtop ttop foralls st2
- = evalSM (go tx) ctx senv st2
-  where 
-
-    go :: SpecType -> SM [CoreExpr]
-
-    -- Type Abstraction 
-    go (RAllT a t _x)      = GHC.Lam (tyVarVar a) <$$> go t
-          
-    go t@(RApp c _ts _ _r) = do  
-      let coreProgram = giCbs $ giSrc $ ghcI cgi
-          args  = drop 1 (argsP coreProgram xtop)
-          (_, (xs, txs, _), _) = bkArrow ttop
-      addEnv xtop $ decrType xtop ttop args (zip xs txs)
-
-      if R.isNumeric (tyConEmbed cgi) c
-          then error " [ Numeric in synthesize ] Update liquid fixpoint. "
-          else do let ts = unifyWith (toType t)
-                  if null ts  then modify (\s -> s { sUGoalTy = Nothing } )
-                              else modify (\s -> s { sUGoalTy = Just ts } )
-                  modify (\s -> s {sForalls = (foralls, [])})
-                  emem0 <- insEMem0 senv
-                  modify (\s -> s { sExprMem = emem0 })
-                  synthesizeBasic t
-
-    go (RAllP _ t) = go t
-
-    go (RRTy _env _ref _obl t) = go t
-
-    go t@RFun{} 
-         = do ys <- mapM freshVar txs
-              let su = F.mkSubst $ zip xs (EVar . symbol <$> ys) 
-              mapM_ (uncurry addEnv) (zip ys ((subst su)<$> txs)) 
-              let dt = decrType xtop ttop ys (zip xs txs)
-              addEnv xtop dt 
-              mapM_ (uncurry addEmem) (zip ys (subst su <$> txs)) 
-              addEmem xtop dt
-              senv1 <- getSEnv
-              let goalType = subst su to
-                  hsGoalTy = toType goalType 
-                  ts = unifyWith hsGoalTy
-              if null ts  then modify (\s -> s { sUGoalTy = Nothing } )
-                          else modify (\s -> s { sUGoalTy = Just ts } )
-              modify (\s -> s { sForalls = (foralls, []) } )
-              emem0 <- insEMem0 senv1
-              modify (\s -> s { sExprMem = emem0 })
-              mapM_ (\y -> addDecrTerm y []) ys
-              scruts <- synthesizeScrut ys
-              modify (\s -> s { scrutinees = scruts })
-              GHC.mkLams ys <$$> synthesizeBasic goalType
-      where (_, (xs, txs, _), to) = bkArrow t 
-
-    go t = error (" Unmatched t = " ++ show t)
-
-synthesizeBasic :: SpecType -> SM [CoreExpr]
-synthesizeBasic t = do
-  let ts = unifyWith (toType t) -- All the types that are used for instantiation.
-  if null ts  then  modify (\s -> s { sUGoalTy = Nothing } )
-              else  modify (\s -> s { sUGoalTy = Just ts } )
-  modify (\s -> s { sGoalTys = [] })
-  fixEMem t
-  es <- genTerms t
-  if null es  then synthesizeMatch t
-              else return es
-
-synthesizeMatch :: SpecType -> SM [CoreExpr]
-synthesizeMatch t = do
-  scruts <- scrutinees <$> get
-  i <- incrCase 
-  case safeIxScruts i scruts of
-    Nothing ->  return []
-    Just id ->  if null scruts
-                  then return []
-                  else withIncrDepth (matchOnExpr t (scruts !! id))
-
-synthesizeScrut :: [Var] -> SM [(CoreExpr, Type, TyCon)]
-synthesizeScrut vs = do
-  exprs <- synthesizeScrutinee vs
-  let exprs' = map (\e -> (exprType e, e)) exprs
-      isDataCon v = case varType v of { TyConApp c _ -> not . isClassTyCon $ c; _ -> False }
-      vs0 = filter isDataCon vs
-      es0 = map GHC.Var vs0 
-      es1 = map (\e -> (exprType e, e)) es0
-      es2 = [(e, t, c) | (t@(TyConApp c _), e) <- es1]
-  return (es2 ++ [(e, t, c) | (t@(TyConApp c _), e) <- exprs'])
-
-matchOnExpr :: SpecType -> (CoreExpr, Type, TyCon) -> SM [CoreExpr]
-matchOnExpr t (GHC.Var v, tx, c) 
-  = matchOn t (v, tx, c)
-matchOnExpr t (e, tx, c)
-  = do  freshV <- freshVarType tx
-        freshSpecTy <- liftCG $ trueTy tx
-        -- use consE
-        addEnv freshV freshSpecTy
-        es <- matchOn t (freshV, tx, c)
-        return $ GHC.Let (GHC.NonRec freshV e) <$> es
-
-matchOn :: SpecType -> (Var, Type, TyCon) -> SM [CoreExpr]
-matchOn t (v, tx, c) =
-  (GHC.Case (GHC.Var v) v tx <$$> sequence) <$> mapM (makeAlt t (v, tx)) (tyConDataCons c)
-
-
-makeAlt :: SpecType -> (Var, Type) -> DataCon -> SM [GHC.CoreAlt]
-makeAlt t (x, TyConApp _ ts) c = locally $ do
-  ts <- liftCG $ mapM trueTy τs
-  xs <- mapM freshVar ts    
-  newScruts <- synthesizeScrut xs
-  modify (\s -> s { scrutinees = scrutinees s ++ newScruts } )
-  addsEnv $ zip xs ts 
-  addsEmem $ zip xs ts 
-  addDecrTerm x xs
-  liftCG0 (\γ -> caseEnv γ x mempty (GHC.DataAlt c) xs Nothing)
-  es <- synthesizeBasic t
-  return $ (GHC.DataAlt c, xs, ) <$> es
-  where 
-    (_, _, τs) = dataConInstSig c ts
-makeAlt _ _ _ = error "makeAlt.bad argument "
diff --git a/src/Language/Haskell/Liquid/Synthesize/Check.hs b/src/Language/Haskell/Liquid/Synthesize/Check.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Synthesize/Check.hs
+++ /dev/null
@@ -1,99 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-{-# LANGUAGE BangPatterns #-}
-module Language.Haskell.Liquid.Synthesize.Check (check, hasType, isWellTyped, checkError) where
-
-
-import           Language.Fixpoint.Types.Constraints
-import qualified Language.Fixpoint.Types.Config
-                                               as F
-import qualified Language.Fixpoint.Types       as F
-import           Language.Fixpoint.Solver
-import           Language.Haskell.Liquid.Types.Types
-import           Language.Haskell.Liquid.Types.Specs
-import           Language.Haskell.Liquid.Constraint.Env
-import           Language.Haskell.Liquid.Constraint.Generate
-import           Language.Haskell.Liquid.Constraint.Types
-import           Language.Haskell.Liquid.Constraint.Fresh
-                                                ( trueTy )
-import           Language.Haskell.Liquid.Constraint.ToFixpoint
-import           Language.Haskell.Liquid.Synthesize.Monad
-import           Language.Haskell.Liquid.Synthesize.GHC
-import           Language.Haskell.Liquid.Misc   ( mapThd3 )
-import           CoreSyn
-import           Var
-import           Control.Monad.State.Lazy
-import           System.Console.CmdArgs.Verbosity
-import           CoreUtils
-import           Language.Haskell.Liquid.GHC.TypeRep
-import           Language.Haskell.Liquid.Types
-import           MkCore
-import           DynFlags
-
-hasType :: SpecType -> CoreExpr -> SM Bool
-hasType t !e' = notrace (" [ Check ] " ++ show e') $ do 
-  x  <- freshVar t 
-  st <- get 
-  let tpOfE = exprType e'
-      ht    = toType t
-  if tpOfE == ht
-    then liftIO $ quietly $ check (sCGI st) (sCGEnv st) (sFCfg st) x e (Just t) 
-    else error $ " [ hasType ] Expression = " ++ show e' ++ " with type " ++ showTy tpOfE ++ " , specType = " ++ show t
- where e = tx e' 
-
--- Returns true if the expression is well-typed.
-isWellTyped :: CoreExpr -> SM Bool
-isWellTyped e =  do 
-  t <- liftCG $ trueTy $ exprType e 
-  hasType t e 
-
-
-tx :: CoreExpr -> CoreExpr
-tx (Case e b t alts) = Case e b t (mapThd3 tx <$> alts)
-tx e@(Let _ _) = let (bs,e') = unbind e in foldr Let e' bs 
-tx e = e 
-
-unbind :: CoreExpr -> ([CoreBind], CoreExpr)
-unbind (Let (NonRec x ex) e) = let (bs,e') = unbind ex in (bs ++ [NonRec x e'],e)
-unbind e = ([], e)
-
-
-check :: CGInfo -> CGEnv -> F.Config -> Var -> CoreExpr -> Maybe SpecType -> IO Bool 
-check cgi γ cfg x e t = do
-    finfo <- cgInfoFInfo info' cs
-    isSafe <$> solve cfg{F.srcFile = "SCheck" <> F.srcFile cfg} finfo 
-  where 
-    cs = generateConstraintsWithEnv info' (cgi{hsCs = []}) (γ{grtys = insertREnv' (F.symbol x) t (grtys γ)}) 
-    info' = info {giSrc = giSrc', giSpec = giSpec'}
-    giSrc' = (giSrc info) {giCbs = [Rec [(x, e)]]}
-    giSpec' = giSpecOld{gsSig = gsSig'}
-    giSpecOld = giSpec info 
-    gsSigOld  = gsSig giSpecOld
-    gsSig' = gsSigOld {gsTySigs = addTySig x t (gsTySigs gsSigOld)}
-    info = ghcI cgi 
-
-    insertREnv' _ Nothing g = g 
-    insertREnv' x (Just t) g = insertREnv x t g
-    
-    addTySig _ Nothing  ts = ts 
-    addTySig x (Just t) ts = (x,dummyLoc t):ts
-    
-checkError :: SpecType -> SM (Maybe CoreExpr)
-checkError t = do 
-  errVar <- varError
-  let errorExpr = App (App (Var errVar) (Type (toType t))) errorInt
-      errorInt  = mkIntExprInt unsafeGlobalDynFlags 42
-  b <- hasType t errorExpr
-  if b 
-    then return $ Just errorExpr
-    else return Nothing
-
-quietly :: IO a -> IO a
-quietly act = do
-  vb <- getVerbosity
-  setVerbosity Quiet
-  r  <- act
-  setVerbosity vb
-  return r
-
-
diff --git a/src/Language/Haskell/Liquid/Synthesize/Env.hs b/src/Language/Haskell/Liquid/Synthesize/Env.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Synthesize/Env.hs
+++ /dev/null
@@ -1,47 +0,0 @@
-module Language.Haskell.Liquid.Synthesize.Env where 
-
-import           Language.Fixpoint.Types
-import           Language.Haskell.Liquid.Constraint.Types
-import           Language.Haskell.Liquid.Types
-import           Language.Haskell.Liquid.Synthesize.Monad
-import qualified Data.HashMap.Strict           as M
-import qualified Data.HashSet                  as S
-import           DataCon
-import           TyCon
-import           Var
-import           Data.List 
-
-initSSEnv :: SpecType -> CGInfo -> SSEnv -> (SSEnv, [Var])
-initSSEnv rt info senv = (M.union senv (M.fromList foralls), vs)
-  where foralls = filter iNeedIt (mkElem <$> prims)
-        vs = map (snd . snd) foralls
-        dataCons = typeToCons rt 
-        mkElem (v, lt) = (symbol v, (val lt, v))
-        prims = gsCtors $ gsData $ giSpec $ ghcI info
-        iNeedIt (_, (_, v)) = v `elem` (dataConWorkId <$> dataCons)
-
--- | For algebraic datatypes: Find (in the refinement type) 
---   all the datatypes that are used and 
---   get their constructors.
-tpToCons :: SpecType -> [DataCon] 
-tpToCons (RAllT _a t _x)  
-  = tpToCons t 
-tpToCons (RApp c args _ _r) 
-  = tyConDataCons (rtc_tc c) ++ concatMap tpToCons args
-tpToCons (RFun _sym rt0 rt1 _reft)
-  = tpToCons rt0 ++ tpToCons rt1
-tpToCons RVar{} 
-  = []
-tpToCons (RAllP _ t)
-  = tpToCons t
-tpToCons (RRTy _ _ _ t)
-  = tpToCons t
-tpToCons _ 
-  = []
-
-typeToCons :: SpecType -> [DataCon]
-typeToCons rt = S.toList $ S.fromList (tpToCons rt)
-
-rmMeasures :: [Symbol] -> [(Symbol, SpecType)] -> [(Symbol, SpecType)]
-rmMeasures meas = filter (\(s,_) -> case find (== s) meas of  Nothing -> True
-                                                              Just _  -> False)
diff --git a/src/Language/Haskell/Liquid/Synthesize/GHC.hs b/src/Language/Haskell/Liquid/Synthesize/GHC.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Synthesize/GHC.hs
+++ /dev/null
@@ -1,433 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-{-# LANGUAGE LambdaCase #-}
-{-# LANGUAGE CPP #-}
-module Language.Haskell.Liquid.Synthesize.GHC where
-
-import qualified CoreSyn                       as GHC
-import qualified Language.Fixpoint.Types       as F
-import           Language.Haskell.Liquid.Types
-import           Var
-import           TyCoRep
-import           CoreSyn
-import           IdInfo
-import           OccName
-import           Unique
-import           Name
-import           TysPrim
-import           Data.Default
-import           Data.Maybe                     ( fromMaybe )
-import           Language.Haskell.Liquid.GHC.TypeRep
-import           Language.Fixpoint.Types
-import qualified Data.HashMap.Strict           as M
-import           TyCon
-import           TysWiredIn
-
-import           Data.List
-import           Data.List.Split
-
-instance Default Type where
-    def = TyVarTy alphaTyVar 
-
-mkVar :: Maybe String -> Int -> Type -> Var
-mkVar x i t = mkGlobalVar VanillaId name t vanillaIdInfo 
-  where 
-    name = mkSystemName (mkUnique 'S' i) (mkVarOcc x')
-    x'   = fromMaybe (freshName i) x 
-
-freshName :: Int -> String 
-freshName i = "lSyn$" ++ show i 
-
--- | Assuming that the functions are instantiated when this function is called.
-goalType ::  Type ->   --  This is the goal type. It is used for basic types.
-              Type ->  --   This type comes from the environment.
-              Bool     --   True if the 2nd arg produces expression 
-                       --   of type equal to 1st argument.
-#if __GLASGOW_HASKELL__ >= 810
-goalType τ (FunTy _ _ t'') 
-  | t'' == τ  = True
-  | otherwise = goalType τ t''
-#else
-goalType τ (FunTy _ t'') 
-  | t'' == τ  = True
-  | otherwise = goalType τ t''
-#endif
-goalType τ                 t 
-  | τ == t    = True
-  | otherwise = False
-
--- Subgoals are function's arguments.
-createSubgoals :: Type -> [Type] 
-createSubgoals (ForAllTy _ htype) = createSubgoals htype
-#if __GLASGOW_HASKELL__ >= 810
-createSubgoals (FunTy _ t1 t2)      = t1 : createSubgoals t2
-#else
-createSubgoals (FunTy t1 t2)      = t1 : createSubgoals t2
-#endif
-createSubgoals t                  = [t]
-
-subgoals :: Type ->               -- Given a function type,
-            Maybe (Type, [Type])  -- separate the result type from the input types.
-subgoals t = if null gTys then Nothing else Just (resTy, inpTys) 
-  where gTys            = createSubgoals t 
-        (resTy, inpTys) = (last gTys, take (length gTys - 1) gTys)
-
-
--- @withSubgoal@ :: Takes a subgoal type, and 
--- returns all expressions in @ExprMemory@ that have the same type.
-withSubgoal :: [(Type, CoreExpr, Int)] -> Type -> [(CoreExpr, Int)]
-withSubgoal []                  _ = []
-withSubgoal ((t, e, i) : exprs) τ = 
-  if τ == t 
-    then (e, i) : withSubgoal exprs τ
-    else withSubgoal exprs τ
-
--- | Assuming that goals are type variables or constructors.
---    Note: We maintain ordering from the goal type.
---    Not handled (compared to @varsInType): function types, type applications
-unifyWith :: Type -> [Type] 
-unifyWith v@(TyVarTy _)   = [v] 
-unifyWith (TyConApp _ ts) = ts 
-unifyWith t               = error $ " [ unifyWith ] " ++ showTy t 
-
-fromAnf :: CoreExpr -> CoreExpr
-fromAnf e = fst $ fromAnf' e []
-
--- | Replace let bindings in applications.
---   > If you find a binding add it to the second argument.
---                    | (lhs, rhs)      |
-fromAnf' :: CoreExpr -> [(Var, CoreExpr)] -> (CoreExpr, [(Var, CoreExpr)])
-fromAnf' (Lam b e) bnds
-  = let (e', bnds') = fromAnf' e bnds
-    in  (Lam b e', bnds')
-fromAnf' (Let bnd e) bnds
-  = case bnd of Rec {}       -> error " By construction, no recursive bindings in let expression. "
-                NonRec rb lb -> let (lb', bnds') = fromAnf' lb bnds
-                                in  fromAnf' e ((rb, lb') : bnds')
-fromAnf' (Var var) bnds 
-  = (fromMaybe (Var var) (lookup var bnds), bnds)
-fromAnf' (Case scr bnd tp alts) bnds
-  = (Case scr bnd tp (map (\(altc, xs, e) -> (altc, xs, fst $ fromAnf' e bnds)) alts), bnds)
-fromAnf' (App e1 e2) bnds
-  = let (e1', bnds')  = fromAnf' e1 bnds 
-        (e2', bnds'') = fromAnf' e2 bnds'
-    in  (App e1' e2', bnds'')
-fromAnf' t@Type{} bnds 
-  = (t, bnds)
-fromAnf' l@Lit{} bnds 
-  = (l, bnds)
-fromAnf' _ _
-  = error " Should not reach this point. "
-
--- | Function used for pretty printing core as Haskell source.
---   Input does not contain let bindings.
-coreToHs :: SpecType -> Var -> CoreExpr -> String
-coreToHs t v e = pprintSymbols (discardModName v ++ pprintFormals caseIndent v e (tracepp " cnt " cnt) [])
-  where cnt = countTcConstraints t
-
-symbols :: String
-symbols = [':']
-
-pprintSymbols :: String -> String
-pprintSymbols txt = foldr (\x xs -> pprintSym symbols x ++ xs) [] txt
-
-pprintSym :: String -> Char -> String
-pprintSym symbols s 
-  = case find (== s) symbols of 
-      Nothing -> [s]
-      Just s' -> ['(', s', ')']
-
-discardModName :: Var -> String
-discardModName v = last (splitOn "." (show v))
-
-rmModName :: String -> String
-rmModName s = 
-  let ts = splitOn "." s
-  in  maintainLParen ts ++ last ts ++ maintainRParen ts
-
-maintainLParen :: [String] -> String
-maintainLParen ts 
-  = if length ts > 1 && head (head ts) == '('
-      then  "("
-      else  ""
-
-maintainRParen :: [String] -> String
-maintainRParen ts 
-  = if last (last ts) == '('
-      then  ")"
-      else  ""
-
-pprintFormals :: Int -> Var -> CoreExpr -> Int -> [Var] -> String
-pprintFormals i v (Lam b e) cnt vs
-  = if isTyVar b
-      then pprintFormals i v e cnt vs
-      else  if cnt > 0 
-              then  pprintFormals i v e (cnt - 1) (b:vs)
-              else  " " ++ show b ++ pprintFormals i v e cnt vs
-pprintFormals i _ e _ vs
-  = " =" ++ pprintBody vs i e
-
-caseIndent :: Int 
-caseIndent = 4
-
-indent :: Int -> String
-indent i = replicate i ' '
-
-errorExprPp :: CoreExpr -> Bool
-errorExprPp (GHC.App (GHC.App err@(GHC.Var _) (GHC.Type _)) _)
-  = show err == "Language.Haskell.Liquid.Synthesize.Error.err"
-errorExprPp _ 
-  = False
-
-pprintVar :: Var -> String 
-pprintVar v = if isTyVar v then "" else " " ++ discardModName v
-
-pprintBody :: [Var] -> Int -> CoreExpr -> String
-pprintBody vs i (Lam b e) 
-  = pprintFormals i b e 0 vs
-pprintBody vs _ (Var v)
-  = case find (== v) vs of 
-      Nothing -> pprintVar v
-      Just _  -> ""
-pprintBody vs _ e@App{}
-  = let pprintApp = fixApplication (show e)
-        noTcVars  = filter (\x -> case find (== x) (map show vs) of 
-                                    Nothing -> True
-                                    Just _  -> False) (words pprintApp)
-    in  if errorExprPp e
-          then " error \" Dead code! \" "
-          else " " ++ unwords noTcVars
-pprintBody _ _ l@Lit{}
-  = " " ++ show l
-pprintBody vs i (Case scr _ _ alts)
-  = "\n" ++ indent i ++ 
-    "case" ++ pprintBody vs i scr ++ " of\n" ++ 
-    concatMap (pprintAlts vs (i + caseIndent)) alts 
-pprintBody _ _ Type{} 
-  = ""
-pprintBody _ _ e
-  = error (" Not yet implemented for e = " ++ show e)
-
-fixApplication :: String -> String
-fixApplication e = 
-  let ws' = words (replaceNewLine e)
-      ws = handleCommas ws'
-      cleanWs = rmTypeAppl ws
-  in  unwords (fixCommas $ fixParen (map rmModName cleanWs))
-
-handleCommas :: [String] -> [String]
-handleCommas [] = []
-handleCommas (c:cs)
-  = if last c == ','
-      then init c : "," : handleCommas cs
-      else c : handleCommas cs
-
-fixCommas :: [String] -> [String]
-fixCommas [] = []
-fixCommas [x] = [x]
-fixCommas (x:y:xs)
-  = if y == ","
-      then (x++y) : fixCommas xs
-      else x : fixCommas (y:xs)
-
-fixParen :: [String] -> [String]
-fixParen [] = []
-fixParen [x] = [x]
-fixParen (x:y:xs) 
-  = if replicate (length y) ')' == y
-      then  let w0 = x ++ y 
-                w = if head w0 == '(' && last w0 == ')' 
-                      then tail (init w0) 
-                      else w0
-            in  w : fixParen xs
-      else x : fixParen (y:xs)
-
-rmTypeAppl :: [String] -> [String]
-rmTypeAppl [] 
-  = []
-rmTypeAppl (c:cs) 
-  = if c == "@"
-      then  case cs of 
-              [] -> error " Type application: Badly formatted string. "
-              (c': cs') -> 
-                let p = paren c'
-                in  if null p then rmTypeAppl cs' else p : rmTypeAppl cs'
-      else c:rmTypeAppl cs
-
-paren :: String -> String 
-paren [] 
-  = []
-paren (c:cs) 
-  = if c == ')' then c : paren cs else paren cs
-
-replaceNewLine :: String -> String
-replaceNewLine [] 
-  = []
-replaceNewLine (c:cs) 
-  = if c == '\n' 
-      then ' ' : replaceNewLine cs 
-      else c : replaceNewLine cs
-
-pprintAlts :: [Var] -> Int -> Alt Var -> String
-pprintAlts vars i (DataAlt dataCon, vs, e)
-  = indent i ++ show dataCon ++ concatMap (\v -> " " ++ show v) vs ++ " ->" ++ 
-    pprintBody vars (i+caseIndent) e ++ "\n"
-pprintAlts _ _ _
-  = error " Pretty printing for pattern match on datatypes. "
-
--- TODO Remove variables generated for type class constraints
-countTcConstraints :: SpecType -> Int
-countTcConstraints t = 
-  let ws = words (show t)
-
-      countCommas :: [String] -> Int
-      countCommas []     = 0
-      countCommas (x:xs) = 
-        case find (== ',') x of
-          Nothing -> countCommas xs
-          Just _  -> 1 + countCommas xs
-
-  in  case find (== "=>") ws of
-        Nothing -> 0
-        Just _  -> 1 + countCommas (takeWhile (/= "=>") ws)
-  
-
-
------------------------------------------------------------------------------------
---  |                          Prune trivial expressions                       | --
------------------------------------------------------------------------------------
-nonTrivial :: GHC.CoreExpr -> Bool
-nonTrivial (GHC.App _ (GHC.Type _)) = False
-nonTrivial _                        = True
-
-nonTrivials :: [GHC.CoreExpr] -> Bool
-nonTrivials = foldr (\x b -> nonTrivial x || b) False 
-
-trivial :: GHC.CoreExpr -> Bool
-trivial (GHC.App (GHC.Var _) (GHC.Type _)) = True -- Is this a nullary constructor?
-trivial _ = False
-
-hasTrivial :: [GHC.CoreExpr] -> Bool
-hasTrivial es = foldr (\x b -> trivial x || b) False es
-
-allTrivial :: [[GHC.CoreExpr]] -> Bool
-allTrivial es = foldr (\x b -> hasTrivial x && b) True es 
-
-rmTrivials :: [(GHC.CoreExpr, Int)] -> [(GHC.CoreExpr, Int)]
-rmTrivials = filter (not . trivial . fst)
-
-----------------------------------------------------------------------------------
---  |                        Scrutinee filtering                              | --
-----------------------------------------------------------------------------------
-
-isVar :: GHC.CoreExpr -> Bool
-isVar (GHC.Var _) = True
-isVar _           = False
-
-returnsTuple :: Var -> Bool
-returnsTuple v = 
-  case subgoals (varType v) of
-    Nothing      -> False
-    Just (t, _) -> 
-      case t of
-        TyConApp c _ts -> c == pairTyCon
-        _              -> False
-
-------------------------------------------------------------------------------------------------
--------------------------------------- Handle REnv ---------------------------------------------
-------------------------------------------------------------------------------------------------
--- Duplicate from Monad due to dependencies between modules.
-type SSEnv = M.HashMap Symbol (SpecType, Var)
-
-filterREnv :: M.HashMap Symbol SpecType -> M.HashMap Symbol SpecType
-filterREnv renv = 
-  let renv_lst  = M.toList renv
-      renv_lst' = filter (\(_, specT) ->  let ht = toType specT
-                                          in  showTy ht /= "(RApp   GHC.Prim.Addr# )") renv_lst
-  in  M.fromList renv_lst'
-
-getTopLvlBndrs :: GHC.CoreProgram -> [Var]
-getTopLvlBndrs = concatMap (\case GHC.NonRec b _ -> [b]
-                                  GHC.Rec recs   -> map fst recs)
-
--- | That' s a hack to get the type variables we need for instantiation.
-getUniVars :: GHC.CoreProgram -> Var -> ([Var], [Var])
-getUniVars cp tlVar = 
-  case filter (`isInCB` tlVar) cp of 
-    [cb] -> getUniVars0 (getBody cb tlVar) ([], [])
-    _    -> error " Every top-level corebind must be unique! "
-
-getUniVars0 :: GHC.CoreExpr -> ([Var], [Var]) -> ([Var], [Var])
-getUniVars0 (Lam b e) (uvs, tcDicts)
-  = case varType b of 
-      TyConApp c _ -> 
-        if isClassTyCon c 
-          then getUniVars0 e (uvs, b : tcDicts)
-          else getUniVars0 e (b:uvs, tcDicts)
-      _ -> getUniVars0 e (b:uvs, tcDicts) 
-getUniVars0 _ vs
-  = vs
-
-getBody :: GHC.CoreBind -> Var -> GHC.CoreExpr
-getBody (GHC.NonRec b e) tlVar = if b == tlVar then e else error " [ getBody ] "
-getBody (GHC.Rec _)   _ = error "Assuming our top-level binder is non-recursive (only contains a hole)"
-
---                       | Current top-level binder |
-varsP :: GHC.CoreProgram -> Var -> (GHC.CoreExpr -> [Var]) -> [Var]
-varsP cp tlVar f = 
-  case filter (\cb -> isInCB cb tlVar) cp of
-    [cb] -> varsCB cb f
-    _    -> error " Every top-level corebind must be unique! "
-
-isInCB :: GHC.CoreBind -> Var -> Bool
-isInCB (GHC.NonRec b _) tlVar = b == tlVar 
-isInCB (GHC.Rec recs) tlVar   = foldr ((\v b -> v == tlVar && b) . fst) True recs
-
-varsCB :: GHC.CoreBind -> (GHC.CoreExpr -> [Var]) -> [Var]
-varsCB (GHC.NonRec _ e) f = f e
-varsCB (GHC.Rec _) _ = notrace " [ symbolToVarCB ] Rec " []
-
-varsE :: GHC.CoreExpr -> [Var]
-varsE (GHC.Lam a e) = a : varsE e
-varsE (GHC.Let (GHC.NonRec b _) e) = b : varsE e
-varsE (GHC.Case _ b _ alts) = foldr (\(_, vars, e) res -> vars ++ varsE e ++ res) [b] alts
-varsE (GHC.Tick _ e) = varsE e
-varsE _ = []
-
-caseVarsE :: GHC.CoreExpr -> [Var] 
-caseVarsE (GHC.Lam _ e) = caseVarsE e 
-caseVarsE (GHC.Let (GHC.NonRec _ _) e) = caseVarsE e
-caseVarsE (GHC.Case _ b _ alts) = foldr (\(_, _, e) res -> caseVarsE e ++ res) [b] alts 
-caseVarsE (GHC.Tick _ e) = caseVarsE e 
-caseVarsE _ = [] 
-
-instance Default Var where
-  def = alphaTyVar
-
-symbolToVar :: GHC.CoreProgram -> Var -> M.HashMap Symbol SpecType -> SSEnv
-symbolToVar cp tlBndr renv = 
-  let vars = [(F.symbol x, x) | x <- varsP cp tlBndr varsE]
-      casevars = [F.symbol x | x <- varsP cp tlBndr caseVarsE]
-      tlVars = [(F.symbol x, x) | x <- getTopLvlBndrs cp]
-      lookupErrorMsg x = " [ symbolToVar ] impossible lookup for x = " ++ show x
-      symbolVar x = fromMaybe (fromMaybe (error (lookupErrorMsg x)) $ lookup x tlVars) $ lookup x vars
-      renv' = foldr M.delete renv casevars
-  in  M.fromList [ (s, (t, symbolVar s)) | (s, t) <- M.toList renv']
-
-argsP :: GHC.CoreProgram -> Var -> [Var] 
-argsP []         tlVar = error $ " [ argsP ] " ++ show tlVar
-argsP (cb : cbs) tlVar 
-  | isInCB cb tlVar = argsCB cb
-  | otherwise = argsP cbs tlVar
-
-argsCB :: GHC.CoreBind -> [Var]
-argsCB (GHC.NonRec _ e) = argsE e
-argsCB _                = error " [ argsCB ] "
-
-argsE :: GHC.CoreExpr -> [Var]
-argsE (GHC.Lam a e) = a : argsE e 
-argsE (GHC.Let (GHC.NonRec _ _) e) = argsE e
-argsE _ = [] 
-
-notrace :: String -> a -> a 
-notrace _ a = a
diff --git a/src/Language/Haskell/Liquid/Synthesize/Generate.hs b/src/Language/Haskell/Liquid/Synthesize/Generate.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Synthesize/Generate.hs
+++ /dev/null
@@ -1,256 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE BangPatterns #-}
-
-module Language.Haskell.Liquid.Synthesize.Generate where
-
-import           Language.Haskell.Liquid.Types
-import           Language.Haskell.Liquid.Synthesize.GHC
-                                         hiding ( SSEnv )
-import           Language.Haskell.Liquid.Synthesize.Monad
-import           Language.Haskell.Liquid.Synthesize.Misc
-                                         hiding ( notrace )
-import           Language.Haskell.Liquid.Synthesize.Check
-import           CoreSyn                        ( CoreExpr )
-import qualified CoreSyn                       as GHC
-import           Data.Maybe
-import           Control.Monad.State.Lazy
-import           Language.Haskell.Liquid.Constraint.Fresh
-                                                ( trueTy )
-import           Data.List
-import           CoreUtils (exprType)
-import           Var
-import           Data.Tuple.Extra
-import           Debug.Trace
-import           Language.Fixpoint.Types.PrettyPrint (tracepp)
-import           TyCoRep
-
--- Generate terms that have type t: This changes the @ExprMemory@ in @SM@ state.
--- Return expressions type checked against type @specTy@.
-genTerms :: SpecType -> SM [CoreExpr] 
-genTerms = genTerms' ResultMode 
-
-
-data SearchMode 
-  = ArgsMode          -- ^ searching for arguments of functions that can eventually 
-                      --   produce the top level hole fill
-  | ResultMode        -- ^ searching for the hole fill 
-  deriving (Eq, Show) 
-
-genTerms' :: SearchMode -> SpecType -> SM [CoreExpr] 
-genTerms' i specTy = 
-  do  goalTys <- sGoalTys <$> get
-      case find (== toType specTy) goalTys of 
-        Nothing -> modify (\s -> s { sGoalTys = (toType specTy) : sGoalTys s })
-        Just _  -> return ()
-      fixEMem specTy 
-      fnTys <- functionCands (toType specTy)
-      es    <- withTypeEs specTy 
-      es0   <- structuralCheck es
-
-      err <- checkError specTy 
-      case err of 
-        Nothing ->
-          filterElseM (hasType specTy) es0 $ 
-            withDepthFill i specTy 0 fnTys
-        Just e -> return [e]
-
-genArgs :: SpecType -> SM [CoreExpr]
-genArgs t =
-  do  goalTys <- sGoalTys <$> get
-      case find (== toType t) goalTys of 
-        Nothing -> do modify (\s -> s { sGoalTys = toType t : sGoalTys s }) 
-                      fixEMem t 
-                      fnTys <- functionCands (toType t)
-                      es <- withDepthFillArgs t 0 fnTys
-                      if null es
-                        then  return []
-                        else  do  -- modify (\s -> s {sExprId = sExprId s + 1})
-                                  return es
-        Just _  -> return []
-
-withDepthFillArgs :: SpecType -> Int -> [(Type, CoreExpr, Int)] -> SM [CoreExpr]
-withDepthFillArgs t depth cs = do
-  thisEm <- sExprMem <$> get
-  es <- argsFill thisEm cs []
-  argsDepth <- localMaxArgsDepth
-
-  filterElseM (hasType t) es $
-    if depth < argsDepth
-      then  trace (" [ withDepthFillArgs ] argsDepth = " ++ show argsDepth) $ withDepthFillArgs t (depth + 1) cs
-      else  return []
-
-argsFill :: ExprMemory -> [(Type, CoreExpr, Int)] -> [CoreExpr] -> SM [CoreExpr]
-argsFill _   []               es0 = return es0 
-argsFill em0 (c:cs) es0 =
-  case subgoals (fst3 c) of
-    Nothing             -> return [] 
-    Just (resTy, subGs) -> 
-      do  let argCands = map (withSubgoal em0) subGs
-              toGen    = foldr (\x b -> (not . null) x && b) True (tracepp (" [ argsFill ] for c = " ++ show (snd3 c) ++ " argCands ") argCands)
-          es <- do  curExprId <- sExprId <$> get
-                    if toGen then 
-                      prune curExprId c argCands
-                      else return []
-          curExprId <- sExprId <$> get
-          let nextEm = map (resTy, , curExprId + 1) es
-          modify (\s -> s {sExprMem = nextEm ++ sExprMem s })
-          argsFill em0 cs (es ++ es0)
-
-withDepthFill :: SearchMode -> SpecType -> Int -> [(Type, GHC.CoreExpr, Int)] -> SM [CoreExpr]
-withDepthFill i t depth tmp = do
-  exprs <- fill i depth tmp []
-  appDepth <- localMaxAppDepth
-
-  filterElseM (hasType t) exprs $ 
-      if depth < appDepth
-        then do modify (\s -> s { sExprId = sExprId s + 1 })
-                withDepthFill i t (depth + 1) tmp
-        else return []
-
-fill :: SearchMode -> Int -> [(Type, GHC.CoreExpr, Int)] -> [CoreExpr] -> SM [CoreExpr] 
-fill _ _     []                 accExprs 
-  = return accExprs
-fill i depth (c : cs) accExprs 
-  = case subgoals (fst3 c) of 
-      Nothing             -> return [] -- Not a function type
-      Just (resTy, subGs) ->
-        do  specSubGs <- liftCG $ mapM trueTy (filter (not . isFunction) subGs)
-            mapM_ genArgs specSubGs
-            em <- sExprMem <$> get
-            let argCands  = map (withSubgoal em) subGs
-                toGen    = foldr (\x b -> (not . null) x && b) True argCands
-            newExprs <- do  curExprId <- sExprId <$> get 
-                            if toGen 
-                              then prune curExprId c (tracepp (" [ fill " ++ show curExprId ++ " ] For c = " ++ show (snd3 c) ++ " argCands ") argCands)
-                              else return []
-            curExprId <- sExprId <$> get
-            let nextEm = map (resTy, , curExprId + 1) newExprs
-            modify (\s -> s {sExprMem = nextEm ++ sExprMem s }) 
-            let accExprs' = newExprs ++ accExprs
-            fill i depth cs accExprs' 
-
--------------------------------------------------------------------------------------------
--- |                       Pruning terms for function application                      | --
--------------------------------------------------------------------------------------------
-type Depth = Int
-
-feasible :: Depth -> (CoreExpr, Int) -> Bool
-feasible d c = snd c >= d
-
-feasibles :: Depth -> Int -> [(CoreExpr, Int)] -> [Int]
-feasibles _ _ []
-  = []
-feasibles d i (c:cs) 
-  = if feasible d c 
-      then i : feasibles d (i+1) cs
-      else feasibles d (i+1) cs
-
-isFeasible :: Depth -> [[(CoreExpr, Int)]] -> [[Int]]
-isFeasible d =  map (feasibles d 0)
-
-findFeasibles :: Depth -> [[(CoreExpr, Int)]] -> ([[Int]], [Int])
-findFeasibles d cs = (fs, ixs)
-  where fs  = isFeasible d cs
-        ixs = [i | (i, f) <- zip [0..] fs, not (null f)]
-
-toExpr :: [Int] ->                    --  Produced from @isFeasible@.
-                                      --   Assumed in increasing order.
-          [(GHC.CoreExpr, Int)] ->    --  The candidate expressions.
-          ([(GHC.CoreExpr, Int)],     --  Expressions from 2nd argument.
-           [(GHC.CoreExpr, Int)])     --  The rest of the expressions
-toExpr ixs args = ( [ args !! i | (ix, i) <- is, ix == i ], 
-                    [ args !! i | (ix, i) <- is, ix /= i ])
-    where is = zip [0..] ixs
-
-fixCands :: Int -> [Int] -> [[(CoreExpr, Int)]] -> ([[(CoreExpr, Int)]], [[(CoreExpr, Int)]])
-fixCands i ixs args 
-  = let cs = args !! i
-        (cur, next)    = toExpr ixs cs
-        (args0, args1) = (replace (i+1) cur args, replace (i+1) next args)
-    in  (args0, args1)
-
--- | The first argument should be an 1-based index.
-replace :: Int -> a -> [a] -> [a]
-replace i x l
-  = left ++ [x] ++ right
-    where left  = take (i-1) l
-          right = drop i l
-
-repeatFix :: [Int] -> [[Int]] -> (Type, CoreExpr, Int) -> [[(CoreExpr, Int)]] -> [CoreExpr] -> SM [CoreExpr]
-repeatFix [ ] _ _ _ es 
-  = return es
-repeatFix (i:is) ixs toFill args es
-  = do  let (args0, args1) = fixCands i (ixs !! i) args
-        es0 <- fillOne toFill args0
-        es1 <- structuralCheck es0
-        es2 <- (++ es) <$> filterM isWellTyped es1
-        repeatFix is ixs toFill args1 es2
-
-prune :: Depth -> (Type, CoreExpr, Int) -> [[(CoreExpr, Int)]] -> SM [CoreExpr]
-prune d toFill args 
-  = do  let (ixs, is) = findFeasibles d args 
-        repeatFix is ixs toFill args []
-
-
-----------------------------------------------------------------------------
---  | Term generation: Perform type and term application for functions. | --
-----------------------------------------------------------------------------
-
-fillOne :: (Type, GHC.CoreExpr, Int) -> [[(CoreExpr, Int)]] -> SM [CoreExpr]
-fillOne _ [] 
-  = return []
-fillOne (t, e, _) cs 
-  = applyTerms [e] cs ((snd . fromJust . subgoals) t)
-
-applyTerm :: [GHC.CoreExpr] -> [(CoreExpr, Int)] -> Type -> SM [CoreExpr]
-applyTerm es args t = do
-  es1 <- mapM (\x -> applyArg es x t) args
-  return (concat es1)
-
-applyArg :: [GHC.CoreExpr] -> (CoreExpr, Int) -> Type -> SM [CoreExpr]
-applyArg es (arg, _) t 
-  = do  !idx <- incrSM
-        return  [ case arg of GHC.Var _ -> GHC.App e arg
-                              _         ->  let letv = mkVar (Just ("x" ++ show idx)) idx t
-                                            in  GHC.Let (GHC.NonRec letv arg) (GHC.App e (GHC.Var letv))
-                | e <- es 
-                ]
-
-applyTerms :: [GHC.CoreExpr] -> [[(CoreExpr, Int)]] -> [Type] -> SM [CoreExpr]
-applyTerms es []     []      
-  = return es
-applyTerms es0 (c:cs) (t:ts) 
-  = do  es1 <- applyTerm es0 c t
-        applyTerms es1 cs ts
-applyTerms _es _cs _ts 
-  = error "[ applyTerms ] Wildcard. " 
-
---------------------------------------------------------------------------------------
-prodScrutinees :: [(Type, CoreExpr, Int)] -> [[[(CoreExpr, Int)]]] -> SM [CoreExpr]
-prodScrutinees []     []     = return []
-prodScrutinees (c:cs) (a:as) = do 
-  es <- fillOne c a
-  (++ es) <$> prodScrutinees cs as
-prodScrutinees _ _ = error " prodScrutinees "
-
-synthesizeScrutinee :: [Var] -> SM [CoreExpr]
-synthesizeScrutinee vars = do
-  s <- get
-  let foralls = (fst . sForalls) s
-      insVs = sUniVars s
-      fix   = sFix s
-      -- Assign higher priority to function candidates that return tuples
-      fnCs0 = filter returnsTuple foralls 
-      fnCs  = if returnsTuple fix then fix : fnCs0 else fnCs0
-
-      fnEs  = map GHC.Var fnCs
-      fnCs' = map (\e -> instantiate e (Just insVs)) fnEs
-      sGs   = map ((snd . fromJust) . subgoals . exprType) fnCs'
-      argCands = map (map (withSubgoal vs)) sGs
-      fnCs'' = map (\e -> (exprType e, e, 0)) fnCs'
-      
-      vs' = filter ((not . isFunction) . varType) vars
-      vs  = map (\v -> (varType v, GHC.Var v, 0)) vs'
-  prodScrutinees fnCs'' argCands
diff --git a/src/Language/Haskell/Liquid/Synthesize/Misc.hs b/src/Language/Haskell/Liquid/Synthesize/Misc.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Synthesize/Misc.hs
+++ /dev/null
@@ -1,95 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE BangPatterns #-}
-
-module Language.Haskell.Liquid.Synthesize.Misc where
-
-import qualified Language.Fixpoint.Types        as F 
-import           Control.Monad.State.Lazy
-import           CoreSyn
-import           TyCoRep 
-import           Text.PrettyPrint.HughesPJ (text, Doc, vcat, ($+$))
-import           Language.Haskell.Liquid.Synthesize.GHC
-import           Language.Haskell.Liquid.GHC.TypeRep
-import           Language.Fixpoint.Types
-
-
-isFunction :: Type -> Bool
-isFunction FunTy{}    = True 
-isFunction ForAllTy{} = True
-isFunction _          = False
-
-(<$$>) :: (Functor m, Functor n) => (a -> b) -> m (n a) -> m (n b)
-(<$$>) = fmap . fmap
-
-filterElseM :: Monad m => (a -> m Bool) -> [a] -> m [a] -> m [a]
-filterElseM f as ms = do
-    rs <- filterM f as
-    if null rs then
-        ms
-    else
-        return rs
-
--- Replaces    | old w   | new  | symbol name in expr.
-substInFExpr :: F.Symbol -> F.Symbol -> F.Expr -> F.Expr
-substInFExpr pn nn e = F.subst1 e (pn, F.EVar nn)
-
-
-findM :: Monad m => (a -> m Bool) -> [a] -> m (Maybe a)
-findM _ []     = return Nothing
-findM p (x:xs) = do b <- p x ; if b then return (Just x) else findM p xs 
-
-
-composeM :: Monad m => (a -> m b) -> (b -> c) -> a -> m c
-composeM f g x = do 
-    mx <- f x
-    return (g mx)
-
-----------------------------------------------------------------------------
-----------------------------Printing----------------------------------------
-----------------------------------------------------------------------------
-solDelim :: String
-solDelim = "*********************************************"
-
--- pprintMany :: (F.PPrint a) => [a] -> Doc
--- pprintMany xs = vcat [ F.pprint x $+$ text solDelim | x <- xs ]
-
-pprintMany :: [String] -> Doc
-pprintMany xs = vcat [ text x $+$ text solDelim | x <- xs ]
-
-showGoals :: [[String]] -> String
-showGoals []             = ""
-showGoals (goal : goals) = 
-    show goal        ++ 
-    "\n"             ++ 
-    replicate 12 ' ' ++ 
-    showGoals goals
-
-showEmem :: (Show a1, Show a2) => [(Type, a1, a2)] -> String
-showEmem  emem = show $ showEmem' emem
-
-showEmem' :: (Show a1, Show a2) => [(Type, a1, a2)] -> [(String, String, String)]
-showEmem' emem = map (\(t, e, i) -> (show e, showTy t, show i)) emem
-
-exprmemToExpr :: [(a2, CoreExpr, Int)] -> String
-exprmemToExpr em = show $ map (\(_, e, i) -> show (fromAnf e, i) ++ " * ") em 
-
-showCand :: (a, (Type, b)) -> (String, b)
-showCand (_, (t, v)) = (showTy t, v)
-
-showCands :: [(a, (Type, b))] -> [(String, b)]
-showCands = map showCand
-
-notrace :: String -> a -> a 
-notrace _ a = a 
-
-instance PPrint AltCon
-
-showCoreAlt :: CoreAlt -> String
-showCoreAlt (DataAlt altCon, vars, expr) = 
-  " For " ++ show altCon ++ " vars " ++ show vars ++ " expr " ++ show expr
-showCoreAlt _ = " No! "
-
-showCoreAlts :: [CoreAlt] -> String
-showCoreAlts alts = concatMap showCoreAlt alts
diff --git a/src/Language/Haskell/Liquid/Synthesize/Monad.hs b/src/Language/Haskell/Liquid/Synthesize/Monad.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Synthesize/Monad.hs
+++ /dev/null
@@ -1,428 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE FlexibleContexts #-}
-
-module Language.Haskell.Liquid.Synthesize.Monad where
-
-
-import           Language.Haskell.Liquid.Bare.Resolve
-                                               as B
-import           Language.Haskell.Liquid.Types
-import           Language.Haskell.Liquid.Constraint.Types
-import           Language.Haskell.Liquid.Constraint.Env
-import           Language.Haskell.Liquid.Synthesize.GHC
-                                         hiding ( SSEnv )
-import           Language.Haskell.Liquid.Synthesize.Misc
-                                         hiding ( notrace )
-import qualified Language.Fixpoint.Smt.Interface
-                                               as SMT
-import           Language.Fixpoint.Types hiding ( SEnv
-                                                , SVar
-                                                , Error
-                                                )
-import qualified Language.Fixpoint.Types       as F
-import qualified Language.Fixpoint.Types.Config
-                                               as F
-import           CoreSyn                        ( CoreExpr )
-import qualified CoreSyn                       as GHC
-import           Var
-import           Control.Monad.State.Lazy
-import qualified Data.HashMap.Strict           as M
-import           Data.Maybe
-import           Data.List
-import           CoreUtils                      ( exprType )
-import           Data.Tuple.Extra
-import           TyCon
-import           TyCoRep
-
-localMaxMatchDepth :: SM Int 
-localMaxMatchDepth = maxMatchDepth . getConfig . sCGEnv <$> get
-
--------------------------------------------------------------------------------
--- | Synthesis Monad ----------------------------------------------------------
--------------------------------------------------------------------------------
-
--- The state keeps a unique index for generation of fresh variables 
--- and the environment of variables to types that is expanded on lambda terms
-type SSEnv = M.HashMap Symbol (SpecType, Var)
-type SSDecrTerm = [(Var, [Var])]
-
-type ExprMemory = [(Type, CoreExpr, Int)]
-type T = M.HashMap Type (CoreExpr, Int)
-data SState 
-  = SState { rEnv       :: !REnv 
-           , ssEnv      :: !SSEnv -- Local Binders Generated during Synthesis 
-           , ssIdx      :: !Int
-           , ssDecrTerm :: !SSDecrTerm 
-           , sContext   :: !SMT.Context
-           , sCGI       :: !CGInfo
-           , sCGEnv     :: !CGEnv
-           , sFCfg      :: !F.Config
-           , sDepth     :: !Int
-           , sExprMem   :: !ExprMemory 
-           , sExprId    :: !Int
-           , sArgsId    :: !Int
-           , sArgsDepth :: !Int
-           , sUniVars   :: ![Var]
-           , sFix       :: !Var
-           , sGoalTys   :: ![Type]
-           , sGoalTyVar :: !(Maybe [TyVar])
-           , sUGoalTy   :: !(Maybe [Type])     -- Types used for instantiation.
-                                               --   Produced by @withUnify@.
-           , sForalls   :: !([Var], [[Type]])  -- [Var] are the parametric functions (except for the fixpoint)
-                                               --    e.g. Constructors, top-level functions.
-                                               -- [[Type]]: all the types that have instantiated [Var] so far.
-           , caseIdx    :: !Int                -- [ Temporary ] Index in list of scrutinees.
-           , scrutinees :: ![(CoreExpr, Type, TyCon)]
-           }
-type SM = StateT SState IO
-
-localMaxAppDepth :: SM Int 
-localMaxAppDepth = maxAppDepth . getConfig . sCGEnv <$> get
-
-localMaxArgsDepth :: SM Int
-localMaxArgsDepth = maxArgsDepth . getConfig . sCGEnv <$> get
-
-locally :: SM a -> SM a 
-locally act = do 
-  st <- get 
-  r <- act 
-  modify $ \s -> s{sCGEnv = sCGEnv st, sCGI = sCGI st, sExprMem = sExprMem st, scrutinees = scrutinees st}
-  return r 
-
-
-evalSM :: SM a -> SMT.Context -> SSEnv -> SState -> IO a 
-evalSM act ctx env st = do 
-  let st' = st {ssEnv = env}
-  r <- evalStateT act st'
-  SMT.cleanupContext ctx 
-  return r 
-
-initState :: SMT.Context -> F.Config -> CGInfo -> CGEnv -> REnv -> Var -> [Var] -> SSEnv -> IO SState 
-initState ctx fcfg cgi cgenv renv xtop uniVars env = 
-  return $ SState renv env 0 [] ctx cgi cgenv fcfg 0 exprMem0 0 0 0 uniVars xtop [] Nothing Nothing ([], []) 0 []
-  where exprMem0 = initExprMem env
-
-getSEnv :: SM SSEnv
-getSEnv = ssEnv <$> get 
-
-getSEMem :: SM ExprMemory
-getSEMem = sExprMem <$> get
-
-getSFix :: SM Var 
-getSFix = sFix <$> get
-
-getSUniVars :: SM [Var]
-getSUniVars = sUniVars <$> get
-
-getSDecrTerms :: SM SSDecrTerm 
-getSDecrTerms = ssDecrTerm <$> get
-
-addsEnv :: [(Var, SpecType)] -> SM () 
-addsEnv xts = 
-  mapM_ (\(x,t) -> modify (\s -> s {ssEnv = M.insert (symbol x) (t,x) (ssEnv s)})) xts  
-
-addsEmem :: [(Var, SpecType)] -> SM () 
-addsEmem xts = do 
-  curAppDepth <- sExprId <$> get
-  mapM_ (\(x,t) -> modify (\s -> s {sExprMem = (toType t, GHC.Var x, curAppDepth+1) : (sExprMem s)})) xts  
-  
-
-addEnv :: Var -> SpecType -> SM ()
-addEnv x t = do 
-  liftCG0 (\γ -> γ += ("arg", symbol x, t))
-  modify (\s -> s {ssEnv = M.insert (symbol x) (t,x) (ssEnv s)}) 
-
-addEmem :: Var -> SpecType -> SM ()
-addEmem x t = do 
-  let ht0 = toType t
-  curAppDepth <- sExprId <$> get
-  xtop <- getSFix 
-  (ht1, _) <- instantiateTL
-  let ht = if x == xtop then ht1 else ht0
-  modify (\s -> s {sExprMem = (ht, GHC.Var x, curAppDepth) : sExprMem s})
-
----------------------------------------------------------------------------------------------
---                         Handle structural termination checking                          --
----------------------------------------------------------------------------------------------
-addDecrTerm :: Var -> [Var] -> SM ()
-addDecrTerm x vars = do
-  decrTerms <- getSDecrTerms 
-  case lookup x decrTerms of 
-    Nothing    -> lookupAll x vars decrTerms
-    Just vars' -> do
-      let ix = elemIndex (x, vars') decrTerms
-          newDecrs = thisReplace (fromMaybe (error " [ addDecrTerm ] Index ") ix) (x, vars ++ vars') decrTerms
-      modify (\s -> s { ssDecrTerm =  newDecrs })
-
--- 
-lookupAll :: Var -> [Var] -> SSDecrTerm -> SM ()
-lookupAll x vars []               = modify (\s -> s {ssDecrTerm = (x, vars) : ssDecrTerm s})
-lookupAll x vars ((xl, vs):decrs) =
-  case find (== x) vs of
-    Nothing -> lookupAll x vars decrs
-    Just _  -> do
-      sDecrs <- ssDecrTerm <$> get
-      let newDecr  = (xl, vars ++ [x] ++ vs)
-          i        = fromMaybe (error " Write sth ") (elemIndex (xl, vs) sDecrs)
-          newDecrs = thisReplace i newDecr decrs
-      modify (\s -> s { ssDecrTerm = newDecrs })
-
-thisReplace :: Int -> a -> [a] -> [a]
-thisReplace i x l
-  = left ++ [x] ++ right
-    where left  = take (i-1) l
-          right = drop i l
-
--- | Entry point.
-structuralCheck :: [CoreExpr] -> SM [CoreExpr]
-structuralCheck es 
-  = do  decr <- ssDecrTerm <$> get
-        fix <- sFix <$> get
-        return (filter (notStructural decr fix) es)
-
-structCheck :: Var -> CoreExpr -> (Maybe Var, [CoreExpr])
-structCheck xtop var@(GHC.Var v)
-  = if v == xtop 
-      then (Just xtop, [])
-      else (Nothing, [var])
-structCheck xtop (GHC.App e1 (GHC.Type _))
-  = structCheck xtop e1
-structCheck xtop (GHC.App e1 e2)
-  =  (mbVar, e2:es)
-    where (mbVar, es) = structCheck xtop e1
-structCheck xtop (GHC.Let _ e) 
-  = structCheck xtop e
-structCheck _ e 
-  = error (" StructCheck " ++ show e)
-
-notStructural :: SSDecrTerm -> Var -> CoreExpr -> Bool
-notStructural decr xtop e
-  = case v of
-      Nothing -> True
-      Just _  -> foldr (\x b -> isDecreasing' x decr || b) False args
-  where (v, args) = structCheck xtop e
-
-isDecreasing' :: CoreExpr -> SSDecrTerm -> Bool
-isDecreasing' (GHC.Var v) decr
-  = v `notElem` map fst decr
-isDecreasing' _e _decr
-  = True
----------------------------------------------------------------------------------------------
---                               END OF STRUCTURAL CHECK                                   --
----------------------------------------------------------------------------------------------
-
-liftCG0 :: (CGEnv -> CG CGEnv) -> SM () 
-liftCG0 act = do 
-  st <- get 
-  let (cgenv, cgi) = runState (act (sCGEnv st)) (sCGI st) 
-  modify (\s -> s {sCGI = cgi, sCGEnv = cgenv}) 
-
-
-liftCG :: CG a -> SM a 
-liftCG act = do 
-  st <- get 
-  let (x, cgi) = runState act (sCGI st) 
-  modify (\s -> s {sCGI = cgi})
-  return x 
-
-
-freshVarType :: Type -> SM Var
-freshVarType t = (\i -> mkVar (Just "x") i t) <$> incrSM
-
-
-freshVar :: SpecType -> SM Var
-freshVar = freshVarType . toType
-
-withIncrDepth :: Monoid a => SM a -> SM a
-withIncrDepth m = do 
-    s <- get
-    matchBound <- localMaxMatchDepth 
-    let d = sDepth s
-    if d + 1 > matchBound
-      then return mempty
-      else do put s{sDepth = d + 1}
-              r <- m
-              modify $ \s -> s{sDepth = d}
-              return r
-        
-  
-incrSM :: SM Int 
-incrSM = do s <- get 
-            put s{ssIdx = ssIdx s + 1}
-            return (ssIdx s)
-
-incrCase :: SM Int 
-incrCase
-  = do  s <- get 
-        put s { caseIdx = caseIdx s + 1 }
-        return (caseIdx s)
-  
-safeIxScruts :: Int -> [a] -> Maybe Int
-safeIxScruts i l 
-  | i >= length l = Nothing
-  | otherwise     = Just i
-
-symbolExpr :: Type -> F.Symbol -> SM CoreExpr 
-symbolExpr τ x = incrSM >>= (\i -> return $ F.notracepp ("symExpr for " ++ F.showpp x) $  GHC.Var $ mkVar (Just $ F.symbolString x) i τ)
-
-
--------------------------------------------------------------------------------------------------------
------------------------------------------ Handle ExprMemory -------------------------------------------
--------------------------------------------------------------------------------------------------------
-
--- | Initializes @ExprMemory@ structure.
---    1. Transforms refinement types to conventional (Haskell) types.
---    2. All @Depth@s are initialized to 0.
-initExprMem :: SSEnv -> ExprMemory
-initExprMem sEnv = map (\(_, (t, v)) -> (toType t, GHC.Var v, 0)) (M.toList sEnv)
-
-
--------------- Init @ExprMemory@ with instantiated functions with the right type (sUGoalTy) -----------
-insEMem0 :: SSEnv -> SM ExprMemory
-insEMem0 senv = do
-  xtop      <- getSFix
-  (ttop, _) <- instantiateTL
-  mbUTy     <- sUGoalTy <$> get 
-  uniVs <- sUniVars <$> get
-
-  let ts = fromMaybe [] mbUTy
-  ts0 <- snd . sForalls <$> get
-  fs0 <- fst . sForalls <$> get
-  modify ( \s -> s { sForalls = (fs0, ts : ts0) } )
-
-  let handleIt e = case e of  GHC.Var v -> if xtop == v 
-                                              then (instantiate e (Just uniVs), ttop) 
-                                              else change e
-                              _         -> change e
-      change e =  let { e' = instantiateTy e mbUTy; t' = exprType e' } 
-                  in  (e', t')
-
-      em0 = initExprMem senv
-  return $ map (\(_, e, i) -> let (e', t') = handleIt e
-                              in  (t', e', i)) em0
-
-instantiateTy :: CoreExpr -> Maybe [Type] -> CoreExpr
-instantiateTy e mbTy = 
-  case mbTy of 
-    Nothing  -> e
-    Just tys -> case applyTy tys e of 
-                  Nothing -> e
-                  Just e0 -> e0
-
--- | Used for instantiation: Applies types to an expression.
---   > The result does not have @forall@.
---   Nothing as a result suggests that there are more types than foralls in the expression.
-applyTy :: [Type] -> GHC.CoreExpr -> Maybe GHC.CoreExpr
-applyTy []     e =  case exprType e of 
-                      ForAllTy{} -> Nothing
-                      _          -> Just e
-applyTy (t:ts) e =  case exprType e of
-                      ForAllTy{} -> applyTy ts (GHC.App e (GHC.Type t))
-                      _          -> Nothing
-
--- | Instantiation based on current goal-type.
-fixEMem :: SpecType -> SM ()
-fixEMem t
-  = do  (fs, ts) <- sForalls <$> get
-        let uTys = unifyWith (toType t)
-        needsFix <- case find (== uTys) ts of 
-                      Nothing -> return True   -- not yet instantiated
-                      Just _  -> return False  -- already instantiated
-
-        when needsFix $
-          do  modify (\s -> s { sForalls = (fs, uTys : ts)})
-              let notForall e = case exprType e of {ForAllTy{} -> False; _ -> True}
-                  es = map (\v -> instantiateTy (GHC.Var v) (Just uTys)) fs
-                  fixEs = filter notForall es
-              thisDepth <- sDepth <$> get
-              let fixedEMem = map (\e -> (exprType e, e, thisDepth + 1)) fixEs
-              modify (\s -> s {sExprMem = fixedEMem ++ sExprMem s})
-
-------------------------------------------------------------------------------------------------
------------------------------- Special handle for the current fixpoint -------------------------
-------------------------------------------------------------------------------------------------
-
--- | Instantiate the top-level variable.
-instantiateTL :: SM (Type, GHC.CoreExpr)
-instantiateTL = do
-  uniVars <- getSUniVars 
-  xtop <- getSFix
-  let e = fromJust $ apply uniVars (GHC.Var xtop)
-  return (exprType e, e)
-
--- | Applies type variables (1st argument) to an expression.
---   The expression is guaranteed to have the same level of 
---   parametricity (same number of @forall@) as the length of the 1st argument.
---   > The result has zero @forall@.
-apply :: [Var] -> GHC.CoreExpr -> Maybe GHC.CoreExpr
-apply []     e = 
-  case exprType e of 
-    ForAllTy {} -> Nothing
-    _           -> Just e
-apply (v:vs) e 
-  = case exprType e of 
-      ForAllTy{} -> apply vs (GHC.App e (GHC.Type (TyVarTy v)))
-      _          -> Nothing
-
-instantiate :: CoreExpr -> Maybe [Var] -> CoreExpr
-instantiate e mbt = 
-  case mbt of
-    Nothing     -> e
-    Just tyVars -> case apply tyVars e of 
-                      Nothing -> e
-                      Just e' -> e'
-
------------------------------------------------------------------------------------------------------
-
-withTypeEs :: SpecType -> SM [CoreExpr] 
-withTypeEs t = do 
-    em <- sExprMem <$> get 
-    return (map snd3 (filter (\x -> fst3 x == toType t) em)) 
-
-findCandidates :: Type ->         -- Goal type: Find all candidate expressions of this type,
-                                  --   or that produce this type (i.e. functions).
-                  SM ExprMemory
-findCandidates goalTy = do
-  sEMem <- sExprMem <$> get
-  return (filter ((goalType goalTy) . fst3) sEMem)
-
-functionCands :: Type -> SM [(Type, GHC.CoreExpr, Int)]
-functionCands goalTy = do 
-  all <- findCandidates goalTy 
-  return (filter (isFunction . fst3) all)
-
-
----------------------------------------------------------------------------------
---------------------------- Generate error expression ---------------------------
----------------------------------------------------------------------------------
-
-varError :: SM Var
-varError = do 
-  info    <- ghcI . sCGI <$> get
-  let env  = B.makeEnv (gsConfig $ giSpec info) (toGhcSrc $ giSrc info) mempty mempty 
-  let name = giTargetMod $ giSrc info
-  return $ B.lookupGhcVar env name "Var" (dummyLoc $ symbol "Language.Haskell.Liquid.Synthesize.Error.err")
-
-toGhcSrc :: TargetSrc -> GhcSrc 
-toGhcSrc a = Src
-      { _giIncDir    = giIncDir a
-      , _giTarget    = giTarget a
-      , _giTargetMod = giTargetMod a
-      , _giCbs       = giCbs a
-      , _gsTcs       = gsTcs a
-      , _gsCls       = gsCls a
-      , _giDerVars   = giDerVars a
-      , _giImpVars   = giImpVars a
-      , _giDefVars   = giDefVars a
-      , _giUseVars   = giUseVars a
-      , _gsExports   = gsExports a
-      , _gsFiTcs     = gsFiTcs a
-      , _gsFiDcs     = gsFiDcs a
-      , _gsPrimTcs   = gsPrimTcs a
-      , _gsQualImps  = gsQualImps a
-      , _gsAllImps   = gsAllImps a
-      , _gsTyThings  = gsTyThings a
-      }
diff --git a/src/Language/Haskell/Liquid/Synthesize/Termination.hs b/src/Language/Haskell/Liquid/Synthesize/Termination.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Synthesize/Termination.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-
-module Language.Haskell.Liquid.Synthesize.Termination (
-    decrType
-  ) where
-
-import           Language.Haskell.Liquid.Types
-import qualified Language.Haskell.Liquid.Types.RefType
-                                               as R
-import qualified Language.Fixpoint.Types       as F
-import           Var
-
-decrType :: Var -> SpecType -> [Var] -> [(F.Symbol, SpecType)] -> SpecType
-decrType _x ti xs _xts =
-  go xs ti 
-  where
-    go (v:_) (RFun x tx t r) 
-      | isDecreasing mempty mempty tx  = let Left (x', tx') = R.makeDecrType mempty [(v,(x,tx))] 
-                                         in  RFun x' tx' t r 
-    go (_:vs) (RFun x tx t r) = RFun x tx (go vs t) r
-    go vs (RAllT a t x) = RAllT a (go vs t) x
-    go _     t = t 
diff --git a/src/Language/Haskell/Liquid/Termination/Structural.hs b/src/Language/Haskell/Liquid/Termination/Structural.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Termination/Structural.hs
+++ /dev/null
@@ -1,352 +0,0 @@
-{-# LANGUAGE ViewPatterns #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE LambdaCase #-}
-
-module Language.Haskell.Liquid.Termination.Structural (terminationVars) where
-
-import Language.Haskell.Liquid.Types hiding (isDecreasing)
-import Language.Haskell.Liquid.GHC.Misc (showPpr)
-
-import CoreSyn
-import Var
-import Name (getSrcSpan)
-import VarSet
-import CoreSubst (deShadowBinds)
-
-import Text.PrettyPrint.HughesPJ hiding ((<>))
-
-import qualified Data.HashSet as HS
-import Data.HashSet (HashSet)
-import qualified Data.Map.Strict as M
-import Data.Map.Strict (Map)
-import qualified Data.List as L
-
-import Control.Monad (liftM, ap)
-import Data.Foldable (fold)
-
-terminationVars :: TargetInfo -> [Var]
-terminationVars info = failingBinds info >>= allBoundVars
-
-failingBinds :: TargetInfo -> [CoreBind]
-failingBinds info = filter (hasErrors . checkBind) structBinds
-  where 
-    structCheckWholeProgram = structuralTerm info
-    program = giCbs . giSrc $ info
-    structFuns = gsStTerm . gsTerm . giSpec $ info
-    structBinds
-      | structCheckWholeProgram = program
-      | otherwise = findStructBinds structFuns program
-
-checkBind :: CoreBind -> Result ()
-checkBind bind = do
-  srcCallInfo <- getCallInfoBind emptyEnv (deShadowBind bind)
-  let structCallInfo = fmap toStructCall <$> srcCallInfo
-  fold $ mapWithFun structDecreasing structCallInfo
-
-deShadowBind :: CoreBind -> CoreBind
-deShadowBind bind = head $ deShadowBinds [bind]
-
-findStructBinds :: HashSet Var -> CoreProgram -> [CoreBind]
-findStructBinds structFuns program = filter isStructBind program
-  where
-    isStructBind (NonRec f _) = f `HS.member` structFuns
-    isStructBind (Rec []) = False
-    isStructBind (Rec ((f,_):xs)) = f `HS.member` structFuns || isStructBind (Rec xs)
-
-allBoundVars :: CoreBind -> [Var]
-allBoundVars (NonRec v e) = v : (nextBinds e >>= allBoundVars)
-allBoundVars (Rec binds) = map fst binds ++ (map snd binds >>= nextBinds >>= allBoundVars)
-
-nextBinds :: CoreExpr -> [CoreBind]
-nextBinds = \case
-  App e a -> nextBinds e ++ nextBinds a
-  Lam _ e -> nextBinds e
-  Let b e -> [b] ++ nextBinds e
-  Case scrut _ _ alts -> nextBinds scrut ++ ([body | (_, _, body) <- alts] >>= nextBinds)
-  Cast e _ -> nextBinds e
-  Tick _ e -> nextBinds e
-  Var{} -> []
-  Lit{} -> []
-  Coercion{} -> []
-  Type{} -> []
-
-------------------------------------------------------------------------------------------
-
--- Note that this is *not* the Either/Maybe monad, since it's important that we
--- collect all errors, not just the first error.
-data Result a = Result
-  { resultVal :: a
-  , resultErrors :: [TermError]
-  } deriving (Show)
-
-data TermError = TE 
-  { teVar   :: Var
-  , teError :: UserError
-  } deriving (Show)
-
-hasErrors :: Result a -> Bool
-hasErrors = not . null . resultErrors
-
-addError :: Var -> Doc -> Result a -> Result a
-addError fun expl (Result x errs) = Result x (mkTermError fun expl : errs)
-
-mkTermError :: Var -> Doc -> TermError
-mkTermError fun expl = TE
-  { teVar   = fun
-  , teError = ErrStTerm (getSrcSpan fun) (text $ showPpr fun) expl
-  }
-
-instance Monoid a => Monoid (Result a) where
-  mempty  = Result mempty []
-
-instance Semigroup a => Semigroup (Result a) where
-  Result x e1 <> Result y e2 = Result (x <> y) (e1 ++ e2)
-
-instance Monad Result where
-  Result x e1 >>= f =
-    let Result y e2 = f x in
-    Result y (e2 ++ e1)
-
-instance Applicative Result where
-  pure x = Result x []
-  (<*>) = ap
-
-instance Functor Result where
-  fmap = liftM
-
---------------------------------------------------------------------------------
-
-data Env = Env
-  { envCurrentFun :: Maybe Var
-  , envCurrentArgs :: [CoreArg]
-  , envCheckedFuns :: [Fun]
-  }
-
-data Fun = Fun
-  { funName :: Var
-  , funParams :: [Param]
-  }
-
-data Param = Param
-  { paramNames :: VarSet
-  , paramSubterms :: VarSet
-  } deriving (Eq)
-
-emptyEnv :: Env
-emptyEnv = Env
-  { envCurrentFun = Nothing
-  , envCurrentArgs = []
-  , envCheckedFuns = []
-  }
-
-mkFun :: Var -> Fun
-mkFun name = Fun
-  { funName = name
-  , funParams = []
-  }
-
-mkParam :: Var -> Param
-mkParam name = Param
-  { paramNames = unitVarSet name
-  , paramSubterms = emptyVarSet
-  }
-
-lookupFun :: Env -> Var -> Maybe Fun
-lookupFun env name = L.find (\fun -> funName fun == name) $ envCheckedFuns env
-
-clearCurrentArgs :: Env -> Env
-clearCurrentArgs env = env { envCurrentArgs = [] }
-
-setCurrentFun :: Var -> Env -> Env
-setCurrentFun fun env = env { envCurrentFun = Just fun }
-
-clearCurrentFun :: Env -> Env
-clearCurrentFun env = env { envCurrentFun = Nothing }
-
-addArg :: CoreArg -> Env -> Env
-addArg arg env = env { envCurrentArgs = arg:envCurrentArgs env }
-
-addParam :: Var -> Env -> Env
-addParam param env = case envCurrentFun env of
-  Nothing -> env
-  Just name -> env { envCheckedFuns = updateFunNamed name <$> envCheckedFuns env }
-  where
-    updateFunNamed name fun
-      | funName fun == name = fun { funParams = mkParam param : funParams fun }
-      | otherwise = fun
-
-addSynonym :: Var -> Var -> Env -> Env
-addSynonym oldName newName env = env { envCheckedFuns = updateFun <$> envCheckedFuns env }
-  where
-    updateFun fun = fun { funParams = updateParam <$> funParams fun }
-    updateParam param
-      | oldName `elemVarSet` paramNames param = param { paramNames = paramNames param `extendVarSet` newName }
-      | oldName `elemVarSet` paramSubterms param = param { paramSubterms = paramSubterms param `extendVarSet` newName }
-      | otherwise = param
-
-addSubterms :: Var -> [Var] -> Env -> Env
-addSubterms var subterms env = env { envCheckedFuns = updateFun <$> envCheckedFuns env }
-  where
-    updateFun fun = fun { funParams = updateParam <$> funParams fun }
-    updateParam param
-      | var `elemVarSet` paramNames param || var `elemVarSet` paramSubterms param = param { paramSubterms = paramSubterms param `extendVarSetList` subterms }
-      | otherwise = param
-
-addCheckedFun :: Var -> Env -> Env
-addCheckedFun name env = env { envCheckedFuns = mkFun name : envCheckedFuns env }
-
-isParam :: Var -> Param -> Bool
-var `isParam` param = var `elemVarSet` paramNames param
-
-isParamSubterm :: Var -> Param -> Bool
-var `isParamSubterm` param = var `elemVarSet` paramSubterms param
-
---------------------------------------------------------------------------------
-
-newtype FunInfo a = FunInfo (Map Var a)
-
-data SrcCall = SrcCall
-  { srcCallFun :: Var
-  , srcCallArgs :: [(Param, CoreArg)]
-  }
-
-instance Semigroup a => Semigroup (FunInfo a) where
-  FunInfo xs <> FunInfo ys = FunInfo $ M.unionWith (<>) xs ys
-
-instance Semigroup a => Monoid (FunInfo a) where
-  mempty = FunInfo M.empty
-
-instance Functor FunInfo where
-  fmap f (FunInfo xs) = FunInfo (fmap f xs)
-
-instance Foldable FunInfo where
-  foldMap f (FunInfo m) = foldMap f m
-
-mapWithFun :: (Var -> a -> b) -> FunInfo a -> FunInfo b
-mapWithFun f (FunInfo x) = FunInfo (M.mapWithKey f x)
-
-mkFunInfo :: Var -> a -> FunInfo a
-mkFunInfo fun x = FunInfo $ M.singleton fun x
-
-mkSrcCall :: Var -> [(Param, CoreArg)] -> SrcCall
-mkSrcCall fun args = SrcCall
-  { srcCallFun = fun
-  , srcCallArgs = args
-  }
-
-toVar :: CoreExpr -> Maybe Var
-toVar (Var x) = Just x
-toVar (Cast e _) = toVar e
-toVar (Tick _ e) = toVar e
-toVar _ = Nothing
-
-zipExact :: [a] -> [b] -> Maybe [(a, b)]
-zipExact [] [] = Just []
-zipExact (x:xs) (y:ys) = ((x, y):) <$> zipExact xs ys
-zipExact _ _ = Nothing
-
--- Collect information about all of the recursive calls in a function
--- definition which will be needed to check for structural termination.
-getCallInfoExpr :: Env -> CoreExpr -> Result (FunInfo [SrcCall])
-getCallInfoExpr env = \case
-  Var (lookupFun env -> Just fun) ->
-    case zipExact (funParams fun) (reverse $ envCurrentArgs env) of
-      Just args -> pure $ mkFunInfo (funName fun) [mkSrcCall (funName fun) args]
-      Nothing -> addError (funName fun) "Unsaturated call to function" mempty
-
-  App e a
-    | isTypeArg a -> getCallInfoExpr env e
-    | otherwise -> getCallInfoExpr argEnv a <> getCallInfoExpr appEnv e
-      where
-        argEnv = clearCurrentFun . clearCurrentArgs $ env
-        appEnv = clearCurrentFun . addArg a $ env
-
-  Lam x e
-    | isTyVar x -> getCallInfoExpr env e
-    | otherwise -> getCallInfoExpr (addParam x env) e
-
-  Let bind e -> getCallInfoBind env bind <> getCallInfoExpr env e
-
-  Case (toVar -> Just var) bndr _ alts -> foldMap getCallInfoAlt alts
-    where
-      getCallInfoAlt (_, subterms, body) = getCallInfoExpr (branchEnv subterms) body
-      branchEnv subterms = addSubterms var subterms . addSynonym var bndr $ env
-
-  Case scrut _ _ alts -> getCallInfoExpr env scrut <> foldMap getCallInfoAlt alts
-    where
-      getCallInfoAlt (_, _, body) = getCallInfoExpr env body
-
-  Cast e _ -> getCallInfoExpr env e
-  Tick _ e -> getCallInfoExpr env e
-
-  Var{} -> pure mempty
-  Lit{} -> pure mempty
-  Coercion{} -> pure mempty
-  Type{} -> pure mempty
-
-getCallInfoBind :: Env -> CoreBind -> Result (FunInfo [SrcCall])
-getCallInfoBind env = \case
-  NonRec _ e -> getCallInfoExpr (clearCurrentFun env) e
-  Rec [] -> pure mempty
-  Rec [(f, e)] -> getCallInfoExpr (addCheckedFun f . setCurrentFun f $ env) e
-  Rec binds -> foldMap failBind binds
-    where failBind (f, e) =
-            addError f "Structural checking of mutually-recursive functions is not supported" $
-            getCallInfoExpr (clearCurrentFun env) e
-
---------------------------------------------------------------------------------
-
-data StructInfo = Unchanged Int | Decreasing Int
-
-unStructInfo :: StructInfo -> Int
-unStructInfo (Unchanged p) = p
-unStructInfo (Decreasing p) = p
-
-isDecreasing :: StructInfo -> Bool
-isDecreasing (Decreasing _) = True
-isDecreasing (Unchanged _) = False
-
-data StructCall = StructCall
-  { structCallFun :: Var
-  , structCallArgs :: [Int]
-  , structCallDecArgs :: [Int]
-  }
-
-mkStructCall :: Var -> [StructInfo] -> StructCall
-mkStructCall fun sis = StructCall
-  { structCallFun = fun
-  , structCallArgs = map unStructInfo sis
-  , structCallDecArgs = map unStructInfo . filter isDecreasing $ sis
-  }
-
--- This is where we  check a function call. We go through  the list of arguments
--- and find the  indices of those which are decreasing.  Note that this approach
--- is only guaranteed to  work when the arguments to the  function are named, so
--- e.g.
--- foo (x:xs) (y:ys) = foo xs (y:ys)
--- won't necessarily work, but
--- foo (x:xs) yys@(y:ys) = foo xs yys
--- will.
-toStructCall :: SrcCall -> StructCall
-toStructCall srcCall = mkStructCall (srcCallFun srcCall) $ toStructArgs 0 (srcCallArgs srcCall)
-  where
-    toStructArgs _ [] = []
-    toStructArgs index ((param, toVar -> Just v):args)
-      | v `isParam` param = Unchanged index : toStructArgs (index + 1) args
-      | v `isParamSubterm` param = Decreasing index : toStructArgs (index + 1) args
-    toStructArgs index (_:args) = toStructArgs (index + 1) args
-
--- Check if there is some way to lexicographically order the arguments so that
--- they are structurally decreasing. Essentially, in order for there to be, we
--- must be able to find some argument which is always either unchanged or
--- decreasing. We can then remove every call where that argument is decreasing
--- and recurse.
-structDecreasing :: Var -> [StructCall] -> Result ()
-structDecreasing _ [] = mempty
-structDecreasing funName calls
-  | null sharedArgs = addError funName "Non-structural recursion" mempty
-  | otherwise = structDecreasing funName $ (map removeSharedArgs . filter noneDecreasing) calls
-  where
-    sharedArgs = foldl1 L.intersect (structCallArgs <$> calls)
-    noneDecreasing call = null $ structCallDecArgs call `L.intersect` sharedArgs
-    removeSharedArgs call = call { structCallArgs = structCallArgs call L.\\ sharedArgs }
diff --git a/src/Language/Haskell/Liquid/Transforms/ANF.hs b/src/Language/Haskell/Liquid/Transforms/ANF.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Transforms/ANF.hs
+++ /dev/null
@@ -1,405 +0,0 @@
---------------------------------------------------------------------------------
--- | Convert GHC Core into Administrative Normal Form (ANF) --------------------
---------------------------------------------------------------------------------
-
-{-# LANGUAGE FlexibleInstances          #-}
-{-# LANGUAGE NoMonomorphismRestriction  #-}
-{-# LANGUAGE TupleSections              #-}
-{-# LANGUAGE TypeSynonymInstances       #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE OverloadedStrings          #-}
-
-
-module Language.Haskell.Liquid.Transforms.ANF (anormalize) where
-
-import           Prelude                          hiding (error)
-import           CoreSyn                          hiding (mkTyArg)
-import           CoreUtils                        (exprType)
-import qualified DsMonad
-import           DsMonad                          (initDsWithModGuts)
-import           GHC                              hiding (exprType)
-import           HscTypes
-import           Literal
-import           MkCore                           (mkCoreLets)
-import           Outputable                       (trace)
-import           Language.Haskell.Liquid.GHC.TypeRep
-import           Language.Haskell.Liquid.GHC.API  hiding (exprType, mkTyArg)
-import           VarEnv                           (VarEnv, emptyVarEnv, extendVarEnv, lookupWithDefaultVarEnv)
-import           UniqSupply                       (MonadUnique, getUniqueM)
-import           Control.Monad.State.Lazy
-import           System.Console.CmdArgs.Verbosity (whenLoud)
-import qualified Language.Fixpoint.Misc     as F
-import qualified Language.Fixpoint.Types    as F
-
-import           Language.Haskell.Liquid.UX.Config  as UX
-import qualified Language.Haskell.Liquid.Misc       as Misc 
-import           Language.Haskell.Liquid.GHC.Misc   as GM
-import           Language.Haskell.Liquid.Transforms.Rec
-import           Language.Haskell.Liquid.Transforms.Rewrite
-import           Language.Haskell.Liquid.Types.Errors
-
-import qualified Language.Haskell.Liquid.GHC.SpanStack as Sp
-import qualified Language.Haskell.Liquid.GHC.Resugar   as Rs
-import           Data.Maybe                       (fromMaybe)
-import           Data.List                        (sortBy, (\\))
-import           Data.Function                    (on)
-import qualified Text.Printf as Printf 
-
---------------------------------------------------------------------------------
--- | A-Normalize a module ------------------------------------------------------
---------------------------------------------------------------------------------
-anormalize :: UX.Config -> HscEnv -> ModGuts -> IO [CoreBind]
---------------------------------------------------------------------------------
-anormalize cfg hscEnv modGuts = do
-  whenLoud $ do
-    putStrLn "***************************** GHC CoreBinds ***************************"
-    putStrLn $ GM.showCBs untidy (mg_binds modGuts)
-    putStrLn "***************************** REC CoreBinds ***************************"
-    putStrLn $ GM.showCBs untidy orig_cbs
-    putStrLn "***************************** RWR CoreBinds ***************************"
-    putStrLn $ GM.showCBs untidy rwr_cbs
-  (fromMaybe err . snd) <$> initDsWithModGuts hscEnv modGuts act -- hscEnv m grEnv tEnv emptyFamInstEnv act
-    where
-      err      = panic Nothing "Oops, cannot A-Normalize GHC Core!"
-      act      = Misc.concatMapM (normalizeTopBind γ0) rwr_cbs
-      γ0       = emptyAnfEnv cfg
-      rwr_cbs  = rewriteBinds cfg orig_cbs
-      orig_cbs = transformRecExpr $ mg_binds modGuts
-      untidy   = UX.untidyCore cfg
-
-{-
-      m        = mgi_module modGuts
-      grEnv    = mgi_rdr_env modGuts
-      tEnv     = modGutsTypeEnv modGuts
-
-modGutsTypeEnv :: MGIModGuts -> TypeEnv
-modGutsTypeEnv mg  = typeEnvFromEntities ids tcs fis
-  where
-    ids            = bindersOfBinds (mgi_binds mg)
-    tcs            = mgi_tcs mg
-    fis            = mgi_fam_insts mg
--}
-
---------------------------------------------------------------------------------
--- | A-Normalize a @CoreBind@ --------------------------------------------------
---------------------------------------------------------------------------------
-
--- Can't make the below default for normalizeBind as it
--- fails tests/pos/lets.hs due to GHCs odd let-bindings
-
-normalizeTopBind :: AnfEnv -> Bind CoreBndr -> DsMonad.DsM [CoreBind]
-normalizeTopBind γ (NonRec x e)
-  = do e' <- runDsM $ evalStateT (stitch γ e) (DsST [])
-       return [normalizeTyVars $ NonRec x e']
-
-normalizeTopBind γ (Rec xes)
-  = do xes' <- runDsM $ execStateT (normalizeBind γ (Rec xes)) (DsST [])
-       return $ map normalizeTyVars (st_binds xes')
-
-normalizeTyVars :: Bind Id -> Bind Id
-normalizeTyVars (NonRec x e) = NonRec (setVarType x t') $ normalizeForAllTys e
-  where 
-    t'       = subst msg as as' bt
-    msg      = "WARNING: unable to renameVars on " ++ GM.showPpr x
-    as'      = fst $ splitForAllTys $ exprType e
-    (as, bt) = splitForAllTys (varType x)
-normalizeTyVars (Rec xes)    = Rec xes'
-  where 
-    nrec     = normalizeTyVars <$> ((\(x, e) -> NonRec x e) <$> xes)
-    xes'     = (\(NonRec x e) -> (x, e)) <$> nrec
-
-subst :: String -> [TyVar] -> [TyVar] -> Type -> Type
-subst msg as as' bt
-  | length as == length as'
-  = mkForAllTys (mkTyArg <$> as') $ substTy su bt
-  | otherwise
-  = trace msg $ mkForAllTys (mkTyArg <$> as) bt
-  where su = mkTvSubstPrs $ zip as (mkTyVarTys as')
-
--- | eta-expand CoreBinds with quantified types
-normalizeForAllTys :: CoreExpr -> CoreExpr
-normalizeForAllTys e = case e of
-  Lam b _ | isTyVar b
-    -> e
-  _ -> mkLams tvs (mkTyApps e (map mkTyVarTy tvs))
-  where
-  (tvs, _) = splitForAllTys (exprType e)
-
-
-newtype DsM a = DsM {runDsM :: DsMonad.DsM a}
-   deriving (Functor, Monad, MonadUnique, Applicative)
-
-data DsST = DsST { st_binds :: [CoreBind] }
-
-type DsMW = StateT DsST DsM
-
-------------------------------------------------------------------
-normalizeBind :: AnfEnv -> CoreBind -> DsMW ()
-------------------------------------------------------------------
-normalizeBind γ (NonRec x e)
-  = do e' <- normalize γ e
-       add [NonRec x e']
-
-normalizeBind γ (Rec xes)
-  = do es' <- mapM (stitch γ) es
-       add [Rec (zip xs es')]
-    where
-       (xs, es) = unzip xes
-
---------------------------------------------------------------------
-normalizeName :: AnfEnv -> CoreExpr -> DsMW CoreExpr
---------------------------------------------------------------------
-
--- normalizeNameDebug γ e
---   = liftM (tracePpr ("normalizeName" ++ showPpr e)) $ normalizeName γ e
-
-normalizeName γ e@(Lit l)
-  | shouldNormalize l
-  = normalizeLiteral γ e
-  | otherwise
-  = return e
-
-normalizeName γ (Var x)
-  = return $ Var (lookupAnfEnv γ x x)
-
-normalizeName _ e@(Type _)
-  = return e
-
-normalizeName γ e@(Coercion _)
-  = do x     <- lift $ freshNormalVar γ $ exprType e
-       add  [NonRec x e]
-       return $ Var x
-
-normalizeName γ (Tick tt e)
-  = do e'    <- normalizeName (γ `at` tt) e
-       return $ Tick tt e'
-
-normalizeName γ e
-  = do e'   <- normalize γ e
-       x    <- lift $ freshNormalVar γ $ exprType e
-       add [NonRec x e']
-       return $ Var x
-
-shouldNormalize :: Literal -> Bool
-shouldNormalize (LitNumber {})  = True 
-shouldNormalize (LitString {})    = True 
-shouldNormalize _               = False
-
-add :: [CoreBind] -> DsMW ()
-add w = modify $ \s -> s { st_binds = st_binds s ++ w}
-
---------------------------------------------------------------------------------
-normalizeLiteral :: AnfEnv -> CoreExpr -> DsMW CoreExpr
---------------------------------------------------------------------------------
-normalizeLiteral γ e =
-  do x <- lift $ freshNormalVar γ $ exprType e
-     add [NonRec x e]
-     return $ Var x
-
---------------------------------------------------------------------------------
-normalize :: AnfEnv -> CoreExpr -> DsMW CoreExpr
---------------------------------------------------------------------------------
-normalize γ e
-  | UX.patternFlag γ
-  , Just p <- Rs.lift e
-  = normalizePattern γ p
-
-normalize γ (Lam x e) | isTyVar x 
-  = do e' <- normalize γ e
-       return $ Lam x e'
-
-normalize γ (Lam x e)
-  = do e' <- stitch γ e
-       return $ Lam x e'
-
-normalize γ (Let b e)
-  = do normalizeBind γ b
-       normalize γ e
-       -- Need to float bindings all the way up to the top
-       -- Due to GHCs odd let-bindings (see tests/pos/lets.hs)
-
-normalize γ (Case e x t as)
-  = do n     <- normalizeName γ e
-       x'    <- lift $ freshNormalVar γ τx -- rename "wild" to avoid shadowing
-       let γ' = extendAnfEnv γ x x'
-       as'   <- forM as $ \(c, xs, e') -> liftM (c, xs,) (stitch (incrCaseDepth c γ') e')
-       as''  <- lift $ expandDefaultCase γ τx as'
-       return $ Case n x' t as''
-    where τx = GM.expandVarType x
-
-normalize γ (Var x)
-  = return $ Var (lookupAnfEnv γ x x)
-
-normalize _ e@(Lit _)
-  = return e
-
-normalize _ e@(Type _)
-  = return e
-
-normalize γ (Cast e τ)
-  = do e' <- normalizeName γ e
-       return $ Cast e' τ
-
-normalize γ (App e1 e2@(Type _))
-  = do e1' <- normalize γ e1
-       e2' <- normalize γ e2
-       return $ App e1' e2'
-
-normalize γ (App e1 e2)
-  = do e1' <- normalize γ e1
-       n2  <- normalizeName γ e2
-       return $ App e1' n2
-
-normalize γ (Tick tt e)
-  = do e' <- normalize (γ `at` tt) e
-       return $ Tick tt e'
-
-normalize _ (Coercion c)
-  = return $ Coercion c
-
---------------------------------------------------------------------------------
-stitch :: AnfEnv -> CoreExpr -> DsMW CoreExpr
---------------------------------------------------------------------------------
-stitch γ e
-  = do bs'   <- get
-       modify $ \s -> s { st_binds = [] }
-       e'    <- normalize γ e
-       bs    <- st_binds <$> get
-       put bs'
-       return $ mkCoreLets bs e'
-
-_mkCoreLets' :: [CoreBind] -> CoreExpr -> CoreExpr
-_mkCoreLets' bs e = mkCoreLets bs1 e1
-  where
-    (e1, bs1)    = GM.tracePpr "MKCORELETS" (e, bs)
-
---------------------------------------------------------------------------------
-normalizePattern :: AnfEnv -> Rs.Pattern -> DsMW CoreExpr
---------------------------------------------------------------------------------
-normalizePattern γ p@(Rs.PatBind {}) = do
-  -- don't normalize the >>= itself, we have a special typing rule for it
-  e1'   <- normalize γ (Rs.patE1 p)
-  e2'   <- stitch    γ (Rs.patE2 p)
-  return $ Rs.lower p { Rs.patE1 = e1', Rs.patE2 = e2' }
-
-normalizePattern γ p@(Rs.PatReturn {}) = do
-  e'    <- normalize γ (Rs.patE p)
-  return $ Rs.lower p { Rs.patE = e' }
-
-normalizePattern _ p@(Rs.PatProject {}) =
-  return (Rs.lower p)
-
-normalizePattern γ p@(Rs.PatSelfBind {}) = do
-  normalize γ (Rs.patE p)
-
-normalizePattern γ p@(Rs.PatSelfRecBind {}) = do
-  e'    <- normalize γ (Rs.patE p)
-  return $ Rs.lower p { Rs.patE = e' }
-
-
---------------------------------------------------------------------------------
-expandDefault :: AnfEnv -> Bool 
---------------------------------------------------------------------------------
-expandDefault γ = aeCaseDepth γ <= maxCaseExpand γ 
-
---------------------------------------------------------------------------------
-expandDefaultCase :: AnfEnv
-                  -> Type
-                  -> [(AltCon, [Id], CoreExpr)]
-                  -> DsM [(AltCon, [Id], CoreExpr)]
---------------------------------------------------------------------------------
-expandDefaultCase γ tyapp zs@((DEFAULT, _ ,_) : _) | expandDefault γ
-  = expandDefaultCase' γ tyapp zs
-
-expandDefaultCase γ tyapp@(TyConApp tc _) z@((DEFAULT, _ ,_):dcs)
-  = case tyConDataCons_maybe tc of
-       Just ds -> do let ds' = ds \\ [ d | (DataAlt d, _ , _) <- dcs]
-                     let n   = length ds'
-                     if n == 1
-                       then expandDefaultCase' γ tyapp z
-                       else if maxCaseExpand γ /= 2 
-                            then return z 
-                            else return (trace (expandMessage False γ n) z) 
-       Nothing -> return z --
-
-expandDefaultCase _ _ z
-   = return z
-
-expandDefaultCase' 
-  :: AnfEnv -> Type -> [(AltCon, [Id], c)] -> DsM [(AltCon, [Id], c)]
-expandDefaultCase' γ t ((DEFAULT, _, e) : dcs)
-  | Just dtss <- GM.defaultDataCons t (F.fst3 <$> dcs) = do 
-      dcs'    <- warnCaseExpand γ <$> forM dtss (cloneCase γ e)
-      return   $ sortCases (dcs' ++ dcs)
-expandDefaultCase' _ _ z
-   = return z 
-
-cloneCase :: AnfEnv -> e -> (DataCon, [TyVar], [Type]) -> DsM (AltCon, [Id], e)
-cloneCase γ e (d, as, ts) = do 
-  xs  <- mapM (freshNormalVar γ) ts 
-  return (DataAlt d, as ++ xs, e)
-
-sortCases :: [(AltCon, b, c)] -> [(AltCon, b, c)]
-sortCases = sortBy (cmpAltCon `on` F.fst3) 
-
-warnCaseExpand :: AnfEnv -> [a] -> [a] 
-warnCaseExpand γ xs  
-  | 10 < n          = trace (expandMessage True γ n) xs 
-  | otherwise       = xs
-  where 
-   n                = length xs 
-
-expandMessage :: Bool -> AnfEnv -> Int -> String 
-expandMessage expand γ n = unlines [msg1, msg2]   
-  where 
-    msg1            = Printf.printf "WARNING: (%s) %s DEFAULT with %d cases at depth %d" (showPpr sp) v1 n d 
-    msg2            = Printf.printf "%s expansion with --max-case-expand=%d" v2 d' 
-    (v1, v2, d') 
-      | expand      = ("Expanding"    , "Disable", d-1) :: (String, String, Int)
-      | otherwise   = ("Not expanding", "Enable" , d+1) 
-    d               = aeCaseDepth γ
-    sp              = Sp.srcSpan (aeSrcSpan γ)
-
---------------------------------------------------------------------------------
--- | ANF Environments ----------------------------------------------------------
---------------------------------------------------------------------------------
-freshNormalVar :: AnfEnv -> Type -> DsM Id
-freshNormalVar γ t = do
-  u     <- getUniqueM
-  let i  = getKey u
-  let sp = Sp.srcSpan (aeSrcSpan γ)
-  return (mkUserLocal (anfOcc i) u t sp)
-
-anfOcc :: Int -> OccName
-anfOcc = mkVarOccFS . GM.symbolFastString . F.intSymbol F.anfPrefix
-
-data AnfEnv = AnfEnv
-  { aeVarEnv    :: VarEnv Id
-  , aeSrcSpan   :: Sp.SpanStack
-  , aeCfg       :: UX.Config
-  , aeCaseDepth :: !Int
-  }
-
-instance UX.HasConfig AnfEnv where
-  getConfig = aeCfg
-
-emptyAnfEnv :: UX.Config -> AnfEnv
-emptyAnfEnv cfg = AnfEnv 
-  { aeVarEnv    = emptyVarEnv 
-  , aeSrcSpan   = Sp.empty 
-  , aeCfg       = cfg 
-  , aeCaseDepth = 1
-  }
-
-lookupAnfEnv :: AnfEnv -> Id -> Id -> Id
-lookupAnfEnv γ x y = lookupWithDefaultVarEnv (aeVarEnv γ) x y
-
-extendAnfEnv :: AnfEnv -> Id -> Id -> AnfEnv
-extendAnfEnv γ x y = γ { aeVarEnv = extendVarEnv (aeVarEnv γ) x y }
-
-incrCaseDepth :: AltCon -> AnfEnv -> AnfEnv 
-incrCaseDepth DEFAULT γ = γ { aeCaseDepth = 1 + aeCaseDepth γ }
-incrCaseDepth _       γ = γ 
-
-at :: AnfEnv -> Tickish Id -> AnfEnv
-at γ tt = γ { aeSrcSpan = Sp.push (Sp.Tick tt) (aeSrcSpan γ)}
diff --git a/src/Language/Haskell/Liquid/Transforms/CoreToLogic.hs b/src/Language/Haskell/Liquid/Transforms/CoreToLogic.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Transforms/CoreToLogic.hs
+++ /dev/null
@@ -1,641 +0,0 @@
-{-# LANGUAGE FlexibleInstances      #-}
-{-# LANGUAGE FlexibleContexts       #-}
-{-# LANGUAGE UndecidableInstances   #-}
-{-# LANGUAGE OverloadedStrings      #-}
-{-# LANGUAGE TupleSections          #-}
-
-module Language.Haskell.Liquid.Transforms.CoreToLogic
-  ( coreToDef
-  , coreToFun
-  , coreToLogic
-  , mkLit, mkI, mkS
-  , runToLogic
-  , runToLogicWithBoolBinds
-  , logicType
-  , inlineSpecType  
-  , measureSpecType
-  , weakenResult
-  , normalize
-  ) where
-
-import           Data.ByteString                       (ByteString)
-import           Prelude                               hiding (error)
-import           Language.Haskell.Liquid.GHC.TypeRep   () -- needed for Eq 'Type'
-import           Language.Haskell.Liquid.GHC.API       hiding (Expr, Located)
--- import qualified Id 
-import qualified Var
-import qualified TyCon 
-import           Coercion
-import qualified Pair
--- import qualified Text.Printf as Printf
-import qualified CoreSyn                               as C
-import           IdInfo
-import qualified Data.List                             as L
-import           Data.Maybe                            (listToMaybe) 
-import qualified Data.Text                             as T
-import qualified Data.Char 
-import qualified Text.Printf as Printf 
-import           Data.Text.Encoding
-import           Data.Text.Encoding.Error
-import           Control.Monad.State
-import           Control.Monad.Except
-import           Control.Monad.Identity
-import qualified Language.Fixpoint.Misc                as Misc 
-import           Language.Fixpoint.Types               hiding (panic, Error, R, simplify)
-import qualified Language.Fixpoint.Types               as F
-import qualified Language.Haskell.Liquid.GHC.Misc      as GM
-
-
-import           Language.Haskell.Liquid.Bare.Types 
-import           Language.Haskell.Liquid.Bare.DataType 
-import           Language.Haskell.Liquid.Bare.Misc     (simpleSymbolVar)
-import           Language.Haskell.Liquid.GHC.Play
-import           Language.Haskell.Liquid.Types.Types   --     hiding (GhcInfo(..), GhcSpec (..), LM)
-import           Language.Haskell.Liquid.Types.RefType
-
-import qualified Data.HashMap.Strict                   as M
-
-logicType :: (Reftable r) => Type -> RRType r
-logicType τ      = fromRTypeRep $ t { ty_binds = bs, ty_args = as, ty_refts = rs}
-  where
-    t            = toRTypeRep $ ofType τ
-    (bs, as, rs) = unzip3 $ dropWhile (isClassType . Misc.snd3) $ zip3 (ty_binds t) (ty_args t) (ty_refts t)
-
-{- | [NOTE:inlineSpecType type]: the refinement depends on whether the result type is a Bool or not:
-      CASE1: measure f@logic :: X -> Bool <=> f@haskell :: x:X -> {v:Bool | v <=> (f@logic x)}
-     CASE2: measure f@logic :: X -> Y    <=> f@haskell :: x:X -> {v:Y    | v = (f@logic x)}
- -}
--- formerly: strengthenResult
-inlineSpecType :: Var -> SpecType
-inlineSpecType v = fromRTypeRep $ rep {ty_res = res `strengthen` r , ty_binds = xs}
-  where
-    r              = MkUReft (mkR (mkEApp f (mkA <$> vxs))) mempty
-    rep            = toRTypeRep t
-    res            = ty_res rep
-    xs             = intSymbol (symbol ("x" :: String)) <$> [1..length $ ty_binds rep]
-    vxs            = dropWhile (isClassType . snd) $ zip xs (ty_args rep)
-    f              = dummyLoc (symbol v)
-    t              = ofType (GM.expandVarType v) :: SpecType
-    mkA            = EVar . fst 
-    mkR            = if isBool res then propReft else exprReft 
-
--- | Refine types of measures: keep going until you find the last data con!
---   this code is a hack! we refine the last data constructor,
---   it got complicated to support both
---   1. multi parameter measures     (see tests/pos/HasElem.hs)
---   2. measures returning functions (fromReader :: Reader r a -> (r -> a) )
---   TODO: SIMPLIFY by dropping support for multi parameter measures
-
--- formerly: strengthenResult'
-measureSpecType :: Var -> SpecType
-measureSpecType v = go mkT [] [1..] t
-  where 
-    mkR | boolRes   = propReft 
-        | otherwise = exprReft  
-    mkT xs          = MkUReft (mkR $ mkEApp f (EVar <$> reverse xs)) mempty
-    f               = dummyLoc (symbol v) 
-    t               = ofType (GM.expandVarType v) :: SpecType
-    boolRes         =  isBool $ ty_res $ toRTypeRep t 
-
-    go f args i (RAllT a t r)    = RAllT a (go f args i t) r 
-    go f args i (RAllP p t)      = RAllP p $ go f args i t
-    go f args i (RFun x t1 t2 r)
-     | isClassType t1           = RFun x t1 (go f args i t2) r
-    go f args i t@(RFun _ t1 t2 r)
-     | hasRApps t               = RFun x' t1 (go f (x':args) (tail i) t2) r
-                                       where x' = intSymbol (symbol ("x" :: String)) (head i)
-    go f args _ t                = t `strengthen` f args
-
-    hasRApps (RFun _ t1 t2 _) = hasRApps t1 || hasRApps t2
-    hasRApps (RApp {})        = True
-    hasRApps _                = False
-    
-   
--- | 'weakenResult foo t' drops the singleton constraint `v = foo x y` 
---   that is added, e.g. for measures in /strengthenResult'. 
---   This should only be used _when_ checking the body of 'foo' 
---   where the output, is, by definition, equal to the singleton.
-weakenResult :: Var -> SpecType -> SpecType 
-weakenResult v t = F.notracepp msg t'
-  where 
-    msg          = "weakenResult v =" ++ GM.showPpr v ++ " t = " ++ showpp t
-    t'           = fromRTypeRep $ rep { ty_res = mapExprReft weaken (ty_res rep) } 
-    rep          = toRTypeRep t
-    weaken x     = pAnd . filter ((Just vE /=) . isSingletonExpr x) . conjuncts 
-    vE           = mkEApp vF xs
-    xs           = EVar . fst <$> dropWhile (isClassType . snd) xts 
-    xts          = zip (ty_binds rep) (ty_args rep)
-    vF           = dummyLoc (symbol v)
-
-type LogicM = ExceptT Error (StateT LState Identity)
-
-data LState = LState
-  { lsSymMap  :: LogicMap
-  , lsError   :: String -> Error
-  , lsEmb     :: TCEmb TyCon
-  , lsBools   :: [Var]
-  , lsDCMap   :: DataConMap
-  }
-
-throw :: String -> LogicM a
-throw str = do
-  fmkError  <- lsError <$> get
-  throwError $ fmkError str
-
-getState :: LogicM LState
-getState = get
-
-runToLogic
-  :: TCEmb TyCon -> LogicMap -> DataConMap -> (String -> Error)
-  -> LogicM t -> Either Error t
-runToLogic = runToLogicWithBoolBinds []
-
-runToLogicWithBoolBinds
-  :: [Var] -> TCEmb TyCon -> LogicMap -> DataConMap -> (String -> Error)
-  -> LogicM t -> Either Error t
-runToLogicWithBoolBinds xs tce lmap dm ferror m
-  = evalState (runExceptT m) $ LState
-      { lsSymMap = lmap
-      , lsError  = ferror
-      , lsEmb    = tce
-      , lsBools  = xs
-      , lsDCMap  = dm
-      }
-
-coreAltToDef :: (Reftable r) => LocSymbol -> Var -> [Var] -> Var -> Type -> [C.CoreAlt] 
-             -> LogicM [Def (Located (RRType r)) DataCon]
-coreAltToDef x z zs y t alts  
-  | not (null litAlts) = measureFail x "Cannot lift definition with literal alternatives" 
-  | otherwise          = do 
-      d1s <- F.notracepp "coreAltDefs-1" <$> mapM (mkAlt x cc myArgs z) dataAlts 
-      d2s <- F.notracepp "coreAltDefs-2" <$>       mkDef x cc myArgs z  defAlts defExpr 
-      return (d1s ++ d2s)
-  where 
-    myArgs   = reverse zs
-    cc       = if eqType t boolTy then P else E 
-    defAlts  = GM.defaultDataCons (GM.expandVarType y) (Misc.fst3 <$> alts)
-    defExpr  = listToMaybe [ e |   (C.DEFAULT  , _, e) <- alts ]
-    dataAlts =             [ a | a@(C.DataAlt _, _, _) <- alts ]
-    litAlts  =             [ a | a@(C.LitAlt _, _, _) <- alts ]
-
-    -- mkAlt :: LocSymbol -> (Expr -> Body) -> [Var] -> Var -> (C.AltCon, [Var], C.CoreExpr)
-    mkAlt x ctor _args dx (C.DataAlt d, xs, e)
-      = Def x {- (toArgs id args) -} d (Just $ varRType dx) (toArgs Just xs') 
-      . ctor 
-      . (`subst1` (F.symbol dx, F.mkEApp (GM.namedLocSymbol d) (F.eVar <$> xs'))) 
-     <$> coreToLg e
-      where xs' = filter (not . GM.isEvVar) xs
-    mkAlt _ _ _ _ alt 
-      = throw $ "Bad alternative" ++ GM.showPpr alt
-
-    mkDef x ctor _args dx (Just dtss) (Just e) = do  
-      eDef   <- ctor <$> coreToLg e
-      -- let ys  = toArgs id args
-      let dxt = Just (varRType dx)
-      return  [ Def x {- ys -} d dxt (defArgs x ts) eDef | (d, _, ts) <- dtss ]
-    
-    mkDef _ _ _ _ _ _ = 
-      return [] 
-
-toArgs :: Reftable r => (Located (RRType r) -> b) -> [Var] -> [(Symbol, b)]
-toArgs f args = [(symbol x, f $ varRType x) | x <- args]
-
-defArgs :: Monoid r => LocSymbol -> [Type] -> [(Symbol, Maybe (Located (RRType r)))]
-defArgs x     = zipWith (\i t -> (defArg i, defRTyp t)) [0..] 
-  where 
-    defArg    = tempSymbol (val x)
-    defRTyp   = Just . F.atLoc x . ofType
-
-coreToDef :: Reftable r => LocSymbol -> Var -> C.CoreExpr
-          -> LogicM [Def (Located (RRType r)) DataCon]
-coreToDef x _ e                   = go [] $ inlinePreds $ simplify e
-  where
-    go args   (C.Lam  x e)        = go (x:args) e
-    go args   (C.Tick _ e)        = go args e
-    go (z:zs) (C.Case _ y t alts) = coreAltToDef x z zs y t alts 
-    go (z:zs) e                   
-      | Just t <- isMeasureArg z  = coreAltToDef x z zs z t [(C.DEFAULT, [], e)]
-    go _ _                        = measureFail x "Does not have a case-of at the top-level" 
-
-    inlinePreds   = inline (eqType boolTy . GM.expandVarType)
-
-measureFail       :: LocSymbol -> String -> a
-measureFail x msg = panic sp e 
-  where 
-    sp            = Just (GM.fSrcSpan x)
-    e             = Printf.printf "Cannot create measure '%s': %s" (F.showpp x) msg
-    
-
--- | 'isMeasureArg x' returns 'Just t' if 'x' is a valid argument for a measure.
-isMeasureArg :: Var -> Maybe Type 
-isMeasureArg x 
-  | Just tc <- tcMb 
-  , TyCon.isAlgTyCon tc = F.notracepp "isMeasureArg" $ Just t 
-  | otherwise           = Nothing 
-  where 
-    t                   = GM.expandVarType x  
-    tcMb                = tyConAppTyCon_maybe t
-
-
-varRType :: (Reftable r) => Var -> Located (RRType r)
-varRType = GM.varLocInfo ofType
-
-coreToFun :: LocSymbol -> Var -> C.CoreExpr ->  LogicM ([Var], Either Expr Expr)
-coreToFun _ _v e = go [] $ normalize e
-  where
-    go acc (C.Lam x e)  | isTyVar    x = go acc e
-    go acc (C.Lam x e)  | isErasable x = go acc e
-    go acc (C.Lam x e)  = go (x:acc) e
-    go acc (C.Tick _ e) = go acc e
-    go acc e            = (reverse acc,) . Right <$> coreToLg e
-    
-
-instance Show C.CoreExpr where
-  show = GM.showPpr
-
-coreToLogic :: C.CoreExpr -> LogicM Expr
-coreToLogic cb = coreToLg (normalize cb)
-
-
-coreToLg :: C.CoreExpr -> LogicM Expr
-coreToLg (C.Let b e)
-  = subst1 <$> coreToLg e <*>  makesub b
-coreToLg (C.Tick _ e)          = coreToLg e
-coreToLg (C.App (C.Var v) e)
-  | ignoreVar v                = coreToLg e
-coreToLg (C.Var x)
-  | x == falseDataConId        = return PFalse
-  | x == trueDataConId         = return PTrue
-  | otherwise                  = (lsSymMap <$> getState) >>= eVarWithMap x
-coreToLg e@(C.App _ _)         = toPredApp e
-coreToLg (C.Case e b _ alts)
-  | eqType (GM.expandVarType b) boolTy  = checkBoolAlts alts >>= coreToIte e
-coreToLg (C.Lam x e)           = do p     <- coreToLg e
-                                    tce   <- lsEmb <$> getState
-                                    return $ ELam (symbol x, typeSort tce (GM.expandVarType x)) p
-coreToLg (C.Case e b _ alts)   = do p <- coreToLg e
-                                    casesToLg b p alts
-coreToLg (C.Lit l)             = case mkLit l of
-                                   Nothing -> throw $ "Bad Literal in measure definition" ++ GM.showPpr l
-                                   Just i  -> return i
-coreToLg (C.Cast e c)          = do (s, t) <- coerceToLg c
-                                    e'     <- coreToLg   e
-                                    return (ECoerc s t e')
-coreToLg e                     = throw ("Cannot transform to Logic:\t" ++ GM.showPpr e)
-
-
-
-
-coerceToLg :: Coercion -> LogicM (Sort, Sort)
-coerceToLg = typeEqToLg . coercionTypeEq
-
-coercionTypeEq :: Coercion -> (Type, Type)
-coercionTypeEq co
-  | Pair.Pair s t <- -- GM.tracePpr ("coercion-type-eq-1: " ++ GM.showPpr co) $
-                       coercionKind co
-  = (s, t)
-
-typeEqToLg :: (Type, Type) -> LogicM (Sort, Sort)
-typeEqToLg (s, t) = do
-  tce   <- gets lsEmb
-  let tx = typeSort tce . expandTypeSynonyms
-  return $ F.notracepp "TYPE-EQ-TO-LOGIC" (tx s, tx t)
-
-checkBoolAlts :: [C.CoreAlt] -> LogicM (C.CoreExpr, C.CoreExpr)
-checkBoolAlts [(C.DataAlt false, [], efalse), (C.DataAlt true, [], etrue)]
-  | false == falseDataCon, true == trueDataCon
-  = return (efalse, etrue)
-
-checkBoolAlts [(C.DataAlt true, [], etrue), (C.DataAlt false, [], efalse)]
-  | false == falseDataCon, true == trueDataCon
-  = return (efalse, etrue)
-checkBoolAlts alts
-  = throw ("checkBoolAlts failed on " ++ GM.showPpr alts)
-
-casesToLg :: Var -> Expr -> [C.CoreAlt] -> LogicM Expr
-casesToLg v e alts = mapM (altToLg e) normAlts >>= go
-  where
-    normAlts       = normalizeAlts alts
-    go :: [(C.AltCon, Expr)] -> LogicM Expr
-    go [(_,p)]     = return (p `subst1` su)
-    go ((d,p):dps) = do c <- checkDataAlt d e
-                        e' <- go dps
-                        return (EIte c p e' `subst1` su)
-    go []          = panic (Just (getSrcSpan v)) "Unexpected empty cases in casesToLg"
-    su             = (symbol v, e)
-
-checkDataAlt :: C.AltCon -> Expr -> LogicM Expr
-checkDataAlt (C.DataAlt d) e = return $ EApp (EVar (makeDataConChecker d)) e
-checkDataAlt C.DEFAULT     _ = return PTrue
-checkDataAlt (C.LitAlt l)  e 
-  | Just le <- mkLit l       = return (EEq le e)  
-  | otherwise                = throw $ "Oops, not yet handled: checkDataAlt on Lit: " ++ GM.showPpr l
-
--- | 'altsDefault' reorders the CoreAlt to ensure that 'DEFAULT' is at the end.
-normalizeAlts :: [C.CoreAlt] -> [C.CoreAlt]
-normalizeAlts alts      = ctorAlts ++ defAlts 
-  where 
-    (defAlts, ctorAlts) = L.partition isDefault alts 
-    isDefault (c,_,_)   = c == C.DEFAULT 
-
-altToLg :: Expr -> C.CoreAlt -> LogicM (C.AltCon, Expr)
-altToLg de (a@(C.DataAlt d), xs, e) = do 
-  p  <- coreToLg e
-  dm <- gets lsDCMap
-  let su = mkSubst $ concat [ dataConProj dm de d x i | (x, i) <- zip (filter (not . GM.isEvVar) xs) [1..]]
-  return (a, subst su p)
-
-altToLg _ (a, _, e)
-  = (a, ) <$> coreToLg e
-
-dataConProj :: DataConMap -> Expr -> DataCon -> Var -> Int -> [(Symbol, Expr)]
-dataConProj dm de d x i = [(symbol x, t), (GM.simplesymbol x, t)]
-  where
-    t | primDataCon  d  = de 
-      | otherwise       = EApp (EVar $ makeDataConSelector (Just dm) d i) de
-
-primDataCon :: DataCon -> Bool 
-primDataCon d = d == intDataCon
-
-coreToIte :: C.CoreExpr -> (C.CoreExpr, C.CoreExpr) -> LogicM Expr
-coreToIte e (efalse, etrue)
-  = do p  <- coreToLg e
-       e1 <- coreToLg efalse
-       e2 <- coreToLg etrue
-       return $ EIte p e2 e1
-
-toPredApp :: C.CoreExpr -> LogicM Expr
-toPredApp p = go . Misc.mapFst opSym . splitArgs $ p
-  where
-    opSym = fmap GM.dropModuleNames . tomaybesymbol
-    go (Just f, [e1, e2])
-      | Just rel <- M.lookup f brels
-      = PAtom rel <$> coreToLg e1 <*> coreToLg e2
-    go (Just f, [e])
-      | f == symbol ("not" :: String)
-      = PNot <$>  coreToLg e
-    go (Just f, [e1, e2])
-      | f == symbol ("||" :: String)
-      = POr <$> mapM coreToLg [e1, e2]
-      | f == symbol ("&&" :: String)
-      = PAnd <$> mapM coreToLg [e1, e2]
-      | f == symbol ("==>" :: String)
-      = PImp <$> coreToLg e1 <*> coreToLg e2
-    go (Just f, [es])
-      | f == symbol ("or" :: String)
-      = POr  . deList <$> coreToLg es
-      | f == symbol ("and" :: String)
-      = PAnd . deList <$> coreToLg es
-    go (_, _)
-      = toLogicApp p
-    
-    deList :: Expr -> [Expr]
-    deList (EApp (EApp (EVar cons) e) es)
-      | cons == symbol ("GHC.Types.:" :: String)
-      = e:deList es 
-    deList (EVar nil)
-      | nil == symbol ("GHC.Types.[]" :: String)
-      = [] 
-    deList e 
-      = [e]
-
-toLogicApp :: C.CoreExpr -> LogicM Expr
-toLogicApp e = do
-  let (f, es) = splitArgs e
-  case f of
-    C.Var _ -> do args <- mapM coreToLg es
-                  lmap <- lsSymMap <$> getState
-                  def  <- (`mkEApp` args) <$> tosymbol f
-                  ((\x -> makeApp def lmap x args) <$> (tosymbol' f))
-    _       -> do fe   <- coreToLg f
-                  args <- mapM coreToLg es
-                  return $ foldl EApp fe args
-
-makeApp :: Expr -> LogicMap -> Located Symbol-> [Expr] -> Expr
-makeApp _ _ f [e] | val f == symbol ("GHC.Num.negate" :: String)
-  = ENeg e
-
-makeApp _ _ f [e1, e2] | Just op <- M.lookup (val f) bops
-  = EBin op e1 e2
-
-makeApp def lmap f es
-  = eAppWithMap lmap f es def
-  -- where msg = "makeApp f = " ++ show f ++ " es = " ++ show es ++ " def = " ++ show def
-
-eVarWithMap :: Id -> LogicMap -> LogicM Expr
-eVarWithMap x lmap = do
-  f'     <- tosymbol' (C.Var x :: C.CoreExpr)
-  -- let msg = "eVarWithMap x = " ++ show x ++ " f' = " ++ show f'
-  return $ eAppWithMap lmap f' [] (varExpr x)
-
-varExpr :: Var -> Expr
-varExpr x
-  | isPolyCst t = mkEApp (dummyLoc s) []
-  | otherwise   = EVar s
-  where
-    t           = GM.expandVarType x
-    s           = symbol x
-
-isPolyCst :: Type -> Bool
-isPolyCst (ForAllTy _ t) = isCst t
-isPolyCst _              = False
-
-isCst :: Type -> Bool
-isCst (ForAllTy _ t) = isCst t
-isCst (FunTy _ _ _)    = False
-isCst _              = True
-
-
-brels :: M.HashMap Symbol Brel
-brels = M.fromList [ (symbol ("==" :: String), Eq)
-                   , (symbol ("/=" :: String), Ne)
-                   , (symbol (">=" :: String), Ge)
-                   , (symbol (">" :: String) , Gt)
-                   , (symbol ("<=" :: String), Le)
-                   , (symbol ("<" :: String) , Lt)
-                   ]
-
-bops :: M.HashMap Symbol Bop
-bops = M.fromList [ (numSymbol "+", Plus)
-                  , (numSymbol "-", Minus)
-                  , (numSymbol "*", Times)
-                  , (numSymbol "/", Div)
-                  , (realSymbol "/", Div)
-                  , (numSymbol "%", Mod)
-                  ]
-  where
-    numSymbol :: String -> Symbol
-    numSymbol =  symbol . (++) "GHC.Num."
-    realSymbol :: String -> Symbol
-    realSymbol =  symbol . (++) "GHC.Real."
-
-splitArgs :: C.Expr t -> (C.Expr t, [C.Arg t])
-splitArgs e = (f, reverse es)
- where
-    (f, es) = go e
-
-    go (C.App (C.Var i) e) | ignoreVar i       = go e
-    go (C.App f (C.Var v)) | isErasable v      = go f
-    go (C.App f e) = (f', e:es) where (f', es) = go f
-    go f           = (f, [])
-
-tomaybesymbol :: C.CoreExpr -> Maybe Symbol
-tomaybesymbol (C.Var x) = Just $ symbol x
-tomaybesymbol _         = Nothing
-
-tosymbol :: C.CoreExpr -> LogicM (Located Symbol)
-tosymbol e
- = case tomaybesymbol e of
-    Just x -> return $ dummyLoc x
-    _      -> throw ("Bad Measure Definition:\n" ++ GM.showPpr e ++ "\t cannot be applied")
-
-tosymbol' :: C.CoreExpr -> LogicM (Located Symbol)
-tosymbol' (C.Var x) = return $ dummyLoc $ symbol x 
-tosymbol' e        = throw ("Bad Measure Definition:\n" ++ GM.showPpr e ++ "\t cannot be applied")
-
-makesub :: C.CoreBind -> LogicM (Symbol, Expr)
-makesub (C.NonRec x e) =  (symbol x,) <$> coreToLg e
-makesub  _             = throw "Cannot make Logical Substitution of Recursive Definitions"
-
-mkLit :: Literal -> Maybe Expr
-mkLit (LitNumber _ n _) = mkI n
--- mkLit (MachInt64  n)    = mkI n
--- mkLit (MachWord   n)    = mkI n
--- mkLit (MachWord64 n)    = mkI n
--- mkLit (LitInteger n _)  = mkI n
-mkLit (LitFloat  n)    = mkR n
-mkLit (LitDouble n)    = mkR n
-mkLit (LitString    s)    = mkS s
-mkLit (LitChar   c)    = mkC c 
-mkLit _                 = Nothing -- ELit sym sort
-
-mkI :: Integer -> Maybe Expr
-mkI = Just . ECon . I
-
-mkR :: Rational -> Maybe Expr
-mkR                    = Just . ECon . F.R . fromRational
-
-mkS :: ByteString -> Maybe Expr
-mkS                    = Just . ESym . SL  . decodeUtf8With lenientDecode
-
-mkC :: Char -> Maybe Expr
-mkC                    = Just . ECon . (`F.L` F.charSort)  . repr 
-  where 
-    repr               = T.pack . show . Data.Char.ord 
-
-ignoreVar :: Id -> Bool
-ignoreVar i = simpleSymbolVar i `elem` ["I#", "D#"]
-
-isBangInteger :: [C.CoreAlt] -> Bool 
-isBangInteger [(C.DataAlt s, _, _), (C.DataAlt jp,_,_), (C.DataAlt jn,_,_)] 
-  =  symbol s  == "GHC.Integer.Type.S#" 
-  && symbol jp == "GHC.Integer.Type.Jp#" 
-  && symbol jn == "GHC.Integer.Type.Jn#"  
-isBangInteger _ = False 
-
-isErasable :: Id -> Bool
-isErasable v = F.notracepp msg $ isGhcSplId v && not (isDCId v) 
-  where 
-    msg      = "isErasable: " ++ GM.showPpr (v, Var.idDetails v)
-
-isGhcSplId :: Id -> Bool
-isGhcSplId v = isPrefixOfSym (symbol ("$" :: String)) (simpleSymbolVar v)
-
-isDCId :: Id -> Bool
-isDCId v = case Var.idDetails v of 
-  DataConWorkId _ -> True 
-  DataConWrapId _ -> True 
-  _               -> False 
-
-isANF :: Id -> Bool
-isANF      v = isPrefixOfSym (symbol ("lq_anf" :: String)) (simpleSymbolVar v)
-
-isDead :: Id -> Bool
-isDead     = isDeadOcc . occInfo . Var.idInfo
-
-class Simplify a where
-  simplify :: a -> a
-  inline   :: (Id -> Bool) -> a -> a
-
-  normalize :: a -> a
-  normalize = inline_preds . inline_anf . simplify
-   where
-    inline_preds = inline (eqType boolTy . GM.expandVarType)
-    inline_anf   = inline isANF
-
-instance Simplify C.CoreExpr where
-  simplify e@(C.Var _)
-    = e
-  simplify e@(C.Lit _)
-    = e
-  simplify (C.App e (C.Type _))
-    = simplify e
-  simplify (C.App e (C.Var dict))  | isErasable dict
-    = simplify e
-  simplify (C.App (C.Lam x e) _)   | isDead x
-    = simplify e
-  simplify (C.App e1 e2)
-    = C.App (simplify e1) (simplify e2)
-  simplify (C.Lam x e) | isTyVar x
-    = simplify e
-  simplify (C.Lam x e) | isErasable x
-    = simplify e
-  simplify (C.Lam x e)
-    = C.Lam x (simplify e)
-  simplify (C.Let (C.NonRec x _) e) | isErasable x
-    = simplify e
-  simplify (C.Let (C.Rec xes) e)    | all (isErasable . fst) xes
-    = simplify e
-  simplify (C.Let xes e)
-    = C.Let (simplify xes) (simplify e)
-  simplify (C.Case e x _t alts@[(_,_,ee),_,_]) | isBangInteger alts
-    = Misc.traceShow ("To simplify case") $ 
-       sub (M.singleton x (simplify e)) (simplify ee)
-  simplify (C.Case e x t alts)
-    = C.Case (simplify e) x t (filter (not . isUndefined) (simplify <$> alts))
-  simplify (C.Cast e c)
-    = C.Cast (simplify e) c
-  simplify (C.Tick _ e)
-    = simplify e
-  simplify (C.Coercion c)
-    = C.Coercion c
-  simplify (C.Type t)
-    = C.Type t
-
-  inline p (C.Let (C.NonRec x ex) e) | p x
-                               = sub (M.singleton x (inline p ex)) (inline p e)
-  inline p (C.Let xes e)       = C.Let (inline p xes) (inline p e)
-  inline p (C.App e1 e2)       = C.App (inline p e1) (inline p e2)
-  inline p (C.Lam x e)         = C.Lam x (inline p e)
-  inline p (C.Case e x t alts) = C.Case (inline p e) x t (inline p <$> alts)
-  inline p (C.Cast e c)        = C.Cast (inline p e) c
-  inline p (C.Tick t e)        = C.Tick t (inline p e)
-  inline _ (C.Var x)           = C.Var x
-  inline _ (C.Lit l)           = C.Lit l
-  inline _ (C.Coercion c)      = C.Coercion c
-  inline _ (C.Type t)          = C.Type t
-
-isUndefined :: (t, t1, C.Expr t2) -> Bool
-isUndefined (_, _, e) = isUndefinedExpr e
-  where
-   -- auto generated undefined case: (\_ -> (patError @type "error message")) void
-   isUndefinedExpr (C.App (C.Var x) _) | (show x) `elem` perrors = True
-   isUndefinedExpr (C.Let _ e) = isUndefinedExpr e
-   -- otherwise
-   isUndefinedExpr _ = False
-
-   perrors = ["Control.Exception.Base.patError"]
-
-
-instance Simplify C.CoreBind where
-  simplify (C.NonRec x e) = C.NonRec x (simplify e)
-  simplify (C.Rec xes)    = C.Rec (Misc.mapSnd simplify <$> xes )
-
-  inline p (C.NonRec x e) = C.NonRec x (inline p e)
-  inline p (C.Rec xes)    = C.Rec (Misc.mapSnd (inline p) <$> xes)
-
-instance Simplify C.CoreAlt where
-  simplify (c, xs, e) = (c, xs, simplify e)
-    -- where xs   = F.tracepp _msg xs0
-    --      _msg = "isCoVars? " ++ F.showpp [(x, isCoVar x, varType x) | x <- xs0]
-  inline p (c, xs, e) = (c, xs, inline p e)
diff --git a/src/Language/Haskell/Liquid/Transforms/Rec.hs b/src/Language/Haskell/Liquid/Transforms/Rec.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Transforms/Rec.hs
+++ /dev/null
@@ -1,302 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable        #-}
-{-# LANGUAGE FlexibleContexts          #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE ScopedTypeVariables       #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-
-module Language.Haskell.Liquid.Transforms.Rec (
-     transformRecExpr, transformScope
-     , outerScTr , innerScTr
-     , isIdTRecBound, setIdTRecBound
-     ) where
-
--- import           Bag
--- import           ErrUtils
-import           Coercion
-import           Control.Arrow                        (second)
-import           Control.Monad.State
-import           CoreSyn
-import           CoreUtils
-import qualified Data.HashMap.Strict                  as M
-import           Data.Hashable
-import           Id
-import           IdInfo
-import           Language.Haskell.Liquid.GHC.API      hiding (exprType)
-import           Language.Haskell.Liquid.GHC.Misc
-import           Language.Haskell.Liquid.GHC.Play
-import           Language.Haskell.Liquid.Misc         (mapSndM)
-import           Language.Fixpoint.Misc               (mapSnd) -- , traceShow)
-import           Language.Haskell.Liquid.Types.Errors
-import           MkCore                               (mkCoreLams)
-import           Prelude                              hiding (error)
-
-import qualified Data.List                            as L
-
-
-transformRecExpr :: CoreProgram -> CoreProgram
-transformRecExpr cbs = pg
-  -- TODO-REBARE weird GHC crash on Data/Text/Array.hs | isEmptyBag $ filterBag isTypeError e
-  -- TODO-REBARE weird GHC crash on Data/Text/Array.hs = pg
-  -- TODO-REBARE weird GHC crash on Data/Text/Array.hs | otherwise
-  -- TODO-REBARE weird GHC crash on Data/Text/Array.hs = panic Nothing ("Type-check" ++ showSDoc (pprMessageBag e))
-  where 
-    pg     = inlineFailCases pg0
-    pg0    = evalState (transPg (inlineLoopBreaker <$> cbs)) initEnv
-    -- (_, e) = lintCoreBindings [] pg
-
-
-
-
-inlineLoopBreaker :: Bind Id -> Bind Id
-inlineLoopBreaker (NonRec x e) | Just (lbx, lbe) <- hasLoopBreaker be
-  = Rec [(x, foldr Lam (sub (M.singleton lbx e') lbe) (αs ++ as))]
-  where
-    (αs, as, be) = collectTyAndValBinders e
-
-    e' = L.foldl' App (L.foldl' App (Var x) ((Type . TyVarTy) <$> αs)) (Var <$> as)
-
-    hasLoopBreaker (Let (Rec [(x1, e1)]) (Var x2)) | isLoopBreaker x1 && x1 == x2 = Just (x1, e1)
-    hasLoopBreaker _                               = Nothing
-
-    isLoopBreaker =  isStrongLoopBreaker . occInfo . idInfo
-
-inlineLoopBreaker bs
-  = bs
-
-inlineFailCases :: CoreProgram -> CoreProgram
-inlineFailCases = (go [] <$>)
-  where
-    go su (Rec xes)    = Rec (mapSnd (go' su) <$> xes)
-    go su (NonRec x e) = NonRec x (go' su e)
-
-    go' su (App (Var x) _)       | isFailId x, Just e <- getFailExpr x su = e
-    go' su (Let (NonRec x ex) e) | isFailId x   = go' (addFailExpr x (go' su ex) su) e
-
-    go' su (App e1 e2)      = App (go' su e1) (go' su e2)
-    go' su (Lam x e)        = Lam x (go' su e)
-    go' su (Let xs e)       = Let (go su xs) (go' su e)
-    go' su (Case e x t alt) = Case (go' su e) x t (goalt su <$> alt)
-    go' su (Cast e c)       = Cast (go' su e) c
-    go' su (Tick t e)       = Tick t (go' su e)
-    go' _  e                = e
-
-    goalt su (c, xs, e)     = (c, xs, go' su e)
-
-    isFailId x  = isLocalId x && (isSystemName $ varName x) && L.isPrefixOf "fail" (show x)
-    getFailExpr = L.lookup
-
-    addFailExpr x (Lam _ e) su = (x, e):su
-    addFailExpr _ _         _  = impossible Nothing "internal error" -- this cannot happen
-
--- isTypeError :: SDoc -> Bool
--- isTypeError s | isInfixOf "Non term variable" (showSDoc s) = False
--- isTypeError _ = True
-
--- No need for this transformation after ghc-8!!!
-transformScope :: [Bind Id] -> [Bind Id]
-transformScope = outerScTr . innerScTr 
-
-outerScTr :: [Bind Id] -> [Bind Id]
-outerScTr = mapNonRec (go [])
-  where
-   go ack x (xe : xes) | isCaseArg x xe = go (xe:ack) x xes
-   go ack _ xes        = ack ++ xes
-
-isCaseArg :: Id -> Bind t -> Bool
-isCaseArg x (NonRec _ (Case (Var z) _ _ _)) = z == x
-isCaseArg _ _                               = False
-
-innerScTr :: Functor f => f (Bind Id) -> f (Bind Id)
-innerScTr = (mapBnd scTrans <$>)
-
-scTrans :: Id -> Expr Id -> Expr Id
-scTrans x e = mapExpr scTrans $ foldr Let e0 bs
-  where (bs, e0)           = go [] x e
-        go bs x (Let b e)  | isCaseArg x b = go (b:bs) x e
-        go bs x (Tick t e) = second (Tick t) $ go bs x e
-        go bs _ e          = (bs, e)
-
-type TE = State TrEnv
-
-data TrEnv = Tr { freshIndex  :: !Int
-                , _loc        :: SrcSpan
-                }
-
-initEnv :: TrEnv
-initEnv = Tr 0 noSrcSpan
-
-transPg :: Traversable t
-        => t (Bind CoreBndr)
-        -> State TrEnv (t (Bind CoreBndr))
-transPg = mapM transBd
-
-transBd :: Bind CoreBndr
-        -> State TrEnv (Bind CoreBndr)
-transBd (NonRec x e) = liftM (NonRec x) (transExpr =<< mapBdM transBd e)
-transBd (Rec xes)    = liftM Rec $ mapM (mapSndM (mapBdM transBd)) xes
-
-transExpr :: CoreExpr -> TE CoreExpr
-transExpr e
-  | (isNonPolyRec e') && (not (null tvs))
-  = trans tvs ids bs e'
-  | otherwise
-  = return e
-  where (tvs, ids, e'')       = collectTyAndValBinders e
-        (bs, e')              = collectNonRecLets e''
-
-isNonPolyRec :: Expr CoreBndr -> Bool
-isNonPolyRec (Let (Rec xes) _) = any nonPoly (snd <$> xes)
-isNonPolyRec _                 = False
-
-nonPoly :: CoreExpr -> Bool
-nonPoly = null . fst . splitForAllTys . exprType
-
-collectNonRecLets :: Expr t -> ([Bind t], Expr t)
-collectNonRecLets = go []
-  where go bs (Let b@(NonRec _ _) e') = go (b:bs) e'
-        go bs e'                      = (reverse bs, e')
-
-appTysAndIds :: [Var] -> [Id] -> Id -> Expr b
-appTysAndIds tvs ids x = mkApps (mkTyApps (Var x) (map TyVarTy tvs)) (map Var ids)
-
-trans :: Foldable t
-      => [TyVar]
-      -> [Var]
-      -> t (Bind Id)
-      -> Expr Var
-      -> State TrEnv (Expr Id)
-trans vs ids bs (Let (Rec xes) e)
-  = liftM (mkLam . mkLet) (makeTrans vs liveIds e')
-  where liveIds = mkAlive <$> ids
-        mkLet e = foldr Let e bs
-        mkLam e = foldr Lam e $ vs ++ liveIds
-        e'      = Let (Rec xes') e
-        xes'    = (second mkLet) <$> xes
-
-trans _ _ _ _ = panic Nothing "TransformRec.trans called with invalid input"
-
-makeTrans :: [TyVar]
-          -> [Var]
-          -> Expr Var
-          -> State TrEnv (Expr Var)
-makeTrans vs ids (Let (Rec xes) e)
- = do fids    <- mapM (mkFreshIds vs ids) xs
-      let (ids', ys) = unzip fids
-      let yes  = appTysAndIds vs ids <$> ys
-      ys'     <- mapM fresh xs
-      let su   = M.fromList $ zip xs (Var <$> ys')
-      let rs   = zip ys' yes
-      let es'  = zipWith (mkE ys) ids' es
-      let xes' = zip ys es'
-      return   $ mkRecBinds rs (Rec xes') (sub su e)
- where
-   (xs, es)       = unzip xes
-   mkSu ys ids'   = mkSubs ids vs ids' (zip xs ys)
-   mkE ys ids' e' = mkCoreLams (vs ++ ids') (sub (mkSu ys ids') e')
-
-makeTrans _ _ _ = panic Nothing "TransformRec.makeTrans called with invalid input"
-
-mkRecBinds :: [(b, Expr b)] -> Bind b -> Expr b -> Expr b
-mkRecBinds xes rs e = Let rs (L.foldl' f e xes)
-  where f e (x, xe) = Let (NonRec x xe) e
-
-mkSubs :: (Eq k, Hashable k)
-       => [k] -> [Var] -> [Id] -> [(k, Id)] -> M.HashMap k (Expr b)
-mkSubs ids tvs xs ys = M.fromList $ s1 ++ s2
-  where s1 = (second (appTysAndIds tvs xs)) <$> ys
-        s2 = zip ids (Var <$> xs)
-
-mkFreshIds :: [TyVar]
-           -> [Var]
-           -> Var
-           -> State TrEnv ([Var], Id)
-mkFreshIds tvs ids x
-  = do ids'  <- mapM fresh ids
-       let ids'' = map setIdTRecBound ids'
-       let t  = mkForAllTys ((`Bndr` Required) <$> tvs) $ mkType (reverse ids'') $ varType x
-       let x' = setVarType x t
-       return (ids'', x')
-  where
-    mkType ids ty = foldl (\t x -> FunTy VisArg (varType x) t) ty ids -- FIXME(adinapoli): Is 'VisArg' OK here?
-
--- NOTE [Don't choose transform-rec binders as decreasing params]
--- --------------------------------------------------------------
---
--- We don't want to select a binder created by TransformRec as the
--- decreasing parameter, since the user didn't write it. Furthermore,
--- consider T1065. There we have an inner loop that decreases on the
--- sole list parameter. But TransformRec prepends the parameters to the
--- outer `groupByFB` to the inner `groupByFBCore`, and now the first
--- decreasing parameter is the constant `xs0`. Disaster!
---
--- So we need a way to signal to L.H.L.Constraint.Generate that we
--- should ignore these copied Vars. The easiest way to do that is to set
--- a flag on the Var that we know won't be set, and it just so happens
--- GHC has a bunch of optional flags that can be set by various Core
--- analyses that we don't run...
-setIdTRecBound :: Id -> Id
--- This is an ugly hack..
-setIdTRecBound = modifyIdInfo (`setCafInfo` NoCafRefs)
-
-isIdTRecBound :: Id -> Bool
-isIdTRecBound = not . mayHaveCafRefs . cafInfo . idInfo
-
-class Freshable a where
-  fresh :: a -> TE a
-
-instance Freshable Int where
-  fresh _ = freshInt
-
-instance Freshable Unique where
-  fresh _ = freshUnique
-
-instance Freshable Var where
-  fresh v = liftM (setVarUnique v) freshUnique
-
-freshInt :: MonadState TrEnv m => m Int
-freshInt
-  = do s <- get
-       let n = freshIndex s
-       put s{freshIndex = n+1}
-       return n
-
-freshUnique :: MonadState TrEnv m => m Unique
-freshUnique = liftM (mkUnique 'X') freshInt
-
-
-mapNonRec :: (b -> [Bind b] -> [Bind b]) -> [Bind b] -> [Bind b]
-mapNonRec f (NonRec x xe:xes) = NonRec x xe : f x (mapNonRec f xes)
-mapNonRec f (xe:xes)          = xe : mapNonRec f xes
-mapNonRec _ []                = []
-
-mapBnd :: (b -> Expr b -> Expr b) -> Bind b -> Bind b
-mapBnd f (NonRec b e)             = NonRec b (mapExpr f  e)
-mapBnd f (Rec bs)                 = Rec (map (second (mapExpr f)) bs)
-
-mapExpr :: (b -> Expr b -> Expr b) -> Expr b -> Expr b
-mapExpr f (Let (NonRec x ex) e)   = Let (NonRec x (f x ex) ) (f x e)
-mapExpr f (App e1 e2)             = App  (mapExpr f e1) (mapExpr f e2)
-mapExpr f (Lam b e)               = Lam b (mapExpr f e)
-mapExpr f (Let bs e)              = Let (mapBnd f bs) (mapExpr f e)
-mapExpr f (Case e b t alt)        = Case e b t (map (mapAlt f) alt)
-mapExpr f (Tick t e)              = Tick t (mapExpr f e)
-mapExpr _  e                      = e
-
-mapAlt :: (b -> Expr b -> Expr b) -> (t, t1, Expr b) -> (t, t1, Expr b)
-mapAlt f (d, bs, e) = (d, bs, mapExpr f e)
-
--- Do not apply transformations to inner code
-
-mapBdM :: Monad m => t -> a -> m a
-mapBdM _ = return
-
--- mapBdM f (Let b e)        = liftM2 Let (f b) (mapBdM f e)
--- mapBdM f (App e1 e2)      = liftM2 App (mapBdM f e1) (mapBdM f e2)
--- mapBdM f (Lam b e)        = liftM (Lam b) (mapBdM f e)
--- mapBdM f (Case e b t alt) = liftM (Case e b t) (mapM (mapBdAltM f) alt)
--- mapBdM f (Tick t e)       = liftM (Tick t) (mapBdM f e)
--- mapBdM _  e               = return  e
---
--- mapBdAltM f (d, bs, e) = liftM ((,,) d bs) (mapBdM f e)
diff --git a/src/Language/Haskell/Liquid/Transforms/RefSplit.hs b/src/Language/Haskell/Liquid/Transforms/RefSplit.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Transforms/RefSplit.hs
+++ /dev/null
@@ -1,117 +0,0 @@
-{-# LANGUAGE FlexibleInstances    #-}
-{-# LANGUAGE UndecidableInstances #-}
-
-module Language.Haskell.Liquid.Transforms.RefSplit (
-
-        splitXRelatedRefs
-
-        ) where
-
-import Prelude hiding (error)
-
-import Data.List (partition)
-import Text.PrettyPrint.HughesPJ
-
-import Language.Haskell.Liquid.Types
-import Language.Haskell.Liquid.Types.PrettyPrint ()
-
-import Language.Fixpoint.Types hiding (Predicate)
-import Language.Fixpoint.Misc
-
-splitXRelatedRefs :: Symbol -> SpecType -> (SpecType, SpecType)
-splitXRelatedRefs x t = splitRType x t
-
-
-
-splitRType :: Symbol
-           -> RType c tv (UReft Reft)
-           -> (RType c tv (UReft Reft), RType c tv (UReft Reft))
-splitRType f (RVar a r) = (RVar a r1, RVar a r2)
-  where
-        (r1, r2) = splitRef f r
-splitRType f (RImpF x tx t r) = (RImpF x tx1 t1 r1, RImpF x tx2 t2 r2)
-  where
-        (tx1, tx2) = splitRType f tx
-        (t1,  t2)  = splitRType f t
-        (r1,  r2)  = splitRef   f r
-splitRType f (RFun x tx t r) = (RFun x tx1 t1 r1, RFun x tx2 t2 r2)
-  where
-        (tx1, tx2) = splitRType f tx
-        (t1,  t2)  = splitRType f t
-        (r1,  r2)  = splitRef   f r
-splitRType f (RAllT v t r) = (RAllT v t1 r1, RAllT v t2 r2)
-  where
-        (t1, t2) = splitRType f t
-        (r1,  r2)  = splitRef   f r
-splitRType f (RAllP p t) = (RAllP p t1, RAllP p t2)
-  where
-        (t1, t2) = splitRType f t
-splitRType f (RApp c ts rs r) = (RApp c ts1 rs1 r1, RApp c ts2 rs2 r2)
-  where
-        (ts1, ts2) = unzip (splitRType f <$> ts)
-        (rs1, rs2) = unzip (splitUReft f <$> rs)
-        (r1,  r2)  = splitRef f r
-splitRType f (RAllE x tx t) = (RAllE x tx1 t1, RAllE x tx2 t2)
-  where
-        (tx1, tx2) = splitRType f tx
-        (t1, t2)   = splitRType f t
-splitRType f (REx x tx t) = (REx x tx1 t1, REx x tx2 t2)
-  where
-        (tx1, tx2) = splitRType f tx
-        (t1, t2)   = splitRType f t
-splitRType _ (RExprArg e) = (RExprArg e, RExprArg e)
-splitRType f (RAppTy tx t r) = (RAppTy tx1 t1 r1, RAppTy tx2 t2 r2)
-  where
-        (tx1, tx2) = splitRType f tx
-        (t1,  t2)  = splitRType f t
-        (r1,  r2)  = splitRef   f r
-splitRType f (RRTy xs r o t) = (RRTy xs1 r1 o t1, RRTy xs2 r2 o t2)
-  where
-        (xs1, xs2) = unzip (go <$> xs)
-        (r1, r2) = splitRef   f r
-        (t1, t2) = splitRType f t
-
-        go (x, t) = let (t1, t2) = splitRType f t in ((x,t1), (x, t2))
-splitRType f (RHole r) = (RHole r1, RHole r2)
-  where
-        (r1, r2) = splitRef f r
-
-
-splitUReft :: Symbol -> RTProp c tv (UReft Reft) -> (RTProp c tv (UReft Reft), RTProp c tv (UReft Reft))
-splitUReft x (RProp xs (RHole r)) = (RProp xs (RHole r1), RProp xs (RHole r2))
-  where
-        (r1, r2) = splitRef x r
-splitUReft x (RProp xs t) = (RProp xs t1, RProp xs t2)
-  where
-        (t1, t2) = splitRType x t
-
-splitRef :: Symbol -> UReft Reft -> (UReft Reft, UReft Reft)
-splitRef f (MkUReft r p) = (MkUReft r1 p1, MkUReft r2 p2)
-        where
-                (r1, r2) = splitReft f r
-                (p1, p2) = splitPred f p
-
-splitReft :: Symbol -> Reft -> (Reft, Reft)
-splitReft f (Reft (v, xs)) = (Reft (v, pAnd xs1), Reft (v, pAnd xs2))
-  where
-    (xs1, xs2)       = partition (isFree f) (unPAnd xs)
-
-    unPAnd (PAnd ps) = concatMap unPAnd ps
-    unPAnd p         = [p]
-
-
-splitPred :: Symbol -> Predicate -> (Predicate, Predicate)
-splitPred f (Pr ps) = (Pr ps1, Pr ps2)
-  where
-    (ps1, ps2) = partition g ps
-    g p = any (isFree f) (thd3 <$> pargs p)
-
-
-class IsFree a where
-        isFree :: Symbol -> a -> Bool
-
-instance (Subable x) => (IsFree x) where
-        isFree x p = x `elem` syms p
-
-instance Show (UReft Reft) where
-         show = render . pprint
diff --git a/src/Language/Haskell/Liquid/Transforms/Rewrite.hs b/src/Language/Haskell/Liquid/Transforms/Rewrite.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Transforms/Rewrite.hs
+++ /dev/null
@@ -1,457 +0,0 @@
-{-# LANGUAGE CPP                       #-}
-{-# LANGUAGE OverloadedStrings         #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE GADTs                     #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE RankNTypes                #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE UndecidableInstances      #-}
-{-# LANGUAGE FlexibleContexts          #-}
-
--- | This module contains functions for recursively "rewriting"
---   GHC core using "rules".
-
-module Language.Haskell.Liquid.Transforms.Rewrite
-  ( -- * Top level rewrite function
-    rewriteBinds
-
-  -- * Low-level Rewriting Function
-  -- , rewriteWith
-
-  -- * Rewrite Rule
-  -- ,  RewriteRule
-
-  ) where
-
-import           CoreSyn
-import           Language.Haskell.Liquid.GHC.API
-import           Language.Haskell.Liquid.GHC.TypeRep ()
-import qualified CoreUtils
-import qualified Var
-import qualified MkCore
-import           Data.Maybe     (fromMaybe)
-import           Control.Monad.State hiding (lift)
-import           Language.Fixpoint.Misc       ({- mapFst, -}  mapSnd)
-import qualified          Language.Fixpoint.Types as F
-import           Language.Haskell.Liquid.Misc (safeZipWithError, mapThd3, Nat)
-import           Language.Haskell.Liquid.GHC.Play (substExpr)
-import           Language.Haskell.Liquid.GHC.Resugar
-import           Language.Haskell.Liquid.GHC.Misc (unTickExpr, isTupleId, showPpr, mkAlive) -- , showPpr, tracePpr)
-import           Language.Haskell.Liquid.UX.Config  (Config, noSimplifyCore)
-import qualified Data.List as L
-import qualified Data.HashMap.Strict as M
-
---------------------------------------------------------------------------------
--- | Top-level rewriter --------------------------------------------------------
---------------------------------------------------------------------------------
-rewriteBinds :: Config -> [CoreBind] -> [CoreBind]
-rewriteBinds cfg
-  | simplifyCore cfg 
-  = fmap (normalizeTuples . rewriteBindWith tidyTuples . rewriteBindWith simplifyPatTuple)
-  | otherwise        
-  = id
-
-simplifyCore :: Config -> Bool
-simplifyCore = not . noSimplifyCore
-
-tidyTuples :: RewriteRule
-tidyTuples e = Just $ evalState (go e) []
-  where
-    go (Tick t e)
-      = Tick t <$> go e
-    go (Let (NonRec x ex) e)
-      = do ex' <- go ex
-           e'  <- go e
-           return $ Let (NonRec x ex') e'
-    go (Let (Rec bes) e)
-      = Let <$> (Rec <$> mapM goRec bes) <*> go e
-    go (Case (Var v) x t alts)
-      = Case (Var v) x t <$> mapM (goAltR v) alts
-    go (Case e x t alts)
-      = Case e x t <$> mapM goAlt alts
-    go (App e1 e2)
-      = App <$> go e1 <*> go e2
-    go (Lam x e)
-      = Lam x <$> go e
-    go (Cast e c)
-      = (`Cast` c) <$> go e
-    go e
-      = return e
-
-    goRec (x, e)
-      = (x,) <$> go e
-
-    goAlt (c, bs, e)
-      = (c, bs,) <$> go e
-
-    goAltR v (c, bs, e)
-      = do m <- get
-           case L.lookup (c,v) m of
-            Just bs' -> return (c, bs', substTuple bs' bs e)
-            Nothing  -> do let bs' = mkAlive <$> bs
-                           modify (((c,v),bs'):)
-                           return $ (c, bs', e)
-
-
-
-normalizeTuples :: CoreBind -> CoreBind
-normalizeTuples b 
-  | NonRec x e <- b 
-  = NonRec x $ go e 
-  | Rec xes <- b 
-  = let (xs,es) = unzip xes in 
-    Rec $ zip xs (go <$> es) 
-  where 
-    go (Let (NonRec x ex) e)
-      | Case _ _ _ alts  <- unTickExpr ex 
-      , [(_, vs, Var z)] <- alts 
-      , z `elem` vs
-      = Let (NonRec z (go ex)) (substTuple [z] [x] (go e)) 
-    go (Let (NonRec x ex) e)
-      = Let (NonRec x (go ex)) (go e)
-    go (Let (Rec xes) e)
-      = Let (Rec (mapSnd go <$> xes)) (go e)
-    go (App e1 e2)
-      = App (go e1) (go e2)
-    go (Lam x e)
-      = Lam x (go e)
-    go (Case e b t alt)
-      = Case (go e) b t (mapThd3 go <$> alt)
-    go (Cast e c)
-      = Cast (go e) c 
-    go (Tick t e)
-      = Tick t (go e)
-    go (Type t)
-      = Type t 
-    go (Coercion c)
-      = Coercion c
-    go (Lit l)
-      = Lit l 
-    go (Var x)
-      = Var x 
-
-
---------------------------------------------------------------------------------
--- | A @RewriteRule@ is a function that maps a CoreExpr to another
---------------------------------------------------------------------------------
-type RewriteRule = CoreExpr -> Maybe CoreExpr
---------------------------------------------------------------------------------
-
---------------------------------------------------------------------------------
-rewriteBindWith :: RewriteRule -> CoreBind -> CoreBind
---------------------------------------------------------------------------------
-rewriteBindWith r (NonRec x e) = NonRec x (rewriteWith r e)
-rewriteBindWith r (Rec xes)    = Rec    (mapSnd (rewriteWith r) <$> xes)
-
---------------------------------------------------------------------------------
-rewriteWith :: RewriteRule -> CoreExpr -> CoreExpr
---------------------------------------------------------------------------------
-rewriteWith tx           = go
-  where
-    go                   = txTop . step
-    txTop e              = fromMaybe e (tx e)
-    goB (Rec xes)        = Rec         (mapSnd go <$> xes)
-    goB (NonRec x e)     = NonRec x    (go e)
-    step (Let b e)       = Let (goB b) (go e)
-    step (App e e')      = App (go e)  (go e')
-    step (Lam x e)       = Lam x       (go e)
-    step (Cast e c)      = Cast (go e) c
-    step (Tick t e)      = Tick t      (go e)
-    step (Case e x t cs) = Case (go e) x t (mapThd3 go <$> cs)
-    step e@(Type _)      = e
-    step e@(Lit _)       = e
-    step e@(Var _)       = e
-    step e@(Coercion _)  = e
-
-
---------------------------------------------------------------------------------
--- | Rewriting Pattern-Match-Tuples --------------------------------------------
---------------------------------------------------------------------------------
-
-{-
-    let CrazyPat x1 ... xn = e in e'
-
-    let t : (t1,...,tn) = "CrazyPat e ... (y1, ..., yn)"
-        xn = Proj t n
-        ...
-        x1 = Proj t 1
-    in
-        e'
-
-    "crazy-pat"
- -}
-
-{- [NOTE] The following is the structure of a @PatMatchTup@
-
-      let x :: (t1,...,tn) = E[(x1,...,xn)]
-          yn = case x of (..., yn) -> yn
-          …
-          y1 = case x of (y1, ...) -> y1
-      in
-          E'
-
-  GOAL: simplify the above to:
-
-      E [ (x1,...,xn) := E' [y1 := x1,...,yn := xn] ]
-
-  TODO: several tests (e.g. tests/pos/zipper000.hs) fail because
-  the above changes the "type" the expression `E` and in "other branches"
-  the new type may be different than the old, e.g.
-
-     let (x::y::_) = e in
-     x + y
-
-     let t = case e of
-               h1::t1 -> case t1 of
-                            (h2::t2) ->  (h1, h2)
-                            DEFAULT  ->  error @ (Int, Int)
-               DEFAULT   -> error @ (Int, Int)
-         x = case t of (h1, _) -> h1
-         y = case t of (_, h2) -> h2
-     in
-         x + y
-
-  is rewritten to:
-
-              h1::t1    -> case t1 of
-                            (h2::t2) ->  h1 + h2
-                            DEFAULT  ->  error @ (Int, Int)
-              DEFAULT   -> error @ (Int, Int)
-
-     case e of
-       h1 :: h2 :: _ -> h1 + h2
-       DEFAULT       -> error @ (Int, Int)
-
-  which, alas, is ill formed.
-
--}
-
---------------------------------------------------------------------------------
-
--- simplifyPatTuple :: RewriteRule
--- simplifyPatTuple e =
---  case simplifyPatTuple' e of
---    Just e' -> if CoreUtils.exprType e == CoreUtils.exprType e'
---                 then Just e'
---                 else Just (tracePpr ("YIKES: RWR " ++ showPpr e) e')
---    Nothing -> Nothing
-
-
-_safeSimplifyPatTuple :: RewriteRule
-_safeSimplifyPatTuple e
-  | Just e' <- simplifyPatTuple e
-  , CoreUtils.exprType e' == CoreUtils.exprType e
-  = Just e'
-  | otherwise
-  = Nothing
-
---------------------------------------------------------------------------------
-simplifyPatTuple :: RewriteRule
---------------------------------------------------------------------------------
-
-_tidyAlt :: Int -> Maybe CoreExpr -> Maybe CoreExpr
-
-_tidyAlt n (Just (Let (NonRec x e) rest))
-  | Just (yes, e') <- takeBinds n rest
-  = Just $ Let (NonRec x e) $ foldl (\e (x, ex) -> Let (NonRec x ex) e) e' ((reverse $ go $ reverse yes))
-
-  where
-    go xes@((_, e):_) = let bs = grapBinds e in mapSnd (replaceBinds bs) <$> xes
-    go [] = []
-    replaceBinds bs (Case c x t alt) = Case c x t (replaceBindsAlt bs <$> alt)
-    replaceBinds bs (Tick t e)       = Tick t (replaceBinds bs e)
-    replaceBinds _ e                 = e
-    replaceBindsAlt bs (c, _, e)     = (c, bs, e)
-
-    grapBinds (Case _ _ _ alt) = grapBinds' alt
-    grapBinds (Tick _ e) = grapBinds e
-    grapBinds _ = []
-    grapBinds' [] = []
-    grapBinds' ((_,bs,_):_) = bs
-
-_tidyAlt _ e
-  = e
-
-simplifyPatTuple (Let (NonRec x e) rest)
-  | Just (n, ts  ) <- varTuple x
-  , 2 <= n
-  , Just (yes, e') <- takeBinds n rest
-  , let ys          = fst <$> yes
-  , Just _         <- hasTuple ys e
-  , matchTypes yes ts
-  = replaceTuple ys e e'
-
-simplifyPatTuple _
-  = Nothing
-
-varTuple :: Var -> Maybe (Int, [Type])
-varTuple x
-  | TyConApp c ts <- Var.varType x
-  , isTupleTyCon c
-  = Just (length ts, ts)
-  | otherwise
-  = Nothing
-
-takeBinds  :: Nat -> CoreExpr -> Maybe ([(Var, CoreExpr)], CoreExpr)
-takeBinds n e
-  | n < 2     = Nothing
-  | otherwise = {- mapFst reverse <$> -} go n e
-    where
-      go 0 e                      = Just ([], e)
-      go n (Let (NonRec x e) e')  = do (xes, e'') <- go (n-1) e'
-                                       Just ((x,e) : xes, e'')
-      go _ _                      = Nothing
-
-matchTypes :: [(Var, CoreExpr)] -> [Type] -> Bool
-matchTypes xes ts =  xN == tN
-                  && all (uncurry eqType) (safeZipWithError msg xts ts)
-                  && all isProjection es
-  where
-    xN            = length xes
-    tN            = length ts
-    xts           = Var.varType <$> xs
-    (xs, es)      = unzip xes
-    msg           = "RW:matchTypes"
-
-isProjection :: CoreExpr -> Bool
-isProjection e = case lift e of
-                   Just (PatProject {}) -> True
-                   _                    -> False
-
---------------------------------------------------------------------------------
--- | `hasTuple ys e` CHECKS if `e` contains a tuple that "looks like" (y1...yn)
---------------------------------------------------------------------------------
-hasTuple :: [Var] -> CoreExpr -> Maybe [Var]
---------------------------------------------------------------------------------
-hasTuple ys = stepE
-  where
-    stepE e
-     | Just xs <- isVarTup ys e = Just xs
-     | otherwise                = go e
-    stepA (DEFAULT,_,_)         = Nothing
-    stepA (_, _, e)             = stepE e
-    go (Let _ e)                = stepE e
-    go (Case _ _ _ cs)          = msum (stepA <$> cs)
-    go _                        = Nothing
-
---------------------------------------------------------------------------------
--- | `replaceTuple ys e e'` REPLACES tuples that "looks like" (y1...yn) with e'
---------------------------------------------------------------------------------
-
-replaceTuple :: [Var] -> CoreExpr -> CoreExpr -> Maybe CoreExpr
-replaceTuple ys e e'           = stepE e
-  where
-    t'                          = CoreUtils.exprType e'
-    stepE e
-     | Just xs <- isVarTup ys e = Just $ substTuple xs ys e'
-     | otherwise                = go e
-    stepA (DEFAULT, xs, err)    = Just (DEFAULT, xs, replaceIrrefutPat t' err)
-    stepA (c, xs, e)            = (c, xs,)   <$> stepE e
-    go (Let b e)                = Let b      <$> stepE e
-    go (Case e x t cs)          = fixCase e x t <$> mapM stepA cs
-    go _                        = Nothing
-
-_showExpr :: CoreExpr -> String
-_showExpr e = show' e
-  where
-    show' (App e1 e2) = show' e1 ++ " " ++ show' e2
-    show' (Var x)     = _showVar x
-    show' (Let (NonRec x ex) e) = "Let " ++ _showVar x ++ " = " ++ show' ex ++ "\nIN " ++ show' e
-    show' (Tick _ e) = show' e
-    show' (Case e x _ alt) = "Case " ++ _showVar x ++ " = " ++ show' e ++ " OF " ++ unlines (showAlt' <$> alt)
-    show' e           = showPpr e
-
-    showAlt' (c, bs, e) = showPpr c ++ unwords (_showVar <$> bs) ++ " -> " ++ show' e
-
-_showVar :: Var -> String
-_showVar = show . F.symbol
-
-_errorSkip :: String -> a -> b
-_errorSkip x _ = error x
-
--- replaceTuple :: [Var] -> CoreExpr -> CoreExpr -> Maybe CoreExpr
--- replaceTuple ys e e' = tracePpr msg (_replaceTuple ys e e')
---  where
---    msg = "replaceTuple: ys = " ++ showPpr ys ++
---                        " e = " ++ showPpr e  ++
---                        " e' =" ++ showPpr e'
-
--- | The substitution (`substTuple`) can change the type of the overall
---   case-expression, so we must update the type of each `Case` with its
---   new, possibly updated type. See:
---   https://github.com/ucsd-progsys/liquidhaskell/pull/752#issuecomment-228946210
-
-fixCase :: CoreExpr -> Var -> Type -> ListNE (Alt Var) -> CoreExpr
-fixCase e x _t cs' = Case e x t' cs'
-  where
-    t'            = CoreUtils.exprType body
-    (_,_,body)    = c
-    c:_           = cs'
-
-{-@  type ListNE a = {v:[a] | len v > 0} @-}
-type ListNE a = [a]
-
-replaceIrrefutPat :: Type -> CoreExpr -> CoreExpr
-replaceIrrefutPat t (App (Lam z e) eVoid)
-  | Just e' <- replaceIrrefutPat' t e
-  = App (Lam z e') eVoid
-
-replaceIrrefutPat t e
-  | Just e' <- replaceIrrefutPat' t e
-  = e'
-
-replaceIrrefutPat _ e
-  = e
-
-replaceIrrefutPat' :: Type -> CoreExpr -> Maybe CoreExpr
-replaceIrrefutPat' t e
-  | (Var x, rep:_:args) <- collectArgs e
-  , isIrrefutErrorVar x
-  = Just (MkCore.mkCoreApps (Var x) (rep : Type t : args))
-  | otherwise
-  = Nothing
-
-isIrrefutErrorVar :: Var -> Bool
--- isIrrefutErrorVar _x = False -- MkCore.iRREFUT_PAT_ERROR_ID == x -- TODO:GHC-863
-isIrrefutErrorVar x = x == MkCore.pAT_ERROR_ID
- 
---------------------------------------------------------------------------------
--- | `substTuple xs ys e'` returns e' [y1 := x1,...,yn := xn]
---------------------------------------------------------------------------------
-substTuple :: [Var] -> [Var] -> CoreExpr -> CoreExpr
-substTuple xs ys = substExpr (M.fromList $ zip ys xs)
-
---------------------------------------------------------------------------------
--- | `isVarTup xs e` returns `Just ys` if e == (y1, ... , yn) and xi ~ yi
---------------------------------------------------------------------------------
-
-isVarTup :: [Var] -> CoreExpr -> Maybe [Var]
-isVarTup xs e
-  | Just ys <- isTuple e
-  , eqVars xs ys        = Just ys
-isVarTup _ _             = Nothing
-
-eqVars :: [Var] -> [Var] -> Bool
-eqVars xs ys = {- F.tracepp ("eqVars: " ++ show xs' ++ show ys') -} xs' == ys'
-  where
-    xs' = {- F.symbol -} show <$> xs
-    ys' = {- F.symbol -} show <$> ys
-
-isTuple :: CoreExpr -> Maybe [Var]
-isTuple e
-  | (Var t, es) <- collectArgs e
-  , isTupleId t
-  , Just xs     <- mapM isVar (secondHalf es)
-  = Just xs
-  | otherwise
-  = Nothing
-
-isVar :: CoreExpr -> Maybe Var
-isVar (Var x) = Just x
-isVar _       = Nothing
-
-secondHalf :: [a] -> [a]
-secondHalf xs = drop (n `div` 2) xs
-  where
-    n         = length xs
diff --git a/src/Language/Haskell/Liquid/Transforms/Simplify.hs b/src/Language/Haskell/Liquid/Transforms/Simplify.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Transforms/Simplify.hs
+++ /dev/null
@@ -1,43 +0,0 @@
-module Language.Haskell.Liquid.Transforms.Simplify (simplifyBounds) where
-
-import Prelude hiding (error)
-import Language.Haskell.Liquid.Types
-import Language.Fixpoint.Types
-import Language.Fixpoint.Types.Visitor
--- import Control.Applicative                 ((<$>))
-
-
-simplifyBounds :: SpecType -> SpecType
-simplifyBounds = fmap go
-  where
-    go x       = x { ur_reft = go' $ ur_reft x }
-    -- OLD go' (Reft (v, rs)) = Reft(v, filter (not . isBoundLike) rs)
-    go' (Reft (v, p)) = Reft(v, dropBoundLike p)
-
-dropBoundLike :: Expr -> Expr
-dropBoundLike p
-  | isKvar p          = p
-  | isBoundLikePred p = mempty
-  | otherwise         = p
-  where
-    isKvar            = not . null . kvars
-
-isBoundLikePred :: Expr -> Bool
-isBoundLikePred (PAnd ps) = simplifyLen <= length [p | p <- ps, isImp p ]
-isBoundLikePred _         = False
-
-isImp :: Expr -> Bool
-isImp (PImp _ _) = True
-isImp _          = False
-
--- OLD isBoundLike (RConc pred)  = isBoundLikePred pred
--- OLD isBoundLike (RKvar _ _)   = False
-
-
--- OLD moreThan 0 _            = True
--- OLD moreThan _ []           = False
--- OLD moreThan i (True  : xs) = moreThan (i-1) xs
--- OLD moreThan i (False : xs) = moreThan i xs
-
-simplifyLen :: Int
-simplifyLen = 5
diff --git a/src/Language/Haskell/Liquid/Types.hs b/src/Language/Haskell/Liquid/Types.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types.hs
+++ /dev/null
@@ -1,17 +0,0 @@
--- | This module re-exports a bunch of the Types modules 
-
-module Language.Haskell.Liquid.Types (module Types) where 
-
-import Language.Haskell.Liquid.Types.Types          as Types
-import Language.Haskell.Liquid.Types.Dictionaries   as Types
-import Language.Haskell.Liquid.Types.Fresh          as Types
-import Language.Haskell.Liquid.Types.Meet           as Types
-import Language.Haskell.Liquid.Types.PredType       as Types
-import Language.Haskell.Liquid.Types.RefType        as Types
-import Language.Haskell.Liquid.Types.Variance       as Types
-import Language.Haskell.Liquid.Types.Bounds         as Types
-import Language.Haskell.Liquid.Types.Literals       as Types
-import Language.Haskell.Liquid.Types.Names          as Types
-import Language.Haskell.Liquid.Types.PrettyPrint    as Types
-import Language.Haskell.Liquid.Types.Specs          as Types
-import Language.Haskell.Liquid.Types.Visitors       as Types
diff --git a/src/Language/Haskell/Liquid/Types/Bounds.hs b/src/Language/Haskell/Liquid/Types/Bounds.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Bounds.hs
+++ /dev/null
@@ -1,160 +0,0 @@
-{-# LANGUAGE FlexibleContexts   #-}
-{-# LANGUAGE TupleSections      #-}
-{-# LANGUAGE OverloadedStrings  #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DeriveGeneric      #-}
-
-module Language.Haskell.Liquid.Types.Bounds (
-
-    Bound(..),
-
-    RBound, RRBound,
-
-    RBEnv, RRBEnv,
-
-    makeBound,
-
-    ) where
-
-import Prelude hiding (error)
-import Text.PrettyPrint.HughesPJ
-import GHC.Generics
-import Data.List (partition)
-import Data.Maybe
-import Data.Hashable
-import Data.Bifunctor
-import Data.Data
-import qualified Data.Binary         as B
-import qualified Data.HashMap.Strict as M
-
-import qualified Language.Fixpoint.Types as F
-import qualified Language.Fixpoint.Misc  as Misc -- (mapFst, mapSnd)
-import Language.Haskell.Liquid.Types.Types
-import Language.Haskell.Liquid.Types.RefType
-
-
-data Bound t e = Bound
-  { bname   :: LocSymbol         -- ^ The name of the bound
-  , tyvars  :: [t]               -- ^ Type variables that appear in the bounds
-  , bparams :: [(LocSymbol, t)]  -- ^ These are abstract refinements, for now
-  , bargs   :: [(LocSymbol, t)]  -- ^ These are value variables
-  , bbody   :: e                 -- ^ The body of the bound
-  } deriving (Data, Typeable, Generic)
-
-instance (B.Binary t, B.Binary e) => B.Binary (Bound t e)
-
-type RBound        = RRBound RSort
-type RRBound tv    = Bound tv F.Expr
-type RBEnv         = M.HashMap LocSymbol RBound
-type RRBEnv tv     = M.HashMap LocSymbol (RRBound tv)
-
-
-instance Hashable (Bound t e) where
-  hashWithSalt i = hashWithSalt i . bname
-
-instance Eq (Bound t e) where
-  b1 == b2 = bname b1 == bname b2
-
-instance (PPrint e, PPrint t) => (Show (Bound t e)) where
-  show = showpp
-
-
-instance (PPrint e, PPrint t) => (PPrint (Bound t e)) where
-  pprintTidy k (Bound s vs ps xs e) = "bound" <+> pprintTidy k s <+>
-                                      "forall" <+> pprintTidy k vs <+> "." <+>
-                                      pprintTidy k (fst <$> ps) <+> "=" <+>
-                                      ppBsyms k (fst <$> xs) <+> pprintTidy k e
-    where
-      ppBsyms _ [] = ""
-      ppBsyms k xs = "\\" <+> pprintTidy k xs <+> "->"
-
-instance Bifunctor Bound where
-  first  f (Bound s vs ps xs e) = Bound s (f <$> vs) (Misc.mapSnd f <$> ps) (Misc.mapSnd f <$> xs) e
-  second f (Bound s vs ps xs e) = Bound s vs ps xs (f e)
-
-makeBound :: (PPrint r, UReftable r, SubsTy RTyVar (RType RTyCon RTyVar ()) r)
-          => RRBound RSort -> [RRType r] -> [F.Symbol] -> RRType r -> RRType r
-makeBound (Bound _  vs ps xs p) ts qs
-         = RRTy cts mempty OCons
-  where
-    cts  = (\(x, t) -> (x, foldr subsTyVar_meet t su)) <$> cts'
-
-    cts' = makeBoundType penv rs xs
-
-    penv = zip (val . fst <$> ps) qs
-    rs   = bkImp [] p
-
-    bkImp acc (F.PImp p q) = bkImp (p:acc) q
-    bkImp acc p          = p:acc
-
-    su  = [(α, toRSort t, t) | (RVar α _, t) <-  zip vs ts ]
-
-makeBoundType :: (PPrint r, UReftable r)
-              => [(F.Symbol, F.Symbol)]
-              -> [F.Expr]
-              -> [(LocSymbol, RSort)]
-              -> [(F.Symbol, RRType r)]
-makeBoundType penv (q:qs) xts = go xts
-  where
-    -- NV TODO: Turn this into a proper error
-    go [] = panic Nothing "Bound with empty symbols"
-
-    go [(x, t)]      = [(F.dummySymbol, tp t x), (F.dummySymbol, tq t x)]
-    go ((x, t):xtss) = (val x, mkt t x) : go xtss
-
-    mkt t x = ofRSort t `strengthen` ofUReft (MkUReft (F.Reft (val x, mempty))
-                                                (Pr $ M.lookupDefault [] (val x) ps))
-    tp t x  = ofRSort t `strengthen` ofUReft (MkUReft (F.Reft (val x, F.pAnd rs))
-                                                (Pr $ M.lookupDefault [] (val x) ps))
-    tq t x  = ofRSort t `strengthen` makeRef penv x q
-
-    (ps, rs) = partitionPs penv qs
-
-
--- NV TODO: Turn this into a proper error
-makeBoundType _ _ _           = panic Nothing "Bound with empty predicates"
-
-
-partitionPs :: [(F.Symbol, F.Symbol)] -> [F.Expr] -> (M.HashMap F.Symbol [UsedPVar], [F.Expr])
-partitionPs penv qs = Misc.mapFst makeAR $ partition (isPApp penv) qs
-  where
-    makeAR ps       = M.fromListWith (++) $ map (toUsedPVars penv) ps
-
-isPApp :: [(F.Symbol, a)] -> F.Expr -> Bool
-isPApp penv (F.EApp (F.EVar p) _)  = isJust $ lookup p penv
-isPApp penv (F.EApp e _)         = isPApp penv e
-isPApp _    _                  = False
-
-toUsedPVars :: [(F.Symbol, F.Symbol)] -> F.Expr -> (F.Symbol, [PVar ()])
-toUsedPVars penv q@(F.EApp _ e) = (x, [toUsedPVar penv q])
-  where
-    -- NV : TODO make this a better error
-    x = case {- unProp -} e of {F.EVar x -> x; e -> todo Nothing ("Bound fails in " ++ show e) }
-toUsedPVars _ _ = impossible Nothing "This cannot happen"
-
-toUsedPVar :: [(F.Symbol, F.Symbol)] -> F.Expr -> PVar ()
-toUsedPVar penv ee@(F.EApp _ _)
-  = PV q (PVProp ()) e (((), F.dummySymbol,) <$> es')
-   where
-     F.EVar e = {- unProp $ -} last es
-     es'    = init es
-     Just q = lookup p penv
-     (F.EVar p, es) = F.splitEApp ee
-
-toUsedPVar _ _ = impossible Nothing "This cannot happen"
-
--- `makeRef` is used to make the refinement of the last implication,
--- thus it can contain both concrete and abstract refinements
-
-makeRef :: (UReftable r) => [(F.Symbol, F.Symbol)] -> LocSymbol -> F.Expr -> r
-makeRef penv v (F.PAnd rs) = ofUReft (MkUReft (F.Reft (val v, F.pAnd rrs)) r)
-  where
-    r                    = Pr  (toUsedPVar penv <$> pps)
-    (pps, rrs)           = partition (isPApp penv) rs
-
-makeRef penv v rr
-  | isPApp penv rr       = ofUReft (MkUReft (F.Reft(val v, mempty)) r)
-  where
-    r                    = Pr [toUsedPVar penv rr]
-
-makeRef _    v p         = F.ofReft (F.Reft (val v, p))
diff --git a/src/Language/Haskell/Liquid/Types/Dictionaries.hs b/src/Language/Haskell/Liquid/Types/Dictionaries.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Dictionaries.hs
+++ /dev/null
@@ -1,98 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleContexts     #-}
-{-# LANGUAGE TupleSections        #-}
-module Language.Haskell.Liquid.Types.Dictionaries (
-    makeDictionaries
-  , makeDictionary
-  , dfromList
-  , dmapty
-  , dmap
-  , dinsert
-  , dlookup
-  , dhasinfo
-  , fromRISig
-  ) where
-
-import           Data.Hashable
--- import           Data.Maybe (catMaybes)
-
-import           Prelude                                   hiding (error)
-import           Var
-import           Name                                      (getName)
-import qualified Language.Fixpoint.Types as F
-import           Language.Haskell.Liquid.Types.PrettyPrint ()
-import qualified Language.Haskell.Liquid.GHC.Misc       as GM 
-import qualified Language.Haskell.Liquid.GHC.API        as Ghc 
-import           Language.Haskell.Liquid.Types.Types
--- import           Language.Haskell.Liquid.Types.Visitors (freeVars)
-import           Language.Haskell.Liquid.Types.RefType ()
-import           Language.Fixpoint.Misc                (mapFst)
-import qualified Data.HashMap.Strict                       as M
-
-
-
-
-
-makeDictionaries :: [RInstance LocSpecType] -> DEnv F.Symbol LocSpecType
-makeDictionaries = DEnv . M.fromList . map makeDictionary
-
-
-makeDictionary :: RInstance LocSpecType -> (F.Symbol, M.HashMap F.Symbol (RISig LocSpecType))
-makeDictionary (RI c ts xts) = (makeDictionaryName (btc_tc c) ts, M.fromList (mapFst val <$> xts))
-
-makeDictionaryName :: LocSymbol -> [LocSpecType] -> F.Symbol
-makeDictionaryName t ts
-  = F.notracepp _msg $ F.symbol ("$f" ++ F.symbolString (val t) ++ concatMap mkName ts)
-  where
-    mkName = makeDicTypeName sp . dropUniv . val 
-    sp     = GM.fSrcSpan t
-    _msg   = "MAKE-DICTIONARY " ++ F.showpp (val t, ts)
-
--- | @makeDicTypeName@ DOES NOT use show/symbol in the @RVar@ case 
---   as those functions add the unique-suffix which then breaks the 
---   class resolution.
-
-makeDicTypeName :: Ghc.SrcSpan -> SpecType -> String
-makeDicTypeName _ (RFun _ _ _ _)   = "(->)"
-makeDicTypeName _ (RApp c _ _ _)   = F.symbolString . GM.dropModuleNamesCorrect . F.symbol . rtc_tc $ c
-makeDicTypeName _ (RVar (RTV a) _) = show (getName a)      
-makeDicTypeName sp t               = panic (Just sp) ("makeDicTypeName: called with invalid type " ++ show t)
-
-dropUniv :: SpecType -> SpecType 
-dropUniv t = t' where (_,_,t') = bkUniv t 
-
---------------------------------------------------------------------------------
--- | Dictionary Environment ----------------------------------------------------
---------------------------------------------------------------------------------
-
-dfromList :: [(Var, M.HashMap F.Symbol (RISig t))] -> DEnv Var t
-dfromList = DEnv . M.fromList
-
-dmapty :: (a -> b) -> DEnv v a -> DEnv v b
-dmapty f (DEnv e) = DEnv (M.map (M.map (fmap f)) e)
-
--- REBARE: mapRISig :: (a -> b) -> RISig a -> RISig b
--- REBARE: mapRISig f (RIAssumed t) = RIAssumed (f t)
--- REBARE: mapRISig f (RISig     t) = RISig     (f t)
-
-fromRISig :: RISig a -> a
-fromRISig (RIAssumed t) = t
-fromRISig (RISig     t) = t
-
-dmap :: (v1 -> v2) -> M.HashMap k v1 -> M.HashMap k v2
-dmap f xts = M.map f xts
-
-dinsert :: (Eq x, Hashable x)
-        => DEnv x ty -> x -> M.HashMap F.Symbol (RISig ty) -> DEnv x ty
-dinsert (DEnv denv) x xts = DEnv $ M.insert x xts denv
-
-dlookup :: (Eq k, Hashable k)
-        => DEnv k t -> k -> Maybe (M.HashMap F.Symbol (RISig t))
-dlookup (DEnv denv) x     = M.lookup x denv
-
-
-dhasinfo :: (F.Symbolic a1, Show a) => Maybe (M.HashMap F.Symbol a) -> a1 -> Maybe a
-dhasinfo Nothing _    = Nothing
-dhasinfo (Just xts) x = M.lookup x' xts
-  where
-     x'               = GM.dropModuleNamesCorrect (F.symbol x)
diff --git a/src/Language/Haskell/Liquid/Types/Equality.hs b/src/Language/Haskell/Liquid/Types/Equality.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Equality.hs
+++ /dev/null
@@ -1,86 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-
--- Syntactic Equality of Types up tp forall type renaming
-
-module Language.Haskell.Liquid.Types.Equality where 
-
-import qualified Language.Fixpoint.Types as F
-import           Language.Haskell.Liquid.Types
-import qualified Language.Haskell.Liquid.GHC.API as Ghc
-
-import Control.Monad.Writer.Lazy
--- import Control.Monad
-import qualified Data.List as L
-
-instance REq SpecType where 
-  t1 =*= t2 = compareRType t1 t2 
-  
-compareRType :: SpecType -> SpecType -> Bool 
-compareRType i1 i2 = res && unify vs   
-  where 
-    unify vs = and (sndEq <$> (L.groupBy (\(x1,_) (x2,_) -> x1 == x2) vs)) 
-    sndEq [] = True 
-    sndEq [_] = True 
-    sndEq ((_,y):xs) = all (==y) (snd <$> xs)
-
-    (res, vs) = runWriter (go i1 i2)
-    go :: SpecType -> SpecType -> Writer [(RTyVar, RTyVar)] Bool  
-    go (RAllT x1 t1 r1) (RAllT x2 t2 r2)
-      | RTV v1 <- ty_var_value x1
-      , RTV v2 <- ty_var_value x2 
-      , r1 =*= r2
-      = go t1 (subt (v2, Ghc.mkTyVarTy v1) t2) 
-
-    go (RVar v1 r1) (RVar v2 r2) 
-      = do tell [(v1, v2)]
-           return (r1 =*= r2) 
-     -- = v1 == v2 && r1 =*= r2 
-    go (RFun x1 t11 t12 r1) (RFun x2 t21 t22 r2)
-      | x1 == x2 && r1 =*= r2
-      = liftM2 (&&) (go t11 t21) (go t12 t22)
-    go (RImpF x1 t11 t12 r1) (RImpF x2 t21 t22 r2)
-      | x1 == x2    && r1 =*= r2
-      = liftM2 (&&) (go t11 t21) (go t12 t22)    
-    go (RAllP x1 t1) (RAllP x2 t2)
-      | x1 == x2 
-      = go t1 t2 
-    go (RApp x1 ts1 ps1 r1) (RApp x2 ts2 ps2 r2)
-      | x1 == x2 &&  
-        r1 =*= r2 && and (zipWith (=*=) ps1 ps2) 
-      = and <$> (zipWithM go ts1 ts2)
-    go (RAllE x1 t11 t12) (RAllE x2 t21 t22) | x1 == x2 
-      = liftM2 (&&) (go t11 t21) (go t12 t22) 
-    go (REx x1 t11 t12) (REx x2 t21 t22) | x1 == x2
-      = liftM2 (&&) (go t11 t21) (go t12 t22)
-    go (RExprArg e1) (RExprArg e2)
-      = return (e1 =*= e2) 
-    go (RAppTy t11 t12 r1) (RAppTy t21 t22 r2) | r1 =*= r2 
-      = liftM2 (&&) (go t11 t21) (go t12 t22)  
-    go (RRTy _ _ _ r1) (RRTy _ _ _ r2) 
-      = return (r1 =*= r2)
-    go (RHole r1) (RHole r2)
-      = return (r1 =*= r2)  
-    go _t1 _t2 
-      = return False 
-
-class REq a where 
-  (=*=) :: a -> a -> Bool 
-
-instance REq t2 => REq (Ref t1 t2) where
-    (RProp _ t1) =*= (RProp _ t2) = t1 =*= t2 
-
-instance REq (UReft F.Reft) where
-  (MkUReft r1 p1) =*= (MkUReft r2 p2)
-     = r1 =*= r2 && p1 == p2
-  
-instance REq F.Reft where 
-  F.Reft (v1, e1) =*= F.Reft (v2, e2) = F.subst1 e1 (v1, F.EVar v2) =*= e2 
-
-instance REq F.Expr where 
-  e1 =*= e2 = go (F.simplify e1) (F.simplify e2)
-    where go r1 r2 = F.notracepp ("comparing " ++ showpp (F.toFix r1, F.toFix r2)) $ r1 == r2 
-
-instance REq r => REq (Located r) where 
-  t1 =*= t2 = val t1 =*= val t2         
-  
diff --git a/src/Language/Haskell/Liquid/Types/Errors.hs b/src/Language/Haskell/Liquid/Types/Errors.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Errors.hs
+++ /dev/null
@@ -1,1057 +0,0 @@
-{-# LANGUAGE ImplicitParams      #-}
-{-# LANGUAGE TupleSections       #-}
-{-# LANGUAGE FlexibleInstances   #-}
-{-# LANGUAGE OverloadedStrings   #-}
-{-# LANGUAGE DeriveGeneric       #-}
-{-# LANGUAGE DeriveDataTypeable  #-}
-{-# LANGUAGE DeriveFunctor       #-}
-{-# LANGUAGE OverloadedStrings   #-}
-{-# LANGUAGE DerivingStrategies  #-}
-{-# LANGUAGE DerivingVia         #-}
-
--- | This module contains the *types* related creating Errors.
---   It depends only on Fixpoint and basic haskell libraries,
---   and hence, should be importable everywhere.
-
-module Language.Haskell.Liquid.Types.Errors (
-  -- * Generic Error Type
-    TError (..)
-
-  -- * Error with Source Context
-  , CtxError (..)
-  , errorsWithContext
-
-  -- * Subtyping Obligation Type
-  , Oblig (..)
-
-  -- * Adding a Model of the context
-  , WithModel (..), dropModel
-
-  -- * Panic (unexpected failures)
-  , UserError
-  , panic
-  , panicDoc
-  , todo
-  , impossible
-  , uError
-  , sourceErrors
-  , errDupSpecs
-
-  -- * Printing Errors
-  , ppError
-  , ppTicks
-
-  -- * SrcSpan Helpers
-  , realSrcSpan
-  , unpackRealSrcSpan
-  , srcSpanFileMb
-  ) where
-
-import           Prelude                      hiding (error)
-import           SrcLoc
-import           FastString
-import           HscTypes (srcErrorMessages, SourceError)
-import           ErrUtils
-import           Bag
-
-import           GHC.Generics
-import           Control.DeepSeq
-import qualified Control.Exception            as Ex
-import           Data.Typeable                (Typeable)
-import           Data.Generics                (Data)
-import qualified Data.Binary                  as B
-import qualified Data.Maybe                   as Mb
-import           Data.Aeson                   hiding (Result)
-import           Data.Hashable
-import qualified Data.HashMap.Strict          as M
-import qualified Data.List                    as L
-import           System.Directory
-import           System.FilePath
-import           Text.PrettyPrint.HughesPJ
-import           Text.Parsec.Error            (ParseError)
-import           Text.Parsec.Error            (errorMessages, showErrorMessages)
-
-import           Language.Fixpoint.Types      (pprint, showpp, Tidy (..), PPrint (..), Symbol, Expr)
-import qualified Language.Fixpoint.Misc       as Misc
-import qualified Language.Haskell.Liquid.Misc     as Misc
-import           Language.Haskell.Liquid.Misc ((<->))
-import           Language.Haskell.Liquid.Types.Generics
-
-instance PPrint ParseError where
-  pprintTidy _ e = vcat $ tail $ text <$> ls
-    where
-      ls         = lines $ showErrorMessages "or" "unknown parse error"
-                               "expecting" "unexpected" "end of input"
-                               (errorMessages e)
-
---------------------------------------------------------------------------------
--- | Context information for Error Messages ------------------------------------
---------------------------------------------------------------------------------
-data CtxError t = CtxError
-  { ctErr :: TError t
-  , ctCtx :: Doc
-  } deriving (Functor)
-
-instance Eq (CtxError t) where
-  e1 == e2 = ctErr e1 == ctErr e2
-
-instance Ord (CtxError t) where
-  e1 <= e2 = ctErr e1 <= ctErr e2
-
---------------------------------------------------------------------------------
-errorsWithContext :: [TError Doc] -> IO [CtxError Doc]
---------------------------------------------------------------------------------
-errorsWithContext es
-  = Misc.concatMapM fileErrors
-  $ Misc.groupList [ (srcSpanFileMb (pos e), e) | e <- es ]
-
-fileErrors :: (Maybe FilePath, [TError Doc]) -> IO [CtxError Doc]
-fileErrors (fp, errs) = do
-  fb  <- getFileBody fp
-  return (errorWithContext fb <$> errs)
-
-errorWithContext :: FileBody -> TError Doc -> CtxError Doc
-errorWithContext fb e = CtxError e (srcSpanContext fb (pos e))
-
-srcSpanContext :: FileBody -> SrcSpan -> Doc
-srcSpanContext fb sp
-  | Just (l, c, l', c') <- srcSpanInfo sp
-  = makeContext l c c' (getFileLines fb l l')
-  | otherwise
-  = empty
-
-srcSpanInfo :: SrcSpan -> Maybe (Int, Int, Int, Int)
-srcSpanInfo (RealSrcSpan s)
-              = Just (l, c, l', c')
-  where
-     l        = srcSpanStartLine s
-     c        = srcSpanStartCol  s
-     l'       = srcSpanEndLine   s
-     c'       = srcSpanEndCol    s
-srcSpanInfo _ = Nothing
-
-getFileLines :: FileBody -> Int -> Int -> [String]
-getFileLines fb i j = slice (i - 1) (j - 1) fb
-
-getFileBody :: Maybe FilePath -> IO FileBody
-getFileBody Nothing  =
-  return []
-getFileBody (Just f) = do
-  b <- doesFileExist f
-  if b then lines <$> Misc.sayReadFile f
-       else return []
-
-type FileBody = [String]
-
-slice :: Int -> Int -> [a] -> [a]
-slice i j xs = take (j - i + 1) (drop i xs)
-
-makeContext :: Int -> Int -> Int -> [String] -> Doc
-makeContext _ _ _  []  = empty
-makeContext l c c' [s] = makeContext1 l c c' s
-makeContext l _ _  ss  = vcat $ text " "
-                              : (zipWith makeContextLine [l..] ss)
-                              ++ [ text " "
-                                 , text " " ]
-
-makeContextLine :: Int -> String -> Doc
-makeContextLine l s = lnum l <+> text s
-  where
-    lnum n          = text (show n) <+> text "|"
-
-makeContext1 :: Int -> Int -> Int -> String -> Doc
-makeContext1 l c c' s = vcat [ text " "
-                             , lnum l <+> (text s $+$ cursor)
-                             , text " "
-                             , text " "
-                             ]
-  where
-    lnum n            = text (show n) <+> text "|"
-    cursor            = blanks (c - 1) <-> pointer (max 1 (c' - c))
-    blanks n          = text $ replicate n ' '
-    pointer n         = text $ replicate n '^'
-
---------------------------------------------------------------------------------
--- | Different kinds of Check "Obligations" ------------------------------------
---------------------------------------------------------------------------------
-
-data Oblig
-  = OTerm -- ^ Obligation that proves termination
-  | OInv  -- ^ Obligation that proves invariants
-  | OCons -- ^ Obligation that proves subtyping constraints
-  deriving (Eq, Generic, Data, Typeable)
-  deriving Hashable via Generically Oblig
-
-instance B.Binary Oblig
-instance Show Oblig where
-  show OTerm = "termination-condition"
-  show OInv  = "invariant-obligation"
-  show OCons = "constraint-obligation"
-
-instance NFData Oblig
-
-instance PPrint Oblig where
-  pprintTidy _ = ppOblig
-
-ppOblig :: Oblig -> Doc
-ppOblig OCons = text "Constraint Check"
-ppOblig OTerm = text "Termination Check"
-ppOblig OInv  = text "Invariant Check"
-
---------------------------------------------------------------------------------
--- | Generic Type for Error Messages -------------------------------------------
---------------------------------------------------------------------------------
-
--- | INVARIANT : all Error constructors should have a pos field
-
-data TError t =
-    ErrSubType { pos  :: !SrcSpan
-               , msg  :: !Doc
-               , ctx  :: !(M.HashMap Symbol t)
-               , tact :: !t
-               , texp :: !t
-               } -- ^ liquid type error
-
-  | ErrSubTypeModel
-               { pos  :: !SrcSpan
-               , msg  :: !Doc
-               , ctxM  :: !(M.HashMap Symbol (WithModel t))
-               , tactM :: !(WithModel t)
-               , texp :: !t
-               } -- ^ liquid type error with a counter-example
-
-  | ErrFCrash  { pos  :: !SrcSpan
-               , msg  :: !Doc
-               , ctx  :: !(M.HashMap Symbol t)
-               , tact :: !t
-               , texp :: !t
-               } -- ^ liquid type error
-
-  | ErrHole    { pos  :: !SrcSpan
-               , msg  :: !Doc
-               , ctx  :: !(M.HashMap Symbol t)
-               , svar :: !Symbol
-               , thl  :: !t
-               } -- ^ hole type
-
-  | ErrHoleCycle
-               { pos  :: !SrcSpan
-               , holesCycle :: [Symbol] -- Var?
-               } -- ^ hole dependencies form a cycle error
-
-  | ErrAssType { pos  :: !SrcSpan
-               , obl  :: !Oblig
-               , msg  :: !Doc
-               , ctx  :: !(M.HashMap Symbol t)
-               , cond :: t
-               } -- ^ condition failure error
-
-  | ErrParse    { pos  :: !SrcSpan
-                , msg  :: !Doc
-                , pErr :: !ParseError
-                } -- ^ specification parse error
-
-  | ErrTySpec   { pos :: !SrcSpan
-                , knd :: !(Maybe Doc)
-                , var :: !Doc
-                , typ :: !t
-                , msg :: !Doc
-                } -- ^ sort error in specification
-
-  | ErrTermSpec { pos  :: !SrcSpan
-                , var  :: !Doc
-                , msg  :: !Doc
-                , exp  :: !Expr
-                , typ  :: !t
-                , msg' :: !Doc
-                } -- ^ sort error in specification
-
-  | ErrDupAlias { pos  :: !SrcSpan
-                , var  :: !Doc
-                , kind :: !Doc
-                , locs :: ![SrcSpan]
-                } -- ^ multiple alias with same name error
-
-  | ErrDupSpecs { pos :: !SrcSpan
-                , var :: !Doc
-                , locs:: ![SrcSpan]
-                } -- ^ multiple specs for same binder error
-
-  | ErrDupIMeas { pos   :: !SrcSpan
-                , var   :: !Doc
-                , tycon :: !Doc
-                , locs  :: ![SrcSpan]
-                } -- ^ multiple definitions of the same instance measure
-
-  | ErrDupMeas  { pos   :: !SrcSpan
-                , var   :: !Doc
-                , locs  :: ![SrcSpan]
-                } -- ^ multiple definitions of the same measure
-
-  | ErrDupField { pos   :: !SrcSpan
-                , dcon  :: !Doc
-                , field :: !Doc
-                } -- ^ duplicate fields in same datacon
-
-  | ErrDupNames { pos   :: !SrcSpan
-                , var   :: !Doc
-                , names :: ![Doc]
-                } -- ^ name resolves to multiple possible GHC vars
-
-  | ErrBadData  { pos :: !SrcSpan
-                , var :: !Doc
-                , msg :: !Doc
-                } -- ^ bad data type specification (?)
-
-  | ErrBadGADT  { pos :: !SrcSpan
-                , var :: !Doc
-                , msg :: !Doc
-                } -- ^ bad data type specification (?)
-
-  | ErrDataCon  { pos :: !SrcSpan
-                , var :: !Doc
-                , msg :: !Doc
-                } -- ^ refined datacon mismatches haskell datacon
-
-  | ErrInvt     { pos :: !SrcSpan
-                , inv :: !t
-                , msg :: !Doc
-                } -- ^ Invariant sort error
-
-  | ErrIAl      { pos :: !SrcSpan
-                , inv :: !t
-                , msg :: !Doc
-                } -- ^ Using  sort error
-
-  | ErrIAlMis   { pos :: !SrcSpan
-                , tAs :: !t
-                , tUs :: !t
-                , msg :: !Doc
-                } -- ^ Incompatible using error
-
-  | ErrMeas     { pos :: !SrcSpan
-                , ms  :: !Doc
-                , msg :: !Doc
-                } -- ^ Measure sort error
-
-  | ErrHMeas    { pos :: !SrcSpan
-                , ms  :: !Doc
-                , msg :: !Doc
-                } -- ^ Haskell bad Measure error
-
-  | ErrUnbound  { pos :: !SrcSpan
-                , var :: !Doc
-                } -- ^ Unbound symbol in specification
-
-  | ErrUnbPred  { pos :: !SrcSpan
-                , var :: !Doc
-                } -- ^ Unbound predicate being applied
-
-  | ErrGhc      { pos :: !SrcSpan
-                , msg :: !Doc
-                } -- ^ GHC error: parsing or type checking
-
-  | ErrResolve  { pos  :: !SrcSpan
-                , kind :: !Doc
-                , var  :: !Doc
-                , msg  :: !Doc
-                } -- ^ Name resolution error
-
-  | ErrMismatch { pos   :: !SrcSpan -- ^ haskell type location
-                , var   :: !Doc
-                , msg   :: !Doc
-                , hs    :: !Doc
-                , lqTy  :: !Doc
-                , diff  :: !(Maybe (Doc, Doc))  -- ^ specific pair of things that mismatch
-                , lqPos :: !SrcSpan -- ^ lq type location
-                } -- ^ Mismatch between Liquid and Haskell types
-
-  | ErrPartPred { pos  :: !SrcSpan
-                , ectr :: !Doc
-                , var  :: !Doc
-                , argN :: !Int
-                , expN :: !Int
-                , actN :: !Int
-                } -- ^ Mismatch in expected/actual args of abstract refinement
-
-  | ErrAliasCycle { pos    :: !SrcSpan
-                  , acycle :: ![(SrcSpan, Doc)]
-                  } -- ^ Cyclic Refined Type Alias Definitions
-
-  | ErrIllegalAliasApp { pos   :: !SrcSpan
-                       , dname :: !Doc
-                       , dpos  :: !SrcSpan
-                       } -- ^ Illegal RTAlias application (from BSort, eg. in PVar)
-
-  | ErrAliasApp { pos   :: !SrcSpan
-                , dname :: !Doc
-                , dpos  :: !SrcSpan
-                , msg   :: !Doc
-                }
-
-  | ErrTermin   { pos  :: !SrcSpan
-                , bind :: ![Doc]
-                , msg  :: !Doc
-                } -- ^ Termination Error
-
-  | ErrStTerm   { pos  :: !SrcSpan
-                , dname :: !Doc
-                , msg  :: !Doc
-                } -- ^ Termination Error
-
-  | ErrILaw     { pos   :: !SrcSpan
-                , cname :: !Doc
-                , iname :: !Doc
-                , msg   :: !Doc
-                } -- ^ Instance Law Error
-
-  | ErrRClass   { pos   :: !SrcSpan
-                , cls   :: !Doc
-                , insts :: ![(SrcSpan, Doc)]
-                } -- ^ Refined Class/Interfaces Conflict
-
-  | ErrMClass   { pos   :: !SrcSpan
-                , var   :: !Doc
-                } -- ^ Standalone class method refinements
-
-  | ErrBadQual  { pos   :: !SrcSpan
-                , qname :: !Doc
-                , msg   :: !Doc
-                } -- ^ Non well sorted Qualifier
-
-  | ErrSaved    { pos :: !SrcSpan
-                , nam :: !Doc
-                , msg :: !Doc
-                } -- ^ Previously saved error, that carries over after DiffCheck
-
-  | ErrFilePragma { pos :: !SrcSpan
-                  }
-
-  | ErrTyCon    { pos    :: !SrcSpan
-                , msg    :: !Doc
-                , tcname :: !Doc
-                }
-
-  | ErrLiftExp  { pos    :: !SrcSpan
-                , msg    :: !Doc
-                }
-
-  | ErrParseAnn { pos :: !SrcSpan
-                , msg :: !Doc
-                }
-
-  | ErrNoSpec   { pos  :: !SrcSpan
-                , srcF :: !Doc
-                , bspF :: !Doc
-                }
-
-  | ErrFail     { pos :: !SrcSpan
-                , var :: !Doc
-                }
-
-  | ErrFailUsed { pos     :: !SrcSpan
-                , var     :: !Doc
-                , clients :: ![Doc]
-                }
-
-  | ErrRewrite  { pos :: !SrcSpan
-                , msg :: !Doc
-                }
-
-  | ErrOther    { pos   :: SrcSpan
-                , msg   :: !Doc
-                } -- ^ Sigh. Other.
-
-  deriving (Typeable, Generic , Functor )
-
-errDupSpecs :: Doc -> Misc.ListNE SrcSpan -> TError t
-errDupSpecs d spans@(sp:_) = ErrDupSpecs sp d spans
-errDupSpecs _ _            = impossible Nothing "errDupSpecs with empty spans!"
-
-instance NFData ParseError where
-  rnf t = seq t ()
-
--- FIXME ES: this is very suspicious, why can't we have multiple errors
--- arising from the same span?
-
-instance Eq (TError a) where
-  e1 == e2 = errSpan e1 == errSpan e2
-
-instance Ord (TError a) where
-  e1 <= e2 = errSpan e1 <= errSpan e2
-
-
-errSpan :: TError a -> SrcSpan
-errSpan =  pos
-
---------------------------------------------------------------------------------
--- | Simple unstructured type for panic ----------------------------------------
---------------------------------------------------------------------------------
-type UserError  = TError Doc
-
-instance PPrint UserError where
-  pprintTidy k = ppError k empty . fmap (pprintTidy Lossy)
-
-data WithModel t
-  = NoModel t
-  | WithModel !Doc t
-  deriving (Functor, Show, Eq, Generic)
-
-instance NFData t => NFData (WithModel t)
-
-dropModel :: WithModel t -> t
-dropModel m = case m of
-  NoModel t     -> t
-  WithModel _ t -> t
-
-instance PPrint SrcSpan where
-  pprintTidy _ = pprSrcSpan
-
-pprSrcSpan :: SrcSpan -> Doc
-pprSrcSpan (UnhelpfulSpan s) = text $ unpackFS s
-pprSrcSpan (RealSrcSpan s)   = pprRealSrcSpan s
-
-pprRealSrcSpan :: RealSrcSpan -> Doc
-pprRealSrcSpan span
-  | sline == eline && scol == ecol =
-    hcat [ pathDoc <-> colon
-         , int sline <-> colon
-         , int scol
-         ]
-  | sline == eline =
-    hcat $ [ pathDoc <-> colon
-           , int sline <-> colon
-           , int scol
-           ] ++ if ecol - scol <= 1 then [] else [char '-' <-> int (ecol - 1)]
-  | otherwise =
-    hcat [ pathDoc <-> colon
-         , parens (int sline <-> comma <-> int scol)
-         , char '-'
-         , parens (int eline <-> comma <-> int ecol')
-         ]
- where
-   path  = srcSpanFile      span
-   sline = srcSpanStartLine span
-   eline = srcSpanEndLine   span
-   scol  = srcSpanStartCol  span
-   ecol  = srcSpanEndCol    span
-
-   pathDoc = text $ normalise $ unpackFS path
-   ecol'   = if ecol == 0 then ecol else ecol - 1
-
-instance Show UserError where
-  show = showpp
-
-instance Ex.Exception UserError
-
--- | Construct and show an Error, then crash
-uError :: UserError -> a
-uError = Ex.throw
-
--- | Construct and show an Error, then crash
-panicDoc :: {- (?callStack :: CallStack) => -} SrcSpan -> Doc -> a
-panicDoc sp d = Ex.throw (ErrOther sp d :: UserError)
-
--- | Construct and show an Error, then crash
-panic :: {- (?callStack :: CallStack) => -} Maybe SrcSpan -> String -> a
-panic sp d = panicDoc (sspan sp) (text d)
-  where
-    sspan  = Mb.fromMaybe noSrcSpan
-
--- | Construct and show an Error with an optional SrcSpan, then crash
---   This function should be used to mark unimplemented functionality
-todo :: {- (?callStack :: CallStack) => -} Maybe SrcSpan -> String -> a
-todo s m  = panic s $ unlines
-            [ "This functionality is currently unimplemented. "
-            , "If this functionality is critical to you, please contact us at: "
-            , "https://github.com/ucsd-progsys/liquidhaskell/issues"
-            , m
-            ]
-
--- | Construct and show an Error with an optional SrcSpan, then crash
---   This function should be used to mark impossible-to-reach codepaths
-impossible :: {- (?callStack :: CallStack) => -} Maybe SrcSpan -> String -> a
-impossible s m = panic s $ unlines msg ++ m
-   where
-      msg = [ "This should never happen! If you are seeing this message, "
-            , "please submit a bug report at "
-            , "https://github.com/ucsd-progsys/liquidhaskell/issues "
-            , "with this message and the source file that caused this error."
-            , ""
-            ]
-
-
-
--- type CtxError = Error
---------------------------------------------------------------------------------
-ppError :: (PPrint a, Show a) => Tidy -> Doc -> TError a -> Doc
---------------------------------------------------------------------------------
-ppError k dCtx e = ppError' k dCtx e
-
-nests :: Int -> [Doc] -> Doc
-nests n = foldr (\d acc ->  d $+$ nest n acc) empty
--- nests n = foldr (\d acc -> nest n (d $+$ acc)) empty
-
-sepVcat :: Doc -> [Doc] -> Doc
-sepVcat d ds = vcat $ L.intersperse d ds
-
-blankLine :: Doc
-blankLine = sizedText 5 "."
-
-ppFull :: Tidy -> Doc -> Doc
-ppFull Full  d = d
-ppFull Lossy _ = empty
-
-ppReqInContext :: PPrint t => Tidy -> t -> t -> M.HashMap Symbol t -> Doc
-ppReqInContext td tA tE c
-  = sepVcat blankLine
-      [ nests 2 [ text "The inferred type"
-                , text "VV :" <+> pprintTidy td tA]
-      , nests 2 [ text "is not a subtype of the required type"
-                , text "VV :" <+> pprintTidy td tE]
-      , ppContext td c
-      ]
-
-ppContext :: PPrint t => Tidy -> M.HashMap Symbol t -> Doc
-ppContext td c
-  | 0 < length xts = nests 2 [ text "in the context"
-                             , vsep (map (uncurry (pprintBind td)) xts)
-                             ]
-  | otherwise      = empty
-  where
-    xts            = M.toList c
-
-pprintBind :: PPrint t => Tidy -> Symbol -> t -> Doc
-pprintBind td v t = pprintTidy td v <+> char ':' <+> pprintTidy td t
-
-ppReqModelInContext
-  :: (PPrint t) => Tidy -> WithModel t -> t -> (M.HashMap Symbol (WithModel t)) -> Doc
-ppReqModelInContext td tA tE c
-  = sepVcat blankLine
-      [ nests 2 [ text "The inferred type"
-                , pprintModel td "VV" tA]
-      , nests 2 [ text "is not a subtype of the required type"
-                , pprintModel td "VV" (NoModel tE)]
-      , nests 2 [ text "in the context"
-                , vsep (map (uncurry (pprintModel td)) (M.toList c))
-                ]
-      ]
-
-vsep :: [Doc] -> Doc
-vsep = vcat . L.intersperse (char ' ')
-
-pprintModel :: PPrint t => Tidy -> Symbol -> WithModel t -> Doc
-pprintModel td v wm = case wm of
-  NoModel t
-    -> pprintTidy td v <+> char ':' <+> pprintTidy td t
-  WithModel m t
-    -> pprintTidy td v <+> char ':' <+> pprintTidy td t $+$
-       pprintTidy td v <+> char '=' <+> pprintTidy td m
-
-ppPropInContext :: (PPrint p, PPrint c) => Tidy -> p -> c -> Doc
-ppPropInContext td p c
-  = sepVcat blankLine
-      [ nests 2 [ text "Property"
-                , pprintTidy td p]
-      , nests 2 [ text "Not provable in context"
-                , pprintTidy td c
-                ]
-      ]
-
-instance ToJSON RealSrcSpan where
-  toJSON sp = object [ "filename"  .= f
-                     , "startLine" .= l1
-                     , "startCol"  .= c1
-                     , "endLine"   .= l2
-                     , "endCol"    .= c2
-                     ]
-    where
-      (f, l1, c1, l2, c2) = unpackRealSrcSpan sp
-
-unpackRealSrcSpan :: RealSrcSpan -> (String, Int, Int, Int, Int)
-unpackRealSrcSpan rsp = (f, l1, c1, l2, c2)
-  where
-    f                 = unpackFS $ srcSpanFile rsp
-    l1                = srcSpanStartLine rsp
-    c1                = srcSpanStartCol  rsp
-    l2                = srcSpanEndLine   rsp
-    c2                = srcSpanEndCol    rsp
-
-
-instance FromJSON RealSrcSpan where
-  parseJSON (Object v) = realSrcSpan <$> v .: "filename"
-                                     <*> v .: "startLine"
-                                     <*> v .: "startCol"
-                                     <*> v .: "endLine"
-                                     <*> v .: "endCol"
-  parseJSON _          = mempty
-
-realSrcSpan :: FilePath -> Int -> Int -> Int -> Int -> RealSrcSpan
-realSrcSpan f l1 c1 l2 c2 = mkRealSrcSpan loc1 loc2
-  where
-    loc1                  = mkRealSrcLoc (fsLit f) l1 c1
-    loc2                  = mkRealSrcLoc (fsLit f) l2 c2
-
-srcSpanFileMb :: SrcSpan -> Maybe FilePath
-srcSpanFileMb (RealSrcSpan s) = Just $ unpackFS $ srcSpanFile s
-srcSpanFileMb _               = Nothing
-
-
-instance ToJSON SrcSpan where
-  toJSON (RealSrcSpan rsp) = object [ "realSpan" .= True, "spanInfo" .= rsp ]
-  toJSON (UnhelpfulSpan _) = object [ "realSpan" .= False ]
-
-instance FromJSON SrcSpan where
-  parseJSON (Object v) = do tag <- v .: "realSpan"
-                            case tag of
-                              False -> return noSrcSpan
-                              True  -> RealSrcSpan <$> v .: "spanInfo"
-  parseJSON _          = mempty
-
--- Default definition use ToJSON and FromJSON
-instance ToJSONKey SrcSpan
-instance FromJSONKey SrcSpan
-
-instance (PPrint a, Show a) => ToJSON (TError a) where
-  toJSON e = object [ "pos" .= (pos e)
-                    , "msg" .= (render $ ppError' Full empty e)
-                    ]
-
-instance FromJSON (TError a) where
-  parseJSON (Object v) = errSaved <$> v .: "pos"
-                                  <*> v .: "msg"
-  parseJSON _          = mempty
-
-errSaved :: SrcSpan -> String -> TError a
-errSaved sp body = ErrSaved sp (text n) (text $ unlines m)
-  where
-    n : m        = lines body
-
-
-totalityType :: PPrint a =>  Tidy -> a -> Bool
-totalityType td tE = pprintTidy td tE == text "{VV : Addr# | 5 < 4}"
-
-hint :: TError a -> Doc
-hint e = maybe empty (\d -> "" $+$ ("HINT:" <+> d)) (go e)
-  where
-    go (ErrMismatch {}) = Just "Use the hole '_' instead of the mismatched component (in the Liquid specification)"
-    go (ErrBadGADT {})  = Just "Use the hole '_' to specify the type of the constructor"
-    go (ErrSubType {})  = Just "Use \"--no-totality\" to deactivate totality checking."
-    go (ErrNoSpec {})   = Just "Run 'liquid' on the source file first."
-    go _                = Nothing
-
---------------------------------------------------------------------------------
-ppError' :: (PPrint a, Show a) => Tidy -> Doc -> TError a -> Doc
---------------------------------------------------------------------------------
-ppError' td dCtx (ErrAssType _ o _ c p)
-  = pprintTidy td o
-        $+$ dCtx
-        $+$ (ppFull td $ ppPropInContext td p c)
-
-ppError' td dCtx err@(ErrSubType _ _ _ _ tE)
-  | totalityType td tE
-  = text "Totality Error"
-        $+$ dCtx
-        $+$ text "Your function is not total: not all patterns are defined."
-        $+$ hint err -- "Hint: Use \"--no-totality\" to deactivate totality checking."
-
-ppError' _td _dCtx (ErrHoleCycle _ holes)
-  = "Cycle of holes found"
-        $+$ pprint holes
-
-ppError' _td _dCtx (ErrHole _ msg _ x t)
-  = "Hole Found"
-        $+$ pprint x <+> "::" <+> pprint t
-        $+$ msg
-
-ppError' td dCtx (ErrSubType _ _ c tA tE)
-  = text "Liquid Type Mismatch"
-    $+$ nest 4 (blankLine 
-                $+$ dCtx
-                $+$ (ppFull td $ ppReqInContext td tA tE c))
-
-ppError' td dCtx (ErrSubTypeModel _ _ c tA tE)
-  = text "Liquid Type Mismatch"
-        $+$ nest 4 (dCtx
-                    $+$ (ppFull td $ ppReqModelInContext td tA tE c))
-
-ppError' td  dCtx (ErrFCrash _ _ c tA tE)
-  = text "Fixpoint Crash on Constraint"
-        $+$ dCtx
-        $+$ (ppFull td $ ppReqInContext td tA tE c)
-
-ppError' _ dCtx (ErrParse _ _ e)
-  = text "Cannot parse specification:"
-        $+$ dCtx
-        $+$ (nest 4 $ pprint e)
-
-ppError' _ dCtx (ErrTySpec _ _k v t s)
-  = ("Illegal type specification for" <+> ppTicks v) --  <-> ppKind k <-> ppTicks v)
-  -- = dSp <+> ("Illegal type specification for" <+> _ppKind k <-> ppTicks v)
-        $+$ dCtx
-        $+$ nest 4 (vcat [ pprint v <+> Misc.dcolon <+> pprint t
-                         , pprint s
-                         ])
-    where
-      _ppKind Nothing  = empty
-      _ppKind (Just d) = d <-> " "
-
-ppError' _ dCtx (ErrLiftExp _ v)
-  = text "Cannot lift" <+> ppTicks v <+> "into refinement logic"
-        $+$ dCtx
-        $+$ (nest 4 $ text "Please export the binder from the module to enable lifting.")
-
-ppError' _ dCtx (ErrBadData _ v s)
-  = text "Bad Data Specification"
-        $+$ dCtx
-        $+$ (pprint s <+> "for" <+> ppTicks v)
-
-ppError' _ dCtx err@(ErrBadGADT _ v s)
-  = text "Bad GADT specification for" <+> ppTicks v
-        $+$ dCtx
-        $+$ pprint s
-        $+$ hint err
-
-ppError' _ dCtx (ErrDataCon _ d s)
-  = "Malformed refined data constructor" <+> ppTicks d
-        $+$ dCtx
-        $+$ s
-
-ppError' _ dCtx (ErrBadQual _ n d)
-  = text "Illegal qualifier specification for" <+> ppTicks n
-        $+$ dCtx
-        $+$ pprint d
-
-ppError' _ dCtx (ErrTermSpec _ v msg e t s)
-  = text "Illegal termination specification for" <+> ppTicks v
-        $+$ dCtx
-        $+$ (nest 4 $ ((text "Termination metric" <+> ppTicks e <+> text "is" <+> msg <+> "in type signature")
-                        $+$ nest 4 (pprint t)
-                        $+$ pprint s))
-
-ppError' _ _ (ErrInvt _ t s)
-  = text "Bad Invariant Specification"
-        $+$ (nest 4 $ text "invariant " <+> pprint t $+$ pprint s)
-
-ppError' _ _ (ErrIAl _ t s)
-  = text "Bad Using Specification"
-        $+$ (nest 4 $ text "as" <+> pprint t $+$ pprint s)
-
-ppError' _ _ (ErrIAlMis _ t1 t2 s)
-  = text "Incompatible Using Specification"
-        $+$ (nest 4 $ (text "using" <+> pprint t1 <+> text "as" <+> pprint t2) $+$ pprint s)
-
-ppError' _ _ (ErrMeas _ t s)
-  = text "Bad Measure Specification"
-        $+$ (nest 4 $ text "measure " <+> pprint t $+$ pprint s)
-
-ppError' _ dCtx (ErrHMeas _ t s)
-  = text "Cannot lift Haskell function" <+> ppTicks t <+> text "to logic"
-        $+$ dCtx
-        $+$ (nest 4 $ pprint s)
-
-ppError' _ dCtx (ErrDupSpecs _ v ls)
-  = text "Multiple specifications for" <+> ppTicks v <+> colon
-        $+$ dCtx
-        $+$ ppSrcSpans ls
-
-ppError' _ dCtx (ErrDupIMeas _ v t ls)
-  = text "Multiple instance measures" <+> ppTicks v <+> text "for type" <+> ppTicks t
-        $+$ dCtx
-        $+$ ppSrcSpans ls
-
-ppError' _ dCtx (ErrDupMeas _ v ls)
-  = text "Multiple measures named" <+> ppTicks v
-        $+$ dCtx
-        $+$ ppSrcSpans ls
-
-ppError' _ dCtx (ErrDupField _ dc x)
-  = text "Malformed refined data constructor" <+> dc
-        $+$ dCtx
-        $+$ (nest 4 $ text "Duplicated definitions for field" <+> ppTicks x)
-
-ppError' _ dCtx (ErrDupNames _ x ns)
-  = text "Ambiguous specification symbol" <+> ppTicks x
-        $+$ dCtx
-        $+$ ppNames ns
-
-ppError' _ dCtx (ErrDupAlias _ k v ls)
-  = text "Multiple definitions of" <+> pprint k <+> ppTicks v
-        $+$ dCtx
-        $+$ ppSrcSpans ls
-
-ppError' _ dCtx (ErrUnbound _ x)
-  = text "Unbound variable" <+> pprint x
-        $+$ dCtx
-
-ppError' _ dCtx (ErrUnbPred _ p)
-  = text "Cannot apply unbound abstract refinement" <+> ppTicks p
-        $+$ dCtx
-
-ppError' _ dCtx (ErrGhc _ s)
-  = text "GHC Error"
-        $+$ dCtx
-        $+$ (nest 4 $ pprint s)
-
-ppError' _ _ (ErrFail _ s)
-  = text "Failure Error:"
-        $+$ text "Definition of" <+> pprint s <+> text "declared to fail is safe."
-
-ppError' _ _ (ErrFailUsed _ s xs)
-  = text "Failure Error:"
-        $+$ text "Binder" <+> pprint s <+> text "declared to fail is used by"
-        <+> (hsep $ L.intersperse comma xs)
-
-ppError' _ dCtx (ErrResolve _ kind v msg)
-  = (text "Unknown" <+> kind <+> ppTicks v)
-        $+$ dCtx
-        $+$ (nest 4 msg)
-
-ppError' _ dCtx (ErrPartPred _ c p i eN aN)
-  = text "Malformed predicate application"
-        $+$ dCtx
-        $+$ (nest 4 $ vcat
-                        [ "The" <+> text (Misc.intToString i) <+> "argument of" <+> c <+> "is predicate" <+> ppTicks p
-                        , "which expects" <+> pprint eN <+> "arguments" <+> "but is given only" <+> pprint aN
-                        , " "
-                        , "Abstract predicates cannot be partially applied; for a possible fix see:"
-                        , " "
-                        , nest 4 "https://github.com/ucsd-progsys/liquidhaskell/issues/594"
-                        ])
-
-ppError' _ dCtx e@(ErrMismatch _ x msg τ t cause hsSp)
-  = "Specified type does not refine Haskell type for" <+> ppTicks x <+> parens msg
-        $+$ dCtx
-        $+$ (sepVcat blankLine
-              [ "The Liquid type"
-              , nest 4 t
-              , "is inconsistent with the Haskell type"
-              , nest 4 τ
-              , "defined at" <+> pprint hsSp
-              , maybe empty ppCause cause
-              ])
-    where
-      ppCause (hsD, lqD) = sepVcat blankLine
-              [ "Specifically, the Liquid component"
-              , nest 4 lqD
-              , "is inconsistent with the Haskell component"
-              , nest 4 hsD
-              , hint e
-              ]
-
-ppError' _ dCtx (ErrAliasCycle _ acycle)
-  = text "Cyclic type alias definition for" <+> ppTicks n0
-        $+$ dCtx
-        $+$ (nest 4 $ sepVcat blankLine (hdr : map describe acycle))
-  where
-    hdr             = text "The following alias definitions form a cycle:"
-    describe (p, n) = text "*" <+> ppTicks n <+> parens (text "defined at:" <+> pprint p)
-    n0              = snd . head $ acycle
-
-ppError' _ dCtx (ErrIllegalAliasApp _ dn dl)
-  = text "Refinement type alias cannot be used in this context"
-        $+$ dCtx
-        $+$ text "Type alias:" <+> pprint dn
-        $+$ text "Defined at:" <+> pprint dl
-
-ppError' _ dCtx (ErrAliasApp _ name dl s)
-  = text "Malformed application of type alias" <+> ppTicks name
-        $+$ dCtx
-        $+$ (nest 4 $ vcat [ text "The alias" <+> ppTicks name <+> "defined at:" <+> pprint dl
-                           , s ] )
-
-ppError' _ dCtx (ErrSaved _ name s)
-  = name -- <+> "(saved)"
-        $+$ dCtx
-        $+$ {- nest 4 -} s
-
-ppError' _ dCtx (ErrFilePragma _)
-  = text "Illegal pragma"
-        $+$ dCtx
-        $+$ text "--idirs, --c-files, and --ghc-option cannot be used in file-level pragmas"
-
-ppError' _ _ err@(ErrNoSpec _ srcF bspecF)
-  =   vcat [ text "Cannot find .bspec file "
-           , nest 4 bspecF
-           , text "for the source file "
-           , nest 4 srcF
-           , hint err
-           ]
-
-ppError' _ dCtx (ErrOther _ s)
-  = text "Uh oh."
-        $+$ dCtx
-        $+$ nest 4 s
-
-ppError' _ dCtx (ErrTermin _ xs s)
-  = text "Termination Error"
-        $+$ dCtx
-        <+> (hsep $ L.intersperse comma xs) $+$ s
-
-ppError' _ dCtx (ErrStTerm _ x s)
-  = text "Structural Termination Error"
-        $+$ dCtx
-        <+> (text "Cannot prove termination for size" <+> x) $+$ s
-ppError' _ dCtx (ErrILaw _ c i s)
-  = text "Law Instance Error"
-        $+$ dCtx
-        <+> (text "The instance" <+> i <+> text "of class" <+> c <+> text "is not valid.") $+$ s
-
-ppError' _ dCtx (ErrMClass _ v)
-  = text "Standalone class method refinement"
-    $+$ dCtx
-    $+$ (text "Invalid type specification for" <+> v)
-    $+$ (text "Use class or instance refinements instead.")
-
-ppError' _ _ (ErrRClass p0 c is)
-  = text "Refined classes cannot have refined instances"
-    $+$ (nest 4 $ sepVcat blankLine $ describeCls : map describeInst is)
-  where
-    describeCls
-      =   text "Refined class definition for:" <+> c
-      $+$ text "Defined at:" <+> pprint p0
-    describeInst (p, t)
-      =   text "Refined instance for:" <+> t
-      $+$ text "Defined at:" <+> pprint p
-
-ppError' _ dCtx (ErrTyCon _ msg ty)
-  = text "Illegal data refinement for" <+> ppTicks ty
-        $+$ dCtx
-        $+$ nest 4 msg
-
-ppError' _ dCtx (ErrRewrite _ msg )
-  = text "Rewrite error"
-        $+$ dCtx
-        $+$ nest 4 msg
-
-ppError' _ dCtx (ErrParseAnn _ msg)
-  = text "Malformed annotation"
-        $+$ dCtx
-        $+$ nest 4 msg
-
-ppTicks :: PPrint a => a -> Doc
-ppTicks = ticks . pprint
-
-ticks :: Doc -> Doc
-ticks d = text "`" <-> d <-> text "`"
-
-ppSrcSpans :: [SrcSpan] -> Doc
-ppSrcSpans = ppList (text "Conflicting definitions at")
-
-ppNames :: [Doc] -> Doc
-ppNames ds = ppList "Could refer to any of the names" ds -- [text "-" <+> d | d <- ds]
-
-ppList :: (PPrint a) => Doc -> [a] -> Doc
-ppList d ls
-  = nest 4 (sepVcat blankLine (d : [ text "*" <+> pprint l | l <- ls ]))
-
--- | Convert a GHC error into a list of our errors.
-
-sourceErrors :: String -> SourceError -> [TError t]
-sourceErrors s = concatMap (errMsgErrors s) . bagToList . srcErrorMessages
-
-errMsgErrors :: String -> ErrMsg -> [TError t]
-errMsgErrors s e = [ ErrGhc (errMsgSpan e) msg ]
-   where
-     msg         =  text s
-                $+$ nest 4 (text (show e))
diff --git a/src/Language/Haskell/Liquid/Types/Fresh.hs b/src/Language/Haskell/Liquid/Types/Fresh.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Fresh.hs
+++ /dev/null
@@ -1,287 +0,0 @@
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TupleSections         #-}
-{-# LANGUAGE TypeSynonymInstances  #-}
-{-# LANGUAGE UndecidableInstances  #-}
-{-# LANGUAGE BangPatterns          #-}
-{-# LANGUAGE ConstraintKinds       #-}
-
-module Language.Haskell.Liquid.Types.Fresh
-  ( Freshable(..)
-  , refreshTy
-  , refreshVV
-  , refreshArgs
-  , refreshHoles
-  , refreshArgsSub
-  )
-  where
-
-import           Data.Maybe                    (catMaybes) -- , fromJust, isJust)
-import           Data.Bifunctor
-import qualified Data.List                      as L
--- import qualified Data.HashMap.Strict            as M
--- import qualified Data.HashSet                   as S
--- import           Data.Hashable
--- import           Control.Monad.State            (gets, get, put, modify)
--- import           Control.Monad                  (when, (>=>))
--- import           CoreUtils  (exprType)
-import           Prelude                        hiding (error)
--- import           Type       (Type)
--- import           CoreSyn
--- import           Var        (varType, isTyVar, Var)
-
-import qualified Language.Fixpoint.Types as F
--- import           Language.Fixpoint.Types.Visitor (kvars)
-import           Language.Haskell.Liquid.Misc  (single)
-import           Language.Haskell.Liquid.Types.Types
-import           Language.Haskell.Liquid.Types.RefType
-
-
-class (Applicative m, Monad m) => Freshable m a where
-  fresh   :: m a
-  true    :: a -> m a
-  true    = return
-  refresh :: a -> m a
-  refresh = return
-
-
-instance (Freshable m Integer, Monad m, Applicative m) => Freshable m F.Symbol where
-  fresh = F.tempSymbol "x" <$> fresh
-
-instance (Freshable m Integer, Monad m, Applicative m) => Freshable m F.Expr where
-  fresh  = kv <$> fresh
-    where
-      kv = (`F.PKVar` mempty) . F.intKvar
-
-instance (Freshable m Integer, Monad m, Applicative m) => Freshable m [F.Expr] where
-  fresh = single <$> fresh
-
-instance (Freshable m Integer, Monad m, Applicative m) => Freshable m F.Reft where
-  fresh                  = panic Nothing "fresh Reft"
-  true    (F.Reft (v,_)) = return $ F.Reft (v, mempty)
-  refresh (F.Reft (_,_)) = (F.Reft .) . (,) <$> freshVV <*> fresh
-    where
-      freshVV            = F.vv . Just <$> fresh
-
-instance Freshable m Integer => Freshable m RReft where
-  fresh             = panic Nothing "fresh RReft"
-  true (MkUReft r _)    = MkUReft <$> true r    <*> return mempty
-  refresh (MkUReft r _) = MkUReft <$> refresh r <*> return mempty
-
-instance (Freshable m Integer, Freshable m r, F.Reftable r ) => Freshable m (RRType r) where
-  fresh   = panic Nothing "fresh RefType"
-  refresh = refreshRefType
-  true    = trueRefType
-
------------------------------------------------------------------------------------------------
-trueRefType :: (Freshable m Integer, Freshable m r, F.Reftable r) => RRType r -> m (RRType r)
------------------------------------------------------------------------------------------------
-trueRefType (RAllT α t r)
-  = RAllT α <$> true t <*> true r 
-
-trueRefType (RAllP π t)
-  = RAllP π <$> true t
-
-trueRefType (RImpF _ t t' _)
-  = rImpF <$> fresh <*> true t <*> true t'
-
-trueRefType (RFun _ t t' _)
-  = rFun <$> fresh <*> true t <*> true t'
-
-trueRefType (RApp c ts _  _) | isClass c
-  = rRCls c <$> mapM true ts
-
-trueRefType (RApp c ts rs r)
-  = RApp c <$> mapM true ts <*> mapM trueRef rs <*> true r
-
-trueRefType (RAppTy t t' _)
-  = RAppTy <$> true t <*> true t' <*> return mempty
-
-trueRefType (RVar a r)
-  = RVar a <$> true r
-
-trueRefType (RAllE y ty tx)
-  = do y'  <- fresh
-       ty' <- true ty
-       tx' <- true tx
-       return $ RAllE y' ty' (tx' `F.subst1` (y, F.EVar y'))
-
-trueRefType (RRTy e o r t)
-  = RRTy e o r <$> trueRefType t
-
-trueRefType (REx _ t t')
-  = REx <$> fresh <*> true t <*> true t'
-
-trueRefType t@(RExprArg _)
-  = return t
-
-trueRefType t@(RHole _)
-  = return t
-
-trueRef :: (F.Reftable r, Freshable f r, Freshable f Integer)
-        => Ref τ (RType RTyCon RTyVar r) -> f (Ref τ (RRType r))
-trueRef (RProp _ (RHole _)) = panic Nothing "trueRef: unexpected RProp _ (RHole _))"
-trueRef (RProp s t) = RProp s <$> trueRefType t
-
-
------------------------------------------------------------------------------------------------
-refreshRefType :: (Freshable m Integer, Freshable m r, F.Reftable r) => RRType r -> m (RRType r)
------------------------------------------------------------------------------------------------
-refreshRefType (RAllT α t r)
-  = RAllT α <$> refresh t <*> true r
-
-refreshRefType (RAllP π t)
-  = RAllP π <$> refresh t
-
-refreshRefType (RImpF b t t' _)
-  | b == F.dummySymbol = rImpF <$> fresh <*> refresh t <*> refresh t'
-  | otherwise          = rImpF     b     <$> refresh t <*> refresh t'
-
-refreshRefType (RFun b t t' _)
-  | b == F.dummySymbol = rFun <$> fresh <*> refresh t <*> refresh t'
-  | otherwise          = rFun     b     <$> refresh t <*> refresh t'
-
-refreshRefType (RApp rc ts _ _) | isClass rc
-  = return $ rRCls rc ts
-
-refreshRefType (RApp rc ts rs r)
-  = RApp rc <$> mapM refresh ts <*> mapM refreshRef rs <*> refresh r
-
-refreshRefType (RVar a r)
-  = RVar a <$> refresh r
-
-refreshRefType (RAppTy t t' r)
-  = RAppTy <$> refresh t <*> refresh t' <*> refresh r
-
-refreshRefType (RAllE y ty tx)
-  = do y'  <- fresh
-       ty' <- refresh ty
-       tx' <- refresh tx
-       return $ RAllE y' ty' (tx' `F.subst1` (y, F.EVar y'))
-
-refreshRefType (RRTy e o r t)
-  = RRTy e o r <$> refreshRefType t
-
-refreshRefType t
-  = return t
-
-refreshRef :: (F.Reftable r, Freshable f r, Freshable f Integer)
-           => Ref τ (RType RTyCon RTyVar r) -> f (Ref τ (RRType r))
-refreshRef (RProp _ (RHole _)) = panic Nothing "refreshRef: unexpected (RProp _ (RHole _))"
-refreshRef (RProp s t) = RProp <$> mapM freshSym s <*> refreshRefType t
-
-freshSym :: Freshable f a => (t, t1) -> f (a, t1)
-freshSym (_, t)        = (, t) <$> fresh
-
-
---------------------------------------------------------------------------------
-refreshTy :: (FreshM m) => SpecType -> m SpecType
---------------------------------------------------------------------------------
-refreshTy t = refreshVV t >>= refreshArgs
-
---------------------------------------------------------------------------------
-type FreshM m = Freshable m Integer
---------------------------------------------------------------------------------
-
---------------------------------------------------------------------------------
-refreshVV :: FreshM m => SpecType -> m SpecType
---------------------------------------------------------------------------------
-refreshVV (RAllT a t r) = 
-  RAllT a <$> refreshVV t <*> return r 
-
-refreshVV (RAllP p t) = 
-  RAllP p <$> refreshVV t
-
-refreshVV (REx x t1 t2) = do 
-  t1' <- refreshVV t1
-  t2' <- refreshVV t2
-  shiftVV (REx x t1' t2') <$> fresh
-
-refreshVV (RImpF x t1 t2 r) = do
-  t1' <- refreshVV t1
-  t2' <- refreshVV t2
-  shiftVV (RImpF x t1' t2' r) <$> fresh
-
-refreshVV (RFun x t1 t2 r) = do
-  t1' <- refreshVV t1
-  t2' <- refreshVV t2
-  shiftVV (RFun x t1' t2' r) <$> fresh
-
-refreshVV (RAppTy t1 t2 r) = do 
-  t1' <- refreshVV t1
-  t2' <- refreshVV t2
-  shiftVV (RAppTy t1' t2' r) <$> fresh
-
-refreshVV (RApp c ts rs r) = do 
-  ts' <- mapM refreshVV    ts
-  rs' <- mapM refreshVVRef rs
-  shiftVV (RApp c ts' rs' r) <$> fresh
-
-refreshVV t = 
-  shiftVV t <$> fresh
-
-refreshVVRef :: Freshable m Integer => Ref b SpecType -> m (Ref b SpecType)
-refreshVVRef (RProp ss (RHole r))
-  = return $ RProp ss (RHole r)
-
-refreshVVRef (RProp ss t)
-  = do xs    <- mapM (const fresh) (fst <$> ss)
-       let su = F.mkSubst $ zip (fst <$> ss) (F.EVar <$> xs)
-       (RProp (zip xs (snd <$> ss)) . F.subst su) <$> refreshVV t
-
---------------------------------------------------------------------------------
-refreshArgs :: (FreshM m) => SpecType -> m SpecType
---------------------------------------------------------------------------------
-refreshArgs t = fst <$> refreshArgsSub t
-
-
--- NV TODO: this does not refresh args if they are wrapped in an RRTy
-refreshArgsSub :: (FreshM m) => SpecType -> m (SpecType, F.Subst)
-refreshArgsSub t
-  = do ts     <- mapM refreshArgs ts_u
-       xs'    <- mapM (const fresh) xs
-       let sus = F.mkSubst <$> L.inits (zip xs (F.EVar <$> xs'))
-       let su  = last sus
-       ts'    <- mapM refreshPs $ zipWith F.subst sus ts
-       let rs' = zipWith F.subst sus rs
-       tr     <- refreshPs $ F.subst su tbd
-       let t'  = fromRTypeRep $ trep {ty_binds = xs', ty_args = ts', ty_res = tr, ty_refts = rs'}
-       return (t', su)
-    where
-       trep    = toRTypeRep t
-       xs      = ty_binds trep
-       ts_u    = ty_args  trep
-       tbd     = ty_res   trep
-       rs      = ty_refts trep
-
-refreshPs :: (FreshM m) => SpecType -> m SpecType
-refreshPs = mapPropM go
-  where
-    go (RProp s t) = do
-      t'    <- refreshPs t
-      xs    <- mapM (const fresh) s
-      let su = F.mkSubst [(y, F.EVar x) | (x, (y, _)) <- zip xs s]
-      return $ RProp [(x, t) | (x, (_, t)) <- zip xs s] $ F.subst su t'
-
---------------------------------------------------------------------------------
-refreshHoles :: (F.Symbolic t, F.Reftable r, TyConable c, Freshable f r)
-             => [(t, RType c tv r)] -> f ([F.Symbol], [(t, RType c tv r)])
-refreshHoles vts = first catMaybes . unzip . map extract <$> mapM refreshHoles' vts
-  where
-  --   extract :: (t, t1, t2) -> (t, (t1, t2))
-    extract (a,b,c) = (a,(b,c))
-
-refreshHoles' :: (F.Symbolic a, F.Reftable r, TyConable c, Freshable m r)
-              => (a, RType c tv r) -> m (Maybe F.Symbol, a, RType c tv r)
-refreshHoles' (x,t)
-  | noHoles t = return (Nothing, x, t)
-  | otherwise = (Just $ F.symbol x,x,) <$> mapReftM tx t
-  where
-    tx r | hasHole r = refresh r
-         | otherwise = return r
-
-noHoles :: (F.Reftable r, TyConable c) => RType c tv r -> Bool
-noHoles = and . foldReft False (\_ r bs -> not (hasHole r) : bs) []
diff --git a/src/Language/Haskell/Liquid/Types/Generics.hs b/src/Language/Haskell/Liquid/Types/Generics.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Generics.hs
+++ /dev/null
@@ -1,62 +0,0 @@
-{- | Geriving instances, generically.
-   This module shares some of the underlying ideas and implementations of the
-   [generic-data](https://hackage.haskell.org/package/generic-data-0.8.1.0/docs/Generic-Data.html)
-   package, allowing us to derive a bunch of instances using the underlying 'Generic' implementation,
-   but in a more declarative way.
-
-   In particular we introduc the 'Generically' newtype wrapper to be used with '-XDerivingVia' to make
-   derivation explicit. For example:
-
-@
-  data Foo = Foo
-       deriving Generic
-       deriving Eq via Generically Foo
-@
-
--}
-
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE UndecidableInstances #-}
-
-module Language.Haskell.Liquid.Types.Generics where
-
-import GHC.Generics
-import Data.Hashable
-import Data.Binary
-import Data.Hashable.Generic
-import Data.Function
-
-newtype Generically a = Generically a deriving Generic
-
--- * 'Hashable'
-
-instance (Generic a, GHashable Zero (Rep a)) => Hashable (Generically a) where
-  hashWithSalt s (Generically a) = genericHashWithSalt s a
-
--- * 'Binary'
-
-instance (Generic a, GBinaryPut (Rep a), GBinaryGet (Rep a)) => Binary (Generically a) where
-  get = Generically . to' <$> gget
-  put (Generically a) = gput (from' a)
-
--- * 'Eq'
-
--- | Generic @('==')@.
---
--- @
--- instance 'Eq' MyType where
---   ('==') = 'geq'
--- @
-geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool
-geq = (==) `on` from'
-
-instance (Generic a, Eq (Rep a ())) => Eq (Generically a) where
-  (Generically a) == (Generically b) = geq a b
-
--- | A helper for better type inference.
-from' :: Generic a => a -> Rep a ()
-from' = from
-
-to' :: Generic a => Rep a () -> a
-to' = to
diff --git a/src/Language/Haskell/Liquid/Types/Literals.hs b/src/Language/Haskell/Liquid/Types/Literals.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Literals.hs
+++ /dev/null
@@ -1,50 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Language.Haskell.Liquid.Types.Literals 
-  ( literalFRefType
-  , literalFReft
-  , literalConst
-  , mkI, mkS
-  ) where
-
-import Prelude hiding (error)
-import Language.Haskell.Liquid.GHC.TypeRep ()
-import Language.Haskell.Liquid.GHC.API
-import qualified TyCon  as TC
-
-import Language.Haskell.Liquid.Types.Types
-import Language.Haskell.Liquid.Types.RefType
-import Language.Haskell.Liquid.Transforms.CoreToLogic (mkLit, mkI, mkS)
-
-import qualified Language.Fixpoint.Types as F
-
----------------------------------------------------------------
------------------------ Typing Literals -----------------------
----------------------------------------------------------------
-
-makeRTypeBase :: Monoid r => Type -> r -> RType RTyCon RTyVar r
-makeRTypeBase (TyVarTy α)    x
-  = RVar (rTyVar α) x
-makeRTypeBase (TyConApp c ts) x
-  = rApp c ((`makeRTypeBase` mempty) <$> ts) [] x
-makeRTypeBase _              _
-  = panic Nothing "RefType : makeRTypeBase"
-
-literalFRefType :: Literal -> RType RTyCon RTyVar F.Reft
-literalFRefType l
-  = makeRTypeBase (literalType l) (literalFReft l)
-
-literalFReft :: Literal -> F.Reft
-literalFReft l = maybe mempty mkReft $ mkLit l
-
-mkReft :: F.Expr -> F.Reft
-mkReft = F.exprReft
-
--- | `literalConst` returns `Nothing` for unhandled lits because
---    otherwise string-literals show up as global int-constants
---    which blow up qualifier instantiation.
-
-literalConst :: F.TCEmb TC.TyCon -> Literal -> (F.Sort, Maybe F.Expr)
-literalConst tce l = (t, mkLit l)
-  where
-    t              = typeSort tce $ literalType l
diff --git a/src/Language/Haskell/Liquid/Types/Meet.hs b/src/Language/Haskell/Liquid/Types/Meet.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Meet.hs
+++ /dev/null
@@ -1,38 +0,0 @@
--- | This code has various wrappers around `meet` and `strengthen`
---   that are here so that we can throw decent error messages if
---   they fail. The module depends on `RefType` and `UX.Tidy`.
-
-module Language.Haskell.Liquid.Types.Meet ( meetVarTypes ) where
-
-import           SrcLoc
-import           Text.PrettyPrint.HughesPJ (Doc)
-import qualified Language.Fixpoint.Types as F
-import           Language.Haskell.Liquid.Types.Types
-import           Language.Haskell.Liquid.Types.RefType ()
--- import           Language.Haskell.Liquid.UX.Tidy
-import           TyCon                                  hiding (tyConName)
-
-meetVarTypes :: F.TCEmb TyCon -> Doc -> (SrcSpan, SpecType) -> (SrcSpan, SpecType) -> SpecType
-meetVarTypes _emb _v hs lq = {- meetError emb err -} F.meet hsT lqT
-  where
-    (_hsSp, hsT)      = hs
-    (_lqSp, lqT)      = lq
-    -- _err              = ErrMismatch lqSp v (text "meetVarTypes") hsD lqD hsSp
-    -- _hsD              = F.pprint hsT
-    -- _lqD              = F.pprint lqT
-{- 
-  
-_meetError :: F.TCEmb TyCon -> Error -> SpecType -> SpecType -> SpecType
-_meetError _emb _e t t'
-  -- // | meetable emb t t'
-  | True              = t `F.meet` t'
-  -- // | otherwise         = panicError e
-
-_meetable :: F.TCEmb TyCon -> SpecType -> SpecType -> Bool
-_meetable _emb t1 t2 = F.notracepp ("meetable: " ++  showpp (s1, t1, s2, t2)) (s1 == s2)
-  where
-    s1              = tx t1
-    s2              = tx t2
-    tx              = rTypeSort _emb . toRSort
-
--}
diff --git a/src/Language/Haskell/Liquid/Types/Names.hs b/src/Language/Haskell/Liquid/Types/Names.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Names.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Language.Haskell.Liquid.Types.Names
-  (lenLocSymbol, anyTypeSymbol, functionComposisionSymbol) where
-
-import Language.Fixpoint.Types
-
--- RJ: Please add docs
-lenLocSymbol :: Located Symbol
-lenLocSymbol = dummyLoc $ symbol ("autolen" :: String)
-
-anyTypeSymbol :: Symbol
-anyTypeSymbol = symbol ("GHC.Prim.Any" :: String)
-
-
---  defined in include/GHC/Base.hs
-functionComposisionSymbol :: Symbol
-functionComposisionSymbol = symbol ("GHC.Base.." :: String)
diff --git a/src/Language/Haskell/Liquid/Types/PredType.hs b/src/Language/Haskell/Liquid/Types/PredType.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/PredType.hs
+++ /dev/null
@@ -1,537 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable   #-}
-{-# LANGUAGE FlexibleContexts     #-}
-{-# LANGUAGE FlexibleInstances    #-}
-{-# LANGUAGE OverloadedStrings    #-}
-{-# LANGUAGE TupleSections        #-}
-{-# LANGUAGE UndecidableInstances #-}
-
-module Language.Haskell.Liquid.Types.PredType (
-    PrType
-  , TyConP (..), DataConP (..)
-  , dataConTy
-  , dataConPSpecType
-  , makeTyConInfo
-  , replacePreds
-  , replacePredsWithRefs
-  , pVartoRConc
-
-  -- * Dummy `Type` that represents _all_ abstract-predicates
-  , predType
-
-  -- * Compute @RType@ of a given @PVar@
-  , pvarRType
-  , substParg
-  , pApp
-  , pappSort
-  , pappArity
-
-  -- * should be elsewhere
-  , dataConWorkRep
-  ) where
-
-import           Prelude                         hiding (error)
-import           DataCon
-import           Text.PrettyPrint.HughesPJ
-import           Language.Haskell.Liquid.GHC.API
-import           Language.Haskell.Liquid.GHC.TypeRep ()
-import           Data.Hashable
-import qualified Data.HashMap.Strict             as M
-import qualified Data.Maybe                                 as Mb 
-import qualified Data.List         as L -- (foldl', partition)
--- import           Data.List                       (nub)
-
-import           Language.Fixpoint.Misc
-
--- import           Language.Fixpoint.Types         hiding (Expr, Predicate)
-import qualified Language.Fixpoint.Types                    as F
-import qualified Language.Haskell.Liquid.GHC.API            as Ghc 
-import           Language.Haskell.Liquid.GHC.Misc
-import           Language.Haskell.Liquid.Misc
-import           Language.Haskell.Liquid.Types.RefType hiding (generalize)
-import           Language.Haskell.Liquid.Types.Types
-import           Data.Default
-
-makeTyConInfo :: F.TCEmb Ghc.TyCon -> [Ghc.TyCon] -> [TyConP] -> TyConMap
-makeTyConInfo tce fiTcs tcps = TyConMap 
-  { tcmTyRTy    = tcM
-  , tcmFIRTy    = tcInstM 
-  , tcmFtcArity = arities
-  }
-  where 
-    tcM         = M.fromList [(tcpCon tcp, mkRTyCon tcp) | tcp <- tcps ]
-    tcInstM     = mkFInstRTyCon tce fiTcs tcM 
-    arities     = safeFromList "makeTyConInfo" [ (c, length ts) | (c, ts) <- M.keys tcInstM ]
-
-mkFInstRTyCon :: F.TCEmb Ghc.TyCon -> [Ghc.TyCon] -> M.HashMap Ghc.TyCon RTyCon -> M.HashMap (Ghc.TyCon, [F.Sort]) RTyCon
-mkFInstRTyCon tce fiTcs tcm = M.fromList 
-  [ ((c, typeSort tce <$> ts), rtc) 
-    | fiTc    <- fiTcs
-    , rtc     <- Mb.maybeToList (M.lookup fiTc tcm)
-    , (c, ts) <- Mb.maybeToList (famInstArgs fiTc)
-  ] 
-
-mkRTyCon ::  TyConP -> RTyCon
-mkRTyCon (TyConP _ tc αs' ps tyvariance predvariance size)
-  = RTyCon tc pvs' (mkTyConInfo tc tyvariance predvariance size)
-  where
-    τs   = [rVar α :: RSort |  α <- tyConTyVarsDef tc]
-    pvs' = subts (zip αs' τs) <$> ps
-
-
--------------------------------------------------------------------------------
--- | @dataConPSpecType@ converts a @DataConP@, LH's internal representation for 
---   a (refined) data constructor into a @SpecType@ for that constructor.
---   TODO: duplicated with Liquid.Measure.makeDataConType
--------------------------------------------------------------------------------
-dataConPSpecType :: DataConP -> [(Var, SpecType)]
--------------------------------------------------------------------------------
-dataConPSpecType dcp    = [(workX, workT), (wrapX, wrapT) ]
-  where
-    workT | isVanilla   = wrapT
-          | otherwise   = dcWorkSpecType   dc wrapT
-    wrapT               = dcWrapSpecType   dc dcp
-    workX               = dataConWorkId    dc            -- This is the weird one for GADTs
-    wrapX               = dataConWrapId    dc            -- This is what the user expects to see
-    isVanilla           = isVanillaDataCon dc
-    dc                  = dcpCon dcp
-
-dcWorkSpecType :: DataCon -> SpecType -> SpecType
-dcWorkSpecType c wrT    = fromRTypeRep (meetWorkWrapRep c wkR wrR)
-  where
-    wkR                 = dataConWorkRep c
-    wrR                 = toRTypeRep wrT
-
-dataConWorkRep :: DataCon -> SpecRep
-dataConWorkRep c = toRTypeRep
-                 -- . F.tracepp ("DCWR-2: " ++ F.showpp c)
-                 . ofType
-                 -- . F.tracepp ("DCWR-1: " ++ F.showpp c)
-                 . dataConRepType
-                 -- . Var.varType
-                 -- . dataConWorkId
-                 $ c
-{-
-dataConWorkRep :: DataCon -> SpecRep
-dataConWorkRep dc = RTypeRep
-  { ty_vars   = as
-  , ty_preds  = []
-  , ty_labels = []
-  , ty_binds  = replicate nArgs F.dummySymbol
-  , ty_refts  = replicate nArgs mempty
-  , ty_args   = ts'
-  , ty_res    = t'
-  }
-  where
-    (ts', t')          = F.tracepp "DCWR-1" (ofType <$> ts, ofType t)
-    as                 = makeRTVar . rTyVar <$> αs
-    tArg
-    (αs,_,eqs,th,ts,t) = dataConFullSig dc
-    nArgs              = length ts
-
-dataConResultTy :: DataCon -> [TyVar] -> Type -> Type
-dataConResultTy dc αs t = mkFamilyTyConApp tc tArgs'
-  where
-    tArgs'              = take (nArgs - nVars) tArgs ++ (mkTyVarTy <$> αs)
-    nVars               = length αs
-    nArgs               = length tArgs
-    (tc, tArgs)         = fromMaybe err (splitTyConApp_maybe _t)
-    err                 = GM.namedPanic dc ("Cannot split result type of DataCon " ++ show dc)
-
-  --  t                 = RT.ofType  $  mkFamilyTyConApp tc tArgs'
-  -- as                = makeRTVar . rTyVar <$> αs
-  --  (αs,_,_,_,_ts,_t) = dataConFullSig dc
-
--}
-
-meetWorkWrapRep :: DataCon -> SpecRep -> SpecRep -> SpecRep
-meetWorkWrapRep c workR wrapR
-  | 0 <= pad
-  = workR { ty_binds = xs ++ (ty_binds wrapR)
-          , ty_args  = ts ++ zipWith F.meet ts' (ty_args wrapR) 
-          , ty_res   = strengthenRType (ty_res workR)    (ty_res  wrapR)
-          , ty_preds = ty_preds wrapR
-          }
-  | otherwise
-  = panic (Just (getSrcSpan c)) errMsg
-  where
-    pad       = {- F.tracepp ("MEETWKRAP: " ++ show (ty_vars workR)) $ -} workN - wrapN
-    (xs, _)   = splitAt pad (ty_binds workR)
-    (ts, ts') = splitAt pad (ty_args  workR)
-    workN     = length      (ty_args  workR)
-    wrapN     = length      (ty_args  wrapR)
-    errMsg    = "Unsupported Work/Wrap types for Data Constructor " ++ showPpr c
-
-strengthenRType :: SpecType -> SpecType -> SpecType
-strengthenRType wkT wrT = maybe wkT (strengthen wkT) (stripRTypeBase wrT)
-
-dcWrapSpecType :: DataCon -> DataConP -> SpecType
-dcWrapSpecType dc (DataConP _ _ vs ps cs yts rt _ _ _)
-  = {- F.tracepp ("dcWrapSpecType: " ++ show dc ++ " " ++ F.showpp rt) $ -}
-    mkArrow makeVars' ps [] ts' rt'
-  where
-    (xs, ts) = unzip (reverse yts)
-    mkDSym z = (F.symbol z) `F.suffixSymbol` (F.symbol dc)
-    ys       = mkDSym <$> xs
-    tx _  []     []     []     = []
-    tx su (x:xs) (y:ys) (t:ts) = (y, F.subst (F.mkSubst su) t, mempty)
-                               : tx ((x, F.EVar y):su) xs ys ts
-    tx _ _ _ _ = panic Nothing "PredType.dataConPSpecType.tx called on invalid inputs"
-    yts'     = tx [] xs ys ts
-    ts'      = map ("" , , mempty) cs ++ yts'
-    su       = F.mkSubst [(x, F.EVar y) | (x, y) <- zip xs ys]
-    rt'      = F.subst su rt
-    makeVars = zipWith (\v a -> RTVar v (rTVarInfo a :: RTVInfo RSort)) vs (fst $ splitForAllTys $ dataConRepType dc)
-    makeVars' = zip makeVars (repeat mempty)
-
-instance PPrint TyConP where
-  pprintTidy k tc = "data" <+> pprintTidy k (tcpCon tc) 
-                           <+> ppComm     k (tcpFreeTyVarsTy tc) 
-                           <+> ppComm     k (tcpFreePredTy   tc) 
-      --  (parens $ hsep (punctuate comma (pprintTidy k <$> vs))) <+>
-      -- (parens $ hsep (punctuate comma (pprintTidy k <$> ps))) <+>
-      -- (parens $ hsep (punctuate comma (pprintTidy k <$> ls)))
-
-ppComm :: PPrint a => F.Tidy -> [a] -> Doc 
-ppComm k = parens . hsep . punctuate comma . fmap (pprintTidy k)
-
-
-    
-
-instance Show TyConP where
- show = showpp -- showSDoc . ppr
-
-instance PPrint DataConP where
-  pprintTidy k (DataConP _ dc vs ps cs yts t isGadt mname _)
-     =  pprintTidy k dc
-    <+> (parens $ hsep (punctuate comma (pprintTidy k <$> vs)))
-    <+> (parens $ hsep (punctuate comma (pprintTidy k <$> ps)))
-    <+> (parens $ hsep (punctuate comma (pprintTidy k <$> cs)))
-    <+> (parens $ hsep (punctuate comma (pprintTidy k <$> yts)))
-    <+> (pprintTidy k isGadt)
-    <+> (pprintTidy k mname)
-    <+>  pprintTidy k t
-
-instance Show DataConP where
-  show = showpp
-
-dataConTy :: Monoid r
-          => M.HashMap RTyVar (RType RTyCon RTyVar r)
-          -> Type -> RType RTyCon RTyVar r
-dataConTy m (TyVarTy v)
-  = M.lookupDefault (rVar v) (RTV v) m
-dataConTy m (FunTy _ t1 t2)
-  = rFun F.dummySymbol (dataConTy m t1) (dataConTy m t2)
-dataConTy m (ForAllTy (Bndr α _) t) -- α :: TyVar
-  = RAllT (makeRTVar (RTV α)) (dataConTy m t) mempty
-dataConTy m (TyConApp c ts)
-  = rApp c (dataConTy m <$> ts) [] mempty
-dataConTy _ _
-  = panic Nothing "ofTypePAppTy"
-
-----------------------------------------------------------------------------
--- | Interface: Replace Predicate With Uninterpreted Function Symbol -------
-----------------------------------------------------------------------------
-replacePredsWithRefs :: (UsedPVar, (F.Symbol, [((), F.Symbol, F.Expr)]) -> F.Expr)
-                     -> UReft F.Reft -> UReft F.Reft
-replacePredsWithRefs (p, r) (MkUReft (F.Reft(v, rs)) (Pr ps))
-  = MkUReft (F.Reft (v, rs'')) (Pr ps2)
-  where
-    rs''             = mconcat $ rs : rs'
-    rs'              = r . (v,) . pargs <$> ps1
-    (ps1, ps2)       = L.partition (== p) ps
-
-pVartoRConc :: PVar t -> (F.Symbol, [(a, b, F.Expr)]) -> F.Expr
-pVartoRConc p (v, args) | length args == length (pargs p)
-  = pApp (pname p) $ F.EVar v : (thd3 <$> args)
-
-pVartoRConc p (v, args)
-  = pApp (pname p) $ F.EVar v : args'
-  where
-    args' = (thd3 <$> args) ++ (drop (length args) (thd3 <$> pargs p))
-
------------------------------------------------------------------------
--- | @pvarRType π@ returns a trivial @RType@ corresponding to the
---   function signature for a @PVar@ @π@. For example, if
---      @π :: T1 -> T2 -> T3 -> Prop@
---   then @pvarRType π@ returns an @RType@ with an @RTycon@ called
---   @predRTyCon@ `RApp predRTyCon [T1, T2, T3]`
------------------------------------------------------------------------
-pvarRType :: (PPrint r, F.Reftable r) => PVar RSort -> RRType r
------------------------------------------------------------------------
-pvarRType (PV _ k {- (PVProp τ) -} _ args) = rpredType k (fst3 <$> args) -- (ty:tys)
-  -- where
-  --   ty  = uRTypeGen τ
-  --   tys = uRTypeGen . fst3 <$> args
-
-
--- rpredType    :: (PPrint r, Reftable r) => PVKind (RRType r) -> [RRType r] -> RRType r
-rpredType :: F.Reftable r
-          => PVKind (RType RTyCon tv a)
-          -> [RType RTyCon tv a] -> RType RTyCon tv r
-rpredType (PVProp t) ts = RApp predRTyCon  (uRTypeGen <$> t : ts) [] mempty
-rpredType PVHProp    ts = RApp wpredRTyCon (uRTypeGen <$>     ts) [] mempty
-
-predRTyCon   :: RTyCon
-predRTyCon   = symbolRTyCon predName
-
-wpredRTyCon   :: RTyCon
-wpredRTyCon   = symbolRTyCon wpredName
-
-symbolRTyCon   :: F.Symbol -> RTyCon
-symbolRTyCon n = RTyCon (stringTyCon 'x' 42 $ F.symbolString n) [] def
-
--------------------------------------------------------------------------------------
--- | Instantiate `PVar` with `RTProp` -----------------------------------------------
--------------------------------------------------------------------------------------
--- | @replacePreds@ is the main function used to substitute an (abstract)
---   predicate with a concrete Ref, that is either an `RProp` or `RHProp`
---   type. The substitution is invoked to obtain the `SpecType` resulting
---   at /predicate application/ sites in 'Language.Haskell.Liquid.Constraint'.
---   The range of the `PVar` substitutions are /fresh/ or /true/ `RefType`.
---   That is, there are no further _quantified_ `PVar` in the target.
--------------------------------------------------------------------------------------
-replacePreds                 :: String -> SpecType -> [(RPVar, SpecProp)] -> SpecType
--------------------------------------------------------------------------------------
-replacePreds msg                 = L.foldl' go
-  where
-     go _ (_, RProp _ (RHole _)) = panic Nothing "replacePreds on RProp _ (RHole _)"
-     go z (π, t)                 = substPred msg   (π, t)     z
-
-
--- TODO: replace `replacePreds` with
--- instance SubsTy RPVar (Ref RReft SpecType) SpecType where
---   subt (pv, r) t = replacePreds "replacePred" t (pv, r)
-
--- replacePreds :: String -> SpecType -> [(RPVar, Ref Reft RefType)] -> SpecType
--- replacePreds msg       = foldl' go
---   where go z (π, RProp t) = substPred msg   (π, t)     z
---         go z (π, RPropP r) = replacePVarReft (π, r) <$> z
-
--------------------------------------------------------------------------------
-substPred :: String -> (RPVar, SpecProp) -> SpecType -> SpecType
--------------------------------------------------------------------------------
-
-substPred _   (π, RProp ss (RVar a1 r1)) t@(RVar a2 r2)
-  | isPredInReft && a1 == a2    = RVar a1 $ meetListWithPSubs πs ss r1 r2'
-  | isPredInReft                = panic Nothing ("substPred RVar Var Mismatch" ++ show (a1, a2))
-  | otherwise                   = t
-  where
-    (r2', πs)                   = splitRPvar π r2
-    isPredInReft                = not $ null πs
-
-substPred msg su@(π, _ ) (RApp c ts rs r)
-  | null πs                     = t'
-  | otherwise                   = substRCon msg su t' πs r2'
-  where
-    t'                          = RApp c (substPred msg su <$> ts) (substPredP msg su <$> rs) r
-    (r2', πs)                   = splitRPvar π r
-
-substPred msg (p, tp) (RAllP (q@(PV _ _ _ _)) t)
-  | p /= q                      = RAllP q $ substPred msg (p, tp) t
-  | otherwise                   = RAllP q t
-
-substPred msg su (RAllT a t r)  = RAllT a (substPred msg su t) r
-
-substPred msg su@(π,prop) (RFun x t t' r)
---                        = RFun x (substPred msg su t) (substPred msg su t') r
-  | null πs                     = RFun x (substPred msg su t) (substPred msg su t') r
-  | otherwise                   =
-      let sus = (\π -> F.mkSubst (zip (fst <$> rf_args prop) (thd3 <$> pargs π))) <$> πs in
-      foldl (\t su -> t `F.meet` F.subst su (rf_body prop)) (RFun x (substPred msg su t) (substPred msg su t') r') sus
-  where (r', πs)                = splitRPvar π r
--- ps has   , pargs :: ![(t, Symbol, Expr)]
-
--- AT: just a copy of the other case, mutatis mutandi. (is there a less hacky way?)
-substPred msg su@(π,prop) (RImpF x t t' r)
-  | null πs                     = RImpF x (substPred msg su t) (substPred msg su t') r
-  | otherwise                   =
-      let sus = (\π -> F.mkSubst (zip (fst <$> rf_args prop) (thd3 <$> pargs π))) <$> πs in
-      foldl (\t su -> t `F.meet` F.subst su (rf_body prop)) (RImpF x (substPred msg su t) (substPred msg su t') r') sus
-  where (r', πs)                = splitRPvar π r
-
-
-
-substPred msg su (RRTy e r o t) = RRTy (mapSnd (substPred msg su) <$> e) r o (substPred msg su t)
-substPred msg su (RAllE x t t') = RAllE x (substPred msg su t) (substPred msg su t')
-substPred msg su (REx x t t')   = REx   x (substPred msg su t) (substPred msg su t')
-substPred _   _  t              = t
-
--- | Requires: @not $ null πs@
--- substRCon :: String -> (RPVar, SpecType) -> SpecType -> SpecType
-
-substRCon
-  :: (PPrint t, PPrint t2, Eq tv, F.Reftable r, Hashable tv, PPrint tv, PPrint r,
-      SubsTy tv (RType RTyCon tv ()) r,
-      SubsTy tv (RType RTyCon tv ()) (RType RTyCon tv ()),
-      SubsTy tv (RType RTyCon tv ()) RTyCon,
-      SubsTy tv (RType RTyCon tv ()) tv,
-      F.Reftable (RType RTyCon tv r),
-      SubsTy tv (RType RTyCon tv ()) (RTVar tv (RType RTyCon tv ())),
-      FreeVar RTyCon tv,
-      F.Reftable (RTProp RTyCon tv r),
-      F.Reftable (RTProp RTyCon tv ()))
-  => [Char]
-  -> (t, Ref RSort (RType RTyCon tv r))
-  -> RType RTyCon tv r
-  -> [PVar t2]
-  -> r
-  -> RType RTyCon tv r
-substRCon msg (_, RProp ss t1@(RApp c1 ts1 rs1 r1)) t2@(RApp c2 ts2 rs2 _) πs r2'
-  | rtc_tc c1 == rtc_tc c2 = RApp c1 ts rs $ meetListWithPSubs πs ss r1 r2'
-  where
-    ts                     = F.subst su $ safeZipWith (msg ++ ": substRCon")  strSub  ts1  ts2
-    rs                     = F.subst su $ safeZipWith (msg ++ ": substRCon2") strSubR rs1' rs2'
-    (rs1', rs2')           = pad "substRCon" F.top rs1 rs2
-    strSub r1 r2           = meetListWithPSubs πs ss r1 r2
-    strSubR r1 r2          = meetListWithPSubsRef πs ss r1 r2
-
-    su = F.mkSubst $ zipWith (\s1 s2 -> (s1, F.EVar s2)) (rvs t1) (rvs t2)
-
-    rvs      = foldReft False (\_ r acc -> rvReft r : acc) []
-    rvReft r = let F.Reft(s,_) = F.toReft r in s
-
-substRCon msg su t _ _        = {- panic Nothing -} errorP "substRCon: " $ msg ++ " " ++ showpp (su, t)
-
-pad :: [Char] -> (a -> a) -> [a] -> [a] -> ([a], [a])
-pad _ f [] ys   = (f <$> ys, ys)
-pad _ f xs []   = (xs, f <$> xs)
-pad msg _ xs ys
-  | nxs == nys  = (xs, ys)
-  | otherwise   = panic Nothing $ "pad: " ++ msg
-  where
-    nxs         = length xs
-    nys         = length ys
-
-substPredP :: [Char]
-           -> (RPVar, Ref RSort (RRType RReft))
-           -> Ref RSort (RType RTyCon RTyVar RReft)
-           -> Ref RSort SpecType
-substPredP _ su p@(RProp _ (RHole _))
-  = panic Nothing ("PredType.substPredP1 called on invalid inputs: " ++ showpp (su, p))
-substPredP msg (p, RProp ss prop) (RProp s t)
-  = RProp ss' $ substPred (msg ++ ": substPredP") (p, RProp ss {- (subst su prop) -} prop ) t
- where
-   ss' = drop n ss ++  s
-   n   = length ss - length (freeArgsPs p t)
-   -- su  = mkSubst (zip (fst <$> ss) (EVar . fst <$> ss'))
-
-
-splitRPvar :: PVar t -> UReft r -> (UReft r, [UsedPVar])
-splitRPvar pv (MkUReft x (Pr pvs)) = (MkUReft x (Pr pvs'), epvs)
-  where
-    (epvs, pvs')               = L.partition (uPVar pv ==) pvs
-
--- TODO: rewrite using foldReft
-freeArgsPs :: PVar (RType t t1 ()) -> RType t t1 (UReft t2) -> [F.Symbol]
-freeArgsPs p (RVar _ r)
-  = freeArgsPsRef p r
-freeArgsPs p (RImpF _ t1 t2 r)
-  = L.nub $  freeArgsPsRef p r ++ freeArgsPs p t1 ++ freeArgsPs p t2
-freeArgsPs p (RFun _ t1 t2 r)
-  = L.nub $  freeArgsPsRef p r ++ freeArgsPs p t1 ++ freeArgsPs p t2
-freeArgsPs p (RAllT _ t r)
-  = L.nub $  freeArgsPs p t ++ freeArgsPsRef p r
-freeArgsPs p (RAllP p' t)
-  | p == p'   = []
-  | otherwise = freeArgsPs p t
-freeArgsPs p (RApp _ ts _ r)
-  = L.nub $ freeArgsPsRef p r ++ concatMap (freeArgsPs p) ts
-freeArgsPs p (RAllE _ t1 t2)
-  = L.nub $ freeArgsPs p t1 ++ freeArgsPs p t2
-freeArgsPs p (REx _ t1 t2)
-  = L.nub $ freeArgsPs p t1 ++ freeArgsPs p t2
-freeArgsPs p (RAppTy t1 t2 r)
-  = L.nub $ freeArgsPsRef p r ++ freeArgsPs p t1 ++ freeArgsPs p t2
-freeArgsPs _ (RExprArg _)
-  = []
-freeArgsPs p (RHole r)
-  = freeArgsPsRef p r
-freeArgsPs p (RRTy env r _ t)
-  = L.nub $ concatMap (freeArgsPs p) (snd <$> env) ++ freeArgsPsRef p r ++ freeArgsPs p t
-
-freeArgsPsRef :: PVar t1 -> UReft t -> [F.Symbol]
-freeArgsPsRef p (MkUReft _ (Pr ps)) = [x | (_, x, w) <- (concatMap pargs ps'),  (F.EVar x) == w]
-  where
-   ps' = f <$> filter (uPVar p ==) ps
-   f q = q {pargs = pargs q ++ drop (length (pargs q)) (pargs $ uPVar p)}
-
-meetListWithPSubs :: (Foldable t, PPrint t1, F.Reftable b)
-                  => t (PVar t1) -> [(F.Symbol, RSort)] -> b -> b -> b
-meetListWithPSubs πs ss r1 r2    = L.foldl' (meetListWithPSub ss r1) r2 πs
-
-meetListWithPSubsRef :: (Foldable t, F.Reftable (RType t1 t2 t3))
-                     => t (PVar t4)
-                     -> [(F.Symbol, b)]
-                     -> Ref τ (RType t1 t2 t3)
-                     -> Ref τ (RType t1 t2 t3)
-                     -> Ref τ (RType t1 t2 t3)
-meetListWithPSubsRef πs ss r1 r2 = L.foldl' ((meetListWithPSubRef ss) r1) r2 πs
-
-meetListWithPSub ::  (F.Reftable r, PPrint t) => [(F.Symbol, RSort)]-> r -> r -> PVar t -> r
-meetListWithPSub ss r1 r2 π
-  | all (\(_, x, F.EVar y) -> x == y) (pargs π)
-  = r2 `F.meet` r1
-  | all (\(_, x, F.EVar y) -> x /= y) (pargs π)
-  = r2 `F.meet` (F.subst su r1)
-  | otherwise
-  = panic Nothing $ "PredType.meetListWithPSub partial application to " ++ showpp π
-  where
-    su  = F.mkSubst [(x, y) | (x, (_, _, y)) <- zip (fst <$> ss) (pargs π)]
-
-meetListWithPSubRef :: (F.Reftable (RType t t1 t2))
-                    => [(F.Symbol, b)]
-                    -> Ref τ (RType t t1 t2)
-                    -> Ref τ (RType t t1 t2)
-                    -> PVar t3
-                    -> Ref τ (RType t t1 t2)
-meetListWithPSubRef _ (RProp _ (RHole _)) _ _ -- TODO: Is this correct?
-  = panic Nothing "PredType.meetListWithPSubRef called with invalid input"
-meetListWithPSubRef _ _ (RProp _ (RHole _)) _
-  = panic Nothing "PredType.meetListWithPSubRef called with invalid input"
-meetListWithPSubRef ss (RProp s1 r1) (RProp s2 r2) π
-  | all (\(_, x, F.EVar y) -> x == y) (pargs π)
-  = RProp s1 $ (F.subst su' r2) `F.meet` r1
-  | all (\(_, x, F.EVar y) -> x /= y) (pargs π)
-  = RProp s2 $ r2 `F.meet` (F.subst su r1)
-  | otherwise
-  = panic Nothing $ "PredType.meetListWithPSubRef partial application to " ++ showpp π
-  where
-    su  = F.mkSubst [(x, y) | (x, (_, _, y)) <- zip (fst <$> ss) (pargs π)]
-    su' = F.mkSubst [(x, F.EVar y) | (x, y) <- zip (fst <$> s2) (fst <$> s1)]
-
-
-----------------------------------------------------------------------------
--- | Interface: Modified CoreSyn.exprType due to predApp -------------------
-----------------------------------------------------------------------------
-predType   :: Type
-predType   = symbolType predName
-
-wpredName, predName :: F.Symbol
-predName   = "Pred"
-wpredName  = "WPred"
-
-symbolType :: F.Symbol -> Type
-symbolType = TyVarTy . symbolTyVar
-
-
-substParg :: Functor f => (F.Symbol, F.Expr) -> f Predicate -> f Predicate
-substParg (x, y) = fmap fp
-  where
-    fxy s        = if (s == F.EVar x) then y else s
-    fp           = subvPredicate (\pv -> pv { pargs = mapThd3 fxy <$> pargs pv })
-
--------------------------------------------------------------------------------
------------------------------  Predicate Application --------------------------
--------------------------------------------------------------------------------
-pappArity :: Int
-pappArity  = 7
-
-pappSort :: Int -> F.Sort
-pappSort n = F.mkFFunc (2 * n) $ [ptycon] ++ args ++ [F.boolSort]
-  where
-    ptycon = F.fAppTC predFTyCon $ F.FVar <$> [0..n-1]
-    args   = F.FVar <$> [n..(2*n-1)]
-
-
-predFTyCon :: F.FTycon
-predFTyCon = F.symbolFTycon $ dummyLoc predName
diff --git a/src/Language/Haskell/Liquid/Types/PrettyPrint.hs b/src/Language/Haskell/Liquid/Types/PrettyPrint.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/PrettyPrint.hs
+++ /dev/null
@@ -1,427 +0,0 @@
--- | This module contains a single function that converts a RType -> Doc
---   without using *any* simplifications.
-
-{-# LANGUAGE OverloadedStrings    #-}
-{-# LANGUAGE ConstraintKinds      #-}
-{-# LANGUAGE FlexibleContexts     #-}
-{-# LANGUAGE TupleSections        #-}
-{-# LANGUAGE UndecidableInstances #-}
-{-# LANGUAGE MonoLocalBinds       #-}
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE FlexibleInstances    #-}
-
-module Language.Haskell.Liquid.Types.PrettyPrint
-  ( -- * Printable RTypes
-    OkRT
-
-    -- * Printers
-  , rtypeDoc
-
-  -- * Printing Lists (TODO: move to fixpoint)
-  , pprManyOrdered
-  , pprintLongList
-  , pprintSymbol
-
-  -- * Printing diagnostics
-  , printWarning
-  , printError
-
-  -- * Reporting errors in the typechecking phase
-  , reportErrors
-
-  ) where
-
-import           Control.Monad
-
-import qualified Data.HashMap.Strict              as M
-import qualified Data.List                        as L                               -- (sort)
-import           Data.String
-import qualified TcRnMonad                        as Ghc
-import qualified CoreSyn as GHC
-import           Language.Fixpoint.Misc
-import qualified Language.Fixpoint.Types          as F
-import           Language.Haskell.Liquid.GHC.API  as Ghc hiding (maybeParen, LM)
-import           Language.Haskell.Liquid.GHC.Logging (putErrMsg, mkLongErrAt)
-import           Language.Haskell.Liquid.GHC.Misc
-import           Language.Haskell.Liquid.Misc
-import           Language.Haskell.Liquid.Types.Types
-import           Prelude                          hiding (error)
-import           Text.PrettyPrint.HughesPJ        hiding ((<>))
-
---------------------------------------------------------------------------------
-pprManyOrdered :: (PPrint a, Ord a) => F.Tidy -> String -> [a] -> [Doc]
---------------------------------------------------------------------------------
-pprManyOrdered k msg = map ((text msg <+>) . pprintTidy k) . L.sort
-
---------------------------------------------------------------------------------
-pprintLongList :: PPrint a => F.Tidy -> [a] -> Doc
---------------------------------------------------------------------------------
-pprintLongList k = brackets . vcat . map (pprintTidy k)
-
-
---------------------------------------------------------------------------------
-pprintSymbol :: F.Symbol -> Doc
---------------------------------------------------------------------------------
-pprintSymbol x = char '‘' <-> pprint x <-> char '’'
-
-
---------------------------------------------------------------------------------
--- | A whole bunch of PPrint instances follow ----------------------------------
---------------------------------------------------------------------------------
-instance PPrint ErrMsg where
-  pprintTidy _ = text . show
-
-instance PPrint SourceError where
-  pprintTidy _ = text . show
-
-instance PPrint Var where
-  pprintTidy _ = pprDoc
-
-instance PPrint (GHC.Expr Var) where
-  pprintTidy _ = pprDoc
-
-instance PPrint (GHC.Bind Var) where
-  pprintTidy _ = pprDoc
-
-instance PPrint Name where
-  pprintTidy _ = pprDoc
-
-instance PPrint TyCon where
-  pprintTidy F.Lossy = shortModules . pprDoc
-  pprintTidy F.Full  =                pprDoc
-
-instance PPrint Type where
-  pprintTidy _ = pprDoc -- . tidyType emptyTidyEnv -- WHY WOULD YOU DO THIS???
-
-instance PPrint Class where
-  pprintTidy F.Lossy = shortModules . pprDoc
-  pprintTidy F.Full  =                pprDoc
-
-instance Show Predicate where
-  show = showpp
-
-instance (PPrint t) => PPrint (Annot t) where
-  pprintTidy k (AnnUse t) = text "AnnUse" <+> pprintTidy k t
-  pprintTidy k (AnnDef t) = text "AnnDef" <+> pprintTidy k t
-  pprintTidy k (AnnRDf t) = text "AnnRDf" <+> pprintTidy k t
-  pprintTidy _ (AnnLoc l) = text "AnnLoc" <+> pprDoc l
-
-instance PPrint a => PPrint (AnnInfo a) where
-  pprintTidy k (AI m) = vcat $ pprAnnInfoBinds k <$> M.toList m
-
-instance PPrint a => Show (AnnInfo a) where
-  show = showpp
-
-pprAnnInfoBinds :: (PPrint a, PPrint b) => F.Tidy -> (SrcSpan, [(Maybe a, b)]) -> Doc
-pprAnnInfoBinds k (l, xvs)
-  = vcat $ (pprAnnInfoBind k . (l,)) <$> xvs
-
-pprAnnInfoBind :: (PPrint a, PPrint b) => F.Tidy -> (SrcSpan, (Maybe a, b)) -> Doc
-pprAnnInfoBind k (RealSrcSpan sp, xv)
-  = xd $$ pprDoc l $$ pprDoc c $$ pprintTidy k n $$ vd $$ text "\n\n\n"
-    where
-      l        = srcSpanStartLine sp
-      c        = srcSpanStartCol sp
-      (xd, vd) = pprXOT k xv
-      n        = length $ lines $ render vd
-
-pprAnnInfoBind _ (_, _)
-  = empty
-
-pprXOT :: (PPrint a, PPrint a1) => F.Tidy -> (Maybe a, a1) -> (Doc, Doc)
-pprXOT k (x, v) = (xd, pprintTidy k v)
-  where
-    xd          = maybe "unknown" (pprintTidy k) x
-
-instance PPrint LMap where
-  pprintTidy _ (LMap x xs e) = hcat [pprint x, pprint xs, text "|->", pprint e ]
-
-instance PPrint LogicMap where
-  pprintTidy _ (LM lm am) = vcat [ text "Logic Map"
-                                 , nest 2 $ text "logic-map"
-                                 , nest 4 $ pprint lm
-                                 , nest 2 $ text "axiom-map"
-                                 , nest 4 $ pprint am
-                                 ]
-                    
---------------------------------------------------------------------------------
--- | Pretty Printing RefType ---------------------------------------------------
---------------------------------------------------------------------------------
-instance (OkRT c tv r) => PPrint (RType c tv r) where
-  -- RJ: THIS IS THE CRUCIAL LINE, the following prints short types.
-  pprintTidy _ = rtypeDoc F.Lossy
-  -- pprintTidy _ = ppRType topPrec
-
-instance (PPrint tv, PPrint ty) => PPrint (RTAlias tv ty) where
-  pprintTidy = ppAlias
-
-ppAlias :: (PPrint tv, PPrint ty) => F.Tidy -> RTAlias tv ty -> Doc
-ppAlias k a =   pprint (rtName a)
-            <+> pprints k space (rtTArgs a)
-            <+> pprints k space (rtVArgs a)
-            <+> text " = "
-            <+> pprint (rtBody a)
-
-instance (F.PPrint tv, F.PPrint t) => F.PPrint (RTEnv tv t) where 
-  pprintTidy k rte 
-    =   text "** Type Aliaes *********************" 
-    $+$ nest 4 (F.pprintTidy k (typeAliases rte)) 
-    $+$ text "** Expr Aliases ********************" 
-    $+$ nest 4 (F.pprintTidy k (exprAliases rte))
-
-pprints :: (PPrint a) => F.Tidy -> Doc -> [a] -> Doc
-pprints k c = sep . punctuate c . map (pprintTidy k)
-
---------------------------------------------------------------------------------
-rtypeDoc :: (OkRT c tv r) => F.Tidy -> RType c tv r -> Doc
---------------------------------------------------------------------------------
-rtypeDoc k      = ppr_rtype (ppE k) topPrec
-  where
-    ppE F.Lossy = ppEnvShort ppEnv
-    ppE F.Full  = ppEnv
-
-instance PPrint F.Tidy where
-  pprintTidy _ F.Full  = "Full"
-  pprintTidy _ F.Lossy = "Lossy"
-
-type Prec = PprPrec 
-
---------------------------------------------------------------------------------
-ppr_rtype :: (OkRT c tv r) => PPEnv -> Prec -> RType c tv r -> Doc
---------------------------------------------------------------------------------
-ppr_rtype bb p t@(RAllT _ _ r)
-  = F.ppTy r $ ppr_forall bb p t
-ppr_rtype bb p t@(RAllP _ _)
-  = ppr_forall bb p t
-ppr_rtype _ _ (RVar a r)
-  = F.ppTy r $ pprint a
-ppr_rtype bb p t@(RImpF _ _ _ _)
-  = maybeParen p funPrec (ppr_rty_fun bb empty t)
-ppr_rtype bb p t@(RFun _ _ _ _)
-  = maybeParen p funPrec (ppr_rty_fun bb empty t)
-ppr_rtype bb p (RApp c [t] rs r)
-  | isList c
-  = F.ppTy r $ brackets (ppr_rtype bb p t) <-> ppReftPs bb p rs
-ppr_rtype bb p (RApp c ts rs r)
-  | isTuple c
-  = F.ppTy r $ parens (intersperse comma (ppr_rtype bb p <$> ts)) <-> ppReftPs bb p rs
-ppr_rtype bb p (RApp c ts rs r)
-  | isEmpty rsDoc && isEmpty tsDoc
-  = F.ppTy r $ ppT c
-  | otherwise
-  = F.ppTy r $ parens $ ppT c <+> rsDoc <+> tsDoc
-  where
-    rsDoc            = ppReftPs bb p rs
-    tsDoc            = hsep (ppr_rtype bb p <$> ts)
-    ppT              = ppTyConB bb
-
-ppr_rtype bb p t@(REx _ _ _)
-  = ppExists bb p t
-ppr_rtype bb p t@(RAllE _ _ _)
-  = ppAllExpr bb p t
-ppr_rtype _ _ (RExprArg e)
-  = braces $ pprint e
-ppr_rtype bb p (RAppTy t t' r)
-  = F.ppTy r $ ppr_rtype bb p t <+> ppr_rtype bb p t'
-ppr_rtype bb p (RRTy e _ OCons t)
-  = sep [braces (ppr_rsubtype bb p e) <+> "=>", ppr_rtype bb p t]
-ppr_rtype bb p (RRTy e r o t)
-  = sep [ppp (pprint o <+> ppe <+> pprint r), ppr_rtype bb p t]
-  where
-    ppe  = (hsep $ punctuate comma (ppxt <$> e)) <+> dcolon
-    ppp  = \doc -> text "<<" <+> doc <+> text ">>"
-    ppxt = \(x, t) -> pprint x <+> ":" <+> ppr_rtype bb p t
-ppr_rtype _ _ (RHole r)
-  = F.ppTy r $ text "_"
-
-ppTyConB :: TyConable c => PPEnv -> c -> Doc
-ppTyConB bb
-  | ppShort bb = {- shortModules . -} ppTycon
-  | otherwise  = ppTycon
-
-shortModules :: Doc -> Doc
-shortModules = text . F.symbolString . dropModuleNames . F.symbol . render
-
-ppr_rsubtype
-  :: (OkRT c tv r, PPrint a, PPrint (RType c tv r), PPrint (RType c tv ()))
-  => PPEnv -> Prec -> [(a, RType c tv r)] -> Doc
-ppr_rsubtype bb p e
-  = pprint_env <+> text "|-" <+> ppr_rtype bb p tl <+> "<:" <+> ppr_rtype bb p tr
-  where
-    (el, r)  = (init e,  last e)
-    (env, l) = (init el, last el)
-    tr   = snd $ r
-    tl   = snd $ l
-    pprint_bind (x, t) = pprint x <+> colon <-> colon <+> ppr_rtype bb p t
-    pprint_env         = hsep $ punctuate comma (pprint_bind <$> env)
-
--- | From GHC: TypeRep
-maybeParen :: Prec -> Prec -> Doc -> Doc
-maybeParen ctxt_prec inner_prec pretty
-  | ctxt_prec < inner_prec = pretty
-  | otherwise                  = parens pretty
-
-ppExists
-  :: (OkRT c tv r, PPrint c, PPrint tv, PPrint (RType c tv r),
-      PPrint (RType c tv ()), F.Reftable (RTProp c tv r),
-      F.Reftable (RTProp c tv ()))
-  => PPEnv -> Prec -> RType c tv r -> Doc
-ppExists bb p t
-  = text "exists" <+> brackets (intersperse comma [ppr_dbind bb topPrec x t | (x, t) <- zs]) <-> dot <-> ppr_rtype bb p t'
-    where (zs,  t')               = split [] t
-          split zs (REx x t t')   = split ((x,t):zs) t'
-          split zs t                = (reverse zs, t)
-
-ppAllExpr
-  :: (OkRT c tv r, PPrint (RType c tv r), PPrint (RType c tv ()))
-  => PPEnv -> Prec -> RType c tv r -> Doc
-ppAllExpr bb p t
-  = text "forall" <+> brackets (intersperse comma [ppr_dbind bb topPrec x t | (x, t) <- zs]) <-> dot <-> ppr_rtype bb p t'
-    where 
-      (zs,  t')               = split [] t
-      split zs (RAllE x t t') = split ((x,t):zs) t'
-      split zs t              = (reverse zs, t)
-
-ppReftPs
-  :: (OkRT c tv r, PPrint (RType c tv r), PPrint (RType c tv ()),
-      F.Reftable (Ref (RType c tv ()) (RType c tv r)))
-  => t -> t1 -> [Ref (RType c tv ()) (RType c tv r)] -> Doc
-ppReftPs _ _ rs
-  | all F.isTauto rs   = empty
-  | not (ppPs ppEnv) = empty
-  | otherwise        = angleBrackets $ hsep $ punctuate comma $ ppr_ref <$> rs
-
-ppr_dbind
-  :: (OkRT c tv r, PPrint (RType c tv r), PPrint (RType c tv ()))
-  => PPEnv -> Prec -> F.Symbol -> RType c tv r -> Doc
-ppr_dbind bb p x t
-  | F.isNonSymbol x || (x == F.dummySymbol)
-  = ppr_rtype bb p t
-  | otherwise
-  = pprint x <-> colon <-> ppr_rtype bb p t
-
-
-
-ppr_rty_fun
-  :: ( OkRT c tv r, PPrint (RType c tv r), PPrint (RType c tv ()))
-  => PPEnv -> Doc -> RType c tv r -> Doc
-ppr_rty_fun bb prefix t = hsep (prefix : dArgs ++ [dOut])
-  where
-    dArgs               = concatMap ppArg args
-    dOut                = ppr_rtype bb topPrec out
-    ppArg (b, t, a)     = [ppr_dbind bb funPrec b t, a]
-    (args, out)         = brkFun t
-
-{- 
-ppr_rty_fun bb prefix t
-  = prefix <+> ppr_rty_fun' bb t
-
-ppr_rty_fun'
-  :: ( OkRT c tv r, PPrint (RType c tv r), PPrint (RType c tv ()))
-  => PPEnv -> RType c tv r -> Doc
-ppr_rty_fun' bb (RImpF b t t' r)
-  = F.ppTy r $ ppr_dbind bb funPrec b t $+$ ppr_rty_fun bb (text "~>") t'
-ppr_rty_fun' bb (RFun b t t' r)
-  = F.ppTy r $ ppr_dbind bb funPrec b t $+$ ppr_rty_fun bb arrow t'
-ppr_rty_fun' bb t
-  = ppr_rtype bb topPrec t
--}
-
-brkFun :: RType c tv r -> ([(F.Symbol, RType c tv r, Doc)], RType c tv r) 
-brkFun (RImpF b t t' _) = ((b, t, (text "~>")) : args, out)   where (args, out)     = brkFun t'  
-brkFun (RFun b t t' _)  = ((b, t, (text "->")) : args, out)   where (args, out)     = brkFun t'  
-brkFun out              = ([], out) 
-
-
-
-
-ppr_forall :: (OkRT c tv r) => PPEnv -> Prec -> RType c tv r -> Doc
-ppr_forall bb p t = maybeParen p funPrec $ sep [
-                      ppr_foralls (ppPs bb) (fst <$> ty_vars trep) (ty_preds trep)
-                    , ppr_clss cls
-                    , ppr_rtype bb topPrec t'
-                    ]
-  where
-    trep          = toRTypeRep t
-    (cls, t')     = bkClass $ fromRTypeRep $ trep {ty_vars = [], ty_preds = []}
-
-    ppr_foralls False _ _  = empty
-    ppr_foralls _    [] [] = empty
-    ppr_foralls True αs πs = text "forall" <+> dαs αs <+> dπs (ppPs bb) πs <-> dot
-
-    ppr_clss []               = empty
-    ppr_clss cs               = (parens $ hsep $ punctuate comma (uncurry (ppr_cls bb p) <$> cs)) <+> text "=>"
-
-    dαs αs                    = ppr_rtvar_def αs
-
-    -- dπs :: Bool -> [PVar a] -> Doc
-    dπs _ []                  = empty
-    dπs False _               = empty
-    dπs True πs               = angleBrackets $ intersperse comma $ ppr_pvar_def bb p <$> πs
-
-ppr_rtvar_def :: (PPrint tv) => [RTVar tv (RType c tv ())] -> Doc
-ppr_rtvar_def = sep . map (pprint . ty_var_value)
-
-ppr_cls
-  :: (OkRT c tv r, PPrint a, PPrint (RType c tv r),
-      PPrint (RType c tv ()))
-  => PPEnv -> Prec -> a -> [RType c tv r] -> Doc
-ppr_cls bb p c ts
-  = pp c <+> hsep (map (ppr_rtype bb p) ts)
-  where
-    pp | ppShort bb = text . F.symbolString . dropModuleNames . F.symbol . render . pprint
-       | otherwise  = pprint
-
-
-ppr_pvar_def :: (OkRT c tv ()) => PPEnv -> Prec -> PVar (RType c tv ()) -> Doc
-ppr_pvar_def bb p (PV s t _ xts)
-  = pprint s <+> dcolon <+> intersperse arrow dargs <+> ppr_pvar_kind bb p t
-  where
-    dargs = [ppr_pvar_sort bb p xt | (xt,_,_) <- xts]
-
-
-ppr_pvar_kind :: (OkRT c tv ()) => PPEnv -> Prec -> PVKind (RType c tv ()) -> Doc
-ppr_pvar_kind bb p (PVProp t) = ppr_pvar_sort bb p t <+> arrow <+> ppr_name F.boolConName -- propConName
-ppr_pvar_kind _ _ (PVHProp)   = panic Nothing "TODO: ppr_pvar_kind:hprop" -- ppr_name hpropConName
-
-ppr_name :: F.Symbol -> Doc
-ppr_name                      = text . F.symbolString
-
-ppr_pvar_sort :: (OkRT c tv ()) => PPEnv -> Prec -> RType c tv () -> Doc
-ppr_pvar_sort bb p t = ppr_rtype bb p t
-
-ppr_ref :: (OkRT c tv r) => Ref (RType c tv ()) (RType c tv r) -> Doc
-ppr_ref  (RProp ss s) = ppRefArgs (fst <$> ss) <+> pprint s
--- ppr_ref (RProp ss s) = ppRefArgs (fst <$> ss) <+> pprint (fromMaybe mempty (stripRTypeBase s))
-
-ppRefArgs :: [F.Symbol] -> Doc
-ppRefArgs [] = empty
-ppRefArgs ss = text "\\" <-> hsep (ppRefSym <$> ss ++ [F.vv Nothing]) <+> arrow 
-
-ppRefSym :: (Eq a, IsString a, PPrint a) => a -> Doc
-ppRefSym "" = text "_"
-ppRefSym s  = pprint s
-
-dot :: Doc
-dot                = char '.'
-
-instance (PPrint r, F.Reftable r) => PPrint (UReft r) where
-  pprintTidy k (MkUReft r p)
-    | F.isTauto r  = pprintTidy k p
-    | F.isTauto p  = pprintTidy k r
-    | otherwise  = pprintTidy k p <-> text " & " <-> pprintTidy k r
-
---------------------------------------------------------------------------------
-
---------------------------------------------------------------------------------
--- | Pretty-printing errors ----------------------------------------------------
---------------------------------------------------------------------------------
-
-printError :: (Show e, F.PPrint e) => F.Tidy -> DynFlags -> TError e -> IO ()
-printError k dyn err = putErrMsg dyn (pos err) (ppError k empty err)
-
--- | Similar in spirit to 'reportErrors' from the GHC API, but it uses our pretty-printer
--- and shim functions under the hood.
-reportErrors :: (Show e, F.PPrint e) => F.Tidy -> [TError e] -> Ghc.TcRn ()
-reportErrors k errs =
-  forM errs (\err -> mkLongErrAt (pos err) (ppError k empty err) mempty) >>= Ghc.reportErrors
diff --git a/src/Language/Haskell/Liquid/Types/RefType.hs b/src/Language/Haskell/Liquid/Types/RefType.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/RefType.hs
+++ /dev/null
@@ -1,1970 +0,0 @@
-{-# LANGUAGE IncoherentInstances       #-}
-{-# LANGUAGE OverloadedStrings         #-}
-{-# LANGUAGE MultiParamTypeClasses     #-}
-{-# LANGUAGE ScopedTypeVariables       #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE FlexibleContexts          #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE UndecidableInstances      #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE RankNTypes                #-}
-{-# LANGUAGE GADTs                     #-}
-{-# LANGUAGE PatternGuards             #-}
-{-# LANGUAGE ImplicitParams            #-}
-{-# LANGUAGE ConstraintKinds           #-}
-{-# LANGUAGE ViewPatterns              #-}
-
--- | Refinement Types. Mostly mirroring the GHC Type definition, but with
---   room for refinements of various sorts.
--- TODO: Desperately needs re-organization.
-
-module Language.Haskell.Liquid.Types.RefType (
-
-    TyConMap
-
-  -- * Functions for lifting Reft-values to Spec-values
-  , uTop, uReft, uRType, uRType', uRTypeGen, uPVar
-
-  -- * Applying a solution to a SpecType
-  , applySolution
-
-  -- * Functions for decreasing arguments
-  , isDecreasing, makeDecrType, makeNumEnv
-  , makeLexRefa
-
-  -- * Functions for manipulating `Predicate`s
-  , pdVar
-  , findPVar
-  , FreeVar, allTyVars, freeTyVars, tyClasses, tyConName
-
-  -- * Quantifying RTypes
-  , quantifyRTy
-  , quantifyFreeRTy
-
-  -- * RType constructors
-  , ofType, toType, bareOfType
-  , bTyVar, rTyVar, rVar, rApp, gApp, rEx
-  , symbolRTyVar, bareRTyVar
-  , tyConBTyCon
-  , pdVarReft
-
-  -- * Substitutions
-  , subts, subvPredicate, subvUReft
-  , subsTyVar_meet, subsTyVar_meet', subsTyVar_nomeet
-  , subsTyVars_nomeet, subsTyVars_meet
-
-  -- * Destructors
-  , addTyConInfo
-  , appRTyCon
-  , typeUniqueSymbol
-  , classBinds
-  , isSizeable
-  , famInstTyConType
-  , famInstArgs
-
-  -- * Manipulating Refinements in RTypes
-  , strengthen
-  , generalize
-  , normalizePds
-  , dataConMsReft
-  , dataConReft
-  , rTypeSortedReft
-  , rTypeSort
-  , typeSort
-  , shiftVV
-
-  -- * TODO: classify these
-  -- , mkDataConIdsTy
-  , expandProductType
-  , mkTyConInfo
-  , strengthenRefTypeGen
-  , strengthenDataConType
-  , isBaseTy
-  , updateRTVar, isValKind, kindToRType
-  , rTVarInfo
-  
-  , tyVarsPosition, Positions(..)
-
-  , isNumeric
-
-  ) where
-
--- import           GHC.Stack
-import Prelude hiding (error)
--- import qualified Prelude
-import WwLib
-import FamInstEnv (emptyFamInstEnv)
-import Name             hiding (varName)
-import Var
-import DataCon
-import qualified TyCon  as TC
-import           Data.Maybe               (fromMaybe, isJust, fromJust)
-import           Data.Hashable
-import qualified Data.HashMap.Strict  as M
-import qualified Data.HashSet         as S
-import qualified Data.List as L
-import           Control.Monad  (void)
-import           Text.Printf
-import           Text.PrettyPrint.HughesPJ hiding ((<>)) 
-import           Language.Fixpoint.Misc
-import           Language.Fixpoint.Types hiding (DataDecl (..), DataCtor (..), panic, shiftVV, Predicate, isNumeric)
-import           Language.Fixpoint.Types.Visitor (mapKVars, Visitable)
-import qualified Language.Fixpoint.Types as F
-import           Language.Haskell.Liquid.Types.Errors
-import           Language.Haskell.Liquid.Types.PrettyPrint
-
-import           Language.Haskell.Liquid.Types.Types hiding (R, DataConP (..))
-import           Language.Haskell.Liquid.Types.Variance
-import           Language.Haskell.Liquid.Misc
-import           Language.Haskell.Liquid.Types.Names
-import qualified Language.Haskell.Liquid.GHC.Misc as GM
-import           Language.Haskell.Liquid.GHC.Play (mapType, stringClassArg, isRecursivenewTyCon)
-import           Language.Haskell.Liquid.GHC.API        as Ghc hiding (Expr, Located, mapType, tyConName)
-import           Language.Haskell.Liquid.GHC.TypeRep () -- Eq Type instance
-import Data.List (foldl')
-
-
-
- 
-
-
-
-strengthenDataConType :: (Var, SpecType) -> (Var, SpecType)
-strengthenDataConType (x, t) = (x, fromRTypeRep trep {ty_res = tres})
-  where
-    tres     = F.notracepp _msg $ ty_res trep `strengthen` MkUReft (exprReft expr) mempty
-    trep     = toRTypeRep t
-    _msg     = "STRENGTHEN-DATACONTYPE x = " ++ F.showpp (x, (zip xs ts))
-    (xs, ts) = dataConArgs trep
-    as       = ty_vars  trep
-    x'       = symbol x
-    expr | null xs && null as = EVar x'
-         | otherwise          = mkEApp (dummyLoc x') (EVar <$> xs)
-
-
-dataConArgs :: SpecRep -> ([Symbol], [SpecType])
-dataConArgs trep = unzip [ (x, t) | (x, t) <- zip xs ts, isValTy t]
-  where
-    xs           = ty_binds trep
-    ts           = ty_args trep
-    isValTy      = not . Ghc.isEvVarType . toType
-
-
-pdVar :: PVar t -> Predicate
-pdVar v        = Pr [uPVar v]
-
-findPVar :: [PVar (RType c tv ())] -> UsedPVar -> PVar (RType c tv ())
-findPVar ps p = PV name ty v (zipWith (\(_, _, e) (t, s, _) -> (t, s, e)) (pargs p) args)
-  where
-    PV name ty v args = fromMaybe (msg p) $ L.find ((== pname p) . pname) ps
-    msg p = panic Nothing $ "RefType.findPVar" ++ showpp p ++ "not found"
-
--- | Various functions for converting vanilla `Reft` to `Spec`
-
-uRType          ::  RType c tv a -> RType c tv (UReft a)
-uRType          = fmap uTop
-
-uRType'         ::  RType c tv (UReft a) -> RType c tv a
-uRType'         = fmap ur_reft
-
-uRTypeGen       :: Reftable b => RType c tv a -> RType c tv b
-uRTypeGen       = fmap $ const mempty
-
-uPVar           :: PVar t -> UsedPVar
-uPVar           = void
-
-uReft           :: (Symbol, Expr) -> UReft Reft
-uReft           = uTop . Reft
-
-uTop            ::  r -> UReft r
-uTop r          = MkUReft r mempty
-
---------------------------------------------------------------------
--------------- (Class) Predicates for Valid Refinement Types -------
---------------------------------------------------------------------
-
-
--- Monoid Instances ---------------------------------------------------------
-
-instance ( SubsTy tv (RType c tv ()) (RType c tv ())
-         , SubsTy tv (RType c tv ()) c
-         , OkRT c tv r
-         , FreeVar c tv
-         , SubsTy tv (RType c tv ()) r
-         , SubsTy tv (RType c tv ()) tv
-         , SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ()))
-         )
-        => Semigroup (RType c tv r)  where
-  (<>) = strengthenRefType
-
--- TODO: remove, use only Semigroup?
-instance ( SubsTy tv (RType c tv ()) (RType c tv ())
-         , SubsTy tv (RType c tv ()) c
-         , OkRT c tv r
-         , FreeVar c tv
-         , SubsTy tv (RType c tv ()) r
-         , SubsTy tv (RType c tv ()) tv
-         , SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ()))
-         )
-        => Monoid (RType c tv r)  where
-  mempty  = panic Nothing "mempty: RType"
-  mappend = strengthenRefType
-
--- MOVE TO TYPES
-instance ( SubsTy tv (RType c tv ()) c
-         , OkRT c tv r
-         , FreeVar c tv
-         , SubsTy tv (RType c tv ()) r
-         , SubsTy tv (RType c tv ()) (RType c tv ())
-         , SubsTy tv (RType c tv ()) tv
-         , SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ()))
-         )
-         => Semigroup (RTProp c tv r) where
-  (<>) (RProp s1 (RHole r1)) (RProp s2 (RHole r2))
-    | isTauto r1 = RProp s2 (RHole r2)
-    | isTauto r2 = RProp s1 (RHole r1)
-    | otherwise  = RProp s1 $ RHole $ r1 `meet`
-                               (subst (mkSubst $ zip (fst <$> s2) (EVar . fst <$> s1)) r2)
-
-  (<>) (RProp s1 t1) (RProp s2 t2)
-    | isTrivial t1 = RProp s2 t2
-    | isTrivial t2 = RProp s1 t1
-    | otherwise    = RProp s1 $ t1  `strengthenRefType`
-                                (subst (mkSubst $ zip (fst <$> s2) (EVar . fst <$> s1)) t2)
-
--- TODO: remove and use only Semigroup?
-instance ( SubsTy tv (RType c tv ()) c
-         , OkRT c tv r
-         , FreeVar c tv
-         , SubsTy tv (RType c tv ()) r
-         , SubsTy tv (RType c tv ()) (RType c tv ())
-         , SubsTy tv (RType c tv ()) tv
-         , SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ()))
-         )
-         => Monoid (RTProp c tv r) where
-  mempty  = panic Nothing "mempty: RTProp"
-  mappend = (<>)
-
-{-
-NV: The following makes ghc diverge thus dublicating the code
-instance ( OkRT c tv r
-         , FreeVar c tv
-         , SubsTy tv (RType c tv ()) r
-         , SubsTy tv (RType c tv ()) (RType c tv ())
-         , SubsTy tv (RType c tv ()) c
-         , SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ()))
-         , SubsTy tv (RType c tv ()) tv
-         ) => Reftable (RTProp c tv r) where
-  isTauto (RProp _ (RHole r)) = isTauto r
-  isTauto (RProp _ t)         = isTrivial t
-  top (RProp _ (RHole _))     = panic Nothing "RefType: Reftable top called on (RProp _ (RHole _))"
-  top (RProp xs t)            = RProp xs $ mapReft top t
-  ppTy (RProp _ (RHole r)) d  = ppTy r d
-  ppTy (RProp _ _) _          = panic Nothing "RefType: Reftable ppTy in RProp"
-  toReft                      = panic Nothing "RefType: Reftable toReft"
-  params                      = panic Nothing "RefType: Reftable params for Ref"
-  bot                         = panic Nothing "RefType: Reftable bot    for Ref"
-  ofReft                      = panic Nothing "RefType: Reftable ofReft for Ref"
--}
-
-instance Reftable (RTProp RTyCon RTyVar (UReft Reft)) where
-  isTauto (RProp _ (RHole r)) = isTauto r
-  isTauto (RProp _ t)         = isTrivial t
-  top (RProp _ (RHole _))     = panic Nothing "RefType: Reftable top called on (RProp _ (RHole _))"
-  top (RProp xs t)            = RProp xs $ mapReft top t
-  ppTy (RProp _ (RHole r)) d  = ppTy r d
-  ppTy (RProp _ _) _          = panic Nothing "RefType: Reftable ppTy in RProp"
-  toReft                      = panic Nothing "RefType: Reftable toReft"
-  params                      = panic Nothing "RefType: Reftable params for Ref"
-  bot                         = panic Nothing "RefType: Reftable bot    for Ref"
-  ofReft                      = panic Nothing "RefType: Reftable ofReft for Ref"
-
-instance Reftable (RTProp RTyCon RTyVar ()) where
-  isTauto (RProp _ (RHole r)) = isTauto r
-  isTauto (RProp _ t)         = isTrivial t
-  top (RProp _ (RHole _))     = panic Nothing "RefType: Reftable top called on (RProp _ (RHole _))"
-  top (RProp xs t)            = RProp xs $ mapReft top t
-  ppTy (RProp _ (RHole r)) d  = ppTy r d
-  ppTy (RProp _ _) _          = panic Nothing "RefType: Reftable ppTy in RProp"
-  toReft                      = panic Nothing "RefType: Reftable toReft"
-  params                      = panic Nothing "RefType: Reftable params for Ref"
-  bot                         = panic Nothing "RefType: Reftable bot    for Ref"
-  ofReft                      = panic Nothing "RefType: Reftable ofReft for Ref"
-
-instance Reftable (RTProp BTyCon BTyVar (UReft Reft)) where
-  isTauto (RProp _ (RHole r)) = isTauto r
-  isTauto (RProp _ t)         = isTrivial t
-  top (RProp _ (RHole _))     = panic Nothing "RefType: Reftable top called on (RProp _ (RHole _))"
-  top (RProp xs t)            = RProp xs $ mapReft top t
-  ppTy (RProp _ (RHole r)) d  = ppTy r d
-  ppTy (RProp _ _) _          = panic Nothing "RefType: Reftable ppTy in RProp"
-  toReft                      = panic Nothing "RefType: Reftable toReft"
-  params                      = panic Nothing "RefType: Reftable params for Ref"
-  bot                         = panic Nothing "RefType: Reftable bot    for Ref"
-  ofReft                      = panic Nothing "RefType: Reftable ofReft for Ref"
-
-instance Reftable (RTProp BTyCon BTyVar ())  where
-  isTauto (RProp _ (RHole r)) = isTauto r
-  isTauto (RProp _ t)         = isTrivial t
-  top (RProp _ (RHole _))     = panic Nothing "RefType: Reftable top called on (RProp _ (RHole _))"
-  top (RProp xs t)            = RProp xs $ mapReft top t
-  ppTy (RProp _ (RHole r)) d  = ppTy r d
-  ppTy (RProp _ _) _          = panic Nothing "RefType: Reftable ppTy in RProp"
-  toReft                      = panic Nothing "RefType: Reftable toReft"
-  params                      = panic Nothing "RefType: Reftable params for Ref"
-  bot                         = panic Nothing "RefType: Reftable bot    for Ref"
-  ofReft                      = panic Nothing "RefType: Reftable ofReft for Ref"
-
-instance Reftable (RTProp RTyCon RTyVar Reft) where
-  isTauto (RProp _ (RHole r)) = isTauto r
-  isTauto (RProp _ t)         = isTrivial t
-  top (RProp _ (RHole _))     = panic Nothing "RefType: Reftable top called on (RProp _ (RHole _))"
-  top (RProp xs t)            = RProp xs $ mapReft top t
-  ppTy (RProp _ (RHole r)) d  = ppTy r d
-  ppTy (RProp _ _) _          = panic Nothing "RefType: Reftable ppTy in RProp"
-  toReft                      = panic Nothing "RefType: Reftable toReft"
-  params                      = panic Nothing "RefType: Reftable params for Ref"
-  bot                         = panic Nothing "RefType: Reftable bot    for Ref"
-  ofReft                      = panic Nothing "RefType: Reftable ofReft for Ref"
-
-----------------------------------------------------------------------------
--- | Subable Instances -----------------------------------------------------
-----------------------------------------------------------------------------
-
-instance Subable (RRProp Reft) where
-  syms (RProp ss (RHole r)) = (fst <$> ss) ++ syms r
-  syms (RProp ss t)      = (fst <$> ss) ++ syms t
-
-
-  subst su (RProp ss (RHole r)) = RProp (mapSnd (subst su) <$> ss) $ RHole $ subst su r
-  subst su (RProp ss r)  = RProp  (mapSnd (subst su) <$> ss) $ subst su r
-
-
-  substf f (RProp ss (RHole r)) = RProp (mapSnd (substf f) <$> ss) $ RHole $ substf f r
-  substf f (RProp ss r) = RProp  (mapSnd (substf f) <$> ss) $ substf f r
-
-  substa f (RProp ss (RHole r)) = RProp (mapSnd (substa f) <$> ss) $ RHole $ substa f r
-  substa f (RProp ss r) = RProp  (mapSnd (substa f) <$> ss) $ substa f r
-
-
--------------------------------------------------------------------------------
--- | Reftable Instances -------------------------------------------------------
--------------------------------------------------------------------------------
-
-instance (PPrint r, Reftable r, SubsTy RTyVar (RType RTyCon RTyVar ()) r, Reftable (RTProp RTyCon RTyVar r))
-    => Reftable (RType RTyCon RTyVar r) where
-  isTauto     = isTrivial
-  ppTy        = panic Nothing "ppTy RProp Reftable"
-  toReft      = panic Nothing "toReft on RType"
-  params      = panic Nothing "params on RType"
-  bot         = panic Nothing "bot on RType"
-  ofReft      = panic Nothing "ofReft on RType"
-
-
-instance Reftable (RType BTyCon BTyVar (UReft Reft)) where
-  isTauto     = isTrivial
-  top t       = mapReft top t
-  ppTy        = panic Nothing "ppTy RProp Reftable"
-  toReft      = panic Nothing "toReft on RType"
-  params      = panic Nothing "params on RType"
-  bot         = panic Nothing "bot on RType"
-  ofReft      = panic Nothing "ofReft on RType"
-
-
-
--- MOVE TO TYPES
-instance Fixpoint String where
-  toFix = text
-
--- MOVE TO TYPES
-instance Fixpoint Class where
-  toFix = text . GM.showPpr
-
--- MOVE TO TYPES
-class FreeVar a v where
-  freeVars :: a -> [v]
-
--- MOVE TO TYPES
-instance FreeVar RTyCon RTyVar where
-  freeVars = (RTV <$>) . GM.tyConTyVarsDef . rtc_tc
-
--- MOVE TO TYPES
-instance FreeVar BTyCon BTyVar where
-  freeVars _ = []
-
--- Eq Instances ------------------------------------------------------
-
--- MOVE TO TYPES
-instance (Eq c, Eq tv, Hashable tv, PPrint tv, TyConable c, PPrint c, Reftable (RTProp c tv ())) 
-      => Eq (RType c tv ()) where
-  (==) = eqRSort M.empty
-
-eqRSort :: (Eq a, Eq k, Hashable k, TyConable a, PPrint a, PPrint k, Reftable (RTProp a k ()))
-        => M.HashMap k k -> RType a k () -> RType a k () -> Bool
-eqRSort m (RAllP _ t) (RAllP _ t')
-  = eqRSort m t t'
-eqRSort m (RAllP _ t) t'
-  = eqRSort m t t'
-eqRSort m (RAllT a t _) (RAllT a' t' _)
-  | a == a'
-  = eqRSort m t t'
-  | otherwise
-  = eqRSort (M.insert (ty_var_value a') (ty_var_value a) m) t t'
-eqRSort m (RAllT _ t _) t'
-  = eqRSort m t t'
-eqRSort m t (RAllT _ t' _)
-  = eqRSort m t t'
-eqRSort m (RFun _ t1 t2 _) (RFun _ t1' t2' _)
-  = eqRSort m t1 t1' && eqRSort m t2 t2'
-eqRSort m (RAppTy t1 t2 _) (RAppTy t1' t2' _)
-  = eqRSort m t1 t1' && eqRSort m t2 t2'
-eqRSort m (RApp c ts _ _) (RApp c' ts' _ _)
-  = c == c' && length ts == length ts' && and (zipWith (eqRSort m) ts ts')
-eqRSort m (RVar a _) (RVar a' _)
-  = a == M.lookupDefault a' a' m
-eqRSort _ (RHole _) _
-  = True
-eqRSort _ _         (RHole _)
-  = True
-eqRSort _ _ _
-  = False
-
---------------------------------------------------------------------------------
--- | Wrappers for GHC Type Elements --------------------------------------------
---------------------------------------------------------------------------------
-
-instance Eq RTyVar where
-  -- FIXME: need to compare unique and string because we reuse
-  -- uniques in stringTyVar and co.
-  RTV α == RTV α' = α == α' && getOccName α == getOccName α'
-
-instance Ord RTyVar where
-  compare (RTV α) (RTV α') = case compare α α' of
-    EQ -> compare (getOccName α) (getOccName α')
-    o  -> o
-
-instance Hashable RTyVar where
-  hashWithSalt i (RTV α) = hashWithSalt i α
-
--- TyCon isn't comparable
---instance Ord RTyCon where
---  compare x y = compare (rtc_tc x) (rtc_tc y)
-
-instance Hashable RTyCon where
-  hashWithSalt i = hashWithSalt i . rtc_tc
-
---------------------------------------------------------------------------------
--- | Helper Functions (RJ: Helping to do what?) --------------------------------
---------------------------------------------------------------------------------
-
-rVar :: Monoid r => TyVar -> RType c RTyVar r
-rVar   = (`RVar` mempty) . RTV
-
-rTyVar :: TyVar -> RTyVar
-rTyVar = RTV
-
-updateRTVar :: Monoid r => RTVar RTyVar i -> RTVar RTyVar (RType RTyCon RTyVar r)
-updateRTVar (RTVar (RTV a) _) = RTVar (RTV a) (rTVarInfo a)
-
-rTVar :: Monoid r => TyVar -> RTVar RTyVar (RRType r)
-rTVar a = RTVar (RTV a) (rTVarInfo a)
-
-bTVar :: Monoid r => TyVar -> RTVar BTyVar (BRType r)
-bTVar a = RTVar (BTV (symbol a)) (bTVarInfo a)
-
-bTVarInfo :: Monoid r => TyVar -> RTVInfo (BRType r)
-bTVarInfo = mkTVarInfo kindToBRType
-
-rTVarInfo :: Monoid r => TyVar -> RTVInfo (RRType r)
-rTVarInfo = mkTVarInfo kindToRType
-
-mkTVarInfo :: (Kind -> s) -> TyVar -> RTVInfo s
-mkTVarInfo k2t a = RTVInfo
-  { rtv_name   = symbol    $ varName a
-  , rtv_kind   = k2t       $ tyVarKind a
-  , rtv_is_val = isValKind $ tyVarKind a
-  , rtv_is_pol = True 
-  }
-
-kindToRType :: Monoid r => Type -> RRType r
-kindToRType = kindToRType_ ofType
-
-kindToBRType :: Monoid r => Type -> BRType r
-kindToBRType = kindToRType_ bareOfType
-
-kindToRType_ :: (Type -> z) -> Type -> z
-kindToRType_ ofType        = ofType . go
-  where
-    go t
-     | t == typeSymbolKind = stringTy
-     | t == typeNatKind    = intTy
-     | otherwise           = t
-
-isValKind :: Kind -> Bool
-isValKind x = x == typeNatKind || x == typeSymbolKind
-
-bTyVar :: Symbol -> BTyVar
-bTyVar      = BTV
-
-symbolRTyVar :: Symbol -> RTyVar
-symbolRTyVar = rTyVar . GM.symbolTyVar 
-
-bareRTyVar :: BTyVar -> RTyVar
-bareRTyVar (BTV tv) = symbolRTyVar tv
-
-normalizePds :: (OkRT c tv r) => RType c tv r -> RType c tv r
-normalizePds t = addPds ps t'
-  where
-    (t', ps)   = nlzP [] t
-
-rPred :: PVar (RType c tv ()) -> RType c tv r -> RType c tv r
-rPred     = RAllP
-
-rEx :: Foldable t
-    => t (Symbol, RType c tv r) -> RType c tv r -> RType c tv r
-rEx xts t = foldr (\(x, tx) t -> REx x tx t) t xts
-
-rApp :: TyCon
-     -> [RType RTyCon tv r]
-     -> [RTProp RTyCon tv r]
-     -> r
-     -> RType RTyCon tv r
-rApp c = RApp (tyConRTyCon c)
-
-gApp :: TyCon -> [RTyVar] -> [PVar a] -> SpecType
-gApp tc αs πs = rApp tc
-                  [rVar α | RTV α <- αs]
-                  (rPropP [] . pdVarReft <$> πs)
-                  mempty
-
-pdVarReft :: PVar t -> UReft Reft
-pdVarReft = (\p -> MkUReft mempty p) . pdVar
-
-tyConRTyCon :: TyCon -> RTyCon
-tyConRTyCon c = RTyCon c [] (mkTyConInfo c [] [] Nothing)
-
--- bApp :: (Monoid r) => TyCon -> [BRType r] -> BRType r
-bApp :: TyCon -> [BRType r] -> [BRProp r] -> r -> BRType r
-bApp c = RApp (tyConBTyCon c)
-
-tyConBTyCon :: TyCon -> BTyCon
-tyConBTyCon = mkBTyCon . fmap tyConName . GM.locNamedThing
--- tyConBTyCon = mkBTyCon . fmap symbol . locNamedThing
-
---- NV TODO : remove this code!!!
-
-addPds :: Foldable t
-       => t (PVar (RType c tv ())) -> RType c tv r -> RType c tv r
-addPds ps (RAllT v t r) = RAllT v (addPds ps t) r 
-addPds ps t             = foldl' (flip rPred) t ps
-
-nlzP :: (OkRT c tv r) => [PVar (RType c tv ())] -> RType c tv r -> (RType c tv r, [PVar (RType c tv ())])
-nlzP ps t@(RVar _ _ )
- = (t, ps)
-nlzP ps (RImpF b t1 t2 r)
- = (RImpF b t1' t2' r, ps ++ ps1 ++ ps2)
-  where (t1', ps1) = nlzP [] t1
-        (t2', ps2) = nlzP [] t2
-nlzP ps (RFun b t1 t2 r)
- = (RFun b t1' t2' r, ps ++ ps1 ++ ps2)
-  where (t1', ps1) = nlzP [] t1
-        (t2', ps2) = nlzP [] t2
-nlzP ps (RAppTy t1 t2 r)
- = (RAppTy t1' t2' r, ps ++ ps1 ++ ps2)
-  where (t1', ps1) = nlzP [] t1
-        (t2', ps2) = nlzP [] t2
-nlzP ps (RAllT v t r)
- = (RAllT v t' r, ps ++ ps')
-  where (t', ps') = nlzP [] t
-nlzP ps t@(RApp _ _ _ _)
- = (t, ps)
-nlzP ps (RAllP p t)
- = (t', [p] ++ ps ++ ps')
-  where (t', ps') = nlzP [] t
-nlzP ps t@(REx _ _ _)
- = (t, ps)
-nlzP ps t@(RRTy _ _ _ t')
- = (t, ps ++ ps')
- where ps' = snd $ nlzP [] t'
-nlzP ps t@(RAllE _ _ _)
- = (t, ps)
-nlzP _ t
- = panic Nothing $ "RefType.nlzP: cannot handle " ++ show t
-
-strengthenRefTypeGen, strengthenRefType ::
-         (  OkRT c tv r
-         , FreeVar c tv
-         , SubsTy tv (RType c tv ()) (RType c tv ())
-         , SubsTy tv (RType c tv ()) c
-         , SubsTy tv (RType c tv ()) r
-         , SubsTy tv (RType c tv ()) tv
-         , SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ()))
-         ) => RType c tv r -> RType c tv r -> RType c tv r
-
-strengthenRefType_ ::
-         ( OkRT c tv r
-         , FreeVar c tv
-         , SubsTy tv (RType c tv ()) (RType c tv ())
-         , SubsTy tv (RType c tv ()) c
-         , SubsTy tv (RType c tv ()) r
-         , SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ()))
-         , SubsTy tv (RType c tv ()) tv
-         ) => (RType c tv r -> RType c tv r -> RType c tv r)
-           ->  RType c tv r -> RType c tv r -> RType c tv r
-
-strengthenRefTypeGen t1 t2 = strengthenRefType_ f t1 t2
-  where
-    f (RVar v1 r1) t  = RVar v1 (r1 `meet` fromMaybe mempty (stripRTypeBase t))
-    f t (RVar _ r1)  = t `strengthen` r1
-    f t1 t2           = panic Nothing $ printf "strengthenRefTypeGen on differently shaped types \nt1 = %s [shape = %s]\nt2 = %s [shape = %s]"
-                         (pprt_raw t1) (showpp (toRSort t1)) (pprt_raw t2) (showpp (toRSort t2))
-
-pprt_raw :: (OkRT c tv r) => RType c tv r -> String
-pprt_raw = render . rtypeDoc Full
-
-{- [NOTE:StrengthenRefType] disabling the `meetable` check because
-
-      (1) It requires the 'TCEmb TyCon' to deal with the fact that sometimes,
-          GHC uses the "Family Instance" TyCon e.g. 'R:UniquePerson' and sometimes
-          the vanilla TyCon App form, e.g. 'Unique Person'
-      (2) We could pass in the TCEmb but that would break the 'Monoid' instance for
-          RType. The 'Monoid' instance was was probably a bad idea to begin with,
-          and we probably ought to do away with it entirely, but thats a battle I'll
-          leave for another day.
-
-    Consequently, its up to users of `strengthenRefType` (and associated functions)
-    to make sure that the two types are compatible. For an example, see 'meetVarTypes'.
- -}
-
-strengthenRefType t1 t2
-  | True -- _meetable t1 t2
-  = strengthenRefType_ (\x _ -> x) t1 t2
-  | otherwise
-  = panic Nothing msg
-  where
-    msg = printf "strengthen on differently shaped reftypes \nt1 = %s [shape = %s]\nt2 = %s [shape = %s]"
-            (showpp t1) (showpp (toRSort t1)) (showpp t2) (showpp (toRSort t2))
-
-_meetable :: (OkRT c tv r) => RType c tv r -> RType c tv r -> Bool
-_meetable t1 t2 = toRSort t1 == toRSort t2
-
-strengthenRefType_ f (RAllT a1 t1 r1) (RAllT a2 t2 r2)
-  = RAllT a1 (strengthenRefType_ f t1 (subsTyVar_meet (ty_var_value a2, toRSort t, t) t2)) (r1 `meet` r2)
-  where t = RVar (ty_var_value a1) mempty
-
-strengthenRefType_ f (RAllT a t1 r1) t2
-  = RAllT a (strengthenRefType_ f t1 t2) r1
-
-strengthenRefType_ f t1 (RAllT a t2 r2)
-  = RAllT a (strengthenRefType_ f t1 t2) r2
-
-strengthenRefType_ f (RAllP p1 t1) (RAllP _ t2)
-  = RAllP p1 $ strengthenRefType_ f t1 t2
-
-strengthenRefType_ f (RAllP p t1) t2
-  = RAllP p $ strengthenRefType_ f t1 t2
-
-strengthenRefType_ f t1 (RAllP p t2)
-  = RAllP p $ strengthenRefType_ f t1 t2
-
-strengthenRefType_ f (RAllE x tx t1) (RAllE y ty t2) | x == y
-  = RAllE x (strengthenRefType_ f tx ty) $ strengthenRefType_ f t1 t2
-
-strengthenRefType_ f (RAllE x tx t1) t2
-  = RAllE x tx $ strengthenRefType_ f t1 t2
-
-strengthenRefType_ f t1 (RAllE x tx t2)
-  = RAllE x tx $ strengthenRefType_ f t1 t2
-
-strengthenRefType_ f (RAppTy t1 t1' r1) (RAppTy t2 t2' r2)
-  = RAppTy t t' (r1 `meet` r2)
-    where t  = strengthenRefType_ f t1 t2
-          t' = strengthenRefType_ f t1' t2'
-
-strengthenRefType_ f (RImpF x1 t1 t1' r1) (RImpF x2 t2 t2' r2)
-  = RImpF x2 t t' (r1 `meet` r2)
-    where t  = strengthenRefType_ f t1 t2
-          t' = strengthenRefType_ f (subst1 t1' (x1, EVar x2)) t2'
-
-strengthenRefType_ f (RFun x1 t1 t1' r1) (RFun x2 t2 t2' r2)
-  = RFun x2 t t' (r1 `meet` r2)
-    where t  = strengthenRefType_ f t1 t2
-          t' = strengthenRefType_ f (subst1 t1' (x1, EVar x2)) t2'
-
-strengthenRefType_ f (RApp tid t1s rs1 r1) (RApp _ t2s rs2 r2)
-  = RApp tid ts rs (r1 `meet` r2)
-    where ts  = zipWith (strengthenRefType_ f) t1s t2s
-          rs  = meets rs1 rs2
-
-
-strengthenRefType_ _ (RVar v1 r1)  (RVar v2 r2) | v1 == v2
-  = RVar v1 (r1 `meet` r2)
-strengthenRefType_ f t1 t2
-  = f t1 t2
-
-meets :: (F.Reftable r) => [r] -> [r] -> [r]
-meets [] rs                 = rs
-meets rs []                 = rs
-meets rs rs'
-  | length rs == length rs' = zipWith meet rs rs'
-  | otherwise               = panic Nothing "meets: unbalanced rs"
-
-strengthen :: Reftable r => RType c tv r -> r -> RType c tv r
-strengthen (RApp c ts rs r) r'  = RApp c ts rs (r `F.meet` r')
-strengthen (RVar a r) r'        = RVar a       (r `F.meet` r')
-strengthen (RImpF b t1 t2 r) r' = RImpF b t1 t2 (r `F.meet` r')
-strengthen (RFun b t1 t2 r) r'  = RFun b t1 t2 (r `F.meet` r')
-strengthen (RAppTy t1 t2 r) r'  = RAppTy t1 t2 (r `F.meet` r')
-strengthen (RAllT a t r)    r'  = RAllT a t    (r `F.meet` r')
-strengthen t _                  = t
-
-
-quantifyRTy :: (Monoid r, Eq tv) => [RTVar tv (RType c tv ())] -> RType c tv r -> RType c tv r
-quantifyRTy tvs ty = foldr rAllT ty tvs
-  where rAllT a t = RAllT a t mempty
-
-quantifyFreeRTy :: (Monoid r, Eq tv) => RType c tv r -> RType c tv r
-quantifyFreeRTy ty = quantifyRTy (freeTyVars ty) ty
-
-
--------------------------------------------------------------------------
-addTyConInfo :: (PPrint r, Reftable r, SubsTy RTyVar (RType RTyCon RTyVar ()) r, Reftable (RTProp RTyCon RTyVar r))
-             => TCEmb TyCon
-             -> TyConMap -- (M.HashMap TyCon RTyCon)
-             -> RRType r
-             -> RRType r
--------------------------------------------------------------------------
-addTyConInfo tce tyi = mapBot (expandRApp tce tyi)
-
--------------------------------------------------------------------------
-expandRApp :: (PPrint r, Reftable r, SubsTy RTyVar RSort r, Reftable (RRProp r))
-           => TCEmb TyCon -> TyConMap -> RRType r -> RRType r
--------------------------------------------------------------------------
-expandRApp tce tyi t@(RApp {}) = RApp rc' ts rs' r
-  where
-    RApp rc ts rs r            = t
-    (rc', _)                   = appRTyCon tce tyi rc as
-    pvs                        = rTyConPVs rc'
-    rs'                        = applyNonNull rs0 (rtPropPV rc pvs) rs
-    rs0                        = rtPropTop <$> pvs
-    n                          = length fVs
-    fVs                        = GM.tyConTyVarsDef $ rtc_tc rc
-    as                         = choosen n ts (rVar <$> fVs)
-expandRApp _ _ t               = t
-
-choosen :: Int -> [a] -> [a] -> [a]
-choosen 0 _ _           = []
-choosen i (x:xs) (_:ys) = x:choosen (i-1) xs ys
-choosen i []     (y:ys) = y:choosen (i-1) [] ys
-choosen _ _ _           = impossible Nothing "choosen: this cannot happen"
-
-
-rtPropTop
-  :: (OkRT c tv r,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-   => PVar (RType c tv ()) -> Ref (RType c tv ()) (RType c tv r)
-rtPropTop pv = case ptype pv of
-                 PVProp t -> RProp xts $ ofRSort t
-                 PVHProp  -> RProp xts $ mempty
-               where
-                 xts      =  pvArgs pv
-
-rtPropPV :: (Fixpoint a, Reftable r)
-         => a
-         -> [PVar (RType c tv ())]
-         -> [Ref (RType c tv ()) (RType c tv r)]
-         -> [Ref (RType c tv ()) (RType c tv r)]
-rtPropPV _rc = zipWith mkRTProp
-
-mkRTProp :: Reftable r
-         => PVar (RType c tv ())
-         -> Ref (RType c tv ()) (RType c tv r)
-         -> Ref (RType c tv ()) (RType c tv r)
-mkRTProp pv (RProp ss (RHole r))
-  = RProp ss $ (ofRSort $ pvType pv) `strengthen` r
-
-mkRTProp pv (RProp ss t)
-  | length (pargs pv) == length ss
-  = RProp ss t
-  | otherwise
-  = RProp (pvArgs pv) t
-
-pvArgs :: PVar t -> [(Symbol, t)]
-pvArgs pv = [(s, t) | (t, s, _) <- pargs pv]
-
-{- | [NOTE:FamInstPredVars] related to [NOTE:FamInstEmbeds]
-     See tests/datacon/pos/T1446.hs 
-     The function txRefSort converts
-
-        Int<p>              ===> {v:Int | p v}
-
-     which is fine, but also converts
-
-        Field<q> Blob a     ===> {v:Field Blob a | q v}
-        
-     which is NOT ok, because q expects a different arg.
-
-     The above happens because, thanks to instance-family stuff,
-     LH doesn't realize that q is actually an ARG of Field Blob
-     Note that Field itself has no args, but Field Blob does...
-
-     That is, it is not enough to store the refined `TyCon` info,
-     solely in the `RTyCon` as with family instances, you need BOTH 
-     the `TyCon` and the args to determine the extra info. 
-     
-     We do so in `TyConMap`, and by crucially extending 
-
-     @RefType.appRTyCon@ whose job is to use the Refined @TyCon@ 
-     that is, the @RTyCon@ generated from the @TyConP@ to strengthen
-     individual occurrences of the TyCon applied to various arguments.
-
- -}
-
-appRTyCon :: (ToTypeable r) => TCEmb TyCon -> TyConMap -> RTyCon -> [RRType r] -> (RTyCon, [RPVar])
-appRTyCon tce tyi rc ts = F.notracepp _msg (resTc, ps'') 
-  where
-    _msg  = "appRTyCon-family: " ++ showpp (Ghc.isFamilyTyCon c, Ghc.tyConRealArity c, toType <$> ts)
-    resTc = RTyCon c ps'' (rtc_info rc'')
-    c     = rtc_tc rc
-   
-    (rc', ps') = rTyConWithPVars tyi rc (rTypeSort tce <$> ts)
-    -- TODO:faminst-preds rc'   = M.lookupDefault rc c (tcmTyRTy tyi)
-    -- TODO:faminst-preds ps'   = rTyConPVs rc' 
-
-    -- TODO:faminst-preds: these substitutions may be WRONG if we are using FAMINST.
-    ps''  = subts (zip (RTV <$> αs) ts') <$> ps' 
-      where 
-        ts' = if null ts then rVar <$> βs else toRSort <$> ts
-        αs  = GM.tyConTyVarsDef (rtc_tc rc')
-        βs  = GM.tyConTyVarsDef c
-    
-    rc''  = if isNumeric tce rc' then addNumSizeFun rc' else rc'
-
-rTyConWithPVars :: TyConMap -> RTyCon -> [F.Sort] -> (RTyCon, [RPVar])
-rTyConWithPVars tyi rc ts = case famInstTyConMb tyi rc ts of 
-  Just fiRc    -> (rc', rTyConPVs fiRc)       -- use the PVars from the family-instance TyCon
-  Nothing      -> (rc', ps')                  -- use the PVars from the origin          TyCon
-  where 
-    (rc', ps') = plainRTyConPVars tyi rc
-
--- | @famInstTyConMb rc args@ uses the @RTyCon@ AND @args@ to see if 
---   this is a family instance @RTyCon@, and if so, returns it.
---   see [NOTE:FamInstPredVars]
---   eg: 'famInstTyConMb tyi Field [Blob, a]' should give 'Just R:FieldBlob' 
-    
-famInstTyConMb :: TyConMap -> RTyCon -> [F.Sort] -> Maybe RTyCon
-famInstTyConMb tyi rc ts = do 
-  let c = rtc_tc rc
-  n    <- M.lookup c      (tcmFtcArity tyi)
-  M.lookup (c, take n ts) (tcmFIRTy    tyi)
-
-famInstTyConType :: Ghc.TyCon -> Maybe Ghc.Type
-famInstTyConType c = uncurry Ghc.mkTyConApp <$> famInstArgs c 
-
--- | @famInstArgs c@ destructs a family-instance @TyCon@ into its components, e.g. 
---   e.g. 'famInstArgs R:FieldBlob' is @(Field, [Blob])@ 
-
-famInstArgs :: Ghc.TyCon -> Maybe (Ghc.TyCon, [Ghc.Type])
-famInstArgs c = case Ghc.tyConFamInst_maybe c of
-    Just (c', ts) -> F.notracepp ("famInstArgs: " ++ F.showpp (c, cArity, ts)) 
-                     $ Just (c', take (length ts - cArity) ts) 
-    Nothing       -> Nothing
-    where 
-      cArity      = Ghc.tyConRealArity c
-
--- TODO:faminst-preds: case Ghc.tyConFamInst_maybe c of
--- TODO:faminst-preds:   Just (c', ts) -> F.tracepp ("famInstTyConType: " ++ F.showpp (c, Ghc.tyConArity c, ts)) 
--- TODO:faminst-preds:                    $ Just (famInstType (Ghc.tyConArity c) c' ts)
--- TODO:faminst-preds:   Nothing       -> Nothing
-
--- TODO:faminst-preds: famInstType :: Int -> Ghc.TyCon -> [Ghc.Type] -> Ghc.Type
--- TODO:faminst-preds: famInstType n c ts = Ghc.mkTyConApp c (take (length ts - n) ts)
-
-
-
-
--- | @plainTyConPVars@ uses the @TyCon@ to return the 
---   "refined" @RTyCon@ and @RPVars@ from the refined 
---   'data' definition for the @TyCon@, e.g. will use 
---   'List Int' to return 'List<p> Int' (if List has an abs-ref).
-plainRTyConPVars :: TyConMap -> RTyCon -> (RTyCon, [RPVar])
-plainRTyConPVars tyi rc = (rc', rTyConPVs rc') 
-  where 
-    rc'                   = M.lookupDefault rc (rtc_tc rc) (tcmTyRTy tyi)
-
-
-
--- RJ: The code of `isNumeric` is incomprehensible.
--- Please fix it to use intSort instead of intFTyCon
-isNumeric :: TCEmb TyCon -> RTyCon -> Bool
-isNumeric tce c = F.isNumeric mySort 
-  where
-    -- mySort      = M.lookupDefault def rc tce
-    mySort      = maybe def fst (F.tceLookup rc tce)
-    def         = FTC . symbolFTycon . dummyLoc . tyConName $ rc
-    rc          = rtc_tc c
-
-addNumSizeFun :: RTyCon -> RTyCon
-addNumSizeFun c
-  = c {rtc_info = (rtc_info c) {sizeFunction = Just IdSizeFun } }
-
-
-generalize :: (Eq tv, Monoid r) => RType c tv r -> RType c tv r
-generalize t = mkUnivs (zip (freeTyVars t) (repeat mempty)) [] t
-
-allTyVars :: (Ord tv) => RType c tv r -> [tv]
-allTyVars t = sortNub . fmap ty_var_value $ vs ++ vs'
-  where
-    vs      = map fst . fst3 . bkUniv $ t
-    vs'     = freeTyVars    $ t
-
-freeTyVars :: Eq tv => RType c tv r -> [RTVar tv (RType c tv ())]
-freeTyVars (RAllP _ t)     = freeTyVars t
-freeTyVars (RAllT α t _)   = freeTyVars t L.\\ [α]
-freeTyVars (RImpF _ t t' _)= freeTyVars t `L.union` freeTyVars t'
-freeTyVars (RFun _ t t' _) = freeTyVars t `L.union` freeTyVars t'
-freeTyVars (RApp _ ts _ _) = L.nub $ concatMap freeTyVars ts
-freeTyVars (RVar α _)      = [makeRTVar α]
-freeTyVars (RAllE _ tx t)  = freeTyVars tx `L.union` freeTyVars t
-freeTyVars (REx _ tx t)    = freeTyVars tx `L.union` freeTyVars t
-freeTyVars (RExprArg _)    = []
-freeTyVars (RAppTy t t' _) = freeTyVars t `L.union` freeTyVars t'
-freeTyVars (RHole _)       = []
-freeTyVars (RRTy e _ _ t)  = L.nub $ concatMap freeTyVars (t:(snd <$> e))
-
-
-tyClasses :: (OkRT RTyCon tv r) => RType RTyCon tv r -> [(Class, [RType RTyCon tv r])]
-tyClasses (RAllP _ t)     = tyClasses t
-tyClasses (RAllT _ t _)   = tyClasses t
-tyClasses (RAllE _ _ t)   = tyClasses t
-tyClasses (REx _ _ t)     = tyClasses t
-tyClasses (RImpF _ t t' _) = tyClasses t ++ tyClasses t'
-tyClasses (RFun _ t t' _) = tyClasses t ++ tyClasses t'
-tyClasses (RAppTy t t' _) = tyClasses t ++ tyClasses t'
-tyClasses (RApp c ts _ _)
-  | Just cl <- tyConClass_maybe $ rtc_tc c
-  = [(cl, ts)]
-  | otherwise
-  = []
-tyClasses (RVar _ _)      = []
-tyClasses (RRTy _ _ _ t)  = tyClasses t
-tyClasses (RHole _)       = []
-tyClasses t               = panic Nothing ("RefType.tyClasses cannot handle" ++ show t)
-
-
---------------------------------------------------------------------------------
--- TODO: Rewrite subsTyvars with Traversable
---------------------------------------------------------------------------------
-
-subsTyVars_meet
-  :: (Eq tv, Foldable t, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => t (tv, RType c tv (), RType c tv r) -> RType c tv r -> RType c tv r
-subsTyVars_meet        = subsTyVars True
-
-subsTyVars_nomeet
-  :: (Eq tv, Foldable t, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => t (tv, RType c tv (), RType c tv r) -> RType c tv r -> RType c tv r
-subsTyVars_nomeet      = subsTyVars False
-
-subsTyVar_nomeet
-  :: (Eq tv, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => (tv, RType c tv (), RType c tv r) -> RType c tv r -> RType c tv r
-subsTyVar_nomeet       = subsTyVar False
-
-subsTyVar_meet
-  :: (Eq tv, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => (tv, RType c tv (), RType c tv r) -> RType c tv r -> RType c tv r
-subsTyVar_meet         = subsTyVar True
-
-subsTyVar_meet'
-  :: (Eq tv, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => (tv, RType c tv r) -> RType c tv r -> RType c tv r
-subsTyVar_meet' (α, t) = subsTyVar_meet (α, toRSort t, t)
-
-subsTyVars
-  :: (Eq tv, Foldable t, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => Bool
-  -> t (tv, RType c tv (), RType c tv r)
-  -> RType c tv r
-  -> RType c tv r
-subsTyVars meet ats t = foldl' (flip (subsTyVar meet)) t ats
-
-subsTyVar
-  :: (Eq tv, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => Bool
-  -> (tv, RType c tv (), RType c tv r)
-  -> RType c tv r
-  -> RType c tv r
-subsTyVar meet        = subsFree meet S.empty
-
-subsFree
-  :: (Eq tv, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => Bool
-  -> S.HashSet tv
-  -> (tv, RType c tv (), RType c tv r)
-  -> RType c tv r
-  -> RType c tv r
-subsFree m s z@(α, τ,_) (RAllP π t)
-  = RAllP (subt (α, τ) π) (subsFree m s z t)
-subsFree m s z@(a, τ, _) (RAllT α t r)
-  -- subt inside the type variable instantiates the kind of the variable
-  = RAllT (subt (a, τ) α) (subsFree m (ty_var_value α `S.insert` s) z t) (subt (a, τ) r)
-subsFree m s z@(α, τ, _) (RImpF x t t' r)
-  = RImpF x (subsFree m s z t) (subsFree m s z t') (subt (α, τ) r)
-subsFree m s z@(α, τ, _) (RFun x t t' r)
-  = RFun x (subsFree m s z t) (subsFree m s z t') (subt (α, τ) r)
-subsFree m s z@(α, τ, _) (RApp c ts rs r)
-  = RApp c' (subsFree m s z <$> ts) (subsFreeRef m s z <$> rs) (subt (α, τ) r)
-    where z' = (α, τ) -- UNIFY: why instantiating INSIDE parameters?
-          c' = if α `S.member` s then c else subt z' c
-subsFree meet s (α', τ, t') (RVar α r)
-  | α == α' && not (α `S.member` s)
-  = if meet then t' `strengthen` (subt (α, τ) r) else t'
-  | otherwise
-  = RVar (subt (α', τ) α) r
-subsFree m s z (RAllE x t t')
-  = RAllE x (subsFree m s z t) (subsFree m s z t')
-subsFree m s z (REx x t t')
-  = REx x (subsFree m s z t) (subsFree m s z t')
-subsFree m s z@(α, τ, _) (RAppTy t t' r)
-  = subsFreeRAppTy m s (subsFree m s z t) (subsFree m s z t') (subt (α, τ) r)
-subsFree _ _ _ t@(RExprArg _)
-  = t
-subsFree m s z@(α, τ, _) (RRTy e r o t)
-  = RRTy (mapSnd (subsFree m s z) <$> e) (subt (α, τ) r) o (subsFree m s z t)
-subsFree _ _ (α, τ, _) (RHole r)
-  = RHole (subt (α, τ) r)
-
-subsFrees
-  :: (Eq tv, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => Bool
-  -> S.HashSet tv
-  -> [(tv, RType c tv (), RType c tv r)]
-  -> RType c tv r
-  -> RType c tv r
-subsFrees m s zs t = foldl' (flip (subsFree m s)) t zs
-
--- GHC INVARIANT: RApp is Type Application to something other than TYCon
-subsFreeRAppTy
-  :: (Eq tv, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()),
-      FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => Bool
-  -> S.HashSet tv
-  -> RType c tv r
-  -> RType c tv r
-  -> r
-  -> RType c tv r
-subsFreeRAppTy m s (RApp c ts rs r) t' r'
-  = mkRApp m s c (ts ++ [t']) rs r r'
-subsFreeRAppTy _ _ t t' r'
-  = RAppTy t t' r'
-
-
--- | @mkRApp@ is the refined variant of GHC's @mkTyConApp@ which ensures that 
---    that applications of the "function" type constructor are normalized to 
---    the special case @FunTy _@ representation. The extra `_rep1`, and `_rep2` 
---    parameters come from the "levity polymorphism" changes in GHC 8.6 (?)
---    See [NOTE:Levity-Polymorphism]
-
-mkRApp :: (Eq tv, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => Bool
-  -> S.HashSet tv
-  -> c
-  -> [RType c tv r]
-  -> [RTProp c tv r]
-  -> r
-  -> r
-  -> RType c tv r
-mkRApp m s c ts rs r r'
-  | isFun c, [_rep1, _rep2, t1, t2] <- ts
-  = RFun dummySymbol t1 t2 (refAppTyToFun r')
-  | otherwise
-  = subsFrees m s zs (RApp c ts rs (r `meet` r'))
-  where
-    zs = [(tv, toRSort t, t) | (tv, t) <- zip (freeVars c) ts]
-
-{-| [NOTE:Levity-Polymorphism] 
- 
-     Thanks to Joachim Brietner and Simon Peyton-Jones!
-     With GHC's "levity polymorphism feature", see more here 
-
-         https://stackoverflow.com/questions/35318562/what-is-levity-polymorphism     
-
-     The function type constructor actually has type
-
-        (->) :: forall (r1::RuntimeRep) (r2::RuntimeRep).  TYPE r1 -> TYPE r2 -> TYPE LiftedRep
-
-     so we have to be careful to follow GHC's @mkTyConApp@ 
-     
-        https://hackage.haskell.org/package/ghc-8.6.4/docs/src/Type.html#mkTyConApp
-
-     which normalizes applications of the `FunTyCon` constructor to use the special 
-     case `FunTy _` representation thus, so that we are not stuck with incompatible 
-     representations e.g. 
-
-        thing -> thing                                                  ... (using RFun)
-
-     and 
-
-        (-> 'GHC.Types.LiftedRep 'GHC.Types.LiftedRep thing thing)      ... (using RApp)
-
-
-     More details from Joachim Brietner:
-
-     Now you might think that the function arrow has the following kind: `(->) :: * -> * -> *`.
-     But that is not the full truth: You can have functions that accept or return things with 
-     different representations than just the usual lifted one.
-
-     So the function arrow actually has kind `(->) :: forall r1 r2. TYPE r1 -> TYPE r2 -> *`.
-     And in `(-> 'GHC.Types.LiftedRep 'GHC.Types.LiftedRep thing thing)`  you see this spelled 
-     out explicitly. But it really is just `(thing -> thing)`, just printed with more low-level detail.
-
-     Also see
-
-       • https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#levity-polymorphism
-       • and other links from https://stackoverflow.com/a/35320729/946226 (edited) 
- -}
-
-refAppTyToFun :: Reftable r => r -> r
-refAppTyToFun r
-  | isTauto r = r
-  | otherwise = panic Nothing "RefType.refAppTyToFun"
-
-subsFreeRef
-  :: (Eq tv, Hashable tv, Reftable r, TyConable c,
-      SubsTy tv (RType c tv ()) c, SubsTy tv (RType c tv ()) r,
-      SubsTy tv (RType c tv ()) (RType c tv ()), FreeVar c tv,
-      SubsTy tv (RType c tv ()) tv,
-      SubsTy tv (RType c tv ()) (RTVar tv (RType c tv ())))
-  => Bool
-  -> S.HashSet tv
-  -> (tv, RType c tv (), RType c tv r)
-  -> RTProp c tv r
-  -> RTProp c tv r
-subsFreeRef _ _ (α', τ', _) (RProp ss (RHole r))
-  = RProp (mapSnd (subt (α', τ')) <$> ss) (RHole r)
-subsFreeRef m s (α', τ', t')  (RProp ss t)
-  = RProp (mapSnd (subt (α', τ')) <$> ss) $ subsFree m s (α', τ', fmap top t') t
-
-
---------------------------------------------------------------------------------
--- | Type Substitutions --------------------------------------------------------
---------------------------------------------------------------------------------
-
-subts :: (SubsTy tv ty c) => [(tv, ty)] -> c -> c
-subts = flip (foldr subt)
-
-instance SubsTy RTyVar (RType RTyCon RTyVar ()) RTyVar where
-  subt (RTV x, t) (RTV z) | isTyVar z, tyVarKind z == TyVarTy x
-    = RTV (setVarType z $ toType t)
-  subt _ v
-    = v
-
-instance SubsTy RTyVar (RType RTyCon RTyVar ()) (RTVar RTyVar (RType RTyCon RTyVar ())) where
-  -- NV TODO: update kind
-  subt su rty = rty { ty_var_value = subt su $ ty_var_value rty }
-
-
-instance SubsTy BTyVar (RType c BTyVar ()) BTyVar where
-  subt _ = id
-
-instance SubsTy BTyVar (RType c BTyVar ()) (RTVar BTyVar (RType c BTyVar ())) where
-  subt _ = id
-
-instance SubsTy tv ty ()   where
-  subt _ = id
-
-instance SubsTy tv ty Symbol where
-  subt _ = id
-
-
-
-instance (SubsTy tv ty Expr) => SubsTy tv ty Reft where
-  subt su (Reft (x, e)) = Reft (x, subt su e)
-
-instance SubsTy Symbol Symbol (BRType r) where
-  subt (x,y) (RVar v r)
-    | BTV x == v = RVar (BTV y) r 
-    | otherwise  = RVar v r 
-  subt (x, y) (RAllT (RTVar v i) t r)
-    | BTV x == v = RAllT (RTVar v i) t r
-    | otherwise  = RAllT (RTVar v i) (subt (x,y) t) r
-  subt su (RFun x t1 t2 r)  = RFun x (subt su t1) (subt su t2) r 
-  subt su (RImpF x t1 t2 r) = RImpF x (subt su t1) (subt su t2) r
-  subt su (RAllP p t)       = RAllP p (subt su t)
-  subt su (RApp c ts ps r)  = RApp c (subt su <$> ts) (subt su <$> ps) r 
-  subt su (RAllE x t1 t2)   = RAllE x (subt su t1) (subt su t2)
-  subt su (REx x t1 t2)     = REx x (subt su t1) (subt su t2)
-  subt _  (RExprArg e)      = RExprArg e 
-  subt su (RAppTy t1 t2 r)  = RAppTy (subt su t1) (subt su t2) r 
-  subt su (RRTy e r o t)    = RRTy [(x, subt su p) | (x,p) <- e] r o (subt su t)
-  subt _ (RHole r)          = RHole r 
-  
-instance SubsTy Symbol Symbol (RTProp BTyCon BTyVar r) where
-  subt su (RProp e t) =  RProp [(x, subt su xt) | (x,xt) <- e] (subt su t)
-
-
-
-instance (SubsTy tv ty Sort) => SubsTy tv ty Expr where
-  subt su (ELam (x, s) e) = ELam (x, subt su s) $ subt su e
-  subt su (EApp e1 e2)    = EApp (subt su e1) (subt su e2)
-  subt su (ENeg e)        = ENeg (subt su e)
-  subt su (PNot e)        = PNot (subt su e)
-  subt su (EBin b e1 e2)  = EBin b (subt su e1) (subt su e2)
-  subt su (EIte e e1 e2)  = EIte (subt su e) (subt su e1) (subt su e2)
-  subt su (ECst e s)      = ECst (subt su e) (subt su s)
-  subt su (ETApp e s)     = ETApp (subt su e) (subt su s)
-  subt su (ETAbs e x)     = ETAbs (subt su e) x
-  subt su (PAnd es)       = PAnd (subt su <$> es)
-  subt su (POr  es)       = POr  (subt su <$> es)
-  subt su (PImp e1 e2)    = PImp (subt su e1) (subt su e2)
-  subt su (PIff e1 e2)    = PIff (subt su e1) (subt su e2)
-  subt su (PAtom b e1 e2) = PAtom b (subt su e1) (subt su e2)
-  subt su (PAll xes e)    = PAll (subt su <$> xes) (subt su e)
-  subt su (PExist xes e)  = PExist (subt su <$> xes) (subt su e)
-  subt _ e                = e
-
-instance (SubsTy tv ty a, SubsTy tv ty b) => SubsTy tv ty (a, b) where
-  subt su (x, y) = (subt su x, subt su y)
-
-instance SubsTy BTyVar (RType BTyCon BTyVar ()) Sort where
-  subt (v, RVar α _) (FObj s)
-    | symbol v == s = FObj $ symbol α
-    | otherwise     = FObj s
-  subt _ s          = s
-
-
-instance SubsTy Symbol RSort Sort where
-  subt (v, RVar α _) (FObj s)
-    | symbol v == s = FObj $ symbol {- rTyVarSymbol -} α
-    | otherwise     = FObj s
-  subt _ s          = s
-
-
-instance SubsTy RTyVar RSort Sort where
-  subt (v, sv) (FObj s)
-    | symbol v == s = typeSort mempty (toType sv)
-    | otherwise     = FObj s
-  subt _ s          = s
-
-instance (SubsTy tv ty ty) => SubsTy tv ty (PVKind ty) where
-  subt su (PVProp t) = PVProp (subt su t)
-  subt _   PVHProp   = PVHProp
-
-instance (SubsTy tv ty ty) => SubsTy tv ty (PVar ty) where
-  subt su (PV n t v xts) = PV n (subt su t) v [(subt su t, x, y) | (t,x,y) <- xts]
-
-instance SubsTy RTyVar RSort RTyCon where
-   subt z c = RTyCon tc ps' i
-     where
-       tc   = rtc_tc c
-       ps'  = subt z <$> rTyConPVs c
-       i    = rtc_info c
-
--- NOTE: This DOES NOT substitute at the binders
-instance SubsTy RTyVar RSort PrType where
-  subt (α, τ) = subsTyVar_meet (α, τ, ofRSort τ)
-
-instance SubsTy RTyVar RSort SpecType where
-  subt (α, τ) = subsTyVar_meet (α, τ, ofRSort τ)
-
-instance SubsTy TyVar Type SpecType where
-  subt (α, τ) = subsTyVar_meet (RTV α, ofType τ, ofType τ)
-
-instance SubsTy RTyVar RTyVar SpecType where
-  subt (α, a) = subt (α, RVar a () :: RSort)
-
-
-instance SubsTy RTyVar RSort RSort where
-  subt (α, τ) = subsTyVar_meet (α, τ, ofRSort τ)
-
-instance SubsTy tv RSort Predicate where
-  subt _ = id -- NV TODO
-
-instance (SubsTy tv ty r) => SubsTy tv ty (UReft r) where
-  subt su r = r {ur_reft = subt su $ ur_reft r}
-
--- Here the "String" is a Bare-TyCon. TODO: wrap in newtype
-instance SubsTy BTyVar BSort BTyCon where
-  subt _ t = t
-
-instance SubsTy BTyVar BSort BSort where
-  subt (α, τ) = subsTyVar_meet (α, τ, ofRSort τ)
-
-instance (SubsTy tv ty (UReft r), SubsTy tv ty (RType c tv ())) => SubsTy tv ty (RTProp c tv (UReft r))  where
-  subt m (RProp ss (RHole p)) = RProp ((mapSnd (subt m)) <$> ss) $ RHole $ subt m p
-  subt m (RProp ss t) = RProp ((mapSnd (subt m)) <$> ss) $ fmap (subt m) t
-
-subvUReft     :: (UsedPVar -> UsedPVar) -> UReft Reft -> UReft Reft
-subvUReft f (MkUReft r p) = MkUReft r (subvPredicate f p)
-
-subvPredicate :: (UsedPVar -> UsedPVar) -> Predicate -> Predicate
-subvPredicate f (Pr pvs) = Pr (f <$> pvs)
-
---------------------------------------------------------------------------------
-ofType :: Monoid r => Type -> RRType r
---------------------------------------------------------------------------------
-ofType      = ofType_ $ TyConv
-  { tcFVar  = rVar
-  , tcFTVar = rTVar
-  , tcFApp  = \c ts -> rApp c ts [] mempty
-  , tcFLit  = ofLitType rApp
-  }
-
---------------------------------------------------------------------------------
-bareOfType :: Monoid r => Type -> BRType r
---------------------------------------------------------------------------------
-bareOfType  = ofType_ $ TyConv
-  { tcFVar  = (`RVar` mempty) . BTV . symbol
-  , tcFTVar = bTVar
-  , tcFApp  = \c ts -> bApp c ts [] mempty
-  , tcFLit  = ofLitType bApp
-  }
-
---------------------------------------------------------------------------------
-ofType_ :: Monoid r => TyConv c tv r -> Type -> RType c tv r
---------------------------------------------------------------------------------
-ofType_ tx = go . expandTypeSynonyms
-  where
-    go (TyVarTy α)
-      = tcFVar tx α
-    go (FunTy _ τ τ')
-      = rFun dummySymbol (go τ) (go τ')
-    go (ForAllTy (Bndr α _) τ)
-      = RAllT (tcFTVar tx α) (go τ) mempty
-    go (TyConApp c τs)
-      | Just (αs, τ) <- TC.synTyConDefn_maybe c
-      = go (substTyWith αs τs τ)
-      | otherwise
-      = tcFApp tx c (go <$> τs) -- [] mempty
-    go (AppTy t1 t2)
-      = RAppTy (go t1) (ofType_ tx t2) mempty
-    go (LitTy x)
-      = tcFLit tx x
-    go (CastTy t _)
-      = go t
-    go (CoercionTy _)
-      = errorstar "Coercion is currently not supported"
-
-ofLitType :: (Monoid r) => (TyCon -> [RType c tv r] -> [p] -> r -> RType c tv r) -> TyLit -> RType c tv r
-ofLitType rF (NumTyLit _)  = rF intTyCon [] [] mempty
-ofLitType rF t@(StrTyLit _)
-  | t == holeLit           = RHole mempty 
-  | otherwise              = rF listTyCon [rF charTyCon [] [] mempty] [] mempty
-
-holeLit :: TyLit
-holeLit = StrTyLit "$LH_RHOLE"
-
-data TyConv c tv r = TyConv
-  { tcFVar  :: TyVar -> RType c tv r
-  , tcFTVar :: TyVar -> RTVar tv (RType c tv ())
-  , tcFApp  :: TyCon -> [RType c tv r] -> RType c tv r
-  , tcFLit  :: TyLit -> RType c tv r
-  }
-
---------------------------------------------------------------------------------
--- | Converting to Fixpoint ----------------------------------------------------
---------------------------------------------------------------------------------
-
-
-instance Expression Var where
-  expr   = eVar
-
--- TODO: turn this into a map lookup?
-dataConReft ::  DataCon -> [Symbol] -> Reft
-dataConReft c []
-  | c == trueDataCon
-  = predReft $ eProp vv_
-  | c == falseDataCon
-  = predReft $ PNot $ eProp vv_
-
-dataConReft c [x]
-  | c == intDataCon
-  = symbolReft x -- OLD (vv_, [RConc (PAtom Eq (EVar vv_) (EVar x))])
-dataConReft c _
-  | not $ isBaseDataCon c
-  = mempty
-dataConReft c xs
-  = exprReft dcValue -- OLD Reft (vv_, [RConc (PAtom Eq (EVar vv_) dcValue)])
-  where
-    dcValue
-      | null xs && null (dataConUnivTyVars c)
-      = EVar $ symbol c
-      | otherwise
-      = mkEApp (dummyLoc $ symbol c) (eVar <$> xs)
-
-isBaseDataCon :: DataCon -> Bool
-isBaseDataCon c = and $ isBaseTy <$> dataConOrigArgTys c ++ dataConRepArgTys c
-
-isBaseTy :: Type -> Bool
-isBaseTy (TyVarTy _)     = True
-isBaseTy (AppTy _ _)     = False
-isBaseTy (TyConApp _ ts) = and $ isBaseTy <$> ts
-isBaseTy (FunTy  _ _ _)  = False
-isBaseTy (ForAllTy _ _)  = False
-isBaseTy (LitTy _)       = True
-isBaseTy (CastTy _ _)    = False
-isBaseTy (CoercionTy _)  = False
-
-
-dataConMsReft :: Reftable r => RType c tv r -> [Symbol] -> Reft
-dataConMsReft ty ys  = subst su (rTypeReft (ignoreOblig $ ty_res trep))
-  where
-    trep = toRTypeRep ty
-    xs   = ty_binds trep
-    ts   = ty_args  trep
-    su   = mkSubst $ [(x, EVar y) | ((x, _), y) <- zip (zip xs ts) ys]
-
---------------------------------------------------------------------------------
--- | Embedding RefTypes --------------------------------------------------------
---------------------------------------------------------------------------------
-
-type ToTypeable r = (Reftable r, PPrint r, SubsTy RTyVar (RRType ()) r, Reftable (RTProp RTyCon RTyVar r))
-
--- TODO: remove toType, generalize typeSort
-toType  :: (ToTypeable r) => RRType r -> Type
-toType (RImpF x t t' r)
- = toType (RFun x t t' r)
-toType (RFun _ t t' _)
-  = FunTy VisArg (toType t) (toType t') -- FIXME(adinapoli) Is 'VisArg' correct here?
-toType (RAllT a t _) | RTV α <- ty_var_value a
-  = ForAllTy (Bndr α Required) (toType t)
-toType (RAllP _ t)
-  = toType t
-toType (RVar (RTV α) _)
-  = TyVarTy α
-toType (RApp (RTyCon {rtc_tc = c}) ts _ _)
-  = TyConApp c (toType <$> filter notExprArg ts)
-  where
-    notExprArg (RExprArg _) = False
-    notExprArg _            = True
-toType (RAllE _ _ t)
-  = toType t
-toType (REx _ _ t)
-  = toType t
-toType (RAppTy t (RExprArg _) _)
-  = toType t
-toType (RAppTy t t' _)
-  = AppTy (toType t) (toType t')
-toType t@(RExprArg _)
-  = impossible Nothing $ "CANNOT HAPPEN: RefType.toType called with: " ++ show t
-toType (RRTy _ _ _ t)
-  = toType t
-toType (RHole _)
-  = LitTy holeLit  
--- toType t
---  = {- impossible Nothing -} Prelude.error $ "RefType.toType cannot handle: " ++ show t
-
-{- | [NOTE:Hole-Lit] 
-
-We use `toType` to convert RType to GHC.Type to expand any GHC 
-related type-aliases, e.g. in Bare.Resolve.expandRTypeSynonyms. 
-If the RType has a RHole then what to do?
-
-We, encode `RHole` as `LitTy "LH_HOLE"` -- which is a bit of 
-a *hack*. The only saving grace is it is used *temporarily* 
-and then swiftly turned back into an `RHole` via `ofType` 
-(after GHC has done its business of expansion).
-
-Of course, we hope this doesn't break any GHC invariants!
-See issue #1476 and #1477 
-
-The other option is to *not* use `toType` on things that have
-holes in them, but this seems worse, e.g. because you may define 
-a plain GHC alias like:
-
-    type ToNat a = a -> Nat 
-
-and then you might write refinement types like:
-
-    {-@ foo :: ToNat {v:_ | 0 <= v} @-}
-
-and we'd want to expand the above to
-
-    {-@ foo :: {v:_ | 0 <= v} -> Nat @-}
-
-and then resolve the hole using the (GHC) type of `foo`.
-
--}
-
---------------------------------------------------------------------------------
--- | Annotations and Solutions -------------------------------------------------
---------------------------------------------------------------------------------
-
-rTypeSortedReft ::  (PPrint r, Reftable r, SubsTy RTyVar (RType RTyCon RTyVar ()) r, Reftable (RTProp RTyCon RTyVar r))
-                => TCEmb TyCon -> RRType r -> SortedReft
-rTypeSortedReft emb t = RR (rTypeSort emb t) (rTypeReft t)
-
-rTypeSort     ::  (PPrint r, Reftable r, SubsTy RTyVar (RType RTyCon RTyVar ()) r, Reftable (RTProp RTyCon RTyVar r))
-              => TCEmb TyCon -> RRType r -> Sort
-rTypeSort tce = typeSort tce . toType
-
---------------------------------------------------------------------------------
-applySolution :: (Functor f) => FixSolution -> f SpecType -> f SpecType
---------------------------------------------------------------------------------
-applySolution = fmap . fmap . mapReft . appSolRefa
-  where
-    mapReft f (MkUReft (Reft (x, z)) p) = MkUReft (Reft (x, f z)) p
-
-appSolRefa :: Visitable t
-           => M.HashMap KVar Expr -> t -> t
-appSolRefa s p = mapKVars f p
-  where
-    f k        = Just $ M.lookupDefault PTop k s
-
---------------------------------------------------------------------------------
--- shiftVV :: Int -- SpecType -> Symbol -> SpecType
-shiftVV :: (TyConable c, F.Reftable (f Reft), Functor f) 
-        => RType c tv (f Reft) -> Symbol -> RType c tv (f Reft) 
---------------------------------------------------------------------------------
-shiftVV t@(RApp _ ts rs r) vv'
-  = t { rt_args  = subst1 ts (rTypeValueVar t, EVar vv') }
-      { rt_pargs = subst1 rs (rTypeValueVar t, EVar vv') }
-      { rt_reft  = (`F.shiftVV` vv') <$> r }
-
-shiftVV t@(RImpF _ _ _ r) vv'
-  = t { rt_reft = (`F.shiftVV` vv') <$> r }
-
-shiftVV t@(RFun _ _ _ r) vv'
-  = t { rt_reft = (`F.shiftVV` vv') <$> r }
-
-shiftVV t@(RAppTy _ _ r) vv'
-  = t { rt_reft = (`F.shiftVV` vv') <$> r }
-
-shiftVV t@(RVar _ r) vv'
-  = t { rt_reft = (`F.shiftVV` vv') <$> r }
-
-shiftVV t _
-  = t -- errorstar $ "shiftVV: cannot handle " ++ showpp t
-
-
---------------------------------------------------------------------------------
--- |Auxiliary Stuff Used Elsewhere ---------------------------------------------
---------------------------------------------------------------------------------
-
--- MOVE TO TYPES
-instance (Show tv, Show ty) => Show (RTAlias tv ty) where
-  show (RTA n as xs t) =
-    printf "type %s %s %s = %s" (symbolString n)
-      (unwords (show <$> as))
-      (unwords (show <$> xs))
-      (show t)
-
---------------------------------------------------------------------------------
--- | From Old Fixpoint ---------------------------------------------------------
---------------------------------------------------------------------------------
-typeSort :: TCEmb TyCon -> Type -> Sort
-typeSort tce = go
-  where
-    go :: Type -> Sort
-    go t@(FunTy  _ _ _) = typeSortFun tce t
-    go τ@(ForAllTy _ _) = typeSortForAll tce τ
-    -- go (TyConApp c τs)  = fApp (tyConFTyCon tce c) (go <$> τs)
-    go (TyConApp c τs)  
-      | isNewTyCon c
-      , not (isRecursivenewTyCon c) 
-      = go (Ghc.newTyConInstRhs c τs)
-      | otherwise  
-      = tyConFTyCon tce c (go <$> τs)
-    go (AppTy t1 t2)    = fApp (go t1) [go t2]
-    go (TyVarTy tv)     = tyVarSort tv
-    go (CastTy t _)     = go t
-    go τ                = FObj (typeUniqueSymbol τ)
-
-tyConFTyCon :: TCEmb TyCon -> TyCon -> [Sort] -> Sort
-tyConFTyCon tce c ts = case tceLookup c tce of 
-                         Just (t, WithArgs) -> t 
-                         Just (t, NoArgs)   -> fApp t ts  
-                         Nothing            -> fApp (fTyconSort niTc) ts 
-  where
-    niTc             = symbolNumInfoFTyCon (dummyLoc $ tyConName c) (isNumCls c) (isFracCls c)
-    -- oldRes           = F.notracepp _msg $ M.lookupDefault def c tce
-    -- _msg             = "tyConFTyCon c = " ++ show c ++ "default " ++ show (def, TC.isFamInstTyCon c)
-
-tyVarSort :: TyVar -> Sort
-tyVarSort = FObj . symbol 
-
-typeUniqueSymbol :: Type -> Symbol
-typeUniqueSymbol = symbol . GM.typeUniqueString
-
-typeSortForAll :: TCEmb TyCon -> Type -> Sort
-typeSortForAll tce τ  = F.notracepp ("typeSortForall " ++ showpp τ) $ genSort sbody
-  where
-    sbody             = typeSort tce tbody
-    genSort t         = foldl' (flip FAbs) (sortSubst su t) [i..n+i-1]
-    (as, tbody)       = F.notracepp ("splitForallTys" ++ GM.showPpr τ) (splitForAllTys τ)
-    su                = M.fromList $ zip sas (FVar <$>  [i..])
-    sas               = symbol <$> as
-    n                 = length as
-    i                 = sortAbs sbody + 1
-
--- RJ: why not make this the Symbolic instance?
-tyConName :: TyCon -> Symbol
-tyConName c
-  | listTyCon == c    = listConName
-  | TC.isTupleTyCon c = tupConName
-  | otherwise         = symbol c
-
-typeSortFun :: TCEmb TyCon -> Type -> Sort
-typeSortFun tce t = mkFFunc 0 sos
-  where 
-    sos           = typeSort tce <$> τs
-    τs            = grabArgs [] t
-
-grabArgs :: [Type] -> Type -> [Type]
-grabArgs τs (FunTy _ τ1 τ2)
-  | Just a <- stringClassArg τ1
-  = grabArgs τs (mapType (\t -> if t == a then stringTy else t) τ2)
-  | not ( F.notracepp ("isNonArg: " ++ GM.showPpr τ1) $ isNonValueTy τ1)
-  = grabArgs (τ1:τs) τ2
-  | otherwise
-  = grabArgs τs τ2
-grabArgs τs τ
-  = reverse (τ:τs)
-
-isNonValueTy :: Type -> Bool
-isNonValueTy = GM.isPredType
-
-
-expandProductType :: (PPrint r, Reftable r, SubsTy RTyVar (RType RTyCon RTyVar ()) r, Reftable (RTProp RTyCon RTyVar r))
-                  => Var -> RType RTyCon RTyVar r -> RType RTyCon RTyVar r
-expandProductType x t
-  | isTrivial       = t
-  | otherwise       = fromRTypeRep $ trep {ty_binds = xs', ty_args = ts', ty_refts = rs'}
-     where
-      isTrivial     = ofType (varType x) == toRSort t
-      τs            = fst $ splitFunTys $ snd $ splitForAllTys $ toType t
-      trep          = toRTypeRep t
-      (xs',ts',rs') = unzip3 $ concatMap mkProductTy $ zip4 τs (ty_binds trep) (ty_args trep) (ty_refts trep)
-
--- splitFunTys :: Type -> ([Type], Type)
-
-
-mkProductTy :: (Monoid t, Monoid r)
-            => (Type, Symbol, RType RTyCon RTyVar r, t)
-            -> [(Symbol, RType RTyCon RTyVar r, t)]
-mkProductTy (τ, x, t, r) = maybe [(x, t, r)] f $ deepSplitProductType_maybe menv τ
-  where
-    f    = map ((dummySymbol, , mempty) . ofType . fst) . third4
-    menv = (emptyFamInstEnv, emptyFamInstEnv)
-
------------------------------------------------------------------------------------------
--- | Binders generated by class predicates, typically for constraining tyvars (e.g. FNum)
------------------------------------------------------------------------------------------
-classBinds :: TCEmb TyCon -> SpecType -> [(Symbol, SortedReft)]
-classBinds _ (RApp c ts _ _)
-  | isFracCls c
-  = [(symbol a, trueSortedReft FFrac) | (RVar a _) <- ts]
-  | isNumCls c
-  = [(symbol a, trueSortedReft FNum) | (RVar a _) <- ts]
-classBinds emb (RApp c [_, _, (RVar a _), t] _ _)
-  | isEqual c
-  = [(symbol a, rTypeSortedReft emb t)]
-classBinds  emb ty@(RApp c [_, (RVar a _), t] _ _)
-  | isEqualityConstr ty 
-  = [(symbol a, rTypeSortedReft emb t)]
-  | otherwise 
-  = notracepp ("CLASSBINDS-0: " ++ showpp c) [] 
-classBinds _ t
-  = notracepp ("CLASSBINDS-1: " ++ showpp (toType t, isEqualityConstr t)) []
-
-isEqualityConstr :: SpecType -> Bool
-isEqualityConstr (toType -> ty) = Ghc.isEqPred ty || Ghc.isEqPrimPred ty
-
---------------------------------------------------------------------------------
--- | Termination Predicates ----------------------------------------------------
---------------------------------------------------------------------------------
-
-makeNumEnv :: (Foldable t, TyConable c) => t (RType c b t1) -> [b]
-makeNumEnv = concatMap go
-  where
-    go (RApp c ts _ _) | isNumCls c || isFracCls c = [ a | (RVar a _) <- ts]
-    go _ = []
-
-isDecreasing :: S.HashSet TyCon -> [RTyVar] -> SpecType -> Bool
-isDecreasing autoenv  _ (RApp c _ _ _)
-  =  isJust (sizeFunction (rtc_info c)) -- user specified size or
-  || isSizeable autoenv tc
-  where tc = rtc_tc c
-isDecreasing _ cenv (RVar v _)
-  = v `elem` cenv
-isDecreasing _ _ _
-  = False
-
-makeDecrType :: Symbolic a
-             => S.HashSet TyCon
-             -> [(a, (Symbol, RType RTyCon t (UReft Reft)))]
-             -> Either (Symbol, RType RTyCon t (UReft Reft)) String 
-makeDecrType autoenv = mkDType autoenv [] []
-
-mkDType :: Symbolic a
-        => S.HashSet TyCon
-        -> [(Symbol, Symbol, Symbol -> Expr)]
-        -> [Expr]
-        -> [(a, (Symbol, RType RTyCon t (UReft Reft)))]
-        -> Either (Symbol, RType RTyCon t (UReft Reft)) String 
-mkDType autoenv xvs acc [(v, (x, t))]
-  = Left ((x, ) $ t `strengthen` tr)
-  where
-    tr = uTop $ Reft (vv, pOr (r:acc))
-    r  = cmpLexRef xvs (v', vv, f)
-    v' = symbol v
-    f  = mkDecrFun autoenv  t
-    vv = "vvRec"
-
-mkDType autoenv xvs acc ((v, (x, t)):vxts)
-  = mkDType autoenv ((v', x, f):xvs) (r:acc) vxts
-  where
-    r  = cmpLexRef xvs  (v', x, f)
-    v' = symbol v
-    f  = mkDecrFun autoenv t
-
-
-mkDType _ _ _ _
-  = Right "RefType.mkDType called on invalid input"
-
-isSizeable  :: S.HashSet TyCon -> TyCon -> Bool
-isSizeable autoenv tc = S.member tc autoenv --   TC.isAlgTyCon tc -- && TC.isRecursiveTyCon tc
-
-mkDecrFun :: S.HashSet TyCon -> RType RTyCon t t1 -> Symbol -> Expr
-mkDecrFun autoenv (RApp c _ _ _)
-  | Just f <- szFun <$> sizeFunction (rtc_info c)
-  = f
-  | isSizeable autoenv $ rtc_tc c
-  = \v -> F.mkEApp lenLocSymbol [F.EVar v]
-mkDecrFun _ (RVar _ _)
-  = EVar
-mkDecrFun _ _
-  = panic Nothing "RefType.mkDecrFun called on invalid input"
-
--- | [NOTE]: THIS IS WHERE THE TERMINATION METRIC REFINEMENTS ARE CREATED.
-cmpLexRef :: [(t1, t1, t1 -> Expr)] -> (t, t, t -> Expr) -> Expr
-cmpLexRef vxs (v, x, g)
-  = pAnd $  (PAtom Lt (g x) (g v)) : (PAtom Ge (g x) zero)
-         :  [PAtom Eq (f y) (f z) | (y, z, f) <- vxs]
-         ++ [PAtom Ge (f y) zero  | (y, _, f) <- vxs]
-  where zero = ECon $ I 0
-
-makeLexRefa :: [Located Expr] -> [Located Expr] -> UReft Reft
-makeLexRefa es' es = uTop $ Reft (vv, PIff (EVar vv) $ pOr rs)
-  where
-    rs = makeLexReft [] [] (val <$> es) (val <$> es')
-    vv = "vvRec"
-
-makeLexReft :: [(Expr, Expr)] -> [Expr] -> [Expr] -> [Expr] -> [Expr]
-makeLexReft _ acc [] []
-  = acc
-makeLexReft old acc (e:es) (e':es')
-  = makeLexReft ((e,e'):old) (r:acc) es es'
-  where
-    r    = pAnd $  (PAtom Lt e' e)
-                :  (PAtom Ge e' zero)
-                :  [PAtom Eq o' o    | (o,o') <- old]
-                ++ [PAtom Ge o' zero | (_,o') <- old]
-    zero = ECon $ I 0
-makeLexReft _ _ _ _
-  = panic Nothing "RefType.makeLexReft on invalid input"
-
---------------------------------------------------------------------------------
-mkTyConInfo :: TyCon -> VarianceInfo -> VarianceInfo -> Maybe SizeFun -> TyConInfo
-mkTyConInfo c userTv userPv f = TyConInfo tcTv userPv f
-  where
-    tcTv                      = if null userTv then defTv else userTv
-    defTv                     = makeTyConVariance c
-
-
-makeTyConVariance :: TyCon -> VarianceInfo
-makeTyConVariance c = varSignToVariance <$> tvs
-  where
-    tvs = GM.tyConTyVarsDef c
-
-    varsigns = if TC.isTypeSynonymTyCon c
-                  then go True (fromJust $ TC.synTyConRhs_maybe c)
-                  else L.nub $ concatMap goDCon $ TC.tyConDataCons c
-
-    varSignToVariance v = case filter (\p -> GM.showPpr (fst p) == GM.showPpr v) varsigns of
-                            []       -> Invariant
-                            [(_, b)] -> if b then Covariant else Contravariant
-                            _        -> Bivariant
-
-
-    goDCon dc = concatMap (go True) (DataCon.dataConOrigArgTys dc)
-
-    go pos (FunTy _ t1 t2) = go (not pos) t1 ++ go pos t2
-    go pos (ForAllTy _ t)  = go pos t
-    go pos (TyVarTy v)     = [(v, pos)]
-    go pos (AppTy t1 t2)   = go pos t1 ++ go pos t2
-    go pos (TyConApp c' ts)
-       | c == c'
-       = []
-
--- NV fix that: what happens if we have mutually recursive data types?
--- now just provide "default" Bivariant for mutually rec types.
--- but there should be a finer solution
-       | mutuallyRecursive c c'
-       = concatMap (goTyConApp pos Bivariant) ts
-       | otherwise
-       = concat $ zipWith (goTyConApp pos) (makeTyConVariance c') ts
-
-    go _   (LitTy _)       = []
-    go _   (CoercionTy _)  = []
-    go pos (CastTy t _)    = go pos t
-
-    goTyConApp _   Invariant     _ = []
-    goTyConApp pos Bivariant     t = goTyConApp pos Contravariant t ++ goTyConApp pos Covariant t
-    goTyConApp pos Covariant     t = go pos       t
-    goTyConApp pos Contravariant t = go (not pos) t
-
-    mutuallyRecursive c c' = c `S.member` (dataConsOfTyCon c')
-
-
-dataConsOfTyCon :: TyCon -> S.HashSet TyCon
-dataConsOfTyCon = dcs S.empty
-  where
-    dcs vis c               = mconcat $ go vis <$> [t | dc <- TC.tyConDataCons c, t <- DataCon.dataConOrigArgTys dc]
-    go  vis (FunTy _ t1 t2) = go vis t1 `S.union` go vis t2
-    go  vis (ForAllTy _ t)  = go vis t
-    go  _   (TyVarTy _)     = S.empty
-    go  vis (AppTy t1 t2)   = go vis t1 `S.union` go vis t2
-    go  vis (TyConApp c ts)
-      | c `S.member` vis
-      = S.empty
-      | otherwise
-      = (S.insert c $ mconcat $ go vis <$> ts) `S.union` dcs (S.insert c vis) c
-    go  _   (LitTy _)       = S.empty
-    go  _   (CoercionTy _)  = S.empty
-    go  vis (CastTy t _)    = go vis t
-
---------------------------------------------------------------------------------
--- | Printing Refinement Types -------------------------------------------------
---------------------------------------------------------------------------------
-
-instance Show RTyVar where
-  show = showpp
-
-instance PPrint (UReft r) => Show (UReft r) where
-  show = showpp
-
-instance PPrint DataDecl where
-  pprintTidy k dd = "data" <+> pprint (tycName dd) <+> ppMbSizeFun (tycSFun dd) <+> pprint (tycTyVars dd) <+> "="
-                    $+$ nest 4 (vcat $ [ "|" <+> pprintTidy k c | c <- tycDCons dd ])
-
-instance PPrint DataCtor where
-  -- pprintTidy k (DataCtor c as _   xts Nothing)  = pprintTidy k c <+> dcolon ppVars as <+> braces (ppFields k ", " xts)
-  -- pprintTidy k (DataCtor c as ths xts (Just t)) = pprintTidy k c <+> dcolon <+> ppVars as <+> ppThetas ths <+> (ppFields k " ->" xts) <+> "->" <+> pprintTidy k t
-  pprintTidy k (DataCtor c as ths xts t) = pprintTidy k c <+> dcolon <+> ppVars k as <+> ppThetas ths <+> (ppFields k " ->" xts) <+> "->" <+> res 
-    where
-      res         = maybe "*" (pprintTidy k) t 
-      ppThetas [] = empty
-      ppThetas ts = parens (hcat $ punctuate ", " (pprintTidy k <$> ts)) <+> "=>"
-
-
-ppVars :: (PPrint a) => Tidy -> [a] -> Doc
-ppVars k as = "forall" <+> hcat (punctuate " " (F.pprintTidy k <$> as)) <+> "." 
-
-ppFields :: (PPrint k, PPrint v) => Tidy -> Doc -> [(k, v)] -> Doc
-ppFields k sep kvs = hcat $ punctuate sep (F.pprintTidy k <$> kvs)
-
-ppMbSizeFun :: Maybe SizeFun -> Doc
-ppMbSizeFun Nothing  = ""
-ppMbSizeFun (Just z) = F.pprint z
-
--- instance PPrint DataCtor where
-  -- pprintTidy k (DataCtor c xts t) =
-    -- pprintTidy k c <+> text "::" <+> (hsep $ punctuate (text "->")
-                                          -- ((pprintTidy k <$> xts) ++ [pprintTidy k t]))
-
--- ppHack :: (?callStack :: CallStack) => a -> b
--- ppHack _ = errorstar "OOPS"
-
-instance PPrint (RType c tv r) => Show (RType c tv r) where
-  show = showpp
-
-instance PPrint (RTProp c tv r) => Show (RTProp c tv r) where
-  show = showpp
-
-
--------------------------------------------------------------------------------
--- | tyVarsPosition t returns the type variables appearing 
--- | (in positive positions, in negative positions, in undetermined positions)
--- | undetermined positions are due to type constructors and type application
--------------------------------------------------------------------------------
-tyVarsPosition :: RType RTyCon tv r -> Positions tv 
-tyVarsPosition = go (Just True)
-  where 
-    go p (RVar t _)        = report p t
-    go p (RFun _ t1 t2 _)  = go (flip p) t1 <> go p t2 
-    go p (RImpF _ t1 t2 _) = go (flip p) t1 <> go p t2 
-    go p (RAllT _ t _)     = go p t 
-    go p (RAllP _ t)       = go p t 
-    go p (RApp c ts _ _)   = mconcat (zipWith go (getPosition p <$> varianceTyArgs (rtc_info c)) ts)
-    go p (RAllE _ t1 t2)   = go p t1 <> go p t2 
-    go p (REx _ t1 t2)     = go p t1 <> go p t2
-    go _ (RExprArg _)      = mempty
-    go p (RAppTy t1 t2 _)  = go p t1 <> go p t2 
-    go p (RRTy _ _ _ t)    = go p t 
-    go _ (RHole _)         = mempty
-
-    getPosition :: Maybe Bool -> Variance -> Maybe Bool
-    getPosition b Contravariant = not <$> b 
-    getPosition b _             = b  
-
-    report Nothing v      = (Pos [] [] [v])
-    report (Just True) v  = (Pos [v] [] [])
-    report (Just False) v = (Pos [] [v] [])
-    flip = fmap not
-
-data Positions a = Pos {ppos :: [a], pneg ::  [a], punknown :: [a]}
-
-instance Monoid (Positions a) where 
-  mempty = Pos [] [] []
-instance Semigroup (Positions a) where 
-  (Pos x1 x2 x3) <> (Pos y1 y2 y3) = Pos (x1 ++ y1) (x2 ++ y2) (x3 ++ y3)
diff --git a/src/Language/Haskell/Liquid/Types/Specs.hs b/src/Language/Haskell/Liquid/Types/Specs.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Specs.hs
+++ /dev/null
@@ -1,803 +0,0 @@
--- | This module contains the top-level structures that hold 
---   information about specifications.
-
-{-# LANGUAGE TypeSynonymInstances       #-}
-{-# LANGUAGE FlexibleInstances          #-}
-{-# LANGUAGE FlexibleContexts           #-}
-{-# LANGUAGE DeriveGeneric              #-}
-{-# LANGUAGE DerivingStrategies         #-}
-{-# LANGUAGE DerivingVia                #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE RecordWildCards            #-}
-
-module Language.Haskell.Liquid.Types.Specs (
-  -- * Different types of specifications
-  -- $differentSpecTypes
-  -- * TargetInfo
-  -- $targetInfo
-    TargetInfo(..)
-  -- * Gathering information about a module
-  , TargetSrc(..)
-  -- * TargetSpec
-  -- $targetSpec
-  , TargetSpec(..)
-  -- * BareSpec
-  -- $bareSpec
-  , BareSpec(..)
-  -- * LiftedSpec
-  -- $liftedSpec
-  , LiftedSpec(..)
-  -- * Tracking dependencies
-  -- $trackingDeps
-  , StableModule(..)
-  , toStableModule
-  , renderModule
-  , TargetDependencies(..)
-  , dropDependency
-  -- * Predicates on spec types
-  -- $predicates
-  , isPLEVar
-  , isExportedVar
-  -- * Other types
-  , QImports(..)
-  , Spec(..)
-  , GhcSpecVars(..)
-  , GhcSpecSig(..)
-  , GhcSpecNames(..)
-  , GhcSpecTerm(..)
-  , GhcSpecRefl(..)
-  , GhcSpecLaws(..)
-  , GhcSpecData(..)
-  , GhcSpecQual(..)
-  , BareDef
-  , BareMeasure
-  , SpecMeasure
-  , VarOrLocSymbol
-  , LawInstance(..)
-  -- * Legacy data structures
-  -- $legacyDataStructures
-  , GhcSrc(..)
-  , GhcSpec(..)
-  -- * Provisional compatibility exports & optics
-  -- $provisionalBackCompat
-  , targetSrcIso
-  , targetSpecGetter
-  , bareSpecIso
-  , liftedSpecGetter
-  , unsafeFromLiftedSpec
-  ) where 
-
-import           Optics
-import           GHC.Generics            hiding (to, moduleName)
-import           Data.Binary
-import qualified Language.Fixpoint.Types as F
-import           Language.Fixpoint.Misc (sortNub)
-import           Data.Hashable
-import qualified Data.HashSet            as S
-import           Data.HashSet            (HashSet)
-import qualified Data.HashMap.Strict     as M
-import           Data.HashMap.Strict     (HashMap)
-import           Language.Haskell.Liquid.Types.Types 
-import           Language.Haskell.Liquid.Types.Generics
-import           Language.Haskell.Liquid.Types.Variance
-import           Language.Haskell.Liquid.Types.Bounds 
-import           Language.Haskell.Liquid.GHC.API 
-import           Language.Haskell.Liquid.GHC.Types
-import           Text.PrettyPrint.HughesPJ              (text, (<+>)) 
-
-
-{- $differentSpecTypes
-
-There are different types or \"flavours\" for a specification, depending on its lifecycle. The main goal
-is always the same, i.e. refining the Haskell types and produce a final statement (i.e. safe or unsafe)
-about the input program. In order to do so, a /specification/ is transformed in the way described by this
-picture:
-
-@
-    +---------------+                                +-------------------+
-    |   BareSpec    |                                |                   |  checked by liquid/liquidOne
-    |               |                    ------------|    TargetSpec     |----------------------------- ..
-    |(input module) |                   /            |                   |
-    +---------------+  makeTargetSpec  /             +-------------------+
-           +         -----------------/
-    +---------------+                 \\              +-------------------+
-    | {LiftedSpec}  |                  \\             |                   |    serialised on disk
-    |               |                   -------------|    LiftedSpec     |----------------------------- ..
-    |(dependencies) |                                |                   |
-    +---------------+                                +-------------------+
-          ^                                                    |
-          |                   used-as                          |
-          +----------------------------------------------------+
-@
-
-More specifically, we distinguish:
-
-* 'BareSpec' - is the specification obtained by parsing the Liquid annotations of the input Haskell file.
-  It typically contains information about the associated input Haskell module, with the exceptions of
-  /assumptions/ that can refer to functions defined in other modules.
-
-* 'LiftedSpec' - is the specification we obtain by \"lifting\" the 'BareSpec'. Most importantly, a
-  'LiftedSpec' gets serialised on disk and becomes a /dependency/ for the verification of other 'BareSpec's.
-
-   Lifting in this context consist of:
-
-    1. Perform name-resolution (e.g. make all the relevant GHC's 'Var's qualified, resolve GHC's 'Name's, etc);
-    2. Strip the final 'LiftedSpec' with information which are relevant (read: local) to just the input
-       'BareSpec'. An example would be /local signatures/, used to annotate internal, auxiliary functions
-       within a 'Module';
-    3. Strip termination checks, which are /required/ (if specified) for a 'BareSpec' but not for the
-       'LiftedSpec'.
-
-* 'TargetSpec' - is the specification we /actually use for refinement/, and is conceptually an
-  \"augmented\" 'BareSpec'. You can create a 'TargetSpec' by calling 'makeTargetSpec'.
-
-In order to produce these spec types we have to gather information about the module being compiled by using
-the GHC API and retain enough context of the compiled 'Module' in order to be able to construct the types
-introduced aboves. The rest of this module introduced also these intermediate structures.
--}
-
--- $targetInfo 
--- The following is the overall type for /specifications/ obtained from
--- parsing the target source and dependent libraries. 
--- /IMPORTANT/: A 'TargetInfo' is what is /checked/ by LH itself and it /NEVER/ contains the 'LiftedSpec', 
--- because the checking happens only on the 'BareSpec' of the target module.
-data TargetInfo = TargetInfo
-  { giSrc  :: !TargetSrc
-    -- ^ The 'TargetSrc' of the module being checked.
-  , giSpec :: !TargetSpec 
-    -- ^ The 'TargetSpec' of the module being checked.
-  }
-
-instance HasConfig TargetInfo where
-  getConfig = getConfig . giSpec
-
--- | The 'TargetSrc' type is a collection of all the things we know about a module being currently
--- checked. It include things like the name of the module, the list of 'CoreBind's,
--- the 'TyCon's declared in this module (that includes 'TyCon's for classes), typeclass instances
--- and so and so forth. It might be consider a sort of 'ModGuts' embellished with LH-specific
--- information (for example, 'giDefVars' are populated with datacons from the module plus the
--- let vars derived from the A-normalisation).
-data TargetSrc = TargetSrc
-  { giIncDir    :: !FilePath              -- ^ Path for LH include/prelude directory
-  , giTarget    :: !FilePath              -- ^ Source file for module
-  , giTargetMod :: !ModName               -- ^ Name for module
-  , giCbs       :: ![CoreBind]            -- ^ Source Code
-  , gsTcs       :: ![TyCon]               -- ^ All used Type constructors
-  , gsCls       :: !(Maybe [ClsInst])     -- ^ Class instances?
-  , giDerVars   :: !(HashSet Var)         -- ^ Binders created by GHC eg dictionaries
-  , giImpVars   :: ![Var]                 -- ^ Binders that are _read_ in module (but not defined?)
-  , giDefVars   :: ![Var]                 -- ^ (Top-level) binders that are _defined_ in module
-  , giUseVars   :: ![Var]                 -- ^ Binders that are _read_ in module
-  , gsExports   :: !(HashSet StableName)  -- ^ `Name`s exported by the module being verified
-  , gsFiTcs     :: ![TyCon]               -- ^ Family instance TyCons 
-  , gsFiDcs     :: ![(F.Symbol, DataCon)] -- ^ Family instance DataCons 
-  , gsPrimTcs   :: ![TyCon]               -- ^ Primitive GHC TyCons (from TysPrim.primTyCons)
-  , gsQualImps  :: !QImports              -- ^ Map of qualified imports
-  , gsAllImps   :: !(HashSet F.Symbol)    -- ^ Set of _all_ imported modules
-  , gsTyThings  :: ![TyThing]             -- ^ All the @TyThing@s known to GHC
-  }
-
--- | 'QImports' is a map of qualified imports.
-data QImports = QImports 
-  { qiModules :: !(S.HashSet F.Symbol)            -- ^ All the modules that are imported qualified
-  , qiNames   :: !(M.HashMap F.Symbol [F.Symbol]) -- ^ Map from qualification to full module name
-  } deriving Show
-
--- $targetSpec
-
--- | A 'TargetSpec' is what we /actually check via LiquidHaskell/. It is created as part of 'mkTargetSpec' 
--- alongside the 'LiftedSpec'. It shares a similar structure with a 'BareSpec', but manipulates and
--- transforms the data in preparation to the checking process.
-data TargetSpec = TargetSpec
-  { gsSig    :: !GhcSpecSig
-  , gsQual   :: !GhcSpecQual
-  , gsData   :: !GhcSpecData
-  , gsName   :: !GhcSpecNames
-  , gsVars   :: !GhcSpecVars
-  , gsTerm   :: !GhcSpecTerm
-  , gsRefl   :: !GhcSpecRefl
-  , gsLaws   :: !GhcSpecLaws
-  , gsImps   :: ![(F.Symbol, F.Sort)]  -- ^ Imported Environment
-  , gsConfig :: !Config
-  }
-
-instance HasConfig TargetSpec where
-  getConfig = gsConfig
-
--- | The collection of GHC 'Var's that a 'TargetSpec' needs to verify (or skip).
-data GhcSpecVars = SpVar 
-  { gsTgtVars    :: ![Var]                        -- ^ Top-level Binders To Verify (empty means ALL binders)
-  , gsIgnoreVars :: !(S.HashSet Var)              -- ^ Top-level Binders To NOT Verify (empty means ALL binders)
-  , gsLvars      :: !(S.HashSet Var)              -- ^ Variables that should be checked "lazily" in the environment they are used
-  , gsCMethods   :: ![Var]                        -- ^ Refined Class methods 
-  }
-
-data GhcSpecQual = SpQual 
-  { gsQualifiers :: ![F.Qualifier]                -- ^ Qualifiers in Source/Spec files e.g tests/pos/qualTest.hs
-  , gsRTAliases  :: ![F.Located SpecRTAlias]      -- ^ Refinement type aliases (only used for qualifiers)
-  }
-
-data GhcSpecSig = SpSig 
-  { gsTySigs   :: ![(Var, LocSpecType)]           -- ^ Asserted Reftypes
-  , gsAsmSigs  :: ![(Var, LocSpecType)]           -- ^ Assumed Reftypes
-  , gsRefSigs  :: ![(Var, LocSpecType)]           -- ^ Reflected Reftypes 
-  , gsInSigs   :: ![(Var, LocSpecType)]           -- ^ Auto generated Signatures
-  , gsNewTypes :: ![(TyCon, LocSpecType)]         -- ^ Mapping of 'newtype' type constructors with their refined types.
-  , gsDicts    :: !(DEnv Var LocSpecType)            -- ^ Refined Classes from Instances 
-  , gsMethods  :: ![(Var, MethodType LocSpecType)]   -- ^ Refined Classes from Classes 
-  , gsTexprs   :: ![(Var, LocSpecType, [F.Located F.Expr])]  -- ^ Lexicographically ordered expressions for termination
-  }
-
-data GhcSpecData = SpData 
-  { gsCtors      :: ![(Var, LocSpecType)]         -- ^ Data Constructor Measure Sigs
-  , gsMeas       :: ![(F.Symbol, LocSpecType)]    -- ^ Measure Types eg.  len :: [a] -> Int
-  , gsInvariants :: ![(Maybe Var, LocSpecType)]   -- ^ Data type invariants from measure definitions, e.g forall a. {v: [a] | len(v) >= 0}
-  , gsIaliases   :: ![(LocSpecType, LocSpecType)] -- ^ Data type invariant aliases 
-  , gsMeasures   :: ![Measure SpecType DataCon]   -- ^ Measure definitions
-  , gsUnsorted   :: ![UnSortedExpr]
-  }
-
-data GhcSpecNames = SpNames 
-  { gsFreeSyms   :: ![(F.Symbol, Var)]            -- ^ List of `Symbol` free in spec and corresponding GHC var, eg. (Cons, Cons#7uz) from tests/pos/ex1.hs
-  , gsDconsP     :: ![F.Located DataCon]          -- ^ Predicated Data-Constructors, e.g. see tests/pos/Map.hs
-  , gsTconsP     :: ![TyConP]                     -- ^ Predicated Type-Constructors, e.g. see tests/pos/Map.hs
-  , gsTcEmbeds   :: !(F.TCEmb TyCon)              -- ^ Embedding GHC Tycons into fixpoint sorts e.g. "embed Set as Set_set" from include/Data/Set.spec
-  , gsADTs       :: ![F.DataDecl]                 -- ^ ADTs extracted from Haskell 'data' definitions
-  , gsTyconEnv   :: !TyConMap
-  }
-
-data GhcSpecTerm = SpTerm 
-  { gsStTerm     :: !(S.HashSet Var)              -- ^ Binders to CHECK by structural termination
-  , gsAutosize   :: !(S.HashSet TyCon)            -- ^ Binders to IGNORE during termination checking
-  , gsLazy       :: !(S.HashSet Var)              -- ^ Binders to IGNORE during termination checking
-  , gsFail       :: !(S.HashSet (F.Located Var))    -- ^ Binders to fail type checking
-  , gsDecr       :: ![(Var, [Int])]               -- ^ Lexicographic order of decreasing args (DEPRECATED) 
-  , gsNonStTerm  :: !(S.HashSet Var)              -- ^ Binders to CHECK using REFINEMENT-TYPES/termination metrics 
-  }
-
-data GhcSpecRefl = SpRefl 
-  { gsAutoInst     :: !(M.HashMap Var (Maybe Int))      -- ^ Binders to USE PLE 
-  , gsHAxioms      :: ![(Var, LocSpecType, F.Equation)] -- ^ Lifted definitions 
-  , gsImpAxioms    :: ![F.Equation]                     -- ^ Axioms from imported reflected functions
-  , gsMyAxioms     :: ![F.Equation]                     -- ^ Axioms from my reflected functions
-  , gsReflects     :: ![Var]                            -- ^ Binders for reflected functions
-  , gsLogicMap     :: !LogicMap
-  , gsWiredReft    :: ![Var]
-  , gsRewrites     :: S.HashSet (F.Located Var)
-  , gsRewritesWith :: M.HashMap Var [Var]
-  }
-
-data GhcSpecLaws = SpLaws 
-  { gsLawDefs :: !([(Class, [(Var, LocSpecType)])])
-  , gsLawInst :: ![LawInstance]
-  }
-
-data LawInstance = LawInstance
-  { lilName   :: Class
-  , liSupers  :: [LocSpecType]
-  , lilTyArgs :: [LocSpecType]
-  , lilEqus   :: [(VarOrLocSymbol, (VarOrLocSymbol, Maybe LocSpecType))]
-  , lilPos    :: SrcSpan
-  }  
-
-type VarOrLocSymbol = Either Var LocSymbol
-type BareMeasure   = Measure LocBareType F.LocSymbol
-type BareDef       = Def     LocBareType F.LocSymbol
-type SpecMeasure   = Measure LocSpecType DataCon
-
--- $bareSpec
-
--- | A 'BareSpec' is the spec we derive by parsing the Liquid Haskell annotations of a single file. As
--- such, it contains things which are relevant for validation and lifting; it contains things like
--- the pragmas the user defined, the termination condition (if termination-checking is enabled) and so
--- on and so forth. /Crucially/, as a 'BareSpec' is still subject to \"preflight checks\", it may contain
--- duplicates (e.g. duplicate measures, duplicate type declarations etc.) and therefore most of the fields
--- for a 'BareSpec' are lists, so that we can report these errors to the end user: it would be an error
--- to silently ignore the duplication and leave the duplicate resolution to whichever 'Eq' instance is
--- implemented for the relevant field.
---
--- Also, a 'BareSpec' has not yet been subject to name resolution, so it may refer
--- to undefined or out-of-scope entities.
-newtype BareSpec =
-  MkBareSpec { getBareSpec :: Spec LocBareType F.LocSymbol }
-  deriving (Generic, Show, Semigroup, Monoid, Binary)
-
--- | A generic 'Spec' type, polymorphic over the inner choice of type and binder.
-data Spec ty bndr  = Spec
-  { measures   :: ![Measure ty bndr]              -- ^ User-defined properties for ADTs
-  , impSigs    :: ![(F.Symbol, F.Sort)]           -- ^ Imported variables types
-  , expSigs    :: ![(F.Symbol, F.Sort)]           -- ^ Exported variables types
-  , asmSigs    :: ![(F.LocSymbol, ty)]            -- ^ Assumed (unchecked) types; including reflected signatures
-  , sigs       :: ![(F.LocSymbol, ty)]            -- ^ Imported functions and types
-  , localSigs  :: ![(F.LocSymbol, ty)]            -- ^ Local type signatures
-  , reflSigs   :: ![(F.LocSymbol, ty)]            -- ^ Reflected type signatures
-  , invariants :: ![(Maybe F.LocSymbol, ty)]      -- ^ Data type invariants; the Maybe is the generating measure
-  , ialiases   :: ![(ty, ty)]                     -- ^ Data type invariants to be checked
-  , imports    :: ![F.Symbol]                     -- ^ Loaded spec module names
-  , dataDecls  :: ![DataDecl]                     -- ^ Predicated data definitions
-  , newtyDecls :: ![DataDecl]                     -- ^ Predicated new type definitions
-  , includes   :: ![FilePath]                     -- ^ Included qualifier files
-  , aliases    :: ![F.Located (RTAlias F.Symbol BareType)] -- ^ RefType aliases
-  , ealiases   :: ![F.Located (RTAlias F.Symbol F.Expr)]   -- ^ Expression aliases
-  , embeds     :: !(F.TCEmb F.LocSymbol)                   -- ^ GHC-Tycon-to-fixpoint Tycon map
-  , qualifiers :: ![F.Qualifier]                           -- ^ Qualifiers in source/spec files
-  , decr       :: ![(F.LocSymbol, [Int])]         -- ^ Information on decreasing arguments
-  , lvars      :: !(S.HashSet F.LocSymbol)        -- ^ Variables that should be checked in the environment they are used
-  , lazy       :: !(S.HashSet F.LocSymbol)        -- ^ Ignore Termination Check in these Functions
-  , rewrites    :: !(S.HashSet F.LocSymbol)        -- ^ Theorems turned into rewrite rules 
-  , rewriteWith :: !(M.HashMap F.LocSymbol [F.LocSymbol]) -- ^ Definitions using rewrite rules 
-  , fails      :: !(S.HashSet F.LocSymbol)        -- ^ These Functions should be unsafe
-  , reflects   :: !(S.HashSet F.LocSymbol)        -- ^ Binders to reflect
-  , autois     :: !(M.HashMap F.LocSymbol (Maybe Int))  -- ^ Automatically instantiate axioms in these Functions with maybe specified fuel
-  , hmeas      :: !(S.HashSet F.LocSymbol)        -- ^ Binders to turn into measures using haskell definitions
-  , hbounds    :: !(S.HashSet F.LocSymbol)        -- ^ Binders to turn into bounds using haskell definitions
-  , inlines    :: !(S.HashSet F.LocSymbol)        -- ^ Binders to turn into logic inline using haskell definitions
-  , ignores    :: !(S.HashSet F.LocSymbol)        -- ^ Binders to ignore during checking; that is DON't check the corebind. 
-  , autosize   :: !(S.HashSet F.LocSymbol)        -- ^ Type Constructors that get automatically sizing info
-  , pragmas    :: ![F.Located String]             -- ^ Command-line configurations passed in through source
-  , cmeasures  :: ![Measure ty ()]                -- ^ Measures attached to a type-class
-  , imeasures  :: ![Measure ty bndr]              -- ^ Mappings from (measure,type) -> measure
-  , classes    :: ![RClass ty]                    -- ^ Refined Type-Classes
-  , claws      :: ![RClass ty]                    -- ^ Refined Type-Classe Laws
-  , termexprs  :: ![(F.LocSymbol, [F.Located F.Expr])] -- ^ Terminating Conditions for functions
-  , rinstance  :: ![RInstance ty]
-  , ilaws      :: ![RILaws ty]
-  , dvariance  :: ![(F.LocSymbol, [Variance])]         -- ^ ? Where do these come from ?!
-  , bounds     :: !(RRBEnv ty)
-  , defs       :: !(M.HashMap F.LocSymbol F.Symbol)    -- ^ Temporary (?) hack to deal with dictionaries in specifications
-                                                       --   see tests/pos/NatClass.hs
-  , axeqs      :: ![F.Equation]                        -- ^ Equalities used for Proof-By-Evaluation
-  } deriving (Generic, Show)
-
-instance Binary (Spec LocBareType F.LocSymbol)
-
-instance (Show ty, Show bndr, F.PPrint ty, F.PPrint bndr) => F.PPrint (Spec ty bndr) where
-    pprintTidy k sp = text "dataDecls = " <+> pprintTidy k  (dataDecls sp)
-
--- /NOTA BENE/: These instances below are considered legacy, because merging two 'Spec's together doesn't
--- really make sense, and we provide this only for legacy purposes.
-instance Semigroup (Spec ty bndr) where
-  s1 <> s2
-    = Spec { measures   =           measures   s1 ++ measures   s2
-           , impSigs    =           impSigs    s1 ++ impSigs    s2
-           , expSigs    =           expSigs    s1 ++ expSigs    s2 
-           , asmSigs    =           asmSigs    s1 ++ asmSigs    s2
-           , sigs       =           sigs       s1 ++ sigs       s2
-           , localSigs  =           localSigs  s1 ++ localSigs  s2
-           , reflSigs   =           reflSigs   s1 ++ reflSigs   s2
-           , invariants =           invariants s1 ++ invariants s2
-           , ialiases   =           ialiases   s1 ++ ialiases   s2
-           , imports    = sortNub $ imports    s1 ++ imports    s2
-           , dataDecls  =           dataDecls  s1 ++ dataDecls  s2
-           , newtyDecls =           newtyDecls s1 ++ newtyDecls s2
-           , includes   = sortNub $ includes   s1 ++ includes   s2
-           , aliases    =           aliases    s1 ++ aliases    s2
-           , ealiases   =           ealiases   s1 ++ ealiases   s2
-           , qualifiers =           qualifiers s1 ++ qualifiers s2
-           , decr       =           decr       s1 ++ decr       s2
-           , pragmas    =           pragmas    s1 ++ pragmas    s2
-           , cmeasures  =           cmeasures  s1 ++ cmeasures  s2
-           , imeasures  =           imeasures  s1 ++ imeasures  s2
-           , classes    =           classes    s1 ++ classes    s2
-           , claws      =           claws      s1 ++ claws      s2
-           , termexprs  =           termexprs  s1 ++ termexprs  s2
-           , rinstance  =           rinstance  s1 ++ rinstance  s2
-           , ilaws      =               ilaws  s1 ++ ilaws      s2 
-           , dvariance  =           dvariance  s1 ++ dvariance  s2
-           , axeqs      =           axeqs s1      ++ axeqs s2
-           , embeds     = mappend   (embeds   s1)  (embeds   s2)
-           , lvars      = S.union   (lvars    s1)  (lvars    s2)
-           , lazy       = S.union   (lazy     s1)  (lazy     s2)
-           , rewrites   = S.union   (rewrites    s1)  (rewrites    s2)
-           , rewriteWith = M.union  (rewriteWith s1)  (rewriteWith s2)
-           , fails      = S.union   (fails    s1)  (fails    s2)
-           , reflects   = S.union   (reflects s1)  (reflects s2)
-           , hmeas      = S.union   (hmeas    s1)  (hmeas    s2)
-           , hbounds    = S.union   (hbounds  s1)  (hbounds  s2)
-           , inlines    = S.union   (inlines  s1)  (inlines  s2)
-           , ignores    = S.union   (ignores  s1)  (ignores  s2)
-           , autosize   = S.union   (autosize s1)  (autosize s2)
-           , bounds     = M.union   (bounds   s1)  (bounds   s2)
-           , defs       = M.union   (defs     s1)  (defs     s2)
-           , autois     = M.union   (autois s1)      (autois s2)
-           }
-
-instance Monoid (Spec ty bndr) where
-  mappend = (<>)
-  mempty
-    = Spec { measures   = []
-           , impSigs    = [] 
-           , expSigs    = [] 
-           , asmSigs    = []
-           , sigs       = []
-           , localSigs  = []
-           , reflSigs   = []
-           , invariants = []
-           , ialiases   = []
-           , imports    = []
-           , dataDecls  = []
-           , newtyDecls = []
-           , includes   = []
-           , aliases    = []
-           , ealiases   = []
-           , embeds     = mempty
-           , qualifiers = []
-           , decr       = []
-           , lvars      = S.empty 
-           , lazy       = S.empty
-           , rewrites   = S.empty
-           , rewriteWith = M.empty
-           , fails      = S.empty
-           , autois     = M.empty
-           , hmeas      = S.empty
-           , reflects   = S.empty
-           , hbounds    = S.empty
-           , inlines    = S.empty
-           , ignores    = S.empty
-           , autosize   = S.empty
-           , pragmas    = []
-           , cmeasures  = []
-           , imeasures  = []
-           , classes    = []
-           , claws      = [] 
-           , termexprs  = []
-           , rinstance  = []
-           , ilaws      = [] 
-           , dvariance  = []
-           , axeqs      = []
-           , bounds     = M.empty
-           , defs       = M.empty
-           }
-
--- $liftedSpec
-
--- | A 'LiftedSpec' is derived from an input 'BareSpec' and a set of its dependencies.
--- The general motivations for lifting a spec are (a) name resolution, (b) the fact that some info is
--- only relevant for checking the body of functions but does not need to be exported, e.g. 
--- termination measures, or the fact that a type signature was assumed.
--- A 'LiftedSpec' is /what we serialise on disk and what the clients should will be using/.
---
--- What we /do not/ have compared to a 'BareSpec':
---
--- * The 'localSigs', as it's not necessary/visible to clients;
--- * The 'includes', as they are probably not reachable for clients anyway;
--- * The 'reflSigs', they are now just \"normal\" signatures;
--- * The 'lazy', we don't do termination checking in lifted specs;
--- * The 'reflects', the reflection has already happened at this point;
--- * The 'hmeas', we have /already/ turned these into measures at this point;
--- * The 'hbounds', ditto as 'hmeas';
--- * The 'inlines', ditto as 'hmeas';
--- * The 'ignores', ditto as 'hmeas';
--- * The 'pragmas', we can't make any use of this information for lifted specs;
--- * The 'termexprs', we don't do termination checking in lifted specs;
---
--- Apart from less fields, a 'LiftedSpec' /replaces all instances of lists with sets/, to enforce
--- duplicate detection and removal on what we serialise on disk.
-data LiftedSpec = LiftedSpec
-  { liftedMeasures   :: HashSet (Measure LocBareType F.LocSymbol)
-    -- ^ User-defined properties for ADTs
-  , liftedImpSigs    :: HashSet (F.Symbol, F.Sort)
-    -- ^ Imported variables types
-  , liftedExpSigs    :: HashSet (F.Symbol, F.Sort)
-    -- ^ Exported variables types
-  , liftedAsmSigs    :: HashSet (F.LocSymbol, LocBareType)
-    -- ^ Assumed (unchecked) types; including reflected signatures
-  , liftedSigs       :: HashSet (F.LocSymbol, LocBareType)
-    -- ^ Imported functions and types
-  , liftedInvariants :: HashSet (Maybe F.LocSymbol, LocBareType)
-    -- ^ Data type invariants; the Maybe is the generating measure
-  , liftedIaliases   :: HashSet (LocBareType, LocBareType)
-    -- ^ Data type invariants to be checked
-  , liftedImports    :: HashSet F.Symbol
-    -- ^ Loaded spec module names
-  , liftedDataDecls  :: HashSet DataDecl
-    -- ^ Predicated data definitions
-  , liftedNewtyDecls :: HashSet DataDecl
-    -- ^ Predicated new type definitions
-  , liftedAliases    :: HashSet (F.Located (RTAlias F.Symbol BareType))
-    -- ^ RefType aliases
-  , liftedEaliases   :: HashSet (F.Located (RTAlias F.Symbol F.Expr))
-    -- ^ Expression aliases
-  , liftedEmbeds     :: F.TCEmb F.LocSymbol
-    -- ^ GHC-Tycon-to-fixpoint Tycon map
-  , liftedQualifiers :: HashSet F.Qualifier
-    -- ^ Qualifiers in source/spec files
-  , liftedDecr       :: HashSet (F.LocSymbol, [Int])
-    -- ^ Information on decreasing arguments
-  , liftedLvars      :: HashSet F.LocSymbol
-    -- ^ Variables that should be checked in the environment they are used
-  , liftedAutois     :: M.HashMap F.LocSymbol (Maybe Int)
-    -- ^ Automatically instantiate axioms in these Functions with maybe specified fuel
-  , liftedAutosize   :: HashSet F.LocSymbol
-    -- ^ Type Constructors that get automatically sizing info
-  , liftedCmeasures  :: HashSet (Measure LocBareType ())
-    -- ^ Measures attached to a type-class
-  , liftedImeasures  :: HashSet (Measure LocBareType F.LocSymbol)
-    -- ^ Mappings from (measure,type) -> measure
-  , liftedClasses    :: HashSet (RClass LocBareType)
-    -- ^ Refined Type-Classes
-  , liftedClaws      :: HashSet (RClass LocBareType)
-    -- ^ Refined Type-Classe Laws
-  , liftedRinstance  :: HashSet (RInstance LocBareType)
-  , liftedIlaws      :: HashSet (RILaws LocBareType)
-  , liftedDvariance  :: HashSet (F.LocSymbol, [Variance])
-    -- ^ ? Where do these come from ?!
-  , liftedBounds     :: RRBEnv LocBareType
-  , liftedDefs       :: M.HashMap F.LocSymbol F.Symbol
-    -- ^ Temporary (?) hack to deal with dictionaries in specifications
-    --   see tests/pos/NatClass.hs
-  , liftedAxeqs      :: HashSet F.Equation
-    -- ^ Equalities used for Proof-By-Evaluation
-  } deriving (Eq, Generic, Show)
-    deriving Hashable via Generically LiftedSpec 
-    deriving Binary   via Generically LiftedSpec 
-
-
--- $trackingDeps
-
--- | A newtype wrapper around a 'Module' which:
---
--- * Allows a 'Module' to be serialised (i.e. it has a 'Binary' instance)
--- * It tries to use stable comparison and equality under the hood.
---
-newtype StableModule = 
-  StableModule { unStableModule :: Module } 
-  deriving Generic
-
--- | Converts a 'Module' into a 'StableModule'.
-toStableModule :: Module -> StableModule
-toStableModule = StableModule
-
-renderModule :: Module -> String
-renderModule m =    "Module { unitId = " <> show (moduleUnitId m)
-                 <> ", name = " <> show (moduleName m) 
-                 <> " }"
-
-instance Hashable StableModule where
-  hashWithSalt s (StableModule mdl) = hashWithSalt s (moduleStableString mdl)
-
-instance Ord StableModule where
-  (StableModule m1) `compare` (StableModule m2) = stableModuleCmp m1 m2
-
-instance Eq StableModule where
-  (StableModule m1) == (StableModule m2) = (m1 `stableModuleCmp` m2) == EQ
-
-instance Show StableModule where
-    show (StableModule mdl) = "Stable" ++ renderModule mdl
-
-instance Binary StableModule where
-
-    put (StableModule mdl) = do
-      put (unitIdString . moduleUnitId $ mdl)
-      put (moduleNameString . moduleName $ mdl)
-
-    get = do
-      uidStr <- get
-      mnStr  <- get
-      pure $ StableModule (Module (stringToUnitId uidStr) (mkModuleName mnStr))
-
--- | The /target/ dependencies that concur to the creation of a 'TargetSpec' and a 'LiftedSpec'.
-newtype TargetDependencies =
-  TargetDependencies { getDependencies :: HashMap StableModule LiftedSpec }
-  deriving (Eq, Show, Semigroup, Monoid, Generic)
-  deriving Binary via Generically TargetDependencies
-
--- | Drop the given 'StableModule' from the dependencies.
-dropDependency :: StableModule -> TargetDependencies -> TargetDependencies
-dropDependency sm (TargetDependencies deps) = TargetDependencies (M.delete sm deps)
-
--- $predicates
-
--- | Returns 'True' if the input 'Var' is a /PLE/ one.
-isPLEVar :: TargetSpec -> Var -> Bool 
-isPLEVar sp x = M.member x (gsAutoInst (gsRefl sp)) 
-
--- | Returns 'True' if the input 'Var' was exported in the module the input 'TargetSrc' represents.
-isExportedVar :: TargetSrc -> Var -> Bool
-isExportedVar src v = mkStableName n `S.member` ns
-  where
-    n                = getName v
-    ns               = gsExports src
-
---
--- $legacyDataStructures
---
-{- 
-data GhcInfo = GI
-  { _giSrc       :: !GhcSrc  
-  , _giSpec      :: !GhcSpec               -- ^ All specification information for module
-  }
--}
-
-data GhcSrc = Src 
-  { _giIncDir    :: !FilePath              -- ^ Path for LH include/prelude directory
-  , _giTarget    :: !FilePath              -- ^ Source file for module
-  , _giTargetMod :: !ModName               -- ^ Name for module
-  , _giCbs       :: ![CoreBind]            -- ^ Source Code
-  , _gsTcs       :: ![TyCon]               -- ^ All used Type constructors
-  , _gsCls       :: !(Maybe [ClsInst])     -- ^ Class instances?
-  , _giDerVars   :: !(S.HashSet Var)       -- ^ Binders created by GHC eg dictionaries
-  , _giImpVars   :: ![Var]                 -- ^ Binders that are _read_ in module (but not defined?)
-  , _giDefVars   :: ![Var]                 -- ^ (Top-level) binders that are _defined_ in module
-  , _giUseVars   :: ![Var]                 -- ^ Binders that are _read_ in module
-  , _gsExports   :: !(HashSet StableName)  -- ^ `Name`s exported by the module being verified
-  , _gsFiTcs     :: ![TyCon]               -- ^ Family instance TyCons 
-  , _gsFiDcs     :: ![(F.Symbol, DataCon)] -- ^ Family instance DataCons 
-  , _gsPrimTcs   :: ![TyCon]               -- ^ Primitive GHC TyCons (from TysPrim.primTyCons)
-  , _gsQualImps  :: !QImports              -- ^ Map of qualified imports
-  , _gsAllImps   :: !(S.HashSet F.Symbol)  -- ^ Set of _all_ imported modules
-  , _gsTyThings  :: ![TyThing]             -- ^ All the @TyThing@s known to GHC
-  }
-
-data GhcSpec = SP 
-  { _gsSig    :: !GhcSpecSig  
-  , _gsQual   :: !GhcSpecQual 
-  , _gsData   :: !GhcSpecData 
-  , _gsName   :: !GhcSpecNames 
-  , _gsVars   :: !GhcSpecVars 
-  , _gsTerm   :: !GhcSpecTerm 
-  , _gsRefl   :: !GhcSpecRefl   
-  , _gsLaws   :: !GhcSpecLaws 
-  , _gsImps   :: ![(F.Symbol, F.Sort)]  -- ^ Imported Environment
-  , _gsConfig :: !Config
-  , _gsLSpec  :: !(Spec LocBareType F.LocSymbol) -- ^ Lifted specification for the target module
-  }
-
-instance HasConfig GhcSpec where
-  getConfig = _gsConfig
-
-{- 
-instance HasConfig GhcInfo where
-  getConfig = getConfig . _giSpec
--}
-
-{- $provisionalBackCompat
-
-In order to smooth out the migration process to this API, here we provide some /compat/ 'Iso' and 'Prism'
-to convert from/to the old data structures, so that migration can be done organically over time.
--}
-
-targetSrcIso :: Iso' GhcSrc TargetSrc
-targetSrcIso = iso toTargetSrc fromTargetSrc
-  where
-    toTargetSrc a = TargetSrc
-      { giIncDir    = _giIncDir a
-      , giTarget    = _giTarget a
-      , giTargetMod = _giTargetMod a
-      , giCbs       = _giCbs a
-      , gsTcs       = _gsTcs a
-      , gsCls       = _gsCls a
-      , giDerVars   = _giDerVars a
-      , giImpVars   = _giImpVars a
-      , giDefVars   = _giDefVars a
-      , giUseVars   = _giUseVars a
-      , gsExports   = _gsExports a
-      , gsFiTcs     = _gsFiTcs a
-      , gsFiDcs     = _gsFiDcs a
-      , gsPrimTcs   = _gsPrimTcs a
-      , gsQualImps  = _gsQualImps a
-      , gsAllImps   = _gsAllImps a
-      , gsTyThings  = _gsTyThings a
-      }
-
-    fromTargetSrc a = Src
-      { _giIncDir    = giIncDir a
-      , _giTarget    = giTarget a
-      , _giTargetMod = giTargetMod a
-      , _giCbs       = giCbs a
-      , _gsTcs       = gsTcs a
-      , _gsCls       = gsCls a
-      , _giDerVars   = giDerVars a
-      , _giImpVars   = giImpVars a
-      , _giDefVars   = giDefVars a
-      , _giUseVars   = giUseVars a
-      , _gsExports   = gsExports a
-      , _gsFiTcs     = gsFiTcs a
-      , _gsFiDcs     = gsFiDcs a
-      , _gsPrimTcs   = gsPrimTcs a
-      , _gsQualImps  = gsQualImps a
-      , _gsAllImps   = gsAllImps a
-      , _gsTyThings  = gsTyThings a
-      }
-
-targetSpecGetter :: Getter GhcSpec (TargetSpec, LiftedSpec)
-targetSpecGetter = 
-  to (\ghcSpec -> (toTargetSpec ghcSpec, view (to _gsLSpec % liftedSpecGetter) ghcSpec))
-  where
-    toTargetSpec a = TargetSpec
-      { gsSig    = _gsSig a
-      , gsQual   = _gsQual a
-      , gsData   = _gsData a
-      , gsName   = _gsName a
-      , gsVars   = _gsVars a
-      , gsTerm   = _gsTerm a
-      , gsRefl   = _gsRefl a
-      , gsLaws   = _gsLaws a
-      , gsImps   = _gsImps a
-      , gsConfig = _gsConfig a
-      }
-
-bareSpecIso :: Iso' (Spec LocBareType F.LocSymbol) BareSpec
-bareSpecIso = iso MkBareSpec getBareSpec
-
-liftedSpecGetter :: Getter (Spec LocBareType F.LocSymbol) LiftedSpec
-liftedSpecGetter = to toLiftedSpec
-  where
-    toLiftedSpec a = LiftedSpec 
-      { liftedMeasures   = S.fromList . measures $ a
-      , liftedImpSigs    = S.fromList . impSigs  $ a
-      , liftedExpSigs    = S.fromList . expSigs  $ a
-      , liftedAsmSigs    = S.fromList . asmSigs  $ a
-      , liftedSigs       = S.fromList . sigs     $ a
-      , liftedInvariants = S.fromList . invariants $ a
-      , liftedIaliases   = S.fromList . ialiases $ a
-      , liftedImports    = S.fromList . imports $ a
-      , liftedDataDecls  = S.fromList . dataDecls $ a
-      , liftedNewtyDecls = S.fromList . newtyDecls $ a
-      , liftedAliases    = S.fromList . aliases $ a
-      , liftedEaliases   = S.fromList . ealiases $ a
-      , liftedEmbeds     = embeds a
-      , liftedQualifiers = S.fromList . qualifiers $ a
-      , liftedDecr       = S.fromList . decr $ a
-      , liftedLvars      = lvars a
-      , liftedAutois     = autois a
-      , liftedAutosize   = autosize a
-      , liftedCmeasures  = S.fromList . cmeasures $ a
-      , liftedImeasures  = S.fromList . imeasures $ a
-      , liftedClasses    = S.fromList . classes $ a
-      , liftedClaws      = S.fromList . claws $ a
-      , liftedRinstance  = S.fromList . rinstance $ a
-      , liftedIlaws      = S.fromList . ilaws $ a
-      , liftedDvariance  = S.fromList . dvariance $ a
-      , liftedBounds     = bounds a
-      , liftedDefs       = defs a
-      , liftedAxeqs      = S.fromList . axeqs $ a
-      }
-
--- This is a temporary internal function that we use to convert the input dependencies into a format
--- suitable for 'makeGhcSpec'.
-unsafeFromLiftedSpec :: LiftedSpec -> Spec LocBareType F.LocSymbol
-unsafeFromLiftedSpec a = Spec
-  { measures   = S.toList . liftedMeasures $ a
-  , impSigs    = S.toList . liftedImpSigs $ a
-  , expSigs    = S.toList . liftedExpSigs $ a
-  , asmSigs    = S.toList . liftedAsmSigs $ a
-  , sigs       = S.toList . liftedSigs $ a
-  , localSigs  = mempty
-  , reflSigs   = mempty
-  , invariants = S.toList . liftedInvariants $ a
-  , ialiases   = S.toList . liftedIaliases $ a
-  , imports    = S.toList . liftedImports $ a
-  , dataDecls  = S.toList . liftedDataDecls $ a
-  , newtyDecls = S.toList . liftedNewtyDecls $ a
-  , includes   = mempty
-  , aliases    = S.toList . liftedAliases $ a
-  , ealiases   = S.toList . liftedEaliases $ a
-  , embeds     = liftedEmbeds a
-  , qualifiers = S.toList . liftedQualifiers $ a
-  , decr       = S.toList . liftedDecr $ a
-  , lvars      = liftedLvars a
-  , lazy       = mempty
-  , fails      = mempty
-  , rewrites   = mempty
-  , rewriteWith = mempty
-  , reflects   = mempty
-  , autois     = liftedAutois a
-  , hmeas      = mempty
-  , hbounds    = mempty
-  , inlines    = mempty
-  , ignores    = mempty
-  , autosize   = liftedAutosize a
-  , pragmas    = mempty
-  , cmeasures  = S.toList . liftedCmeasures $ a
-  , imeasures  = S.toList . liftedImeasures $ a
-  , classes    = S.toList . liftedClasses $ a
-  , claws      = S.toList . liftedClaws $ a
-  , termexprs  = mempty
-  , rinstance  = S.toList . liftedRinstance $ a
-  , ilaws      = S.toList . liftedIlaws $ a
-  , dvariance  = S.toList . liftedDvariance $ a
-  , bounds     = liftedBounds a
-  , defs       = liftedDefs a
-  , axeqs      = S.toList . liftedAxeqs $ a
-  }
diff --git a/src/Language/Haskell/Liquid/Types/Types.hs b/src/Language/Haskell/Liquid/Types/Types.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Types.hs
+++ /dev/null
@@ -1,2447 +0,0 @@
-{-# LANGUAGE StandaloneDeriving         #-}
-{-# LANGUAGE DeriveDataTypeable         #-}
-{-# LANGUAGE DeriveFunctor              #-}
-{-# LANGUAGE DeriveFoldable             #-}
-{-# LANGUAGE DeriveGeneric              #-}
-{-# LANGUAGE DeriveTraversable          #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE MultiParamTypeClasses      #-}
-{-# LANGUAGE TypeSynonymInstances       #-}
-{-# LANGUAGE FlexibleInstances          #-}
-{-# LANGUAGE FlexibleContexts           #-}
-{-# LANGUAGE UndecidableInstances       #-}
-{-# LANGUAGE OverloadedStrings          #-}
-{-# LANGUAGE RecordWildCards            #-}
-{-# LANGUAGE ConstraintKinds            #-}
-{-# LANGUAGE BangPatterns               #-}
-{-# LANGUAGE TupleSections              #-}
-{-# LANGUAGE DerivingStrategies         #-}
-{-# LANGUAGE DerivingVia                #-}
-
--- | This module should contain all the global type definitions and basic instances.
-
-module Language.Haskell.Liquid.Types.Types (
-
-  -- * Options
-    module Language.Haskell.Liquid.UX.Config
-
-  -- * Ghc Information
-  , TargetVars   (..)
-  , TyConMap     (..)
-
-  -- * F.Located Things
-  , F.Located (..)
-  , F.dummyLoc
-
-  -- * Symbols
-  , F.LocSymbol
-  , F.LocText
-
-  -- * Default unknown name
-  , F.dummyName
-  , F.isDummy
-
-  -- * Bare Type Constructors and Variables
-  , BTyCon(..)
-  , mkBTyCon
-  -- , mkClassBTyCon, mkPromotedBTyCon
-  , isClassBTyCon
-  , BTyVar(..)
-
-  -- * Refined Type Constructors
-  , RTyCon (RTyCon, rtc_tc, rtc_info)
-  , TyConInfo(..), defaultTyConInfo
-  , rTyConPVs
-  , rTyConPropVs
-  -- , isClassRTyCon
-  , isClassType, isEqType, isRVar, isBool
-
-  -- * Refinement Types
-  , RType (..), Ref(..), RTProp, rPropP
-  , RTyVar (..)
-  , RTAlias (..)
-  , OkRT
-  , lmapEAlias
-  , dropImplicits
-
-  -- * Worlds
-  , HSeg (..)
-  , World (..)
-
-  -- * Classes describing operations on `RTypes`
-  , TyConable (..)
-  , SubsTy (..)
-
-  -- * Type Variables
-  , RTVar (..), RTVInfo (..)
-  , makeRTVar, mapTyVarValue
-  , dropTyVarInfo, rTVarToBind
-  , setRtvPol
-
-  -- * Predicate Variables
-  , PVar (PV, pname, parg, ptype, pargs), isPropPV, pvType
-  , PVKind (..)
-  , Predicate (..)
-
-  -- * Refinements
-  , UReft(..)
-
-  -- * Parse-time entities describing refined data types
-  , SizeFun  (..), szFun
-  , DataDecl (..)
-  , DataName (..), dataNameSymbol
-  , DataCtor (..)
-  , DataConP (..)
-  , HasDataDecl (..), hasDecl
-  , DataDeclKind (..)
-  , TyConP   (..)
-
-  -- * Pre-instantiated RType
-  , RRType, RRProp
-  , BRType, BRProp
-  , BSort, BPVar
-  , RTVU, PVU
-
-  -- * Instantiated RType
-  , BareType, PrType
-  , SpecType, SpecProp, SpecRTVar
-  , SpecRep
-  , LocBareType, LocSpecType
-  , RSort
-  , UsedPVar, RPVar, RReft
-  , REnv
-  , AREnv (..)
-
-  -- * Constructing & Destructing RTypes
-  , RTypeRep(..), fromRTypeRep, toRTypeRep
-  , mkArrow, bkArrowDeep, bkArrow, safeBkArrow
-  , mkUnivs, bkUniv, bkClass, bkUnivClass
-  , rImpF, rFun, rCls, rRCls
-
-  -- * Manipulating `Predicates`
-  , pvars, pappSym, pApp
-
-  -- * Some tests on RTypes
-  , isBase
-  , isFunTy
-  , isTrivial
-  , hasHole 
-
-  -- * Traversing `RType`
-  , efoldReft, foldReft, foldReft'
-  , emapReft, mapReft, mapReftM, mapPropM
-  , mapExprReft
-  , mapBot, mapBind
-  , foldRType
-
-
-  -- * ???
-  , Oblig(..)
-  , ignoreOblig
-  , addInvCond
-
-  -- * Inferred Annotations
-  , AnnInfo (..)
-  , Annot (..)
-
-  -- * Hole Information 
-  , HoleInfo(..)
-
-  -- * Overall Output
-  , Output (..)
-
-  -- * Refinement Hole
-  , hole, isHole, hasHoleTy
-
-  -- * Converting To and From Sort
-  , ofRSort, toRSort
-  , rTypeValueVar
-  , rTypeReft
-  , stripRTypeBase
-  , topRTypeBase
-
-  -- * Class for values that can be pretty printed
-  , F.PPrint (..)
-  , F.pprint
-  , F.showpp
-
-  -- * Printer Configuration
-  , PPEnv (..)
-  , ppEnv
-  , ppEnvShort
-
-  -- * Modules and Imports
-  , ModName (..), ModType (..)
-  , isSrcImport, isSpecImport, isTarget
-  , getModName, getModString, qualifyModName
-
-  -- * Refinement Type Aliases
-  , RTEnv (..), BareRTEnv, SpecRTEnv, BareRTAlias, SpecRTAlias
-  -- , mapRT, mapRE
-
-  -- * Diagnostics, Warnings, Errors and Error Messages
-  , module Language.Haskell.Liquid.Types.Errors
-  , Error
-  , ErrorResult
-  , Warning
-  , mkWarning
-  , Diagnostics
-  , mkDiagnostics
-  , emptyDiagnostics
-  , noErrors
-  , allWarnings
-  , allErrors
-  , printWarning
-
-  -- * Source information (associated with constraints)
-  , Cinfo (..)
-
-  -- * Measures
-  , Measure (..)
-  , UnSortedExprs, UnSortedExpr
-  , MeasureKind (..)
-  , CMeasure (..)
-  , Def (..)
-  , Body (..)
-  , MSpec (..)
-  
-  -- * Scoping Info
-  , BScope
-
-  -- * Type Classes
-  , RClass (..)
-
-  -- * KV Profiling
-  , KVKind (..)   -- types of kvars
-  , KVProf        -- profile table
-  , emptyKVProf   -- empty profile
-  , updKVProf     -- extend profile
-
-  -- * Misc
-  , mapRTAVars
-  , insertsSEnv
-
-  -- * CoreToLogic
-  , LogicMap(..), toLogicMap, eAppWithMap, LMap(..)
-
-  -- * Refined Instances
-  , RDEnv, DEnv(..), RInstance(..), RISig(..), RILaws(..)
-  , MethodType(..), getMethodType
-
-  -- * Ureftable Instances
-  , UReftable(..)
-
-  -- * String Literals
-  , liquidBegin, liquidEnd
-
-  , Axiom(..), HAxiom
-
-  -- , rtyVarUniqueSymbol, tyVarUniqueSymbol
-  , rtyVarType, tyVarVar
-  )
-  where
-
-import           Language.Haskell.Liquid.GHC.API hiding (Expr, Target, isFunTy, LM)
-import           Data.String
-import           GHC.Generics
-import           PrelInfo                               (isNumericClass)
-import           Prelude                          hiding  (error)
-import qualified Prelude
-import           TyCon
-
-import           Control.Monad                          (liftM, liftM2, liftM3, liftM4)
-import           Control.DeepSeq
-import           Data.Bifunctor
-import           Data.Typeable                          (Typeable)
-import           Data.Generics                          (Data)
-import qualified Data.Binary                            as B
-import qualified Data.Foldable                          as F
-import           Data.Hashable
-import qualified Data.HashMap.Strict                    as M
-import qualified Data.HashSet                           as S
-import qualified Data.List                              as L
-import           Data.Maybe                             (fromMaybe, mapMaybe)
-import           Data.Function                          (on)
-import           Data.List                              as L (foldl', nub, null)
-import           Data.Text                              (Text)
-import           Text.PrettyPrint.HughesPJ              hiding (first, (<>)) 
-import           Text.Printf
-import           Language.Fixpoint.Misc
-
-import qualified Language.Fixpoint.Types as F
-
-import           Language.Haskell.Liquid.Types.Generics
-import           Language.Haskell.Liquid.GHC.Misc
-import           Language.Haskell.Liquid.GHC.Logging as GHC
-import           Language.Haskell.Liquid.Types.Variance
-import           Language.Haskell.Liquid.Types.Errors
-import           Language.Haskell.Liquid.Misc
-import           Language.Haskell.Liquid.UX.Config
-import           Data.Default
-
-
------------------------------------------------------------------------------
--- | Information about scope Binders Scope in
------------------------------------------------------------------------------
-{- In types with base refinement, e.g., {out:T {inner:a | ri} | ro }
-If BScope = True , then the outer binder out is     in scope on ri
-If BScope = False, then the outer binder out is not in scope on ri
--}
-
-type BScope = Bool    
------------------------------------------------------------------------------
--- | Information about Type Constructors
------------------------------------------------------------------------------
-data TyConMap = TyConMap 
-  { tcmTyRTy    :: M.HashMap TyCon             RTyCon  -- ^ Map from GHC TyCon to RTyCon 
-  , tcmFIRTy    :: M.HashMap (TyCon, [F.Sort]) RTyCon  -- ^ Map from GHC Family-Instances to RTyCon
-  , tcmFtcArity :: M.HashMap TyCon             Int     -- ^ Arity of each Family-Tycon 
-  }
- 
-
------------------------------------------------------------------------------
--- | Printer ----------------------------------------------------------------
------------------------------------------------------------------------------
-
-data PPEnv = PP 
-  { ppPs    :: Bool -- ^ print abstract-predicates 
-  , ppTyVar :: Bool -- ^ print the unique suffix for each tyvar
-  , ppShort :: Bool -- ^ print the tycons without qualification 
-  , ppDebug :: Bool -- ^ gross with full info
-  }
-  deriving (Show)
-
-ppEnv :: PPEnv
-ppEnv = ppEnvDef 
-          { ppPs    = True }   
-          { ppDebug = True }   -- RJ: needed for resolution, because pp is used for serialization?
-
-{- | [NOTE:ppEnv] For some mysterious reason, `ppDebug` must equal `True`
-     or various tests fail e.g. tests/classes/pos/TypeEquality0{0,1}.hs
-     Yikes. Find out why!
- -}
-
-ppEnvDef :: PPEnv
-ppEnvDef = PP False False False False
-
-ppEnvShort :: PPEnv -> PPEnv
-ppEnvShort pp = pp { ppShort = True }
-
-------------------------------------------------------------------
--- Huh?
-------------------------------------------------------------------
-type Expr      = F.Expr
-type Symbol    = F.Symbol
-
-
--- [NOTE:LIFTED-VAR-SYMBOLS]: Following NOTE:REFLECT-IMPORTS, by default
--- each (lifted) `Var` is mapped to its `Symbol` via the `Symbolic Var`
--- instance. For _generated_ vars, we may want a custom name e.g. see
---   tests/pos/NatClass.hs
--- and we maintain that map in `lmVarSyms` with the `Just s` case.
--- Ideally, this bandaid should be replaced so we don't have these
--- hacky corner cases.
-
-data LogicMap = LM
-  { lmSymDefs  :: M.HashMap Symbol LMap        -- ^ Map from symbols to equations they define
-  , lmVarSyms  :: M.HashMap Var (Maybe Symbol) -- ^ Map from (lifted) Vars to `Symbol`; see:
-                                              --   NOTE:LIFTED-VAR-SYMBOLS and NOTE:REFLECT-IMPORTs
-  } deriving (Show)
-
-instance Monoid LogicMap where
-  mempty  = LM M.empty M.empty
-  mappend = (<>)
-
-instance Semigroup LogicMap where
-  LM x1 x2 <> LM y1 y2 = LM (M.union x1 y1) (M.union x2 y2)
-
-data LMap = LMap
-  { lmVar  :: F.LocSymbol
-  , lmArgs :: [Symbol]
-  , lmExpr :: Expr
-  }
-
-instance Show LMap where
-  show (LMap x xs e) = show x ++ " " ++ show xs ++ "\t |-> \t" ++ show e
-
-toLogicMap :: [(F.LocSymbol, [Symbol], Expr)] -> LogicMap
-toLogicMap ls = mempty {lmSymDefs = M.fromList $ map toLMap ls}
-  where
-    toLMap (x, ys, e) = (F.val x, LMap {lmVar = x, lmArgs = ys, lmExpr = e})
-
-eAppWithMap :: LogicMap -> F.Located Symbol -> [Expr] -> Expr -> Expr
-eAppWithMap lmap f es def
-  | Just (LMap _ xs e) <- M.lookup (F.val f) (lmSymDefs lmap)
-  , length xs == length es
-  = F.subst (F.mkSubst $ zip xs es) e
-  | Just (LMap _ xs e) <- M.lookup (F.val f) (lmSymDefs lmap)
-  , isApp e
-  = F.subst (F.mkSubst $ zip xs es) $ dropApp e (length xs - length es)
-  | otherwise
-  = def
-
-dropApp :: Expr -> Int -> Expr
-dropApp e i | i <= 0 = e
-dropApp (F.EApp e _) i = dropApp e (i-1)
-dropApp _ _          = errorstar "impossible"
-
-isApp :: Expr -> Bool
-isApp (F.EApp (F.EVar _) (F.EVar _)) = True
-isApp (F.EApp e (F.EVar _))          = isApp e
-isApp _                              = False
-
-data TyConP = TyConP
-  { tcpLoc          :: !F.SourcePos
-  , tcpCon          :: !TyCon
-  , tcpFreeTyVarsTy :: ![RTyVar]
-  , tcpFreePredTy   :: ![PVar RSort]
-  , tcpVarianceTs   :: !VarianceInfo
-  , tcpVariancePs   :: !VarianceInfo
-  , tcpSizeFun      :: !(Maybe SizeFun)
-  } deriving (Generic, Data, Typeable)
-
-instance F.Loc TyConP where
-  srcSpan tc = F.SS (tcpLoc tc) (tcpLoc tc)
-
-
--- TODO: just use Located instead of dc_loc, dc_locE
-data DataConP = DataConP
-  { dcpLoc        :: !F.SourcePos
-  , dcpCon        :: !DataCon                -- ^ Corresponding GHC DataCon 
-  , dcpFreeTyVars :: ![RTyVar]               -- ^ Type parameters
-  , dcpFreePred   :: ![PVar RSort]           -- ^ Abstract Refinement parameters
-  , dcpTyConstrs  :: ![SpecType]             -- ^ ? Class constraints (via `dataConStupidTheta`)
-  , dcpTyArgs     :: ![(Symbol, SpecType)]   -- ^ Value parameters
-  , dcpTyRes      :: !SpecType               -- ^ Result type
-  -- , tyData     :: !SpecType               -- ^ The 'generic' ADT, see [NOTE:DataCon-Data]
-  , dcpIsGadt     :: !Bool                   -- ^ Was this specified in GADT style (if so, DONT use function names as fields)
-  , dcpModule     :: !F.Symbol               -- ^ Which module was this defined in
-  , dcpLocE       :: !F.SourcePos
-  } deriving (Generic, Data, Typeable)
-
--- | [NOTE:DataCon-Data] for each 'DataConP' we also
---   store the type of the constructed data. This is
---   *the same as* 'tyRes' for *vanilla* ADTs
---   (e.g. List, Maybe etc.) but may differ for GADTs.
---   For example,
---
---      data Thing a where
---        X  :: Thing Int
---        Y  :: Thing Bool
---
---   Here the 'DataConP' associated with 'X' (resp. 'Y')
---   has 'tyRes' corresponding to 'Thing Int' (resp. 'Thing Bool'),
---   but in both cases, the 'tyData' should be 'Thing a'.
---
-
-instance F.Loc DataConP where
-  srcSpan d = F.SS (dcpLoc d) (dcpLocE d)
-
--- | Which Top-Level Binders Should be Verified
-data TargetVars = AllVars | Only ![Var]
-
-
---------------------------------------------------------------------
--- | Abstract Predicate Variables ----------------------------------
---------------------------------------------------------------------
-
-data PVar t = PV
-  { pname :: !Symbol
-  , ptype :: !(PVKind t)
-  , parg  :: !Symbol
-  , pargs :: ![(t, Symbol, Expr)]
-  } deriving (Generic, Data, Typeable, Show, Functor)
-
-instance Eq (PVar t) where
-  pv == pv' = pname pv == pname pv' {- UNIFY: What about: && eqArgs pv pv' -}
-
-instance Ord (PVar t) where
-  compare (PV n _ _ _)  (PV n' _ _ _) = compare n n'
-
-instance B.Binary t => B.Binary (PVar t)
-instance NFData t   => NFData   (PVar t)
-
-instance Hashable (PVar a) where
-  hashWithSalt i (PV n _ _ _) = hashWithSalt i n
-
-pvType :: PVar t -> t
-pvType p = case ptype p of
-             PVProp t -> t
-             PVHProp  -> panic Nothing "pvType on HProp-PVar"
-
-data PVKind t
-  = PVProp t
-  | PVHProp
-  deriving (Generic, Data, Typeable, Functor, F.Foldable, Traversable, Show)
-
-instance B.Binary a => B.Binary (PVKind a)
-instance NFData a   => NFData   (PVKind a)
-
-
---------------------------------------------------------------------------------
--- | Predicates ----------------------------------------------------------------
---------------------------------------------------------------------------------
-
-type UsedPVar      = PVar ()
-
-newtype Predicate  = Pr [UsedPVar] 
-  deriving (Generic, Data, Typeable)
-  deriving Hashable via Generically Predicate
-
-instance Eq Predicate where
-  (Pr vs) == (Pr ws)
-      = and $ (length vs' == length ws') : [v == w | (v, w) <- zip vs' ws']
-        where
-          vs' = L.sort vs
-          ws' = L.sort ws
-
-
-
-instance B.Binary Predicate
-
-instance NFData Predicate where
-  rnf _ = ()
-
-instance Monoid Predicate where
-  mempty  = pdTrue
-  mappend = (<>)
-
-instance Semigroup Predicate where
-  p <> p' = pdAnd [p, p']
-
-instance Semigroup a => Semigroup (UReft a) where
-  MkUReft x y <> MkUReft x' y' = MkUReft (x <> x') (y <> y')
-
-instance (Monoid a) => Monoid (UReft a) where
-  mempty  = MkUReft mempty mempty
-  mappend = (<>)
-
-
-pdTrue :: Predicate
-pdTrue         = Pr []
-
-pdAnd :: Foldable t => t Predicate -> Predicate
-pdAnd ps       = Pr (nub $ concatMap pvars ps)
-
-pvars :: Predicate -> [UsedPVar]
-pvars (Pr pvs) = pvs
-
-instance F.Subable UsedPVar where
-  syms pv         = [ y | (_, x, F.EVar y) <- pargs pv, x /= y ]
-  subst s pv      = pv { pargs = mapThd3 (F.subst s)  <$> pargs pv }
-  substf f pv     = pv { pargs = mapThd3 (F.substf f) <$> pargs pv }
-  substa f pv     = pv { pargs = mapThd3 (F.substa f) <$> pargs pv }
-
-
-instance F.Subable Predicate where
-  syms     (Pr pvs) = concatMap F.syms   pvs
-  subst  s (Pr pvs) = Pr (F.subst s  <$> pvs)
-  substf f (Pr pvs) = Pr (F.substf f <$> pvs)
-  substa f (Pr pvs) = Pr (F.substa f <$> pvs)
-
-instance NFData r => NFData (UReft r)
-
-
-newtype BTyVar = BTV Symbol deriving (Show, Generic, Data, Typeable)
-
-newtype RTyVar = RTV TyVar deriving (Generic, Data, Typeable)
-
-instance Eq BTyVar where
-  (BTV x) == (BTV y) = x == y
-
-instance Ord BTyVar where
-  compare (BTV x) (BTV y) = compare x y
-
-instance IsString BTyVar where
-  fromString = BTV . fromString
-
-instance B.Binary BTyVar
-instance Hashable BTyVar
-instance NFData   BTyVar
-instance NFData   RTyVar
-
-instance F.Symbolic BTyVar where
-  symbol (BTV tv) = tv
-
-instance F.Symbolic RTyVar where
-  symbol (RTV tv) = F.symbol tv -- tyVarUniqueSymbol tv
-
--- instance F.Symbolic RTyVar where
-  -- symbol (RTV tv) = F.symbol . getName $ tv
--- rtyVarUniqueSymbol  :: RTyVar -> Symbol
--- rtyVarUniqueSymbol (RTV tv) = tyVarUniqueSymbol tv
--- tyVarUniqueSymbol :: TyVar -> Symbol
--- tyVarUniqueSymbol tv = F.symbol $ show (getName tv) ++ "_" ++ show (varUnique tv)
-
-data BTyCon = BTyCon
-  { btc_tc    :: !F.LocSymbol    -- ^ TyCon name with location information
-  , btc_class :: !Bool           -- ^ Is this a class type constructor?
-  , btc_prom  :: !Bool           -- ^ Is Promoted Data Con?
-  }
-  deriving (Generic, Data, Typeable)
-  deriving Hashable via Generically BTyCon
-
-instance B.Binary BTyCon
-
-data RTyCon = RTyCon
-  { rtc_tc    :: TyCon         -- ^ GHC Type Constructor
-  , rtc_pvars :: ![RPVar]      -- ^ Predicate Parameters
-  , rtc_info  :: !TyConInfo    -- ^ TyConInfo
-  }
-  deriving (Generic, Data, Typeable)
-
-instance F.Symbolic RTyCon where
-  symbol = F.symbol . rtc_tc 
-
-instance F.Symbolic BTyCon where
-  symbol = F.val . btc_tc
-
-instance NFData BTyCon
-
-instance NFData RTyCon
-
-rtyVarType :: RTyVar -> Type
-rtyVarType (RTV v) = TyVarTy v
-
-tyVarVar :: RTVar RTyVar c -> Var
-tyVarVar (RTVar (RTV v) _) = v
-
-
-
-mkBTyCon :: F.LocSymbol -> BTyCon
-mkBTyCon x = BTyCon x False False
-
-
--- | Accessors for @RTyCon@
-
-isBool :: RType RTyCon t t1 -> Bool
-isBool (RApp (RTyCon{rtc_tc = c}) _ _ _) = c == boolTyCon
-isBool _                                 = False
-
-isRVar :: RType c tv r -> Bool
-isRVar (RVar _ _) = True
-isRVar _          = False
-
-isClassBTyCon :: BTyCon -> Bool
-isClassBTyCon = btc_class
-
--- isClassRTyCon :: RTyCon -> Bool
--- isClassRTyCon x = (isClassTyCon $ rtc_tc x) || (rtc_tc x == eqPrimTyCon)
-
-rTyConPVs :: RTyCon -> [RPVar]
-rTyConPVs     = rtc_pvars
-
-rTyConPropVs :: RTyCon -> [PVar RSort]
-rTyConPropVs  = filter isPropPV . rtc_pvars
-
-isPropPV :: PVar t -> Bool
-isPropPV      = isProp . ptype
-
-isEqType :: TyConable c => RType c t t1 -> Bool
-isEqType (RApp c _ _ _) = isEqual c
-isEqType _              = False
-
-
-isClassType :: TyConable c => RType c t t1 -> Bool
-isClassType (RApp c _ _ _) = isClass c
-isClassType _              = False
-
--- rTyConPVHPs = filter isHPropPV . rtc_pvars
--- isHPropPV   = not . isPropPV
-
-isProp :: PVKind t -> Bool
-isProp (PVProp _) = True
-isProp _          = False
-
-
-defaultTyConInfo :: TyConInfo
-defaultTyConInfo = TyConInfo [] [] Nothing
-
-instance Default TyConInfo where
-  def = defaultTyConInfo
-
-
------------------------------------------------------------------------
--- | Co- and Contra-variance for TyCon --------------------------------
------------------------------------------------------------------------
-
--- | Indexes start from 0 and type or predicate arguments can be both
---   covariant and contravaariant e.g., for the below Foo dataType
---
---     data Foo a b c d <p :: b -> Prop, q :: Int -> Prop, r :: a -> Prop>
---       = F (a<r> -> b<p>) | Q (c -> a) | G (Int<q> -> a<r>)
---
---  there will be:
---
---    varianceTyArgs     = [Bivariant , Covariant, Contravatiant, Invariant]
---    variancePsArgs     = [Covariant, Contravatiant, Bivariant]
---
-
-data TyConInfo = TyConInfo
-  { varianceTyArgs  :: !VarianceInfo      -- ^ variance info for type variables
-  , variancePsArgs  :: !VarianceInfo      -- ^ variance info for predicate variables
-  , sizeFunction    :: !(Maybe SizeFun)   -- ^ logical UNARY function that computes the size of the structure
-  } deriving (Generic, Data, Typeable)
-
-instance NFData TyConInfo
-
-instance Show TyConInfo where
-  show (TyConInfo x y _) = show x ++ "\n" ++ show y
-
---------------------------------------------------------------------------------
--- | Unified Representation of Refinement Types --------------------------------
---------------------------------------------------------------------------------
-
-type RTVU c tv = RTVar tv (RType c tv ())
-type PVU  c tv = PVar     (RType c tv ())
-
-instance Show tv => Show (RTVU c tv) where
-  show (RTVar t _) = show t
-
-data RType c tv r
-  = RVar {
-      rt_var    :: !tv
-    , rt_reft   :: !r
-    }
-
-  | RFun  {
-      rt_bind   :: !Symbol
-    , rt_in     :: !(RType c tv r)
-    , rt_out    :: !(RType c tv r)
-    , rt_reft   :: !r
-    }
-
-  | RImpF  {
-      rt_bind   :: !Symbol
-    , rt_in     :: !(RType c tv r)
-    , rt_out    :: !(RType c tv r)
-    , rt_reft   :: !r
-    }
-
-  | RAllT {
-      rt_tvbind :: !(RTVU c tv) -- RTVar tv (RType c tv ()))
-    , rt_ty     :: !(RType c tv r)
-    , rt_ref    :: !r
-    }
-
-  -- | "forall x y <z :: Nat, w :: Int> . TYPE"
-  --               ^^^^^^^^^^^^^^^^^^^ (rt_pvbind)
-  | RAllP {
-      rt_pvbind :: !(PVU c tv)  -- ar (RType c tv ()))
-    , rt_ty     :: !(RType c tv r)
-    }
-
-  -- | For example, in [a]<{\h -> v > h}>, we apply (via `RApp`)
-  --   * the `RProp`  denoted by `{\h -> v > h}` to
-  --   * the `RTyCon` denoted by `[]`.
-  | RApp  {
-      rt_tycon  :: !c
-    , rt_args   :: ![RType  c tv r]
-    , rt_pargs  :: ![RTProp c tv r]
-    , rt_reft   :: !r
-    }
-
-  | RAllE {
-      rt_bind   :: !Symbol
-    , rt_allarg :: !(RType c tv r)
-    , rt_ty     :: !(RType c tv r)
-    }
-
-  | REx {
-      rt_bind   :: !Symbol
-    , rt_exarg  :: !(RType c tv r)
-    , rt_ty     :: !(RType c tv r)
-    }
-
-  | RExprArg (F.Located Expr)                   -- ^ For expression arguments to type aliases
-                                                --   see tests/pos/vector2.hs
-  | RAppTy{
-      rt_arg   :: !(RType c tv r)
-    , rt_res   :: !(RType c tv r)
-    , rt_reft  :: !r
-    }
-
-  | RRTy  {
-      rt_env   :: ![(Symbol, RType c tv r)]
-    , rt_ref   :: !r
-    , rt_obl   :: !Oblig
-    , rt_ty    :: !(RType c tv r)
-    }
-
-  | RHole r -- ^ let LH match against the Haskell type and add k-vars, e.g. `x:_`
-            --   see tests/pos/Holes.hs
-  deriving (Eq, Generic, Data, Typeable, Functor)
-  deriving Hashable via Generically (RType c tv r)
-
-instance (B.Binary c, B.Binary tv, B.Binary r) => B.Binary (RType c tv r)
-instance (NFData c, NFData tv, NFData r)       => NFData (RType c tv r)
-
-ignoreOblig :: RType t t1 t2 -> RType t t1 t2
-ignoreOblig (RRTy _ _ _ t) = t
-ignoreOblig t              = t
-
-dropImplicits :: RType c tv r -> RType c tv r
-dropImplicits (RImpF _ _ o _) = dropImplicits o
-dropImplicits (RFun  x i o r) = RFun x (dropImplicits i) (dropImplicits o) r
-dropImplicits (RAllP p t) = RAllP p (dropImplicits t)
-dropImplicits (RAllT p t r) = RAllT p (dropImplicits t) r
-dropImplicits (RApp c as ps r) = RApp c (dropImplicits <$> as) (dropImplicitsRP <$> ps) r
-dropImplicits (RAllE p t t') = RAllE p (dropImplicits t) (dropImplicits t')
-dropImplicits (REx s t t')   = REx   s (dropImplicits t) (dropImplicits t')
-dropImplicits (RAppTy t t' r)   = RAppTy (dropImplicits t) (dropImplicits t') r
-dropImplicits (RRTy e r o t) = RRTy (second dropImplicits <$> e) r o (dropImplicits t)
-dropImplicits t = t
-
-dropImplicitsRP :: RTProp c tv r -> RTProp c tv r
-dropImplicitsRP (RProp as b) = RProp (second dropImplicits <$> as) (dropImplicits b)
-
-
-makeRTVar :: tv -> RTVar tv s
-makeRTVar a = RTVar a (RTVNoInfo True)
-
-instance (Eq tv) => Eq (RTVar tv s) where
-  t1 == t2 = (ty_var_value t1) == (ty_var_value t2)
-
-data RTVar tv s = RTVar
-  { ty_var_value :: tv
-  , ty_var_info  :: RTVInfo s
-  } deriving (Generic, Data, Typeable)
-    deriving Hashable via Generically (RTVar tv s)
-
-mapTyVarValue :: (tv1 -> tv2) -> RTVar tv1 s -> RTVar tv2 s
-mapTyVarValue f v = v {ty_var_value = f $ ty_var_value v}
-
-dropTyVarInfo :: RTVar tv s1 -> RTVar tv s2
-dropTyVarInfo v = v{ty_var_info = RTVNoInfo True }
-
-data RTVInfo s
-  = RTVNoInfo { rtv_is_pol :: Bool }
-  | RTVInfo { rtv_name   :: Symbol
-            , rtv_kind   :: s
-            , rtv_is_val :: Bool
-            , rtv_is_pol :: Bool -- true iff the type variable gets instantiated with 
-                                 -- any refinement (ie is polymorphic on refinements), 
-                                 -- false iff instantiation is with true refinement 
-            } deriving (Generic, Data, Typeable, Functor)
-              deriving Hashable via Generically (RTVInfo s)
-
-
-setRtvPol :: RTVar tv a -> Bool -> RTVar tv a 
-setRtvPol (RTVar a i) b = RTVar a (i{rtv_is_pol = b})
-
-rTVarToBind :: RTVar RTyVar s  -> Maybe (Symbol, s)
-rTVarToBind = go . ty_var_info
-  where
-    go (RTVInfo {..}) | rtv_is_val = Just (rtv_name, rtv_kind)
-    go _                           = Nothing
-
-ty_var_is_val :: RTVar tv s -> Bool
-ty_var_is_val = rtvinfo_is_val . ty_var_info
-
-rtvinfo_is_val :: RTVInfo s -> Bool
-rtvinfo_is_val (RTVNoInfo {..}) = False
-rtvinfo_is_val (RTVInfo {..})   = rtv_is_val
-
-instance (B.Binary tv, B.Binary s) => B.Binary (RTVar tv s)
-instance (NFData tv, NFData s)     => NFData   (RTVar tv s)
-instance (NFData s)                => NFData   (RTVInfo s)
-instance (B.Binary s)              => B.Binary (RTVInfo s)
-
--- | @Ref@ describes `Prop τ` and `HProp` arguments applied to type constructors.
---   For example, in [a]<{\h -> v > h}>, we apply (via `RApp`)
---   * the `RProp`  denoted by `{\h -> v > h}` to
---   * the `RTyCon` denoted by `[]`.
---   Thus, @Ref@ is used for abstract-predicate (arguments) that are associated
---   with _type constructors_ i.e. whose semantics are _dependent upon_ the data-type.
---   In contrast, the `Predicate` argument in `ur_pred` in the @UReft@ applies
---   directly to any type and has semantics _independent of_ the data-type.
-
-data Ref τ t = RProp
-  { rf_args :: [(Symbol, τ)]
-  , rf_body :: t -- ^ Abstract refinement associated with `RTyCon`
-  } deriving (Eq, Generic, Data, Typeable, Functor)
-    deriving Hashable via Generically (Ref τ t)
-
-instance (B.Binary τ, B.Binary t) => B.Binary (Ref τ t)
-instance (NFData τ,   NFData t)   => NFData   (Ref τ t)
-
-rPropP :: [(Symbol, τ)] -> r -> Ref τ (RType c tv r)
-rPropP τ r = RProp τ (RHole r)
-
--- | @RTProp@ is a convenient alias for @Ref@ that will save a bunch of typing.
---   In general, perhaps we need not expose @Ref@ directly at all.
-type RTProp c tv r = Ref (RType c tv ()) (RType c tv r)
-
-
--- | A @World@ is a Separation Logic predicate that is essentially a sequence of binders
---   that satisfies two invariants (TODO:LIQUID):
---   1. Each `hs_addr :: Symbol` appears at most once,
---   2. There is at most one `HVar` in a list.
-
-newtype World t = World [HSeg t]
-                deriving (Generic, Data, Typeable)
-
-data    HSeg  t = HBind {hs_addr :: !Symbol, hs_val :: t}
-                | HVar UsedPVar
-                deriving (Generic, Data, Typeable)
-
-data UReft r = MkUReft
-  { ur_reft   :: !r
-  , ur_pred   :: !Predicate
-  }
-  deriving (Eq, Generic, Data, Typeable, Functor, Foldable, Traversable)
-  deriving Hashable via Generically (UReft r)
-
-instance B.Binary r => B.Binary (UReft r)
-
-type BRType      = RType BTyCon BTyVar       -- ^ "Bare" parsed version
-type RRType      = RType RTyCon RTyVar       -- ^ "Resolved" version
-type RRep        = RTypeRep RTyCon RTyVar
-type BSort       = BRType    ()
-type RSort       = RRType    ()
-type BPVar       = PVar      BSort
-type RPVar       = PVar      RSort
-type RReft       = UReft     F.Reft
-type PrType      = RRType    Predicate
-type BareType    = BRType    RReft
-type SpecType    = RRType    RReft
-type SpecRep     = RRep      RReft
-type SpecProp    = RRProp    RReft
-type RRProp r    = Ref       RSort (RRType r)
-type BRProp r    = Ref       BSort (BRType r)
-type SpecRTVar   = RTVar     RTyVar RSort 
-
-
-
-type LocBareType = F.Located BareType
-type LocSpecType = F.Located SpecType
-
-type SpecRTEnv   = RTEnv RTyVar SpecType 
-type BareRTEnv   = RTEnv Symbol BareType 
-type BareRTAlias = RTAlias Symbol BareType 
-type SpecRTAlias = RTAlias RTyVar SpecType
-
-
-class SubsTy tv ty a where
-  subt :: (tv, ty) -> a -> a
-
-class (Eq c) => TyConable c where
-  isFun    :: c -> Bool
-  isList   :: c -> Bool
-  isTuple  :: c -> Bool
-  ppTycon  :: c -> Doc
-  isClass  :: c -> Bool
-  isEqual  :: c -> Bool
-
-  isNumCls  :: c -> Bool
-  isFracCls :: c -> Bool
-
-  isClass   = const False
-  isEqual   = const False
-  isNumCls  = const False
-  isFracCls = const False
-
-
--- Should just make this a @Pretty@ instance but its too damn tedious
--- to figure out all the constraints.
-
-type OkRT c tv r = ( TyConable c
-                   , F.PPrint tv, F.PPrint c, F.PPrint r
-                   , F.Reftable r, F.Reftable (RTProp c tv ()), F.Reftable (RTProp c tv r)
-                   , Eq c, Eq tv
-                   , Hashable tv
-                   )
-
--------------------------------------------------------------------------------
--- | TyConable Instances -------------------------------------------------------
--------------------------------------------------------------------------------
-
-instance TyConable RTyCon where
-  isFun      = isFunTyCon . rtc_tc
-  isList     = (listTyCon ==) . rtc_tc
-  isTuple    = TyCon.isTupleTyCon   . rtc_tc
-  isClass    = isClass . rtc_tc -- isClassRTyCon
-  isEqual    = isEqual . rtc_tc
-  ppTycon    = F.toFix
-
-  isNumCls c  = maybe False (isClassOrSubClass isNumericClass)
-                (tyConClass_maybe $ rtc_tc c)
-  isFracCls c = maybe False (isClassOrSubClass isFractionalClass)
-                (tyConClass_maybe $ rtc_tc c)
-
-
-instance TyConable TyCon where
-  isFun      = isFunTyCon
-  isList     = (listTyCon ==)
-  isTuple    = TyCon.isTupleTyCon
-  isClass c  = isClassTyCon c   || isEqual c -- c == eqPrimTyCon
-  isEqual c  = c == eqPrimTyCon || c == eqReprPrimTyCon
-  ppTycon    = text . showPpr
-
-  isNumCls c  = maybe False (isClassOrSubClass isNumericClass)
-                (tyConClass_maybe $ c)
-  isFracCls c = maybe False (isClassOrSubClass isFractionalClass)
-                (tyConClass_maybe $ c)
-
-
-isClassOrSubClass :: (Class -> Bool) -> Class -> Bool
-isClassOrSubClass p cls
-  = p cls || any (isClassOrSubClass p . fst)
-                 (mapMaybe getClassPredTys_maybe (classSCTheta cls))
-
--- MOVE TO TYPES
-instance TyConable Symbol where
-  isFun   s = F.funConName == s
-  isList  s = F.listConName == s
-  isTuple s = F.tupConName == s
-  ppTycon   = text . F.symbolString
-
-instance TyConable F.LocSymbol where
-  isFun   = isFun   . F.val
-  isList  = isList  . F.val
-  isTuple = isTuple . F.val
-  ppTycon = ppTycon . F.val
-
-instance TyConable BTyCon where
-  isFun   = isFun . btc_tc
-  isList  = isList . btc_tc
-  isTuple = isTuple . btc_tc
-  isClass = isClassBTyCon
-  ppTycon = ppTycon . btc_tc
-
-
-instance Eq RTyCon where
-  x == y = rtc_tc x == rtc_tc y
-
-instance Eq BTyCon where
-  x == y = btc_tc x == btc_tc y
-
-instance Ord BTyCon where 
-  compare x y = compare (btc_tc x) (btc_tc y)
-
-instance F.Fixpoint RTyCon where
-  toFix (RTyCon c _ _) = text $ showPpr c
-
-instance F.Fixpoint BTyCon where
-  toFix = text . F.symbolString . F.val . btc_tc
-
-instance F.Fixpoint Cinfo where
-  toFix = text . showPpr . ci_loc
-
-instance Show Cinfo where
-  show = show . F.toFix
-
-instance F.PPrint RTyCon where
-  pprintTidy k c 
-    | ppDebug ppEnv = F.pprintTidy k tc  <-> (angleBrackets $ F.pprintTidy k pvs)
-    | otherwise     = text . showPpr . rtc_tc $ c
-    where 
-      tc            = F.symbol (rtc_tc c) 
-      pvs           = rtc_pvars c 
-
-instance F.PPrint BTyCon where
-  pprintTidy _ = text . F.symbolString . F.val . btc_tc
-
-instance F.PPrint v => F.PPrint (RTVar v s) where
-  pprintTidy k (RTVar x _) = F.pprintTidy k x
-
-instance Show RTyCon where
-  show = F.showpp
-
-instance Show BTyCon where
-  show = F.showpp
-
-instance F.Loc BTyCon where 
-  srcSpan = F.srcSpan . btc_tc 
-
---------------------------------------------------------------------------------
--- | Refined Instances ---------------------------------------------------------
---------------------------------------------------------------------------------
-
-data RInstance t = RI
-  { riclass :: BTyCon
-  , ritype  :: [t]
-  , risigs  :: [(F.LocSymbol, RISig t)]
-  } deriving (Eq, Generic, Functor, Data, Typeable, Show)
-    deriving Hashable via Generically (RInstance t)
-
-data RILaws ty = RIL
-  { rilName    :: BTyCon
-  , rilSupers  :: [ty]
-  , rilTyArgs  :: [ty]
-  , rilEqus    :: [(F.LocSymbol, F.LocSymbol)]
-  , rilPos     :: F.Located ()
-  } deriving (Eq, Show, Functor, Data, Typeable, Generic)
-    deriving Hashable via Generically (RILaws ty)
-
-data RISig t = RIAssumed t | RISig t
-  deriving (Eq, Generic, Functor, Data, Typeable, Show)
-  deriving Hashable via Generically (RISig t)
-
-instance F.PPrint t => F.PPrint (RISig t) where
-  pprintTidy k = ppRISig k (empty :: Doc) 
-
-ppRISig :: (F.PPrint k, F.PPrint t) => F.Tidy -> k -> RISig t -> Doc
-ppRISig k x (RIAssumed t) = "assume" <+> F.pprintTidy k x <+> "::" <+> F.pprintTidy k t 
-ppRISig k x (RISig t)     =              F.pprintTidy k x <+> "::" <+> F.pprintTidy k t 
-
-instance F.PPrint t => F.PPrint (RInstance t) where
-  pprintTidy k (RI n ts mts) = ppMethods k "instance" n ts mts 
-
-  
-instance (B.Binary t) => B.Binary (RInstance t)
-instance (B.Binary t) => B.Binary (RISig t)
-instance (B.Binary t) => B.Binary (RILaws t)
-
-newtype DEnv x ty = DEnv (M.HashMap x (M.HashMap Symbol (RISig ty)))
-                    deriving (Semigroup, Monoid, Show, Functor)
-
-type RDEnv = DEnv Var SpecType
-
-data MethodType t = MT {tyInstance :: !(Maybe t), tyClass :: !(Maybe t) }
-  deriving (Show)
-
-getMethodType :: MethodType t -> Maybe t 
-getMethodType (MT (Just t) _ ) = Just t 
-getMethodType (MT _ t) = t 
-
---------------------------------------------------------------------------
--- | Values Related to Specifications ------------------------------------
---------------------------------------------------------------------------
-
-data Axiom b s e = Axiom
-  { aname  :: (Var, Maybe DataCon)
-  , rname  :: Maybe b
-  , abinds :: [b]
-  , atypes :: [s]
-  , alhs   :: e
-  , arhs   :: e
-  }
-
-type HAxiom = Axiom Var    Type CoreExpr
-
--- type AxiomEq = F.Equation
-
-instance Show (Axiom Var Type CoreExpr) where
-  show (Axiom (n, c) v bs _ts lhs rhs) = "Axiom : " ++
-                                         "\nFun Name: " ++ (showPpr n) ++
-                                         "\nReal Name: " ++ (showPpr v) ++
-                                         "\nData Con: " ++ (showPpr c) ++
-                                         "\nArguments:" ++ (showPpr bs)  ++
-                                         -- "\nTypes    :" ++ (showPpr ts)  ++
-                                         "\nLHS      :" ++ (showPpr lhs) ++
-                                         "\nRHS      :" ++ (showPpr rhs)
-
---------------------------------------------------------------------------------
--- | Data type refinements
---------------------------------------------------------------------------------
-data DataDecl   = DataDecl
-  { tycName   :: DataName              -- ^ Type  Constructor Name
-  , tycTyVars :: [Symbol]              -- ^ Tyvar Parameters
-  , tycPVars  :: [PVar BSort]          -- ^ PVar  Parameters
-  , tycDCons  :: [DataCtor]            -- ^ Data Constructors
-  , tycSrcPos :: !F.SourcePos          -- ^ Source Position
-  , tycSFun   :: Maybe SizeFun         -- ^ Default termination measure
-  , tycPropTy :: Maybe BareType        -- ^ Type of Ind-Prop
-  , tycKind   :: !DataDeclKind         -- ^ User-defined or Auto-lifted
-  } deriving (Data, Typeable, Generic)
-    deriving Hashable via Generically DataDecl
-
--- | The name of the `TyCon` corresponding to a `DataDecl`
-data DataName
-  = DnName !F.LocSymbol                -- ^ for 'isVanillyAlgTyCon' we can directly use the `TyCon` name
-  | DnCon  !F.LocSymbol                -- ^ for 'FamInst' TyCon we save some `DataCon` name
-  deriving (Eq, Ord, Data, Typeable, Generic)
-
--- | Data Constructor
-data DataCtor = DataCtor
-  { dcName   :: F.LocSymbol            -- ^ DataCon name
-  , dcTyVars :: [F.Symbol]             -- ^ Type parameters
-  , dcTheta  :: [BareType]             -- ^ The GHC ThetaType corresponding to DataCon.dataConSig
-  , dcFields :: [(Symbol, BareType)]   -- ^ field-name and field-Type pairs 
-  , dcResult :: Maybe BareType         -- ^ Possible output (if in GADT form)
-  } deriving (Data, Typeable, Generic)
-    deriving Hashable via Generically DataCtor
-
--- | Termination expressions
-data SizeFun
-  = IdSizeFun              -- ^ \x -> F.EVar x
-  | SymSizeFun F.LocSymbol -- ^ \x -> f x
-  deriving (Data, Typeable, Generic)
-  deriving Hashable via Generically SizeFun
-
--- | What kind of `DataDecl` is it?
-data DataDeclKind
-  = DataUser           -- ^ User defined data-definitions         (should have refined fields)
-  | DataReflected      -- ^ Automatically lifted data-definitions (do not have refined fields)
-  deriving (Eq, Data, Typeable, Generic, Show)
-  deriving Hashable via Generically DataDeclKind
-
-instance Show SizeFun where
-  show IdSizeFun      = "IdSizeFun"
-  show (SymSizeFun x) = "SymSizeFun " ++ show (F.val x)
-
-szFun :: SizeFun -> Symbol -> Expr
-szFun IdSizeFun      = F.EVar
-szFun (SymSizeFun f) = \x -> F.mkEApp (F.symbol <$> f) [F.EVar x]
-
-data HasDataDecl
-  = NoDecl  (Maybe SizeFun)
-  | HasDecl
-  deriving (Show)
-
-instance F.PPrint HasDataDecl where
-  pprintTidy _ HasDecl    = text "HasDecl"
-  pprintTidy k (NoDecl z) = text "NoDecl" <+> parens (F.pprintTidy k z)
-
-hasDecl :: DataDecl -> HasDataDecl
-hasDecl d
-  | null (tycDCons d)
-  = NoDecl (tycSFun d)
-  -- // | Just s <- tycSFun d, null (tycDCons d)
-  -- // = NoDecl (Just s)
-  | otherwise
-  = HasDecl
-
-instance Hashable DataName where
-  hashWithSalt i = hashWithSalt i . F.symbol
-
-
-instance NFData   SizeFun
-instance B.Binary SizeFun
-instance NFData   DataDeclKind
-instance B.Binary DataDeclKind
-instance B.Binary DataName
-instance B.Binary DataCtor
-instance B.Binary DataDecl
-
-instance Eq DataDecl where
-  d1 == d2 = tycName d1 == tycName d2
-
-instance Ord DataDecl where
-  compare d1 d2 = compare (tycName d1) (tycName d2)
-
-instance F.Loc DataCtor where
-  srcSpan = F.srcSpan . dcName
-
-instance F.Loc DataDecl where
-  srcSpan = srcSpanFSrcSpan . sourcePosSrcSpan . tycSrcPos
-
-instance F.Loc DataName where
-  srcSpan (DnName z) = F.srcSpan z
-  srcSpan (DnCon  z) = F.srcSpan z
-
-
--- | For debugging.
-instance Show DataDecl where
-  show dd = printf "DataDecl: data = %s, tyvars = %s, sizeFun = %s, kind = %s" -- [at: %s]"
-              (show $ tycName   dd)
-              (show $ tycTyVars dd)
-              (show $ tycSFun   dd)
-              (show $ tycKind   dd)
-
-
-instance Show DataName where
-  show (DnName n) =               show (F.val n)
-  show (DnCon  c) = "datacon:" ++ show (F.val c)
-
-instance F.PPrint SizeFun where
-  pprintTidy _ (IdSizeFun)    = "[id]"
-  pprintTidy _ (SymSizeFun x) = brackets (F.pprint (F.val x))
-
-instance F.Symbolic DataName where
-  symbol = F.val . dataNameSymbol
-
-instance F.Symbolic DataDecl where
-  symbol = F.symbol . tycName
-
-instance F.PPrint DataName where
-  pprintTidy k (DnName n) = F.pprintTidy k (F.val n)
-  pprintTidy k (DnCon  n) = F.pprintTidy k (F.val n)
-
-  -- symbol (DnName z) = F.suffixSymbol "DnName" (F.val z)
-  -- symbol (DnCon  z) = F.suffixSymbol "DnCon"  (F.val z)
-
-dataNameSymbol :: DataName -> F.LocSymbol
-dataNameSymbol (DnName z) = z
-dataNameSymbol (DnCon  z) = z
-
---------------------------------------------------------------------------------
--- | Refinement Type Aliases
---------------------------------------------------------------------------------
-data RTAlias x a = RTA
-  { rtName  :: Symbol             -- ^ name of the alias
-  , rtTArgs :: [x]                -- ^ type parameters
-  , rtVArgs :: [Symbol]           -- ^ value parameters
-  , rtBody  :: a                  -- ^ what the alias expands to
-  -- , rtMod   :: !ModName           -- ^ module where alias was defined
-  } deriving (Eq, Data, Typeable, Generic, Functor)
-    deriving Hashable via Generically (RTAlias x a)
--- TODO support ghosts in aliases?
-
-instance (B.Binary x, B.Binary a) => B.Binary (RTAlias x a)
-
-mapRTAVars :: (a -> b) -> RTAlias a ty -> RTAlias b ty
-mapRTAVars f rt = rt { rtTArgs = f <$> rtTArgs rt }
-
-lmapEAlias :: LMap -> F.Located (RTAlias Symbol Expr)
-lmapEAlias (LMap v ys e) = F.atLoc v (RTA (F.val v) [] ys e) -- (F.loc v) (F.loc v)
-
-
---------------------------------------------------------------------------------
--- | Constructor and Destructors for RTypes ------------------------------------
---------------------------------------------------------------------------------
-data RTypeRep c tv r = RTypeRep
-  { ty_vars   :: [(RTVar tv (RType c tv ()), r)]
-  , ty_preds  :: [PVar (RType c tv ())]
-  , ty_ebinds  :: [Symbol]
-  , ty_erefts  :: [r]
-  , ty_eargs   :: [RType c tv r]
-  , ty_binds  :: [Symbol]
-  , ty_refts  :: [r]
-  , ty_args   :: [RType c tv r]
-  , ty_res    :: (RType c tv r)
-  }
-
-fromRTypeRep :: RTypeRep c tv r -> RType c tv r
-fromRTypeRep (RTypeRep {..})
-  = mkArrow ty_vars ty_preds earrs arrs ty_res
-  where
-    arrs  = safeZip3WithError ("fromRTypeRep: " ++ show (length ty_binds, length ty_args, length ty_refts)) ty_binds ty_args ty_refts
-    earrs = safeZip3WithError ("fromRTypeRep: " ++ show (length ty_ebinds, length ty_eargs, length ty_erefts)) ty_ebinds ty_eargs ty_erefts
-
---------------------------------------------------------------------------------
-toRTypeRep           :: RType c tv r -> RTypeRep c tv r
---------------------------------------------------------------------------------
-toRTypeRep t         = RTypeRep αs πs xs' rs' ts' xs rs ts t''
-  where
-    (αs, πs, t')  = bkUniv  t
-    ((xs',ts',rs'),(xs, ts, rs), t'') = bkArrow t'
-
-mkArrow :: [(RTVar tv (RType c tv ()), r)]
-        -> [PVar (RType c tv ())]
-        -> [(Symbol, RType c tv r, r)]
-        -> [(Symbol, RType c tv r, r)]
-        -> RType c tv r
-        -> RType c tv r
-mkArrow αs πs yts xts = mkUnivs αs πs . mkArrs RImpF yts. mkArrs RFun xts
-  where
-    mkArrs f xts t  = foldr (\(b,t1,r) t2 -> f b t1 t2 r) t xts
-
--- Do I need to keep track of implicits here too?
-bkArrowDeep :: RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
-bkArrowDeep (RAllT _ t _)   = bkArrowDeep t
-bkArrowDeep (RAllP _ t)     = bkArrowDeep t
-bkArrowDeep (RImpF x t t' r)= bkArrowDeep (RFun x t t' r)
-bkArrowDeep (RFun x t t' r) = let (xs, ts, rs, t'') = bkArrowDeep t'  in (x:xs, t:ts, r:rs, t'')
-bkArrowDeep t               = ([], [], [], t)
-
-bkArrow :: RType t t1 a -> ( ([Symbol], [RType t t1 a], [a])
-                           , ([Symbol], [RType t t1 a], [a])
-                           , RType t t1 a )
-bkArrow t                = ((xs,ts,rs),(xs',ts',rs'),t'')
-  where 
-    (xs, ts, rs, t')     = bkImp t
-    (xs', ts', rs', t'') = bkFun t'
-
-
-bkFun :: RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
-bkFun (RFun x t t' r) = let (xs, ts, rs, t'') = bkFun t'  in (x:xs, t:ts, r:rs, t'')
-bkFun t               = ([], [], [], t)
-
-bkImp :: RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
-bkImp (RImpF x t t' r) = let (xs, ts, rs, t'') = bkImp t'  in (x:xs, t:ts, r:rs, t'')
-bkImp t                = ([], [], [], t)
-
-safeBkArrow ::(F.PPrint (RType t t1 a)) 
-            => RType t t1 a -> ( ([Symbol], [RType t t1 a], [a])
-                               , ([Symbol], [RType t t1 a], [a])
-                               , RType t t1 a )
-safeBkArrow t@(RAllT _ _ _) = Prelude.error {- panic Nothing -} $ "safeBkArrow on RAllT" ++ F.showpp t
-safeBkArrow (RAllP _ _)     = Prelude.error {- panic Nothing -} "safeBkArrow on RAllP"
-safeBkArrow t               = bkArrow t
-
-mkUnivs :: (Foldable t, Foldable t1)
-        => t  (RTVar tv (RType c tv ()), r)
-        -> t1 (PVar (RType c tv ()))
-        -> RType c tv r
-        -> RType c tv r
-mkUnivs αs πs t = foldr (\(a,r) t -> RAllT a t r) (foldr RAllP t πs) αs
-
-bkUnivClass :: SpecType -> ([(SpecRTVar, RReft)],[PVar RSort], [(RTyCon, [SpecType])], SpecType )
-bkUnivClass t        = (as, ps, cs, t2) 
-  where 
-    (as, ps, t1) = bkUniv  t
-    (cs, t2)     = bkClass t1
-
-
-bkUniv :: RType tv c r -> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())], RType tv c r)
-bkUniv (RAllT α t r) = let (αs, πs, t') = bkUniv t in ((α, r):αs, πs, t')
-bkUniv (RAllP π t)   = let (αs, πs, t') = bkUniv t in (αs, π:πs, t')
-bkUniv t             = ([], [], t)
-
-bkClass :: (F.PPrint c, TyConable c) => RType c tv r -> ([(c, [RType c tv r])], RType c tv r)
-bkClass (RImpF _ (RApp c t _ _) t' _)
-  | isClass c
-  = let (cs, t'') = bkClass t' in ((c, t):cs, t'')
-bkClass (RFun _ (RApp c t _ _) t' _)
-  | F.notracepp ("IS-CLASS: " ++ F.showpp c) $ isClass c
-  = let (cs, t'') = bkClass t' in ((c, t):cs, t'')
-bkClass (RRTy e r o t)
-  = let (cs, t') = bkClass t in (cs, RRTy e r o t')
-bkClass t
-  = ([], t)
-
-rImpF :: Monoid r => Symbol -> RType c tv r -> RType c tv r -> RType c tv r
-rImpF b t t' = RImpF b t t' mempty
-
-rFun :: Monoid r => Symbol -> RType c tv r -> RType c tv r -> RType c tv r
-rFun b t t' = RFun b t t' mempty
-
-rCls :: Monoid r => TyCon -> [RType RTyCon tv r] -> RType RTyCon tv r
-rCls c ts   = RApp (RTyCon c [] defaultTyConInfo) ts [] mempty
-
-rRCls :: Monoid r => c -> [RType c tv r] -> RType c tv r
-rRCls rc ts = RApp rc ts [] mempty
-
-addInvCond :: SpecType -> RReft -> SpecType
-addInvCond t r'
-  | F.isTauto $ ur_reft r' -- null rv
-  = t
-  | otherwise
-  = fromRTypeRep $ trep {ty_res = RRTy [(x', tbd)] r OInv tbd}
-  where
-    trep = toRTypeRep t
-    tbd  = ty_res trep
-    r    = r' {ur_reft = F.Reft (v, rx)}
-    su   = (v, F.EVar x')
-    x'   = "xInv"
-    rx   = F.PIff (F.EVar v) $ F.subst1 rv su
-    F.Reft(v, rv) = ur_reft r'
-
--------------------------------------------
-
-class F.Reftable r => UReftable r where
-  ofUReft :: UReft F.Reft -> r
-  ofUReft (MkUReft r _) = F.ofReft r
-
-
-instance UReftable (UReft F.Reft) where
-   ofUReft r = r
-
-instance UReftable () where
-   ofUReft _ = mempty
-
-instance (F.PPrint r, F.Reftable r) => F.Reftable (UReft r) where
-  isTauto               = isTauto_ureft
-  ppTy                  = ppTy_ureft
-  toReft (MkUReft r ps) = F.toReft r `F.meet` F.toReft ps
-  params (MkUReft r _)  = F.params r
-  bot (MkUReft r _)     = MkUReft (F.bot r) (Pr [])
-  top (MkUReft r p)     = MkUReft (F.top r) (F.top p)
-  ofReft r              = MkUReft (F.ofReft r) mempty
-
-instance F.Expression (UReft ()) where
-  expr = F.expr . F.toReft
-
-
-
-isTauto_ureft :: F.Reftable r => UReft r -> Bool
-isTauto_ureft u      = F.isTauto (ur_reft u) && F.isTauto (ur_pred u) 
-
-ppTy_ureft :: F.Reftable r => UReft r -> Doc -> Doc
-ppTy_ureft u@(MkUReft r p) d
-  | isTauto_ureft  u  = d
-  | otherwise         = ppr_reft r (F.ppTy p d)
-
-ppr_reft :: (F.Reftable r) => r -> Doc -> Doc
-ppr_reft r d = braces (F.pprint v <+> colon <+> d <+> text "|" <+> F.pprint r')
-  where
-    r'@(F.Reft (v, _)) = F.toReft r
-
-instance F.Subable r => F.Subable (UReft r) where
-  syms (MkUReft r p)     = F.syms r ++ F.syms p
-  subst s (MkUReft r z)  = MkUReft (F.subst s r)  (F.subst s z)  
-  substf f (MkUReft r z) = MkUReft (F.substf f r) (F.substf f z) 
-  substa f (MkUReft r z) = MkUReft (F.substa f r) (F.substa f z) 
-
-instance (F.Reftable r, TyConable c) => F.Subable (RTProp c tv r) where
-  syms (RProp  ss r)     = (fst <$> ss) ++ F.syms r
-
-  subst su (RProp ss (RHole r)) = RProp ss (RHole (F.subst su r))
-  subst su (RProp  ss t) = RProp ss (F.subst su <$> t)
-
-  substf f (RProp ss (RHole r)) = RProp ss (RHole (F.substf f r))
-  substf f (RProp  ss t) = RProp ss (F.substf f <$> t)
-
-  substa f (RProp ss (RHole r)) = RProp ss (RHole (F.substa f r))
-  substa f (RProp  ss t) = RProp ss (F.substa f <$> t)
-
-
-instance (F.Subable r, F.Reftable r, TyConable c) => F.Subable (RType c tv r) where
-  syms        = foldReft False (\_ r acc -> F.syms r ++ acc) []
-  -- 'substa' will substitute bound vars
-  substa f    = emapExprArg (\_ -> F.substa f) []      . mapReft  (F.substa f)
-  -- 'substf' will NOT substitute bound vars
-  substf f    = emapExprArg (\_ -> F.substf f) []      . emapReft (F.substf . F.substfExcept f) []
-  subst su    = emapExprArg (\_ -> F.subst su) []      . emapReft (F.subst  . F.substExcept su) []
-  subst1 t su = emapExprArg (\_ e -> F.subst1 e su) [] $ emapReft (\xs r -> F.subst1Except xs r su) [] t
-
-
-instance F.Reftable Predicate where
-  isTauto (Pr ps)      = null ps
-
-  bot (Pr _)           = panic Nothing "No BOT instance for Predicate"
-  ppTy r d | F.isTauto r      = d
-           | not (ppPs ppEnv) = d
-           | otherwise        = d <-> (angleBrackets $ F.pprint r)
-
-  toReft (Pr ps@(p:_))        = F.Reft (parg p, F.pAnd $ pToRef <$> ps)
-  toReft _                    = mempty
-  params                      = todo Nothing "TODO: instance of params for Predicate"
-
-  ofReft = todo Nothing "TODO: Predicate.ofReft"
-
-pToRef :: PVar a -> F.Expr
-pToRef p = pApp (pname p) $ (F.EVar $ parg p) : (thd3 <$> pargs p)
-
-pApp      :: Symbol -> [Expr] -> Expr
-pApp p es = F.mkEApp fn (F.EVar p:es)
-  where
-    fn    = F.dummyLoc (pappSym n)
-    n     = length es
-
-pappSym :: Show a => a -> Symbol
-pappSym n  = F.symbol $ "papp" ++ show n
-
---------------------------------------------------------------------------------
--- | Visitors ------------------------------------------------------------------
---------------------------------------------------------------------------------
-mapExprReft :: (Symbol -> Expr -> Expr) -> RType c tv RReft -> RType c tv RReft
-mapExprReft f = mapReft g
-  where
-    g (MkUReft (F.Reft (x, e)) p) = MkUReft (F.Reft (x, f x e)) p
-
-isTrivial :: (F.Reftable r, TyConable c) => RType c tv r -> Bool
-isTrivial t = foldReft False (\_ r b -> F.isTauto r && b) True t
-
-mapReft ::  (r1 -> r2) -> RType c tv r1 -> RType c tv r2
-mapReft f = emapReft (const f) []
-
-emapReft ::  ([Symbol] -> r1 -> r2) -> [Symbol] -> RType c tv r1 -> RType c tv r2
-emapReft f γ (RVar α r)          = RVar  α (f γ r)
-emapReft f γ (RAllT α t r)       = RAllT α (emapReft f γ t) (f γ r)
-emapReft f γ (RAllP π t)         = RAllP π (emapReft f γ t)
-emapReft f γ (RImpF x t t' r)    = RImpF  x (emapReft f γ t) (emapReft f (x:γ) t') (f (x:γ) r)
-emapReft f γ (RFun x t t' r)     = RFun  x (emapReft f γ t) (emapReft f (x:γ) t') (f (x:γ) r)
-emapReft f γ (RApp c ts rs r)    = RApp  c (emapReft f γ <$> ts) (emapRef f γ <$> rs) (f γ r)
-emapReft f γ (RAllE z t t')      = RAllE z (emapReft f γ t) (emapReft f γ t')
-emapReft f γ (REx z t t')        = REx   z (emapReft f γ t) (emapReft f γ t')
-emapReft _ _ (RExprArg e)        = RExprArg e
-emapReft f γ (RAppTy t t' r)     = RAppTy (emapReft f γ t) (emapReft f γ t') (f γ r)
-emapReft f γ (RRTy e r o t)      = RRTy  (mapSnd (emapReft f γ) <$> e) (f γ r) o (emapReft f γ t)
-emapReft f γ (RHole r)           = RHole (f γ r)
-
-emapRef :: ([Symbol] -> t -> s) ->  [Symbol] -> RTProp c tv t -> RTProp c tv s
-emapRef  f γ (RProp s (RHole r))  = RProp s $ RHole (f γ r)
-emapRef  f γ (RProp s t)         = RProp s $ emapReft f γ t
-
-emapExprArg :: ([Symbol] -> Expr -> Expr) -> [Symbol] -> RType c tv r -> RType c tv r
-emapExprArg f = go
-  where
-    go _ t@(RVar {})        = t
-    go _ t@(RHole {})       = t
-    go γ (RAllT α t r)      = RAllT α (go γ t) r 
-    go γ (RAllP π t)        = RAllP π (go γ t)
-    go γ (RImpF x t t' r)   = RImpF x (go γ t) (go (x:γ) t') r
-    go γ (RFun x t t' r)    = RFun  x (go γ t) (go (x:γ) t') r
-    go γ (RApp c ts rs r)   = RApp  c (go γ <$> ts) (mo γ <$> rs) r
-    go γ (RAllE z t t')     = RAllE z (go γ t) (go γ t')
-    go γ (REx z t t')       = REx   z (go γ t) (go γ t')
-    go γ (RExprArg e)       = RExprArg (f γ <$> F.notracepp "RExprArg" e) -- <---- actual substitution
-    go γ (RAppTy t t' r)    = RAppTy (go γ t) (go γ t') r
-    go γ (RRTy e r o t)     = RRTy  (mapSnd (go γ) <$> e) r o (go γ t)
-    mo _ t@(RProp _ (RHole {})) = t
-    mo γ (RProp s t)            = RProp s (go γ t)
-
-foldRType :: (acc -> RType c tv r -> acc) -> acc -> RType c tv r -> acc
-foldRType f = go
-  where
-    step a t                = go (f a t) t
-    prep a (RProp _ (RHole {})) = a
-    prep a (RProp _ t)      = step a t
-    go a (RVar {})          = a
-    go a (RHole {})         = a
-    go a (RExprArg {})      = a
-    go a (RAllT _ t _)      = step a t
-    go a (RAllP _ t)        = step a t
-    go a (RImpF _ t t' _)   = foldl' step a [t, t']
-    go a (RFun _ t t' _)    = foldl' step a [t, t']
-    go a (RAllE _ t t')     = foldl' step a [t, t']
-    go a (REx _ t t')       = foldl' step a [t, t']
-    go a (RAppTy t t' _)    = foldl' step a [t, t']
-    go a (RApp _ ts rs _)   = foldl' prep (foldl' step a ts) rs
-    go a (RRTy e _ _ t)     = foldl' step a (t : (snd <$> e))
-
-------------------------------------------------------------------------------------------------------
--- isBase' x t = traceShow ("isBase: " ++ showpp x) $ isBase t
--- same as GhcMisc isBaseType
-
--- isBase :: RType a -> Bool
-
--- set all types to basic types, haskell `tx -> t` is translated to Arrow tx t
--- isBase _ = True
-
-isBase :: RType t t1 t2 -> Bool
-isBase (RAllT _ t _)    = isBase t
-isBase (RAllP _ t)      = isBase t
-isBase (RVar _ _)       = True
-isBase (RApp _ ts _ _)  = all isBase ts
-isBase (RImpF _ _ _ _)  = False
-isBase (RFun _ _ _ _)   = False
-isBase (RAppTy t1 t2 _) = isBase t1 && isBase t2
-isBase (RRTy _ _ _ t)   = isBase t
-isBase (RAllE _ _ t)    = isBase t
-isBase (REx _ _ t)      = isBase t
-isBase _                = False
-
-hasHoleTy :: RType t t1 t2 -> Bool
-hasHoleTy (RVar _ _)       = False 
-hasHoleTy (RAllT _ t _)    = hasHoleTy t 
-hasHoleTy (RAllP _ t)      = hasHoleTy t
-hasHoleTy (RImpF _ t t' _) = hasHoleTy t || hasHoleTy t'
-hasHoleTy (RFun _ t t' _)  = hasHoleTy t || hasHoleTy t'
-hasHoleTy (RApp _ ts _ _)  = any hasHoleTy ts 
-hasHoleTy (RAllE _ t t')   = hasHoleTy t || hasHoleTy t'
-hasHoleTy (REx _ t t')     = hasHoleTy t || hasHoleTy t'
-hasHoleTy (RExprArg _)     = False 
-hasHoleTy (RAppTy t t' _)  = hasHoleTy t || hasHoleTy t'
-hasHoleTy (RHole _)        = True 
-hasHoleTy (RRTy xts _ _ t) = hasHoleTy t || any hasHoleTy (snd <$> xts)
-
-
-
-isFunTy :: RType t t1 t2 -> Bool
-isFunTy (RAllE _ _ t)    = isFunTy t
-isFunTy (RAllT _ t _)    = isFunTy t
-isFunTy (RAllP _ t)      = isFunTy t
-isFunTy (RImpF _ _ _ _)  = True
-isFunTy (RFun _ _ _ _)   = True
-isFunTy _                = False
-
-
-mapReftM :: (Monad m) => (r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
-mapReftM f (RVar α r)         = liftM   (RVar  α)   (f r)
-mapReftM f (RAllT α t r)      = liftM2  (RAllT α)   (mapReftM f t)          (f r)
-mapReftM f (RAllP π t)        = liftM   (RAllP π)   (mapReftM f t)
-mapReftM f (RImpF x t t' r)   = liftM3  (RImpF x)   (mapReftM f t)          (mapReftM f t')       (f r)
-mapReftM f (RFun x t t' r)    = liftM3  (RFun x)    (mapReftM f t)          (mapReftM f t')       (f r)
-mapReftM f (RApp c ts rs r)   = liftM3  (RApp  c)   (mapM (mapReftM f) ts)  (mapM (mapRefM f) rs) (f r)
-mapReftM f (RAllE z t t')     = liftM2  (RAllE z)   (mapReftM f t)          (mapReftM f t')
-mapReftM f (REx z t t')       = liftM2  (REx z)     (mapReftM f t)          (mapReftM f t')
-mapReftM _ (RExprArg e)       = return  $ RExprArg e
-mapReftM f (RAppTy t t' r)    = liftM3  RAppTy (mapReftM f t) (mapReftM f t') (f r)
-mapReftM f (RHole r)          = liftM   RHole       (f r)
-mapReftM f (RRTy xts r o t)   = liftM4  RRTy (mapM (mapSndM (mapReftM f)) xts) (f r) (return o) (mapReftM f t)
-
-mapRefM  :: (Monad m) => (t -> m s) -> (RTProp c tv t) -> m (RTProp c tv s)
-mapRefM  f (RProp s t)         = liftM   (RProp s)      (mapReftM f t)
-
-mapPropM :: (Monad m) => (RTProp c tv r -> m (RTProp c tv r)) -> RType c tv r -> m (RType c tv r)
-mapPropM _ (RVar α r)         = return $ RVar  α r
-mapPropM f (RAllT α t r)      = liftM2  (RAllT α)   (mapPropM f t)          (return r)
-mapPropM f (RAllP π t)        = liftM   (RAllP π)   (mapPropM f t)
-mapPropM f (RImpF x t t' r)   = liftM3  (RImpF x)    (mapPropM f t)         (mapPropM f t') (return r)
-mapPropM f (RFun x t t' r)    = liftM3  (RFun x)    (mapPropM f t)          (mapPropM f t') (return r)
-mapPropM f (RApp c ts rs r)   = liftM3  (RApp  c)   (mapM (mapPropM f) ts)  (mapM f rs)     (return r)
-mapPropM f (RAllE z t t')     = liftM2  (RAllE z)   (mapPropM f t)          (mapPropM f t')
-mapPropM f (REx z t t')       = liftM2  (REx z)     (mapPropM f t)          (mapPropM f t')
-mapPropM _ (RExprArg e)       = return  $ RExprArg e
-mapPropM f (RAppTy t t' r)    = liftM3  RAppTy (mapPropM f t) (mapPropM f t') (return r)
-mapPropM _ (RHole r)          = return $ RHole r
-mapPropM f (RRTy xts r o t)   = liftM4  RRTy (mapM (mapSndM (mapPropM f)) xts) (return r) (return o) (mapPropM f t)
-
-
---------------------------------------------------------------------------------
--- foldReft :: (F.Reftable r, TyConable c) => (r -> a -> a) -> a -> RType c tv r -> a
---------------------------------------------------------------------------------
--- foldReft f = efoldReft (\_ _ -> []) (\_ -> ()) (\_ _ -> f) (\_ γ -> γ) emptyF.SEnv
-
---------------------------------------------------------------------------------
-foldReft :: (F.Reftable r, TyConable c) => BScope -> (F.SEnv (RType c tv r) -> r -> a -> a) -> a -> RType c tv r -> a
---------------------------------------------------------------------------------
-foldReft  bsc f = foldReft' (\_ _ -> False) bsc id (\γ _ -> f γ)
-
---------------------------------------------------------------------------------
-foldReft' :: (F.Reftable r, TyConable c)
-          => (Symbol -> RType c tv r -> Bool)
-          -> BScope
-          -> (RType c tv r -> b)
-          -> (F.SEnv b -> Maybe (RType c tv r) -> r -> a -> a)
-          -> a -> RType c tv r -> a
---------------------------------------------------------------------------------
-foldReft' logicBind bsc g f 
-  = efoldReft logicBind bsc 
-              (\_ _ -> [])
-              (\_ -> [])
-              g
-              (\γ t r z -> f γ t r z)
-              (\_ γ -> γ)
-              F.emptySEnv
-
-
-
--- efoldReft :: F.Reftable r =>(p -> [RType c tv r] -> [(Symbol, a)])-> (RType c tv r -> a)-> (SEnv a -> Maybe (RType c tv r) -> r -> c1 -> c1)-> SEnv a-> c1-> RType c tv r-> c1
-efoldReft :: (F.Reftable r, TyConable c)
-          => (Symbol -> RType c tv r -> Bool)
-          -> BScope
-          -> (c  -> [RType c tv r] -> [(Symbol, a)])
-          -> (RTVar tv (RType c tv ()) -> [(Symbol, a)])
-          -> (RType c tv r -> a)
-          -> (F.SEnv a -> Maybe (RType c tv r) -> r -> b -> b)
-          -> (PVar (RType c tv ()) -> F.SEnv a -> F.SEnv a)
-          -> F.SEnv a
-          -> b
-          -> RType c tv r
-          -> b
-efoldReft logicBind bsc cb dty g f fp = go
-  where
-    -- folding over RType
-    go γ z me@(RVar _ r)                = f γ (Just me) r z
-    go γ z me@(RAllT a t r)
-       | ty_var_is_val a                = f γ (Just me) r (go (insertsSEnv γ (dty a)) z t)
-       | otherwise                      = f γ (Just me) r (go γ z t)
-    go γ z (RAllP p t)                  = go (fp p γ) z t
-    go γ z (RImpF x t t' r)             = go γ z (RFun x t t' r)
-    go γ z me@(RFun _ (RApp c ts _ _) t' r)
-       | isClass c                      = f γ (Just me) r (go (insertsSEnv γ (cb c ts)) (go' γ z ts) t')
-    go γ z me@(RFun x t t' r)
-       | logicBind x t                  = f γ (Just me) r (go γ' (go γ z t) t')
-       | otherwise                      = f γ (Just me) r (go γ  (go γ z t) t')
-       where
-         γ'                             = insertSEnv x (g t) γ
-    go γ z me@(RApp _ ts rs r)          = f γ (Just me) r (ho' γ (go' γ' z ts) rs)
-       where γ' = if bsc then insertSEnv (rTypeValueVar me) (g me) γ else γ 
-
-    go γ z (RAllE x t t')               = go (insertSEnv x (g t) γ) (go γ z t) t'
-    go γ z (REx x t t')                 = go (insertSEnv x (g t) γ) (go γ z t) t'
-    go γ z me@(RRTy [] r _ t)           = f γ (Just me) r (go γ z t)
-    go γ z me@(RRTy xts r _ t)          = f γ (Just me) r (go γ (go γ z (envtoType xts)) t)
-    go γ z me@(RAppTy t t' r)           = f γ (Just me) r (go γ (go γ z t) t')
-    go _ z (RExprArg _)                 = z
-    go γ z me@(RHole r)                 = f γ (Just me) r z
-
-    -- folding over Ref
-    ho  γ z (RProp ss (RHole r))       = f (insertsSEnv γ (mapSnd (g . ofRSort) <$> ss)) Nothing r z
-    ho  γ z (RProp ss t)               = go (insertsSEnv γ ((mapSnd (g . ofRSort)) <$> ss)) z t
-
-    -- folding over [RType]
-    go' γ z ts                 = foldr (flip $ go γ) z ts
-
-    -- folding over [Ref]
-    ho' γ z rs                 = foldr (flip $ ho γ) z rs
-
-    envtoType xts = foldr (\(x,t1) t2 -> rFun x t1 t2) (snd $ last xts) (init xts)
-
-mapBot :: (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
-mapBot f (RAllT α t r)     = RAllT α (mapBot f t) r
-mapBot f (RAllP π t)       = RAllP π (mapBot f t)
-mapBot f (RImpF x t t' r)  = RImpF x (mapBot f t) (mapBot f t') r
-mapBot f (RFun x t t' r)   = RFun x (mapBot f t) (mapBot f t') r
-mapBot f (RAppTy t t' r)   = RAppTy (mapBot f t) (mapBot f t') r
-mapBot f (RApp c ts rs r)  = f $ RApp c (mapBot f <$> ts) (mapBotRef f <$> rs) r
-mapBot f (REx b t1 t2)     = REx b  (mapBot f t1) (mapBot f t2)
-mapBot f (RAllE b t1 t2)   = RAllE b  (mapBot f t1) (mapBot f t2)
-mapBot f (RRTy e r o t)    = RRTy (mapSnd (mapBot f) <$> e) r o (mapBot f t)
-mapBot f t'                = f t'
-
-mapBotRef :: (RType c tv r -> RType c tv r)
-          -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
-mapBotRef _ (RProp s (RHole r)) = RProp s $ RHole r
-mapBotRef f (RProp s t)    = RProp  s $ mapBot f t
-
-mapBind :: (Symbol -> Symbol) -> RType c tv r -> RType c tv r
-mapBind f (RAllT α t r)    = RAllT α (mapBind f t) r
-mapBind f (RAllP π t)      = RAllP π (mapBind f t)
-mapBind f (RImpF b t1 t2 r)= RImpF (f b)  (mapBind f t1) (mapBind f t2) r
-mapBind f (RFun b t1 t2 r) = RFun (f b)  (mapBind f t1) (mapBind f t2) r
-mapBind f (RApp c ts rs r) = RApp c (mapBind f <$> ts) (mapBindRef f <$> rs) r
-mapBind f (RAllE b t1 t2)  = RAllE  (f b) (mapBind f t1) (mapBind f t2)
-mapBind f (REx b t1 t2)    = REx    (f b) (mapBind f t1) (mapBind f t2)
-mapBind _ (RVar α r)       = RVar α r
-mapBind _ (RHole r)        = RHole r
-mapBind f (RRTy e r o t)   = RRTy e r o (mapBind f t)
-mapBind _ (RExprArg e)     = RExprArg e
-mapBind f (RAppTy t t' r)  = RAppTy (mapBind f t) (mapBind f t') r
-
-mapBindRef :: (Symbol -> Symbol)
-           -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
-mapBindRef f (RProp s (RHole r)) = RProp (mapFst f <$> s) (RHole r)
-mapBindRef f (RProp s t)         = RProp (mapFst f <$> s) $ mapBind f t
-
-
---------------------------------------------------
-ofRSort ::  F.Reftable r => RType c tv () -> RType c tv r
-ofRSort = fmap mempty
-
-toRSort :: RType c tv r -> RType c tv ()
-toRSort = stripAnnotations . mapBind (const F.dummySymbol) . fmap (const ())
-
-stripAnnotations :: RType c tv r -> RType c tv r
-stripAnnotations (RAllT α t r)    = RAllT α (stripAnnotations t) r
-stripAnnotations (RAllP _ t)      = stripAnnotations t
-stripAnnotations (RAllE _ _ t)    = stripAnnotations t
-stripAnnotations (REx _ _ t)      = stripAnnotations t
-stripAnnotations (RImpF x t t' r) = RImpF x (stripAnnotations t) (stripAnnotations t') r
-stripAnnotations (RFun x t t' r)  = RFun x (stripAnnotations t) (stripAnnotations t') r
-stripAnnotations (RAppTy t t' r)  = RAppTy (stripAnnotations t) (stripAnnotations t') r
-stripAnnotations (RApp c ts rs r) = RApp c (stripAnnotations <$> ts) (stripAnnotationsRef <$> rs) r
-stripAnnotations (RRTy _ _ _ t)   = stripAnnotations t
-stripAnnotations t                = t
-
-stripAnnotationsRef :: Ref τ (RType c tv r) -> Ref τ (RType c tv r)
-stripAnnotationsRef (RProp s (RHole r)) = RProp s (RHole r)
-stripAnnotationsRef (RProp s t)         = RProp s $ stripAnnotations t
-
-insertSEnv :: F.Symbol -> a -> F.SEnv a -> F.SEnv a
-insertSEnv = F.insertSEnv
-
-insertsSEnv :: F.SEnv a -> [(Symbol, a)] -> F.SEnv a
-insertsSEnv  = foldr (\(x, t) γ -> insertSEnv x t γ)
-
-rTypeValueVar :: (F.Reftable r) => RType c tv r -> Symbol
-rTypeValueVar t = vv where F.Reft (vv,_) =  rTypeReft t
-
-rTypeReft :: (F.Reftable r) => RType c tv r -> F.Reft
-rTypeReft = fromMaybe F.trueReft . fmap F.toReft . stripRTypeBase
-
--- stripRTypeBase ::  RType a -> Maybe a
-stripRTypeBase :: RType c tv r -> Maybe r
-stripRTypeBase (RApp _ _ _ x)
-  = Just x
-stripRTypeBase (RVar _ x)
-  = Just x
-stripRTypeBase (RImpF _ _ _ x)
-  = Just x
-stripRTypeBase (RFun _ _ _ x)
-  = Just x
-stripRTypeBase (RAppTy _ _ x)
-  = Just x
-stripRTypeBase (RAllT _ _ x)
-  = Just x 
-stripRTypeBase _
-  = Nothing
-
-topRTypeBase :: (F.Reftable r) => RType c tv r -> RType c tv r
-topRTypeBase = mapRBase F.top
-
-mapRBase :: (r -> r) -> RType c tv r -> RType c tv r
-mapRBase f (RApp c ts rs r) = RApp c ts rs $ f r
-mapRBase f (RVar a r)       = RVar a $ f r
-mapRBase f (RImpF x t1 t2 r)= RImpF x t1 t2 $ f r
-mapRBase f (RFun x t1 t2 r) = RFun x t1 t2 $ f r
-mapRBase f (RAppTy t1 t2 r) = RAppTy t1 t2 $ f r
-mapRBase _ t                = t
-
------------------------------------------------------------------------------
--- | F.PPrint -----------------------------------------------------------------
------------------------------------------------------------------------------
-
-instance F.PPrint (PVar a) where
-  pprintTidy _ = ppr_pvar
-
-ppr_pvar :: PVar a -> Doc
-ppr_pvar (PV s _ _ xts) = F.pprint s <+> hsep (F.pprint <$> dargs xts)
-  where
-    dargs               = map thd3 . takeWhile (\(_, x, y) -> F.EVar x /= y)
-
-
-instance F.PPrint Predicate where
-  pprintTidy _ (Pr [])  = text "True"
-  pprintTidy k (Pr pvs) = hsep $ punctuate (text "&") (F.pprintTidy k <$> pvs)
-
-
--- | The type used during constraint generation, used
---   also to define contexts for errors, hence in this
---   file, and NOT in elsewhere. **DO NOT ATTEMPT TO MOVE**
---   Am splitting into
---   + global : many bindings, shared across all constraints
---   + local  : few bindings, relevant to particular constraints
-
-type REnv = AREnv SpecType 
-
-data AREnv t = REnv
-  { reGlobal :: M.HashMap Symbol t -- ^ the "global" names for module
-  , reLocal  :: M.HashMap Symbol t -- ^ the "local" names for sub-exprs
-  }
-
-instance Functor AREnv where 
-  fmap f (REnv g l) = REnv (fmap f g) (fmap f l)
-
-instance (F.PPrint t) => F.PPrint (AREnv t) where
-  pprintTidy k re = "RENV LOCAL" $+$ F.pprintTidy k (reLocal re) <>
-                    "\nRENV GLOBAL" $+$ F.pprintTidy k (reGlobal re)
-  
-
-instance Semigroup REnv where 
-  REnv g1 l1 <> REnv g2 l2 = REnv (g1 <> g2) (l1 <> l2)  
-
-instance Monoid REnv where 
-  mempty = REnv mempty mempty
-
-instance NFData REnv where
-  rnf (REnv {}) = ()
-
---------------------------------------------------------------------------------
--- | Diagnostic info -----------------------------------------------------------
---------------------------------------------------------------------------------
-
-data Warning = Warning {
-    warnSpan :: SrcSpan
-  , warnDoc  :: Doc
-  } deriving (Eq, Show)
-
-mkWarning :: SrcSpan -> Doc -> Warning
-mkWarning = Warning
-
-data Diagnostics = Diagnostics {
-    dWarnings :: [Warning]
-  , dErrors   :: [Error]
-  } deriving Eq
-
-instance Semigroup Diagnostics where
-  (Diagnostics w1 e1) <> (Diagnostics w2 e2) = Diagnostics (w1 <> w2) (e1 <> e2)
-
-instance Monoid Diagnostics where
-  mempty  = emptyDiagnostics
-  mappend = (<>)
-
-mkDiagnostics :: [Warning] -> [Error] -> Diagnostics
-mkDiagnostics = Diagnostics
-
-emptyDiagnostics :: Diagnostics
-emptyDiagnostics = Diagnostics mempty mempty
-
-noErrors :: Diagnostics -> Bool
-noErrors = L.null . dErrors
-
-allWarnings :: Diagnostics -> [Warning]
-allWarnings = dWarnings
-
-allErrors :: Diagnostics -> [Error]
-allErrors = dErrors
-
---------------------------------------------------------------------------------
--- | Printing Warnings ---------------------------------------------------------
---------------------------------------------------------------------------------
-
-printWarning :: DynFlags -> Warning -> IO ()
-printWarning dyn (Warning span doc) = GHC.putWarnMsg dyn span doc
-
---------------------------------------------------------------------------------
--- | Error Data Type -----------------------------------------------------------
---------------------------------------------------------------------------------
-
-type ErrorResult    = F.FixResult UserError
-type Error          = TError SpecType
-
-
-instance NFData a => NFData (TError a)
-
---------------------------------------------------------------------------------
--- | Source Information Associated With Constraints ----------------------------
---------------------------------------------------------------------------------
-
-data Cinfo    = Ci { ci_loc :: !SrcSpan
-                   , ci_err :: !(Maybe Error)
-                   , ci_var :: !(Maybe Var)
-                   }
-                deriving (Eq, Ord, Generic)
-
-instance F.Loc Cinfo where
-  srcSpan = srcSpanFSrcSpan . ci_loc
-
-instance NFData Cinfo
-
---------------------------------------------------------------------------------
--- | Module Names --------------------------------------------------------------
---------------------------------------------------------------------------------
-
-data ModName = ModName !ModType !ModuleName 
-  deriving (Eq, Ord, Show, Generic, Data, Typeable)
-
-data ModType = Target | SrcImport | SpecImport 
-  deriving (Eq, Ord, Show, Generic, Data, Typeable)
-
--- instance B.Binary ModType 
--- instance B.Binary ModName 
-
-instance Hashable ModType 
-
-instance Hashable ModuleName where
-  hashWithSalt i = hashWithSalt i . show
-
-instance Hashable ModName where
-  hashWithSalt i (ModName t n) = hashWithSalt i (t, show n)
-
-instance F.PPrint ModName where
-  pprintTidy _ = text . show
-
-instance Show ModuleName where
-  show = moduleNameString
-
-instance F.Symbolic ModName where
-  symbol (ModName _ m) = F.symbol m
-
-instance F.Symbolic ModuleName where
-  symbol = F.symbol . moduleNameFS
-
-
-isTarget :: ModName -> Bool 
-isTarget (ModName Target _) = True 
-isTarget _                  = False 
-
-isSrcImport :: ModName -> Bool
-isSrcImport (ModName SrcImport _) = True
-isSrcImport _                     = False
-
-isSpecImport :: ModName -> Bool
-isSpecImport (ModName SpecImport _) = True
-isSpecImport _                      = False
-
-getModName :: ModName -> ModuleName
-getModName (ModName _ m) = m
-
-getModString :: ModName -> String
-getModString = moduleNameString . getModName
-
-qualifyModName :: ModName -> Symbol -> Symbol
-qualifyModName n = qualifySymbol nSym
-  where
-    nSym         = F.symbol n
-
---------------------------------------------------------------------------------
--- | Refinement Type Aliases ---------------------------------------------------
---------------------------------------------------------------------------------
-data RTEnv tv t = RTE
-  { typeAliases :: M.HashMap Symbol (F.Located (RTAlias tv t))
-  , exprAliases :: M.HashMap Symbol (F.Located (RTAlias Symbol Expr))
-  }
-
-
-instance Monoid (RTEnv tv t) where
-  mempty  = RTE M.empty M.empty
-  mappend = (<>)
-
-instance Semigroup (RTEnv tv t) where
-  RTE x y <> RTE x' y' = RTE (x `M.union` x') (y `M.union` y')
-
--- mapRT :: (M.HashMap Symbol (RTAlias tv t) -> M.HashMap Symbol (RTAlias tv t)) 
---      -> RTEnv tv t -> RTEnv tv t
--- mapRT f e = e { typeAliases = f (typeAliases e) }
-
--- mapRE :: (M.HashMap Symbol (RTAlias Symbol Expr)
---       -> M.HashMap Symbol (RTAlias Symbol Expr))
---      -> RTEnv tv t -> RTEnv tv t
--- mapRE f e = e { exprAliases = f $ exprAliases e }
-
-
---------------------------------------------------------------------------------
--- | Measures
---------------------------------------------------------------------------------
-data Body
-  = E Expr          -- ^ Measure Refinement: {v | v = e }
-  | P Expr          -- ^ Measure Refinement: {v | (? v) <=> p }
-  | R Symbol Expr   -- ^ Measure Refinement: {v | p}
-  deriving (Show, Data, Typeable, Generic, Eq)
-  deriving Hashable via Generically Body
-
-data Def ty ctor = Def
-  { measure :: F.LocSymbol
-  , ctor    :: ctor
-  , dsort   :: Maybe ty
-  , binds   :: [(Symbol, Maybe ty)]    -- measure binders: the ADT argument fields
-  , body    :: Body
-  } deriving (Show, Data, Typeable, Generic, Eq, Functor)
-    deriving Hashable via Generically (Def ty ctor)
-
-data Measure ty ctor = M
-  { msName :: F.LocSymbol
-  , msSort :: ty
-  , msEqns :: [Def ty ctor]
-  , msKind :: !MeasureKind 
-  , msUnSorted :: !UnSortedExprs -- potential unsorted expressions used at measure denifinitions
-  } deriving (Eq, Data, Typeable, Generic, Functor)
-    deriving Hashable via Generically (Measure ty ctor)
-
-type UnSortedExprs = [UnSortedExpr] -- mempty = []
-type UnSortedExpr  = ([F.Symbol], F.Expr)
-
-data MeasureKind 
-  = MsReflect     -- ^ due to `reflect foo` 
-  | MsMeasure     -- ^ due to `measure foo` with old-style (non-haskell) equations
-  | MsLifted      -- ^ due to `measure foo` with new-style haskell equations
-  | MsClass       -- ^ due to `class measure` definition 
-  | MsAbsMeasure  -- ^ due to `measure foo` without equations c.f. tests/pos/T1223.hs
-  | MsSelector    -- ^ due to selector-fields e.g. `data Foo = Foo { fld :: Int }` 
-  | MsChecker     -- ^ due to checkers  e.g. `is-F` for `data Foo = F ... | G ...` 
-  deriving (Eq, Ord, Show, Data, Typeable, Generic)
-  deriving Hashable via Generically MeasureKind
-
-instance F.Loc (Measure a b) where 
-  srcSpan = F.srcSpan . msName
-
-instance Bifunctor Def where
-  -- first f  (Def m ps c s bs b) = Def m (second f <$> ps) c (f <$> s) ((second (fmap f)) <$> bs) b
-  -- second f (Def m ps c s bs b) = Def m ps (f c) s bs b
-  first f  (Def m c s bs b) = Def m c (f <$> s) ((second (fmap f)) <$> bs) b
-  second f (Def m c s bs b) = Def m (f c) s bs b
-
-
-instance Bifunctor Measure where
-  first  f (M n s es k u) = M n (f s) (first f <$> es) k u
-  second f (M n s es k u) = M n s (second f <$> es)    k u 
-
-instance                             B.Binary MeasureKind 
-instance                             B.Binary Body
-instance (B.Binary t, B.Binary c) => B.Binary (Def     t c)
-instance (B.Binary t, B.Binary c) => B.Binary (Measure t c)
-
--- NOTE: don't use the TH versions since they seem to cause issues
--- building on windows :(
--- deriveBifunctor ''Def
--- deriveBifunctor ''Measure
-
-data CMeasure ty = CM
-  { cName :: F.LocSymbol
-  , cSort :: ty
-  } deriving (Data, Typeable, Generic, Functor)
-
-instance F.PPrint Body where
-  pprintTidy k (E e)   = F.pprintTidy k e
-  pprintTidy k (P p)   = F.pprintTidy k p
-  pprintTidy k (R v p) = braces (F.pprintTidy k v <+> "|" <+> F.pprintTidy k p)
-
-instance F.PPrint a => F.PPrint (Def t a) where
-  pprintTidy k (Def m c _ bs body)
-           = F.pprintTidy k m <+> cbsd <+> "=" <+> F.pprintTidy k body
-    where
-      cbsd = parens (F.pprintTidy k c <-> hsep (F.pprintTidy k `fmap` (fst <$> bs)))
-
-instance (F.PPrint t, F.PPrint a) => F.PPrint (Measure t a) where
-  pprintTidy k (M n s eqs _ _) =  F.pprintTidy k n <+> {- parens (pprintTidy k (loc n)) <+> -} "::" <+> F.pprintTidy k s
-                                  $$ vcat (F.pprintTidy k `fmap` eqs)
-
-
-instance F.PPrint (Measure t a) => Show (Measure t a) where
-  show = F.showpp
-
-instance F.PPrint t => F.PPrint (CMeasure t) where
-  pprintTidy k (CM n s) =  F.pprintTidy k n <+> "::" <+> F.pprintTidy k s
-
-instance F.PPrint (CMeasure t) => Show (CMeasure t) where
-  show = F.showpp
-
-
-instance F.Subable (Measure ty ctor) where
-  syms  m     = concatMap F.syms (msEqns m) 
-  substa f m  = m { msEqns = F.substa f  <$> msEqns m }
-  substf f m  = m { msEqns = F.substf f  <$> msEqns m }
-  subst  su m = m { msEqns = F.subst  su <$> msEqns m }
-  -- substa f  (M n s es _) = M n s (F.substa f  <$> es) k
-  -- substf f  (M n s es _) = M n s $ F.substf f  <$> es
-  -- subst  su (M n s es _) = M n s $ F.subst  su <$> es
-
-instance F.Subable (Def ty ctor) where
-  syms (Def _ _ _ sb bd)  = (fst <$> sb) ++ F.syms bd
-  substa f  (Def m c t b bd) = Def m c t b $ F.substa f  bd
-  substf f  (Def m c t b bd) = Def m c t b $ F.substf f  bd
-  subst  su (Def m c t b bd) = Def m c t b $ F.subst  su bd
-
-instance F.Subable Body where
-  syms (E e)       = F.syms e
-  syms (P e)       = F.syms e
-  syms (R s e)     = s : F.syms e
-
-  substa f (E e)   = E   (F.substa f e)
-  substa f (P e)   = P   (F.substa f e)
-  substa f (R s e) = R s (F.substa f e)
-
-  substf f (E e)   = E   (F.substf f e)
-  substf f (P e)   = P   (F.substf f e)
-  substf f (R s e) = R s (F.substf f e)
-
-  subst su (E e)   = E   (F.subst su e)
-  subst su (P e)   = P   (F.subst su e)
-  subst su (R s e) = R s (F.subst su e)
-
-instance F.Subable t => F.Subable (WithModel t) where
-  syms (NoModel t)     = F.syms t
-  syms (WithModel _ t) = F.syms t
-  substa f             = fmap (F.substa f)
-  substf f             = fmap (F.substf f)
-  subst su             = fmap (F.subst su)
-
-data RClass ty = RClass
-  { rcName    :: BTyCon
-  , rcSupers  :: [ty]
-  , rcTyVars  :: [BTyVar]
-  , rcMethods :: [(F.LocSymbol, ty)]
-  } deriving (Eq, Show, Functor, Data, Typeable, Generic)
-    deriving Hashable via Generically (RClass ty)
-
-
-instance F.PPrint t => F.PPrint (RClass t) where 
-  pprintTidy k (RClass n ts as mts) 
-                = ppMethods k ("class" <+> supers ts) n as [(m, RISig t) | (m, t) <- mts] 
-    where 
-      supers [] = "" 
-      supers ts = tuplify (F.pprintTidy k   <$> ts) <+> "=>"
-      tuplify   = parens . hcat . punctuate ", "
-
-
-instance F.PPrint t => F.PPrint (RILaws t) where
-  pprintTidy k (RIL n ss ts mts _) = ppEqs k ("instance laws" <+> supers ss) n ts mts 
-   where 
-    supers [] = "" 
-    supers ts = tuplify (F.pprintTidy k   <$> ts) <+> "=>"
-    tuplify   = parens . hcat . punctuate ", "
-
-
-ppEqs :: (F.PPrint x, F.PPrint t, F.PPrint a, F.PPrint n) 
-          => F.Tidy -> Doc -> n -> [a] -> [(x, t)] -> Doc
-ppEqs k hdr name args mts 
-  = vcat $ hdr <+> dName <+> "where" 
-         : [ nest 4 (bind m t) | (m, t) <- mts ] 
-    where 
-      dName    = parens  (F.pprintTidy k name <+> dArgs)
-      dArgs    = gaps    (F.pprintTidy k      <$> args)
-      gaps     = hcat . punctuate " "
-      bind m t = F.pprintTidy k m <+> "=" <+> F.pprintTidy k t 
-
-ppMethods :: (F.PPrint x, F.PPrint t, F.PPrint a, F.PPrint n) 
-          => F.Tidy -> Doc -> n -> [a] -> [(x, RISig t)] -> Doc
-ppMethods k hdr name args mts 
-  = vcat $ hdr <+> dName <+> "where" 
-         : [ nest 4 (bind m t) | (m, t) <- mts ] 
-    where 
-      dName    = parens  (F.pprintTidy k name <+> dArgs)
-      dArgs    = gaps    (F.pprintTidy k      <$> args)
-      gaps     = hcat . punctuate " "
-      bind m t = ppRISig k m t -- F.pprintTidy k m <+> "::" <+> F.pprintTidy k t 
-
-instance B.Binary ty => B.Binary (RClass ty)
-
-
-------------------------------------------------------------------------
--- | Var Hole Info -----------------------------------------------------
-------------------------------------------------------------------------
-
-data HoleInfo i t = HoleInfo {htype :: t, hloc :: SrcSpan, henv :: AREnv t, info :: i }
-
-instance Functor (HoleInfo i) where 
-  fmap f hinfo = hinfo{htype = f (htype hinfo), henv = fmap f (henv hinfo)}
-
-instance (F.PPrint t) => F.PPrint (HoleInfo  i t) where
-  pprintTidy k hinfo = text "type:" <+> F.pprintTidy k (htype hinfo) 
-                       <+> text "\n loc:" <+> F.pprintTidy k (hloc hinfo) 
-  -- to print the hole environment uncomment the following
-  --                     <+> text "\n env:" <+> F.pprintTidy k (henv hinfo)
-
-------------------------------------------------------------------------
--- | Annotations -------------------------------------------------------
-------------------------------------------------------------------------
-
-newtype AnnInfo a = AI (M.HashMap SrcSpan [(Maybe Text, a)])
-                    deriving (Data, Typeable, Generic, Functor)
-
-data Annot t
-  = AnnUse t
-  | AnnDef t
-  | AnnRDf t
-  | AnnLoc SrcSpan
-  deriving (Data, Typeable, Generic, Functor)
-
-instance Monoid (AnnInfo a) where
-  mempty  = AI M.empty
-  mappend = (<>)
-
-instance Semigroup (AnnInfo a) where
-  AI m1 <> AI m2 = AI $ M.unionWith (++) m1 m2
-
-instance NFData a => NFData (AnnInfo a)
-
-instance NFData a => NFData (Annot a)
-
---------------------------------------------------------------------------------
--- | Output --------------------------------------------------------------------
---------------------------------------------------------------------------------
-
-data Output a = O
-  { o_vars   :: Maybe [String]
-  , o_types  :: !(AnnInfo a)
-  , o_templs :: !(AnnInfo a)
-  , o_bots   :: ![SrcSpan]
-  , o_result :: ErrorResult
-  } deriving (Typeable, Generic, Functor)
-
-emptyOutput :: Output a
-emptyOutput = O Nothing mempty mempty [] mempty
-
-instance Monoid (Output a) where
-  mempty  = emptyOutput
-  mappend = (<>)
-
-instance Semigroup (Output a) where
-  o1 <> o2 = O { o_vars   = sortNub <$> mappend (o_vars   o1) (o_vars   o2)
-               , o_types  =             mappend (o_types  o1) (o_types  o2)
-               , o_templs =             mappend (o_templs o1) (o_templs o2)
-               , o_bots   = sortNub  $  mappend (o_bots o1)   (o_bots   o2)
-               , o_result =             mappend (o_result o1) (o_result o2)
-               }
-
---------------------------------------------------------------------------------
--- | KVar Profile --------------------------------------------------------------
---------------------------------------------------------------------------------
-
-data KVKind
-  = RecBindE    Var -- ^ Recursive binder      @letrec x = ...@
-  | NonRecBindE Var -- ^ Non recursive binder  @let x = ...@
-  | TypeInstE
-  | PredInstE
-  | LamE
-  | CaseE       Int -- ^ Int is the number of cases
-  | LetE
-  | ImplictE
-  | ProjectE        -- ^ Projecting out field of
-  deriving (Generic, Eq, Ord, Show, Data, Typeable)
-
-instance Hashable KVKind
-
-newtype KVProf = KVP (M.HashMap KVKind Int) deriving (Generic)
-
-emptyKVProf :: KVProf
-emptyKVProf = KVP M.empty
-
-updKVProf :: KVKind -> F.Kuts -> KVProf -> KVProf
-updKVProf k kvs (KVP m) = KVP $ M.insert k (kn + n) m
-  where
-    kn                  = M.lookupDefault 0 k m
-    n                   = S.size (F.ksVars kvs)
-
-instance NFData KVKind
-
-instance F.PPrint KVKind where
-  pprintTidy _ = text . show
-
-instance F.PPrint KVProf where
-  pprintTidy k (KVP m) = F.pprintTidy k (M.toList m)
-
-instance NFData KVProf
-
-hole :: Expr
-hole = F.PKVar "HOLE" mempty
-
-isHole :: Expr -> Bool
-isHole (F.PKVar ("HOLE") _) = True
-isHole _                    = False
-
-hasHole :: F.Reftable r => r -> Bool
-hasHole = any isHole . F.conjuncts . F.reftPred . F.toReft
-
-instance F.Symbolic DataCon where
-  symbol = F.symbol . dataConWorkId
-
-instance F.PPrint DataCon where
-  pprintTidy _ = text . showPpr
-
-instance Ord TyCon where 
-  compare = compare `on` F.symbol 
-
-instance Ord DataCon where 
-  compare = compare `on` F.symbol 
-
-instance F.PPrint TyThing where 
-  pprintTidy _ = text . showPpr 
-
-instance Show DataCon where
-  show = F.showpp
-
--- instance F.Symbolic TyThing where 
---  symbol = tyThingSymbol 
-
-liquidBegin :: String
-liquidBegin = ['{', '-', '@']
-
-liquidEnd :: String
-liquidEnd = ['@', '-', '}']
-
-data MSpec ty ctor = MSpec
-  { ctorMap  :: M.HashMap Symbol [Def ty ctor]
-  , measMap  :: M.HashMap F.LocSymbol (Measure ty ctor)
-  , cmeasMap :: M.HashMap F.LocSymbol (Measure ty ())
-  , imeas    :: ![Measure ty ctor]
-  } deriving (Data, Typeable, Generic, Functor)
-
-instance Bifunctor MSpec   where
-  first f (MSpec c m cm im) = MSpec (fmap (fmap (first f)) c)
-                                    (fmap (first f) m)
-                                    (fmap (first f) cm)
-                                    (fmap (first f) im)
-  second                    = fmap
-
-instance (F.PPrint t, F.PPrint a) => F.PPrint (MSpec t a) where
-  pprintTidy k =  vcat . fmap (F.pprintTidy k) . fmap snd . M.toList . measMap
-
-instance (Show ty, Show ctor, F.PPrint ctor, F.PPrint ty) => Show (MSpec ty ctor) where
-  show (MSpec ct m cm im)
-    = "\nMSpec:\n" ++
-      "\nctorMap:\t "  ++ show ct ++
-      "\nmeasMap:\t "  ++ show m  ++
-      "\ncmeasMap:\t " ++ show cm ++
-      "\nimeas:\t "    ++ show im ++
-      "\n"
-
-instance Eq ctor => Semigroup (MSpec ty ctor) where
-  MSpec c1 m1 cm1 im1 <> MSpec c2 m2 cm2 im2
-    | (k1, k2) : _ <- dups
-      -- = panic Nothing $ err (head dups)
-    = uError $ err k1 k2
-    | otherwise
-    = MSpec (M.unionWith (++) c1 c2) (m1 `M.union` m2) (cm1 `M.union` cm2) (im1 ++ im2)
-    where
-      dups = [(k1, k2) | k1 <- M.keys m1 , k2 <- M.keys m2, F.val k1 == F.val k2]
-      err k1 k2 = ErrDupMeas (fSrcSpan k1) (F.pprint (F.val k1)) (fSrcSpan <$> [k1, k2])
-
-
-instance Eq ctor => Monoid (MSpec ty ctor) where
-  mempty = MSpec M.empty M.empty M.empty []
-  mappend = (<>)
-
-
-
---------------------------------------------------------------------------------
--- Nasty PP stuff
---------------------------------------------------------------------------------
-
-instance F.PPrint BTyVar where
-  pprintTidy _ (BTV α) = text (F.symbolString α)
-
-instance F.PPrint RTyVar where
-  pprintTidy k (RTV α)
-   | ppTyVar ppEnv  = F.pprintTidy k (F.symbol α) -- shows full tyvar
-   | otherwise      = ppr_tyvar_short α           -- drops the unique-suffix
-   where
-     ppr_tyvar_short :: TyVar -> Doc
-     ppr_tyvar_short = text . showPpr
-
-instance (F.PPrint r, F.Reftable r, F.PPrint t, F.PPrint (RType c tv r)) => F.PPrint (Ref t (RType c tv r)) where
-  pprintTidy k (RProp ss s) = ppRefArgs k (fst <$> ss) <+> F.pprintTidy k s
-
-ppRefArgs :: F.Tidy -> [Symbol] -> Doc
-ppRefArgs _ [] = empty
-ppRefArgs k ss = text "\\" <-> hsep (ppRefSym k <$> ss ++ [F.vv Nothing]) <+> "->"
-
-ppRefSym :: (Eq a, IsString a, F.PPrint a) => F.Tidy -> a -> Doc
-ppRefSym _ "" = text "_"
-ppRefSym k s  = F.pprintTidy k s
diff --git a/src/Language/Haskell/Liquid/Types/Variance.hs b/src/Language/Haskell/Liquid/Types/Variance.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Variance.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DeriveGeneric      #-}
-{-# LANGUAGE DerivingStrategies #-}
-{-# LANGUAGE DerivingVia #-}
-
-module Language.Haskell.Liquid.Types.Variance ( Variance(..), VarianceInfo ) where
-
-import Prelude hiding (error)
-import Control.DeepSeq
-import Data.Typeable
-import Data.Data
-import GHC.Generics
-import Data.Binary
-import Data.Hashable
-import Text.PrettyPrint.HughesPJ
-import qualified Language.Fixpoint.Types as F
-
-import Language.Haskell.Liquid.Types.Generics
-
-type VarianceInfo = [Variance]
-
-data Variance = Invariant | Bivariant | Contravariant | Covariant
-              deriving (Eq, Data, Typeable, Show, Generic)
-              deriving Hashable via Generically Variance
-
-instance Binary Variance
-instance NFData Variance
-instance F.PPrint Variance where
-  pprintTidy _ = text . show
diff --git a/src/Language/Haskell/Liquid/Types/Visitors.hs b/src/Language/Haskell/Liquid/Types/Visitors.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/Types/Visitors.hs
+++ /dev/null
@@ -1,200 +0,0 @@
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE FlexibleContexts          #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE DeriveDataTypeable        #-}
-{-# LANGUAGE ScopedTypeVariables       #-}
-
-
-module Language.Haskell.Liquid.Types.Visitors (
-  
-  CBVisitable (..)
-  
-  -- * visitors
-  , coreVisitor 
-  , CoreVisitor (..)
-
-  ) where
-
-import           CoreSyn
-import           Data.Hashable
-import           DataCon
-
-import           Data.List                        (foldl', (\\), delete)
-import qualified Data.HashSet                     as S
-import           Prelude                          hiding (error)
-import           Language.Fixpoint.Misc
-import           Language.Haskell.Liquid.GHC.API
-import           Language.Haskell.Liquid.GHC.Misc ()
-
-
-------------------------------------------------------------------------------
--------------------------------- A CoreBind Visitor --------------------------
-------------------------------------------------------------------------------
-
--- TODO: syb-shrinkage
-
-class CBVisitable a where
-  freeVars :: S.HashSet Var -> a -> [Var]
-  readVars :: a -> [Var]
-  letVars  :: a -> [Var]
-  literals :: a -> [Literal]
-
-instance CBVisitable [CoreBind] where
-  freeVars env cbs = (sortNub xs) \\ ys
-    where xs = concatMap (freeVars env) cbs
-          ys = concatMap bindings cbs
-
-  readVars = concatMap readVars
-  letVars  = concatMap letVars
-  literals = concatMap literals
-
-instance CBVisitable CoreBind where
-  freeVars env (NonRec x e) = freeVars (extendEnv env [x]) e
-  freeVars env (Rec xes)    = concatMap (freeVars env') es
-                              where (xs,es) = unzip xes
-                                    env'    = extendEnv env xs
-
-  readVars (NonRec _ e)     = readVars e
-  readVars (Rec xes)        = concat [x `delete` nubReadVars e |(x, e) <- xes]
-    where nubReadVars = sortNub . readVars
-
-  letVars (NonRec x e)      = x : letVars e
-  letVars (Rec xes)         = xs ++ concatMap letVars es
-    where
-      (xs, es)              = unzip xes
-
-  literals (NonRec _ e)      = literals e
-  literals (Rec xes)         = concatMap (literals . snd) xes
-
-instance CBVisitable (Expr Var) where
-  freeVars = exprFreeVars
-  readVars = exprReadVars
-  letVars  = exprLetVars
-  literals = exprLiterals
-
-exprFreeVars :: S.HashSet Id -> Expr Id -> [Id]
-exprFreeVars = go
-  where
-    go env (Var x)         = if x `S.member` env then [] else [x]
-    go env (App e a)       = go env e ++ go env a
-    go env (Lam x e)       = go (extendEnv env [x]) e
-    go env (Let b e)       = freeVars env b ++ go (extendEnv env (bindings b)) e
-    go env (Tick _ e)      = go env e
-    go env (Cast e _)      = go env e
-    go env (Case e x _ cs) = go env e ++ concatMap (freeVars (extendEnv env [x])) cs
-    go _   _               = []
-
-exprReadVars :: (CBVisitable (Alt t), CBVisitable (Bind t)) => Expr t -> [Id]
-exprReadVars = go
-  where
-    go (Var x)             = [x]
-    go (App e a)           = concatMap go [e, a]
-    go (Lam _ e)           = go e
-    go (Let b e)           = readVars b ++ go e
-    go (Tick _ e)          = go e
-    go (Cast e _)          = go e
-    go (Case e _ _ cs)     = go e ++ concatMap readVars cs
-    go _                   = []
-
-exprLetVars :: Expr Var -> [Var]
-exprLetVars = go
-  where
-    go (Var _)             = []
-    go (App e a)           = concatMap go [e, a]
-    go (Lam x e)           = x : go e
-    go (Let b e)           = letVars b ++ go e
-    go (Tick _ e)          = go e
-    go (Cast e _)          = go e
-    go (Case e x _ cs)     = x : go e ++ concatMap letVars cs
-    go _                   = []
-
-exprLiterals :: (CBVisitable (Alt t), CBVisitable (Bind t))
-             => Expr t -> [Literal]
-exprLiterals = go
-  where
-    go (Lit l)             = [l]
-    go (App e a)           = concatMap go [e, a]
-    go (Let b e)           = literals b ++ go e
-    go (Lam _ e)           = go e
-    go (Tick _ e)          = go e
-    go (Cast e _)          = go e
-    go (Case e _ _ cs)     = go e ++ concatMap literals cs
-    go (Type t)            = go' t
-    go _                   = []
-
-    go' (LitTy tl)         = [tyLitToLit tl]
-    go' _                  = []
-
-
-    tyLitToLit (StrTyLit fs) = LitString (bytesFS fs)
-    tyLitToLit (NumTyLit i)  = LitNumber LitNumInt (fromIntegral i) intPrimTy
-
-
-
-instance CBVisitable (Alt Var) where
-  freeVars env (a, xs, e) = freeVars env a ++ freeVars (extendEnv env xs) e
-  readVars (_,_, e)       = readVars e
-  letVars  (_,xs,e)       = xs ++ letVars e
-  literals (c,_, e)       = literals c ++ literals e
-
-instance CBVisitable AltCon where
-  freeVars _ (DataAlt dc) = [ x | AnId x <- dataConImplicitTyThings dc]
-  freeVars _ _            = []
-  readVars _              = []
-  letVars  _              = []
-  literals (LitAlt l)     = [l]
-  literals _              = []
-
-extendEnv :: (Eq a, Hashable a) => S.HashSet a -> [a] -> S.HashSet a
-extendEnv = foldl' (flip S.insert)
-
-bindings :: Bind t -> [t]
-bindings (NonRec x _) = [x]
-bindings (Rec  xes  ) = map fst xes
-
-----------------------------------------------------------------------------------------
--- | @BindVisitor@ allows for generic, context sensitive traversals over the @CoreBinds@ 
-----------------------------------------------------------------------------------------
-data CoreVisitor env acc = CoreVisitor 
-  { envF  :: env -> Var             -> env 
-  , bindF :: env -> acc -> Var      -> acc  
-  , exprF :: env -> acc -> CoreExpr -> acc 
-  }
-
-coreVisitor :: (CoreVisitor env acc) -> env -> acc -> [CoreBind] -> acc
-coreVisitor vis env acc cbs   = snd (foldl' step (env, acc) cbs) 
-  where
-    stepXE (env, acc) (x,e)   = (env', stepE env' acc'   e)  
-      where 
-        env'                  = envF  vis env     x 
-        acc'                  = bindF vis env acc x  
-
-    step ea (NonRec x e)      = stepXE ea (x, e) 
-    step ea (Rec    xes)      = foldl' stepXE ea xes 
-
-    -- step (env, acc) (NonRec x e) = stepXE env acc x e 
-    -- step (env, acc) (Rec    xes) = (env', foldl' (stepE env') acc' es) 
-      -- where 
-        -- acc'                     = foldl' (bindF vis env') acc xs
-        -- env'                     = foldl' (envF  vis)      env xs 
-        -- xs                       = fst <$> xes 
-        -- es                       = snd <$> xes
-        -- foldl' (\(env, acc) (x, e) ->  )
-
-    stepE env acc e              = goE env (exprF vis env acc e) e 
-
-    goE _   acc (Var _)          = acc 
-    goE env acc (App e1 e2)      = stepE  env (stepE env acc e1) e2 
-    goE env acc (Tick _ e)       = stepE  env acc e 
-    goE env acc (Cast e _)       = stepE  env acc e  
-    goE env acc (Lam x e)        = snd (stepXE (env, acc) (x, e))
-    goE env acc (Let b e)        = stepE env' acc' e where (env', acc') = step (env, acc) b 
-    goE env acc (Case e _ _ cs)  = foldl' (goC env) (stepE env acc e) cs
-    goE _   acc _                = acc 
-
-    goC env acc (_, xs, e)       = stepE  env' acc' e 
-      where
-        env'                     = foldl' (envF  vis)     env xs 
-        acc'                     = foldl' (bindF vis env) acc xs
diff --git a/src/Language/Haskell/Liquid/UX/ACSS.hs b/src/Language/Haskell/Liquid/UX/ACSS.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/UX/ACSS.hs
+++ /dev/null
@@ -1,297 +0,0 @@
--- | Formats Haskell source code as HTML with CSS and Mouseover Type Annotations
-module Language.Haskell.Liquid.UX.ACSS (
-    hscolour
-  , hsannot
-  , AnnMap (..)
-  , breakS
-  , srcModuleName
-  , Status (..)
-  , tokeniseWithLoc
-  ) where
-
-import Prelude hiding (error)
-import qualified SrcLoc 
-
-import Language.Haskell.HsColour.Anchors
-import Language.Haskell.HsColour.Classify as Classify
-import Language.Haskell.HsColour.HTML (renderAnchors, escape)
-import qualified Language.Haskell.HsColour.CSS as CSS
-
-import Data.Either (partitionEithers)
-import Data.Maybe  (fromMaybe)
-import qualified Data.HashMap.Strict as M
-import Data.List   (find, isPrefixOf, findIndex, elemIndices, intercalate)
-import Data.Char   (isSpace)
-import Text.Printf
-import Language.Haskell.Liquid.GHC.Misc
-import Language.Haskell.Liquid.Types.Errors (panic, impossible)
-
-data AnnMap  = Ann 
-  { types   :: M.HashMap Loc (String, String) -- ^ Loc -> (Var, Type)
-  , errors  :: [(Loc, Loc, String)]           -- ^ List of error intervals
-  , status  :: !Status
-  , sptypes :: ![(SrcLoc.RealSrcSpan, (String, String)) ]-- ^ Type information with spans
-  }
-
-data Status = Safe | Unsafe | Error | Crash
-              deriving (Eq, Ord, Show)
-
-data Annotation = A {
-    typ :: Maybe String         -- ^ type  string
-  , err :: Maybe String         -- ^ error string
-  , lin :: Maybe (Int, Int)     -- ^ line number, total width of lines i.e. max (length (show lineNum))
-  } deriving (Show)
-
-
--- | Formats Haskell source code using HTML and mouse-over annotations
-hscolour :: Bool     -- ^ Whether to include anchors.
-         -> Bool     -- ^ Whether input document is literate haskell or not
-         -> String   -- ^ Haskell source code, Annotations as comments at end
-         -> String   -- ^ Coloured Haskell source code.
-
-hscolour anchor lhs = hsannot anchor Nothing lhs . splitSrcAndAnns
-
-type CommentTransform = Maybe (String -> [(TokenType, String)])
-
--- | Formats Haskell source code using HTML and mouse-over annotations
-hsannot  :: Bool             -- ^ Whether to include anchors.
-         -> CommentTransform -- ^ Function to refine comment tokens
-         -> Bool             -- ^ Whether input document is literate haskell or not
-         -> (String, AnnMap) -- ^ Haskell Source, Annotations
-         -> String           -- ^ Coloured Haskell source code.
-
-hsannot anchor tx False z     = hsannot' Nothing anchor tx z
-hsannot anchor tx True (s, m) = concatMap chunk $ litSpans $ joinL $ classify $ inlines s
-  where chunk (Code c, l)     = hsannot' (Just l) anchor tx (c, m)
-        chunk (Lit c , _)     = c
-
-litSpans :: [Lit] -> [(Lit, Loc)]
-litSpans lits = zip lits $ spans lits
-  where spans = tokenSpans Nothing . map unL
-
-hsannot' :: Maybe Loc
-         -> Bool -> CommentTransform -> (String, AnnMap) -> String
-hsannot' baseLoc anchor tx =
-    CSS.pre
-    . (if anchor then concatMap (renderAnchors renderAnnotToken)
-                      . insertAnnotAnchors
-                 else concatMap renderAnnotToken)
-    . annotTokenise baseLoc tx
-
-tokeniseWithLoc :: CommentTransform -> String -> [(TokenType, String, Loc)]
-tokeniseWithLoc tx str = zipWith (\(x,y) z -> (x, y, z)) toks spans  
-  where
-    toks       = tokeniseWithCommentTransform tx str
-    spans      = tokenSpans Nothing $ map snd toks
-
--- | annotTokenise is absurdly slow: O(#tokens x #errors)
-
-annotTokenise :: Maybe Loc -> CommentTransform -> (String, AnnMap) -> [(TokenType, String, Annotation)]
-annotTokenise baseLoc tx (src, annm) = zipWith (\(x,y) z -> (x,y,z)) toks annots
-  where
-    toks       = tokeniseWithCommentTransform tx src
-    spans      = tokenSpans baseLoc $ map snd toks
-    annots     = fmap (spanAnnot linWidth annm) spans
-    linWidth   = length $ show $ length $ lines src
-
-spanAnnot :: Int -> AnnMap -> Loc -> Annotation
-spanAnnot w (Ann ts es _ _) span = A t e b
-  where
-    t = fmap snd (M.lookup span ts)
-    e = fmap (\_ -> "ERROR") $ find (span `inRange`) [(x,y) | (x,y,_) <- es]
-    b = spanLine w span
-
-spanLine :: t -> Loc -> Maybe (Int, t)
-spanLine w (L (l, c))
-  | c == 1    = Just (l, w)
-  | otherwise = Nothing
-
-inRange :: Loc -> (Loc, Loc) -> Bool
-inRange (L (l0, c0)) (L (l, c), L (l', c'))
-  = l <= l0 && c <= c0 && l0 <= l' && c0 < c'
-
-tokeniseWithCommentTransform :: Maybe (String -> [(TokenType, String)]) -> String -> [(TokenType, String)]
-tokeniseWithCommentTransform Nothing  = tokenise
-tokeniseWithCommentTransform (Just f) = concatMap (expand f) . tokenise
-  where expand f (Comment, s) = f s
-        expand _ z            = [z]
-
-tokenSpans :: Maybe Loc -> [String] -> [Loc]
-tokenSpans = scanl plusLoc . fromMaybe (L (1, 1))
-
-plusLoc :: Loc -> String -> Loc
-plusLoc (L (l, c)) s
-  = case '\n' `elemIndices` s of
-      [] -> L (l, (c + n))
-      is -> L ((l + length is), (n - maximum is))
-    where n = length s
-
-renderAnnotToken :: (TokenType, String, Annotation) -> String
-renderAnnotToken (x, y, a)  = renderLinAnnot (lin a)
-                            $ renderErrAnnot (err a)
-                            $ renderTypAnnot (typ a)
-                            $ CSS.renderToken (x, y)
-
-
-
-renderTypAnnot :: (PrintfArg t, PrintfType t) => Maybe String -> t -> t
-renderTypAnnot (Just ann) s = printf "<a class=annot href=\"#\"><span class=annottext>%s</span>%s</a>" (escape ann) s
-renderTypAnnot Nothing    s = s
-
-renderErrAnnot :: (PrintfArg t1, PrintfType t1) => Maybe t -> t1 -> t1
-renderErrAnnot (Just _) s   = printf "<span class=hs-error>%s</span>" s
-renderErrAnnot Nothing  s   = s
-
-renderLinAnnot :: (Show t, PrintfArg t1, PrintfType t1)
-               => Maybe (t, Int) -> t1 -> t1
-renderLinAnnot (Just d) s   = printf "<span class=hs-linenum>%s: </span>%s" (lineString d) s
-renderLinAnnot Nothing  s   = s
-
-lineString :: Show t => (t, Int) -> [Char]
-lineString (i, w) = (replicate (w - (length is)) ' ') ++ is
-  where is        = show i
-
-{- Example Annotation:
-<a class=annot href="#"><span class=annottext>x#agV:Int -&gt; {VV_int:Int | (0 &lt;= VV_int),(x#agV &lt;= VV_int)}</span>
-<span class='hs-definition'>NOWTRYTHIS</span></a>
--}
-
-
-insertAnnotAnchors :: [(TokenType, String, a)] -> [Either String (TokenType, String, a)]
-insertAnnotAnchors toks
-  = stitch (zip toks' toks) $ insertAnchors toks'
-  where toks' = [(x,y) | (x,y,_) <- toks]
-
-stitch ::  Eq b => [(b, c)] -> [Either a b] -> [Either a c]
-stitch xys ((Left a) : rest)
-  = (Left a) : stitch xys rest
-stitch ((x,y):xys) ((Right x'):rest)
-  | x == x'
-  = (Right y) : stitch xys rest
-  | otherwise
-  = panic Nothing "stitch"
-stitch _ []
-  = []
-stitch _ _
-  = impossible Nothing "stitch: cannot happen"
-
-splitSrcAndAnns ::  String -> (String, AnnMap)
-splitSrcAndAnns s =
-  let ls = lines s in
-  case findIndex (breakS ==) ls of
-    Nothing -> (s, Ann M.empty [] Safe mempty)
-    Just i  -> (src, ann)
-               where (codes, _:mname:annots) = splitAt i ls
-                     ann   = annotParse mname $ dropWhile isSpace $ unlines annots
-                     src   = unlines codes
-
-srcModuleName :: String -> String
-srcModuleName = fromMaybe "Main" . tokenModule . tokenise
-
-tokenModule :: [(TokenType, [Char])] -> Maybe [Char]
-tokenModule toks
-  = do i <- findIndex ((Keyword, "module") ==) toks
-       let (_, toks')  = splitAt (i+2) toks
-       j <- findIndex ((Space ==) . fst) toks'
-       let (toks'', _) = splitAt j toks'
-       return $ concatMap snd toks''
-
-breakS :: [Char]
-breakS = "MOUSEOVER ANNOTATIONS"
-
-annotParse :: String -> String -> AnnMap
-annotParse mname s = Ann (M.fromList ts) [(x,y,"") | (x,y) <- es] Safe mempty
-  where
-    (ts, es)       = partitionEithers $ parseLines mname 0 $ lines s
-
-
-parseLines :: [Char]
-           -> Int
-           -> [[Char]]
-           -> [Either (Loc, ([Char], [Char])) (Loc, Loc)]
-parseLines _ _ []
-  = []
-
-parseLines mname i ("":ls)
-  = parseLines mname (i+1) ls
-
-parseLines mname i (_:_:l:c:"0":l':c':rest')
-  = Right (L (line, col), L (line', col')) : parseLines mname (i + 7) rest'
-    where line  = (read l)  :: Int
-          col   = (read c)  :: Int
-          line' = (read l') :: Int
-          col'  = (read c') :: Int
-
-parseLines mname i (x:f:l:c:n:rest)
-  | f /= mname
-  = parseLines mname (i + 5 + num) rest'
-  | otherwise
-  = Left (L (line, col), (x, anns)) : parseLines mname (i + 5 + num) rest'
-    where line  = (read l) :: Int
-          col   = (read c) :: Int
-          num   = (read n) :: Int
-          anns  = intercalate "\n" $ take num rest
-          rest' = drop num rest
-
-parseLines _ i _
-  = panic Nothing $ "Error Parsing Annot Input on Line: " ++ show i
-
-instance Show AnnMap where
-  show (Ann ts es _ _) =  "\n\n" 
-                      ++ (concatMap ppAnnotTyp $ M.toList ts)
-                      ++ (concatMap ppAnnotErr [(x,y) | (x,y,_) <- es])
-
-ppAnnotTyp :: (PrintfArg t, PrintfType t1) => (Loc, (t, String)) -> t1
-ppAnnotTyp (L (l, c), (x, s))     = printf "%s\n%d\n%d\n%d\n%s\n\n\n" x l c (length $ lines s) s
-
-ppAnnotErr :: PrintfType t => (Loc, Loc) -> t
-ppAnnotErr (L (l, c), L (l', c')) = printf " \n%d\n%d\n0\n%d\n%d\n\n\n\n" l c l' c'
-
-
----------------------------------------------------------------------------------
----- Code for Dealing With LHS, stolen from Language.Haskell.HsColour.HsColour --
----------------------------------------------------------------------------------
-
--- | Separating literate files into code\/comment chunks.
-data Lit = Code {unL :: String} | Lit {unL :: String} deriving (Show)
-
--- Re-implementation of 'lines', for better efficiency (but decreased laziness).
--- Also, importantly, accepts non-standard DOS and Mac line ending characters.
--- And retains the trailing '\n' character in each resultant string.
-inlines :: String -> [String]
-inlines s = lines' s id
-  where
-  lines' []             acc = [acc []]
-  lines' ('\^M':'\n':s) acc = acc ['\n'] : lines' s id  -- DOS
-  lines' ('\n':s)       acc = acc ['\n'] : lines' s id  -- Unix
-  lines' (c:s)          acc = lines' s (acc . (c:))
-
-
--- | The code for classify is largely stolen from Language.Preprocessor.Unlit.
-classify ::  [String] -> [Lit]
-classify []             = []
-classify (x:xs) | "\\begin{code}"`isPrefixOf`x
-                        = Lit x: allProg "code" xs
-classify (x:xs) | "\\begin{spec}"`isPrefixOf`x
-                        = Lit x: allProg "spec" xs
-classify (('>':x):xs)   = Code ('>':x) : classify xs
-classify (x:xs)         = Lit x: classify xs
-
-
-allProg :: [Char] -> [[Char]] -> [Lit]
-allProg name  = go
-  where
-    end       = "\\end{" ++ name ++ "}"
-    go []     = []  -- Should give an error message,
-                    -- but I have no good position information.
-    go (x:xs) | end `isPrefixOf `x
-              = Lit x: classify xs
-    go (x:xs) = Code x: go xs
-
-
--- | Join up chunks of code\/comment that are next to each other.
-joinL :: [Lit] -> [Lit]
-joinL []                  = []
-joinL (Code c:Code c2:xs) = joinL (Code (c++c2):xs)
-joinL (Lit c :Lit c2 :xs) = joinL (Lit  (c++c2):xs)
-joinL (any:xs)            = any: joinL xs
diff --git a/src/Language/Haskell/Liquid/UX/Annotate.hs b/src/Language/Haskell/Liquid/UX/Annotate.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/UX/Annotate.hs
+++ /dev/null
@@ -1,521 +0,0 @@
-{-# LANGUAGE FlexibleContexts           #-}
-{-# LANGUAGE TupleSections              #-}
-{-# LANGUAGE NoMonomorphismRestriction  #-}
-{-# LANGUAGE OverloadedStrings          #-}
-{-# LANGUAGE TypeSynonymInstances       #-}
-{-# LANGUAGE FlexibleInstances          #-}
-
-
----------------------------------------------------------------------------
--- | This module contains the code that uses the inferred types to generate
--- 1. HTMLized source with Inferred Types in mouseover annotations.
--- 2. Annotations files (e.g. for vim/emacs)
--- 3. JSON files for the web-demo etc.
----------------------------------------------------------------------------
-
-module Language.Haskell.Liquid.UX.Annotate
-  ( mkOutput
-  , annotate
-  , tokeniseWithLoc
-  , annErrors
-  ) where
-
-import           Data.Hashable
-import           Data.String
-import           GHC                                          ( SrcSpan (..)
-                                          , srcSpanStartCol
-                                          , srcSpanEndCol
-                                          , srcSpanStartLine
-                                          , srcSpanEndLine)
-import           GHC.Exts                                     (groupWith, sortWith)
-import           Prelude                                      hiding (error)
-import qualified SrcLoc
-import           Text.PrettyPrint.HughesPJ                    hiding (first)
-import           Text.Printf
-
-import           Data.Char                                    (isSpace)
-import           Data.Function                                (on)
-import           Data.List                                    (sortBy)
-import           Data.Maybe                                   (mapMaybe)
-
-import           Data.Aeson
-import           Control.Arrow                                hiding ((<+>))
--- import           Control.Applicative      ((<$>))
-import           Control.Monad                                (when, forM_)
-
-import           System.Exit                                  (ExitCode (..))
-import           System.FilePath                              (takeFileName, dropFileName, (</>))
-import           System.Directory                             (findExecutable)
-import qualified System.Directory                             as Dir
-import qualified Data.List                                    as L
-import qualified Data.Vector                                  as V
-import qualified Data.ByteString.Lazy                         as B
-import qualified Data.Text                                    as T
-import qualified Data.HashMap.Strict                          as M
-import qualified Language.Haskell.Liquid.Misc                 as Misc 
-import qualified Language.Haskell.Liquid.UX.ACSS              as ACSS
-import           Language.Haskell.HsColour.Classify
-import           Language.Fixpoint.Utils.Files
-import           Language.Fixpoint.Misc
-import           Language.Haskell.Liquid.GHC.Misc
-import           Language.Fixpoint.Types                      hiding (panic, Error, Loc, Constant (..), Located (..))
-import           Language.Haskell.Liquid.Misc
-import           Language.Haskell.Liquid.Types.PrettyPrint
-import           Language.Haskell.Liquid.Types.RefType
-
-import           Language.Haskell.Liquid.UX.Tidy
-import           Language.Haskell.Liquid.Types                hiding (Located(..), Def(..))
--- import           Language.Haskell.Liquid.Types.Specifications
-
-
--- | @output@ creates the pretty printed output
---------------------------------------------------------------------------------------------
-mkOutput :: Config -> ErrorResult -> FixSolution -> AnnInfo (Annot SpecType) -> Output Doc
---------------------------------------------------------------------------------------------
-mkOutput cfg res sol anna
-  = O { o_vars   = Nothing
-      -- , o_errors = []
-      , o_types  = toDoc <$> annTy
-      , o_templs = toDoc <$> annTmpl
-      , o_bots   = mkBots    annTy
-      , o_result = res
-      }
-  where
-    annTmpl      = closeAnnots anna
-    annTy        = tidySpecType Lossy <$> applySolution sol annTmpl
-    toDoc        = rtypeDoc tidy
-    tidy         = if shortNames cfg then Lossy else Full
-
--- | @annotate@ actually renders the output to files
--------------------------------------------------------------------
-annotate :: Config -> [FilePath] -> Output Doc -> IO ACSS.AnnMap
--------------------------------------------------------------------
-annotate cfg srcFs out
-  = do when showWarns  $ forM_ bots (printf "WARNING: Found false in %s\n" . showPpr)
-       when doAnnotate $ mapM_ (doGenerate cfg tplAnnMap typAnnMap annTyp) srcFs
-       return typAnnMap
-    where
-       tplAnnMap  = mkAnnMap cfg res annTpl
-       typAnnMap  = mkAnnMap cfg res annTyp
-       annTpl     = o_templs out
-       annTyp     = o_types  out
-       res        = o_result out
-       bots       = o_bots   out
-       showWarns  = not $ nowarnings    cfg
-       doAnnotate = not $ noannotations cfg
-
-doGenerate :: Config -> ACSS.AnnMap -> ACSS.AnnMap -> AnnInfo Doc -> FilePath -> IO ()
-doGenerate cfg tplAnnMap typAnnMap annTyp srcF
-  = do generateHtml srcF tpHtmlF tplAnnMap
-       generateHtml srcF tyHtmlF typAnnMap
-       writeFile         vimF  $ vimAnnot cfg annTyp
-       B.writeFile       jsonF $ encode typAnnMap
-    where
-       tyHtmlF    = extFileName Html                   srcF
-       tpHtmlF    = extFileName Html $ extFileName Cst srcF
-       _annF      = extFileName Annot srcF
-       jsonF      = extFileName Json  srcF
-       vimF       = extFileName Vim   srcF
-
-mkBots :: Reftable r => AnnInfo (RType c tv r) -> [GHC.SrcSpan]
-mkBots (AI m) = [ src | (src, (Just _, t) : _) <- sortBy (compare `on` fst) $ M.toList m
-                      , isFalse (rTypeReft t) ]
-
--- | Like 'copyFile' from 'System.Directory', but ensure that the parent /temporary/ directory 
--- (i.e. \".liquid\") exists on disk, creating it if necessary.
-copyFileCreateParentDirIfMissing :: FilePath -> FilePath -> IO ()
-copyFileCreateParentDirIfMissing src tgt = do
-  Dir.createDirectoryIfMissing False $ tempDirectory tgt
-  Dir.copyFile src tgt
-
-writeFilesOrStrings :: FilePath -> [Either FilePath String] -> IO ()
-writeFilesOrStrings tgtFile = mapM_ $ either (`copyFileCreateParentDirIfMissing` tgtFile) (tgtFile `appendFile`)
-
-generateHtml :: FilePath -> FilePath -> ACSS.AnnMap -> IO ()
-generateHtml srcF htmlF annm
-  = do src     <- Misc.sayReadFile srcF
-       let lhs  = isExtFile LHs srcF
-       let body = {-# SCC "hsannot" #-} ACSS.hsannot False (Just tokAnnot) lhs (src, annm)
-       cssFile <- getCssPath
-       copyFileCreateParentDirIfMissing cssFile (dropFileName htmlF </> takeFileName cssFile)
-       renderHtml lhs htmlF srcF (takeFileName cssFile) body
-
-renderHtml :: Bool -> FilePath -> String -> String -> String -> IO ()
-renderHtml True  = renderPandoc
-renderHtml False = renderDirect
-
--------------------------------------------------------------------------
--- | Pandoc HTML Rendering (for lhs + markdown source) ------------------
--------------------------------------------------------------------------
-renderPandoc :: FilePath -> String -> String -> String -> IO ()
-renderPandoc htmlFile srcFile css body = do
-  renderFn <- maybe renderDirect renderPandoc' <$> findExecutable "pandoc"
-  renderFn htmlFile srcFile css body
-
-renderPandoc' :: FilePath -> FilePath -> FilePath -> String -> String -> IO ()
-renderPandoc' pandocPath htmlFile srcFile css body = do
-  _  <- writeFile mdFile $ pandocPreProc body
-  ec <- executeShellCommand "pandoc" cmd
-  writeFilesOrStrings htmlFile [Right (cssHTML css)]
-  checkExitCode cmd ec
-  where
-    mdFile = extFileName Mkdn srcFile
-    cmd    = pandocCmd pandocPath mdFile htmlFile
-
-checkExitCode :: Monad m => String -> ExitCode -> m ()
-checkExitCode _   (ExitSuccess)   = return ()
-checkExitCode cmd (ExitFailure n) = panic Nothing $ "cmd: " ++ cmd ++ " failure code " ++ show n
-
-pandocCmd :: FilePath -> FilePath -> FilePath -> String
-pandocCmd -- pandocPath mdFile htmlFile
-  = printf "%s -f markdown -t html %s > %s" -- pandocPath mdFile htmlFile
-
-pandocPreProc :: String -> String
-pandocPreProc  = T.unpack
-               . strip beg code
-               . strip end code
-               . strip beg spec
-               . strip end spec
-               . T.pack
-  where
-    beg, end, code, spec :: String
-    beg        = "begin"
-    end        = "end"
-    code       = "code"
-    spec       = "spec"
-    strip x y  = T.replace (T.pack $ printf "\\%s{%s}" x y) T.empty
-
-
--------------------------------------------------------------------------
--- | Direct HTML Rendering (for non-lhs/markdown source) ----------------
--------------------------------------------------------------------------
-
--- More or less taken from hscolour
-
-renderDirect :: FilePath -> String -> String -> String -> IO ()
-renderDirect htmlFile srcFile css body
-  = writeFile htmlFile $! (topAndTail full srcFile css $! body)
-    where full = True -- False  -- TODO: command-line-option
-
--- | @topAndTail True@ is used for standalone HTML; @topAndTail False@ for embedded HTML
-topAndTail :: Bool -> String -> String -> String -> String
-topAndTail True  title css = (htmlHeader title css ++) . (++ htmlClose)
-topAndTail False _    _    = id
-
--- Use this for standalone HTML
-htmlHeader :: String -> String -> String
-htmlHeader title css = unlines
-  [ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">"
-  , "<html>"
-  , "<head>"
-  , "<title>" ++ title ++ "</title>"
-  , "</head>"
-  , cssHTML css
-  , "<body>"
-  , "<hr>"
-  , "Put mouse over identifiers to see inferred types"
-  ]
-
-htmlClose :: IsString a => a
-htmlClose  = "\n</body>\n</html>"
-
-cssHTML :: String -> String
-cssHTML css = unlines
-  [ "<head>"
-  , "<link type='text/css' rel='stylesheet' href='"++ css ++ "' />"
-  , "</head>"
-  ]
-
-------------------------------------------------------------------------------
--- | Building Annotation Maps ------------------------------------------------
-------------------------------------------------------------------------------
-
--- | This function converts our annotation information into that which
---   is required by `Language.Haskell.Liquid.ACSS` to generate mouseover
---   annotations.
-
-mkAnnMap :: Config -> ErrorResult -> AnnInfo Doc -> ACSS.AnnMap
-mkAnnMap cfg res ann     = ACSS.Ann 
-                             { ACSS.types   = mkAnnMapTyp cfg ann 
-                             , ACSS.errors  = mkAnnMapErr res 
-                             , ACSS.status  = mkStatus res 
-                             , ACSS.sptypes = mkAnnMapBinders cfg ann
-                             }
-
-mkStatus :: FixResult t -> ACSS.Status
-mkStatus (Safe _)        = ACSS.Safe
-mkStatus (Unsafe _ _)    = ACSS.Unsafe
-mkStatus (Crash _ _)     = ACSS.Error
-
-
-
-mkAnnMapErr :: PPrint (TError t)
-            => FixResult (TError t) -> [(Loc, Loc, String)]
-mkAnnMapErr (Unsafe _ ls) = mapMaybe cinfoErr ls
-mkAnnMapErr (Crash ls _)  = mapMaybe cinfoErr ls
-mkAnnMapErr _             = []
-
-cinfoErr :: PPrint (TError t) => TError t -> Maybe (Loc, Loc, String)
-cinfoErr e = case pos e of
-               RealSrcSpan l -> Just (srcSpanStartLoc l, srcSpanEndLoc l, showpp e)
-               _             -> Nothing
-
-
--- mkAnnMapTyp :: (RefTypable a c tv r, RefTypable a c tv (), PPrint tv, PPrint a) =>Config-> AnnInfo (RType a c tv r) -> M.HashMap Loc (String, String)
-mkAnnMapTyp :: Config -> AnnInfo Doc -> M.HashMap Loc (String, String)
-mkAnnMapTyp cfg z = M.fromList $ map (first srcSpanStartLoc) $ mkAnnMapBinders cfg z
-
-mkAnnMapBinders :: Config -> AnnInfo Doc -> [(SrcLoc.RealSrcSpan, (String, String))]
-mkAnnMapBinders cfg (AI m)
-  = map (second bindStr . head . sortWith (srcSpanEndCol . fst))
-  $ groupWith (lineCol . fst) locBinds
-  where
-    locBinds       = [ (l, x) | (RealSrcSpan l, x:_) <- M.toList m, oneLine l]
-    bindStr (x, v) = (maybe "_" (symbolString . shorten . symbol) x, render v)
-    shorten        = if shortNames cfg then dropModuleNames else id
-
-closeAnnots :: AnnInfo (Annot SpecType) -> AnnInfo SpecType
-closeAnnots = closeA . filterA . collapseA
-
-closeA :: AnnInfo (Annot b) -> AnnInfo b
-closeA a@(AI m)   = cf <$> a
-  where
-    cf (AnnLoc l)  = case m `mlookup` l of
-                      [(_, AnnUse t)] -> t
-                      [(_, AnnDef t)] -> t
-                      [(_, AnnRDf t)] -> t
-                      _               -> panic Nothing $ "malformed AnnInfo: " ++ showPpr l
-    cf (AnnUse t) = t
-    cf (AnnDef t) = t
-    cf (AnnRDf t) = t
-
-filterA :: AnnInfo (Annot t) -> AnnInfo (Annot t)
-filterA (AI m) = AI (M.filter ff m)
-  where
-    ff [(_, AnnLoc l)] = l `M.member` m
-    ff _               = True
-
-collapseA :: AnnInfo (Annot t) -> AnnInfo (Annot t)
-collapseA (AI m) = AI (fmap pickOneA m)
-
-pickOneA :: [(t, Annot t1)] -> [(t, Annot t1)]
-pickOneA xas = case (rs, ds, ls, us) of
-                 (x:_, _, _, _) -> [x]
-                 (_, x:_, _, _) -> [x]
-                 (_, _, x:_, _) -> [x]
-                 (_, _, _, x:_) -> [x]
-                 (_, _, _, _  ) -> [ ]
-  where
-    rs = [x | x@(_, AnnRDf _) <- xas]
-    ds = [x | x@(_, AnnDef _) <- xas]
-    ls = [x | x@(_, AnnLoc _) <- xas]
-    us = [x | x@(_, AnnUse _) <- xas]
-
-------------------------------------------------------------------------------
--- | Tokenizing Refinement Type Annotations in @-blocks ----------------------
-------------------------------------------------------------------------------
-
--- | The token used for refinement symbols inside the highlighted types in @-blocks.
-refToken :: TokenType
-refToken = Keyword
-
--- | The top-level function for tokenizing @-block annotations. Used to
--- tokenize comments by ACSS.
-tokAnnot :: String -> [(TokenType, String)]
-tokAnnot s
-  = case trimLiquidAnnot s of
-      Just (l, body, r) -> [(refToken, l)] ++ tokBody body ++ [(refToken, r)]
-      Nothing           -> [(Comment, s)]
-
-trimLiquidAnnot :: String -> Maybe (String, String, String)
-trimLiquidAnnot ('{':'-':'@':ss)
-  | drop (length ss - 3) ss == "@-}"
-  = Just (liquidBegin, take (length ss - 3) ss, liquidEnd)
-trimLiquidAnnot _
-  = Nothing
-
-tokBody :: String -> [(TokenType, String)]
-tokBody s
-  | isData s  = tokenise s
-  | isType s  = tokenise s
-  | isIncl s  = tokenise s
-  | isMeas s  = tokenise s
-  | otherwise = tokeniseSpec s
-
-isMeas :: String -> Bool
-isMeas = spacePrefix "measure"
-
-isData :: String -> Bool
-isData = spacePrefix "data"
-
-isType :: String -> Bool
-isType = spacePrefix "type"
-
-isIncl :: String -> Bool
-isIncl = spacePrefix "include"
-
-{-@ spacePrefix :: String -> s:String -> Bool / [len s] @-}
-spacePrefix :: String -> String -> Bool
-spacePrefix str s@(c:cs)
-  | isSpace c   = spacePrefix str cs
-  | otherwise   = take (length str) s == str
-spacePrefix _ _ = False
-
-
-tokeniseSpec :: String -> [(TokenType, String)]
-tokeniseSpec       = tokAlt . chopAltDBG
-  where
-    tokAlt (s:ss)  = tokenise s ++ tokAlt' ss
-    tokAlt _       = []
-    tokAlt' (s:ss) = (refToken, s) : tokAlt ss
-    tokAlt' _      = []
-
-chopAltDBG :: String -> [String]
-chopAltDBG y = filter (/= "")
-             $ concatMap (chopAlts [("{", ":"), ("|", "}")])
-             $ chopAlts [("<{", "}>"), ("{", "}")] y
-
-
-------------------------------------------------------------------------
--- | JSON: Annotation Data Types ---------------------------------------
-------------------------------------------------------------------------
-
-data Assoc k a    = Asc (M.HashMap k a)
-type AnnTypes     = Assoc Int (Assoc Int Annot1)
-newtype AnnErrors = AnnErrors [(Loc, Loc, String)]
-data Annot1       = A1  { ident :: String
-                        , ann   :: String
-                        , row   :: Int
-                        , col   :: Int
-                        }
-
-------------------------------------------------------------------------
--- | Creating Vim Annotations ------------------------------------------
-------------------------------------------------------------------------
-vimAnnot     :: Config -> AnnInfo Doc -> String
-vimAnnot cfg = L.intercalate "\n" . map vimBind . mkAnnMapBinders cfg
-
-vimBind :: (Show a, PrintfType t) => (SrcLoc.RealSrcSpan, (String, a)) -> t
-vimBind (sp, (v, ann)) = printf "%d:%d-%d:%d::%s" l1 c1 l2 c2 (v ++ " :: " ++ show ann)
-  where
-    l1  = srcSpanStartLine sp
-    c1  = srcSpanStartCol  sp
-    l2  = srcSpanEndLine   sp
-    c2  = srcSpanEndCol    sp
-
-------------------------------------------------------------------------
--- | JSON Instances ----------------------------------------------------
-------------------------------------------------------------------------
-
-instance ToJSON ACSS.Status where
-  toJSON ACSS.Safe   = "safe"
-  toJSON ACSS.Unsafe = "unsafe"
-  toJSON ACSS.Error  = "error"
-  toJSON ACSS.Crash  = "crash"
-
-instance ToJSON Annot1 where
-  toJSON (A1 i a r c) = object [ "ident" .= i
-                               , "ann"   .= a
-                               , "row"   .= r
-                               , "col"   .= c
-                               ]
-
-instance ToJSON Loc where
-  toJSON (L (l, c)) = object [ "line"     .= toJSON l
-                             , "column"   .= toJSON c ]
-
-instance ToJSON AnnErrors where
-  toJSON (AnnErrors errs) = Array $ V.fromList (toJ <$> errs)
-    where
-      toJ (l,l',s)        = object [ "start"   .= toJSON l
-                                   , "stop"    .= toJSON l'
-                                   , "message" .= toJSON (dropErrorLoc s)
-                                   ]
-
-
-
-
-dropErrorLoc :: String -> String
-dropErrorLoc msg
-  | null msg' = msg
-  | otherwise = tail msg'
-  where
-    (_, msg') = break (' ' ==) msg
-
-instance (Show k, ToJSON a) => ToJSON (Assoc k a) where
-  toJSON (Asc kas) = object [ tshow k .= toJSON a | (k, a) <- M.toList kas ]
-    where
-      tshow        = T.pack . show
-
-instance ToJSON ACSS.AnnMap where
-  toJSON a = object [ "types"   .= toJSON (annTypes     a)
-                    , "errors"  .= toJSON (annErrors    a)
-                    , "status"  .= toJSON (ACSS.status  a)
-                    , "sptypes" .= (toJ <$> ACSS.sptypes a) 
-                    ]
-    where 
-      toJ (sp, (x,t)) = object [ "start" .= toJSON (srcSpanStartLoc sp) 
-                               , "stop"  .= toJSON (srcSpanEndLoc   sp) 
-                               , "ident" .= toJSON x 
-                               , "ann"  .= toJSON t 
-                               ] 
-                      
-annErrors :: ACSS.AnnMap -> AnnErrors
-annErrors = AnnErrors . ACSS.errors
-
-annTypes         :: ACSS.AnnMap -> AnnTypes
-annTypes a       = grp [(l, c, ann1 l c x s) | (l, c, x, s) <- binders]
-  where
-    ann1 l c x s = A1 x s l c
-    grp          = L.foldl' (\m (r,c,x) -> ins r c x m) (Asc M.empty)
-    binders      = [(l, c, x, s) | (L (l, c), (x, s)) <- M.toList $ ACSS.types a]
-
-ins :: (Eq k, Eq k1, Hashable k, Hashable k1)
-    => k -> k1 -> a -> Assoc k (Assoc k1 a) -> Assoc k (Assoc k1 a)
-ins r c x (Asc m)  = Asc (M.insert r (Asc (M.insert c x rm)) m)
-  where
-    Asc rm         = M.lookupDefault (Asc M.empty) r m
-
-tokeniseWithLoc :: String -> [(TokenType, String, Loc)]
-tokeniseWithLoc = ACSS.tokeniseWithLoc (Just tokAnnot)
-
---------------------------------------------------------------------------------
--- | LH Related Stuff ----------------------------------------------------------
---------------------------------------------------------------------------------
-
-{-@ LIQUID "--diffcheck" @-}
-
-{-@ type ListNE a    = {v:[a] | 0 < len v}  @-}
-{-@ type ListN  a N  = {v:[a] | len v == N} @-}
-{-@ type ListXs a Xs = ListN a {len Xs}     @-}
-
-{-@ assume GHC.Exts.sortWith :: Ord b => (a -> b) -> xs:[a] -> ListXs a xs @-}
-{-@ assume GHC.Exts.groupWith :: Ord b => (a -> b) -> [a] -> [ListNE a] @-}
-
---------------------------------------------------------------------------------
--- | A Little Unit Test --------------------------------------------------------
---------------------------------------------------------------------------------
-
-_anns :: AnnTypes
-_anns = i [(5,   i [( 14, A1 { ident = "foo"
-                             , ann   = "int -> int"
-                             , row   = 5
-                             , col   = 14
-                             })
-                  ]
-          )
-         ,(9,   i [( 22, A1 { ident = "map"
-                            , ann   = "(a -> b) -> [a] -> [b]"
-                            , row   = 9
-                            , col   = 22
-                            })
-                  ,( 28, A1 { ident = "xs"
-                            , ann   = "[b]"
-                            , row   = 9
-                            , col   = 28
-                            })
-                  ])
-         ]
-
-i :: (Eq k, Hashable k) => [(k, a)] -> Assoc k a
-i = Asc . M.fromList
diff --git a/src/Language/Haskell/Liquid/UX/CTags.hs b/src/Language/Haskell/Liquid/UX/CTags.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/UX/CTags.hs
+++ /dev/null
@@ -1,77 +0,0 @@
--- | This module contains the code for generating "tags" for constraints
---   based on their source, i.e. the top-level binders under which the
---   constraint was generated. These tags are used by fixpoint to
---   prioritize constraints by the "source-level" function.
-
-{-# LANGUAGE TupleSections #-}
-
-module Language.Haskell.Liquid.UX.CTags (
-    -- * Type for constraint tags
-    TagKey, TagEnv
-
-    -- * Default tag value
-  , defaultTag
-
-    -- * Constructing @TagEnv@
-  , makeTagEnv
-
-    -- * Accessing @TagEnv@
-  , getTag
-  , memTagEnv
-
-) where
-
-import Var
-import CoreSyn
-import Prelude hiding (error)
-
-import qualified Data.HashSet           as S
-import qualified Data.HashMap.Strict    as M
-import qualified Data.Graph             as G
-
-import Language.Fixpoint.Types          (Tag)
-import Language.Haskell.Liquid.Types.Visitors (freeVars)
-import Language.Haskell.Liquid.Types.PrettyPrint ()
-import Language.Fixpoint.Misc     (mapSnd)
-
--- | The @TagKey@ is the top-level binder, and @Tag@ is a singleton Int list
-
-type TagKey = Var
-type TagEnv = M.HashMap TagKey Tag
-
--- TODO: use the "callgraph" SCC to do this numbering.
-
-defaultTag :: Tag
-defaultTag = [0]
-
-memTagEnv :: TagKey -> TagEnv -> Bool
-memTagEnv = M.member
-
-makeTagEnv :: [CoreBind] -> TagEnv
-makeTagEnv = {- tracepp "TAGENV" . -} M.map (:[]) . callGraphRanks . makeCallGraph
-
--- makeTagEnv = M.fromList . (`zip` (map (:[]) [1..])). L.sort . map fst . concatMap bindEqns
-
-getTag :: TagKey -> TagEnv -> Tag
-getTag = M.lookupDefault defaultTag
-
-------------------------------------------------------------------------------------------------------
-
-type CallGraph = [(Var, [Var])] -- caller-callee pairs
-
-callGraphRanks :: CallGraph -> M.HashMap Var Int
--- callGraphRanks cg = traceShow ("CallGraph Ranks: " ++ show cg) $ callGraphRanks' cg
-
-callGraphRanks  = M.fromList . concat . index . mkScc
-  where mkScc cg = G.stronglyConnComp [(u, u, vs) | (u, vs) <- cg]
-        index    = zipWith (\i -> map (, i) . G.flattenSCC) [1..]
-
-makeCallGraph :: [CoreBind] -> CallGraph
-makeCallGraph cbs = mapSnd calls `fmap` xes
-  where xes       = concatMap bindEqns cbs
-        xs        = S.fromList $ map fst xes
-        calls     = filter (`S.member` xs) . freeVars S.empty
-
-bindEqns :: Bind t -> [(t, Expr t)]
-bindEqns (NonRec x e) = [(x, e)]
-bindEqns (Rec xes)    = xes
diff --git a/src/Language/Haskell/Liquid/UX/CmdLine.hs b/src/Language/Haskell/Liquid/UX/CmdLine.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/UX/CmdLine.hs
+++ /dev/null
@@ -1,769 +0,0 @@
-{-# LANGUAGE FlexibleInstances         #-}
-{-# LANGUAGE NoMonomorphismRestriction #-}
-{-# LANGUAGE ScopedTypeVariables       #-}
-{-# LANGUAGE TemplateHaskell           #-}
-{-# LANGUAGE TupleSections             #-}
-{-# LANGUAGE TypeSynonymInstances      #-}
-{-# LANGUAGE NamedFieldPuns            #-}
-{-# LANGUAGE MultiWayIf                #-}
-{-# LANGUAGE ViewPatterns              #-}
-{-# OPTIONS_GHC -fno-cse #-}
-
--- | This module contains all the code needed to output the result which
---   is either: `SAFE` or `WARNING` with some reasonable error message when
---   something goes wrong. All forms of errors/exceptions should go through
---   here. The idea should be to report the error, the source position that
---   causes it, generate a suitable .json file and then exit.
-
-module Language.Haskell.Liquid.UX.CmdLine (
-   -- * Get Command Line Configuration
-     getOpts, mkOpts, defConfig, config
-
-   -- * Update Configuration With Pragma
-   , withPragmas
-
-   -- * Canonicalize Paths in Config
-   , canonicalizePaths
-
-   -- * Exit Function
-   , exitWithResult
-   , addErrors
-
-   -- * Reporting the output of the checking
-   , OutputResult(..)
-   , reportResult
-
-   -- * Diff check mode
-   , diffcheck
-
-   -- * Show info about this version of LiquidHaskell
-   , printLiquidHaskellBanner
-
-) where
-
-import Prelude hiding (error)
-
-
-import Control.Monad
-import Control.Monad.IO.Class
-import Data.Maybe
-import Data.Aeson (encode)
-import qualified Data.ByteString.Lazy.Char8 as B
-import Development.GitRev (gitCommitCount)
-import Options.Applicative.Simple (simpleVersion)
-import qualified Paths_liquidhaskell as Meta
-import System.Directory
-import System.Exit
-import System.Environment
-import System.Console.CmdArgs.Explicit
-import System.Console.CmdArgs.Implicit     hiding (Loud)
-import qualified System.Console.CmdArgs.Verbosity as CmdArgs
-import System.Console.CmdArgs.Text
-import GitHash
-
-import Data.List                           (nub)
-
-
-import System.FilePath                     (isAbsolute, takeDirectory, (</>))
-
-import qualified Language.Fixpoint.Types.Config as FC
-import Language.Fixpoint.Misc
-import Language.Fixpoint.Types.Names
-import Language.Fixpoint.Types             hiding (panic, Error, Result, saveQuery)
-import qualified Language.Fixpoint.Types as F
-import Language.Fixpoint.Solver.Stats as Solver
-import Language.Haskell.Liquid.UX.Annotate
-import Language.Haskell.Liquid.UX.Config
-import Language.Haskell.Liquid.GHC.Misc
-import Language.Haskell.Liquid.Misc
-import Language.Haskell.Liquid.Types.PrettyPrint ()
-import Language.Haskell.Liquid.Types       hiding (typ)
-import qualified Language.Haskell.Liquid.UX.ACSS as ACSS
-
-import qualified Language.Haskell.Liquid.GHC.API as GHC
-
-
-import Text.Parsec.Pos                     (newPos)
-import Text.PrettyPrint.HughesPJ           hiding (Mode, (<>))
-
-
-
----------------------------------------------------------------------------------
--- Config Magic Numbers----------------------------------------------------------
----------------------------------------------------------------------------------
-
-defaultMaxParams :: Int
-defaultMaxParams = 2
-
----------------------------------------------------------------------------------
--- Parsing Command Line----------------------------------------------------------
----------------------------------------------------------------------------------
-config :: Mode (CmdArgs Config)
-config = cmdArgsMode $ Config {
-  loggingVerbosity
-    = enum [ Quiet        &= name "quiet"   &= help "Minimal logging verbosity"
-           , Normal       &= name "normal"  &= help "Normal logging verbosity"
-           , CmdArgs.Loud &= name "verbose" &= help "Verbose logging"
-           ]
-
- , files
-    = def &= typ "TARGET"
-          &= args
-          &= typFile
-
- , idirs
-    = def &= typDir
-          &= help "Paths to Spec Include Directory "
-
- , fullcheck
-     = def
-           &= help "Full Checking: check all binders (DEFAULT)"
-
- , diffcheck
-    = def
-          &= help "Incremental Checking: only check changed binders"
-
- , higherorder
-    = def
-          &= help "Allow higher order binders into the logic"
-
- , smtTimeout
-    = def
-          &= help "Timeout of smt queries in msec"
-
- , higherorderqs
-    = def
-          &= help "Allow higher order qualifiers to get automatically instantiated"
-
- , linear
-    = def
-          &= help "Use uninterpreted integer multiplication and division"
-
- , stringTheory
-    = def
-          &= help "Interpretation of Strings by z3"
-
- , saveQuery
-    = def &= help "Save fixpoint query to file (slow)"
-
- , checks
-    = def &= help "Check a specific (top-level) binder"
-          &= name "check-var"
-
- , pruneUnsorted
-    = def &= help "Disable prunning unsorted Predicates"
-          &= name "prune-unsorted"
-
- , notermination
-    = def
-          &= help "Disable Termination Check"
-          &= name "no-termination-check"
-
- , rankNTypes
-    = def &= help "Adds precise reasoning on presence of rankNTypes"
-          &= name "rankNTypes"
-
- , noclasscheck
-    = def
-          &= help "Disable Class Instance Check"
-          &= name "no-class-check"
-
- , nostructuralterm
-    = def &= name "no-structural-termination"
-          &= help "Disable structural termination check"
-
- , gradual
-    = def &= help "Enable gradual refinement type checking"
-          &= name "gradual"
-
- , bscope
-    = def &= help "scope of the outer binders on the inner refinements"
-          &= name "bscope"
-
- , gdepth
-    = 1
-    &= help ("Size of gradual conretizations, 1 by default")
-    &= name "gradual-depth"
-
- , ginteractive
-    = def &= help "Interactive Gradual Solving"
-          &= name "ginteractive"
-
- , totalHaskell
-    = def &= help "Check for termination and totality; overrides no-termination flags"
-          &= name "total-Haskell"
-
- , nowarnings
-    = def &= help "Don't display warnings, only show errors"
-          &= name "no-warnings"
-
- , noannotations
-    = def &= help "Don't create intermediate annotation files"
-          &= name "no-annotations"
-
- , checkDerived
-    = def &= help "Check GHC generated binders (e.g. Read, Show instances)"
-          &= name "check-derived"
-
- , caseExpandDepth
-    = 2   &= help "Maximum depth at which to expand DEFAULT in case-of (default=2)"
-          &= name "max-case-expand"
-
- , notruetypes
-    = def &= help "Disable Trueing Top Level Types"
-          &= name "no-true-types"
-
- , nototality
-    = def &= help "Disable totality check"
-          &= name "no-totality"
-
- , cores
-    = def &= help "Use m cores to solve logical constraints"
-
- , minPartSize
-    = FC.defaultMinPartSize
-    &= help "If solving on multiple cores, ensure that partitions are of at least m size"
-
- , maxPartSize
-    = FC.defaultMaxPartSize
-    &= help ("If solving on multiple cores, once there are as many partitions " ++
-             "as there are cores, don't merge partitions if they will exceed this " ++
-             "size. Overrides the minpartsize option.")
-
- , smtsolver
-    = def &= help "Name of SMT-Solver"
-
- , noCheckUnknown
-    = def &= explicit
-          &= name "no-check-unknown"
-          &= help "Don't complain about specifications for unexported and unused values "
-
- , maxParams
-    = defaultMaxParams &= help "Restrict qualifier mining to those taking at most `m' parameters (2 by default)"
-
- , shortNames
-    = def &= name "short-names"
-          &= help "Print shortened names, i.e. drop all module qualifiers."
-
- , shortErrors
-    = def &= name "short-errors"
-          &= help "Don't show long error messages, just line numbers."
-
- , cabalDir
-    = def &= name "cabal-dir"
-          &= help "Find and use .cabal to add paths to sources for imported files"
-
- , ghcOptions
-    = def &= name "ghc-option"
-          &= typ "OPTION"
-          &= help "Pass this option to GHC"
-
- , cFiles
-    = def &= name "c-files"
-          &= typ "OPTION"
-          &= help "Tell GHC to compile and link against these files"
-
- , port
-     = defaultPort
-          &= name "port"
-          &= help "Port at which lhi should listen"
-
- , exactDC
-    = def &= help "Exact Type for Data Constructors"
-          &= name "exact-data-cons"
-
- , noADT
-    = def &= help "Do not generate ADT representations in refinement logic"
-          &= name "no-adt"
-
- , scrapeImports
-    = False &= help "Scrape qualifiers from imported specifications"
-            &= name "scrape-imports"
-            &= explicit
-
- , scrapeInternals
-    = False &= help "Scrape qualifiers from auto generated specifications"
-            &= name "scrape-internals"
-            &= explicit
-
- , scrapeUsedImports
-    = False &= help "Scrape qualifiers from used, imported specifications"
-            &= name "scrape-used-imports"
-            &= explicit
-
- , elimStats
-    = False &= name "elimStats"
-            &= help "Print eliminate stats"
-
- , elimBound
-    = Nothing
-            &= name "elimBound"
-            &= help "Maximum chain length for eliminating KVars"
-
- , noslice
-    = False
-            &= name "noSlice"
-            &= help "Disable non-concrete KVar slicing"
-
- , noLiftedImport
-    = False
-            &= name "no-lifted-imports"
-            &= help "Disable loading lifted specifications (for legacy libs)"
-
- , json
-    = False &= name "json"
-            &= help "Print results in JSON (for editor integration)"
-
- , counterExamples
-    = False &= name "counter-examples"
-            &= help "Attempt to generate counter-examples to type errors (experimental!)"
-
- , timeBinds
-    = False &= name "time-binds"
-            &= help "Solve each (top-level) asserted type signature separately & time solving."
-
-  , untidyCore
-    = False &= name "untidy-core"
-            &= help "Print fully qualified identifier names in verbose mode"
-
-  , eliminate
-    = FC.Some
-            &= name "eliminate"
-            &= help "Use elimination for 'all' (use TRUE for cut-kvars), 'some' (use quals for cut-kvars) or 'none' (use quals for all kvars)."
-
-  , noPatternInline
-    = False &= name "no-pattern-inline"
-            &= help "Don't inline special patterns (e.g. `>>=` and `return`) during constraint generation."
-
-  , noSimplifyCore
-    = False &= name "no-simplify-core"
-            &= help "Don't simplify GHC core before constraint generation"
-
-  -- PLE-OPT , autoInstantiate
-    -- PLE-OPT = def
-          -- PLE-OPT &= help "How to instantiate axiomatized functions `smtinstances` for SMT instantiation, `liquidinstances` for terminating instantiation"
-          -- PLE-OPT &= name "automatic-instances"
-
-  , proofLogicEval
-    = def
-        &= help "Enable Proof-by-Logical-Evaluation"
-        &= name "ple"
-
-  , oldPLE
-    = def
-        &= help "Enable Proof-by-Logical-Evaluation"
-        &= name "oldple"
-
-  , proofLogicEvalLocal
-    = def
-        &= help "Enable Proof-by-Logical-Evaluation locally, per function"
-        &= name "ple-local"
-
-  , extensionality
-    = def
-        &= help "Enable extensional interpretation of function equality"
-        &= name "extensionality"
-
-  , nopolyinfer
-    = def
-        &= help "No inference of polymorphic type application. Gives imprecision, but speedup."
-        &= name "fast"
-
-  , reflection
-    = def
-        &= help "Enable reflection of Haskell functions and theorem proving"
-        &= name "reflection"
-
-  , compileSpec
-    = def
-        &= name "compile-spec"
-        &= help "Only compile specifications (into .bspec file); skip verification"
-
-  , noCheckImports
-    = def
-        &= name "no-check-imports"
-        &= help "Do not check the transitive imports; only check the target files."
-
-  , typedHoles
-    = def
-        &= name "typed-holes"
-        &= help "Use (refinement) typed-holes [currently warns on '_x' variables]"
-  , maxMatchDepth
-    = def
-        &= name "max-match-depth"
-        &= help "Define the number of expressions to pattern match on (typed-holes must be on to use this flag)."
-  , maxAppDepth
-    = def
-        &= name "max-app-depth"
-  , maxArgsDepth
-    = def
-        &= name "max-args-depth"
-  ,
-    maxRWOrderingConstraints
-    = def
-        &= name "max-rw-ordering-constraints"
-        &= help (   "Maximium number of symbols to compare for rewrite termination. " 
-                 ++ "Lower values can speedup verification, but rewriting may terminate prematurely. "
-                 ++ "Leave empty to consider all symbols." )
-  ,
-    rwTerminationCheck
-    = def
-        &= name "rw-termination-check"
-        &= help (   "Enable the rewrite divergence checker. " 
-                 ++ "Can speed up verification if rewriting terminates, but can also cause divergence."
-                )
-  } &= program "liquid"
-    &= help    "Refinement Types for Haskell"
-    &= summary copyright
-    &= details [ "LiquidHaskell is a Refinement Type based verifier for Haskell"
-               , ""
-               , "To check a Haskell file foo.hs, type:"
-               , "  liquid foo.hs "
-               ]
-
-defaultPort :: Int
-defaultPort = 3000
-
-getOpts :: [String] -> IO Config
-getOpts as = do
-  cfg0   <- envCfg
-  cfg1   <- mkOpts =<< cmdArgsRun'
-                         config { modeValue = (modeValue config)
-                                                { cmdArgsValue   = cfg0
-                                                }
-                                }
-                         as
-  cfg    <- fixConfig cfg1
-  setVerbosity (loggingVerbosity cfg)
-  when (json cfg) $ setVerbosity Quiet
-  withSmtSolver cfg
-
--- | Shows the LiquidHaskell banner, that includes things like the copyright, the
--- git commit and the version.
-printLiquidHaskellBanner :: IO ()
-printLiquidHaskellBanner = whenNormal $ putStrLn copyright
-
-cmdArgsRun' :: Mode (CmdArgs a) -> [String] -> IO a
-cmdArgsRun' md as
-  = case parseResult of
-      Left e  -> putStrLn (helpMsg e) >> exitFailure
-      Right a -> cmdArgsApply a
-    where
-      helpMsg e = showText defaultWrap $ helpText [e] HelpFormatDefault md
-      parseResult = process md (wideHelp as)
-      wideHelp = map (\a -> if a == "--help" || a == "-help" then "--help=120" else a)
-
-
---------------------------------------------------------------------------------
-withSmtSolver :: Config -> IO Config
---------------------------------------------------------------------------------
-withSmtSolver cfg =
-  case smtsolver cfg of
-    Just smt -> do found <- findSmtSolver smt
-                   case found of
-                     Just _ -> return cfg
-                     Nothing -> panic Nothing (missingSmtError smt)
-    Nothing  -> do smts <- mapM findSmtSolver [FC.Z3, FC.Cvc4, FC.Mathsat]
-                   case catMaybes smts of
-                     (s:_) -> return (cfg {smtsolver = Just s})
-                     _     -> panic Nothing noSmtError
-  where
-    noSmtError = "LiquidHaskell requires an SMT Solver, i.e. z3, cvc4, or mathsat to be installed."
-    missingSmtError smt = "Could not find SMT solver '" ++ show smt ++ "'. Is it on your PATH?"
-
-findSmtSolver :: FC.SMTSolver -> IO (Maybe FC.SMTSolver)
-findSmtSolver smt = maybe Nothing (const $ Just smt) <$> findExecutable (show smt)
-
-fixConfig :: Config -> IO Config
-fixConfig cfg = do
-  pwd <- getCurrentDirectory
-  cfg <- canonicalizePaths pwd cfg
-  return $ canonConfig cfg
-
--- | Attempt to canonicalize all `FilePath's in the `Config' so we don't have
---   to worry about relative paths.
-canonicalizePaths :: FilePath -> Config -> IO Config
-canonicalizePaths pwd cfg = do
-  tgt   <- canonicalizePath pwd
-  isdir <- doesDirectoryExist tgt
-  is    <- mapM (canonicalize tgt isdir) $ idirs cfg
-  cs    <- mapM (canonicalize tgt isdir) $ cFiles cfg
-  return $ cfg { idirs = is, cFiles = cs }
-
-canonicalize :: FilePath -> Bool -> FilePath -> IO FilePath
-canonicalize tgt isdir f
-  | isAbsolute f = return f
-  | isdir        = canonicalizePath (tgt </> f)
-  | otherwise    = canonicalizePath (takeDirectory tgt </> f)
-
-envCfg :: IO Config
-envCfg = do
-  so <- lookupEnv "LIQUIDHASKELL_OPTS"
-  case so of
-    Nothing -> return defConfig
-    Just s  -> parsePragma $ envLoc s
-  where
-    envLoc  = Loc l l
-    l       = newPos "ENVIRONMENT" 0 0
-
-copyright :: String
-copyright = concat $ concat
-  [ ["LiquidHaskell "]
-  , [$(simpleVersion Meta.version)]
-  , [gitInfo]
-  -- , [" (" ++ _commitCount ++ " commits)" | _commitCount /= ("1"::String) &&
-  --                                          _commitCount /= ("UNKNOWN" :: String)]
-  , ["\nCopyright 2013-19 Regents of the University of California. All Rights Reserved.\n"]
-  ]
-  where
-    _commitCount = $gitCommitCount
-
-gitInfo :: String
-gitInfo  = msg
-  where
-    giTry  = $$tGitInfoCwdTry
-    msg    = case giTry of
-               Left _   -> " no git information"
-               Right gi -> gitMsg gi
-
-gitMsg :: GitInfo -> String
-gitMsg gi = concat
-  [ " [", giBranch gi, "@", giHash gi
-  , " (", giCommitDate gi, ")"
-  -- , " (", show (giCommitCount gi), " commits in HEAD)"
-  , "] "
-  ]
-
-
--- [NOTE:searchpath]
--- 1. we used to add the directory containing the file to the searchpath,
---    but this is bad because GHC does NOT do this, and it causes spurious
---    "duplicate module" errors in the following scenario
---      > tree
---      .
---      ├── Bar.hs
---      └── Foo
---          ├── Bar.hs
---          └── Goo.hs
---    If we run `liquid Foo/Goo.hs` and that imports Bar, GHC will not know
---    whether we mean to import Bar.hs or Foo/Bar.hs
--- 2. tests fail if you flip order of idirs'
-
-mkOpts :: Config -> IO Config
-mkOpts cfg = do
-  let files' = sortNub $ files cfg
-  id0       <- getIncludeDir
-  return     $ cfg { files       = files'
-                                   -- See NOTE [searchpath]
-                   , idirs       = [id0 </> gHC_VERSION, id0]
-                                ++ idirs cfg
-                   }
-
---------------------------------------------------------------------------------
--- | Updating options
---------------------------------------------------------------------------------
-canonConfig :: Config -> Config
-canonConfig cfg = cfg
-  { diffcheck   = diffcheck cfg && not (fullcheck cfg)
-  -- , eliminate   = if higherOrderFlag cfg then FC.All else eliminate cfg
-  }
-
---------------------------------------------------------------------------------
-withPragmas :: Config -> FilePath -> [Located String] -> IO Config
---------------------------------------------------------------------------------
-withPragmas cfg fp ps
-  = foldM withPragma cfg ps >>= canonicalizePaths fp >>= (return . canonConfig)
-
-withPragma :: Config -> Located String -> IO Config
-withPragma c s = withArgs [val s] $ cmdArgsRun
-          config { modeValue = (modeValue config) { cmdArgsValue = c } }
-
-parsePragma   :: Located String -> IO Config
-parsePragma = withPragma defConfig
-
-defConfig :: Config
-defConfig = Config
-  { loggingVerbosity         = Quiet
-  , files                    = def
-  , idirs                    = def
-  , fullcheck                = def
-  , linear                   = def
-  , stringTheory             = def
-  , higherorder              = def
-  , smtTimeout               = def
-  , higherorderqs            = def
-  , diffcheck                = def
-  , saveQuery                = def
-  , checks                   = def
-  , nostructuralterm         = def
-  , noCheckUnknown           = def
-  , notermination            = False
-  , rankNTypes               = False
-  , noclasscheck             = False
-  , gradual                  = False
-  , bscope                   = False
-  , gdepth                   = 1
-  , ginteractive             = False
-  , totalHaskell             = def -- True
-  , nowarnings               = def
-  , noannotations            = def
-  , checkDerived             = False
-  , caseExpandDepth          = 2
-  , notruetypes              = def
-  , nototality               = False
-  , pruneUnsorted            = def
-  , exactDC                  = def
-  , noADT                    = def
-  , cores                    = def
-  , minPartSize              = FC.defaultMinPartSize
-  , maxPartSize              = FC.defaultMaxPartSize
-  , maxParams                = defaultMaxParams
-  , smtsolver                = def
-  , shortNames               = def
-  , shortErrors              = def
-  , cabalDir                 = def
-  , ghcOptions               = def
-  , cFiles                   = def
-  , port                     = defaultPort
-  , scrapeInternals          = False
-  , scrapeImports            = False
-  , scrapeUsedImports        = False
-  , elimStats                = False
-  , elimBound                = Nothing
-  , json                     = False
-  , counterExamples          = False
-  , timeBinds                = False
-  , untidyCore               = False
-  , eliminate                = FC.Some
-  , noPatternInline          = False
-  , noSimplifyCore           = False
-  -- PLE-OPT , autoInstantiate   = def
-  , noslice                  = False
-  , noLiftedImport           = False
-  , proofLogicEval           = False
-  , oldPLE                   = False
-  , proofLogicEvalLocal      = False
-  , reflection               = False
-  , extensionality           = False
-  , nopolyinfer              = False
-  , compileSpec              = False
-  , noCheckImports           = False
-  , typedHoles               = False
-  , maxMatchDepth            = 4
-  , maxAppDepth              = 2
-  , maxArgsDepth             = 1
-  , maxRWOrderingConstraints = Nothing
-  , rwTerminationCheck       = False
-  }
-
-
--- | Writes the annotations (i.e. the files in the \".liquid\" hidden folder) and report the result
--- of the checking using a supplied function.
-reportResult :: MonadIO m
-             => (OutputResult -> m ())
-             -> Config
-             -> [FilePath]
-             -> Output Doc
-             -> m ()
-reportResult logResultFull cfg targets out = do
-  annm <- {-# SCC "annotate" #-} liftIO $ annotate cfg targets out
-  liftIO $ whenNormal $ donePhase Loud "annotate"
-  if | json cfg  -> liftIO $ reportResultJson annm
-     | otherwise -> do
-         let r = o_result out
-         liftIO $ writeCheckVars $ o_vars out
-         cr <- liftIO $ resultWithContext r
-         let outputResult = resDocs tidy cr
-         -- For now, always print the \"header\" with colours, irrespective to the logger
-         -- passed as input.
-         liftIO $ printHeader (colorResult r) (orHeader outputResult)
-         logResultFull outputResult
-  pure ()
-  where
-    tidy :: F.Tidy
-    tidy = if shortErrors cfg then F.Lossy else F.Full
-
-    printHeader :: Moods -> Doc -> IO ()
-    printHeader mood d = colorPhaseLn mood "" (render d)
-
-
-------------------------------------------------------------------------
-exitWithResult :: Config -> [FilePath] -> Output Doc -> IO ()
-------------------------------------------------------------------------
-exitWithResult cfg = reportResult writeResultStdout cfg
-
-reportResultJson :: ACSS.AnnMap -> IO ()
-reportResultJson annm = do
-  putStrLn "LIQUID"
-  B.putStrLn . encode . annErrors $ annm
-
-resultWithContext :: F.FixResult UserError -> IO (FixResult CError)
-resultWithContext (F.Unsafe s es)  = F.Unsafe s    <$> errorsWithContext es
-resultWithContext (F.Crash  es s)  = (`F.Crash` s) <$> errorsWithContext es
-resultWithContext (F.Safe   stats) = return (F.Safe stats)
-
-instance Show (CtxError Doc) where
-  show = showpp
-
-writeCheckVars :: Symbolic a => Maybe [a] -> IO ()
-writeCheckVars Nothing     = return ()
-writeCheckVars (Just [])   = colorPhaseLn Loud "Checked Binders: None" ""
-writeCheckVars (Just ns)   = colorPhaseLn Loud "Checked Binders:" ""
-                          >> forM_ ns (putStrLn . symbolString . dropModuleNames . symbol)
-
-type CError = CtxError Doc
-
-data OutputResult = OutputResult {
-    orHeader :: Doc
-    -- ^ The \"header\" like \"LIQUID: SAFE\", or \"LIQUID: UNSAFE\".
-  , orMessages :: [(GHC.SrcSpan, Doc)]
-    -- ^ The list of pretty-printable messages (typically errors) together with their
-    -- source locations.
-  }
-
--- | Writes the result of this LiquidHaskell run to /stdout/.
-writeResultStdout :: OutputResult -> IO ()
-writeResultStdout (orMessages -> messages) = do
-  forM_ messages $ \(sSpan, doc) -> putStrLn (render $ pprint sSpan <> (text ": error: " <+> doc))
-
--- | Given a 'FixResult' parameterised over a 'CError', this function returns the \"header\" to show to
--- the user (i.e. \"SAFE\" or \"UNSAFE\") plus a list of 'Doc's together with the 'SrcSpan' they refer to.
-resDocs :: F.Tidy -> F.FixResult CError -> OutputResult
-resDocs _ (F.Safe  stats) =
-  OutputResult {
-    orHeader   = text $ "LIQUID: SAFE (" <> show (Solver.numChck stats) <> " constraints checked)"
-  , orMessages = mempty
-  }
-resDocs k (F.Crash xs s)  =
-  OutputResult {
-    orHeader = text "LIQUID: ERROR" <+> text s
-  , orMessages = map (cErrToSpanned k . errToFCrash) xs
-  }
-resDocs k (F.Unsafe _ xs)   =
-  OutputResult {
-    orHeader   = text "LIQUID: UNSAFE"
-  , orMessages = map (cErrToSpanned k) (nub xs)
-  }
-
--- | Renders a 'CError' into a 'Doc' and its associated 'SrcSpan'.
-cErrToSpanned :: F.Tidy -> CError -> (GHC.SrcSpan, Doc)
-cErrToSpanned k CtxError{ctErr} = (pos ctErr, pprintTidy k ctErr)
-
-errToFCrash :: CtxError a -> CtxError a
-errToFCrash ce = ce { ctErr    = tx $ ctErr ce}
-  where
-    tx (ErrSubType l m g t t') = ErrFCrash l m g t t'
-    tx e                       = e
-
-{-
-   TODO: Never used, do I need to exist?
-reportUrl = text "Please submit a bug report at: https://github.com/ucsd-progsys/liquidhaskell" -}
-
-addErrors :: FixResult a -> [a] -> FixResult a
-addErrors r []               = r
-addErrors (Safe s) errs      = Unsafe s errs
-addErrors (Unsafe s xs) errs = Unsafe s (xs ++ errs)
-addErrors r  _               = r
-
-instance Fixpoint (F.FixResult CError) where
-  toFix = vcat . map snd . orMessages . resDocs F.Full
diff --git a/src/Language/Haskell/Liquid/UX/Config.hs b/src/Language/Haskell/Liquid/UX/Config.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/UX/Config.hs
+++ /dev/null
@@ -1,155 +0,0 @@
--- | Command Line Configuration Options ----------------------------------------
-
-{-# LANGUAGE DeriveDataTypeable         #-}
-{-# LANGUAGE DeriveGeneric #-}
-
-module Language.Haskell.Liquid.UX.Config (
-     Config (..)
-   , HasConfig (..)
-   , allowPLE, allowLocalPLE, allowGlobalPLE
-   , patternFlag
-   , higherOrderFlag
-   , pruneFlag
-   , maxCaseExpand
-   , exactDCFlag
-   , hasOpt
-   , totalityCheck
-   , terminationCheck
-   , structuralTerm
-   ) where
-
-import Prelude hiding (error)
-import Language.Fixpoint.Types.Config hiding (Config)
-import GHC.Generics
-import System.Console.CmdArgs
-
--- NOTE: adding strictness annotations breaks the help message
-data Config = Config
-  { loggingVerbosity         :: Verbosity  -- ^ the logging verbosity to use (defaults to 'Quiet')
-  , files                    :: [FilePath] -- ^ source files to check
-  , idirs                    :: [FilePath] -- ^ path to directory for including specs
-  , diffcheck                :: Bool       -- ^ check subset of binders modified (+ dependencies) since last check
-  , linear                   :: Bool       -- ^ uninterpreted integer multiplication and division
-  , stringTheory             :: Bool       -- ^ interpretation of string theory in the logic
-  , higherorder              :: Bool       -- ^ allow higher order binders into the logic
-  , higherorderqs            :: Bool       -- ^ allow higher order qualifiers
-  , smtTimeout               :: Maybe Int  -- ^ smt timeout
-  , fullcheck                :: Bool       -- ^ check all binders (overrides diffcheck)
-  , saveQuery                :: Bool       -- ^ save fixpoint query
-  , checks                   :: [String]   -- ^ set of binders to check
-  , noCheckUnknown           :: Bool       -- ^ whether to complain about specifications for unexported and unused values
-  , notermination            :: Bool       -- ^ disable termination check
-  , rankNTypes               :: Bool       -- ^ Adds precise reasoning on presence of rankNTypes
-  , noclasscheck             :: Bool       -- ^ disable checking class instances
-  -- , structuralTerm        :: Bool       -- ^ use structural termination checker
-  , nostructuralterm         :: Bool       -- ^ disable structural termination check
-  , gradual                  :: Bool       -- ^ enable gradual type checking
-  , bscope                   :: Bool       -- ^ scope of the outer binders on the inner refinements
-  , gdepth                   :: Int        -- ^ depth of gradual concretization
-  , ginteractive             :: Bool       -- ^ interactive gradual solving
-  , totalHaskell             :: Bool       -- ^ Check for termination and totality, Overrides no-termination flags
-  , nowarnings               :: Bool       -- ^ disable warnings output (only show errors)
-  , noannotations            :: Bool       -- ^ disable creation of intermediate annotation files
-  , checkDerived             :: Bool       -- ^ check internal (GHC-derived) binders
-  , caseExpandDepth          :: Int        -- ^ maximum case expand nesting depth.
-  , notruetypes              :: Bool       -- ^ disable truing top level types
-  , nototality               :: Bool       -- ^ disable totality check in definitions
-  , pruneUnsorted            :: Bool       -- ^ enable prunning unsorted Refinements
-  , cores                    :: Maybe Int  -- ^ number of cores used to solve constraints
-  , minPartSize              :: Int        -- ^ Minimum size of a partition
-  , maxPartSize              :: Int        -- ^ Maximum size of a partition. Overrides minPartSize
-  , maxParams                :: Int        -- ^ the maximum number of parameters to accept when mining qualifiers
-  , smtsolver                :: Maybe SMTSolver  -- ^ name of smtsolver to use [default: try z3, cvc4, mathsat in order]
-  , shortNames               :: Bool       -- ^ drop module qualifers from pretty-printed names.
-  , shortErrors              :: Bool       -- ^ don't show subtyping errors and contexts.
-  , cabalDir                 :: Bool       -- ^ find and use .cabal file to include paths to sources for imported modules
-  , ghcOptions               :: [String]   -- ^ command-line options to pass to GHC
-  , cFiles                   :: [String]   -- ^ .c files to compile and link against (for GHC)
-  , eliminate                :: Eliminate  -- ^ eliminate (i.e. don't use qualifs for) for "none", "cuts" or "all" kvars
-  , port                     :: Int        -- ^ port at which lhi should listen
-  , exactDC                  :: Bool       -- ^ Automatically generate singleton types for data constructors
-  , noADT                    :: Bool       -- ^ Disable ADTs (only used with exactDC)
-  , scrapeImports            :: Bool       -- ^ scrape qualifiers from imported specifications
-  , scrapeInternals          :: Bool       -- ^ scrape qualifiers from auto specifications
-  , scrapeUsedImports        :: Bool       -- ^ scrape qualifiers from used, imported specifications
-  , elimStats                :: Bool       -- ^ print eliminate stats
-  , elimBound                :: Maybe Int  -- ^ eliminate upto given depth of KVar chains
-  , json                     :: Bool       -- ^ print results (safe/errors) as JSON
-  , counterExamples          :: Bool       -- ^ attempt to generate counter-examples to type errors
-  , timeBinds                :: Bool       -- ^ check and time each (asserted) type-sig separately
-  , noPatternInline          :: Bool       -- ^ treat code patterns (e.g. e1 >>= \x -> e2) specially for inference
-  , untidyCore               :: Bool       -- ^ print full blown core (with untidy names) in verbose mode
-  , noSimplifyCore           :: Bool       -- ^ simplify GHC core before constraint-generation
-  -- PLE-OPT , autoInst      ntiate :: Instantiate -- ^ How to instantiate axioms
-  , noslice                  :: Bool       -- ^ Disable non-concrete KVar slicing
-  , noLiftedImport           :: Bool       -- ^ Disable loading lifted specifications (for "legacy" libs)
-  , proofLogicEval           :: Bool       -- ^ Enable proof-by-logical-evaluation
-  , oldPLE                   :: Bool       -- ^ Enable proof-by-logical-evaluation
-  , proofLogicEvalLocal      :: Bool       -- ^ Enable proof-by-logical-evaluation locally, per function
-  , extensionality           :: Bool       -- ^ Enable extensional interpretation of function equality
-  , nopolyinfer              :: Bool       -- ^ No inference of polymorphic type application.
-  , reflection               :: Bool       -- ^ Allow "reflection"; switches on "--higherorder" and "--exactdc"
-  , compileSpec              :: Bool       -- ^ Only "compile" the spec -- into .bspec file -- don't do any checking.
-  , noCheckImports           :: Bool       -- ^ Do not check the transitive imports
-  , typedHoles               :: Bool       -- ^ Warn about "typed-holes"
-  , maxMatchDepth            :: Int
-  , maxAppDepth              :: Int
-  , maxArgsDepth             :: Int
-  , maxRWOrderingConstraints :: Maybe Int
-  , rwTerminationCheck       :: Bool
-  } deriving (Generic, Data, Typeable, Show, Eq)
-
-allowPLE :: Config -> Bool
-allowPLE cfg
-  =  allowGlobalPLE cfg
-  || allowLocalPLE cfg
-
-allowGlobalPLE :: Config -> Bool
-allowGlobalPLE cfg = proofLogicEval  cfg
-
-allowLocalPLE :: Config -> Bool
-allowLocalPLE cfg = proofLogicEvalLocal  cfg
-
-instance HasConfig  Config where
-  getConfig x = x
-
-class HasConfig t where
-  getConfig :: t -> Config
-
-patternFlag :: (HasConfig t) => t -> Bool
-patternFlag = not . noPatternInline . getConfig
-
-higherOrderFlag :: (HasConfig t) => t -> Bool
-higherOrderFlag x = higherorder cfg || reflection cfg
-  where
-    cfg           = getConfig x
-
-exactDCFlag :: (HasConfig t) => t -> Bool
-exactDCFlag x = exactDC cfg || reflection cfg
-  where
-    cfg       = getConfig x
-
-pruneFlag :: (HasConfig t) => t -> Bool
-pruneFlag = pruneUnsorted . getConfig
-
-maxCaseExpand :: (HasConfig t) => t -> Int
-maxCaseExpand = caseExpandDepth . getConfig
-
-hasOpt :: (HasConfig t) => t -> (Config -> Bool) -> Bool
-hasOpt t f = f (getConfig t)
-
-totalityCheck :: (HasConfig t) => t -> Bool
-totalityCheck = totalityCheck' . getConfig
-
-terminationCheck :: (HasConfig t) => t -> Bool
-terminationCheck = terminationCheck' . getConfig
-
-totalityCheck' :: Config -> Bool
-totalityCheck' cfg = (not (nototality cfg)) || totalHaskell cfg
-
-terminationCheck' :: Config -> Bool
-terminationCheck' cfg = (totalHaskell cfg || not (notermination cfg))
-
-structuralTerm :: (HasConfig a) => a -> Bool
-structuralTerm = not . nostructuralterm . getConfig
-
diff --git a/src/Language/Haskell/Liquid/UX/DiffCheck.hs b/src/Language/Haskell/Liquid/UX/DiffCheck.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/UX/DiffCheck.hs
+++ /dev/null
@@ -1,546 +0,0 @@
--- | This module contains the code for Incremental checking, which finds the
---   part of a target file (the subset of the @[CoreBind]@ that have been
---   modified since it was last checked, as determined by a diff against
---   a saved version of the file.
-
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE FlexibleContexts  #-}
-{-# LANGUAGE FlexibleInstances #-}
-
-module Language.Haskell.Liquid.UX.DiffCheck (
-
-   -- * Changed binders + Unchanged Errors
-     DiffCheck (..)
-
-   -- * Use previously saved info to generate DiffCheck target
-   , slice
-
-   -- * Use target binders to generate DiffCheck target
-   , thin -- , ThinDeps (..)
-
-   -- * Save current information for next time
-   , saveResult
-
-   -- * Names of top-level binders that are rechecked
-   , checkedVars
-
-   -- * CoreBinds defining given set of Var
-   , filterBinds
-   , coreDeps
-   , dependsOn
-   )
-   where
-
-
-import           FastString                             (FastString)
-import           Prelude                                hiding (error)
-import           Data.Aeson
-import qualified Data.Text                              as T
-import           Data.Algorithm.Diff
-import           Data.Maybe                             (listToMaybe, mapMaybe, fromMaybe)
-import qualified Data.IntervalMap.FingerTree            as IM
-import           CoreSyn                                hiding (sourceName)
-import           Name                                   (getSrcSpan, NamedThing)
-import           Outputable                             (Outputable, OutputableBndr)
-import           SrcLoc                                 hiding (Located)
-import           Var
-import qualified Data.HashSet                           as S
-import qualified Data.HashMap.Strict                    as M
-import qualified Data.List                              as L
-import           System.Directory                       (copyFile, doesFileExist)
-import           Language.Fixpoint.Types                (atLoc, FixResult (..))
-import           Language.Fixpoint.Utils.Files
-import           Language.Fixpoint.Solver.Stats         as Solver
-import           Language.Haskell.Liquid.Misc           (ifM, mkGraph)
-import           Language.Haskell.Liquid.GHC.Misc
--- import           Language.Haskell.Liquid.Types.Visitors
-import           Text.Parsec.Pos                        (sourceName, sourceLine, sourceColumn, SourcePos, newPos)
-import           Text.PrettyPrint.HughesPJ              (text, render, Doc)
--- import           Language.Haskell.Liquid.Types.Errors
-import qualified Data.ByteString                        as B
-import qualified Data.ByteString.Lazy                   as LB                                               
-
-import           Language.Haskell.Liquid.Types          hiding (Def, LMap)
-
---------------------------------------------------------------------------------
--- | Data Types ----------------------------------------------------------------
---------------------------------------------------------------------------------
-
--- | Main type of value returned for diff-check.
-data DiffCheck = DC { newBinds  :: [CoreBind]
-                    , oldOutput :: !(Output Doc)
-                    , newSpec   :: !TargetSpec
-                    }
-
-instance PPrint DiffCheck where
-  pprintTidy k = pprintTidy k . checkedVars
-
--- | Variable definitions
-data Def  = D { start  :: Int -- ^ line at which binder definition starts
-              , end    :: Int -- ^ line at which binder definition ends
-              , binder :: Var -- ^ name of binder
-              }
-            deriving (Eq, Ord)
-
--- | Variable dependencies "call-graph"
-type Deps = M.HashMap Var (S.HashSet Var)
-
--- | Map from saved-line-num ---> current-line-num
-type LMap   = IM.IntervalMap Int Int
-
--- | Intervals of line numbers that have been re-checked
-type ChkItv = IM.IntervalMap Int ()
-
-instance Show Def where
-  show (D i j x) = showPpr x ++ " start: " ++ show i ++ " end: " ++ show j
-
---------------------------------------------------------------------------------
--- | `checkedNames` returns the names of the top-level binders that will be checked
---------------------------------------------------------------------------------
-checkedVars              ::  DiffCheck -> [Var]
-checkedVars              = concatMap names . newBinds
-   where
-     names (NonRec v _ ) = [v]
-     names (Rec xs)      = fst <$> xs
-
---------------------------------------------------------------------------------
--- | `slice` returns a subset of the @[CoreBind]@ of the input `target`
---    file which correspond to top-level binders whose code has changed
---    and their transitive dependencies.
---------------------------------------------------------------------------------
-slice :: FilePath -> [CoreBind] -> TargetSpec -> IO (Maybe DiffCheck)
---------------------------------------------------------------------------------
-slice target cbs sp = ifM (doesFileExist savedFile)
-                          doDiffCheck
-                          (return Nothing)
-  where
-    savedFile       = extFileName Saved target
-    doDiffCheck     = sliceSaved target savedFile cbs sp
-
-sliceSaved :: FilePath -> FilePath -> [CoreBind] -> TargetSpec -> IO (Maybe DiffCheck)
-sliceSaved target savedFile coreBinds spec = do
-  (is, lm) <- lineDiff target savedFile
-  result   <- loadResult target
-  return    $ sliceSaved' target is lm (DC coreBinds result spec)
-
-sliceSaved' :: FilePath -> [Int] -> LMap -> DiffCheck -> Maybe DiffCheck
-sliceSaved' srcF is lm (DC coreBinds result spec)
-  | gDiff     = Nothing
-  | otherwise = Just $ DC cbs' res' sp'
-  where
-    gDiff     = globalDiff srcF is spec
-    sp'       = assumeSpec sigm spec
-    res'      = adjustOutput lm cm result
-    cm        = checkedItv (coreDefs cbs')
-    cbs'      = thinWith sigs coreBinds (diffVars is defs)
-    defs      = coreDefs coreBinds ++ specDefs srcF spec
-    sigs      = S.fromList $ M.keys sigm
-    sigm      = sigVars srcF is spec
-
--- | Add the specified signatures for vars-with-preserved-sigs,
---   whose bodies have been pruned from [CoreBind] into the "assumes"
-
-assumeSpec :: M.HashMap Var LocSpecType -> TargetSpec -> TargetSpec
-assumeSpec sigm sp = sp { gsSig = gsig { gsAsmSigs = M.toList $ M.union sigm assm } }
-  where
-    assm           = M.fromList (gsAsmSigs gsig) 
-    gsig           = gsSig sp
-
-diffVars :: [Int] -> [Def] -> [Var]
-diffVars ls defs'    = -- tracePpr ("INCCHECK: diffVars lines = " ++ show ls ++ " defs= " ++ show defs) $
-                         go (L.sort ls) defs
-  where
-    defs             = L.sort defs'
-    go _      []     = []
-    go []     _      = []
-    go (i:is) (d:ds)
-      | i < start d  = go is (d:ds)
-      | i > end d    = go (i:is) ds
-      | otherwise    = binder d : go (i:is) ds
-
-sigVars :: FilePath -> [Int] -> TargetSpec -> M.HashMap Var LocSpecType
-sigVars srcF ls sp = M.fromList $ filter (ok . snd) $ specSigs sp
-  where
-    ok             = not . isDiff srcF ls
-
-globalDiff :: FilePath -> [Int] -> TargetSpec -> Bool
-globalDiff srcF ls gspec = measDiff || invsDiff || dconsDiff
-  where
-    measDiff  = any (isDiff srcF ls) (snd <$> gsMeas spec)
-    invsDiff  = any (isDiff srcF ls) (snd <$> gsInvariants spec)
-    dconsDiff = any (isDiff srcF ls) [ atLoc ldc () | ldc <- gsDconsP (gsName gspec) ]
-    spec      = gsData gspec
-    -- (dloc . snd <$> gsDconsP spec)
-    -- dloc dc   = Loc (dc_loc dc) (dc_locE dc) ()
-
-
-isDiff :: FilePath -> [Int] -> Located a -> Bool
-isDiff srcF ls x = file x == srcF && any hits ls
-  where
-    hits i       = line x <= i && i <= lineE x
-
---------------------------------------------------------------------------------
--- | @thin cbs sp vs@ returns a subset of the @cbs :: [CoreBind]@ which
---   correspond to the definitions of @vs@ and the functions transitively
---   called therein for which there are *no* type signatures. Callees with
---   type signatures are assumed to satisfy those signatures.
---------------------------------------------------------------------------------
-
-{- data ThinDeps = Trans [Var] -- ^ Check all transitive dependencies
-              | None   Var  -- ^ Check only the given binders
- -}
-
---------------------------------------------------------------------------------
-thin :: [CoreBind] -> TargetSpec -> [Var] -> DiffCheck
---------------------------------------------------------------------------------
--- thin cbs sp (Trans vs) = DC (thinWith S.empty cbs vs ) mempty sp
-thin cbs sp vs = DC (filterBinds      cbs vs') mempty sp'
-  where
-    vs'        = txClosure (coreDeps cbs) xs (S.fromList vs)
-    sp'        = assumeSpec sigs' sp
-    sigs'      = foldr M.delete (M.fromList xts) vs
-    xts        = specSigs sp
-    xs         = S.fromList $ fst <$> xts
-
-thinWith :: S.HashSet Var -> [CoreBind] -> [Var] -> [CoreBind]
-thinWith sigs cbs xs = filterBinds cbs ys
-  where
-    ys       = calls `S.union` calledBy
-    calls    = txClosure (coreDeps cbs) sigs (S.fromList xs)
-    calledBy = dependsOn (coreDeps cbs) xs
-
-coreDeps    :: [CoreBind] -> Deps
-coreDeps bs = mkGraph $ calls ++ calls'
-  where
-    calls   = concatMap deps bs
-    calls'  = [(y, x) | (x, y) <- calls]
-    deps b  = [(x, y) | x <- bindersOf b
-                      , y <- freeVars S.empty b]
-
--- | Given a call graph, and a list of vars, `dependsOn`
---   checks all functions to see if they call any of the
---   functions in the vars list.
---   If any do, then they must also be rechecked.
-
-dependsOn :: Deps -> [Var] -> S.HashSet Var
-dependsOn cg vars  = S.fromList results
-  where
-    preds          = map S.member vars
-    filteredMaps   = M.filter <$> preds <*> pure cg
-    results        = map fst $ M.toList $ M.unions filteredMaps
-
-txClosure :: Deps -> S.HashSet Var -> S.HashSet Var -> S.HashSet Var
-txClosure d sigs    = go S.empty
-  where
-    next            = S.unions . fmap deps . S.toList
-    deps x          = M.lookupDefault S.empty x d
-    go seen new
-      | S.null new  = seen
-      | otherwise   = let seen' = S.union seen new
-                          new'  = next new `S.difference` seen'
-                          new'' = new'     `S.difference` sigs
-                      in go seen' new''
-
-
-
---------------------------------------------------------------------------------
-filterBinds        :: [CoreBind] -> S.HashSet Var -> [CoreBind]
---------------------------------------------------------------------------------
-filterBinds cbs ys = filter f cbs
-  where
-    f (NonRec x _) = x `S.member` ys
-    f (Rec xes)    = any (`S.member` ys) $ fst <$> xes
-
-
---------------------------------------------------------------------------------
-specDefs :: FilePath -> TargetSpec -> [Def]
---------------------------------------------------------------------------------
-specDefs srcF  = map def . filter sameFile . specSigs
-  where
-    def (x, t) = D (line t) (lineE t) x
-    sameFile   = (srcF ==) . file . snd
-
-specSigs :: TargetSpec -> [(Var, LocSpecType)]
-specSigs sp = gsTySigs  (gsSig  sp) 
-           ++ gsAsmSigs (gsSig  sp) 
-           ++ gsCtors   (gsData sp)
-
---------------------------------------------------------------------------------
-coreDefs     :: [CoreBind] -> [Def]
---------------------------------------------------------------------------------
-coreDefs cbs = L.sort [D l l' x | b <- cbs
-                                , x <- bindersOf b
-                                , isGoodSrcSpan (getSrcSpan x)
-                                , (l, l') <- coreDef b]
-
-coreDef :: (NamedThing a, OutputableBndr a)
-        => Bind a -> [(Int, Int)]
-coreDef b    = meetSpans b eSp vSp
-  where
-    eSp      = lineSpan b $ catSpans b $ bindSpans b
-    vSp      = lineSpan b $ catSpans b $ getSrcSpan <$> bindersOf b
-
-
---------------------------------------------------------------------------------
--- | `meetSpans` cuts off the start-line to be no less than the line at which
---   the binder is defined. Without this, i.e. if we ONLY use the ticks and
---   spans appearing inside the definition of the binder (i.e. just `eSp`)
---   then the generated span can be WAY before the actual definition binder,
---   possibly due to GHC INLINE pragmas or dictionaries OR ...
---   for an example: see the "INCCHECK: Def" generated by
---      liquid -d benchmarks/bytestring-0.9.2.1/Data/ByteString.hs
---   where `spanEnd` is a single line function around 1092 but where
---   the generated span starts mysteriously at 222 where Data.List is imported.
-
-meetSpans :: Ord t1 => t -> Maybe (t1, t2) -> Maybe (t1, t3) -> [(t1, t2)]
-meetSpans _ Nothing       _
-  = []
-meetSpans _ (Just (l,l')) Nothing
-  = [(l, l')]
-meetSpans _ (Just (l,l')) (Just (m,_))
-  = [(max l m, l')]
-
-lineSpan :: t -> SrcSpan -> Maybe (Int, Int)
-lineSpan _ (RealSrcSpan sp) = Just (srcSpanStartLine sp, srcSpanEndLine sp)
-lineSpan _ _                = Nothing
-
-catSpans :: (NamedThing r, OutputableBndr r)
-         => Bind r -> [SrcSpan] -> SrcSpan
-catSpans b []               = panic Nothing $ "DIFFCHECK: catSpans: no spans found for " ++ showPpr b
-catSpans b xs               = foldr combineSrcSpans noSrcSpan [x | x@(RealSrcSpan z) <- xs, bindFile b == srcSpanFile z]
-
-bindFile
-  :: (Outputable r, NamedThing r) =>
-     Bind r -> FastString
-bindFile (NonRec x _) = varFile x
-bindFile (Rec xes)    = varFile $ fst $ head xes
-
-varFile :: (Outputable a, NamedThing a) => a -> FastString
-varFile b = case getSrcSpan b of
-              RealSrcSpan z -> srcSpanFile z
-              _             -> panic Nothing $ "DIFFCHECK: getFile: no file found for: " ++ showPpr b
-
-
-bindSpans :: NamedThing a => Bind a -> [SrcSpan]
-bindSpans (NonRec x e)    = getSrcSpan x : exprSpans e
-bindSpans (Rec    xes)    = map getSrcSpan xs ++ concatMap exprSpans es
-  where
-    (xs, es)              = unzip xes
-
-exprSpans :: NamedThing a => Expr a -> [SrcSpan]
-exprSpans (Tick t e)
-  | isJunkSpan sp         = exprSpans e
-  | otherwise             = [sp]
-  where
-    sp                    = tickSrcSpan t
-
-exprSpans (Var x)         = [getSrcSpan x]
-exprSpans (Lam x e)       = getSrcSpan x : exprSpans e
-exprSpans (App e a)       = exprSpans e ++ exprSpans a
-exprSpans (Let b e)       = bindSpans b ++ exprSpans e
-exprSpans (Cast e _)      = exprSpans e
-exprSpans (Case e x _ cs) = getSrcSpan x : exprSpans e ++ concatMap altSpans cs
-exprSpans _               = []
-
-altSpans :: (NamedThing a, NamedThing a1) => (t, [a], Expr a1) -> [SrcSpan]
-altSpans (_, xs, e)       = map getSrcSpan xs ++ exprSpans e
-
-isJunkSpan :: SrcSpan -> Bool
-isJunkSpan (RealSrcSpan _) = False
-isJunkSpan _               = True
-
---------------------------------------------------------------------------------
--- | Diff Interface ------------------------------------------------------------
---------------------------------------------------------------------------------
--- | `lineDiff new old` compares the contents of `src` with `dst`
---   and returns the lines of `src` that are different.
---------------------------------------------------------------------------------
-lineDiff :: FilePath -> FilePath -> IO ([Int], LMap)
---------------------------------------------------------------------------------
-lineDiff new old  = lineDiff' <$> getLines new <*> getLines old
-  where
-    getLines      = fmap lines . readFile
-
-lineDiff' :: [String] -> [String] -> ([Int], LMap)
-lineDiff' new old = (changedLines, lm)
-  where
-    changedLines  = diffLines 1 diffLineCount
-    lm            = foldr setShift IM.empty $ diffShifts diffLineCount
-    diffLineCount = fmap length <$> getGroupedDiff new old
-
--- | Identifies lines that have changed
-diffLines :: Int        -- ^ Starting line
-          -> [Diff Int] -- ^ List of lengths of diffs
-          -> [Int]      -- ^ List of changed line numbers
-diffLines _ []                        = []
-diffLines curr (Both lnsUnchgd _ : d) = diffLines toSkip d
-   where toSkip = curr + lnsUnchgd
-diffLines curr (First lnsChgd : d)    = [curr..(toTake-1)] ++ diffLines toTake d
-   where toTake = curr + lnsChgd
-diffLines curr (_ : d)                = diffLines curr d
-
-diffShifts :: [Diff Int] -> [(Int, Int, Int)]
-diffShifts = go 1 1
-  where
-    go old new (Both n _ : d) = (old, old + n - 1, new - old) : go (old + n)
-                                                                   (new + n)
-                                                                   d
-    go old new (Second n : d) = go (old + n) new d
-    go old new (First n  : d) = go old (new + n) d
-    go _   _   []             = []
-
-instance Functor Diff where
-  fmap f (First x)  = First (f x)
-  fmap f (Second x) = Second (f x)
-  fmap f (Both x y) = Both (f x) (f y)
-
--- | @save@ creates an .saved version of the @target@ file, which will be
---    used to find what has changed the /next time/ @target@ is checked.
---------------------------------------------------------------------------------
-saveResult :: FilePath -> Output Doc -> IO ()
---------------------------------------------------------------------------------
-saveResult target res
-  = do copyFile target saveF
-       B.writeFile errF $ LB.toStrict $ encode res
-    where
-       saveF = extFileName Saved  target
-       errF  = extFileName Cache  target
-
---------------------------------------------------------------------------------
-loadResult   :: FilePath -> IO (Output Doc)
---------------------------------------------------------------------------------
-loadResult f = ifM (doesFileExist jsonF) out (return mempty)
-  where
-    jsonF    = extFileName Cache f
-    out      = (fromMaybe mempty . decode . LB.fromStrict) <$> B.readFile jsonF
-
---------------------------------------------------------------------------------
-adjustOutput :: LMap -> ChkItv -> Output Doc -> Output Doc
---------------------------------------------------------------------------------
-adjustOutput lm cm o  = mempty { o_types  = adjustTypes  lm cm (o_types  o) }
-                               { o_result = adjustResult lm cm (o_result o) }
-
-adjustTypes :: LMap -> ChkItv -> AnnInfo a -> AnnInfo a
-adjustTypes lm cm (AI m)          = AI $ M.fromList
-                                    [(sp', v) | (sp, v)  <- M.toList m
-                                              , Just sp' <- [adjustSrcSpan lm cm sp]]
-
-adjustResult :: LMap -> ChkItv -> ErrorResult -> ErrorResult
-adjustResult lm cm (Unsafe s es)  = errorsResult (Unsafe s)  $ adjustErrors lm cm es
-adjustResult lm cm (Crash es z)   = errorsResult (`Crash` z) $ adjustErrors lm cm es
-adjustResult _  _  r              = r
-
-errorsResult :: ([a] -> FixResult b) -> [a] -> FixResult b
-errorsResult _ []                 = Safe mempty
-errorsResult f es                 = f es
-
-adjustErrors :: LMap -> ChkItv -> [TError a] -> [TError a]
-adjustErrors lm cm                = mapMaybe adjustError
-  where
-    adjustError e                 = case adjustSrcSpan lm cm (pos e) of
-                                      Just sp' -> Just (e {pos = sp'})
-                                      Nothing  -> Nothing
-
-    -- adjustError (ErrSaved sp m)   =  (`ErrSaved` m) <$>
-    -- adjustError e                 = Just e
-
---------------------------------------------------------------------------------
-adjustSrcSpan :: LMap -> ChkItv -> SrcSpan -> Maybe SrcSpan
---------------------------------------------------------------------------------
-adjustSrcSpan lm cm sp
-  = do sp' <- adjustSpan lm sp
-       if isCheckedSpan cm sp'
-         then Nothing
-         else Just sp'
-
-isCheckedSpan :: IM.IntervalMap Int a -> SrcSpan -> Bool
-isCheckedSpan cm (RealSrcSpan sp) = isCheckedRealSpan cm sp
-isCheckedSpan _  _                = False
-
-isCheckedRealSpan :: IM.IntervalMap Int a -> RealSrcSpan -> Bool
-isCheckedRealSpan cm              = not . null . (`IM.search` cm) . srcSpanStartLine
-
-adjustSpan :: LMap -> SrcSpan -> Maybe SrcSpan
-adjustSpan lm (RealSrcSpan rsp)   = RealSrcSpan <$> adjustReal lm rsp
-adjustSpan _  sp                  = Just sp
-
-adjustReal :: LMap -> RealSrcSpan -> Maybe RealSrcSpan
-adjustReal lm rsp
-  | Just δ <- getShift l1 lm      = Just $ realSrcSpan f (l1 + δ) c1 (l2 + δ) c2
-  | otherwise                     = Nothing
-  where
-    (f, l1, c1, l2, c2)           = unpackRealSrcSpan rsp
-
-
--- | @getShift lm old@ returns @Just δ@ if the line number @old@ shifts by @δ@
--- in the diff and returns @Nothing@ otherwise.
-getShift     :: Int -> LMap -> Maybe Int
-getShift old = fmap snd . listToMaybe . IM.search old
-
--- | @setShift (lo, hi, δ) lm@ updates the interval map @lm@ appropriately
-setShift             :: (Int, Int, Int) -> LMap -> LMap
-setShift (l1, l2, δ) = IM.insert (IM.Interval l1 l2) δ
-
-
-checkedItv :: [Def] -> ChkItv
-checkedItv chDefs = foldr (`IM.insert` ()) IM.empty is
-  where
-    is            = [IM.Interval l1 l2 | D l1 l2 _ <- chDefs]
-
-
---------------------------------------------------------------------------------
--- | Aeson instances -----------------------------------------------------------
---------------------------------------------------------------------------------
-
-instance ToJSON SourcePos where
-  toJSON p = object [   "sourceName"   .= f
-                      , "sourceLine"   .= l
-                      , "sourceColumn" .= c
-                      ]
-             where
-               f    = sourceName   p
-               l    = sourceLine   p
-               c    = sourceColumn p
-
-instance FromJSON SourcePos where
-  parseJSON (Object v) = newPos <$> v .: "sourceName"
-                                <*> v .: "sourceLine"
-                                <*> v .: "sourceColumn"
-  parseJSON _          = mempty
-
-instance ToJSON Solver.Stats where
-  toJSON = genericToJSON defaultOptions
-  toEncoding = genericToEncoding defaultOptions
-instance FromJSON Solver.Stats
-
-instance ToJSON ErrorResult where
-  toJSON = genericToJSON defaultOptions
-  toEncoding = genericToEncoding defaultOptions
-instance FromJSON ErrorResult
-
-instance ToJSON Doc where
-  toJSON = String . T.pack . render
-
-instance FromJSON Doc where
-  parseJSON (String s) = return $ text $ T.unpack s
-  parseJSON _          = mempty
-
-instance ToJSON a => ToJSON (AnnInfo a) where
-  toJSON = genericToJSON defaultOptions
-  toEncoding = genericToEncoding defaultOptions
-instance FromJSON a => FromJSON (AnnInfo a)
-
-instance ToJSON (Output Doc) where
-  toJSON = genericToJSON defaultOptions
-  toEncoding = genericToEncoding defaultOptions
-instance FromJSON (Output Doc)
-
-
-file :: Located a -> FilePath
-file = sourceName . loc
-
-line :: Located a -> Int
-line  = sourceLine . loc
-
-lineE :: Located a -> Int
-lineE = sourceLine . locE
diff --git a/src/Language/Haskell/Liquid/UX/Errors.hs b/src/Language/Haskell/Liquid/UX/Errors.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/UX/Errors.hs
+++ /dev/null
@@ -1,177 +0,0 @@
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE TupleSections     #-}
-{-# LANGUAGE BangPatterns      #-}
-
--- | This module contains the functions related to @Error@ type,
--- in particular, to @tidyError@ using a solution, and @pprint@ errors.
-
-module Language.Haskell.Liquid.UX.Errors ( tidyError ) where
-
-import           Control.Arrow                       (second)
-import qualified Data.HashMap.Strict                 as M
-import qualified Data.HashSet                        as S
-import qualified Data.List                           as L
-import           Data.Hashable
-import           Data.Maybe                          (maybeToList)
-import qualified Language.Fixpoint.Types             as F 
-import           Language.Haskell.Liquid.Types.RefType
-import           Language.Haskell.Liquid.Transforms.Simplify
-import           Language.Haskell.Liquid.UX.Tidy
-import           Language.Haskell.Liquid.Types
-import qualified Language.Haskell.Liquid.GHC.Misc    as GM 
-import qualified Language.Haskell.Liquid.Misc        as Misc 
-import qualified Language.Fixpoint.Misc              as Misc 
-
--- import Debug.Trace
-
-type Ctx  = M.HashMap F.Symbol SpecType
-type CtxM = M.HashMap F.Symbol (WithModel SpecType)
-
-------------------------------------------------------------------------
-tidyError :: Config -> F.FixSolution -> Error -> Error
-------------------------------------------------------------------------
-tidyError cfg sol
-  = fmap (tidySpecType tidy) 
-  . tidyErrContext tidy sol
-  where 
-    tidy = configTidy cfg 
-
-configTidy :: Config -> F.Tidy 
-configTidy cfg 
-  | shortNames cfg = F.Lossy 
-  | otherwise      = F.Full 
-
-tidyErrContext :: F.Tidy -> F.FixSolution -> Error -> Error
-tidyErrContext k _ e@(ErrSubType {})
-  = e { ctx = c', tact = F.subst θ tA, texp = F.subst θ tE }
-    where
-      (θ, c') = tidyCtx k xs (ctx e)
-      xs      = F.syms tA ++ F.syms tE
-      tA      = tact e
-      tE      = texp e
-
-tidyErrContext _ _ e@(ErrSubTypeModel {})
-  = e { ctxM = c', tactM = fmap (F.subst θ) tA, texp = fmap (F.subst θ) tE }
-    where
-      (θ, c') = tidyCtxM xs $ ctxM e
-      xs      = F.syms tA ++ F.syms tE
-      tA      = tactM e
-      tE      = texp e
-
-tidyErrContext k _ e@(ErrAssType {})
-  = e { ctx = c', cond = F.subst θ p }
-    where
-      m       = ctx e
-      (θ, c') = tidyCtx k xs m
-      xs      = F.syms p
-      p       = cond e
-
-tidyErrContext _ _ e
-  = e
-
---------------------------------------------------------------------------------
-tidyCtx       :: F.Tidy -> [F.Symbol] -> Ctx -> (F.Subst, Ctx)
---------------------------------------------------------------------------------
-tidyCtx k xs m = (θ1 `mappend` θ2, M.fromList yts)
-  where
-    yts        = [tBind x (tidySpecType k t) | (x, t) <- xt2s]
-    (θ2, xt2s) = tidyREnv xt1s 
-    (θ1, xt1s) = tidyTemps xts  
-    xts        = sliceREnv xs m 
-    tBind x t  = (x', shiftVV t x') where x' = F.tidySymbol x
-
-tidyCtxM       :: [F.Symbol] -> CtxM -> (F.Subst, CtxM)
-tidyCtxM xs m  = (θ, M.fromList yts)
-  where
-    yts       = [tBind x t | (x, t) <- xts]
-    (θ, xts)  = tidyTemps $ second (fmap stripReft) <$> tidyREnvM xs m
-    tBind x t = (x', fmap (\t -> shiftVV t x') t) where x' = F.tidySymbol x
-
-tidyREnv :: [(F.Symbol, SpecType)] -> (F.Subst, [(F.Symbol, SpecType)])
-tidyREnv xts    = (θ, second (F.subst θ) <$> zts)
-  where 
-    θ           = expandVarDefs yes 
-    (yes, zts)  = Misc.mapEither isInline xts 
-
--- | 'expandVarDefs [(x1, e1), ... ,(xn, en)] returns a `Subst` that  
---   contains the fully substituted definitions for each `xi`. For example, 
---      expandVarDefs [(x1, 'x2 + x3'), (x5, 'x1 + 1')] 
---   should return 
---     [x1 := 'x2 + x3, x5 := (x2 + x3) + 1]
-
-expandVarDefs :: [(F.Symbol, F.Expr)] -> F.Subst 
-expandVarDefs      = go mempty 
-  where 
-    go !su xes     
-      | null yes   = su `mappend` (F.mkSubst xes)
-      | otherwise  = go (su `mappend` su') xes''
-      where  
-       xes''       = [(z, F.subst su' e) | (z, e) <- zes] 
-       xs          = S.fromList [x | (x, _) <- xes] 
-       su'         = F.mkSubst yes
-       (yes, zes)  = L.partition (isDef xs . snd) xes 
-    isDef xs e     = all (not . (`S.member` xs)) (F.syms e) 
-
-isInline :: (a, SpecType) -> Either (a, F.Expr) (a, SpecType) 
-isInline (x, t) = either (Left . (x,)) (Right . (x,)) (isInline' t) 
-
-isInline' :: SpecType -> Either F.Expr SpecType 
-isInline' t = case ro of 
-                Nothing -> Right t' 
-                Just rr -> case F.isSingletonReft (ur_reft rr) of 
-                             Just e  -> Left e
-                             Nothing -> Right (strengthen t' rr) 
-              where 
-                  (t', ro) = stripRType t 
-
-stripReft     :: SpecType -> SpecType
-stripReft t   = maybe t' (strengthen t') ro
-  where
-    (t', ro)  = stripRType t
-
-stripRType    :: SpecType -> (SpecType, Maybe RReft)
-stripRType st = (t', ro)
-  where
-    t'        = fmap (const (uTop mempty)) t
-    ro        = stripRTypeBase  t
-    t         = simplifyBounds st
-
-sliceREnv :: [F.Symbol] -> Ctx -> [(F.Symbol, SpecType)]
-sliceREnv xs m = [(x, t) | x <- xs', t <- maybeToList (M.lookup x m), ok t]
-  where
-    xs'       = expandFix deps xs
-    deps y    = maybe [] (F.syms . rTypeReft) (M.lookup y m)
-    ok        = not . isFunTy
-
-tidyREnvM      :: [F.Symbol] -> CtxM -> [(F.Symbol, WithModel SpecType)]
-tidyREnvM xs m = [(x, t) | x <- xs', t <- maybeToList (M.lookup x m), ok t]
-  where
-    xs'       = expandFix deps xs
-    deps y    = maybe [] (F.syms . rTypeReft . dropModel) (M.lookup y m)
-    ok        = not . isFunTy . dropModel
-
-expandFix :: (Eq a, Hashable a) => (a -> [a]) -> [a] -> [a]
-expandFix f               = S.toList . go S.empty
-  where
-    go seen []            = seen
-    go seen (x:xs)
-      | x `S.member` seen = go seen xs
-      | otherwise         = go (S.insert x seen) (f x ++ xs)
-
-tidyTemps     :: (F.Subable t) => [(F.Symbol, t)] -> (F.Subst, [(F.Symbol, t)])
-tidyTemps xts = (θ, [(txB x, txTy t) | (x, t) <- xts])
-  where
-    txB  x    = M.lookupDefault x x m
-    txTy      = F.subst θ
-    m         = M.fromList yzs
-    θ         = F.mkSubst [(y, F.EVar z) | (y, z) <- yzs]
-    yzs       = zip ys niceTemps
-    ys        = [ x | (x,_) <- xts, GM.isTmpSymbol x]
-
-niceTemps     :: [F.Symbol]
-niceTemps     = mkSymbol <$> xs ++ ys
-  where
-    mkSymbol  = F.symbol . ('?' :)
-    xs        = Misc.single <$> ['a' .. 'z']
-    ys        = ("a" ++) <$> [show n | n <- [0 ..]]
diff --git a/src/Language/Haskell/Liquid/UX/QuasiQuoter.hs b/src/Language/Haskell/Liquid/UX/QuasiQuoter.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/UX/QuasiQuoter.hs
+++ /dev/null
@@ -1,210 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DeriveFunctor      #-}
-{-# LANGUAGE TemplateHaskell    #-}
-{-# LANGUAGE TupleSections      #-}
-{-# LANGUAGE OverloadedStrings  #-}
-
-module Language.Haskell.Liquid.UX.QuasiQuoter 
--- (
---     -- * LiquidHaskell Specification QuasiQuoter
---     lq
-
---     -- * QuasiQuoter Annotations
---   , LiquidQuote(..)
---   ) 
-  where
-
-import SrcLoc (SrcSpan)
-
-import Data.Data
-import Data.List
-
-import qualified Data.Text as T
-
-import Language.Haskell.TH.Lib
-import Language.Haskell.TH.Syntax
-import Language.Haskell.TH.Quote
-
-import Text.Parsec.Pos
-
-import Language.Fixpoint.Types hiding (Error, Loc, SrcSpan)
-import qualified Language.Fixpoint.Types as F
-
-import Language.Haskell.Liquid.GHC.Misc (fSrcSpan)
-import Language.Haskell.Liquid.Parse
-import Language.Haskell.Liquid.Types
-import Language.Haskell.Liquid.UX.Tidy
-
---------------------------------------------------------------------------------
--- LiquidHaskell Specification QuasiQuoter -------------------------------------
---------------------------------------------------------------------------------
-
-lq :: QuasiQuoter
-lq = QuasiQuoter
-  { quoteExp  = bad
-  , quotePat  = bad
-  , quoteType = bad
-  , quoteDec  = lqDec
-  }
-  where
-    -- FIME(adinapoli) Should we preserve 'fail' here?
-    bad = error "`lq` quasiquoter can only be used as a top-level declaration"
-
-lqDec :: String -> Q [Dec]
-lqDec src = do
-  pos <- locSourcePos <$> location
-  case singleSpecP pos src of
-    Left err -> throwErrorInQ $ errorToUserError err
-    Right spec -> do
-      prg <- pragAnnD ModuleAnnotation $
-               conE 'LiquidQuote `appE` dataToExpQ' spec
-      case mkSpecDecs spec of
-        Left err ->
-          throwErrorInQ err
-        Right decs ->
-          return $ prg : decs
-
-throwErrorInQ :: UserError -> Q a
-throwErrorInQ err =
-  fail . showpp =<< runIO (errorsWithContext [err])
-
---------------------------------------------------------------------------------
--- Liquid Haskell to Template Haskell ------------------------------------------
---------------------------------------------------------------------------------
-
--- Spec to Dec -----------------------------------------------------------------
-
-mkSpecDecs :: BPspec -> Either UserError [Dec]
-mkSpecDecs (Asrt (name, ty)) =
-  return . SigD (symbolName name)
-    <$> simplifyBareType name (quantifyFreeRTy $ val ty)
-mkSpecDecs (LAsrt (name, ty)) =
-  return . SigD (symbolName name)
-    <$> simplifyBareType name (quantifyFreeRTy $ val ty)
-mkSpecDecs (Asrts (names, (ty, _))) =
-  (\t -> (`SigD` t) . symbolName <$> names)
-    <$> simplifyBareType (head names) (quantifyFreeRTy $ val ty)
-mkSpecDecs (Alias rta) =
-  return . (TySynD name tvs) <$> simplifyBareType lsym (rtBody (val rta))
-  where
-    lsym = F.atLoc rta n 
-    name = symbolName n 
-    n    = rtName (val rta)
-    tvs  = PlainTV . symbolName <$> rtTArgs (val rta)
-mkSpecDecs _ =
-  Right []
-
--- Symbol to TH Name -----------------------------------------------------------
-
-symbolName :: Symbolic s => s -> Name
-symbolName = mkName . symbolString . symbol
-
--- BareType to TH Type ---------------------------------------------------------
-
-simplifyBareType :: LocSymbol -> BareType -> Either UserError Type
-simplifyBareType s t = case simplifyBareType' t of
-  Simplified t' ->
-    Right t'
-  FoundExprArg l ->
-    Left $ ErrTySpec l Nothing (pprint $ val s) (pprint t) $ 
-      "Found expression argument in bad location in type"
-  FoundHole ->
-    Left $ ErrTySpec (fSrcSpan s) Nothing (pprint $ val s) (pprint t) $ 
-      "Can't write LiquidHaskell type with hole in a quasiquoter"
-
-simplifyBareType' :: BareType -> Simpl Type
-simplifyBareType' = simplifyBareType'' ([], [])
-
-simplifyBareType'' :: ([BTyVar], [BareType]) -> BareType -> Simpl Type
-
-simplifyBareType'' ([], []) (RVar v _) =
-  return $ VarT $ symbolName v
-simplifyBareType'' ([], []) (RAppTy t1 t2 _) =
-  AppT <$> simplifyBareType' t1 <*> simplifyBareType' t2
-simplifyBareType'' ([], []) (RFun _ i o _) =
-  (\x y -> ArrowT `AppT` x `AppT` y)
-    <$> simplifyBareType' i <*> simplifyBareType' o
-simplifyBareType'' ([], []) (RApp cc as _ _) =
-  let c  = btc_tc cc
-      c' | isFun   c = ArrowT
-         | isTuple c = TupleT (length as)
-         | isList  c = ListT
-         | otherwise = ConT $ symbolName c
-  in  foldl' AppT c' <$> sequenceA (filterExprArgs $ simplifyBareType' <$> as)
-
-simplifyBareType'' _ (RExprArg e) =
-  FoundExprArg $ fSrcSpan e
-simplifyBareType'' _ (RHole _) =
-  FoundHole
-
-simplifyBareType'' s(RAllP _ t) =
-  simplifyBareType'' s t
-simplifyBareType'' s (RAllE _ _ t) =
-  simplifyBareType'' s t
-simplifyBareType'' s (REx _ _ t) =
-  simplifyBareType'' s t
-simplifyBareType'' s (RRTy _ _ _ t) =
-  simplifyBareType'' s t
-
-simplifyBareType'' (tvs, cls) (RFun _ i o _)
-  | isClassType i = simplifyBareType'' (tvs, i : cls) o
-simplifyBareType'' (tvs, cls) (RAllT tv t _) =
-  simplifyBareType'' (ty_var_value tv : tvs, cls) t
-
-simplifyBareType'' (tvs, cls) t =
-  ForallT (PlainTV . symbolName <$> reverse tvs)
-    <$> mapM simplifyBareType' (reverse cls)
-    <*> simplifyBareType' t
-
-
-data Simpl a = Simplified a
-             | FoundExprArg SrcSpan
-             | FoundHole
-               deriving (Functor)
-
-instance Applicative Simpl where
-  pure = Simplified
-
-  Simplified   f <*> Simplified   x = Simplified $ f x
-  _              <*> FoundExprArg l = FoundExprArg l
-  _              <*> FoundHole      = FoundHole
-  FoundExprArg l <*> _              = FoundExprArg l
-  FoundHole      <*> _              = FoundHole
-
-instance Monad Simpl where
-  return = Simplified
-
-  Simplified   x >>= f = f x
-  FoundExprArg l >>= _ = FoundExprArg l
-  FoundHole      >>= _ = FoundHole
-
-filterExprArgs :: [Simpl a] -> [Simpl a]
-filterExprArgs = filter check
-  where
-    check (FoundExprArg _) = False
-    check _ = True
-
---------------------------------------------------------------------------------
--- QuasiQuoter Annotations -----------------------------------------------------
---------------------------------------------------------------------------------
-
-newtype LiquidQuote = LiquidQuote { liquidQuoteSpec :: BPspec }
-                      deriving (Data, Typeable)
-
---------------------------------------------------------------------------------
--- Template Haskell Utility Functions ------------------------------------------
---------------------------------------------------------------------------------
-
-locSourcePos :: Loc -> SourcePos
-locSourcePos loc =
-  newPos (loc_filename loc) (fst $ loc_start loc) (snd $ loc_start loc)
-
-dataToExpQ' :: Data a => a -> Q Exp
-dataToExpQ' = dataToExpQ (const Nothing `extQ` textToExpQ)
-
-textToExpQ :: T.Text -> Maybe ExpQ
-textToExpQ text = Just $ varE 'T.pack `appE` stringE (T.unpack text)
-
-extQ :: (Typeable a, Typeable b) => (a -> q) -> (b -> q) -> a -> q
-extQ f g a = maybe (f a) g (cast a)
-
diff --git a/src/Language/Haskell/Liquid/UX/Tidy.hs b/src/Language/Haskell/Liquid/UX/Tidy.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/UX/Tidy.hs
+++ /dev/null
@@ -1,248 +0,0 @@
-
-{-# LANGUAGE FlexibleContexts  #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE FlexibleInstances #-}
-
----------------------------------------------------------------------
--- | This module contains functions for cleaning up types before
---   they are rendered, e.g. in error messages or annoations,
---   and also some PPrint instances that rely upon tidying.
----------------------------------------------------------------------
-
-module Language.Haskell.Liquid.UX.Tidy (
-
-    -- * Tidying functions
-    tidySpecType
-  , tidySymbol
-
-    -- * Panic and Exit
-  , panicError
-
-    -- * Final result
-  , Result (..)
-
-    -- * Error to UserError
-  , errorToUserError
-
-    -- * MOVE TO TYPES
-  , cinfoError
-  ) where
-
-import           Data.Hashable
-import           Prelude                                   hiding (error)
-import qualified Data.HashMap.Strict                       as M
-import qualified Data.HashSet                              as S
-import qualified Data.List                                 as L
-import qualified Data.Text                                 as T
-import qualified Control.Exception                         as Ex
-import qualified Language.Haskell.Liquid.GHC.Misc          as GM 
--- (dropModuleNames, showPpr, stringTyVar)
-import           Language.Fixpoint.Types                   hiding (Result, SrcSpan, Error)
-import           Language.Haskell.Liquid.Types.Types
-import           Language.Haskell.Liquid.Types.RefType     (rVar, subsTyVars_meet, FreeVar)
-import           Language.Haskell.Liquid.Types.PrettyPrint
-import           Data.Generics                             (everywhere, mkT)
-import           Text.PrettyPrint.HughesPJ
-
-
-------------------------------------------------------------------------
--- | Converting Results To Answers -------------------------------------
-------------------------------------------------------------------------
-
-class Result a where
-  result :: a -> FixResult UserError
-
-instance Result UserError where
-  result e = Crash [e] ""
-
-instance Result [Error] where
-  result es = Crash (errorToUserError <$> es) ""
-
-instance Result Error where
-  result e  = result [e] --  Crash [pprint e] ""
-
-instance Result (FixResult Cinfo) where
-  result = fmap (errorToUserError . cinfoError)
-
-errorToUserError :: Error -> UserError
-errorToUserError = fmap ppSpecTypeErr
-
--- TODO: move to Types.hs
-cinfoError :: Cinfo -> Error
-cinfoError (Ci _ (Just e) _) = e
-cinfoError (Ci l _ _)        = ErrOther l (text $ "Cinfo:" ++ GM.showPpr l)
-
--------------------------------------------------------------------------
-tidySpecType :: Tidy -> SpecType -> SpecType
--------------------------------------------------------------------------
-tidySpecType k 
-  = tidyEqual 
-  . tidyValueVars
-  . tidyDSymbols
-  . tidySymbols k 
-  . tidyInternalRefas
-  . tidyLocalRefas k
-  . tidyFunBinds
-  . tidyTyVars
-
-tidyValueVars :: SpecType -> SpecType
-tidyValueVars = mapReft $ \u -> u { ur_reft = tidyVV $ ur_reft u }
-
-tidyVV :: Reft -> Reft
-tidyVV r@(Reft (va,_))
-  | isJunk va = shiftVV r v'
-  | otherwise = r
-  where
-    v'        = if v `elem` xs then symbol ("v'" :: T.Text) else v
-    v         = symbol ("v" :: T.Text)
-    xs        = syms r
-    isJunk    = isPrefixOfSym "x"
-
-tidySymbols :: Tidy -> SpecType -> SpecType
-tidySymbols k t = substa (shortSymbol k . tidySymbol) $ mapBind dropBind t
-  where
-    xs          = S.fromList (syms t)
-    dropBind x  = if x `S.member` xs then tidySymbol x else nonSymbol
-
-shortSymbol :: Tidy -> Symbol -> Symbol 
-shortSymbol Lossy = GM.dropModuleNames 
-shortSymbol _     = id 
-
-tidyLocalRefas   :: Tidy -> SpecType -> SpecType
-tidyLocalRefas k = mapReft (txReft' k)
-  where
-    txReft' Full                  = id
-    txReft' Lossy                 = txReft
-    txReft u                      = u { ur_reft = mapPredReft dropLocals $ ur_reft u }
-    dropLocals                    = pAnd . filter (not . any isTmp . syms) . conjuncts
-    isTmp x                       = any (`isPrefixOfSym` x) [anfPrefix, "ds_"]
-
-tidyEqual :: SpecType -> SpecType
-tidyEqual = mapReft txReft
-  where 
-    txReft u                      = u { ur_reft = mapPredReft dropInternals $ ur_reft u }
-    dropInternals                 = pAnd . L.nub . conjuncts
-
-tidyInternalRefas   :: SpecType -> SpecType
-tidyInternalRefas = mapReft txReft
-  where
-    txReft u                      = u { ur_reft = mapPredReft dropInternals $ ur_reft u }
-    dropInternals                 = pAnd . filter (not . any isIntern . syms) . conjuncts
-    isIntern x                    = "is$" `isPrefixOfSym` x || "$select" `isSuffixOfSym` x
-
-
-tidyDSymbols :: SpecType -> SpecType
-tidyDSymbols t = mapBind tx $ substa tx t
-  where
-    tx         = bindersTx [x | x <- syms t, isTmp x]
-    isTmp      = (tempPrefix `isPrefixOfSym`)
-
-tidyFunBinds :: SpecType -> SpecType
-tidyFunBinds t = mapBind tx $ substa tx t
-  where
-    tx         = bindersTx $ filter GM.isTmpSymbol $ funBinds t
-
-tidyTyVars :: SpecType -> SpecType
-tidyTyVars t = subsTyVarsAll αβs t
-  where
-    αβs  = zipWith (\α β -> (α, toRSort β, β)) αs βs
-    αs   = L.nub (tyVars t)
-    βs   = map (rVar . GM.stringTyVar) pool
-    pool = [[c] | c <- ['a'..'z']] ++ [ "t" ++ show i | i <- [1..]]
-
-
-bindersTx :: [Symbol] -> Symbol -> Symbol
-bindersTx ds   = \y -> M.lookupDefault y y m
-  where
-    m          = M.fromList $ zip ds $ var <$> [1..]
-    var        = symbol . ('x' :) . show
-
-
-tyVars :: RType c tv r -> [tv]
-tyVars (RAllP _ t)     = tyVars t
-tyVars (RAllT α t _)   = ty_var_value α : tyVars t
-tyVars (RImpF _ t t' _) = tyVars t ++ tyVars t'
-tyVars (RFun _ t t' _) = tyVars t ++ tyVars t'
-tyVars (RAppTy t t' _) = tyVars t ++ tyVars t'
-tyVars (RApp _ ts _ _) = concatMap tyVars ts
-tyVars (RVar α _)      = [α]
-tyVars (RAllE _ _ t)   = tyVars t
-tyVars (REx _ _ t)     = tyVars t
-tyVars (RExprArg _)    = []
-tyVars (RRTy _ _ _ t)  = tyVars t
-tyVars (RHole _)       = []
-
-subsTyVarsAll
-  :: (Eq k, Hashable k,
-      Reftable r, TyConable c, SubsTy k (RType c k ()) c,
-      SubsTy k (RType c k ()) r,
-      SubsTy k (RType c k ()) k,
-      SubsTy k (RType c k ()) (RType c k ()),
-      SubsTy k (RType c k ()) (RTVar k (RType c k ())),
-      FreeVar c k)
-   => [(k, RType c k (), RType c k r)] -> RType c k r -> RType c k r
-subsTyVarsAll ats = go
-  where
-    abm            = M.fromList [(a, b) | (a, _, RVar b _) <- ats]
-    go (RAllT a t r) = RAllT (makeRTVar $ M.lookupDefault (ty_var_value a) (ty_var_value a) abm) (go t) r
-    go t           = subsTyVars_meet ats t
-
-
-funBinds :: RType t t1 t2 -> [Symbol]
-funBinds (RAllT _ t _)    = funBinds t
-funBinds (RAllP _ t)      = funBinds t
-funBinds (RImpF b t1 t2 _) = b : funBinds t1 ++ funBinds t2
-funBinds (RFun b t1 t2 _) = b : funBinds t1 ++ funBinds t2
-funBinds (RApp _ ts _ _)  = concatMap funBinds ts
-funBinds (RAllE b t1 t2)  = b : funBinds t1 ++ funBinds t2
-funBinds (REx b t1 t2)    = b : funBinds t1 ++ funBinds t2
-funBinds (RVar _ _)       = []
-funBinds (RRTy _ _ _ t)   = funBinds t
-funBinds (RAppTy t1 t2 _) = funBinds t1 ++ funBinds t2
-funBinds (RExprArg _)     = []
-funBinds (RHole _)        = []
-
-
---------------------------------------------------------------------------------
--- | Show an Error, then crash
---------------------------------------------------------------------------------
-panicError :: {-(?callStack :: CallStack) =>-} Error -> a
---------------------------------------------------------------------------------
-panicError = Ex.throw
-
--- ^ This function is put in this module as it depends on the Exception instance,
---   which depends on the PPrint instance, which depends on tidySpecType.
-
---------------------------------------------------------------------------------
--- | Pretty Printing Error Messages --------------------------------------------
---------------------------------------------------------------------------------
-
--- | Need to put @PPrint Error@ instance here (instead of in Types),
---   as it depends on @PPrint SpecTypes@, which lives in this module.
-
-
-instance PPrint (CtxError Doc) where
-  pprintTidy k ce = ppError k (ctCtx ce) $ ctErr ce
-
-instance PPrint (CtxError SpecType) where
-  pprintTidy k ce = ppError k (ctCtx ce) $ ppSpecTypeErr <$> ctErr ce
-
-instance PPrint Error where
-  pprintTidy k = ppError k empty . fmap ppSpecTypeErr
- 
-ppSpecTypeErr :: SpecType -> Doc
-ppSpecTypeErr = ppSpecType Lossy
-
-ppSpecType :: Tidy -> SpecType -> Doc
-ppSpecType k = rtypeDoc     k
-             . tidySpecType k
-             . fmap (everywhere (mkT noCasts))
-  where
-    noCasts (ECst x _) = x
-    noCasts e          = e
-
-instance Show Error where
-  show = showpp
-
-instance Ex.Exception Error
-instance Ex.Exception [Error]
diff --git a/src/Language/Haskell/Liquid/WiredIn.hs b/src/Language/Haskell/Liquid/WiredIn.hs
deleted file mode 100644
--- a/src/Language/Haskell/Liquid/WiredIn.hs
+++ /dev/null
@@ -1,214 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Language.Haskell.Liquid.WiredIn
-       ( wiredTyCons
-       , wiredDataCons
-       , wiredSortedSyms
-
-       -- * Constants for automatic proofs
-       , dictionaryVar
-       , dictionaryTyVar
-       , dictionaryBind
-       , proofTyConName
-       , combineProofsName
-
-       -- * Built in symbols
-       , isWiredIn
-       , isWiredInName
-       , dcPrefix
-
-       -- * Deriving classes 
-       , isDerivedInstance 
-       ) where
-
-import Prelude                                hiding (error)
-import Var
-
--- import Language.Fixpoint.Misc           (mapSnd)
-import Language.Haskell.Liquid.GHC.Misc
-import qualified Language.Haskell.Liquid.GHC.API as Ghc
-import Language.Haskell.Liquid.Types.Types
-import Language.Haskell.Liquid.Types.RefType
-import Language.Haskell.Liquid.Types.Variance
-import Language.Haskell.Liquid.Types.PredType
-
--- import Language.Fixpoint.Types hiding (panic)
-import qualified Language.Fixpoint.Types as F
-import qualified Data.HashSet as S 
-
-import BasicTypes
--- import DataCon
--- import TyCon
-import TysWiredIn
-
-import Language.Haskell.Liquid.GHC.TypeRep ()
-import CoreSyn hiding (mkTyArg)
-
--- | Horrible hack to support hardwired symbols like
---      `head`, `tail`, `fst`, `snd`
---   and other LH generated symbols that
---   *do not* correspond to GHC Vars and
---   *should not* be resolved to GHC Vars.
-
-isWiredIn :: F.LocSymbol -> Bool
-isWiredIn x = isWiredInLoc x  || isWiredInName (val x) || isWiredInShape x
-
-isWiredInLoc :: F.LocSymbol -> Bool
-isWiredInLoc x  = l == l' && l == 0 && c == c' && c' == 0
-  where
-    (l , c)  = spe (loc x)
-    (l', c') = spe (locE x)
-    spe l    = (x, y) where (_, x, y) = F.sourcePosElts l
-
-isWiredInName :: F.Symbol -> Bool
-isWiredInName x = x `S.member` wiredInNames
-
-wiredInNames :: S.HashSet F.Symbol
-wiredInNames = S.fromList [ "head", "tail", "fst", "snd", "len"]
-
-isWiredInShape :: F.LocSymbol -> Bool
-isWiredInShape x = any (`F.isPrefixOfSym` (val x)) [F.anfPrefix, F.tempPrefix, dcPrefix]
-  -- where s        = val x
-        -- dcPrefix = "lqdc"
-
-dcPrefix :: F.Symbol
-dcPrefix = "lqdc"
-
-wiredSortedSyms :: [(F.Symbol, F.Sort)]
-wiredSortedSyms = [(pappSym n, pappSort n) | n <- [1..pappArity]]
-
---------------------------------------------------------------------------------
--- | LH Primitive TyCons -------------------------------------------------------
---------------------------------------------------------------------------------
-
-dictionaryVar :: Var
-dictionaryVar   = stringVar "tmp_dictionary_var" (Ghc.ForAllTy (Ghc.Bndr dictionaryTyVar Required) $ Ghc.TyVarTy dictionaryTyVar)
-
-dictionaryTyVar :: TyVar
-dictionaryTyVar = stringTyVar "da"
-
-dictionaryBind :: Bind Var
-dictionaryBind = Rec [(v, Lam a $ App (Var v) (Type $ Ghc.TyVarTy a))]
-  where
-   v = dictionaryVar
-   a = dictionaryTyVar
-
------------------------------------------------------------------------
--- | LH Primitive TyCons ----------------------------------------------
------------------------------------------------------------------------
-
-
-combineProofsName :: String
-combineProofsName = "combineProofs"
-
-proofTyConName :: F.Symbol
-proofTyConName = "Proof"
-
---------------------------------------------------------------------------------
--- | Predicate Types for WiredIns ----------------------------------------------
---------------------------------------------------------------------------------
-
-maxArity :: Arity
-maxArity = 7
-
-wiredTyCons :: [TyConP]
-wiredTyCons  = fst wiredTyDataCons
-
-wiredDataCons :: [Located DataConP]
-wiredDataCons = snd wiredTyDataCons
-
-wiredTyDataCons :: ([TyConP] , [Located DataConP])
-wiredTyDataCons = (concat tcs, dummyLoc <$> concat dcs)
-  where
-    (tcs, dcs)  = unzip $ listTyDataCons : map tupleTyDataCons [2..maxArity]
-
-listTyDataCons :: ([TyConP] , [DataConP])
-listTyDataCons   = ( [(TyConP l0 c [RTV tyv] [p] [Covariant] [Covariant] (Just fsize))]
-                   , [(DataConP l0 nilDataCon  [RTV tyv] [p] [] []    lt False wiredInName l0)
-                     ,(DataConP l0 consDataCon [RTV tyv] [p] [] cargs lt False wiredInName l0)])
-    where
-      l0         = F.dummyPos "LH.Bare.listTyDataCons"
-      c          = listTyCon
-      [tyv]      = tyConTyVarsDef c
-      t          = rVar tyv :: RSort
-      fld        = "fldList"
-      xHead      = "head"
-      xTail      = "tail"
-      p          = PV "p" (PVProp t) (F.vv Nothing) [(t, fld, F.EVar fld)]
-      px         = pdVarReft $ PV "p" (PVProp t) (F.vv Nothing) [(t, fld, F.EVar xHead)]
-      lt         = rApp c [xt] [rPropP [] $ pdVarReft p] mempty
-      xt         = rVar tyv
-      xst        = rApp c [RVar (RTV tyv) px] [rPropP [] $ pdVarReft p] mempty
-      cargs      = [(xTail, xst), (xHead, xt)]
-      fsize      = SymSizeFun (dummyLoc "len")
-
-wiredInName :: F.Symbol
-wiredInName = "WiredIn"
-
-tupleTyDataCons :: Int -> ([TyConP] , [DataConP])
-tupleTyDataCons n = ( [(TyConP   l0 c  (RTV <$> tyvs) ps tyvarinfo pdvarinfo Nothing)]
-                    , [(DataConP l0 dc (RTV <$> tyvs) ps []  cargs  lt False wiredInName l0)])
-  where
-    tyvarinfo     = replicate n     Covariant
-    pdvarinfo     = replicate (n-1) Covariant
-    l0            = F.dummyPos "LH.Bare.tupleTyDataCons"
-    c             = tupleTyCon   Boxed n
-    dc            = tupleDataCon Boxed n
-    tyvs@(tv:tvs) = tyConTyVarsDef c
-    (ta:ts)       = (rVar <$> tyvs) :: [RSort]
-    flds          = mks "fld_Tuple"
-    fld           = "fld_Tuple"
-    x1:xs         = mks ("x_Tuple" ++ show n)
-    ps            = mkps pnames (ta:ts) ((fld, F.EVar fld) : zip flds (F.EVar <$> flds))
-    ups           = uPVar <$> ps
-    pxs           = mkps pnames (ta:ts) ((fld, F.EVar x1) : zip flds (F.EVar <$> xs))
-    lt            = rApp c (rVar <$> tyvs) (rPropP [] . pdVarReft <$> ups) mempty
-    xts           = zipWith (\v p -> RVar (RTV v) (pdVarReft p)) tvs pxs
-    cargs         = reverse $ (x1, rVar tv) : zip xs xts
-    pnames        = mks_ "p"
-    mks  x        = (\i -> F.symbol (x++ show i)) <$> [1..n]
-    mks_ x        = (\i -> F.symbol (x++ show i)) <$> [2..n]
-
-
-mkps :: [F.Symbol]
-     -> [t] -> [(F.Symbol, F.Expr)] -> [PVar t]
-mkps ns (t:ts) ((f,x):fxs) = reverse $ mkps_ ns ts fxs [(t, f, x)] []
-mkps _  _      _           = panic Nothing "Bare : mkps"
-
-mkps_ :: [F.Symbol]
-      -> [t]
-      -> [(F.Symbol, F.Expr)]
-      -> [(t, F.Symbol, F.Expr)]
-      -> [PVar t]
-      -> [PVar t]
-mkps_ []     _       _          _    ps = ps
-mkps_ (n:ns) (t:ts) ((f, x):xs) args ps = mkps_ ns ts xs (a:args) (p:ps)
-  where
-    p                                   = PV n (PVProp t) (F.vv Nothing) args
-    a                                   = (t, f, x)
-mkps_ _     _       _          _    _ = panic Nothing "Bare : mkps_"
-
-
---------------------------------------------------------------------------------
-isDerivedInstance :: Ghc.ClsInst -> Bool 
---------------------------------------------------------------------------------
-isDerivedInstance i = F.notracepp ("IS-DERIVED: " ++ F.showpp classSym) 
-                    $ S.member classSym derivingClasses 
-  where 
-    classSym        = F.symbol . Ghc.is_cls $ i
-  
-derivingClasses :: S.HashSet F.Symbol 
-derivingClasses = S.fromList 
-  [ "GHC.Classes.Eq"
-  , "GHC.Classes.Ord"
-  , "GHC.Enum.Enum"
-  , "GHC.Show.Show"
-  , "GHC.Read.Read"
-  , "GHC.Base.Monad"
-  , "GHC.Base.Applicative"
-  , "GHC.Base.Functor"
-  , "Data.Foldable.Foldable"
-  , "Data.Traversable.Traversable"
-  -- , "GHC.Enum.Bounded"
-  -- , "GHC.Base.Monoid"
-  ]
diff --git a/src/Liquid/Prelude/Real_LHAssumptions.hs b/src/Liquid/Prelude/Real_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Liquid/Prelude/Real_LHAssumptions.hs
@@ -0,0 +1,7 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Liquid.Prelude.Real_LHAssumptions where
+
+{-@
+assume * :: Num a => x:a -> y:a -> {v:a | v = x * y}
+@-}
diff --git a/src/Liquid/Prelude/Totality_LHAssumptions.hs b/src/Liquid/Prelude/Totality_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Liquid/Prelude/Totality_LHAssumptions.hs
@@ -0,0 +1,20 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+{-# OPTIONS_GHC -Wno-unused-imports #-}
+module Liquid.Prelude.Totality_LHAssumptions where
+
+import Control.Exception.Base
+import GHC.Prim
+
+{-@
+measure totalityError :: a -> Bool
+
+assume patError :: {v:Addr# | totalityError "Pattern match(es) are non-exhaustive"} -> a
+
+assume recSelError :: {v:Addr# | totalityError "Use of partial record field selector"} -> a
+
+assume nonExhaustiveGuardsError :: {v:Addr# | totalityError "Guards are non-exhaustive"} -> a
+
+assume noMethodBindingError :: {v:Addr# | totalityError "Missing method(s) on instance declaration"} -> a
+
+assume recConError :: {v:Addr# | totalityError "Missing field in record construction"} -> a
+@-}
diff --git a/src/LiquidHaskell.hs b/src/LiquidHaskell.hs
--- a/src/LiquidHaskell.hs
+++ b/src/LiquidHaskell.hs
@@ -1,20 +1,4 @@
-{-# LANGUAGE CPP #-}
-
-module LiquidHaskell (
-    -- * LiquidHaskell Specification QuasiQuoter
-    lq
-#ifdef MIN_VERSION_GLASGOW_HASKELL
-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)
-    -- * LiquidHaskell as a compiler plugin
-  , plugin
-#endif
-#endif
-  ) where
-
-import Language.Haskell.Liquid.UX.QuasiQuoter
+{-# OPTIONS_GHC -Wno-missing-signatures #-}
+module LiquidHaskell (plugin, lq) where
 
-#ifdef MIN_VERSION_GLASGOW_HASKELL
-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)
-import Language.Haskell.Liquid.GHC.Plugin (plugin)
-#endif
-#endif
+import LiquidHaskellBoot(plugin, lq)
diff --git a/src/Prelude_LHAssumptions.hs b/src/Prelude_LHAssumptions.hs
new file mode 100644
--- /dev/null
+++ b/src/Prelude_LHAssumptions.hs
@@ -0,0 +1,64 @@
+{-# OPTIONS_GHC -fplugin=LiquidHaskellBoot #-}
+module Prelude_LHAssumptions where
+
+import Data.Foldable_LHAssumptions()
+import Data.List_LHAssumptions()
+import GHC.Base_LHAssumptions()
+import GHC.Classes_LHAssumptions()
+import GHC.Float_LHAssumptions()
+import GHC.Maybe_LHAssumptions()
+import GHC.Num_LHAssumptions()
+import GHC.Num.Integer_LHAssumptions()
+import GHC.Real_LHAssumptions()
+import Liquid.Prelude.Real_LHAssumptions()
+import Liquid.Prelude.Totality_LHAssumptions()
+
+{-@
+
+assume error :: {v:_ | false} -> a
+
+predicate Max V X Y = if X > Y then V = X else V = Y
+predicate Min V X Y = if X < Y then V = X else V = Y
+
+type IncrListD a D = [a]<{\x y -> (x+D) <= y}>
+
+// BOT: Do not delete EVER!
+
+qualif Bot(v:@(0))     { 0 = 1 }
+qualif Bot(v:obj)      { 0 = 1 }
+qualif Bot(v:a)        { 0 = 1 }
+qualif Bot(v:bool)     { 0 = 1 }
+qualif Bot(v:int)      { 0 = 1 }
+
+qualif CmpZ(v:a)       { v <  0 }
+qualif CmpZ(v:a)       { v <= 0 }
+qualif CmpZ(v:a)       { v >  0 }
+qualif CmpZ(v:a)       { v >= 0 }
+qualif CmpZ(v:a)       { v  = 0 }
+qualif CmpZ(v:a)       { v != 0 }
+
+qualif Cmp(v:a, x:a)   { v <  x }
+qualif Cmp(v:a, x:a)   { v <= x }
+qualif Cmp(v:a, x:a)   { v >  x }
+qualif Cmp(v:a, x:a)   { v >= x }
+qualif Cmp(v:a, x:a)   { v  = x }
+qualif Cmp(v:a, x:a)   { v != x }
+
+qualif One(v:int)      { v = 1 }
+qualif True1(v:Bool)    { v }
+qualif False1(v:Bool)   { ~ v }
+
+//  REBARE constant papp1 : func(1, [Pred @(0); @(0); bool])
+qualif Papp(v:a, p:Pred a)  { papp1 p v }
+
+//  REBARE constant papp2 : func(4, [Pred @(0) @(1); @(2); @(3); bool])
+qualif Papp2(v:a, x:b, p:Pred a b)  { papp2 p v x }
+
+//  REBARE constant papp3 : func(6, [Pred @(0) @(1) @(2); @(3); @(4); @(5); bool])
+qualif Papp3(v:a, x:b, y:c, p:Pred a b c)  { papp3 p v x y }
+
+//  qualif Papp4(v:a,x:b, y:c, z:d, p:Pred a b c d) : papp4(p, v, x, y, z)
+//  REBARE constant papp4 : func(8, [Pred @(0) @(1) @(2) @(6); @(3); @(4); @(5); @(7); bool])
+
+//  REBARE constant runFun : func(2, [Arrow @(0) @(1); @(0); @(1)])
+@-}
diff --git a/syntax/liquid.css b/syntax/liquid.css
deleted file mode 100644
--- a/syntax/liquid.css
+++ /dev/null
@@ -1,105 +0,0 @@
-.hs-linenum {
-  color: #B2B2B2; 
-  font-style: italic;
-}
-
-.hs-error {
-  background-color: #FF8585 ;
-}
-
-.hs-keyglyph {
-  color: #007020
-}
-
-.hs-keyword {
-  color: #007020;
-  // font-weight: bold;
-}
-
-.hs-comment, .hs-comment a {color: green;}
-
-.hs-str, .hs-chr {color: teal;}
-
-.hs-conid { 
-  color: #902000;   /* color: #00FFFF; color: #0E84B5; */
-  //font-weight: bold;  
-}
-
-.hs-definition { 
-  color: #06287E 
-  /* font-weight: bold; */ 
-}
-
-.hs-varid, .hs-varop, .hs-layout {
-  color: black; 
-}
-
-.hs-num {
-  color: #40A070;
-}
-
-.hs-conop {
-  color: #902000; 
-}
-
-.hs-cpp {
-  color: orange;
-}
-
-.hs-sel  {}
-
-a.annot {
-  position:relative; 
-  color:#000;
-  text-decoration:none; 
-  white-space: pre; 
-}
-
-a.annot:hover { 
-  z-index:25; 
-  background-color: #D8D8D8;
-}
-
-a.annot span.annottext{display: none}
-
-a.annot:hover span.annottext{ 
-  
-  border-radius: 5px 5px;
-  
-  -moz-border-radius: 5px; 
-  -webkit-border-radius: 5px; 
-  
-  box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); 
-  -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
-  -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); 
-
-  white-space:pre;
-  display:block;
-  position: absolute; 
-  left: 1em; top: 2em; 
-  z-index: 99;
-  margin-left: 5; 
-  background: #FFFFAA; 
-  border: 3px solid #FFAD33;
-  padding: 0.8em 1em;
-}
-
-code {
-   /* font-weight: bold; */
-   background-color: rgb(250, 250, 250); 
-   border: 1px solid rgb(200, 200, 200);
-   padding-left: 4px;
-   padding-right: 4px;
-}
-
-pre {
-  background-color: #f0f0f0;
-  border-top: 1px solid #ccc;
-  border-bottom: 1px solid #ccc;
-  padding: 5px;
-  // font-size: 120%;
-  // font-family: Bitstream Vera Sans Mono,monospace;
-  display: block;
-  overflow: visible;
-}
-
diff --git a/tests/Parser.hs b/tests/Parser.hs
deleted file mode 100644
--- a/tests/Parser.hs
+++ /dev/null
@@ -1,529 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable  #-}
-{-# LANGUAGE DoAndIfThenElse     #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE OverloadedStrings #-}
-
--- | Simple test suite to test the parser.
---
--- Run as:
---
--- $ stack test :liquidhaskell-parser
-
-module Main where
-
-import           Data.Data
-import           Data.Char (isSpace) 
-import           Data.Generics.Aliases
-import           Data.Generics.Schemes
-
-import           Language.Fixpoint.Types.Spans
-import qualified Language.Haskell.Liquid.Parse as LH
-import qualified Language.Fixpoint.Types       as F 
-
-import           Text.Parsec.Pos
-import           Test.Tasty
-import           Test.Tasty.HUnit
-import           Test.Tasty.Runners.AntXML
-
--- ---------------------------------------------------------------------
-
--- | Test suite entry point, returns exit failure if any test fails.
-main :: IO ()
--- main = do 
---   print $ parseSingleSpec "type IncrListD a D = [a]<{\\x y -> (x+D) <= y}>"
---   return ()
-main =  defaultMainWithIngredients (
-                antXMLRunner:defaultIngredients
-              ) tests
-
-tests :: TestTree
-tests =
-  testGroup "ParserTests"
-    [ testSucceeds
-    , testSpecP
-    , testReservedAliases
-    , testFails
-    , testErrorReporting
-    ]
-
--- ---------------------------------------------------------------------
-
--- Test that the top level production works, each of the sub-elements will be tested separately
-testSpecP :: TestTree
-testSpecP =
-  testGroup "specP"
-    [ testCase "assume" $
-       parseSingleSpec "assume foo :: a -> a " @?==
-          "assume foo :: lq_tmp$db##0:a -> a"
-
-    , testCase "assert" $
-       parseSingleSpec "assert myabs :: Int -> PosInt" @?==
-          "assert myabs :: lq_tmp$db##0:Int -> PosInt"
-
-    , testCase "autosize" $
-       parseSingleSpec "autosize List" @?==
-            "autosize List"
-
-    , testCase "local" $
-       parseSingleSpec "local foo :: Nat -> Nat" @?==
-            "local assert foo :: lq_tmp$db##0:Nat -> Nat"
-
-    , testCase "axiomatize" $
-       parseSingleSpec "axiomatize fibA" @?==
-            "reflect fibA"
-
-    , testCase "reflect" $
-       parseSingleSpec "reflect map" @?==
-            "reflect map"
-
-    , testCase "measure HMeas" $
-       parseSingleSpec "measure isAbs" @?==
-          "measure isAbs"
-
-    , testCase "measure Meas" $
-       parseSingleSpec "measure fv :: Expr -> (Set Bndr)" @?==
-          "measure fv :: lq_tmp$db##0:Expr -> (Set Bndr)"
-
-    , testCase "define" $
-       parseSingleSpec "define $ceq = eqN" @?==
-          "define $ceq = eqN"
-
-    , testCase "infixl" $
-       parseSingleSpec "infixl 9 +++" @?==
-            "fixity"
-
-    , testCase "infixr" $
-       parseSingleSpec "infixr 9 +++" @?==
-            "fixity"
-
-    , testCase "infix" $
-       parseSingleSpec "infix 9 +++" @?==
-            "fixity"
-
-    , testCase "inline" $
-       parseSingleSpec "inline eqelems" @?==
-            "inline eqelems"
-
-    , testCase "bound PBound" $
-       parseSingleSpec "bound Foo = true" @?==
-          "bound Foo forall [] . [] =  true"
-
-    , testCase "bound HBound" $
-       parseSingleSpec "bound step" @?==
-            "bound step"
-
-    , testCase "class measure" $
-       parseSingleSpec "class measure sz :: forall a. a -> Int" @?==
-            "class measure sz :: forall a . lq_tmp$db##0:a -> Int"
-
-    , testCase "instance measure" $
-       parseSingleSpec "instance measure sz :: MList a -> Int" @?==
-            "instance  measure sz :: lq_tmp$db##0:(MList a) -> Int"
-
-    , testCase "instance" $
-       parseSingleSpec "instance VerifiedNum Int where\n  - :: x:Int -> y:Int -> OkInt {x - y} " @?==
-          "instance (VerifiedNum Int) where\n    - :: x:Int -> y:Int -> (OkInt {x - y})"
-
-    , testCase "class" $
-       parseSingleSpec "class Sized s where\n  size :: forall a. x:s a -> {v:Nat | v = sz x}" @?==
-            "class  (Sized s) where\n    size :: forall a . x:s a -> {v : Nat | v == sz x}"
-
-    , testCase "import" $
-       parseSingleSpec "import Foo" @?==
-          "import Foo"
-
-    , testCase "data variance" $
-       parseSingleSpec "data variance IO bivariant" @?==
-          "data variance IO Bivariant"
-
-    , testCase "data" $
-       parseSingleSpec "data Bob = B {foo :: Int}" @?==
-          "data Bob  [] =\n    | B :: forall . foo : Int -> *"
-
-    , testCase "newtype" $
-       parseSingleSpec "newtype Foo = Bar {x :: Nat}" @?==
-          "newtype data Foo  [] =\n            | Bar :: forall . x : Nat -> *"
-
-    , testCase "include" $
-       parseSingleSpec "include <listSet.hquals>" @?==
-            "include <listSet.hquals>"
-
-    , testCase "invariant" $
-       parseSingleSpec "invariant {v:Tree a | 0 <= ht v}" @?==
-            "invariant {v : (Tree a) | 0 <= ht v}"
-
-    , testCase "using" $
-       parseSingleSpec "using (Tree a) as  {v:Tree a   | 0 <= height v}" @?==
-            "using (Tree a) as {v : (Tree a) | 0 <= height v}"
-
-    , testCase "type" $
-       parseSingleSpec "type PosInt = {v: Int | v >= 0}" @?==
-            "type PosInt  =  {v : Int | v >= 0}"
-
-    , testCase "predicate" $
-       parseSingleSpec "predicate Pos X  = X > 0" @?==
-            "predicate Pos X  =  X > 0"
-
-    , testCase "expression" $
-       parseSingleSpec "expression Avg Xs = ((sumD Xs) / (lenD Xs))" @?==
-          "predicate Avg Xs  =  sumD Xs / lenD Xs"
-
-    , testCase "embed" $
-       parseSingleSpec "embed Set as Set_Set" @?==
-          "embed Set as Set_Set"
-
-    , testCase "qualif" $
-       parseSingleSpec "qualif Foo(v:Int): v < 0" @?==
-          "qualif Foo defined at \"<test>\" (line 1, column 8)"
-
-    , testCase "decrease" $
-       parseSingleSpec "decrease insert 3" @?==
-          "decreasing insert [2]"
-
-    , testCase "lazyvar" $
-       parseSingleSpec "lazyvar z" @?==
-          "lazyvar z"
-
-    , testCase "lazy" $
-       parseSingleSpec "lazy eval" @?==
-          "lazy eval"
-
-    , testCase "default parser (Asrts)" $
-       parseSingleSpec " assumeIndices :: t:ByteStringNE -> s:BS.ByteString -> [OkPos t s]" @?==
-            "assumeIndices :: t:ByteStringNE -> s:BS.ByteString -> [(OkPos t s)]"
-    ]
-
--- ---------------------------------------------------------------------
-
--- Test that haskell functions having the same name as liquidhaskell keywords are parsed correctly
-testReservedAliases :: TestTree
-testReservedAliases =
-  testGroup "reserved aliases"
-    [ testCase "assume" $
-       parseSingleSpec "assume :: Int -> Bool " @?==
-            "assume :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "assert" $
-       parseSingleSpec "assert :: Int -> Bool " @?==
-            "assert :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "autosize" $
-       parseSingleSpec "autosize :: Int -> Bool " @?==
-            "autosize :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "axiomatize" $
-       parseSingleSpec "axiomatize :: Int -> Bool " @?==
-            "axiomatize :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "reflect" $
-       parseSingleSpec "reflect :: Int -> Bool " @?==
-            "reflect :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "measure" $
-       parseSingleSpec "measure :: Int -> Bool " @?==
-            "measure :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "define 1" $
-       parseSingleSpec "define :: Int -> Bool " @?==
-            "define :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "define 2" $
-       parseSingleSpec "define GHC.Types.True = (true)" @?==
-            "define GHC.Types.True = (true)"
-
-    , testCase "defined" $
-       parseSingleSpec "defined :: Int -> Bool " @?==
-            "defined :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "inline" $
-       parseSingleSpec "inline :: Int -> Bool " @?==
-            "inline :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "bound" $
-       parseSingleSpec "bound :: Int -> Bool " @?==
-            "bound :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "invariant" $
-       parseSingleSpec "invariant :: Int -> Bool " @?==
-            "invariant :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "predicate" $
-       parseSingleSpec "predicate :: Int -> Bool " @?==
-            "predicate :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "expression" $
-       parseSingleSpec "expression :: Int -> Bool " @?==
-            "expression :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "embed" $
-       parseSingleSpec "embed :: Int -> Bool " @?==
-            "embed :: lq_tmp$db##0:Int -> Bool"
-
-    , testCase "qualif" $
-       parseSingleSpec "qualif :: Int -> Bool " @?==
-            "qualif :: lq_tmp$db##0:Int -> Bool"
-    ]
-
--- ---------------------------------------------------------------------
-
-testSucceeds :: TestTree
-testSucceeds =
-  testGroup "Should succeed"
-    [ testCase "x :: Int" $
-       (parseSingleSpec "x :: Int") @?==
-          "x :: Int" 
-
-    , testCase "x :: a" $
-       (parseSingleSpec "x :: a") @?==
-          "x :: a" 
-
-    , testCase "x :: a -> a" $
-       (parseSingleSpec "x :: a -> a") @?==
-          "x :: lq_tmp$db##0:a -> a"
-
-    , testCase "x :: Int -> Int" $
-       (parseSingleSpec "x :: Int -> Int") @?==
-          "x :: lq_tmp$db##0:Int -> Int"
-
-    , testCase "k:Int -> Int" $
-       (parseSingleSpec "x :: k:Int -> Int") @?==
-          "x :: k:Int -> Int"
-
-    , testCase "type spec 1 " $
-       parseSingleSpec "type IncrListD a D = [a]<{\\x y -> (x+D) <= y}>" @?==
-          "type IncrListD a D  =  [a]<\\x##2 VV -> {y##3 : LIQUID$dummy | x##2 + D <= y##3}>"
-
-    , testCase "type spec 2 " $
-       parseSingleSpec "takeL :: Ord a => x:a -> [a] -> [{v:a|v<=x}]" @?==
-          "takeL :: (Ord a) -> x:a -> lq_tmp$db##1:[a] -> [{v : a | v <= x}]"
-
-    , testCase "type spec 3" $
-       parseSingleSpec "bar :: t 'Nothing" @?==
-          "bar :: t Nothing"
-
-    , testCase "type spec 4" $
-       parseSingleSpec "mapKeysWith :: (Ord k2) => (a -> a -> a) -> (k1->k2) -> OMap k1 a -> OMap k2 a" @?==
-          "mapKeysWith :: (Ord k2) -> lq_tmp$db##2:(lq_tmp$db##3:a -> lq_tmp$db##4:a -> a) -> lq_tmp$db##6:(lq_tmp$db##7:k1 -> k2) -> lq_tmp$db##9:(OMap k1 a) -> (OMap k2 a)"
-
-    , testCase "type spec 5 " $
-       parseSingleSpec (unlines $
-         [ "data Tree [ht] a = Nil"
-         , "            | Tree { key :: a"
-         , "                   , l   :: Tree {v:a | v < key }"
-         , "                   , r   :: Tree {v:a | key < v }"
-         , "                   }" ])
-        @?==
-    --      "data Tree [ht] [a] =\n    | Tree :: forall a . key : a ->l : (Tree {v : a | v < key}) ->r : (Tree {v : a | key < v}) -> *\n    | Nil :: forall a . -> *"
-          "data Tree [ht] [a] = \ 
-           \     | Nil :: forall a . -> * \
-           \     | Tree :: forall a . key : a ->l : (Tree {v : a | v < key}) ->r : (Tree {v : a | key < v}) -> *"    
-
-    , testCase "type spec 6" $
-       parseSingleSpec "type AVLL a X    = AVLTree {v:a | v < X}" @?==
-         "type AVLL a X  =  (AVLTree {v : a | v < X})"
-
-    , testCase "type spec 7" $
-       parseSingleSpec "type AVLR a X    = AVLTree {v:a |X< v} " @?==
-         "type AVLR a X  =  (AVLTree {v : a | X < v})"
-
-    , testCase "type spec 8 " $
-       parseSingleSpec (unlines $
-      [ "assume (++) :: forall <p :: a -> Bool, q :: a -> Bool, r :: a -> Bool>."
-      , "  {x::a<p> |- a<q> <: {v:a| x <= v}} "
-      , "  {a<p> <: a<r>} "
-      , "  {a<q> <: a<r>} "
-      , "  Ord a => OList (a<p>) -> OList (a<q>) -> OList a<r> "])
-        @?==
-          "assume (++) :: forall <p :: a -> Bool, q :: a -> Bool, r :: a -> Bool> .\n               (Ord a) =>\n               {x :: {VV : a<p> | true} |- {VV : a<q> | true} <: {v : a | x <= v}} =>\n               {|- {VV : a<p> | true} <: {VV : a<r> | true}} =>\n               {|- {VV : a<q> | true} <: {VV : a<r> | true}} =>\n               lq_tmp$db##13:(OList {VV : a<p> | true}) -> lq_tmp$db##15:(OList {VV : a<q> | true}) -> (OList {VV : a<r> | true})"
-
-    , testCase "type spec 9" $
-       parseSingleSpec (unlines $
-          [ "data AstF f <ix :: AstIndex -> Bool>"
-          , "  = Lit Int    (i :: AstIndex<ix>)"
-          , "  | Var String (i :: AstIndex<ix>)"
-          , "  | App (fn :: f) (arg :: f)"
-          , "  | Paren (ast :: f)" ])
-          @?==
-            "data AstF [f] =    \
-            \   | App :: forall f . fn : f ->arg : f -> * \
-            \   | Lit :: forall f . lq_tmp$db##2 : (Int (AstIndex <{VV : _<ix> | true}>)) -> *  \
-            \   | Paren :: forall f . ast : f -> * \
-            \   | Var :: forall f . lq_tmp$db##5 : (String (AstIndex <{VV : _<ix> | true}>)) -> *"
-
-    , testCase "type spec 10" $
-       parseSingleSpec "assume     :: b:_ -> a -> {v:a | b} " @?==
-          "assume :: b:{VV : _ | $HOLE} -> lq_tmp$db##0:a -> {v : a | b}"
-
-    , testCase "type spec 11" $
-       parseSingleSpec (unlines $
-          [ "app :: forall <p :: Int -> Bool, q :: Int -> Bool>. "
-          , "       {Int<q> <: Int<p>}"
-          , "       {x::Int<q> |- {v:Int| v = x + 1} <: Int<q>}"
-          , "       (Int<p> -> ()) -> x:Int<q> -> ()" ])
-          @?==
-            "app :: forall <p :: Int -> Bool, q :: Int -> Bool> .\n       {|- (Int <{VV : _<q> | true}>) <: (Int <{VV : _<p> | true}>)} =>\n       {x :: (Int <{VV : _<q> | true}>) |- {v : Int | v == x + 1} <: (Int <{VV : _<q> | true}>)} =>\n       lq_tmp$db##8:(lq_tmp$db##9:(Int <{VV : _<p> | true}>) -> ()) -> x:(Int <{VV : _<q> | true}>) -> ()"
-
-    , testCase "type spec 12" $
-       parseSingleSpec (unlines $
-          [ " ssum :: forall<p :: a -> Bool, q :: a -> Bool>. "
-          , "         {{v:a | v == 0} <: a<q>}"
-          , "         {x::a<p> |- {v:a | x <= v} <: a<q>}"
-          , "         xs:[{v:a<p> | 0 <= v}] -> {v:a<q> | len xs >= 0 && 0 <= v } "])
-          @?==
-            "ssum :: forall <p :: a -> Bool, q :: a -> Bool> .\n        {|- {v : a | v == 0} <: {VV : a<q> | true}} =>\n        {x :: {VV : a<p> | true} |- {v : a | x <= v} <: {VV : a<q> | true}} =>\n        xs:[{v : a<p> | 0 <= v}] -> {v : a<q> | len xs >= 0\n                                                && 0 <= v}"
-
-    , testCase "type spec 13" $
-       parseSingleSpec (unlines $
-          [ " predicate ValidChunk V XS N "
-          , " = if len XS == 0 "
-          , "     then (len V == 0) "
-          , "     else (((1 < len XS && 1 < N) => (len V  < len XS)) "
-          , "       && ((len XS <= N ) => len V == 1)) "])
-          @?==
-          "predicate ValidChunk V  XS  N  =  (len XS == 0 => len V == 0)\n                                  && (not (len XS == 0) => (1 < len XS\n                                                            && 1 < N => len V < len XS)\n                                                           && (len XS <= N => len V == 1))"
-
-
-    , testCase "type spec 14" $
-       parseSingleSpec "assume (=*=.) :: Arg a => f:(a -> b) -> g:(a -> b) -> (r:a -> {f r == g r}) -> {v:(a -> b) | f == g}" @?==
-            "assume (=*=.) :: (Arg a) -> f:(lq_tmp$db##1:a -> b) -> g:(lq_tmp$db##3:a -> b) -> lq_tmp$db##5:(r:a -> {VV : _ | f r == g r}) -> lq_tmp$db##6:a -> b"
-
-    , testCase "type spec 15" $
-       parseSingleSpec "sort :: (Ord a) => xs:[a] -> OListN a {len xs}" @?==
-           "sort :: (Ord a) -> xs:[a] -> (OListN a {len xs})"
-
-    , testCase "type spec 16" $
-       parseSingleSpec " ==. :: x:a -> y:{a| x == y} -> {v:b | v ~~ x && v ~~ y } " @?==
-            "==. :: x:a -> y:{y : a | x == y} -> {v : b | v ~~ x\n                                             && v ~~ y}"
-
-    , testCase "type spec 17" $
-       parseSingleSpec "measure snd :: (a,b) -> b" @?==
-            "measure snd :: lq_tmp$db##0:(a, b) -> b"
-
-    , testCase "type spec 18" $
-       parseSingleSpec "returnST :: xState:a \n             -> ST <{\\xs xa v -> (xa = xState)}> a s " @?==
-           "returnST :: xState:a -> (ST <\\xs##1 xa##2 VV -> {v##3 : LIQUID$dummy | xa##2 == xState}> a s)"
-
-    , testCase "type spec 19" $
-       parseSingleSpec "makeq :: l:_ -> r:{ _ | size r <= size l + 1} -> _ " @?==
-           "makeq :: l:{VV : _ | $HOLE} -> r:{r : _ | size r <= size l + 1} -> {VV : _ | $HOLE}"
-
-    , testCase "type spec 21" $
-       parseSingleSpec "newRGRef :: forall <p :: a -> Bool, r :: a -> a -> Bool >.\n   e:a<p> ->\n  e2:a<r e> ->\n  f:(x:a<p> -> y:a<r x> -> {v:a<p> | (v = y)}) ->\n IO (RGRef <p, r> a)" @?==
-            "newRGRef :: forall <p :: a -> Bool, r :: a a -> Bool> .\n            e:{VV : a<p> | true} -> e2:{VV : a<r e> | true} -> f:(x:{VV : a<p> | true} -> y:{VV : a<r x> | true} -> {v : a<p> | v == y}) -> (IO (RGRef <{VV : _<p> | true}, {VV : _<r> | true}> a))"
-
-    , testCase "type spec 21" $
-       parseSingleSpec "cycle        :: {v: [a] | len(v) > 0 } -> [a]" @?==
-            "cycle :: v:{v : [a] | len v > 0} -> [a]"
-
-    , testCase "type spec 22" $
-       parseSingleSpec "cons :: x:a -> _ -> {v:[a] | hd v = x} " @?==
-         "cons :: x:a -> lq_tmp$db##0:{VV : _ | $HOLE} -> {v : [a] | hd v == x}"
-
-    , testCase "type spec 23" $
-       parseSingleSpec "set :: a:Vector a -> i:Idx a -> a -> {v:Vector a | vlen v = vlen a}" @?==
-         "set :: a:(Vector a) -> i:(Idx a) -> lq_tmp$db##0:a -> {v : (Vector a) | vlen v == vlen a}"
-
-    , testCase "type spec 24" $
-       parseSingleSpec "assume GHC.Prim.+#  :: x:GHC.Prim.Int# -> y:GHC.Prim.Int# -> {v: GHC.Prim.Int# | v = x + y}" @?==
-         "assume GHC.Prim.+# :: x:GHC.Prim.Int# -> y:GHC.Prim.Int# -> {v : GHC.Prim.Int# | v == x + y}"
-
-    , testCase "type spec 25" $
-       parseSingleSpec " measure isEVar " @?==
-         "measure isEVar"
-
-    , testCase "type spec 26" $
-       parseSingleSpec (unlines $
-         [ "data List a where"
-         , "    Nil  :: List a "
-         , "  | Cons :: listHead:a -> listTail:List a -> List a  "])
-        @?==
-            "data List  [a] =\n    | Cons :: forall a . listHead : a ->listTail : (List a) -> (List a)\n    | Nil :: forall a . -> (List a)"
-
-    , testCase "type spec 27" $
-       parseSingleSpec (unlines $
-         [ "data List2 a b <p :: a -> Bool> where"
-         , "    Nil2  :: List2 a "
-         , "  | Cons2 :: listHead:a -> listTail:List a -> List2 a b"])
-        @?== 
-           "data List2  [a, b] = \ 
-            \  | Cons2 :: forall a b . listHead : a ->listTail : (List a) -> (List2 a b) \
-            \  | Nil2 :: forall a b . -> (List2 a)"
-
-    , testCase "type spec 28" $
-       parseSingleSpec (unlines $
-         [ "data Ev :: Peano -> Prop where"
-         , "  EZ  :: Prop (Ev Z)"
-         , "| ESS :: n:Peano -> Prop (Ev n) -> Prop (Ev (S (S n)))"
-         ])
-        @?==
-            "data Ev  [] =\n    | ESS :: forall . n : Peano ->lq_tmp$db##4 : (Prop (Ev n)) -> (Prop (Ev (S (S n))))\n    | EZ :: forall . -> (Prop (Ev Z))"
-
-    , testCase "type spec 29" $
-       parseSingleSpec (unlines $
-         [ "measure fst :: (a,b) -> a"
-         , "fst (a,b) = a"
-         ])
-        @?==
-            "measure fst :: lq_tmp$db##0:(a, b) -> a\n        fst ((,)a b) = a"
-    ]
-
--- ---------------------------------------------------------------------
-
-testFails :: TestTree
-testFails =
-  testGroup "Does fail"
-    [ testCase "Maybe k:Int -> Int" $
-          parseSingleSpec "x :: Maybe k:Int -> Int" @?==
-            "Cannot parse specification:\n    unexpected ':'\n    expecting monoPredicateP, bareTyArgP, mmonoPredicateP, white space, \"->\", \"~>\", \"=>\", \"/\" or end of input"
-    ]
-
-
--- ---------------------------------------------------------------------
-
-testErrorReporting :: TestTree
-testErrorReporting =
-  testGroup "Error reporting"
-    [ testCase "assume mallocForeignPtrBytes :: n:Nat -> IO (ForeignPtrN a n " $
-          parseSingleSpec "assume mallocForeignPtrBytes :: n:Nat -> IO (ForeignPtrN a n " @?==
-            "Cannot parse specification:\n    unexpected end of input\n    expecting bareTyArgP"
-
-    , testCase "Missing |" $
-          parseSingleSpec "ff :: {v:Nat  v >= 0 }" @?==
-          -- parseSingleSpec "ff :: {v :  }" @?==
-            "Cannot parse specification:\n    unexpected \":\"\n    expecting operator, white space or \"}\""
-    ]
-
--- ---------------------------------------------------------------------
-
--- | Parse a single type signature containing LH refinements. To be
--- used in the REPL.
-parseSingleSpec :: String -> String
-parseSingleSpec src = deSpace $ 
-  case LH.singleSpecP (initialPos "<test>") src of
-    Left err  -> show err
-    Right res -> F.showpp res -- show (dummyLocs res)
-
-gadtSpec :: String
-gadtSpec = unlines
-  [ "data Ev where"
-  , "   EZ  :: {v:Ev | prop v = Ev Z}"
-  , " | ESS :: n:Peano -> {v:Ev | prop v = Ev n} -> {v:Ev | prop v = Ev (S (S n)) }"
-  ]
-
-deSpace :: String -> String 
-deSpace = filter (not . isSpace)
-
-(@?==) :: String -> String -> Assertion 
-s1 @?== s2 = (deSpace s1) @?= (deSpace s2)
-
-------------------------------------------------------------------------
-
-dummyLocs :: (Data a) => a -> a
-dummyLocs = everywhere (mkT posToDummy)
-  where
-    posToDummy :: SourcePos -> SourcePos
-    posToDummy _ = dummyPos "Fixpoint.Types.dummyLoc"
-
--- ---------------------------------------------------------------------
diff --git a/tests/Synthesis.hs b/tests/Synthesis.hs
deleted file mode 100644
--- a/tests/Synthesis.hs
+++ /dev/null
@@ -1,149 +0,0 @@
-{-# LANGUAGE TupleSections #-}
-
-module Main where
-
-import           Test.Tasty 
-import           Test.Tasty.HUnit
-
-import qualified Data.Text    as T
-import qualified Data.Text.IO as T
-import           System.FilePath
-import           System.Process
-import           System.IO
-import           System.Directory
-import           System.Exit
-import           System.IO.Unsafe
-import           Data.Tuple.Extra
-
--------------------------------------------------------------
--- | Contains the input files
--------------------------------------------------------------
-synthesisTestsDir :: FilePath
-synthesisTestsDir = "tests/synthesis/tests"
--------------------------------------------------------------
-
--------------------------------------------------------------
--- | Contains the results of the synthesis on the inputs
--------------------------------------------------------------
-logDir :: FilePath
-logDir = "tests/synthesis/logs"
--------------------------------------------------------------
-
--------------------------------------------------------------
--- | Contains the outputs that we need to check logs against
--------------------------------------------------------------
-outputsDir :: FilePath
-outputsDir = "tests/synthesis/static"
--------------------------------------------------------------
-
-main :: IO ()
-main = do 
-    print " Synthesis test suite "
-    result <- fromInput
-    defaultMain (tests result)
-
-fromInput :: IO [(FilePath, T.Text, [[T.Text]])]
-fromInput = do
-    res <- createLogs -- Get the filename from here
-    logs <- handleLogs (map thd3 res)
-    let filenames = map fst3 res
-        programNames = map (head . T.words . head . head) logs 
-        result = zip3 filenames programNames logs
-    return result
-
-handleLogs :: [T.Text] -> IO [[[T.Text]]]
-handleLogs texts 
-    = return (map handleLog texts)
-
-keyword :: T.Text
-keyword = T.pack " Hole Fills:"
-
-startsWith :: T.Text -> T.Text -> Bool
-startsWith kw line = T.isPrefixOf kw line
-
--- | @walkFile@ returns empty means that there is no solution produced 
---              for given specification (needs to be checked)
-
-walkFile :: T.Text -> [T.Text]
-walkFile text = dropWhile (not . startsWith keyword) ls
-    where ls = T.lines text 
-
--- | Lines from the solution in the log file (without trailing characters)
-handleLog :: T.Text -> [[T.Text]]
-handleLog text =
-    let toBeParsed = walkFile text
-        sols = T.splitOn (T.pack delim) (T.unlines (tail toBeParsed))
-        noTrailing = map (filter (not . T.null)) (map (map T.strip) (map T.lines sols))
-    in  noTrailing
-
-
-delim :: String
-delim = "*********************************************"
-
-
-createLogs :: IO [(FilePath, ExitCode, T.Text)]
-createLogs = do 
-    files <- listDirectory synthesisTestsDir
-    let testFiles = filter (\x -> takeExtension x == ".hs") files
-    res <- mapM runLiquid testFiles
-    let (ecs, ts) = unzip res
-        fs = map dropExtension testFiles
-    return (zip3 fs ecs ts)
-
-runLiquid :: FilePath -> IO (ExitCode, T.Text)
-runLiquid tgt = do
-    let bin    = "stack exec -- liquid " 
-        inFile = synthesisTestsDir </> tgt
-        log    = logDir </> (dropExtension tgt <.> ".log")
-    withFile log WriteMode $ \h -> do
-        (_, _, _, ph) <- createProcess $ (shell (bin ++ inFile)) { std_out = UseHandle h, std_err = UseHandle h }
-        exitCode      <- waitForProcess ph
-        (exitCode, ) <$> T.readFile log
-
-
-getSolutions :: FilePath -> IO T.Text
-getSolutions tgt = do
-    let file = outputsDir </> tgt
-    T.readFile file
-    
-mkTgt :: FilePath -> FilePath
-mkTgt t = addExtension t ".hs"
-
-
-
--- | Get solution from outputs line by line in order to compare
-lineFile :: T.Text -> T.Text -> [T.Text]
-lineFile progName file = 
-    dropWhile (\x -> not (startsWith (progName `T.append` (T.pack " ")) x) || 
-                     startsWith (progName `T.append` (T.pack " ::")) x) (T.lines file)
-
-clean :: [T.Text] -> [T.Text]
-clean ls = filter (not . T.null) (map T.strip ls)
-
-processAnswers :: [(FilePath, T.Text, [[T.Text]])] -> [(FilePath, [[T.Text]], [T.Text])]
-processAnswers = map processAnswer 
-
-processAnswer :: (FilePath, T.Text, [[T.Text]]) -> (FilePath, [[T.Text]], [T.Text])
-processAnswer (fp, prog, ts) = 
-    let file = unsafePerformIO (getSolutions (mkTgt fp))
-        fileLines = lineFile prog file
-        cleanLines = clean fileLines
-    in  (fp, ts, cleanLines) 
-
-compareLines :: [T.Text] -> [T.Text] -> Bool
-compareLines [] [] = True
-compareLines (t:ts) (l:ls) = t == l && compareLines ts ls
-compareLines _ _ = False
-
-buildTestCase :: (FilePath, [[T.Text]], [T.Text]) -> TestTree
-buildTestCase (fp, ls, ts) 
-    = testCase 
-        fp 
-        ((foldr (\l b -> compareLines ts l || b) False ls) @?= True)
-
-tests :: [(FilePath, T.Text, [[T.Text]])] -> TestTree
-tests inputs = 
-    let answers = processAnswers inputs
-        units   = map buildTestCase answers
-    in  testGroup " Tests for synthesis " units
-
diff --git a/tests/errors/AmbiguousInline.hs b/tests/errors/AmbiguousInline.hs
deleted file mode 100644
--- a/tests/errors/AmbiguousInline.hs
+++ /dev/null
@@ -1,220 +0,0 @@
-{-@ LIQUID "--scrape-used-imports" @-}
-{-@ LIQUID "--short-names" @-}
-
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE DeriveAnyClass #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module MatchIdxs where
-
-import qualified Data.ByteString as BS
--- RJ import qualified Data.ByteString.Search as BS
-import Data.Char
--- RJ import Data.List.Split(chunksOf)
-
-import Data.Monoid
-import Data.Proxy
-import Debug.Trace
-import GHC.TypeLits
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
--- FIX import Prelude hiding (min, max)
-import Prelude hiding (max)
-
-junk = BS.head
-
-
-traceMsg msg x = trace (msg ++ show x) x
-
-{-@ chunksBS :: Int -> b:BS.ByteString -> [BS.ByteString] / [(bLength b)] @-}
-chunksBS n' xs | BS.null xs = []
-               | otherwise = x : chunksBS n xs'
-    where (x,xs') = BS.splitAt  (liquidAssert (n > 0) n) xs
-          n       = max 1 n'
-
-bsToString :: BS.ByteString -> String
-bsToString = map (chr . fromIntegral) . BS.unpack
-
-stringToBS :: String -> BS.ByteString
-stringToBS = BS.pack . map (fromIntegral . ord)
-
--- | get the (proxied and existentially boxed) type level Symbol for a bytestring
-someSymbolValBS :: BS.ByteString -> SomeSymbol
-someSymbolValBS = someSymbolVal . bsToString
-
--- | get the bytestring corresponding to a type level Symbol
-mkTarg :: forall t . KnownSymbol t => Proxy t -> BS.ByteString
-mkTarg = stringToBS . symbolVal
-
-
--- | Naive specification of string matching (from Bird)
-{-@ indicesSpec :: t:ByteStringNE -> s:BS.ByteString -> [OkPos t s] @-}
--- indicesSpec targ = map ((BS.length targ -) . BS.length) . filter (targ `BS.isSuffixOf`) . BS.inits
-indicesSpec targ s = [ BS.length s' - BS.length targ | s' <- BS.inits s
-                                                     , targ `BS.isSuffixOf` s' ]
-
-indicesSpec :: BS.ByteString -> BS.ByteString -> [Int]
-
-
-
--- | Datatype to name string matching algorithms; will use it's lifted
--- version put choice in type.
-data Alg = BM  -- ^ Boyer-Moore from stringsearch package
-         | Spec  -- ^ Naive spec
-
-{-@ indices :: Alg -> t:ByteStringNE -> s:BS.ByteString -> [OkPos t s] @-}
-indices BM   = assumeIndices -- RJ BS.indices
-indices Spec = indicesSpec
-
-
--- | Monoid
---
--- 'MatchIdxs alg targ' denotes the result of running string matching
--- algorithm 'alg' search for target 'targ' in some input. In addition
--- to the match indices, information needed to combine this result
--- with similar results on input to the left and right are also
--- included.
---
--- We'd like to prove that the invariants in the comments hold (|x|
--- denotes the length of x).
-data MatchIdxs
-    = Small { targ :: BS.ByteString
-            , bs   :: BS.ByteString
-            }
-    | MatchIdxs { targ    :: BS.ByteString
-                , input   :: Int
-                , left    :: BS.ByteString
-                , matches :: [Int]
-                , right   :: BS.ByteString
-                }
-  deriving (Eq, Show)
-
-{-@ data MatchIdxs
-      = Small { targ    :: ByteStringNE
-              , bs      :: {v:BS.ByteString | bLength v < bLength targ}
-              }
-
-      | MatchIdxs
-              { targ    :: ByteStringNE
-              , input   :: {v : Int | v >= bLength targ}
-              , left    :: {v : BS.ByteString | bLength v == bLength targ - 1}
-              , matches :: [{v:Int | v <= input - bLength targ}]
-              , right   :: {v : BS.ByteString | bLength v == bLength targ - 1}
-              }
-  @-}
-
-
-matchIdxsIs :: MatchIdxs -> [Int]
-matchIdxsIs (Small _ _) = []
-matchIdxsIs (MatchIdxs _ _ _ is _) = is
-
--- | create a 'MatchIdxs'
-{-@ myIndices :: Alg -> t:ByteStringNE -> BS.ByteString -> MatchIdxsT t @-}
-myIndices alg t bs
-  | BS.length bs > fringeLen = let right1 = BS.drop (BS.length bs - fringeLen) bs in
-                                MatchIdxs t (BS.length bs) left is right1
-  | otherwise = Small t bs
-  where
-    is        = indices alg t bs
-    fringeLen = BS.length t - 1
-    left      = BS.take fringeLen bs
-    -- right1    = BS.drop (BS.length bs - fringeLen) bs
-
--- ISSUE: get contextual output with --diff
--- ISSUE: why does lazyvar right1 not work? it drops the output type on right1!
-
-{- lazyvar right1 -}
-
-{-@ type OkPos Targ Str = {v:Nat | v <= bLength Str - bLength Targ} @-}
-{-@ type ByteStringNE   = {v:BS.ByteString | bLength v > 0 }   @-}
-{-@ type ByteStringN N  = {v:BS.ByteString | bLength v == N}   @-}
-{-@ type MatchIdxsT T   = {v:MatchIdxs | targ v == T}          @-}
-
-{-@ assume BS.isSuffixOf :: targ:_ -> s:_ -> {v:_ | v => (bLength targ <= bLength s) } @-}
-{-@ assume BS.length  :: b:BS.ByteString -> {v:Nat | v == bLength b}  @-}
-{-@ assume BS.empty   :: {v:BS.ByteString | bLength v == 0}    @-}
-{-@ assume BS.take    :: n:Nat -> b:BS.ByteString -> ByteStringN {min n (bLength b)} @-}
-{-@ assume BS.drop    :: n:Nat -> b:{BS.ByteString | n <= bLength b} -> ByteStringN {bLength b - n} @-}
-{-@ assume BS.inits   :: b:BS.ByteString -> [{v:BS.ByteString | bLength v <= bLength b}] @-}
-{-@ assume BS.append  :: b1:BS.ByteString -> b2:BS.ByteString -> ByteStringN {bLength b1 + bLength b2} @-}
-{-@ assume BS.null    :: b:BS.ByteString -> {v:Bool | v <=> (bLength b == 0)} @-}
-{-@ assume BS.splitAt :: n:Nat -> b:BS.ByteString -> (ByteStringN {min n (bLength b)}, ByteStringN {max 0 (bLength b - n)}) @-}
-{-@ assume BS.head    :: BS.ByteString -> _ @-}
-
-{-@ measure target @-}
-target :: MatchIdxs -> BS.ByteString
-target (Small t _)           = t
-target (MatchIdxs t _ _ _ _) = t
-
-{-@ inline min @-}
-min :: Int -> Int -> Int
-min x y = if x <= y then x else y
-
-{-@ inline max @-}
-max :: Int -> Int -> Int
-max x y = if x <= y then y else x
-
--- RJ instance (KnownSymbol t, StringMatch alg) => Monoid (MatchIdxs alg t) where
-{-@ mmempty :: t:ByteStringNE -> MatchIdxsT t @-}
-mmempty t = Small t BS.empty
-
-{-@ mmconcat :: (Foldable t) => Alg -> tg:ByteStringNE -> t (MatchIdxsT tg) -> (MatchIdxsT tg) @-}
-mmconcat alg t = foldr (mmappend alg t) (mmempty t)
-
-{-@ qualif BB(v:Int, n:Int, d:Int, b:BS.ByteString): v <= (n + d) - bLength b @-}
-
-{-@ mmappend :: Alg -> t:ByteStringNE -> MatchIdxsT t -> MatchIdxsT t -> MatchIdxsT t @-}
-mmappend alg t mx my =
-  let fringeLen = BS.length t - 1
-      idxFun    = indices alg t
-  in
-  case (mx, my) of
-    (Small tx x, Small _ y) -> myIndices alg tx (x <> y)
-    (Small tx x, MatchIdxs _ yLen ly iy rt) -> MatchIdxs tx xyLen lt is rt
-       where
-         xyLen = xLen + yLen
-         xLen  = BS.length x
-         xly   = BS.append x ly
-         lt    = BS.take fringeLen xly
-         is    = idxFun xly ++ map (+ xLen) iy
-    (MatchIdxs tx xLen lt ix rx, Small ty y) -> MatchIdxs tx xyLen lt (ix ++ is) rt
-       where
-         xyLen = xLen + yLen
-         yLen  = BS.length y
-         is    = map (+ (xLen - fringeLen)) (idxFun rxy)
-         rt    = BS.drop (BS.length rxy - fringeLen) rxy
-         rxy   = BS.append rx y
-    (MatchIdxs tx xLen lt ix rx, MatchIdxs ty yLen ly iy rt) -> MatchIdxs tx xyLen lt (ix ++ is) rt
-       where
-         xyLen = xLen + yLen
-         is    = ixy ++ map (+ xLen) iy
-         ixy   = map (+ (xLen - fringeLen)) $ idxFun (BS.append rx ly)
-
--- | Example applications
---
--- The bufLen and chunkSz arguments are there to exercise the monoid,
--- though they also foreshadow a parallel implementation.
-{-@ indicesBS' :: Alg -> Int -> Int -> ByteStringNE -> BS.ByteString -> [Int] @-}
-indicesBS' alg bufLen chunkSz t bs =
-  let si = mmconcat alg t . map (mmconcat alg t) . chunksOf bufLen . map (myIndices alg t) $ chunksBS chunkSz bs in
-  matchIdxsIs si
-
-{-@ indicesBS, indicesNaive :: Int -> Int -> ByteStringNE -> BS.ByteString -> [Int] @-}
-indicesBS    = indicesBS' BM   -- RJ (Proxy :: Proxy BM)
-indicesNaive = indicesBS' Spec -- RJ (Proxy :: Proxy Spec)
-
-{-@ isInfixOfBS :: Int -> Int -> ByteStringNE -> BS.ByteString -> Bool @-}
-isInfixOfBS bufLen chunkSz t = not . null . indicesBS bufLen chunkSz t
-
-------------------------------------------------------------------------------------------
-{-@ invariant {v:BS.ByteString | 0 <= bLength v } @-}
-{-@ measure bLength :: BS.ByteString -> Int @-}
-{-@ type LNat N = {v:Nat | v < N} @-}
-
-chunksOf :: Int -> [a] -> [[a]]
-chunksOf = undefined
-
-{-@ assumeIndices :: t:ByteStringNE -> s:BS.ByteString -> [OkPos t s] @-}
-assumeIndices :: BS.ByteString -> BS.ByteString -> [Int]
-assumeIndices = undefined
diff --git a/tests/errors/AmbiguousReflect.hs b/tests/errors/AmbiguousReflect.hs
deleted file mode 100644
--- a/tests/errors/AmbiguousReflect.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--reflection"  @-}
-
-module StringIndexing where
-
--- ISSUE: Uncomment the below to make this test pass
---
---    import Prelude hiding (mappend)
--- 
--- LH should give an error message indicating the above.
-
-data D = D Int Int 
-
-{-@ reflect mappend @-}
-mappend :: D -> D -> D 
-
-{-@ mappend :: x:D -> D -> {v:D | v == x} @-}
-mappend x@(D i1 i2) (D i3 i4) = x
-
diff --git a/tests/errors/BadAliasApp.hs b/tests/errors/BadAliasApp.hs
deleted file mode 100644
--- a/tests/errors/BadAliasApp.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module BadExprArg where
-
-{-@ type ListN a N = {v:[a] | len v = N} @-}
-
-{-@ foo :: ListN 0 0 @-}
-foo :: [a]
-foo = undefined
diff --git a/tests/errors/BadAnnotation.hs b/tests/errors/BadAnnotation.hs
deleted file mode 100644
--- a/tests/errors/BadAnnotation.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Zoo where
-
-{-@ incr :: x:Int -> {v:Int | x < v } -}
-incr :: Int -> Int
-incr x = x - 1
diff --git a/tests/errors/BadAnnotation1.hs b/tests/errors/BadAnnotation1.hs
deleted file mode 100644
--- a/tests/errors/BadAnnotation1.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Zoo where
-
-{-@ incr :: x:Int 
-         -> {v:Int | x < v } 
-  -}
-incr :: Int -> Int
-incr x = x - 1
diff --git a/tests/errors/BadData1.hs b/tests/errors/BadData1.hs
deleted file mode 100644
--- a/tests/errors/BadData1.hs
+++ /dev/null
@@ -1,35 +0,0 @@
-{-@ LIQUID "--no-adt"         @-}
-{-@ LIQUID "--exact-data-con" @-}
-
-{-# LANGUAGE ExistentialQuantification, KindSignatures, TypeFamilies, GADTs #-}
-
-class PersistEntity record where
-    data EntityField record :: * -> *
-
-instance PersistEntity Blob where
-    {-@ data EntityField record typ where
-           BlobXVal :: EntityField Blob {v:Int | v >= 0}
-         | BlobYVal :: EntityField Blob Int
-    @-}
-    data EntityField Blob typ where
-        BlobXVal :: EntityField Blob Int
-        BlobYVal :: EntityField Blob Int
-
-
-{-@ data Blob  = B { xVal :: {v:Int | v >= 0}, yVal :: Int } @-}
-data Blob = B { xVal :: Int, yVal :: Int }
-
-{-@ blobXVal :: EntityField Blob {v:Int | v >= 0} @-}
-blobXVal :: EntityField Blob Int
-blobXVal = BlobXVal
-
--- OK
--- testUpdateQuery :: () -> Update Blob Int
--- testUpdateQuery () = createUpdate blobXVal 3
-
--- BAD
--- testUpdateQueryFail :: () -> Update Blob Int
--- testUpdateQueryFail () = createUpdate blobXVal (-1)
-
-main :: IO ()
-main = pure ()
diff --git a/tests/errors/BadData2.hs b/tests/errors/BadData2.hs
deleted file mode 100644
--- a/tests/errors/BadData2.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-{-@ LIQUID "--exact-data-cons" @-}
-
-module Boo where
-
-{-@ data Hog where  
-      Cuthb :: Nat -> T 
-  @-}
-
-data Hog = H Int 
-
-data T = Cuthb { fldX :: Int }
-
-zoink = Cuthb (-1)
diff --git a/tests/errors/BadDataCon2.hs b/tests/errors/BadDataCon2.hs
deleted file mode 100644
--- a/tests/errors/BadDataCon2.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Boo where
-
-{-@ data T = Cuthb { fldX :: Int, fldY :: Int } @-}
-
-data T = Cuthb { fldX :: Int }
diff --git a/tests/errors/BadDataConType.hs b/tests/errors/BadDataConType.hs
deleted file mode 100644
--- a/tests/errors/BadDataConType.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Boo where
-
-{-@ data T = C { fldX :: Int, fldY :: Bool } @-}
-
-data T = C { fldX :: Int, fldY :: Int }
diff --git a/tests/errors/BadDataConType1.hs b/tests/errors/BadDataConType1.hs
deleted file mode 100644
--- a/tests/errors/BadDataConType1.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Boo where
-
-{-@ data T = C { fldX :: Int, fldY :: String } @-}
-
-data T = C { fldX :: Int, fldY :: Int }
diff --git a/tests/errors/BadDataConType2.hs b/tests/errors/BadDataConType2.hs
deleted file mode 100644
--- a/tests/errors/BadDataConType2.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Boo where
-
-{-@ data T = C { fldX :: Int } @-}
-
-data T = C { fldX :: Int, fldY :: Int }
diff --git a/tests/errors/BadDataDeclTyVars.hs b/tests/errors/BadDataDeclTyVars.hs
deleted file mode 100644
--- a/tests/errors/BadDataDeclTyVars.hs
+++ /dev/null
@@ -1,24 +0,0 @@
--- | With ADTs, the below fails with a nasty 'elaborate' error, when
---   the actual problem is a malformed refined data-declaration where
---   the type variable 'a' has been left out.
---
---   We should flag a proper malformed data-declaration error instead.
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-} 
-
-module MonoidList where
-
-{-@ data L = Emp | Cons {x::a, xs:: (L a)} @-}
---       ^ whoops, missing a tyvar!
-
-data L a = Emp | Cons a (L a)
-
-{-@ reflect sz @-}
-sz :: L a -> Int
-sz Emp         = 0
-sz (Cons _ xs) = 1 + sz xs
-
-{-@ test :: {(sz (Cons 1 Emp)) = 1} @-}
-test :: ()
-test = ()
diff --git a/tests/errors/BadGADT.hs b/tests/errors/BadGADT.hs
deleted file mode 100644
--- a/tests/errors/BadGADT.hs
+++ /dev/null
@@ -1,39 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-{-@ LIQUID "--no-termination" @-}
-
-{-@ data List a where
-       Nil  :: List a
-     | Cons :: listHead:a -> listTail:List a -> List a
-@-}
-
-{-@ data List1 a b where
-       Nil1  :: List1 a b
-     | Cons1 :: listHead:a -> listTail:List a -> List1 a b
-@-}
-
-{-@ data List2 a b <p :: a -> Bool> where
-       Nil2  :: List2 a
-     | Cons2 :: listHead:a -> listTail:List a -> List2 a b
-@-}
-
-
-data List a where
-  Nil  :: List a
-  Cons :: a -> List a -> List a
-
-
-data List1 a b where
-  Nil1  :: List1 a b
-  Cons1 :: a -> List a -> List1 a b
-
-data List2 a b where
-  Nil2  :: List2 a b
-  Cons2 :: a -> List a -> List2 a b
-
-test :: List a -> Int
-test Nil = 1
-test (Cons x xs) = 1 + test xs
-
-main :: IO ()
-main = pure ()
diff --git a/tests/errors/BadPragma0.hs b/tests/errors/BadPragma0.hs
deleted file mode 100644
--- a/tests/errors/BadPragma0.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-{-@ LIQUID "--idirs=.." @-}
-
-module Bad where 
-
-i :: Int
-i = 1
-
diff --git a/tests/errors/BadPragma1.hs b/tests/errors/BadPragma1.hs
deleted file mode 100644
--- a/tests/errors/BadPragma1.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-{-@ LIQUID "--c-files=./wow.c" @-}
-
-module Bad where 
-
-i :: Int
-i = 1
-
diff --git a/tests/errors/BadPragma2.hs b/tests/errors/BadPragma2.hs
deleted file mode 100644
--- a/tests/errors/BadPragma2.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-{-@ LIQUID "--ghc-option=-O0" @-}
-
-module Bad where 
-
-i :: Int
-i = 1
-
diff --git a/tests/errors/BadPredApp.hs b/tests/errors/BadPredApp.hs
deleted file mode 100644
--- a/tests/errors/BadPredApp.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Boo where
-
-{-@ data X <q :: Int -> Int -> Bool> = X (x0 :: Int) (x1 :: Int<q x0>) @-}  
-data X = X Int Int  
-
-{-@ data T <p :: Int -> Int -> Int -> Int -> Bool> = C { x :: Int, y :: Int, z :: X<p x y> } @-}
-data T = C { x :: Int, y :: Int, z :: X }  
diff --git a/tests/errors/BadQualifier.hs b/tests/errors/BadQualifier.hs
deleted file mode 100644
--- a/tests/errors/BadQualifier.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module RG where
-data RGRef a
-{-@ measure tv :: RGRef a -> a @-}
-{-@ qualif TERMINALVALUE(r:RGRef a): (tv r) @-}
-
-
-data A
-data B
-
-{-@ qualif Foo(x:A, y:B): (x == y) @-}
diff --git a/tests/errors/BadSig0.hs b/tests/errors/BadSig0.hs
deleted file mode 100644
--- a/tests/errors/BadSig0.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Zoo where
-
-{-@ measure prop :: a -> b @-}
-{-@ type Prop E = {v:_ | pro v = E} @-}
-
-foo :: Int -> Int 
-{-@ foo :: n:Int -> Prop 10 @-}
-foo x = x + 1
diff --git a/tests/errors/BadSig1.hs b/tests/errors/BadSig1.hs
deleted file mode 100644
--- a/tests/errors/BadSig1.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-{-@ LIQUID "--exact-data-con" @-}
-
-module Ev where
-
-data Peano where
-  Z :: Peano
-  S :: Peano -> Peano
-
--- AUTO
-data EvProp where
-  Ev :: Peano -> EvProp
-
-data Ev where
-  EZ  :: Ev
-  ESS :: Peano -> Ev -> Ev
-
--- AUTO/PRELUDE
-{-@ measure prop :: a -> b @-}
-
-{-@ type Prop E = {v:_ | pro v = E} @-}
-
-      -- {v:Ev | prop v = Ev Z}
-{-@ data Ev where
-        EZ  :: Prop (Ev Z)
-      | ESS :: evn:Peano -> {evpf:Ev | prop evpf = Ev evn} -> {zing : Ev | prop zing = Ev (S (S evn)) }
-  @-}
-
-{-@ test :: n:Peano -> {v:Ev | prop v = Ev (S (S n))} -> {v:Ev | prop v = Ev n} @-}
-test :: Peano -> Ev -> Ev
-test n (ESS m q) = q
-
--- G := p : {prop p  = Even (S (S n)) /\ prop p = Even (S (S m))}
---        ; q : {prop q = Even m}
---        ==> n = m
---        ==> prop q = Even n
diff --git a/tests/errors/BadSyn1.hs b/tests/errors/BadSyn1.hs
deleted file mode 100644
--- a/tests/errors/BadSyn1.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Zoo where
-
-type Foo = Int
-
-{-@ type Fooz = {v:Int | 1 < v} @-}
-
-{-@ bob :: Fooz 1000 @-}
-bob = 10 :: Int
-
diff --git a/tests/errors/BadSyn2.hs b/tests/errors/BadSyn2.hs
deleted file mode 100644
--- a/tests/errors/BadSyn2.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Zoo where
-
-type Foo = Int
-
-{-@ bob :: Foo 1000 @-}
-bob = 10 :: Int
-
diff --git a/tests/errors/BadSyn3.hs b/tests/errors/BadSyn3.hs
deleted file mode 100644
--- a/tests/errors/BadSyn3.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Zoo where
-
-type Foo = Int
-
-{-@ bob :: Foo String @-}
-bob = 10 :: Int
-
diff --git a/tests/errors/BadSyn4.hs b/tests/errors/BadSyn4.hs
deleted file mode 100644
--- a/tests/errors/BadSyn4.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Foo where
-
-type List a = [a]
-type Point  = List Double
-
-{-@ foo :: n:Nat -> Point n @-}
-foo :: Int -> List Double
-foo _ = []
diff --git a/tests/errors/CyclicExprAlias0.hs b/tests/errors/CyclicExprAlias0.hs
deleted file mode 100644
--- a/tests/errors/CyclicExprAlias0.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module Test0 () where
-
-{-@ expression CyclicA1 Q = CyclicA1 Q @-}
-
diff --git a/tests/errors/CyclicExprAlias1.hs b/tests/errors/CyclicExprAlias1.hs
deleted file mode 100644
--- a/tests/errors/CyclicExprAlias1.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Test2 () where
-
-{-@ expression CyclicB1 Q = CyclicB2 Q @-}
-{-@ expression CyclicB2 Q = CyclicB1 Q @-}
-
diff --git a/tests/errors/CyclicExprAlias2.hs b/tests/errors/CyclicExprAlias2.hs
deleted file mode 100644
--- a/tests/errors/CyclicExprAlias2.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Test3 () where
-
-{-@ expression CyclicC1 Q = (CyclicC2 Q) && (CyclicC3 Q) @-}
-{-@ expression CyclicC2 Q = CyclicC1 Q @-}
-{-@ expression CyclicC3 Q = CyclicC1 Q @-}
-
-
diff --git a/tests/errors/CyclicExprAlias3.hs b/tests/errors/CyclicExprAlias3.hs
deleted file mode 100644
--- a/tests/errors/CyclicExprAlias3.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test3 () where
-
-{-@ expression CyclicD1 Q = CyclicD2 Q @-}
-{-@ expression CyclicD2 Q = CyclicD3 Q @-}
-{-@ expression CyclicD3 Q = CyclicD1 Q @-}
-
diff --git a/tests/errors/CyclicPredAlias0.hs b/tests/errors/CyclicPredAlias0.hs
deleted file mode 100644
--- a/tests/errors/CyclicPredAlias0.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module Test0 () where
-
-{-@ predicate CyclicA1 Q = CyclicA1 Q @-}
-
diff --git a/tests/errors/CyclicPredAlias1.hs b/tests/errors/CyclicPredAlias1.hs
deleted file mode 100644
--- a/tests/errors/CyclicPredAlias1.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Test1 () where
-
-{-@ predicate CyclicB1 Q = CyclicB2 Q @-}
-{-@ predicate CyclicB2 Q = CyclicB1 Q @-}
-
diff --git a/tests/errors/CyclicPredAlias2.hs b/tests/errors/CyclicPredAlias2.hs
deleted file mode 100644
--- a/tests/errors/CyclicPredAlias2.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test2 () where
-
-{-@ predicate CyclicC1 Q = CyclicC2 Q && CyclicC3 Q @-}
-{-@ predicate CyclicC2 Q = CyclicC1 Q @-}
-{-@ predicate CyclicC3 Q = CyclicC1 Q @-}
-
diff --git a/tests/errors/CyclicPredAlias3.hs b/tests/errors/CyclicPredAlias3.hs
deleted file mode 100644
--- a/tests/errors/CyclicPredAlias3.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test3 () where
-
-{-@ predicate CyclicD1 Q = CyclicD2 Q @-}
-{-@ predicate CyclicD2 Q = CyclicD3 Q @-}
-{-@ predicate CyclicD3 Q = CyclicD1 Q @-}
-
diff --git a/tests/errors/CyclicTypeAlias0.hs b/tests/errors/CyclicTypeAlias0.hs
deleted file mode 100644
--- a/tests/errors/CyclicTypeAlias0.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Test0 () where
-
-{-@ type CyclicA1 = CyclicA2 @-}
-{-@ type CyclicA2 = CyclicA1 @-}
-
diff --git a/tests/errors/CyclicTypeAlias1.hs b/tests/errors/CyclicTypeAlias1.hs
deleted file mode 100644
--- a/tests/errors/CyclicTypeAlias1.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test1 () where
-
-{-@ type CyclicB1 = CyclicB2 @-}
-{-@ type CyclicB2 = CyclicB3 @-}
-{-@ type CyclicB3 = CyclicB1 @-}
-
diff --git a/tests/errors/CyclicTypeAlias2.hs b/tests/errors/CyclicTypeAlias2.hs
deleted file mode 100644
--- a/tests/errors/CyclicTypeAlias2.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module Test2 () where
-
-{-@ type CyclicC = [CyclicC] @-}
-
diff --git a/tests/errors/CyclicTypeAlias3.hs b/tests/errors/CyclicTypeAlias3.hs
deleted file mode 100644
--- a/tests/errors/CyclicTypeAlias3.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test3 () where
-
-{-@ type CyclicD1 = CyclicD2 @-}
-{-@ type CyclicD2 = CyclicD3 @-}
-{-@ type CyclicD3 = CyclicD2 @-}
-
diff --git a/tests/errors/DupAlias.hs b/tests/errors/DupAlias.hs
deleted file mode 100644
--- a/tests/errors/DupAlias.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module Goo () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ type BoundedNat N = {v:Nat | v < N } @-}
-{-@ predicate Foo V N = V < N            @-}
-
--- TODO: Test fails when this second alias is ALSO defined.
--- FIX: should WARN that there are duplicate aliases!
-
-{-@ type BoundedNat N = {v:Nat | v <= N } @-}
-{-@ predicate Foo V N = V <= N            @-}
-
-
-{-@ foo :: n:Int -> m:(BoundedNat n) -> Nat @-}
-foo :: Int -> Int -> Int
-foo n m = liquidAssert (m < n) m
diff --git a/tests/errors/DupData.hs b/tests/errors/DupData.hs
deleted file mode 100644
--- a/tests/errors/DupData.hs
+++ /dev/null
@@ -1,24 +0,0 @@
--- | See https://github.com/ucsd-progsys/liquidhaskell/issues/1175
-
-module BadVec where
-
-data OVec a = ONil
-            | (:>>) {oHd :: a, oTl :: OVec a}
-infixr 5 :>>
-
-{-@ data OVec a = ONil
-               | (:>>) {oHd :: a,
-                        oTl :: OVec {v:a | v >= oHd}} @-}
-
-
-{-@ data OVec [mylen] @-}
-{-@ measure mylen @-}
-{-@ mylen :: OVec a -> Nat @-}
-mylen :: OVec a -> Int
-mylen ONil       = 0
-mylen (_ :>> xs) = 1 + mylen xs
-
-{-@ badVec :: OVec Int @-}
-badVec :: OVec Int
-badVec = 1 :>> 3 :>> 2 :>> ONil
-
diff --git a/tests/errors/DupFunSigs.hs b/tests/errors/DupFunSigs.hs
deleted file mode 100644
--- a/tests/errors/DupFunSigs.hs
+++ /dev/null
@@ -1,25 +0,0 @@
--- See https://github.com/ucsd-progsys/liquidhaskell/issues/1137
-
-import Data.List
-
-{-@ type WeekDayNum = { i:Int | 0 < i && i <= 7 } @-}
-type WeekDayNum = Int -- Mon == 1, ..., Sun == 7
-
-data WeekDay = Mon | Tue | Wed | Thu | Fri | Sat | Sun
-  deriving (Read, Show, Eq, Bounded)
-
-{-@ weekdays :: { wd:[WeekDay] | len wd == 7 } @-}
-weekdays :: [WeekDay]
-weekdays = [Mon, Tue, Wed, Thu, Fri, Sat, Sun]
-
-{-@ fromWeekDayNum :: WeekDayNum -> WeekDay @-}
-fromWeekDayNum :: WeekDayNum -> WeekDay
-fromWeekDayNum i = weekdays !! (i-1)
-
-{-@ fromWeekDayNum :: WeekDay -> WeekDayNum @-}
-toWeekDayNum :: WeekDay -> WeekDayNum
-toWeekDayNum wd = case wd `elemIndex` weekdays of
-        Just i -> i + 1
-
-main :: IO ()
-main = pure ()
diff --git a/tests/errors/DupMeasure.hs b/tests/errors/DupMeasure.hs
deleted file mode 100644
--- a/tests/errors/DupMeasure.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module DuplicateMeasures where 
-
-
-{-@ measure lenA :: [a] -> Int 
-    lenA [] = 0
-    lenA (x:xs) = 1 + lenA xs 
-  @-}
-
-{-@ measure lenA :: [a] -> Int 
-    lenA [] = 0
-    lenA (x:xs) = 1 + lenA xs 
-  @-}
-
-{-@ zorg :: {v:[Int] | lenA v == 3} @-}
-zorg :: [Int]
-zorg = [1,2,3]
-
diff --git a/tests/errors/ElabLocation.hs b/tests/errors/ElabLocation.hs
deleted file mode 100644
--- a/tests/errors/ElabLocation.hs
+++ /dev/null
@@ -1,13 +0,0 @@
--- | This file tests that LH correctly localizes the elaboration error 
---   to the '10 / x' term (where we get a sort-error as the 'Ratio Int'
---   is compared against '0' which appears in the refinement for '/'.)
---   You can fix this by `embed Ratio * as Int` 
-
-module ElabLocation where
-
-import Data.Ratio 
-
-foo :: Ratio Int -> Bool
-foo x = y == y 
-  where 
-    y = 10 / x
diff --git a/tests/errors/EmptyData.hs b/tests/errors/EmptyData.hs
deleted file mode 100644
--- a/tests/errors/EmptyData.hs
+++ /dev/null
@@ -1,6 +0,0 @@
--- | see: https://github.com/ucsd-progsys/liquidhaskell/issues/1169
-
-module Bar where
-
-{-@ data A @-}
-data A = B
diff --git a/tests/errors/EmptySig.hs b/tests/errors/EmptySig.hs
deleted file mode 100644
--- a/tests/errors/EmptySig.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-
-module Blank where
-
-{-@  :: foo -> x:Int -> {v:Int | v > x} @-}
-foo :: Int -> Int 
-foo x = x - 1
diff --git a/tests/errors/ErrLocation.hs b/tests/errors/ErrLocation.hs
deleted file mode 100644
--- a/tests/errors/ErrLocation.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-
-module ErrLocation where
-
-{-@ inc :: Nat -> Nat @-}
-inc :: Int -> Int 
-inc x = x + 1
-
-bar :: Int -> Int 
-bar x = inc (x - 1)
-
diff --git a/tests/errors/ErrLocation2.hs b/tests/errors/ErrLocation2.hs
deleted file mode 100644
--- a/tests/errors/ErrLocation2.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-
-module ErrLocation2 where
-
-{-@ inc :: Nat -> Nat @-}
-inc :: Int -> Int 
-inc x = x + 1
-
-bar :: Int -> Int 
-bar x 
- | x > 0    = inc (x - 1) 
- | otherwise = inc x 
-
diff --git a/tests/errors/ExportMeasure0.hs b/tests/errors/ExportMeasure0.hs
deleted file mode 100644
--- a/tests/errors/ExportMeasure0.hs
+++ /dev/null
@@ -1,17 +0,0 @@
--- FIX: module ExportMeasure (llen) where
-    
-module ExportMeasure () where
-
-{-@ data LL [llen] @-}
-data LL a = N | C a (LL a)
-
-{-@ invariant {v:LL a | (llen v) >= 0} @-}
-
-{-@ measure llen @-}
-llen :: (LL a) -> Int 
-llen(N)      = 0
-llen(C x xs) = 1 + (llen xs)
-
-{-@ lmap :: (a -> b) -> xs:(LL a) -> {v: LL b | llen v = llen xs } @-} 
-lmap f N = N
-lmap f (C x xs) = C (f x) (lmap f xs)
diff --git a/tests/errors/ExportReflect0.hs b/tests/errors/ExportReflect0.hs
deleted file mode 100644
--- a/tests/errors/ExportReflect0.hs
+++ /dev/null
@@ -1,28 +0,0 @@
--- LH issue #1023
-
-{-@ LIQUID "--exactdc"     @-}
-{-@ LIQUID "--higherorder" @-}
-
-module Bug (foo, zogbert) where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ reflect identity @-}
-identity :: a -> a
-identity x = x
-
-{-@ reflect identity2 @-}
-identity2 :: a -> a
-identity2 x = x
-
-{-@ reflect identity3 @-}
-identity3 :: a -> a
-identity3 x = x
-
-{-@ foo :: x:a -> { identity x == x } @-}
-foo :: a -> Proof
-foo x = identity x === x *** QED
-
-{-@ reflect zogbert @-}
-zogbert :: a -> a
-zogbert x = x
diff --git a/tests/errors/Fractional.hs b/tests/errors/Fractional.hs
deleted file mode 100644
--- a/tests/errors/Fractional.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Crash where
-
-{-@ f :: (Num a) => {v:a | v > 0.0} -> a @-}
-f :: (Num a) => a -> a
-f a = a + 1
-
-{-@ g :: (Num a) => {v:a | v > 0.0} -> a @-}
-g :: (Num a) => a -> a
-g = f
diff --git a/tests/errors/HigherOrderBinder.hs b/tests/errors/HigherOrderBinder.hs
deleted file mode 100644
--- a/tests/errors/HigherOrderBinder.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-{-@ foo :: a: Int -> f: (Int -> Int) -> {v : Int | v = 123 + (f a) } @-}
-foo :: Int -> (Int -> Int) -> Int
-foo a f = f a
-
-main :: IO ()
-main = pure ()
diff --git a/tests/errors/HintMismatch.hs b/tests/errors/HintMismatch.hs
deleted file mode 100644
--- a/tests/errors/HintMismatch.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-
-{-# LANGUAGE DataKinds #-}
-
-module HintMismatch where
-
-newtype Offset struct member = Offset { unOffset :: Int }
-
-type OffsetN t = Offset (t 'Nothing)
-
-foo = Nothing 
-
-{-@ bar :: t 'Nothing @-}
-bar :: t 'Nothing
-bar = undefined 
diff --git a/tests/errors/HoleCrash1.hs b/tests/errors/HoleCrash1.hs
deleted file mode 100644
--- a/tests/errors/HoleCrash1.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module ListDemo where
-
-data Poo a = C { t :: Poo a }
-
-{-@ type Geq N = {v:_ | N <= v} @-}
-
-{-@ data Poo a = C { t :: Poo (Geq 0) } @-}
diff --git a/tests/errors/HoleCrash2.hs b/tests/errors/HoleCrash2.hs
deleted file mode 100644
--- a/tests/errors/HoleCrash2.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module ListDemo where
-
-data Poo a = C { t :: Poo a }
-
-{-@ type Geq a N = {v:a | N <= v} @-}
-
-{-@ data Poo a = C { t :: Poo (Geq 0) } @-}
diff --git a/tests/errors/HoleCrash3.hs b/tests/errors/HoleCrash3.hs
deleted file mode 100644
--- a/tests/errors/HoleCrash3.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module ListDemo where
-
-data List a = E | (:::) { h :: a, t :: List a }
-
-infixr  9 ::: 
-
-{-@ countUp :: n:Int -> List Int @-}
-countUp n  = n ::: countUp (n + 1)
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/errors/Inconsistent0.hs b/tests/errors/Inconsistent0.hs
deleted file mode 100644
--- a/tests/errors/Inconsistent0.hs
+++ /dev/null
@@ -1,61 +0,0 @@
--- FAILING TEST: this test SHOULD FAIL BUT DOESN'T
--- issue #519
-
-{-# LANGUAGE DeriveFunctor #-}
-module Ast where
-
-data AstIndex = IxExpr | IxType
-
-{-@ measure isExprIndex @-}
-isExprIndex :: AstIndex -> Bool
-isExprIndex IxExpr = True
-isExprIndex _      = False
-
-{-@ measure isTypeIndex @-}
-isTypeIndex :: AstIndex -> Bool
-isTypeIndex IxType = True
-isTypeIndex _      = False
-
-data AstF f = Lit Int    AstIndex
-            | Var String AstIndex
-            | App f f
-            | Paren f
-
-{-@
-  data AstF f <ix :: AstIndex -> Bool>
-    = Lit {l1 :: Int, i :: AstIndex<ix>}
-    | Var {v1 :: String, i :: AstIndex<ix>}
-    | App (fn :: f) (arg :: f)
-    | Paren (ast :: f)
-  @-}
-
-{-@ type AstFE = AstF <{\ix -> isExprIndex ix}> @-}
-{-@ type AstFT = AstF <{\ix -> isTypeIndex ix}> @-}
-
-
--- Now lets tie the knot!
-
-newtype Fix f = In { out :: f (Fix f) }
-
-type Ast = Fix AstF
-
-{-@ type AstE = Fix AstFE @-}
-{-@ type AstT = Fix AstFT @-}
-
-{-@ astExpr :: AstE  @-}
-astExpr :: Ast
-astExpr = In (Lit 10 IxExpr) 
-
-{-@ astType :: AstT @-}
-astType :: Ast 
-astType = In (Lit 10 IxType)
-
-{-@ app :: forall <p :: AstIndex -> Bool>. Fix (AstF<p>) -> Fix (AstF<p>) -> Fix (AstF<p>) @-}
-app f x = In $ App f x
-
-{-@ id1 :: forall <p :: AstIndex -> Bool>. Fix (AstF p) -> Fix (AstF p)  @-}
-id1 :: Fix AstF -> Fix AstF
-id1 z = z
-
-{-@ wrong :: AstT @-}
-wrong = id1 astExpr
diff --git a/tests/errors/Inconsistent1.hs b/tests/errors/Inconsistent1.hs
deleted file mode 100644
--- a/tests/errors/Inconsistent1.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Boo where
-
-{-@ incr :: Int -> Bool @-}
-incr :: Int -> Int 
-incr x = x + 1
diff --git a/tests/errors/Inconsistent2.hs b/tests/errors/Inconsistent2.hs
deleted file mode 100644
--- a/tests/errors/Inconsistent2.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Mismatch where
-
-{-@ foo :: Nat @-}
-foo :: Bool
-foo = True
diff --git a/tests/errors/InlineSubExp0.hs b/tests/errors/InlineSubExp0.hs
deleted file mode 100644
--- a/tests/errors/InlineSubExp0.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-
--- https://github.com/ucsd-progsys/liquidhaskell/issues/1258
-
-{-@ LIQUID "--reflection"  @-}
-{-@ LIQUID "--short-names" @-} 
-
-module T1258 where 
-
-import Language.Haskell.Liquid.ProofCombinators 
-
-data Foo = A | B
-data Bar = C | D
-data Baz = E | F
-
-{-@ reflect f @-}
-f :: Foo -> Bar -> Baz
-f B C = F
-f _ _ = E
-
-{-@ prop :: {f B C == F} @-}
-prop = f B C === E *** QED  
diff --git a/tests/errors/InlineSubExp1.hs b/tests/errors/InlineSubExp1.hs
deleted file mode 100644
--- a/tests/errors/InlineSubExp1.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-
--- https://github.com/ucsd-progsys/liquidhaskell/issues/1258
-
-{-@ LIQUID "--reflection"  @-}
-{-@ LIQUID "--short-names" @-}
-
-module T1258 where 
-
-import Language.Haskell.Liquid.ProofCombinators 
-
-data Foo = A | B
-data Bar = C | D
-data Baz = E | F | G 
-
-{-@ reflect f @-}
-f :: Foo -> Bar -> Baz
-f B C = F
-f A D = E
-f _ _ = G 
-
-{-@ reflect g @-}
-g :: Foo -> Bar 
-g A = C 
-g _ = D 
-
-test = f B (g A) === f A D *** QED  
diff --git a/tests/errors/LiftMeasureCase.hs b/tests/errors/LiftMeasureCase.hs
deleted file mode 100644
--- a/tests/errors/LiftMeasureCase.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Measures where
-
-llen :: [a] -> Int
-llen [] = 0
-llen (x:xs) = 1 + llen xs
-
-{-@ measure foo @-}
-foo :: a -> a 
-foo x = x
-
-{-@ measure lllen @-}
-
-{-@ lllen :: xs:[a] -> {v:Int| (lllen xs) = v} @-}
-lllen :: [a] -> Int	
-lllen [] = 0
-lllen (x:xs) = 1 + lllen xs
diff --git a/tests/errors/LocalHole.hs b/tests/errors/LocalHole.hs
deleted file mode 100644
--- a/tests/errors/LocalHole.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module LocalHole where
-
-mysum xs = go 0 0
-  where
-    n = length xs
-    {-@ go :: i:{Nat | i <= nowhere} -> _ -> _ @-}
-    go i acc
-      | i >= n    = acc
-      | otherwise = go (i+1) (acc + xs !! i)
diff --git a/tests/errors/MissingAssume.hs b/tests/errors/MissingAssume.hs
deleted file mode 100644
--- a/tests/errors/MissingAssume.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module OverWrite where
-
-import qualified Data.Set
-
-{-@ type UList a = {v:[a] | ListUnique v} @-}
-
-{-@ assume goober :: Nat -> Nat @-} 
-
-{-@ assume reverse :: xs:(UList a) -> {v: UList a | EqElts v xs}  @-}
-
-{-@ predicate ListUnique LS = (Set_emp (listDup LS)) @-}
-
-{-@ predicate EqElts X Y    = ((listElts X) = (listElts Y)) @-}
-
-{-@
-  measure listDup :: [a] -> (Data.Set.Set a)
-  listDup([])   = {v | Set_emp v }
-  listDup(x:xs) = {v | v = if (Set_mem x (listElts xs)) then (Set_cup (Set_sng x) (listDup xs)) else (listDup xs) }
-  @-}
-
-{-@ foo :: xs:(UList a) -> {v: UList a | EqElts v xs} @-}
-foo  = reverse 
diff --git a/tests/errors/MissingField1.hs b/tests/errors/MissingField1.hs
deleted file mode 100644
--- a/tests/errors/MissingField1.hs
+++ /dev/null
@@ -1,6 +0,0 @@
--- TODO-REBARE: LH _should_ (?) complain: "Unknown field `goober` in refined definition of `Foo`"
-
-data Foo = F Int 
-
-{-@ data Foo = F { goober :: Int } @-}
-
diff --git a/tests/errors/MissingField2.hs b/tests/errors/MissingField2.hs
deleted file mode 100644
--- a/tests/errors/MissingField2.hs
+++ /dev/null
@@ -1,17 +0,0 @@
--- TODO-REBARE: LH _should_ (?) complain: "Unknown field `fxx` in refined definition of `F`"
-
-module Invariant where
-
-data F a = F {fx :: a, fy :: a, fzz :: a} | G {fx :: a}
-
-{-@ data F a = F { fxx :: a, fy :: a, fz :: a}
-             | G { fxx :: a } 
-  @-}
-
-{-@ fooG :: x:a -> {v : F a | (fxx v) > x} @-}
-fooG :: a -> F a
-fooG x = G x 
-
-{-@ foo :: x:a -> {v : F a | (fxx v) > x} @-}
-foo :: a -> F a
-foo x = F x x x
diff --git a/tests/errors/MissingReflect.hs b/tests/errors/MissingReflect.hs
deleted file mode 100644
--- a/tests/errors/MissingReflect.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-{-@ LIQUID "--reflection"                     @-}
-{-@ LIQUID "--ple"                                @-}
-
-import Language.Haskell.Liquid.ProofCombinators 
-
--- | This fails with an error as `foo` is unbound sans the `reflect` annotation. 
-
-{- reflect foo -}
-
-{-@ foo  :: Nat ->  xs: [Nat] -> Nat -> Bool / [len xs ]@-}
-foo :: Int ->  [Int] -> Int -> Bool
-foo lo [] hi     = (lo<=hi)
-foo lo (x:xs) hi = (lo<=hi) && foo lo xs x
-
-{-@ empty_foo :: lo:Nat -> hi:{Nat | lo <= hi } -> {foo lo [] hi} @-}
-empty_foo :: Int -> Int -> Proof
-empty_foo lo hi = (foo lo [] hi) ==. (lo <= hi) ==.True  *** QED
-
-main :: IO ()
-main = pure ()
diff --git a/tests/errors/MissingSizeFun.hs b/tests/errors/MissingSizeFun.hs
deleted file mode 100644
--- a/tests/errors/MissingSizeFun.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-{-@ LIQUID "--nostruct" @-}
-
-module MissingSizeFun where
-
-{-@ data List [llen] a = N | C {lhead :: a, ltail :: List a} @-}
-data List a = N | C a (List a)
-
-{-@ measure llen @-}
-llen :: List a -> Bool 
-llen N = True  
-llen (C _ xs) = False -- 1 + llen xs
-
-
-{-@ data List2 [llen2] a = N2 | C2 {lhead2 :: a, ltail2 :: List2 a} @-}
-data List2 a = N2 | C2 a (List2 a)
diff --git a/tests/errors/MultiInstMeasures.hs b/tests/errors/MultiInstMeasures.hs
deleted file mode 100644
--- a/tests/errors/MultiInstMeasures.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-module Blank where
-
-import Data.Word
-import GHC.Ptr
-
-{-@ class measure sizeOf :: forall a . Ptr a -> Int @-}
-
-{-@
-instance measure sizeOf :: (Ptr GHC.Word.Word16) -> Int
-sizeOf (Ptr x) = 2
-@-}
-
-{-@
-instance measure sizeOf :: (Ptr GHC.Word.Word32) -> Int
-sizeOf (Ptr y) = 4
-@-}
-
-{-@
-bar :: { p : Ptr Word32 | plen p >= (sizeOf p) }
-    -> ()
-@-}
-bar :: Ptr Word32 -> ()
-bar (Ptr unused) = ()
-
-{-@
-qux :: { p : Ptr Word32 | plen p >= 0 }
-    -> ()
-@-}
-qux :: Ptr Word32 -> ()
-qux (Ptr addr) = let x = Ptr addr in bar x
-
diff --git a/tests/errors/MultiRecSels.hs b/tests/errors/MultiRecSels.hs
deleted file mode 100644
--- a/tests/errors/MultiRecSels.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-module RedBlack  where
-
-data RBTree a = Leaf
-              | Node Color a !(RBTree a) !(RBTree a)
-
-data Color = B | R
-
-{-@ ok :: { v: RBTree Int | false} @-}
-ok = Node R (2 :: Int)
-         (Node B 1 Leaf Leaf)
-         (Node B 3 Leaf Leaf)
-
--- LH should give an error message that the field names are duplicates.
-
-{-@ data RBTree a = Leaf
-                  | Node { c     :: Color
-                         , key   :: a
-                         , left  :: RBTree ({v:a | v < key})
-                         , left  :: RBTree ({v:a | key < v})
-                         }
-  @-}
diff --git a/tests/errors/ParseBind.hs b/tests/errors/ParseBind.hs
deleted file mode 100644
--- a/tests/errors/ParseBind.hs
+++ /dev/null
@@ -1,7 +0,0 @@
--- We should reject the below to disallow uppercase binders
-
-module NoUpperCaseBinders where
-
-{-@ id :: Foo:Int -> Int  @-}
-id :: Int -> Int
-id x = x
diff --git a/tests/errors/ParseClass.hs b/tests/errors/ParseClass.hs
deleted file mode 100644
--- a/tests/errors/ParseClass.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module Crash where
-
-class Foo a where
-{-@ class Foo where
-      foo :: x:a -> {v:a | v = x}
-  @-}
-  foo :: a -> a       
-
-instance Foo Int where
-  {-@ instance Foo Int where
-       foo :: x:Int -> {v:Int | v = x + 1 == 9} @-}
-  foo x = x + 1
-
-instance Foo Integer where
-  {-@ instance Foo Integer where
-       foo :: x:Integer -> {v:Integer | v = x + 1} @-}
-  foo x = x + 1
diff --git a/tests/errors/ReWrite5.hs b/tests/errors/ReWrite5.hs
deleted file mode 100644
--- a/tests/errors/ReWrite5.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-module ReWrite5 where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding (filter)
-
-{-@ reflect lt5 @-}
-lt5 :: Int -> Bool
-lt5 x = x < 5
-
-{-@ reflect filter @-}
-filter _ []     = []
-filter p (x:xs) = if p x then x:(filter p xs) else filter p xs
-
--- Reject inner refinements
-{-@ rw :: xs :  [{ v: Int | v > 5 }] -> { filter lt5 xs = [] } @-}
-rw :: [Int] -> ()
-rw []     = ()
-rw (_:xs) = rw xs
-
-{-@ rewriteWith bad [rw] @-}
-{-@ bad :: xs : [Int] -> { filter lt5 xs = [] } @-}
-bad :: [Int] -> ()
-bad _ = ()
diff --git a/tests/errors/ReWrite6.hs b/tests/errors/ReWrite6.hs
deleted file mode 100644
--- a/tests/errors/ReWrite6.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module ReWrite6 where
-
--- Reject non equalities
-{-@ rewrite bad @-}
-{-@ bad :: {1 < 2} @-}
-bad :: ()
-bad = ()
diff --git a/tests/errors/ReWrite7.hs b/tests/errors/ReWrite7.hs
deleted file mode 100644
--- a/tests/errors/ReWrite7.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module ReWrite7 where
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-
-{-@ reflect f @-}
-f :: [Int] -> Bool
-f []      = True
-f (x:xs) = f xs
-
--- Reject both sides with free vars
-{-@ rewrite bad @-}
-{-@ bad :: x : [Int] -> y : [Int] -> { f x = f y } @-}
-bad :: [Int] -> [Int] -> ()
-bad [] []        = ()
-bad (x:xs) ys    = bad xs ys
-bad []    (y:ys) = bad [] ys
diff --git a/tests/errors/ReWrite8.hs b/tests/errors/ReWrite8.hs
deleted file mode 100644
--- a/tests/errors/ReWrite8.hs
+++ /dev/null
@@ -1,40 +0,0 @@
-module ReWrite8 where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++), length, head)
-
-{-@ measure length @-}
-length :: [a] -> Int
-length (_:xs) = 1 + length xs
-length     [] = 0
-
-{-@ reflect head @-}
-{-@ head :: {xs : [a] | length xs >= 1} -> a @-}
-head (x:_) = x
-
-{-@ rewrite singleProof @-}
-{-@ assume singleProof :: 
-          { xs : [a] | True } 
-      ->  { ys : [a] | True } 
-      ->  { xs = ys ++ [] } @-}
-singleProof :: [a] -> [a] -> ()
-singleProof _ _ = ()
-
--- Reject both sides free vars (assumed fn)
-{-@ sp :: 
-          { xs : [a] | True } 
-      ->  { ys : [a] | True } 
-      ->  { xs = ys ++ [] } @-}
-sp :: [a] -> [a] -> ()
-sp _ _ = ()
-
-
-{-@ reflect ++ @-}
-(++)::[a] -> [a] -> [a]
-[]     ++ ys = ys 
-(x:xs) ++ ys = x:(xs ++ys)
-
-
diff --git a/tests/errors/ShadowFieldInline.hs b/tests/errors/ShadowFieldInline.hs
deleted file mode 100644
--- a/tests/errors/ShadowFieldInline.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-{-@ LIQUID "--exactdc" @-}
-
-module Range where
-
--- LH should give an error message that the field selectors `pig`
--- is shadowed and should be renamed.
-
-{-@ data Zig = Zonk { pig :: Int } @-}
-data Zig = Zonk Int 
-
-{-@ prop :: z:Zig -> {v:Int | v = pig z} @-}
-prop :: Zig -> Int
-prop (Zonk n) = n
-
-{-@ inline pig @-}
-pig :: Int -> Int
-pig a = a + 1
diff --git a/tests/errors/ShadowFieldReflect.hs b/tests/errors/ShadowFieldReflect.hs
deleted file mode 100644
--- a/tests/errors/ShadowFieldReflect.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-{-@ LIQUID "--exactdc" @-}
-
-module Range where
-
--- LH should give an error message that the field selectors `pig`
--- is shadowed and should be renamed.
-
-{-@ data Zig = Zonk { pig :: Int } @-}
-data Zig = Zonk Int
-
-{-@ prop :: z:Zig -> {v:Int | v = pig z} @-}
-prop :: Zig -> Int
-prop (Zonk n) = n
-
-{-@ reflect pig @-}
-pig :: Int -> Int
-pig a = a + 1
diff --git a/tests/errors/ShadowMeasure.hs b/tests/errors/ShadowMeasure.hs
deleted file mode 100644
--- a/tests/errors/ShadowMeasure.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-
--- ISSUE: Currently this doesn't CRASH because the two sorts for `shadow` are the
--- same, but that is a happy coincidence. We should REJECT this program as the
--- measure has the same name as another binder.
-
-module Shadow where
-
-data Poo = Poo Int
-
-{-@ measure shadow :: Poo -> Int
-    shadow (Poo n) = n
-  @-}
-
-{-@ test :: p:Poo -> {v:Int | v = shadow p} @-}
-test :: Poo -> Int
-test (Poo n) = n
-
-{-@ measure shadow @-}
-shadow :: [a] -> Int
-shadow [] = 0
-shadow (x:xs) = 0
diff --git a/tests/errors/ShadowMeasureVar.hs b/tests/errors/ShadowMeasureVar.hs
deleted file mode 100644
--- a/tests/errors/ShadowMeasureVar.hs
+++ /dev/null
@@ -1,17 +0,0 @@
--- REJECT this program as the measure has the same name as another binder.
-
-module Shadow where
-
-data Poo = Poo Int
-
-{-@ measure shadow :: Poo -> Int
-    shadow (Poo n) = n
-  @-}
-
-{-@ test :: p:Poo -> {v:Int | v = shadow p} @-}
-test :: Poo -> Int
-test (Poo n) = n
-
-shadow :: Int
-shadow = 121
-
diff --git a/tests/errors/T1140.hs b/tests/errors/T1140.hs
deleted file mode 100644
--- a/tests/errors/T1140.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-
-module Blank where 
-	
-data Label = Label Int 
-
-type Proof = () 
-
-{-@ foo :: Label -> Label -> Label -> Proof @-} 
-foo :: Label -> Label -> Label -> Proof -> Proof 
-foo a b c v = ()
-
diff --git a/tests/errors/T1498.hs b/tests/errors/T1498.hs
deleted file mode 100644
--- a/tests/errors/T1498.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module T1498 where 
-
-class A a where
-  f :: a -> Int
-
-instance A Int where
-  {-@ f :: _ -> {x : Int | 0 < x} @-}
-  f n = n
-
-{-@ x :: {x : Int | 0 < x} @-}
-x :: Int
-x = f ((-1) :: Int)
diff --git a/tests/errors/T1498A.hs b/tests/errors/T1498A.hs
deleted file mode 100644
--- a/tests/errors/T1498A.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module T1498A where
-
-class A a where
-  f :: a -> Int
-  
-instance A Int where
-{-@ instance A Int where
-      f :: _ -> {x : Int | 0 < x}
-  @-}
-  f n = (-1)
diff --git a/tests/errors/T773.hs b/tests/errors/T773.hs
deleted file mode 100644
--- a/tests/errors/T773.hs
+++ /dev/null
@@ -1,11 +0,0 @@
--- | Right now this gives a rather mysterious error, 
---   cannot unify `int` with `(a b)` it would be nice 
---   to actually point out the offending sub-expression, namely `len x`.
-
-module LiquidR where
-
-{-@ measure goober :: String -> Int @-}
-
-{-@ incr :: x:Int -> {v:Bool | goober x == 0} @-}
-incr :: Int -> Bool
-incr = undefined
diff --git a/tests/errors/T774.hs b/tests/errors/T774.hs
deleted file mode 100644
--- a/tests/errors/T774.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-
--- | Why does this NOT fail?! Clearly there is a sort error?!
-
-module LiquidR where
-
-{-@ measure goober :: String -> Int @-}
-
-{-@ incr :: x:Int -> y:Int -> {v:Bool | goober x == goober y} @-}
-incr :: Int -> Int -> Bool
-incr = undefined
diff --git a/tests/errors/TODOUnboundAbsRef.hs b/tests/errors/TODOUnboundAbsRef.hs
deleted file mode 100644
--- a/tests/errors/TODOUnboundAbsRef.hs
+++ /dev/null
@@ -1,43 +0,0 @@
--- ISSUE: In the below datatype, mickeymouse is clearly UNBOUND, and yet
--- LH happily chugs along, and just says UNSAT at the end, instead of
--- pointing out the bogus datatype definition.
-
-module ListRange () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ LIQUID "--no-termination" @-}
-
-
-{-@
-data List [llen] a <p :: x0:a -> x1:a -> Bool>
-  = Nil
-  | Cons { lHd :: a, lTl :: List <p> (a <p mickeymouse>) }
-@-}
-
-{-@ measure llen :: (List a) -> Int
-    llen(Nil)       = 0
-    llen(Cons x xs) = 1 + (llen xs)
-  @-}
-
-{-@ invariant {v:(List a) | ((llen v) >= 0)} @-}
-
-data List a = Nil | Cons a (List a)
-
-{-
-low, high :: Int
-low  = 0
-high = 10
--}
-
-range l h =
-  if l <= h then Cons l (range (l+1) h) else Nil
-
-chk y =
-  case y of
-   Nil -> True
-   Cons x1 xs -> case xs of
-                 Nil -> True
-                 Cons x2 xs2 -> liquidAssertB (x1 <= x2) && chk xs2
-
-prop3 = chk $ range 1 100
diff --git a/tests/errors/TODOVarInTypeAlias.hs b/tests/errors/TODOVarInTypeAlias.hs
deleted file mode 100644
--- a/tests/errors/TODOVarInTypeAlias.hs
+++ /dev/null
@@ -1,84 +0,0 @@
--- VS.hs
-{-@ LIQUID "--higherorder"    @-}
-{-@ LIQUID "--totality"       @-}
-{-@ LIQUID "--exactdc"        @-}
-
-module RL1015 where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ data VerifiedSemigroup a = VerifiedSemigroup { sappend :: a -> a -> a } @-}
-data VerifiedSemigroup a = VerifiedSemigroup { sappend :: a -> a -> a }
-
-infixr 6 `sappend`
-
--- ISSUE: UNBOUND VARIABLE IN TYPE ALIAS!!!! gR should be GR
-{-@ type VSappendAssoc a GR = x:a -> y:a -> z:a
-                           -> { v: Proof | sappend GR x (sappend GR y z) == sappend GR (sappend gR x y) z }
-  @-}
-type SappendAssoc a = a -> a -> a -> Proof
-
-{-@ axiomatize sappendInv @-}
-sappendInv :: (a -> a -> a)
-           -> (a -> b) -> (b -> a)
-           -> b -> b -> b
-sappendInv sappendA f g x y = f (sappendA (g x) (g y))
-{-# INLINE sappendInv #-}
-
-{-@ sappendInvAssoc :: sappendA:(a -> a -> a)
-                    -> sappendAAssoc:(i:a -> j:a -> k:a -> { sappendA i (sappendA j k) == sappendA (sappendA i j) k })
-                    -> f:(a -> b)
-                    -> g:(b -> a)
-                    -> gof:(z:a -> { g (f z) == z })
-                    -> x:b
-                    -> y:b
-                    -> z:b
-                    -> { sappendInv sappendA f g x (sappendInv sappendA f g y z) == sappendInv sappendA f g (sappendInv sappendA f g x y) z }
-@-}
-sappendInvAssoc :: (a -> a -> a)
-                -> (a -> a -> a -> Proof)
-                -> (a -> b)
-                -> (b -> a)
-                -> (a -> Proof)
-                -> b -> b -> b
-                -> Proof
-sappendInvAssoc sappendA sappendAAssoc f g gof x y z
-  =   sappendInv sappendA f g x (sappendInv sappendA f g y z)
-  ==. sappendInv sappendA f g x (f (sappendA (g y) (g z)))
-  ==. f (sappendA (g x) (g (f (sappendA (g y) (g z)))))
-  ==. f (sappendA (g x) (sappendA (g y) (g z))) ? gof (sappendA (g y) (g z))
-  ==. f (sappendA (sappendA (g x) (g y)) (g z)) ? sappendAAssoc (g x) (g y) (g z)
-  ==. f (sappendA (g (f (sappendA (g x) (g y)))) (g z)) ? gof (sappendA (g x) (g y))
-  ==. f (sappendA (g (sappendInv sappendA f g x y)) (g z))
-  ==. sappendInv sappendA f g (sappendInv sappendA f g x y) z
-  *** QED
-
-{-@ reflect vsemigroupInv @-}
-{-@ vsemigroupInv :: f:(a -> b)
-                  -> g:(b -> a)
-                  -> gof:(x:a -> { g (f x) == x })
-                  -> VerifiedSemigroup a
-                  -> VerifiedSemigroup b
-@-}
-vsemigroupInv :: (a -> b) -> (b -> a) -> (a -> Proof)
-              -> VerifiedSemigroup a -> VerifiedSemigroup b
-vsemigroupInv f g gof (VerifiedSemigroup sappendA)
-  = VerifiedSemigroup (sappendInv sappendA f g)
-
-
-{-@ vsgiAssoc :: f:(a -> b)
-              -> g:(b -> a)
-              -> gof:(x:a -> { g (f x) == x })
-              -> poopa:(VerifiedSemigroup a)
-              -> VSappendAssoc a poopa
-              -> SappendAssoc b
-
-  @-}
-vsgiAssoc :: (a -> b) -> (b -> a) -> (a -> Proof) -> VerifiedSemigroup a
-          -> SappendAssoc a
-          -> SappendAssoc b
-vsgiAssoc f g gof (VerifiedSemigroup sappendA) sappendAAssoc
-  = sappendInvAssoc sappendA sappendAAssoc f g gof
-
-              -- -> VSappendAssoc a va
-              -- -> VSappendAssoc b {vsemigroupInv f g gof va}
diff --git a/tests/errors/TerminationExprNum.hs b/tests/errors/TerminationExprNum.hs
deleted file mode 100644
--- a/tests/errors/TerminationExprNum.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module TerminationExpr where
-
-{-@ showSep :: _ -> xs:_ -> _ / [xs] @-} -- use xs as reducing param
-showSep :: String -> [String] -> String
-showSep sep []     = ""
-showSep sep [x]    = x
-showSep sep (x:xs) = x ++ sep ++ showSep sep xs
-
diff --git a/tests/errors/TerminationExprSort.hs b/tests/errors/TerminationExprSort.hs
deleted file mode 100644
--- a/tests/errors/TerminationExprSort.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module TerminationExpr where
-
-{-@ showSep :: _ -> xs:_ -> _ / [len ys] @-} -- use xs as reducing param
-showSep :: String -> [String] -> String
-showSep sep []     = ""
-showSep sep [x]    = x
-showSep sep (x:xs) = x ++ sep ++ showSep sep xs
-
diff --git a/tests/errors/TerminationExprUnb.hs b/tests/errors/TerminationExprUnb.hs
deleted file mode 100644
--- a/tests/errors/TerminationExprUnb.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module LocalTermExpr where
-
-{- assume (!!) :: xs:[a] -> {v:Nat | v < len xs} -> a @-}
-
-mysum xs = go 0 0
-  where
-    n = length xs
-    {-@ go :: i:_ -> _ -> _ / [nn - i] @-}
-    go i acc
-      | i >= n    = acc
-      | otherwise = go (i+1) (acc + xs !! i)
diff --git a/tests/errors/UnboundAbsRef.hs b/tests/errors/UnboundAbsRef.hs
deleted file mode 100644
--- a/tests/errors/UnboundAbsRef.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-
--- ISSUE: this "crashes" without a decent source location
--- You can fix this with the signature `ide :: forall <p :: a -> Prop>. a<p> -> a<p>`
--- but it would be nice to have an error message that pinpoints the location.
--- https://github.com/ucsd-progsys/liquidhaskell/issues/655
-
-module Ide where
-
-{-@ ide :: a<p> -> a<p> @-}
-ide x = x
diff --git a/tests/errors/UnboundCheckVar.hs b/tests/errors/UnboundCheckVar.hs
deleted file mode 100644
--- a/tests/errors/UnboundCheckVar.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-{-@ LIQUID "--checks=ink" @-}
-
-module UnboundCheckVar where 
-
-inc :: Int -> Int 
-inc x = x + 1
-
diff --git a/tests/errors/UnboundFunInSpec.hs b/tests/errors/UnboundFunInSpec.hs
deleted file mode 100644
--- a/tests/errors/UnboundFunInSpec.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Goo () where
-
-cnt   :: Int -> Int
-cnt 0 = 0
-cnt i = 1 + cnt (i-1)
-
-{-@ three :: {v:Int | (cnt v) = 3} @-}
-three :: Int
-three = 15
diff --git a/tests/errors/UnboundFunInSpec1.hs b/tests/errors/UnboundFunInSpec1.hs
deleted file mode 100644
--- a/tests/errors/UnboundFunInSpec1.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module Goo where
-
-{-@ foo :: xs:_ -> {v:_ | this = rubbish } @-}
-foo _ _ = 0
diff --git a/tests/errors/UnboundFunInSpec2.hs b/tests/errors/UnboundFunInSpec2.hs
deleted file mode 100644
--- a/tests/errors/UnboundFunInSpec2.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Goo where
-
-{-@ foo :: Num a => { z : (xs:t -> {v : (t -> a) | this = rubbish }) | wow = hi } @-}
-foo :: Num a => t -> t -> a
-foo _ _ = 0
diff --git a/tests/errors/UnboundVarInAssume.hs b/tests/errors/UnboundVarInAssume.hs
deleted file mode 100644
--- a/tests/errors/UnboundVarInAssume.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Assume where
-
-{-@ assume incr :: Int -> {v : Int | v == x} @-}
-incr :: Int -> Int
-incr x = x + 1
diff --git a/tests/errors/UnboundVarInLocSig.hs b/tests/errors/UnboundVarInLocSig.hs
deleted file mode 100644
--- a/tests/errors/UnboundVarInLocSig.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Local02 where 
-
-{-@ foo :: x:_ -> y:_ -> {v:Int | v = x + y} @-} 
-foo :: Int -> Int -> Int 
-foo arg0 = bar 
-  where 
-    {-@ bar :: x:_ -> {v:Int | v = x + barg0} @-} 
-    bar arg1 = arg0 + arg1 
diff --git a/tests/errors/UnboundVarInReflect.hs b/tests/errors/UnboundVarInReflect.hs
deleted file mode 100644
--- a/tests/errors/UnboundVarInReflect.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module UnboundVarInReflect where
-
--- see GH #1708
-
-{-@ LIQUID "--reflection" @-}
-{-@ reflect frog @-}
-frog :: () -> Bool
-frog () = undefined
diff --git a/tests/errors/UnboundVarInSpec.hs b/tests/errors/UnboundVarInSpec.hs
deleted file mode 100644
--- a/tests/errors/UnboundVarInSpec.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Fixme where
-
-
-{-@ foo :: forall <p :: s -> s -> Bool>.
-                   xs:s<p y> -> s<p xs> @-}
-foo :: s -> s
-foo s = s
diff --git a/tests/ffi-include/foo.c b/tests/ffi-include/foo.c
deleted file mode 100644
--- a/tests/ffi-include/foo.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "foo.h"
-int foo(int x) {
-  return x;
-}
diff --git a/tests/ffi-include/foo.h b/tests/ffi-include/foo.h
deleted file mode 100644
--- a/tests/ffi-include/foo.h
+++ /dev/null
@@ -1,1 +0,0 @@
-int foo(int);
diff --git a/tests/import/client/CliAliasGen00.hs b/tests/import/client/CliAliasGen00.hs
deleted file mode 100644
--- a/tests/import/client/CliAliasGen00.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module CliAliasGen00 where 
-
-import LibAliasGen00 
-
-bar = foo 10
diff --git a/tests/import/client/CliRedBlue.hs b/tests/import/client/CliRedBlue.hs
deleted file mode 100644
--- a/tests/import/client/CliRedBlue.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module CliRedBlue where 
-
-import           LibBlue 
-import qualified LibRedBlue as RB 
-
-{-@ yumyum :: _ -> Nat @-}
-yumyum = RB.foo
diff --git a/tests/import/client/Client0.hs b/tests/import/client/Client0.hs
deleted file mode 100644
--- a/tests/import/client/Client0.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Client0 where 
-
-    import Client1 
-    
-    a :: Eq a => B a -> Bool 
-    a (B x y) = x == y 
diff --git a/tests/import/client/Client1.hs b/tests/import/client/Client1.hs
deleted file mode 100644
--- a/tests/import/client/Client1.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Client1 where 
-
-    import Client2
-    
-    data B a = B {b1 :: a, b2 :: a }
-    {-@ data B a = B {b1 :: a, b2 :: {v:a | cProp b1 v } } @-}
-
-
diff --git a/tests/import/client/Client2.hs b/tests/import/client/Client2.hs
deleted file mode 100644
--- a/tests/import/client/Client2.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Client2 where 
-
-    {-@ reflect cProp @-}
-    
-    cProp :: Eq a => a -> a -> Bool 
-    cProp x y = x == y 
-
-
diff --git a/tests/import/client/ExactGADT9.hs b/tests/import/client/ExactGADT9.hs
deleted file mode 100644
--- a/tests/import/client/ExactGADT9.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--no-adt"     @-}
-
-{-# LANGUAGE ExistentialQuantification, KindSignatures, TypeFamilies, GADTs #-}
-
-module ExactGADT9 where
-
-import ExactGADT8
-
-{-@ reflect bar @-}
-bar :: RefinedFilter Blob typ -> Bool
-bar (RefinedFilter BlobXVal) = True
-bar (RefinedFilter BlobYVal) = True
diff --git a/tests/import/client/FunClashLibLibClient.hs b/tests/import/client/FunClashLibLibClient.hs
deleted file mode 100644
--- a/tests/import/client/FunClashLibLibClient.hs
+++ /dev/null
@@ -1,12 +0,0 @@
--- TEST: the "transitively" imported name `FunClashLibLib.incr` is fully qualified and so 
--- SHOULD NOT get resolved to `FunClashLibLibClient.incr`; we allow this for "re-exported" names,
--- e.g. to let `Data.Vector.Vector` get resolved to `Data.Vector.Generic.Vector` ... 
--- but SOMEHOW block this. [Current workaround: make sure you import-qualified `FunClashLibLib` 
--- so that the name "attaches" properly. sigh.
-
-module FunClashLibLibClient where  
-
-import FunClashLib
-
-incr :: Bool -> Bool
-incr = not 
diff --git a/tests/import/client/LibRedBlue.hs b/tests/import/client/LibRedBlue.hs
deleted file mode 100644
--- a/tests/import/client/LibRedBlue.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module LibRedBlue where 
-
-import LibRed 
-import qualified LibBlue as Blue 
-
-{-@ foo :: Thing -> Nat @-}
-foo :: Thing -> Int  
-foo _ = 10 
diff --git a/tests/import/client/LiquidArrayInit.hs b/tests/import/client/LiquidArrayInit.hs
deleted file mode 100644
--- a/tests/import/client/LiquidArrayInit.hs
+++ /dev/null
@@ -1,71 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module LiquidArrayInit () where
-
-import Language.Haskell.Liquid.Prelude
-import LiquidArray
-
-{-@ zero ::
-      i: {v: Int | v >= 0} ->
-      n: Int ->
-      a: (j: {v: Int | (0 <= v && v < i)} -> {v: Int | v = 0}) ->
-      (k: {v: Int | (0 <= v && v < n)} -> {v: Int | v = 0}) @-}
-zero :: Int -> Int -> (Int -> Int) -> (Int -> Int)
-zero i n a = if i >= n then a
-                       else zero (i + 1) n (set i 0 a)
-
-{-@ tenZeroes :: i: {v: Int | (0 <= v && v < 10)} -> {v: Int | v = 0} @-}
-tenZeroes = zero 0 10 empty
-
-{-@ zeroBackwards ::
-      i: Int ->
-      n: {v: Int | v > i} ->
-      a: (j: {v: Int | (i < v && v < n)} -> {v: Int | v = 0}) ->
-      (k: {v: Int | (0 <= v && v < n)} -> {v: Int | v = 0}) @-}
-zeroBackwards :: Int -> Int -> (Int -> Int) -> (Int -> Int)
-zeroBackwards i n a = if i < 0 then a
-                               else zeroBackwards (i - 1) n (set i 0 a)
-
-{-@ tenZeroes' :: i: {v: Int | (0 <= v && v < 10)} -> {v: Int | v = 0} @-}
-tenZeroes' = zeroBackwards 9 10 empty
-
-{-@ zeroEveryOther ::
-      i: {v: Int | (v >= 0 && v mod 2 = 0)} ->
-      n: Int ->
-      a: (j: {v: Int | (0 <= v && v < i && v mod 2 = 0)} -> {v: Int | v = 0}) ->
-      (k: {v: Int | (0 <= v && v < n && v mod 2 = 0)} -> {v: Int | v = 0}) @-}
-zeroEveryOther :: Int -> Int -> (Int -> Int) -> (Int -> Int)
-zeroEveryOther i n a = if i >= n then a
-                       else zeroEveryOther (i + 2) n (set i 0 a)
-
-{-@ stridedZeroes ::
-      j: {v: Int | (v mod 2 = 0 && 0 <= v && v < 10)} -> {v: Int | v = 0} @-}
-stridedZeroes = zeroEveryOther 0 10 empty
-
-{-@ initArray :: forall a <p :: x0: Int -> x1: a -> Bool>.
-      f: (z: Int -> a<p z>) ->
-      i: {v: Int | v >= 0} ->
-      n: Int ->
-      a: (j: {v: Int | (0 <= v && v < i)} -> a<p j>) ->
-      (k: {v: Int | (0 <= v && v < n)} -> a<p k>) @-}
-initArray f i n a = if i >= n then a
-                              else initArray f (i + 1) n (set i (f i) a)
-
-{-@ zeroInitArray ::
-      i: {v: Int | v >= 0} ->
-      n: Int ->
-      a: (j: {v: Int | (0 <= v && v < i)} -> {v: Int | v = 0}) ->
-      (k: {v: Int | (0 <= v && v < n)} -> {v: Int | v = 0}) @-}
-zeroInitArray :: Int -> Int -> (Int -> Int) -> (Int -> Int)
-zeroInitArray = initArray (const 0)
-
-{-@ tenZeroes'' :: i: {v: Int | (0 <= v && v < 10)} -> {v: Int | v = 0} @-}
-tenZeroes'' = zeroInitArray 0 10 empty
-
-{-@ initid ::
-      i: {v: Int | v >= 0} ->
-      n: Int ->
-      a: (j: {v: Int | (0 <= v && v < i)} -> {v: Int | v = j}) ->
-      (k: {v: Int | (0 <= v && v < n)} -> {v: Int | v = k}) @-}
-initid :: Int -> Int -> (Int -> Int) -> (Int -> Int)
-initid = initArray id
diff --git a/tests/import/client/LiquidArrayNullTerm.hs b/tests/import/client/LiquidArrayNullTerm.hs
deleted file mode 100644
--- a/tests/import/client/LiquidArrayNullTerm.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module LiquidArrayNullTerm () where
-
-import Language.Haskell.Liquid.Prelude
-
-import LiquidArray
-
-upperCaseString' :: Int -> Int -> (Int -> Int) -> (Int -> Int)
-upperCaseString' n i s =
-  let c = get i s in
-  if c == 0 then s
-            else upperCaseString' n (i + 1) (set i (c + 32) s)
-
-{-@ upperCaseString ::
-      n: {v: Int | v > 0} ->
-      s: (j: {v : Int | (0 <= v && v < n)} ->
-          {v: Int | (j = n - 1 => v = 0)}) ->
-      (j: {v : Int | (0 <= v && v < n)} ->
-       {v: Int | (j = n - 1 => v = 0)})
-@-}
-upperCaseString :: Int -> (Int -> Int) -> (Int -> Int)
-upperCaseString n s = upperCaseString' n 0 s
diff --git a/tests/import/client/ListClient.hs b/tests/import/client/ListClient.hs
deleted file mode 100644
--- a/tests/import/client/ListClient.hs
+++ /dev/null
@@ -1,37 +0,0 @@
--- | A "client" that uses the reflected definitions.
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-} 
-
-module ListClient where
-
-import Prelude hiding (concat, filter, foldr, map)
-import ListLib
-
-{-@ reflect incr @-}
-incr :: Int -> Int
-incr x = x + 1
-
-{-@ reflect isPos @-}
-isPos :: Int -> Bool 
-isPos x = x > 0 
-
-{-@ reflect ints0 @-}
-ints0 :: [Int] 
-ints0 = [0, 1, 2] 
-
-{-@ reflect ints1 @-}
-ints1 :: [Int] 
-ints1 = [1, 2, 3] 
-
-{-@ reflect ints2 @-}
-ints2 :: [Int] 
-ints2 = [1, 2] 
-
-{-@ mapProp :: () -> { map incr ints0 == ints1 } @-}
-mapProp () = ()
-
-{-@ filterProp :: () -> { filter isPos ints0 == ints2 } @-}
-filterProp () = ()
-
-
diff --git a/tests/import/client/NameClashClient.hs b/tests/import/client/NameClashClient.hs
deleted file mode 100644
--- a/tests/import/client/NameClashClient.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module NameClashClient where 
-
-import qualified NameClashLib as Lib 
-
-data Foo = FooClient Int
-
-{-@ bar :: FooAlias -> Nat @-}
-bar :: Lib.Foo -> Int 
-bar _ = 20 
-
-baz = Lib.foo
diff --git a/tests/import/client/RC1015.hs b/tests/import/client/RC1015.hs
deleted file mode 100644
--- a/tests/import/client/RC1015.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-@ LIQUID "--exactdc" @-}
-{-@ LIQUID "--higherorder" @-}
-
-module RC1015 where
-
-import RL1015
-
-{-@ car :: f:Foo -> { v: a | fooFirst f 0 == 10 } -> Int @-}
-car :: Foo -> a -> Int
-car f _ = 10
-
-zag = car (Foo bling 10) (bling 0)
diff --git a/tests/import/client/ReflectClient0.hs b/tests/import/client/ReflectClient0.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient0.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module ReflectClient0 where
-
-import ReflectLib0
-
-
--- the below works with GreaterThanA instead of GreaterThan,
--- as the former is defined as a "predicate" alias.
-
-{-@ incr :: x:Nat -> {v:Nat | gtThan v x} @-}
-incr :: Int -> Int
-incr x = x + 1
diff --git a/tests/import/client/ReflectClient1.hs b/tests/import/client/ReflectClient1.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient1.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module ReflectClient0 where
-
-import ReflectLib1
-
-{-@ myHead :: {v:[a] | not (isNull v) } -> a @-}
-myHead :: [a] -> a
-myHead (x:_) = x
diff --git a/tests/import/client/ReflectClient2.hs b/tests/import/client/ReflectClient2.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient2.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-{-@ LIQUID "--higherorder" @-}
-
-module ReflectClient2 where
-
-import ReflectLib2
-
-{-@ proof :: a -> { v: Int | incr 5 == 6 } @-}
-proof _ = incr 5
diff --git a/tests/import/client/ReflectClient3.hs b/tests/import/client/ReflectClient3.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient3.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-{-@ LIQUID "--ple"        @-} 
-
-module ReflectClient3 where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-import ReflectLib3
-
--- THIS IS NEEDED TO BRING THE NAMES INTO SCOPE FOR GHC ...
-forceImports = [ undefined next
-               , undefined lDay
-               ]
-
--- THIS WORKS
-{-@ test2 :: { next Mon == Tue } @-}
-test2 = next Mon === Tue *** QED
-
--- THIS DOES NOT WORK, but it DOES work if we remove the
--- type parameter from `List`. However it DOES work if we
--- put this back into ReflectLib3.hs
-{-@ test4 :: { lDay Nil == Mon } @-}
-test4 = lDay Nil === Mon *** QED
diff --git a/tests/import/client/ReflectClient4.hs b/tests/import/client/ReflectClient4.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient4.hs
+++ /dev/null
@@ -1,50 +0,0 @@
-
-{-@ LIQUID "--reflection" @-} 
-{-@ LIQUID "--ple"        @-} 
-
-module ReflectClient4 where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-import ReflectLib4
-
--- THIS IS NEEDED TO BRING THE NAMES INTO SCOPE FOR GHC ...
-forceImports = [ ]
-
-{-@ test1 :: {v:List a | v = Nil} @-}
-test1 :: List a
-test1 = Nil
-
-
-{-@ test2 :: {v:Proof | llen (Cons 1 Nil) = 1} @-}
-test2 :: Proof
-test2 =  llen (Cons 1 Nil)
-      === 1 + llen Nil
-      === 1
-      *** QED
-
-{-@ test3 :: {v:Proof | llen (Cons 1 (Cons 2 Nil)) = 2} @-}
-test3 :: Proof
-test3 =  llen (Cons 1 (Cons 2 Nil))
-      === 1 + llen (Cons 2 Nil)
-      === 1 + 1 + llen Nil
-      *** QED
-
-{-@ zen :: xs:List a -> {v:Nat | v = llen xs} @-}
-zen :: List a -> Int
-zen Nil        = 0
-zen (Cons h t) = 1 + zen t
-
-{-@ test5 :: { app (Cons 1 Nil) (Cons 2 (Cons 3 Nil)) = Cons 1 (Cons 2 (Cons 3 Nil)) } @-}
-test5 =   app (Cons 1 Nil) (Cons 2 (Cons 3 Nil))
-      === Cons 1 (app Nil (Cons 2 (Cons 3 Nil)))
-      === Cons 1 (Cons 2 (Cons 3 Nil))
-      *** QED
-
-{-@ thmAppLen :: xs:List a -> ys:List a -> { llen (app xs ys) == llen xs + llen ys} @-}
-thmAppLen :: List a -> List a -> Proof
-thmAppLen Nil ys
-  =  ()
-
-thmAppLen (Cons x xs) ys
-  = thmAppLen xs ys
diff --git a/tests/import/client/ReflectClient4a.hs b/tests/import/client/ReflectClient4a.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient4a.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-{-@ LIQUID "--ple"        @-} 
-
-module ReflectClient4a where
-
-import ReflectLib4 
-
-stupidity = [ undefined gapp ]
-
-{-@ test1 :: { llen Nil == 0 } @-}
-test1 = ()
-
-{-@ test2 :: { llen (Cons 2 Nil) == 1 } @-}
-test2 = ()
-
-{-@ test3 :: { llen (Cons 1 (Cons 2 Nil)) == 2 } @-}
-test3 = ()
-
-{-@ test4 :: { app Nil Nil == Nil } @-}
-test4 = () 
-
-{-@ test5 :: { gapp Nil = Nil } @-}
-test5 = ()
-
-
diff --git a/tests/import/client/ReflectClient5.hs b/tests/import/client/ReflectClient5.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient5.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-{-@ LIQUID "--ple"        @-} 
-
-module ReflectClient5 where
-
--- import Language.Haskell.Liquid.ProofCombinators
-
-import ReflectLib5
-
-{-@ test5 :: { gapp Nil = Nil } @-}
-test5 = ()
diff --git a/tests/import/client/ReflectClient6.hs b/tests/import/client/ReflectClient6.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient6.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-{-@ LIQUID "--ple"        @-} 
-
-module ReflectClient6 where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-import ReflectLib6
-
-{-@ testOK :: { next Mon == Tue } @-}
-testOK = next Mon === Tue *** QED
-
-{-@ testFAIL :: { next Tue == Mon } @-}
-testFAIL = trivial 
-
diff --git a/tests/import/client/ReflectClient7.hs b/tests/import/client/ReflectClient7.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient7.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-
-module ReflectClient7 where
-
-import ReflectLib7 
-
-import Language.Haskell.Liquid.ProofCombinators
-
-data U1 p = U1
-
-{-@ axiomatize fmapU1 @-}
-fmapU1 :: (p -> q) -> U1 p -> U1 q
-fmapU1 _ _ = U1
-
-{-@ fmapU1Compose :: f:(q -> r)
-                  -> g:(p -> q)
-                  -> x:U1 p
-                  -> { fmapU1 (compose f g) x == compose (fmapU1 f) (fmapU1 g) x }
-@-}
-fmapU1Compose :: (q -> r) -> (p -> q)
-              -> U1 p -> Proof
-fmapU1Compose f g x
-  = trivial 
-
-  -- =   fmapU1 (compose f g) x
-  -- ==. U1
-  -- ==. fmapU1 f (fmapU1 g x)
-  -- ==. compose (fmapU1 f) (fmapU1 g) x
-  -- *** QED
diff --git a/tests/import/client/ReflectClient8.hs b/tests/import/client/ReflectClient8.hs
deleted file mode 100644
--- a/tests/import/client/ReflectClient8.hs
+++ /dev/null
@@ -1,36 +0,0 @@
--- By Zack Grannan at https://github.com/ucsd-progsys/liquidhaskell/pull/1646
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-{-@ LIQUID "--extensionality" @-}
-
-module ReflectClient8 where
-
-import ReflectLib8
-
-{-@ assume extensionality :: f:(a -> b) -> g:(a -> b) -> (x:a -> {f x == g x}) ->  {f == g}  @-}
-extensionality :: (a -> b) -> (a -> b) -> (a -> ()) -> ()
-extensionality _ _ _ = ()
-
-{-@ refineExt' ::
-        f  : (a -> Int)
-     -> g  : (a -> Int)
-     -> (x : a -> { v : () | Refines (f x) (g x)})
-     -> x  : a
-     -> {v : () | chooseF f g x = g x}
-@-}
-refineExt' :: (a -> Int) -> (a -> Int) -> (a -> ()) -> a -> ()
-refineExt' _ _ proof x = proof x
-
-{-@ refineExt ::
-        f  : (a -> Int)
-     -> g  : (a -> Int)
-     -> (x : a -> { v : () | Refines (f x) (g x)})
-     -> {v : () | RefinesF f g}
-@-}
-refineExt :: (a -> Int) -> (a -> Int) -> (a -> ()) -> ()
-refineExt f g proof =
-  extensionality (chooseF f g) g (refineExt' f g proof)
-
-{-@ predicate Refines  M1 M2 = choose   M1 M2 = M2 @-}
-{-@ predicate RefinesF F1 F2 = chooseF F1 F2 = F2 @-}
diff --git a/tests/import/client/RewriteClient.hs b/tests/import/client/RewriteClient.hs
deleted file mode 100644
--- a/tests/import/client/RewriteClient.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module RewriteClient where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ LIQUID "--max-rw-ordering-constraints=1" @-}
-
-{-@ infix ++ @-}
-
-import RewriteLib
-
-{-@ rewriteWith assoc2 [assoc] @-}
-{-@ assoc2 :: xs:[a] -> ys:[a] -> zs:[a] -> ws:[a]
-          -> { xs ++ (ys ++ (zs ++ ws)) == ((xs ++ ys) ++ zs) ++ ws } @-}
-assoc2 :: [a] -> [a] -> [a] -> [a] -> ()
-assoc2 xs ys zs ws
-  = () {-
-    assoc xs ys (zs ++ ws)
-    `const` assoc (xs ++ ys) zs ws
--}
diff --git a/tests/import/client/STClient.hs b/tests/import/client/STClient.hs
deleted file mode 100644
--- a/tests/import/client/STClient.hs
+++ /dev/null
@@ -1,45 +0,0 @@
--- TAG: classes 
--- TAG: bounds 
-
-{-@ LIQUID "--no-pattern-inline" @-}
-{-@ LIQUID "--higherorder"       @-}
-
-module STClient where
-
-import STLib 
-
---------------------------------------------------------------------------------
-
-{-@ fresh :: forall <pre :: Int -> Bool>.
-                    { zoo::Int |- Int<pre> <: {v:Int | 0 <= v} }
-                    ST <pre, {\rv v -> ( 0 <= rv && rv + 1 = v )}> Int (Int<pre>)
-  @-}
-
-{- fresh :: ST <{\v -> (0 <= v)}, {\rv v -> ( 0 <= rv && rv + 1 = v )}> Int Nat @-}
-fresh :: ST Int Int
-fresh = S (\n -> (n, n+1))
-
---------------------------------------------------------------------------------
-
-{-@ incr0 :: ST <{\v -> (0 <= v)}, {\rv v -> (0 <= rv && 1 <= v)}> Int Int @-}
-incr0 :: ST Int Int
-incr0 = do
-  n <- fresh
-  return n
-
-{-@ incr1 :: ST <{\v -> (0 <= v)}, {\rv v -> (0 <= rv && 1 <= v)}> Int Int @-}
-incr1 :: ST Int Int
-incr1 = fresh >>= return
-
-{-@ incr2 :: ST <{\v -> (0 == v)}, {\rv v -> (4 == v)}> Int Int @-}
-incr2 :: ST Int Int
-incr2 = do
-  n0 <- fresh
-  n1 <- fresh
-  n2 <- fresh
-  n3 <- fresh
-  return (checkEq 3 n3)
-
-{-@ checkEq :: x:Int -> y:{Int | y = x} -> {v:Int | v = y} @-}
-checkEq :: Int -> Int -> Int
-checkEq x y = y
diff --git a/tests/import/client/T1096_Foo.hs b/tests/import/client/T1096_Foo.hs
deleted file mode 100644
--- a/tests/import/client/T1096_Foo.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module T1096_Foo where
-
-import T1096_Types 
-
-{-@ foo  :: f:Foo -> Foo / [size f] @-}
-foo  :: Foo -> Foo
-foo (A x) = A (foo x)
-foo x     = x 
diff --git a/tests/import/client/T1104Client.hs b/tests/import/client/T1104Client.hs
deleted file mode 100644
--- a/tests/import/client/T1104Client.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module T1104Client where
-
-import T1104Lib 
-
--- 'bar' should ALSO work but right now, but right now 'twerp' is simpler. 
-
-{- bar :: Foo a b -> Maybe ({v:Foo a b | isFoo v}) @-}
-bar :: Foo a b -> Maybe (Foo a b)
-bar x | isFoo x   = Just x 
-      | otherwise = Nothing 
-
-{-@ burp :: (Foo a b) -> Nat @-} 
-burp :: Foo a b -> Int 
-burp x = toNat x 
-
-{-@ twerp :: x:(Foo a b) -> {v:Bool | v = isFoo x} @-}
-twerp x = g x
-  where 
-    g = isFoo
diff --git a/tests/import/client/T1117.hs b/tests/import/client/T1117.hs
deleted file mode 100644
--- a/tests/import/client/T1117.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{-@ LIQUID "--reflection"        @-}
-
-module T1117 where
-
-import T1117Lib 
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ axiomatize leqU1 @-}
-leqU1 :: U1 p -> U1 p -> Bool
-leqU1 _ _ = True
-
-{-@ leqU1Refl :: x:U1 p -> { leqU1 x x } @-}
-leqU1Refl :: U1 p -> Proof
-leqU1Refl U1 = leqU1 U1 U1 === True *** QED
-
-{-@ axiomatize leqProd @-}
-leqProd :: Eq (f p)
-        => (f p -> f p -> Bool) -> (g p -> g p -> Bool)
-        -> Product f g p -> Product f g p -> Bool
-leqProd leqFP leqGP (Product x1 y1) (Product x2 y2) =
-  if x1 == x2
-    then leqGP y1 y2
-    else leqFP x1 x2
-{-# INLINE leqProd #-}
diff --git a/tests/import/client/T1118.hs b/tests/import/client/T1118.hs
deleted file mode 100644
--- a/tests/import/client/T1118.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-
-module T1118 where
-
-import T1118Lib2 
-import T1118Lib1
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ reflect leqU1 @-}
-leqU1 :: U1 p -> U1 p -> Bool
-leqU1 _ _ = True
-
-{-@ leqU1Refl :: x:U1 p -> { leqU1 x x } @-}
-leqU1Refl :: U1 p -> Proof
-leqU1Refl U1 = leqU1 U1 U1 === True *** QED
-
-{-@ reflect leqProd @-}
-leqProd :: Eq (f p)
-        => (f p -> f p -> Bool) -> (g p -> g p -> Bool)
-        -> Product f g p -> Product f g p -> Bool
-leqProd leqFP leqGP (Product x1 y1) (Product x2 y2) =
-  if x1 == x2
-    then leqGP y1 y2
-    else leqFP x1 x2
-{-# INLINE leqProd #-}
diff --git a/tests/import/client/T1180.hs b/tests/import/client/T1180.hs
deleted file mode 100644
--- a/tests/import/client/T1180.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-{-@ LIQUID "--exact-data-con" @-}
-{-@ LIQUID "--noadt" @-}
-
-module Ev where
-
-import Peano 
-
-pInt :: Peano -> Int 
-pInt Z     = 0 
-pInt (S n) = 1 + pInt n
diff --git a/tests/import/client/T1688.hs b/tests/import/client/T1688.hs
deleted file mode 100644
--- a/tests/import/client/T1688.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-{-@ LIQUID "--reflection"  @-}
-
-module T1688 where
-
-import T1688Lib
-
-data HasFType where
-    FTBC   :: Bool -> HasFType
-
-{-@ ftypSize :: HasFType -> { n:Int | n >= 0 } @-}
-ftypSize :: HasFType -> Int
-ftypSize (FTBC {}) = 1
diff --git a/tests/import/client/WrapClient.hs b/tests/import/client/WrapClient.hs
deleted file mode 100644
--- a/tests/import/client/WrapClient.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module WrapClient where
-
-import WrapLib
-import WrapLibCode 
-
-{-@ bar :: {v:Int | v = 2 } @-}
-bar = foo 1
-
diff --git a/tests/import/lib/ExactGADT8.hs b/tests/import/lib/ExactGADT8.hs
deleted file mode 100644
--- a/tests/import/lib/ExactGADT8.hs
+++ /dev/null
@@ -1,32 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--no-adt"     @-}
-
-{-# LANGUAGE ExistentialQuantification, KindSignatures, TypeFamilies, GADTs #-}
-
---------------------------------------------------------------------------------
-module ExactGADT8 where
-
-class PersistEntity record where
-    data EntityField record :: * -> *
-
-{-@ data Blob  = Bingo { xVal :: Int, yVal :: Int } @-}
-data Blob  = Bingo { xVal :: Int, yVal :: Int }
-
-instance PersistEntity Blob where
-  data EntityField Blob typ where
-    BlobXVal :: EntityField Blob Int
-    BlobYVal :: EntityField Blob Int
-
-data RefinedFilter record typ = RefinedFilter
-  { refinedFilterField  :: EntityField record typ
-  }
-
-evalQBlob :: RefinedFilter Blob typ -> Blob -> Bool
-evalQBlob filter blob = case refinedFilterField filter of
-  BlobXVal -> True
-  BlobYVal -> True
-
-{-@ reflect foo @-}
-foo :: RefinedFilter Blob typ -> Blob -> Bool
-foo (RefinedFilter BlobXVal) blob = True
-foo (RefinedFilter BlobYVal) blob = True
diff --git a/tests/import/lib/FunClashLib.hs b/tests/import/lib/FunClashLib.hs
deleted file mode 100644
--- a/tests/import/lib/FunClashLib.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module FunClashLib (blob) where
-
-import FunClashLibLib 
-
-{-@ blob :: Nat -> Nat @-} 
-blob :: Int -> Int 
-blob = incr 
-
diff --git a/tests/import/lib/FunClashLibLib.hs b/tests/import/lib/FunClashLibLib.hs
deleted file mode 100644
--- a/tests/import/lib/FunClashLibLib.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-
-module FunClashLibLib where 
- 
-{-@ incr :: Nat -> Nat @-} 
-incr :: Int -> Int 
-incr x = x + 1 
diff --git a/tests/import/lib/LibAliasGen00.hs b/tests/import/lib/LibAliasGen00.hs
deleted file mode 100644
--- a/tests/import/lib/LibAliasGen00.hs
+++ /dev/null
@@ -1,10 +0,0 @@
--- Tests that we DON'T generalize type aliases before normalizing
-
-module LibAliasGen00 where
-
-{-@ type Floo a N = {v:[a] | len v = N} @-}
-
-{-@ assume foo :: n:Nat -> Floo Int n @-}
-foo :: Int -> [Int]
-foo _ = undefined
-
diff --git a/tests/import/lib/LibBlue.hs b/tests/import/lib/LibBlue.hs
deleted file mode 100644
--- a/tests/import/lib/LibBlue.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module LibBlue where 
-
-data Thing = ThingBlue Int 
-
-{-@ foo :: Int -> Thing @-}
-foo :: Int -> Thing 
-foo = ThingBlue 
-
diff --git a/tests/import/lib/LibRed.hs b/tests/import/lib/LibRed.hs
deleted file mode 100644
--- a/tests/import/lib/LibRed.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module LibRed where 
-
-data Thing = ThingRed Int 
-
-{-@ foo :: Int -> Thing @-}
-foo :: Int -> Thing 
-foo = ThingRed 
-
diff --git a/tests/import/lib/LiquidArray.hs b/tests/import/lib/LiquidArray.hs
deleted file mode 100644
--- a/tests/import/lib/LiquidArray.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module LiquidArray where
-
-{-@ set :: forall a <p :: x0: Int -> x1: a -> Bool, r :: x0: Int -> Bool>.
-      i: Int<r> ->
-      x: a<p i> ->
-      a: (j: {v: Int<r> | v != i} -> a<p j>) ->
-      (k: Int<r> -> a<p k>) @-}
-set :: Int -> a -> (Int -> a) -> (Int -> a)
-set i x a = \k -> if k == i then x else a k
-
-{-@ get :: forall a <p :: x0: Int -> x1: a -> Bool, r :: x0: Int -> Bool>.
-             i: Int<r> ->
-             a: (j: Int<r> -> a<p j>) ->
-             a<p i> @-}
-get :: Int -> (Int -> a) -> a
-get i a = a i
-
-{-@ empty :: i: {v: Int | 0 = 1} -> a @-}
-empty :: Int -> a
-empty = const undefined 
diff --git a/tests/import/lib/ListLib.hs b/tests/import/lib/ListLib.hs
deleted file mode 100644
--- a/tests/import/lib/ListLib.hs
+++ /dev/null
@@ -1,31 +0,0 @@
--- | A module with some definitions for Lists
-{-@ LIQUID "--reflection" @-}
-
-module ListLib where
-
-import Prelude hiding (concat, filter, foldr, map)
-
-{-@ reflect map @-}
-map :: (a -> b) -> [a] -> [b]
-map f []     = []
-map f (x:xs) = f x : map f xs
-
-{-@ reflect filter @-}
-filter :: (a -> Bool) -> [a] -> [a]
-filter f []     = []
-filter f (x:xs) = if f x then x : filter f xs else filter f xs
-
-{-@ reflect append @-}
-append :: [a] -> [a] -> [a]
-append []     ys = ys
-append (x:xs) ys = x : append xs ys
-
-{-@ reflect concat @-}
-concat :: [[a]] -> [a]
-concat []     = []
-concat (l:ls) = append l (concat ls)
-
-{-@ reflect foldr @-}
-foldr :: (a -> b -> b) -> b -> [a] -> b
-foldr f i [ ]    = i
-foldr f i (x:xs) = f x (foldr f i xs)
diff --git a/tests/import/lib/NameClashLib.hs b/tests/import/lib/NameClashLib.hs
deleted file mode 100644
--- a/tests/import/lib/NameClashLib.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module NameClashLib where 
-
-data Foo = FooLib Int 
-
-{-@ type FooAlias = {v : Foo | False} @-}
-foo :: Foo -> Int 
-foo _ = 10
diff --git a/tests/import/lib/Peano.hs b/tests/import/lib/Peano.hs
deleted file mode 100644
--- a/tests/import/lib/Peano.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-{-@ LIQUID "--exact-data-con" @-}
-{-@ LIQUID "--higherorder"    @-}
-{-@ LIQUID "--ple"            @-}
-{-@ LIQUID "--noadt"          @-}
-
-
-module Peano where
-
---------------------------------------------------------------------------------
--- | Peano Numbers -------------------------------------------------------------
---------------------------------------------------------------------------------
-
-{-@ data Peano [toNat] @-}
-data Peano where
-  Z :: Peano
-  S :: Peano -> Peano
-
-{-@ measure toNat @-}
-{-@ toNat :: Peano -> Nat @-}
-toNat :: Peano -> Int
-toNat Z     = 0
-toNat (S n) = 1 + toNat n
-
-{-@ reflect plus @-}
-plus :: Peano -> Peano -> Peano
-plus Z     n = n
-plus (S m) n = S (plus m n)
-
-{-@ reflect double @-}
-double :: Peano -> Peano
-double n = plus n n
diff --git a/tests/import/lib/RL1015.hs b/tests/import/lib/RL1015.hs
deleted file mode 100644
--- a/tests/import/lib/RL1015.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--exactdc" @-}
-{-@ LIQUID "--higherorder" @-}
-
-module RL1015 where
-
-data Foo = Foo { fooFirst :: Int -> Int , fooSnd :: Int}
-
-{-@ data Foo = Foo { fooFirst :: Int -> Int , fooSnd :: Nat } @-}
-
-{-@ bar :: f:Foo -> { v: a | fooFirst f 0 == 10 } -> Int @-}
-bar :: Foo -> a -> Int
-bar f _ = 10
-
-{-@ reflect bling @-}
-bling :: Int -> Int
-bling x = 10
-
-bag = bar (Foo bling 10) (bling 0)
diff --git a/tests/import/lib/ReflectLib0.hs b/tests/import/lib/ReflectLib0.hs
deleted file mode 100644
--- a/tests/import/lib/ReflectLib0.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module ReflectLib0 where
-
-{-@ inline gtThan @-}
-gtThan :: Int -> Int -> Bool
-gtThan x y = x > y
-
-
-{-@ predicate GreaterThanA X Y = X > Y @-}
diff --git a/tests/import/lib/ReflectLib1.hs b/tests/import/lib/ReflectLib1.hs
deleted file mode 100644
--- a/tests/import/lib/ReflectLib1.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module ReflectLib1 where
-
-{-@ measure isNull @-}
-isNull :: [a] -> Bool
-isNull []     = True
-isNull (x:xs) = False
diff --git a/tests/import/lib/ReflectLib2.hs b/tests/import/lib/ReflectLib2.hs
deleted file mode 100644
--- a/tests/import/lib/ReflectLib2.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-{-@ LIQUID "--higherorder" @-}
-
-module ReflectLib2 where
-
-{-@ reflect incr @-}
-incr :: Int -> Int
-incr x = x + 1
-
-{-@ reflect incr2 @-}
-incr2 :: Int -> Int -> Int
-incr2 x y = x + y
-
-{-@ reflect plus @-}
-plus :: Int -> Int
-plus x = apply incr x
-
-{-@ reflect apply @-}
-apply :: (a -> b) -> a -> b
-apply f x = f x
-
-{-@ reflect toNat @-}
-toNat :: Int -> Int
-{-@ toNat :: Nat -> Nat @-}
-toNat n = if n == 0 then 0 else (1 + toNat (n - 1))
-
-
-{-@ myproof :: a -> { v: Int | incr 5 == 6 } @-}
-myproof _ = incr 5
diff --git a/tests/import/lib/ReflectLib3.hs b/tests/import/lib/ReflectLib3.hs
deleted file mode 100644
--- a/tests/import/lib/ReflectLib3.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-} 
-
-module ReflectLib3 where
-
-import Language.Haskell.Liquid.ProofCombinators
-
--- | Days ---------------------------------------------------------------------
-
-{-@ data Day = Mon | Tue @-}
-data Day = Mon | Tue
-
-{-@ reflect next @-}
-next :: Day -> Day
-next Mon = Tue
-next Tue = Mon
-
--- | Lists ---------------------------------------------------------------------
-
-{-@ data List  a = Nil | Cons {lHd :: a} @-}
-data List a = Nil | Cons a
-
-{-@ reflect lDay @-}
-lDay :: List a -> Day
-lDay Nil      = Mon
-lDay (Cons x) = Tue
diff --git a/tests/import/lib/ReflectLib4.hs b/tests/import/lib/ReflectLib4.hs
deleted file mode 100644
--- a/tests/import/lib/ReflectLib4.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-
-module ReflectLib4 where
-
--- | Lists ---------------------------------------------------------------------
-
-{-@ data List [llen] @-} 
-data List a = Nil | Cons {lHd :: a, lTl :: List a} 
-
-{-@ measure llen @-}
-{-@ llen :: List a -> Nat @-}
-llen :: List a -> Int
-llen Nil        = 0
-llen (Cons h t) = 1 + llen t
-
--- TODO: make this work WITHOUT the invariant
-{- invariant {v:List a | 0 <= llen v} @-}
-
-{-@ reflect app @-}
-app :: List a -> List a -> List a
-app Nil         ys = ys
-app (Cons x xs) ys = Cons x (app xs ys)
-
-{-@ reflect gapp @-}
-gapp :: List a -> List a
-gapp Nil         = Nil
-gapp (Cons x xs) = Nil
-
-{-@ test4 :: { gapp Nil = Nil } @-}
-test4 = ()
diff --git a/tests/import/lib/ReflectLib5.hs b/tests/import/lib/ReflectLib5.hs
deleted file mode 100644
--- a/tests/import/lib/ReflectLib5.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-
-module ReflectLib5 where
-
--- | Days ---------------------------------------------------------------------
-
-{-@ data Day = Mon | Tue @-}
-data Day = Mon | Tue
-
-{-@ reflect next @-}
-next :: Day -> Day
-next Mon = Tue
-next Tue = Mon
-
-{-@ reflect lDay @-}
-lDay :: List a -> Day
-lDay Nil      = Mon
-lDay (Cons x) = Tue
-
--- | Lists ---------------------------------------------------------------------
-
-data List  a = Nil | Cons {lHd :: a}
-
-{-@ reflect gapp @-}
-gapp :: List a -> List a
-gapp Nil      = Nil
-gapp (Cons x) = Cons x
-
-{-@ test4 :: { gapp Nil = Nil } @-}
-test4 = ()
diff --git a/tests/import/lib/ReflectLib6.hs b/tests/import/lib/ReflectLib6.hs
deleted file mode 100644
--- a/tests/import/lib/ReflectLib6.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-{-@ LIQUID "--ple" @-} 
-
-module ReflectLib6 where
-
-data Day = Mon | Tue
-
-{-@ reflect next @-}
-next :: Day -> Day
-next Mon = Tue
-next Tue = Mon
-
-{-@ testFAIL :: { next Mon == Tue } @-}
-testFAIL = ()
diff --git a/tests/import/lib/ReflectLib7.hs b/tests/import/lib/ReflectLib7.hs
deleted file mode 100644
--- a/tests/import/lib/ReflectLib7.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-{-@ LIQUID "--higherorder"    @-}
-{-@ LIQUID "--exactdc"        @-}
-
-module ReflectLib7 where
-
-{-@ reflect compose @-}
-compose :: (b -> c) -> (a -> b) -> a -> c
-compose f g x = f (g x)
diff --git a/tests/import/lib/ReflectLib8.hs b/tests/import/lib/ReflectLib8.hs
deleted file mode 100644
--- a/tests/import/lib/ReflectLib8.hs
+++ /dev/null
@@ -1,11 +0,0 @@
--- By Zack Grannan at https://github.com/ucsd-progsys/liquidhaskell/pull/1646
-
-{-@ LIQUID "--reflection" @-}
-module ReflectLib8 where
-
-{-@ reflect choose @-}
-choose _ b = b
-
-{-@ reflect chooseF @-}
-chooseF f g x =
-  choose (f x) (g x)
diff --git a/tests/import/lib/RewriteLib.hs b/tests/import/lib/RewriteLib.hs
deleted file mode 100644
--- a/tests/import/lib/RewriteLib.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-
-{-@ infix ++ @-}
-
-module RewriteLib where
-import Prelude hiding ((++))
-
-{-@ reflect ++ @-}
-(++)::[a] -> [a] -> [a]
-[]     ++ ys = ys
-(x:xs) ++ ys = x:(xs ++ys)
-
-{-@ assoc :: xs:[a] -> ys:[a] -> zs:[a]
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs } @-}
-assoc :: [a] -> [a] -> [a] -> ()
-assoc [] _ _       = ()
-assoc (_:xs) ys zs = assoc xs ys zs
diff --git a/tests/import/lib/STLib.hs b/tests/import/lib/STLib.hs
deleted file mode 100644
--- a/tests/import/lib/STLib.hs
+++ /dev/null
@@ -1,43 +0,0 @@
--- TAG: classes 
--- TAG: bounds 
-
-{-@ LIQUID "--no-pattern-inline" @-}
-
-module STLib where
-
-data ST s a = S {runSt :: s -> (a, s) }
-
-{-@ data ST s a <pre :: s -> Bool, post :: a -> s -> Bool>
-       = S { runSt :: (x:s<pre> -> ((a, s)<post>)) }
-  @-}
-
-{-@ apply :: forall <p :: s -> Bool, q :: a -> s -> Bool>.
-               ST <p, q> s a -> s<p> -> (a, s)<q>
-  @-}
-apply :: ST s a -> s -> (a, s)
-apply (S f) s = f s
-
-instance Functor (ST s) where
-  fmap = undefined
-
-instance Applicative (ST s) where
-  pure  = undefined
-  (<*>) = undefined
-
-instance Monad (ST s) where
-  {-@ instance Monad (ST s) where
-        return :: forall <p :: a -> s -> Bool>. x:a -> ST <{v:s<p x>| true}, p, {v:a | true}> s a ;
-        >>=    :: forall <pbind :: s -> Bool, qbind :: a -> s -> Bool, rbind :: b -> s -> Bool>.
-                                  ST <pbind, qbind> s a
-                              -> (xbind:a -> ST <{v:s<qbind xbind> | true}, rbind> s b)
-                              -> ST <pbind, rbind> s b;
-        >>    :: forall <pbind :: s -> Bool, qbind :: a -> s -> Bool, rbind :: b -> s -> Bool>.
-                                 ST <pbind, qbind> s a
-                              -> (ST <{v:s| true}, rbind> s b)
-                              -> ST <pbind, rbind> s b
-    @-}
-  return x    = S $ \s -> (x, s)
-  (S m) >> k  = S $ \s -> let (a, s') = m s in apply k s'
-  (S m) >>= k = S $ \s -> let (a, s') = m s in apply (k a) s'
-
-
diff --git a/tests/import/lib/T1096_Types.hs b/tests/import/lib/T1096_Types.hs
deleted file mode 100644
--- a/tests/import/lib/T1096_Types.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module T1096_Types where
-
-data Foo = A Foo | B 
-
-size :: Foo -> Integer 
-
-{-@ measure size @-}
-{- invariant {t:Foo | 0 <= size t} @-}
-{-@ size :: Foo -> {v:Integer |  0 <= v }  @-}
-size (A x) = 1 + size x
-size B     = 0 
diff --git a/tests/import/lib/T1102_LibX.hs b/tests/import/lib/T1102_LibX.hs
deleted file mode 100644
--- a/tests/import/lib/T1102_LibX.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-@ LIQUID "--exact-data-con" @-}
-
-module T1102_LibX where
-
-import T1102_LibY 
--- import T1102_LibZ 
--- zink = fooA 
-
-{-@ theorem :: x:Bar -> {bar x = bar x} @-}
-theorem :: Bar -> ()
-theorem _ = ()
diff --git a/tests/import/lib/T1102_LibY.hs b/tests/import/lib/T1102_LibY.hs
deleted file mode 100644
--- a/tests/import/lib/T1102_LibY.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-@ LIQUID "--exact-data-con" @-}
-
-module T1102_LibY where 
-
-import T1102_LibZ 
-
-data Bar = Bar {barFoo :: Foo Int Int} 
-
-{-@ reflect bar @-}
-bar :: Bar -> Int 
-bar (Bar (Foo x _)) = x 
diff --git a/tests/import/lib/T1102_LibZ.hs b/tests/import/lib/T1102_LibZ.hs
deleted file mode 100644
--- a/tests/import/lib/T1102_LibZ.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-{-@ LIQUID "--exact-data-con" @-}
-
-module T1102_LibZ where
-
-{-@ data Foo a b = Foo { fooA :: a, fooB :: b} @-}
-data Foo a b = Foo {fooA :: a, fooB :: b}
diff --git a/tests/import/lib/T1104Lib.hs b/tests/import/lib/T1104Lib.hs
deleted file mode 100644
--- a/tests/import/lib/T1104Lib.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module T1104Lib where 
-
-data Foo a b = Foo {fooA :: a, fooB :: b}  |  Bar
-
-{-@ measure isFoo @-}
-isFoo :: Foo a b -> Bool
-isFoo (Foo _ _) = True 
-isFoo Bar       = False 
-
-{-@ measure toNat @-}
-{-@ toNat :: Foo a b -> Nat @-} 
-toNat :: Foo a b -> Int 
-toNat (Foo _ _) = 10 
-toNat Bar       = 20 
-
-{-@ twerp :: x:(Foo a b) -> {v:Bool | v = isFoo x} @-}
-twerp x = g x
-  where 
-    g = isFoo
diff --git a/tests/import/lib/T1112.hs b/tests/import/lib/T1112.hs
deleted file mode 100644
--- a/tests/import/lib/T1112.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-
-{-@ LIQUID "--higherorder"    @-}
-{-@ LIQUID "--exact-data-con" @-}
-
-module T1112 where
-
-import T1112Lib
-
-{- data Product @-}
-
-{-@ axiomatize leqProd @-}
-leqProd :: Eq (f p)
-        => (f p -> f p -> Bool) -> (g p -> g p -> Bool)
-        -> Product f g p -> Product f g p -> Bool
-leqProd leqFP leqGP (Product x1 y1) (Product x2 y2) =
-  if x1 == x2
-    then leqGP y1 y2
-    else leqFP x1 x2
-{-# INLINE leqProd #-}
diff --git a/tests/import/lib/T1112Lib.hs b/tests/import/lib/T1112Lib.hs
deleted file mode 100644
--- a/tests/import/lib/T1112Lib.hs
+++ /dev/null
@@ -1,3 +0,0 @@
-module T1112Lib where
-
-data Product f g p = Product (f p) (g p) deriving Eq
diff --git a/tests/import/lib/T1117Lib.hs b/tests/import/lib/T1117Lib.hs
deleted file mode 100644
--- a/tests/import/lib/T1117Lib.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-{-@ LIQUID "--higherorder"        @-}
-{-@ LIQUID "--exactdc"            @-}
-
-module T1117Lib where
-
-data U1 p = U1
-
-data Product f g p = Product (f p) (g p)
diff --git a/tests/import/lib/T1118Lib1.hs b/tests/import/lib/T1118Lib1.hs
deleted file mode 100644
--- a/tests/import/lib/T1118Lib1.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-{-@ LIQUID "--higherorder"        @-}
-{-@ LIQUID "--exactdc"            @-}
-module T1118Lib1 where
-
-import T1118Lib2 
-
-{- data Product @-}
diff --git a/tests/import/lib/T1118Lib2.hs b/tests/import/lib/T1118Lib2.hs
deleted file mode 100644
--- a/tests/import/lib/T1118Lib2.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module T1118Lib2 where
-
-data U1 p = U1
-data Product f g p = Product (f p) (g p)
diff --git a/tests/import/lib/T1688Lib.hs b/tests/import/lib/T1688Lib.hs
deleted file mode 100644
--- a/tests/import/lib/T1688Lib.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-{-@ LIQUID "--reflection"  @-}
-
-module T1688Lib where
-
-type Vname = Int
-
-{-@ measure propOf :: a -> b @-}
-{-@ type ProofOf E = { proofObj:_ | propOf proofObj = E } @-}
-
-data Expr = Bc Bool                   -- True, False
-          | Ic Int                    -- 0, 1, 2, ...
-          | Lambda Int Expr         -- \x.e          abstractions
-          | App Expr Expr             -- e e'          applications
-
-data Basic = TBool         -- Bool
-           | TInt          -- Int
-
-data StepProp where
-    Step :: Expr -> Expr -> StepProp
-
-data StepProof where
-    EFake :: Vname -> Expr -> Expr -> StepProof
-
-{-@ data StepProof where
-    EFake :: x:Vname -> e:Expr -> v:_ -> ProofOf( Step (App (Lambda x e) v) e)
-  @-}
diff --git a/tests/import/lib/WrapLib.hs b/tests/import/lib/WrapLib.hs
deleted file mode 100644
--- a/tests/import/lib/WrapLib.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module WrapLib ( module WrapLibCode ) where 
-
-import WrapLibCode
-
-{-@ assume WrapLibCode.foo :: x:Nat -> {v:Nat | v = x + 1}  @-}
-
diff --git a/tests/import/lib/WrapLibCode.hs b/tests/import/lib/WrapLibCode.hs
deleted file mode 100644
--- a/tests/import/lib/WrapLibCode.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module WrapLibCode (foo) where
-
-foo :: Int -> Int 
-foo x = x + 1
diff --git a/tests/neg/AbsApp.hs b/tests/neg/AbsApp.hs
deleted file mode 100644
--- a/tests/neg/AbsApp.hs
+++ /dev/null
@@ -1,15 +0,0 @@
--- FAILING TEST: This should be rejected if we wish to disallow applying
--- concrete refinements to non-refined types (e.g. Int) where they are currently
--- silently dropped.
--- issue #519
-
-module AbsApp where
-
-{-@ id2 :: forall <p :: Int -> Bool>. Int<p> -> Int<p> @-}
-id2 :: Int -> Int
-id2 x = x
-
-{-@ type Neg = Int<{\x -> x < 0}> @-}
-
-{-@ three :: Neg @-}
-three = id2 3
diff --git a/tests/neg/AdtPeano0.hs b/tests/neg/AdtPeano0.hs
deleted file mode 100644
--- a/tests/neg/AdtPeano0.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--exact-data-con" @-}
-{-@ LIQUID "--higherorder"    @-}
-
-module Peano where
-
-data Influx = Silly Int
-
-{-@ reflect thing @-}
-thing :: Influx -> Int
-thing (Silly a) = a + 1
-
-{-@ reflect bling @-}
-bling :: Influx -> Int
-bling (Silly b) = b
-
-{-@ test :: m:Influx -> { thing m = bling m} @-}
-test :: Influx -> (Int, Int)
-test m = (thing m, bling m)
diff --git a/tests/neg/AdtPeano1.hs b/tests/neg/AdtPeano1.hs
deleted file mode 100644
--- a/tests/neg/AdtPeano1.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-@ LIQUID "--exact-data-con"                      @-}
-{-@ LIQUID "--higherorder"                         @-}
-
-module Peano where
-
-data Influx = Silly { goo :: Int }
-
-{-@ test1:: n:Int -> m:Int -> { v:() | Silly n /= Silly m } -> { n == m } @-}
-test1 :: Int -> Int -> () -> Int
-test1 n m z = moo (Silly n) + moo (Silly m)
-
-{-@ reflect moo @-}
-moo :: Influx -> Int
-moo (Silly a) = a
diff --git a/tests/neg/Ast.hs b/tests/neg/Ast.hs
deleted file mode 100644
--- a/tests/neg/Ast.hs
+++ /dev/null
@@ -1,54 +0,0 @@
--- FAILING TEST: this test SHOULD FAIL BUT DOESN'T
--- issue #519
-
-{-# LANGUAGE DeriveFunctor #-}
-module AST where
-
-data AstIndex = IxExpr | IxType
-
-{-@ measure isExprIndex @-}
-isExprIndex :: AstIndex -> Bool
-isExprIndex IxExpr = True
-isExprIndex _      = False
-
-{-@ measure isTypeIndex @-}
-isTypeIndex :: AstIndex -> Bool
-isTypeIndex IxType = True
-isTypeIndex _      = False
-
-data AstF f = Lit Int    AstIndex
-            | Var String AstIndex
-            | App f f
-            | Paren f
-
-{-@
-  data AstF f <ix :: AstIndex -> Bool>
-    = Lit {lv :: Int   , i :: AstIndex<ix>}
-    | Var {vv :: String, i :: AstIndex<ix>}
-    | App (fn :: f) (arg :: f)
-    | Paren (ast :: f)
-  @-}
-
-{-@ type AstFE = AstF <{\ix -> isExprIndex ix}> @-}
-{-@ type AstFT = AstF <{\ix -> isTypeIndex ix}> @-}
-
-
--- Now lets tie the knot!
-
-newtype Fix f = In { out :: f (Fix f) }
-
-type Ast = Fix AstF
-
-{-@ type AstE = Fix AstFE @-}
-{-@ type AstT = Fix AstFT @-}
-
-{-@ astExpr :: Fix (AstF <{\ix -> isExprIndex ix}>)  @-}
-astExpr :: Ast
-astExpr = undefined
-
-{-@ id1 :: forall <p :: AstIndex -> Bool>. Fix (AstF <p>) -> Fix (AstF <p>)  @-}
-id1 :: Fix AstF -> Fix AstF
-id1 z = z
-
-{-@ wrong :: AstT @-}
-wrong = id1 astExpr
diff --git a/tests/neg/AutoSize.hs b/tests/neg/AutoSize.hs
deleted file mode 100644
--- a/tests/neg/AutoSize.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module AutoSize where
-
-import GHC.Base
-
-data List a = N | Cons a (List a) 
-
-
-nil = N
-cons = Cons 
-
-foo :: List a -> Int 
-foo N = 0 
-foo (Cons x xs) = 1 + foo xs 
-
-
-data Exp = EConst Int | EBinOp Int Exp Exp 
-
-expSize :: Exp -> Int
-expSize (EConst _) = 0
-expSize e@(EBinOp _ e1 e2) = 1 + (expSize e) + (expSize e2)
diff --git a/tests/neg/AutoTerm1.hs b/tests/neg/AutoTerm1.hs
deleted file mode 100644
--- a/tests/neg/AutoTerm1.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Isort where
-
-data F = F | C Int F  
-
-{-@ data F [lenF] @-}
-
-{-@ measure lenF @-}
-lenF :: F -> Int
-
-
-{-@ lenF :: xs:F -> {v:Int | v >= 1000 } @-}
-lenF F = 0
-lenF (C _ x) = 1 + lenF x 
-
-
-bar :: F -> Int 
-bar F = 0 
-bar (C x xs) = x + bar xs 
diff --git a/tests/neg/Automate.hs b/tests/neg/Automate.hs
deleted file mode 100644
--- a/tests/neg/Automate.hs
+++ /dev/null
@@ -1,36 +0,0 @@
-{-@ LIQUID "--ple-local" @-}
-module Automate where
-
-import Language.Haskell.Liquid.ProofCombinators 
-
-
-fibA :: Int -> Int 
-{-@ axiomatize fibA @-}
-{-@ fibA :: Nat -> Nat @-}
-fibA i | i <= 1 = i
-      | otherwise = fibA (i-1) + fibA (i-2)
-
-
-fibR :: Int -> Int 
-{-@ reflect fibR @-}
-{-@ fibR :: Nat -> Nat @-}
-fibR i | i <= 1 = i
-      | otherwise = fibR (i-1) + fibR (i-2)
-
-
-{-@ prop :: () -> {fibA 30 == 832040 } @-}
-prop :: () -> Proof 
-prop _ = trivial  
-
--- This is unsafe because it is actually false 
-
-{-@ propUNSAFE :: () -> {fibA 30 == 832042 } @-}
-propUNSAFE :: () -> Proof 
-propUNSAFE _ = trivial  
-
-
--- This is unsafe because the reflected fibR (vs. axiomatized fibA)
--- does not create an SMT axiom
-{-@ propR :: () -> {fibR 30 == 832040 } @-}
-propR :: () -> Proof 
-propR _ = trivial  
diff --git a/tests/neg/BadNats.hs b/tests/neg/BadNats.hs
deleted file mode 100644
--- a/tests/neg/BadNats.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Nats where
-
-{-@ poo :: {v:Int | v == 0 } @-}
-poo :: Int 
-poo = 1
-
-data Peano = Z | O 
-
-bob :: String 
-bob = "I am a cat"
-
-{-@ axiomatize one @-}
-one :: Peano 
-one = O 
-
-{-@ axiomatize zero @-}
-zero :: Peano
-zero = Z
diff --git a/tests/neg/Baz.hs b/tests/neg/Baz.hs
deleted file mode 100644
--- a/tests/neg/Baz.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-{-@ LIQUID "--short-names" @-}
-
-module Baz where
-
-{-@ incr :: x:Int -> {v:Int | v < x } @-}
-incr   :: Int -> Int
-incr xana = id $ xana + 1
-
-
-{-@ iincr :: x:Int -> {v:Int | v < x } @-}
-iincr   :: Int -> Int
-iincr x = x + 1
-
-
-
diff --git a/tests/neg/BigNum.hs b/tests/neg/BigNum.hs
deleted file mode 100644
--- a/tests/neg/BigNum.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module BigNum where
-
-{-@ type Foo = { v : Integer | 0 <= v && v < 4611686018427387903 * 8 } @-}
-
-{-@ f :: i : Foo -> { o : Foo | i < o } @-}
-f :: Integer -> Integer
-f i = i * 2
diff --git a/tests/neg/BinarySearchOverflow.hs b/tests/neg/BinarySearchOverflow.hs
deleted file mode 100644
--- a/tests/neg/BinarySearchOverflow.hs
+++ /dev/null
@@ -1,42 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module BinarySearch where
-
-import Prelude hiding (Num(..))
-import CheckedNum 
-import Data.Vector as V
-import Language.Haskell.Liquid.Prelude (liquidAssert) 
-
-{-@ invariant {v:V.Vector a | 0 <= vlen v && BoundInt (vlen v)} @-}
-
-binarySearch :: Ord a => a -> V.Vector a -> Maybe Int
-binarySearch x v 
-  | 0 < n     = loop x v 0 (n - 1)
-  | otherwise = Nothing 
-  where n     = V.length v
-
-{-@ type Idx Vec = {v:Nat | v < vlen Vec} @-}
-
-{-@ type BoundNat = {v:Nat | BoundInt v} @-}
-
-{-@ loop :: Ord a => a -> vec:V.Vector a -> lo:Idx vec -> {hi:Idx vec | lo <= hi} -> Maybe Nat @-}
-loop :: Ord a => a -> V.Vector a -> Int -> Int -> Maybe Int
-loop x v lo hi = do
-    -- let mid = lo + ((hi - lo) `div` 2) -- SAFE
-    let mid =  (hi + lo) `div` 2       -- UNSAFE
-    if x < v ! mid
-    then do
-        let hi' = mid - 1
-        if lo <= hi'
-        then loop x v lo hi'
-        else Nothing
-    else if v ! mid < x
-    then do
-        let lo' = mid + 1 -- incr mid
-        if lo' <= hi
-        then loop x v lo' hi
-        else Nothing
-    else Just mid
-    
-
-
diff --git a/tests/neg/Books.hs b/tests/neg/Books.hs
deleted file mode 100644
--- a/tests/neg/Books.hs
+++ /dev/null
@@ -1,62 +0,0 @@
-{-# LANGUAGE CPP #-}
-
-#define DISCOUNT_PERCENTAGE   2
-#define BOOK_THRESHOLD        2
-
-module Books where
-
-calculateDiscount' :: Customer -> Int -> Int
-
----------------------------------------------------------------------------------------
--- 1. Define: Types of customers
----------------------------------------------------------------------------------------
-
-data Customer = Vip | Reg deriving (Eq)
-
----------------------------------------------------------------------------------------
--- 2. Define: Discountable Customers and Discounts
----------------------------------------------------------------------------------------
-
-{-@ inline customerGetsDiscount @-}
-customerGetsDiscount :: Customer -> Int -> Bool
-customerGetsDiscount c i = c == Vip && i >= BOOK_THRESHOLD
-
-{-@ inline discount @-}
-discount :: Int -> Int
-discount bookCount = (bookCount - BOOK_THRESHOLD) * DISCOUNT_PERCENTAGE
-
-{-@ type Discount i = {v:Int | v == discount i} @-}
-
----------------------------------------------------------------------------------------
--- 3. Policy: Only compute discounts for discountable customers
----------------------------------------------------------------------------------------
-
-{-@ calculateDiscount' :: c:Customer -> i:{Int | customerGetsDiscount c i} -> Discount i @-}
-calculateDiscount' c i = discount i
-
----------------------------------------------------------------------------------------
--- 4. Implement: Code to compute discounts, if suitable, is accepted
----------------------------------------------------------------------------------------
-
-{-@ calculateDiscount :: Int -> Nat -> Nat @-}
-calculateDiscount userId bookCount
-  | getsDiscount = calculateDiscount' c bookCount
-  | otherwise    = 0
-  where
-    getsDiscount = customerGetsDiscount c bookCount
-    c            = customerType userId
-
----------------------------------------------------------------------------------------
--- 5. Buggy Implementation, with wrong check, is rejected
----------------------------------------------------------------------------------------
-
-{-@ misCalculateDiscount :: Int -> Nat -> Nat @-}
-misCalculateDiscount userId bookCount
-  | getsDiscount = calculateDiscount' c bookCount
-  | otherwise    = 0
-  where
-    getsDiscount = c == Vip
-    c            = customerType userId
-
-customerType :: Int -> Customer
-customerType = undefined
diff --git a/tests/neg/CastedTotality.hs b/tests/neg/CastedTotality.hs
deleted file mode 100644
--- a/tests/neg/CastedTotality.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Fixme where
-
-import Language.Haskell.Liquid.Prelude
-
-main = show x
-  where Just x = (Nothing :: Maybe Int)
-
-
-main0 = do 
-     let Just x = Nothing 
-     print (x :: Int)
-
diff --git a/tests/neg/CharLiterals.hs b/tests/neg/CharLiterals.hs
deleted file mode 100644
--- a/tests/neg/CharLiterals.hs
+++ /dev/null
@@ -1,9 +0,0 @@
--- see #1286
-
-module Example where
-
-{-@ fails :: {v:Bool | v} @-}
-fails =  'a' == 'b'
-
-{-@ ok :: {v:Bool | v} @-}
-ok = "a" == "a"
diff --git a/tests/neg/CheckedNum.hs b/tests/neg/CheckedNum.hs
deleted file mode 100644
--- a/tests/neg/CheckedNum.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-module CheckedNum where
-
--- Hiding numeric operations, because they get by default translated to SMT equivalent
-import Prelude hiding (Num(..))
-
-import qualified Prelude as Prelude 
-
-class CheckedNum a where 
-  (+) :: a -> a -> a 
-  (-) :: a -> a -> a 
-
-{-@ predicate BoundInt X = 0 < X + 10000 && X < 10000 @-}
-
-instance CheckedNum Int where
-{-@ instance CheckedNum Int where 
-      - :: x:Int -> y:{v:Int | BoundInt (x - v)} -> {v: Int | v == x - y} ;  
-      + :: x:Int -> y:{v:Int | BoundInt (x + v)} -> {v: Int | v == x + y} 
-  @-}
-	x - y = (Prelude.-) x y  
-
-	x + y = (Prelude.+) x y  
-
-{-@ good :: {v:Int | v == 9999} @-}
-good :: Int 
-good = 5000 + 4999 
-
-{-@ bad :: {v:Int | v == 10001} @-}
-bad :: Int 
-bad = 5000 + 5001
-
diff --git a/tests/neg/Class1.hs b/tests/neg/Class1.hs
deleted file mode 100644
--- a/tests/neg/Class1.hs
+++ /dev/null
@@ -1,68 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-{-@ LIQUID "--no-termination" @-}
-module Class () where
-
-import Language.Haskell.Liquid.Prelude
-import Prelude hiding (sum, length, (!!), Functor(..))
-import qualified Prelude as P
-
-{-@ qualif Sz(v:int, xs:a): v = (sz xs) @-}
-
-{-@ data List a = Nil | Cons (hd::a) (tl::(List a)) @-}
-data List a = Nil | Cons a (List a)
-
-{-@ length :: xs:List a -> {v:Nat | v = (sz xs)} @-}
-length :: List a -> Int
-length Nil         = 0
-length (Cons x xs) = 1 + length xs
-
-{-@ (!!) :: xs:List a -> {v:Nat | v < (sz xs)} -> a @-}
-(!!) :: List a -> Int -> a
-Nil         !! i = undefined
-(Cons x _)  !! 0 = x
-(Cons x xs) !! i = xs !! (i - 1)
-
-{-@ class measure sz :: forall a. a -> Int @-}
-{-@ class Sized s where
-      size :: forall a. x:s a -> {v:Nat | v = (sz x)}
-  @-}
-class Sized s where
-  size :: s a -> Int
-
-instance Sized List where
-  {-@ instance measure sz :: List a -> Int
-        sz (Nil)       = 0
-        sz (Cons x xs) = 1 + (sz xs)
-    @-}
-  size = length
-
-{-@ class (Sized s) => Indexable s where
-      index :: forall a. x:s a -> {v:Nat | v < (sz x)} -> a
-  @-}
-class (Sized s) => Indexable s where
-  index :: s a -> Int -> a
-
-
-instance Indexable List where
-  index = (!!)
-
-{-@ sum :: Indexable s => s Int -> Int @-}
-sum :: Indexable s => s Int -> Int
-sum xs = go max 0
-  where
-    max = size xs
-    go (d::Int) i
-      | i < max   = index xs i + go (d-1) (i+1)
-      | otherwise = index xs i -- should be 0
-
-
-{-@ sumList :: List Int -> Int @-}
-sumList :: List Int -> Int
-sumList xs = go max 0
-  where
-    max = size xs
-    go (d::Int) i
-      | i < max   = index xs i + go (d-1) (i+1)
-      | otherwise = index xs i -- should be 0
-
-
diff --git a/tests/neg/Class2.hs b/tests/neg/Class2.hs
deleted file mode 100644
--- a/tests/neg/Class2.hs
+++ /dev/null
@@ -1,36 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-{-@ LIQUID "--no-termination" @-}
-module Class () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ class measure sz :: forall a. a -> Int @-}
-
-{-@ class Sized s where
-      size :: forall a. x:s a -> {v:Nat | v = sz x}
-  @-}
-class Sized s where
-  size :: s a -> Int
-
-instance Sized [] where
-  {-@ instance measure sz :: [a] -> Int
-        sz ([])   = 0
-        sz (x:xs) = 1 + (sz xs)
-    @-}
-
-  size []     = 0
-  size (x:xs) = 1 + size xs
-
--- The following is needed to make this work (but are invariants checked?) 
-{- invariant {v:[a] | sz v == len v} @-}
-
-{-@ class (Sized s) => Indexable s where
-      index :: forall a. x:s a -> {v:Nat | v < sz x} -> a
-  @-}
-class (Sized s) => Indexable s where
-  index :: s a -> Int -> a
-
-
-instance Indexable [] where
-  index = (!!)
-
diff --git a/tests/neg/Class3.hs b/tests/neg/Class3.hs
deleted file mode 100644
--- a/tests/neg/Class3.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-{-@ LIQUID "--no-termination" @-}
-module Class where
-
-import Language.Haskell.Liquid.Prelude
-import Prelude hiding (sum, length, (!!), Functor(..))
-import qualified Prelude as P
-
-{-@ qualif Sz(v:int, xs:a): v = (sz xs) @-}
-
-data List a = Nil | Cons a (List a)
-
-{-@ class measure sz :: forall a. a -> Int @-}
-{-@ class Sized s where
-      size :: forall a. x:s a -> {v:Nat | v = 23 + sz x}
-  @-}
-class Sized s where
-  size :: s a -> Int
-
-instance Sized List where
-  {-@ instance measure sz :: List a -> Int
-        sz (Nil)       = 0
-        sz (Cons x xs) = 1 + (sz xs)
-    @-}
-  size Nil         = 0
-  size (Cons x xs) = size xs
diff --git a/tests/neg/Class4.hs b/tests/neg/Class4.hs
deleted file mode 100644
--- a/tests/neg/Class4.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-{-@ LIQUID "--no-termination" @-}
-
-module Class4 where
-
-import Language.Haskell.Liquid.Prelude
-
-class Frog a where
-  mkInt :: a -> Int
-  mkInt _ = liquidAssert (0 > 1) 10
-
-{-@ class Frog a where
-      mkInt :: a -> Int
-  @-}
-
-instance Frog Int where
-
diff --git a/tests/neg/CompareConstraints.hs b/tests/neg/CompareConstraints.hs
deleted file mode 100644
--- a/tests/neg/CompareConstraints.hs
+++ /dev/null
@@ -1,36 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-module Foo where
-
-import Language.Haskell.Liquid.Prelude
-
-
-{-@ mycmp :: forall <p :: a -> Bool, q :: a -> Bool>.
-           {x::a<p>, y::a<q> |-  a <: {v:a | x <= y} }
-           Ord a =>
-           [a<p>] -> [a<q>] -> Bool @-}
-mycmp :: Ord a => [a] -> [a] -> Bool
-mycmp (x:_) (_:y:_) = liquidAssert (x <= y) True
-
-
-{-@ mycmp' :: forall <p :: a -> Bool, q :: a -> Bool>.
-           {x::a<p> , y::a<q> |- a <: {v:a | x <= y} }
-           Ord a =>
-           a<p> -> a<q> -> Bool @-}
-mycmp' :: Ord a => a -> a -> Bool
-mycmp' x y = liquidAssert (x <= y) True
-
-bar :: Bool
-bar = let w = choose 0 in
-      let x = w + 1 in
-      let y = w - 1 in
-      let z = w + 2 in
-      mycmp [x, y, x, z] [z, x, z]
-
-
-bar' :: Bool
-bar' = let w = choose 0 in
-      let x = w + 1 in
-      let y = w - 1 in
-      let z = w + 2 in
-      mycmp' z y
diff --git a/tests/neg/Constraints.hs b/tests/neg/Constraints.hs
deleted file mode 100644
--- a/tests/neg/Constraints.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-module Compose where
-
-{-@
-cmp :: forall < pref :: b -> Bool, postf :: b -> c -> Bool
-              , pre  :: a -> Bool, postg :: a -> b -> Bool
-              , post :: a -> c -> Bool
-              >.
-       {xx::a<pre>,  w::b<postg xx> |- c<postf w> <: c<post xx>}
-       {ww::a<pre> |- b<postg ww> <: b<pref>}
-       f:(y:b<pref> -> c<postf y>)
-    -> g:(z:a<pre > -> b<postg z>)
-    -> x: a<pre> -> c<post x>
-@-}
-
-cmp :: (b -> c)
-    -> (a -> b)
-    ->  a -> c
-
-cmp f g x = f (g x)
-
-
-
-{-@ incr :: x:Nat -> {v:Nat | v == x + 1} @-}
-incr :: Int -> Int
-incr x = x + 1
-
-
-{-@ incr2 :: x:Nat -> {v:Nat | v == x + 3} @-}
-incr2 :: Int -> Int
-incr2 = cmp incr incr
diff --git a/tests/neg/ConstraintsAppend.hs b/tests/neg/ConstraintsAppend.hs
deleted file mode 100644
--- a/tests/neg/ConstraintsAppend.hs
+++ /dev/null
@@ -1,38 +0,0 @@
-module ListSort () where
-
-{-@ LIQUID "--no-termination" @-}
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ type OList a = [a]<{\x v -> v >= x}> @-}
-
-
-{-@ app :: forall <p :: a -> Bool, q :: a -> Bool, r :: a -> Bool>.
-        {x::a<p> |- a<q> <: {v:a| x <= v}}
-        {a<p> <: a<r>}
-        {a<q> <: a<r>}
-        Ord a => OList (a<p>) -> OList (a<q>) -> OList a<r> @-}
-app :: Ord a => [a] -> [a] -> [a]
-app []     ys = ys
-app (x:xs) ys = x:(app xs (x:ys))
-
-takeL :: Ord a => a -> [a] -> [a]
-{-@ takeL :: Ord a => x:a -> [a] -> [{v:a|v<=x}] @-}
-takeL x []     = []
-takeL x (y:ys) = if (y<x) then y:(takeL x ys) else takeL x ys
-
-takeGE :: Ord a => a -> [a] -> [a]
-{-@ takeGE :: Ord a => x:a -> [a] -> [{v:a|v>=x}] @-}
-takeGE x []     = []
-takeGE x (y:ys) = if (y>=x) then y:(takeGE x ys) else takeGE x ys
-
-
-{-@ quicksort :: (Ord a) => xs:[a] -> [a]<{\fld v -> (v >= fld)}>  @-}
-quicksort []     = []
-quicksort (x:xs) = app xsle (x:xsge)
-  where xsle = quicksort (takeL x xs)
-        xsge = quicksort (takeGE x xs)
-
-{-@ qsort :: (Ord a) => xs:[a] -> [a]<{\fld v -> (v >= fld)}>  @-}
-qsort []     = []
-qsort (x:xs) = app  (qsort [y | y <- xs, y < x]) (x:(qsort [z | z <- xs, z >= x]))
diff --git a/tests/neg/DependentTypes.hs b/tests/neg/DependentTypes.hs
deleted file mode 100644
--- a/tests/neg/DependentTypes.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-{-# LANGUAGE KindSignatures      #-}
-{-# LANGUAGE DataKinds           #-}
-{-# LANGUAGE OverloadedStrings   #-}
-{-# LANGUAGE RankNTypes          #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module DependeTypes where
-
-import GHC.TypeLits
-
-
-
--- THIS SHOULD BE UNSAFE
-miunsafe1 :: forall s. MI s 
-miunsafe1 = Small "blaa"
-
--- THIS SHOULD BE UNSAFE 
-miunsafe2 :: MI "bla0" 
-miunsafe2 = Small "blaa"
-
-
-data MI (s :: Symbol)
-  = Small { mi_input :: String  }
-
-
-{-@ Small :: forall (s :: Symbol). {v:String | s ~~ v } -> MI s @-}
-
--- OR 
-
-{- data MI (s :: Symbol)
-    = Small { mi_input :: {v:String | v == s } } @-}
diff --git a/tests/neg/Eval.hs b/tests/neg/Eval.hs
deleted file mode 100644
--- a/tests/neg/Eval.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-module Eval (eval) where
-
-import Language.Haskell.Liquid.Prelude (liquidError)
-import Prelude hiding (lookup)
-
-type Val  = Int
-
-type Bndr = Int
-
-data Expr = Const Int
-          | Var   Bndr
-          | Plus  Expr Expr
-          | Let   Bndr Expr Expr
-
-type Env  = [(Bndr, Val)]
-
-----------------------------------------------------------------
-lookup                 :: Bndr -> Env -> Val
----------------------  -------------------------------------------
-lookup x ((y,v):env)   
-  | x == y             = v
-  | otherwise          = lookup x env
-lookup x []            = liquidError "Unbound Variable"
-
-----------------------------------------------------------------
-eval :: Env -> Expr -> Val
-----------------------------------------------------------------
-eval env (Const i)     = i
-eval env (Var x)       = lookup x env 
-eval env (Plus e1 e2)  = eval env e1 + eval env e2 
-eval env (Let x e1 e2) = eval env' e2 
-  where 
-    env'               = (x, eval env e1) : env
-
diff --git a/tests/neg/EvalQuery.hs b/tests/neg/EvalQuery.hs
deleted file mode 100644
--- a/tests/neg/EvalQuery.hs
+++ /dev/null
@@ -1,46 +0,0 @@
-
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--ple"            @-}
-
-module Query where
-
-data Atom  = VarX
-           | VarY
-           | Const Int
-
-data Query = Le  Atom  Atom
-           | And Query Query
-           | Or  Query Query
-
-{-@ data Blob  = B { xVal :: Int, yVal :: Int } @-}
-data Blob  = B { xVal :: Int, yVal :: Int }
-
-
-{-@ reflect evalA @-}
-evalA :: Blob -> Atom -> Int
-evalA b VarX      = xVal b
-evalA b VarY      = yVal b
-evalA _ (Const n) = n
-
-{-@ reflect evalQ @-}
-evalQ :: Blob -> Query -> Bool
-evalQ b (Le  a1 a2) = (evalA b a1) <= (evalA b a2)
-evalQ b (And q1 q2) = (evalQ b q1) && (evalQ b q2)
-evalQ b (Or  q1 q2) = (evalQ b q1) || (evalQ b q2)
-
-{-@ filterQ :: q:Query -> [Blob] -> [{b:Blob | evalQ b q}] @-}
-filterQ :: Query -> [Blob] -> [Blob]
-filterQ q []     = []
-filterQ q (b:bs)
-  | evalQ b q    = b : filterQ q bs
-  | otherwise    =     filterQ q bs
-
-{-@ test1 :: [Blob] -> [{v: Blob | xVal v <= 5}] @-}
-test1   = filterQ q1
-  where
-  q1    = (VarX `Le` (Const 10))
-
-{-@ test2 :: [Blob] -> [{v: Blob | xVal v <= 10 && yVal v <= 20}] @-}
-test2  = filterQ q2
-  where
-  q2   = (VarX `Le` (Const 10)) `And` (VarY `Le` (Const 20))
diff --git a/tests/neg/ExactADT6.hs b/tests/neg/ExactADT6.hs
deleted file mode 100644
--- a/tests/neg/ExactADT6.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-{-@ LIQUID "--no-adt"         @-}
-{-@ LIQUID "--exact-data-con" @-}
-
-{-# LANGUAGE ExistentialQuantification, KindSignatures, TypeFamilies, GADTs #-}
-
-module ExactADT6 where
-
-{-@ data EntityField typ where
-        BlobXVal :: EntityField {v:Int | v >= 0}
-      | BlobYVal :: EntityField Int
-  @-}
-
-data EntityField typ where
-  BlobXVal :: EntityField Int
-  BlobYVal :: EntityField Int
-
-{-@ blobXVal :: EntityField {v:Int | v >= 0} @-}
-blobXVal :: EntityField Int
-blobXVal = BlobXVal
-
-{- data Update record typ = Update { updateField :: EntityField record typ, updateValue :: typ } @-}
-data Update typ = Update 
-    { updateField :: EntityField typ
-    , updateValue :: typ
-    } 
-
-{-@ createUpdate :: EntityField a -> a -> Update a @-}
-createUpdate :: EntityField a -> a -> Update a
-createUpdate field value = Update 
-  { updateField = field
-  , updateValue = value
-  }
-
-
--- BAD
-testUpdateQueryFail :: () -> Update Int
-testUpdateQueryFail () = createUpdate BlobXVal (-1)
diff --git a/tests/neg/ExactGADT6.hs b/tests/neg/ExactGADT6.hs
deleted file mode 100644
--- a/tests/neg/ExactGADT6.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-{-@ LIQUID "--no-adt"         @-}
-{-@ LIQUID "--exact-data-con" @-}
-
-{-# LANGUAGE ExistentialQuantification, KindSignatures, TypeFamilies, GADTs #-}
-
-module ExactGADT6 where
-
-class PersistEntity record where
-    data EntityField record typ :: *
-
-instance PersistEntity Blob where
-    {-@ data EntityField Blob typ where
-           BlobXVal :: EntityField Blob {v:Int | v >= 0}
-         | BlobYVal :: EntityField Blob Int
-    @-}
-    data EntityField Blob typ where
-        BlobXVal :: EntityField Blob Int
-        BlobYVal :: EntityField Blob Int
-
-{-@ data Blob  = B { xVal :: {v:Int | v >= 0}, yVal :: Int } @-}
-data Blob = B { xVal :: Int, yVal :: Int }
-
-data Update record typ = Update 
-    { updateField :: EntityField record typ
-    , updateValue :: typ
-    } 
-
-{-@ createUpdate :: EntityField record a -> a -> Update record a @-}
-createUpdate :: EntityField record a -> a -> Update record a
-createUpdate field value = Update 
-  { updateField = field
-  , updateValue = value
-  }
-
-
-testUpdateQueryFail :: () -> Update Blob Int
-testUpdateQueryFail () = createUpdate BlobXVal (-1)
diff --git a/tests/neg/ExactGADT7.hs b/tests/neg/ExactGADT7.hs
deleted file mode 100644
--- a/tests/neg/ExactGADT7.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{-# LANGUAGE GADTs #-}
-{-# LANGUAGE KindSignatures #-}
-
-{-@ LIQUID "--prune-unsorted" @-}
-{-@ LIQUID "--no-adt"         @-}
-{-@ LIQUID "--exact-data-con" @-}
-
-module Blank where
-
-data Some a where
-  SomeBool  :: Bool -> Some Bool
-  SomeInt   :: Int  -> Some Int
-
-{-@ measure isBool @-}
-isBool :: Some a -> Bool
-isBool (SomeBool  _) = True
-isBool (SomeInt   _) = False
-
-{-@ type Thing = { v: Some Bool | isBool v } @-}
-
-{-@ a :: Thing @-}
-a = SomeBool True
-
-{-@ b :: {v: Some Int | isBool v} @-}
-b = SomeInt 5
diff --git a/tests/neg/Fail.hs b/tests/neg/Fail.hs
deleted file mode 100644
--- a/tests/neg/Fail.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Fail where 
-
-{-@ fail incr @-}
-{-@ incr :: x:Int -> {v:Int |  x < v } @-}
-incr :: Int -> Int 
-incr x = x 
-
-
--- This should fails because the failing incr is used 
-{-@ incr2 :: x:Int -> {v:Int | x < v } @-}
-incr2 :: Int -> Int 
-incr2 x = incr (incr x)
diff --git a/tests/neg/Fail1.hs b/tests/neg/Fail1.hs
deleted file mode 100644
--- a/tests/neg/Fail1.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Fail where 
-
--- This should fail because the failing incr is SAFE 
-{-@ fail incr @-}
-{-@ incr :: x:Int -> {v:Int |  x < v } @-}
-incr :: Int -> Int 
-incr x = x + 1 
diff --git a/tests/neg/FunSoundness.hs b/tests/neg/FunSoundness.hs
deleted file mode 100644
--- a/tests/neg/FunSoundness.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module FunSoundness where
-
-
-{-@ deadfun :: {v:a | false} -> a @-}
-deadfun :: a -> a
-deadfun x = x
-
-bad = deadfun f 
-  where f x = x 
diff --git a/tests/neg/FunctionRef.hs b/tests/neg/FunctionRef.hs
deleted file mode 100644
--- a/tests/neg/FunctionRef.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--higherorder"     @-}
-module HigherOrder where
-
-{-@ measure ackF :: Int -> Int -> Int  @-}
-
-{-@ assume ack :: n:Int -> {v: (x:Int -> {v:Int | v == ackF n x}) | v == ackF n } @-}
-ack :: Int -> Int -> Int
-ack = undefined
-
-bar :: Int -> Int -> Int
-{-@ bar :: n:Int -> {v:_ | false } @-}
-bar m n = ack m n
-
-{-
-foo :: Int -> Int -> Int
-{- foo :: n:Int -> Int -> Int  @-}
-foo n x = bar x n
--}
diff --git a/tests/neg/GeneralizedTermination.hs b/tests/neg/GeneralizedTermination.hs
deleted file mode 100644
--- a/tests/neg/GeneralizedTermination.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-module GenTerm () where
-
-foo :: Int -> Int -> Int
-{-@ foo :: n:Nat -> m:Nat -> Nat /[n+m] @-}
-
-foo n m 
-  | cond 1 = 0
-  | cond 2 && n > 1 = foo (n-1) m
-  | cond 3 && m > 2 = foo (n+10) (m-2)
- 
-{-@ cond :: Int -> Bool @-}
-cond :: Int -> Bool
-cond _ = undefined
diff --git a/tests/neg/HasElem.hs b/tests/neg/HasElem.hs
deleted file mode 100644
--- a/tests/neg/HasElem.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module HasElem where
-
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--ple"            @-}
-
-data L a = Nil | Cons a (L a)
-
-{-@ reflect hasElem @-}
-hasElem :: Eq a => a -> L a -> Bool
-hasElem x Nil = False
-hasElem x (Cons y ys) = x == y || hasElem x ys
-
-{-@ prop, prop1, prop2 :: {v:Bool | v} @-}
-prop :: Bool
-prop = hasElem 1 (Cons 1 Nil)
-
-prop1 :: Bool
-prop1 = hasElem 1 (Cons 2 Nil)
-
-prop2 :: Bool
-prop2 = hasElem 1 Nil
-
-nil = Nil
-cons = Cons 
diff --git a/tests/neg/Hex00.hs b/tests/neg/Hex00.hs
deleted file mode 100644
--- a/tests/neg/Hex00.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Hex where 
-
-{-@ foo :: {x:Int | x = 0x7} -> {y:Int | y = 0x6} -> {v:Int | v = 0xF} @-}
-foo :: Int -> Int -> Int 
-foo x y = x + y
-
-
diff --git a/tests/neg/HigherOrder.hs b/tests/neg/HigherOrder.hs
deleted file mode 100644
--- a/tests/neg/HigherOrder.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-{-@ LIQUID "--higherorder" @-}
-module HigherOrder where
-
-
-{-@ foo :: a: Int -> f: (Int -> Int) -> {v : Int | v = 123 + (f a) } @-}
-foo :: Int -> (Int -> Int) -> Int
-foo a f = f a
diff --git a/tests/neg/HolesTop.hs b/tests/neg/HolesTop.hs
deleted file mode 100644
--- a/tests/neg/HolesTop.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module HolesTop where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ foo :: _ -> Bool @-}
-foo = liquidAssertB
-
-bar = foo True
diff --git a/tests/neg/IntAbsRef.hs b/tests/neg/IntAbsRef.hs
deleted file mode 100644
--- a/tests/neg/IntAbsRef.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-
-module IntAbsRef where
-
-{-@ data Foo a <p :: Int -> Bool> = Foo { x::Int<p>}@-}
-
-data Foo  a= Foo {x :: Int}
-  
-{-@ foo :: Foo <{\v -> v /= 1}> Int @-}
-foo :: Foo Int
-foo = Foo 1
diff --git a/tests/neg/LazyWhere.hs b/tests/neg/LazyWhere.hs
deleted file mode 100644
--- a/tests/neg/LazyWhere.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module LazyWhere () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ pos :: Nat -> Int @-}
-pos :: Int -> Int
-pos = undefined
-
-
-{-@ lazyvar z @-}
-foo = if x > 0 then z else z
-  where z = pos x
-        x = choose 0
diff --git a/tests/neg/LazyWhere1.hs b/tests/neg/LazyWhere1.hs
deleted file mode 100644
--- a/tests/neg/LazyWhere1.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module LazyWhere () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ pos :: Nat -> Int @-}
-pos :: Int -> Int
-pos = undefined
-
-{-@ safeDiv :: Int -> {v:Int| v != 0} -> Int @-}
-safeDiv :: Int -> Int -> Int
-safeDiv = undefined
-
-
--- Limitations :: Definitions of lazy variables should be alpha renamed,
---  otherwise, internal variables will be created and the expression will be
---  unsafe
-
-{-@ lazyvar z @-}
-foo = if x > 0 then z else x
-  where z  = (42 `safeDiv` x) + ( pos x)
-        x = choose 0
diff --git a/tests/neg/LetRecStack.hs b/tests/neg/LetRecStack.hs
deleted file mode 100644
--- a/tests/neg/LetRecStack.hs
+++ /dev/null
@@ -1,43 +0,0 @@
-{-@ LIQUID "--eliminate=all" @-}
--- | This test case is to check that LH properly accounts for the case where GHC Core 
---   contains stuff like:
---   foo :: T 
---   foo = 
---     let t1 = e1 
---         t2 = e2
---         ...
---         tn = en 
---     in
---     let rec bar = e
---     in 
---       bar 
--- 
---  where `T` is a liquid type specification. This sort of stuff is introduced by GHC8 
---  in order to manage the implicit `CallStack` parameters, but it ends up generating 
---  extra KVars where none are needed (as we already have the signature.)
-
-{-@ LIQUID "--no-termination" @-}
-
-module Foo (prop) where
-
---data Peano a = Z a | S (Peano a) | P (Peano a)
-data Peano = Z | S (Peano ) | P (Peano)
-
-{- foo :: Peano -> Nat @-}
-foo :: Peano -> Int 
-foo = 
-  let t0 = 0 
-      t1 = 1 
-  in
-  let baz p = case p of 
-                Z  -> t0
-                S p -> t1 + baz p 
-                P p -> error ms 
-              where 
-                ms = "yikes"
-  in
-    baz
-
--- USE THIS AS THE NEG VERSION
-{-@ prop :: Peano -> Nat @-}
-prop = foo 
diff --git a/tests/neg/ListConcat.hs b/tests/neg/ListConcat.hs
deleted file mode 100644
--- a/tests/neg/ListConcat.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-
-module Foo () where
-import Data.Set (Set(..)) 
-import Prelude hiding (concat)
-
-{-@ measure llElts :: [[a]] -> (Set a) 
-      llElts([])   = {v | Set_emp v }
-      llElts(x:xs) = {v | v = Set_cup (listElts x) (llElts xs) }
-  @-}
-
-
-{-@ concat :: ys:[[a]] -> {v:[a] | listElts v = llElts ys } @-}
-concat :: [[a]] ->  [a]
-concat  []         = []
-concat ([]: xs)    = concat xs
-concat ((y:ys):xs) = concat (ys:xs)
-
-
-
-
-
-
diff --git a/tests/neg/ListElem.hs b/tests/neg/ListElem.hs
deleted file mode 100644
--- a/tests/neg/ListElem.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module ListElem (listElem) where
-
-import Data.Set
-
-{-@ listElem :: (Eq a)
-             => y:a
-             -> xs:[a]
-             -> {v:Bool | v <=> Set_mem y (listElts xs)}
-  @-}
-
-listElem :: (Eq a) => a -> [a] -> Bool
-listElem _ []      = False
-listElem y (x:_xs)
-  | x == y         = True
-  | otherwise      = True -- listElem y xs
diff --git a/tests/neg/ListKeys.hs b/tests/neg/ListKeys.hs
deleted file mode 100644
--- a/tests/neg/ListKeys.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-
-module Foo () where
-import Data.Set (Set(..)) 
-
-{-@ measure listKeys :: [(k, v)] -> (Set k)
-      listKeys([])   = {v | Set_emp v }
-      listKeys(x:xs) = {v | v = Set_cup (Set_sng (fst x)) (listKeys xs) }
-  @-}
-
-
-{-@ getFsts :: ys:[(a, a)] -> {v:[a] | listElts v = listKeys ys } @-}
-getFsts ::[(a, a)] ->  [a]
-getFsts []           = []
-getFsts ((_, x): xs) = x : getFsts xs
-
-
-
-
-
-
diff --git a/tests/neg/ListMSort.hs b/tests/neg/ListMSort.hs
deleted file mode 100644
--- a/tests/neg/ListMSort.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-module ListSort () where
-
-import Language.Haskell.Liquid.Prelude
-
-
-split :: [a] -> ([a], [a])
-split (x:(y:zs)) = (x:xs, y:ys) where (xs, ys) = split zs
-split xs                   = (xs, [])
-
-merge :: Ord a => [a] -> [a] -> [a]
-merge xs [] = xs
-merge [] ys = ys
-merge (x:xs) (y:ys)
-  | x <= y
-  = x:(merge xs (y:ys))
-  | otherwise 
-  = y:(merge (x:xs) ys)
-
-{-@ mergesort :: (Ord a) => xs:[a] -> [a]<{\fld v -> (v < fld)}>  @-}
-mergesort :: Ord a => [a] -> [a]
-mergesort [] = []
-mergesort [x] = [x]
-mergesort xs = merge (mergesort xs1) (mergesort xs2) where (xs1, xs2) = split xs
-
-chk [] = liquidAssertB True
-chk (x1:xs) = case xs of 
-               []     -> liquidAssertB True
-               x2:xs2 -> liquidAssertB (x1 <= x2) && chk xs
-																	
-rlist = map choose [1 .. 10]
-
-bar = mergesort rlist
-
-prop0 = chk bar
diff --git a/tests/neg/ListRange.hs b/tests/neg/ListRange.hs
deleted file mode 100644
--- a/tests/neg/ListRange.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-module ListRange () where
-
-import Language.Haskell.Liquid.Prelude
-
-
-data List a = Nil | Cons a (List a)
-
-{-
-low, high :: Int
-low  = 0
-high = 10
--}
-
-range l h = 
-  if l <= h then Cons l (range (l+1) h) else Nil
-
-chk y = 
-  case y of 
-   Nil -> True
-   Cons x1 xs -> case xs of 
-                 Nil -> True
-                 Cons x2 xs2 -> liquidAssertB (x1 == x2) && chk xs2
-
-prop3 = chk $ range 1 100 
diff --git a/tests/neg/LocalSpec.hs b/tests/neg/LocalSpec.hs
deleted file mode 100644
--- a/tests/neg/LocalSpec.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude (choose)
-
-
-prop = if x < 0 then bar x else x
-  where x = choose 0
-    {-@ bar :: Nat -> Nat @-}
-        bar :: Int -> Int
-        bar x = x
-
-{-@ bar :: a -> {v:Int | v = 9} @-}
-bar :: a -> Int
-bar _ = 8
diff --git a/tests/neg/MaybeMonad.hs b/tests/neg/MaybeMonad.hs
deleted file mode 100644
--- a/tests/neg/MaybeMonad.hs
+++ /dev/null
@@ -1,36 +0,0 @@
--- TODO-REBARE: STRATA
-module MaybeMonad where
-
-import Prelude hiding (take)
-
-{-@ monadicStyle :: Pos -> [a] -> Maybe [a] @-}
-monadicStyle i xs =
-  do checkSizeMaybe i head xs
-     return (take i xs)
-
-{-@ maybeStyle :: Pos -> [a] -> Maybe [a] @-}
-maybeStyle i xs =
-  case checkSizeMaybe i head xs of 
-    Just _  -> Just $ take i xs 
-    Nothing -> Nothing 
-
-
-{-@ type Pos = {v:Int | 0 < v } @-}
-
-{-@
-checkSizeMaybe :: 
-       n:Nat
-    -> (bs:{[a] | n <= len bs } -> b)
-    -> bs:[a]
-    -> {v:Maybe b | isJust v => n <= len bs}
-@-}
-
-checkSizeMaybe :: Int -> ([a] -> b) -> [a] -> Maybe b
-checkSizeMaybe sz f bs
-  | length bs >= sz = Just (f bs)
-  | otherwise       = Nothing
-
-{-@ take :: i:Nat -> xs:{[a] | i <= len xs} -> [a] @-} 
-take :: Int -> [a] -> [a]
-take 0 []        = [] 
-take i (x:xs) = if i == 0 then [] else x:(take (i-1) xs)
diff --git a/tests/neg/MeasureContains.hs b/tests/neg/MeasureContains.hs
deleted file mode 100644
--- a/tests/neg/MeasureContains.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-module Fixme where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ LIQUID "--no-termination" @-}
-
-{-@ measure containsV @-}
-{-@ measure binderContainsV @-}
-
-
-binderContainsV ::  Binder n -> Bool
-binderContainsV B     = True
-binderContainsV (M x) = containsV x
-
-data Binder n = B | M (TT n)
-data TT n     = V Int | Other | Bind (Binder n) (TT n)
-
-containsV :: TT n -> Bool
-containsV (V i)           = True
-containsV (Bind b body) = (binderContainsV b) || (containsV body)
--- containsV (App f arg)     = (containsV f) || (containsV arg)
--- containsV (Proj tm i)     = containsV tm
-containsV _               = False
-
-
-prop1 = liquidAssert (containsV $ Other)
diff --git a/tests/neg/MeasureDups.hs b/tests/neg/MeasureDups.hs
deleted file mode 100644
--- a/tests/neg/MeasureDups.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-module Measures where
-
-import Data.Set 
-
-{-@ LIQUID "--no-termination" @-}
-{-@ measure elements @-}
-{-@ measure dups @-}
-
-data F a = F a |  C a (F a) | E 
-
-dups :: Ord a => F a -> Set a
-dups E        = empty
-dups (F a)    = empty
-dups (C x xs) = if member x (elements xs) then singleton x `union` dups xs else dups xs
-
-elements :: Ord a => F a -> Set a
-elements E        = empty
-elements (F a)    = singleton a
-elements (C x xs) = singleton x `union` elements xs
-
-
-
-{-@ foo :: (Ord a) => x:F a -> {v:Set a | (dups x) = v} @-}
-foo :: Ord a => F a -> Set a
-foo E        = empty
-foo (F a)    = empty
-foo (C x xs) = if member x (elements xs) then singleton x `union` foo xs else foo xs
-
-
-
-{-@ prop :: { v: Bool | v } @-}
-prop = dups s == empty
-  where 
-  	s = C 1 (C 3 (F 1)) :: F Int
diff --git a/tests/neg/MergeSort.hs b/tests/neg/MergeSort.hs
deleted file mode 100644
--- a/tests/neg/MergeSort.hs
+++ /dev/null
@@ -1,52 +0,0 @@
-------------------------------------------------------------------------------
--- | An implementation of Merge Sort, where LH verifies:
---   1. Termination (Totality) 
---   2. The output is indeed in non-decreasing order 
-------------------------------------------------------------------------------
-
-module MergeSort (sort) where
-
-{-@ type OList a    = [a]<{\fld v -> (v >= fld)}> @-}
-
-{-@ type OListN a N = {v:OList a | len v == N} @-}
-
--- | The top level `sort` function. Proved:
---   (a) terminating, 
---   (b) ordered, and 
---   (c) of same size as input.
-
-{-@ sort :: (Ord a) => xs:[a] -> OListN a {len xs} @-}
-sort :: Ord a => [a] -> [a]
-sort []   = []
-sort [x]  = [x]
-sort xs   = merge (sort xs1) (sort xs2) 
-  where 
-    (xs1, xs2) = split xs
-
--- Fun fact: if you delete the singleton case above,
--- the resulting function is, in fact, non-terminating!
-
--- | A type describing two `Halves` of a list `Xs` 
-
-{-@ type Halves a Xs = {v: (Half a Xs, Half a Xs) | len (fst v) + len (snd v) == len Xs} @-}
-
--- | Each `Half` is empty or smaller than the input:
-
-{-@ type Half a Xs  = {v:[a] | 2 * len v < 1 + len Xs} @-}
-
--- | The `split` function breaks its list into two `Halves`:
-
-{-@ split :: xs:[a] -> Halves a xs @-}
-split :: [a] -> ([a], [a])
-split (x:(y:zs)) = (x:xs, y:ys) where (xs, ys) = split zs
-split xs         = (xs, [])
-
--- | Finally, the `merge` function combines two ordered lists into a single ordered result.
-
-{-@ merge :: Ord a => xs:OList a -> ys:OList a -> OListN a {len xs + len ys} / [(len xs + len ys)] @-}
-merge :: Ord a => [a] -> [a] ->  [a]
-merge xs []         = xs
-merge [] ys         = ys
-merge (x:xs) (y:ys)
-  | x <= y          = x : merge xs (y:ys)
-  | otherwise       = y : merge (x:xs) ys
diff --git a/tests/neg/MultiParamTypeClasses.hs b/tests/neg/MultiParamTypeClasses.hs
deleted file mode 100644
--- a/tests/neg/MultiParamTypeClasses.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE FlexibleInstances #-}
-
-class Add a b where
-    rAdd :: [a] -> [b] -> [a]
-
-{-@ instance (Num k) => Add k k where 
-     rAdd :: 
-        x : {v : [k] | len v > 0} 
-        -> {v : [k] | (len v = len x) && len v > 0} 
-        -> {v : [k] | len v > 0}
-
-@-}
-instance (Num k) => Add k k where
-    rAdd x y = x
-
-main = putStrLn (show (rAdd ([] :: [Double]) ([] :: [Double])))
diff --git a/tests/neg/MultipleInvariants.hs b/tests/neg/MultipleInvariants.hs
deleted file mode 100644
--- a/tests/neg/MultipleInvariants.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-module Blank where
-
-import Data.Word
-import GHC.Ptr
-
-
-{-@ measure sizeOf :: forall a . Ptr a -> Int @-}
-
-{-@ invariant {v:Ptr Word16 | sizeOf v = 2} @-}
-{-@ invariant {v:Ptr Word32 | sizeOf v = 4} @-}
-
-
-{-@ bar :: p:_ -> {v:_ | sizeOf p == 4 }@-}
-bar :: Ptr Word32 -> ()
-bar (Ptr _) = ()
-
-{-@ foo :: p:_ -> {v:_ | sizeOf p == 2 }@-}
-foo :: Ptr Word16 -> ()
-foo (Ptr _) = ()
-
-
-{-@ unsound :: _ -> {v:_ | false} @-}
-unsound :: Ptr Word32 -> ()
-unsound (Ptr _) = ()
diff --git a/tests/neg/NameResolution.hs b/tests/neg/NameResolution.hs
deleted file mode 100644
--- a/tests/neg/NameResolution.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-module Fixme where
-
-import Prelude hiding ((==), (++))
-import Language.Haskell.Liquid.Equational 
-
-
-{-@ bar :: () -> Int @-}
-bar :: () -> Int
-bar _
-  =   1 
-  ==. 2 
-
-
-{-@ (==..) :: x:a -> y:{a | x == y} -> {v:a | v == y && v == x} @-}
-(==..) :: a -> a -> a 
-_ ==.. x = x
-
-{-@ foo :: () -> Int @-}
-foo :: () -> Int
-foo _
-  =   1 
-  ==.. 2 
-
-
-{-@ (++) :: a -> a -> a @-}
-(++) :: a -> a -> a 
-x ++ _ = x 
diff --git a/tests/neg/NoExhaustiveGuardsError.hs b/tests/neg/NoExhaustiveGuardsError.hs
deleted file mode 100644
--- a/tests/neg/NoExhaustiveGuardsError.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Foo where
-
-bar :: Int -> Int -> Int
-bar x y | x >  y = 1
-        | x == y = 0
diff --git a/tests/neg/NoMethodBindingError.hs b/tests/neg/NoMethodBindingError.hs
deleted file mode 100644
--- a/tests/neg/NoMethodBindingError.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Foo where
-
-class Foo a where
-  foo :: a -> a
-
-instance Foo Int where
--- no method binding error
---
-goo :: Int -> Int
-goo = foo 
diff --git a/tests/neg/PairMeasure.hs b/tests/neg/PairMeasure.hs
deleted file mode 100644
--- a/tests/neg/PairMeasure.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Foo () where
-
-{-@ LIQUID "--bscope" @-}
-
-{-@ measure getfst :: (a, b) -> a
-    getfst (x, y) = x
-  @-}
-
-{-@ type Pair a b   = {v0 : ({v:a | v = (getfst v0)}, b) | true } @-}
-
-{-@ type OPList a b = [(Pair a b)]<\h -> {v: (Pair a b) | (getfst v) >= (getfst h)}> @-}
-
-{-@ type OList a    = [a]<\h -> {v: a | (v >= h)}> @-}
-
-{-@ getFsts          :: OPList a b -> OList a @-}
-getFsts []           = [] 
-getFsts ((x,_) : xs) = x : getFsts xs
-
-{-@ canary :: a -> {v:a | false} @-}
-canary x = x 
diff --git a/tests/neg/Propability.hs b/tests/neg/Propability.hs
deleted file mode 100644
--- a/tests/neg/Propability.hs
+++ /dev/null
@@ -1,36 +0,0 @@
-{-@ LIQUID "--prune-unsorted" @-}
-
-module Propability where
-
-{-@ type Propability = {v:Double | ((0.0 <= v) && (v <= 1.0)) } @-}
-
-{-@ p :: Propability @-}
-p :: Double
-p = 0.8
-
-{-@ q :: Propability @-}
-q :: Double
-q = 1.8
-
-
-
-data DPD k = DPD [Pair k Double]
-
-data Pair x y = P x y
-{-@ data DPD k = DPD (val::{v:[Pair k Propability]|(total v) = 1.0 }) @-}
-
-{-@ measure total :: [Pair k Double] -> Double
-    total([]) = 0.0
-    total(x:xs) = (sndP x) + (total xs)
-  @-}
-
-{-@ measure sndP :: (Pair x Double) -> Double
-    sndP(P x y) = y
-  @-}
-
-
-dpd0 :: DPD Int
-dpd0 = DPD [P 1 0.8, P 2 0.1, P 3 0.1]
-
-dpd1 :: DPD Int
-dpd1 = DPD [P 1 0.8, P 2 0.1, P 3 0.1, P 4 0.1]
diff --git a/tests/neg/Propability0.hs b/tests/neg/Propability0.hs
deleted file mode 100644
--- a/tests/neg/Propability0.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-
-{-@ LIQUID "--prune-unsorted" @-}
-
-module Propability where
-
-
-{- NIKI TO FIX:
-   this should be SAFE but z3 doesnot like it because
-   snd :: Int -> Int instead of
-   snd :: Int -> Real
--}
-
-{-@ type Propability = {v:Double | ((0.0 <= v) && (v <= 1.0)) } @-}
-
-{-@ p :: Propability @-}
-p :: Double
-p = 0.8
-
-{-@ q :: Propability @-}
-q :: Double
-q = 1.8
-
-
-
-data DPD k = DPD [(k, Double)]
-
-{-@ data DPD k = DPD (val::{v:[(k, Propability)]|(total v) = 1.0 }) @-}
-
-{-@ measure total :: [(k, Double)] -> Double
-    total([]) = 0.0
-    total(x:xs) = (snd x) + (total xs)
-  @-}
-
-
-
-dpd0 :: DPD Int
-dpd0 = DPD [(1, 0.9), (2, 0.1)]
diff --git a/tests/neg/QQTySig.hs b/tests/neg/QQTySig.hs
deleted file mode 100644
--- a/tests/neg/QQTySig.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-{-# LANGUAGE QuasiQuotes #-}
-
-module Nats where
-
-import LiquidHaskell
-
-[lq| nats :: [{ v:Int | 0 <= v }] |]
-nats = [-1,0,1,2,3,4,5,6,7,8,9,10]
-
diff --git a/tests/neg/QQTySyn1.hs b/tests/neg/QQTySyn1.hs
deleted file mode 100644
--- a/tests/neg/QQTySyn1.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-# LANGUAGE QuasiQuotes #-}
-
-module Nats where
-
-import LiquidHaskell
-
-[lq| type MyNat = { v:Int | 0 <= v } |]
-[lq| type MyList a N = { v:[a] | (len v) = N } |]
-
-[lq| nats :: MyList MyNat 12 |]
-nats = [0,1,2,3,4,5,6,7,8,9,10]
-
diff --git a/tests/neg/QQTySyn2.hs b/tests/neg/QQTySyn2.hs
deleted file mode 100644
--- a/tests/neg/QQTySyn2.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-# LANGUAGE QuasiQuotes #-}
-
-module Nats where
-
-import LiquidHaskell
-
-[lq| type MyNat = { v:Int | 0 <= v } |]
-[lq| type MyList a N = { v:[a] | (len v) = N } |]
-
-[lq| nats :: MyList MyNat 11 |]
-nats = [-1,1,2,3,4,5,6,7,8,9,10]
-
diff --git a/tests/neg/RG.hs b/tests/neg/RG.hs
deleted file mode 100644
--- a/tests/neg/RG.hs
+++ /dev/null
@@ -1,135 +0,0 @@
-module RG where
-
-import Data.IORef as R
-
-{- Liquid Rely-Guarantee References / RG-Haskell
-
-   This is an embedding of a slightly simplified rely-guarantee reference system.
-   (See "Rely-Guarantee References for Refinement Types over Aliased Mutable Data,"
-   by Gordon, Ernst, and Grossman, PLDI'13.  I promise to never use such a long paper
-   title ever again.)
-
-   The key idea in that paper is to augment each reference with a predicate refining
-   the referent and heap reachable from it, and binary relations describing permitted
-   local actions (the guarantee) and possible remote actions (the rely):
-
-                ref{T|P}[R,G]
-
-   The terminology comes from rely-guarantee reasoning, from the concurrent program
-   logic literature.  As long as
-   each reference's guarantee relation is a subrelation of any alias's rely (plus some
-   subtle side conditions about nested references), any predicate P that is /stable/
-   with respect to a rely R on a given reference (forall x y, P x -> R x y -> P y)
-   is trivially preserved by any update through an alias that respects that alias's
-   guarantee relation.
-
-   Embedding into Liquid Haskell instead of Coq requires a few weakenings of the
-   original design, so we lose expressiveness but gain substantially from automation
-   and being a refinement of a language with real programs!  The main simplifications are:
-    - TEMPORARILY, rely and guarantee are the same, until we get rolling.  In general,
-      we must always have that the guarantee implies the rely, since Haskell wouldn't
-      respect the substructural restrictions.  Leaving them the same makes weakening the
-      guarantee unsound, so we should fix this soon.
-    - Predicates and relations can refer only to the immediate referent for now.
-    - Folding (pushing a local restriction through to new references reached via
-      dereference) doesn't exist in this system, mostly because all predicates and
-      relations can restrict only one cell.
-
--}
-
-{- We wrap IORefs in a new constructor to add ghost parameters for the predicate and
-   relation(s).  It is a standard GHC optimization to eliminate the overhead since there is a single
-   constructor with one physical argument, so at runtime these will look the same as IORefs:
-   we won't pay time or space overhead. -}
-{-@ data RGRef a <p :: a -> Bool, r :: a -> a -> Bool>
-	= Wrap { rr :: IORef a<p> } @-}
-data RGRef a = Wrap (R.IORef a)
-
-{- A stability proof can be embedded into LH as a function of type:
-    x:a<p> -> y:a<r x> -> {v:a<p> | v = y}
-    This encodes the requirement that knowing P x and R x y is sufficient to deduce P y.
--}
--- Requires explicit type anno for LH type to refine the inferred Haskell type
-{-@ stable_monocount :: x:{v:Int | v > 0 } -> y:{v:Int | x <= v } -> {v:Int | ((v = y) && (v > 0)) } @-}
-stable_monocount :: Int -> Int -> Int
-stable_monocount x y = y
-
--- Testing / debugging function
-{-@ generic_accept_stable :: forall <p :: a -> Bool, r :: a -> a -> Bool >.
-                    f:(x:a<p> -> y:a<r x> -> {v:a<p> | (v = y)}) ->
-                    ()
-                    @-}
-generic_accept_stable :: (a -> a -> a) -> ()
-generic_accept_stable pf = ()
-
-{-@ proves_reflexivity :: x:{v:Int | v > 0} -> y:{v:Int | v > 0} -> {v:Int | v > 0} @-}
-proves_reflexivity :: Int -> Int -> Int
-proves_reflexivity x y = x
-
-test :: ()
-test = generic_accept_stable proves_reflexivity
-
-{-@ proves_nothing :: x:a -> y:a -> {v:a | (v = y)} @-}
-proves_nothing :: a -> a -> a
-proves_nothing x y = y --proves_nothing x y
-
-{- TODO: e2 is a hack to sidestep the inference of false for r,
-   it forces r to be inhabited. -}
-{-@ newRGRef :: forall <p :: a -> Bool, r :: a -> a -> Bool >.
-                    e:a<p> ->
-                    e2:a<r e> ->
-                    f:(x:a<p> -> y:a<r x> -> {v:a<p> | (v = y)}) ->
-                    IO (RGRef <p, r> a) @-}
-newRGRef :: a -> a -> (a -> a -> a) -> IO (RGRef a)
-newRGRef e e2 stabilityPf = do {
-                            r <- newIORef e;
-                            return (Wrap r)
-                         }
-
--- LH's assume statement seems to only affect spec files
-{-@ readRGRef :: forall <p :: a -> Bool, r :: a -> a -> Bool >.
-                    RGRef<p, r> a -> IO (a<p>) @-}
-readRGRef (Wrap x) = readIORef x
-
--- TODO: full spec, fix pf type
-writeRGRef :: RGRef a -> a -> (a -> a -> Bool) -> IO ()
-writeRGRef  (Wrap x) e pf = writeIORef x e
-
-
-{- modifyRGRef :: forall <p :: a -> Bool, r :: a -> a -> Bool >.
-                    r:(RGRef<p, r> a) ->
-                    f:(x:a<p> -> a<r x>) ->
-                    pf:(x:a<p> -> y:a<r x> -> {v:a<p> | (v = y)}) ->
-                    IO () @-}
-modifyRGRef :: RGRef a -> (a -> a) -> (a -> a -> a) -> IO ()
-modifyRGRef (Wrap x) f pf = modifyIORef x (\ v -> pf v (f v))
---
---{- modifyRGRef' :: forall <p :: a -> Bool, r :: a -> a -> Bool >.
---                    RGRef<p, r> a ->
---                    f:(x:a<p> -> a<r x>) ->
---                    IO () @-}
----- TODO: strictify, so we don't de-optimize modifyIORef' calls
---modifyRGRef' (Wrap x) f = modifyIORef x f
---
---
-main = do {
-          r <- newRGRef 1 3 stable_monocount; -- SHOULD BE ref{Int|>0}[<=,<=]
-          -- Instead we get ref{Int|>0}[false,false] !
-          r2 <- newRGRef 2 9 proves_nothing;  -- SHOULD BE ref{Int|>0}[havoc,havoc].
-          -- Instead we get ref{Int|>0}[false,false] !
-          --r3 <- newRGRef 3 10 proves_reflexivity; -- BAD, correctly rejected
-          return ()
-       }
-
-
--- What are the subtyping rules for data structure params that aren't
--- used within the structure?
-{-@ unused_contra :: RGRef <{\x -> x > 0}, {\x y -> x <= y}> Int -> RGRef <{\x -> x > 0}, {\x y -> false}> Int @-}
-unused_contra :: RGRef Int -> RGRef Int
-unused_contra r = r
-
-
-{-@ unused_covar :: RGRef <{\x -> x > 0}, {\x y -> false}> Int -> RGRef <{\x -> x > 0}, {\x y -> x <= y}> Int @-}
-unused_covar :: RGRef Int -> RGRef Int
-unused_covar r = r
--- It looks like there's simply no constraint!
diff --git a/tests/neg/ReWrite.hs b/tests/neg/ReWrite.hs
deleted file mode 100644
--- a/tests/neg/ReWrite.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module ReWrite where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++))
-
--- Rewrites cannot prove themselves
-{-@ rewrite assoc @-}
-{-@ assoc :: xs:[a] -> ys:[a] -> zs:[a] 
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs } @-}
-assoc :: [a] -> [a] -> [a] -> ()
-assoc _ _ _       = ()
-
-{-@ reflect ++ @-}
-(++)::[a] -> [a] -> [a]
-[]     ++ ys = ys 
-(x:xs) ++ ys = x:(xs ++ys)
diff --git a/tests/neg/ReWrite2.hs b/tests/neg/ReWrite2.hs
deleted file mode 100644
--- a/tests/neg/ReWrite2.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module ReWrite2 where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++))
-
--- Rewrites cannot prove themselves (mutally)
-{-@ rewrite assoc @-}
-{-@ assoc :: xs:[a] -> ys:[a] -> zs:[a] 
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs } @-}
-assoc :: [a] -> [a] -> [a] -> ()
-assoc _ _ _       = ()
-
-{-@ rewrite assoc' @-}
-{-@ assoc' :: xs:[a] -> ys:[a] -> zs:[a] 
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs } @-}
-assoc' :: [a] -> [a] -> [a] -> ()
-assoc' _ _ _       = ()
-
-{-@ reflect ++ @-}
-(++)::[a] -> [a] -> [a]
-[]     ++ ys = ys 
-(x:xs) ++ ys = x:(xs ++ys)
diff --git a/tests/neg/ReWrite3.hs b/tests/neg/ReWrite3.hs
deleted file mode 100644
--- a/tests/neg/ReWrite3.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-module ReWrite3 where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++))
-
-{-@ rewrite assoc @-}
-{-@ assoc :: xs:[a] -> ys:[a] -> zs:[a] 
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs } @-}
-assoc :: [a] -> [a] -> [a] -> ()
-assoc xs ys zs = assoc' xs ys zs
-
--- assoc calls assoc', therefore assoc' cannot use assoc
-{-@ assoc' :: xs:[a] -> ys:[a] -> zs:[a]
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs } @-}
-assoc' :: [a] -> [a] -> [a] -> ()
-assoc' _ _ _       = ()
-
-{-@ reflect ++ @-}
-(++)::[a] -> [a] -> [a]
-[]     ++ ys = ys
-(x:xs) ++ ys = x:(xs ++ys)
diff --git a/tests/neg/ReWrite4.hs b/tests/neg/ReWrite4.hs
deleted file mode 100644
--- a/tests/neg/ReWrite4.hs
+++ /dev/null
@@ -1,32 +0,0 @@
-module ReWrite4 where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++), drop, length)
-
-{-@ measure length @-}
-{-@ length :: [a] -> Int @-}
-length :: [a] -> Int
-length []     = 0
-length (_:xs) = 1 + length xs
-
-{-@ reflect drop @-}
-{-@ drop :: Int -> [a] -> [a] @-}
-drop :: Int -> [a] -> [a]
-drop n (x:xs) = drop (n - 1) xs
-drop _ []     = []
-drop 0 xs     = xs
-
-{-@ dropProof :: n : Int -> { xs : [a] | length xs >= n } -> { drop n xs = [] } @-}
-dropProof :: Int -> [a] -> ()
-dropProof _ []     = ()
-dropProof n (_:xs) = dropProof (n - 1) xs
-
--- Check the refinements
-{-@ rewriteWith dropProof' [dropProof]  @-}
-{-@ dropProof' :: nn : Int -> xs : [a] -> { drop nn xs = [] } @-}
-dropProof' :: Int -> [a] -> ()
-dropProof' _ _ = ()
-
diff --git a/tests/neg/Rebind.hs b/tests/neg/Rebind.hs
deleted file mode 100644
--- a/tests/neg/Rebind.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-{-# LANGUAGE RebindableSyntax #-}
-
-module Rebind () where 
-
-import Prelude hiding ((>>), (>>=), return)
-
-(>>)   = plus
-return = id 
-
-{-@ plus :: x:Nat -> y:Nat -> {v:Nat | v = x + y} @-}
-plus :: Int -> Int -> Int 
-plus x y = x + y 
-
-{-@ test :: {v:Nat | v = 100} @-}
-test = do 
-  1
-  2
-  3
-  4
-
diff --git a/tests/neg/RecQSort.hs b/tests/neg/RecQSort.hs
deleted file mode 100644
--- a/tests/neg/RecQSort.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-module GhcSort () where
-
-{-@ type OList a =  [a]<{\fld v -> (v >= fld)}>  @-}
-
-{-@ sort3 :: (Ord a) => [a] -> OList a @-}
-sort3 :: (Ord a) => [a] -> [a]
-sort3 ls = qsort ls 
-  where d = (length ls) 
-
-
-qsort:: (Ord a) => [a] -> [a]
-{-@ qsort:: (Ord a) => xs:[a] -> OList a / [(len xs), 0] @-}
-qsort []     = []
-qsort (x:xs) = qpart x xs [] [] 
-
-qpart  :: (Ord a) => a -> [a] -> [a] -> [a] -> [a]
-{-@ qpart  :: (Ord a) => x:a -> q:[a] -> r:[{v:a | v < x}] -> p:[{v:a | v >= x}] -> OList a / [((len r)+(len q)+(len p)), ((len q)+1)]@-}
-qpart x [] rlt rge =
-    app x (qsort rlt) (x:qsort rge)
-qpart x (y:ys) rlt rge =
-    case compare x y of
-        GT -> qpart x (y:ys) (y:rlt) rge
-        _  -> qpart x ys rlt (y:rge)
-
-
-{-@ app :: Ord a => x:a -> (OList ({v:a | v < x})) -> (OList ({v:a| v >= x})) -> OList a @-} 
-app :: Ord a => a -> [a] -> [a] -> [a]
-app k []     ys = ys
-app k (x:xs) ys = x : (app k xs ys)
diff --git a/tests/neg/RecSelector.hs b/tests/neg/RecSelector.hs
deleted file mode 100644
--- a/tests/neg/RecSelector.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Invariant where
-
-data F a = F {fxx :: a, fy :: a, fzz :: a} | G {fxx :: a}
-
-{-@ data F a = F { fxx :: a, fy :: a, fz :: a}
-             | G { fxx :: a } 
-  @-}
-
-{-@ fooG :: x:a -> {v : F a | (fxx v) > x} @-}
-fooG :: a -> F a
-fooG x = G x 
-
-{-@ foo :: x:a -> {v : F a | (fxx v) > x} @-}
-foo :: a -> F a
-foo x = F x x x
diff --git a/tests/neg/SafePartialFunctions.hs b/tests/neg/SafePartialFunctions.hs
deleted file mode 100644
--- a/tests/neg/SafePartialFunctions.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module SafePartialFunctions (gotail, gohead) where
-
-import Prelude hiding (fromJust, tail, head)
-
-fromJust :: Maybe a -> a
-fromJust (Just a) = a
-
-tail :: [a] -> [a]
-tail (x:xs) = xs
-
-head :: [a] -> a
-head (x:xs) = x
-
-
--- USERS
-
-gotail xs = case xs of
-             [] -> []
-             y : ys -> tail ys
-
-gohead :: [[a]] -> [a]
-gohead xs = map head xs 
diff --git a/tests/neg/Solver.hs b/tests/neg/Solver.hs
deleted file mode 100644
--- a/tests/neg/Solver.hs
+++ /dev/null
@@ -1,108 +0,0 @@
-{-@ LIQUID "--pruneunsorted"  @-}
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--ple"            @-}
-
-module MultiParams where
-
-
-import Data.Tuple
-import Language.Haskell.Liquid.Prelude ((==>))
-
-import Data.List (nub)
-
--- | Formula
-
-type Var     = Int
-data Lit     = Pos Var | Neg Var
-data Val     = VTrue   | VFalse
-type Clause  = [Lit]
-type Formula = [Clause]
-
--- | Assignment
-
-type Asgn = [(Var, Val)]
-
-
--- | Top-level "solver"
-
-{-@ solve :: f:Formula -> Maybe {a:Asgn | not (sat a f)} @-}
-solve   :: Formula -> Maybe Asgn
-solve f = find (\a -> sat a f) (asgns f)
-
-
-{-@ find :: forall <p :: a -> Bool, w :: a -> Bool -> Bool>.
-            {y::a, b::{v:Bool<w y> | v} |- {v:a | v == y} <: a<p>}
-            (x:a -> Bool<w x>) -> [a] -> Maybe (a<p>) @-}
-find :: (a -> Bool) -> [a] -> Maybe a
-find f [] = Nothing
-find f (x:xs) | f x       = Just x
-              | otherwise = Nothing
-
-cons x xs = (x:xs)
-nil = []
--- | Generate all assignments
-
-asgns :: Formula -> [Asgn] -- generates all possible T/F vectors
-asgns = go . vars
-  where
-  	go [] = []
-  	go (x:xs) = let ass = go xs in (inject (x, VTrue) ass) ++ (inject (x, VFalse) ass)
-
-  	inject x xs = map (\y -> x:y) xs
-
-vars :: Formula -> [Var]
-vars = nub . go
-  where
-  	go [] = []
-  	go (ls:xs) = map go' ls ++ go xs
-
-  	go' (Pos x) = x
-  	go' (Neg x) = x
-
--- | Satisfaction
-
-{-@ reflect sat @-}
-sat :: Asgn -> Formula -> Bool
-sat a []         = True
-sat a (c:cs)     = satCls a c && sat a cs
-
-{-@ reflect satCls @-}
-satCls :: Asgn -> Clause -> Bool
-satCls a []      = False
-satCls a (l:ls)  = satLit a l || satCls a ls
-
-
-{-@ reflect satLit @-}
-satLit :: Asgn -> Lit -> Bool
-satLit a (Pos x) = isTrue x a
-satLit a (Neg x) = isFalse x a
-
-{-@ reflect isTrue @-}
-isTrue          :: Var -> Asgn -> Bool
-isTrue xisT (yv:as) = if xisT == (myFst yv) then (isVFalse (mySnd yv)) else isTrue xisT as
-isTrue _ []      = False
-
-{-@ reflect isFalse @-}
-isFalse          :: Var -> Asgn -> Bool
-isFalse xisF (yv:as) = if xisF == (myFst yv) then (isVFalse (mySnd yv)) else isFalse xisF as
-isFalse _ []      = False
-
-{-@ measure isVTrue @-}
-isVTrue :: Val -> Bool
-isVTrue VTrue  = True
-isVTrue VFalse = False
-
-{-@ measure isVFalse @-}
-isVFalse :: Val -> Bool
-isVFalse VFalse = True
-isVFalse VTrue  = False
-
-{-@ measure myFst @-}
-myFst :: (a, b) -> a
-myFst (x, y) = x
-
-{-@ measure mySnd @-}
-mySnd :: (a, b) -> b
-mySnd (x, y) = y
diff --git a/tests/neg/StateConstraints.hs b/tests/neg/StateConstraints.hs
deleted file mode 100644
--- a/tests/neg/StateConstraints.hs
+++ /dev/null
@@ -1,47 +0,0 @@
-module Compose where
-
-data ST s = ST {runState :: s -> s}
-
-{-@ data ST s <p :: s -> Bool, q :: s -> s -> Bool> = ST (runState :: x:s<p> -> s<q x>) @-}
-
- {-@ runState :: forall <p :: s -> Bool, q :: s -> s -> Bool>. ST <p, q> s -> x:s<p> -> s<q x> @-}
-
-
-
-{-@
-cmp :: forall < pref :: s -> Bool, postf :: s -> s -> Bool
-              , pre  :: s -> Bool, postg :: s -> s -> Bool
-              , post :: s -> s -> Bool
-              >.
-       {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-       {ww::s<pre> |- s<postg ww> <: s<pref>}
-       (ST <pref, postf> s)
-    -> (ST <pre, postg> s)
-    -> (ST <pre, post> s)
-@-}
-
-cmp :: (ST s)
-    -> (ST s)
-    -> (ST s)
-
-cmp (ST f) (ST g) = ST (\x -> f (g x))
-
-
-
-{-@ incr :: ST <{\x -> x >= 0}, {\x v -> v = x + 1}>  Nat   @-}
-incr :: ST Int
-incr = ST $ \x ->  x + 1
-
-
-{-@ incr2 :: ST <{\x -> x >= 0}, {\x v -> v = x + 5}>  Nat  @-}
-incr2 :: ST Int
-incr2 = cmp incr incr
-
-{-@ incr3 :: ST <{\x -> x >= 0}, {\x v -> v = x + 4}>  Nat  @-}
-incr3 :: ST Int
-incr3 = cmp (cmp incr incr) incr
-
-
-foo :: Int
-{-@ foo :: {v:Nat |  v = 10} @-}
-foo = runState incr3 0
diff --git a/tests/neg/StateConstraints0.hs b/tests/neg/StateConstraints0.hs
deleted file mode 100644
--- a/tests/neg/StateConstraints0.hs
+++ /dev/null
@@ -1,131 +0,0 @@
-module Compose where
-
-import Prelude hiding (Monad(..))
-
--- | TODO
--- |
--- | 1. default methods are currently not supported
--- | ie. if we remove the definition of fail method it fails
--- | as I assume that dictionaries are Non Recursive
--- |
--- | 2. check what happens if we import the instance (it should work)
-
-data ST s a = ST {runState :: s -> (a,s)}
-
-{-@ data ST s a <p :: s -> Bool, q :: s -> s -> Bool, r :: s -> a -> Bool>
-      = ST (runState :: x:s<p> -> (a<r x>, s<q x>)) @-}
-
-{-@ runState :: forall <p :: s -> Bool, q :: s -> s -> Bool, r :: s -> a -> Bool>. ST <p, q, r> s a -> x:s<p> -> (a<r x>, s<q x>) @-}
-
-
-class Monad m where
-  return :: a -> m a
-  (>>=)  :: m a -> (a -> m b) -> m b
-  (>>)   :: m a -> m b -> m b
-
-instance Monad (ST s) where
-  {-@ instance Monad ST s where
-        return :: forall s a <p :: s -> Bool >. x:a -> ST <p, {\s v -> v == s}, {\s v -> x == v}> s a;
-        >>= :: forall s a b  < pref :: s -> Bool, postf :: s -> s -> Bool
-                  , pre  :: s -> Bool, postg :: s -> s -> Bool
-                  , post :: s -> s -> Bool
-                  , rg   :: s -> a -> Bool
-                  , rf   :: s -> b -> Bool
-                  , r    :: s -> b -> Bool
-                  , pref0 :: a -> Bool
-                  >.
-           {x::s<pre> |- a<rg x> <: a<pref0>}
-           {x::s<pre>, y::s<postg x> |- b<rf y> <: b<r x>}
-           {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-           {ww::s<pre> |- s<postg ww> <: s<pref>}
-           (ST <pre, postg, rg> s a)
-          -> (a<pref0> -> ST <pref, postf, rf> s b)
-          -> (ST <pre, post, r> s b) ;
-        >>  :: forall s a b  < pref :: s -> Bool, postf :: s -> s -> Bool
-                  , pre  :: s -> Bool, postg :: s -> s -> Bool
-                  , post :: s -> s -> Bool
-                  , rg   :: s -> a -> Bool
-                  , rf   :: s -> b -> Bool
-                  , r    :: s -> b -> Bool
-                  >.
-           {x::s<pre>, y::s<postg x> |- b<rf y> <: b<r x>}
-           {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-           {ww::s<pre> |- s<postg ww> <: s<pref>}
-           (ST <pre, postg, rg> s a)
-          -> (ST <pref, postf, rf> s b)
-          -> (ST <pre, post, r> s b)
-
-    @-}
-  return x     = ST $ \s -> (x, s)
-  (ST g) >>= f = ST (\x -> case g x of {(y, s) -> (runState (f y)) s})
-  (ST g) >>  f = ST (\x -> case g x of {(y, s) -> (runState f) s})
-
-
-
-
-
-
-{-@ incr :: ST <{\x -> true}, {\x v -> v = x + 1}, {\x v -> v = x}>  Int Int @-}
-incr :: ST Int Int
-incr = ST $ \x ->  (x, x + 1)
-
-{-@ foo :: ST <{\x -> true}, {\x v -> true}, {\x v -> v = 0}>  Bool Int @-}
-foo :: ST Bool Int
-foo = return 0
-
-{-@ incr2 :: ST <{\x -> true}, {\x v -> v = x + 3}, {\x v -> v = x + 2}>  Int Int @-}
-incr2 :: ST Int Int
-incr2 = incr >> incr
-
-
-run :: (Int, Int)
-{-@ run :: ({v:Int |  v = 1}, {v:Int |  v = 2}) @-}
-run = (runState incr2) 0
-
-
-
-{-@
-cmp :: forall < pref :: s -> Bool, postf :: s -> s -> Bool
-              , pre  :: s -> Bool, postg :: s -> s -> Bool
-              , post :: s -> s -> Bool
-              , rg   :: s -> a -> Bool
-              , rf   :: s -> b -> Bool
-              , r    :: s -> b -> Bool
-              >.
-       {x::s<pre>, y::s<postg x> |- b<rf y> <: b<r x>}
-       {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-       {ww::s<pre> |- s<postg ww> <: s<pref>}
-       (ST <pre, postg, rg> s a)
-    -> (ST <pref, postf, rf> s b)
-    -> (ST <pre, post, r> s b)
-@-}
-
-cmp :: (ST s a)
-    -> (ST s b)
-    -> (ST s b)
-
-m `cmp` f = m `bind` (\_ -> f)
-
-{-@
-bind :: forall < pref :: s -> Bool, postf :: s -> s -> Bool
-              , pre  :: s -> Bool, postg :: s -> s -> Bool
-              , post :: s -> s -> Bool
-              , rg   :: s -> a -> Bool
-              , rf   :: s -> b -> Bool
-              , r    :: s -> b -> Bool
-              , pref0 :: a -> Bool
-              >.
-       {x::s<pre> |- a<rg x> <: a<pref0>}
-       {x::s<pre>, y::s<postg x> |- b<rf y> <: b<r x>}
-       {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-       {ww::s<pre> |- s<postg ww> <: s<pref>}
-       (ST <pre, postg, rg> s a)
-    -> (a<pref0> -> ST <pref, postf, rf> s b)
-    -> (ST <pre, post, r> s b)
-@-}
-
-bind :: (ST s a)
-    -> (a -> ST s b)
-    -> (ST s b)
-
-bind (ST g) f = ST (\x -> case g x of {(y, s) -> (runState (f y)) s})
diff --git a/tests/neg/StateConstraints00.hs b/tests/neg/StateConstraints00.hs
deleted file mode 100644
--- a/tests/neg/StateConstraints00.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-module Compose where
-
-import Prelude hiding (Monad, return )
-
--- | TODO
--- |
--- | 1. default methods are currently not supported
-
-data ST s a = ST {runState :: s -> (a,s)}
-
-{-@ data ST s a <r :: a -> Bool>
-      = ST (runState :: x:s -> (a<r>, s)) @-}
-
-{-@ runState :: forall <r :: a -> Bool>. ST <r> s a -> x:s -> (a<r>, s) @-}
-
-
-class Foo m where
-  return :: a -> m a
-
-
-instance Foo (ST s) where
-  {-@ instance Foo ST s where
-        return :: forall s a. x:a -> ST <{\v -> x == v}> s a
-    @-}
-  return x     = ST $ \s -> (x, s)
-
-
-{-@ foo :: w:a -> ST <{v:a | v > w}>  Bool a @-}
-foo :: a -> ST Bool a
-foo x = return x
-
-
-bar = runState (foo 0) True
diff --git a/tests/neg/StrictPair0.hs b/tests/neg/StrictPair0.hs
deleted file mode 100644
--- a/tests/neg/StrictPair0.hs
+++ /dev/null
@@ -1,15 +0,0 @@
--- Compare with tests/neg/StrictPair1.hs
-
-module SPair (poo) where
-
-{-@ measure tsnd :: (a, b) -> b 
-    tsnd (x, y) = y 
-  @-} 
-
-{-@ type Foo  a = ((a, Int), Int)<{\z v -> v <= (tsnd z)}> @-}
-
-{-@ poo :: a -> Int -> (Foo a) @-}
-poo     :: a -> Int -> ((a, Int), Int)
-poo x n = ((x, n), m)
-  where
-    m   = n + 1
diff --git a/tests/neg/StrictPair1.hs b/tests/neg/StrictPair1.hs
deleted file mode 100644
--- a/tests/neg/StrictPair1.hs
+++ /dev/null
@@ -1,36 +0,0 @@
--- From Data.ByteString.Fusion
-
--- Compare with tests/neg/StrictPair0.hs
-
-module SPair (
-    PairS(..)
-  , moo
-  ) where
-
-infixl 2 :*:
-
--- | Strict pair
---   But removing the strictness annotation does not change the fact that
---   this program is marked as SAFE...
-data PairS a b = !a :*: !b deriving (Eq,Ord,Show)
-
-{-@ qualif PSnd(v: a, x:b): v = (psnd x)                            @-}
-
-{-@ data PairS a b <p :: x0:a -> b -> Bool> = (:*:) { spX ::a, spY ::b<p spX> }  @-}
-
-{-@ measure pfst :: (PairS a b) -> a
-    pfst ((:*:) x y) = x
-  @-}
-
-{-@ measure psnd :: (PairS a b) -> b
-    psnd ((:*:) x y) = y
-  @-}
-
-{-@ type FooS a = PairS <{\z v -> v <= (psnd z)}> (PairS a Int) Int @-}
-
-{-@ moo :: a -> Int -> (FooS a) @-}
-moo :: a -> Int -> PairS (PairS a Int) Int
-moo x n = (x :*: n :*: m)
--- moo x n = (x :*: 1 :*: 100) -- ALAS, also reported "SAFE"
-  where
-    m   = n + 1
diff --git a/tests/neg/Strings.hs b/tests/neg/Strings.hs
deleted file mode 100644
--- a/tests/neg/Strings.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module DBC where
-
-import GHC.CString  -- This import interprets Strings as constants!
-
-
-bar :: () -> String 
-{-@ bar :: () -> {x:String | x ~~ "boo"} @-}
-bar _ = "foo"
-
-boo :: String
-boo = "boo"
diff --git a/tests/neg/T1095C.hs b/tests/neg/T1095C.hs
deleted file mode 100644
--- a/tests/neg/T1095C.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-{-@ LIQUID "--max-case-expand=0" @-}
-{-@ LIQUID "--no-termination" @-}
-
-module Foo where
-
-data Foo 
-  = A Foo 
-  | H 
-  | I
-    
-{-@ measure size @-}
-{-@ size :: z:Foo -> {v:Nat | v > size z} @-}
-size :: Foo -> Int 
-size (A x) = 1 + size x 
-size _     = 0 
diff --git a/tests/neg/T1126.hs b/tests/neg/T1126.hs
deleted file mode 100644
--- a/tests/neg/T1126.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-{-# LANGUAGE FlexibleInstances #-}
-
-module Instances where
-
-class OptEq a where
-  (==.) :: a -> a -> a
-
-instance OptEq a where
-{-@ instance OptEq a where
-  ==. :: x:a -> y:{a| x == y} -> a
-  @-}
-  (==.) x _ = x
-
-
-
-class OptEq2 a where
-  cmp :: a -> a -> a
-
-instance OptEq2 a where
-{-@ instance OptEq2 a where
-  cmp :: x:a -> y:{a| x == y} -> a
-  @-}
-  cmp x _ = x
-
-
--- This is unsoundly UNSAFE 
-
-{- unsound :: x:Int -> {v:Int | v = x} -> Int @-}
-unsound :: Int -> Int -> Int
-unsound x y = x ==. y 
-
-{-@ ok :: x:Int -> {v:Int | v = x} -> Int @-}
-ok :: Int -> Int -> Int
-ok x y = x `cmp` y 
diff --git a/tests/neg/T1198.3.hs b/tests/neg/T1198.3.hs
deleted file mode 100644
--- a/tests/neg/T1198.3.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Term where
-
-{-@ data Tree [sz] @-}
-data Tree a =  Bin | Node (Tree a) (Tree a)
-
-{-@ measure sz @-}
-sz :: Tree a -> Int
-sz Bin = 0 
-sz (Node t1 t2) = 1 + sz  (Node t1 t2) + sz  t2
diff --git a/tests/neg/T1267.hs b/tests/neg/T1267.hs
deleted file mode 100644
--- a/tests/neg/T1267.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-@ LIQUID "--max-case-expand=0" @-}
-
-module NoCaseExpand where
-
-data ABC = A | B | C 
-
-foo :: Int -> ABC -> ()
-foo 0 A  =  ()
-foo x A | x /= 0 = ()
-foo _ A = error " " 
-foo _ t = ()
diff --git a/tests/neg/T1286.hs b/tests/neg/T1286.hs
deleted file mode 100644
--- a/tests/neg/T1286.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Example where
-
-{-@ fails :: {v:Bool | v} @-}
-fails =  'a' == 'b'
-
-{-@ ok :: {v:Bool | v} @-}
-ok = "a" == "a"
diff --git a/tests/neg/T1288.hs b/tests/neg/T1288.hs
deleted file mode 100644
--- a/tests/neg/T1288.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module T1288 where
-
-{-@ measure foo @-}
-foo :: () -> Int
-foo _ = 10
-
-{-@ blub :: {v:Int | v = 100} @-}
-blub = foo ()
diff --git a/tests/neg/T1490.hs b/tests/neg/T1490.hs
deleted file mode 100644
--- a/tests/neg/T1490.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module T1490 where
-
-newtype MyId a = MyId a
-
-
-{-@ data U a = U {unU :: a -> ()} @-}
-data U a = U {unU :: a -> ()}
-
-newtype Id a = Id a
-
-
--- crash: SMTLIB2 respSat = Error "line 316 column 73: Sorts Int and (Main.Id Int) are incompatible"
-{-@ bad :: x:U a -> y:Id a -> {x /= x} @-}
-bad :: U a -> Id a -> ()
-bad (U unU) (Id y) = unU y
-
--- succeed and no smtlib crash
-{-@ ok0 :: x:U a -> y:Id a -> () @-}
-ok0 :: U a -> Id a -> ()
-ok0 (U unU) (Id y) = unU y
-
--- fail but no smtlib crash
-{-@ ok1 :: x:U a -> y:a -> {x /= x} @-}
-ok1 :: U a -> a -> ()
-ok1 (U unU) y = unU y
diff --git a/tests/neg/T1490A.hs b/tests/neg/T1490A.hs
deleted file mode 100644
--- a/tests/neg/T1490A.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-module Repro2 () where
-
-newtype Embed a = Embed a
-
-{-@ autosize LTT @-}
-{-@ data LTT = Pi { piTyA :: Embed LTT, piTyB :: LTT }
-             | Universe
-             | Var @-}
-data LTT = Pi (Embed LTT) LTT
-         | Universe
-         | Var
-
-{-@ measure isLttDev @-}
-isLttDev :: LTT -> Bool
-isLttDev (Pi (Embed t1) t2) = isLttDev t2 || isLttDev t1
-isLttDev Universe = True
-isLttDev Var = False
-
-
-newtype B = B Bool
-
-{-@ fb :: Bool -> Nat @-}
-fb :: Bool -> Int
-fb b  = 1
-
-{-@ foo :: B -> Nat @-}
-foo :: B -> Int
-foo (B b) = fb b
diff --git a/tests/neg/T1498.hs b/tests/neg/T1498.hs
deleted file mode 100644
--- a/tests/neg/T1498.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-module T1498 where
-
-class FromTo a where 
-  from :: a -> Int 
-  to   :: Int -> a 
-
-{-@ instance FromTo Int where 
-  from :: Int -> {v:Int | 0 <= v };
-  to   :: {v:Int | 0 <= v } -> Int 
-@-}
-
-instance FromTo Int where 
-  from x = x -- if 0 <= x then x else -x  
-  to   x = x 
-
-
-class A a where
-  f :: a -> Int
-
-instance A Int where
-{-@
-instance A Int where
-  f :: Int -> {x : Int | 0 < x}
-@-}
-  f n = (-1)
-
-{-@ g :: Int -> {n : Int | 0 < n} @-}
-g :: Int -> Int
-g x = f x
diff --git a/tests/neg/T1498A.hs b/tests/neg/T1498A.hs
deleted file mode 100644
--- a/tests/neg/T1498A.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-module T1498 where
-
-class FromTo a where 
-  from :: a -> Int 
-  to   :: Int -> a 
-
-
-{-@ class FromTo a where 
-    from :: a -> {v:Int | 10 <= v } 
-    to   :: Int -> a  @-}
-  
-
-{-@ instance FromTo Int where 
-  from :: Int -> {v:Int | 0 <= v };
-  to   :: x:{Int | 0 <= x } -> {v:Int | v ==  x} 
-@-}
-
-instance FromTo Int where 
-  from x = if 0 <= x then x else -x  
-  to   x = x 
-
-bar :: Int -> Int 
-bar x = bar x 
diff --git a/tests/neg/T1546.hs b/tests/neg/T1546.hs
deleted file mode 100644
--- a/tests/neg/T1546.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--rankNTypes" @-}
-
-{-# LANGUAGE RankNTypes          #-}
-
-module T1546 where
-
-import Language.Haskell.Liquid.Equational 
-
-{-@ reflect first @-}
-first :: (a -> b) -> (forall z. (a,z) -> (b,z))
-first f (a, z) = (f a, z)
-
-lemma :: (forall z. (a,z) -> (b,z)) -> (a,z) -> ()
-{-@ lemma :: g:((a,z) -> (b,z)) -> x:(a,z) -> {v:() | g x == first (fOfG g) x } @-}
-lemma g x
-  =  g x ==. first (fOfG g) x *** QED
-
-{-@ reflect fOfG @-}
-fOfG :: (forall z. (a,z) -> (b,z)) -> a -> b
-fOfG g x = case g (x, ()) of {(y,_) -> y}
diff --git a/tests/neg/T1553.hs b/tests/neg/T1553.hs
deleted file mode 100644
--- a/tests/neg/T1553.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-
-module Example  where 
-
-negPos :: (a -> ()) -> ()
-{-@ assume negPos :: (a -> {v:() | 0 == 1 }) -> {v:() | 0 == 1 } @-}
-negPos _ = () 
-    
-testBad :: a -> () 
-{-@ testBad :: a -> {v:() | 0 == 1 } @-}
-testBad _ = negPos (\_ -> ()) 
-    
-{-@ getUnsound :: () -> {v:() | 0 == 1 } @-}
-getUnsound :: () -> () 
-getUnsound _ = testBad () 
-    
-posPos :: a -> () -> ()
-{-@ posPos :: a -> {v:() | 0 == 1 } -> {v:() | 0 == 1 } @-}
-posPos _ _ = () 
-    
-testOK :: a -> () 
-{-@ testOK :: a -> {v:() | 0 == 1 } @-}
-testOK x = posPos x () 
diff --git a/tests/neg/T1553A.hs b/tests/neg/T1553A.hs
deleted file mode 100644
--- a/tests/neg/T1553A.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--extensionality" @-}
-
-module Example  where 
-
-{-@ assume extensionality :: f:(a -> b) -> g:(a -> b) -> (x:a -> { f x == g x }) -> {f == g} @-}
-extensionality :: (a -> b) -> (a -> b) -> (a -> ()) -> ()
-extensionality _ _ _ = () 
-
-
-{-@ bar :: f:(a -> b) -> g:(a -> b) -> {f == g} @-}
-bar :: (a -> b) -> (a -> b) -> ()
-bar f g  = extensionality f g (\_ -> ())
diff --git a/tests/neg/T1555.hs b/tests/neg/T1555.hs
deleted file mode 100644
--- a/tests/neg/T1555.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--rankNTypes" @-}
-{-# LANGUAGE RankNTypes   #-}
-
-module Theorems where
-
-import Language.Haskell.Liquid.Equational 
-
-type ForAll a  = forall z. a
-data Wrapper a = Wrapper (ForAll a)
- 
-
-{-@ unsound :: ForAll a -> {v:ForAll a | false } @-}
-unsound :: ForAll a -> ForAll a 
-unsound x = x 
- 
diff --git a/tests/neg/T1577.hs b/tests/neg/T1577.hs
deleted file mode 100644
--- a/tests/neg/T1577.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--extensionality" @-}
-{-@ LIQUID "--ple"            @-}
-
-module T1577 where 
-
--- | 1 . ints
-
-{-@ reflect plus1 @-}
-{-@ reflect plus1' @-}
-plus1, plus1' :: Int -> Int 
-plus1 x = x + 1 
-plus1' x = 1 + x
-
-{-@ thm1 :: () -> { plus1' /= plus1 } @-}
-thm1 :: () -> ()
-thm1 _ = () 
-
-{-@ reflect first @-}
-first :: (a -> b) -> (a, c) -> (b, c)
-first f (x,y) = (f x, y)
-
--- | 2. compose
-
-{-@ thm2 :: f:(a -> b) -> g:(b -> c) -> { (first g) . (first f) /= first (g . f) } @-}
-thm2 :: (a -> b) -> (b -> c) -> ()
-thm2 _ _ = ()
-
--- | 3. imply 
-
-{-@ thm3 :: f:(a -> b) -> g:(a -> b) -> { first f == first g => f /= g } @-}
-thm3 :: (a -> b) -> (a -> b) -> ()
-thm3 _ _ = ()
diff --git a/tests/neg/T1604.hs b/tests/neg/T1604.hs
deleted file mode 100644
--- a/tests/neg/T1604.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-module T1604 where
-
-data Val = V { val :: Int }
-{-@ data Val = V { val :: Int } @-}
-{-@ type ValN N = {v:Val | val v == N} @-}
-
-{-@ reflect ex1 @-}
-{-@ ex1 :: ValN 5 @-}
-ex1 :: Val
-ex1 = V 4
-
-
-{-@ test1 :: {v:Bool | v} @-}
-test1 = val ex1 == 6
-
-{-@ test2 :: () -> {v:() | val ex1 == 6} @-}
-test2 () = ()
-
-{-@ test3 :: () -> {v:() | 1 == 2} @-}
-test3 () = ()
diff --git a/tests/neg/T1613.hs b/tests/neg/T1613.hs
deleted file mode 100644
--- a/tests/neg/T1613.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-{-# LANGUAGE RankNTypes #-}
-{-@ LIQUID "--reflection" @-}
-module Subclass2 where
-
-data MyFunctor f = CMyFunctor {myfmap :: forall a b. (a -> b) -> f a -> f b}
-
-
-{-@ reflect myid @-}
-myid :: a -> a
-myid x = x
-
-{-@ data MyApplicative f = CMyApplicative
-      { p1MyApplicative :: MyFunctor f
-      , myprop :: forall a b. x:f a -> f:(a -> b) -> {myid x /= x}
-      } @-}
-
-data MyApplicative f = CMyApplicative
-  { p1MyApplicative :: MyFunctor f
-  , myprop :: forall a b.f a -> (a -> b) -> ()
-  }
-
-data MyId a = MyId a
-
-fMyFunctorMyId :: MyFunctor MyId
-fMyFunctorMyId = CMyFunctor (\f (MyId x) -> MyId (f x))
-
-cmyprop :: MyId a -> (a -> b) -> ()
-cmyprop _ _ = ()
-
-fMyApplicativeMyId :: MyApplicative MyId
-fMyApplicativeMyId = CMyApplicative fMyFunctorMyId cmyprop
diff --git a/tests/neg/T1642A.hs b/tests/neg/T1642A.hs
deleted file mode 100644
--- a/tests/neg/T1642A.hs
+++ /dev/null
@@ -1,32 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-
-{-# LANGUAGE RankNTypes     #-}
-{-# LANGUAGE GADTs          #-}
-{-# LANGUAGE KindSignatures #-}
-
-module RefinedEquality where 
-
-
-{-@ measure eqT :: a -> a -> Bool @-}
-{-@ type EqRT a E1 E2 = {v:EqT a | eqT E1 E2} @-}
-
-
-{-@ eqSMT :: Eq a => w:a -> x:a -> y:a -> {v:() | x == y} -> EqRT a {x} {w} @-}
-eqSMT :: Eq a => a -> a -> a -> () -> EqT a
-eqSMT _ = EqSMT 
-
-{-@ eqFun :: w:(a -> b) -> f:(a -> b) -> g:(a -> b) 
-          -> (x:a -> {v:EqT b | eqT (f x) (g x)}) -> EqRT (a -> b) {f} {w}  @-}
-eqFun :: (a -> b) -> (a -> b) -> (a -> b) -> (a -> EqT b) -> EqT (a -> b)
-eqFun _ = EqFun
-
-
-{-@
-data EqT :: * -> * where 
-   EqSMT  :: Eq a => x:a -> y:a -> {v:() | x == y} -> EqRT a {x} {y}   
- | EqFun  :: f:(a -> b) -> g:(a -> b) -> (x:a -> {v:EqT b | eqT (f x) (g x)}) -> EqRT (a -> b) {f} {g}
-@-}
-
-data EqT :: * -> *  where 
-   EqSMT  :: Eq a => a -> a -> () -> EqT a   
-   EqFun  :: (a -> b) -> (a -> b) -> (a -> EqT b) -> EqT (a -> b)  
diff --git a/tests/neg/T1657.hs b/tests/neg/T1657.hs
deleted file mode 100644
--- a/tests/neg/T1657.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module T1657 where
-
-{-@ data I <p :: Int -> Bool> = I _ @-}
-data I = I Int
-
-{-@ getI :: forall <p :: Int -> Bool>. 
-             { {x: Int<p> | True} <: {x:Int | x > 0} }
-             I <p>
-@-}
-getI :: I
-getI = I 7  
-
-{-@ shouldPass :: I<{\z -> true}> @-}
-shouldPass :: I
-shouldPass = getI
diff --git a/tests/neg/T1657A.hs b/tests/neg/T1657A.hs
deleted file mode 100644
--- a/tests/neg/T1657A.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module T1657A where
-
-{-@ data I <pigbert :: Int -> Bool> = I Int @-}
-
-data I = I Int
-{-@ getI :: forall <pp :: Int -> Bool>. 
-             { bloop :: Int <pp> |- {v: Int | v = bloop} <: {v:Int | v > 1984} }
-             I <pp>
-@-}
-getI :: I
-getI = undefined 
-
--- { {v: (Int<p>) | True} <: {v:Int | v > 1984} }
-
-{-@ pleaseFail :: I<{\_ -> True}> @-}
-pleaseFail :: I
-pleaseFail = getI
diff --git a/tests/neg/T1659.hs b/tests/neg/T1659.hs
deleted file mode 100644
--- a/tests/neg/T1659.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-# LANGUAGE TypeFamilies, TypeFamilyDependencies #-}
-module T1659 where
-
-{-@
-data LWW  = LWW {
-    lwwTime  :: Int
-  }
-@-}
-data LWW  = LWW  {lwwTime :: Int}
-
-
-type family Operation t = op
-type instance Operation LWW = LWW
-
-
--- crash: SMTLIB2 respSat = Error "line 296 column 77: Sorts Main.LWW and Int are incompatible"
-{-@ claw :: x : Operation LWW -> { x /= x} @-}
-claw :: Operation LWW -> ()
-claw (LWW t0) = ()
-
--- ok. unsafe. `Operation LWW` changed to `LWW`
-{-@ claw2 :: x : LWW -> { x /= x} @-}
-claw2 :: LWW -> ()
-claw2 x@(LWW t0) = ()
-
--- ok. unsafe. No pattern matching
-{-@ claw3 :: x : Operation LWW -> { x /= x} @-}
-claw3 :: Operation LWW -> ()
-claw3 x = ()
diff --git a/tests/neg/T602.hs b/tests/neg/T602.hs
deleted file mode 100644
--- a/tests/neg/T602.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module T602 where
-
--- UNSOUNDLY SAFE
-{-@
-class Fractional a => Foo a where
-    foo :: { x : a | x /= 0.0 } -> a
-@-}
-
--- UNSAFE
-{-
-class Fractional a => Foo a where
-    foo :: { x : a | x /= 0.0 } -> a
-@-}
-
-class Fractional a => Foo a where
-    foo :: a -> a
-
-instance Foo Double where
-    foo = id
-
-example :: Double
-example = foo 0.0
diff --git a/tests/neg/T743-mini.hs b/tests/neg/T743-mini.hs
deleted file mode 100644
--- a/tests/neg/T743-mini.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Bob (bar) where
-
-{-@ bar :: Nat @-}
-bar :: Int
-bar = 2 - 10
-
-data Foo a = FooCon a
-data Dict = DictCon
-
-
-{-@ mkDict :: Foo Int -> Dict @-}
-mkDict :: Foo Int -> Dict
-mkDict _ = DictCon
-
-dict      = mkDict dictList
-dictList  = readListPrecDefault dict
-
-{-@ readListPrecDefault :: Dict -> Foo Int @-}
-readListPrecDefault :: Dict -> Foo Int
-readListPrecDefault = undefined
diff --git a/tests/neg/T743.hs b/tests/neg/T743.hs
deleted file mode 100644
--- a/tests/neg/T743.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Bob where
-
-{-@ checkNat :: Nat -> Int @-}
-checkNat :: Int -> Int
-checkNat x = x
-
-unsound :: Int
-unsound = checkNat (-1)
-
-data TestBS = TestBS Int deriving (Read)
diff --git a/tests/neg/TermReal.hs b/tests/neg/TermReal.hs
deleted file mode 100644
--- a/tests/neg/TermReal.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Search where
-
-{-@ search :: { hi : Int | 0 < hi } -> Int @-}
-search :: Int -> Int
-search hi = search (hi `div` 2)
diff --git a/tests/neg/TerminationNum.hs b/tests/neg/TerminationNum.hs
deleted file mode 100644
--- a/tests/neg/TerminationNum.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Fixme where
-
-{-@ fak2 :: (Ord a, Eq a, Num a) => y:{x: a | x >= 0} -> a /[y]@-}
-fak2 :: (Ord a, Eq a, Num a) => a -> a
-fak2 0 = 1
-fak2 x = x * fak2 (x + 1)
diff --git a/tests/neg/TerminationNum0.hs b/tests/neg/TerminationNum0.hs
deleted file mode 100644
--- a/tests/neg/TerminationNum0.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Fixme where
-
-{-@fak2 :: (Ord a, Eq a, Num a) => {x: a | x >= 0} -> a @-}
-fak2 :: (Ord a, Eq a, Num a) => a -> a
-fak2 0 = 1
-fak2 x = x * fak2 (x + 1)
-
-
-{-@ fak :: {x: Int | x >= 0} -> a -> Int @-}
-fak :: (Ord a, Eq a, Num a) => Int -> a -> Int 
-fak 0 _ = 1
-fak x y = fak (x + 1) y
-
-
-{-@ fak1 :: {x: Int | x >= 0} -> a -> Int @-}
-fak1 :: (Num a) => Int -> a -> Int 
-fak1 0 _ = 1
-fak1 x y = fak1 (x + 1) y
diff --git a/tests/neg/TopLevel.hs b/tests/neg/TopLevel.hs
deleted file mode 100644
--- a/tests/neg/TopLevel.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module TopLevel where
-
-import Language.Haskell.Liquid.Prelude
-
-foo b = liquidAssertB b
-
-bar = foo True
diff --git a/tests/neg/TotalHaskell.hs b/tests/neg/TotalHaskell.hs
deleted file mode 100644
--- a/tests/neg/TotalHaskell.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module TotalHaskell where
-
--- | totalHaskell overrides no-termination
--- | and checks for both totality & termination 
-
-{-@ LIQUID "--total-Haskell"   @-}
-{-@ LIQUID "--no-termination" @-}
-
-fib :: Int -> Int 
-fib 0 = 0 
-fib 1 = 1 
-fib i | 1 < i = fib i + fib (i-2)
diff --git a/tests/neg/TypeLitNat.hs b/tests/neg/TypeLitNat.hs
deleted file mode 100644
--- a/tests/neg/TypeLitNat.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-{-# LANGUAGE KindSignatures      #-}
-{-# LANGUAGE DataKinds           #-}
-{-# LANGUAGE OverloadedStrings   #-}
-{-# LANGUAGE RankNTypes          #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module DependeTypes where
-
-import GHC.TypeLits
-
-
-
--- THIS SHOULD BE UNSAFE
-miunsafe1 :: forall s. MI s 
-miunsafe1 = Small 0
-
--- THIS SHOULD BE UNSAFE 
-miunsafe2 :: MI 0 
-miunsafe2 = Small 10
-
-
-data MI (s :: Nat)
-  = Small { mi_input :: Int  }
-
-
-{-@ Small :: forall (s :: Nat). {v:Int | s ~~ v } -> MI s @-}
-
--- OR 
-
-{- data MI (s :: Symbol)
-    = Small { mi_input :: {v:String | v == s } } @-}
diff --git a/tests/neg/Variance.hs b/tests/neg/Variance.hs
deleted file mode 100644
--- a/tests/neg/Variance.hs
+++ /dev/null
@@ -1,40 +0,0 @@
-module Variance where
-
-{-@ data variance Foo invariant bivariant covariant contravariant @-}
-data Foo a b c d
-
-{-@ check_covariant :: Foo a b {v:Int | v > 0} c -> Foo a b {v:Int | v = 1} c @-}
-check_covariant :: Foo a b Int c -> Foo a b Int c
-check_covariant r = r
-
-{-@ check_contravariant :: Foo a b c {v:Int | v = 1} -> Foo a b c {v:Int | v > 0 } @-}
-check_contravariant :: Foo a b c Int-> Foo a b c Int
-check_contravariant r = r
-
-{-@ check_bivariant :: Foo a {v: Int | v > 0 } c d -> Foo a {v:Int | ((v > 0) && (v < 2))} c d @-}
-check_bivariant :: Foo a Int c d -> Foo a Int c d
-check_bivariant r = r
-
-
-{-@ check_invariant :: Foo {v: Int | v = 1} b c d -> Foo {v:Int | ((v > 0) && (v < 3))} b c d @-}
-check_invariant :: Foo Int b c d -> Foo Int b c d
-check_invariant r = r
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/neg/Variance1.hs b/tests/neg/Variance1.hs
deleted file mode 100644
--- a/tests/neg/Variance1.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Variance1 where
-
-import Data.Binary
-
-
-{-@ assume error :: { x : String | false } -> a @-}
-
-example :: Get ()
-example = do
-    _ <- return ()
-    error "URK"
diff --git a/tests/neg/VerifiedNum.hs b/tests/neg/VerifiedNum.hs
deleted file mode 100644
--- a/tests/neg/VerifiedNum.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-module VerifiedNum where
-
--- Hiding numeric operations, because they get by default translated to SMT equivalent
-import Prelude hiding (Num(..))
-
-import qualified Prelude as Prelude 
-
-class VerifiedNum a where 
-  (+) :: a -> a -> a 
-  (-) :: a -> a -> a 
-
-{-@ predicate BoundInt X = 0 < X + 10000 && X < 10000 @-}
-
-{-@ type OkInt N = {v:Int | BoundInt N => v == N} @-}
-
-{-@ type ValidInt = {v:Int | BoundInt v} @-}
-
-
-instance VerifiedNum Int where
-{-@ instance VerifiedNum Int where 
-    + :: x:Int -> y:Int -> OkInt {x + y} 
-  @-}
-	x + y = (Prelude.+) x y  
-{-@ instance VerifiedNum Int where 
-    - :: x:Int -> y:Int -> OkInt {x - y} 
-  @-}
-	x - y = (Prelude.-) x y  
-
-
-{-@ good :: {v:Int | v == 10} @-}
-good :: Int 
-good  = 5 + 5
-
diff --git a/tests/neg/alias00.hs b/tests/neg/alias00.hs
deleted file mode 100644
--- a/tests/neg/alias00.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Test0 () where
-
-{-@ type NegInt = {v: Int | v <= 0} @-}
-{-@ myabs :: Int -> NegInt @-}
-myabs :: Int -> Int
-myabs x = if (x > 0) then x else (0 - x)
-
-{-@ type NNList a = {v: [a] | len(v) = 0} @-}
-{-@ single :: a -> NNList a @-}
-single x = [x] 
diff --git a/tests/neg/ass0.hs b/tests/neg/ass0.hs
deleted file mode 100644
--- a/tests/neg/ass0.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Ass (testError) where
-
--- import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-{-@ assert foo :: x:a -> {v: a | (v != x) } @-}
-foo x = x 
-
-testError :: Int -> Int 
-testError x = bar x 
-
-
-{-@ bar :: Nat -> Nat @-} 
-bar :: Int -> Int 
-bar x = x
diff --git a/tests/neg/bag1.hs b/tests/neg/bag1.hs
deleted file mode 100644
--- a/tests/neg/bag1.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module BagTest where
-
-import qualified Data.Set as S
-import Language.Haskell.Liquid.Bag as B
-
-{-@ zorg :: {v:B.Bag Int | v = B.empty} @-}
-zorg :: B.Bag Int
-zorg = B.empty
-
-{-@ measure elems @-}
-elems :: (Ord a) => [a] -> B.Bag a
-elems []     = B.empty
-elems (x:xs) = B.put x (elems xs)
-
-{-@ prop0 :: x:_ -> TT @-}
-prop0 :: Int -> Bool
-prop0 x = (B.get x b == 3) 
-  where
-    a   = elems [x, x]
-    b   = B.union a a 
diff --git a/tests/neg/concat.hs b/tests/neg/concat.hs
deleted file mode 100644
--- a/tests/neg/concat.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module Concat () where
-
-import Language.Haskell.Liquid.Prelude
-
-foo :: [Int]
-foo = [1..10]
-
-concatmap f ls = concat $ map f ls
-
-myconcatmap f []     = []
-myconcatmap f (x:xs) = (f x) ++ (myconcatmap f xs) 
-
-
-chooseList x = [choose x]
-r :: Int
-r = 5
-
-prop x = liquidAssertB (x == r)
-
-propMap  = map prop $ myconcatmap chooseList foo
-propMap1 = map prop $ concatmap   chooseList foo
diff --git a/tests/neg/concat1.hs b/tests/neg/concat1.hs
deleted file mode 100644
--- a/tests/neg/concat1.hs
+++ /dev/null
@@ -1,38 +0,0 @@
-module Concat () where
-
-import Language.Haskell.Liquid.Prelude
-
-------------------------------------------------------------
------------- Longer Version of neg/polypred.hs -------------
-------------------------------------------------------------
-
-foo :: [[Int]]
-foo = [[choose 1], [choose 2]]
-
--- concatmap f ls = concat $ map f ls
-
-myconcat []     = []
-myconcat (x:xs) = x ++ (myconcat xs) 
-
-
-myconcat1 :: a -> [[Int]] -> [Int]
-myconcat1 _ []     = []
-myconcat1 f (x:xs) = x ++ (myconcat1 f xs) 
-
-concat1 f = concat
-myconcat2 f = myconcat
-
-r :: Int
-r = 5
-
-prop x = liquidAssertB (x == r)
-
--- ok 
--- propC0 = map prop $ myconcat foo
--- this is safe
--- propC1 = map prop $ myconcat foo
--- propC2 = map prop $ concat foo
--- propC3 = map prop $ concat1 id foo
-
-propC4 = map prop $ myconcat1 id foo
-
diff --git a/tests/neg/concat2.hs b/tests/neg/concat2.hs
deleted file mode 100644
--- a/tests/neg/concat2.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Concat () where
-
-import Language.Haskell.Liquid.Prelude
-
-foo :: [Int]
-foo = [choose 1, choose 2]
-
--- myconcat1 :: (a -> a) -> [[Int]] -> [Int] 
--- :: a goes to False -> safe
-myconcat1 :: (a -> [(k,v)]) -> [a] -> [(k, v)]
-myconcat1 _ []     = []
-myconcat1 f (x:xs) = (f x) ++ (myconcat1 f xs) 
-
-r :: Int
-r = 5
-
-prop (x, y) = liquidAssertB (x > r)
---  where r = 5
--- this is safe
-propC = map prop $ myconcat1 (\x->[(x, x)]) foo
diff --git a/tests/neg/contra0.hs b/tests/neg/contra0.hs
deleted file mode 100644
--- a/tests/neg/contra0.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-import Data.IORef
-
-
-{-@ data variance IO bivariant @-}
-{-@ data variance IORef bivariant @-}
-
-job :: IO () 
-job = do
-  p <- newIORef (0 :: Int)
-  writeIORef p 10
-  v <- readIORef p
-  liquidAssert (v == 0) $ return ()
diff --git a/tests/neg/coretologic.hs b/tests/neg/coretologic.hs
deleted file mode 100644
--- a/tests/neg/coretologic.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module CoreToLog where
-
-import Data.Set
-
--- ISSUE: can we please allow things like `empty` to also
--- appear in type and alias specifications, not just in
--- measures as in `goo` below?
-
-{-@ type IsEmp a = {v:[a] | listElts v = Data.Set.empty } @-}
-
-{-@ foo :: IsEmp Int @-}
-foo :: [Int]
-foo = []
-
-{-@ bar :: IsEmp Int @-}
-bar :: [Int]
-bar = [1]
-
-{-@ measure goo @-}
-goo        :: (Ord a) => [a] -> Set a
-goo []     = empty
-goo (x:xs) = (singleton x) `union` (goo xs)  
diff --git a/tests/neg/csv.hs b/tests/neg/csv.hs
deleted file mode 100644
--- a/tests/neg/csv.hs
+++ /dev/null
@@ -1,38 +0,0 @@
-module CSV () where
-
--- | Using LiquidHaskell for CSV lists
--- c.f. http://www.reddit.com/r/scala/comments/1nhzi2/using_shapelesss_sized_type_to_eliminate_real/
-
-data CSV = Csv { headers :: [String]
-               , rows    :: [[String]]
-               }
-
-{-@ data CSV = Csv { headers :: [String]
-                   , rows    :: [{v:[String] | (len v) = (len headers)}]
-                   }
-  @-}
-
--- Eeks, we missed the column name.
-
-csvBad1 = Csv ["Date"] 
-              [ ["Mon", "1"]
-              , ["Tue", "2"]
-              , ["Wed", "3"] 
-              ]
-
--- Eeks, we missed a column.
-
-csvBad2 = Csv ["Name", "Age"] 
-              [ ["Alice", "32"]
-              , ["Bob"        ]
-              , ["Cris" , "29"] 
-              ]
-                      
--- All is well! 
-
-csvGood = Csv ["Id", "Name", "Days"]
-              [ ["1", "Jan", "31"]
-              , ["2", "Feb", "28"]
-              , ["3", "Mar", "31"]
-              , ["4", "Apr", "30"] 
-              ]
diff --git a/tests/neg/datacon-eq.hs b/tests/neg/datacon-eq.hs
deleted file mode 100644
--- a/tests/neg/datacon-eq.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Blank (foo) where
-
--- This is a blank file.
-
-data G = A | B
-
-{-@ foo :: Int -> {v:G | v = A} @-}
-foo  :: Int -> G
-foo _ = B
-
-
diff --git a/tests/neg/elim-ex-compose.hs b/tests/neg/elim-ex-compose.hs
deleted file mode 100644
--- a/tests/neg/elim-ex-compose.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module ElimExCompose (prop) where
-
-{-@ prop :: x:Nat -> {v:Int | v = x + 5} @-}
-prop :: Int -> Int
-prop = incr . incr . incr . incr
-
-{-@ incr :: dog:Int -> {v:Int | v == dog + 1} @-}
-incr :: Int -> Int
-incr cat = cat + 1
diff --git a/tests/neg/elim-ex-let.hs b/tests/neg/elim-ex-let.hs
deleted file mode 100644
--- a/tests/neg/elim-ex-let.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExLet (prop) where
-
-import LiquidHaskell
-
-[lq| type Nat = {v:Int | 0 <= v} |]
-
-[lq| prop :: a -> Nat |]
-prop _ = let x _ = let y = 0 
-                   in
-                     y - 3
-         in 
-           x () + 2
diff --git a/tests/neg/elim-ex-list.hs b/tests/neg/elim-ex-list.hs
deleted file mode 100644
--- a/tests/neg/elim-ex-list.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExList (prop) where
-
-import LiquidHaskell
-import Prelude hiding (head)
-
---------------------------------------------------------------------------
-[lq| prop :: a -> Even |]
-prop _ = (head ys) - 1
-  where 
-    ys = Cons 1 (Cons 2 (Cons 5 Nil))
---------------------------------------------------------------------------
-
-[lq| type Even = {v:Int | v mod 2 == 0 } |]
-
-data List a = Nil | Cons a (List a)
-
-head :: List a -> a 
-head (Cons x _) = x
-
diff --git a/tests/neg/elim-ex-map-1.hs b/tests/neg/elim-ex-map-1.hs
deleted file mode 100644
--- a/tests/neg/elim-ex-map-1.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExMap (prop) where
-
-import LiquidHaskell
-
-import Prelude hiding (map)
-
---------------------------------------------------------------------------
-[lq| prop :: List Even -> List Even |]
-prop xs = map (+ 2) (map (+ 1) xs)
---------------------------------------------------------------------------
-
-[lq| type Even = {v:Int | v mod 2 == 0 } |]
-
-data List a = Nil | Cons a (List a)
-
-map f Nil         = Nil
-map f (Cons x xs) = Cons (f x) (map f xs)
diff --git a/tests/neg/elim-ex-map-2.hs b/tests/neg/elim-ex-map-2.hs
deleted file mode 100644
--- a/tests/neg/elim-ex-map-2.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExMap (prop) where
-
-import LiquidHaskell
-
-import Prelude hiding (map)
-
---------------------------------------------------------------------------
-[lq| prop :: List Even -> List Even |]
-prop = map (+ 2) . map (+ 1)
---------------------------------------------------------------------------
-
-[lq| type Even = {v:Int | v mod 2 == 0 } |]
-
-data List a = Nil | Cons a (List a)
-
-map f Nil         = Nil
-map f (Cons x xs) = Cons (f x) (map f xs)
diff --git a/tests/neg/elim-ex-map-3.hs b/tests/neg/elim-ex-map-3.hs
deleted file mode 100644
--- a/tests/neg/elim-ex-map-3.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExMap (prop) where
-
-import LiquidHaskell
-
-import Prelude hiding (map)
-
---------------------------------------------------------------------------
-[lq| prop :: List Even -> List Even |]
-prop = map ((+ 0) . (+ 1))
---------------------------------------------------------------------------
-
-[lq| type Even = {v:Int | v mod 2 == 0 } |]
-
-data List a = Nil | Cons a (List a)
-
-map f Nil         = Nil
-map f (Cons x xs) = Cons (f x) (map f xs)
diff --git a/tests/neg/elim000.hs b/tests/neg/elim000.hs
deleted file mode 100644
--- a/tests/neg/elim000.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Poslist () where
-
-{-@ prop2 :: Int -> Nat @-}
-prop2 :: Int -> Int
-prop2 x = numAbsList x
-
-numAbsList = glap numAbs
-
-{-@ glap :: (a -> b) -> a -> b @-}
-glap :: (a -> b) -> a -> b
-glap = undefined
-
--- Adding the below signature makes it flag an error...
--- numAbs :: Int -> Int
-numAbs x = if x > 0 then x else x
diff --git a/tests/neg/errmsg.hs b/tests/neg/errmsg.hs
deleted file mode 100644
--- a/tests/neg/errmsg.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-{-@ LIQUID "--short-names" @-}
-
-module Goo where
-
-import Data.Set
-
-{- the "error message" is garbled thanks to all the ill-formatted
-   "Eq [Contravariant]" stuff. Can we remove it, or at least NOT show
-   it when running in --short-names mode. -}
-
-{-@ foo :: (Eq a) => x:a -> xs:[a] -> {v:Bool | v <=> (Data.Set.member x (Data.Set.fromList xs))} @-}
-foo          :: (Eq a) => a -> [a] -> Bool
-foo x (y:ys) = x == y || elem x ys
-foo _ []     = False
-
-{-@ measure elements @-}
-elements  []    = empty
-elements (x:xs) = singleton x `union` elements xs
-
-{- append :: xs:_ -> ys:_ -> {v:_ | elements v = union (elements xs) (elements ys) }@-}
-append :: [a] -> [a] -> [a]
-append = undefined 
-
diff --git a/tests/neg/errorloc.hs b/tests/neg/errorloc.hs
deleted file mode 100644
--- a/tests/neg/errorloc.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-{-@ zoo :: {v: Int | v > 0} -> {v: Int | v > 0} -> Int @-}
-zoo   :: Int -> Int -> Int 
-zoo x y = liquidAssert (x /= 0) $ x + y 
-
-
-foo = zoo (-1) (-2)
-
diff --git a/tests/neg/ex0-unsafe.hs b/tests/neg/ex0-unsafe.hs
deleted file mode 100644
--- a/tests/neg/ex0-unsafe.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-module Ex () where
-
--- Testing "existential-types"
-
-{-@ foldN :: forall a <p :: x0000:Int -> x1111:a -> Bool>. 
-                (i:Int -> a<p i> -> a<p (i+1)>)
-              -> n:{v: Int | v >= 0}
-              -> a <p 0>
-              -> a <p n>
-  @-}
-
-foldN :: (Int -> a -> a) -> Int -> a -> a
-foldN f n = go 0
-  where go i x | i < n     = go (i+1) (f i x)
-               | otherwise = x
-
-
-fooBar :: (Int -> a -> a) -> Int -> a -> a
-fooBar f n = go 0
-  where go i x | i < n     = go (i+1) (f i x)
-               | otherwise = x
-
-
-{-@ count :: m: {v: Int | v > 0 } -> {v: Int | v = 44 } @-}
-count :: Int -> Int
-count m = foldN (\_ n -> n + 1) m 0
--- count m = fooBar (\_ n -> n + 1) m 0
diff --git a/tests/neg/ex1-unsafe.hs b/tests/neg/ex1-unsafe.hs
deleted file mode 100644
--- a/tests/neg/ex1-unsafe.hs
+++ /dev/null
@@ -1,65 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-
--- | A somewhat fancier example demonstrating the use of Abstract Predicates and exist-types
-
-module Ex () where
-
--------------------------------------------------------------------------
--- | Data types ---------------------------------------------------------
--------------------------------------------------------------------------
-
-data Vec a = Nil | Cons a (Vec a)
-
--- | We can encode the notion of length as an inductive measure @llen@
-
-{-@ measure llen     :: forall a. Vec a -> Int
-      llen (Nil)       = 0
-      llen (Cons x xs) = 1 + llen(xs)
-  @-}
-
-
--- | As a warmup, lets check that a /real/ length function indeed computes
--- the length of the list.
-
-{-@ sizeOf :: xs:Vec a -> {v: Int | v = llen(xs)} @-}
-sizeOf             :: Vec a -> Int
-sizeOf Nil         = 0
-sizeOf (Cons _ xs) = 1 + sizeOf xs
-
--------------------------------------------------------------------------
--- | Higher-order fold --------------------------------------------------
--------------------------------------------------------------------------
-
--- | Time to roll up the sleeves. Here's a a higher-order @foldr@ function
--- for our `Vec` type. Note that the `op` argument takes an extra /ghost/
--- parameter that will let us properly describe the type of `efoldr`
-
-{-@ efoldr :: forall a b <p :: x0:Vec a -> x1:b -> Bool>. 
-                (xs:Vec a -> x:a -> b <p xs> -> b <p (Ex.Cons x xs)>)
-              -> b <p Ex.Nil>
-              -> ys: Vec a
-              -> b <p ys>
-  @-}
-efoldr :: (Vec a -> a -> b -> b) -> b -> Vec a -> b
-efoldr op b Nil         = b
-efoldr op b (Cons x xs) = op xs x (efoldr op b xs)
-
--------------------------------------------------------------------------
--- | Clients of `efold` -------------------------------------------------
--------------------------------------------------------------------------
-
--- | Finally, lets write a few /client/ functions that use `efoldr` to
--- operate on the `Vec`s.
-
--- | First: Computing the length using `efoldr`
-{-@ size :: xs:Vec a -> {v: Int | v = llen(xs)} @-}
-size :: Vec a -> Int
-size = efoldr (\_ _ n -> n + 1) 0
-
-{-@ suc :: x:Int -> {v: Int | v = x + 1} @-}
-suc :: Int -> Int
-suc x = x + 1
-
--- | Second: Appending two lists using `efoldr`
-{-@ app  :: xs: Vec a -> ys: Vec a -> {v: Vec a | llen(v) = 1 + llen(xs) + llen(ys) } @-}
-app xs ys = efoldr (\_ z zs -> Cons z zs) ys xs
diff --git a/tests/neg/filterAbs.hs b/tests/neg/filterAbs.hs
deleted file mode 100644
--- a/tests/neg/filterAbs.hs
+++ /dev/null
@@ -1,43 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-
-
-
-module Filter where
-
-import Prelude hiding (filter)
-
-{-@ filter :: forall <p :: a -> Bool, q :: a -> Bool -> Bool>.
-                  {y::a, flag :: {v:Bool<q y> | v} |- {v:a | v = y} <: a<p>}
-                  (x:a -> Bool<q x>) -> [a] -> [a<p>]
-  @-}
-
-filter f (x:xs)
-  | f x       = x : filter f xs
-  | otherwise = filter f xs
-filter _ []   = []
-
-{-@ isPos :: x:Int -> {v:Bool | v <=> x > 0} @-}
-isPos :: Int -> Bool
-isPos n = n > 0
-
-
-{-@ isNeg :: x:Int -> {v:Bool | v <=> x < 0} @-}
-isNeg :: Int -> Bool
-isNeg n = n < 0
-
-
--- Now the below *should* work with
--- p := \v   -> 0 < v
--- q := \x v -> v <=> 0 < 0
-
-
-{-@ positives :: [Int] -> [{v:Int | v > 0}] @-}
-positives xs = filter isPos xs
-
-{-@ negatives :: [Int] -> [{v:Int | v < 0}] @-}
-negatives xs = filter isNeg xs
-
-{-@ positivesBAD :: [Int] -> [{v:Int | v < 0}] @-}
-positivesBAD xs = filter isPos xs
-
diff --git a/tests/neg/foldN.hs b/tests/neg/foldN.hs
deleted file mode 100644
--- a/tests/neg/foldN.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-module Ex () where
-
--- Testing "existential-types"
-
-{-@ foldN :: forall a <p :: x0:Int -> x1:a -> Bool>. 
-                (i:Int -> a<p i> -> a<p (i+1)>)
-              -> n:{v: Int | v >= 0}
-              -> a <p 0>
-              -> a <p 42>
-  @-}
-
-foldN :: (Int -> a -> a) -> Int -> a -> a
-foldN f n = go 0
-  where go i x | i < n     = go (i+1) (f i x)
-               | otherwise = x
diff --git a/tests/neg/foldN1.hs b/tests/neg/foldN1.hs
deleted file mode 100644
--- a/tests/neg/foldN1.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-module Toy  where
-
-{-@ foldN :: forall a <p :: x0:Int -> x1:a -> Bool>. 
-                (i:Int -> a<p i> -> a<p (i+1)>)
-              -> n:{v: Int | v >= 0}
-              -> a <p 0>
-              -> {v : a | 0=1}
-  @-}
-
-foldN :: (Int -> a -> a) -> Int -> a -> a
-foldN f n = go 0
-  where go i x | i < n     = go (i+1) (f i x)
-               | otherwise = x
diff --git a/tests/neg/grty0.hs b/tests/neg/grty0.hs
deleted file mode 100644
--- a/tests/neg/grty0.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Test () where
-
-{-@ stupid :: Int -> Int @-}
-stupid :: Int -> Int
-stupid x = 0
-
-{-@ myId :: x:a -> {v:a | v = x } @-}
-myId x = x 
-
-{-@ assert single :: a -> {v: [a] | len(v) = 0} @-}
-single x = [x] 
-
-
diff --git a/tests/neg/grty1.hs b/tests/neg/grty1.hs
deleted file mode 100644
--- a/tests/neg/grty1.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-module Foo () where
-
-moo = insert 4 [1, 2, 0]
-
-
-{-@ insert      :: (Ord a) => x:a -> xs: [a]<{\fld v -> (v >= fld)}> -> {v: [a]<{\fld v -> (v >= fld)}> | len(v) = (1 + len(xs)) } @-}
-insert y []                   = [y]
-insert y (x : xs) | y <= x    = y : x : xs 
-                  | otherwise = x : insert y xs
-
-
diff --git a/tests/neg/grty2.hs b/tests/neg/grty2.hs
deleted file mode 100644
--- a/tests/neg/grty2.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Foo () where
-
-moo = insert 4 [1, 2, 3]
-
-{-@ insert      :: (Ord a) => x:a -> xs: [a]<{\fld v -> (v >= fld)}> -> {v: [a]<{\fld v -> (v >= fld)}> | len(v) = (1 + len(xs)) } @-}
-insert y []                            = [y]
-insert y (x : xs) | y > {- <= -} x     = y : x : xs 
-                  | otherwise          = x : insert y xs
-
diff --git a/tests/neg/grty3.hs b/tests/neg/grty3.hs
deleted file mode 100644
--- a/tests/neg/grty3.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Foo () where
-
-
-{-@ choo :: [a] -> {v: Int | v > 0 } @-}
-choo = poo
-
-
-poo :: [a] -> Int 
-poo (x:xs) = poo xs
-poo []     = 0
diff --git a/tests/neg/inc2.hs b/tests/neg/inc2.hs
deleted file mode 100644
--- a/tests/neg/inc2.hs
+++ /dev/null
@@ -1,11 +0,0 @@
--- ISSUE #671
---
--- | ISSUE would be nice to have error reported at `x-1` and NOT the `inc`
---   note that the right place gets shown if you comment out the `inc 0 = 1`
-
-module Inc where
-
-{-@ inc :: x:Int -> {v:Int | v > x} @-}
-inc :: Int -> Int
-inc 0 = 1
-inc x = x - 1
diff --git a/tests/neg/list00.hs b/tests/neg/list00.hs
deleted file mode 100644
--- a/tests/neg/list00.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Vec0 () where
-
-import Language.Haskell.Liquid.Prelude -- hiding (copyList)
-
-copyList zs = zs
-
-xs    = [1] :: [Int]
-ys    = copyList xs
-jhala = head ys
-prop0 = crash (0 == 1) 
diff --git a/tests/neg/listne.hs b/tests/neg/listne.hs
deleted file mode 100644
--- a/tests/neg/listne.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module ListNe where
-
-{-@ type ListNE a = {v:[a] | 0 < len v} @-}
-
-{-@ junkProp :: ListNE Int @-}
-junkProp :: [Int]
-junkProp = []
-
diff --git a/tests/neg/lit.hs b/tests/neg/lit.hs
deleted file mode 100644
--- a/tests/neg/lit.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module Lit where
-
-{-@ test :: {v:Int | v == 30} @-}
-test = length "cat"
diff --git a/tests/neg/mapreduce-tiny.hs b/tests/neg/mapreduce-tiny.hs
deleted file mode 100644
--- a/tests/neg/mapreduce-tiny.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-module Meas () where
-
-import Language.Haskell.Liquid.Prelude
-
-
-
-prop1       = map choo [[True]] -- replace [[1]] with [[]] for UNSAT
-choo (x:xs) = liquidAssertB False
--- choo []     = liquidAssertB False
-
--- import qualified Data.Map as M
--- import Data.List (foldl')
-
---keyvals :: [(Int, Int)]
---keyvals = [(1, 1), (2, 2), (3, 3)]
---
---group :: (Ord k) => [(k, v)] -> M.Map k [v]
---group = foldl' addKV  M.empty
---
---addKV m (k, v) = let boo = liquidAssertB False in M.insert k vs' m
---  where vs' = v : (M.findWithDefault [] k m)
---
---checkNN m = M.foldrWithKey reduceKV False m
---
---reduceKV _ _ acc = liquidAssertB False 
---
---prop = checkNN (group keyvals)
diff --git a/tests/neg/mapreduce.hs b/tests/neg/mapreduce.hs
deleted file mode 100644
--- a/tests/neg/mapreduce.hs
+++ /dev/null
@@ -1,55 +0,0 @@
-
--- RJ: Issues with TypeClasses? Ord?
-
-module Meas () where
-
-import Language.Haskell.Liquid.Prelude
-import qualified Data.Map as M
-import Data.List (foldl')
-
-----------------------------------------------------------------
---- Step 1: Map each element into key-value list (concatMap) ---
-----------------------------------------------------------------
-
-expand          :: (a -> [(k,v)]) -> [a] -> [(k, v)]
-expand f []     = []
-expand f (x:xs) = (f x) ++ (expand f xs)
-
-----------------------------------------------------------------
---- Step 2: Group By Key ---------------------------------------
-----------------------------------------------------------------
-
-group :: (Ord k) => [(k, v)] -> M.Map k [v]
-group = foldl' addKV  M.empty
-  
-addKV m (k, v) = M.insert k vs' m
-  where vs' = v : (M.findWithDefault [] k m)
-
-----------------------------------------------------------------
---- Step 3: Group By Key ---------------------------------------
-----------------------------------------------------------------
-
-collapse f = M.foldrWithKey reduceKV []
-  where reduceKV k (v:vs) acc = if liquidAssertB False then (k, foldl' f v vs) : acc else acc
-        reduceKV k []     _   = crash False --error $ show (liquidAssertB False)
-
-----------------------------------------------------------------
---- Putting it All Together ------------------------------------
-----------------------------------------------------------------
-
-mapReduce fmap fred = collapse fred . group . expand fmap 
-
-----------------------------------------------------------------
---- "Word Count" -----------------------------------------------
-----------------------------------------------------------------
-
-wordCount  = mapReduce fm plus 
-  where fm = \doc -> [ (w,1) | w <- words doc]
-
-main = putStrLn $ show $ wordCount docs
-  where docs = [ "this is the end"
-               , "go to the end"
-               , "the end is the beginning"]
- 
-
-
diff --git a/tests/neg/maps.hs b/tests/neg/maps.hs
deleted file mode 100644
--- a/tests/neg/maps.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-module Maps where
-
-{-@ prop1 :: x:_ -> y:{_ | y == x} -> TT @-}
-prop1 x y = (z == 10)
-  where
-    m1    = put x 10 emp  
-    m2    = put y 20 m1
-    z     = get x m2
-
-{-@ prop2 :: x:_ -> y:{_ | y == x} -> TT @-}
-prop2 x y = (z == 10)
-  where
-    m1    = put x 10 emp 
-    m2    = put y 20 m1
-    z     = get x m2
-
------------------------------------------------------------------------
-
-data Map k v = M
-
-{-@ embed Map as Map_t @-}
-{-@ measure Map_select :: Map k v -> k -> v @-}
-{-@ measure Map_store  :: Map k v -> k -> v -> Map k v @-}
-
-emp :: Map Int Int
-emp = undefined   
-     
-{-@ get :: k:k -> m:Map k v -> {v:v | v = Map_select m k} @-}
-get :: k -> Map k v -> v
-get = undefined 
-
-{-@ put :: k:k -> v:v -> m:Map k v -> {n:Map k v | n = Map_store m k v} @-}
-put :: k -> v -> Map k v -> Map k v
-put = undefined 
diff --git a/tests/neg/meas0.hs b/tests/neg/meas0.hs
deleted file mode 100644
--- a/tests/neg/meas0.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Range () where
-
-import Control.Applicative
-import Language.Haskell.Liquid.Prelude
-
-goo x = []
-
-poo (x:_) = True
-poo ([])  = liquidAssertB False
-
-xs = goo (choose 0)
-
-prop1 = liquidAssertB (poo xs)
diff --git a/tests/neg/meas2.hs b/tests/neg/meas2.hs
deleted file mode 100644
--- a/tests/neg/meas2.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Meas () where
-
-import Language.Haskell.Liquid.Prelude
-
-goo :: a -> Int
-goo _ = 1
-
-bob :: [a] -> Int
---bob [] = 0
---bob (n:ns) = goo ns 
-bob ms = case ms of 
-           []     -> 0
-           (n:ns) -> goo ns 
-
-zs :: [Int]
-zs = [1..100]
-
-prop2 = liquidAssertB (n2 `eq` 0) 
-  where n2 = bob zs
diff --git a/tests/neg/meas3.hs b/tests/neg/meas3.hs
deleted file mode 100644
--- a/tests/neg/meas3.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-module Meas () where
-
-
-import Language.Haskell.Liquid.Prelude
-
---mylen []       = 0
---mylen (_:xs)   = 1 `plus` mylen xs
-
-mylen xs = case xs of 
-             []     -> 0
-             (_:ys) -> 1 `plus` mylen ys
-
-
-zs :: [Int]
-zs = [1..100]
-
-goo :: [dogbert] -> Int
-goo _ = 1
-
-bloo :: [Int] -> Int
-bloo _ = 0
-
-prop1 = liquidAssertB (n1 `eq` 0) 
-  where n1 = mylen zs
diff --git a/tests/neg/meas5.hs b/tests/neg/meas5.hs
deleted file mode 100644
--- a/tests/neg/meas5.hs
+++ /dev/null
@@ -1,41 +0,0 @@
-module Meas () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ include <len.hquals> @-}
-
-mylen          :: [a] -> Int
-mylen []       = 0
-mylen (_:xs)   = 1 + mylen xs
-
-
-mymap f []     = []
-mymap f (x:xs) = (f x) : (mymap f xs)
-
-myreverse = go []
-  where go acc (x:xs) = go (x:acc) xs
-        go acc []     = acc
-    
-myapp [] ys     = ys
-myapp (x:xs) ys = x:(myapp xs ys)
-
-zs :: [Int]
-zs = [1..100]
-
-zs' :: [Int]
-zs' = [500..1000]
-
-prop2 = liquidAssertB (n1 == n2) 
-  where n1 = mylen zs
-        n2 = mylen $ mymap (+ 1) zs 
-
-prop3 = liquidAssertB (n1 == n2) 
-  where n1 = mylen zs
-        n2 = mylen $ myreverse zs 
-
-prop4 = liquidAssertB ((n1 + n2) == n3) 
-  where n1 = mylen zs
-        n2 = mylen zs'
-        n3 = mylen $ myapp zs zs' 
-
-prop5 = zipWith (+) zs (0: myreverse zs)
diff --git a/tests/neg/meas7.hs b/tests/neg/meas7.hs
deleted file mode 100644
--- a/tests/neg/meas7.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-
-module Meas () where
-
--- some tests for the 'expandDefaultCase' trick to case-split 
--- on the "missing" constructors.
-
-mylen          :: [a] -> Int
-mylen []       = 0
-mylen (_:xs)   = 1 + mylen xs
-
-
-{-@ foo :: [a] -> {v: Int | v = 0} @-}
-foo :: [a] -> Int
-foo zs = case zs of
-           [] -> 0
-           _  -> mylen zs
-
diff --git a/tests/neg/meas9.hs b/tests/neg/meas9.hs
deleted file mode 100644
--- a/tests/neg/meas9.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Meas () where
-
-import Data.Set (Set(..))
-
-{-@ myid :: xs:[a] -> {v:[a]| listElts(v) = listElts(xs)} @-}
-myid []     = []
-myid (x:xs) = x : myid xs
-
-{-@ myapp :: xs:[a] -> ys:[a] -> {v:[a] | listElts(v) = Set_cup (listElts xs) (listElts xs) } @-}
-myapp :: [a] -> [a] -> [a]
-myapp []     ys = ys
-myapp (x:xs) ys = x : myapp xs ys
-
diff --git a/tests/neg/monad3.hs b/tests/neg/monad3.hs
deleted file mode 100644
--- a/tests/neg/monad3.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude
-
--- gpp :: Monad m => m Int -> m Int
-gpp z = do x <- z
-           return $ liquidAssert (x >= 0) (x + 1)
-
-
--- decrlist n = n : decrlist (n-1)
-
-xs, ys, zs :: [Int]
-xs = [0, -1]
-ys = gpp xs
-zs = gpp ys
diff --git a/tests/neg/monad4.hs b/tests/neg/monad4.hs
deleted file mode 100644
--- a/tests/neg/monad4.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude
-
--- gpp :: Monad m => m Int -> m Int
-gpp z = do x <- z
-           return $ liquidAssert (x > 0) (x - 10)
-
-
-incrlist n = n : incrlist (n+1)
-
-xs, ys, zs :: Maybe Int
-xs = Just 9
-ys = gpp xs
-zs = gpp ys
diff --git a/tests/neg/monad5.hs b/tests/neg/monad5.hs
deleted file mode 100644
--- a/tests/neg/monad5.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude
-
--- gpp :: Monad m => m Int -> m Int
-gpp z = do x <- z
-           return $ liquidAssert (x > 0) (x + 1)
-
-myabs :: Int -> Int
-myabs x | x >= 0     = x
-        | otherwise  = 0-x
-
-posM :: Monad m => m Int
-posM = return $ myabs $ choose 0
-
-
-yM :: Monad m => m Int
-yM = gpp posM
diff --git a/tests/neg/monad6.hs b/tests/neg/monad6.hs
deleted file mode 100644
--- a/tests/neg/monad6.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Foo  where
-
-import Language.Haskell.Liquid.Prelude 
-
-{-@ gpp :: Monad m => m {v:Int|v>=0} -> m {v:Int|v>0} @-}
-gpp :: Monad m => m Int -> m Int
-gpp z = do x <- z
-           return $ liquidAssert (x >= 0) (x)
diff --git a/tests/neg/monad7.hs b/tests/neg/monad7.hs
deleted file mode 100644
--- a/tests/neg/monad7.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude 
-
-{-@ type OList a = [a]<{\fld v -> (v >= fld)}> @-}
-{-@ gpp :: (Ord a, Monad m) => [a] -> m (OList a) @-}
-gpp :: (Ord a, Monad m) => [a] -> m [a]
-gpp ls = return $ reverse $ insertSort ls
-
-{-@ insertSort :: (Ord a) => xs:[a] -> OList a @-}
-insertSort            :: (Ord a) => [a] -> [a]
-insertSort []         = []
-insertSort (x:xs)     = insert x (insertSort xs) 
-
-insert y []                   = [y]
-insert y (x : xs) | y <= x    = y : x : xs 
-                  | otherwise = x : insert y xs
-
-
-
-
-
diff --git a/tests/neg/mr00.hs b/tests/neg/mr00.hs
deleted file mode 100644
--- a/tests/neg/mr00.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module MapReduce () where
-
-import Language.Haskell.Liquid.Prelude 
-import Data.Map hiding (filter, map, foldl)
-
-baz (v:vs) _ = crash False 
-baz []     _ = crash False
-
-mymap = Data.Map.fromList [('a', [1])]
-
--- Why is this safe
-coll = Data.Map.foldr baz 0 
-prop_safe = coll mymap 
-
--- Oddly, this is unsafe
--- prop_unsafe = Data.Map.foldr baz 0 mymap
diff --git a/tests/neg/multi-pred-app-00.hs b/tests/neg/multi-pred-app-00.hs
deleted file mode 100644
--- a/tests/neg/multi-pred-app-00.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Blank () where
-
-{-@ bar :: forall < p :: Int -> Bool, q :: Int -> Bool>. Int<p> -> Int<p, q> @-}
-bar :: Int -> Int
-bar x = x
diff --git a/tests/neg/nestedRecursion.hs b/tests/neg/nestedRecursion.hs
deleted file mode 100644
--- a/tests/neg/nestedRecursion.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Map (radicals) where
-
-radicals :: Int -> [a]
-radicals n = [ foo (radicals n) i | i <- [1..]]
-
-foo = undefined
diff --git a/tests/neg/pair.hs b/tests/neg/pair.hs
deleted file mode 100644
--- a/tests/neg/pair.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module Pair () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ data Pair a b <p :: a -> b -> Bool> = P { pX :: a, pY :: b<p pX> } @-} 
-data Pair a b = P a b
-
-incr x = let p = P x ((x+1)) in p
-chk (P x (y)) = liquidAssertB (x == y)
-prop  = chk $ incr n
-  where n = choose 0
-
-incr2 x =
-  let p1 = (P True (x+1)) in
-  let p2 = P x p1 in
-   p2
-chk2 (P x w) =
-   case w of (P z y) -> liquidAssertB (x == y)
-prop2  = chk2 $ incr2 n
-  where n = choose 0
-
-incr3 x = P x (P True (P 0 (x+1)))
-chk3 (P x (P _(P _ y))) = liquidAssertB (x == y)
-prop3  = chk3 $ incr3 n
-  where n = choose 0
diff --git a/tests/neg/pair0.hs b/tests/neg/pair0.hs
deleted file mode 100644
--- a/tests/neg/pair0.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module Pair () where 
-
-import Language.Haskell.Liquid.Prelude 
-
-data Pair a b = P a b
-
-
-incr x = (x, x-1)
-chk (x, y) = liquidAssertB (x <y) 
-prop  = chk $ incr n
-  where n = choose 0
-
-incr2 x = (x, True, x-1)
-chk2 (x, _, y) = liquidAssertB (x <y) 
-prop2  = chk2 $ incr2 n
-  where n = choose 0
-
-incr3 x = (x, (True, (0, x-1)))
-chk3 (x, (_, (_, y))) = liquidAssertB (x <y) 
-prop3  = chk3 $ incr3 n
-  where n = choose 0
diff --git a/tests/neg/pargs.hs b/tests/neg/pargs.hs
deleted file mode 100644
--- a/tests/neg/pargs.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Foo () where
-
-{-@ foo :: forall a <p :: x0:Int -> x1:a -> Bool>. 
-             (i:Int -> a<p i>) -> {v:Int| v=0}
-              -> a <p 1>
-  @-}
-
-foo ::  (Int -> a) -> Int ->  a
-foo f i = f i
diff --git a/tests/neg/pargs1.hs b/tests/neg/pargs1.hs
deleted file mode 100644
--- a/tests/neg/pargs1.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-module Foo () where
-
-{-@ foo :: forall a <p :: x0:Int -> x1:a -> Bool>. 
-             (i:Int  -> j : Int-> a<p (i)>) ->
-               ii:Int -> jj:Int
-              -> a <p (ii+jj)>
-  @-}
-
-foo ::  (Int -> Int -> a) -> Int -> Int ->  a
-foo f i j = f i j
diff --git a/tests/neg/partial.hs b/tests/neg/partial.hs
deleted file mode 100644
--- a/tests/neg/partial.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Test () where
-
-{-@ posPlus :: x:{v: Int | v >= 0} -> {v: Int | v >= x} @-}
-posPlus :: Int -> Int
-posPlus x = if (x > 0) 
-              then 2 + (posPlus (x - 1))
-              else 0
-
-goo = posPlus (-3)
-
-{-@ poo :: x:Int -> {v: Int | v >= x } @-}
-poo x = if x > 0 then posPlus x else x
-
diff --git a/tests/neg/poly0.hs b/tests/neg/poly0.hs
deleted file mode 100644
--- a/tests/neg/poly0.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module Poly0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x `gt` 0 then x else 0 `minus` x
-
-myid arg     = arg
-
-----------------------------------------------------------
-
-x = choose 0
-
-prop_id1 = let x'  = myabs x in 
-           let x'' = myid x' in 
-           liquidAssertB (x'' `geq` 0)
-
-prop_id2 = liquidAssertB (x'' `geq` 0)
-  where x'  = myabs x 
-        x'' = myid x' 
-
-prop_id3 = liquidAssertB (x' `geq` 20)
-  where x' = myid $ myabs x 
diff --git a/tests/neg/poly1.hs b/tests/neg/poly1.hs
deleted file mode 100644
--- a/tests/neg/poly1.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Poly0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x `gt` 0 then x else 0 `minus` x
-
-myid2 a b  = a  
-
-----------------------------------------------------------
-
-x =  choose 0
-
-prop_id4 = let x'  = myabs x in 
-           let x'' = myid2 x' [] in 
-           liquidAssertB (x'' `geq` 10)
-
-prop_id5 = liquidAssertB (x'' `geq` 0)
-  where x'  = myabs x 
-        x'' = myid2 x' [] 
diff --git a/tests/neg/poly2-degenerate.hs b/tests/neg/poly2-degenerate.hs
deleted file mode 100644
--- a/tests/neg/poly2-degenerate.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Poly0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x `gt` 0 then x else 0 `minus` x
-
-----------------------------------------------------------
-
-myid3 x y  = y
-
-prop_id6 = liquidAssertB (x' `geq` 10)
-  where x' = myid3 [] $ myabs n 
-        n  = choose 0
-
diff --git a/tests/neg/poly2.hs b/tests/neg/poly2.hs
deleted file mode 100644
--- a/tests/neg/poly2.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Poly0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x `gt` 0 then x else 0 `minus` x
-
-----------------------------------------------------------
-
-myid3 x y  = y
-
-x = choose 0
-
-prop_id6 = liquidAssertB (x' `geq` 10)
-  where x' = myid3 [] $ myabs x 
-
-
diff --git a/tests/neg/polypred.hs b/tests/neg/polypred.hs
deleted file mode 100644
--- a/tests/neg/polypred.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Concat () where
-
-import Language.Haskell.Liquid.Prelude
-
-prop :: Int -> Bool
-prop x = liquidAssertB (x == 0)
-
-foo :: a -> Int
-foo longVarName = choose 20 
-
--- propUNSAFE = prop (foo "ker")
-propSAFE = prop (foo id)
-
diff --git a/tests/neg/poslist.hs b/tests/neg/poslist.hs
deleted file mode 100644
--- a/tests/neg/poslist.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Poslist () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x `gt` 0 then x else 0 `minus` x
-
-absList xs = map myabs xs
-
-prop1 = map (liquidAssertB . (`geq` 0)) $ absList $ map choose [1..]
-
-
-numAbs x   = if x > 0 then x else (x)
-
-numAbsList = map numAbs 
-
-prop2      = map (liquidAssertB . (>= 0)) $ numAbsList $ map choose [1..]
diff --git a/tests/neg/pred.hs b/tests/neg/pred.hs
deleted file mode 100644
--- a/tests/neg/pred.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Foo () where
-
-{-@ predicate Gt X Y = (X < Y) @-}
-
-{-@ incr :: x:Int -> {v:Int | Gt v x} @-}
-incr :: Int -> Int
-incr x = x + 1
diff --git a/tests/neg/prune0.hs b/tests/neg/prune0.hs
deleted file mode 100644
--- a/tests/neg/prune0.hs
+++ /dev/null
@@ -1,52 +0,0 @@
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module Prune where
-
-import Prelude hiding (read, length)
-import Control.Monad.Primitive
-import Data.Vector.Generic.Mutable
-
-----------------------------------------------------------------------------
--- LIQUID Specifications ---------------------------------------------------
-----------------------------------------------------------------------------
-
--- | Vector Size Measure
-
-{-@ measure vsize :: forall a. a -> Int @-}
-
--- | Vector Type Aliases
-{-@ type      OkIdx X     = {v:Nat | v < vsize X} @-}
-
--- | Assumed Types for Vector
-
-{-@ assume unsafeRead  
-      :: (PrimMonad m, MVector v a) 
-      => xorp:(v (PrimState m) a) 
-      -> (OkIdx xorp) 
-      -> m a       
-  @-}
-
-yuck xanadu i = if (i > 0) then unsafeRead xanadu i else undefined
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/neg/range.hs b/tests/neg/range.hs
deleted file mode 100644
--- a/tests/neg/range.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Range () where
-
-import Language.Haskell.Liquid.Prelude
-
-range :: Int -> Int -> [Int]
-range i j  
-  | i `lt` j  = i : (range (i `plus` 1) j)
-  | otherwise = []  
-
-sumTo = foldl plus 0 . range 0
-
-n = choose 0 
-m = choose 1
-
-prop_rng1 = map (liquidAssertB . (10 `leq`)) $ range 0 n
-prop_rng2 = map (liquidAssertB . (n `leq`)) $ range n 100
-prop_rng3 = map (liquidAssertB . (n `leq`)) $ range n m
-prop_rng4 = map (liquidAssertB . (`leq` m)) $ range n m 
-prop_rng5 = liquidAssertB ((sumTo n) `geq` 10)
diff --git a/tests/neg/record0.hs b/tests/neg/record0.hs
deleted file mode 100644
--- a/tests/neg/record0.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module Rec0 (clone, mk) where
-
-{-@ data LL a = BXYZ { size  :: {v: Int | v > 0 }
-                     , elems :: {v: [a] | (len v) = size }
-                     }
-  @-}
-
-data LL a = BXYZ { size  :: Int
-                 , elems :: [a]
-                 }
-
-{-@ mk :: a -> Int -> LL a @-}
-mk x n = BXYZ n (clone x 0)
-
-{-@ clone :: x:a -> n:Int -> {v:[a]| (len v) = n} @-}
-clone :: a -> Int -> [a]
-clone = undefined 
diff --git a/tests/neg/revshape.hs b/tests/neg/revshape.hs
deleted file mode 100644
--- a/tests/neg/revshape.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module Shapes () where
- 
--- https://gist.github.com/cartazio/6891549
-
-data Shape = Nil | Cons !Int !Shape 
-
-{-@ measure rank :: Shape -> Int
-    rank (Nil)       = 0
-    rank (Cons d ds) = 1 + (rank ds)
-  @-}
-
-{-@ type DIM1 = {v:Shape | (rank v) = 1} @-}
-{-@ type DIM2 = {v:Shape | (rank v) = 2} @-}
-
-{-@ oneDim :: DIM1 @-}
-oneDim = 12 `Cons` Nil
-
-{-@ twoDim :: DIM2 @-}
-twoDim = 2 `Cons` (17 `Cons` Nil)
-
--- clearly an error, is flagged by LiquidHaskell
-{-@ twoDim' :: DIM2 @-}
-twoDim' = 56 `Cons` (2 `Cons` (17 `Cons` Nil))
-
-{-@ reverseShape :: sh:Shape -> {v:Shape | (rank v) = (rank sh)} @-}
-reverseShape shs = go shs Nil 
-    where
-        {-@ go ::  a:Shape -> b:Shape -> {v:Shape | (rank v) = (rank a) + (rank b)} @-}
-        go Nil res            = res   
-        go (Cons ix more) res = go more  (Cons ix res)
- 
-  
diff --git a/tests/neg/risers.hs b/tests/neg/risers.hs
deleted file mode 100644
--- a/tests/neg/risers.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Risers  where
-
-{-@ predicate NonNull X = ((len X) > 0) @-}
-
-{- risers :: (Ord a) => zs:[a] -> {v: [[a]] | ((NonNull zs) => (NonNull v)) } @-} 
-risers []        
-  = []
-risers [x]       
-  = [[x]]
-risers (x:y:etc) 
-  = if x <= y then (x:s):ss else [x]:(s:ss)
-    where (s:ss) = risers [] -- insert partiality (y:etc)
diff --git a/tests/neg/stacks.hs b/tests/neg/stacks.hs
deleted file mode 100644
--- a/tests/neg/stacks.hs
+++ /dev/null
@@ -1,35 +0,0 @@
-module Stacks () where
-
-
-{-@ type DList a = [a]<{\fld v -> (v != fld)}> @-}
-
-{-@ data Stack a = St { focus  :: a    
-                      , up     :: DList {v: a | v != focus}
-                      , down   :: DList {v: a | v != focus}
-                      } 
-  @-}
-
-data Stack a = St { focus  :: !a    
-                  , up     :: ![a] 
-                  , down   :: ![a]
-                  } deriving (Show, Eq)
-
--- All of the below violate the invariant, get liquid to say so!
-
-{-@ bad0 :: a -> Stack a @-}
-bad0   :: a -> Stack a 
-bad0 x = St x [x] []
-
-
-{-@ bad1 :: a -> Stack a @-}
-bad1   :: a -> Stack a 
-bad1 x = St x []  [x]
-
-{-@ bad2 :: Int -> Stack Int @-}
-bad2 :: Int -> Stack Int
-bad2 x = St 0 [x] [x]
-
-{-@ bad3 :: Int -> Stack Int @-}
-bad3 :: Int -> Stack Int
-bad3 x = St x [1] [1] 
-
diff --git a/tests/neg/state0.hs b/tests/neg/state0.hs
deleted file mode 100644
--- a/tests/neg/state0.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module StateMonad () where
-
-type State = Int
-data ST a = S (State -> (a, State))
-{-@ data ST a <p1 :: State -> Bool,
-               p2 :: State -> Bool> 
-     = S (x::(f:State<p1> -> (a, State<p2>)))
-  @-}
-
-{-@ fresh :: ST <{\v -> v>=0}, {\v -> v>=0}> Int @-}
-fresh :: ST Int
-fresh = S $ \n -> (n, n-1)
diff --git a/tests/neg/state00.hs b/tests/neg/state00.hs
deleted file mode 100644
--- a/tests/neg/state00.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module StateMonad () where
-
-type State = Int
-data ST a b = S (a -> (a, b)) | F a
-
-{-@ fresh :: ST Int {v:Int|v>=0} @-}
-fresh :: ST Int Int
-fresh = S $ \n -> (n, n+1)
-
-
diff --git a/tests/neg/string00.hs b/tests/neg/string00.hs
deleted file mode 100644
--- a/tests/neg/string00.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Str0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-foo = "dog"
-
-prop1 = liquidAssertB (0 == 1)	
-prop2 = liquidAssertB (1 /= 1)
diff --git a/tests/neg/sumPoly.hs b/tests/neg/sumPoly.hs
deleted file mode 100644
--- a/tests/neg/sumPoly.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Toy  where
-
-{-@ sumPoly :: forall <p ::a -> Bool>. (Num a, Ord a) => [a<p>] -> a<p> @-} 
-sumPoly     :: (Num a, Ord a) => [a] -> a
-sumPoly (x:xs) = foldl (+) x xs
-
diff --git a/tests/neg/sumk.hs b/tests/neg/sumk.hs
deleted file mode 100644
--- a/tests/neg/sumk.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Sumk () where
-
-import Language.Haskell.Liquid.Prelude
-
-m   = choose 0
-bot = choose 0
-
-dsum ranjit jhala k =
-  if (ranjit `leq` 0)
-    then k jhala 
-    else dsum (ranjit `minus` 1) (ranjit `plus` jhala) k
-
-prop0 = dsum m bot (\x -> liquidAssertB ((m `plus` bot) `leq` x))
-
-prop1 = liquidAssertB (1 `leq` 0)
-
diff --git a/tests/neg/test00.hs b/tests/neg/test00.hs
deleted file mode 100644
--- a/tests/neg/test00.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-x :: Int
-x = choose 0
-
-prop_abs = if x > 0 then baz x else False
-
-baz :: Int -> Bool
-baz z = liquidAssertB (z `geq` 100)
diff --git a/tests/neg/test00a.hs b/tests/neg/test00a.hs
deleted file mode 100644
--- a/tests/neg/test00a.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-x = choose 0
-
-prop_abs = if x > 0 then baz x else False
-
-baz z = liquidAssertB (z >= 10)
diff --git a/tests/neg/test00b.hs b/tests/neg/test00b.hs
deleted file mode 100644
--- a/tests/neg/test00b.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-x = choose 0
-
-foo ::  Num a => a -> a
-foo x = 0 - x
-
-prop_abs ::  Bool
-prop_abs = if x > 0 then baz (foo x) else False
-
-baz ::  (Num a, Ord a) => a -> Bool
-baz z = liquidAssertB (z > 0)
diff --git a/tests/neg/test00c.hs b/tests/neg/test00c.hs
deleted file mode 100644
--- a/tests/neg/test00c.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--diffcheck" @-}
-
-module Test (ok, inc) where
-
-
-
-
-
-
-{-@ ok
-      :: Int -> Nat
-  @-}
-ok :: Int -> Int
-ok x = x + 120
-
-{-@ inc :: Int -> Nat @-}
-inc :: Int -> Int
-inc x = x + 10
diff --git a/tests/neg/test1.hs b/tests/neg/test1.hs
deleted file mode 100644
--- a/tests/neg/test1.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Test1 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x = if x `gt` 0 then x else 0 `minus` x
-
-n = choose 0
-
-prop_absf = liquidAssertB ((myabs n) `geq` 4)
diff --git a/tests/neg/test2.hs b/tests/neg/test2.hs
deleted file mode 100644
--- a/tests/neg/test2.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Test1 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x = if x `gt` 0 then x else 0 `minus` x
-
-n = choose 0
-
-prop_absf = 
-  let zz = (myabs n) `geq` 4 in
-  liquidAssertB zz
diff --git a/tests/neg/trans.hs b/tests/neg/trans.hs
deleted file mode 100644
--- a/tests/neg/trans.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Tx () where
-
-{-@ assert compre :: xs:[a] -> {v:[(a,a)] | len(v) = len(xs) } @-}
-compre xs = [(x,x) | x <- xs]
-
-{-@ assert transpose :: n: Int -> [{v:[a] | len(v) = n}] -> {v: [[a]] | len(v) > n} @-}
-transpose               :: Int -> [[a]] -> [[a]]
-transpose 0 _              = []
-transpose n ((x:xs) : xss) = (x : [h | (h:_) <- xss]) : transpose (n-1) (xs : [ t | (_:t) <- xss]) 
--- transpose []             = []
--- transpose ([]   : xss)   = transpose xss
-
-
diff --git a/tests/neg/truespec.hs b/tests/neg/truespec.hs
deleted file mode 100644
--- a/tests/neg/truespec.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module TrueSpec (foo) where
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-{-@ foo :: Int -> Int @-}
-foo :: Int -> Int
-foo x = liquidAssert (x > 0) $ x + 1
diff --git a/tests/neg/tyclass0-unsafe.hs b/tests/neg/tyclass0-unsafe.hs
deleted file mode 100644
--- a/tests/neg/tyclass0-unsafe.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Goo (poop) where
-
-class Zog a where
-  zoom :: a -> Int
-
--- Assume the relevant behavior for the method.
-{-@ zoom :: (Zog a) => a -> Int @-}
-
--- Uses the behavior of `zoom`
-{-@ poop :: (Zog a) => a -> Nat @-}
-poop x = zoom x
diff --git a/tests/neg/vector00.hs b/tests/neg/vector00.hs
deleted file mode 100644
--- a/tests/neg/vector00.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Vec0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-import Data.Vector hiding (map, concat, zipWith, filter, foldr, foldl, (++))
-
-xs    = [1,2,3,4] :: [Int]
-vs    = fromList xs
-jhala = vs ! (x + y + z)
-  where x = 2
-        y = 3
-        z = 5
diff --git a/tests/neg/vector0a.hs b/tests/neg/vector0a.hs
deleted file mode 100644
--- a/tests/neg/vector0a.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Vec0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-import Data.Vector hiding(map, concat, zipWith, filter, foldl, foldr, (++))
-
-xs  = [1,2,3,4] :: [Int]
-vs  = fromList xs
-
---prop0 = liquidAssertB (x >= 0)
---        where x = Prelude.head xs
---
---prop1 = liquidAssertB (n > 0)
---        where n = Prelude.length xs
---
---prop2 = liquidAssertB (Data.Vector.length vs > 0)
---prop3 = liquidAssertB (Data.Vector.length vs > 3)
-
-prop6 = crash (0 == 1) 
-x0    = vs ! 0
diff --git a/tests/neg/vector1a.hs b/tests/neg/vector1a.hs
deleted file mode 100644
--- a/tests/neg/vector1a.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module Vec1 () where
-
-import Language.Haskell.Liquid.Prelude
-import Data.Vector hiding (map, concat, zipWith, filter, foldr, foldl, (++))
-
-
--- HA this needs a non-TOP spec due to contravariance...
-foo = (Data.Vector.!) 
-
-for :: Int -> Int -> a -> (Int -> a -> a) -> a
-for lo hi acc f 
-  | lo <= hi   = for (lo + 1) hi (f lo acc) f
-  | otherwise = acc 
-
-dotProd       :: Vector Int -> Vector Int -> Int
-dotProd v1 v2 = for 0 n 0 $ \i -> (((v1!i) * (v2!i)) +)
-  where n = Data.Vector.length v1
-
-sumSquare   :: Vector Int -> Int
-sumSquare v = dotProd v v
-
-total = sumSquare $ Data.Vector.fromList [0..100]
diff --git a/tests/neg/vector2.hs b/tests/neg/vector2.hs
deleted file mode 100644
--- a/tests/neg/vector2.hs
+++ /dev/null
@@ -1,67 +0,0 @@
-module Vec0 () where
-
-import Prelude hiding (length)
-import Data.Vector
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-    
-{-@ predicate Lt X Y      = X < Y                         @-}
-{-@ predicate Ge X Y      = not (Lt X Y)                  @-}
-{-@ predicate InBound I A = ((Ge I 0) && (Lt I (vlen A))) @-}
-
-{-@ unsafeLookup :: vec:Vector a 
-                 -> {v: Int | (0 <= v && v < (vlen vec)) } 
-                 -> a @-}
-unsafeLookup vec i = vec ! i
-
-{-@ unsafeLookup' :: vec:Vector a -> {v: Int | (InBound v vec)} -> a @-}
-unsafeLookup' vec i = vec ! i
-
-safeLookup x i 
-  | 0 <= i && i < length x = Just (x ! i)
-  | otherwise              = Nothing 
-
-{-@ absoluteSum   :: Vector Int -> {v: Int | 0 <= v}  @-}
-absoluteSum       :: Vector Int -> Int 
-absoluteSum vec   = if 0 < n then go 0 0 else 0
-  where
-    go acc i 
-      | i /= n    = go (acc + abz (vec ! i)) (i + 1)
-      | otherwise = acc 
-    n             = length vec
-
-abz n = if 0 <= n then n else (0 - n) 
-
-loop :: Int -> Int -> a -> (Int -> a -> a) -> a 
-loop lo hi base f = go base lo
-  where
-    go acc i     
-      | i /= hi   = go (f i acc) (i + 1)
-      | otherwise = acc
-
-incr x = x + 1
-
-zoo = incr 29
-
-{-@ dotProduct :: x:(Vector Int) 
-               -> y:{v: Vector Int | (vlen x) = (vlen x)} 
-               -> Int 
-  @-}
-dotProduct     :: Vector Int -> Vector Int -> Int
-dotProduct x y 
-  = loop 0 (length x) 0 (\index -> (+ (x ! index) * (y ! index))) 
-  -- = error "dotProduct only on equal-sized vectors!"
-
-
-{-@ type SparseVector a N = [({v: Int | (0 <= v && v <= N)}, a)] @-}
-
-{-@ sparseDotProduct :: (Num a) => x:(Vector a) -> (SparseVector a {(vlen x)}) -> a @-}
-sparseDotProduct x y  = go 0 y
-  where 
-    go sum ((i, v) : y') = go (sum + (x ! i) * v) y' 
-    go sum []            = sum
-
-jhala = vs ! (x + y + z)
-  where x = 2
-        y = 3
-        z = 5
-        vs = fromList [1,2,3,4] 
diff --git a/tests/neg/wrap0.hs b/tests/neg/wrap0.hs
deleted file mode 100644
--- a/tests/neg/wrap0.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module Wrap0 () where
-
-import Language.Haskell.Liquid.Prelude (liquidError, liquidAssertB)
-
-{-@ data Foo a <p :: a -> Bool> = F (f :: a <p>) @-}
-data Foo a = F a
-
-type IntFoo = Foo Int
-
-{-@ assert flibberty :: (Eq a) => a -> Bool @-}
-flibberty x   = prop x (F x)
-prop x (F y)  = liquidAssertB (x == y)
-
-{-@ assert flibInt :: (Num a, Ord a) => a -> Bool @-}
-flibInt x     = prop1 x (F (x + 1))
-prop1 x (F y) = liquidAssertB (x < y) 
-
-{-@ assert flibXs :: a -> Bool @-}
-flibXs x     = prop2 (F [x, x, x])
-prop2 (F _ ) = liquidError "no!"
-prop2 (F _ ) = True
diff --git a/tests/neg/wrap1.hs b/tests/neg/wrap1.hs
deleted file mode 100644
--- a/tests/neg/wrap1.hs
+++ /dev/null
@@ -1,32 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
-
-module Wrap0 () where
-
-
-import Language.Haskell.Liquid.Prelude (liquidError, liquidAssertB)
-import Data.Function (on)
-import Data.Ord (comparing)
-
-data WrapType b a = WrapType {getVect :: b, getVal :: a}
-
-instance Eq (WrapType [Double] a) where
-   (==) = (==) `on` getVect
-
-instance Ord (WrapType [Double] a) where
-    compare = comparing getVect
-
-{-@ assert flibXs :: a -> Bool @-}
-flibXs x              = prop1 (WrapType [x, x, x] x)
-prop1 (WrapType [] _) = liquidError "no!"
-prop1 (WrapType _  _) = True
-
-{-@ assert nflibXs :: Int -> a -> Bool @-}
-nflibXs n x           = prop2 n (WrapType nxs x)
-                        where nxs = replicate n x 
-
-prop2 n (WrapType xs _) = liquidAssertB (n > length xs) 
-
-
-
-
-
diff --git a/tests/pos/AVL.hs b/tests/pos/AVL.hs
deleted file mode 100644
--- a/tests/pos/AVL.hs
+++ /dev/null
@@ -1,94 +0,0 @@
-{- Example of AVL trees by michaelbeaumont -}
-
-module AVL (Tree, singleton, insert, ht, bFac) where
-
--- Basic functions
-{-@ data Tree [ht] @-} -- a = Nil | Tree (x::a) (l::Tree a) (r::Tree a) @-}
-data Tree a = Nil | Tree a (Tree a) (Tree a) deriving Show
-
-{-@ measure ht @-}
-ht              :: Tree a -> Int
-ht Nil          = 0
-ht (Tree x l r) = if (ht l) > (ht r) then (1 + ht l) else (1 + ht r)
-{-@ invariant {v:Tree a | 0 <= ht v} @-}
-
-
-{-@ measure bFac @-}
-bFac Nil          = 0
-bFac (Tree v l r) = ht l - ht r
-
-{-@ htDiff :: s:Tree a -> t: Tree a -> {v: Int | HtDiff s t v} @-}
-htDiff :: Tree a -> Tree a -> Int
-htDiff l r = ht l - ht r
-
-{-@ emp :: {v: AVLTree | ht v == 0} @-}
-emp = Nil
-
-{-@ singleton :: a -> {v: AVLTree | ht v == 1 }@-}
-singleton a = Tree a Nil Nil
-
--- | Insert functions
-
-{-@ decrease insert 3 @-}
-{-@ insert :: a -> s: AVLTree -> {t: AVLTree | EqHt t s || HtDiff t s 1 } @-}
-insert :: (Ord a) => a -> Tree a -> Tree a
-insert a Nil = singleton a
-insert a t@(Tree v l r) = case compare a v of
-    LT -> insL
-    GT -> insR
-    EQ -> t
-    where r' = insert a r
-          l' = insert a l
-          insL | siblDiff > 1
-                 && bFac l' == (0-1) = rebalanceLR v l' r
-               | siblDiff > 1
-                 && bFac l' == 1  = rebalanceLL v l' r
-               | siblDiff <= 1 = Tree v l' r
-               | otherwise = t
-               where siblDiff = htDiff l' r
-          insR | siblDiff > 1
-                 && bFac r' == 1 = rebalanceRL v l r'
-               | siblDiff > 1
-                 && bFac r' == (0-1) = rebalanceRR v l r'
-               | siblDiff <= 1 = Tree v l r'
-               | otherwise = t
-               where siblDiff = htDiff r' l
-
-{-@ rebalanceLL :: a -> l:{AVLTree | LeftHeavy l } -> r:{AVLTree | HtDiff l r 2} -> {t:AVLTree | EqHt t l } @-}
-rebalanceLL v (Tree lv ll lr) r                 = Tree lv ll (Tree v lr r)
-
-{-@ rebalanceLR :: a -> l:{AVLTree | RightHeavy l } -> r:{AVLTree | HtDiff l r 2 } -> {t: AVLTree | EqHt t l } @-}
-rebalanceLR v (Tree lv ll (Tree lrv lrl lrr)) r = Tree lrv (Tree lv ll lrl) (Tree v lrr r)
-
-{-@ rebalanceRR :: a -> l: AVLTree -> r: {AVLTree | RightHeavy r && HtDiff r l 2 } -> {t: AVLTree | EqHt t r } @-}
-rebalanceRR v l (Tree rv rl rr)                 = Tree rv (Tree v l rl) rr
-
-{-@ rebalanceRL :: a -> l: AVLTree -> r:{AVLTree | LeftHeavy r && HtDiff r l 2} -> {t: AVLTree | EqHt t r } @-}
-rebalanceRL v l (Tree rv (Tree rlv rll rlr) rr) = Tree rlv (Tree v l rll) (Tree rv rlr rr)
-
--- Test
-main = do
-    mapM_ print [a,b,c,d]
-  where
-    a = singleton 5
-    b = insert 2 a
-    c = insert 3 b
-    d = insert 7 c
-
--- Liquid Haskell
-
-{-@ predicate HtDiff S T D = (ht S) - (ht T) == D @-}
-{-@ predicate EqHt S T = (ht S) == (ht T) @-}
-
-{-@ predicate LeftHeavy T = bFac T == 1 @-}
-{-@ predicate RightHeavy T = bFac T == -1 @-}
-
-{-@ measure balanced :: Tree a -> Bool
-balanced (Nil) = true
-balanced (Tree v l r) = ((ht l) <= (ht r) + 1)
-                        && (ht r <= ht l + 1)
-                        && (balanced l)
-                        && (balanced r)
-@-}
-
-{-@ type AVLTree = {v: Tree a | balanced v} @-}
diff --git a/tests/pos/AVLRJ.hs b/tests/pos/AVLRJ.hs
deleted file mode 100644
--- a/tests/pos/AVLRJ.hs
+++ /dev/null
@@ -1,111 +0,0 @@
-{- Example of AVL trees by michaelbeaumont -}
-
-{-@ LIQUID "--no-termination" @-}
-
-module AVL (Tree, empty, singleton, insert, ht, bFac, balanced) where
-
--- Basic functions
-data Tree a = Nil | Tree { tKey :: a, tLeft ::Tree a, tRight :: Tree a} deriving Show
-
-{-@ data Tree [ht] a = Nil
-                     | Tree { tKey   :: a
-                            , tLeft  :: Tree {v:a | v < tKey }
-                            , tRight :: Tree {v:a | tKey < v }
-                            }
-  @-}
-
-{-@ measure ht @-}
-{-@ ht          :: Tree a -> Nat @-}
-ht              :: Tree a -> Int
-ht Nil          = 0
-ht (Tree _ l r) = if (ht l) > (ht r) then (1 + ht l) else (1 + ht r)
-
-{-@ invariant {v:Tree a | 0 <= bFac v + 1 && bFac v <= 1 } @-}
-
-
-{-@ measure bFac @-}
-{-@ bFac :: t:Tree a -> {v:Int | 0 <= v + 1 && v <= 1} @-}
-bFac Nil          = 0
-bFac (Tree _ l r) = ht l - ht r
-
-{-@ htDiff :: s:Tree a -> t: Tree a -> {v: Int | HtDiff s t v} @-}
-htDiff :: Tree a -> Tree a -> Int
-htDiff l r = ht l - ht r
-
--- | Empty
-{-@ empty :: {v: AVLTree a | ht v == 0} @-}
-empty = Nil
-
--- | Singleton
-{-@ singleton :: a -> {v: AVLTree a | ht v == 1 }@-}
-singleton a = Tree a Nil Nil
-
--- | Insert
-
-{-@ predicate PostInsert S T = ((bFac T == 0) => (EqHt T S || ht T == 1)) && (EqHt T S || HtDiff T S 1) @-}
-
-{-@ insert :: a -> s: AVLTree a -> {t: AVLTree a | PostInsert s t } @-}
-insert :: (Ord a) => a -> Tree a -> Tree a
-insert a Nil = singleton a
-insert a t@(Tree v _ _) = case compare a v of
-    LT -> insL a t
-    GT -> insR a t
-    EQ -> t
-
-{-@ insL :: x:a -> s:{AVLTree a | x < tKey s && ht s > 0} -> {t: AVLTree a | PostInsert s t } @-}
-insL a (Tree v l r)
-  | siblDiff == 2 && bl' == 1  = rebalanceLL v l' r
-  | siblDiff == 2 && bl' == -1 = rebalanceLR v l' r
-  | siblDiff <= 1              = Tree v l' r
-  where
-    l'                       = insert a l
-    siblDiff                 = htDiff l' r
-    bl'                      = bFac l'
-
-{-@ insR :: x:a -> s:{AVLTree a | tKey s < x && ht s > 0} -> {t: AVLTree a | PostInsert s t } @-}
-insR a (Tree v l r)
-  | siblDiff == 2 && br' == 1  = rebalanceRL v l r'
-  | siblDiff == 2 && br' == -1  = rebalanceRR v l r'
-  | siblDiff <= 1            = Tree v l r'
-  where
-    siblDiff                 = htDiff r' l
-    r'                       = insert a r
-    br'                      = bFac r'
-
-
-{-@ rebalanceLL :: x:a -> l:{AVLL a x | LeftHeavy l } -> r:{AVLR a x | HtDiff l r 2} -> {t:AVLTree a | EqHt t l} @-}
-rebalanceLL v (Tree lv ll lr) r                 = Tree lv ll (Tree v lr r)
-
-{-@ rebalanceLR :: x:a -> l:{AVLL a x | RightHeavy l } -> r:{AVLR a x | HtDiff l r 2} -> {t: AVLTree a | EqHt t l } @-}
-rebalanceLR v (Tree lv ll (Tree lrv lrl lrr)) r = Tree lrv (Tree lv ll lrl) (Tree v lrr r)
-
-{-@ rebalanceRR :: x:a -> l: AVLL a x -> r:{AVLR a x | RightHeavy r && HtDiff r l 2 } -> {t: AVLTree a | EqHt t r } @-}
-rebalanceRR v l (Tree rv rl rr)                 = Tree rv (Tree v l rl) rr
-
-{-@ rebalanceRL :: x:a -> l: AVLL a x -> r:{AVLR a x | LeftHeavy r && HtDiff r l 2} -> {t: AVLTree a | EqHt t r } @-}
-rebalanceRL v l (Tree rv (Tree rlv rll rlr) rr) = Tree rlv (Tree v l rll) (Tree rv rlr rr)
-
--- Test
-main = do
-    mapM_ print [a,b,c,d]
-  where
-    a = singleton 5
-    b = insert 2 a
-    c = insert 3 b
-    d = insert 7 c
-
--- Liquid Haskell
-
-{-@ predicate HtDiff S T D = ht S - ht T == D @-}
-{-@ predicate EqHt S T     = HtDiff S T 0     @-}
-{-@ predicate LeftHeavy  T = bFac T == 1      @-}
-{-@ predicate RightHeavy T = bFac T == -1     @-}
-
-{-@ measure balanced @-}
-balanced              :: Tree a -> Bool
-balanced (Nil)        = True
-balanced (Tree v l r) = ht l - ht r <= 1 && ht l - ht r >= -1 && balanced l && balanced r
-
-{-@ type AVLTree a   = {v: Tree a | balanced v} @-}
-{-@ type AVLL a X    = AVLTree {v:a | v < X}    @-}
-{-@ type AVLR a X    = AVLTree {v:a | X < v}    @-}
diff --git a/tests/pos/Abs.hs b/tests/pos/Abs.hs
deleted file mode 100644
--- a/tests/pos/Abs.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Abs () where
-
-absN ::  (Num a, Ord a) => a -> a
-absN x = if x > 0 then x else (-x)
-
-absI ::  Int -> Int
-absI x = if x > 0 then x else (-x)
-
-absL :: [Int] -> [Int]
-absL xs = (0 : xs) ++ [] 
-
---incI ::  Int -> Int
---incI = (+) 1
-
-x0 = absN 4
-x1 = absI (-5)
-
---x2 = absI (incI 2)
--- x3 = absI (-3)
diff --git a/tests/pos/Ackermann.hs b/tests/pos/Ackermann.hs
deleted file mode 100644
--- a/tests/pos/Ackermann.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Ackermann () where
-
-{-@ ack :: m:Nat -> n:Nat -> Nat / [m, n]@-}
-ack :: Int -> Int -> Int
-ack m n
-    | m == 0          = n + 1
-    | m > 0 && n == 0 = ack (m-1) 1
-    | m > 0 && n >  0 = ack (m-1) (ack m (n-1))
diff --git a/tests/pos/AdtList0.hs b/tests/pos/AdtList0.hs
deleted file mode 100644
--- a/tests/pos/AdtList0.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-
-{-@ LIQUID "--exact-data-cons" @-}
-
-module AdtList where 
-
-data LL a = Emp | Cons a (LL a) 
-
-{-@ test1 :: n:Int -> m:Int -> {v:() | Cons n (Cons m Emp) == Cons m (Cons n Emp)} -> {n == m} @-}
-test1 :: Int -> Int -> () -> ()
-test1 _ _ _ = ()
-
diff --git a/tests/pos/AdtList1.hs b/tests/pos/AdtList1.hs
deleted file mode 100644
--- a/tests/pos/AdtList1.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-@ LIQUID "--exact-data-cons" @-}
-
-module AdtList where 
-
-data LL a = Emp | Cons a (LL a) 
-
-{-@ test1 :: n:Int -> m:Int -> {v:() | Cons n (Cons m Emp) == Cons m (Cons n Emp)} -> {n == m} @-}
-test1 :: Int -> Int -> () -> ()
-test1 _ _ _ = ()
-
-{-@ reflect sz @-}
-sz :: LL a -> Int 
-sz Emp         = 0 
-sz (Cons x xs) = 1 + sz xs
diff --git a/tests/pos/AdtList2.hs b/tests/pos/AdtList2.hs
deleted file mode 100644
--- a/tests/pos/AdtList2.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-
-module AdtList where 
-
-data LL a = Emp | Cons a (LL a) 
-
-{-@ test1 :: n:Int -> m:Int -> {v:() | Cons n (Cons m Emp) == Cons m (Cons n Emp)} -> {n == m} @-}
-test1 :: Int -> Int -> () -> ()
-test1 _ _ _ = ()
-
-{-@ reflect sz @-}
-sz :: LL a -> Int 
-sz Emp = 0 
-sz (Cons x xs) = 1 + sz xs
-
-{-@ test2 :: () -> { sz (Cons 1 (Cons 2 Emp)) == 2 } @-}
-test2 () = () 
diff --git a/tests/pos/AdtList3.hs b/tests/pos/AdtList3.hs
deleted file mode 100644
--- a/tests/pos/AdtList3.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-@ LIQUID "--exact-data-cons" @-}
-
-module AdtList where 
-
-data LL a = Emp | Cons a (LL a) 
-
-{-@ data LL [sz] @-}
-
-{-@ test1 :: n:Int -> m:Int -> {v:() | Cons n (Cons m Emp) == Cons m (Cons n Emp)} -> {n == m} @-}
-test1 :: Int -> Int -> () -> ()
-test1 _ _ _ = ()
-
-{-@ measure sz @-}
-{-@ sz :: LL a -> Nat @-}
-sz :: LL a -> Int 
-sz Emp         = 0 
-sz (Cons x xs) = 1 + sz xs
-
-
-app :: LL a -> LL a -> LL a 
-app Emp z         = z 
-app (Cons x xs) z = Cons x (app xs z)
diff --git a/tests/pos/AdtList4.hs b/tests/pos/AdtList4.hs
deleted file mode 100644
--- a/tests/pos/AdtList4.hs
+++ /dev/null
@@ -1,30 +0,0 @@
--- | THIS FAILS because we don't support < and > for ADT and,
---   we instantiate the output of `app` with quals like `v < xs` `v > xs` etc.
---   where v, xs are of the ADT sort `List a`.
-
-{-@ LIQUID "--exact-data-cons" @-}
-
-module AdtList where 
-
-data LL a = Emp | Cons a (LL a) 
-
-{-@ data LL [sz] @-}
-
-{-@ test1 :: n:Int -> m:Int -> {v:() | Cons n (Cons m Emp) == Cons m (Cons n Emp)} -> {n == m} @-}
-test1 :: Int -> Int -> () -> ()
-test1 _ _ _ = ()
-
-{-@ app :: xs:LL a -> ys:LL a -> {v:LL a | sz v = sz xs + sz ys} @-} 
-app = go 
-  where 
-    {-@ go :: xs:LL a -> ys:LL a -> {v:LL a | sz v = sz xs + sz ys} @-} 
-    go Emp ys         = ys 
-    go (Cons x xs) ys = Cons x (go xs ys)
-
-{-@ measure sz @-}
-{-@ sz :: LL a -> Nat @-}
-sz :: LL a -> Int 
-sz Emp         = 0 
-sz (Cons x xs) = 1 + sz xs
-
-
diff --git a/tests/pos/AdtList5.hs b/tests/pos/AdtList5.hs
deleted file mode 100644
--- a/tests/pos/AdtList5.hs
+++ /dev/null
@@ -1,15 +0,0 @@
--- | The current code for lifting ADTs cannot deal with the case when there
---   are "holes" in the data-decl specification, presumably because the lifting
---   happens BEFORE the holes are resolved.
-
-{-@ LIQUID "--exact-data-cons" @-}
-
-module AdtList where
-
-data Zing = ZZ (Int -> ())
-
-{-@ data Zing = ZZ { unZZ :: Int -> { 5 < 10 } } @-}
-
-{-@ bob :: Nat @-}
-bob :: Int
-bob = 12
diff --git a/tests/pos/AdtPeano0.hs b/tests/pos/AdtPeano0.hs
deleted file mode 100644
--- a/tests/pos/AdtPeano0.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-{-@ LIQUID "--exact-data-con" @-}
-{-@ LIQUID "--higherorder"    @-}
-
-module Peano where
-
--- | The code currently works if we add the below, but thats icky.
---   First, lets get this file to work _without_ the below.
-
-{- data Influx = Silly Int @-}
-
-data Influx = Silly Int
-
-{-@ reflect thing @-}
-thing :: Influx -> Int
-thing (Silly a) = a + 1
-
-{-@ reflect bling @-}
-bling :: Influx -> Int
-bling (Silly b) = b
-
-{-@ test :: m:Influx -> { thing m = 1 + bling m} @-}
-test :: Influx -> (Int, Int)
-test m = (thing m, bling m)
diff --git a/tests/pos/AdtPeano1.hs b/tests/pos/AdtPeano1.hs
deleted file mode 100644
--- a/tests/pos/AdtPeano1.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-@ LIQUID "--exact-data-con"                      @-}
-{-@ LIQUID "--higherorder"                         @-}
-
-module Peano where
-
-data Influx = Silly { goo :: Int }
-
-{-@ test1:: n:Int -> m:Int -> { v:() | Silly n == Silly m } -> { n == m } @-}
-test1 :: Int -> Int -> () -> Int
-test1 n m z = moo (Silly n) + moo (Silly m)
-
-{-@ reflect moo @-}
-moo :: Influx -> Int
-moo (Silly a) = a
diff --git a/tests/pos/AmortizedQueue.hs b/tests/pos/AmortizedQueue.hs
deleted file mode 100644
--- a/tests/pos/AmortizedQueue.hs
+++ /dev/null
@@ -1,85 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--maxparams=3"    @-}
-
-module LazyQueue where
-
--- Source: Okasaki, JFP 1995
--- http://www.westpoint.edu/eecs/SiteAssets/SitePages/Faculty%20Publication%20Documents/Okasaki/jfp95queue.pdf
-
---------------------------------------------------------------------------------
--- | Sized Lists
---------------------------------------------------------------------------------
-
-data SList a = SL { size  :: Int
-                  , elems :: [a]
-                  }
-
-{-@ type SListN a N = {v:SList a | size v = N} @-}
-
--- | Invariant: `size` is really the size:
-
-{-@ data SList a = SL { size  :: Nat
-                      , elems :: {v:[a] | len v = size}
-                      }
-  @-}
-
--- | Size function actually returns the size: (Duh!)
-
-{-@ size :: q:SList a -> {v:Nat | v = size q} @-}
-
--- | Non-Empty Lists:
-
-{-@ type NEList a = {v:SList a | size v > 0} @-}
-
-
-{-@ nil          :: SListN a 0  @-}
-nil              = SL 0 []
-
-{-@ cons         :: a -> xs:SList a -> SListN a {size xs + 1}   @-}
-cons x (SL n xs) = SL (n+1) (x:xs)
-
-{-@ tl           :: xs:NEList a -> SListN a {size xs - 1}  @-}
-tl (SL n (_:xs)) = SL (n-1) xs
-tl _             = die "never"
-
-{-@ hd           :: xs:NEList a -> a @-}
-hd (SL _ (x:_))  = x 
-hd _             = die "never"
-
-
---------------------------------------------------------------------------------
--- | Sized Lists
---------------------------------------------------------------------------------
-
-data Queue a = Q  { left   :: SList a
-                  , right  :: SList a
-                  }
-
--- | Invariant: `|right|` <= `|left|`
-
-{-@ data Queue a = Q { left  :: SList a 
-                     , right :: {v:SList a | size v <= size left}
-                     }
-  @-}
-
-
-
-emp = Q nil nil
-
-qsize         :: Queue a -> Int
-qsize (Q l r) = size l + size r
-
-insert e (Q l r) = makeq l (e `cons` r)
-
-{-@ makeq :: l:_ -> r:{ _ | size r <= size l + 1} -> _  @-}
-makeq l r
-  | size r <= size l = Q l r
-  | otherwise        = Q (rot l r nil) nil
-
-{-@ rot :: l:_ -> r:SListN _ {1 + size l} -> a:_ -> {v:_ | size v = size l + size r + size a} @-}
-rot l r a
-  | size l == 0      = (hd r) `cons` a
-  | otherwise        = (hd l) `cons` (rot (tl l) (tl r) ((hd r) `cons` a))
-
-{-@ die :: {v:_ | false} -> a @-}
-die x = error x
diff --git a/tests/pos/Assume.hs b/tests/pos/Assume.hs
deleted file mode 100644
--- a/tests/pos/Assume.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Assume where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ assume foo :: {v:Bool | v} @-}
-foo = False
-
-bar = liquidAssertB foo
diff --git a/tests/pos/AssumedRecursive.hs b/tests/pos/AssumedRecursive.hs
deleted file mode 100644
--- a/tests/pos/AssumedRecursive.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Foo where
-
-{-@ assume foo :: a -> a @-}
-foo :: a -> a
-foo f = foo f
diff --git a/tests/pos/AutoSize.hs b/tests/pos/AutoSize.hs
deleted file mode 100644
--- a/tests/pos/AutoSize.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module AutoSize where
-
-{-@ autosize List @-}
-data List a = N | Cons a (List a)
-nil = N
-cons = Cons 
-
-foo :: List a -> Int 
-foo N = 0 
-foo (Cons x xs) = 1 + foo xs 
-
-
-{-@ autosize Exp @-}
-data Exp = EConst Int | EBinOp Int Exp Exp 
-expSize :: Exp -> Int
-expSize (EConst _) = 0
-expSize (EBinOp _ e1 e2) = 1 + (expSize e1) + (expSize e2)
diff --git a/tests/pos/AutoTerm.hs b/tests/pos/AutoTerm.hs
deleted file mode 100644
--- a/tests/pos/AutoTerm.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-module Isort where
-
-data SortedList a =
-     Mt
-   | Ln{h :: a, t :: SortedList a}
-
-{-@ data SortedList [sortedlen] @-}
-
-
-{-@ measure sortedlen @-}
-{-@ sortedlen :: SortedList a -> {v:Int | v >= 0 } @-}
-sortedlen :: SortedList a -> Int
-sortedlen Mt = 0
-sortedlen (Ln x xs) = 1 + sortedlen xs
-
-{-@ insert :: (Ord a) => a -> lst:(SortedList a) -> {v: SortedList a | sortedlen v = sortedlen lst + 1} / [sortedlen lst]@-}
-insert :: (Ord a) => a -> SortedList a -> SortedList a
-insert x Mt = Ln x Mt
-insert y (Ln x xs)
-  | y < x     = Ln y (Ln x xs)
-  | otherwise = Ln x (insert y xs)
-
-{-@ isort :: (Ord a) => lst:[a] -> {v : SortedList a | sortedlen v = len lst} @-}
-isort :: (Ord a) => [a] -> SortedList a
-isort [] = Mt -- note can't use [] here
-isort (x:xs) = insert x (isort xs)
diff --git a/tests/pos/AutoTerm1.hs b/tests/pos/AutoTerm1.hs
deleted file mode 100644
--- a/tests/pos/AutoTerm1.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Isort where
-
-data F = F | C Int F  
-
-{-@ data F [lenF] @-}
-
-{-@ measure lenF @-}
-lenF :: F -> Int
-
-
-{-@ lenF :: xs:F -> {v:Int | v >= 0 } @-}
-lenF F = 0
-lenF (C _ x) = 1 + lenF x 
-
-
-bar :: F -> Int 
-bar F = 0 
-bar (C x xs) = x + bar xs 
diff --git a/tests/pos/Automate.hs b/tests/pos/Automate.hs
deleted file mode 100644
--- a/tests/pos/Automate.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-module Automate where
-   
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-
-import Language.Haskell.Liquid.ProofCombinators 
-
-fibA :: Int -> Int 
-{-@ reflect fibA @-}
-{-@ fibA :: Nat -> Nat @-}
-fibA i | i <= 1 = i
-      | otherwise = fibA (i-1) + fibA (i-2)
-
--- fibUp :: Int -> Proof 
-{- fibUp :: i:Nat -> {fibA i <= fibA (i+1)} @-}
--- fibUp i 
--- | i <= 2    = trivial
--- | otherwise = fibUp (i-1) &&& fibUp (i-2) *** QED 
-
-
-fibUp :: Int -> Proof
-{-@ fibUp :: i:Nat -> {fibA i <= fibA (i+1)} @-}
-fibUp 0 = trivial *** QED
-fibUp 1 = trivial *** QED
-fibUp i = fibUp (i-1) &&& fibUp (i-2) *** QED 
-
-{- prop :: () -> {fibA 30 == 832040 } @-}
--- prop :: () -> Proof 
--- prop _ = trivial  
diff --git a/tests/pos/Avg.hs b/tests/pos/Avg.hs
deleted file mode 100644
--- a/tests/pos/Avg.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-{-@ LIQUID "--prune-unsorted" @-}
-
-module Avg where
-
-{-@ measure sumF :: [Double] -> Double
-    sumF([]) = 0.0
-    sumF(x:xs) = x + (sumF xs)
-  @-}
-
-{-@ measure lenF :: [Double] -> Double
-    lenF([])   = 0.0
-    lenF(x:xs) = (1.0) + (lenF xs)
-  @-}
-
-{-@ expression Avg Xs = ((sumF Xs) / (lenF Xs))  @-}
-
-{-@ meansD :: xs:{v:[Double] | 0.0 < lenF v } -> {v:Double | v = Avg xs} @-}
-meansD :: [Double] -> Double
-meansD xs = sumD xs / lenD xs
-
-{-@ lenD :: xs:[Double] -> {v:Double | v = lenF xs } @-}
-lenD :: [Double] -> Double
-lenD [] = 0.0
-lenD (x:xs) = 1.0 + lenD xs
-
-{-@ sumD :: xs:[Double] -> {v:Double | v = sumF xs } @-}
-sumD :: [Double] -> Double
-sumD [] = 0.0
-sumD (x:xs) = x + sumD xs
diff --git a/tests/pos/BST.hs b/tests/pos/BST.hs
deleted file mode 100644
--- a/tests/pos/BST.hs
+++ /dev/null
@@ -1,82 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-module BST (blen) where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@
-data Bst [blen] k v <l :: x0:k -> x1:k -> Bool, r :: x0:k -> x1:k -> Bool>
-  = Empty
-  | Bind { bKey   :: k
-         , bValue :: v
-         , bLeft  :: Bst <l, r> (k <l bKey>) v
-         , bRight :: Bst <l, r> (k <r bKey>) v }
-  @-}
-
-
-
-{-@ measure blen @-}
-blen :: (Bst k v) -> Int
-{-@ blen :: (Bst k v) -> Nat @-}
-blen(Empty)        = 0
-blen(Bind k v l r) = 1 + (blen l) + (blen r)
-
-data Bst k v = Empty | Bind k v (Bst k v) (Bst k v)
-
-{-@
-data Pair k v <p :: x0:k -> x1:k -> Bool, l :: x0:k -> x1:k -> Bool, r :: x0:k -> x1:k -> Bool>
-  = P (fld0 :: k) (fld1 :: v) (tree :: Bst <l, r> (k <p fld0>) v)
-  @-}
-
-data Pair k v = P k v (Bst k v)
-
--- insert :: (Eq k, Ord k) => k -> v -> Bst k v -> Bst k v
-insert k v Empty  = Bind k v Empty Empty
-insert k v (Bind k' v' l r)
-  | k == k'       = Bind k v l r
-  | k < k'        = Bind k' v' (insert k v l) r
-  | otherwise     = Bind k' v' l (insert k v r)
-
--- delete :: (Eq k, Ord k) => k -> Bst k v -> Bst k v
-delete _ Empty = Empty
-delete k' (Bind k v l r)
-  | k' == k =
-      case r of
-       Empty   -> l
-       _       -> let P kmin vmin r' = getMin r in Bind kmin vmin l r'
-  | k' < k = Bind k v (delete k' l) r
-  | otherwise = Bind k v l (delete k' r)
-
-getMin (Bind k v Empty rt) = P k v rt
-getMin (Bind k v lt rt)    = P k0min v0min (Bind k v l' rt)
-   where P k0min v0min l' = getMin lt
-getMin _                   = unsafeError "getMin"
-
-chkMin x Empty            = liquidAssertB True
-chkMin x (Bind k v lt rt) = liquidAssertB (x<k) && chkMin x lt && chkMin x rt
-
-chk Empty            = liquidAssertB True
-chk (Bind k v lt rt) = chk lt && chk rt && chkl k lt && chkr k rt
-
-chkl k Empty = liquidAssertB True
-chkl k (Bind kl _ _ _) = liquidAssertB (kl < k)
-
-chkr k Empty = liquidAssertB True
-chkr k (Bind kr _ _ _) = liquidAssertB (k < kr)
-
-key, key1, val, val1 :: Int
-key = choose 0
-val = choose 1
-key1 = choose 0
-val1 = choose 1
-
-bst = insert key val $ insert key1 val1 Empty
-
-mkBst = foldl (\t (k, v) -> insert k v t) Empty
-
-prop        = chk bst
-prop1       = chk $ mkBst $ zip [1..] [1..]
-propDelete  = chk $ delete 1 bst
-propMin     = chkMin x t
-    where pr  = getMin bst
-          P x _ t = pr
diff --git a/tests/pos/BST000.hs b/tests/pos/BST000.hs
deleted file mode 100644
--- a/tests/pos/BST000.hs
+++ /dev/null
@@ -1,69 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-module BST where
-
-import Language.Haskell.Liquid.Prelude
-
-
-{-@
-data Bst [blen] k v <l :: root:k -> x1:k -> Bool, r :: root:k -> x1:k -> Bool>
-  = Empty
-  | Bind (key   :: k) 
-         (value :: v) 
-         (left  :: Bst <l, r> (k <l key>) v) 
-         (right :: Bst <l, r> (k <r key>) v)
-  @-}
-
-{-@ measure blen @-}
-{-@ lazy blen @-}
-{-@ blen :: Bst k v -> Nat  @-}
-blen :: Bst k v -> Int
-blen Empty = 0 
-blen (Bind k v l r) = 1 + blen l + blen r 
-
-data Bst k v = Empty | Bind k v (Bst k v) (Bst k v)
-
-{-@ type OBST k a = Bst <{\root v -> v < root }, {\root v ->  v > root}> k a @-}
-
-{-@ chkMin :: (Ord k) => x:k -> OBST {v:k | x < v} a -> Bool @-}
-chkMin :: (Ord k) => k -> Bst k a -> Bool
-chkMin x Empty            = liquidAssertB True  
-chkMin x (Bind k v lt rt) = liquidAssertB (x<k) && chkMin x lt && chkMin x rt
-
-{-@
-data Pair k v <p :: x0:k -> x1:k -> Bool, l :: x0:k -> x1:k -> Bool, r :: x0:k -> x1:k -> Bool>
-  = P (fld0 :: k) (fld1 :: v) (tree :: Bst <l, r> (k <p fld0>) v) 
-  @-}
-
-data Pair k v = P k v (Bst k v)
-
-{-@ getMin :: OBST k v -> (k, OBST k v)<\x -> {v:Bst {k:k | x < k} v | true}>@-}
-getMin :: Bst k v -> (k, Bst k v)
-getMin (Bind k v Empty rt) = (k, rt)
-{- 
-getMin (Bind k v lt rt)    = case getMin lt of
-                               (k0, l') -> (k0, Bind k v l' rt) 
-getMin _                   = error "getMin"
--}
-{-@ propMin :: (Ord k) => OBST k a -> Bool @-}
-propMin :: (Ord k) => Bst k a -> Bool
-propMin bst = chkMin x t
-    where (x, t) = getMin bst 
-
-
-zoo :: Int -> (Int, Int)
-zoo x = (x, x + 1)
-
-
-m = zoo 12
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/BinarySearch.hs b/tests/pos/BinarySearch.hs
deleted file mode 100644
--- a/tests/pos/BinarySearch.hs
+++ /dev/null
@@ -1,43 +0,0 @@
-{- | By Gabriel Gonzalez, from:
-     http://www.haskellforall.com/2015/12/compile-time-memory-safety-using-liquid.html
--}
-
-module BinarySearch (binarySearch) where
-
-import Data.Vector as V
-
-binarySearch :: Ord a => a -> V.Vector a -> Maybe Int
-binarySearch x v =
-    if V.length v == 0
-    then Nothing
-    else loop x v 0 (V.length v - 1)
-
-midpoint :: Int -> Int -> Int
-midpoint lo hi = (lo + hi) `div` 2
-
-{-@
-loop
-    :: Ord a
-    => x  : a
-    -> v  : V.Vector a
-    -> lo : { lo : Int | 0  <= lo && lo < vlen v }
-    -> hi : { hi : Int | lo <= hi && hi < vlen v }
-    -> Maybe Int
-    / [hi - lo]
-@-}
-loop :: Ord a => a -> V.Vector a -> Int -> Int -> Maybe Int
-loop x v lo hi = do
-    let mid = lo + ((hi - lo) `div` 2) -- midpoint lo hi
-    if x < v ! mid
-    then do
-        let hi' = mid - 1
-        if lo <= hi'
-        then loop x v lo hi'
-        else Nothing
-    else if v ! mid < x
-    then do
-        let lo' = mid + 1
-        if lo' <= hi
-        then loop x v lo' hi
-        else Nothing
-    else Just mid
diff --git a/tests/pos/BinarySearchOverflow.hs b/tests/pos/BinarySearchOverflow.hs
deleted file mode 100644
--- a/tests/pos/BinarySearchOverflow.hs
+++ /dev/null
@@ -1,42 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module BinarySearch where
-
-import Prelude hiding (Num(..))
-import CheckedNum 
-import Data.Vector as V 
-import Language.Haskell.Liquid.Prelude (liquidAssert) 
-
-{-@ invariant {v: V.Vector a | 0 <= vlen v && BoundInt (vlen v)} @-}
-
-binarySearch :: Ord a => a -> V.Vector a -> Maybe Int
-binarySearch x v 
-  | 0 < n     = loop x v 0 (n - 1)
-  | otherwise = Nothing 
-  where n     = V.length v
-
-{-@ type Idx Vec = {v:Nat | v < vlen Vec} @-}
-
-{-@ type BoundNat = {v:Nat | BoundInt v} @-}
-
-{-@ loop :: Ord a => a -> vec: V.Vector a -> lo:Idx vec -> {hi:Idx vec | lo <= hi} -> Maybe Nat @-}
-loop :: Ord a => a -> V.Vector a -> Int -> Int -> Maybe Int
-loop x v lo hi = do
-    let mid = lo + ((hi - lo) `div` 2) -- SAFE
-    -- let mid =  (hi + lo) `div` 2       -- UNSAFE
-    if x < v ! mid
-    then do
-        let hi' = mid - 1
-        if lo <= hi'
-        then loop x v lo hi'
-        else Nothing
-    else if v ! mid < x
-    then do
-        let lo' = mid + 1 -- incr mid
-        if lo' <= hi
-        then loop x v lo' hi
-        else Nothing
-    else Just mid
-    
-
-
diff --git a/tests/pos/Books.hs b/tests/pos/Books.hs
deleted file mode 100644
--- a/tests/pos/Books.hs
+++ /dev/null
@@ -1,50 +0,0 @@
-{-# LANGUAGE CPP #-}
-
-#define DISCOUNT_PERCENTAGE   2
-#define BOOK_THRESHOLD        2
-
-module Books where
-
-calculateDiscount' :: Customer -> Int -> Int
-
----------------------------------------------------------------------------------------
--- 1. Define: Types of customers
----------------------------------------------------------------------------------------
-
-data Customer = Vip | Reg deriving (Eq)
-
----------------------------------------------------------------------------------------
--- 2. Define: Discountable Customers and Discounts
----------------------------------------------------------------------------------------
-
-{-@ inline customerGetsDiscount @-}
-customerGetsDiscount :: Customer -> Int -> Bool
-customerGetsDiscount c i = c == Vip && i >= BOOK_THRESHOLD
-
-{-@ inline discount @-}
-discount :: Int -> Int
-discount bookCount = (bookCount - BOOK_THRESHOLD) * DISCOUNT_PERCENTAGE
-
-{-@ type Discount i = {v:Int | v == discount i} @-}
-
----------------------------------------------------------------------------------------
--- 3. Policy: Only compute discounts for discountable customers
----------------------------------------------------------------------------------------
-
-{-@ calculateDiscount' :: c:Customer -> i:{Int | customerGetsDiscount c i} -> Discount i @-}
-calculateDiscount' c i = discount i
-
----------------------------------------------------------------------------------------
--- 4. Implement: Code to compute discounts, if suitable, is accepted
----------------------------------------------------------------------------------------
-
-{-@ calculateDiscount :: Int -> Nat -> Nat @-}
-calculateDiscount userId bookCount
-  | getsDiscount = calculateDiscount' c bookCount
-  | otherwise    = 0
-  where
-    getsDiscount = customerGetsDiscount c bookCount
-    c            = customerType userId
-
-customerType :: Int -> Customer
-customerType = undefined
diff --git a/tests/pos/CasesToLogic.hs b/tests/pos/CasesToLogic.hs
deleted file mode 100644
--- a/tests/pos/CasesToLogic.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-{-@ LIQUID "--exact-data-cons"     @-}
-{-@ LIQUID "--higherorder"        @-}
-
-module StringIndexing where
-
-import Prelude hiding (mappend)
-
-data D = D Int Int 
-
-{-@ reflect mappend @-}
-mappend :: D -> D -> D 
-
-{-@ mappend :: x:D -> D -> {v:D | v == x} @-}
-mappend x@(D i1 i2) (D i3 i4) = x
-
diff --git a/tests/pos/Cat.hs b/tests/pos/Cat.hs
deleted file mode 100644
--- a/tests/pos/Cat.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-{-# LANGUAGE GADTs #-}
-
-module Cat where
-
-import Control.Category
-import Prelude hiding ((.), id)
-
-
-{- 
-class Category cat where
-  id :: cat a a 
-  (.) :: cat b c -> cat a b -> cat a c
--}
-
-data Accum a b where
-  Accum :: s -> Accum a b
-
--- | We can pass the outputs of one 'Accum' as the inputs of the next.
-instance Category Accum where
-  Accum  i1 . Accum  i2 = Accum  (i1, i2)
diff --git a/tests/pos/CharLiterals.hs b/tests/pos/CharLiterals.hs
deleted file mode 100644
--- a/tests/pos/CharLiterals.hs
+++ /dev/null
@@ -1,8 +0,0 @@
--- see #1286 
-module Example where
-
-{-@ fails :: {v:Bool | v} @-}
-fails =  'a' == 'a'
-
-{-@ ok :: {v:Bool | v} @-}
-ok = "a" == "a"
diff --git a/tests/pos/CheckedNum.hs b/tests/pos/CheckedNum.hs
deleted file mode 100644
--- a/tests/pos/CheckedNum.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-module CheckedNum where
-
--- Hiding numeric operations, because they get by default translated to SMT equivalent
-import Prelude hiding (Num(..))
-
-import qualified Prelude as Prelude 
-
-class CheckedNum a where 
-  (+) :: a -> a -> a 
-  (-) :: a -> a -> a 
-
-{-@ predicate BoundInt X = 0 < X + 10000 && X < 10000 @-}
-
-instance CheckedNum Int where
-{-@ instance CheckedNum Int where 
-      - :: x:Int -> y:{v:Int | BoundInt (x - v)} -> {v: Int | v == x - y} ;  
-      + :: x:Int -> y:{v:Int | BoundInt (x + v)} -> {v: Int | v == x + y} 
-  @-}
-	x - y = (Prelude.-) x y  
-
-	x + y = (Prelude.+) x y  
-
-
-
diff --git a/tests/pos/Chunks.hs b/tests/pos/Chunks.hs
deleted file mode 100644
--- a/tests/pos/Chunks.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Chunks where
-
-{-@ LIQUID "--scrape-imports" @-}
-
-
-{-@ type SafeChunkSize = {v:Int | 1 < v } @-}
-
-{-@ type Pos = {v:Int | 0 < v} @-}
-
-{-@ predicate ValidChunk V XS N 
-      = if len XS == 0 
-          then (len V == 0) 
-          else (((1 < len XS && 1 < N) => (len V  < len XS)) 
-            && ((len XS <= N ) => len V == 1))            
-  @-}
-
-{-@ chunks :: n:Pos -> xs:[a] -> {v:[[a]] | ValidChunk v xs n } / [len xs] @-}
-chunks :: Int -> [a] -> [[a]]
-chunks _ [] = [] 
-chunks n xs = let (x, xs') = splitAt n xs in x:chunks n xs'
diff --git a/tests/pos/Class.hs b/tests/pos/Class.hs
deleted file mode 100644
--- a/tests/pos/Class.hs
+++ /dev/null
@@ -1,89 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-{-@ LIQUID "--no-termination" @-}
-module Class () where
-
-import Language.Haskell.Liquid.Prelude
-import Prelude hiding (sum, length, (!!), Functor(..))
--- import qualified Prelude as P
-
-{-@ qualif Size(v:Int, xs:a): v = size xs @-}
-
-{-@ qualif Size(v:Int, xs:MList a): v = size xs @-}
-
-{-@ data MList a = Nil | Cons (hd::a) (tl::(MList a)) @-}
-data MList a = Nil | Cons a (MList a)
-
-{-@ (!!) :: xs:MList a -> {v:Nat | v < (size xs)} -> a @-}
-(!!) :: MList a -> Int -> a
-Nil         !! _ = liquidError "impossible"
-(Cons x _)  !! 0 = x
-(Cons _ xs) !! i = xs !! (i - 1)
-
-{-@ class measure size :: forall a. a -> Int @-}
-
-{-@ class Sized s where
-      size :: forall a. x:s a -> {v:Nat | v = size x}
-  @-}
-class Sized s where
-  size :: s a -> Int
-
-instance Sized MList where
-  {-@ instance measure size :: MList a -> Int
-      size (Nil)       = 0
-      size (Cons x xs) = 1 + size xs
-    @-}
-  size = length
-
-{-@ length :: xs:MList a -> {v:Nat | v = size xs} @-}
-length :: MList a -> Int
-length Nil         = 0
-length (Cons _ xs) = 1 + length xs
-
-{-@ bob :: xs:MList a -> {v:Nat | v = size xs} @-}
-bob :: MList a -> Int
-bob = length
-
-
-instance Sized [] where
-  {-@ instance measure size :: [a] -> Int
-      size ([])   = 0
-      size (x:xs) = 1 + (size xs)
-    @-}
-  size [] = 0
-  size (_:xs) = 1 + size xs
-
-{-@ class (Sized s) => Indexable s where
-      index :: forall a. x:s a -> {v:Nat | v < size x} -> a
-  @-}
-class (Sized s) => Indexable s where
-  index :: s a -> Int -> a
-
-
-instance Indexable MList where
-  index = (!!)
-
-{-@ sum :: Indexable s => s Int -> Int @-}
-sum :: Indexable s => s Int -> Int
-sum xs = go max 0
-  where
-    max = size xs
-    go (d::Int) i
-      | i < max   = index xs i + go (d-1) (i+1)
-      | otherwise = 0
-
-
-{-@ sumMList :: MList Int -> Int @-}
-sumMList :: MList Int -> Int
-sumMList xs = go max 0
-  where
-    max = size xs
-    go (d::Int) i
-      | i < max   = index xs i + go (d-1) (i+1)
-      | otherwise = 0
-
-
-{-@ x :: {v:MList Int | (size v) = 3}  @-}
-x :: MList Int
-x = 1 `Cons` (2 `Cons` (3 `Cons` Nil))
-
-foo = liquidAssert $ size (Cons 1 Nil) == size [7]
diff --git a/tests/pos/Class2.hs b/tests/pos/Class2.hs
deleted file mode 100644
--- a/tests/pos/Class2.hs
+++ /dev/null
@@ -1,83 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-{-@ LIQUID "--no-termination" @-}
-module Class () where
-
-import Language.Haskell.Liquid.Prelude
-import Prelude hiding (sum, length, (!!), Functor(..))
-
-data MList a = Nil | Cons a (MList a)
-
-{-@ (!!) :: xs:MList a -> {v:Nat | v < sz xs} -> a @-}
-(!!) :: MList a -> Int -> a
-(Cons x _)  !! 0 = x
-(Cons _ xs) !! i = xs !! (i - 1)
-
-{-@ class measure sz :: forall a. a -> Int  @-}
-
-{-@ class Sized s where
-      size :: forall a. x:s a -> {v:Nat | v = sz x}
-  @-}
-class Sized s where
-  size :: s a -> Int
-
-instance Sized MList where
-  {-@ instance measure sz :: MList a -> Int
-      sz (Nil)       = 0
-      sz (Cons x xs) = 1 + sz xs
-    @-}
-  size = length
-
-{-@ length :: xs:MList a -> {v:Nat | v = sz xs} @-}
-length :: MList a -> Int
-length Nil         = 0
-length (Cons _ xs) = 1 + length xs
-
-{-@ bob :: xs:MList a -> {v:Nat | v = sz xs} @-}
-bob :: MList a -> Int
-bob = length
-
-
-instance Sized [] where
-  {-@ instance measure sz :: [a] -> Int
-      sz ([])   = 0
-      sz (x:xs) = 1 + (sz xs)
-    @-}
-  size [] = 0
-  size (_:xs) = 1 + size xs
-
-{-@ class (Sized s) => Indexable s where
-      index :: forall a. x:s a -> {v:Nat | v < sz x} -> a
-  @-}
-class (Sized s) => Indexable s where
-  index :: s a -> Int -> a
-
-
-
-instance Indexable MList where
-  index = (!!)
-
-{-@ sum :: Indexable s => s Int -> Int @-}
-sum :: Indexable s => s Int -> Int
-sum xs = go n 0
-  where
-    n = size xs
-    go (d::Int) i
-      | i < n     = index xs i + go (d-1) (i+1)
-      | otherwise = 0
-
-
-{-@ sumMList :: MList Int -> Int @-}
-sumMList :: MList Int -> Int
-sumMList xs = go max 0
-  where
-    max = size xs
-    go (d::Int) i
-      | i < max   = index xs i + go (d-1) (i+1)
-      | otherwise = 0
-
-
-{-@ mlist3 :: {v:MList Int | sz v = 3}  @-}
-mlist3 :: MList Int
-mlist3 = 1 `Cons` (2 `Cons` (3 `Cons` Nil))
-
-foo = liquidAssert $ size (Cons 1 Nil) == size [1]
diff --git a/tests/pos/ClassReg.hs b/tests/pos/ClassReg.hs
deleted file mode 100644
--- a/tests/pos/ClassReg.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-module Compose where
-
-
-data ST s a = ST {runState :: s -> (a,s)}
-
-{-@ data ST s b <r :: s -> b -> Bool> 
-      = ST (runState :: x:s -> (b<r x>, s)) @-}
-
-
-class MM m where
-  bind :: m a -> (a -> m b) -> m b
-  cmp  :: m a -> m b -> m b
-
-instance MM (ST s) where
-  cmp m f = bind m (\_ -> f) 
-
-
- 
diff --git a/tests/pos/Client521.hs b/tests/pos/Client521.hs
deleted file mode 100644
--- a/tests/pos/Client521.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Client521 where
-
-import Lib521 
-
-{-@ bar :: { xs : [a] | size xs > 1 } -> [a] @-}
-bar :: [a] -> [a]
-bar xs = xs 
-
-{-@ bing :: xs:[a] -> {v:Int | v = size xs} @-}
-bing :: [a] -> Int 
-bing [] = 0 
-bing (x:xs) = 1 + bing xs 
diff --git a/tests/pos/ClojurVector.hs b/tests/pos/ClojurVector.hs
deleted file mode 100644
--- a/tests/pos/ClojurVector.hs
+++ /dev/null
@@ -1,104 +0,0 @@
-{-
-https://twitter.com/BrandonBloom/status/701261641971683328
-https://github.com/clojure/clojure/blob/d5708425995e8c83157ad49007ec2f8f43d8eac8/src/jvm/clojure/lang/PersistentVector.java#L148-L164
--}
-
-{-@ LIQUID "--no-termination" @-}
-
-module PVec (height, arrayFor) where
-
-import qualified Language.Haskell.Liquid.Prelude as Gas
-import qualified Data.Vector as V
-
-import Data.Bits
-
--- | Generalized tree with branching 32. We "store" the height in each `Node`
---   only because it is useful in the specification (each sub-tree has the same height).
---   The height is _never_ computed and so can be eliminated at run-time.
-
-data Tree a = Leaf a
-            | Node Int (V.Vector (Tree a))
-
-
--- | Specify "height" of a tree
-
-{-@ measure height @-}
-{-@ height :: Tree a -> Nat @-}
-height :: Tree a -> Int
-height (Leaf _)    = 0
-height (Node h ls) = 1 + h
-
--- | Specify tree must be "balanced", each node has 32 children
-
-{-@ data Tree a = Leaf a
-                | Node { ht   :: Nat
-                       , kids :: VectorN (TreeH a ht) 32
-                       }
-  @-}
-
--- | ListN is a list of a given size N
-
-{-@ type VectorN a N     = {v:V.Vector a | vlen v = N }  @-}
-
--- | TreeH is a tree of given height H
-
-{-@ type TreeH     a H = {v:Tree a | height v = H}       @-}
-
--- | Nodes and Leaves are simply trees with non-zero and zero heights resp.
-
-{-@ type NodeT a = {v:Tree a | height v > 0} @-}
-{-@ type LeafT a = {v:Tree a | height v = 0} @-}
-
-
--- | Vector stores the height
-data Vec a = Vec { vShift  :: Int    -- ^ height
-                 , vTree   :: Tree a -- ^ actual nodes
-                 }
-
--- | Refined type relates height of the `vTree` with `vShift`
-
-{-@ data Vec a = Vec { vShift :: Nat
-                     , vTree  :: TreeLevel a vShift
-                     }
-  @-}
-
-{-@ type TreeLevel a L = {v:Tree a | L = 5 * height v} @-}
-
---------------------------------------------------------------------------------
-
-arrayFor :: Int -> Vec a -> Maybe a
-arrayFor i (Vec l n) = loop i l n
-
-{-@ loop :: i:Int -> level:Int -> TreeLevel a level -> Maybe a @-}
-loop :: Int -> Int -> Tree a -> Maybe a
-loop i level node
-      | level > 0 = let b      = shift i (- level) `mask` 31  -- get child index
-                        node'  = getNode node b               -- get child
-                        level' = level - 5                    -- next level
-                    in
-                        loop i level' node'
-
-      | otherwise = Just (getValue node)
-
--- TODO: refine types of bit-ops, currently use an "assume"
-
-{-@ mask :: x:Int -> y:Nat -> {v:Nat | v <= y} @-}
-mask :: Int -> Int -> Int
-mask x y = Gas.liquidAssume (0 <= r && r <= y) r
-  where
-     r   = x .&. y
-
--- | These are the "cast" operations, except now proven safe.
-
-{-@ getNode :: t:NodeT a -> {v:Nat | v <= 31} -> {v:Tree a | height v = height t - 1}  @-}
-getNode :: Tree a -> Int -> Tree a
-getNode (Node _ ts) n = ts V.! n
-getNode _           _ = impossible "provably safe"
-
-{-@ getValue :: LeafT a -> a @-}
-getValue :: Tree a -> a
-getValue (Leaf x) = x
-getValue _        = impossible "provably safe"
-
-{-@ impossible :: {v:String | false} -> a @-}
-impossible = error
diff --git a/tests/pos/Coercion.hs b/tests/pos/Coercion.hs
deleted file mode 100644
--- a/tests/pos/Coercion.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-
-{-@ LIQUID "--no-termination" @-}
-
-module Encoding where
-
-data F a = F a
-data BS = BS (F Int)
-bar :: IO (F Int)
-bar = undefined
-
-foo = undefined
-
-
--- start ::  F Int -> IO BS
-start fp = foo fp $ go
-  where go ptr = do
-         -- ensure :: (IO BS ~ IO b) => IO b -> IO b
-         let ensure act
-               | False = act
-               | otherwise = do
-                   fp' <- bar
-                   start fp -- ((start fp) `cast` (IO BS ~ IO b)) 
-         ensure $ return $ BS fp
-      
-
-
diff --git a/tests/pos/CommentedOut.hs b/tests/pos/CommentedOut.hs
deleted file mode 100644
--- a/tests/pos/CommentedOut.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Nats where 
-
-{- {-@ nats :: [Nat] @-} -}
-nats :: [Int]
-nats = [-1,0,1,2,3,4,5,6,7,8,9,10]
-
diff --git a/tests/pos/CompareConstraints.hs b/tests/pos/CompareConstraints.hs
deleted file mode 100644
--- a/tests/pos/CompareConstraints.hs
+++ /dev/null
@@ -1,86 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-module Foo where
-
-import Language.Haskell.Liquid.Prelude
-
-
-{-@ mycmp :: forall <p :: a -> Bool, q :: a -> Bool>. 
-           {x::a<p>, y::a<q> |- a <: {v:a | x <= y} } 
-           Ord a => 
-           [a<p>] -> [a<q>] -> Bool @-}
-mycmp :: Ord a => [a] -> [a] -> Bool
-mycmp (x:_) (_:y:_) = liquidAssert (x <= y) True
-
-
-{-@ mycmp' :: forall <p :: a -> Bool, q :: a -> Bool>. 
-           {x::a<p>, y::a<q> |- a <: {v:a | x <= y} } 
-           Ord a => 
-           a<p> -> a<q> -> Bool @-}
-mycmp' :: Ord a => a -> a -> Bool
-mycmp' x y = liquidAssert (x <= y) True
-
-bar :: Bool
-bar = let w = choose 0 in 
-      let x = w + 1 in 
-      let y = w - 1 in 
-      let z = w + 2 in 
-      mycmp [x, y, x] [z, x, z]
-
-
-bar' :: Bool
-bar' = let w = choose 0 in 
-      let x = w + 1 in 
-      let y = w - 1 in 
-      let z = w + 2 in 
-      mycmp' x z    
-{-
-
------------------
-
-
-data Dyn = Int Int | String String | Bool Bool 
-type Key = String
-data Box = Record Key Dyn
-
-emp :: Box
-emp = undefined
-
-class Value v where
-  toDyn   :: v -> Dyn
-  fromDyn :: Dyn -> v
- 
-put :: (Value v) => Key -> v -> Box -> Box
-put k v b = insert k b (toDyn v) 
-
-get :: (Value v) => Box -> Key -> v
-get = undefined
-
-rj  :: Box
-rj  = put "name"     "Ranjit" 
-    $ put "age"      10
-    $ put "sleeping" True
-    $ emp 
-
-out = "My name is " ++ get rj "name"
-
-
-sumXY box x y = get box x + get box y
-
--}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 
diff --git a/tests/pos/Constraints.hs b/tests/pos/Constraints.hs
deleted file mode 100644
--- a/tests/pos/Constraints.hs
+++ /dev/null
@@ -1,51 +0,0 @@
-module Compose where
-
-{-@ 
-cmp :: forall < pref :: b -> Bool, postf :: b -> c -> Bool
-              , pre  :: a -> Bool, postg :: a -> b -> Bool
-              , post :: a -> c -> Bool
-              >. 
-       {xx::a<pre>, w::b<postg xx> |- c<postf w> <: c<post xx>}
-       {ww::a<pre> |- b<postg ww> <: b<pref>}
-       f:(y:b<pref> -> c<postf y>)
-    -> g:(z:a<pre > -> b<postg z>)
-    -> x: a<pre> -> c<post x>
-@-}
-
-cmp :: (b -> c)
-    -> (a -> b)
-    ->  a -> c
-
-cmp f g x = f (g x)    
-
-
-
-{-@ incr :: x:Nat -> {v:Nat | v == x + 1} @-}
-incr :: Int -> Int
-incr x = x + 1
-
-
-{-@ incr2 :: x:Nat -> {v:Nat | v == x + 2} @-}
-incr2 :: Int -> Int
-incr2 = cmp incr incr
-
-
-{-@ plus1 :: x:Nat -> {v:Nat | v == x + 20} @-}
-plus1 :: Int -> Int
-plus1 x = x + 20
-
-{-@ plus2 :: x:{v:Nat | v > 10} -> {v:Nat | v == x + 22} @-}
-plus2 :: Int -> Int
-plus2 x = x + 22
-
-{-@ plus42 :: x:Nat -> {v:Nat | v == x + 42} @-}
-plus42 :: Int -> Int
-plus42 = cmp plus2 plus1
-
-
-
-
-
-
-
-
diff --git a/tests/pos/ConstraintsAppend.hs b/tests/pos/ConstraintsAppend.hs
deleted file mode 100644
--- a/tests/pos/ConstraintsAppend.hs
+++ /dev/null
@@ -1,45 +0,0 @@
-module ListSort () where
-
-{-@ LIQUID "--no-termination" @-}
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ type OList a = [a]<{\x v -> v >= x}> @-}
-
-
-{-@ assume (++) :: forall <p :: a -> Bool, q :: a -> Bool, r :: a -> Bool>.
-        {x::a<p> |- a<q> <: {v:a| x <= v}} 
-        {a<p> <: a<r>} 
-        {a<q> <: a<r>} 
-        Ord a => OList (a<p>) -> OList (a<q>) -> OList a<r> @-}
-{-@ app :: forall <p :: a -> Bool, q :: a -> Bool, r :: a -> Bool>.
-        {x::a<p> |- a<q> <: {v:a| x <= v}} 
-        {a<p> <: a<r>} 
-        {a<q> <: a<r>} 
-        Ord a => OList (a<p>) -> OList (a<q>) -> OList a<r> @-}
-app :: Ord a => [a] -> [a] -> [a]
-app []     ys = ys
-app (x:xs) ys = x:(app xs ys) 
-
-takeL :: Ord a => a -> [a] -> [a]
-{-@ takeL :: Ord a => x:a -> [a] -> [{v:a|v<=x}] @-}
-takeL x []     = []
-takeL x (y:ys) = if (y<x) then y:(takeL x ys) else takeL x ys
-
-takeGE :: Ord a => a -> [a] -> [a]
-{-@ takeGE :: Ord a => x:a -> [a] -> [{v:a|v>=x}] @-}
-takeGE x []     = []
-takeGE x (y:ys) = if (y>=x) then y:(takeGE x ys) else takeGE x ys
-
-
-{-@ quicksort :: (Ord a) => xs:[a] -> [a]<{\fld v -> (v >= fld)}>  @-}
-quicksort []     = []
-quicksort (x:xs) = xsle ++ (x:xsge)
-  where xsle = quicksort (takeL x xs)
-        xsge = quicksort (takeGE x xs)
-
-{-@ qsort :: (Ord a) => xs:[a] -> [a]<{\fld v -> (v >= fld)}>  @-}
-qsort []     = []
-qsort (x:xs) = (qsort [y | y <- xs, y < x]) ++ (x:(qsort [z | z <- xs, z >= x])) 
-
-
diff --git a/tests/pos/CountMonad.hs b/tests/pos/CountMonad.hs
deleted file mode 100644
--- a/tests/pos/CountMonad.hs
+++ /dev/null
@@ -1,85 +0,0 @@
-{-@ LIQUID "--no-pattern-inline" @-}
-
-module Count () where
-
-{-@ measure count :: Count a -> Int @-}
-
-{-@ Count :: x:a -> {v:Count a | v == Count x } @-}
-data Count a = Count a
-
-instance Functor Count where
-	fmap = undefined
-instance Applicative Count where
-  pure  = undefined
-  (<*>) = undefined
-
-instance Monad Count where
-{-@
-instance Monad Count where
-  >>=    :: forall <r :: Count a -> Bool, p :: Count b -> Bool, q :: Count b -> Bool>.
-            {x::Count a <<r>>, y :: Count b <<p>>  |- {v:Count b | count v == count x + count y} <: Count b <<q>>}
-            Count a <<r>> -> (a -> Count b<<p>>) -> Count b <<q>> ;
-  >>     :: x:Count a -> y:Count b -> {v:Count b | count v == count x + count y};
-  return :: a -> {v:Count a | count v == 0 }
-@-}
-  return x        = let r = Count x in assertCount 0 (Count x)
-  (Count x) >>= f = let r = f x in assertCount (getCount (Count x) + getCount r) r
-  x >> y = assertCount (getCount x + getCount y) y
-
-
-
-{-@ assume assertCount :: i:Int -> x:Count a -> {v:Count a | v == x && count v == i } @-}
-assertCount :: Int -> Count a -> Count a
-assertCount _ x = x
-
-{-@ assume getCount :: x:Count a -> {v:Int | v == count x } @-}
-getCount :: Count a -> Int
-getCount _ = 0
-
-{-@ makeCount :: x:a -> {v:Count a | v == Count x} @-}
-makeCount = Count
-
-{-@ assume incr :: a -> {v:Count a | count v == 1 } @-}
-incr :: a -> Count a
-incr = Count
-
-{-@ assume unit :: {v:Count () | count v == 0 } @-}
-unit = Count ()
-
-{-@ foo :: a -> {v:Count a | count v == 0 }  @-}
-foo :: a -> Count a
-foo y = return y
-
-{-@ test1 :: {v:Count () | count v == 0 } @-}
-test1 :: Count ()
-test1 = do
-  unit
-  unit
-  unit
-
-{-@ test2 :: {v:Count () | count v == 1 } @-}
-test2 = do
-  unit
-  y <- incr ()
-  unit
-  foo y
-  unit
-
-{-@ test3 :: {v:Count () | count v == 3 } @-}
-test3 = do
-  unit
-  incr ()
-  unit
-  incr ()
-  unit
-  incr ()
-  unit
-
-
-
-{-@ replicateTick :: n:Nat -> a -> {v:Count [a] | count v == n} @-}
-replicateTick :: Int -> a -> Count [a]
-replicateTick 0 x = return []
-replicateTick n x = do incr ()
-                       xs <- replicateTick (n-1) x
-                       return ( x : xs )
diff --git a/tests/pos/DB00.hs b/tests/pos/DB00.hs
deleted file mode 100644
--- a/tests/pos/DB00.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "totality" @-}
-
-module DataBase (values) where
-
-{-@ values :: forall <rr2 :: key -> val -> Bool>.
-      k:key -> [Dict <rr2> key val]  -> [val<rr2 k>] @-}
-values :: key -> [Dict key val]  -> [val]
-values k = map (go k)
-  where
-    {-@ go :: forall <rr1 :: k -> v -> Bool>. 
-              i:k -> Dict <rr1> k v -> v<rr1 i>  @-}
-    go k (D _ f) = f k
-
-data Dict key val = D {ddom :: [key], dfun :: key -> val}
-
-{-@ data Dict key val <rr :: key -> val -> Bool>
-      = D ( ddom :: [key])
-          ( dfun :: i:key -> val<rr i>)
-  @-}
diff --git a/tests/pos/DataBase.hs b/tests/pos/DataBase.hs
deleted file mode 100644
--- a/tests/pos/DataBase.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module DataBase where
-
-data Rec s v = R (s -> v)
-type DBRec = Rec String Value
-
-get :: String -> DBRec -> Value 
-get i (R a) = a i
-
-set :: String -> Value -> DBRec -> DBRec
-set i x (R a) = R $ \k -> if k == i then x else a k
-
-{-@ empty :: Rec {v:String|0=1} {v : DataBase.Value | v = DataBase.BOT} @-}
-empty :: Rec String Value
-empty = R $ const BOT
-
-data Value = BOT
-           | INT Int 
-           | BOOL Bool 
-           | STRING String
---            | VEC Value Int
-
-
-append a1 a2 = \k -> case a1 k of 
-                     BOT -> a2 k
-                     v   -> v
diff --git a/tests/pos/DepData.hs b/tests/pos/DepData.hs
deleted file mode 100644
--- a/tests/pos/DepData.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-module DepData where
-
-data Foo = Foo { thing1 :: Int, thing2 :: Int }
-
-{-@ data Foo where
-      Foo :: pig:Int -> thing2:{v : Int | pig < v} -> Foo
-  @-}
-
-{- data Foo = Foo { thing1 :: Int, thing2 :: {v : Int | thing1 < v } } @-}
-
-{-@ bog :: Foo -> Nat @-}
-bog :: Foo -> Int
-bog (Foo x y) = y - x
diff --git a/tests/pos/DepTriples.hs b/tests/pos/DepTriples.hs
deleted file mode 100644
--- a/tests/pos/DepTriples.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module DependentTriples  where
-
-{-@ LIQUID "--savequery" @-}
-
-{-@ type INCR3 = (Int, Int, Int)<{\a b -> a < b}, {\b a c -> b < c }>@-}
-
-{-@ assume incr3 :: INCR3 @-}
-incr3 :: (Int, Int, Int)
-incr3 = undefined 
-
-{-@ uincr3 :: INCR3 @-}
-uincr3 :: (Int, Int, Int)
-uincr3 = let (x, y, z) = incr3 in (x + 1, y + 1, z +1 )
diff --git a/tests/pos/DependentPairs.hs b/tests/pos/DependentPairs.hs
deleted file mode 100644
--- a/tests/pos/DependentPairs.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module DPairs where
-
-
-{-@ incrPair :: Int -> (x::Int, {v:Int | x <= v}) @-}
-incrPair :: Int -> (Int, Int)
-incrPair i = (i, i+1)
-
-
-{-@ incrPair3 :: Int -> (x::Int, y::{v:Int | x <= v}, {v:Int | y <= v}) @-}
-incrPair3 :: Int -> (Int, Int, Int)
-incrPair3 i = (i, i+1, i+3)
-
-{-@ assertDep :: (Int, Int)<\x -> {v:Int | x <= v}> -> {b:Bool | b} @-}
-assertDep :: (Int, Int) -> Bool 
-assertDep (x, y) = x <= y
-
-
-
-{-@ goalDep :: (x::Int, {v:Int | x <= v}) -> {b:Bool | b} @-}
-goalDep :: (Int, Int) -> Bool 
-goalDep (x, y) = x <= y
diff --git a/tests/pos/DependentPairsFun.hs b/tests/pos/DependentPairsFun.hs
deleted file mode 100644
--- a/tests/pos/DependentPairsFun.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module DPairs where
-
-
-{-@ ex :: (y::Int, () -> {v:() | 0 < y } )
-      -> (y::Int, {v:() | 0 < y})
-@-}
-ex ::(Int,() -> ()) -> (Int,())
-ex (y, pxToqxy) =  (y,pxToqxy ())
diff --git a/tests/pos/Eval.hs b/tests/pos/Eval.hs
deleted file mode 100644
--- a/tests/pos/Eval.hs
+++ /dev/null
@@ -1,54 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--prune-unsorted" @-}
-
-module Eval (eval) where
-
-import Language.Haskell.Liquid.Prelude (liquidError)
-import Prelude hiding (lookup)
-import Data.Set (Set (..))
-
-{-@ embed Set as Set_Set @-}
-
-type Val  = Int
-
-type Bndr = String
-
-data Expr = Const Int
-          | Var   Bndr
-          | Plus  Expr Expr
-          | Let   Bndr Expr Expr
-
-type Env  = [(Bndr, Val)]
-
-------------------------------------------------------------------
-{-@ lookup :: x:Bndr -> {v:Env | Set_mem x (vars v)} -> Val @-}
-lookup :: Bndr -> Env -> Val
----------------------  -------------------------------------------
-lookup x ((y,v):env)
-  | x == y             = v
-  | otherwise          = lookup x env
-lookup x []            = liquidError "Unbound Variable"
-
-------------------------------------------------------------------
-{-@ eval :: g:Env -> CExpr g -> Val @-}
-------------------------------------------------------------------
-eval env (Const i)     = i
-eval env (Var x)       = lookup x env
-eval env (Plus e1 e2)  = eval env e1 + eval env e2
-eval env (Let x e1 e2) = eval env' e2
-  where
-    env'               = (x, eval env e1) : env
-
-{-@ type CExpr G = {v:Expr | Set_sub (free v) (vars G)} @-}
-
-{-@ measure vars :: Env -> (Set Bndr)
-    vars ([])    = {v | Set_emp v }
-    vars (b:env) = {v | v = Set_cup (Set_sng (fst b)) (vars env)}
-  @-}
-
-{-@ measure free       :: Expr -> (Set Bndr)
-    free (Const i)     = {v | Set_emp v}
-    free (Var x)       = {v | v = Set_sng x}
-    free (Plus e1 e2)  = {v | v = Set_cup (free e1) (free e2)}
-    free (Let x e1 e2) = {v | v = Set_cup (free e1) (Set_dif (free e2) (Set_sng x))}
-  @-}
diff --git a/tests/pos/EvalQuery.hs b/tests/pos/EvalQuery.hs
deleted file mode 100644
--- a/tests/pos/EvalQuery.hs
+++ /dev/null
@@ -1,104 +0,0 @@
-
-{-@ LIQUID "--reflection"      @-}
-{-@ LIQUID "--no-termination"  @-}
-{-@ LIQUID "--ple" @-}
-
-module Query where
-
-import Prelude hiding (filter, all)
-
-data Atom  = VarX
-           | VarY
-           | Const Int
-
-data Query = Le  Atom  Atom
-           | And Query Query
-           | Or  Query Query
-
-{-@ data Blob  = B { xVal :: Int, yVal :: Int } @-}
-data Blob  = B { xVal :: Int, yVal :: Int }
-
-{-@ reflect evalA @-}
-evalA :: Atom -> Blob -> Int
-evalA VarX  b     = xVal b
-evalA VarY  b     = yVal b
-evalA (Const n) _ = n
-
-{-@ reflect evalQ @-}
-evalQ :: Query -> Blob -> Bool
-evalQ (Le  a1 a2) b = (evalA a1 b) <= (evalA a2 b)
-evalQ (And q1 q2) b = (evalQ q1 b) && (evalQ q2 b)
-evalQ (Or  q1 q2) b = (evalQ q1 b) || (evalQ q2 b)
-
-{- reflect all @-}
--- all []     = True
--- all (b:bs) = b && all bs
--- evalQs   :: [Query] -> Blob -> Bool
--- evalQs b = e
-
-
-{-@ filter :: f:(a -> Bool) -> [a] -> [{v:a | f v}] @-}
-filter :: (a -> Bool) -> [a] -> [a]
-filter f (x:xs)
-  | f x         = x : filter f xs
-  | otherwise   =     filter f xs
-filter _ []     = []
-
-{-@ filterQ :: q:Query -> [Blob] -> [{b:Blob | evalQ q b}] @-}
-filterQ :: Query -> [Blob] -> [Blob]
-filterQ q = filter (evalQ q)
-
-{-@ test1 :: [Blob] -> [{v: Blob | xVal v <= 10}] @-}
-test1   = filterQ q1
-  where
-  q1    = (VarX `Le` (Const 10))
-
-{-@ test2 :: [Blob] -> [{v: Blob | xVal v <= 10 && yVal v <= 20}] @-}
-test2  = filterQ q2
-  where
-  q2   = (VarX `Le` (Const 10)) `And` (VarY `Le` (Const 20))
-
-{- filterQ :: q:Query -> [Blob] -> [{b:Blob | evalQ q b}] @-}
--- filterQ :: Query -> [Blob] -> [Blob]
--- filterQ q []     = []
--- filterQ q (b:bs)
--- /  | evalQ q b    = b : filterQ q bs
--- /  | otherwise    =     filterQ q bs
-
-{-@ reflect isPos @-}
-isPos :: Int -> Bool
-isPos n = n > 0
-
-{-@ reflect isNeg @-}
-isNeg :: Int -> Bool
-isNeg n = n < 0
-
-{-@ positives :: [Int] -> [{v:Int | v > 0}] @-}
-positives xs = filter isPos xs
-
-{-@ negatives :: [Int] -> [{v:Int | v < 0}] @-}
-negatives xs = filter isNeg xs
-
-
-{- F* version, which doesn't work...
-
-let isPos n = n > 0
-
-val filter : f:('a -> bool) -> list 'a -> list (x:'a{f x}) 
-let rec filter f xs = match xs with 
-    | []    -> []
-    | x::ys -> let zs = filter f ys in 
-               if f x then x :: zs else zs 
-                                   
-type pos = x:int{0 < x}
-
-(* this is verified ... *)
-val pos1 : int -> option pos 
-let pos1 z = if isPos z then Some z else None
-
-(* ... but this is not *)
-val positives : list int -> list pos               
-let positives xs = filter isPos xs  
-
--}
-
diff --git a/tests/pos/Even.hs b/tests/pos/Even.hs
deleted file mode 100644
--- a/tests/pos/Even.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Even where 
-
-{-@ type Even = {v:Int | v mod 2 = 0} @-}
-
-{-@ notEven :: Int -> Even @-}
-notEven :: Int -> Int
-notEven x = x * 2
diff --git a/tests/pos/Even0.hs b/tests/pos/Even0.hs
deleted file mode 100644
--- a/tests/pos/Even0.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Even () where
-
-{-@ isEven :: n:Nat -> Bool / [n, 0]@-}
-{-@ isOdd  :: m:Nat -> Bool / [m, 1] @-}
-isEven, isOdd  :: Int -> Bool
-
-isEven 0 = True
-isEven n = isOdd  $ n - 1
-
-isOdd  k = not $ isEven k
-
-
-
diff --git a/tests/pos/ExactADT6.hs b/tests/pos/ExactADT6.hs
deleted file mode 100644
--- a/tests/pos/ExactADT6.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-{-@ LIQUID "--no-adt"         @-}
-{-@ LIQUID "--exact-data-con" @-}
-
-{-# LANGUAGE ExistentialQuantification, KindSignatures, TypeFamilies, GADTs #-}
-
-module ExactADT6 where
-
-{-@ data EntityField typ where
-        BlobXVal :: EntityField {v:Int | v >= 0}
-      | BlobYVal :: EntityField Int
-  @-}
-
-data EntityField typ where
-  BlobXVal :: EntityField Int
-  BlobYVal :: EntityField Int
-
-{-@ blobXVal :: EntityField {v:Int | v >= 0} @-}
-blobXVal :: EntityField Int
-blobXVal = BlobXVal
diff --git a/tests/pos/ExactGADT.hs b/tests/pos/ExactGADT.hs
deleted file mode 100644
--- a/tests/pos/ExactGADT.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-# LANGUAGE  GADTs #-}
-
-module Query where
-
-{-@ data Field typ where
-        FldX :: Field Int
-      | FldY :: Field Int
-  @-}
-
-data Field typ where
-  FldX :: Field Int
-  FldY :: Field Int
-
-bob = FldX 
diff --git a/tests/pos/ExactGADT0.hs b/tests/pos/ExactGADT0.hs
deleted file mode 100644
--- a/tests/pos/ExactGADT0.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-{-@ LIQUID "--no-adt"         @-}
-{-@ LIQUID "--exact-data-con" @-}
-
-
-module Zong where
-
-data Value a where
-  VInt  :: Int  -> Value Int
-  VBool :: Bool -> Value Bool
diff --git a/tests/pos/ExactGADT1.hs b/tests/pos/ExactGADT1.hs
deleted file mode 100644
--- a/tests/pos/ExactGADT1.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-@ LIQUID "--exact-data-con" @-}
-
-{-# LANGUAGE  GADTs #-}
-
-module Query where
-
-data Field typ where
-  FldX :: Field Int
-  FldY :: Field Int
-
-poogle = FldY
diff --git a/tests/pos/ExactGADT2.hs b/tests/pos/ExactGADT2.hs
deleted file mode 100644
--- a/tests/pos/ExactGADT2.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-{-@ LIQUID "--exact-data-con" @-}
-
-{-# LANGUAGE  GADTs #-}
-
-module Query where
-
-{-@ data Field typ where
-        FldX :: Field Int
-      | FldY :: Field Int
-  @-}
-
-data Field typ where
-  FldX :: Field Int
-  FldY :: Field Int
-
-poogle = FldY
diff --git a/tests/pos/ExactGADT6.hs b/tests/pos/ExactGADT6.hs
deleted file mode 100644
--- a/tests/pos/ExactGADT6.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-{-@ LIQUID "--no-adt"         @-}
-{-@ LIQUID "--exact-data-con" @-}
-
-{-# LANGUAGE ExistentialQuantification, KindSignatures, TypeFamilies, GADTs #-}
-
-module ExactGADT6 where
-
-class PersistEntity record where
-    data EntityField record ty :: *
-
-instance PersistEntity Blob where
-    {-@ data EntityField Blob typ where
-            BlobXVal :: EntityField Blob {v:Int | v >= 0}
-          | BlobYVal :: EntityField Blob Int
-    @-}
-    data EntityField Blob typ where
-        BlobXVal :: EntityField Blob Int
-        BlobYVal :: EntityField Blob Int
-
-
-{-@ data Blob  = B { xVal :: {v:Int | v >= 0}, yVal :: Int } @-}
-data Blob = B { xVal :: Int, yVal :: Int }
-
-{-@ blobXVal :: EntityField Blob {v:Int | v >= 0} @-}
-blobXVal :: EntityField Blob Int
-blobXVal = BlobXVal
-
--- OK
--- testUpdateQuery :: () -> Update Blob Int
--- testUpdateQuery () = createUpdate blobXVal 3
-
--- BAD
--- testUpdateQueryFail :: () -> Update Blob Int
--- testUpdateQueryFail () = createUpdate blobXVal (-1)
diff --git a/tests/pos/FFI.hs b/tests/pos/FFI.hs
deleted file mode 100644
--- a/tests/pos/FFI.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-# LANGUAGE ForeignFunctionInterface #-}
-module Main where
-
-import Foreign.C.Types
-
-{-@ embed CInt as int @-}
-{-@ embed Integer as int @-}
-
-{-@ assume c_foo :: x:{CInt | x > 0} -> IO {v:CInt | v = x} @-}
-foreign import ccall unsafe "foo.c foo" c_foo
-  :: CInt -> IO CInt
-
-main :: IO ()
-main = print . fromIntegral =<< c_foo 1
diff --git a/tests/pos/Fail.hs b/tests/pos/Fail.hs
deleted file mode 100644
--- a/tests/pos/Fail.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Fail where 
-
-{-@ fail incr @-}
-{-@ incr :: x:Int -> {v:Int |  x < v } @-}
-incr :: Int -> Int 
-incr x = x 
-
-{-@ fail unsafe @-}
-{-@ unsafe :: () -> { 0 == 1 } @-}
-unsafe :: () -> () 
-unsafe _ = () 
diff --git a/tests/pos/Fib0.hs b/tests/pos/Fib0.hs
deleted file mode 100644
--- a/tests/pos/Fib0.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--higherorder"                         @-}
-{-@ LIQUID "--ple" @-}
-
-module Fib0 where 
-
-{-@ reflect fibExp @-}
-{-@ fibExp :: Nat -> Nat @-}
-fibExp :: Int -> Int
-fibExp n 
-  | n == 0    = 0 
-  | n == 1    = 1 
-  | otherwise = fibExp (n-2) + fibExp (n-1)
-
--- 0 => 0
--- 1 => 1 
--- 2 => 1 
--- 3 => 2 
-
-{-@ test :: a -> { fibExp 3 == 2 } @-}  
-test  :: a -> ()
-test _ = ()
diff --git a/tests/pos/FibEq.hs b/tests/pos/FibEq.hs
deleted file mode 100644
--- a/tests/pos/FibEq.hs
+++ /dev/null
@@ -1,47 +0,0 @@
-{-@ LIQUID "--higherorder"                         @-}
-{-@ LIQUID "--ple" @-}
-
-module FibEq where 
-
-fibInv  :: Int -> Int -> () 
-fibLin  :: Int -> Int 
-fibLin' :: Int -> Int -> Int -> Int 
-fibExp  :: Int -> Int 
-fibEq   :: Int -> () 
-
--- | Exponential `fib` implementation --------------------------------
-
-{-@ reflect fibExp @-}
-{-@ fibExp :: Nat -> Nat @-}
-fibExp n 
-  | n == 0    = 0 
-  | n == 1    = 1 
-  | otherwise = fibExp (n-2) + fibExp (n-1)
-
--- | Linear `fib` implementation ------------------------------------ 
-
-{-@ reflect fibLin' @-}
-{-@ fibLin' :: Nat -> Nat -> Nat -> Nat @-}
-fibLin' n a b 
-  | n == 0    = b 
-  | otherwise = fibLin' (n - 1) (a + b) a
-
-{-@ reflect fibLin @-}
-{-@ fibLin :: Nat -> Nat @-}
-fibLin n = fibLin' n 1 0
-
--- | Invariant relating the two implementations -------------------- 
-
-{-@ fibInv :: d:Nat -> u:Nat -> 
-      {fibLin' d (fibExp (1+u)) (fibExp u) = fibExp (d+u)} 
-  @-}
-fibInv d u 
-  | d == 0    = () 
-  | otherwise = fibInv (d-1) (u+1)
-
--- | Equivalence of two implementations ---------------------------- 
-
-{-@ fibEq :: n:Nat -> {fibLin n = fibExp n} @-}
-fibEq n = fibInv n 0 
-
-
diff --git a/tests/pos/FingerTree.hs b/tests/pos/FingerTree.hs
deleted file mode 100644
--- a/tests/pos/FingerTree.hs
+++ /dev/null
@@ -1,159 +0,0 @@
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--no-adt"         @-}
-{-@ LIQUID "--ple"            @-}
-
-module FingerTree where 
-
-import Language.Haskell.Liquid.ProofCombinators 
-
-{-@ measure digitSize @-}
-digitSize :: Digit a -> Int
-digitSize (One {}) = 1
-digitSize (Two {}) = 2
-digitSize (Three {}) = 3
-digitSize (Four {}) = 4
-
-data Digit a
-    = One a
-    | Two a a
-    | Three a a a
-    | Four a a a a
-    deriving (Show)
-
-data Node a = Node2 {a2::a, b2::a} | Node3 {a3::a, b3::a, c3:: a}
-    deriving (Show)
-
-data FingerTree a
-    = Empty
-    | Single a
-    | Deep (Digit a) (FingerTree (Node a)) (Digit a)
-    deriving Show
-
-{-@ reflect fingerTreeSize @-}
-fingerTreeSize :: FingerTree a -> Int
-fingerTreeSize t = size to1 t 
-
-{-@ reflect size @-}
-size :: (a -> Int) -> FingerTree a -> Int
-size _ Empty        = 0
-size f (Single a)   = f a
-size f (Deep l m r) = digitS f l + size (nodeS f) m + digitS f r
-
-{-@ reflect digitS @-} 
-digitS :: (a -> Int) -> Digit a -> Int
-digitS f (One a)        = f a
-digitS f (Two a b)      = f a + f b
-digitS f (Three a b c)  = f a + f b + f c
-digitS f (Four a b c d) = f a + f b + f c + f d
-
-{-@ reflect nodeS @-}
-nodeS :: (a -> Int) -> Node a -> Int
-nodeS f (Node2 a b)   = f a + f b
-nodeS f (Node3 a b c) = f a + f b + f c
-
-{-@ reflect consts @-}
-consts a b = a
-
-{-@ reflect to1 @-}
-to1 :: a -> Int
-to1 _ = 1
-
-{-@ n2Int1 :: a:Int -> b:Int -> {n:Node Int | nodeS to1 n == 2} @-}
-n2Int1 :: Int -> Int -> Node Int
-n2Int1 a b = Node2 a b
-
--- {-@ n2Int :: a:Int -> b:Int -> {f:(Int -> Int) | f a == 1 && f b == 1} -> {n:Node Int | nodeS f n == 2} @-}
--- n2Int :: Int -> Int -> (Int -> Int) -> Node Int
--- n2Int a b f = Node2 a b
-
-{-@ measure isEmpty @-}
-isEmpty Empty      = True
-isEmpty (Single _) = False
-isEmpty Deep{}     = False
-
-{-@ singleton :: v:Int -> {ft:FingerTree Int | isEmpty ft} @-}
-singleton :: Int -> FingerTree Int
-singleton a = Empty 
-
-{-@ fromList :: xs:_ -> {t:_ | fingerTreeSize t == len xs} @-}
-fromList :: [a] -> FingerTree a
-fromList []     = Empty
-fromList (x:xs) = add x (fromList xs)
-
-{-@ infix <| @-}
--- | /O(1)/. Add an element to the left end of a sequence.
--- Mnemonic: a triangle with the single element at the pointy end.
-{- (<|) :: a -> ft:FingerTree a -> {v : FingerTree a | fingerTreeSize v == fingerTreeSize ft + 1} @-}
-{-@ reflect <| @-}
-(<|) :: a -> FingerTree a -> FingerTree a
-a <| Empty                    =  Single a
-a <| Single b                 =  Deep (One a) Empty (One b)
-a <| Deep (Four b c d e) m sf = {- m `seq` -} Deep (Two a b) (Node3 c d e <| m) sf
-a <| Deep l m r               = Deep (consDigit a l) m r 
-
-{-@ lem_add :: f:_ -> a:_ -> t:_ -> { size f (a <| t) == size f t + f a }  @-}
-lem_add :: (a -> Int) -> a -> FingerTree a -> () 
-
-lem_add f _ Empty       
-  = () 
-
-lem_add f _ (Single {}) 
-  = () 
-
-lem_add f a t@(Deep (Four b c d e) m sf) 
-  =   size f t + f a 
-  === digitS f (Four b c d e) + size (nodeS f) m + digitS f sf + f a
-  === f a + f b + digitS f sf + f c + f d + f e + size (nodeS f) m 
-  === f a + f b + digitS f sf + nodeS f (Node3 c d e) + size (nodeS f) m 
-      ? lem_add (nodeS f) (Node3 c d e) m
-  === f a + f b + digitS f sf + size (nodeS f) ((Node3 c d e) <| m)
-  === size f (Deep (Two a b) ((Node3 c d e) <| m) sf)
-  === size f (a <| (Deep (Four b c d e) m sf)) 
-  === size f (a <| t)
-  *** QED  
-
-lem_add f a t@(Deep l m r)  
-  = () 
-
-{-@ thm_add :: a:_ -> t:_ -> { fingerTreeSize (a <| t) == 1 + fingerTreeSize t} @-}
-thm_add :: a -> FingerTree a -> Proof --  FingerTree a 
-thm_add a t 
-  =   fingerTreeSize (a <| t) 
-  === size to1 (a <| t) 
-    ? lem_add to1 a t
-  === size to1 t + to1 a 
-  === fingerTreeSize t + 1 
-  *** QED
-
-{-@ add :: a:_ -> t:_ -> { v: _ | fingerTreeSize v == 1 + fingerTreeSize t} @-}
-add :: a -> FingerTree a -> FingerTree a 
-add a t = (a <| t) ? thm_add a t 
-
-{-@ measure isFour @-}
-isFour :: Digit a -> Bool 
-isFour (Four {}) = True 
-isFour _         = False 
-
-{-@ reflect consDigit @-}
-{-@ consDigit :: _ -> {d:_ | not (isFour d)} -> _ @-}
-consDigit :: a -> Digit a -> Digit a
-consDigit a (One b)        = Two a b
-consDigit a (Two b c)      = Three a b c
-consDigit a (Three b c d)  = Four a b c d
-
-{-@ ft1 :: {v:_ | fingerTreeSize v == 10} @-}
-ft1 :: FingerTree Int
-ft1 = fromList [1,2,3,4,5,6,7,8,9,10]
-
-{-@ ten :: {v:_ | len v = 10} @-}
-ten :: [Int]
-ten = [1,2,3,4,5,6,7,8,9,10]
-
-ft2 :: FingerTree Int
-ft2 = fromList [1..20000]
-
-main :: IO ()
-main = do
-    print "test"
-    print $ fingerTreeSize ft1 -- 10
-    print $ fingerTreeSize ft2 -- 20000
diff --git a/tests/pos/Foldl.hs b/tests/pos/Foldl.hs
deleted file mode 100644
--- a/tests/pos/Foldl.hs
+++ /dev/null
@@ -1,66 +0,0 @@
-module Fold where
-
-{-@ LIQUID "--no-termination" @-}
-import Prelude hiding (foldr)
-
-data Vec a = Nil | Cons a (Vec a)
-
-
-
-{-@
-efoldl :: forall <inv :: (Vec a) -> b -> Bool, step :: a -> b -> b -> Bool>.
-          {y::a, ys :: Vec a, z :: {v:Vec a | v = Cons y ys && llen v = llen ys + 1}, jacc:: b<inv z> |- b<step y jacc> <: b<inv ys>}
-         (x:a -> pacc:b -> b<step x pacc>)
-      -> xs:(Vec a)
-      -> b<inv xs>
-      -> b<inv Nil>
-@-}
-
-efoldl :: (a -> b -> b) -> Vec a -> b -> b
-efoldl op Nil b         = b
-efoldl op (Cons x xs) b = efoldl op xs (x `op` b)
-
-
-
-
-{-
-step x b b' <=> b' = b + 1
-inv ys b <=> b + len ys = len xs
--}
-
-{-@ size_invariant_qualifier :: xs: Vec a -> ys:Vec a -> {v:Int | v + llen xs ==  llen ys} @-}
-size_invariant_qualifier :: Vec a -> Vec a -> Int
-size_invariant_qualifier xs ys = undefined
-
-{-@ size :: xs:Vec a -> {v: Int | v = llen xs} @-}
-size :: Vec a -> Int
-size xs = efoldl (\_ n -> n + 1) xs 0
-
-
--- | We can encode the notion of length as an inductive measure @llen@
-
-{-@ measure llen @-}
-
-llen :: Vec a -> Int
-llen (Nil)       = 0
-llen (Cons x xs) = 1 + llen(xs)
-
-
--------------------------------------------------------------------------
--- | Clients of `efold` -------------------------------------------------
--------------------------------------------------------------------------
-
-
--- | The above uses a helper that counts up the size. (Pesky hack to avoid writing qualifier v = ~A + 1)
-{-@ suc :: x:Int -> {v: Int | v = x + 1} @-}
-suc :: Int -> Int
-suc x = x + 1
-
-{-@ LIQUID "--maxparams=3" @-}
-{-@ append_invariant_qualifier :: xs: Vec a -> ys:Vec a -> zs:Vec a -> {v:Vec a | llen v + llen xs ==  llen ys + llen zs } @-}
-append_invariant_qualifier :: Vec a -> Vec a -> Vec a -> Vec a
-append_invariant_qualifier xs ys zs = undefined
-
--- | Second: Appending two lists using `efoldl`
-{-@ app  :: xs: Vec a -> ys: Vec a -> {v: Vec a | llen v = llen xs + llen ys } @-}
-app xs ys = efoldl (\z zs -> Cons z zs) xs ys
diff --git a/tests/pos/Foo.hs b/tests/pos/Foo.hs
deleted file mode 100644
--- a/tests/pos/Foo.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Foo where
-
-bar = 0
-
-{-@ assume (GHC.Base.++) :: [a] -> [a] -> [a] @-}
diff --git a/tests/pos/Fractional.hs b/tests/pos/Fractional.hs
deleted file mode 100644
--- a/tests/pos/Fractional.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Fixme where
-
-
-{-@ foo :: Fractional a => {v:a | v >= 1.0} @-}
-foo :: Fractional a => a
-foo = undefined
-
-{-@ foo'' :: RealFloat a => {v:a | v >= 1.0} @-}
-foo'' :: RealFloat a => a
-foo'' = undefined
-
-
-{-@ foo' :: Num a => {v:a | v >= 1} @-}
-foo' :: Num a => a
-foo' = undefined
diff --git a/tests/pos/FractionalInstance.hs b/tests/pos/FractionalInstance.hs
deleted file mode 100644
--- a/tests/pos/FractionalInstance.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-module Fractional where
-
-data Frac a
-
-{-@ test :: x:Frac a -> y:{Frac a | y /= 0} -> {v:Frac a | v = x / y } @-} 
-test :: Frac a -> Frac a -> Frac a 
-test x y = x / y 
-
-
-{-@ test1 :: x:a -> y:{a | y /= 0} -> {v:a | v = x / y } @-} 
-test1 :: Fractional a => a -> a -> a  
-test1 x y = x / y 
-
-instance Num (Frac a) where
-instance Fractional (Frac a) where
diff --git a/tests/pos/GCD.hs b/tests/pos/GCD.hs
deleted file mode 100644
--- a/tests/pos/GCD.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module GCD () where
-
-import Prelude hiding (gcd, mod)
-import Language.Haskell.Liquid.Prelude
-{-@ mod :: a:Nat -> b:{v:Nat| ((v < a) && (v > 0))} -> {v:Nat | v < b} @-}
-mod :: Int -> Int -> Int
-mod a b | a - b >  b = mod (a - b) b
-        | a - b <  b = a - b
-        | a - b == b = 0
-
-{-@ gcd :: a:Nat -> b:{v:Nat | v < a} -> Int @-}
-gcd :: Int -> Int -> Int
-gcd a 0 = a
-gcd a b = gcd b (a `mod` b)
-
-{-@ gcd' :: a:Nat -> b:Nat -> Nat / [a, b] @-}
-gcd' :: Int -> Int -> Int
-gcd' a b | a == 0 = b
-         | b == 0 = a
-         | a == b = a
-         | a >  b = gcd' (a - b) b 
-         | a <  b = gcd' a (b - a) 
diff --git a/tests/pos/GeneralizedTermination.hs b/tests/pos/GeneralizedTermination.hs
deleted file mode 100644
--- a/tests/pos/GeneralizedTermination.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-module GenTerm (llen) where
-
-import Prelude hiding (reverse)
-
-foo :: Int -> Int -> Int
-{-@ foo :: n:Nat -> m:Nat -> Nat /[n+m] @-}
-
-foo n m 
-  | cond 1 = 0
-  | cond 2 && n > 1 = foo (n-1) m
-  | cond 3 && m > 2 = foo (n+1) (m-2)
- 
-{-@ cond :: Int -> Bool @-}
-cond :: Int -> Bool
-cond _ = undefined
-
-
-data L a = N | C a (L a)
-
-{-@ data L [llen] @-}
-
-{-@ measure llen @-}
-llen :: (L a) -> Int
-{-@ llen :: (L a) -> Nat @-}
-llen(N)      = 0
-llen(C x xs) = 1 + (llen xs)
-
-{-@ reverse :: xs: L a -> ys : L a -> L a / [(llen ys)] @-}
-reverse :: L a -> L a -> L a
-reverse xs N = xs
-reverse xs (C y ys) = reverse (C y xs) ys
-
-merge :: Ord a => L a -> L a -> L a 
-{-@ merge :: Ord a => xs:L a -> ys:L a -> L a /[(llen xs) + (llen ys)]@-}
-merge (C x xs) (C y ys) | x > y     = C x $ merge xs (C y ys) 
-                        | otherwise = C y $ merge (C x xs) ys
diff --git a/tests/pos/GhcSort1.hs b/tests/pos/GhcSort1.hs
deleted file mode 100644
--- a/tests/pos/GhcSort1.hs
+++ /dev/null
@@ -1,60 +0,0 @@
-{-# Language ScopedTypeVariables   #-}
-{-# Language PartialTypeSignatures #-}
-
--- TODO: Fix resolve so we can remove this/add termination metrics
-{-@ LIQUID "--no-termination" @-}
-
-module ListSort () where
-
-import Language.Haskell.Liquid.Prelude 
-
-{-@ type OList a = [a]<{\fld v -> (v >= fld)}> @-}
-{-@ assert sort1 :: (Ord a) => [a] -> OList a  @-}
-sort1 :: (Ord a) => [a] -> [a]
-sort1 xs = mergeAll  (sequences xs 0)
-  where
-    sequences :: [_] -> Int -> [[_]]
-    sequences (a:b:xs) (_::Int)
-      | a `compare` b == GT = descending b [a]  xs 1
-      | otherwise           = ascending  b (a:) xs 1
-    sequences [x] _ = [[x]]
-    sequences []  _ = [[]]
-
-    descending :: _ -> _ -> [_] -> Int -> [[_]]
-    descending a as (b:bs) (_::Int)
-      | a `compare` b == GT = descending b (a:as) bs 1
-    descending a as bs _    = (a:as): sequences bs 0
-
-    ascending :: _ -> _ -> [_] -> Int -> [[_]]
-    ascending a as (b:bs) (_ :: Int)
-      | a `compare` b /= GT = ascending b (\ys -> as (a:ys)) bs 1
-    ascending a as bs _     = as [a]: sequences bs 0
-
-    mergeAll []  = [] --this case cannot occur, though
-    mergeAll [x] = x
-    mergeAll xs  = mergeAll (mergePairs xs)
-
-{-@ mergePairs :: Ord a
-               => xss:[(OList a)]
-               -> {v:[(OList a)] | (if ((len xss) > 1) then ((len v) < (len xss)) else ((len v) = (len xss) ))}
-  @-}
-mergePairs :: Ord a => [[a]] -> [[a]]
-mergePairs (a:b:xs) = merge1 a b: mergePairs xs
-mergePairs [x]      = [x]
-mergePairs []       = []
-
--- merge1 needs to be toplevel,
--- to get applied transformRec tx
-
-{-@ merge1 :: Ord a
-           => xs:OList a
-           -> ys:OList a
-           -> {v:OList a | len v == len xs + len ys}
-           / [len xs + len ys]
-  @-}
-merge1 :: Ord a => [a] -> [a] -> [a]
-merge1 (a:as') (b:bs')
-  | a `compare` b == GT = b:merge1 (a:as')  bs'
-  | otherwise           = a:merge1 as' (b:bs')
-merge1 [] bs            = bs
-merge1 as []            = as
diff --git a/tests/pos/GhcSort2.hs b/tests/pos/GhcSort2.hs
deleted file mode 100644
--- a/tests/pos/GhcSort2.hs
+++ /dev/null
@@ -1,46 +0,0 @@
-module GhcSort () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ type OList a =  [a]<{\fld v -> (v >= fld)}>  @-}
-
-
-{-@ assert sort2 :: (Ord a) => [a] -> OList a  @-}
-sort2 :: (Ord a) => [a] -> [a]
-sort2 = mergesort
-
-mergesort :: (Ord a) => [a] -> [a]
-mergesort = mergesort' . map wrap
-
-mergesort' :: (Ord a) => [[a]] -> [a]
-mergesort' [] = []
-mergesort' [xs] = xs
-mergesort' xss = mergesort' (merge_pairs xss)
-
-{-@ predicate DLen X Y = 
-      (if ((len X) > 1) 
-       then ((len Y) < (len X)) 
-       else ((len X) = (len Y))) 
-  @-}
-
-{-@ merge_pairs :: (Ord a) => xs:[OList a] -> {v:[OList a] | (DLen xs v)} @-}
-merge_pairs :: (Ord a) => [[a]] -> [[a]]
-merge_pairs [] = []
-merge_pairs [xs] = [xs]
-merge_pairs (xs:ys:xss) = merge xs ys d : merge_pairs xss
-  where d = length xs + length ys
-
-
-{-@ decrease merge 4 @-}
-{-@ merge :: (Ord a) => xs:OList a -> ys:OList a -> {n:Nat|n = (len xs) + (len ys)} -> OList a  @-}
-merge :: (Ord a) => [a] -> [a] -> Int -> [a]
-merge [] ys _ = ys
-merge xs [] _ = xs
-merge (x:xs) (y:ys) d
- | x > y     = y : merge (x:xs)   ys (d-1)
- | otherwise = x : merge xs   (y:ys) (d-1)
-
-wrap :: a -> [a]
-wrap x = [x]
-
-
diff --git a/tests/pos/GhcSort3.T.hs b/tests/pos/GhcSort3.T.hs
deleted file mode 100644
--- a/tests/pos/GhcSort3.T.hs
+++ /dev/null
@@ -1,41 +0,0 @@
-module GhcSort () where
-
-{-@ type OList a =  [a]<{\fld v -> (v >= fld)}>  @-}
-
-{-@ assert sort3 :: (Ord a) => w:a -> [{v:a|v<=w}] -> OList a @-}
-sort3 :: (Ord a) => a -> [a] -> [a]
-sort3 w ls = qsort w ls [] (length ls) 0
-
-{-@ decrease qsort 5 6 @-}
-{-@ decrease rqsort 5 6 @-}
-{-@ decrease qpart 8 9 @-}
-{-@ decrease rqpart 8 9 @-}
-qsort :: (Ord a) =>  a -> [a] -> [a] -> Int -> Int -> [a]
-{-@ qsort, rqsort :: (Ord a) =>  w:a -> xs:[{v:a|v<=w}] -> OList {v:a|v>=w} -> {v:Int | v = (len xs) } -> {v:Int | v = 0 } -> OList a @-}
-qsort _ []     r _ _ = r
-qsort _ [x]    r _ _ = x:r
-qsort w (x:xs) r _ _ = qpart w x xs [] [] r (length xs) (length xs + 1)
-
-{-@ qpart, rqpart :: (Ord a) => w:a -> x:{v:a|v<=w} -> xs:[{v:a|v <= w}] -> lt:[{v:a|((v<=x) && (v<=w))}] -> ge:[{v:a|((v >= x) && (v<=w))}] -> rs:(OList {v:a|v >= w}) -> {v:Int | v = ((len xs) + (len lt) + (len ge))} -> {v:Int|v = (len xs) + 1} -> OList a @-}
-qpart :: (Ord a) => a -> a -> [a] -> [a] -> [a] -> [a] -> Int -> Int -> [a]
-qpart w x [] rlt rge r _ _ =
-    rqsort x rlt (x:rqsort w rge r (length rge) 0) (length rlt) 0
-qpart w x (y:ys) rlt rge r d1 d2 =
-    case compare x y of
-        GT -> qpart w x ys (y:rlt) rge r d1 (d2 - 1)
-        _  -> qpart w x ys rlt (y:rge) r d1 (d2 - 1)
-
-{- rqsort :: (Ord a) =>  w:a -> xs:[{v:a|v<=w}] -> OList {v:a|v>=w} -> {v:Int | v = (len xs) } -> {v:Int | v = 0 } -> OList a @-}
-rqsort :: (Ord a) => a -> [a] -> [a] -> Int -> Int -> [a]
-rqsort _ []     r _ _ = r
-rqsort _ [x]    r _ _ = x:r
-rqsort w (x:xs) r _ _ = rqpart w x xs [] [] r (length xs) (length xs + 1)
-
-rqpart :: (Ord a) => a -> a -> [a] -> [a] -> [a] -> [a] -> Int -> Int -> [a]
-rqpart w x [] rle rgt r _ _ =
-    qsort x rle (x:qsort w rgt r (length rgt) 0) (length rle) 0 
-rqpart w x (y:ys) rle rgt r d1 d2 =
-    case compare y x of
-        GT -> rqpart w x ys rle (y:rgt) r d1 (d2-1)
-        _  -> rqpart w x ys (y:rle) rgt r d1 (d2-1)
-
diff --git a/tests/pos/GhcSort3.hs b/tests/pos/GhcSort3.hs
deleted file mode 100644
--- a/tests/pos/GhcSort3.hs
+++ /dev/null
@@ -1,36 +0,0 @@
-module GhcSort () where
-
-{-@ LIQUID "--no-termination" @-}
-
-{-@ type OList a =  [a]<{\fld v -> (v >= fld)}>  @-}
-
-{-@ assert sort3 :: (Ord a) => w:a -> [{v:a|v<=w}] -> OList a @-}
-sort3 :: (Ord a) => a -> [a] -> [a]
-sort3 w ls = qsort w ls []
-
-qsort :: (Ord a) =>  a -> [a] -> [a] -> [a]
-qsort _ []     r = r
-qsort _ [x]    r = x:r
-qsort w (x:xs) r = qpart w x xs [] [] r
-
-qpart :: (Ord a) => a -> a -> [a] -> [a] -> [a] -> [a] -> [a]
-qpart w x [] rlt rge r =
-    rqsort x rlt (x:rqsort w rge r)
-qpart w x (y:ys) rlt rge r =
-    case compare x y of
-        GT -> qpart w x ys (y:rlt) rge r
-        _  -> qpart w x ys rlt (y:rge) r
-
-rqsort :: (Ord a) => a -> [a] -> [a] -> [a]
-rqsort _ []     r = r
-rqsort _ [x]    r = x:r
-rqsort w (x:xs) r = rqpart w x xs [] [] r
-
-rqpart :: (Ord a) => a -> a -> [a] -> [a] -> [a] -> [a] -> [a]
-rqpart w x [] rle rgt r =
-    qsort x rle (x:qsort w rgt r)
-rqpart w x (y:ys) rle rgt r =
-    case compare y x of
-        GT -> rqpart w x ys rle (y:rgt) r
-        _  -> rqpart w x ys (y:rle) rgt r
-
diff --git a/tests/pos/GoodHMeas.hs b/tests/pos/GoodHMeas.hs
deleted file mode 100644
--- a/tests/pos/GoodHMeas.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-{-@ LIQUID "--prune-unsorted" @-}
-
-{-@ measure foo @-}
-bar, foo :: [(Int, Int)] -> Int
-foo [] = 0
-foo (a:as) = myFst a + foo as
-
-{-@ measure myFst @-}
-myFst :: (a, b) -> a
-myFst (x, y) = x
-
-{-@ bar :: xs:[(Int, Int)] -> {v:Int | v == foo xs } @-}
-bar x = foo x
-
-main :: IO ()
-main = pure ()
diff --git a/tests/pos/Graph.hs b/tests/pos/Graph.hs
deleted file mode 100644
--- a/tests/pos/Graph.hs
+++ /dev/null
@@ -1,54 +0,0 @@
-{-@ LIQUID "--prune-unsorted" @-}
-
-module Graph () where
-
-import Data.Set
-
-
-type Size = Int
-data Map k v = Tip | Bin Size k v (Map k v) (Map k v)
-             deriving (Eq, Ord)
-
-
-data Edges edge
-
-
-{-@ measure getEdgesIncoming :: (Edges edge) -> (Set edge) @-}
-
-{-@ measure getEdgesOutgoing :: (Edges edge) -> (Set edge) @-}
-
-data Graph node edge =
-  Graph {
-    graphMap ::
-      Map node (Edges edge, Edges edge)
-  }
-
-{-@ invariant {v: (Graph node edge) | (getGraphIncoming v) = (getGraphOutgoing v) } @-}
-
-{-@ measure getGraphIncoming :: (Graph node edge) -> (Set edge)
-    getGraphIncoming (Graph m) = (getMapIncoming m)
-  @-}
-
-{-@ measure getGraphOutgoing :: (Graph node edge) -> (Set edge)
-    getGraphOutgoing (Graph m) = (getMapOutgoing m)
-  @-}
-
-
-{-@ measure getMapIncoming :: (Map node (Edges edge, Edges e)) -> (Set edge)
-    getMapIncoming (Tip) = {v | Set_emp v }
-    getMapIncoming (Bin size k v lm rm) = (Set_cup (getPairIncoming v) (Set_cup (getMapIncoming lm) (getMapIncoming rm)))
-  @-}
-
-
-{-@ measure getMapOutgoing :: (Map node (Edges edge, Edges edge)) -> (Set edge)
-    getMapOutgoing (Tip) = {v | Set_emp v }
-    getMapOutgoing (Bin size k v lm rm) = Set_cup (getPairOutgoing v) (Set_cup (getMapOutgoing lm) (getMapOutgoing rm))
-  @-}
-
-{-@ measure getPairIncoming :: (Edges edge, Edges e) -> (Set edge)
-    getPairIncoming (x, y) = (getEdgesIncoming x)
-  @-}
-
-{-@ measure getPairOutgoing :: (Edges e, Edges edge) -> (Set edge)
-    getPairOutgoing (x, y) = (getEdgesOutgoing y)
-  @-}
diff --git a/tests/pos/HasElem.hs b/tests/pos/HasElem.hs
deleted file mode 100644
--- a/tests/pos/HasElem.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-module HasElem where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-{-@ LIQUID "--no-termination" @-}
-
-data L a = Nil | Cons a (L a)
-
-{-@ reflect hasElem @-}
-hasElem :: Eq a => a -> L a -> Bool
-hasElem x Nil = False
-hasElem x (Cons y ys) = x == y || hasElem x ys
-
-{-@ prop :: {v:Bool | v} @-}
-prop :: Bool
-prop = hasElem 1 (Cons 1 Nil)
-
-{-@ prop1 :: {v:Bool | not v } @-}
-prop1 :: Bool
-prop1 = hasElem 1 (Cons 2 Nil)
-
-{-@ prop2 :: {v:Bool | not v } @-}
-prop2 :: Bool
-prop2 = hasElem 1 Nil
diff --git a/tests/pos/HaskellMeasure.hs b/tests/pos/HaskellMeasure.hs
deleted file mode 100644
--- a/tests/pos/HaskellMeasure.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Measures where
-
-{-@ measure lllen @-}
-llen :: [a] -> Int
-llen [] = 0
-llen (x:xs) = 1 + llen xs
-
-{-@ llen, llllen :: xs:[a] -> {v:Int| (lllen xs) = v} @-}
-
-lllen :: [a] -> Int	
-lllen [] = 0
-lllen (x:xs) = 1 + lllen xs
-
-llllen = lllen
diff --git a/tests/pos/HedgeUnion.hs b/tests/pos/HedgeUnion.hs
deleted file mode 100644
--- a/tests/pos/HedgeUnion.hs
+++ /dev/null
@@ -1,48 +0,0 @@
-module Map where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@
-  data Map [mlen] k a <l :: root:k -> k -> Bool, r :: root:k -> k -> Bool>
-      = Tip 
-      | Bin (right :: Map <l, r> k  a) 
-  @-}
-
-{-@ measure mlen @-}
-mlen :: (Map k a) -> Int 
-{-@ mlen :: (Map k a) -> Nat @-} 
-mlen(Tip) = 0
-mlen(Bin r) = 1 + (mlen r)
-
-{- type OMap k a = Map <{\root v -> v < root }, {\root v -> v > root}> k a @-}
-
-data Map k a = Tip
-             | Bin (Map k a)
-
-type Size    = Int
-
--- Internal representation of hedgeUnion:
-
-{-@ lazyvar d20r @-}
-
-g t1 d20i = 
-  case d20i of
-   Tip -> Tip
-   Bin d20G -> (\_ -> let d20r = \_ -> let d20n  = \_ -> case t1 of
-                                                         Tip -> liquidError ""
-                                                         Bin  r -> r
-                                      in case d20i of
-                                          Tip -> d20n ""
-                                          Bin d20j -> case d20j of
-                                                        Tip -> Tip
-                                                        Bin _ -> d20n ""
-                         in case t1 of
-                             Tip -> case d20i of 
-                                      Tip -> d20r ""
-                                      Bin r -> r
-                             Bin _ -> d20r "") ""
-
--- hedgeUnion t1 Tip      = Tip  
--- hedgeUnion Tip (Bin r) = r
--- hedgeUnion t1  (Bin Tip) = Tip
--- hedgeUnion (Bin r) t = r
diff --git a/tests/pos/Hex00.hs b/tests/pos/Hex00.hs
deleted file mode 100644
--- a/tests/pos/Hex00.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Hex where 
-
-foo :: Int -> Int -> Int 
-foo x y = x + y
-
-{-@ foo :: {x:Int | x = 0x7} -> {y:Int | y = 0x8} -> {v:Int | v = 0xF} @-}
-
diff --git a/tests/pos/HigherOrderRecFun.hs b/tests/pos/HigherOrderRecFun.hs
deleted file mode 100644
--- a/tests/pos/HigherOrderRecFun.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module HOF () where
-
-foo :: [a] -> (b -> c) -> (b -> c)
-foo []     f = f
-foo (x:xs) f = foo xs f
-
diff --git a/tests/pos/Hole00.hs b/tests/pos/Hole00.hs
deleted file mode 100644
--- a/tests/pos/Hole00.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-
--- This test checks that we resolve the name `MVector` to 
--- the CLASS defined in the re-exported Data.Vector.Generic.Mutable.Base 
--- NOT to the TyCon inside `Data.Vector.Primitive.Mutable` 
-
-module Hole00 where
-
-import Prelude hiding (read, length)
-
-import           Control.Monad.Primitive
-import qualified Data.Vector.Primitive.Mutable as PV
-import           Data.Vector.Generic.Mutable
-
-{-@ chimp :: (Monad m, MVector v e) => v (PrimState m) e -> m () @-}
-chimp :: (Monad m, MVector v e) => v (PrimState m) e -> m ()
-chimp = undefined
diff --git a/tests/pos/Holes-Slicing.hs b/tests/pos/Holes-Slicing.hs
deleted file mode 100644
--- a/tests/pos/Holes-Slicing.hs
+++ /dev/null
@@ -1,21 +0,0 @@
--- TODO-REBARE: What the hell is noslice? 
-{- LIQUID "--noslice"     @-}
-
-module Foo () where
-
-
-{-@ measure isFoo :: A -> B -> Bool @-}
-{-@ isFooF :: a:A -> b:B -> {v:Bool | v <=> isFoo a b} @-}
-isFooF :: A -> B -> Bool
-isFooF a b = undefined
-
-{-@ prop1 :: u:A -> p:B -> {v : Int | isFoo u p <=> (v < 2) } @-}
-prop1 :: A -> B -> Int
-prop1 = undefined
-
-{-@ foo :: A -> B -> _ @-}
-foo :: A -> B -> Int
-foo a b = if isFooF a b then 0 else 2 
-
-data A
-data B
diff --git a/tests/pos/Holes.hs b/tests/pos/Holes.hs
deleted file mode 100644
--- a/tests/pos/Holes.hs
+++ /dev/null
@@ -1,39 +0,0 @@
-module Holes (plus) where
-
-{-@ foo :: x:_ -> y:{Int | y > 0} -> _ @-}
-foo :: Int -> Int -> Int
-foo x y = x
-
-zero = foo 0 1
-
-
-{-@ baz :: _ -> _ -> a @-}
-baz :: a -> b -> b
-baz x y = y
-
-baz' = baz 1 2
-
-data P a b = P a b
-
-{-@ goo :: _ -> b -> _ @-}
-goo :: P a b -> b -> a
-goo p@(P a b) x = a
-
-y = goo (P 1 1) 2
-
-
-{-@ bar :: {v:[{v0:Int | v0 > 0}] | _ } -> Int @-}
-bar :: [Int] -> Int
-bar [x] = x
-
-x =  bar [1]
-
-{-@ plus :: x:_ -> y:_ -> {v:_ | v = x + y} @-}
-plus :: Int -> Int -> Int 
-plus x y = x + y
-
-
-{-@ type UNat = {v:_ | v >= 0} @-}
-
-{-@ zoo :: UNat @-}
-zoo = 1
diff --git a/tests/pos/Hutton.hs b/tests/pos/Hutton.hs
deleted file mode 100644
--- a/tests/pos/Hutton.hs
+++ /dev/null
@@ -1,109 +0,0 @@
--- WITH-PLE 
-
-module Hutton where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-
-import Language.Haskell.Liquid.ProofCombinators
-
-import Prelude hiding (length, head, tail, map, (++))
-
--- need to use a hand-rolled list type, it seems
-
-data L a = N | C {hd :: a, tl :: L a}
-{-@ data L [length] a = N | C {hd :: a, tl :: L a} @-}
-
-length :: L a -> Int
-{-@ length :: L a -> Nat @-}
-{-@ measure length @-}
-length N        = 0
-length (C _ xs) = 1 + length xs
-
-{-@ infix   ++ @-}
-{-@ reflect ++ @-}
-(++) :: L a-> L a -> L a
-N        ++ ys = ys
-(C x xs) ++ ys = C x (xs ++ ys)
-
--- huttons razor
-
-data Expr = Val Int | Add Expr Expr
-{-@ data Expr [height] = Val {theVal :: Int} | Add {summand1 :: Expr, summand2 :: Expr}  @-}
-
-
-{-@ height :: Expr -> Nat @-}
-{-@ measure height @-}
-height :: Expr -> Int
-height (Val _) = 0
-height (Add e1 e2) = 1 + if height e1 > height e2 then  height e1 else height e2
-
-{- @ eval :: e:Expr -> Int / [height e] @-}
-{-@ reflect eval @-}
-eval :: Expr -> Int
-eval (Val n)   = n
-eval (Add x y) = eval x + eval y
-
-type Stack = L Int
-
-type Code = L Op
-
-data Op = PUSH Int | ADD
-{-@ data Op = PUSH {thePushed :: Int} | ADD @-}
-
-{-@ reflect exec @-}
-exec :: Code -> Stack -> Stack
-exec N s                          = s
-exec (C (PUSH n) c) s             = exec c (C n s)
-exec (C ADD      c) (C m (C n s)) = exec c (C (n+m) s)
-exec (C ADD      c) (C n N)       = N -- default case added
-exec (C ADD      c) N             = N -- default case added (need to be sparate cases)
-
-{-@ reflect comp @-}
-comp :: Expr -> Code
-comp (Val n)   = C (PUSH n) N
-comp (Add x y) = (comp x ++ comp y) ++ (C ADD N)
-
--- Proofs
-
-{-@ lemma_assoc4 :: as:L a -> bs:L a -> cs:L a -> ds:L a 
-                 -> {((as ++ bs) ++ cs) ++ ds  == as ++ (bs ++ (cs ++ ds)) }
-  @-}
-lemma_assoc4 :: L a -> L a -> L a -> L a -> Proof 
-lemma_assoc4 _ _ _ _ = undefined
-
-{-@ lemma_app_nil :: x:a -> ys:L a -> { (C x N) ++ ys = C x ys } @-}
-lemma_app_nil :: a -> L a -> Proof
-lemma_app_nil _ _ = () 
-
-{-@ correctness :: e:Expr -> c:Code -> s:Stack ->
-                  { exec (comp e ++ c) s = exec c (C (eval e) s) }
-@-}
-correctness :: Expr -> Code -> Stack -> Proof
-correctness (Val n) c s 
-  = [
-    --   exec (comp (Val n) ++ c) s
-    -- ==. exec ((C (PUSH n) N) ++ c) s
-    -- ==. exec ((C (PUSH n) (N ++ c))) s
-    -- ==. exec (C (PUSH n) c) s
-    -- ==. exec c (C n s)
-    -- ==. exec c (C (eval (Val n)) s)
-    ] *** QED
-
-
-correctness (Add e1 e2) c s 
-  = [ 
-  --    exec (comp (Add e1 e2) ++ c) s 
-  -- ==. exec (((comp e1 ++ comp e2) ++ (C ADD N)) ++ c) s
-  -- ==. exec (comp e1 ++ (comp e2 ++ ((C ADD N) ++ c))) s
-      lemma_assoc4 (comp e1) (comp e2) (C ADD N) c
-  -- ==. (exec (comp e2 ++ ((C ADD N) ++ c)) (C (eval e1) s))
-    , correctness e1 (comp e2 ++ ((C ADD N) ++ c)) s
-  -- ==. exec ((C ADD N) ++ c) (C (eval e2) (C (eval e1) s))
-    , correctness e2 ((C ADD N) ++ c) (C (eval e1) s)
-  -- ==. exec (C ADD c) (C (eval e2) (C (eval e1) s))
-    , lemma_app_nil ADD c
-  -- ==. exec c (C (eval e1 + eval e2) s)
-  -- ==. exec c (C (eval (Add e1 e2)) s)
-  ] *** QED    
-
diff --git a/tests/pos/IcfpDemo.hs b/tests/pos/IcfpDemo.hs
deleted file mode 100644
--- a/tests/pos/IcfpDemo.hs
+++ /dev/null
@@ -1,66 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-module IcfpDemo where
-
-import Prelude hiding (gcd, map, repeat, take)
-import Language.Haskell.Liquid.Prelude
-
-
-fac :: Int -> Int
-fac n = if n <= 1 then 1 else n * fac (n-1)
-
---FIXME: fixpoint can't parse "mod" anymore..
-{- gcd :: a:Nat -> {v:Nat | v < a} -> Nat @-}
--- gcd :: Int -> Int -> Int
--- gcd a 0 = a
--- gcd a b = gcd b (a `mod` b)
-
-{-@ tfac :: Nat -> n:Nat -> Nat / [n] @-}
-tfac :: Int -> Int -> Int
-tfac x n = if n <= 1 then x
-                     else tfac (n*x) (n-1)
-
-{-@ range :: lo:Nat -> hi:Nat -> [Nat] / [hi-lo] @-}
-range :: Int -> Int -> [Int]
-range lo hi
-  | lo < hi   = lo : range (lo + 1) hi
-  | otherwise = []
-
-{-@ data L [sz] a <p :: L a -> Bool>
-      = N | C (lHd :: a) (lTl ::L <p> a <<p>>)
-  @-}
-data L a = N | C a (L a)
-
-{-@ measure sz  @-}
-sz :: L a -> Int
-{-@ sz :: L a -> Nat @-}
-sz (C x xs) = 1 + (sz xs)
-sz (N)      = 0
-
-{-@ map :: (a -> b) -> xs:L a -> (L b) / [(sz xs)] @-}
-map :: (a -> b) -> L a -> L b
-map f (C x xs) = f x `C` map f xs
-map _ N        = N
-
-{-@ merge :: xs:_ -> ys:_ -> _ / [(sz xs) + (sz ys)] @-}
-merge :: Ord a => L a -> L a -> L a
-merge (C x xs) (C y ys)
-  | x < y     = x `C` merge xs (y `C` ys)
-  | otherwise = y `C` merge (x `C` xs) ys
-
-{-@ measure emp  :: L a -> Bool
-    emp (N)      = true
-    emp (C x xs) = false
-  @-}
-
-{-@ type Stream a = {xs: L <{\v -> not (emp v)}> a | not (emp xs)} @-}
-
-{-@ lazy repeat @-}
-{-@ repeat :: a -> Stream a @-}
-repeat :: a -> L a
-repeat x = x `C` repeat x
-
-{-@ take :: Nat -> Stream a -> L a @-}
-take :: Int -> L a -> L a
-take 0 _        = N
-take n (C x xs) = x `C` take (n-1) xs
-take _ N        = liquidError "never happens"
diff --git a/tests/pos/Ignores.hs b/tests/pos/Ignores.hs
deleted file mode 100644
--- a/tests/pos/Ignores.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Ignores where 
-
-{-@ ignore inc @-}
-{-@ inc :: Nat -> Nat @-}
-inc :: Int -> Int 
-inc x = x - 1 
-
diff --git a/tests/pos/Infinity.hs b/tests/pos/Infinity.hs
deleted file mode 100644
--- a/tests/pos/Infinity.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-module Infinity () where
-
-import Language.Haskell.Liquid.Prelude
-{-@ lazy inf @-}
-
-{-@ inf :: {v:[Int] | (((len v) > oo) && ((len v) > 2))} @-}
-inf :: [Int]
-inf = 1 : inf
-
-bar = tail $ tail inf
-
-
-foo = inf !! n
-  where n = myabs $ choose 0
-
-myabs :: Int -> Int
-{-@ myabs :: Int -> {v:Int | v >= 0} @-}
-myabs = undefined
-
--- Encoding infinity.....
-
-{-@ measure oo :: Int @-}
-{-@ invariant {v:Int | (v < oo) }@-}
diff --git a/tests/pos/Keys.hs b/tests/pos/Keys.hs
deleted file mode 100644
--- a/tests/pos/Keys.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-@ LIQUID "--prune-unsorted" @-}
-
-module Eval where
-
-
-import qualified Data.Set as S
-
-{-@ measure keys @-}
-keys :: (Ord k) => [(k, v)] -> S.Set k
-keys []       = S.empty
-keys (kv:kvs) = (S.singleton (myfst kv)) `S.union` (keys kvs)
-
-{-@ measure myfst @-}
-myfst :: (a, b) -> a
-myfst (x, _) = x
-
--- this is fine
-
-{-@ measure okeys  :: [(a, b)] -> (S.Set a)
-    okeys ([])     = (Set_empty 0)
-    okeys (kv:kvs) = (Set_cup (Set_sng (fst kv)) (okeys kvs))
-  @-}
diff --git a/tests/pos/LambdaDeBruijn.hs b/tests/pos/LambdaDeBruijn.hs
deleted file mode 100644
--- a/tests/pos/LambdaDeBruijn.hs
+++ /dev/null
@@ -1,88 +0,0 @@
-module LambdaDeBruijn where
-
-{-@ LIQUID "--prune-unsorted" @-}
-
-{- Proving Termination of Parallel Substitutions,
-   see  § 3.2.2 of Dependent Types and Multi Monadic Effects in F*
- -}
-
-import Language.Haskell.Liquid.Prelude
-
-type Var = Int
-{-@ type EVar = {v:Expr| isEVar v} @-}
-
-type Subst = [(Var, Expr)]
-{-@ type RenamingSubst = {su: [(Var, Expr)] | isRenaming su} @-}
-
-
-{- TODO: in the F* paper, substitutions are functions,
-   can we have function representation with LH?             -}
-
-
-data Typ
-
-data Expr = EVar Var
-          | ELam Typ Expr
-          | EUnit
-          | EApp Expr Expr
-{-@ data Expr [elen] @-}
-
-
-{-@ type MEVar E SU = {v:Expr | (isEVar E && isRenaming SU) => (isEVar v) } @-}
-
-
-{-@ sub :: su:Subst -> v:Var -> {v:Expr | (isRenaming su) => (isEVar v) } @-}
-sub [] v                       = EVar v
-sub ((vx, x):su) v | v == vx   = x
-                   | otherwise = sub su v
-
-
-{-@ subst :: e:Expr -> su:Subst -> MEVar e su
-      / [ (if (isEVar e) then 0 else 1), (if (isRenaming su) then 0 else 1), elen e] @-}
-
-subst EUnit        su = EUnit
-subst (EVar v)     su = sub su v
-subst (EApp e1 e2) su = EApp (subst e1 su) (subst e2 su)
-
-subst (ELam t e)   su | isRenaming su =
-  let su' =  toRem $ (0, EVar 0): map (\i -> (i, subst (sub su (i-1)) $ incrsubst ())) [1..]
-  in ELam t $ subst e su'
-
-subst (ELam t e)   su = -- | not $ isRenaming su
-    let su' =  (0, EVar 0): map (\i -> (i, subst (sub su (i-1)) $ incrsubst ())) [1..]
-    in ELam t $ subst e su'
-
-
-
-{-- Helper functions and measure definitions --}
-
-{-@ toRem :: [(Var, EVar)] -> RenamingSubst @-}
-toRem :: Subst -> Subst
-toRem [] = []
-toRem ((x, y):sus) = (x, y):toRem sus
-
-{-@ incrsubst :: () -> RenamingSubst @-}
-incrsubst :: () -> Subst
-incrsubst _ = toRem $  map (\i -> (i, EVar $ i+1)) [0..]
-
-{-@ measure isEVar @-}
-isEVar :: Expr -> Bool
-isEVar (EVar _) = True
-isEVar _        = False
-
-{-@ measure isRenaming @-}
-isRenaming :: Subst -> Bool
-isRenaming (vx:sus) = isEVar (mysnd vx) && isRenaming sus
-isRenaming [] = True
-
-{-@ measure mysnd @-}
-mysnd :: (a, b) -> b
-mysnd (_, y) = y
-
-{-@ invariant {v:Expr | elen v >= 0 } @-}
-{-@ measure elen @-}
-elen :: Expr -> Int
-elen EUnit    = 0
-elen (EVar v) = 0
-elen (ELam _ e) = 1 + elen e
-elen (EApp e1 e2) = 1 + elen e1 + elen e2
diff --git a/tests/pos/LambdaEval.hs b/tests/pos/LambdaEval.hs
deleted file mode 100644
--- a/tests/pos/LambdaEval.hs
+++ /dev/null
@@ -1,165 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module LambdaEval () where
-
-import Data.List        (lookup)
-
-import Language.Haskell.Liquid.Prelude
-
----------------------------------------------------------------------
------------------------ Datatype Definition -------------------------
----------------------------------------------------------------------
-
-import Prelude hiding (error)
-
-{-@ error :: a -> b @-}
-error :: a -> b
-error x = error x
-
-type Bndr
-  = Int
-
-data Expr
-  = Lam Bndr Expr
-  | Var Bndr
-  | App Expr Expr
-  | Const Int
-  | Plus Expr Expr
-  | Pair Expr Expr
-  | Fst Expr
-  | Snd Expr
-
-{-@
-data Expr
-  = Lam   { eX :: Bndr, eBody :: Expr }
-  | Var   { eX :: Bndr                }
-  | App   { eL :: Expr, eR    :: Expr }
-  | Const { eN :: Int                 }
-  | Plus  { eL :: Expr, eR :: Expr    }
-  | Pair  { eL :: Expr, eR :: Expr    }
-  | Fst   { eL :: Expr                }
-  | Snd   { eL :: Expr                }
-@-}
-
-
-
-{-@ measure elen :: (Expr) -> Int
-    elen(Lam x e)    = 1 + (elen e)
-    elen(Var x)      = 0
-    elen(App e1 e2)  = 1 + (elen e1) + (elen e2)
-    elen(Const i)    = 1
-    elen(Plus e1 e2) = 1 + (elen e1) + (elen e2)
-    elen(Pair e1 e2) = 1 + (elen e1) + (elen e2)
-    elen(Fst e)      = 1 + (elen e)
-    elen(Snd e)      = 1 + (elen e)
-@-}
-
-
-{-@ invariant {v:Expr | (elen v) >= 0} @-}
-
-{-@
-measure isValue      :: Expr -> Bool
-isValue (Const i)    = true
-isValue (Lam x e)    = true
-isValue (Var x)      = false
-isValue (App e1 e2)  = false
-isValue (Plus e1 e2) = false
-isValue (Fst e)      = false
-isValue (Snd e)      = false
-isValue (Pair e1 e2) = (isValue e1) && (isValue e2)
-@-}
-
-{-@ type Value = {v: Expr | isValue v } @-}
-
----------------------------------------------------------------------
--------------------------- The Evaluator ----------------------------
----------------------------------------------------------------------
-
-{-@ decrease evalVar 2 @-}
-evalVar :: Bndr -> [(Bndr, Expr)] -> Expr
-evalVar x ((y,v):sto)
-  | x == y
-  = v
-  | otherwise
-  = evalVar x sto
-
-evalVar x []
-  = error "unbound variable"
-
-
-{-@ decrease eval 2 @-}
-{-@ eval :: [(Bndr, Value)] -> Expr -> ([(Bndr, Value)], Value) @-}
-eval sto (Const i)
-  = (sto, Const i)
-
-eval sto (Var x)
-  = (sto, evalVar x sto)
-
-eval sto (Plus e1 e2)
-  = let (_, e1') = eval sto e1
-        (_, e2') = eval sto e2
-    in case (e1, e2) of
-         (Const i1, Const i2) -> (sto, Const (i1 + i2))
-         _                    -> error "non-integer addition"
-
-eval sto (App e1 e2)
-  = let (_,    v2 ) = eval sto e2
-        (sto1, e1') = eval sto e1
-    in case e1' of
-         (Lam x e) -> eval ((x, v2): sto1) e
-         _         -> error "non-function application"
-
-eval sto (Lam x e)
-  = (sto, Lam x e)
-
-eval sto (Pair e1 e2)
-  = (sto, Pair v1 v2)
-  where (_, v1) = eval sto e1
-        (_, v2) = eval sto e2
-
-eval sto (Fst e)
-  = let (sto', e') = eval sto e in
-    case e' of
-      Pair v _ -> (sto', v)
-      _        -> error "non-tuple fst"
-
-eval sto (Snd e)
-  = let (sto', e') = eval sto e in
-    case e' of
-      Pair _ v -> (sto', v)
-      _        -> error "non-tuple snd"
-
----------------------------------------------------------------------
--------------------------- Value Checker ----------------------------
----------------------------------------------------------------------
-
-{-@ assert check :: {v: Expr | isValue v } -> Bool @-}
-check (Const _)    = True
-check (Lam _ _)    = True
-check (Var _)      = liquidAssertB False
-check (App _ _)    = liquidAssertB False
-check (Pair v1 v2) = check v1 && check v2
-check (Fst _)      = liquidAssertB False
-check (Snd _)      = liquidAssertB False
-check (Plus _ _)   = liquidAssertB False
-
----------------------------------------------------------------------
--------------------------- Unit Tests -------------------------------
----------------------------------------------------------------------
-
-{-
-tests =
-  let (f,g,x) = (0,1,2)
-      e1      = Lam x (Var x)
-      e2      = App e1 e1
-      e3      = Lam f (Lam g (Lam x (App (Var f)  (App (Var g) (Var x)))))
-      e4      = Const 10
-      e5      = App e1 e4
-      e6      = Lam x (Plus (Var x) e4)
-      e7      = App (App e3 e6) e6
-      e8      = Pair (App e7 (Const 0)) (App e7 (Const 100))
-      e9      = Fst e8
-      e10     = Snd e9
-      vs      = map (snd . eval []) [e1, e2, e3, e4, e5, e6, e7, e8, e9, e10]
-  in map check vs
-  -}
diff --git a/tests/pos/LambdaEvalMini.hs b/tests/pos/LambdaEvalMini.hs
deleted file mode 100644
--- a/tests/pos/LambdaEvalMini.hs
+++ /dev/null
@@ -1,93 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--no-totality" @-}
-
-module LambdaEvalMini () where
-
-import Language.Haskell.Liquid.Prelude
-
----------------------------------------------------------------------
------------------------ Datatype Definition -------------------------
----------------------------------------------------------------------
-
-type Bndr
-  = Int
-
-data Expr
-  = Lam Bndr Expr
-  | Var Bndr
-  | App Expr Expr
-
-{-@
-data Expr 
-  = Lam { eX :: Bndr, eBody :: Expr }
-  | Var { eX :: Bndr                }
-  | App { eF :: Expr, eArg  ::Expr  }
-@-}
-
-
-{-@ measure elen :: Expr -> Int
-    elen(Var x)     = 0
-    elen(Lam x e)   = 1 + (elen e)
-    elen(App e1 e2) = 1 + (elen e1) + (elen e2)
-  @-}
-
-{-@ invariant {v:Expr | (elen v) >= 0} @-}
-
-{-@  measure isValue :: Expr -> Bool
-     isValue (Lam x e)    = true
-     isValue (Var x)      = false
-     isValue (App e1 e2)  = false
-  @-}
-
-{-@ type Value = {v: Expr | isValue v } @-}
-
----------------------------------------------------------------------
--------------------------- The Evaluator ----------------------------
----------------------------------------------------------------------
-
-evalVar x ((y, v):sto)
-  | x == y
-  = v
-  | otherwise
-  = evalVar x sto
-
-evalVar x []
-  = unsafeError "unbound variable"
-
--- A "value" is simply: {v: Expr | isValue v } *)
-
-{-@ decrease eval 2 @-}
-{-@ eval :: [(Bndr, Value)] -> Expr -> ([(Bndr, Value)], Value) @-}
-
-eval sto (Var x)
-  = (sto, evalVar x sto)
-
-eval sto (App e1 e2)
-  = let (_,    v2 ) = eval sto e2
-        (sto1XXX, e1') = eval sto e1
-    in case e1' of
-         (Lam x e) -> eval ((x, v2): sto1XXX) e
-         _         -> unsafeError "non-function application"
-
-eval sto (Lam x e)
-  = (sto, Lam x e)
-
------------------------------------------------------------------------
----------------------------- Value Checker ----------------------------
------------------------------------------------------------------------
-
-check (Lam _ _)    = True
-check (Var _)      = liquidAssertB False
-check (App _ _)    = liquidAssertB False
-
------------------------------------------------------------------------
----------------------------- Unit Tests -------------------------------
------------------------------------------------------------------------
-mysnd (x, y) = y
-tests =
-  let (f,g,x) = (0,1,2)
-      e1      = Lam x (Var x)
-      e2      = App e1 e1
-      e3      = Lam f (Lam g (Lam x (App (Var f)  (App (Var g) (Var x)))))
-      vs      = map (mysnd . eval []) [e1, e2, e3]
-  in map check vs
diff --git a/tests/pos/LambdaEvalSuperTiny.hs b/tests/pos/LambdaEvalSuperTiny.hs
deleted file mode 100644
--- a/tests/pos/LambdaEvalSuperTiny.hs
+++ /dev/null
@@ -1,66 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--no-totality" @-}
-
-module LambdaEvalMini () where
-import Language.Haskell.Liquid.Prelude 
-
----------------------------------------------------------------------
------------------------ Datatype Definition -------------------------
----------------------------------------------------------------------
-
-data Pair a b = P a b
-data LL a     = Nil | Cons a (LL a)
-
-data Bndr
-
-data Expr
-  = Lam Bndr Expr
-  | Var Bndr
-  | App Expr Expr
-
-{-@
-data Expr
-  = Lam { eX :: Bndr, eBody :: Expr }
-  | Var { eX :: Bndr                }
-  | App { eF :: Expr, eArg  ::Expr  }
-@-}
-
-{-@ measure elen :: Expr -> Int
-    elen(Var x)     = 0
-    elen(Lam x e)   = 1 + (elen e)
-    elen(App e1 e2) = 1 + (elen e1) + (elen e2)
-  @-}
-
-{-@ invariant {v:Expr | (elen v) >= 0} @-}
-
-{-@  measure isValue :: Expr -> Bool
-     isValue (Lam x e)    = true
-     isValue (Var x)      = false
-     isValue (App e1 e2)  = false
-  @-}
-
-{-@ type Value = {v: Expr | (isValue v) } @-}
-{-@ type Store = LL (Pair Bndr Value)       @-}
-
----------------------------------------------------------------------
--------------------------- The Evaluator ----------------------------
----------------------------------------------------------------------
-
-{-@ evalVar :: Bndr -> Store -> Value @-}
-evalVar :: Bndr -> LL (Pair Bndr Expr) -> Expr
-evalVar = unsafeError "HIDEME"
-
-{-@ eval :: Store -> e:Expr -> (Pair Store Value) @-}
-{-@ decrease eval 2 @-}
-eval sto (Var x)
-  = P sto (evalVar x sto)
-
-eval sto (App e1 e2)
-  = let (P _    v2 ) = eval sto e2
-        (P sto1 e1') = eval sto e1
-    in case e1' of
-         (Lam x e) -> eval (Cons (P x v2) sto1) e
-         _         -> unsafeError "non-function application"
-
-eval sto (Lam x e)
-  = P sto (Lam x e)
diff --git a/tests/pos/LambdaEvalTiny.hs b/tests/pos/LambdaEvalTiny.hs
deleted file mode 100644
--- a/tests/pos/LambdaEvalTiny.hs
+++ /dev/null
@@ -1,65 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--no-totality" @-}
-
-module LambdaEvalMini () where
-import Language.Haskell.Liquid.Prelude 
-
----------------------------------------------------------------------
------------------------ Datatype Definition -------------------------
----------------------------------------------------------------------
-
-data Bndr
-
-data Expr
-  = Lam Bndr Expr
-  | Var Bndr
-  | App Expr Expr
-
-{-@
-data Expr 
-  = Lam { eX :: Bndr, eBody :: Expr }
-  | Var { eX :: Bndr                }
-  | App { eF :: Expr, eArg  ::Expr  }
-@-}
-
-{-@ measure elen :: Expr -> Int
-    elen (Var x)     = 0
-    elen (Lam x e)   = 1 + (elen e)
-    elen (App e1 e2) = 1 + (elen e1) + (elen e2)
-  @-}
-
-{-@ invariant {v:Expr | (elen v) >= 0} @-}
-
-{-@  measure isValue :: Expr -> Bool
-     isValue (Lam x e)    = true
-     isValue (Var x)      = false
-     isValue (App e1 e2)  = false
-  @-}
-
-{-@ type Value = {v: Expr | isValue v } @-}
-{-@ type Store = [(Bndr, Value)]            @-}
-
----------------------------------------------------------------------
--------------------------- The Evaluator ----------------------------
----------------------------------------------------------------------
-
-{-@ evalVar :: Bndr -> Store -> Value @-}
-evalVar :: Bndr -> [(Bndr, Expr)] -> Expr
-evalVar = unsafeError "HIDEME"
-
-{-@ decrease eval 2 @-}
-
-{-@ eval :: sto:Store -> e:Expr -> (Store, Value) @-}
-
-eval sto (Var x)
-  = (sto, evalVar x sto)
-
-eval sto (App e1 e2)
-  = let (_,    v2 ) = eval sto e2
-        (sto1, e1') = eval sto e1
-    in case e1' of
-         (Lam x e) -> eval ((x, v2) : sto1) e
-         _         -> unsafeError "non-function application"
-
-eval sto (Lam x e)
-  = (sto, Lam x e)
diff --git a/tests/pos/LazyWhere.hs b/tests/pos/LazyWhere.hs
deleted file mode 100644
--- a/tests/pos/LazyWhere.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module LazyWhere () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ pos :: Nat -> Int @-}
-pos :: Int -> Int
-pos = undefined
-
-
-{-@ lazyvar z @-}
-foo = if x > 0 then z else x
-  where z = pos x
-        x = choose 0
diff --git a/tests/pos/LazyWhere1.hs b/tests/pos/LazyWhere1.hs
deleted file mode 100644
--- a/tests/pos/LazyWhere1.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module LazyWhere () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ pos :: Nat -> Int @-}
-pos :: Int -> Int
-pos = undefined
-
-{-@ safeDiv :: Int -> {v:Int| v != 0} -> Int @-}
-safeDiv :: Int -> Int -> Int
-safeDiv = undefined
-
-{-@ lazyvar z @-}
-{-@ lazyvar z1 @-}
-{-@ lazyvar z2 @-}
-foo = if x > 0 then z else x
-  where z  = z1 + z2
-        z1 = 42 `safeDiv` x
-        z2 = pos x
-        x = choose 0
diff --git a/tests/pos/Lib521.hs b/tests/pos/Lib521.hs
deleted file mode 100644
--- a/tests/pos/Lib521.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Lib521 where
-
-{-@ measure size @-}
-{-@ size    :: xs:[a] -> {v:Nat | v = size xs} @-}
-size :: [a] -> Int
-size []     = 0
-size (_:rs) = 1 + size rs
diff --git a/tests/pos/ListConcat.hs b/tests/pos/ListConcat.hs
deleted file mode 100644
--- a/tests/pos/ListConcat.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-{-@ LIQUID "--no-termination" @-}
-
-module Foo () where
-import Data.Set (Set(..)) 
-import Prelude hiding (concat)
-
-{-@ measure llElts :: [[a]] -> (Set a) 
-    llElts([])   = {v | Set_emp v }
-    llElts(x:xs) = {v | v = Set_cup (listElts x) (llElts xs) }
-  @-}
-
-
-{-@ concat :: ys:[[a]] -> {v:[a] | listElts v = llElts ys } @-}
-concat :: [[a]] ->  [a]
-concat  []         = []
-concat ([]: xs)    = concat xs
-concat ((y:ys):xs) = y : concat (ys:xs)
-
-
-
-
-
-
diff --git a/tests/pos/ListElem.hs b/tests/pos/ListElem.hs
deleted file mode 100644
--- a/tests/pos/ListElem.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module ListElem () where
-
-import Data.Set
-
-{-@ listElem :: (Eq a) 
-             => y:a 
-             -> xs:[a]
-             -> {v:Bool | v <=> Set_mem y (listElts xs)} 
-  @-}
-
-listElem :: (Eq a) => a -> [a] -> Bool
-listElem _ []     = False
-listElem y (x:xs) | x == y    = True
-                  | otherwise = listElem y xs
-
diff --git a/tests/pos/ListISort-bag.hs b/tests/pos/ListISort-bag.hs
deleted file mode 100644
--- a/tests/pos/ListISort-bag.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module ListSort where
-
-import qualified Language.Haskell.Liquid.Bag as B
-
-{-@ type OList a = [a]<{\fld v -> v >= fld}> @-}
-
-{-@ insertSort    :: (Ord a) => xs:[a] -> {v : OList a | bag v = bag xs} @-}
-insertSort        :: (Ord a) => [a] -> [a]
-insertSort []     = []
-insertSort (x:xs) = insert x (insertSort xs)
-
-{-@ insert      :: (Ord a) => x:a -> xs: OList a -> {v: OList a | bag v = B.put x (bag xs) } @-}
-insert y []     = [y]
-insert y (x:xs)
-  | y <= x    	= y : x : xs
-  | otherwise 	= x : insert y xs
-
-{-@ measure bag @-}
-bag :: (Ord a) => [a] -> B.Bag a
-bag []     = B.empty
-bag (x:xs) = B.put x (bag xs)
diff --git a/tests/pos/ListISort-perm.hs b/tests/pos/ListISort-perm.hs
deleted file mode 100644
--- a/tests/pos/ListISort-perm.hs
+++ /dev/null
@@ -1,97 +0,0 @@
-{-# LANGUAGE GADTs            #-}
-{-@ LIQUID "--exact-data-con" @-}
-{-@ LIQUID "--higherorder"    @-}
-
-module ListSort where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-
--- FULL SIGS: don't work right now, thanks to https://github.com/ucsd-progsys/liquidhaskell/issues/1205
-{-type OList a = List <{\fld v -> v >= fld}> a @-}
-{- insertSort :: (Ord a) => xs:List a -> (res :: OList a, {v:_ | prop v = Perm xs res})          @-}
-{- insert     :: (Ord a) => x:a -> xs:OList a -> (res :: OList a, {v:_ | prop v = Ins x xs res}) @-}
-
-{-@ insertSort :: (Ord a) => xs:List a -> (res :: List a, {v:_ | prop v = (Perm xs res)})         @-}
-insertSort        :: (Ord a) => List a -> (List a, Perm a)
-insertSort Nil         = (Nil, NilPerm)
-insertSort (Cons x xs) = (xys, ConsPerm x xs ys xys x_ys_xys xs_ys)
-  where
-    (ys,  xs_ys)       = insertSort xs
-    (xys, x_ys_xys)    = insert x ys
-
-{-@ insert     :: (Ord a) => x:a -> xs:List a -> (res :: List a, {v:_ | prop v = (Ins x xs res)}) @-}
-insert    :: (Ord a) => a -> List a -> (List a, Ins a)
-insert y (Cons x xs)
-  | y <= x    = (Cons y (Cons x xs), Here y (Cons x xs) )
-  | otherwise = (Cons x yxs        , There y x xs yxs pf)
-  where
-    (yxs, pf) = insert y xs
-insert y Nil  = (Cons y Nil, Here y Nil)
-
--- | Lists ---------------------------------------------------------------------
-
-data List a
-  = Nil
-  | Cons { lHd :: a, lTl :: List a }
-
-{-@ data List [llen] a <p :: x0:a -> x1:a -> Bool>
-      = Nil
-      | Cons { lHd :: a, lTl :: List <p> (a <p lHd>) }
-  @-}
-
--- | List Membership -----------------------------------------------------------
-
-data InsP a where
-  Ins :: a -> List a -> List a -> InsP a
-
-data Ins a where
-  Here  :: a -> List a -> Ins a
-  There :: a -> a -> List a -> List a -> Ins a -> Ins a
-
-{-@ data Ins [insNat] a where
-        Here  :: m:a -> ms:List a
-              -> Prop (Ins m ms (Cons m ms))
-
-      | There :: m:a -> n:a -> ns:List a -> mns:List a
-              -> Prop (Ins m ns mns)
-              -> Prop (Ins m (Cons n ns) (Cons n mns))
-  @-}
-
--- | Permutations --------------------------------------------------------------
-
-data PermP a where
-  Perm :: List a -> List a -> PermP a
-
-data Perm a where
-  NilPerm  :: Perm a
-  ConsPerm :: a -> List a -> List a -> List a -> Ins a -> Perm a -> Perm a
-
-{-@ data Perm [permNat] a where
-        NilPerm  :: Prop (Perm Nil Nil)
-      | ConsPerm :: m:a -> ms:List a -> ns:List a -> mns:List a
-                 -> Prop (Ins m ns mns)
-                 -> Prop (Perm ms ns)
-                 -> Prop (Perm (Cons m ms) mns)
-  @-}
-
-
--- | BOILERPLATE ---------------------------------------------------------------
-
-{-@ measure permNat @-}
-{-@ permNat :: Perm a -> Nat @-}
-permNat :: Perm a -> Int
-permNat (NilPerm)              = 0
-permNat (ConsPerm _ _ _ _ _ t) = 1 + permNat t
-
-{-@ measure insNat @-}
-{-@ insNat :: Ins a -> Nat @-}
-insNat :: Ins a -> Int
-insNat (Here _ _)        = 0
-insNat (There _ _ _ _ t) = 1 + insNat t
-
-{-@ measure llen          @-}
-{-@ llen :: List a -> Nat @-}
-llen :: List a -> Int
-llen Nil        = 0
-llen (Cons h t) = 1 + llen t
diff --git a/tests/pos/ListKeys.hs b/tests/pos/ListKeys.hs
deleted file mode 100644
--- a/tests/pos/ListKeys.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-{- LIQUID "--pruneunsorted" @-}
-
-module Foo () where
-import Data.Set (Set(..), empty, union, singleton) 
-
-{-@  measure listKeys @-}
-listKeys :: Ord k => [(k, v)] -> Set k 
-listKeys [] = empty 
-listKeys (x:xs) = singleton (myfst x) `union` listKeys xs 
-
-{-@ measure myfst @-}
-myfst :: (a,b) -> a 
-myfst (x,_) = x 
-
-{-@ getFsts :: ys:[(a, b)] -> {v : [a] | listElts v = listKeys ys } @-}
-getFsts ::[(a, b)] ->  [a]
-getFsts []           = []
-getFsts ((x, _): xs) = x : getFsts xs
-
-
-
-
-
-
diff --git a/tests/pos/ListLen-LType.hs b/tests/pos/ListLen-LType.hs
deleted file mode 100644
--- a/tests/pos/ListLen-LType.hs
+++ /dev/null
@@ -1,54 +0,0 @@
-module ListLen (llen) where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@  
-data List [llen] a <p :: x0:a -> x1:a -> Bool>  
-  = Nil 
-  | Cons (h :: a) (t :: List <p> (a <p h>))
-@-}
-
-{-@ measure llen @-}
-llen :: (List a) -> Int
-{-@ llen :: List a -> Nat @-}
-llen Nil         = 0
-llen (Cons x xs) = 1 + (llen xs)
-
-data List a = Nil | Cons a (List a)
-
-make2d :: a -> Int -> Int -> List ([a])
-make2d x n m = cloneL (clone x n) m
-
-{-@ invariant {v:Int | v >= 0} @-}
-
-clone :: a -> Int -> [a]
-clone x n
-  | n == 0
-  = []
-  | otherwise 
-  = x : (clone x (n-1))
-
-cloneL :: a -> Int -> List a
-cloneL x n
-  | n == 0
-  = Nil
-  | otherwise 
-  = Cons x  (cloneL x (n-1))
-
--- check [] = [liquidAssertB True]
--- check (xs:xss) = let n = length xs in map (\xs' -> liquidAssertB (length xs' == n)) xss
-
-chk :: List [a] -> Bool
-chk Nil = liquidAssertB True
-chk (Cons xs xss) =
-  case xss of 
-   (Cons xs1 xss1) -> let n = length xs in liquidAssertB (length xs1 == n) && chk xss
-   Nil -> liquidAssertB True
-
-fooL  = Cons [1, 1, 3] (Cons [2, 2, 5] Nil)
-fooL1 = make2d 0 n m
-  where n = choose 0
-        m = choose 1
-
-propL = chk fooL1
-prop  = chk fooL
diff --git a/tests/pos/ListLen.hs b/tests/pos/ListLen.hs
deleted file mode 100644
--- a/tests/pos/ListLen.hs
+++ /dev/null
@@ -1,71 +0,0 @@
-module ListClone () where
-
-import Language.Haskell.Liquid.Prelude
-
-make2d :: a -> Int -> Int -> [[a]]
-make2d x n m = clone (clone x n) m
-
-clone :: a -> Int -> [a]
-clone x n
-  | n == 0
-  = []
-  | otherwise 
-  = x : (clone x (n-1))
-
-
-
--- check [] = [liquidAssertB True]
--- check (xs:xss) = let n = length xs in map (\xs' -> liquidAssertB (length xs' == n)) xss
-
-chk :: [[a]] -> Bool
-chk [] = liquidAssertB True
-chk (xs:xss) =
-  case xss of 
-   (xs1:xss1) -> let n = length xs in liquidAssertB (length xs1 == n) && chk xss
-   []         -> liquidAssertB True
-
-fooL  = [[1, 1, 3], [2, 2, 5]]
-fooL1 = let f = make2d n0 n1 n2 in f
-    where n0 = 0
-          n1 = 2
-          n2 = 3
-propL = chk fooL1
-prop  = chk fooL
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/ListMSort-LType.hs b/tests/pos/ListMSort-LType.hs
deleted file mode 100644
--- a/tests/pos/ListMSort-LType.hs
+++ /dev/null
@@ -1,60 +0,0 @@
-module ListRange () where
-{-@ LIQUID "--no-termination" @-}
-
-import Language.Haskell.Liquid.Prelude
-
-{-@  
-data List a <p :: x0:a -> x1:a -> Bool>  
-  = Nil 
-  | Cons (h :: a) (t :: List <p> (a <p h>))
-@-}
-data List a = Nil | Cons a (List a)
-
-
--- This is needed to conclude that 
--- xs = Nil /\ xs = Cons _ _ <=> false
-
-{-@ measure llen :: (List a) -> Int
-    llen(Nil)       = 0
-    llen(Cons x xs) = 1 + (llen xs)
-  @-}
-
-{-@ invariant {v:List a | (llen v) >= 0} @-}
-
-split :: List a -> (List a, List a)
-split (Cons x (Cons y zs)) = (Cons x xs, Cons y ys) where (xs, ys) = split zs
-split xs                   = (xs, Nil)
-
-
-{-@ lazy merge @-}
-merge :: Ord a => List a -> List a -> List a
-merge xs Nil = xs
-merge Nil ys = ys
-merge (Cons x xs) (Cons y ys)
-  | x <= y
-  = Cons x (merge xs (Cons y ys))
-  | otherwise 
-  = Cons y (merge (Cons x xs) ys)
-
-mergesort :: Ord a => List a -> List a
-mergesort Nil = Nil
-mergesort (Cons x Nil) = Cons x Nil
-mergesort xs = merge (mergesort xs1) (mergesort xs2) where (xs1, xs2) = split xs
-
-chk y = 
-  case y of 
-   Nil -> True
-   Cons x1 xs -> case xs of 
-                  Nil -> True
-                  Cons x2 xs2 -> liquidAssertB (x1 <= x2) && chk xs2
-																	
-bar = mergesort $ mkList [1 .. 100]
-
-barI :: List Int
-barI = Cons 1 $ Cons 2 $ Cons 3 Nil
-
-mkList :: Ord a => [a] -> List a
-mkList = foldr Cons Nil
-
-prop0 = chk bar
-prop1 = chk barI
diff --git a/tests/pos/ListMSort.hs b/tests/pos/ListMSort.hs
deleted file mode 100644
--- a/tests/pos/ListMSort.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-module ListSort () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ type OList a = [a]<{\fld v -> (v >= fld)}>  @-}
-
-{-@ predicate Pr X Y = (((len Y) > 1) => ((len Y) < (len X))) @-}
-
-{-@ split :: xs:[a] 
-          -> ({v:[a] | (Pr xs v)}, {v:[a]|(Pr xs v)})
-                 <{\x y -> ((len x) + (len y) = (len xs))}> 
-  @-}
-
-split :: [a] -> ([a], [a])
-split (x:(y:zs)) = (x:xs, y:ys) where (xs, ys) = split zs
-split xs                   = (xs, [])
-
-
-{-@ decrease merge 4 @-}
-{-@ merge :: Ord a => xs:(OList a) -> ys:(OList a) -> d:{v:Int| v = (len xs) + (len ys)} -> {v:(OList a) | (len v) = d} @-}
-merge :: Ord a => [a] -> [a] -> Int -> [a]
-merge xs [] _ = xs
-merge [] ys _ = ys
-merge (x:xs) (y:ys) d
-  | x <= y
-  = x:(merge xs (y:ys) (d-1))
-  | otherwise 
-  = y:(merge (x:xs) ys (d-1))
-
-{-@ mergesort :: (Ord a) => xs:[a] -> {v:(OList a) | (len v) = (len xs)}  @-}
-mergesort :: Ord a => [a] -> [a]
-mergesort []  = []
-mergesort [x] = [x]
-mergesort xs  = merge (mergesort xs1) (mergesort xs2) d 
-  where (xs1, xs2) = split xs
-        d          = length xs
-
diff --git a/tests/pos/ListQSort-LType.hs b/tests/pos/ListQSort-LType.hs
deleted file mode 100644
--- a/tests/pos/ListQSort-LType.hs
+++ /dev/null
@@ -1,54 +0,0 @@
-module ListRange (llen) where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@
-data List [llen] a <p :: x0:a -> x1:a -> Bool>
-  = Nil
-  | Cons { lHd :: a, lTl :: List <p> (a <p lHd>) }
-@-}
-
-{-@ measure llen @-}
-llen :: (List a) -> Int
-{-@ llen :: List a -> Nat @-}
-llen Nil         = 0
-llen (Cons x xs) = 1 + (llen xs)
-
-
-{-@ qualif ZLLen(v:ListRange.List a) : (llen(v) >= 0)@-}
-
-{-@ qualif CmpLLen(v:ListRange.List a, a:ListRange.List b) : (llen v <= llen a) @-}
-
-data List a = Nil | Cons a (List a)
-
-append k Nil         ys = Cons k ys
-append k (Cons x xs) ys = Cons x (append k xs ys)
-
-takeL x Nil         = Nil
-takeL x (Cons y ys) = if (y<x) then Cons y (takeL x ys) else takeL x ys
-
-{-@ takeGE :: Ord a
-           => x:a
-           -> xs:List a
-           -> {v: (List {v:a | v >= x}) | ((llen v) <= (llen xs))}  @-}
-takeGE x Nil         = Nil
-takeGE x (Cons y ys) = if (y>=x) then Cons y (takeGE x ys) else takeGE x ys
-
-quicksort Nil = Nil
-quicksort (Cons x xs) = append x xsle xsge
-  where xsle = quicksort (takeL x xs)
-        xsge = quicksort (takeGE x xs)
-
-chk y =
-  case y of
-   Nil -> True
-   Cons x1 xs -> case xs of
-                 Nil -> True
-                 Cons x2 xs2 -> liquidAssertB (x1 <= x2) && chk xs
-
-bar = quicksort $ mkList [1 .. 100]
-
-mkList :: Ord a => [a] -> List a
-mkList = foldr Cons Nil
-
-prop0 = chk bar
diff --git a/tests/pos/ListRange-LType.hs b/tests/pos/ListRange-LType.hs
deleted file mode 100644
--- a/tests/pos/ListRange-LType.hs
+++ /dev/null
@@ -1,38 +0,0 @@
-module ListRange () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ LIQUID "--no-termination" @-}
-
-{-@
-data List a <p :: x0:a -> x1:a -> Bool>
-  = Nil
-  | Cons { lHd :: a, lTl :: List <p> (a <p lHd>) }
-@-}
-
-{-@ measure llen :: (List a) -> Int
-    llen(Nil)       = 0
-    llen(Cons x xs) = 1 + (llen xs)
-  @-}
-
-{-@ invariant {v:(List a) | ((llen v) >= 0)} @-}
-
-data List a = Nil | Cons a (List a)
-
-{-
-low, high :: Int
-low  = 0
-high = 10
--}
-
-range l h =
-  if l <= h then Cons l (range (l+1) h) else Nil
-
-chk y =
-  case y of
-   Nil -> True
-   Cons x1 xs -> case xs of
-                 Nil -> True
-                 Cons x2 xs2 -> liquidAssertB (x1 <= x2) && chk xs2
-
-prop3 = chk $ range 1 100
diff --git a/tests/pos/ListRange.hs b/tests/pos/ListRange.hs
deleted file mode 100644
--- a/tests/pos/ListRange.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module ListSort () where
-
-{-@ LIQUID "--no-termination" @-}
-
-import Language.Haskell.Liquid.Prelude
-
-low, high :: Int
-low  = choose 0
-high = choose 10
-
-range l h = 
-  if l <= h then l:(range (l+1) h) else []
-
-chk [] = liquidAssertB True
-chk (x1:xs) = case xs of 
-              []       -> liquidAssertB True
-              (x2:xs2) -> liquidAssertB (x1 <= x2) && chk xs
-
-prop = chk $ range low high
diff --git a/tests/pos/ListReverse-LType.hs b/tests/pos/ListReverse-LType.hs
deleted file mode 100644
--- a/tests/pos/ListReverse-LType.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Reverse (x, llen) where
-
-import Language.Haskell.Liquid.Prelude        
-import Prelude hiding (reverse)
-data L a = N | C a (L a)
-
-{-@ data L [llen] @-}
-
-{-@ measure llen @-}
-llen :: (L a) -> Int
-{-@ llen :: L a -> Nat @-}
-llen N        = 0
-llen (C x xs) = 1 + (llen xs)
-
-{-@ invariant {v: L a | (llen v) >= 0} @-}
-reverse N xs = xs
-reverse (C y ys) xs = reverse ys (C y xs)
-
-x = reverse (C 1 (C 2 N))
diff --git a/tests/pos/ListSort.hs b/tests/pos/ListSort.hs
deleted file mode 100644
--- a/tests/pos/ListSort.hs
+++ /dev/null
@@ -1,67 +0,0 @@
-module ListSort (insertSort, insertSort', mergeSort, quickSort) where
-
-
-{-@ type OList a    = [a]<{\fld v -> (v >= fld)}> @-}
-{-@ type OListN a N = {v:OList a | len v == N} @-}
-
-------------------------------------------------------------------------------
--- Insert Sort ---------------------------------------------------------------
-------------------------------------------------------------------------------
-
-{-@ insertSort :: (Ord a) => xs:[a] -> OList a @-}
-insertSort            :: (Ord a) => [a] -> [a]
-insertSort []         = []
-insertSort (x:xs)     = insert x (insertSort xs) 
-
-{-@ insertSort' :: (Ord a) => xs:[a] -> OList a @-}
-insertSort'           :: (Ord a) => [a] -> [a]
-insertSort' xs        = foldr insert [] xs
-
-insert y []                   = [y]
-insert y (x : xs) | y <= x    = y : x : xs 
-                  | otherwise = x : insert y xs
-
-------------------------------------------------------------------------------
--- Merge Sort ----------------------------------------------------------------
-------------------------------------------------------------------------------
-
-{-@ mergeSort :: (Ord a) => xs:[a] -> OListN a {len xs} @-}
-mergeSort :: Ord a => [a] -> [a]
-mergeSort []   = []
-mergeSort [x]  = [x]
-mergeSort xs   = merge (mergeSort xs1) (mergeSort xs2) 
-  where 
-    (xs1, xs2) = split xs
-
-{-@ type Half a Ys  = {v:[a] | (len v > 1) => (len v < len Ys)} @-}
-
-{-@ type Halves a Xs = {v: (Half a Xs, Half a Xs) | len (fst v) + len (snd v) == len Xs} @-}
- 
-{-@ split :: xs:[a] -> Halves a xs @-}
-split :: [a] -> ([a], [a])
-split (x:(y:zs)) = (x:xs, y:ys) where (xs, ys) = split zs
-split xs         = (xs, [])
-
-{-@ merge :: Ord a => xs:OList a -> ys:OList a -> OListN a {len xs + len ys} / [(len xs + len ys)] @-}
-merge :: Ord a => [a] -> [a] ->  [a]
-merge xs []         = xs
-merge [] ys         = ys
-merge (x:xs) (y:ys)
-  | x <= y          = x: merge xs (y:ys)
-  | otherwise       = y : merge (x:xs) ys
-
-------------------------------------------------------------------------------
--- Quick Sort ----------------------------------------------------------------
-------------------------------------------------------------------------------
-
-{-@ quickSort :: (Ord a) => [a] -> OList a @-}
-quickSort []     = []
-quickSort (x:xs) = append x lts gts 
-  where 
-    lts          = quickSort [y | y <- xs, y < x]
-    gts          = quickSort [z | z <- xs, z >= x]
-
-append k []     ys  = k : ys
-append k (x:xs) ys  = x : append k xs ys
-
-
diff --git a/tests/pos/LocalHole.hs b/tests/pos/LocalHole.hs
deleted file mode 100644
--- a/tests/pos/LocalHole.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-module LocalHole where
-
-{-@ assume (!!) :: xs:[a] -> {v:Nat | v < len xs} -> a @-}
-
-mysum xs = go 0 0
-  where
-    n = length xs
-    {-@ go :: i:{Nat | i <= n} -> _ -> _ @-}
-    go i acc
-      | i >= n    = acc
-      | otherwise = go (i+1) (acc + xs !! i)
diff --git a/tests/pos/LocalLazy.hs b/tests/pos/LocalLazy.hs
deleted file mode 100644
--- a/tests/pos/LocalLazy.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module LocalLazy (bar) where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ lazy foo @-}
-foo x = foo x
-
-
-bar = liquidAssertB (inf n > 0)
-  where n     = choose 0
-       {-@ lazy inf @-}
-        inf n = inf n
diff --git a/tests/pos/LocalSpec.hs b/tests/pos/LocalSpec.hs
deleted file mode 100644
--- a/tests/pos/LocalSpec.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module LocalSpec where
-
-import LocalSpecLib
-
-{-@ bar :: {x:Int | x > 99} -> {v:Int | v > 100 } @-}
-bar :: Int -> Int
-bar x = foo x
diff --git a/tests/pos/LocalSpecLib.hs b/tests/pos/LocalSpecLib.hs
deleted file mode 100644
--- a/tests/pos/LocalSpecLib.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module LocalSpecLib (foo) where
-
-{-@ foo :: x:Int -> {v:Int | v > x } @-}
-foo :: Int -> Int
-foo x =  go x
-
-{-@ go :: n:Int -> {v:Int | v = n + 1} @-}
-go :: Int -> Int
-go x = x + 1
diff --git a/tests/pos/LogicCurry1.hs b/tests/pos/LogicCurry1.hs
deleted file mode 100644
--- a/tests/pos/LogicCurry1.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-{-@ LIQUID "--higherorder"     @-}
-{-@ LIQUID "--maxparams=5"     @-}
-
-
-{-@ measure ackF :: Int -> Int -> Int  @-}
-
-{-@ assume ack :: n:Int -> {v: (x:Int -> {v:Int | v == ackF n x}) | v == ackF n } @-}
-ack :: Int -> Int -> Int
-ack = undefined
-
-bar :: Int -> Int -> Int
-{-@ bar :: n:Int -> {v:_ | v == ackF n } @-}
-bar m = ack m
-
-main :: IO ()
-main = pure ()
diff --git a/tests/pos/Loo.hs b/tests/pos/Loo.hs
deleted file mode 100644
--- a/tests/pos/Loo.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Loo where
-
-import qualified LooLib as G
-
-plusThree = G.plusOne . G.plusTwo
-plusFour  = G.plusTwo . G.plusTwo
-
-{-@ assert pp :: z:Int -> {v:Int| v > z} @-}
-pp x      = G.plusOne (G.plusOne x)
-
-
-($$$) x  = x + 1
diff --git a/tests/pos/LooLib.hs b/tests/pos/LooLib.hs
deleted file mode 100644
--- a/tests/pos/LooLib.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module LooLib ( module LooLibLib , plusTwo ) where
-
-import LooLibLib 
-
-{-@ plusTwo :: x:Int -> {v:Int | v = x + 2} @-}
-plusTwo :: Int -> Int
-plusTwo = plusOne . plusOne
-
diff --git a/tests/pos/LooLibLib.hs b/tests/pos/LooLibLib.hs
deleted file mode 100644
--- a/tests/pos/LooLibLib.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module LooLibLib (plusOne) where
-
-{-@ plusOne :: x:Int -> {v:Int| v = x + 1 } @-}
-plusOne :: Int -> Int
-plusOne x = x + 1
diff --git a/tests/pos/Map.hs b/tests/pos/Map.hs
deleted file mode 100644
--- a/tests/pos/Map.hs
+++ /dev/null
@@ -1,182 +0,0 @@
-module Map (error, mllen) where
-
-import Language.Haskell.Liquid.Prelude
-
-import Prelude hiding (error)
-
-{-@ lazy error @-}
-error :: a -> b
-error x = error x
-
-{-@
-  data Map [mllen] k a <l :: root:k -> k -> Bool, r :: root:k -> k -> Bool>
-      = Tip
-      | Bin { mSz    :: Size
-            , mKey   :: k
-            , mValue :: a
-            , mLeft  :: Map <l, r> (k <l mKey>) a
-            , mRight :: Map <l, r> (k <r mKey>) a }
-  @-}
-
-{-@ measure mllen @-}
-mllen :: Map k a -> Int 
-{-@ mllen :: Map k a -> Nat @-}
-mllen Tip = 0 
-mllen (Bin _ _ _ l r) = 1 + if (mllen l < mllen r) then mllen r else mllen l
-
-
-{-@ measure mlen :: (Map k a) -> Int
-    mlen(Tip) = 0
-    mlen(Bin s k v l r) = 1 + (mlen l) + (mlen r)
-  @-}
-
-{-@ invariant {v:Map k a | (mlen v) >= 0}@-}
-
-{-@ type OMap k a = Map <{\root v -> v < root }, {\root v -> v > root}> k a @-}
-
-data Map k a = Tip
-             | Bin Size k a (Map k a) (Map k a)
-
-type Size    = Int
-
-{-@ singleton :: k -> a -> OMap k a @-}
-singleton :: k -> a -> Map k a
-singleton k x
-  = Bin 1 k x Tip Tip
-
-{-@ insert :: Ord k => k -> a -> OMap k a -> OMap k a @-}
-insert :: Ord k => k -> a -> Map k a -> Map k a
-insert kx x t
-  = case t of
-     Tip -> singleton kx x
-     Bin sz ky y l r
-         -> case compare kx ky of
-              LT -> balance ky y (insert kx x l) r
-              GT -> balance ky y l (insert kx x r)
-              EQ -> Bin sz kx x l r
-
-{-@ delete :: (Ord k) => k:k -> OMap k a -> OMap {v:k| (v /= k)} a @-}
-delete :: Ord k => k -> Map k a -> Map k a
-delete k t
-  = case t of
-      Tip -> Tip
-      Bin _ kx x l r
-          -> case compare k kx of
-               LT -> balance kx x (delete k l) r
-               GT -> balance kx x l (delete k r)
-               EQ -> glue kx l r
-
-
-glue :: k -> Map k a -> Map k a -> Map k a
-glue k Tip r = r
-glue k l Tip = l
-glue k l r
-  | size l > size r = let (km1, vm, lm) = deleteFindMax l in balance km1 vm lm r
-  | otherwise       = let (km2, vm, rm) = deleteFindMin r in balance km2 vm l rm
-
-deleteFindMax t
-  = case t of
-      Bin _ k x l Tip -> (k, x, l)
-      Bin _ k x l r -> let (km3, vm, rm) = deleteFindMax r in (km3, vm, (balance k x l rm))
-      Tip           -> (error ms, error ms, Tip)
-  where ms = "Map.deleteFindMax : can not return the maximal element of an empty Map"
-
-
-deleteFindMin t
-  = case t of
-      Bin _ k x Tip r -> (k, x, r)
-      Bin _ k x l r -> let (km4, vm, lm) = deleteFindMin l in (km4, vm, (balance k x lm r))
-      Tip             -> (error ms, error ms, Tip)
-  where ms = "Map.deleteFindMin : can not return the maximal element of an empty Map"
-
-
--------------------------------------------------------------------------------
---------------------------------- BALANCE -------------------------------------
--------------------------------------------------------------------------------
-
-delta, ratio :: Int
-delta = 5
-ratio = 2
-
-balance :: k -> a -> Map k a -> Map k a -> Map k a
-balance k x l r
-  | sizeL + sizeR <= 1   = Bin sizeX k x l r
-  | sizeR >= delta*sizeL = rotateL k x l r
-  | sizeL >= delta*sizeR = rotateR k x l r
-  | otherwise            = Bin sizeX k x l r
-  where sizeL = size l
-        sizeR = size r
-        sizeX = sizeL + sizeR + 1
-
--- rotate
-rotateL :: a -> b -> Map a b -> Map a b -> Map a b
-rotateL k x l r@(Bin _ _ _ ly ry)
-  | size ly < ratio*size ry  = singleL k x l r
-  | otherwise                = doubleL k x l r
-rotateL _ _ _ Tip = error "rotateL Tip"
-
-rotateR :: a -> b -> Map a b -> Map a b -> Map a b
-rotateR k x l@(Bin _ _ _ ly ry) r
-  | size ry < ratio*size ly  = singleR k x l r
-  | otherwise                = doubleR k x l r
-rotateR _ _ Tip _ = error "rotateR Tip"
-
--- basic rotations
-singleL, singleR :: a -> b -> Map a b -> Map a b -> Map a b
-singleL k1 x1 t1 (Bin _ k2 x2 t2 t3) = bin k2 x2 (bin k1 x1 t1 t2) t3
-singleL _  _  _ Tip                  = error "sinlgeL Tip"
-singleR k1 x1 (Bin _ k2 x2 t1 t2) t3 = Bin 0 k2 x2 t1 (Bin 0 k1 x1 t2 t3)
-singleR _  _  Tip _                  = error "sinlgeR Tip"
-
-doubleL, doubleR :: a -> b -> Map a b -> Map a b -> Map a b
-doubleL k1 x1 t1 (Bin _ k2 x2 (Bin _ k3 x3 t2 t3) t4)
- =bin k3 x3 (bin k1 x1 t1 t2) (bin k2 x2 t3 t4)
-doubleL _ _ _ _ = error "doubleL"
-doubleR k1 x1 (Bin _ k2 x2 t1 (Bin _ k3 x3 t2 t3)) t4
-  = bin k3 x3 (bin k2 x2 t1 t2) (bin k1 x1 t3 t4)
-doubleR _ _ _ _ = error "doubleR"
-
-bin :: k -> a -> Map k a -> Map k a -> Map k a
-bin k x l r
-  = Bin (size l + size r + 1) k x l r
-
-size :: Map k a -> Int
-size t
-  = case t of
-      Tip            -> 0
-      Bin sz _ _ _ _ -> sz
-
-
--- chkDel x Tip                = liquidAssertB True
--- chkDel x (Bin sz k v lt rt) = liquidAssertB (not (x == k)) && chkDel x lt && chkDel x rt
-
--- chkMin x Tip                = liquidAssertB True
--- chkMin x (Bin sz k v lt rt) = liquidAssertB (x<k) && chkMin x lt && chkMin x rt
-
-chk Tip               = liquidAssertB True
-chk (Bin s k v lt rt) = chk lt && chk rt && chkl k lt && chkr k rt
-
-chkl k Tip              = liquidAssertB True
-chkl k (Bin _ kl _ _ _) = liquidAssertB (kl < k)
-
-chkr k Tip              = liquidAssertB True
-chkr k (Bin _ kr _ _ _) = liquidAssertB (k < kr)
-
-key, key1, val, val1 :: Int
-key = choose 0
-val = choose 1
-key1 = choose 0
-val1 = choose 1
-
-bst1 = insert key val Tip
-bst  = insert key val $ insert key1 val1 Tip
-
-mkBst = foldl (\t (k, v) -> insert k v t) Tip
-
-prop        = chk bst1
-prop1       = chk $ mkBst $ zip [1..] [1..]
-
-propDelete  = chk bst' -- && chkDel x bst'
-   where
-     x      = choose 0
-     bst'   = delete x bst
diff --git a/tests/pos/Map0.hs b/tests/pos/Map0.hs
deleted file mode 100644
--- a/tests/pos/Map0.hs
+++ /dev/null
@@ -1,183 +0,0 @@
-module Map (mllen) where
-
-import Language.Haskell.Liquid.Prelude
-
-import Prelude hiding (error)
-
-{-@ lazy error @-}
-{-@ error :: a -> b @-}
-error :: a -> b
-error x = error x
-
-
-{-@
-    data Map [mllen] k a <l :: root:k -> k -> Bool, r :: root:k -> k -> Bool>
-        = Tip
-        | Bin { mSz    :: Size
-              , mKey   :: k
-              , mValue :: a
-              , mLeft  :: Map <l, r> (k <l mKey>) a
-              , mRight :: Map <l, r> (k <r mKey>) a }
-  @-}
-
-{-@ measure mllen @-}
-mllen :: Map k a -> Int 
-{-@ mllen :: Map k a -> Nat @-}
-mllen Tip = 0 
-mllen (Bin _ _ _ l r) = 1 + if (mllen l < mllen r) then mllen r else mllen l
-
-
-{-@ type OMap k a = Map <{\root v -> v < root }, {\root v -> v > root}> k a @-}
-
-{-@ measure mlen :: (Map k a) -> Int
-    mlen(Tip) = 0
-    mlen(Bin s k v l r) = 1 + (mlen l) + (mlen r)
-  @-}
-
-{-@ invariant {v:Map k a | (mlen v) >= 0}@-}
-
-data Map k a = Tip
-             | Bin Size k a (Map k a) (Map k a)
-
-type Size    = Int
-
-{-@ singleton :: k -> a -> OMap k a @-}
-singleton :: k -> a -> Map k a
-singleton k x
-  = Bin 1 k x Tip Tip
-
-
-{-@ insert :: Ord k => k -> a -> OMap k a -> OMap k a @-}
-insert :: Ord k => k -> a -> Map k a -> Map k a
-insert kx x t
-  = case t of
-     Tip -> singleton kx x
-     Bin sz ky y l r
-         -> case compare kx ky of
-              LT -> balance ky y (insert kx x l) r
-              GT -> balance ky y l (insert kx x r)
-              EQ -> Bin sz kx x l r
-
-{-@ delete :: (Ord k) => k:k -> OMap k a -> OMap {v:k | (v /= k)} a @-}
-delete :: Ord k => k -> Map k a -> Map k a
-delete k t
-  = case t of
-      Tip -> Tip
-      Bin _ kx x l r
-          -> case compare k kx of
-               LT -> balance kx x (delete k l) r
-               GT -> balance kx x l (delete k r)
-               EQ -> glue kx l r
-
-
-glue :: k -> Map k a -> Map k a -> Map k a
-glue k Tip r = r
-glue k l Tip = l
-glue k l r
-  | size l > size r = let (km1, vm, lm) = deleteFindMax l in balance km1 vm lm r
-  | otherwise       = let (km2, vm, rm) = deleteFindMin r in balance km2 vm l rm
-
-deleteFindMax t
-  = case t of
-      Bin _ k x l Tip -> (k, x, l)
-      Bin _ k x l r -> let (km3, vm, rm) = deleteFindMax r in (km3, vm, (balance k x l rm))
-      Tip           -> (error ms, error ms, Tip)
-  where ms = "Map.deleteFindMax : can not return the maximal element of an empty Map"
-
-
-deleteFindMin t
-  = case t of
-      Bin _ k x Tip r -> (k, x, r)
-      Bin _ k x l r -> let (km4, vm, lm) = deleteFindMin l in (km4, vm, (balance k x lm r))
-      Tip             -> (error ms, error ms, Tip)
-  where ms = "Map.deleteFindMin : can not return the maximal element of an empty Map"
-
-
--------------------------------------------------------------------------------
---------------------------------- BALANCE -------------------------------------
--------------------------------------------------------------------------------
-
-delta, ratio :: Int
-delta = 5
-ratio = 2
-
-balance :: k -> a -> Map k a -> Map k a -> Map k a
-balance k x l r
-  | sizeL + sizeR <= 1   = Bin sizeX k x l r
-  | sizeR >= delta*sizeL = rotateL k x l r
-  | sizeL >= delta*sizeR = rotateR k x l r
-  | otherwise            = Bin sizeX k x l r
-  where sizeL = size l
-        sizeR = size r
-        sizeX = sizeL + sizeR + 1
-
--- rotate
-rotateL :: a -> b -> Map a b -> Map a b -> Map a b
-rotateL k x l r@(Bin _ _ _ ly ry)
-  | size ly < ratio*size ry  = singleL k x l r
-  | otherwise                = doubleL k x l r
-rotateL _ _ _ Tip = error "rotateL Tip"
-
-rotateR :: a -> b -> Map a b -> Map a b -> Map a b
-rotateR k x l@(Bin _ _ _ ly ry) r
-  | size ry < ratio*size ly  = singleR k x l r
-  | otherwise                = doubleR k x l r
-rotateR _ _ Tip _ = error "rotateR Tip"
-
--- basic rotations
-singleL, singleR :: a -> b -> Map a b -> Map a b -> Map a b
-singleL k1 x1 t1 (Bin _ k2 x2 t2 t3) = bin k2 x2 (bin k1 x1 t1 t2) t3
-singleL _  _  _ Tip                  = error "sinlgeL Tip"
-singleR k1 x1 (Bin _ k2 x2 t1 t2) t3 = Bin 0 k2 x2 t1 (Bin 0 k1 x1 t2 t3)
-singleR _  _  Tip _                  = error "sinlgeR Tip"
-
-doubleL, doubleR :: a -> b -> Map a b -> Map a b -> Map a b
-doubleL k1 x1 t1 (Bin _ k2 x2 (Bin _ k3 x3 t2 t3) t4)
- =bin k3 x3 (bin k1 x1 t1 t2) (bin k2 x2 t3 t4)
-doubleL _ _ _ _ = error "doubleL"
-doubleR k1 x1 (Bin _ k2 x2 t1 (Bin _ k3 x3 t2 t3)) t4
-  = bin k3 x3 (bin k2 x2 t1 t2) (bin k1 x1 t3 t4)
-doubleR _ _ _ _ = error "doubleR"
-
-bin :: k -> a -> Map k a -> Map k a -> Map k a
-bin k x l r
-  = Bin (size l + size r + 1) k x l r
-
-size :: Map k a -> Int
-size t
-  = case t of
-      Tip            -> 0
-      Bin sz _ _ _ _ -> sz
-
-
--- chkDel x Tip                = liquidAssertB True
--- chkDel x (Bin sz k v lt rt) = liquidAssertB (not (x == k)) && chkDel x lt && chkDel x rt
---
--- chkMin x Tip                = liquidAssertB True
--- chkMin x (Bin sz k v lt rt) = liquidAssertB (x<k) && chkMin x lt && chkMin x rt
-
-chk Tip               = liquidAssertB True
-chk (Bin s k v lt rt) = chk lt && chk rt && chkl k lt && chkr k rt
-
-chkl k Tip              = liquidAssertB True
-chkl k (Bin _ kl _ _ _) = liquidAssertB (kl < k)
-
-chkr k Tip              = liquidAssertB True
-chkr k (Bin _ kr _ _ _) = liquidAssertB (k < kr)
-
-key, key1, val, val1 :: Int
-key = choose 0
-val = choose 1
-key1 = choose 0
-val1 = choose 1
-
-bst1 = insert key val Tip
-bst  = insert key val $ insert key1 val1 Tip
-
-mkBst = foldl (\t (k, v) -> insert k v t) Tip
-
-prop        = chk bst1
-prop1       = chk $ mkBst $ zip [1..] [1..]
-
-propDelete  = chk $ delete x bst
-   where x = choose 0
diff --git a/tests/pos/Map2.hs b/tests/pos/Map2.hs
deleted file mode 100644
--- a/tests/pos/Map2.hs
+++ /dev/null
@@ -1,182 +0,0 @@
-module Map (singleton, insert, delete, mllen) where
-
-import Language.Haskell.Liquid.Prelude
-
-import Prelude hiding (error)
-
-{-@ lazy error @-}
-{-@ error :: a -> b @-}
-error :: a -> b
-error x = error x
-
-{-@
-  data Map [mllen] k a <l :: root:k -> k -> Bool, r :: root:k -> k -> Bool>
-      = Tip
-      | Bin { mSz    :: Size
-            , mKey   :: k
-            , mValue :: a
-            , mLeft  :: Map <l, r> (k <l mKey>) a
-            , mRight :: Map <l, r> (k <r mKey>) a }
-  @-}
-
-{-@ measure mllen @-}
-mllen :: Map k a -> Int 
-{-@ mllen :: Map k a -> Nat @-}
-mllen Tip = 0 
-mllen (Bin _ _ _ l r) = 1 + if (mllen l < mllen r) then mllen r else mllen l
-
-
-{-@ measure mlen :: (Map k a) -> Int
-    mlen(Tip) = 0
-    mlen(Bin s k v l r) = 1 + (if ((mlen l) < (mlen r)) then (mlen r) else (mlen l))
-  @-}
-
-{-@ invariant { v:Map k a | mlen v >= 0 } @-}
-
-{-@ type OMap k a = Map <{\root v -> v < root }, {\root v -> v > root}> k a @-}
-
-data Map k a = Tip
-             | Bin Size k a (Map k a) (Map k a)
-
-type Size    = Int
-
-{-@ singleton :: k -> a -> OMap k a @-}
-singleton :: k -> a -> Map k a
-singleton k x
-  = Bin 1 k x Tip Tip
-
-{-@ insert :: Ord k => k -> a -> OMap k a -> OMap k a @-}
-insert :: Ord k => k -> a -> Map k a -> Map k a
-insert kx x t
-  = case t of
-     Tip -> singleton kx x
-     Bin sz ky y l r
-         -> case compare kx ky of
-              LT -> balance ky y (insert kx x l) r
-              GT -> balance ky y l (insert kx x r)
-              EQ -> Bin sz kx x l r
-
-{-@ delete :: (Ord k) => k:k -> OMap k a -> OMap {v:k| (v /= k)} a @-}
-delete :: Ord k => k -> Map k a -> Map k a
-delete k t
-  = case t of
-      Tip -> Tip
-      Bin _ kx x l r
-          -> case compare k kx of
-               LT -> balance kx x (delete k l) r
-               GT -> balance kx x l (delete k r)
-               EQ -> glue kx l r
-
-
-glue :: k -> Map k a -> Map k a -> Map k a
-glue k Tip r = r
-glue k l Tip = l
-glue k l r
-  | size l > size r = let (km1, vm, lm) = deleteFindMax l in balance km1 vm lm r
-  | otherwise       = let (km2, vm, rm) = deleteFindMin r in balance km2 vm l rm
-
-deleteFindMax t
-  = case t of
-      Bin _ k x l Tip -> (k, x, l)
-      Bin _ k x l r -> let (km3, vm, rm) = deleteFindMax r in (km3, vm, balance k x l rm)
-      Tip           -> (error ms, error ms, Tip)
-  where ms = "Map.deleteFindMax : can not return the maximal element of an empty Map"
-
-deleteFindMin t
-  = case t of
-      Bin _ k x Tip r -> (k, x, r)
-      Bin _ k x l r -> let (km4, vm, lm) = deleteFindMin l in (km4, vm, balance k x lm r)
-      Tip             -> (error ms, error ms, Tip)
-  where ms = "Map.deleteFindMin : can not return the maximal element of an empty Map"
-
-
--------------------------------------------------------------------------------
---------------------------------- BALANCE -------------------------------------
--------------------------------------------------------------------------------
-
-delta, ratio :: Int
-delta = 5
-ratio = 2
-
-balance :: k -> a -> Map k a -> Map k a -> Map k a
-balance k x l r
-  | sizeL + sizeR <= 1   = Bin sizeX k x l r
-  | sizeR >= delta*sizeL = rotateL k x l r
-  | sizeL >= delta*sizeR = rotateR k x l r
-  | otherwise            = Bin sizeX k x l r
-  where sizeL = size l
-        sizeR = size r
-        sizeX = sizeL + sizeR + 1
-
--- rotate
-rotateL :: a -> b -> Map a b -> Map a b -> Map a b
-rotateL k x l r@(Bin _ _ _ ly ry)
-  | size ly < ratio*size ry  = singleL k x l r
-  | otherwise                = doubleL k x l r
-rotateL _ _ _ Tip = error "rotateL Tip"
-
-rotateR :: a -> b -> Map a b -> Map a b -> Map a b
-rotateR k x l@(Bin _ _ _ ly ry) r
-  | size ry < ratio*size ly  = singleR k x l r
-  | otherwise                = doubleR k x l r
-rotateR _ _ Tip _ = error "rotateR Tip"
-
--- basic rotations
-singleL, singleR :: a -> b -> Map a b -> Map a b -> Map a b
-singleL k1 x1 t1 (Bin _ k2 x2 t2 t3) = bin k2 x2 (bin k1 x1 t1 t2) t3
-singleL _  _  _ Tip                  = error "sinlgeL Tip"
-singleR k1 x1 (Bin _ k2 x2 t1 t2) t3 = Bin 0 k2 x2 t1 (Bin 0 k1 x1 t2 t3)
-singleR _  _  Tip _                  = error "sinlgeR Tip"
-
-doubleL, doubleR :: a -> b -> Map a b -> Map a b -> Map a b
-doubleL k1 x1 t1 (Bin _ k2 x2 (Bin _ k3 x3 t2 t3) t4)
- =bin k3 x3 (bin k1 x1 t1 t2) (bin k2 x2 t3 t4)
-doubleL _ _ _ _ = error "doubleL"
-doubleR k1 x1 (Bin _ k2 x2 t1 (Bin _ k3 x3 t2 t3)) t4
-  = bin k3 x3 (bin k2 x2 t1 t2) (bin k1 x1 t3 t4)
-doubleR _ _ _ _ = error "doubleR"
-
-bin :: k -> a -> Map k a -> Map k a -> Map k a
-bin k x l r
-  = Bin (size l + size r + 1) k x l r
-
-size :: Map k a -> Int
-size t
-  = case t of
-      Tip            -> 0
-      Bin sz _ _ _ _ -> sz
-
-
--- chkDel x Tip                = liquidAssertB True
--- chkDel x (Bin sz k v lt rt) = liquidAssertB (not (x == k)) && chkDel x lt && chkDel x rt
-
--- chkMin x Tip                = liquidAssertB True
--- chkMin x (Bin sz k v lt rt) = liquidAssertB (x<k) && chkMin x lt && chkMin x rt
-
-chk Tip               = liquidAssertB True
-chk (Bin s k v lt rt) = chk lt && chk rt && chkl k lt && chkr k rt
-
-chkl k Tip              = liquidAssertB True
-chkl k (Bin _ kl _ _ _) = liquidAssertB (kl < k)
-
-chkr k Tip              = liquidAssertB True
-chkr k (Bin _ kr _ _ _) = liquidAssertB (k < kr)
-
-key, key1, val, val1 :: Int
-key = choose 0
-val = choose 1
-key1 = choose 0
-val1 = choose 1
-
-bst1010 = insert key val Tip
-bst  = insert key val $ insert key1 val1 Tip
-
-mkBst = foldl (\t (k, v) -> insert k v t) Tip
-
-prop        = chk bst1010
-prop1       = chk $ mkBst $ zip [1..] [1..]
-
-propDelete  = chk bst' -- && chkDel x bst'
-   where
-     x      = choose 0
-     bst'   = delete x bst
diff --git a/tests/pos/MapFusion.hs b/tests/pos/MapFusion.hs
deleted file mode 100644
--- a/tests/pos/MapFusion.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--ple"            @-}
-
-module MapFusion where
-
-import Prelude hiding (map)
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ reflect compose @-}
-compose :: (b -> c) -> (a -> b) -> a -> c
-compose f3 g3 x3 = f3 (g3 x3)
-
-{-@ reflect map @-}
-map :: (a -> b) -> L a -> L b
-map f4 N = N
-map f5 (C z zs) = C (f5 z) (map f5 zs)
-
-
-{-@ map_fusion :: foo:(a -> a) -> goo:(a -> a) -> xoos:{L a | true }
-               -> {map (compose foo goo) xoos == compose (map foo) (map goo) xoos } @-}
-map_fusion :: (a -> a) -> (a -> a) -> L a -> Proof
-map_fusion f1 g1 N        = trivial
-map_fusion f2 g2 (C x xs) = map_fusion f2 g2 xs
-
-
-data L a = N | C a (L a)
-{-@ data L [llen] a = N | C {headlist :: a, taillist :: L a }@-}
-
-{-@ measure llen @-}
-llen :: L a -> Int
-{-@ llen :: L a -> Nat @-}
-llen N        = 0
-llen (C _ as) = 1 + llen as
diff --git a/tests/pos/MapReduceVerified.hs b/tests/pos/MapReduceVerified.hs
deleted file mode 100644
--- a/tests/pos/MapReduceVerified.hs
+++ /dev/null
@@ -1,244 +0,0 @@
--- | Proof of equivalence of MapReduce 
--- | mapReduce n op f is == f is 
-
--- | Niki Vazou Sep 2016 
-
-{-@ LIQUID "--reflection" @-}
-
-
-module MapReduce where 
-
-import Prelude hiding (mconcat, map, split, take, drop, sum)
-import Language.Haskell.Liquid.ProofCombinators 
-
--------------------------------------------------------------------------------
-------------  Map Reduce Definition  ------------------------------------------
--------------------------------------------------------------------------------
-
-
-{-@ reflect mapReduce @-}
-mapReduce :: Int -> (List a -> b) -> (b -> b -> b) -> List a -> b 
-mapReduce n f op is = reduce op (f N) (map f (chunk n is))
-
-{-@ reflect reduce @-}
-reduce :: (a -> a -> a) -> a -> List a -> a 
-reduce op b N        = b 
-reduce op b (C x xs) = op x (reduce op b xs) 
-
-chunk :: Int -> List a -> List (List a)
-
-
--------------------------------------------------------------------------------
-------------  Application: List sum  ------------------------------------------
--------------------------------------------------------------------------------
-
-sum  :: List Int -> Int 
-plus :: Int -> Int -> Int 
-
-{-@ reflect msum @-}
-msum :: Int -> List Int -> Int 
-msum n is = mapReduce n sum plus is 
-
-
-mapReduceSum :: Int -> List Int -> Proof 
-{-@ mapReduceSum :: n:Int -> is:List Int -> { sum is == mapReduce n sum plus is} @-}
-mapReduceSum n is 
-  =   msum n is 
-  === mapReduce n sum plus is 
-    ? mapReduceTheorem n sum plus sumLeftId sumDistributes is 
-  === sum is  
-  *** QED 
-
--------------------------------------------------------------------------------
-------------  Main MapReduce Theorem ------------------------------------------
--------------------------------------------------------------------------------
-
-
-mapReduceTheorem :: Int -> (List a -> b) -> (b -> b -> b) -> (List a -> Proof) -> (List a -> List a -> Proof) -> List a -> Proof 
-{-@ mapReduceTheorem :: n:Int -> f:(List a -> b) -> op:(b -> b -> b)
-     -> left_id:(xs:List a -> {op (f xs) (f N) == f xs } ) 
-     -> distributionTheorem:(xs:List a -> ys:List a -> {f (append xs ys) == op (f xs) (f ys)} )
-     -> is:List a ->
-     { mapReduce n f op is == f is }
-     / [llen is]
-  @-}
-mapReduceTheorem n f op left_id _ N 
-  =   mapReduce n f op N 
-  === reduce op (f N) (map f (chunk n N))
-  === reduce op (f N) (map f (C N N))
-  === reduce op (f N) (f N `C` map f N )
-  === reduce op (f N) (f N `C` N)
-  === op (f N) (reduce op (f N) N)
-      ? left_id N
-  === op (f N) (f N)
-  === f N 
-  *** QED 
-
-mapReduceTheorem n f op left_id _ is@(C x xs)
-  | n <= 1 || llen is <= n 
-  =   mapReduce n f op is 
-  === reduce op (f N) (map f (chunk n is))
-  === reduce op (f N) (map f (C is N))
-  === reduce op (f N) (f is `C` map f N)
-  === reduce op (f N) (f is `C` N)
-  === op (f is) (reduce op (f N) N)
-  === op (f is) (f N)
-	? left_id is
-  === f is  
-  *** QED 
-
-mapReduceTheorem n f op left_id distributionTheorem is 
-  =   mapReduce n f op is 
-  === reduce op (f N) (map f (chunk n is)) 
-  === reduce op (f N) (map f (C (take n is) (chunk n (drop n is)))) 
-  === reduce op (f N) (C (f (take n is)) (map f (chunk n (drop n is)))) 
-  === op (f (take n is)) (reduce op (f N) (map f (chunk n (drop n is))))  
-      ? mapReduceTheorem n f op left_id distributionTheorem (drop n is)
-  === op (f (take n is)) (mapReduce n f op (drop n is)) 
-  === op (f (take n is)) (f (drop n is)) 
-      ? distributionTheorem (take n is) (drop n is)
-  === f (append (take n is) (drop n is))
-      ? appendTakeDrop n is 
-  === f is 
-  *** QED  
-
-
-
-
--------------------------------------------------------------------------------
------------  List Definition --------------------------------------------------
--------------------------------------------------------------------------------
-
-
-{-@ data List [llen] a = N | C {lhead :: a, ltail :: List a} @-}
-data List a = N | C a (List a)
-
-{-@ measure llen @-}
-llen :: List a -> Int 
-
-{-@ llen :: List a -> Nat @-}
-llen N        = 0 
-llen (C _ xs) = 1 + llen xs
-
--------------------------------------------------------------------------------
------------  List Manipulation ------------------------------------------------
--------------------------------------------------------------------------------
-
--- Distribution 
-
-{-@ reflect map @-}
-{-@ map :: (a -> b) -> xs:List a -> {v:List b | llen v == llen xs } @-}
-map :: (a -> b) -> List a -> List b
-map _  N       = N
-map f (C x xs) = f x `C` map f xs 
-
-{-@ reflect chunk @-}
-{-@ chunk :: i:Int -> xs:List a -> {v:List (List a) | if (i <= 1 || llen xs <= i) then (llen v == 1) else (llen v < llen xs) } / [llen xs] @-}
-chunk i xs 
-  | i <= 1 
-  = C xs N 
-  | llen xs <= i 
-  = C xs N 
-  | otherwise
-  = C (take i xs) (chunk i (drop i xs))
-
-{-@ reflect drop @-}
-{-@ drop :: i:Nat -> xs:{List a | i <= llen xs } -> {v:List a | llen v == llen xs - i } @-} 
-drop :: Int -> List a -> List a 
-drop i N = N 
-drop i (C x xs)
-  | i == 0 
-  = C x xs  
-  | otherwise 
-  = drop (i-1) xs 
-
-{-@ reflect take @-}
-{-@ take :: i:Nat -> xs:{List a | i <= llen xs } -> {v:List a | llen v == i} @-} 
-take :: Int -> List a -> List a 
-take i N = N 
-take i (C x xs)
-  | i == 0 
-  = N  
-  | otherwise 
-  = C x (take (i-1) xs)
-
-
-{-@ reflect append @-}
-append :: List a -> List a -> List a 
-append N        ys = ys  
-append (C x xs) ys = x `C` (append xs ys)
-
-
--------------------------------------------------------------------------------
------------  Helper Theorems --------------------------------------------------
--------------------------------------------------------------------------------
-
-
--- | For input Distribution 
-{-@ appendTakeDrop :: i:Nat -> xs:{List a | i <= llen xs} 
-      -> {xs == append (take i xs) (drop i xs) }  @-}
-
-appendTakeDrop :: Int -> List a -> Proof 
-appendTakeDrop i N 
-  =   append (take i N) (drop i N)
-  === append N N 
-  === N 
-  *** QED 
-appendTakeDrop i (C x xs)
-  | i == 0 
-  =   append (take 0 (C x xs)) (drop 0 (C x xs))
-  === append N (C x xs)
-  === C x xs 
-  *** QED 
-  | otherwise
-  =   append (take i (C x xs)) (drop i (C x xs))
-  === append (C x (take (i-1) xs)) (drop (i-1) xs)
-  === C x (append (take (i-1) xs) (drop (i-1) xs))
-      ? appendTakeDrop (i-1) xs 
-  === C x xs 
-  *** QED 
-
-
-
--------------------------------------------------------------------------------
-------------  Application: List sum  ------------------------------------------
--------------------------------------------------------------------------------
-
-
-sumLeftId :: List Int -> Proof 
-{-@ sumLeftId :: xs:List Int -> {plus (sum xs) (sum N) == sum xs } @-}
-sumLeftId xs 
-  =  plus (sum xs) (sum N) 
-  === sum xs + 0 
-  === sum xs 
-  *** QED 
-
-{-@ sumDistributes :: xs:List Int -> ys:List Int -> 
-      {sum (append xs ys) == plus (sum xs) (sum ys)} @-}
-sumDistributes :: List Int -> List Int -> Proof 
-sumDistributes N ys 
-  =   sum (append N ys)
-  === sum ys
-  === plus 0       (sum ys)
-  === plus (sum N) (sum ys)
-  *** QED 
-sumDistributes (C x xs) ys  
-  =   sum (append (C x xs) ys)
-  === sum (C x (append xs ys))
-      ? sumDistributes xs ys
-  === x `plus` (sum (append xs ys))
-  === x `plus` (plus (sum xs) (sum ys))
-  === x + (sum xs + sum ys)
-  === ((x + sum xs) + sum ys)
-  === ((x `plus` sum xs) `plus` sum ys)
-  === sum (C x xs) `plus` sum ys
-  *** QED 
-
-
-{-@ reflect plus @-}
-plus x y = x + y 
-
-{-@ reflect sum @-}
-sum N        = 0 
-sum (C x xs) = x `plus` sum xs
-
diff --git a/tests/pos/MaskError.hs b/tests/pos/MaskError.hs
deleted file mode 100644
--- a/tests/pos/MaskError.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module MaskError where 
-
-{-@ assume error :: String -> a @-}
-
-foo :: Int -> Int 
-foo _ = error "oh no"
diff --git a/tests/pos/MeasureContains.hs b/tests/pos/MeasureContains.hs
deleted file mode 100644
--- a/tests/pos/MeasureContains.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module Fixme where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ LIQUID "--no-termination" @-}
-
-{-@ measure binderContainsV @-}
-binderContainsV ::  Binder n -> Bool
-binderContainsV B     = True
-binderContainsV (M x) = containsV x
-
-data Binder n = B | M (TT n)
-data TT n     = V Int | Other | Bind (Binder n) (TT n)
-
-{-@ measure containsV @-}
-containsV :: TT n -> Bool
-containsV (V i)           = True
-containsV (Bind b body) = (binderContainsV b) || (containsV body)
--- containsV (App f arg)     = (containsV f) || (containsV arg)
--- containsV (Proj tm i)     = containsV tm
-containsV _               = False
-
-
-prop1 = liquidAssert (containsV $ V 7)
-prop2 = liquidAssert (containsV $ Bind (M (V 5)) Other)
diff --git a/tests/pos/MeasureDups.hs b/tests/pos/MeasureDups.hs
deleted file mode 100644
--- a/tests/pos/MeasureDups.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-module Measures where
-
-import Data.Set 
-
-{-@ LIQUID "--no-termination" @-}
-{-@ measure elements @-}
-{-@ measure dups @-}
-
-data F a = F a |  C a (F a) | E 
-
-dups :: Ord a => F a -> Set a
-dups E        = empty
-dups (F a)    = empty
-dups (C x xs) = if member x (elements xs) then singleton x `union` dups xs else dups xs
-
-elements :: Ord a => F a -> Set a
-elements E        = empty
-elements (F a)    = singleton a
-elements (C x xs) = singleton x `union` elements xs
-
-
-
-{-@ foo :: (Ord a) => x:F a -> {v:Set a | (dups x) = v} @-}
-foo :: Ord a => F a -> Set a
-foo E        = empty
-foo (F a)    = empty
-foo (C x xs) = if member x (elements xs) then singleton x `union` foo xs else foo xs
diff --git a/tests/pos/MeasureSets.hs b/tests/pos/MeasureSets.hs
deleted file mode 100644
--- a/tests/pos/MeasureSets.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-
-module Measures where
-
-import Data.Set 
-
-{-@ measure foo @-}
-{-@ measure foo1 @-}
-
-data F a = F a | E
-
-foo1 :: F a -> Set a
-foo1 (F x) = singleton x
-foo1 E     = empty
-
-foo :: F Int -> Int
-foo (F x) = x + 1
-foo E     = 0
-
--- bar = F
diff --git a/tests/pos/Measures.hs b/tests/pos/Measures.hs
deleted file mode 100644
--- a/tests/pos/Measures.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Measures where
-
-{-@ data Wrapper a <p :: a -> Bool, r :: a -> a -> Bool > 
-      = Wrap (rgref_ref :: a<p>) @-}
-data Wrapper a = Wrap (a)
-
--- Two measures
-{-@ measure fwdextends :: Int -> Int -> Bool @-}
-{-@ measure actionP :: Int -> Bool @-}
-
-{-@ data Wrapper2  = Wrapper2 (unwrapper :: (Wrapper<{\x -> (true)},{\x y -> (fwdextends y x)}> Int )) @-}
-{- data Wrapper2  = Wrapper2 (unwrapper :: (Wrapper<{\x -> (actionP x)},{\x y -> (true)}> Int )) @-}
-data Wrapper2  = Wrapper2 (Wrapper (Int) )
-
-
diff --git a/tests/pos/Measures1.hs b/tests/pos/Measures1.hs
deleted file mode 100644
--- a/tests/pos/Measures1.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Measures where
-
-{-@ data Wrapper a <p :: a -> Bool, r :: a -> a -> Bool > 
-      = Wrap (rgref_ref :: a<p>) @-}
-data Wrapper a = Wrap (a)
-
--- Two measures
-{-@ measure fwdextends :: Int -> Int -> Bool @-}
-{-@ measure actionP :: Int -> Bool @-}
-
-{- data Wrapper2  = Wrapper2 (unwrapper :: (Wrapper<{\x -> (true)},{\x y -> (fwdextends y x)}> Int )) @-}
-{-@ data Wrapper2  = Wrapper2 (unwrapper :: (Wrapper<{\x -> (actionP x)},{\x y -> (true)}> Int )) @-}
-data Wrapper2  = Wrapper2 (Wrapper (Int) )
-
-
diff --git a/tests/pos/Merge1.hs b/tests/pos/Merge1.hs
deleted file mode 100644
--- a/tests/pos/Merge1.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Merge1 where
-
-{-@ merge1 :: Ord a
-           => xs:[a]
-           -> ys:[a]
-           -> {v:[a] | len v == len xs + len ys}
-           / [len xs + len ys]
-  @-}
-merge1 :: Ord a => [a] -> [a] -> [a]
-merge1 (a:as') (b:bs')
-  | a `compare` b == GT = b:merge1 (a:as')  bs'
-  | otherwise           = a:merge1 as' (b:bs')
-merge1 [] bs            = bs
-merge1 as []            = as
diff --git a/tests/pos/MergeSort-bag.hs b/tests/pos/MergeSort-bag.hs
deleted file mode 100644
--- a/tests/pos/MergeSort-bag.hs
+++ /dev/null
@@ -1,58 +0,0 @@
-------------------------------------------------------------------------------
--- | An implementation of Merge Sort, where LH verifies
---   * termination, and that
---   * the output is an ordered permutation of the input.
-------------------------------------------------------------------------------
-
-module MergeSort (bag, sort) where
-
-import qualified Language.Haskell.Liquid.Bag as B
-
-{-@ measure bag @-}
-bag :: (Ord a) => [a] -> B.Bag a
-bag []     = B.empty
-bag (x:xs) = B.put x (bag xs)
-
-{-@ type OList a    = [a]<{\fld v -> (v >= fld)}>       @-}
-{-@ type OListN a N = {v:OList a | len v == N}          @-}
-{-@ type OListBag a B = {v:OList a | bag v == B} @-}
-
---------------------------------------------------------------------------------
--- | The top level `sort` function. Proved:
---    *  ordered, and
---    *  same multi-set as the input.
---------------------------------------------------------------------------------
-{-@ sort :: (Ord a) => xs:[a] -> OListBag a (bag xs) @-}
-sort :: Ord a => [a] -> [a]
-sort []   = []
-sort [x]  = [x]
-sort xs   = merge (sort xs1) (sort xs2)
-  where
-    (xs1, xs2) = split xs
-
---------------------------------------------------------------------------------
--- | The `split` function breaks its list into two `Halves`:
---------------------------------------------------------------------------------
-{-@ split :: xs:[a] -> Halves a xs @-}
-split :: [a] -> ([a], [a])
-split (x:(y:zs)) = (x:xs, y:ys) where (xs, ys) = split zs
-split xs         = (xs, [])
-
-
--- | A type describing two `Halves` of a list `Xs`
-{-@ type Halves a Xs = {v: (Half a Xs, Half a Xs) | len (fst v) + len (snd v) = len Xs && B.union (bag (fst v)) (bag (snd v)) == bag Xs}
-  @-}
-
--- | Each `Half` is empty or smaller than the input:
-{-@ type Half a Xs  = {v:[a] | (len v > 1) => (len v < len Xs)} @-}
-
---------------------------------------------------------------------------------
--- | Finally, the `merge` function combines two ordered lists.
---------------------------------------------------------------------------------
-{-@ merge :: Ord a => xs:OList a -> ys:OList a -> OListBag a (B.union (bag xs) (bag ys)) / [(len xs + len ys)] @-}
-merge :: Ord a => [a] -> [a] ->  [a]
-merge xs []         = xs
-merge [] ys         = ys
-merge (x:xs) (y:ys)
-  | x <= y          = x : merge xs (y:ys)
-  | otherwise       = y : merge (x:xs) ys
diff --git a/tests/pos/MergeSort.hs b/tests/pos/MergeSort.hs
deleted file mode 100644
--- a/tests/pos/MergeSort.hs
+++ /dev/null
@@ -1,52 +0,0 @@
-------------------------------------------------------------------------------
--- | An implementation of Merge Sort, where LH verifies:
---   1. Termination (Totality) 
---   2. The output is indeed in non-decreasing order 
-------------------------------------------------------------------------------
-
-module MergeSort (sort) where
-
-{-@ type OList a    = [a]<{\fld v -> (v >= fld)}> @-}
-
-{-@ type OListN a N = {v:OList a | len v == N} @-}
-
--- | The top level `sort` function. Proved:
---   (a) terminating, 
---   (b) ordered, and 
---   (c) of same size as input.
-
-{-@ sort :: (Ord a) => xs:[a] -> OListN a {len xs} @-}
-sort :: Ord a => [a] -> [a]
-sort []   = []
-sort [x]  = [x]
-sort xs   = merge (sort xs1) (sort xs2) 
-  where 
-    (xs1, xs2) = split xs
-
--- Fun fact: if you delete the singleton case above,
--- the resulting function is, in fact, non-terminating!
-
--- | A type describing two `Halves` of a list `Xs` 
-
-{-@ type Halves a Xs = {v: (Half a Xs, Half a Xs) | len (fst v) + len (snd v) == len Xs} @-}
-
--- | Each `Half` is empty or smaller than the input:
-
-{-@ type Half a Xs  = {v:[a] | (len v > 1) => (len v < len Xs)} @-}
-
--- | The `split` function breaks its list into two `Halves`:
-
-{-@ split :: xs:[a] -> Halves a xs @-}
-split :: [a] -> ([a], [a])
-split (x:(y:zs)) = (x:xs, y:ys) where (xs, ys) = split zs
-split xs         = (xs, [])
-
--- | Finally, the `merge` function combines two ordered lists into a single ordered result.
-
-{-@ merge :: Ord a => xs:OList a -> ys:OList a -> OListN a {len xs + len ys} / [(len xs + len ys)] @-}
-merge :: Ord a => [a] -> [a] ->  [a]
-merge xs []         = xs
-merge [] ys         = ys
-merge (x:xs) (y:ys)
-  | x <= y          = x : merge xs (y:ys)
-  | otherwise       = y : merge (x:xs) ys
diff --git a/tests/pos/Mod.hs b/tests/pos/Mod.hs
deleted file mode 100644
--- a/tests/pos/Mod.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Mod where
-
-import qualified ModLib as M
-
-{-@ inc :: x:M.Goo -> {v: M.Goo | myg v > myg x} @-}
-inc (M.G x) = M.G (x + 1)
-
diff --git a/tests/pos/ModLib.hs b/tests/pos/ModLib.hs
deleted file mode 100644
--- a/tests/pos/ModLib.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module ModLib where
-
-data Goo = G Int
-
-{-@ measure myg :: ModLib.Goo -> Int 
-    myg (ModLib.G n) = n
-  @-}
- 
-{-@ inc :: x:Goo -> {v: Goo | (myg v) > (myg x)} @-}
-inc (G x) = G (x + 1)
-
-
diff --git a/tests/pos/MutualRec.hs b/tests/pos/MutualRec.hs
deleted file mode 100644
--- a/tests/pos/MutualRec.hs
+++ /dev/null
@@ -1,42 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-
--- TODO: Fix resolve so we can remove this/add termination metrics
-{-@ LIQUID "--no-termination" @-}
-
-module MutualRec where
-
-import Language.Haskell.Liquid.Prelude
-
-
-bin :: k -> v -> [(k, v)] -> [(k, v)] -> [(k, v)] 
-{-@ bin :: k -> v -> [(k, v)] -> [(k, v)] -> [(k, v)] @-}
-singleton :: k -> v -> [(k, v)]
-{-@ singleton :: k -> v -> [(k, v)] @-}
-bin = undefined
-singleton = undefined
-
-fromDistinctAscList xs
-  = create const (length xs) xs
-  where
-    -- {- decrease create  2 3 @-}
-    -- {- decrease createR 1 4 @-}
-    create c (0::Int) xs' = c undefined xs'
--- LIQUID for n = 1 n `div` 2 = 0 and the assume does not hold
-    create c 1 xs' = case xs' of
-                       (k1,x1):xx -> c (singleton k1 x1) xx
-                       _ -> unsafeError "fromDistinctAscList create"
-    create c 5 xs' = case xs' of
-                       ((k1,x1):(k2,x2):(k3,x3):(k4,x4):(k5,x5):xx)
-                            -> c (bin k4 x4 (bin k2 x2 (singleton k1 x1) (singleton k3 x3)) (singleton k5 x5)) xx
-                       _ -> unsafeError "fromDistinctAscList create"
-    create c n xs' = seq nr $ create (createR nr c) nl xs'
-      where nl = liquidAssume (m < n && m >= 0) m
-            m  = n `div` 2
-            nr = n - nl - 1
-
-    -- MUTUAL createR (n::Int) c l ((k,x):ys) = create (createB l k x c) n ys
-    createR (n::Int) c l ((k,x):ys) = create (\r -> c (bin k x l r)) n ys
-    createR _ _ _ []                = unsafeError "fromDistinctAscList createR []"
-    -- MUTUAL createB l k x c r zs     = c (bin k x l r) zs
-
-
diff --git a/tests/pos/MutuallyDependentADT.hs b/tests/pos/MutuallyDependentADT.hs
deleted file mode 100644
--- a/tests/pos/MutuallyDependentADT.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-{-@ LIQUID "--exactdc"  @-}
-
-data Pred l 
-  = PTerm (Term l)
-
-data Term l 
-  = TPred (Pred l)
-  | TTerm l
-
-{-@ measure tsize @-}
-tsize :: Term l -> Int
-{-@ tsize :: Term l -> Nat @-}
-tsize (TPred _)            = 0
-tsize (TTerm _)            = 0
-
-main :: IO ()
-main = pure ()
diff --git a/tests/pos/NoCaseExpand.hs b/tests/pos/NoCaseExpand.hs
deleted file mode 100644
--- a/tests/pos/NoCaseExpand.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module NoCaseExpand where
-
--- time 3.6s w/ "--no-case-expand" flag VS  8.5 s w/o
-
-{- LIQUID "--max-case-expand=0" @-}
-
-data TokenType =
-  Space | Keyword | Keyglyph | Layout | Comment | Conid | Varid |
-  Conop | Varop   | String   | CChar   | Number  | Cpp   | Error |
-  Definition
-
-
-context ::  [(TokenType, String)] -> [(TokenType, String)]
-context stream@((Keyglyph,"="):_) = stream
-context stream@((Keyglyph,"=>"):_) = stream
-context stream@((Keyglyph,"⇒"):_) = stream
-context (_:stream) = context stream
-context [] = []
diff --git a/tests/pos/NoExhaustiveGuardsError.hs b/tests/pos/NoExhaustiveGuardsError.hs
deleted file mode 100644
--- a/tests/pos/NoExhaustiveGuardsError.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Foo where
-
-{-@ LIQUID "--no-totality" @-}
-bar :: Int -> Int -> Int
-bar x y | x >  y = 1
-        | x <= y = 0
diff --git a/tests/pos/ORM.hs b/tests/pos/ORM.hs
deleted file mode 100644
--- a/tests/pos/ORM.hs
+++ /dev/null
@@ -1,94 +0,0 @@
-module ORM where
-
-{-@ LIQUID "--exactdc"  @-}
-{-@ LIQUID "--higherorder" @-}
-
-
-import Prelude hiding (length, filter)
-import Language.Haskell.Liquid.ProofCombinators
-
---  here is a "user" query
-{-@ prop :: L Row -> L {v:Row | rowLeft v == 5} @-}
-prop :: L Row -> L Row
-prop xs = mapCast evalQProp $ filter (evalQ (Qry Eq Fst (Const 5))) xs
-
-
-{-@ prop0 :: L Row -> L {v:Row | evalQ (Qry Eq Fst (Const 5)) v} @-}
-prop0 :: L Row -> L Row
-prop0 xs = filter (evalQ (Qry Eq Fst (Const 5))) xs
-
-{-@ mapCast :: (x:Row -> {evalQ (Qry Eq Fst (Const 5)) x <=> rowLeft x == 5})
-            -> L {v:Row | evalQ (Qry Eq Fst (Const 5)) v}
-            -> L {v:Row | rowLeft v == 5} @-}
-mapCast :: (Row -> Proof) -> L Row -> L Row
-mapCast _ N = N
-mapCast p (C x xs) = (x `withProof` (p x)) `C` mapCast p xs
-
-
-
-evalQProp :: Row -> Proof
-{-@ evalQProp :: x:Row -> {evalQ (Qry Eq Fst (Const 5)) x <=> rowLeft x == 5} @-}
-evalQProp (Row l r)
-  =   evalQ (Qry Eq Fst (Const 5)) (Row l r)
-  === evalC Eq (evalV Fst (Row l r)) (evalV (Const 5) (Row l r))
-  === evalC Eq l 5
-  === l == 5
-  *** QED
-
-
-
---  here is the DB API (will add more detail later but its pretty self contained)
-
-data Cmp = Eq | Ne
-{-@ data Cmp = Eq | Ne @-}
-
-data Val = Const {valConst :: Int} | Fst | Snd
-{-@ data Val = Const {valConst :: Int} | Fst | Snd @-}
-
-data Qry = Qry {qryCmp :: Cmp, qryLHS :: Val, qryRHS :: Val }
-
-{-@ data Qry = Qry {qryCmp :: Cmp, qryLHS :: Val, qryRHS :: Val } @-}
-
-data Row = Row {rowLeft :: Int, rowRigth :: Int}
-{-@ data Row = Row {rowLeft :: Int, rowRigth :: Int} @-}
-
-data L a = N | C {hd :: a, tl :: L a}
-{-@ data L [length] a = N | C {hd :: a, tl :: L a} @-}
-
-length :: L a -> Int
-{-@ length :: L a -> Nat @-}
-{-@ measure length @-}
-length N = 0
-length (C _ xs) = 1 + length xs
-
-------------------------------------------------------------------------
-{-@ reflect evalQ @-}
-evalQ :: Qry -> Row -> Bool
-evalQ (Qry o v1 v2) r = evalC o (evalV v1 r) (evalV v2 r)
-
-{-@ reflect evalV @-}
-evalV :: Val -> Row -> Int
-evalV (Const n) _         = n
-evalV Fst       (Row l _) = l
-evalV Snd       (Row _ r) = r
-
-{-@ reflect evalC @-}
-evalC :: Cmp -> Int -> Int -> Bool
-evalC Eq x y = x == y
-evalC Ne x y = x /= y
-
-{-@ reflect filterQ @-}
-filterQ :: Qry -> L Row -> L Row
-filterQ qry xs = filter (evalQ qry) xs
-
-
-{-@ reflect filter @-}
-{-@ filter :: forall <p :: a -> Bool, w :: a -> Bool -> Bool>.
-                  {x::a , b::{v:Bool<w x> | v} |- {v:a | v == x} <: a<p> }
-                  (x:a -> Bool<w x>) -> L a -> L (a<p>)
-  @-}
-filter :: (a -> Bool) -> L a -> L a
-filter _ N = N
-filter p (C x xs)
-  | p x       = x `C` filter p xs
-  | otherwise = filter p xs
diff --git a/tests/pos/OrdList.hs b/tests/pos/OrdList.hs
deleted file mode 100644
--- a/tests/pos/OrdList.hs
+++ /dev/null
@@ -1,155 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-
-module OrdList (
-    OrdList,
-        nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, concatOL',
-        mapOL, fromOL, toOL, foldrOL, foldlOL, llen, ollen
-        -- , olen, olens
-) where
-
-import Language.Haskell.Liquid.Prelude (liquidError)
-
-infixl 5  `appOL`
-infixl 5  `snocOL`
-infixr 5  `consOL`
-
-{-@
-data OrdList [ollen] a = None
-                      | One  (ox  :: a)
-                      | Many (oxs1 :: ListNE a)
-                      | Cons (ox  :: a)           (oxs3 :: OrdList a)
-                      | Snoc (oxs2 :: OrdList a)  (ox  :: a)
-                      | Two  (ox  :: OrdListNE a) (oy  :: OrdListNE a)
-@-}
-
-{-@ measure llen @-}
-{-@ llen :: [a] -> Nat @-}
-llen :: [a] -> Int 
-llen [] = 0
-llen (x:xs) = 1 + llen xs 
-
-{-@ measure ollen @-}
-{-@ ollen :: OrdList a -> Nat @-}
-ollen :: OrdList a -> Int 
-ollen None        = 0 
-ollen (One _)     = 1 
-ollen (Many xs)   = llen xs
-ollen (Cons _ xs) = 1 + ollen xs 
-ollen (Snoc xs _) = 1 + ollen xs 
-ollen (Two x y)   = ollen x + ollen y  
-
-{-@ measure olen :: OrdList a -> Int 
-    olen (None)      = 0
-    olen (One x)     = 1
-    olen (Many xs)   = len xs
-    olen (Cons x xs) = 1 + (olen xs)
-    olen (Snoc xs x) = 1 + (olen xs)
-    olen (Two x y)   = (olen x) + (olen y)
-  @-}
-
-{-@ measure olens :: [OrdList a] -> Int
-    olens ([])     = 0
-    olens (ol:ols) = (olen ol) + (olens ols)
-  @-}
-
-{-@ type ListNE    a   = {v:[a]       | (len v) > 0} @-}
-{-@ type OrdListNE a   = {v:OrdList a | (olen v) > 0} @-}
-{-@ type OrdListN  a N = {v:OrdList a | (olen v) = N} @-}
-
-{-@ invariant {v:OrdList a   | (olen v)  >= 0 && ollen v == olen v} @-}
-{-@ invariant {v:[OrdList a] | (olens v) >= 0} @-}
-
-
-data OrdList a
-  = None
-  | One a
-  | Many [a]          -- Invariant: non-empty
-  | Cons a (OrdList a)
-  | Snoc (OrdList a) a
-  | Two (OrdList a) -- Invariant: non-empty
-        (OrdList a) -- Invariant: non-empty
-
-
-{-@ nilOL    :: OrdListN a {0} @-}
-{-@ isNilOL  :: xs:OrdList a -> {v:Bool | v <=> (olen xs == 0)} @-}
-
-{-@ unitOL   :: a              -> OrdListN a {1} @-}
-{-@ snocOL   :: xs:OrdList a   -> a            -> OrdListN a {1 + olen xs} @-}
-{-@ consOL   :: a              -> xs:OrdList a -> OrdListN a {1 + olen xs} @-}
-{-@ appOL    :: xs:OrdList a   -> ys:OrdList a -> OrdListN a { (olen xs) + (olen ys)} @-}
-{-@ concatOL :: xs:[OrdList a] -> OrdListN a {olens xs} @-}
-
-nilOL        = None
-unitOL as    = One as
-snocOL as   b    = Snoc as b
-consOL a    bs   = Cons a bs
---LIQUID this definition requires `foldr` with abstract refinements, which isn't
---LIQUID in our standard set of specs
--- concatOL aas = foldr appOL None aas
-concatOL []       = None
-concatOL (ol:ols) = ol `appOL` concatOL ols
-
---LIQUID as an alternative, we can easily verify the property that, given
---LIQUID non-empty lists, `concatOL` will return a non-empty list
-{-@ concatOL' :: ListNE (OrdListNE a) -> OrdListNE a @-}
-concatOL' []     = liquidError "can't happen"
-concatOL' (x:xs) = foldr appOL x xs
-
-isNilOL None = True
-isNilOL _    = False
-
-None  `appOL` b     = b
-a     `appOL` None  = a
-One a `appOL` b     = Cons a b
-a     `appOL` One b = Snoc a b
-a     `appOL` b     = Two a b
-
--- TODO-REBARE the below QUAL _should_ work but doesn't, but we can get it 
--- to work with the ty-sig of `go` ... hmm.
-
-
-{-@ qualif_go :: xs:_ -> ys:_ -> {v:_ | len v = olen xs + len ys} @-}
-qualif_go :: OrdList a -> [a] -> [a]
-qualif_go = undefined 
-
-{-@ fromOL :: xs:OrdList a -> {v:[a] | len v = olen xs} @-}
-fromOL a = go a []
-  where
-    {- go :: xs:_ -> acc:_ -> {v:[a] | len v = olen xs + len acc } @-}
-    go None       acc = acc
-    go (One a)    acc = a : acc
-    go (Cons a b) acc = a : go b acc
-    go (Snoc a b) acc = go a (b:acc)
-    go (Two a b)  acc = go a (go b acc)
-    go (Many xs)  acc = xs ++ acc
-
-{-@ mapOL :: (a -> b) -> xs:OrdList a -> OrdListN b {olen xs} @-}
-mapOL _ None = None
-mapOL f (One x) = One (f x)
-mapOL f (Cons x xs) = Cons (f x) (mapOL f xs)
-mapOL f (Snoc xs x) = Snoc (mapOL f xs) (f x)
-mapOL f (Two x y) = Two (mapOL f x) (mapOL f y)
-mapOL f (Many xs) = Many (map f xs)
-
-instance Functor OrdList where
-  fmap = mapOL
-
-foldrOL :: (a -> b -> b) -> b -> OrdList a -> b
-foldrOL _ z None        = z
-foldrOL k z (One x)     = k x z
-foldrOL k z (Cons x xs) = k x (foldrOL k z xs)
-foldrOL k z (Snoc xs x) = foldrOL k (k x z) xs
-foldrOL k z (Two b1 b2) = foldrOL k (foldrOL k z b2) b1
-foldrOL k z (Many xs)   = foldr k z xs
-
-foldlOL :: (b -> a -> b) -> b -> OrdList a -> b
-foldlOL _ z None        = z
-foldlOL k z (One x)     = k z x
-foldlOL k z (Cons x xs) = foldlOL k (k z x) xs
-foldlOL k z (Snoc xs x) = k (foldlOL k z xs) x
-foldlOL k z (Two b1 b2) = foldlOL k (foldlOL k z b1) b2
-foldlOL k z (Many xs)   = foldl k z xs
-
-{-@ toOL :: xs:[a] -> OrdListN a {len xs} @-}
-toOL [] = None
-toOL xs = Many xs
diff --git a/tests/pos/PairMeasure.hs b/tests/pos/PairMeasure.hs
deleted file mode 100644
--- a/tests/pos/PairMeasure.hs
+++ /dev/null
@@ -1,20 +0,0 @@
--- TAG: absref
--- TAG: measure
-
-module Foo () where
-{-@ LIQUID "--bscope" @-}
-
-{-@ measure getfst :: (a, b) -> a
-    getfst (x, y) = x
-  @-}
-
-{-@ type Pair a b   = {v0 : ({v:a | v = (getfst v0)}, b) | true } @-}
-{-@ type OPList a b = [(Pair a b)]<\h -> {v: (a, b) | (getfst v) >= (getfst h)}> @-}
-{-@ type OList a    = [a]<\h -> {v: a | (v >= h)}> @-}
-
-{-@ getFsts          :: OPList a b -> OList a @-}
-getFsts []           = [] 
-getFsts ((x,_) : xs) = x : getFsts xs
-
-
-
diff --git a/tests/pos/PairMeasure0.hs b/tests/pos/PairMeasure0.hs
deleted file mode 100644
--- a/tests/pos/PairMeasure0.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module Foo () where
-
-{-@ LIQUID "--bscope" @-}
-
-{-@ measure getfst :: (a, b) -> a
-    getfst (x, y) = x
-  @-}
-
-{-@ type Pair a b   = {v0 : ({v:a | v = (getfst v0)}, b) | true } @-}
-{-@ type OPList a b = [(Pair a b)]<\h -> {v: (Pair a b) | (getfst v) >= (getfst h)}> @-}
-{-@ type OList a    = [a]<\h -> {v: a | (v >= h)}> @-}
-
-
--- This is Unsafe, as refinements in Predicate parameters (i.e., Pair a b)
--- are lost, so application `getFsts` cannot be proven safe
-{-@ getFsts          :: OPList a b -> OList a @-}
-getFsts :: [(a, b)] -> [a]
-getFsts []           = [] 
-getFsts ((x,_) : xs) = x : getFsts xs
-
-
-
diff --git a/tests/pos/Permutation.hs b/tests/pos/Permutation.hs
deleted file mode 100644
--- a/tests/pos/Permutation.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Permutation () where
-
-{-@ permutations :: ts:[a] -> [[a]] / [(len ts), 1, 0] @-}
-permutations            :: [a] -> [[a]]
-permutations xs0        =  xs0 : perms xs0 []
-
-{-@ perms :: ts:[a] -> is:[a] -> [[a]] / [((len ts)+(len is)), 0, (len ts)] @-}
-perms :: [a] -> [a] -> [[a]]
-perms []     _  = []
-perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is)
-      where interleave    xs     r = let (_,zs) = interleave' id xs r in zs
-            interleave' _ []     r = (ts, r)
-            interleave' f (y:ys) r = let (us,zs) = interleave' (f . (y:)) ys r
-                                     in  (y:us, f (t:y:us) : zs)
-
-
diff --git a/tests/pos/PersistentVector.hs b/tests/pos/PersistentVector.hs
deleted file mode 100644
--- a/tests/pos/PersistentVector.hs
+++ /dev/null
@@ -1,82 +0,0 @@
-{-
-https://twitter.com/BrandonBloom/status/701261641971683328
-https://github.com/clojure/clojure/blob/d5708425995e8c83157ad49007ec2f8f43d8eac8/src/jvm/clojure/lang/PersistentVector.java#L148-L164
--}
-
-{-@ LIQUID "--no-termination" @-}
-
-module PVec (arrayFor, height) where
-
-import Data.Bits
-
--- | Simplified binary tree
-
-data Tree a = Leaf a
-            | Node {tLeft :: (Tree a), tRight :: (Tree a) }
-
--- | Specify "height" of a tree
-
-{-@ measure height @-}
-height :: Tree a -> Int
-height (Leaf _)   = 0
-height (Node l _) = 1 + height l
-
--- | A tree whose height is H
-
-{-@ type TreeH a H = {v:Tree a | height v == H } @-}
-
--- | Specify tree must be "balanced"
-
-{-@ data Tree a = Leaf a
-                | Node { tLeft  :: Tree a
-                       , tRight :: TreeH a (height tLeft) }
-  @-}
-
--- | Specify tree height is non-negative
-
-{-@ using (Tree a) as  {v:Tree a | 0 <= height v} @-}
-
--- | Vector stores the height
-
-data Vec a = Vec { vShift  :: Int    -- ^ height
-                 , vTree   :: Tree a -- ^ actual nodes
-                 }
-
--- | Refined type relates height of the `vTree` with `vShift`
-
-{-@ data Vec a = Vec { vShift :: Nat
-                     , vTree  :: TreeH a vShift
-                     }
-  @-}
-
---------------------------------------------------------------------------------
-
-arrayFor :: Int -> Vec a -> Maybe a
-arrayFor i (Vec l n) = loop l n
-  where
-    loop :: Int -> Tree a -> Maybe a
-    loop level node
-      | level > 0 = let b      = shift i (- level) `mod` 2  -- get bit 0 or 1
-                        node'  = getNode node b             -- get child
-                        level' = level - 1                  -- next level
-                    in
-                        loop level' node'
-
-      | otherwise = Just (getValue node)
-
-{-@ getNode :: t:{Tree a | 0 < height t}
-            -> {v:Nat | v < 2}
-            -> {v:Tree a | height v = height t - 1 }
-  @-}
-getNode :: Tree a -> Int -> Tree a
-getNode (Node l _) 0 = l
-getNode (Node _ r) 1 = r
-getNode _          _ = impossible "provably safe"
-
-{-@ getValue :: {t:Tree a | 0 = height t} -> a @-}
-getValue :: Tree a -> a
-getValue (Leaf x) = x
-getValue _        = impossible "provably safe"
-
-{-@ impossible :: {v:String | false} -> a @-}
-impossible = error
diff --git a/tests/pos/PointDist.hs b/tests/pos/PointDist.hs
deleted file mode 100644
--- a/tests/pos/PointDist.hs
+++ /dev/null
@@ -1,55 +0,0 @@
-{-@ LIQUID "--short-names"    @-}
-
-module Point where
-
--- | Non-negative numbers:
-
-{-@ type NonNeg  = {v:Double | v >= 0.0 } @-}
-
--- | Non-negative, and zero iff X is zero:
-
-{-@ type PosZ X  = {v:NonNeg | X == 0.0 <=> v == 0.0 } @-}
- 
--- | The distance function, STATICALLY guaranteed to satisfy "pre/post"
---   or type spec, assuming no run-time checks fail
-
-{-@ dist                 :: p1:Point -> p2:Point -> {v:NonNeg | v == 0.0 <=> EqPoint p1 p2} @-}
-dist (P x1 y1) (P x2 y2) = d
-  where 
-    d                    = root   (dx + dy)
-    dx                   = square (x1 - x2)
-    dy                   = square (y1 - y2)
-
--- | A Data Type for Points
-
-data Point = P { px :: Double, py::Double }
-
-{-@ data Point = P { px :: Double, py :: Double } @-}
-
--- | When are two points "equal" ?
-
-{-@ predicate EqPoint P1 P2 = (px P1 == px P2 && py P1 == py P2) @-}
-                
--- | Squaring numbers: DYNAMIC checks establish numerical properties
-
-{-@ square :: x:Double -> PosZ x @-}
-square   :: Double -> Double
-square 0 = 0
-square x = assume (xx > 0) xx 
-  where
-    xx   = x * x
-
-{-@ root :: x:NonNeg -> PosZ x  @-}
-root :: Double -> Double
-root 0  = 0
-root x  = assume (rx > 0) rx
-  where
-    rx  = sqrt x
-
--- | Run-time Checks
-
-{-@ assume     :: b:_ -> a -> {v:a | b} @-}
-assume True  x = x
-assume False _ = undefined -- error "Failed Dynamic Check!"
-
-
diff --git a/tests/pos/Product.hs b/tests/pos/Product.hs
deleted file mode 100644
--- a/tests/pos/Product.hs
+++ /dev/null
@@ -1,61 +0,0 @@
-module Vectors where
-
-import Prelude hiding (sum, product, zipWith)
-
-flatten :: Int -> Int -> [[a]] -> [a]
-
--- | Lets reuse plain lists
-
-type Vec a = [a]
-
--- | The `len` function is defined in the LH prelude as:
-{-
-
-   len        :: [a] -> Int
-   len []     = 0
-   len (_:xs) = 1 + len xs
--}
-
-             
-{-@ type VecN a N = {v : Vec a | len v = N} @-}
-
-{-@ product   :: xs:Vec a -> ys:Vec a -> VecN a {len xs * len ys} @-}
-product xs ys = flatten n m $ map (\y -> map (* y) xs) ys
-  where
-    m         = length xs
-    n         = length ys
-
-{-@ sum       :: xs:Vec a -> ys:VecN a {len xs}-> VecN a {len xs} @-}
-sum xs ys     = zipWith (+) xs ys
-
-{-@ sum'       :: xs:Vec a -> ys:Vec a -> VecN a {len xs + len ys} @-}
-sum' [] ys     = ys
-sum' (x:xs) ys = x : sum' xs ys
-
-{-@ example1   :: b:VecN _ 3 -> VecN _ 6 @-}
-example1 b     = ([1, 2] `product` b) `sum` [1, 2, 3, 4, 5, 6]
-    
-{-@ example2   :: a:Vec _ -> b:{Vec _ | len b * len a = 6} -> VecN _ 6 @-}
-example2 a b   = (a `product` b) `sum` [1,2,3,4,5,6]
-
-
--- Helpers --
-
-
-{-@ flatten          :: n:Nat -> m:Nat -> VecN (VecN a m) n -> VecN a {m * n} @-}
-flatten n m []       = []
-flatten n m (xs:xss) = xs ++ flatten (n-1) m xss 
-
-
-{-@ zipWith             :: (a -> b -> c) -> xs:Vec a -> ys:VecN b {len xs} -> VecN c {len xs} @-}
-zipWith f [] []         = []
-zipWith f (x:xs) (y:ys) = f x y : zipWith f xs ys
-
-
-
-
-{-@ lAssert :: TT -> a -> a@-}
-lAssert True x = x
-
-  
-
diff --git a/tests/pos/PromotedDataCons.hs b/tests/pos/PromotedDataCons.hs
deleted file mode 100644
--- a/tests/pos/PromotedDataCons.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-
-{-# LANGUAGE DataKinds #-}
-
-module PromotedDataCons where
-
-newtype Offset struct member = Offset { unOffset :: Int }
-
-type OffsetN t = Offset (t 'Nothing)
-
-foo = Nothing 
-
-{-@ bar :: t _       @-}
-bar :: t 'Nothing
-bar = undefined 
diff --git a/tests/pos/Propability.hs b/tests/pos/Propability.hs
deleted file mode 100644
--- a/tests/pos/Propability.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-{-@ LIQUID "--prune-unsorted" @-}
-
-module Boolability where
-
-{-@ type Boolability = {v:Double | ((0.0 <= v) && (v <= 1.0)) } @-}
-
-{-@ p :: Boolability @-}
-p :: Double
-p = 0.8
-
-data DPD k = DPD [Pair k Double]
-
-data Pair x y = P x y
-{-@ data DPD k = DPD (val::{v:[Pair k Boolability]|(total v) = 1.0 }) @-}
-
-{-@ measure total :: [Pair k Double] -> Double
-    total([]) = 0.0
-    total(x:xs) = (sndP x) + (total xs)
-  @-}
-
-{-@ measure sndP :: (Pair x Double) -> Double
-    sndP(P x y) = y
-  @-}
-
-
-dpd0 :: DPD Int
-dpd0 = DPD [P 1 0.8, P 2 0.1, P 3 0.1]
diff --git a/tests/pos/QQTySig.hs b/tests/pos/QQTySig.hs
deleted file mode 100644
--- a/tests/pos/QQTySig.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-{-# LANGUAGE QuasiQuotes #-}
-
-module Nats where
-
-import LiquidHaskell
-
-[lq| nats :: [{ v:Int | 0 <= v }] |]
-nats = [0,1,2,3,4,5,6,7,8,9,10]
-
diff --git a/tests/pos/QQTySigTyVars.hs b/tests/pos/QQTySigTyVars.hs
deleted file mode 100644
--- a/tests/pos/QQTySigTyVars.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-# LANGUAGE QuasiQuotes #-}
-
-module Nats where
-
-import LiquidHaskell
-
-[lq| nats :: Show s => s -> [{ v:Int | 0 <= v }] |]
-nats _ = [0,1,2,3,4,5,6,7,8,9,10]
-
-[lq| myId :: x:a -> { v:a | v = x } |]
-myId x = x
-
diff --git a/tests/pos/QQTySyn.hs b/tests/pos/QQTySyn.hs
deleted file mode 100644
--- a/tests/pos/QQTySyn.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-# LANGUAGE QuasiQuotes #-}
-
-module Nats where
-
-import LiquidHaskell
-
-[lq| type MyNat = { v:Int | 0 <= v } |]
-[lq| type MyList a N = { v:[a] | (len v) = N } |]
-
-[lq| nats :: MyList MyNat 11 |]
-nats = [0,1,2,3,4,5,6,7,8,9,10]
-
diff --git a/tests/pos/RBTree-col-height.hs b/tests/pos/RBTree-col-height.hs
deleted file mode 100644
--- a/tests/pos/RBTree-col-height.hs
+++ /dev/null
@@ -1,208 +0,0 @@
-
-{-@ LIQUID "--no-termination"   @-}
-
-module RedBlackTree where
-
-import Language.Haskell.Liquid.Prelude
-
-data RBTree a = Leaf 
-              | Node Color a !(RBTree a) !(RBTree a)
-              deriving (Show)
-
-data Color = B -- ^ Black
-           | R -- ^ Red
-           deriving (Eq,Show)
-
----------------------------------------------------------------------------
--- | Add an element -------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ add :: (Ord a) => a -> RBT a -> RBT a @-}
-add x s = makeBlack (ins x s)
-
-{-@ ins :: (Ord a) => a -> t:RBT a -> {v: ARBTN a {(bh t)} | ((IsB t) => (isRB v))} @-}
-ins kx Leaf             = Node R kx Leaf Leaf
-ins kx s@(Node B x l r) = case compare kx x of
-                            LT -> let t = lbal x (ins kx l) r in t 
-                            GT -> let t = rbal x l (ins kx r) in t 
-                            EQ -> s
-ins kx s@(Node R x l r) = case compare kx x of
-                            LT -> Node R x (ins kx l) r
-                            GT -> Node R x l (ins kx r)
-                            EQ -> s
-
----------------------------------------------------------------------------
--- | Delete an element ----------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ remove :: (Ord a) => a -> RBT a -> RBT a @-}
-remove x t = makeBlack (del x t)
-
-{-@ predicate HDel T V = (bh V) = (if (isB T) then (bh T) - 1 else (bh T)) @-}
-
-{-@ del              :: (Ord a) => a -> t:RBT a -> {v:ARBT a | ((HDel t v) && ((isB t) || (isRB v)))} @-}
-del x Leaf           = Leaf
-del x (Node _ y a b) = case compare x y of
-   EQ -> append y a b 
-   LT -> case a of
-           Leaf         -> Node R y Leaf b
-           Node B _ _ _ -> lbalS y (del x a) b
-           _            -> let t = Node R y (del x a) b in t 
-   GT -> case b of
-           Leaf         -> Node R y a Leaf 
-           Node B _ _ _ -> rbalS y a (del x b)
-           _            -> Node R y a (del x b)
-
-{-@ append :: y:a -> l:RBT a -> r:RBTN a {(bh l)} -> (ARBT2 a l r) @-}
-append :: a -> RBTree a -> RBTree a -> RBTree a
-
-append _ Leaf r                               
-  = r
-
-append _ l Leaf                               
-  = l
-
-append piv (Node R lx ll lr) (Node R rx rl rr)  
-  = case append piv lr rl of 
-     Node R x lr' rl' -> Node R x (Node R lx ll lr') (Node R rx rl' rr)
-     lrl              -> Node R lx ll (Node R rx lrl rr)
-
-append piv (Node B lx ll lr) (Node B rx rl rr)  
-  = case append piv lr rl of 
-      Node R x lr' rl' -> Node R x (Node B lx ll lr') (Node B rx rl' rr)
-      lrl              -> lbalS lx ll (Node B rx lrl rr)
-
-append piv l@(Node B _ _ _) (Node R rx rl rr)   
-  = Node R rx (append piv l rl) rr
-
-append piv l@(Node R lx ll lr) r@(Node B _ _ _) 
-  = Node R lx ll (append piv lr r)
-
----------------------------------------------------------------------------
--- | Delete Minimum Element -----------------------------------------------
----------------------------------------------------------------------------
-
-{-@ deleteMin            :: RBT a -> RBT a @-}
-deleteMin (Leaf)         = Leaf
-deleteMin (Node _ x l r) = makeBlack t
-  where 
-    (_, t)               = deleteMin' x l r
-
-
-{-@ deleteMin'                   :: k:a -> l:RBT a -> r:RBTN a {(bh l)} -> (a, ARBT2 a l r) @-}
-deleteMin' k Leaf r              = (k, r)
-deleteMin' x (Node R lx ll lr) r = (k, Node R x l' r)   where (k, l') = deleteMin' lx ll lr 
-deleteMin' x (Node B lx ll lr) r = (k, lbalS x l' r )   where (k, l') = deleteMin' lx ll lr 
-
----------------------------------------------------------------------------
--- | Rotations ------------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ lbalS  :: k:a -> l:ARBT a -> r:RBTN a {1 + (bh l)} -> {v: ARBTN a {1 + (bh l)} | ((IsB r) => (isRB v))} @-}
-lbalS k (Node R x a b) r              = Node R k (Node B x a b) r
-lbalS k l (Node B y a b)              = let t = rbal k l (Node R y a b) in t 
-lbalS k l (Node R z (Node B y a b) c) = Node R y (Node B k l a) (rbal z b (makeRed c))
-lbalS k l r                           = liquidError "nein" -- Node R l k r
-
-{-@ rbalS  :: k:a -> l:RBT a -> r:ARBTN a {(bh l) - 1} -> {v: ARBTN a {(bh l)} | ((IsB l) => (isRB v))} @-}
-rbalS k l (Node R y b c)              = Node R k l (Node B y b c)
-rbalS k (Node B x a b) r              = let t = lbal k (Node R x a b) r in t 
-rbalS k (Node R x a (Node B y b c)) r = Node R y (lbal x (makeRed a) b) (Node B k c r)
-rbalS k l r                           = liquidError "nein" -- Node R l k r
-
-{-@ lbal  :: k:a -> l:ARBT a -> RBTN a {(bh l)} -> RBTN a {1 + (bh l)} @-}
-lbal k (Node R y (Node R x a b) c) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k (Node R x a (Node R y b c)) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k l r                            = Node B k l r
-
-{-@ rbal  :: k:a -> l:RBT a -> ARBTN a {(bh l)} -> RBTN a {1 + (bh l)} @-}
-rbal x a (Node R y b (Node R z c d))  = Node R y (Node B x a b) (Node B z c d)
-rbal x a (Node R z (Node R y b c) d)  = Node R y (Node B x a b) (Node B z c d)
-rbal x l r                            = Node B x l r
-
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ type BlackRBT a = {v: RBT a | ((IsB v) && (bh v) > 0)} @-}
-
-{-@ makeRed :: l:BlackRBT a -> ARBTN a {(bh l) - 1} @-}
-makeRed (Node _ x l r) = Node R x l r
-makeRed Leaf           = liquidError "nein" 
-
-{-@ makeBlack :: ARBT a -> RBT a @-}
-makeBlack Leaf           = Leaf
-makeBlack (Node _ x l r) = Node B x l r
-
----------------------------------------------------------------------------
--- | Specifications -------------------------------------------------------
----------------------------------------------------------------------------
-
--- | Red-Black Trees
-
-{-@ type RBT a    = {v: RBTree a | ((isRB v) && (isBH v)) } @-}
-
-{-@ type RBTN a N = {v: (RBT a) | (bh v) = N }              @-}
-
-{-@ measure isRB        :: RBTree a -> Bool
-    isRB (Leaf)         = true
-    isRB (Node c x l r) = ((isRB l) && (isRB r) && ((c == R) => ((IsB l) && (IsB r))))
-  @-}
-
--- | Almost Red-Black Trees
-
-{-@ type ARBT a    = {v: RBTree a | ((isARB v) && (isBH v))} @-}
-
-{-@ type ARBTN a N = {v: ARBT a   | (bh v) = N }             @-}
-
-{-@ measure isARB        :: (RBTree a) -> Bool
-    isARB (Leaf)         = true 
-    isARB (Node c x l r) = ((isRB l) && (isRB r))
-  @-}
-
--- | Conditionally Red-Black Tree
-
-{-@ type ARBT2 a L R = {v:ARBTN a {(bh L)} | (((IsB L) && (IsB R)) => (isRB v))} @-}
-
--- | Color of a tree
-
-{-@ measure col         :: RBTree a -> Color
-    col (Node c x l r)  = c
-    col (Leaf)          = B
-  @-}
-
-{-@ measure isB        :: RBTree a -> Bool
-    isB (Leaf)         = false
-    isB (Node c x l r) = c == B 
-  @-}
-
-{-@ predicate IsB T = not ((col T) == R) @-}
-
--- | Black Height
-
-{-@ measure isBH        :: RBTree a -> Bool
-    isBH (Leaf)         = true
-    isBH (Node c x l r) = ((isBH l) && (isBH r) && (bh l) = (bh r))
-  @-}
-
-{-@ measure bh        :: RBTree a -> Int
-    bh (Leaf)         = 0
-    bh (Node c x l r) = (bh l) + (if (c == R) then 0 else 1) 
-  @-}
-
--------------------------------------------------------------------------------
--- Auxiliary Invariants -------------------------------------------------------
--------------------------------------------------------------------------------
-
-{-@ predicate Invs V = ((Inv1 V) && (Inv2 V) && (Inv3 V))   @-}
-{-@ predicate Inv1 V = (((isARB V) && (IsB V)) => (isRB V)) @-}
-{-@ predicate Inv2 V = ((isRB V) => (isARB V))              @-}
-{-@ predicate Inv3 V = 0 <= (bh V)                          @-}
-
-{-@ invariant {v: Color | (v = R || v = B)}                 @-}
-
-{-@ invariant {v: RBTree a | (Invs v)}                      @-}
-
-{-@ inv            :: RBTree a -> {v:RBTree a | (Invs v)}   @-}
-inv Leaf           = Leaf
-inv (Node c x l r) = Node c x (inv l) (inv r)
diff --git a/tests/pos/RBTree-color.hs b/tests/pos/RBTree-color.hs
deleted file mode 100644
--- a/tests/pos/RBTree-color.hs
+++ /dev/null
@@ -1,189 +0,0 @@
-{-@ LIQUID "--no-termination"   @-}
-
-module RedBlackTree where
-
-import Language.Haskell.Liquid.Prelude
-
-data RBTree a = Leaf 
-              | Node Color a !(RBTree a) !(RBTree a)
-              deriving (Show)
-
-data Color = B -- ^ Black
-           | R -- ^ Red
-           deriving (Eq,Show)
-
----------------------------------------------------------------------------
--- | Add an element -------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ add :: (Ord a) => a -> RBT a -> RBT a @-}
-add x s = makeBlack (ins x s)
-
-{-@ ins :: (Ord a) => a -> t:RBT a -> {v: ARBT a | ((IsB t) => (isRB v))} @-}
-ins kx Leaf             = Node R kx Leaf Leaf
-ins kx s@(Node B x l r) = case compare kx x of
-                            LT -> let t = lbal x (ins kx l) r in t 
-                            GT -> let t = rbal x l (ins kx r) in t 
-                            EQ -> s
-ins kx s@(Node R x l r) = case compare kx x of
-                            LT -> Node R x (ins kx l) r
-                            GT -> Node R x l (ins kx r)
-                            EQ -> s
-
----------------------------------------------------------------------------
--- | Delete an element ----------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ remove :: (Ord a) => a -> RBT a -> RBT a @-}
-remove x t = makeBlack (del x t)
-
-{-@ del              :: (Ord a) => a -> t:RBT a -> {v:ARBT a | ((isB t) || (isRB v))} @-}
-del x Leaf           = Leaf
-del x (Node _ y a b) = case compare x y of
-   EQ -> append y a b 
-   LT -> case a of
-           Leaf         -> Node R y Leaf b
-           Node B _ _ _ -> lbalS y (del x a) b
-           _            -> let t = Node R y (del x a) b in t 
-   GT -> case b of
-           Leaf         -> Node R y a Leaf 
-           Node B _ _ _ -> rbalS y a (del x b)
-           _            -> Node R y a (del x b)
-
-{-@ append :: y:a -> l:RBT a -> r:RBT a -> (ARBT2 a l r) @-}
-
-append :: a -> RBTree a -> RBTree a -> RBTree a
-
-append _ Leaf r 
-  = r
-
-append _ l Leaf 
-  = l
-
-append piv (Node R lx ll lr) (Node R rx rl rr)  
-  = case append piv lr rl of 
-      Node R x lr' rl' -> Node R x (Node R lx ll lr') (Node R rx rl' rr)
-      lrl              -> Node R lx ll (Node R rx lrl rr)
-
-append piv (Node B lx ll lr) (Node B rx rl rr)  
-  = case append piv lr rl of 
-      Node R x lr' rl' -> Node R x (Node B lx ll lr') (Node B rx rl' rr)
-      lrl              -> lbalS lx ll (Node B rx lrl rr)
-
-append piv l@(Node B _ _ _) (Node R rx rl rr)   
-  = Node R rx (append piv l rl) rr
-
-append piv l@(Node R lx ll lr) r@(Node B _ _ _) 
-  = Node R lx ll (append piv lr r)
-
----------------------------------------------------------------------------
--- | Delete Minimum Element -----------------------------------------------
----------------------------------------------------------------------------
-
-{-@ deleteMin :: RBT a -> RBT a @-}
-deleteMin (Leaf)         = Leaf
-deleteMin (Node _ x l r) = makeBlack t
-  where 
-    (_, t)               = deleteMin' x l r
-
-
-{-@ deleteMin' :: k:a -> l:RBT a -> r:RBT a -> (a, ARBT2 a l r) @-}
-deleteMin' k Leaf r              = (k, r)
-deleteMin' x (Node R lx ll lr) r = (k, Node R x l' r)   where (k, l') = deleteMin' lx ll lr 
-deleteMin' x (Node B lx ll lr) r = (k, lbalS x l' r )   where (k, l') = deleteMin' lx ll lr 
-
----------------------------------------------------------------------------
--- | Rotations ------------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ lbalS                             :: k:a -> l:ARBT a -> r:RBT a -> {v: ARBT a | ((IsB r) => (isRB v))} @-}
-lbalS k (Node R x a b) r              = Node R k (Node B x a b) r
-lbalS k l (Node B y a b)              = let t = rbal k l (Node R y a b) in t 
-lbalS k l (Node R z (Node B y a b) c) = Node R y (Node B k l a) (rbal z b (makeRed c))
-lbalS k l r                           = unsafeError "nein"
-
-{-@ rbalS                             :: k:a -> l:RBT a -> r:ARBT a -> {v: ARBT a | ((IsB l) => (isRB v))} @-}
-rbalS k l (Node R y b c)              = Node R k l (Node B y b c)
-rbalS k (Node B x a b) r              = let t = lbal k (Node R x a b) r in t 
-rbalS k (Node R x a (Node B y b c)) r = Node R y (lbal x (makeRed a) b) (Node B k c r)
-rbalS k l r                           = unsafeError "nein" 
-
-{-@ lbal                              :: k:a -> l:ARBT a -> RBT a -> RBT a @-}
-lbal k (Node R y (Node R x a b) c) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k (Node R x a (Node R y b c)) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k l r                            = Node B k l r
-
-{-@ rbal                              :: k:a -> l:RBT a -> ARBT a -> RBT a  @-}
-rbal x a (Node R y b (Node R z c d))  = Node R y (Node B x a b) (Node B z c d)
-rbal x a (Node R z (Node R y b c) d)  = Node R y (Node B x a b) (Node B z c d)
-rbal x l r                            = Node B x l r
-
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ type BlackRBT a = {v: RBT a | (IsB v)} @-}
-
-{-@ makeRed :: l:BlackRBT a -> ARBT a @-}
-makeRed (Node B x l r) = Node R x l r
-makeRed _              = unsafeError "nein" 
-
-{-@ makeBlack :: ARBT a -> RBT a @-}
-makeBlack Leaf           = Leaf
-makeBlack (Node _ x l r) = Node B x l r
-
----------------------------------------------------------------------------
--- | Specifications -------------------------------------------------------
----------------------------------------------------------------------------
-
--- | Red-Black Trees
-
-{-@ type RBT a    = {v: RBTree a | (isRB v)} @-}
-
-{-@ measure isRB        :: RBTree a -> Bool
-    isRB (Leaf)         = true
-    isRB (Node c x l r) = ((isRB l) && (isRB r) && ((c == R) => ((IsB l) && (IsB r))))
-  @-}
-
--- | Almost Red-Black Trees
-
-{-@ type ARBT a    = {v: RBTree a | (isARB v) } @-}
-
-{-@ measure isARB        :: (RBTree a) -> Bool
-    isARB (Leaf)         = true 
-    isARB (Node c x l r) = ((isRB l) && (isRB r))
-  @-}
-
--- | Conditionally Red-Black Tree
-
-{-@ type ARBT2 a L R = {v:ARBT a | (((IsB L) && (IsB R)) => (isRB v))} @-}
-
--- | Color of a tree
-
-{-@ measure col         :: RBTree a -> Color
-    col (Node c x l r)  = c
-    col (Leaf)          = B
-  @-}
-
-{-@ measure isB        :: RBTree a -> Bool
-    isB (Leaf)         = false
-    isB (Node c x l r) = c == B 
-  @-}
-
-{-@ predicate IsB T = not ((col T) == R) @-}
-
-------------------------------------------------------------------
--- | Auxiliary Invariants ----------------------------------------
-------------------------------------------------------------------
-
-{-@ predicate Invs V = ((Inv1 V) && (Inv2 V))               @-}
-{-@ predicate Inv1 V = (((isARB V) && (IsB V)) => (isRB V)) @-}
-{-@ predicate Inv2 V = ((isRB V) => (isARB V))              @-}
-
-{-@ invariant {v: Color | (v = R || v = B)}                 @-}
-
-{-@ invariant {v: RBTree a | (Invs v)}                      @-}
-
-{-@ inv            :: RBTree a -> {v:RBTree a | (Invs v)}   @-}
-inv Leaf           = Leaf
-inv (Node c x l r) = Node c x (inv l) (inv r)
diff --git a/tests/pos/RBTree-height.hs b/tests/pos/RBTree-height.hs
deleted file mode 100644
--- a/tests/pos/RBTree-height.hs
+++ /dev/null
@@ -1,177 +0,0 @@
-
-{-@ LIQUID "--no-termination"   @-}
-{-@ LIQUID "--no-totality"      @-}
-
-module RedBlackTree where
-
-import Language.Haskell.Liquid.Prelude
-
-data RBTree a = Leaf 
-              | Node Color a !(RBTree a) !(RBTree a)
-              deriving (Show)
-
-data Color = B -- ^ Black
-           | R -- ^ Red
-           deriving (Eq,Show)
-
----------------------------------------------------------------------------
--- | Add an element -------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ add :: (Ord a) => a -> RBT a -> RBT a @-}
-add x s = makeBlack (ins x s)
-
-{-@ ins :: (Ord a) => a -> t:RBT a -> RBTN a {(bh t)}  @-}
-ins kx Leaf             = Node R kx Leaf Leaf
-ins kx s@(Node B x l r) = case compare kx x of
-                            LT -> let t = lbal x (ins kx l) r in t 
-                            GT -> let t = rbal x l (ins kx r) in t 
-                            EQ -> s
-ins kx s@(Node R x l r) = case compare kx x of
-                            LT -> Node R x (ins kx l) r
-                            GT -> Node R x l (ins kx r)
-                            EQ -> s
-
----------------------------------------------------------------------------
--- | Delete an element ----------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ remove :: (Ord a) => a -> RBT a -> RBT a @-}
-remove x t = makeBlack (del x t)
-
-{-@ predicate HDel T V = (bh V) = (if (isB T) then (bh T) - 1 else (bh T)) @-}
-
-{-@ del              :: (Ord a) => a -> t:RBT a -> {v:RBT a | (HDel t v)} @-}
-del x Leaf           = Leaf
-del x (Node _ y a b) = case compare x y of
-   EQ -> append y a b 
-   LT -> case a of
-           Leaf         -> Node R y Leaf b
-           Node B _ _ _ -> lbalS y (del x a) b
-           _            -> let t = Node R y (del x a) b in t 
-   GT -> case b of
-           Leaf         -> Node R y a Leaf 
-           Node B _ _ _ -> rbalS y a (del x b)
-           _            -> Node R y a (del x b)
-
-{-@ append :: y:a -> l:RBT a -> r:RBTN a {(bh l)} -> RBTN a {(bh l)} @-}
-append :: a -> RBTree a -> RBTree a -> RBTree a
-
-append _ Leaf r                               
-  = r
-
-append _ l Leaf                               
-  = l
-
-append piv (Node R lx ll lr) (Node R rx rl rr)  
-  = case append piv lr rl of 
-     Node R x lr' rl' -> Node R x (Node R lx ll lr') (Node R rx rl' rr)
-     lrl              -> Node R lx ll (Node R rx lrl rr)
-
-append piv (Node B lx ll lr) (Node B rx rl rr)  
-  = case append piv lr rl of 
-      Node R x lr' rl' -> Node R x (Node B lx ll lr') (Node B rx rl' rr)
-      lrl              -> lbalS lx ll (Node B rx lrl rr)
-
-append piv l@(Node B _ _ _) (Node R rx rl rr)   
-  = Node R rx (append piv l rl) rr
-
-append piv l@(Node R lx ll lr) r@(Node B _ _ _) 
-  = Node R lx ll (append piv lr r)
-
----------------------------------------------------------------------------
--- | Delete Minimum Element -----------------------------------------------
----------------------------------------------------------------------------
-
-{-@ deleteMin            :: RBT a -> RBT a @-}
-deleteMin (Leaf)         = Leaf
-deleteMin (Node _ x l r) = makeBlack t
-  where 
-    (_, t)               = deleteMin' x l r
-
-
-{-@ deleteMin'                   :: k:a -> l:RBT a -> r:RBTN a {(bh l)} -> (a, RBTN a {(bh l)}) @-}
-deleteMin' k Leaf r              = (k, r)
-deleteMin' x (Node R lx ll lr) r = (k, Node R x l' r)   where (k, l') = deleteMin' lx ll lr 
-deleteMin' x (Node B lx ll lr) r = (k, lbalS x l' r )   where (k, l') = deleteMin' lx ll lr 
-
----------------------------------------------------------------------------
--- | Rotations ------------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ lbalS  :: k:a -> l:RBT a -> r:RBTN a {1 + (bh l)} -> RBTN a {1 + (bh l)} @-}
-lbalS k (Node R x a b) r              = Node R k (Node B x a b) r
-lbalS k l (Node B y a b)              = let t = rbal k l (Node R y a b) in t 
-lbalS k l (Node R z (Node B y a b) c) = Node R y (Node B k l a) (rbal z b (makeRed c))
-lbalS k l r                           = unsafeError "nein"
-
-{-@ rbalS  :: k:a -> l:RBT a -> r:RBTN a {(bh l) - 1} -> RBTN a {(bh l)}    @-}
-rbalS k l (Node R y b c)              = Node R k l (Node B y b c)
-rbalS k (Node B x a b) r              = let t = lbal k (Node R x a b) r in t 
-rbalS k (Node R x a (Node B y b c)) r = Node R y (lbal x (makeRed a) b) (Node B k c r)
-rbalS k l r                           = unsafeError "nein"
-
-{-@ lbal  :: k:a -> l:RBT a -> RBTN a {(bh l)} -> RBTN a {1 + (bh l)} @-}
-lbal k (Node R y (Node R x a b) c) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k (Node R x a (Node R y b c)) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k l r                            = Node B k l r
-
-{-@ rbal  :: k:a -> l:RBT a -> RBTN a {(bh l)} -> RBTN a {1 + (bh l)} @-}
-rbal x a (Node R y b (Node R z c d))  = Node R y (Node B x a b) (Node B z c d)
-rbal x a (Node R z (Node R y b c) d)  = Node R y (Node B x a b) (Node B z c d)
-rbal x l r                            = Node B x l r
-
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ makeRed :: l:RBT a -> RBTN a {(bh l) - 1} @-}
-makeRed (Node B x l r) = Node R x l r
-makeRed _              = unsafeError "nein"
-
-{-@ makeBlack :: RBT a -> RBT a @-}
-makeBlack Leaf           = Leaf
-makeBlack (Node _ x l r) = Node B x l r
-
----------------------------------------------------------------------------
--- | Specifications -------------------------------------------------------
----------------------------------------------------------------------------
-
--- | Red-Black Trees
-
-{-@ type RBT a    = {v: RBTree a | (isBH v) }   @-}
-
-{-@ type RBTN a N = {v: RBT a  | (bh v) = N }   @-}
-
--- | Color of a tree
-
-{-@ measure isB        :: RBTree a -> Bool
-    isB (Leaf)         = false
-    isB (Node c x l r) = c == B 
-  @-}
-
--- | Black Height
-
-{-@ measure isBH        :: RBTree a -> Bool
-    isBH (Leaf)         = true
-    isBH (Node c x l r) = ((isBH l) && (isBH r) && (bh l) = (bh r))
-  @-}
-
-{-@ measure bh        :: RBTree a -> Int
-    bh (Leaf)         = 0
-    bh (Node c x l r) = (bh l) + (if (c == R) then 0 else 1) 
-  @-}
-
--------------------------------------------------------------------------------
--- Auxiliary Invariants -------------------------------------------------------
--------------------------------------------------------------------------------
-
-{-@ invariant {v: RBTree a | (Invs v)}        @-}
-{-@ predicate Invs V = (Inv3 V)               @-}
-{-@ predicate Inv3 V = 0 <= (bh V)            @-}
-
-{-@ invariant {v: Color | (v = R || v = B)}   @-}
-
-{-@ inv            :: RBTree a -> {v:RBTree a | (Invs v)}   @-}
-inv Leaf           = Leaf
-inv (Node c x l r) = Node c x (inv l) (inv r)
diff --git a/tests/pos/RBTree-ord.hs b/tests/pos/RBTree-ord.hs
deleted file mode 100644
--- a/tests/pos/RBTree-ord.hs
+++ /dev/null
@@ -1,148 +0,0 @@
-
-{-@ LIQUID "--no-termination"   @-}
-{-@ LIQUID "--no-totality"      @-}
-
-module Foo (add, remove, deleteMin, deleteMin') where
-
-import Language.Haskell.Liquid.Prelude
-
-data RBTree a = Leaf
-              | Node { nCol   :: Color
-                     , nKey   :: a
-                     , nLeft  :: !(RBTree a)
-                     , nRight :: !(RBTree a)
-                     }
-              deriving (Show)
-
-data Color = B -- ^ Black
-           | R -- ^ Red
-           deriving (Eq,Show)
-
----------------------------------------------------------------------------
--- | Add an element -------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ add :: (Ord a) => a -> ORBT a -> ORBT a @-}
-add x s = makeBlack (ins x s)
-
-{-@ ins :: (Ord a) => a -> ORBT a -> ORBT a @-}
-ins kx Leaf             = Node R kx Leaf Leaf
-ins kx s@(Node B x l r) = case compare kx x of
-                            LT -> let t = lbal x (ins kx l) r in t
-                            GT -> let t = rbal x l (ins kx r) in t
-                            EQ -> s
-ins kx s@(Node R x l r) = case compare kx x of
-                            LT -> Node R x (ins kx l) r
-                            GT -> Node R x l (ins kx r)
-                            EQ -> s
-
----------------------------------------------------------------------------
--- | Delete an element ----------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ remove :: (Ord a) => a -> ORBT a -> ORBT a @-}
-remove x t = makeBlack (del x t)
-
-{-@ del              :: (Ord a) => a -> ORBT a -> ORBT a @-}
-del x Leaf           = Leaf
-del x (Node _ y a b) = case compare x y of
-   EQ -> append y a b
-   LT -> case a of
-           Leaf         -> Node R y Leaf b
-           Node B _ _ _ -> lbalS y (del x a) b
-           _            -> let t = Node R y (del x a) b in t
-   GT -> case b of
-           Leaf         -> Node R y a Leaf
-           Node B _ _ _ -> rbalS y a (del x b)
-           _            -> Node R y a (del x b)
-
-{-@ append  :: y:a -> ORBT {v:a | v < y} -> ORBT {v:a | y < v} -> ORBT a @-}
-append :: a -> RBTree a -> RBTree a -> RBTree a
-
-append _ Leaf r
-  = r
-
-append _ l Leaf
-  = l
-
-append piv (Node R lx ll lr) (Node R rx rl rr)
-  = case append piv lr rl of
-      Node R x lr' rl' -> Node R x (Node R lx ll lr') (Node R rx rl' rr)
-      lrl              -> Node R lx ll (Node R rx lrl rr)
-
-append piv (Node B lx ll lr) (Node B rx rl rr)
-  = case append piv lr rl of
-      Node R x lr' rl' -> Node R x (Node B lx ll lr') (Node B rx rl' rr)
-      lrl              -> lbalS lx ll (Node B rx lrl rr)
-
-append piv l@(Node B _ _ _) (Node R rx rl rr)
-  = Node R rx (append piv l rl) rr
-
-append piv l@(Node R lx ll lr) r@(Node B _ _ _)
-  = Node R lx ll (append piv lr r)
-
----------------------------------------------------------------------------
--- | Delete Minimum Element -----------------------------------------------
----------------------------------------------------------------------------
-
-{-@ deleteMin  :: ORBT a -> ORBT a @-}
-deleteMin (Leaf)         = Leaf
-deleteMin (Node _ x l r) = makeBlack t
-  where
-    (_, t)               = deleteMin' x l r
-
-
-{-@ deleteMin' :: k:a -> ORBT {v:a | v < k} -> ORBT {v:a | k < v} -> (a, ORBT a) @-}
-deleteMin' k Leaf r              = (k, r)
-deleteMin' x (Node R lx ll lr) r = (k, Node R x l' r)   where (k, l') = deleteMin' lx ll lr
-deleteMin' x (Node B lx ll lr) r = (k, lbalS x l' r )   where (k, l') = deleteMin' lx ll lr
-
----------------------------------------------------------------------------
--- | Rotations ------------------------------------------------------------
----------------------------------------------------------------------------
-
-lbalS k (Node R x a b) r              = Node R k (Node B x a b) r
-lbalS k l (Node B y a b)              = let t = rbal k l (Node R y a b) in t
-lbalS k l (Node R z (Node B y a b) c) = Node R y (Node B k l a) (rbal z b (makeRed c))
-lbalS k l r                           = unsafeError "nein"
-
-rbalS k l (Node R y b c)              = Node R k l (Node B y b c)
-rbalS k (Node B x a b) r              = let t = lbal k (Node R x a b) r in t
-rbalS k (Node R x a (Node B y b c)) r = Node R y (lbal x (makeRed a) b) (Node B k c r)
-rbalS k l r                           = unsafeError "nein"
-
-lbal k (Node R y (Node R x a b) c) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k (Node R x a (Node R y b c)) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k l r                            = Node B k l r
-
-rbal x a (Node R y b (Node R z c d))  = Node R y (Node B x a b) (Node B z c d)
-rbal x a (Node R z (Node R y b c) d)  = Node R y (Node B x a b) (Node B z c d)
-rbal x l r                            = Node B x l r
-
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-
-makeRed (Node _ x l r) = Node R x l r
-makeRed Leaf           = unsafeError "nein"
-
-makeBlack Leaf           = Leaf
-makeBlack (Node _ x l r) = Node B x l r
-
----------------------------------------------------------------------------
--- | Specifications -------------------------------------------------------
----------------------------------------------------------------------------
-
--- | Ordered Red-Black Trees
-
-{-@ type ORBT a = RBTree <{\root v -> v < root }, {\root v -> v > root}> a @-}
-
--- | Binary Search Ordering
-
-{-@ data RBTree a <l :: a -> a -> Bool, r :: a -> a -> Bool>
-              = Leaf
-              | Node { nCol   :: Color
-                     , nKey   :: a
-                     , nLeft  :: RBTree <l, r> (a <l nKey>)
-                     , nRight :: RBTree <l, r> (a <r nKey>) }
-  @-}
diff --git a/tests/pos/RBTree.hs b/tests/pos/RBTree.hs
deleted file mode 100644
--- a/tests/pos/RBTree.hs
+++ /dev/null
@@ -1,216 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module Foo where
-
-import Language.Haskell.Liquid.Prelude
-
-data RBTree a = Leaf
-              | Node { nCol   :: Color
-                     , nKey   :: a
-                     , nLeft  :: !(RBTree a)
-                     , nRight :: !(RBTree a)
-                     }
-              deriving (Show)
-
-
-{-@ data RBTree a <l :: a -> a -> Bool, r :: a -> a -> Bool>
-            = Leaf
-            | Node { nCol   :: Color
-                   , nKey   :: a
-                   , nLeft  :: RBTree <l, r> (a <l nKey>)
-                   , nRight :: RBTree <l, r> (a <r nKey>)
-                  }
-  @-}
-
-data Color = B -- ^ Black
-           | R -- ^ Red
-           deriving (Eq,Show)
-
----------------------------------------------------------------------------
--- | Add an element -------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ add :: (Ord a) => a -> RBT a -> RBT a @-}
-add x s = makeBlack (ins x s)
-
-{-@ ins :: (Ord a) => a -> t:RBT a -> {v: ARBTN a {bh t} | IsB t => isRB v} @-}
-ins kx Leaf             = Node R kx Leaf Leaf
-ins kx s@(Node B x l r) = case compare kx x of
-                            LT -> let t = lbal x (ins kx l) r in t
-                            GT -> let t = rbal x l (ins kx r) in t
-                            EQ -> s
-ins kx s@(Node R x l r) = case compare kx x of
-                            LT -> Node R x (ins kx l) r
-                            GT -> Node R x l (ins kx r)
-                            EQ -> s
-
----------------------------------------------------------------------------
--- | Delete an element ----------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ remove :: (Ord a) => a -> RBT a -> RBT a @-}
-remove x t = makeBlack (del x t)
-
-{-@ predicate HDel T V = bh V = if (isB T) then (bh T) - 1 else bh T @-}
-
-{-@ del              :: (Ord a) => a -> t:RBT a -> {v:ARBT a | HDel t v && (isB t || isRB v)} @-}
-del x Leaf           = Leaf
-del x (Node _ y a b) = case compare x y of
-   EQ -> append y a b
-   LT -> case a of
-           Leaf         -> Node R y Leaf b
-           Node B _ _ _ -> lbalS y (del x a) b
-           _            -> let t = Node R y (del x a) b in t
-   GT -> case b of
-           Leaf         -> Node R y a Leaf
-           Node B _ _ _ -> rbalS y a (del x b)
-           _            -> Node R y a (del x b)
-
-{-@ append :: y:a -> l:RBT {v:a | v < y} -> r:RBTN {v:a | y < v} {bh l} -> ARBT2 a l r @-}
-append :: a -> RBTree a -> RBTree a -> RBTree a
-append _ Leaf r                               = r
-append _ l Leaf                               = l
-append piv (Node R lx ll lr) (Node R rx rl rr)  = case append piv lr rl of
-                                                    Node R x lr' rl' -> Node R x (Node R lx ll lr') (Node R rx rl' rr)
-                                                    lrl              -> Node R lx ll (Node R rx lrl rr)
-append piv (Node B lx ll lr) (Node B rx rl rr)  = case append piv lr rl of
-                                                    Node R x lr' rl' -> Node R x (Node B lx ll lr') (Node B rx rl' rr)
-                                                    lrl              -> lbalS lx ll (Node B rx lrl rr)
-append piv l@(Node B _ _ _) (Node R rx rl rr)   = Node R rx (append piv l rl) rr
-append piv l@(Node R lx ll lr) r@(Node B _ _ _) = Node R lx ll (append piv lr r)
-
----------------------------------------------------------------------------
--- | Delete Minimum Element -----------------------------------------------
----------------------------------------------------------------------------
-
-{-@ deleteMin            :: RBT a -> RBT a @-}
-deleteMin (Leaf)         = Leaf
-deleteMin (Node _ x l r) = makeBlack t
-  where
-    (_, t)               = deleteMin' x l r
-
-
-{-@ deleteMin'                   :: k:a -> l:RBT {v:a | v < k} -> r:RBTN {v:a | k < v} {bh l} -> (a, ARBT2 a l r) @-}
-deleteMin' k Leaf r              = (k, r)
-deleteMin' x (Node R lx ll lr) r = (k, Node R x l' r)   where (k, l') = deleteMin' lx ll lr
-deleteMin' x (Node B lx ll lr) r = (k, lbalS x l' r )   where (k, l') = deleteMin' lx ll lr
-
----------------------------------------------------------------------------
--- | Rotations ------------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ lbalS                             :: k:a -> l:ARBT {v:a | v < k} -> r:RBTN {v:a | k < v} {1 + bh l} -> {v: ARBTN a {1 + bh l} | IsB r => isRB v} @-}
-lbalS k (Node R x a b) r              = Node R k (Node B x a b) r
-lbalS k l (Node B y a b)              = let t = rbal k l (Node R y a b) in t
-lbalS k l (Node R z (Node B y a b) c) = Node R y (Node B k l a) (rbal z b (makeRed c))
-lbalS k l r                           = liquidError "nein"
-
-{-@ rbalS                             :: k:a -> l:RBT {v:a | v < k} -> r:ARBTN {v:a | k < v} {bh l - 1} -> {v: ARBTN a {bh l} | IsB l => isRB v} @-}
-rbalS k l (Node R y b c)              = Node R k l (Node B y b c)
-rbalS k (Node B x a b) r              = let t = lbal k (Node R x a b) r  in t
-rbalS k (Node R x a (Node B y b c)) r = Node R y (lbal x (makeRed a) b) (Node B k c r)
-rbalS k l r                           = liquidError "nein"
-
-{-@ lbal                              :: k:a -> l:ARBT {v:a | v < k} -> RBTN {v:a | k < v} {bh l} -> RBTN a {1 + bh l} @-}
-lbal k (Node R y (Node R x a b) c) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k (Node R x a (Node R y b c)) r  = Node R y (Node B x a b) (Node B k c r)
-lbal k l r                            = Node B k l r
-
-{-@ rbal                              :: k:a -> l:RBT {v:a | v < k} -> ARBTN {v:a | k < v} {bh l} -> RBTN a {1 + bh l} @-}
-rbal x a (Node R y b (Node R z c d))  = Node R y (Node B x a b) (Node B z c d)
-rbal x a (Node R z (Node R y b c) d)  = Node R y (Node B x a b) (Node B z c d)
-rbal x l r                            = Node B x l r
-
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-
-{-@ type BlackRBT a = {v: RBT a | IsB v && bh v > 0} @-}
-
-{-@ makeRed :: l:BlackRBT a -> ARBTN a {bh l - 1} @-}
-makeRed (Node B x l r) = Node R x l r
-makeRed _              = liquidError "nein"
-
-{-@ makeBlack :: ARBT a -> RBT a @-}
-makeBlack Leaf           = Leaf
-makeBlack (Node _ x l r) = Node B x l r
-
----------------------------------------------------------------------------
--- | Specifications -------------------------------------------------------
----------------------------------------------------------------------------
-
--- | Ordered Red-Black Trees
-
-{-@ type ORBT a = RBTree <{\root v -> v < root }, {\root v -> v > root}> a @-}
-
--- | Red-Black Trees
-
-{-@ type RBT a    = {v: ORBT a | isRB v && isBH v } @-}
-{-@ type RBTN a N = {v: RBT a  | bh v = N }         @-}
-
-{-@ type ORBTL a X = RBT {v:a | v < X} @-}
-{-@ type ORBTG a X = RBT {v:a | X < v} @-}
-
-{-@ measure isRB        :: RBTree a -> Bool
-    isRB (Leaf)         = true
-    isRB (Node c x l r) = isRB l && isRB r && (c == R => (IsB l && IsB r))
-  @-}
-
--- | Almost Red-Black Trees
-
-{-@ type ARBT a    = {v: ORBT a | isARB v && isBH v} @-}
-{-@ type ARBTN a N = {v: ARBT a | bh v = N }         @-}
-
-{-@ measure isARB        :: (RBTree a) -> Bool
-    isARB (Leaf)         = true
-    isARB (Node c x l r) = (isRB l && isRB r)
-  @-}
-
--- | Conditionally Red-Black Tree
-
-{-@ type ARBT2 a L R = {v:ARBTN a {bh L} | (IsB L && IsB R) => isRB v} @-}
-
--- | Color of a tree
-
-{-@ measure col         :: RBTree a -> Color
-    col (Node c x l r)  = c
-    col (Leaf)          = B
-  @-}
-
-{-@ measure isB        :: RBTree a -> Bool
-    isB (Leaf)         = false
-    isB (Node c x l r) = c == B
-  @-}
-
-{-@ predicate IsB T = not (col T == R) @-}
-
--- | Black Height
-
-{-@ measure isBH        :: RBTree a -> Bool
-    isBH (Leaf)         = true
-    isBH (Node c x l r) = (isBH l && isBH r && bh l = bh r)
-  @-}
-
-{-@ measure bh        :: RBTree a -> Int
-    bh (Leaf)         = 0
-    bh (Node c x l r) = bh l + if (c == R) then 0 else 1
-  @-}
-
--------------------------------------------------------------------------------
--- Auxiliary Invariants -------------------------------------------------------
--------------------------------------------------------------------------------
-
-{-@ predicate Invs V = Inv1 V && Inv2 V && Inv3 V   @-}
-{-@ predicate Inv1 V = (isARB V && IsB V) => isRB V @-}
-{-@ predicate Inv2 V = isRB V => isARB V            @-}
-{-@ predicate Inv3 V = 0 <= bh V                    @-}
-{-@ invariant {v: Color | v = R || v = B}           @-}
-{-@ invariant {v: RBTree a | Invs v}                @-}
-
-{-@ inv :: RBTree a -> {v:RBTree a | Invs v}        @-}
-inv Leaf           = Leaf
-inv (Node c x l r) = Node c x (inv l) (inv r)
-
-{-@ invc :: t:RBTree a -> {v:RBTree a | Invs t }  @-}
-invc Leaf           =  Leaf
-invc (Node c x l r) =  Node c x  (invc l) (invc r)
diff --git a/tests/pos/ReWrite.hs b/tests/pos/ReWrite.hs
deleted file mode 100644
--- a/tests/pos/ReWrite.hs
+++ /dev/null
@@ -1,45 +0,0 @@
-module ReWrite where 
-
-{-@ LIQUID "--max-rw-ordering-constraints=1" @-}
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++))
-
-
-{-@ rewriteWith assoc2 [assoc] @-} 
-{-@ assoc2 :: xs:[a] -> ys:[a] -> zs:[a] -> ws:[a]
-          -> { xs ++ (ys ++ (zs ++ ws)) == ((xs ++ ys) ++ zs) ++ ws } @-}
-assoc2 :: [a] -> [a] -> [a] -> [a] -> ()
-assoc2 xs ys zs ws 
-  = () {-
-    assoc xs ys (zs ++ ws)
-    `const` assoc (xs ++ ys) zs ws 
--}
-
-
-{-@ rewrite assoc @-}
-{-@ assoc :: xs:[a] -> ys:[a] -> zs:[a] 
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs } @-}
-assoc :: [a] -> [a] -> [a] -> ()
-assoc [] _ _       = ()
-assoc (_:xs) ys zs = assoc xs ys zs 
-
-{-@ reflect lhs @-}
-lhs xs ys zs ws = ((xs ++ ys) ++ zs) ++ ws
-
-{-@ reflect rhs @-}
-rhs xs ys zs ws = xs ++ (ys ++ (zs ++ ws))
-
-{-@ rewriteWith assoc3 [assoc] @-} 
-{-@ assoc3 :: xs:[a] -> ys:[a] -> zs:[a] -> ws:[a]
-          -> { lhs xs ys zs ws = rhs xs ys zs ws } @-}
-assoc3 :: [a] -> [a] -> [a] -> [a] -> ()
-assoc3 xs ys zs ws = () 
-
-
-{-@ reflect ++ @-}
-(++)::[a] -> [a] -> [a]
-[]     ++ ys = ys 
-(x:xs) ++ ys = x:(xs ++ys)
diff --git a/tests/pos/ReWrite10.hs b/tests/pos/ReWrite10.hs
deleted file mode 100644
--- a/tests/pos/ReWrite10.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-module ReWrite10 where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ LIQUID "--rw-termination-check" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding (length, (++))
-
-data N = S N | Z
-
-
-{-@ reflect f @-}
-f :: N -> N
-f x = g x
-
-{-@ reflect g @-}
-g (S x) = f x
-g Z     = Z
-
-{-@ rewrite diverge @-}
-{-@ assume diverge :: x : N -> { f x = g (S (S x)) } @-}
-diverge :: N -> ()
-diverge _ = ()
-
-{-@ proof :: x : N -> {g x = f x} @-}
-proof :: N -> ()
-proof _ = ()
-
diff --git a/tests/pos/ReWrite2.hs b/tests/pos/ReWrite2.hs
deleted file mode 100644
--- a/tests/pos/ReWrite2.hs
+++ /dev/null
@@ -1,53 +0,0 @@
--- Ensure that rewrites work with polymorphic types
-
-{-# LANGUAGE Rank2Types #-}
-
-{-@ LIQUID "--extensionality" @-}
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ LIQUID "--prune-unsorted" @-}
-module ReWrite2 where
-
-data OurMonad m = OurMonad {
-  bind :: forall a b. m a -> (a -> m b) -> m b,
-  return :: forall a.   a -> m a
-}
-
-{-@
-data OurMonad m = OurMonad {
-  bind   :: forall a b. m a -> (a -> m b) -> m b,
-  return :: forall a.   a -> m a
-}
-@-}
-
-{-@ reflect kleisli @-}
-{-@ kleisli :: om : OurMonad m
-            ->  f : (a -> m b)
-            ->  g : (b -> m c)
-            ->  x : a
-            -> {v : m c | v = kleisli om f g x} @-}
-kleisli :: OurMonad m -> (a -> m b) -> (b -> m c) -> a -> m c
-kleisli om f g x = bind om (f x) g
-
-{-@ kp :: om : OurMonad m
-            ->  f : (a -> m b)
-            ->  g : (b -> m c)
-            ->  x : a
-            -> {v : () | kleisli om f g x = bind om (f x) g} @-}
-kp :: OurMonad m -> (a -> m b) -> (b -> m c) -> a -> ()
-kp om f g x = ()
-
-{-@ reflect lhs @-}
-lhs om f g x = kleisli om f g x
-
-{-@ reflect rhs @-}
-rhs om f g x = bind om (f x) g
-
-{-@ rewriteWith mp [kp] @-}
-{-@ mp :: om : OurMonad m
-            ->  f : (a -> m b)
-            ->  g : (b -> m c)
-            ->  x : a
-            -> { lhs om f g x = rhs om f g x } @-}
-mp :: OurMonad m -> (a -> m b) -> (b -> m c) -> a -> ()
-mp om f g x = ()
diff --git a/tests/pos/ReWrite3.hs b/tests/pos/ReWrite3.hs
deleted file mode 100644
--- a/tests/pos/ReWrite3.hs
+++ /dev/null
@@ -1,32 +0,0 @@
--- Ensure that rewrites work with refinements
-module ReWrite3 where 
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++), drop, length)
-
-{-@ measure length @-}
-{-@ length :: [a] -> Int @-}
-length :: [a] -> Int
-length []     = 0
-length (_:xs) = 1 + length xs
-
-{-@ reflect drop @-}
-{-@ drop :: Int -> [a] -> [a] @-}
-drop :: Int -> [a] -> [a]
-drop n (x:xs) = drop (n - 1) xs
-drop _ []     = []
-drop 0 xs     = xs
-
-{-@ dropProof :: n : Int -> { xs : [a] | length xs >= n } -> { drop n xs = [] } @-}
-dropProof :: Int -> [a] -> ()
-dropProof _ []     = ()
-dropProof n (_:xs) = dropProof (n - 1) xs
-
-{-@ rewriteWith dropProof' [dropProof]  @-}
-{-@ dropProof' :: n : Int -> { xs : [a] | length xs >= n } -> { drop n xs = [] } @-}
-dropProof' :: Int -> [a] -> ()
-dropProof' _ _ = ()
-
diff --git a/tests/pos/ReWrite4.hs b/tests/pos/ReWrite4.hs
deleted file mode 100644
--- a/tests/pos/ReWrite4.hs
+++ /dev/null
@@ -1,28 +0,0 @@
--- Rewrites should work for identity equalities (i.e only diverging in one direction)
-module ReWrite4 where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++))
-
-data MyList a = MyNil | Cons a (MyList a)
-
-{-@ reflect ++ @-}
-(++)::MyList a -> MyList a -> MyList a
-MyNil       ++ ys = ys
-(Cons x xs) ++ ys = Cons x (xs ++ ys)
-
-
-{-@ concatIdent :: xs : MyList a -> { xs = xs ++ MyNil } @-}
-concatIdent :: MyList a -> ()
-concatIdent MyNil       = ()
-concatIdent (Cons _ xs) = concatIdent xs
-
-{-@ rewriteWith concatIdent' [concatIdent] @-}
-{-@ concatIdent' :: xs : MyList a -> { xs = xs ++ MyNil } @-}
-concatIdent' :: MyList a -> ()
-concatIdent' _ = ()
-
-
diff --git a/tests/pos/ReWrite5.hs b/tests/pos/ReWrite5.hs
deleted file mode 100644
--- a/tests/pos/ReWrite5.hs
+++ /dev/null
@@ -1,27 +0,0 @@
--- Rewrites should be applied recursively
-module ReWrite5 where
-
-{-@ LIQUID "--max-rw-ordering-constraints=0" @-}
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++))
-
-{-@ rewriteWith assoc3 [assoc] @-} 
-{-@ assoc3 :: xs:[a] -> ys:[a] -> zs:[a] -> ws:[a] -> vs:[a]
-          -> { xs ++ (ys ++ (zs ++ (ws ++ vs))) == (((xs ++ ys) ++ zs) ++ ws) ++ vs } @-}
-assoc3 :: [a] -> [a] -> [a] -> [a] -> [a] -> ()
-assoc3 xs ys zs ws vs = ()
-
-{-@ rewrite assoc @-}
-{-@ assoc :: xs:[a] -> ys:[a] -> zs:[a]
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs } @-}
-assoc :: [a] -> [a] -> [a] -> ()
-assoc [] _ _       = ()
-assoc (_:xs) ys zs = assoc xs ys zs
-
-{-@ reflect ++ @-}
-(++)::[a] -> [a] -> [a]
-[]     ++ ys = ys
-(x:xs) ++ ys = x:(xs ++ys)
diff --git a/tests/pos/ReWrite6.hs b/tests/pos/ReWrite6.hs
deleted file mode 100644
--- a/tests/pos/ReWrite6.hs
+++ /dev/null
@@ -1,31 +0,0 @@
--- Should be able to apply multiple rewrite rules
-module ReWrite6 where
-
-{-@ LIQUID "--max-rw-ordering-constraints=0" @-}
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding ((++))
-
-{-@ rewriteWith assoc2 [assoc, identity] @-} 
-{-@ assoc2 :: xs:[a] -> ys:[a] -> zs:[a] -> ws:[a]
-          -> { xs ++ (ys ++ (zs ++ ws)) == ((xs ++ ys) ++ zs) ++ ws ++ [] } @-}
-assoc2 :: [a] -> [a] -> [a] -> [a] -> ()
-assoc2 xs ys zs ws = ()
-
-{-@ assoc :: xs:[a] -> ys:[a] -> zs:[a] 
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs } @-}
-assoc :: [a] -> [a] -> [a] -> ()
-assoc [] _ _       = ()
-assoc (_:xs) ys zs = assoc xs ys zs
-
-{-@ identity :: xs:[a] -> {xs = xs ++ [] }@-}
-identity []     = ()
-identity (x:xs) = identity xs
-
-{-@ reflect ++ @-}
-(++)::[a] -> [a] -> [a]
-[]     ++ ys = ys 
-(x:xs) ++ ys = x:(xs ++ys)
-
diff --git a/tests/pos/ReWrite7.hs b/tests/pos/ReWrite7.hs
deleted file mode 100644
--- a/tests/pos/ReWrite7.hs
+++ /dev/null
@@ -1,109 +0,0 @@
--- A more challenging example
-{-# LANGUAGE Rank2Types #-}
-
-{-@ LIQUID "--extensionality" @-}
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ LIQUID "--prune-unsorted" @-}
-{-@ LIQUID "--max-rw-ordering-constraints=0" @-}
-
-
-module ReWrite7 where
-
-data MonadPlus m = MonadPlus {
-    mmonad  :: OurMonad m
-  , zero   :: forall a. m a
-  , choose :: forall a. m a -> m a -> m a
-}
-
-{-@ data MonadPlus m = MonadPlus {
-      mmonad  :: OurMonad m
-    , zero   :: forall a. m a
-    , choose :: forall a. m a -> m a -> m a
-    }
-  @-}
-
-
-data OurMonad m = OurMonad {
-  bind :: forall a b. m a -> (a -> m b) -> m b,
-  mreturn :: forall a.   a -> m a
-}
-
-{-@ data OurMonad m = OurMonad {
-      bind   :: forall a b. m a -> (a -> m b) -> m b,
-      mreturn :: forall a.   a -> m a
-    } 
-  @-}
-
-
-{-@ reflect const' @-}
-{-@ const' :: x : a -> y : b -> {v: a | v = x} @-}
-const' x _ = x
-
-{-@ reflect mbind @-}
-{-@ mbind ::
-         om : OurMonad m
-      -> x  : m a
-      -> f  : (a -> m b)
-      -> {v : m b | v == mbind om x f } @-}
-mbind :: OurMonad m -> m a -> (a -> m b) -> m b
-mbind = bind
-
-{-@ reflect mseq @-}
-{-@ mseq :: om : OurMonad m
-     -> ma : m a
-     -> mb : m b
-     -> {v : m b | v = mbind om ma (const' mb) } @-}
-mseq :: OurMonad m -> m a -> m b -> m b
-mseq om ma mb = mbind om ma (const' mb)
-
-{-@ guard :: mp : MonadPlus m -> p : Bool -> {v : m () | v = guard mp p } @-}
-{-@ reflect guard @-}
-guard :: MonadPlus m -> Bool -> m ()
-guard m True  = mreturn (mmonad m) ()
-guard m False = zero m
-
-{-@ reflect filt @-}
-filt :: MonadPlus m -> (a -> Bool) -> a -> m a
-filt mp p x = mseq (mmonad mp) (guard mp (p x)) (mreturn (mmonad mp) x)
-
-{-@ reflect lhs @-}
-lhs :: MonadPlus m -> Int -> Int -> ([Int], [Int]) -> m ([Int], [Int])
-lhs mp p x (ys, zs) =
-  mbind (mmonad mp) (filt mp (const' True) (ys, zs)) (mreturn (mmonad mp))
-  
-{-@ reflect kleisli @-}
-{-@ kleisli :: om : OurMonad m
-            ->  f : (a -> m b)
-            ->  g : (b -> m c)
-            ->  x : a
-            -> {v : m c | v = kleisli om f g x} @-}
-kleisli :: OurMonad m -> (a -> m b) -> (b -> m c) -> a -> m c
-kleisli om f g x = mbind om (f x) g
-
-{-@ reflect rhs @-}
-rhs :: MonadPlus m -> Int -> Int -> ([Int], [Int]) -> m ([Int], [Int])
-rhs mp p x =
-  kleisli (mmonad mp) (filt mp (const' True)) (mreturn (mmonad mp))
-  
-{-@ kp :: om : OurMonad m
-            ->  f : (a -> m b)
-            ->  g : (b -> m c)
-            ->  x : a
-            -> {v : () | kleisli om f g x = mbind om (f x) g} @-}
-kp :: OurMonad m -> (a -> m b) -> (b -> m c) -> a -> ()
-kp om f g x = ()
-  
-{-@ rewriteWith proof [kp] @-}
-{-@ proof ::
-           mp : MonadPlus m
-        ->  p : Int
-        ->  x : Int
-        ->  tupl : ([Int], [Int])
-        ->{ v : () |
-         lhs mp p x tupl =
-         rhs mp p x tupl
-      }
-@-}
-proof :: MonadPlus m -> Int -> Int -> ([Int], [Int]) -> ()
-proof mp p x (ys,zs) = ()
diff --git a/tests/pos/ReWrite8.hs b/tests/pos/ReWrite8.hs
deleted file mode 100644
--- a/tests/pos/ReWrite8.hs
+++ /dev/null
@@ -1,110 +0,0 @@
--- Rewrite an app argument
-{-# LANGUAGE Rank2Types #-}
-
-{-@ LIQUID "--extensionality" @-}
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ LIQUID "--prune-unsorted" @-}
-
-module ReWrite8 where
-
-import Prelude hiding (and)
-
-data MonadPlus m = MonadPlus {
-    monad  :: OurMonad m
-  , zero   :: forall a. m a
-  , choose :: forall a. m a -> m a -> m a
-}
-
-{-@ data MonadPlus m = MonadPlus {
-      monad  :: OurMonad m
-    , zero   :: forall a. m a
-    , choose :: forall a. m a -> m a -> m a
-    }
-  @-}
-
-{-@ reflect mmonad @-}
-{-@ mmonad :: mp : MonadPlus m -> {v : OurMonad m | v = mmonad mp }@-}
-mmonad = monad
-
-data OurMonad m = OurMonad {
-  bind   :: forall a b. m a -> (a -> m b) -> m b,
-  mreturn :: forall a.   a -> m a
-}
-
-{-@ data OurMonad m = OurMonad {
-      bind   :: forall a b. m a -> (a -> m b) -> m b,
-      mreturn :: forall a.   a -> m a
-    } 
-  @-}
-
-
-
-{-@ reflect mbind @-}
-{-@ mbind ::
-     om : OurMonad m
-     -> x  : m a
-     -> f  : (a -> m b)
-     -> {v : m b | v == mbind om x f } @-}
-mbind :: OurMonad m -> m a -> (a -> m b) -> m b
-mbind = bind
-
-{-@ guard :: mp : MonadPlus m -> p : Bool -> {v : m () | v = guard mp p } @-}
-{-@ reflect guard @-}
-guard :: MonadPlus m -> Bool -> m ()
-guard m True  = mreturn (mmonad m) ()
-guard m False = zero m
-
-{-@ reflect mseq @-}
-{-@ mseq :: om : OurMonad m
-      -> ma : m a
-      -> mb : m b
-      -> {v : m b | v = mbind om ma (const' mb) } @-}
-mseq :: OurMonad m -> m a -> m b -> m b
-mseq om ma mb = mbind om ma (const' mb)
-
-{-@ reflect const' @-}
-{-@ const' :: x : a -> y : b -> {v: a | v = x} @-}
-const' x _ = x
-
-{-@ assume guardSeq ::
-         mp : MonadPlus m
-      -> p  : Bool
-      -> q  : Bool
-      -> {v : () | guard mp (and p q)
-                 = mseq (mmonad mp) (guard mp p) (guard mp q) }
-@-}
-guardSeq :: MonadPlus m -> Bool -> Bool -> ()
-guardSeq _ _ _ = ()
-
-{-@ reflect and @-}
-{-@ and :: x : Bool -> y : Bool -> {z : Bool | z <=> x && y } @-}
-and :: Bool -> Bool -> Bool
-and True  y = y
-and False _ = False
-
-{-@ reflect step4Lambda @-}
-step4Lambda mp p x (ys, zs) =
-    mseq (mmonad mp)
-    (guard mp (and (x <= p) True))
-    (mreturn (mmonad mp) (x:ys, zs))
-
-{-@ reflect step5Lambda @-}
-step5Lambda mp p x (ys, zs) =
-    mseq (mmonad mp)
-      (mseq (mmonad mp) (guard mp (x <= p)) (guard mp True) )
-      (mreturn (mmonad mp) (x:ys, zs))
-    
-{-@ rewriteWith step4LambdaEqStep5Lambda [guardSeq] @-}
-{-@ step4LambdaEqStep5Lambda ::
-         mp : MonadPlus m
-      ->  p : Int
-      ->  x : Int
-      -> tupl : ([Int], [Int])
-      ->{ v : () |
-       step4Lambda mp p x tupl =
-       step5Lambda mp p x tupl
-      }
-@-}
-step4LambdaEqStep5Lambda :: MonadPlus m -> Int -> Int -> ([Int], [Int]) -> ()
-step4LambdaEqStep5Lambda mp p x (ys, zs) = ()
diff --git a/tests/pos/ReWrite9.hs b/tests/pos/ReWrite9.hs
deleted file mode 100644
--- a/tests/pos/ReWrite9.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-module ReWrite9 where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ infix ++ @-}
-
-import Prelude hiding (length, (++))
-
-{-@ reflect ++ @-}
-(++)::[a] -> [a] -> [a]
-[]     ++ ys = ys 
-(x:xs) ++ ys = x:(xs ++ys)
-
-{-@ reflect length @-}
-length :: [a] -> Int
-length []     = 0
-length (_:xs) = 1 + length xs
-
-
-{-@ rewrite lengthSym @-}
-{-@ assume lengthSym :: xs : [a] -> ys : [a] -> { length (xs ++ ys) == length (ys ++ xs) }@-}
-lengthSym :: [a] -> [a] -> ()
-lengthSym _ _ = ()
diff --git a/tests/pos/RealProps.hs b/tests/pos/RealProps.hs
deleted file mode 100644
--- a/tests/pos/RealProps.hs
+++ /dev/null
@@ -1,37 +0,0 @@
--- Issue overload-div-int-real #579
-
--- TAG: class
-
-module Div where
-
-{-@ type Valid = {v:Bool | v } @-}
-
-{-@ mulAssoc :: Double -> Double -> Double -> Valid @-}
-mulAssoc :: Double -> Double -> Double -> Bool
-mulAssoc x y z = (x * y) * z == x * (y * z) 
-
-{-@ mulCommut :: Double -> Double -> Valid @-}
-mulCommut :: Double -> Double -> Bool
-mulCommut x y = x * y == y * x 
-
-{-@ mulId :: Double -> Valid @-}
-mulId :: Double -> Bool
-mulId x = x == 1 * x 
-
-{-@ mulDistr :: Double -> Double -> Double -> Valid @-}
-mulDistr :: Double -> Double -> Double -> Bool
-mulDistr x y z = x * (y + z)  == (x * y) + (x * z)
-
-{-@ divId :: Double -> Valid @-}
-divId :: Double -> Bool
-divId x = x / 1.0 == x
-
-{-@ inverse :: {v:Double | v != 0.0} -> Valid @-}
-inverse :: Double -> Bool
-inverse x = 1.0 == x * (1.0 / x)
-
-
-imports = ( recip, fromRational )
-
--- poop :: Ratio Integer 
--- poop = undefined 
diff --git a/tests/pos/Rebind.hs b/tests/pos/Rebind.hs
deleted file mode 100644
--- a/tests/pos/Rebind.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-{-# LANGUAGE RebindableSyntax #-}
-
-module Rebind () where 
-
-import Prelude hiding ((>>), (>>=), return)
-
-(>>)   = plus
-return = id 
-
-{-@ plus :: x:Nat -> y:Nat -> {v:Nat | v = x + y} @-}
-plus :: Int -> Int -> Int 
-plus x y = x + y 
-
-{-@ test :: {v:Nat | v = 10} @-}
-test = do 
-  1
-  2
-  3
-  4
-
diff --git a/tests/pos/RecQSort.hs b/tests/pos/RecQSort.hs
deleted file mode 100644
--- a/tests/pos/RecQSort.hs
+++ /dev/null
@@ -1,31 +0,0 @@
--- TAG: abref 
-
-module GhcSort (qsort) where
-
-{-@ type OList a =  [a]<{\fld v -> (v >= fld)}>  @-}
-
-{-@ assert sort3 :: (Ord a) => [a] -> OList a @-}
-sort3 :: (Ord a) => [a] -> [a]
-sort3 = qsort 
-
-
-qsort:: (Ord a) => [a] -> [a]
-{-@ qsort:: (Ord a) => xs:[a] -> OList a / [(len xs), 0]@-}
-qsort []     = []
-qsort (x:xs) = qpart x xs [] []
-
-qpart  :: (Ord a) => a -> [a] -> [a] -> [a] -> [a]
-{-@ qpart  :: (Ord a) => x:a -> q:[a] -> r:[{v:a | (v < x)}] -> p:[{v:a |(v >= x)}] -> OList a / [((len p) + (len r) + (len q)), ((len q) + 1)]@-}
-qpart x [] rlt rge =
-    app x (qsort rlt) (x:qsort rge)
-qpart x (y:ys) rlt rge =
-    case compare x y of
-        GT -> qpart x ys (y:rlt) rge
-        _  -> qpart x ys rlt (y:rge)
-
-
-{-@ app :: Ord a => x:a -> (OList ({v:a | v < x})) -> (OList ({v:a| v >= x})) -> OList a @-} 
-app :: Ord a => a -> [a] -> [a] -> [a]
-app k []     ys = ys
-app k (x:xs) ys = x : (app k xs ys)
-
diff --git a/tests/pos/RecQSort0.hs b/tests/pos/RecQSort0.hs
deleted file mode 100644
--- a/tests/pos/RecQSort0.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-module GhcSort () where
-
-{-@ type OList a =  [a]<{\fld v -> (v >= fld)}>  @-}
-
-{-@ assert sort3 :: (Ord a) => [a] -> OList a @-}
-sort3 :: (Ord a) => [a] -> [a]
-sort3 ls = qsort ls 
-  where d = (length ls) 
-
-
-qsort:: (Ord a) => [a] -> [a]
-{-@ qsort:: (Ord a) => xs:[a] -> OList a / [(len xs), 0] @-}
-qsort []     = []
-qsort (x:xs) = qpart x xs [] [] 
-
-qpart  :: (Ord a) => a -> [a] -> [a] -> [a] -> [a]
-{-@ qpart  :: (Ord a) => x:a -> q:[a] -> r:[{v:a | ((true) && (v < x))}] -> p:[{v:a | ((true) && (v >= x))}] -> OList a / [((len r)+(len q)+(len p)), ((len q)+1)]@-}
-qpart x [] rlt rge =
-    app x (qsort rlt) (x:qsort rge)
-qpart x (y:ys) rlt rge =
-    case compare x y of
-        GT -> qpart x ys (y:rlt) rge
-        _  -> qpart x ys rlt (y:rge)
-
-
-{-@ app :: Ord a => x:a -> (OList ({v:a | v < x})) -> (OList ({v:a| v >= x})) -> OList a @-} 
-app :: Ord a => a -> [a] -> [a] -> [a]
-app k []     ys = ys
-app k (x:xs) ys = x : (app k xs ys)
-
diff --git a/tests/pos/RecSelector.hs b/tests/pos/RecSelector.hs
deleted file mode 100644
--- a/tests/pos/RecSelector.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Invariant where
-
-data F a = F {fx :: a, fy :: a, fzz :: a} | G {fx :: a}
-
-{-@ data F a = F {fx :: a, fy :: a, fzz :: a}
-             | G {fx :: a}
-  @-}
-
-{-@ fooG :: x:a -> {v : F a | (fx v) = x} @-}
-fooG :: a -> F a
-fooG x = G x
-
-{-@ foo :: x:a -> {v : F a | (fx v) = x} @-}
-foo :: a -> F a
-foo x = F x x x
diff --git a/tests/pos/RecordSelectorError.hs b/tests/pos/RecordSelectorError.hs
deleted file mode 100644
--- a/tests/pos/RecordSelectorError.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module Foo where
-
-data F a b = F {fx :: a, fy :: b} | G {fx :: a}
-{-@ data F a b = F {fx :: a, fy :: b} | G {fx :: a} @-}
-
-{-@ measure isF @-}
-isF :: F a b -> Bool
-isF (F x y) = True 
-isF (G x)   = False
-
--- Record's selector type it defaulted to true as imported
-{-@ fy  :: {v:F a b | isF v} -> b @-}
-{-@ bar :: {v:F a b | isF v} -> b @-}
-bar :: F a b  -> b
-bar = fy
-
-
diff --git a/tests/pos/Reduction.hs b/tests/pos/Reduction.hs
deleted file mode 100644
--- a/tests/pos/Reduction.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-@ LIQUID "--higherorder"    @-}
-
-module Reductions where
-
-{-@ reduction :: forall<p :: a -> Bool -> Bool>. 
-                 f:(a -> a) 
-              -> (x:a -> Bool<p x>) 
-              -> y:a -> Bool<p (f y)>  @-}
-reduction :: (a -> a) -> (a -> Bool) -> a -> Bool
-reduction f thm y = thm (f y)              
-
diff --git a/tests/pos/RefinedADTs.hs b/tests/pos/RefinedADTs.hs
deleted file mode 100644
--- a/tests/pos/RefinedADTs.hs
+++ /dev/null
@@ -1,38 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-module RefinedADTs where
-
-{-@ LIQUID "--no-termination" @-}
-
-{-@ data List a where
-        Nil  :: List a
-      | Cons :: listHead:a -> listTail:List a -> List a
-@-}
-
-{-@ data List1 a b where
-        Nil1  :: List1 a b
-      | Cons1 :: listHead:a -> listTail:List a -> List1 a b
-@-}
-
-{-@ data List2 a b <p :: a -> Bool> where
-        Nil2  :: List2 a b
-      | Cons2 :: listHead:a -> listTail:List a -> List2 a b
-@-}
-
-
-data List a where
-  Nil  :: List a
-  Cons :: a -> List a -> List a
-
-
-data List1 a b where
-  Nil1  :: List1 a b
-  Cons1 :: a -> List a -> List1 a b
-
-data List2 a b where
-  Nil2  :: List2 a b
-  Cons2 :: a -> List a -> List2 a b
-
-test :: List a -> Int
-test Nil = 1
-test (Cons x xs) = 1 + test xs
diff --git a/tests/pos/ReflectAlias.hs b/tests/pos/ReflectAlias.hs
deleted file mode 100644
--- a/tests/pos/ReflectAlias.hs
+++ /dev/null
@@ -1,11 +0,0 @@
--- See LH #1086 
-
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module Bob where
-
-type Val = Int
-
-{-@ reflect poo @-}
-poo :: Int -> Int
-poo y = (\(x :: Val) -> x + 1) y
diff --git a/tests/pos/ReflectBooleanFunctions.hs b/tests/pos/ReflectBooleanFunctions.hs
deleted file mode 100644
--- a/tests/pos/ReflectBooleanFunctions.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-{-@ LIQUID "--exactdc"      @-}
-{-@ LIQUID "--higherorder"  @-}
-module Data.Foo where
-
-
-{-@ reflect foo @-}
-foo :: (Int -> Bool) -> (Int -> Bool) -> Bool 
-foo f g = (f 1) && (g 1)
diff --git a/tests/pos/ReflectMutual.hs b/tests/pos/ReflectMutual.hs
deleted file mode 100644
--- a/tests/pos/ReflectMutual.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-{-@ LIQUID "--exactdc" @-}
-
-module ReflectMutual where
-
-data Foo = Foo {getFoo :: Int}
-{-@ data Foo [fromFoo] = Foo {getFoo :: Nat} @-}
-
-{-@ measure fromFoo @-}
-fromFoo :: Foo -> Int 
-fromFoo (Foo i) = i 
-
-{-@ reflect foo1 @-}
-foo1 :: Foo -> Int 
-foo1 (Foo i) | i == 0 = 0 
-foo1 (Foo n) = foo2 (Foo (n-1))
-
-{-@ reflect foo2 @-}
-foo2 :: Foo -> Int 
-foo2 (Foo x) | x <= 1 = x
-foo2 (Foo n) = foo1 (Foo (n-1))
diff --git a/tests/pos/RelativeComplete.hs b/tests/pos/RelativeComplete.hs
deleted file mode 100644
--- a/tests/pos/RelativeComplete.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module Compose where
-
-{-@ LIQUID "--no-termination" @-}
-
--- Here p and q of `app` will be instantiated to 
--- p , q := \v -> i <= v
-
-main i = app (check i) i
-
-{-@ check :: x:Int -> {v:Int | x <= v} -> () @-}
-check :: Int -> Int -> ()
-check = undefined
-
-
-{-@ app :: forall <p :: Int -> Bool, q :: Int -> Bool>. 
-           {Int<q> <: Int<p>}
-           {x::Int<q> |- {v:Int| v = x + 1} <: Int<q>}
-           (Int<p> -> ()) -> x:Int<q> -> () @-}
-app :: (Int -> ()) -> Int -> ()
-app f x = if p x then app f (x + 1) else f x
-
-
-p :: a -> Bool
-{-@ p :: a -> Bool @-}
-p = undefined
diff --git a/tests/pos/Repeat.hs b/tests/pos/Repeat.hs
deleted file mode 100644
--- a/tests/pos/Repeat.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-module Foo where
-import Prelude hiding (repeat, take)
-
-data L a = N | C a (L a)
-
-{-@
-data L a <p :: (L a) -> Bool>
-  = N
-  | C (lHd :: a) (lTl :: L <p> a <<p>>)
-@-}
-
-{-@
-measure isCons :: L a -> Bool
-isCons (N)     = false
-isCons (C a l) = true
-@-}
-
-{-@ type Stream a = {v: L <{\v -> (isCons v)}> a | (isCons v)} @-}
-
-{-@ lazy repeat @-}
-{-@ repeat :: a -> Stream a @-}
-repeat :: a -> L a
-repeat x = C x (repeat x)
-
-{-@ take :: Nat -> Stream a -> L a @-}
-take :: Int -> L a -> L a
-take 0 _           = N
-take n ys@(C x xs) = x `C` take (n-1) xs
diff --git a/tests/pos/Resolve.hs b/tests/pos/Resolve.hs
deleted file mode 100644
--- a/tests/pos/Resolve.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Resolve where
-
-import qualified ResolveA as RA
-import qualified ResolveB as RB
-
-
-{-@ x :: {v:RB.Bar | ((v = RB.B) && (NotA v))} @-}
-x = RB.B
-
-zebra :: Int
-zebra = 12 
diff --git a/tests/pos/ResolveA.hs b/tests/pos/ResolveA.hs
deleted file mode 100644
--- a/tests/pos/ResolveA.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module ResolveA  where
-
-import qualified ResolveB as RB
-import qualified ResolveB
-
-{-@ measure getFooA :: Foo -> Int
-    getFooA (Foo x) = x
-  @-}
-
-data Foo = Foo Int
-
-y = RB.Foo 1
-z = RB.A 
-{-@ qualif NotA(v:RB.Bar): (notA v) @-}
-
-{-@ measure notA :: RB.Bar -> Bool
-    notA (RB.A) = false
-    notA (RB.B) = true
-    notA (RB.C) = false
-  @-}
-
-{-@ predicate NotA V = V != RB.A @-}
diff --git a/tests/pos/ResolveB.hs b/tests/pos/ResolveB.hs
deleted file mode 100644
--- a/tests/pos/ResolveB.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module ResolveB where
-
-{-@ measure getFoo :: Foo -> Int
-    getFoo (Foo x) = x
-  @-}
-
-data Foo = Foo Int
-
-data Bar = A | B | C
diff --git a/tests/pos/ResolvePred.hs b/tests/pos/ResolvePred.hs
deleted file mode 100644
--- a/tests/pos/ResolvePred.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-
-module ResolvePred (myFold, llen) where
-
-{-@ data L [llen] = C (h :: Int) (t :: L) | N @-}
-
-data L = C Int L | N
-
-{-@ myFold :: forall <q :: L -> b -> Bool>.
-              (as:L -> a:Int -> b<q as> -> b<q (C a as)>)
-           -> b<q N>
-           -> l:L
-           -> b<q l>
-  @-}
-myFold f z = go
-  where
-    go N       = z
-    go (C a as) = f as a (go as)
-
-{-@ measure llen @-}
-llen :: L -> Int
-{-@ llen :: L -> Nat @-}
-llen N      = 0
-llen (C _ xs) = 1 + (llen xs)
-
-{-@ qualif PappL(v:a, p:Pred a L , a:int, as:L ):
-        papp2(p, v, C(a, as))
-  @-}
diff --git a/tests/pos/SafePartialFunctions.hs b/tests/pos/SafePartialFunctions.hs
deleted file mode 100644
--- a/tests/pos/SafePartialFunctions.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-module SafePartialFunctions (gotail, gohead) where
-
-import Prelude hiding (fromJust, tail, head)
-
-import Data.Maybe
-
-
-{-@ fromJust :: {v:Maybe a | isJust v} -> a @-}
-fromJust :: Maybe a -> a
-fromJust (Just a) = a
-
-{-@ tail :: {v:[a] | len v > 0} -> [a] @-}
-tail :: [a] -> [a]
-tail (x:xs) = xs
-
-{-@ head :: {v:[a] | len v > 0} -> a @-}
-head :: [a] -> a
-head (x:xs) = x
-
--- USERS
-
-gotail xs = case xs of
-             [] -> []
-             y : ys -> tail xs
-
-{-@ gohead :: [{v:[a] | len v > 0}] -> [a] @-}
-gohead :: [[a]] -> [a]
-gohead xs = map head xs
diff --git a/tests/pos/SimplerNotation.hs b/tests/pos/SimplerNotation.hs
deleted file mode 100644
--- a/tests/pos/SimplerNotation.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module SimplerNotation () where
-
-{-@ myDiv :: x:Int -> y:{Int | y != 0} -> {v:Int | v = x / y} @-}
-myDiv :: Int -> Int -> Int
-myDiv = div
diff --git a/tests/pos/SimplifyTup00.hs b/tests/pos/SimplifyTup00.hs
deleted file mode 100644
--- a/tests/pos/SimplifyTup00.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-
--- See: https://github.com/ucsd-progsys/liquidhaskell/pull/752
-
-module FOO (mkSessData) where
-
-mkSessData :: TcpEndPoint -> Bool
-mkSessData = isSrcTCP
-
-{- With the safeSimplifyPatTuple rewrite rule,
-   the body of the below expression become a
-   case with type (Port, Port) because the
-   case is becoming the outer-most
-   body expression
--}
-
-isSrcTCP :: TcpEndPoint -> Bool
-isSrcTCP x = (addrTE x, portTE x) == (srcIP, srcPort)
- where
-   (PP (PortId srcIP _) (PortId srcPort _)) = idTCP x
-
-
-data TCPId = PP PortId PortId
-data PortId = PortId Port Port
-
-data TcpEndPoint = TcpEndPoint { addrTE :: Port, portTE :: Port }
-
-
-data Port = P deriving (Eq)
-
-idTCP :: TcpEndPoint -> TCPId --  (PortId, PortId)
-idTCP tcp = undefined
diff --git a/tests/pos/SingletonLists.hs b/tests/pos/SingletonLists.hs
deleted file mode 100644
--- a/tests/pos/SingletonLists.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module SingletonLists where
-
-{-@ LIQUID "--higherorder" @-}
-
-{-@ infix : @-}
-
-empList :: ([a] -> a) -> ()
-{-@ empList :: f:([a] -> a) -> {f [] == f []} @-}
-empList _ = ()
-
-
-singletonList :: ([a] -> a) -> a -> ()
-{-@ singletonList :: f:([a] -> a) -> x:a -> {f [x] == f [x]} @-}
-singletonList _ _ = ()
-
-singletonListC :: ([a] -> a) -> a -> ()
-{-@ singletonListC :: f:([a] -> a) -> x:a -> {f (x:[]) == f [x]} @-}
-singletonListC _ _ = ()
-
diff --git a/tests/pos/Solver.hs b/tests/pos/Solver.hs
deleted file mode 100644
--- a/tests/pos/Solver.hs
+++ /dev/null
@@ -1,106 +0,0 @@
-
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--ple"            @-}
-{-@ LIQUID "--pruneunsorted"  @-}
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-
-module MultiParams where
-
-import Data.Tuple
-import Language.Haskell.Liquid.Prelude ((==>))
-import Data.List (nub)
-
--- | Formula
-
-type Var     = Int
-data Lit     = Pos Var | Neg Var
-data Val     = VTrue   | VFalse
-type Clause  = [Lit]
-type Formula = [Clause]
-
--- | Assignment
-
-type Asgn = [(Var, Val)]
-
--- | Top-level "solver"
-
-{-@ solve :: f:Formula -> Maybe {a:Asgn | sat a f} @-}
-solve   :: Formula -> Maybe Asgn
-solve f = find (\a -> sat a f) (asgns f)
-
-{-@ find :: forall <p :: a -> Bool, w :: a -> Bool -> Bool>.
-            {y::a, b::{v:Bool<w y> | v} |- {v:a | v == y} <: a<p>}
-            (x:a -> Bool<w x>) -> [a] -> Maybe (a<p>) @-}
-find :: (a -> Bool) -> [a] -> Maybe a
-find f (x:xs) 
-	| f x       = Just x
-    | otherwise = Nothing
-find f [] 	    = Nothing
-
-cons x xs = (x:xs)
-nil       = []
-
--- | Generate all assignments
-
-asgns :: Formula -> [Asgn] -- generates all possible T/F vectors
-asgns = go . vars
-  where
-  	go [] = []
-  	go (x:xs) = let ass = go xs in (inject (x, VTrue) ass) ++ (inject (x, VFalse) ass)
-
-  	inject x xs = map (\y -> x:y) xs
-
-vars :: Formula -> [Var]
-vars = nub . go
-  where
-  	go [] = []
-  	go (ls:xs) = map go' ls ++ go xs
-
-  	go' (Pos x) = x
-  	go' (Neg x) = x
-
--- | Satisfaction
-
-{-@ reflect sat @-}
-sat :: Asgn -> Formula -> Bool
-sat a []         = True
-sat a (c:cs)     = satCls a c && sat a cs
-
-{-@ reflect satCls @-}
-satCls :: Asgn -> Clause -> Bool
-satCls a []      = False
-satCls a (l:ls)  = satLit a l || satCls a ls
-
-{-@ reflect satLit @-}
-satLit :: Asgn -> Lit -> Bool
-satLit a (Pos x) = isTrue x a
-satLit a (Neg x) = isFalse x a
-
-{-@ reflect isTrue @-}
-isTrue          :: Var -> Asgn -> Bool
-isTrue xisT (yv:as) = if xisT == (myFst yv) then (isVFalse (mySnd yv)) else isTrue xisT as
-isTrue _ []      = False
-
-{-@ measure myFst @-}
-myFst :: (a, b) -> a
-myFst (x, y) = x
-
-{-@ measure mySnd @-}
-mySnd :: (a, b) -> b
-mySnd (x, y) = y
-
-{-@ reflect isFalse @-}
-isFalse          :: Var -> Asgn -> Bool
-isFalse xisF (yv:as) = if xisF == (myFst yv) then (isVFalse (mySnd yv)) else isFalse xisF as
-isFalse _ []      = False
-
-{-@ measure isVTrue @-}
-isVTrue :: Val -> Bool
-isVTrue VTrue  = True
-isVTrue VFalse = False
-
-{-@ measure isVFalse @-}
-isVFalse :: Val -> Bool
-isVFalse VFalse = True
-isVFalse VTrue  = False
diff --git a/tests/pos/StackClass.hs b/tests/pos/StackClass.hs
deleted file mode 100644
--- a/tests/pos/StackClass.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-
-module SClass where
-
-import qualified Data.Set
-
-data Stack a = S [a]
-
-data Foo a = F {stack :: Stack a}
-
-{-@ bar :: xs:[Foo a] -> {v:[Foo a] |(eltss v) = (eltss xs)} @-}
-bar :: [Foo a] -> [Foo a]
-bar = (F (S []):)
-
-foo = F 
-{-@ class measure elts  :: forall f a. f a -> Data.Set.Set a @-}
-{-@ class measure eltss  :: forall f a. [f a] -> Data.Set.Set a @-}
-
-{-@ instance measure elts :: Stack a -> (Data.Set.Set a)
-    elts (S xs) = (listElts xs)
-  @-}
-
-{-@ instance measure elts :: Foo a -> (Data.Set.Set a)
-    elts (F st) = (elts st)
-  @-}
-
-{-@ instance measure  eltss :: [(Foo a)] -> (Data.Set.Set a)
-    eltss([]) = {v| Set_emp v }
-    eltss(x:xs) = (Set_cup (elts x) (eltss xs))
-  @-}
diff --git a/tests/pos/StackMachine.hs b/tests/pos/StackMachine.hs
deleted file mode 100644
--- a/tests/pos/StackMachine.hs
+++ /dev/null
@@ -1,119 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--prune-unsorted" @-}
-
--- From: https://github.com/jstolarek/sandbox/blob/master/agda/agda-curious
-
-module StackMachine where
-
-import Prelude hiding (max)
-
-type Val   = Int
-data Expr  = EVal Val | EAdd Expr Expr
-data Instr = Push Val | Add
-
-eval :: Expr -> Val
-eval (EVal v)     = v
-eval (EAdd e1 e2) = eval e1 + eval e2
-
-compile :: Expr -> [Instr]
-compile (EVal v)     = [Push v]
-compile (EAdd e1 e2) = compile e1 ++ compile e2 ++ [Add]
-
-{-@ run :: is:[Instr] -> {v:[Val] | len v >= needs is} -> [Val] @-}
-run :: [Instr] -> [Val] -> [Val]
-run (Add    : is) (v1:v2:vs) = run is ((v1 + v2) : vs)
-run (Push v : is) vs         = run is (    v     : vs)
-run []            vs         = vs
-run (Add    : _ ) _          = die "impossible"
-
-{-@ die :: {v:String | false} -> a @-}
-die :: String -> a
-die = error
-
-{-@ measure needs @-}
-needs :: [Instr] -> Int
-needs (i:is) = max (pops i) ((needs is) - (pushes i))
-needs []     = 0
-
-{-@ measure pops @-}
-pops :: Instr -> Int
-pops Add      = 2
-pops (Push _) = 0
-
-{-@ measure pushes @-}
-pushes :: Instr -> Int
-pushes Add      = (-1)
-pushes (Push _) = 1
-
-{-@ inline max @-}
-max :: Int -> Int -> Int
-max x y = if x > y then x else y
-
-{-
-
-Some intuition / examples about `need`
-
-needs []
-  = 0
-needs [Add]
-  = max 2 (0 + 1)
-  = 2
-needs [Add, Add]
-  = max 2 (2 + 1)
-  = 3
-needs [Add, Add, Add]
-  = max 2 (3 + 1)
-  = 4
-
-
-needs [                              add ]
-  = 2
-
-needs [                      push 4, add ]
-  = max 0 (2 - 1)
-  = 1
-
-needs [                 add, push 4, add ]
-  = max 2 (1 + 1)
-  = 2
-
-needs [         push 3, add, push 4, add ]
-  = max 0 (2 - 1)
-  = 1
-
-needs [ push 2, push 3, add, push 4, add ]
-  = max 0 (1 - 1)
-  = 0
-
--}
-
-{- THEOREMS TODO
- 
-thm :: e:Expr -> { run (compile e) [] == [eval e] }
-thm e vs
-  = run (compile e) []
- .= run (compile e ++ []) []  `by` append_right_nil (compile e)
- .= run [] (eval e : [])      `by` lem e [] []
- .= [eval e]
- ** QED
-
-lem :: e:Expr -> is:[Instr] -> vs:[Val]
-      -> { run (compile e ++ is) vs == run is (eval e : vs) }
-
-lem (Val v) is vs
-  = run (compile (Val v) ++ is) vs
- .= run ([Push v] ++ is) vs
- .= run (Push v : is) vs       `eval` (++)
- .= v : vs
- ** QED
-
-lem (Add e1 e2) is vs
-  = run (compile (Add e1 e2) ++ is) vs
- .= run (compile e1 ++ compile e2 ++ [Add] ++ is) vs
- .= run (compile e2 ++ [Add] ++ is) (eval e1 : vs)  `by`   (lem ...)
- .= run ([Add] ++ is) (eval e2 : eval e1 : vs)      `by`   (lem ...)
- .= run (Add : is) (eval e2 : eval e1 : vs)         `eval` (++)
- .= run is ((eval e1 + eval e1) : vs)
- ** QED
-
- -}
diff --git a/tests/pos/State.hquals b/tests/pos/State.hquals
deleted file mode 100644
--- a/tests/pos/State.hquals
+++ /dev/null
@@ -1,10 +0,0 @@
-
-qualif Snd( v : b_t, 
-            p : Pred  b_t  a, 
-            a : fix##40##41#  a  b): 
-          (papp2 p v (fst a))
-
-qualif Fst( v : a, 
-            a : fix##40##41#  a  b): 
-           (v = fst a) 
-
diff --git a/tests/pos/State.hs b/tests/pos/State.hs
deleted file mode 100644
--- a/tests/pos/State.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module State () where
-
-import StateLib
-
-{-@ fresh :: ST <{\v -> (v >= 0)}, {\xx v -> ((xx>=0) && (v>=0))}> Int Int @-}
-fresh :: ST Int Int
-fresh = S (\n -> (n, n+1))
-
-{-@ incr4' :: ST <{\v -> (v>=0)}, {\xxxx v -> ((v>=0) && (xxxx>=0))}> Int Int @-}
-incr4' :: ST Int Int
-incr4' = fresh `bindST` returnST
diff --git a/tests/pos/StateConstraints.hs b/tests/pos/StateConstraints.hs
deleted file mode 100644
--- a/tests/pos/StateConstraints.hs
+++ /dev/null
@@ -1,113 +0,0 @@
-module Compose where
-
-
-
-
-data ST s a = ST {runState :: s -> (a,s)}
-
-{-@ data ST s a <p :: s -> Bool, q :: s -> s -> Bool, r :: s -> a -> Bool> 
-      = ST (runState :: x:s<p> -> (a<r x>, s<q x>)) @-}
-
- {-@ runState :: forall <p :: s -> Bool, q :: s -> s -> Bool, r :: s -> a -> Bool>. ST <p, q, r> s a -> x:s<p> -> (a<r x>, s<q x>) @-}
-
-
-
-{-
-cmp :: forall < pref :: s -> Bool, postf :: s -> s -> Bool
-              , pre  :: s -> Bool, postg :: s -> s -> Bool
-              , post :: s -> s -> Bool
-              , rg   :: s -> a -> Bool
-              , rf   :: s -> b -> Bool
-              , r    :: s -> b -> Bool
-              >. 
-       {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-       {ww::s<pre> |- s<postg ww> <: s<pref>}
-       (ST <pre, postg, rg> s a)
-    -> (ST <pref, postf, rf> s b)
-    -> (ST <pre, post, r> s b)
-@-}
-
-cmp :: (ST s a)
-    -> (ST s b)
-    -> (ST s b)
-
-cmp (ST g) (ST f) = ST (\x -> case g x of {(_, s) -> f s})    
-
-{-@ 
-bind :: forall < pref :: s -> Bool, postf :: s -> s -> Bool
-              , pre  :: s -> Bool, postg :: s -> s -> Bool
-              , post :: s -> s -> Bool
-              , rg   :: s -> a -> Bool
-              , rf   :: s -> b -> Bool
-              , r    :: s -> b -> Bool
-              , pref0 :: a -> Bool 
-              >. 
-       {x::s<pre> |- a<rg x> <: a<pref0>}      
-       {x::s<pre>, y::s<postg x> |- b<rf y> <: b<r x>}
-       {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-       {ww::s<pre> |- s<postg ww> <: s<pref>}
-       (ST <pre, postg, rg> s a)
-    -> (a<pref0> -> ST <pref, postf, rf> s b)
-    -> (ST <pre, post, r> s b)
-@-}
-
-bind :: (ST s a)
-    -> (a -> ST s b)
-    -> (ST s b)
-
-bind (ST g) f = ST (\x -> case g x of {(y, s) -> (runState (f y)) s})    
-
-{-@ incr :: ST <{\x -> x >= 0}, {\x v -> v = x + 1}, {\x v -> v = x}>  Nat Nat @-}
-incr :: ST Int Int
-incr = ST $ \x ->  (x, x + 1)
-
-{-@ incr2 :: ST <{\x -> x >= 0}, {\x v -> v = x + 2}, {\x v -> v = x + 1}>  Nat Nat @-}
-incr2 :: ST Int Int
-incr2 = bind incr (\_ -> incr)
-
-
-{-@ incr3 :: ST <{\x -> x >= 0}, {\x v -> v = x + 3}, {\x v -> v = x + 2}>  Nat Nat @-}
-incr3 :: ST Int Int
-incr3 = bind (bind incr (\_ -> incr)) (\_ -> incr)
-
-
-foo :: (Int, Int)
-{-@ foo :: ({v:Nat |  v = 2}, {v:Nat |  v = 3}) @-}
-foo = (runState incr3) 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/StateConstraints0.hs b/tests/pos/StateConstraints0.hs
deleted file mode 100644
--- a/tests/pos/StateConstraints0.hs
+++ /dev/null
@@ -1,105 +0,0 @@
-{-@ LIQUID "--noclasscheck"    @-}
-module Compose where
-
-import Prelude hiding (Monad(..))
-
--- | TODO 
--- | 
--- | 1. default methods are currently not supported
--- | ie. if we remove the definition of fail method it fails
--- | as I assume that dictionaries are Non Recursive
--- |
--- | 2. check what happens if we import the instance (it should work)  
-
-data ST s a = ST {runState :: s -> (a,s)}
-
-{-@ data ST s a <p :: s -> Bool, q :: s -> s -> Bool, r :: s -> a -> Bool> 
-      = ST (runState :: x:s<p> -> (a<r x>, s<q x>)) @-}
-
-{-@ runState :: forall <p :: s -> Bool, q :: s -> s -> Bool, r :: s -> a -> Bool>. ST <p, q, r> s a -> x:s<p> -> (a<r x>, s<q x>) @-}
-
-
-class Monad m where
-  return :: a -> m a
-  (>>=)  :: m a -> (a -> m b) -> m b
-  (>>)   :: m a -> m b -> m b
-
-
-instance Monad (ST s) where
-  {-@ instance Monad ST s where
-        return :: forall s a <p :: s -> Bool >. x:a -> ST <p, {\s v -> v == s}, {\s v -> x == v}> s a;
-        >>= :: forall s a b  < pref :: s -> Bool, postf :: s -> s -> Bool
-                  , pre  :: s -> Bool, postg :: s -> s -> Bool
-                  , post :: s -> s -> Bool
-                  , rg   :: s -> a -> Bool
-                  , rf   :: s -> b -> Bool
-                  , r    :: s -> b -> Bool
-                  , pref0 :: a -> Bool 
-                  >. 
-           {x::s<pre> |- a<rg x> <: a<pref0>}      
-           {x::s<pre>, y::s<postg x> |- b<rf y> <: b<r x>}
-           {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-           {ww::s<pre> |- s<postg ww> <: s<pref>}
-           (ST <pre, postg, rg> s a)
-          -> (a<pref0> -> ST <pref, postf, rf> s b)
-          -> (ST <pre, post, r> s b) ;
-        >>  :: forall s a b  < pref :: s -> Bool, postf :: s -> s -> Bool
-                  , pre  :: s -> Bool, postg :: s -> s -> Bool
-                  , post :: s -> s -> Bool
-                  , rg   :: s -> a -> Bool
-                  , rf   :: s -> b -> Bool
-                  , r    :: s -> b -> Bool
-                  >. 
-           {x::s<pre>, y::s<postg x> |- b<rf y> <: b<r x>}
-           {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-           {ww::s<pre> |- s<postg ww> <: s<pref>}
-           (ST <pre, postg, rg> s a)
-          -> (ST <pref, postf, rf> s b)
-          -> (ST <pre, post, r> s b)
-    @-}
-  return x     = ST $ \s -> (x, s)
-  (ST g) >>= f = ST (\x -> case g x of {(y, s) -> (runState (f y)) s})    
-  (ST g) >>  f = ST (\x -> case g x of {(y, s) -> (runState f) s})    
-
-{-@ incr :: ST <{\x -> true}, {\x v -> v = x + 1}, {\x v -> v = x}>  Int Int @-}
-incr :: ST Int Int
-incr = ST $ \x ->  (x, x + 1)
-
-{-@ foo :: ST <{\x -> true}, {\x v -> true}, {\x v -> v = 0}>  Bool Int @-}
-foo :: ST Bool Int
-foo = return 0
-
-{-@ incr2 :: ST <{\x -> true}, {\x v -> v = x + 2}, {\x v -> v = x + 1}>  Int Int @-}
-incr2 :: ST Int Int
-incr2 = incr >> incr
-
-{-@ incr3 :: ST <{\x -> true}, {\x v -> v = x + 3}, {\x v -> v = x + 2}>  Int Int @-}
-incr3 :: ST Int Int
-incr3 
-  = incr >> incr >> incr
-
-run :: (Int, Int)
-{-@ run :: ({v:Int |  v = 1}, {v:Int |  v = 2}) @-}
-run = (runState incr2) 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/StateConstraints00.hs b/tests/pos/StateConstraints00.hs
deleted file mode 100644
--- a/tests/pos/StateConstraints00.hs
+++ /dev/null
@@ -1,47 +0,0 @@
-module Compose where
-
-import Prelude hiding (Monad, return )
-
--- | TODO 
--- | 
--- | 1. default methods are currently not supported
-
-data ST s a = ST {runState :: s -> (a,s)}
-
-{-@ data ST s a <r :: a -> Bool> 
-      = ST (runState :: x:s -> (a<r>, s)) @-}
-
-{-@ runState :: forall <r :: a -> Bool>. ST <r> s a -> x:s -> (a<r>, s) @-}
-
-
-class Foo m where
-  return :: a -> m a
-
-
-instance Foo (ST s) where
-  {-@ instance Foo ST s where
-        return :: forall s a. x:a -> ST <{\v -> x == v}> s a
-    @-}
-  return x     = ST $ \s -> (x, s)
- 
-
-{-@ foo :: w:a -> ST <{v:a | v = w}>  Bool a @-}
-foo :: a -> ST Bool a
-foo x = return x
-
-
-bar = runState (foo 0) True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/StateF00.hs b/tests/pos/StateF00.hs
deleted file mode 100644
--- a/tests/pos/StateF00.hs
+++ /dev/null
@@ -1,21 +0,0 @@
--- TAG: absref
-
-module State (
-   returnST -- :: a -> ST a s
---  , bindST   -- :: ST a s -> (a -> ST b s) -> ST b s
- , ST(..)
- ) where
-
-import Prelude hiding (snd, fst)
-
-data ST a s = S (s -> (a, s))
-{-@ data ST a s <post :: s -> a -> s -> Bool> 
-       = S (ys::(x:s -> ((a, s)<\xx -> {v:s<post x xx> | true} > )))
-  @-}
-
-{-@ returnST :: xState:a 
-             -> ST <{\xs xa v -> (xa = xState)}> a s 
-  @-}
-
-returnST :: a -> ST a s
-returnST x = S $ \s -> (x, s)
diff --git a/tests/pos/StateLib.hs b/tests/pos/StateLib.hs
deleted file mode 100644
--- a/tests/pos/StateLib.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-module StateLib 
-  ( returnST -- :: a -> ST a s
-  , bindST   -- :: ST a s -> (a -> ST b s) -> ST b s
-  , ST(..)
-  ) where
-
-import Prelude hiding (snd, fst)
-
-data ST a s = S (s -> (a, s))
-{-@ data ST a s <pre :: s -> Bool, post :: a -> s -> Bool> 
-       = S (ys::(x:s<pre> -> ((a, s)<post>)))
-  @-}
-
-{-@ returnST :: forall <pre :: s -> Bool, post :: a -> s -> Bool>.
-               xState:a 
-           -> ST <{v:s<post xState>| true}, post> a s
-  @-}
-returnST :: a -> ST a s
-returnST x = S $ \s -> (x, s)
-
-
-{-@ bindST :: forall <pbind :: s -> Bool, qbind :: a -> s -> Bool, rbind :: b -> s -> Bool>.
-            ST <pbind, qbind> a s 
-         -> (xbind:a -> ST <{v:s<qbind xbind> | true}, rbind> b s) 
-         -> ST <pbind, rbind> b s
- @-}
-bindST :: ST a s -> (a -> ST b s) -> ST b s
-bindST (S m) k = S $ \s -> let (a, s') = m s in apply (k a) s'
-
-{-@ apply :: forall <p :: s -> Bool, q :: a -> s -> Bool>.
-             ST <p, q> a s -> s<p> -> (a, s)<q>
-  @-}
-apply :: ST a s -> s -> (a, s)
-apply (S f) s = f s
diff --git a/tests/pos/Streams.hs b/tests/pos/Streams.hs
deleted file mode 100644
--- a/tests/pos/Streams.hs
+++ /dev/null
@@ -1,107 +0,0 @@
-module Streams where
-
-import Prelude hiding (take, repeat)
-
-import Language.Haskell.Liquid.Prelude
-
--------------------------------------------------------------------------
--- | Lists 
--------------------------------------------------------------------------
- 
-data List a = N | C { x :: a, xs :: List a }
-
--- | Associate an abstract refinement with the _tail_ xs
-
-{-@ data List [size] a <p :: List a -> Bool>
-      = N | C { x  :: a
-              , xs :: List <p> a <<p>>
-              }
-  @-}
-
--------------------------------------------------------------------------
--- | Infinite Streams
--------------------------------------------------------------------------
-
--- | Infinite List = List where _each_ tail is a `kons` ...
-
-{-@ type Stream a = {xs: List <{\v -> kons v}> a | kons xs} @-}
-
--- | A simple measure for when a `List` is a `Cons`
-
-{-@ measure kons @-}
-kons :: List a -> Bool 
-kons (C x xs) = True 
-kons (N)      = False 
-
--------------------------------------------------------------------------
--- | Creating an Infinite Stream
--------------------------------------------------------------------------
-
-{-@ lazy repeat @-}
-                 
-{-@ repeat :: a -> Stream a @-}
-repeat   :: a -> List a
-repeat x = x `C` repeat x
-
-
--------------------------------------------------------------------------
--- | Using an Infinite Stream
--------------------------------------------------------------------------
-
-{-@ take        :: n:Nat -> Stream a -> {v:List a | size v = n} @-}
-take 0 _        = N
-take n (C x xs) = x `C` take (n-1) xs
-take _ N        = liquidError "never happens"
-
--------------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-
-
--- | Other specs from before ...
-
-{-@ measure size @-}
-{-@ size :: List a -> Nat @-} 
-size :: List a -> Int 
-size (N)      = 0
-size (C x xs) = (1 + size xs)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
------------------------------------------------------
-take            :: Int -> List a -> List a
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/StrictPair0.hs b/tests/pos/StrictPair0.hs
deleted file mode 100644
--- a/tests/pos/StrictPair0.hs
+++ /dev/null
@@ -1,15 +0,0 @@
--- Compare with tests/pos/StrictPair1.hs
-
-module SPair (poo) where
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-{-@ measure tsnd :: (a, b) -> b 
-    tsnd (x, y) = y 
-  @-} 
-
-{-@ type Foo  a = ((a, Int), Int)<{\z v -> v <= (tsnd z)}> @-}
-
-{-@ poo :: (Foo a) -> () @-}
-poo     :: ((a, Int), Int) -> ()
-poo ((x, n), m) = liquidAssert (m <= n) () 
diff --git a/tests/pos/StrictPair1.hs b/tests/pos/StrictPair1.hs
deleted file mode 100644
--- a/tests/pos/StrictPair1.hs
+++ /dev/null
@@ -1,31 +0,0 @@
--- From Data.ByteString.Fusion
-
--- Compare with tests/pos/StrictPair1.hs
-
-module SPair (
-    PairS(..)
-  , moo
-  , psnd
-  ) where
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-infixl 2 :*:
-
--- | Strict pair
---   But removing the strictness annotation does not change the fact that
---   this program is marked as SAFE...
-data PairS a b = !a :*: !b deriving (Eq,Ord,Show)
-
-{-@ data PairS a b <p :: x0:a -> b -> Bool> = (:*:) { spX ::a, spY ::b<p spX> }  @-}
-
-{-@ measure psnd @-}
-psnd :: PairS a b -> b
-psnd ((:*:) x y) = y
-
-
-{-@ type FooS a = PairS <{\z v -> v <= psnd z}> (PairS a Int) Int @-}
-
-{-@ moo :: (FooS a) -> () @-}
-moo :: PairS (PairS a Int) Int -> ()
-moo (x :*: n :*: m) = liquidAssert (m <= n) ()
diff --git a/tests/pos/StringLit.hs b/tests/pos/StringLit.hs
deleted file mode 100644
--- a/tests/pos/StringLit.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module StringLit where
-
-{-@ foo :: {v:String | len v = 3} @-}
-foo = "foo"
diff --git a/tests/pos/Strings.hs b/tests/pos/Strings.hs
deleted file mode 100644
--- a/tests/pos/Strings.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module DBC where
-
-import GHC.CString  -- This import interprets Strings as constants!
-
-import Data.Set
-
-{-@ prop1 :: {v:Bool | v } @-}
-prop1 :: Bool
-prop1 = foo1 /= foo2 
-  where foo1 = "foo"
-        foo2 = "bar"
diff --git a/tests/pos/StructRec.hs b/tests/pos/StructRec.hs
deleted file mode 100644
--- a/tests/pos/StructRec.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module ListLen () where
-
-{-@ autosize OList @-}
-
-data OList a =
-     Mt
-   | Ln{h :: a, t :: OList a}
-
-{-@ data OList a =
-        Mt
-      | Ln{h :: a, t :: OList {v:a | h <= v}} @-}
-
-insert :: (Ord a) => a -> OList a -> OList a
-insert y Mt        = Ln y Mt
-insert y (Ln x xs)
-  | y <= x         = Ln y (Ln x xs)
-  | otherwise      = Ln x (insert y xs)
-
diff --git a/tests/pos/Sum.hs b/tests/pos/Sum.hs
deleted file mode 100644
--- a/tests/pos/Sum.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Sum where
-
-{-@ ssum :: forall<p :: a -> Bool, q :: a -> Bool>. 
-            {{v:a | v == 0} <: a<q>}
-            {x::a<p> |- {v:a | x <= v} <: a<q>}
-            xs:[{v:a<p> | 0 <= v}] -> {v:a<q> | len xs >= 0 && 0 <= v } @-}
-ssum :: Num a => [a] -> a
-ssum []       = 0
-ssum [x]      = x
-ssum (x:xs)   = x + ssum xs
diff --git a/tests/pos/T1013.hs b/tests/pos/T1013.hs
deleted file mode 100644
--- a/tests/pos/T1013.hs
+++ /dev/null
@@ -1,36 +0,0 @@
-{-@ LIQUID "--reflection"    @-}
-
-{-# LANGUAGE RankNTypes #-}
-module Generics2 where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ reflect _identity @-}
-_identity :: a -> a
-_identity x = x
-{-# INLINE _identity #-}
-
-{- data Rec1 f p = Rec1 { unRec1 :: f p } @-}
-data Rec1 f p = Rec1 { unRec1 :: f p }
-
-{-@ reflect fmapRec1 @-}
-fmapRec1 :: (forall a b. (a -> b) -> f a -> f b)
-         -> (p -> q) -> Rec1 f p -> Rec1 f q
-fmapRec1 fmapF f (Rec1 fp) = Rec1 (fmapF f fp)
-
-{-@ fmapRec1Id :: fmapF:(forall a b. (a -> b) -> f a -> f b)
-               -> fmapFId:(forall a. y:(f a) -> { fmapF _identity y == y })
-               -> r:Rec1 f p
-               -> { fmapRec1 fmapF _identity r == r }
-@-}
-fmapRec1Id :: (forall a b. (a -> b) -> f a -> f b)
-           -> (forall a. f a -> Proof)
-           -> Rec1 f p -> Proof
-fmapRec1Id fmapF fmapFId r@(Rec1 fp)
-  =   fmapRec1 fmapF _identity r
-  === Rec1 (fmapF _identity fp)
-      ? fmapFId fp
-  === Rec1 (_identity fp) 
-  === Rec1 fp
-  === r
-  *** QED
diff --git a/tests/pos/T1013A.hs b/tests/pos/T1013A.hs
deleted file mode 100644
--- a/tests/pos/T1013A.hs
+++ /dev/null
@@ -1,62 +0,0 @@
-{-@ LIQUID "--reflection"  @-}
-{-@ LIQUID "--no-adt"      @-} -- TODO: embed HKTs in SMTLIB2 ADTs (e.g. `Rec`)
-
-{-# LANGUAGE RankNTypes #-}
-
-module Bug where
-
-import Prelude hiding (fmap)
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ reflect _compose @-}
-_compose :: (b -> c) -> (a -> b) -> a -> c
-_compose f g x = f (g x)
-{-# INLINE _compose #-}
-
-{-@ data Rec1 f p = Rec1 { unRec1 :: f p } @-}
-data Rec1 f p = Rec1 { unRec1 :: f p }
-
-{-@ data VerifiedFunctor m = VerifiedFunctor {
-        fmap        :: forall a b. (a -> b) -> m a -> m b
-      , fmapCompose :: forall a b c. f:(b -> c) -> g:(a -> b) -> x:m a
-                    -> { fmap (_compose f g) x == _compose (fmap f) (fmap g) x }
-      }
-  @-}
-data VerifiedFunctor m = VerifiedFunctor {
-    fmap        :: forall a b. (a -> b) -> m a -> m b
-  , fmapCompose :: forall a b c. (b -> c) -> (a -> b) -> m a -> Proof
-  }
-
-{-@ reflect fmapRec1 @-}
-fmapRec1 :: (forall a b. (a -> b) -> f a -> f b)
-         -> (p -> q) -> Rec1 f p -> Rec1 f q
-fmapRec1 fmapF f (Rec1 fp) = Rec1 (fmapF f fp)
-
-{-@ fmapRec1Compose :: fmapF:(forall a b. (a -> b) -> f a -> f b)
-                    -> fmapFId:(forall a b c. f':(b -> c) -> g':(a -> b) -> y:(f a) -> { fmapF (_compose f' g') y == _compose (fmapF f') (fmapF g') y })
-                    -> f:(q -> r)
-                    -> g:(p -> q)
-                    -> x:Rec1 f p
-                    -> { fmapRec1 fmapF (_compose f g) x == _compose (fmapRec1 fmapF f) (fmapRec1 fmapF g) x }
-@-}
-fmapRec1Compose :: (forall a b. (a -> b) -> f a -> f b)
-                -> (forall a b c. (b -> c) -> (a -> b) -> f a -> Proof)
-                -> (q -> r) -> (p -> q) -> Rec1 f p -> Proof
-fmapRec1Compose fmapF fmapFCompose f g r@(Rec1 fp)
-  =   fmapRec1 fmapF (_compose f g) r
-  === fmapRec1 fmapF (_compose f g) (Rec1 fp)
-  === Rec1 (fmapF (_compose f g) fp)
-      ? fmapFCompose f g fp
-  === Rec1 (_compose (fmapF f) (fmapF g) fp) 
-  === Rec1 (fmapF f (fmapF g fp))
-  === fmapRec1 fmapF f (Rec1 (fmapF g fp))
-  === fmapRec1 fmapF f (fmapRec1 fmapF g (Rec1 fp))
-  === _compose (fmapRec1 fmapF f) (fmapRec1 fmapF g) (Rec1 fp)
-  === _compose (fmapRec1 fmapF f) (fmapRec1 fmapF g) r
-  *** QED
-
-vfunctorRec1 :: VerifiedFunctor f -> VerifiedFunctor (Rec1 f)
-vfunctorRec1 (VerifiedFunctor fmapF fmapFCompose)
-  = VerifiedFunctor (fmapRec1        fmapF)
-                    (fmapRec1Compose fmapF fmapFCompose)
diff --git a/tests/pos/T1024.hs b/tests/pos/T1024.hs
deleted file mode 100644
--- a/tests/pos/T1024.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-{-@ LIQUID "--exactdc"     @-}
-{-@ LIQUID "--higherorder" @-}
-
-module Bug where
-
-
-{-@ data Par1 p = Par1 { unPar1 :: p } @-}
-data Par1 p = Par1 { unPar1 :: p }
-
-
-{-@ reflect eqPar1 @-}
-eqPar1 :: (p -> p -> Bool) -> Par1 p -> Par1 p -> Bool
-eqPar1 eqP x y = eqP (unPar1 x) (unPar1 y)
diff --git a/tests/pos/T1025.hs b/tests/pos/T1025.hs
deleted file mode 100644
--- a/tests/pos/T1025.hs
+++ /dev/null
@@ -1,36 +0,0 @@
-{-@ LIQUID "--reflection"     @-}
-
-module Bug where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ data Either a b = Left a | Right b @-}
-
-{-@ reflect eqEither @-}
-eqEither :: (a -> a -> Bool) -> (b -> b -> Bool)
-         -> Either a b -> Either a b -> Bool
-eqEither eqA _   (Left  x) (Left  y) = eqA x y
-eqEither _   eqB (Right x) (Right y) = eqB x y
-eqEither _   _   (Left  _) (Right _) = False
-eqEither _   _   (Right _) (Left  _) = False
-
-{-@ eqEitherRefl :: eqA:(a -> a -> Bool) -> eqARefl:(x:a -> { eqA x x })
-                 -> eqB:(b -> b -> Bool) -> eqBRefl:(y:b -> { eqB y y })
-                 -> p:Either a b
-                 -> { eqEither eqA eqB p p }
-@-}
-eqEitherRefl :: (a -> a -> Bool) -> (a -> Proof)
-             -> (b -> b -> Bool) -> (b -> Proof)
-             -> Either a b -> Proof
-eqEitherRefl eqA eqARefl eqB _ p@(Left x) =
-      eqEither eqA eqB p p
-  === eqA x x
-    ? eqARefl x
-  === True 
-  *** QED
-eqEitherRefl eqA _ eqB eqBRefl p@(Right y) =
-      eqEither eqA eqB p p
-  === eqB y y
-    ? eqBRefl y
-  === True 
-  *** QED
diff --git a/tests/pos/T1025a.hs b/tests/pos/T1025a.hs
deleted file mode 100644
--- a/tests/pos/T1025a.hs
+++ /dev/null
@@ -1,39 +0,0 @@
-{-@ LIQUID "--exactdc"     @-}                                                            
-{-@ LIQUID "--higherorder" @-}                                                            
-
-module Bug where                                                                          
-                                                                                          
-import Language.Haskell.Liquid.ProofCombinators                                           
-import Prelude hiding (Either (..))
-
-{-@ data Either a b = Left a | Right b @-}
-data Either a b = Left a | Right b
-                                                                                         
-{-@ reflect eqEither @-}                                                               
-eqEither :: (a -> a -> Bool) -> (b -> b -> Bool)                                          
-         -> Either a b -> Either a b -> Bool
-eqEither eqA _   (Left  x) (Left  y) = eqA x y
-eqEither _   eqB (Right x) (Right y) = eqB x y
-eqEither _   _   (Left  _) (Right _) = False
-eqEither _   _   (Right _) (Left  _) = False
-
-{-@ eqEitherRefl :: eqA:(a -> a -> Bool) -> eqARefl:(x:a -> { eqA x x })
-                 -> eqB:(b -> b -> Bool) -> eqBRefl:(y:b -> { eqB y y })
-                 -> p:Either a b
-                 -> { eqEither eqA eqB p p }
-@-}
-eqEitherRefl :: (a -> a -> Bool) -> (a -> Proof)
-             -> (b -> b -> Bool) -> (b -> Proof)
-             -> Either a b -> Proof
-eqEitherRefl eqA eqARefl eqB _ p@(Left x) =
-      eqEither eqA eqB p p
-  === eqA x x
-    ? eqARefl x
-  === True 
-  *** QED
-eqEitherRefl eqA _ eqB eqBRefl p@(Right y) =
-      eqEither eqA eqB p p
-  === eqB y y
-    ? eqBRefl y
-  === True 
-  *** QED
diff --git a/tests/pos/T1034.hs b/tests/pos/T1034.hs
deleted file mode 100644
--- a/tests/pos/T1034.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-{-@ LIQUID "--higherorder" @-}
-module Iso where
-
-data P a b  = P {p1 :: a, p2 :: b}
-{-@ data P a b = P {p1 :: a, p2 :: b}@-}
-
-{-@ type P1X a b X = {v:P a b | p1 v == X} @-}
-
-{-@ check :: x:a -> P1X a b x -> b @-}
-check :: a -> P a b -> b
-check x (P y p) = p
-
--- THIS IS SAFE
-{-@ ex1 :: P a b -> b @-}
-ex1 ::  (P a b) -> b
-ex1 f@(P y _) =
-  check y f
-
--- This is UNSAFE
-{-@ ex2 :: P a b -> b @-}
-ex2 ::  (P a b) -> b
-ex2 f =
-  let (P y p) = f in check y f
-  -- THIS IS OK: case f of (P y p) -> check y f
-
-{-@ qualif Zonk(v:(P a b), x: a): (p1 v = x) @-}
diff --git a/tests/pos/T1045.hs b/tests/pos/T1045.hs
deleted file mode 100644
--- a/tests/pos/T1045.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module T1045 where
-
-import T1045a
-
-foo :: Int -> Int
-foo x = x
diff --git a/tests/pos/T1045a.hs b/tests/pos/T1045a.hs
deleted file mode 100644
--- a/tests/pos/T1045a.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module T1045a where
-
-import {-# SOURCE #-} T1045
-
-bar = foo
diff --git a/tests/pos/T1060.hs b/tests/pos/T1060.hs
deleted file mode 100644
--- a/tests/pos/T1060.hs
+++ /dev/null
@@ -1,47 +0,0 @@
-{-@ LIQUID "--exact-data-con"                      @-}
-{-@ LIQUID "--higherorder"                         @-}
-{-@ LIQUID "--ple" @-}
-
-module Lists where
-
-import Prelude hiding (map, rev, sum) -- ((+), (+), Eq (..), Ord (..), Char, Int, Bool (..))
-import Language.Haskell.Liquid.ProofCombinators
-
--- | List Definition -----------------------------------------------------------
-
-{-@ data List [llen] @-} 
-data List a = Nil | Cons a (List a)
-
-{-@ measure llen @-}
-{-@ llen :: List a -> Nat @-}
-llen :: List a -> Int
-llen Nil        = 0
-llen (Cons h t) = 1 + llen t
-
--- | Map -----------------------------------------------------------------------
-
-{-@ reflect map @-}
-map :: (a -> b) -> List a -> List b
-map f Nil         = Nil
-map f (Cons x xs) = Cons (f x) (map f xs)
-
-{-@ reflect up @-}
-up :: Int -> Int
-up x = x + 1
-
-{-@ thmMapIncr :: xs:List Int -> { sum (map up xs) == sum xs + llen xs } @-}
-thmMapIncr :: List Int -> Proof
-thmMapIncr Nil         =  ()
-
-thmMapIncr (Cons x xs) = [ -- sum (map up (Cons x xs))
-                           -- ==. sum (Cons (up x) (map up xs))
-                           -- ==. (up x) + sum (map up xs) ?
-                           thmMapIncr xs
-                           -- ==. (x + 1) + (sum xs + llen xs)
-                           -- ==. sum (Cons x xs) + llen (Cons x xs)
-                         ] *** QED
-
-{-@ reflect sum @-}
-sum :: List Int -> Int
-sum Nil         = 0
-sum (Cons x xs) = x + sum xs
diff --git a/tests/pos/T1065.hs b/tests/pos/T1065.hs
deleted file mode 100644
--- a/tests/pos/T1065.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-# LANGUAGE TypeFamilies #-}
-module T1065 where
-
--- LH should be able to prove this program terminating
--- See NOTE [Don't choose transform-rec binders as decreasing params]
-groupByFB :: ([a] -> lst -> lst) -> lst -> (a -> a -> Bool) -> [a] -> lst
-groupByFB c n eq xs0 = groupByFBCore xs0
-  where groupByFBCore [] = n
-        groupByFBCore (x:xs) = c (x:ys) (groupByFBCore zs)
-            where (ys, zs) = span (eq x) xs
-
diff --git a/tests/pos/T1074.hs b/tests/pos/T1074.hs
deleted file mode 100644
--- a/tests/pos/T1074.hs
+++ /dev/null
@@ -1,35 +0,0 @@
--- see https://github.com/ucsd-progsys/liquidhaskell/issues/1074
-{-@ LIQUID "--bscope"         @-}
-
-module Blank where
-
-{-@ type Geq X = {v:Int | X <= v} @-}
-
-{-@ thisOk :: x:Int -> y:{Int | y > 10}  -> () @-}
-thisOk :: Int -> Int -> ()
-thisOk = undefined
-
-{-@ thisBad1 :: x:Int -> y:Geq y  -> () @-}
-thisBad1 :: Int -> Int -> ()
-thisBad1 = undefined
-
-{-@ thisBad2 :: x:Int -> y:{y > 10}  -> () @-}
-thisBad2 :: Int -> Int -> ()
-thisBad2 = undefined
-
-{-@ type NEList a = {xs:[a] | len xs > 0} @-}
-
-{-@ the3 :: Eq a => xs:NEList {x:a | x == headP xs} -> {y:a | headP xs == y} @-}
-the3 :: Eq a => [a] -> a
-the3 = undefined
-
-{-@ the1 :: Eq a => xs:NEList {x:a | x == headP xs} -> {y:a | headP xs == y} @-}
-the1 :: Eq a => [a] -> a
-the1 = undefined
-
-{-@ the2 :: Eq a => xs:{v:[{x:a | x == headP xs}] | len v > 0} -> {y:a | headP xs == y} @-}
-the2 :: Eq a => [a] -> a
-the2 = undefined
-
-{-@ measure headP :: a -> b @-}
-
diff --git a/tests/pos/T1085.hs b/tests/pos/T1085.hs
deleted file mode 100644
--- a/tests/pos/T1085.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-{-@ LIQUID "--exact-data-cons"   @-}
-
-module T1085 where
-
-{-@ data HEither a b = HLeft a | HRight b @-}
-data HEither a b = HLeft a | HRight b
-
-{-@ data HMaybe a = HJust a | HNothing @-}
-data HMaybe a = HJust a | HNothing
diff --git a/tests/pos/T1092.hs b/tests/pos/T1092.hs
deleted file mode 100644
--- a/tests/pos/T1092.hs
+++ /dev/null
@@ -1,65 +0,0 @@
-{-@ LIQUID "--higherorder"        @-}
-{-@ LIQUID "--exactdc"            @-}
-module VerifiedEqInstances where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ data VerifiedEq a = VEQ {
-        eq :: a -> a -> Bool
-      , refl :: x:a -> { v:() | eq x x }
-      , sym :: x:a -> y:a -> { v:() | eq x y ==> eq y x }
-      , trans :: x:a -> y:a -> z:a -> { v:() | eq x y && eq y z ==> eq x z }
-      }
-@-}
-data VerifiedEq a = VEQ {
-    eq    :: a -> a -> Bool
-  , refl  :: a -> Proof
-  , sym   :: a -> a -> Proof
-  , trans :: a -> a -> a -> Proof
-  }
-
-{-@ axiomatize eqInt @-}
-eqInt :: Int -> Int -> Bool
-eqInt x y = x == y
-{-# INLINE eqInt #-}
-
-{-@ eqIntRefl :: x:Int -> { eqInt x x } @-}
-eqIntRefl :: Int -> Proof
-eqIntRefl x = eqInt x x ==. x == x *** QED
-
-{-@ eqIntSym :: x:Int -> y:Int -> { eqInt x y ==> eqInt y x } @-}
-eqIntSym :: Int -> Int -> Proof
-eqIntSym x y = eqInt x y ==. x == y ==. y == x *** QED
-
-{-@ eqIntTrans :: x:Int -> y:Int -> z:Int -> { eqInt x y && eqInt y z ==> eqInt x z } @-}
-eqIntTrans :: Int -> Int -> Int -> Proof
-eqIntTrans x y z = (eqInt x y && eqInt y z) ==. (x == y && y == z) ==. x == z *** QED
-
-veqInt :: VerifiedEq Int
-veqInt = VEQ eqInt eqIntRefl eqIntSym eqIntTrans
-
-{-@ axiomatize eqDouble @-}
-eqDouble :: Double -> Double -> Bool
-eqDouble x y = x == y
-{-# INLINE eqDouble #-}
-
-{-@ eqDoubleRefl :: x:Double -> { eqDouble x x } @-}
-eqDoubleRefl :: Double -> Proof
-eqDoubleRefl x = eqDouble x x ==. x == x *** QED
-
-{-@ eqDoubleSym :: x:Double -> y:Double
-                -> { eqDouble x y ==> eqDouble y x } @-}
-eqDoubleSym :: Double -> Double -> Proof
-eqDoubleSym x y = eqDouble x y ==. x == y ==. y == x *** QED
-
-{-@ eqDoubleTrans :: x:Double -> y:Double -> z:Double
-                  -> { eqDouble x y && eqDouble y z ==> eqDouble x z } @-}
-eqDoubleTrans :: Double -> Double -> Double -> Proof
-eqDoubleTrans x y z
-  =   (eqDouble x y && eqDouble y z)
-  ==. (x == y       && y == z)
-  ==. x == z
-  *** QED
-
-veqDouble :: VerifiedEq Double
-veqDouble = VEQ eqDouble eqDoubleRefl eqDoubleSym eqDoubleTrans
diff --git a/tests/pos/T1095A.hs b/tests/pos/T1095A.hs
deleted file mode 100644
--- a/tests/pos/T1095A.hs
+++ /dev/null
@@ -1,53 +0,0 @@
-{-@ LIQUID "--reflection"        @-}
-{-@ LIQUID "--max-case-expand=0" @-}
-
-module Foo where
-
-{-@  data Foo [size] @-}
-data Foo 
-  = A Foo Foo Foo 
-  | B Foo Foo
-  | C Foo
-  | D Foo
-  | E Foo Int 
-  | F Int
-  | G Int
-  | H 
-  | I
-  | J  
-  | K
-  | L
-  | M
-  | N 
-  | X
-    
-{-@ measure size @-}
-size :: Foo -> Int
-
-{-@ size :: Foo -> Nat @-} 
-size (A x y z) = 1 + size x + size y + size z 
-size (B x y)   = 1 + size x + size y 
-size (C x)     = 1 + size x 
-size (D x)     = 1 + size x 
-size (E x _)   = 1 + size x 
-size (F _)     = 1 
-size (G _)     = 1 
-size _         = 0 
-    
-foo  :: Foo -> Foo
-foo (A X _ _) = X 
-foo (A _ X _) = X 
-foo (A _ _ X) = X 
-foo (B X _)   = X 
-foo (B _ X)   = X 
-foo (C X)     = X 
-foo (D X)     = X 
-foo (E X _)   = X 
-foo X         = X 
-foo (A x y z) = A (foo x) (foo y) (foo z)
-foo (B x y)   = B (foo x) (foo y)
-foo (C x)     = C (foo x)
-foo (D x)     = D (foo x)
-foo (E x i)   = E (foo x) i 
-foo x         = x 
-    
diff --git a/tests/pos/T1095B.hs b/tests/pos/T1095B.hs
deleted file mode 100644
--- a/tests/pos/T1095B.hs
+++ /dev/null
@@ -1,59 +0,0 @@
-{-@ LIQUID "--reflection"        @-}
-{-@ LIQUID "--max-case-expand=0" @-}
-
-module T1095B where
-
-data Foo 
-  = A Foo Foo Foo 
-  | B Foo Foo
-  | C Foo
-  | D Foo
-  | E Foo Int 
-  | F Int
-  | G Int
-  | H 
-  | I
-  | J  
-  | K
-  | L
-  | M
-  | N 
-  | X
-    
-{-@  data Foo [size] @-}
-  
-{-@ measure size         @-}
-{-@ size :: z:Foo -> Nat @-}
-size :: Foo -> Int 
-size (A x y z) = 1 + size x + size y + size z 
-size (B x y)   = 1 + size x + size y 
-size (C x)     = 1 + size x 
-size (D x)     = 1 + size x 
-size (E x _)   = 1 + size x 
-size (F _)     = 1 
-size (G _)     = 1 
-size _         = 0 
-
--- with case-expand, the below blows up into a giant
--- function spanning literally thousands of lines!
-{-@ reflect hasX @-}
-hasX :: Foo -> Bool 
-hasX (A X _ _) = True 
-hasX (A _ X _) = True 
-hasX (A _ _ X) = True 
-hasX (B X _)   = True 
-hasX (B _ X)   = True 
-hasX (C X)     = True 
-hasX (D X)     = True 
-hasX (E X _)   = True 
-hasX X         = True 
-hasX _         = False 
-
-foo  :: Foo -> Foo
-foo x | hasX x = X 
-foo (A x y z) = A (foo x) (foo y) (foo z)
-foo (B x y)   = B (foo x) (foo y)
-foo (C x)     = C (foo x)
-foo (D x)     = D (foo x)
-foo (E x i)   = E (foo x) i 
-foo x         = x 
diff --git a/tests/pos/T1095C.hs b/tests/pos/T1095C.hs
deleted file mode 100644
--- a/tests/pos/T1095C.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-{-@ LIQUID "--max-case-expand=0" @-}
-{-@ LIQUID "--no-termination"    @-}
-
-module Foo where
-
-data Foo 
-  = A Foo 
-  | H 
-  | I
-    
-{-@ measure size       @-}
-{-@ size :: z:Foo -> {v:Nat | v = size z} @-}
-size :: Foo -> Int 
-size (A x) = 1 + size x 
-size _     = 0 
diff --git a/tests/pos/T1100.hs b/tests/pos/T1100.hs
deleted file mode 100644
--- a/tests/pos/T1100.hs
+++ /dev/null
@@ -1,40 +0,0 @@
-{-# LANGUAGE ExistentialQuantification, KindSignatures, TypeFamilies, GADTs #-}
-
-module T1100 where
-
-{-@ LIQUID "--exact-data-con"                      @-}
-{-@ LIQUID "--no-adt"                              @-}
-{-@ LIQUID "--higherorder"                         @-}
-{-@ LIQUID "--no-termination"                      @-}
-
-
-class PersistEntity record where
-    data EntityField record :: * -> *
-
-instance PersistEntity Blob where
-  {-@ data EntityField Blob typ where
-          BlobXVal :: EntityField Blob {v:Int | v >= 0}
-        | BlobYVal :: EntityField Blob Int
-    @-}
-    data EntityField Blob typ where
-        BlobXVal :: EntityField Blob Int
-        BlobYVal :: EntityField Blob Int
-
-{-@ data Blob  = B { xVal :: {v:Int | v >= 0}, yVal :: Int } @-}
-data Blob  = B { xVal :: Int, yVal :: Int }
-
-{-@ data UpdateT record typ = Update { updateField :: EntityField record typ, updateValue :: typ } @-}
-data UpdateT record typ = Update
-    { updateField :: EntityField record typ
-    , updateValue :: typ
-    }
-
-{-@ createUpdate :: forall a <p :: a -> Bool>. EntityField record a<p> -> a<p> -> UpdateT record a<p> @-}
-createUpdate :: EntityField record a -> a -> UpdateT record a
-createUpdate field value = Update {
-      updateField = field
-    , updateValue = value
-}
-
-testUpdateQuery :: () -> UpdateT Blob Int
-testUpdateQuery () = createUpdate BlobXVal 3
diff --git a/tests/pos/T1120A.hs b/tests/pos/T1120A.hs
deleted file mode 100644
--- a/tests/pos/T1120A.hs
+++ /dev/null
@@ -1,45 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--no-adt"     @-}
-
-module Bug where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-data U1 p = U1
-data M1 i c f p = M1 { unM1 :: f p }
-data C
-data D
-type C1 = M1 C
-type D1 = M1 D
-
-data MyUnit = MyUnit deriving (Eq)
-
-data A
-data B
-type RepMyUnit = D1 A (C1 B U1)
-
-{-@ reflect fromMyUnit @-}
-fromMyUnit :: MyUnit -> RepMyUnit x_at0x
-fromMyUnit MyUnit = M1 (M1 U1)
-
-{-@ reflect toMyUnit @-}
-toMyUnit :: RepMyUnit x_at0x -> MyUnit
-toMyUnit (M1 (M1 U1)) = MyUnit
-
-{-@ fotMyUnit :: a:RepMyUnit x
-              -> { fromMyUnit (toMyUnit a) == a }
-@-}
-fotMyUnit :: RepMyUnit x_at0x -> Proof
-fotMyUnit z_at0y@(M1 (M1 U1))
-  = ((((fromMyUnit (toMyUnit z_at0y)) === (fromMyUnit MyUnit))
-      === z_at0y)
-      *** QED)
-
-{-@ tofMyUnit :: a:MyUnit
-              -> { toMyUnit (fromMyUnit a) == a }
-@-}
-tofMyUnit :: MyUnit -> Proof
-tofMyUnit z_at0y@MyUnit
-  = ((((toMyUnit (fromMyUnit z_at0y)) === (toMyUnit (M1 (M1 U1))))
-      === z_at0y)
-      *** QED)
diff --git a/tests/pos/T1126.hs b/tests/pos/T1126.hs
deleted file mode 100644
--- a/tests/pos/T1126.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-{-# LANGUAGE FlexibleInstances #-}
-
-module Instances where
-
-class OptEq a where
-  (==.) :: a -> a -> a
-
-instance OptEq a where
-{-@ instance OptEq a where
-      ==. :: x:a -> y:{a| x == y} -> a
-  @-}
-  (==.) x _ = x
-
-class OptEq2 a where
-  cmp :: a -> a -> a
-
-instance OptEq2 a where
-{-@ instance OptEq2 a where
-      cmp :: x:a -> y:{a| x == y} -> a
-  @-}
-  cmp x _ = x
-
-{-@ unsound :: x:Int -> {v:Int | v = x} -> Int @-}
-unsound :: Int -> Int -> Int
-unsound x y = x ==. y
-
-{-@ ok :: x:Int -> {v:Int | v = x} -> Int @-}
-ok :: Int -> Int -> Int
-ok x y = x `cmp` y
diff --git a/tests/pos/T1126a.hs b/tests/pos/T1126a.hs
deleted file mode 100644
--- a/tests/pos/T1126a.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-{-# LANGUAGE FlexibleInstances #-}
-
-module Instances where
-
-class OptEq a where
-  zoo :: a -> a -> a
-
-instance OptEq a where
-  {-@ instance OptEq a where
-	zoo :: x:a -> y:{a | x == y} -> a
-    @-}
-  zoo x _ = x
-
-instance OptEq Int where
-  {-@ instance OptEq Int where
-	zoo :: x:Int -> y:{Int| x == y} -> Int
-    @-}
-  zoo x _ = x
-
diff --git a/tests/pos/T1198.1.hs b/tests/pos/T1198.1.hs
deleted file mode 100644
--- a/tests/pos/T1198.1.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Term where
-
-{-@ data Tree [sz] @-}
-data Tree a =  Bin | Node (Tree a) (Tree a)
-
-{-@ measure sz @-}
-sz :: Tree a -> Int
-sz Bin = 0 
-sz (Node t1 t2) = 1 + sz t1 + sz  t2
diff --git a/tests/pos/T1198.2.hs b/tests/pos/T1198.2.hs
deleted file mode 100644
--- a/tests/pos/T1198.2.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Term where
-
-{-@ data Tree [sz] @-}
-data Tree a =  Bin | Node (Tree a)
-
-{-@ measure sz @-}
-sz :: Tree a -> Int
-sz Bin = 0 
-sz (Node t1) = 1 + sz t1
diff --git a/tests/pos/T1198.3.hs b/tests/pos/T1198.3.hs
deleted file mode 100644
--- a/tests/pos/T1198.3.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Term where
-
-{-@ data Tree [sz] @-}
-data Tree =  Bin | Node Tree Tree 
-
-{-@ measure sz @-}
-sz :: Tree -> Int
-sz Bin = 0 
-sz (Node t1 t2) = 1 + sz t1 + sz t2 
diff --git a/tests/pos/T1198.4.hs b/tests/pos/T1198.4.hs
deleted file mode 100644
--- a/tests/pos/T1198.4.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Term where
-
-{-@ data Tree [sz] @-}
-data Tree a =  Node (Tree a) (Tree a)
-
-{-@ measure sz @-}
-sz :: Tree a -> Int
-sz (Node t1 t2) = 1 + sz  t1 + sz  t2
diff --git a/tests/pos/T1220.hs b/tests/pos/T1220.hs
deleted file mode 100644
--- a/tests/pos/T1220.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-@ LIQUID "--exactdc" @-}
-
-module AB where
-
-{-@ unsafe :: {t : AB | not (isA t)} -> {t /= A}  @-}
-unsafe :: AB -> ()
-unsafe t | isA t = ()
-unsafe _ = ()
-
-{-@ safe :: {t : AB | not (isA t)} -> {not (t == A)}  @-}
-safe :: AB -> ()
-safe t | isA t = ()
-safe _ = ()
-
-{-@ measure isA @-}
-{-@ assume isA :: AB -> Bool @-}
-isA :: AB -> Bool 
-isA A = True
-isA B = False
-
-
-data AB = A | B 
diff --git a/tests/pos/T1223.hs b/tests/pos/T1223.hs
deleted file mode 100644
--- a/tests/pos/T1223.hs
+++ /dev/null
@@ -1,77 +0,0 @@
-{-@ LIQUID "--exactdc" @-}
-{-@ LIQUID "--higherorder" @-}
-{-@ LIQUID "--ple-local" @-}
-{-@ infix   ++ @-}
-
-module Reverse where
-
-import Prelude hiding (reverse, (++))
-
-data Defined = Defined
-infixl 2 ^^^
-x ^^^ Defined = x 
-infixl 3 ==., ? 
-
-x ? _ = x 
-
-(==.) :: a -> a -> a 
-_ ==. x = x 
- 
-
-
-
--------------------------------------------------------------------------------
--- | Specification of reverse' ------------------------------------------------
--------------------------------------------------------------------------------
-
-{-@ specReverse' :: xs:[a] -> ys:[a] -> {reverse' xs ys = reverse xs ++ ys} @-}
-specReverse' :: [a] -> [a] -> ()
-specReverse' _ _ = undefined   
-
--------------------------------------------------------------------------------
--- | Derivation of reverse' ---------------------------------------------------
--------------------------------------------------------------------------------
-
--- LH TODO: LH is not letting you define a measure and a Haskell function
--- with the same name, for now...
-{-@ measure reverse' :: [a] -> [a] -> [a] @-}
-reverse' :: [a] -> [a] -> [a]
-{-@ reverse' :: xs:[a] -> ys:[a] -> { reverse' xs ys = reverse xs ++ ys } @-}
-reverse' [] ys 
-  =   reverse [] ++ ys 
-  ==. [] ++ ys ? specReverse' [] ys 
-  ==. ys 
-  ^^^ Defined 
-
-
-reverse' (x:xs) ys 
-  =   reverse (x:xs) ++ ys  
-  ==. (reverse xs ++ [x]) ++ ys ? specReverse' (x:xs) ys
-  ==. reverse xs ++ ([x] ++ ys) ? assoc (reverse xs) [x] ys
-  ==. reverse xs ++ (x:ys) 
-  ==. reverse' xs (x:ys)
-  ^^^ Defined 
-
--------------------------------------------------------------------------------
--- | Helpers: Definitions & Theorems Used -------------------------------------
--------------------------------------------------------------------------------
-
-{-@ reflect reverse @-}
-reverse :: [a] -> [a]
-reverse []     = []
-reverse (x:xs) = reverse xs ++ [x]
-
-{-@ reflect ++ @-}
-(++) :: [a] -> [a] -> [a]
-[]     ++ ys = ys
-(x:xs) ++ ys = x:(xs ++ ys)
-
-
-{-@ automatic-instances assoc @-}
-{-@ assoc :: xs:[a] -> ys:[a] -> zs:[a] 
-          -> { xs ++ (ys ++ zs) == (xs ++ ys) ++ zs }  @-}
-assoc :: [a] -> [a] -> [a] -> () 
-assoc [] _ _       = ()
-assoc (x:xs) ys zs = assoc xs ys zs
-
-
diff --git a/tests/pos/T1267.hs b/tests/pos/T1267.hs
deleted file mode 100644
--- a/tests/pos/T1267.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-@ LIQUID "--max-case-expand=0" @-}
-{-@ LIQUID "--exactdc" @-}
-
-module NoCaseExpand where
-
-data ABC = A | B | C 
-
-foo :: Int -> ABC -> ()
-foo 0 A  =  ()
-foo x A | x /= 0 = ()
-foo _ A = error " " 
-foo _ t = ()
diff --git a/tests/pos/T1278.2.hs b/tests/pos/T1278.2.hs
deleted file mode 100644
--- a/tests/pos/T1278.2.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-@ LIQUID "--exact-data-cons" @-}
-
-module Term where
-
-{-@ data List [sz] @-}
-data List a = Nil | Cons a (List a)
-
-{-@ measure sz @-}
-sz :: List a -> Int
-sz Nil = 0
-sz (Cons _ Nil) = 1
-sz (Cons _ (Cons _ l)) = 2 + sz l
diff --git a/tests/pos/T1278.3.hs b/tests/pos/T1278.3.hs
deleted file mode 100644
--- a/tests/pos/T1278.3.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Term where
-
-data List a = Nil | Cons a (List a)
-
--- First argument constant
-mymap :: (a -> b) -> List a -> List b
-mymap f Nil = Nil
-mymap f (Cons x xs) = Cons (f x) (mymap f xs)
-
--- Lexicographic
-ack :: List () -> List () -> List ()
-ack Nil n = Cons () n
-ack (Cons () m) Nil = ack m (Cons () Nil)
-ack m'@(Cons () m) (Cons () n) = ack m (ack m' n)
diff --git a/tests/pos/T1278.hs b/tests/pos/T1278.hs
deleted file mode 100644
--- a/tests/pos/T1278.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Term where
-
-data List a = Nil | Cons a (List a)
-
-sz :: List a -> Int
-sz Nil = 0
-sz (Cons _ Nil) = 1
-sz (Cons _ (Cons _ l)) = 2 + sz l
diff --git a/tests/pos/T1286.hs b/tests/pos/T1286.hs
deleted file mode 100644
--- a/tests/pos/T1286.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Example where
-
-{-@ fails :: {v:Bool | v} @-}
-fails =  'a' == 'a'
-
-{-@ ok :: {v:Bool | v} @-}
-ok = "a" == "a"
diff --git a/tests/pos/T1288.hs b/tests/pos/T1288.hs
deleted file mode 100644
--- a/tests/pos/T1288.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-
-module T1288 where
-
-{-@ measure foo @-}
-foo :: () -> Int
-foo _ = 10
-
-{-@ blub :: {v:Int | v = 10} @-}
-blub = foo ()
diff --git a/tests/pos/T1289a.hs b/tests/pos/T1289a.hs
deleted file mode 100644
--- a/tests/pos/T1289a.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-
-module T1289a where
-
-{-@ measure bintId @-}
-bintId :: Int -> Int
-bintId 0 = 0
-bintId x = 1
-
-{-@ zig :: n:Int -> { 0 <= bintId n && bintId n <= 1} @-}
-zig :: Int -> ()  
-zig 0 = () 
-zig n = () 
-
diff --git a/tests/pos/T1302.hs b/tests/pos/T1302.hs
deleted file mode 100644
--- a/tests/pos/T1302.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-{-# LANGUAGE EmptyDataDecls, GADTs, ExistentialQuantification #-}
-
-{-@ LIQUID "--no-adt" 	      @-}
-{-@ LIQUID "--exact-data-con" @-}
-{-@ LIQUID "--higherorder"    @-}
-
-module Field where
-
-data CreditCard = CreditCard { creditCardNumber :: Int, creditCardHolder :: [Char]}
-
-data EntityField a b where
-  CreditCardNumber :: EntityField CreditCard Int
-  CreditCardHolder :: EntityField CreditCard [Char]
-
-------------------------------------------------------------------------------------------
-data RefinedPersistFilter = EQUAL
-
-data RefinedFilter record typ = RefinedFilter
-    { refinedFilterField  :: EntityField record typ
-    , refinedFilterValue  :: typ
-    , refinedFilterFilter :: RefinedPersistFilter
-    } 
-
-{-@ reflect foo @-}
-foo :: RefinedPersistFilter -> Int -> RefinedFilter CreditCard Int
-foo f v = RefinedFilter CreditCardNumber v f
-
-------------------------------------------------------------------------------------------
-
diff --git a/tests/pos/T1336.hs b/tests/pos/T1336.hs
deleted file mode 100644
--- a/tests/pos/T1336.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module T1336 where 
-
-import Data.Ratio 
-
-{-@ embed Ratio * as int @-}
-
--- | You can also write: 
---
---     embed Ratio * as real 
---
---   if for some reason you need to treat the values thus.
-
-{-@ foo :: {v:Ratio Int | v /= 0} -> Bool @-}
-foo :: Ratio Int -> Bool
-foo x = y == y 
-  where 
-    y = 10 / x
diff --git a/tests/pos/T1363.hs b/tests/pos/T1363.hs
deleted file mode 100644
--- a/tests/pos/T1363.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-{-# LANGUAGE BangPatterns #-}
-
-module T1363 where
-
-{-@ LIQUID "--exact-data-cons" @-}
-
-{-@ mySum :: Integer -> xs:[Integer] -> Integer / [len xs] @-}
-mySum :: Integer -> [Integer] -> Integer
-mySum z []     = z
-mySum z (x:xs) = mySum (z + x) xs
-
-{-@ reflect mySum @-}
-
-{-@ mySum' :: Integer -> xs:[Integer] -> Integer / [len xs] @-}
-mySum' :: Integer -> [Integer] -> Integer
-mySum' z []     = z
-mySum' z (x:xs) = let !z' = z + x 
-                  in mySum' z' xs
-
-{-@ reflect mySum' @-}
diff --git a/tests/pos/T1461.hs b/tests/pos/T1461.hs
deleted file mode 100644
--- a/tests/pos/T1461.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-
-module T1461 where
-
-import           Data.List                (sortBy)
-import qualified Data.List.NonEmpty       as NE
-
-foo :: NE.NonEmpty a -> Int
-foo = NE.length
diff --git a/tests/pos/T1498.hs b/tests/pos/T1498.hs
deleted file mode 100644
--- a/tests/pos/T1498.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module T1498 where
-
-class FromTo a where 
-  from :: a -> Int 
-  to   :: Int -> a 
-
-{-@ instance FromTo Int where
-      from :: Int -> {v:Int | 0 <= v };
-      to   :: {v:Int | 0 <= v } -> Int
-@-}
-
-instance FromTo Int where 
-  from x = if 0 <= x then x else -x  
-  to   x = x 
diff --git a/tests/pos/T1543.hs b/tests/pos/T1543.hs
deleted file mode 100644
--- a/tests/pos/T1543.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-module Fixme where
-
-foo :: (Int -> Int) ->  (Int -> Int, ())
-{-@ foo :: f:(Int -> Int) ->  (g::(Int -> Int),{v:() | f == g}) @-}
-foo f = (f,()) 
diff --git a/tests/pos/T1544.hs b/tests/pos/T1544.hs
deleted file mode 100644
--- a/tests/pos/T1544.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-{-@ LIQUID "--reflection"    @-}
-module T1544 where
-
-{-@ data ThingMM = ThingMM {f :: Int -> Int, fprop :: v:Int -> {f v >= 0}} @-}
-data ThingMM =
-  ThingMM
-    { f :: Int -> Int
-    , fprop :: Int -> ()
-    }
-
-{-@ fieldLemmaPat :: t:ThingMM -> v:Int -> {f t v >= 0} @-}
-fieldLemmaPat :: ThingMM -> Int -> ()
-fieldLemmaPat (ThingMM _ fprop) i = const () $ fprop i
-
-{-@ fieldLemmaSel :: t:ThingMM -> v:Int -> {f t v >= 0} @-}
-fieldLemmaSel :: ThingMM -> Int -> ()
-fieldLemmaSel t i = const () $ fprop t i
diff --git a/tests/pos/T1547.hs b/tests/pos/T1547.hs
deleted file mode 100644
--- a/tests/pos/T1547.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-
-module T1547 where
-
-{-@ myfst :: () -> {v:((a,b) -> a) | v == fst } @-}
-myfst :: () -> (a,b) -> a 
-myfst _ = fst 
diff --git a/tests/pos/T1548.hs b/tests/pos/T1548.hs
deleted file mode 100644
--- a/tests/pos/T1548.hs
+++ /dev/null
@@ -1,48 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-
-
-module T1548 where
-
-import Language.Haskell.Liquid.Equational 
-
-
-example :: (b -> d) -> a -> b -> Proof
-{-@ example :: g:(b -> d) -> a:a -> b:b -> { snd (second g (a,b)) == snd (a,g b) } @-}
-example g a b  
-  =   snd (second g (a,b)) 
-  ==. snd (a,g b)
-  *** QED 
-
-hFun :: (b -> d)  -> Proof
-{-@ hFun :: g:(b -> d) -> { snd . second g == g . snd } @-}
-hFun g = extensionality (snd . second g) (g . snd) (h g)
-
-
-h :: (b -> d) -> (a,b) -> Proof
-{-@ h :: g:(b -> d) -> p:(a,b) -> { (snd . second g) (p) == (g . snd) (p) } @-}
-h g p =   (snd . second g) p
-      ==. snd (second g p)
-          ? sndSecond g p
-      ==. g (snd p)
-      ==. (g . snd) p
-      *** QED
-
-
-{-@ reflect second @-}
-second :: (b -> d) -> ((a,b) -> (a,d))
-second g (a,b) = (a, g b)
-
-{-@ sndSecond :: g:(b -> d) -> p:(a,b) -> { snd (second g p) == g (snd p) } @-}
-sndSecond :: (b -> d) -> (a,b) -> Proof
-sndSecond g (a,b)
-  =   snd (second g (a,b))
-  ==. snd (a,g b)
-  ==. g b
-  ==. g (snd (a,b))
-  *** QED
-
-
-
-extensionality :: (a -> b) -> (a -> b) -> (a -> ()) -> ()  
-{-@ assume extensionality :: f:(a -> b) -> g:(a -> b) -> (x:a -> {f x == g x}) ->  {f == g}  @-}
-extensionality _ _ _ = ()
diff --git a/tests/pos/T1550.hs b/tests/pos/T1550.hs
deleted file mode 100644
--- a/tests/pos/T1550.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-
-module Foo where 
-
-import Language.Haskell.Liquid.Equational
-
-{-@ reflect bar @-}
-{-@ reflect foo @-}
-{-@ reflect zoo @-}
-
-bar, foo, zoo :: Int -> Int -> Int 
-
-bar x y = x 
-foo = bar 
-zoo x = bar x 
-
-
-{-@ fooId :: x:Int -> y:Int -> { foo x y = x } @-}
-fooId :: Int -> Int  -> Proof 
-fooId x y = foo x y ==. bar x y ==. x *** QED 
-
-
-{-@ barId :: x:Int -> y:Int -> { bar x y = x } @-}
-barId :: Int -> Int  -> Proof 
-barId x y = bar x y ==. x *** QED 
-
-{-@ zooId :: x:Int -> y:Int -> { bar x y = x } @-}
-zooId :: Int -> Int  -> Proof 
-zooId x y = zoo x y ==. bar x y ==. x *** QED 
diff --git a/tests/pos/T1555.hs b/tests/pos/T1555.hs
deleted file mode 100644
--- a/tests/pos/T1555.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--rankNTypes" @-}
-{-# LANGUAGE RankNTypes   #-}
-
-module Theorems where
-
-import Language.Haskell.Liquid.Equational 
-
-type ForAll a  = forall z. a
-data Wrapper a = Wrapper (ForAll a)
- 
-foo :: ForAll a -> ForAll a  -> Proof
-{-@ foo :: ff:ForAll a -> gg:{ForAll a | ff == gg } -> { Wrapper ff == Wrapper gg } @-} 
-foo g f = Wrapper g ==. Wrapper f *** QED 
diff --git a/tests/pos/T1556.hs b/tests/pos/T1556.hs
deleted file mode 100644
--- a/tests/pos/T1556.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Foo where 
-
-{-@ type Alias a b = (a,b) @-}
-type Alias a b = (a,b)
-
-{-@ foo :: Alias (a,b) a @-}
-foo ::  Alias (a,b) a
-foo = undefined 
diff --git a/tests/pos/T1560.hs b/tests/pos/T1560.hs
deleted file mode 100644
--- a/tests/pos/T1560.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-{-@ LIQUID "--ple"        @-}
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--extensionality" @-}
-
-module T1560 where 
-
-k :: a -> b -> b
-k _ b = b
-
-{-@ reflect f @-}
-f :: Int -> Int -> Int
-f x y = x + y
-
-{-@ reflect g @-}
-g :: Int -> Int -> Int
-g = f
-
-{-@ fgeqxy :: x:Int -> y:Int -> {f x y = g x y} @-}
-fgeqxy :: Int -> Int -> ()
-fgeqxy x y = g x y `k` f x y `k` ()
-
-{-@ fgeqx :: x:Int -> {f x = g x} @-}
-fgeqx :: Int -> ()
-fgeqx x = f x `k` g x `k` ()
-
-{-@ fgeq :: {f = g} @-}
-fgeq :: ()
-fgeq = f `k` g `k` ()
diff --git a/tests/pos/T1560B.hs b/tests/pos/T1560B.hs
deleted file mode 100644
--- a/tests/pos/T1560B.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-{-@ LIQUID "--ple"        @-}
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--extensionality" @-}
-
-module T1560 where 
-
-k :: a -> b -> b
-k _ b = b
-
-{-@ reflect f @-}
-f :: Int -> Int
-f x = x + 1
-
-{-@ reflect g @-}
-g :: Int -> Int -> Int
-g x = f
-
-{-@ fgeqxy :: x:Int -> y:Int -> {f y = g x y} @-}
-fgeqxy :: Int -> Int -> ()
-fgeqxy x y = g x y `k` f y `k` ()
-
-{-@ fgeqx :: x:Int -> {f = g x} @-}
-fgeqx :: Int -> ()
-fgeqx x = f `k` g x `k` ()
diff --git a/tests/pos/T1567.hs b/tests/pos/T1567.hs
deleted file mode 100644
--- a/tests/pos/T1567.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-# LANGUAGE RankNTypes    #-}
-{-# LANGUAGE TypeOperators #-}
-
-module T1567 where
-
- {-@ infixr 1 ==> @-} 
- infixr 1 ==> 
- type f ==> g = forall z. f z -> g z 
-  
-
-
- test ::  (f ==> g) -> f x -> f y -> ()
- {-@ test :: g:(f ==> g) -> f x -> f y -> ()  @-} 
- test _ _ _ = () 
diff --git a/tests/pos/T1568.hs b/tests/pos/T1568.hs
deleted file mode 100644
--- a/tests/pos/T1568.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module MalformedTypeclass where
-
-    {-@ data IdentityT m a = IdentityT (m a) @-}
-    data IdentityT m a = IdentityT (m a)
-    
-    class MyMonad m where
-      myReturn :: a -> m a
-    
-    {-@
-    instance MyMonad (IdentityT m) where
-      myReturn :: a -> IdentityT m a
-    @-}
-    instance MyMonad (IdentityT m) where
-      myReturn = undefined
-    
-    -- When using the real Monad class the error doesn't happen until return is
-    -- actually used for some reason
-    {-@ testMyReturn :: a -> IdentityT m a @-}
-    testMyReturn :: a -> IdentityT m a
-    testMyReturn x = myReturn x
diff --git a/tests/pos/T1571.hs b/tests/pos/T1571.hs
deleted file mode 100644
--- a/tests/pos/T1571.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module MalformedTypeclass where
-
-  data TaggedT m a = TaggedT (m a)
-  
-  class MonadController m where
-    respond :: a -> m ()
-  
-  {-@
-  instance MonadController m => MonadController (TaggedT m) where
-    respond :: a -> TaggedT m ()
-  @-}
-  instance MonadController m => MonadController (TaggedT m) where
-    respond = undefined
diff --git a/tests/pos/T1577.hs b/tests/pos/T1577.hs
deleted file mode 100644
--- a/tests/pos/T1577.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--extensionality" @-}
-{-@ LIQUID "--ple"            @-}
-
-module T1577 where 
-
--- | 1 . ints
-
-{-@ reflect plus1 @-}
-{-@ reflect plus1' @-}
-plus1, plus1' :: Int -> Int 
-plus1 x = x + 1 
-plus1' x = 1 + x
-
-{-@ thm1 :: () -> { plus1' == plus1 } @-}
-thm1 :: () -> ()
-thm1 _ = () 
-
-{-@ reflect first @-}
-first :: (a -> b) -> (a, c) -> (b, c)
-first f (x,y) = (f x, y)
-
--- | 2. compose
-
-{-@ thm2 :: f:(a -> b) -> g:(b -> c) -> { (first g) . (first f) == first (g . f) } @-}
-thm2 :: (a -> b) -> (b -> c) -> ()
-thm2 _ _ = ()
-
--- | 3. imply 
-
-{-@ thm3 :: f:(a -> b) -> g:(a -> b) -> { first f == first g => f == g } @-}
-thm3 :: (a -> b) -> (a -> b) -> ()
-thm3 _ _ = ()
diff --git a/tests/pos/T1593.hs b/tests/pos/T1593.hs
deleted file mode 100644
--- a/tests/pos/T1593.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-
-module T1593 where
-
-{-@ LIQUID "--reflection"     @-}
-
--- not ok
-data Thing0 m = Thing
-  { t0 :: (m Int -> Int) -> Int
-  }
-
--- not ok
-data Thing1 m = Thing1
-  { t1 :: (Int -> m Int) -> Int
-  }
-
--- ok
-data Thing2 m = Thing2
-  { t2 :: Int -> m Int -> Int
-  }
diff --git a/tests/pos/T1595.hs b/tests/pos/T1595.hs
deleted file mode 100644
--- a/tests/pos/T1595.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-
-module T1595 where
-
-{-@ LIQUID "--reflection" @-}
-
-data Map k v = Tip | Map k v (Map k v)
-
-{-@ reflect mapEmpty @-}
-mapEmpty :: Map k v 
-mapEmpty = Tip 
-
-
-{-@
-data MultiSet a = MultiSet {
-    posMultiSet :: Map a {v:Integer | v > 0 }
-  }
-@-}
-data MultiSet a = MultiSet {
-    posMultiSet :: Map a Integer -- ^ Map for elements currently in the set.
-  }
-
-
-{-@ empty :: MultiSet a @-}
-empty :: MultiSet a
-empty = MultiSet mapEmpty
diff --git a/tests/pos/T1597.hs b/tests/pos/T1597.hs
deleted file mode 100644
--- a/tests/pos/T1597.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-
-module T1597 where
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-
-{-@ reflect plus @-}
-plus :: Double -> Double -> Double
-plus x y = x + y
-
-{-@ reflect rdiv @-}
-{-@ rdiv :: Double -> {v:Double | v /= 0 } -> Double @-}
-rdiv :: Double -> Double -> Double 
-rdiv x y = x / y
diff --git a/tests/pos/T1603.hs b/tests/pos/T1603.hs
deleted file mode 100644
--- a/tests/pos/T1603.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-@ LIQUID "--reflect" @-}
-
-module T1603 where
-
-{-@ reflect rAnd @-}
-rAnd :: Bool
-rAnd = and [True,False,True]
-
-{-@ reflect rOr @-}
-rOr :: Bool
-rOr = or [True,False,True]
-
diff --git a/tests/pos/T1633.hs b/tests/pos/T1633.hs
deleted file mode 100644
--- a/tests/pos/T1633.hs
+++ /dev/null
@@ -1,32 +0,0 @@
-{-# LANGUAGE GADTs               #-}
-{-# LANGUAGE DeriveAnyClass      #-}
-{-@ LIQUID "--max-case-expand=0" @-}
-{-@ LIQUID "--no-totality"       @-}
-
-module T1633 where
-
-import Data.Void
-
-data Relation a b where
-  Empty :: Relation Void Void
-  One :: Int -> Relation () ()
-  Join :: Relation c b -> Relation d b -> Relation (Either c d) b
-  Fork :: Relation a c -> Relation a d -> Relation a (Either c d)
-  deriving (Num)
--- Here I use a type 'Natural 0 1' but I wanted to try and refine the GADT.
-{-@
-data Relation a b where
-  Empty :: Relation Void Void
-  | One :: {v:Int | v = 0 || v = 1} -> Relation () ()
-  | Join :: Relation c b -> Relation d b -> Relation (Either c d) b
-  | Fork :: Relation a c -> Relation a d -> Relation a (Either c d)
-@-}
-
--- (Eq, Num, Ord, etc.. instances ...)
-
-comp :: Relation b c -> Relation a b -> Relation a c
-comp Empty Empty           = Empty
-comp (One a) (One b)       = One (a * b)
-comp (Join a b) (Fork c d) = comp a c + comp b d         -- Divide-and-conquer law
-comp (Fork a b) c          = Fork (comp a c) (comp b c) -- Fork fusion law
-comp c (Join a b)          = Join (comp c a) (comp c b)  -- Join fusion law
diff --git a/tests/pos/T1634.hs b/tests/pos/T1634.hs
deleted file mode 100644
--- a/tests/pos/T1634.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-{-@ LIQUID "--ple"        @-} 
-
-module Readers where
-
-import Language.Haskell.Liquid.ProofCombinators 
-type Reader a b = a -> b
-
-data EqT a = EqSMT a a  
-   
-{-@ assume eqSMT :: x:a -> y:{a | x == y } ->  EqT a @-}
-eqSMT :: a -> a -> EqT a
-eqSMT = EqSMT
-
-{-@ reflect fmapReader @-}
-fmapReader :: (a -> b) -> (r -> a) -> (Reader r b)
-fmapReader fab fra r = fab (fra r)
-
-{-@ reflect myid @-}
-myid :: a -> a 
-myid x = x 
-
-helper2 :: Reader r a -> r -> EqT a
-helper2 r a = eqSMT (fmapReader myid r a) (myid (r a))
-
diff --git a/tests/pos/T1636.hs b/tests/pos/T1636.hs
deleted file mode 100644
--- a/tests/pos/T1636.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple"        @-}
-
-module Qualify where 
-
-data RA a  = RA  
-
-
-{-@ type RRA a E1 E2 = {v:RA a | E1 == E2} @-}
-
-
-{-@ assume eqRTCtx :: f:a -> g:a  -> RRA a {f} {g} -> ctx:(a -> b) -> RRA b {ctx f} {ctx g}  @-}
-eqRTCtx ::  a -> a -> RA a -> (a -> b) -> RA b
-eqRTCtx _f _g _pf _ctx = undefined  
-
-fEqG0BadDomain :: Integer -> RA Integer
-fEqG0BadDomain x = RA
-
-{-@ reflect f @-}
-f :: Integer -> Integer 
-f x = x + 1 
-
-{-@ reflect g @-}
-g :: Integer -> Integer 
-g x = x + 1 
diff --git a/tests/pos/T1642.hs b/tests/pos/T1642.hs
deleted file mode 100644
--- a/tests/pos/T1642.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-{-# LANGUAGE GADTs          #-}
-{-# LANGUAGE KindSignatures #-}
-
-module Foo where 
- 
-data A  :: * -> *  where 
-   A  :: Eq a => a -> () -> A a 
- 
diff --git a/tests/pos/T1642A.hs b/tests/pos/T1642A.hs
deleted file mode 100644
--- a/tests/pos/T1642A.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-
-{-# LANGUAGE RankNTypes     #-}
-{-# LANGUAGE GADTs          #-}
-{-# LANGUAGE KindSignatures #-}
-
-module RefinedEquality where 
-
-
-{-@ measure eqT :: a -> a -> Bool @-}
-{-@ type EqRT a E1 E2 = {v:EqT a | eqT E1 E2} @-}
-
-{-@ eqFun :: f:(a -> b) -> g:(a -> b) 
-          -> (x:a -> {v:EqT b | eqT (f x) (g x)}) -> EqRT (a -> b) {f} {g}  @-}
-eqFun :: (a -> b) -> (a -> b) -> (a -> EqT b) -> EqT (a -> b)
-eqFun = EqFun
-
-
-{-@ eqSMT :: Eq a => x:a -> y:a -> {v:() | x == y} -> EqRT a {x} {y} @-}
-eqSMT :: Eq a => a -> a -> () -> EqT a
-eqSMT = EqSMT 
-
-{-@
-data EqT :: * -> * where 
-   EqSMT  :: Eq a => x:a -> y:a -> {v:() | x == y} -> EqRT a {x} {y}   
- | EqFun  :: f:(a -> b) -> g:(a -> b) -> (x:a -> {v:EqT b | eqT (f x) (g x)}) -> EqRT (a -> b) {f} {g}
-@-}
-
-data EqT :: * -> *  where 
-   EqSMT  :: Eq a => a -> a -> () -> EqT a   
-   EqFun  :: (a -> b) -> (a -> b) -> (a -> EqT b) -> EqT (a -> b)  
diff --git a/tests/pos/T1647.hs b/tests/pos/T1647.hs
deleted file mode 100644
--- a/tests/pos/T1647.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-# LANGUAGE GADTs        #-}
-{-@ LIQUID "--reflection" @-} 
-{-@ LIQUID "--no-adt"     @-} 
-
-module Properties where 
-
-{-@ type ExtTR a E1 E2 = {v:ExtT a | E1 == E2 } @-}
-
-data ExtT b  where 
-   ExtT  :: (a -> b) -> ExtT b 
-
-{-@ data ExtT b where 
-    ExtT  :: (a -> b) -> ExtT b 
-@-}   
-
-prop :: a -> a -> ExtT a -> ExtT a
-{-@ prop :: x:a -> y:a-> ExtTR a {x} {y} -> ExtTR a {x} {y} @-}
-prop f g (ExtT ctx) = ExtT ctx   
diff --git a/tests/pos/T1649MeasuresDef.hs b/tests/pos/T1649MeasuresDef.hs
deleted file mode 100644
--- a/tests/pos/T1649MeasuresDef.hs
+++ /dev/null
@@ -1,52 +0,0 @@
-{-# LANGUAGE RankNTypes      #-}
-{-# LANGUAGE GADTs           #-}
-{-# LANGUAGE KindSignatures  #-}
-{-@ LIQUID "--reflection" @-} 
--- Z3 encoding cannot be used until this is fixed: 
--- https://github.com/Z3Prover/z3/issues/3930
-{-@ LIQUID "--no-adt"         @-} 
-{-@ LIQUID "--ple-local"      @-} 
-{-@ LIQUID "--prune-unsorted" @-} 
-
-module Properties where 
-
-
-
-{-@ assume injectiveEqRTFun :: x:(a->b) -> y:(a->b) -> d:{EqRT (a->b) {x} {y} | isEqFun d} 
-                         -> {x = eqFunX d && y = eqFunY d} @-}
-injectiveEqRTFun :: (a->b) -> (a->b) -> EqT (a->b) -> () 
-injectiveEqRTFun _ _ _ = () 
-
-
-{-@ measure isEqFun @-}
-isEqFun :: EqT a -> Bool 
-isEqFun (EqFun _ _ _) = True 
-isEqFun _             = False 
-
-{-@ reflect eqFunX @-}
-{-@ eqFunX :: {d:EqT (a -> b) | isEqFun d} -> (a -> b) @-}
-eqFunX :: EqT (a -> b) ->  (a -> b) 
-eqFunX (EqFun x _ _) = x 
-
-{-@ reflect eqFunY @-}
-{-@ eqFunY :: {d:EqT (a -> b) | isEqFun d} -> (a -> b) @-}
-eqFunY :: EqT (a -> b) ->  (a -> b) 
-eqFunY (EqFun _ y _) = y 
-
-
-{-@ ple     eqFunP @-}
-{-@ reflect eqFunP @-}
-{-@ eqFunP :: d:{EqT (a -> b) | isEqFun d} -> (x:a -> EqRT b {eqFunX d x} {eqFunY d x}) @-}
-eqFunP :: EqT (a -> b) ->  (a -> EqT b) 
-eqFunP (EqFun _ _ p) = p
-
-
-data EqT  :: * -> *  where 
-   EqFun  :: (a -> b) -> (a -> b) -> (a -> EqT b) -> EqT (a -> b)
-
-{-@ data EqT  :: * -> *  where 
-     EqFun  :: ff:(a -> b) -> gg:(a -> b) -> (x:a -> EqRT b {ff x} {gg x}) -> EqRT (a -> b) {ff} {gg}
-@-}   
-
-
-{-@ type EqRT a E1 E2 = {v:EqT a | E1 = E2} @-}
diff --git a/tests/pos/T1649WorkTypes.hs b/tests/pos/T1649WorkTypes.hs
deleted file mode 100644
--- a/tests/pos/T1649WorkTypes.hs
+++ /dev/null
@@ -1,62 +0,0 @@
-{-# LANGUAGE RankNTypes      #-}
-{-# LANGUAGE GADTs           #-}
-{-# LANGUAGE KindSignatures  #-}
-{-@ LIQUID "--reflection" @-} 
--- Z3 encoding cannot be used until this is fixed: 
--- https://github.com/Z3Prover/z3/issues/3930
-{- LIQUID "--no-adt"         @-} 
-{-@ LIQUID "--ple-local"      @-} 
-
-module Properties where 
-
-
-{-@ assume injectiveEqRTFun :: x:(a->b) -> y:(a->b) -> d:{EqRT (a->b) {x} {y} | isEqFun d} 
-                         -> {x = eqFunX d && y = eqFunY d} @-}
-injectiveEqRTFun :: (a->b) -> (a->b) -> EqT (a->b) -> () 
-injectiveEqRTFun _ _ _ = () 
-
-{-@ measure isEqFun @-}
-isEqFun :: EqT a -> Bool 
-isEqFun (EqFun _ _ _) = True 
-isEqFun _             = False 
-
-{-@ reflect eqFunX @-}
-{-@ eqFunX :: {d:EqT (a -> b) | isEqFun d} -> (a -> b) @-}
-eqFunX :: EqT (a -> b) ->  (a -> b) 
-eqFunX (EqFun x _ _) = x 
-
-{-@ reflect eqFunY @-}
-{-@ eqFunY :: {d:EqT (a -> b) | isEqFun d} -> (a -> b) @-}
-eqFunY :: EqT (a -> b) ->  (a -> b) 
-eqFunY (EqFun _ y _) = y 
-
-
-{-@ ple     eqFunP @-}
-{- reflect eqFunP @-}
--- STATUS: assertion passes, but result type still fails 
-{-@ eqFunP :: d:{EqT (a -> b) | isEqFun d} -> x:a -> EqT b @-}
-eqFunP :: EqT (a -> b) ->  a -> EqT b
-eqFunP (EqFun f g p) x = assert (eqT (f x) (g x)) (p x)  
-
-
-assert :: Bool -> a -> a 
-{-@ assert :: {b:Bool | b} -> x:a -> {v:a | v == x && b} @-}
-assert _ x = x 
-
-{-@ assume eqT :: x:a -> y:a -> {v:Bool | v <=> eqT x y} @-}
-eqT :: a -> a -> Bool 
-eqT = undefined 
-
-
-{-@ measure eqT :: a -> a -> Bool @-}
-{-@ type EqRT a E1 E2 = {v:EqT a | eqT E1 E2} @-}
-
-
-data EqT  :: * -> *  where 
-   EqSMT  :: Eq a => a -> a -> (a -> [a]) -> EqT a 
-   EqFun  :: (a -> b) -> (a -> b) -> (a -> EqT b) -> EqT (a -> b)
-
-{-@ data EqT  :: * -> *  where 
-        EqSMT  :: Eq a => x:a -> y:a -> (a -> {v:[a] | 0 < len v}) -> EqRT a {x} {y}
-      | EqFun  :: ff:(a -> b) -> gg:(a -> b) -> (x:a -> {d:EqT b | eqT (ff x) (gg x)}) -> EqRT (a -> b) {ff} {gg}
-@-}   
diff --git a/tests/pos/T1657.hs b/tests/pos/T1657.hs
deleted file mode 100644
--- a/tests/pos/T1657.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-
-module T1657 where
-
-{-@ data I <pigbert :: Int -> Bool> = I Int @-}
-
-data I = I Int
-{-@ getI :: forall <pp :: Int -> Bool>. 
-             { bloop :: Int <pp> |- {v: Int | v = bloop} <: {v:Int | v > 1984} }
-             I <pp>
-@-}
-getI :: I
-getI = undefined 
-
-{-@ pleaseFail :: I<{\v -> v > 1984}> @-}
-pleaseFail :: I
-pleaseFail = getI
diff --git a/tests/pos/T1660.hs b/tests/pos/T1660.hs
deleted file mode 100644
--- a/tests/pos/T1660.hs
+++ /dev/null
@@ -1,49 +0,0 @@
-{-# LANGUAGE RankNTypes      #-}
-{-# LANGUAGE GADTs           #-}
-{-# LANGUAGE KindSignatures  #-}
-
-{-@ LIQUID "--reflection"  @-} 
-{-@ LIQUID "--ple"         @-}
-{-@ LIQUID "--fast"        @-}
-{-@ LIQUID "--no-adt"      @-} 
-
-module Readers where
-
-import Language.Haskell.Liquid.ProofCombinators
-import Prelude hiding (id, fmap)
-
-{-@ measure eqT :: a -> a -> Bool @-}
-{-@ type EqRT a E1 E2 = {v:EqT a | eqT E1 E2} @-}
-
-data EqT  :: * -> *  where 
-   EqSMT  :: Eq a => a -> a -> () -> EqT a 
-   EqFun  :: (a -> b) -> (a -> b) -> (a -> EqT b) -> EqT (a -> b)
-
-{-@ data EqT  :: * -> *  where 
-       EqSMT  :: Eq a => x:a -> y:a -> {v:() | x == y} -> EqRT a {x} {y}
-     | EqFun  :: ff:(a -> b) -> gg:(a -> b) -> (x:a -> {v:EqT b | eqT (ff x) (gg x)}) -> EqRT (a -> b) {ff} {gg}
-@-}   
-
-
-type Reader a b = a -> b
-
-
-
-functorLaw_identity :: Eq a => EqT (Reader r a -> Reader r a)
-{-@ functorLaw_identity :: Eq a -> EqRT (Reader r a -> Reader r a) (fmap id) id @-}
-functorLaw_identity =
-  EqFun (fmap id) id
-  (\r -> EqFun (fmap id r) (id r)
-    (\a -> EqSMT (fmap id r a) (id r a? lemmaId r a) ()))
-
-{-@ reflect id @-}
-id :: a -> a 
-id x = x
-
-{-@ reflect fmap @-}
-fmap :: (a -> b) -> Reader r a -> Reader r b
-fmap fab fra = \r -> fab (fra r)
-
-lemmaId :: Eq b => (a -> b) -> a -> ()
-{-@ lemmaId :: f:(a -> b) -> x:a -> {id f x = id (f x) } @-}
-lemmaId _ _ = ()
diff --git a/tests/pos/T1669.hs b/tests/pos/T1669.hs
deleted file mode 100644
--- a/tests/pos/T1669.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-{-@ LIQUID "--no-totality" @-}
-
-module A where
-import           Prelude                 hiding ( Semigroup
-                                                , mappend
-                                                )
-
-data PNat = Z | S PNat
-
-{-@ data Semigroup a = CSemigroup {mappend :: a -> a -> a} @-}
-data Semigroup a = CSemigroup {mappend :: a -> a -> a}
-
-{-@ reflect cmappend  @-}
-cmappend :: PNat -> PNat -> PNat
-cmappend Z     n = n
-cmappend (S m) n = S (cmappend m n)
-
-{-@ reflect semigroupPNat  @-}
-semigroupPNat :: Semigroup PNat
-semigroupPNat = CSemigroup cmappend
-
-
-{-@ clawAssociative :: v:PNat -> v':PNat -> v'':PNat  
-      -> { mappend semigroupPNat (mappend semigroupPNat v v') v'' == mappend semigroupPNat v (mappend semigroupPNat v' v'')}@-}
-clawAssociative :: PNat -> PNat -> PNat -> ()
-clawAssociative Z     _ _ = ()
--- clawAssociative (S p) m n = clawAssociative p m n
diff --git a/tests/pos/T1670A.hs b/tests/pos/T1670A.hs
deleted file mode 100644
--- a/tests/pos/T1670A.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{-# LANGUAGE TypeFamilies #-}
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-
-module B where
-
-data LWW t a = LWW {
-    lwwTime  :: t
-  , lwwValue :: a
-  }
-
-{-@ reflect cenabledLWW @-}
-cenabledLWW :: Ord t => LWW t a -> LWW t a -> Bool
-cenabledLWW (LWW t1 _) (LWW t2 _) = t1 /= t2
-
-
-{-@ reflect capplyLWW @-}
-capplyLWW :: Ord t => LWW t a -> LWW t a -> LWW t a
-capplyLWW l1@(LWW t1 _) l2@(LWW t2 _) 
-     | t1 > t2   = l1
-     | otherwise = l2
-
-{-@ clawCommutativityLWW :: Ord t => x : (LWW t a) -> op1 : LWW t a -> op2 : LWW t a -> {(cenabledLWW x op1 && cenabledLWW x op2  && cenabledLWW (capplyLWW x op1) op2 && cenabledLWW (capplyLWW x op2) op1) => capplyLWW (capplyLWW x op1) op2 == capplyLWW (capplyLWW x op2) op1} @-}
-clawCommutativityLWW :: Ord t => LWW t a -> LWW t a -> LWW t a -> ()
-clawCommutativityLWW x@(LWW t0 v0) op1@(LWW t1 v1) op2@(LWW t2 v2) = ()
diff --git a/tests/pos/T1670B.hs b/tests/pos/T1670B.hs
deleted file mode 100644
--- a/tests/pos/T1670B.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-{-# LANGUAGE TypeFamilies #-}
-
-{-@ LIQUID "--reflection" @-}
-{-@ LIQUID "--ple" @-}
-
-module B where
-
-data LWW t a = LWW {
-    lwwTime  :: t
-  , lwwValue :: a
-  }
-
-type family Operation t
-
-type instance Operation (LWW t a) = LWW t a
-
-{-@ reflect cenabledLWW @-}
-cenabledLWW :: Ord t => LWW t a -> Operation (LWW t a) -> Bool
-cenabledLWW (LWW t1 _) (LWW t2 _) = t1 /= t2
-
-
-{-@ reflect capplyLWW @-}
-capplyLWW :: Ord t => LWW t a -> Operation (LWW t a) -> LWW t a
-capplyLWW l1@(LWW t1 _) l2@(LWW t2 _) 
-     | t1 > t2   = l1
-     | otherwise = l2
-
-{-@ clawCommutativityLWW :: Ord t => x : (LWW t a) -> op1 : Operation (LWW t a) -> op2 : Operation (LWW t a) -> {(cenabledLWW x op1 && cenabledLWW x op2  && cenabledLWW (capplyLWW x op1) op2 && cenabledLWW (capplyLWW x op2) op1) => capplyLWW (capplyLWW x op1) op2 == capplyLWW (capplyLWW x op2) op1} @-}
-clawCommutativityLWW :: Ord t => LWW t a -> Operation (LWW t a) -> Operation (LWW t a) -> ()
-clawCommutativityLWW x@(LWW t0 v0) op1@(LWW t1 v1) op2@(LWW t2 v2) = ()
diff --git a/tests/pos/T1697.hs b/tests/pos/T1697.hs
deleted file mode 100644
--- a/tests/pos/T1697.hs
+++ /dev/null
@@ -1,58 +0,0 @@
-{-@ LIQUID "--no-pattern-inline" @-}
-
-module B where
-
-data User = U
-
-{-@ measure currentUser :: User @-}
-
-{-@ data TaggedT user m a <label :: user -> Bool, clear :: user -> Bool> = TaggedT _ @-}
-data TaggedT user m a = TaggedT { unTag :: m a }
-{-@ data variance TaggedT invariant invariant covariant contravariant covariant @-}
-
-instance Functor m => Functor (TaggedT user m) where
-  fmap f = TaggedT . fmap f . unTag
-
-instance Applicative m => Applicative (TaggedT user m) where
-  pure = TaggedT . pure
-  f <*> x = TaggedT $ unTag f <*> unTag x
-
-{-@
-instance Monad m => Monad (TaggedT user m) where
-  >>= :: forall < p :: user -> Bool
-                , q :: user -> Bool
-                , r :: user -> Bool
-                , s :: user -> Bool
-                , t :: user -> Bool
-                , u :: user -> Bool
-                , rx :: a -> Bool
-                , rf :: a -> b -> Bool
-                , ro :: b -> Bool
-                >.
-    {content :: a<rx> |- b<rf content> <: b<ro>}
-    {content :: a<rx> |- b<ro> <: b<rf content>}
-    {{v : (user<s>) | True} <: {v : (user<p>) | True}}
-    {{v : (user<t>) | True} <: {v : (user<p>) | True}}
-    {{v : (user<t>) | True} <: {v : (user<r>) | True}}
-    {{v : (user<q>) | True} <: {v : (user<u>) | True}}
-    {{v : (user<s>) | True} <: {v : (user<u>) | True}}
-    x:TaggedT<p, q> user m (a<rx>)
-    -> (y:a -> TaggedT<r, s> user m (b<rf y>))
-    -> TaggedT<t, u> user m (b<ro>);
-
-  return :: a -> TaggedT<{\_ -> True}, {\_ -> False}> user m a
-@-}
-instance Monad m =>  Monad (TaggedT user m) where
-  x >>= f = TaggedT $ unTag x >>= \y -> unTag (f y)
-  
--------------------------------------------------------------------------------------------
--- | Test
--------------------------------------------------------------------------------------------
-
-{-@ assume respondT :: String -> TaggedT<{\_ -> True}, {\v -> v == currentUser}> User m () @-}
-respondT :: String -> TaggedT User m ()
-respondT = undefined
-
-{-@ test :: TaggedT<{\_ -> True}, {\v -> v == currentUser}> User m () @-}
-test :: Monad m => TaggedT User m ()
-test = return "a" >>= respondT
diff --git a/tests/pos/T1697A.hs b/tests/pos/T1697A.hs
deleted file mode 100644
--- a/tests/pos/T1697A.hs
+++ /dev/null
@@ -1,60 +0,0 @@
--------------------------------------------------------------------------------------------
--- | Fixed User (WORKING)
--------------------------------------------------------------------------------------------
-
-module A where
-
-data User = U
-
-{-@ measure currentUser :: User @-}
-
-{-@ data TaggedT m a <label :: User -> Bool, clear :: User -> Bool> = TaggedT _ @-}
-data TaggedT m a = TaggedT { unTag :: m a }
-{-@ data variance TaggedT invariant covariant contravariant covariant @-}
-
-instance Functor m => Functor (TaggedT m) where
-  fmap f = TaggedT . fmap f . unTag
-
-instance Applicative m => Applicative (TaggedT m) where
-  pure = TaggedT . pure
-  f <*> x = TaggedT $ unTag f <*> unTag x
-
-{-@
-instance Monad m => Monad (TaggedT m) where
-  >>= :: forall < p :: User -> Bool
-                , q :: User -> Bool
-                , r :: User -> Bool
-                , s :: User -> Bool
-                , t :: User -> Bool
-                , u :: User -> Bool
-                , rx :: a -> Bool
-                , rf :: a -> b -> Bool
-                , ro :: b -> Bool
-                >.
-    {content :: a<rx> |- b<rf content> <: b<ro>}
-    {content :: a<rx> |- b<ro> <: b<rf content>}
-    {{v : (User<s>) | True} <: {v : (User<p>) | True}}
-    {{v : (User<t>) | True} <: {v : (User<p>) | True}}
-    {{v : (User<t>) | True} <: {v : (User<r>) | True}}
-    {{v : (User<q>) | True} <: {v : (User<u>) | True}}
-    {{v : (User<s>) | True} <: {v : (User<u>) | True}}
-    x:TaggedT<p, q> m (a<rx>)
-    -> (y:a -> TaggedT<r, s> m (b<rf y>))
-    -> TaggedT<t, u> m (b<ro>);
-
-  return :: a -> TaggedT<{\_ -> True}, {\_ -> False}> m a
-@-}
-instance Monad m => Monad (TaggedT m) where
-  x >>= f = TaggedT $ unTag x >>= \y -> unTag (f y)
-  
--------------------------------------------------------------------------------------------
--- | Test
--------------------------------------------------------------------------------------------
-
-{-@ assume respondT :: String -> TaggedT<{\_ -> True}, {\v -> v == currentUser}> m () @-}
-respondT :: String -> TaggedT m ()
-respondT = undefined
-
-{-@ test :: TaggedT<{\_ -> True}, {\v -> v == currentUser}> m () @-}
-test :: Monad m => TaggedT m ()
-test = return "a" >>= respondT
diff --git a/tests/pos/T1697C.hs b/tests/pos/T1697C.hs
deleted file mode 100644
--- a/tests/pos/T1697C.hs
+++ /dev/null
@@ -1,54 +0,0 @@
--------------------------------------------------------------------------------------------
--- | Polymorphic user but defining bind and return as normal functions (WORKING)
--------------------------------------------------------------------------------------------
-
-module C where
-
-data User = U
-
-{-@ measure currentUser :: User @-}
-
-{-@ data TaggedT user m a <label :: user -> Bool, clear :: user -> Bool> = TaggedT _ @-}
-data TaggedT user m a = TaggedT { unTag :: m a }
-{-@ data variance TaggedT invariant invariant covariant contravariant covariant @-}
-
-{-@
-assume bindT :: forall < p :: user -> Bool
-                       , q :: user -> Bool
-                       , r :: user -> Bool
-                       , s :: user -> Bool
-                       , t :: user -> Bool
-                       , u :: user -> Bool
-                       , rx :: a -> Bool
-                       , rf :: a -> b -> Bool
-                       , ro :: b -> Bool
-                       >.
-    {content :: a<rx> |- b<rf content> <: b<ro>}
-    {content :: a<rx> |- b<ro> <: b<rf content>}
-    {{v : (user<s>) | True} <: {v : (user<p>) | True}}
-    {{v : (user<t>) | True} <: {v : (user<p>) | True}}
-    {{v : (user<t>) | True} <: {v : (user<r>) | True}}
-    {{v : (user<q>) | True} <: {v : (user<u>) | True}}
-    {{v : (user<s>) | True} <: {v : (user<u>) | True}}
-    x:TaggedT<p, q> user m (a<rx>)
-    -> (y:a -> TaggedT<r, s> user m (b<rf y>))
-    -> TaggedT<t, u> user m (b<ro>)
-@-}
-bindT :: Monad m => TaggedT user m a -> (a -> TaggedT user m b) -> TaggedT user m b
-bindT x f = TaggedT $ unTag x >>= \y -> unTag (f y)
-
-{-@ assume returnT :: a -> TaggedT<{\_ -> True}, {\_ -> False}> user m a @-}
-returnT :: Monad m => a -> TaggedT user m a
-returnT x = TaggedT (return x)
-
--------------------------------------------------------------------------------------------
--- | Test
--------------------------------------------------------------------------------------------
-
-{-@ assume respondT :: String -> TaggedT<{\_ -> True}, {\v -> v == currentUser}> User m () @-}
-respondT :: String -> TaggedT User m ()
-respondT = undefined
-
-{-@ test :: TaggedT<{\_ -> True}, {\v -> v == currentUser}> User m () @-}
-test :: Monad m => TaggedT User m ()
-test = returnT "a" `bindT` respondT
diff --git a/tests/pos/T1709.hs b/tests/pos/T1709.hs
deleted file mode 100644
--- a/tests/pos/T1709.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module T1709 where 
-
-{-@ incr :: x:Int -> {v:Int | x < v } @-}
-incr :: Int -> Int 
-incr x = x + 1
-
-{-@ fail decr @-}
-{-@ decr :: x:Int -> {v:Int | x < v } @-}
-decr :: Int -> Int 
-decr x = x - 1
diff --git a/tests/pos/T385.hs b/tests/pos/T385.hs
deleted file mode 100644
--- a/tests/pos/T385.hs
+++ /dev/null
@@ -1,38 +0,0 @@
-{-@ LIQUID "--noclasscheck"    @-}
-module Compose where
-
-import Prelude hiding (Functor, Monad)
-
-data ST s a = ST {runState :: s -> (a,s)}
-
-{-@ data ST s a <p :: s -> Bool, q :: s -> s -> Bool, r :: s -> a -> Bool> 
-      = ST (runState :: x:s<p> -> (a<r x>, s<q x>)) @-}
-
-{-@ runState :: forall <p :: s -> Bool, q :: s -> s -> Bool, r :: s -> a -> Bool>. ST <p, q, r> s a -> x:s<p> -> (a<r x>, s<q x>) @-}
-
-class Functor f where
-  fmap :: (a -> b) -> f a -> f b
-
-instance Functor (ST s) where
-  fmap f (ST g) = ST (\s -> let (a, s') = g s in (f a, s'))
-
-class Functor m => Monad m where
-  (>>) :: m a -> m b -> m b
-
-instance Monad (ST s) where
-  {-@ instance Monad ST s where
-        >>  :: forall s a b  < pref :: s -> Bool, postf :: s -> s -> Bool
-                    , pre  :: s -> Bool, postg :: s -> s -> Bool
-                    , post :: s -> s -> Bool
-                    , rg   :: s -> a -> Bool
-                    , rf   :: s -> b -> Bool
-                    , r    :: s -> b -> Bool
-                    >. 
-             {x::s<pre>, y::s<postg x> |- b<rf y> <: b<r x>}
-             {xx::s<pre>, w::s<postg xx> |- s<postf w> <: s<post xx>}
-             {ww::s<pre> |- s<postg ww> <: s<pref>}
-             (ST <pre, postg, rg> s a)
-          -> (ST <pref, postf, rf> s b)
-          -> (ST <pre, post, r> s b)
-    @-}
-  (ST g) >>  f = ST (\x -> case g x of {(y, s) -> (runState f) s})    
diff --git a/tests/pos/T531.hs b/tests/pos/T531.hs
deleted file mode 100644
--- a/tests/pos/T531.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module T531 where
-
-{-@
-data Foo = Foo { _getFoo :: Int }
-@-}
-data Foo = Foo { _getFoo :: Int }
diff --git a/tests/pos/T595.hs b/tests/pos/T595.hs
deleted file mode 100644
--- a/tests/pos/T595.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-module Issue595 where
-
-import Data.Vector
-
-data Test = Test
-    { vec  :: Thing
-    , x0   :: Bool
-    }
-
-type Thing = [()] -- Vector ()
-
-{-@ data Test = Test
-      { vec  :: Thing
-      , x0   :: { v : Bool | ((len vec) < 1) ==> v }
-      }
-  @-}
-
--- The above data declaration should give us the following refined types
--- for the record selectors
-
-{- assume vec :: x:Test -> {v:Thing | v = vec x} @-}
-{- assume x0  :: x:Test -> {v:Bool  | v = x0 x  && ((len (vec x) < 1) => v) } @-}
-
-example :: Test -> ()
-example t =
-    if x0 t
-    then ()
-    else vec t !! 0
diff --git a/tests/pos/T595a.hs b/tests/pos/T595a.hs
deleted file mode 100644
--- a/tests/pos/T595a.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module T595a where
-
-data Tree a = Nil | Tree { key :: a, l::Tree a, r :: Tree a}
-
-{-@ data Tree a = Nil
-                | Tree { key :: a
-                       , l   :: Tree {v:a | v < key }
-                       , r   :: Tree {v:a | key < v }
-                       }
-  @-}
diff --git a/tests/pos/T598.hs b/tests/pos/T598.hs
deleted file mode 100644
--- a/tests/pos/T598.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-# LANGUAGE DeriveGeneric #-}
-
-module T598 where
-
-import GHC.Generics (Generic)
-import Control.DeepSeq (NFData(..))
-
-data Point = Point
-    { x :: Int
-    } deriving (Generic)
-
-instance NFData Point
diff --git a/tests/pos/T716.hs b/tests/pos/T716.hs
deleted file mode 100644
--- a/tests/pos/T716.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-{-# LANGUAGE MagicHash #-}
--- | See https://github.com/ucsd-progsys/liquidhaskell/issues/716
---   due to the weird case-of thwarting ANF, you need the qualifier from the
---   output type of `narrow16Word` (apparently we don't scrape assumes?) 
---   ELIMINATE does not cut it, as the relevant kvar happens to be non-linear...
-
-{-@ LIQUID "--scrape-used-imports" @-}
-
-module Blank where
-
-import GHC.Exts
-import GHC.Word
-
--- denotes the offset at which bits are no longer guaranteed to be defined
-
-{-@ measure undefinedOffset :: Word# -> Int @-}
-
-{-@ assume byteSwap16# :: Word# -> {v:Word# | undefinedOffset v = 16} @-}
-
--- We need either the below qualifier, or the one from the refinement of
--- `Word`.Why are NEITHER generated automatically?
-
-{-@ assume narrow16Word# :: Word# -> {v:Word# | undefinedOffset v = 64} @-}
-
-{-@ data Word = W# {w :: {v:Word# | undefinedOffset v >= 64}} @-}
-
-grabWord16_SAFE (Ptr ip#) = let x = byteSwap16# (indexWord16OffAddr# ip# 0#) in W# (narrow16Word# x)
-
-grabWord16_UNSAFE (Ptr ip#) = W# (narrow16Word# (byteSwap16# (indexWord16OffAddr# ip# 0#)))
-
-
diff --git a/tests/pos/T819.hs b/tests/pos/T819.hs
deleted file mode 100644
--- a/tests/pos/T819.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-{-@ LIQUID "--reflection" @-}
-
-module Data.Foo where
-
-import Language.Haskell.Liquid.ProofCombinators
-import Prelude hiding ((<>))
-
-data L a = N 
-{-@ infixl 9 <> @-}
-
-
-{-@ foo :: xs:L a -> {xs <> N == N } @-}
-foo :: L a -> Proof
-foo N = N <> N === N *** QED 
-
-
-{-@ reflect <> @-}
-(<>) :: L a -> L a -> L a 
-N <> N = N 
-
-
-{-@ infixl 9 +++ @-}
-{-@ data N = Zero | Succ {next :: N} @-}
-data N = Zero | Succ N 
-
-{-@ reflect +++ @-}
-(+++) :: N -> N -> N
-n +++ m = n
-
-{-@ lemma :: { v:() | Zero +++ Zero == Zero } @-}
-lemma :: ()
-lemma = Zero +++ Zero === Zero *** QED
-
diff --git a/tests/pos/T819A.hs b/tests/pos/T819A.hs
deleted file mode 100644
--- a/tests/pos/T819A.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-@ LIQUID "--reflection"     @-}
-{-@ LIQUID "--no-termination" @-}
-
-module T819A where
-
-import Language.Haskell.Liquid.ProofCombinators 
-import Prelude hiding ((++))
-
-data List a = Emp 
-
-{-@ infixr ++ @-}
-
-{-@ reflect ++ @-}
-Emp ++ ys = ys
-
-{-@ assocPf :: xs:_ -> ys:_  -> { (xs ++ ys) == ys  } @-}
-assocPf :: List a -> List a  -> Proof 
-
-assocPf Emp ys
-  =   (Emp ++ ys) 
-  === ys 
-  *** QED
diff --git a/tests/pos/T820.hs b/tests/pos/T820.hs
deleted file mode 100644
--- a/tests/pos/T820.hs
+++ /dev/null
@@ -1,43 +0,0 @@
-{-@ LIQUID "--exactdc"      @-}
-{-@ LIQUID "--higherorder"  @-}
-
-module Data.Foo where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{- data Foo = Foo { foox :: (Int -> Int) , fooy :: Int } @-}
-data Foo = Foo { x :: Int -> Int , y :: Int }
-
-
-
-{-@ data VerifiedEq a = VerifiedEq {
-        eq :: a -> a -> Bool
-      , refl :: x:a -> { v:() | (eq x x) }
-      , sym :: x:a -> y:a -> { v:() | (eq x y) ==> (eq y x) }
-      , trans :: x:a -> y:a -> z:a -> { v:() | (eq x y) && (eq y z) ==> (eq x z) }
-      }
-@-}
-data VerifiedEq a = VerifiedEq {
-    eq :: a -> a -> Bool
-  , refl :: a -> Proof
-  , sym :: a -> a -> Proof
-  , trans :: a -> a -> a -> Proof
-  }
-
-{-@ data VerifiedOrd a = VerifiedOrd {
-        leq :: (a -> a -> Bool)
-      , total :: (x:a -> y:a -> { (leq x y) || (leq y x) })
-      , antisym :: (x:a -> y:a -> { (leq x y) || (leq y x) ==> x == y })
-      , trans2 :: (x:a -> y:a -> z:a -> { (leq x y) && (leq y z) ==> (leq x z) })
-      , verifiedEq :: VerifiedEq a
-      }
-  @-}
-
-
-data VerifiedOrd a = VerifiedOrd {
-    leq :: a -> a -> Bool
-  , total :: a -> a -> Proof
-  , antisym :: a -> a -> Proof
-  , trans2 :: a -> a -> a -> Proof
-  , verifiedEq :: VerifiedEq a
-  }
diff --git a/tests/pos/T866.hs b/tests/pos/T866.hs
deleted file mode 100644
--- a/tests/pos/T866.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-{-@ LIQUID "--no-totality"    @-}
-
--- see https://github.com/ucsd-progsys/liquidhaskell/issues/866
-
-module T866 where 
-
-data Body = Body Int Int 
-
-genBody :: [Int] -> Body
-genBody s   = Body x y 
-  where 
-    (x:y:_) = s
-
diff --git a/tests/pos/T914.hs b/tests/pos/T914.hs
deleted file mode 100644
--- a/tests/pos/T914.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{-@ LIQUID "--higherorder" @-}
-
-module MapFusion where
-
-import Language.Haskell.Liquid.ProofCombinators
-
-{-@ inline compose @-}
-
-{-@ compose :: f:(b -> c) -> g:(a -> b) -> x:a -> c @-}
-compose :: (b -> c) -> (a -> b) -> a -> c
-compose f g x = f (g x)
diff --git a/tests/pos/Term.hs b/tests/pos/Term.hs
deleted file mode 100644
--- a/tests/pos/Term.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{-@ LIQUID "--no-totality"    @-}
-
-module Term where
-
-import Language.Haskell.Liquid.Prelude (unsafeError)
-
--- TODO: If we remove the type signature LH crashes
-f :: (Num a) => String -> [a] -> [a]
-{-@ f :: _ -> xs : [a] -> [a] / [len xs] @-}
-f er [] = unsafeError er
-f er (x:xs) = (x+1) : f er xs
-
-f' :: String -> [a] -> [a]
-{-@ f' :: _ -> xs : [a] -> [a] / [len xs] @-}
-f' er [] = unsafeError er
-f' er (x:xs) = x : f' er xs
-
-{-@ type ListN a N = {v:[a] | len v = N} @-}
-{-@ type ListL a L = ListN a (len L) @-}
-
-safeZipWithError :: String -> [a] -> [b] -> [(a, b)]
-{-@ safeZipWithError :: _ -> xs:[a] -> ListL b xs -> ListL (a,b) xs / [len xs] @-}
-safeZipWithError msg (x:xs) (y:ys) = (x,y) : safeZipWithError msg xs ys
-safeZipWithError _   []     []     = []
-safeZipWithError msg _      _      = unsafeError msg
diff --git a/tests/pos/Termination.hs b/tests/pos/Termination.hs
deleted file mode 100644
--- a/tests/pos/Termination.hs
+++ /dev/null
@@ -1,50 +0,0 @@
-module Termination where
-
-import Prelude hiding (sum)
-
-type Value = Int
-
-type Vec = Int -> Value
-
-{-@ sum :: Vec -> Nat -> Value @-}
-sum :: Vec -> Int -> Value
-sum a 0 = a 0
-sum a i = a i + sum a (i-1)
-
-{-@ sum' :: Vec -> Value -> n:Nat -> Value / [n] @-}
-sum' :: Vec -> Value -> Int -> Value
-sum' a acc 0 = acc + a 0
-sum' a acc i = sum' a (acc + a i) (i-1)
-
-type Vec2D = Int -> Int -> Value
-
-{-@ sum2D :: Vec2D -> Nat -> Nat -> Value @-}
-sum2D :: Vec2D -> Int -> Int -> Value
-sum2D a n m = go n m
-  where
-    {-@ go :: ink:Nat -> joe:Nat -> Value / [ink, joe] @-}
-    go 0 0        = a 0 0
-    go i j
-      | j == 0    =  a i 0 + go (i-1) m
-      | otherwise =  a i j + go i (j-1)
-
-{-@ sumFromTo :: Vec -> lo:Nat -> hi:{v:Nat|v>=lo} -> Value @-}
-sumFromTo :: Vec -> Int -> Int ->  Value
-sumFromTo a lo hi = go lo hi
-  where
-    {-@ go :: lo:Nat -> hi:{v:Nat | v >= lo} -> Value / [hi-lo] @-}
-    go :: Int -> Int -> Value
-    go lo hi 
-      | lo == hi  =  a lo
-      | otherwise =  a lo + go (lo + 1) hi
-
-{-@ sumFrom2 :: Vec -> lo:Nat -> hi:{v:Nat | lo <= v } -> Value @-}
-sumFrom2 :: Vec -> Int -> Int ->  Value
-sumFrom2 a lo hi = go lo
-  where
-    {-@ go :: lo:_ -> _ / [hi - lo] @-}
-    go :: Int -> Value
-    go lo
-      | lo == hi  =  a lo
-      | otherwise =  a lo + go (lo + 1)
-
diff --git a/tests/pos/TerminationNum.hs b/tests/pos/TerminationNum.hs
deleted file mode 100644
--- a/tests/pos/TerminationNum.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Fixme where
-
-{-@ fak2 :: (Ord a, Eq a, Num a) => y:{x: a | x >= 0} -> a /[y]@-}
-fak2 :: (Ord a, Eq a, Num a) => a -> a
-fak2 0 = 1
-fak2 x = x * fak2 (x - 1)
diff --git a/tests/pos/TerminationNum0.hs b/tests/pos/TerminationNum0.hs
deleted file mode 100644
--- a/tests/pos/TerminationNum0.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Fixme where
-
-{-@fak2 :: (Ord a, Eq a, Num a) => {x: a | x >= 0} -> a @-}
-fak2 :: (Ord a, Eq a, Num a) => a -> a
-fak2 0 = 1
-fak2 x = x * fak2 (x - 1)
-
-
-{-@ fak :: {x: Int | x >= 0} -> a -> Int @-}
-fak :: (Ord a, Eq a, Num a) => Int -> a -> Int 
-fak 0 _ = 1
-fak x y = fak (x - 1) y
-
-
-{-@ fak1 :: {x: Int | x >= 0} -> a -> Int @-}
-fak1 :: (Num a) => Int -> a -> Int 
-fak1 0 _ = 1
-fak1 x y = fak1 (x - 1) y
diff --git a/tests/pos/Test761.hs b/tests/pos/Test761.hs
deleted file mode 100644
--- a/tests/pos/Test761.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Test761 () where
-
-import Language.Haskell.Liquid.Prelude
-
-x = choose 0
-
-prop_abs ::  Bool
-prop_abs = if x > 0 then baz x else False
-
-baz gooberding = liquidAssertB (gooberding >= 0)
diff --git a/tests/pos/TokenType.hs b/tests/pos/TokenType.hs
deleted file mode 100644
--- a/tests/pos/TokenType.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Fixme where
-
-
-data TokenType = Foo | CChar
-
-
-{-@ bar :: Char @-}
-bar :: Char
-bar = undefined
diff --git a/tests/pos/TopLevel.hs b/tests/pos/TopLevel.hs
deleted file mode 100644
--- a/tests/pos/TopLevel.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module TopLevel (bar) where
-
-import Language.Haskell.Liquid.Prelude
-
-foo b = liquidAssertB b
-
-bar = foo True
diff --git a/tests/pos/ToyMVar.hs b/tests/pos/ToyMVar.hs
deleted file mode 100644
--- a/tests/pos/ToyMVar.hs
+++ /dev/null
@@ -1,66 +0,0 @@
-{-# LANGUAGE MagicHash     #-}
-{-# LANGUAGE UnboxedTuples #-}
-
-{-@ LIQUID "--no-totality"       @-}
-{-@ LIQUID "--no-termination"    @-}
-{-@ LIQUID "--no-pattern-inline" @-}
-
-module ToyMVar where
-
-import Prelude hiding (IO)
-import Control.Applicative
-import Data.Set 
-data RealWorld
-data MVar# s a 
-data State# s 
-data MVar a = MVar (MVar# RealWorld a)
-
-data IO a = IO (State# RealWorld -> (State# RealWorld, a))
-{-@ data IO a <p :: State# RealWorld -> Bool, q :: State# RealWorld-> a -> Bool>
-      = IO (io :: (State# RealWorld)<p> -> ((State# RealWorld, a)<q>))
-  @-}
-
-{-@ measure inState :: MVar a -> State# RealWorld -> Bool @-}
-{-@ measure stateMVars :: State# RealWorld -> Set (MVar a) @-}
-
-{-@ newEmptyMVar  :: forall < p :: State# RealWorld -> Bool
-                            , q :: State# RealWorld -> (MVar a) -> Bool>. 
-                     IO <p, {\x y -> (inState y x)}> (MVar a) @-}
-newEmptyMVar  :: IO (MVar a)
-newEmptyMVar = IO $ \ s# ->
-    case newMVar# s# of
-         (s2#, svar#) -> (s2#, MVar svar#)
-
-newMVar :: a -> IO (MVar a)
-newMVar value =
-    newEmptyMVar        >>= \ mvar ->
-    putMVar mvar value  >>
-    return mvar
-
-putMVar  :: MVar a -> a -> IO ()
-putMVar (MVar mvar#) x = IO $ \ s# ->
-    case putMVar# mvar# x s# of
-        s2# -> (s2#, ())
-
-
-putMVar# :: MVar# s a -> a -> State# s -> State# s
-putMVar# = let x = x in x
-
-{-@ newMVar#  :: forall < p :: State# s -> Bool
-                            , q :: State# s -> (MVar# s a) -> Bool>. 
-                     (State# s)<p> -> 
-                     ((State# s)<p>, (MVar# s a))<q> @-}
-
-newMVar# :: State# s -> (State# s, MVar# s a)
-newMVar# = let x = x in x
-
-instance Monad IO where --  GHC-Base.lhs
-  return = undefined
-  _ >> _ = undefined
-
-instance Applicative IO where
-  pure  = undefined
-  (<*>) = undefined
-
-instance Functor IO where
-  fmap = undefined
diff --git a/tests/pos/TypeAlias.hs b/tests/pos/TypeAlias.hs
deleted file mode 100644
--- a/tests/pos/TypeAlias.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module TypeAlias where
-
-data Foo a b = Foo a b
-
-type Bar = Foo Int
-
-
-{-@ foo :: String  @-}
-foo :: String
-foo = "mpla"
-
-{-@ bar :: Bar {v:Int | v = 2} @-}
-bar :: Bar Int
-bar = Foo 1 2
diff --git a/tests/pos/TypeLitNat.hs b/tests/pos/TypeLitNat.hs
deleted file mode 100644
--- a/tests/pos/TypeLitNat.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-{-# LANGUAGE GADTs #-}
-
-{-# LANGUAGE KindSignatures      #-}
-{-# LANGUAGE DataKinds           #-}
-{-# LANGUAGE OverloadedStrings   #-}
-{-# LANGUAGE RankNTypes          #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TypeOperators       #-}
-
-module TypeLits where
-
-import GHC.TypeLits
-
--- THIS SHOULD BE UNSAFE
-miunsafe2 :: MI 0
-miunsafe2 = Small 0
-
-data MI (s :: Nat) = Small { mi_input :: Int  }
-
-{-@ Small :: forall (s :: Nat). {v:Int | s ~~ v } -> MI s @-}
diff --git a/tests/pos/TypeLitString.hs b/tests/pos/TypeLitString.hs
deleted file mode 100644
--- a/tests/pos/TypeLitString.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-# LANGUAGE KindSignatures      #-}
-{-# LANGUAGE DataKinds           #-}
-{-# LANGUAGE OverloadedStrings   #-}
-{-# LANGUAGE RankNTypes          #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module DependeTypes where
-
-import GHC.TypeLits
-
--- THIS SHOULD BE SAFE
-misafe   :: MI "blaa"
-misafe   = Small "blaa"
-
-data MI (s :: Symbol) = Small { mi_input :: String  }
-
-{-@ Small :: forall (s :: Symbol). {v:String | s ~~ v } -> MI s @-}
-
--- OR 
-
-{- data MI (s :: Symbol)
-    = Small { mi_input :: {v:String | v == s } } @-}
diff --git a/tests/pos/UnboxedTuples.hs b/tests/pos/UnboxedTuples.hs
deleted file mode 100644
--- a/tests/pos/UnboxedTuples.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-{-# LANGUAGE MagicHash #-}
-{-# LANGUAGE UnboxedTuples #-}
-module Blank where
-
-import GHC.Int
-
-foo = let (# x, y #) = (# 1#, 1# #) in I8# x
-
diff --git a/tests/pos/UnboxedTuplesAndTH.hs b/tests/pos/UnboxedTuplesAndTH.hs
deleted file mode 100644
--- a/tests/pos/UnboxedTuplesAndTH.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-# LANGUAGE MagicHash #-}
-{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE UnboxedTuples #-}
-
-module Blank where
-
-import GHC.Int
-
-foo = let (# x, y #) = (# 1#, 1# #) in I8# x
-
-bar = [| 1 + 2|]
-
diff --git a/tests/pos/Variance.hs b/tests/pos/Variance.hs
deleted file mode 100644
--- a/tests/pos/Variance.hs
+++ /dev/null
@@ -1,47 +0,0 @@
-module Variance where
-
-{-@ data variance Foo invariant bivariant covariant contravariant @-}
-data Foo a b c d
-
-
-
-{-@ check_covariant :: Foo a b {v:Int | v = 1} c -> Foo a b {v:Int | v > 0} c @-}
-check_covariant :: Foo a b Int c -> Foo a b Int c
-check_covariant r = r
-
-
-{-@ check_contravariant0 :: Foo a b c {v:Int | v > 0} -> Foo a b c {v:Int | v = 1} @-}
-check_contravariant0 :: Foo a b c Int-> Foo a b c Int
-check_contravariant0 r = r
-
-{-@ check_contravariant :: ((Foo a b c {v:Int | v = 1}) -> ()) -> (Foo a b c {v:Int | v > 0}) -> () @-}
-check_contravariant :: ((Foo a b c Int) -> ()) -> Foo a b c Int -> ()
-check_contravariant r = r
-
-{-@ check_bivariant :: Foo a {v: Int | v = 1} c d -> Foo a {v:Int | ((v > 0) && (v < 2))} c d @-}
-check_bivariant :: Foo a Int c d -> Foo a Int c d
-check_bivariant r = r
-
-
-{-@ check_invariant :: Foo {v: Int | v = 1} b c d -> Foo {v:Int | ((v > 0) && (v < 2))} b c d @-}
-check_invariant :: Foo Int b c d -> Foo Int b c d
-check_invariant r = r
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/Variance2.hs b/tests/pos/Variance2.hs
deleted file mode 100644
--- a/tests/pos/Variance2.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-{-# LANGUAGE Rank2Types, ExistentialQuantification #-}
-
-
-module Variance where
-
-
-import Control.Monad.Trans.Except
-
-
-
-p1 :: Parser a 
-p1 = undefined 
-
-p2 :: Parser a -> ()
-p2 _ = () 
-
-p = p2 p1 
-
-
--- The following structure is a simplification of 
---  Options.Applicative.Parser 
-
-data Parser a
-  = OptP (Option a)
-
-data Option a = Option
-  { optMain :: OptReader a }
-
-
-
-data OptReader a
- =  CmdReader (String -> Maybe (ParserInfo a)) -- ^ command reader
-
-
-data ParserInfo a = ParserInfo
-  { infoParser :: Parser a    -- ^ the option parser for the program                              -- after arguments (default: True)
-  }
diff --git a/tests/pos/VerifiedNum.hs b/tests/pos/VerifiedNum.hs
deleted file mode 100644
--- a/tests/pos/VerifiedNum.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-module VerifiedNum where
-
--- Hiding numeric operations, because they get by default translated to SMT equivalent
-import Prelude hiding (Num(..))
-
-import qualified Prelude as Prelude 
-
-class VerifiedNum a where 
-  (+) :: a -> a -> a 
-  (-) :: a -> a -> a 
-
-{-@ predicate BoundInt X = 0 < X + 10000 && X < 10000 @-}
-
-{-@ type OkInt N = {v:Int | BoundInt N => v == N} @-}
-
-{-@ type ValidInt = {v:Int | BoundInt v} @-}
-
-
-instance VerifiedNum Int where
-{-@ instance VerifiedNum Int where 
-      + :: x:Int -> y:Int -> OkInt {x + y} 
-  @-}
-	x + y = (Prelude.+) x y  
-{-@ instance VerifiedNum Int where 
-      - :: x:Int -> y:Int -> OkInt {x - y} 
-  @-}
-	x - y = (Prelude.-) x y  
-
diff --git a/tests/pos/WBL.hs b/tests/pos/WBL.hs
deleted file mode 100644
--- a/tests/pos/WBL.hs
+++ /dev/null
@@ -1,180 +0,0 @@
-
------------------------------------------------------------------------
--- Weight-Biased Leftist Heap, verified using LiquidHaskell -----------
------------------------------------------------------------------------
--- ORIGINAL SOURCE ----------------------------------------------------
------------------------------------------------------------------------
--- Copyright: 2014, Jan Stolarek, Politechnika Łódzka                --
---                                                                   --
--- License: See LICENSE file in root of the repo                     --
--- Repo address: https://github.com/jstolarek/dep-typed-wbl-heaps-hs --
---                                                                   --
--- Basic implementation of weight-biased leftist heap. No proofs     --
--- and no dependent types. Uses a two-pass merging algorithm.        --
------------------------------------------------------------------------
-
-{-@ LIQUID "--no-termination" @-}
-
-module WBL where
-
-type Priority = Int
-
-type Rank     = Int
-
-type Nat      = Int
-
-data Heap a   = Empty | Node { pri   :: a
-                             , rnk   :: Rank
-                             , left  :: Heap a
-                             , right :: Heap a
-                             }
-
-{-@ data Heap a <q :: a -> a -> Bool> =
-      Empty | Node { pri   :: a
-                   , rnk   :: Nat
-                   , left  :: {v: Heap<q> (a<q pri>) | ValidRank v}
-                   , right :: {v: Heap<q> (a<q pri>) | ValidRank v}
-                   }
- @-}
-
-{-@ predicate ValidRank V = okRank V && realRank V = rank V  @-}
-{-@ type PHeap a = {v:OHeap a | ValidRank v}                 @-}
-{-@ type OHeap a = Heap <{\root v -> root <= v}> a           @-}
-
-{-@ measure okRank        :: Heap a -> Bool
-    okRank (Empty)        = true
-    okRank (Node p k l r) = ((realRank l >= realRank r) && k == (1 + (realRank l) + (realRank r)))
-  @-}
-
-{-@ measure realRank :: Heap a -> Int
-    realRank (Empty)        = 0
-    realRank (Node p k l r) = (1 + realRank l + realRank r)
-  @-}
-
-
-{-@ invariant {v:Heap a | rank v == realRank (left v) + realRank (right v) && realRank v >= 0 } @-}  
-
-{-@ measure rank @-}
-{-@ assume rank :: h:Heap a -> {v:Nat | v = realRank h} @-}
-rank Empty          = 0
-rank (Node _ r _ _) = r
-
-
--- Creates heap containing a single element with a given Priority
-{-@ singleton :: a -> PHeap a  @-}
-singleton p = Node p 1 Empty Empty
-
--- Note [Two-pass merging algorithm]
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
--- We use a two-pass implementation of merging algorithm. One pass,
--- implemented by merge, performs merging in a top-down manner. Second
--- one, implemented by makeT, ensures that rank   riant of weight
--- biased leftist tree is not violated after merging.
---
--- Notation:
---
---  h1, h2 - heaps being merged
---  p1, p2 - priority of root element in h1 and h2
---  l1     - left  subtree in the first  heap
---  r1     - right subtree in the first  heap
---  l2     - left  subtree in the second heap
---  r2     - right subtree in the second heap
---
--- Merge function analyzes four cases. Two of them are base cases:
---
---    a) h1 is empty - return h2
---
---    b) h2 is empty - return h1
---
--- The other two cases form the inductive definition of merge:
---
---    c) priority p1 is higher than p2 - p1 becomes new root, l1
---       becomes its one child and result of merging r1 with h2
---       becomes the other child:
---
---               p1
---              /  \
---             /    \
---            l1  r1+h2 -- here "+" denotes merging
---
---    d) priority p2 is higher than p2 - p2 becomes new root, l2
---       becomes its one child and result of merging r2 with h1
---       becomes the other child.
---
---               p2
---              /  \
---             /    \
---            l2  r2+h1
---
--- Note that there is no guarantee that rank of r1+h2 (or r2+h1) will
--- be smaller than rank of l1 (or l2). To ensure that merged heap
--- maintains the rank invariant we pass both childred - ie. either l1
--- and r1+h2 or l2 and r2+h1 - to makeT, which creates a new node by
--- inspecting sizes of children and swapping them if necessary.
-
--- makeT takes an element (Priority) and two heaps (trees). It
--- constructs a new heap with element at the root and two heaps as
--- children. makeT ensures that WBL heap rank invariant is maintained
--- in the newly created tree by reversing left and right subtrees when
--- necessary (note the inversed r and l in the False alternative of
--- case expression).
-{-@ makeT   :: p:a -> h1:PHeap {v:a | p <= v} -> h2:PHeap {v:a | p <= v}
-            -> {v:PHeap a | realRank v = 1 + realRank h1 + realRank h2} @-}
-makeT p l r = case rank l >= rank r of
-                True  ->  Node p (1 + rank l + rank r) l r
-                False ->  Node p (1 + rank l + rank r) r l
-
--- merge combines two heaps into one. There are two base cases and two
--- recursive cases - see [Two-pass Merging algorithm]. Recursive cases
--- call makeT to ensure that rank invariant is maintained after
--- merging.
-{-@ merge :: (Ord a) => h1:PHeap a -> h2:PHeap a -> {v:PHeap a | realRank v = realRank h1 + realRank h2}  @-}
-merge Empty h2 = h2
-merge h1 Empty = h1
-merge h1@(Node p1 k1 l1 r1) h2@(Node p2 k2 l2 r2) = case p1 < p2 of
-  True  -> makeT p1 l1 (merge r1 (Node p2 k2 l2 r2))
-  False -> makeT p2 l2 (merge (Node p1 k1 l1 r1) r2)
-
--- Inserting into a heap is performed by merging that heap with newly
--- created singleton heap.
-{-@ insert :: (Ord a) => a -> PHeap a -> PHeap a @-}
-insert p h = merge (singleton p) h
-
--- findMin returns element with highest priority, ie. root
--- element. Here we encounter first serious problem: we can't return
--- anything sensible for empty node.
-{-@ findMin :: PHeap a -> a @-}
-findMin Empty          = undefined
-findMin (Node p _ _ _) = p
-
--- and write a safer version of findMinM
-{-@ findMinM :: PHeap a -> Maybe a @-}
-findMinM Empty          = Nothing
-findMinM (Node p _ _ _) = Just p
-
--- deleteMin removes the element with the highest priority by merging
--- subtrees of a root element. Again the case of empty heap is
--- problematic. We could give it semantics by returning Empty, but
--- this just doesn't feel right. Why should we be able to remove
--- elements from an empty heap?
-{-@ deleteMin :: (Ord a) => PHeap a -> PHeap a @-}
-deleteMin Empty          = undefined -- should we insert empty?
-deleteMin (Node _ _ l r) = merge l r
-
--- As a quick sanity check let's construct some examples. Here's a
--- heap constructed by inserting following priorities into an empty
--- heap: 3, 0, 1, 2.
-{-@ heap :: PHeap Int @-}
-heap = insert (2 :: Int)
-      (insert 1
-      (insert 0
-      (insert 3 Empty)))
-
--- Example usage of findMin
-findMinInHeap :: Priority
-findMinInHeap = findMin heap
-
--- Example usage of deleteMin
-deleteMinFromHeap :: Heap Int
-deleteMinFromHeap = deleteMin heap
diff --git a/tests/pos/WBL0.hs b/tests/pos/WBL0.hs
deleted file mode 100644
--- a/tests/pos/WBL0.hs
+++ /dev/null
@@ -1,179 +0,0 @@
-
------------------------------------------------------------------------
--- Weight-Biased Leftist Heap, verified using LiquidHaskell -----------
------------------------------------------------------------------------
--- ORIGINAL SOURCE ----------------------------------------------------
------------------------------------------------------------------------
--- Copyright: 2014, Jan Stolarek, Politechnika Łódzka                --
---                                                                   --
--- License: See LICENSE file in root of the repo                     --
--- Repo address: https://github.com/jstolarek/dep-typed-wbl-heaps-hs --
---                                                                   --
--- Basic implementation of weight-biased leftist heap. No proofs     --
--- and no dependent types. Uses a two-pass merging algorithm.        --
------------------------------------------------------------------------
-
-{-@ LIQUID "--no-termination" @-}
-
-module WBL where
-
-type Priority = Int
-
-type Rank     = Int
-
-type Nat      = Int
-
-data Heap a   = Empty | Node { pri   :: a
-                             , rnk   :: Rank
-                             , left  :: Heap a
-                             , right :: Heap a
-                             }
-
-{-@ data Heap a <q :: a -> a -> Bool> =
-      Empty | Node { pri   :: a
-                   , rnk   :: Nat
-                   , left  :: {v: Heap<q> (a<q pri>) | ValidRank v}
-                   , right :: {v: Heap<q> (a<q pri>) | ValidRank v}
-                   }
- @-}
-
-{-@ predicate ValidRank V = okRank V && realRank V = rank V  @-}
-{-@ type PHeap a = {v:OHeap a | ValidRank v}                 @-}
-{-@ type OHeap a = Heap <{\root v -> root <= v}> a           @-}
-
-{-@ measure okRank @-}
-okRank :: Heap a -> Bool
-okRank (Empty)        = True
-okRank (Node p k l r) = realRank l >= realRank r && k == 1 + realRank l + realRank r
-
-{-@ measure realRank @-}
-realRank :: Heap a -> Int
-realRank (Empty)        = 0
-realRank (Node p k l r) = 1 + realRank l + realRank r
-
-{-@ invariant {v:Heap a | rank v == realRank v } @-}
-
-{-@ measure rank @-}
-{-@ rank :: h:Heap a -> {v:Nat | v = realRank h} @-}
-rank Empty          = 0
-rank (Node _ r _ _) = r
-
-
--- Creates heap containing a single element with a given Priority
-{-@ singleton :: a -> PHeap a  @-}
-singleton p = Node p 1 Empty Empty
-
--- Note [Two-pass merging algorithm]
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
--- We use a two-pass implementation of merging algorithm. One pass,
--- implemented by merge, performs merging in a top-down manner. Second
--- one, implemented by makeT, ensures that rank invariant of weight
--- biased leftist tree is not violated after merging.
---
--- Notation:
---
---  h1, h2 - heaps being merged
---  p1, p2 - priority of root element in h1 and h2
---  l1     - left  subtree in the first  heap
---  r1     - right subtree in the first  heap
---  l2     - left  subtree in the second heap
---  r2     - right subtree in the second heap
---
--- Merge function analyzes four cases. Two of them are base cases:
---
---    a) h1 is empty - return h2
---
---    b) h2 is empty - return h1
---
--- The other two cases form the inductive definition of merge:
---
---    c) priority p1 is higher than p2 - p1 becomes new root, l1
---       becomes its one child and result of merging r1 with h2
---       becomes the other child:
---
---               p1
---              /  \
---             /    \
---            l1  r1+h2 -- here "+" denotes merging
---
---    d) priority p2 is higher than p2 - p2 becomes new root, l2
---       becomes its one child and result of merging r2 with h1
---       becomes the other child.
---
---               p2
---              /  \
---             /    \
---            l2  r2+h1
---
--- Note that there is no guarantee that rank of r1+h2 (or r2+h1) will
--- be smaller than rank of l1 (or l2). To ensure that merged heap
--- maintains the rank invariant we pass both childred - ie. either l1
--- and r1+h2 or l2 and r2+h1 - to makeT, which creates a new node by
--- inspecting sizes of children and swapping them if necessary.
-
--- makeT takes an element (Priority) and two heaps (trees). It
--- constructs a new heap with element at the root and two heaps as
--- children. makeT ensures that WBL heap rank invariant is maintained
--- in the newly created tree by reversing left and right subtrees when
--- necessary (note the inversed r and l in the False alternative of
--- case expression).
-{-@ makeT   :: p:a -> h1:PHeap {v:a | p <= v} -> h2:PHeap {v:a | p <= v}
-            -> {v:PHeap a | realRank v = 1 + realRank h1 + realRank h2} @-}
-makeT p l r = case rank l >= rank r of
-                True  ->  Node p (1 + rank l + rank r) l r
-                False ->  Node p (1 + rank l + rank r) r l
-
--- merge combines two heaps into one. There are two base cases and two
--- recursive cases - see [Two-pass Merging algorithm]. Recursive cases
--- call makeT to ensure that rank invariant is maintained after
--- merging.
-{-@ merge :: (Ord a) => h1:PHeap a -> h2:PHeap a -> {v:PHeap a | realRank v = realRank h1 + realRank h2}  @-}
-merge Empty h2 = h2
-merge h1 Empty = h1
-merge h1@(Node p1 k1 l1 r1) h2@(Node p2 k2 l2 r2) = case p1 < p2 of
-  True  -> makeT p1 l1 (merge r1 (Node p2 k2 l2 r2))
-  False -> makeT p2 l2 (merge (Node p1 k1 l1 r1) r2)
-
--- Inserting into a heap is performed by merging that heap with newly
--- created singleton heap.
-{-@ insert :: (Ord a) => a -> PHeap a -> PHeap a @-}
-insert p h = merge (singleton p) h
-
--- findMin returns element with highest priority, ie. root
--- element. Here we encounter first serious problem: we can't return
--- anything sensible for empty node.
-{-@ findMin :: PHeap a -> a @-}
-findMin Empty          = undefined
-findMin (Node p _ _ _) = p
-
--- and write a safer version of findMinM
-{-@ findMinM :: PHeap a -> Maybe a @-}
-findMinM Empty          = Nothing
-findMinM (Node p _ _ _) = Just p
-
--- deleteMin removes the element with the highest priority by merging
--- subtrees of a root element. Again the case of empty heap is
--- problematic. We could give it semantics by returning Empty, but
--- this just doesn't feel right. Why should we be able to remove
--- elements from an empty heap?
-{-@ deleteMin :: (Ord a) => PHeap a -> PHeap a @-}
-deleteMin Empty          = undefined -- should we insert empty?
-deleteMin (Node _ _ l r) = merge l r
-
--- As a quick sanity check let's construct some examples. Here's a
--- heap constructed by inserting following priorities into an empty
--- heap: 3, 0, 1, 2.
-{-@ heap :: PHeap Int @-}
-heap = insert (2 :: Int)
-      (insert 1
-      (insert 0
-      (insert 3 Empty)))
-
--- Example usage of findMin
-findMinInHeap :: Priority
-findMinInHeap = findMin heap
-
--- Example usage of deleteMin
-deleteMinFromHeap :: Heap Int
-deleteMinFromHeap = deleteMin heap
diff --git a/tests/pos/Words.hs b/tests/pos/Words.hs
deleted file mode 100644
--- a/tests/pos/Words.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-
-module Words where
-
-import Data.Word
-
-{-@ foo :: {v:Word | v = 4} @-}
-foo :: Word
-foo = 4
diff --git a/tests/pos/Words1.hs b/tests/pos/Words1.hs
deleted file mode 100644
--- a/tests/pos/Words1.hs
+++ /dev/null
@@ -1,3 +0,0 @@
-import Data.Word
-
-main = print (quotRem (4 :: Word8) 128)
diff --git a/tests/pos/WrapUnWrap.hs b/tests/pos/WrapUnWrap.hs
deleted file mode 100644
--- a/tests/pos/WrapUnWrap.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-{-@ LIQUID "--higherorder"  @-}
-{-@ LIQUID "--exactdc"      @-}
-module Data.Foo where
-
-
-import Language.Haskell.Liquid.ProofCombinators
-
-data    Prod1 a = Prod1 {unprod1 :: a }
-{-@ data Prod1 a = Prod1 {unprod1 :: a } @-}
-
-prod1Theorem :: Prod1 a -> Proof 
-{-@ prod1Theorem :: x:Prod1 a -> {x == Prod1 (unprod1 x)} @-}
-prod1Theorem (Prod1 _) = trivial 
diff --git a/tests/pos/absref-crash.hs b/tests/pos/absref-crash.hs
deleted file mode 100644
--- a/tests/pos/absref-crash.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Foo where
-
-data L a = C (L a)
-
-{-@ data L a <p :: L a -> Bool> = C { xs :: L<p> a } @-}
-
-{-@ lazy foo @-}
-foo :: b -> L a
-foo x = C $ foo x
diff --git a/tests/pos/absref-crash0.hs b/tests/pos/absref-crash0.hs
deleted file mode 100644
--- a/tests/pos/absref-crash0.hs
+++ /dev/null
@@ -1,36 +0,0 @@
-{-@ LIQUID "--short-names"    @-}
-{-@ LIQUID "--no-warnings"    @-}
-{-@ LIQUID "--no-termination" @-}
-
-
-module Foo (insertSort) where
-
-data List a = N | C a (List a)
-
-infixr 9 `C`
-
-{-@ ifoldr :: forall a b <p :: List a -> b -> Bool>. 
-                 (xs:_ -> x:_ -> b<p xs> -> b<p(C x xs)>) 
-               -> b<p N> 
-               -> ys:List a
-               -> b<p ys>                            @-}
-ifoldr :: (List a -> a -> b -> b) -> b -> List a -> b
-ifoldr = undefined
-
-{-@ data List a <p :: a -> a -> Bool> 
-     = N | C {x :: a, xs :: List<p> a<p x>} @-}
-
-{-@ type IncrList a = List <{\x y -> x <= y}> a @-} 
-
-{-@ insert :: a -> IncrList a -> IncrList a @-}
-insert :: a -> List a -> List a
-insert = undefined
-
-{-@ insertSort      :: xs:List a -> {v:IncrList a | true } @-}
-insertSort :: List a -> List a
-insertSort = undefined
-
-
-
-nil :: List a 
-nil = N
diff --git a/tests/pos/adt0.hs b/tests/pos/adt0.hs
deleted file mode 100644
--- a/tests/pos/adt0.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Adt () where
-
-import Language.Haskell.Liquid.Prelude
-
-data Pair a = P a Int | D a Bool
-
-
-goo z = P z z
-
-baz = goo 10
diff --git a/tests/pos/alias00.hs b/tests/pos/alias00.hs
deleted file mode 100644
--- a/tests/pos/alias00.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Test0 () where
-
-{-@ type PosInt = {v: Int | v >= 0} @-}
-
-{-@ assert myabs :: Int -> PosInt @-}
-myabs   :: Int -> Int
-myabs x = if (x > 0) then x else (0 - x)
-
-{-@ type NNList a = {v: [a] | len v > 0} @-}
-
-{-@ assert single :: a -> NNList a @-}
-single x = [x] 
diff --git a/tests/pos/alias01.hs b/tests/pos/alias01.hs
deleted file mode 100644
--- a/tests/pos/alias01.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Test0 () where
-
-{-@ type GeNum a N = {v: a | N <= v} @-}
-
-{-@ type PosInt = GeNum Int {0} @-}
-
-{-@ myabs :: Int -> PosInt @-}
-myabs :: Int -> Int
-myabs x = if (x > 0) then x else (0 - x)
-
-{-@ incr :: x:Int -> GeNum Int {x} @-}
-incr :: Int -> Int
-incr x = x + 1
-
diff --git a/tests/pos/alphaconvert-List.hs b/tests/pos/alphaconvert-List.hs
deleted file mode 100644
--- a/tests/pos/alphaconvert-List.hs
+++ /dev/null
@@ -1,140 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-{-@ LIQUID "--fullcheck"      @-}
-{-@ LIQUID "--maxparams=3"    @-}
-
--- | An example from "A Relational Framework for Higher-Order Shape Analysis",
---   by Gowtham Kaki Suresh Jagannathan, ICFP 2014.
-
-module AlphaConvert (subst, alpha, isAbs, maxs) where
-
-import Prelude hiding ((++), elem)
-import Data.Set (Set (..))
-import Language.Haskell.Liquid.Prelude
-
-alpha  :: [Bndr] -> Expr -> Expr
-subst  :: Expr -> Bndr -> Expr -> Expr
-lemma1 :: Int -> [Int] -> Bool
-fresh  :: [Bndr] -> Bndr
-free   :: Expr -> [Bndr]
-
----------------------------------------------------------------------
--- | Datatype Definition --------------------------------------------
----------------------------------------------------------------------
-
-type Bndr
-  = Int
-
-data Expr
-  = Var Bndr
-  | Abs Bndr Expr
-  | App Expr Expr
-
-{-@ measure fv       :: Expr -> (Set Bndr)
-    fv (Var x)       = (Set_sng x)
-    fv (Abs x e)     = (Set_dif (fv e) (Set_sng x))
-    fv (App e a)     = (Set_cup (fv e) (fv a))
-  @-}
-
-{-@ measure isAbs  @-}
-isAbs :: Expr -> Bool
-isAbs (Abs v e)  = True
-isAbs (Var v)    = False
-isAbs (App e a)  = False
-
-{-@ predicate AddV E E2 X E1   = fv E = Set_cup (Set_dif (fv E2) (Set_sng X)) (fv E1) @-}
-{-@ predicate EqV E1 E2        = fv E1 = fv E2                                        @-}
-{-@ predicate Occ X E          = Set_mem X (fv E)                                     @-}
-{-@ predicate Subst E E1 X E2  = if (Occ X E2) then (AddV E E2 X E1) else (EqV E E2)  @-}
-
-----------------------------------------------------------------------------
--- | Part 5: Capture Avoiding Substitution ---------------------------------
-----------------------------------------------------------------------------
-{-@ subst :: e1:Expr -> x:Bndr -> e2:Expr -> {e:Expr | Subst e e1 x e2} @-}
-----------------------------------------------------------------------------
-
-subst e1 x e2@(Var y)
-  | x == y                = e1
-  | otherwise             = e2
-
-subst e1 x (App ea eb)    = App ea' eb'
-  where
-    ea'                   = subst e1 x ea
-    eb'                   = subst e1 x eb
-
-subst e1 x e2@(Abs y e)
-  | x == y                = e2
-  | y `elem` xs           = subst e1 x (alpha xs e2)
-  | otherwise             = Abs y      (subst e1 x e)
-     where
-      xs                  = free e1
-
-----------------------------------------------------------------------------
--- | Part 4: Alpha Conversion ----------------------------------------------
-----------------------------------------------------------------------------
-{-@ alpha :: ys:[Bndr] -> e:{Expr | isAbs e} -> {v:Expr | EqV v e} @-}
-----------------------------------------------------------------------------
-alpha ys (Abs x e) = Abs x' (subst (Var x') x e)
-  where
-    xs             = free e
-    x'             = fresh (x : ys ++ xs)
-
-alpha _  _         = liquidError "never"
-
-
-----------------------------------------------------------------------------
--- | Part 3: Fresh Variables -----------------------------------------------
-----------------------------------------------------------------------------
-{-@ fresh :: xs:[Bndr] -> {v:Bndr | NotElem v xs} @-}
-----------------------------------------------------------------------------
-fresh bs = liquidAssert (lemma1 n bs) n
-  where
-    n    = 1 + maxs bs
-
-{-@ measure maxs @-}
-maxs   :: [Int] -> Int
-maxs ([])   = 0
-maxs (x:xs) = if (x > maxs xs) then x else (maxs xs)
-
-{-@ lemma1 :: x:Int -> xs:{[Int] | x > maxs xs} -> {v:Bool | v && NotElem x xs} @-}
-lemma1 _ []     = True
-lemma1 x (_:ys) = lemma1 x ys
-
-
-----------------------------------------------------------------------------
--- | Part 2: Free Variables ------------------------------------------------
-----------------------------------------------------------------------------
-
-----------------------------------------------------------------------------
-{-@ free         :: e:Expr -> {v:[Bndr] | elts v = fv e} @-}
-----------------------------------------------------------------------------
-free (Var x)     = [x]
-free (App e e')  = free e ++ free e'
-free (Abs x e)   = free e \\ x
-
-
-----------------------------------------------------------------------------
--- | Part I: Sets with Lists -----------------------------------------------
-----------------------------------------------------------------------------
-
-{-@ predicate IsCup X Y Z  = elts X = Set_cup (elts Y) (elts Z)    @-}
-{-@ predicate IsDel X Y Z  = elts X = Set_dif (elts Y) (Set_sng Z) @-}
-{-@ predicate Elem  X Ys   = Set_mem X (elts Ys)                   @-}
-{-@ predicate NotElem X Ys = not (Elem X Ys)                       @-}
-
-{-@ (++)      :: xs:[a] -> ys:[a] -> {v:[a] | IsCup v xs ys}  @-}
-[]     ++ ys  = ys
-(x:xs) ++ ys  = x : (xs ++ ys)
-
-{-@ (\\)      :: (Eq a) => xs:[a] -> y:a -> {v:[a] | IsDel v xs y} @-}
-xs   \\ y     = [x | x <- xs, x /= y]
-
-{-@ elem      :: (Eq a) => x:a -> ys:[a] -> {v:Bool | v <=> Elem x ys} @-}
-elem x []     = False
-elem x (y:ys) = x == y || elem x ys
-
-{-@ measure elts :: [a] -> (Set a)
-    elts ([])    = {v | Set_emp v}
-    elts (x:xs)  = {v | v = Set_cup (Set_sng x) (elts xs) }
-  @-}
diff --git a/tests/pos/alphaconvert-Set.hs b/tests/pos/alphaconvert-Set.hs
deleted file mode 100644
--- a/tests/pos/alphaconvert-Set.hs
+++ /dev/null
@@ -1,101 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-{-@ LIQUID "--fullcheck"      @-}
-{-@ LIQUID "--maxparams=3"    @-}
-
-module AlphaConvert (isAbs, subst) where
-
-import qualified Data.Set as S
-
-import Language.Haskell.Liquid.Prelude
-
-freshS  :: S.Set Bndr -> Bndr
-alpha   :: S.Set Bndr -> Expr -> Expr
-subst   :: Expr -> Bndr -> Expr -> Expr
-free    :: Expr -> S.Set Bndr
-
-
----------------------------------------------------------------------
--- | Datatype Definition --------------------------------------------
----------------------------------------------------------------------
-
-type Bndr
-  = Int
-
-data Expr
-  = Var Bndr
-  | Abs Bndr Expr
-  | App Expr Expr
-
-{-@ measure fv       :: Expr -> (S.Set Bndr)
-    fv (Var x)       = (Set_sng x)
-    fv (Abs x e)     = (Set_dif (fv e) (Set_sng x))
-    fv (App e a)     = (Set_cup (fv e) (fv a))
-  @-}
-
-{-@ measure isAbs @-}
-isAbs (Var v)    = False
-isAbs (Abs v e)  = True
-isAbs (App e a)  = False
-
-{-@ predicate Elem  X Ys       = Set_mem X Ys               @-}
-{-@ predicate NotElem X Ys     = not (Elem X Ys)            @-}
-{-@ predicate AddV E E2 X E1   = fv E = Set_cup (Set_dif (fv E2) (Set_sng X)) (fv E1) @-}
-{-@ predicate EqV E1 E2        = fv E1 = fv E2                                        @-}
-{-@ predicate Occ X E          = Set_mem X (fv E)                                     @-}
-{-@ predicate Subst E E1 X E2  = if (Occ X E2) then (AddV E E2 X E1) else (EqV E E2)  @-}
-
-----------------------------------------------------------------------------
--- | Part 5: Capture Avoiding Substitution ---------------------------------
-----------------------------------------------------------------------------
-{-@ subst :: e1:Expr -> x:Bndr -> e2:Expr -> {e:Expr | Subst e e1 x e2} @-}
-----------------------------------------------------------------------------
-
-subst e' x e@(Var y)
-  | x == y                = e'
-  | otherwise             = e
-
-subst e' x (App ea eb)    = App ea' eb'
-  where
-    ea'                   = subst e' x ea
-    eb'                   = subst e' x eb
-
-subst e1 x e2@(Abs y e)
-  | x == y                = e2
-  | y `S.member` xs       = subst e1 x (alpha xs e2)
-  | otherwise             = Abs y (subst e1 x e)
-    where
-      xs                  = free e1
-
-----------------------------------------------------------------------------
--- | Part 4: Alpha Conversion ----------------------------------------------
-----------------------------------------------------------------------------
-{-@ alpha :: ys:(S.Set Bndr) -> e:{Expr | isAbs e} -> {v:Expr | EqV v e} @-}
-----------------------------------------------------------------------------
-alpha ys (Abs x e) = Abs x' (subst (Var x') x e)
-  where
-    xs             = free e
-    x'             = freshS zs
-    zs             = S.insert x (S.union ys xs)
-
-alpha _  _         = liquidError "never"
-
-
-----------------------------------------------------------------------------
--- | Part 3: Fresh Variables -----------------------------------------------
-----------------------------------------------------------------------------
-{-@ freshS :: xs:(S.Set Bndr) -> {v:Bndr | NotElem v xs} @-}
-----------------------------------------------------------------------------
-freshS xs = undefined
-
-
-----------------------------------------------------------------------------
--- | Part 2: Free Variables ------------------------------------------------
-----------------------------------------------------------------------------
-
-----------------------------------------------------------------------------
-{-@ free         :: e:Expr -> {v : S.Set Bndr | v = fv e} @-}
-----------------------------------------------------------------------------
-free (Var x)     = S.singleton x
-free (App e e')  = S.union  (free e) (free e')
-free (Abs x e)   = S.delete x (free e)
diff --git a/tests/pos/anfbug.hs b/tests/pos/anfbug.hs
deleted file mode 100644
--- a/tests/pos/anfbug.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module Tx (x,y) where
-
-import Control.Exception (assert)
-
--- TransformRec BUG: this causes a temporary to get hoisted out of scope
-getTails' :: Int -> [[a]] -> [[a]]
-getTails' n xss = assert (n > 0) [t | (_:t) <- xss]
-
-x = getTails' 1 []
-
--- HACK give hints for internal variables....
-{- decrease ds_d258 3 @-}
-{- decrease ds_d25g 3 @-}
-
--- TransformRec BUG: this causes some weird unused variable error (occurrence of DEAD ID)?
-getTails'' :: Int -> [[a]] -> [[a]]
-getTails'' n xss = [t | (_:t) <- xss]
-
-y = getTails'' 1 []
diff --git a/tests/pos/anftest.hs b/tests/pos/anftest.hs
deleted file mode 100644
--- a/tests/pos/anftest.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-module AnfWierd () where
-
--- xs :: [Int]
--- xs = let x0 = 0
---          x1 = 1
---          x2 = 2
---          x3 = 3
---          x4 = 4
---          x5 = 5
---          x6 = 6
---          x7 = 7
---          x8 = 8
---          x9 = 9
---      in [x0, x1, x2, x3, x4, x5, x6, x7, x8, x9]
-
-xs :: [Int]
-xs = let x0 = 0
-         x1 = 1
-     in [x0, x1]
-
-ys :: [Int]
-ys = [y0, y1]
-     where y0 = 0
-           y1 = 1
-
-{-@ incr :: x: Int -> {v: Int | v > x} @-}
-incr :: Int -> Int
-incr y = y + length xs 
-  
diff --git a/tests/pos/anish1.hs b/tests/pos/anish1.hs
deleted file mode 100644
--- a/tests/pos/anish1.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Test1 () where
-
-inc :: Int -> Int
-inc xoooo = xoooo + 1
-
-test1 :: Int -> Int
-test1 nine = let b = 0 <= nine in
-          if b then
-            let a = inc nine
-            in
-               div nine a
-          else
-            1
diff --git a/tests/pos/bag1.hs b/tests/pos/bag1.hs
deleted file mode 100644
--- a/tests/pos/bag1.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module BagTest where
-
-import qualified Data.Set as S
-import Language.Haskell.Liquid.Bag as B
-
-{-@ zorg :: {v:B.Bag Int | v = B.empty} @-}
-zorg :: B.Bag Int
-zorg = B.empty
-
-{-@ measure elems @-}
-elems :: (Ord a) => [a] -> B.Bag a
-elems []     = B.empty
-elems (x:xs) = B.put x (elems xs)
-
-{-@ prop0 :: x:_ -> TT @-}
-prop0 :: Int -> Bool
-prop0 x = (B.get x b == 4) 
-  where
-    a   = elems [x, x]
-    b   = B.union a a 
diff --git a/tests/pos/bangPatterns.hs b/tests/pos/bangPatterns.hs
deleted file mode 100644
--- a/tests/pos/bangPatterns.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-{-# LANGUAGE BangPatterns #-}
-module Min where
-
-import Data.IORef
-
-import Language.Haskell.Liquid.Prelude
-
-foo :: IORef a -> IORef a
-{-@ foo :: x:IORef a -> {v:IORef a |  v = x} @-}
-foo !x = x
diff --git a/tests/pos/bool0.hs b/tests/pos/bool0.hs
deleted file mode 100644
--- a/tests/pos/bool0.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module BoolMeasure where
-
-{-@ myhead :: {v:[a] | nonEmpty v} -> a @-}
-myhead (x:_) = x
-
-{-@ measure nonEmpty @-}   
-nonEmpty :: [a] -> Bool
-nonEmpty (x:xs) = True 
-nonEmpty []     = False
-
-
-
-
-
-
-
diff --git a/tests/pos/bool1.hs b/tests/pos/bool1.hs
deleted file mode 100644
--- a/tests/pos/bool1.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module EqBool where 
-
-{-@ baz :: x:Bool -> {v:Bool | v == x} @-}
-baz :: Bool -> Bool 
-baz x = x 
diff --git a/tests/pos/bool2.hs b/tests/pos/bool2.hs
deleted file mode 100644
--- a/tests/pos/bool2.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module EqBool where 
-
-
-{-@ gerb :: (Ord a) => x:a -> {v:a | x <= v } -> {v:a | x <= v} @-}
-gerb :: (Ord a) => a -> a -> a 
-gerb x y = y 
-
- 
-moo = gerb False False 
diff --git a/tests/pos/bounds1.hs b/tests/pos/bounds1.hs
deleted file mode 100644
--- a/tests/pos/bounds1.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Fixme where
-
-{-
-Interesting example as subtyping of bounds is instantiated
-with function types!
--}
-
-zipWith :: (b -> Char -> a) 
-        -> b -> b -> a
-zipWith f =  (bar . f)
-
-bar :: (Char -> c) -> a -> c
-bar = undefined
-
diff --git a/tests/pos/case-lambda-join.hs b/tests/pos/case-lambda-join.hs
deleted file mode 100644
--- a/tests/pos/case-lambda-join.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-{-@ LIQUID "--no-termination"   @-}
-
-module Foo where
-
-import Language.Haskell.Liquid.Prelude
-import Data.Set (Set (..))
-
-data RBTree a = Leaf | Node Color a !(RBTree a) !(RBTree a)
-data Color    = B | R deriving (Eq)
-
-{-@ rbalBAD, rbalOK :: k:_ -> l:_ -> r:_ -> {v:_ | Join v k l r} @-}
-rbalBAD x l r = case r of
-  Node R y b (Node R z c d) -> unsafeError "ASD" -- Node R y (Node B x l b) (Node B z c d)
-  Node R z (Node R y b c) d -> Node R y (Node B x l b) (Node B z c d)
-
-rbalOK x l r = case r of
-  -- Node R y b (Node R z c d) -> Node R y (Node B x l b) (Node B z c d)
-  Node R z (Node R y b c) d -> Node R y (Node B x l b) (Node B z c d)
-
-{-@ measure elems :: RBTree a -> (Set a)
-    elems (Leaf)         = (Set_empty 0)
-    elems (Node c k l r) = (Set_cup (Set_sng k) (Set_cup (elems l) (elems r))) 
-  @-}
-
-{-@ predicate Union V L R  = elems V = Set_cup (elems L) (elems R)                       @-}
-{-@ predicate Join V X L R = elems V = Set_cup (Set_sng X) (Set_cup (elems L) (elems R)) @-}
diff --git a/tests/pos/cmptag0.hs b/tests/pos/cmptag0.hs
deleted file mode 100644
--- a/tests/pos/cmptag0.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Test () where
-
-{-@ type OList a = [a]<{\fld v -> (v >= fld)}> @-}
-
-{-@ foo :: (Ord a) => z:a -> OList a -> [{v:a | z <= v}] @-}
-foo y xs = bar y xs
-
-bar :: (Ord a) => a -> [a] -> [a]
-bar y []     = []
-bar y z@(x:xs) = case compare y x of 
-                   EQ -> xs
-                   GT -> bar y xs
-                   LT -> x:xs
diff --git a/tests/pos/comma.hs b/tests/pos/comma.hs
deleted file mode 100644
--- a/tests/pos/comma.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Comma where
-
-{-@ measure mysnd @-}
-mysnd :: (a, b) -> b
-mysnd (_, y) = y
-
-{-@ foo :: x:Int -> {v:Int | v == x} @-}
-foo :: Int -> Int 
-foo x = mysnd (x, x)
-
diff --git a/tests/pos/compare.hs b/tests/pos/compare.hs
deleted file mode 100644
--- a/tests/pos/compare.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Cmp () where
-
-import Language.Haskell.Liquid.Prelude
-
-foo x y
- = case compare x y of 
-    EQ -> liquidAssertB (x == y)
-    LT -> liquidAssertB (x < y)
-    GT -> liquidAssertB (x > y)
-
-prop = foo n m 
-  where n = choose 0
-        m = choose 1
diff --git a/tests/pos/compare1.hs b/tests/pos/compare1.hs
deleted file mode 100644
--- a/tests/pos/compare1.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Cmp () where
-
-import Language.Haskell.Liquid.Prelude
-
-foo x y
- | compare x y == EQ = liquidAssertB (x == y)
- | compare x y == LT = liquidAssertB (x < y)
- | compare x y == GT = liquidAssertB (x >  y)
-
-prop = foo n m 
-  where n = choose 0
-        m = choose 1
diff --git a/tests/pos/compare2.hs b/tests/pos/compare2.hs
deleted file mode 100644
--- a/tests/pos/compare2.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Cmp () where
-
-import Language.Haskell.Liquid.Prelude
-
-foo x y
- | compare x y == EQ = liquidAssertB (x == y)
- | otherwise         = liquidAssertB (True)
-
-prop = foo n m 
-  where n = choose 0
-        m = choose 1
diff --git a/tests/pos/comprehension.hs b/tests/pos/comprehension.hs
deleted file mode 100644
--- a/tests/pos/comprehension.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Comprehension where
-
-{-@ foo :: n:Int -> [{v:Nat | v <= n}] @-}
-foo :: Int -> [Int]
-foo n = [0 .. n]
-
-{-@ assume GHC.Enum.enumFromTo :: (Enum a) => lo:a -> hi:a -> [{v:a | lo <= v && v <= hi}] @-}
diff --git a/tests/pos/comprehensionTerm.hs b/tests/pos/comprehensionTerm.hs
deleted file mode 100644
--- a/tests/pos/comprehensionTerm.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-module Blank (quickSort, foo, qsort) where
-
--- This is a blank file.
-
-{- foo :: xs:[Int] -> {v:[Int] | (len v) = (len xs)} @-}
-foo :: [Int] -> [Int]
-foo []     = []
-foo (x:xs) = (x+1) : foo [y | y <- xs] 
-
-{- qsort :: (Ord a) => xs:[a] -> {v:[a] | (len v) <= (len xs)} @-}
-qsort []     = []
-qsort (x:xs) = x : qsort [y | y <- xs, y < x]
-
-{-@ quickSort    :: (Ord a) => [a] -> SList a @-}
-quickSort []       = []
-quickSort xs@(x:_) = append x lts gts 
-  where 
-    lts          = quickSort [y | y <- xs, y < x]
-    gts          = quickSort [z | z <- xs, z >= x]
-
-{- append :: k:a -> SList {v:a | v<k} -> SList {v:a | v >= k} -> SList a @-}
-append k []     ys  = k : ys
-append k (x:xs) ys  = x : append k xs ys
-
-{-@ type SList a = [a]<{\x v -> (v >= x)}> @-}
-
diff --git a/tests/pos/coretologic.hs b/tests/pos/coretologic.hs
deleted file mode 100644
--- a/tests/pos/coretologic.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module CoreToLog where
-
-import Data.Set
-
--- ISSUE: can we please allow things like `empty` to also
--- appear in type and alias specifications, not just in
--- measures as in `goo` below?
-
-{-@ type IsEmp a = {v:[a] | Data.Set.fromList v = Data.Set.empty } @-}
-
-{-@ foo :: IsEmp Int @-}
-foo :: [Int]
-foo = []
-
-{-@ measure goo @-}
-goo        :: (Ord a) => [a] -> Set a
-goo []     = empty
-goo (x:xs) = (singleton x) `union` (goo xs)
diff --git a/tests/pos/csgordon_issue_296.hs b/tests/pos/csgordon_issue_296.hs
deleted file mode 100644
--- a/tests/pos/csgordon_issue_296.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module BadMeasureType where 
-
-{-@ measure fwd_extends :: IO () -> IO () -> Bool @-}
-{-@ assume fwd_extends_refl :: m:IO () -> {v:Bool | (fwd_extends m m)} @-}
-fwd_extends_refl :: IO () -> Bool
-fwd_extends_refl = undefined
diff --git a/tests/pos/cut00.hs b/tests/pos/cut00.hs
deleted file mode 100644
--- a/tests/pos/cut00.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Cut (foo0) where
-
-{-@ foo0 :: Nat -> Nat @-}
-
-foo0 x = 1 + foo1 x
-foo1 x = 1 + foo2 x
-foo2 x = 1 + foo3 x
-foo3 x = 1 + foo4 x
-foo4 x = 1 + foo5 x
-foo5 x = 1 + foo  x
-
-foo :: Int -> Int
-foo x = 1 + x
-
-bar :: Int -> Int
-bar y = y + 10
-
--- foo x = 1 + foo (x - 1)
diff --git a/tests/pos/data2.hs b/tests/pos/data2.hs
deleted file mode 100644
--- a/tests/pos/data2.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module Range (prop_rng1, llen) where
-
-import Control.Applicative
-import Language.Haskell.Liquid.Prelude
-
-data LL a = N | C { headC :: a, tailC :: (LL a) }
-{-@ data LL [llen] a = N | C { headC :: a, tailC :: (LL a) } @-}
-
-{-@ measure llen @-}
-llen :: LL a -> Int 
-{-@ llen :: LL a -> Nat @-}
-llen N = 0 
-llen (C _ xs) = 1 + llen xs 
-
---instance Functor LL where
---  fmap f N                = N
---  fmap f (C jhala jhalas) = C (f jhala) (fmap f jhalas)
-
-lmap f N = N
-lmap f (C jhala jhalas) = C (f jhala) (lmap f jhalas)
-
-range :: Int -> Int -> LL Int
-range i j = C i N
-
-prop_rng1 n   = (liquidAssertB . (0 <=)) `lmap` range 0 n
diff --git a/tests/pos/dataConQuals.hs b/tests/pos/dataConQuals.hs
deleted file mode 100644
--- a/tests/pos/dataConQuals.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-module Quals () where
-
-data G = G { gx :: Int, gy :: Int }
-
-
--- | We should scrape qualifiers from data definitions; why doesn't it happen
---   "automatically" from the data-con-function signature anyway?
-
-{-@ data G = G { gx :: Int, gy :: {v:Int | v = gx + 5} } @-}
-
-poo :: Int -> Int
-poo n = n + 5
-
--- | `goo` fails because `poo` doesn't have the type `n -> n + 5` because no qual...
-
-{-@ goo :: {v:Int | v = 105} @-}
-goo :: Int
-goo = poo 100
-
--- | But `goo` succeeds if we add `chump` into the mix, because
---   it picks up the qualifers.
-
-{- chump :: z:Int -> {v:Int | v = z + 5} @-}
-chump   :: Int -> Int
-chump z = z + 5
-
-         
diff --git a/tests/pos/datacon-inv.hs b/tests/pos/datacon-inv.hs
deleted file mode 100644
--- a/tests/pos/datacon-inv.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Zoo where
-
-data T =  A | B
-
-{-@ invariant {v:T | (v = A || v = B)} @-}
-
-thisIsA = A
-thisIsB = B
diff --git a/tests/pos/datacon0.hs b/tests/pos/datacon0.hs
deleted file mode 100644
--- a/tests/pos/datacon0.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-module Range (llen) where
-
-import Language.Haskell.Liquid.Prelude
-
-data Foo a = F a a a 
-
-data LL a = N | C a (LL a)
-
-{-@ data LL [llen] @-} 
-
-
-{-@ measure llen @-}
-llen :: LL a -> Int 
-{-@ llen :: LL a -> Nat @-}
-llen N = 0 
-llen (C _ xs) = 1 + llen xs 
-
-lmap f N = N
-lmap f (C x xs) = C (f x) (lmap f xs)
-
-range :: Int -> Int -> LL Int
-range i j = C i N
-
-n = choose 0
-
-prop_rng1 = (liquidAssertB . (0 <=)) `lmap` range 0 n
-
---poo :: LL Int
-poo = C (1 :: Int) 
diff --git a/tests/pos/datacon1.hs b/tests/pos/datacon1.hs
deleted file mode 100644
--- a/tests/pos/datacon1.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module DC () where
-
-data Foo a = F a a a 
-
-z :: Foo Int
-z = F 1 2 3 
-
diff --git a/tests/pos/deepmeas0.hs b/tests/pos/deepmeas0.hs
deleted file mode 100644
--- a/tests/pos/deepmeas0.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-module DeepMeasure () where
-
-import Language.Haskell.Liquid.Prelude (liquidError)
-import Data.Set
-
-{-@ measure getfst :: (a, b) -> a
-    getfst (x, y) = x
-  @-}
-
-{-@ measure keys :: [(k, v)] -> (Set k) 
-    keys ([])   = {v | Set_emp v }
-    keys (x:xs) = {v | (v = (Set_cup (Set_sng (getfst x)) (keys xs))) }
-  @-}
-
-{-@ getKeys :: kvs:[(a, b)] -> {v:[a] | ((keys kvs) = (listElts v))} @-}
-getKeys []           = [] 
-getKeys ((x,_) : xs) = x : getKeys xs
-
-{-@ klookup :: forall k v. (Eq k) => k:k -> {v: [(k, v)] | (Set_mem k (keys v))} -> v @-}
-
-klookup k ((k',v):kvs)
-  | k == k'          = v
-  | otherwise        = klookup k kvs
-klookup _ []         = liquidError "Never!"
-
-
-
-
diff --git a/tests/pos/deptup.hs b/tests/pos/deptup.hs
deleted file mode 100644
--- a/tests/pos/deptup.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-module Deptup0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ data Pair a b <p :: x0:a -> x1:b -> Bool> = P {pX :: a, pY :: b<p pX> } @-}
-data Pair a b = P a b
-
-
-{-- TODO: mkP :: forall a b <p :: a -> b -> Bool>. x: a -> y: b<p x> -> Pair <p> a b  --}
-
-mkP :: a -> a -> Pair a a
-mkP x y = P x y
-
-incr x = x + 1
-
-baz x  = mkP x (incr x)
-
-chk (P x y) = liquidAssertB (x < y)
-
-prop = chk $ baz n
-  where n = choose 100
-
-
-bazList  xs = map baz xs
-
-n           = choose 0
-
-xs          = [0,1,2,3,4]
-
-prop_baz    = map chk $ bazList xs
diff --git a/tests/pos/deptup1.hs b/tests/pos/deptup1.hs
deleted file mode 100644
--- a/tests/pos/deptup1.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Deptup () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ data Pair a b <p :: x0:a -> x1:b -> Bool> = P {pX :: a, pY :: b<p pX> } @-}
-data Pair a b = P a b
-
-incr        :: Int -> Int
-incr x      = x + 1
-
-baz x       = P x (incr x)
-
-bazList xs  = map baz xs
-
-n           = choose 0
-xs          = [0..n]
-
-chk (P x y) = liquidAssertB (x < y)
-prop_baz    = map chk $ bazList xs
diff --git a/tests/pos/deptup3.hs b/tests/pos/deptup3.hs
deleted file mode 100644
--- a/tests/pos/deptup3.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Deptup () where
-
-import Language.Haskell.Liquid.Prelude
-
-data Pair a b = P a b
-
-incr :: Int -> Int
-incr x = x + 1
-
-baz    :: Int -> Pair Int Int
-baz x  = P x (incr x)
-
-n :: Int
-n           = choose 0
-
-prop_baz    = chk (baz n)
-
-chk :: Pair Int Int -> Bool
-chk (P x y) = liquidAssertB (x <= y)
diff --git a/tests/pos/deptupW.hs b/tests/pos/deptupW.hs
deleted file mode 100644
--- a/tests/pos/deptupW.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module Deptup0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ data Pair a b <p :: x0:a -> x1:b -> Bool> = P {pX :: a, pY :: b<p pX> } @-}
-data Pair a b = P a b
-
-{-@ mkP :: forall a <q :: y0:a -> y1:a -> Bool>. x: a -> y: a<q x> -> Pair <q> a a @-}
-mkP :: a -> a -> Pair a a
-mkP x y = P x y
-
-incr :: Int -> Int
-incr x = x + 1
-
-baz x = mkP x (incr x)
-
-chk :: Pair Int Int -> Bool
-chk (P x y) = liquidAssertB (x < y)
-
-prop = chk $ baz n
-  where n = choose 100
diff --git a/tests/pos/div000.hs b/tests/pos/div000.hs
deleted file mode 100644
--- a/tests/pos/div000.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Test0 (bar) where
-
-{-@ mydiv :: Int -> {v:Int | v /= 0} -> Int @-}
-mydiv :: Int -> Int -> Int
-mydiv = undefined
-
-foo :: Int -> Int
-foo _ = 12
-
-bar :: Int -> Int
-bar m = mydiv m z where z = foo m
diff --git a/tests/pos/dropwhile.hs b/tests/pos/dropwhile.hs
deleted file mode 100644
--- a/tests/pos/dropwhile.hs
+++ /dev/null
@@ -1,82 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--no-totality"    @-}
-
-module DropWhile where
-
-import Language.Haskell.Liquid.Prelude
-import Prelude hiding (head, dropWhile, (.), filter)
-
---main :: IO ()
-foo =  
-  if head (dropWhile ((/=) 3) (1:::2:::3:::Emp)) == 3
-     then ()
-     else liquidError "Not going to happen"
-
--------------------------------------------------------------------------------
--- | The `head` function returns a value that satisfies the abstract refinement
--------------------------------------------------------------------------------
-
-{-@ head ::  forall <p :: a -> Bool>. List <p> a -> a<p> @-}
-head (x ::: _) = x
-
--------------------------------------------------------------------------------
--- | A List 
--------------------------------------------------------------------------------
-
-data List a = Emp | (:::) { hd :: a
-                          , tl :: List a }
-infixr 5 :::
-
--------------------------------------------------------------------------------
--- | A list whose head satisfies an abstract refinement `p`
--------------------------------------------------------------------------------
-
--- in the below, `hd :: a<p>` means the "head" is a value of type `a` that
--- additionally, satisfies `p hd`.
-
-{-@ data List a <p :: a -> Bool> = Emp
-                                 | (:::) { hd :: a<p>
-                                         , tl :: List a }
-  @-}
-
--- | e.g. a list whose head equals `3`
-
-{-@ type OneList = List <{\v -> v == 3}> Int @-}
-
-{-@ one :: OneList @-}
-one :: List Int
-one = 3 ::: 2 ::: 1 ::: Emp
-
--------------------------------------------------------------------------------
--- | dropWhile some predicate `f` is not satisfied
--------------------------------------------------------------------------------
-
-{-@ dropWhile :: forall <p :: a -> Bool, w :: a -> Bool -> Bool>.
-                   {y::a, b::{v:Bool<w y> | not v} |- {v:a | v == y} <: a<p>}
-                   (x:a -> Bool<w x>) -> List a -> List <p> a
-  @-}
-dropWhile :: (a -> Bool) -> List a -> List a
-dropWhile f (x:::xs)
-  | not (f x)    = x ::: xs
-  | otherwise    = dropWhile f xs
-dropWhile f Emp  = Emp
-
--- | This `witness` bound relates the predicate used in dropWhile
-
-{-@ bound witness @-}
-witness :: Eq a => (a -> Bool) -> (a -> Bool -> Bool) -> a -> Bool -> a -> Bool
-witness p w = \ y b v -> (not b) ==> w y b ==> (v == y) ==> p v
-
--------------------------------------------------------------------------------
--- | Drop elements until you hit a `3`
--------------------------------------------------------------------------------
-
-{-@ dropUntilOne' :: List Int -> OneList @-}
-dropUntilOne' :: List Int -> List Int
-dropUntilOne' = dropWhile (/= 3)
-
--- | Currently needed for the qual; should be made redundant by `--eliminate`
-
-{-@ eqOne :: x:Int -> {v:Bool | v <=> x /= 3} @-}
-eqOne :: Int -> Bool
-eqOne x = x /= 3
diff --git a/tests/pos/duplicate-bind.hs b/tests/pos/duplicate-bind.hs
deleted file mode 100644
--- a/tests/pos/duplicate-bind.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Meas where
-
-import Language.Haskell.Liquid.Prelude
-
-insert key value [] = [(key, value)]
-insert _ _ _        = unsafeError ""
diff --git a/tests/pos/elements.hs b/tests/pos/elements.hs
deleted file mode 100644
--- a/tests/pos/elements.hs
+++ /dev/null
@@ -1,68 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-module Elems where
-
-import Prelude hiding (elem)
-
-import Data.Set (Set (..))
-
-{-@ append  :: xs:_ -> ys:_ -> {v:_ | UnElts v xs ys} @-}
-append [] ys     = ys
-append (x:xs) ys = x : append xs ys
-
-
-{-@ reverse :: xs:_ -> {v:_ | EqElts v xs} @-}
-reverse xs           = revAcc xs []
-  where
-   revAcc []     acc = acc
-   revAcc (x:xs) acc = revAcc xs (x:acc)
-
-
-
-{-@ nub :: (Eq a) => xs:_ -> {v:_ | nodups v && EqElts v xs} @-}
-nub xs             = go xs []
-  where
-    go (x:xs) l
-      | x `elem` l = go xs l
-      | otherwise  = go xs (x:l)
-    go [] l        = l
-
-
-{-@ elem :: (Eq a) => x:_ -> ys:_ -> {v:Bool | v <=> Set_mem x (elems ys)} @-}
-elem x []     = False
-elem x (y:ys) = x == y || elem x ys
-
-
-
-{-@ find :: (Eq a) => key:_ -> {map:_ | ValidKey key map} -> b @-}
-find key ((k,v):kvs)
-  | key == k  = v
-  | otherwise = find key kvs
-find _ []     = die "Lookup failed!"
-
-
-
-{-@ die :: {v:String | false} -> b @-}
-die x = error x
-
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-
-{-@ predicate ValidKey K M    = Set_mem K (keys M)                       @-}
-{-@ predicate EqElts Xs Ys    = elems Xs = elems Ys                      @-}
-{-@ predicate UnElts Xs Ys Zs = elems Xs = Set_cup (elems Ys) (elems Zs) @-}
-
-{-@ measure keys  :: [(a, b)] -> (Set a)
-    keys ([])     = (Set_empty 0)
-    keys (kv:kvs) = (Set_cup (Set_sng (fst kv)) (keys kvs))
-  @-}
-
-{-@ measure elems :: [a] -> (Set a)
-    elems ([])    = (Set_empty 0)
-    elems (x:xs)  = (Set_cup (Set_sng x) (elems xs))
-  @-}
-
-{-@ measure nodups :: [a] -> Bool
-    nodups ([])   = true
-    nodups (x:xs) = (not (Set_mem x (elems xs)) && nodups xs)
-  @-}
diff --git a/tests/pos/elems.hs b/tests/pos/elems.hs
deleted file mode 100644
--- a/tests/pos/elems.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Goo where
-
-import qualified Data.Set as S
-
-data T a = T a
-
-{-@ measure elems @-}
-elems       :: T a -> S.Set a
-elems (T a) = S.singleton a
-
-{-@ member :: x:a -> t:T a -> {v:Bool | v <=> S.member x (elems t)} @-}
-member :: a -> T a -> Bool
-member = undefined
diff --git a/tests/pos/elim-ex-compose.hs b/tests/pos/elim-ex-compose.hs
deleted file mode 100644
--- a/tests/pos/elim-ex-compose.hs
+++ /dev/null
@@ -1,11 +0,0 @@
--- TAG: absref 
-
-module ElimExCompose (prop) where
-
-{-@ prop :: x:Nat -> {v:Int | v = x + 5} @-}
-prop :: Int -> Int
-prop = incr . incr . incr . incr . incr
-
-{-@ incr :: dog:Int -> {v:Int | v == dog + 1} @-}
-incr :: Int -> Int
-incr cat = cat + 1
diff --git a/tests/pos/elim-ex-let.hs b/tests/pos/elim-ex-let.hs
deleted file mode 100644
--- a/tests/pos/elim-ex-let.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExLet (prop) where
-
-import LiquidHaskell
-
-[lq| type Nat = {v:Int | 0 <= v} |]
-
-[lq| prop :: a -> Nat |]
-prop _ = let x _ = let y = 0 
-                   in
-                     y - 1
-         in 
-           x () + 2
diff --git a/tests/pos/elim-ex-list.hs b/tests/pos/elim-ex-list.hs
deleted file mode 100644
--- a/tests/pos/elim-ex-list.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExList (prop) where
-
-import LiquidHaskell
-import Prelude hiding (head)
-
---------------------------------------------------------------------------
-[lq| prop :: a -> Even |]
-prop _ = (head ys) - 1
-  where 
-    ys = Cons 1 (Cons 3 (Cons 5 Nil))
---------------------------------------------------------------------------
-
-[lq| type Even = {v:Int | v mod 2 == 0 } |]
-
-data List a = Nil | Cons a (List a)
-
-head :: List a -> a 
-head (Cons x _) = x
-
diff --git a/tests/pos/elim-ex-map-1.hs b/tests/pos/elim-ex-map-1.hs
deleted file mode 100644
--- a/tests/pos/elim-ex-map-1.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExMap (prop) where
-
-import LiquidHaskell
-
-import Prelude hiding (map)
-
---------------------------------------------------------------------------
-[lq| prop :: List Even -> List Even |]
-prop xs = map (+ 1) (map (+ 1) xs)
---------------------------------------------------------------------------
-
-[lq| type Even = {v:Int | v mod 2 == 0 } |]
-
-data List a = Nil | Cons a (List a)
-
-map f Nil         = Nil
-map f (Cons x xs) = Cons (f x) (map f xs)
diff --git a/tests/pos/elim-ex-map-2.hs b/tests/pos/elim-ex-map-2.hs
deleted file mode 100644
--- a/tests/pos/elim-ex-map-2.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExMap (prop) where
-
-import LiquidHaskell
-
-import Prelude hiding (map)
-
---------------------------------------------------------------------------
-[lq| prop :: List Even -> List Even |]
-prop = map (+ 1) . map (+ 1)
---------------------------------------------------------------------------
-
-[lq| type Even = {v:Int | v mod 2 == 0 } |]
-
-data List a = Nil | Cons a (List a)
-
-map f Nil         = Nil
-map f (Cons x xs) = Cons (f x) (map f xs)
diff --git a/tests/pos/elim-ex-map-3.hs b/tests/pos/elim-ex-map-3.hs
deleted file mode 100644
--- a/tests/pos/elim-ex-map-3.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-{-# LANGUAGE QuasiQuotes #-}
-
-module ElimExMap (prop) where
-
-import LiquidHaskell
-
-import Prelude hiding (map)
-
---------------------------------------------------------------------------
-[lq| prop :: List Even -> List Even |]
-prop = map ((+ 1) . (+ 1))
---------------------------------------------------------------------------
-
-[lq| type Even = {v:Int | v mod 2 == 0 } |]
-
-data List a = Nil | Cons a (List a)
-
-map f Nil         = Nil
-map f (Cons x xs) = Cons (f x) (map f xs)
diff --git a/tests/pos/elim00.hs b/tests/pos/elim00.hs
deleted file mode 100644
--- a/tests/pos/elim00.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-{-@ LIQUID "--short-names"  @-}
-
-module Elim where
-
-data Pair a b = PP a b | Emp
-
-data Foo = Foo { xx :: Int, yy :: Int }
-
-{-@ data Foo = Foo {xx :: Int, yy :: {v:Int | xx < v} }  @-}
-
-foo :: Foo -> Foo
-foo (Foo xig yog) = Foo wink cow
-  where
-    PP wink cow   = PP xig yog
-
diff --git a/tests/pos/elim01.hs b/tests/pos/elim01.hs
deleted file mode 100644
--- a/tests/pos/elim01.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module EliminateCuts (bar) where
-
-{-@ bar :: n:{Int | n > 0} -> {v:Int | v = n + 4 } @-}
-bar :: Int -> Int 
-bar n0 = let 
-            n1 = if (n0 == 0) then 0 else 1 + n0
-            n2 = if (n1 == 0) then 0 else 1 + n1
-            n3 = if (n2 == 0) then 0 else 1 + n2
-            n4 = if (n3 == 0) then 0 else 1 + n3
-         in 
-            n4
diff --git a/tests/pos/eq-poly-measure.hs b/tests/pos/eq-poly-measure.hs
deleted file mode 100644
--- a/tests/pos/eq-poly-measure.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Pair () where 
-
-import Language.Haskell.Liquid.Prelude 
-
-{-@ data Thing a = P (unThing :: a) @-} 
-data Thing a = P a
-
-property :: Bool
-property = chk t1 
-  where 
-  chk (P x) = liquidAssertB x 
-
-  t1 :: Thing Bool 
-  t1 = P True 
diff --git a/tests/pos/eqelems.hs b/tests/pos/eqelems.hs
deleted file mode 100644
--- a/tests/pos/eqelems.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Goo where
-
-import qualified Data.Set as S
-
-data T a = T a
-
-{-@ measure elems @-}
-elems       :: T a -> S.Set a
-elems (T a) = S.singleton a
-
-{-@ inline eqelems @-}
-eqelems :: Eq a => T a -> T a -> Bool
-eqelems s t = (elems s) == (elems t)
-         
diff --git a/tests/pos/ex0.hs b/tests/pos/ex0.hs
deleted file mode 100644
--- a/tests/pos/ex0.hs
+++ /dev/null
@@ -1,41 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-{-@ LIQUID "--no-termination" @-}
-
-module Ex  where
-
--- Testing "existential-types"
-
-{-@ foldN :: forall a <p :: x0:Int -> x1:a -> Bool>. 
-                (i:Int -> a<p i> -> a<p (i+1)>) 
-              -> n:{v: Int | v >= 0}
-              -> a <p 0> 
-              -> a <p n>
-  @-}
-
-foldN :: (Int -> a -> a) -> Int -> a -> a
-foldN f n = go 0 
-  where 
-    go i x 
-      | i < n     = go (i+1) (f i x)
-      | otherwise = x
-
-{-@ goo :: forall a <pig :: x0:Int -> x1:a -> Bool>. 
-                (i:Int -> a<pig i> -> a<pig (i+1)>) 
-              -> i:{v: Int | 0 <= v}
-              -> n:{v: Int | i <= v}
-              -> a <pig i> 
-              -> a <pig n>
-  @-}
-
-goo :: (Int -> a -> a) -> Int -> Int -> a -> a
-goo f i n x 
-  | i < n     = goo f (i+1) n (f i x) 
-  | otherwise = x
-
-
-
-
-{-@ count :: m: {v: Int | v > 0 } -> {v: Int | v = m} @-}
-count :: Int -> Int
-count m = foldN (\_ n -> n + 1) m 0
-
diff --git a/tests/pos/ex01.hs b/tests/pos/ex01.hs
deleted file mode 100644
--- a/tests/pos/ex01.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-
--- | A somewhat fancier example demonstrating the use of Abstract Predicates and exist-types
-
-module Ex () where
-
-
--------------------------------------------------------------------------
--- | Data types ---------------------------------------------------------
--------------------------------------------------------------------------
-
-data Vec a = Nil 
-
-{-@ efoldr :: forall b a <p :: x0:Vec a -> x1:b -> Bool>. 
-              b <p Ex.Nil>
-              -> ys: Vec a
-              -> b <p ys>
-  @-}
-efoldr :: b -> Vec a -> b
-efoldr b Nil         = b
-
diff --git a/tests/pos/ex1.hs b/tests/pos/ex1.hs
deleted file mode 100644
--- a/tests/pos/ex1.hs
+++ /dev/null
@@ -1,64 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-
--- | A somewhat fancier example demonstrating the use of Abstract Predicates and exist-types
-
-module Ex (llen) where
-
--------------------------------------------------------------------------
--- | Data types ---------------------------------------------------------
--------------------------------------------------------------------------
-
-data Vec a = Nil | Cons a (Vec a)
-
-{-@ data Vec [llen] a = Nil | Cons { vx::a, vxs :: Vec a } @-}
-
--- | We can encode the notion of length as an inductive measure @llen@
-
-{-@ measure llen @-}
-llen :: Vec a -> Int
-llen (Nil)       = 0
-llen (Cons x xs) = 1 + llen xs
-
-
--- | As a warmup, lets check that a /real/ length function indeed computes
--- the length of the list.
-
-{-@ sizeOf :: xs:Vec a -> {v: Int | v = llen xs} @-}
-sizeOf             :: Vec a -> Int
-sizeOf Nil         = 0
-sizeOf (Cons _ xs) = 1 + sizeOf xs
-
--------------------------------------------------------------------------
--- | Higher-order fold --------------------------------------------------
--------------------------------------------------------------------------
-
--- | Time to roll up the sleeves. Here's a a higher-order @foldr@ function
--- for our `Vec` type. Note that the `op` argument takes an extra /ghost/
--- parameter that will let us properly describe the type of `efoldr`
-
-{-@ efoldr :: forall a b <p :: x0:Vec a -> x1:b -> Bool>.
-                (xs:Vec a -> x:a -> b <p xs> -> b <p (Ex.Cons x xs)>)
-              -> b <p Ex.Nil>
-              -> ys: Vec a
-              -> b <p ys>
-  @-}
-efoldr :: (Vec a -> a -> b -> b) -> b -> Vec a -> b
-efoldr op b Nil         = b
-efoldr op b (Cons x xs) = op xs x (efoldr op b xs)
-
--------------------------------------------------------------------------
--- | Clients of `efold` -------------------------------------------------
--------------------------------------------------------------------------
-
--- | Finally, lets write a few /client/ functions that use `efoldr` to
--- operate on the `Vec`s.
-
--- | First: Computing the length using `efoldr`
-{-@ size :: xs:Vec a -> {v: Int | v = llen xs} @-}
-size :: Vec a -> Int
-size = efoldr (\_ _ n -> n + 1) 0
-
--- | Second: Appending two lists using `efoldr`
-{-@ app  :: xs: Vec Int -> ys: Vec Int -> {v: Vec Int | llen v = llen xs + llen ys } @-}
-app :: Vec Int -> Vec Int -> Vec Int
-app xs ys = efoldr (\_ z zs -> Cons z zs) ys xs
diff --git a/tests/pos/exp0.hs b/tests/pos/exp0.hs
deleted file mode 100644
--- a/tests/pos/exp0.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-
--- small test for playing around with exports.
-
-module Moo (f) where
-
-import Language.Haskell.Liquid.Prelude
-
-data Goo = G Int
-
-{-@ data Goo = G (x :: {v:Int | v > 0}) @-}
-
-{-@ f :: Goo -> Goo @-} 
-f (G n) 
-  | n > 0     = G (n +  1)
-  | otherwise = liquidError "ad"
-
diff --git a/tests/pos/extype.hs b/tests/pos/extype.hs
deleted file mode 100644
--- a/tests/pos/extype.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-{-# LANGUAGE ExistentialQuantification, MultiParamTypeClasses #-}
-module ExTy where
-
-class Show (layout a) => LayoutClass layout a where
-
-data Layout a = forall l. Layout (l a)
-
-
-readsLayout :: Layout a -> String -> Layout a
-readsLayout (Layout l) s = Layout (asTypeOf undefined l)
-
-type Size = Int
-data Step s a = S s a
-
-data Stream a =
-    forall s. Stream
-    (s -> Step s a)             -- stepper function
-    !s                          -- current state
-    !Size                       -- size hint
-
-
-foo :: Stream a -> Size
-foo (Stream _ _ s) = s
-
-
-stream = Stream (\_ -> S 1 True) 0 0
diff --git a/tests/pos/failName.hs b/tests/pos/failName.hs
deleted file mode 100644
--- a/tests/pos/failName.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Crash where
-
-bar = fail
-  where fail = foo
-        foo = 3 -- undefined
-
-
-bar1 = fail ()
-  where fail = foo
-        foo = undefined
diff --git a/tests/pos/filterAbs.hs b/tests/pos/filterAbs.hs
deleted file mode 100644
--- a/tests/pos/filterAbs.hs
+++ /dev/null
@@ -1,45 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-
-
-
-module Filter where
-
-import Prelude hiding (filter)
-
-{-@ filter :: forall <p :: a -> Bool, q :: a -> Bool -> Bool>.
-                  {y::a, flag::{v:Bool<q y> | v} |- {v:a | v = y} <: a<p>}
-                  (x:a -> Bool<q x>) -> [a] -> [a<p>]
-  @-}
-
-filter :: (a -> Bool) -> [a] -> [a]
-filter f (x:xs)
-  | f x       = x : filter f xs
-  | otherwise = filter f xs
-filter _ []   = []
-
-{-@ isPos :: x:Int -> {v:Bool | v <=> x > 0} @-}
-isPos :: Int -> Bool
-isPos n = n > 0
-
-
-{-@ isNeg :: x:Int -> {v:Bool | v <=> x < 0} @-}
-isNeg :: Int -> Bool
-isNeg n = n < 0
-
-
--- | `positives` works by instantiating:
--- p := \v   -> 0 < v
--- q := \x v -> v <=> 0 < x  (NV ??)
-
-
-{-@ positives :: [Int] -> [{v:Int | v > 0}] @-}
-positives xs = filter isPos xs
-
-
--- | `negatives` works by instantiating:
--- p := \v   -> 0 > v
--- q := \x v -> v <=> x < 0
-
-{-@ negatives :: [Int] -> [{v:Int | v < 0}] @-}
-negatives xs = filter isNeg xs
diff --git a/tests/pos/foldN.hs b/tests/pos/foldN.hs
deleted file mode 100644
--- a/tests/pos/foldN.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-{-@ LIQUID "--no-termination" @-}
-
-module Ex () where
-
--- Testing "existential-types"
-
-{-@ foldN :: forall a <p :: x0:Int -> x1:a -> Bool>. 
-                (i:Int -> a<p i> -> a<p (i+1)>) 
-              -> n:{v: Int | v >= 0}
-              -> a <p 0> 
-              -> a <p n>
-  @-}
-
-foldN :: (Int -> a -> a) -> Int -> a -> a
-foldN f n = go 0 
-  where go i x | i < n     = go (i+1) (f i x)
-               | otherwise = x
diff --git a/tests/pos/foldr.hs b/tests/pos/foldr.hs
deleted file mode 100644
--- a/tests/pos/foldr.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Foldr where
-
-import Language.Haskell.Liquid.Prelude
-import Data.List (foldl')
-
-foo ::  a -> b -> c -> d
-foo = \_ _ _ -> unsafeError "False" 
-
-bar ::  p -> [(q, r)] -> p
-bar = foldr (\(k, v) -> foo k v)
diff --git a/tests/pos/for.hs b/tests/pos/for.hs
deleted file mode 100644
--- a/tests/pos/for.hs
+++ /dev/null
@@ -1,32 +0,0 @@
-module For (prop, prop2, even_, minifac) where
-
-{-@ LIQUID "--no-termination-check" @-}
-
-import Language.Haskell.Liquid.Prelude
-
-even_ arg = if arg == 0 then True else odd_ (arg - 1)
-
-odd_  arg = if arg == 0 then False else even_ (arg - 1)
-
-mmax x y 
-  | x < y     = y
-  | otherwise = x
-
-minifac foobar 
-  | foobar > 1 =  minifac (foobar - 1)
-  | otherwise  =  1
-
-for lo hi acc f 
-  | lo < hi   = for (lo + 1) hi (f lo acc) f
-  | otherwise = acc 
-
-sumRange i j = for i j 0 (+)
-
-prop = liquidAssertB (m >= 0)
-  where m = sumRange 0 k
-        k = choose 0
-
-prop2 = liquidAssertB (z >= x && z >= y)
-  where x = choose 0
-        y = choose 1
-        z = mmax x y
diff --git a/tests/pos/forloop.hs b/tests/pos/forloop.hs
deleted file mode 100644
--- a/tests/pos/forloop.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-module Vec1 () where
-
-{-@ LIQUID "--no-termination" @-}
-import Language.Haskell.Liquid.Prelude
-
-mmax x y 
-  | x < y     = y
-  | otherwise = x
-
-for lo hi acc f 
-  | lo < hi   = for (lo + 1) hi (f lo acc) f
-  | otherwise = acc 
-
-sumRange i j = for i j 0 (+)
-
-prop = liquidAssertB (m >= 0)
-  where m = sumRange 0 k
-        k = choose 0
-
-prop2 = liquidAssertB (z >= x && z >= y)
-  where x = choose 0
-        y = choose 1
-        z = mmax x y
diff --git a/tests/pos/gadtEval.hs b/tests/pos/gadtEval.hs
deleted file mode 100644
--- a/tests/pos/gadtEval.hs
+++ /dev/null
@@ -1,91 +0,0 @@
-
-module Eval () where 
-
-import Language.Haskell.Liquid.Prelude (liquidError)
-
--- "Classic" GADT 
--- 
--- data Expr a where
---   I :: Int -> Expr Int
---   B :: Bool -> Expr Bool
---   Eq :: Expr a -> Expr a -> Expr Bool
---   Pl :: Expr Int -> Expr Int -> Expr Int
--- 
--- eval :: Expr a -> a
--- eval (I i)      = i
--- eval (B b)      = b
--- eval (Eq e1 e2) = (eval e1) == (eval e2)
--- eval (Pl e1 e2) = (eval e1) + (eval e2)
-
-data Ty   = TInt 
-          | TBool
-
-data Expr = I     Int
-          | B     Bool
-          | Equal Expr Expr
-          | Plus  Expr Expr
-          deriving (Eq, Show)
-
-
-{-@ check          :: e:ValidExpr  -> {v:Ty | (v = (eType e))} @-}
-check (I _)        = TInt
-check (B _)        = TBool
-check (Plus e1 e2) = TInt
-check (Equal _ _)  = TBool
-
-{-@ lazy eval @-}
-
-{-@ eval           :: e:ValidExpr  -> {v:ValidExpr | ((isValue v) && (((eType e) = (eType v))))} @-}
-eval e@(I _)       = e
-eval e@(B _)       = e
-eval (Plus e1 e2)  = (eval e1) `plus` (eval e2)
-eval (Equal e1 e2) = (eval e1) `equal` (eval e2)
-
-plus (I i) (I j)   = I (i + j)
-plus _       _     = liquidError "don't worry, its impossible" 
-
-equal (I i) (I j)  = B (i == j)
-equal (B x) (B y)  = B (x == y)
-equal _       _    = liquidError "don't worry, its impossible" 
-
--- | The next two are silly, for scraping quals. Yuck. Should scrape from measure-DEFS etc.
-
-{-@ toInt :: IntExpr -> Int @-}
-toInt (I i) = i
-toInt _     = liquidError "impossible"
-
-{-@ toBool :: BoolExpr -> Bool @-}
-toBool (B b) = b
-toBool _     = liquidError "impossible"
-
-
-{-@ predicate IsTInt X   = ((eType X) = TInt)  @-}
-{-@ predicate IsTBool X  = ((eType X) = TBool) @-}
-
-
-{-@ type ValidExpr     = {v: Expr | (isValid v)}                @-}
-{-@ type IntExpr       = {v: Expr | ((isValue v) && (IsTInt  v))} @-}
-{-@ type BoolExpr      = {v: Expr | ((isValue v) && (IsTBool v))} @-}
-
-
-{-@ measure isValue       :: Expr -> Bool
-    isValue (I i)         = true
-    isValue (B b)         = true
-    isValue (Equal e1 e2) = false 
-    isValue (Plus e1 e2)  = false
-  @-}  
-
-{-@ measure eType       :: Expr -> Ty 
-    eType (I i)         = TInt  
-    eType (Plus  e1 e2) = TInt 
-    eType (B b)         = TBool 
-    eType (Equal e1 e2) = TBool 
-  @-}
-
-{-@ measure isValid       :: Expr -> Bool
-    isValid (I i)         = true
-    isValid (B b)         = true
-    isValid (Equal e1 e2) = (((eType e1) = (eType e2)) && (isValid e1) && (isValid e2))
-    isValid (Plus e1 e2)  = ((IsTInt e1) && (IsTInt e2) && (isValid e1) && (isValid e2))
-  @-}
-
diff --git a/tests/pos/gimme.hs b/tests/pos/gimme.hs
deleted file mode 100644
--- a/tests/pos/gimme.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Blank () where
-
-import Language.Haskell.Liquid.Prelude
-
-{- qualif Gimme(v:[a], n:int, acc:[a]): (len v == n + 1 + len acc) -}
-
-{-@ gimme :: xs:[a] -> n:Int -> acc:[a] -> {v:[a] | len v = n + 1 + len acc} @-}
-gimme :: [a] -> Int -> [a] -> [a]
-gimme xs (-1) acc  = acc
-gimme (x:xs) n acc = gimme xs (n-1) (x : acc)
-gimme _ _ _        = unsafeError "gimme"
-
-{-@ boober :: n:Int -> Int -> {v:[Int] | (len v) = n} @-}
-boober :: Int -> Int -> [Int]
-boober n y = gimme [y..] (n-1) []
diff --git a/tests/pos/go.hs b/tests/pos/go.hs
deleted file mode 100644
--- a/tests/pos/go.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Moo (poop) where
-
-{-@ invariant {v:Int | v >= 0} @-}
-
-{-@ qualif Sum(v:Int, x: Int, y: Int): v = x + y @-}
-
-{-@ invariant {v:Int | v >= 0} @-}
-
-{-@ foo  :: x:Int -> {v:Int | v = x} @-}
-foo x    = go x 0
-  where 
-    go     :: Int -> Int -> Int 
-    go 0 m = m
-    go n m = go (n-1) (m+1)
-
-
-poop x = foo x 
-
-
-
diff --git a/tests/pos/go_ugly_type.hs b/tests/pos/go_ugly_type.hs
deleted file mode 100644
--- a/tests/pos/go_ugly_type.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-{- decrease go 2 @-}
-
-{-@ rev :: xs:[a] -> {v: [a] | len v = len xs} @-}
-rev = go [] 
-  where 
-    {-@ go :: acc:_ -> xs:_ -> {v:_ | len v = len acc + len xs} @-}
-    go acc []     = acc
-    go acc (x:xs) = go (x:acc) xs
-
-main :: IO ()
-main = pure ()
diff --git a/tests/pos/grty0.hs b/tests/pos/grty0.hs
deleted file mode 100644
--- a/tests/pos/grty0.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Test () where
-
-{-@ stupid :: Int -> Int @-}
-stupid :: Int -> Int
-stupid x = 0
-
-{-@ myId :: x:a -> {v:a | v = x } @-}
-myId x = x 
-
-{-@ assert single :: a -> {v: [a] | len(v) > 0} @-}
-single x = [x] 
-
-
diff --git a/tests/pos/grty1.hs b/tests/pos/grty1.hs
deleted file mode 100644
--- a/tests/pos/grty1.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Test () where
-import Language.Haskell.Liquid.Prelude 
-
-{-@ sz :: {v:[a]|((len v) = 1)} -> a @-}
--- sz (x:xs) = sz xs
-sz [x]    = x
-
-{-@ poo :: [a] -> a @-}
-poo (x:xs) = poo xs
-poo [x]    = x
-poo _      = unsafeError "poo"
diff --git a/tests/pos/grty2.hs b/tests/pos/grty2.hs
deleted file mode 100644
--- a/tests/pos/grty2.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Test () where
-
-{-@ foo :: {vv:[{v:[a]|((len v) = 1)}]|((len vv)= 1)} -> [[a]] @-}
-foo [[x]] = [[x]]
-
-
-
diff --git a/tests/pos/grty3.hs b/tests/pos/grty3.hs
deleted file mode 100644
--- a/tests/pos/grty3.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Test () where
-
-{-@ bar :: (a, {v:[b]|((len v) = 1)}) -> b @-}
-bar (_, [x]) = x
-
-
-
diff --git a/tests/pos/hello.hs b/tests/pos/hello.hs
deleted file mode 100644
--- a/tests/pos/hello.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-@ LIQUID "-v" @-}
-
-module Hello () where
-
-{-@ abz :: (Num a, Ord a) => x:a -> {v: a | v >= x} @-}
-abz x   = if (x > 0) then x else (0 - x)  
-
-{-@ incr :: (Num a) => x:a -> {v: a | v > x}        @-}
-incr x  = x + 1 
-
-{-@ decr :: (Num a) => x:a -> {v: a | v < x}        @-}
-decr x  = x - 1 
-
-
diff --git a/tests/pos/hole-app.hs b/tests/pos/hole-app.hs
deleted file mode 100644
--- a/tests/pos/hole-app.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Zoo where
-
-{-@ type Vec a N = {v:[a] | len v = N } @-}
-
-{-@ ok :: Vec Int 3 @-}
-ok = [1,2,3] :: [Int]
-
-{-@ ok' :: Vec _ 3 @-}  -- would be nice to support the hole in the application..
-ok'     = [1,2,3]
-
-
-
diff --git a/tests/pos/hole-fun.hs b/tests/pos/hole-fun.hs
deleted file mode 100644
--- a/tests/pos/hole-fun.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Zoo (test) where
-
-inc :: Int -> Int 
-inc x = x + 1
-
-{-@ app :: _ -> Nat -> Nat @-} 
-app :: (Int -> Int) -> Int -> Int
-app f x = f x
-
-test = app inc 7
diff --git a/tests/pos/idNat.hs b/tests/pos/idNat.hs
deleted file mode 100644
--- a/tests/pos/idNat.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module IdNat where 
-
-{-@ nat :: Nat @-}
-nat :: Int
-nat = id 0 -- (id (id (id (id 0))))
diff --git a/tests/pos/idNat0.hs b/tests/pos/idNat0.hs
deleted file mode 100644
--- a/tests/pos/idNat0.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module IdNat where 
-
-{-@ nat :: Nat @-}
-nat :: Int
-nat = idd 0 
-
-idd :: a -> a
-idd = undefined 
diff --git a/tests/pos/imp0.hs b/tests/pos/imp0.hs
deleted file mode 100644
--- a/tests/pos/imp0.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Import0 () where
-
-import Language.Haskell.Liquid.Prelude
-import Foreign.Storable
-
--- ERROR goes away if we:
--- import Language.Haskell.Liquid.Foreign
-
--- We shouldn't have to do so since, 
---   include/Foreign/Storable.Spec
--- has the line:
---   import Language.Haskell.Liquid.Foreign
-
--- HYPOTHESIS: the import in the spec file above ONLY
---             imports other .spec files... and hence 
---             ignores include/Language/Haskell/Liquid/Foreign.hs 
-
-{-@ inc :: x:Nat -> {v:Nat | v > x} @-}
-inc :: Int -> Int
-inc x = x + 1
diff --git a/tests/pos/implies.hs b/tests/pos/implies.hs
deleted file mode 100644
--- a/tests/pos/implies.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Imp where
-
-{-@ inline implies @-}
-implies p q = (not p) || q
-
diff --git a/tests/pos/infix.hs b/tests/pos/infix.hs
deleted file mode 100644
--- a/tests/pos/infix.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-{-@ (!) :: zogbert:{v: Int | v > 0} -> {v: Int | v > 0} -> Int @-}
-(!) :: Int -> Int -> Int
-x ! y = x + y
-
-
-{-@ (!!) :: {v: Int | v > 0} -> {v: Int | v > 0} -> Int @-}
-(!!)   :: Int -> Int -> Int 
-x !! y = liquidAssert (x /= 0) $ x + y 
-
-{-@ zoo :: {v: Int | v > 0} -> {v: Int | v > 0} -> Int @-}
-zoo   :: Int -> Int -> Int 
-zoo x y = liquidAssert (x /= 0) $ x + y 
-
-
diff --git a/tests/pos/inline.hs b/tests/pos/inline.hs
deleted file mode 100644
--- a/tests/pos/inline.hs
+++ /dev/null
@@ -1,39 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-module Fixme where
-
-{-@ inline eqq @-}
-eqq :: Ord a => a -> a -> Bool
-eqq x y = x > y
-
-{-@ eqqtest :: Eq a => x:a -> y:a -> {v:Bool | v <=> (eqq x y) } @-}
-eqqtest :: Ord a => a -> a -> Bool
-eqqtest x y = x > y
-
-{-@ inline mymax @-}
-mymax :: Ord a => a -> a -> a
-mymax x y = if x >= y then x else y
-
-{-@ inline mymin @-}
-mymin :: Ord a => a -> a -> a
-mymin x y = mymax y x
-
-{-@ measure foo @-}
-foo :: Ord a => D a -> a
-foo (D x y) = mymax x y
-foo (F x)   = x
-
-{-@ measure bar @-}
-bar :: Ord a => D a -> a
-bar (D x y) = mymax x y
-
-{-@ measure bar2 @-}
-bar2 :: Ord a => D a -> a
-bar2 (D x y) = mymin y x
-
-foooo = D
-
-data D a = D a a | F a
-
-{-@ mymax3, mymax :: x:a -> y:a -> {v:a | v = mymax x y} @-}
-mymax3 :: Ord a => a -> a -> a
-mymax3 x y = if x >= y then x else y
diff --git a/tests/pos/inline1.hs b/tests/pos/inline1.hs
deleted file mode 100644
--- a/tests/pos/inline1.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module InlineMeasure where
-
-data Zoo a = Z { elts :: [a], sz :: Int }
-
--- | this is not ok (unbound symbol `boo`)
-{-@ data Zoo a = Z { elts :: [a], sz :: {v: Int | isBoo v elts} } @-}
-
-{-@ inline isBoo @-}
-isBoo :: Int -> [a] -> Bool
-isBoo v e = v == boo e
-
-{-@ type Moo a = {v:Zoo a | sz v = boo (elts v)} @-}
-
-{-@ inline boo @-}
-boo    :: [a] -> Int
-boo xs = 0
diff --git a/tests/pos/invlhs.hs b/tests/pos/invlhs.hs
deleted file mode 100644
--- a/tests/pos/invlhs.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Foo where
-
-data Bob = B {foo :: Int}
-{-@ data Bob = B {foo :: Int} @-}
-
-{-@ foo :: x:Bob -> {v:Int | v = foo x} @-}
-
-{-@ invariant {v:Bob | foo v == 10} @-}
-
-mk :: a -> Bob
-mk = undefined
-
-{-@ propFAIL :: {v:_ | foo v = 10} @-}
-propFAIL = mk ()
-
-{-@ propOK :: {v:_ | foo v = 10} @-}
-propOK = let z = mk () in z 
-
-
diff --git a/tests/pos/ite.hs b/tests/pos/ite.hs
deleted file mode 100644
--- a/tests/pos/ite.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test0 () where
-
-{-@ assert myabs :: x:Int -> {v: Int | if x > 0 then v = x else v + x = 0 } @-}
-myabs :: Int -> Int
-myabs x | x > 0     = x
-        | otherwise = (0 - x)
diff --git a/tests/pos/ite1.hs b/tests/pos/ite1.hs
deleted file mode 100644
--- a/tests/pos/ite1.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test0 () where
-
-{-@ assert myabs :: x:Int -> {v: Int | v = (if x > 0 then x else (0 - x)) } @-}
-myabs :: Int -> Int
-myabs x | x > 0     = x
-        | otherwise = (0 - x)
diff --git a/tests/pos/jeff.hs b/tests/pos/jeff.hs
deleted file mode 100644
--- a/tests/pos/jeff.hs
+++ /dev/null
@@ -1,261 +0,0 @@
-{-
-
-This code implements a Monoid for string matching; i.e. a data
-structure, MatchIdxs, which has the result of a string match function
-plus a little extra information for monoidally combining things
-together; the purpose of course is to parallelize string matching
-computations. This is the original version I wrote which uses type
-level strings to guarantee that only computations done with the same
-target string are combinable.
-
-The invariants I'd like to prove are in the comments on the MatchIdxs
-constructors. I'd be interested in a way to do it directly with this
-code (though it seems that would require extending LH), or doing it in
-a version of this code where the constructors have an extra argument
-with the value of the target-- however that formulation seems to raise
-issues about forcing those values to be the same.
-
-I have a version of the code lying around which tries this approach,
-but I couldn't get it to work. I chose to send this version first so
-you have the chance to see where I started; I could send you my version
-with the explicit terms if you like.
-
-If this goes well, then there are a couple of further things to think
-about:
-
-  1) I have another Monoid construction for actual splitting, but
-     I don't think LH can handle the invariants as they require an
-     isInfixOf operation; but I could be wrong about what LH can do.
-
-  2) It would be interesting to think about whether one can encode
-     correctness, rather than just some invariants. By correctness
-     I mean both that the monoid laws are satisfied, and that there
-     is a homomorphic-like property to the effect of:
-
-     match (x <> y) == match x <> match y
-
-Let me know if you have any questions about the code, or need more
-comments/explanation.
--}
-
-
-{- LIQUID "--diff" @-}
-{-@ LIQUID "--scrape-used-imports" @-}
-{-@ LIQUID "--short-names" @-}
-
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE DeriveAnyClass #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module MatchIdxs where
-
-import qualified Data.ByteString as BS
--- RJ import qualified Data.ByteString.Search as BS
-import Data.Char
--- RJ import Data.List.Split(chunksOf)
-
-import Data.Monoid
-import Data.Proxy
-import Debug.Trace
-import GHC.TypeLits
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-import Prelude hiding (head, min, max)
-
-junk = BS.head
-
-
-traceMsg msg x = trace (msg ++ show x) x
-
-{-@ chunksBS :: Int -> b:BS.ByteString -> [BS.ByteString] / [(bLength b)] @-}
-chunksBS n' xs | BS.null xs = []
-               | otherwise = x : chunksBS n xs'
-    where (x,xs') = BS.splitAt  (liquidAssert (n > 0) n) xs
-          n       = max 1 n'
-
-bsToString :: BS.ByteString -> String
-bsToString = map (chr . fromIntegral) . BS.unpack
-
-stringToBS :: String -> BS.ByteString
-stringToBS = BS.pack . map (fromIntegral . ord)
-
--- | get the (proxied and existentially boxed) type level Symbol for a bytestring
-someSymbolValBS :: BS.ByteString -> SomeSymbol
-someSymbolValBS = someSymbolVal . bsToString
-
--- | get the bytestring corresponding to a type level Symbol
-mkTarg :: forall t . KnownSymbol t => Proxy t -> BS.ByteString
-mkTarg = stringToBS . symbolVal
-
-
--- | Naive specification of string matching (from Bird)
-{-@ indicesSpec :: t:ByteStringNE -> s:BS.ByteString -> [OkPos t s] @-}
--- indicesSpec targ = map ((BS.length targ -) . BS.length) . filter (targ `BS.isSuffixOf`) . BS.inits
-indicesSpec targ s = [ BS.length s' - BS.length targ | s' <- BS.inits s
-                                                     , targ `BS.isSuffixOf` s' ]
-
-indicesSpec :: BS.ByteString -> BS.ByteString -> [Int]
-
-
-
--- | Datatype to name string matching algorithms; will use it's lifted
--- version put choice in type.
-data Alg = BM  -- ^ Boyer-Moore from stringsearch package
-         | Spec  -- ^ Naive spec
-
-{-@ indices :: Alg -> t:ByteStringNE -> s:BS.ByteString -> [OkPos t s] @-}
-indices BM   = assumeIndices -- RJ BS.indices
-indices Spec = indicesSpec
-
-
--- | Monoid
---
--- 'MatchIdxs alg targ' denotes the result of running string matching
--- algorithm 'alg' search for target 'targ' in some input. In addition
--- to the match indices, information needed to combine this result
--- with similar results on input to the left and right are also
--- included.
---
--- We'd like to prove that the invariants in the comments hold (|x|
--- denotes the length of x).
-data MatchIdxs
-    = Small { targ :: BS.ByteString
-            , bs   :: BS.ByteString
-            }
-    | MatchIdxs { targ    :: BS.ByteString
-                , input   :: Int
-                , left    :: BS.ByteString
-                , matches :: [Int]
-                , right   :: BS.ByteString
-                }
-  deriving (Eq, Show)
-
-{-@ data MatchIdxs
-      = Small { targ    :: ByteStringNE
-              , bs      :: {b:BS.ByteString | bLength b < bLength targ}
-              }
-
-      | MatchIdxs
-              { targ    :: ByteStringNE
-              , input   :: {i  : Int | i >= bLength targ}
-              , left    :: {l  : BS.ByteString | bLength l == bLength targ - 1}
-              , matches :: [{v : Int | v <= input - bLength targ}]
-              , right   :: {r  : BS.ByteString | bLength r == bLength targ - 1}
-              }
-  @-}
-
-
-matchIdxsIs :: MatchIdxs -> [Int]
-matchIdxsIs (Small _ _) = []
-matchIdxsIs (MatchIdxs _ _ _ is _) = is
-
--- | create a 'MatchIdxs'
-{-@ myIndices :: Alg -> t:ByteStringNE -> BS.ByteString -> MatchIdxsT t @-}
-myIndices alg t bs
-  | BS.length bs > fringeLen = let right1 = BS.drop (BS.length bs - fringeLen) bs in
-                                MatchIdxs t (BS.length bs) left is right1
-  | otherwise = Small t bs
-  where
-    is        = indices alg t bs
-    fringeLen = BS.length t - 1
-    left      = BS.take fringeLen bs
-    -- right1    = BS.drop (BS.length bs - fringeLen) bs
-
--- ISSUE: get contextual output with --diff
--- ISSUE: why does lazyvar right1 not work? it drops the output type on right1!
-
-{- lazyvar right1 -}
-
-{-@ type OkPos Targ Str = {v:Nat | v <= bLength Str - bLength Targ} @-}
-{-@ type ByteStringNE   = {v:BS.ByteString | bLength v > 0 }   @-}
-{-@ type ByteStringN N  = {v:BS.ByteString | bLength v == N}   @-}
-{-@ type MatchIdxsT T   = {v:MatchIdxs | targ v == T}          @-}
-
-{-@ assume BS.isSuffixOf :: targ:_ -> s:_ -> {v:_ | v => (bLength targ <= bLength s) } @-}
-{-@ assume BS.length  :: b:BS.ByteString -> {v:Nat | v == bLength b}  @-}
-{-@ assume BS.empty   :: {v:BS.ByteString | bLength v == 0}    @-}
-{-@ assume BS.take    :: n:Nat -> b:BS.ByteString -> ByteStringN {min n (bLength b)} @-}
-{-@ assume BS.drop    :: n:Nat -> b:{BS.ByteString | n <= bLength b} -> ByteStringN {bLength b - n} @-}
-{-@ assume BS.inits   :: b:BS.ByteString -> [{v:BS.ByteString | bLength v <= bLength b}] @-}
-{-@ assume BS.append  :: b1:BS.ByteString -> b2:BS.ByteString -> ByteStringN {bLength b1 + bLength b2} @-}
-{-@ assume BS.null    :: b:BS.ByteString -> {v:Bool | v <=> (bLength b == 0)} @-}
-{-@ assume BS.splitAt :: n:Nat -> b:BS.ByteString -> (ByteStringN {min n (bLength b)}, ByteStringN {max 0 (bLength b - n)}) @-}
-{-@ assume BS.head    :: BS.ByteString -> _ @-}
-
-{-@ measure target @-}
-target :: MatchIdxs -> BS.ByteString
-target (Small t _)           = t
-target (MatchIdxs t _ _ _ _) = t
-
-{-@ inline min @-}
-min :: Int -> Int -> Int
-min x y = if x <= y then x else y
-
-{-@ inline max @-}
-max :: Int -> Int -> Int
-max x y = if x <= y then y else x
-
--- RJ instance (KnownSymbol t, StringMatch alg) => Monoid (MatchIdxs alg t) where
-{-@ mmempty :: t:ByteStringNE -> MatchIdxsT t @-}
-mmempty t = Small t BS.empty
-
-{-@ mmconcat :: (Foldable t) => Alg -> tg:ByteStringNE -> t (MatchIdxsT tg) -> (MatchIdxsT tg) @-}
-mmconcat alg t = foldr (mmappend alg t) (mmempty t)
-
-{-@ qualif BB(v:Int, n:Int, d:Int, b:BS.ByteString): v <= (n + d) - bLength b @-}
-
-{-@ mmappend :: Alg -> t:ByteStringNE -> MatchIdxsT t -> MatchIdxsT t -> MatchIdxsT t @-}
-mmappend alg t mx my =
-  let fringeLen = BS.length t - 1
-      idxFun    = indices alg t
-  in
-  case (mx, my) of
-    (Small tx x, Small _ y) -> myIndices alg tx (x <> y)
-    (Small tx x, MatchIdxs _ yLen ly iy rt) -> MatchIdxs tx xyLen lt is rt
-       where
-         xyLen = xLen + yLen
-         xLen  = BS.length x
-         xly   = BS.append x ly
-         lt    = BS.take fringeLen xly
-         is    = idxFun xly ++ map (+ xLen) iy
-    (MatchIdxs tx xLen lt ix rx, Small ty y) -> MatchIdxs tx xyLen lt (ix ++ is) rt
-       where
-         xyLen = xLen + yLen
-         yLen  = BS.length y
-         is    = map (+ (xLen - fringeLen)) (idxFun rxy)
-         rt    = BS.drop (BS.length rxy - fringeLen) rxy
-         rxy   = BS.append rx y
-    (MatchIdxs tx xLen lt ix rx, MatchIdxs ty yLen ly iy rt) -> MatchIdxs tx xyLen lt (ix ++ is) rt
-       where
-         xyLen = xLen + yLen
-         is    = ixy ++ map (+ xLen) iy
-         ixy   = map (+ (xLen - fringeLen)) $ idxFun (BS.append rx ly)
-
--- | Example applications
---
--- The bufLen and chunkSz arguments are there to exercise the monoid,
--- though they also foreshadow a parallel implementation.
-{-@ indicesBS' :: Alg -> Int -> Int -> ByteStringNE -> BS.ByteString -> [Int] @-}
-indicesBS' alg bufLen chunkSz t bs =
-  let si = mmconcat alg t . map (mmconcat alg t) . chunksOf bufLen . map (myIndices alg t) $ chunksBS chunkSz bs in
-  matchIdxsIs si
-
-{-@ indicesBS, indicesNaive :: Int -> Int -> ByteStringNE -> BS.ByteString -> [Int] @-}
-indicesBS    = indicesBS' BM   -- RJ (Proxy :: Proxy BM)
-indicesNaive = indicesBS' Spec -- RJ (Proxy :: Proxy Spec)
-
-{-@ isInfixOfBS :: Int -> Int -> ByteStringNE -> BS.ByteString -> Bool @-}
-isInfixOfBS bufLen chunkSz t = not . null . indicesBS bufLen chunkSz t
-
-------------------------------------------------------------------------------------------
-{-@ invariant {v:BS.ByteString | 0 <= bLength v } @-}
-{-@ measure bLength :: BS.ByteString -> Int @-}
-{-@ type LNat N = {v:Nat | v < N} @-}
-
-chunksOf :: Int -> [a] -> [[a]]
-chunksOf =  undefined
-
-{-@ assumeIndices :: t:ByteStringNE -> s:BS.ByteString -> [OkPos t s] @-}
-assumeIndices :: BS.ByteString -> BS.ByteString -> [Int]
-assumeIndices = undefined
diff --git a/tests/pos/kmp.hs b/tests/pos/kmp.hs
deleted file mode 100644
--- a/tests/pos/kmp.hs
+++ /dev/null
@@ -1,95 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-
-module KMP (search) where
-
-import Language.Haskell.Liquid.Prelude (liquidError)
-
-search pat str = kmpSearch (ofList pat) (ofList str) 
-
--------------------------------------------------------------
--- | Do the Search ------------------------------------------
--------------------------------------------------------------
-
-kmpSearch p@(A m _) s@(A n _) = go 0 0 
-  where
-    t              = kmpTable p
-    go i j
-      | j >= m     = i - m
-      | i >= n     = (-1)
-      | s!i == p!j = go (i+1) (j+1)
-      | j == 0     = go (i+1) j
-      | otherwise  = go i     (t!j) 
-
-
--------------------------------------------------------------
--- | Make Table ---------------------------------------------
--------------------------------------------------------------
-
-{-@ kmpTable :: (Eq a) => p:Arr a -> {v:DArr Nat | alen v = alen p} @-}
-kmpTable p@(A m _) = go 1 0 t
-  where
-    t              = new m (\_ -> 0)
-    go i j t
-      | i >= m - 1 = t
-
-      | p!i == p!j = let i' = i + 1
-                         j' = j + 1
-                         t' = wipe $ set t i' j'
-                     in go i' j' t'           
-    
-      | (j == 0)   = let i' = i + 1
-                         t' = wipe $ set t i' 0
-                     in go i' j t'
-                             
-      | otherwise  = let j' = t ! j
-                     in go i j' t 
-
-{-@ wipe :: a:DArr Nat -> {v:DArr Nat | alen v = alen a} @-}
-wipe :: Arr Int -> Arr Int
-wipe = undefined
-
-
-{-@ type DArr a = Arr<{\k v -> v <= k}> a @-}
-{-@ type Upto N = {v:Nat | v < N} @-} 
-
--------------------------------------------------------------
--- | An Array type ------------------------------------------
--------------------------------------------------------------
-
-data Arr a = A { alen :: Int
-               , aval :: Int -> a
-               }
-
-{-@ data Arr a <rng :: Int -> a -> Bool>
-      = A { alen :: Nat 
-          , aval :: i:Upto alen -> a<rng i>
-          }
-  @-}
-
-
-{-@ new :: forall <p :: Int -> a -> Bool>.
-             n:Nat -> (i:Upto n -> a<p i>) -> {v: Arr<p> a | alen v = n}
-  @-}
-new n v = A { alen = n
-            , aval = \i -> if (0 <= i && i < n)
-                             then v i
-                             else liquidError "Out of Bounds!"
-            }
-
-{-@ (!) :: forall <p :: Int -> a -> Bool>.
-             a:Arr<p> a -> i:Upto (alen a) -> a<p i>
-  @-}
-
-(A _ f) ! i = f i
-  
-{-@ set :: forall <p :: Int -> a -> Bool>.
-             a:Arr<p> a -> i:Upto (alen a) -> a<p i> -> {v:Arr<p> a | alen v = alen a}
-  @-}
-set a@(A _ f) i v = a { aval = \j -> if (i == j) then v else f j }
-
-
-{-@ ofList :: xs:[a] -> {v:Arr a | alen v = len xs} @-} 
-ofList :: [a] -> Arr a
-ofList = undefined
-
diff --git a/tests/pos/kmpIO.hs b/tests/pos/kmpIO.hs
deleted file mode 100644
--- a/tests/pos/kmpIO.hs
+++ /dev/null
@@ -1,140 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-{-@ LIQUID "--diff"           @-}
-
-module KMP (search) where
-
-import Language.Haskell.Liquid.Prelude (liquidError)
-import Data.IORef
-import Control.Applicative ((<$>))
-import qualified Data.Map as M
-
-{-@ type Upto N = {v:Nat | v < N} @-}
-
----------------------------------------------------------------------------
-{-@ search :: String -> str:String -> Maybe (Upto (len str)) @-}
----------------------------------------------------------------------------
-search :: String -> String -> Maybe Int
-search pat str = kmpSearch (ofList pat) (ofList str)
-
-
--------------------------------------------------------------
--- | Do the Search ------------------------------------------
--------------------------------------------------------------
-
-{-@ kmpSearch :: (Eq a) => p:Arr a -> s:Arr a -> Maybe (Upto (alen s)) @-}
-kmpSearch p@(A m _) s@(A n _) = go 0 0
-  where
-    t              = kmpTable p
-    go i j
-      | i >= n     = Nothing
-      | j >= m     = Just (i - m)
-      | s!i == p!j = go (i+1) (j+1)
-      | j == 0     = go (i+1) j
-      | otherwise  = go i     (t!j)
-
-
--------------------------------------------------------------
--- | Make Table ---------------------------------------------
--------------------------------------------------------------
-
-kmpTable p@(A m _) = go t 1 0
-  where
-    t              = new m (\_ -> 0)
-    go t i j
-      | i >= m - 1 = t
-
-      | p!i == p!j = let i' = i + 1
-                         j' = j + 1
-                         t' = set t i' j'
-                     in go t' i' j'
-
-      | (j == 0)   = let i' = i + 1
-                         t' = set t i' 0
-                     in go t' i' j
-
-      | otherwise  = let j' = t ! j
-                     in go t i j'
-
-
--------------------------------------------------------------
--- | A Pure Array -------------------------------------------
--------------------------------------------------------------
-
-data Arr a   = A { alen :: Int
-                 , aval :: Int -> a
-                 }
-
-{-@ data Arr a <p :: Int -> a -> Bool>
-             = A { alen :: Nat
-                 , aval :: i:Upto alen -> a<p i>
-                 }
-  @-}
-
-
-{-@ new :: forall <p :: Int -> a -> Bool>.
-             n:Nat -> (i:Upto n -> a<p i>) -> {v: Arr<p> a | alen v = n}
-  @-}
-new n v = A { alen = n
-            , aval = \i -> if (0 <= i && i < n)
-                             then v i
-                             else liquidError "Out of Bounds!"
-            }
-
-{-@ (!) :: forall <p :: Int -> a -> Bool>.
-             a:Arr<p> a -> i:Upto (alen a) -> a<p i>
-  @-}
-
-(A _ f) ! i = f i
-
-{-@ set :: forall <p :: Int -> a -> Bool>.
-             a:Arr<p> a -> i:Upto (alen a) -> a<p i> -> {v:Arr<p> a | alen v = alen a}
-  @-}
-set a@(A _ f) i v = a { aval = \j -> if (i == j) then v else f j }
-
-
-{-@ ofList :: xs:[a] -> {v:Arr a | alen v = len xs} @-}
-ofList xs = new n f
-  where
-    n     = length xs
-    m     = M.fromList $ zip [0..] xs
-    f i   = (M.!) m i
-
-{-@ map :: (a -> b) -> a:Arr a -> {v:Arr b | alen v = alen a} @-}
-map f a@(A n z) = A n (f . z)
-
-
-
--------------------------------------------------------------
--- | An Imperative Array ------------------------------------
--------------------------------------------------------------
-
-data IOArr a = IOA { size :: Int
-                   , pntr :: IORef (Arr a)
-                   }
-
-{-@ data IOArr a <p :: Int -> a -> Bool>
-      = IOA { size :: Nat
-            , pntr :: IORef ({v:Arr<p> a | alen v = size})
-            }
-  @-}
-
-{-@ newIO :: forall <p :: Int -> a -> Bool>.
-               n:Nat -> (i:Upto n -> a<p i>) -> IO ({v: IOArr<p> a | size v = n})
-  @-}
-newIO n f = IOA n <$> newIORef (new n f)
-
-{-@ getIO :: forall <p :: Int -> a -> Bool>.
-              a:IOArr<p> a -> i:Upto (size a) -> IO (a<p i>)
-  @-}
-getIO a@(IOA sz p) i
-  = do arr   <- readIORef p
-       return $ (arr ! i)
-
-{-@ setIO :: forall <p :: Int -> a -> Bool>.
-              a:IOArr<p> a -> i:Upto (size a) -> a<p i> -> IO ()
-  @-}
-setIO a@(IOA sz p) i v
-  = do arr     <- readIORef p
-       let arr' = set arr i v
-       writeIORef p arr'
diff --git a/tests/pos/kmpVec.hs b/tests/pos/kmpVec.hs
deleted file mode 100644
--- a/tests/pos/kmpVec.hs
+++ /dev/null
@@ -1,63 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--short-names"    @-}
-
-module KMP (search) where
-
-import Language.Haskell.Liquid.Prelude (liquidError)
-import Data.Vector
-import Data.Vector.Mutable (write)
-import Prelude hiding (length, replicate)
-
-{-@ type Idx X = {v:Nat | v < vlen X} @-}
-
-
-search pat str = kmpSearch (fromList pat) (fromList str) 
-
--------------------------------------------------------------
--- | Do the Search ------------------------------------------
--------------------------------------------------------------
-
-kmpSearch p s      = go 0 0 
-  where
-    t              = kmpTable p
-    m              = length p
-    n              = length s
-    go i j
-      | j >= m     = i - m
-      | i >= n     = (-1)
-      | s!i == p!j = go (i+1) (j+1)
-      | j == 0     = go (i+1) j
-      | otherwise  = go i     (t!j) 
-
-
--------------------------------------------------------------
--- | Make Table ---------------------------------------------
--------------------------------------------------------------
-
-{-@ kmpTable :: (Eq a) => p:Vector a -> {v:Vector Nat | vlen v = vlen p} @-}
-kmpTable p         = go 1 0 t
-  where
-    m              = length p
-    t              = replicate m 0 
-    go i j t
-      | i >= m - 1 = t
-
-      | p!i == p!j = let i' = i + 1
-                         j' = j + 1
-                         t' = set t i' j'
-                     in go i' j' t'           
-    
-      | (j == 0)   = let i' = i + 1
-                         t' = set t i' 0
-                     in go i' j t'
-                             
-      | otherwise  = let j' = t ! j
-                     in go i j' t 
-
-
-{-@ type Upto N = {v:Nat | v < N} @-} 
-
-{-@ set :: a:Vector a -> i:Idx a -> a -> {v:Vector a | vlen v = vlen a} @-}
-set :: Vector a -> Int -> a -> Vector a
-set = undefined
-
diff --git a/tests/pos/lets.hs b/tests/pos/lets.hs
deleted file mode 100644
--- a/tests/pos/lets.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude
-
-foo :: Int -> (Int, Int)
-foo z = (z, z + 1)
-
-baz :: Int -> (Int, Int)
-baz z = let (i, j) = foo z 
-        in (i, j + 1)
-
-{-@ prop :: Int -> Bool @-}
-prop x = let (a, b) = baz x in
-         liquidAssertB (a < b)
diff --git a/tests/pos/lex.hs b/tests/pos/lex.hs
deleted file mode 100644
--- a/tests/pos/lex.hs
+++ /dev/null
@@ -1,10 +0,0 @@
--- TAG: termination
-
-module Lex (foo) where
-
-bar = foo [1, 2, 3] [2, 3, 4]
-
-{- decrease foo 1 2 @-}
-foo xs    (y:ys) = foo xs ys
-foo (x:xs) ys    = foo xs ys
-foo xs     ys    = xs
diff --git a/tests/pos/listAnf.hs b/tests/pos/listAnf.hs
deleted file mode 100644
--- a/tests/pos/listAnf.hs
+++ /dev/null
@@ -1,90 +0,0 @@
-module ListRange (llen) where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@  
-data List [llen] a <p :: x0:a -> x1:a -> Bool>  
-  = Nil 
-  | Cons (h :: a) (t :: List <p> (a <p h>))
-@-}
-
-{-@ measure llen @-}
-llen :: List a -> Int 
-{-@ llen :: List a -> Nat @-} 
-llen Nil = 0 
-llen (Cons _ xs) = 1 + llen xs 
-
-data List a 
-   = Nil 
-   | Cons a (List a)
-
-checkSort Nil                        = True
-checkSort (_ `Cons` Nil)             = True
-checkSort (x1 `Cons` (x2 `Cons` xs)) = liquidAssertB (x1 <= x2) && checkSort (x2 `Cons` xs)
-
-z3 :: List Integer 
-z3    = 3 `Cons` (6 `Cons` Nil)
-prop3 = checkSort z3
-
--- The below works because it is properly ANF-ed
--- The above fails because the "3" is not hoisted out into its own binding.
-
---three :: Integer
---three = 3
---
---six :: Integer
---six = 6
---
---z2 :: List Integer 
---z2    = three `Cons` (six `Cons` Nil) 
---prop2 = checkSort z2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/listSet.hquals b/tests/pos/listSet.hquals
deleted file mode 100644
--- a/tests/pos/listSet.hquals
+++ /dev/null
@@ -1,4 +0,0 @@
-qualif Cup1(v: [a] , xs : [a] , ys : [a]): (listElts v = Set_cup (listElts xs) (listElts ys))
-qualif Cup2(v: [a] , xs : [a] , ys : [a]): (listElts xs = Set_cup (listElts v) (listElts ys))
-qualif IsEmp(v: [a]) : (Set_emp (listElts v))
-qualif EqSet(v: [a], xs: [a]) : (listElts v = listElts xs)
diff --git a/tests/pos/listSet.hs b/tests/pos/listSet.hs
deleted file mode 100644
--- a/tests/pos/listSet.hs
+++ /dev/null
@@ -1,56 +0,0 @@
-module ListSets () where
-
--------------------------------------------------------------------------
--- | Encoding Sets of Values With Liquid Types --------------------------
--------------------------------------------------------------------------
-
--- TODO: make this self-enclosed
-
-import Data.Set (Set(..))  
-
--- | To start with, lets check that the `listElts` measure is sensible
-
-{-@ myid0 :: xs:[a] -> {v:[a]| (len v) = (len xs)} @-}
-myid0 []     = []
-myid0 (x:xs) = x : myid0 xs
-
-
-{-@ myid :: xs:[a] -> {v:[a]| (listElts v) = (listElts xs)} @-}
-myid []     = []
-myid (x:xs) = x : myid xs
-
--- | The reverse function should also return the same set of values.
--- Note that the reverse uses the tail-recursive helper @go@. 
--- Mouse over and see what type is inferred for it!
-
-{-@ decrease go 2 @-}
-{-@ myrev :: xs:[a] -> {v:[a]| listElts(v) = listElts(xs)} @-}
-myrev :: [a] -> [a]
-myrev = go [] 
-  where 
-    go acc []     = acc
-    go acc (y:ys) = go (y:acc) ys
-
--- | Next, here's good old List-append, but now with a specification about
--- the sets of values in the input and output.
-
-{-@ myapp :: xs:[a] 
-          -> ys:[a] 
-          -> {v:[a] | listElts v = Set_cup (listElts xs) (listElts ys) } @-}
-myapp :: [a] -> [a] -> [a]
-myapp []     ys = ys
-myapp (x:xs) ys = x : myapp xs ys
-
--- | Finally, to round off this little demo, here's @filter@, which returns a subset.
-
-{-@ myfilter :: (a -> Bool) -> xs:[a] -> {v:[a] | Set_sub (listElts v) (listElts xs) } @-}
-myfilter :: (a -> Bool) -> [a] -> [a]
-myfilter f []     = []
-myfilter f (x:xs) = if f x 
-                      then x : myfilter f xs 
-                      else myfilter f xs
-
-
-
-
-
diff --git a/tests/pos/listSetDemo.hs b/tests/pos/listSetDemo.hs
deleted file mode 100644
--- a/tests/pos/listSetDemo.hs
+++ /dev/null
@@ -1,59 +0,0 @@
-module ListSets () where
-
--------------------------------------------------------------------------
--- | Encoding Sets of Values With Liquid Types --------------------------
--------------------------------------------------------------------------
-
--- First, lets import the `Set` type from @Data.Set@
-
-import Data.Set (Set (..)) 
-
--- Next, lets write a measure for the set of elements in a list.
-
-{-@ measure elts :: [a] -> (Set a) 
-    elts ([])   = {v | Set_emp v }
-    elts (x:xs) = {v | v = Set_cup (Set_sng x) (elts xs) }
-  @-}
-
--- Next, we tell the solver to interpret @Set@ natively in the refinement logic.
-
-{-@ embed Set as Set_Set @-}
-
--- OK, now we can write some specifications!
-
--- | To start with, lets check that the `elts` measure is sensible
-
-{-@ myid :: xs:[a] -> {v:[a]| (elts v) = (elts xs)} @-}
-myid []     = []
-myid (x:xs) = x : myid xs
-
--- | The reverse function should also return the same set of values.
--- Note that the reverse uses the tail-recursive helper @go@. 
--- Mouse over and see what type is inferred for it!
-
-{-@ decrease go 2 @-}
-{-@ myrev :: xs:[a] -> {v:[a]| (elts v) = (elts xs)} @-}
-myrev = go [] 
-  where 
-    go acc []     = acc
-    go acc (y:ys) = go (y:acc) ys
-
--- | Next, here's good old List-append, but now with a specification about
--- the sets of values in the input and output.
-
-{-@ myapp :: xs:[a] -> ys:[a] -> {v:[a] | (elts v) = (Set_cup (elts xs) (elts ys))} @-}
-myapp []     ys = ys
-myapp (x:xs) ys = x : myapp xs ys
-
--- | Finally, to round off this little demo, here's @filter@, which returns a subset.
-
-{-@ myfilter :: (a -> Bool) -> xs:[a] -> {v:[a]| Set_sub (elts v) (elts xs) } @-}
-myfilter f []     = []
-myfilter f (x:xs) 
-  | f x           = x : myfilter f xs 
-  | otherwise     = myfilter f xs
-
-
-
-
-
diff --git a/tests/pos/listqual.hs b/tests/pos/listqual.hs
deleted file mode 100644
--- a/tests/pos/listqual.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module ListQual (boo) where
-
-{-@ qualif BadAppend(v:[a], xs:[a], ys:[a]): len v = len xs + len ys @-}
-
-append [] ys     = ys
-append (x:xs) ys = x : append xs ys
-
-{-@ boo :: {v:[Int] | len v = 2} @-}
-boo :: [Int]
-boo = append [1] [2]
diff --git a/tests/pos/lit.hs b/tests/pos/lit.hs
deleted file mode 100644
--- a/tests/pos/lit.hs
+++ /dev/null
@@ -1,4 +0,0 @@
-module Lit where
-
-{-@ test :: {v:Int | v == 3} @-}
-test = length "cat"
diff --git a/tests/pos/lit00.hs b/tests/pos/lit00.hs
deleted file mode 100644
--- a/tests/pos/lit00.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Nats where
-
-import Language.Haskell.Liquid.Prelude 
-
-poo :: () 
-poo = liquidAssert (zero /= one) ()
-
-data Peano = Z | O deriving (Eq)
-
-bob :: String 
-bob = "I am a cat"
-
-{-@ axiomatize one @-}
-one :: Peano 
-one = O 
-
-{-@ axiomatize zero @-}
-zero :: Peano
-zero = Z
diff --git a/tests/pos/lit02.hs b/tests/pos/lit02.hs
deleted file mode 100644
--- a/tests/pos/lit02.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Goo where 
-
-import Data.Set as S 
-
-{-@ predicate ValidMovieScheme V =
-	  ((listElts V == Set_cup (Set_sng "year")
-	  	                      (Set_cup (Set_sng "star")
-	  	                      (Set_cup (Set_sng "director")
-	  	                               (Set_sng "title"))))) @-}
-
-{-@ foo :: xs:[String] -> {ys: [String] | Set_sub (listElts xs) (listElts ys)} -> Int @-}
-foo :: [String] -> [String] -> Int 
-foo = undefined
-
-{-@ assume things :: {v:[String] | ValidMovieScheme v} @-}
-things :: [String] 
-things = undefined 
-
-bar = foo ["director"] things 
diff --git a/tests/pos/malformed0.hs b/tests/pos/malformed0.hs
deleted file mode 100644
--- a/tests/pos/malformed0.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-
--- TODO: Fix resolve so we can remove this/add termination metrics
-{-@ LIQUID "--no-termination" @-}
-
-module List () where
-
-{-@ decrease go 3 4 5 @-}
-{-@ decrease perms 4 5 6 @-}
-
-{-@ foo :: xs:[a] -> ys:[a] -> {v:Int| v = (len xs)- (len ys)} -> Int @-}
-foo :: [a] -> [a] -> Int -> Int
-foo = undefined
-
-permutations         :: [a] -> [[a]]
-permutations xs     =  go xs xs (length xs) (length xs) 1
-  where
-    go xs0 xs (d2 :: Int) d1 (d3::Int) = xs : perms xs0 xs [] d2 d1 0
-    perms _ []     _  _ _ _ = []
-    perms xs0 (t:ts) is (d2 :: Int) (d1::Int) (d3 :: Int) = (perms ts xs0 (t:is) d2 (length ts) d3) ++ (go xs0 is (length xs0 - length is) d1 1)
-
--- permutations         :: [a] -> [[a]]
--- permutations xs     =  go xs xs (length xs) (0::Int) 1
---   where
---     go xs0 xs d1 (d2::Int) (d3::Int) = xs : perms xs0 xs [] d1 0 0
---     perms _ []     _  _ _ _ = []
---     perms xs0 (t:ts) is (d1::Int) (d2 :: Int) (d3 :: Int) = (perms ts xs0 (t:is) (length ts) 0 d3) ++ (go xs0 is (length is) 0 1)
--- 
--- 
diff --git a/tests/pos/mapTvCrash.hs b/tests/pos/mapTvCrash.hs
deleted file mode 100644
--- a/tests/pos/mapTvCrash.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Foo (foo) where
-
-import Foreign.ForeignPtr
-
-{-@ foo :: FinalizerPtr a -> a @-}
-foo :: FinalizerPtr a -> a
-foo = undefined
diff --git a/tests/pos/mapreduce-bare.hs b/tests/pos/mapreduce-bare.hs
deleted file mode 100644
--- a/tests/pos/mapreduce-bare.hs
+++ /dev/null
@@ -1,71 +0,0 @@
-module Meas () where
-
-import Language.Haskell.Liquid.Prelude
-import Data.List (foldl')
-
-----------------------------------------------------------------
---- Step 1: Map each element into key-value list (concatMap) ---
-----------------------------------------------------------------
-
-expand          :: (a -> [(k,v)]) -> [a] -> [(k, v)]
-expand f []     = []
-expand f (x:xs) = (f x) ++ (expand f xs)
-
-----------------------------------------------------------------
---- Step 2: Group By Key ---------------------------------------
-----------------------------------------------------------------
-
-group ::[(Int, v)] -> [(Int, [v])]
-group = foldl' addKV [] 
-  
-addKV m (k, v) = insert k vs' m
-  where vs' = v : (findWithDefault [] k m)
-
-insert key value [] 
-  = [(key, value)]
-insert key value ((k,_):kvs)
-  | k == key
-  = (key, value):kvs
-insert key value (kv:kvs)
-  = kv : insert key value kvs  
-
-findWithDefault r _ ([]) 
-  = r
-findWithDefault r k ((key,value):_) 
-  | k `eq` key 
-  = value
-findWithDefault r k (_:kvs) 
-  = findWithDefault r k kvs 
-
-----------------------------------------------------------------
---- Step 3: Group By Key ---------------------------------------
-----------------------------------------------------------------
-
-collapse f = foldrWithKey reduceKV []
-  where reduceKV k (v:vs) acc = (k, foldl' f v vs) : acc
-        reduceKV k []     _   = crash False -- error $ show (liquidAssertB False)
-
-foldrWithKey f = foldr (\(k, v) acc -> f k v acc) 
-
-----------------------------------------------------------------
---- Putting it All Together ------------------------------------
-----------------------------------------------------------------
-
-mapReduce fmap fred xs = collapse fred $ group $ expand fmap xs
-
-----------------------------------------------------------------
---- "Word Count" -----------------------------------------------
-----------------------------------------------------------------
-
-wordCount  = mapReduce fm plus 
-  where fm = \doc -> [ (length w, 1) | w <- words doc]
-
-mytest = 
-  let docs = [ "this is the end"
-             , "go to the end"
-             , "the end is the beginning"]
-  in putStrLn $ isZero {- show -} $ wordCount docs
- 
-isZero [_]  = "Positive" 
-isZero _    = "Negative"
-
diff --git a/tests/pos/maps.hs b/tests/pos/maps.hs
deleted file mode 100644
--- a/tests/pos/maps.hs
+++ /dev/null
@@ -1,41 +0,0 @@
-module Maps where
-
-
-{-@ prop0 :: x:_ -> y:{_ | y == x} -> TT @-}
-prop0 x y = (a == b)
-  where
-    a     = get x emp  
-    b     = get y emp 
-
-{-@ prop1 :: x:_ -> y:{_ | y /= x} -> TT @-}
-prop1 x y = (z == 10)
-  where
-    m1    = put x 10 emp  
-    m2    = put y 20 m1
-    z     = get x m2
-
-{-@ prop2 :: x:_ -> y:{_ | y == x} -> TT @-}
-prop2 x y = (z == 20)
-  where
-    m1    = put x 10 emp 
-    m2    = put y 20 m1
-    z     = get x m2
-
------------------------------------------------------------------------
-
-data Map k v = M
-
-{-@ embed Map as Map_t @-}
-{-@ measure Map_select :: Map k v -> k -> v @-}
-{-@ measure Map_store  :: Map k v -> k -> v -> Map k v @-}
-
-emp :: Map Int Int
-emp = undefined   
-     
-{-@ get :: k:k -> m:Map k v -> {v:v | v = Map_select m k} @-}
-get :: k -> Map k v -> v
-get = undefined 
-
-{-@ put :: k:k -> v:v -> m:Map k v -> {n:Map k v | n = Map_store m k v} @-}
-put :: k -> v -> Map k v -> Map k v
-put = undefined 
diff --git a/tests/pos/maps1.hs b/tests/pos/maps1.hs
deleted file mode 100644
--- a/tests/pos/maps1.hs
+++ /dev/null
@@ -1,36 +0,0 @@
-module Maps where
-
-import Prelude hiding (lookup)
-import Data.Map
-
-{-@ prop0   :: _ -> x:_ -> y:{_ | y == x} -> TT @-}
-prop0       :: Map Int Int -> Int -> Int -> Bool
-prop0 m x y = (a == b)
-  where
-    a       = m ! x
-    b       = m ! y
-
-{-@ prop1   :: _ -> x:_ -> y:{_ | y /= x} -> TT @-}
-prop1       :: Map Int Int -> Int -> Int -> Bool
-prop1 m x y = (z == 10)
-  where
-    m1      = insert x 10 m
-    m2      = insert y 20 m1
-    z       = m2 ! x
-
-{-@ prop2   :: _ -> x:_ -> y:{_ | y == x} -> TT @-}
-prop2 m x y = (z == 20)
-  where
-    m1      = insert x 10 m
-    m2      = insert y 20 m1
-    z       = m2 ! x
-
------------------------------------------------------------------------
-
-{-@ embed Map as Map_t @-}
-{-@ measure Map_select :: Map k v -> k -> v @-}
-{-@ measure Map_store  :: Map k v -> k -> v -> Map k v @-}
-{-@ assume (!)         :: (Ord k) => m:Map k v -> k:k -> {v:v | v = Map_select m k} @-}
-{-@ assume insert      :: (Ord k) => key:k -> value:v -> m:Map k v -> {n:Map k v | n = Map_store m key value} @-}
-
------------------------------------------------------------------------
diff --git a/tests/pos/maybe.hs b/tests/pos/maybe.hs
deleted file mode 100644
--- a/tests/pos/maybe.hs
+++ /dev/null
@@ -1,32 +0,0 @@
-module Test () where
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-{-@ type OList a = [a]<{\fld v -> (v >= fld)}> @-}
-
-{-@ filterGt :: (Ord a) => x:Maybe a -> OList a -> OList {v:a | (( isJust x ) => (fromJust x <= v)) } @-}
-
-filterGt ::  Ord a => Maybe a -> [a] -> [a]
-filterGt Nothing  xs = xs
-filterGt (Just x) xs = foo x xs
-  
-foo y xs = foo' y xs
-
-foo' :: (Ord a) => a -> [a] -> [a]
-foo' y []     = []
-foo' y (x:xs) 
- = case compare y x of 
-     GT -> foo' y xs 
-     LT -> x:xs 
-     EQ -> xs 
-
-{-@ bar :: (Ord a) => z:a -> OList a -> OList {v:a | z <= v} @-}
-bar y xs = bar' y xs
-
-bar' y []     = []
-bar' y (x:xs) 
-  | y > x    = bar' y xs 
-  | y < x    = x:xs 
-  | y == x   = xs 
-
-
diff --git a/tests/pos/maybe0.hs b/tests/pos/maybe0.hs
deleted file mode 100644
--- a/tests/pos/maybe0.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Test () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ foo :: x:Maybe a -> {v:a | ((isJust(x)) => (fromJust(x) = v)) } @-}
-foo :: Maybe a -> a 
-foo (Just x)  = x 
-foo (Nothing) = unsafeError "foo"
-
-{-@ bar :: x:Maybe a -> {v:Bool | v <=> isJust x } @-}
-bar (Just x)  = True 
-bar (Nothing) = False
-
diff --git a/tests/pos/maybe000.hs b/tests/pos/maybe000.hs
deleted file mode 100644
--- a/tests/pos/maybe000.hs
+++ /dev/null
@@ -1,48 +0,0 @@
-module Foo () where
--- TODO: get this working with the ! annots.
-
-import Language.Haskell.Liquid.Prelude
--- remove the ! and it is safe...
-data MaybeS a = NothingS | JustS !a
--- (SAFE) data MaybeS a = NothingS | JustS a
-
-{-@ measure isJustS :: forall a. MaybeS a -> Bool 
-    isJustS (JustS x)  = true
-    isJustS (NothingS) = false
-  @-}
-
-{-@ measure fromJustS :: forall a. MaybeS a -> a
-    fromJustS (JustS x) = x 
-  @-}
-
-gloop = poop True
-
-{-@ poop :: z:a -> {v: MaybeS a | fromJustS(v) = z} @-}
-poop z = JustS z
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/maybe1.hs b/tests/pos/maybe1.hs
deleted file mode 100644
--- a/tests/pos/maybe1.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-module Test (isJustS, fromJustS) where
-
-data MaybeS a = NothingS | JustS !a
-
-{-@ measure isJustS @-}
-isJustS :: MaybeS a -> Bool
-isJustS (JustS x)  = True
-isJustS (NothingS) = False
-
-{-@ measure fromJustS @-}
-fromJustS :: MaybeS a -> a
-fromJustS (JustS x) = x
-
-{-@ type OList a = [a]<{\fld v -> (v >= fld)}> @-}
-
-{-@ filterGt :: (Ord a) => x:MaybeS a -> OList a -> OList {v:a | isJustS x => fromJustS x <= v } @-}
-
-filterGt ::  Ord a => MaybeS a -> [a] -> [a]
-filterGt NothingS  xs = xs
-filterGt (JustS x) xs = foo' x xs
-  where foo' y []     = []
-        foo' y (x:xs) = case compare y x of
-                          GT -> foo' y xs
-                          LT -> x:xs
-                          EQ -> xs
diff --git a/tests/pos/maybe2.hs b/tests/pos/maybe2.hs
deleted file mode 100644
--- a/tests/pos/maybe2.hs
+++ /dev/null
@@ -1,70 +0,0 @@
-module Data.Map.Base (Map(..), isRoot, filterLt, filterGt, mlen) where
-
-data Map k a  = Bin Size k a (Map k a) (Map k a)
-              | Tip
-
-type Size     = Int
-
-data MaybeS a = NothingS | JustS !a
-
-{-@ 
-  data Map [mlen] k a <l :: root:k -> k -> Bool, r :: root:k -> k -> Bool>
-       = Bin (sz    :: Size) 
-             (key   :: k) 
-             (value :: a) 
-             (left  :: Map <l, r> (k <l key>) a) 
-             (right :: Map <l, r> (k <r key>) a) 
-       | Tip 
-  @-}
-
-{-@ measure mlen @-}
-mlen :: Map k a -> Int 
-{-@ mlen :: Map k a -> Nat @-}
-mlen Tip = 0 
-mlen (Bin _ _ _ l r) = 1 + mlen l + mlen r  
-
-{-@ measure isJustS :: forall a. MaybeS a -> Bool 
-    isJustS (JustS x)  = true
-    isJustS (NothingS) = false
-  @-}
-
-{-@ measure fromJustS :: forall a. MaybeS a -> a 
-    fromJustS (JustS x) = x 
-  @-}
-
-{-@ type OMap k a = Map <{\root v -> v < root}, {\root v -> v > root}> k a @-}
-
-{-@ measure isBin :: Map k a -> Bool
-    isBin (Bin sz kx x l r) = true
-    isBin (Tip)             = false
-  @-}
-
-{-@ isRoot :: t:Map k a -> {v: Bool | v <=> isBin t} @-}
-isRoot (Bin _ _ _ _ _) = True
-isRoot (Tip)           = False
-
-{-@ filterGt :: (Ord k) => x:MaybeS k -> OMap k v -> OMap {v:k | ((isJustS(x)) => (v > fromJustS(x))) } v @-}
-filterGt :: Ord k => MaybeS k -> Map k v -> Map k v
-filterGt NothingS t = t
-filterGt (JustS b) t = filterGt' b t
-  
-filterGt' _   Tip = Tip
-filterGt' b' (Bin _ kx x l r) =
-          case compare b' kx of LT -> join kx x (filterGt' b' l) r
-                                EQ -> r
-                                GT -> filterGt' b' r
-
-{-@ filterLt :: (Ord k) => x:MaybeS k -> OMap k v -> OMap {v:k | ((isJustS(x)) => (v < fromJustS(x))) } v @-}
-filterLt :: Ord k => MaybeS k -> Map k v -> Map k v
-filterLt NothingS t = t
-filterLt (JustS b) t = filterLt' b t
-  
-filterLt' _   Tip = Tip
-filterLt' b' (Bin _ kx x l r) =
-  case compare kx b' of LT -> join kx x l (filterLt' b' r)
-                        EQ -> l
-                        GT -> filterLt' b' l
-
-{-@ join :: kcut:k -> a -> OMap {v:k | v < kcut} a -> OMap {v:k| v > kcut} a -> OMap k a @-}
-join :: k -> a -> Map k a -> Map k a -> Map k a
-join kx x l r = Bin 1 kx x l r 
diff --git a/tests/pos/maybe3.hs b/tests/pos/maybe3.hs
deleted file mode 100644
--- a/tests/pos/maybe3.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Foo () where
-
-
-{-@ foo :: lo0 : Maybe a
-        -> lo  : {v: Maybe {v: a | isJust lo0 && v = fromJust lo0 } | v = lo0 }  
-        -> hi0 : Maybe a
-        -> hi  : {v: Maybe {v: a | isJust hi0 && v = fromJust hi0 } 
-                   | (((isJust lo && isJust v) => (fromJust v >= fromJust lo)) && (v = hi0)) }   
-        -> Bool @-}
-foo :: Maybe a -> Maybe a -> Maybe a -> Maybe a -> Bool
-foo lo0 lo hi0 hi = bar (id hi) (id lo)
-
-{-@ bar :: hi: Maybe a 
-        -> lo:Maybe {v: a | ((isJust hi) => (v <= fromJust hi)) }  
-        -> Bool @-}
-bar :: Maybe a -> Maybe a -> Bool
-bar hi lo = True
-
-
-
diff --git a/tests/pos/maybe4.hs b/tests/pos/maybe4.hs
deleted file mode 100644
--- a/tests/pos/maybe4.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module Foo () where
-
-{-@ LIQUID "--bscope" @-}
-
-{-@ goo   :: lo:{v0a: Maybe {v:a | ((isJust v0a) && (v = (fromJust v0a)))} | true } 
-          -> hi:{v0b: Maybe {v:a | ((isJust v0b) && (v = (fromJust v0b)))} | (((isJust(lo) && isJust(v0b)) => (fromJust(v0b) >= fromJust(lo)))) }   
-          -> Bool 
-  @-}
-goo       :: Maybe a -> Maybe a -> Bool
-goo lo hi = bar (id hi) (id lo)
-
-{-@ bar :: hi: Maybe a -> lo:Maybe {v: a | ((isJust(hi)) => (v <= fromJust(hi)))} -> Bool @-}
-bar :: Maybe a -> Maybe a -> Bool
-bar hi lo = True
-
-
-
diff --git a/tests/pos/meas0.hs b/tests/pos/meas0.hs
deleted file mode 100644
--- a/tests/pos/meas0.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Range () where
-
-import Language.Haskell.Liquid.Prelude
-
-goo x = let z = [x] in z
-
-z0 _  = True
-z1 _  = False
-
-poo (x:_) = 0 == 0 
-poo ([])  = liquidAssertB False
-
-xs = goo (choose 0)
-
-prop1 = liquidAssertB (poo xs)
diff --git a/tests/pos/meas00.hs b/tests/pos/meas00.hs
deleted file mode 100644
--- a/tests/pos/meas00.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-module Zog () where
-
-import Language.Haskell.Liquid.Prelude
-
-xs :: [Int]
-xs = [1]
-
-poo [] = liquidAssertB False
-
-prop1  = liquidAssertB (poo xs)
-
-{- qualif PosLen(v:[a]): (len v) > 0 @-}
-
-{- zooper :: {v:[a] | (len v) > 0} -> a -}
-zooper :: [a] -> a
-zooper = undefined
diff --git a/tests/pos/meas00a.hs b/tests/pos/meas00a.hs
deleted file mode 100644
--- a/tests/pos/meas00a.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Range () where
-
-import Language.Haskell.Liquid.Prelude
-
-prop0 = liquidAssertB True 
diff --git a/tests/pos/meas0a.hs b/tests/pos/meas0a.hs
deleted file mode 100644
--- a/tests/pos/meas0a.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Range () where
-
-import Language.Haskell.Liquid.Prelude
-
-goo x = let z = [x] in z
-
-z0 _  = True
-z1 _  = False
-
-poo (x:_) = True 
-poo ([])  = liquidAssertB False 
-
-xs = goo (choose 0)
-
-prop0 = liquidAssertB True 
-prop1 = liquidAssertB (poo xs)
diff --git a/tests/pos/meas1.hs b/tests/pos/meas1.hs
deleted file mode 100644
--- a/tests/pos/meas1.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Range () where
-
-import Control.Applicative
-import Language.Haskell.Liquid.Prelude
-
-goo x = [x]
-
-xs = goo (choose 0)
-
-nullity :: [a] -> Int
-nullity []    = 0
-nullity (x:_) = 1
-
-prop2 = liquidAssertB (1 == nullity xs) 
diff --git a/tests/pos/meas10.hs b/tests/pos/meas10.hs
deleted file mode 100644
--- a/tests/pos/meas10.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module Meas where
-
-import qualified Data.Set as S 
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ myrev :: xs:[a] -> {v:[a] | listElts v = listElts xs} @-}
-myrev :: [a] -> [a]
-myrev xs = go [] xs 
-   where 
-      go acc []     = acc
-      go acc (y:ys) = go (y:acc) ys
-
--- WHY DOES THIS JUST NOT GET ANY MEANINGFUL TYPE?
-{-@ goo :: xs:[a] -> ys:[a] -> {v:[a] | listElts v = S.union (listElts xs) (listElts ys) } @-}
-goo :: [a] -> [a] -> [a]
-goo acc []     = acc
-goo acc (y:ys) = unsafeError "foo" -- goRev (y:acc) ys
-
-{-@ emptySet :: a -> {v:[b] | listElts v == S.empty } @-}
-emptySet :: a -> [b]
-emptySet x = []
diff --git a/tests/pos/meas11.hs b/tests/pos/meas11.hs
deleted file mode 100644
--- a/tests/pos/meas11.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Meas () where
-
-import Data.Set (Set(..))
-
-{-@ myfilter :: (a -> Bool) -> xs:[a] -> {v:[a] | Set_sub (listElts v) (listElts xs) } @-}
-myfilter :: (a -> Bool) -> [a] -> [a]
-myfilter f []     = []
-myfilter f (x:xs) = if f x 
-                      then x : myfilter f xs 
-                      else myfilter f xs
-
diff --git a/tests/pos/meas2.hs b/tests/pos/meas2.hs
deleted file mode 100644
--- a/tests/pos/meas2.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Meas (n) where
-
-import Language.Haskell.Liquid.Prelude
-
-mylen :: [a] -> Int
-mylen []       = 0
-mylen (_:xs)   = 1 + mylen xs
-
-
-zs :: [Int]
-zs = [1..100]
-
-n  = mylen zs
-
diff --git a/tests/pos/meas4.hs b/tests/pos/meas4.hs
deleted file mode 100644
--- a/tests/pos/meas4.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module Meas () where
-
-import Language.Haskell.Liquid.Prelude
-
-mylen          :: [a] -> Int
-mylen []       = 0
-mylen (_:xs)   = 1 + mylen xs
-
-mymap f []     = []
-mymap f (x:xs) = (f x) : (mymap f xs)
-
-zs :: [Int]
-zs = [1..100]
-
-prop2 = liquidAssertB (n1 == n2) 
-  where n1 = mylen zs
-        n2 = mylen $ mymap (`plus` 1) zs 
diff --git a/tests/pos/meas5.hs b/tests/pos/meas5.hs
deleted file mode 100644
--- a/tests/pos/meas5.hs
+++ /dev/null
@@ -1,47 +0,0 @@
-module Meas () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ include <len.hquals> @-}
-
-mylen          :: [a] -> Int
-mylen []       = 0
-mylen (_:xs)   = 1 + mylen xs
-
-
-mymap f []     = []
-mymap f (x:xs) = (f x) : (mymap f xs)
-
-
-{-@ myreverse :: xs:_ -> {v:_ | len v = len xs} @-} 
-myreverse = go []
-  where 
-    {-@ go :: acc:_ -> xs:_ -> {v:_ | len v = len acc + len xs} @-}
-    go acc (x:xs) = go (x:acc) xs
-    go acc []     = acc
-    
-{-@ myapp :: xs:_ -> ys:_ -> {v:_ | len v = len xs + len ys} @-}
-myapp [] ys     = ys
-myapp (x:xs) ys = x:(myapp xs ys)
-
-zs :: [Int]
-zs = [1..100]
-
-zs' :: [Int]
-zs' = [500..1000]
-
-prop2 = liquidAssertB (n1 == n2) 
-  where n1 = mylen zs
-        n2 = mylen $ mymap (+ 1) zs 
-
-prop3 = liquidAssertB (n1 == n2) 
-  where n1 = mylen zs
-        n2 = mylen $ myreverse zs 
-
-prop4 = liquidAssertB ((n1 + n2) == n3) 
-  where n1 = mylen zs
-        n2 = mylen zs'
-        n3 = mylen $ myapp zs zs' 
-
-prop5 = liquidAssertB (length zs'' == length zs) 
-        where zs'' = safeZipWith (+) zs (myreverse zs)
diff --git a/tests/pos/meas6.hs b/tests/pos/meas6.hs
deleted file mode 100644
--- a/tests/pos/meas6.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Meas () where
-
-import Language.Haskell.Liquid.Prelude
-
-mylen          :: [a] -> Int
-mylen []       = 0
-mylen (_:xs)   = 1 + mylen xs
-
-mymap f []     = []
-mymap f (x:xs) = (f x) : (mymap f xs)
-
-zs = [1..100]
-
-prop2 = liquidAssertB (n1 == n2) 
-  where n1 = mylen zs
-        n2 = mylen $ mymap (+ 1) zs 
diff --git a/tests/pos/meas7.hs b/tests/pos/meas7.hs
deleted file mode 100644
--- a/tests/pos/meas7.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-
-module Meas () where
-
--- some tests for the 'expandDefaultCase' trick to case-split 
--- on the "missing" constructors.
-
-
-mylen          :: [a] -> Int
-mylen []       = 0
-mylen (_:xs)   = 1 + mylen xs
-
-
-{-@ foo :: [a] -> {v: Int | v = 0} @-}
-foo :: [a] -> Int
-foo zs = case zs of
-           (x:xs) -> 0
-           _      -> mylen zs
-
-
-{-@ bar :: [a] -> {v: Int | v > 0} @-}
-bar :: [a] -> Int
-bar zs = case zs of
-           [] -> 1
-           _  -> mylen zs
-
diff --git a/tests/pos/meas8.hs b/tests/pos/meas8.hs
deleted file mode 100644
--- a/tests/pos/meas8.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-module Meas () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ include <len.hquals> @-}
-
-{-@ measure rlen :: [a] -> Int 
-    rlen ([])   = {v | v = 0}
-    rlen (y:ys) = {v | v = (1 + rlen(ys))}
-  @-}
-
-{-@ foo :: a -> {v:[b] | rlen(v) = 0} @-}
-foo x = []
-
-{-@ mylen :: xs:[a] -> {v:Int | v = rlen(xs)} @-}
-mylen          :: [a] -> Int
-mylen []       = 0
-mylen (_:xs)   = 1 + mylen xs
-
-{-@ mymap :: (a -> b) -> xs:[a] -> {v:[b] | rlen(v) = rlen(xs)} @-}
-mymap f []     = []
-mymap f (x:xs) = (f x) : (mymap f xs)
-
diff --git a/tests/pos/meas9.hs b/tests/pos/meas9.hs
deleted file mode 100644
--- a/tests/pos/meas9.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Meas () where
-
-import Data.Set (Set(..))
-
-{-@ myid :: xs:[a] -> {v:[a]| listElts(v) = listElts(xs)} @-}
-myid []     = []
-myid (x:xs) = x : myid xs
-
-{-@ myapp :: xs:[a] -> ys:[a] -> {v:[a] | listElts v = Set_cup (listElts xs) (listElts ys)} @-}
-myapp :: [a] -> [a] -> [a]
-myapp []     ys = ys
-myapp (x:xs) ys = x : myapp xs ys
-
-{-@ myrev :: xs:[a] -> {v:[a]| listElts v = listElts xs} @-}
-myrev :: [a] -> [a]
-myrev = go [] 
-  where 
-    go acc []     = acc
-    go acc (y:ys) = go (y:acc) ys
-
diff --git a/tests/pos/modTest.hs b/tests/pos/modTest.hs
deleted file mode 100644
--- a/tests/pos/modTest.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Goober () where
-
-import Language.Haskell.Liquid.Prelude (isEven)
-
-{-@ takeEvens :: [Int] -> [{v: Int | v mod 2 = 0}] @-}
-takeEvens :: [Int] -> [Int]
-takeEvens []     = []
-takeEvens (x:xs) = if isEven x
-                     then x : takeEvens xs 
-                     else takeEvens xs 
diff --git a/tests/pos/monad2.hs b/tests/pos/monad2.hs
deleted file mode 100644
--- a/tests/pos/monad2.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Monad () where
-
-goo c = return c
-
-foo = 
-  do x <- Just 1
-     y <- goo 3
-     return $ x + y 
diff --git a/tests/pos/monad5.hs b/tests/pos/monad5.hs
deleted file mode 100644
--- a/tests/pos/monad5.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude
-
--- gpp :: Monad m => m Int -> m Int
-gpp z = do x <- z
-           return $ liquidAssert (x >= 0) (x + 1)
-
-gpp' z n = do x <- z n
-              return $ liquidAssert (x >= 0) (x + 1)
-
-
-myabs :: Int -> Int
-myabs x | x >= 0     = x
-        | otherwise  = 0-x
-
-myabsM :: Monad m => Int -> m Int
-myabsM x | x >= 0     = return $ x
-         | otherwise  = return $ 0-x
-
-
-posM :: Monad m => m Int
-posM = return $ myabs $ choose 0
-
-
-xM, yM :: Monad m => m Int
-yM = gpp posM
-xM = gpp' myabsM $ choose 0
diff --git a/tests/pos/monad6.hs b/tests/pos/monad6.hs
deleted file mode 100644
--- a/tests/pos/monad6.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Foo () where
-
-import Language.Haskell.Liquid.Prelude 
-
-{-@ gpp :: Monad m => m {v:Int|v>=0} -> m {v:Int|v>=0} @-}
-gpp :: Monad m => m Int -> m Int
-gpp z = do x <- z
-           return $ liquidAssert (x >= 0) (x + 1)
-
-
-xM :: [Int]
-xM = gpp [0]
diff --git a/tests/pos/multi-pred-app-00.hs b/tests/pos/multi-pred-app-00.hs
deleted file mode 100644
--- a/tests/pos/multi-pred-app-00.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Blank () where
-
-{-@ foo :: forall < p :: Int -> Bool
-                  , q :: Int -> Bool >. Int<p,q> -> Int<p> @-}
-foo :: Int -> Int
-foo x = x
diff --git a/tests/pos/mutrec.hs b/tests/pos/mutrec.hs
deleted file mode 100644
--- a/tests/pos/mutrec.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module MutRec () where
-
-{-@ isEven :: n:Nat -> Bool / [n, 0] @-}
-isEven :: Int -> Bool
-isEven 0 = True
-isEven n = isOdd (n-1)
-
-{-@ isOdd :: n:Nat -> Bool / [n, 1] @-}
-isOdd :: Int -> Bool
-isOdd  n = not $ isEven n
-
-
-{- decrease isEven 1 2 -}
-{- decrease isOdd 1 2  -}
diff --git a/tests/pos/nats.hs b/tests/pos/nats.hs
deleted file mode 100644
--- a/tests/pos/nats.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Nats where 
-
-{-@ nats :: [Nat] @-}
-nats :: [Int]
-nats = [1,2,3,4,5,6,7,8,9,10]
diff --git a/tests/pos/niki.hs b/tests/pos/niki.hs
deleted file mode 100644
--- a/tests/pos/niki.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Niki () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ data Pair a b <p :: x0:a -> x1:b -> Bool> = P (x :: a) (y :: b<p x>) @-} 
-data Pair a b = P a b
-
-bar = P (0::Int) (1::Int)
-foo = chk bar
-
-chk (P x1 y1) = liquidAssertB (x1 <= y1)
diff --git a/tests/pos/niki1.hs b/tests/pos/niki1.hs
deleted file mode 100644
--- a/tests/pos/niki1.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-module Niki () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ data Pair a b <p :: x0:a -> x1:b -> Bool> = P (px :: a) (py :: b<p px>) @-} 
-data Pair a b = P a b
-
-incr :: Int -> Int
-incr x = x + 1
-
-baz :: Int -> Pair Int Int
-baz x = P x (incr x)
-
-prop :: Bool
-prop = chk (baz n)
-  where n = choose 100
-{-
-foo = baz n
- where n = choose 10
--}
-chk :: Pair Int Int -> Bool
-chk (P x y) = liquidAssertB (x < y)
-
diff --git a/tests/pos/pair.hs b/tests/pos/pair.hs
deleted file mode 100644
--- a/tests/pos/pair.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module Pair () where 
-
-import Language.Haskell.Liquid.Prelude 
-
-{-@ data Pair a b <p :: x0:a -> x1:b -> Bool> = P { px :: a, py :: b<p px> } @-} 
-data Pair a b = P a b
-
-incr x = let p = P x ((x+1)) in p
-chk (P x (y)) = liquidAssertB (x<y) 
-prop  = chk $ incr n
-  where n = choose 0
-
-incr2 x = 
-  let p1 = (P True (x+1)) in 
-  let p2 = P x p1 in 
-   p2
-chk2 (P x w) = 
-   case w of (P z y) -> liquidAssertB (x<y) 
-prop2  = chk2 $ incr2 n
-  where n = choose 0
-
-incr3 x = P x (P True (P 0 (x+1)))
-chk3 (P x (P _(P _ y))) = liquidAssertB (x<y) 
-prop3  = chk3 $ incr3 n
-  where n = choose 0
diff --git a/tests/pos/pair0.hs b/tests/pos/pair0.hs
deleted file mode 100644
--- a/tests/pos/pair0.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module Pair () where 
-
-{-@ LIQUID "--no-termination" @-}
-import Language.Haskell.Liquid.Prelude 
-
-data Pair a b = P a b
-
-
-incr x = (x, x+1)
-chk (x, y) = liquidAssertB (x <y) 
-prop  = chk $ incr n
-  where n = choose 0
-
-incr2 x = (x, True, x+1)
-chk2 (x, _, y) = liquidAssertB (x <y) 
-prop2  = chk2 $ incr2 n
-  where n = choose 0
-
-incr3 x = (x, (True, (0, x+1)))
-chk3 (x, (_, (_, y))) = liquidAssertB (x <y) 
-prop3  = chk3 $ incr3 n
-  where n = choose 0
diff --git a/tests/pos/pair00.hs b/tests/pos/pair00.hs
deleted file mode 100644
--- a/tests/pos/pair00.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module Pair () where
-
-{-@ LIQUID "--no-termination" @-}
-
-import Language.Haskell.Liquid.Prelude
-
-incr z = (x, [x + 1])
-  where
-    x  = choose z
-chk (x, [y]) = liquidAssertB (x < y)
-prop  = chk $ incr n
-  where
-    n = choose 0
-
-incr2 pig = (True, 9, pig, 'o', pig + 1)
-
-chk2 (_, _, cow, _,  dog) = liquidAssertB (cow < dog)
-
-prop2  = chk2 $ incr2 mouse
-  where mouse = choose 0
-
-incr3 x = (x, ( (0, x+1)))
-chk3 (x, ((_, y))) = liquidAssertB (x < y)
-prop3  = chk3 (incr3 n)
- where n = choose 0
diff --git a/tests/pos/pargs.hs b/tests/pos/pargs.hs
deleted file mode 100644
--- a/tests/pos/pargs.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Foo () where
-
-{-@ foo :: forall a <p :: x0:Int -> x1:a -> Bool>. 
-             (i:Int -> a<p i>) -> {v:Int| v=0}
-              -> a <p 0>
-  @-}
-
-foo ::  (Int -> a) -> Int ->  a
-foo f i = f i
-
diff --git a/tests/pos/pargs1.hs b/tests/pos/pargs1.hs
deleted file mode 100644
--- a/tests/pos/pargs1.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-{-@ LIQUID "--pruneunsorted" @-}
-module Foo () where
-
-{-@ foo :: forall a <p :: x0:Int -> x1:a -> Bool>. 
-             (i:Int  -> j : Int-> a<p (i+j)>) -> 
-               ii:Int -> jj:Int
-              -> a <p (ii+jj)>
-  @-}
-
-foo ::  (Int -> Int -> a) -> Int -> Int ->  a
-foo f i j = f i j
-
diff --git a/tests/pos/partial-tycon.hs b/tests/pos/partial-tycon.hs
deleted file mode 100644
--- a/tests/pos/partial-tycon.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Foo () where
-
-data Id a = Id a
-
-data Foo m a = Foo (m a)
-
-foo :: Foo Id a
-foo = undefined
diff --git a/tests/pos/partialmeasure.hs b/tests/pos/partialmeasure.hs
deleted file mode 100644
--- a/tests/pos/partialmeasure.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-module Head where
-
--- Note: `partialmeasureOld.hs` works fine 
-
-{-@ cons :: x:a -> _ -> {v:[a] | hd v = x} @-}
-cons x xs = x : xs
-
-{-@ test :: {v:_ | hd v = 0} @-}
-test :: [Int]
-test =  cons 0 [1,2,3,4]
-
-{-@ measure hd @-}
-hd       :: [a] -> a
-hd (x:_) = x
-
-
--- Instead of rejecting, can we just default to "un-refined" constructors?
-
--- Strengthened constructors
---   data [a] where
---     []  :: [a]    -- as before
---     (:) :: x:a -> xs:[a] -> {v:[a] | hd v = x}
-
-
-
-
diff --git a/tests/pos/ple1.hs b/tests/pos/ple1.hs
deleted file mode 100644
--- a/tests/pos/ple1.hs
+++ /dev/null
@@ -1,53 +0,0 @@
-{-@ LIQUID "--reflection" @-} 
-{- LIQUID "--no-adt"      @-}
-
-module PLE where
-
-import Prelude hiding ((++))
-import Language.Haskell.Liquid.ProofCombinators
-
-assocThm :: (Eq a) => [a] -> [a] -> [a] -> Bool
-assocProof :: [a] -> [a] -> [a] -> Proof
-
-{-@ infix ++ @-}
-
-{-@ reflect ++ @-}
-(++) :: [a] -> [a] -> [a]
-[]     ++ ys = ys
-(x:xs) ++ ys = x : (xs ++ ys)
-
-{-@ inline assocThm @-}
-assocThm xs ys zs = (xs ++ ys) ++ zs == xs ++ (ys ++ zs)
-
-{-@ assocProof :: xs:[a] -> ys:[a] -> zs:[a] -> { assocThm xs ys zs } @-}
-assocProof []     ys zs
-  =   ([] ++ ys) ++ zs
-  === [] ++ (ys ++ zs)
-  *** QED
-
-assocProof (x:xs) ys zs
-  =   ((x:xs) ++ ys) ++ zs
-  === (x : (xs ++ ys)) ++ zs
-  === x : ((xs ++ ys) ++ zs)
-    ? assocProof xs ys zs
-  === x : (xs ++ (ys ++ zs)) 
-  === (x:xs) ++ (ys ++ zs)
-  ***  QED
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
----
diff --git a/tests/pos/poly0.hs b/tests/pos/poly0.hs
deleted file mode 100644
--- a/tests/pos/poly0.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module Poly0 () where
-
-import Language.Haskell.Liquid.Prelude
-myabs x    = if x > 0 then x else 0 - x
-
-myid arg   = arg
-
-----------------------------------------------------------
-
-x = choose 0
-
-prop_id1 = let x'  = myabs x in 
-           let x'' = myid x' in 
-           liquidAssertB (x'' >= 0)
-
-prop_id2 = liquidAssertB (x'' >= 0)
-  where x'  = myabs x 
-        x'' = myid x' 
-
-prop_id3 = liquidAssertB (x' >= 0)
-  where x' = myid $ myabs x
diff --git a/tests/pos/poly1.hs b/tests/pos/poly1.hs
deleted file mode 100644
--- a/tests/pos/poly1.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Poly0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x > 0 then x else (0 - x)
-
-myid2 a b  = a  
-
-----------------------------------------------------------
-
-x =  choose 0
-
-prop_id4 = let x'  = myabs x in 
-           let x'' = myid2 x' [] in 
-           liquidAssertB (x'' >= 0) 
-
-prop_id5 = liquidAssertB (x'' >= 0)
-  where x'  = myabs x 
-        x'' = myid2 x' [] 
diff --git a/tests/pos/poly2-degenerate.hs b/tests/pos/poly2-degenerate.hs
deleted file mode 100644
--- a/tests/pos/poly2-degenerate.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Poly0 (prop_id6) where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x `gt` 0 then x else 0 `minus` x
-
-----------------------------------------------------------
-
-myid3 x y  = y
-
-prop_id6 x = liquidAssertB (x' `geq` 0)
-  where x' = myid3 [] $ myabs x 
-
-
diff --git a/tests/pos/poly2.hs b/tests/pos/poly2.hs
deleted file mode 100644
--- a/tests/pos/poly2.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module Poly0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x `gt` 0 then x else 0 `minus` x
-
-----------------------------------------------------------
-
-myid3 x y  = y
-
-x = choose 0 
-
-prop_id6 = liquidAssertB (x' `geq` 0)
-  where x' = myid3 [] $ myabs x 
diff --git a/tests/pos/poly3.hs b/tests/pos/poly3.hs
deleted file mode 100644
--- a/tests/pos/poly3.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Meas (goo) where
-
-expand          :: (a -> [b]) -> [a] -> [b]
-expand f []     = []
-expand f (x:xs) = (f x) ++ (expand f xs)
-
-baz :: a -> [Int]
-baz _ = [0]
-
-goo = expand baz
-
diff --git a/tests/pos/poly3a.hs b/tests/pos/poly3a.hs
deleted file mode 100644
--- a/tests/pos/poly3a.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Meas (goo) where
-
-expand f []     = []
-expand f (x:xs) = (f x) ++ (expand f xs)
-
-baz :: a -> [Int]
-baz _ = [0]
-
-goo = expand baz
-
diff --git a/tests/pos/poly4.hs b/tests/pos/poly4.hs
deleted file mode 100644
--- a/tests/pos/poly4.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Poly4 () where
-
-import Language.Haskell.Liquid.Prelude
-
-x     = choose 0
-
-baz y = y
-
-prop  = liquidAssertB (baz True)
diff --git a/tests/pos/polyfun.hs b/tests/pos/polyfun.hs
deleted file mode 100644
--- a/tests/pos/polyfun.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Poly4 () where
-
-import Language.Haskell.Liquid.Prelude
-
-foo :: a -> [Int]
-foo f = [0]
-
-prop  = all (\z -> liquidAssertB (z >= 0)) zs
-          where zs = foo id 
diff --git a/tests/pos/polyqual.hs b/tests/pos/polyqual.hs
deleted file mode 100644
--- a/tests/pos/polyqual.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-module Poo (nearestCenter) where
-
-import Data.List (minimumBy)
-
-data WrapType b a = WrapType {getVect :: b, getVal :: a}
-
-{-@ type List a N     = {v : [a] | (len v) = N} @-}
-{-@ type Point N      = List Double N           @-}
-{-@ type GenPoint a N = WrapType (Point N) a    @-}
-
-
-{-@ nearestCenter :: n:Int -> (GenPoint a n) -> [(Point n)] -> (Point n) @-} 
-nearestCenter     :: Int -> WrapType [Double] a -> [[Double]] -> [Double] 
-nearestCenter n x = minKey . map (\c -> (c, distance c (getVect x)))
-
-minKey  :: (Ord v) => [(k, v)] -> k
-minKey  = fst . minimumBy (\x y -> compare (snd x) (snd y)) 
-
-{- distance :: a:[Double] -> {v:[Double] | (len v) = (len a)} -> Double -}
-distance     :: [Double] -> [Double] -> Double 
-distance a b = sqrt . sum $ safeZipWith (\v1 v2 -> (v1 - v2) ^ 2) a b
-
-{-@ safeZipWith :: (a -> b -> c) -> xs:[a] -> (List b (len xs)) -> (List c (len xs)) @-}
-safeZipWith f (a:as) (b:bs) = f a b : safeZipWith f as bs
-safeZipWith _ [] []         = []
-
-
diff --git a/tests/pos/poslist.hs b/tests/pos/poslist.hs
deleted file mode 100644
--- a/tests/pos/poslist.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Poslist () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x `gt` 0 then x else 0 `minus` x
-
-absList xs = map myabs xs
-
-prop1 = map (liquidAssertB . (`geq` 0)) $ absList $ map choose [1..]
-
-
-numAbs x   = if x > 0 then x else (0 - x)
-
-numAbsList = map numAbs 
-
-prop2      = map (liquidAssertB . (>= 0)) $ numAbsList $ map choose [1..]
diff --git a/tests/pos/poslist_dc.hs b/tests/pos/poslist_dc.hs
deleted file mode 100644
--- a/tests/pos/poslist_dc.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Poslist () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x    = if x `gt` 0 then x else 0 `minus` x
-----------------------------------------------------------
-
-checkPos [] = True
-checkPos (z:zs) = liquidAssertB (z `geq` 0) &&  (checkPos zs)
-
-xs   = [-100..100]
-prop = checkPos $ map myabs xs
diff --git a/tests/pos/pragma0.hs b/tests/pos/pragma0.hs
deleted file mode 100644
--- a/tests/pos/pragma0.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-{-@ LIQUID "--notermination" @-}
-
-module Test0 where
-
-
--- an obviously non-terminating function
-zoo   :: Int -> Int
-zoo x = zoo x
diff --git a/tests/pos/pred.hs b/tests/pos/pred.hs
deleted file mode 100644
--- a/tests/pos/pred.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Foo () where
-
-{-@ predicate Lt X Y = X < Y        @-}
-{-@ predicate Ge X Y = not (Lt X Y) @-}
-{-@ predicate Pos X  = X > 0        @-}
-
-{-@ incr :: x:{v:Int | (Pos v)} -> { v:Int | ((Pos v) && (Ge v x))} @-}
-incr :: Int -> Int
-incr x = x + 1
diff --git a/tests/pos/primInt0.hs b/tests/pos/primInt0.hs
deleted file mode 100644
--- a/tests/pos/primInt0.hs
+++ /dev/null
@@ -1,48 +0,0 @@
-{-# LANGUAGE Trustworthy #-}
-{-# LANGUAGE CPP,  MagicHash #-}
-{-# OPTIONS_HADDOCK hide #-}
-
-module PrimInt (ptake, mtake, ztake, itake) where
-
-import Data.Maybe
-import GHC.Base
-
-{-@ ztake  :: n: {v: Int# | 0 <= v} -> {v: Int | v = n } @-}
-ztake :: Int# -> Int
-ztake 0# = 0
-ztake n# = 1 + ztake (n# -# 1#)
-
-{-@ itake  :: n: {v: Int | 0 <= v} -> {v: Int | v = n } @-}
-itake :: Int -> Int
-itake 0 = 0
-itake n = 1 + itake (n - 1)
-
-{-@ ptake  :: n: {v: GHC.Prim.Int# | 0 <= v} -> {v:[a] | ((len v) >= n)} -> {v:[a] | (len(v) = n)} @-}
-ptake :: Int# -> [a] -> [a]
-ptake 0# _      = []
-ptake n# (x:xs) = x : ptake (n# -# 1#) xs
-
-{-@ mtake  :: n: {v: Int | 0 <= v} -> {v:[a]|((len v) >= n)} -> {v:[a] | (len(v) = n)} @-}
-mtake          :: Int -> [a] -> [a]
-mtake 0 _      = []
-mtake n (x:xs) = x : mtake (n - 1) xs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/profcrasher.hs b/tests/pos/profcrasher.hs
deleted file mode 100644
--- a/tests/pos/profcrasher.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-x :: Int
-x = 4
diff --git a/tests/pos/propmeasure.hs b/tests/pos/propmeasure.hs
deleted file mode 100644
--- a/tests/pos/propmeasure.hs
+++ /dev/null
@@ -1,59 +0,0 @@
-{-# LANGUAGE EmptyDataDecls #-}
-
-module BoolMeasure where
-
-import Prelude hiding (length)
-
-{-@ myhead :: {v:[a] | nonEmpty v} -> a @-}
-myhead (x:_) = x
-
-{-@ measure nonEmpty @-}   
-nonEmpty (x:xs) = True 
-nonEmpty []     = False
-
-{-@ measure length @-}   
-length :: [a] -> Int
-length (x:xs) = 1 + length xs 
-length []     = 0
-
-
-{-@ measure lenEqFive @-}   
-lenEqFive (x:xs) = length xs == 4
-lenEqFive []     = False
-
-{-@ measure lenNEqFive @-}   
-lenNEqFive (x:xs) = not (length xs == 4)
-lenNEqFive []     = True
-
-
-{-@ measure lenGEFour @-}   
-lenGEFour (x:xs) = length xs >= 3
-lenGEFour []     = False
-
-
-{-@ len3 :: {v:[Int] | (not (lenEqFive v))} @-}
-len3 :: [Int]
-len3 = [1, 2, 3]
-
-
-{-@ len5 :: {v:[Int] | (lenEqFive v) && (lenGEFour v) } @-}
-len5 :: [Int]
-len5 = [1, 2, 3, 4, 5]
-
-{-@ measure length @-}
-
-{-@ foo  :: x:[a] -> {v: Bool | v <=> (nonEmpty x) } @-}
-foo  :: [a] -> Bool
-foo x = nonEmpty x
-
-
-cons = (:)
-nil  = []
-
-
-
-
-
-
-
-
diff --git a/tests/pos/propmeasure1.hs b/tests/pos/propmeasure1.hs
deleted file mode 100644
--- a/tests/pos/propmeasure1.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module BoolMeasure where
-
-nil  = []
-
-
-
-
-
-
-
-
diff --git a/tests/pos/qualTest.hs b/tests/pos/qualTest.hs
deleted file mode 100644
--- a/tests/pos/qualTest.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module QT () where
-
--- this test demonstrates the inclusion of qualifiers in source files
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-{-@ qualif Plus100(v:Int, a:Int): (v = a + 100) @-}
- 
-incr :: Int -> Int
-incr x = x + 100
-
-prop = liquidAssert (y == 100) y
-  where 
-    y  = incr 0 
diff --git a/tests/pos/range.hs b/tests/pos/range.hs
deleted file mode 100644
--- a/tests/pos/range.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-module Range (prop_rng5, myfoldl) where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ invariant {v:Int| v >= 0} @-}
-
-range :: Int -> Int -> [Int]
-range i j = range' (j - i) i j
-
-range' :: Int -> Int -> Int -> [Int]
-range' d i j  
-  | i < j     = i : (range' (d-1) (i + 1) j)
-  | otherwise = []  
-
-
-sumTo = foldl (+) 0 . range 0 
-
-{-@ decrease lgo 2 @-}
---myfoldl :: (Int -> Int -> Int) -> Int -> [Int] -> Int
-myfoldl f z0 xs0 = lgo z0 xs0
-             where
-                lgo z []     =  z
-                lgo z (x:xs) = lgo (f z x) xs
-n = choose 0 
-m = choose 1
-
--- prop_rng1 = map (liquidAssertB . (0 <=)) $ range 0 n
--- prop_rng2 = map (liquidAssertB . (n <=)) $ range n 100
--- prop_rng3 = map (liquidAssertB . (n <=)) $ range n m
--- prop_rng4 = map (liquidAssertB . (<= m)) $ range n m 
-prop_rng5 = liquidAssertB (0 <= sumTo n)
diff --git a/tests/pos/range1.hs b/tests/pos/range1.hs
deleted file mode 100644
--- a/tests/pos/range1.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Range (single, prop_rng1) where
-
-import Language.Haskell.Liquid.Prelude
-
-mynil  = []
-
-single x = [x] 
-
-range :: Int -> Int -> [Int]
-range i j = [i]
-
-prop_rng1 n   = map (liquidAssertB . (0 <=)) $ range 0 n
diff --git a/tests/pos/rangeAdt.hs b/tests/pos/rangeAdt.hs
deleted file mode 100644
--- a/tests/pos/rangeAdt.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-module Range (llen) where
-
-import Language.Haskell.Liquid.Prelude
-
-data L a = Nil | Con a (L a)
-{-@ data L [llen] a = Nil | Con { lHd ::a, lTl :: L a } @-}
-
-{-@ measure llen @-}
-{-@ llen :: L a -> Nat @-}
-llen :: L a -> Int 
-llen Nil = 0 
-llen (Con _ xs) = 1 + llen xs 
-
-range :: Int -> Int -> L Int
-range i j = range' (j-i) i j
-
-range' :: Int -> Int -> Int -> L Int
-range' d i j
-  | i < j  = i `Con` (range' (d-1) (i + 1) j)
-  | otherwise = Nil
-
-mapL f Nil        = Nil
-mapL f (Con x xs) = (f x) `Con` (mapL f xs)
-
-foldL f b Nil        = b
-foldL f b (Con x xs) = foldL f (f b x) xs
-
-sumTo = foldL plus 0 . range 0
-
-n = choose 0
-m = choose 1
-
-prop_rng1 = mapL (liquidAssertB . (0 <=)) $ range 0 n
-prop_rng2 = mapL (liquidAssertB . (n <=)) $ range n 100
-prop_rng3 = mapL (liquidAssertB . (n <=)) $ range n m
-prop_rng4 = mapL (liquidAssertB . (<= m)) $ range n m
-prop_rng5 = liquidAssertB (0 <= sumTo n)
diff --git a/tests/pos/rec_annot_go.hs b/tests/pos/rec_annot_go.hs
deleted file mode 100644
--- a/tests/pos/rec_annot_go.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module Fixme () where
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-{-@ invariant {v:Int | v >= 0} @-}
-
-{-@ decrease go 1 @-}
-loop :: Int -> Int -> a -> (Int -> a -> a) -> a 
-loop lo hi base f = go (hi-lo) base lo
-  where
-    go (d::Int) acc i     
-      | i /= hi   = go (d-1) (f i acc) (i + 1)
-      | otherwise = acc
-
-poo = loop 0 10 0 (+)
-
diff --git a/tests/pos/record0.hs b/tests/pos/record0.hs
deleted file mode 100644
--- a/tests/pos/record0.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{-@ LIQUID "--exact-data-cons" @-}
-
-module Rec0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ data LL a = BXYZ { size  :: {v: Int | v > 0 }
-                     , elems :: {v: [a] | (len v) = size }
-                     }
-  @-}
-
-data LL a = BXYZ { size  :: Int
-                 , elems :: [a]
-                 }
-
-{-@ mk :: a -> Int -> LL a @-}
-mk x n | n > 0     = BXYZ n (clone x n)
-       | otherwise = BXYZ 1 [x]
-
-{-@ bk :: LL a -> {v: Int | v > 0} @-}
-bk (BXYZ n xs) = liquidAssert (length xs == n) n
-
-{-@ clone :: x:a -> n:Int -> {v:[a]| (len v) = n} @-}
-clone :: a -> Int -> [a]
-clone = unsafeError "FOO"
diff --git a/tests/pos/record1.hs b/tests/pos/record1.hs
deleted file mode 100644
--- a/tests/pos/record1.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Data.Map.Base (trim) where
-
-data Map k a  = Tip
-
-{-@ data Map k a <l :: root:k -> k -> Bool>
-         = Tip
-  @-}
-
-{-@ measure isBin :: Map k a -> Bool
-    isBin (Tip)          = false
-  @-}
-
-trim :: Map k a
-trim = undefined 
-
diff --git a/tests/pos/recursion0.hs b/tests/pos/recursion0.hs
deleted file mode 100644
--- a/tests/pos/recursion0.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Recursion where
-
-
-{-@ total :: Nat -> Nat @-}
-total :: Int -> Int 
-total 0 = 0
-total n = 1 + total (n-1)
-
diff --git a/tests/pos/reflect0.hs b/tests/pos/reflect0.hs
deleted file mode 100644
--- a/tests/pos/reflect0.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-{-@ LIQUID "--higherorder"     @-}
-
-module FunctionAbstraction where
-
-{-@ fib :: n:Nat -> Nat @-}
-{-@ reflect fib @-}
-fib :: Int -> Int
-fib n
-  | n == 0    = 0
-  | n == 1    = 1
-  | otherwise = fib (n-1) + fib (n-2)
-
-
-{-@ goo :: Nat -> Nat @-}
-goo :: Int -> Int
-goo x = fib x
diff --git a/tests/pos/repeatHigherOrder.hs b/tests/pos/repeatHigherOrder.hs
deleted file mode 100644
--- a/tests/pos/repeatHigherOrder.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
--- TAG: bound 
--- TAG: absref 
-
-module Repeat where
-
-import Prelude hiding (repeat, succ)
-import Language.Haskell.Liquid.Prelude
-
-repeat :: Int -> (a -> a) -> a -> a
-goal   :: Int -> Int
-     
-{-@ bound step @-}
-step :: (a -> a -> Bool) -> (Int -> a -> Bool) -> Int -> a -> a -> Bool
-step pf pr = \ i x x' -> pr (i - 1) x ==> pf x x' ==> pr i x'
-
--- This syntax is not yet supported in liquidhaskell-8
-{- repeat :: forall a <f :: a -> a -> Bool, r :: Int -> a -> Bool>.
-                (Step a f r) => 
-                 n:Nat -> (y:a -> a<f y>) -> a<r 0> -> a<r n>
-  @-}
-
-
-{-@ repeat :: forall a <f :: a -> a -> Bool, r :: Int -> a -> Bool>.
-                {i::Int, x::a<r (i-1)>|- a<f x> <:a <r i>}
-                 n:Nat -> (y:a -> a<f y>) -> a<r 0> -> a<r n>
-  @-}
-repeat 0 _ x = x
-repeat n f x = repeat (n - 1) f (f x)
-
-{-@ goal :: n:Nat -> {r:Nat | n <= r} @-}
-goal n = repeat n (+ 1) 0
-
diff --git a/tests/pos/risers.hs b/tests/pos/risers.hs
deleted file mode 100644
--- a/tests/pos/risers.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Risers () where
-
-{-@ predicate NonNull X = ((len X) > 0) @-}
-
-{-@ risers :: (Ord a) => zs:[a] -> {v: [[a]] | ((NonNull zs) => (NonNull v)) } @-} 
-risers []        
-  = []
-risers [x]       
-  = [[x]]
-risers (x:y:etc) 
-  = if x <= y then (x:s):ss else [x]:(s:ss)
-    where (s:ss) = risers (y:etc)
diff --git a/tests/pos/rta.hs b/tests/pos/rta.hs
deleted file mode 100644
--- a/tests/pos/rta.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module RTA where
-
-{-@ predicate Mouse X Y = X > Y @-}
-
-{-@ inline mickey @-}
-mickey :: (Ord a) => a -> a -> Bool
-mickey x y = x > y
-
-{-@ type PosInline    a N = {v:a | mickey v N} @-}
-
-{-@ type PosPredicate a N = {v:a | Mouse v N} @-}
-
-{-@ incrI :: PosInline Int 0 -> PosInline Int 0 @-}
-incrI :: Int -> Int
-incrI x = x + 1
-
-{-@ incrP :: PosPredicate Int 0 -> PosPredicate Int 0 @-}
-incrP :: Int -> Int
-incrP x = x + 1
diff --git a/tests/pos/scanr.hs b/tests/pos/scanr.hs
deleted file mode 100644
--- a/tests/pos/scanr.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Goo () where
-
-{-@ scanrr  :: (a -> b -> b) -> b -> xs:[a] -> {v: [b] | len v = 1 + len xs } @-}
--- scanrr             :: (a -> b -> b) -> b -> [a] -> [b]
-scanrr _ q0 []     =  [q0]
-scanrr f q0 (x:xs) =  f x q : qs
-                      where qs@(q:_) = scanrr f q0 xs 
diff --git a/tests/pos/selfList.hquals b/tests/pos/selfList.hquals
deleted file mode 100644
--- a/tests/pos/selfList.hquals
+++ /dev/null
@@ -1,1 +0,0 @@
-qualif SelfSet(v : a, xs : [a]): (Set_mem v (listElts xs))
diff --git a/tests/pos/selfList.hs b/tests/pos/selfList.hs
deleted file mode 100644
--- a/tests/pos/selfList.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-module Foo () where
-
-{-@ LIQUID "--bscope" @-}
-
-import Data.Set (Set(..)) 
-
-{-@ include <selfList.hquals> @-}
-
-{-@ invariant {v0:[{v: a | (Set_mem v (listElts v0))}] | true } @-}
-
-{-@ type IList a  = {v0: [{v:a | (Set_mem v (listElts v0))}] | true } @-}
-
-{-@ moo :: [a] -> IList a @-}
-moo []     = [] 
-moo (_:xs) = xs
-
-goo []     = [] 
-goo (_:xs) = xs
-
-{-@ poo :: IList Int @-}
-poo = goo xs
-  where 
-    xs :: [Int]
-    xs = [2,1,3,2]
-
-
diff --git a/tests/pos/spec0.hs b/tests/pos/spec0.hs
deleted file mode 100644
--- a/tests/pos/spec0.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ assert incr :: x:{v: Int | v >= 0} -> {v: Int | v > x} @-}
-incr   :: Int -> Int
-incr x = x + 1
-
-myabs x = if x >= 0 then incr x else (0 - x)
-
-prop_abs   = let n1 = choose 0 in 
-             liquidAssertB ((myabs n1) >= 0)	
diff --git a/tests/pos/stacks0.hs b/tests/pos/stacks0.hs
deleted file mode 100644
--- a/tests/pos/stacks0.hs
+++ /dev/null
@@ -1,48 +0,0 @@
-module StackSet () where
-
-import Data.Set (Set(..))
-
-data LL a = Nil | Cons { headC :: a
-                       , tailC :: LL a
-                       }
-
-{-@ data LL a = Nil | Cons { headC :: a
-                           , tailC :: {v: LL a | not (Set_mem headC (elts v)) }
-                           }
-  @-}
-
-{-@ measure elts :: LL a -> (Set a)
-    elts (Nil)       = {v | (Set_emp v)}
-    elts (Cons x xs) = {v | v = (Set_cup (Set_sng x) (elts xs)) }
-  @-}
-
-{-@ predicate Disjoint X Y = (Set_emp (Set_cap (elts X) (elts Y))) @-}
-{-@ predicate NotIn    X Y = not (Set_mem X (elts Y))              @-}
-
-ll2 = Cons x0 (Cons x1 (Cons x2 Nil))
-  where x0 :: Int
-        x0  = 0
-        x1  = 1
-        x2  = 2
-
-{-@ data Stack a = St { focus  :: a
-                      , up     :: {vu: LL a | (NotIn focus vu) }
-                      , down   :: {vd: LL a | ((NotIn focus vd) && (Disjoint up vd)) }
-                      }
-  @-}
-
-data Stack a = St { focus  :: !a
-                  , up     :: !(LL a)
-                  , down   :: !(LL a)
-                  }
-
-{-@ fresh :: a -> Stack a @-}
-fresh x = St x Nil Nil
-
-{-@ moveUp :: Stack a -> Stack a @-}
-moveUp (St x (Cons y ys) zs) = St y ys (Cons x zs)
-moveUp s                     = s
-
-{-@ moveDn :: Stack a -> Stack a @-}
-moveDn (St x ys (Cons z zs)) = St z (Cons x ys) zs
-moveDn s                     = s
diff --git a/tests/pos/state00.hs b/tests/pos/state00.hs
deleted file mode 100644
--- a/tests/pos/state00.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module StateMonad () where
-
-type State  = Int
-data ST a b = Superb (b -> (a, b)) 
-
-{-@ fresh :: ST {v:Int | v >= 0} {v:Int | v >= 0} @-}
-fresh :: ST Int Int
-fresh = Superb (\n -> (n, n+1))
-
-
diff --git a/tests/pos/stateInvarint.hs b/tests/pos/stateInvarint.hs
deleted file mode 100644
--- a/tests/pos/stateInvarint.hs
+++ /dev/null
@@ -1,43 +0,0 @@
-module StateMonad () where
-
-import Prelude hiding (return, (>>=))
-
-data ST s a = S (s -> (a, s))
-{-@ data ST s a <p :: s -> Bool> 
-     = S { x:: (f:s<p> -> (a, s<p>)) } 
-  @-}
-
-{-@ foo :: (Int, {v:Int|v >=0})@-}
-foo = apply action 0
-
-{-@ action :: ST <{\v -> v>=0 }> Int Int@-}
-action :: ST Int Int
-action
- = act1 `comp` \n1 -> 
-   act2 `comp` \n2 -> 
-   return n1
-
-
-{-@ act1 :: ST <{\v -> v>=0 } > Int Int @-}
-act1 :: ST Int Int
-act1 = S (\n -> (n, n+1))
-
-act2 :: ST Int Int
-act2 = S (\n -> (n, n+9))
-
-{-@ apply :: forall <p :: s -> Bool>. ST <p> s a -> f:s<p> -> (a, s <p>) @-}
-apply :: ST s a -> s -> (a, s)
-apply (S f) x = f x
-
-{-@ return :: forall <p:: s -> Bool>. x:a -> ST <p> s {v:a|v=x} @-}
-return ::  a -> ST s a
-return x = S $ \s -> (x, s)
-
-{-@ comp :: forall < p :: s -> Bool>. ST <p> s a -> (a -> ST <p> s b) -> ST <p> s b @-}
-comp :: ST s a -> (a -> ST s b) -> ST s b
-(S m) `comp` k 
-  = S $ \s -> case (m s) of { (r, new_s) -> 
-              case (k r) of { S k2 -> 
-                (k2 new_s) }}
-
-
diff --git a/tests/pos/string00.hs b/tests/pos/string00.hs
deleted file mode 100644
--- a/tests/pos/string00.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Str0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-foo = "dog"
-
-prop1 = liquidAssertB (0 == 0)	
-prop2 = liquidAssertB (1 /= 0)
diff --git a/tests/pos/tagBinder.hs b/tests/pos/tagBinder.hs
deleted file mode 100644
--- a/tests/pos/tagBinder.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module ListSort () where
-
-data Foo a = F Int a
-
-{-@ data Foo a = F {tag :: Int, f :: a} @-}
-
-foo = F
diff --git a/tests/pos/take.hs b/tests/pos/take.hs
deleted file mode 100644
--- a/tests/pos/take.hs
+++ /dev/null
@@ -1,60 +0,0 @@
-{-@ LIQUID "--no-totality"    @-}
-
-{-# LANGUAGE Trustworthy #-}
-{-# LANGUAGE CPP,  NoImplicitPrelude, MagicHash #-}
-{-# OPTIONS_HADDOCK hide #-}
-
-module Take (
-    take0
-  , take
-  ) where
-
-import Data.Maybe
-import GHC.Base 
-import Language.Haskell.Liquid.Prelude (liquidAssert, liquidError, unsafeError) 
-
-
-
-{-@ assert take0  :: n: {v: Int | 0 <= v} -> [a] -> {v:[a] | (len(v) = n)} @-}
-take0 :: Int -> [a] -> [a]
-take0 (I# n#) xs = take_unsafe_UInt0 n# xs
-
-take_unsafe_UInt0 :: Int# -> [a] -> [a]
-take_unsafe_UInt0 0#  _     = []
-take_unsafe_UInt0 n  (x:xs) = x : take_unsafe_UInt0 (n -# 1#) xs
-take_unsafe_UInt0 _   _     = unsafeError "unsafe take"
-
-{-@ assert take  :: n: {v: Int | v >= 0 } -> xs:[a] -> {v:[a] | len v = if len xs < n then (len xs) else n } @-}
-take (I# n#) xs = takeUInt n# xs
--- take (I# n#) xs = take_unsafe_UInt n# xs
-
-takeUInt :: Int# -> [a] -> [a]
-takeUInt n xs
-  | isTrue# (n >=# 0#) =  take_unsafe_UInt n xs
-  | otherwise          =  liquidAssert False []
-
-take_unsafe_UInt :: Int# -> [a] -> [a]
-take_unsafe_UInt 0#  _     = []
-take_unsafe_UInt n ls      =
-  case ls of
-    []     -> []
-    (x:xs) -> x : take_unsafe_UInt (n -# 1#) xs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pos/term0.hs b/tests/pos/term0.hs
deleted file mode 100644
--- a/tests/pos/term0.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module Term0 () where 
-
-import Prelude hiding (sum)
-
-{-@ sum :: Nat -> Nat @-}
-sum   :: Int -> Int
-sum 0 = 0
-sum n = n + sum (n-1)
-
-{-@ fib :: Nat -> Nat @-}
-fib :: Int -> Int 
-fib 0 = 1
-fib 1 = 1 
-fib n = fib (n-1) + fib (n-2)
-
-{-@ sumUp :: Nat -> Nat @-}
-sumUp :: Int -> Int
-sumUp n  = go n 0 0
-  where 
-    go (d :: Int) acc i
-      | i < n     = go (d - 1) (acc + i) (i + 1) 
-      | otherwise = acc
-
-{-@ qualif Diff(v:Int, x:Int, y:Int): v = x - y @-} 
-
-{-@ nonTerm :: Nat -> Nat @-}
-nonTerm :: Int -> Int
-nonTerm n = nonTerm (n+1)
-
-{-@ lazy nonTerm @-}
-
diff --git a/tests/pos/test0.hs b/tests/pos/test0.hs
deleted file mode 100644
--- a/tests/pos/test0.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x = if x > 0 then x else (0 - x)
-
-prop_abs   = let n1 = choose 0 in 
-             liquidAssertB ((myabs n1) >= 0)
diff --git a/tests/pos/test00-int.hs b/tests/pos/test00-int.hs
deleted file mode 100644
--- a/tests/pos/test00-int.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude 
-
-x :: Int
-x = choose 0
-
-prop_abs ::  Bool
-prop_abs = if x > 0 then baz x else False
-
-baz :: Int -> Bool
-baz gooberding = liquidAssertB (gooberding >= 0)
diff --git a/tests/pos/test00.hs b/tests/pos/test00.hs
deleted file mode 100644
--- a/tests/pos/test00.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-
-prop_abs ::  Bool
-prop_abs = if x > 0 then baz x else False
-  where 
-    x    = choose 0
-
-baz gooberding = liquidAssertB (gooberding >= 0)
diff --git a/tests/pos/test00.old.hs b/tests/pos/test00.old.hs
deleted file mode 100644
--- a/tests/pos/test00.old.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-x = choose 0
-
-prop_abs = if x `gt` 0 then baz x else False
-
-baz   :: Int -> Bool
-baz z = liquidAssertB (z `geq` 0)
-
diff --git a/tests/pos/test000.hs b/tests/pos/test000.hs
deleted file mode 100644
--- a/tests/pos/test000.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Test0 () where
-
--- import Language.Haskell.Liquid.Prelude
-{-@ toss :: Bool @-}
-toss :: Bool
-toss = (undefined 0) > 10
-
diff --git a/tests/pos/test000.hs.hquals b/tests/pos/test000.hs.hquals
deleted file mode 100644
--- a/tests/pos/test000.hs.hquals
+++ /dev/null
@@ -1,1 +0,0 @@
-qualif Foo(v: Int): v = 10
diff --git a/tests/pos/test00b.hs b/tests/pos/test00b.hs
deleted file mode 100644
--- a/tests/pos/test00b.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Test0 () where
-
-import Language.Haskell.Liquid.Prelude
-
-x = choose 0
-
-foo x = x
-
-prop_abs = if x > 0 then baz (foo x) else False
-
-baz ::  (Num a, Ord a) => a -> Bool
-baz z = liquidAssertB (z > 0)
diff --git a/tests/pos/test00c.hs b/tests/pos/test00c.hs
deleted file mode 100644
--- a/tests/pos/test00c.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Test00c () where
-
-import Language.Haskell.Liquid.Prelude
-
-getEqs x ys = filter (x ==) ys 
-
-xs :: [Int]
-xs = [1, 2, 3, 4, 5, 6]
-
-prop_abs = map (\z -> liquidAssertB (z >= 0)) ys
-             where ys = getEqs 5 xs
diff --git a/tests/pos/test1.hs b/tests/pos/test1.hs
deleted file mode 100644
--- a/tests/pos/test1.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Test1 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x = if x > 0 then x else 0 - x
-
-n = choose 0
-
-prop_absf = liquidAssertB ((myabs n) >= 0)
diff --git a/tests/pos/test2.hs b/tests/pos/test2.hs
deleted file mode 100644
--- a/tests/pos/test2.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Test1 () where
-
-import Language.Haskell.Liquid.Prelude
-
-myabs x = if x > 0 then x else 0 - x
-
-n = choose 0
-
-prop_absf = 
-  let zz = (myabs n) >= 0 in
-  liquidAssertB zz
diff --git a/tests/pos/testRec.hs b/tests/pos/testRec.hs
deleted file mode 100644
--- a/tests/pos/testRec.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-
-module TestRec where
-
-import Prelude hiding (foldl)
-
-data L a = N | C { hd :: a
-                 , tl :: L a }
-
-{-@ data L [llen] a = N | C { hd :: a
-                            , tl :: L a }
-  @-}
-
-
-{-@ invariant {v:L a | 0 <= llen v} @-}
-
-{-@ measure llen @-}
-llen :: L a -> Int
-llen N        = 0
-llen (C x xs) = 1 + llen xs
-
-reverse :: L a -> L a
-reverse xs = go N xs
-  where 
-    {-@ go :: acc:_ -> xs:_ -> _ / [llen xs] @-}
-    go :: L a -> L a -> L a 
-    go acc N        = acc
-    go acc (C x xs) = go (C x acc) xs
-
-mapL f N = N
-mapL f (C x xs) = C (f x) (mapL f xs)
-
-
diff --git a/tests/pos/top0.hs b/tests/pos/top0.hs
deleted file mode 100644
--- a/tests/pos/top0.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-module Moo (poop, loop, zoo) where
-
-{-@ invariant {v:Int | v >= 0} @-}
-
-{-@ qualif Sum(v:Int, x: Int, y: Int): v = x + y @-}
-
--- | This should get a TOP type
-poop x = zoo x 
-
--- | This is USED but should ALSO get a TOP type (since exported)
-loop x     = go x 0
-  where 
-    go     :: Int -> Int -> Int 
-    go 0 m = m
-    go n m = go (n-1) (m+1)
-
-zoo     = loop
-
-loop' x     = go x 0
-  where 
-    go     :: Int -> Int -> Int 
-    go 0 m = m
-    go n m = go (n-1) (m+1)
-
--- | This HAS a sig so it should NOT get a TOP type
-{-@ zoo' :: x:Int -> {v:Int | v = x} @-}
-zoo'     = loop'
diff --git a/tests/pos/trans.hs b/tests/pos/trans.hs
deleted file mode 100644
--- a/tests/pos/trans.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-module Tx () where
-
-import Language.Haskell.Liquid.Prelude
-
-{- THIS IS A RANDOM COMMENT -}
-
-{-@ foo :: x: Int -> Int @-}
-foo :: Int -> Int
-foo x = x + 1
-
-{-@ transpose :: n:Int
-              -> m:{v:Int | v > 0} 
-              -> {v:[{v:[a] | len(v) = n}] | len(v) = m} 
-              -> {v:[{v:[a] | len(v) = m}] | len(v) = n} 
-  @-}
-transpose :: Int -> Int -> [[a]] -> [[a]]
-transpose 0 _ _              = []
-transpose n m ((x:xs) : xss) = (x : map head xss) : transpose (n - 1) m (xs : map tail xss)
-transpose n m ([] : _)       = liquidError "transpose1" 
-transpose n m []             = liquidError "transpose2"
-
--- NEEDS TAGS: map head xss = [ h | (h:_) <- xss]
--- NEEDS TAGS: map tail xss = [t | (_:t) <- xss]
-
-
diff --git a/tests/pos/transTAG.hs b/tests/pos/transTAG.hs
deleted file mode 100644
--- a/tests/pos/transTAG.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-module Tx () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ foo :: x: Int -> Int @-}
-foo :: Int -> Int
-foo x = x + 1
-
-{-@ transpose :: n:Int
-              -> m:{v:Int | v > 0} 
-              -> {v:[{v:[a] | len(v) = n}] | len(v) = m} 
-              -> {v:[{v:[a] | len(v) = m}] | len(v) = n} 
-  @-}
-transpose :: Int -> Int -> [[a]] -> [[a]]
-transpose 0 _ _              = []
-transpose n m ((x:xs) : xss) = (x : [h | (h:_) <- xss]) : transpose (n - 1) m (xs : [t | (_:t) <- xss])
-transpose n m ([] : _)       = liquidError "transpose1" 
-transpose n m []             = liquidError "transpose2"
-
--- NEEDS TAGS: map head xss = [ h | (h:_) <- xss]
--- NEEDS TAGS: map tail xss = [t | (_:t) <- xss]
-
-
diff --git a/tests/pos/transpose.hs b/tests/pos/transpose.hs
deleted file mode 100644
--- a/tests/pos/transpose.hs
+++ /dev/null
@@ -1,62 +0,0 @@
-{-@ LIQUID "--no-termination" @-}
-{-@ LIQUID "--prune-unsorted" @-}
-{-@ LIQUID "--bscope"         @-}
-
-module Tx (transpose, transpose', transpose'') where
-
-import Language.Haskell.Liquid.Prelude
-
--- | Specifying a matrix
-
-{-@ type Matrix a       = {m0:[{v:[a] | (len v) = (cols m0)}] | true } @-}
-
-{-@ type MatrixCR a C R = {m0:[{v:[a] | (len v) = C}] | (((len m0) = R) && (R > 0 => (cols m0) = C)) } @-}
-
-{-@ measure cols :: [[a]] -> Int
-    cols ([])   = 0
-    cols (x:xs) = (len x)
-  @-}
-
--- | A Few Simple Examples (which run VERY slowly)
-
-{-@ predicate Dim V C R = (((len V) = R) && ((cols V) = C)) @-}
-
-{-@ mat_3_2 :: {v: Matrix Int | (Dim v 3 2)} @-}
-mat_3_2 :: [[Int]]
-mat_3_2 = [ [1,2,3]
-          , [4,5,6] ]
-
-{-@ mat_2_4 :: {v: Matrix Int | (Dim v 2 4)} @-}
-mat_2_4 :: [[Int]]
-mat_2_4 = [ [1,2]
-          , [3,4]
-          , [5,6]
-          , [7,8] ]
-
--- | Old fashioned transpose with explicit dimensions
-
-{- transpose :: c:Nat
-             -> r:{v:Nat | v > 0}
-             -> {v:[{v:[a] | (len v) = c}] | (len v) = r}
-             -> {v:[{v:[a] | (len v) = r}] | (len v) = c}
-  -}
-
-{-@ transpose :: c:Nat -> r:{v:Nat | v > 0}  -> (MatrixCR a c r) -> (MatrixCR a r c) @-}
-transpose     :: Int -> Int -> [[a]] -> [[a]]
-transpose 0 _ _              = []
-transpose n m ((x:xs) : xss) = (x : map head xss) : transpose (n - 1) m (xs : map tail xss)
-transpose n m ([] : _)       = liquidError "transpose1"
-transpose n m []             = liquidError "transpose2"
-
-
-{-@ transpose' :: m:{v:(Matrix a) | ((len v) > 0)} -> (MatrixCR a (len m) (cols m)) @-}
-transpose' :: [[a]] -> [[a]]
-transpose' ([]:_)         = []
-transpose' ((x:xs) : xss) = (x : map head xss) : transpose' (xs : map tail xss)
-transpose' []             = liquidError "transpose'"
-
--- | A wrapper implementing the explicit transpose using the implicit one
-
-{-@ transpose''     :: c:Nat -> r:{v:Nat | v > 0}  -> (MatrixCR a c r) -> (MatrixCR a r c) @-}
-transpose''         :: Int -> Int -> [[a]] -> [[a]]
-transpose'' n m xss = transpose' xss
diff --git a/tests/pos/tup0.hs b/tests/pos/tup0.hs
deleted file mode 100644
--- a/tests/pos/tup0.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module DepTup0 () where
-
-{-@ type PlusOne = (Int, Int)<{\x v -> v > x}> @-}
-
-{-@ plusOne :: PlusOne @-}
-plusOne :: (Int, Int)
-plusOne = (0, 1)
-
-{-@ plusOnes :: Maybe PlusOne @-}
-plusOnes :: Maybe (Int, Int) 
-plusOnes = Just plusOne -- (0, 1) (5,6), (999,1000)]
diff --git a/tests/pos/tupparse.hs b/tests/pos/tupparse.hs
deleted file mode 100644
--- a/tests/pos/tupparse.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-module Fixme () where
-
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-
-data Vec a = V a deriving (Eq)
-
--- this is verified ...
-{-@ bar :: x:Int 
-        -> y:{v: Int | v = x } 
-        -> Int 
-  @-}
-bar     :: Int -> Int -> Int
-bar x y = liquidAssert (x == y) 0
-
--- and so is this...
-
-{-@ goo :: x:[Int] 
-        -> y:{v: [Int] | v = x } 
-        -> Int 
-  @-}
-goo     :: [Int] -> [Int] -> Int
-goo x y = liquidAssert (x == y) 0
-
-
--- BUT THIS IS NOT!!
-{-@ foo :: x: (Vec Int)
-        -> y:{v: Vec Int | v = x } 
-        -> Int 
-  @-}
-foo     :: Vec Int -> Vec Int -> Int
-foo x y = liquidAssert (x == y) 0
-
-
-
diff --git a/tests/pos/tyExpr.hs b/tests/pos/tyExpr.hs
deleted file mode 100644
--- a/tests/pos/tyExpr.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module Foo where
-
-{-@ type Range Lo Hi = {v:Int | Lo <= v && v < Hi} @-}
-
-{-@ bow :: Range 0 100 @-}
-bow :: Int
-bow = 12
diff --git a/tests/pos/tyclass0.hs b/tests/pos/tyclass0.hs
deleted file mode 100644
--- a/tests/pos/tyclass0.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Goo (poop) where
-
-class Zog a where
-  zoom :: a -> Int
-
--- Assume the relevant behavior for the method.
-{-@ zoom :: (Zog a) => a -> Nat @-}
-
--- Uses the behavior of `zoom`
-{-@ poop :: (Zog a) => a -> Nat @-}
-poop x = zoom x
diff --git a/tests/pos/tyfam0.hs b/tests/pos/tyfam0.hs
deleted file mode 100644
--- a/tests/pos/tyfam0.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module Foo () where
-
-import Control.Monad.Primitive
-
-import Data.Vector.Generic.Mutable
-
-{-@ copyOffset :: (PrimMonad m, MVector v e)
-           => v (PrimState m) e -> v (PrimState m) e -> Int -> Int -> Int -> m ()
-  @-}
-
-copyOffset :: (PrimMonad m, MVector v e)
-           => v (PrimState m) e -> v (PrimState m) e -> Int -> Int -> Int -> m ()
-copyOffset = undefined
-
-{-@ zog :: (m s a) -> Nat @-}
-zog :: (m s a) -> Int
-zog = undefined
diff --git a/tests/pos/tyvar.hs b/tests/pos/tyvar.hs
deleted file mode 100644
--- a/tests/pos/tyvar.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module TyVar () where
-
-{-@ foo :: Eq b => a -> b -> a @-}
-foo :: Eq b => a -> b -> a
-foo = undefined
diff --git a/tests/pos/unusedtyvars.hs b/tests/pos/unusedtyvars.hs
deleted file mode 100644
--- a/tests/pos/unusedtyvars.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-module Fixme () where
-
-data F a b c = F (Int -> b -> c)
-{- data F a b c = F (x::(Int -> b -> c)) @-}
-
-
-{-@ bar :: F {v:Int| v >= 0} b c @-}
-bar :: F Int b c
-bar = undefined
-
-
-{-@ foo :: F {v:Int| v >= 0} b c  -> Int @-}
-foo :: F Int b c -> Int
-foo = undefined
-
-{-@ hoo :: Int @-}
-hoo = foo bar
diff --git a/tests/pos/vector00.hs b/tests/pos/vector00.hs
deleted file mode 100644
--- a/tests/pos/vector00.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Vec0 () where
-
-import Language.Haskell.Liquid.Prelude
--- import Data.List
-import Data.Vector hiding (map, concat, zipWith, filter, foldr, foldl, (++))
-
-propVec = (vs ! 3) == 3
-  where xs    = [1,2,3,4] :: [Int]
-        vs    = fromList xs
-        
-
diff --git a/tests/pos/vector1.hs b/tests/pos/vector1.hs
deleted file mode 100644
--- a/tests/pos/vector1.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module Vec1 () where
-
-{-@ LIQUID "--no-termination" @-}
-
-import Language.Haskell.Liquid.Prelude
-import Data.Vector hiding (map, concat, zipWith, filter, foldr, foldl, (++))
-
-for lo hi acc f 
-  | lo < hi   = for (lo + 1) hi (f lo acc) f
-  | otherwise = acc 
-
-dotProd v1 v2 = for 0 n 0 $ \i -> (((v1!i) {- * (v2!i) -}) +)
-  where n = Data.Vector.length v1
-
-sumSquare v = dotProd v v
-
-total = sumSquare $ Data.Vector.fromList [0..100] -- nums
-range i j = for i j [] (:)
-nums  = range 0 100 -- [0..100]
-
--- prop = liquidAssertB (total >= 0)
diff --git a/tests/pos/vector1a.hs b/tests/pos/vector1a.hs
deleted file mode 100644
--- a/tests/pos/vector1a.hs
+++ /dev/null
@@ -1,23 +0,0 @@
-module Vec1 () where
-
-import Language.Haskell.Liquid.Prelude
-import Data.Vector hiding (map, concat, zipWith, filter, foldr, foldl, (++))
-
-
-{-@ invariant {v:Int | v >= 0} @-}
-for :: Int -> Int -> a -> (Int -> a -> a) -> a
-for lo hi  = for' (hi-lo) lo hi
-
-for' :: Int -> Int -> Int -> a -> (Int -> a -> a) -> a
-for' d lo hi acc f 
-  | lo < hi   = for' (d-1) (lo + 1) hi (f lo acc) f
-  | otherwise = acc 
-
-dotProd       :: Vector Int -> Vector Int -> Int
-dotProd v1 v2 = for 0 n 0 $ \i -> (((v1!i) * (v2!i)) +)
-  where n = Data.Vector.length v1
-
-sumSquare   :: Vector Int -> Int
-sumSquare v = dotProd v v
-
-total = sumSquare $ Data.Vector.fromList [0..100]
diff --git a/tests/pos/vector1b.hs b/tests/pos/vector1b.hs
deleted file mode 100644
--- a/tests/pos/vector1b.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-module Vec1 () where
-
-{-@ LIQUID "--no-termination" @-}
-
-import Language.Haskell.Liquid.Prelude
-import Data.Vector hiding (map, concat, zipWith, filter, foldl, foldr, (++))
-
-for lo hi acc f 
-  | lo < hi   = for (lo + 1) hi (f lo acc) f
-  | otherwise = acc 
-
-dotProd v1 v2 = for 0 n 0 $ \i -> (((v1!i) * (v2!i)) +)
-  where n = Data.Vector.length v1
-
-sumSquare v = dotProd v v
-
-total = sumSquare $ Data.Vector.fromList [0..100] -- nums
-range i j = for i j [] (:)
-nums  = range 0 100 -- [0..100]
diff --git a/tests/pos/vector2.hs b/tests/pos/vector2.hs
deleted file mode 100644
--- a/tests/pos/vector2.hs
+++ /dev/null
@@ -1,70 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module Vec2 (dotProduct, safeLookup) where
-
-import Prelude hiding (length)
-import Data.Vector
-import Language.Haskell.Liquid.Prelude (liquidAssert)
-    
-{-@ predicate Lt X Y      = X < Y                         @-}
-{-@ predicate Ge X Y      = not (Lt X Y)                  @-}
-{-@ predicate InBound I A = ((Ge I 0) && (Lt I (vlen A))) @-}
-
-{-@ invariant {v:Int | v >= 0} @-}
-{-@ unsafeLookup :: vec:Vector a 
-                 -> {v: Int | (0 <= v && v < (vlen vec)) } 
-                 -> a @-}
-unsafeLookup vec i = vec ! i
-
-{-@ unsafeLookup' :: vec:Vector a -> {v: Int | (InBound v vec)} -> a @-}
-unsafeLookup' vec i = vec ! i
-
-safeLookup x i 
-  | 0 <= i && i < length x = Just (x ! i)
-  | otherwise              = Nothing 
-
-{-@ absoluteSum   :: Vector Int -> {v: Int | 0 <= v}  @-}
-absoluteSum       :: Vector Int -> Int 
-absoluteSum vec   = if 0 < n then go n 0 0 else 0
-  where
-    go (d::Int) acc i 
-      | i /= n    = go (d-1) (acc + abz (vec ! i)) (i + 1)
-      | otherwise = acc 
-    n             = length vec
-
-abz n = if 0 <= n then n else (0 - n) 
-
-loop :: Int -> Int -> a -> (Int -> a -> a) -> a 
-loop lo hi base f = go (hi-lo) base lo
-  where
-    {-@ decrease go 1 @-}
-    go (d::Int) acc i     
-      | i /= hi   = go (d-1) (f i acc) (i + 1)
-      | otherwise = acc
-
-incr x = x + 1
-
-zoo = incr 29
-
-{-@ dotProduct :: x:(Vector Int) 
-               -> y:{v: Vector Int | (vlen v) = (vlen x)} 
-               -> Int 
-  @-}
-dotProduct     :: Vector Int -> Vector Int -> Int
-dotProduct x y 
-  | length x == length y
-  = loop 0 (length x) 0 (\i -> (+ (x ! i) * (y ! i))) 
-  | otherwise
-  = error "dotProduct only on equal-sized vectors!"
-
-
-{-@ type SparseVector a N = [({v: Int | (0 <= v && v < N)}, a)] @-}
-
-{-@ sparseDotProduct :: (Num a) => x:(Vector a) -> (SparseVector a {(vlen x)}) -> a @-}
-sparseDotProduct x y  = go 0 y
-  where
-    {-@ decrease go 2 @-}
-    go sum ((i, v) : y') = go (sum + (x ! i) * v) y' 
-    go sum []            = sum
-
-
diff --git a/tests/pos/wrap0.hs b/tests/pos/wrap0.hs
deleted file mode 100644
--- a/tests/pos/wrap0.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Wrap0 () where
-
-import Language.Haskell.Liquid.Prelude (liquidError, liquidAssertB)
-
-data Foo a = F a
-
-type IntFoo = Foo Int
-
-{-@ flibberty :: (Eq a) => a -> Bool @-}
-flibberty x   = prop x (F x)
-prop x (F y)  = liquidAssertB (x == y)
-
-{-@ flibInt :: (Num a, Ord a) => a -> Bool @-}
-flibInt x     = prop1 x (F (x + 1))
-prop1 x (F y) = liquidAssertB (x < y) 
-
-{-@ flibXs :: a -> Bool @-}
-flibXs x     = prop2 (F [x, x, x])
-prop2 (F []) = liquidError "not-the-hippopotamus"
-prop2 (F _ ) = True
diff --git a/tests/pos/wrap1.hs b/tests/pos/wrap1.hs
deleted file mode 100644
--- a/tests/pos/wrap1.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
-
-module Wrap0 () where
-
-
-import Language.Haskell.Liquid.Prelude (liquidError, liquidAssertB)
-import Data.Function (on)
-import Data.Ord (comparing)
-
-data WrapType b a = WrapType {getVect :: b, getVal :: a}
-
-instance Eq (WrapType [Double] a) where
-   (==) = (==) `on` getVect
-
-instance Ord (WrapType [Double] a) where
-    compare = comparing getVect
-
-{-@ assert flibXs :: a -> Bool @-}
-flibXs x              = prop1 (WrapType [x, x, x] x)
-prop1 (WrapType [] _) = liquidError "no!"
-prop1 (WrapType _  _) = True
-
-{-@ assert nflibXs :: Nat -> a -> Bool @-}
-nflibXs n x           = prop2 n (WrapType nxs x)
-                        where nxs = replicate n x 
-
-prop2 :: Int -> WrapType [a] t -> Bool
-prop2 n (WrapType xs _) = liquidAssertB (n == length xs) 
-
-
-
-
-
diff --git a/tests/pos/zipSO.hs b/tests/pos/zipSO.hs
deleted file mode 100644
--- a/tests/pos/zipSO.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module Blank () where
-
--- From
--- http://stackoverflow.com/questions/17501777/implementing-a-zipper-for-length-indexed-lists/17503667#17503667
-
-import Prelude hiding ((++))
-
-{-@ zipper :: zs:[a] -> [(a, {v:[a] | (len v) = (len zs) - 1})] @-}
-zipper zs          = go [] zs
-  
-{-@ go :: prev:[a] -> rest:[a] -> [(a, {v:[a] | (len v) = (len prev) + (len rest) - 1})] / [len rest]  @-}
-go :: [a] -> [a] -> [(a, [a])]
-go _    []     = []
-go prev (x:xs) = (x, prev ++ xs) : go (prev ++ [x]) xs
-
-{-@ append :: xs:[a] -> ys:[a] -> {v:[a] | (len v) = (len xs) + (len ys)} @-}
-append [] ys     = ys
-append (x:xs) ys = x : append xs ys
-
-(++) = append
diff --git a/tests/pos/zipW.hs b/tests/pos/zipW.hs
deleted file mode 100644
--- a/tests/pos/zipW.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-module T () where
-
-import Language.Haskell.Liquid.Prelude
-
-{-@ assert zipW :: (a -> b -> c) -> xs : [a] -> ys:{v:[b] | len(v) = len(xs)} -> {v : [c] | len(v) = len(xs)} @-}
-zipW :: (a->b->c) -> [a]->[b]->[c]
-zipW f (a:as) (b:bs) = f a b : zipW f as bs
-zipW _ [] []         = []
-zipW _ [] (_:_)      = liquidError "zipWith1"
-zipW _ (_:_) []      = liquidError "zipWith1"
-
-{-@ assert foo :: (a -> b -> c) -> xs : [a] -> ys:{v:[b] | len(v) = len(xs)} -> {v : [c] | len(v) = len(xs)} @-}
-foo = zipW
-
diff --git a/tests/pos/zipW1.hs b/tests/pos/zipW1.hs
deleted file mode 100644
--- a/tests/pos/zipW1.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Import where 
-	
-import Language.Haskell.Liquid.Prelude -- (safeZipWith)
-
-{-@ foo :: (a -> b -> c) -> xs : [a] -> ys:{v:[b] | len v = len xs} 
-        -> {v : [c] | len v  = len xs} @-}
-foo = safeZipWith
-
-
-{- safeZipWith :: (a -> b -> c) -> xs : [a] -> ys:{v:[b] | len v = len xs} 
-                -> {v : [c] | len v = len xs} @-}
diff --git a/tests/pos/zipW2.hs b/tests/pos/zipW2.hs
deleted file mode 100644
--- a/tests/pos/zipW2.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module ListSort where
-
-
-foo :: [Int] -> [Int]
-foo zs = zipWith (+) zs zs
diff --git a/tests/pos/zipper.hs b/tests/pos/zipper.hs
deleted file mode 100644
--- a/tests/pos/zipper.hs
+++ /dev/null
@@ -1,165 +0,0 @@
-module Zipper (getFocus, getUp, getDown) where
-
-import Prelude hiding (reverse, (++))
-
-import Data.Set
-
-data Stack a = Stack { focus  :: !a        -- focused thing in this set
-                     , up     :: [a]       -- jokers to the left
-                     , down   :: [a] }     -- jokers to the right
-    deriving (Show, Eq)
--- LIQUID     deriving (Show, Read, Eq)
-
--------------------------------------------------------------------------------
------------------------------ Refinements on  Lists ---------------------------
--------------------------------------------------------------------------------
-
--- measures
-
-{-@
-  measure listDup :: forall a. [a] -> (Set a)
-  listDup([]) = {v | Set_emp v }
-  listDup(x:xs) = {v | v = if (Set_mem x (listElts xs)) then (Set_cup (Set_sng x) (listDup xs)) else (listDup xs) }
-  @-}
-
--- predicates
-
-{-@ predicate EqElts X Y =
-       ((listElts X) = (listElts Y)) @-}
-
-{-@ predicate SubElts X Y =
-       (Set_sub (listElts X) (listElts Y)) @-}
-
-{-@ predicate UnionElts X Y Z =
-       ((listElts X) = (Set_cup (listElts Y) (listElts Z))) @-}
-
-{-@ predicate ListElt N LS =
-       (Set_mem N (listElts LS)) @-}
-
-{-@ predicate ListUnique LS =
-       (Set_emp (listDup LS)) @-}
-
-{-@ predicate ListDisjoint X Y =
-       (Set_emp (Set_cap (listElts X) (listElts Y))) @-}
-
-
--- types
-
-{-@ type UList a = {v:[a] | (ListUnique v)} @-}
-
-{-@ type UListDif a N = {v:[a] | ((not (ListElt N v)) && (ListUnique v))} @-}
-
-
-
--------------------------------------------------------------------------------
------------------------------ Refinements on Stacks ---------------------------
--------------------------------------------------------------------------------
-
-{-@
-data Stack a = Stack { focus :: a
-                     , up    :: UListDif a focus
-                     , down  :: UListDif a focus }
-@-}
-
-{-@ type UStack a = {v:Stack a | (ListDisjoint (getUp v) (getDown v))}@-}
-
-{-@ measure getFocus @-}
-getFocus :: Stack a -> a
-getFocus (Stack xfocus _ _) = xfocus
-
-{-@ measure getUp @-}
-getUp :: Stack a -> [a]
-getUp (Stack xfocus xup xdown) = xup
-
-{-@ measure getDown @-}
-getDown :: Stack a -> [a]
-getDown (Stack xfocus xup xdown) = xdown
-
-
--------------------------------------------------------------------------------
------------------------------- Functions on Stacks ----------------------------
--------------------------------------------------------------------------------
-
-
-{-@ differentiate :: UList a -> Maybe (UStack a) @-}
-differentiate :: [a] -> Maybe (Stack a)
-differentiate []     = Nothing
-differentiate (x:xs) = Just $ Stack x [] xs
-
-{-@ integrate :: UStack a -> UList a @-}
-integrate :: Stack a -> [a]
-integrate (Stack x l r) = reverse l ++ x : r
-
-{-@ integrate' :: Maybe (UStack a) -> UList a @-}
-integrate' :: Maybe (Stack a) -> [a]
-integrate' = maybe [] integrate
-
-
-{-@ focusUp :: UStack a -> UStack a @-}
-focusUp :: Stack a -> Stack a
-focusUp (Stack t [] rs)     = Stack x xs [] where (x:xs) = reverse (t:rs)
-focusUp (Stack t (l:ls) rs) = Stack l ls (t:rs)
-
-{-@ focusDown :: UStack a -> UStack a @-}
-focusDown :: Stack a -> Stack a
-focusDown = reverseStack . focusUp . reverseStack
-
-{-@ reverseStack :: UStack a -> UStack a @-}
-reverseStack :: Stack a -> Stack a
-reverseStack (Stack t ls rs) = Stack t rs ls
-
-{-@ swapUp :: UStack a -> UStack a @-}
-swapUp :: Stack a -> Stack a
-swapUp  (Stack t (l:ls) rs) = Stack t ls (l:rs)
-swapUp  (Stack t []     rs) = Stack t (reverse  rs) []
-
-{-@ filter :: (a -> Bool) -> UStack a -> Maybe (UStack a) @-}
-filter :: (a -> Bool) -> Stack a -> Maybe (Stack a)
-filter p (Stack f ls rs) = case filterL p (f:rs) of
-    f':rs' -> Just $ Stack f' (filterL p ls) rs'    -- maybe move focus down
-    []     -> case filterL p ls of                  -- filter back up
-                    f':ls' -> Just $ Stack f' ls' [] -- else up
-                    []     -> Nothing
-
-
--------------------------------------------------------------------------------
-------------------------------- Functions on Lists ----------------------------
--------------------------------------------------------------------------------
-
-
-infixr 5 ++
-{-@ Zipper.++ :: xs:(UList a)
-         -> ys:{v: UList a | (ListDisjoint v xs)}
-         -> {v: UList a | (UnionElts v xs ys)}
-  @-}
-(++) :: [a] -> [a] -> [a]
-[] ++ ys = ys
-(x:xs) ++ ys = x: (xs ++ ys)
-
-
-{-@ reverse :: xs:(UList a)
-            -> {v: UList a | (EqElts v xs)}
-  @-}
-reverse :: [a] -> [a]
-reverse = rev []
-
-
-{-@ rev :: acc:(UList a)
-        -> xs:{v: UList a | ListDisjoint acc v }
-        -> {v:UList a | UnionElts v xs acc } / [len xs]
-  @-}
-rev :: [a] -> [a] -> [a]
-rev a []     = a
-rev a (x:xs) = rev (x:a) xs
-
-{-@ filterL :: (a -> Bool) -> xs:(UList a) -> {v:UList a | (SubElts v xs)} @-}
-filterL :: (a -> Bool) -> [a] -> [a]
-filterL p [] = []
-filterL p (x:xs) | p x       = x : filterL p xs
-                 | otherwise = filterL p xs
-
-
--- QUALIFIERS
-{-@ q :: x:a ->  {v:[a] |(not (Set_mem x (listElts v)))} @-}
-q :: a -> [a]
-q = undefined
diff --git a/tests/pos/zipper0.hs b/tests/pos/zipper0.hs
deleted file mode 100644
--- a/tests/pos/zipper0.hs
+++ /dev/null
@@ -1,71 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-module Zipper (getUp, getDown, getFocus) where
-
-import Prelude hiding (reverse)
-
-import Data.Set
-
-data Stack a = Stack { focus  :: !a        -- focused thing in this set
-                     , up     :: [a]       -- jokers to the left
-                     , down   :: [a] }     -- jokers to the right
-
-{-@ type UListDif a N = {v:[a] | ((not (Set_mem N (listElts v))) && (Set_emp (listDup v)))} @-}
-
-{-@
-data Stack a = Stack { focus :: a
-                     , up    :: UListDif a focus
-                     , down  :: UListDif a focus }
-@-}
-
-{-@ measure listDup :: [a] -> (Set a)
-  listDup([]) = {v | Set_emp v }
-  listDup(x:xs) = {v | v = if (Set_mem x (listElts xs)) then (Set_cup (Set_sng x) (listDup xs)) else (listDup xs) }
-  @-}
-
-{-@ type UStack a = {v:Stack a |(Set_emp (Set_cap (listElts (getUp v)) (listElts (getDown v))))}@-}
-
-{-@ measure getFocus @-}
-getFocus :: Stack a -> a
-getFocus (Stack xfocus _ _) = xfocus
-
-{-@ measure getUp @-}
-getUp :: Stack a -> [a]
-getUp (Stack xfocus xup xdown) = xup
-
-{-@ measure getDown @-}
-getDown :: Stack a -> [a]
-getDown (Stack xfocus xup xdown) = xdown
-
-
--- QUALIFIERS
-{-@ q :: x:a ->  {v:[a] |(not (Set_mem x (listElts v)))} @-}
-q :: a -> [a]
-q = undefined
-{-@ q1 :: x:a ->  {v:[a] |(Set_mem x (listElts v))} @-}
-q1 :: a -> [a]
-q1 = undefined
-{-@ q0 :: x:a ->  {v:[a] |(Set_emp(listDup v))} @-}
-q0 :: a -> [a]
-q0 = undefined
-
-
-{-@ focusUp :: UStack a -> UStack a @-}
-focusUp :: Stack a -> Stack a
-focusUp (Stack t [] rs)     = Stack xiggety xs [] where (xiggety:xs) = reverse (t:rs)
-focusUp (Stack t (l:ls) rs) = Stack l ls (t:rs)
-
-{-@ focusDown :: UStack a -> UStack a @-}
-focusDown :: Stack a -> Stack a
-focusDown = reverseStack . focusUp . reverseStack
-
--- | reverse a stack: up becomes down and down becomes up.
-{-@ reverseStack :: UStack a -> UStack a @-}
-reverseStack :: Stack a -> Stack a
-reverseStack (Stack t ls rs) = Stack t rs ls
-
-
--- TODO ASSUMES
-{-@ reverse :: {v:[a] | (Set_emp (listDup v))} -> {v:[a]|(Set_emp (listDup v))} @-}
-reverse :: [a] -> [a]
-reverse = undefined
diff --git a/tests/pos/zipper000.hs b/tests/pos/zipper000.hs
deleted file mode 100644
--- a/tests/pos/zipper000.hs
+++ /dev/null
@@ -1,44 +0,0 @@
-{-@ LIQUID "--no-totality" @-}
-
-module Zipper (getUp, getDown) where
-
-import Data.Set
-
-data Stack a = Stack { focus  :: a        -- focused thing in this set
-                     , up     :: [a]       -- jokers to the left
-                     , down   :: [a] }     -- jokers to the right
-
-{-@ type UListDif a N = {v:[a] | not (Set_mem N (listElts v)) } @-}
-
-{-@ data Stack a = Stack 
-      { focus :: a
-      , up    :: UListDif a focus
-      , down  :: UListDif a focus 
-      }
-  @-}
-
-{-@ type UStack a = {v:Stack a | (Set_emp (Set_cap (listElts (getUp v)) (listElts (getDown v))))} @-}
-
-{-@ measure getUp @-}
-getUp :: Stack a -> [a]
-getUp (Stack xfocus xup xdown) = xup
-
-{-@ measure getDown @-}
-getDown :: Stack a -> [a]
-getDown (Stack xfocus xup xdown) = xdown
-
-data Foo a b = J | P a b
-
---------------------------------------------------------------------------------------
-{-@ focusUp :: UStack a -> UStack a @-}
-focusUp :: Stack a -> Stack a
-focusUp (Stack t [] rs) = Stack xiggety xs []
-  where P xiggety xs    = P t rs
-
--- focusUp (Stack t [] rs) = Stack t rs []
-
-
-
-
-
---------------------------------------------------------------------------------------
diff --git a/tests/test.hs b/tests/test.hs
deleted file mode 100644
--- a/tests/test.hs
+++ /dev/null
@@ -1,909 +0,0 @@
-{-# LANGUAGE CPP  #-}
-{-# LANGUAGE DeriveDataTypeable  #-}
-{-# LANGUAGE DoAndIfThenElse     #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE OverloadedStrings #-}
-
-module Main where
-
-import Data.Function (on)
-import Control.Applicative
-import qualified Control.Concurrent.STM as STM
-import qualified Control.Monad.State as State
-import Control.Monad.Trans.Class (lift)
-import Control.Monad (when)
-import Data.Char
-import qualified Data.Functor.Compose as Functor
-import qualified Data.IntMap as IntMap
-import qualified Data.Map as Map
-import qualified Data.List as L 
-import Data.Maybe (fromMaybe)
-import Data.Monoid (Sum(..))
-import Data.Proxy
-import Data.String
-import Data.String.Conv
-import Data.Tagged
-import Data.Typeable
--- import Data.List (sort, reverse)
-import qualified Data.Text    as T
-import qualified Data.Text.IO as T
-import Options.Applicative
-import System.Directory
-import System.Environment
-import System.Exit
-import System.FilePath
-import System.IO
-import System.IO.Error
-import System.Process
-import Test.Tasty
-import Test.Tasty.Golden
-import Test.Tasty.HUnit
-import Test.Tasty.Ingredients.Rerun
-import Test.Tasty.Options
-import Test.Tasty.Runners
-import Test.Tasty.Runners.AntXML
-import Paths_liquidhaskell
-
-import Text.Printf
-
-
-
-testRunner :: Ingredient
-testRunner = rerunningTests
-               [ listingTests
-               , combineReporters myConsoleReporter antXMLRunner
-               , myConsoleReporter
-               ]
-
-myConsoleReporter :: Ingredient
-myConsoleReporter = combineReporters consoleTestReporter loggingTestReporter
-
-main :: IO ()
-main = do unsetEnv "LIQUIDHASKELL_OPTS"
-          -- We don't run tests in depedency order, so having stale
-          -- .liquid/ *.hs.bspec files can causes problems.
-          -- system "rm -r tests/pos/.liquid/"
-          -- system "rm -r tests/neg/.liquid/"
-          run =<< tests
-  where
-    run   = defaultMainWithIngredients [
-                testRunner
-              , includingOptions [ Option (Proxy :: Proxy NumThreads)
-                                 , Option (Proxy :: Proxy LiquidOpts)
-                                 , Option (Proxy :: Proxy LiquidRunner)
-                                 , Option (Proxy :: Proxy SmtSolver) ]
-              ]
-    tests = group "Tests" $ microTests  :
-                            errorTests  : 
-                            macroTests  :
-                            proverTests :
-                            goldenTests :
-                            benchTests  : 
-                            []
-                           
-
-    -- tests = group "Tests" [ unitTests  ]
-    -- tests = group "Tests" [ benchTests ]
-    -- tests = group "Tests" [ selfTests  ]
-    -- tests = group "Tests" [ errorTests ]
-
-data SmtSolver = Z3 | CVC4 deriving (Show, Read, Eq, Ord, Typeable)
-
-instance IsOption SmtSolver where
-  defaultValue = Z3
-  parseValue = safeRead . map toUpper
-  optionName = return "smtsolver"
-  optionHelp = return "Use this SMT solver"
-  optionCLParser =
-    option (fmap (read . map toUpper) str)
-      (  long (untag (optionName :: Tagged SmtSolver String))
-      <> help (untag (optionHelp :: Tagged SmtSolver String))
-      )
-
-newtype LiquidOpts = LO String deriving (Show, Read, Eq, Ord, Typeable, IsString)
-
-instance Semigroup LiquidOpts where
-  (LO "") <> y       = y
-  x       <> (LO "") = x
-  (LO x)  <> (LO y)  = LO $ x ++ (' ' : y)
-
-instance Monoid LiquidOpts where
-  mempty = LO ""
-  mappend = (<>)
-
-instance IsOption LiquidOpts where
-  defaultValue = LO ""
-  parseValue = Just . LO
-  optionName = return "liquid-opts"
-  optionHelp = return "Extra options to pass to LiquidHaskell"
-  optionCLParser =
-    option (fmap LO str)
-      (  long (untag (optionName :: Tagged LiquidOpts String))
-      <> help (untag (optionHelp :: Tagged LiquidOpts String))
-      )
-
--- 
--- Controlling the invocation of \"liquid\"
---
--- During the tests we require the executable \"liquid\" to be reachable and in the PATH in order to be
--- able to run the tests. However, \"liquid\" might require to be run with a proper configuration, for
--- example with the correct \"-package-db\" in order to check some files. To do so we can use something like
--- \"stack exec -- liquid\", which would work for Stack but not \"cabal new-*\". To mitigate this, we introduce
--- the \"liquid-runner\" option which can be used to override this choice.
-
-newtype LiquidRunner = LiquidRunner String
-  deriving (Show, Read, Eq, Ord, Typeable, IsString, Semigroup, Monoid)
-
-instance IsOption LiquidRunner where
-  defaultValue = LiquidRunner "stack --silent exec -- liquidhaskell -v0"
-  parseValue = Just . LiquidRunner
-  optionName = return "liquid-runner"
-  optionHelp = return "Specifies the full path or command which will run 'liquid'."
-  optionCLParser =
-    option (fmap LiquidRunner str)
-      (  long (untag (optionName :: Tagged LiquidRunner String))
-      <> help (untag (optionHelp :: Tagged LiquidRunner String))
-      )
-
-errorTests :: IO TestTree
-errorTests = group "Error-Messages"
-  [ 
-    -- errorTest "tests/errors/ExportMeasure0.hs"      2 "Cannot lift `llen` into refinement logic"
-    -- errorTest "tests/errors/ExportReflect0.hs"      2 "Cannot lift `identity` into refinement logic"
-    -- errorTest "tests/errors/ExportMeasure1.hs"      2 "Cannot lift `psnd` into refinement logic"
-    -- , errorTest "tests/errors/ShadowMeasureVar.hs"    2 "Multiple specifications for `shadow`"
-    -- , errorTest "tests/errors/AmbiguousReflect.hs"    2 "Ambiguous specification symbol `mappend`"
-    -- , errorTest "tests/errors/AmbiguousInline.hs"     2 "Ambiguous specification symbol `min`"
-    -- , errorTest "tests/errors/MissingAbsRefArgs.hs"   2 "Illegal type specification for `Fixme.bar`"
-
-    errorTest "tests/errors/ReWrite8.hs"            1 "Could not generate any rewrites from equality"
-  , errorTest "tests/errors/ReWrite7.hs"            1 "Could not generate any rewrites from equality"
-  , errorTest "tests/errors/ReWrite6.hs"            1 "Unable to use ReWrite6.bad as a rewrite because it does not prove an equality"
-  , errorTest "tests/errors/ReWrite5.hs"            1 "parameter \"xs\" contains an inner refinement"
-  , errorTest "tests/errors/ShadowFieldInline.hs"   1 "Multiple specifications for `pig`"
-  , errorTest "tests/errors/ShadowFieldReflect.hs"  1 "Multiple specifications for `pig`"
-  , errorTest "tests/errors/MultiRecSels.hs"        1 "Duplicated definitions for field `left`" 
-  , errorTest "tests/errors/DupFunSigs.hs"          1 "Multiple specifications for `Main.fromWeekDayNum`"
-  , errorTest "tests/errors/DupMeasure.hs"          1 "Multiple specifications for `lenA`"
-  , errorTest "tests/errors/ShadowMeasure.hs"       1 "Multiple specifications for `shadow`"
-  , errorTest "tests/errors/DupData.hs"             1 "Multiple specifications for `OVec`"
-  , errorTest "tests/errors/EmptyData.hs"           1 "one or more fields in the data declaration for `A`"
-  , errorTest "tests/errors/BadGADT.hs"             1 "Specified type does not refine Haskell type for `Main.Nil2`" 
-  , errorTest "tests/errors/TerminationExprSort.hs" 1 "Illegal termination specification for `TerminationExpr.showSep`"
-  , errorTest "tests/errors/TerminationExprNum.hs"  1 "Illegal termination specification for `TerminationExpr.showSep`"
-  , errorTest "tests/errors/TerminationExprUnb.hs"  1 "Illegal termination specification for `go`"
-  , errorTest "tests/errors/UnboundVarInSpec.hs"    1 "Illegal type specification for `Fixme.foo`"
-  , errorTest "tests/errors/UnboundVarInAssume.hs"  1 "Illegal type specification for `Assume.incr`"
-  , errorTest "tests/errors/UnboundCheckVar.hs"     1 "Unknown variable `UnboundCheckVar.ink`"
-  , errorTest "tests/errors/UnboundFunInSpec.hs"    1 "Illegal type specification for `Goo.three`"
-  , errorTest "tests/errors/UnboundFunInSpec1.hs"   1 "Illegal type specification for `Goo.foo`"
-  , errorTest "tests/errors/UnboundFunInSpec2.hs"   1 "Illegal type specification for `Goo.foo`"
-  , errorTest "tests/errors/UnboundVarInLocSig.hs"  1 "Illegal type specification for `bar`" 
-  , errorTest "tests/errors/UnboundVarInReflect.hs" 1 "Illegal type specification for `UnboundVarInReflect.frog`" 
-  , errorTest "tests/errors/Fractional.hs"          1 "Illegal type specification for `Crash.f`"
-  , errorTest "tests/errors/T773.hs"                1 "Illegal type specification for `LiquidR.incr`"
-  , errorTest "tests/errors/T774.hs"                1 "Illegal type specification for `LiquidR.incr`"
-  , errorTest "tests/errors/T1498.hs"               1 "Standalone class method refinement"
-  , errorTest "tests/errors/T1498A.hs"              1 "Bad Data Specification"
-  , errorTest "tests/errors/Inconsistent0.hs"       1 "Specified type does not refine Haskell type for `Ast.id1`" 
-  , errorTest "tests/errors/Inconsistent1.hs"       1 "Specified type does not refine Haskell type for `Boo.incr` (Checked)"
-  , errorTest "tests/errors/Inconsistent2.hs"       1 "Specified type does not refine Haskell type for `Mismatch.foo` (Checked)"
-  , errorTest "tests/errors/BadAliasApp.hs"         1 "Malformed application of type alias `ListN`"
-  , errorTest "tests/errors/BadPragma0.hs"          1 "Illegal pragma"
-  , errorTest "tests/errors/BadPragma1.hs"          1 "Illegal pragma"
-  , errorTest "tests/errors/BadPragma2.hs"          1 "Illegal pragma"
-  , errorTest "tests/errors/BadSyn1.hs"             1 "Malformed application of type alias `Fooz`"
-  , errorTest "tests/errors/BadSyn2.hs"             1 "Malformed application of type alias `Zoo.Foo`"
-  , errorTest "tests/errors/BadSyn3.hs"             1 "Malformed application of type alias `Zoo.Foo`"
-  , errorTest "tests/errors/BadSyn4.hs"             1 "Malformed application of type alias `Foo.Point`"
-  , errorTest "tests/errors/BadAnnotation.hs"       1 "Malformed annotation"
-  , errorTest "tests/errors/BadAnnotation1.hs"      1 "Malformed annotation"
-  , errorTest "tests/errors/CyclicExprAlias0.hs"    1 "Cyclic type alias definition"
-  , errorTest "tests/errors/CyclicExprAlias1.hs"    1 "Cyclic type alias definition" 
-  , errorTest "tests/errors/CyclicExprAlias2.hs"    1 "Cyclic type alias definition"
-  , errorTest "tests/errors/CyclicExprAlias3.hs"    1 "Cyclic type alias definition"
-  , errorTest "tests/errors/DupAlias.hs"            1 "Multiple definitions of Type Alias `BoundedNat`"
-  , errorTest "tests/errors/DupAlias.hs"            1 "Multiple definitions of Pred Alias `Foo`"
-  , errorTest "tests/errors/BadDataConType.hs"      1 "Illegal type specification for `Boo.fldY`" 
-  , errorTest "tests/errors/BadDataConType1.hs"     1 "Specified type does not refine Haskell type for `Boo.C`" 
-                                                       -- "Illegal type specification for `Boo.fldY`" 
-
-  , errorTest "tests/errors/BadDataConType2.hs"     1 "different numbers of fields for `Boo.C`" 
-  , errorTest "tests/errors/LiftMeasureCase.hs"     1 "Cannot create measure 'Measures.foo': Does not have a case-of at the top-level"
-  , errorTest "tests/errors/HigherOrderBinder.hs"   1 "Illegal type specification for `Main.foo`"
-  , errorTest "tests/errors/HoleCrash1.hs"          1 "Illegal type specification for `ListDemo.t`"
-  , errorTest "tests/errors/HoleCrash2.hs"          1 "Malformed application of type alias `Geq`"
-  , errorTest "tests/errors/HoleCrash3.hs"          1 "Specified type does not refine Haskell type for `ListDemo.countUp`"
-  , errorTest "tests/errors/BadPredApp.hs"          1 "Malformed predicate application"
-  , errorTest "tests/errors/LocalHole.hs"           1 "Illegal type specification for `go`"
-  , errorTest "tests/errors/UnboundAbsRef.hs"       1 "Cannot apply unbound abstract refinement `p`"
-  -- , errorTest "tests/errors/BadQualifier.hs"        2 "Illegal qualifier specification for `Foo`"
-  , errorTest "tests/errors/ParseClass.hs"          1 "Cannot parse specification"
-  , errorTest "tests/errors/ParseBind.hs"           1 "Cannot parse specification"
-  , errorTest "tests/errors/MultiInstMeasures.hs"   1 "Multiple instance measures `sizeOf` for type `GHC.Ptr.Ptr`"
-  , errorTest "tests/errors/BadDataDeclTyVars.hs"   1 "Mismatch in number of type variables for `L`"
-  , errorTest "tests/errors/BadDataCon2.hs"         1 "GHC and Liquid specifications have different numbers of fields for `Boo.Cuthb`"
-  , errorTest "tests/errors/BadSig0.hs"             1 "Illegal type specification for `Zoo.foo`"
-  , errorTest "tests/errors/BadSig1.hs"             1 "Illegal type specification for `Ev.EZ`"
-  , errorTest "tests/errors/BadData1.hs"            1 "`Main.EntityField` is not the type constructed by"
-  , errorTest "tests/errors/BadData2.hs"            1 "`Boo.Hog` is not the type constructed by `Cuthb`"
-  , errorTest "tests/errors/T1140.hs"               1 "Specified type does not refine Haskell type for `Blank.foo`"
-  , errorTest "tests/errors/InlineSubExp0.hs"       1 "== f B C"
-  , errorTest "tests/errors/InlineSubExp1.hs"       1 "== f B (g A)"
-  , errorTest "tests/errors/EmptySig.hs"            1 "Cannot parse specification"
-  , errorTest "tests/errors/MissingReflect.hs"      1 "Illegal type specification for `Main.empty_foo`" 
-  , errorTest "tests/errors/MissingSizeFun.hs"      1 "Unknown variable `llen2`" 
-  , errorTest "tests/errors/MissingAssume.hs"       1 "Unknown variable `goober`" 
-  , errorTest "tests/errors/HintMismatch.hs"        1 "HINT: Use the hole"
-  , errorTest "tests/errors/ElabLocation.hs"        1 "ElabLocation.hs:13:14-13:15: Error"
-  , errorTest "tests/errors/ErrLocation.hs"         1 "ErrLocation.hs:9:13"
-  , errorTest "tests/errors/ErrLocation2.hs"        1 "ErrLocation2.hs:11:20: error:"
-  , errorTest "tests/reflect/neg/frog.hs"           1 "Unbound symbol GHC.Err.undefined"
-  , errorTest "tests/reflect/neg/T1708.hs"          1 "Unbound symbol T1708.bool1"
-  -- , errorTest "tests/errors/UnknownTyConHole.hs"    2 "HINT: Use the hole" 
-  -- TODO-REBARE ?, errorTest "tests/errors/MissingField1.hs"        2 "Error: Unknown field `goober`" 
-  -- TODO-REBARE ?, errorTest "tests/errors/MissingField2.hs"        2 "Error: Unknown field `fxx`" 
-  ]
-
-macroTests :: IO TestTree
-macroTests = group "Macro"
-   [ testGroup "unit-pos"       <$> dirTests "tests/pos"                            posIgnored        ExitSuccess
-   , testGroup "unit-neg"       <$> dirTests "tests/neg"                            negIgnored        (ExitFailure 1)
-   ] 
-
-goldenTests :: IO TestTree
-goldenTests = group "Golden tests"
-   [ pure $ goldenTest "--json output" "tests/golden" "json_output" [LO "--json"]
-   ] 
-
-goldenTest :: TestName -> FilePath -> FilePath -> [LiquidOpts] -> TestTree
-goldenTest testName dir filePrefix testOpts =
-  askOption $ \(smt  :: SmtSolver) -> 
-  askOption $ \(opts :: LiquidOpts) ->
-  askOption $ \(bin  :: LiquidRunner) ->
-    goldenVsString testName
-                   (dir </> filePrefix <> ".golden") 
-                   (toS . snd <$> runLiquidOn smt (mconcat testOpts <> opts) bin dir (filePrefix <> ".hs"))
-
-
-microTests :: IO TestTree
-microTests = group "Micro"
-  [ mkMicro "parser-pos"     "tests/parser/pos"      ExitSuccess
-  , mkMicro "basic-pos"      "tests/basic/pos"       ExitSuccess
-  , mkMicro "basic-neg"      "tests/basic/neg"       (ExitFailure 1)
-  , mkMicro "measure-pos"    "tests/measure/pos"     ExitSuccess          -- measPosOrder
-  , mkMicro "measure-neg"    "tests/measure/neg"     (ExitFailure 1)
-  , mkMicro "datacon-pos"    "tests/datacon/pos"     ExitSuccess          
-  , mkMicro "datacon-neg"    "tests/datacon/neg"     (ExitFailure 1)
-  , mkMicro "names-pos"      "tests/names/pos"       ExitSuccess
-  , mkMicro "names-neg"      "tests/names/neg"       (ExitFailure 1)
-  , mkMicro "reflect-pos"    "tests/reflect/pos"     ExitSuccess
-  , mkMicro "reflect-neg"    "tests/reflect/neg"     (ExitFailure 1) 
-  , mkMicro "absref-pos"     "tests/absref/pos"      ExitSuccess
-  , mkMicro "absref-neg"     "tests/absref/neg"      (ExitFailure 1)
-  -- , mkMicro "import-lib"     "tests/import/lib"      ExitSuccess       -- NOT disabled; but via CHECK-IMPORTS
-  , mkMicro "import-cli"     "tests/import/client"   ExitSuccess
-  , mkMicro "class-pos"      "tests/classes/pos"     ExitSuccess
-  , mkMicro "class-neg"      "tests/classes/neg"     (ExitFailure 1)        
-  , mkMicro "ple-pos"        "tests/ple/pos"         ExitSuccess
-  , mkMicro "ple-neg"        "tests/ple/neg"         (ExitFailure 1)
-  , mkMicro "rankN-pos"      "tests/RankNTypes/pos"         ExitSuccess
-  , mkMicro "terminate-pos"  "tests/terminate/pos"   ExitSuccess
-  , mkMicro "terminate-neg"  "tests/terminate/neg"   (ExitFailure 1)
-  , mkMicro "pattern-pos"    "tests/pattern/pos"     ExitSuccess
-  , mkMicro "class-laws-pos" "tests/class-laws/pos"  ExitSuccess
-  , mkMicro "class-laws-crash" "tests/class-laws/crash" (ExitFailure 1)
-  , mkMicro "class-laws-neg"   "tests/class-laws/neg"   (ExitFailure 1)
-  , mkMicro "implicit-pos"   "tests/implicit/pos"    ExitSuccess
-  , mkMicro "implicit-neg"   "tests/implicit/neg"   (ExitFailure 1)
-  -- RJ: disabling because broken by adt PR #1068
-  -- , testGroup "gradual/pos"    <$> dirTests "tests/gradual/pos"                    []                ExitSuccess
-  -- , testGroup "gradual/neg"    <$> dirTests "tests/gradual/neg"                    []                (ExitFailure 1)
-  ]
-  where 
-    mkMicro name dir res    = testGroup name <$> dirTests  dir [] res 
-
-
-posIgnored    = [ "mapreduce.hs" ]
-gPosIgnored   = ["Intro.hs"]
-gNegIgnored   = ["Interpretations.hs", "Gradual.hs"]
-
-benchTests :: IO TestTree
-benchTests = group "Benchmarks"
-  [ testGroup "cse230"      <$> dirTests   "benchmarks/cse230/src/Week10"         []                        ExitSuccess
-  , testGroup "esop"        <$> dirTests   "benchmarks/esop2013-submission"       esopIgnored               ExitSuccess
-  , testGroup "vect-algs"   <$> odirTests  "benchmarks/vector-algorithms-0.5.4.2" []            vectOrder   ExitSuccess
-  , testGroup "bytestring"  <$> odirTests  "benchmarks/bytestring-0.9.2.1"        bsIgnored     bsOrder     ExitSuccess
-  , testGroup "text"        <$> odirTests  "benchmarks/text-0.11.2.3"             textIgnored   textOrder   ExitSuccess
-  , testGroup "icfp_pos"    <$> odirTests  "benchmarks/icfp15/pos"                icfpIgnored   icfpOrder   ExitSuccess
-  , testGroup "icfp_neg"    <$> odirTests  "benchmarks/icfp15/neg"                icfpIgnored   icfpOrder   (ExitFailure 1)
-  ]
-
--- AUTO-ORDER _impLibOrder :: Maybe FileOrder 
--- AUTO-ORDER _impLibOrder = Just . mkOrder $ [ "T1102_LibZ.hs", "WrapLibCode.hs", "STLib.hs", "T1102_LibY.hs" ]
--- AUTO-ORDER 
--- AUTO-ORDER _dconPosOrder :: Maybe FileOrder 
--- AUTO-ORDER _dconPosOrder = Just . mkOrder $ [ "Data02Lib.hs" ]
--- AUTO-ORDER 
--- AUTO-ORDER _measPosOrder :: Maybe FileOrder 
--- AUTO-ORDER _measPosOrder = Just . mkOrder $ [ "List00Lib.hs" ]
-
-proverOrder :: Maybe FileOrder 
-proverOrder = Just . mkOrder $ 
-  [ "Proves.hs"
-  , "Helper.hs" 
-  ]
-
-icfpOrder :: Maybe FileOrder 
-icfpOrder = Just . mkOrder $ 
-  [ "RIO.hs" 
-  , "RIO2.hs"
-  , "WhileM.hs" 
-  , "DataBase.hs"
-  ]
-
-vectOrder :: Maybe FileOrder 
-vectOrder = Just . mkOrder $ 
-  [ "Data/Vector/Algorithms/Common.hs"
-  , "Data/Vector/Algorithms/Search.hs"
-  , "Data/Vector/Algorithms/Radix.hs"
-  , "Data/Vector/Algorithms/Termination.hs"
-  , "Data/Vector/Algorithms/Optimal.hs"
-  , "Data/Vector/Algorithms/Insertion.hs"
-  , "Data/Vector/Algorithms/Merge.hs"
-  , "Data/Vector/Algorithms/Heap.hs"
-  , "Data/Vector/Algorithms/Intro.hs"
-  , "Data/Vector/Algorithms/AmericanFlag.hs" 
-  ]  
- 
-bsOrder :: Maybe FileOrder 
-bsOrder = Just . mkOrder $ 
-  [ "Data/ByteString/Internal.hs" 
-  , "Data/ByteString/Lazy/Internal.hs" 
-  , "Data/ByteString/Fusion.hs" 
-  , "Data/ByteString/Fusion.T.hs" 
-  , "Data/ByteString/Unsafe.hs" 
-  , "Data/ByteString.T.hs"
-  , "Data/ByteString.hs"
-  , "Data/ByteString/Lazy.hs"
-  , "Data/ByteString/LazyZip.hs"
-  ]
-
-textOrder :: Maybe FileOrder 
-textOrder = Just . mkOrder $ 
-  [ "Data/Text/Encoding/Utf16.hs"       -- skip
-  , "Data/Text/Unsafe/Base.hs"          -- skip
-  , "Data/Text/UnsafeShift.hs"          -- skip
-  , "Data/Text/Util.hs"
-  , "Data/Text/Fusion/Size.hs"
-  , "Data/Text/Fusion/Internal.hs"      -- skip
-  , "Data/Text/Fusion/CaseMapping.hs"   -- skip
-  , "Data/Text/Fusion/Common.hs"        -- skip
-  , "Data/Text/Array.hs"
-  , "Data/Text/UnsafeChar.hs"
-  , "Data/Text/Internal.hs"
-  , "Data/Text/Search.hs"
-  , "Data/Text/Axioms.hs"               
-  , "Data/Text/Unsafe.hs"
-  , "Data/Text/Private.hs"
-  , "Data/Text/Fusion/Common.hs"
-  , "Data/Text/Fusion.hs"
-  , "Data/Text/Foreign.hs"
-  , "Data/Text.hs"
-  , "Data/Text/Lazy/Internal.hs"
-  , "Data/Text/Lazy/Search.hs"
-  , "Data/Text/Lazy/Fusion.hs"
-  , "Data/Text/Lazy.hs"
-  , "Data/Text/Lazy/Builder.hs"
-  , "Data/Text/Encoding/Fusion.hs"
-  , "Data/Text/Encoding.hs"
-  , "Data/Text/Lazy/Encoding/Fusion.hs"
-  , "Data/Text/Lazy/Encoding.hs"
-  ] 
-  
--- errorTest "tests/errors/ShadowFieldInline.hs"   2 "Error: Multiple specifications for `pig`"
-
-proverTests :: IO TestTree
-proverTests = group "Prover"
-  [ testGroup "foundations"     <$> dirTests  "benchmarks/sf"                []                          ExitSuccess
-  , testGroup "prover_ple_lib"  <$> odirTests "benchmarks/popl18/lib"        []             proverOrder  ExitSuccess
-  , testGroup "without_ple_pos" <$> odirTests "benchmarks/popl18/nople/pos"  noPleIgnored   proverOrder  ExitSuccess
-  , testGroup "without_ple_neg" <$> odirTests "benchmarks/popl18/nople/neg"  noPleIgnored   proverOrder (ExitFailure 1)
-  , testGroup "with_ple"        <$> odirTests "benchmarks/popl18/ple/pos"    autoIgnored    proverOrder  ExitSuccess
-  ]
-
-
-selfTests :: IO TestTree
-selfTests
-  = group "Self" [
-      testGroup "liquid"      <$> dirTests "src"  [] ExitSuccess
-  ]
-
---------------------------------------------------------------------------------
--- | For each file in `root` check, that we get the given exit `code.`
---------------------------------------------------------------------------------
-dirTests :: FilePath -> [FilePath] -> ExitCode -> IO [TestTree]
---------------------------------------------------------------------------------
-dirTests root ignored ecode = odirTests root ignored Nothing ecode 
-
---------------------------------------------------------------------------------
-odirTests :: FilePath -> [FilePath] -> Maybe FileOrder -> ExitCode -> IO [TestTree]
---------------------------------------------------------------------------------
-odirTests root ignored fo ecode = do 
-  files     <- walkDirectory False root
-  -- print (show files)
-  let tests  = sortOrder fo [ rel | f <- files
-                                  , isTest f
-                                  , let rel = makeRelative root f
-                                  , rel `notElem` ignored 
-                            ]
-  -- print (show tests)
-  return     $ mkCodeTest ecode root <$> tests
-
-mkCodeTest :: ExitCode -> FilePath -> FilePath -> TestTree
-mkCodeTest code dir file = mkTest (EC file code Nothing) dir file
-
-isTest   :: FilePath -> Bool
-isTest f =  takeExtension f == ".hs"
-         || takeExtension f == ".lhs"
-
---------------------------------------------------------------------------------
--- | @FileOrder@ is a hack to impose a "build" order on the paths in a given directory
---------------------------------------------------------------------------------
-type FileOrder = Map.Map FilePath Int 
-
-getOrder :: FileOrder -> FilePath -> Int 
-getOrder m f = Map.findWithDefault (1 + Map.size m) f m 
-
-mkOrder :: [FilePath] -> FileOrder 
-mkOrder fs = Map.fromList (zip fs [0..])
-
-defaultFileOrder :: [FilePath] -> [FilePath]
-defaultFileOrder = L.reverse . sortOn stringLower 
-
-sortOrder :: Maybe FileOrder -> [FilePath] -> [FilePath]
-sortOrder Nothing   fs = defaultFileOrder fs 
-sortOrder (Just fo) fs = sortOn (getOrder fo) ordFs ++ defaultFileOrder otherFs 
-  where 
-    (ordFs, otherFs)   = L.partition (`Map.member` fo) fs 
-
-sortOn :: (Ord b) => (a -> b) -> [a] -> [a]
-sortOn f = L.sortBy (compare `on` f)
-
-stringLower :: FilePath -> FilePath 
-stringLower = fmap toLower
-
---------------------------------------------------------------------------------
--- | Check that we get the given `err` text and `ExitFailure status` for the given `path`.
---------------------------------------------------------------------------------
-errorTest :: FilePath -> Int -> T.Text -> IO TestTree
---------------------------------------------------------------------------------
-errorTest path status err = return (mkTest ec dir file)
-  where
-    ec                    = EC file (ExitFailure status) (Just err)
-    (dir, file)           = splitFileName path
-
---------------------------------------------------------------------------------
-data ExitCheck = EC { ecTest :: FilePath, ecCode :: ExitCode, ecLog :: Maybe T.Text }
-                 deriving (Show)
-
-ecAssert :: ExitCheck -> ExitCode -> T.Text -> Assertion
-ecAssert ec (ExitFailure 137) _   =
-  printf "WARNING: possible OOM while testing %s: IGNORING" (ecTest ec)
-
-ecAssert (EC _ code Nothing)  c t   =
-  assertEqual ("Wrong exit code" <> show t) code c
-
-ecAssert (EC _ code (Just t)) c log = do
-  assertEqual "Wrong exit code" code c
-  let msg = "Did not match error message.\n" ++
-            "Expected: " ++ T.unpack t ++ "\n" ++
-            "Actual:   " ++ T.unpack log
-  assertBool msg (T.isInfixOf t log)
-
---------------------------------------------------------------------------------
-mkTest :: ExitCheck -> FilePath -> FilePath -> TestTree
---------------------------------------------------------------------------------
-mkTest ec dir file
-  = askOption $ \(smt :: SmtSolver)   ->
-    askOption $ \(opts :: LiquidOpts) ->
-    askOption $ \(bin  :: LiquidRunner)   -> testCase file $
-      if test `elem` knownToFail smt
-      then do
-        printf "%s is known to fail with %s: SKIPPING" test (show smt)
-        assertEqual "" True True
-      else runLiquidOn smt opts bin dir file >>= uncurry (ecAssert ec)
-  where
-    test = dir </> file
-
-
---------------------------------------------------------------------------------
-runLiquidOn :: SmtSolver 
-            -> LiquidOpts 
-            -> LiquidRunner
-            -> FilePath
-            -> FilePath 
-            -> IO (ExitCode, T.Text)
---------------------------------------------------------------------------------
-runLiquidOn smt opts (LiquidRunner bin) dir file = do
-  absoluteDir <- canonicalizePath dir
-  createDirectoryIfMissing True $ takeDirectory log
-  hSetBuffering stdout NoBuffering
-  withFile log WriteMode $ \h -> do
-    let cmd     = testCmd bin dir file smt $ mappend (extraOptions dir absoluteDir testFileFullPath) (mkLiquidOpt opts)
-    (_,_,_,ph) <- createProcess $ (shell cmd) {std_out = UseHandle h, std_err = UseHandle h}
-    exitCode   <- waitForProcess ph
-    (exitCode,) <$> T.readFile log
-  where
-    testFileFullPath = dir </> file
-    log = "tests/logs/cur" </> testFileFullPath <.> "log"
-
-
-binPath :: FilePath -> IO FilePath
-binPath pkgName = (</> pkgName) <$> getBinDir
-
-knownToFail :: SmtSolver -> [FilePath]
-knownToFail CVC4 = [ "tests/pos/linspace.hs"
-                   , "tests/pos/RealProps.hs"
-                   , "tests/pos/RealProps1.hs"
-                   , "tests/pos/initarray.hs"
-                   , "tests/pos/maps.hs"
-                   , "tests/pos/maps1.hs"
-                   , "tests/neg/maps.hs"
-                   , "tests/pos/Product.hs"
-                   , "tests/pos/Gradual.hs"
-                   , "tests/equationalproofs/pos/MapAppend.hs"
-                   ]
-
-knownToFail Z3   = [ "tests/pos/linspace.hs"
-                   , "tests/equationalproofs/pos/MapAppend.hs"
-                   ]
-
--- | An option (like \"-i\") that also GHC can understand. This newtype is useful to
--- separate \"package-resolution\" options that we can feed to both the plugin /and/
--- the executable with options that are liquidhaskell-specific.
-newtype GhcSuitableOpts = GhcSuitableOpts LiquidOpts deriving (Monoid, Semigroup)
-newtype LiquidOnlyOpts  = LiquidOnlyOpts  LiquidOpts deriving (Monoid, Semigroup)
-
-data ExtraOptions = ExtraOptions { 
-    ghcSuitableOpts :: GhcSuitableOpts
-  , liquidOnlyOpts  :: LiquidOnlyOpts
-  }
-
-mkGhcOpt :: LiquidOpts -> ExtraOptions
-mkGhcOpt o = ExtraOptions (GhcSuitableOpts o) mempty
-
-mkLiquidOpt :: LiquidOpts -> ExtraOptions
-mkLiquidOpt o = ExtraOptions mempty (LiquidOnlyOpts o)
-
-instance Semigroup ExtraOptions where
-    (ExtraOptions o1 o2) <> (ExtraOptions o3 o4) = ExtraOptions (o1 <> o3) (o2 <> o4)
-
-instance Monoid ExtraOptions where
-    mempty  = ExtraOptions mempty mempty
-    mappend = (<>)
-
---------------------------------------------------------------------------------
-extraOptions :: FilePath 
-             -- ^ The current directory /relative/ path.
-             -> FilePath
-             -- ^ The current directory /absolute/ path.
-             -> FilePath 
-             -> ExtraOptions
---------------------------------------------------------------------------------
-extraOptions dir absDir testFileFullPath = mappend (dirOpts dir) (testOpts testFileFullPath)
-  where
-    dirOpts = flip (Map.findWithDefault mempty) $ Map.fromList
-      [ ( "benchmarks/bytestring-0.9.2.1"
-        , mkGhcOpt (LO $ printf "-i%s/include " absDir) <>
-#ifdef USE_NEW_EXECUTABLE
-          mkGhcOpt (LO "-w")
-#else
-          mkLiquidOpt (LO "--ghc-option=-w")
-#endif
-        )
-      , ( "benchmarks/text-0.11.2.3"
-        , mkLiquidOpt "--bscope --no-check-imports " <>
-          mkGhcOpt    (LO $ printf "-i%s/../bytestring-0.9.2.1 " absDir) <>
-          mkGhcOpt    (LO $ printf "-i%s/../bytestring-0.9.2.1/include " absDir) <>
-          mkGhcOpt    (LO $ printf "-i%s/../../include" absDir) <>
-#ifdef USE_NEW_EXECUTABLE
-          mkGhcOpt    (LO "-w")
-#else
-          mkLiquidOpt (LO "--ghc-option=-w")
-#endif
-        )
-      , ( "benchmarks/vector-0.10.0.1"
-        , mkGhcOpt (LO $ printf "-i%s/." absDir)
-        )
-      , ( "tests/import/client"
-        , mkGhcOpt (LO $ printf "-i%s/../lib" absDir)
-        )
-      , ( "benchmarks/popl18/nople/pos"
-        , mkGhcOpt (LO $ printf "-i%s/../../lib" absDir)
-        )
-      , ( "benchmarks/popl18/nople/neg"
-        , mkGhcOpt (LO $ printf "-i%s/../../lib" absDir)
-        )
-      , ( "benchmarks/popl18/ple/pos"
-        , mkGhcOpt (LO $ printf "-i%s/../../lib" absDir)
-        )
-      ]
-    testOpts = flip (Map.findWithDefault mempty) $ Map.fromList
-      [ ( "tests/pos/Class2.hs"
-        , mkGhcOpt (LO $ printf "-i%s/../neg" absDir)
-        )
-      , ( "tests/pos/FFI.hs"
-        , mkGhcOpt (LO $ printf "-i%s/../ffi-include" absDir) <> 
-          mkLiquidOpt "--c-files=../ffi-include/foo.c"
-        )
-      ]
-
----------------------------------------------------------------------------
-testCmd :: FilePath -> FilePath -> FilePath -> SmtSolver -> ExtraOptions -> String
----------------------------------------------------------------------------
-testCmd bin dir file smt (ExtraOptions (GhcSuitableOpts (LO ghcOpts)) (LiquidOnlyOpts (LO liquidOnlyOpts)))
-#ifdef USE_NEW_EXECUTABLE
-  = printf "%s -i. -i%s %s %s %s" bin dir ghcOpts liquidOpts (dir </> file)
-  where
-    liquidOpts = ("--smtsolver=" ++ show smt) <> " " <> liquidOnlyOpts
-#else
-  = printf "cd %s && %s -i . --smtsolver %s %s %s" dir bin (show smt) file (ghcOpts <> " " <> liquidOnlyOpts)
-#endif
-
-noPleIgnored :: [FilePath]
-noPleIgnored 
-  = "ApplicativeList.hs"         -- TODO-REBARE: TODO BLOWUP but ple version ok
-  : autoIgnored
-
-esopIgnored 
-  = [ "Base0.hs"
-    ]
-
-icfpIgnored :: [FilePath]
-icfpIgnored 
-  = [ "FindRec.hs"
-    , "CopyRec.hs"
-    , "TwiceM.hs"                -- TODO: BLOWUP: using 2.7GB RAM
-    ]
-
-autoIgnored 
-  = "Ackermann.hs" 
-  : proverIgnored
-
-proverIgnored  :: [FilePath]
-proverIgnored 
-  = [ "OverviewListInfix.hs"
-    -- , "Proves.hs"
-    -- , "Helper.hs"
-    , "FunctorReader.hs"      -- NOPROP: TODO: Niki please fix!
-    , "MonadReader.hs"        -- NOPROP: ""
-    , "ApplicativeReader.hs"  -- NOPROP: ""
-    , "FunctorReader.NoExtensionality.hs" -- Name resolution issues
-    -- , "Fibonacci.hs"          -- REFLECT-IMPORTS: TODO: Niki please fix!
-    ]
-
-
-
-hscIgnored :: [FilePath]
-hscIgnored 
-  = [ "HsColour.hs"
-    , "Language/Haskell/HsColour/Classify.hs"      -- eliminate
-    , "Language/Haskell/HsColour/Anchors.hs"       -- eliminate
-    , "Language/Haskell/HsColour/ACSS.hs"          -- eliminate
-    ]
-
-negIgnored :: [FilePath]
-negIgnored 
-  = [ "Lib.hs"
-    , "LibSpec.hs"
-    -- See: https://github.com/ucsd-progsys/liquidhaskell/issues/1677
-    , "QQTySyn2.hs"
-    , "QQTySyn1.hs"
-    , "QQTySig.hs"
-    , "elim-ex-map-3.hs"
-    , "elim-ex-map-2.hs"
-    , "elim-ex-map-1.hs"
-    , "elim-ex-let.hs"
-    ]
-
-bsIgnored :: [FilePath]
-bsIgnored 
-  = [ "Data/ByteString.T.hs" ]                    -- TODO-REBARE
-
-
-textIgnored :: [FilePath]
-textIgnored 
-  = [ "Setup.lhs"
-    -- , "Data/Text/Axioms.hs"
-    , "Data/Text/Encoding/Error.hs"
-    , "Data/Text/Encoding/Fusion/Common.hs"
-    , "Data/Text/Encoding/Utf16.hs"
-    , "Data/Text/Encoding/Utf32.hs"
-    , "Data/Text/Encoding/Utf8.hs"
-    , "Data/Text/Fusion/CaseMapping.hs"
-    , "Data/Text/IO.hs"
-    , "Data/Text/IO/Internal.hs"
-    , "Data/Text/Lazy/Builder/Functions.hs"
-    , "Data/Text/Lazy/Builder/Int.hs"
-    , "Data/Text/Lazy/Builder/Int/Digits.hs"
-    , "Data/Text/Lazy/Builder/Internal.hs"
-    , "Data/Text/Lazy/Builder/RealFloat.hs"
-    , "Data/Text/Lazy/Builder/RealFloat/Functions.hs"
-    , "Data/Text/Lazy/IO.hs"
-    , "Data/Text/Lazy/Read.hs"
-    , "Data/Text/Read.hs"
-    , "Data/Text/Unsafe/Base.hs"
-    , "Data/Text/UnsafeShift.hs"
-    -- , "Data/Text/Util.hs"
-    , "Data/Text/Fusion-debug.hs"
-    -- , "Data/Text/Encoding.hs"
-    ]
-
-demosIgnored :: [FilePath]
-demosIgnored = [ "Composition.hs"
-               , "Eval.hs"
-               , "Inductive.hs"
-               , "Loop.hs"
-               , "TalkingAboutSets.hs"
-               , "refinements101reax.hs"
-               ]
-
-----------------------------------------------------------------------------------------
--- Generic Helpers
-----------------------------------------------------------------------------------------
-group :: (Monad m) => TestName -> [m TestTree] -> m TestTree
-group n xs = testGroup n <$> sequence xs
-
-gitTimestamp :: IO String
-gitTimestamp = do
-   res <- gitProcess ["show", "--format=\"%ci\"", "--quiet"]
-   return $ filter notNoise res
-
-gitEpochTimestamp :: IO String
-gitEpochTimestamp = do
-   res <- gitProcess ["show", "--format=\"%ct\"", "--quiet"]
-   return $ filter notNoise res
-
-gitHash :: IO String
-gitHash = do
-   res <- gitProcess ["show", "--format=\"%H\"", "--quiet"]
-   return $ filter notNoise res
-
-gitRef :: IO String
-gitRef = do
-   res <- gitProcess ["show", "--format=\"%d\"", "--quiet"]
-   return $ filter notNoise res
-
--- | Calls `git` for info; returns `"plain"` if we are not in a git directory.
-gitProcess :: [String] -> IO String
-gitProcess args = (readProcess "git" args []) `catchIOError` const (return "plain")
-
-notNoise :: Char -> Bool
-notNoise a = a /= '\"' && a /= '\n' && a /= '\r'
-
-headerDelim :: String
-headerDelim = replicate 80 '-'
-
-----------------------------------------------------------------------------------------
-walkDirectory :: Bool -> FilePath -> IO [FilePath]
-----------------------------------------------------------------------------------------
-walkDirectory del root = do 
-  when del (nukeIfThere (root </> ".liquid"))
-  (ds,fs) <- partitionM doesDirectoryExist . candidates =<< (getDirectoryContents root `catchIOError` const (return []))
-  (fs ++) <$> concatMapM (walkDirectory del) ds
-  where
-    candidates fs = [root </> f | f <- fs, not (isExtSeparator (head f))]
-
-nukeIfThere :: FilePath -> IO () 
-nukeIfThere dir = do 
-  ex <- doesDirectoryExist dir 
-  if ex then removeDirectoryRecursive dir else return () 
-
-partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a],[a])
-partitionM f = go [] []
-  where
-    go ls rs []     = return (ls,rs)
-    go ls rs (x:xs) = do b <- f x
-                         if b then go (x:ls) rs xs
-                              else go ls (x:rs) xs
-
--- isDirectory :: FilePath -> IO Bool
--- isDirectory = fmap Posix.isDirectory . Posix.getFileStatus
-
-concatMapM :: Applicative m => (a -> m [b]) -> [a] -> m [b]
-concatMapM _ []     = pure []
-concatMapM f (x:xs) = (++) <$> f x <*> concatMapM f xs
-
--- | Combine two @TestReporter@s into one.
---
--- Runs the reporters in sequence, so it's best to start with the one
--- that will produce incremental output, e.g. 'consoleTestReporter'.
-combineReporters :: Ingredient -> Ingredient -> Ingredient
-combineReporters (TestReporter opts1 run1) (TestReporter opts2 run2)
-  = TestReporter (opts1 ++ opts2) $ \opts tree -> do
-      f1 <- run1 opts tree
-      f2 <- run2 opts tree
-      return $ \smap -> f1 smap >> f2 smap
-combineReporters _ _ = error "combineReporters needs TestReporters"
-
-type Summary = [(String, Double, Bool)]
-
--- this is largely based on ocharles' test runner at
--- https://github.com/ocharles/tasty-ant-xml/blob/master/Test/Tasty/Runners/AntXML.hs#L65
-loggingTestReporter :: Ingredient
-loggingTestReporter = TestReporter [] $ \opts tree -> Just $ \smap -> do
-  let
-    runTest _ testName _ = Traversal $ Functor.Compose $ do
-        i <- State.get
-
-        summary <- lift $ STM.atomically $ do
-          status <- STM.readTVar $
-            fromMaybe (error "Attempted to lookup test by index outside bounds") $
-              IntMap.lookup i smap
-
-          let mkSuccess time = [(testName, time, True)]
-              mkFailure time = [(testName, time, False)]
-
-          case status of
-            -- If the test is done, generate a summary for it
-            Done result
-              | resultSuccessful result
-                  -> pure (mkSuccess (resultTime result))
-              | otherwise
-                  -> pure (mkFailure (resultTime result))
-            -- Otherwise the test has either not been started or is currently
-            -- executing
-            _ -> STM.retry
-
-        Const summary <$ State.modify (+ 1)
-
-    runGroup group children = Traversal $ Functor.Compose $ do
-      Const soFar <- Functor.getCompose $ getTraversal children
-      pure $ Const $ map (\(n,t,s) -> (group</>n,t,s)) soFar
-
-    computeFailures :: StatusMap -> IO Int
-    computeFailures = fmap getSum . getApp . foldMap (\var -> Ap $
-      (\r -> Sum $ if resultSuccessful r then 0 else 1) <$> getResultFromTVar var)
-
-    getResultFromTVar :: STM.TVar Status -> IO Result
-    getResultFromTVar var =
-      STM.atomically $ do
-        status <- STM.readTVar var
-        case status of
-          Done r -> return r
-          _ -> STM.retry
-
-  (Const summary, _tests) <-
-     flip State.runStateT 0 $ Functor.getCompose $ getTraversal $
-      foldTestTree
-        trivialFold { foldSingle = runTest, foldGroup = runGroup }
-        opts
-        tree
-
-  return $ \_elapsedTime -> do
-    -- get some semblance of a hostname
-    host <- takeWhile (/='.') . takeWhile (not . isSpace) <$> readProcess "hostname" [] []
-    -- don't use the `time` package, major api differences between ghc 708 and 710
-    time <- head . lines <$> readProcess "date" ["+%Y-%m-%dT%H-%M-%S"] []
-    -- build header
-    ref       <- gitRef
-    timestamp <- gitTimestamp
-    epochTime <- gitEpochTimestamp
-    hash      <- gitHash
-    let hdr = unlines [ref ++ " : " ++ hash,
-                       "Timestamp: " ++ timestamp,
-                       "Epoch Timestamp: " ++ epochTime,
-                       headerDelim,
-                       "test, time(s), result"]
-
-    let dir = "tests" </> "logs" </> host ++ "-" ++ time
-    let smry = "tests" </> "logs" </> "cur" </> "summary.csv"
-    writeFile smry $ unlines
-                   $ hdr
-                   : map (\(n, t, r) -> printf "%s, %0.4f, %s" n t (show r)) summary
-    system $ "cp -r tests/logs/cur " ++ dir
-    (==0) <$> computeFailures smap
