diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000000..6aa97380fc
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,28 @@
+---
+name: Bug report
+about: Create a report to help us improve the PureScript compiler
+title: ''
+labels: 'type: bug'
+assignees: ''
+
+---
+
+## Description
+
+A clear and concise description of what the bug is.
+
+## To Reproduce
+
+Steps to reproduce the behavior.
+
+## Expected behavior
+
+A clear and concise description of what you expected to happen.
+
+## Additional context
+
+Add any other context about the problem here.
+
+## PureScript version
+
+0.x.x
diff --git a/.github/ISSUE_TEMPLATE/compiler-proposal.md b/.github/ISSUE_TEMPLATE/compiler-proposal.md
new file mode 100644
index 0000000000..889002fa08
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/compiler-proposal.md
@@ -0,0 +1,23 @@
+---
+name: Compiler proposal
+about: A concrete suggestion to change the PureScript compiler
+labels: 'type: enhancement'
+assignees: ''
+
+---
+
+## Summary
+
+One or two sentence summary of the proposal.
+
+## Motivation
+
+Background information about why this proposal is necessary.
+
+## Proposal
+
+Detailed description of the proposal.
+
+## Examples
+
+At least one or two examples of the proposal being used.
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000000..94e49fa62e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,5 @@
+blank_issues_enabled: true
+contact_links:
+ - about: Please discuss ideas and ask questions on the PureScript Discourse.
+ name: Ideas and Questions
+ url: https://discourse.purescript.org/
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000000..501ee01403
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,13 @@
+**Description of the change**
+
+Clearly and concisely describe the purpose of the pull request. If this PR relates to an existing issue or change proposal, please link to it. Include any other background context that would help reviewers understand the motivation for this PR.
+
+---
+
+**Checklist:**
+
+- [ ] Added a file to CHANGELOG.d for this PR (see CHANGELOG.d/README.md)
+- [ ] Added myself to CONTRIBUTORS.md (if this is my first contribution)
+- [ ] Linked any existing issues or proposals that this pull request should close
+- [ ] Updated or added relevant documentation
+- [ ] Added a test for the contribution (if applicable)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000000..b73b5cbdd3
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,299 @@
+name: "CI"
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+ paths:
+ - .github/workflows/**/*.yml
+ - app/**/*
+ - bundle/**/*
+ - ci/**/*
+ - license-generator/**/*
+ - src/**/*
+ - test/**/*
+ - .gitignore
+ - .hlint.yaml
+ - .hspec
+ - cabal.project
+ - purescript.cabal
+ - Setup.hs
+ - stack.yaml
+ - stack.yaml.lock
+ - update-changelog.hs
+ - weeder.dhall
+ release:
+ types: [ "published" ]
+
+defaults:
+ run:
+ shell: "bash"
+
+env:
+ CI_PRERELEASE: "${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}"
+ CI_RELEASE: "${{ github.event_name == 'release' }}"
+ STACK_VERSION: "3.3.1"
+
+concurrency:
+ # We never want two prereleases building at the same time, since they would
+ # likely both claim the same version number. Pull request builds can happen
+ # in parallel with anything else, since they don't mutate global state with a
+ # release. Release builds don't change their behavior based on published
+ # state, so they don't interfere with each other and there's no point in
+ # canceling a prerelease build if a release build starts; and we would never
+ # want a release build to be canceled by a prerelease build either. (GitHub
+ # Actions is either too cheap to give us `if` expressions or too lazy to
+ # document them, but we have untyped boolean operators to fall back on.)
+ group: "${{ github.event_name != 'push' && github.run_id || 'continuous-deployment' }}"
+ cancel-in-progress: true
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false # do not cancel builds for other OSes if one fails
+ matrix:
+ include:
+ - image: quay.io/benz0li/ghc-musl:9.8.4
+ os: ubuntu-latest
+
+ - image: quay.io/benz0li/ghc-musl:9.8.4
+ os: ubuntu-24.04-arm
+
+ - os: macos-15-intel # x64
+ - os: macos-14 # arm64
+ - os: windows-2022 # x64
+
+ runs-on: "${{ matrix.os }}"
+ container:
+ image: "${{ matrix.image }}"
+ # https://github.com/actions/runner/issues/801#issuecomment-2976165281
+ # This workaround also requires a special installation step for Node.js on arm64
+ volumes:
+ - "${{ contains(matrix.os, 'arm') && '/opt:/opt:rw,rshared' || ' ' }}"
+ - "${{ contains(matrix.os, 'arm') && '/opt:/__e/node20:ro,rshared' || ' ' }}"
+ env:
+ CI_STATIC: "${{ startsWith(matrix.os, 'ubuntu') }}"
+
+ outputs:
+ do-not-prerelease: "${{ steps.build.outputs.do-not-prerelease }}"
+ version: "${{ steps.build.outputs.version }}"
+
+ steps:
+ # We need `gh` installed on the Linux version. Otherwise, release artifacts won't be uploaded.
+ - name: "(Linux only) Install gh"
+ if: "${{ startsWith(matrix.os, 'ubuntu') }}"
+ run: |
+ apk add github-cli
+
+ - name: "(Linux only / x64) Install Node"
+ if: "${{ startsWith(matrix.os, 'ubuntu') && ! contains(matrix.os, 'arm') }}"
+ run: |
+ apk add nodejs npm
+
+ - name: "(Linux only / arm64) Install Node"
+ if: "${{ startsWith(matrix.os, 'ubuntu') && contains(matrix.os, 'arm') }}"
+ run: |
+ sed -i "/^ID=/s/alpine/NotpineForGHA/" /etc/os-release
+ apk add nodejs npm --update-cache
+ mkdir /opt/bin
+ ln -s /usr/bin/node /opt/bin/node
+
+ - uses: "actions/checkout@v4"
+
+ - id: "haskell"
+ name: "(Non-Linux only) Install Haskell"
+ if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'windows')
+ uses: "haskell-actions/setup@v2"
+ with:
+ ghc-version: "9.8.4"
+ enable-stack: true
+ stack-version: "${{ env.STACK_VERSION }}"
+ stack-no-global: true
+
+ - name: "(Linux only) Fix working directory ownership"
+ if: "${{ startsWith(matrix.os, 'ubuntu') }}"
+ run: |
+ chown root:root .
+
+ - uses: "actions/cache@v4"
+ with:
+ path: |
+ /root/.stack
+ ${{ steps.haskell.outputs.stack-root }}
+ key: "${{ matrix.image || matrix.os }}-v3-${{ hashFiles('stack.yaml.lock', 'purescript.cabal') }}"
+
+ - name: "(Windows only) Configure Stack to store its programs in STACK_ROOT"
+ # This ensures that the local GHC and MSYS binaries that Stack installs
+ # are included in the cache. (This behavior is the default on
+ # non-Windows OSes.)
+ if: "${{ runner.os == 'Windows' }}"
+ run: |
+ mkdir -p "$STACK_ROOT"
+ echo "local-programs-path: $STACK_ROOT/programs" > $STACK_ROOT/config.yaml
+
+ - name: "(Linux only) Configure Stack"
+ if: "${{ startsWith(matrix.os, 'ubuntu') }}"
+ run: |
+ ci/fix-home stack config set system-ghc --global true
+ ci/fix-home stack config set install-ghc --global false
+
+ - id: "build"
+ run: "ci/fix-home ci/build.sh"
+
+ - name: "(Linux only) Glob tests"
+ if: "${{ startsWith(matrix.os, 'ubuntu') }}"
+ working-directory: "sdist-test"
+ # We build in this directory in build.sh, so this is where we need to
+ # launch `stack exec`. The actual glob checks happen in a temporary directory.
+ run: |
+ apk add tree
+ ../ci/fix-home stack exec bash ../glob-test.sh
+
+ - name: "(Linux only) Build the entire package set"
+ if: "${{ startsWith(matrix.os, 'ubuntu') }}"
+ # We build in this directory in build.sh, so this is where we need to
+ # launch `stack exec`. The actual package-set building happens in a
+ # temporary directory.
+ working-directory: "sdist-test"
+ # The presence or absence of the --haddock flag changes the location
+ # into which stack places all build artifacts. Since we use --haddock
+ # in our CI builds, in order to actually get stack to find the purs
+ # binary it created, we need to use the flag here as well.
+ #
+ # Moreover, npm has a hook issue that will cause spago to fail to install
+ # We upgrade npm to fix this
+ run: |
+ apk add jq coreutils
+ ../ci/fix-home stack --haddock exec ../ci/build-package-set.sh
+
+ - name: Verify that 'libtinfo' isn't in binary
+ if: ${{ runner.os == 'Linux' }}
+ working-directory: "sdist-test"
+ run: |
+ if [ $(ldd $(../ci/fix-home stack path --local-doc-root)/../bin/purs | grep 'libtinfo' | wc -l) -ge 1 ]; then
+ echo "libtinfo detected"
+ ldd $(../ci/fix-home stack path --local-doc-root)/../bin/purs | grep 'libtinfo'
+ exit 1
+ fi
+
+ - name: "(Linux only) Install perl-utils"
+ if: "${{ startsWith(matrix.os, 'ubuntu') }}"
+ run: |
+ apk add perl-utils
+
+ - name: "(Release/prerelease only) Create bundle"
+ if: "${{ env.CI_RELEASE == 'true' || env.CI_PRERELEASE == 'true' && steps.build.outputs.do-not-prerelease != 'true' }}"
+ run: |
+ os_name="${{ runner.os }}"
+ os_arch="${{ runner.arch }}"
+ case "$os_name" in
+ Linux)
+ case "$os_arch" in
+ ARM64)
+ bundle_os=linux-arm64;;
+ *)
+ bundle_os=linux64;;
+ esac;;
+ macOS)
+ case "$os_arch" in
+ ARM64)
+ bundle_os=macos-arm64;;
+ *)
+ bundle_os=macos;;
+ esac;;
+ Windows)
+ bundle_os=win64;;
+ *)
+ echo "Unknown OS name: $os_name"
+ exit 1;;
+ esac
+ cd sdist-test
+ ../ci/fix-home bundle/build.sh "$bundle_os"
+
+ - name: "(Prerelease only) Upload bundle"
+ if: "${{ env.CI_PRERELEASE == 'true' && steps.build.outputs.do-not-prerelease != 'true' }}"
+ uses: "actions/upload-artifact@v4.6.0"
+ with:
+ name: "${{ runner.os }}-${{ runner.arch }}-bundle"
+ path: |
+ sdist-test/bundle/*.sha
+ sdist-test/bundle/*.tar.gz
+
+ - name: "(Release only) Publish bundle"
+ if: "${{ env.CI_RELEASE == 'true' }}"
+ env:
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
+ run: "gh release upload --clobber ${{ github.ref_name }} sdist-test/bundle/*.{tar.gz,sha}"
+
+ lint:
+ container: haskell:9.8.4
+ runs-on: ubuntu-latest # Exact version is not important, as it's only the container host
+
+ steps:
+ - uses: "actions/checkout@v4"
+
+ - name: "Fix working directory ownership"
+ run: |
+ chown root:root .
+
+ - uses: "actions/cache@v4"
+ with:
+ path: |
+ /root/.stack
+ key: "lint-${{ hashFiles('stack.yaml.lock', 'purescript.cabal') }}"
+
+ - run: "ci/fix-home ci/run-hlint.sh --git"
+ env:
+ VERSION: "3.10"
+
+ - name: Install weeder
+ run: |
+ ci/fix-home stack --no-terminal --jobs=2 \
+ build --copy-compiler-tool weeder-2.9.0
+
+ - run: |
+ ci/fix-home stack --no-terminal --jobs=2 \
+ build --fast --ghc-options -fwrite-ide-info
+
+ - run: "ci/fix-home stack exec weeder -- --hie-directory .stack-work"
+
+ # Now do it again, with the test suite included. We don't want a
+ # reference from our test suite to count in the above check; the fact
+ # that a function is tested is not evidence that it's needed. But we also
+ # don't want to leave weeds lying around in our test suite either.
+ - run: |
+ ci/fix-home stack --no-terminal --jobs=2 \
+ build --fast --test --no-run-tests --ghc-options -fwrite-ide-info
+
+ - run: "ci/fix-home stack exec weeder -- --hie-directory .stack-work"
+
+ make-prerelease:
+ runs-on: ubuntu-latest
+ needs:
+ - "build"
+ - "lint"
+ if: "${{ github.event_name == 'push' && needs.build.outputs.do-not-prerelease != 'true' }}"
+ steps:
+ - uses: "actions/download-artifact@v4"
+ - uses: "ncipollo/release-action@v1.10.0"
+ with:
+ tag: "v${{ needs.build.outputs.version }}"
+ artifacts: "*-bundle/*"
+ prerelease: true
+ body: "This is an automated preview release. Get the latest stable release [here](https://github.com/purescript/purescript/releases/latest)."
+ - uses: "actions/checkout@v4"
+ - uses: "actions/setup-node@v4"
+ with:
+ node-version: "16.x"
+ registry-url: "https://registry.npmjs.org"
+ - name: "Publish npm package"
+ working-directory: "npm-package"
+ env:
+ BUILD_VERSION: "${{ needs.build.outputs.version }}"
+ NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}"
+ run: |
+ src_version=$(node -pe 'require("./package.json").version')
+ npm version --allow-same-version "$BUILD_VERSION"
+ sed -i -e "s/--purs-ver=${src_version//./\\.}/--purs-ver=$BUILD_VERSION/" package.json
+ npm publish --tag next
diff --git a/.gitignore b/.gitignore
index 06ddeaa54b..73b2b4678f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,11 @@
+.build
+bin
dist
cabal-dev
.cabal-sandbox
cabal.sandbox.config
+dist-newstyle/
+cabal.project.local*
*.o
*.hi
*.chi
@@ -20,13 +24,16 @@ core-tests/full-core-docs.md
tests/support/package-lock.json
.psc-ide-port
.psc-package/
-purescript.cabal
tags
TAGS
+# Gather source map files from golden tests
+.source-maps
+
# Profiling related
*.aux
*.hp
*.prof
*.ps
*.svg
+tests/purs/make/
diff --git a/.hlint.yaml b/.hlint.yaml
new file mode 100644
index 0000000000..cd4df2a65f
--- /dev/null
+++ b/.hlint.yaml
@@ -0,0 +1,75 @@
+# HLint configuration file
+# https://github.com/ndmitchell/hlint
+##########################
+
+# This file contains a template configuration file, which is typically
+# placed as .hlint.yaml in the root of your project
+
+
+# Warnings currently triggered by your code
+- ignore: {name: "Redundant do"}
+- ignore: {name: "Use newtype instead of data"}
+- ignore: {name: "Fuse foldr/map"}
+- ignore: {name: "Avoid lambda"}
+- ignore: {name: "Use record patterns"}
+- ignore: {name: "Use section"}
+- ignore: {name: "Reduce duplication"}
+- ignore: {name: "Functor law"}
+- ignore: {name: "Avoid lambda using `infix`"}
+- ignore: {name: "Fuse mapM/map"}
+- ignore: {name: "Eta reduce"} # This warning will often make suggestions that are no longer valid due to simplified subsumption
+- ignore: {name: "Redundant <$>"}
+
+
+# Specify additional command line arguments
+#
+# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
+
+
+# Control which extensions/flags/modules/functions can be used
+#
+# - extensions:
+# - default: false # all extension are banned by default
+# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used
+# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
+#
+# - flags:
+# - {name: -w, within: []} # -w is allowed nowhere
+#
+# - modules:
+# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
+# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
+#
+# - functions:
+# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules
+
+
+# Add custom hints for this project
+#
+# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
+# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
+
+
+# Turn on hints that are off by default
+#
+# Ban "module X(module X) where", to require a real export list
+# - warn: {name: Use explicit module export list}
+#
+# Replace a $ b $ c with a . b $ c
+# - group: {name: dollar, enabled: true}
+#
+# Generalise map to fmap, ++ to <>
+# - group: {name: generalise, enabled: true}
+
+
+# Ignore some builtin hints
+# - ignore: {name: Use let}
+# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
+
+
+# Define some custom infix operators
+# - fixity: infixr 3 ~^#^~
+
+
+# To generate a suitable file for HLint do:
+# $ hlint --default > .hlint.yaml
diff --git a/.hspec b/.hspec
new file mode 100644
index 0000000000..28f079001c
--- /dev/null
+++ b/.hspec
@@ -0,0 +1 @@
+--times
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index ae31a4d547..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,139 +0,0 @@
-language: node_js
-node_js:
- - "10"
-branches:
- # Only build master and tagged versions, i.e. not feature branches; feature
- # branches already get built after opening a pull request.
- only:
- - master
- - /^v\d+\.\d+(\.\d+)?(-\S*)?$/
-matrix:
- include:
- # We use trusty boxes because they seem to be a bit faster.
- - os: linux
- dist: trusty
- sudo: required
-
- - os: osx
-
- - os: windows
- # Workaround for a Travis caching bug on Windows where absolute paths
- # are not restored from caches properly:
- # https://github.com/travis-ci/casher/pull/38
- env: STACK_ROOT=$TRAVIS_BUILD_DIR/.stack_root
- # workaround for https://travis-ci.community/t/windows-instances-hanging-before-install/250/15
- filter_secrets: false
-addons:
- apt:
- packages:
- - libgmp-dev
-cache:
-# Travis CI's build cache mechanism allows you to cache compiled artifacts in
-# order to speed subsequent builds up; this is essential for us, because
-# installing all of the compiler's Haskell dependencies takes longer than the
-# allotted time for a single build.
-#
-# Unfortunately, if we allow a build to reach the Travis timeout limit, we
-# don't get the opportunity to upload a cache (since uploading is included in
-# the time limit, and we've already run out of time). Therefore, if we want
-# the progress we have made in a build to be saved to the build cache, we need
-# to make sure we abort the build early to allow time to upload the cache.
-# Then, the next commit can pick up where the previous commit left off.
-#
-# If a CI build times out, you need to push a new commit. Amending and
-# force-pushing DOES NOT WORK. I suspect this is because Travis will only
-# consider a particular build cache to be appropriate to use when building a
-# given commit with if the cache was created by a parent of the commit being
-# built (which is sensible of them).
- directories:
- - $HOME/.stack
-
- # Workaround for a Travis caching bug on Windows where absolute paths
- # are not restored from caches properly:
- # https://github.com/travis-ci/casher/pull/38
- - .stack_root
- # Maximum amount of time in seconds spent attempting to upload a new cache
- # before aborting. Since our cache can get rather large, increasing this
- # value helps avoid situations where caches fail to be stored. The default
- # value is 180 (at the time of writing).
- timeout: 1000
-install:
-- |
- if [ "$TRAVIS_OS_NAME" = "windows" ]
- then
- ci/disable-windows-defender.sh
- fi
-- mkdir -p "$HOME/.local/bin"
-- export PATH="$PATH:$HOME/.local/bin"
-- | # Install stack.
- if ! which stack >/dev/null
- then
- URL="https://www.stackage.org/stack/$TRAVIS_OS_NAME-x86_64"
- mkdir "$HOME/stack"
- pushd "$HOME/stack"
- if [ "$TRAVIS_OS_NAME" = "windows" ]
- then
- curl --location "$URL" > stack.zip
- unzip stack.zip
- mv stack.exe "$HOME/.local/bin/"
- else
- curl --location "$URL" > stack.tar.gz
- tar -xzf stack.tar.gz --strip-components=1
- mv stack "$HOME/.local/bin/"
- fi
- popd
- fi
-- | # Set up the timeout command
- if which timeout >/dev/null
- then
- TIMEOUT=timeout
- elif [ "$TRAVIS_OS_NAME" == "osx" ]
- then
- if ! which gtimeout >/dev/null
- then
- brew update
- brew install coreutils
- fi
- TIMEOUT=gtimeout
- else
- echo "Unable to set up timeout command"
- exit 1
- fi
-- |
- if ! stack --no-terminal setup 2>&1 > stack-setup.log
- then
- cat stack-setup.log
- exit 1
- else
- # stack setup is very verbose on windows
- tail stack-setup.log
- fi
-- head stack-setup.log
-- stack --version
-- stack path
-- npm install -g bower # for psc-docs / psc-publish tests
-- export OS_NAME=$(./ci/convert-os-name.sh)
-- |
- if [ -n "$TRAVIS_TAG" ]
- then
- export CI_RELEASE=true
- fi
-script:
-# Set a timeout of 35 minutes. We could use travis_wait here, but travis_wait
-# doesn't produce any output until the command finishes, and also doesn't
-# always show all of the command's output.
-- $TIMEOUT 35m ci/build.sh
-before_deploy:
-- pushd sdist-test
-- bundle/build.sh $OS_NAME
-- popd
-deploy:
- provider: releases
- api_key: $RELEASE_KEY
- file:
- - sdist-test/bundle/$OS_NAME.tar.gz
- - sdist-test/bundle/$OS_NAME.sha
- skip_cleanup: true
- on:
- all_branches: true
- tags: true
diff --git a/CHANGELOG.d/README.md b/CHANGELOG.d/README.md
new file mode 100644
index 0000000000..7fa2fa83e1
--- /dev/null
+++ b/CHANGELOG.d/README.md
@@ -0,0 +1,69 @@
+This directory contains changelog entries for work that has not yet been
+released. When a release goes out, these files will be concatenated and
+prepended to CHANGELOG.md in a new section for that release.
+
+Maintainers: see update-changelog.hs for details of this process.
+
+Contributors: read on!
+
+Our guiding principle is that the changelog is a tool for users—people who
+depend on PureScript as a compiler or as a library—who are considering
+upgrading, or have recently upgraded, their PureScript compiler version. We ask
+that when making changes that such users might need to know about, you help
+them out by adding to our changelog.
+
+Work that doesn't change the compiler (such as updates to README.md) doesn't
+need a changelog entry. But keep in mind that even parts of the project like
+our CI workflow can introduce changes to the compiler we release.
+
+When you are preparing a new PR that does change the compiler, add a new file
+to this directory. The file should be named `{PREFIX}_{SLUG}.md`, where
+`{PREFIX}` is one of the following:
+* `breaking`: for breaking changes to the compiler, for which a user may need to do
+ work to their project before or immediately upon upgrading
+* `feature`: for new features, which might prevent a user from downgrading to an
+ earlier version
+* `fix`: for bug fixes, which might motivate a user to upgrade
+* `internal`: for work that is not expected to directly affect users; these
+ entries should usually be brief, but may serve as useful starting points for
+ investigations if a change ends up having unintended consequences
+
+(There is also a fifth prefix, `misc`. This is an escape hatch in case we have
+something that somehow doesn't fit in the above categories but that we want to
+include in the changelog, which frankly seems unlikely given how much of a
+catch-all `internal` is. We'll tell you if you should use this one.)
+
+`{SLUG}` should be a short description of the work you've done. The name has no
+impact on the final CHANGELOG.md.
+
+Some example names:
+* `fix_issue-9876.md`
+* `breaking_deprecate-classes.md`
+* `internal_use-ubuntu-38.04-in-ci.md`
+
+The contents of the file can be as brief as:
+
+```markdown
+* A short message, like the title of your commit
+```
+
+Please remember the initial `*`! These files will all be concatenated into
+lists.
+
+If you have more to say about your work, indent additional lines like so:
+
+``````markdown
+* A short message, like the title of your commit
+
+ Here is a longer explanation of what this is all about. Of course, this file
+ is Markdown, so feel free to use *formatting*
+
+ ```
+ and code blocks
+ ```
+
+ if it makes your work more understandable.
+``````
+
+You do not have to edit your changelog file to include a reference to your PR.
+The CHANGELOG.md updating script will do this automatically and credit you.
diff --git a/CHANGELOG.d/internal_fix-typo-in-traversal.md b/CHANGELOG.d/internal_fix-typo-in-traversal.md
new file mode 100644
index 0000000000..98dfa19747
--- /dev/null
+++ b/CHANGELOG.d/internal_fix-typo-in-traversal.md
@@ -0,0 +1 @@
+* Fix typo in CoreFn.Traversals.traverseCoreFn which caused it to not recurse into Let bodies
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000..d2dbd016b3
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,5059 @@
+# Changelog
+
+Notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## 0.15.16
+
+Bugfixes:
+
+* Fix compiler crash when a type operator is used in a type argument (#4536 by @purefunctor)
+
+* Speed up IDE performance on large projects (#4546 by @roryc89)
+
+* Fix double click select of titles in generated documentation (#4579 by @ad-si)
+
+Other improvements:
+
+* Update Stackage snapshot to lts-20.26 and GHC to 9.2.8 (#4537 by @purefunctor)
+
+* Enable statically-linked binaries using [ghc-musl](https://github.com/benz0li/ghc-musl) (#4573 by @purefunctor)
+* Update haskeline version bounds to >=0.8.2.1 && <0.9
+
+ Consequently, this fixes Cabal-based builds on GHC 9.8.4
+
+Internal:
+
+* Remove the step that upgraded Git from the CI workflow (#4541 by @rhendric)
+
+* Upgrade GHC to [`9.6.6`](https://downloads.haskell.org/~ghc/9.6.6/docs/users_guide/9.6.6-notes.html), Stackage LTS `22.43` (#4568 by @ad-si)
+* Minimum required glibc version is bumped from [`2.28` to `2.31`](https://sourceware.org/glibc/wiki/Glibc%20Timeline)
+
+* Upgrade GHC to [`9.8.4`](https://downloads.haskell.org/~ghc/9.8.4/docs/users_guide/9.8.4-notes.html), Stackage LTS `23.18` (#4574 by @ad-si)
+* Use [HLint 3.10](https://github.com/ndmitchell/hlint/blob/master/CHANGES.txt) in CI
+
+* Update weeder version in CI to 2.9.0 (#4573 by @purefunctor)
+* Add happy ==2.0.2 as build-tool-depends
+
+* Use `-fspecialize-aggressively` GHC option to improve compiler performance by ~30% on large builds (#4584 by @seastian)
+
+## 0.15.15
+
+New features:
+
+* Add `--exclude-file` to more commands (#4530 by @JordanMartinez)
+
+ This CLI arg was added to the `compile` command, but not to other commands
+ where such a usage would be relevant (e.g. `docs`, `repl`, `graph`, and `ide`).
+
+* Enable passing source input globs via `--source-globs-file path/to/file` (#4530 by @JordanMartinez)
+
+ `--source-globs-file` support has been added to the following commands:
+ `compile`, `docs`, `graph`, `ide`, and `publish`.
+
+ Due to a [shell character limitation on Windows](https://learn.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation) where a large list of
+ source globs cannot be passed (e.g. `purs compile ... glob1000/src/**/*.purs`),
+ source globs can be stored in a file according to the format below
+ and the file is passed in instead via `purs compile ---source-globs-file path/to/file`.
+
+ ```
+ # Lines starting with '#' are comments.
+ # Blank lines are ignored.
+ # Otherwise, every line is a glob.
+
+ .spago/foo-1.2.3/src/**/*.purs
+ .spago/bar-2.3.3/src/**/*.purs
+ my-package/src/**/*.purs
+ my-package/tests/**/*.purs
+ ```
+
+ `--source-globs-file` is an optional argument. Mixing it with the normal source globs is fine.
+ Assuming `.spago/source-globs` contains `src/**/*.purs`, each command below will use
+ the same input globs:
+ ```sh
+ purs compile src/**/*.purs
+ purs compile --source-globs .spago/source-globs
+ purs compile --source-globs .spago/source-globs src/**/*.purs
+ ```
+
+ In the command...
+ ```
+ purs compile inputGlob1 inputGlob2 --source-globs-file fileWithMoreGlobs --exclude-files excludeGlob1
+ ```
+ the files passed to the compiler are: all the files found by
+ `inputGlob1`, `inputGlob2`, and all the globs listed in `fileWithMoreGlobs`
+ minus the files found by `excludeGlob1`.
+
+## 0.15.14
+
+Bugfixes:
+
+* Fix a compilation memory regression for very large files (#4521 by @mjrussell)
+
+ When compiling a a very large file (>12K lines)
+ the CSE pass could balloon memory and result in increased
+ compilation times.
+
+ This fix uses a strict Map instead of a lazy Map to avoid
+ building up unnecessary thunks during the optimization pass.
+
+* Fix two space leaks while compiling many modules (#4517 by @MonoidMusician)
+
+ The first would interleave compilation of too many modules at once, which
+ would increase memory usage, especially for single threaded builds with
+ `+RTS -N1 -RTS`. Now the number of concurrent modules is limited to
+ the number of threads available to the
+ [GHC runtime system](https://downloads.haskell.org/ghc/latest/docs/users_guide/using-concurrent.html#rts-options-for-smp-parallelism).
+
+ The second would hold on to memory from modules that compiled with warnings
+ until the end of the build when the warnings were printed and the memory freed.
+ This is now fixed with additional `NFData` instances.
+
+## 0.15.13
+
+New features:
+
+* Replace `UnusableDeclaration` with updated `NoInstanceFound` (#4513 by @JordanMartinez)
+
+ Previously, the following type class would be invalid
+ because there was no way for the compiler to infer
+ which type class instance to select because
+ the type variable in the class head `a` was
+ not mentioned in `bar`'s type signature:
+
+ ```purs
+ class Foo a where
+ bar :: Int
+ ```
+
+ The recently-added visible type applications (VTAs)
+ can now be used to guide the compiler in such cases:
+
+ ```purs
+ class Foo a where bar :: Int
+ instance Foo String where bar = 0
+ someInt = bar @String -- use the `String` instance
+ ```
+
+ Without VTAs, the compiler
+ will still produce an `InstanceNotFound` error, but this error
+ has been updated to note which type variables in the class head
+ can only be disambiguated via visible type applications.
+ Given the following code
+
+ ```purs
+ class Single tyVarDoesNotAppearInBody where
+ useSingle :: Int
+
+ single :: Int
+ single = useSingle
+ ```
+
+ The error reported for `useSingle` will be:
+
+ ```
+ No type class instance was found for
+
+ Main.Single t0
+
+ The instance head contains unknown type variables.
+
+
+ Note: The following type class members found in the expression require visible type applications
+ to be unambiguous (e.g. tyClassMember @Int).
+ Main.useSingle
+ tyNotAppearInBody
+ ```
+
+ For a multiparameter typeclass with functional dependencies...
+
+ ```purs
+ class MultiFdBidi a b | a -> b, b -> a where
+ useMultiFdBidi :: Int
+
+ multiFdBidi :: Int
+ multiFdBidi = useMultiFdBidi
+ ```
+
+ ...the "Note" part is updated to read
+ ```
+ Note: The following type class members found in the expression require visible type applications
+ to be unambiguous (e.g. tyClassMember @Int).
+ Main.useMultiFdBidi
+ One of the following sets of type variables:
+ a
+ b
+ ```
+
+Bugfixes:
+
+* Fix parsing bug where `@var` was allowed in type class head (#4523 by @JordanMartinez)
+
+## 0.15.12
+
+New features:
+
+* Move the closed record update optimization (#4489 by @rhendric)
+
+ For consumers of CoreFn like alternate backends, the optimization of
+ replacing a closed record update with an object literal has now been moved to
+ the point of desugaring CoreFn into JS. The `ObjectUpdate` expression
+ constructor now contains a `Maybe` field holding a list of record labels to
+ be copied as-is, for backends that want to perform this optimization also.
+
+* Allow instances that require `Fail` to be empty (#4490 by @rhendric)
+
+ A class instance declaration that has `Prim.TypeError.Fail` as a constraint
+ will never be used. In light of this, such instances are now allowed to have
+ empty bodies even if the class has members.
+
+ (Such instances are still allowed to declare all of their members, and it is
+ still an error to specify some but not all members.)
+
+Bugfixes:
+
+* Stop emitting warnings for wildcards in Visible Type Applications (#4492 by @JordanMartinez)
+
+ Previously, the below usage of a wildcard (i.e. `_`) would
+ incorrectly cause the compiler to emit a warning.
+
+ ```purs
+ f :: forall @a. a -> a
+ f = identity
+
+ x :: { x :: Int }
+ x = f @{ x :: _ } { x: 42 }
+ ```
+
+* Infer types using VTA inside a record (#4501 by @JordanMartinez)
+
+ Previously, `use` would fail to compile
+ because the `v` type variable would not be inferred
+ to `String`. Now the below code compiles:
+
+ ```purs
+ reflect :: forall @t v . Reflectable t v => v
+ reflect = reflectType (Proxy @t)
+
+ use :: String
+ use = show { asdf: reflect @"asdf" }
+ ```
+
+Internal:
+
+* Use `gh` for release artifacts (#4493 by @rhendric, #4509 by @JordanMartinez)
+
+* Stop triggering CI on non-code-related changes (e.g. Readme) (#4502 by @JordanMartinez)
+
+
+## 0.15.11
+
+Please use `0.15.12` instead of this release. There was an issue with the Linux build. This release notes were moved into `0.15.12`'s release notes.
+
+## 0.15.10
+
+New features:
+
+* Implement visible type applications
+
+ The compiler now supports visible type applications, allowing the user to instantiate one or more "visible" type variables to a specific type.
+
+ A "visible" type variable is a type variable in a `forall` binder that appears prefixed with an `@`, like the following example:
+
+ ```purescript
+ id :: forall @a. a -> a -- or with kinds: `forall (@a :: Type). a -> a`
+ id a = a
+ ```
+
+ We can then use type application syntax to instantiate this binding to a specific type:
+
+ ```purescript
+ idInt :: Int -> Int
+ idInt = id @Int
+
+ example :: Int
+ example = id @Int 0
+ ```
+
+ Type variables appearing in `class` or `data` are automatically visible, meaning that they do not require annotations:
+
+ ```purescript
+ data Maybe a = Just a | Nothing
+
+ nothingInt :: Maybe Int
+ nothingInt = Nothing @Int
+
+ class Identity a where
+ identity :: a -> a
+
+ instance Identity Int where
+ identity a = a
+
+ identityInt = identity @Int
+
+ -- This throws a `NoInstanceFound` error.
+ identityNumber = identity @Number
+ ```
+
+ Lastly, visible type variables can also be skipped with a wildcard (i.e. `_`)
+
+ ```purescript
+ data Either a b = Left a | Right b
+
+ example = Left @_ @Number 0
+ ```
+
+ Note that performing a type application with a type that has no visible type variables throws an error:
+
+ ```purescript
+ module Main where
+
+ id :: forall a. a -> a
+ id a = a
+
+ idInt = id @Int
+
+ {-
+ Error found:
+ in module Main
+ at Main.purs:6:9 - 6:16 (line 6, column 9 - line 6, column 16)
+
+ An expression of polymorphic type
+ with the invisible type variable a:
+
+ forall a. a -> a
+
+ cannot be applied to:
+
+ Int
+
+
+ while inferring the type of id
+ in value declaration idInt
+
+ See https://github.com/purescript/documentation/blob/master/errors/CannotApplyExpressionOfTypeOnType.md for more information,
+ or to contribute content related to this error.
+ -}
+ ```
+
+ Similarly, monomorphic types also cannot be used for type applications:
+
+ ```purescript
+ module Main where
+
+ idInt :: Int -> Int
+ idInt a = a
+
+ example = idInt @Int
+
+ {-
+ Error found:
+ in module Main
+ at Main.purs:6:11 - 6:21 (line 6, column 11 - line 6, column 21)
+
+ An expression of monomorphic type:
+
+ Int -> Int
+
+ cannot be applied to:
+
+ Int
+
+
+ while inferring the type of idInt
+ in value declaration example
+
+ See https://github.com/purescript/documentation/blob/master/errors/CannotApplyExpressionOfTypeOnType.md for more information,
+ or to contribute content related to this error.
+ -}
+ ```
+
+* Exclude files from compiler input (#4480 by @i-am-the-slime)
+
+ The compiler now supports excluding files from the globs given to it as input.
+ This means there's now a new option for `purs compile`, namely
+ `--exclude-files` (or the short version `-x`):
+
+ ```sh
+ > purs compile --help
+ Usage: purs compile [FILE] [-x|--exclude-files ARG] [-o|--output ARG] ...
+
+ Compile PureScript source files
+
+ Available options:
+ -h,--help Show this help text
+ FILE The input .purs file(s).
+ -x,--exclude-files ARG Glob of .purs files to exclude from the supplied
+ files.
+ ...
+ ```
+
+ This allows you to keep related files closer together (that is, [colocate](https://kentcdodds.com/blog/colocation) them).
+
+ Consider a setup like the following:
+
+ ```sh
+ src/
+ Main.purs
+ View/
+ LoginPage.purs
+ LoginPageTest.purs
+ LoginPageStories.purs
+ ```
+
+ In order to exclude the files in the example above you can now invoke `purs`
+ like this and it will only compile `LoginPage.purs`:
+
+ ```sh
+ purs compile "src/**/*.purs" --exclude-files "src/**/*Stories.purs" -x "src/**/*Test.purs"
+ ```
+
+ With `spago`, the equivalent command is:
+
+ ```sh
+ spago build --purs-args '-x "src/**/*Test.purs" -x "src/**/*Stories.purs"'
+ ```
+
+## 0.15.9
+
+New features:
+
+* Add release artifacts for Linux and macOS running on the ARM64 architecture. (#4455 by @f-f)
+
+Bugfixes:
+
+* Fix prerelease version number on macOS (#4461 by @rhendric)
+
+* Consider fixity declarations during linting (#4462 by @ozkutuk)
+
+* Defer monomorphization for data constructors (#4376 by @purefunctor)
+
+ In `0.15.4` and earlier, the compiler monomorphizes type
+ constructors early, yielding the following type:
+
+ ```purs
+ > :t Nothing
+ forall (a1 :: Type). Maybe a1
+
+ > :t { a : Nothing }
+ forall (a1 :: Type).
+ { a :: Maybe a1
+ }
+ ```
+
+ With this change, the monomorphization introduced in
+ [#835](https://github.com/purescript/purescript/pull/835) is
+ deferred to only when it's needed, such as when constructors are
+ used as values inside of records.
+
+ ```purs
+ > :t Nothing
+ forall a. Maybe a
+
+ > :t { a : Nothing }
+ forall (a1 :: Type).
+ { a :: Maybe a1
+ }
+ ```
+
+ Also as a consequence, record updates should not throw
+ `ConstrainedTypeUnified` in cases such as:
+
+ ```purs
+ v1 :: { a :: Maybe Unit }
+ v1 = { a : Just Unit }
+
+ v2 :: { a :: Maybe Unit }
+ v2 = let v3 = v1 { a = mempty } in v3
+ ```
+
+* Update installer to version 0.3.5 to support ARM builds (#4468 and #4469 by @rhendric)
+
+* Fix exhaustiveness checking to account for case guards (#4467 by @purefunctor)
+
+Internal:
+
+* Refactor module imports to make identifiers' origins obvious (#4451 by @JordanMartinez)
+
+* Require comments not to cause Haddock warnings (#4456 by @rhendric)
+
+## 0.15.8
+
+New features:
+
+* Generated documentation now supports dark mode (#4438 by @sometimes-i-send-pull-requests)
+
+ PureScript documentation has a new dark theme available. It will
+ automatically be used based on your browser or system's color scheme
+ preferences.
+
+Bugfixes:
+
+* Fix instance deriving regression (#4432 by @rhendric)
+
+* Outputs what label the type-error occurred on when types don't match (#4411 by @FredTheDino)
+
+* Account for typed holes when checking value declarations (#4437 by @purefunctor)
+
+ The compiler now takes into account typed holes when ordering value declarations
+ for type checking, allowing more top-level values to be suggested instead of
+ being limited by reverse lexicographical ordering.
+
+ Given:
+ ```purescript
+ module Main where
+
+ newtype K = K Int
+
+ aRinku :: Int -> K
+ aRinku = K
+
+ bMaho :: K
+ bMaho = ?help 0
+
+ cMuni :: Int -> K
+ cMuni = K
+
+ dRei :: Int -> K
+ dRei _ = bMaho
+ ```
+
+ Before:
+ ```
+ Hole 'help' has the inferred type
+
+ Int -> K
+
+ You could substitute the hole with one of these values:
+
+ Main.cMuni :: Int -> K
+ Main.K :: Int -> K
+ ```
+
+ After:
+ ```
+ Hole 'help' has the inferred type
+
+ Int -> K
+
+ You could substitute the hole with one of these values:
+
+ Main.aRinku :: Int -> K
+ Main.cMuni :: Int -> K
+ Main.K :: Int -> K
+ ```
+
+Other improvements:
+
+* Bump Stackage snapshot to lts-20.9 and GHC to 9.2.5 (#4422, #4428, and #4433 by @purefunctor, @JordanMartinez, and @andys8)
+
+Internal:
+
+* Update license/changelog scrips to latest Stack resolver (#4445 by @JordanMartinez)
+
+## 0.15.7
+
+New features:
+
+* Allow IDE module rebuilds eschewing the filesystem (#4399 by @i-am-the-slime)
+
+ This allows IDE clients to typecheck the module the user is currently typing in without modifying the output.
+ This allows for faster feedback cycles in editors and avoids producing a broken `/output` before the user actually saves the file.
+
+* Add `purs ide` dependency/imports filter (#4412 by @nwolverson)
+
+ This allows IDE tooling to filter type searches according to the imports of a given module,
+ restricting to identifiers in scope.
+
+* Shorten custom user-defined error message's prefix (#4418 by @i-am-the-slime)
+
+ Improves clarity and gets to the relevant information faster.
+
+* The compiler can now derive instances for more types and type classes (#4420 by @rhendric)
+
+ New type classes that the compiler can derive:
+ - `Bifunctor`
+ - `Bifoldable`
+ - `Bitraversable`
+ - `Contravariant`
+ - `Profunctor`
+
+ Moreover, the compiler can also use these classes when deriving
+ `Functor`, `Foldable`, and `Traversable`, enabling more instances to be derived
+ whereas before such instances would need to be written manually.
+
+Bugfixes:
+
+* Update installer to `0.3.3` to fix a few installation issues (#4425 by @JordanMartinez)
+
+Other improvements:
+
+* Improve `DuplicateDeclarationsInLet` error so that it mentions what variable names were duplicated, reporting several in separate errors as necessary. (#4405 by @MonoidMusician)
+
+* Fix various typos in documentation and source comments. (#4415 by @Deltaspace0)
+
+* Bump Stackage snapshot to 2022-11-12 and GHC to 9.2.4 (#4422 by @purefunctor)
+
+Internal:
+
+* Organize the compiler's internal constants files (#4406 by @rhendric)
+
+* Enable more GHC warnings (#4429 by @rhendric)
+
+## 0.15.6
+
+Bugfixes:
+
+* Make `FromJSON` instance for `Qualified` backwards compatible (#4403 by @ptrfrncsmrph)
+
+ Prior to #4293, `Qualified` was encoded to JSON such that
+
+ ```haskell
+ >>> encode $ Qualified Nothing "foo"
+ [null,"foo"]
+ >>> encode $ Qualified (Just $ ModuleName "A") "bar"
+ ["A","bar"]
+ ```
+
+ The type of `Qualified` has changed so that `null` no longer appears in JSON output, but for sake of backwards-compatibility with JSON that was produced prior to those changes (pre-`v0.15.2`), we need to accept `null`, which will be interpreted as `Qualified ByNullSourcePos`.
+
+* Fix extraneous qualifiers added to references to floated expressions (#4401 by @rhendric)
+
+## 0.15.5
+
+New features:
+
+* Increases the max number of typed holes displayed from 5 up to 30 (#4341 by @JordanMartinez)
+
+* Add a compiler optimization for `ST` functions with up to 10 arity, similar to `Effect` optimizations. (#4386 by @mikesol)
+
+* Enable the compiler to derive `Foldable` and `Traversable` instances (#4392 by @rhendric)
+
+ These instances follow the same rules as derived `Functor` instances.
+ For details, see [the PureScript language reference](https://github.com/purescript/documentation/blob/master/language/Type-Classes.md#functor-foldable-and-traversable).
+
+Bugfixes:
+
+* Qualify references to expressions floated to the top level of a module by the compiler (#4364 by @rhendric)
+
+* Fix replicated type hole suggestions due to malformed source spans (#4374 by @PureFunctor)
+
+ In PureScript `0.15.4`, the following code will produce multiple entries in
+ the type hole suggestions. This is due to malformed source spans that are
+ generated when desugaring value declarations into case expressions.
+
+ ```purs
+ module Main where
+
+ data F = X | Y
+
+ f :: forall a. F -> a -> a
+ f X b = ?help
+ f Y b = ?help
+ ```
+
+* Improve error spans for class and instance declarations (#4383 and #4391 by @PureFunctor and @rhendric)
+
+ This improves the error spans for class and instance
+ declarations. Instead of highlighting the entire class or instance
+ declaration when `UnknownName` is thrown, the compiler now
+ highlights the class name and its arguments.
+
+ Before:
+ ```purs
+ [1/2 UnknownName]
+
+ 5 class G a <= F a
+ ^^^^^^^^^^^^^^^^
+
+ Unknown type class G
+
+ [2/2 UnknownName]
+
+ 7 instance G a => F a
+ ^^^^^^^^^^^^^^^^^^^
+
+ Unknown type class G
+ ```
+
+ After:
+ ```purs
+ [1/2 UnknownName]
+
+ 5 class G a <= F a
+ ^^^
+
+ Unknown type class G
+
+ [2/2 UnknownName]
+
+ 7 instance G a => F a
+ ^^^
+
+ Unknown type class G
+ ```
+
+* Fix a bug where the compiler did not consider interactions of all functional dependencies in classes. (#4195 by @MonoidMusician)
+ In particular, combinations of multiple parameters determining other parameter(s) were not handled properly,
+ affecting overlapping instance checks and the selection of which parameters are fully determined.
+
+Other improvements:
+
+* Bump actions environment to `macOS-11` (#4372 by @PureFunctor)
+
+Internal:
+
+* Enable `OverloadedRecordDot` extension throughout codebase (#4355 by @JordanMartinez)
+
+* Ensure order of args remain unchanged in `freeTypeVariables` (#4369 by @JordanMartinez)
+
+* Bump HLint to version 3.5 and address most of the new hints (#4391 by @rhendric)
+
+* Remove `purescript-cst` from Makefile (#4389 by @ptrfrncsmrph)
+
+* Bump depend NPM purescript-installer to ^0.3.1 (#4353 by @imcotton)
+
+* Remove base-compat as a dependency (#4384 by @PureFunctor)
+
+## 0.15.4
+
+Bugfixes:
+
+* Fix name clash in guard clauses introduced in #4293 (#4385 by @PureFunctor)
+
+ As a consequence, a problem with the compiler not being able to see
+ imported names if they're shadowed by a guard binder is also solved.
+ ```purs
+ import Data.Foldable (fold)
+ import Data.Maybe (Maybe(..))
+ import Data.Monoid.Additive (Additive(..))
+
+ test :: Maybe Int -> Int
+ test = case _ of
+ m | Just fold <- m -> fold
+ -- Previously would complain about `fold` being undefined
+ | otherwise -> case fold [] of Additive x -> x
+ ```
+
+Internal:
+
+* Add `Guard` handler for the `everywhereWithContextOnValuesM` traversal. (#4385 by @PureFunctor)
+
+## 0.15.3
+
+New features:
+
+* Float compiler-synthesized function applications (#3915 by @rhendric)
+
+ This is a limited implementation of common subexpression elimination for
+ expressions created by the compiler in the process of creating and using
+ typeclass dictionaries. Users can expect code that heavily uses typeclasses
+ to produce JavaScript that is shorter, simpler, and faster.
+
+ Common subexpression elimination is not applied to any expressions explicitly
+ written by users. If you want those floated to a higher scope, you have to do
+ so manually.
+
+* Add support for optional shebang lines (#4214 by @colinwahl and @JordanMartinez)
+
+ One or more shebang line are only allowed as the first lines of a file
+
+ ```purs
+ #! a shebang line
+ #! another shebang line
+ -- | module doc comment
+ -- other comment
+ module MyModule where
+
+ #! Using a shebang here will fail to parse
+ foo :: String
+ foo = ""
+ ```
+
+Bugfixes:
+
+* Stop requiring `bower.json` `devDependencies` when publishing (#4332 by @JordanMartinez)
+
+* Stop emitting source spans with negative line/column numbers (#4343 by @j-nava and @JordanMartinez)
+
+Internal:
+
+* Accommodate internally-generated identifiers that start with digits (#4334 by @rhendric)
+
+* Enable `-Wincomplete-uni-patterns` and `-Wincomplete-record-updates` by default (#4336 by @hdgarrood)
+
+ Update `purescript.cabal` so that the PureScript compiler is built with the
+ flags `-Wincomplete-uni-patterns` and `-Wincomplete-record-updates`
+ enabled by default.
+
+* Setup infrastructure for testing source maps (#4335 by @JordanMartinez)
+
+* Removed a couple of unused `SimpleErrorMessage` constructors (#4344 by @hdgarrood)
+
+* Compare json files through `aeson` in tests (#4354 by @PureFunctor)
+
+ This fixes the tests for the graph and source map outputs, as the
+ ordering is inconsistent between `stack test` and `cabal test`.
+
+* Add version bounds to the test suite's `build-depends`. (#4354 by @PureFunctor)
+
+* Update GHC to 9.2.3 (#4351 by @hdgarrood and @JordanMartinez)
+
+* Add qualification for locally-bound names (#4293 by @PureFunctor)
+
+ This change makes it so that `Qualified` names can now be qualified by either
+ a `ModuleName` for module-level declarations or the starting `SourcePos` for
+ bindings introduced locally. This makes disambiguation between references to
+ local bindings much easier in AST-driven analysis.
+
+## 0.15.2
+
+New features:
+
+* Check for partially applied synonyms in kinds, ctors (#4169 by @rhendric)
+
+ This check doesn't prevent any programs from compiling; it just makes
+ sure that a more specific `PartiallyAppliedSynonym` error is raised
+ instead of a `KindsDoNotUnify` error, which could be interpreted as
+ implying that a partially applied synonym has a valid kind and would be
+ supported elsewhere if that kind is expected.
+
+* Support deriving instances for type synonyms (#4315 by @rhendric)
+
+Bugfixes:
+
+* Do not emit warnings about type wildcards used in binders (patterns). (#4309 by @fsoikin)
+
+ Type wildcards in the following examples no longer trigger a warning:
+
+ ```
+ f :: Int
+ f = 42 # \(x :: _) -> x
+
+ g :: Maybe Int
+ g = do
+ x :: _ <- getX
+ pure $ x + 5
+ ```
+
+* Fix issue with unnamed instances using type operators (#4311 by @rhendric)
+
+* Fix incorrect `Prim.Int (class Compare)` docs: `Int` & `Ordering`, not `Symbol` (#4313 by @JordanMartinez)
+
+* Fix bad interaction between module renaming and inliner (#4322 by @rhendric)
+
+ This bug was triggered when modules that the compiler handles specially
+ are shadowed by local constructors. For example, a constructor named
+ `Prim` could have caused references to `Prim_1["undefined"]` to be
+ produced in the compiled code, leading to a reference error at run time.
+ Less severely, a constructor named `Control_Bind` would have caused the
+ compiler not to inline known monadic functions, leading to slower and
+ less readable compiled code.
+
+* Update `Prim` docs for Boolean, Int, String/Symbol, Number, Record, and Row (#4317 by @JordanMartinez)
+
+* Fix crash caused by polykinded instances (#4325 by @rhendric)
+
+ A polykinded instance is a class instance where one or more of the type
+ parameters has an indeterminate kind. For example, the kind of `a` in
+
+ ```purs
+ instance SomeClass (Proxy a) where ...
+ ```
+
+ is indeterminate unless it's somehow used in a constraint or functional
+ dependency of the instance in a way that determines it.
+
+ The above instance would not have caused the crash; instead, instances needed
+ to be of the form
+
+ ```purs
+ instance SomeClass (f a) where ...
+ ```
+
+ in order to cause it.
+
+* Fix bad interaction between newtype deriving and type synonyms (#4315 by @rhendric)
+
+ See #3453.
+
+* Fix bad interaction between instance deriving and type synonyms (#4315 by @rhendric)
+
+ See #4105.
+
+* Fix spurious kind unification error triggered by newtype deriving, type synonyms, and polykinds (#4315 by @rhendric)
+
+ See #4200.
+
+Internal:
+
+* Deploy builds continuously to GitHub and npm (#4306 and #4324 by @rhendric)
+
+ (Builds triggered by changes that shouldn't affect the published package are
+ not deployed.)
+
+* Fix incomplete type traversals (#4155 by @rhendric)
+
+ This corrects oversights in some compiler internals that are not known to be
+ the cause of any user-facing issues.
+
+* Drop dependency on microlens libraries (#4327 by @rhendric)
+
+## 0.15.1
+
+Release skipped; use [0.15.2](#0152).
+
+## 0.15.0
+
+Breaking changes:
+
+* Switch from Common JS to ES modules (#4232 by @sigma-andex)
+
+ Previously, Purescript used Common JS for FFI declarations.
+
+ Before, FFI was declared like this...
+
+ ```javascript
+ const mymodule = require('mymodule')
+
+ exports.myvar = mymodule.myvar
+ ```
+
+ ...and will be changed to this...
+
+ ```javascript
+ import * as M from 'mymodule';
+ export const myvar = M.myvar
+ ```
+ ...or using the short version...
+
+ ```javascript
+ export { myvar } from 'mymodule';
+ ```
+
+* FFI is annotated with `/* #__PURE__ */` so that bundlers can perform DCE
+* The current LTS Node.js version `12` is now the required minimum version
+
+* Improve apartness checking (#4149 by @rhendric)
+
+ See details in https://github.com/purescript/documentation/blob/master/language/Type-Classes.md#instance-chains
+
+* Disable type class constraints in FFI (#4240 by @JordanMartinez)
+
+ Previously, one could write FFI like the following:
+ ```purescript
+ foreign import foo :: forall a. Show a => a -> String
+ ```
+
+ Type class dictionaries are "magically" handled by the compiler.
+ By including them in the above FFI, one can depend on their representation.
+ Since the representation can change without notice, this may silently break
+ code.
+
+ In `v0.14.x`, a warning was emitted if these were used. Now it will fail
+ to compile. Rather, one should write something like the following
+ where the members of the type class are passed explicitly to
+ the FFI function as arguments:
+
+ ```purescript
+ foo :: forall a. Show a => a -> String
+ foo val = fooImpl show val
+
+ foreign import fooImpl :: forall a. (a -> String) -> a -> String
+ ```
+
+* Removes deprecated syntax for rows (i.e. `#`) and kinds (i.e. `kind`-keyword) (#4239 by @JordanMartinez)
+
+* Apply precedence rules to operator sections (#4033 by @rhendric)
+
+ Previously, `(_ * 4 + 1)` would desugar to `\x -> x * (4 + 1)`, even
+ though `*` has higher precedence than `+`. Conversely, `(3 * 2 + _)`
+ would not compile, even though `*` has higher precedence than `+`. These
+ bugs have now been fixed; `(_ * 4 + 1)` is an error, and `(3 * 2 + _)`
+ desugars to `\x -> 3 * 2 + x`.
+
+ If you have code that relied on the old behavior, add an extra pair of
+ parentheses around the expression in the section.
+
+* If FFI parsing succeeds & CommonJS is detected, fail; otherwise, do not error or warn (#4250 by @sigma-andex)
+
+ Previously, the compiler would emit an error if it failed to parse the FFI JavaScript file.
+ Since the underlying JavaScript parser (i.e. `language-javascript`) fails to parse even
+ valid JavaScript files, we cannot consider every failed parse to mean invalid JS files.
+ Fixing the parser would require a lot of effort, so we are planning to remove it instead
+ in `v0.16.x`.
+
+ If the parse succeeds and a CommonJS module is detected, a compiler error is now emitted.
+ If the parse fails, we no longer emit a compiler error. While we could emit a warning,
+ such a warning will quickly become annoying for FFI files that trigger the buggy paths
+ of `language-javascript`. Moreover, we presume that all will be migrating their code to
+ ES modules now that CommonJS is being deprecated in the larger JavaScript ecosystem.
+
+* Warn on ad-hoc non-single-line case expression syntax (#4241 by @JordanMartinez)
+
+ The following code will now produce a compiler warning.
+ These were originally supported to ease the migration
+ to the new CST parser.
+
+ ```purescript
+ -- before: `arg` isn't indented "past" the `Foo arg` binder
+ case foo of Foo arg ->
+ arg
+ -- after
+ case foo of Foo arg ->
+ foo
+ ```
+
+ Dropping the above syntax make case expressions more similar to how `let` bindings work:
+ ```purescript
+ let ok = 1
+ let
+ ok = 1
+ let ok =
+ 1
+ let notOk =
+ 1
+ ```
+
+* Drop support for browser backend for repl (i.e. `purs repl --port 1234`) (#4255 by @JordanMartinez)
+
+ Running this command will print a link that directs users to use
+ Try PureScript instead.
+
+* Remove `purs bundle` (#4255 by @JordanMartinez)
+
+ Users of `purs bundle` should switch to a standalone bundler such as `esbuild`, `webpack` or `parcel`.
+
+* Lazy initialization for recursive bindings (#4283 by @rhendric)
+
+ This is unlikely to break a working program, but the upshot for users is
+ that it's now possible to get a run-time error when dereferencing an
+ identifier in a recursive binding group before it has been initialized,
+ instead of silently getting an `undefined` value and having that maybe
+ or maybe not lead to an error somewhere else.
+
+ This change can cause code that relies on tail-call optimization to no
+ longer compile with that optimization. If you find that code that
+ previously compiled to a TCO loop no longer does but does include `$lazy`
+ initializers, please report the issue.
+
+ **Alternate backend maintainers:** for you, this change represents a
+ clarification of a responsibility shared by all backends. The identifiers
+ bound in a recursive binding group need to behave as if those identifiers
+ have call-by-need semantics during the initialization of the entire binding
+ group. (Initializing the binding group entails ensuring every initializer
+ has been executed, so after the binding group is initialized, these
+ identifiers can be considered call-by-value again.)
+
+ If an identifier is needed during its own call-by-need initialization, the
+ backend must ensure that an explicit run-time error is raised appropriate for
+ your target platform. This error may be raised at compile time instead if the
+ backend can determine that such a cycle is inevitable. Returning your
+ target language's equivalent of JavaScript's `undefined`, as `purs` did in
+ earlier releases in some cases, is not permitted.
+
+ If your target language natively has call-by-need semantics, you probably
+ don't have to do anything. If your target language is call-by-value and you
+ are using PureScript as a library, you can use the function
+ `Language.PureScript.CoreFn.Laziness.applyLazinessTransform` to your CoreFn
+ input to satisfy this responsibility; if you do, you will need to do the
+ following:
+
+ * Translate `InternalIdent RuntimeLazyFactory` and `InternalIdent (Lazy _)`
+ identifiers to appropriate strings for your backend
+ * Ensure that any output file that needs it has a reference to a function
+ named `InternalIdent RuntimeLazyFactory`, with type `forall a. Fn3 String
+ String (Unit -> a) (Int -> a)`, and with the same semantics as the
+ following JavaScript (though you should customize the error raised to be
+ appropriate for your target language):
+
+ ```js
+ function (name, moduleName, init) {
+ var state = 0;
+ var val;
+ return function (lineNumber) {
+ if (state === 2) return val;
+ if (state === 1) throw new ReferenceError(name + " was needed before it finished initializing (module " + moduleName + ", line " + lineNumber + ")", moduleName, lineNumber);
+ state = 1;
+ val = init();
+ state = 2;
+ return val;
+ };
+ };
+ ```
+
+ If neither of the previous cases apply to you, you can meet this
+ responsibility most easily simply by ensuring that all recursive bindings are
+ lazy. You may instead choose to implement some light analysis to skip
+ generating lazy bindings in some cases, such as if every initializer in the
+ binding group is an `Abs`. You also may choose to reimplement
+ `applyLazinessTransform`, or even develop a more sophisticated laziness
+ transform for your backend. It is of course your responsibility to ensure
+ that the result of whatever analysis you do is equivalent to the expected
+ semantics.
+
+New features:
+
+* Implement the Reflectable type class (#4207 by @PureFunctor)
+
+ The `Reflectable` type class is a common interface for reflecting
+ type-level values down to the term-level. Its instances are
+ automatically solved by the compiler, and it allows `Symbol`, `Int`,
+ `Boolean`, and `Ordering` kinded types to be reflected to their
+ term-level representations.
+
+* Implement native type-level integers (#4207 and #4267 by @PureFunctor and @JordanMartinez)
+
+ Added support for type-level integers and compiler-solved operations
+ such as `Add`, `Mul`, `Compare`, and `ToString`. Type-level integers use the `Int`
+ type as their kind.
+
+* Print compilation progress on the command line (#4258 by @PureFunctor)
+
+ This feature makes it so `purs compile` and `purs docs` now show
+ compilation progress on the command line. Example output:
+
+ ```purs
+ [ 1 of 59] Compiling Type.Proxy
+ [ 2 of 59] Compiling Type.Data.RowList
+ ...
+ [58 of 59] Compiling Effect.Class.Console
+ [59 of 59] Compiling Test.Main
+ ```
+
+* Restore names of quantified variables during generalization (#4257 by @PureFunctor)
+
+ This makes the compiler aware of the names of quantified variables
+ instantiated into unification variables, such that when the latter
+ is generalized, semantic information is restored. For example:
+
+ ```purs
+ addNumberSuffix :: forall a b c d. a -> b -> c -> d -> a
+ addNumberSuffix a _ _ _ = a
+
+ addNumberSuffix' = addNumberSuffix 0
+ ```
+
+ Previously, inferring top-level declarations without type signatures
+ would use `t` suffixed with an integer for type variables.
+
+ ```purs
+ forall t6 t7 t8. t6 -> t7 -> t8 -> Int
+ ```
+
+ Now, the inferred type would refer back to their original names.
+
+ ```purs
+ forall b6 c7 d8. b6 -> c7 -> d8 -> Int
+ ```
+
+* Support Glibc versions >= `2.24` (#4228 by @sd-yip)
+
+ Previously, `purs` required a Glibc version greater than or equal to `2.27`.
+ This requirement is relaxed to support a Glibc version down to `2.24`.
+
+Bugfixes:
+
+* Fix warning suppression for wildcard types (#4269 by @rhendric)
+
+ This bug was triggered by defining recursive partial functions or
+ recursive bindings that contained wildcards in inner type annotations.
+ Recursive partial function declarations now no longer cause spurious
+ wildcard warnings to be emitted, and actual user-written wildcards now
+ accurately emit warnings if and only if they don't appear within a
+ binding (recursive or otherwise) with a complete (wildcard-free) type
+ signature.
+
+* Remove compiler-generated identifiers from type search results (#4260 by @PureFunctor)
+
+Other improvements:
+
+* Improve "Unknown value bind" and "Unknown value discard" errors (#4272 by @mhmdanas)
+
+ The previous error implies that do-notation compiles down to only `bind` or to
+ only `discard` (depending on whether the symbol not found was `bind` or
+ `discard` respectively), which is somewhat misleading, especially in the
+ latter case. Now, the error states correctly that do-notation compiles down to
+ both functions.
+
+Internal:
+
+* Document the `HSPEC_ACCEPT` flag for generating golden files (#4243 by @JordanMartinez)
+
+* Fail test if PureScript file(s) don't have a `Main` module (#4243 by @JordanMartinez)
+
+* Update CI to use `windows-2019` since `windows-2016` is deprecated (#4248 by @JordanMartinez)
+
+* Move `lib/purescript-cst` into `src/` (#4290 by @JordanMartinez)
+
+* Update tests and their bower deps to 0.15.0-compatible versions (#4300 by @JordanMartinez)
+
+## 0.14.7
+
+New features:
+
+* Make `Prim.TypeError`'s `Quote` work on all kinds, not just kind `Type`. (#4142 by @xgrommx)
+
+* Display role annotations in HTML docs (#4121 by @JordanMartinez)
+
+ Previously, the HTML docs would not indicate which types could be safely
+ coerced and which could not:
+
+ ```purescript
+ -- cannot be coerced
+ data Foo1 a = Foo1 a
+ type role Foo1 nominal
+
+ -- can be coerced
+ data Foo2 a = Foo2
+ type role Foo2 phantom
+
+ -- can be coerced in some contexts
+ data Foo3 a = Foo3 a
+ type role Foo3 representational
+ ```
+
+ The HTML docs now display the role annotations either explicitly
+ declared by the developer or those inferred by the compiler.
+
+ Since role annotations are an advanced feature and since most type
+ parameters' roles are the `representational` role, the `phantom` and
+ `nominal` role annotations are displayed in documentation whereas the
+ `representational` role is not, similar to "uninteresting" kind signatures.
+
+ Lastly, FFI declarations like below...
+
+ ```purescript
+ foreign import data Foo :: (Type -> Type) -> Type
+ type role Foo nominal
+ ```
+
+ ...will be rendered as though they are data declarations:
+
+ ```purescript
+ data Foo :: (Type -> Type) -> Type
+ data Foo t0
+ type role Foo nominal
+ ```
+
+ One can distinguish FFI declarations with roles separately from normal `data`
+ declarations that have roles based on the name of the type parameters. Since FFI declarations' type parameters are implicit and thus unnamed, the compiler will generate their name: `t0`, `t1`, ..., `tN` where `N` is a zero-based
+ index of the type parameter.
+
+ Note: the resulting documentation will display the roles, but the roles
+ will not be selectable when selecting the type in case one wants to
+ copy-paste the type into source code.
+
+* Rewrite `Partial` optimization to be cleaner (#4208 by @rhendric)
+
+ This feature shrinks the generated JS code for declarations that use
+ empty type classes, such as `Partial`, but is otherwise not expected to
+ have user-visible consequences.
+
+- Add support for publishing via the `purs.json` manifest format (#4233 by @thomashoneyman)
+
+ This feature expands compiler support for publishing packages with different
+ manifest formats. Previously, packages had to have a `bower.json` manifest;
+ now, packages can choose to have a `purs.json` manifest instead.
+
+ This feature provides only partial support for packages published to the
+ PureScript registry using the `purs.json` manifest format. Registry packages
+ are allowed to be hosted anywhere (not just GitHub), and do not need to be
+ Git repositories at all. However, `purs publish` and its primary consumer,
+ Pursuit, both require packages to be available on GitHub and for their version
+ to be a SemVer-compliant Git tag. Therefore, this feature only supports
+ registry packages that are compatible with these restrictions.
+
+Bugfixes:
+
+* Add missing source spans to data constructors when generating docs (#4202 by @PureFunctor)
+
+* Check role declarations arity during type checking (#4157 by @kl0tl)
+
+* Optimize newtype applications with the ($) operator (#4205 by @PureFunctor)
+
+* Properly deserialize unused identifiers in the CoreFn (#4221 by @sjpgarcia)
+
+ This mostly affects downstream consumers of the CoreFn as discussed in
+ #4201. This makes it so CoreFn deserialization properly reads `$__unused`
+ into `UnusedIdent` instead of an `Ident`. This is particularly useful for
+ downstream consumers of the CoreFn such as alternative backends that don't
+ allow arguments to be omitted from functions.
+
+* Fix type operators in declaration param kinds (#4220 by @rhendric)
+
+ This fixes an internal error triggered by using a type operator in the
+ kind of a type parameter of a data declaration, type synonym
+ declaration, or class declaration.
+
+* Scope type vars when type checking typed values (#4216 by @rhendric)
+
+ When the compiler is checking an expression that is annotated with a
+ type against another expected type, and the annotation introduces a type
+ variable, the compiler needs to introduce that type variable to the
+ scope of any types used inside the expression.
+
+ One noteworthy case of this pattern is member signatures inside
+ instances. This fix allows type variables introduced in member
+ signatures to be used in the member declaration itself.
+
+Internal:
+
+* Bump PureScript to building with GHC-8.10.7, as well as from LTS-17 to LTS-18. (#4199 by @cdepillabout)
+
+* Prevent hangs on internal errors (#4126 by @rhendric)
+
+* The explicit disabling of Nix has been removed from `stack.yaml`. (#4198 by @cdepillabout)
+
+ For developers on NixOS, this means that you should be able to build
+ PureScript by running `stack build` instead of `stack build --nix`.
+ For other developers, this shouldn't affect you.
+
+* Build the entire latest package set in CI (#4217 by @rhendric)
+
+ See [#4128](https://github.com/purescript/purescript/pull/4128).
+
+* Create test machinery for optimizations (#4205 by @PureFunctor)
+
+ This adds machinery for testing code generation for optimizations.
+
+ Partially extracted from #3915 to add tests for #4205.
+
+## 0.14.6
+
+Do not use this release. `purescript-cst`'s version wasn't bumped when this release was made. So, tools like `trypurescript` cannot depend on it. See [0.14.7](#0147) for the same thing.
+
+## 0.14.5
+
+Bugfixes:
+
+* Fix a case where kind inference inferred the wrong kind for type synonyms (#4184 by @jy14898)
+
+* Properly rename module imports in case of conflicts with declarations (#4188 by @PureFunctor)
+
+Internal:
+
+* Fix command and clarify a few other requirements in release guide (#4177 by @JordanMartinez)
+
+* Add `Functor` instance for `Language.PureScript.CoreFn.Module`. (#4186 by @cdepillabout)
+
+## v0.14.4
+
+Bugfixes:
+
+* Solve `Prim.Row.Union left right all` constraint for `left` when `all` and `right` are already closed rows, (#3720 by @MonoidMusician)
+ reflecting the existing functional dependency `all right -> left`
+
+* Account for redundant parens when excluding uninteresting kind sigs from docs (#4137 by @JordanMartinez)
+
+* Add a hint for errors in foreign data type declarations (#4161 by @kl0tl)
+
+* Do not remove bindings referenced in function declarations when bundling (#4044 by @kl0tl)
+
+* Improve row type error messages (#4159 by @rhendric)
+ * Remove a redundant hint that repeats the types in the error
+ * Correctly diff rows containing duplicate items
+ * Erase kind applications from rows in errors (by default)
+
+* Fix bad interaction between superclasses and type synonyms (#4164 by @rhendric)
+
+ See #4101.
+
+* Fix regression in row unification (#4168 by @rhendric)
+
+* Fix backtick operator rule (#4172 by @JordanMartinez)
+
+Other improvements:
+
+* Add developer guide to readme (#3900 by @milesfrain)
+
+Internal:
+
+* Move unreleased changelog entries to CHANGELOG.d (#4132 by @rhendric)
+
+ See CHANGELOG.d/README.md for details.
+
+* Clarify in RELEASE_GUIDE what to do when broken releases are made (#4147 by @JordanMartinez)
+
+* Miscellaneous updates/clarifications to the release guide (#4131 by @JordanMartinez)
+
+* Run Weeder in CI and make it happy (#4148 by @rhendric)
+
+* Add golden tests for self cycles in type class declarations, kind declarations and foreign data type declarations (#4162 by @kl0tl)
+
+* Represent class dictionaries as newtypes (#4125 by @rhendric)
+
+## v0.14.3
+
+New features:
+
+* Display kind signatures and their comments in documentation (#4100 and #4119 by JordanMartinez)
+
+ The compiler now displays kind signatures for data, newtype, type
+ synonym, and type class declarations in generated documentation. The
+ compiler now also includes documentation-comments (i.e. those which start
+ with a `|` character) both above and below the associated kind signature
+ declaration (if any) in generated documentation, whereas previously
+ documentation-comments above a kind signature declaration were ignored.
+
+ Both explicitly declared and inferred kinds are included in documentation.
+ The compiler omits including a kind signature in generated documentation
+ only when the kind is considered "uninteresting". An uninteresting kind is
+ defined as one where all of the declaration's type parameters have kind
+ `Type`.
+
+Bugfixes:
+
+* Ensure unnamed instances appear in documentation (#4109 by @JordanMartinez)
+
+* Allow fixity, kind, role declarations in REPL (#4046, @rhendric)
+
+* Pin OS versions used in CI (#4107, @f-f)
+
+* Fix UnusedName warnings for multiple non-recursive let bindings (#4114 by @nwolverson)
+
+* Remove generated names from errors about instances (#4118 by @rhendric)
+
+Internal:
+
+* Fix for Haddock (#4072 by @ncaq and @JordanMartinez, #4139 by @JordanMartinez)
+
+* Update RELEASE_GUIDE.md with more details (#4104 by @JordanMartinez)
+
+* Use GenIdent for anonymous instances (#4096, @rhendric)
+
+* Desugar type class instance names in type class desugaring pass (#4099 by @JordanMartinez)
+
+## v0.14.2
+
+New features:
+
+* Make type class instance names optional (#4085, @JordanMartinez)
+
+ Previously, one would be required to define a unique name for a type class
+ instance. For example
+
+ ```purescript
+ -- instance naming convention:
+ -- classNameType1Type2Type3
+ instance fooIntString :: Foo Int String
+ ```
+
+ Now, the name and `::` separator characters are optional. The above instance
+ could be rewritten like so:
+
+ ```purescript
+ instance Foo Int String
+ ```
+
+ Note that generated instance names can change without warning as a result of changes
+ elsewhere in your code, so do not rely upon these names in any FFI code.
+
+Bugfixes:
+
+* Unused identifier warnings now report smaller and more relevant source spans (#4088, @nwolverson)
+
+ Also fix incorrect warnings in cases involving a let-pattern binding shadowing
+ an existing identifier.
+
+Internal:
+
+* Drop libtinfo dependency (#3696, @hdgarrood)
+
+ Changes the build configuration so that by default, compiler binaries will
+ not have a dynamic library dependency on libncurses/libtinfo. This should
+ alleviate one of the most common pains in getting the compiler successfully
+ installed, especially on Linux. The cost is a slight degradation in the REPL
+ experience when editing long lines, but this can be avoided by building the
+ compiler with the libtinfo dependency by setting the `terminfo` flag of the
+ `haskeline` library to `true`.
+
+* Migrate CI from Travis to GitHub Actions (#4077, @rhendric)
+
+* Remove tasty from test suite and just use hspec (#4056, @hdgarrood)
+
+* Avoid compiling tests with diagnostics twice in test suite (#4079, @hdgarrood)
+
+* Do less work in test initialization (#4080, @rhendric)
+
+* Follow more HLint suggestions (#4090, @rhendric)
+
+* Export `rebuildModule'` to speed up Try PureScript! slightly (#4095 by @JordanMartinez)
+
+* Merge `purescript-ast` into `purescript-cst` (#4094 by @JordanMartinez)
+
+## v0.14.1
+
+New features:
+
+* Support TCO for functions with tail-recursive inner functions (#3958, @rhendric)
+
+ Adds support for optimizing functions that contain local functions which call
+ the outer function in tail position, as long as those functions themselves
+ are only called from tail position, either in the outer function or in other
+ such functions.
+
+ This enables hand-written mutually-tail-recursive function groups to be
+ optimized, but more critically, it also means that case guards which desugar
+ to use local functions don't break TCO.
+
+* Add warnings for unused names and values (#3819, @nwolverson)
+
+ The compiler now emits warnings when it encounters unused names in binders
+ and unused value declarations. A declaration is considered to be unused if it
+ is not exported and is also not reachable by any of the exported
+ declarations. The compiler will not currently produce unused warnings about
+ other kinds of declarations such as data and type class declarations, but we
+ intend to produce warnings for these in the future as well.
+
+Bugfixes:
+
+* Make close punctuation printable in errors (#3982, @rhendric)
+* Desugar type operators in top-level kind signatures (#4027, @natefaubion)
+* Use type annotation hint only when needed (#4025, @rhendric)
+* Fix pretty printing of "hiding" imports (#4058, @natefaubion)
+
+* Instantiate polymorphic kinds when unwrapping newtypes while solving Coercible constraints (#4040, @kl0tl)
+
+* Fix row unification with shared unknown in tails (#4048, @rhendric)
+
+* Fix kinded declaration reordering in desugaring (#4047, @rhendric)
+
+* Fix wildly off kind unification positions (#4050, @natefaubion)
+
+* Fix incorrect incremental builds with different `--codegen` options (#3911, #3914, @hdgarrood)
+
+ This bug meant that after invoking the compiler with different `--codegen`
+ options, it was easy to end up with (for example) an outdated docs.json or
+ corefn.json file in your output directory which would be incorrectly
+ considered up-to-date by the compiler.
+
+Other improvements:
+
+* Add white outline stroke to logo in README (#4003, @ptrfrncsmrph)
+
+ The previous `logo.png` was not legible against a dark background (#4001).
+
+* Show the constraints that were being solved when encountering a type error (@nwolverson, #4004)
+
+* Removed all shift/reduce conflicts in parser (#4063, @JordanMartinez).
+
+ Happy defaults to using "shift" rather than "reduce" in shift/reduce
+ conflicts. This change merely makes explicit what is already happening
+ implicitly.
+
+Internal:
+
+* Upgrade tests Bower dependencies (#4041, @kl0tl)
+* Remove unused Data.Foldable.foldr import (#4042, @kl0tl)
+
+## v0.14.0
+
+### Polykinds
+
+Polymorphic kinds, based on the [Kind Inference for Datatypes](https://richarde.dev/papers/2020/kind-inference/kind-inference.pdf) paper (#3779, #3831, #3929, #4007, @natefaubion, @kl0tl)
+
+Just as types classify terms, kinds classify types. But while we have polymorphic types, kinds were previously monomorphic.
+
+This meant that we were not able to abstract over kinds, leading for instance to a proliferation of proxy types:
+
+```purescript
+data Proxy (a :: Type) = Proxy
+data SProxy (a :: Symbol) = SProxy
+data RProxy (row :: # Type) = RProxy
+data RLProxy (row :: RowList) = RLProxy
+```
+
+Now we can have a single proxy type, whose parameter has a polymorphic kind.
+
+#### Type :: Type
+
+The old `Kind` data type and namespace is gone. Kinds and types are the same and exist in the same namespace.
+
+Previously one could do:
+
+```purescript
+foreign import kind Boolean
+foreign import data True :: Boolean
+foreign import data False :: Boolean
+```
+
+Where the kind `Boolean` and type `Boolean` were two different things. This is no longer the case. The `Prim` kind `Boolean` is now removed, and you can just use `Prim` type `Boolean` in the same way. This is a breaking change.
+
+The compiler still supports the old `foreign import kind` syntax but it warns that it's deprecated.
+
+```purescript
+foreign import kind Foo
+```
+
+> Foreign kind imports are deprecated and will be removed in a future release. Use empty 'data' instead.
+
+It is treated internally as:
+
+```purescript
+data Foo
+```
+
+Note that `foreign import data` declarations are not deprecated. They are still necessary to define types with kinds other than `Type` since constructors are not lifted as in GHC with [DataKinds](https://downloads.haskell.org/ghc/latest/docs/html/users_guide/exts/data_kinds.html#extension-DataKinds).
+
+Likewise, `kind` imports and exports are deprecated and treated the same as a type import or export.
+
+> Kind imports are deprecated and will be removed in a future release. Omit the 'kind' keyword instead.
+
+The special unary `#` syntax for row kinds is still supported, but deprecated and will warn. There is now `Prim.Row :: Type -> Type` which can be used like a normal type constructor.
+
+> Unary '#' syntax for row kinds is deprecated and will be removed in a future release. Use the 'Row' kind instead.
+
+All of these deprecations have suggested fixes in the JSON output, so tools like [`purescript-suggest`](https://github.com/nwolverson/purescript-suggest) (or your IDE plugin) can automatically apply them.
+
+#### Kind Signatures
+
+With PolyKinds, all type-level declarations are generalized.
+
+```purescript
+data Proxy a = Proxy
+```
+
+Previously, this had the `Type`-defaulted kind `Type -> Type`. Now this will be generalized to `forall k. k -> Type`. Such signature can be written with a kind signature declarations, similar to [standalone kind signatures](https://ryanglscott.github.io/2020/01/05/five-benefits-to-using-standalonekindsignatures/) in GHC.
+
+```purescript
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+```
+
+In GHC, all signatures use the `type` prefix, but we reuse the same keyword as the subsequent declaration because we already have `foreign import data` (rather than `foreign import type`) and because it makes things align nicer. Signatures have the same rule as value-level signatures, so they must always be followed by the "real" declaration.
+
+It's better to be explicit about polymorphism by writing signatures. Since we don't really quantify over free type variables, it's also necessary in the case that two poly-kinded arguments must have the same kind. The compiler will warn about missing kind signatures when polymorphic kinds are inferred.
+
+Classes can have signatures too, but they must end with the new `Constraint` kind instead of `Type`. For example, here's the new definition of `Prim.Row.Cons`:
+
+```purescript
+class Cons :: forall k. Symbol -> k -> Row k -> Row k -> Constraint
+class Cons label a tail row | label a tail -> row, label row -> a tail
+```
+
+### Safe zero-cost coercions
+
+Coercible constraints, based on the [Safe Zero-cost Coercions for Haskell](https://www.microsoft.com/en-us/research/uploads/prod/2018/05/coercible-JFP.pdf) paper (#3351, #3810, #3896, #3873, #3860, #3905, #3893, #3909, #3931, #3906, #3881, #3878, #3937, #3930, #3955, #3927, #3999, #4000, @lunaris, @rhendric, @kl0tl, @hdgarrood)
+
+`Prim.Coerce.Coercible` is a new compiler-solved class, used to relate types with the same runtime representation. One can use `Safe.Coerce.coerce` (from the new [`safe-coerce`](https://github.com/purescript/purescript-safe-coerce) library) instead of `Unsafe.Coerce.unsafeCoerce` to safely turn a `a` into a `b` when `Coercible a b` holds.
+
+#### Roles
+
+Types parameters now have _roles_, which depend on how they affect the runtime representation of their type. There are three roles, from most to least restrictive:
+
+* _nominal_ parameters can only be coerced to themselves.
+
+* _representational_ parameters can only be coerced to each other when a Coercible constraint holds.
+
+* _phantom_ parameters can be coerced to anything.
+
+#### Role annotations
+
+The compiler infers _nominal_ roles for foreign data types, which is safe but can be too constraining sometimes. For example this prevents the coercion of `Effect Age` to `Effect Int`, even though they have the same runtime representation.
+
+The roles of foreign data types can thus be loosened with explicit role annotations, similar to the [RoleAnnotations](https://downloads.haskell.org/ghc/latest/docs/html/users_guide/exts/roles.html#extension-RoleAnnotations) GHC extension.
+
+Here's the annotation we added to `Effect`:
+
+```purescript
+type role Effect representational
+```
+
+Conversely, we might want to strengthen the roles of parameters with invariants invisible to the type system. Maps are the canonical example of this: the shape of their underlying tree rely on the `Ord` instance of their keys, but the `Ord` instance of a newtype may behave differently than the one of the wrapped type so it would be unsafe to allow coercions between `Map k1 a` and `Map k2 a`, even when `Coercible k1 k2` holds.
+
+In order to forbid such unsafe coercion we added a _nominal_ annotation to the first parameter of `Map`:
+
+```purescript
+type role Map nominal representational
+```
+
+Annotated roles are compared against the roles inferred by the compiler so it is not possible to compromise safety by ascribing too permissive roles, except for foreign types.
+
+### Other changes
+
+#### Breaking
+
+* Add compiler support for `Coercible` based `Newtype` (#3975, @fsoikin)
+
+We added a `Coercible` superclass to `Data.Newtype.Newtype` in order to implement `unwrap`, `wrap` and most newtype combinators with `coerce` (see https://github.com/purescript/purescript-newtype/pull/22). This is only a breaking change for non derived instances because the `Newtype` class has no members anymore and can now only be implemented for representationally equal types (those satisfying the new superclass constraint).
+
+For example the instance for `newtype Additive a = Additive a` no longer implements `unwrap` and `wrap`:
+
+```diff
++instance newtypeAdditive :: Newtype (Additive a) a
+-instance newtypeAdditive :: Newtype (Additive a) a where
+- wrap = Additive
+- unwrap (Additive a) = a
+```
+
+Derived instances don't require any modifications.
+
+* Reform handling of quote characters in raw strings (#3961, @rhendric)
+
+Quotes behaved rather unexpectedly in various edge cases inside raw strings. This clears things up by enforcing the following specification:
+
+```
+'"""' '"'{0,2} ([^"]+ '"'{1,2})* [^"]* '"""'
+```
+
+Meaning that raw strings can contain up to two successive quotes, any number of times, but three successive quotes are not allowed inside.
+
+* Unsupport bare negative literals as equational binders (#3956, @rhendric)
+
+It used to be possible to match on negative literals, such as `-1`, but this prevented parsing matches on constructors aliased to `-`. The compiler will reject matches on _bare_ negative literals, but they can still be matched by wrapping them in parentheses.
+
+* Forbid partial data constructors exports (#3872, @kl0tl)
+
+Exporting only some of the constructors of a type meant that changes internal to a module, such as adding or removing an unexported constructor, could cause unexhaustive pattern match errors in downstream code. Partial explicit export lists will have to be completed with the missing constructors or replaced by implicit export lists.
+
+* Print compile errors to stdout, progress messages to stderr (#3839, @JordanMartinez)
+
+Compiler errors and warnings arising from your code are now printed to stdout rather than stderr, and progress messages such as "Compiling Data.Array" are now printed to stderr rather than stdout. Warnings and errors arising from incorrect use of the CLI, such as specifying input files which don't exist or specifying globs which don't match any files, are still printed to stderr (as they were before). This change is useful when using the `--json-errors` flag, since you can now pipe JSON errors into other programs without having to perform awkward gymnastics such as `2>&1`.
+
+#### Fixes
+
+* Only include direct dependencies in the output for `purs graph` instead of their transitive closure (#3993, @colinwahl)
+
+* Fix the reversal of the qualifier of qualified operators (#3971, @rhendric)
+
+Qualified operators, for instance `Data.Array.(!)`, were interpreted with a reversed qualifier, like `Array.Data.(!)`.
+
+* Check all recursive paths in data binding groups (#3936, @natefaubion)
+
+The compiler was not catching recursive type synonyms when some recursive paths were guarded by data types or newtypes.
+
+* Desugar type operator aliases inside parens (#3935, @natefaubion)
+
+The compiler did not accept type operators inside parens in prefix position, except `(->)`.
+
+* Pin language-javascript to a specific version (#3904, @hdgarrood)
+
+Allowing the compiler to be built against various versions of `language-javascript` meant that multiple builds of the same version of the compiler could accept different syntaxes for JavaScript foreign modules, depending on how they were built.
+
+#### Improvements
+
+* Improves protocol errors from the IDE server (#3998, @kritzcreek)
+
+The IDE server now respond with more descriptive error messages when failing to parse a command. This should make it easier to contribute fixes to the various clients.
+
+* Extend IDE ImportCompletion with declarationType (#3997, @i-am-the-slime)
+
+By exposing the declaration type (value, type, typeclass, etc.) downstream tooling can annotate imports with this info so users know what they are about to import. The info can also be mapped to a namespace filter to allow importing identifiers that appear more than once in a source file which throws an exception without such a filter.
+
+* Improve error message when `negate` isn't imported (#3952, @mhmdanas)
+
+This shows a specific message when using negative literals but `Data.Ring.negate` is out of scope, similar to the messages shown when using do notation if `Control.Bind.bind` and `Control.Bind.discard` are out of scope.
+
+* Add source spans to `PartiallyAppliedSynonym` errors (#3951, @rhendric)
+
+`PartiallyAppliedSynonym` errors were usually rethrown with the appropriate source span, but not when deriving instances. This annotates those errors with the source span of the partially applied synonyms themselves, which is more robust and accurate than rethrowing the error with an approximate source span.
+
+* Allow type synonyms in instances heads and superclass constraints (#3539, #3966, #3965, @garyb, @kl0tl)
+
+This allows declarations such as
+
+```purescript
+type Env = { port :: Int }
+newtype App a = App (ReaderT Env Aff a)
+derive newtype instance monadAskApp :: MonadAsk Env App
+```
+
+or
+
+```purescript
+class (Monad m, MonadAsk Env m) <= MonadAskEnv m
+```
+
+* Improve incremental rebuild times for modules with large dependencies (#3899, @milesfrain)
+
+#### Other
+
+* Warn against exported types with hidden constructors but `Generic` or `Newtype` instances (#3907, @kl0tl)
+
+Types with hidden constructors are supposed to be opaque outside of their module of definition but `Generic` and `Newtype` instances allow to construct them with `Data.Generic.Rep.to` or `Data.Newtype.wrap` and examine their content with `Data.Generic.Rep.from` or `Data.Newtype.unwrap`, thus making void any invariant those types may witness.
+
+* Have module re-exports appear in generated code (#3883, @citizengabe)
+
+This is the first step towards smarter incremental rebuilds, which could skip rebuilding downstream modules when the interface of a module did not change (see #3724).
+
+* Add a printer for CST modules (#3887, @kritzcreek)
+
+* Deprecate constraints in foreign imports (#3829, @kl0tl)
+
+Constrained foreign imports leak instance dictionaries, hindering the compiler ability to optimize their representation. Manipulating dictionaries in foreign code should be avoided and foreign imports should accept the class members they need as additional arguments instead of being constrained.
+
+* Deprecate primes (the `'` character) in identifiers exported from foreign modules (#3792, @kl0tl)
+
+We are going to output ES modules instead of CommonJS in the next breaking release but named exports of ES modules, unlike CommonJS exports, have to be valid JavaScript identifiers and so cannot contain primes.
+
+#### Docs
+
+* Generate a changelog from the GitHub releases and add a pull request template (#3989, @JordanMartinez)
+
+* Detail license related error messages and fix incorrect SPDX sample licenses (#3970, @fsoikin)
+
+* Remove a spurious doc comment on the CoreFn Module type (#3552, @jmackie)
+
+* Add a link to the releases page (#3920, @milesfrain)
+
+* Update CONTRIBUTING.md (#3924, @hdgarrood)
+
+* Add troubleshooting steps for libtinfo and EACCES errors (#3903, @milesfrain)
+
+* Update an outdated link to the book (#3916, @sumew)
+
+#### Internal
+
+* Simplify the `Ord` instances of some AST types (#3902, @milesfrain)
+
+* Update the desugaring pipeline to work on individual modules (#3944, @kl0tl)
+
+* Remove the unmaintained and ignored core libraries tests (#3861, @kl0tl)
+
+* Configure Travis to run `hlint` (#3816, #3864, @joneshf, @hdgarrood)
+
+* Remove support for the legacy Bower resolutions format in `purs publish` (#3847, @kl0tl)
+
+* Add GitHub issue templates for bugs and proposals (#3853, @joneshf)
+
+* Add support for Happy >=1.19.10 (#3837, @arrowd)
+
+* Use the same default extensions in all packages (#3823, #3908, @natefaubion, @i-am-the-slime)
+
+* Relax `purescript-ast` dependency on `microlens-platform` to `microlens` (#3817, @joneshf)
+
+* Extract the AST and CST types, and related functions, into their own `purescript-ast` and `purescript-cst` packages for ease of consumption by external tooling (#3793, #3821, #3826, @joneshf, @natefaubion)
+
+* Fix various typos in documentation, comments and bindings names (#3795, @mhmdanas)
+
+* Add golden tests for errors and warnings (#3774, #3811, #3808, #3846, @dariooddenino, @rhendric, @kl0tl)
+
+* More descriptive protocol errors from the ide server (@kritzcreek)
+
+
+## [v0.13.8](https://github.com/purescript/purescript/releases/tag/v0.13.8) - 2020-05-23
+
+**Bug Fixes**
+
+* Update incremental build cache information properly on IDE rebuilds (#3789, @kritzcreek)
+
+ Fixes a bug where triggering a rebuild via the IDE would not update the
+ `output/cache-db.json` file, which in certain situations could lead to
+ unnecessary rebuilds, as well as modules not being rebuilt when they should
+ have been.
+
+* Don't include compiler-internal declarations in IDE completions (#3850, @kritzcreek)
+
+ IDE completions would previously include pseudo-declarations such as
+ `RowToList$Dict` which only exist internally, due to how type class
+ desugaring inside the compiler works. These declarations are now suppressed.
+
+* Fix corefn JSON version parsing (#3877, @paulyoung)
+
+ Fixes a bug where the parser for the functional core (or "corefn") JSON
+ format would ignore all but the first component of the compiler version
+ stored in the JSON. This does not affect the compiler directly, but will be
+ useful for other tooling which depends on the corefn JSON parser provided by
+ the compiler library.
+
+**Improvements**
+
+* Add `purs graph` subcommand for graphing module dependencies (#3781, @jmackie, @f-f)
+
+ This adds a new `graph` subcommand which allows tools to consume information
+ about which modules depend on which other modules. The format is as follows:
+
+ ```
+ { "Prelude":
+ { "path": "src/Prelude.purs"
+ , "depends": ["Data.Semiring", "Data.Ring", ...]
+ },
+ "Data.Ring":
+ { "path": "src/Data/Ring.purs"
+ , "depends": []
+ },
+ ...
+ }
+ ```
+
+ Each property in the returned object has exactly two properties; `path`,
+ which is a string containing the file path relative to the directory where
+ the command was run, and `depends`, which is an array of the names of all
+ directly imported modules.
+
+* purs ide is better at reloading changes (#3799, @kritzcreek)
+
+ The IDE would previously sometimes miss changes that were made outside of the
+ editor, like building with new dependencies or recompiling larger parts of
+ the project on the console.
+
+ The IDE will now notice when this happened on the next command issued to it
+ and refresh its state before processing that command. This might cause the
+ first command after an external change to take a long time to execute, but
+ should increase reliability in general.
+
+* Switch to a binary encoding for externs files (#3841, @kritzcreek)
+
+ This change should result in significant performance improvements in both IDE
+ load times and incremental builds where lots of modules are already built.
+
+* Represent module names as a single Text value internally (#3843, @kritzcreek)
+
+ Boosts compiler performance by representing module names as a single Text
+ value, rather than a list of Text values as it was previously.
+
+* Extract documentation for type classes in purs ide (#3856, @kritzcreek)
+
+ This changes makes documentation comments on type classes visible to the IDE.
+
+**Other**
+
+* Declare explicit upper bounds on Cabal and haskeline rather than relying on
+ stack's pvp-bounds (#3777, @coot)
+
+## [v0.13.7](https://github.com/purescript/purescript/releases/tag/v0.13.7) - 2020-05-23
+
+_release withdrawn due to CI mishap_
+
+## [v0.13.6](https://github.com/purescript/purescript/releases/tag/v0.13.6) - 2020-01-17
+
+**Bug Fixes**
+
+* Reset IDE state before performing a full reload. (#3766, @kritzcreek)
+
+ This prevents a space leak in the IDE.
+
+* Added source spans to ado desugaring. (#3758, @dariooddenino)
+
+ Previously errors in ado desugaring might have had no line information.
+
+* Generate correct arity failure case for some guarded matches. (#3763, @nwolverson)
+
+ Specifically when a multi-way case contains a pattern guard or multiple
+guard expressions, the desugared case expression could contain a guard with
+a different arity to the matched expressions, resulting in an error.
+
+**Improvements**
+
+* Improved ambiguous variable check for functional dependencies. (#3721, @MonoidMusician)
+
+ Previously the compiler might warn about ambiguous variables that aren't actually ambiguous
+due to functional dependencies. This check now fully takes functional dependencies into
+consideration.
+
+* Optimize import desugaring for full builds (#3768, @colinwahl)
+
+ The compiler was performing redundant work when resolving dependencies for modules resulting
+in poor asymptotics. This work is now shared across modules yielding a 30-40% improvement in
+build times for full builds.
+
+* Use PureScript escapes in string pretty-printing (#3751, @hdgarrood)
+
+ Previously the compiler might print invalid escape sequences when pretty-printing code for
+error messages. It now prints correctly escaped code based on PureScript's lexical grammar.
+
+* Optimize away binds to wildcards in do-notation (#3220, @matthewleon, @hdgarrood)
+
+ This avoids generating variable assignments if no variables are actually bound in do-notation.
+Previously the compiler would emit a unique variable name that went unused.
+
+* Output docs.json files for Prim modules (#3769, @f-f)
+
+ This change allows downstream tools such as spago to obtain documentation data for Prim modules.
+Please note, however, that the API for the docs.json files is unstable and may change without warning.
+
+**Other**
+* Fix various typos in source comments (#3760, @bwignall)
+
+## [v0.13.5](https://github.com/purescript/purescript/releases/tag/v0.13.5) - 2019-11-13
+
+This is a small bugfix release to address some issues which were introduced in 0.13.4.
+
+**Bug fixes**
+
+* Fix "too many open files" during compiling (#3743, @hdgarrood)
+
+ The compiler would not promptly close files after opening them, which could easily lead to reaching the open file limit, causing the compiler to crash.
+
+* Fix incorrect unused import warnings when kinds are re-exported (#3744, @hdgarrood)
+
+ Fixes a bug in which unused import warnings were generated for kinds which were re-exported (and therefore should have been considered "used").
+
+**Other**
+
+* Fix Haddock markup error preventing Haddock docs being generated (#3745, @cdepillabout)
+* Add upper bound on Protolude to prevent 0.2.4 from being selected (#3752, @hdgarrood)
+
+## [v0.13.4](https://github.com/purescript/purescript/releases/tag/v0.13.4) - 2019-10-20
+
+**Enhancements**
+
+* Use content hashes when determining whether a file needs rebuilding (#3708, @hdgarrood)
+
+ We now calculate and store content hashes of input files during compilation. If a file's modification time has changed since the last compile, we compare the hash to the previous hash; if the hash is unchanged, this allows us to skip rebuilding this file, speeding up the build.
+
+* Include import declaration qualifiers in unused import warnings (#3685, @matthew-hilty)
+
+ Previously, warnings didn't distinguish between import declarations from the same module. Code like the following
+ ```purescript
+ import A.B (x) -- `x` is used.
+ import A.B (y) as C -- `y` is not used.
+ ```
+ would induce a warning like `The import of module A.B is redundant` even though only the qualified import declaration `C` is actually redundant. The warning now would be `The import of module A.B (qualified as C) is redundant`.
+
+* Include kind imports when determining unused import warnings (#3685, @matthew-hilty)
+
+ Previously, kind imports were ignored. The linter wouldn't emit any warnings for code like the following.
+ ```purescript
+ import A.B (kind K) -- `kind K` is not used.
+ ```
+ And the linter, disregarding `kind K`, would emit an `UnusedImport` instead of an `UnusedExplicitImport` for code like the following.
+ ```purescript
+ import A.B (x, kind K) -- `x` is not used, but `kind K` is.
+ ```
+
+* Better reporting of I/O errors (#3730, @hdgarrood)
+
+ If an unexpected I/O error occurs during compiling, we now include details in the error message. For example, when trying to write compilation results onto a device which has run out of space, we previously would have received a "CannotWriteFile" error with no further information. Now, we receive the underlying error message too:
+
+ ```
+ I/O error while trying to write JSON file: ./output/cache-db.json
+
+ ./output/cache-db.json: hClose: resource exhausted (No space left on device)
+ ```
+
+**Bug fixes**
+
+* Improve type class resolution in the presence of constrained higher-order functions (#3558, @matthew-hilty)
+
+ This is perhaps best illustrated with an example.
+ ```purescript
+ newtype LBox row a = LBox (∀ r. (∀ lbl _1. Row.Cons lbl a _1 row ⇒ IsSymbol lbl ⇒ SProxy lbl → r) → r)
+
+ unLBox ∷ ∀ row a r. (∀ lbl _1. Row.Cons lbl a _1 row ⇒ IsSymbol lbl ⇒ SProxy lbl → r) → LBox row a → r
+ unLBox g (LBox f) = f g
+
+ read ∷ ∀ row a. Record row → LBox row a → a
+ read rec = unLBox \lbl → Record.get lbl rec
+ ```
+
+ The `read` function would previously fail with the error
+
+ ```
+ No type class instance was found for
+
+ Prim.Row.Cons lbl4
+ a5
+ t2
+ row6
+ ```
+
+ although that dictionary should have been available in the function passed to `unLBox`. Now, it type checks successfully.
+
+* Fix cache invalidation false negatives by storing timestamps (#3705, @hdgarrood)
+
+ Previously, an input file would be considered 'modified', and thus requiring rebuilding on a subsequent compile, if its modification time specifies a point in time after any of the modification times of the corresponding output files. This has turned out to be insufficient; files can often change in a way that this algorithm misses, because the input file might still have a timestamp older than the output files. Often this can happen by switching between `git` branches or by updating a dependency.
+
+ This problem can manifest as compiler errors which don't appear to make sense or correspond to what is inside a source file, and which (until now) would need to be fixed by a clean rebuild (e.g. `rm -r output`).
+
+ We now make a note of the modification time when we read an input file, and we consider that input file to have changed on a subsequent compile if the modification time is different to what it was before.
+
+ The hope with this fix is that it should never be necessary to remove an output directory to get a build to run successfully. If you do run into this problem again, it is a bug: please report it.
+
+* Fix exports incorrectly being identified as unused in purs bundle (#3727, @rhendric)
+
+ References to properties on the `exports` object would previously not be picked up by `purs bundle` as uses of those properties, which could lead to them being incorrectly removed. For example:
+
+ ```javascript
+ 'use strict';
+
+ exports.foo = 1;
+ exports.bar = exports.foo;
+ ```
+
+ would remove the `exports.foo = 1;` statement, breaking the assignment to `exports.bar`, if `foo` were not used elsewhere. This statement is now no longer removed.
+
+* Show entire rows in type errors in the presence of the `--verbose-errors` flag (#3722, @Woody88)
+
+ The row diffing feature, which elides common labels in rows occurring in type errors, did not previously respect the `--verbose-errors` flag, giving the same output regardless of whether it was set or not. Now, if the flag has been supplied, we always show the entire row.
+
+**Other**
+
+* Add Makefile command to run license generator (#3718, @hdgarrood)
+* Update language-javascript to 0.7.0.0 (@rhendric, @hdgarrood)
+
+ This enables a number of newer JavaScript syntactic constructs to be used in FFI files. Please see the [language-javascript release notes][] for details.
+
+* Fix for object shorthand syntax in FFI files (#3742, @hdgarrood)
+
+[language-javascript release notes]: https://hackage.haskell.org/package/language-javascript-0.7.0.0/changelog
+
+## [v0.13.3](https://github.com/purescript/purescript/releases/tag/v0.13.3) - 2019-08-18
+
+**Enhancements**
+
+* Eliminate empty type class dictionaries in generated code (#2768, @LiamGoodacre)
+
+ Empty type class dictionaries — dictionaries which do not contain any type class member implementations at runtime — are often used to provide evidence at compile-time to justify that a particular operation will not fail; for example, `Prim.Row.Cons` can be used to justify that we can expect a record to contain a particular field with a particular type. Unfortunately, constructing empty dictionaries can be costly, especially in more complex scenarios such as type-level programming. This release implements a new optimization which avoids the need to build empty dictionaries at runtime by instead inserting `undefined` into the generated code. This optimization can both reduce code size and improve performance in certain contexts.
+
+* Render doc-comments for data constructors and type class members in HTML documentation (#3507, @marcosh)
+
+ Documentation comments for data constructors and type class members are now picked up by `purs docs`, and will soon start appearing in Pursuit too. For example:
+
+ ```purescript
+ -- | Doc-comments like this one were always rendered in Pursuit
+ data Maybe a =
+ -- | Now this one (for the Just constructor) will be rendered too
+ = Just a
+ -- | And this one (for Nothing)
+ | Nothing
+
+ -- | Doc-comments like this one were always rendered in Pursuit
+ class Eq a where
+ -- | Now this one (for the `eq` method) will be rendered too
+ eq :: a -> a -> Boolean
+ ```
+
+* Show diffs of rows in errors and hints (#3392, @dariooddenino)
+
+ In type mismatches between rows, we now elide common labels so that the problem is easier to identify. For example, consider the following code, which has a type error due to the types of the `b` fields in the two records not matching:
+
+ ```purescript
+ foo =
+ { a: 1, b: "hi", c: 3, d: 4, e: 5 }
+ bar =
+ { a: 1, b: 2, c: 3, d: 4, e: 5 }
+ baz =
+ [ foo, bar ]
+ ```
+
+ Previously, the type error would include the entirety of each record type:
+
+ ```
+ Could not match type
+
+ String
+
+ with type
+
+ Int
+
+ while trying to match type ( a :: Int
+ , b :: String
+ , c :: Int
+ , d :: Int
+ , e :: Int
+ )
+ with type ( a :: Int
+ , b :: Int
+ , c :: Int
+ , d :: Int
+ , e :: Int
+ )
+ ```
+
+ This can become quite difficult to read in the case of large record types. Now, we get this:
+
+ ```
+ Could not match type
+
+ String
+
+ with type
+
+ Int
+
+ while trying to match type
+ ( b :: String
+ ...
+ )
+
+ with type
+ ( b :: Int
+ ...
+ )
+ ```
+
+**Bug fixes**
+
+* Remove more dead code in `purs bundle` (#3551, @rhendric)
+
+ The dead code elimination in `purs bundle` now no longer incorrectly considers declarations to be used in the presence of local variables which happen to share their names, and is therefore able to remove these declarations when they are unused.
+
+* Fix parsing of comma-separated guards in let statements (#3713, @natefaubion)
+
+ The 0.13 parser would previously choke on guards separated by commas in let statements within do/ado blocks, such as
+
+ ```purescript
+ test = ado
+ let
+ foo
+ | bar
+ , baz =
+ 42
+ | otherwise = 100
+ in
+ foo
+ ```
+
+ This has now been fixed.
+
+**Other**
+
+* Add placeholder purs.bin to fix npm installs (#3695, @hdgarrood)
+* Refactor and simplify BuildPlan a little (#3699, @hdgarrood)
+* Update link to partial type class guide in error message hints (#3717, @alextes)
+
+## [v0.13.2](https://github.com/purescript/purescript/releases/tag/v0.13.2) - 2019-07-05
+
+**Enhancements**
+
+* Add --debug flag to `purs bundle` command (#3666, @rhendric)
+
+ This flag causes an optimized-for-humans JSON representation of the modules
+being bundled to be dumped to stderr, prior to dead code elimination.
+
+* Ignore duplicate file inputs to CLI commands (#3653, @dyerw)
+
+ If, after expanding globs, a particular file path appears more than once, the
+compiler will now ignore the extra occurrences, instead of emitting a
+`DuplicateModule` error.
+
+**Bug fixes**
+
+* Fix printing of tokens with string escapes (#3665, @hdgarrood)
+* Fix multiple "let"s in ado before the final "in" (#3675, @natefaubion)
+* Throw a parse error (not internal error) when using quoted labels as puns (#3690, @natefaubion)
+
+**Other**
+
+* Parser: Remove partial type signatures for parameterized productions (#3667, @natefaubion)
+* Make git consider \*.out files as binary for the golden tests (#3656, @kritzcreek)
+* Fix build failures on older GHCs by tightening base lower bound (#3659, @hdgarrood)
+* Pin happy version to address build failures when building with Cabal (#3660, @hdgarrood)
+* Add upper bounds when producing source distributions (#3661, @hdgarrood)
+* Update test dependency on typelevel-prelude (#3649, @hdgarrood)
+* Update author and maintainer sections of cabal file (#3663, @hdgarrood)
+* Update to GHC 8.6.5, Stackage LTS 13.26 (#3688, @hdgarrood)
+* Various CI maintenance (#3687, @hdgarrood)
+* Move the "purescript" npm package into the compiler repo (#3691, @hdgarrood)
+
+## [v0.13.1](https://github.com/purescript/purescript/releases/tag/v0.13.1) - 2019-07-04
+
+_Notice: This release has been unpublished due to an error in the package tarball._
+
+## [v0.13.0](https://github.com/purescript/purescript/releases/tag/v0.13.0) - 2019-05-30
+
+**Grammar/Parser Changes**
+
+`0.13` is a very exciting release for me (@natefaubion). For the past few months I've been working on a complete rewrite of the existing parser. The old parser has served us very well, but it has grown very organically over the years which means it's developed some unsightly limbs! Throughout the process I've tried to iron out a lot of dark corner cases in the language grammar, and I hope this release will set us on a firm foundation so we can start to specify what "PureScript the Language" actually is. This release is definitely breaking, but I think you'll find the changes are modest. I also hope that this release will open up a lot of opportunities for syntactic tooling, both using the existing parser or even using alternative parsers (which are now possible).
+
+**Breaking**
+
+There are a number of breaking changes, but I think you'll find that most code will continue to parse fine. We've tested the parser against the existing ecosystem and several large production applications at Awake, Lumi, and SlamData. The migration burden was either non-existent or only involved a few changes.
+
+* The only whitespace now allowed in _code_ is ASCII space and line endings. Since you must use indentation to format PureScript code (unlike Haskell), we felt it was best to be more restrictive in what you can write instead of allowing potentially confusing behavior (implicit tab-width, zero-width spaces, etc). You can still use unicode whitespace within string literals.
+* The only escapes accepted in string literals are `\n\r\t\'\"\\`, `\x[0-9a-fA-F]{1,6}` (unicode hex escape), and `\[\r\n ]+\` (gap escapes). We had inherited a vast zoo of escape codes from the Parsec Haskell Language parser. We decided to minimize what we support, and only add things back if there is significant demand.
+* Octal and binary literals have been removed (hex remains).
+* `\` is no longer a valid operator. It conflicts with lambda syntax.
+* `@` is no longer a valid operator. It conflicts with named binder syntax.
+* `forall` is no longer a valid identifier for expressions. We wanted a consistent rule for type identifiers and expression identifiers.
+* Precedence of constructors with arguments in binders (`a@Foo b` must be `a@(Foo b)`).
+* Precedence of kind annotations (`a :: Type -> Type b :: Type` must now be `(a :: Type -> Type) (b :: Type)`).
+* Precedence of type annotations (`::` has lowest precedence, rather than sitting between operators and function application).
+* Various edge cases with indentation/layout. Again, most code should work fine, but there were some cases where the old parser let you write code that violated the offside rule.
+
+**Fixes**
+
+* Many fixes around parse error locations. The new parser should yield much more precise error locations, especially for large expressions (like in HTML DSLs).
+* Reported source spans no longer include whitespace and comments.
+* Reported source span for the last token in a file is now correct.
+
+**Enhancements**
+
+* `where` is still only sugar for `let` (it does not introduce bindings over guards), but it is now usable in `case` branches in the same manner as declarations.
+* `_` is now allowed in numeric literals, and is an ignored character (ie. `1_000_000 == 1000000`).
+* Raw string literals (triple quotes) can now contain trailing quotes (ie. `"""hello "world"""" == "hello \"world\""`).
+* Kind annotations are now allowed in `forall` contexts (#3576 @colinwahl).
+* The new parser is much faster and can avoid parsing module bodies when initially sorting modules. We also do more work in parallel during the initialization phase of `purs compile`. This means that time to start compiling is faster, and incremental builds are faster. In my testing, a noop call to `purs compile` on the Awake codebase went from ~10s to ~3s.
+
+**Other Changes**
+
+**Breaking**
+
+* Fix sharing in function composition inlining (#3439 @natefaubion). This is really a bugfix, but it has the potential to break code. Previously, you could write recursive point-free compositions that the compiler inadvertently eta-expanded into working code by eliminating sharing. We've changed the optimization to respect strict evaluation semantics, which can cause existing code to stack overflow. This generally arises in instance definitions. Unfortunately, we don't have a way to disallow the problematic code at this time.
+* Fail compilation when a module imports itself (#3586 @hdgarrood).
+* Disallow re-exporting class and type with the same name (#3648 @joneshf).
+
+**Enhancements**
+
+* Better illegal whitespace errors (#3627 @hdgarrood).
+* Only display class members that are not exported from the module when throwing a `TransitiveExportError` for a class (#3612 @colinwahl).
+* Tweaks to type pretty printing (#3610 @garyb).
+* Unify matching constraints (#3620 @garyb).
+* Improve error message on ModuleNotFound error for Prim modules (#3637 @ealmansi).
+
+**Docs**
+
+* Make markdown format behave like html. Remove --docgen opt. Separate directories for html and markdown docs (#3641 @ealmansi).
+* Make html the default output format (#3643 @ealmansi).
+* Write ctags and etags to filesystem instead of stdout (#3644 @ealmansi).
+* Add --output option for purs docs (#3647 @hdgarrood).
+* Use externs files when producing docs (#3645 @hdgarrood). `docs` is now a codegen target for `purs compile` where documentation is persisted as a `docs.json` file in the `output` directory.
+
+**Internal**
+
+* Remove failable patterns and `NoMonadFailDesugaring` extension (#3610 @adnelson).
+* Add tests for grammar fixes addressed by CST (#3629 #3631 @hdgarrood).
+* Keep Parser.y ASCII to avoid locale issues with happy (#3640 @jmackie).
+* Improve display of internal errors (#3634 @hdgarrood).
+
+## [v0.12.5](https://github.com/purescript/purescript/releases/tag/v0.12.5) - 2019-04-15
+
+This small release fixes three issues which were introduced in 0.12.4.
+
+**Filter out module declarations when suggesting imports (#3591)**
+
+When determining candidates for imports, ignore modules. This allows you to easily import types which come from modules of the same name, like `Effect`. (@kRITZCREEK)
+
+**Running purs ide server crashes on macOS (#3594)**
+
+Running `purs ide server` on macOS would immediately crash with the error `purs: Network.Socket.listen: unsupported operation (Operation not supported on socket)`; this has now been fixed. (@f-f)
+
+**Take qualification into consideration when determining type class cycles (#3595)**
+
+When checking for cycles in type classes, the compiler is now able to distinguish classes which have come from different modules, meaning that e.g. `class SomeOtherModule.Foo <= Foo` is no longer incorrectly reported as a class having itself as a superclass. (@hdgarrood)
+
+## [v0.12.4](https://github.com/purescript/purescript/releases/tag/v0.12.4) - 2019-04-07
+
+**Enhancements**
+
+**[purs ide] Treat module declarations like any other (#3541)**
+
+This means we can now complete module names with the completion API as well as being able to query for module level documentation and goto-defintion for module names.
+
+The list loadedModules command has also been deprecated, since you can now use the completion command with a filter for modules instead. (@kRITZCREEK)
+
+**Truncate types in errors (#3401)**
+
+Large types in error messages are now truncated. For example:
+
+```purescript
+module Main where
+
+data Id a = Id a
+
+foo :: Id (Id (Id (Id (Id Int))))
+foo = "hi"
+```
+
+now produces
+
+```
+ Could not match type
+
+ String
+
+ with type
+
+ Id (Id (Id (... ...)))
+```
+
+The previous behaviour of printing the types in full may be recovered by passing the `--verbose-errors` flag to the compiler. (@hdgarrood)
+
+**Don't generate unused imports in JavaScript output (#2177)**
+
+In both CommonJS compiler output and JavaScript `purs bundle` output, we no longer emit JS imports for modules whose use sites have all been optimized out. This reduces the number of warnings produced by other JavaScript bundlers or compressors such as "Side effects in initialization of unused variable Control_Category". (@rhendric)
+
+**Simplify `purs publish` resolutions format (#3565)**
+
+The format for resolutions files passed via the CLI to `purs publish` has been simplified. A new-style resolutions file should look something like this:
+
+```
+{
+ "purescript-prelude": {
+ "version": "4.0.0",
+ "path": "bower_components/purescript-prelude"
+ },
+ "purescript-lists": {
+ "version": "6.0.0",
+ "path": "bower_components/purescript-lists"
+ },
+ ...
+}
+```
+
+The `version` field is used for generating links between packages on Pursuit, and the `path` field is used to obtain the source files while generating documentation: all files matching the glob "src/**/*.purs" relative to the
+`path` directory will be picked up.
+
+The `version` field is optional, but omitting it will mean that no links will be generated for any declarations from that package on Pursuit. The "path" field is required.
+
+The old format is still accepted, but it has been deprecated, and `purs publish` will now produce a warning when consuming it.
+
+This change allows us to work around a bug in Bower which prevented packages with larger dependency trees (such as Halogen) from being uploaded to Pursuit (https://github.com/purescript-contrib/pulp/issues/351). (@hdgarrood)
+
+**Improve error messages for cycles in type class declarations (#3223)**
+
+A cycle in type class declarations, such as
+
+```purescript
+class C a <= D a
+class D a <= C a
+```
+
+now produces a more informative error, which no longer confusingly refers to type synonyms, and which displays all of the classes involved in the cycle. (@Saulukass)
+
+**Bug fixes**
+
+* Naming a constructor `PS` no longer causes JS runtime errors when using `purs bundle` (#3505, @mhcurylo)
+* `purs publish` now warns instead of failing if not all dependencies have a resolved version, e.g. if some have been installed via a branch or commit reference instead of a version range (#3061, @hdgarrood)
+* Fix handling of directive prologues like "use strict" in `purs bundle` (#3581, @rhendric)
+
+**Other**
+
+* Raise upper bound on aeson in package.yaml (#3537, @jacereda)
+* Add Nix test dependencies to stack.yaml (#3525, @jmackie)
+* [purs ide] Represent filters as a data type rather than functions (#3547, @kRITZCREEK)
+* Carry data constructor field names in the AST (#3566, @garyb)
+* Convert prim docs tests to use tasty (#3568, @hdgarrood)
+* Bump bower version used in tests (#3570, @garyb)
+* Add tests for `purs bundle` (#3533, @mhcurylo)
+* Update to GHC 8.6.4 (#3560, @kRITZCREEK)
+* Rerun some of the compiler tests to test with `purs bundle` (#3579, @rhendric)
+
+## [v0.12.3](https://github.com/purescript/purescript/releases/tag/v0.12.3) - 2019-02-24
+
+**Enhancements**
+
+- Add better positions for UnknownName errors for types/kinds (#3515, @colinwahl)
+
+ Previously an UnknownName error (arising from e.g. referring to a non-existent type, or a type which you forgot to import) would have a span covering the whole type annotation. Now, the error span only covers the relevant part of the type.
+
+- Boost performance of `purs docs` by simplifying re-export handling (#3534, @hdgarrood)
+
+**Bug fixes**
+
+- Fix applicative do notation breaking API documentation generation with `purs docs` (#3414, @hdgarrood)
+- Fix the REPL browser backend (#3387, @dariooddenino)
+
+**Other**
+
+- Make the license generator a proper stack script (@kRITZCREEK)
+- Include the module from which something was imported for re-exports in externs files (@hdgarrood)
+- Add AppVeyor build status to README.md (@hdgarrood)
+
+## [v0.12.2](https://github.com/purescript/purescript/releases/tag/v0.12.2) - 2019-01-13
+
+**New features**
+
+- Named type wildcards (#3500, @natefaubion)
+
+ It's now possible to use `?hole` style syntax in type signatures where you want the compiler to tell you the missing type. This was previously possible by using `_` in a type signature, but now `_` can be used without raising a warning, as long as it does not appear in a top level declaration.
+
+**Enhancements**
+
+- Improve error message for missing node.js in the repl (#3456, @justinwoo)
+- Add `Boolean` kind to `Prim.Boolean` (#3389, @justinwoo)
+- Link to documentation repo as docs for non-Prim built-in types/kinds (#3460, @JordanMartinez)
+- PSCi: Support multiple command types in paste-mode (#3471, @LiamGoodacre)
+- Add `row:column` printing for source positions in error messages (#3473, @justinwoo)
+- Add `:print` directive for customizable repl printing (#3478, @hdgarrood)
+- Implement qualified `do` (#3373, @pkamenarsky)
+- Add better source positions to kind errors (#3495, @natefaubion)
+
+**Fixes**
+
+- Remove references to previous kinds `*` and `!` (#3458, @LiamGoodacre)
+- Fix linting of unused type variables (#3464, @LiamGoodacre)
+- Avoid dropping super class dicts for the same class (#3461, @LiamGoodacre)
+- Fix issue where `Partial` can foil TCO optimizations (#3218, @matthewleon)
+- Fix quoting of record labels in error messages (#3480, @hdgarrood)
+- Prevent invalid JS being generated from awkward record labels (#3486, @hdgarrood)
+- Fix unnecessary quoting of reserved names when used as labels (#3487, @hdgarrood)
+- Fix source spans for binding groups (#3462, @LiamGoodacre)
+- Fix kind error for recursive data type (#3511, @natefaubion)
+
+**Other (internals)**
+
+- Add annotations to `Type` and `Kind` (#3484, @natefaubion)
+- Use handwritten JSON instances for `Type`/`Kind` (#3496, @natefaubion)
+- Remove pretty print constructors from `Type` (#3498, @natefaubion)
+- Add JSON compatibility tests (#3497, @hdgarrood)
+- Remove the concept of the 'current module' in Docs (#3506, @hdgarrood)
+
+## [v0.12.1](https://github.com/purescript/purescript/releases/tag/v0.12.1) - 2018-11-12
+
+**Enhancements**
+
+* Print types of missing typeclass members (#3398, @fehrenbach)
+* Added `Prim.TypeError.QuoteLabel` for pretty printing labels in custom type errors (#3436, @dariooddenino)
+* `purs ide` accepts codegen targets for the rebuild command (#3449, @kRITZCREEK)
+
+**Fixes**
+
+* Fixes errors spans for `CannotFindDerivingType` (#3425, @kRITZCREEK)
+* Fixes a traversal bug where `ObjectNestedUpdate` was surviving desugaring (#3388, @natefaubion)
+* Fixes type operators reexports (#3410, @natefaubion)
+* Fixes ST magic-do and inlining (#3444, @natefaubion)
+* Fixes missing span information when using do-syntax without importing `bind` or `discard` (#3418, @natefaubion)
+* Fixes missing span information when shadowing an open import with a module definition (#3417, @natefaubion)
+* Fixes stale `:browse` environment after `:reload` (#3001, @rndnoise)
+
+**Other**
+
+* Fix test-support dependency versions and update psci browse test (#3374, @LiamGoodacre)
+* Changes to build with GHC 8.4.3 (#3372, @kRITZCREEK)
+* Set --haddock flag based on BUILD_TYPE (#3409, @justinwoo)
+* Use `microlens-platform` instead of `lens` (#3400, @joneshf)
+* Avoid `Data.ByteString.Lazy.toStrict` (#3433, @coot)
+* Add ffiCodegen to MakeActions (#3434, @coot)
+* Add nix config to stack.yaml (#3435, @f-f)
+
+## [v0.12.0](https://github.com/purescript/purescript/releases/tag/v0.12.0) - 2018-05-21
+
+**Breaking changes**
+
+- Added applicative-do notation; `ado` is now a keyword. An full explanation of the behaviour and usage of `ado` is available [in a comment on the issue](https://github.com/purescript/purescript/pull/2889#issuecomment-301260299). (#2889, @rightfold)
+- Removed wrapper scripts for the old binary names (psc, psci, etc.) (#2993, @hdgarrood)
+- Removed compiler support for deriving `purescript-generics`. `purescript-generics-rep` is still supported. (#3007, @paf31)
+- Instances with just one method now require the method to be indented (bug fix, but potentially breaking) (#2947, @quesebifurcan)
+- Overlapping instances are now an error rather than a warning, but can be resolved with the new instance chain groups feature (#2315, @LiamGoodacre)
+- Reworked the `CoreFn` json representation. This change enables use of the [Zephyr tree shaking tool](https://github.com/coot/zephyr) for PureScript. (#3049, #3342, @coot)
+- It is no longer possible to export a type class that has superclasses that are not also exported (bug fix, but potentially breaking) (#3132, @parsonsmatt)
+- `Eq` and `Ord` deriving will now rely on `Eq1` and `Ord1` constraints as necessary where sometimes previously `Eq (f _)` would be required. `Eq1` and `Ord1` instances can also be derived. (#3207, @garyb)
+- Some `Prim` type classes have been renamed/moved, so will require explicit importing (#3176, @parsonsmatt):
+ - `RowCons` is now `Prim.Row.Cons`
+ - `Union` is now `Prim.Row.Union`
+ - `Fail` is now `Prim.TypeError.Fail`
+ - `Warn` is now `Prim.TypeError.Warn`
+- Users can no longer specify modules under the `Prim` namespace (#3291, @parsonsmatt)
+- `TypeConcat` and `TypeString` have been replaced because they were in kind `Symbol` but weren't literals. The `Prim.TypeError.Doc` kind and related constructors (`Text`, `Quote`, `Beside`, `Above`) have been added in their place. The `Fail` and `Warn` type classes now accept a `Doc` instead of a `Symbol`.
+ (#3134, @LiamGoodacre)
+- In simple cases instance overlaps are now checked at declaration time rather than being deferred until an attempt is made to use them. (#3129, @LiamGoodacre)
+- Chaining non-associative or mixed associativity operators of the same precedence is no longer allowed (#3315, @garyb)
+- The `--dump-corefn` and `--source-maps` arguments to `purs compile` have been removed. There is now a `--codegen` argument that allows the specific codegen targets to be specified - for example, `--codegen corefn` will not produce JS files, `--codgen js,corefn` will produce both. If the `sourcemaps` target is used `js` will be implied, so there's no difference between `--codegen js,sourcemaps` and `--codegen sourcemaps`). If no targets are specified the default is `js`. (#3196, @garyb, @gabejohnson)
+- Exported types that use foreign kinds now require the foreign kinds to be exported too (bug fix, but potentially breaking) (#3331, @garyb)
+- The pursuit commands were removed from `purs ide` due to lack of use and editor tooling implementing the features instead (#3355, @kRITZCREEK)
+
+**Enhancements**
+
+- Added `Cons` compiler-solved type class for `Symbol` (#3054, @kcsongor)
+- The `Append` compiler-solved type class for `Symbol` can now be run in reverse (#3025, @paf31)
+- Find Usages for values and constructors in `purs ide` (#3206, @kRITZCREEK)
+- `purs ide` treats `hiding` imports the same as open imports when sorting (#3069, @kRITZCREEK)
+- Added inlining for fully saturated usages of `runEffFn/mkEffFn` (#3026, @nwolverson)
+- Improved explanation of `UnusableDeclaration` error (#3088, #3304, @i-am-tom)
+- Improved rendering of comments in generated JavaScript by removing additional newlines (#3096, @brandonhamilton)
+- Instance chain support. (#2315, @LiamGoodacre)
+ > We can now express an explicit ordering on instances that would previously have been overlapping.
+ > For example we could now write an `IsEqual` type class to compute if two types are equal or apart:
+ > ```
+ > class IsEqual (l :: Type) (r :: Type) (o :: Boolean) | l r -> o
+ > instance isEqualRefl :: IsEqual x x True
+ > else instance isEqualContra :: IsEqual l r False
+ > ```
+ > Note the `else` keyword that links the two instances together.
+ > The `isEqualContra` will only be up for selection once the compiler knows it couldn't possible select `isEqualRefl` - i.e that `l` and `r` are definitely not equal.
+- Improved orphan instance error to include locations where the instance would be valid (#3106, @i-am-tom)
+- Added an explicit error for better explanation of duplicate type class or instance declarations (#3093, @LiamGoodacre)
+- `purs ide` now provide documentation comments (#2349, @nwolverson)
+- Clarified meaning of duplicate labels in a `Record` row (#3143, @paf31)
+- Explicit import suggestions consistently use `(..)` for constructors now (#3142, @nwolverson)
+- Improved tab completion in `purs repl` (#3227, @rndnoise)
+- Large compiler perfomance improvement in some cases by skipping source spans in `Eq`, `Ord` for binders (#3265, @bitemyapp)
+- Added support for error/warning messages to carry multiple source spans (#3255, @garyb)
+- Improved tab completion in `purs repl` when parens and brackets are involved (#3236, @rndnoise)
+- Improved completion in `purs repl` after `:kind` and `:type` (#3237, @rndnoise)
+- Added the "magic do" optimisation for the new simplified `Effect` type (`Control.Monad.Eff` is still supported) (#3289, @kRITZCREEK, #3301, @garyb)
+- Improvide build startup times when resuming a build with incremental results (#3270, @kRITZCREEK)
+- Added compiler-solved `Prim.Row.Nub` type class (#3293, @natefaubion)
+- Improved docs for `Prim.Row.Cons` and `Prim.Row.Union` (#3292, @vladciobanu)
+- `Functor` can now be derived when quantifiers are used in constructors (#3232, @i-am-tom)
+- `purs repl` will now complete types after `::` (#3239, @rndnoise)
+- Added compiler-solved `Prim.Row.Lacks` type class (#3305, @natefaubion)
+- Added current output path to missing output error message from `purs ide` (#3311, @rgrinberg)
+- Improved parser error messages for `.purs-repl` (#3248, @rndnoise)
+- `require` in generated JavaScript now includes full `index.js` file paths (#2621, @chexxor)
+- Added more compiler-solved type classes and supporting types and kinds to `Prim`:
+ - `Prim.Ordering` module with `kind Ordering`, `type LT`, `type EQ`, `type GT`
+ - `Prim.RowList` module with `class RowToList`, `kind RowList`, `type Nil`, `type Cons`
+ - `Prim.Symbol` module with `class Compare`, `class Append`, `class Cons`
+ (#3312, @LiamGoodacre, @kRITZCREEK)
+- Generated code for closed records now explicitly reconstructs the record rather than looping (#1493, @fehrenbach, [blog post with more details](http://stefan-fehrenbach.net/blog/2018-04-28-efficient-updates-closed-records-purescript/index.html))
+- Enhanced `purs --help` message to include hint about using `--help` with commands (#3344, @hdgarrood)
+- `IncorrectConstructorArity` error message now includes a hint of how many arguments are expected for the constructor (#3353, @joneshf)
+- `purs ide` now uses absolute locations for file paths for better experience in some editors (#3363, @kRITZCREEK)
+
+**Bug fixes**
+
+- Fixed a bug with names cause by `Prim` always being imported unqualified (#2197, @LightAndLight)
+- Fixed overlapping instances error message to reflect its new status as an error (#3084, @drets)
+- Added source position to `TypeClassDeclaration` errors (#3109, @b123400)
+- Fixed entailment issues with skolems and matches in the typechecker (#3121, @LiamGoodacre)
+- Fixed multiple parentheses around a type causing a crash (#3085, @MonoidMusician)
+- Fixed `purs ide` inserting conflicting imports for types (#3131, @nwolverson)
+- Fixed constraints being inferred differently for lambda expressions compared with equational declarations (#3125, @LiamGoodacre)
+- Updated glob handling to prevent excessive memory usage (#3055, @hdgarrood)
+- Added position information to warnings in type declarations (#3174, @b123400)
+- Fixed documentation generated for Pursuit rendering functional dependency variables as identifier links (#3180, @houli)
+- Naming a function argument `__unused` no longer breaks codegen (#3187, @matthewleon)
+- Added position information to `ShadowedName` warning (#3213, @garyb)
+- Added position information to `UnusedTypeVar` warning (#3214, @garyb)
+- Added position information to `MissingClassMember`, `ExtraneousClassMember`, `ExpectedWildcard` errors (#3216, @garyb)
+- Added position information to `ExportConflict` errors (#3217, @garyb)
+- Fixed `ctags` and `etags` generation when explicit exports are involved (#3204, @matthewleon)
+- Added position information to `ScopeShadowing` warning (#3219, @garyb)
+- Added position information for various FFI related errors and warnings (#3276, @garyb)
+- Added all available positions to `CycleInModule` and `DuplicateModule` errors (#3273, @garyb)
+- Added position information for `IntOutOfRange` errors (#3277, @garyb, @kRITZCREEK)
+- Warnings are now raised when a module re-exports a qualified module with implicit import (#2726, @garyb)
+- `purs repl` now shows results for `:browse Prim` (#2672, @rndnoise)
+- Added position information to `ErrorParsingFFIModule` (#3307, @nwolverson)
+- Added position information for `ScopeConflict` cause by exports (#3318, @garyb)
+- Added position information to errors that occur in binding groups and data binding groups (#3275, @garyb)
+- Fixed a scoping issue when resolving operators (#2803, @kRITZCREEK, @LightAndLight)
+- Type synonyms are now desugared earlier when newtype deriving (#3325, @LiamGoodacre)
+- Fixed subgoals of compiler-solved type classes being ignored (#3333, @LiamGoodacre)
+- Added position information to type operator associativity errors (#3337, @garyb)
+- Updated description of `purs docs` command (#3343, @hdgarrood)
+- Fixed `purs docs` issue with re-exporting from `Prim` submodules (#3347, @hdgarrood)
+- Enabled `purs ide` imports for `Prim` submodules (#3352, @kRITZCREEK)
+- Fixed `purs bundle` failing to bundle in the 0.12-rc1 (#3359, @garyb)
+- Enabled `:browse` for `Prim` submodules in `purs repl` (#3364, @kRITZCREEK)
+
+**Other**
+
+- Updated installation information to include details about prebuild binaries (#3167, @MiracleBlue)
+- Test suite now prints output when failing cases are encountered (#3181, @parsonsmatt)
+- Updated test suite to use tasty (#2848, @kRITZCREEK)
+- Improved performance of `repl` test suite (#3234, @rndnoise)
+- Refactored `let` pattern desugaring to be less brittle (#3268, @kRITZCREEK)
+- Added makefile with common tasks for contributors (#3266, @bitemyapp)
+- Added `ghcid` and testing commands to makefile (#3290, @parsonsmatt)
+- Removed old unused `MultipleFFIModules` error (#3308, @nwolverson)
+- `mod` and `div` for `Int` are no longer inlined as their definition has changed in a way that makes their implementation more complicated - purescript/purescript-prelude#161 (#3309, @garyb)
+- The test suite now checks warnings and errors have position information (#3211, @garyb)
+- The AST was updated to be able to differentiate between `let` and `where` clauses (#3317, @joneshf)
+- Support for an optimization pass on `CoreFn` was added (#3319, @matthewleon)
+- Clarified note in the `purs ide` docs about the behaviour of `--editor-mode` (#3350, @chexxor)
+- Updated bundle/install docs for 0.12 (#3357, @hdgarrood)
+- Removed old readme for `psc-bundle` (a leftover from before the unified `purs` binary) (#3356, @Cmdv)
+
+## [v0.12.0-rc1](https://github.com/purescript/purescript/releases/tag/v0.12.0-rc1) - 2018-04-29
+
+**Breaking changes**
+
+- Added applicative-do notation; `ado` is now a keyword. An full explanation of the behaviour and usage of `ado` is available [in a comment on the issue](https://github.com/purescript/purescript/pull/2889#issuecomment-301260299). (#2889, @rightfold)
+- Removed wrapper scripts for the old binary names (psc, psci, etc.) (#2993, @hdgarrood)
+- Removed compiler support for deriving `purescript-generics`. `purescript-generics-rep` is still supported. (#3007, @paf31)
+- Instances with just one method now require the method to be indented (bug fix, but potentially breaking) (#2947, @quesebifurcan)
+- Overlapping instances are now an error rather than a warning, but can be resolved with the new instance chain groups feature (#2315, @LiamGoodacre)
+- Reworked the `CoreFn` json representation (#3049, @coot)
+- It is no longer possible to export a type class that has superclasses that are not also exported (bug fix, but potentially breaking) (#3132, @parsonsmatt)
+- `Eq` and `Ord` deriving will now rely on `Eq1` and `Ord1` constraints as necessary where sometimes previously `Eq (f _)` would be required. `Eq1` and `Ord1` instances can also be derived. (#3207, @garyb)
+- Some `Prim` type classes have been renamed/moved, so will require explicit importing (#3176, @parsonsmatt):
+ - `RowCons` is now `Prim.Row.Cons`
+ - `Union` is now `Prim.Row.Union`
+ - `Fail` is now `Prim.TypeError.Fail`
+ - `Warn` is now `Prim.TypeError.Warn`
+- Users can no longer specify modules under the `Prim` namespace (#3291, @parsonsmatt)
+- `TypeConcat` and `TypeString` have been replaced because they were in kind `Symbol` but weren't literals. The `Prim.TypeErrer.Doc` kind and related constructors (`Text`, `Quote`, `Beside`, `Above`) have been added in their place. The `Fail` and `Warn` type classes now accept a `Doc` instead of a `Symbol`.
+ (#3134, @LiamGoodacre)
+- In simple cases instance overlaps are now checked at declaration time rather than being deferred until an attempt is made to use them. (#3129, @LiamGoodacre)
+- Chaining non-associative or mixed associativity operators of the same precedence is no longer allowed (#3315, @garyb)
+- The `--dump-corefn` and `--source-maps` arguments to `purs compile` have been removed. There is now a `--codegen` argument that allows the specific codegen targets to be specified - for example, `--codegen corefn` will not produce JS files, `--codgen js,corefn` will produce both. If the `sourcemaps` target is used `js` will be implied, so there's no difference between `--codegen js,sourcemaps` and `--codegen sourcemaps`). If no targets are specified the default is `js`. (#3196, @garyb, @gabejohnson)
+- Exported types that use foreign kinds now require the foreign kinds to be exported too (bug fix, but potentially breaking) (#3331, @garyb)
+
+**Enhancements**
+
+- Added `Cons` compiler-solved type class for `Symbol` (#3054, @kcsongor)
+- The `Append` compiler-solved type class for `Symbol` can now be run in reverse (#3025, @paf31)
+- Find Usages for values and constructors in `purs ide` (#3206, @kRITZCREEK)
+- `purs ide` treats `hiding` imports the same as open imports when sorting (#3069, @kRITZCREEK)
+- Added inlining for fully saturated usages of `runEffFn/mkEffFn` (#3026, @nwolverson)
+- Improved explanation of `UnusableDeclaration` error (#3088, #3304, @i-am-tom)
+- Improved rendering of comments in generated JavaScript by removing additional newlines (#3096, @brandonhamilton)
+- Instance chain support. (#2315, @LiamGoodacre)
+ > We can now express an explicit ordering on instances that would previously have been overlapping.
+ > For example we could now write an `IsEqual` type class to compute if two types are equal or apart:
+ > ```
+ > class IsEqual (l :: Type) (r :: Type) (o :: Boolean) | l r -> o
+ > instance isEqualRefl :: IsEqual x x True
+ > else instance isEqualContra :: IsEqual l r False
+ > ```
+ > Note the `else` keyword that links the two instances together.
+ > The `isEqualContra` will only be up for selection once the compiler knows it couldn't possible select `isEqualRefl` - i.e that `l` and `r` are definitely not equal.
+- Improved orphan instance error to include locations where the instance would be valid (#3106, @i-am-tom)
+- Added an explicit error for better explanation of duplicate type class or instance declarations (#3093, @LiamGoodacre)
+- `purs ide` now provide documentation comments (#2349, @nwolverson)
+- Clarified meaning of duplicate labels in a `Record` row (#3143, @paf31)
+- Explicit import suggestions consistently use `(..)` for constructors now (#3142, @nwolverson)
+- Improved tab completion in `purs repl` (#3227, @rndnoise)
+- Large compiler perfomance improvement in some cases by skipping source spans in `Eq`, `Ord` for binders (#3265, @bitemyapp)
+- Added support for error/warning messages to carry multiple source spans (#3255, @garyb)
+- Improved tab completion in `purs repl` when parens and brackets are involved (#3236, @rndnoise)
+- Improved completion in `purs repl` after `:kind` and `:type` (#3237, @rndnoise)
+- Added the "magic do" optimisation for the new simplified `Effect` type (`Control.Monad.Eff` is still supported) (#3289, @kRITZCREEK, #3301, @garyb)
+- Improvide build startup times when resuming a build with incremental results (#3270, @kRITZCREEK)
+- Added compiler-solved `Prim.Row.Nub` type class (#3293, @natefaubion)
+- Improved docs for `Prim.Row.Cons` and `Prim.Row.Union` (#3292, @vladciobanu)
+- `Functor` can now be derived when quantifiers are used in constructors (#3232, @i-am-tom)
+- `purs repl` will now complete types after `::` (#3239, @rndnoise)
+- Added compiler-solved `Prim.Row.Lacks` type class (#3305, @natefaubion)
+- Added current output path to missing output error message from `purs ide` (#3311, @rgrinberg)
+- Improved parser error messages for `.purs-repl` (#3248, @rndnoise)
+- `require` in generated JavaScript now includes full `index.js` file paths (#2621, @chexxor)
+- Added more compiler-solved type classes and supporting types and kinds to `Prim`:
+ - `Prim.Ordering` module with `kind Ordering`, `type LT`, `type EQ`, `type GT`
+ - `Prim.RowList` module with `class RowToList`, `kind RowList`, `type Nil`, `type Cons`
+ - `Prim.Symbol` module with `class Compare`, `class Append`, `class Cons`
+ (#3312, @LiamGoodacre, @kRITZCREEK)
+- Generated code for closed records now explicitly reconstructs the record rather than looping (#1493, @fehrenbach, [blog post with more details](http://stefan-fehrenbach.net/blog/2018-04-28-efficient-updates-closed-records-purescript/index.html))
+
+**Bug fixes**
+
+- Fixed a bug with names cause by `Prim` always being imported unqualified (#2197, @LightAndLight)
+- Fixed overlapping instances error message to reflect its new status as an error (#3084, @drets)
+- Added source position to `TypeClassDeclaration` errors (#3109, @b123400)
+- Fixed entailment issues with skolems and matches in the typechecker (#3121, @LiamGoodacre)
+- Fixed multiple parentheses around a type causing a crash (#3085, @MonoidMusician)
+- Fixed `purs ide` inserting conflicting imports for types (#3131, @nwolverson)
+- Fixed constraints being inferred differently for lambda expressions compared with equational declarations (#3125, @LiamGoodacre)
+- Updated glob handling to prevent excessive memory usage (#3055, @hdgarrood)
+- Added position information to warnings in type declarations (#3174, @b123400)
+- Fixed documentation generated for Pursuit rendering functional dependency variables as identifier links (#3180, @houli)
+- Naming a function argument `__unused` no longer breaks codegen (#3187, @matthewleon)
+- Added position information to `ShadowedName` warning (#3213, @garyb)
+- Added position information to `UnusedTypeVar` warning (#3214, @garyb)
+- Added position information to `MissingClassMember`, `ExtraneousClassMember`, `ExpectedWildcard` errors (#3216, @garyb)
+- Added position information to `ExportConflict` errors (#3217, @garyb)
+- Fixed `ctags` and `etags` generation when explicit exports are involved (#3204, @matthewleon)
+- Added position information to `ScopeShadowing` warning (#3219, @garyb)
+- Added position information for various FFI related errors and warnings (#3276, @garyb)
+- Added all available positions to `CycleInModule` and `DuplicateModule` errors (#3273, @garyb)
+- Added position information for `IntOutOfRange` errors (#3277, @garyb, @kRITZCREEK)
+- Warnings are now raised when a module re-exports a qualified module with implicit import (#2726, @garyb)
+- `purs repl` now shows results for `:browse Prim` (#2672, @rndnoise)
+- Added position information to `ErrorParsingFFIModule` (#3307, @nwolverson)
+- Added position information for `ScopeConflict` cause by exports (#3318, @garyb)
+- Added position information to errors that occur in binding groups and data binding groups (#3275, @garyb)
+- Fixed a scoping issue when resolving operators (#2803, @kRITZCREEK, @LightAndLight)
+- Type synonyms are now desugared earlier when newtype deriving (#3325, @LiamGoodacre)
+- Fixed subgoals of compiler-solved type classes being ignored (#3333, @LiamGoodacre)
+- Added position information to type operator associativity errors (#3337, @garyb)
+
+**Other**
+
+- Updated installation information to include details about prebuild binaries (#3167, @MiracleBlue)
+- Test suite now prints output when failing cases are encountered (#3181, @parsonsmatt)
+- Updated test suite to use tasty (#2848, @kRITZCREEK)
+- Improved performance of `repl` test suite (#3234, @rndnoise)
+- Refactored `let` pattern desugaring to be less brittle (#3268, @kRITZCREEK)
+- Added makefile with common tasks for contributors (#3266, @bitemyapp)
+- Added `ghcid` and testing commands to makefile (#3290, @parsonsmatt)
+- Removed old unused `MultipleFFIModules` error (#3308, @nwolverson)
+- `mod` and `div` for `Int` are no longer inlined as their definition has changed in a way that makes their implementation more complicated - purescript/purescript-prelude#161 (#3309, @garyb)
+- The test suite now checks warnings and errors have position information (#3211, @garyb)
+- The AST was updated to be able to differentiate between `let` and `where` clauses (#3317, @joneshf)
+- Support for an optimization pass on `CoreFn` was added (#3319, @matthewleon)
+
+## [v0.11.7](https://github.com/purescript/purescript/releases/tag/v0.11.7) - 2017-11-15
+
+**Enhancements**
+
+- Add position to type class declaration errors (@b123400)
+- Add valid location list to orphan instance errors (@i-am-tom)
+- Expand error message for UnusableDeclaration (#3088, @i-am-tom)
+- Inline `Unsafe.Coerce.unsafeCoerce` (@coot)
+
+**Bug Fixes**
+
+- Correctly quote uppercased field labels in errors (@Thimoteus)
+- `purs ide` inserts conflicting imports for types (#3131, @nwolverson)
+- Instantiate abstraction body during inference to fix a type checking bug (@LiamGoodacre)
+- Fix a bug related to the desugaring of nested parentheses (@MonoidMusician)
+- Fix a loop in the kind checker (@paf31)
+- Fix a bug in type operator precedence parsing (@paf31)
+- Eliminate some redundant whitespace in the generated JS output (@matthewleon)
+- Only add newline before initial group of comment lines during code generation (@brandonhamilton)
+- Treat kinds as used in import warnings (@nwolverson)
+
+**`purs ide`**
+
+- Add an "editor mode" (@kRITZCREEK)
+
+ When the `editor-mode` flag is specified at startup the server will not start afile watcher process any more. Instead it only reloads after successful rebuild commands. This is a lot less fragile than relying on the file system APIs, but will mean that a manual load needs to be triggered after builds that didn't go through `purs ide`.
+
+- `purs ide` now groups `hiding` imports with implicit ones (@kRITZCREEK)
+- Return documentation comments in `purs ide` completions (@nwolverson)
+- Add an `actualFile` parameter to the rebuild command (@kRITZCREEK)
+- Add qualified explicit import (@nwolverson)
+- Fixed case-splitting on local non-exported datatypes (@LightAndLight)
+- Make the `filters` parameter in the `type` command optional (@b123400)
+
+**`purs docs`**
+
+- Embed CSS for HTML docs (@hdgarrood)
+- Fix source links for re-exports (@felixSchl)
+- Use order given in export list in generated docs (@hdgarrood)
+- Prevent browser from treating the title and source link as one word (@Rufflewind)
+- Fix fragment links to type constructors in HTML (@hdgarrood)
+
+**`purs repl`**
+
+- Add `:complete` directive to `purs repl` to support completion in more editors (@actionshrimp)
+
+**Other**
+
+- Add docs for duplicate labels in record types (@paf31)
+- Adds a document for the design of `purs ide`. (@kRITZCREEK)
+- Update `PROTOCOL.md` docs for `purs ide` (@BjornMelgaard)
+- Upgrade to GHC version 8.2 (@kRITZCREEK)
+- Allow `blaze-html-0.9` (@felixonmars)
+- Bump `Glob` dependency (@mjhoy)
+- Use `Hspec` in `TestDocs` (@hdgarrood)
+- Fix AppVeyor deployment (#2774) (@hdgarrood)
+- Various type safety improvements to the AST (@kRITZCREEK)
+- Remove some references to old executables (@hdgarrood)
+- Update the installation documentation (@hdgarrood)
+- Update test dependencies (@hdgarrood)
+- Only build `master` and versioned tags in AppVeyor (@hdgarrood)
+
+## [v0.11.6](https://github.com/purescript/purescript/releases/tag/v0.11.6) - 2017-07-10
+
+**New Features**
+
+**`RowToList` support**
+
+(@LiamGoodacre)
+
+There is a new type class in `typelevel-prelude` called `RowToList`, which turns
+a row of types into a type-level list. This allows us to work with closed
+rows in more ways at the type level. The compiler will now solve these constraints
+automatically for closed rows of types.
+
+**Enhancements**
+
+- Allow things to be hidden from Prim (@garyb)
+- Re-evaluate REPL globs on `:reload` (@hdgarrood)
+- Include comments in child declarations in HTML docs (@hdgarrood)
+
+**IDE Enhancements**
+
+- Collect data constructors (@kRITZCREEK)
+- Adds declarations for Prim (@kRITZCREEK)
+- Repopulates the rebuild cache when populating volatile state (@kRITZCREEK)
+- Add declaration type filter (#2924) (@sectore)
+- Improve reexport bundling (@kRITZCREEK)
+- Resolve synonyms and kinds (@kRITZCREEK)
+
+**Bug Fixes**
+
+- Replace synonyms in instance constraints (@LiamGoodacre)
+- Encode PSCI's server content as UTF-8 string (@dgendill)
+- Fix child declaration ordering in docs (@hdgarrood)
+- Improve instance ordering in HTML docs (@hdgarrood)
+- Fix links to type operators in HTML docs (@hdgarrood)
+
+**Other**
+
+- Add source span annotations to Declaration (@garyb)
+- Add source span annotations to DeclarationRef (@garyb)
+- Remove `purescript.cabal` and add to `.gitignore` (@garyb)
+- Raise upper bound on `aeson` in `package.yaml` (@garyb)
+- Only build master and semver tags in Travis (@hdgarrood)
+
+## [v0.11.5](https://github.com/purescript/purescript/releases/tag/v0.11.5) - 2017-06-05
+
+**Compiler**
+
+**Enhancements**
+
+**Type signatures in instances**
+
+(@cdepillabout)
+
+Type class instances can now include type signatures for class members, as documentation:
+
+```purescript
+data MyType = MyType String
+
+instance showMyType :: Show MyType where
+ show :: MyType -> String
+ show (MyType s) = "(MyType " <> show s <> ")"
+```
+
+**Bug Fixes**
+
+- Encode HTML content as UTF8 when using `purs repl` with `--port` (@dgendill)
+- Disallow some invalid newtype-derived instances (@paf31)
+- Disallow `forall` within constraints (#2874, @sectore)
+- Convert `\r\n` into `\n` after reading files (@kRITZCREEK)
+- Fix PSCi tests (@kRITZCREEK)
+- Better variable naming hygiene in TCO. (#2868, @houli)
+- Simplify TCO generated code (@matthewleon)
+- Remove newlines from printed custom type errors (@matthewleon)
+- Fix some `purs` command line help message issues (@Cmdv)
+- Apply relative paths during pretty printing of errors (@kRITZCREEK)
+- Desugar `let` properly when generating docs (@paf31)
+- Fix kind signature for `RowCons` type class in documentation (@tslawler)
+- Fix an issue with error messages for `TypesDoNotUnify` involving duplicate labels (#2820, @thoradam)
+
+**Other**
+
+- Update `package.yaml` (@sol)
+- Parse support modules from actual test support `purs` (@noraesae)
+- Update `build` command to run tests (@sectore)
+- Bumps lower bound for `directory` (@kRITZCREEK)
+- Switch `core-tests` to `psc-package` (#2830, @matthewleon)
+- Small fix for the copyright dates (@seanwestfall)
+- Update `CONTRIBUTING.md` for "new contributor" label (@thoradam)
+
+**`purs ide`**
+
+**Features**
+
+- Add a new namespace filter (#2792, @sectore, @stefanholzmueller)
+
+A new filter, which restricts query results to the value, type and/or kind namespaces, which allows improvements to the completion and import commands.
+
+- Adds a command to add qualified imports (@kRITZCREEK)
+
+This empowers editor plugins to add imports for qualified identifiers, for example in [the Emacs plugin](https://github.com/epost/psc-ide-emacs/pull/103).
+
+- New import formatting (@kRITZCREEK)
+- Group reexports in completions (@kRITZCREEK)
+
+Editors can now choose to let `purs ide` group reexports for the same value, to reduce noise when completing values like `Data.Functor.map` which are reexported a lot and show up that many times in the completion list.
+
+**Enhancements**
+
+- Parse modules in parallel (@kRITZCREEK)
+
+This can yield significant speedups in the initial load times. For example a full load of `slamdata/slamdata` improves from 11 to 6 seconds
+
+- Introduce completion options (@kRITZCREEK)
+
+**Bug Fixes**
+
+- Resolve synonyms and kinds (@kRITZCREEK)
+- Work around laziness when measuring command performance (@kRITZCREEK)
+- Simplify state type (@kRITZCREEK)
+- Extract namespace ADT (@kRITZCREEK)
+- Decodes source files as UTF8 when parsing out the imports (@kRITZCREEK)
+- Fix the import command for kinds (@kRITZCREEK)
+- Reads files in text mode for adding imports (@kRITZCREEK)
+- Add `-h`/`--help` to `ide` subcommands (@simonyangme)
+
+## [v0.11.4](https://github.com/purescript/purescript/releases/tag/v0.11.4) - 2017-04-17
+
+**Enhancements**
+
+- `purs` executable will now display help text by default (@matthewleon)
+- Adding `-h`/`--help` to `ide` subcommands (@simonyangme)
+- Some simplifications to the tail call optimization (@matthewleon)
+
+**Bug Fixes**
+
+- Remove newline from printed custom type errors (@matthewleon)
+- Fix pretty printing of rows in error messages (#2820, @thoradam)
+- Allow user to propagate Warn constraints (@paf31)
+- Match type level strings in docs renderer (#2772, @hdgarrood)
+- Fix encoding bug in `purs ide` list import command (@kRITZCREEK)
+- `purs ide` now reads files in text mode for adding imports (@kRITZCREEK)
+
+**Other**
+
+- Bump `aeson` lower bound to 1.0 (@hdgarrood)
+- Add a bunch of NFData instances (@hdgarrood)
+- Turn off coveralls upload for now (@paf31)
+- `purs` command line help message fixes (@Cmdv)
+- Switch core-tests to `psc-package` (#2830, @matthewleon)
+- Update `CONTRIBUTING.md` notes (@thoradam)
+
+## [v0.11.3](https://github.com/purescript/purescript/releases/tag/v0.11.3) - 2017-04-08
+
+**Bug Fixes**
+
+- Fix the exhaustivity check for pattern guards (@alexbiehl)
+
+**Other**
+
+- Require `directory >=1.2.3.0` for XDG support (@bergmark)
+- @noraesae has refactored some PSCi code to improve the test suite.
+- Use `hpack` to generate the `.cabal` file (@kRITZCREEK)
+- Use XDG Base Directory Specification for `psci_history` (@legrostdg)
+
+## [v0.11.2](https://github.com/purescript/purescript/releases/tag/v0.11.2) - 2017-04-02
+
+**New Features**
+
+**Polymorphic Labels**
+
+(@paf31)
+
+A new `RowCons` constraint has been added to `Prim`. `RowCons` is a 4-way relation between
+
+1. Symbols
+1. Types
+1. Input rows
+1. Output rows
+
+which appends a new label (1) with the specified type (2) onto the front of the input row (3), to generate a new output row (4). The constraint can also be run backwards to subtract a label from an output row.
+
+This allows us to quantify types over labels appearing at the front of a row type, by quantifying over the corresponding symbol/type pair. This gives us a limited form of polymorphic labels which enables things like writing [a single lens for any record accessor](https://github.com/purescript/purescript/blob/e4ff177017f1411ad4cbeade129cfe1bb52d6e99/examples/passing/PolyLabels.purs#L41-L51).
+
+**Enhancements**
+
+- Use XDG Base Directory Specification for the location of the `psci_history` file (@legrostdg)
+- Collect more information for classes and synonyms in `purs ide` (@kRITZCREEK)
+
+**Bug Fixes**
+
+- Desugar pattern guards *after* type checking, to avoid an issue with the exhaustivity checker (@alexbiehl)
+
+**Other**
+
+- A new PSCi evaluation test suite was added (@noraesae)
+- Use `hpack` to generate the `.cabal` file (@kRITZCREEK)
+
+## [v0.11.1](https://github.com/purescript/purescript/releases/tag/v0.11.1) - 2017-03-28
+
+**Bug Fixes**
+
+**Compiler**
+
+- Enable TCO for variable intros and assignments #2779 (@paf31)
+- Fixed special case in codegen for guards #2787 (@paf31)
+
+**Docs generation**
+
+- Wrap decl title in span for better double-click selection #2786 (@rightfold)
+- List instance info under correct sections, fix #2780 (@paf31)
+
+## [v0.11.0](https://github.com/purescript/purescript/releases/tag/v0.11.0) - 2017-03-25
+
+This release includes several breaking changes, in preparation for the 1.0 release, as well as many enhancements and bug fixes.
+
+Most users will probably want to wait until all aspects of the release have been finalized. Progress on libraries and tools is being tracked [here](https://github.com/purescript/purescript/issues/2745).
+
+Many thanks to the contributors who helped with this release!
+
+**Breaking Changes**
+
+(@garyb, @paf31)
+
+**`=>` now acts like a binary type operator**
+
+It was previously possible to specify many constraints in the same context by
+separating them with commas inside parentheses on the left of the `=>`:
+
+```purescript
+runFreeT :: ∀ m f. (Functor f, Monad m) => ...
+```
+
+This is no longer allowed. Instead, `=>` now acts like a binary operator, with a
+constraint on the left and a type on the right. Multiple constraints must be
+introduced using currying, as with regular function arguments:
+
+```purescript
+runFreeT :: ∀ m f. Functor f => Monad m => ...
+```
+
+This is in preparation for adding _constraint kinds_, at which point `=>` will become
+an actual binary type operator, defined in `Prim`.
+
+**`*` and `!` kinds have been removed**
+
+The kind symbols `*` (for the kind of types) and `!` (for the kind of effects) have been
+removed from the parser. Instead of `*`, use `Type`, which is defined in `Prim`.
+Instead of `!`, use `Effect`, which can now be imported from `Control.Monad.Eff`.
+
+The `#` symbol, which is used to construct a row kind, is still supported. We cannot move this kind into `Prim` (because it is polykinded, and we do not support kind polymorphism).
+
+**One single consolidated executable**
+
+The various `psc-*` executables have been replaced with a single executable called `purs`.
+The various subcommands are documented on the `--help` page:
+
+```
+bundle Bundle compiled PureScript modules for the browser
+compile Compile PureScript source files
+docs Generate Markdown documentation from PureScript source files
+hierarchy Generate a GraphViz directed graph of PureScript type classes
+ide Start or query an IDE server process
+publish Generates documentation packages for upload to Pursuit
+repl Enter the interactive mode (PSCi)
+```
+
+Wrapper scripts will be provided in the binary distribution.
+
+**`psc-package` was removed**
+
+`psc-package` has been removed from the main compiler distribution. It will still
+be maintained along with the package sets repo, but will not be bundled with the compiler.
+
+A binary distribution which is compatible with this release is [available](https://github.com/purescript/psc-package/releases/tag/v0.1.0).
+
+**Implicitly discarded values in `do` blocks now raise errors**
+
+Code which discards the result of a computation in a `do` block:
+
+```purescript
+duplicate :: Array a -> Array a
+duplicate xs = do
+ x <- xs
+ [true, false] -- the result here is discarded
+ pure x
+```
+
+will now raise an error. The compiler allows values of certain types to be discarded,
+based on the `Discard` class in `Control.Bind`. The only type which can be discarded is
+`Unit`, but the feature was implemented using a type class to enable support for
+alternative preludes.
+
+**No more dependency on the Bower executable**
+
+In addition to removing `psc-package` from the compiler distribution, we have also
+removed any explicit dependency on the Bower executable. The compiler will not assume
+use of any particular package manager, but will aim to provide generic support for
+package managers generally, via command line options and hooks.
+
+`purs publish` will continue to use the Bower JSON formats. The `bower.json` format
+is now referred to as the "manifest file", while the output of `bower list --json`,
+which is used by `purs publish` internally, is referred to as the "resolutions file".
+
+**Enhancements**
+
+**Pattern Guards**
+
+(@alexbiehl)
+
+In addition to regular guards:
+
+```purescript
+foo x | condition x = ...
+```
+
+the compiler now supports _pattern guards_, which let the user simultaneously
+test a value against a pattern, and bind names to values.
+
+For example, we can apply a function `fn` to an argument `x`, succeeding only if
+`fn` returns `Just y` for some `y`, binding `y` at the same time:
+
+```purescript
+bar x | Just y <- fn x = ... -- x and y are both in scope here
+```
+
+Pattern guards can be very useful for expressing certain types of control flow when
+using algebraic data types.
+
+**HTML Documentation**
+
+(@hdgarrood)
+
+The `--format html` option has been added to `purs docs`. The HTML format uses
+the Pursuit template, and is very useful for rendering documentation for offline
+use.
+
+[Here is an example](http://harry.garrood.me/purs-html-docs-example/) of the generated HTML.
+
+**Duplicate Labels**
+
+(@paf31)
+
+Row types now support duplicate labels, which can be useful when using the `Eff`
+monad. For example, we could not previously use the `catchException` function if
+the resulting action _also_ required the `EXCEPTION` effect, since otherwise the
+type of the inner action would contain a duplicate label.
+
+Rows are now unordered collections (of labels and types) _with duplicates_. However,
+the collection of types for a specific label within a row _is_ ordered.
+Conceptually, a row can be thought of as a type-level `Map Label (NonEmptyList Type)`.
+
+A type constructor (such as `Record`) which takes a row of types as an argument should
+define what its meaning is on each row. The meaning of a value of type `Record r`
+is a JavaScript object where the type of the value associated with each label is given
+by the head element of the non-empty list of types for that label.
+
+**Row Constraints**
+
+(@doolse, @paf31)
+
+A new constraint called `Union` has been added to `Prim`. `Union` is a three-way relation between
+rows of types, and the compiler will solve it automatically when it is possible to do so.
+
+`Union` is a left-biased union of rows which takes into account duplicate labels. If the same label appears in rows `l` and `r`, and `Union l r u` holds, then the label will appear twice in `u`.
+
+`Union` makes it possible to give a type to the function which merges two records:
+
+```purescript
+merge :: forall r1 r2 r3. Union r1 r2 r3 => Record r1 -> Record r2 -> Record r3
+```
+
+Note that this is a left-biased merge - if the two input record contain a common label, the type of the
+label in the result will be taken from the left input.
+
+**Patterns in `let` expressions**
+
+(@noraesae)
+
+Let expressions and `where` clauses can now use binders on the left hand side of
+a declaration:
+
+```purescript
+map f xs =
+ let { head, tail } = uncons xs
+ in [f head] <> map f tail
+```
+
+Unlike in Haskell, declarations with these patterns cannot appear in dependency cycles, and bound names can only be used in declarations after the one in which they are brought into scope.
+
+**Find record accessors in Type Directed Search**
+
+(@kRITZCREEK)
+
+Type-directed search will now include results for record accessors. This can
+be very useful when working with extensible records with a type-driven programming
+workflow.
+
+**Other Enhancements**
+
+- Add basic usability check and error for ambiguously-typed type class members (@LiamGoodacre)
+- Improved skolem escape check (@paf31)
+- Fix links to declarations in `Prim` (@hdgarrood)
+- Emit `_` instead of `false` case for `if then else` to improve optimizations (@rightfold)
+- Add `InvalidDerivedInstance` error to improve errors for derived instances (@paf31)
+- Make generated code for superclass instances less ugly (@paf31)
+- Support polymorphic types in typed binders (@paf31)
+- Make file paths relative in error messages (@paf31)
+- Improve errors from module sorter (@paf31)
+- Improve error for unused type variables (@paf31)
+- Include source span in externs file for error reporting purposes (@paf31)
+- Improve instance arity errors (@mrkgnao)
+
+**`purs ide`**
+
+**Features**
+
+**Improve import parsing**
+
+- `purs ide` now uses a new import parser, which allows `purs ide` to handle any
+import section that the compiler would accept correctly. (@kRITZCREEK)
+- Parse imports with hanging right paren (@matthewleon)
+- Reuses lenient import parsing for the list import command (@kRITZCREEK)
+
+**Don't create the output/ directory if it can't be found**
+
+(@kRITZCREEK)
+
+`purs ide` will now no longer leave empty output/ directories behind when it is
+started in a directory that is not a PureScript project.
+
+**Collect type class instances**
+
+(@kRITZCREEK)
+
+`purs ide` collects instances and stores them with their respective type class.
+There's no way to retrieve these yet, but we will extend the protocol soon.
+
+**Bug Fixes**
+
+- No longer strip trailing dots for Pursuit queries (@kRITZCREEK)
+- Fix #2537 (`psc-ide` shouldn't crash when building a non-existent file) (@kRITZCREEK)
+- Fix #2504 (fix a crash related to prematurely closed handles) (@kRITZCREEK)
+- Speed up rebuilding by x2, by rebuilding with open exports asynchronously (@kRITZCREEK)
+- Return operators in `purs ide` imports list (@nwolverson)
+- Also detect location information for operators (@kRITZCREEK)
+
+**Cleanup**
+
+- Removes unnecessary clause in import pretty printing (@kRITZCREEK)
+- Removes the deprecated `--debug` option (@kRITZCREEK)
+- Restructure testing to avoid running the server (@kRITZCREEK)
+
+**`purs repl`**
+
+- Add back `.purs-repl` file support (@paf31)
+- PSCi command changes, add `:clear` (@noraesae)
+- Declarations no longer require `let` (@noraesae)
+- Improve CLI error and startup messages (@noraesae)
+
+**Bug Fixes**
+
+- Changes to help the tail call optimization fire more consistently (@paf31)
+- Fix `everythingWithScope` traversal bug #2718 (@paf31)
+- Errors for open rows in derived instances (@paf31)
+- Instantiate types in record literals as necessary (@paf31)
+- Fix `Generic` deriving with synonyms (@paf31)
+- Rebuild modules if necessary when using `--dump-corefn` (@paf31)
+- Ensure solved type classes are imported (@LiamGoodacre)
+- Allow for older Git versions in `purs publish` (@mcoffin)
+- Fix `purs publish --dry-run` (@hdgarrood)
+- Exported data constructors can now contain quotes (@LiamGoodacre)
+
+**Documentation**
+
+- Capitalise *script into *Script (@noraesae)
+
+**Performance**
+
+- Optimize `keepImp` (@paf31)
+- Replace `nub` with `ordNub` (@matthewleon)
+- Combine inlining optimizations into a single pass (@paf31)
+
+**Other**
+
+- Add `HasCallStack` to internalError (@alexbiehl)
+- Use Stackage LTS 8.0 (@noraesae)
+- Address Travis timeout issues (@hdgarrood)
+- Improve module structure in PSCi test suite (@noraesae)
+- Fix the PSCi script (@mrkgnao)
+- Include Git commit information in non-release builds (@hdgarrood)
+- Add test case for #2756 (@int-index)
+- Some code cleanup in the module imports phase (@matthewleon)
+
+## [v0.10.7](https://github.com/purescript/purescript/releases/tag/v0.10.7) - 2017-02-11
+
+This release contains a bug fix for a bug in `psc-bundle` which was introduced in 0.10.6.
+
+## [v0.10.6](https://github.com/purescript/purescript/releases/tag/v0.10.6) - 2017-02-07
+
+**Enhancements**
+- Add support for user defined warnings via the `Warn` type class (@LiamGoodacre, [blog post](https://liamgoodacre.github.io/purescript/warnings/2017/01/17/purescript-warn-type-class.html))
+- Support nested record update (@LiamGoodacre, [blog post](https://liamgoodacre.github.io/purescript/records/2017/01/29/nested-record-updates.html))
+- Inline `unsafePartial` (@paf31)
+- Fail early when `bind` is brought into scope inside `do` (@paf31)
+
+**Bug Fixes**
+- Disallow polymorphic types in binders, preventing a crash (@paf31)
+- Rebuild modules if necessary when using `--dump-corefn` (@paf31)
+- `TypeLevelString`/`TypeConcat` should not be quoted (@michaelficarra)
+- Generate JS static member accesses whenever possible (@michaelficarra)
+- Require dependencies to exist during sorting phase (@paf31)
+- Fix inlining for `negateInt` (@paf31)
+- Fix object key quoting (@hdgarrood)
+- Don't expand synonyms until after kind checking (@paf31)
+- Fix 'Unknown type index' on mismatch between class and instance argument counts (@LiamGoodacre)
+- Style comment types differently (@matthewleon)
+
+**`psc-ide`**
+- Return operators in `psc-ide` imports list (@nwolverson)
+- Collect type class instances (@kRITZCREEK)
+- Log failing to accept or parse an incoming command (@kRITZCREEK)
+- Fix #2537 (@kRITZCREEK)
+- Fix #2504 (@kRITZCREEK)
+- Also detect location information for operators (@kRITZCREEK)
+- Speeds up rebuilding by x2 (@kRITZCREEK)
+- Restructure testing to avoid running the server (@kRITZCREEK)
+
+**`psc-publish`**
+- Add modules for rendering HTML documentation (@hdgarrood)
+- Fix `psc-publish --dry-run` (@hdgarrood)
+- Fix failure to parse git tag date in `psc-publish` (@hdgarrood)
+- Add git tag time to `psc-publish` JSON (@hdgarrood)
+- Remove `Docs.Bookmarks` (@hdgarrood)
+
+**Performance**
+- Combine inlining optimizations into a single pass (@paf31)
+- Use `Map.foldlWithKey'` instead of `foldl` (@hdgarrood)
+- Minor memory usage improvements in `Language.PureScript.Docs` (@hdgarrood)
+
+**Other**
+- Generate data constructors without IIFEs (@hdgarrood)
+- Add stack-ghc-8.0.2.yaml (@noraesae)
+- Add `HasCallStack` to `internalError` (@alexbiehl)
+- Update `psc-package` to use turtle 1.3 (@taktoa)
+- Remove `JSAccessor`; replace with `JSIndexer` (@michaelficarra)
+- Store more information in `RenderedCode` (@hdgarrood)
+
+## [v0.10.5](https://github.com/purescript/purescript/releases/tag/v0.10.5) - 2017-01-06
+
+**Enhancements**
+- Adds specific error message when failing to import bind (@FrigoEU)
+
+**Bug Fixes**
+- Detect conflicting data constructor names (@LiamGoodacre)
+- Update pretty printer for Kinds (@hdgarrood)
+- Restore JSON backwards compatibility for `PSString` (@hdgarrood)
+- Replace type wildcards earlier (@paf31)
+- Restore backwards compatibility for parsing Kinds (@hdgarrood)
+
+**Other**
+- Update `bower-json` to 1.0.0.1 (@hdgarrood)
+
+## [v0.10.4](https://github.com/purescript/purescript/releases/tag/v0.10.4) - 2017-01-02
+
+**New Features**
+
+**Deriving `Functor`**
+
+(@LiamGoodacre, #2515)
+
+The `Functor` type class can now be derived using the standard `derive instance` syntax:
+
+``` purescript
+newtype F a = F { foo :: Array a, bar :: a }
+
+derive instance functorF :: Functor F
+```
+
+**User-Defined Kinds**
+
+(@LiamGoodacre, #2486)
+
+Custom kinds can now be defined using the `foreign import kind` syntax:
+
+``` purescript
+foreign import kind SymbolList
+```
+
+Custom kinds can be ascribed to types using `foreign import data` declarations, as usual:
+
+``` purescript
+foreign import data Nil :: SymbolList
+foreign import data Cons :: Symbol -> SymbolList -> SymbolList
+```
+
+Note that kind arguments are not supported.
+
+User defined kinds can be imported/exported using the `kind` prefix, for example:
+
+``` purescript
+import Type.SymbolList (kind SymbolList)
+```
+
+**Source Maps in `psc-bundle`**
+
+(@nwolverson)
+
+`psc-bundle` will now generate source maps if the`--source-maps` flag is used.
+
+**Solving `CompareSymbol` and `AppendSymbol`**
+
+(@LiamGoodacre, #2511)
+
+Support for the new `purescript-typelevel-prelude` library has been added to the compiler. `CompareSymbol` and `AppendSymbol` constraints will now be solved automatically for literal symbols.
+
+**New `psc-package` Features**
+
+(@paf31)
+
+Two new commands have been added to `psc-package` to support library authors and package set curators.
+- The `updates` command (#2510) is used to update packages in the set.
+- The `verify-set` command (#2459) is used to verify the health of a package set. This command replicates the work done by the `package-sets` CI job, and can be used to test modifications to the package set locally before making a pull request.
+
+**Enhancements**
+- Update orphan instance check to use covering sets when functional dependencies are involved (@LiamGoodacre)
+- Add `--node-path` option to PSCi to modify the path to the Node executable (#2507, @paf31)
+- Add package information to re-exports (@hdgarrood)
+- Add `Prim` docs to the library (#2498, @hdgarrood)
+
+**Bug Fixes**
+- Derive instances when data types use type synonyms (#2516, @paf31)
+- Unwrap `KindedType` when instance solving (@LiamGoodacre)
+- Update links to wiki (#2476, @LiamGoodacre)
+- Update websocket host to fix PSCi on Windows (#2483, @seungha-kim)
+- Fix `psc-ide` tests on windows (@kRITZCREEK)
+- Fix some issues with the pretty printer (#2039, @paf31)
+
+**Other**
+- More robust license generator script (@hdgarrood)
+- Further conversions to `Text` in the `Docs` modules (#2502, @hdgarrood)
+- Add upper bound on `turtle`, fixes #2472, (@hdgarrood)
+- Fix version bounds on `language-javascript` (@hdgarrood)
+
+## [v0.10.3](https://github.com/purescript/purescript/releases/tag/v0.10.3) - 2016-12-11
+
+**Enhancements**
+
+**Solving `IsSymbol` instances**
+
+(@LiamGoodacre)
+
+The compiler will now derive `Data.Symbol.IsSymbol` instances for type-level string literals.
+
+This enables interesting type-level programming features, such as [deriving `Show` instances using `Data.Generics.Rep`](https://asciinema.org/a/1lc5nn3o9b24y2bos8eowmfa9).
+
+**Rows in Instance Heads**
+
+(@LiamGoodacre)
+
+The compiler now allows rows to appear in type class instance heads, but only in type arguments which are fully determined by some functional dependency.
+
+This allows instances like
+
+``` purescript
+MonadState { field :: Type } MyAppMonad
+```
+
+and also `Newtype` instances for newtypes which contain records.
+
+**Speeds up parsing by reading files as Text**
+
+(@kRITZCREEK)
+
+The use of `String` has been replaced by `Text` in the compiler, resulting in some non-trivial performance improvements.
+
+**Functional Dependencies in `psc-docs` output**
+
+(@soupi, #2439)
+
+`psc-docs` now includes functional dependency information when rendering type classes.
+
+**New `psc-package` Commands**
+- The `available` command (@andyarvanitis) shows all available packages in the current package set
+- The `uninstall` command (@joneshf) removes a package from the set of active packages and updates the package configuration file.
+
+**Type Class Warning (@joneshf)**
+
+A warning was added for shadowed type variables in type class declarations.
+
+**Bug Fixes**
+- `psc-package`: display full path in 'packages.json does not exist' error messsage (@andyarvanitis)
+- Use `writeUTF8File` in `psc-bundle` (@hdgarrood)
+- Use HTTPS to query Pursuit (@paf31)
+- Moved the expansion of astral code points to UTF-16 surrogate pairs from the JS code generator to the parser (@michaelficarra, #2434)
+- Allow astral code points in record literal keys (@michaelficarra, #2438)
+- Add value source positions (@nwolverson)
+- Update error message of `ErrorInDataBindingGroup` to include participating identifiers (@LiamGoodacre)
+
+**`psc-ide`**
+- Polling option for psc-ide-server (@kRITZCREEK)
+- Better logging and diagnostics (@kRITZCREEK)
+
+**Other**
+- Dump output of `psc` tests to file (@andyarvanitis, #2453)
+- Fix windows CI (@hdgarrood)
+- Link to new documentation repo (@hdgarrood)
+- Create documentation for psc-package (@paf31)
+- Fix GHC 8.0.2 build (@RyanGlScott)
+- Add `psc-package` to release bundle (@marsam)
+- Update for latest `language-javascript` (@tmcgilchrist)
+- Fix exhaustivity warnings (@charleso)
+- Update `CONTRIBUTING.md` (@osa1)
+
+## [v0.10.2](https://github.com/purescript/purescript/releases/tag/v0.10.2) - 2016-11-07
+
+**Major Changes**
+
+**Type-directed search (@kRITZCREEK)**
+
+This extends the typed holes error messages to include suggested replacements for a typed hole, by using type subsumption to determine which identifiers in scope are appropriate replacements.
+
+A blog post will accompany this feature soon.
+
+**`psc-package` (@paf31)**
+
+This is an experimental package manager for PureScript packages. It supports the following commands:
+- `init` - create a new project using the package set for the current compiler version
+- `update` - sync the local package collection with the package set
+- `install` - install a specific package from the current set and add it to the package config
+- `build` - run `psc` on any active packages
+- `sources` - list source globs for active package versions
+- `dependencies` - list transitive dependencies of the current project
+
+For example:
+
+``` text
+$ psc-package init
+$ psc-package install transformers
+$ psc-package build
+```
+
+Eventually, `psc-package` might replace the use of Bower, but that will require support from tools like Pulp. For now, package authors should continue to publish packages using Bower and Pursuit.
+
+**`Data.Generic.Rep.Generic` Deriving (@paf31)**
+
+This is an alternative generic programming implementation based on `GHC.Generics`. It should allow deriving of more interesting classes, such as `Semigroup`. See the `purescript-generics-rep` package for examples.
+
+**Enhancements**
+- #2323: Sort IDE-generated explicit imports (@bbqbaron)
+- #2374: Add error message for ambiguous type variables in inferred contexts (@bbqbaron)
+- #934 Add paste mode, remove --multi-line option (@paf31)
+- Allow symbols in data constructors (@brandonhamilton)
+- Fix inliner for integer bitwise operators (@brandonhamilton)
+- Use SSL for pursuit queries (@guido4000)
+
+**Bug Fixes**
+- #2370, allow rows in instance contexts (@paf31)
+- #2379, add error message for unknown classes (@paf31)
+- Better error messages for bad indentation (@paf31)
+- Fix inliner for `Data.Array.unsafeIndex` (@brandonhamilton)
+- Fix issue with typed holes in inference mode (@paf31)
+- Fix scope traversal for do-notation bind. (@LiamGoodacre)
+- Handle `TypeLevelString` when checking orphans (@joneshf)
+- Move unsafeIndex to Data.Array (@brandonhamilton)
+- Pretty-print suggested types differently (@paf31)
+- Traversal should pick up bindings in all value declarations. (@LiamGoodacre)
+- Treat type annotations on top-level expressions as if they were type declarations (@paf31)
+
+**Other**
+- Refactor subsumes function (@paf31)
+- Refactor to use `lens` (@kRITZCREEK)
+- Small cleanup to `Language.PureScript.Interactive.IO` (@phiggins)
+- Speeds up parsing by reading files as `Text` (@kRITZCREEK)
+- Update outdated comments about Prim types (@rightfold)
+
+## [v0.10.1](https://github.com/purescript/purescript/releases/tag/v0.10.1) - 2016-10-02
+
+**Breaking Changes**
+
+The new functional dependencies feature fixes type inference in some cases involving multi-parameter type classes. However, due to a bug in the compiler, some of those expressions were previously type checking where they should not have. As a result, it is necessary to add functional dependencies to some classes in order to make previous code type-check in some cases. Known examples are:
+- `MonadEff` and `MonadAff`
+- `MonadState`, `MonadReader`, and the rest of the MTL-style classes in `transformers`
+
+**New Features**
+
+**`Data.Newtype` Deriving**
+
+(@garyb)
+
+It is now possible to derive the `Newtype` class for any data declaration which is a `newtype`, using the existing `deriving instance` syntax:
+
+``` purescript
+newtype Test = Test String
+
+derive instance newtypeTest :: Newtype Test _
+```
+
+Note that the second type argument should be specified as a wildcard, and will be inferred.
+
+**Added type level string functions**
+
+(@FrigoEU)
+
+The `Prim` module now defines the `TypeString` and `TypeConcat` type constructors, which can be used to build more descriptive error messages which can depend on types, using the `Fail` constraint:
+
+``` purescript
+instance cannotShowFunctions
+ :: Fail ("Function type " <> TypeString (a -> b) <> " cannot be shown.")
+ => Show (a -> b) where
+ show _ = "unreachable"
+
+infixl 6 type TypeConcat as <>
+```
+
+**`--dump-corefn`**
+
+(@rightfold)
+
+The compiler now supports the `--dump-corefn` option, which causes the functional core to be dumped in `output/**/corefn.json`. This should be useful for implementing new backends which interpret the functional core.
+
+**Newtype Deriving**
+
+(@paf31)
+
+It is now possible to derive type class instances for `newtype`s, by reusing the instance for the underlying type:
+
+``` purescript
+newtype X = X String
+
+derive newtype instance showX :: Show X
+```
+
+Note that it is possible to derive instances for multi-parameter type classes, but the newtype must only appear as the last type argument.
+
+**Allow anonymous accessor chains (`_.a.b`)**
+
+(@rvion)
+
+Anonymous record accessor syntax has been extended to work with chains of one or more accessors:
+
+``` purescript
+getBaz = _.foo.bar.baz
+```
+
+**Functional Dependencies (@paf31)**
+
+The type class solver now supports functional dependencies. A multi-parameter type class can define dependencies between its type arguments by using the `->` operator:
+
+``` purescript
+class Stream el s | s -> el where
+ cons :: el -> (Unit -> s) -> s
+ uncons :: s -> { head :: el, tail :: s }
+```
+
+Here, the `s` and `el` type arguments are related by a single functional dependency, which ensures that there is at most one instance for any given type `s`. Alternatively, the type `s` _determines_ the type `el`, i.e. there is an implicit function from types `s` to types `el`. This information can be used by the solver to infer types where it was previously not possible.
+
+See the following examples for more information:
+- [Streams](https://github.com/purescript/purescript/blob/f5aa07606b2ed87343bb80244c5490cb157def0a/examples/passing/Stream.purs)
+- [GHC-style generics](https://github.com/purescript/purescript/blob/f5aa07606b2ed87343bb80244c5490cb157def0a/examples/passing/GHCGenerics.purs)
+- [Type-level arithmetic](https://github.com/purescript/purescript/blob/f5aa07606b2ed87343bb80244c5490cb157def0a/examples/passing/FunWithFunDeps.purs)
+- [Heterogeneous Lists](https://gist.github.com/paf31/ded46a2fb2419f4610582a02a0690bec)
+
+**Enhancements**
+- Return qualifier from explicit/hiding imports (@nwolverson)
+- Verify entry points exist in `psc-bundle` (@kRITZCREEK)
+- Improved error messages for record subsumption (@FrigoEU)
+
+**psc-ide**
+- Resolve types/kinds for operators (@kRITZCREEK)
+- Unify Completion Commands (@kRITZCREEK)
+- Parse type annotations from source files (@kRITZCREEK)
+- Update pursuit JSON parsing (@nwolverson)
+- Remove a pursuit workaround (@kRITZCREEK)
+- Add a suggestion to the `UnusedDctorImport` warning (@FrigoEU)
+- Return JSON errors for cycles in module dependencies (@kRITZCREEK)
+
+**Bug Fixes**
+- Fix usage detection for operators (@garyb)
+- Fix handling of duplicate module imports in JS codegen (@garyb)
+- Fix a small bug in the type pretty-printer (@paf31)
+- Fix function application judgment (@paf31)
+- Fix inlining for `$` and `#` operators (@garyb)
+- Fix `everywhereOnTypesTopDown` (@ianbollinger)
+- Fix unification of string literals (@paf31)
+
+**Infrastructure**
+- Support `aeson-1.0` (@phadej)
+- Support `http-client-0.5` (@phadej)
+- Safer installation from source in INSTALL.md (@hdgarrood)
+
+**Implementation**
+- Fix most HLint warnings (@ianbollinger)
+- Fixing imports (@charleso)
+- Export `desugarDecl` from `Sugar.ObjectWildcards` (@rvion)
+- Remove legacy `ObjectGetter` and update doc (@rvion)
+
+## [v0.9.3](https://github.com/purescript/purescript/releases/tag/v0.9.3) - 2016-08-01
+
+**Enhancements**
+- Better context information for typed hole errors (@paf31)
+- Improved error messages in the constraint solver. Type class errors now include better contextual information, including smaller source spans. (@paf31)
+
+**Bug Fixes**
+- Decode externs with correct encoding (@natefaubion)
+- Fix bad codegen for empty string fields (@LiamGoodacre, #2244)
+- Instantiate types in array literals before unification (@paf31, #2252)
+
+**Other**
+- Upgrade to protolude 0.1.6 (@ilovezfs)
+- Use latest LTS (@paf31, #2241)
+- Add upper bound to http-client (@paf31, #2237)
+- Combine the sdist and coverage builds. Avoid .tix files during deployment. (@paf31)
+
+## [v0.9.2](https://github.com/purescript/purescript/releases/tag/v0.9.2) - 2016-07-11
+
+**Enhancements**
+
+**Goto Definition**
+
+@kRITZCREEK has added the ability to return position information for expressions in `psc-ide`. This can be used to implement a Goto Definition feature in IDEs which use `psc-ide-server` as the backend.
+
+**Evaluate PSCi expressions in the browser**
+
+(@paf31)
+
+PSCi now features an alternative backend, which can run commands in the browser via a websocket. To use this mode, simply pass the `--port` option on the command line:
+
+```
+$ pulp psci --port 9000
+```
+
+and open your web browser to `localhost` on that port.
+
+See https://github.com/paf31/psci-experiment for a demonstration.
+
+**`psc-ide` architecture changes**
+
+@kRITZCREEK has worked on changing the architecture of `psc-ide` generally, to load data in multiple phases and asynchronously. This enables new features like Goto Definition above.
+
+**Other**
+- Allow `pipes` version 4.2 (@felixonmars)
+- Elaborate re-exports (@garyb)
+
+**Bug Fixes**
+
+**`psc-ide`**
+- Fix unicode encoding of json responses (@kRITZCREEK)
+- Improved handling of reexports (@kRITZCREEK)
+
+**Other**
+- Update Data.Function constant for prelude 1.0 (@felixSchl)
+- Include position info in ScopeShadowing warning (@garyb)
+
+## [v0.9.1](https://github.com/purescript/purescript/releases/tag/v0.9.1) - 2016-06-01
+
+PureScript 0.9.1 is a major stable release of the compiler. It removes features which were deprecated in the 0.8.x series, and contains several useful enhancements and bug fixes.
+
+This release will be accompanied by new releases of the core libraries and a compatible version of Pulp, which have been updated to work with this version.
+
+Due to the relatively large number of breaking changes, library authors are advised that they will probably need to update their libraries to maintain compatibility. Users may prefer to continue using version 0.8.5 until their dependencies have been updated.
+
+**Breaking Changes**
+
+**Name resolving**
+
+(@garyb)
+
+The way names are resolved has now been updated in a way that may result in some breakages. The short version is: now only names that have been imported into a module can be referenced, and you can only reference things exactly as you imported them.
+
+Some examples:
+
+| Import statement | Exposed members |
+| -------------------------- | --------------- |
+| `import X` | `A`, `f` |
+| `import X as Y` | `Y.A` `Y.f` |
+| `import X (A)` | `A` |
+| `import X (A) as Y` | `Y.A` |
+| `import X hiding (f)` | `A` |
+| `import Y hiding (f) as Y` | `Y.A` |
+
+Qualified references like `Control.Monad.Eff.Console.log` will no longer resolve unless there is a corresponding `import Control.Monad.Eff.Console as Control.Monad.Eff.Console`. Importing a module unqualified does not allow you to reference it with qualification, so `import X` does not allow references to `X.A` unless there is also an `import X as X`.
+
+Although the new scheme is stricter it should be easier to understand exactly what the effect of any given import statement is. The old resolution rules for qualified names were obscure and unexpected results could arise when locally-qualified module names overlapped with "actual" module names.
+
+Module re-exports have also been tightened up as a result of these rules. Now if module `X` is only imported `as Y`, the re-export must list `module Y` also. If a module is imported without being re-qualified then the original name is used.
+
+**Partial Constraints**
+
+(@garyb, @paf31)
+
+The compiler will now generate an error for a missing `Partial` constraints, where it would previously have issued a warning.
+
+**Module Restrictions**
+
+(@garyb, @paf31)
+- Imports must now appear before other declarations in a module.
+- A source file must now contain exactly one module.
+
+These restrictions will allow us to improve incremental build times in future, since we will only need to parse a small prefix of each file in order to figure out what needs to be rebuilt. Right now, we need to parse every file fully.
+
+**Foreign Function Interface Changes**
+
+(@paf31)
+
+Foreign modules are now found by filename rather than by searching for a custom JavaScript comment. The foreign module is found by changing the extension of the corresponding PureScript module from `.purs` to `.js`.
+
+This change was made to be more consistent with `psc-ide`, and also to adopt a simple convention which will port well to other backends.
+
+**Operator Aliases**
+
+(@garyb)
+
+All operators must be defined as aliases from now on. That is, it is no longer valid to define an operator as a name in local scope (e.g. `let (#) x y = x y in ...`). This change makes it possible to generate better JavaScript code for operators, by desugaring them to the functions they alias.
+
+**Other**
+- Deprecated class import/export syntax has been removed (@LiamGoodacre). Classes are now imported using the `class` keyword, and exported similarly:
+
+ ``` purescript
+ import Prelude (class Show, show)
+ ```
+- Remove support for `=` in record binders (@paf31).
+
+ Record binders such as
+
+ ``` purescript
+ f { x = 0 } = true
+ ```
+
+ are no longer supported. Record binders must now use `:` instead:
+
+ ``` purescript
+ f { x: 0 } = true
+ ```
+- `Prim.Object` has been renamed to `Prim.Record` (#1768, @paf31)
+
+**Enhancements**
+
+**Programmable Type Errors**
+
+(@paf31)
+
+Constraints can now contain type-level strings which can be used as custom error messages using the `Fail` constraint. For example, one can now document the fact that foreign types such as `JSDate` cannot be made instances of `Generic`:
+
+``` purescript
+instance dateIsNotGeneric
+ :: Fail "JSDate is not Generic. Consider using Int with toEpochMilliseconds instead."
+ => Generic JSDate where
+ fromSpine = crashWith "fromSpine: unreachable"
+ toSpine = crashWith "toSpine: unreachable"
+ toSignature = crashWith "toSignature: unreachable"
+```
+
+Attempting to derive a `Generic` instance for a type containing `JSDate` will then result in
+
+``` text
+A custom type error occurred while solving type class constraints:
+
+ JSDate is not Generic. Consider using Int with toEpochMilliseconds instead.
+```
+
+**Typed Hole Improvements**
+
+(#2070, @paf31)
+
+Typed hole error messages now include the types of any names in scope, to assist with type-driven development:
+
+``` text
+> :t \x -> maybe 0 ?f x
+Error found:
+in module $PSCI
+at line 1, column 8 - line 1, column 22
+
+ Hole 'f' has the inferred type
+
+ t0 -> Int
+
+ in the following context:
+
+ it :: Maybe t0 -> Int
+ x :: Maybe t0
+
+
+in value declaration it
+
+where t0 is an unknown type
+```
+
+**Editor Support**
+- The results of the last rebuild are now cached by `psc-ide`, which improves completion support for editor plugins. (@kRITZCREEK)
+- A `reset` command was added to `psc-ide` (@kRITZCREEK)
+- The compiler will now suggest replacements to address `MissingTypeDeclaration` and `TypeWildCard` warnings (@nwolverson)
+
+**PSCi Improvements**
+
+(@paf31)
+- The design of PSCi has been changed to improve performance. PSCi now precompiles all dependencies and uses the same incremental rebuilding approach as `psc-ide`. This means that the `:load` and `:foreign` commands have been removed, since dependencies are fixed and pre-compiled when PSCi loads.
+- PSCi now supports alternative base libraries such as Neon, by depending on `purescript-psci-support` for its supporting code.
+
+**Colors in Error Messages**
+
+Types and values will now be highlighted in error messages, when the terminal supports it (MacOS and Linux for now) (@soupi).
+
+**Type Names**
+
+Prime characters are now allowed in type names. (@garyb)
+
+**Bug Fixes**
+- Parser error messages inside type class and instance declarations were improved (#2128, @bmjames)
+- Editor suggestions for imports now use `(..)` (@garyb)
+- Source-spans to token end position (@nwolverson)
+- Some pretty printing issues related to string literals in records were fixed (@LiamGoodacre)
+- Some presentation bugs in PSCi's `:show import` were fixed (@LiamGoodacre)
+- Parsec was updated to the latest version to fix an issue with literal parsing (#2115, @hdgarrood)
+- Fixed a bug related to certain typed binders which would cause the compiler to crash (#2055, @paf31)
+- As-patterns now bind less tightly (@paf31)
+- More identifiers can now be parsed in FFI imports (@michaelficarra)
+- Fixed a performance issue which manifested under certain conditions in `psc-ide` (#2064, @kika)
+- Fixed a test which contained an unreliable comparison (#2093, @andyarvanitis)
+- The precedence of type application was corrected (#2092, @paf31)
+- An indentation bug in the parser was fixed (@DavidLindbom)
+- License errors from `psc-publish` were improved (@hdgarrood)
+
+**Other**
+- The test suite now exercises various compiler warnings (@garyb)
+- The test suite performance was improved by using incremental rebuilds (@paf31)
+- The test suite now tests that passing tests contain a `main` function (@hdgarrood)
+- The test suite now supports tests which use multiple files (@garyb)
+- Portability of the core library test suite was improved (@bmjames)
+- Performance of import elaboration was improved (@garyb)
+- We now use Stack for our CI builds and release builds (#1974, @hdgarrood)
+- We now use `NoImplicitPrelude` and enable some global extensions (@garyb)
+- Type-safety in the source-level AST was improved (@garyb)
+- Use HSpec for the compiler tests (@garyb)
+- New Prelude names in 0.9 (@garyb)
+
+## [v0.9.0](https://github.com/purescript/purescript/releases/tag/v0.9.0) - 2016-05-22
+
+**This is pre-release software**
+
+This release is provided so that library developers can test the new compiler features.
+
+## [v0.8.5](https://github.com/purescript/purescript/releases/tag/v0.8.5) - 2016-04-21
+
+**New Features**
+- Fast recompilation for single files in `psc-ide-server` #1712 (@kRITZCREEK, @paf31)
+
+ The [`pscid`](https://github.com/kRITZCREEK/pscid) project makes use of this to watch files as you work and raise errors and warnings when they occur with near instant feedback.
+- Operator aliases can now be declared for types #416 (@garyb)
+
+ ``` purescript
+ infixr 6 type Natural as ~>
+ ```
+- Underscore wildcards can now be used in `case` and `if` expressions #1558 (@garyb)
+
+ ``` purescript
+ case _ of
+ Something -> ...
+ ```
+
+ ``` purescript
+ -- underscores can optionally be used in any part of an `if` expression
+ cond = if _ then _ else _
+ picker = if _ then "x" else "y"
+ ```
+- Typed holes #1283 (@garyb)
+
+ ``` purescript
+ example :: forall a. Maybe a -> Unit
+ example ma = ?umm
+ ```
+
+ ```
+ Hole 'umm' has the inferred type
+
+ Unit
+
+ in value declaration example
+ ```
+
+ You can use any identifier name after the question mark and that will be used to label the hole in the raised error message.
+
+**Breaking changes**
+- Type annotations may need parentheses in some situations that they previously did not due to the introduction of type operators. For example, `x :: a == y` will be now parsed as `x :: (a == y)` instead of `(x :: a) == y`.
+
+**Enhancements**
+- Improved error messages for invalid FFI identifiers #2011 (@hdgarrood)
+- `psc-publish` now allows publishing of packages with a valid SPDX license field in `bower.json` #1985 (@hdgarrood)
+- Haddock markdown fix #2001 (@trofi)
+- `psc-ide` now creates the `output` folder on startup if it is missing #2030 (@kRITZCREEK)
+
+**Bug Fixes**
+- Fixed an issue with incorrect suggestions when re-exporting modules #1862 (@garyb)
+- Fixed an issue with invalid redundant import warnings #1823 (@garyb)
+- Fixed an issue where `DuplicateSelectiveImport` would not fire when it should #2004 (@garyb)
+- Fixed the error that occurs when an invalid newtype is created that belongs to a data binding group #1895 (@garyb)
+- Fixed a case where re-exports included unintended exports #1872 (@garyb)
+- Operator aliases can now be declared for qualified data constructors #2015 (@LiamGoodacre)
+- A single `hiding` import will no longer raise an "unspecified imports" error #2017 (@garyb)
+- Fixed a case where cycles in modules were being detected when they do not occur #2018 (@garyb)
+- Various cases where files were not being read as UTF-8 on Windows were fixed #2027, #2031 (@garyb, @kRITZCREEK)
+- Fixed some issues in pretty printing of records #2043 (@LiamGoodacre)
+- `psci` now shows qualified imports correctly #2040 (@LiamGoodacre)
+- Parser errors are now returned as JSON during IDE rebuild #2042 (@paf31)
+
+## [v0.8.4](https://github.com/purescript/purescript/releases/tag/v0.8.4) - 2016-04-06
+
+This is an interim bug fix release before 0.9.0.
+
+**Enhancements**
+- Check that FFI imports match with implementations (@hdgarrood)
+
+ This is technically a breaking change, since some existing code might fail to compile if it has missing FFI code (`purescript-dom` is an example), but these libraries should be fixed soon.
+- Import helper commands in psc-ide (@kRITZCREEK)
+
+**Bug Fixes**
+- Disallow constraint generalization for recursive functions. (#1978, @paf31)
+- Fix #1991, instantiate polymorphic types before unification (@paf31)
+- Use UTF8 when writing to stdout and stderr (@garyb)
+- Fix for rendered constrained types needing parens. (@LiamGoodacre)
+- everythingWithScope improperly traversing binary ops (@LiamGoodacre)
+
+**Other**
+- Update to use language-javascript 0.6.x (@nwolverson)
+
+## [v0.8.3](https://github.com/purescript/purescript/releases/tag/v0.8.3) - 2016-03-26
+
+**Breaking Changes**
+- We have dropped support for GHC 7.8 and older (@hdgarrood)
+
+**Enhancements**
+- Infer types with class constraints (@paf31)
+
+ For example, this simple code would previously have failed with a confusing `NoInstanceFound` error:
+
+ ``` purescript
+ add x y = x + y
+ ```
+
+ The compiler will now infer the most general type, namely `forall a. (Semiring a) => a -> a -> a`.
+
+ Note that constraints can only be inferred if they only mention type variables; inference of arbitrary types in constraints is not (yet) supported. So, for example, you would still have to write a type signature for a function which had a constraint such as `(MonadEff (console :: CONSOLE | eff) m)`.
+- Default require path to `../` (@nwolverson)
+
+ The previous default behavior was no require path prefix, which was confusing for some workflows. The new default is `../`, which is the prefix used in `purs-loader`. This option will be removed completely in 0.9.
+- Expose hiding import suggestion in JSON (@nwolverson)
+- Error on missing `LICENSE` file or missing license field in `bower.json` (@faineance)
+
+**Bug Fixes**
+- Fix #1916 (@bagl)
+- Fix detection of single open import (@garyb)
+- Fix `true` not being treated as an infallible guard (@garyb)
+- Fix pretty printer spinning (@garyb)
+- Fix Windows build script (@garyb)
+- Fix #1889, improve performance by avoiding whitespace operations on large strings (@paf31)
+
+**psc-ide**
+- Fix a crash related to error messages in the case splitting command (@kRITZCREEK)
+- Escape regex characters when using the flex matcher (@kRITZCREEK)
+- Adds `--help` commands to the `psc-ide` executables (@kRITZCREEK)
+- Catches EOF exceptions thrown in `acceptCommand` (@kRITZCREEK)
+
+**Other**
+- Switched to Trusty distribution for Travis (@garyb)
+- @kRITZCREEK and @faineance worked on refactoring the compiler.
+- The `optparse-applicative` dependency was updated to `>= 0.12.1` (@stevejb71)
+- The `bower-json` dependency was bumped (@hdgarrood)
+- Better error message for `psc-publish` tests (@kRITZCREEK)
+- Use generic Literal in the AST (@garyb)
+
+## [v0.8.2](https://github.com/purescript/purescript/releases/tag/v0.8.2) - 2016-02-29
+
+**Breaking Changes**
+
+_None_
+
+**Enhancements**
+- `psc-ide` is now distributed with the compiler! (@kRITZCREEK)
+
+ The `psc-ide-server` and `psc-ide-client` executables are now maintained and
+ distributed alongside the compiler. This will ensure that the externs file
+ format used by `psc-ide-server` is kept in sync with changes in the compiler.
+- Source maps (@nwolverson)
+
+ Source maps can be generated using the `--source-maps` flag. See the
+ [example repository](https://github.com/nwolverson/purescript-sourcemap-test) for a full demonstration of source maps using Webpack.
+- Operator aliases for data constructors (@garyb)
+
+ Aliases can now be defined for data constructors. For example:
+
+ ``` purescript
+ data List a = Nil | Cons a (List a)
+
+ infixr 6 Cons as :
+ ```
+
+ Here, the `:` operator can be used as a function to replace the `Cons` constructor,
+ _and also in binders_.
+- `Eq` and `Ord` deriving (@paf31)
+
+ `Eq` and `Ord` instances can now be derived, using the `derive instance` syntax:
+
+ ``` purescript
+ derive instance eqList :: (Eq a) => Eq (List a)
+ derive instance ordList :: (Ord a) => Ord (List a)
+ ```
+- Types are now inferred in `psc-docs` and `psc-publish` (@hdgarrood)
+
+ If type annotations are missing in source files, they will be inferred by
+ `psc-docs` and `psc-publish` before documentation generation.
+- Initial version of new syntax for operator sections (#1846, @paf31)
+
+ Operator sections can now be written using underscores. For example:
+
+ ``` purescript
+ decrementAll :: Array Int -> Array Int
+ decrementAll = map (_ - 1)
+ ```
+
+ which is equivalent to:
+
+ ``` purescript
+ decrementAll :: Array Int -> Array Int
+ decrementAll = map (\x -> x - 1)
+ ```
+
+**Bug Fixes**
+- Allow one open import without warning (@garyb)
+
+ Warnings for open imports were a pain point for some users after the 0.8 release.
+ This change allows a single open import without a warning. This is still safe
+ in the presence of dependency updates, and does not lead to ambiguity for editor
+ plugins searching for declaration sites.
+
+**Other**
+- @phadej has updated the Stack build to use the latest LTS and nightly builds.
+- @izgzhen has refactored the PSCi code to be more readable.
+- @hdgarrood has refactored the test suite.
+
+## [v0.8.1](https://github.com/purescript/purescript/releases/tag/v0.8.1) - 2016-02-29
+
+You are recommended to use v0.8.2 instead.
+
+## [v0.8.0](https://github.com/purescript/purescript/releases/tag/v0.8.0) - 2016-01-31
+
+A massive thanks to everyone involved in this release!
+
+**Breaking Changes**
+
+_None_, but there are lots of new warnings related to upcoming breaking changes in 0.9:
+- Operators as aliases will become mandatory, and regular operators (as functions) will now generate warnings.
+- Non-exhaustive functions will get a `Partial` constraint in 0.9, so the exhaustivity checker will now attempt to generate warnings by looking for `Partial` constraints in scope.
+- The `qualified` import syntax has been deprecated.
+- Class imports will use the new `class` syntax in 0.9 and the alternative syntax is deprecated.
+
+**Enhancements**
+- Add native `Partial` constraint (@garyb)
+- Reduce backtracking in parser to hopefully improve quality of parsing error messages (@paf31)
+- Drop requirement to parenthesize single constraints in instance contexts (@garyb)
+- Case expressions can now match multiple values (@natefaubion)
+- Add operator aliases (@garyb)
+- Show identifiers correctly in ctags (@nwolverson)
+- Fix #1523, add `--json-errors` flag for editor integrations (@paf31)
+- Error and warning corrections are now available to editors via `--json-errors` (@nwolverson)
+- Check integer values are within range in codegen (@garyb)
+- Support for unicode operators (@paf31)
+- The parser now supports unicode symbols for `forall` and function arrows (@DavidLindbom)
+- Module Imports
+ - Use `class` keyword for class references in imports (@garyb)
+ - Type imports no longer require `()` (@garyb)
+ - Allow import hiding with qualified imports (@garyb)
+ - Naming conflicts are now resolved at the use site (@garyb)
+- Error Messages
+ - Fix #1662, display extra type info in instance errors (@paf31)
+ - Add information about skolem constants to type errors (@paf31)
+ - Sort rows in unification errors (@paf31)
+- Warnings
+ - Warn on unspecified imports (@garyb)
+ - Warn when import X hiding (..) imports nothing (@garyb)
+ - Warn on duplicate imports and exports (@garyb)
+ - Warn about unused class imports (@garyb)
+
+**Bug Fixes**
+- Renamer updates, fixes naming bug in some unlikely situations (@garyb)
+- Fix #1645, implement new indentation rules for types to avoid very wide errors (@paf31)
+- Fix "resource exhausted" issue on MacOS (@mgmeier)
+- Fix #1664, check kind before expanding wildcards. (@paf31)
+- Fix up shadowed module names in JS codegen (@garyb)
+- Fix #1185, fix #1369, add everythingWithScope traversal to correct some scoping issues. (@paf31)
+- Fix two cases where errors were missing context (@garyb)
+- Fix #1636, instantiate polytypes fully, even under constraints. (@paf31)
+- Fix missing data constructors in re-exports (@garyb)
+- Fix codegen error with instance for re-exported class (@garyb)
+- Fix #1479, encode .js files as UTF8. (@paf31)
+- Fix a bug related to redundancy checking in cases (#1853, @nicodelpiano)
+- Fix a TCO/composition inlining bug (@garyb, @hdgarrood)
+- Fix renaming for nested constructor binders (#1839, @sharkdp)
+- Fix generic deriving bug with >1 type argument (@hdgarrood)
+- Fix generate fresh binder names unless all names in case are equal (#1825, @paf31)
+- Fix external require expressions when minifying (#1794, @paf31)
+- Rename `foreign` argument to fix compiling issue (@anttih)
+- Allow use of bottom integer (@garyb)
+
+**Other**
+- Fix #1700, remove warnings for syntactic features removed in 0.7.0 (@paf31)
+- Fix psc-publish test (@passy)
+- Relax rules for docs comments (#1820, @hdgarrood)
+- Qualified name lookup is now supported in PSCi (#974, @soupi)
+- https://github.com and git@github.com URLs are now allowed by psc-publish (@passy, @codedmart)
+- Docs are now generated for module re-exports (@hdgarrood)
+- Use friendly module name in psc-docs error (@nwolverson)
+- Distinguish between the different ProperNames (@garyb)
+- Warn about unspecified constructors in type imports (@garyb)
+- Fix warning about values missing from virtual modules (@garyb)
+
+## [v0.7.6.1](https://github.com/purescript/purescript/releases/tag/v0.7.6.1) - 2015-11-18
+
+Fixes a bug in generic deriving.
+
+See the [release notes for 0.7.6](https://github.com/purescript/purescript/releases/tag/v0.7.6).
+
+## [v0.7.6](https://github.com/purescript/purescript/releases/tag/v0.7.6) - 2015-11-18
+
+Thanks once again to everyone involved in this release!
+
+This release includes some updates to generic deriving which require updating to the latest version of `purescript-generics`.
+
+**Features**
+- Field puns, fix #921 (@balajirrao)
+
+ It is now possble to construct objects by using values in scope with the same name as the field labels. For example, the expression `{ foo, bar }` is equivalent to `{ foo: foo, bar: bar }`. Patterns desugar in the same way.
+
+**Enhancements**
+- Modules are now parsed in parallel (@paf31)
+- Use `Types.Proxy.Proxy` instead of `Data.Generic.Proxy`. This fixes #1573 (@tfausak)
+- Update generic deriving for latest `purescript-generics` changes (@paf31)
+- New import warnings - unused data constructors, unused imports (@nwolverson)
+- `psc-publish`: only warn on dirty working tree on dry runs (@hdgarrood)
+- Add more information to psci :browse command (@soupi)
+- Add support for --require-path option to psc-bundle (@natefaubion)
+- Improved error reporting in psc-publish (@hdgarrood)
+- Reduce noise in instance declarations in documentation (@hdgarrood)
+
+**Bug Fixes**
+- New approach to unification, fixing some loops in the type checker (@paf31)
+- Fix #1632, instantiate type variables in anyProxy calls in generic instances (@paf31)
+- Fix warnings for unqualified implicit imports (@nwolverson)
+- Fix #1596, don't show type checker warnings in the event of an error (@paf31)
+- Fix #1602, improvements around code generation of string literals (@michaelficarra)
+- Fix #1090, allow accessors in operator sections (@paf31)
+- Fix #1590, limit depth of pretty-printed expressions (@paf31)
+- Fix #1591, use the 'negate' in scope (@paf31)
+- Fix #1335, track scoped type variables when skolemizing (@paf31)
+- Fix #1175, check types inside where clauses inside instances (@paf31)
+- Some refactoring (@phadej)
+- Fixed some error messages (@zudov)
+
+**Deployment**
+- Use `base-compat` to reduce the need for `CPP` (@phadej)
+- Write license-generator in Haskell (@phadej)
+- Add GHC 7.10.3 to CI build matrix (@phadej)
+
+## [v0.7.5.3](https://github.com/purescript/purescript/releases/tag/v0.7.5.3) - 2015-10-29
+
+**Bug Fixes**
+- #1072, #1130, #1578, #1577, #1582
+
+## [v0.7.5.2](https://github.com/purescript/purescript/releases/tag/v0.7.5.2) - 2015-10-27
+
+Fixes a build issue with GHC versions < 7.10. Functionally equivalent to v0.7.5.1.
+
+## [v0.7.5.1](https://github.com/purescript/purescript/releases/tag/v0.7.5.1) - 2015-10-27
+
+**Bug Fixes**
+- Fix #1169, #1315, #1534, #1543, #1548, #1551, #1557, #1570
+- Fix memory leak caused by WriterT (#1297) by @paf31
+- Display hints after main error (#1563) by @paf31
+- Friendlier errors by @paf31
+- Documentation fixes by @nwolverson
+- Haddock fixes by @trofi
+
+## [v0.7.5](https://github.com/purescript/purescript/releases/tag/v0.7.5) - 2015-10-20
+
+A big thank you to everyone who was involved in this release, from filing issues, through fixing bugs to testing patches.
+
+The main focus areas for this release, as part of the 0.8 milestone, were error messages and performance.
+
+**Breaking Changes**
+
+_None!_
+
+**Enhancements**
+- Pretty printing of types and expressions in errors was improved (@paf31)
+- Externs files are now saved as JSON (@paf31)
+- Support for parallel builds has been added (@paf31)
+ Builds will now use multiple cores by default, but the number of capabilities can be modified by passing the `-N` option to the GHC runtime:
+
+ ``` text
+ psc +RTS -N8
+ ```
+- Binders can now be given type annotations (@5outh)
+
+ For example:
+
+ ``` purescript
+ example = do
+ n :: Int <- get
+ put (n + 1)
+ ```
+
+ This can be useful when disambiguating types.
+- There is a new warning for missing type signatures on top-level declarations (@paf31)
+- There are new warnings for shadowed and unused type variables (@garyb)
+- Contextual information in warnings was improved (@garyb)
+- The `qualified` keyword is now optional when importing modules qualified (@michaelficarra)
+- @zudov changed the behavior of PSCi on CTRL+C/D to match GHCi and other REPLs.
+- A bug in row unification was fixed (#1310, @paf31)
+- Constrained types can now be defined without a `forall` keyword. This is useful in some nullary type class and rank-N scenarios. (@paf31)
+
+**Bug Fixes**
+- @garyb added some additional checks for transitive module exports.
+- Type synonyms are now expanded more eagerly to avoid some error cases in the type checker (@paf31)
+- Better support for multi-byte UTF-8 characters (@senju)
+- A check has been added to the exhaustivity checker to avoid exponential blowup (@paf31)
+- Empty case statements are no longer syntactically valid (@zudov)
+
+**Other**
+- @aspidites fixed all compiler warnings in the core libraries.
+- @zudov and @phadej have made improvements to the Stack distribution of the compiler, and the Stackage builds.
+- @garyb has added a warning for operators in type classes, since they will be disallowed before 0.8.
+
+## [v0.7.4.1](https://github.com/purescript/purescript/releases/tag/v0.7.4.1) - 2015-08-26
+
+This patch release fixes two bugs related to the new instance resolution algorithm and overlapping instances:
+- `psci` would not work due to overlaps in the `PSCI.Support` module
+- `free` would not build due to its dependency on `inject`
+
+The solution for now is to make overlapping instances into a _warning_ (instead of an error) at the site of their use.
+
+Later we might revisit this decision and allow the user to express classes like `Inject` which are necessarily overlapping.
+
+## [v0.7.4.0](https://github.com/purescript/purescript/releases/tag/v0.7.4.0) - 2015-08-25
+
+**Breaking Changes**
+- The type class instance search algorithm has changed. The search will now eagerly match an instance for each subgoal based on the instance head, or fail. This makes certain instances in previous versions of `purescript-transformers` invalid, so users of this release should upgrade to the latest `transformers`.
+- A module must be imported to be re-exported.
+
+**Enhancements**
+- `RedefinedModule` errors now include position info #1024 (@garyb)
+- Multiple imports of the same module are now resolved correctly, allowing for combinations of qualified and unqualified importing #817 #1112 (@garyb)
+- Errors for unresolvable imports and exports have been clarified #1232 (@garyb)
+- A warning is emitted when importing `Type(..)` when `Type` is a synonym or has no constructors. #1391 (@garyb)
+- Superclass constraints can now be relied upon when resolving instances #421 (@paf31)
+- A serious performance regression was partially addressed, memory usage should now be drastically reduced #1297 (@garyb)
+- Module re-export handling has been much improved. If a module is partially imported, only the specifically imported members are re-exported. Qualified modules can also be re-exported. #291 #1244 (@garyb)
+- Parser error messages are now formatted in a manner more consistent with other errors #1098 (@epost)
+- Using `-ffi` to specify JavaScript FFI files is now optional, files with a `.js` extension will be detected as FFI files automatically when encountered. #1268 (@mjgpy3)
+
+**Bug fixes**
+- Fixed an error when attempting to derive for `Void` #1380 (@nicodelpiano)
+- `"The impossible happened in desugarDo"` should no longer occur #386 (@paf31)
+
+**Other**
+
+@zudov, @phadej and @erdeszt made more updates and improvements to the CI build.
+
+## [v0.7.3](https://github.com/purescript/purescript/releases/tag/v0.7.3) - 2015-08-13
+
+**Major Features**
+- @gbaz has implemented **generic deriving**. This allows instances for the `Generic` class in the `purescript-generics` package to be derived by the compiler.
+
+ A `Generic` instance can be derived as follows:
+
+ ``` purescript
+ data Example = Foo String | Bar Int | Baz Boolean
+
+ derive instance genericExample :: Generic Example
+ ```
+
+ `purescript-generics` provides examples of usage, such as `gShow`, `gEq` and `gCompare`, for printing, equality tests and comparison respectively.
+
+ See #1138.
+- @garyb has implemented a test for **orphan instances** which will now cause the build to fail with an error. See #1247
+
+**Enhancements**
+- @mjgpy3 has added a warning when an input glob does not match any files.
+
+**Bug Fixes**
+- The `psc: <>` has been fixed. This was due to a bug in the error pretty printer. (@paf31)
+- An issue with unicode characters in string literals was fixed by @michaelficarra.
+- Compiler errors are now pretty printed in `psc-publish` (@paf31)
+- Modules are no longer linted if they are not being rebuilt (@paf31)
+- FFI bindings are now reloaded when changed, in PSCi (@paf31)
+
+**Other**
+- @phadej and @zudov have improved our CI process, so that PureScript now compiles against three versions of GHC and two LTS Stackage releases, as well as the nightly stackage releases.
+- @phadej and @lukerandall have worked on supporting PureScript in Stackage.
+
+## [v0.7.2.1](https://github.com/purescript/purescript/releases/tag/v0.7.2.1) - 2015-08-12
+
+Functionally equivalent to v0.7.2. This release fixes a version incompatibility with Stackage.
+
+## [v0.7.2](https://github.com/purescript/purescript/releases/tag/v0.7.2) - 2015-08-03
+
+**Bug fixes**
+- Fixed haddock for the Language.PureScript.Bundle module #1262 (@wuzzeb)
+- Some erroneous error positions were fixed for kind and missing instance errors #1086 (@garyb)
+- The number of warnings printed for exhaustivity checks was limited to 5 #1281 (@nicodelpiano)
+- Home directory is checked for `.psci` file _after_ the current working directory #883 (@mjgpy3)
+- Line numbers now show for shadowed name warnings #1165 (@nicodelpiano)
+- Cabal file was fixed for Nix packaging #1302 (@MasseGuillaume)
+- Kind query for types defined in psci now works #1235 (@mjgpy3)
+- Boolean operations are now being inlined again #1312 (@garyb)
+- Int operations are now being inlined again #1330 (@garyb)
+- "Writing..." and "Compiling..." messages are no-longer printed in `psci` #1276 (@paf31)
+
+**Enhancements**
+- Exhaustivity checker was extended to report errors about redundant cases #1289 (@nicodelpiano)
+- Improved triggering of suggestion for errors about using `(<<<)` instead of `(.)` #1284 (@mjgpy3)
+- Only show the module name rather than the filename for pattern errors #1296 (@nicodelpiano)
+- Error reporting in `psc-bundle` was improved #1307 (@hdgarrood)
+- `psc-publish` code is now part of the library module #1304 (@hdgarrood)
+- `psc-publish` now has `--version` and `--help` options #1300 (@garyb)
+- `psc-publish` now has a `--dry-run` option for checking whether the module can be published #1308 (@hdgarrood)
+- `psc-publish` now requires a clean working tree #1306 (@hdgarrood)
+- `psc-publish` can now find `bower` on Windows machines #1317 (@hdgarrood)
+- `psc-publish` now uses OS-specific path delimiters to fix another bug on Windows #1326 (@hdgarrood)
+- Error list heading was made emacs-friendly #1327 (@epost)
+
+## [v0.7.1](https://github.com/purescript/purescript/releases/tag/v0.7.1) - 2015-07-13
+
+Minor fixes after 0.7.0:
+- @hdgarrood has worked on improvements to `psc-publish` to support the new Pursuit website.
+- @mjgpy3 has improved warning messages
+- @wuzzeb has improved the pretty printers
+- @hdgarrood has added CI builds for GHC 7.10 and 7.6
+
+Enhancements
+- @nicodelpiano has added exhaustivity checking as a new warning type. Incomplete pattern matches will now generate warnings like this:
+
+ ``` text
+ Warning in module Data.Either.Unsafe:
+ Warning in value declaration fromRight:
+ Warning at src/Data/Either/Unsafe.purs line 14, column 1 - line 15, column 1:
+ Pattern could not be determined to cover all cases.
+ The definition has the following uncovered cases:
+ (Data.Either.Left _)
+ See https://github.com/purescript/purescript/wiki/Error-Code-NotExhaustivePattern for more information, or to contribute content related to this error.
+ ```
+
+## [v0.7.0](https://github.com/purescript/purescript/releases/tag/v0.7.0) - 2015-06-30
+
+**Introduction**
+
+This release ("MELTDOWN") aims to handle as many planned breaking changes as possible, to ease the upgrade path before 1.0. It is necessary to upgrade almost all PureScript code to compile with this release.
+
+The latest versions of the core libraries have all been updated to compile with this release. Older versions of the core libraries will not work with this release, and the latest versions of libraries will not build with older compiler releases.
+
+Detailed instructions for those who need to migrate their code can be found [on the wiki](https://github.com/purescript/purescript/wiki/0.7-Migration-Guide).
+
+As usual, many thanks go to all of the contributors who helped with this release!
+
+**Breaking changes**
+- The `psc` executable has been replaced with `psc-make`, which has been renamed to `psc` (in an effort to standardize on CommonJS module output). Features which were previously only available in old `psc` (dead code elimination, bundling code for the browser) are now handled by the new executable `psc-bundle`, which works with the output of the new `psc` (for faster, incremental builds).
+- There are now `Int` and `Number` literals. To disambiguate the two, integer `Number` values must now be written with a decimal place (`3.0` rather than `3`).
+- The `Prelude` module is no longer imported automatically, and must be imported the same way as any other module.
+- No modules are included with the compiler now, they have been broken out into their own libraries:
+ - [purescript-prelude](https://github.com/purescript/purescript-prelude)
+ - [purescript-eff](https://github.com/purescript/purescript-eff)
+ - [purescript-st](https://github.com/purescript/purescript-st)
+ - [purescript-console](https://github.com/purescript/purescript-console)
+ - [purescript-functions](https://github.com/purescript/purescript-functions)
+- `Debug.Trace` has been renamed to `Control.Monad.Eff.Console`, and `trace` has been renamed to `log`.
+- `[]` syntax for array types has been removed. It is still possible to use `[]` array literals however.
+ - `[]` should now be written as `Array`, and `[a]` as `Array a`.
+- Cons patterns for arrays have been removed.
+- Declaring operators in classes will now produce a warning. Changes will be coming to operators in PureScript 0.8, and moving to named members in classes with operators as aliases (e.g. `(<$>) = map`) should make the transition easier in the future.
+- JavaScript for the FFI can no longer be provided inline.
+ - Values must instead be provided in a separate `.js` file, and passed to the compiler with the `-ffi` flag.
+ - Values should be provided in the form `exports.foo = ...`, similar to a CommonJS module
+ - The file should have a comment `// module X.Y.Z` where `X.Y.Z` is the name of the module the JS values are for.
+ - [See here for an example](https://github.com/purescript/purescript-eff/blob/v0.1.0-rc.1/src/Control/Monad/Eff.js)
+
+**Enhancements**
+- Module exports (@andyarvanitis). Currently, only full module exports are supported, but imported modules can be re-exported using the following syntax:
+ `purescript
+ module M1 (module M2) where
+ import M2
+ `
+- Documentation improvements (@hdgarrood):
+ - `psc-docs` can now generate multiple output files, allowing documentation to be collected into functional groups.
+ - A new tool `psc-publish` has been added, which generates module documentation in a JSON format required by Pursuit 2 (coming soon)
+- @hdgarrood has worked on improving the quality of code completion inside `psci`, and generally tidying up and refactoring that code.
+- @puffnfresh has worked on dramatically increasing the performance of incremental builds, with improvements up to 10x compared to the previous release.
+- The new `--require-path` option allows the syntax of module imports in generated CommonJS modules to be customized (@garyb).
+- @etrepum has added support for building with Stack.
+- PSCi now supports computations in the `Eff` monad. (@paf31)
+- The compiler now emits warnings in the following cases:
+ - Operator name used in type class definition (@garyb)
+ - Type wildcard used (@nicodelpiano)
+ - Shadowed variable name (@paf31)
+- @balajirrao has improved the appearance of unknown and rigid types appearing in error messages.
+- @puffnfresh has added position information to pattern match errors.
+- @puffnfresh has added some new optimizations (inlining `<<<` and `$`)
+
+**Bug Fixes**
+- `psc`, `psc-docs` and `psc-bundle` now support file globs as command-line arguments, fixing a bug related to the command length on Windows machines (@paf31)
+- @wuzzeb has fixed some issues in the pretty printer.
+- @mjgpy3 has improved error messages related to incorrect pattern matches on data constructors.
+
+**Tools**
+- Pulp has been updated:
+ - The new `psc` and `psc-bundle` binaries are supported
+ - FFI modules are now identified and compiled based on a convention
+ - `pulp docs` now generates individual Markdown files for each source module
+- `gulp-purescript` has been updated:
+ - The new `psc` and `psc-bundle` binaries are supported
+ - FFI modules are now supported
+
+**Libraries**
+- The following libraries have been moved into the core library set:
+ - `purescript-lists` - Strict and lazy linked list data structures
+ - `purescript-assert` - Low level assertion library for tests
+ - `purescript-parallel` - An applicative functor for parallel composition of asynchronous computations.
+ - `purescript-arrows` - Arrow type classes and standard instances.
+ - `purescript-tailrec` - A type class for stack-safe monadic tail recursion.
+- The requirements for libraries in the `purescript-contrib` organization [have been tightened](https://github.com/purescript/purescript/wiki/Contrib-Guidelines), to try to ensure that libraries stay maintained.
+
+## [v0.7.0-rc.1](https://github.com/purescript/purescript/releases/tag/v0.7.0-rc.1) - 2015-06-07
+
+**Important note**
+
+This release should be used with the latest versions of the core libraries, which are also tagged as `-rc.1`.
+
+**Breaking changes**
+- There are now `Int` and `Number` literals. To disambiguate the two, integer `Number` values must now be written with a decimal place (`3.0` rather than `3`).
+- The `Prelude` module is no longer imported automatically, and must be imported the same way as any other module.
+- No modules are included with the compiler now, they have been broken out into their own libraries:
+ - [purescript-prelude](https://github.com/purescript/purescript-prelude)
+ - [purescript-eff](https://github.com/purescript/purescript-eff)
+ - [purescript-st](https://github.com/purescript/purescript-st)
+ - [purescript-console](https://github.com/purescript/purescript-console)
+ - [purescript-functions](https://github.com/purescript/purescript-functions)
+- `[]` syntax for array types has been removed. It is still possible to use `[]` array literals however.
+ - `[]` should now be written as `Array`, and `[a]` as `Array a`.
+- Cons patterns for arrays have been removed.
+- Declaring operators in classes will now produce a warning. Changes will be coming to operators in PureScript 0.8, and moving to named members in classes with operators as aliases (e.g. `(<$>) = map`) should make the transition easier in the future.
+- JavaScript for the FFI can no longer be provided inline.
+ - Values must instead be provided in a separate `.js` file, and passed to the compiler with the `-ffi` flag.
+ - Values should be provided in the form `exports.foo = ...`, similar to a CommonJS module
+ - The file should have a coment `// module X.Y.Z` where `X.Y.Z` is the name of the module the JS values are for.
+ - [See here for an example](https://github.com/purescript/purescript-eff/blob/v0.1.0-rc.1/src/Control/Monad/Eff.js)
+
+_Full release notes coming soon_
+
+## [v0.6.9.5](https://github.com/purescript/purescript/releases/tag/v0.6.9.5) - 2015-04-25
+
+This release contains two patches:
+- Case statements were generating incorrect function name arguments #1008 (@paf31)
+- Comments and verbose error flags were mixed up #991 (@garyb)
+
+## [v0.6.9.3](https://github.com/purescript/purescript/releases/tag/v0.6.9.3) - 2015-03-18
+
+**Breaking Changes**
+- `refEq` and `refIneq` are no longer exported from the `Prelude`.
+
+**Bug Fixes**
+- Instances can now be defined before the corresponding class declaration (@paf31)
+- A bug related to imports in `psci` was fixed. (@paf31)
+- A typechecker bug related to type class dictionaries was fixed. (@garyb)
+- A bug related to operator precedence in codegen was fixed. (@garyb)
+
+**Enhancements**
+- `psci` now supports long-form directives (@mrhania)
+- Syntax for imports and other declaration types in `psci` was improved. (@hdgarrood)
+- Markdown comments can now be included at the module level (@joneshf)
+- Error messages are now represented internally as an algebraic data type, and pretty printing has been improved by using the `boxes` library. Errors now link to the wiki. (@paf31)
+- `psc-docs` can now generate tags files for Vim and Emacs (@jacereda)
+- `psci` now supports a `--node-opts` flag for passing options to the Node executable. (@MichaelXavier)
+- Code gen now preserves names of more function arguments in case statements (@andyarvanitis)
+- There is now a `Semigroup` instance for `Ordering` (@pseudonom)
+
+**Documentation**
+- The Prelude now has Markdown documentation (various contributors - thank you!)
+- The [Pursuit](http://pursuit.purescript.org) website has been updated with new versions of libraries, including Markdown documentation (@hdgarrood)
+
+**Libraries**
+- The following libraries are now core libraries:
+ - `purescript-tailrec` - A type class for monadic tail recursion
+ - `purescript-monad-eff` - A type class for monads supporting native effects
+ - `purescript-integers` - Integer numeric type
+ - `purescript-invariant` - Invariant functors
+ - `purescript-parallel` - An applicative functor for parallel composition of asynchronous computations
+
+**Other**
+- There is an experimental C++11 backend for PureScript called [pure11](https://github.com/andyarvanitis/pure11).
+
+## [v0.6.8](https://github.com/purescript/purescript/releases/tag/v0.6.8) - 2015-02-21
+
+**Breaking Changes**
+- The `Num` type class has been refined to allow more interesting instances. The `Semiring`, `ModuloSemiring`, `Ring` and `DivisionRing` classes have been introduced. Most code should continue to compile, since `Number` was one of only a handful of instances, but library developers will need to break up their `Num` instances.
+
+**Enhancements**
+- @garyb has improved the readability of `psc-docs` output.
+
+**Notes**
+- All uses of the deprecated `ErrorT` have been replaced with `ExceptT` and the `transformers` and `mtl` dependencies bumped accordingly.
+
+## [v0.6.7.1](https://github.com/purescript/purescript/releases/tag/v0.6.7.1) - 2015-02-14
+
+**Bug Fixes**
+- A fix for a bug in the type class instance resolution code (#870, @paf31)
+
+## [v0.6.7](https://github.com/purescript/purescript/releases/tag/v0.6.7) - 2015-02-12
+
+**Enhancements**
+
+**Scoped Type Variables**
+
+(#347, @paf31)
+
+This feature allows type variables which are bound by a `forall` keyword to be used inside type annotations in the body of the function. For example, suppose we want to define a `map` function on a `List` type:
+
+``` purescript
+data List a = Nil | Cons a (List a)
+
+map :: forall a b. (a -> b) -> List a -> List b
+map f = go
+ where
+ go Nil = Nil
+ go (Cons x xs) = Cons (f x) (map f xs)
+```
+
+To give a type to `go`, we could previously use type wildcards:
+
+``` purescript
+go :: List _ -> List _
+```
+
+Now, we can refer to the types `a` and `b` inside the type of `go`, giving a more precise type:
+
+``` purescript
+go :: List a -> List b
+```
+
+**Rows In Instance Contexts**
+
+(@paf31, @apsk)
+
+This feature allows rows to appear on the left of a `=>` in a type signature. For example, given a `MonadEff` class:
+
+``` purescript
+class MonadEff eff m where
+ liftEff :: forall a. Eff eff a -> m a
+```
+
+we can now write the following function which works in any `Monad` supporting `Trace` actions:
+
+``` purescript
+logging :: forall m a eff. (Monad m, MonadEff (trace :: Trace | eff) m) => String -> m a -> m a
+logging s action = do
+ liftEff $ trace $ "Starting: " <> s
+ a <- action
+ liftEff $ trace $ "Done: " <> s
+ return a
+```
+
+**Improved `let` bindings in `psci`**
+
+(#782, @paf31)
+
+Any declaration can now be used inside a `let` binding in `psci`. For example, we can define data types or foreign imports:
+
+``` text
+> let data Foo = Foo | Bar | Baz
+
+> let foreign import foo :: Foo -> String
+```
+
+The general form of a `let` statement in `psci` now contains one or more declarations of any type, and these declarations simply get added to the current module.
+
+As a bonus, polymorphic functions bound using `let` now work at multiple type instantiations in `psci`:
+
+``` text
+> let f x = x
+
+> if f true then f "true" else f "False"
+"true"
+```
+
+**Markdown Support in `psc-docs`**
+
+(#802, @paf31)
+
+Markdown can now be used for documentation purposes by using pipe characters to align content. For example:
+
+``` purescript
+-- | Create a copy of the array without its first element.
+-- |
+-- | Running time: `O(n)`, where `n` is the length of the array.
+-- |
+-- | This function is partial. Specifically, `tail []` is undefined.
+tail :: forall a. [a] -> [a]
+```
+
+`psc-docs` will insert this markdown content verbatim into your generated documentation.
+
+**Bug Fixes**
+- Modules are rebuilt before a command is executed in `psci`, to avoid situations where compiled code becomes out-of-date (@paf31)
+- `@` is a valid operator name again (#815, @paf31)
+- Reserved module names are now properly escaped (@garyb)
+
+## [v0.6.6](https://github.com/purescript/purescript/releases/tag/v0.6.6) - 2015-02-09
+
+**Breaking Changes**
+- The syntax of record getters was changed to `_.prop` (@garyb)
+
+**Enhancements**
+- The record part of a record updater can now be made into a wildcard, e.g. `_ { foo = 1 }` (@garyb)
+- Extended infix expressions are now supported, (@paf31) e.g.
+
+ ```
+ [1, 2, 3] `zipWith (+)` [4, 5, 6]
+ ```
+
+**Bug Fixes**
+- Newline issues were fixed in executables (@michaelficarra)
+
+## [v0.6.5](https://github.com/purescript/purescript/releases/tag/v0.6.5) - 2015-02-08
+
+**Enhancements**
+- Lightweight record constructors are now supported (@garyb):
+
+ ``` purescript
+ person :: Maybe String -> Maybe Number -> Maybe Address -> Maybe Person
+ person = { name: _, age: _, location: _ } <$> name <*> age <*> location
+ ```
+- Field accessor sections are now supported (@garyb):
+
+ ``` purescript
+ getPersonName :: Maybe String
+ getPersonName = (.name) <$> getPersonInfo
+ ```
+- Syntactic sugar has been introduced for object update functions:
+
+ ``` purescript
+ updateName :: Person -> String -> Person
+ updateName person = person { name = _ }
+ ```
+- Operator sections are now supported (@garyb)
+
+**Bug Fixes**
+- Some command line options were fixed in `psc-make` (@paulyoung)
+- Some module import errors were fixed (@garyb)
+- A typechecker bug related to row synonyms was fixed (#795, @paf31)
+
+## [v0.6.4.1](https://github.com/purescript/purescript/releases/tag/v0.6.4.1) - 2015-02-03
+
+Various small bug fixes.
+
+## [v0.6.4](https://github.com/purescript/purescript/releases/tag/v0.6.4) - 2015-01-23
+
+- Fix some precedence issues in the code generator.
+- Tighten the bounds on `utf8-string`.
+- Fixed a bug in the typechecker.
+
+## [v0.6.3](https://github.com/purescript/purescript/releases/tag/v0.6.3) - 2015-01-08
+
+**Breaking Changes**
+
+**Bug Fixes**
+- Case statement at end of `Eff` block not being executed. (#759, @paf31)
+- A bug related to dead code elimination was fixed. (@garyb)
+- Wildcards can now appear in row endings. (@RossMeikleham)
+
+**Enhancements**
+- There is a new "core functional representation", which will enable certain optimizations, and new features such as rewrite rules. (#710, @garyb)
+- Record pattern matches now allow field names to be separated from binders using `:` instead of `=`, to match record construction (#760, @leighman)
+- Some improvements needed for the Pursuit tool (@hdgarrood)
+- The lexer was separated from the parser, and now supports explicit comments in the AST. Documentation generated by `psc-docs` now contains any inline comments which precede the corresponding declaration, and generated code preserves the same comments. (@paf31)
+- PureScript now builds on GHC 7.6.\* again. (@dylex)
+- Proper names can now contain underscores. (@dylex)
+- Several auto-completion improvements and fixes in PSCI. (@vkorablin)
+
+**Libraries**
+- The Prelude now contains a `pureST` function to run `ST` computations in a pure context. (@KMahoney)
+
+**Tools**
+- The Pursuit tool now runs on the community server, and integrates with Bower. Libraries can be added by submitting a pull request. (@hdgarrood)
+
+## [v0.6.2](https://github.com/purescript/purescript/releases/tag/v0.6.2) - 2014-11-28
+
+**Breaking Changes**
+- Command line options with multiplicity 1 now require an equals symbol, e.g.
+
+ ```
+ psc --main=Main --browser-namespace=PS
+ ```
+
+ The Grunt and Gulp plugins already support this format.
+
+**Enhancements**
+- Use `optparse-applicative` instead of `cmdtheline` (@anthoq88)
+
+**Libraries**
+- Move `STArray` out of Prelude. (@paf31)
+
+## [v0.6.1.2](https://github.com/purescript/purescript/releases/tag/v0.6.1.2) - 2014-11-24
+
+
+
+## [v0.6.1.1](https://github.com/purescript/purescript/releases/tag/v0.6.1.1) - 2014-11-19
+
+**Breaking Changes**
+- The pipe symbol is now a reserved operator.
+- The operators in the `Bits` type class have been renamed.
+
+**Enhancements**
+- Fix build on GHC 7.6.\* (@dylex)
+- Relax indentation requirements (@paf31)
+
+## [v0.6.1](https://github.com/purescript/purescript/releases/tag/v0.6.1) - 2014-11-18
+
+**Breaking Changes**
+- The body of a guarded expression must now be indented _past the guard_. For example, this is valid:
+
+``` haskell
+positive n | n > 0 = true
+positive _ = false
+```
+
+but this is not:
+
+``` haskell
+positive n | n > 0
+ = true
+positive _ = false
+```
+
+**New Features**
+- Type wildcards are now supported (#287, @paf31)
+
+**Enhancements**
+- Allow unquoted keywords as key names in record literals (#606, @michaelficarra)
+- Import instances when referencing qualified values (#667, @garyb)
+- Multiple guard clauses are now supported (#294, @paf31)
+- Type check let declarations immediately in `psci` (#615, @garyb)
+
+## [v0.6.0.2](https://github.com/purescript/purescript/releases/tag/v0.6.0.2) - 2014-11-09
+
+- Prevent `psci` and `psc-make` from rebuilding everything on every build #692
+
+## [v0.6.0](https://github.com/purescript/purescript/releases/tag/v0.6.0) - 2014-11-06
+
+For more information on PureScript, see the [purescript.org website](http://purescript.org).
+
+**Breaking Changes**
+- The `Alternative` type class hierarchy was refactored. See [here](https://github.com/purescript/purescript-control/issues/6).
+- `--runtime-type-checks` has been removed. The recommended approach is to use `purescript-foreign`. (@garyb)
+- The `Unit` type is now used in the Prelude and core libraries to represent values containing no data. (@garyb)
+- The Prelude is no longer distributed as a separate file, but is embedded in the compiler executables. (@paf31)
+- `docgen` is now called `psc-docs`.
+
+**New Features**
+- Newtypes are now supported using the `newtype` keyword. The runtime representation of a newtype is identical to that of the contained type. (@garyb)
+- Multiline string literals are now supported via triple-quote syntax, making FFI declarations much neater. (@phadej)
+- Kind signatures on types and type constructor arguments are now supported. (@paf31)
+
+**Enhancements**
+- The `runFnN` and `mkFnN` families of functions are now inlined by the optimizer, making interop with JavaScript functions of multiple arguments much simpler. (@paf31)
+- Tail call optimization has been improved for functions using case expressions. (@paf31)
+- Saturated calls to data constructors are now optimized. (@garyb)
+- A new `Renamer` module now renames identifiers which shadow other names in scope, which greatly simplies code generation. (@garyb)
+- `psci` now provides the following new options:
+ - `:b` to browse a module (@ardumont)
+ - `:s` to show current imports or modules (@ardumont)
+ - `:k` to find the kind of a type constructor (@5outh)
+- The approach to checking whether a name is initialized in the generated JavaScript was simplified (@paf31)
+- The dependency on the `PureScript_paths` module has been removed, which makes distribution via binaries simpler. (@paf31)
+- Nested `if` blocks now get optimized. (@garyb)
+- Generated code for type class dictionaries was simplified. (@garyb, @dylex)
+- The code generator now inserts the version of `psc` into the file as a comment. (@co-dh)
+- `()` is now valid syntax, referring to the empty row. (@paf31)
+- The type checker will now display multiple errors for type errors in the same binding group. (@paf31)
+- Imports can now specify hidden names using `import ... hiding ( ... )` (@andreypopp)
+
+**Bug Fixes**
+- Binding group errors in type class members are now caught at compile time. (@dylex)
+- Some errors related to type checking rows with duplicate labels were fixed. (@paf31)
+- Some issues with the calculation of binding groups were fixed. (@paf31)
+- Error messages for invalid case declarations are now generated. (@natefaubion)
+- Some issues related to module exports were fixed. (@garyb)
+- `psci` now checks imports for validity. (@Bogdanp)
+
+**Libraries**
+- The `Alternative` type class hierarchy was refactored (@joneshf, @garyb)
+- The `exceptions` library no longer supports throwing exceptions of any type.
+- The following libraries have been moved to the core PureScript organisation: (@garyb)
+ - `purescript-transformers`
+ - `purescript-free`
+ - `purescript-const`
+ - `purescript-identity`
+ - `purescript-lazy`
+ - `purescript-distributive`
+ - `purescript-bifunctors`
+ - `purescript-contravariant`
+ - `purescript-profunctors`
+ - `purescript-maps`
+
+**Documentation**
+- The [PureScript book](https://leanpub.com/purescript/read) is now available.
+- The [PureScript wiki](https://github.com/purescript/purescript/wiki) is now the main resource for compiler and library documentation.
+
+## [v0.5.7.1](https://github.com/purescript/purescript/releases/tag/v0.5.7.1) - 2014-10-30
+
+
+
+## [v0.5.7](https://github.com/purescript/purescript/releases/tag/v0.5.7) - 2014-10-29
+
+
+
+## [0.5.6.1](https://github.com/purescript/purescript/releases/tag/0.5.6.1) - 2014-10-06
+
+
+
+## [0.5.6](https://github.com/purescript/purescript/releases/tag/0.5.6) - 2014-10-06
+
+
+
+## [v0.5.6.3](https://github.com/purescript/purescript/releases/tag/v0.5.6.3) - 2014-10-06
+
+
+
+## [0.5.6.2](https://github.com/purescript/purescript/releases/tag/0.5.6.2) - 2014-09-22
+
+
+
+## [v0.5.5](https://github.com/purescript/purescript/releases/tag/v0.5.5) - 2014-09-02
+
+
+
+## [v0.5.4](https://github.com/purescript/purescript/releases/tag/v0.5.4) - 2014-08-04
+
+This incremental release is provided to provide bug fixes and features required to compile the latest core libraries.
+
+## [v0.5.0](https://github.com/purescript/purescript/releases/tag/v0.5.0) - 2014-04-27
+
+**Breaking Changes**
+- Support for blocks has been removed. (paf31)
+- Type class instances must now be named (paf31)
+
+ ```
+ instance showNumber :: Show Number where
+ ...
+ ```
+- Prelude modules now follow a naming scheme similar to haskell (e.g. `Data.Maybe`, `Control.Monad`) (garyb)
+- Many modules that were previously part of the Prelude have been split into individual libraries, [now distributed via Bower](http://bower.io/search/?q=purescript) (garyb)
+- Multiple modules with the same name are now disallowed rather than merged (garyb)
+- The `Prelude` module is now imported automatically. Conflicts can be avoided by using qualified imports or an explicit import list. (garyb, paf31)
+- Overlapping instances are no longer allowed. The `Prelude` and core libraries have been updated accordingly. (paf31)
+- `Functor`, `Applicative`, `Monad` are now part of a class heirarchy that include `Apply` and `Bind`. `return` is now an alias for `pure`. (joneshf, paf31, garyb)
+- `Semigroupoid` is now a superclass of `Category` (garyb)
+- `(:)` is now part of Prelude (garyb)
+- `(!!)` has been renamed to `Prelude.Unsafe.unsafeIndex` and a safe version has been added to `Data.Array` (garyb)
+
+**New Features**
+- Multi parameter typeclasses (paf31)
+- Superclasses (puffnfresh, paf31)
+- FlexibleInstances and FlexibleContexts (paf31)
+- Let bindings are now supported. The `let` keyword can introduce several local (possibly mutually recursive) bindings, along with optional type signatures. (paf31)
+- `where` clauses are now supported in value declarations, with the same rules as `let` bindings (garyb)
+- Empty data declarations and empty type classes are now supported (paf31)
+- A new command line option `--codegen` controls which modules will have Javascript and externs generated (paf31)
+- `psc-make` now generates CommonJS-compatible modules, which can be used with `require()` in `node`. `psc` still generates modules for use in the browser. (paf31, garyb)
+
+**Enhancements**
+- Pretty printing for row types was improved (garyb)
+- Module names can now contain `.` (garyb)
+- New optimizer rules have been added for code in the ST monad, to reproduce the functionality of the blocks feature, which has been removed (paf31)
+- Pattern binders are now usable in lambda expression arguments (paf31)
+- PSCI now has a `:t` command for checking the type of a value (paf31)
+- Array pretty printing via `show` has been improved (joneshf)
+- PSCI completions are sorted (joneshf)
+- PSCI now has help commands (joneshf)
+- PSCI history is in XDG config (joneshf)
+- PSCI allows loading of modules from ~ paths (joneshf)
+- PSCI can accept a list of modules to load on start from the command line (paf31)
+- PSCI can now be configured using a `.psci` file in the current directory. If such a file exists, it should contain a list of commands to run on startup. (paf31)
+- Type class instances are now named, to enable easier interop with Javascript (paf31)
+- Class names no longer need to be qualified in instance declarations (garyb)
+- Module exports can now be specified explicitly (garyb)
+- Let bindings can now define functions with binders (paf31)
+- Case statements and functions which do not pattern match on their arguments now generate smaller code (paf31)
+- Imported type class instances are now exported (paf31)
+- Some error messages were improved (paf31)
+- Qualfied module imports are now supported as `import qualified M as X` (garyb)
+- The escape check was removed, since it was too restrictive (paf31)
+- The binary operator reordering step was greatly simplified (paf31)
+**The Object type constructor can now be referenced explicitly as `Prim.Object` (with kind `# * -> *`) (paf31)**
+- Optimizations are now enabled by default and can be disabled with the `--no-tco` and `--no-magic-do` flags (garyb)
+- Unary minus and signed numeric literals are now supported again (paf31, garyb)
+- Type errors have been simplified, the full trace can be enabled with `--verbose-errors` or `-v` (paf31)
+- Error messages now display source positions (paf31, garyb)
+- The type classes implementation and code generation was greatly simplified (paf31)
+- Object properties and row labels can now be accessed with arbitrary string names by using string literals (paf31)
+- `(++)` is now an alias for the Semigroup operator `(<>)` (paf31)
+- Error messages for classes with undefined or missing members have been improved (garyb)
+- The SYB dependency was removed, and traversals rewritten by hand, for a large performance increase (paf31)
+
+**Bug Fixes**
+- The subsumes relation has been fixed for object types (paf31)
+- `sort` no longer mutates arrays (joneshf)
+- PSCI now evaluates expressions (joneshf)
+- Overlapping variables in typeclass instances are rejected (paf31)
+- A bug in the optimizer related to inlining was fixed (paf31)
+- A type checker bug related to array literals was fixed (paf31)
+- Externs files (`--externs`) are now working again (paf31)
+- Precedence of backticked infix functions have been corrected (paf31)
+- A bug which allowed some incorrect type class instances to pass the type checker was fixed (paf31)
+- Type synonyms are no longer restricted to kind `*` (paf31)
+- Negative number literals have been restored (garyb)
+- If a type defined in a module appears in an exported declaration it must also be exported from the module (garyb)
+- Error messages for unresolvable types or values include the declaration name again (garyb)
+- Characters in string literals are now properly escaped (garyb)
+- A module containing a single orphan type declaration and no other declarations now fails to compile (garyb)
+- An error involving ordering of type class instances was fixed (garyb, paf31)
+- Externs files no longer include fixity declarations for members that were removed as dead code (garyb)
+- A bug which prevented `sequence $ [Just 1]` from typechecking was fixed (paf31)
+
+**Libraries**
+- Purescript libraries are now [distributed via Bower](http://bower.io/search/?q=purescript). There are currently around 40 libraries available.
+
+**Plugins**
+- The `grunt-purescript` plugin has been updated to provide support for new command line options.
+- There is a new `gulp-purescript` plugin available for compiling with Gulp.
+
+**Documentation**
+- There is a new `hierarchy` executable which will generate `.dot` diagrams based on the type class hierarchy of a module. The Prelude docs have been updated to include such a type class diagram. (joneshf)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index dc455d66e8..219f7ba701 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,50 +1,177 @@
+# Contributing to the PureScript Compiler
+
+## Reporting Issues
+
+When reporting issues, please be aware of the following:
+
+* Please use the appropriate issue template if there is one: filling out all of the sections in the template makes it much easier for us to understand what the problem is and how we might want to address it.
+* We prefer to reserve the issue tracker in this repository for tasks which involve work on the compiler. If your report or proposal doesn't involve work on the compiler, please open it on the repository where the work would be done. If you're unsure, you can always ask on [Discord](https://purescript.org/chat) or [Discourse](https://discourse.purescript.org).
+* If you have a question or need help, please ask on [Discord](https://purescript.org/chat) or [Discourse](https://discourse.purescript.org) instead.
+* When submitting feature proposals, please be aware that we prefer to be conservative about adding things to the language/compiler. A feature proposal is much more likely to be accepted if it includes a clear description of the problem it intends to solve, as well as not only a strong justification for why adding the feature will solve that problem, but also for why any existing features or techniques that could be used to solve that problem are insufficient.
+
+We have defined some [Project Values](https://github.com/purescript/governance#project-values) in our organization's governance document; referring to these may help you get a better idea of what is likely to be accepted and what isn't.
+
+## Sending Pull Requests
+
Pull requests are encouraged, but please open issues before starting to work on something that you intend to make into a PR, so that we can decide if it is a good fit or not.
-## Finding Issues to Work On
+### Finding Issues to Work On
If you would like to contribute, please consider the issues in the current milestone first. If you are a new contributor, you may want to have a go at the ["new contributor" issues](https://github.com/purescript/purescript/labels/new%20contributor) to get started.
-## Pull Requests
+### Submitting Your Code
-Please follow the following guidelines:
+When submitting a pull request, please follow the following guidelines:
-- Add at least a test to `tests/purs/passing/` and possibly to `tests/purs/failing/`.
-- Build the binaries and libs with `stack build`
-- Make sure that all test suites are passing. Run the test suites with `stack test`.
-- Build the core libraries by running the script in `core-tests`.
+- Add tests according to the next section
+- Build the binaries and libraries with `stack build --fast`. The `--fast` flag is recommended but not required; it disables optimizations, which can speed things up quite a bit.
+- Make sure that all test suites are passing. Run the test suites with `stack test --fast`.
+- Please try to keep changes small and isolated: smaller pull requests which only address one issue are much easier to review.
+- For any code change, please append a copyright and licensing notice to the [CONTRIBUTORS.md](CONTRIBUTORS.md) file if your name is not in there already.
-## Tests
+### Writing Tests
-Run all test suites with `stack test`. You will need `npm`, `bower` and `node` on your PATH to run the tests.
+When writing tests, try to have at least one passing test and one failing test, if applicable.
+
+- Passing tests go in `tests/purs/passing/`
+- Failing tests go in `tests/purs/failing/`
+- Tests that check warnings go in `tests/purs/warning/`
+
+Passing tests may produce warnings. Tests in `tests/purs/warning/` can ensure no warning is emitted by having no annotations and an empty `.out` file.
-You can run individual test suites using `stack test --test-arguments="-p
-PATTERN"` where `PATTERN` is one of `compiler`, `repl`, `ide`, `docs`, `corefn`,
-or `hierarchy`.
+### Running Tests
-To build and run a specific test in `tests/purs/passing/` or `tests/purs/failing/`, add test arguments like so:
+Run all test suites with `stack test`. You will need `npm`, `bower` and `node` on your PATH to run the tests.
+
+You can run individual test suites using `stack test --test-arguments="--match PATTERN"` where `PATTERN` is one of `compiler`, `repl`, `ide`, `docs`, `corefn`, or `hierarchy`. You can also build and run a specific test in `tests/purs/passing/` or `tests/purs/failing/` by using the test's filename as the pattern, e.g.:
-`stack test --fast --test-arguments="-p 1110.purs"`
+```
+stack test --fast --test-arguments="--match 1110.purs"
+```
This will run whatever test uses the example file `1110.purs`.
-## Code Review
+The golden files (e.g. `*.out` files) are generated automatically when missing, and can be updated by setting the "HSPEC_ACCEPT" environment variable, e.g. by running `HSPEC_ACCEPT=true stack test`.
+
+The source map tests' output can be visualized using the [Source Map Visualization](https://sokra.github.io/source-map-visualization/) website. The site requires uploading three files in the following order: the `.js` file, the `.js.map` file, and the `.purs` file.
+
+To produce these files, run `stack test --fast --ta "--match sourcemaps" && ./get-source-maps.sh`. Each test's 3 files will be stored in `.source-maps//` folder. The `get-source-maps.sh` script only works if the test files abide by the requirements described in [TestSourceMaps.hs](.tests/TestSourceMaps.hs).
+
+### Adding Dependencies
+
+Because the PureScript compiler is distributed in binary form, we include the licenses of all dependencies, including transitive ones, in the LICENSE file. Therefore, whenever the dependencies change, the LICENSE file should be updated.
+
+This process can be performed automatically by running `make license-generator`.
+
+### Getting Pull Requests Merged
+
+Sometimes pull requests take a little while to be merged. This is partially because they often have knock-on effects for the rest of the ecosystem, and partially because we want to give core team members time to review and consider changes thoroughly. Please see the organization's [governance document](https://github.com/purescript/governance) for information about when a pull request may be merged.
+
+## Developer Guide
+
+The following instructions are intended to help PureScript users more easily contribute to the compiler, even if this is your first Haskell project.
+
+### Prerequisites
+
+Install `stack`. [Instructions](https://docs.haskellstack.org/en/stable/README/).
+
+Update stack's package index before proceeding:
+```
+stack update
+```
+
+### Clone
+
+```
+git clone https://github.com/purescript/purescript.git purescript_compiler
+cd purescript_compiler
+```
+
+### Build
+
+```
+stack build
+```
+
+This will take a while the first time it is run.
+
+### Running a locally-compiled version of PureScript
+
+Run `stack exec bash` to launch a subshell (substitute `bash` with your preferred shell) where your locally-compiled version of `purs` is available at the front of your `PATH`. Other tools (such as `spago`) will also grab this latest `purs` version if executed in this shell. You can use `purs --version` and `which purs` to confirm you're executing your locally-compiled version.
+
+```
+> purs --version
+0.14.2
+> which purs
+~/.nvm/versions/node/v14.9.0/bin/purs
+
+> stack exec bash
+
+> purs --version
+0.14.2 [development build; commit: f1953214775945b65ba53ae903b4238c352dcd29 DIRTY]
+> which purs
+~/projects/purescript/complier/.stack-work/install/x86_64-linux-tinfo6/1a835accec0abb5a1f7364196133985d18f8c46ee8c7424ce43cf68bab56e5b1/8.10.4/bin/purs
+```
+
+If you plan on using your patched version of `purs` for a while (for example, while waiting on your changes to be incorporated into the next official release), it may be more convenient to install it globally with:
+
+```
+stack install
+```
+
+Note that other installed version (e.g. what npm installs) may still have priority depending on how your `PATH` is configured. `stack install` should warn about other higher-priority versions, and you can always use `which purs` as a sanity check. Uninstall by simply deleting the `purs` binary (location can be found with `which purs`).
+
+### Profiling
+
+A profiling build is used to help diagnose performance issues with the compiler.
+
+Create a profiling build with:
+```
+stack build --profile
+```
+This will also take a while the first time it is run.
+
+Setting-up a local shell for your profiling build is similar to the steps for the standard build, just add the `--profile` flag:
+```
+stack exec --profile bash
+```
+Note that the bin directory prepended to `$PATH` is different than the standard build, so you can let this be a third "profiling" shell that you leave open between rebuilds.
+
+The `purs` compiler is often wrapped by `spago`. Here's how to pass the "time profiling" flag `-p` via spago:
+```
+spago build --purs-args "+RTS -p -RTS"
+```
+
+Note: There are other profiling flags (such as `-hc` for heap size). You can read more about these flags [here](http://book.realworldhaskell.org/read/profiling-and-optimization.html).
+
+This creates a `purs.prof` file. You can view the contents of this file directly, but it is often more convenient to use a visualizer.
+
+### Profile Visualizers
+
+Each of these produces a clickable visual display of profiling info. Feel free to open the output files in the web browser of your choice. These examples use `firefox`.
-To prevent core libraries from getting broken, every change must be reviewed. A pull request will be merged as long as one other team member has verified the changes.
+#### [ghc-prof-flamegraph](https://github.com/fpco/ghc-prof-flamegraph)
+```
+stack build --copy-compiler-tool ghc-prof-flamegraph
+stack exec -- ghc-prof-flamegraph purs.prof
+firefox purs.svg
+```
-## Adding Dependencies
+For more flamegraph customizations, you can also try [`stackcollapse-ghc`](https://github.com/marcin-rzeznicki/stackcollapse-ghc)
-Because the PureScript compiler is distributed in binary form, we include
-the licenses of all dependencies, including transitive ones, in the LICENSE
-file. Therefore, whenever the dependencies change, the LICENSE file should be
-updated.
+#### [profiteur](https://github.com/jaspervdj/profiteur)
+```
+stack build --copy-compiler-tool profiteur
+stack exec -- profiteur purs.prof
+firefox purs.prof.html
+```
-This can be automated; see the `license-generator/generate.hs` file.
+### Additional Resources
-## Writing Issues
+* [Haskell Language Server](https://github.com/haskell/haskell-language-server#installation) installation guide.
-- If the issue is actually a question, please consider asking on Reddit, Stack Overflow or IRC first.
-- Please include a minimal, repeatable test case with any bug report.
+* PureScript-compiler-focused [guide](https://discourse.purescript.org/t/haskell-tooling-guide-vscode-hie/1505) covering VSCode + HIE setup.
-## Copyright and Licensing
+* Beginner-friendly [guide](https://www.vacationlabs.com/haskell/environment-setup.html) covering VSCode + HIE setup, although the steps needed some tweaking for compatibility with the PureScript compiler project.
-For any code change, please append a copyright and licensing notice to the [CONTRIBUTORS.md](CONTRIBUTORS.md) file.
+* An [outdated table](https://github.com/rainbyte/haskell-ide-chart#the-chart-with-a-link-to-each-plug-in) of IDE recommendations. Note that the [`intero`](https://github.com/chrisdone/intero/blob/master/README.md) backend (listed for four entries) is no longer supported.
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index ab5a25a6a4..3a4fb44ab8 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -14,140 +14,187 @@ If you would prefer to use different terms, please use the section below instead
| Username | Name | License |
| :------- | :--- | :------ |
-| [@5outh](https://github.com/5outh) | Benjamin Kovach | MIT license |
-| [@actionshrimp](https://github.com/actionshrimp) | David Aitken | [MIT license](http://opensource.org/licenses/MIT) |
-| [@alexbiehl](https://github.com/alexbiehl) | Alexander Biehl | [MIT license](http://opensource.org/licenses/MIT) |
-| [@andreypopp](https://github.com/andreypopp) | Andrey Popp | MIT license |
-| [@andyarvanitis](https://github.com/andyarvanitis) | Andy Arvanitis | [MIT license](http://opensource.org/licenses/MIT) |
-| [@anthok88](https://github.com/anthok88) | anthoq88 | MIT license |
-| [@ardumont](https://github.com/ardumont) | Antoine R. Dumont | [MIT license](http://opensource.org/licenses/MIT) |
-| [@aspidites](https://github.com/aspidites) | Edwin Marshall | [MIT license](http://opensource.org/licenses/MIT) |
-| [@bagl](https://github.com/bagl) | Petr Vapenka | [MIT license](http://opensource.org/licenses/MIT) |
-| [@balajirrao](https://github.com/balajirrao) | Balaji Rao | MIT license |
-| [@bbqbaron](https://github.com/bbqbaron) | Eric Loren | [MIT license](http://opensource.org/licenses/MIT) |
-| [@bergmark](https://github.com/bergmark) | Adam Bergmark | MIT license |
-| [@bitemyapp](https://github.com/bitemyapp) | Chris Allen | [MIT license](http://opensource.org/licenses/MIT) |
-| [@bmjames](https://github.com/bmjames) | Ben James | [MIT license](http://opensource.org/licenses/MIT) |
-| [@Bogdanp](https://github.com/Bogdanp) | Bogdan Paul Popa | [MIT license](http://opensource.org/licenses/MIT) |
-| [@brandonhamilton](https://github.com/brandonhamilton) | Brandon Hamilton | [MIT license](http://opensource.org/licenses/MIT) |
-| [@bsermons](https://github.com/bsermons) | Brian Sermons | [MIT license](http://opensource.org/licenses/MIT) |
-| [@cdepillabout](https://github.com/cdepillabout) | Dennis Gosnell | [MIT license](http://opensource.org/licenses/MIT) |
-| [@chexxor](https://github.com/chexxor) | Alex Berg | [MIT license](http://opensource.org/licenses/MIT) |
-| [@chrisdone](https://github.com/chrisdone) | Chris Done | MIT license |
-| [@cmdv](https://github.com/cmdv) | Vincent Orr | MIT license |
-| [@codedmart](https://github.com/codedmart) | Brandon Martin | [MIT license](http://opensource.org/licenses/MIT) |
-| [@coot](https://github.com/coot) | Marcin Szamotulski | [MIT license](http://opensource.org/licenses/MIT) |
-| [@davidchambers](https://github.com/davidchambers) | David Chambers | [MIT license](http://opensource.org/licenses/MIT) |
-| [@DavidLindbom](https://github.com/DavidLindbom) | David Lindbom | [MIT license](http://opensource.org/licenses/MIT) |
-| [@dckc](https://github.com/dckc) | Dan Connolly | [MIT license](http://opensource.org/licenses/MIT) |
-| [@kleeneplus](https://github.com/dgendill) | Dominick Gendill | [MIT license](http://opensource.org/licenses/MIT) |
-| [@ealmansi](https://github.com/ealmansi) | Emilio Almansi | MIT license |
-| [@eamelink](https://github.com/eamelink) | Erik Bakker | MIT license |
-| [@epost](https://github.com/epost) | Erik Post | MIT license |
-| [@erdeszt](https://github.com/erdeszt) | Tibor Erdesz | [MIT license](http://opensource.org/licenses/MIT) |
-| [@etrepum](https://github.com/etrepum) | Bob Ippolito | [MIT license](http://opensource.org/licenses/MIT) |
-| [@faineance](https://github.com/faineance) | faineance | [MIT license](http://opensource.org/licenses/MIT) |
-| [@fehrenbach](https://github.com/fehrenbach) | Stefan Fehrenbach | [MIT license](http://opensource.org/licenses/MIT) |
-| [@felixSchl](https://github.com/felixSchl) | Felix Schlitter | [MIT license](http://opensource.org/licenses/MIT) |
-| [@FrigoEU](https://github.com/FrigoEU) | Simon Van Casteren | [MIT license](http://opensource.org/licenses/MIT) |
-| [@garyb](https://github.com/garyb) | Gary Burgess | [MIT license](http://opensource.org/licenses/MIT) |
-| [@hdgarrood](https://github.com/hdgarrood) | Harry Garrood | [MIT license](http://opensource.org/licenses/MIT) |
-| [@houli](https://github.com/houli) | Eoin Houlihan | [MIT license](http://opensource.org/licenses/MIT) |
-| [@ianbollinger](https://github.com/ianbollinger) | Ian D. Bollinger | [MIT license](http://opensource.org/licenses/MIT) |
-| [@ilovezfs](https://github.com/ilovezfs) | ilovezfs | MIT license |
-| [@i-am-tom](https://github.com/i-am-tom) | i-am-tom | [MIT license](http://opensource.org/licenses/MIT) |
-| [@izgzhen](https://github.com/izgzhen) | Zhen Zhang | [MIT license](http://opensource.org/licenses/MIT) |
-| [@jacereda](https://github.com/jacereda) | Jorge Acereda | [MIT license](http://opensource.org/licenses/MIT) |
-| [@japesinator](https://github.com/japesinator) | JP Smith | [MIT license](http://opensource.org/licenses/MIT) |
-| [@jkachmar](https://github.com/jkachmar) | Joe Kachmar | MIT license |
-| [@joneshf](https://github.com/joneshf) | Hardy Jones | MIT license |
-| [@kika](https://github.com/kika) | Kirill Pertsev | MIT license |
-| [@kRITZCREEK](https://github.com/kRITZCREEK) | Christoph Hegemann | MIT license |
-| [@L8D](https://github.com/L8D) | Tenor Biel | [MIT license](http://opensource.org/licenses/MIT) |
-| [@legrostdg](https://github.com/legrostdg) | Félix Sipma | [MIT license](http://opensource.org/licenses/MIT) |
-| [@LiamGoodacre](https://github.com/LiamGoodacre) | Liam Goodacre | [MIT license](http://opensource.org/licenses/MIT) |
-| [@lukerandall](https://github.com/lukerandall) | Luke Randall | [MIT license](http://opensource.org/licenses/MIT) |
-| [@matthewleon](https://github.com/matthewleon) | Matthew Leon | [MIT license](http://opensource.org/licenses/MIT) |
-| [@mcoffin](https://github.com/mcoffin) | Matt Coffin | [MIT license](http://opensource.org/licenses/MIT) |
-| [@mhcurylo](https://github.com/mhcurylo) | Mateusz Curylo | [MIT license](http://opensource.org/licenses/MIT) |
-| [@MiracleBlue](https://github.com/MiracleBlue) | Nicholas Kircher | [MIT license](http://opensource.org/licenses/MIT) |
-| [@mrkgnao](https://github.com/mrkgnao) | Soham Chowdhury | [MIT license](http://opensource.org/licenses/MIT) |
-| [@mgmeier](https://github.com/mgmeier) | Michael Gilliland | [MIT license](http://opensource.org/licenses/MIT) |
-| [@michaelficarra](https://github.com/michaelficarra) | Michael Ficarra | [MIT license](http://opensource.org/licenses/MIT) |
-| [@MichaelXavier](https://github.com/MichaelXavier) | Michael Xavier | MIT license |
-| [@mjgpy3](https://github.com/mjgpy3) | Michael Gilliland | [MIT license](http://opensource.org/licenses/MIT) |
-| [@mpietrzak](https://github.com/mpietrzak) | Maciej Pietrzak | [MIT license](http://opensource.org/licenses/MIT) |
-| [@mrhania](https://github.com/mrhania) | Łukasz Hanuszczak | [MIT license](http://opensource.org/licenses/MIT) |
-| [@natefaubion](https://github.com/natefaubion) | Nathan Faubion | [MIT license](http://opensource.org/licenses/MIT) |
-| [@nicodelpiano](https://github.com/nicodelpiano) | Nicolas Del Piano | [MIT license](http://opensource.org/licenses/MIT) |
-| [@noraesae](https://github.com/noraesae) | Hyunje Jun | [MIT license](http://opensource.org/licenses/MIT) |
-| [@nullobject](https://github.com/nullobject) | Josh Bassett | [MIT license](http://opensource.org/licenses/MIT) |
-| [@nwolverson](https://github.com/nwolverson) | Nicholas Wolverson | [MIT license](http://opensource.org/licenses/MIT) |
-| [@osa1](https://github.com/osa1) | Ömer Sinan Ağacan | MIT license |
-| [@paf31](https://github.com/paf31) | Phil Freeman | [MIT license](http://opensource.org/licenses/MIT) |
-| [@parsonsmatt](https://github.com/parsonsmatt) | Matt Parsons | [MIT license](http://opensource.org/licenses/MIT) |
-| [@passy](https://github.com/passy) | Pascal Hartig | [MIT license](http://opensource.org/licenses/MIT) |
-| [@paulyoung](https://github.com/paulyoung) | Paul Young | [MIT license](http://opensource.org/licenses/MIT) |
-| [@pelotom](https://github.com/pelotom) | Thomas Crockett | [MIT license](http://opensource.org/licenses/MIT) |
-| [@phadej](https://github.com/phadej) | Oleg Grenrus | [MIT license](http://opensource.org/licenses/MIT) |
-| [@phiggins](https://github.com/phiggins) | Pete Higgins | [MIT license](http://opensource.org/licenses/MIT) |
-| [@philopon](https://github.com/philopon) | Hirotomo Moriwaki | [MIT license](http://opensource.org/licenses/MIT) |
-| [@pseudonom](https://github.com/pseudonom) | Eric Easley | [MIT license](http://opensource.org/licenses/MIT) |
-| [@quesebifurcan](https://github.com/quesebifurcan) | Fredrik Wallberg | [MIT license](http://opensource.org/licenses/MIT) |
-| [@rhendric](https://github.com/rhendric) | Ryan Hendrickson | [MIT license](http://opensource.org/licenses/MIT) |
-| [@rightfold](https://github.com/rightfold) | rightfold | [MIT license](https://opensource.org/licenses/MIT) |
-| [@rndnoise](https://www.github.com/rndnoise) | rndnoise | [MIT license](http://opensource.org/licenses/MIT) |
-| [@robdaemon](https://github.com/robdaemon) | Robert Roland | [MIT license](http://opensource.org/licenses/MIT) |
-| [@RossMeikleham](https://github.com/RossMeikleham) | Ross Meikleham | [MIT license](http://opensource.org/licenses/MIT) |
-| [@Rufflewind](https://github.com/Rufflewind) | Phil Ruffwind | [MIT license](https://opensource.org/licenses/MIT) |
-| [@rvion](https://github.com/rvion) | Rémi Vion | [MIT license](http://opensource.org/licenses/MIT) |
-| [@RyanGlScott](https://github.com/RyanGlScott) | Ryan Scott | [MIT license](http://opensource.org/licenses/MIT) |
-| [@sebastiaanvisser](https://github.com/sebastiaanvisser) | Sebastiaan Visser | MIT license |
-| [@sectore](https://github.com/sectore) | Jens Krause | [MIT license](http://opensource.org/licenses/MIT) |
-| [@senju](https://github.com/senju) | senju | [MIT license](http://opensource.org/licenses/MIT) |
-| [@seungha-kim](https://github.com/seungha-kim) | Seungha Kim | [MIT license](http://opensource.org/licenses/MIT) |
-| [@simonyangme](https://github.com/simonyangme) | Simon Yang | [MIT license](http://opensource.org/licenses/MIT) |
-| [@sharkdp](https://github.com/sharkdp) | David Peter | [MIT license](http://opensource.org/licenses/MIT) |
-| [@soupi](https://github.com/soupi) | Gil Mizrahi | [MIT license](http://opensource.org/licenses/MIT) |
-| [@stefanholzmueller](https://github.com/stefanholzmueller) | Stefan Holzmüller | [MIT license](http://opensource.org/licenses/MIT) |
-| [@sztupi](https://github.com/sztupi) | Attila Sztupak | [MIT license](http://opensource.org/licenses/MIT) |
-| [@taktoa](https://github.com/taktoa) | Remy Goldschmidt | [MIT license](http://opensource.org/licenses/MIT) |
-| [@taku0](https://github.com/taku0) | taku0 | [MIT license](http://opensource.org/licenses/MIT) |
-| [@tfausak](https://github.com/tfausak) | Taylor Fausak | [MIT license](http://opensource.org/licenses/MIT) |
-| [@thoradam](https://github.com/thoradam) | Thor Adam | [MIT license](http://opensource.org/licenses/MIT) |
-| [@tmcgilchrist](https://github.com/tmcgilchrist) | Tim McGilchrist | [MIT license](http://opensource.org/licenses/MIT) |
-| [@trofi](https://github.com/trofi) | Sergei Trofimovich | [MIT license](http://opensource.org/licenses/MIT) |
-| [@utkarshkukreti](https://github.com/utkarshkukreti) | Utkarsh Kukreti | [MIT license](http://opensource.org/licenses/MIT) |
-| [@vkorablin](https://github.com/vkorablin) | Vladimir Korablin | MIT license |
-| [@vladciobanu](https://github.com/vladciobanu) | Vladimir Ciobanu | [MIT license](http://opensource.org/licenses/MIT) |
-| [@zudov](https://github.com/zudov) | Konstantin Zudov | [MIT license](http://opensource.org/licenses/MIT) |
-| [@b123400](https://github.com/b123400) | b123400 | [MIT license](https://opensource.org/licenses/MIT) |
-| [@kcsongor](https://github.com/kcsongor) | Csongor Kiss | [MIT license](http://opensource.org/licenses/MIT) |
-| [@drets](https://github.com/drets) | Dmytro Rets | [MIT license](http://opensource.org/licenses/MIT) |
-| [@bjornmelgaaard](https://github.com/BjornMelgaard) | Sergey Homa | [MIT license](http://opensource.org/licenses/MIT) |
-| [@thimoteus](https://github.com/Thimoteus) | thimoteus | [MIT license](http://opensource.org/licenses/MIT) |
-| [@sloosch](https://github.com/sloosch) | Simon Looschen | [MIT license](http://opensource.org/licenses/MIT) |
-| [@rgrinberg](https://github.com/rgrinberg) | Rudi Grinberg | [MIT license](http://opensource.org/licenses/MIT) |
-| [@gabejohnson](https://github.com/gabejohnson) | Gabe Johnson | [MIT license](http://opensource.org/licenses/MIT) |
-| [@dariooddenino](https://github.com/dariooddenino) | Dario Oddenino | [MIT license](http://opensource.org/licenses/MIT) |
-| [@jordanmartinez](https://github.com/jordanmartinez) | Jordan Martinez | [MIT license](http://opensource.org/licenses/MIT) |
-| [@Saulukass](https://github.com/Saulukass) | Saulius Skliutas | [MIT license](http://opensource.org/licenses/MIT) |
-| [@adnelson](https://github.com/adnelson) | Allen Nelson | [MIT license](http://opensource.org/licenses/MIT) |
+| [@5outh](https://github.com/5outh) | Benjamin Kovach | [MIT license] |
+| [@actionshrimp](https://github.com/actionshrimp) | David Aitken | [MIT license] |
+| [@ad-si](https://github.com/ad-si) | Adrian Sieber | [MIT license] |
+| [@adnelson](https://github.com/adnelson) | Allen Nelson | [MIT license] |
+| [@alexbiehl](https://github.com/alexbiehl) | Alexander Biehl | [MIT license] |
+| [@andreypopp](https://github.com/andreypopp) | Andrey Popp | [MIT license] |
+| [@andyarvanitis](https://github.com/andyarvanitis) | Andy Arvanitis | [MIT license] |
+| [@andys8](https://github.com/andys8) | andys8 | [MIT license] |
+| [@anthok88](https://github.com/anthok88) | anthoq88 | [MIT license] |
+| [@ardumont](https://github.com/ardumont) | Antoine R. Dumont | [MIT license] |
+| [@arrowd](https://github.com/arrowd) | Gleb Popov | [MIT license] |
+| [@aspidites](https://github.com/aspidites) | Edwin Marshall | [MIT license] |
+| [@b123400](https://github.com/b123400) | b123400 | [MIT license] |
+| [@bagl](https://github.com/bagl) | Petr Vapenka | [MIT license] |
+| [@balajirrao](https://github.com/balajirrao) | Balaji Rao | [MIT license] |
+| [@bbqbaron](https://github.com/bbqbaron) | Eric Loren | [MIT license] |
+| [@bergmark](https://github.com/bergmark) | Adam Bergmark | [MIT license] |
+| [@bitemyapp](https://github.com/bitemyapp) | Chris Allen | [MIT license] |
+| [@bjornmelgaaard](https://github.com/BjornMelgaard) | Sergey Homa | [MIT license] |
+| [@bmjames](https://github.com/bmjames) | Ben James | [MIT license] |
+| [@Bogdanp](https://github.com/Bogdanp) | Bogdan Paul Popa | [MIT license] |
+| [@brandonhamilton](https://github.com/brandonhamilton) | Brandon Hamilton | [MIT license] |
+| [@bsermons](https://github.com/bsermons) | Brian Sermons | [MIT license] |
+| [@cdepillabout](https://github.com/cdepillabout) | Dennis Gosnell | [MIT license] |
+| [@chexxor](https://github.com/chexxor) | Alex Berg | [MIT license] |
+| [@chrisdone](https://github.com/chrisdone) | Chris Done | [MIT license] |
+| [@cmdv](https://github.com/cmdv) | Vincent Orr | [MIT license] |
+| [@codedmart](https://github.com/codedmart) | Brandon Martin | [MIT license] |
+| [@coot](https://github.com/coot) | Marcin Szamotulski | [MIT license] |
+| [@dariooddenino](https://github.com/dariooddenino) | Dario Oddenino | [MIT license] |
+| [@davidchambers](https://github.com/davidchambers) | David Chambers | [MIT license] |
+| [@DavidLindbom](https://github.com/DavidLindbom) | David Lindbom | [MIT license] |
+| [@dckc](https://github.com/dckc) | Dan Connolly | [MIT license] |
+| [@Deltaspace0](https://github.com/Deltaspace0) | Ruslan Gadeev | [MIT license] |
+| [@drets](https://github.com/drets) | Dmytro Rets | [MIT license] |
+| [@dyerw](https://github.com/dyerw) | Liam Dyer | [MIT license] |
+| [@ealmansi](https://github.com/ealmansi) | Emilio Almansi | [MIT license] |
+| [@eamelink](https://github.com/eamelink) | Erik Bakker | [MIT license] |
+| [@EMattfolk](https://github.com/EMattfolk) | Erik Mattfolk | [MIT license] |
+| [@epost](https://github.com/epost) | Erik Post | [MIT license] |
+| [@erdeszt](https://github.com/erdeszt) | Tibor Erdesz | [MIT license] |
+| [@etrepum](https://github.com/etrepum) | Bob Ippolito | [MIT license] |
+| [@f-f](https://github.com/f-f) | Fabrizio Ferrai | [MIT license] |
+| [@faineance](https://github.com/faineance) | faineance | [MIT license] |
+| [@fehrenbach](https://github.com/fehrenbach) | Stefan Fehrenbach | [MIT license] |
+| [@felixSchl](https://github.com/felixSchl) | Felix Schlitter | [MIT license] |
+| [@FredTheDino](https://github.com/FredTheDino) | Edvard Thörnros | [MIT license] |
+| [@FrigoEU](https://github.com/FrigoEU) | Simon Van Casteren | [MIT license] |
+| [@fsoikin](https://github.com/fsoikin) | Fyodor Soikin | [MIT license] |
+| [@gabejohnson](https://github.com/gabejohnson) | Gabe Johnson | [MIT license] |
+| [@garyb](https://github.com/garyb) | Gary Burgess | [MIT license] |
+| [@hdgarrood](https://github.com/hdgarrood) | Harry Garrood | [MIT license] |
+| [@houli](https://github.com/houli) | Eoin Houlihan | [MIT license] |
+| [@i-am-the-slime](https://github.com/i-am-the-slime) | Mark Eibes | [MIT license] |
+| [@i-am-tom](https://github.com/i-am-tom) | i-am-tom | [MIT license] |
+| [@ianbollinger](https://github.com/ianbollinger) | Ian D. Bollinger | [MIT license] |
+| [@ilovezfs](https://github.com/ilovezfs) | ilovezfs | [MIT license] |
+| [@imcotton](https://github.com/imcotton) | Cotton Hou | [MIT license] |
+| [@izgzhen](https://github.com/izgzhen) | Zhen Zhang | [MIT license] |
+| [@j-nava](https://github.com/j-nava) | Jesse Nava | [MIT license] |
+| [@jacereda](https://github.com/jacereda) | Jorge Acereda | [MIT license] |
+| [@japesinator](https://github.com/japesinator) | JP Smith | [MIT license] |
+| [@jkachmar](https://github.com/jkachmar) | Joe Kachmar | [MIT license] |
+| [@joneshf](https://github.com/joneshf) | Hardy Jones | [MIT license] |
+| [@jordanmartinez](https://github.com/jordanmartinez) | Jordan Martinez | [MIT license] |
+| [@jy14898](https://github.com/jy14898) | Joseph Young | [MIT license] |
+| [@kcsongor](https://github.com/kcsongor) | Csongor Kiss | [MIT license] |
+| [@kika](https://github.com/kika) | Kirill Pertsev | [MIT license] |
+| [@kl0tl](https://github.com/kl0tl) | Cyril Sobierajewicz | [MIT license] |
+| [@kleeneplus](https://github.com/dgendill) | Dominick Gendill | [MIT license] |
+| [@kRITZCREEK](https://github.com/kRITZCREEK) | Christoph Hegemann | [MIT license] |
+| [@L8D](https://github.com/L8D) | Tenor Biel | [MIT license] |
+| [@legrostdg](https://github.com/legrostdg) | Félix Sipma | [MIT license] |
+| [@LiamGoodacre](https://github.com/LiamGoodacre) | Liam Goodacre | [MIT license] |
+| [@lukerandall](https://github.com/lukerandall) | Luke Randall | [MIT license] |
+| [@lunaris](https://github.com/lunaris) | Will Jones | [MIT license] |
+| [@marcosh](https://github.com/marcosh) | Marco Perone | [MIT license] |
+| [@matthew-hilty](https://github.com/matthew-hilty) | Matthew Hilty | [MIT license] |
+| [@matthewleon](https://github.com/matthewleon) | Matthew Leon | [MIT license] |
+| [@mcoffin](https://github.com/mcoffin) | Matt Coffin | [MIT license] |
+| [@mgmeier](https://github.com/mgmeier) | Michael Gilliland | [MIT license] |
+| [@mhcurylo](https://github.com/mhcurylo) | Mateusz Curylo | [MIT license] |
+| [@mhmdanas](https://github.com/mhmdanas) | Mohammed Anas | [MIT license] |
+| [@michaelficarra](https://github.com/michaelficarra) | Michael Ficarra | [MIT license] |
+| [@MichaelXavier](https://github.com/MichaelXavier) | Michael Xavier | [MIT license] |
+| [@mikesol](https://github.com/mikesol) | Mike Solomon | [MIT license] |
+| [@milesfrain](https://github.com/milesfrain) | Miles Frain | [MIT license] |
+| [@MiracleBlue](https://github.com/MiracleBlue) | Nicholas Kircher | [MIT license] |
+| [@mjgpy3](https://github.com/mjgpy3) | Michael Gilliland | [MIT license] |
+| [@mjrussell](https://github.com/mjrussell) | Matthew Russell | [MIT license] |
+| [@MonoidMusician](https://github.com/MonoidMusician) | Verity Scheel | [MIT license] |
+| [@mpietrzak](https://github.com/mpietrzak) | Maciej Pietrzak | [MIT license] |
+| [@mrhania](https://github.com/mrhania) | Łukasz Hanuszczak | [MIT license] |
+| [@mrkgnao](https://github.com/mrkgnao) | Soham Chowdhury | [MIT license] |
+| [@natefaubion](https://github.com/natefaubion) | Nathan Faubion | [MIT license] |
+| [@ncaq](https://github.com/ncaq) | ncaq | [MIT license] |
+| [@NickMolloy](https://github.com/NickMolloy) | Nick Molloy | [MIT license] |
+| [@nicodelpiano](https://github.com/nicodelpiano) | Nicolas Del Piano | [MIT license] |
+| [@noraesae](https://github.com/noraesae) | Hyunje Jun | [MIT license] |
+| [@nullobject](https://github.com/nullobject) | Josh Bassett | [MIT license] |
+| [@osa1](https://github.com/osa1) | Ömer Sinan Ağacan | [MIT license] |
+| [@ozkutuk](https://github.com/ozkutuk) | Berk Özkütük | [MIT license] |
+| [@paf31](https://github.com/paf31) | Phil Freeman | [MIT license] |
+| [@parsonsmatt](https://github.com/parsonsmatt) | Matt Parsons | [MIT license] |
+| [@passy](https://github.com/passy) | Pascal Hartig | [MIT license] |
+| [@paulyoung](https://github.com/paulyoung) | Paul Young | [MIT license] |
+| [@pelotom](https://github.com/pelotom) | Thomas Crockett | [MIT license] |
+| [@peterbecich](https://github.com/peterbecich) | Peter Becich | [MIT license] |
+| [@phadej](https://github.com/phadej) | Oleg Grenrus | [MIT license] |
+| [@phiggins](https://github.com/phiggins) | Pete Higgins | [MIT license] |
+| [@philopon](https://github.com/philopon) | Hirotomo Moriwaki | [MIT license] |
+| [@pseudonom](https://github.com/pseudonom) | Eric Easley | [MIT license] |
+| [@ptrfrncsmrph](https://github.com/ptrfrncsmrph) | Peter Murphy | [MIT license] |
+| [@PureFunctor](https://github.com/PureFunctor), [@sjpgarcia](https://github.com/sjpgarcia) | Justin Garcia | [MIT license] |
+| [@quesebifurcan](https://github.com/quesebifurcan) | Fredrik Wallberg | [MIT license] |
+| [@radrow](https://github.com/radrow) | Radosław Rowicki | [MIT license] |
+| [@rgrinberg](https://github.com/rgrinberg) | Rudi Grinberg | [MIT license] |
+| [@rhendric](https://github.com/rhendric) | Ryan Hendrickson | [MIT license] |
+| [@rightfold](https://github.com/rightfold) | rightfold | [MIT license] |
+| [@rndnoise](https://www.github.com/rndnoise) | rndnoise | [MIT license] |
+| [@robdaemon](https://github.com/robdaemon) | Robert Roland | [MIT license] |
+| [@RossMeikleham](https://github.com/RossMeikleham) | Ross Meikleham | [MIT license] |
+| [@Rufflewind](https://github.com/Rufflewind) | Phil Ruffwind | [MIT license] |
+| [@rvion](https://github.com/rvion) | Rémi Vion | [MIT license] |
+| [@RyanGlScott](https://github.com/RyanGlScott) | Ryan Scott | [MIT license] |
+| [@Saulukass](https://github.com/Saulukass) | Saulius Skliutas | [MIT license] |
+| [@sd-yip](https://github.com/sd-yip) | Nicholas Yip | [MIT license] |
+| [@sebastiaanvisser](https://github.com/sebastiaanvisser) | Sebastiaan Visser | [MIT license] |
+| [@sectore](https://github.com/sectore) | Jens Krause | [MIT license] |
+| [@senju](https://github.com/senju) | senju | [MIT license] |
+| [@seungha-kim](https://github.com/seungha-kim) | Seungha Kim | [MIT license] |
+| [@sharkdp](https://github.com/sharkdp) | David Peter | [MIT license] |
+| [@sigma-andex](https://github.com/sigma-andex) | Jan Schulte | [MIT license] |
+| [@simonyangme](https://github.com/simonyangme) | Simon Yang | [MIT license] |
+| [@sloosch](https://github.com/sloosch) | Simon Looschen | [MIT license] |
+| [@sometimes-i-send-pull-requests](https://github.com/sometimes-i-send-pull-requests) | Alexander Kirchhoff | [MIT license] |
+| [@soupi](https://github.com/soupi) | Gil Mizrahi | [MIT license] |
+| [@stefanholzmueller](https://github.com/stefanholzmueller) | Stefan Holzmüller | [MIT license] |
+| [@sztupi](https://github.com/sztupi) | Attila Sztupak | [MIT license] |
+| [@taktoa](https://github.com/taktoa) | Remy Goldschmidt | [MIT license] |
+| [@taku0](https://github.com/taku0) | taku0 | [MIT license] |
+| [@tfausak](https://github.com/tfausak) | Taylor Fausak | [MIT license] |
+| [@thimoteus](https://github.com/Thimoteus) | thimoteus | [MIT license] |
+| [@thomashoneyman](https://github.com/thomashoneyman) | Thomas Honeyman | [MIT license] |
+| [@thoradam](https://github.com/thoradam) | Thor Adam | [MIT license] |
+| [@tmcgilchrist](https://github.com/tmcgilchrist) | Tim McGilchrist | [MIT license] |
+| [@trofi](https://github.com/trofi) | Sergei Trofimovich | [MIT license] |
+| [@utkarshkukreti](https://github.com/utkarshkukreti) | Utkarsh Kukreti | [MIT license] |
+| [@vkorablin](https://github.com/vkorablin) | Vladimir Korablin | [MIT license] |
+| [@vladciobanu](https://github.com/vladciobanu) | Vladimir Ciobanu | [MIT license] |
+| [@wclr](https://github.com/wclr) | Alex Osh | [MIT license] |
+| [@woody88](https://github.com/woody88) | Woodson Delhia | [MIT license] |
+| [@xgrommx](https://github.com/xgrommx) | Denis Stoyanov | [MIT license] |
+| [@zudov](https://github.com/zudov) | Konstantin Zudov | [MIT license] |
+| [@roryc89](https://github.com/roryc89) | Rory Campbell | [MIT license] |
+| [@drathier](https://github.com/drathier) | Drathier | [MIT license] |
+
### Contributors using Modified Terms
| Username | Name | Terms |
| :------- | :--- | :------ |
-| [@charleso](https://github.com/charleso) | Charles O'Farrell | My existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright Charles O'Farrell, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). |
-| [@chrissmoak](https://github.com/chrissmoak) | Chris Smoak | My existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright Chris Smoak, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). |
-| [@dylex](https://github.com/dylex) | Dylan Simon | My existing and all future contributions to the PureScript compiler until further notice are Copyright Dylan Simon, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). |
-| [@leighman](http://github.com/leighman) | Jack Leigh | My existing contributions and all future contributions until further notice are Copyright Jack Leigh, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). |
+| [@charleso](https://github.com/charleso) | Charles O'Farrell | My existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright Charles O'Farrell, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. |
+| [@chrissmoak](https://github.com/chrissmoak) | Chris Smoak | My existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright Chris Smoak, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. |
+| [@citizengabe](https://github.com/citizengabe) | Gabe Johnson | All contributions I have or will make using the @citizengabe GitHub account are during employment at [CitizenNet Inc.](#companies) who owns the copyright. All of my existing or future contributions made using the @gabejohnson GitHub account are personal contributions and subject to the terms specified [above](#contributors-using-standard-terms). |
+| [@dylex](https://github.com/dylex) | Dylan Simon | My existing and all future contributions to the PureScript compiler until further notice are Copyright Dylan Simon, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. |
+| [@leighman](http://github.com/leighman) | Jack Leigh | My existing contributions and all future contributions until further notice are Copyright Jack Leigh, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. |
| [@nagisa](https://github.com/nagisa) | nagisa | I hereby release my [only contribution](https://github.com/purescript/purescript/commit/80287a5d0de619862d3b4cda9c1ee276d18fdcd8) into public domain. |
| [@puffnfresh](https://github.com/puffnfresh) | Brian McKenna | All contributions I made during June 2015 were during employment at [SlamData, Inc.](#companies) who owns the copyright. I assign copyright of all my personal contributions before June 2015 to the owners of the PureScript compiler. |
+| [@nwolverson](https://github.com/nwolverson) | Nicholas Wolverson | Contributions I made during March 2020 until further notice are in employment of [Id3as Company](#companies), who own the copyright. All other contributions remain Copyright Nicholas Wolverson, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. |
+
### Companies
| Username | Company | Terms |
| :------- | :--- | :------ |
-| [@slamdata](https://github.com/slamdata) | SlamData, Inc. | Speaking on behalf of SlamData for SlamData employees, our existing contributions and all future contributions to the PureScript compiler are, until further notice, Copyright SlamData Inc., and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). - @jdegoes |
-| [@qfpl](https://github.com/qfpl) | qfpl @ Data61 / CSIRO | Our existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright Data61 / CSIRO, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). - [@lightandlight](https://github.com/lightandlight) |
+| [@citizennet](https://github.com/citizennet) | CitizenNet Inc. | Our existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright CitizenNet Inc., and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. - [@dbenyamin-cn](https://github.com/dbenyamin-cn) |
+| [@slamdata](https://github.com/slamdata) | SlamData, Inc. | Speaking on behalf of SlamData for SlamData employees, our existing contributions and all future contributions to the PureScript compiler are, until further notice, Copyright SlamData Inc., and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. - @jdegoes |
+| [@qfpl](https://github.com/qfpl) | qfpl @ Data61 / CSIRO | Our existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright Data61 / CSIRO, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. - [@lightandlight](https://github.com/lightandlight) |
+| [@id3as](https://github.com/id3as) | id3as-company Ltd. | Speaking on behalf of id3as for id3as employees, our existing contributions and all future contributions to the PureScript compiler are, until further notice, Copyright id3as-company Ltd, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. - @adrianroe |
+| [@aeternity](https://aeternity.com/) | Aeternity Establishment | Our existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright Aeternity Establishment, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license]. |
+
+
+[MIT license]: https://opensource.org/licenses/MIT
diff --git a/INSTALL.md b/INSTALL.md
index 7b4fe9f777..6854652cb3 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -1,21 +1,20 @@
# Installation information
-If you are having difficulty installing the PureScript compiler, feel free to
-ask for help! A good place is the #purescript IRC channel on Freenode, the #purescript channel on [FPChat Slack](https://fpchat-invite.herokuapp.com/), or
-alternatively Stack Overflow.
+If you are having difficulty installing the PureScript compiler, feel free to ask for help! The best places are the [PureScript Discord](https://purescript.org/chat) or [PureScript Discourse](https://discourse.purescript.org).
## Requirements
-The PureScript compiler is built using GHC 8.6.4, and should be able to run on any operating system supported by GHC 8.6.4. In particular:
+The PureScript compiler is built using GHC 9.8.4, and should be able to run on any operating system supported by GHC 9.8.4.
+In particular:
* for Windows users, versions predating Vista are not officially supported,
* for macOS / OS X users, versions predating Mac OS X 10.7 (Lion) are not officially supported.
-See also for more details about the operating systems which GHC 8.6.4 supports.
+See also for more details about the operating systems which GHC 9.8.4 supports.
## Official prebuilt binaries
-Each release comes with prebuilt x86-64 binary bundles for Linux, mac OS, and Windows. Users of other operating systems or architectures will likely need to build the compiler from source; see below.
+Each [release](https://github.com/purescript/purescript/releases) comes with prebuilt x86-64 binary bundles for Linux, mac OS, and Windows. Users of other operating systems or architectures will likely need to build the compiler from source; see below.
To install a binary bundle, simply extract it and place the `purs` executable somewhere on your PATH.
@@ -25,7 +24,8 @@ There are several other distributions of the PureScript compiler available, whic
* NPM: `npm install -g purescript`
* Homebrew (for macOS): `brew install purescript`
-* [PSVM](https://github.com/ThomasCrevoisier/psvm-js): `npm install -g psvm`
+* FreeBSD binary packages: `pkg install hs-purescript`
+* GNU Guix: `guix install purescript`
## Compiling from source
@@ -44,13 +44,31 @@ If you don't have stack installed, please see the [stack install documentation](
## The "curses" library
-The PureScript REPL depends on the `curses` library (via the Haskell package
-`terminfo`). If you are having difficulty running the compiler, it may be
-because the `curses` library is missing.
+Prior to version v0.14.2, the PureScript REPL depends on the `curses` library
+by default (via the Haskell package `terminfo`). If you are having difficulty
+running the compiler, it may be because the `curses` library is missing. This
+problem may appear as a `libtinfo` error:
+```
+error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
+```
On Linux, you will probably need to install `ncurses` manually. On Ubuntu, for
example, this can be done by running:
+```
+$ sudo apt install libtinfo5 libncurses5-dev
+```
+As of v0.14.2, this should no longer be necessary if you are using the prebuilt
+binaries or building the compiler from source with the default configuration.
+However, you can still opt into using `curses` by setting the Haskeline
+`terminfo` flag to `true`. This may improve the REPL experience slightly - for
+example, by providing better editing of long input lines.
+
+## EACCES error
+
+If you encounter this error while trying to install via `npm`:
```
-$ sudo apt-get install libncurses5-dev
+Error: EACCES: permission denied
```
+
+The best solution is to install [Node.js and npm via a node version manager](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-version-manager-to-install-nodejs-and-npm). This error is due to permissions issues when installing packages globally. You can read more about this error in npm's guide to [resolving EACCES permissions errors when installing packages globally](https://docs.npmjs.com/getting-started/fixing-npm-permissions).
diff --git a/LICENSE b/LICENSE
index b81d5fcbd7..6b8251ded8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -12,46 +12,63 @@ Redistribution and use in source and binary forms, with or without modification,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+PureScript executables for Linux distributed under the Releases tab of its GitHub
+repository (https://github.com/purescript/purescript) may be statically-linked to
+a version of GMP, licensed under the GNU Lesser General Public License Version 3,
+29 June 2007.
+
+The full source code of PureScript is available in the aforementioned repository,
+https://github.com/purescript/purescript, allowing you to modify and relink the
+GMP portion if desired.
+
+GMP source code is available at: https://gmplib.org/
+
+A copy of the LGPL is reproduced below.
+
PureScript uses the following Haskell library packages. Their license files follow.
Cabal
+ Cabal-syntax
Glob
- SHA
+ OneTuple
+ QuickCheck
+ StateVar
+ adjunctions
aeson
aeson-better-errors
alex
ansi-terminal
- ansi-wl-pprint
- appar
+ ansi-terminal-types
array
+ assoc
async
attoparsec
auto-update
base
- base-compat
base-orphans
- base64-bytestring
basement
+ bifunctors
binary
+ bitvec
blaze-builder
blaze-html
blaze-markup
+ boring
bower-json
boxes
- bsb-http-chunked
- byteorder
bytestring
- bytestring-builder
- cabal-doctest
- case-insensitive
+ call-stack
+ cborg
+ character-ps
cheapskate
clock
colour
+ comonad
conduit
conduit-extra
constraints
containers
- cookie
+ contravariant
cryptonite
css-text
data-default
@@ -59,87 +76,94 @@ PureScript uses the following Haskell library packages. Their license files foll
data-default-instances-containers
data-default-instances-dlist
data-default-instances-old-locale
+ data-fix
data-ordlist
deepseq
directory
+ distributive
dlist
easy-file
edit-distance
- enclosed-exceptions
- entropy
exceptions
fast-logger
file-embed
filepath
- fsnotify
- ghc-boot-th
+ free
+ generically
+ ghc-bignum
ghc-prim
+ half
happy
hashable
haskeline
- hinotify
- http-date
- http-types
- http2
+ indexed-traversable
+ indexed-traversable-instances
+ integer-conversion
integer-gmp
integer-logarithms
- iproute
+ invariant
+ kan-extensions
language-javascript
+ lens
lifted-async
lifted-base
memory
- microlens
- microlens-ghc
- microlens-mtl
- microlens-platform
- microlens-th
- mime-types
monad-control
monad-logger
monad-loops
mono-traversable
+ monoidal-containers
mtl
mtl-compat
network
- network-byte-order
network-uri
+ newtype
old-locale
old-time
optparse-applicative
+ os-string
parallel
parsec
- pattern-arrows
pretty
+ prettyprinter
+ prettyprinter-ansi-terminal
primitive
process
+ profunctors
protolude
- psqueues
random
+ reflection
regex-base
regex-tdfa
resourcet
safe
scientific
+ semialign
+ semigroupoids
semigroups
- shelly
- simple-sendfile
+ serialise
sourcemap
split
+ splitmix
stm
stm-chans
streaming-commons
+ strict
stringsearch
syb
- system-fileio
- system-filepath
tagged
tagsoup
+ tasty
template-haskell
terminfo
text
+ text-iso8601
+ text-short
th-abstraction
+ th-compat
+ these
time
- time-locale-compat
+ time-compat
transformers
transformers-base
transformers-compat
@@ -152,25 +176,58 @@ PureScript uses the following Haskell library packages. Their license files foll
unordered-containers
utf8-string
uuid-types
- vault
vector
vector-algorithms
+ vector-stream
void
- wai
- wai-app-static
- wai-extra
- wai-logger
- wai-websockets
- warp
- websockets
- word8
+ witherable
xss-sanitize
zlib
Cabal LICENSE file:
- Copyright (c) 2003-2017, Cabal Development Team.
+ Copyright (c) 2003-2023, Cabal Development Team.
+ See the AUTHORS file for the full list of copyright holders.
+
+ See */LICENSE for the copyright holders of the subcomponents.
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Isaac Jones nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Cabal-syntax LICENSE file:
+
+ Copyright (c) 2003-2023, Cabal Development Team.
See the AUTHORS file for the full list of copyright holders.
+
+ See */LICENSE for the copyright holders of the subcomponents.
+
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -232,41 +289,139 @@ Glob LICENSE file:
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-SHA LICENSE file:
+OneTuple LICENSE file:
- Copyright (c) 2008, Galois, Inc.
+
+ Copyright (c) 2008, John A. Dorsey.
All rights reserved.
+ Redistribution and use of this software in source and binary forms,
+ with or without modification, are permitted provided that the
+ following conditions are met:
+
+ * Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the
+ following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+ * Neither the name of John Dorsey nor the names of its
+ contributors may be used to endorse or promote products
+ derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+QuickCheck LICENSE file:
+
+ (The following is the 3-clause BSD license.)
+
+ Copyright (c) 2000-2019, Koen Claessen
+ Copyright (c) 2006-2008, Björn Bringert
+ Copyright (c) 2009-2019, Nick Smallbone
+
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
+ modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the Galois, Inc. nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ - Neither the names of the copyright owners nor the names of the
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+StateVar LICENSE file:
+
+ Copyright (c) 2014-2015, Edward Kmett
+ Copyright (c) 2009-2021, Sven Panne
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the author nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+adjunctions LICENSE file:
+
+ Copyright 2011-2014 Edward Kmett
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
aeson LICENSE file:
- Copyright (c) 2011, MailRank, Inc.
+ Copyright (c) 2011, MailRank, Inc. 2014-2021 Aeson project contributors
All rights reserved.
@@ -358,85 +513,56 @@ ansi-terminal LICENSE file:
Copyright (c) 2008, Maximilian Bolingbroke
All rights reserved.
- Redistribution and use in source and binary forms, with or without modification, are permitted
- provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of
- conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of
- conditions and the following disclaimer in the documentation and/or other materials
- provided with the distribution.
- * Neither the name of Maximilian Bolingbroke nor the names of other contributors may be used to
- endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
- IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-ansi-wl-pprint LICENSE file:
-
- Copyright 2008, Daan Leijen and Max Bolingbroke. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+ * Neither the name of Maximilian Bolingbroke nor the names of other contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
- This software is provided by the copyright holders "as is" and any
- express or implied warranties, including, but not limited to, the
- implied warranties of merchantability and fitness for a particular
- purpose are disclaimed. In no event shall the copyright holders be
- liable for any direct, indirect, incidental, special, exemplary, or
- consequential damages (including, but not limited to, procurement of
- substitute goods or services; loss of use, data, or profits; or
- business interruption) however caused and on any theory of liability,
- whether in contract, strict liability, or tort (including negligence
- or otherwise) arising in any way out of the use of this software, even
- if advised of the possibility of such damage.
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-appar LICENSE file:
+ansi-terminal-types LICENSE file:
- Copyright (c) 2009, IIJ Innovation Institute Inc.
+ Copyright (c) 2008, Maximilian Bolingbroke
All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Maximilian Bolingbroke nor the names of other contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
array LICENSE file:
@@ -524,9 +650,10 @@ array LICENSE file:
-----------------------------------------------------------------------------
-async LICENSE file:
- Copyright (c) 2012, Simon Marlow
+assoc LICENSE file:
+
+ Copyright (c) 2017, Oleg Grenrus
All rights reserved.
@@ -541,7 +668,7 @@ async LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Simon Marlow nor the names of other
+ * Neither the name of Oleg Grenrus nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -557,25 +684,58 @@ async LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-attoparsec LICENSE file:
+async LICENSE file:
- Copyright (c) Lennart Kolmodin
+ Copyright (c) 2012, Simon Marlow
All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
+ modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
- 3. Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
+ * Neither the name of Simon Marlow nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+attoparsec LICENSE file:
+
+ Copyright (c) Lennart Kolmodin
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the author nor the names of his contributors
+ may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
@@ -699,28 +859,6 @@ base LICENSE file:
-----------------------------------------------------------------------------
-base-compat LICENSE file:
-
- Copyright (c) 2012-2018 Simon Hengel and Ryan Scott
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-
base-orphans LICENSE file:
Copyright (c) 2015-2017 Simon Hengel , João Cristóvão , Ryan Scott
@@ -744,69 +882,65 @@ base-orphans LICENSE file:
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-base64-bytestring LICENSE file:
+basement LICENSE file:
- Copyright (c) 2010 Bryan O'Sullivan
+ Copyright (c) 2015-2017 Vincent Hanquez
+ Copyright (c) 2017-2019 Foundation Maintainers
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
-
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
-
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
3. Neither the name of the author nor the names of his contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
-basement LICENSE file:
+bifunctors LICENSE file:
- Copyright (c) 2015-2017 Vincent Hanquez
- Copyright (c) 2017 Foundation Maintainers
+ Copyright 2008-2016 Edward Kmett
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
+
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- 3. Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS AS IS'' AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
binary LICENSE file:
@@ -841,9 +975,9 @@ binary LICENSE file:
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-blaze-builder LICENSE file:
+bitvec LICENSE file:
- Copyright Jasper Van der Jeugt 2010, Simon Meier 2010 & 2011
+ Copyright (c) 2019-2022 Andrew Lelechenko, 2012-2016 James Cook
All rights reserved.
@@ -858,9 +992,9 @@ blaze-builder LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Jasper Van der Jeugt nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
+ * The names of the contributors may not be used to endorse may be
+ used to endorse or promote products derived from this software
+ without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -874,9 +1008,9 @@ blaze-builder LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-blaze-html LICENSE file:
+blaze-builder LICENSE file:
- Copyright Jasper Van der Jeugt 2010
+ Copyright Jasper Van der Jeugt 2010, Simon Meier 2010 & 2011
All rights reserved.
@@ -907,7 +1041,7 @@ blaze-html LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-blaze-markup LICENSE file:
+blaze-html LICENSE file:
Copyright Jasper Van der Jeugt 2010
@@ -940,62 +1074,9 @@ blaze-markup LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-bower-json LICENSE file:
-
- Copyright (c) 2015 Harry Garrood
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-boxes LICENSE file:
-
- Copyright (c) Brent Yorgey 2008
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. Neither the name of the author nor the names of other contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- All other rights are reserved.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
-bsb-http-chunked LICENSE file:
+blaze-markup LICENSE file:
- Copyright Jasper Van der Jeugt 2010, Simon Meier 2010 & 2011
+ Copyright Jasper Van der Jeugt 2010
All rights reserved.
@@ -1026,9 +1107,9 @@ bsb-http-chunked LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-byteorder LICENSE file:
+boring LICENSE file:
- Copyright 2009, Antoine Latter
+ Copyright (c) 2017, Oleg Grenrus
All rights reserved.
@@ -1043,7 +1124,7 @@ byteorder LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of the author nor the names of other
+ * Neither the name of Oleg Grenrus nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -1059,12 +1140,66 @@ byteorder LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+bower-json LICENSE file:
+
+ Copyright (c) 2015 Harry Garrood
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+boxes LICENSE file:
+
+ Copyright (c) Brent Yorgey 2008
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the author nor the names of other contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ All other rights are reserved.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
bytestring LICENSE file:
Copyright (c) Don Stewart 2005-2009
(c) Duncan Coutts 2006-2015
(c) David Roundy 2003-2005
(c) Simon Meier 2010-2011
+ (c) Koz Ross 2021
All rights reserved.
@@ -1092,14 +1227,39 @@ bytestring LICENSE file:
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-bytestring-builder LICENSE file:
+call-stack LICENSE file:
+
+ Copyright (c) 2016-2021 Simon Hengel
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+cborg LICENSE file:
- Copyright Jasper Van der Jeugt 2010, Simon Meier 2010-2013
+ Copyright (c) 2015-2017 Duncan Coutts,
+ 2015-2017 Well-Typed LLP,
+ 2015 IRIS Connect Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ modification, are permitted provided that the following conditions are
+ met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@@ -1109,7 +1269,7 @@ bytestring-builder LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Jasper Van der Jeugt nor the names of other
+ * Neither the name of Duncan Coutts nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -1125,9 +1285,9 @@ bytestring-builder LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-cabal-doctest LICENSE file:
+character-ps LICENSE file:
- Copyright (c) 2017, Oleg Grenrus
+ Copyright (c) 2023, Oleg Grenrus
All rights reserved.
@@ -1158,48 +1318,14 @@ cabal-doctest LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-case-insensitive LICENSE file:
+cheapskate LICENSE file:
- Copyright (c) 2011-2013 Bas van Dijk
+ Copyright (c) 2013, John MacFarlane
All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- * The name of Bas van Dijk and the names of contributors may NOT
- be used to endorse or promote products derived from this
- software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-cheapskate LICENSE file:
-
- Copyright (c) 2013, John MacFarlane
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@@ -1227,8 +1353,7 @@ cheapskate LICENSE file:
clock LICENSE file:
- Copyright (c) 2009-2012, Cetin Sert
- Copyright (c) 2010, Eugene Kirpichov
+ Copyright (c) 2009-2022, Clock Contributors
All rights reserved.
@@ -1283,6 +1408,36 @@ colour LICENSE file:
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+comonad LICENSE file:
+
+ Copyright 2008-2014 Edward Kmett
+ Copyright 2004-2008 Dave Menendez
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
conduit LICENSE file:
Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
@@ -1392,28 +1547,38 @@ containers LICENSE file:
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
-cookie LICENSE file:
+contravariant LICENSE file:
- Copyright (c) 2010 Michael Snoyman, http://www.yesodweb.com/
+ Copyright 2007-2015 Edward Kmett
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
+ All rights reserved.
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the author nor the names of his contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
cryptonite LICENSE file:
@@ -1471,148 +1636,201 @@ css-text LICENSE file:
data-default LICENSE file:
- Copyright (c) 2013 Lukas Mai
+ Copyright (c) 2013, Lukas Mai
All rights reserved.
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Lukas Mai nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data-default-class LICENSE file:
- Copyright (c) 2013 Lukas Mai
+ Copyright (c) 2013, Lukas Mai
All rights reserved.
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Lukas Mai nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data-default-instances-containers LICENSE file:
- Copyright (c) 2013 Lukas Mai
+ Copyright (c) 2013, Lukas Mai
All rights reserved.
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED BY LUKAS MAI AND CONTRIBUTORS "AS IS" AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Lukas Mai nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data-default-instances-dlist LICENSE file:
- Copyright (c) 2013 Lukas Mai
+ Copyright (c) 2013, Lukas Mai
All rights reserved.
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED BY LUKAS MAI AND CONTRIBUTORS "AS IS" AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Lukas Mai nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data-default-instances-old-locale LICENSE file:
- Copyright (c) 2013 Lukas Mai
+ Copyright (c) 2013, Lukas Mai
All rights reserved.
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED BY LUKAS MAI AND CONTRIBUTORS "AS IS" AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Lukas Mai nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+data-fix LICENSE file:
+
+ Copyright Anton Kholomiov 2010
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Anton Kholomiov nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data-ordlist LICENSE file:
@@ -1735,39 +1953,65 @@ directory LICENSE file:
-----------------------------------------------------------------------------
-dlist LICENSE file:
+distributive LICENSE file:
- Copyright (c) 2006-2009 Don Stewart, 2013-2016 Sean Leather
+ Copyright 2011-2016 Edward Kmett
All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
+ modification, are permitted provided that the following conditions
+ are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
- * Neither the name of Don Stewart nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+dlist LICENSE file:
+
+ Copyright © 2006-2009 Don Stewart, 2013-2020 Sean Leather, contributors
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the copyright holders nor the names of other contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
easy-file LICENSE file:
@@ -1826,62 +2070,6 @@ edit-distance LICENSE file:
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-enclosed-exceptions LICENSE file:
-
- Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-entropy LICENSE file:
-
- Copyright (c) Thomas DuBuisson
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
exceptions LICENSE file:
Copyright 2013-2015 Edward Kmett
@@ -1978,7 +2166,7 @@ file-embed LICENSE file:
filepath LICENSE file:
- Copyright Neil Mitchell 2005-2018.
+ Copyright Neil Mitchell 2005-2020.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -2009,9 +2197,40 @@ filepath LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-fsnotify LICENSE file:
+free LICENSE file:
+
+ Copyright 2008-2013 Edward Kmett
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the author nor the names of his contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
- Copyright (c) 2012, Mark Dittmer
+generically LICENSE file:
All rights reserved.
@@ -2026,7 +2245,7 @@ fsnotify LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Mark Dittmer nor the names of other
+ * Neither the name of Herbert Valerio Riedel nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -2042,11 +2261,11 @@ fsnotify LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-ghc-boot-th LICENSE file:
+ghc-bignum LICENSE file:
The Glasgow Haskell Compiler License
- Copyright 2002, The University Court of the University of Glasgow.
+ Copyright 2020, The University Court of the University of Glasgow.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -2141,6 +2360,35 @@ ghc-prim LICENSE file:
be a definition of the Haskell 98 Language.
+half LICENSE file:
+
+ Copyright 2014 Edward Kmett
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
happy LICENSE file:
The Happy License
@@ -2209,33 +2457,36 @@ hashable LICENSE file:
haskeline LICENSE file:
- Copyright 2007-2009, Judah Jacobson.
- All Rights Reserved.
+ Copyright 2007 Judah Jacobson
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- - Redistribution of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
- - Redistribution in binary form must reproduce the above copyright notice,
+ 2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTORS BE LIABLE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-hinotify LICENSE file:
+indexed-traversable LICENSE file:
- Copyright (c) Lennart Kolmodin
+ Copyright 2012-2016 Edward Kmett
All rights reserved.
@@ -2250,12 +2501,8 @@ hinotify LICENSE file:
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- 3. Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
@@ -2266,42 +2513,38 @@ hinotify LICENSE file:
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-http-date LICENSE file:
+indexed-traversable-instances LICENSE file:
+
+ Copyright 2012-2016 Edward Kmett
- Copyright (c) 2009, IIJ Innovation Institute Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-http-types LICENSE file:
+integer-conversion LICENSE file:
- Copyright (c) 2011, Aristid Breitkreuz
- Copyright (c) 2011, Michael Snoyman
+ Copyright (c) 2023, Oleg Grenrus
All rights reserved.
@@ -2316,7 +2559,7 @@ http-types LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Aristid Breitkreuz nor the names of other
+ * Neither the name of Oleg Grenrus nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -2332,38 +2575,6 @@ http-types LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-http2 LICENSE file:
-
- Copyright (c) 2013, IIJ Innovation Institute Inc.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
integer-gmp LICENSE file:
Copyright (c) 2014, Herbert Valerio Riedel
@@ -2416,35 +2627,62 @@ integer-logarithms LICENSE file:
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-iproute LICENSE file:
+invariant LICENSE file:
+
+ Copyright (c) 2012-2017, University of Kansas
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+kan-extensions LICENSE file:
+
+ Copyright 2008-2016 Edward Kmett
- Copyright (c) 2009, IIJ Innovation Institute Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the author nor the names of his contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
@@ -2481,6 +2719,35 @@ language-javascript LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+lens LICENSE file:
+
+ Copyright 2012-2016 Edward Kmett
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
lifted-async LICENSE file:
Copyright (c) 2012-2017, Mitsutoshi Aoe
@@ -2578,34 +2845,31 @@ memory LICENSE file:
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-microlens LICENSE file:
-
- Copyright (c) 2013-2016 Edward Kmett,
- 2015-2016 Artyom Kazak,
- 2018 Monadfix
+monad-control LICENSE file:
+ Copyright © 2010, Bas van Dijk, Anders Kaseorg
All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ modification, are permitted provided that the following conditions are
+ met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
+ • Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
+ • Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
- * Neither the name of Monadfix nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
+ • Neither the name of the author nor the names of other contributors
+ may be used to endorse or promote products derived from this
+ software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@@ -2613,11 +2877,55 @@ microlens LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-microlens-ghc LICENSE file:
+monad-logger LICENSE file:
+
+ Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+mono-traversable LICENSE file:
+
+ Copyright (c) 2013 Michael Snoyman, http://www.fpcomplete.com/
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+monoidal-containers LICENSE file:
- Copyright (c) 2013-2016 Edward Kmett,
- 2015-2016 Artyom Kazak,
- 2018 Monadfix
+ Copyright (c) 2015, Ben Gamari
All rights reserved.
@@ -2632,7 +2940,7 @@ microlens-ghc LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Monadfix nor the names of other
+ * Neither the name of Ben Gamari nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -2648,10 +2956,43 @@ microlens-ghc LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-microlens-mtl LICENSE file:
+mtl LICENSE file:
+
+ The Glasgow Haskell Compiler License
+
+ Copyright 2004, The University Court of the University of Glasgow.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither name of the University nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+ GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+mtl-compat LICENSE file:
- Copyright (c) 2013-2016 Edward Kmett,
- 2015-2016 Artyom
+ Copyright (c) 2015-2017, Ryan Scott
All rights reserved.
@@ -2666,7 +3007,7 @@ microlens-mtl LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Artyom nor the names of other
+ * Neither the name of Ryan Scott nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -2682,181 +3023,10 @@ microlens-mtl LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-microlens-platform LICENSE file:
-
- Copyright (c) 2012-2016 Edward Kmett,
- 2015-2016 Artyom Kazak,
- 2018 Monadfix
+network LICENSE file:
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- * Neither the name of Monadfix nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-microlens-th LICENSE file:
-
- Copyright (c) 2013-2016 Eric Mertens, Edward Kmett, Artyom
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- * Neither the name of Artyom nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-mime-types LICENSE file:
-
- Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-monad-control LICENSE file:
-
- Copyright © 2010, Bas van Dijk, Anders Kaseorg
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- • Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- • Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- • Neither the name of the author nor the names of other contributors
- may be used to endorse or promote products derived from this
- software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-monad-logger LICENSE file:
-
- Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-mono-traversable LICENSE file:
-
- Copyright (c) 2013 Michael Snoyman, http://www.fpcomplete.com/
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-mtl LICENSE file:
-
- The Glasgow Haskell Compiler License
-
- Copyright 2004, The University Court of the University of Glasgow.
- All rights reserved.
+ Copyright (c) 2002-2010, The University Court of the University of Glasgow.
+ Copyright (c) 2007-2010, Johan Tibell
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -2885,40 +3055,7 @@ mtl LICENSE file:
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
-mtl-compat LICENSE file:
-
- Copyright (c) 2015, Ryan Scott
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- * Neither the name of Ryan Scott nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-network LICENSE file:
+network-uri LICENSE file:
Copyright (c) 2002-2010, The University Court of the University of Glasgow.
Copyright (c) 2007-2010, Johan Tibell
@@ -2950,9 +3087,10 @@ network LICENSE file:
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
-network-byte-order LICENSE file:
+newtype LICENSE file:
- Copyright (c) 2017, Kazu Yamamoto
+ Copyright (c) 2011, Darius Jahandarie
+ 2019, Herbert Valerio Riedel
All rights reserved.
@@ -2967,7 +3105,7 @@ network-byte-order LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Kazu Yamamoto nor the names of other
+ * Neither the name of Darius Jahandarie nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -2983,38 +3121,6 @@ network-byte-order LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-network-uri LICENSE file:
-
- Copyright (c) 2002-2010, The University Court of the University of Glasgow.
- Copyright (c) 2007-2010, Johan Tibell
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- - Neither name of the University nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
- GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- DAMAGE.
-
old-locale LICENSE file:
This library (libraries/base) is derived from code from two
@@ -3180,32 +3286,65 @@ optparse-applicative LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-parallel LICENSE file:
-
- This library (libraries/parallel) is derived from code from
- the GHC project which is largely (c) The University of
- Glasgow, and distributable under a BSD-style license (see below).
-
- -----------------------------------------------------------------------------
-
- The Glasgow Haskell Compiler License
+os-string LICENSE file:
- Copyright 2004, The University Court of the University of Glasgow.
+ Copyright Neil Mitchell 2005-2020.
All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ modification, are permitted provided that the following conditions are
+ met:
- - Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- - Neither name of the University nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Neil Mitchell nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+parallel LICENSE file:
+
+ This library (libraries/parallel) is derived from code from
+ the GHC project which is largely (c) The University of
+ Glasgow, and distributable under a BSD-style license (see below).
+
+ -----------------------------------------------------------------------------
+
+ The Glasgow Haskell Compiler License
+
+ Copyright 2004, The University Court of the University of Glasgow.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither name of the University nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
@@ -3246,29 +3385,6 @@ parsec LICENSE file:
negligence or otherwise) arising in any way out of the use of this software,
even if advised of the possibility of such damage.
-pattern-arrows LICENSE file:
-
- The MIT License (MIT)
-
- Copyright (c) 2013 Phil Freeman
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of
- this software and associated documentation files (the "Software"), to deal in
- the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- the Software, and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
pretty LICENSE file:
This library (libraries/pretty) is derived from code from
@@ -3311,6 +3427,58 @@ pretty LICENSE file:
-----------------------------------------------------------------------------
+prettyprinter LICENSE file:
+
+ Copyright 2008, Daan Leijen and Max Bolingbroke, 2016 David Luposchainsky. All
+ rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ This software is provided by the copyright holders "as is" and any express or
+ implied warranties, including, but not limited to, the implied warranties of
+ merchantability and fitness for a particular purpose are disclaimed. In no event
+ shall the copyright holders be liable for any direct, indirect, incidental,
+ special, exemplary, or consequential damages (including, but not limited to,
+ procurement of substitute goods or services; loss of use, data, or profits; or
+ business interruption) however caused and on any theory of liability, whether in
+ contract, strict liability, or tort (including negligence or otherwise) arising
+ in any way out of the use of this software, even if advised of the possibility
+ of such damage.
+
+prettyprinter-ansi-terminal LICENSE file:
+
+ Copyright 2008, Daan Leijen and Max Bolingbroke, 2016 David Luposchainsky. All
+ rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ This software is provided by the copyright holders "as is" and any express or
+ implied warranties, including, but not limited to, the implied warranties of
+ merchantability and fitness for a particular purpose are disclaimed. In no event
+ shall the copyright holders be liable for any direct, indirect, incidental,
+ special, exemplary, or consequential damages (including, but not limited to,
+ procurement of substitute goods or services; loss of use, data, or profits; or
+ business interruption) however caused and on any theory of liability, whether in
+ contract, strict liability, or tort (including negligence or otherwise) arising
+ in any way out of the use of this software, even if advised of the possibility
+ of such damage.
+
primitive LICENSE file:
Copyright (c) 2008-2009, Roman Leshchinskiy
@@ -3410,9 +3578,42 @@ process LICENSE file:
-----------------------------------------------------------------------------
+profunctors LICENSE file:
+
+ Copyright 2011-2015 Edward Kmett
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the author nor the names of his contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
protolude LICENSE file:
- Copyright (c) 2016-2017, Stephen Diehl
+ Copyright (c) 2016-2020, Stephen Diehl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -3432,40 +3633,6 @@ protolude LICENSE file:
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-psqueues LICENSE file:
-
- The Glasgow Haskell Compiler License
-
- Copyright 2004, The University Court of the University of Glasgow.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- - Neither name of the University nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
- GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- DAMAGE.
-
random LICENSE file:
This library (libraries/base) is derived from code from two
@@ -3532,9 +3699,41 @@ random LICENSE file:
-----------------------------------------------------------------------------
-regex-base LICENSE file:
+reflection LICENSE file:
+
+ Copyright (c) 2009-2013 Edward Kmett
+ Copyright (c) 2004 Oleg Kiselyov and Chung-chieh Shan
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Edward Kmett nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- This modile is under this "3 clause" BSD license:
+regex-base LICENSE file:
Copyright (c) 2007, Christopher Kuklewicz
All rights reserved.
@@ -3543,13 +3742,14 @@ regex-base LICENSE file:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
* The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
regex-tdfa LICENSE file:
- This modile is under this "3 clause" BSD license:
+ This module is under this "3 clause" BSD license:
Copyright (c) 2007-2009, Christopher Kuklewicz
All rights reserved.
@@ -3597,7 +3797,7 @@ resourcet LICENSE file:
safe LICENSE file:
- Copyright Neil Mitchell 2007-2018.
+ Copyright Neil Mitchell 2007-2024.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -3661,6 +3861,68 @@ scientific LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+semialign LICENSE file:
+
+ Copyright (c) 2012, C. McCann, 2015-2019 Oleg Grenrus
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of C. McCann nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+semigroupoids LICENSE file:
+
+ Copyright 2011-2015 Edward Kmett
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
semigroups LICENSE file:
Copyright 2011-2015 Edward Kmett
@@ -3690,9 +3952,9 @@ semigroups LICENSE file:
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-shelly LICENSE file:
+serialise LICENSE file:
- Copyright (c) 2017, Petr Rockai
+ Copyright (c) 2017, Duncan Coutts
All rights reserved.
@@ -3707,7 +3969,7 @@ shelly LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Petr Rockai nor the names of other
+ * Neither the name of Duncan Coutts nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -3723,49 +3985,17 @@ shelly LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-simple-sendfile LICENSE file:
+sourcemap LICENSE file:
+
+ Copyright (c) 2012, Chris Done
- Copyright (c) 2009, IIJ Innovation Institute Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
+ modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-sourcemap LICENSE file:
-
- Copyright (c) 2012, Chris Done
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
@@ -3818,6 +4048,39 @@ split LICENSE file:
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
+splitmix LICENSE file:
+
+ Copyright (c) 2017, Oleg Grenrus
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Oleg Grenrus nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
stm LICENSE file:
The Glasgow Haskell Compiler License
@@ -3914,6 +4177,35 @@ streaming-commons LICENSE file:
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+strict LICENSE file:
+
+ Copyright (c) Roman Leshchinskiy 2006-2007
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the author nor the names of his contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
stringsearch LICENSE file:
Copyright (c)2010, Daniel Fischer
@@ -4033,56 +4325,6 @@ syb LICENSE file:
-----------------------------------------------------------------------------
-system-fileio LICENSE file:
-
- Copyright (c) 2011 John Millikin
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation
- files (the "Software"), to deal in the Software without
- restriction, including without limitation the rights to use,
- copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following
- conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
-
-system-filepath LICENSE file:
-
- Copyright (c) 2010 John Millikin
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation
- files (the "Software"), to deal in the Software without
- restriction, including without limitation the rights to use,
- copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following
- conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
-
tagged LICENSE file:
Copyright (c) 2009-2015 Edward Kmett
@@ -4118,7 +4360,7 @@ tagged LICENSE file:
tagsoup LICENSE file:
- Copyright Neil Mitchell 2006-2018.
+ Copyright Neil Mitchell 2006-2019.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -4149,6 +4391,28 @@ tagsoup LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+tasty LICENSE file:
+
+ Copyright (c) 2013 Roman Cheplyaka
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
template-haskell LICENSE file:
@@ -4188,28 +4452,31 @@ template-haskell LICENSE file:
terminfo LICENSE file:
Copyright 2007, Judah Jacobson.
- All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- - Redistribution of source code must retain the above copyright notice,
- this list of conditions and the following disclamer.
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
- - Redistribution in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclamer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTORS BE LIABLE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
text LICENSE file:
@@ -4240,9 +4507,75 @@ text LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+text-iso8601 LICENSE file:
+
+ Copyright (c) 2023 Oleg Grenrus
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the author nor the names of his contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+text-short LICENSE file:
+
+ Copyright (c) 2017, Herbert Valerio Riedel
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Herbert Valerio Riedel nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
th-abstraction LICENSE file:
- Copyright (c) 2017 Eric Mertens
+ Copyright (c) 2017-2020 Eric Mertens
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
@@ -4256,9 +4589,75 @@ th-abstraction LICENSE file:
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
+th-compat LICENSE file:
+
+ Copyright (c) 2020, Ryan Scott
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Ryan Scott nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+these LICENSE file:
+
+ Copyright (c) 2012, C. McCann, 2015-2019 Oleg Grenrus
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of C. McCann nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
time LICENSE file:
- TimeLib is Copyright (c) Ashley Yakeley, 2004-2014. All rights reserved.
+ TimeLib is Copyright (c) Ashley Yakeley and contributors, 2004-2022. All rights reserved.
Certain sections are Copyright 2004, The University Court of the University of Glasgow. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -4269,9 +4668,9 @@ time LICENSE file:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-time-locale-compat LICENSE file:
+time-compat LICENSE file:
- Copyright (c) 2014, Kei Hibino
+ Copyright (c) 2019 time contibutors, Oleg Grenrus
All rights reserved.
@@ -4286,7 +4685,7 @@ time-locale-compat LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Kei Hibino nor the names of other
+ * Neither the name of Oleg Grenrus nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -4424,7 +4823,7 @@ typed-process LICENSE file:
uniplate LICENSE file:
- Copyright Neil Mitchell 2006-2013.
+ Copyright Neil Mitchell 2006-2020.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -4491,6 +4890,8 @@ unix LICENSE file:
unix-compat LICENSE file:
+ BSD 3-Clause License
+
Copyright (c) 2007-2008, Björn Bringert
Copyright (c) 2007-2009, Duncan Coutts
Copyright (c) 2010-2011, Jacob Stanley
@@ -4667,42 +5068,12 @@ uuid-types LICENSE file:
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-vault LICENSE file:
-
- Copyright (c)2011, Heinrich Apfelmus
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- * Neither the name of Heinrich Apfelmus nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
vector LICENSE file:
Copyright (c) 2008-2012, Roman Leshchinskiy
+ 2020-2022, Alexey Kuleshevich
+ 2020-2022, Aleksey Khudyakov
+ 2020-2022, Andrew Lelechenko
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -4732,7 +5103,6 @@ vector LICENSE file:
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
-
vector-algorithms LICENSE file:
Copyright (c) 2015 Dan Doel
@@ -4770,7 +5140,7 @@ vector-algorithms LICENSE file:
------------------------------------------------------------------------------
The code in Data.Array.Vector.Algorithms.Mutable.Optimal is adapted from a C
- algorithm for the same purpose. The folowing is the copyright notice for said
+ algorithm for the same purpose. The following is the copyright notice for said
C code:
Copyright (c) 2004 Paul Hsieh
@@ -4802,6 +5172,41 @@ vector-algorithms LICENSE file:
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
+vector-stream LICENSE file:
+
+ Copyright (c) 2008-2012, Roman Leshchinskiy
+ 2020-2022, Alexey Kuleshevich
+ 2020-2022, Aleksey Khudyakov
+ 2020-2022, Andrew Lelechenko
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither name of the University nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+ GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
void LICENSE file:
Copyright 2015 Edward Kmett
@@ -4835,156 +5240,9 @@ void LICENSE file:
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-wai LICENSE file:
-
- Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
+witherable LICENSE file:
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-wai-app-static LICENSE file:
-
- Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-wai-extra LICENSE file:
-
- Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-wai-logger LICENSE file:
-
- Copyright (c) 2009, IIJ Innovation Institute Inc.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-wai-websockets LICENSE file:
-
- Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-warp LICENSE file:
-
- Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-websockets LICENSE file:
-
- Copyright Jasper Van der Jeugt, 2011
+ Copyright (c) 2014, Fumiaki Kinoshita
All rights reserved.
@@ -4999,7 +5257,7 @@ websockets LICENSE file:
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Siniša Biđin nor the names of other
+ * Neither the name of Fumiaki Kinoshita nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
@@ -5015,38 +5273,6 @@ websockets LICENSE file:
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-word8 LICENSE file:
-
- Copyright (c) 2012, IIJ Innovation Institute Inc.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
xss-sanitize LICENSE file:
The following license covers this documentation, and the source code, except
@@ -5102,3 +5328,161 @@ zlib LICENSE file:
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
+============================================================================
+
+GNU LESSER GENERAL PUBLIC LICENSE
+Version 3, 29 June 2007
+
+Copyright (C) 2007 Free Software Foundation, Inc.
+
+Everyone is permitted to copy and distribute verbatim copies of this license
+document, but changing it is not allowed.
+
+This version of the GNU Lesser General Public License incorporates the terms
+and conditions of version 3 of the GNU General Public License, supplemented
+by the additional permissions listed below.
+
+0. Additional Definitions.
+
+As used herein, “this License” refers to version 3 of the GNU Lesser General
+Public License, and the “GNU GPL” refers to version 3 of the
+GNU General Public License.
+
+“The Library” refers to a covered work governed by this License, other than
+an Application or a Combined Work as defined below.
+
+An “Application” is any work that makes use of an interface provided by the
+Library, but which is not otherwise based on the Library. Defining a subclass
+of a class defined by the Library is deemed a mode of using an interface
+provided by the Library.
+
+A “Combined Work” is a work produced by combining or linking an Application
+with the Library. The particular version of the Library with which the
+Combined Work was made is also called the “Linked Version”.
+
+The “Minimal Corresponding Source” for a Combined Work means the Corresponding
+Source for the Combined Work, excluding any source code for portions of the
+Combined Work that, considered in isolation, are based on the Application,
+and not on the Linked Version.
+
+The “Corresponding Application Code” for a Combined Work means the object code
+and/or source code for the Application, including any data and utility programs
+needed for reproducing the Combined Work from the Application, but excluding
+the System Libraries of the Combined Work.
+
+1. Exception to Section 3 of the GNU GPL.
+
+You may convey a covered work under sections 3 and 4 of this License without
+being bound by section 3 of the GNU GPL.
+
+2. Conveying Modified Versions.
+
+If you modify a copy of the Library, and, in your modifications, a facility
+refers to a function or data to be supplied by an Application that uses the
+facility (other than as an argument passed when the facility is invoked),
+then you may convey a copy of the modified version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the function or
+ data, the facility still operates, and performs whatever part of its
+ purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of this
+ License applicable to that copy.
+
+3. Object Code Incorporating Material from Library Header Files.
+
+The object code form of an Application may incorporate material from a header
+file that is part of the Library. You may convey such object code under terms
+of your choice, provided that, if the incorporated material is not limited to
+numerical parameters, data structure layouts and accessors, or small macros,
+inline functions and templates (ten or fewer lines in length),
+you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the Library
+ is used in it and that the Library and its use are covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL
+ and this license document.
+
+4. Combined Works.
+
+You may convey a Combined Work under terms of your choice that, taken together,
+effectively do not restrict modification of the portions of the Library
+contained in the Combined Work and reverse engineering for debugging such
+modifications, if you also do each of the following:
+
+ a) Give prominent notice with each copy of the Combined Work that the
+ Library is used in it and that the Library and its use are covered
+ by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and
+ this license document.
+
+ c) For a Combined Work that displays copyright notices during execution,
+ include the copyright notice for the Library among these notices, as well
+ as a reference directing the user to the copies of the GNU GPL
+ and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form suitable
+ for, and under terms that permit, the user to recombine or relink
+ the Application with a modified version of the Linked Version to
+ produce a modified Combined Work, in the manner specified by section 6
+ of the GNU GPL for conveying Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time a
+ copy of the Library already present on the user's computer system,
+ and (b) will operate properly with a modified version of the Library
+ that is interface-compatible with the Linked Version.
+
+ e) Provide Installation Information, but only if you would otherwise be
+ required to provide such information under section 6 of the GNU GPL, and
+ only to the extent that such information is necessary to install and
+ execute a modified version of the Combined Work produced by recombining
+ or relinking the Application with a modified version of the Linked Version.
+ (If you use option 4d0, the Installation Information must accompany the
+ Minimal Corresponding Source and Corresponding Application Code. If you
+ use option 4d1, you must provide the Installation Information in the
+ manner specified by section 6 of the GNU GPL for
+ conveying Corresponding Source.)
+
+5. Combined Libraries.
+
+You may place library facilities that are a work based on the Library side by
+side in a single library together with other library facilities that are not
+Applications and are not covered by this License, and convey such a combined
+library under terms of your choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based on
+ the Library, uncombined with any other library facilities, conveyed under
+ the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it is a
+ work based on the Library, and explaining where to find the accompanying
+ uncombined form of the same work.
+
+6. Revised Versions of the GNU Lesser General Public License.
+
+The Free Software Foundation may publish revised and/or new versions of the
+GNU Lesser General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library as you
+received it specifies that a certain numbered version of the GNU Lesser
+General Public License “or any later version” applies to it, you have the
+option of following the terms and conditions either of that published version
+or of any later version published by the Free Software Foundation. If the
+Library as you received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser General
+Public License ever published by the Free Software Foundation.
+
+If the Library as you received it specifies that a proxy can decide whether
+future versions of the GNU Lesser General Public License shall apply, that
+proxy's public statement of acceptance of any version is permanent
+authorization for you to choose that version for the Library.
+
diff --git a/Makefile b/Makefile
index 8316136b5f..91235d9c8f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,30 @@
+bin_dir = bin
+build_dir = .build
package = purescript
exe_target = purs
stack_yaml = STACK_YAML="stack.yaml"
stack = $(stack_yaml) stack
+stack_dir = .stack-work
+
+.DEFAULT_GOAL := help
+
+$(bin_dir)/hlint: ci/install-hlint.sh
+ BIN_DIR=$(bin_dir) BUILD_DIR=$(build_dir) $<
+ touch $@
+
+clean: ## Remove build artifacts
+ rm -fr $(bin_dir)
+ rm -fr $(build_dir)
+ rm -fr $(stack_dir)
+ rm -fr dist-newstyle
+ rm -fr .psci_modules
+ rm -fr .test_modules
help: ## Print documentation
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
ghcid: ## Run ghcid to quickly reload code on save.
- ghcid --command "stack ghci purescript:lib purescript:test:tests --ghci-options -fno-code"
+ ghcid --command "stack ghci purescript:exe:purs purescript:lib purescript:test:tests --main-is purescript:exe:purs --ghci-options -fno-code"
ghcid-test: ## Run ghcid to quickly reload code and run tests on save.
ghcid --command "stack ghci purescript:lib purescript:test:tests --ghci-options -fobject-code" \
@@ -56,4 +73,12 @@ bench: ## Run benchmarks for PureScript
dev-deps: ## Install helpful development tools.
stack install ghcid ghc-prof-aeson-flamegraph
-.PHONY : build build-dirty run install ghci test test-ghci test-profiling ghcid dev-deps
+license-generator: ## Update dependencies in LICENSE
+ $(stack) ls dependencies purescript --flag purescript:RELEASE | stack license-generator/generate.hs > LICENSE
+
+lint: lint-hlint ## Check project adheres to standards
+
+lint-hlint: $(bin_dir)/hlint ## Check project adheres to hlint standards
+ $< --git
+
+.PHONY : build build-dirty run install ghci test test-ghci test-profiling ghcid dev-deps license-generator clean lint lint-hlint
diff --git a/README.md b/README.md
index f2239f35e0..59ce6231cb 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
-[](http://purescript.org)
+
A small strongly typed programming language with expressive types that compiles to JavaScript, written in and inspired by Haskell.
-[](http://hackage.haskell.org/package/purescript) [](http://travis-ci.org/purescript/purescript)
+[](http://hackage.haskell.org/package/purescript) [](https://github.com/purescript/purescript/actions/workflows/ci.yml)
## Language info
@@ -12,13 +12,22 @@ A small strongly typed programming language with expressive types that compiles
## Resources
-- [PureScript book](https://leanpub.com/purescript/read)
+- [PureScript book](https://book.purescript.org/)
- [Documentation](https://github.com/purescript/documentation)
- [Try PureScript](http://try.purescript.org)
- [Pursuit Package Index](http://pursuit.purescript.org/)
## Help!
-- [#purescript @ FP Slack](https://functionalprogramming.slack.com/)
-- [PureScript Language Forum](https://discourse.purescript.org/)
+### Community Spaces
+
+The following spaces are governed by the [PureScript Community Code of Conduct](https://github.com/purescript/governance/blob/master/CODE_OF_CONDUCT.md). The majority of PureScript users use these spaces to discuss and collaborate on PureScript-related topics:
+- [PureScript Discord](https://purescript.org/chat)
+- [PureScript Discourse](https://discourse.purescript.org/)
+
+### Unaffiliated Spaces
+
+Some PureScript users also collaborate in the below spaces. These do not fall under the code of conduct linked above. They may have no code of conduct or one very different than the one linked above.
+- [PureScript Matrix](https://matrix.to/#/#purescript:matrix.org)
- [PureScript on StackOverflow](http://stackoverflow.com/questions/tagged/purescript)
+- [The `#purescript` channel on Libera.Chat](https://libera.chat/)
diff --git a/RELEASE_CHECKLIST.md b/RELEASE_CHECKLIST.md
deleted file mode 100644
index f3ec657f6e..0000000000
--- a/RELEASE_CHECKLIST.md
+++ /dev/null
@@ -1,62 +0,0 @@
-# Release Checklist
-
-## For every release
-
-- [ ] Regenerate LICENSE (see `license-generator/`)
-- [ ] Release notes
-- [ ] Publish to Hackage
-- [ ] Update npm package
-- [ ] Try PureScript? — need to decide whether we want to continue
- officially supporting this
-
-## Libraries
-
-Are there breaking changes to the language? Or alternatively, are there
-language changes which require breaking changes in the relevant libraries to
-make use of? If so:
-
-- [ ] Update core libraries
-- [ ] Update contrib libraries
-- [ ] Update node bindings
-- [ ] Create a new package set
-
-## Tools
-
-Has the compiler CLI changed at all? If so, the following may need updates:
-
-- [ ] psc-package
-- [ ] Pulp
-- [ ] purs-loader
-- [ ] ide plugins
-
-## JSON formats
-
-Have any of the following JSON formats changed? If so, it may be worth
-considering what effects this may have:
-
-- [ ] Corefn
-- [ ] Ide protocol
-- [ ] JSON produced by `purs publish`
- - [ ] check whether this affects Pursuit
-
-## Documentation
-
-- [ ] Check that purescript.org is up-to-date
-- [ ] Check that INSTALL.md is up-to-date
-
-Have there been any changes or additions to the language which should be
-documented?
-
-- [ ] Document any language changes in the documentation repo
-
-Have there been additions or changes to `Prim` (including documentation
-changes?) If so,
-
-- [ ] Update Pursuit to depend on the latest compiler so that these docs appear
- on pursuit.purescript.org
-
-## Announcements
-
-- [ ] Discourse
-- [ ] Twitter
-- [ ] /r/purescript
diff --git a/RELEASE_GUIDE.md b/RELEASE_GUIDE.md
new file mode 100644
index 0000000000..02ac3a4fe5
--- /dev/null
+++ b/RELEASE_GUIDE.md
@@ -0,0 +1,155 @@
+# Release Guide (for maintainers)
+
+## Prerequisites
+
+- You will need a [Hackage](https://hackage.haskell.org/) account that has been invited to be a maintainer of the `purescript` package on Hackage. If you don't have one, create one and ask to be invited as a maintainer.
+- You will need an [NPM](https://www.npmjs.com/) account that has been invited to be a maintainer of the `purescript` package on NPM. If you don't have one, create one and ask to be invited as a maintainer.
+- You need `spago` installed.
+- You need to be logged into NPM (i.e. running `npm whoami` should print your NPM account's username)
+
+## Before making a release
+
+- Check that there are no unintended breaking changes by compiling [the latest package set](https://github.com/purescript/package-sets/releases/latest)
+
+```bash
+stack build
+mkdir wPackageSet
+pushd wPackageSet
+spago init
+spago upgrade-set
+# install all packages in the set
+spago install $(spago ls packages | cut -f 1 -d ' ' | tr '\n' ' ')
+
+# Verify that code compiles and docs are properly created
+stack exec bash <), (<.>), takeFileName)
-import System.FilePath.Glob (glob)
-import System.Exit (exitFailure)
-import System.IO (stderr, hPutStr, hPutStrLn)
-import System.IO.UTF8 (readUTF8File, writeUTF8File)
-import System.Directory (createDirectoryIfMissing, getCurrentDirectory)
-import qualified Data.ByteString.Lazy.UTF8 as LBU8
-import Language.PureScript.Bundle
-import Options.Applicative (Parser)
-import qualified Options.Applicative as Opts
-import SourceMap
-import SourceMap.Types
-
--- | Command line options.
-data Options = Options
- { optionsInputFiles :: [FilePath]
- , optionsOutputFile :: Maybe FilePath
- , optionsEntryPoints :: [String]
- , optionsMainModule :: Maybe String
- , optionsNamespace :: String
- , optionsSourceMaps :: Bool
- } deriving Show
-
--- | The main application function.
--- This function parses the input files, performs dead code elimination, filters empty modules
--- and generates and prints the final Javascript bundle.
-app :: (MonadError ErrorMessage m, MonadIO m) => Options -> m (Maybe SourceMapping, String)
-app Options{..} = do
- inputFiles <- concat <$> mapM (liftIO . glob) optionsInputFiles
- when (null inputFiles) . liftIO $ do
- hPutStrLn stderr "purs bundle: No input files."
- exitFailure
- when (isNothing optionsOutputFile && optionsSourceMaps == True) . liftIO $ do
- hPutStrLn stderr "purs bundle: Source maps only supported when output file specified."
- exitFailure
-
- input <- for inputFiles $ \filename -> do
- js <- liftIO (readUTF8File filename)
- mid <- guessModuleIdentifier filename
- length js `seq` return (mid, Just filename, js) -- evaluate readFile till EOF before returning, not to exhaust file handles
-
- let entryIds = map (`ModuleIdentifier` Regular) optionsEntryPoints
-
- currentDir <- liftIO getCurrentDirectory
- let outFile = if optionsSourceMaps then fmap (currentDir >) optionsOutputFile else Nothing
- bundleSM input entryIds optionsMainModule optionsNamespace outFile
-
--- | Command line options parser.
-options :: Parser Options
-options = Options <$> some inputFile
- <*> optional outputFile
- <*> many entryPoint
- <*> optional mainModule
- <*> namespace
- <*> sourceMaps
- where
- inputFile :: Parser FilePath
- inputFile = Opts.strArgument $
- Opts.metavar "FILE"
- <> Opts.help "The input .js file(s)"
-
- outputFile :: Parser FilePath
- outputFile = Opts.strOption $
- Opts.short 'o'
- <> Opts.long "output"
- <> Opts.help "The output .js file"
-
- entryPoint :: Parser String
- entryPoint = Opts.strOption $
- Opts.short 'm'
- <> Opts.long "module"
- <> Opts.help "Entry point module name(s). All code which is not a transitive dependency of an entry point module will be removed."
-
- mainModule :: Parser String
- mainModule = Opts.strOption $
- Opts.long "main"
- <> Opts.help "Generate code to run the main method in the specified module."
+import Prelude
- namespace :: Parser String
- namespace = Opts.strOption $
- Opts.short 'n'
- <> Opts.long "namespace"
- <> Opts.value "PS"
- <> Opts.showDefault
- <> Opts.help "Specify the namespace that PureScript modules will be exported to when running in the browser."
+import System.Exit (exitFailure)
+import System.IO (stderr, hPutStrLn)
+import Options.Applicative qualified as Opts
- sourceMaps :: Parser Bool
- sourceMaps = Opts.switch $
- Opts.long "source-maps"
- <> Opts.help "Whether to generate source maps for the bundle (requires --output)."
+app :: IO ()
+app = do
+ hPutStrLn stderr $ unlines
+ [ "'purs bundle' was removed in the v0.15.0 release."
+ , "See https://github.com/purescript/documentation/blob/master/migration-guides/0.15-Migration-Guide.md"
+ , "for more information and bundler alternatives."
+ ]
+ exitFailure
-- | Make it go.
command :: Opts.Parser (IO ())
-command = run <$> (Opts.helper <*> options) where
- run :: Options -> IO ()
- run opts = do
- output <- runExceptT (app opts)
- case output of
- Left err -> do
- hPutStr stderr (unlines (printErrorMessage err))
- exitFailure
- Right (sourcemap, js) ->
- case optionsOutputFile opts of
- Just outputFile -> do
- createDirectoryIfMissing True (takeDirectory outputFile)
- case sourcemap of
- Just sm -> do
- writeUTF8File outputFile $ js ++ "\n//# sourceMappingURL=" ++ (takeFileName outputFile <.> "map") ++ "\n"
- writeUTF8File (outputFile <.> "map") $ LBU8.toString . encode $ generate sm
- Nothing -> writeUTF8File outputFile js
- Nothing -> putStrLn js
+command = run <$> (Opts.helper <*> pure ()) where
+ run :: () -> IO ()
+ run _ = app
diff --git a/app/Command/Compile.hs b/app/Command/Compile.hs
index 461985f6b1..d81dd75c07 100644
--- a/app/Command/Compile.hs
+++ b/app/Command/Compile.hs
@@ -1,99 +1,82 @@
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TupleSections #-}
-
module Command.Compile (command) where
-import Control.Applicative
-import Control.Monad
-import qualified Data.Aeson as A
-import Data.Bool (bool)
-import qualified Data.ByteString.Lazy.UTF8 as LBU8
-import Data.List (intercalate)
-import qualified Data.Map as M
-import qualified Data.Set as S
-import Data.Text (Text)
-import qualified Data.Text as T
-import Data.Traversable (for)
-import qualified Language.PureScript as P
-import qualified Language.PureScript.CST as CST
-import Language.PureScript.Errors.JSON
-import Language.PureScript.Make
-import qualified Options.Applicative as Opts
-import qualified System.Console.ANSI as ANSI
-import System.Exit (exitSuccess, exitFailure)
-import System.Directory (getCurrentDirectory)
-import System.FilePath.Glob (glob)
-import System.IO (hPutStr, hPutStrLn, stderr)
-import System.IO.UTF8 (readUTF8FileT)
+import Prelude
+
+import Control.Applicative (Alternative(..))
+import Control.Monad (when)
+import Data.Aeson qualified as A
+import Data.Bool (bool)
+import Data.ByteString.Lazy.UTF8 qualified as LBU8
+import Data.List (intercalate)
+import Data.Map qualified as M
+import Data.Set qualified as S
+import Data.Text qualified as T
+import Data.Traversable (for)
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Errors.JSON (JSONResult(..), toJSONErrors)
+import Language.PureScript.Glob (toInputGlobs, PSCGlobs(..), warnFileTypeNotFound)
+import Language.PureScript.Make (buildMakeActions, inferForeignModules, runMake)
+import Options.Applicative qualified as Opts
+import SharedCLI qualified
+import System.Console.ANSI qualified as ANSI
+import System.Exit (exitSuccess, exitFailure)
+import System.Directory (getCurrentDirectory)
+import System.IO (hPutStr, stderr, stdout)
+import System.IO.UTF8 (readUTF8FilesT)
data PSCMakeOptions = PSCMakeOptions
{ pscmInput :: [FilePath]
+ , pscmInputFromFile :: Maybe FilePath
+ , pscmExclude :: [FilePath]
, pscmOutputDir :: FilePath
, pscmOpts :: P.Options
, pscmUsePrefix :: Bool
, pscmJSONErrors :: Bool
}
--- | Argumnets: verbose, use JSON, warnings, errors
-printWarningsAndErrors :: Bool -> Bool -> P.MultipleErrors -> Either P.MultipleErrors a -> IO ()
-printWarningsAndErrors verbose False warnings errors = do
+-- | Arguments: verbose, use JSON, warnings, errors
+printWarningsAndErrors :: Bool -> Bool -> [(FilePath, T.Text)] -> P.MultipleErrors -> Either P.MultipleErrors a -> IO ()
+printWarningsAndErrors verbose False files warnings errors = do
pwd <- getCurrentDirectory
- cc <- bool Nothing (Just P.defaultCodeColor) <$> ANSI.hSupportsANSI stderr
- let ppeOpts = P.defaultPPEOptions { P.ppeCodeColor = cc, P.ppeFull = verbose, P.ppeRelativeDirectory = pwd }
+ cc <- bool Nothing (Just P.defaultCodeColor) <$> ANSI.hSupportsANSI stdout
+ let ppeOpts = P.defaultPPEOptions { P.ppeCodeColor = cc, P.ppeFull = verbose, P.ppeRelativeDirectory = pwd, P.ppeFileContents = files }
when (P.nonEmpty warnings) $
- hPutStrLn stderr (P.prettyPrintMultipleWarnings ppeOpts warnings)
+ putStrLn (P.prettyPrintMultipleWarnings ppeOpts warnings)
case errors of
Left errs -> do
- hPutStrLn stderr (P.prettyPrintMultipleErrors ppeOpts errs)
+ putStrLn (P.prettyPrintMultipleErrors ppeOpts errs)
exitFailure
Right _ -> return ()
-printWarningsAndErrors verbose True warnings errors = do
- hPutStrLn stderr . LBU8.toString . A.encode $
- JSONResult (toJSONErrors verbose P.Warning warnings)
- (either (toJSONErrors verbose P.Error) (const []) errors)
+printWarningsAndErrors verbose True files warnings errors = do
+ putStrLn . LBU8.toString . A.encode $
+ JSONResult (toJSONErrors verbose P.Warning files warnings)
+ (either (toJSONErrors verbose P.Error files) (const []) errors)
either (const exitFailure) (const (return ())) errors
compile :: PSCMakeOptions -> IO ()
compile PSCMakeOptions{..} = do
- input <- globWarningOnMisses (unless pscmJSONErrors . warnFileTypeNotFound) pscmInput
- when (null input && not pscmJSONErrors) $ do
+ input <- toInputGlobs $ PSCGlobs
+ { pscInputGlobs = pscmInput
+ , pscInputGlobsFromFile = pscmInputFromFile
+ , pscExcludeGlobs = pscmExclude
+ , pscWarnFileTypeNotFound = warnFileTypeNotFound "compile"
+ }
+ when (null input) $ do
hPutStr stderr $ unlines [ "purs compile: No input files."
, "Usage: For basic information, try the `--help' option."
]
exitFailure
- moduleFiles <- readInput input
+ moduleFiles <- readUTF8FilesT input
(makeErrors, makeWarnings) <- runMake pscmOpts $ do
ms <- CST.parseModulesFromFiles id moduleFiles
let filePathMap = M.fromList $ map (\(fp, pm) -> (P.getModuleName $ CST.resPartial pm, Right fp)) ms
foreigns <- inferForeignModules filePathMap
let makeActions = buildMakeActions pscmOutputDir filePathMap foreigns pscmUsePrefix
P.make makeActions (map snd ms)
- printWarningsAndErrors (P.optionsVerboseErrors pscmOpts) pscmJSONErrors makeWarnings makeErrors
+ printWarningsAndErrors (P.optionsVerboseErrors pscmOpts) pscmJSONErrors moduleFiles makeWarnings makeErrors
exitSuccess
-warnFileTypeNotFound :: String -> IO ()
-warnFileTypeNotFound = hPutStrLn stderr . ("purs compile: No files found using pattern: " ++)
-
-globWarningOnMisses :: (String -> IO ()) -> [FilePath] -> IO [FilePath]
-globWarningOnMisses warn = concatMapM globWithWarning
- where
- globWithWarning pattern' = do
- paths <- glob pattern'
- when (null paths) $ warn pattern'
- return paths
- concatMapM f = fmap concat . mapM f
-
-readInput :: [FilePath] -> IO [(FilePath, Text)]
-readInput inputFiles = forM inputFiles $ \inFile -> (inFile, ) <$> readUTF8FileT inFile
-
-inputFile :: Opts.Parser FilePath
-inputFile = Opts.strArgument $
- Opts.metavar "FILE"
- <> Opts.help "The input .purs file(s)."
-
outputDirectory :: Opts.Parser FilePath
outputDirectory = Opts.strOption $
Opts.short 'o'
@@ -157,10 +140,12 @@ options =
where
-- Ensure that the JS target is included if sourcemaps are
handleTargets :: [P.CodegenTarget] -> S.Set P.CodegenTarget
- handleTargets ts = S.fromList (if elem P.JSSourceMap ts then P.JS : ts else ts)
+ handleTargets ts = S.fromList (if P.JSSourceMap `elem` ts then P.JS : ts else ts)
pscMakeOptions :: Opts.Parser PSCMakeOptions
-pscMakeOptions = PSCMakeOptions <$> many inputFile
+pscMakeOptions = PSCMakeOptions <$> many SharedCLI.inputFile
+ <*> SharedCLI.globInputFile
+ <*> many SharedCLI.excludeFiles
<*> outputDirectory
<*> options
<*> (not <$> noPrefix)
diff --git a/app/Command/Docs.hs b/app/Command/Docs.hs
index 048cb646d2..22bd6bdd3f 100644
--- a/app/Command/Docs.hs
+++ b/app/Command/Docs.hs
@@ -1,30 +1,29 @@
-{-# LANGUAGE TupleSections #-}
module Command.Docs (command, infoModList) where
-import Command.Docs.Html
-import Control.Applicative
-import Control.Arrow (first, second)
-import Control.Category ((>>>))
-import Control.Monad.Writer
-import Control.Monad.Trans.Except (runExceptT)
-import qualified Data.Text as T
-import qualified Data.Text.IO as T
-import Data.Function (on)
-import Data.List
-import Data.Tuple (swap)
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Docs as D
-import qualified Language.PureScript.Docs.AsMarkdown as D
-import Language.PureScript.Docs.Tags (dumpCtags, dumpEtags)
-import qualified Options.Applicative as Opts
-import qualified Text.PrettyPrint.ANSI.Leijen as PP
-import System.Directory (createDirectoryIfMissing)
-import System.Exit (exitFailure)
-import System.FilePath (takeDirectory)
-import System.FilePath.Glob (glob)
-import System.IO (hPutStrLn, stderr)
-import System.IO.UTF8 (writeUTF8FileT)
+import Prelude
+
+import Command.Docs.Html (asHtml, writeHtmlModules)
+import Command.Docs.Markdown (asMarkdown, writeMarkdownModules)
+import Control.Applicative (Alternative(..), optional)
+import Control.Monad (when)
+import Control.Monad.Trans.Except (runExceptT)
+import Data.Maybe (fromMaybe)
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.Docs qualified as D
+import Language.PureScript.Docs.Tags (dumpCtags, dumpEtags)
+import Language.PureScript.Glob (PSCGlobs(..), toInputGlobs, warnFileTypeNotFound)
+import Options.Applicative qualified as Opts
+import Prettyprinter qualified as PP
+import Prettyprinter.Render.Terminal (AnsiStyle)
+import SharedCLI qualified
+import System.Directory (getCurrentDirectory, createDirectoryIfMissing, removeFile)
+import System.Exit (exitFailure)
+import System.FilePath ((>))
+import System.FilePath.Glob (compile, globDir1)
+import System.IO (hPutStrLn, stderr)
+import System.IO.UTF8 (writeUTF8FileT)
-- | Available output formats
data Format
@@ -34,67 +33,51 @@ data Format
| Etags -- Output etags symbol index suitable for use with emacs
deriving (Show, Eq, Ord)
--- | Available methods of outputting Markdown documentation
-data DocgenOutput
- = EverythingToStdOut
- | ToStdOut [P.ModuleName]
- | ToFiles [(P.ModuleName, FilePath)]
- deriving (Show)
-
data PSCDocsOptions = PSCDocsOptions
{ _pscdFormat :: Format
+ , _pscdOutput :: Maybe FilePath
+ , _pscdCompileOutputDir :: FilePath
, _pscdInputFiles :: [FilePath]
- , _pscdDocgen :: DocgenOutput
+ , _pscdInputFromFile :: Maybe FilePath
+ , _pscdExcludeFiles :: [FilePath]
}
deriving (Show)
docgen :: PSCDocsOptions -> IO ()
-docgen (PSCDocsOptions fmt inputGlob output) = do
- input <- concat <$> mapM glob inputGlob
+docgen (PSCDocsOptions fmt moutput compileOutput inputGlob inputGlobFromFile excludeGlob) = do
+ input <- toInputGlobs $ PSCGlobs
+ { pscInputGlobs = inputGlob
+ , pscInputGlobsFromFile = inputGlobFromFile
+ , pscExcludeGlobs = excludeGlob
+ , pscWarnFileTypeNotFound = warnFileTypeNotFound "docs"
+ }
when (null input) $ do
hPutStrLn stderr "purs docs: no input files."
exitFailure
+ let output = fromMaybe (defaultOutputForFormat fmt) moutput
+
fileMs <- parseAndConvert input
- let ms = map snd fileMs
+ let ms = D.primModules ++ map snd fileMs
case fmt of
- Etags -> mapM_ putStrLn $ dumpEtags fileMs
- Ctags -> mapM_ putStrLn $ dumpCtags fileMs
+ Etags -> writeTagsToFile output $ dumpEtags fileMs
+ Ctags -> writeTagsToFile output $ dumpCtags fileMs
Html -> do
- let outputDir = "./generated-docs" -- TODO: make this configurable
- let msHtml = map asHtml (D.primModules ++ ms)
- createDirectoryIfMissing False outputDir
- writeHtmlModules outputDir msHtml
-
- Markdown ->
- case output of
- EverythingToStdOut ->
- T.putStrLn (D.runDocs (D.modulesAsMarkdown ms))
- ToStdOut names -> do
- let (ms', missing) = takeByName ms names
- guardMissing missing
- T.putStrLn (D.runDocs (D.modulesAsMarkdown ms'))
- ToFiles names -> do
- let (ms', missing) = takeByName' ms names
- guardMissing missing
-
- let ms'' = groupBy ((==) `on` fst) . sortBy (compare `on` fst) $ map swap ms'
- forM_ ms'' $ \grp -> do
- let fp = fst (head grp)
- createDirectoryIfMissing True (takeDirectory fp)
- writeUTF8FileT fp (D.runDocs (D.modulesAsMarkdown (map snd grp)))
+ let ext = compile "*.html"
+ let msHtml = map asHtml ms
+ createDirectoryIfMissing True output
+ globDir1 ext output >>= mapM_ removeFile
+ writeHtmlModules output msHtml
+ Markdown -> do
+ let ext = compile "*.md"
+ let msMarkdown = map asMarkdown ms
+ createDirectoryIfMissing True output
+ globDir1 ext output >>= mapM_ removeFile
+ writeMarkdownModules output msMarkdown
+
+ putStrLn $ "Documentation written to: " ++ output
where
- guardMissing [] = return ()
- guardMissing [mn] = do
- hPutStrLn stderr ("purs docs: error: unknown module \"" ++ T.unpack (P.runModuleName mn) ++ "\"")
- exitFailure
- guardMissing mns = do
- hPutStrLn stderr "purs docs: error: unknown modules:"
- forM_ mns $ \mn ->
- hPutStrLn stderr (" * " ++ T.unpack (P.runModuleName mn))
- exitFailure
-
successOrExit :: Either P.MultipleErrors a -> IO a
successOrExit act =
case act of
@@ -104,39 +87,16 @@ docgen (PSCDocsOptions fmt inputGlob output) = do
hPutStrLn stderr $ P.prettyPrintMultipleErrors P.defaultPPEOptions err
exitFailure
- takeByName = takeModulesByName D.modName
- takeByName' = takeModulesByName' D.modName
-
parseAndConvert input =
- runExceptT (D.parseFilesInPackages input []
- >>= uncurry D.convertTaggedModulesInPackage)
+ runExceptT (fmap fst (D.collectDocs compileOutput input []))
>>= successOrExit
--- |
--- Given a list of module names and a list of modules, return a list of modules
--- whose names appeared in the given name list, together with a list of names
--- for which no module could be found in the module list.
---
-takeModulesByName :: (Eq n) => (m -> n) -> [m] -> [n] -> ([m], [n])
-takeModulesByName getModuleName modules names =
- first (map fst) (takeModulesByName' getModuleName modules (map (,()) names))
-
--- |
--- Like takeModulesByName, but also keeps some extra information with each
--- module.
---
-takeModulesByName' :: (Eq n) => (m -> n) -> [m] -> [(n, a)] -> ([(m, a)], [n])
-takeModulesByName' getModuleName modules = foldl go ([], [])
- where
- go (ms, missing) (name, x) =
- case find ((== name) . getModuleName) modules of
- Just m -> ((m, x) : ms, missing)
- Nothing -> (ms, name : missing)
-
-inputFile :: Opts.Parser FilePath
-inputFile = Opts.strArgument $
- Opts.metavar "FILE"
- <> Opts.help "The input .purs file(s)"
+ writeTagsToFile :: String -> [String] -> IO ()
+ writeTagsToFile outputFilename tags = do
+ currentDir <- getCurrentDirectory
+ let outputFile = currentDir > outputFilename
+ let text = T.pack . unlines $ tags
+ writeUTF8FileT outputFile text
instance Read Format where
readsPrec _ "etags" = [(Etags, "")]
@@ -145,90 +105,65 @@ instance Read Format where
readsPrec _ "html" = [(Html, "")]
readsPrec _ _ = []
-format :: Opts.Parser Format
-format = Opts.option Opts.auto $ Opts.value Markdown
- <> Opts.long "format"
- <> Opts.metavar "FORMAT"
- <> Opts.help "Set output FORMAT (markdown | html | etags | ctags)"
-
-docgenModule :: Opts.Parser String
-docgenModule = Opts.strOption $
- Opts.long "docgen"
- <> Opts.help "A list of module names which should appear in the output. This can optionally include file paths to write individual modules to, by separating with a colon ':'. For example, Prelude:docs/Prelude.md. This option may be specified multiple times."
-
-pscDocsOptions :: Opts.Parser (Format, [FilePath], [String])
-pscDocsOptions = (,,) <$> format <*> many inputFile <*> many docgenModule
-
-parseDocgen :: [String] -> Either String DocgenOutput
-parseDocgen [] = Right EverythingToStdOut
-parseDocgen xs = go xs
- where
- go = intersperse " "
- >>> concat
- >>> words
- >>> map parseItem
- >>> combine
-
-data DocgenOutputItem
- = IToStdOut P.ModuleName
- | IToFile (P.ModuleName, FilePath)
-
-parseItem :: String -> DocgenOutputItem
-parseItem s = case elemIndex ':' s of
- Just i ->
- s # splitAt i
- >>> first (P.moduleNameFromString . T.pack)
- >>> second (drop 1)
- >>> IToFile
- Nothing ->
- IToStdOut (P.moduleNameFromString (T.pack s))
-
- where
- infixr 1 #
- (#) = flip ($)
-
-combine :: [DocgenOutputItem] -> Either String DocgenOutput
-combine [] = Right EverythingToStdOut
-combine (x:xs) = foldM go (initial x) xs
+defaultOutputForFormat :: Format -> FilePath
+defaultOutputForFormat fmt =
+ case fmt of
+ Markdown -> "generated-docs/md"
+ Html -> "generated-docs/html"
+ Etags -> "TAGS"
+ Ctags -> "tags"
+
+pscDocsOptions :: Opts.Parser PSCDocsOptions
+pscDocsOptions =
+ PSCDocsOptions <$> format
+ <*> output
+ <*> compileOutputDir
+ <*> many SharedCLI.inputFile
+ <*> SharedCLI.globInputFile
+ <*> many SharedCLI.excludeFiles
where
- initial (IToStdOut m) = ToStdOut [m]
- initial (IToFile m) = ToFiles [m]
-
- go (ToStdOut ms) (IToStdOut m) = Right (ToStdOut (m:ms))
- go (ToFiles ms) (IToFile m) = Right (ToFiles (m:ms))
- go _ _ = Left "Can't mix module names and module name/file path pairs in the same invocation."
-
-buildOptions :: (Format, [FilePath], [String]) -> IO PSCDocsOptions
-buildOptions (fmt, input, mapping) =
- case parseDocgen mapping of
- Right mapping' -> return (PSCDocsOptions fmt input mapping')
- Left err -> do
- hPutStrLn stderr "purs docs: error in --docgen option:"
- hPutStrLn stderr (" " ++ err)
- exitFailure
+ format :: Opts.Parser Format
+ format = Opts.option Opts.auto $
+ Opts.value Html
+ <> Opts.long "format"
+ <> Opts.metavar "FORMAT"
+ <> Opts.help "Set output FORMAT (markdown | html | etags | ctags)"
+
+ output :: Opts.Parser (Maybe FilePath)
+ output = optional $ Opts.strOption $
+ Opts.long "output"
+ <> Opts.short 'o'
+ <> Opts.metavar "DEST"
+ <> Opts.help "File/directory path for docs to be written to"
+
+ compileOutputDir :: Opts.Parser FilePath
+ compileOutputDir = Opts.strOption $
+ Opts.value "output"
+ <> Opts.showDefault
+ <> Opts.long "compile-output"
+ <> Opts.metavar "DIR"
+ <> Opts.help "Compiler output directory"
command :: Opts.Parser (IO ())
-command = (buildOptions >=> docgen) <$> (Opts.helper <*> pscDocsOptions)
+command = docgen <$> (Opts.helper <*> pscDocsOptions)
infoModList :: Opts.InfoMod a
infoModList = Opts.fullDesc <> footerInfo where
footerInfo = Opts.footerDoc $ Just examples
-examples :: PP.Doc
+examples :: PP.Doc AnsiStyle
examples =
- PP.vcat $ map PP.text
+ PP.vcat
[ "Examples:"
- , " print documentation for Data.List to stdout:"
- , " purs docs \"src/**/*.purs\" \".psc-package/*/*/*/src/**/*.purs\" \\"
- , " --docgen Data.List"
+ , " write documentation for all modules to ./generated-docs:"
+ , " purs docs \"src/**/*.purs\" \".psc-package/*/*/*/src/**/*.purs\""
+ , ""
+ , " write documentation in Markdown format for all modules to ./generated-docs:"
+ , " purs docs --format markdown \"src/**/*.purs\" \".psc-package/*/*/*/src/**/*.purs\""
, ""
- , " write documentation for Data.List to docs/Data.List.md:"
- , " purs docs \"src/**/*.purs\" \".psc-package/*/*/*/src/**/*.purs\" \\"
- , " --docgen Data.List:docs/Data.List.md"
+ , " write CTags to ./tags:"
+ , " purs docs --format ctags \"src/**/*.purs\" \".psc-package/*/*/*/src/**/*.purs\""
, ""
- , " write documentation for Data.List to docs/Data.List.md, and"
- , " documentation for Data.List.Lazy to docs/Data.List.Lazy.md:"
- , " purs docs \"src/**/*.purs\" \".psc-package/*/*/*/src/**/*.purs\" \\"
- , " --docgen Data.List:docs/Data.List.md \\"
- , " --docgen Data.List.Lazy:docs/Data.List.Lazy.md"
+ , " write ETags to ./TAGS:"
+ , " purs docs --format etags \"src/**/*.purs\" \".psc-package/*/*/*/src/**/*.purs\""
]
diff --git a/app/Command/Docs/Html.hs b/app/Command/Docs/Html.hs
index 1e4a176e46..116cf0f7a7 100644
--- a/app/Command/Docs/Html.hs
+++ b/app/Command/Docs/Html.hs
@@ -1,6 +1,3 @@
-{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE OverloadedStrings #-}
-
module Command.Docs.Html
( asHtml
, layout
@@ -8,28 +5,27 @@ module Command.Docs.Html
, writeHtmlModules
) where
-import Control.Applicative
-import Control.Arrow ((&&&))
-import Control.Monad.Writer
-import Data.List (sort)
-import Data.Text (Text)
-import Data.Text.Lazy (toStrict)
-import qualified Data.Text as T
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Docs as D
-import qualified Language.PureScript.Docs.AsHtml as D
-import Text.Blaze.Html5 (Html, (!), toMarkup)
-import qualified Text.Blaze.Html5 as H
-import qualified Text.Blaze.Html5.Attributes as A
-import qualified Text.Blaze.Html.Renderer.Text as Blaze
-import System.IO.UTF8 (writeUTF8FileT)
-import System.FilePath.Glob (glob)
-import System.Directory (removeFile)
-import Version (versionString)
+import Prelude
+
+import Control.Applicative (Alternative(..))
+import Control.Arrow ((&&&))
+import Control.Monad (guard)
+import Data.List (sort)
+import Data.Text (Text)
+import Data.Text.Lazy (toStrict)
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.Docs qualified as D
+import Language.PureScript.Docs.AsHtml qualified as D
+import Text.Blaze.Html5 (Html, (!), toMarkup)
+import Text.Blaze.Html5 qualified as H
+import Text.Blaze.Html5.Attributes qualified as A
+import Text.Blaze.Html.Renderer.Text qualified as Blaze
+import System.IO.UTF8 (writeUTF8FileT)
+import Version (versionString)
writeHtmlModules :: FilePath -> [(P.ModuleName, D.HtmlOutputModule Html)] -> IO ()
writeHtmlModules outputDir modules = do
- glob (outputDir <> "/*.html") >>= mapM_ removeFile
let moduleList = sort $ map fst modules
writeHtmlFile (outputDir ++ "/index.html") (renderIndexModule moduleList)
mapM_ (writeHtmlModule outputDir . (fst &&& layout moduleList)) modules
diff --git a/app/Command/Docs/Markdown.hs b/app/Command/Docs/Markdown.hs
new file mode 100644
index 0000000000..1a05590d3f
--- /dev/null
+++ b/app/Command/Docs/Markdown.hs
@@ -0,0 +1,24 @@
+module Command.Docs.Markdown
+ ( asMarkdown
+ , writeMarkdownModules
+ ) where
+
+import Prelude
+
+import Data.Text (Text)
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.Docs qualified as D
+import Language.PureScript.Docs.AsMarkdown qualified as D
+import System.IO.UTF8 (writeUTF8FileT)
+
+asMarkdown :: D.Module -> (P.ModuleName, Text)
+asMarkdown m = (D.modName m, D.runDocs . D.moduleAsMarkdown $ m)
+
+writeMarkdownModules :: FilePath -> [(P.ModuleName, Text)] -> IO ()
+writeMarkdownModules outputDir = mapM_ $ writeMarkdownModule outputDir
+
+writeMarkdownModule :: FilePath -> (P.ModuleName, Text) -> IO ()
+writeMarkdownModule outputDir (mn, text) = do
+ let filepath = outputDir ++ "/" ++ T.unpack (P.runModuleName mn) ++ ".md"
+ writeUTF8FileT filepath text
diff --git a/app/Command/Graph.hs b/app/Command/Graph.hs
new file mode 100644
index 0000000000..43cb1e2591
--- /dev/null
+++ b/app/Command/Graph.hs
@@ -0,0 +1,85 @@
+module Command.Graph (command) where
+
+import Prelude
+
+import Control.Applicative (many)
+import Control.Monad (unless, when)
+import Data.Aeson qualified as Json
+import Data.Bool (bool)
+import Data.ByteString.Lazy qualified as LB
+import Data.ByteString.Lazy.UTF8 qualified as LBU8
+import Language.PureScript qualified as P
+import Language.PureScript.Errors.JSON (JSONResult(..), toJSONErrors)
+import Language.PureScript.Glob (PSCGlobs(..), toInputGlobs, warnFileTypeNotFound)
+import Options.Applicative qualified as Opts
+import SharedCLI qualified
+import System.Console.ANSI qualified as ANSI
+import System.Exit (exitFailure)
+import System.Directory (getCurrentDirectory)
+import System.IO (hPutStr, hPutStrLn, stderr)
+
+data GraphOptions = GraphOptions
+ { graphInput :: [FilePath]
+ , graphInputFromFile :: Maybe FilePath
+ , graphExclude :: [FilePath]
+ , graphJSONErrors :: Bool
+ }
+
+graph :: GraphOptions -> IO ()
+graph GraphOptions{..} = do
+ input <- toInputGlobs $ PSCGlobs
+ { pscInputGlobs = graphInput
+ , pscInputGlobsFromFile = graphInputFromFile
+ , pscExcludeGlobs = graphExclude
+ , pscWarnFileTypeNotFound = unless graphJSONErrors . warnFileTypeNotFound "graph"
+ }
+
+ when (null input && not graphJSONErrors) $ do
+ hPutStr stderr $ unlines
+ [ "purs graph: No input files."
+ , "Usage: For basic information, try the `--help' option."
+ ]
+ exitFailure
+
+ (makeResult, makeWarnings) <- P.graph input
+
+ printWarningsAndErrors graphJSONErrors makeWarnings makeResult
+ >>= (LB.putStr . Json.encode)
+
+command :: Opts.Parser (IO ())
+command = graph <$> (Opts.helper <*> graphOptions)
+ where
+ graphOptions :: Opts.Parser GraphOptions
+ graphOptions =
+ GraphOptions <$> many SharedCLI.inputFile
+ <*> SharedCLI.globInputFile
+ <*> many SharedCLI.excludeFiles
+ <*> jsonErrors
+
+ jsonErrors :: Opts.Parser Bool
+ jsonErrors =
+ Opts.switch $
+ Opts.long "json-errors" <>
+ Opts.help "Print errors to stderr as JSON"
+
+-- | Arguments: use JSON, warnings, errors
+printWarningsAndErrors :: Bool -> P.MultipleErrors -> Either P.MultipleErrors a -> IO a
+printWarningsAndErrors False warnings errors = do
+ pwd <- getCurrentDirectory
+ cc <- bool Nothing (Just P.defaultCodeColor) <$> ANSI.hSupportsANSI stderr
+ let ppeOpts = P.defaultPPEOptions { P.ppeCodeColor = cc, P.ppeFull = True, P.ppeRelativeDirectory = pwd }
+ when (P.nonEmpty warnings) $
+ hPutStrLn stderr (P.prettyPrintMultipleWarnings ppeOpts warnings)
+ case errors of
+ Left errs -> do
+ hPutStrLn stderr (P.prettyPrintMultipleErrors ppeOpts errs)
+ exitFailure
+ Right res -> pure res
+printWarningsAndErrors True warnings errors = do
+ let verbose = True
+ hPutStrLn stderr . LBU8.toString . Json.encode $
+ JSONResult (toJSONErrors verbose P.Warning [] warnings)
+ (either (toJSONErrors verbose P.Error []) (const []) errors)
+ case errors of
+ Left _errs -> exitFailure
+ Right res -> pure res
diff --git a/app/Command/Hierarchy.hs b/app/Command/Hierarchy.hs
index 9e0b26e9fc..4da946ba1f 100644
--- a/app/Command/Hierarchy.hs
+++ b/app/Command/Hierarchy.hs
@@ -13,43 +13,41 @@
--
-----------------------------------------------------------------------------
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE DataKinds #-}
-
module Command.Hierarchy (command) where
-import Protolude (catMaybes)
+import Prelude
+import Protolude (catMaybes)
-import Control.Applicative (optional)
-import Data.Foldable (for_)
-import qualified Data.Text as T
-import qualified Data.Text.IO as T
-import Options.Applicative (Parser)
-import qualified Options.Applicative as Opts
-import System.Directory (createDirectoryIfMissing)
-import System.FilePath ((>))
-import System.FilePath.Glob (glob)
-import System.Exit (exitFailure, exitSuccess)
-import System.IO (hPutStr, stderr)
-import System.IO.UTF8 (readUTF8FileT)
-import qualified Language.PureScript as P
-import qualified Language.PureScript.CST as CST
-import Language.PureScript.Hierarchy (Graph(..), _unDigraph, _unGraphName, typeClasses)
+import Control.Applicative (optional)
+import Data.Foldable (for_)
+import Data.Text qualified as T
+import Data.Text.IO qualified as T
+import Options.Applicative (Parser)
+import Options.Applicative qualified as Opts
+import System.Directory (createDirectoryIfMissing)
+import System.FilePath ((>))
+import System.FilePath.Glob (glob)
+import System.Exit (exitFailure, exitSuccess)
+import System.IO (hPutStr, stderr)
+import System.IO.UTF8 (readUTF8FilesT)
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Hierarchy (Graph(..), _unDigraph, _unGraphName, typeClasses)
data HierarchyOptions = HierarchyOptions
- { _hierachyInput :: FilePath
+ { _hierarchyInput :: FilePath
, _hierarchyOutput :: Maybe FilePath
}
-readInput :: [FilePath] -> IO (Either P.MultipleErrors [P.Module])
-readInput paths = do
- content <- mapM (\path -> (path, ) <$> readUTF8FileT path) paths
- return $ map snd <$> CST.parseFromFiles id content
+parseInput :: [FilePath] -> IO (Either P.MultipleErrors [P.Module])
+parseInput paths = do
+ content <- readUTF8FilesT paths
+ return $ map (snd . snd) <$> CST.parseFromFiles id content
compile :: HierarchyOptions -> IO ()
compile (HierarchyOptions inputGlob mOutput) = do
input <- glob inputGlob
- modules <- readInput input
+ modules <- parseInput input
case modules of
Left errs -> hPutStr stderr (P.prettyPrintMultipleErrors P.defaultPPEOptions errs) >> exitFailure
Right ms -> do
diff --git a/app/Command/Ide.hs b/app/Command/Ide.hs
index 30adccc71b..f5a501af75 100644
--- a/app/Command/Ide.hs
+++ b/app/Command/Ide.hs
@@ -12,38 +12,34 @@
-- The server accepting commands for psc-ide
-----------------------------------------------------------------------------
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE PackageImports #-}
-{-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE PackageImports #-}
+{-# LANGUAGE TemplateHaskell #-}
module Command.Ide (command) where
-import Protolude
-
-import qualified Data.Aeson as Aeson
-import Control.Concurrent.STM
-import "monad-logger" Control.Monad.Logger
-import qualified Data.Text.IO as T
-import qualified Data.ByteString.Char8 as BS8
-import qualified Data.ByteString.Lazy.Char8 as BSL8
-import GHC.IO.Exception (IOErrorType(..), IOException(..))
-import Language.PureScript.Ide
-import Language.PureScript.Ide.Command
-import Language.PureScript.Ide.Util
-import Language.PureScript.Ide.Error
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Watcher
-import qualified Network.Socket as Network
-import qualified Options.Applicative as Opts
-import System.Directory
-import System.Info as SysInfo
-import System.FilePath
-import System.IO hiding (putStrLn, print)
-import System.IO.Error (isEOFError)
+import Protolude
+
+import Data.Aeson qualified as Aeson
+import Control.Concurrent.STM (newTVarIO)
+import "monad-logger" Control.Monad.Logger (MonadLogger, logDebug, logError, logInfo)
+import Data.IORef (newIORef)
+import Data.Text.IO qualified as T
+import Data.ByteString.Char8 qualified as BS8
+import Data.ByteString.Lazy.Char8 qualified as BSL8
+import GHC.IO.Exception (IOErrorType(..), IOException(..))
+import Language.PureScript.Ide (handleCommand)
+import Language.PureScript.Ide.Command (Command(..), commandName)
+import Language.PureScript.Ide.Util (decodeT, displayTimeSpec, encodeT, logPerf, runLogger)
+import Language.PureScript.Ide.Error (IdeError(..))
+import Language.PureScript.Ide.State (updateCacheTimestamp)
+import Language.PureScript.Ide.Types (Ide, IdeConfiguration(..), IdeEnvironment(..), IdeLogLevel(..), emptyIdeState)
+import Network.Socket qualified as Network
+import Options.Applicative qualified as Opts
+import SharedCLI qualified
+import System.Directory (doesDirectoryExist, getCurrentDirectory, setCurrentDirectory)
+import System.FilePath ((>))
+import System.IO (BufferMode(..), hClose, hFlush, hSetBuffering, hSetEncoding, utf8)
+import System.IO.Error (isEOFError)
listenOnLocalhost :: Network.PortNumber -> IO Network.Socket
listenOnLocalhost port = do
@@ -64,12 +60,15 @@ listenOnLocalhost port = do
data ServerOptions = ServerOptions
{ _serverDirectory :: Maybe FilePath
, _serverGlobs :: [FilePath]
+ , _serverGlobsFromFile :: Maybe FilePath
+ , _serverGlobsExcluded :: [FilePath]
, _serverOutputPath :: FilePath
, _serverPort :: Network.PortNumber
- , _serverNoWatch :: Bool
- , _serverPolling :: Bool
, _serverLoglevel :: IdeLogLevel
+ -- TODO(Christoph) Deprecated
, _serverEditorMode :: Bool
+ , _serverPolling :: Bool
+ , _serverNoWatch :: Bool
} deriving (Show)
data ClientOptions = ClientOptions
@@ -114,7 +113,7 @@ command = Opts.helper <*> subcommands where
Opts.option Opts.auto (Opts.long "port" `mappend` Opts.short 'p' `mappend` Opts.value (4242 :: Integer))
server :: ServerOptions -> IO ()
- server opts'@(ServerOptions dir globs outputPath port noWatch polling logLevel editorMode) = do
+ server opts'@(ServerOptions dir globs globsFromFile globsExcluded outputPath port logLevel editorMode polling noWatch) = do
when (logLevel == LogDebug || logLevel == LogAll)
(putText "Parsed Options:" *> print opts')
maybe (pure ()) setCurrentDirectory dir
@@ -122,37 +121,54 @@ command = Opts.helper <*> subcommands where
cwd <- getCurrentDirectory
let fullOutputPath = cwd > outputPath
+ when editorMode
+ (putText "The --editor-mode flag is deprecated and ignored. It's now the default behaviour and the flag will be removed in a future version")
+
+ when polling
+ (putText "The --polling flag is deprecated and ignored. purs ide no longer uses a file system watcher, instead it relies on its clients to notify it about updates and checks timestamps to invalidate itself")
+
+ when noWatch
+ (putText "The --no-watch flag is deprecated and ignored. purs ide no longer uses a file system watcher, instead it relies on its clients to notify it about updates and checks timestamps to invalidate itself")
+
unlessM (doesDirectoryExist fullOutputPath) $ do
putText "Your output directory didn't exist. This usually means you didn't compile your project yet."
putText "psc-ide needs you to compile your project (for example by running pulp build)"
- unless (noWatch || editorMode) $
- void (forkFinally (watcher polling logLevel ideState fullOutputPath) print)
let
conf = IdeConfiguration
{ confLogLevel = logLevel
, confOutputPath = outputPath
, confGlobs = globs
- , confEditorMode = editorMode
+ , confGlobsFromFile = globsFromFile
+ , confGlobsExclude = globsExcluded
+ }
+ ts <- newIORef Nothing
+ let
+ env = IdeEnvironment
+ { ideStateVar = ideState
+ , ideConfiguration = conf
+ , ideCacheDbTimestamp = ts
}
- let env = IdeEnvironment {ideStateVar = ideState, ideConfiguration = conf}
startServer port env
serverOptions :: Opts.Parser ServerOptions
serverOptions =
ServerOptions
<$> optional (Opts.strOption (Opts.long "directory" `mappend` Opts.short 'd'))
- <*> many (Opts.argument Opts.str (Opts.metavar "Source GLOBS..."))
+ <*> many SharedCLI.inputFile
+ <*> SharedCLI.globInputFile
+ <*> many SharedCLI.excludeFiles
<*> Opts.strOption (Opts.long "output-directory" `mappend` Opts.value "output/")
<*> (fromIntegral <$>
Opts.option Opts.auto (Opts.long "port" `mappend` Opts.short 'p' `mappend` Opts.value (4242 :: Integer)))
- <*> Opts.switch (Opts.long "no-watch")
- <*> flipIfWindows (Opts.switch (Opts.long "polling"))
<*> (parseLogLevel <$> Opts.strOption
(Opts.long "log-level"
`mappend` Opts.value ""
`mappend` Opts.help "One of \"debug\", \"perf\", \"all\" or \"none\""))
+ -- TODO(Christoph): Deprecated
<*> Opts.switch (Opts.long "editor-mode")
+ <*> Opts.switch (Opts.long "no-watch")
+ <*> Opts.switch (Opts.long "polling")
parseLogLevel :: Text -> IdeLogLevel
parseLogLevel s = case s of
@@ -162,10 +178,6 @@ command = Opts.helper <*> subcommands where
"none" -> LogNone
_ -> LogDefault
- -- polling is the default on Windows and the flag turns it off. See
- -- #2209 and #2414 for explanations
- flipIfWindows = map (if SysInfo.os == "mingw32" then not else identity)
-
startServer :: Network.PortNumber -> IdeEnvironment -> IO ()
startServer port env = Network.withSocketsDo $ do
sock <- listenOnLocalhost port
@@ -178,30 +190,45 @@ startServer port env = Network.withSocketsDo $ do
Left err -> $(logError) err
Right (cmd, h) -> do
case decodeT cmd of
- Just cmd' -> do
+ Right cmd' -> do
let message duration =
"Command "
<> commandName cmd'
<> " took "
<> displayTimeSpec duration
logPerf message $ do
- result <- runExceptT (handleCommand cmd')
+ result <- runExceptT $ do
+ updateCacheTimestamp >>= \case
+ Nothing -> pure ()
+ Just (before, after) -> do
+ -- If the cache db file was changed outside of the IDE
+ -- we trigger a reset before processing the command
+ $(logInfo) ("cachedb was changed from: " <> show before <> ", to: " <> show after)
+ unless (isLoadAll cmd') $
+ void (handleCommand Reset *> handleCommand (LoadSync []))
+ handleCommand cmd'
liftIO $ catchGoneHandle $ BSL8.hPutStrLn h $ case result of
Right r -> Aeson.encode r
Left err -> Aeson.encode err
liftIO (hFlush stdout)
- Nothing -> do
- $(logError) ("Parsing the command failed. Command: " <> cmd)
+ Left err -> do
+ let errMsg = "Parsing the command failed with:\n" <> err <> "\nCommand: " <> cmd
+ $(logError) errMsg
liftIO $ do
- catchGoneHandle (T.hPutStrLn h (encodeT (GeneralError "Error parsing Command.")))
+ catchGoneHandle (T.hPutStrLn h (encodeT (GeneralError errMsg)))
hFlush stdout
liftIO $ catchGoneHandle (hClose h)
+isLoadAll :: Command -> Bool
+isLoadAll = \case
+ Load [] -> True
+ _ -> False
+
catchGoneHandle :: IO () -> IO ()
catchGoneHandle =
handle (\e -> case e of
IOError { ioe_type = ResourceVanished } ->
- putText ("[Error] psc-ide-server tried interact with the handle, but the connection was already gone.")
+ putText "[Error] psc-ide-server tried to interact with the handle, but the connection was already gone."
_ -> throwIO e)
acceptCommand
diff --git a/app/Command/Publish.hs b/app/Command/Publish.hs
index bffb3e838a..b63d366c91 100644
--- a/app/Command/Publish.hs
+++ b/app/Command/Publish.hs
@@ -1,16 +1,23 @@
-{-# LANGUAGE OverloadedStrings #-}
-
module Command.Publish (command) where
-import Control.Monad.IO.Class (liftIO)
-import qualified Data.Aeson as A
-import qualified Data.ByteString.Lazy.Char8 as BL
-import Data.Time.Clock (getCurrentTime)
-import Data.Version (Version(..))
-import Language.PureScript.Publish
-import Language.PureScript.Publish.ErrorsWarnings
-import Options.Applicative (Parser)
-import qualified Options.Applicative as Opts
+import Prelude
+
+import Control.Monad.IO.Class (liftIO)
+import Data.Aeson qualified as A
+import Data.ByteString.Lazy.Char8 qualified as BL
+import Data.Time.Clock (getCurrentTime)
+import Data.Version (Version(..))
+import Language.PureScript.Publish (PublishOptions(..), defaultPublishOptions, unsafePreparePackage, warn)
+import Language.PureScript.Publish.ErrorsWarnings (PackageWarning(..))
+import Options.Applicative (Parser)
+import Options.Applicative qualified as Opts
+
+data PublishOptionsCLI = PublishOptionsCLI
+ { cliManifestPath :: FilePath
+ , cliResolutionsPath :: FilePath
+ , cliCompileOutputDir :: FilePath
+ , cliDryRun :: Bool
+ }
manifestPath :: Parser FilePath
manifestPath = Opts.strOption $
@@ -29,23 +36,45 @@ dryRun = Opts.switch $
Opts.long "dry-run"
<> Opts.help "Produce no output, and don't require a tagged version to be checked out."
-dryRunOptions :: PublishOptions
-dryRunOptions = defaultPublishOptions
- { publishGetVersion = return dummyVersion
- , publishWorkingTreeDirty = warn DirtyWorkingTree_Warn
- , publishGetTagTime = const (liftIO getCurrentTime)
- }
- where dummyVersion = ("0.0.0", Version [0,0,0] [])
+compileOutputDir :: Opts.Parser FilePath
+compileOutputDir = Opts.option Opts.auto $
+ Opts.value "output"
+ <> Opts.showDefault
+ <> Opts.long "compile-output"
+ <> Opts.metavar "DIR"
+ <> Opts.help "Compiler output directory"
+
+cliOptions :: Opts.Parser PublishOptionsCLI
+cliOptions =
+ PublishOptionsCLI <$> manifestPath <*> resolutionsPath <*> compileOutputDir <*> dryRun
+
+mkPublishOptions :: PublishOptionsCLI -> PublishOptions
+mkPublishOptions cliOpts =
+ let
+ opts =
+ defaultPublishOptions
+ { publishManifestFile = cliManifestPath cliOpts
+ , publishResolutionsFile = cliResolutionsPath cliOpts
+ , publishCompileOutputDir = cliCompileOutputDir cliOpts
+ }
+ in
+ if cliDryRun cliOpts
+ then
+ opts
+ { publishGetVersion = return ("0.0.0", Version [0,0,0] [])
+ , publishGetTagTime = const (liftIO getCurrentTime)
+ , publishWorkingTreeDirty = warn DirtyWorkingTreeWarn
+ }
+ else
+ opts
command :: Opts.Parser (IO ())
-command = publish <$> manifestPath <*> resolutionsPath <*> (Opts.helper <*> dryRun)
-
-publish :: FilePath -> FilePath -> Bool -> IO ()
-publish manifestFile resolutionsFile isDryRun =
- if isDryRun
- then do
- _ <- unsafePreparePackage manifestFile resolutionsFile dryRunOptions
- putStrLn "Dry run completed, no errors."
- else do
- pkg <- unsafePreparePackage manifestFile resolutionsFile defaultPublishOptions
- BL.putStrLn (A.encode pkg)
+command = publish <$> (Opts.helper <*> cliOptions)
+
+publish :: PublishOptionsCLI -> IO ()
+publish cliOpts = do
+ let opts = mkPublishOptions cliOpts
+ pkg <- unsafePreparePackage opts
+ if cliDryRun cliOpts
+ then putStrLn "Dry run completed, no errors."
+ else BL.putStrLn (A.encode pkg)
diff --git a/app/Command/REPL.hs b/app/Command/REPL.hs
index f44c1e8abe..4d73c2303c 100644
--- a/app/Command/REPL.hs
+++ b/app/Command/REPL.hs
@@ -1,71 +1,39 @@
-{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DoAndIfThenElse #-}
{-# LANGUAGE GADTs #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE PatternGuards #-}
-{-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE TupleSections #-}
module Command.REPL (command) where
-import Prelude ()
-import Prelude.Compat
-import Control.Applicative (many, (<|>))
-import Control.Concurrent (forkIO)
-import Control.Concurrent.MVar (MVar, newEmptyMVar, putMVar, takeMVar,
- tryPutMVar)
-import Control.Concurrent.STM (TVar, atomically, newTVarIO, writeTVar,
- readTVarIO,
- TChan, newBroadcastTChanIO, dupTChan,
- readTChan, writeTChan)
-import Control.Exception (fromException)
-import Control.Monad
-import Control.Monad.IO.Class (liftIO)
-import Control.Monad.Trans.Class
-import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
-import Control.Monad.Trans.State.Strict (StateT, evalStateT)
-import Control.Monad.Trans.Reader (ReaderT, runReaderT)
-import Data.FileEmbed (embedStringFile)
-import Data.Foldable (for_)
-import Data.String (IsString(..))
-import Data.Text (Text, unpack)
-import Data.Traversable (for)
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Bundle as Bundle
-import qualified Language.PureScript.CST as CST
-import Language.PureScript.Interactive
-import Network.HTTP.Types.Header (hContentType, hCacheControl,
- hPragma, hExpires)
-import Network.HTTP.Types.Status (status200, status404, status503)
-import qualified Network.Wai as Wai
-import qualified Network.Wai.Handler.Warp as Warp
-import qualified Network.Wai.Handler.WebSockets as WS
-import qualified Network.WebSockets as WS
-import qualified Options.Applicative as Opts
-import System.Console.Haskeline
-import System.IO.UTF8 (readUTF8File)
-import System.Exit
-import System.Directory (doesFileExist, getCurrentDirectory)
-import System.FilePath ((>))
-import System.FilePath.Glob (glob)
-import System.Process (readProcessWithExitCode)
-import qualified Data.ByteString.Lazy.UTF8 as U
+import Prelude
+import Control.Applicative (many, (<|>))
+import Control.Monad (unless, when)
+import Control.Monad.Catch (MonadMask)
+import Control.Monad.IO.Class (liftIO, MonadIO)
+import Control.Monad.Trans.Class (MonadTrans(..))
+import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
+import Control.Monad.Trans.State.Strict (StateT, evalStateT)
+import Control.Monad.Trans.Reader (ReaderT, runReaderT)
+import Data.Foldable (for_)
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Glob (PSCGlobs(..), toInputGlobs, warnFileTypeNotFound)
+import Language.PureScript.Interactive
+import Options.Applicative qualified as Opts
+import SharedCLI qualified
+import System.Console.Haskeline (InputT, Settings(..), defaultSettings, getInputLine, handleInterrupt, outputStrLn, runInputT, setComplete, withInterrupt)
+import System.IO.UTF8 (readUTF8File)
+import System.Exit (ExitCode(..), exitFailure)
+import System.Directory (doesFileExist, getCurrentDirectory)
+import System.FilePath ((>))
+import System.IO (hPutStrLn, stderr)
-- | Command line options
data PSCiOptions = PSCiOptions
{ psciInputGlob :: [String]
+ , psciInputFromFile :: Maybe String
+ , psciExclude :: [String]
, psciBackend :: Backend
}
-inputFile :: Opts.Parser FilePath
-inputFile = Opts.strArgument $
- Opts.metavar "FILES"
- <> Opts.help "Optional .purs files to load on start"
-
nodePathOption :: Opts.Parser (Maybe FilePath)
nodePathOption = Opts.optional . Opts.strOption $
Opts.metavar "FILE"
@@ -85,7 +53,7 @@ port :: Opts.Parser Int
port = Opts.option Opts.auto $
Opts.long "port"
<> Opts.short 'p'
- <> Opts.help "The web server port"
+ <> Opts.help "The browser REPL backend was removed in v0.15.0. Use https://try.purescript.org instead."
backend :: Opts.Parser Backend
backend =
@@ -93,11 +61,13 @@ backend =
<|> (nodeBackend <$> nodePathOption <*> nodeFlagsOption)
psciOptions :: Opts.Parser PSCiOptions
-psciOptions = PSCiOptions <$> many inputFile
+psciOptions = PSCiOptions <$> many SharedCLI.inputFile
+ <*> SharedCLI.globInputFile
+ <*> many SharedCLI.excludeFiles
<*> backend
-- | Parses the input and returns either a command, or an error as a 'String'.
-getCommand :: forall m. MonadException m => InputT m (Either String [Command])
+getCommand :: forall m. (MonadIO m, MonadMask m) => InputT m (Either String [Command])
getCommand = handleInterrupt (return (Right [])) $ do
line <- withInterrupt $ getInputLine "> "
case line of
@@ -105,29 +75,13 @@ getCommand = handleInterrupt (return (Right [])) $ do
Just "" -> return (Right [])
Just s -> return (parseCommand s)
-pasteMode :: forall m. MonadException m => InputT m (Either String [Command])
+pasteMode :: forall m. (MonadIO m, MonadMask m) => InputT m (Either String [Command])
pasteMode =
parseCommand <$> go []
where
go :: [String] -> InputT m String
go ls = maybe (return . unlines $ reverse ls) (go . (:ls)) =<< getInputLine "… "
--- | Make a JavaScript bundle for the browser.
-bundle :: IO (Either Bundle.ErrorMessage String)
-bundle = runExceptT $ do
- inputFiles <- liftIO (glob (".psci_modules" > "node_modules" > "*" > "*.js"))
- input <- for inputFiles $ \filename -> do
- js <- liftIO (readUTF8File filename)
- mid <- Bundle.guessModuleIdentifier filename
- length js `seq` return (mid, js)
- Bundle.bundle input [] Nothing "PSCI"
-
-indexJS :: IsString string => string
-indexJS = $(embedStringFile "app/static/index.js")
-
-indexPage :: IsString string => string
-indexPage = $(embedStringFile "app/static/index.html")
-
-- | All of the functions required to implement a PSCi backend
data Backend = forall state. Backend
{ _backendSetup :: IO state
@@ -140,144 +94,13 @@ data Backend = forall state. Backend
-- ^ Shut down the backend
}
--- | Commands which can be sent to the browser
-data BrowserCommand
- = Eval (MVar String)
- -- ^ Evaluate the latest JS
- | Refresh
- -- ^ Refresh the page
-
--- | State for the browser backend
-data BrowserState = BrowserState
- { browserCommands :: TChan BrowserCommand
- -- ^ A channel which receives data when the compiled JS has
- -- been updated
- , browserShutdownNotice :: MVar ()
- -- ^ An MVar which becomes full when the server should shut down
- , browserIndexJS :: TVar (Maybe String)
- -- ^ A TVar holding the latest compiled JS
- , browserBundleJS :: TVar (Maybe String)
- -- ^ A TVar holding the latest bundled JS
- }
-
browserBackend :: Int -> Backend
-browserBackend serverPort = Backend setup evaluate reload shutdown
+browserBackend _ = Backend setup mempty mempty mempty
where
- setup :: IO BrowserState
+ setup :: IO ()
setup = do
- shutdownVar <- newEmptyMVar
- cmdChan <- newBroadcastTChanIO
- indexJs <- newTVarIO Nothing
- bundleJs <- newTVarIO Nothing
-
- let
- handleWebsocket :: WS.PendingConnection -> IO ()
- handleWebsocket pending = do
- conn <- WS.acceptRequest pending
- -- Fork a thread to keep the connection alive
- WS.forkPingThread conn 10
- -- Clone the command channel
- cmdChanCopy <- atomically $ dupTChan cmdChan
- -- Listen for commands
- forever $ do
- cmd <- atomically $ readTChan cmdChanCopy
- case cmd of
- Eval resultVar -> void $ do
- WS.sendTextData conn ("eval" :: Text)
- result <- WS.receiveData conn
- -- With many connected clients, all but one of
- -- these attempts will fail.
- tryPutMVar resultVar (unpack result)
- Refresh ->
- WS.sendTextData conn ("reload" :: Text)
-
- shutdownHandler :: IO () -> IO ()
- shutdownHandler stopServer = void . forkIO $ do
- () <- takeMVar shutdownVar
- stopServer
-
- onException :: Maybe Wai.Request -> SomeException -> IO ()
- onException req ex
- | Just (_ :: WS.ConnectionException) <- fromException ex
- = return () -- ignore websocket disconnects
- | otherwise = Warp.defaultOnException req ex
-
- staticServer :: Wai.Application
- staticServer req respond =
- case Wai.pathInfo req of
- [] ->
- respond $ Wai.responseLBS status200
- [(hContentType, "text/html; charset=UTF-8")]
- (U.fromString indexPage)
- ["js", "index.js"] ->
- respond $ Wai.responseLBS status200
- [(hContentType, "application/javascript")]
- (U.fromString indexJS)
- ["js", "latest.js"] -> do
- may <- readTVarIO indexJs
- case may of
- Nothing ->
- respond $ Wai.responseLBS status503 [] "Service not available"
- Just js ->
- respond $ Wai.responseLBS status200
- [ (hContentType, "application/javascript")
- , (hCacheControl, "no-cache, no-store, must-revalidate")
- , (hPragma, "no-cache")
- , (hExpires, "0")
- ]
- (U.fromString js)
- ["js", "bundle.js"] -> do
- may <- readTVarIO bundleJs
- case may of
- Nothing ->
- respond $ Wai.responseLBS status503 [] "Service not available"
- Just js ->
- respond $ Wai.responseLBS status200
- [ (hContentType, "application/javascript")]
- (U.fromString js)
- _ -> respond $ Wai.responseLBS status404 [] "Not found"
-
- let browserState = BrowserState cmdChan shutdownVar indexJs bundleJs
- createBundle browserState
-
- putStrLn $ "Serving http://localhost:" <> show serverPort <> "/. Waiting for connections..."
- _ <- forkIO $ Warp.runSettings ( Warp.setInstallShutdownHandler shutdownHandler
- . Warp.setPort serverPort
- . Warp.setOnException onException
- $ Warp.defaultSettings
- ) $
- WS.websocketsOr WS.defaultConnectionOptions
- handleWebsocket
- staticServer
- return browserState
-
- createBundle :: BrowserState -> IO ()
- createBundle state = do
- putStrLn "Bundling JavaScript..."
- ejs <- bundle
- case ejs of
- Left err -> do
- putStrLn (unlines (Bundle.printErrorMessage err))
- exitFailure
- Right js ->
- atomically $ writeTVar (browserBundleJS state) (Just js)
-
- reload :: BrowserState -> IO ()
- reload state = do
- createBundle state
- atomically $ writeTChan (browserCommands state) Refresh
-
- shutdown :: BrowserState -> IO ()
- shutdown state = putMVar (browserShutdownNotice state) ()
-
- evaluate :: BrowserState -> String -> IO ()
- evaluate state js = liftIO $ do
- resultVar <- newEmptyMVar
- atomically $ do
- writeTVar (browserIndexJS state) (Just js)
- writeTChan (browserCommands state) (Eval resultVar)
- result <- takeMVar resultVar
- putStrLn result
+ hPutStrLn stderr "The browser REPL backend was removed in v0.15.0. Use TryPureScript instead: https://try.purescript.org"
+ exitFailure
nodeBackend :: Maybe FilePath -> [String] -> Backend
nodeBackend nodePath nodeArgs = Backend setup eval reload shutdown
@@ -287,13 +110,12 @@ nodeBackend nodePath nodeArgs = Backend setup eval reload shutdown
eval :: () -> String -> IO ()
eval _ _ = do
- writeFile indexFile "require('$PSCI')['$main']();"
- process <- maybe findNodeProcess (pure . pure) nodePath
- result <- traverse (\node -> readProcessWithExitCode node (nodeArgs ++ [indexFile]) "") process
+ writeFile indexFile "import('./$PSCI/index.js').then(({ $main }) => $main());"
+ result <- readNodeProcessWithExitCode nodePath (nodeArgs ++ [indexFile]) ""
case result of
- Just (ExitSuccess, out, _) -> putStrLn out
- Just (ExitFailure _, _, err) -> putStrLn err
- Nothing -> putStrLn "Could not find node.js. Do you have node.js installed and available in your PATH?"
+ Right (ExitSuccess, out, _) -> putStrLn out
+ Right (ExitFailure _, _, err) -> putStrLn err
+ Left err -> putStrLn err
reload :: () -> IO ()
reload _ = return ()
@@ -310,7 +132,12 @@ command = loop <$> options
where
loop :: PSCiOptions -> IO ()
loop PSCiOptions{..} = do
- inputFiles <- concat <$> traverse glob psciInputGlob
+ inputFiles <- toInputGlobs $ PSCGlobs
+ { pscInputGlobs = psciInputGlob
+ , pscInputGlobsFromFile = psciInputFromFile
+ , pscExcludeGlobs = psciExclude
+ , pscWarnFileTypeNotFound = warnFileTypeNotFound "repl"
+ }
e <- runExceptT $ do
modules <- ExceptT (loadAllModules inputFiles)
when (null modules) . liftIO $ do
diff --git a/app/Main.hs b/app/Main.hs
index f3e72ab68a..ff4e04ab6d 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -1,33 +1,32 @@
-{-# LANGUAGE DeriveAnyClass #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE NamedFieldPuns #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE TupleSections #-}
-
module Main where
-import qualified Command.Bundle as Bundle
-import qualified Command.Compile as Compile
-import qualified Command.Docs as Docs
-import qualified Command.Hierarchy as Hierarchy
-import qualified Command.Ide as Ide
-import qualified Command.Publish as Publish
-import qualified Command.REPL as REPL
-import Data.Foldable (fold)
-import qualified Options.Applicative as Opts
-import System.Environment (getArgs)
-import qualified System.IO as IO
-import qualified Text.PrettyPrint.ANSI.Leijen as Doc
-import Version (versionString)
+import Prelude
+
+import Command.Bundle qualified as Bundle
+import Command.Compile qualified as Compile
+import Command.Docs qualified as Docs
+import Command.Graph qualified as Graph
+import Command.Hierarchy qualified as Hierarchy
+import Command.Ide qualified as Ide
+import Command.Publish qualified as Publish
+import Command.REPL qualified as REPL
+import Control.Monad (join)
+import Data.Foldable (fold)
+import Options.Applicative qualified as Opts
+import Prettyprinter qualified as Doc
+import Prettyprinter.Render.Terminal (AnsiStyle)
+import System.Environment (getArgs)
+import System.IO qualified as IO
+import Version (versionString)
main :: IO ()
main = do
IO.hSetEncoding IO.stdout IO.utf8
IO.hSetEncoding IO.stderr IO.utf8
- cmd <- Opts.handleParseResult . execParserPure opts =<< getArgs
- cmd
+ IO.hSetBuffering IO.stdout IO.LineBuffering
+ IO.hSetBuffering IO.stderr IO.LineBuffering
+ join $ Opts.handleParseResult . execParserPure opts =<< getArgs
where
opts = Opts.info (versionInfo <*> Opts.helper <*> commands) infoModList
infoModList = Opts.fullDesc <> headerInfo <> footerInfo
@@ -41,16 +40,16 @@ main = do
"For example, `purs compile --help` displays options specific to the `compile` command."
, Doc.hardline
, Doc.hardline
- , Doc.text $ "purs " ++ versionString
+ , Doc.pretty $ "purs " ++ versionString
]
- para :: String -> Doc.Doc
- para = foldr (Doc.>) Doc.empty . map Doc.text . words
+ para :: String -> Doc.Doc AnsiStyle
+ para = foldr (\x y -> x <> Doc.softline <> y) mempty . map Doc.pretty . words
-- | Displays full command help when invoked with no arguments.
execParserPure :: Opts.ParserInfo a -> [String] -> Opts.ParserResult a
execParserPure pinfo [] = Opts.Failure $
- Opts.parserFailure Opts.defaultPrefs pinfo Opts.ShowHelpText mempty
+ Opts.parserFailure Opts.defaultPrefs pinfo (Opts.ShowHelpText Nothing) mempty
execParserPure pinfo args = Opts.execParserPure Opts.defaultPrefs pinfo args
versionInfo :: Opts.Parser (a -> a)
@@ -62,13 +61,16 @@ main = do
(Opts.subparser . fold)
[ Opts.command "bundle"
(Opts.info Bundle.command
- (Opts.progDesc "Bundle compiled PureScript modules for the browser"))
+ (Opts.progDesc "This command was removed in v0.15.0. Run this command for migration information."))
, Opts.command "compile"
(Opts.info Compile.command
(Opts.progDesc "Compile PureScript source files"))
, Opts.command "docs"
(Opts.info Docs.command
(Opts.progDesc "Generate documentation from PureScript source files in a variety of formats, including Markdown and HTML" <> Docs.infoModList))
+ , Opts.command "graph"
+ (Opts.info Graph.command
+ (Opts.progDesc "Module dependency graph"))
, Opts.command "hierarchy"
(Opts.info Hierarchy.command
(Opts.progDesc "Generate a GraphViz directed graph of PureScript type classes"))
diff --git a/app/SharedCLI.hs b/app/SharedCLI.hs
new file mode 100644
index 0000000000..0aa85469d4
--- /dev/null
+++ b/app/SharedCLI.hs
@@ -0,0 +1,24 @@
+module SharedCLI where
+
+import Prelude
+
+import Options.Applicative qualified as Opts
+
+inputFile :: Opts.Parser FilePath
+inputFile = Opts.strArgument $
+ Opts.metavar "GLOB"
+ <> Opts.help "A glob for input .purs file(s)."
+
+globInputFile :: Opts.Parser (Maybe FilePath)
+globInputFile = Opts.optional $ Opts.strOption $
+ Opts.long "source-globs-file"
+ <> Opts.metavar "FILE"
+ <> Opts.help "A file containing a line-separated list of input .purs globs."
+
+excludeFiles :: Opts.Parser FilePath
+excludeFiles = Opts.strOption $
+ Opts.short 'x'
+ <> Opts.long "exclude-files"
+ <> Opts.metavar "GLOB"
+ <> Opts.help "A glob of .purs files to exclude from the input .purs files."
+
diff --git a/app/Version.hs b/app/Version.hs
index dcf385041a..35f620b127 100644
--- a/app/Version.hs
+++ b/app/Version.hs
@@ -3,21 +3,31 @@
module Version where
+import Prelude
+
import Data.Version (showVersion)
import Paths_purescript as Paths
#ifndef RELEASE
-import qualified Development.GitRev as GitRev
+import Development.GitRev qualified as GitRev
#endif
+-- Unfortunately, Cabal doesn't support prerelease identifiers on versions. To
+-- avoid misleading users who run `purs --version`, we manually add the
+-- prerelease identifier here (if any). When releasing a proper version, simply
+-- set this to an empty string.
+prerelease :: String
+prerelease = ""
+
versionString :: String
-versionString = showVersion Paths.version ++ extra
+versionString = showVersion Paths.version ++ prerelease ++ extra
where
#ifdef RELEASE
extra = ""
#else
extra = " [development build; commit: " ++ $(GitRev.gitHash) ++ dirty ++ "]"
- dirty
- | $(GitRev.gitDirty) = " DIRTY"
- | otherwise = ""
+ dirty =
+ if $(GitRev.gitDirty)
+ then " DIRTY"
+ else ""
#endif
diff --git a/app/static/index.html b/app/static/index.html
deleted file mode 100644
index f749b8ae22..0000000000
--- a/app/static/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- PureScript Interactive
-
-
-
-
-
-
diff --git a/app/static/index.js b/app/static/index.js
deleted file mode 100644
index 1d0714fd71..0000000000
--- a/app/static/index.js
+++ /dev/null
@@ -1,63 +0,0 @@
-var get = function get(uri, callback, onError) {
- var request = new XMLHttpRequest();
- request.addEventListener('load', function() {
- callback(request.responseText);
- });
- request.addEventListener('error', onError);
- request.open('GET', uri);
- request.send();
-};
-var evaluate = function evaluate(js) {
- var buffer = [];
- // Save the old console.log function
- var oldLog = console.log;
- console.log = function(s) {
- // Push log output into a temporary buffer
- // which will be returned to PSCi.
- buffer.push(s);
- };
- // Replace any require(...) statements with lookups on the PSCI object.
- var replaced = js.replace(/require\("[^"]*"\)/g, function(s) {
- return "PSCI['" + s.split('/')[1] + "']";
- });
- // Wrap the module and evaluate it.
- var wrapped =
- [ 'var module = {};'
- , '(function(module) {'
- , replaced
- , '})(module);'
- , 'return module.exports["$main"] && module.exports["$main"]();'
- ].join('\n');
- new Function(wrapped)();
- // Restore console.log
- console.log = oldLog;
- return buffer.join('\n');
-};
-window.onload = function() {
- var socket = new WebSocket('ws://localhost:' + location.port);
- var evalNext = function reload() {
- get('js/latest.js', function(response) {
- try {
- var result = evaluate(response);
- socket.send(result);
- } catch (ex) {
- socket.send(ex.stack);
- }
- }, function(err) {
- socket.send('Error sending JavaScript');
- });
- };
- socket.onopen = function() {
- console.log('Connected');
- socket.onmessage = function(event) {
- switch (event.data) {
- case 'eval':
- evalNext();
- break;
- case 'reload':
- location.reload();
- break;
- }
- };
- };
-};
diff --git a/app/static/pursuit.css b/app/static/pursuit.css
index dd4671995f..d7641624e0 100644
--- a/app/static/pursuit.css
+++ b/app/static/pursuit.css
@@ -49,6 +49,9 @@
* ========================================================================== */
/* Section: Document Styles
* ========================================================================== */
+:root {
+ color-scheme: light dark;
+}
html {
box-sizing: border-box;
/* This overflow rule prevents everything from shifting slightly to the side
@@ -63,11 +66,17 @@ html {
}
body {
background-color: #ffffff;
- color: #000;
+ color: #000000;
font-family: "Roboto", sans-serif;
font-size: 87.5%;
line-height: 1.563;
}
+@media (prefers-color-scheme: dark) {
+ body {
+ background-color: #141417;
+ color: #dedede;
+ }
+}
@media (min-width: 38em) {
body {
font-size: 100%;
@@ -158,6 +167,12 @@ body {
background-color: #1d222d;
color: #f0f0f0;
}
+@media (prefers-color-scheme: dark) {
+ .footer {
+ background-color: #1d222d;
+ color: #f0f0f0;
+ }
+}
.footer * {
margin-bottom: 0;
}
@@ -169,16 +184,32 @@ body {
:target {
background-color: #f1f5f9;
}
+@media (prefers-color-scheme: dark) {
+ :target {
+ background-color: #232327;
+ }
+}
a,
a:visited {
color: #c4953a;
text-decoration: none;
font-weight: bold;
}
+@media (prefers-color-scheme: dark) {
+ a,
+ a:visited {
+ color: #d8ac55;
+ }
+}
a:hover {
color: #7b5904;
text-decoration: none;
}
+@media (prefers-color-scheme: dark) {
+ a:hover {
+ color: #f0dcab;
+ }
+}
code,
pre {
background-color: #f1f5f9;
@@ -187,10 +218,23 @@ pre {
font-family: "Roboto Mono", monospace;
font-size: 87.5%;
}
+@media (prefers-color-scheme: dark) {
+ code,
+ pre {
+ background-color: #232327;
+ color: #c1d3da;
+ }
+}
:target code,
:target pre {
background-color: #dfe8f1;
}
+@media (prefers-color-scheme: dark) {
+ :target code,
+ :target pre {
+ background-color: #2f2f34;
+ }
+}
code {
padding: 0.2em 0;
margin: 0;
@@ -212,6 +256,11 @@ a > code::before {
a:hover > code {
color: #c4953a;
}
+@media (prefers-color-scheme: dark) {
+ a:hover > code {
+ color: #d8ac55;
+ }
+}
pre {
margin-top: 0;
margin-bottom: 0;
@@ -255,14 +304,14 @@ h1 {
h2 {
font-size: 1.953em;
font-weight: normal;
- line-height: 1.250;
+ line-height: 1.25;
margin-top: 3.052rem;
margin-bottom: 1rem;
}
h3 {
font-size: 1.563em;
font-weight: normal;
- line-height: 1.250;
+ line-height: 1.25;
margin-top: 2.441rem;
margin-bottom: 1rem;
}
@@ -285,6 +334,11 @@ hr {
height: 1px;
background-color: #cccccc;
}
+@media (prefers-color-scheme: dark) {
+ hr {
+ background-color: #43434e;
+ }
+}
img {
border-style: none;
max-width: 100%;
@@ -302,6 +356,11 @@ table {
margin-bottom: 1rem;
width: 100%;
}
+@media (prefers-color-scheme: dark) {
+ table {
+ border-bottom-color: #43434e;
+ }
+}
td,
th {
text-align: left;
@@ -310,6 +369,11 @@ th {
td {
border-top: 1px solid #cccccc;
}
+@media (prefers-color-scheme: dark) {
+ td {
+ border-top-color: #43434e;
+ }
+}
td:first-child,
th:first-child {
padding-left: 0;
@@ -326,7 +390,7 @@ ul {
}
ul li {
position: relative;
- padding-left: 1.250em;
+ padding-left: 1.25em;
}
ul li::before {
position: absolute;
@@ -334,7 +398,12 @@ ul li::before {
content: "–";
display: inline-block;
margin-left: -1.25em;
- width: 1.250em;
+ width: 1.25em;
+}
+@media (prefers-color-scheme: dark) {
+ ul li::before {
+ color: #a0a0a0;
+ }
}
/* Tying this tightly to ul at the moment because it's a slight variation thereof */
ul.ul--search li::before {
@@ -345,7 +414,7 @@ ul.ul--search li::before {
ol {
margin-top: 1rem;
margin-bottom: 1rem;
- padding-left: 1.250em;
+ padding-left: 1.25em;
}
ol li {
position: relative;
@@ -359,9 +428,9 @@ ol li {
position: relative;
top: -0.1em;
display: inline-block;
- background-color: #000;
+ background-color: #000000;
border-radius: 1.3em;
- color: #fff;
+ color: #ffffff;
font-size: 77%;
font-weight: bold;
line-height: 1.563;
@@ -369,10 +438,21 @@ ol li {
height: 1.5em;
width: 1.5em;
}
+@media (prefers-color-scheme: dark) {
+ .badge {
+ background-color: #dedede;
+ color: #141417;
+ }
+}
.badge.badge--package {
background-color: #c4953a;
letter-spacing: -0.1em;
}
+@media (prefers-color-scheme: dark) {
+ .badge.badge--package {
+ background-color: #d8ac55;
+ }
+}
.badge.badge--module {
background-color: #75B134;
}
@@ -396,22 +476,69 @@ ol li {
left: -0.8em;
color: #bababa;
}
+@media (prefers-color-scheme: dark) {
+ .decl__anchor,
+ .decl__anchor:visited {
+ color: #878787;
+ }
+}
.decl__anchor:hover {
color: #c4953a;
}
+@media (prefers-color-scheme: dark) {
+ .decl__anchor:hover {
+ color: #d8ac55;
+ }
+}
.decl__signature {
background-color: transparent;
border-radius: 0;
border-top: 1px solid #cccccc;
border-bottom: 1px solid #cccccc;
- padding: 0.328em 0;
+ padding: 0;
+}
+@media (prefers-color-scheme: dark) {
+ .decl__signature {
+ border-top-color: #43434e;
+ border-bottom-color: #43434e;
+ }
}
.decl__signature code {
display: block;
+ padding: 0.328em 0;
padding-left: 2.441em;
text-indent: -2.441em;
white-space: normal;
}
+.decl__role {
+ font-family: "Roboto", sans-serif;
+ font-style: italic;
+ font-weight: normal;
+}
+/* See https://stackoverflow.com/a/32162038
+ Content licensed under CC BY-SA 3.0
+*/
+.decl__role_hover[title] {
+ /* Remove line that appears under abbr element */
+ border-bottom: none;
+ text-decoration: none;
+ /* Ensure cursor doesn't change to question mark */
+ cursor: inherit;
+}
+.decl__role_nominal::after {
+ content: "nominal";
+}
+.decl__role_phantom::after {
+ content: "phantom";
+}
+.decl__kind {
+ border-bottom: 1px solid #cccccc;
+}
+@media (prefers-color-scheme: dark) {
+ .decl__kind {
+ border-bottom-color: #43434e;
+ }
+}
:target .decl__signature,
:target .decl__signature code {
/* We want the background to be transparent, even when the parent is a target */
@@ -419,7 +546,13 @@ ol li {
}
.decl__body .keyword,
.decl__body .syntax {
- color: #0B71B4;
+ color: #0b71b4;
+}
+@media (prefers-color-scheme: dark) {
+ .decl__body .keyword,
+ .decl__body .syntax {
+ color: #3796d5;
+ }
}
.decl__child_comments {
margin-top: 1rem;
@@ -440,12 +573,22 @@ ol li {
font-size: 0.8em;
line-height: 1;
}
+@media (prefers-color-scheme: dark) {
+ .deplink__version {
+ color: #a0a0a0;
+ }
+}
/* Component: Grouped List
* -------------------------------------------------------------------------- */
.grouped-list {
border-top: 1px solid #cccccc;
margin: 0 0 2.44em 0;
}
+@media (prefers-color-scheme: dark) {
+ .grouped-list {
+ border-top-color: #43434e;
+ }
+}
.grouped-list__title {
color: #666666;
font-size: 0.8em;
@@ -454,6 +597,11 @@ ol li {
margin: 0.8em 0 -0.1em 0;
text-transform: uppercase;
}
+@media (prefers-color-scheme: dark) {
+ .grouped-list__title {
+ border-top-color: #a0a0a0;
+ }
+}
.grouped-list__item {
margin: 0;
}
@@ -468,10 +616,22 @@ ol li {
background-color: #fff0f0;
border-color: #c85050;
}
+@media (prefers-color-scheme: dark) {
+ .message.message--error {
+ background-color: #6b0e0e;
+ border-color: #c85050;
+ }
+}
.message.message--not-available {
background-color: #f0f096;
border-color: #e3e33d;
}
+@media (prefers-color-scheme: dark) {
+ .message.message--not-available {
+ background-color: #56560b;
+ border-color: #b0b017;
+ }
+}
/* Component: Multi Col
* Multiple columns side by side
* -------------------------------------------------------------------------- */
@@ -523,6 +683,11 @@ ol li {
text-transform: uppercase;
z-index: 1;
}
+@media (prefers-color-scheme: dark) {
+ .page-title__label {
+ color: #a0a0a0;
+ }
+}
/* Component: Top Banner
* -------------------------------------------------------------------------- */
.top-banner {
@@ -530,6 +695,12 @@ ol li {
color: #f0f0f0;
font-weight: normal;
}
+@media (prefers-color-scheme: dark) {
+ .top-banner {
+ background-color: #1d222d;
+ color: #f0f0f0;
+ }
+}
.top-banner__logo,
.top-banner__logo:visited {
float: left;
@@ -539,6 +710,12 @@ ol li {
line-height: 90px;
margin: 0;
}
+@media (prefers-color-scheme: dark) {
+ .top-banner__logo,
+ .top-banner__logo:visited {
+ color: #f0f0f0;
+ }
+}
.top-banner__logo:hover {
color: #c4953a;
text-decoration: none;
@@ -549,12 +726,20 @@ ol li {
.top-banner__form input {
border: 1px solid #1d222d;
border-radius: 3px;
+ background-color: #ffffff;
color: #1d222d;
font-weight: 300;
line-height: 2;
padding: 0.21em 0.512em;
width: 100%;
}
+@media (prefers-color-scheme: dark) {
+ .top-banner__form input {
+ border-color: #1d222d;
+ background-color: #141417;
+ color: #dedede;
+ }
+}
.top-banner__actions {
float: right;
text-align: right;
@@ -572,9 +757,20 @@ ol li {
.top-banner__actions__item a:visited {
color: #f0f0f0;
}
+@media (prefers-color-scheme: dark) {
+ .top-banner__actions__item a,
+ .top-banner__actions__item a:visited {
+ color: #f0f0f0;
+ }
+}
.top-banner__actions__item a:hover {
color: #c4953a;
}
+@media (prefers-color-scheme: dark) {
+ .top-banner__actions__item a:hover {
+ color: #d8ac55;
+ }
+}
@media (min-width: 38em) {
.top-banner__logo {
float: left;
@@ -616,6 +812,12 @@ ol li {
border-bottom: 1px solid #cccccc;
padding: 0.328em 0;
}
+@media (prefers-color-scheme: dark) {
+ .result__signature {
+ border-top-color: #43434e;
+ border-bottom-color: #43434e;
+ }
+}
.result__signature code {
display: block;
padding-left: 2.441em;
@@ -682,6 +884,11 @@ ol li {
color: #777;
border-left: 0.25em solid #ddd;
}
+@media (prefers-color-scheme: dark) {
+ .markdown-body blockquote {
+ border-left-color: #444;
+ }
+}
.markdown-body blockquote > :first-child {
margin-top: 0;
}
@@ -696,6 +903,11 @@ ol li {
/* Keyword */
color: #a0a0a0;
}
+@media (prefers-color-scheme: dark) {
+ .markdown-body .pl-k {
+ color: #676767;
+ }
+}
.markdown-body .pl-c1,
.markdown-body .pl-en {
/* Not really sure what this is */
diff --git a/app/static/pursuit.less b/app/static/pursuit.less
index 1b064b2c5f..2520590ca3 100644
--- a/app/static/pursuit.less
+++ b/app/static/pursuit.less
@@ -49,9 +49,9 @@
/* Section: Variables
* ========================================================================== */
@background: rgb(255, 255, 255);
+@foreground: rgb(0, 0, 0);
@banner_background: rgb(29, 34, 45);
-@package_banner_background: lighten(@banner_background, 30%);
-@dark_foreground: rgb(240, 240, 240);
+@dim_foreground: rgb(240, 240, 240);
@link: rgb(196, 149, 58);
@link_active: rgb(123, 89, 4);
@error_background: rgb(255, 240, 240);
@@ -59,12 +59,32 @@
@not_available_background: rgb(240, 240, 150);
@code_foreground: rgb(25, 74, 91);
@code_background: rgb(241, 245, 249);
-@light_glyph: rgb(160, 160, 160);
-@light_type: rgb(102, 102, 102);
+@dim_glyph: rgb(160, 160, 160);
+@dim_type: rgb(102, 102, 102);
+@keyword: rgb(11, 113, 180);
+
+@dark_background: rgb(20, 20, 23);
+@dark_foreground: rgb(222, 222, 222);
+@dark_banner_background: rgb(29, 34, 45);
+@dark_dim_foreground: rgb(240, 240, 240);
+@dark_link: rgb(216, 172, 85);
+@dark_link_active: rgb(240, 220, 171);
+@dark_error_background: rgb(107, 14, 14);
+@dark_error_border: rgb(200, 80, 80);
+@dark_not_available_background: rgb(86, 86, 11);
+@dark_code_foreground: rgb(193, 211, 218);
+@dark_code_background: rgb(35, 35, 39);
+@dark_dim_glyph: rgb(160, 160, 160);
+@dark_dim_type: rgb(160, 160, 160);
+@dark_keyword: rgb(55, 150, 213);
/* Section: Document Styles
* ========================================================================== */
+:root {
+ color-scheme: light dark;
+}
+
html {
box-sizing: border-box;
@@ -80,10 +100,15 @@ html {
body {
background-color: @background;
- color: #000;
+ color: @foreground;
font-family: "Roboto", sans-serif;
font-size: 87.5%;
line-height: 1.563;
+
+ @media (prefers-color-scheme: dark) {
+ background-color: @dark_background;
+ color: @dark_foreground;
+ }
}
@media (min-width: 38em) {
@@ -193,7 +218,12 @@ html, body {
width: 100%;
text-align: center;
background-color: @banner_background;
- color: @dark_foreground;
+ color: @dim_foreground;
+
+ @media (prefers-color-scheme: dark) {
+ background-color: @dark_banner_background;
+ color: @dark_dim_foreground;
+ }
}
.footer * {
@@ -209,17 +239,29 @@ html, body {
:target {
background-color: @code_background;
+
+ @media (prefers-color-scheme: dark) {
+ background-color: @dark_code_background;
+ }
}
a, a:visited {
color: @link;
text-decoration: none;
font-weight: bold;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_link;
+ }
}
a:hover {
color: @link_active;
text-decoration: none;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_link_active;
+ }
}
code, pre {
@@ -228,11 +270,20 @@ code, pre {
color: @code_foreground;
font-family: "Roboto Mono", monospace;
font-size: 87.5%;
+
+ @media (prefers-color-scheme: dark) {
+ background-color: @dark_code_background;
+ color: @dark_code_foreground;
+ }
}
:target code,
:target pre {
background-color: darken(@code_background, 5%);
+
+ @media (prefers-color-scheme: dark) {
+ background-color: lighten(@dark_code_background, 5%);
+ }
}
code {
@@ -259,6 +310,10 @@ a > code::before {
a:hover > code {
color: @link;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_link;
+ }
}
pre {
@@ -341,6 +396,10 @@ hr {
border: none;
height: 1px;
background-color: darken(@background, 20%);
+
+ @media (prefers-color-scheme: dark) {
+ background-color: lighten(@dark_background, 20%);
+ }
}
img {
@@ -361,6 +420,10 @@ table {
margin-top: 1rem;
margin-bottom: 1rem;
width: 100%;
+
+ @media (prefers-color-scheme: dark) {
+ border-bottom-color: lighten(@dark_background, 20%);
+ }
}
td, th {
@@ -370,6 +433,10 @@ td, th {
td {
border-top: 1px solid darken(@background, 20%);
+
+ @media (prefers-color-scheme: dark) {
+ border-top-color: lighten(@dark_background, 20%);
+ }
}
td:first-child, th:first-child {
@@ -394,11 +461,15 @@ ul li {
ul li::before {
position: absolute;
- color: @light_glyph;
+ color: @dim_glyph;
content: "–";
display: inline-block;
margin-left: -1.250em;
width: 1.250em;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_dim_glyph;
+ }
}
/* Tying this tightly to ul at the moment because it's a slight variation thereof */
@@ -430,20 +501,29 @@ ol li {
position: relative;
top: -0.1em;
display: inline-block;
- background-color: #000;
+ background-color: @foreground;
border-radius: 1.3em;
- color: #fff;
+ color: @background;
font-size: 77%;
font-weight: bold;
line-height: 1.563;
text-align: center;
height: 1.5em;
width: 1.5em;
+
+ @media (prefers-color-scheme: dark) {
+ background-color: @dark_foreground;
+ color: @dark_background;
+ }
}
.badge.badge--package {
background-color: @link;
letter-spacing: -0.1em;
+
+ @media (prefers-color-scheme: dark) {
+ background-color: @dark_link;
+ }
}
.badge.badge--module {
@@ -473,11 +553,19 @@ ol li {
.decl__anchor, .decl__anchor:visited {
position: absolute;
left: -0.8em;
- color: lighten(@light_glyph, 10%);
+ color: lighten(@dim_glyph, 10%);
+
+ @media (prefers-color-scheme: dark) {
+ color: darken(@dark_dim_glyph, 10%);
+ }
}
.decl__anchor:hover {
color: @link;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_link;
+ }
}
.decl__signature {
@@ -485,16 +573,56 @@ ol li {
border-radius: 0;
border-top: 1px solid darken(@background, 20%);
border-bottom: 1px solid darken(@background, 20%);
- padding: 0.328em 0;
+ padding: 0;
+
+ @media (prefers-color-scheme: dark) {
+ border-top-color: lighten(@dark_background, 20%);
+ border-bottom-color: lighten(@dark_background, 20%);
+ }
}
.decl__signature code {
display: block;
+ padding: 0.328em 0;
padding-left: 2.441em;
text-indent: -2.441em;
white-space: normal;
}
+.decl__role {
+ font-family: "Roboto", sans-serif;
+ font-style: italic;
+ font-weight: normal;
+}
+
+/* See https://stackoverflow.com/a/32162038
+ Content licensed under CC BY-SA 3.0
+*/
+.decl__role_hover[title] {
+ /* Remove line that appears under abbr element */
+ border-bottom: none;
+ text-decoration: none;
+
+ /* Ensure cursor doesn't change to question mark */
+ cursor: inherit;
+}
+
+.decl__role_nominal::after {
+ content: "nominal";
+}
+
+.decl__role_phantom::after {
+ content: "phantom";
+}
+
+.decl__kind {
+ border-bottom: 1px solid darken(@background, 20%);
+
+ @media (prefers-color-scheme: dark) {
+ border-bottom-color: lighten(@dark_background, 20%);
+ }
+}
+
:target .decl__signature,
:target .decl__signature code {
/* We want the background to be transparent, even when the parent is a target */
@@ -503,7 +631,11 @@ ol li {
.decl__body .keyword,
.decl__body .syntax {
- color: #0B71B4;
+ color: @keyword;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_keyword;
+ }
}
.decl__child_comments {
@@ -522,10 +654,14 @@ ol li {
}
.deplink__version {
- color: @light_type;
+ color: @dim_type;
display: inline-block;
font-size: 0.8em;
line-height: 1;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_dim_type;
+ }
}
@@ -535,15 +671,23 @@ ol li {
.grouped-list {
border-top: 1px solid darken(@background, 20%);
margin: 0 0 2.44em 0;
+
+ @media (prefers-color-scheme: dark) {
+ border-top-color: lighten(@dark_background, 20%);
+ }
}
.grouped-list__title {
- color: @light_type;
+ color: @dim_type;
font-size: 0.8em;
font-weight: 300;
letter-spacing: 1px;
margin: 0.8em 0 -0.1em 0;
text-transform: uppercase;
+
+ @media (prefers-color-scheme: dark) {
+ border-top-color: @dark_dim_type;
+ }
}
.grouped-list__item {
@@ -563,11 +707,21 @@ ol li {
.message.message--error {
background-color: @error_background;
border-color: @error_border;
+
+ @media (prefers-color-scheme: dark) {
+ background-color: @dark_error_background;
+ border-color: @dark_error_border;
+ }
}
.message.message--not-available {
background-color: @not_available_background;
border-color: darken(@not_available_background, 20%);
+
+ @media (prefers-color-scheme: dark) {
+ background-color: @dark_not_available_background;
+ border-color: lighten(@dark_not_available_background, 20%);
+ }
}
@@ -624,13 +778,17 @@ ol li {
.page-title__label {
position: relative;
- color: @light_type;
+ color: @dim_type;
font-size: 0.8rem;
font-weight: 300;
letter-spacing: 1px;
margin-bottom: -0.8em;
text-transform: uppercase;
z-index: 1;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_dim_type;
+ }
}
@@ -639,18 +797,27 @@ ol li {
.top-banner {
background-color: @banner_background;
- color: @dark_foreground;
+ color: @dim_foreground;
font-weight: normal;
+
+ @media (prefers-color-scheme: dark) {
+ background-color: @dark_banner_background;
+ color: @dark_dim_foreground;
+ }
}
.top-banner__logo,
.top-banner__logo:visited {
float: left;
- color: @dark_foreground;
+ color: @dim_foreground;
font-size: 2.44em;
font-weight: 300;
line-height: 90px;
margin: 0;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_dim_foreground;
+ }
}
.top-banner__logo:hover {
@@ -665,11 +832,18 @@ ol li {
.top-banner__form input {
border: 1px solid @banner_background;
border-radius: 3px;
+ background-color: @background;
color: @banner_background;
font-weight: 300;
line-height: 2;
padding: 0.21em 0.512em;
width: 100%;
+
+ @media (prefers-color-scheme: dark) {
+ border-color: @dark_banner_background;
+ background-color: @dark_background;
+ color: @dark_foreground;
+ }
}
.top-banner__actions {
@@ -690,11 +864,19 @@ ol li {
.top-banner__actions__item a,
.top-banner__actions__item a:visited {
- color: @dark_foreground;
+ color: @dim_foreground;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_dim_foreground;
+ }
}
.top-banner__actions__item a:hover {
color: @link;
+
+ @media (prefers-color-scheme: dark) {
+ color: @dark_link;
+ }
}
@media (min-width: 38em) {
@@ -749,6 +931,11 @@ ol li {
border-top: 1px solid darken(@background, 20%);
border-bottom: 1px solid darken(@background, 20%);
padding: 0.328em 0;
+
+ @media (prefers-color-scheme: dark) {
+ border-top-color: lighten(@dark_background, 20%);
+ border-bottom-color: lighten(@dark_background, 20%);
+ }
}
.result__signature code {
@@ -833,6 +1020,10 @@ ol li {
padding: 0 1em;
color: #777;
border-left: 0.25em solid #ddd;
+
+ @media (prefers-color-scheme: dark) {
+ border-left-color: #444;
+ }
}
.markdown-body blockquote>:first-child {
@@ -851,6 +1042,10 @@ ol li {
.markdown-body .pl-k {
/* Keyword */
color: #a0a0a0;
+
+ @media (prefers-color-scheme: dark) {
+ color: #676767;
+ }
}
.markdown-body .pl-c1,
diff --git a/bundle/build.sh b/bundle/build.sh
index 4402c6baa9..db37b52937 100755
--- a/bundle/build.sh
+++ b/bundle/build.sh
@@ -26,7 +26,7 @@ then
else
BIN="purs"
fi
-FULL_BIN="$(stack path --local-install-root)/bin/$BIN"
+FULL_BIN="$(stack path --local-doc-root)/../bin/$BIN"
if [ "$OS" != "win64" ]
then
strip "$FULL_BIN"
diff --git a/cabal.project b/cabal.project
new file mode 100644
index 0000000000..d6a4a8e102
--- /dev/null
+++ b/cabal.project
@@ -0,0 +1,10 @@
+packages:
+ purescript.cabal
+
+source-repository-package
+ type: git
+ location: https://github.com/purescript/cheapskate.git
+ tag: 633c69024e061ad956f1aecfc137fb99a7a7a20b
+
+package purescript
+ ghc-options: -fspecialize-aggressively -fexpose-all-unfoldings
diff --git a/ci/build-package-set.sh b/ci/build-package-set.sh
new file mode 100755
index 0000000000..174757d384
--- /dev/null
+++ b/ci/build-package-set.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+
+set -eu -o pipefail
+shopt -s nullglob
+
+psroot=$(dirname "$(dirname "$(realpath "$0")")")
+
+if [[ "${CI:-}" && "$(echo "$psroot"/CHANGELOG.d/breaking_*)" ]]; then
+ echo "Skipping package-set build due to unreleased breaking changes"
+ exit 0
+fi
+
+tmpdir=$(mktemp -d)
+trap 'rm -rf "$tmpdir"' EXIT
+export PATH="$tmpdir/node_modules/.bin:$PATH"
+cd "$tmpdir"
+
+echo ::group::Ensure Spago is available
+which spago || npm install spago
+echo ::endgroup::
+
+echo ::group::Create dummy project
+spago init --name purescript-dummy
+echo ::endgroup::
+
+echo ::group::Compile package set
+spago ls packages --json | jq -r 'keys[]' | xargs spago install
+echo ::endgroup::
+
+echo ::group::Document package set
+spago docs
+echo ::endgroup::
diff --git a/ci/build.sh b/ci/build.sh
index c6695b3c98..180c3545a3 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -2,6 +2,10 @@
set -ex
+# Provides expanders that group console output in GitHub Actions
+# See https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#grouping-log-lines
+(echo "::group::Initialize variables") 2>/dev/null
+
# This is the main CI build script. It is intended to run on all platforms we
# run CI on: linux, mac os, and windows. It makes use of the following
# environment variables:
@@ -19,23 +23,173 @@ set -ex
# for compilation or for tests in our package.yaml file (these sorts of issues
# don't test to get noticed until after releasing otherwise).
-STACK="stack --no-terminal --jobs=2"
+# We test with --haddock because haddock generation can fail if there is invalid doc-comment syntax,
+# and these failures are very easy to miss otherwise.
+STACK="stack --no-terminal --haddock --jobs=4"
STACK_OPTS="--test"
-if [ "$CI_RELEASE" = "true" ]
+if [ "$CI_RELEASE" = "true" -o "$CI_PRERELEASE" = "true" ]
then
STACK_OPTS="$STACK_OPTS --flag=purescript:RELEASE"
else
STACK_OPTS="$STACK_OPTS --fast"
fi
+if [ "$CI_STATIC" = "true" ]
+then
+ STACK_OPTS="$STACK_OPTS --flag=purescript:static"
+fi
+
+(echo "::endgroup::"; echo "::group::Set version number for build") 2>/dev/null
+
+if [ "$CI_PRERELEASE" = "true" ]
+then
+ git fetch --depth=1 origin "v$(npm view purescript@next version)"
+
+ # List of files/folders to use to detect if a new prerelease should be
+ # issued. Any path that could contain files that affect the built bundles or
+ # the published npm package should be included here. Paths that no longer
+ # exist should be deleted. A false positive is not as big a deal as a false
+ # negative, so err on the side of including stuff.
+ if git diff --quiet FETCH_HEAD HEAD -- \
+ .github/workflows app bundle ci npm-package src \
+ purescript.cabal stack.yaml
+ then
+ echo "Skipping prerelease because no input affecting the published package was"
+ echo "changed since the last prerelease"
+ echo "do-not-prerelease=true" >> $GITHUB_OUTPUT
+ else
+ do_prerelease=true
+ fi
+fi
+
+package_version=$(node -pe 'require("./npm-package/package.json").version')
+package_release_version=${package_version%%-*}
+package_prerelease_suffix=${package_version#$package_release_version}
+
+if ! grep -q "\"install-purescript --purs-ver=${package_version//./\\.}\"" npm-package/package.json
+then
+ echo "Version in npm-package/package.json doesn't match version in install-purescript call"
+ exit 1
+fi
+
+if ! grep -q "^version:\\s*${package_release_version//./\\.}$" purescript.cabal
+then
+ echo "Version in npm-package/package.json doesn't match version in purescript.cabal"
+ exit 1
+fi
+
+if ! grep -q "^prerelease = \"${package_prerelease_suffix//./\\.}\"$" app/Version.hs
+then
+ echo "Version in npm-package/package.json doesn't match prerelease in app/Version.hs"
+ exit 1
+fi
+
+if [ "$do_prerelease" ]
+then
+ # (some versions of?) macOS have an old FreeBSD sed that requires -i to be followed with an argument
+ if sed --version >/dev/null
+ then
+ # Probably GNU sed
+ sedi=(sed -i)
+ else
+ # Probably FreeBSD sed
+ sedi=(sed -i '')
+ fi
+
+ function largest-matching-git-tag {
+ grep -E "^${1//./\\.}(\\.|$)" "$git_tags" | head -n 1
+ }
+
+ git_tags=$(mktemp)
+ trap 'rm "$git_tags"' EXIT
+ git ls-remote --tags -q --sort=-version:refname | sed 's_^.*refs/tags/__' > $git_tags
+
+ pushd npm-package
+
+ if [ "$package_prerelease_suffix" ]
+ then
+ tag=$(largest-matching-git-tag "v$package_release_version${package_prerelease_suffix%%.*}")
+ if [ "$tag" ]
+ then
+ npm version --allow-same-version "$tag"
+ build_version=$(npm version --no-git-tag-version prerelease)
+ build_version=${build_version#v}
+ else
+ build_version=$package_version
+ fi
+ else # (current version does not contain a prerelease suffix)
+ if grep -Fqx "v$package_release_version" "$git_tags"
+ then # (the current version has been published)
+ bump=patch
+ if [ "$(find ../CHANGELOG.d -maxdepth 1 -name 'breaking_*' -print -quit)" ]
+ then
+ # If we ever reach 1.0, change this to major and uncomment the below
+ bump=minor
+ #elif [ "$(find ../CHANGELOG.d -maxdepth 1 -name 'feature_*' -print -quit)" ]
+ #then
+ # bump=minor
+ fi
+ next_tag=$(npm version --no-git-tag-version "$bump")
+ tag=$(largest-matching-git-tag "$next_tag-[0-9]+")
+ if [ "$tag" ]
+ then
+ npm version --allow-same-version "$tag"
+ build_version=$(npm version --no-git-tag-version prerelease)
+ else
+ build_version=$(npm version --allow-same-version "$next_tag-0")
+ fi
+ build_version=${build_version#v}
+ else # (current version has not been published)
+ build_version=$package_version
+ echo "do-not-prerelease=true" >> $GITHUB_OUTPUT
+ fi
+ fi
+
+ echo "version=$build_version" >> $GITHUB_OUTPUT
+
+ popd
+
+ if [ "$build_version" != "$package_version" ]
+ then
+ build_release_version=${build_version%%-*}
+ build_prerelease_suffix=${build_version#$build_release_version}
+ # We don't need to update the install-purescript command before we build;
+ # we'll do that when we publish. All we need to update here are the files
+ # that affect the purs binary.
+ "${sedi[@]}" -e "s/^\\(version:[[:blank:]]*\\)${package_release_version//./\\.}/\1$build_release_version/" purescript.cabal
+ "${sedi[@]}" -e "s/^prerelease = \"${package_prerelease_suffix//./\\.}\"$/prerelease = \"${build_prerelease_suffix}\"/" app/Version.hs
+ fi
+fi
+
+(echo "::endgroup::"; echo "::group::Install snapshot dependencies") 2>/dev/null
# Install snapshot dependencies (since these will be cached globally and thus
# can be reused during the sdist build step)
$STACK build --only-snapshot $STACK_OPTS
+(echo "::endgroup::"; echo "::group::Build source distributions") 2>/dev/null
+
# Test in a source distribution (see above)
-$STACK sdist --tar-dir sdist-test;
+$STACK sdist . --tar-dir sdist-test;
tar -xzf sdist-test/purescript-*.tar.gz -C sdist-test --strip-components=1
+
+(echo "::endgroup::"; echo "::group::Build and test PureScript") 2>/dev/null
+
pushd sdist-test
-$STACK build --pedantic $STACK_OPTS
+# --ghc-options -Werror applies only to local packages, catching our own
+# haddock doc-comment errors without failing on warnings in dependencies.
+# (--haddock-arguments --optghc=-Werror would pass -Werror to all packages
+# via haddock, which breaks when the dependency cache is cold.)
+$STACK build $STACK_OPTS --ghc-options -Werror
+
+if [ "$do_prerelease" ]
+then
+ if [ "$($STACK exec -- purs --version)" != "$build_version" ]
+ then
+ echo "purs --version doesn't equal the expected value"
+ exit 1
+ fi
+fi
popd
+
+(echo "::endgroup::") 2>/dev/null
diff --git a/ci/convert-os-name.sh b/ci/convert-os-name.sh
deleted file mode 100755
index a2e0574ad3..0000000000
--- a/ci/convert-os-name.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-# This script converts the Travis OS name into the format used for PureScript
-# binary bundles.
-set -e
-
-case "$TRAVIS_OS_NAME" in
- "linux")
- echo linux64;;
- "osx")
- echo macos;;
- "windows")
- echo win64;;
- *)
- echo "Unknown TRAVIS_OS_NAME: $TRAVIS_OS_NAME";
- exit 1;;
-esac
diff --git a/ci/disable-windows-defender.sh b/ci/disable-windows-defender.sh
deleted file mode 100755
index a344b3bf6e..0000000000
--- a/ci/disable-windows-defender.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-# Intended to speed up builds by disabling Windows Defender.
-# See https://travis-ci.community/t/current-known-issues-please-read-this-before-posting-a-new-topic/264/15
-
-export NODEPATH=$(where.exe node.exe)
-export PROJECTDIR=$(pwd)
-export TEMPDIR=$LOCALAPPDATA\\Temp
-
-powershell Add-MpPreference -ExclusionProcess ${NODEPATH}
-powershell Add-MpPreference -ExclusionPath ${PROJECTDIR}
-powershell Add-MpPreference -ExclusionPath ${TEMPDIR}
-
-echo "DisableArchiveScanning..."
-powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableArchiveScanning \$true'"
-
-echo "DisableBehaviorMonitoring..."
-powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableBehaviorMonitoring \$true'"
-
-echo "DisableRealtimeMonitoring..."
-powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableRealtimeMonitoring \$true'"
-
-
diff --git a/ci/fix-home b/ci/fix-home
new file mode 100755
index 0000000000..7423615071
--- /dev/null
+++ b/ci/fix-home
@@ -0,0 +1,12 @@
+#!/usr/bin/env sh
+
+# CI Steps on Linux (in the container) are run as root, while on macOS and Windows, they are not.
+# And on GitHub Actions, environment variables from the host machine has a higher priority than those from a container,
+# including user-specific variables like `USER`, `HOME`, etc.
+#
+# The following fixes the `HOME` value for CLI tools (primarily Stack) that expects a properly configured `HOME` value.
+if [ "$(whoami)" = root ]; then
+ HOME=/root "$@"
+else
+ "$@"
+fi
diff --git a/ci/run-hlint.sh b/ci/run-hlint.sh
new file mode 100755
index 0000000000..bc98888214
--- /dev/null
+++ b/ci/run-hlint.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+# This script was originally sourced from
+# https://github.com/ndmitchell/neil/blob/b06624fe697c23375222856d538cb974e96da048/misc/run.sh
+# and adapted for PureScript to do the following:
+# * specialize for hlint instead of an arbitrary ndmitchell project
+# * use a specified version, instead of the most recent release
+# * install to a native temporary directory instead of a subdirectory of the project
+# * make curl silent
+#
+# The original script was distributed with the following license, also available at
+# https://github.com/ndmitchell/neil/blob/b06624fe697c23375222856d538cb974e96da048/LICENSE
+#
+# Copyright (c) Neil Mitchell 2010-2021
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided
+# with the distribution.
+#
+# * The names of its contributors may not be used to endorse or
+# promote products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This script is invoked from my Travis commands
+# It bootstraps to grab the a binary release and run it
+set -e # exit on errors
+
+PACKAGE=hlint
+if [ -z "$VERSION" ]; then
+ echo The environment variable VERSION is required
+ exit 1
+fi
+
+case "$(uname)" in
+ "Darwin")
+ OS=osx;;
+ MINGW64_NT-*|MSYS_NT-*)
+ OS=windows;;
+ *)
+ OS=linux
+esac
+
+if [ "$OS" = "windows" ]; then
+ EXT=.zip
+else
+ EXT=.tar.gz
+fi
+
+echo Downloading and running $PACKAGE...
+URL=https://github.com/ndmitchell/$PACKAGE/releases/download/v$VERSION/$PACKAGE-$VERSION-x86_64-$OS$EXT
+TEMP=$(mktemp -d ${TEMP:-/tmp}/.$PACKAGE-XXXXXX)
+
+cleanup(){
+ rm -r $TEMP
+}
+trap cleanup EXIT
+
+retry(){
+ ($@) && return
+ sleep 15
+ ($@) && return
+ sleep 15
+ $@
+}
+
+retry curl --silent --location -o$TEMP/$PACKAGE$EXT $URL
+if [ "$OS" = "windows" ]; then
+ 7z x -y $TEMP/$PACKAGE$EXT -o$TEMP -r > /dev/null
+else
+ tar -xzf $TEMP/$PACKAGE$EXT -C$TEMP
+fi
+$TEMP/$PACKAGE-$VERSION/$PACKAGE $*
diff --git a/core-tests/.gitignore b/core-tests/.gitignore
deleted file mode 100644
index ec714d16e2..0000000000
--- a/core-tests/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-core-docs.md
-bower_components/
-output/
diff --git a/core-tests/psc-package.json b/core-tests/psc-package.json
deleted file mode 100644
index 296a7aac3e..0000000000
--- a/core-tests/psc-package.json
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- "name": "core-tests",
- "set": "psc-0.11.3",
- "source": "https://github.com/purescript/package-sets.git",
- "depends": [
- "arrays",
- "assert",
- "bifunctors",
- "catenable-lists",
- "console",
- "const",
- "contravariant",
- "control",
- "datetime",
- "distributive",
- "eff",
- "either",
- "enums",
- "exceptions",
- "exists",
- "foldable-traversable",
- "foreign",
- "free",
- "functions",
- "functors",
- "gen",
- "generics",
- "generics-rep",
- "globals",
- "graphs",
- "identity",
- "inject",
- "integers",
- "invariant",
- "lazy",
- "maps",
- "math",
- "maybe",
- "monoid",
- "newtype",
- "nonempty",
- "orders",
- "partial",
- "parallel",
- "prelude",
- "profunctor",
- "proxy",
- "psci-support",
- "quickcheck",
- "random",
- "refs",
- "semirings",
- "sets",
- "st",
- "strings",
- "tailrec",
- "transformers",
- "tuples",
- "typelevel-prelude",
- "type-equality",
- "unfoldable",
- "unsafe-coerce",
- "validation"
- ]
-}
diff --git a/core-tests/test-everything.sh b/core-tests/test-everything.sh
deleted file mode 100755
index 848a41c7bd..0000000000
--- a/core-tests/test-everything.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-
-# exit on error
-set -o errexit
-# needed for using $(psc-package sources)
-set -o noglob
-
-force_recompile='false'
-force_reinstall='false'
-
-while getopts 'ci' flag; do
- case "${flag}" in
- c) force_recompile='true' ;;
- i) force_reinstall='true' ;;
- *) error "Unexpected option ${flag}" ;;
- esac
-done
-
-if [ "$force_reinstall" = "true" ] && [ -d ".psc-package" ]; then
- echo "Reinstalling core packages..."
- rm -rf .psc-package
-fi
-
-psc-package update
-
-if [ "$force_recompile" = "true" ] && [ -d "output" ]; then
- echo "Recompiling..."
- rm -r output
-fi
-
-stack exec purs compile tests/**/*.purs $(psc-package sources)
-
-stack exec purs docs $(psc-package sources) > core-docs.md
-
-NODE_PATH=output node -e "require('Test.Main').main()"
diff --git a/core-tests/tests/GenericDeriving.purs b/core-tests/tests/GenericDeriving.purs
deleted file mode 100755
index b95b185fb2..0000000000
--- a/core-tests/tests/GenericDeriving.purs
+++ /dev/null
@@ -1,30 +0,0 @@
-module Test.GenericDeriving where
-
-import Prelude
-
-import Effect (Effect)
-import Effect.Console (log, logShow)
-import Data.Generic (class Generic, gShow, gEq)
-import Partial.Unsafe (unsafePartial)
-
-data Empty
-
-derive instance genericEmpty :: Partial => Generic Empty
-
-data A a
- = A Number String
- | B Int
- | C (Array (A a))
- | D { "asgård" :: a }
- | E Empty
-
-derive instance genericA :: (Partial, Generic b) => Generic (A b)
-
-newtype X b = X b
-
-derive instance genericX :: Generic (X String)
-
-main :: Effect Unit
-main = unsafePartial do
- log $ gShow (D { "asgård": C [ A 1.0 "test", B 42, D { "asgård": true } ] })
- logShow $ gEq (C [B 0]) (C [B 0] :: A Empty)
diff --git a/core-tests/tests/Main.purs b/core-tests/tests/Main.purs
deleted file mode 100644
index 8559c444ac..0000000000
--- a/core-tests/tests/Main.purs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Test.Main where
-
-import Prelude
-import Effect (Effect)
-import Test.GenericDeriving as GenericDeriving
-
-main :: Effect Unit
-main = GenericDeriving.main
diff --git a/debug/eventlog.js b/debug/eventlog.js
new file mode 100644
index 0000000000..43aa4f7221
--- /dev/null
+++ b/debug/eventlog.js
@@ -0,0 +1,215 @@
+// Debug compilation times of modules from eventlog profiling
+//
+// Build and run purs with profiling enabled:
+// cabal build --enable-profiling
+// cabal exec -- purs ......
+// Or with stack:
+// stack build --profile
+// stack --profile exec -- purs ......
+// Run a command like this to generate purs.eventlog:
+// purs +RTS -l-agu -i1.5 -hc -RTS compile -g corefn $(spago sources)
+// (If you want accurate stats for individual modules, add -N1.)
+// Process it with
+// eventlog2html --json purs.eventlog
+// node eventlog.js purs.eventlog.json
+//
+// See the GHC docs for descriptions of the RTS flags:
+// - https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html#rts-options-for-heap-profiling
+// - https://downloads.haskell.org/ghc/latest/docs/users_guide/runtime_control.html#rts-eventlog
+// - https://downloads.haskell.org/ghc/latest/docs/users_guide/using-concurrent.html?highlight=threaded#rts-options-for-smp-parallelism
+var mainFile = process.argv[2];
+if (!mainFile) throw new Error("Provide a file name");
+
+var name_length = 0;
+
+function summarizeEventlog(filename) {
+ var eventlog = JSON.parse(require("fs").readFileSync(filename, "utf-8"));
+ // eventlog.heap
+ // c: Set(3) { 'Heap Size', 'Live Bytes', 'Blocks Size' }
+ // eventlog.samples
+ // eventlog.traces
+
+ var traces = {};
+ var minTx = Infinity;
+ var maxTx = -Infinity;
+ var maxMem = -Infinity;
+ var total = 0;
+ var con = [];
+ var max_cons = [[]];
+ var cursor = 0;
+
+ // I guess some buffering makes it out of order?
+ eventlog.traces.sort(({tx: tx1}, {tx: tx2}) => tx1 - tx2);
+
+ for (let trace of eventlog.traces) {
+ var m = /^([\w.]+) (start|end)$/.exec(trace.desc);
+ if (!m) continue;
+ var name = m[1];
+ if (!(name in traces)) traces[name] = {};
+ if (name.length > name_length) name_length = name.length;
+ var ev = m[2];
+
+ if (traces[name][ev]) {
+ if (traces[name].time === 0) {
+ console.log("Warn: start after end", name, traces[name].start, trace.tx);
+ } else {
+ console.log("Warn: duplicate event", trace.desc);
+ }
+ continue;
+ }
+
+ var time = trace.tx;
+ if (time < minTx) minTx = time;
+ if (time > maxTx) maxTx = time;
+
+ while (cursor < eventlog.heap.length && eventlog.heap[cursor].x < trace.tx) {
+ cursor++;
+ if (eventlog.heap[cursor].c !== 'Heap Size') {
+ cursor = eventlog.heap.length;
+ }
+ }
+ if (ev === "start") {
+ traces[name].cursor = cursor;
+ }
+
+ traces[name][ev] = time;
+ if (ev === "end" && !("start" in traces[name])) {
+ console.log("Warn: missing start for", name);
+ traces[name].start = time;
+ traces[name].time = 0;
+ continue;
+ }
+ if ("start" in traces[name] && "end" in traces[name]) {
+ traces[name].time = traces[name].end - traces[name].start;
+ var mems = eventlog.heap.slice(traces[name].cursor, cursor).map(e => e.y);
+ var mem_min = Math.min(...mems);
+ var mem_max = Math.max(...mems);
+ var maxMem = Math.max(maxMem, mem_max);
+ Object.assign(traces[name], {mem_min,mem_max});
+ total += traces[name].time;
+ }
+
+ if (ev === "start") con = con.concat([name]);
+ if (ev === "end") {
+ var l = con.length;
+ con = con.filter(n => n !== name);
+ if (con.length !== l - 1) {
+ console.log(con, name);
+ }
+ }
+ if (con.length >= max_cons[0].length) {
+ if (con.length > max_cons[0].length)
+ max_cons = [];
+ max_cons.push(con);
+ }
+ }
+
+ var timespan = maxTx - minTx;
+
+ return { traces, total, minTx, maxTx, timespan, max_cons, maxMem };
+}
+
+var mainFiles = process.argv.slice(2);
+
+if (mainFiles.length > 1) {
+ for (let file of mainFiles) {
+ console.log(file);
+ var { traces, total, timespan, max_cons, maxMem } = summarizeEventlog(file);
+ if (timespan === -Infinity && total === 0 && max_cons[0].length === 0) continue;
+ var max_con_time = 0;
+ var concurrencies = max_cons.map(max_con => {
+ if (max_con.length !== max_cons[0].length)
+ throw new Error("max_con length error");
+ var modules = max_con.map(name => [name, traces[name]]);
+ var start = Math.max(...modules.map(([name, {start}]) => start));
+ var end = Math.min(...modules.map(([name, {end}]) => end));
+ var time = end - start;
+ max_con_time += time;
+ return {
+ modules,
+ start,
+ end,
+ time,
+ };
+ });
+ console.log("timespan ", timespan);
+ console.log("ratio (avg concurrency?) ", total/timespan);
+ console.log("max concurrency ", max_cons[0].length);
+ console.log("time at max concurrency (%)", 100*max_con_time/timespan);
+ console.log("peak heap size ", space(maxMem));
+ }
+ process.exit(0);
+}
+
+var { traces, total, timespan, max_cons } = summarizeEventlog(mainFile);
+
+var timings = [];
+for (let name in traces) {
+ let trace = traces[name];
+ if (!("time" in trace)) {
+ console.log("Warn: missing timing for", name, trace);
+ } else if (trace.time > 0) {
+ timings.push([name, trace.time]);
+ }
+}
+
+timings.sort(([n1,t1,_1,m1], [n2,t2,_2,m2]) => t1 - t2);
+
+timings.push(["stats", "-----"]);
+timings.push(["total", total]);
+timings.push(["timespan", timespan]);
+timings.push(["ratio (avg concurrency?)", total/timespan]);
+var max_con_time = 0;
+var concurrencies = max_cons.map(max_con => {
+ if (max_con.length !== max_cons[0].length)
+ throw new Error("max_con length error");
+ var modules = max_con.map(name => [name, traces[name]]);
+ var start = Math.max(...modules.map(([name, {start}]) => start));
+ var end = Math.min(...modules.map(([name, {end}]) => end));
+ var time = end - start;
+ max_con_time += time;
+ return {
+ modules,
+ start,
+ end,
+ time,
+ };
+});
+timings.push(["max concurrency", max_cons[0].length]);
+timings.push(["time at max concurrency (s)", max_con_time]);
+timings.push(["time at max concurrency (%)", 100*max_con_time/timespan]);
+
+for (let [name, time] of timings) {
+ // console.log(name.padEnd(name_length, " "), (""+time).substring(0, 5).padStart(5, " "));
+ console.log(name.padEnd(name_length, " "), time);
+}
+
+//require("fs").writeFileSync("concurrencies.json", JSON.stringify(concurrencies, null, 2), "utf-8");
+
+
+function space(v) {
+ if (!isFinite(v)) return "----";
+ if (v === Infinity) return "+Inf";
+ if (v === -Infinity) return "-Inf";
+ if (v !== v) return " NaN";
+ var sizes = [
+ [1_000_000_000, "G"],
+ [1_000_000, "M"],
+ [1_000, "K"],
+ [0, ""],
+ ]
+ for (let [value, suffix] of sizes) {
+ if (v < value) continue;
+ if (!suffix) return (""+v).padStart(4, " ");
+ var adj = v/value;
+ var str = ""+adj;
+ if (adj >= 100) return str.substring(0,3)+suffix;
+ if (adj >= 10) return " "+str.substring(0,2)+suffix;
+ return str.substring(0,3)+suffix;
+ }
+}
+function signed(fmt, v) {
+ if (!isFinite(v)) return " "+fmt(v);
+ if (v < 0) return "-"+fmt(-v);
+ return "+"+fmt(v);
+}
diff --git a/get-source-maps.sh b/get-source-maps.sh
new file mode 100755
index 0000000000..af61df247b
--- /dev/null
+++ b/get-source-maps.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+TEST_MODULES_DIR=.test_modules
+OUTPUT_DIR=.source-maps
+
+if [ ! -d "$TEST_MODULES_DIR" ]; then
+ echo "'$TEST_MODULES_DIR' dir does not exist. You need to run 'stack test --fast --ta \"--match sourcemaps\"' first"
+ exit 1
+fi
+
+if [ -d "$OUTPUT_DIR" ]; then
+ echo "Removing $OUTPUT_DIR"
+ rm -rf "$OUTPUT_DIR"
+fi
+
+echo "Getting source maps"
+
+mkdir -p "$OUTPUT_DIR"
+
+while IFS= read -r -d '' file
+do
+ MODULE="$(basename "$file" .purs)"
+ echo "Copying files for $MODULE"
+ mkdir -p "$OUTPUT_DIR/$MODULE"
+ cp -r \
+ "$TEST_MODULES_DIR/SourceMaps.$MODULE/index.js" \
+ "$TEST_MODULES_DIR/SourceMaps.$MODULE/index.js.map" \
+ "$OUTPUT_DIR/$MODULE/"
+ cp "$file" "$OUTPUT_DIR/$MODULE/$MODULE.purs"
+done < <(find "tests/purs/sourcemaps" -type f -wholename '*.purs' -print0)
diff --git a/glob-test.sh b/glob-test.sh
new file mode 100644
index 0000000000..aba4432f31
--- /dev/null
+++ b/glob-test.sh
@@ -0,0 +1,113 @@
+#!/usr/bin/env bash
+
+# This script assumes `ci/build.sh && cd sdist-test` has been run
+# and that the program `tree` has been installed.
+
+# Creates the following structure
+# Foo.purs
+# src/Bar.purs
+# src/Bar/Baz.purs
+#
+# and verifies that the two kinds of input globs interact consistently.
+
+set -eu -o pipefail
+shopt -s nullglob
+
+PURS="$(stack path --local-doc-root)/../bin/purs"
+
+tmpdir=$(mktemp -d)
+trap 'rm -rf "$tmpdir"' EXIT
+cd "$tmpdir"
+
+echo ::group::Environment info
+echo "purs: ${PURS}"
+echo "purs --version"
+"${PURS}" --version
+echo ::endgroup::
+
+echo ::group::Setting up structure
+mkdir -p "src/Bar"
+
+cat > "Foo.purs" < "src/Bar.purs" < "src/Bar/Baz.purs" < "globsAll" < "globsNoFoo" <&1
+EXPECTED=$(cd out1 && tree . 2>&1)
+
+"${PURS}" compile --output "out2" --source-globs-file globsAll 2>&1
+SOURCE_GLOBS=$(cd out2 && tree . 2>&1)
+
+"${PURS}" compile --output "out3" --source-globs-file globsAll 'Foo.purs' 2>&1
+MIXED_ALL=$(cd out3 && tree . 2>&1)
+
+"${PURS}" compile --output "out4" --source-globs-file globsNoFoo 'Foo.purs' 2>&1
+MIXED_NO_FOO=$(cd out4 && tree . 2>&1)
+echo ::endgroup::
+
+echo ::group::Running checks
+if [ "${EXPECTED}" = "" ] ; then
+ echo "'purs compile' output should not be empty"
+ exit 1
+fi
+
+if [ "${EXPECTED}" = "${SOURCE_GLOBS}" ]; then
+ echo "SOURCE_GLOBS is correct"
+else
+ echo "SOURCE_GLOBS output different from EXPECTED"
+ echo "Expected: ${EXPECTED}"
+ echo "SOURCE_GLOBS: ${SOURCE_GLOBS}"
+ exit 1
+fi
+
+if [ "${EXPECTED}" = "${MIXED_ALL}" ]; then
+ echo "MIXED_ALL is correct"
+else
+ echo "MIXED_ALL output different from EXPECTED"
+ echo "Expected: ${MIXED_ALL}"
+ echo "MIXED_ALL: ${MIXED_ALL}"
+ exit 1
+fi
+
+if [ "${EXPECTED}" = "${MIXED_NO_FOO}" ]; then
+ echo "MIXED_NO_FOO is correct"
+else
+ echo "MIXED_NO_FOO output different from EXPECTED"
+ echo "Expected: ${MIXED_NO_FOO}"
+ echo "MIXED_NO_FOO: ${MIXED_NO_FOO}"
+ exit 1
+fi
+
+echo "Tests passed"
+echo ::endgroup::
+exit 0
diff --git a/lib/purescript-cst/README.md b/lib/purescript-cst/README.md
new file mode 100644
index 0000000000..8f385dc45a
--- /dev/null
+++ b/lib/purescript-cst/README.md
@@ -0,0 +1,25 @@
+# purescript-cst
+
+The parser for the PureScript programming language was temporarily released as a separate package for the `0.14.x` series. In `0.15.x`, it was merged back into the main `purescript` package. This table only exists for documentary purposes.
+
+## Compiler compatibility
+
+In `v0.15.0`, the `purescript-cst` package was merged back into the `purescript` package.
+
+We provide a table to make it a bit easier to map between versions of `purescript` and `purescript-cst`.
+
+| `purescript` | `purescript-cst` |
+| --- | --- |
+| 0.14.2 | 0.2.0.0 |
+| 0.14.3 | 0.3.0.0 |
+| 0.14.4 | 0.4.0.0 |
+| 0.14.5 | 0.4.0.0 |
+| 0.14.6 | 0.4.0.0 |
+| 0.14.7 | 0.5.0.0 |
+
+Before v0.14.2, there was a third package, `purescript-ast`. In v0.14.2, `purescript-ast` was merged into `purescript-cst`.
+
+| `purescript` | `purescript-cst` | `purescript-ast` |
+| --- | --- | --- |
+| 0.14.1 | 0.1.1.0 | 0.1.1.0 |
+| 0.14.0 | 0.1.0.0 | 0.1.0.0 |
diff --git a/license-generator/generate.hs b/license-generator/generate.hs
index f2e389c113..09f7ab89b6 100644
--- a/license-generator/generate.hs
+++ b/license-generator/generate.hs
@@ -1,5 +1,13 @@
#!/usr/bin/env stack
--- stack --resolver lts-13.12 script
+{- stack
+ --resolver lts-20.9 script
+ --package bytestring
+ --package http-client-tls
+ --package http-client
+ --package http-types
+ --package text
+ --package split
+-}
{-# LANGUAGE TupleSections #-}
-- |
@@ -39,6 +47,7 @@ main = do
putStrLn ""
manager <- newManager tlsManagerSettings
results <- traverse (\d -> (d,) <$> depsLicense manager d) deps
+ echoLgpl
let failures = filter (not . snd) results
if not (null failures)
then do
@@ -55,13 +64,23 @@ echoHeader :: IO ()
echoHeader =
readFile "license-generator/header.txt" >>= putStr
+echoLgpl :: IO ()
+echoLgpl =
+ readFile "license-generator/lgpl.txt" >>= putStr
+
depsNamesAndVersions :: IO [(String, String)]
depsNamesAndVersions = do
contents <- lines <$> getContents
deps <- traverse parse contents
- pure (filter (\(name, _) -> name /= "purescript" && name /= "rts") deps)
+ pure (filter (\(name, _) -> not (excluded name)) deps)
where
+ excluded name =
+ name == "purescript"
+ || name == "rts"
+ || name == "ghc-boot-th"
+ || name == "happy-lib"
+
parse line =
case splitOn " " line of
[pkg, vers] -> pure (pkg, vers)
@@ -154,7 +173,7 @@ downloadFromHackage urlpath manager dep = do
resp <- httpLbs req manager
let status = responseStatus resp
- if (status /= ok200)
+ if status /= ok200
then do
hPutStrLn stderr $ "Bad status code for " ++ url
hPutStrLn stderr $ "Expected 200, got " ++ show status
diff --git a/license-generator/header.txt b/license-generator/header.txt
index cdebf0bb84..9ce87381dd 100644
--- a/license-generator/header.txt
+++ b/license-generator/header.txt
@@ -12,4 +12,17 @@ Redistribution and use in source and binary forms, with or without modification,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+PureScript executables for Linux distributed under the Releases tab of its GitHub
+repository (https://github.com/purescript/purescript) may be statically-linked to
+a version of GMP, licensed under the GNU Lesser General Public License Version 3,
+29 June 2007.
+
+The full source code of PureScript is available in the aforementioned repository,
+https://github.com/purescript/purescript, allowing you to modify and relink the
+GMP portion if desired.
+
+GMP source code is available at: https://gmplib.org/
+
+A copy of the LGPL is reproduced below.
+
PureScript uses the following Haskell library packages. Their license files follow.
diff --git a/license-generator/lgpl.txt b/license-generator/lgpl.txt
new file mode 100644
index 0000000000..12fad8bef5
--- /dev/null
+++ b/license-generator/lgpl.txt
@@ -0,0 +1,158 @@
+============================================================================
+
+GNU LESSER GENERAL PUBLIC LICENSE
+Version 3, 29 June 2007
+
+Copyright (C) 2007 Free Software Foundation, Inc.
+
+Everyone is permitted to copy and distribute verbatim copies of this license
+document, but changing it is not allowed.
+
+This version of the GNU Lesser General Public License incorporates the terms
+and conditions of version 3 of the GNU General Public License, supplemented
+by the additional permissions listed below.
+
+0. Additional Definitions.
+
+As used herein, “this License” refers to version 3 of the GNU Lesser General
+Public License, and the “GNU GPL” refers to version 3 of the
+GNU General Public License.
+
+“The Library” refers to a covered work governed by this License, other than
+an Application or a Combined Work as defined below.
+
+An “Application” is any work that makes use of an interface provided by the
+Library, but which is not otherwise based on the Library. Defining a subclass
+of a class defined by the Library is deemed a mode of using an interface
+provided by the Library.
+
+A “Combined Work” is a work produced by combining or linking an Application
+with the Library. The particular version of the Library with which the
+Combined Work was made is also called the “Linked Version”.
+
+The “Minimal Corresponding Source” for a Combined Work means the Corresponding
+Source for the Combined Work, excluding any source code for portions of the
+Combined Work that, considered in isolation, are based on the Application,
+and not on the Linked Version.
+
+The “Corresponding Application Code” for a Combined Work means the object code
+and/or source code for the Application, including any data and utility programs
+needed for reproducing the Combined Work from the Application, but excluding
+the System Libraries of the Combined Work.
+
+1. Exception to Section 3 of the GNU GPL.
+
+You may convey a covered work under sections 3 and 4 of this License without
+being bound by section 3 of the GNU GPL.
+
+2. Conveying Modified Versions.
+
+If you modify a copy of the Library, and, in your modifications, a facility
+refers to a function or data to be supplied by an Application that uses the
+facility (other than as an argument passed when the facility is invoked),
+then you may convey a copy of the modified version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the function or
+ data, the facility still operates, and performs whatever part of its
+ purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of this
+ License applicable to that copy.
+
+3. Object Code Incorporating Material from Library Header Files.
+
+The object code form of an Application may incorporate material from a header
+file that is part of the Library. You may convey such object code under terms
+of your choice, provided that, if the incorporated material is not limited to
+numerical parameters, data structure layouts and accessors, or small macros,
+inline functions and templates (ten or fewer lines in length),
+you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the Library
+ is used in it and that the Library and its use are covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL
+ and this license document.
+
+4. Combined Works.
+
+You may convey a Combined Work under terms of your choice that, taken together,
+effectively do not restrict modification of the portions of the Library
+contained in the Combined Work and reverse engineering for debugging such
+modifications, if you also do each of the following:
+
+ a) Give prominent notice with each copy of the Combined Work that the
+ Library is used in it and that the Library and its use are covered
+ by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and
+ this license document.
+
+ c) For a Combined Work that displays copyright notices during execution,
+ include the copyright notice for the Library among these notices, as well
+ as a reference directing the user to the copies of the GNU GPL
+ and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form suitable
+ for, and under terms that permit, the user to recombine or relink
+ the Application with a modified version of the Linked Version to
+ produce a modified Combined Work, in the manner specified by section 6
+ of the GNU GPL for conveying Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time a
+ copy of the Library already present on the user's computer system,
+ and (b) will operate properly with a modified version of the Library
+ that is interface-compatible with the Linked Version.
+
+ e) Provide Installation Information, but only if you would otherwise be
+ required to provide such information under section 6 of the GNU GPL, and
+ only to the extent that such information is necessary to install and
+ execute a modified version of the Combined Work produced by recombining
+ or relinking the Application with a modified version of the Linked Version.
+ (If you use option 4d0, the Installation Information must accompany the
+ Minimal Corresponding Source and Corresponding Application Code. If you
+ use option 4d1, you must provide the Installation Information in the
+ manner specified by section 6 of the GNU GPL for
+ conveying Corresponding Source.)
+
+5. Combined Libraries.
+
+You may place library facilities that are a work based on the Library side by
+side in a single library together with other library facilities that are not
+Applications and are not covered by this License, and convey such a combined
+library under terms of your choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based on
+ the Library, uncombined with any other library facilities, conveyed under
+ the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it is a
+ work based on the Library, and explaining where to find the accompanying
+ uncombined form of the same work.
+
+6. Revised Versions of the GNU Lesser General Public License.
+
+The Free Software Foundation may publish revised and/or new versions of the
+GNU Lesser General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library as you
+received it specifies that a certain numbered version of the GNU Lesser
+General Public License “or any later version” applies to it, you have the
+option of following the terms and conditions either of that published version
+or of any later version published by the Free Software Foundation. If the
+Library as you received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser General
+Public License ever published by the Free Software Foundation.
+
+If the Library as you received it specifies that a proxy can decide whether
+future versions of the GNU Lesser General Public License shall apply, that
+proxy's public statement of acceptance of any version is permanent
+authorization for you to choose that version for the Library.
+
diff --git a/logo.png b/logo.png
index e6cc934745..6c91bf49d8 100644
Binary files a/logo.png and b/logo.png differ
diff --git a/make_release_notes b/make_release_notes
deleted file mode 100755
index edf84a2d22..0000000000
--- a/make_release_notes
+++ /dev/null
@@ -1,2 +0,0 @@
-curl https://api.github.com/repos/purescript/purescript/pulls?state=closed\&per_page=100 \
- | jq -r '.[] | ("- " + .title + " (@" + .user.login + ")")'
diff --git a/npm-package/.gitignore b/npm-package/.gitignore
new file mode 100644
index 0000000000..059fb4c540
--- /dev/null
+++ b/npm-package/.gitignore
@@ -0,0 +1,2 @@
+purs.bin
+package-lock.json
diff --git a/npm-package/LICENSE b/npm-package/LICENSE
new file mode 100644
index 0000000000..d99869e6a1
--- /dev/null
+++ b/npm-package/LICENSE
@@ -0,0 +1,6 @@
+ISC License (ISC)
+Copyright 2017 - 2019 Watanabe Shinnosuke
+
+Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/npm-package/README.md b/npm-package/README.md
new file mode 100644
index 0000000000..de54955987
--- /dev/null
+++ b/npm-package/README.md
@@ -0,0 +1,62 @@
+# PureScript npm package
+
+[](https://www.npmjs.com/package/purescript)
+[](https://travis-ci.org/purescript-contrib/node-purescript)
+
+[PureScript](https://github.com/purescript/purescript) binary wrapper that makes it seamlessly available via [npm](https://www.npmjs.com/)
+
+## Prerequisites
+
+This package makes maximum use of `postinstall` [script](https://docs.npmjs.com/misc/scripts), so please make sure that [`ignore-scripts` npm-config](https://docs.npmjs.com/misc/config#ignore-scripts) is not enabled before installation.
+
+```console
+$ npm config get ignore-scripts
+false
+```
+
+## Installation
+
+[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).
+
+```
+npm install purescript
+```
+
+Once the command above is executed,
+
+__1.__ First, it checks if a PureScript binary has been already cached, and restores that if available.
+
+__2.__ The second plan: if no cache is available, it downloads a prebuilt binary from [the PureScript release page](https://github.com/purescript/purescript/releases).
+
+__3.__ The last resort: if no prebuilt binary is provided for your platform or the downloaded binary doesn't work correctly, it downloads [the PureScript source code](https://github.com/purescript/purescript/tree/master) and compile it with [Stack](https://docs.haskellstack.org/).
+
+## API
+
+### `require('purescript')`
+
+Type: `string`
+
+An absolute path to the installed PureScript binary, which can be used with [`child_process`](https://nodejs.org/api/child_process.html) functions.
+
+```javascript
+const {execFile} = require('child_process');
+const purs = require('purescript'); //=> '/Users/you/example/node_modules/purescript/purs.bin'
+
+execFile(purs, ['compile', 'input.purs', '--output', 'output.purs'], () => {
+ console.log('Compiled.');
+});
+```
+
+## CLI
+
+You can use it via CLI by installing it [globally](https://docs.npmjs.com/files/folders#global-installation).
+
+```
+npm install --global purescript
+
+purs --help
+```
+
+## License
+
+[ISC License](./LICENSE) © 2017 - 2019 Watanabe Shinnosuke
diff --git a/npm-package/index.js b/npm-package/index.js
new file mode 100644
index 0000000000..b4fec3cf51
--- /dev/null
+++ b/npm-package/index.js
@@ -0,0 +1 @@
+module.exports = require.resolve('./purs.bin');
diff --git a/npm-package/package.json b/npm-package/package.json
new file mode 100644
index 0000000000..a1bbc7f452
--- /dev/null
+++ b/npm-package/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "purescript",
+ "version": "0.15.16",
+ "license": "ISC",
+ "description": "PureScript wrapper that makes it available as a local dependency",
+ "author": {
+ "name": "Watanabe Shinnosuke",
+ "url": "http://github.com/shinnn"
+ },
+ "files": [
+ "index.js",
+ "purs.bin"
+ ],
+ "bin": {
+ "purs": "purs.bin"
+ },
+ "dependencies": {
+ "purescript-installer": "^0.3.5"
+ },
+ "homepage": "https://github.com/purescript/purescript",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/purescript/purescript.git"
+ },
+ "bugs": {
+ "url": "https://github.com/purescript/npm-installer/issues"
+ },
+ "keywords": [
+ "cli",
+ "build",
+ "install",
+ "installation",
+ "fallback",
+ "purs",
+ "purescript",
+ "haskell",
+ "language",
+ "compile",
+ "compiler",
+ "bin",
+ "binary",
+ "wrapper"
+ ],
+ "scripts": {
+ "prepublishOnly": "node -e \"require('fs').copyFileSync('purs.bin.placeholder', 'purs.bin');\"",
+ "postinstall": "install-purescript --purs-ver=0.15.16",
+ "test": "echo 'Error: no test specified' && exit 1"
+ }
+}
diff --git a/npm-package/purs.bin.placeholder b/npm-package/purs.bin.placeholder
new file mode 100755
index 0000000000..ca25a635fd
--- /dev/null
+++ b/npm-package/purs.bin.placeholder
@@ -0,0 +1,7 @@
+# This is a placeholder file of a PureScript binary installed with npm. If you
+# see this file, that means the installation has failed and the placeholder has
+# not been replaced with a valid binary. Try installing the `purescript` npm
+# package again.
+
+echo >&2 "purescript npm installer: installation failed; please try installing again"
+exit 1
diff --git a/package.yaml b/package.yaml
deleted file mode 100644
index d18104e122..0000000000
--- a/package.yaml
+++ /dev/null
@@ -1,180 +0,0 @@
-name: purescript
-version: '0.12.5'
-synopsis: PureScript Programming Language Compiler
-description: A small strongly, statically typed programming language with expressive
- types, inspired by Haskell and compiling to JavaScript.
-category: Language
-author: >
- Phil Freeman ,
- Gary Burgess ,
- Hardy Jones ,
- Harry Garrood ,
- Christoph Hegemann
-maintainer: Phil Freeman
-copyright: (c) 2013-17 Phil Freeman, (c) 2014-17 Gary Burgess
-license: BSD3
-github: purescript/purescript
-homepage: http://www.purescript.org/
-extra-source-files:
- - app/static/*
- - bundle/build.sh
- - bundle/README
- - tests/purs/**/*.js
- - tests/purs/**/*.purs
- - tests/purs/**/*.json
- - tests/json-compat/**/*.json
- - tests/support/*.json
- - tests/support/setup-win.cmd
- - tests/support/psci/**.purs
- - tests/support/psci/**.edit
- - tests/support/pscide/src/**/*.purs
- - tests/support/pscide/src/**/*.js
- - tests/support/pscide/src/**/*.fail
- - stack.yaml
- - README.md
- - INSTALL.md
- - CONTRIBUTORS.md
- - CONTRIBUTING.md
-dependencies:
- - aeson >=1.0 && <1.5
- - aeson-better-errors >=0.8
- - ansi-terminal >=0.7.1 && <0.9
- - array
- - base >=4.8 && <4.13
- - base-compat >=0.6.0
- - blaze-html >=0.8.1 && <0.10
- - bower-json >=1.0.0.1 && <1.1
- - boxes >=0.1.4 && <0.2.0
- - bytestring
- - Cabal >= 2.2
- - cheapskate >=0.1 && <0.2
- - clock
- - containers
- - data-ordlist >=0.4.7.0
- - deepseq
- - directory >=1.2.3
- - dlist
- - edit-distance
- - file-embed
- - filepath
- - fsnotify >=0.2.1
- - Glob >=0.9 && <0.10
- - haskeline >=0.7.0.0
- - language-javascript >=0.6.0.9 && <0.7
- - lifted-async >=0.10.0.3 && <0.10.1
- - lifted-base >=0.2.3 && <0.2.4
- - microlens-platform >=0.3.9.0 && <0.4
- - monad-control >=1.0.0.0 && <1.1
- - monad-logger >=0.3 && <0.4
- - mtl >=2.1.0 && <2.3.0
- - parallel >=3.2 && <3.3
- - parsec >=3.1.10
- - pattern-arrows >=0.0.2 && <0.1
- - process >=1.2.0 && <1.7
- - protolude >=0.1.6
- - regex-tdfa
- - safe >=0.3.9 && <0.4
- - scientific >=0.3.4.9 && <0.4
- - semigroups >=0.16.2 && <0.19
- - sourcemap >=0.1.6
- - split
- - stm >=0.2.4.0
- - stringsearch
- - syb
- - text
- - time
- - transformers >=0.3.0 && <0.6
- - transformers-base >=0.4.0 && <0.5
- - transformers-compat >=0.3.0
- - unordered-containers
- - utf8-string >=1 && <2
- - vector
-
-library:
- source-dirs: src
- ghc-options: -Wall -O2
- other-modules: Paths_purescript
- default-extensions:
- - ConstraintKinds
- - DataKinds
- - DeriveFunctor
- - DeriveFoldable
- - DeriveTraversable
- - DeriveGeneric
- - EmptyDataDecls
- - FlexibleContexts
- - KindSignatures
- - LambdaCase
- - MultiParamTypeClasses
- - NoImplicitPrelude
- - PatternGuards
- - PatternSynonyms
- - RankNTypes
- - RecordWildCards
- - OverloadedStrings
- - ScopedTypeVariables
- - TupleSections
- - ViewPatterns
-
-executables:
- purs:
- main: Main.hs
- source-dirs: app
- ghc-options: -Wall -O2 -fno-warn-unused-do-bind -threaded -rtsopts -with-rtsopts=-N
- other-modules:
- - Command.Bundle
- - Command.Compile
- - Command.Docs
- - Command.Docs.Html
- - Command.Hierarchy
- - Command.Ide
- - Command.Publish
- - Command.REPL
- - Paths_purescript
- - Version
-
- dependencies:
- - ansi-wl-pprint
- - file-embed
- - http-types
- - network >= 3.0.1.1
- - optparse-applicative >=0.13.0
- - purescript
- - wai ==3.*
- - wai-websockets ==3.*
- - warp ==3.*
- - websockets >=0.9 && <0.13
- when:
- - condition: flag(release)
- then:
- cpp-options: -DRELEASE
- else:
- dependencies:
- - gitrev >=1.2.0 && <1.4
-
-tests:
- tests:
- main: Main.hs
- source-dirs: tests
- ghc-options: -Wall
- dependencies:
- - purescript
- - tasty
- - tasty-golden
- - tasty-hspec
- - tasty-quickcheck
- - hspec
- - hspec-discover
- - HUnit
- default-extensions:
- - NoImplicitPrelude
-
-flags:
- release:
- description: >
- Mark this build as a release build: prevents inclusion of extra
- info e.g. commit SHA in --version output)
- manual: false
- default: false
-
-stability: experimental
diff --git a/psc-ide/DESIGN.org b/psc-ide/DESIGN.org
index ec63e5d747..45b77f22a3 100644
--- a/psc-ide/DESIGN.org
+++ b/psc-ide/DESIGN.org
@@ -15,10 +15,10 @@
=purs ide= is split into a library and an executable. The library code lives
inside =src/Language/PureScript/Ide=. The executable, which is invoked by the
editors is located inside =app/Command/Ide.hs=.
-
+
The =purs ide= library is unopinionated about:
- - Protocol
+ - Protocol
- Concurrency Model
- Logging
- File watchers
@@ -33,7 +33,7 @@
Break down the type signature:
=handleCommand :: (Ide m, MonadLogger m, MonadError IdeError m) => Command -> m Success=
-
+
Ide m expands to (MonadReader IdeEnvironment m, MonadIO m) and so we end up
with 4 constraints/capabilities handleCommand needs to be provided with by
the caller.
@@ -48,9 +48,9 @@
gets to decide how to handle them.
- MonadLogger
-
+
purs ide uses the =MonadLogger= constraint to defer the choice of logging
- to the exeutable. This constraint can be fulfilled with a console based
+ to the executable. This constraint can be fulfilled with a console based
logger, a file-based one or the log messages can just be discarded (helpful
during testing)
@@ -96,7 +96,7 @@
let environment = IdeEnvironment {ideStateVar = stateVar, ideConfiguration = defConfig}
-- It's easiest to read the next line inside out:
- -- 1. apply =handleCommand= to the command
+ -- 1. apply =handleCommand= to the command
-- 2. Satisfy the MonadReader IdeEnvironment constraint by passing
-- =environment= to =runReaderT=
@@ -122,7 +122,7 @@
=ide= makes sure to not run into deadlocks or data races.
However the current implementation of =purs ide server= runs all the commands
- sequentially, because the commmands run fast enough at this point, and a
+ sequentially, because the commands run fast enough at this point, and a
users interaction with his editor are mostly sequential anyway.
* Commands
The three most involved commands are completion, adding imports and rebuilding.
@@ -144,7 +144,7 @@
plugins.
*** The Query Pipeline
-
+
When fulfilling completion requests or other queries, `ide` runs the stored
declarations through the following pipeline:
@@ -163,7 +163,7 @@
All the different filters, matchers and completion options are documented in
the PROTOCOL.md file.
-
+
*** Filters
Filters are functions of type =Map ModuleName [IdeDeclaration] ->
Map ModuleName [IdeDeclaration]=. They only ever keep or remove
@@ -285,7 +285,7 @@ Language.PureScript.Ide.RebuildSpec)
- All data is regenerated on starting ide = no cache invalidation necessary
- Things are fast, without any effort spent on optimizing things
- Simple model, keeps complexity low
-- We don't polute projects with ide artifacts
+- We don't pollute projects with ide artifacts
*** Cons
- Imposes a limit on how big of a project we can handle
- Means we need to be careful about what information we denormalize, since it
diff --git a/psc-ide/PROTOCOL.md b/psc-ide/PROTOCOL.md
index d64bfbc78b..e6cb5d1115 100644
--- a/psc-ide/PROTOCOL.md
+++ b/psc-ide/PROTOCOL.md
@@ -2,7 +2,7 @@
Communication with `purs ide server` is via a JSON protocol over a TCP connection:
the server listens on a particular (configurable) port, and will accept a single line
-of JSON input in the format described below, terminated by a newline, before giving
+of JSON input in the format described below, terminated by a newline, before giving
a JSON response and closing the connection.
The `purs ide client` command can be used as a wrapper for the TCP connection, but
@@ -80,7 +80,7 @@ The `complete` command looks up possible completions/corrections.
If no matcher is given every candidate, that passes the filters, is returned
in no particular order.
- - `currentModule :: (optional) String`: The current modules name. Allows you
+ - `currentModule :: (optional) String`: The current modules name. Allows you
to see module-private functions after a successful rebuild. If it matches
with the rebuild cache non-exported modules will also be completed. You can
fill the rebuild cache by using the "Rebuild" command.
@@ -107,8 +107,10 @@ The `complete` command looks up possible completions/corrections.
The following format is returned as the Result:
-Both the `definedAt` aswell as the `documentation` field might be `null` if they
-couldn't be extracted from a source file.
+The `definedAt`, `documentation`, as well as the `declarationType` field might
+be `null` if they couldn't be extracted from a source file. See the
+[Declaration Type Filter](#declaration-type-filter) further down for all
+possible values of declaration types and how to use this information.
```json
[
@@ -124,7 +126,8 @@ couldn't be extracted from a source file.
"end": [3, 1]
},
"documentation": "A filtering function",
- "exportedFrom": ["Data.Array"]
+ "exportedFrom": ["Data.Array"],
+ "declarationType": "value",
}
]
```
@@ -368,7 +371,8 @@ loaded. A successful rebuild will be stored to allow for completions of private
identifiers.
Arguments:
- - `file :: String` the path to the module to rebuild
+ - `file :: String` the path to the module to rebuild **or** the complete
+ source code of the module to be compiled prefixed with `data:`
- `actualFile :: Maybe String` Specifies the path to be used for location
information and parse errors. This is useful in case a temp file is used as
the source for a rebuild.
@@ -435,7 +439,7 @@ The list availableModules command returns a list of strings.
#### Imports
-The list commmand can also list the imports for a given file.
+The list command can also list the imports for a given file.
```json
{
@@ -573,14 +577,22 @@ The Module filter only keeps identifiers that appear in the listed modules.
```
### Dependency filter
-The Dependency filter only keeps identifiers that appear in the listed modules
-and in any of their dependencies/imports.
+The Dependency filter only keeps identifiers that appear in the listed module or
+are brought into scope by any of its imports.
+
+The module text is provided, though only the portion up until the end of the import section
+need be provided.
+
+Parameters:
+- `moduleText :: String`
+- `qualifier :: String` (optional)
```json
{
"filter": "dependencies",
"params": {
- "modules": ["My.Module"]
+ "moduleText": "module My.Module where\nimport Foo as F\n",
+ "qualifier": "F"
}
}
```
@@ -623,7 +635,7 @@ A filter which allows to filter type declarations. Valid type declarations are
## Matcher:
### Flex matcher
-Matches any occurence of the search string with intersections
+Matches any occurrence of the search string with intersections
The scoring measures how far the matches span the string, where
closer is better. The matches then get sorted with highest score first.
diff --git a/psc-ide/README.md b/psc-ide/README.md
index bd05fcdc7c..80d9f65eed 100644
--- a/psc-ide/README.md
+++ b/psc-ide/README.md
@@ -23,12 +23,7 @@ It supports the following options:
- `--output-directory`: Specify where to look for compiled output inside your
project directory. Defaults to `output/`, relative to either the current
directory or the directory specified by `-d`.
-- `--polling`: Uses polling instead of file system events to watch the externs
- files. This flag is reversed on Windows and polling is the default.
- `--log-level`: Can be set to one of "all", "none", "debug" and "perf"
-- `--no-watch`: Disables the filewatcher
-- `--editor-mode`: Rather than watch externs files, expect an editor to report
- changed source files.
- `--version`: Output psc-ide version
## Issuing queries
@@ -37,7 +32,7 @@ After you started the server you can start issuing requests using
`purs ide client`. Make sure you start by loading the modules before you try to
query them.
-`purs ide` expects the built externs.json inside the output folder of your
+`purs ide` expects the built externs inside the output folder of your
project after running `pulp build` or `purs compile` respectively.
(If you changed the port of the server you can change the port for
diff --git a/purescript.cabal b/purescript.cabal
new file mode 100644
index 0000000000..0a36e8c0b4
--- /dev/null
+++ b/purescript.cabal
@@ -0,0 +1,496 @@
+cabal-version: 2.4
+
+name: purescript
+-- Note: don't add prerelease identifiers here! Add them in app/Version.hs and npm-package/package.json instead.
+version: 0.15.16
+synopsis: PureScript Programming Language Compiler
+description: A small strongly, statically typed programming language with expressive types, inspired by Haskell and compiling to JavaScript.
+category: Language
+stability: experimental
+homepage: http://www.purescript.org/
+bug-reports: https://github.com/purescript/purescript/issues
+author: Phil Freeman
+maintainer: Gary Burgess , Hardy Jones , Harry Garrood , Christoph Hegemann , Liam Goodacre , Nathan Faubion
+
+copyright: (c) 2013-17 Phil Freeman, (c) 2014-19 Gary Burgess, (c) other contributors (see CONTRIBUTORS.md)
+license: BSD-3-Clause
+license-file: LICENSE
+build-type: Simple
+extra-source-files:
+ app/static/*.css
+ app/static/*.less
+ bundle/build.sh
+ bundle/README
+ tests/purs/**/*.js
+ tests/purs/**/*.js.map
+ tests/purs/**/*.purs
+ tests/purs/**/*.json
+ tests/purs/**/*.out
+ tests/json-compat/**/*.json
+ tests/support/*.json
+ tests/support/checkSourceMapValidity.js
+ tests/support/psci/**/*.purs
+ tests/support/psci/**/*.edit
+ tests/support/pscide/src/**/*.purs
+ tests/support/pscide/src/**/*.js
+ tests/support/pscide/src/**/*.fail
+ stack.yaml
+ README.md
+ INSTALL.md
+ CONTRIBUTORS.md
+ CONTRIBUTING.md
+ VERSIONING_POLICY.md
+ .hspec
+
+source-repository head
+ type: git
+ location: https://github.com/purescript/purescript
+
+flag release
+ description: Mark this build as a release build: prevents inclusion of extra info e.g. commit SHA in --version output)
+
+ manual: False
+ default: False
+
+common defaults
+ ghc-options:
+ -- This list taken from https://medium.com/mercury-bank/enable-all-the-warnings-a0517bc081c3
+ -- Enable all warnings with -Weverything, then disable the ones we don’t care about
+ -Weverything
+
+ -- missing-exported-signatures turns off the more strict -Wmissing-signatures. See https://ghc.haskell.org/trac/ghc/ticket/14794#ticket
+ -Wno-missing-exported-signatures
+
+ -- Requires explicit imports of _every_ function (e.g. ‘$’); too strict
+ -Wno-missing-import-lists
+
+ -- When GHC can’t specialize a polymorphic function. No big deal and requires fixing underlying libraries to solve.
+ -Wno-missed-specialisations
+ -Wno-all-missed-specialisations
+
+ -- Don’t use Safe Haskell warnings
+ -Wno-unsafe
+ -Wno-safe
+ -Wno-trustworthy-safe
+ -Wno-inferred-safe-imports
+ -Wno-missing-safe-haskell-mode
+
+ -- Warning for polymorphic local bindings; nothing wrong with those.
+ -Wno-missing-local-signatures
+
+ -- Don’t warn if the monomorphism restriction is used
+ -Wno-monomorphism-restriction
+
+ -- Remaining options don't come from the above blog post
+ -Wno-missing-deriving-strategies
+ -Wno-missing-export-lists
+ -Wno-missing-kind-signatures
+ -Wno-partial-fields
+ -Wno-missing-role-annotations
+ default-language: Haskell2010
+ default-extensions:
+ BangPatterns
+ ConstraintKinds
+ DataKinds
+ DefaultSignatures
+ DeriveFunctor
+ DeriveFoldable
+ DeriveTraversable
+ DeriveGeneric
+ DerivingStrategies
+ DerivingVia
+ EmptyDataDecls
+ FlexibleContexts
+ FlexibleInstances
+ GeneralizedNewtypeDeriving
+ ImportQualifiedPost
+ KindSignatures
+ LambdaCase
+ MultiParamTypeClasses
+ NamedFieldPuns
+ NoImplicitPrelude
+ PatternGuards
+ PatternSynonyms
+ RankNTypes
+ RecordWildCards
+ OverloadedRecordDot
+ OverloadedStrings
+ ScopedTypeVariables
+ TupleSections
+ TypeFamilies
+ ViewPatterns
+ build-depends:
+ -- NOTE: Please do not edit these version constraints manually. They are
+ -- deliberately made narrow because changing the dependency versions in
+ -- use can often result in changes in the compiler's behaviour. The
+ -- PureScript compiler is an executable first and foremost, and only
+ -- incidentally a library, and supporting a wide range of dependencies is
+ -- not a goal.
+ --
+ -- These version ranges are generated from taking a Stackage snapshot and
+ -- then generating PVP-compliant bounds based on that snapshot. You can
+ -- update to a newer snapshot as follows:
+ --
+ -- 1. Remove all version constraints from this cabal file (apart from
+ -- language-javascript).
+ -- 2. Update stack.yaml as required to select a new snapshot, and check
+ -- everything builds correctly with stack.
+ -- 3. Run `stack sdist`; this will produce a source distribution including
+ -- a modified version of the cabal file, which includes bounds for all
+ -- dependencies (because of `pvp-bounds: both` in stack.yaml).
+ -- 4. Copy the version bounds from the library's build-depends section
+ -- to here.
+ --
+ -- This procedure allows us to take advantage of Stackage snapshots to
+ -- easily perform updates, while also ensuring that the compiler will be
+ -- built with (almost) the same install plan for both cabal and stack
+ -- users.
+ --
+ -- We need to be especially careful with
+ -- language-javascript, because it forms a part of the compiler's
+ -- public API. In the case of language-javascript specifically, all FFI
+ -- modules must be parseable by this library otherwise the compiler
+ -- will reject them. It should therefore always be pinned to a single
+ -- specific version.
+ aeson >=2.2.3.0 && <2.3,
+ aeson-better-errors >=0.9.1.3 && <0.10,
+ ansi-terminal >=1.1.2 && <1.2,
+ array >=0.5.8.0 && <0.6,
+ base >=4.19.2.0 && <4.20,
+ blaze-html >=0.9.2.0 && <0.10,
+ bower-json >=1.1.0.0 && <1.2,
+ boxes >=0.1.5 && <0.2,
+ bytestring >=0.12.1.0 && <0.13,
+ Cabal >=3.10.3.0 && <3.11,
+ cborg >=0.2.10.0 && <0.3,
+ cheapskate >=0.1.1.2 && <0.2,
+ clock >=0.8.4 && <0.9,
+ containers >=0.6.8 && <0.7,
+ cryptonite >=0.30 && <0.31,
+ data-ordlist >=0.4.7.0 && <0.5,
+ deepseq >=1.5.1.0 && <1.6,
+ directory >=1.3.8.5 && <1.4,
+ dlist >=1.0 && <1.1,
+ edit-distance >=0.2.2.1 && <0.3,
+ file-embed >=0.0.16.0 && <0.1,
+ filepath >=1.4.301.0 && <1.5,
+ Glob >=0.10.2 && <0.11,
+ haskeline >=0.8.2.1 && <0.9,
+ language-javascript ==0.7.0.0,
+ lens >=5.3.4 && <5.4,
+ lifted-async >=0.10.2.7 && <0.11,
+ lifted-base >=0.2.3.12 && <0.3,
+ memory >=0.18.0 && <0.19,
+ monad-control >=1.0.3.1 && <1.1,
+ monad-logger >=0.3.42 && <0.4,
+ monoidal-containers >=0.6.6.0 && <0.7,
+ mtl >=2.3.1 && <2.4,
+ parallel >=3.2.2.0 && <3.3,
+ parsec >=3.1.17.0 && <3.2,
+ process >=1.6.25.0 && <1.7,
+ protolude >=0.3.4 && <0.4,
+ regex-tdfa >=1.3.2.3 && <1.4,
+ safe >=0.3.21 && <0.4,
+ scientific >=0.3.8.0 && <0.4,
+ semialign >=1.3.1 && <1.4,
+ semigroups >=0.20 && <0.21,
+ serialise >=0.2.6.1 && <0.3,
+ sourcemap >=0.1.7 && <0.2,
+ stm >=2.5.3.1 && <2.6,
+ stringsearch >=0.3.6.6 && <0.4,
+ template-haskell >=2.21.0.0 && <2.22,
+ text >=2.1.1 && <2.2,
+ these >=1.2.1 && <1.3,
+ time >=1.12.2 && <1.13,
+ transformers >=0.6.1.0 && <0.7,
+ transformers-base >=0.4.6 && <0.5,
+ utf8-string >=1.0.2 && <1.1,
+ vector >=0.13.2.0 && <0.14,
+ witherable >=0.5 && <0.6,
+
+library
+ import: defaults
+ hs-source-dirs: src
+ exposed-modules:
+ Control.Monad.Logger
+ Control.Monad.Supply
+ Control.Monad.Supply.Class
+ Control.PatternArrows
+ Language.PureScript
+ Language.PureScript.AST
+ Language.PureScript.AST.Binders
+ Language.PureScript.AST.Declarations
+ Language.PureScript.AST.Declarations.ChainId
+ Language.PureScript.AST.Exported
+ Language.PureScript.AST.Literals
+ Language.PureScript.AST.Operators
+ Language.PureScript.AST.SourcePos
+ Language.PureScript.AST.Traversals
+ Language.PureScript.AST.Utils
+ Language.PureScript.Bundle
+ Language.PureScript.CodeGen
+ Language.PureScript.CodeGen.JS
+ Language.PureScript.CodeGen.JS.Common
+ Language.PureScript.CodeGen.JS.Printer
+ Language.PureScript.Constants.Libs
+ Language.PureScript.CoreFn
+ Language.PureScript.CoreFn.Ann
+ Language.PureScript.CoreFn.Binders
+ Language.PureScript.CoreFn.CSE
+ Language.PureScript.CoreFn.Desugar
+ Language.PureScript.CoreFn.Expr
+ Language.PureScript.CoreFn.FromJSON
+ Language.PureScript.CoreFn.Laziness
+ Language.PureScript.CoreFn.Meta
+ Language.PureScript.CoreFn.Module
+ Language.PureScript.CoreFn.Optimizer
+ Language.PureScript.CoreFn.ToJSON
+ Language.PureScript.CoreFn.Traversals
+ Language.PureScript.CoreImp
+ Language.PureScript.CoreImp.AST
+ Language.PureScript.CoreImp.Module
+ Language.PureScript.CoreImp.Optimizer
+ Language.PureScript.CoreImp.Optimizer.Blocks
+ Language.PureScript.CoreImp.Optimizer.Common
+ Language.PureScript.CoreImp.Optimizer.Inliner
+ Language.PureScript.CoreImp.Optimizer.MagicDo
+ Language.PureScript.CoreImp.Optimizer.TCO
+ Language.PureScript.CoreImp.Optimizer.Unused
+ Language.PureScript.CST
+ Language.PureScript.CST.Convert
+ Language.PureScript.CST.Errors
+ Language.PureScript.CST.Flatten
+ Language.PureScript.CST.Layout
+ Language.PureScript.CST.Lexer
+ Language.PureScript.CST.Monad
+ Language.PureScript.CST.Parser
+ Language.PureScript.CST.Positions
+ Language.PureScript.CST.Print
+ Language.PureScript.CST.Traversals
+ Language.PureScript.CST.Traversals.Type
+ Language.PureScript.CST.Types
+ Language.PureScript.CST.Utils
+ Language.PureScript.Comments
+ Language.PureScript.Constants.Prim
+ Language.PureScript.Crash
+ Language.PureScript.Docs
+ Language.PureScript.Docs.AsHtml
+ Language.PureScript.Docs.AsMarkdown
+ Language.PureScript.Docs.Collect
+ Language.PureScript.Docs.Convert
+ Language.PureScript.Docs.Convert.ReExports
+ Language.PureScript.Docs.Convert.Single
+ Language.PureScript.Docs.Css
+ Language.PureScript.Docs.Prim
+ Language.PureScript.Docs.Render
+ Language.PureScript.Docs.RenderedCode
+ Language.PureScript.Docs.RenderedCode.RenderType
+ Language.PureScript.Docs.RenderedCode.Types
+ Language.PureScript.Docs.Tags
+ Language.PureScript.Docs.Types
+ Language.PureScript.Docs.Utils.MonoidExtras
+ Language.PureScript.Environment
+ Language.PureScript.Errors
+ Language.PureScript.Errors.JSON
+ Language.PureScript.Externs
+ Language.PureScript.Glob
+ Language.PureScript.Graph
+ Language.PureScript.Hierarchy
+ Language.PureScript.Ide
+ Language.PureScript.Ide.CaseSplit
+ Language.PureScript.Ide.Command
+ Language.PureScript.Ide.Completion
+ Language.PureScript.Ide.Error
+ Language.PureScript.Ide.Externs
+ Language.PureScript.Ide.Filter
+ Language.PureScript.Ide.Filter.Declaration
+ Language.PureScript.Ide.Filter.Imports
+ Language.PureScript.Ide.Imports
+ Language.PureScript.Ide.Imports.Actions
+ Language.PureScript.Ide.Logging
+ Language.PureScript.Ide.Matcher
+ Language.PureScript.Ide.Prim
+ Language.PureScript.Ide.Rebuild
+ Language.PureScript.Ide.Reexports
+ Language.PureScript.Ide.SourceFile
+ Language.PureScript.Ide.State
+ Language.PureScript.Ide.Types
+ Language.PureScript.Ide.Usage
+ Language.PureScript.Ide.Util
+ Language.PureScript.Interactive
+ Language.PureScript.Interactive.Completion
+ Language.PureScript.Interactive.Directive
+ Language.PureScript.Interactive.IO
+ Language.PureScript.Interactive.Message
+ Language.PureScript.Interactive.Module
+ Language.PureScript.Interactive.Parser
+ Language.PureScript.Interactive.Printer
+ Language.PureScript.Interactive.Types
+ Language.PureScript.Label
+ Language.PureScript.Linter
+ Language.PureScript.Linter.Exhaustive
+ Language.PureScript.Linter.Imports
+ Language.PureScript.Linter.Wildcards
+ Language.PureScript.Make
+ Language.PureScript.Make.Actions
+ Language.PureScript.Make.BuildPlan
+ Language.PureScript.Make.Cache
+ Language.PureScript.Make.Monad
+ Language.PureScript.ModuleDependencies
+ Language.PureScript.Names
+ Language.PureScript.Options
+ Language.PureScript.Pretty
+ Language.PureScript.Pretty.Common
+ Language.PureScript.Pretty.Types
+ Language.PureScript.Pretty.Values
+ Language.PureScript.PSString
+ Language.PureScript.Publish
+ Language.PureScript.Publish.BoxesHelpers
+ Language.PureScript.Publish.ErrorsWarnings
+ Language.PureScript.Publish.Registry.Compat
+ Language.PureScript.Publish.Utils
+ Language.PureScript.Renamer
+ Language.PureScript.Roles
+ Language.PureScript.Sugar
+ Language.PureScript.Sugar.AdoNotation
+ Language.PureScript.Sugar.BindingGroups
+ Language.PureScript.Sugar.CaseDeclarations
+ Language.PureScript.Sugar.DoNotation
+ Language.PureScript.Sugar.LetPattern
+ Language.PureScript.Sugar.Names
+ Language.PureScript.Sugar.Names.Common
+ Language.PureScript.Sugar.Names.Env
+ Language.PureScript.Sugar.Names.Exports
+ Language.PureScript.Sugar.Names.Imports
+ Language.PureScript.Sugar.ObjectWildcards
+ Language.PureScript.Sugar.Operators
+ Language.PureScript.Sugar.Operators.Binders
+ Language.PureScript.Sugar.Operators.Common
+ Language.PureScript.Sugar.Operators.Expr
+ Language.PureScript.Sugar.Operators.Types
+ Language.PureScript.Sugar.TypeClasses
+ Language.PureScript.Sugar.TypeClasses.Deriving
+ Language.PureScript.Sugar.TypeDeclarations
+ Language.PureScript.Traversals
+ Language.PureScript.TypeChecker
+ Language.PureScript.TypeChecker.Deriving
+ Language.PureScript.TypeChecker.Entailment
+ Language.PureScript.TypeChecker.Entailment.Coercible
+ Language.PureScript.TypeChecker.Entailment.IntCompare
+ Language.PureScript.TypeChecker.Kinds
+ Language.PureScript.TypeChecker.Monad
+ Language.PureScript.TypeChecker.Roles
+ Language.PureScript.TypeChecker.Skolems
+ Language.PureScript.TypeChecker.Subsumption
+ Language.PureScript.TypeChecker.Synonyms
+ Language.PureScript.TypeChecker.Types
+ Language.PureScript.TypeChecker.TypeSearch
+ Language.PureScript.TypeChecker.Unify
+ Language.PureScript.TypeClassDictionaries
+ Language.PureScript.Types
+ System.IO.UTF8
+ other-modules:
+ Data.Text.PureScript
+ Language.PureScript.Constants.TH
+ Paths_purescript
+ autogen-modules:
+ Paths_purescript
+ build-tool-depends:
+ happy:happy ==2.0.2
+
+executable purs
+ import: defaults
+ hs-source-dirs: app
+ main-is: Main.hs
+ ghc-options: -fno-warn-unused-do-bind -threaded -rtsopts -with-rtsopts=-N -Wno-unused-packages
+ build-depends:
+ prettyprinter >=1.7.1 && <1.8,
+ prettyprinter-ansi-terminal >=1.1.3 && <1.2,
+ exceptions >=0.10.7 && <0.11,
+ network >=3.2.7.0 && <3.3,
+ optparse-applicative >=0.18.1.0 && <0.19,
+ purescript
+ if flag(release)
+ cpp-options: -DRELEASE
+ else
+ build-depends:
+ gitrev >=1.3.1 && <1.4,
+ other-modules:
+ Command.Bundle
+ Command.Compile
+ Command.Docs
+ Command.Docs.Html
+ Command.Docs.Markdown
+ Command.Graph
+ Command.Hierarchy
+ Command.Ide
+ Command.Publish
+ Command.REPL
+ SharedCLI
+ Version
+ Paths_purescript
+ autogen-modules:
+ Paths_purescript
+ if flag(static)
+ ld-options: -static -pthread
+
+test-suite tests
+ import: defaults
+ type: exitcode-stdio-1.0
+ hs-source-dirs: tests
+ main-is: Main.hs
+ -- Not a problem for this warning to arise in tests
+ ghc-options: -Wno-incomplete-uni-patterns -Wno-unused-packages
+ build-depends:
+ purescript,
+ generic-random >=1.5.0.1 && <1.6,
+ hspec >=2.11.12 && <2.12,
+ HUnit >=1.6.2.0 && <1.7,
+ newtype >=0.2.2.0 && <0.3,
+ QuickCheck >=2.14.3 && <2.15,
+ regex-base >=0.94.0.3 && <0.95,
+ split >=0.2.5 && <0.3,
+ typed-process >=0.2.12.0 && <0.3,
+ build-tool-depends:
+ hspec-discover:hspec-discover -any
+ -- we need the compiler's executable available for the ide tests
+ , purescript:purs -any
+ other-modules:
+ Language.PureScript.Ide.CompletionSpec
+ Language.PureScript.Ide.FilterSpec
+ Language.PureScript.Ide.ImportsSpec
+ Language.PureScript.Ide.MatcherSpec
+ Language.PureScript.Ide.RebuildSpec
+ Language.PureScript.Ide.ReexportsSpec
+ Language.PureScript.Ide.SourceFileSpec
+ Language.PureScript.Ide.StateSpec
+ Language.PureScript.Ide.Test
+ Language.PureScript.Ide.UsageSpec
+ PscIdeSpec
+ TestAst
+ TestCompiler
+ TestCoreFn
+ TestCst
+ TestDocs
+ TestGraph
+ TestHierarchy
+ TestIde
+ TestInteractive
+ TestMake
+ TestPrimDocs
+ TestPsci
+ TestPsci.CommandTest
+ TestPsci.CompletionTest
+ TestPsci.EvalTest
+ TestPsci.TestEnv
+ TestPscPublish
+ TestSourceMaps
+ TestUtils
+ Paths_purescript
+ autogen-modules:
+ Paths_purescript
+
+flag static
+ description: Builds a statically-linked version of the PureScript compiler.
+ manual: True
+ default: False
diff --git a/src/Control/Monad/Logger.hs b/src/Control/Monad/Logger.hs
index c4969d8572..a3ed57b0da 100644
--- a/src/Control/Monad/Logger.hs
+++ b/src/Control/Monad/Logger.hs
@@ -1,20 +1,17 @@
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE TypeFamilies #-}
-
-- |
-- A replacement for WriterT IO which uses mutable references.
--
module Control.Monad.Logger where
-import Prelude.Compat
+import Prelude
import Control.Monad (ap)
import Control.Monad.Base (MonadBase(..))
-import Control.Monad.IO.Class
+import Control.Monad.IO.Class (MonadIO(..))
import Control.Monad.Trans.Control (MonadBaseControl(..))
-import Control.Monad.Writer.Class
+import Control.Monad.Writer.Class (MonadWriter(..))
-import Data.IORef
+import Data.IORef (IORef, atomicModifyIORef', newIORef, readIORef)
-- | A replacement for WriterT IO which uses mutable references.
newtype Logger w a = Logger { runLogger :: IORef w -> IO a }
diff --git a/src/Control/Monad/Supply.hs b/src/Control/Monad/Supply.hs
index 49df7d4fb7..dd447a9c39 100644
--- a/src/Control/Monad/Supply.hs
+++ b/src/Control/Monad/Supply.hs
@@ -1,19 +1,18 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-
-- |
-- Fresh variable supply
--
module Control.Monad.Supply where
-import Prelude.Compat
+import Prelude
-import Control.Applicative
+import Control.Applicative (Alternative)
import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.Reader
-import Control.Monad.State
-import Control.Monad.Writer
+import Control.Monad.Reader (MonadReader, MonadTrans)
+import Control.Monad (MonadPlus)
+import Control.Monad.State (StateT(..))
+import Control.Monad.Writer (MonadWriter)
-import Data.Functor.Identity
+import Data.Functor.Identity (Identity(..))
newtype SupplyT m a = SupplyT { unSupplyT :: StateT Integer m a }
deriving (Functor, Applicative, Monad, MonadTrans, MonadError e, MonadWriter w, MonadReader r, Alternative, MonadPlus)
@@ -28,6 +27,3 @@ type Supply = SupplyT Identity
runSupply :: Integer -> Supply a -> (a, Integer)
runSupply n = runIdentity . runSupplyT n
-
-evalSupply :: Integer -> Supply a -> a
-evalSupply n = runIdentity . evalSupplyT n
diff --git a/src/Control/Monad/Supply/Class.hs b/src/Control/Monad/Supply/Class.hs
index 64038a6aac..b10b42d549 100644
--- a/src/Control/Monad/Supply/Class.hs
+++ b/src/Control/Monad/Supply/Class.hs
@@ -1,17 +1,17 @@
+{-# LANGUAGE TypeOperators #-}
+
-- |
-- A class for monads supporting a supply of fresh names
--
-{-# LANGUAGE DefaultSignatures #-}
-{-# LANGUAGE TypeFamilies #-}
-
module Control.Monad.Supply.Class where
-import Prelude.Compat
+import Prelude
-import Control.Monad.Supply
-import Control.Monad.State
-import Control.Monad.Writer
+import Control.Monad.RWS (MonadState(..), MonadTrans(..), RWST)
+import Control.Monad.State (StateT)
+import Control.Monad.Supply (SupplyT(..))
+import Control.Monad.Writer (WriterT)
import Data.Text (Text, pack)
class Monad m => MonadSupply m where
@@ -31,6 +31,7 @@ instance Monad m => MonadSupply (SupplyT m) where
instance MonadSupply m => MonadSupply (StateT s m)
instance (Monoid w, MonadSupply m) => MonadSupply (WriterT w m)
+instance (Monoid w, MonadSupply m) => MonadSupply (RWST r w s m)
freshName :: MonadSupply m => m Text
freshName = fmap (("$" <> ) . pack . show) fresh
diff --git a/src/Control/PatternArrows.hs b/src/Control/PatternArrows.hs
new file mode 100644
index 0000000000..b01d1cccdc
--- /dev/null
+++ b/src/Control/PatternArrows.hs
@@ -0,0 +1,118 @@
+-----------------------------------------------------------------------------
+--
+-- Module : Control.PatternArrows
+-- Copyright : (c) Phil Freeman 2013
+-- License : MIT
+--
+-- Maintainer : Phil Freeman
+-- Stability : experimental
+-- Portability :
+--
+-- |
+-- Arrows for Pretty Printing
+--
+-----------------------------------------------------------------------------
+
+{-# LANGUAGE GeneralizedNewtypeDeriving, GADTs #-}
+
+module Control.PatternArrows where
+
+import Prelude
+
+import Control.Arrow ((***), (<+>))
+import Control.Arrow qualified as A
+import Control.Category ((>>>))
+import Control.Category qualified as C
+import Control.Monad.State
+import Control.Monad.Fix (fix)
+
+-- |
+-- A first-order pattern match
+--
+-- A pattern is a Kleisli arrow for the @StateT Maybe@ monad. That is, patterns can fail, and can carry user-defined state.
+--
+newtype Pattern u a b = Pattern { runPattern :: A.Kleisli (StateT u Maybe) a b } deriving (A.Arrow, A.ArrowZero, A.ArrowPlus)
+
+instance C.Category (Pattern u) where
+ id = Pattern C.id
+ Pattern p1 . Pattern p2 = Pattern (p1 C.. p2)
+
+instance Functor (Pattern u a) where
+ fmap f (Pattern p) = Pattern $ A.Kleisli $ fmap f . A.runKleisli p
+
+-- |
+-- Run a pattern with an input and initial user state
+--
+-- Returns Nothing if the pattern fails to match
+--
+pattern_ :: Pattern u a b -> u -> a -> Maybe b
+pattern_ p u = flip evalStateT u . A.runKleisli (runPattern p)
+
+-- |
+-- Construct a pattern from a function
+--
+mkPattern :: (a -> Maybe b) -> Pattern u a b
+mkPattern f = Pattern $ A.Kleisli (lift . f)
+
+-- |
+-- Construct a pattern from a stateful function
+--
+mkPattern' :: (a -> StateT u Maybe b) -> Pattern u a b
+mkPattern' = Pattern . A.Kleisli
+
+-- |
+-- Construct a pattern which recursively matches on the left-hand-side
+--
+chainl :: Pattern u a (a, a) -> (r -> r -> r) -> Pattern u a r -> Pattern u a r
+chainl g f p = fix $ \c -> g >>> ((c <+> p) *** p) >>> A.arr (uncurry f)
+
+-- |
+-- Construct a pattern which recursively matches on the right-hand side
+--
+chainr :: Pattern u a (a, a) -> (r -> r -> r) -> Pattern u a r -> Pattern u a r
+chainr g f p = fix $ \c -> g >>> (p *** (c <+> p)) >>> A.arr (uncurry f)
+
+-- |
+-- Construct a pattern which recursively matches on one-side of a tuple
+--
+wrap :: Pattern u a (s, a) -> (s -> r -> r) -> Pattern u a r -> Pattern u a r
+wrap g f p = fix $ \c -> g >>> (C.id *** (c <+> p)) >>> A.arr (uncurry f)
+
+-- |
+-- Construct a pattern which matches a part of a tuple
+--
+split :: Pattern u a (s, t) -> (s -> t -> r) -> Pattern u a r
+split s f = s >>> A.arr (uncurry f)
+
+-- |
+-- A table of operators
+--
+data OperatorTable u a r = OperatorTable { runOperatorTable :: [ [Operator u a r] ] }
+
+-- |
+-- An operator:
+--
+-- [@AssocL@] A left-associative operator
+--
+-- [@AssocR@] A right-associative operator
+--
+-- [@Wrap@] A prefix-like or postfix-like operator
+--
+-- [@Split@] A prefix-like or postfix-like operator which does not recurse into its operand
+--
+data Operator u a r where
+ AssocL :: Pattern u a (a, a) -> (r -> r -> r) -> Operator u a r
+ AssocR :: Pattern u a (a, a) -> (r -> r -> r) -> Operator u a r
+ Wrap :: Pattern u a (s, a) -> (s -> r -> r) -> Operator u a r
+ Split :: Pattern u a (s, t) -> (s -> t -> r) -> Operator u a r
+
+-- |
+-- Build a pretty printer from an operator table and an indecomposable pattern
+--
+buildPrettyPrinter :: OperatorTable u a r -> Pattern u a r -> Pattern u a r
+buildPrettyPrinter table p = foldl (\p' ops -> foldl1 (<+>) (flip map ops $ \case
+ AssocL pat g -> chainl pat g p'
+ AssocR pat g -> chainr pat g p'
+ Wrap pat g -> wrap pat g p'
+ Split pat g -> split pat g
+ ) <+> p') p $ runOperatorTable table
diff --git a/src/Data/Text/PureScript.hs b/src/Data/Text/PureScript.hs
new file mode 100644
index 0000000000..65751bff6b
--- /dev/null
+++ b/src/Data/Text/PureScript.hs
@@ -0,0 +1,23 @@
+-- |
+-- This module contains internal extensions to Data.Text.
+--
+module Data.Text.PureScript (spanUpTo) where
+
+import Prelude
+
+import Data.Text.Internal (Text(..), text)
+import Data.Text.Unsafe (Iter(..), iter)
+
+-- | /O(n)/ 'spanUpTo', applied to a number @n@, predicate @p@, and text @t@,
+-- returns a pair whose first element is the longest prefix (possibly empty) of
+-- @t@ of length less than or equal to @n@ of elements that satisfy @p@, and
+-- whose second is the remainder of the text.
+{-# INLINE spanUpTo #-}
+spanUpTo :: Int -> (Char -> Bool) -> Text -> (Text, Text)
+spanUpTo n p t@(Text arr off len) = (hd, tl)
+ where hd = text arr off k
+ tl = text arr (off + k) (len - k)
+ !k = loop n 0
+ loop !n' !i | n' > 0 && i < len && p c = loop (n' - 1) (i + d)
+ | otherwise = i
+ where Iter c d = iter t i
diff --git a/src/Language/PureScript.hs b/src/Language/PureScript.hs
index a2c7554c2a..f2309f3549 100644
--- a/src/Language/PureScript.hs
+++ b/src/Language/PureScript.hs
@@ -17,20 +17,20 @@ import Language.PureScript.Crash as P
import Language.PureScript.Environment as P
import Language.PureScript.Errors as P hiding (indent)
import Language.PureScript.Externs as P
-import Language.PureScript.Kinds as P
+import Language.PureScript.Graph as P
import Language.PureScript.Linter as P
import Language.PureScript.Make as P
import Language.PureScript.ModuleDependencies as P
import Language.PureScript.Names as P
import Language.PureScript.Options as P
-import Language.PureScript.Parser as P
import Language.PureScript.Pretty as P
import Language.PureScript.Renamer as P
+import Language.PureScript.Roles as P
import Language.PureScript.Sugar as P
import Language.PureScript.TypeChecker as P
import Language.PureScript.Types as P
-import qualified Paths_purescript as Paths
+import Paths_purescript qualified as Paths
version :: Version
version = Paths.version
diff --git a/src/Language/PureScript/AST/Binders.hs b/src/Language/PureScript/AST/Binders.hs
index 528ffb0987..1f427755f0 100644
--- a/src/Language/PureScript/AST/Binders.hs
+++ b/src/Language/PureScript/AST/Binders.hs
@@ -1,15 +1,18 @@
+{-# LANGUAGE DeriveAnyClass #-}
-- |
-- Case binders
--
module Language.PureScript.AST.Binders where
-import Prelude.Compat
+import Prelude
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.AST.Literals
-import Language.PureScript.Names
-import Language.PureScript.Comments
-import Language.PureScript.Types
+import Control.DeepSeq (NFData)
+import GHC.Generics (Generic)
+import Language.PureScript.AST.SourcePos (SourceSpan)
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.Names (Ident, OpName, OpNameType(..), ProperName, ProperNameType(..), Qualified)
+import Language.PureScript.Comments (Comment)
+import Language.PureScript.Types (SourceType)
-- |
-- Data type for binders
@@ -61,7 +64,7 @@ data Binder
-- A binder with a type annotation
--
| TypedBinder SourceType Binder
- deriving (Show)
+ deriving (Show, Generic, NFData)
-- Manual Eq and Ord instances for `Binder` were added on 2018-03-05. Comparing
-- the `SourceSpan` values embedded in some of the data constructors of `Binder`
@@ -71,113 +74,78 @@ data Binder
-- the `Ord` instance was needed for the speed-up, but I did not want the `Eq`
-- to have mismatched behavior.
instance Eq Binder where
- (==) NullBinder NullBinder = True
- (==) NullBinder _ = False
-
- (==) (LiteralBinder _ lb) (LiteralBinder _ lb') = (==) lb lb'
- (==) LiteralBinder{} _ = False
-
- (==) (VarBinder _ ident) (VarBinder _ ident') = (==) ident ident'
- (==) VarBinder{} _ = False
-
- (==) (ConstructorBinder _ qpc bs) (ConstructorBinder _ qpc' bs') =
- (==) qpc qpc' && (==) bs bs'
- (==) ConstructorBinder{} _ = False
-
- (==) (OpBinder _ qov) (OpBinder _ qov') =
- (==) qov qov'
- (==) OpBinder{} _ = False
-
- (==) (BinaryNoParensBinder b1 b2 b3) (BinaryNoParensBinder b1' b2' b3') =
- (==) b1 b1' && (==) b2 b2' && (==) b3 b3'
- (==) BinaryNoParensBinder{} _ = False
-
- (==) (ParensInBinder b) (ParensInBinder b') =
- (==) b b'
- (==) ParensInBinder{} _ = False
-
- (==) (NamedBinder _ ident b) (NamedBinder _ ident' b') =
- (==) ident ident' && (==) b b'
- (==) NamedBinder{} _ = False
-
- (==) (PositionedBinder _ comments b) (PositionedBinder _ comments' b') =
- (==) comments comments' && (==) b b'
- (==) PositionedBinder{} _ = False
-
- (==) (TypedBinder ty b) (TypedBinder ty' b') =
- (==) ty ty' && (==) b b'
- (==) TypedBinder{} _ = False
+ NullBinder == NullBinder =
+ True
+ (LiteralBinder _ lb) == (LiteralBinder _ lb') =
+ lb == lb'
+ (VarBinder _ ident) == (VarBinder _ ident') =
+ ident == ident'
+ (ConstructorBinder _ qpc bs) == (ConstructorBinder _ qpc' bs') =
+ qpc == qpc' && bs == bs'
+ (OpBinder _ qov) == (OpBinder _ qov') =
+ qov == qov'
+ (BinaryNoParensBinder b1 b2 b3) == (BinaryNoParensBinder b1' b2' b3') =
+ b1 == b1' && b2 == b2' && b3 == b3'
+ (ParensInBinder b) == (ParensInBinder b') =
+ b == b'
+ (NamedBinder _ ident b) == (NamedBinder _ ident' b') =
+ ident == ident' && b == b'
+ (PositionedBinder _ comments b) == (PositionedBinder _ comments' b') =
+ comments == comments' && b == b'
+ (TypedBinder ty b) == (TypedBinder ty' b') =
+ ty == ty' && b == b'
+ _ == _ = False
instance Ord Binder where
compare NullBinder NullBinder = EQ
- compare NullBinder _ = LT
-
- compare (LiteralBinder _ lb) (LiteralBinder _ lb') = compare lb lb'
- compare LiteralBinder{} NullBinder = GT
- compare LiteralBinder{} _ = LT
-
- compare (VarBinder _ ident) (VarBinder _ ident') = compare ident ident'
- compare VarBinder{} NullBinder = GT
- compare VarBinder{} LiteralBinder{} = GT
- compare VarBinder{} _ = LT
-
+ compare (LiteralBinder _ lb) (LiteralBinder _ lb') =
+ compare lb lb'
+ compare (VarBinder _ ident) (VarBinder _ ident') =
+ compare ident ident'
compare (ConstructorBinder _ qpc bs) (ConstructorBinder _ qpc' bs') =
compare qpc qpc' <> compare bs bs'
- compare ConstructorBinder{} NullBinder = GT
- compare ConstructorBinder{} LiteralBinder{} = GT
- compare ConstructorBinder{} VarBinder{} = GT
- compare ConstructorBinder{} _ = LT
-
compare (OpBinder _ qov) (OpBinder _ qov') =
compare qov qov'
- compare OpBinder{} NullBinder = GT
- compare OpBinder{} LiteralBinder{} = GT
- compare OpBinder{} VarBinder{} = GT
- compare OpBinder{} ConstructorBinder{} = GT
- compare OpBinder{} _ = LT
-
compare (BinaryNoParensBinder b1 b2 b3) (BinaryNoParensBinder b1' b2' b3') =
compare b1 b1' <> compare b2 b2' <> compare b3 b3'
- compare BinaryNoParensBinder{} ParensInBinder{} = LT
- compare BinaryNoParensBinder{} NamedBinder{} = LT
- compare BinaryNoParensBinder{} PositionedBinder{} = LT
- compare BinaryNoParensBinder{} TypedBinder{} = LT
- compare BinaryNoParensBinder{} _ = GT
-
compare (ParensInBinder b) (ParensInBinder b') =
compare b b'
- compare ParensInBinder{} NamedBinder{} = LT
- compare ParensInBinder{} PositionedBinder{} = LT
- compare ParensInBinder{} TypedBinder{} = LT
- compare ParensInBinder{} _ = GT
-
compare (NamedBinder _ ident b) (NamedBinder _ ident' b') =
compare ident ident' <> compare b b'
- compare NamedBinder{} PositionedBinder{} = LT
- compare NamedBinder{} TypedBinder{} = LT
- compare NamedBinder{} _ = GT
-
compare (PositionedBinder _ comments b) (PositionedBinder _ comments' b') =
compare comments comments' <> compare b b'
- compare PositionedBinder{} TypedBinder{} = LT
- compare PositionedBinder{} _ = GT
-
compare (TypedBinder ty b) (TypedBinder ty' b') =
compare ty ty' <> compare b b'
- compare TypedBinder{} _ = GT
+ compare binder binder' =
+ compare (orderOf binder) (orderOf binder')
+ where
+ orderOf :: Binder -> Int
+ orderOf NullBinder = 0
+ orderOf LiteralBinder{} = 1
+ orderOf VarBinder{} = 2
+ orderOf ConstructorBinder{} = 3
+ orderOf OpBinder{} = 4
+ orderOf BinaryNoParensBinder{} = 5
+ orderOf ParensInBinder{} = 6
+ orderOf NamedBinder{} = 7
+ orderOf PositionedBinder{} = 8
+ orderOf TypedBinder{} = 9
-- |
-- Collect all names introduced in binders in an expression
--
binderNames :: Binder -> [Ident]
-binderNames = go []
+binderNames = map snd . binderNamesWithSpans
+
+binderNamesWithSpans :: Binder -> [(SourceSpan, Ident)]
+binderNamesWithSpans = go []
where
go ns (LiteralBinder _ b) = lit ns b
- go ns (VarBinder _ name) = name : ns
+ go ns (VarBinder ss name) = (ss, name) : ns
go ns (ConstructorBinder _ _ bs) = foldl go ns bs
go ns (BinaryNoParensBinder b1 b2 b3) = foldl go ns [b1, b2, b3]
go ns (ParensInBinder b) = go ns b
- go ns (NamedBinder _ name b) = go (name : ns) b
+ go ns (NamedBinder ss name b) = go ((ss, name) : ns) b
go ns (PositionedBinder _ _ b) = go ns b
go ns (TypedBinder _ b) = go ns b
go ns _ = ns
@@ -185,6 +153,7 @@ binderNames = go []
lit ns (ArrayLiteral bs) = foldl go ns bs
lit ns _ = ns
+
isIrrefutable :: Binder -> Bool
isIrrefutable NullBinder = True
isIrrefutable (VarBinder _ _) = True
diff --git a/src/Language/PureScript/AST/Declarations.hs b/src/Language/PureScript/AST/Declarations.hs
index 4de31e2565..cf0c83a42d 100644
--- a/src/Language/PureScript/AST/Declarations.hs
+++ b/src/Language/PureScript/AST/Declarations.hs
@@ -1,43 +1,38 @@
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE DeriveFoldable #-}
-{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DeriveAnyClass #-}
+{-# LANGUAGE TemplateHaskell #-}
-- |
-- Data types for modules and declarations
--
module Language.PureScript.AST.Declarations where
-import Prelude.Compat
+import Prelude
+import Protolude.Exceptions (hush)
+import Codec.Serialise (Serialise)
import Control.DeepSeq (NFData)
-import Control.Monad.Identity
+import Data.Functor.Identity (Identity(..))
-import Data.Aeson.TH
-import qualified Data.Map as M
-import Data.Set (Set)
+import Data.Aeson.TH (Options(..), SumEncoding(..), defaultOptions, deriveJSON)
+import Data.Map qualified as M
import Data.Text (Text)
-import qualified Data.List.NonEmpty as NEL
+import Data.List.NonEmpty qualified as NEL
import GHC.Generics (Generic)
-import Language.PureScript.AST.Binders
-import Language.PureScript.AST.Literals
-import Language.PureScript.AST.Operators
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Types
+import Language.PureScript.AST.Binders (Binder)
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.AST.Operators (Fixity)
+import Language.PureScript.AST.SourcePos (SourceAnn, SourceSpan)
+import Language.PureScript.AST.Declarations.ChainId (ChainId)
+import Language.PureScript.Types (SourceConstraint, SourceType)
import Language.PureScript.PSString (PSString)
import Language.PureScript.Label (Label)
-import Language.PureScript.Names
-import Language.PureScript.Kinds
-import Language.PureScript.TypeClassDictionaries
-import Language.PureScript.Comments
-import Language.PureScript.Environment
-import qualified Language.PureScript.Bundle as Bundle
-import qualified Language.PureScript.Constants as C
-import qualified Language.PureScript.CST.Errors as CST
-
-import qualified Text.Parsec as P
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName(..), Name(..), OpName, OpNameType(..), ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), toMaybeModuleName)
+import Language.PureScript.Roles (Role)
+import Language.PureScript.TypeClassDictionaries (NamedDict)
+import Language.PureScript.Comments (Comment)
+import Language.PureScript.Environment (DataDeclType, Environment, FunctionalDependency, NameKind)
+import Language.PureScript.Constants.Prim qualified as C
-- | A map of locally-bound names in scope.
type Context = [(Ident, SourceType)]
@@ -47,15 +42,15 @@ data TypeSearch
= TSBefore Environment
-- ^ An Environment captured for later consumption by type directed search
| TSAfter
+ -- ^ Results of applying type directed search to the previously captured
+ -- Environment
{ tsAfterIdentifiers :: [(Qualified Text, SourceType)]
-- ^ The identifiers that fully satisfy the subsumption check
, tsAfterRecordFields :: Maybe [(Label, SourceType)]
-- ^ Record fields that are available on the first argument to the typed
-- hole
}
- -- ^ Results of applying type directed search to the previously captured
- -- Environment
- deriving Show
+ deriving (Show, Generic, NFData)
onTypeSearchTypes :: (SourceType -> SourceType) -> TypeSearch -> TypeSearch
onTypeSearchTypes f = runIdentity . onTypeSearchTypesM (Identity . f)
@@ -64,124 +59,6 @@ onTypeSearchTypesM :: (Applicative m) => (SourceType -> m SourceType) -> TypeSea
onTypeSearchTypesM f (TSAfter i r) = TSAfter <$> traverse (traverse f) i <*> traverse (traverse (traverse f)) r
onTypeSearchTypesM _ (TSBefore env) = pure (TSBefore env)
--- | A type of error messages
-data SimpleErrorMessage
- = ModuleNotFound ModuleName
- | ErrorParsingFFIModule FilePath (Maybe Bundle.ErrorMessage)
- | ErrorParsingModule P.ParseError
- | ErrorParsingCSTModule CST.ParserError
- | MissingFFIModule ModuleName
- | UnnecessaryFFIModule ModuleName FilePath
- | MissingFFIImplementations ModuleName [Ident]
- | UnusedFFIImplementations ModuleName [Ident]
- | InvalidFFIIdentifier ModuleName Text
- | CannotGetFileInfo FilePath
- | CannotReadFile FilePath
- | CannotWriteFile FilePath
- | InfiniteType SourceType
- | InfiniteKind SourceKind
- | MultipleValueOpFixities (OpName 'ValueOpName)
- | MultipleTypeOpFixities (OpName 'TypeOpName)
- | OrphanTypeDeclaration Ident
- | RedefinedIdent Ident
- | OverlappingNamesInLet
- | UnknownName (Qualified Name)
- | UnknownImport ModuleName Name
- | UnknownImportDataConstructor ModuleName (ProperName 'TypeName) (ProperName 'ConstructorName)
- | UnknownExport Name
- | UnknownExportDataConstructor (ProperName 'TypeName) (ProperName 'ConstructorName)
- | ScopeConflict Name [ModuleName]
- | ScopeShadowing Name (Maybe ModuleName) [ModuleName]
- | DeclConflict Name Name
- | ExportConflict (Qualified Name) (Qualified Name)
- | DuplicateModule ModuleName
- | DuplicateTypeClass (ProperName 'ClassName) SourceSpan
- | DuplicateInstance Ident SourceSpan
- | DuplicateTypeArgument Text
- | InvalidDoBind
- | InvalidDoLet
- | CycleInDeclaration Ident
- | CycleInTypeSynonym (Maybe (ProperName 'TypeName))
- | CycleInTypeClassDeclaration [Qualified (ProperName 'ClassName)]
- | CycleInModules [ModuleName]
- | NameIsUndefined Ident
- | UndefinedTypeVariable (ProperName 'TypeName)
- | PartiallyAppliedSynonym (Qualified (ProperName 'TypeName))
- | EscapedSkolem Text (Maybe SourceSpan) SourceType
- | TypesDoNotUnify SourceType SourceType
- | KindsDoNotUnify SourceKind SourceKind
- | ConstrainedTypeUnified SourceType SourceType
- | OverlappingInstances (Qualified (ProperName 'ClassName)) [SourceType] [Qualified Ident]
- | NoInstanceFound SourceConstraint
- | AmbiguousTypeVariables SourceType SourceConstraint
- | UnknownClass (Qualified (ProperName 'ClassName))
- | PossiblyInfiniteInstance (Qualified (ProperName 'ClassName)) [SourceType]
- | CannotDerive (Qualified (ProperName 'ClassName)) [SourceType]
- | InvalidDerivedInstance (Qualified (ProperName 'ClassName)) [SourceType] Int
- | ExpectedTypeConstructor (Qualified (ProperName 'ClassName)) [SourceType] SourceType
- | InvalidNewtypeInstance (Qualified (ProperName 'ClassName)) [SourceType]
- | MissingNewtypeSuperclassInstance (Qualified (ProperName 'ClassName)) (Qualified (ProperName 'ClassName)) [SourceType]
- | UnverifiableSuperclassInstance (Qualified (ProperName 'ClassName)) (Qualified (ProperName 'ClassName)) [SourceType]
- | CannotFindDerivingType (ProperName 'TypeName)
- | DuplicateLabel Label (Maybe Expr)
- | DuplicateValueDeclaration Ident
- | ArgListLengthsDiffer Ident
- | OverlappingArgNames (Maybe Ident)
- | MissingClassMember (NEL.NonEmpty (Ident, SourceType))
- | ExtraneousClassMember Ident (Qualified (ProperName 'ClassName))
- | ExpectedType SourceType SourceKind
- -- | constructor name, expected argument count, actual argument count
- | IncorrectConstructorArity (Qualified (ProperName 'ConstructorName)) Int Int
- | ExprDoesNotHaveType Expr SourceType
- | PropertyIsMissing Label
- | AdditionalProperty Label
- | TypeSynonymInstance
- | OrphanInstance Ident (Qualified (ProperName 'ClassName)) (Set ModuleName) [SourceType]
- | InvalidNewtype (ProperName 'TypeName)
- | InvalidInstanceHead SourceType
- | TransitiveExportError DeclarationRef [DeclarationRef]
- | TransitiveDctorExportError DeclarationRef (ProperName 'ConstructorName)
- | ShadowedName Ident
- | ShadowedTypeVar Text
- | UnusedTypeVar Text
- | WildcardInferredType SourceType Context
- | HoleInferredType Text SourceType Context (Maybe TypeSearch)
- | MissingTypeDeclaration Ident SourceType
- | OverlappingPattern [[Binder]] Bool
- | IncompleteExhaustivityCheck
- | MisleadingEmptyTypeImport ModuleName (ProperName 'TypeName)
- | ImportHidingModule ModuleName
- | UnusedImport ModuleName
- | UnusedExplicitImport ModuleName [Name] (Maybe ModuleName) [DeclarationRef]
- | UnusedDctorImport ModuleName (ProperName 'TypeName) (Maybe ModuleName) [DeclarationRef]
- | UnusedDctorExplicitImport ModuleName (ProperName 'TypeName) [ProperName 'ConstructorName] (Maybe ModuleName) [DeclarationRef]
- | DuplicateSelectiveImport ModuleName
- | DuplicateImport ModuleName ImportDeclarationType (Maybe ModuleName)
- | DuplicateImportRef Name
- | DuplicateExportRef Name
- | IntOutOfRange Integer Text Integer Integer
- | ImplicitQualifiedImport ModuleName ModuleName [DeclarationRef]
- | ImplicitQualifiedImportReExport ModuleName ModuleName [DeclarationRef]
- | ImplicitImport ModuleName [DeclarationRef]
- | HidingImport ModuleName [DeclarationRef]
- | CaseBinderLengthDiffers Int [Binder]
- | IncorrectAnonymousArgument
- | InvalidOperatorInBinder (Qualified (OpName 'ValueOpName)) (Qualified Ident)
- | CannotGeneralizeRecursiveFunction Ident SourceType
- | CannotDeriveNewtypeForData (ProperName 'TypeName)
- | ExpectedWildcard (ProperName 'TypeName)
- | CannotUseBindWithDo Ident
- -- | instance name, type class, expected argument count, actual argument count
- | ClassInstanceArityMismatch Ident (Qualified (ProperName 'ClassName)) Int Int
- -- | a user-defined warning raised by using the Warn type class
- | UserDefinedWarning SourceType
- -- | a declaration couldn't be used because it contained free variables
- | UnusableDeclaration Ident [[Text]]
- | CannotDefinePrimModules ModuleName
- | MixedAssociativityError (NEL.NonEmpty (Qualified (OpName 'AnyOpName), Associativity))
- | NonAssociativeError (NEL.NonEmpty (Qualified (OpName 'AnyOpName)))
- deriving (Show)
-
-- | Error message hints, providing more detailed information about failure.
data ErrorMessageHint
= ErrorUnifyingTypes SourceType SourceType
@@ -189,11 +66,13 @@ data ErrorMessageHint
| ErrorInModule ModuleName
| ErrorInInstance (Qualified (ProperName 'ClassName)) [SourceType]
| ErrorInSubsumption SourceType SourceType
+ | ErrorInRowLabel Label
| ErrorCheckingAccessor Expr PSString
| ErrorCheckingType Expr SourceType
- | ErrorCheckingKind SourceType
+ | ErrorCheckingKind SourceType SourceType
| ErrorCheckingGuard
| ErrorInferringType Expr
+ | ErrorInferringKind SourceType
| ErrorInApplication Expr SourceType Expr
| ErrorInDataConstructor (ProperName 'ConstructorName)
| ErrorInTypeConstructor (ProperName 'TypeName)
@@ -203,10 +82,15 @@ data ErrorMessageHint
| ErrorInValueDeclaration Ident
| ErrorInTypeDeclaration Ident
| ErrorInTypeClassDeclaration (ProperName 'ClassName)
+ | ErrorInKindDeclaration (ProperName 'TypeName)
+ | ErrorInRoleDeclaration (ProperName 'TypeName)
| ErrorInForeignImport Ident
+ | ErrorInForeignImportData (ProperName 'TypeName)
| ErrorSolvingConstraint SourceConstraint
+ | MissingConstructorImportForCoercible (Qualified (ProperName 'ConstructorName))
| PositionedError (NEL.NonEmpty SourceSpan)
- deriving (Show)
+ | RelatedPositions (NEL.NonEmpty SourceSpan)
+ deriving (Show, Generic, NFData)
-- | Categories of hints
data HintCategory
@@ -215,13 +99,20 @@ data HintCategory
| CheckHint
| PositionHint
| SolverHint
+ | DeclarationHint
| OtherHint
deriving (Show, Eq)
-data ErrorMessage = ErrorMessage
- [ErrorMessageHint]
- SimpleErrorMessage
- deriving (Show)
+-- |
+-- In constraint solving, indicates whether there were `TypeUnknown`s that prevented
+-- an instance from being found, and whether VTAs are required
+-- due to type class members not referencing all the type class
+-- head's type variables.
+data UnknownsHint
+ = NoUnknowns
+ | Unknowns
+ | UnknownsWithVtaRequiringArgs (NEL.NonEmpty (Qualified Ident, [[Text]]))
+ deriving (Show, Generic, NFData)
-- |
-- A module declaration, consisting of comments about the module, a module name,
@@ -252,13 +143,15 @@ getModuleDeclarations (Module _ _ _ declarations _) = declarations
addDefaultImport :: Qualified ModuleName -> Module -> Module
addDefaultImport (Qualified toImportAs toImport) m@(Module ss coms mn decls exps) =
if isExistingImport `any` decls || mn == toImport then m
- else Module ss coms mn (ImportDeclaration (ss, []) toImport Implicit toImportAs : decls) exps
+ else Module ss coms mn (ImportDeclaration (ss, []) toImport Implicit toImportAs' : decls) exps
where
+ toImportAs' = toMaybeModuleName toImportAs
+
isExistingImport (ImportDeclaration _ mn' _ as')
| mn' == toImport =
- case toImportAs of
+ case toImportAs' of
Nothing -> True
- _ -> as' == toImportAs
+ _ -> as' == toImportAs'
isExistingImport _ = False
-- | Adds import declarations to a module for an implicit Prim import and Prim
@@ -266,24 +159,31 @@ addDefaultImport (Qualified toImportAs toImport) m@(Module ss coms mn decls exps
importPrim :: Module -> Module
importPrim =
let
- primModName = C.Prim
+ primModName = C.M_Prim
in
- addDefaultImport (Qualified (Just primModName) primModName)
- . addDefaultImport (Qualified Nothing primModName)
+ addDefaultImport (Qualified (ByModuleName primModName) primModName)
+ . addDefaultImport (Qualified ByNullSourcePos primModName)
+
+data NameSource = UserNamed | CompilerNamed
+ deriving (Show, Generic, NFData, Serialise)
-- |
-- An item in a list of explicit imports or exports
--
data DeclarationRef
-- |
- -- A type constructor with data constructors
+ -- A type class
--
- = TypeRef SourceSpan (ProperName 'TypeName) (Maybe [ProperName 'ConstructorName])
+ = TypeClassRef SourceSpan (ProperName 'ClassName)
-- |
-- A type operator
--
| TypeOpRef SourceSpan (OpName 'TypeOpName)
-- |
+ -- A type constructor with data constructors
+ --
+ | TypeRef SourceSpan (ProperName 'TypeName) (Maybe [ProperName 'ConstructorName])
+ -- |
-- A value
--
| ValueRef SourceSpan Ident
@@ -292,71 +192,59 @@ data DeclarationRef
--
| ValueOpRef SourceSpan (OpName 'ValueOpName)
-- |
- -- A type class
- --
- | TypeClassRef SourceSpan (ProperName 'ClassName)
- -- |
- -- A type class instance, created during typeclass desugaring (name, class name, instance types)
+ -- A type class instance, created during typeclass desugaring
--
- | TypeInstanceRef SourceSpan Ident
+ | TypeInstanceRef SourceSpan Ident NameSource
-- |
-- A module, in its entirety
--
| ModuleRef SourceSpan ModuleName
-- |
- -- A named kind
- --
- | KindRef SourceSpan (ProperName 'KindName)
- -- |
-- A value re-exported from another module. These will be inserted during
-- elaboration in name desugaring.
--
| ReExportRef SourceSpan ExportSource DeclarationRef
- deriving (Show, Generic, NFData)
+ deriving (Show, Generic, NFData, Serialise)
instance Eq DeclarationRef where
- (TypeRef _ name dctors) == (TypeRef _ name' dctors') = name == name' && dctors == dctors'
+ (TypeClassRef _ name) == (TypeClassRef _ name') = name == name'
(TypeOpRef _ name) == (TypeOpRef _ name') = name == name'
+ (TypeRef _ name dctors) == (TypeRef _ name' dctors') = name == name' && dctors == dctors'
(ValueRef _ name) == (ValueRef _ name') = name == name'
(ValueOpRef _ name) == (ValueOpRef _ name') = name == name'
- (TypeClassRef _ name) == (TypeClassRef _ name') = name == name'
- (TypeInstanceRef _ name) == (TypeInstanceRef _ name') = name == name'
+ (TypeInstanceRef _ name _) == (TypeInstanceRef _ name' _) = name == name'
(ModuleRef _ name) == (ModuleRef _ name') = name == name'
- (KindRef _ name) == (KindRef _ name') = name == name'
(ReExportRef _ mn ref) == (ReExportRef _ mn' ref') = mn == mn' && ref == ref'
_ == _ = False
+instance Ord DeclarationRef where
+ TypeClassRef _ name `compare` TypeClassRef _ name' = compare name name'
+ TypeOpRef _ name `compare` TypeOpRef _ name' = compare name name'
+ TypeRef _ name dctors `compare` TypeRef _ name' dctors' = compare name name' <> compare dctors dctors'
+ ValueRef _ name `compare` ValueRef _ name' = compare name name'
+ ValueOpRef _ name `compare` ValueOpRef _ name' = compare name name'
+ TypeInstanceRef _ name _ `compare` TypeInstanceRef _ name' _ = compare name name'
+ ModuleRef _ name `compare` ModuleRef _ name' = compare name name'
+ ReExportRef _ mn ref `compare` ReExportRef _ mn' ref' = compare mn mn' <> compare ref ref'
+ compare ref ref' =
+ compare (orderOf ref) (orderOf ref')
+ where
+ orderOf :: DeclarationRef -> Int
+ orderOf TypeClassRef{} = 0
+ orderOf TypeOpRef{} = 1
+ orderOf TypeRef{} = 2
+ orderOf ValueRef{} = 3
+ orderOf ValueOpRef{} = 4
+ orderOf TypeInstanceRef{} = 5
+ orderOf ModuleRef{} = 6
+ orderOf ReExportRef{} = 7
+
data ExportSource =
ExportSource
{ exportSourceImportedFrom :: Maybe ModuleName
, exportSourceDefinedIn :: ModuleName
}
- deriving (Eq, Ord, Show, Generic, NFData)
-
--- enable sorting lists of explicitly imported refs when suggesting imports in linting, IDE, etc.
--- not an Ord because this implementation is not consistent with its Eq instance.
--- think of it as a notion of contextual, not inherent, ordering.
-compDecRef :: DeclarationRef -> DeclarationRef -> Ordering
-compDecRef (TypeRef _ name _) (TypeRef _ name' _) = compare name name'
-compDecRef (TypeOpRef _ name) (TypeOpRef _ name') = compare name name'
-compDecRef (ValueRef _ ident) (ValueRef _ ident') = compare ident ident'
-compDecRef (ValueOpRef _ name) (ValueOpRef _ name') = compare name name'
-compDecRef (TypeClassRef _ name) (TypeClassRef _ name') = compare name name'
-compDecRef (TypeInstanceRef _ ident) (TypeInstanceRef _ ident') = compare ident ident'
-compDecRef (ModuleRef _ name) (ModuleRef _ name') = compare name name'
-compDecRef (KindRef _ name) (KindRef _ name') = compare name name'
-compDecRef (ReExportRef _ name _) (ReExportRef _ name' _) = compare name name'
-compDecRef ref ref' = compare
- (orderOf ref) (orderOf ref')
- where
- orderOf :: DeclarationRef -> Int
- orderOf TypeClassRef{} = 0
- orderOf TypeOpRef{} = 1
- orderOf TypeRef{} = 2
- orderOf ValueRef{} = 3
- orderOf ValueOpRef{} = 4
- orderOf KindRef{} = 5
- orderOf _ = 6
+ deriving (Eq, Ord, Show, Generic, NFData, Serialise)
declRefSourceSpan :: DeclarationRef -> SourceSpan
declRefSourceSpan (TypeRef ss _ _) = ss
@@ -364,9 +252,8 @@ declRefSourceSpan (TypeOpRef ss _) = ss
declRefSourceSpan (ValueRef ss _) = ss
declRefSourceSpan (ValueOpRef ss _) = ss
declRefSourceSpan (TypeClassRef ss _) = ss
-declRefSourceSpan (TypeInstanceRef ss _) = ss
+declRefSourceSpan (TypeInstanceRef ss _ _) = ss
declRefSourceSpan (ModuleRef ss _) = ss
-declRefSourceSpan (KindRef ss _) = ss
declRefSourceSpan (ReExportRef ss _ _) = ss
declRefName :: DeclarationRef -> Name
@@ -375,9 +262,8 @@ declRefName (TypeOpRef _ n) = TyOpName n
declRefName (ValueRef _ n) = IdentName n
declRefName (ValueOpRef _ n) = ValOpName n
declRefName (TypeClassRef _ n) = TyClassName n
-declRefName (TypeInstanceRef _ n) = IdentName n
+declRefName (TypeInstanceRef _ n _) = IdentName n
declRefName (ModuleRef _ n) = ModName n
-declRefName (KindRef _ n) = KiName n
declRefName (ReExportRef _ _ ref) = declRefName ref
getTypeRef :: DeclarationRef -> Maybe (ProperName 'TypeName, Maybe [ProperName 'ConstructorName])
@@ -400,10 +286,6 @@ getTypeClassRef :: DeclarationRef -> Maybe (ProperName 'ClassName)
getTypeClassRef (TypeClassRef _ name) = Just name
getTypeClassRef _ = Nothing
-getKindRef :: DeclarationRef -> Maybe (ProperName 'KindName)
-getKindRef (KindRef _ name) = Just name
-getKindRef _ = Nothing
-
isModuleRef :: DeclarationRef -> Bool
isModuleRef ModuleRef{} = True
isModuleRef _ = False
@@ -424,16 +306,25 @@ data ImportDeclarationType
-- An import with a list of references to hide: `import M hiding (foo)`
--
| Hiding [DeclarationRef]
- deriving (Eq, Show)
-
-isImplicit :: ImportDeclarationType -> Bool
-isImplicit Implicit = True
-isImplicit _ = False
+ deriving (Eq, Show, Generic, Serialise, NFData)
isExplicit :: ImportDeclarationType -> Bool
isExplicit (Explicit _) = True
isExplicit _ = False
+-- | A role declaration assigns a list of roles to a type constructor's
+-- parameters, e.g.:
+--
+-- @type role T representational phantom@
+--
+-- In this example, @T@ is the identifier and @[representational, phantom]@ is
+-- the list of roles (@T@ presumably having two parameters).
+data RoleDeclarationData = RoleDeclarationData
+ { rdeclSourceAnn :: !SourceAnn
+ , rdeclIdent :: !(ProperName 'TypeName)
+ , rdeclRoles :: ![Role]
+ } deriving (Show, Eq, Generic, NFData)
+
-- | A type declaration assigns a type to an identifier, eg:
--
-- @identity :: forall a. a -> a@
@@ -443,10 +334,7 @@ data TypeDeclarationData = TypeDeclarationData
{ tydeclSourceAnn :: !SourceAnn
, tydeclIdent :: !Ident
, tydeclType :: !SourceType
- } deriving (Show, Eq)
-
-overTypeDeclaration :: (TypeDeclarationData -> TypeDeclarationData) -> Declaration -> Declaration
-overTypeDeclaration f d = maybe d (TypeDeclaration . f) (getTypeDeclaration d)
+ } deriving (Show, Eq, Generic, NFData)
getTypeDeclaration :: Declaration -> Maybe TypeDeclarationData
getTypeDeclaration (TypeDeclaration d) = Just d
@@ -468,10 +356,7 @@ data ValueDeclarationData a = ValueDeclarationData
-- ^ Whether or not this value is exported/visible
, valdeclBinders :: ![Binder]
, valdeclExpression :: !a
- } deriving (Show, Functor, Foldable, Traversable)
-
-overValueDeclaration :: (ValueDeclarationData [GuardedExpr] -> ValueDeclarationData [GuardedExpr]) -> Declaration -> Declaration
-overValueDeclaration f d = maybe d (ValueDeclaration . f) (getValueDeclaration d)
+ } deriving (Show, Functor, Generic, NFData, Foldable, Traversable)
getValueDeclaration :: Declaration -> Maybe (ValueDeclarationData [GuardedExpr])
getValueDeclaration (ValueDeclaration d) = Just d
@@ -481,6 +366,18 @@ pattern ValueDecl :: SourceAnn -> Ident -> NameKind -> [Binder] -> [GuardedExpr]
pattern ValueDecl sann ident name binders expr
= ValueDeclaration (ValueDeclarationData sann ident name binders expr)
+data DataConstructorDeclaration = DataConstructorDeclaration
+ { dataCtorAnn :: !SourceAnn
+ , dataCtorName :: !(ProperName 'ConstructorName)
+ , dataCtorFields :: ![(Ident, SourceType)]
+ } deriving (Show, Eq, Generic, NFData)
+
+mapDataCtorFields :: ([(Ident, SourceType)] -> [(Ident, SourceType)]) -> DataConstructorDeclaration -> DataConstructorDeclaration
+mapDataCtorFields f DataConstructorDeclaration{..} = DataConstructorDeclaration { dataCtorFields = f dataCtorFields, .. }
+
+traverseDataCtorFields :: Monad m => ([(Ident, SourceType)] -> m [(Ident, SourceType)]) -> DataConstructorDeclaration -> m DataConstructorDeclaration
+traverseDataCtorFields f DataConstructorDeclaration{..} = DataConstructorDeclaration dataCtorAnn dataCtorName <$> f dataCtorFields
+
-- |
-- The data type of declarations
--
@@ -488,7 +385,7 @@ data Declaration
-- |
-- A data type declaration (data or newtype, name, arguments, data constructors)
--
- = DataDeclaration SourceAnn DataDeclType (ProperName 'TypeName) [(Text, Maybe SourceKind)] [(ProperName 'ConstructorName, [(Ident, SourceType)])]
+ = DataDeclaration SourceAnn DataDeclType (ProperName 'TypeName) [(Text, Maybe SourceType)] [DataConstructorDeclaration]
-- |
-- A minimal mutually recursive set of data type declarations
--
@@ -496,7 +393,15 @@ data Declaration
-- |
-- A type synonym declaration (name, arguments, type)
--
- | TypeSynonymDeclaration SourceAnn (ProperName 'TypeName) [(Text, Maybe SourceKind)] SourceType
+ | TypeSynonymDeclaration SourceAnn (ProperName 'TypeName) [(Text, Maybe SourceType)] SourceType
+ -- |
+ -- A kind signature declaration
+ --
+ | KindDeclaration SourceAnn KindSignatureFor (ProperName 'TypeName) SourceType
+ -- |
+ -- A role declaration (name, roles)
+ --
+ | RoleDeclaration {-# UNPACK #-} !RoleDeclarationData
-- |
-- A type declaration for a value (name, ty)
--
@@ -519,11 +424,7 @@ data Declaration
-- |
-- A data type foreign import (name, kind)
--
- | ExternDataDeclaration SourceAnn (ProperName 'TypeName) SourceKind
- -- |
- -- A foreign kind import (name)
- --
- | ExternKindDeclaration SourceAnn (ProperName 'KindName)
+ | ExternDataDeclaration SourceAnn (ProperName 'TypeName) SourceType
-- |
-- A fixity declaration
--
@@ -535,19 +436,22 @@ data Declaration
-- |
-- A type class declaration (name, argument, implies, member declarations)
--
- | TypeClassDeclaration SourceAnn (ProperName 'ClassName) [(Text, Maybe SourceKind)] [SourceConstraint] [FunctionalDependency] [Declaration]
+ | TypeClassDeclaration SourceAnn (ProperName 'ClassName) [(Text, Maybe SourceType)] [SourceConstraint] [FunctionalDependency] [Declaration]
-- |
-- A type instance declaration (instance chain, chain index, name,
-- dependencies, class name, instance types, member declarations)
--
- | TypeInstanceDeclaration SourceAnn [Ident] Integer Ident [SourceConstraint] (Qualified (ProperName 'ClassName)) [SourceType] TypeInstanceBody
- deriving (Show)
+ -- The first @SourceAnn@ serves as the annotation for the entire
+ -- declaration, while the second @SourceAnn@ serves as the
+ -- annotation for the type class and its arguments.
+ | TypeInstanceDeclaration SourceAnn SourceAnn ChainId Integer (Either Text Ident) [SourceConstraint] (Qualified (ProperName 'ClassName)) [SourceType] TypeInstanceBody
+ deriving (Show, Generic, NFData)
data ValueFixity = ValueFixity Fixity (Qualified (Either Ident (ProperName 'ConstructorName))) (OpName 'ValueOpName)
- deriving (Eq, Ord, Show)
+ deriving (Eq, Ord, Show, Generic, NFData)
data TypeFixity = TypeFixity Fixity (Qualified (ProperName 'TypeName)) (OpName 'TypeOpName)
- deriving (Eq, Ord, Show)
+ deriving (Eq, Ord, Show, Generic, NFData)
pattern ValueFixityDeclaration :: SourceAnn -> Fixity -> Qualified (Either Ident (ProperName 'ConstructorName)) -> OpName 'ValueOpName -> Declaration
pattern ValueFixityDeclaration sa fixity name op = FixityDeclaration sa (Left (ValueFixity fixity name op))
@@ -555,18 +459,20 @@ pattern ValueFixityDeclaration sa fixity name op = FixityDeclaration sa (Left (V
pattern TypeFixityDeclaration :: SourceAnn -> Fixity -> Qualified (ProperName 'TypeName) -> OpName 'TypeOpName -> Declaration
pattern TypeFixityDeclaration sa fixity name op = FixityDeclaration sa (Right (TypeFixity fixity name op))
+data InstanceDerivationStrategy
+ = KnownClassStrategy
+ | NewtypeStrategy
+ deriving (Show, Generic, NFData)
+
-- | The members of a type class instance declaration
data TypeInstanceBody
= DerivedInstance
-- ^ This is a derived instance
| NewtypeInstance
-- ^ This is an instance derived from a newtype
- | NewtypeInstanceWithDictionary Expr
- -- ^ This is an instance derived from a newtype, desugared to include a
- -- dictionary for the type under the newtype.
| ExplicitInstance [Declaration]
-- ^ This is a regular (explicit) instance
- deriving (Show)
+ deriving (Show, Generic, NFData)
mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
@@ -576,40 +482,53 @@ traverseTypeInstanceBody :: (Applicative f) => ([Declaration] -> f [Declaration]
traverseTypeInstanceBody f (ExplicitInstance ds) = ExplicitInstance <$> f ds
traverseTypeInstanceBody _ other = pure other
+-- | What sort of declaration the kind signature applies to.
+data KindSignatureFor
+ = DataSig
+ | NewtypeSig
+ | TypeSynonymSig
+ | ClassSig
+ deriving (Eq, Ord, Show, Generic, NFData)
+
declSourceAnn :: Declaration -> SourceAnn
declSourceAnn (DataDeclaration sa _ _ _ _) = sa
declSourceAnn (DataBindingGroupDeclaration ds) = declSourceAnn (NEL.head ds)
declSourceAnn (TypeSynonymDeclaration sa _ _ _) = sa
+declSourceAnn (KindDeclaration sa _ _ _) = sa
+declSourceAnn (RoleDeclaration rd) = rdeclSourceAnn rd
declSourceAnn (TypeDeclaration td) = tydeclSourceAnn td
declSourceAnn (ValueDeclaration vd) = valdeclSourceAnn vd
declSourceAnn (BoundValueDeclaration sa _ _) = sa
declSourceAnn (BindingGroupDeclaration ds) = let ((sa, _), _, _) = NEL.head ds in sa
declSourceAnn (ExternDeclaration sa _ _) = sa
declSourceAnn (ExternDataDeclaration sa _ _) = sa
-declSourceAnn (ExternKindDeclaration sa _) = sa
declSourceAnn (FixityDeclaration sa _) = sa
declSourceAnn (ImportDeclaration sa _ _ _) = sa
declSourceAnn (TypeClassDeclaration sa _ _ _ _ _) = sa
-declSourceAnn (TypeInstanceDeclaration sa _ _ _ _ _ _ _) = sa
+declSourceAnn (TypeInstanceDeclaration sa _ _ _ _ _ _ _ _) = sa
declSourceSpan :: Declaration -> SourceSpan
declSourceSpan = fst . declSourceAnn
+-- Note: Kind Declarations' names can refer to either a `TyClassName`
+-- or a `TypeName`. Use a helper function for handling `KindDeclaration`s
+-- specifically in the context in which it is needed.
declName :: Declaration -> Maybe Name
declName (DataDeclaration _ _ n _ _) = Just (TyName n)
declName (TypeSynonymDeclaration _ n _ _) = Just (TyName n)
declName (ValueDeclaration vd) = Just (IdentName (valdeclIdent vd))
declName (ExternDeclaration _ n _) = Just (IdentName n)
declName (ExternDataDeclaration _ n _) = Just (TyName n)
-declName (ExternKindDeclaration _ n) = Just (KiName n)
declName (FixityDeclaration _ (Left (ValueFixity _ _ n))) = Just (ValOpName n)
declName (FixityDeclaration _ (Right (TypeFixity _ _ n))) = Just (TyOpName n)
declName (TypeClassDeclaration _ n _ _ _ _) = Just (TyClassName n)
-declName (TypeInstanceDeclaration _ _ _ n _ _ _ _) = Just (IdentName n)
+declName (TypeInstanceDeclaration _ _ _ _ n _ _ _ _) = IdentName <$> hush n
+declName (RoleDeclaration RoleDeclarationData{..}) = Just (TyName rdeclIdent)
declName ImportDeclaration{} = Nothing
declName BindingGroupDeclaration{} = Nothing
declName DataBindingGroupDeclaration{} = Nothing
declName BoundValueDeclaration{} = Nothing
+declName KindDeclaration{} = Nothing
declName TypeDeclaration{} = Nothing
-- |
@@ -620,13 +539,19 @@ isValueDecl ValueDeclaration{} = True
isValueDecl _ = False
-- |
--- Test if a declaration is a data type or type synonym declaration
+-- Test if a declaration is a data type declaration
--
isDataDecl :: Declaration -> Bool
isDataDecl DataDeclaration{} = True
-isDataDecl TypeSynonymDeclaration{} = True
isDataDecl _ = False
+-- |
+-- Test if a declaration is a type synonym declaration
+--
+isTypeSynonymDecl :: Declaration -> Bool
+isTypeSynonymDecl TypeSynonymDeclaration{} = True
+isTypeSynonymDecl _ = False
+
-- |
-- Test if a declaration is a module import
--
@@ -634,6 +559,13 @@ isImportDecl :: Declaration -> Bool
isImportDecl ImportDeclaration{} = True
isImportDecl _ = False
+-- |
+-- Test if a declaration is a role declaration
+--
+isRoleDecl :: Declaration -> Bool
+isRoleDecl RoleDeclaration{} = True
+isRoleDecl _ = False
+
-- |
-- Test if a declaration is a data type foreign import
--
@@ -641,13 +573,6 @@ isExternDataDecl :: Declaration -> Bool
isExternDataDecl ExternDataDeclaration{} = True
isExternDataDecl _ = False
--- |
--- Test if a declaration is a foreign kind import
---
-isExternKindDecl :: Declaration -> Bool
-isExternKindDecl ExternKindDeclaration{} = True
-isExternKindDecl _ = False
-
-- |
-- Test if a declaration is a fixity declaration
--
@@ -669,16 +594,23 @@ isExternDecl _ = False
-- |
-- Test if a declaration is a type class instance declaration
--
-isTypeClassInstanceDeclaration :: Declaration -> Bool
-isTypeClassInstanceDeclaration TypeInstanceDeclaration{} = True
-isTypeClassInstanceDeclaration _ = False
+isTypeClassInstanceDecl :: Declaration -> Bool
+isTypeClassInstanceDecl TypeInstanceDeclaration{} = True
+isTypeClassInstanceDecl _ = False
-- |
-- Test if a declaration is a type class declaration
--
-isTypeClassDeclaration :: Declaration -> Bool
-isTypeClassDeclaration TypeClassDeclaration{} = True
-isTypeClassDeclaration _ = False
+isTypeClassDecl :: Declaration -> Bool
+isTypeClassDecl TypeClassDeclaration{} = True
+isTypeClassDecl _ = False
+
+-- |
+-- Test if a declaration is a kind signature declaration.
+--
+isKindDecl :: Declaration -> Bool
+isKindDecl KindDeclaration{} = True
+isKindDecl _ = False
-- |
-- Recursively flatten data binding groups in the list of declarations
@@ -693,13 +625,13 @@ flattenDecls = concatMap flattenOne
--
data Guard = ConditionGuard Expr
| PatternGuard Binder Expr
- deriving (Show)
+ deriving (Show, Generic, NFData)
-- |
-- The right hand side of a binder in value declarations
-- and case expressions.
data GuardedExpr = GuardedExpr [Guard] Expr
- deriving (Show)
+ deriving (Show, Generic, NFData)
pattern MkUnguarded :: Expr -> GuardedExpr
pattern MkUnguarded e = GuardedExpr [] e
@@ -753,6 +685,16 @@ data Expr
--
| App Expr Expr
-- |
+ -- A type application (e.g. `f @Int`)
+ --
+ | VisibleTypeApp Expr SourceType
+ -- |
+ -- Hint that an expression is unused.
+ -- This is used to ignore type class dictionaries that are necessarily empty.
+ -- The inner expression lets us solve subgoals before eliminating the whole expression.
+ -- The code gen will render this as `undefined`, regardless of what the inner expression is.
+ | Unused Expr
+ -- |
-- Variable
--
| Var SourceSpan (Qualified Ident)
@@ -791,11 +733,6 @@ data Expr
--
| Ado (Maybe ModuleName) [DoNotationElement] Expr
-- |
- -- An application of a typeclass dictionary constructor. The value should be
- -- an ObjectLiteral.
- --
- | TypeClassDictionaryConstructorApp (Qualified (ProperName 'ClassName)) Expr
- -- |
-- A placeholder for a type class dictionary to be inserted later. At the end of type checking, these
-- placeholders will be replaced with actual expressions representing type classes dictionaries which
-- can be evaluated at runtime. The constructor arguments represent (in order): whether or not to look
@@ -803,17 +740,17 @@ data Expr
-- instance type, and the type class dictionaries in scope.
--
| TypeClassDictionary SourceConstraint
- (M.Map (Maybe ModuleName) (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict))))
+ (M.Map QualifiedBy (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict))))
[ErrorMessageHint]
-- |
- -- A typeclass dictionary accessor, the implementation is left unspecified until CoreFn desugaring.
- --
- | TypeClassDictionaryAccessor (Qualified (ProperName 'ClassName)) Ident
- -- |
-- A placeholder for a superclass dictionary to be turned into a TypeClassDictionary during typechecking
--
| DeferredDictionary (Qualified (ProperName 'ClassName)) [SourceType]
-- |
+ -- A placeholder for a type class instance to be derived during typechecking
+ --
+ | DerivedInstancePlaceholder (Qualified (ProperName 'ClassName)) InstanceDerivationStrategy
+ -- |
-- A placeholder for an anonymous function argument
--
| AnonymousArgument
@@ -825,7 +762,7 @@ data Expr
-- A value with source position information
--
| PositionedValue SourceSpan [Comment] Expr
- deriving (Show)
+ deriving (Show, Generic, NFData)
-- |
-- Metadata that tells where a let binding originated
@@ -839,7 +776,7 @@ data WhereProvenance
-- The let binding was always a let binding
--
| FromLet
- deriving (Show)
+ deriving (Show, Generic, NFData)
-- |
-- An alternative in a case statement
@@ -853,7 +790,7 @@ data CaseAlternative = CaseAlternative
-- The result expression or a collect of guarded expressions
--
, caseAlternativeResult :: [GuardedExpr]
- } deriving (Show)
+ } deriving (Show, Generic, NFData)
-- |
-- A statement in a do-notation block
@@ -875,7 +812,7 @@ data DoNotationElement
-- A do notation element with source position information
--
| PositionedDoNotationElement SourceSpan [Comment] DoNotationElement
- deriving (Show)
+ deriving (Show, Generic, NFData)
-- For a record update such as:
@@ -903,21 +840,29 @@ data DoNotationElement
newtype PathTree t = PathTree (AssocList PSString (PathNode t))
deriving (Show, Eq, Ord, Functor, Foldable, Traversable)
+ deriving newtype NFData
data PathNode t = Leaf t | Branch (PathTree t)
- deriving (Show, Eq, Ord, Functor, Foldable, Traversable)
+ deriving (Show, Eq, Ord, Generic, NFData, Functor, Foldable, Traversable)
newtype AssocList k t = AssocList { runAssocList :: [(k, t)] }
deriving (Show, Eq, Ord, Foldable, Functor, Traversable)
+ deriving newtype NFData
+$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''NameSource)
+$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExportSource)
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''DeclarationRef)
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ImportDeclarationType)
-$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExportSource)
isTrueExpr :: Expr -> Bool
isTrueExpr (Literal _ (BooleanLiteral True)) = True
-isTrueExpr (Var _ (Qualified (Just (ModuleName [ProperName "Prelude"])) (Ident "otherwise"))) = True
-isTrueExpr (Var _ (Qualified (Just (ModuleName [ProperName "Data", ProperName "Boolean"])) (Ident "otherwise"))) = True
+isTrueExpr (Var _ (Qualified (ByModuleName (ModuleName "Prelude")) (Ident "otherwise"))) = True
+isTrueExpr (Var _ (Qualified (ByModuleName (ModuleName "Data.Boolean")) (Ident "otherwise"))) = True
isTrueExpr (TypedValue _ e _) = isTrueExpr e
isTrueExpr (PositionedValue _ _ e) = isTrueExpr e
isTrueExpr _ = False
+
+isAnonymousArgument :: Expr -> Bool
+isAnonymousArgument AnonymousArgument = True
+isAnonymousArgument (PositionedValue _ _ e) = isAnonymousArgument e
+isAnonymousArgument _ = False
diff --git a/src/Language/PureScript/AST/Declarations/ChainId.hs b/src/Language/PureScript/AST/Declarations/ChainId.hs
new file mode 100644
index 0000000000..aacfc11fe8
--- /dev/null
+++ b/src/Language/PureScript/AST/Declarations/ChainId.hs
@@ -0,0 +1,20 @@
+module Language.PureScript.AST.Declarations.ChainId
+ ( ChainId
+ , mkChainId
+ ) where
+
+import Prelude
+import Language.PureScript.AST.SourcePos qualified as Pos
+import Control.DeepSeq (NFData)
+import Codec.Serialise (Serialise)
+
+-- |
+-- For a given instance chain, stores the chain's file name and
+-- the starting source pos of the first instance in the chain.
+-- This data is used to determine which instances are part of
+-- the same instance chain.
+newtype ChainId = ChainId (String, Pos.SourcePos)
+ deriving (Eq, Ord, Show, NFData, Serialise)
+
+mkChainId :: String -> Pos.SourcePos -> ChainId
+mkChainId fileName startingSourcePos = ChainId (fileName, startingSourcePos)
diff --git a/src/Language/PureScript/AST/Exported.hs b/src/Language/PureScript/AST/Exported.hs
index f24b1dc697..8ca960bb95 100644
--- a/src/Language/PureScript/AST/Exported.hs
+++ b/src/Language/PureScript/AST/Exported.hs
@@ -3,17 +3,18 @@ module Language.PureScript.AST.Exported
, isExported
) where
-import Prelude.Compat
-import Protolude (sortBy, on)
+import Prelude
+import Protolude (sortOn)
import Control.Category ((>>>))
+import Control.Applicative ((<|>))
import Data.Maybe (mapMaybe)
-import qualified Data.Map as M
+import Data.Map qualified as M
-import Language.PureScript.AST.Declarations
-import Language.PureScript.Types
-import Language.PureScript.Names
+import Language.PureScript.AST.Declarations (DataConstructorDeclaration(..), Declaration(..), DeclarationRef(..), Module(..), declName, declRefName, flattenDecls)
+import Language.PureScript.Types (Constraint(..), Type(..), everythingOnTypes)
+import Language.PureScript.Names (ModuleName, Name(..), ProperName, ProperNameType(..), Qualified, coerceProperName, disqualify, isQualified, isQualifiedWith)
-- |
-- Return a list of all declarations which are exported from a module.
@@ -30,6 +31,8 @@ import Language.PureScript.Names
-- list, unless there is no export list, in which case they appear in the same
-- order as they do in the source file.
--
+-- Kind signatures declarations are also exported if their associated
+-- declaration is exported.
exportedDeclarations :: Module -> [Declaration]
exportedDeclarations (Module _ _ mn decls exps) = go decls
where
@@ -47,7 +50,7 @@ exportedDeclarations (Module _ _ mn decls exps) = go decls
filterDataConstructors :: Maybe [DeclarationRef] -> Declaration -> Declaration
filterDataConstructors exps (DataDeclaration sa dType tyName tyArgs dctors) =
DataDeclaration sa dType tyName tyArgs $
- filter (isDctorExported tyName exps . fst) dctors
+ filter (isDctorExported tyName exps . dataCtorName) dctors
filterDataConstructors _ other = other
-- |
@@ -101,7 +104,7 @@ filterInstances mn (Just exps) =
-- Get all type and type class names referenced by a type instance declaration.
--
typeInstanceConstituents :: Declaration -> [Either (Qualified (ProperName 'ClassName)) (Qualified (ProperName 'TypeName))]
-typeInstanceConstituents (TypeInstanceDeclaration _ _ _ _ constraints className tys _) =
+typeInstanceConstituents (TypeInstanceDeclaration _ _ _ _ _ constraints className tys _) =
Left className : (concatMap fromConstraint constraints ++ concatMap fromType tys)
where
@@ -126,6 +129,11 @@ typeInstanceConstituents _ = []
isExported :: Maybe [DeclarationRef] -> Declaration -> Bool
isExported Nothing _ = True
isExported _ TypeInstanceDeclaration{} = True
+isExported (Just exps) (KindDeclaration _ _ n _) = any matches exps
+ where
+ matches declRef = do
+ let refName = declRefName declRef
+ TyName n == refName || TyClassName (tyToClassName n) == refName
isExported (Just exps) decl = any matches exps
where
matches declRef = declName decl == Just (declRefName declRef)
@@ -148,9 +156,18 @@ isDctorExported ident (Just exps) ctor = test `any` exps
--
reorder :: [DeclarationRef] -> [Declaration] -> [Declaration]
reorder refs =
- sortBy (compare `on` refIndex)
+ sortOn refIndex
where
refIndices =
M.fromList $ zip (map declRefName refs) [(0::Int)..]
- refIndex decl =
- declName decl >>= flip M.lookup refIndices
+ refIndex = \case
+ KindDeclaration _ _ n _ ->
+ M.lookup (TyName n) refIndices <|> M.lookup (TyClassName (tyToClassName n)) refIndices
+
+ decl -> declName decl >>= flip M.lookup refIndices
+
+-- |
+-- Workaround to the fact that a `KindDeclaration`'s name's `ProperNameType`
+-- isn't the same as the corresponding `TypeClassDeclaration`'s `ProperNameType`
+tyToClassName :: ProperName 'TypeName -> ProperName 'ClassName
+tyToClassName = coerceProperName
diff --git a/src/Language/PureScript/AST/Literals.hs b/src/Language/PureScript/AST/Literals.hs
index a161fd82ab..05e06ab8f9 100644
--- a/src/Language/PureScript/AST/Literals.hs
+++ b/src/Language/PureScript/AST/Literals.hs
@@ -1,9 +1,12 @@
+{-# LANGUAGE DeriveAnyClass #-}
-- |
-- The core functional representation for literal values.
--
module Language.PureScript.AST.Literals where
-import Prelude.Compat
+import Prelude
+import Control.DeepSeq (NFData)
+import GHC.Generics (Generic)
import Language.PureScript.PSString (PSString)
-- |
@@ -35,4 +38,4 @@ data Literal a
-- An object literal
--
| ObjectLiteral [(PSString, a)]
- deriving (Eq, Ord, Show, Functor)
+ deriving (Eq, Ord, Show, Functor, Generic, NFData)
diff --git a/src/Language/PureScript/AST/Operators.hs b/src/Language/PureScript/AST/Operators.hs
index ffe53771d0..eb217a2444 100644
--- a/src/Language/PureScript/AST/Operators.hs
+++ b/src/Language/PureScript/AST/Operators.hs
@@ -1,17 +1,17 @@
-{-# LANGUAGE DeriveGeneric #-}
-- |
-- Operators fixity and associativity
--
module Language.PureScript.AST.Operators where
-import Prelude.Compat
+import Prelude
+import Codec.Serialise (Serialise)
import GHC.Generics (Generic)
import Control.DeepSeq (NFData)
import Data.Aeson ((.=))
-import qualified Data.Aeson as A
+import Data.Aeson qualified as A
-import Language.PureScript.Crash
+import Language.PureScript.Crash (internalError)
-- |
-- A precedence level for an infix operator
@@ -25,6 +25,7 @@ data Associativity = Infixl | Infixr | Infix
deriving (Show, Eq, Ord, Generic)
instance NFData Associativity
+instance Serialise Associativity
showAssoc :: Associativity -> String
showAssoc Infixl = "infixl"
@@ -50,6 +51,7 @@ data Fixity = Fixity Associativity Precedence
deriving (Show, Eq, Ord, Generic)
instance NFData Fixity
+instance Serialise Fixity
instance A.ToJSON Fixity where
toJSON (Fixity associativity precedence) =
diff --git a/src/Language/PureScript/AST/SourcePos.hs b/src/Language/PureScript/AST/SourcePos.hs
index d47de81a50..262d44b6a1 100644
--- a/src/Language/PureScript/AST/SourcePos.hs
+++ b/src/Language/PureScript/AST/SourcePos.hs
@@ -1,18 +1,19 @@
-{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE DeriveAnyClass #-}
-- |
-- Source position information
--
module Language.PureScript.AST.SourcePos where
-import Prelude.Compat
+import Prelude
+import Codec.Serialise (Serialise)
import Control.DeepSeq (NFData)
import Data.Aeson ((.=), (.:))
import Data.Text (Text)
import GHC.Generics (Generic)
-import Language.PureScript.Comments
-import qualified Data.Aeson as A
-import qualified Data.Text as T
+import Language.PureScript.Comments (Comment)
+import Data.Aeson qualified as A
+import Data.Text qualified as T
import System.FilePath (makeRelative)
-- | Source annotation - position information and comments.
@@ -24,9 +25,7 @@ data SourcePos = SourcePos
-- ^ Line number
, sourcePosColumn :: Int
-- ^ Column number
- } deriving (Show, Eq, Ord, Generic)
-
-instance NFData SourcePos
+ } deriving (Show, Eq, Ord, Generic, NFData, Serialise)
displaySourcePos :: SourcePos -> Text
displaySourcePos sp =
@@ -54,9 +53,7 @@ data SourceSpan = SourceSpan
-- ^ Start of the span
, spanEnd :: SourcePos
-- ^ End of the span
- } deriving (Show, Eq, Ord, Generic)
-
-instance NFData SourceSpan
+ } deriving (Show, Eq, Ord, Generic, NFData, Serialise)
displayStartEndPos :: SourceSpan -> Text
displayStartEndPos sp =
diff --git a/src/Language/PureScript/AST/Traversals.hs b/src/Language/PureScript/AST/Traversals.hs
index 536792595e..abbe6e5a15 100644
--- a/src/Language/PureScript/AST/Traversals.hs
+++ b/src/Language/PureScript/AST/Traversals.hs
@@ -3,23 +3,27 @@
--
module Language.PureScript.AST.Traversals where
-import Prelude.Compat
+import Prelude
+import Protolude (swap)
-import Control.Monad
+import Control.Monad ((<=<), (>=>))
+import Control.Monad.Trans.State (StateT(..))
import Data.Foldable (fold)
+import Data.Functor.Identity (runIdentity)
import Data.List (mapAccumL)
import Data.Maybe (mapMaybe)
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Set as S
-
-import Language.PureScript.AST.Binders
-import Language.PureScript.AST.Declarations
-import Language.PureScript.AST.Literals
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.Traversals
-import Language.PureScript.Types
+import Data.List.NonEmpty qualified as NEL
+import Data.Map qualified as M
+import Data.Set qualified as S
+
+import Language.PureScript.AST.Binders (Binder(..), binderNames)
+import Language.PureScript.AST.Declarations (CaseAlternative(..), DataConstructorDeclaration(..), Declaration(..), DoNotationElement(..), Expr(..), Guard(..), GuardedExpr(..), TypeDeclarationData(..), TypeInstanceBody(..), pattern ValueDecl, ValueDeclarationData(..), mapTypeInstanceBody, traverseTypeInstanceBody)
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident)
+import Language.PureScript.Traversals (sndM, sndM', thirdM)
+import Language.PureScript.TypeClassDictionaries (TypeClassDictionaryInScope(..))
+import Language.PureScript.Types (Constraint(..), SourceType, mapConstraintArgs)
guardedExprM :: Applicative m
=> (Guard -> m Guard)
@@ -58,7 +62,7 @@ everywhereOnValues f g h = (f', g', h')
f' (BoundValueDeclaration sa b expr) = f (BoundValueDeclaration sa (h' b) (g' expr))
f' (BindingGroupDeclaration ds) = f (BindingGroupDeclaration (fmap (\(name, nameKind, val) -> (name, nameKind, g' val)) ds))
f' (TypeClassDeclaration sa name args implies deps ds) = f (TypeClassDeclaration sa name args implies deps (fmap f' ds))
- f' (TypeInstanceDeclaration sa ch idx name cs className args ds) = f (TypeInstanceDeclaration sa ch idx name cs className args (mapTypeInstanceBody (fmap f') ds))
+ f' (TypeInstanceDeclaration sa na ch idx name cs className args ds) = f (TypeInstanceDeclaration sa na ch idx name cs className args (mapTypeInstanceBody (fmap f') ds))
f' other = f other
g' :: Expr -> Expr
@@ -66,12 +70,13 @@ everywhereOnValues f g h = (f', g', h')
g' (UnaryMinus ss v) = g (UnaryMinus ss (g' v))
g' (BinaryNoParens op v1 v2) = g (BinaryNoParens (g' op) (g' v1) (g' v2))
g' (Parens v) = g (Parens (g' v))
- g' (TypeClassDictionaryConstructorApp name v) = g (TypeClassDictionaryConstructorApp name (g' v))
g' (Accessor prop v) = g (Accessor prop (g' v))
g' (ObjectUpdate obj vs) = g (ObjectUpdate (g' obj) (fmap (fmap g') vs))
g' (ObjectUpdateNested obj vs) = g (ObjectUpdateNested (g' obj) (fmap g' vs))
g' (Abs binder v) = g (Abs (h' binder) (g' v))
g' (App v1 v2) = g (App (g' v1) (g' v2))
+ g' (VisibleTypeApp v ty) = g (VisibleTypeApp (g' v) ty)
+ g' (Unused v) = g (Unused (g' v))
g' (IfThenElse v1 v2 v3) = g (IfThenElse (g' v1) (g' v2) (g' v3))
g' (Case vs alts) = g (Case (fmap g' vs) (fmap handleCaseAlternative alts))
g' (TypedValue check v ty) = g (TypedValue check (g' v) ty)
@@ -129,9 +134,9 @@ everywhereOnValuesTopDownM f g h = (f' <=< f, g' <=< g, h' <=< h)
f' (DataBindingGroupDeclaration ds) = DataBindingGroupDeclaration <$> traverse (f' <=< f) ds
f' (ValueDecl sa name nameKind bs val) =
ValueDecl sa name nameKind <$> traverse (h' <=< h) bs <*> traverse (guardedExprM handleGuard (g' <=< g)) val
- f' (BindingGroupDeclaration ds) = BindingGroupDeclaration <$> traverse (\(name, nameKind, val) -> (,,) name nameKind <$> (g val >>= g')) ds
+ f' (BindingGroupDeclaration ds) = BindingGroupDeclaration <$> traverse (\(name, nameKind, val) -> (name, nameKind, ) <$> (g val >>= g')) ds
f' (TypeClassDeclaration sa name args implies deps ds) = TypeClassDeclaration sa name args implies deps <$> traverse (f' <=< f) ds
- f' (TypeInstanceDeclaration sa ch idx name cs className args ds) = TypeInstanceDeclaration sa ch idx name cs className args <$> traverseTypeInstanceBody (traverse (f' <=< f)) ds
+ f' (TypeInstanceDeclaration sa na ch idx name cs className args ds) = TypeInstanceDeclaration sa na ch idx name cs className args <$> traverseTypeInstanceBody (traverse (f' <=< f)) ds
f' (BoundValueDeclaration sa b expr) = BoundValueDeclaration sa <$> (h' <=< h) b <*> (g' <=< g) expr
f' other = f other
@@ -140,12 +145,13 @@ everywhereOnValuesTopDownM f g h = (f' <=< f, g' <=< g, h' <=< h)
g' (UnaryMinus ss v) = UnaryMinus ss <$> (g v >>= g')
g' (BinaryNoParens op v1 v2) = BinaryNoParens <$> (g op >>= g') <*> (g v1 >>= g') <*> (g v2 >>= g')
g' (Parens v) = Parens <$> (g v >>= g')
- g' (TypeClassDictionaryConstructorApp name v) = TypeClassDictionaryConstructorApp name <$> (g v >>= g')
g' (Accessor prop v) = Accessor prop <$> (g v >>= g')
g' (ObjectUpdate obj vs) = ObjectUpdate <$> (g obj >>= g') <*> traverse (sndM (g' <=< g)) vs
g' (ObjectUpdateNested obj vs) = ObjectUpdateNested <$> (g obj >>= g') <*> traverse (g' <=< g) vs
g' (Abs binder v) = Abs <$> (h binder >>= h') <*> (g v >>= g')
g' (App v1 v2) = App <$> (g v1 >>= g') <*> (g v2 >>= g')
+ g' (VisibleTypeApp v ty) = VisibleTypeApp <$> (g v >>= g') <*> pure ty
+ g' (Unused v) = Unused <$> (g v >>= g')
g' (IfThenElse v1 v2 v3) = IfThenElse <$> (g v1 >>= g') <*> (g v2 >>= g') <*> (g v3 >>= g')
g' (Case vs alts) = Case <$> traverse (g' <=< g) vs <*> traverse handleCaseAlternative alts
g' (TypedValue check v ty) = TypedValue check <$> (g v >>= g') <*> pure ty
@@ -198,10 +204,10 @@ everywhereOnValuesM f g h = (f', g', h')
f' (DataBindingGroupDeclaration ds) = (DataBindingGroupDeclaration <$> traverse f' ds) >>= f
f' (ValueDecl sa name nameKind bs val) =
ValueDecl sa name nameKind <$> traverse h' bs <*> traverse (guardedExprM handleGuard g') val >>= f
- f' (BindingGroupDeclaration ds) = (BindingGroupDeclaration <$> traverse (\(name, nameKind, val) -> (,,) name nameKind <$> g' val) ds) >>= f
+ f' (BindingGroupDeclaration ds) = (BindingGroupDeclaration <$> traverse (\(name, nameKind, val) -> (name, nameKind, ) <$> g' val) ds) >>= f
f' (BoundValueDeclaration sa b expr) = (BoundValueDeclaration sa <$> h' b <*> g' expr) >>= f
f' (TypeClassDeclaration sa name args implies deps ds) = (TypeClassDeclaration sa name args implies deps <$> traverse f' ds) >>= f
- f' (TypeInstanceDeclaration sa ch idx name cs className args ds) = (TypeInstanceDeclaration sa ch idx name cs className args <$> traverseTypeInstanceBody (traverse f') ds) >>= f
+ f' (TypeInstanceDeclaration sa na ch idx name cs className args ds) = (TypeInstanceDeclaration sa na ch idx name cs className args <$> traverseTypeInstanceBody (traverse f') ds) >>= f
f' other = f other
g' :: Expr -> m Expr
@@ -209,12 +215,13 @@ everywhereOnValuesM f g h = (f', g', h')
g' (UnaryMinus ss v) = (UnaryMinus ss <$> g' v) >>= g
g' (BinaryNoParens op v1 v2) = (BinaryNoParens <$> g' op <*> g' v1 <*> g' v2) >>= g
g' (Parens v) = (Parens <$> g' v) >>= g
- g' (TypeClassDictionaryConstructorApp name v) = (TypeClassDictionaryConstructorApp name <$> g' v) >>= g
g' (Accessor prop v) = (Accessor prop <$> g' v) >>= g
g' (ObjectUpdate obj vs) = (ObjectUpdate <$> g' obj <*> traverse (sndM g') vs) >>= g
g' (ObjectUpdateNested obj vs) = (ObjectUpdateNested <$> g' obj <*> traverse g' vs) >>= g
g' (Abs binder v) = (Abs <$> h' binder <*> g' v) >>= g
g' (App v1 v2) = (App <$> g' v1 <*> g' v2) >>= g
+ g' (VisibleTypeApp v ty) = (VisibleTypeApp <$> g' v <*> pure ty) >>= g
+ g' (Unused v) = (Unused <$> g' v) >>= g
g' (IfThenElse v1 v2 v3) = (IfThenElse <$> g' v1 <*> g' v2 <*> g' v3) >>= g
g' (Case vs alts) = (Case <$> traverse g' vs <*> traverse handleCaseAlternative alts) >>= g
g' (TypedValue check v ty) = (TypedValue check <$> g' v <*> pure ty) >>= g
@@ -272,7 +279,7 @@ everythingOnValues (<>.) f g h i j = (f', g', h', i', j')
f' d@(ValueDeclaration vd) = foldl (<>.) (f d) (fmap h' (valdeclBinders vd) ++ concatMap (\(GuardedExpr grd v) -> fmap k' grd ++ [g' v]) (valdeclExpression vd))
f' d@(BindingGroupDeclaration ds) = foldl (<>.) (f d) (fmap (\(_, _, val) -> g' val) ds)
f' d@(TypeClassDeclaration _ _ _ _ _ ds) = foldl (<>.) (f d) (fmap f' ds)
- f' d@(TypeInstanceDeclaration _ _ _ _ _ _ _ (ExplicitInstance ds)) = foldl (<>.) (f d) (fmap f' ds)
+ f' d@(TypeInstanceDeclaration _ _ _ _ _ _ _ _ (ExplicitInstance ds)) = foldl (<>.) (f d) (fmap f' ds)
f' d@(BoundValueDeclaration _ b expr) = f d <>. h' b <>. g' expr
f' d = f d
@@ -281,12 +288,13 @@ everythingOnValues (<>.) f g h i j = (f', g', h', i', j')
g' v@(UnaryMinus _ v1) = g v <>. g' v1
g' v@(BinaryNoParens op v1 v2) = g v <>. g' op <>. g' v1 <>. g' v2
g' v@(Parens v1) = g v <>. g' v1
- g' v@(TypeClassDictionaryConstructorApp _ v1) = g v <>. g' v1
g' v@(Accessor _ v1) = g v <>. g' v1
g' v@(ObjectUpdate obj vs) = foldl (<>.) (g v <>. g' obj) (fmap (g' . snd) vs)
g' v@(ObjectUpdateNested obj vs) = foldl (<>.) (g v <>. g' obj) (fmap g' vs)
g' v@(Abs b v1) = g v <>. h' b <>. g' v1
g' v@(App v1 v2) = g v <>. g' v1 <>. g' v2
+ g' v@(VisibleTypeApp v' _) = g v <>. g' v'
+ g' v@(Unused v1) = g v <>. g' v1
g' v@(IfThenElse v1 v2 v3) = g v <>. g' v1 <>. g' v2 <>. g' v3
g' v@(Case vs alts) = foldl (<>.) (foldl (<>.) (g v) (fmap g' vs)) (fmap i' alts)
g' v@(TypedValue _ v1 _) = g v <>. g' v1
@@ -351,7 +359,7 @@ everythingWithContextOnValues s0 r0 (<>.) f g h i j = (f'' s0, g'' s0, h'' s0, i
f' s (ValueDeclaration vd) = foldl (<>.) r0 (fmap (h'' s) (valdeclBinders vd) ++ concatMap (\(GuardedExpr grd v) -> fmap (k' s) grd ++ [g'' s v]) (valdeclExpression vd))
f' s (BindingGroupDeclaration ds) = foldl (<>.) r0 (fmap (\(_, _, val) -> g'' s val) ds)
f' s (TypeClassDeclaration _ _ _ _ _ ds) = foldl (<>.) r0 (fmap (f'' s) ds)
- f' s (TypeInstanceDeclaration _ _ _ _ _ _ _ (ExplicitInstance ds)) = foldl (<>.) r0 (fmap (f'' s) ds)
+ f' s (TypeInstanceDeclaration _ _ _ _ _ _ _ _ (ExplicitInstance ds)) = foldl (<>.) r0 (fmap (f'' s) ds)
f' _ _ = r0
g'' :: s -> Expr -> r
@@ -362,12 +370,13 @@ everythingWithContextOnValues s0 r0 (<>.) f g h i j = (f'' s0, g'' s0, h'' s0, i
g' s (UnaryMinus _ v1) = g'' s v1
g' s (BinaryNoParens op v1 v2) = g'' s op <>. g'' s v1 <>. g'' s v2
g' s (Parens v1) = g'' s v1
- g' s (TypeClassDictionaryConstructorApp _ v1) = g'' s v1
g' s (Accessor _ v1) = g'' s v1
g' s (ObjectUpdate obj vs) = foldl (<>.) (g'' s obj) (fmap (g'' s . snd) vs)
g' s (ObjectUpdateNested obj vs) = foldl (<>.) (g'' s obj) (fmap (g'' s) vs)
g' s (Abs binder v1) = h'' s binder <>. g'' s v1
g' s (App v1 v2) = g'' s v1 <>. g'' s v2
+ g' s (VisibleTypeApp v _) = g'' s v
+ g' s (Unused v) = g'' s v
g' s (IfThenElse v1 v2 v3) = g'' s v1 <>. g'' s v2 <>. g'' s v3
g' s (Case vs alts) = foldl (<>.) (foldl (<>.) r0 (fmap (g'' s) vs)) (fmap (i'' s) alts)
g' s (TypedValue _ v1 _) = g'' s v1
@@ -414,6 +423,27 @@ everythingWithContextOnValues s0 r0 (<>.) f g h i j = (f'' s0, g'' s0, h'' s0, i
k' s (ConditionGuard e) = g'' s e
k' s (PatternGuard b e) = h'' s b <>. g'' s e
+everywhereWithContextOnValues
+ :: forall s
+ . s
+ -> (s -> Declaration -> (s, Declaration))
+ -> (s -> Expr -> (s, Expr))
+ -> (s -> Binder -> (s, Binder))
+ -> (s -> CaseAlternative -> (s, CaseAlternative))
+ -> (s -> DoNotationElement -> (s, DoNotationElement))
+ -> (s -> Guard -> (s, Guard))
+ -> ( Declaration -> Declaration
+ , Expr -> Expr
+ , Binder -> Binder
+ , CaseAlternative -> CaseAlternative
+ , DoNotationElement -> DoNotationElement
+ , Guard -> Guard
+ )
+everywhereWithContextOnValues s f g h i j k = (runIdentity . f', runIdentity . g', runIdentity . h', runIdentity . i', runIdentity . j', runIdentity . k')
+ where
+ (f', g', h', i', j', k') = everywhereWithContextOnValuesM s (wrap f) (wrap g) (wrap h) (wrap i) (wrap j) (wrap k)
+ wrap = ((pure .) .)
+
everywhereWithContextOnValuesM
:: forall m s
. (Monad m)
@@ -423,13 +453,15 @@ everywhereWithContextOnValuesM
-> (s -> Binder -> m (s, Binder))
-> (s -> CaseAlternative -> m (s, CaseAlternative))
-> (s -> DoNotationElement -> m (s, DoNotationElement))
+ -> (s -> Guard -> m (s, Guard))
-> ( Declaration -> m Declaration
, Expr -> m Expr
, Binder -> m Binder
, CaseAlternative -> m CaseAlternative
, DoNotationElement -> m DoNotationElement
+ , Guard -> m Guard
)
-everywhereWithContextOnValuesM s0 f g h i j = (f'' s0, g'' s0, h'' s0, i'' s0, j'' s0)
+everywhereWithContextOnValuesM s0 f g h i j k = (f'' s0, g'' s0, h'' s0, i'' s0, j'' s0, k'' s0)
where
f'' s = uncurry f' <=< f s
@@ -438,7 +470,7 @@ everywhereWithContextOnValuesM s0 f g h i j = (f'' s0, g'' s0, h'' s0, i'' s0, j
ValueDecl sa name nameKind <$> traverse (h'' s) bs <*> traverse (guardedExprM (k' s) (g'' s)) val
f' s (BindingGroupDeclaration ds) = BindingGroupDeclaration <$> traverse (thirdM (g'' s)) ds
f' s (TypeClassDeclaration sa name args implies deps ds) = TypeClassDeclaration sa name args implies deps <$> traverse (f'' s) ds
- f' s (TypeInstanceDeclaration sa ch idx name cs className args ds) = TypeInstanceDeclaration sa ch idx name cs className args <$> traverseTypeInstanceBody (traverse (f'' s)) ds
+ f' s (TypeInstanceDeclaration sa na ch idx name cs className args ds) = TypeInstanceDeclaration sa na ch idx name cs className args <$> traverseTypeInstanceBody (traverse (f'' s)) ds
f' _ other = return other
g'' s = uncurry g' <=< g s
@@ -447,12 +479,13 @@ everywhereWithContextOnValuesM s0 f g h i j = (f'' s0, g'' s0, h'' s0, i'' s0, j
g' s (UnaryMinus ss v) = UnaryMinus ss <$> g'' s v
g' s (BinaryNoParens op v1 v2) = BinaryNoParens <$> g'' s op <*> g'' s v1 <*> g'' s v2
g' s (Parens v) = Parens <$> g'' s v
- g' s (TypeClassDictionaryConstructorApp name v) = TypeClassDictionaryConstructorApp name <$> g'' s v
g' s (Accessor prop v) = Accessor prop <$> g'' s v
g' s (ObjectUpdate obj vs) = ObjectUpdate <$> g'' s obj <*> traverse (sndM (g'' s)) vs
g' s (ObjectUpdateNested obj vs) = ObjectUpdateNested <$> g'' s obj <*> traverse (g'' s) vs
g' s (Abs binder v) = Abs <$> h' s binder <*> g'' s v
g' s (App v1 v2) = App <$> g'' s v1 <*> g'' s v2
+ g' s (VisibleTypeApp v ty) = VisibleTypeApp <$> g'' s v <*> pure ty
+ g' s (Unused v) = Unused <$> g'' s v
g' s (IfThenElse v1 v2 v3) = IfThenElse <$> g'' s v1 <*> g'' s v2 <*> g'' s v3
g' s (Case vs alts) = Case <$> traverse (g'' s) vs <*> traverse (i'' s) alts
g' s (TypedValue check v ty) = TypedValue check <$> g'' s v <*> pure ty
@@ -480,7 +513,18 @@ everywhereWithContextOnValuesM s0 f g h i j = (f'' s0, g'' s0, h'' s0, i'' s0, j
i'' s = uncurry i' <=< i s
- i' s (CaseAlternative bs val) = CaseAlternative <$> traverse (h'' s) bs <*> traverse (guardedExprM (k' s) (g'' s)) val
+ i' s (CaseAlternative bs val) = CaseAlternative <$> traverse (h'' s) bs <*> traverse (guardedExprM' s) val
+
+ -- A specialized `guardedExprM` that keeps track of the context `s`
+ -- after traversing `guards`, such that it's also exposed to `expr`.
+ guardedExprM' :: s -> GuardedExpr -> m GuardedExpr
+ guardedExprM' s (GuardedExpr guards expr) = do
+ (guards', s') <- runStateT (traverse (StateT . goGuard) guards) s
+ GuardedExpr guards' <$> g'' s' expr
+
+ -- Like k'', but `s` is tracked.
+ goGuard :: Guard -> s -> m (Guard, s)
+ goGuard x s = k s x >>= fmap swap . sndM' k'
j'' s = uncurry j' <=< j s
@@ -489,6 +533,8 @@ everywhereWithContextOnValuesM s0 f g h i j = (f'' s0, g'' s0, h'' s0, i'' s0, j
j' s (DoNotationLet ds) = DoNotationLet <$> traverse (f'' s) ds
j' s (PositionedDoNotationElement pos com e1) = PositionedDoNotationElement pos com <$> j'' s e1
+ k'' s = uncurry k' <=< k s
+
k' s (ConditionGuard e) = ConditionGuard <$> g'' s e
k' s (PatternGuard b e) = PatternGuard <$> h'' s b <*> g'' s e
@@ -529,7 +575,7 @@ everythingWithScope f g h i j = (f'', g'', h'', i'', \s -> snd . j'' s)
let s' = S.union s (S.fromList (NEL.toList (fmap (\((_, name), _, _) -> ToplevelIdent name) ds)))
in foldMap (\(_, _, val) -> g'' s' val) ds
f' s (TypeClassDeclaration _ _ _ _ _ ds) = foldMap (f'' s) ds
- f' s (TypeInstanceDeclaration _ _ _ _ _ _ _ (ExplicitInstance ds)) = foldMap (f'' s) ds
+ f' s (TypeInstanceDeclaration _ _ _ _ _ _ _ _ (ExplicitInstance ds)) = foldMap (f'' s) ds
f' _ _ = mempty
g'' :: S.Set ScopedIdent -> Expr -> r
@@ -540,7 +586,6 @@ everythingWithScope f g h i j = (f'', g'', h'', i'', \s -> snd . j'' s)
g' s (UnaryMinus _ v1) = g'' s v1
g' s (BinaryNoParens op v1 v2) = g'' s op <> g'' s v1 <> g'' s v2
g' s (Parens v1) = g'' s v1
- g' s (TypeClassDictionaryConstructorApp _ v1) = g'' s v1
g' s (Accessor _ v1) = g'' s v1
g' s (ObjectUpdate obj vs) = g'' s obj <> foldMap (g'' s . snd) vs
g' s (ObjectUpdateNested obj vs) = g'' s obj <> foldMap (g'' s) vs
@@ -548,6 +593,8 @@ everythingWithScope f g h i j = (f'', g'', h'', i'', \s -> snd . j'' s)
let s' = S.union (S.fromList (localBinderNames b)) s
in h'' s b <> g'' s' v1
g' s (App v1 v2) = g'' s v1 <> g'' s v2
+ g' s (VisibleTypeApp v _) = g'' s v
+ g' s (Unused v) = g'' s v
g' s (IfThenElse v1 v2 v3) = g'' s v1 <> g'' s v2 <> g'' s v3
g' s (Case vs alts) = foldMap (g'' s) vs <> foldMap (i'' s) alts
g' s (TypedValue _ v1 _) = g'' s v1
@@ -627,56 +674,33 @@ accumTypes
, CaseAlternative -> r
, DoNotationElement -> r
)
-accumTypes f = everythingOnValues mappend forDecls forValues (const mempty) (const mempty) (const mempty)
- where
- forDecls (DataDeclaration _ _ _ _ dctors) = mconcat (concatMap (fmap (f . snd) . snd) dctors)
- forDecls (ExternDeclaration _ _ ty) = f ty
- forDecls (TypeClassDeclaration _ _ _ implies _ _) = mconcat (concatMap (fmap f . constraintArgs) implies)
- forDecls (TypeInstanceDeclaration _ _ _ _ cs _ tys _) = mconcat (concatMap (fmap f . constraintArgs) cs) <> mconcat (fmap f tys)
- forDecls (TypeSynonymDeclaration _ _ _ ty) = f ty
- forDecls (TypeDeclaration td) = f (tydeclType td)
- forDecls _ = mempty
-
- forValues (TypeClassDictionary c _ _) = mconcat (fmap f (constraintArgs c))
- forValues (DeferredDictionary _ tys) = mconcat (fmap f tys)
- forValues (TypedValue _ _ ty) = f ty
- forValues _ = mempty
-
-accumKinds
- :: (Monoid r)
- => (SourceKind -> r)
- -> ( Declaration -> r
- , Expr -> r
- , Binder -> r
- , CaseAlternative -> r
- , DoNotationElement -> r
- )
-accumKinds f = everythingOnValues mappend forDecls forValues (const mempty) (const mempty) (const mempty)
+accumTypes f = everythingOnValues mappend forDecls forValues forBinders (const mempty) (const mempty)
where
forDecls (DataDeclaration _ _ _ args dctors) =
foldMap (foldMap f . snd) args <>
- foldMap (foldMap (forTypes . snd) . snd) dctors
+ foldMap (foldMap (f . snd) . dataCtorFields) dctors
+ forDecls (ExternDataDeclaration _ _ ty) = f ty
+ forDecls (ExternDeclaration _ _ ty) = f ty
forDecls (TypeClassDeclaration _ _ args implies _ _) =
- foldMap (foldMap f . snd) args <>
- foldMap (foldMap forTypes . constraintArgs) implies
- forDecls (TypeInstanceDeclaration _ _ _ _ cs _ tys _) =
- foldMap (foldMap forTypes . constraintArgs) cs <>
- foldMap forTypes tys
+ foldMap (foldMap (foldMap f)) args <>
+ foldMap (foldMap f . constraintArgs) implies
+ forDecls (TypeInstanceDeclaration _ _ _ _ _ cs _ tys _) =
+ foldMap (foldMap f . constraintArgs) cs <> foldMap f tys
forDecls (TypeSynonymDeclaration _ _ args ty) =
foldMap (foldMap f . snd) args <>
- forTypes ty
- forDecls (TypeDeclaration td) = forTypes (tydeclType td)
- forDecls (ExternDeclaration _ _ ty) = forTypes ty
- forDecls (ExternDataDeclaration _ _ kn) = f kn
+ f ty
+ forDecls (KindDeclaration _ _ _ ty) = f ty
+ forDecls (TypeDeclaration td) = f (tydeclType td)
forDecls _ = mempty
- forValues (TypeClassDictionary c _ _) = foldMap forTypes (constraintArgs c)
- forValues (DeferredDictionary _ tys) = foldMap forTypes tys
- forValues (TypedValue _ _ ty) = forTypes ty
+ forValues (TypeClassDictionary c _ _) = foldMap f (constraintArgs c)
+ forValues (DeferredDictionary _ tys) = foldMap f tys
+ forValues (TypedValue _ _ ty) = f ty
+ forValues (VisibleTypeApp _ ty) = f ty
forValues _ = mempty
- forTypes (KindedType _ _ k) = f k
- forTypes _ = mempty
+ forBinders (TypedBinder ty _) = f ty
+ forBinders _ = mempty
-- |
-- Map a function over type annotations appearing inside a value
@@ -686,5 +710,12 @@ overTypes f = let (_, f', _) = everywhereOnValues id g id in f'
where
g :: Expr -> Expr
g (TypedValue checkTy val t) = TypedValue checkTy val (f t)
- g (TypeClassDictionary c sco hints) = TypeClassDictionary (mapConstraintArgs (fmap f) c) sco hints
+ g (TypeClassDictionary c sco hints) =
+ TypeClassDictionary
+ (mapConstraintArgs (fmap f) c)
+ (updateCtx sco)
+ hints
g other = other
+ updateDict fn dict = dict { tcdInstanceTypes = fn (tcdInstanceTypes dict) }
+ updateScope = fmap . fmap . fmap . fmap $ updateDict $ fmap f
+ updateCtx = M.alter updateScope ByNullSourcePos
diff --git a/src/Language/PureScript/AST/Utils.hs b/src/Language/PureScript/AST/Utils.hs
new file mode 100644
index 0000000000..d768a884fd
--- /dev/null
+++ b/src/Language/PureScript/AST/Utils.hs
@@ -0,0 +1,59 @@
+module Language.PureScript.AST.Utils where
+
+import Protolude
+
+import Language.PureScript.AST (Binder(..), CaseAlternative, Expr(..), GuardedExpr, Literal, pattern MkUnguarded, nullSourceSpan)
+import Language.PureScript.Names (Ident, ModuleName, ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), byMaybeModuleName)
+import Language.PureScript.Types (SourceType, Type(..))
+
+lam :: Ident -> Expr -> Expr
+lam = Abs . mkBinder
+
+lamCase :: Ident -> [CaseAlternative] -> Expr
+lamCase s = lam s . Case [mkVar s]
+
+lamCase2 :: Ident -> Ident -> [CaseAlternative] -> Expr
+lamCase2 s t = lam s . lam t . Case [mkVar s, mkVar t]
+
+mkRef :: Qualified Ident -> Expr
+mkRef = Var nullSourceSpan
+
+mkVarMn :: Maybe ModuleName -> Ident -> Expr
+mkVarMn mn = mkRef . Qualified (byMaybeModuleName mn)
+
+mkVar :: Ident -> Expr
+mkVar = mkVarMn Nothing
+
+mkBinder :: Ident -> Binder
+mkBinder = VarBinder nullSourceSpan
+
+mkLit :: Literal Expr -> Expr
+mkLit = Literal nullSourceSpan
+
+mkCtor :: ModuleName -> ProperName 'ConstructorName -> Expr
+mkCtor mn name = Constructor nullSourceSpan (Qualified (ByModuleName mn) name)
+
+mkCtorBinder :: ModuleName -> ProperName 'ConstructorName -> [Binder] -> Binder
+mkCtorBinder mn name = ConstructorBinder nullSourceSpan (Qualified (ByModuleName mn) name)
+
+unguarded :: Expr -> [GuardedExpr]
+unguarded e = [MkUnguarded e]
+
+data UnwrappedTypeConstructor = UnwrappedTypeConstructor
+ { utcModuleName :: ModuleName
+ , utcTyCon :: ProperName 'TypeName
+ , utcKindArgs :: [SourceType]
+ , utcArgs :: [SourceType]
+ }
+
+utcQTyCon :: UnwrappedTypeConstructor -> Qualified (ProperName 'TypeName)
+utcQTyCon UnwrappedTypeConstructor{..} = Qualified (ByModuleName utcModuleName) utcTyCon
+
+unwrapTypeConstructor :: SourceType -> Maybe UnwrappedTypeConstructor
+unwrapTypeConstructor = go [] []
+ where
+ go kargs args = \case
+ TypeConstructor _ (Qualified (ByModuleName mn) tyCon) -> Just (UnwrappedTypeConstructor mn tyCon kargs args)
+ TypeApp _ ty arg -> go kargs (arg : args) ty
+ KindApp _ ty karg -> go (karg : kargs) args ty
+ _ -> Nothing
diff --git a/src/Language/PureScript/Bundle.hs b/src/Language/PureScript/Bundle.hs
index d92d5662d7..f40cc44e9f 100644
--- a/src/Language/PureScript/Bundle.hs
+++ b/src/Language/PureScript/Bundle.hs
@@ -4,44 +4,36 @@
-- This module takes as input the individual generated modules from 'Language.PureScript.Make' and
-- performs dead code elimination, filters empty modules,
-- and generates the final JavaScript bundle.
+{-# LANGUAGE DeriveAnyClass #-}
module Language.PureScript.Bundle
- ( bundle
- , bundleSM
- , guessModuleIdentifier
- , ModuleIdentifier(..)
- , moduleName
+ ( ModuleIdentifier(..)
, ModuleType(..)
, ErrorMessage(..)
, printErrorMessage
+ , ForeignModuleExports(..)
, getExportedIdentifiers
+ , ForeignModuleImports(..)
+ , getImportedModules
+ , Module
) where
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
-import Control.Monad
-import Control.Monad.Error.Class
-import Control.Arrow ((&&&))
+import Control.DeepSeq (NFData)
+import Control.Monad.Error.Class (MonadError(..))
-import Data.Array ((!))
+import Data.Aeson ((.=))
import Data.Char (chr, digitToInt)
import Data.Foldable (fold)
-import Data.Generics (GenericM, everything, everywhere, gmapMo, mkMp, mkQ, mkT)
-import Data.Graph
-import Data.List (stripPrefix)
-import Data.Maybe (catMaybes, fromMaybe, mapMaybe)
-import Data.Version (showVersion)
-import qualified Data.Map as M
-import qualified Data.Set as S
+import Data.Maybe (mapMaybe, maybeToList)
+import Data.Aeson qualified as A
+import Data.Text.Lazy qualified as LT
-import Language.JavaScript.Parser
-import Language.JavaScript.Parser.AST
+import GHC.Generics (Generic)
-import qualified Paths_purescript as Paths
-
-import System.FilePath (takeFileName, takeDirectory, takeDirectory, makeRelative)
-
-import SourceMap.Types
+import Language.JavaScript.Parser (JSAST(..), JSAnnot(..), JSAssignOp(..), JSExpression(..), JSStatement(..), renderToText)
+import Language.JavaScript.Parser.AST (JSCommaList(..), JSCommaTrailingList(..), JSExportClause(..), JSExportDeclaration(..), JSExportSpecifier(..), JSFromClause(..), JSIdent(..), JSImportDeclaration(..), JSModuleItem(..), JSObjectProperty(..), JSObjectPropertyList, JSPropertyName(..), JSVarInitializer(..))
+import Language.JavaScript.Process.Minify (minifyJS)
-- | The type of error messages. We separate generation and rendering of errors using a data
-- type, in case we need to match on error types later.
@@ -49,40 +41,42 @@ data ErrorMessage
= UnsupportedModulePath String
| InvalidTopLevel
| UnableToParseModule String
+ | UnsupportedImport
| UnsupportedExport
| ErrorInModule ModuleIdentifier ErrorMessage
| MissingEntryPoint String
| MissingMainModule String
- deriving (Show)
+ deriving (Show, Generic, NFData)
-- | Modules are either "regular modules" (i.e. those generated by the PureScript compiler) or
-- foreign modules.
data ModuleType
= Regular
| Foreign
- deriving (Show, Eq, Ord)
+ deriving (Show, Eq, Ord, Generic, NFData)
showModuleType :: ModuleType -> String
showModuleType Regular = "Regular"
showModuleType Foreign = "Foreign"
-- | A module is identified by its module name and its type.
-data ModuleIdentifier = ModuleIdentifier String ModuleType deriving (Show, Eq, Ord)
-
-moduleName :: ModuleIdentifier -> String
-moduleName (ModuleIdentifier name _) = name
-
--- | Given a filename, assuming it is in the correct place on disk, infer a ModuleIdentifier.
-guessModuleIdentifier :: MonadError ErrorMessage m => FilePath -> m ModuleIdentifier
-guessModuleIdentifier filename = ModuleIdentifier (takeFileName (takeDirectory filename)) <$> guessModuleType (takeFileName filename)
- where
- guessModuleType "index.js" = pure Regular
- guessModuleType "foreign.js" = pure Foreign
- guessModuleType name = throwError $ UnsupportedModulePath name
+data ModuleIdentifier = ModuleIdentifier String ModuleType
+ deriving (Show, Eq, Ord, Generic, NFData)
+
+instance A.ToJSON ModuleIdentifier where
+ toJSON (ModuleIdentifier name mt) =
+ A.object [ "name" .= name
+ , "type" .= show mt
+ ]
+
+data Visibility
+ = Public
+ | Internal
+ deriving (Show, Eq, Ord)
--- | A piece of code is identified by its module and its name. These keys are used to label vertices
--- in the dependency graph.
-type Key = (ModuleIdentifier, String)
+-- | A piece of code is identified by its module, its name, and whether it is an internal variable
+-- or a public member. These keys are used to label vertices in the dependency graph.
+type Key = (ModuleIdentifier, String, Visibility)
-- | An export is either a "regular export", which exports a name from the regular module we are in,
-- or a reexport of a declaration in the corresponding foreign module.
@@ -95,7 +89,7 @@ data ExportType
-- | There are four types of module element we are interested in:
--
--- 1) Require statements
+-- 1) Import declarations and require statements
-- 2) Member declarations
-- 3) Export lists
-- 4) Everything else
@@ -103,23 +97,87 @@ data ExportType
-- Each is labelled with the original AST node which generated it, so that we can dump it back
-- into the output during codegen.
data ModuleElement
- = Require JSStatement String (Either String ModuleIdentifier)
- | Member JSStatement Bool String JSExpression [Key]
+ = Import JSModuleItem String (Either String ModuleIdentifier)
+ | Member JSStatement Visibility String JSExpression [Key]
| ExportsList [(ExportType, String, JSExpression, [Key])]
| Other JSStatement
- | Skip JSStatement
+ | Skip JSModuleItem
deriving (Show)
+instance A.ToJSON ModuleElement where
+ toJSON = \case
+ (Import _ name (Right target)) ->
+ A.object [ "type" .= A.String "Import"
+ , "name" .= name
+ , "target" .= target
+ ]
+ (Import _ name (Left targetPath)) ->
+ A.object [ "type" .= A.String "Import"
+ , "name" .= name
+ , "targetPath" .= targetPath
+ ]
+ (Member _ visibility name _ dependsOn) ->
+ A.object [ "type" .= A.String "Member"
+ , "name" .= name
+ , "visibility" .= show visibility
+ , "dependsOn" .= map keyToJSON dependsOn
+ ]
+ (ExportsList exports) ->
+ A.object [ "type" .= A.String "ExportsList"
+ , "exports" .= map exportToJSON exports
+ ]
+ (Other stmt) ->
+ A.object [ "type" .= A.String "Other"
+ , "js" .= getFragment (JSAstStatement stmt JSNoAnnot)
+ ]
+ (Skip item) ->
+ A.object [ "type" .= A.String "Skip"
+ , "js" .= getFragment (JSAstModule [item] JSNoAnnot)
+ ]
+
+ where
+
+ keyToJSON (mid, member, visibility) =
+ A.object [ "module" .= mid
+ , "member" .= member
+ , "visibility" .= show visibility
+ ]
+
+ exportToJSON (RegularExport sourceName, name, _, dependsOn) =
+ A.object [ "type" .= A.String "RegularExport"
+ , "name" .= name
+ , "sourceName" .= sourceName
+ , "dependsOn" .= map keyToJSON dependsOn
+ ]
+ exportToJSON (ForeignReexport, name, _, dependsOn) =
+ A.object [ "type" .= A.String "ForeignReexport"
+ , "name" .= name
+ , "dependsOn" .= map keyToJSON dependsOn
+ ]
+
+ getFragment = ellipsize . renderToText . minifyJS
+ where
+ ellipsize text = if LT.compareLength text 20 == GT then LT.take 19 text `LT.snoc` ellipsis else text
+ ellipsis = '\x2026'
+
-- | A module is just a list of elements of the types listed above.
data Module = Module ModuleIdentifier (Maybe FilePath) [ModuleElement] deriving (Show)
+instance A.ToJSON Module where
+ toJSON (Module moduleId filePath elements) =
+ A.object [ "moduleId" .= moduleId
+ , "filePath" .= filePath
+ , "elements" .= elements
+ ]
+
-- | Prepare an error message for consumption by humans.
printErrorMessage :: ErrorMessage -> [String]
printErrorMessage (UnsupportedModulePath s) =
- [ "A CommonJS module has an unsupported name (" ++ show s ++ ")."
+ [ "An ES or CommonJS module has an unsupported name (" ++ show s ++ ")."
, "The following file names are supported:"
, " 1) index.js (PureScript native modules)"
- , " 2) foreign.js (PureScript foreign modules)"
+ , " 2) foreign.js (PureScript ES foreign modules)"
+ , " 3) foreign.cjs (PureScript CommonJS foreign modules)"
]
printErrorMessage InvalidTopLevel =
[ "Expected a list of source elements at the top level." ]
@@ -127,10 +185,24 @@ printErrorMessage (UnableToParseModule err) =
[ "The module could not be parsed:"
, err
]
+printErrorMessage UnsupportedImport =
+ [ "An import was unsupported."
+ , "Modules can be imported with ES namespace imports declarations:"
+ , " import * as module from \"Module.Name\""
+ , "Alternatively, they can be also be imported with the CommonJS require function:"
+ , " var module = require(\"Module.Name\")"
+ ]
printErrorMessage UnsupportedExport =
- [ "An export was unsupported. Exports can be defined in one of two ways: "
- , " 1) exports.name = ..."
- , " 2) exports = { ... }"
+ [ "An export was unsupported."
+ , "Declarations can be exported as ES named exports:"
+ , " export var decl"
+ , "Existing identifiers can be exported as well:"
+ , " export { name }"
+ , "They can also be renamed on export:"
+ , " export { name as alias }"
+ , "Alternatively, CommonJS exports can be defined in one of two ways:"
+ , " 1) exports.name = value"
+ , " 2) exports = { name: value }"
]
printErrorMessage (ErrorInModule mid e) =
("Error in module " ++ displayIdentifier mid ++ ":")
@@ -140,87 +212,12 @@ printErrorMessage (ErrorInModule mid e) =
displayIdentifier (ModuleIdentifier name ty) =
name ++ " (" ++ showModuleType ty ++ ")"
printErrorMessage (MissingEntryPoint mName) =
- [ "Couldn't find a CommonJS module for the specified entry point: " ++ mName
+ [ "Could not find an ES module or CommonJS module for the specified entry point: " ++ mName
]
printErrorMessage (MissingMainModule mName) =
- [ "Couldn't find a CommonJS module for the specified main module: " ++ mName
+ [ "Could not find an ES module or CommonJS module for the specified main module: " ++ mName
]
--- | Calculate the ModuleIdentifier which a require(...) statement imports.
-checkImportPath :: String -> ModuleIdentifier -> S.Set String -> Either String ModuleIdentifier
-checkImportPath "./foreign.js" m _ =
- Right (ModuleIdentifier (moduleName m) Foreign)
-checkImportPath name _ names
- | Just name' <- stripSuffix "/index.js" =<< stripPrefix "../" name
- , name' `S.member` names = Right (ModuleIdentifier name' Regular)
-checkImportPath name _ _ = Left name
-
-stripSuffix :: Eq a => [a] -> [a] -> Maybe [a]
-stripSuffix suffix xs =
- case splitAt (length xs - length suffix) xs of
- (before, after)
- | after == suffix -> Just before
- | otherwise -> Nothing
-
--- | Compute the dependencies of all elements in a module, and add them to the tree.
---
--- Members and exports can have dependencies. A dependency is of one of the following forms:
---
--- 1) module.name or member["name"]
---
--- where module was imported using
---
--- var module = require("Module.Name");
---
--- 2) name
---
--- where name is the name of a member defined in the current module.
-withDeps :: Module -> Module
-withDeps (Module modulePath fn es) = Module modulePath fn (map expandDeps es)
- where
- -- | Collects all modules which are imported, so that we can identify dependencies of the first type.
- imports :: [(String, ModuleIdentifier)]
- imports = mapMaybe toImport es
- where
- toImport :: ModuleElement -> Maybe (String, ModuleIdentifier)
- toImport (Require _ nm (Right mid)) = Just (nm, mid)
- toImport _ = Nothing
-
- -- | Collects all member names in scope, so that we can identify dependencies of the second type.
- boundNames :: [String]
- boundNames = mapMaybe toBoundName es
- where
- toBoundName :: ModuleElement -> Maybe String
- toBoundName (Member _ _ nm _ _) = Just nm
- toBoundName _ = Nothing
-
- -- | Calculate dependencies and add them to the current element.
- expandDeps :: ModuleElement -> ModuleElement
- expandDeps (Member n f nm decl _) = Member n f nm decl (ordNub $ dependencies modulePath decl)
- expandDeps (ExportsList exps) = ExportsList (map expand exps)
- where
- expand (ty, nm, n1, _) = (ty, nm, n1, ordNub (dependencies modulePath n1))
- expandDeps other = other
-
- dependencies :: ModuleIdentifier -> JSExpression -> [(ModuleIdentifier, String)]
- dependencies m = everything (++) (mkQ [] toReference)
- where
- toReference :: JSExpression -> [(ModuleIdentifier, String)]
- toReference (JSMemberDot mn _ nm)
- | JSIdentifier _ mn' <- mn
- , JSIdentifier _ nm' <- nm
- , Just mid <- lookup mn' imports
- = [(mid, nm')]
- toReference (JSMemberSquare mn _ nm _)
- | JSIdentifier _ mn' <- mn
- , Just nm' <- fromStringLiteral nm
- , Just mid <- lookup mn' imports
- = [(mid, nm')]
- toReference (JSIdentifier _ nm)
- | nm `elem` boundNames
- = [(m, nm)]
- toReference _ = []
-
-- String literals include the quote chars
fromStringLiteral :: JSExpression -> Maybe String
fromStringLiteral (JSStringLiteral _ str) = Just $ strValue str
@@ -261,69 +258,69 @@ trailingCommaList :: JSCommaTrailingList a -> [a]
trailingCommaList (JSCTLComma l _) = commaList l
trailingCommaList (JSCTLNone l) = commaList l
--- | Attempt to create a Module from a JavaScript AST.
---
--- Each type of module element is matched using pattern guards, and everything else is bundled into the
--- Other constructor.
-toModule :: forall m. (MonadError ErrorMessage m) => S.Set String -> ModuleIdentifier -> Maybe FilePath -> JSAST -> m Module
-toModule mids mid filename top
- | JSAstProgram smts _ <- top = Module mid filename <$> traverse toModuleElement smts
- | otherwise = err InvalidTopLevel
+identName :: JSIdent -> Maybe String
+identName (JSIdentName _ ident) = Just ident
+identName _ = Nothing
+
+exportStatementIdentifiers :: JSStatement -> [String]
+exportStatementIdentifiers (JSVariable _ jsExpressions _) =
+ varNames jsExpressions
+exportStatementIdentifiers (JSConstant _ jsExpressions _) =
+ varNames jsExpressions
+exportStatementIdentifiers (JSLet _ jsExpressions _) =
+ varNames jsExpressions
+exportStatementIdentifiers (JSClass _ jsIdent _ _ _ _ _) =
+ maybeToList . identName $ jsIdent
+exportStatementIdentifiers (JSFunction _ jsIdent _ _ _ _ _) =
+ maybeToList . identName $ jsIdent
+exportStatementIdentifiers (JSGenerator _ _ jsIdent _ _ _ _ _) =
+ maybeToList . identName $ jsIdent
+exportStatementIdentifiers _ = []
+
+varNames :: JSCommaList JSExpression -> [String]
+varNames = mapMaybe varName . commaList
where
- err = throwError . ErrorInModule mid
-
- toModuleElement :: JSStatement -> m ModuleElement
- toModuleElement stmt
- | Just (importName, importPath) <- matchRequire mids mid stmt
- = pure (Require stmt importName importPath)
- toModuleElement stmt
- | Just (exported, name, decl) <- matchMember stmt
- = pure (Member stmt exported name decl [])
- toModuleElement stmt
- | Just props <- matchExportsAssignment stmt
- = ExportsList <$> traverse toExport (trailingCommaList props)
- where
- toExport :: JSObjectProperty -> m (ExportType, String, JSExpression, [Key])
- toExport (JSPropertyNameandValue name _ [val]) =
- (,,val,[]) <$> exportType val
- <*> extractLabel' name
- toExport _ = err UnsupportedExport
-
- exportType :: JSExpression -> m ExportType
- exportType (JSMemberDot f _ _)
- | JSIdentifier _ "$foreign" <- f
- = pure ForeignReexport
- exportType (JSMemberSquare f _ _ _)
- | JSIdentifier _ "$foreign" <- f
- = pure ForeignReexport
- exportType (JSIdentifier _ s) = pure (RegularExport s)
- exportType _ = err UnsupportedExport
-
- extractLabel' = maybe (err UnsupportedExport) pure . extractLabel
-
- toModuleElement other = pure (Other other)
+ varName (JSVarInitExpression (JSIdentifier _ ident) _) = Just ident
+ varName _ = Nothing
+
+data ForeignModuleExports =
+ ForeignModuleExports
+ { cjsExports :: [String]
+ , esExports :: [String]
+ } deriving (Show)
+
+instance Semigroup ForeignModuleExports where
+ (ForeignModuleExports cjsExports esExports) <> (ForeignModuleExports cjsExports' esExports') =
+ ForeignModuleExports (cjsExports <> cjsExports') (esExports <> esExports')
+instance Monoid ForeignModuleExports where
+ mempty = ForeignModuleExports [] []
-- Get a list of all the exported identifiers from a foreign module.
--
-- TODO: what if we assign to exports.foo and then later assign to
-- module.exports (presumably overwriting exports.foo)?
-getExportedIdentifiers :: (MonadError ErrorMessage m)
+getExportedIdentifiers :: forall m. (MonadError ErrorMessage m)
=> String
-> JSAST
- -> m [String]
+ -> m ForeignModuleExports
getExportedIdentifiers mname top
- | JSAstProgram stmts _ <- top = concat <$> traverse go stmts
+ | JSAstModule jsModuleItems _ <- top = fold <$> traverse go jsModuleItems
| otherwise = err InvalidTopLevel
where
+ err :: ErrorMessage -> m a
err = throwError . ErrorInModule (ModuleIdentifier mname Foreign)
- go stmt
- | Just props <- matchExportsAssignment stmt
- = traverse toIdent (trailingCommaList props)
- | Just (True, name, _) <- matchMember stmt
- = pure [name]
+ go (JSModuleStatementListItem jsStatement)
+ | Just props <- matchExportsAssignment jsStatement
+ = do cjsExports <- traverse toIdent (trailingCommaList props)
+ pure ForeignModuleExports{ cjsExports, esExports = [] }
+ | Just (Public, name, _) <- matchMember jsStatement
+ = pure ForeignModuleExports{ cjsExports = [name], esExports = [] }
| otherwise
- = pure []
+ = pure mempty
+ go (JSModuleExportDeclaration _ jsExportDeclaration) =
+ pure ForeignModuleExports{ cjsExports = [], esExports = exportDeclarationIdentifiers jsExportDeclaration }
+ go _ = pure mempty
toIdent (JSPropertyNameandValue name _ [_]) =
extractLabel' name
@@ -332,13 +329,57 @@ getExportedIdentifiers mname top
extractLabel' = maybe (err UnsupportedExport) pure . extractLabel
+ exportDeclarationIdentifiers (JSExportFrom jsExportClause _ _) =
+ exportClauseIdentifiers jsExportClause
+ exportDeclarationIdentifiers (JSExportLocals jsExportClause _) =
+ exportClauseIdentifiers jsExportClause
+ exportDeclarationIdentifiers (JSExport jsStatement _) =
+ exportStatementIdentifiers jsStatement
+
+ exportClauseIdentifiers (JSExportClause _ jsExportsSpecifiers _) =
+ mapMaybe exportSpecifierName $ commaList jsExportsSpecifiers
+
+ exportSpecifierName (JSExportSpecifier jsIdent) = identName jsIdent
+ exportSpecifierName (JSExportSpecifierAs _ _ jsIdentAs) = identName jsIdentAs
+
+data ForeignModuleImports =
+ ForeignModuleImports
+ { cjsImports :: [String]
+ , esImports :: [String]
+ } deriving (Show)
+
+instance Semigroup ForeignModuleImports where
+ (ForeignModuleImports cjsImports esImports) <> (ForeignModuleImports cjsImports' esImports') =
+ ForeignModuleImports (cjsImports <> cjsImports') (esImports <> esImports')
+instance Monoid ForeignModuleImports where
+ mempty = ForeignModuleImports [] []
+
+-- Get a list of all the imported module identifiers from a foreign module.
+getImportedModules :: forall m. (MonadError ErrorMessage m)
+ => String
+ -> JSAST
+ -> m ForeignModuleImports
+getImportedModules mname top
+ | JSAstModule jsModuleItems _ <- top = pure $ foldMap go jsModuleItems
+ | otherwise = err InvalidTopLevel
+ where
+ err :: ErrorMessage -> m a
+ err = throwError . ErrorInModule (ModuleIdentifier mname Foreign)
+
+ go (JSModuleStatementListItem jsStatement)
+ | Just (_, mid) <- matchRequire jsStatement
+ = ForeignModuleImports{ cjsImports = [mid], esImports = [] }
+ go (JSModuleImportDeclaration _ jsImportDeclaration) =
+ ForeignModuleImports{ cjsImports = [], esImports = [importDeclarationModuleId jsImportDeclaration] }
+ go _ = mempty
+
+ importDeclarationModuleId (JSImportDeclaration _ (JSFromClause _ _ mid) _) = mid
+ importDeclarationModuleId (JSImportDeclarationBare _ mid _) = mid
+
-- Matches JS statements like this:
-- var ModuleName = require("file");
-matchRequire :: S.Set String
- -> ModuleIdentifier
- -> JSStatement
- -> Maybe (String, Either String ModuleIdentifier)
-matchRequire mids mid stmt
+matchRequire :: JSStatement -> Maybe (String, String)
+matchRequire stmt
| JSVariable _ jsInit _ <- stmt
, [JSVarInitExpression var varInit] <- commaList jsInit
, JSIdentifier _ importName <- var
@@ -346,37 +387,48 @@ matchRequire mids mid stmt
, JSMemberExpression req _ argsE _ <- jsInitEx
, JSIdentifier _ "require" <- req
, [ Just importPath ] <- map fromStringLiteral (commaList argsE)
- , importPath' <- checkImportPath importPath mid mids
- = Just (importName, importPath')
+ = Just (importName, importPath)
| otherwise
= Nothing
-- Matches JS member declarations.
-matchMember :: JSStatement -> Maybe (Bool, String, JSExpression)
+matchMember :: JSStatement -> Maybe (Visibility, String, JSExpression)
matchMember stmt
+ | Just (name, decl) <- matchInternalMember stmt
+ = pure (Internal, name, decl)
+ -- exports.foo = expr; exports["foo"] = expr;
+ | JSAssignStatement e (JSAssign _) decl _ <- stmt
+ , Just name <- exportsAccessor e
+ = Just (Public, name, decl)
+ | otherwise
+ = Nothing
+
+matchInternalMember :: JSStatement -> Maybe (String, JSExpression)
+matchInternalMember stmt
-- var foo = expr;
| JSVariable _ jsInit _ <- stmt
, [JSVarInitExpression var varInit] <- commaList jsInit
, JSIdentifier _ name <- var
, JSVarInit _ decl <- varInit
- = Just (False, name, decl)
- -- exports.foo = expr; exports["foo"] = expr;
- | JSAssignStatement e (JSAssign _) decl _ <- stmt
- , Just name <- accessor e
- = Just (True, name, decl)
+ = pure (name, decl)
+ -- function foo(...args) { body }
+ | JSFunction a0 jsIdent a1 args a2 body _ <- stmt
+ , JSIdentName _ name <- jsIdent
+ = pure (name, JSFunctionExpression a0 jsIdent a1 args a2 body)
| otherwise
= Nothing
- where
- accessor :: JSExpression -> Maybe String
- accessor (JSMemberDot exports _ nm)
- | JSIdentifier _ "exports" <- exports
- , JSIdentifier _ name <- nm
- = Just name
- accessor (JSMemberSquare exports _ nm _)
- | JSIdentifier _ "exports" <- exports
- , Just name <- fromStringLiteral nm
- = Just name
- accessor _ = Nothing
+
+-- Matches exports.* or exports["*"] expressions and returns the property name.
+exportsAccessor :: JSExpression -> Maybe String
+exportsAccessor (JSMemberDot exports _ nm)
+ | JSIdentifier _ "exports" <- exports
+ , JSIdentifier _ name <- nm
+ = Just name
+exportsAccessor (JSMemberSquare exports _ nm _)
+ | JSIdentifier _ "exports" <- exports
+ , Just name <- fromStringLiteral nm
+ = Just name
+exportsAccessor _ = Nothing
-- Matches assignments to module.exports, like this:
-- module.exports = { ... }
@@ -395,368 +447,3 @@ extractLabel :: JSPropertyName -> Maybe String
extractLabel (JSPropertyString _ nm) = Just $ strValue nm
extractLabel (JSPropertyIdent _ nm) = Just nm
extractLabel _ = Nothing
-
--- | Eliminate unused code based on the specified entry point set.
-compile :: [Module] -> [ModuleIdentifier] -> [Module]
-compile modules [] = modules
-compile modules entryPoints = filteredModules
- where
- (graph, vertexToNode, vertexFor) = graphFromEdges verts
-
- -- | The vertex set
- verts :: [(ModuleElement, Key, [Key])]
- verts = do
- Module mid _ els <- modules
- concatMap (toVertices mid) els
- where
- -- | Create a set of vertices for a module element.
- --
- -- Some special cases worth commenting on:
- --
- -- 1) Regular exports which simply export their own name do not count as dependencies.
- -- Regular exports which rename and reexport an operator do count, however.
- --
- -- 2) Require statements don't contribute towards dependencies, since they effectively get
- -- inlined wherever they are used inside other module elements.
- toVertices :: ModuleIdentifier -> ModuleElement -> [(ModuleElement, Key, [Key])]
- toVertices p m@(Member _ _ nm _ deps) = [(m, (p, nm), deps)]
- toVertices p m@(ExportsList exps) = mapMaybe toVertex exps
- where
- toVertex (ForeignReexport, nm, _, ks) = Just (m, (p, nm), ks)
- toVertex (RegularExport nm, nm1, _, ks) | nm /= nm1 = Just (m, (p, nm1), ks)
- toVertex _ = Nothing
- toVertices _ _ = []
-
- -- | The set of vertices whose connected components we are interested in keeping.
- entryPointVertices :: [Vertex]
- entryPointVertices = catMaybes $ do
- (_, k@(mid, _), _) <- verts
- guard $ mid `elem` entryPoints
- return (vertexFor k)
-
- -- | The set of vertices reachable from an entry point
- reachableSet :: S.Set Vertex
- reachableSet = S.fromList (concatMap (reachable graph) entryPointVertices)
-
- -- | A map from modules to the modules that are used by its reachable members.
- moduleReferenceMap :: M.Map ModuleIdentifier (S.Set ModuleIdentifier)
- moduleReferenceMap = M.fromAscListWith mappend $ map (vertToModule &&& vertToModuleRefs) $ S.toList reachableSet
- where
- vertToModuleRefs v = foldMap (S.singleton . vertToModule) $ graph ! v
- vertToModule v = m where (_, (m, _), _) = vertexToNode v
-
- filteredModules :: [Module]
- filteredModules = map filterUsed modules
- where
- filterUsed :: Module -> Module
- filterUsed (Module mid fn ds) = Module mid fn (map filterExports (go ds))
- where
- go :: [ModuleElement] -> [ModuleElement]
- go [] = []
- go (d : rest)
- | not (isDeclUsed d) = skipDecl d : go rest
- | otherwise = d : go rest
-
- skipDecl :: ModuleElement -> ModuleElement
- skipDecl (Require s _ _) = Skip s
- skipDecl (Member s _ _ _ _) = Skip s
- skipDecl (ExportsList _) = Skip (JSEmptyStatement JSNoAnnot)
- skipDecl (Other s) = Skip s
- skipDecl (Skip s) = Skip s
-
- -- | Filter out the exports for members which aren't used.
- filterExports :: ModuleElement -> ModuleElement
- filterExports (ExportsList exps) = ExportsList (filter (\(_, nm, _, _) -> isKeyUsed (mid, nm)) exps)
- filterExports me = me
-
- isDeclUsed :: ModuleElement -> Bool
- isDeclUsed (Member _ _ nm _ _) = isKeyUsed (mid, nm)
- isDeclUsed (Require _ _ (Right midRef)) = midRef `S.member` modulesReferenced
- isDeclUsed _ = True
-
- isKeyUsed :: Key -> Bool
- isKeyUsed k
- | Just me <- vertexFor k = me `S.member` reachableSet
- | otherwise = False
-
- modulesReferenced :: S.Set ModuleIdentifier
- modulesReferenced = fold $ M.lookup mid moduleReferenceMap
-
--- | Topologically sort the module dependency graph, so that when we generate code, modules can be
--- defined in the right order.
-sortModules :: [Module] -> [Module]
-sortModules modules = map (\v -> case nodeFor v of (n, _, _) -> n) (reverse (topSort graph))
- where
- (graph, nodeFor, _) = graphFromEdges $ do
- m@(Module mid _ els) <- modules
- return (m, mid, mapMaybe getKey els)
-
- getKey :: ModuleElement -> Maybe ModuleIdentifier
- getKey (Require _ _ (Right mi)) = Just mi
- getKey _ = Nothing
-
--- | A module is empty if it contains no exported members (in other words,
--- if the only things left after dead code elimination are module imports and
--- "other" foreign code).
---
--- If a module is empty, we don't want to generate code for it.
-isModuleEmpty :: Module -> Bool
-isModuleEmpty (Module _ _ els) = all isElementEmpty els
- where
- isElementEmpty :: ModuleElement -> Bool
- isElementEmpty (ExportsList exps) = null exps
- isElementEmpty Require{} = True
- isElementEmpty (Other _) = True
- isElementEmpty (Skip _) = True
- isElementEmpty _ = False
-
--- | Generate code for a set of modules, including a call to main().
---
--- Modules get defined on the global PS object, as follows:
---
--- var PS = { };
--- (function(exports) {
--- ...
--- })(PS["Module.Name"] = PS["Module.Name"] || {});
---
--- In particular, a module and its foreign imports share the same namespace inside PS.
--- This saves us from having to generate unique names for a module and its foreign imports,
--- and is safe since a module shares a namespace with its foreign imports in PureScript as well
--- (so there is no way to have overlaps in code generated by the compiler).
-codeGen :: Maybe String -- ^ main module
- -> String -- ^ namespace
- -> [Module] -- ^ input modules
- -> Maybe String -- ^ output filename
- -> (Maybe SourceMapping, String)
-codeGen optionsMainModule optionsNamespace ms outFileOpt = (fmap sourceMapping outFileOpt, rendered)
- where
- rendered = renderToString (JSAstProgram (prelude : concatMap fst modulesJS ++ maybe [] runMain optionsMainModule) JSNoAnnot)
-
- sourceMapping :: String -> SourceMapping
- sourceMapping outFile = SourceMapping {
- smFile = outFile,
- smSourceRoot = Nothing,
- smMappings = concat $
- zipWith3 (\file (pos :: Int) positions ->
- map (\(porig, pgen) -> Mapping {
- mapOriginal = Just (Pos (fromIntegral $ porig + 1) 0)
- , mapSourceFile = pathToFile <$> file
- , mapGenerated = (Pos (fromIntegral $ pos + pgen) 0)
- , mapName = Nothing
- })
- (offsets (0,0) (Right 1 : positions)))
- moduleFns
- (scanl (+) (3 + moduleLength [prelude]) (map (3+) moduleLengths)) -- 3 lines between each module & at top
- (map snd modulesJS)
- }
- where
- pathToFile = makeRelative (takeDirectory outFile)
-
- offsets (m, n) (Left d:rest) = offsets (m+d, n) rest
- offsets (m, n) (Right d:rest) = map ((m+) &&& (n+)) [0 .. d - 1] ++ offsets (m+d, n+d) rest
- offsets _ _ = []
-
- moduleLength :: [JSStatement] -> Int
- moduleLength = everything (+) (mkQ 0 countw)
- where
- countw :: CommentAnnotation -> Int
- countw (WhiteSpace _ s) = length (filter (== '\n') s)
- countw _ = 0
-
- moduleLengths :: [Int]
- moduleLengths = map (sum . map (either (const 0) id) . snd) modulesJS
- moduleFns = map (\(Module _ fn _) -> fn) ms
-
- modulesJS = map moduleToJS ms
-
- moduleToJS :: Module -> ([JSStatement], [Either Int Int])
- moduleToJS (Module mid _ ds) = (wrap mid (indent (concat jsDecls)), lengths)
- where
- (jsDecls, lengths) = unzip $ map declToJS ds
-
- withLength :: [JSStatement] -> ([JSStatement], Either Int Int)
- withLength n = (n, Right $ moduleLength n)
-
- declToJS :: ModuleElement -> ([JSStatement], Either Int Int)
- declToJS (Member n _ _ _ _) = withLength [n]
- declToJS (Other n) = withLength [n]
- declToJS (Skip n) = ([], Left $ moduleLength [n])
- declToJS (Require _ nm req) = withLength
- [
- JSVariable lfsp
- (cList [
- JSVarInitExpression (JSIdentifier sp nm)
- (JSVarInit sp $ either require (innerModuleReference sp . moduleName) req )
- ]) (JSSemi JSNoAnnot)
- ]
- declToJS (ExportsList exps) = withLength $ map toExport exps
-
- where
-
- toExport :: (ExportType, String, JSExpression, [Key]) -> JSStatement
- toExport (_, nm, val, _) =
- JSAssignStatement
- (JSMemberSquare (JSIdentifier lfsp "exports") JSNoAnnot
- (str nm) JSNoAnnot)
- (JSAssign sp)
- val
- (JSSemi JSNoAnnot)
-
- -- comma lists are reverse-consed
- cList :: [a] -> JSCommaList a
- cList [] = JSLNil
- cList [x] = JSLOne x
- cList l = go $ reverse l
- where
- go [x] = JSLOne x
- go (h:t)= JSLCons (go t) JSNoAnnot h
- go [] = error "Invalid case in comma-list"
-
- indent :: [JSStatement] -> [JSStatement]
- indent = everywhere (mkT squash)
- where
- squash JSNoAnnot = JSAnnot (TokenPn 0 0 2) []
- squash (JSAnnot pos ann) = JSAnnot (keepCol pos) (map splat ann)
- squash JSAnnotSpace = JSAnnot (TokenPn 0 0 2) []
-
- splat (CommentA pos s) = CommentA (keepCol pos) s
- splat (WhiteSpace pos w) = WhiteSpace (keepCol pos) w
- splat ann = ann
-
- keepCol (TokenPn _ _ c) = TokenPn 0 0 (if c >= 0 then c + 2 else 2)
-
- prelude :: JSStatement
- prelude = JSVariable (JSAnnot tokenPosnEmpty [ CommentA tokenPosnEmpty $ "// Generated by purs bundle " ++ showVersion Paths.version
- , WhiteSpace tokenPosnEmpty "\n" ])
- (cList [
- JSVarInitExpression (JSIdentifier sp optionsNamespace)
- (JSVarInit sp (emptyObj sp))
- ]) (JSSemi JSNoAnnot)
-
- require :: String -> JSExpression
- require mn =
- JSMemberExpression (JSIdentifier JSNoAnnot "require") JSNoAnnot (cList [ str mn ]) JSNoAnnot
-
- moduleReference :: JSAnnot -> String -> JSExpression
- moduleReference a mn =
- JSMemberSquare (JSIdentifier a optionsNamespace) JSNoAnnot
- (str mn) JSNoAnnot
-
- innerModuleReference :: JSAnnot -> String -> JSExpression
- innerModuleReference a mn =
- JSMemberSquare (JSIdentifier a "$PS") JSNoAnnot
- (str mn) JSNoAnnot
-
-
- str :: String -> JSExpression
- str s = JSStringLiteral JSNoAnnot $ "\"" ++ s ++ "\""
-
-
- emptyObj :: JSAnnot -> JSExpression
- emptyObj a = JSObjectLiteral a (JSCTLNone JSLNil) JSNoAnnot
-
- initializeObject :: JSAnnot -> (JSAnnot -> String -> JSExpression) -> String -> JSExpression
- initializeObject a makeReference mn =
- JSAssignExpression (makeReference a mn) (JSAssign sp)
- $ JSExpressionBinary (makeReference sp mn) (JSBinOpOr sp)
- $ emptyObj sp
-
- -- Like `somewhere`, but stops after the first successful transformation
- firstwhere :: MonadPlus m => GenericM m -> GenericM m
- firstwhere f x = f x `mplus` gmapMo (firstwhere f) x
-
- prependWhitespace :: String -> [JSStatement] -> [JSStatement]
- prependWhitespace val = fromMaybe <*> firstwhere (mkMp $ Just . reannotate)
- where
- reannotate (JSAnnot rpos annots) = JSAnnot rpos (ws : annots)
- reannotate _ = JSAnnot tokenPosnEmpty [ws]
-
- ws = WhiteSpace tokenPosnEmpty val
-
- iife :: [JSStatement] -> String -> JSExpression -> JSStatement
- iife body param arg =
- JSMethodCall (JSExpressionParen lf (JSFunctionExpression JSNoAnnot JSIdentNone JSNoAnnot (JSLOne (JSIdentName JSNoAnnot param)) JSNoAnnot
- (JSBlock sp (prependWhitespace "\n " body) lf))
- JSNoAnnot)
- JSNoAnnot
- (JSLOne arg)
- JSNoAnnot
- (JSSemi JSNoAnnot)
-
- wrap :: ModuleIdentifier -> [JSStatement] -> [JSStatement]
- wrap (ModuleIdentifier mn mtype) ds =
- case mtype of
- Regular -> [iife (addModuleExports ds) "$PS" (JSIdentifier JSNoAnnot optionsNamespace)]
- Foreign -> [iife ds "exports" (initializeObject JSNoAnnot moduleReference mn)]
- where
- -- Insert the exports var after a directive prologue, if one is present.
- -- Per ECMA-262 5.1, "A Directive Prologue is the longest sequence of
- -- ExpressionStatement productions [...] where each ExpressionStatement
- -- [...] consists entirely of a StringLiteral [...]."
- -- (http://ecma-international.org/ecma-262/5.1/#sec-14.1)
- addModuleExports :: [JSStatement] -> [JSStatement]
- addModuleExports (x:xs) | isDirective x = x : addModuleExports xs
- addModuleExports xs
- = JSExpressionStatement (initializeObject lfsp innerModuleReference mn) (JSSemi JSNoAnnot)
- : JSVariable lfsp (JSLOne $ JSVarInitExpression (JSIdentifier sp "exports") $ JSVarInit sp (innerModuleReference sp mn)) (JSSemi JSNoAnnot)
- : xs
-
- isDirective (JSExpressionStatement (JSStringLiteral _ _) _) = True
- isDirective _ = False
-
- runMain :: String -> [JSStatement]
- runMain mn =
- [JSMethodCall
- (JSMemberDot (moduleReference lf mn) JSNoAnnot
- (JSIdentifier JSNoAnnot "main"))
- JSNoAnnot (cList []) JSNoAnnot (JSSemi JSNoAnnot)]
-
- lf :: JSAnnot
- lf = JSAnnot tokenPosnEmpty [ WhiteSpace tokenPosnEmpty "\n" ]
-
-
- lfsp :: JSAnnot
- lfsp = JSAnnot tokenPosnEmpty [ WhiteSpace tokenPosnEmpty "\n " ]
-
- sp :: JSAnnot
- sp = JSAnnot tokenPosnEmpty [ WhiteSpace tokenPosnEmpty " " ]
-
--- | The bundling function.
--- This function performs dead code elimination, filters empty modules
--- and generates and prints the final JavaScript bundle.
-bundleSM :: (MonadError ErrorMessage m)
- => [(ModuleIdentifier, Maybe FilePath, String)] -- ^ The input modules. Each module should be javascript rendered from the compiler.
- -> [ModuleIdentifier] -- ^ Entry points. These module identifiers are used as the roots for dead-code elimination
- -> Maybe String -- ^ An optional main module.
- -> String -- ^ The namespace (e.g. PS).
- -> Maybe FilePath -- ^ The output file name (if there is one - in which case generate source map)
- -> m (Maybe SourceMapping, String)
-bundleSM inputStrs entryPoints mainModule namespace outFilename = do
- let mid (a,_,_) = a
- forM_ mainModule $ \mname ->
- when (mname `notElem` map (moduleName . mid) inputStrs) (throwError (MissingMainModule mname))
- forM_ entryPoints $ \mIdent ->
- when (mIdent `notElem` map mid inputStrs) (throwError (MissingEntryPoint (moduleName mIdent)))
- input <- forM inputStrs $ \(ident, filename, js) -> do
- ast <- either (throwError . ErrorInModule ident . UnableToParseModule) pure $ parse js (moduleName ident)
- return (ident, filename, ast)
-
- let mids = S.fromList (map (moduleName . mid) input)
-
- modules <- traverse (fmap withDeps . (\(a,fn,c) -> toModule mids a fn c)) input
-
- let compiled = compile modules entryPoints
- sorted = sortModules (filter (not . isModuleEmpty) compiled)
-
- return (codeGen mainModule namespace sorted outFilename)
-
--- | The bundling function.
--- This function performs dead code elimination, filters empty modules
--- and generates and prints the final JavaScript bundle.
-bundle :: (MonadError ErrorMessage m)
- => [(ModuleIdentifier, String)] -- ^ The input modules. Each module should be javascript rendered from the compiler.
- -> [ModuleIdentifier] -- ^ Entry points. These module identifiers are used as the roots for dead-code elimination
- -> Maybe String -- ^ An optional main module.
- -> String -- ^ The namespace (e.g. PS).
- -> m String
-bundle inputStrs entryPoints mainModule namespace = snd <$> bundleSM (map (\(a,b) -> (a,Nothing,b)) inputStrs) entryPoints mainModule namespace Nothing
diff --git a/src/Language/PureScript/CST.hs b/src/Language/PureScript/CST.hs
index 5d1712ee57..b8e895fb20 100644
--- a/src/Language/PureScript/CST.hs
+++ b/src/Language/PureScript/CST.hs
@@ -5,29 +5,37 @@ module Language.PureScript.CST
, parseModulesFromFiles
, unwrapParserError
, toMultipleErrors
+ , toMultipleWarnings
, toPositionedError
+ , toPositionedWarning
, pureResult
, module Language.PureScript.CST.Convert
, module Language.PureScript.CST.Errors
+ , module Language.PureScript.CST.Lexer
+ , module Language.PureScript.CST.Monad
, module Language.PureScript.CST.Parser
+ , module Language.PureScript.CST.Print
, module Language.PureScript.CST.Types
) where
-import Prelude
+import Prelude hiding (lex)
import Control.Monad.Error.Class (MonadError(..))
import Control.Parallel.Strategies (withStrategy, parList, evalTuple2, r0, rseq)
-import qualified Data.List.NonEmpty as NE
+import Data.List.NonEmpty qualified as NE
import Data.Text (Text)
-import qualified Language.PureScript.AST as AST
-import qualified Language.PureScript.Errors as E
+import Language.PureScript.AST qualified as AST
+import Language.PureScript.Errors qualified as E
import Language.PureScript.CST.Convert
import Language.PureScript.CST.Errors
+import Language.PureScript.CST.Lexer
+import Language.PureScript.CST.Monad (Parser, ParserM(..), ParserState(..), LexResult, runParser, runTokenParser)
import Language.PureScript.CST.Parser
+import Language.PureScript.CST.Print
import Language.PureScript.CST.Types
pureResult :: a -> PartialResult a
-pureResult a = PartialResult a (pure a)
+pureResult a = PartialResult a ([], pure a)
parseModulesFromFiles
:: forall m k
@@ -46,18 +54,18 @@ parseFromFiles
. MonadError E.MultipleErrors m
=> (k -> FilePath)
-> [(k, Text)]
- -> m [(k, AST.Module)]
+ -> m [(k, ([ParserWarning], AST.Module))]
parseFromFiles toFilePath input =
flip E.parU (handleParserError toFilePath)
. inParallel
. flip fmap input
- $ \(k, a) -> (k, parseFromFile (toFilePath k) a)
+ $ \(k, a) -> (k, sequence $ parseFromFile (toFilePath k) a)
parseModuleFromFile :: FilePath -> Text -> Either (NE.NonEmpty ParserError) (PartialResult AST.Module)
-parseModuleFromFile fp content = fmap (convertModule fp) <$> parseModule content
+parseModuleFromFile fp content = fmap (convertModule fp) <$> parseModule (lexModule content)
-parseFromFile :: FilePath -> Text -> Either (NE.NonEmpty ParserError) AST.Module
-parseFromFile fp content = convertModule fp <$> parse content
+parseFromFile :: FilePath -> Text -> ([ParserWarning], Either (NE.NonEmpty ParserError) AST.Module)
+parseFromFile fp content = fmap (convertModule fp) <$> parse content
handleParserError
:: forall m k a
@@ -81,9 +89,17 @@ toMultipleErrors :: FilePath -> NE.NonEmpty ParserError -> E.MultipleErrors
toMultipleErrors fp =
E.MultipleErrors . NE.toList . fmap (toPositionedError fp)
+toMultipleWarnings :: FilePath -> [ParserWarning] -> E.MultipleErrors
+toMultipleWarnings fp =
+ E.MultipleErrors . fmap (toPositionedWarning fp)
+
toPositionedError :: FilePath -> ParserError -> E.ErrorMessage
toPositionedError name perr =
E.ErrorMessage [E.positionedError $ sourceSpan name $ errRange perr] (E.ErrorParsingCSTModule perr)
+toPositionedWarning :: FilePath -> ParserWarning -> E.ErrorMessage
+toPositionedWarning name perr =
+ E.ErrorMessage [E.positionedError $ sourceSpan name $ errRange perr] (E.WarningParsingCSTModule perr)
+
inParallel :: [(k, Either (NE.NonEmpty ParserError) a)] -> [(k, Either (NE.NonEmpty ParserError) a)]
inParallel = withStrategy (parList (evalTuple2 r0 rseq))
diff --git a/src/Language/PureScript/CST/Convert.hs b/src/Language/PureScript/CST/Convert.hs
index ee13244881..db1a5ff5ff 100644
--- a/src/Language/PureScript/CST/Convert.hs
+++ b/src/Language/PureScript/CST/Convert.hs
@@ -3,11 +3,11 @@
-- and attaching comments.
module Language.PureScript.CST.Convert
- ( convertKind
- , convertType
+ ( convertType
, convertExpr
, convertBinder
, convertDeclaration
+ , convertImportDecl
, convertModule
, sourcePos
, sourceSpan
@@ -15,31 +15,35 @@ module Language.PureScript.CST.Convert
, comments
) where
-import Prelude
+import Prelude hiding (take)
+import Protolude (headDef)
import Data.Bifunctor (bimap, first)
+import Data.Char (toLower)
import Data.Foldable (foldl', toList)
import Data.Functor (($>))
-import qualified Data.List.NonEmpty as NE
+import Data.List.NonEmpty qualified as NE
import Data.Maybe (isJust, fromJust, mapMaybe)
-import qualified Data.Text as Text
-import qualified Language.PureScript.AST as AST
-import qualified Language.PureScript.AST.SourcePos as Pos
-import qualified Language.PureScript.Comments as C
-import qualified Language.PureScript.Environment as Env
-import qualified Language.PureScript.Kinds as K
-import qualified Language.PureScript.Label as L
-import qualified Language.PureScript.Names as N
-import Language.PureScript.PSString (mkString)
-import qualified Language.PureScript.Types as T
+import Data.Text qualified as Text
+import Language.PureScript.AST qualified as AST
+import Language.PureScript.AST.Declarations.ChainId (mkChainId)
+import Language.PureScript.AST.SourcePos qualified as Pos
+import Language.PureScript.Comments qualified as C
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment qualified as Env
+import Language.PureScript.Label qualified as L
+import Language.PureScript.Names qualified as N
+import Language.PureScript.PSString (mkString, prettyPrintStringJS)
+import Language.PureScript.Types qualified as T
import Language.PureScript.CST.Positions
+import Language.PureScript.CST.Print (printToken)
import Language.PureScript.CST.Types
comment :: Comment a -> Maybe C.Comment
comment = \case
Comment t
- | Text.isPrefixOf "{-" t -> Just $ C.BlockComment $ Text.drop 2 $ Text.dropEnd 2 t
- | Text.isPrefixOf "--" t -> Just $ C.LineComment $ Text.drop 2 t
+ | "{-" `Text.isPrefixOf` t -> Just $ C.BlockComment $ Text.drop 2 $ Text.dropEnd 2 t
+ | "--" `Text.isPrefixOf` t -> Just $ C.LineComment $ Text.drop 2 t
_ -> Nothing
comments :: [Comment a] -> [C.Comment]
@@ -84,36 +88,24 @@ moduleName = \case
_ -> Nothing
where
go [] = Nothing
- go ns = Just $ N.ModuleName $ N.ProperName <$> ns
+ go ns = Just $ N.ModuleName $ Text.intercalate "." ns
qualified :: QualifiedName a -> N.Qualified a
-qualified q = N.Qualified (qualModule q) (qualName q)
+qualified q = N.Qualified qb (qualName q)
+ where
+ qb = maybe N.ByNullSourcePos N.ByModuleName $ qualModule q
ident :: Ident -> N.Ident
ident = N.Ident . getIdent
-convertKind :: String -> Kind a -> K.SourceKind
-convertKind fileName = go
- where
- go = \case
- KindName _ a ->
- K.NamedKind (sourceQualName fileName a) $ qualified a
- KindArr _ a _ b -> do
- let
- lhs = go a
- rhs = go b
- ann = Pos.widenSourceAnn (K.getAnnForKind lhs) (K.getAnnForKind rhs)
- K.FunKind ann lhs rhs
- KindRow _ tok a -> do
- let
- kind = go a
- ann = widenLeft (tokAnn tok) $ K.getAnnForKind kind
- K.Row ann kind
- KindParens _ (Wrapped _ a _) ->
- go a
-
convertType :: String -> Type a -> T.SourceType
-convertType fileName = go
+convertType = convertType' False
+
+convertVtaType :: String -> Type a -> T.SourceType
+convertVtaType = convertType' True
+
+convertType' :: Bool -> String -> Type a -> T.SourceType
+convertType' withinVta fileName = go
where
goRow (Row labels tl) b = do
let
@@ -135,11 +127,13 @@ convertType fileName = go
TypeConstructor _ a ->
T.TypeConstructor (sourceQualName fileName a) $ qualified a
TypeWildcard _ a ->
- T.TypeWildcard (sourceAnnCommented fileName a a) Nothing
+ T.TypeWildcard (sourceAnnCommented fileName a a) $ if withinVta then T.IgnoredWildcard else T.UnnamedWildcard
TypeHole _ a ->
- T.TypeWildcard (sourceName fileName a) . Just . getIdent $ nameValue a
+ T.TypeWildcard (sourceName fileName a) . T.HoleWildcard . getIdent $ nameValue a
TypeString _ a b ->
- T.TypeLevelString (sourceAnnCommented fileName a a) $ b
+ T.TypeLevelString (sourceAnnCommented fileName a a) b
+ TypeInt _ _ a b ->
+ T.TypeLevelInt (sourceAnnCommented fileName a a) b
TypeRow _ (Wrapped _ row b) ->
goRow row b
TypeRecord _ (Wrapped a row b) -> do
@@ -149,20 +143,19 @@ convertType fileName = go
T.TypeApp ann (Env.tyRecord $> annRec) $ goRow row b
TypeForall _ kw bindings _ ty -> do
let
- mkForAll a b t = do
+ mkForAll a b v t = do
let ann' = widenLeft (tokAnn $ nameTok a) $ T.getAnnForType t
- T.ForAll ann' (getIdent $ nameValue a) b t Nothing
- k t (TypeVarKinded (Wrapped _ (Labeled a _ b) _)) = mkForAll a (Just (convertKind fileName b)) t
- k t (TypeVarName a) = mkForAll a Nothing t
- -- The existing parser builds variables in reverse order
- ty' = foldl k (go ty) bindings
+ T.ForAll ann' (maybe T.TypeVarInvisible (const T.TypeVarVisible) v) (getIdent $ nameValue a) b t Nothing
+ k (TypeVarKinded (Wrapped _ (Labeled (v, a) _ b) _)) = mkForAll a (Just (go b)) v
+ k (TypeVarName (v, a)) = mkForAll a Nothing v
+ ty' = foldr k (go ty) bindings
ann = widenLeft (tokAnn kw) $ T.getAnnForType ty'
T.setAnnForType ann ty'
TypeKinded _ ty _ kd -> do
let
ty' = go ty
- kd' = convertKind fileName kd
- ann = Pos.widenSourceAnn (T.getAnnForType ty') (K.getAnnForKind kd')
+ kd' = go kd
+ ann = Pos.widenSourceAnn (T.getAnnForType ty') (T.getAnnForType kd')
T.KindedType ann ty' kd'
TypeApp _ a b -> do
let
@@ -196,20 +189,26 @@ convertType fileName = go
Env.tyFunction $> sourceAnnCommented fileName a a
TypeConstrained _ a _ b -> do
let
- a' = convertConstraint fileName a
+ a' = convertConstraint withinVta fileName a
b' = go b
ann = Pos.widenSourceAnn (T.constraintAnn a') (T.getAnnForType b')
T.ConstrainedType ann a' b'
TypeParens _ (Wrapped a ty b) ->
T.ParensInType (sourceAnnCommented fileName a b) $ go ty
+ ty@(TypeUnaryRow _ _ a) -> do
+ let
+ a' = go a
+ rng = typeRange ty
+ ann = uncurry (sourceAnnCommented fileName) rng
+ T.setAnnForType ann $ Env.kindRow a'
-convertConstraint :: String -> Constraint a -> T.SourceConstraint
-convertConstraint fileName = go
+convertConstraint :: Bool -> String -> Constraint a -> T.SourceConstraint
+convertConstraint withinVta fileName = go
where
go = \case
cst@(Constraint _ name args) -> do
let ann = uncurry (sourceAnnCommented fileName) $ constraintRange cst
- T.Constraint ann (qualified name) (convertType fileName <$> args) Nothing
+ T.Constraint ann (qualified name) [] (convertType' withinVta fileName <$> args) Nothing
ConstraintParens _ (Wrapped _ c _) -> go c
convertGuarded :: String -> Guarded a -> [AST.GuardedExpr]
@@ -343,6 +342,9 @@ convertExpr fileName = go
expr@(ExprApp _ a b) -> do
let ann = uncurry (sourceAnn fileName) $ exprRange expr
positioned ann $ AST.App (go a) (go b)
+ expr@(ExprVisibleTypeApp _ a _ b) -> do
+ let ann = uncurry (sourceAnn fileName) $ exprRange expr
+ positioned ann $ AST.VisibleTypeApp (go a) (convertVtaType fileName b)
expr@(ExprLambda _ (Lambda _ as _ b)) -> do
let ann = uncurry (sourceAnnCommented fileName) $ exprRange expr
positioned ann
@@ -443,25 +445,30 @@ convertBinder fileName = go
convertDeclaration :: String -> Declaration a -> [AST.Declaration]
convertDeclaration fileName decl = case decl of
- DeclData _ (DataHead _ a vars) bd -> do
+ DeclData _ (DataHead _ a vars) bd deriveClauses -> do
let
- ctr (DataCtor _ x ys) = (nameValue x, zip ctrFields $ convertType fileName <$> ys)
- ctrs = case bd of
- Nothing -> []
- Just (_, cs) -> ctr <$> toList cs
- pure $ AST.DataDeclaration ann Env.Data (nameValue a) (goTypeVar <$> vars) ctrs
+ ctrs :: SourceToken -> DataCtor b -> [(SourceToken, DataCtor b)] -> [AST.DataConstructorDeclaration]
+ ctrs st (DataCtor _ name fields) tl
+ = AST.DataConstructorDeclaration (sourceAnnCommented fileName st (nameTok name)) (nameValue name) (zip ctrFields $ convertType fileName <$> fields)
+ : (case tl of
+ [] -> []
+ (st', ctor) : tl' -> ctrs st' ctor tl'
+ )
+ AST.DataDeclaration ann Env.Data (nameValue a) (goTypeVar <$> vars) (maybe [] (\(st, Separated hd tl) -> ctrs st hd tl) bd)
+ : convertDeriveClauses fileName (nameValue a) deriveClauses
DeclType _ (DataHead _ a vars) _ bd ->
pure $ AST.TypeSynonymDeclaration ann
(nameValue a)
(goTypeVar <$> vars)
(convertType fileName bd)
- DeclNewtype _ (DataHead _ a vars) _ x ys -> do
- let ctrs = [(nameValue x, [(head ctrFields, convertType fileName ys)])]
- pure $ AST.DataDeclaration ann Env.Newtype (nameValue a) (goTypeVar <$> vars) ctrs
+ DeclNewtype _ (DataHead _ a vars) st x ys deriveClauses -> do
+ let ctrs = [AST.DataConstructorDeclaration (sourceAnnCommented fileName st (snd $ declRange decl)) (nameValue x) [(headDef (internalError "No constructor name") ctrFields, convertType fileName ys)]]
+ AST.DataDeclaration ann Env.Newtype (nameValue a) (goTypeVar <$> vars) ctrs
+ : convertDeriveClauses fileName (nameValue a) deriveClauses
DeclClass _ (ClassHead _ sup name vars fdeps) bd -> do
let
- goTyVar (TypeVarKinded (Wrapped _ (Labeled a _ _) _)) = nameValue a
- goTyVar (TypeVarName a) = nameValue a
+ goTyVar (TypeVarKinded (Wrapped _ (Labeled (_, a) _ _) _)) = nameValue a
+ goTyVar (TypeVarName (_, a)) = nameValue a
vars' = zip (toList $ goTyVar <$> vars) [0..]
goName = fromJust . flip lookup vars' . nameValue
goFundep (FundepDetermined _ bs) = Env.FunctionalDependency [] (goName <$> NE.toList bs)
@@ -474,33 +481,44 @@ convertDeclaration fileName decl = case decl of
pure $ AST.TypeClassDeclaration ann
(nameValue name)
(goTypeVar <$> vars)
- (convertConstraint fileName <$> maybe [] (toList . fst) sup)
+ (convertConstraint False fileName <$> maybe [] (toList . fst) sup)
(goFundep <$> maybe [] (toList . snd) fdeps)
(goSig <$> maybe [] (NE.toList . snd) bd)
DeclInstanceChain _ insts -> do
let
- instName (Instance (InstanceHead _ a _ _ _ _) _) = ident $ nameValue a
- chainId = instName <$> toList insts
- goInst ix inst@(Instance (InstanceHead _ name _ ctrs cls args) bd) = do
+ chainId = mkChainId fileName $ startSourcePos $ instKeyword $ instHead $ sepHead insts
+ goInst ix inst@(Instance (InstanceHead _ nameSep ctrs cls args) bd) = do
let ann' = uncurry (sourceAnnCommented fileName) $ instanceRange inst
- AST.TypeInstanceDeclaration ann' chainId ix
- (ident $ nameValue name)
- (convertConstraint fileName <$> maybe [] (toList . fst) ctrs)
+ clsAnn = findInstanceAnn cls args
+ AST.TypeInstanceDeclaration ann' clsAnn chainId ix
+ (mkPartialInstanceName nameSep cls args)
+ (convertConstraint False fileName <$> maybe [] (toList . fst) ctrs)
(qualified cls)
(convertType fileName <$> args)
(AST.ExplicitInstance $ goInstanceBinding <$> maybe [] (NE.toList . snd) bd)
uncurry goInst <$> zip [0..] (toList insts)
- DeclDerive _ _ new (InstanceHead _ name _ ctrs cls args) -> do
+ DeclDerive _ _ new (InstanceHead kw nameSep ctrs cls args) -> do
let
- name' = ident $ nameValue name
+ chainId = mkChainId fileName $ startSourcePos kw
+ name' = mkPartialInstanceName nameSep cls args
instTy
| isJust new = AST.NewtypeInstance
| otherwise = AST.DerivedInstance
- pure $ AST.TypeInstanceDeclaration ann [name'] 0 name'
- (convertConstraint fileName <$> maybe [] (toList . fst) ctrs)
+ clsAnn = findInstanceAnn cls args
+ pure $ AST.TypeInstanceDeclaration ann clsAnn chainId 0 name'
+ (convertConstraint False fileName <$> maybe [] (toList . fst) ctrs)
(qualified cls)
(convertType fileName <$> args)
instTy
+ DeclKindSignature _ kw (Labeled name _ ty) -> do
+ let
+ kindFor = case tokValue kw of
+ TokLowerName [] "data" -> AST.DataSig
+ TokLowerName [] "newtype" -> AST.NewtypeSig
+ TokLowerName [] "type" -> AST.TypeSynonymSig
+ TokLowerName [] "class" -> AST.ClassSig
+ tok -> internalError $ "Invalid kind signature keyword " <> Text.unpack (printToken tok)
+ pure . AST.KindDeclaration ann kindFor (nameValue name) $ convertType fileName ty
DeclSignature _ lbl ->
pure $ convertSignature fileName lbl
DeclValue _ fields ->
@@ -522,16 +540,56 @@ convertDeclaration fileName decl = case decl of
ForeignValue (Labeled a _ b) ->
AST.ExternDeclaration ann (ident $ nameValue a) $ convertType fileName b
ForeignData _ (Labeled a _ b) ->
- AST.ExternDataDeclaration ann (nameValue a) $ convertKind fileName b
+ AST.ExternDataDeclaration ann (nameValue a) $ convertType fileName b
ForeignKind _ a ->
- AST.ExternKindDeclaration ann (nameValue a)
+ AST.DataDeclaration ann Env.Data (nameValue a) [] []
+ DeclRole _ _ _ name roles ->
+ pure $ AST.RoleDeclaration $
+ AST.RoleDeclarationData ann (nameValue name) (roleValue <$> NE.toList roles)
where
ann =
uncurry (sourceAnnCommented fileName) $ declRange decl
+ startSourcePos :: SourceToken -> Pos.SourcePos
+ startSourcePos = sourcePos . srcStart . tokRange . tokAnn
+
+ mkPartialInstanceName :: Maybe (Name Ident, SourceToken) -> QualifiedName (N.ProperName 'N.ClassName) -> [Type a] -> Either Text.Text N.Ident
+ mkPartialInstanceName nameSep cls args =
+ maybe (Left (genInstanceName cls (foldMap argName args))) (Right . ident . nameValue . fst) nameSep
+ where
+ argName :: Type a -> Text.Text
+ argName = \case
+ -- These are only useful to disambiguate between overlapping instances
+ -- but they’re disallowed outside of instance chains. Since we’re
+ -- avoiding name collisions with unique identifiers anyway,
+ -- we don't need to render this constructor.
+ TypeVar{} -> ""
+ TypeConstructor _ qn -> N.runProperName $ qualName qn
+ TypeOpName _ qn -> N.runOpName $ qualName qn
+ TypeString _ _ ps -> prettyPrintStringJS ps
+ TypeInt _ _ _ nt -> Text.pack $ show nt
+
+ -- Typed holes are disallowed in instance heads
+ TypeHole{} -> ""
+ TypeParens _ t -> argName $ wrpValue t
+ TypeKinded _ t1 _ t2 -> argName t1 <> argName t2
+ TypeRecord _ _ -> "Record"
+ TypeRow _ _ -> "Row"
+ TypeArrName _ _ -> "Function"
+ TypeWildcard{} -> "_"
+
+ -- Polytypes are disallowed in instance heads
+ TypeForall{} -> ""
+ TypeApp _ t1 t2 -> argName t1 <> argName t2
+ TypeOp _ t1 op t2 ->
+ argName t1 <> N.runOpName (qualName op) <> argName t2
+ TypeArr _ t1 _ t2 -> argName t1 <> "Function" <> argName t2
+ TypeConstrained{} -> ""
+ TypeUnaryRow{} -> "Row"
+
goTypeVar = \case
- TypeVarKinded (Wrapped _ (Labeled x _ y) _) -> (getIdent $ nameValue x, Just $ convertKind fileName y)
- TypeVarName x -> (getIdent $ nameValue x, Nothing)
+ TypeVarKinded (Wrapped _ (Labeled (_, x) _ y) _) -> (getIdent $ nameValue x, Just $ convertType fileName y)
+ TypeVarName (_, x) -> (getIdent $ nameValue x, Nothing)
goInstanceBinding = \case
InstanceBindingSignature _ lbl ->
@@ -540,6 +598,42 @@ convertDeclaration fileName decl = case decl of
let ann' = uncurry (sourceAnnCommented fileName) $ instanceBindingRange binding
convertValueBindingFields fileName ann' fields
+ findInstanceAnn cls args = uncurry (sourceAnnCommented fileName) $
+ if null args then
+ qualRange cls
+ else
+ (fst $ qualRange cls, snd $ typeRange $ last args)
+
+convertDeriveClauses
+ :: String
+ -> N.ProperName 'N.TypeName
+ -> [DeriveClause]
+ -> [AST.Declaration]
+convertDeriveClauses fileName tyName = concatMap go
+ where
+ go (DeriveClause _ (Wrapped _ classes _)) = map convertClass (toList classes)
+ convertClass (DeriveClass cls) =
+ AST.TypeInstanceDeclaration clsAnn clsAnn chainId 0 (Left genName)
+ []
+ (qualified cls)
+ [tyCon]
+ AST.DerivedInstance
+ where
+ clsAnn = uncurry (sourceAnnCommented fileName) (qualRange cls)
+ chainId = mkChainId fileName (Pos.spanStart (fst clsAnn))
+ tyCon = T.TypeConstructor clsAnn (N.Qualified N.ByNullSourcePos tyName)
+ genName = genInstanceName cls (N.runProperName tyName)
+
+genInstanceName :: QualifiedName (N.ProperName 'N.ClassName) -> Text.Text -> Text.Text
+genInstanceName cls typeArgs = Text.take 25 (className <> typeArgs)
+ where
+ className :: Text.Text
+ className
+ = foldMap (uncurry Text.cons . first toLower)
+ . Text.uncons
+ . N.runProperName
+ $ qualName cls
+
convertSignature :: String -> Labeled (Name Ident) (Type a) -> AST.Declaration
convertSignature fileName (Labeled a _ b) = do
let
@@ -554,18 +648,21 @@ convertValueBindingFields fileName ann (ValueBindingFields a bs c) = do
cs' = convertGuarded fileName c
AST.ValueDeclaration $ AST.ValueDeclarationData ann (ident $ nameValue a) Env.Public bs' cs'
-convertImportDecl :: String -> ImportDecl a -> AST.Declaration
+convertImportDecl
+ :: String
+ -> ImportDecl a
+ -> (Pos.SourceAnn, N.ModuleName, AST.ImportDeclarationType, Maybe N.ModuleName)
convertImportDecl fileName decl@(ImportDecl _ _ modName mbNames mbQual) = do
let
ann = uncurry (sourceAnnCommented fileName) $ importDeclRange decl
importTy = case mbNames of
Nothing -> AST.Implicit
- Just (hiding, (Wrapped _ imps _)) -> do
+ Just (hiding, Wrapped _ imps _) -> do
let imps' = convertImport fileName <$> toList imps
if isJust hiding
then AST.Hiding imps'
else AST.Explicit imps'
- AST.ImportDeclaration ann (nameValue modName) importTy (nameValue . snd <$> mbQual)
+ (ann, nameValue modName, importTy, nameValue . snd <$> mbQual)
convertImport :: String -> Import a -> AST.DeclarationRef
convertImport fileName imp = case imp of
@@ -586,8 +683,6 @@ convertImport fileName imp = case imp of
AST.TypeOpRef ann $ nameValue a
ImportClass _ _ a ->
AST.TypeClassRef ann $ nameValue a
- ImportKind _ _ a ->
- AST.KindRef ann $ nameValue a
where
ann = sourceSpan fileName . toSourceRange $ importRange imp
@@ -610,8 +705,6 @@ convertExport fileName export = case export of
AST.TypeOpRef ann $ nameValue a
ExportClass _ _ a ->
AST.TypeClassRef ann $ nameValue a
- ExportKind _ _ a ->
- AST.KindRef ann $ nameValue a
ExportModule _ _ a ->
AST.ModuleRef ann (nameValue a)
where
@@ -621,10 +714,12 @@ convertModule :: String -> Module a -> AST.Module
convertModule fileName module'@(Module _ _ modName exps _ imps decls _) = do
let
ann = uncurry (sourceAnnCommented fileName) $ moduleRange module'
- imps' = convertImportDecl fileName <$> imps
+ imps' = importCtr. convertImportDecl fileName <$> imps
decls' = convertDeclaration fileName =<< decls
exps' = map (convertExport fileName) . toList . wrpValue <$> exps
uncurry AST.Module ann (nameValue modName) (imps' <> decls') exps'
+ where
+ importCtr (a, b, c, d) = AST.ImportDeclaration a b c d
ctrFields :: [N.Ident]
ctrFields = [N.Ident ("value" <> Text.pack (show (n :: Integer))) | n <- [0..]]
diff --git a/src/Language/PureScript/CST/Errors.hs b/src/Language/PureScript/CST/Errors.hs
index 01c9879e5e..3682f2f0a5 100644
--- a/src/Language/PureScript/CST/Errors.hs
+++ b/src/Language/PureScript/CST/Errors.hs
@@ -1,22 +1,29 @@
-{-# LANGUAGE NamedFieldPuns #-}
+{-# LANGUAGE DeriveAnyClass #-}
module Language.PureScript.CST.Errors
- ( ParserError(..)
+ ( ParserErrorInfo(..)
, ParserErrorType(..)
+ , ParserWarningType(..)
+ , ParserError
+ , ParserWarning
, prettyPrintError
, prettyPrintErrorMessage
+ , prettyPrintWarningMessage
) where
import Prelude
-import qualified Data.Text as Text
+import Control.DeepSeq (NFData)
+import Data.Text qualified as Text
import Data.Char (isSpace, toUpper)
-import Language.PureScript.CST.Layout
-import Language.PureScript.CST.Print
-import Language.PureScript.CST.Types
+import GHC.Generics (Generic)
+import Language.PureScript.CST.Layout (LayoutStack)
+import Language.PureScript.CST.Print (printToken)
+import Language.PureScript.CST.Types (SourcePos(..), SourceRange(..), SourceToken(..), Token(..))
import Text.Printf (printf)
data ParserErrorType
= ErrWildcardInType
+ | ErrConstraintInKind
| ErrHoleInType
| ErrExprInBinder
| ErrExprInDeclOrBinder
@@ -33,6 +40,7 @@ data ParserErrorType
| ErrGuardInLetBinder
| ErrKeywordVar
| ErrKeywordSymbol
+ | ErrQuotedPun
| ErrToken
| ErrLineFeedInString
| ErrAstralCodePointInChar
@@ -48,18 +56,31 @@ data ParserErrorType
| ErrQualifiedName
| ErrEmptyDo
| ErrLexeme (Maybe String) [String]
+ | ErrConstraintInForeignImportSyntax
| ErrEof
- deriving (Show, Eq, Ord)
+ | ErrCustom String
+ deriving (Show, Eq, Ord, Generic, NFData)
-data ParserError = ParserError
+data ParserWarningType
+ = WarnDeprecatedRowSyntax
+ | WarnDeprecatedForeignKindSyntax
+ | WarnDeprecatedKindImportSyntax
+ | WarnDeprecatedKindExportSyntax
+ | WarnDeprecatedCaseOfOffsideSyntax
+ deriving (Show, Eq, Ord, Generic, NFData)
+
+data ParserErrorInfo a = ParserErrorInfo
{ errRange :: SourceRange
, errToks :: [SourceToken]
, errStack :: LayoutStack
- , errType :: ParserErrorType
- } deriving (Show, Eq)
+ , errType :: a
+ } deriving (Show, Eq, Generic, NFData)
+
+type ParserError = ParserErrorInfo ParserErrorType
+type ParserWarning = ParserErrorInfo ParserWarningType
prettyPrintError :: ParserError -> String
-prettyPrintError pe@(ParserError { errRange }) =
+prettyPrintError pe@ParserErrorInfo { errRange } =
prettyPrintErrorMessage pe <> " at " <> errPos
where
errPos = case errRange of
@@ -67,9 +88,11 @@ prettyPrintError pe@(ParserError { errRange }) =
"line " <> show line <> ", column " <> show col
prettyPrintErrorMessage :: ParserError -> String
-prettyPrintErrorMessage (ParserError {..}) = case errType of
+prettyPrintErrorMessage ParserErrorInfo {..} = case errType of
ErrWildcardInType ->
"Unexpected wildcard in type; type wildcards are only allowed in value annotations"
+ ErrConstraintInKind ->
+ "Unsupported constraint in kind; constraints are only allowed in value annotations"
ErrHoleInType ->
"Unexpected hole in type; type holes are only allowed in value annotations"
ErrExprInBinder ->
@@ -102,6 +125,8 @@ prettyPrintErrorMessage (ParserError {..}) = case errType of
"Expected variable, saw keyword"
ErrKeywordSymbol ->
"Expected symbol, saw reserved symbol"
+ ErrQuotedPun ->
+ "Unexpected quoted label in record pun, perhaps due to a missing ':'"
ErrEof ->
"Unexpected end of input"
ErrLexeme (Just (hd : _)) _ | isSpace hd ->
@@ -136,11 +161,15 @@ prettyPrintErrorMessage (ParserError {..}) = case errType of
"Expected do statement"
ErrLexeme _ _ ->
basicError
+ ErrConstraintInForeignImportSyntax ->
+ "Constraints are not allowed in foreign imports. Omit the constraint instead and update the foreign module accordingly."
ErrToken
| SourceToken _ (TokLeftArrow _) : _ <- errToks ->
"Unexpected \"<-\" in expression, perhaps due to a missing 'do' or 'ado' keyword"
ErrToken ->
basicError
+ ErrCustom err ->
+ err
where
basicError = case errToks of
@@ -157,3 +186,16 @@ prettyPrintErrorMessage (ParserError {..}) = case errType of
displayCodePoint :: Char -> String
displayCodePoint x =
"U+" <> map toUpper (printf "%0.4x" (fromEnum x))
+
+prettyPrintWarningMessage :: ParserWarning -> String
+prettyPrintWarningMessage ParserErrorInfo {..} = case errType of
+ WarnDeprecatedRowSyntax ->
+ "Unary '#' syntax for row kinds is deprecated and will be removed in a future release. Use the 'Row' kind instead."
+ WarnDeprecatedForeignKindSyntax ->
+ "Foreign kind imports are deprecated and will be removed in a future release. Use empty 'data' instead."
+ WarnDeprecatedKindImportSyntax ->
+ "Kind imports are deprecated and will be removed in a future release. Omit the 'kind' keyword instead."
+ WarnDeprecatedKindExportSyntax ->
+ "Kind exports are deprecated and will be removed in a future release. Omit the 'kind' keyword instead."
+ WarnDeprecatedCaseOfOffsideSyntax ->
+ "Dedented expressions in case branches are deprecated and will be removed in a future release. Indent the branch's expression past it's binder instead."
diff --git a/src/Language/PureScript/CST/Flatten.hs b/src/Language/PureScript/CST/Flatten.hs
new file mode 100644
index 0000000000..3f2e4cda94
--- /dev/null
+++ b/src/Language/PureScript/CST/Flatten.hs
@@ -0,0 +1,326 @@
+module Language.PureScript.CST.Flatten where
+
+import Prelude
+
+import Data.DList (DList)
+import Language.PureScript.CST.Types
+import Language.PureScript.CST.Positions (advanceLeading, moduleRange, srcRange)
+
+flattenModule :: Module a -> DList SourceToken
+flattenModule m@(Module _ a b c d e f g) =
+ pure a <>
+ flattenName b <>
+ foldMap (flattenWrapped (flattenSeparated flattenExport)) c <>
+ pure d <>
+ foldMap flattenImportDecl e <>
+ foldMap flattenDeclaration f <>
+ pure (SourceToken (TokenAnn eofRange g []) TokEof)
+ where
+ (_, endTkn) = moduleRange m
+ eofPos = advanceLeading (srcEnd (srcRange endTkn)) g
+ eofRange = SourceRange eofPos eofPos
+
+flattenDataHead :: DataHead a -> DList SourceToken
+flattenDataHead (DataHead a b c) = pure a <> flattenName b <> foldMap flattenTypeVarBinding c
+
+flattenDataCtor :: DataCtor a -> DList SourceToken
+flattenDataCtor (DataCtor _ a b) = flattenName a <> foldMap flattenType b
+
+flattenClassHead :: ClassHead a -> DList SourceToken
+flattenClassHead (ClassHead a b c d e) =
+ pure a <>
+ foldMap (\(f, g) -> flattenOneOrDelimited flattenConstraint f <> pure g) b <>
+ flattenName c <>
+ foldMap flattenTypeVarBinding d <>
+ foldMap (\(f, g) -> pure f <> flattenSeparated flattenClassFundep g) e
+
+flattenClassFundep :: ClassFundep -> DList SourceToken
+flattenClassFundep = \case
+ FundepDetermined a b ->
+ pure a <> foldMap flattenName b
+ FundepDetermines a b c ->
+ foldMap flattenName a <> pure b <> foldMap flattenName c
+
+flattenInstance :: Instance a -> DList SourceToken
+flattenInstance (Instance a b) =
+ flattenInstanceHead a <> foldMap (\(c, d) -> pure c <> foldMap flattenInstanceBinding d) b
+
+flattenInstanceHead :: InstanceHead a -> DList SourceToken
+flattenInstanceHead (InstanceHead a b c d e) =
+ pure a <>
+ foldMap (\(n, s) -> flattenName n <> pure s) b <>
+ foldMap (\(g, h) -> flattenOneOrDelimited flattenConstraint g <> pure h) c <>
+ flattenQualifiedName d <>
+ foldMap flattenType e
+
+flattenInstanceBinding :: InstanceBinding a -> DList SourceToken
+flattenInstanceBinding = \case
+ InstanceBindingSignature _ a -> flattenLabeled flattenName flattenType a
+ InstanceBindingName _ a -> flattenValueBindingFields a
+
+flattenValueBindingFields :: ValueBindingFields a -> DList SourceToken
+flattenValueBindingFields (ValueBindingFields a b c) =
+ flattenName a <>
+ foldMap flattenBinder b <>
+ flattenGuarded c
+
+flattenBinder :: Binder a -> DList SourceToken
+flattenBinder = \case
+ BinderWildcard _ a -> pure a
+ BinderVar _ a -> flattenName a
+ BinderNamed _ a b c -> flattenName a <> pure b <> flattenBinder c
+ BinderConstructor _ a b -> flattenQualifiedName a <> foldMap flattenBinder b
+ BinderBoolean _ a _ -> pure a
+ BinderChar _ a _ -> pure a
+ BinderString _ a _ -> pure a
+ BinderNumber _ a b _ -> foldMap pure a <> pure b
+ BinderArray _ a -> flattenWrapped (foldMap (flattenSeparated flattenBinder)) a
+ BinderRecord _ a ->
+ flattenWrapped (foldMap (flattenSeparated (flattenRecordLabeled flattenBinder))) a
+ BinderParens _ a -> flattenWrapped flattenBinder a
+ BinderTyped _ a b c -> flattenBinder a <> pure b <> flattenType c
+ BinderOp _ a b c -> flattenBinder a <> flattenQualifiedName b <> flattenBinder c
+
+flattenRecordLabeled :: (a -> DList SourceToken) -> RecordLabeled a -> DList SourceToken
+flattenRecordLabeled f = \case
+ RecordPun a -> flattenName a
+ RecordField a b c -> flattenLabel a <> pure b <> f c
+
+flattenRecordAccessor :: RecordAccessor a -> DList SourceToken
+flattenRecordAccessor (RecordAccessor a b c) =
+ flattenExpr a <> pure b <> flattenSeparated flattenLabel c
+
+flattenRecordUpdate :: RecordUpdate a -> DList SourceToken
+flattenRecordUpdate = \case
+ RecordUpdateLeaf a b c -> flattenLabel a <> pure b <> flattenExpr c
+ RecordUpdateBranch a b ->
+ flattenLabel a <> flattenWrapped (flattenSeparated flattenRecordUpdate) b
+
+flattenLambda :: Lambda a -> DList SourceToken
+flattenLambda (Lambda a b c d) =
+ pure a <> foldMap flattenBinder b <> pure c <> flattenExpr d
+
+flattenIfThenElse :: IfThenElse a -> DList SourceToken
+flattenIfThenElse (IfThenElse a b c d e f) =
+ pure a <> flattenExpr b <> pure c <> flattenExpr d <> pure e <> flattenExpr f
+
+flattenCaseOf :: CaseOf a -> DList SourceToken
+flattenCaseOf (CaseOf a b c d) =
+ pure a <>
+ flattenSeparated flattenExpr b <>
+ pure c <>
+ foldMap (\(e, f) -> flattenSeparated flattenBinder e <> flattenGuarded f) d
+
+flattenLetIn :: LetIn a -> DList SourceToken
+flattenLetIn (LetIn a b c d) =
+ pure a <> foldMap flattenLetBinding b <> pure c <> flattenExpr d
+
+flattenDoBlock :: DoBlock a -> DList SourceToken
+flattenDoBlock (DoBlock a b) =
+ pure a <> foldMap flattenDoStatement b
+
+flattenAdoBlock :: AdoBlock a -> DList SourceToken
+flattenAdoBlock (AdoBlock a b c d) =
+ pure a <> foldMap flattenDoStatement b <> pure c <> flattenExpr d
+
+flattenDoStatement :: DoStatement a -> DList SourceToken
+flattenDoStatement = \case
+ DoLet a b -> pure a <> foldMap flattenLetBinding b
+ DoDiscard a -> flattenExpr a
+ DoBind a b c -> flattenBinder a <> pure b <> flattenExpr c
+
+flattenExpr :: Expr a -> DList SourceToken
+flattenExpr = \case
+ ExprHole _ a -> flattenName a
+ ExprSection _ a -> pure a
+ ExprIdent _ a -> flattenQualifiedName a
+ ExprConstructor _ a -> flattenQualifiedName a
+ ExprBoolean _ a _ -> pure a
+ ExprChar _ a _ -> pure a
+ ExprString _ a _ -> pure a
+ ExprNumber _ a _ -> pure a
+ ExprArray _ a -> flattenWrapped (foldMap (flattenSeparated flattenExpr)) a
+ ExprRecord _ a ->
+ flattenWrapped (foldMap (flattenSeparated (flattenRecordLabeled flattenExpr))) a
+ ExprParens _ a -> flattenWrapped flattenExpr a
+ ExprTyped _ a b c -> flattenExpr a <> pure b <> flattenType c
+ ExprInfix _ a b c -> flattenExpr a <> flattenWrapped flattenExpr b <> flattenExpr c
+ ExprOp _ a b c -> flattenExpr a <> flattenQualifiedName b <> flattenExpr c
+ ExprOpName _ a -> flattenQualifiedName a
+ ExprNegate _ a b -> pure a <> flattenExpr b
+ ExprRecordAccessor _ a -> flattenRecordAccessor a
+ ExprRecordUpdate _ a b -> flattenExpr a <> flattenWrapped (flattenSeparated flattenRecordUpdate) b
+ ExprApp _ a b -> flattenExpr a <> flattenExpr b
+ ExprVisibleTypeApp _ a b c -> flattenExpr a <> pure b <> flattenType c
+ ExprLambda _ a -> flattenLambda a
+ ExprIf _ a -> flattenIfThenElse a
+ ExprCase _ a -> flattenCaseOf a
+ ExprLet _ a -> flattenLetIn a
+ ExprDo _ a -> flattenDoBlock a
+ ExprAdo _ a -> flattenAdoBlock a
+
+flattenLetBinding :: LetBinding a -> DList SourceToken
+flattenLetBinding = \case
+ LetBindingSignature _ a -> flattenLabeled flattenName flattenType a
+ LetBindingName _ a -> flattenValueBindingFields a
+ LetBindingPattern _ a b c -> flattenBinder a <> pure b <> flattenWhere c
+
+flattenWhere :: Where a -> DList SourceToken
+flattenWhere (Where a b) =
+ flattenExpr a <> foldMap (\(c, d) -> pure c <> foldMap flattenLetBinding d) b
+
+flattenPatternGuard :: PatternGuard a -> DList SourceToken
+flattenPatternGuard (PatternGuard a b) =
+ foldMap (\(c, d) -> flattenBinder c <> pure d) a <> flattenExpr b
+
+flattenGuardedExpr :: GuardedExpr a -> DList SourceToken
+flattenGuardedExpr (GuardedExpr a b c d) =
+ pure a <>
+ flattenSeparated flattenPatternGuard b <>
+ pure c <>
+ flattenWhere d
+
+flattenGuarded :: Guarded a -> DList SourceToken
+flattenGuarded = \case
+ Unconditional a b -> pure a <> flattenWhere b
+ Guarded a -> foldMap flattenGuardedExpr a
+
+flattenFixityFields :: FixityFields -> DList SourceToken
+flattenFixityFields (FixityFields (a, _) (b, _) c) =
+ pure a <> pure b <> flattenFixityOp c
+
+flattenFixityOp :: FixityOp -> DList SourceToken
+flattenFixityOp = \case
+ FixityValue a b c -> flattenQualifiedName a <> pure b <> flattenName c
+ FixityType a b c d -> pure a <> flattenQualifiedName b <> pure c <> flattenName d
+
+flattenForeign :: Foreign a -> DList SourceToken
+flattenForeign = \case
+ ForeignValue a -> flattenLabeled flattenName flattenType a
+ ForeignData a b -> pure a <> flattenLabeled flattenName flattenType b
+ ForeignKind a b -> pure a <> flattenName b
+
+flattenRole :: Role -> DList SourceToken
+flattenRole = pure . roleTok
+
+flattenDeclaration :: Declaration a -> DList SourceToken
+flattenDeclaration = \case
+ DeclData _ a b drvs ->
+ flattenDataHead a <>
+ foldMap (\(t, ctrs) -> pure t <> flattenSeparated flattenDataCtor ctrs) b <>
+ foldMap flattenDeriveClause drvs
+ DeclType _ a b c -> flattenDataHead a <> pure b <> flattenType c
+ DeclNewtype _ a b c d drvs -> flattenDataHead a <> pure b <> flattenName c <> flattenType d <> foldMap flattenDeriveClause drvs
+ DeclClass _ a b ->
+ flattenClassHead a <>
+ foldMap (\(c, d) -> pure c <> foldMap (flattenLabeled flattenName flattenType) d) b
+ DeclInstanceChain _ a -> flattenSeparated flattenInstance a
+ DeclDerive _ a b c -> pure a <> foldMap pure b <> flattenInstanceHead c
+ DeclKindSignature _ a b -> pure a <> flattenLabeled flattenName flattenType b
+ DeclSignature _ a -> flattenLabeled flattenName flattenType a
+ DeclFixity _ a -> flattenFixityFields a
+ DeclForeign _ a b c -> pure a <> pure b <> flattenForeign c
+ DeclRole _ a b c d -> pure a <> pure b <> flattenName c <> foldMap flattenRole d
+ DeclValue _ a -> flattenValueBindingFields a
+
+ where
+ flattenDeriveClass :: DeriveClass -> DList SourceToken
+ flattenDeriveClass (DeriveClass cls) =
+ flattenQualifiedName cls
+
+ flattenDeriveClause :: DeriveClause -> DList SourceToken
+ flattenDeriveClause (DeriveClause kw classes) =
+ pure kw <>
+ flattenWrapped (flattenSeparated flattenDeriveClass) classes
+
+flattenQualifiedName :: QualifiedName a -> DList SourceToken
+flattenQualifiedName = pure . qualTok
+
+flattenName :: Name a -> DList SourceToken
+flattenName = pure . nameTok
+
+flattenLabel :: Label -> DList SourceToken
+flattenLabel = pure . lblTok
+
+flattenExport :: Export a -> DList SourceToken
+flattenExport = \case
+ ExportValue _ n -> flattenName n
+ ExportOp _ n -> flattenName n
+ ExportType _ n dms -> flattenName n <> foldMap flattenDataMembers dms
+ ExportTypeOp _ t n -> pure t <> flattenName n
+ ExportClass _ t n -> pure t <> flattenName n
+ ExportModule _ t n -> pure t <> flattenName n
+
+flattenDataMembers :: DataMembers a -> DList SourceToken
+flattenDataMembers = \case
+ DataAll _ t -> pure t
+ DataEnumerated _ ns -> flattenWrapped (foldMap (flattenSeparated flattenName)) ns
+
+flattenImportDecl :: ImportDecl a -> DList SourceToken
+flattenImportDecl (ImportDecl _ a b c d) =
+ pure a <>
+ flattenName b <>
+ foldMap (\(mt, is) ->
+ foldMap pure mt <> flattenWrapped (flattenSeparated flattenImport) is) c <>
+ foldMap (\(t, n) -> pure t <> flattenName n) d
+
+flattenImport :: Import a -> DList SourceToken
+flattenImport = \case
+ ImportValue _ n -> flattenName n
+ ImportOp _ n -> flattenName n
+ ImportType _ n dms -> flattenName n <> foldMap flattenDataMembers dms
+ ImportTypeOp _ t n -> pure t <> flattenName n
+ ImportClass _ t n -> pure t <> flattenName n
+
+flattenWrapped :: (a -> DList SourceToken) -> Wrapped a -> DList SourceToken
+flattenWrapped k (Wrapped a b c) = pure a <> k b <> pure c
+
+flattenSeparated :: (a -> DList SourceToken) -> Separated a -> DList SourceToken
+flattenSeparated k (Separated a b) = k a <> foldMap (\(c, d) -> pure c <> k d) b
+
+flattenOneOrDelimited
+ :: (a -> DList SourceToken) -> OneOrDelimited a -> DList SourceToken
+flattenOneOrDelimited f = \case
+ One a -> f a
+ Many a -> flattenWrapped (flattenSeparated f) a
+
+flattenLabeled :: (a -> DList SourceToken) -> (b -> DList SourceToken) -> Labeled a b -> DList SourceToken
+flattenLabeled ka kc (Labeled a b c) = ka a <> pure b <> kc c
+
+flattenType :: Type a -> DList SourceToken
+flattenType = \case
+ TypeVar _ a -> pure $ nameTok a
+ TypeConstructor _ a -> pure $ qualTok a
+ TypeWildcard _ a -> pure a
+ TypeHole _ a -> pure $ nameTok a
+ TypeString _ a _ -> pure a
+ TypeInt _ a b _ -> maybe mempty pure a <> pure b
+ TypeRow _ a -> flattenWrapped flattenRow a
+ TypeRecord _ a -> flattenWrapped flattenRow a
+ TypeForall _ a b c d -> pure a <> foldMap flattenTypeVarBinding b <> pure c <> flattenType d
+ TypeKinded _ a b c -> flattenType a <> pure b <> flattenType c
+ TypeApp _ a b -> flattenType a <> flattenType b
+ TypeOp _ a b c -> flattenType a <> pure (qualTok b) <> flattenType c
+ TypeOpName _ a -> pure $ qualTok a
+ TypeArr _ a b c -> flattenType a <> pure b <> flattenType c
+ TypeArrName _ a -> pure a
+ TypeConstrained _ a b c -> flattenConstraint a <> pure b <> flattenType c
+ TypeParens _ a -> flattenWrapped flattenType a
+ TypeUnaryRow _ a b -> pure a <> flattenType b
+
+flattenRow :: Row a -> DList SourceToken
+flattenRow (Row lbls tl) =
+ foldMap (flattenSeparated (flattenLabeled (pure . lblTok) flattenType)) lbls
+ <> foldMap (\(a, b) -> pure a <> flattenType b) tl
+
+flattenTypeVarBinding :: TypeVarBinding a -> DList SourceToken
+flattenTypeVarBinding = \case
+ TypeVarKinded a -> flattenWrapped (flattenLabeled go flattenType) a
+ TypeVarName a -> go a
+ where
+ go (a, b) = maybe mempty pure a <> pure (nameTok b)
+
+flattenConstraint :: Constraint a -> DList SourceToken
+flattenConstraint = \case
+ Constraint _ a b -> pure (qualTok a) <> foldMap flattenType b
+ ConstraintParens _ a -> flattenWrapped flattenConstraint a
diff --git a/src/Language/PureScript/CST/Layout.hs b/src/Language/PureScript/CST/Layout.hs
index bf533ff9aa..2f41df6b4f 100644
--- a/src/Language/PureScript/CST/Layout.hs
+++ b/src/Language/PureScript/CST/Layout.hs
@@ -1,4 +1,11 @@
--- | The parser itself is unaware of indentation, and instead only parses explicit
+-- |
+-- ## High-Level Summary
+--
+-- This section provides a high-level summary of this file. For those who
+-- know more about compiler-development, the below explanation is likely enough.
+-- For everyone else, see the next section.
+--
+-- The parser itself is unaware of indentation, and instead only parses explicit
-- delimiters which are inserted by this layout algorithm (much like Haskell).
-- This is convenient because the actual grammar can be specified apart from the
-- indentation rules. Haskell has a few problematic productions which make it
@@ -17,16 +24,160 @@
-- such an algorithm. Unquoted properties for layout keywords introduce a domino
-- effect of complexity since we have to mask and unmask any usage of . (also in
-- foralls!) or labels in record literals.
-
+--
+-- ## Detailed Summary
+--
+-- ### The Problem
+--
+-- The parser itself is unaware of indentation or other such layout concerns.
+-- Rather than dealing with it explicitly, the parser and its
+-- grammar rules are only aware of normal tokens (e.g. @TokLowerName@) and
+-- three special zero-width tokens, @TokLayoutStart@, @TokLayoutSep@,
+-- and @TokLayoutEnd@. This is convenient because the actual grammar
+-- can be specified apart from the indentation rules and other such
+-- layout concerns.
+--
+-- For a simple example, the parser parses all three examples of the code below
+-- using the exact same grammar rules for the @let@ keyword despite
+-- each example using different indentations levels:
+--
+-- @
+-- -- Example 1
+-- let foo = 5
+-- x = 2 in foo
+--
+-- -- Example 2
+-- let
+-- bar = 5
+-- y = 2
+-- in bar
+--
+-- -- Example 3
+-- let baz
+-- =
+-- 5
+-- z= 2 in baz
+-- @
+--
+-- Each block of code might appear to the parser as a stream of the
+-- following source tokens where the @\{@ sequence represents
+-- @TokLayoutStart@, the @\;@ sequence represents @TokLayoutSep@,
+-- and the @\}@ sequence represents @TokLayoutEnd@:
+-- - @let \{foo = 5\;x = 2\} in foo@
+-- - @let \{bar = 5\;y = 2\} in bar@
+-- - @let \{baz = 5\;z = 2\} in baz@
+--
+--
+-- For a more complex example, consider commas:
+--
+-- @
+-- case one, { twoA, twoB }, [ three1
+-- , three2
+-- , do
+-- { three3, three4 } <- case arg1, arg2 of
+-- Nothing, _ -> { three3: 1, three4: 2 }
+-- Just _, Nothing -> { three3: 2, three4: 3 }
+-- _, _ -> { three3: 3, three4: 4 }
+-- pure $ three3 + three4
+-- ] of
+-- @
+--
+-- Which of the above 13 commas function as the separators between the
+-- case binders (e.g. @one@) in the outermost @case ... of@ context?
+--
+-- ### The Solution
+--
+-- The parser doesn't have to care about layout concerns (e.g. indentation
+-- or what starts and ends a context, such as a case binder) because the
+-- lexer solves that problem instead.
+--
+-- So, how does the lexer solve this problem? It follows this general algorithm:
+-- 1. Lex the source code text into an initial stream of `SourceToken`s
+-- that do not have any of the three special tokens mentioned previously.
+-- 2. On a token-by-token basis, determine whether the lexer should
+-- 1. insert one of the three special tokens,
+-- 2. modify the current context (e.g. are we within a case binder?
+-- Are we in a record expression?)
+--
+-- Step 2 is handled via 'insertLayout' and is essentially a state machine.
+-- The layout delimiters, (e.g. 'LytCase', 'LytBrace', 'LytProperty',
+-- and 'LytOf' in the next section's example) either stop certain "rules"
+-- from applying or ensure that certain "rules" now apply. By "rules",
+-- we mean whether and where one of the three special tokens are added.
+-- The comments in the source code for the 'insertLayout' algorithm call
+-- pushing these delimiters onto the stack "masking" and popping them off
+-- as "unmasking". Seeing when a layout delimiter is pushed and popped
+-- are the keys to understanding this algorithm.
+--
+-- ### Walking Through an Example
+--
+-- Before showing an example, let's remember a few things.
+-- 1. The @TokLowerName "case"@ token (i.e. a "case" keyword) indicates the start
+-- of a @case ... of@ context. That context includes case binders (like the
+-- example shown previously) that can get quite complex. When encountered,
+-- we may need to insert one or more of the three special tokens here
+-- until we encounter the terminating @TokLowerName "of"@ token that
+-- signifies its end.
+-- 2. "case" and "of" can also appear as a record field's name. In such a context,
+-- they would not start or end a @case ... of@ block.
+--
+-- Given the below source code...
+--
+-- @
+-- case { case: "foo", of: "bar" } of
+-- @
+--
+-- the lexer would go through something like the following states:
+-- 1. Encountered @TokLowerName "case"@. Update current context to
+-- "within a case of expression" by pushing the 'LytCase' delimiter
+-- onto the layout delimiter stack. Insert the @case@ token
+-- into the stream of source tokens.
+-- 2. Encountered @TokLeftBrace@. Update current context to
+-- "within a record expression" by pushing the 'LytBrace' delimiter.
+-- Since we expect a field name to be the next token we see,
+-- which may include a reserved keyword, update the current context again to
+-- "expecting a field name" by pushing the `LytProperty`.
+-- delimiter. Insert the @{@ token into the stream of source tokens.
+-- 3. Encountered @TokLowerName "case"@. Check the current context.
+-- Since it's a `LytProperty`, this is a field name and we shouldn't
+-- assume that the next few tokens will be case binders. However,
+-- since this might be a record with no more fields, update the
+-- current context back to "within a record expression" by popping
+-- the `LytProperty` off the layout delimiter stack. Insert the @case@ token
+-- 4. Encountered @TokColon@. Insert the @:@ token
+-- 5. Encountered @TokLowerName "foo"@. Insert the @foo@ token.
+-- 6. Encountered @TokComma@. Check the current context. Since it's a `LytBrace`,
+-- we're in a record expression and there is another field. Update the
+-- current context by pushing `LytProperty` as we expect a field name again.
+-- 7. Encountered @TokLowerName "of"@. Check the current context.
+-- Since it's a `LytProperty`, this is a field name rather
+-- than the end of a case binder. Thus, we don't expect the next tokens
+-- to be the @body@ in a @case ... of body@ expression. However, since
+-- this might be a record with no more fields, update the current context
+-- back to "within a record expression" by popping the `LytProperty`
+-- off the stack. Insert the @of@ token.
+-- 8. Encountered @TokRightBrace@. Check the current context.
+-- Since it's a `LytBrace`, this is the end of a record expression.
+-- Update the current context to "within a case of expression"
+-- by popping the `LytBrace` off the stack. Insert the @}@ token.
+-- 9. Encountered @TokLowername "of"@. Check the current context.
+-- Since it's a 'LytCase', this is the end of a @case ... of@ expression
+-- and the body will follow. Update the current context to
+-- "body of a case of expression" by pushing 'LytOf' onto the layout stack.
+-- Insert the @of@ token into the stream of tokens.
+--
+{-# LANGUAGE DeriveAnyClass #-}
module Language.PureScript.CST.Layout where
import Prelude
+import Control.DeepSeq (NFData)
import Data.DList (snoc)
-import qualified Data.DList as DList
+import Data.DList qualified as DList
import Data.Foldable (find)
import Data.Function ((&))
-import Language.PureScript.CST.Types
+import GHC.Generics (Generic)
+import Language.PureScript.CST.Types (Comment, LineFeed, SourcePos(..), SourceRange(..), SourceToken(..), Token(..), TokenAnn(..))
type LayoutStack = [(SourcePos, LayoutDelim)]
@@ -53,7 +204,7 @@ data LayoutDelim
| LytOf
| LytDo
| LytAdo
- deriving (Show, Eq, Ord)
+ deriving (Show, Eq, Ord, Generic, NFData)
isIndented :: LayoutDelim -> Bool
isIndented = \case
@@ -146,13 +297,15 @@ insertLayout src@(SourceToken tokAnn tok) nextPos stack =
inP _ lyt = isIndented lyt
TokLowerName [] "let" ->
- case stk of
+ state & insertKwProperty next
+ where
+ next state'@(stk', _) = case stk' of
(p, LytDo) : _ | srcColumn p == srcColumn tokPos ->
- state & insertKwProperty (insertStart LytLetStmt)
+ state' & insertStart LytLetStmt
(p, LytAdo) : _ | srcColumn p == srcColumn tokPos ->
- state & insertKwProperty (insertStart LytLetStmt)
+ state' & insertStart LytLetStmt
_ ->
- state & insertKwProperty (insertStart LytLet)
+ state' & insertStart LytLet
TokLowerName _ "do" ->
state & insertKwProperty (insertStart LytDo)
@@ -213,7 +366,7 @@ insertLayout src@(SourceToken tokAnn tok) nextPos stack =
state & insertKwProperty (pushStack tokPos LytForall)
-- Lambdas need masking because the usage of `->` should not close a
- -- LytDeclGaurd or LytCaseGuard context.
+ -- LytDeclGuard or LytCaseGuard context.
TokBackslash ->
state & insertDefault & pushStack tokPos LytLambdaBinders
@@ -236,9 +389,10 @@ insertLayout src@(SourceToken tokAnn tok) nextPos stack =
_ ->
state & insertDefault
where
- equalsP _ LytWhere = True
- equalsP _ LytLet = True
- equalsP _ _ = False
+ equalsP _ LytWhere = True
+ equalsP _ LytLet = True
+ equalsP _ LytLetStmt = True
+ equalsP _ _ = False
-- Guards need masking because of commas.
TokPipe ->
@@ -247,6 +401,8 @@ insertLayout src@(SourceToken tokAnn tok) nextPos stack =
state' & pushStack tokPos LytCaseGuard & insertToken src
state'@((_, LytLet) : _, _) ->
state' & pushStack tokPos LytDeclGuard & insertToken src
+ state'@((_, LytLetStmt) : _, _) ->
+ state' & pushStack tokPos LytDeclGuard & insertToken src
state'@((_, LytWhere) : _, _) ->
state' & pushStack tokPos LytDeclGuard & insertToken src
_ ->
@@ -260,9 +416,9 @@ insertLayout src@(SourceToken tokAnn tok) nextPos stack =
((_, LytTick) : stk', acc') ->
(stk', acc') & insertToken src
_ ->
- state & insertDefault & pushStack tokPos LytTick
+ state & collapse offsideEndP & insertSep & insertToken src & pushStack tokPos LytTick
- -- In gneral, commas should close all indented contexts.
+ -- In general, commas should close all indented contexts.
-- example = [ do foo
-- bar, baz ]
TokComma ->
diff --git a/src/Language/PureScript/CST/Lexer.hs b/src/Language/PureScript/CST/Lexer.hs
index b1e9d83733..726a76f26a 100644
--- a/src/Language/PureScript/CST/Lexer.hs
+++ b/src/Language/PureScript/CST/Lexer.hs
@@ -1,42 +1,84 @@
-{-# LANGUAGE BangPatterns #-}
module Language.PureScript.CST.Lexer
- ( lex
- , munch
+ ( lenient
+ , lexModule
+ , lex
+ , lexTopLevel
+ , lexWithState
+ , isUnquotedKey
) where
import Prelude hiding (lex, exp, exponent, lines)
import Control.Monad (join)
-import qualified Data.Char as Char
-import qualified Data.DList as DList
+import Data.Char qualified as Char
+import Data.DList qualified as DList
import Data.Foldable (foldl')
import Data.Functor (($>))
-import qualified Data.Scientific as Sci
+import Data.Scientific qualified as Sci
import Data.String (fromString)
import Data.Text (Text)
-import qualified Data.Text as Text
-import Language.PureScript.CST.Errors
-import Language.PureScript.CST.Monad
-import Language.PureScript.CST.Layout
-import Language.PureScript.CST.Positions
-import Language.PureScript.CST.Types
-
-lex :: Text -> [LexResult]
-lex = go1
+import Data.Text qualified as Text
+import Data.Text.PureScript qualified as Text
+import Language.PureScript.CST.Errors (ParserErrorInfo(..), ParserErrorType(..))
+import Language.PureScript.CST.Monad (LexResult, LexState(..), ParserM(..), throw)
+import Language.PureScript.CST.Layout (LayoutDelim(..), insertLayout, lytToken, unwindLayout)
+import Language.PureScript.CST.Positions (advanceLeading, advanceToken, advanceTrailing, applyDelta, textDelta)
+import Language.PureScript.CST.Types (Comment(..), LineFeed(..), SourcePos(..), SourceRange(..), SourceStyle(..), SourceToken(..), Token(..), TokenAnn(..))
+
+-- | Stops at the first lexing error and replaces it with TokEof. Otherwise,
+-- the parser will fail when it attempts to draw a lookahead token.
+lenient :: [LexResult] -> [LexResult]
+lenient = go
where
- Parser lexK =
- tokenAndComments
+ go [] = []
+ go (Right a : as) = Right a : go as
+ go (Left (st, _) : _) = do
+ let
+ pos = lexPos st
+ ann = TokenAnn (SourceRange pos pos) (lexLeading st) []
+ [Right (SourceToken ann TokEof)]
- go1 src = do
- let (leading, src') = comments src
- go2 $ LexState
- { lexPos = advanceLeading (SourcePos 1 1) leading
+lexModule :: Text -> [LexResult]
+lexModule = lex' shebangThenComments
+
+-- | Lexes according to root layout rules.
+lex :: Text -> [LexResult]
+lex = lex' comments
+
+lex' :: (Text -> ([Comment LineFeed], Text)) -> Text -> [LexResult]
+lex' lexComments src = do
+ let (leading, src') = lexComments src
+
+ lexWithState $ LexState
+ { lexPos = advanceLeading (SourcePos 1 1) leading
+ , lexLeading = leading
+ , lexSource = src'
+ , lexStack = [(SourcePos 0 0, LytRoot)]
+ }
+
+-- | Lexes according to top-level declaration context rules.
+lexTopLevel :: Text -> [LexResult]
+lexTopLevel src = do
+ let
+ (leading, src') = comments src
+ lexPos = advanceLeading (SourcePos 1 1) leading
+ hd = Right $ lytToken lexPos TokLayoutStart
+ tl = lexWithState $ LexState
+ { lexPos = lexPos
, lexLeading = leading
, lexSource = src'
- , lexStack = [(SourcePos 0 0, LytRoot)]
+ , lexStack = [(lexPos, LytWhere), (SourcePos 0 0, LytRoot)]
}
+ hd : tl
+
+-- | Lexes according to some LexState.
+lexWithState :: LexState -> [LexResult]
+lexWithState = go
+ where
+ Parser lexK =
+ tokenAndComments
- go2 state@(LexState {..}) =
+ go state@LexState {..} =
lexK lexSource onError onSuccess
where
onError lexSource' err = do
@@ -48,7 +90,7 @@ lex = go1
pos = applyDelta lexPos chunkDelta
pure $ Left
( state { lexSource = lexSource' }
- , ParserError (SourceRange pos $ applyDelta pos (0, 1)) [] lexStack err
+ , ParserErrorInfo (SourceRange pos $ applyDelta pos (0, 1)) [] lexStack err
)
onSuccess _ (TokEof, _) =
@@ -70,20 +112,10 @@ lex = go1
, lexSource = lexSource'
, lexStack = lexStack'
}
- go3 state' toks
-
- go3 state [] = go2 state
- go3 state (t : ts) = Right t : go3 state ts
+ go2 state' toks
-munch :: Parser SourceToken
-munch = Parser $ \state@(ParserState {..}) kerr ksucc ->
- case parserBuff of
- Right tok : parserBuff' ->
- ksucc (state { parserBuff = parserBuff' }) tok
- Left (_, err) : _ ->
- kerr state err
- [] ->
- error "Empty input"
+ go2 state [] = go state
+ go2 state (t : ts) = Right t : go2 state ts
type Lexer = ParserM ParserErrorType Text
@@ -98,6 +130,12 @@ nextWhile p = Parser $ \inp _ ksucc -> do
let (chs, inp') = Text.span p inp
ksucc inp' chs
+{-# INLINE nextWhile' #-}
+nextWhile' :: Int -> (Char -> Bool) -> Lexer Text
+nextWhile' n p = Parser $ \inp _ ksucc -> do
+ let (chs, inp') = Text.spanUpTo n p inp
+ ksucc inp' chs
+
{-# INLINE peek #-}
peek :: Lexer (Maybe Char)
peek = Parser $ \inp _ ksucc ->
@@ -113,6 +151,17 @@ restore p (Parser k) = Parser $ \inp kerr ksucc ->
tokenAndComments :: Lexer (Token, ([Comment void], [Comment LineFeed]))
tokenAndComments = (,) <$> token <*> breakComments
+shebangThenComments :: Text -> ([Comment LineFeed], Text)
+shebangThenComments src = do
+ let
+ (sb, (coms, src')) = comments <$> shebang src
+ (sb <> coms, src')
+
+shebang :: Text -> ([Comment LineFeed], Text)
+shebang = \src -> k src (\_ _ -> ([], src)) (\inp a -> (a, inp))
+ where
+ Parser k = breakShebang
+
comments :: Text -> ([Comment LineFeed], Text)
comments = \src -> k src (\_ _ -> ([], src)) (\inp (a, b) -> (a <> b, inp))
where
@@ -152,7 +201,7 @@ breakComments = k0 []
goWs a _ = a
goSpace a !n (' ' : ls) = goSpace a (n + 1) ls
- goSpace a !n ls = goWs (Space n : a) ls
+ goSpace a n ls = goWs (Space n : a) ls
isBlockComment = Parser $ \inp _ ksucc ->
case Text.uncons inp of
@@ -174,11 +223,7 @@ breakComments = k0 []
comment = isBlockComment >>= \case
Just True -> Just <$> blockComment "{-"
Just False -> Just <$> lineComment "--"
- Nothing -> pure $ Nothing
-
- lineComment acc = do
- comm <- nextWhile (\c -> c /= '\r' && c /= '\n')
- pure $ Comment (acc <> comm)
+ Nothing -> pure Nothing
blockComment acc = do
chs <- nextWhile (/= '-')
@@ -189,6 +234,57 @@ breakComments = k0 []
Just '}' -> next $> Comment (acc <> chs <> dashes <> "}")
_ -> blockComment (acc <> chs <> dashes)
+breakShebang :: ParserM ParserErrorType Text [Comment LineFeed]
+breakShebang = shebangComment >>= \case
+ Just comm -> k0 [comm]
+ Nothing -> pure []
+ where
+ k0 acc = lineFeedShebang >>= \case
+ Just (lf, sb) -> do
+ comm <- lineComment sb
+ k0 (comm : lf : acc)
+ Nothing ->
+ pure $ reverse acc
+
+ lineFeedShebang = Parser $ \inp _ ksucc ->
+ case unconsLineFeed inp of
+ Just (lf, inp2)
+ | Just (sb, inp3) <- unconsShebang inp2 ->
+ ksucc inp3 $ Just (lf, sb)
+ _ ->
+ ksucc inp Nothing
+
+ unconsLineFeed :: Text -> Maybe (Comment LineFeed, Text)
+ unconsLineFeed inp =
+ case Text.uncons inp of
+ Just ('\r', inp2) ->
+ case Text.uncons inp2 of
+ Just ('\n', inp3) ->
+ Just (Line CRLF, inp3)
+ _ ->
+ Just (Line CRLF, inp2)
+ Just ('\n', inp2) ->
+ Just (Line LF, inp2)
+ _ ->
+ Nothing
+
+ unconsShebang :: Text -> Maybe (Text, Text)
+ unconsShebang = fmap ("#!",) . Text.stripPrefix "#!"
+
+ shebangComment = isShebang >>= traverse lineComment
+
+ isShebang = Parser $ \inp _ ksucc ->
+ case unconsShebang inp of
+ Just (sb, inp3) ->
+ ksucc inp3 $ Just sb
+ _ ->
+ ksucc inp Nothing
+
+lineComment :: forall lf. Text -> ParserM ParserErrorType Text (Comment lf)
+lineComment acc = do
+ comm <- nextWhile (\c -> c /= '\r' && c /= '\n')
+ pure $ Comment (acc <> comm)
+
token :: Lexer Token
token = peek >>= maybe (pure TokEof) k0
where
@@ -292,7 +388,7 @@ token = peek >>= maybe (pure TokEof) k0
peek >>= \case
Just ')'
| isReservedSymbol chs -> throw ErrReservedSymbol
- | otherwise -> next $> TokSymbolName qual chs
+ | otherwise -> next $> TokSymbolName (reverse qual) chs
Just ch2 -> throw $ ErrLexeme (Just [ch2]) []
Nothing -> throw ErrEof
Just ch -> throw $ ErrLexeme (Just [ch]) []
@@ -302,7 +398,7 @@ token = peek >>= maybe (pure TokEof) k0
operator
: symbolChar+
-}
- operator :: [Text] -> [Char] -> Lexer Token
+ operator :: [Text] -> String -> Lexer Token
operator qual pre = do
rest <- nextWhile isSymbolChar
pure . TokOperator (reverse qual) $ Text.pack pre <> rest
@@ -387,7 +483,7 @@ token = peek >>= maybe (pure TokEof) k0
Just ch ->
next $> (Text.singleton ch, ch)
Nothing ->
- throw $ ErrEof
+ throw ErrEof
peek >>= \case
Just '\''
| fromEnum ch > 0xFFFF -> throw ErrAstralCodePointInChar
@@ -395,7 +491,7 @@ token = peek >>= maybe (pure TokEof) k0
Just ch2 ->
throw $ ErrLexeme (Just [ch2]) []
_ ->
- throw $ ErrEof
+ throw ErrEof
{-
stringPart
@@ -405,15 +501,15 @@ token = peek >>= maybe (pure TokEof) k0
string
: '"' stringPart* '"'
- | '"""' .* '"""'
+ | '"""' '"'{0,2} ([^"]+ '"'{1,2})* [^"]* '"""'
- This assumes maximal munch for quotes. A raw string literal can end with
- any number of quotes, where the last 3 are considered the closing
- delimiter.
+ A raw string literal can't contain any sequence of 3 or more quotes,
+ although sequences of 1 or 2 quotes are allowed anywhere, including at the
+ beginning or the end.
-}
string :: Lexer Token
string = do
- quotes1 <- nextWhile (== '"')
+ quotes1 <- nextWhile' 7 (== '"')
case Text.length quotes1 of
0 -> do
let
@@ -444,19 +540,18 @@ token = peek >>= maybe (pure TokEof) k0
go "" mempty
1 ->
pure $ TokString "" ""
- n | n >= 5 -> do
- let str = Text.take 5 quotes1
- pure $ TokString str (fromString (Text.unpack str))
+ n | n >= 5 ->
+ pure $ TokRawString $ Text.drop 5 quotes1
_ -> do
let
go acc = do
chs <- nextWhile (/= '"')
- quotes2 <- nextWhile (== '"')
+ quotes2 <- nextWhile' 5 (== '"')
case Text.length quotes2 of
0 -> throw ErrEof
n | n >= 3 -> pure $ TokRawString $ acc <> chs <> Text.drop 3 quotes2
_ -> go (acc <> chs <> quotes2)
- go ""
+ go $ Text.drop 2 quotes1
{-
escape
@@ -471,9 +566,9 @@ token = peek >>= maybe (pure TokEof) k0
escape = do
ch <- peek
case ch of
- Just 't' -> next $> ("\t", '\t')
- Just 'r' -> next $> ("\\r", '\r')
- Just 'n' -> next $> ("\\n", '\n')
+ Just 't' -> next $> ("t", '\t')
+ Just 'r' -> next $> ("r", '\r')
+ Just 'n' -> next $> ("n", '\n')
Just '"' -> next $> ("\"", '"')
Just '\'' -> next $> ("'", '\'')
Just '\\' -> next $> ("\\", '\\')
@@ -484,7 +579,7 @@ token = peek >>= maybe (pure TokEof) k0
go n acc _
| n <= 0x10FFFF =
ksucc (Text.drop (length acc) inp)
- (Text.pack $ reverse acc, Char.chr n)
+ ("x" <> Text.pack (reverse acc), Char.chr n)
| otherwise =
kerr inp ErrCharEscape -- TODO
go 0 [] $ Text.unpack $ Text.take 6 inp
@@ -541,8 +636,8 @@ token = peek >>= maybe (pure TokEof) k0
Just '0' -> next *> peek >>= \case
Just ch | isNumberChar ch -> throw ErrLeadingZero
_ -> pure $ Just ("0", "0")
- Just ch | isDigitChar ch -> Just <$> digits
- _ -> pure $ Nothing
+ Just ch | Char.isDigit ch -> Just <$> digits
+ _ -> pure Nothing
{-
integer1
@@ -557,10 +652,10 @@ token = peek >>= maybe (pure TokEof) k0
'0' -> peek >>= \case
Just ch | isNumberChar ch -> throw ErrLeadingZero
_ -> pure $ Just ("0", "0")
- ch | isDigitChar ch -> do
+ ch | Char.isDigit ch -> do
(raw, chs) <- digits
pure $ Just (Text.cons ch raw, ch : chs)
- _ -> pure $ Nothing
+ _ -> pure Nothing
{-
fraction
@@ -620,20 +715,20 @@ token = peek >>= maybe (pure TokEof) k0
then throw ErrExpectedHex
else pure $ TokInt ("0x" <> chs) $ digitsToIntegerBase 16 $ Text.unpack chs
-digitsToInteger :: [Char] -> Integer
+digitsToInteger :: String -> Integer
digitsToInteger = digitsToIntegerBase 10
-digitsToIntegerBase :: Integer -> [Char] -> Integer
-digitsToIntegerBase b = foldl' (\n c -> n * b + (toInteger (Char.digitToInt c))) 0
+digitsToIntegerBase :: Integer -> String -> Integer
+digitsToIntegerBase b = foldl' (\n c -> n * b + toInteger (Char.digitToInt c)) 0
-digitsToScientific :: [Char] -> [Char] -> (Integer, Int)
+digitsToScientific :: String -> String -> (Integer, Int)
digitsToScientific = go 0 . reverse
where
go !exp is [] = (digitsToInteger (reverse is), exp)
- go !exp is (f : fs) = go (exp - 1) (f : is) fs
+ go exp is (f : fs) = go (exp - 1) (f : is) fs
isSymbolChar :: Char -> Bool
-isSymbolChar c = (c `elem` (":!#$%&*+./<=>?@\\^|-~" :: [Char])) || (not (Char.isAscii c) && Char.isSymbol c)
+isSymbolChar c = (c `elem` (":!#$%&*+./<=>?@\\^|-~" :: String)) || (not (Char.isAscii c) && Char.isSymbol c)
isReservedSymbolError :: ParserErrorType -> Bool
isReservedSymbolError = (== ErrReservedSymbol)
@@ -663,11 +758,8 @@ isIdentStart c = Char.isLower c || c == '_'
isIdentChar :: Char -> Bool
isIdentChar c = Char.isAlphaNum c || c == '_' || c == '\''
-isDigitChar :: Char -> Bool
-isDigitChar c = c >= '0' && c <= '9'
-
isNumberChar :: Char -> Bool
-isNumberChar c = (c >= '0' && c <= '9') || c == '_'
+isNumberChar c = Char.isDigit c || c == '_'
isNormalStringChar :: Char -> Bool
isNormalStringChar c = c /= '"' && c /= '\\' && c /= '\r' && c /= '\n'
@@ -677,3 +769,12 @@ isStringGapChar c = c == ' ' || c == '\r' || c == '\n'
isLineFeed :: Char -> Bool
isLineFeed c = c == '\r' || c == '\n'
+
+-- | Checks if some identifier is a valid unquoted key.
+isUnquotedKey :: Text -> Bool
+isUnquotedKey t =
+ case Text.uncons t of
+ Nothing ->
+ False
+ Just (hd, tl) ->
+ isIdentStart hd && Text.all isIdentChar tl
diff --git a/src/Language/PureScript/CST/Monad.hs b/src/Language/PureScript/CST/Monad.hs
index 49da019cad..2b79f1a9b3 100644
--- a/src/Language/PureScript/CST/Monad.hs
+++ b/src/Language/PureScript/CST/Monad.hs
@@ -2,14 +2,14 @@ module Language.PureScript.CST.Monad where
import Prelude
-import Data.List (sortBy)
-import qualified Data.List.NonEmpty as NE
+import Data.List (sortOn)
+import Data.List.NonEmpty qualified as NE
import Data.Ord (comparing)
import Data.Text (Text)
-import Language.PureScript.CST.Errors
-import Language.PureScript.CST.Layout
-import Language.PureScript.CST.Positions
-import Language.PureScript.CST.Types
+import Language.PureScript.CST.Errors (ParserError, ParserErrorInfo(..), ParserErrorType(..), ParserWarning, ParserWarningType)
+import Language.PureScript.CST.Layout (LayoutStack)
+import Language.PureScript.CST.Positions (widen)
+import Language.PureScript.CST.Types (Comment, LineFeed, SourcePos(..), SourceRange(..), SourceToken(..), Token, TokenAnn(..))
type LexResult = Either (LexState, ParserError) SourceToken
@@ -23,6 +23,7 @@ data LexState = LexState
data ParserState = ParserState
{ parserBuff :: [LexResult]
, parserErrors :: [ParserError]
+ , parserWarnings :: [ParserWarning]
} deriving (Show)
-- | A bare bones, CPS'ed `StateT s (Except e) a`.
@@ -60,12 +61,24 @@ instance Monad (ParserM e s) where
runParser :: ParserState -> Parser a -> (ParserState, Either (NE.NonEmpty ParserError) a)
runParser st (Parser k) = k st left right
where
- left st'@(ParserState {..}) err =
+ left st'@ParserState {..} err =
(st', Left $ NE.sortBy (comparing errRange) $ err NE.:| parserErrors)
- right st'@(ParserState {..}) res
+ right st'@ParserState {..} res
| null parserErrors = (st', Right res)
- | otherwise = (st', Left $ NE.fromList $ sortBy (comparing errRange) parserErrors)
+ | otherwise = (st', Left $ NE.fromList $ sortOn errRange parserErrors)
+
+runTokenParser :: Parser a -> [LexResult] -> Either (NE.NonEmpty ParserError) ([ParserWarning], a)
+runTokenParser p buff = fmap (warnings,) res
+ where
+ (ParserState _ _ warnings, res) =
+ runParser initialState p
+
+ initialState = ParserState
+ { parserBuff = buff
+ , parserErrors = []
+ , parserWarnings = []
+ }
{-# INLINE throw #-}
throw :: e -> ParserM e s a
@@ -73,40 +86,42 @@ throw e = Parser $ \st kerr _ -> kerr st e
parseError :: SourceToken -> Parser a
parseError tok = Parser $ \st kerr _ ->
- kerr st $ ParserError
+ kerr st $ ParserErrorInfo
{ errRange = tokRange . tokAnn $ tok
, errToks = [tok]
, errStack = [] -- TODO parserStack st
, errType = ErrToken
}
-mkParserError :: LayoutStack -> [SourceToken] -> ParserErrorType -> ParserError
+mkParserError :: LayoutStack -> [SourceToken] -> a -> ParserErrorInfo a
mkParserError stack toks ty =
- ParserError
+ ParserErrorInfo
{ errRange = range
, errToks = toks
, errStack = stack
, errType = ty
}
where
- range = case toks of
- [] -> SourceRange (SourcePos 0 0) (SourcePos 0 0)
- _ -> widen (tokRange . tokAnn $ head toks) (tokRange . tokAnn $ last toks)
+ range = case NE.nonEmpty toks of
+ Nothing -> SourceRange (SourcePos 0 0) (SourcePos 0 0)
+ Just neToks -> widen
+ (tokRange . tokAnn $ NE.head neToks)
+ (tokRange . tokAnn $ NE.last neToks)
addFailure :: [SourceToken] -> ParserErrorType -> Parser ()
addFailure toks ty = Parser $ \st _ ksucc ->
ksucc (st { parserErrors = mkParserError [] toks ty : parserErrors st }) ()
-addFailures :: [ParserError] -> Parser ()
-addFailures errs = Parser $ \st _ ksucc ->
- ksucc (st { parserErrors = errs <> parserErrors st }) ()
-
parseFail' :: [SourceToken] -> ParserErrorType -> Parser a
parseFail' toks msg = Parser $ \st kerr _ -> kerr st (mkParserError [] toks msg)
parseFail :: SourceToken -> ParserErrorType -> Parser a
parseFail = parseFail' . pure
+addWarning :: [SourceToken] -> ParserWarningType -> Parser ()
+addWarning toks ty = Parser $ \st _ ksucc ->
+ ksucc (st { parserWarnings = mkParserError [] toks ty : parserWarnings st }) ()
+
pushBack :: SourceToken -> Parser ()
pushBack tok = Parser $ \st _ ksucc ->
ksucc (st { parserBuff = Right tok : parserBuff st }) ()
@@ -121,3 +136,52 @@ tryPrefix (Parser lhs) rhs = Parser $ \st kerr ksucc ->
(\st' res -> do
let Parser k = (Just res,) <$> rhs
k st' kerr ksucc)
+
+oneOf :: NE.NonEmpty (Parser a) -> Parser a
+oneOf parsers = Parser $ \st kerr ksucc -> do
+ let
+ prevErrs = parserErrors st
+ go (st', Right a) _ = (st', Right a)
+ go _ (st', Right a) = (st', Right a)
+ go (st1, Left errs1) (st2, Left errs2)
+ | errRange (NE.last errs2) > errRange (NE.last errs1) = (st2, Left errs2)
+ | otherwise = (st1, Left errs1)
+ case foldr1 go $ runParser (st { parserErrors = [] }) <$> parsers of
+ (st', Left errs) -> kerr (st' { parserErrors = prevErrs <> NE.tail errs}) $ NE.head errs
+ (st', Right res) -> ksucc (st' { parserErrors = prevErrs }) res
+
+manyDelimited :: Token -> Token -> Token -> Parser a -> Parser [a]
+manyDelimited open close sep p = do
+ _ <- token open
+ res <- go1
+ _ <- token close
+ pure res
+ where
+ go1 =
+ oneOf $ NE.fromList
+ [ go2 . pure =<< p
+ , pure []
+ ]
+
+ go2 acc =
+ oneOf $ NE.fromList
+ [ token sep *> (go2 . (: acc) =<< p)
+ , pure (reverse acc)
+ ]
+
+token :: Token -> Parser SourceToken
+token t = do
+ t' <- munch
+ if t == tokValue t'
+ then pure t'
+ else parseError t'
+
+munch :: Parser SourceToken
+munch = Parser $ \state@ParserState {..} kerr ksucc ->
+ case parserBuff of
+ Right tok : parserBuff' ->
+ ksucc (state { parserBuff = parserBuff' }) tok
+ Left (_, err) : _ ->
+ kerr state err
+ [] ->
+ error "Empty input"
diff --git a/src/Language/PureScript/CST/Parser.y b/src/Language/PureScript/CST/Parser.y
index 35b40667e1..9560619a4a 100644
--- a/src/Language/PureScript/CST/Parser.y
+++ b/src/Language/PureScript/CST/Parser.y
@@ -1,36 +1,55 @@
{
module Language.PureScript.CST.Parser
( parseType
- , parseKind
, parseExpr
+ , parseDecl
+ , parseIdent
+ , parseOperator
, parseModule
+ , parseImportDeclP
+ , parseDeclP
+ , parseExprP
+ , parseTypeP
+ , parseModuleNameP
+ , parseQualIdentP
, parse
, PartialResult(..)
) where
import Prelude hiding (lex)
-import Control.Monad ((>=>), when)
-import Data.Foldable (foldl', for_)
+import Control.Monad ((<=<), when)
+import Data.Bifunctor (second)
+import Data.Foldable (foldl', for_, toList)
import qualified Data.List.NonEmpty as NE
import Data.Text (Text)
-import Data.Traversable (for)
+import Data.Traversable (for, sequence)
import Language.PureScript.CST.Errors
+import Language.PureScript.CST.Flatten (flattenType)
import Language.PureScript.CST.Lexer
import Language.PureScript.CST.Monad
import Language.PureScript.CST.Positions
import Language.PureScript.CST.Types
import Language.PureScript.CST.Utils
import qualified Language.PureScript.Names as N
+import qualified Language.PureScript.Roles as R
import Language.PureScript.PSString (PSString)
}
-%expect 98
+%expect 0
-%name parseKind kind
%name parseType type
%name parseExpr expr
+%name parseIdent ident
+%name parseOperator op
%name parseModuleBody moduleBody
+%name parseDecl decl
+%partial parseImportDeclP importDeclP
+%partial parseDeclP declP
+%partial parseExprP exprP
+%partial parseTypeP typeP
+%partial parseModuleNameP moduleNameP
+%partial parseQualIdentP qualIdentP
%partial parseModuleHeader moduleHeader
%partial parseDoStatement doStatement
%partial parseDoExpr doExpr
@@ -38,6 +57,7 @@ import Language.PureScript.PSString (PSString)
%partial parseGuardExpr guardExpr
%partial parseGuardNext guardNext
%partial parseGuardStatement guardStatement
+%partial parseClassSignature classSignature
%partial parseClassSuper classSuper
%partial parseClassNameAndFundeps classNameAndFundeps
%partial parseBinderAndArrow binderAndArrow
@@ -47,109 +67,111 @@ import Language.PureScript.PSString (PSString)
%lexer { lexer } { SourceToken _ TokEof }
%token
- '(' { SourceToken _ TokLeftParen }
- ')' { SourceToken _ TokRightParen }
- '{' { SourceToken _ TokLeftBrace }
- '}' { SourceToken _ TokRightBrace }
- '[' { SourceToken _ TokLeftSquare }
- ']' { SourceToken _ TokRightSquare }
- '\{' { SourceToken _ TokLayoutStart }
- '\}' { SourceToken _ TokLayoutEnd }
- '\;' { SourceToken _ TokLayoutSep }
- '<-' { SourceToken _ (TokLeftArrow _) }
- '->' { SourceToken _ (TokRightArrow _) }
- '<=' { SourceToken _ (TokOperator [] sym) | isLeftFatArrow sym }
- '=>' { SourceToken _ (TokRightFatArrow _) }
- ':' { SourceToken _ (TokOperator [] ":") }
- '::' { SourceToken _ (TokDoubleColon _) }
- '=' { SourceToken _ TokEquals }
- '|' { SourceToken _ TokPipe }
- '`' { SourceToken _ TokTick }
- '.' { SourceToken _ TokDot }
- ',' { SourceToken _ TokComma }
- '_' { SourceToken _ TokUnderscore }
- '\\' { SourceToken _ TokBackslash }
- '-' { SourceToken _ (TokOperator [] "-") }
- '@' { SourceToken _ (TokOperator [] "@") }
- '#' { SourceToken _ (TokOperator [] "#") }
- 'ado' { SourceToken _ (TokLowerName _ "ado") }
- 'as' { SourceToken _ (TokLowerName [] "as") }
- 'case' { SourceToken _ (TokLowerName [] "case") }
- 'class' { SourceToken _ (TokLowerName [] "class") }
- 'data' { SourceToken _ (TokLowerName [] "data") }
- 'derive' { SourceToken _ (TokLowerName [] "derive") }
- 'do' { SourceToken _ (TokLowerName _ "do") }
- 'else' { SourceToken _ (TokLowerName [] "else") }
- 'false' { SourceToken _ (TokLowerName [] "false") }
- 'forall' { SourceToken _ (TokForall ASCII) }
- 'forallu' { SourceToken _ (TokForall Unicode) }
- 'foreign' { SourceToken _ (TokLowerName [] "foreign") }
- 'hiding' { SourceToken _ (TokLowerName [] "hiding") }
- 'import' { SourceToken _ (TokLowerName [] "import") }
- 'if' { SourceToken _ (TokLowerName [] "if") }
- 'in' { SourceToken _ (TokLowerName [] "in") }
- 'infix' { SourceToken _ (TokLowerName [] "infix") }
- 'infixl' { SourceToken _ (TokLowerName [] "infixl") }
- 'infixr' { SourceToken _ (TokLowerName [] "infixr") }
- 'instance' { SourceToken _ (TokLowerName [] "instance") }
- 'kind' { SourceToken _ (TokLowerName [] "kind") }
- 'let' { SourceToken _ (TokLowerName [] "let") }
- 'module' { SourceToken _ (TokLowerName [] "module") }
- 'newtype' { SourceToken _ (TokLowerName [] "newtype") }
- 'of' { SourceToken _ (TokLowerName [] "of") }
- 'then' { SourceToken _ (TokLowerName [] "then") }
- 'true' { SourceToken _ (TokLowerName [] "true") }
- 'type' { SourceToken _ (TokLowerName [] "type") }
- 'where' { SourceToken _ (TokLowerName [] "where") }
- '(->)' { SourceToken _ (TokSymbolArr _) }
- '(..)' { SourceToken _ (TokSymbolName [] "..") }
- LOWER { SourceToken _ (TokLowerName [] _) }
- QUAL_LOWER { SourceToken _ (TokLowerName _ _) }
- UPPER { SourceToken _ (TokUpperName [] _) }
- QUAL_UPPER { SourceToken _ (TokUpperName _ _) }
- SYMBOL { SourceToken _ (TokSymbolName [] _) }
- QUAL_SYMBOL { SourceToken _ (TokSymbolName _ _) }
- OPERATOR { SourceToken _ (TokOperator [] _) }
- QUAL_OPERATOR { SourceToken _ (TokOperator _ _) }
- LIT_HOLE { SourceToken _ (TokHole _) }
- LIT_CHAR { SourceToken _ (TokChar _ _) }
- LIT_STRING { SourceToken _ (TokString _ _) }
- LIT_RAW_STRING { SourceToken _ (TokRawString _) }
- LIT_INT { SourceToken _ (TokInt _ _) }
- LIT_NUMBER { SourceToken _ (TokNumber _ _) }
+ '(' { SourceToken _ TokLeftParen }
+ ')' { SourceToken _ TokRightParen }
+ '{' { SourceToken _ TokLeftBrace }
+ '}' { SourceToken _ TokRightBrace }
+ '[' { SourceToken _ TokLeftSquare }
+ ']' { SourceToken _ TokRightSquare }
+ '\{' { SourceToken _ TokLayoutStart }
+ '\}' { SourceToken _ TokLayoutEnd }
+ '\;' { SourceToken _ TokLayoutSep }
+ '<-' { SourceToken _ (TokLeftArrow _) }
+ '->' { SourceToken _ (TokRightArrow _) }
+ '<=' { SourceToken _ (TokOperator [] sym) | isLeftFatArrow sym }
+ '=>' { SourceToken _ (TokRightFatArrow _) }
+ ':' { SourceToken _ (TokOperator [] ":") }
+ '::' { SourceToken _ (TokDoubleColon _) }
+ '=' { SourceToken _ TokEquals }
+ '|' { SourceToken _ TokPipe }
+ '`' { SourceToken _ TokTick }
+ '.' { SourceToken _ TokDot }
+ ',' { SourceToken _ TokComma }
+ '_' { SourceToken _ TokUnderscore }
+ '\\' { SourceToken _ TokBackslash }
+ '-' { SourceToken _ (TokOperator [] "-") }
+ '@' { SourceToken _ (TokOperator [] "@") }
+ 'ado' { SourceToken _ (TokLowerName _ "ado") }
+ 'as' { SourceToken _ (TokLowerName [] "as") }
+ 'case' { SourceToken _ (TokLowerName [] "case") }
+ 'class' { SourceToken _ (TokLowerName [] "class") }
+ 'data' { SourceToken _ (TokLowerName [] "data") }
+ 'derive' { SourceToken _ (TokLowerName [] "derive") }
+ 'do' { SourceToken _ (TokLowerName _ "do") }
+ 'else' { SourceToken _ (TokLowerName [] "else") }
+ 'false' { SourceToken _ (TokLowerName [] "false") }
+ 'forall' { SourceToken _ (TokForall ASCII) }
+ 'forallu' { SourceToken _ (TokForall Unicode) }
+ 'foreign' { SourceToken _ (TokLowerName [] "foreign") }
+ 'hiding' { SourceToken _ (TokLowerName [] "hiding") }
+ 'import' { SourceToken _ (TokLowerName [] "import") }
+ 'if' { SourceToken _ (TokLowerName [] "if") }
+ 'in' { SourceToken _ (TokLowerName [] "in") }
+ 'infix' { SourceToken _ (TokLowerName [] "infix") }
+ 'infixl' { SourceToken _ (TokLowerName [] "infixl") }
+ 'infixr' { SourceToken _ (TokLowerName [] "infixr") }
+ 'instance' { SourceToken _ (TokLowerName [] "instance") }
+ 'let' { SourceToken _ (TokLowerName [] "let") }
+ 'module' { SourceToken _ (TokLowerName [] "module") }
+ 'newtype' { SourceToken _ (TokLowerName [] "newtype") }
+ 'nominal' { SourceToken _ (TokLowerName [] "nominal") }
+ 'phantom' { SourceToken _ (TokLowerName [] "phantom") }
+ 'of' { SourceToken _ (TokLowerName [] "of") }
+ 'representational' { SourceToken _ (TokLowerName [] "representational") }
+ 'role' { SourceToken _ (TokLowerName [] "role") }
+ 'then' { SourceToken _ (TokLowerName [] "then") }
+ 'true' { SourceToken _ (TokLowerName [] "true") }
+ 'type' { SourceToken _ (TokLowerName [] "type") }
+ 'where' { SourceToken _ (TokLowerName [] "where") }
+ '(->)' { SourceToken _ (TokSymbolArr _) }
+ '(..)' { SourceToken _ (TokSymbolName [] "..") }
+ LOWER { SourceToken _ (TokLowerName [] _) }
+ QUAL_LOWER { SourceToken _ (TokLowerName _ _) }
+ UPPER { SourceToken _ (TokUpperName [] _) }
+ QUAL_UPPER { SourceToken _ (TokUpperName _ _) }
+ SYMBOL { SourceToken _ (TokSymbolName [] _) }
+ QUAL_SYMBOL { SourceToken _ (TokSymbolName _ _) }
+ OPERATOR { SourceToken _ (TokOperator [] _) }
+ QUAL_OPERATOR { SourceToken _ (TokOperator _ _) }
+ LIT_HOLE { SourceToken _ (TokHole _) }
+ LIT_CHAR { SourceToken _ (TokChar _ _) }
+ LIT_STRING { SourceToken _ (TokString _ _) }
+ LIT_RAW_STRING { SourceToken _ (TokRawString _) }
+ LIT_INT { SourceToken _ (TokInt _ _) }
+ LIT_NUMBER { SourceToken _ (TokNumber _ _) }
%%
-many(a) :: { NE.NonEmpty _ }
- : many1(a) { NE.reverse $1 }
+many(a) :: { NE.NonEmpty a }
+ : many1(a) %shift { NE.reverse $1 }
-many1(a) :: { NE.NonEmpty _ }
+many1(a) :: { NE.NonEmpty a }
: a { pure $1 }
| many1(a) a { NE.cons $2 $1 }
-manySep(a, sep) :: { NE.NonEmpty _ }
+manySep(a, sep) :: { NE.NonEmpty a }
: manySep1(a, sep) { NE.reverse $1 }
-manySep1(a, sep) :: { NE.NonEmpty _ }
+manySep1(a, sep) :: { NE.NonEmpty a }
: a { pure $1 }
| manySep1(a, sep) sep a { NE.cons $3 $1 }
-manySepOrEmpty(a, sep) :: { [_] }
+manySepOrEmpty(a, sep) :: { [a] }
: {- empty -} { [] }
| manySep(a, sep) { NE.toList $1 }
-manyOrEmpty(a) :: { [_] }
+manyOrEmpty(a) :: { [a] }
: {- empty -} { [] }
| many(a) { NE.toList $1 }
-sep(a, s) :: { Separated _ }
+sep(a, s) :: { Separated a }
: sep1(a, s) { separated $1 }
-sep1(a, s) :: { [(SourceToken, _)] }
- : a { [(placeholder, $1)] }
+sep1(a, s) :: { [(SourceToken, a)] }
+ : a %shift { [(placeholder, $1)] }
| sep1(a, s) s a { ($2, $3) : $1 }
-delim(a, b, c, d) :: { Delimited _ }
+delim(a, b, c, d) :: { Delimited b }
: a d { Wrapped $1 Nothing $2 }
| a sep(b, c) d { Wrapped $1 (Just $2) $3 }
@@ -157,49 +179,53 @@ moduleName :: { Name N.ModuleName }
: UPPER {% upperToModuleName $1 }
| QUAL_UPPER {% upperToModuleName $1 }
-qualProperName :: { QualifiedName (N.ProperName a) }
- : UPPER {% toQualifiedName N.ProperName $1 }
- | QUAL_UPPER {% toQualifiedName N.ProperName $1 }
+qualProperName :: { QualifiedProperName }
+ : UPPER {% qualifiedProperName <\$> toQualifiedName N.ProperName $1 }
+ | QUAL_UPPER {% qualifiedProperName <\$> toQualifiedName N.ProperName $1 }
-properName :: { Name (N.ProperName a) }
- : UPPER {% toName N.ProperName $1 }
+properName :: { ProperName }
+ : UPPER {% properName <\$> toName N.ProperName $1 }
qualIdent :: { QualifiedName Ident }
: LOWER {% toQualifiedName Ident $1 }
| QUAL_LOWER {% toQualifiedName Ident $1 }
| 'as' {% toQualifiedName Ident $1 }
| 'hiding' {% toQualifiedName Ident $1 }
- | 'kind' {% toQualifiedName Ident $1 }
+ | 'role' {% toQualifiedName Ident $1 }
+ | 'nominal' {% toQualifiedName Ident $1 }
+ | 'representational' {% toQualifiedName Ident $1 }
+ | 'phantom' {% toQualifiedName Ident $1 }
ident :: { Name Ident }
: LOWER {% toName Ident $1 }
| 'as' {% toName Ident $1 }
| 'hiding' {% toName Ident $1 }
- | 'kind' {% toName Ident $1 }
-
-qualOp :: { QualifiedName (N.OpName a) }
- : OPERATOR {% toQualifiedName N.OpName $1 }
- | QUAL_OPERATOR {% toQualifiedName N.OpName $1 }
- | '<=' {% toQualifiedName N.OpName $1 }
- | '-' {% toQualifiedName N.OpName $1 }
- | '#' {% toQualifiedName N.OpName $1 }
- | ':' {% toQualifiedName N.OpName $1 }
-
-op :: { Name (N.OpName a) }
- : OPERATOR {% toName N.OpName $1 }
- | '<=' {% toName N.OpName $1 }
- | '-' {% toName N.OpName $1 }
- | '#' {% toName N.OpName $1 }
- | ':' {% toName N.OpName $1 }
-
-qualSymbol :: { QualifiedName (N.OpName a) }
- : SYMBOL {% toQualifiedName N.OpName $1 }
- | QUAL_SYMBOL {% toQualifiedName N.OpName $1 }
- | '(..)' {% toQualifiedName N.OpName $1 }
-
-symbol :: { Name (N.OpName a) }
- : SYMBOL {% toName N.OpName $1 }
- | '(..)' {% toName N.OpName $1 }
+ | 'role' {% toName Ident $1 }
+ | 'nominal' {% toName Ident $1 }
+ | 'representational' {% toName Ident $1 }
+ | 'phantom' {% toName Ident $1 }
+
+qualOp :: { QualifiedOpName }
+ : OPERATOR {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
+ | QUAL_OPERATOR {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
+ | '<=' {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
+ | '-' {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
+ | ':' {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
+
+op :: { OpName }
+ : OPERATOR {% opName <\$> toName N.OpName $1 }
+ | '<=' {% opName <\$> toName N.OpName $1 }
+ | '-' {% opName <\$> toName N.OpName $1 }
+ | ':' {% opName <\$> toName N.OpName $1 }
+
+qualSymbol :: { QualifiedOpName }
+ : SYMBOL {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
+ | QUAL_SYMBOL {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
+ | '(..)' {% qualifiedOpName <\$> toQualifiedName N.OpName $1 }
+
+symbol :: { OpName }
+ : SYMBOL {% opName <\$> toName N.OpName $1 }
+ | '(..)' {% opName <\$> toName N.OpName $1 }
label :: { Label }
: LOWER { toLabel $1 }
@@ -224,11 +250,14 @@ label :: { Label }
| 'infixl' { toLabel $1 }
| 'infixr' { toLabel $1 }
| 'instance' { toLabel $1 }
- | 'kind' { toLabel $1 }
| 'let' { toLabel $1 }
| 'module' { toLabel $1 }
| 'newtype' { toLabel $1 }
+ | 'nominal' { toLabel $1 }
| 'of' { toLabel $1 }
+ | 'phantom' { toLabel $1 }
+ | 'representational' { toLabel $1 }
+ | 'role' { toLabel $1 }
| 'then' { toLabel $1 }
| 'true' { toLabel $1 }
| 'type' { toLabel $1 }
@@ -255,61 +284,58 @@ boolean :: { (SourceToken, Bool) }
: 'true' { toBoolean $1 }
| 'false' { toBoolean $1 }
-kind :: { Kind () }
- : kind1 { $1 }
- | kind1 '->' kind { KindArr () $1 $2 $3 }
-
-kind1 :: { Kind () }
- : qualProperName { KindName () $1 }
- | '#' kind1 { KindRow () $1 $2 }
- | '(' kind ')' { KindParens () (Wrapped $1 $2 $3) }
-
type :: { Type () }
- : type1 { $1 }
- | type1 '::' kind { TypeKinded () $1 $2 $3 }
+ : type1 %shift { $1 }
+ | type1 '::' type { TypeKinded () $1 $2 $3 }
type1 :: { Type () }
: type2 { $1 }
| forall many(typeVarBinding) '.' type1 { TypeForall () $1 $2 $3 $4 }
type2 :: { Type () }
- : type3 { $1 }
+ : type3 %shift { $1 }
| type3 '->' type1 { TypeArr () $1 $2 $3 }
| type3 '=>' type1 {% do cs <- toConstraint $1; pure $ TypeConstrained () cs $2 $3 }
type3 :: { Type () }
- : type4 { $1 }
- | type3 qualOp type4 { TypeOp () $1 $2 $3 }
+ : type4 %shift { $1 }
+ | type3 qualOp type4 %shift { TypeOp () $1 (getQualifiedOpName $2) $3 }
type4 :: { Type () }
+ : type5 %shift { $1 }
+ | '-' int { uncurry (TypeInt () (Just $1)) (second negate $2) }
+
+type5 :: { Type () }
: typeAtom { $1 }
- | type4 typeAtom { TypeApp () $1 $2 }
+ | type5 typeAtom { TypeApp () $1 $2 }
typeAtom :: { Type ()}
: '_' { TypeWildcard () $1 }
| ident { TypeVar () $1 }
- | qualProperName { TypeConstructor () $1 }
- | qualSymbol { TypeOpName () $1 }
+ | qualProperName { TypeConstructor () (getQualifiedProperName $1) }
+ | qualSymbol { TypeOpName () (getQualifiedOpName $1) }
| string { uncurry (TypeString ()) $1 }
+ | int { uncurry (TypeInt () Nothing) $1 }
| hole { TypeHole () $1 }
| '(->)' { TypeArrName () $1 }
| '{' row '}' { TypeRecord () (Wrapped $1 $2 $3) }
| '(' row ')' { TypeRow () (Wrapped $1 $2 $3) }
| '(' type1 ')' { TypeParens () (Wrapped $1 $2 $3) }
- | '(' typeKindedAtom '::' kind ')' { TypeParens () (Wrapped $1 (TypeKinded () $2 $3 $4) $5) }
+ | '(' typeKindedAtom '::' type ')' { TypeParens () (Wrapped $1 (TypeKinded () $2 $3 $4) $5) }
-- Due to a conflict between row syntax and kinded type syntax, we require
-- kinded type variables to be wrapped in parens. Thus `(a :: Foo)` is always a
-- row, and to annotate `a` with kind `Foo`, one must use `((a) :: Foo)`.
typeKindedAtom :: { Type () }
: '_' { TypeWildcard () $1 }
- | qualProperName { TypeConstructor () $1 }
- | qualSymbol { TypeOpName () $1 }
+ | qualProperName { TypeConstructor () (getQualifiedProperName $1) }
+ | qualSymbol { TypeOpName () (getQualifiedOpName $1) }
+ | int { uncurry (TypeInt () Nothing) $1 }
| hole { TypeHole () $1 }
| '{' row '}' { TypeRecord () (Wrapped $1 $2 $3) }
| '(' row ')' { TypeRow () (Wrapped $1 $2 $3) }
| '(' type1 ')' { TypeParens () (Wrapped $1 $2 $3) }
- | '(' typeKindedAtom '::' kind ')' { TypeParens () (Wrapped $1 (TypeKinded () $2 $3 $4) $5) }
+ | '(' typeKindedAtom '::' type ')' { TypeParens () (Wrapped $1 (TypeKinded () $2 $3 $4) $5) }
row :: { Row () }
: {- empty -} { Row Nothing Nothing }
@@ -321,24 +347,30 @@ rowLabel :: { Labeled Label (Type ()) }
: label '::' type { Labeled $1 $2 $3 }
typeVarBinding :: { TypeVarBinding () }
- : ident { TypeVarName $1 }
- | '(' ident '::' kind ')' { TypeVarKinded (Wrapped $1 (Labeled $2 $3 $4) $5) }
+ : ident { TypeVarName (Nothing, $1) }
+ | '@' ident { TypeVarName (Just $1, $2) }
+ | '(' ident '::' type ')' {% checkNoWildcards $4 *> pure (TypeVarKinded (Wrapped $1 (Labeled (Nothing, $2) $3 $4) $5)) }
+ | '(' '@' ident '::' type ')' {% checkNoWildcards $5 *> pure (TypeVarKinded (Wrapped $1 (Labeled (Just $2, $3) $4 $5) $6)) }
+
+typeVarBindingPlain :: { TypeVarBinding () }
+ : ident { TypeVarName (Nothing, $1) }
+ | '(' ident '::' type ')' {% checkNoWildcards $4 *> pure (TypeVarKinded (Wrapped $1 (Labeled (Nothing, $2) $3 $4) $5)) }
forall :: { SourceToken }
: 'forall' { $1 }
| 'forallu' { $1 }
exprWhere :: { Where () }
- : expr { Where $1 Nothing }
+ : expr %shift { Where $1 Nothing }
| expr 'where' '\{' manySep(letBinding, '\;') '\}' { Where $1 (Just ($2, $4)) }
expr :: { Expr () }
- : expr1 { $1 }
+ : expr1 %shift { $1 }
| expr1 '::' type { ExprTyped () $1 $2 $3 }
expr1 :: { Expr () }
- : expr2 { $1 }
- | expr1 qualOp expr2 { ExprOp () $1 $2 $3 }
+ : expr2 %shift { $1 }
+ | expr1 qualOp expr2 %shift { ExprOp () $1 (getQualifiedOpName $2) $3 }
expr2 :: { Expr () }
: expr3 { $1 }
@@ -346,10 +378,10 @@ expr2 :: { Expr () }
exprBacktick :: { Expr () }
: expr3 { $1 }
- | exprBacktick qualOp expr3 { ExprOp () $1 $2 $3 }
+ | exprBacktick qualOp expr3 { ExprOp () $1 (getQualifiedOpName $2) $3 }
expr3 :: { Expr () }
- : expr4 { $1 }
+ : expr4 %shift { $1 }
| '-' expr3 { ExprNegate () $1 $2 }
expr4 :: { Expr () }
@@ -362,6 +394,7 @@ expr4 :: { Expr () }
ExprApp () (ExprApp () $1 lhs) rhs
_ -> ExprApp () $1 $2
}
+ | expr4 '@' typeAtom { ExprVisibleTypeApp () $1 $2 $3 }
expr5 :: { Expr () }
: expr6 { $1 }
@@ -376,12 +409,12 @@ expr5 :: { Expr () }
-- at any level, but this is ambiguous. We allow it in the case of a singleton
-- case, since this is used in the wild.
| 'case' sep(expr, ',') 'of' '\{' sep(binder1, ',') '->' '\}' exprWhere
- { ExprCase () (CaseOf $1 $2 $3 (pure ($5, Unconditional $6 $8))) }
- | 'case' sep(expr, ',') 'of' '\{' sep(binder1, ',') '\}' guarded('->')
- { ExprCase () (CaseOf $1 $2 $3 (pure ($5, $7))) }
+ {% addWarning (let (a,b) = whereRange $8 in [a, b]) WarnDeprecatedCaseOfOffsideSyntax *> pure (ExprCase () (CaseOf $1 $2 $3 (pure ($5, Unconditional $6 $8)))) }
+ | 'case' sep(expr, ',') 'of' '\{' sep(binder1, ',') '\}' guardedCase
+ {% addWarning (let (a,b) = guardedRange $7 in [a, b]) WarnDeprecatedCaseOfOffsideSyntax *> pure (ExprCase () (CaseOf $1 $2 $3 (pure ($5, $7)))) }
expr6 :: { Expr () }
- : expr7 { $1 }
+ : expr7 %shift { $1 }
| expr7 '{' '}' { ExprApp () $1 (ExprRecord () (Wrapped $2 Nothing $3)) }
| expr7 '{' sep(recordUpdateOrLabel, ',') '}'
{% toRecordFields $3 >>= \case
@@ -397,8 +430,8 @@ exprAtom :: { Expr () }
: '_' { ExprSection () $1 }
| hole { ExprHole () $1 }
| qualIdent { ExprIdent () $1 }
- | qualProperName { ExprConstructor () $1 }
- | qualSymbol { ExprOpName () $1 }
+ | qualProperName { ExprConstructor () (getQualifiedProperName $1) }
+ | qualSymbol { ExprOpName () (getQualifiedOpName $1) }
| boolean { uncurry (ExprBoolean ()) $1 }
| char { uncurry (ExprChar ()) $1 }
| string { uncurry (ExprString ()) $1 }
@@ -424,19 +457,26 @@ recordUpdate :: { RecordUpdate () }
letBinding :: { LetBinding () }
: ident '::' type { LetBindingSignature () (Labeled $1 $2 $3) }
- | ident guarded('=') { LetBindingName () (ValueBindingFields $1 [] $2) }
- | ident many(binderAtom) guarded('=') { LetBindingName () (ValueBindingFields $1 (NE.toList $2) $3) }
+ | ident guardedDecl { LetBindingName () (ValueBindingFields $1 [] $2) }
+ | ident many(binderAtom) guardedDecl { LetBindingName () (ValueBindingFields $1 (NE.toList $2) $3) }
| binder1 '=' exprWhere { LetBindingPattern () $1 $2 $3 }
caseBranch :: { (Separated (Binder ()), Guarded ()) }
- : sep(binder1, ',') guarded('->') { ($1, $2) }
+ : sep(binder1, ',') guardedCase { ($1, $2) }
+
+guardedDecl :: { Guarded () }
+ : '=' exprWhere { Unconditional $1 $2 }
+ | many(guardedDeclExpr) { Guarded $1 }
+
+guardedDeclExpr :: { GuardedExpr () }
+ : guard '=' exprWhere { uncurry GuardedExpr $1 $2 $3 }
-guarded(a) :: { Guarded () }
- : a exprWhere { Unconditional $1 $2 }
- | many(guardedExpr(a)) { Guarded $1 }
+guardedCase :: { Guarded () }
+ : '->' exprWhere { Unconditional $1 $2 }
+ | many(guardedCaseExpr) { Guarded $1 }
-guardedExpr(a) :: { GuardedExpr () }
- : guard a exprWhere { uncurry GuardedExpr $1 $2 $3 }
+guardedCaseExpr :: { GuardedExpr () }
+ : guard '->' exprWhere { uncurry GuardedExpr $1 $2 $3 }
-- Do/Ado statements and pattern guards require unbounded lookahead due to many
-- conflicts between `binder` and `expr` syntax. For example `Foo a b c` can
@@ -529,21 +569,21 @@ binder :: { Binder () }
binder1 :: { Binder () }
: binder2 { $1 }
- | binder1 qualOp binder2 { BinderOp () $1 $2 $3 }
+ | binder1 qualOp binder2 { BinderOp () $1 (getQualifiedOpName $2) $3 }
binder2 :: { Binder () }
: many(binderAtom) {% toBinderConstructor $1 }
+ | '-' number { uncurry (BinderNumber () (Just $1)) $2 }
binderAtom :: { Binder () }
: '_' { BinderWildcard () $1 }
- | ident { BinderVar () $1 }
+ | ident %shift { BinderVar () $1 }
| ident '@' binderAtom { BinderNamed () $1 $2 $3 }
- | qualProperName { BinderConstructor () $1 [] }
+ | qualProperName { BinderConstructor () (getQualifiedProperName $1) [] }
| boolean { uncurry (BinderBoolean ()) $1 }
| char { uncurry (BinderChar ()) $1 }
| string { uncurry (BinderString ()) $1 }
| number { uncurry (BinderNumber () Nothing) $1 }
- | '-' number { uncurry (BinderNumber () (Just $1)) $2 }
| delim('[', binder, ',', ']') { BinderArray () $1 }
| delim('{', recordBinder, ',', '}') { BinderRecord () $1 }
| '(' binder ')' { BinderParens () (Wrapped $1 $2 $3) }
@@ -577,7 +617,7 @@ moduleDecls :: { ([ImportDecl ()], [Declaration ()]) }
: manySep(moduleDecl, '\;') {% toModuleDecls $ NE.toList $1 }
| {- empty -} { ([], []) }
-moduleDecl :: { TmpModuleDecl a }
+moduleDecl :: { TmpModuleDecl () }
: importDecl { TmpImport $1 }
| sep(decl, declElse) { TmpChain $1 }
@@ -591,18 +631,17 @@ exports :: { Maybe (DelimitedNonEmpty (Export ())) }
export :: { Export () }
: ident { ExportValue () $1 }
- | symbol { ExportOp () $1 }
- | properName { ExportType () $1 Nothing }
- | properName dataMembers { ExportType () $1 (Just $2) }
- | 'type' symbol { ExportTypeOp () $1 $2 }
- | 'class' properName { ExportClass () $1 $2 }
- | 'kind' properName { ExportKind () $1 $2 }
+ | symbol { ExportOp () (getOpName $1) }
+ | properName { ExportType () (getProperName $1) Nothing }
+ | properName dataMembers { ExportType () (getProperName $1) (Just $2) }
+ | 'type' symbol { ExportTypeOp () $1 (getOpName $2) }
+ | 'class' properName { ExportClass () $1 (getProperName $2) }
| 'module' moduleName { ExportModule () $1 $2 }
dataMembers :: { (DataMembers ()) }
: '(..)' { DataAll () $1 }
| '(' ')' { DataEnumerated () (Wrapped $1 Nothing $2) }
- | '(' sep(properName, ',') ')' { DataEnumerated () (Wrapped $1 (Just $2) $3) }
+ | '(' sep(properName, ',') ')' { DataEnumerated () (Wrapped $1 (Just \$ getProperName <\$> $2) $3) }
importDecl :: { ImportDecl () }
: 'import' moduleName imports { ImportDecl () $1 $2 $3 Nothing }
@@ -615,41 +654,51 @@ imports :: { Maybe (Maybe SourceToken, DelimitedNonEmpty (Import ())) }
import :: { Import () }
: ident { ImportValue () $1 }
- | symbol { ImportOp () $1 }
- | properName { ImportType () $1 Nothing }
- | properName dataMembers { ImportType () $1 (Just $2) }
- | 'type' symbol { ImportTypeOp () $1 $2 }
- | 'class' properName { ImportClass () $1 $2 }
- | 'kind' properName { ImportKind () $1 $2 }
+ | symbol { ImportOp () (getOpName $1) }
+ | properName { ImportType () (getProperName $1) Nothing }
+ | properName dataMembers { ImportType () (getProperName $1) (Just $2) }
+ | 'type' symbol { ImportTypeOp () $1 (getOpName $2) }
+ | 'class' properName { ImportClass () $1 (getProperName $2) }
decl :: { Declaration () }
- : dataHead { DeclData () $1 Nothing }
- | dataHead '=' sep(dataCtor, '|') { DeclData () $1 (Just ($2, $3)) }
+ : dataHead manyOrEmpty(deriveClause) { DeclData () $1 Nothing $2 }
+ | dataHead '=' sep(dataCtor, '|') manyOrEmpty(deriveClause) { DeclData () $1 (Just ($2, $3)) $4 }
| typeHead '=' type {% checkNoWildcards $3 *> pure (DeclType () $1 $2 $3) }
- | newtypeHead '=' properName typeAtom {% checkNoWildcards $4 *> pure (DeclNewtype () $1 $2 $3 $4) }
- | classHead {% checkFundeps $1 *> pure (DeclClass () $1 Nothing) }
- | classHead 'where' '\{' manySep(classMember, '\;') '\}' {% checkFundeps $1 *> pure (DeclClass () $1 (Just ($2, $4))) }
+ | newtypeHead '=' properName typeAtom manyOrEmpty(deriveClause) {% checkNoWildcards $4 *> pure (DeclNewtype () $1 $2 (getProperName $3) $4 $5) }
+ | classHead { either id (\h -> DeclClass () h Nothing) $1 }
+ | classHead 'where' '\{' manySep(classMember, '\;') '\}' {% either (const (parseError $2)) (\h -> pure $ DeclClass () h (Just ($2, $4))) $1 }
| instHead { DeclInstanceChain () (Separated (Instance $1 Nothing) []) }
| instHead 'where' '\{' manySep(instBinding, '\;') '\}' { DeclInstanceChain () (Separated (Instance $1 (Just ($2, $4))) []) }
+ | 'data' properName '::' type {% checkNoWildcards $4 *> pure (DeclKindSignature () $1 (Labeled (getProperName $2) $3 $4)) }
+ | 'newtype' properName '::' type {% checkNoWildcards $4 *> pure (DeclKindSignature () $1 (Labeled (getProperName $2) $3 $4)) }
+ | 'type' properName '::' type {% checkNoWildcards $4 *> pure (DeclKindSignature () $1 (Labeled (getProperName $2) $3 $4)) }
| 'derive' instHead { DeclDerive () $1 Nothing $2 }
| 'derive' 'newtype' instHead { DeclDerive () $1 (Just $2) $3 }
| ident '::' type { DeclSignature () (Labeled $1 $2 $3) }
- | ident manyOrEmpty(binderAtom) guarded('=') { DeclValue () (ValueBindingFields $1 $2 $3) }
+ | ident manyOrEmpty(binderAtom) guardedDecl { DeclValue () (ValueBindingFields $1 $2 $3) }
| fixity { DeclFixity () $1 }
- | 'foreign' 'import' foreign { DeclForeign () $1 $2 $3 }
+ | 'foreign' 'import' ident '::' type {% when (isConstrained $5) (addFailure ([$1, $2, nameTok $3, $4] <> toList (flattenType $5)) ErrConstraintInForeignImportSyntax) *> pure (DeclForeign () $1 $2 (ForeignValue (Labeled $3 $4 $5))) }
+ | 'foreign' 'import' 'data' properName '::' type { DeclForeign () $1 $2 (ForeignData $3 (Labeled (getProperName $4) $5 $6)) }
+ | 'type' 'role' properName many(role) { DeclRole () $1 $2 (getProperName $3) $4 }
+
+deriveClause :: { DeriveClause }
+ : 'derive' '(' sep(deriveClass, ',') ')' { DeriveClause $1 (Wrapped $2 $3 $4) }
+
+deriveClass :: { DeriveClass }
+ : qualProperName { DeriveClass (getQualifiedProperName $1) }
dataHead :: { DataHead () }
- : 'data' properName manyOrEmpty(typeVarBinding) { DataHead $1 $2 $3 }
+ : 'data' properName manyOrEmpty(typeVarBindingPlain) { DataHead $1 (getProperName $2) $3 }
typeHead :: { DataHead () }
- : 'type' properName manyOrEmpty(typeVarBinding) { DataHead $1 $2 $3 }
+ : 'type' properName manyOrEmpty(typeVarBindingPlain) { DataHead $1 (getProperName $2) $3 }
newtypeHead :: { DataHead () }
- : 'newtype' properName manyOrEmpty(typeVarBinding) { DataHead $1 $2 $3 }
+ : 'newtype' properName manyOrEmpty(typeVarBindingPlain) { DataHead $1 (getProperName $2) $3 }
dataCtor :: { DataCtor () }
: properName manyOrEmpty(typeAtom)
- {% for_ $2 checkNoWildcards *> pure (DataCtor () $1 $2) }
+ {% for_ $2 checkNoWildcards *> pure (DataCtor () (getProperName $1) $2) }
-- Class head syntax requires unbounded lookahead due to a conflict between
-- row syntax and `typeVarBinding`. `(a :: B)` is either a row in `constraint`
@@ -660,20 +709,26 @@ dataCtor :: { DataCtor () }
-- : 'class' classNameAndFundeps
-- | 'class' constraints '<=' classNameAndFundeps
--
-classHead :: { ClassHead () }
+classHead :: { Either (Declaration ()) (ClassHead ()) }
: 'class'
- {%% revert $ do
- let
- ctr (super, (name, vars, fundeps)) =
- ClassHead $1 super name vars fundeps
- fmap ctr $ tryPrefix parseClassSuper parseClassNameAndFundeps
+ {%% revert $ oneOf $ NE.fromList
+ [ fmap (Left . DeclKindSignature () $1) parseClassSignature
+ , do
+ (super, (name, vars, fundeps)) <- tryPrefix parseClassSuper parseClassNameAndFundeps
+ let hd = ClassHead $1 super name vars fundeps
+ checkFundeps hd
+ pure $ Right hd
+ ]
}
-classSuper
+classSignature :: { Labeled (Name (N.ProperName 'N.TypeName)) (Type ()) }
+ : properName '::' type {%^ revert $ checkNoWildcards $3 *> pure (Labeled (getProperName $1) $2 $3) }
+
+classSuper :: { (OneOrDelimited (Constraint ()), SourceToken) }
: constraints '<=' {%^ revert $ pure ($1, $2) }
classNameAndFundeps :: { (Name (N.ProperName 'N.ClassName), [TypeVarBinding ()], Maybe (SourceToken, Separated ClassFundep)) }
- : properName manyOrEmpty(typeVarBinding) fundeps {%^ revert $ pure ($1, $2, $3) }
+ : properName manyOrEmpty(typeVarBindingPlain) fundeps {%^ revert $ pure (getProperName $1, $2, $3) }
fundeps :: { Maybe (SourceToken, Separated ClassFundep) }
: {- empty -} { Nothing }
@@ -687,60 +742,83 @@ classMember :: { Labeled (Name Ident) (Type ()) }
: ident '::' type {% checkNoWildcards $3 *> pure (Labeled $1 $2 $3) }
instHead :: { InstanceHead () }
- : 'instance' ident '::' constraints '=>' qualProperName manyOrEmpty(typeAtom)
- { InstanceHead $1 $2 $3 (Just ($4, $5)) $6 $7 }
+ : 'instance' constraints '=>' qualProperName manyOrEmpty(typeAtom)
+ { InstanceHead $1 Nothing (Just ($2, $3)) (getQualifiedProperName $4) $5 }
+ | 'instance' qualProperName manyOrEmpty(typeAtom)
+ { InstanceHead $1 Nothing Nothing (getQualifiedProperName $2) $3 }
+ | 'instance' ident '::' constraints '=>' qualProperName manyOrEmpty(typeAtom)
+ { InstanceHead $1 (Just ($2, $3)) (Just ($4, $5)) (getQualifiedProperName $6) $7 }
| 'instance' ident '::' qualProperName manyOrEmpty(typeAtom)
- { InstanceHead $1 $2 $3 Nothing $4 $5 }
+ { InstanceHead $1 (Just ($2, $3)) Nothing (getQualifiedProperName $4) $5 }
constraints :: { OneOrDelimited (Constraint ()) }
: constraint { One $1 }
| '(' sep(constraint, ',') ')' { Many (Wrapped $1 $2 $3) }
constraint :: { Constraint () }
- : qualProperName manyOrEmpty(typeAtom) {% for_ $2 checkNoWildcards *> for_ $2 checkNoForalls *> pure (Constraint () $1 $2) }
+ : qualProperName manyOrEmpty(typeAtom) {% for_ $2 checkNoWildcards *> for_ $2 checkNoForalls *> pure (Constraint () (getQualifiedProperName $1) $2) }
| '(' constraint ')' { ConstraintParens () (Wrapped $1 $2 $3) }
instBinding :: { InstanceBinding () }
: ident '::' type { InstanceBindingSignature () (Labeled $1 $2 $3) }
- | ident manyOrEmpty(binderAtom) guarded('=') { InstanceBindingName () (ValueBindingFields $1 $2 $3) }
+ | ident manyOrEmpty(binderAtom) guardedDecl { InstanceBindingName () (ValueBindingFields $1 $2 $3) }
fixity :: { FixityFields }
- : infix int qualIdent 'as' op { FixityFields $1 $2 (FixityValue (fmap Left $3) $4 $5) }
- | infix int qualProperName 'as' op { FixityFields $1 $2 (FixityValue (fmap Right $3) $4 $5) }
- | infix int 'type' qualProperName 'as' op { FixityFields $1 $2 (FixityType $3 $4 $5 $6) }
+ : infix int qualIdent 'as' op { FixityFields $1 $2 (FixityValue (fmap Left $3) $4 (getOpName $5)) }
+ | infix int qualProperName 'as' op { FixityFields $1 $2 (FixityValue (fmap Right (getQualifiedProperName $3)) $4 (getOpName $5)) }
+ | infix int 'type' qualProperName 'as' op { FixityFields $1 $2 (FixityType $3 (getQualifiedProperName $4) $5 (getOpName $6)) }
infix :: { (SourceToken, Fixity) }
: 'infix' { ($1, Infix) }
| 'infixl' { ($1, Infixl) }
| 'infixr' { ($1, Infixr) }
-foreign :: { Foreign () }
- : ident '::' type { ForeignValue (Labeled $1 $2 $3) }
- | 'data' properName '::' kind { ForeignData $1 (Labeled $2 $3 $4) }
- | 'kind' properName { ForeignKind $1 $2 }
+role :: { Role }
+ : 'nominal' { Role $1 R.Nominal }
+ | 'representational' { Role $1 R.Representational }
+ | 'phantom' { Role $1 R.Phantom }
+
+-- Partial parsers which can be combined with combinators for adhoc use. We need
+-- to revert the lookahead token so that it doesn't consume an extra token
+-- before succeeding.
+
+importDeclP :: { ImportDecl () }
+ : importDecl {%^ revert $ pure $1 }
+
+declP :: { Declaration () }
+ : decl {%^ revert $ pure $1 }
+
+exprP :: { Expr () }
+ : expr {%^ revert $ pure $1 }
+
+typeP :: { Type () }
+ : type {%^ revert $ pure $1 }
+
+moduleNameP :: { Name N.ModuleName }
+ : moduleName {%^ revert $ pure $1 }
+
+qualIdentP :: { QualifiedName Ident }
+ : qualIdent {%^ revert $ pure $1 }
{
lexer :: (SourceToken -> Parser a) -> Parser a
lexer k = munch >>= k
-parse :: Text -> Either (NE.NonEmpty ParserError) (Module ())
-parse = parseModule >=> resFull
+parse :: Text -> ([ParserWarning], Either (NE.NonEmpty ParserError) (Module ()))
+parse = either (([],) . Left) resFull . parseModule . lexModule
data PartialResult a = PartialResult
{ resPartial :: a
- , resFull :: Either (NE.NonEmpty ParserError) a
+ , resFull :: ([ParserWarning], Either (NE.NonEmpty ParserError) a)
} deriving (Functor)
-parseModule :: Text -> Either (NE.NonEmpty ParserError) (PartialResult (Module ()))
-parseModule src = fmap (\header -> PartialResult header (parseFull header)) headerRes
+parseModule :: [LexResult] -> Either (NE.NonEmpty ParserError) (PartialResult (Module ()))
+parseModule toks = fmap (\header -> PartialResult header (parseFull header)) headerRes
where
(st, headerRes) =
- runParser (ParserState (lex src) []) parseModuleHeader
+ runParser (ParserState toks [] []) parseModuleHeader
parseFull header = do
- (decls, trailing) <- snd $ runParser st parseModuleBody
- pure $ header
- { modDecls = decls
- , modTrailingComments = trailing
- }
+ let (ParserState _ _ warnings, res) = runParser st parseModuleBody
+ (warnings, (\(decls, trailing) -> header { modDecls = decls, modTrailingComments = trailing }) <$> res)
}
diff --git a/src/Language/PureScript/CST/Positions.hs b/src/Language/PureScript/CST/Positions.hs
index 67f03a0870..63282e4bef 100644
--- a/src/Language/PureScript/CST/Positions.hs
+++ b/src/Language/PureScript/CST/Positions.hs
@@ -1,6 +1,3 @@
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE NamedFieldPuns #-}
-
-- | This module contains utilities for calculating positions and offsets. While
-- tokens are annotated with ranges, CST nodes are not, but they can be
-- dynamically derived with the functions in this module, which will return the
@@ -11,20 +8,21 @@ module Language.PureScript.CST.Positions where
import Prelude
import Data.Foldable (foldl')
-import qualified Data.List.NonEmpty as NE
+import Data.List.NonEmpty qualified as NE
+import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Data.Void (Void)
-import qualified Data.Text as Text
+import Data.Text qualified as Text
import Language.PureScript.CST.Types
advanceToken :: SourcePos -> Token -> SourcePos
advanceToken pos = applyDelta pos . tokenDelta
advanceLeading :: SourcePos -> [Comment LineFeed] -> SourcePos
-advanceLeading pos = foldl' (\a -> applyDelta a . commentDelta lineDelta) pos
+advanceLeading = foldl' $ \a -> applyDelta a . commentDelta lineDelta
advanceTrailing :: SourcePos -> [Comment Void] -> SourcePos
-advanceTrailing pos = foldl' (\a -> applyDelta a . commentDelta (const (0, 0))) pos
+advanceTrailing = foldl' $ \a -> applyDelta a . commentDelta (const (0, 0))
tokenDelta :: Token -> (Int, Int)
tokenDelta = \case
@@ -117,14 +115,11 @@ nameRange a = (nameTok a, nameTok a)
qualRange :: QualifiedName a -> TokenRange
qualRange a = (qualTok a, qualTok a)
-labelRange :: Label -> TokenRange
-labelRange a = (lblTok a, lblTok a)
-
wrappedRange :: Wrapped a -> TokenRange
-wrappedRange (Wrapped { wrpOpen, wrpClose }) = (wrpOpen, wrpClose)
+wrappedRange Wrapped { wrpOpen, wrpClose } = (wrpOpen, wrpClose)
moduleRange :: Module a -> TokenRange
-moduleRange (Module { modKeyword, modWhere, modImports, modDecls }) =
+moduleRange Module { modKeyword, modWhere, modImports, modDecls } =
case (modImports, modDecls) of
([], []) -> (modKeyword, modWhere)
(is, []) -> (modKeyword, snd . importDeclRange $ last is)
@@ -139,11 +134,10 @@ exportRange = \case
| otherwise -> nameRange a
ExportTypeOp _ a b -> (a, nameTok b)
ExportClass _ a b -> (a, nameTok b)
- ExportKind _ a b -> (a, nameTok b)
ExportModule _ a b -> (a, nameTok b)
importDeclRange :: ImportDecl a -> TokenRange
-importDeclRange (ImportDecl { impKeyword, impModule, impNames, impQual })
+importDeclRange ImportDecl { impKeyword, impModule, impNames, impQual }
| Just (_, modName) <- impQual = (impKeyword, nameTok modName)
| Just (_, imports) <- impNames = (impKeyword, wrpClose imports)
| otherwise = (impKeyword, nameTok impModule)
@@ -157,32 +151,40 @@ importRange = \case
| otherwise -> nameRange a
ImportTypeOp _ a b -> (a, nameTok b)
ImportClass _ a b -> (a, nameTok b)
- ImportKind _ a b -> (a, nameTok b)
dataMembersRange :: DataMembers a -> TokenRange
dataMembersRange = \case
DataAll _ a -> (a, a)
DataEnumerated _ (Wrapped a _ b) -> (a, b)
+deriveClauseRange :: DeriveClause -> TokenRange
+deriveClauseRange (DeriveClause kw classes) = (kw, wrpClose classes)
+
declRange :: Declaration a -> TokenRange
declRange = \case
- DeclData _ hd ctors
+ DeclData _ hd ctors drvs
+ | _:_ <- drvs -> (fst start, snd . deriveClauseRange $ last drvs)
| Just (_, cs) <- ctors -> (fst start, snd . dataCtorRange $ sepLast cs)
| otherwise -> start
where start = dataHeadRange hd
DeclType _ a _ b -> (fst $ dataHeadRange a, snd $ typeRange b)
- DeclNewtype _ a _ _ b -> (fst $ dataHeadRange a, snd $ typeRange b)
+ DeclNewtype _ a _ _ b drvs
+ | _:_ <- drvs -> (fst start, snd . deriveClauseRange $ last drvs)
+ | otherwise -> start
+ where start = (fst $ dataHeadRange a, snd $ typeRange b)
DeclClass _ hd body
| Just (_, ts) <- body -> (fst start, snd . typeRange . lblValue $ NE.last ts)
| otherwise -> start
where start = classHeadRange hd
DeclInstanceChain _ a -> (fst . instanceRange $ sepHead a, snd . instanceRange $ sepLast a)
DeclDerive _ a _ b -> (a, snd $ instanceHeadRange b)
+ DeclKindSignature _ a (Labeled _ _ b) -> (a, snd $ typeRange b)
DeclSignature _ (Labeled a _ b) -> (nameTok a, snd $ typeRange b)
DeclValue _ a -> valueBindingFieldsRange a
DeclFixity _ (FixityFields a _ (FixityValue _ _ b)) -> (fst a, nameTok b)
DeclFixity _ (FixityFields a _ (FixityType _ _ _ b)) -> (fst a, nameTok b)
DeclForeign _ a _ b -> (a, snd $ foreignRange b)
+ DeclRole _ a _ _ b -> (a, roleTok $ NE.last b)
dataHeadRange :: DataHead a -> TokenRange
dataHeadRange (DataHead kw name vars)
@@ -196,7 +198,7 @@ dataCtorRange (DataCtor _ name fields)
classHeadRange :: ClassHead a -> TokenRange
classHeadRange (ClassHead kw _ name vars fdeps)
- | Just (_, fs) <- fdeps = (kw, snd .classFundepRange $ sepLast fs)
+ | Just (_, fs) <- fdeps = (kw, snd . classFundepRange $ sepLast fs)
| [] <- vars = (kw, snd $ nameRange name)
| otherwise = (kw, snd . typeVarBindingRange $ last vars)
@@ -212,7 +214,7 @@ instanceRange (Instance hd bd)
where start = instanceHeadRange hd
instanceHeadRange :: InstanceHead a -> TokenRange
-instanceHeadRange (InstanceHead kw _ _ _ cls types)
+instanceHeadRange (InstanceHead kw _ _ cls types)
| [] <- types = (kw, qualTok cls)
| otherwise = (kw, snd . typeRange $ last types)
@@ -224,7 +226,7 @@ instanceBindingRange = \case
foreignRange :: Foreign a -> TokenRange
foreignRange = \case
ForeignValue (Labeled a _ b) -> (nameTok a, snd $ typeRange b)
- ForeignData a (Labeled _ _ b) -> (a, snd $ kindRange b)
+ ForeignData a (Labeled _ _ b) -> (a, snd $ typeRange b)
ForeignKind a b -> (a, nameTok b)
valueBindingFieldsRange :: ValueBindingFields a -> TokenRange
@@ -243,13 +245,6 @@ whereRange (Where a bs)
| Just (_, ls) <- bs = (fst $ exprRange a, snd . letBindingRange $ NE.last ls)
| otherwise = exprRange a
-kindRange :: Kind a -> TokenRange
-kindRange = \case
- KindName _ a -> qualRange a
- KindArr _ a _ b -> (fst $ kindRange a, snd $ kindRange b)
- KindRow _ a b -> (a, snd $ kindRange b)
- KindParens _ a -> wrappedRange a
-
typeRange :: Type a -> TokenRange
typeRange = \case
TypeVar _ a -> nameRange a
@@ -257,10 +252,11 @@ typeRange = \case
TypeWildcard _ a -> (a, a)
TypeHole _ a -> nameRange a
TypeString _ a _ -> (a, a)
+ TypeInt _ a b _ -> (fromMaybe b a, b)
TypeRow _ a -> wrappedRange a
TypeRecord _ a -> wrappedRange a
TypeForall _ a _ _ b -> (a, snd $ typeRange b)
- TypeKinded _ a _ b -> (fst $ typeRange a, snd $ kindRange b)
+ TypeKinded _ a _ b -> (fst $ typeRange a, snd $ typeRange b)
TypeApp _ a b -> (fst $ typeRange a, snd $ typeRange b)
TypeOp _ a _ b -> (fst $ typeRange a, snd $ typeRange b)
TypeOpName _ a -> qualRange a
@@ -268,6 +264,7 @@ typeRange = \case
TypeArrName _ a -> (a, a)
TypeConstrained _ a _ b -> (fst $ constraintRange a, snd $ typeRange b)
TypeParens _ a -> wrappedRange a
+ TypeUnaryRow _ a b -> (a, snd $ typeRange b)
constraintRange :: Constraint a -> TokenRange
constraintRange = \case
@@ -279,7 +276,7 @@ constraintRange = \case
typeVarBindingRange :: TypeVarBinding a -> TokenRange
typeVarBindingRange = \case
TypeVarKinded a -> wrappedRange a
- TypeVarName a -> nameRange a
+ TypeVarName (atSign, a) -> (fromMaybe (nameTok a) atSign, nameTok a)
exprRange :: Expr a -> TokenRange
exprRange = \case
@@ -302,6 +299,7 @@ exprRange = \case
ExprRecordAccessor _ (RecordAccessor a _ b) -> (fst $ exprRange a, lblTok $ sepLast b)
ExprRecordUpdate _ a b -> (fst $ exprRange a, snd $ wrappedRange b)
ExprApp _ a b -> (fst $ exprRange a, snd $ exprRange b)
+ ExprVisibleTypeApp _ a _ b -> (fst $ exprRange a, snd $ typeRange b)
ExprLambda _ (Lambda a _ _ b) -> (a, snd $ exprRange b)
ExprIf _ (IfThenElse a _ _ _ _ b) -> (a, snd $ exprRange b)
ExprCase _ (CaseOf a _ _ c) -> (a, snd . guardedRange . snd $ NE.last c)
@@ -345,8 +343,3 @@ recordUpdateRange :: RecordUpdate a -> TokenRange
recordUpdateRange = \case
RecordUpdateLeaf a _ b -> (lblTok a, snd $ exprRange b)
RecordUpdateBranch a (Wrapped _ _ b) -> (lblTok a, b)
-
-recordLabeledExprRange :: RecordLabeled (Expr a) -> TokenRange
-recordLabeledExprRange = \case
- RecordPun a -> nameRange a
- RecordField a _ b -> (fst $ labelRange a, snd $ exprRange b)
diff --git a/src/Language/PureScript/CST/Print.hs b/src/Language/PureScript/CST/Print.hs
index 16aac588dc..f6d300ab67 100644
--- a/src/Language/PureScript/CST/Print.hs
+++ b/src/Language/PureScript/CST/Print.hs
@@ -5,18 +5,26 @@
module Language.PureScript.CST.Print
( printToken
, printTokens
+ , printModule
, printLeadingComment
, printTrailingComment
) where
import Prelude
+import Data.DList qualified as DList
import Data.Text (Text)
-import qualified Data.Text as Text
-import Language.PureScript.CST.Types
+import Data.Text qualified as Text
+import Language.PureScript.CST.Types (Comment(..), LineFeed(..), Module, SourceStyle(..), SourceToken(..), Token(..), TokenAnn(..))
+import Language.PureScript.CST.Flatten (flattenModule)
printToken :: Token -> Text
-printToken = \case
+printToken = printToken' True
+
+-- | Prints a given Token. The bool controls whether or not layout
+-- tokens should be printed.
+printToken' :: Bool -> Token -> Text
+printToken' showLayout = \case
TokLeftParen -> "("
TokRightParen -> ")"
TokLeftBrace -> "{"
@@ -52,22 +60,28 @@ printToken = \case
TokRawString raw -> "\"\"\"" <> raw <> "\"\"\""
TokInt raw _ -> raw
TokNumber raw _ -> raw
- TokLayoutStart -> "{"
- TokLayoutSep -> ";"
- TokLayoutEnd -> "}"
- TokEof -> ""
+ TokLayoutStart -> if showLayout then "{" else ""
+ TokLayoutSep -> if showLayout then ";" else ""
+ TokLayoutEnd -> if showLayout then "}" else ""
+ TokEof -> if showLayout then "" else ""
printQual :: [Text] -> Text
printQual = Text.concat . map (<> ".")
printTokens :: [SourceToken] -> Text
-printTokens toks = Text.concat (map pp toks)
+printTokens = printTokens' True
+
+printTokens' :: Bool -> [SourceToken] -> Text
+printTokens' showLayout toks = Text.concat (map pp toks)
where
pp (SourceToken (TokenAnn _ leading trailing) tok) =
Text.concat (map printLeadingComment leading)
- <> printToken tok
+ <> printToken' showLayout tok
<> Text.concat (map printTrailingComment trailing)
+printModule :: Module a -> Text
+printModule = printTokens' False . DList.toList . flattenModule
+
printLeadingComment :: Comment LineFeed -> Text
printLeadingComment = \case
Comment raw -> raw
diff --git a/src/Language/PureScript/CST/Traversals.hs b/src/Language/PureScript/CST/Traversals.hs
index 6d5627f8ac..23532915f1 100644
--- a/src/Language/PureScript/CST/Traversals.hs
+++ b/src/Language/PureScript/CST/Traversals.hs
@@ -2,7 +2,7 @@ module Language.PureScript.CST.Traversals where
import Prelude
-import Language.PureScript.CST.Types
+import Language.PureScript.CST.Types (Separated(..))
everythingOnSeparated :: (r -> r -> r) -> (a -> r) -> Separated a -> r
everythingOnSeparated op k (Separated hd tl) = go hd tl
diff --git a/src/Language/PureScript/CST/Traversals/Type.hs b/src/Language/PureScript/CST/Traversals/Type.hs
index 9e84718ee0..c61e65ca3e 100644
--- a/src/Language/PureScript/CST/Traversals/Type.hs
+++ b/src/Language/PureScript/CST/Traversals/Type.hs
@@ -2,8 +2,8 @@ module Language.PureScript.CST.Traversals.Type where
import Prelude
-import Language.PureScript.CST.Types
-import Language.PureScript.CST.Traversals
+import Language.PureScript.CST.Types (Constraint(..), Labeled(..), Row(..), Type(..), Wrapped(..))
+import Language.PureScript.CST.Traversals (everythingOnSeparated)
everythingOnTypes :: (r -> r -> r) -> (Type a -> r) -> Type a -> r
everythingOnTypes op k = goTy
@@ -14,10 +14,11 @@ everythingOnTypes op k = goTy
TypeWildcard _ _ -> k ty
TypeHole _ _ -> k ty
TypeString _ _ _ -> k ty
+ TypeInt _ _ _ _ -> k ty
TypeRow _ (Wrapped _ row _) -> goRow ty row
TypeRecord _ (Wrapped _ row _) -> goRow ty row
TypeForall _ _ _ _ ty2 -> k ty `op` goTy ty2
- TypeKinded _ ty2 _ _ -> k ty `op` goTy ty2
+ TypeKinded _ ty2 _ ty3 -> k ty `op` (goTy ty2 `op` goTy ty3)
TypeApp _ ty2 ty3 -> k ty `op` (goTy ty2 `op` goTy ty3)
TypeOp _ ty2 _ ty3 -> k ty `op` (goTy ty2 `op` goTy ty3)
TypeOpName _ _ -> k ty
@@ -27,6 +28,7 @@ everythingOnTypes op k = goTy
| null ty2 -> k ty `op` goTy ty3
| otherwise -> k ty `op` (foldr1 op (k <$> ty2) `op` goTy ty3)
TypeParens _ (Wrapped _ ty2 _) -> k ty `op` goTy ty2
+ TypeUnaryRow _ _ ty2 -> k ty `op` goTy ty2
goRow ty = \case
Row Nothing Nothing -> k ty
diff --git a/src/Language/PureScript/CST/Types.hs b/src/Language/PureScript/CST/Types.hs
index 7768b960b3..cf4345e5de 100644
--- a/src/Language/PureScript/CST/Types.hs
+++ b/src/Language/PureScript/CST/Types.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE DeriveAnyClass #-}
-- | This module contains data types for the entire PureScript surface language. Every
-- token is represented in the tree, and every token is annotated with
-- whitespace and comments (both leading and trailing). This means one can write
@@ -9,40 +10,42 @@ module Language.PureScript.CST.Types where
import Prelude
+import Control.DeepSeq (NFData)
import Data.List.NonEmpty (NonEmpty)
import Data.Text (Text)
import Data.Void (Void)
import GHC.Generics (Generic)
-import qualified Language.PureScript.Names as N
+import Language.PureScript.Names qualified as N
+import Language.PureScript.Roles qualified as R
import Language.PureScript.PSString (PSString)
data SourcePos = SourcePos
{ srcLine :: {-# UNPACK #-} !Int
, srcColumn :: {-# UNPACK #-} !Int
- } deriving (Show, Eq, Ord, Generic)
+ } deriving (Show, Eq, Ord, Generic, NFData)
data SourceRange = SourceRange
{ srcStart :: !SourcePos
, srcEnd :: !SourcePos
- } deriving (Show, Eq, Ord, Generic)
+ } deriving (Show, Eq, Ord, Generic, NFData)
data Comment l
= Comment !Text
| Space {-# UNPACK #-} !Int
| Line !l
- deriving (Show, Eq, Ord, Generic, Functor)
+ deriving (Show, Eq, Ord, Generic, Functor, NFData)
data LineFeed = LF | CRLF
- deriving (Show, Eq, Ord, Generic)
+ deriving (Show, Eq, Ord, Generic, NFData)
data TokenAnn = TokenAnn
{ tokRange :: !SourceRange
, tokLeadingComments :: ![Comment LineFeed]
, tokTrailingComments :: ![Comment Void]
- } deriving (Show, Eq, Ord, Generic)
+ } deriving (Show, Eq, Ord, Generic, NFData)
data SourceStyle = ASCII | Unicode
- deriving (Show, Eq, Ord, Generic)
+ deriving (Show, Eq, Ord, Generic, NFData)
data Token
= TokLeftParen
@@ -78,12 +81,12 @@ data Token
| TokLayoutSep
| TokLayoutEnd
| TokEof
- deriving (Show, Eq, Ord, Generic)
+ deriving (Show, Eq, Ord, Generic, NFData)
data SourceToken = SourceToken
{ tokAnn :: !TokenAnn
, tokValue :: !Token
- } deriving (Show, Eq, Ord, Generic)
+ } deriving (Show, Eq, Ord, Generic, NFData)
data Ident = Ident
{ getIdent :: Text
@@ -130,23 +133,17 @@ data OneOrDelimited a
| Many (DelimitedNonEmpty a)
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
-data Kind a
- = KindName a (QualifiedName (N.ProperName 'N.KindName))
- | KindArr a (Kind a) SourceToken (Kind a)
- | KindRow a SourceToken (Kind a)
- | KindParens a (Wrapped (Kind a))
- deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
-
data Type a
= TypeVar a (Name Ident)
| TypeConstructor a (QualifiedName (N.ProperName 'N.TypeName))
| TypeWildcard a SourceToken
| TypeHole a (Name Ident)
| TypeString a SourceToken PSString
+ | TypeInt a (Maybe SourceToken) SourceToken Integer
| TypeRow a (Wrapped (Row a))
| TypeRecord a (Wrapped (Row a))
| TypeForall a SourceToken (NonEmpty (TypeVarBinding a)) SourceToken (Type a)
- | TypeKinded a (Type a) SourceToken (Kind a)
+ | TypeKinded a (Type a) SourceToken (Type a)
| TypeApp a (Type a) (Type a)
| TypeOp a (Type a) (QualifiedName (N.OpName 'N.TypeOpName)) (Type a)
| TypeOpName a (QualifiedName (N.OpName 'N.TypeOpName))
@@ -154,11 +151,12 @@ data Type a
| TypeArrName a SourceToken
| TypeConstrained a (Constraint a) SourceToken (Type a)
| TypeParens a (Wrapped (Type a))
+ | TypeUnaryRow a SourceToken (Type a)
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
data TypeVarBinding a
- = TypeVarKinded (Wrapped (Labeled (Name Ident) (Kind a)))
- | TypeVarName (Name Ident)
+ = TypeVarKinded (Wrapped (Labeled (Maybe SourceToken, Name Ident) (Type a)))
+ | TypeVarName (Maybe SourceToken, Name Ident)
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
data Constraint a
@@ -188,7 +186,6 @@ data Export a
| ExportType a (Name (N.ProperName 'N.TypeName)) (Maybe (DataMembers a))
| ExportTypeOp a SourceToken (Name (N.OpName 'N.TypeOpName))
| ExportClass a SourceToken (Name (N.ProperName 'N.ClassName))
- | ExportKind a SourceToken (Name (N.ProperName 'N.KindName))
| ExportModule a SourceToken (Name N.ModuleName)
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
@@ -197,17 +194,28 @@ data DataMembers a
| DataEnumerated a (Delimited (Name (N.ProperName 'N.ConstructorName)))
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
+data DeriveClass = DeriveClass
+ { dcClass :: QualifiedName (N.ProperName 'N.ClassName)
+ } deriving (Show, Eq, Ord, Generic)
+
+data DeriveClause = DeriveClause
+ { dclKeyword :: SourceToken
+ , dclClasses :: Wrapped (Separated DeriveClass)
+ } deriving (Show, Eq, Ord, Generic)
+
data Declaration a
- = DeclData a (DataHead a) (Maybe (SourceToken, Separated (DataCtor a)))
+ = DeclData a (DataHead a) (Maybe (SourceToken, Separated (DataCtor a))) [DeriveClause]
| DeclType a (DataHead a) SourceToken (Type a)
- | DeclNewtype a (DataHead a) SourceToken (Name (N.ProperName 'N.ConstructorName)) (Type a)
+ | DeclNewtype a (DataHead a) SourceToken (Name (N.ProperName 'N.ConstructorName)) (Type a) [DeriveClause]
| DeclClass a (ClassHead a) (Maybe (SourceToken, NonEmpty (Labeled (Name Ident) (Type a))))
| DeclInstanceChain a (Separated (Instance a))
| DeclDerive a SourceToken (Maybe SourceToken) (InstanceHead a)
+ | DeclKindSignature a SourceToken (Labeled (Name (N.ProperName 'N.TypeName)) (Type a))
| DeclSignature a (Labeled (Name Ident) (Type a))
| DeclValue a (ValueBindingFields a)
| DeclFixity a FixityFields
| DeclForeign a SourceToken SourceToken (Foreign a)
+ | DeclRole a SourceToken SourceToken (Name (N.ProperName 'N.TypeName)) (NonEmpty Role)
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
data Instance a = Instance
@@ -234,7 +242,6 @@ data Import a
| ImportType a (Name (N.ProperName 'N.TypeName)) (Maybe (DataMembers a))
| ImportTypeOp a SourceToken (Name (N.OpName 'N.TypeOpName))
| ImportClass a SourceToken (Name (N.ProperName 'N.ClassName))
- | ImportKind a SourceToken (Name (N.ProperName 'N.KindName))
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
data DataHead a = DataHead
@@ -264,8 +271,7 @@ data ClassFundep
data InstanceHead a = InstanceHead
{ instKeyword :: SourceToken
- , instName :: Name Ident
- , instSep :: SourceToken
+ , instNameSep :: Maybe (Name Ident, SourceToken)
, instConstraints :: Maybe (OneOrDelimited (Constraint a), SourceToken)
, instClass :: QualifiedName (N.ProperName 'N.ClassName)
, instTypes :: [Type a]
@@ -313,10 +319,15 @@ data PatternGuard a = PatternGuard
data Foreign a
= ForeignValue (Labeled (Name Ident) (Type a))
- | ForeignData SourceToken (Labeled (Name (N.ProperName 'N.TypeName)) (Kind a))
- | ForeignKind SourceToken (Name (N.ProperName 'N.KindName))
+ | ForeignData SourceToken (Labeled (Name (N.ProperName 'N.TypeName)) (Type a))
+ | ForeignKind SourceToken (Name (N.ProperName 'N.TypeName))
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
+data Role = Role
+ { roleTok :: SourceToken
+ , roleValue :: R.Role
+ } deriving (Show, Eq, Ord, Generic)
+
data Expr a
= ExprHole a (Name Ident)
| ExprSection a SourceToken
@@ -337,6 +348,7 @@ data Expr a
| ExprRecordAccessor a (RecordAccessor a)
| ExprRecordUpdate a (Expr a) (DelimitedNonEmpty (RecordUpdate a))
| ExprApp a (Expr a) (Expr a)
+ | ExprVisibleTypeApp a (Expr a) SourceToken (Type a)
| ExprLambda a (Lambda a)
| ExprIf a (IfThenElse a)
| ExprCase a (CaseOf a)
diff --git a/src/Language/PureScript/CST/Utils.hs b/src/Language/PureScript/CST/Utils.hs
index 656de2315d..68dcf7d87c 100644
--- a/src/Language/PureScript/CST/Utils.hs
+++ b/src/Language/PureScript/CST/Utils.hs
@@ -1,25 +1,76 @@
-{-# LANGUAGE MonoLocalBinds #-}
module Language.PureScript.CST.Utils where
import Prelude
+import Protolude (headDef)
-import Control.Monad (when)
+import Control.Monad (unless)
import Data.Coerce (coerce)
import Data.Foldable (for_)
import Data.Functor (($>))
-import qualified Data.List.NonEmpty as NE
+import Data.List.NonEmpty qualified as NE
import Data.Set (Set)
-import qualified Data.Set as Set
+import Data.Set qualified as Set
import Data.Text (Text)
-import qualified Data.Text as Text
-import Language.PureScript.CST.Errors
-import Language.PureScript.CST.Monad
-import Language.PureScript.CST.Positions
-import Language.PureScript.CST.Traversals.Type
+import Data.Text qualified as Text
+import Language.PureScript.CST.Errors (ParserErrorType(..))
+import Language.PureScript.CST.Monad (Parser, addFailure, parseFail, pushBack)
+import Language.PureScript.CST.Positions (TokenRange, binderRange, importDeclRange, recordUpdateRange, typeRange)
+import Language.PureScript.CST.Traversals.Type (everythingOnTypes)
import Language.PureScript.CST.Types
-import qualified Language.PureScript.Names as N
+import Language.PureScript.Names qualified as N
import Language.PureScript.PSString (PSString, mkString)
+-- |
+-- A newtype for a qualified proper name whose ProperNameType has not yet been determined.
+-- This is a workaround for Happy's limited support for polymorphism; it is used
+-- inside the parser to allow us to write just one parser for qualified proper names
+-- which can be used for all of the different ProperNameTypes
+-- (via a call to getQualifiedProperName).
+newtype QualifiedProperName =
+ QualifiedProperName { getQualifiedProperName :: forall a. QualifiedName (N.ProperName a) }
+
+qualifiedProperName :: QualifiedName (N.ProperName a) -> QualifiedProperName
+qualifiedProperName n = QualifiedProperName (N.coerceProperName <$> n)
+
+-- |
+-- A newtype for a proper name whose ProperNameType has not yet been determined.
+-- This is a workaround for Happy's limited support for polymorphism; it is used
+-- inside the parser to allow us to write just one parser for proper names
+-- which can be used for all of the different ProperNameTypes
+-- (via a call to getProperName).
+newtype ProperName =
+ ProperName { _getProperName :: forall a. Name (N.ProperName a) }
+
+properName :: Name (N.ProperName a) -> ProperName
+properName n = ProperName (N.coerceProperName <$> n)
+
+getProperName :: forall a. ProperName -> Name (N.ProperName a)
+getProperName pn = _getProperName pn -- eta expansion needed here due to simplified subsumption
+
+-- |
+-- A newtype for a qualified operator name whose OpNameType has not yet been determined.
+-- This is a workaround for Happy's limited support for polymorphism; it is used
+-- inside the parser to allow us to write just one parser for qualified operator names
+-- which can be used for all of the different OpNameTypes
+-- (via a call to getQualifiedOpName).
+newtype QualifiedOpName =
+ QualifiedOpName { getQualifiedOpName :: forall a. QualifiedName (N.OpName a) }
+
+qualifiedOpName :: QualifiedName (N.OpName a) -> QualifiedOpName
+qualifiedOpName n = QualifiedOpName (N.coerceOpName <$> n)
+
+-- |
+-- A newtype for a operator name whose OpNameType has not yet been determined.
+-- This is a workaround for Happy's limited support for polymorphism; it is used
+-- inside the parser to allow us to write just one parser for operator names
+-- which can be used for all of the different OpNameTypes
+-- (via a call to getOpName).
+newtype OpName =
+ OpName { getOpName :: forall a. Name (N.OpName a) }
+
+opName :: Name (N.OpName a) -> OpName
+opName n = OpName (N.coerceOpName <$> n)
+
placeholder :: SourceToken
placeholder = SourceToken
{ tokAnn = TokenAnn (SourceRange (SourcePos 0 0) (SourcePos 0 0)) [] []
@@ -36,25 +87,20 @@ unexpectedLabel :: SourceToken -> Label
unexpectedLabel tok = Label tok ""
unexpectedExpr :: Monoid a => [SourceToken] -> Expr a
-unexpectedExpr toks = ExprIdent mempty (unexpectedQual (head toks))
-
-unexpectedDecl :: Monoid a => [SourceToken] -> Declaration a
-unexpectedDecl toks = DeclValue mempty (ValueBindingFields (unexpectedName (head toks)) [] (error " [SourceToken] -> Binder a
-unexpectedBinder toks = BinderVar mempty (unexpectedName (head toks))
-
-unexpectedLetBinding :: Monoid a => [SourceToken] -> LetBinding a
-unexpectedLetBinding toks = LetBindingName mempty (ValueBindingFields (unexpectedName (head toks)) [] (error ""))
-
-unexpectedInstBinding :: Monoid a => [SourceToken] -> InstanceBinding a
-unexpectedInstBinding toks = InstanceBindingName mempty (ValueBindingFields (unexpectedName (head toks)) [] (error ""))
+unexpectedBinder toks =
+ BinderVar mempty (unexpectedName (headDef placeholder toks))
unexpectedRecordUpdate :: Monoid a => [SourceToken] -> RecordUpdate a
-unexpectedRecordUpdate toks = RecordUpdateLeaf (unexpectedLabel (head toks)) (head toks) (unexpectedExpr toks)
+unexpectedRecordUpdate toks =
+ RecordUpdateLeaf (unexpectedLabel (headDef placeholder toks)) (headDef placeholder toks) (unexpectedExpr toks)
unexpectedRecordLabeled :: [SourceToken] -> RecordLabeled a
-unexpectedRecordLabeled toks = RecordPun (unexpectedName (head toks))
+unexpectedRecordLabeled toks =
+ RecordPun (unexpectedName (headDef placeholder toks))
rangeToks :: TokenRange -> [SourceToken]
rangeToks (a, b) = [a, b]
@@ -68,28 +114,25 @@ unexpectedToks toRange toCst err old = do
separated :: [(SourceToken, a)] -> Separated a
separated = go []
where
- go accum ((_, a) : []) = Separated a accum
+ go accum [(_, a)] = Separated a accum
go accum (x : xs) = go (x : accum) xs
go _ [] = internalError "Separated should not be empty"
-consSeparated :: a -> SourceToken -> Separated a -> Separated a
-consSeparated x sep (Separated {..}) = Separated x ((sep, sepHead) : sepTail)
-
internalError :: String -> a
internalError = error . ("Internal parser error: " <>)
toModuleName :: SourceToken -> [Text] -> Parser (Maybe N.ModuleName)
toModuleName _ [] = pure Nothing
toModuleName tok ns = do
- when (not (all isValidModuleNamespace ns)) $ addFailure [tok] ErrModuleName
- pure . Just . N.ModuleName $ N.ProperName <$> ns
+ unless (all isValidModuleNamespace ns) $ addFailure [tok] ErrModuleName
+ pure . Just . N.ModuleName $ Text.intercalate "." ns
upperToModuleName :: SourceToken -> Parser (Name N.ModuleName)
upperToModuleName tok = case tokValue tok of
TokUpperName q a -> do
let ns = q <> [a]
- when (not (all isValidModuleNamespace ns)) $ addFailure [tok] ErrModuleName
- pure . Name tok . N.ModuleName $ N.ProperName <$> ns
+ unless (all isValidModuleNamespace ns) $ addFailure [tok] ErrModuleName
+ pure . Name tok . N.ModuleName $ Text.intercalate "." ns
_ -> internalError $ "Invalid upper name: " <> show tok
toQualifiedName :: (Text -> a) -> SourceToken -> Parser (QualifiedName a)
@@ -107,6 +150,8 @@ toName k tok = case tokValue tok of
TokLowerName [] a
| not (Set.member a reservedNames) -> pure $ Name tok (k a)
| otherwise -> addFailure [tok] ErrKeywordVar $> Name tok (k "")
+ TokString _ _ -> parseFail tok ErrQuotedPun
+ TokRawString _ -> parseFail tok ErrQuotedPun
TokUpperName [] a -> pure $ Name tok (k a)
TokSymbolName [] a -> pure $ Name tok (k a)
TokOperator [] a -> pure $ Name tok (k a)
@@ -121,9 +166,6 @@ toLabel tok = case tokValue tok of
TokForall ASCII -> Label tok $ mkString "forall"
_ -> internalError $ "Invalid label: " <> show tok
-labelToIdent :: Label -> Parser (Name Ident)
-labelToIdent (Label tok _) = toName Ident tok
-
toString :: SourceToken -> (SourceToken, PSString)
toString tok = case tokValue tok of
TokString _ a -> (tok, a)
@@ -173,12 +215,17 @@ toConstraint = convertParens
addFailure [tok1, tok2] ErrTypeInConstraint
pure $ Constraint mempty (QualifiedName tok1 Nothing (N.ProperName " Bool
+isConstrained = everythingOnTypes (||) $ \case
+ TypeConstrained{} -> True
+ _ -> False
+
toBinderConstructor :: Monoid a => NE.NonEmpty (Binder a) -> Parser (Binder a)
toBinderConstructor = \case
BinderConstructor a name [] NE.:| bs ->
pure $ BinderConstructor a name bs
a NE.:| [] -> pure a
- a NE.:| _ -> unexpectedToks binderRange (unexpectedBinder) ErrExprInBinder a
+ a NE.:| _ -> unexpectedToks binderRange unexpectedBinder ErrExprInBinder a
toRecordFields
:: Monoid a
@@ -206,8 +253,8 @@ checkFundeps :: ClassHead a -> Parser ()
checkFundeps (ClassHead _ _ _ _ Nothing) = pure ()
checkFundeps (ClassHead _ _ _ vars (Just (_, fundeps))) = do
let
- k (TypeVarKinded (Wrapped _ (Labeled a _ _) _)) = getIdent $ nameValue a
- k (TypeVarName a) = getIdent $ nameValue a
+ k (TypeVarKinded (Wrapped _ (Labeled (_, a) _ _) _)) = getIdent $ nameValue a
+ k (TypeVarName (_, a)) = getIdent $ nameValue a
names = k <$> vars
check a
| getIdent (nameValue a) `elem` names = pure ()
diff --git a/src/Language/PureScript/CodeGen/JS.hs b/src/Language/PureScript/CodeGen/JS.hs
index 4153fbbf44..890cc1cd27 100644
--- a/src/Language/PureScript/CodeGen/JS.hs
+++ b/src/Language/PureScript/CodeGen/JS.hs
@@ -6,39 +6,44 @@ module Language.PureScript.CodeGen.JS
, moduleToJs
) where
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
+import Protolude (ordNub, headDef)
-import Control.Arrow ((&&&))
import Control.Monad (forM, replicateM, void)
import Control.Monad.Except (MonadError, throwError)
import Control.Monad.Reader (MonadReader, asks)
-import Control.Monad.Supply.Class
+import Control.Monad.Supply.Class (MonadSupply, freshName)
+import Control.Monad.Writer (MonadWriter, runWriterT, writer)
+import Data.Bifunctor (first)
import Data.List ((\\), intersect)
-import qualified Data.Foldable as F
-import qualified Data.Map as M
-import qualified Data.Set as S
-import Data.Maybe (fromMaybe, isNothing)
+import Data.List.NonEmpty qualified as NEL (nonEmpty)
+import Data.Foldable qualified as F
+import Data.Map qualified as M
+import Data.Set qualified as S
+import Data.Maybe (fromMaybe, mapMaybe, maybeToList)
+import Data.Monoid (Any(..))
import Data.String (fromString)
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
-import Language.PureScript.AST.SourcePos
+import Language.PureScript.AST.SourcePos (SourceSpan, displayStartEndPos)
import Language.PureScript.CodeGen.JS.Common as Common
-import Language.PureScript.CoreImp.AST (AST, everywhereTopDownM, withSourceSpan)
-import qualified Language.PureScript.CoreImp.AST as AST
-import Language.PureScript.CoreImp.Optimizer
-import Language.PureScript.CoreFn
-import Language.PureScript.Crash
+import Language.PureScript.CoreImp.AST (AST, InitializerEffects(..), everywhere, everywhereTopDownM, withSourceSpan)
+import Language.PureScript.CoreImp.AST qualified as AST
+import Language.PureScript.CoreImp.Module qualified as AST
+import Language.PureScript.CoreImp.Optimizer (optimize)
+import Language.PureScript.CoreFn (Ann, Bind(..), Binder(..), CaseAlternative(..), ConstructorType(..), Expr(..), Guard, Literal(..), Meta(..), Module(..), extractAnn, extractBinderAnn, modifyAnn, removeComments)
+import Language.PureScript.CoreFn.Laziness (applyLazinessTransform)
+import Language.PureScript.Crash (internalError)
import Language.PureScript.Errors (ErrorMessageHint(..), SimpleErrorMessage(..),
MultipleErrors(..), rethrow, errorMessage,
errorMessage', rethrowWithPosition, addHint)
-import Language.PureScript.Names
-import Language.PureScript.Options
+import Language.PureScript.Names (Ident(..), ModuleName, ProperName(..), Qualified(..), QualifiedBy(..), runIdent, runModuleName, showIdent, showQualified)
+import Language.PureScript.Options (CodegenTarget(..), Options(..))
import Language.PureScript.PSString (PSString, mkString)
import Language.PureScript.Traversals (sndM)
-import qualified Language.PureScript.Constants as C
+import Language.PureScript.Constants.Prim qualified as C
import System.FilePath.Posix ((>))
@@ -46,119 +51,220 @@ import System.FilePath.Posix ((>))
-- module.
moduleToJs
:: forall m
- . (Monad m, MonadReader Options m, MonadSupply m, MonadError MultipleErrors m)
+ . (MonadReader Options m, MonadSupply m, MonadError MultipleErrors m)
=> Module Ann
- -> Maybe AST
- -> m [AST]
-moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
+ -> Maybe PSString
+ -> m AST.Module
+moduleToJs (Module _ coms mn _ imps exps reExps foreigns decls) foreignInclude =
rethrow (addHint (ErrorInModule mn)) $ do
let usedNames = concatMap getNames decls
- let mnLookup = renameImports usedNames imps
- let decls' = renameModules mnLookup decls
- jsDecls <- mapM bindToJs decls'
- optimized <- traverse (traverse optimize) jsDecls
- let mnReverseLookup = M.fromList $ map (\(origName, (_, safeName)) -> (moduleNameToJs safeName, origName)) $ M.toList mnLookup
- let usedModuleNames = foldMap (foldMap (findModules mnReverseLookup)) optimized
- jsImports <- traverse (importToJs mnLookup)
- . filter (flip S.member usedModuleNames)
- . (\\ (mn : C.primModules)) $ ordNub $ map snd imps
+ let imps' = ordNub $ map snd imps
+ let mnLookup = renameImports usedNames imps'
+ (jsDecls, Any needRuntimeLazy) <- runWriterT $ mapM (moduleBindToJs mn) decls
+ optimized <- fmap (fmap (fmap annotatePure)) . optimize (map identToJs exps) $ if needRuntimeLazy then [runtimeLazy] : jsDecls else jsDecls
F.traverse_ (F.traverse_ checkIntegers) optimized
comments <- not <$> asks optionsNoComments
- let strict = AST.StringLiteral Nothing "use strict"
- let header = if comments && not (null coms) then AST.Comment Nothing coms strict else strict
- let foreign' = [AST.VariableIntroduction Nothing "$foreign" foreign_ | not $ null foreigns || isNothing foreign_]
- let moduleBody = header : foreign' ++ jsImports ++ concat optimized
+ let header = if comments then coms else []
+ let foreign' = maybe [] (pure . AST.Import FFINamespace) $ if null foreigns then Nothing else foreignInclude
+ let moduleBody = concat optimized
+ let (S.union (M.keysSet reExps) -> usedModuleNames, renamedModuleBody) = traverse (replaceModuleAccessors mnLookup) moduleBody
+ let jsImports
+ = map (importToJs mnLookup)
+ . filter (flip S.member usedModuleNames)
+ $ (\\ (mn : C.primModules)) imps'
let foreignExps = exps `intersect` foreigns
let standardExps = exps \\ foreignExps
- let exps' = AST.ObjectLiteral Nothing $ map (mkString . runIdent &&& AST.Var Nothing . identToJs) standardExps
- ++ map (mkString . runIdent &&& foreignIdent) foreignExps
- return $ moduleBody ++ [AST.Assignment Nothing (accessorString "exports" (AST.Var Nothing "module")) exps']
+ let reExps' = M.toList (M.withoutKeys reExps (S.fromList C.primModules))
+ let jsExports
+ = (maybeToList . exportsToJs foreignInclude $ foreignExps)
+ ++ (maybeToList . exportsToJs Nothing $ standardExps)
+ ++ mapMaybe reExportsToJs reExps'
+ return $ AST.Module header (foreign' ++ jsImports) renamedModuleBody jsExports
where
-
- -- | Extracts all declaration names from a binding group.
+ -- Adds purity annotations to top-level values for bundlers.
+ -- The semantics here derive from treating top-level module evaluation as pure, which lets
+ -- us remove any unreferenced top-level declarations. To achieve this, we wrap any non-trivial
+ -- top-level values in an IIFE marked with a pure annotation.
+ annotatePure :: AST -> AST
+ annotatePure = annotateOrWrap
+ where
+ annotateOrWrap = liftA2 fromMaybe pureIife maybePure
+
+ -- If the JS is potentially effectful (in the eyes of a bundler that
+ -- doesn't know about PureScript), return Nothing. Otherwise, return Just
+ -- the JS with any needed pure annotations added, and, in the case of a
+ -- variable declaration, an IIFE to be annotated.
+ maybePure :: AST -> Maybe AST
+ maybePure = maybePureGen False
+
+ -- Like maybePure, but doesn't add a pure annotation to App. This exists
+ -- to prevent from doubling up on annotation comments on curried
+ -- applications; from experimentation, it turns out that a comment on the
+ -- outermost App is sufficient for the entire curried chain to be
+ -- considered effect-free.
+ maybePure' :: AST -> Maybe AST
+ maybePure' = maybePureGen True
+
+ maybePureGen alreadyAnnotated = \case
+ AST.VariableIntroduction ss name j -> Just (AST.VariableIntroduction ss name (fmap annotateOrWrap <$> j))
+ AST.App ss f args -> (if alreadyAnnotated then AST.App else pureApp) ss <$> maybePure' f <*> traverse maybePure args
+ AST.ArrayLiteral ss jss -> AST.ArrayLiteral ss <$> traverse maybePure jss
+ AST.ObjectLiteral ss props -> AST.ObjectLiteral ss <$> traverse (traverse maybePure) props
+ AST.Comment c js -> AST.Comment c <$> maybePure js
+
+ js@(AST.Indexer _ _ (AST.Var _ FFINamespace)) -> Just js
+
+ js@AST.NumericLiteral{} -> Just js
+ js@AST.StringLiteral{} -> Just js
+ js@AST.BooleanLiteral{} -> Just js
+ js@AST.Function{} -> Just js
+ js@AST.Var{} -> Just js
+ js@AST.ModuleAccessor{} -> Just js
+
+ _ -> Nothing
+
+ pureIife :: AST -> AST
+ pureIife val = pureApp Nothing (AST.Function Nothing Nothing [] (AST.Block Nothing [AST.Return Nothing val])) []
+
+ pureApp :: Maybe SourceSpan -> AST -> [AST] -> AST
+ pureApp ss f = AST.Comment AST.PureAnnotation . AST.App ss f
+
+ -- Extracts all declaration names from a binding group.
getNames :: Bind Ann -> [Ident]
getNames (NonRec _ ident _) = [ident]
getNames (Rec vals) = map (snd . fst) vals
- -- | Creates alternative names for each module to ensure they don't collide
+ -- Creates alternative names for each module to ensure they don't collide
-- with declaration names.
- renameImports :: [Ident] -> [(Ann, ModuleName)] -> M.Map ModuleName (Ann, ModuleName)
+ renameImports :: [Ident] -> [ModuleName] -> M.Map ModuleName Text
renameImports = go M.empty
where
- go :: M.Map ModuleName (Ann, ModuleName) -> [Ident] -> [(Ann, ModuleName)] -> M.Map ModuleName (Ann, ModuleName)
- go acc used ((ann, mn') : mns') =
- let mni = Ident $ runModuleName mn'
- in if mn' /= mn && mni `elem` used
- then let newName = freshModuleName 1 mn' used
- in go (M.insert mn' (ann, newName) acc) (Ident (runModuleName newName) : used) mns'
- else go (M.insert mn' (ann, mn') acc) used mns'
+ go :: M.Map ModuleName Text -> [Ident] -> [ModuleName] -> M.Map ModuleName Text
+ go acc used (mn' : mns') =
+ let mnj = moduleNameToJs mn'
+ in if mn' /= mn && Ident mnj `elem` used
+ then let newName = freshModuleName 1 mnj used
+ in go (M.insert mn' newName acc) (Ident newName : used) mns'
+ else go (M.insert mn' mnj acc) used mns'
go acc _ [] = acc
- freshModuleName :: Integer -> ModuleName -> [Ident] -> ModuleName
- freshModuleName i mn'@(ModuleName pns) used =
- let newName = ModuleName $ init pns ++ [ProperName $ runProperName (last pns) <> "_" <> T.pack (show i)]
- in if Ident (runModuleName newName) `elem` used
+ freshModuleName :: Integer -> Text -> [Ident] -> Text
+ freshModuleName i mn' used =
+ let newName = mn' <> "_" <> T.pack (show i)
+ in if Ident newName `elem` used
then freshModuleName (i + 1) mn' used
else newName
- -- | Generates JavaScript code for a module import, binding the required module
+ -- Generates JavaScript code for a module import, binding the required module
-- to the alternative
- importToJs :: M.Map ModuleName (Ann, ModuleName) -> ModuleName -> m AST
- importToJs mnLookup mn' = do
- let ((ss, _, _, _), mnSafe) = fromMaybe (internalError "Missing value in mnLookup") $ M.lookup mn' mnLookup
- let moduleBody = AST.App Nothing (AST.Var Nothing "require")
- [AST.StringLiteral Nothing (fromString (".." > T.unpack (runModuleName mn') > "index.js"))]
- withPos ss $ AST.VariableIntroduction Nothing (moduleNameToJs mnSafe) (Just moduleBody)
-
- -- | Replaces the `ModuleName`s in the AST so that the generated code refers to
- -- the collision-avoiding renamed module imports.
- renameModules :: M.Map ModuleName (Ann, ModuleName) -> [Bind Ann] -> [Bind Ann]
- renameModules mnLookup binds =
- let (f, _, _) = everywhereOnValues id goExpr goBinder
- in map f binds
- where
- goExpr :: Expr a -> Expr a
- goExpr (Var ann q) = Var ann (renameQual q)
- goExpr e = e
- goBinder :: Binder a -> Binder a
- goBinder (ConstructorBinder ann q1 q2 bs) = ConstructorBinder ann (renameQual q1) (renameQual q2) bs
- goBinder b = b
- renameQual :: Qualified a -> Qualified a
- renameQual (Qualified (Just mn') a) =
- let (_,mnSafe) = fromMaybe (internalError "Missing value in mnLookup") $ M.lookup mn' mnLookup
- in Qualified (Just mnSafe) a
- renameQual q = q
-
- -- |
- -- Find the set of ModuleNames referenced by an AST.
- --
- findModules :: M.Map Text ModuleName -> AST -> S.Set ModuleName
- findModules mnReverseLookup = AST.everything mappend go
+ importToJs :: M.Map ModuleName Text -> ModuleName -> AST.Import
+ importToJs mnLookup mn' =
+ let mnSafe = fromMaybe (internalError "Missing value in mnLookup") $ M.lookup mn' mnLookup
+ in AST.Import mnSafe (moduleImportPath mn')
+
+ -- Generates JavaScript code for exporting at least one identifier,
+ -- eventually from another module.
+ exportsToJs :: Maybe PSString -> [Ident] -> Maybe AST.Export
+ exportsToJs from = fmap (flip AST.Export from) . NEL.nonEmpty . fmap runIdent
+
+ -- Generates JavaScript code for re-exporting at least one identifier from
+ -- from another module.
+ reExportsToJs :: (ModuleName, [Ident]) -> Maybe AST.Export
+ reExportsToJs = uncurry exportsToJs . first (Just . moduleImportPath)
+
+ moduleImportPath :: ModuleName -> PSString
+ moduleImportPath mn' = fromString (".." > T.unpack (runModuleName mn') > "index.js")
+
+ -- Replaces the `ModuleAccessor`s in the AST with `Indexer`s, ensuring that
+ -- the generated code refers to the collision-avoiding renamed module
+ -- imports. Also returns set of used module names.
+ replaceModuleAccessors :: M.Map ModuleName Text -> AST -> (S.Set ModuleName, AST)
+ replaceModuleAccessors mnLookup = everywhereTopDownM $ \case
+ AST.ModuleAccessor _ mn' name ->
+ let mnSafe = fromMaybe (internalError "Missing value in mnLookup") $ M.lookup mn' mnLookup
+ in (S.singleton mn', accessorString name $ AST.Var Nothing mnSafe)
+ other -> pure other
+
+ -- Check that all integers fall within the valid int range for JavaScript.
+ checkIntegers :: AST -> m ()
+ checkIntegers = void . everywhereTopDownM go
where
- go (AST.Var _ name) = foldMap S.singleton $ M.lookup name mnReverseLookup
- go _ = mempty
+ go :: AST -> m AST
+ go (AST.Unary _ AST.Negate (AST.NumericLiteral ss (Left i))) =
+ -- Move the negation inside the literal; since this is a top-down
+ -- traversal doing this replacement will stop the next case from raising
+ -- the error when attempting to use -2147483648, as if left unrewritten
+ -- the value is `Unary Negate (NumericLiteral (Left 2147483648))`, and
+ -- 2147483648 is larger than the maximum allowed int.
+ return $ AST.NumericLiteral ss (Left (-i))
+ go js@(AST.NumericLiteral ss (Left i)) =
+ let minInt = -2147483648
+ maxInt = 2147483647
+ in if i < minInt || i > maxInt
+ then throwError . maybe errorMessage errorMessage' ss $ IntOutOfRange i "JavaScript" minInt maxInt
+ else return js
+ go other = return other
- -- |
+ runtimeLazy :: AST
+ runtimeLazy =
+ AST.VariableIntroduction Nothing "$runtime_lazy" . Just . (UnknownEffects, ) . AST.Function Nothing Nothing ["name", "moduleName", "init"] . AST.Block Nothing $
+ [ AST.VariableIntroduction Nothing "state" . Just . (UnknownEffects, ) . AST.NumericLiteral Nothing $ Left 0
+ , AST.VariableIntroduction Nothing "val" Nothing
+ , AST.Return Nothing . AST.Function Nothing Nothing ["lineNumber"] . AST.Block Nothing $
+ [ AST.IfElse Nothing (AST.Binary Nothing AST.EqualTo (AST.Var Nothing "state") (AST.NumericLiteral Nothing (Left 2))) (AST.Return Nothing $ AST.Var Nothing "val") Nothing
+ , AST.IfElse Nothing (AST.Binary Nothing AST.EqualTo (AST.Var Nothing "state") (AST.NumericLiteral Nothing (Left 1))) (AST.Throw Nothing $ AST.Unary Nothing AST.New (AST.App Nothing (AST.Var Nothing "ReferenceError") [foldl1 (AST.Binary Nothing AST.Add)
+ [ AST.Var Nothing "name"
+ , AST.StringLiteral Nothing " was needed before it finished initializing (module "
+ , AST.Var Nothing "moduleName"
+ , AST.StringLiteral Nothing ", line "
+ , AST.Var Nothing "lineNumber"
+ , AST.StringLiteral Nothing ")"
+ ], AST.Var Nothing "moduleName", AST.Var Nothing "lineNumber"])) Nothing
+ , AST.Assignment Nothing (AST.Var Nothing "state") . AST.NumericLiteral Nothing $ Left 1
+ , AST.Assignment Nothing (AST.Var Nothing "val") $ AST.App Nothing (AST.Var Nothing "init") []
+ , AST.Assignment Nothing (AST.Var Nothing "state") . AST.NumericLiteral Nothing $ Left 2
+ , AST.Return Nothing $ AST.Var Nothing "val"
+ ]
+ ]
+
+
+moduleBindToJs
+ :: forall m
+ . (MonadReader Options m, MonadSupply m, MonadWriter Any m, MonadError MultipleErrors m)
+ => ModuleName
+ -> Bind Ann
+ -> m [AST]
+moduleBindToJs mn = bindToJs
+ where
-- Generate code in the simplified JavaScript intermediate representation for a declaration
- --
bindToJs :: Bind Ann -> m [AST]
+ bindToJs (NonRec (_, _, Just IsTypeClassConstructor) _ _) = pure []
+ -- Unlike other newtype constructors, type class constructors are only
+ -- ever applied; it's not possible to use them as values. So it's safe to
+ -- erase them.
bindToJs (NonRec ann ident val) = return <$> nonRecToJS ann ident val
- bindToJs (Rec vals) = forM vals (uncurry . uncurry $ nonRecToJS)
+ bindToJs (Rec vals) = writer (applyLazinessTransform mn vals) >>= traverse (uncurry . uncurry $ nonRecToJS)
- -- | Generate code in the simplified JavaScript intermediate representation for a single non-recursive
+ -- Generate code in the simplified JavaScript intermediate representation for a single non-recursive
-- declaration.
--
-- The main purpose of this function is to handle code generation for comments.
nonRecToJS :: Ann -> Ident -> Expr Ann -> m AST
- nonRecToJS a i e@(extractAnn -> (_, com, _, _)) | not (null com) = do
+ nonRecToJS a i e@(extractAnn -> (_, com, _)) | not (null com) = do
withoutComment <- asks optionsNoComments
if withoutComment
then nonRecToJS a i (modifyAnn removeComments e)
- else AST.Comment Nothing com <$> nonRecToJS a i (modifyAnn removeComments e)
- nonRecToJS (ss, _, _, _) ident val = do
+ else AST.Comment (AST.SourceComments com) <$> nonRecToJS a i (modifyAnn removeComments e)
+ nonRecToJS (ss, _, _) ident val = do
js <- valueToJs val
- withPos ss $ AST.VariableIntroduction Nothing (identToJs ident) (Just js)
+ withPos ss $ AST.VariableIntroduction Nothing (identToJs ident) (Just (guessEffects val, js))
+
+ guessEffects :: Expr Ann -> AST.InitializerEffects
+ guessEffects = \case
+ Var _ (Qualified (BySourcePos _) _) -> NoEffects
+ App (_, _, Just IsSyntheticApp) _ _ -> NoEffects
+ _ -> UnknownEffects
withPos :: SourceSpan -> AST -> m AST
withPos ss js = do
@@ -167,51 +273,33 @@ moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
then withSourceSpan ss js
else js
- -- | Generate code in the simplified JavaScript intermediate representation for a variable based on a
+ -- Generate code in the simplified JavaScript intermediate representation for a variable based on a
-- PureScript identifier.
var :: Ident -> AST
var = AST.Var Nothing . identToJs
- -- | Generate code in the simplified JavaScript intermediate representation for an accessor based on
- -- a PureScript identifier. If the name is not valid in JavaScript (symbol based, reserved name) an
- -- indexer is returned.
- accessor :: Ident -> AST -> AST
- accessor (Ident prop) = accessorString $ mkString prop
- accessor (GenIdent _ _) = internalError "GenIdent in accessor"
- accessor UnusedIdent = internalError "UnusedIdent in accessor"
-
- accessorString :: PSString -> AST -> AST
- accessorString prop = AST.Indexer Nothing (AST.StringLiteral Nothing prop)
-
- -- | Generate code in the simplified JavaScript intermediate representation for a value or expression.
+ -- Generate code in the simplified JavaScript intermediate representation for a value or expression.
valueToJs :: Expr Ann -> m AST
valueToJs e =
- let (ss, _, _, _) = extractAnn e in
+ let (ss, _, _) = extractAnn e in
withPos ss =<< valueToJs' e
valueToJs' :: Expr Ann -> m AST
- valueToJs' (Literal (pos, _, _, _) l) =
+ valueToJs' (Literal (pos, _, _) l) =
rethrowWithPosition pos $ literalToValueJS pos l
- valueToJs' (Var (_, _, _, Just (IsConstructor _ [])) name) =
+ valueToJs' (Var (_, _, Just (IsConstructor _ [])) name) =
return $ accessorString "value" $ qualifiedToJS id name
- valueToJs' (Var (_, _, _, Just (IsConstructor _ _)) name) =
+ valueToJs' (Var (_, _, Just (IsConstructor _ _)) name) =
return $ accessorString "create" $ qualifiedToJS id name
valueToJs' (Accessor _ prop val) =
accessorString prop <$> valueToJs val
- valueToJs' (ObjectUpdate _ o ps) = do
+ valueToJs' (ObjectUpdate (pos, _, _) o copy ps) = do
obj <- valueToJs o
sts <- mapM (sndM valueToJs) ps
- extendObj obj sts
- valueToJs' e@(Abs (_, _, _, Just IsTypeClassConstructor) _ _) =
- let args = unAbs e
- in return $ AST.Function Nothing Nothing (map identToJs args) (AST.Block Nothing $ map assign args)
- where
- unAbs :: Expr Ann -> [Ident]
- unAbs (Abs _ arg val) = arg : unAbs val
- unAbs _ = []
- assign :: Ident -> AST
- assign name = AST.Assignment Nothing (accessorString (mkString $ runIdent name) (AST.Var Nothing "this"))
- (var name)
+ case copy of
+ Nothing -> extendObj obj sts
+ Just names -> pure $ AST.ObjectLiteral (Just pos) (map f names ++ sts)
+ where f name = (name, accessorString name obj)
valueToJs' (Abs _ arg val) = do
ret <- valueToJs val
let jsArg = case arg of
@@ -222,32 +310,31 @@ moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
let (f, args) = unApp e []
args' <- mapM valueToJs args
case f of
- Var (_, _, _, Just IsNewtype) _ -> return (head args')
- Var (_, _, _, Just (IsConstructor _ fields)) name | length args == length fields ->
- return $ AST.Unary Nothing AST.New $ AST.App Nothing (qualifiedToJS id name) args'
- Var (_, _, _, Just IsTypeClassConstructor) name ->
+ Var (_, _, Just IsNewtype) _ ->
+ return (headDef (internalError "Newtype constructor without constructor name") args')
+ Var (_, _, Just (IsConstructor _ fields)) name | length args == length fields ->
return $ AST.Unary Nothing AST.New $ AST.App Nothing (qualifiedToJS id name) args'
_ -> flip (foldl (\fn a -> AST.App Nothing fn [a])) args' <$> valueToJs f
where
unApp :: Expr Ann -> [Expr Ann] -> (Expr Ann, [Expr Ann])
unApp (App _ val arg) args = unApp val (arg : args)
unApp other args = (other, args)
- valueToJs' (Var (_, _, _, Just IsForeign) qi@(Qualified (Just mn') ident)) =
+ valueToJs' (Var (_, _, Just IsForeign) qi@(Qualified (ByModuleName mn') ident)) =
return $ if mn' == mn
then foreignIdent ident
else varToJs qi
- valueToJs' (Var (_, _, _, Just IsForeign) ident) =
+ valueToJs' (Var (_, _, Just IsForeign) ident) =
internalError $ "Encountered an unqualified reference to a foreign ident " ++ T.unpack (showQualified showIdent ident)
valueToJs' (Var _ ident) = return $ varToJs ident
- valueToJs' (Case (ss, _, _, _) values binders) = do
+ valueToJs' (Case (ss, _, _) values binders) = do
vals <- mapM valueToJs values
bindersToJs ss binders vals
valueToJs' (Let _ ds val) = do
ds' <- concat <$> mapM bindToJs ds
ret <- valueToJs val
return $ AST.App Nothing (AST.Function Nothing Nothing [] (AST.Block Nothing (ds' ++ [AST.Return Nothing ret]))) []
- valueToJs' (Constructor (_, _, _, Just IsNewtype) _ ctor _) =
- return $ AST.VariableIntroduction Nothing (properToJs ctor) (Just $
+ valueToJs' (Constructor (_, _, Just IsNewtype) _ ctor _) =
+ return $ AST.VariableIntroduction Nothing (properToJs ctor) (Just . (UnknownEffects, ) $
AST.ObjectLiteral Nothing [("create",
AST.Function Nothing Nothing ["value"]
(AST.Block Nothing [AST.Return Nothing $ AST.Var Nothing "value"]))])
@@ -278,7 +365,7 @@ moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
literalToValueJS ss (ArrayLiteral xs) = AST.ArrayLiteral (Just ss) <$> mapM valueToJs xs
literalToValueJS ss (ObjectLiteral ps) = AST.ObjectLiteral (Just ss) <$> mapM (sndM valueToJs) ps
- -- | Shallow copy an object.
+ -- Shallow copy an object.
extendObj :: AST -> [(PSString, AST)] -> m AST
extendObj obj sts = do
newObj <- freshName
@@ -289,8 +376,8 @@ moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
jsNewObj = AST.Var Nothing newObj
jsEvaluatedObj = AST.Var Nothing evaluatedObj
block = AST.Block Nothing (evaluate:objAssign:copy:extend ++ [AST.Return Nothing jsNewObj])
- evaluate = AST.VariableIntroduction Nothing evaluatedObj (Just obj)
- objAssign = AST.VariableIntroduction Nothing newObj (Just $ AST.ObjectLiteral Nothing [])
+ evaluate = AST.VariableIntroduction Nothing evaluatedObj (Just (UnknownEffects, obj))
+ objAssign = AST.VariableIntroduction Nothing newObj (Just (NoEffects, AST.ObjectLiteral Nothing []))
copy = AST.ForIn Nothing key jsEvaluatedObj $ AST.Block Nothing [AST.IfElse Nothing cond assign Nothing]
cond = AST.App Nothing (accessorString "call" (accessorString "hasOwnProperty" (AST.ObjectLiteral Nothing []))) [jsEvaluatedObj, jsKey]
assign = AST.Block Nothing [AST.Assignment Nothing (AST.Indexer Nothing jsKey jsNewObj) (AST.Indexer Nothing jsKey jsEvaluatedObj)]
@@ -298,28 +385,28 @@ moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
extend = map stToAssign sts
return $ AST.App Nothing (AST.Function Nothing Nothing [] block) []
- -- | Generate code in the simplified JavaScript intermediate representation for a reference to a
+ -- Generate code in the simplified JavaScript intermediate representation for a reference to a
-- variable.
varToJs :: Qualified Ident -> AST
- varToJs (Qualified Nothing ident) = var ident
+ varToJs (Qualified (BySourcePos _) ident) = var ident
varToJs qual = qualifiedToJS id qual
- -- | Generate code in the simplified JavaScript intermediate representation for a reference to a
+ -- Generate code in the simplified JavaScript intermediate representation for a reference to a
-- variable that may have a qualified name.
qualifiedToJS :: (a -> Ident) -> Qualified a -> AST
- qualifiedToJS f (Qualified (Just (ModuleName [ProperName mn'])) a) | mn' == C.prim = AST.Var Nothing . runIdent $ f a
- qualifiedToJS f (Qualified (Just mn') a) | mn /= mn' = accessor (f a) (AST.Var Nothing (moduleNameToJs mn'))
+ qualifiedToJS f (Qualified (ByModuleName C.M_Prim) a) = AST.Var Nothing . runIdent $ f a
+ qualifiedToJS f (Qualified (ByModuleName mn') a) | mn /= mn' = AST.ModuleAccessor Nothing mn' . mkString . T.concatMap identCharToText . runIdent $ f a
qualifiedToJS f (Qualified _ a) = AST.Var Nothing $ identToJs (f a)
foreignIdent :: Ident -> AST
- foreignIdent ident = accessorString (mkString $ runIdent ident) (AST.Var Nothing "$foreign")
+ foreignIdent ident = accessorString (mkString $ runIdent ident) (AST.Var Nothing FFINamespace)
- -- | Generate code in the simplified JavaScript intermediate representation for pattern match binders
+ -- Generate code in the simplified JavaScript intermediate representation for pattern match binders
-- and guards.
bindersToJs :: SourceSpan -> [CaseAlternative Ann] -> [AST] -> m AST
bindersToJs ss binders vals = do
valNames <- replicateM (length vals) freshName
- let assignments = zipWith (AST.VariableIntroduction Nothing) valNames (map Just vals)
+ let assignments = zipWith (AST.VariableIntroduction Nothing) valNames (map (Just . (UnknownEffects, )) vals)
jss <- forM binders $ \(CaseAlternative bs result) -> do
ret <- guardsToJs result
go valNames ret bs
@@ -358,20 +445,20 @@ moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
binderToJs :: Text -> [AST] -> Binder Ann -> m [AST]
binderToJs s done binder =
- let (ss, _, _, _) = extractBinderAnn binder in
+ let (ss, _, _) = extractBinderAnn binder in
traverse (withPos ss) =<< binderToJs' s done binder
- -- | Generate code in the simplified JavaScript intermediate representation for a pattern match
+ -- Generate code in the simplified JavaScript intermediate representation for a pattern match
-- binder.
binderToJs' :: Text -> [AST] -> Binder Ann -> m [AST]
binderToJs' _ done NullBinder{} = return done
binderToJs' varName done (LiteralBinder _ l) =
literalToBinderJS varName done l
binderToJs' varName done (VarBinder _ ident) =
- return (AST.VariableIntroduction Nothing (identToJs ident) (Just (AST.Var Nothing varName)) : done)
- binderToJs' varName done (ConstructorBinder (_, _, _, Just IsNewtype) _ _ [b]) =
+ return (AST.VariableIntroduction Nothing (identToJs ident) (Just (NoEffects, AST.Var Nothing varName)) : done)
+ binderToJs' varName done (ConstructorBinder (_, _, Just IsNewtype) _ _ [b]) =
binderToJs varName done b
- binderToJs' varName done (ConstructorBinder (_, _, _, Just (IsConstructor ctorType fields)) _ ctor bs) = do
+ binderToJs' varName done (ConstructorBinder (_, _, Just (IsConstructor ctorType fields)) _ ctor bs) = do
js <- go (zip fields bs) done
return $ case ctorType of
ProductType -> js
@@ -386,12 +473,12 @@ moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
argVar <- freshName
done'' <- go remain done'
js <- binderToJs argVar done'' binder
- return (AST.VariableIntroduction Nothing argVar (Just $ accessorString (mkString $ identToJs field) $ AST.Var Nothing varName) : js)
+ return (AST.VariableIntroduction Nothing argVar (Just (UnknownEffects, accessorString (mkString $ identToJs field) $ AST.Var Nothing varName)) : js)
binderToJs' _ _ ConstructorBinder{} =
internalError "binderToJs: Invalid ConstructorBinder in binderToJs"
binderToJs' varName done (NamedBinder _ ident binder) = do
js <- binderToJs varName done binder
- return (AST.VariableIntroduction Nothing (identToJs ident) (Just (AST.Var Nothing varName)) : js)
+ return (AST.VariableIntroduction Nothing (identToJs ident) (Just (NoEffects, AST.Var Nothing varName)) : js)
literalToBinderJS :: Text -> [AST] -> Literal (Binder Ann) -> m [AST]
literalToBinderJS varName done (NumericLiteral num) =
@@ -412,7 +499,7 @@ moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
propVar <- freshName
done'' <- go done' bs'
js <- binderToJs propVar done'' binder
- return (AST.VariableIntroduction Nothing propVar (Just (accessorString prop (AST.Var Nothing varName))) : js)
+ return (AST.VariableIntroduction Nothing propVar (Just (UnknownEffects, accessorString prop (AST.Var Nothing varName))) : js)
literalToBinderJS varName done (ArrayLiteral bs) = do
js <- go done 0 bs
return [AST.IfElse Nothing (AST.Binary Nothing AST.EqualTo (accessorString "length" (AST.Var Nothing varName)) (AST.NumericLiteral Nothing (Left (fromIntegral $ length bs)))) (AST.Block Nothing js) Nothing]
@@ -423,24 +510,10 @@ moduleToJs (Module _ coms mn _ imps exps foreigns decls) foreign_ =
elVar <- freshName
done'' <- go done' (index + 1) bs'
js <- binderToJs elVar done'' binder
- return (AST.VariableIntroduction Nothing elVar (Just (AST.Indexer Nothing (AST.NumericLiteral Nothing (Left index)) (AST.Var Nothing varName))) : js)
+ return (AST.VariableIntroduction Nothing elVar (Just (UnknownEffects, AST.Indexer Nothing (AST.NumericLiteral Nothing (Left index)) (AST.Var Nothing varName))) : js)
- -- Check that all integers fall within the valid int range for JavaScript.
- checkIntegers :: AST -> m ()
- checkIntegers = void . everywhereTopDownM go
- where
- go :: AST -> m AST
- go (AST.Unary _ AST.Negate (AST.NumericLiteral ss (Left i))) =
- -- Move the negation inside the literal; since this is a top-down
- -- traversal doing this replacement will stop the next case from raising
- -- the error when attempting to use -2147483648, as if left unrewritten
- -- the value is `Unary Negate (NumericLiteral (Left 2147483648))`, and
- -- 2147483648 is larger than the maximum allowed int.
- return $ AST.NumericLiteral ss (Left (-i))
- go js@(AST.NumericLiteral ss (Left i)) =
- let minInt = -2147483648
- maxInt = 2147483647
- in if i < minInt || i > maxInt
- then throwError . maybe errorMessage errorMessage' ss $ IntOutOfRange i "JavaScript" minInt maxInt
- else return js
- go other = return other
+accessorString :: PSString -> AST -> AST
+accessorString prop = AST.Indexer Nothing (AST.StringLiteral Nothing prop)
+
+pattern FFINamespace :: Text
+pattern FFINamespace = "$foreign"
diff --git a/src/Language/PureScript/CodeGen/JS/Common.hs b/src/Language/PureScript/CodeGen/JS/Common.hs
index c13a22d985..e029468908 100644
--- a/src/Language/PureScript/CodeGen/JS/Common.hs
+++ b/src/Language/PureScript/CodeGen/JS/Common.hs
@@ -1,29 +1,34 @@
-- | Common code generation utility functions
module Language.PureScript.CodeGen.JS.Common where
-import Prelude.Compat
+import Prelude
-import Data.Char
+import Data.Char (isAlpha, isAlphaNum, isDigit, ord)
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
-import Language.PureScript.Crash
-import Language.PureScript.Names
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Names (Ident(..), InternalIdentData(..), ModuleName(..), ProperName(..), unusedIdent)
moduleNameToJs :: ModuleName -> Text
-moduleNameToJs (ModuleName pns) =
- let name = T.intercalate "_" (runProperName `map` pns)
+moduleNameToJs (ModuleName mn) =
+ let name = T.replace "." "_" mn
in if nameIsJsBuiltIn name then "$$" <> name else name
-- | Convert an 'Ident' into a valid JavaScript identifier:
--
-- * Alphanumeric characters are kept unmodified.
--
--- * Reserved javascript identifiers are prefixed with '$$'.
+-- * Reserved javascript identifiers and identifiers starting with digits are
+-- prefixed with '$$'.
identToJs :: Ident -> Text
-identToJs (Ident name) = anyNameToJs name
+identToJs (Ident name)
+ | not (T.null name) && isDigit (T.head name) = "$$" <> T.concatMap identCharToText name
+ | otherwise = anyNameToJs name
identToJs (GenIdent _ _) = internalError "GenIdent in identToJs"
-identToJs UnusedIdent = "$__unused"
+identToJs UnusedIdent = unusedIdent
+identToJs (InternalIdent RuntimeLazyFactory) = "$runtime_lazy"
+identToJs (InternalIdent (Lazy name)) = "$lazy_" <> anyNameToJs name
-- | Convert a 'ProperName' into a valid JavaScript identifier:
--
@@ -51,11 +56,9 @@ anyNameToJs name
-- absolutely necessary.
isValidJsIdentifier :: Text -> Bool
isValidJsIdentifier s =
- and
- [ not (T.null s)
- , isAlpha (T.head s)
- , s == anyNameToJs s
- ]
+ not (T.null s) &&
+ isAlpha (T.head s) &&
+ s == anyNameToJs s
-- | Attempts to find a human-readable name for a symbol, if none has been specified returns the
-- ordinal value.
diff --git a/src/Language/PureScript/CodeGen/JS/Printer.hs b/src/Language/PureScript/CodeGen/JS/Printer.hs
index b69270cdac..6740e2a7a1 100644
--- a/src/Language/PureScript/CodeGen/JS/Printer.hs
+++ b/src/Language/PureScript/CodeGen/JS/Printer.hs
@@ -4,24 +4,26 @@ module Language.PureScript.CodeGen.JS.Printer
, prettyPrintJSWithSourceMaps
) where
-import Prelude.Compat
+import Prelude
import Control.Arrow ((<+>))
import Control.Monad (forM, mzero)
import Control.Monad.State (StateT, evalStateT)
-import Control.PatternArrows
-import qualified Control.Arrow as A
+import Control.PatternArrows (Operator(..), OperatorTable(..), Pattern(..), buildPrettyPrinter, mkPattern, mkPattern')
+import Control.Arrow qualified as A
import Data.Maybe (fromMaybe)
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
+import Data.List.NonEmpty qualified as NEL (toList)
import Language.PureScript.AST (SourceSpan(..))
-import Language.PureScript.CodeGen.JS.Common
-import Language.PureScript.CoreImp.AST
-import Language.PureScript.Comments
-import Language.PureScript.Crash
-import Language.PureScript.Pretty.Common
+import Language.PureScript.CodeGen.JS.Common (identCharToText, isValidJsIdentifier, nameIsJsBuiltIn, nameIsJsReserved)
+import Language.PureScript.CoreImp.AST (AST(..), BinaryOperator(..), CIComments(..), UnaryOperator(..), getSourceSpan)
+import Language.PureScript.CoreImp.Module (Export(..), Import(..), Module(..))
+import Language.PureScript.Comments (Comment(..))
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Pretty.Common (Emit(..), PrinterState(..), SMap, StrPos(..), addMapping', currentIndent, intercalate, parensPos, runPlainString, withIndent)
import Language.PureScript.PSString (PSString, decodeString, prettyPrintStringJS)
-- TODO (Christoph): Get rid of T.unpack / pack
@@ -71,7 +73,7 @@ literals = mkPattern' match'
match (Var _ ident) = return $ emit ident
match (VariableIntroduction _ ident value) = mconcat <$> sequence
[ return $ emit $ "var " <> ident
- , maybe (return mempty) (fmap (emit " = " <>) . prettyPrintJS') value
+ , maybe (return mempty) (fmap (emit " = " <>) . prettyPrintJS' . snd) value
]
match (Assignment _ target value) = mconcat <$> sequence
[ prettyPrintJS' target
@@ -114,40 +116,70 @@ literals = mkPattern' match'
[ return $ emit "throw "
, prettyPrintJS' value
]
- match (Comment _ com js) = mconcat <$> sequence
+ match (Comment (SourceComments com) js) = mconcat <$> sequence
[ return $ emit "\n"
, mconcat <$> forM com comment
, prettyPrintJS' js
]
+ match (Comment PureAnnotation js) = mconcat <$> sequence
+ [ return $ emit "/* #__PURE__ */ "
+ , prettyPrintJS' js
+ ]
match _ = mzero
- comment :: (Emit gen) => Comment -> StateT PrinterState Maybe gen
- comment (LineComment com) = fmap mconcat $ sequence $
- [ currentIndent
- , return $ emit "//" <> emit com <> emit "\n"
- ]
- comment (BlockComment com) = fmap mconcat $ sequence $
- [ currentIndent
- , return $ emit "/**\n"
- ] ++
- map asLine (T.lines com) ++
- [ currentIndent
- , return $ emit " */\n"
+comment :: (Emit gen) => Comment -> StateT PrinterState Maybe gen
+comment (LineComment com) = mconcat <$> sequence
+ [ currentIndent
+ , return $ emit "//" <> emit com <> emit "\n"
+ ]
+comment (BlockComment com) = fmap mconcat $ sequence $
+ [ currentIndent
+ , return $ emit "/**\n"
+ ] ++
+ map asLine (T.lines com) ++
+ [ currentIndent
+ , return $ emit " */\n"
+ , currentIndent
+ ]
+ where
+ asLine :: (Emit gen) => Text -> StateT PrinterState Maybe gen
+ asLine s = do
+ i <- currentIndent
+ return $ i <> emit " * " <> (emit . removeComments) s <> emit "\n"
+
+ removeComments :: Text -> Text
+ removeComments t =
+ case T.stripPrefix "*/" t of
+ Just rest -> removeComments rest
+ Nothing -> case T.uncons t of
+ Just (x, xs) -> x `T.cons` removeComments xs
+ Nothing -> ""
+
+prettyImport :: (Emit gen) => Import -> StateT PrinterState Maybe gen
+prettyImport (Import ident from) =
+ return . emit $
+ "import * as " <> ident <> " from " <> prettyPrintStringJS from <> ";"
+
+prettyExport :: (Emit gen) => Export -> StateT PrinterState Maybe gen
+prettyExport (Export idents from) =
+ mconcat <$> sequence
+ [ return $ emit "export {\n"
+ , withIndent $ do
+ let exportsStrings = emit . exportedIdentToString from <$> idents
+ indentString <- currentIndent
+ return . intercalate (emit ",\n") . NEL.toList $ (indentString <>) <$> exportsStrings
+ , return $ emit "\n"
, currentIndent
+ , return . emit $ "}" <> maybe "" ((" from " <>) . prettyPrintStringJS) from <> ";"
]
- where
- asLine :: (Emit gen) => Text -> StateT PrinterState Maybe gen
- asLine s = do
- i <- currentIndent
- return $ i <> emit " * " <> (emit . removeComments) s <> emit "\n"
-
- removeComments :: Text -> Text
- removeComments t =
- case T.stripPrefix "*/" t of
- Just rest -> removeComments rest
- Nothing -> case T.uncons t of
- Just (x, xs) -> x `T.cons` removeComments xs
- Nothing -> ""
+ where
+ exportedIdentToString Nothing ident
+ | nameIsJsReserved ident || nameIsJsBuiltIn ident
+ = "$$" <> ident <> " as " <> ident
+ exportedIdentToString _ "$main"
+ = T.concatMap identCharToText "$main" <> " as $main"
+ exportedIdentToString _ ident
+ = T.concatMap identCharToText ident
accessor :: Pattern PrinterState AST (Text, AST)
accessor = mkPattern match
@@ -217,14 +249,22 @@ prettyStatements sts = do
indentString <- currentIndent
return $ intercalate (emit "\n") $ map ((<> emit ";") . (indentString <>)) jss
+prettyModule :: (Emit gen) => Module -> StateT PrinterState Maybe gen
+prettyModule Module{..} = do
+ header <- mconcat <$> traverse comment modHeader
+ imps <- traverse prettyImport modImports
+ body <- prettyStatements modBody
+ exps <- traverse prettyExport modExports
+ pure $ header <> intercalate (emit "\n") (imps ++ body : exps)
+
-- | Generate a pretty-printed string representing a collection of JavaScript expressions at the same indentation level
-prettyPrintJSWithSourceMaps :: [AST] -> (Text, [SMap])
+prettyPrintJSWithSourceMaps :: Module -> (Text, [SMap])
prettyPrintJSWithSourceMaps js =
- let StrPos (_, s, mp) = (fromMaybe (internalError "Incomplete pattern") . flip evalStateT (PrinterState 0) . prettyStatements) js
+ let StrPos (_, s, mp) = (fromMaybe (internalError "Incomplete pattern") . flip evalStateT (PrinterState 0) . prettyModule) js
in (s, mp)
-prettyPrintJS :: [AST] -> Text
-prettyPrintJS = maybe (internalError "Incomplete pattern") runPlainString . flip evalStateT (PrinterState 0) . prettyStatements
+prettyPrintJS :: Module -> Text
+prettyPrintJS = maybe (internalError "Incomplete pattern") runPlainString . flip evalStateT (PrinterState 0) . prettyModule
-- | Generate an indented, pretty-printed string representing a JavaScript expression
prettyPrintJS' :: (Emit gen) => AST -> StateT PrinterState Maybe gen
diff --git a/src/Language/PureScript/Comments.hs b/src/Language/PureScript/Comments.hs
index 5c5acd82ac..ee05cd9c31 100644
--- a/src/Language/PureScript/Comments.hs
+++ b/src/Language/PureScript/Comments.hs
@@ -1,17 +1,17 @@
{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE DeriveGeneric #-}
-- |
-- Defines the types of source code comments
--
module Language.PureScript.Comments where
-import Prelude.Compat
+import Prelude
+import Codec.Serialise (Serialise)
import Control.DeepSeq (NFData)
import Data.Text (Text)
import GHC.Generics (Generic)
-import Data.Aeson.TH
+import Data.Aeson.TH (Options(..), SumEncoding(..), defaultOptions, deriveJSON)
data Comment
= LineComment Text
@@ -19,5 +19,6 @@ data Comment
deriving (Show, Eq, Ord, Generic)
instance NFData Comment
+instance Serialise Comment
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''Comment)
diff --git a/src/Language/PureScript/Constants.hs b/src/Language/PureScript/Constants.hs
deleted file mode 100644
index cd07a9cf26..0000000000
--- a/src/Language/PureScript/Constants.hs
+++ /dev/null
@@ -1,599 +0,0 @@
--- | Various constants which refer to things in the Prelude
-module Language.PureScript.Constants where
-
-import Prelude.Compat
-
-import Data.String (IsString)
-import Language.PureScript.PSString (PSString)
-import Language.PureScript.Names
-
--- Operators
-
-($) :: forall a. (IsString a) => a
-($) = "$"
-
-apply :: forall a. (IsString a) => a
-apply = "apply"
-
-(#) :: forall a. (IsString a) => a
-(#) = "#"
-
-applyFlipped :: forall a. (IsString a) => a
-applyFlipped = "applyFlipped"
-
-(<>) :: forall a. (IsString a) => a
-(<>) = "<>"
-
-(++) :: forall a. (IsString a) => a
-(++) = "++"
-
-append :: forall a. (IsString a) => a
-append = "append"
-
-(>>=) :: forall a. (IsString a) => a
-(>>=) = ">>="
-
-bind :: forall a. (IsString a) => a
-bind = "bind"
-
-discard :: forall a. (IsString a) => a
-discard = "discard"
-
-pattern Discard :: Qualified (ProperName 'ClassName)
-pattern Discard = Qualified (Just ControlBind) (ProperName "Discard")
-
-(+) :: forall a. (IsString a) => a
-(+) = "+"
-
-add :: forall a. (IsString a) => a
-add = "add"
-
-(-) :: forall a. (IsString a) => a
-(-) = "-"
-
-sub :: forall a. (IsString a) => a
-sub = "sub"
-
-(*) :: forall a. (IsString a) => a
-(*) = "*"
-
-mul :: forall a. (IsString a) => a
-mul = "mul"
-
-(/) :: forall a. (IsString a) => a
-(/) = "/"
-
-div :: forall a. (IsString a) => a
-div = "div"
-
-(%) :: forall a. (IsString a) => a
-(%) = "%"
-
-mod :: forall a. (IsString a) => a
-mod = "mod"
-
-(<) :: forall a. (IsString a) => a
-(<) = "<"
-
-lessThan :: forall a. (IsString a) => a
-lessThan = "lessThan"
-
-(>) :: forall a. (IsString a) => a
-(>) = ">"
-
-greaterThan :: forall a. (IsString a) => a
-greaterThan = "greaterThan"
-
-(<=) :: forall a. (IsString a) => a
-(<=) = "<="
-
-lessThanOrEq :: forall a. (IsString a) => a
-lessThanOrEq = "lessThanOrEq"
-
-(>=) :: forall a. (IsString a) => a
-(>=) = ">="
-
-greaterThanOrEq :: forall a. (IsString a) => a
-greaterThanOrEq = "greaterThanOrEq"
-
-(==) :: forall a. (IsString a) => a
-(==) = "=="
-
-eq :: forall a. (IsString a) => a
-eq = "eq"
-
-eq1 :: forall a. (IsString a) => a
-eq1 = "eq1"
-
-(/=) :: forall a. (IsString a) => a
-(/=) = "/="
-
-notEq :: forall a. (IsString a) => a
-notEq = "notEq"
-
-compare :: forall a. (IsString a) => a
-compare = "compare"
-
-compare1 :: forall a. (IsString a) => a
-compare1 = "compare1"
-
-(&&) :: forall a. (IsString a) => a
-(&&) = "&&"
-
-conj :: forall a. (IsString a) => a
-conj = "conj"
-
-(||) :: forall a. (IsString a) => a
-(||) = "||"
-
-disj :: forall a. (IsString a) => a
-disj = "disj"
-
-unsafeIndex :: forall a. (IsString a) => a
-unsafeIndex = "unsafeIndex"
-
-or :: forall a. (IsString a) => a
-or = "or"
-
-and :: forall a. (IsString a) => a
-and = "and"
-
-xor :: forall a. (IsString a) => a
-xor = "xor"
-
-(<<<) :: forall a. (IsString a) => a
-(<<<) = "<<<"
-
-compose :: forall a. (IsString a) => a
-compose = "compose"
-
-(>>>) :: forall a. (IsString a) => a
-(>>>) = ">>>"
-
-composeFlipped :: forall a. (IsString a) => a
-composeFlipped = "composeFlipped"
-
-map :: forall a. (IsString a) => a
-map = "map"
-
--- Functions
-
-negate :: forall a. (IsString a) => a
-negate = "negate"
-
-not :: forall a. (IsString a) => a
-not = "not"
-
-shl :: forall a. (IsString a) => a
-shl = "shl"
-
-shr :: forall a. (IsString a) => a
-shr = "shr"
-
-zshr :: forall a. (IsString a) => a
-zshr = "zshr"
-
-complement :: forall a. (IsString a) => a
-complement = "complement"
-
--- Prelude Values
-
-zero :: forall a. (IsString a) => a
-zero = "zero"
-
-one :: forall a. (IsString a) => a
-one = "one"
-
-bottom :: forall a. (IsString a) => a
-bottom = "bottom"
-
-top :: forall a. (IsString a) => a
-top = "top"
-
-return :: forall a. (IsString a) => a
-return = "return"
-
-pure' :: forall a. (IsString a) => a
-pure' = "pure"
-
-returnEscaped :: forall a. (IsString a) => a
-returnEscaped = "$return"
-
-unit :: forall a. (IsString a) => a
-unit = "unit"
-
--- Core lib values
-
-runST :: forall a. (IsString a) => a
-runST = "run"
-
-stRefValue :: forall a. (IsString a) => a
-stRefValue = "value"
-
-newSTRef :: forall a. (IsString a) => a
-newSTRef = "new"
-
-readSTRef :: forall a. (IsString a) => a
-readSTRef = "read"
-
-writeSTRef :: forall a. (IsString a) => a
-writeSTRef = "write"
-
-modifySTRef :: forall a. (IsString a) => a
-modifySTRef = "modify"
-
-mkFn :: forall a. (IsString a) => a
-mkFn = "mkFn"
-
-runFn :: forall a. (IsString a) => a
-runFn = "runFn"
-
-mkEffFn :: forall a. (IsString a) => a
-mkEffFn = "mkEffFn"
-
-runEffFn :: forall a. (IsString a) => a
-runEffFn = "runEffFn"
-
-mkEffectFn :: forall a. (IsString a) => a
-mkEffectFn = "mkEffectFn"
-
-runEffectFn :: forall a. (IsString a) => a
-runEffectFn = "runEffectFn"
-
--- Prim values
-
-undefined :: forall a. (IsString a) => a
-undefined = "undefined"
-
--- Type Class Dictionary Names
-
-data EffectDictionaries = EffectDictionaries
- { edApplicativeDict :: PSString
- , edBindDict :: PSString
- , edMonadDict :: PSString
- , edWhile :: PSString
- , edUntil :: PSString
- }
-
-effDictionaries :: EffectDictionaries
-effDictionaries = EffectDictionaries
- { edApplicativeDict = "applicativeEff"
- , edBindDict = "bindEff"
- , edMonadDict = "monadEff"
- , edWhile = "whileE"
- , edUntil = "untilE"
- }
-
-effectDictionaries :: EffectDictionaries
-effectDictionaries = EffectDictionaries
- { edApplicativeDict = "applicativeEffect"
- , edBindDict = "bindEffect"
- , edMonadDict = "monadEffect"
- , edWhile = "whileE"
- , edUntil = "untilE"
- }
-
-stDictionaries :: EffectDictionaries
-stDictionaries = EffectDictionaries
- { edApplicativeDict = "applicativeST"
- , edBindDict = "bindST"
- , edMonadDict = "monadST"
- , edWhile = "while"
- , edUntil = "until"
- }
-
-discardUnitDictionary :: forall a. (IsString a) => a
-discardUnitDictionary = "discardUnit"
-
-semiringNumber :: forall a. (IsString a) => a
-semiringNumber = "semiringNumber"
-
-semiringInt :: forall a. (IsString a) => a
-semiringInt = "semiringInt"
-
-ringNumber :: forall a. (IsString a) => a
-ringNumber = "ringNumber"
-
-ringInt :: forall a. (IsString a) => a
-ringInt = "ringInt"
-
-moduloSemiringNumber :: forall a. (IsString a) => a
-moduloSemiringNumber = "moduloSemiringNumber"
-
-moduloSemiringInt :: forall a. (IsString a) => a
-moduloSemiringInt = "moduloSemiringInt"
-
-euclideanRingNumber :: forall a. (IsString a) => a
-euclideanRingNumber = "euclideanRingNumber"
-
-euclideanRingInt :: forall a. (IsString a) => a
-euclideanRingInt = "euclideanRingInt"
-
-ordBoolean :: forall a. (IsString a) => a
-ordBoolean = "ordBoolean"
-
-ordNumber :: forall a. (IsString a) => a
-ordNumber = "ordNumber"
-
-ordInt :: forall a. (IsString a) => a
-ordInt = "ordInt"
-
-ordString :: forall a. (IsString a) => a
-ordString = "ordString"
-
-ordChar :: forall a. (IsString a) => a
-ordChar = "ordChar"
-
-eqNumber :: forall a. (IsString a) => a
-eqNumber = "eqNumber"
-
-eqInt :: forall a. (IsString a) => a
-eqInt = "eqInt"
-
-eqString :: forall a. (IsString a) => a
-eqString = "eqString"
-
-eqChar :: forall a. (IsString a) => a
-eqChar = "eqChar"
-
-eqBoolean :: forall a. (IsString a) => a
-eqBoolean = "eqBoolean"
-
-boundedBoolean :: forall a. (IsString a) => a
-boundedBoolean = "boundedBoolean"
-
-booleanAlgebraBoolean :: forall a. (IsString a) => a
-booleanAlgebraBoolean = "booleanAlgebraBoolean"
-
-heytingAlgebraBoolean :: forall a. (IsString a) => a
-heytingAlgebraBoolean = "heytingAlgebraBoolean"
-
-semigroupString :: forall a. (IsString a) => a
-semigroupString = "semigroupString"
-
-semigroupoidFn :: forall a. (IsString a) => a
-semigroupoidFn = "semigroupoidFn"
-
--- Generic Deriving
-
-generic :: forall a. (IsString a) => a
-generic = "Generic"
-
-toSpine :: forall a. (IsString a) => a
-toSpine = "toSpine"
-
-fromSpine :: forall a. (IsString a) => a
-fromSpine = "fromSpine"
-
-toSignature :: forall a. (IsString a) => a
-toSignature = "toSignature"
-
--- Main module
-
-main :: forall a. (IsString a) => a
-main = "main"
-
--- Prim
-
-partial :: forall a. (IsString a) => a
-partial = "Partial"
-
-pattern Prim :: ModuleName
-pattern Prim = ModuleName [ProperName "Prim"]
-
-pattern Partial :: Qualified (ProperName 'ClassName)
-pattern Partial = Qualified (Just Prim) (ProperName "Partial")
-
-pattern Record :: Qualified (ProperName 'TypeName)
-pattern Record = Qualified (Just Prim) (ProperName "Record")
-
--- Prim.Boolean
-
-pattern PrimBoolean :: ModuleName
-pattern PrimBoolean = ModuleName [ProperName "Prim", ProperName "Boolean"]
-
-booleanTrue :: Qualified (ProperName 'TypeName)
-booleanTrue = Qualified (Just PrimBoolean) (ProperName "True")
-
-booleanFalse :: Qualified (ProperName 'TypeName)
-booleanFalse = Qualified (Just PrimBoolean) (ProperName "False")
-
--- Prim.Ordering
-
-pattern PrimOrdering :: ModuleName
-pattern PrimOrdering = ModuleName [ProperName "Prim", ProperName "Ordering"]
-
-orderingLT :: Qualified (ProperName 'TypeName)
-orderingLT = Qualified (Just PrimOrdering) (ProperName "LT")
-
-orderingEQ :: Qualified (ProperName 'TypeName)
-orderingEQ = Qualified (Just PrimOrdering) (ProperName "EQ")
-
-orderingGT :: Qualified (ProperName 'TypeName)
-orderingGT = Qualified (Just PrimOrdering) (ProperName "GT")
-
--- Prim.Row
-
-pattern PrimRow :: ModuleName
-pattern PrimRow = ModuleName [ProperName "Prim", ProperName "Row"]
-
-pattern RowUnion :: Qualified (ProperName 'ClassName)
-pattern RowUnion = Qualified (Just PrimRow) (ProperName "Union")
-
-pattern RowNub :: Qualified (ProperName 'ClassName)
-pattern RowNub = Qualified (Just PrimRow) (ProperName "Nub")
-
-pattern RowCons :: Qualified (ProperName 'ClassName)
-pattern RowCons = Qualified (Just PrimRow) (ProperName "Cons")
-
-pattern RowLacks :: Qualified (ProperName 'ClassName)
-pattern RowLacks = Qualified (Just PrimRow) (ProperName "Lacks")
-
--- Prim.RowList
-
-pattern PrimRowList :: ModuleName
-pattern PrimRowList = ModuleName [ProperName "Prim", ProperName "RowList"]
-
-pattern RowToList :: Qualified (ProperName 'ClassName)
-pattern RowToList = Qualified (Just PrimRowList) (ProperName "RowToList")
-
-pattern RowListNil :: Qualified (ProperName 'TypeName)
-pattern RowListNil = Qualified (Just PrimRowList) (ProperName "Nil")
-
-pattern RowListCons :: Qualified (ProperName 'TypeName)
-pattern RowListCons = Qualified (Just PrimRowList) (ProperName "Cons")
-
--- Prim.Symbol
-
-pattern PrimSymbol :: ModuleName
-pattern PrimSymbol = ModuleName [ProperName "Prim", ProperName "Symbol"]
-
-pattern SymbolCompare :: Qualified (ProperName 'ClassName)
-pattern SymbolCompare = Qualified (Just PrimSymbol) (ProperName "Compare")
-
-pattern SymbolAppend :: Qualified (ProperName 'ClassName)
-pattern SymbolAppend = Qualified (Just PrimSymbol) (ProperName "Append")
-
-pattern SymbolCons :: Qualified (ProperName 'ClassName)
-pattern SymbolCons = Qualified (Just PrimSymbol) (ProperName "Cons")
-
--- Prim.TypeError
-
-pattern PrimTypeError :: ModuleName
-pattern PrimTypeError = ModuleName [ProperName "Prim", ProperName "TypeError"]
-
-pattern Fail :: Qualified (ProperName 'ClassName)
-pattern Fail = Qualified (Just PrimTypeError) (ProperName "Fail")
-
-pattern Warn :: Qualified (ProperName 'ClassName)
-pattern Warn = Qualified (Just PrimTypeError) (ProperName "Warn")
-
-primModules :: [ModuleName]
-primModules = [Prim, PrimBoolean, PrimOrdering, PrimRow, PrimRowList, PrimSymbol, PrimTypeError]
-
--- Data.Symbol
-
-pattern DataSymbol :: ModuleName
-pattern DataSymbol = ModuleName [ProperName "Data", ProperName "Symbol"]
-
-pattern IsSymbol :: Qualified (ProperName 'ClassName)
-pattern IsSymbol = Qualified (Just DataSymbol) (ProperName "IsSymbol")
-
-typ :: forall a. (IsString a) => a
-typ = "Type"
-
-kindBoolean :: forall a. (IsString a) => a
-kindBoolean = "Boolean"
-
-kindOrdering :: forall a. (IsString a) => a
-kindOrdering = "Ordering"
-
-kindRowList :: forall a. (IsString a) => a
-kindRowList = "RowList"
-
-symbol :: forall a. (IsString a) => a
-symbol = "Symbol"
-
-doc :: forall a. (IsString a) => a
-doc = "Doc"
-
--- Modules
-
-prim :: forall a. (IsString a) => a
-prim = "Prim"
-
-moduleBoolean :: forall a. (IsString a) => a
-moduleBoolean = "Boolean"
-
-moduleOrdering :: forall a. (IsString a) => a
-moduleOrdering = "Ordering"
-
-moduleRow :: forall a. (IsString a) => a
-moduleRow = "Row"
-
-moduleRowList :: forall a. (IsString a) => a
-moduleRowList = "RowList"
-
-moduleSymbol :: forall a. (IsString a) => a
-moduleSymbol = "Symbol"
-
-typeError :: forall a. (IsString a) => a
-typeError = "TypeError"
-
-prelude :: forall a. (IsString a) => a
-prelude = "Prelude"
-
-dataArray :: forall a. (IsString a) => a
-dataArray = "Data_Array"
-
-eff :: forall a. (IsString a) => a
-eff = "Control_Monad_Eff"
-
-effect :: forall a. (IsString a) => a
-effect = "Effect"
-
-st :: forall a. (IsString a) => a
-st = "Control_Monad_ST_Internal"
-
-controlApplicative :: forall a. (IsString a) => a
-controlApplicative = "Control_Applicative"
-
-controlSemigroupoid :: forall a. (IsString a) => a
-controlSemigroupoid = "Control_Semigroupoid"
-
-pattern ControlBind :: ModuleName
-pattern ControlBind = ModuleName [ProperName "Control", ProperName "Bind"]
-
-controlBind :: forall a. (IsString a) => a
-controlBind = "Control_Bind"
-
-controlMonadEffUncurried :: forall a. (IsString a) => a
-controlMonadEffUncurried = "Control_Monad_Eff_Uncurried"
-
-effectUncurried :: forall a. (IsString a) => a
-effectUncurried = "Effect_Uncurried"
-
-dataBounded :: forall a. (IsString a) => a
-dataBounded = "Data_Bounded"
-
-dataSemigroup :: forall a. (IsString a) => a
-dataSemigroup = "Data_Semigroup"
-
-dataHeytingAlgebra :: forall a. (IsString a) => a
-dataHeytingAlgebra = "Data_HeytingAlgebra"
-
-dataEq :: forall a. (IsString a) => a
-dataEq = "Data_Eq"
-
-dataOrd :: forall a. (IsString a) => a
-dataOrd = "Data_Ord"
-
-dataSemiring :: forall a. (IsString a) => a
-dataSemiring = "Data_Semiring"
-
-dataRing :: forall a. (IsString a) => a
-dataRing = "Data_Ring"
-
-dataEuclideanRing :: forall a. (IsString a) => a
-dataEuclideanRing = "Data_EuclideanRing"
-
-dataFunction :: forall a. (IsString a) => a
-dataFunction = "Data_Function"
-
-dataFunctionUncurried :: forall a. (IsString a) => a
-dataFunctionUncurried = "Data_Function_Uncurried"
-
-dataIntBits :: forall a. (IsString a) => a
-dataIntBits = "Data_Int_Bits"
-
-partialUnsafe :: forall a. (IsString a) => a
-partialUnsafe = "Partial_Unsafe"
-
-unsafePartial :: forall a. (IsString a) => a
-unsafePartial = "unsafePartial"
-
-unsafeCoerce :: forall a. (IsString a) => a
-unsafeCoerce = "Unsafe_Coerce"
-
-unsafeCoerceFn :: forall a. (IsString a) => a
-unsafeCoerceFn = "unsafeCoerce"
diff --git a/src/Language/PureScript/Constants/Libs.hs b/src/Language/PureScript/Constants/Libs.hs
new file mode 100644
index 0000000000..75c7385e0e
--- /dev/null
+++ b/src/Language/PureScript/Constants/Libs.hs
@@ -0,0 +1,264 @@
+{-# LANGUAGE BlockArguments #-}
+{-# LANGUAGE TemplateHaskell #-}
+-- | Various constants which refer to things in the Prelude and other core libraries
+module Language.PureScript.Constants.Libs where
+
+import Protolude qualified as P
+
+import Data.String (IsString)
+import Language.PureScript.PSString (PSString)
+import Language.PureScript.Constants.TH qualified as TH
+
+-- Core lib values
+
+stRefValue :: forall a. IsString a => a
+stRefValue = "value"
+
+-- Type Class Dictionary Names
+
+data EffectDictionaries = EffectDictionaries
+ { edApplicativeDict :: PSString
+ , edBindDict :: PSString
+ , edMonadDict :: PSString
+ , edWhile :: PSString
+ , edUntil :: PSString
+ }
+
+effDictionaries :: EffectDictionaries
+effDictionaries = EffectDictionaries
+ { edApplicativeDict = "applicativeEff"
+ , edBindDict = "bindEff"
+ , edMonadDict = "monadEff"
+ , edWhile = "whileE"
+ , edUntil = "untilE"
+ }
+
+effectDictionaries :: EffectDictionaries
+effectDictionaries = EffectDictionaries
+ { edApplicativeDict = "applicativeEffect"
+ , edBindDict = "bindEffect"
+ , edMonadDict = "monadEffect"
+ , edWhile = "whileE"
+ , edUntil = "untilE"
+ }
+
+stDictionaries :: EffectDictionaries
+stDictionaries = EffectDictionaries
+ { edApplicativeDict = "applicativeST"
+ , edBindDict = "bindST"
+ , edMonadDict = "monadST"
+ , edWhile = "while"
+ , edUntil = "until"
+ }
+
+$(TH.declare do
+
+ -- purescript-prelude
+
+ TH.mod "Control.Apply" do
+ TH.asIdent do TH.asString do TH.var "apply"
+
+ TH.mod "Control.Applicative" do
+ TH.asIdent do TH.asPair do TH.asString do TH.var "pure"
+
+ TH.mod "Control.Bind" do
+ TH.asPair do
+ TH.asString do
+ TH.var "bind"
+ TH.cls "Discard" ; TH.var "discard"
+
+ TH.var "discardUnit"
+
+ TH.mod "Control.Category" do
+ TH.asPair do
+ TH.asIdent do TH.var "identity"
+
+ TH.var "categoryFn"
+
+ TH.mod "Control.Semigroupoid" do
+ TH.asPair do
+ TH.vars ["compose", "composeFlipped"]
+ TH.var "semigroupoidFn"
+
+ TH.mod "Data.Bounded" do
+ TH.asPair do
+ TH.vars ["bottom", "top"]
+ TH.var "boundedBoolean"
+
+ TH.mod "Data.Eq" do
+ TH.cls "Eq" ; TH.asIdent do TH.asPair do TH.asString do TH.var "eq"
+ TH.cls "Eq1" ; TH.asIdent do TH.asString do TH.var "eq1"
+ TH.asPair do
+ TH.var "notEq"
+
+ TH.var "eqBoolean"
+ TH.var "eqChar"
+ TH.var "eqInt"
+ TH.var "eqNumber"
+ TH.var "eqString"
+
+ TH.mod "Data.EuclideanRing" do
+ TH.asPair do
+ TH.var "div"
+
+ TH.var "euclideanRingNumber"
+
+ TH.mod "Data.Function" do
+ TH.asIdent do
+ TH.prefixWith "function" do TH.vars ["apply", "applyFlipped"]
+ TH.var "const"
+ TH.var "flip"
+
+ TH.mod "Data.Functor" do
+ TH.cls "Functor" ; TH.asIdent do TH.asString do TH.var "map"
+
+ TH.mod "Data.Generic.Rep" do
+ TH.cls "Generic" ; TH.asIdent do TH.vars ["from", "to"]
+ TH.ntys ["Argument", "Constructor", "NoArguments", "NoConstructors", "Product"]
+ TH.dty "Sum" ["Inl", "Inr"]
+
+ TH.mod "Data.HeytingAlgebra" do
+ TH.asPair do
+ TH.asIdent do TH.vars ["conj", "disj", "not"]
+
+ TH.var "heytingAlgebraBoolean"
+
+ TH.mod "Data.Monoid" do
+ TH.asIdent do TH.var "mempty"
+
+ TH.mod "Data.Ord" do
+ TH.cls "Ord" ; TH.asIdent do TH.asString do TH.var "compare"
+ TH.cls "Ord1" ; TH.asIdent do TH.asString do TH.var "compare1"
+ TH.asPair do
+ TH.vars ["greaterThan", "greaterThanOrEq", "lessThan", "lessThanOrEq"]
+
+ TH.var "ordBoolean"
+ TH.var "ordChar"
+ TH.var "ordInt"
+ TH.var "ordNumber"
+ TH.var "ordString"
+
+ TH.mod "Data.Ordering" do
+ TH.dty "Ordering" ["EQ", "GT", "LT"]
+
+ TH.mod "Data.Reflectable" do
+ TH.cls "Reflectable"
+
+ TH.mod "Data.Ring" do
+ TH.asPair do
+ TH.asString do TH.vars ["negate", "sub"]
+
+ TH.var "ringInt"
+ TH.var "ringNumber"
+
+ TH.mod "Data.Semigroup" do
+ TH.asPair do
+ TH.asIdent do TH.var "append"
+
+ TH.var "semigroupString"
+
+ TH.mod "Data.Semiring" do
+ TH.asPair do
+ TH.vars ["add", "mul", "one", "zero"]
+
+ TH.var "semiringInt"
+ TH.var "semiringNumber"
+
+ TH.mod "Data.Symbol" do
+ TH.cls "IsSymbol"
+
+ -- purescript-arrays
+
+ TH.mod "Data.Array" do
+ TH.asPair do TH.var "unsafeIndex"
+
+ -- purescript-bifunctors
+
+ TH.mod "Data.Bifunctor" do
+ TH.cls "Bifunctor" ; TH.asIdent do TH.asString do TH.var "bimap"
+ TH.asIdent do TH.vars ["lmap", "rmap"]
+
+ -- purescript-contravariant
+
+ TH.mod "Data.Functor.Contravariant" do
+ TH.cls "Contravariant" ; TH.asIdent do TH.asString do TH.var "cmap"
+
+ -- purescript-eff
+
+ TH.mod "Control.Monad.Eff" (P.pure ())
+
+ TH.mod "Control.Monad.Eff.Uncurried" do
+ TH.asPair do TH.vars ["mkEffFn", "runEffFn"]
+
+ -- purescript-effect
+
+ TH.mod "Effect" (P.pure ())
+
+ TH.mod "Effect.Uncurried" do
+ TH.asPair do TH.vars ["mkEffectFn", "runEffectFn"]
+
+ -- purescript-foldable-traversable
+
+ TH.mod "Data.Bifoldable" do
+ TH.cls "Bifoldable" ; TH.asIdent do TH.asString do TH.vars ["bifoldMap", "bifoldl", "bifoldr"]
+
+ TH.mod "Data.Bitraversable" do
+ TH.cls "Bitraversable" ; TH.asString do TH.asIdent (TH.var "bitraverse"); TH.var "bisequence"
+ TH.asIdent do
+ TH.vars ["ltraverse", "rtraverse"]
+
+ TH.mod "Data.Foldable" do
+ TH.cls "Foldable" ; TH.asIdent do TH.asString do TH.vars ["foldMap", "foldl", "foldr"]
+
+ TH.mod "Data.Traversable" do
+ TH.cls "Traversable" ; TH.asString do TH.asIdent (TH.var "traverse") ; TH.var "sequence"
+
+ -- purescript-functions
+
+ TH.mod "Data.Function.Uncurried" do
+ TH.asPair do TH.asString do TH.vars ["mkFn", "runFn"]
+
+ -- purescript-integers
+
+ TH.mod "Data.Int.Bits" do
+ TH.asPair do
+ TH.var "and"
+ TH.var "complement"
+ TH.var "or"
+ TH.var "shl"
+ TH.var "shr"
+ TH.var "xor"
+ TH.var "zshr"
+
+ -- purescript-newtype
+
+ TH.mod "Data.Newtype" do
+ TH.cls "Newtype"
+
+ -- purescript-partial
+
+ TH.mod "Partial.Unsafe" do
+ TH.asIdent do TH.asPair do TH.var "unsafePartial"
+
+ -- purescript-profunctor
+
+ TH.mod "Data.Profunctor" do
+ TH.cls "Profunctor" ; TH.asIdent do TH.asString do TH.var "dimap"
+ TH.asIdent do
+ TH.var "lcmap"
+ TH.prefixWith "profunctor" do TH.var "rmap"
+
+ -- purescript-st
+
+ TH.mod "Control.Monad.ST.Internal" do
+ TH.asPair do TH.vars ["modify", "new", "read", "run", "write"]
+
+ TH.mod "Control.Monad.ST.Uncurried" do
+ TH.asPair do TH.vars ["mkSTFn", "runSTFn"]
+
+ -- purescript-unsafe-coerce
+
+ TH.mod "Unsafe.Coerce" do
+ TH.asPair do TH.var "unsafeCoerce"
+
+ )
diff --git a/src/Language/PureScript/Constants/Prim.hs b/src/Language/PureScript/Constants/Prim.hs
new file mode 100644
index 0000000000..08391155da
--- /dev/null
+++ b/src/Language/PureScript/Constants/Prim.hs
@@ -0,0 +1,57 @@
+{-# LANGUAGE BlockArguments #-}
+{-# LANGUAGE TemplateHaskell #-}
+-- | Various constants which refer to things in Prim
+module Language.PureScript.Constants.Prim where
+
+import Language.PureScript.Names (ModuleName)
+import Language.PureScript.Constants.TH qualified as TH
+
+$(TH.declare do
+ TH.mod "Prim" do
+ TH.cls "Partial"
+ TH.ty "Array"
+ TH.ty "Boolean"
+ TH.ty "Char"
+ TH.ty "Constraint"
+ TH.ty "Function"
+ TH.ty "Int"
+ TH.ty "Number"
+ TH.ty "Record"
+ TH.ty "Row"
+ TH.ty "String"
+ TH.ty "Symbol"
+ TH.ty "Type"
+ TH.asIdent do TH.asString do TH.var "undefined"
+
+ TH.mod "Prim.Boolean" do
+ TH.tys ["False", "True"]
+
+ TH.mod "Prim.Coerce" do
+ TH.cls "Coercible"
+
+ TH.mod "Prim.Int" do
+ TH.prefixWith "Int" do TH.clss ["Add", "Compare", "Mul", "ToString"]
+
+ TH.mod "Prim.Ordering" do
+ TH.prefixWith "Type" do TH.ty "Ordering"
+ TH.tys ["EQ", "GT", "LT"]
+
+ TH.mod "Prim.Row" do
+ TH.prefixWith "Row" do TH.clss ["Cons", "Lacks", "Nub", "Union"]
+
+ TH.mod "Prim.RowList" do
+ TH.ty "RowList"
+ TH.cls "RowToList"
+ TH.prefixWith "RowList" do TH.tys ["Cons", "Nil"]
+
+ TH.mod "Prim.Symbol" do
+ TH.prefixWith "Symbol" do TH.clss ["Append", "Compare", "Cons"]
+
+ TH.mod "Prim.TypeError" do
+ TH.clss ["Fail", "Warn"]
+ TH.tys ["Above", "Beside", "Doc", "Quote", "QuoteLabel", "Text"]
+
+ )
+
+primModules :: [ModuleName]
+primModules = [M_Prim, M_Prim_Boolean, M_Prim_Coerce, M_Prim_Ordering, M_Prim_Row, M_Prim_RowList, M_Prim_Symbol, M_Prim_Int, M_Prim_TypeError]
diff --git a/src/Language/PureScript/Constants/TH.hs b/src/Language/PureScript/Constants/TH.hs
new file mode 100644
index 0000000000..2bc8a56d84
--- /dev/null
+++ b/src/Language/PureScript/Constants/TH.hs
@@ -0,0 +1,224 @@
+{-# LANGUAGE TemplateHaskell #-}
+-- | This module implements an eDSL for compactly declaring pattern synonyms
+-- representing known PureScript modules and their members.
+--
+-- The following example assumes this module is imported qualified as TH and
+-- the BlockArguments extension is used, both of which I recommend.
+--
+-- > $(TH.declare do
+-- > TH.mod "Data.Foo" do
+-- > TH.ty "SomeType"
+-- > TH.asIdent do
+-- > TH.var "someVariable"
+-- > )
+--
+-- will become:
+--
+-- > pattern M_Data_Foo :: ModuleName
+-- > pattern M_Data_Foo = ModuleName "Data.Foo"
+-- >
+-- > pattern SomeType :: Qualified (ProperName 'TypeName)
+-- > pattern SomeType = Qualified (ByModuleName M_Data_Foo) (ProperName "SomeType")
+-- >
+-- > pattern I_someVariable :: Qualified Ident
+-- > pattern I_someVariable = Qualified (ByModuleName M_Data_Foo) (Ident "someVariable")
+--
+-- All pattern synonyms must start with an uppercase letter. To prevent
+-- namespace collisions, different types of pattern are distinguished by a sort
+-- of Hungarian notation convention:
+--
+-- @
+-- SomeType -- a type or class name
+-- C_Ctor -- a constructor name
+-- I_name -- a Qualified Ident
+-- M_Data_Foo -- a module name
+-- P_name -- a (module name, polymorphic string) pair
+-- S_name -- a lone polymorphic string (this doesn't contain any module information)
+-- @
+--
+-- I_, P_, and S_ patterns are all optional and have to be enabled with
+-- `asIdent`, `asPair`, and `asString` modifiers respectively.
+--
+-- Finally, to disambiguate between identifiers with the same name (such as
+-- Data.Function.apply and Data.Apply.apply), the `prefixWith` modifier will
+-- modify the names of the patterns created within it.
+--
+-- > TH.mod "Data.Function" do
+-- > TH.prefixWith "function" do
+-- > TH.asIdent do
+-- > TH.var "apply"
+--
+-- results in:
+--
+-- > pattern I_functionApply :: Qualified Ident
+-- > pattern I_functionApply = Qualified (ByModuleName (M_Data_Function) (Ident "apply")
+--
+module Language.PureScript.Constants.TH
+ ( declare
+ , mod
+ , cls, clss
+ , dty
+ , nty, ntys
+ , ty, tys
+ , var, vars
+ , prefixWith
+ , asIdent
+ , asPair
+ , asString
+ ) where
+
+import Protolude hiding (Type, mod)
+
+import Control.Lens (over, _head)
+import Control.Monad.Trans.RWS (RWS, execRWS)
+import Control.Monad.Trans.Writer (Writer, execWriter)
+import Control.Monad.Writer.Class (tell)
+import Data.String (String)
+import Language.Haskell.TH (Dec, Name, Pat, Q, Type, conP, implBidir, litP, mkName, patSynD, patSynSigD, prefixPatSyn, stringL)
+import Language.PureScript.Names (Ident(..), ModuleName(..), ProperName(..), ProperNameType(..), Qualified(..), QualifiedBy(..))
+
+-- | Generate pattern synonyms corresponding to the provided PureScript
+-- declarations.
+declare :: Writer (Q [Dec]) () -> Q [Dec]
+declare = execWriter
+
+-- | Declare a module.
+mod :: String -> ModDecs -> Writer (Q [Dec]) ()
+mod mnStr inner = do
+ -- pattern M_Data_Foo :: ModuleName
+ -- pattern M_Data_Foo = ModuleName "Data.Foo"
+ let mn = mkModuleName mnStr
+ tell $ typedPatSyn mn [t| ModuleName |] [p| ModuleName $(litP $ stringL mnStr) |]
+ tell $ snd $ execRWS inner (mn, "", []) ()
+
+-- | Declare a type class. The resulting pattern will use the name of the class
+-- and have type `Qualified (ProperName 'ClassName)`.
+cls :: String -> ModDecs
+cls cn = ask >>= \(mn, prefix, _) -> tell $ mkPnPat [t| 'ClassName |] mn prefix cn
+
+-- | Declare a list of type classes; shorthand for repeatedly calling `cls`.
+clss :: [String] -> ModDecs
+clss = traverse_ cls
+
+-- | Declare a data type, given the name of the type and a list of constructor
+-- names. A pattern will be created using the name of the type and have type
+-- `Qualified (ProperName 'TypeName)`. A pattern will also be created for each
+-- constructor prefixed with "C_", having type `Qualified (ProperName
+-- 'ConstructorName)`.
+dty :: String -> [String] -> ModDecs
+dty dn ctors = ask >>= \(mn, prefix, _) -> do
+ tell $ mkPnPat [t| 'TypeName |] mn prefix dn
+ tell $ map fold $ traverse (mkPnPat [t| 'ConstructorName |] mn $ "C_" <> prefix) ctors
+
+-- | Declare a data type with a singular constructor named the same as the
+-- type, as is commonly the case with newtypes (but this does not require the
+-- type to be a newtype in reality). Shorthand for calling `dty`.
+nty :: String -> ModDecs
+nty tn = dty tn [tn]
+
+-- | Declare a list of data types with singular constructors; shorthand for
+-- repeatedly calling `nty`, which itself is shorthand for `dty`.
+ntys :: [String] -> ModDecs
+ntys = traverse_ nty
+
+-- | Declare a type. The resulting pattern will use the name of the type and have
+-- type `Qualified (ProperName 'TypeName)`.
+ty :: String -> ModDecs
+ty tn = ask >>= \(mn, prefix, _) -> tell $ mkPnPat [t| 'TypeName |] mn prefix tn
+
+-- | Declare a list of types; shorthand for repeatedly calling `ty`.
+tys :: [String] -> ModDecs
+tys = traverse_ ty
+
+-- | Declare a variable, function, named instance, or generally a lower-case
+-- value member of a module. The patterns created depend on which of `asPair`,
+-- `asIdent`, or `asString` are used in the enclosing context.
+var :: String -> ModDecs
+var nm = ask >>= \(mn, prefix, vtds) -> tell $ foldMap (\f -> f mn prefix nm) vtds
+
+-- | Declare a list of variables; shorthand for repeatedly calling `var`.
+vars :: [String] -> ModDecs
+vars = traverse_ var
+
+-- | For every variable declared within, create a pattern synonym prefixed
+-- with "P_" having type `forall a. (Eq a, IsString a) => (ModuleName, a)`.
+asPair :: ModDecs -> ModDecs
+asPair = local $ addToVars mkPairDec
+
+-- | For every variable declared within, cerate a pattern synonym prefixed
+-- with "I_" having type `Qualified Ident`.
+asIdent :: ModDecs -> ModDecs
+asIdent = local $ addToVars mkIdentDec
+
+-- | For every variable declared within, cerate a pattern synonym prefixed
+-- with "S_" having type `forall a. (Eq a, IsString a) => a`.
+asString :: ModDecs -> ModDecs
+asString = local $ addToVars mkStringDec
+
+-- | Prefix the names of all enclosed declarations with the provided string, to
+-- prevent collisions with other identifiers. For example,
+-- `prefixWith "function"` would turn `I_apply` into `I_functionApply`, and
+-- `C_Example` into `C_FunctionExample`.
+prefixWith :: String -> ModDecs -> ModDecs
+prefixWith = local . applyPrefix
+
+-- Internals start here
+
+type ModDecs = RWS (Name, String, [VarToDec]) (Q [Dec]) () ()
+type VarToDec = Name -> String -> String -> Q [Dec]
+
+addToVars :: VarToDec -> (a, b, [VarToDec]) -> (a, b, [VarToDec])
+addToVars f (a, b, fs) = (a, b, f : fs)
+
+applyPrefix :: String -> (a, String, c) -> (a, String, c)
+applyPrefix prefix (a, prefix', c) = (a, camelAppend prefix' prefix, c)
+
+cap :: String -> String
+cap = over _head toUpper
+
+camelAppend :: String -> String -> String
+camelAppend l r = if null l then r else l <> cap r
+
+-- "Data.Foo" -> M_Data_Foo
+mkModuleName :: String -> Name
+mkModuleName = mkName . ("M_" <>) . map (\case '.' -> '_'; other -> other)
+
+-- "I_" -> "fn" -> "foo" -> I_fnFoo
+-- "I_" -> "" -> "foo" -> I_foo
+mkPrefixedName :: String -> String -> String -> Name
+mkPrefixedName tag prefix = mkName . (tag <>) . camelAppend prefix
+
+-- 'TypeName -> M_Data_Foo -> "Function" -> "Foo" ->
+-- pattern FunctionFoo :: Qualified (ProperName 'TypeName)
+-- pattern FunctionFoo = Qualified (ByModuleName M_Data_Foo) (ProperName "Foo")
+mkPnPat :: Q Type -> VarToDec
+mkPnPat pnType mn prefix str = typedPatSyn (mkName $ cap prefix <> str)
+ [t| Qualified (ProperName $pnType) |]
+ [p| Qualified (ByModuleName $(conP mn [])) (ProperName $(litP $ stringL str)) |]
+
+-- M_Data_Foo -> "function" -> "foo" ->
+-- pattern I_functionFoo :: Qualified Ident
+-- pattern I_functionFoo = Qualified (ByModuleName M_Data_Foo) (Ident "foo")
+mkIdentDec :: VarToDec
+mkIdentDec mn prefix str = typedPatSyn (mkPrefixedName "I_" prefix str)
+ [t| Qualified Ident |]
+ [p| Qualified (ByModuleName $(conP mn [])) (Ident $(litP $ stringL str)) |]
+
+-- M_Data_Foo -> "function" -> "foo" ->
+-- pattern P_functionFoo :: forall a. (Eq a, IsString a) => (ModuleName, a)
+-- pattern P_functionFoo = (M_Data_Foo, "foo")
+mkPairDec :: VarToDec
+mkPairDec mn prefix str = typedPatSyn (mkPrefixedName "P_" prefix str)
+ [t| forall a. (Eq a, IsString a) => (ModuleName, a) |]
+ [p| ($(conP mn []), $(litP $ stringL str)) |]
+
+-- _ -> "function" -> "foo" ->
+-- pattern S_functionFoo :: forall a. (Eq a, IsString a) => a
+-- pattern S_functionFoo = "foo"
+mkStringDec :: VarToDec
+mkStringDec _ prefix str = typedPatSyn (mkPrefixedName "S_" prefix str)
+ [t| forall a. (Eq a, IsString a) => a |]
+ (litP $ stringL str)
+
+typedPatSyn :: Name -> Q Type -> Q Pat -> Q [Dec]
+typedPatSyn nm t p = sequence [patSynSigD nm t, patSynD nm (prefixPatSyn []) implBidir p]
diff --git a/src/Language/PureScript/CoreFn/Ann.hs b/src/Language/PureScript/CoreFn/Ann.hs
index cb536cc2f7..185f8beb5b 100644
--- a/src/Language/PureScript/CoreFn/Ann.hs
+++ b/src/Language/PureScript/CoreFn/Ann.hs
@@ -1,25 +1,24 @@
module Language.PureScript.CoreFn.Ann where
-import Prelude.Compat
+import Prelude
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Comments
-import Language.PureScript.CoreFn.Meta
-import Language.PureScript.Types
+import Language.PureScript.AST.SourcePos (SourceSpan)
+import Language.PureScript.Comments (Comment)
+import Language.PureScript.CoreFn.Meta (Meta)
-- |
-- Type alias for basic annotations
--
-type Ann = (SourceSpan, [Comment], Maybe SourceType, Maybe Meta)
+type Ann = (SourceSpan, [Comment], Maybe Meta)
-- |
-- An annotation empty of metadata aside from a source span.
--
ssAnn :: SourceSpan -> Ann
-ssAnn ss = (ss, [], Nothing, Nothing)
+ssAnn ss = (ss, [], Nothing)
-- |
-- Remove the comments from an annotation
--
removeComments :: Ann -> Ann
-removeComments (ss, _, ty, meta) = (ss, [], ty, meta)
+removeComments (ss, _, meta) = (ss, [], meta)
diff --git a/src/Language/PureScript/CoreFn/Binders.hs b/src/Language/PureScript/CoreFn/Binders.hs
index acff617a41..4b64b97c49 100644
--- a/src/Language/PureScript/CoreFn/Binders.hs
+++ b/src/Language/PureScript/CoreFn/Binders.hs
@@ -3,10 +3,10 @@
--
module Language.PureScript.CoreFn.Binders where
-import Prelude.Compat
+import Prelude
-import Language.PureScript.AST.Literals
-import Language.PureScript.Names
+import Language.PureScript.AST.Literals (Literal)
+import Language.PureScript.Names (Ident, ProperName, ProperNameType(..), Qualified)
-- |
-- Data type for binders
@@ -31,7 +31,7 @@ data Binder a
-- |
-- A binder which binds its input to an identifier
--
- | NamedBinder a Ident (Binder a) deriving (Show, Functor)
+ | NamedBinder a Ident (Binder a) deriving (Eq, Ord, Show, Functor)
extractBinderAnn :: Binder a -> a
diff --git a/src/Language/PureScript/CoreFn/CSE.hs b/src/Language/PureScript/CoreFn/CSE.hs
new file mode 100644
index 0000000000..e3e59bddad
--- /dev/null
+++ b/src/Language/PureScript/CoreFn/CSE.hs
@@ -0,0 +1,442 @@
+{-# LANGUAGE TemplateHaskell #-}
+-- | This module performs limited common subexpression elimination
+module Language.PureScript.CoreFn.CSE (optimizeCommonSubexpressions) where
+
+import Protolude hiding (pass)
+
+import Control.Lens (At(..), makeLenses, non, view, (%~), (.=), (.~), (<>~), (^.))
+import Control.Monad.Supply (Supply)
+import Control.Monad.Supply.Class (MonadSupply)
+import Control.Monad.RWS (MonadWriter, RWST, censor, evalRWST, listen, pass, tell)
+import Data.Bitraversable (bitraverse)
+import Data.Functor.Compose (Compose(..))
+import Data.IntMap.Monoidal qualified as IM
+import Data.IntSet qualified as IS
+import Data.Map.Strict qualified as M
+import Data.Maybe (fromJust)
+import Data.Semigroup (Min(..))
+import Data.Semigroup.Generic (GenericSemigroupMonoid(..))
+
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.AST.SourcePos (nullSourceSpan)
+import Language.PureScript.Constants.Libs qualified as C
+import Language.PureScript.CoreFn.Ann (Ann)
+import Language.PureScript.CoreFn.Binders (Binder(..))
+import Language.PureScript.CoreFn.Expr (Bind(..), CaseAlternative(..), Expr(..))
+import Language.PureScript.CoreFn.Meta (Meta(IsSyntheticApp))
+import Language.PureScript.CoreFn.Traversals (everywhereOnValues, traverseCoreFn)
+import Language.PureScript.Environment (dictTypeName)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName, ProperName(..), Qualified(..), QualifiedBy(..), freshIdent, runIdent, toMaybeModuleName)
+import Language.PureScript.PSString (decodeString)
+
+-- |
+-- `discuss f m` is an action that listens to the output of `m`, passes that
+-- and its value through `f`, and uses (only) the value of the result to set
+-- the new value and output. (Any output produced via the monad in `f` is
+-- ignored, though other monadic effects will hold.)
+--
+discuss :: MonadWriter w m => ((a, w) -> m (b, w)) -> m a -> m b
+discuss f = pass . fmap (second const) . (f <=< listen)
+
+-- |
+-- Modify the target of an optic in the state with a monadic computation that
+-- returns some extra information of type `r` in a tuple.
+--
+-- I would prefer that this be a named function, but I don't know what to name
+-- it. I went with symbols instead because the function that this operator most
+-- resembles is `(%%=)`, which doesn't have a textual name as far as I know.
+-- Compare the following (approximate) types:
+--
+-- @
+-- (%%=) :: MonadState s m => Lens s s a b -> (a -> (r, b)) -> m r
+-- (%%<~) :: MonadState s m => Lens s s a b -> (a -> m (r, b)) -> m r
+-- @
+--
+-- Replacing the `=` with `<~` was inspired by analogy with the following pair:
+--
+-- @
+-- (.=) :: MonadState s m => Lens s s a b -> b -> m ()
+-- (<~) :: MonadState s m => Lens s s a b -> m b -> m ()
+-- @
+--
+-- I regret any confusion that ensues.
+--
+-- Note that there are two interpretations that could reasonably be expected
+-- for this type.
+--
+-- @
+-- (%%<~) :: MonadState s m => Lens s s a b -> (a -> m (r, b)) -> m r
+-- @
+--
+-- One is:
+-- * Get the focused `a` value from the monad
+-- * Run the computation
+-- * Get the new state from the returned monad
+-- * Take the returned `b` value and set it in the new state
+--
+-- The other is:
+-- * Get the focused `a` value from the monad
+-- * Run the computation
+-- * Take the returned `b` value and set it in the *original* state
+-- * Put the result into the returned monad
+--
+-- This operator corresponds to the second interpretation. The purpose of this,
+-- and part of the purpose of having this operator at all instead of composing
+-- simpler operators, is to enable using the lens only once (on the original
+-- state) instead of twice (for a get and a set on different states).
+--
+(%%<~)
+ :: MonadState s m
+ => ((a -> Compose m ((,) r) b) -> s -> Compose m ((,) r) s)
+ -- ^ please read as Lens s s a b
+ -> (a -> m (r, b))
+ -> m r
+l %%<~ f = get >>= getCompose . l (Compose . f) >>= state . const
+infix 4 %%<~
+
+-- |
+-- A PluralityMap is like a weaker multiset: like a multiset, it can hold
+-- several of the same value, but instead of keeping track of their exact
+-- counts, it only records whether there is one (False) or more than one
+-- (True).
+--
+newtype PluralityMap k = PluralityMap { getPluralityMap :: M.Map k Bool }
+
+instance Ord k => Semigroup (PluralityMap k) where
+ PluralityMap l <> PluralityMap r =
+ let
+ l' = M.mapWithKey (\k -> (|| k `M.member` r)) l
+ in PluralityMap $ l' `M.union` r
+
+instance Ord k => Monoid (PluralityMap k) where
+ mempty = PluralityMap M.empty
+
+data BindingType = NonRecursive | Recursive deriving Eq
+
+-- |
+-- Record summary data about an expression.
+--
+data CSESummary = CSESummary
+ { _scopesUsed :: IS.IntSet
+ -- ^ set of the scope numbers used in this expression
+ , _noFloatWithin :: Maybe (Min Int)
+ -- ^ optionally a scope within which this expression is not to be floated
+ -- (because the expression uses an identifier bound recursively in that
+ -- scope)
+ , _plurality :: PluralityMap Ident
+ -- ^ which floated identifiers are used more than once in this expression
+ -- (note that a single use inside an Abs will be considered multiple uses,
+ -- as this pass doesn't know when/how many times an Abs will be executed)
+ , _newBindings :: IM.MonoidalIntMap [(Ident, (PluralityMap Ident, Expr Ann))]
+ -- ^ floated bindings, organized by scope number
+ , _toBeReinlined :: M.Map Ident (Expr Ann)
+ -- ^ a map of floated identifiers that did not end up getting bound and
+ -- will need to be reinlined at the end of the pass
+ }
+ deriving Generic
+ deriving (Semigroup, Monoid) via GenericSemigroupMonoid CSESummary
+
+-- |
+-- Append a value at a given scope depth.
+--
+addToScope :: Semigroup v => Int -> v -> IM.MonoidalIntMap v -> IM.MonoidalIntMap v
+addToScope depth v
+ = IM.alter (Just . maybe v (<> v)) depth
+
+-- |
+-- Remove and return an entire scope from a map of bindings.
+--
+popScope :: Monoid v => Int -> IM.MonoidalIntMap v -> (v, IM.MonoidalIntMap v)
+popScope depth
+ = first fold . IM.updateLookupWithKey (\_ _ -> Nothing) depth
+
+-- |
+-- Describe the context of an expression.
+--
+data CSEEnvironment = CSEEnvironment
+ { _depth :: Int
+ -- ^ number of enclosing binding scopes (this includes not only Abs, but
+ -- Let and CaseAlternative bindings)
+ , _deepestTopLevelScope :: Int
+ -- ^ number of enclosing binding scopes outside the first Abs; used to
+ -- decide whether to qualify floated identifiers
+ , _bound :: M.Map Ident (Int, BindingType)
+ -- ^ map from identifiers to depth in which they are bound and whether
+ -- or not the binding is recursive
+ }
+
+makeLenses ''CSESummary
+makeLenses ''CSEEnvironment
+
+-- |
+-- Map from the shape of an expression to an identifier created to represent
+-- that expression, organized by scope depth.
+--
+type CSEState = IM.MonoidalIntMap (M.Map (Expr ()) Ident)
+
+-- |
+-- The monad in which CSE takes place.
+--
+type CSEMonad a = RWST CSEEnvironment CSESummary CSEState Supply a
+
+type HasCSEReader = MonadReader CSEEnvironment
+type HasCSEWriter = MonadWriter CSESummary
+type HasCSEState = MonadState CSEState
+
+-- |
+-- Run a CSEMonad computation; the return value is augmented with a map of
+-- identifiers that should be replaced in the final expression because they
+-- didn't end up needing to be floated.
+--
+runCSEMonad :: CSEMonad a -> Supply (a, M.Map Ident (Expr Ann))
+runCSEMonad x = second (^. toBeReinlined) <$> evalRWST x (CSEEnvironment 0 0 M.empty) IM.empty
+
+-- |
+-- Mark all expressions floated out of this computation as "plural". This pass
+-- assumes that any given Abs may be invoked multiple times, so any expressions
+-- inside the Abs but floated out of it also count as having multiple uses,
+-- even if they only appear once within the Abs. Consequently, any expressions
+-- that can be floated out of an Abs won't be reinlined at the end.
+--
+enterAbs :: HasCSEWriter m => m a -> m a
+enterAbs = censor $ plurality %~ PluralityMap . fmap (const True) . getPluralityMap
+
+-- |
+-- Run the provided computation in a new scope.
+--
+newScope :: (HasCSEReader m, HasCSEWriter m) => Bool -> (Int -> m a) -> m a
+newScope isTopLevel body = local goDeeper $ do
+ d <- view depth
+ censor (filterToDepth d) (body d)
+ where
+ filterToDepth d
+ = (scopesUsed %~ IS.filter (< d))
+ . (noFloatWithin %~ find (< Min d))
+ goDeeper env@CSEEnvironment{..} =
+ if isTopLevel
+ then env{ _depth = depth', _deepestTopLevelScope = depth' }
+ else env{ _depth = depth' }
+ where
+ depth' = succ _depth
+
+-- |
+-- Record a list of identifiers as being bound in the given scope.
+--
+withBoundIdents :: HasCSEReader m => [Ident] -> (Int, BindingType) -> m a -> m a
+withBoundIdents idents t = local (bound %~ flip (foldl' (flip (flip M.insert t))) idents)
+
+-- |
+-- Run the provided computation in a new scope in which the provided
+-- identifiers are bound non-recursively.
+--
+newScopeWithIdents :: (HasCSEReader m, HasCSEWriter m) => Bool -> [Ident] -> m a -> m a
+newScopeWithIdents isTopLevel idents = newScope isTopLevel . flip (withBoundIdents idents . (, NonRecursive))
+
+-- |
+-- Produce, or retrieve from the state, an identifier for referencing the given
+-- expression, at and below the given depth.
+--
+generateIdentFor :: (HasCSEState m, MonadSupply m) => Int -> Expr () -> m (Bool, Ident)
+generateIdentFor d e = at d . non mempty . at e %%<~ \case
+ Nothing -> freshIdent (nameHint e) <&> \ident -> ((True, ident), Just ident)
+ Just ident -> pure ((False, ident), Just ident)
+ -- A reminder: as with %%=, the first element of the returned pair is the
+ -- final result of the expression, and the second element is the value to
+ -- stuff back through the lens into the state. (The difference is that %%<~
+ -- enables doing monadic work in the RHS, namely `freshIdent` here.)
+ where
+ nameHint = \case
+ App _ v1 v2
+ | Var _ n <- v1
+ , fmap (ProperName . runIdent) n == fmap dictTypeName C.IsSymbol
+ , Literal _ (ObjectLiteral [(_, Abs _ _ (Literal _ (StringLiteral str)))]) <- v2
+ , Just decodedStr <- decodeString str
+ -> decodedStr <> "IsSymbol"
+ | otherwise
+ -> nameHint v1
+ Var _ (Qualified _ ident)
+ | Ident name <- ident -> name
+ | GenIdent (Just name) _ <- ident -> name
+ Accessor _ prop _
+ | Just decodedProp <- decodeString prop -> decodedProp
+ _ -> "ref"
+
+nullAnn :: Ann
+nullAnn = (nullSourceSpan, [], Nothing)
+
+-- |
+-- Use a map to substitute local Vars in a list of Binds.
+--
+replaceLocals :: M.Map Ident (Expr Ann) -> [Bind Ann] -> [Bind Ann]
+replaceLocals m = if M.null m then identity else map f' where
+ (f', g', _) = everywhereOnValues identity f identity
+ f e@(Var _ (Qualified _ ident)) = maybe e g' $ ident `M.lookup` m
+ f e = e
+
+-- |
+-- Store in the monad a new binding for the given expression, returning a Var
+-- referencing it. The provided CSESummary will be transformed to reflect the
+-- replacement.
+--
+floatExpr
+ :: (HasCSEReader m, HasCSEState m, MonadSupply m)
+ => QualifiedBy
+ -> (Expr Ann, CSESummary)
+ -> m (Expr Ann, CSESummary)
+floatExpr topLevelQB = \case
+ (e, w@CSESummary{ _noFloatWithin = Nothing, .. }) -> do
+ let deepestScope = if IS.null _scopesUsed then 0 else IS.findMax _scopesUsed
+ (isNew, ident) <- generateIdentFor deepestScope (void e)
+ topLevel <- view deepestTopLevelScope
+ let qb = if deepestScope > topLevel then ByNullSourcePos else topLevelQB
+ let w' = w
+ & (if isNew then newBindings %~ addToScope deepestScope [(ident, (_plurality, e))] else identity)
+ & plurality .~ PluralityMap (M.singleton ident False)
+ pure (Var nullAnn (Qualified qb ident), w')
+ (e, w) -> pure (e, w)
+
+-- |
+-- Take possession of the Binds intended to be added to the current scope,
+-- removing them from the state, and return the list of Binds along with
+-- whatever value is returned by the provided computation.
+--
+getNewBinds
+ :: (HasCSEReader m, HasCSEState m, HasCSEWriter m)
+ => m a
+ -> m ([Bind Ann], a)
+getNewBinds =
+ discuss $ \(a, w) -> do
+ d <- view depth
+ at d .= Nothing
+ let (floatedHere, w') = newBindings (popScope d) w
+ pure $ first (, a) $ foldr handleFloat ([], w') floatedHere
+ where
+ handleFloat (ident, (p, e)) (bs, w) =
+ if fromJust . M.lookup ident . getPluralityMap $ w ^. plurality
+ then (NonRec nullAnn ident e : bs, w')
+ else (bs, w' & toBeReinlined %~ M.insert ident e)
+ where w' = w & plurality <>~ p
+
+-- |
+-- Like getNewBinds, but also stores the Binds in a Let wrapping the provided
+-- expression. If said expression is already a Let, adds these Binds to that
+-- Let instead.
+--
+getNewBindsAsLet
+ :: (HasCSEReader m, HasCSEWriter m, HasCSEState m)
+ => m (Expr Ann)
+ -> m (Expr Ann)
+getNewBindsAsLet = fmap (uncurry go) . getNewBinds where
+ go bs = if null bs then identity else \case
+ Let a bs' e' -> Let a (bs ++ bs') e'
+ e' -> Let nullAnn bs e'
+
+-- |
+-- Feed the Writer part of the monad with the requirements of this name.
+--
+summarizeName
+ :: (HasCSEReader m, HasCSEWriter m)
+ => ModuleName
+ -> Qualified Ident
+ -> m ()
+summarizeName mn (Qualified mn' ident) = do
+ m <- view bound
+ let (s, bt) =
+ fromMaybe (0, NonRecursive) $
+ guard (all (== mn) (toMaybeModuleName mn')) *> ident `M.lookup` m
+ tell $ mempty
+ & scopesUsed .~ IS.singleton s
+ & noFloatWithin .~ (guard (bt == Recursive) $> Min s)
+
+-- |
+-- Collect all the Idents put in scope by a list of Binders.
+--
+identsFromBinders :: [Binder a] -> [Ident]
+identsFromBinders = foldMap identsFromBinder where
+ identsFromBinder = \case
+ LiteralBinder _ (ArrayLiteral xs) -> identsFromBinders xs
+ LiteralBinder _ (ObjectLiteral xs) -> identsFromBinders (map snd xs)
+ VarBinder _ ident -> [ident]
+ ConstructorBinder _ _ _ xs -> identsFromBinders xs
+ NamedBinder _ ident x -> ident : identsFromBinder x
+ LiteralBinder _ BooleanLiteral{} -> []
+ LiteralBinder _ CharLiteral{} -> []
+ LiteralBinder _ NumericLiteral{} -> []
+ LiteralBinder _ StringLiteral{} -> []
+ NullBinder{} -> []
+
+-- |
+-- Float synthetic Apps (right now, the only Apps marked as synthetic are type
+-- class dictionaries being fed to functions with constraints, superclass
+-- accessors, and instances of IsSymbol) to a new or existing Let as close to
+-- the top level as possible.
+--
+optimizeCommonSubexpressions :: ModuleName -> [Bind Ann] -> Supply [Bind Ann]
+optimizeCommonSubexpressions mn
+ = fmap (uncurry (flip replaceLocals))
+ . runCSEMonad
+ . fmap (uncurry (++))
+ . getNewBinds
+ . fmap fst
+ . handleBinds True (pure ())
+
+ where
+
+ -- This is the one place (I think?) that keeps this from being a general
+ -- common subexpression elimination pass.
+ shouldFloatExpr :: Expr Ann -> Bool
+ shouldFloatExpr = \case
+ App (_, _, Just IsSyntheticApp) e _ -> isSimple e
+ _ -> False
+
+ isSimple :: Expr Ann -> Bool
+ isSimple = \case
+ Var{} -> True
+ Accessor _ _ e -> isSimple e
+ _ -> False
+
+ handleAndWrapExpr :: Expr Ann -> CSEMonad (Expr Ann)
+ handleAndWrapExpr = getNewBindsAsLet . handleExpr
+
+ (handleBind, handleExprDefault, handleBinder, _) = traverseCoreFn handleBind handleExpr handleBinder handleCaseAlternative
+
+ topLevelQB = ByModuleName mn
+
+ handleExpr :: Expr Ann -> CSEMonad (Expr Ann)
+ handleExpr = discuss (ifM (shouldFloatExpr . fst) (floatExpr topLevelQB) pure) . \case
+ Abs a ident e -> enterAbs $ Abs a ident <$> newScopeWithIdents False [ident] (handleAndWrapExpr e)
+ v@(Var _ qname) -> summarizeName mn qname $> v
+ Let a bs e -> uncurry (Let a) <$> handleBinds False (handleExpr e) bs
+ x -> handleExprDefault x
+
+ handleCaseAlternative :: CaseAlternative Ann -> CSEMonad (CaseAlternative Ann)
+ handleCaseAlternative (CaseAlternative bs x) = CaseAlternative bs <$> do
+ newScopeWithIdents False (identsFromBinders bs) $
+ bitraverse (traverse $ bitraverse handleAndWrapExpr handleAndWrapExpr) handleAndWrapExpr x
+
+ handleBinds :: forall a. Bool -> CSEMonad a -> [Bind Ann] -> CSEMonad ([Bind Ann], a)
+ handleBinds isTopLevel = foldr go . fmap pure where
+ go :: Bind Ann -> CSEMonad ([Bind Ann], a) -> CSEMonad ([Bind Ann], a)
+ go b inner = case b of
+ -- For a NonRec Bind, traverse the bound expression in the current scope
+ -- and then create a new scope for any remaining Binds and/or whatever
+ -- inner thing all these Binds are applied to.
+ NonRec a ident e -> do
+ e' <- handleExpr e
+ newScopeWithIdents isTopLevel [ident] $
+ prependToNewBindsFromInner $ NonRec a ident e'
+ Rec es ->
+ -- For a Rec Bind, the bound expressions need a new scope in which all
+ -- these identifiers are bound recursively; then the remaining Binds
+ -- and the inner thing can be traversed in the same scope with the same
+ -- identifiers now bound non-recursively.
+ newScope isTopLevel $ \d -> do
+ let idents = map (snd . fst) es
+ es' <- withBoundIdents idents (d, Recursive) $ traverse (traverse handleExpr) es
+ withBoundIdents idents (d, NonRecursive) $
+ prependToNewBindsFromInner $ Rec es'
+
+ where
+
+ prependToNewBindsFromInner :: Bind Ann -> CSEMonad ([Bind Ann], a)
+ prependToNewBindsFromInner hd = first (hd :) . join <$> getNewBinds inner
diff --git a/src/Language/PureScript/CoreFn/Desugar.hs b/src/Language/PureScript/CoreFn/Desugar.hs
index b404558999..34bf08f1f3 100644
--- a/src/Language/PureScript/CoreFn/Desugar.hs
+++ b/src/Language/PureScript/CoreFn/Desugar.hs
@@ -1,33 +1,33 @@
module Language.PureScript.CoreFn.Desugar (moduleToCoreFn) where
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
+import Protolude (ordNub, orEmpty)
import Control.Arrow (second)
import Data.Function (on)
-import Data.List (sort, sortBy)
import Data.Maybe (mapMaybe)
import Data.Tuple (swap)
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Map as M
+import Data.List.NonEmpty qualified as NEL
+import Data.Map qualified as M
-import Language.PureScript.AST.Literals
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.AST.Traversals
-import Language.PureScript.Comments
-import Language.PureScript.CoreFn.Ann
-import Language.PureScript.CoreFn.Binders
-import Language.PureScript.CoreFn.Expr
-import Language.PureScript.CoreFn.Meta
-import Language.PureScript.CoreFn.Module
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Names
-import Language.PureScript.Sugar.TypeClasses (typeClassMemberName, superClassDictionaryNames)
-import Language.PureScript.Types
-import Language.PureScript.PSString (mkString)
-import qualified Language.PureScript.AST as A
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.AST.SourcePos (pattern NullSourceSpan, SourceSpan(..))
+import Language.PureScript.AST.Traversals (everythingOnValues)
+import Language.PureScript.Comments (Comment)
+import Language.PureScript.CoreFn.Ann (Ann, ssAnn)
+import Language.PureScript.CoreFn.Binders (Binder(..))
+import Language.PureScript.CoreFn.Expr (Bind(..), CaseAlternative(..), Expr(..), Guard)
+import Language.PureScript.CoreFn.Meta (ConstructorType(..), Meta(..))
+import Language.PureScript.CoreFn.Module (Module(..))
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (DataDeclType(..), Environment(..), NameKind(..), isDictTypeName, lookupConstructor, lookupValue)
+import Language.PureScript.Label (Label(..))
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName, ProperName(..), ProperNameType(..), Qualified(..), QualifiedBy(..), getQual)
+import Language.PureScript.PSString (PSString)
+import Language.PureScript.Types (pattern REmptyKinded, SourceType, Type(..))
+import Language.PureScript.AST qualified as A
+import Language.PureScript.Constants.Prim qualified as C
-- | Desugars a module from AST to CoreFn representation.
moduleToCoreFn :: Environment -> A.Module -> Module Ann
@@ -37,85 +37,114 @@ moduleToCoreFn env (A.Module modSS coms mn decls (Just exps)) =
let imports = mapMaybe importToCoreFn decls ++ fmap (ssAnn modSS,) (findQualModules decls)
imports' = dedupeImports imports
exps' = ordNub $ concatMap exportToCoreFn exps
+ reExps = M.map ordNub $ M.unionsWith (++) (mapMaybe (fmap reExportsToCoreFn . toReExportRef) exps)
externs = ordNub $ mapMaybe externToCoreFn decls
decls' = concatMap declToCoreFn decls
- in Module modSS coms mn (spanName modSS) imports' exps' externs decls'
-
+ in Module modSS coms mn (spanName modSS) imports' exps' reExps externs decls'
where
+ -- Creates a map from a module name to the re-export references defined in
+ -- that module.
+ reExportsToCoreFn :: (ModuleName, A.DeclarationRef) -> M.Map ModuleName [Ident]
+ reExportsToCoreFn (mn', ref') = M.singleton mn' (exportToCoreFn ref')
+
+ toReExportRef :: A.DeclarationRef -> Maybe (ModuleName, A.DeclarationRef)
+ toReExportRef (A.ReExportRef _ src ref) =
+ fmap
+ (, ref)
+ (A.exportSourceImportedFrom src)
+ toReExportRef _ = Nothing
- -- | Remove duplicate imports
+ -- Remove duplicate imports
dedupeImports :: [(Ann, ModuleName)] -> [(Ann, ModuleName)]
dedupeImports = fmap swap . M.toList . M.fromListWith const . fmap swap
ssA :: SourceSpan -> Ann
- ssA ss = (ss, [], Nothing, Nothing)
+ ssA ss = (ss, [], Nothing)
- -- | Desugars member declarations from AST to CoreFn representation.
+ -- Desugars member declarations from AST to CoreFn representation.
declToCoreFn :: A.Declaration -> [Bind Ann]
- declToCoreFn (A.DataDeclaration (ss, com) Newtype _ _ [(ctor, _)]) =
- [NonRec (ssA ss) (properToIdent ctor) $
- Abs (ss, com, Nothing, Just IsNewtype) (Ident "x") (Var (ssAnn ss) $ Qualified Nothing (Ident "x"))]
+ declToCoreFn (A.DataDeclaration (ss, com) Newtype _ _ [ctor]) =
+ [NonRec (ss, [], declMeta) (properToIdent $ A.dataCtorName ctor) $
+ Abs (ss, com, Just IsNewtype) (Ident "x") (Var (ssAnn ss) $ Qualified ByNullSourcePos (Ident "x"))]
+ where
+ declMeta = isDictTypeName (A.dataCtorName ctor) `orEmpty` IsTypeClassConstructor
declToCoreFn d@(A.DataDeclaration _ Newtype _ _ _) =
error $ "Found newtype with multiple constructors: " ++ show d
declToCoreFn (A.DataDeclaration (ss, com) Data tyName _ ctors) =
- flip fmap ctors $ \(ctor, _) ->
- let (_, _, _, fields) = lookupConstructor env (Qualified (Just mn) ctor)
- in NonRec (ssA ss) (properToIdent ctor) $ Constructor (ss, com, Nothing, Nothing) tyName ctor fields
+ flip fmap ctors $ \ctorDecl ->
+ let
+ ctor = A.dataCtorName ctorDecl
+ (_, _, _, fields) = lookupConstructor env (Qualified (ByModuleName mn) ctor)
+ in NonRec (ssA ss) (properToIdent ctor) $ Constructor (ss, com, Nothing) tyName ctor fields
declToCoreFn (A.DataBindingGroupDeclaration ds) =
concatMap declToCoreFn ds
declToCoreFn (A.ValueDecl (ss, com) name _ _ [A.MkUnguarded e]) =
[NonRec (ssA ss) name (exprToCoreFn ss com Nothing e)]
declToCoreFn (A.BindingGroupDeclaration ds) =
[Rec . NEL.toList $ fmap (\(((ss, com), name), _, e) -> ((ssA ss, name), exprToCoreFn ss com Nothing e)) ds]
- declToCoreFn (A.TypeClassDeclaration sa@(ss, _) name _ supers _ members) =
- [NonRec (ssA ss) (properToIdent name) $ mkTypeClassConstructor sa supers members]
declToCoreFn _ = []
- -- | Desugars expressions from AST to CoreFn representation.
+ -- Desugars expressions from AST to CoreFn representation.
exprToCoreFn :: SourceSpan -> [Comment] -> Maybe SourceType -> A.Expr -> Expr Ann
- exprToCoreFn _ com ty (A.Literal ss lit) =
- Literal (ss, com, ty, Nothing) (fmap (exprToCoreFn ss com Nothing) lit)
- exprToCoreFn ss com ty (A.Accessor name v) =
- Accessor (ss, com, ty, Nothing) name (exprToCoreFn ss [] Nothing v)
+ exprToCoreFn _ com _ (A.Literal ss lit) =
+ Literal (ss, com, Nothing) (fmap (exprToCoreFn ss com Nothing) lit)
+ exprToCoreFn ss com _ (A.Accessor name v) =
+ Accessor (ss, com, Nothing) name (exprToCoreFn ss [] Nothing v)
exprToCoreFn ss com ty (A.ObjectUpdate obj vs) =
- ObjectUpdate (ss, com, ty, Nothing) (exprToCoreFn ss [] Nothing obj) $ fmap (second (exprToCoreFn ss [] Nothing)) vs
- exprToCoreFn ss com ty (A.Abs (A.VarBinder _ name) v) =
- Abs (ss, com, ty, Nothing) name (exprToCoreFn ss [] Nothing v)
+ ObjectUpdate (ss, com, Nothing) (exprToCoreFn ss [] Nothing obj) (ty >>= unchangedRecordFields (fmap fst vs)) $ fmap (second (exprToCoreFn ss [] Nothing)) vs
+ where
+ -- Return the unchanged labels of a closed record, or Nothing for other types or open records.
+ unchangedRecordFields :: [PSString] -> Type a -> Maybe [PSString]
+ unchangedRecordFields updated (TypeApp _ (TypeConstructor _ C.Record) row) =
+ collect row
+ where
+ collect :: Type a -> Maybe [PSString]
+ collect (REmptyKinded _ _) = Just []
+ collect (RCons _ (Label l) _ r) = (if l `elem` updated then id else (l :)) <$> collect r
+ collect _ = Nothing
+ unchangedRecordFields _ _ = Nothing
+ exprToCoreFn ss com _ (A.Abs (A.VarBinder _ name) v) =
+ Abs (ss, com, Nothing) name (exprToCoreFn ss [] Nothing v)
exprToCoreFn _ _ _ (A.Abs _ _) =
internalError "Abs with Binder argument was not desugared before exprToCoreFn mn"
- exprToCoreFn ss com ty (A.App v1 v2) =
- App (ss, com, ty, Nothing) (exprToCoreFn ss [] Nothing v1) (exprToCoreFn ss [] Nothing v2)
- exprToCoreFn _ com ty (A.Var ss ident) =
- Var (ss, com, ty, getValueMeta ident) ident
- exprToCoreFn ss com ty (A.IfThenElse v1 v2 v3) =
- Case (ss, com, ty, Nothing) [exprToCoreFn ss [] Nothing v1]
+ exprToCoreFn ss com _ (A.App v1 v2) =
+ App (ss, com, (isDictCtor v1 || isSynthetic v2) `orEmpty` IsSyntheticApp) v1' v2'
+ where
+ v1' = exprToCoreFn ss [] Nothing v1
+ v2' = exprToCoreFn ss [] Nothing v2
+ isDictCtor = \case
+ A.Constructor _ (Qualified _ name) -> isDictTypeName name
+ _ -> False
+ isSynthetic = \case
+ A.App v3 v4 -> isDictCtor v3 || isSynthetic v3 && isSynthetic v4
+ A.Accessor _ v3 -> isSynthetic v3
+ A.Var NullSourceSpan _ -> True
+ A.Unused{} -> True
+ _ -> False
+ exprToCoreFn ss com _ (A.Unused _) =
+ Var (ss, com, Nothing) C.I_undefined
+ exprToCoreFn _ com _ (A.Var ss ident) =
+ Var (ss, com, getValueMeta ident) ident
+ exprToCoreFn ss com _ (A.IfThenElse v1 v2 v3) =
+ Case (ss, com, Nothing) [exprToCoreFn ss [] Nothing v1]
[ CaseAlternative [LiteralBinder (ssAnn ss) $ BooleanLiteral True]
(Right $ exprToCoreFn ss [] Nothing v2)
, CaseAlternative [NullBinder (ssAnn ss)]
(Right $ exprToCoreFn ss [] Nothing v3) ]
- exprToCoreFn _ com ty (A.Constructor ss name) =
- Var (ss, com, ty, Just $ getConstructorMeta name) $ fmap properToIdent name
- exprToCoreFn ss com ty (A.Case vs alts) =
- Case (ss, com, ty, Nothing) (fmap (exprToCoreFn ss [] Nothing) vs) (fmap (altToCoreFn ss) alts)
+ exprToCoreFn _ com _ (A.Constructor ss name) =
+ Var (ss, com, Just $ getConstructorMeta name) $ fmap properToIdent name
+ exprToCoreFn ss com _ (A.Case vs alts) =
+ Case (ss, com, Nothing) (fmap (exprToCoreFn ss [] Nothing) vs) (fmap (altToCoreFn ss) alts)
exprToCoreFn ss com _ (A.TypedValue _ v ty) =
exprToCoreFn ss com (Just ty) v
- exprToCoreFn ss com ty (A.Let w ds v) =
- Let (ss, com, ty, getLetMeta w) (concatMap declToCoreFn ds) (exprToCoreFn ss [] Nothing v)
- exprToCoreFn ss com ty (A.TypeClassDictionaryConstructorApp name (A.TypedValue _ lit@(A.Literal _ (A.ObjectLiteral _)) _)) =
- exprToCoreFn ss com ty (A.TypeClassDictionaryConstructorApp name lit)
- exprToCoreFn ss com _ (A.TypeClassDictionaryConstructorApp name (A.Literal _ (A.ObjectLiteral vs))) =
- let args = fmap (exprToCoreFn ss [] Nothing . snd) $ sortBy (compare `on` fst) vs
- ctor = Var (ss, [], Nothing, Just IsTypeClassConstructor) (fmap properToIdent name)
- in foldl (App (ss, com, Nothing, Nothing)) ctor args
- exprToCoreFn ss com ty (A.TypeClassDictionaryAccessor _ ident) =
- Abs (ss, com, ty, Nothing) (Ident "dict")
- (Accessor (ssAnn ss) (mkString $ runIdent ident) (Var (ssAnn ss) $ Qualified Nothing (Ident "dict")))
+ exprToCoreFn ss com _ (A.Let w ds v) =
+ Let (ss, com, getLetMeta w) (concatMap declToCoreFn ds) (exprToCoreFn ss [] Nothing v)
exprToCoreFn _ com ty (A.PositionedValue ss com1 v) =
exprToCoreFn ss (com ++ com1) ty v
exprToCoreFn _ _ _ e =
error $ "Unexpected value in exprToCoreFn mn: " ++ show e
- -- | Desugars case alternatives from AST to CoreFn representation.
+ -- Desugars case alternatives from AST to CoreFn representation.
altToCoreFn :: SourceSpan -> A.CaseAlternative -> CaseAlternative Ann
altToCoreFn ss (A.CaseAlternative bs vs) = CaseAlternative (map (binderToCoreFn ss []) bs) (go vs)
where
@@ -131,19 +160,19 @@ moduleToCoreFn env (A.Module modSS coms mn decls (Just exps)) =
guardToExpr [A.ConditionGuard cond] = cond
guardToExpr _ = internalError "Guard not correctly desugared"
- -- | Desugars case binders from AST to CoreFn representation.
+ -- Desugars case binders from AST to CoreFn representation.
binderToCoreFn :: SourceSpan -> [Comment] -> A.Binder -> Binder Ann
binderToCoreFn _ com (A.LiteralBinder ss lit) =
- LiteralBinder (ss, com, Nothing, Nothing) (fmap (binderToCoreFn ss com) lit)
+ LiteralBinder (ss, com, Nothing) (fmap (binderToCoreFn ss com) lit)
binderToCoreFn ss com A.NullBinder =
- NullBinder (ss, com, Nothing, Nothing)
+ NullBinder (ss, com, Nothing)
binderToCoreFn _ com (A.VarBinder ss name) =
- VarBinder (ss, com, Nothing, Nothing) name
+ VarBinder (ss, com, Nothing) name
binderToCoreFn _ com (A.ConstructorBinder ss dctor@(Qualified mn' _) bs) =
let (_, tctor, _, _) = lookupConstructor env dctor
- in ConstructorBinder (ss, com, Nothing, Just $ getConstructorMeta dctor) (Qualified mn' tctor) dctor (fmap (binderToCoreFn ss []) bs)
+ in ConstructorBinder (ss, com, Just $ getConstructorMeta dctor) (Qualified mn' tctor) dctor (fmap (binderToCoreFn ss []) bs)
binderToCoreFn _ com (A.NamedBinder ss name b) =
- NamedBinder (ss, com, Nothing, Nothing) name (binderToCoreFn ss [] b)
+ NamedBinder (ss, com, Nothing) name (binderToCoreFn ss [] b)
binderToCoreFn _ com (A.PositionedBinder ss com1 b) =
binderToCoreFn ss (com ++ com1) b
binderToCoreFn ss com (A.TypedBinder _ b) =
@@ -155,19 +184,19 @@ moduleToCoreFn env (A.Module modSS coms mn decls (Just exps)) =
binderToCoreFn _ _ A.ParensInBinder{} =
internalError "ParensInBinder should have been desugared before binderToCoreFn"
- -- | Gets metadata for let bindings.
+ -- Gets metadata for let bindings.
getLetMeta :: A.WhereProvenance -> Maybe Meta
getLetMeta A.FromWhere = Just IsWhere
getLetMeta A.FromLet = Nothing
- -- | Gets metadata for values.
+ -- Gets metadata for values.
getValueMeta :: Qualified Ident -> Maybe Meta
getValueMeta name =
case lookupValue env name of
Just (_, External, _) -> Just IsForeign
_ -> Nothing
- -- | Gets metadata for data constructors.
+ -- Gets metadata for data constructors.
getConstructorMeta :: Qualified (ProperName 'ConstructorName) -> Meta
getConstructorMeta ctor =
case lookupConstructor env ctor of
@@ -185,7 +214,7 @@ moduleToCoreFn env (A.Module modSS coms mn decls (Just exps)) =
typeConstructor
:: (Qualified (ProperName 'ConstructorName), (DataDeclType, ProperName 'TypeName, SourceType, [Ident]))
-> (ModuleName, ProperName 'TypeName)
- typeConstructor (Qualified (Just mn') _, (_, tyCtor, _, _)) = (mn', tyCtor)
+ typeConstructor (Qualified (ByModuleName mn') _, (_, tyCtor, _, _)) = (mn', tyCtor)
typeConstructor _ = internalError "Invalid argument to typeConstructor"
-- | Find module names from qualified references to values. This is used to
@@ -197,7 +226,7 @@ findQualModules decls =
in f `concatMap` decls
where
fqDecls :: A.Declaration -> [ModuleName]
- fqDecls (A.TypeInstanceDeclaration _ _ _ _ _ q _ _) = getQual' q
+ fqDecls (A.TypeInstanceDeclaration _ _ _ _ _ _ q _ _) = getQual' q
fqDecls (A.ValueFixityDeclaration _ _ q _) = getQual' q
fqDecls (A.TypeFixityDeclaration _ _ q _) = getQual' q
fqDecls _ = []
@@ -205,10 +234,6 @@ findQualModules decls =
fqValues :: A.Expr -> [ModuleName]
fqValues (A.Var _ q) = getQual' q
fqValues (A.Constructor _ q) = getQual' q
- -- Some instances are automatically solved and have their class dictionaries
- -- built inline instead of having a named instance defined and imported.
- -- We therefore need to import these constructors if they aren't already.
- fqValues (A.TypeClassDictionaryConstructorApp c _) = getQual' c
fqValues _ = []
fqBinders :: A.Binder -> [ModuleName]
@@ -220,7 +245,7 @@ findQualModules decls =
-- | Desugars import declarations from AST to CoreFn representation.
importToCoreFn :: A.Declaration -> Maybe (Ann, ModuleName)
-importToCoreFn (A.ImportDeclaration (ss, com) name _ _) = Just ((ss, com, Nothing, Nothing), name)
+importToCoreFn (A.ImportDeclaration (ss, com) name _ _) = Just ((ss, com, Nothing), name)
importToCoreFn _ = Nothing
-- | Desugars foreign declarations from AST to CoreFn representation.
@@ -229,27 +254,18 @@ externToCoreFn (A.ExternDeclaration _ name _) = Just name
externToCoreFn _ = Nothing
-- | Desugars export declarations references from AST to CoreFn representation.
--- CoreFn modules only export values, so all data constructors, class
--- constructor, instances and values are flattened into one list.
+-- CoreFn modules only export values, so all data constructors, instances and
+-- values are flattened into one list.
exportToCoreFn :: A.DeclarationRef -> [Ident]
exportToCoreFn (A.TypeRef _ _ (Just dctors)) = fmap properToIdent dctors
+exportToCoreFn (A.TypeRef _ _ Nothing) = []
+exportToCoreFn (A.TypeOpRef _ _) = []
exportToCoreFn (A.ValueRef _ name) = [name]
-exportToCoreFn (A.TypeClassRef _ name) = [properToIdent name]
-exportToCoreFn (A.TypeInstanceRef _ name) = [name]
-exportToCoreFn _ = []
-
--- | Makes a typeclass dictionary constructor function. The returned expression
--- is a function that accepts the superclass instances and member
--- implementations and returns a record for the instance dictionary.
-mkTypeClassConstructor :: SourceAnn -> [SourceConstraint] -> [A.Declaration] -> Expr Ann
-mkTypeClassConstructor (ss, com) [] [] = Literal (ss, com, Nothing, Just IsTypeClassConstructor) (ObjectLiteral [])
-mkTypeClassConstructor (ss, com) supers members =
- let args@(a:as) = sort $ fmap typeClassMemberName members ++ superClassDictionaryNames supers
- props = [ (mkString arg, Var (ssAnn ss) $ Qualified Nothing (Ident arg)) | arg <- args ]
- dict = Literal (ssAnn ss) (ObjectLiteral props)
- in Abs (ss, com, Nothing, Just IsTypeClassConstructor)
- (Ident a)
- (foldr (Abs (ssAnn ss) . Ident) dict as)
+exportToCoreFn (A.ValueOpRef _ _) = []
+exportToCoreFn (A.TypeClassRef _ _) = []
+exportToCoreFn (A.TypeInstanceRef _ name _) = [name]
+exportToCoreFn (A.ModuleRef _ _) = []
+exportToCoreFn (A.ReExportRef _ _ _) = []
-- | Converts a ProperName to an Ident.
properToIdent :: ProperName a -> Ident
diff --git a/src/Language/PureScript/CoreFn/Expr.hs b/src/Language/PureScript/CoreFn/Expr.hs
index 981bf37c0f..20ab333011 100644
--- a/src/Language/PureScript/CoreFn/Expr.hs
+++ b/src/Language/PureScript/CoreFn/Expr.hs
@@ -3,13 +3,13 @@
--
module Language.PureScript.CoreFn.Expr where
-import Prelude.Compat
+import Prelude
import Control.Arrow ((***))
-import Language.PureScript.AST.Literals
-import Language.PureScript.CoreFn.Binders
-import Language.PureScript.Names
+import Language.PureScript.AST.Literals (Literal)
+import Language.PureScript.CoreFn.Binders (Binder)
+import Language.PureScript.Names (Ident, ProperName, ProperNameType(..), Qualified)
import Language.PureScript.PSString (PSString)
-- |
@@ -29,9 +29,9 @@ data Expr a
--
| Accessor a PSString (Expr a)
-- |
- -- Partial record update
+ -- Partial record update (original value, fields to copy (if known), fields to update)
--
- | ObjectUpdate a (Expr a) [(PSString, Expr a)]
+ | ObjectUpdate a (Expr a) (Maybe [PSString]) [(PSString, Expr a)]
-- |
-- Function introduction
--
@@ -52,7 +52,7 @@ data Expr a
-- A let binding
--
| Let a [Bind a] (Expr a)
- deriving (Show, Functor)
+ deriving (Eq, Ord, Show, Functor)
-- |
-- A let or module binding.
@@ -65,7 +65,7 @@ data Bind a
-- |
-- Mutually recursive binding group for several values
--
- | Rec [((a, Ident), Expr a)] deriving (Show, Functor)
+ | Rec [((a, Ident), Expr a)] deriving (Eq, Ord, Show, Functor)
-- |
-- A guard is just a boolean-valued expression that appears alongside a set of binders
@@ -84,7 +84,7 @@ data CaseAlternative a = CaseAlternative
-- The result expression or a collect of guarded expressions
--
, caseAlternativeResult :: Either [(Guard a, Expr a)] (Expr a)
- } deriving (Show)
+ } deriving (Eq, Ord, Show)
instance Functor CaseAlternative where
@@ -99,7 +99,7 @@ extractAnn :: Expr a -> a
extractAnn (Literal a _) = a
extractAnn (Constructor a _ _ _) = a
extractAnn (Accessor a _ _) = a
-extractAnn (ObjectUpdate a _ _) = a
+extractAnn (ObjectUpdate a _ _ _) = a
extractAnn (Abs a _ _) = a
extractAnn (App a _ _) = a
extractAnn (Var a _) = a
@@ -111,12 +111,12 @@ extractAnn (Let a _ _) = a
-- Modify the annotation on a term
--
modifyAnn :: (a -> a) -> Expr a -> Expr a
-modifyAnn f (Literal a b) = Literal (f a) b
-modifyAnn f (Constructor a b c d) = Constructor (f a) b c d
-modifyAnn f (Accessor a b c) = Accessor (f a) b c
-modifyAnn f (ObjectUpdate a b c) = ObjectUpdate (f a) b c
-modifyAnn f (Abs a b c) = Abs (f a) b c
-modifyAnn f (App a b c) = App (f a) b c
-modifyAnn f (Var a b) = Var (f a) b
-modifyAnn f (Case a b c) = Case (f a) b c
-modifyAnn f (Let a b c) = Let (f a) b c
+modifyAnn f (Literal a b) = Literal (f a) b
+modifyAnn f (Constructor a b c d) = Constructor (f a) b c d
+modifyAnn f (Accessor a b c) = Accessor (f a) b c
+modifyAnn f (ObjectUpdate a b c d) = ObjectUpdate (f a) b c d
+modifyAnn f (Abs a b c) = Abs (f a) b c
+modifyAnn f (App a b c) = App (f a) b c
+modifyAnn f (Var a b) = Var (f a) b
+modifyAnn f (Case a b c) = Case (f a) b c
+modifyAnn f (Let a b c) = Let (f a) b c
diff --git a/src/Language/PureScript/CoreFn/FromJSON.hs b/src/Language/PureScript/CoreFn/FromJSON.hs
index 0cffaf2ec0..d0426b6f8d 100644
--- a/src/Language/PureScript/CoreFn/FromJSON.hs
+++ b/src/Language/PureScript/CoreFn/FromJSON.hs
@@ -4,24 +4,35 @@
module Language.PureScript.CoreFn.FromJSON
( moduleFromJSON
+ , parseVersion'
) where
-import Prelude.Compat
+import Prelude
-import Data.Aeson
-import Data.Aeson.Types (Parser, Value, listParser)
-import Data.Text (Text)
-import qualified Data.Text as T
-import Text.ParserCombinators.ReadP (readP_to_S)
-import qualified Data.Vector as V
-import Data.Version (Version, parseVersion)
+import Control.Applicative ((<|>))
-import Language.PureScript.AST.SourcePos (SourceSpan(SourceSpan))
-import Language.PureScript.AST.Literals
-import Language.PureScript.CoreFn.Ann
-import Language.PureScript.CoreFn
-import Language.PureScript.Names
-import Language.PureScript.PSString (PSString)
+import Data.Aeson (FromJSON(..), Object, Value(..), withObject, withText, (.:))
+import Data.Aeson.Types (Parser, listParser)
+import Data.Map.Strict qualified as M
+import Data.Text (Text)
+import Data.Text qualified as T
+import Data.Vector qualified as V
+import Data.Version (Version, parseVersion)
+
+import Language.PureScript.AST.SourcePos (SourceSpan(..))
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.CoreFn.Ann (Ann)
+import Language.PureScript.CoreFn (Bind(..), Binder(..), CaseAlternative(..), ConstructorType(..), Expr(..), Guard, Meta(..), Module(..))
+import Language.PureScript.Names (Ident(..), ModuleName(..), ProperName(..), Qualified(..), QualifiedBy(..), unusedIdent)
+import Language.PureScript.PSString (PSString)
+
+import Text.ParserCombinators.ReadP (readP_to_S)
+
+parseVersion' :: String -> Maybe Version
+parseVersion' str =
+ case filter (null . snd) $ readP_to_S parseVersion str of
+ [(vers, "")] -> Just vers
+ _ -> Nothing
constructorTypeFromJSON :: Value -> Parser ConstructorType
constructorTypeFromJSON v = do
@@ -44,6 +55,8 @@ metaFromJSON v = withObject "Meta" metaFromObj v
-> return $ Just IsTypeClassConstructor
"IsForeign" -> return $ Just IsForeign
"IsWhere" -> return $ Just IsWhere
+ "IsSyntheticApp"
+ -> return $ Just IsSyntheticApp
_ -> fail ("not recognized Meta: " ++ T.unpack type_)
isConstructorFromJSON o = do
@@ -57,7 +70,7 @@ annFromJSON modulePath = withObject "Ann" annFromObj
annFromObj o = do
ss <- o .: "sourceSpan" >>= sourceSpanFromJSON modulePath
mm <- o .: "meta" >>= metaFromJSON
- return (ss, [], Nothing, mm)
+ return (ss, [], mm)
sourceSpanFromJSON :: FilePath -> Value -> Parser SourceSpan
sourceSpanFromJSON modulePath = withObject "SourceSpan" $ \o ->
@@ -90,7 +103,9 @@ literalFromJSON t = withObject "Literal" literalFromObj
ObjectLiteral <$> recordFromJSON t val
identFromJSON :: Value -> Parser Ident
-identFromJSON = withText "Ident" (return . Ident)
+identFromJSON = withText "Ident" $ \case
+ ident | ident == unusedIdent -> pure UnusedIdent
+ | otherwise -> pure $ Ident ident
properNameFromJSON :: Value -> Parser (ProperName a)
properNameFromJSON = fmap ProperName . parseJSON
@@ -98,13 +113,19 @@ properNameFromJSON = fmap ProperName . parseJSON
qualifiedFromJSON :: (Text -> a) -> Value -> Parser (Qualified a)
qualifiedFromJSON f = withObject "Qualified" qualifiedFromObj
where
- qualifiedFromObj o = do
- mn <- o .:? "moduleName" >>= traverse moduleNameFromJSON
+ qualifiedFromObj o =
+ qualifiedByModuleFromObj o <|> qualifiedBySourcePosFromObj o
+ qualifiedByModuleFromObj o = do
+ mn <- o .: "moduleName" >>= moduleNameFromJSON
i <- o .: "identifier" >>= withText "Ident" (return . f)
- return $ Qualified mn i
+ pure $ Qualified (ByModuleName mn) i
+ qualifiedBySourcePosFromObj o = do
+ ss <- o .: "sourcePos"
+ i <- o .: "identifier" >>= withText "Ident" (return . f)
+ pure $ Qualified (BySourcePos ss) i
moduleNameFromJSON :: Value -> Parser ModuleName
-moduleNameFromJSON v = ModuleName <$> listParser properNameFromJSON v
+moduleNameFromJSON v = ModuleName . T.intercalate "." <$> listParser parseJSON v
moduleFromJSON :: Value -> Parser (Version, Module Ann)
moduleFromJSON = withObject "Module" moduleFromObj
@@ -116,6 +137,7 @@ moduleFromJSON = withObject "Module" moduleFromObj
moduleSourceSpan <- o .: "sourceSpan" >>= sourceSpanFromJSON modulePath
moduleImports <- o .: "imports" >>= listParser (importFromJSON modulePath)
moduleExports <- o .: "exports" >>= listParser identFromJSON
+ moduleReExports <- o .: "reExports" >>= reExportsFromJSON
moduleDecls <- o .: "decls" >>= listParser (bindFromJSON modulePath)
moduleForeign <- o .: "foreign" >>= listParser identFromJSON
moduleComments <- o .: "comments" >>= listParser parseJSON
@@ -123,9 +145,9 @@ moduleFromJSON = withObject "Module" moduleFromObj
versionFromJSON :: String -> Parser Version
versionFromJSON v =
- case readP_to_S parseVersion v of
- (r, _) : _ -> return r
- _ -> fail "failed parsing purs version"
+ case parseVersion' v of
+ Just r -> return r
+ Nothing -> fail "failed parsing purs version"
importFromJSON :: FilePath -> Value -> Parser (Ann, ModuleName)
importFromJSON modulePath = withObject "Import"
@@ -134,6 +156,9 @@ moduleFromJSON = withObject "Module" moduleFromObj
mn <- o .: "moduleName" >>= moduleNameFromJSON
return (ann, mn))
+ reExportsFromJSON :: Value -> Parser (M.Map ModuleName [Ident])
+ reExportsFromJSON = fmap (M.map (map Ident)) . parseJSON
+
bindFromJSON :: FilePath -> Value -> Parser (Bind Ann)
bindFromJSON modulePath = withObject "Bind" bindFromObj
where
@@ -203,8 +228,9 @@ exprFromJSON modulePath = withObject "Expr" exprFromObj
objectUpdateFromObj o = do
ann <- o .: "annotation" >>= annFromJSON modulePath
e <- o .: "expression" >>= exprFromJSON modulePath
+ copy <- o .: "copy" >>= parseJSON
us <- o .: "updates" >>= recordFromJSON (exprFromJSON modulePath)
- return $ ObjectUpdate ann e us
+ return $ ObjectUpdate ann e copy us
absFromObj o = do
ann <- o .: "annotation" >>= annFromJSON modulePath
diff --git a/src/Language/PureScript/CoreFn/Laziness.hs b/src/Language/PureScript/CoreFn/Laziness.hs
new file mode 100644
index 0000000000..9941fd41c5
--- /dev/null
+++ b/src/Language/PureScript/CoreFn/Laziness.hs
@@ -0,0 +1,568 @@
+module Language.PureScript.CoreFn.Laziness
+ ( applyLazinessTransform
+ ) where
+
+import Protolude hiding (force)
+import Protolude.Unsafe (unsafeHead)
+
+import Control.Arrow ((&&&))
+import Data.Array qualified as A
+import Data.Coerce (coerce)
+import Data.Graph (SCC(..), stronglyConnComp)
+import Data.List (foldl1', (!!))
+import Data.IntMap.Monoidal qualified as IM
+import Data.IntSet qualified as IS
+import Data.Map.Monoidal qualified as M
+import Data.Semigroup (Max(..))
+import Data.Set qualified as S
+
+import Language.PureScript.AST.SourcePos (SourcePos(..), SourceSpan(..), nullSourceSpan)
+import Language.PureScript.Constants.Libs qualified as C
+import Language.PureScript.CoreFn (Ann, Bind, Expr(..), Literal(..), Meta(..), ssAnn, traverseCoreFn)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), InternalIdentData(..), ModuleName, Qualified(..), QualifiedBy(..), runIdent, runModuleName, toMaybeModuleName)
+import Language.PureScript.PSString (mkString)
+
+-- This module is responsible for ensuring that the bindings in recursive
+-- binding groups are initialized in a valid order, introducing run-time
+-- laziness and initialization checks as necessary.
+--
+-- PureScript is a call-by-value language with strict data constructors, this
+-- transformation notwithstanding. The only laziness introduced here is in the
+-- initialization of a binding. PureScript is uninterested in the order in
+-- which bindings are written by the user. The compiler has always attempted to
+-- emit the bindings in an order that makes sense for the backend, but without
+-- this transformation, recursive bindings are emitted in an arbitrary order,
+-- which can cause unexpected behavior at run time if a binding is dereferenced
+-- before it has initialized.
+--
+-- To prevent unexpected errors, this transformation does a syntax-driven
+-- analysis of a single recursive binding group to attempt to statically order
+-- the bindings, and when that fails, falls back to lazy initializers that will
+-- succeed or fail deterministically with a clear error at run time.
+--
+-- Example:
+--
+-- x = f \_ ->
+-- x
+--
+-- becomes (with some details of the $runtime_lazy function elided):
+--
+-- -- the binding of x has been rewritten as a lazy initializer
+-- $lazy_x = $runtime_lazy \_ ->
+-- f \_ ->
+-- $lazy_x 2 -- the reference to x has been rewritten as a force call
+-- x = $lazy_x 1
+--
+-- Central to this analysis are the concepts of delay and force, which are
+-- attributes given to every subexpression in the binding group. Delay and
+-- force are defined by the following traversal. This traversal is used twice:
+-- once to collect all the references made by each binding in the group, and
+-- then again to rewrite some references to force calls. (The implications of
+-- delay and force on initialization order are specified later.)
+
+-- |
+-- Visits every `Var` in an expression with the provided function, including
+-- the amount of delay and force applied to that `Var`, and substitutes the
+-- result back into the tree (propagating an `Applicative` effect).
+--
+-- Delay is a non-negative integer that represents the number of lambdas that
+-- enclose an expression. Force is a non-negative integer that represents the
+-- number of values that are being applied to an expression. Delay is always
+-- statically determinable, but force can be *unknown*, so it's represented
+-- here with a Maybe. In a function application `f a b`, `f` has force 2, but
+-- `a` and `b` have unknown force--it depends on what `f` does with them.
+--
+-- The rules of assigning delay and force are simple:
+-- * The expressions that are assigned to bindings in this group have
+-- delay 0, force 0.
+-- * In a function application, the function expression has force 1 higher
+-- than the force of the application expression, and the argument
+-- expression has unknown force.
+-- * UNLESS this argument is being directly provided to a constructor (in
+-- other words, the function expression is either a constructor itself or
+-- a constructor that has already been partially applied), in which case
+-- the force of both subexpressions is unchanged. We can assume that
+-- constructors don't apply any additional force to their arguments.
+-- * If the force of a lambda is zero, the delay of the body of the lambda is
+-- incremented; otherwise, the force of the body of the lambda is
+-- decremented. (Applying one argument to a lambda cancels out one unit of
+-- delay.)
+-- * In the argument of a Case and the bindings of a Let, force is unknown.
+-- * Everywhere else, preserve the delay and force of the enclosing
+-- expression.
+--
+-- Here are some illustrative examples of the above rules. We will use a
+-- pseudocode syntax to annotate a subexpression with delay and force:
+-- `expr#d!f` means `expr` has delay d and force f. `!*` is used to denote
+-- unknown force.
+--
+-- x = y#0!0
+-- x = y#0!2 a#0!* b#0!*
+-- x = (\_ -> y#1!0)#0!0
+-- x = \_ _ -> y#2!1 a#2!*
+-- x = (\_ -> y#0!0)#0!1 z#0!*
+-- x = Just { a: a#0!0, b: b#0!0 }
+-- x = let foo = (y#1!* a b#1!*)#1!* in foo + 1
+--
+-- (Note that this analysis is quite ignorant of any actual control flow
+-- choices made at run time. It doesn't even track what happens to a reference
+-- after it has been locally bound by a Let or Case. Instead, it just assumes
+-- the worst--once locally bound to a new name, it imagines that absolutely
+-- anything could happen to that new name and thus to the underlying reference.
+-- But the value-to-weight ratio of this approach is perhaps surprisingly
+-- high.)
+--
+-- Every subexpression gets a delay and a force, but we are only interested
+-- in references to other bindings in the binding group, so the traversal only
+-- exposes `Var`s to the provided function.
+--
+onVarsWithDelayAndForce :: forall f. Applicative f => (Int -> Maybe Int -> Ann -> Qualified Ident -> f (Expr Ann)) -> Expr Ann -> f (Expr Ann)
+onVarsWithDelayAndForce f = snd . go 0 $ Just 0
+ where
+ go :: Int -> Maybe Int -> (Bind Ann -> f (Bind Ann), Expr Ann -> f (Expr Ann))
+ go delay force = (handleBind, handleExpr')
+ where
+ (handleBind, handleExpr, handleBinder, handleCaseAlternative) = traverseCoreFn handleBind handleExpr' handleBinder handleCaseAlternative
+ handleExpr' = \case
+ Var a i -> f delay force a i
+ Abs a i e -> Abs a i <$> snd (if force == Just 0 then go (succ delay) force else go delay $ fmap pred force) e
+ -- A clumsy hack to preserve TCO in a particular idiom of unsafePartial once seen in Data.Map.Internal, possibly still used elsewhere.
+ App a1 e1@(Var _ C.I_unsafePartial) (Abs a2 i e2) -> App a1 e1 . Abs a2 i <$> handleExpr' e2
+ App a e1 e2 ->
+ -- `handleApp` is just to handle the constructor application exception
+ -- somewhat gracefully (i.e., without requiring a deep inspection of
+ -- the function expression at every step). If we didn't care about
+ -- constructors, this could have been simply:
+ -- App a <$> snd (go delay (fmap succ force)) e1 <*> snd (go delay Nothing) e2
+ handleApp 1 [(a, e2)] e1
+ Case a vs alts -> Case a <$> traverse (snd $ go delay Nothing) vs <*> traverse handleCaseAlternative alts
+ Let a ds e -> Let a <$> traverse (fst $ go delay Nothing) ds <*> handleExpr' e
+ other -> handleExpr other
+
+ handleApp len args = \case
+ App a e1 e2 -> handleApp (len + 1) ((a, e2) : args) e1
+ Var a@(_, _, Just meta) i | isConstructorLike meta
+ -> foldl (\e1 (a2, e2) -> App a2 <$> e1 <*> handleExpr' e2) (f delay force a i) args
+ e -> foldl (\e1 (a2, e2) -> App a2 <$> e1 <*> snd (go delay Nothing) e2) (snd (go delay (fmap (+ len) force)) e) args
+ isConstructorLike = \case
+ IsConstructor{} -> True
+ IsNewtype -> True
+ _ -> False
+
+-- Once we assign a delay and force value to every `Var` in the binding group,
+-- we can consider how to order the bindings to allow them all to successfully
+-- initialize. There is one principle here: each binding must be initialized
+-- before the identifier being bound is ready for use. If the preorder thus
+-- induced has cycles, those cycles need to be resolved with laziness. All of
+-- the details concern what "ready for use" means.
+--
+-- The definition of delay and force suggests that "ready for use" depends on
+-- those attributes. If a lambda is bound to the name x, then the references in
+-- the lambda don't need to be initialized before x is initialized. This is
+-- represented by the fact that those references have non-zero delay. But if
+-- the expression bound to x is instead the application of a function y that is
+-- also bound in this binding group, then not only does y need to be
+-- initialized before x, so do some of the non-zero delay references in y. This
+-- is represented by the fact that the occurrence of y in the expression bound
+-- to x has non-zero force.
+--
+-- An example, reusing the pseudocode annotations defined above:
+--
+-- x _ = y#1!0
+-- y = x#0!1 a
+--
+-- y doesn't need to be initialized before x is, because the reference to y in
+-- x's initializer has delay 1. But y does need to be initialized before x is
+-- ready for use with force 1, because force 1 is enough to overcome the delay
+-- of that reference. And since y has a delay-0 reference to x with force 1, y
+-- will need to be ready for use before it is initialized; thus, y needs to be
+-- made lazy.
+--
+-- So just as function applications "cancel out" lambdas, a known applied force
+-- cancels out an equal amount of delay, causing some references that may not
+-- have been needed earlier to enter play. (And to be safe, we must assume that
+-- unknown force cancels out *any* amount of delay.) There is another, subtler
+-- aspect of this: if there are not enough lambdas to absorb every argument
+-- applied to a function, those arguments will end up applied to the result of
+-- the function. Likewise, if there is excess force left over after some of it
+-- has been canceled by delay, that excess is carried to the references
+-- activated. (Again, an unknown amount of force must be assumed to lead to an
+-- unknown amount of excess force.)
+--
+-- Another example:
+--
+-- f = g#0!2 a b
+-- g x = h#1!2 c x
+-- h _ _ _ = f#3!0
+--
+-- Initializing f will lead to an infinite loop in this example. f invokes g
+-- with two arguments. g absorbs one argument, and the second ends up being
+-- applied to the result of h c x, resulting in h being invoked with three
+-- arguments. Invoking h with three arguments results in dereferencing f, which
+-- is not yet ready. To capture this loop in our analysis, we say that making
+-- f ready for use with force 0 requires making g ready for use with force 2,
+-- which requires making h ready for use with force 3 (two units of force from
+-- the lexical position of h, plus one unit of excess force carried forward),
+-- which cyclically requires f to be ready for use with force 0.
+--
+-- These preceding observations are captured and generalized by the following
+-- rules:
+--
+-- USE-INIT: Before a reference to x is ready for use with any force, x must
+-- be initialized.
+--
+-- We will make x lazy iff this rule induces a cycle--i.e., initializing x
+-- requires x to be ready for use first.
+--
+-- USE-USE: Before a reference to x is ready for use with force f:
+-- * if a reference in the initializer of x has delay d and force f',
+-- * and either d <= f or f is unknown,
+-- * then that reference must itself be ready for use with
+-- force f – d + f' (or with unknown force if f or f' is unknown).
+--
+-- USE-IMMEDIATE: Initializing a binding x is equivalent to requiring a
+-- reference to x to be ready for use with force 0, per USE-USE.
+--
+-- Equivalently: before x is initialized, any reference in the initializer
+-- of x with delay 0 and force f must be ready for use with force f.
+--
+-- Examples:
+--
+-- Assume x is bound in a recursive binding group with the below bindings.
+--
+-- All of the following initializers require x to be ready for use with some
+-- amount of force, and therefore require x to be initialized first.
+--
+-- a = x#0!0
+-- b = (\_ -> x#0!0) 1
+-- c = foo x#0!*
+-- d = (\_ -> foo x#0!*) 1
+--
+-- In the following initializers, before p can be initialized, x must be
+-- ready for use with force f – d + f'. (And both x and q must be
+-- initialized, of course; but x being ready for use with that force may
+-- induce additional constraints.)
+--
+-- p = ... q#0!f ...
+-- q = ... x#d!f' ... (where d <= f)
+--
+-- Excess force stacks, of course: in the following initializers, before r
+-- can be initialized, x must be ready for use with force
+-- f — d + f' — d' + f'':
+--
+-- r = ... s#0!f ...
+-- s = ... t#d!f' ... (where d <= f)
+-- t = ... x#d'!f'' ... (where d' <= f – d + f')
+--
+--
+-- To satisfy these rules, we will construct a graph between (identifier,
+-- delay) pairs, with edges induced by the USE-USE rule, and effectively run a
+-- topsort to get the initialization preorder. For this part, it's simplest to
+-- think of delay as an element of the naturals extended with a positive
+-- infinity, corresponding to an unknown amount of force. (We'll do arithmetic
+-- on these extended naturals as you would naively expect; we won't do anything
+-- suspect like subtracting infinity from infinity.) With that in mind, we can
+-- construct the graph as follows: for each reference from i1 to i2 with delay
+-- d and force f, draw an infinite family of edges from (i1, d + n) to (i2, f +
+-- n) for all 0 <= n <= ∞, where n represents the excess force carried over
+-- from a previous edge. Unfortunately, as an infinite graph, we can't expect
+-- the tools in Data.Graph to help us traverse it; we will have to be a little
+-- bit clever.
+--
+-- The following data types and functions are for searching this infinite graph
+-- and carving from it a finite amount of data to work with. Specifically, we
+-- want to know for each identifier i, which other identifiers are
+-- irreflexively reachable from (i, 0) (and thus must be initialized before i
+-- is), and with what maximum force (in the event of a loop, not every
+-- reference to i in the reachable identifier needs to be rewritten to a force
+-- call; only the ones with delay up to the maximum force used during i's
+-- initialization). We also want the option of aborting a given reachability
+-- search, for one of two reasons.
+--
+-- * If we encounter a reference with unknown force, abort.
+-- * If we encounter a cycle where force on a single identifier is
+-- increasing, abort. (Because of USE-USE, as soon as an identifier is
+-- revisited with greater force than its first visit, the difference is
+-- carried forward as excess, so it is possible to retrace that path to get
+-- an arbitrarily high amount of force.)
+--
+-- Both reasons mean that it is theoretically possible for the identifier in
+-- question to need every other identifier in the binding group to be
+-- initialized before it is. (Every identifier in a recursive binding group is
+-- necessarily reachable from every other, ignoring delay and force, which is
+-- what arbitrarily high force lets you do.)
+--
+-- In order to reuse parts of this reachability computation across identifiers,
+-- we are going to represent it with a rose tree data structure interleaved with
+-- a monad capturing the abort semantics. (The monad is Maybe, but we don't
+-- need to know that here!)
+
+type MaxRoseTree m a = m (IM.MonoidalIntMap (MaxRoseNode m a))
+data MaxRoseNode m a = MaxRoseNode a (MaxRoseTree m a)
+
+-- Dissecting this data structure:
+--
+-- m (...)
+-- ^ represents whether to abort or continue the search
+--
+-- IM.MonoidalIntMap (...)
+-- ^ the keys of this map are other identifiers reachable from the current
+-- one (we'll map the identifiers in this binding group to Ints for ease of
+-- computation)
+--
+-- the values of this map are:
+--
+-- MaxRoseNode a (...)
+-- ^ this will store the force applied to the next identifier
+-- (MaxRoseTree m a)
+-- ^ and this, the tree of identifiers reachable from there
+--
+-- We're only interested in continuing down the search path that applies the
+-- most force to a given identifier! So when we combine two MaxRoseTrees,
+-- we want to resolve any key collisions in their MonoidalIntMaps with this
+-- semigroup:
+
+instance Ord a => Semigroup (MaxRoseNode m a) where
+ l@(MaxRoseNode l1 _) <> r@(MaxRoseNode r1 _) = if r1 > l1 then r else l
+
+-- And that's why this is called a MaxRoseTree.
+--
+-- Traversing this tree to get a single MonoidalIntMap with the entire closure
+-- plus force information is fairly straightforward:
+
+mrtFlatten :: (Monad m, Ord a) => MaxRoseTree m a -> m (IM.MonoidalIntMap (Max a))
+mrtFlatten = (getAp . IM.foldMapWithKey (\i (MaxRoseNode a inner) -> Ap $ (IM.singleton i (Max a) <>) <$> mrtFlatten inner) =<<)
+
+-- The use of the `Ap` monoid ensures that if any child of this tree aborts,
+-- the entire tree aborts.
+--
+-- One might ask, why interleave the abort monad with the tree at all if we're
+-- just going to flatten it out at the end? The point is to flatten it out at
+-- the end, but *not* during the generation of the tree. Attempting to flatten
+-- the tree as we generate it can result in an infinite loop, because a subtree
+-- needs to be exhaustively searched for abort conditions before it can be used
+-- in another tree. With this approach, we can use lazy trees as building
+-- blocks and, as long as they get rewritten to be finite or have aborts before
+-- they're flattened, the analysis still terminates.
+
+-- |
+-- Given a maximum index and a function that returns a map of edges to next
+-- indices, returns an array for each index up to maxIndex of maps from the
+-- indices reachable from the current index, to the maximum force applied to
+-- those indices.
+searchReachable
+ :: forall m force
+ . (Alternative m, Monad m, Enum force, Ord force)
+ => Int
+ -> ((Int, force) -> m (IM.MonoidalIntMap (Max force)))
+ -> A.Array Int (m (IM.MonoidalIntMap (Max force)))
+searchReachable maxIdx lookupEdges = mrtFlatten . unsafeHead <$> mem
+ where
+ -- This is a finite array of infinite lists, used to memoize all the search
+ -- trees. `unsafeHead` is used above to pull the first tree out of each list
+ -- in the array--the one corresponding to zero force, which is what's needed
+ -- to initialize the corresponding identifier. (`unsafeHead` is safe here, of
+ -- course: infinite lists.)
+ mem :: A.Array Int [MaxRoseTree m force]
+ mem = A.listArray (0, maxIdx)
+ [ [cutLoops <*> fmap (IM.mapWithKey memoizedNode) . lookupEdges $ (i, f) | f <- [toEnum 0..]]
+ | i <- [0..maxIdx]
+ ]
+
+ memoizedNode :: Int -> Max force -> MaxRoseNode m force
+ memoizedNode i (Max force) = MaxRoseNode force $ mem A.! i !! fromEnum force
+
+ -- And this is the function that prevents the search from actually being
+ -- infinite. It applies a filter to a `MaxRoseTree` at every level, looking for
+ -- indices anywhere in the tree that match the current vertex. If a match is
+ -- found with greater force than the current force, that part of the tree is
+ -- rewritten to abort; otherwise, that part of the tree is rewritten to be
+ -- empty (there's nothing new in that part of the search).
+ --
+ -- A new version of `cutLoops` is applied for each node in the search, so
+ -- each edge in a search path will add another filter on a new index. Since
+ -- there are a finite number of indices in our universe, this guarantees that
+ -- the analysis terminates, because no single search path can have length
+ -- greater than `maxIdx`.
+ cutLoops :: (Int, force) -> MaxRoseTree m force -> MaxRoseTree m force
+ cutLoops (i, force) = go
+ where
+ go = (=<<) . IM.traverseWithKey $ \i' (MaxRoseNode force' inner) ->
+ MaxRoseNode force' <$> if i == i' then guard (force >= force') $> pure IM.empty else pure $ go inner
+
+-- One last data structure to define and then it's on to the main event.
+--
+-- The laziness transform effectively takes a list of eager bindings (x = ...)
+-- and splits some of them into lazy definitions ($lazy_x = ...) and lazy
+-- bindings (x = $lazy_x ...). It's convenient to work with these three
+-- declarations as the following sum type:
+
+data RecursiveGroupItem e = EagerBinding Ann e | LazyDefinition e | LazyBinding Ann
+ deriving Functor
+
+-- |
+-- Transform a recursive binding group, reordering the bindings within when a
+-- correct initialization order can be statically determined, and rewriting
+-- bindings and references to be lazy otherwise.
+--
+applyLazinessTransform :: ModuleName -> [((Ann, Ident), Expr Ann)] -> ([((Ann, Ident), Expr Ann)], Any)
+applyLazinessTransform mn rawItems = let
+
+ -- Establish the mapping from names to ints.
+ rawItemsByName :: M.MonoidalMap Ident (Ann, Expr Ann)
+ rawItemsByName = M.fromList $ (snd . fst &&& first fst) <$> rawItems
+
+ maxIdx = M.size rawItemsByName - 1
+
+ rawItemsByIndex :: A.Array Int (Ann, Expr Ann)
+ rawItemsByIndex = A.listArray (0, maxIdx) $ M.elems rawItemsByName
+
+ names :: S.Set Ident
+ names = M.keysSet rawItemsByName
+
+ -- Now do the first delay/force traversal of all the bindings to find
+ -- references to other names in this binding group.
+ --
+ -- The parts of this type mean:
+ -- D is the maximum force (or Nothing if unknown) with which the identifier C
+ -- is referenced in any delay-B position inside the expression A.
+ --
+ -- where A, B, C, and D are as below:
+ -- A B (keys) C (keys) D
+ findReferences :: Expr Ann -> IM.MonoidalIntMap (IM.MonoidalIntMap (Ap Maybe (Max Int)))
+ findReferences = (getConst .) . onVarsWithDelayAndForce $ \delay force _ -> \case
+ Qualified qb ident | all (== mn) (toMaybeModuleName qb), Just i <- ident `S.lookupIndex` names
+ -> Const . IM.singleton delay . IM.singleton i $ coerceForce force
+ _ -> Const IM.empty
+
+ -- The parts of this type mean:
+ -- D is the maximum force (or Nothing if unknown) with which the identifier C
+ -- is referenced in any delay-B position inside the binding of identifier A.
+ --
+ -- where A, B, C, and D are as below:
+ -- A B (keys) C (keys) D
+ refsByIndex :: A.Array Int (IM.MonoidalIntMap (IM.MonoidalIntMap (Ap Maybe (Max Int))))
+ refsByIndex = findReferences . snd <$> rawItemsByIndex
+
+ -- Using the approach explained above, traverse the reference graph generated
+ -- by `refsByIndex` and find all reachable names.
+ --
+ -- The parts of this type mean:
+ -- D is the maximum force with which the identifier C is referenced,
+ -- directly or indirectly, during the initialization of identifier A. B is
+ -- Nothing if the analysis of A was inconclusive and A might need the entire
+ -- binding group.
+ --
+ -- where A, B, C, and D are as below:
+ -- A B C (keys) D
+ reachablesByIndex :: A.Array Int (Maybe (IM.MonoidalIntMap (Max Int)))
+ reachablesByIndex = searchReachable maxIdx $ \(i, force) ->
+ getAp . flip IM.foldMapWithKey (dropKeysAbove force $ refsByIndex A.! i) $ \delay ->
+ IM.foldMapWithKey $ \i' force' ->
+ Ap $ IM.singleton i' . Max . (force - delay +) <$> uncoerceForce force'
+
+ -- If `reachablesByIndex` is a sort of labeled relation, this function
+ -- produces part of the reverse relation, but only for the edges from the
+ -- given vertex.
+ --
+ -- The parts of this type mean:
+ -- The identifier A is reachable from the identifier B with maximum force C
+ -- (B is also the index provided to the function).
+ --
+ -- where A, B, and C are as below:
+ -- (B) A B (singleton key) C
+ reverseReachablesFor :: Int -> IM.MonoidalIntMap (IM.MonoidalIntMap (Ap Maybe (Max Int)))
+ reverseReachablesFor i = case reachablesByIndex A.! i of
+ Nothing -> IM.fromAscList $ (, IM.singleton i $ Ap Nothing) <$> [0..maxIdx]
+ Just im -> IM.singleton i . Ap . Just <$> im
+
+ -- We can use `reachablesByIndex` to build a finite graph and topsort it;
+ -- in the process, we'll pack the nodes of the graph with data we'll want
+ -- next. Remember that if our reachability computation aborted, we have to
+ -- assume that every other identifier is reachable from that one--hence the
+ -- `maybe [0..maxIdx]`.
+ sccs = stronglyConnComp $ do
+ (i, mbReachable) <- A.assocs reachablesByIndex
+ pure ((reverseReachablesFor i, (S.elemAt i names, rawItemsByIndex A.! i)), i, maybe [0..maxIdx] (IS.toList . IM.keysSet) mbReachable)
+
+ (replacements, items) = flip foldMap sccs $ \case
+ -- The easy case: this binding doesn't need to be made lazy after all!
+ AcyclicSCC (_, (ident, (a, e))) -> pure [(ident, EagerBinding a e)]
+ -- The tough case: we have a loop.
+ -- We need to do two things here:
+ -- * Collect the reversed reachables relation for each vertex in this
+ -- loop; we'll use this to replace references with force calls
+ -- * Copy the vertex list into two lists: a list of lazy definitions and
+ -- a list of lazy bindings
+ -- Both of these results are monoidal, so the outer `foldMap` will
+ -- concatenate them pairwise.
+ CyclicSCC vertices -> (foldMap fst vertices, map (fmap (LazyDefinition . snd) . snd) vertices ++ map (fmap (LazyBinding . fst) . snd) vertices)
+
+ -- We have `replacements` expressed in terms of indices; we want to map it
+ -- back to names before traversing the bindings again.
+ replacementsByName :: M.MonoidalMap Ident (M.MonoidalMap Ident (Ap Maybe (Max Int)))
+ replacementsByName = M.fromAscList . map (bimap (flip S.elemAt names) (M.fromAscList . map (first (flip S.elemAt names)) . IM.toAscList)) . IM.toAscList $ replacements
+
+ -- And finally, this is the second delay/force traversal where we take
+ -- `replacementsByName` and use it to rewrite references with force calls,
+ -- but only if the delay of those references is at most the maximum amount
+ -- of force used by the initialization of the referenced binding to
+ -- reference the outer binding. A reference made with a higher delay than
+ -- that can safely continue to use the original reference, since it won't be
+ -- needed until after the referenced binding is done initializing.
+ replaceReferencesWithForceCall :: (Ident, RecursiveGroupItem (Expr Ann)) -> (Ident, RecursiveGroupItem (Expr Ann))
+ replaceReferencesWithForceCall pair@(ident, item) = case ident `M.lookup` replacementsByName of
+ Nothing -> pair
+ Just m -> let
+ rewriteExpr = (runIdentity .) . onVarsWithDelayAndForce $ \delay _ ann -> pure . \case
+ Qualified qb ident' | all (== mn) (toMaybeModuleName qb), any (all (>= Max delay) . getAp) $ ident' `M.lookup` m
+ -> makeForceCall ann ident'
+ q -> Var ann q
+ in (ident, rewriteExpr <$> item)
+
+ -- All that's left to do is run the above replacement on every item,
+ -- translate items from our `RecursiveGroupItem` representation back into the
+ -- form CoreFn expects, and inform the caller whether we made any laziness
+ -- transformations after all. (That last bit of information is used to
+ -- determine if the runtime factory function needs to be injected.)
+ in (uncurry fromRGI . replaceReferencesWithForceCall <$> items, Any . not $ IM.null replacements)
+
+ where
+
+ nullAnn = ssAnn nullSourceSpan
+ runtimeLazy = Var nullAnn . Qualified ByNullSourcePos $ InternalIdent RuntimeLazyFactory
+ runFn3 = Var nullAnn . Qualified (ByModuleName C.M_Data_Function_Uncurried) . Ident $ C.S_runFn <> "3"
+ strLit = Literal nullAnn . StringLiteral . mkString
+
+ lazifyIdent = \case
+ Ident txt -> InternalIdent $ Lazy txt
+ _ -> internalError "Unexpected argument to lazifyIdent"
+
+ makeForceCall :: Ann -> Ident -> Expr Ann
+ makeForceCall (ss, _, _) ident
+ -- We expect the functions produced by `runtimeLazy` to accept one
+ -- argument: the line number on which this reference is made. The runtime
+ -- code uses this number to generate a message that identifies where the
+ -- evaluation looped.
+ = App nullAnn (Var nullAnn . Qualified ByNullSourcePos $ lazifyIdent ident)
+ . Literal nullAnn . NumericLiteral . Left . toInteger . sourcePosLine
+ $ spanStart ss
+
+ fromRGI :: Ident -> RecursiveGroupItem (Expr Ann) -> ((Ann, Ident), Expr Ann)
+ fromRGI i = \case
+ EagerBinding a e -> ((a, i), e)
+ -- We expect the `runtimeLazy` factory to accept three arguments: the
+ -- identifier being initialized, the name of the module, and of course a
+ -- thunk that actually contains the initialization code.
+ LazyDefinition e -> ((nullAnn, lazifyIdent i), foldl1' (App nullAnn) [runFn3, runtimeLazy, strLit $ runIdent i, strLit $ runModuleName mn, Abs nullAnn UnusedIdent e])
+ LazyBinding a -> ((a, i), makeForceCall a i)
+
+ dropKeysAbove :: Int -> IM.MonoidalIntMap a -> IM.MonoidalIntMap a
+ dropKeysAbove n = fst . IM.split (n + 1)
+
+ coerceForce :: Maybe Int -> Ap Maybe (Max Int)
+ coerceForce = coerce
+
+ uncoerceForce :: Ap Maybe (Max Int) -> Maybe Int
+ uncoerceForce = coerce
diff --git a/src/Language/PureScript/CoreFn/Meta.hs b/src/Language/PureScript/CoreFn/Meta.hs
index 9a843473bb..0baddca29b 100644
--- a/src/Language/PureScript/CoreFn/Meta.hs
+++ b/src/Language/PureScript/CoreFn/Meta.hs
@@ -3,9 +3,9 @@
--
module Language.PureScript.CoreFn.Meta where
-import Prelude.Compat
+import Prelude
-import Language.PureScript.Names
+import Language.PureScript.Names (Ident)
-- |
-- Metadata annotations
@@ -31,6 +31,10 @@ data Meta
-- The contained value is a where clause
--
| IsWhere
+ -- |
+ -- The contained function application was synthesized by the compiler
+ --
+ | IsSyntheticApp
deriving (Show, Eq, Ord)
-- |
@@ -38,10 +42,10 @@ data Meta
--
data ConstructorType
-- |
- -- The constructor is for a type with a single construcor
+ -- The constructor is for a type with a single constructor
--
= ProductType
-- |
- -- The constructor is for a type with multiple construcors
+ -- The constructor is for a type with multiple constructors
--
| SumType deriving (Show, Eq, Ord)
diff --git a/src/Language/PureScript/CoreFn/Module.hs b/src/Language/PureScript/CoreFn/Module.hs
index 76559af759..09f5189c4a 100644
--- a/src/Language/PureScript/CoreFn/Module.hs
+++ b/src/Language/PureScript/CoreFn/Module.hs
@@ -1,18 +1,17 @@
module Language.PureScript.CoreFn.Module where
-import Prelude.Compat
+import Prelude
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Comments
-import Language.PureScript.CoreFn.Expr
-import Language.PureScript.Names
+import Data.Map.Strict (Map)
+
+import Language.PureScript.AST.SourcePos (SourceSpan)
+import Language.PureScript.Comments (Comment)
+import Language.PureScript.CoreFn.Expr (Bind)
+import Language.PureScript.Names (Ident, ModuleName)
-- |
-- The CoreFn module representation
--
--- The json CoreFn representation does not contain type information. When
--- parsing it one gets back `ModuleT () Ann` rathern than `ModuleT Type Ann`,
--- which is enough for `moduleToJs`.
data Module a = Module
{ moduleSourceSpan :: SourceSpan
, moduleComments :: [Comment]
@@ -20,6 +19,7 @@ data Module a = Module
, modulePath :: FilePath
, moduleImports :: [(a, ModuleName)]
, moduleExports :: [Ident]
+ , moduleReExports :: Map ModuleName [Ident]
, moduleForeign :: [Ident]
, moduleDecls :: [Bind a]
- } deriving (Show)
+ } deriving (Functor, Show)
diff --git a/src/Language/PureScript/CoreFn/Optimizer.hs b/src/Language/PureScript/CoreFn/Optimizer.hs
index 44567022d4..722893c439 100644
--- a/src/Language/PureScript/CoreFn/Optimizer.hs
+++ b/src/Language/PureScript/CoreFn/Optimizer.hs
@@ -1,56 +1,31 @@
module Language.PureScript.CoreFn.Optimizer (optimizeCoreFn) where
-import Protolude hiding (Type)
+import Protolude hiding (Type, moduleName)
-import Data.List (lookup)
-import Language.PureScript.AST.Literals
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.CoreFn.Ann
-import Language.PureScript.CoreFn.Expr
-import Language.PureScript.CoreFn.Module
-import Language.PureScript.CoreFn.Traversals
-import Language.PureScript.Names (Ident(UnusedIdent), Qualified(Qualified))
-import Language.PureScript.Label
-import Language.PureScript.Types
-import qualified Language.PureScript.Constants as C
+import Control.Monad.Supply (Supply)
+import Language.PureScript.CoreFn.Ann (Ann)
+import Language.PureScript.CoreFn.CSE (optimizeCommonSubexpressions)
+import Language.PureScript.CoreFn.Expr (Bind, Expr(..))
+import Language.PureScript.CoreFn.Module (Module(..))
+import Language.PureScript.CoreFn.Traversals (everywhereOnValues)
+import Language.PureScript.Constants.Libs qualified as C
-- |
-- CoreFn optimization pass.
--
-optimizeCoreFn :: Module Ann -> Module Ann
-optimizeCoreFn m = m {moduleDecls = optimizeModuleDecls $ moduleDecls m}
+optimizeCoreFn :: Module Ann -> Supply (Module Ann)
+optimizeCoreFn m = fmap (\md -> m {moduleDecls = md}) . optimizeCommonSubexpressions (moduleName m) . optimizeModuleDecls $ moduleDecls m
optimizeModuleDecls :: [Bind Ann] -> [Bind Ann]
optimizeModuleDecls = map transformBinds
where
(transformBinds, _, _) = everywhereOnValues identity transformExprs identity
- transformExprs = optimizeUnusedPartialFn . optimizeClosedRecordUpdate
+ transformExprs
+ = optimizeDataFunctionApply
-optimizeClosedRecordUpdate :: Expr Ann -> Expr Ann
-optimizeClosedRecordUpdate ou@(ObjectUpdate a@(_, _, Just t, _) r updatedFields) =
- case closedRecordFields t of
- Nothing -> ou
- Just allFields -> Literal a (ObjectLiteral (map f allFields))
- where f (Label l) = case lookup l updatedFields of
- Nothing -> (l, Accessor (nullSourceSpan, [], Nothing, Nothing) l r)
- Just e -> (l, e)
-optimizeClosedRecordUpdate e = e
-
--- | Return the labels of a closed record, or Nothing for other types or open records.
-closedRecordFields :: Type a -> Maybe [Label]
-closedRecordFields (TypeApp _ (TypeConstructor _ C.Record) row) =
- collect row
- where
- collect :: Type a -> Maybe [Label]
- collect (REmpty _) = Just []
- collect (RCons _ l _ r) = collect r >>= return . (l :)
- collect _ = Nothing
-closedRecordFields _ = Nothing
-
--- | See https://github.com/purescript/purescript/issues/3157
-optimizeUnusedPartialFn :: Expr a -> Expr a
-optimizeUnusedPartialFn (Let _
- [NonRec _ UnusedIdent _]
- (App _ (App _ (Var _ (Qualified _ UnusedIdent)) _) originalCoreFn)) =
- originalCoreFn
-optimizeUnusedPartialFn e = e
+optimizeDataFunctionApply :: Expr a -> Expr a
+optimizeDataFunctionApply e = case e of
+ (App a (App _ (Var _ fn) x) y)
+ | C.I_functionApply <- fn -> App a x y
+ | C.I_functionApplyFlipped <- fn -> App a y x
+ _ -> e
diff --git a/src/Language/PureScript/CoreFn/ToJSON.hs b/src/Language/PureScript/CoreFn/ToJSON.hs
index 75e2d56db9..1b20ac4e65 100644
--- a/src/Language/PureScript/CoreFn/ToJSON.hs
+++ b/src/Language/PureScript/CoreFn/ToJSON.hs
@@ -7,84 +7,92 @@ module Language.PureScript.CoreFn.ToJSON
( moduleToJSON
) where
-import Prelude.Compat
-
-import Control.Arrow ((***))
-import Data.Either (isLeft)
-import Data.Maybe (maybe)
-import Data.Aeson
-import Data.Version (Version, showVersion)
-import Data.Text (Text)
-import qualified Data.Text as T
-
-import Language.PureScript.AST.Literals
-import Language.PureScript.AST.SourcePos (SourceSpan(SourceSpan))
-import Language.PureScript.CoreFn
-import Language.PureScript.Names
-import Language.PureScript.PSString (PSString)
+import Prelude
+
+import Control.Arrow ((***))
+import Data.Either (isLeft)
+import Data.Map.Strict qualified as M
+import Data.Aeson (ToJSON(..), Value(..), object)
+import Data.Aeson qualified
+import Data.Aeson.Key qualified
+import Data.Aeson.Types (Pair)
+import Data.Version (Version, showVersion)
+import Data.Text (Text)
+import Data.Text qualified as T
+
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.AST.SourcePos (SourceSpan(..))
+import Language.PureScript.CoreFn (Ann, Bind(..), Binder(..), CaseAlternative(..), ConstructorType(..), Expr(..), Meta(..), Module(..))
+import Language.PureScript.Names (Ident, ModuleName(..), ProperName(..), Qualified(..), QualifiedBy(..), runIdent)
+import Language.PureScript.PSString (PSString)
constructorTypeToJSON :: ConstructorType -> Value
constructorTypeToJSON ProductType = toJSON "ProductType"
constructorTypeToJSON SumType = toJSON "SumType"
+infixr 8 .=
+(.=) :: ToJSON a => String -> a -> Pair
+key .= value = Data.Aeson.Key.fromString key Data.Aeson..= value
+
metaToJSON :: Meta -> Value
metaToJSON (IsConstructor t is)
= object
- [ T.pack "metaType" .= "IsConstructor"
- , T.pack "constructorType" .= constructorTypeToJSON t
- , T.pack "identifiers" .= identToJSON `map` is
+ [ "metaType" .= "IsConstructor"
+ , "constructorType" .= constructorTypeToJSON t
+ , "identifiers" .= identToJSON `map` is
]
-metaToJSON IsNewtype = object [ T.pack "metaType" .= "IsNewtype" ]
-metaToJSON IsTypeClassConstructor = object [ T.pack "metaType" .= "IsTypeClassConstructor" ]
-metaToJSON IsForeign = object [ T.pack "metaType" .= "IsForeign" ]
-metaToJSON IsWhere = object [ T.pack "metaType" .= "IsWhere" ]
+metaToJSON IsNewtype = object [ "metaType" .= "IsNewtype" ]
+metaToJSON IsTypeClassConstructor = object [ "metaType" .= "IsTypeClassConstructor" ]
+metaToJSON IsForeign = object [ "metaType" .= "IsForeign" ]
+metaToJSON IsWhere = object [ "metaType" .= "IsWhere" ]
+metaToJSON IsSyntheticApp = object [ "metaType" .= "IsSyntheticApp" ]
sourceSpanToJSON :: SourceSpan -> Value
sourceSpanToJSON (SourceSpan _ spanStart spanEnd) =
- object [ T.pack "start" .= spanStart
- , T.pack "end" .= spanEnd
+ object [ "start" .= spanStart
+ , "end" .= spanEnd
]
annToJSON :: Ann -> Value
-annToJSON (ss, _, _, m) = object [ T.pack "sourceSpan" .= sourceSpanToJSON ss
- , T.pack "meta" .= maybe Null metaToJSON m
- ]
+annToJSON (ss, _, m) = object [ "sourceSpan" .= sourceSpanToJSON ss
+ , "meta" .= maybe Null metaToJSON m
+ ]
literalToJSON :: (a -> Value) -> Literal a -> Value
literalToJSON _ (NumericLiteral (Left n))
= object
- [ T.pack "literalType" .= "IntLiteral"
- , T.pack "value" .= n
+ [ "literalType" .= "IntLiteral"
+ , "value" .= n
]
literalToJSON _ (NumericLiteral (Right n))
= object
- [ T.pack "literalType" .= "NumberLiteral"
- , T.pack "value" .= n
+ [ "literalType" .= "NumberLiteral"
+ , "value" .= n
]
literalToJSON _ (StringLiteral s)
= object
- [ T.pack "literalType" .= "StringLiteral"
- , T.pack "value" .= s
+ [ "literalType" .= "StringLiteral"
+ , "value" .= s
]
literalToJSON _ (CharLiteral c)
= object
- [ T.pack "literalType" .= "CharLiteral"
- , T.pack "value" .= c
+ [ "literalType" .= "CharLiteral"
+ , "value" .= c
]
literalToJSON _ (BooleanLiteral b)
= object
- [ T.pack "literalType" .= "BooleanLiteral"
- , T.pack "value" .= b
+ [ "literalType" .= "BooleanLiteral"
+ , "value" .= b
]
literalToJSON t (ArrayLiteral xs)
= object
- [ T.pack "literalType" .= "ArrayLiteral"
- , T.pack "value" .= map t xs
+ [ "literalType" .= "ArrayLiteral"
+ , "value" .= map t xs
]
literalToJSON t (ObjectLiteral xs)
= object
- [ T.pack "literalType" .= "ObjectLiteral"
- , T.pack "value" .= recordToJSON t xs
+ [ "literalType" .= "ObjectLiteral"
+ , "value" .= recordToJSON t xs
]
identToJSON :: Ident -> Value
@@ -94,49 +102,59 @@ properNameToJSON :: ProperName a -> Value
properNameToJSON = toJSON . runProperName
qualifiedToJSON :: (a -> Text) -> Qualified a -> Value
-qualifiedToJSON f (Qualified mn a) = object
- [ T.pack "moduleName" .= maybe Null moduleNameToJSON mn
- , T.pack "identifier" .= toJSON (f a)
- ]
+qualifiedToJSON f (Qualified qb a) =
+ case qb of
+ ByModuleName mn -> object
+ [ "moduleName" .= moduleNameToJSON mn
+ , "identifier" .= toJSON (f a)
+ ]
+ BySourcePos ss -> object
+ [ "sourcePos" .= toJSON ss
+ , "identifier" .= toJSON (f a)
+ ]
moduleNameToJSON :: ModuleName -> Value
-moduleNameToJSON (ModuleName pns) = toJSON $ properNameToJSON `map` pns
+moduleNameToJSON (ModuleName name) = toJSON (T.splitOn (T.pack ".") name)
moduleToJSON :: Version -> Module Ann -> Value
moduleToJSON v m = object
- [ T.pack "sourceSpan" .= sourceSpanToJSON (moduleSourceSpan m)
- , T.pack "moduleName" .= moduleNameToJSON (moduleName m)
- , T.pack "modulePath" .= toJSON (modulePath m)
- , T.pack "imports" .= map importToJSON (moduleImports m)
- , T.pack "exports" .= map identToJSON (moduleExports m)
- , T.pack "foreign" .= map identToJSON (moduleForeign m)
- , T.pack "decls" .= map bindToJSON (moduleDecls m)
- , T.pack "builtWith" .= toJSON (showVersion v)
- , T.pack "comments" .= map toJSON (moduleComments m)
+ [ "sourceSpan" .= sourceSpanToJSON (moduleSourceSpan m)
+ , "moduleName" .= moduleNameToJSON (moduleName m)
+ , "modulePath" .= toJSON (modulePath m)
+ , "imports" .= map importToJSON (moduleImports m)
+ , "exports" .= map identToJSON (moduleExports m)
+ , "reExports" .= reExportsToJSON (moduleReExports m)
+ , "foreign" .= map identToJSON (moduleForeign m)
+ , "decls" .= map bindToJSON (moduleDecls m)
+ , "builtWith" .= toJSON (showVersion v)
+ , "comments" .= map toJSON (moduleComments m)
]
where
importToJSON (ann,mn) = object
- [ T.pack "annotation" .= annToJSON ann
- , T.pack "moduleName" .= moduleNameToJSON mn
+ [ "annotation" .= annToJSON ann
+ , "moduleName" .= moduleNameToJSON mn
]
+ reExportsToJSON :: M.Map ModuleName [Ident] -> Value
+ reExportsToJSON = toJSON . M.map (map runIdent)
+
bindToJSON :: Bind Ann -> Value
bindToJSON (NonRec ann n e)
= object
- [ T.pack "bindType" .= "NonRec"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "identifier" .= identToJSON n
- , T.pack "expression" .= exprToJSON e
+ [ "bindType" .= "NonRec"
+ , "annotation" .= annToJSON ann
+ , "identifier" .= identToJSON n
+ , "expression" .= exprToJSON e
]
bindToJSON (Rec bs)
= object
- [ T.pack "bindType" .= "Rec"
- , T.pack "binds" .= map (\((ann, n), e)
+ [ "bindType" .= "Rec"
+ , "binds" .= map (\((ann, n), e)
-> object
- [ T.pack "identifier" .= identToJSON n
- , T.pack "annotation" .= annToJSON ann
- , T.pack "expression" .= exprToJSON e
+ [ "identifier" .= identToJSON n
+ , "annotation" .= annToJSON ann
+ , "expression" .= exprToJSON e
]) bs
]
@@ -144,86 +162,88 @@ recordToJSON :: (a -> Value) -> [(PSString, a)] -> Value
recordToJSON f = toJSON . map (toJSON *** f)
exprToJSON :: Expr Ann -> Value
-exprToJSON (Var ann i) = object [ T.pack "type" .= toJSON "Var"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "value" .= qualifiedToJSON runIdent i
+exprToJSON (Var ann i) = object [ "type" .= toJSON "Var"
+ , "annotation" .= annToJSON ann
+ , "value" .= qualifiedToJSON runIdent i
]
-exprToJSON (Literal ann l) = object [ T.pack "type" .= "Literal"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "value" .= literalToJSON exprToJSON l
+exprToJSON (Literal ann l) = object [ "type" .= "Literal"
+ , "annotation" .= annToJSON ann
+ , "value" .= literalToJSON exprToJSON l
]
-exprToJSON (Constructor ann d c is) = object [ T.pack "type" .= "Constructor"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "typeName" .= properNameToJSON d
- , T.pack "constructorName" .= properNameToJSON c
- , T.pack "fieldNames" .= map identToJSON is
+exprToJSON (Constructor ann d c is) = object [ "type" .= "Constructor"
+ , "annotation" .= annToJSON ann
+ , "typeName" .= properNameToJSON d
+ , "constructorName" .= properNameToJSON c
+ , "fieldNames" .= map identToJSON is
]
-exprToJSON (Accessor ann f r) = object [ T.pack "type" .= "Accessor"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "fieldName" .= f
- , T.pack "expression" .= exprToJSON r
+exprToJSON (Accessor ann f r) = object [ "type" .= "Accessor"
+ , "annotation" .= annToJSON ann
+ , "fieldName" .= f
+ , "expression" .= exprToJSON r
]
-exprToJSON (ObjectUpdate ann r fs) = object [ T.pack "type" .= "ObjectUpdate"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "expression" .= exprToJSON r
- , T.pack "updates" .= recordToJSON exprToJSON fs
+exprToJSON (ObjectUpdate ann r copy fs)
+ = object [ "type" .= "ObjectUpdate"
+ , "annotation" .= annToJSON ann
+ , "expression" .= exprToJSON r
+ , "copy" .= toJSON copy
+ , "updates" .= recordToJSON exprToJSON fs
]
-exprToJSON (Abs ann p b) = object [ T.pack "type" .= "Abs"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "argument" .= identToJSON p
- , T.pack "body" .= exprToJSON b
+exprToJSON (Abs ann p b) = object [ "type" .= "Abs"
+ , "annotation" .= annToJSON ann
+ , "argument" .= identToJSON p
+ , "body" .= exprToJSON b
]
-exprToJSON (App ann f x) = object [ T.pack "type" .= "App"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "abstraction" .= exprToJSON f
- , T.pack "argument" .= exprToJSON x
+exprToJSON (App ann f x) = object [ "type" .= "App"
+ , "annotation" .= annToJSON ann
+ , "abstraction" .= exprToJSON f
+ , "argument" .= exprToJSON x
]
-exprToJSON (Case ann ss cs) = object [ T.pack "type" .= "Case"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "caseExpressions"
+exprToJSON (Case ann ss cs) = object [ "type" .= "Case"
+ , "annotation" .= annToJSON ann
+ , "caseExpressions"
.= map exprToJSON ss
- , T.pack "caseAlternatives"
+ , "caseAlternatives"
.= map caseAlternativeToJSON cs
]
-exprToJSON (Let ann bs e) = object [ T.pack "type" .= "Let"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "binds" .= map bindToJSON bs
- , T.pack "expression" .= exprToJSON e
+exprToJSON (Let ann bs e) = object [ "type" .= "Let"
+ , "annotation" .= annToJSON ann
+ , "binds" .= map bindToJSON bs
+ , "expression" .= exprToJSON e
]
caseAlternativeToJSON :: CaseAlternative Ann -> Value
caseAlternativeToJSON (CaseAlternative bs r') =
let isGuarded = isLeft r'
in object
- [ T.pack "binders" .= toJSON (map binderToJSON bs)
- , T.pack "isGuarded" .= toJSON isGuarded
- , T.pack (if isGuarded then "expressions" else "expression")
+ [ "binders" .= toJSON (map binderToJSON bs)
+ , "isGuarded" .= toJSON isGuarded
+ , (if isGuarded then "expressions" else "expression")
.= case r' of
- Left rs -> toJSON $ map (\(g, e) -> object [ T.pack "guard" .= exprToJSON g, T.pack "expression" .= exprToJSON e]) rs
+ Left rs -> toJSON $ map (\(g, e) -> object [ "guard" .= exprToJSON g, "expression" .= exprToJSON e]) rs
Right r -> exprToJSON r
]
binderToJSON :: Binder Ann -> Value
-binderToJSON (VarBinder ann v) = object [ T.pack "binderType" .= "VarBinder"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "identifier" .= identToJSON v
+binderToJSON (VarBinder ann v) = object [ "binderType" .= "VarBinder"
+ , "annotation" .= annToJSON ann
+ , "identifier" .= identToJSON v
]
-binderToJSON (NullBinder ann) = object [ T.pack "binderType" .= "NullBinder"
- , T.pack "annotation" .= annToJSON ann
+binderToJSON (NullBinder ann) = object [ "binderType" .= "NullBinder"
+ , "annotation" .= annToJSON ann
]
-binderToJSON (LiteralBinder ann l) = object [ T.pack "binderType" .= "LiteralBinder"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "literal" .= literalToJSON binderToJSON l
+binderToJSON (LiteralBinder ann l) = object [ "binderType" .= "LiteralBinder"
+ , "annotation" .= annToJSON ann
+ , "literal" .= literalToJSON binderToJSON l
]
-binderToJSON (ConstructorBinder ann d c bs) = object [ T.pack "binderType" .= "ConstructorBinder"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "typeName" .= qualifiedToJSON runProperName d
- , T.pack "constructorName"
+binderToJSON (ConstructorBinder ann d c bs) = object [ "binderType" .= "ConstructorBinder"
+ , "annotation" .= annToJSON ann
+ , "typeName" .= qualifiedToJSON runProperName d
+ , "constructorName"
.= qualifiedToJSON runProperName c
- , T.pack "binders" .= map binderToJSON bs
+ , "binders" .= map binderToJSON bs
]
-binderToJSON (NamedBinder ann n b) = object [ T.pack "binderType" .= "NamedBinder"
- , T.pack "annotation" .= annToJSON ann
- , T.pack "identifier" .= identToJSON n
- , T.pack "binder" .= binderToJSON b
+binderToJSON (NamedBinder ann n b) = object [ "binderType" .= "NamedBinder"
+ , "annotation" .= annToJSON ann
+ , "identifier" .= identToJSON n
+ , "binder" .= binderToJSON b
]
diff --git a/src/Language/PureScript/CoreFn/Traversals.hs b/src/Language/PureScript/CoreFn/Traversals.hs
index 5415911863..4b5faa10cd 100644
--- a/src/Language/PureScript/CoreFn/Traversals.hs
+++ b/src/Language/PureScript/CoreFn/Traversals.hs
@@ -3,13 +3,14 @@
--
module Language.PureScript.CoreFn.Traversals where
-import Prelude.Compat
+import Prelude
import Control.Arrow (second, (***), (+++))
+import Data.Bitraversable (bitraverse)
-import Language.PureScript.AST.Literals
-import Language.PureScript.CoreFn.Binders
-import Language.PureScript.CoreFn.Expr
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.CoreFn.Binders (Binder(..))
+import Language.PureScript.CoreFn.Expr (Bind(..), CaseAlternative(..), Expr(..))
everywhereOnValues :: (Bind a -> Bind a) ->
(Expr a -> Expr a) ->
@@ -22,7 +23,7 @@ everywhereOnValues f g h = (f', g', h')
g' (Literal ann e) = g (Literal ann (handleLiteral g' e))
g' (Accessor ann prop e) = g (Accessor ann prop (g' e))
- g' (ObjectUpdate ann obj vs) = g (ObjectUpdate ann (g' obj) (map (fmap g') vs))
+ g' (ObjectUpdate ann obj copy vs) = g (ObjectUpdate ann (g' obj) copy (map (fmap g') vs))
g' (Abs ann name e) = g (Abs ann name (g' e))
g' (App ann v1 v2) = g (App ann (g' v1) (g' v2))
g' (Case ann vs alts) = g (Case ann (map g' vs) (map handleCaseAlternative alts))
@@ -44,34 +45,42 @@ everywhereOnValues f g h = (f', g', h')
handleLiteral i (ObjectLiteral ls) = ObjectLiteral (map (fmap i) ls)
handleLiteral _ other = other
-everythingOnValues :: (r -> r -> r) ->
- (Bind a -> r) ->
- (Expr a -> r) ->
- (Binder a -> r) ->
- (CaseAlternative a -> r) ->
- (Bind a -> r, Expr a -> r, Binder a -> r, CaseAlternative a -> r)
-everythingOnValues (<>.) f g h i = (f', g', h', i')
+-- |
+-- Apply the provided functions to the top level of AST nodes.
+--
+-- This function is useful as a building block for recursive functions, but
+-- doesn't actually recurse itself.
+--
+traverseCoreFn
+ :: forall f a
+ . Applicative f
+ => (Bind a -> f (Bind a))
+ -> (Expr a -> f (Expr a))
+ -> (Binder a -> f (Binder a))
+ -> (CaseAlternative a -> f (CaseAlternative a))
+ -> (Bind a -> f (Bind a), Expr a -> f (Expr a), Binder a -> f (Binder a), CaseAlternative a -> f (CaseAlternative a))
+traverseCoreFn f g h i = (f', g', h', i')
where
- f' b@(NonRec _ _ e) = f b <>. g' e
- f' b@(Rec es) = foldl (<>.) (f b) (map (g' . snd) es)
+ f' (NonRec a name e) = NonRec a name <$> g e
+ f' (Rec es) = Rec <$> traverse (traverse g) es
- g' v@(Literal _ l) = foldl (<>.) (g v) (map g' (extractLiteral l))
- g' v@(Accessor _ _ e1) = g v <>. g' e1
- g' v@(ObjectUpdate _ obj vs) = foldl (<>.) (g v <>. g' obj) (map (g' . snd) vs)
- g' v@(Abs _ _ e1) = g v <>. g' e1
- g' v@(App _ e1 e2) = g v <>. g' e1 <>. g' e2
- g' v@(Case _ vs alts) = foldl (<>.) (foldl (<>.) (g v) (map g' vs)) (map i' alts)
- g' v@(Let _ ds e1) = foldl (<>.) (g v) (map f' ds) <>. g' e1
- g' v = g v
+ g' (Literal ann e) = Literal ann <$> handleLiteral g e
+ g' (Accessor ann prop e) = Accessor ann prop <$> g e
+ g' (ObjectUpdate ann obj copy vs) = (\obj' -> ObjectUpdate ann obj' copy) <$> g obj <*> traverse (traverse g) vs
+ g' (Abs ann name e) = Abs ann name <$> g e
+ g' (App ann v1 v2) = App ann <$> g v1 <*> g v2
+ g' (Case ann vs alts) = Case ann <$> traverse g vs <*> traverse i alts
+ g' (Let ann ds e) = Let ann <$> traverse f ds <*> g e
+ g' e = pure e
- h' b@(LiteralBinder _ l) = foldl (<>.) (h b) (map h' (extractLiteral l))
- h' b@(ConstructorBinder _ _ _ bs) = foldl (<>.) (h b) (map h' bs)
- h' b@(NamedBinder _ _ b1) = h b <>. h' b1
- h' b = h b
+ h' (LiteralBinder a b) = LiteralBinder a <$> handleLiteral h b
+ h' (NamedBinder a name b) = NamedBinder a name <$> h b
+ h' (ConstructorBinder a q1 q2 bs) = ConstructorBinder a q1 q2 <$> traverse h bs
+ h' b = pure b
- i' ca@(CaseAlternative bs (Right val)) = foldl (<>.) (i ca) (map h' bs) <>. g' val
- i' ca@(CaseAlternative bs (Left gs)) = foldl (<>.) (i ca) (map h' bs ++ concatMap (\(grd, val) -> [g' grd, g' val]) gs)
+ i' ca = CaseAlternative <$> traverse h (caseAlternativeBinders ca) <*> bitraverse (traverse $ bitraverse g g) g (caseAlternativeResult ca)
- extractLiteral (ArrayLiteral xs) = xs
- extractLiteral (ObjectLiteral xs) = map snd xs
- extractLiteral _ = []
+ handleLiteral withItem = \case
+ ArrayLiteral ls -> ArrayLiteral <$> traverse withItem ls
+ ObjectLiteral ls -> ObjectLiteral <$> traverse (traverse withItem) ls
+ other -> pure other
diff --git a/src/Language/PureScript/CoreImp/AST.hs b/src/Language/PureScript/CoreImp/AST.hs
index b6dcad1446..9711890a3e 100644
--- a/src/Language/PureScript/CoreImp/AST.hs
+++ b/src/Language/PureScript/CoreImp/AST.hs
@@ -1,16 +1,17 @@
-- | Data types for the imperative core AST
module Language.PureScript.CoreImp.AST where
-import Prelude.Compat
+import Prelude
import Control.Monad ((>=>))
import Control.Monad.Identity (Identity(..), runIdentity)
import Data.Text (Text)
import Language.PureScript.AST (SourceSpan(..))
-import Language.PureScript.Comments
+import Language.PureScript.Comments (Comment)
+import Language.PureScript.Names (ModuleName)
import Language.PureScript.PSString (PSString)
-import Language.PureScript.Traversals
+import Language.PureScript.Traversals (sndM)
-- | Built-in unary operators
data UnaryOperator
@@ -44,6 +45,19 @@ data BinaryOperator
| ZeroFillShiftRight
deriving (Show, Eq)
+-- | Data type for CoreImp comments, which can come from either the PureScript
+-- source or internal transformations.
+data CIComments
+ = SourceComments [Comment]
+ | PureAnnotation
+ deriving (Show, Eq)
+
+-- |
+-- Indicates whether the initializer of a variable is known not to have side
+-- effects, and thus can be inlined if needed or removed if unneeded.
+--
+data InitializerEffects = NoEffects | UnknownEffects deriving (Show, Eq)
+
-- | Data type for simplified JavaScript expressions
data AST
= NumericLiteral (Maybe SourceSpan) (Either Integer Double)
@@ -68,9 +82,11 @@ data AST
-- ^ Function application
| Var (Maybe SourceSpan) Text
-- ^ Variable
+ | ModuleAccessor (Maybe SourceSpan) ModuleName PSString
+ -- ^ Value from another module
| Block (Maybe SourceSpan) [AST]
-- ^ A block of expressions in braces
- | VariableIntroduction (Maybe SourceSpan) Text (Maybe AST)
+ | VariableIntroduction (Maybe SourceSpan) Text (Maybe (InitializerEffects, AST))
-- ^ A variable introduction and optional initialization
| Assignment (Maybe SourceSpan) AST AST
-- ^ A variable assignment
@@ -90,7 +106,7 @@ data AST
-- ^ Throw statement
| InstanceOf (Maybe SourceSpan) AST AST
-- ^ instanceof check
- | Comment (Maybe SourceSpan) [Comment] AST
+ | Comment CIComments AST
-- ^ Commented JavaScript
deriving (Show, Eq)
@@ -111,6 +127,7 @@ withSourceSpan withSpan = go where
go (Function _ name args j) = Function ss name args j
go (App _ j js) = App ss j js
go (Var _ s) = Var ss s
+ go (ModuleAccessor _ s1 s2) = ModuleAccessor ss s1 s2
go (Block _ js) = Block ss js
go (VariableIntroduction _ name j) = VariableIntroduction ss name j
go (Assignment _ j1 j2) = Assignment ss j1 j2
@@ -122,7 +139,7 @@ withSourceSpan withSpan = go where
go (ReturnNoResult _) = ReturnNoResult ss
go (Throw _ js) = Throw ss js
go (InstanceOf _ j1 j2) = InstanceOf ss j1 j2
- go (Comment _ com j) = Comment ss com j
+ go c@Comment{} = c
getSourceSpan :: AST -> Maybe SourceSpan
getSourceSpan = go where
@@ -138,6 +155,7 @@ getSourceSpan = go where
go (Function ss _ _ _) = ss
go (App ss _ _) = ss
go (Var ss _) = ss
+ go (ModuleAccessor ss _ _) = ss
go (Block ss _) = ss
go (VariableIntroduction ss _ _) = ss
go (Assignment ss _ _) = ss
@@ -149,7 +167,7 @@ getSourceSpan = go where
go (ReturnNoResult ss) = ss
go (Throw ss _) = ss
go (InstanceOf ss _ _) = ss
- go (Comment ss _ _) = ss
+ go (Comment _ _) = Nothing
everywhere :: (AST -> AST) -> AST -> AST
everywhere f = go where
@@ -162,7 +180,7 @@ everywhere f = go where
go (Function ss name args j) = f (Function ss name args (go j))
go (App ss j js) = f (App ss (go j) (map go js))
go (Block ss js) = f (Block ss (map go js))
- go (VariableIntroduction ss name j) = f (VariableIntroduction ss name (fmap go j))
+ go (VariableIntroduction ss name j) = f (VariableIntroduction ss name (fmap (fmap go) j))
go (Assignment ss j1 j2) = f (Assignment ss (go j1) (go j2))
go (While ss j1 j2) = f (While ss (go j1) (go j2))
go (For ss name j1 j2 j3) = f (For ss name (go j1) (go j2) (go j3))
@@ -171,7 +189,7 @@ everywhere f = go where
go (Return ss js) = f (Return ss (go js))
go (Throw ss js) = f (Throw ss (go js))
go (InstanceOf ss j1 j2) = f (InstanceOf ss (go j1) (go j2))
- go (Comment ss com j) = f (Comment ss com (go j))
+ go (Comment com j) = f (Comment com (go j))
go other = f other
everywhereTopDown :: (AST -> AST) -> AST -> AST
@@ -188,7 +206,7 @@ everywhereTopDownM f = f >=> go where
go (Function ss name args j) = Function ss name args <$> f' j
go (App ss j js) = App ss <$> f' j <*> traverse f' js
go (Block ss js) = Block ss <$> traverse f' js
- go (VariableIntroduction ss name j) = VariableIntroduction ss name <$> traverse f' j
+ go (VariableIntroduction ss name j) = VariableIntroduction ss name <$> traverse (traverse f') j
go (Assignment ss j1 j2) = Assignment ss <$> f' j1 <*> f' j2
go (While ss j1 j2) = While ss <$> f' j1 <*> f' j2
go (For ss name j1 j2 j3) = For ss name <$> f' j1 <*> f' j2 <*> f' j3
@@ -197,7 +215,7 @@ everywhereTopDownM f = f >=> go where
go (Return ss j) = Return ss <$> f' j
go (Throw ss j) = Throw ss <$> f' j
go (InstanceOf ss j1 j2) = InstanceOf ss <$> f' j1 <*> f' j2
- go (Comment ss com j) = Comment ss com <$> f' j
+ go (Comment com j) = Comment com <$> f' j
go other = f other
everything :: (r -> r -> r) -> (AST -> r) -> AST -> r
@@ -210,7 +228,7 @@ everything (<>.) f = go where
go j@(Function _ _ _ j1) = f j <>. go j1
go j@(App _ j1 js) = foldl (<>.) (f j <>. go j1) (map go js)
go j@(Block _ js) = foldl (<>.) (f j) (map go js)
- go j@(VariableIntroduction _ _ (Just j1)) = f j <>. go j1
+ go j@(VariableIntroduction _ _ (Just (_, j1))) = f j <>. go j1
go j@(Assignment _ j1 j2) = f j <>. go j1 <>. go j2
go j@(While _ j1 j2) = f j <>. go j1 <>. go j2
go j@(For _ _ j1 j2 j3) = f j <>. go j1 <>. go j2 <>. go j3
@@ -220,5 +238,5 @@ everything (<>.) f = go where
go j@(Return _ j1) = f j <>. go j1
go j@(Throw _ j1) = f j <>. go j1
go j@(InstanceOf _ j1 j2) = f j <>. go j1 <>. go j2
- go j@(Comment _ _ j1) = f j <>. go j1
+ go j@(Comment _ j1) = f j <>. go j1
go other = f other
diff --git a/src/Language/PureScript/CoreImp/Module.hs b/src/Language/PureScript/CoreImp/Module.hs
new file mode 100644
index 0000000000..bdf4b8185d
--- /dev/null
+++ b/src/Language/PureScript/CoreImp/Module.hs
@@ -0,0 +1,19 @@
+module Language.PureScript.CoreImp.Module where
+
+import Protolude
+import Data.List.NonEmpty qualified as NEL (NonEmpty)
+
+import Language.PureScript.Comments (Comment)
+import Language.PureScript.CoreImp.AST (AST)
+import Language.PureScript.PSString (PSString)
+
+data Module = Module
+ { modHeader :: [Comment]
+ , modImports :: [Import]
+ , modBody :: [AST]
+ , modExports :: [Export]
+ }
+
+data Import = Import Text PSString
+
+data Export = Export (NEL.NonEmpty Text) (Maybe PSString)
diff --git a/src/Language/PureScript/CoreImp/Optimizer.hs b/src/Language/PureScript/CoreImp/Optimizer.hs
index de92116251..e59738df76 100644
--- a/src/Language/PureScript/CoreImp/Optimizer.hs
+++ b/src/Language/PureScript/CoreImp/Optimizer.hs
@@ -19,29 +19,34 @@
-- * Inlining primitive JavaScript operators
module Language.PureScript.CoreImp.Optimizer (optimize) where
-import Prelude.Compat
+import Prelude
+
+import Data.Text (Text)
import Control.Monad.Supply.Class (MonadSupply)
-import Language.PureScript.CoreImp.AST
-import Language.PureScript.CoreImp.Optimizer.Blocks
-import Language.PureScript.CoreImp.Optimizer.Common
-import Language.PureScript.CoreImp.Optimizer.Inliner
-import Language.PureScript.CoreImp.Optimizer.MagicDo
-import Language.PureScript.CoreImp.Optimizer.TCO
-import Language.PureScript.CoreImp.Optimizer.Unused
+import Language.PureScript.CoreImp.AST (AST(..), InitializerEffects(..))
+import Language.PureScript.CoreImp.Optimizer.Blocks (collapseNestedBlocks, collapseNestedIfs)
+import Language.PureScript.CoreImp.Optimizer.Common (applyAll, replaceIdents)
+import Language.PureScript.CoreImp.Optimizer.Inliner (etaConvert, evaluateIifes, inlineCommonOperators, inlineCommonValues, inlineFnComposition, inlineFnIdentity, inlineUnsafeCoerce, inlineUnsafePartial, inlineVariables, unThunk)
+import Language.PureScript.CoreImp.Optimizer.MagicDo (inlineST, magicDoEff, magicDoEffect, magicDoST)
+import Language.PureScript.CoreImp.Optimizer.TCO (tco)
+import Language.PureScript.CoreImp.Optimizer.Unused (removeCodeAfterReturnStatements, removeUndefinedApp, removeUnusedEffectFreeVars)
-- | Apply a series of optimizer passes to simplified JavaScript code
-optimize :: MonadSupply m => AST -> m AST
-optimize js = do
- js' <- untilFixedPoint (inlineFnComposition . inlineUnsafeCoerce . inlineUnsafePartial . tidyUp . applyAll
- [ inlineCommonValues
- , inlineCommonOperators
- ]) js
- untilFixedPoint (return . tidyUp) . tco . inlineST
- =<< untilFixedPoint (return . magicDoST)
- =<< untilFixedPoint (return . magicDoEff)
- =<< untilFixedPoint (return . magicDoEffect) js'
+optimize :: forall m. MonadSupply m => [Text] -> [[AST]] -> m [[AST]]
+optimize exps jsDecls = removeUnusedEffectFreeVars exps <$> traverse (traverse go) jsDecls
where
+ go :: AST -> m AST
+ go js = do
+ js' <- untilFixedPoint (inlineFnComposition expander . inlineFnIdentity expander . inlineUnsafeCoerce . inlineUnsafePartial . tidyUp . applyAll
+ [ inlineCommonValues expander
+ , inlineCommonOperators expander
+ ]) js
+ untilFixedPoint (return . tidyUp) . tco . inlineST
+ =<< untilFixedPoint (return . magicDoST expander)
+ =<< untilFixedPoint (return . magicDoEff expander)
+ =<< untilFixedPoint (return . magicDoEffect expander) js'
+
tidyUp :: AST -> AST
tidyUp = applyAll
[ collapseNestedBlocks
@@ -54,9 +59,27 @@ optimize js = do
, inlineVariables
]
+ expander = buildExpander (concat jsDecls)
+
untilFixedPoint :: (Monad m, Eq a) => (a -> m a) -> a -> m a
untilFixedPoint f = go
where
go a = do
a' <- f a
if a' == a then return a' else go a'
+
+-- |
+-- Take all top-level ASTs and return a function for expanding top-level
+-- variables during the various inlining steps in `optimize`.
+--
+-- Everything that gets inlined as an optimization is of a form that would
+-- have been lifted to a top-level binding during CSE, so for purposes of
+-- inlining we can save some time by only expanding variables bound at that
+-- level and not worrying about any inner scopes.
+--
+buildExpander :: [AST] -> AST -> AST
+buildExpander = replaceIdents . foldr go []
+ where
+ go = \case
+ VariableIntroduction _ name (Just (NoEffects, e)) -> ((name, e) :)
+ _ -> id
diff --git a/src/Language/PureScript/CoreImp/Optimizer/Blocks.hs b/src/Language/PureScript/CoreImp/Optimizer/Blocks.hs
index 04febf2039..add5d7c953 100644
--- a/src/Language/PureScript/CoreImp/Optimizer/Blocks.hs
+++ b/src/Language/PureScript/CoreImp/Optimizer/Blocks.hs
@@ -4,9 +4,9 @@ module Language.PureScript.CoreImp.Optimizer.Blocks
, collapseNestedIfs
) where
-import Prelude.Compat
+import Prelude
-import Language.PureScript.CoreImp.AST
+import Language.PureScript.CoreImp.AST (AST(..), BinaryOperator(..), everywhere)
-- | Collapse blocks which appear nested directly below another block
collapseNestedBlocks :: AST -> AST
diff --git a/src/Language/PureScript/CoreImp/Optimizer/Common.hs b/src/Language/PureScript/CoreImp/Optimizer/Common.hs
index 040995cb36..ac63f6a2bb 100644
--- a/src/Language/PureScript/CoreImp/Optimizer/Common.hs
+++ b/src/Language/PureScript/CoreImp/Optimizer/Common.hs
@@ -1,14 +1,15 @@
-- | Common functions used by the various optimizer phases
module Language.PureScript.CoreImp.Optimizer.Common where
-import Prelude.Compat
+import Prelude
import Data.Text (Text)
import Data.List (foldl')
import Data.Maybe (fromMaybe)
-import Language.PureScript.Crash
-import Language.PureScript.CoreImp.AST
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.CoreImp.AST (AST(..), everything, everywhere)
+import Language.PureScript.Names (ModuleName)
import Language.PureScript.PSString (PSString)
applyAll :: [a -> a] -> a -> a
@@ -43,14 +44,6 @@ isRebound js d = any (\v -> isReassigned v d || isUpdated v d) (everything (++)
variablesOf (Var _ var) = [var]
variablesOf _ = []
-isUsed :: Text -> AST -> Bool
-isUsed var1 = everything (||) check
- where
- check :: AST -> Bool
- check (Var _ var2) | var1 == var2 = True
- check (Assignment _ target _) | var1 == targetVariable target = True
- check _ = False
-
targetVariable :: AST -> Text
targetVariable (Var _ var) = var
targetVariable (Indexer _ _ tgt) = targetVariable tgt
@@ -67,10 +60,13 @@ removeFromBlock :: ([AST] -> [AST]) -> AST -> AST
removeFromBlock go (Block ss sts) = Block ss (go sts)
removeFromBlock _ js = js
-isDict :: (Text, PSString) -> AST -> Bool
-isDict (moduleName, dictName) (Indexer _ (StringLiteral _ x) (Var _ y)) =
- x == dictName && y == moduleName
-isDict _ _ = False
+pattern Ref :: (ModuleName, PSString) -> AST
+pattern Ref pair <- (refPatternHelper -> Just pair)
+-- ideally: pattern Ref (moduleName, refName) <- ModuleAccessor _ moduleName refName
+-- but: https://gitlab.haskell.org/ghc/ghc/-/issues/12203
+-- https://github.com/ghc-proposals/ghc-proposals/pull/138
-isDict' :: [(Text, PSString)] -> AST -> Bool
-isDict' xs js = any (`isDict` js) xs
+refPatternHelper :: AST -> Maybe (ModuleName, PSString)
+refPatternHelper = \case
+ ModuleAccessor _ moduleName refName -> Just (moduleName, refName)
+ _ -> Nothing
diff --git a/src/Language/PureScript/CoreImp/Optimizer/Inliner.hs b/src/Language/PureScript/CoreImp/Optimizer/Inliner.hs
index 4b627abd06..e7314df971 100644
--- a/src/Language/PureScript/CoreImp/Optimizer/Inliner.hs
+++ b/src/Language/PureScript/CoreImp/Optimizer/Inliner.hs
@@ -4,6 +4,7 @@ module Language.PureScript.CoreImp.Optimizer.Inliner
, inlineCommonValues
, inlineCommonOperators
, inlineFnComposition
+ , inlineFnIdentity
, inlineUnsafeCoerce
, inlineUnsafePartial
, etaConvert
@@ -11,21 +12,22 @@ module Language.PureScript.CoreImp.Optimizer.Inliner
, evaluateIifes
) where
-import Prelude.Compat
+import Prelude
import Control.Monad.Supply.Class (MonadSupply, freshName)
import Data.Either (rights)
import Data.Maybe (fromMaybe)
-import Data.String (IsString, fromString)
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
-import Language.PureScript.PSString (PSString)
-import Language.PureScript.CoreImp.AST
-import Language.PureScript.CoreImp.Optimizer.Common
+import Language.PureScript.Names (ModuleName)
+import Language.PureScript.PSString (PSString, mkString)
+import Language.PureScript.CoreImp.AST (AST(..), BinaryOperator(..), InitializerEffects(..), UnaryOperator(..), everywhere, everywhereTopDown, everywhereTopDownM, getSourceSpan)
+import Language.PureScript.CoreImp.Optimizer.Common (pattern Ref, applyAll, isReassigned, isRebound, isUpdated, removeFromBlock, replaceIdent, replaceIdents)
import Language.PureScript.AST (SourceSpan(..))
-import qualified Language.PureScript.Constants as C
+import Language.PureScript.Constants.Libs qualified as C
+import Language.PureScript.Constants.Prim qualified as C
-- TODO: Potential bug:
-- Shouldn't just inline this case: { var x = 0; x.toFixed(10); }
@@ -33,6 +35,7 @@ import qualified Language.PureScript.Constants as C
-- Probably needs to be fixed in pretty-printer instead.
shouldInline :: AST -> Bool
shouldInline (Var _ _) = True
+shouldInline (ModuleAccessor _ _ _) = True
shouldInline (NumericLiteral _ _) = True
shouldInline (StringLiteral _ _) = True
shouldInline (BooleanLiteral _ _) = True
@@ -45,7 +48,7 @@ etaConvert = everywhere convert
convert :: AST -> AST
convert (Block ss [Return _ (App _ (Function _ Nothing idents block@(Block _ body)) args)])
| all shouldInline args &&
- not (any (`isRebound` block) (map (Var Nothing) idents)) &&
+ not (any ((`isRebound` block) . Var Nothing) idents) &&
not (any (`isRebound` block) args)
= Block ss (map (replaceIdents (zip idents args)) body)
convert (Function _ Nothing [] (Block _ [Return _ (App _ fn [])])) = fn
@@ -68,7 +71,7 @@ evaluateIifes = everywhere convert
convert :: AST -> AST
convert (App _ (Function _ Nothing [] (Block _ [Return _ ret])) []) = ret
convert (App _ (Function _ Nothing idents (Block _ [Return ss ret])) [])
- | not (any (`isReassigned` ret) idents) = replaceIdents (map (, Var ss C.undefined) idents) ret
+ | not (any (`isReassigned` ret) idents) = replaceIdents (map (, Var ss C.S_undefined) idents) ret
convert js = js
inlineVariables :: AST -> AST
@@ -76,139 +79,130 @@ inlineVariables = everywhere $ removeFromBlock go
where
go :: [AST] -> [AST]
go [] = []
- go (VariableIntroduction _ var (Just js) : sts)
+ go (VariableIntroduction _ var (Just (_, js)) : sts)
| shouldInline js && not (any (isReassigned var) sts) && not (any (isRebound js) sts) && not (any (isUpdated var) sts) =
go (map (replaceIdent var js) sts)
go (s:sts) = s : go sts
-inlineCommonValues :: AST -> AST
-inlineCommonValues = everywhere convert
+inlineCommonValues :: (AST -> AST) -> AST -> AST
+inlineCommonValues expander = everywhere convert
where
convert :: AST -> AST
- convert (App ss fn [dict])
- | isDict' [semiringNumber, semiringInt] dict && isDict fnZero fn = NumericLiteral ss (Left 0)
- | isDict' [semiringNumber, semiringInt] dict && isDict fnOne fn = NumericLiteral ss (Left 1)
- | isDict boundedBoolean dict && isDict fnBottom fn = BooleanLiteral ss False
- | isDict boundedBoolean dict && isDict fnTop fn = BooleanLiteral ss True
- convert (App ss (App _ fn [dict]) [x])
- | isDict ringInt dict && isDict fnNegate fn = Binary ss BitwiseOr (Unary ss Negate x) (NumericLiteral ss (Left 0))
- convert (App ss (App _ (App _ fn [dict]) [x]) [y])
- | isDict semiringInt dict && isDict fnAdd fn = intOp ss Add x y
- | isDict semiringInt dict && isDict fnMultiply fn = intOp ss Multiply x y
- | isDict ringInt dict && isDict fnSubtract fn = intOp ss Subtract x y
+ convert (expander -> App ss (Ref fn) [Ref dict])
+ | dict `elem` [C.P_semiringNumber, C.P_semiringInt], C.P_zero <- fn = NumericLiteral ss (Left 0)
+ | dict `elem` [C.P_semiringNumber, C.P_semiringInt], C.P_one <- fn = NumericLiteral ss (Left 1)
+ | C.P_boundedBoolean <- dict, C.P_bottom <- fn = BooleanLiteral ss False
+ | C.P_boundedBoolean <- dict, C.P_top <- fn = BooleanLiteral ss True
+ convert (App ss (expander -> App _ (Ref C.P_negate) [Ref C.P_ringInt]) [x])
+ = Binary ss BitwiseOr (Unary ss Negate x) (NumericLiteral ss (Left 0))
+ convert (App ss (App _ (expander -> App _ (Ref fn) [Ref dict]) [x]) [y])
+ | C.P_semiringInt <- dict, C.P_add <- fn = intOp ss Add x y
+ | C.P_semiringInt <- dict, C.P_mul <- fn = intOp ss Multiply x y
+ | C.P_ringInt <- dict, C.P_sub <- fn = intOp ss Subtract x y
convert other = other
- fnZero = (C.dataSemiring, C.zero)
- fnOne = (C.dataSemiring, C.one)
- fnBottom = (C.dataBounded, C.bottom)
- fnTop = (C.dataBounded, C.top)
- fnAdd = (C.dataSemiring, C.add)
- fnMultiply = (C.dataSemiring, C.mul)
- fnSubtract = (C.dataRing, C.sub)
- fnNegate = (C.dataRing, C.negate)
intOp ss op x y = Binary ss BitwiseOr (Binary ss op x y) (NumericLiteral ss (Left 0))
-inlineCommonOperators :: AST -> AST
-inlineCommonOperators = everywhereTopDown $ applyAll $
- [ binary semiringNumber opAdd Add
- , binary semiringNumber opMul Multiply
-
- , binary ringNumber opSub Subtract
- , unary ringNumber opNegate Negate
-
- , binary euclideanRingNumber opDiv Divide
-
- , binary eqNumber opEq EqualTo
- , binary eqNumber opNotEq NotEqualTo
- , binary eqInt opEq EqualTo
- , binary eqInt opNotEq NotEqualTo
- , binary eqString opEq EqualTo
- , binary eqString opNotEq NotEqualTo
- , binary eqChar opEq EqualTo
- , binary eqChar opNotEq NotEqualTo
- , binary eqBoolean opEq EqualTo
- , binary eqBoolean opNotEq NotEqualTo
-
- , binary ordBoolean opLessThan LessThan
- , binary ordBoolean opLessThanOrEq LessThanOrEqualTo
- , binary ordBoolean opGreaterThan GreaterThan
- , binary ordBoolean opGreaterThanOrEq GreaterThanOrEqualTo
- , binary ordChar opLessThan LessThan
- , binary ordChar opLessThanOrEq LessThanOrEqualTo
- , binary ordChar opGreaterThan GreaterThan
- , binary ordChar opGreaterThanOrEq GreaterThanOrEqualTo
- , binary ordInt opLessThan LessThan
- , binary ordInt opLessThanOrEq LessThanOrEqualTo
- , binary ordInt opGreaterThan GreaterThan
- , binary ordInt opGreaterThanOrEq GreaterThanOrEqualTo
- , binary ordNumber opLessThan LessThan
- , binary ordNumber opLessThanOrEq LessThanOrEqualTo
- , binary ordNumber opGreaterThan GreaterThan
- , binary ordNumber opGreaterThanOrEq GreaterThanOrEqualTo
- , binary ordString opLessThan LessThan
- , binary ordString opLessThanOrEq LessThanOrEqualTo
- , binary ordString opGreaterThan GreaterThan
- , binary ordString opGreaterThanOrEq GreaterThanOrEqualTo
-
- , binary semigroupString opAppend Add
-
- , binary heytingAlgebraBoolean opConj And
- , binary heytingAlgebraBoolean opDisj Or
- , unary heytingAlgebraBoolean opNot Not
-
- , binary' C.dataIntBits C.or BitwiseOr
- , binary' C.dataIntBits C.and BitwiseAnd
- , binary' C.dataIntBits C.xor BitwiseXor
- , binary' C.dataIntBits C.shl ShiftLeft
- , binary' C.dataIntBits C.shr ShiftRight
- , binary' C.dataIntBits C.zshr ZeroFillShiftRight
- , unary' C.dataIntBits C.complement BitwiseNot
-
- , inlineNonClassFunction (isModFn (C.dataFunction, C.apply)) $ \f x -> App Nothing f [x]
- , inlineNonClassFunction (isModFn (C.dataFunction, C.applyFlipped)) $ \x f -> App Nothing f [x]
- , inlineNonClassFunction (isModFnWithDict (C.dataArray, C.unsafeIndex)) $ flip (Indexer Nothing)
+inlineCommonOperators :: (AST -> AST) -> AST -> AST
+inlineCommonOperators expander = everywhereTopDown $ applyAll $
+ [ binary C.P_semiringNumber C.P_add Add
+ , binary C.P_semiringNumber C.P_mul Multiply
+
+ , binary C.P_ringNumber C.P_sub Subtract
+ , unary C.P_ringNumber C.P_negate Negate
+
+ , binary C.P_euclideanRingNumber C.P_div Divide
+
+ , binary C.P_eqNumber C.P_eq EqualTo
+ , binary C.P_eqNumber C.P_notEq NotEqualTo
+ , binary C.P_eqInt C.P_eq EqualTo
+ , binary C.P_eqInt C.P_notEq NotEqualTo
+ , binary C.P_eqString C.P_eq EqualTo
+ , binary C.P_eqString C.P_notEq NotEqualTo
+ , binary C.P_eqChar C.P_eq EqualTo
+ , binary C.P_eqChar C.P_notEq NotEqualTo
+ , binary C.P_eqBoolean C.P_eq EqualTo
+ , binary C.P_eqBoolean C.P_notEq NotEqualTo
+
+ , binary C.P_ordBoolean C.P_lessThan LessThan
+ , binary C.P_ordBoolean C.P_lessThanOrEq LessThanOrEqualTo
+ , binary C.P_ordBoolean C.P_greaterThan GreaterThan
+ , binary C.P_ordBoolean C.P_greaterThanOrEq GreaterThanOrEqualTo
+ , binary C.P_ordChar C.P_lessThan LessThan
+ , binary C.P_ordChar C.P_lessThanOrEq LessThanOrEqualTo
+ , binary C.P_ordChar C.P_greaterThan GreaterThan
+ , binary C.P_ordChar C.P_greaterThanOrEq GreaterThanOrEqualTo
+ , binary C.P_ordInt C.P_lessThan LessThan
+ , binary C.P_ordInt C.P_lessThanOrEq LessThanOrEqualTo
+ , binary C.P_ordInt C.P_greaterThan GreaterThan
+ , binary C.P_ordInt C.P_greaterThanOrEq GreaterThanOrEqualTo
+ , binary C.P_ordNumber C.P_lessThan LessThan
+ , binary C.P_ordNumber C.P_lessThanOrEq LessThanOrEqualTo
+ , binary C.P_ordNumber C.P_greaterThan GreaterThan
+ , binary C.P_ordNumber C.P_greaterThanOrEq GreaterThanOrEqualTo
+ , binary C.P_ordString C.P_lessThan LessThan
+ , binary C.P_ordString C.P_lessThanOrEq LessThanOrEqualTo
+ , binary C.P_ordString C.P_greaterThan GreaterThan
+ , binary C.P_ordString C.P_greaterThanOrEq GreaterThanOrEqualTo
+
+ , binary C.P_semigroupString C.P_append Add
+
+ , binary C.P_heytingAlgebraBoolean C.P_conj And
+ , binary C.P_heytingAlgebraBoolean C.P_disj Or
+ , unary C.P_heytingAlgebraBoolean C.P_not Not
+
+ , binary' C.P_or BitwiseOr
+ , binary' C.P_and BitwiseAnd
+ , binary' C.P_xor BitwiseXor
+ , binary' C.P_shl ShiftLeft
+ , binary' C.P_shr ShiftRight
+ , binary' C.P_zshr ZeroFillShiftRight
+ , unary' C.P_complement BitwiseNot
+
+ , inlineNonClassFunction (isModFnWithDict C.P_unsafeIndex) $ flip (Indexer Nothing)
] ++
[ fn | i <- [0..10], fn <- [ mkFn i, runFn i ] ] ++
- [ fn | i <- [0..10], fn <- [ mkEffFn C.controlMonadEffUncurried C.mkEffFn i, runEffFn C.controlMonadEffUncurried C.runEffFn i ] ] ++
- [ fn | i <- [0..10], fn <- [ mkEffFn C.effectUncurried C.mkEffectFn i, runEffFn C.effectUncurried C.runEffectFn i ] ]
+ [ fn | i <- [0..10], fn <- [ mkEffFn C.P_mkEffFn i, runEffFn C.P_runEffFn i ] ] ++
+ [ fn | i <- [0..10], fn <- [ mkEffFn C.P_mkEffectFn i, runEffFn C.P_runEffectFn i ] ] ++
+ [ fn | i <- [0..10], fn <- [ mkEffFn C.P_mkSTFn i, runEffFn C.P_runSTFn i ] ]
where
- binary :: (Text, PSString) -> (Text, PSString) -> BinaryOperator -> AST -> AST
- binary dict fns op = convert where
+ binary :: (ModuleName, PSString) -> (ModuleName, PSString) -> BinaryOperator -> AST -> AST
+ binary dict fn op = convert where
convert :: AST -> AST
- convert (App ss (App _ (App _ fn [dict']) [x]) [y]) | isDict dict dict' && isDict fns fn = Binary ss op x y
+ convert (App ss (App _ (expander -> App _ (Ref fn') [Ref dict']) [x]) [y]) | dict == dict', fn == fn' = Binary ss op x y
convert other = other
- binary' :: Text -> PSString -> BinaryOperator -> AST -> AST
- binary' moduleName opString op = convert where
+ binary' :: (ModuleName, PSString) -> BinaryOperator -> AST -> AST
+ binary' fn op = convert where
convert :: AST -> AST
- convert (App ss (App _ fn [x]) [y]) | isDict (moduleName, opString) fn = Binary ss op x y
+ convert (App ss (App _ (Ref fn') [x]) [y]) | fn == fn' = Binary ss op x y
convert other = other
- unary :: (Text, PSString) -> (Text, PSString) -> UnaryOperator -> AST -> AST
- unary dicts fns op = convert where
+ unary :: (ModuleName, PSString) -> (ModuleName, PSString) -> UnaryOperator -> AST -> AST
+ unary dict fn op = convert where
convert :: AST -> AST
- convert (App ss (App _ fn [dict']) [x]) | isDict dicts dict' && isDict fns fn = Unary ss op x
+ convert (App ss (expander -> App _ (Ref fn') [Ref dict']) [x]) | dict == dict', fn == fn' = Unary ss op x
convert other = other
- unary' :: Text -> PSString -> UnaryOperator -> AST -> AST
- unary' moduleName fnName op = convert where
+ unary' :: (ModuleName, PSString) -> UnaryOperator -> AST -> AST
+ unary' fn op = convert where
convert :: AST -> AST
- convert (App ss fn [x]) | isDict (moduleName, fnName) fn = Unary ss op x
+ convert (App ss (Ref fn') [x]) | fn == fn' = Unary ss op x
convert other = other
mkFn :: Int -> AST -> AST
- mkFn = mkFn' C.dataFunctionUncurried C.mkFn $ \ss1 ss2 ss3 args js ->
+ mkFn = mkFn' C.P_mkFn $ \ss1 ss2 ss3 args js ->
Function ss1 Nothing args (Block ss2 [Return ss3 js])
- mkEffFn :: Text -> Text -> Int -> AST -> AST
- mkEffFn modName fnName = mkFn' modName fnName $ \ss1 ss2 ss3 args js ->
+ mkEffFn :: (ModuleName, PSString) -> Int -> AST -> AST
+ mkEffFn mkFn_ = mkFn' mkFn_ $ \ss1 ss2 ss3 args js ->
Function ss1 Nothing args (Block ss2 [Return ss3 (App ss3 js [])])
- mkFn' :: Text -> Text -> (Maybe SourceSpan -> Maybe SourceSpan -> Maybe SourceSpan -> [Text] -> AST -> AST) -> Int -> AST -> AST
- mkFn' modName fnName res 0 = convert where
+ mkFn' :: (ModuleName, PSString) -> (Maybe SourceSpan -> Maybe SourceSpan -> Maybe SourceSpan -> [Text] -> AST -> AST) -> Int -> AST -> AST
+ mkFn' mkFn_ res 0 = convert where
convert :: AST -> AST
- convert (App _ mkFnN [Function s1 Nothing [_] (Block s2 [Return s3 js])]) | isNFn modName fnName 0 mkFnN =
+ convert (App _ (Ref mkFnN) [Function s1 Nothing [_] (Block s2 [Return s3 js])]) | isNFn mkFn_ 0 mkFnN =
res s1 s2 s3 [] js
convert other = other
- mkFn' modName fnName res n = convert where
+ mkFn' mkFn_ res n = convert where
convert :: AST -> AST
- convert orig@(App ss mkFnN [fn]) | isNFn modName fnName n mkFnN =
+ convert orig@(App ss (Ref mkFnN) [fn]) | isNFn mkFn_ n mkFnN =
case collectArgs n [] fn of
Just (args, [Return ss' ret]) -> res ss ss ss' args ret
_ -> orig
@@ -218,25 +212,23 @@ inlineCommonOperators = everywhereTopDown $ applyAll $
collectArgs m acc (Function _ Nothing [oneArg] (Block _ [Return _ ret])) = collectArgs (m - 1) (oneArg : acc) ret
collectArgs _ _ _ = Nothing
- isNFn :: Text -> Text -> Int -> AST -> Bool
- isNFn expectMod prefix n (Indexer _ (StringLiteral _ name) (Var _ modName)) | modName == expectMod =
- name == fromString (T.unpack prefix <> show n)
- isNFn _ _ _ _ = False
+ isNFn :: (ModuleName, PSString) -> Int -> (ModuleName, PSString) -> Bool
+ isNFn prefix n fn = fmap (<> mkString (T.pack $ show n)) prefix == fn
runFn :: Int -> AST -> AST
- runFn = runFn' C.dataFunctionUncurried C.runFn App
+ runFn = runFn' C.P_runFn App
- runEffFn :: Text -> Text -> Int -> AST -> AST
- runEffFn modName fnName = runFn' modName fnName $ \ss fn acc ->
+ runEffFn :: (ModuleName, PSString) -> Int -> AST -> AST
+ runEffFn runFn_ = runFn' runFn_ $ \ss fn acc ->
Function ss Nothing [] (Block ss [Return ss (App ss fn acc)])
- runFn' :: Text -> Text -> (Maybe SourceSpan -> AST -> [AST] -> AST) -> Int -> AST -> AST
- runFn' modName runFnName res n = convert where
+ runFn' :: (ModuleName, PSString) -> (Maybe SourceSpan -> AST -> [AST] -> AST) -> Int -> AST -> AST
+ runFn' runFn_ res n = convert where
convert :: AST -> AST
convert js = fromMaybe js $ go n [] js
go :: Int -> [AST] -> AST -> Maybe AST
- go 0 acc (App ss runFnN [fn]) | isNFn modName runFnName n runFnN && length acc == n =
+ go 0 acc (App ss (Ref runFnN) [fn]) | isNFn runFn_ n runFnN && length acc == n =
Just $ res ss fn acc
go m acc (App _ lhs [arg]) = go (m - 1) (arg : acc) lhs
go _ _ _ = Nothing
@@ -247,32 +239,27 @@ inlineCommonOperators = everywhereTopDown $ applyAll $
convert (App _ (App _ op' [x]) [y]) | p op' = f x y
convert other = other
- isModFn :: (Text, PSString) -> AST -> Bool
- isModFn (m, op) (Indexer _ (StringLiteral _ op') (Var _ m')) =
- m == m' && op == op'
- isModFn _ _ = False
-
- isModFnWithDict :: (Text, PSString) -> AST -> Bool
- isModFnWithDict (m, op) (App _ (Indexer _ (StringLiteral _ op') (Var _ m')) [Var _ _]) =
- m == m' && op == op'
+ isModFnWithDict :: (ModuleName, PSString) -> AST -> Bool
+ isModFnWithDict fn (App _ (Ref fn') [Var _ _]) = fn == fn'
isModFnWithDict _ _ = False
-- (f <<< g $ x) = f (g x)
-- (f <<< g) = \x -> f (g x)
-inlineFnComposition :: forall m. MonadSupply m => AST -> m AST
-inlineFnComposition = everywhereTopDownM convert where
+inlineFnComposition :: forall m. MonadSupply m => (AST -> AST) -> AST -> m AST
+inlineFnComposition expander = everywhereTopDownM convert
+ where
convert :: AST -> m AST
- convert (App s1 (App s2 (App _ (App _ fn [dict']) [x]) [y]) [z])
- | isFnCompose dict' fn = return $ App s1 x [App s2 y [z]]
- | isFnComposeFlipped dict' fn = return $ App s2 y [App s1 x [z]]
- convert app@(App ss (App _ (App _ fn [dict']) _) _)
- | isFnCompose dict' fn || isFnComposeFlipped dict' fn = mkApps ss <$> goApps app <*> freshName
+ convert (App s1 (App s2 (App _ (expander -> App _ (Ref fn) [Ref C.P_semigroupoidFn]) [x]) [y]) [z])
+ | C.P_compose <- fn = return $ App s1 x [App s2 y [z]]
+ | C.P_composeFlipped <- fn = return $ App s2 y [App s1 x [z]]
+ convert app@(App ss (App _ (expander -> App _ (Ref fn) [Ref C.P_semigroupoidFn]) _) _)
+ | fn `elem` [C.P_compose, C.P_composeFlipped] = mkApps ss <$> goApps app <*> freshName
convert other = return other
mkApps :: Maybe SourceSpan -> [Either AST (Text, AST)] -> Text -> AST
mkApps ss fns a = App ss (Function ss Nothing [] (Block ss $ vars <> [Return Nothing comp])) []
where
- vars = uncurry (VariableIntroduction ss) . fmap Just <$> rights fns
+ vars = uncurry (VariableIntroduction ss) . fmap (Just . (UnknownEffects, )) <$> rights fns
comp = Function ss Nothing [a] (Block ss [Return Nothing apps])
apps = foldr (\fn acc -> App ss (mkApp fn) [acc]) (Var ss a) fns
@@ -280,138 +267,28 @@ inlineFnComposition = everywhereTopDownM convert where
mkApp = either id $ \(name, arg) -> Var (getSourceSpan arg) name
goApps :: AST -> m [Either AST (Text, AST)]
- goApps (App _ (App _ (App _ fn [dict']) [x]) [y])
- | isFnCompose dict' fn = mappend <$> goApps x <*> goApps y
- | isFnComposeFlipped dict' fn = mappend <$> goApps y <*> goApps x
- goApps app@(App {}) = pure . Right . (,app) <$> freshName
+ goApps (App _ (App _ (expander -> App _ (Ref fn) [Ref C.P_semigroupoidFn]) [x]) [y])
+ | C.P_compose <- fn = mappend <$> goApps x <*> goApps y
+ | C.P_composeFlipped <- fn = mappend <$> goApps y <*> goApps x
+ goApps app@App {} = pure . Right . (,app) <$> freshName
goApps other = pure [Left other]
- isFnCompose :: AST -> AST -> Bool
- isFnCompose dict' fn = isDict semigroupoidFn dict' && isDict fnCompose fn
-
- isFnComposeFlipped :: AST -> AST -> Bool
- isFnComposeFlipped dict' fn = isDict semigroupoidFn dict' && isDict fnComposeFlipped fn
-
- fnCompose :: forall a b. (IsString a, IsString b) => (a, b)
- fnCompose = (C.controlSemigroupoid, C.compose)
-
- fnComposeFlipped :: forall a b. (IsString a, IsString b) => (a, b)
- fnComposeFlipped = (C.controlSemigroupoid, C.composeFlipped)
+inlineFnIdentity :: (AST -> AST) -> AST -> AST
+inlineFnIdentity expander = everywhereTopDown convert
+ where
+ convert :: AST -> AST
+ convert (App _ (expander -> App _ (Ref C.P_identity) [Ref C.P_categoryFn]) [x]) = x
+ convert other = other
inlineUnsafeCoerce :: AST -> AST
inlineUnsafeCoerce = everywhereTopDown convert where
- convert (App _ (Indexer _ (StringLiteral _ unsafeCoerceFn) (Var _ unsafeCoerce)) [ comp ])
- | unsafeCoerceFn == C.unsafeCoerceFn && unsafeCoerce == C.unsafeCoerce
- = comp
+ convert (App _ (Ref C.P_unsafeCoerce) [ comp ]) = comp
convert other = other
inlineUnsafePartial :: AST -> AST
inlineUnsafePartial = everywhereTopDown convert where
- convert (App ss (Indexer _ (StringLiteral _ unsafePartial) (Var _ partialUnsafe)) [ comp ])
- | unsafePartial == C.unsafePartial && partialUnsafe == C.partialUnsafe
+ convert (App ss (Ref C.P_unsafePartial) [ comp ])
-- Apply to undefined here, the application should be optimized away
-- if it is safe to do so
- = App ss comp [ Var ss C.undefined ]
+ = App ss comp [ Var ss C.S_undefined ]
convert other = other
-
-semiringNumber :: forall a b. (IsString a, IsString b) => (a, b)
-semiringNumber = (C.dataSemiring, C.semiringNumber)
-
-semiringInt :: forall a b. (IsString a, IsString b) => (a, b)
-semiringInt = (C.dataSemiring, C.semiringInt)
-
-ringNumber :: forall a b. (IsString a, IsString b) => (a, b)
-ringNumber = (C.dataRing, C.ringNumber)
-
-ringInt :: forall a b. (IsString a, IsString b) => (a, b)
-ringInt = (C.dataRing, C.ringInt)
-
-euclideanRingNumber :: forall a b. (IsString a, IsString b) => (a, b)
-euclideanRingNumber = (C.dataEuclideanRing, C.euclideanRingNumber)
-
-eqNumber :: forall a b. (IsString a, IsString b) => (a, b)
-eqNumber = (C.dataEq, C.eqNumber)
-
-eqInt :: forall a b. (IsString a, IsString b) => (a, b)
-eqInt = (C.dataEq, C.eqInt)
-
-eqString :: forall a b. (IsString a, IsString b) => (a, b)
-eqString = (C.dataEq, C.eqString)
-
-eqChar :: forall a b. (IsString a, IsString b) => (a, b)
-eqChar = (C.dataEq, C.eqChar)
-
-eqBoolean :: forall a b. (IsString a, IsString b) => (a, b)
-eqBoolean = (C.dataEq, C.eqBoolean)
-
-ordBoolean :: forall a b. (IsString a, IsString b) => (a, b)
-ordBoolean = (C.dataOrd, C.ordBoolean)
-
-ordNumber :: forall a b. (IsString a, IsString b) => (a, b)
-ordNumber = (C.dataOrd, C.ordNumber)
-
-ordInt :: forall a b. (IsString a, IsString b) => (a, b)
-ordInt = (C.dataOrd, C.ordInt)
-
-ordString :: forall a b. (IsString a, IsString b) => (a, b)
-ordString = (C.dataOrd, C.ordString)
-
-ordChar :: forall a b. (IsString a, IsString b) => (a, b)
-ordChar = (C.dataOrd, C.ordChar)
-
-semigroupString :: forall a b. (IsString a, IsString b) => (a, b)
-semigroupString = (C.dataSemigroup, C.semigroupString)
-
-boundedBoolean :: forall a b. (IsString a, IsString b) => (a, b)
-boundedBoolean = (C.dataBounded, C.boundedBoolean)
-
-heytingAlgebraBoolean :: forall a b. (IsString a, IsString b) => (a, b)
-heytingAlgebraBoolean = (C.dataHeytingAlgebra, C.heytingAlgebraBoolean)
-
-semigroupoidFn :: forall a b. (IsString a, IsString b) => (a, b)
-semigroupoidFn = (C.controlSemigroupoid, C.semigroupoidFn)
-
-opAdd :: forall a b. (IsString a, IsString b) => (a, b)
-opAdd = (C.dataSemiring, C.add)
-
-opMul :: forall a b. (IsString a, IsString b) => (a, b)
-opMul = (C.dataSemiring, C.mul)
-
-opEq :: forall a b. (IsString a, IsString b) => (a, b)
-opEq = (C.dataEq, C.eq)
-
-opNotEq :: forall a b. (IsString a, IsString b) => (a, b)
-opNotEq = (C.dataEq, C.notEq)
-
-opLessThan :: forall a b. (IsString a, IsString b) => (a, b)
-opLessThan = (C.dataOrd, C.lessThan)
-
-opLessThanOrEq :: forall a b. (IsString a, IsString b) => (a, b)
-opLessThanOrEq = (C.dataOrd, C.lessThanOrEq)
-
-opGreaterThan :: forall a b. (IsString a, IsString b) => (a, b)
-opGreaterThan = (C.dataOrd, C.greaterThan)
-
-opGreaterThanOrEq :: forall a b. (IsString a, IsString b) => (a, b)
-opGreaterThanOrEq = (C.dataOrd, C.greaterThanOrEq)
-
-opAppend :: forall a b. (IsString a, IsString b) => (a, b)
-opAppend = (C.dataSemigroup, C.append)
-
-opSub :: forall a b. (IsString a, IsString b) => (a, b)
-opSub = (C.dataRing, C.sub)
-
-opNegate :: forall a b. (IsString a, IsString b) => (a, b)
-opNegate = (C.dataRing, C.negate)
-
-opDiv :: forall a b. (IsString a, IsString b) => (a, b)
-opDiv = (C.dataEuclideanRing, C.div)
-
-opConj :: forall a b. (IsString a, IsString b) => (a, b)
-opConj = (C.dataHeytingAlgebra, C.conj)
-
-opDisj :: forall a b. (IsString a, IsString b) => (a, b)
-opDisj = (C.dataHeytingAlgebra, C.disj)
-
-opNot :: forall a b. (IsString a, IsString b) => (a, b)
-opNot = (C.dataHeytingAlgebra, C.not)
diff --git a/src/Language/PureScript/CoreImp/Optimizer/MagicDo.hs b/src/Language/PureScript/CoreImp/Optimizer/MagicDo.hs
index 1a2cde1327..b591675793 100644
--- a/src/Language/PureScript/CoreImp/Optimizer/MagicDo.hs
+++ b/src/Language/PureScript/CoreImp/Optimizer/MagicDo.hs
@@ -2,16 +2,16 @@
-- and bind for the Eff monad, as well as some of its actions.
module Language.PureScript.CoreImp.Optimizer.MagicDo (magicDoEffect, magicDoEff, magicDoST, inlineST) where
-import Prelude.Compat
+import Prelude
import Protolude (ordNub)
import Data.Maybe (fromJust, isJust)
-import Data.Text (Text)
-import Language.PureScript.CoreImp.AST
-import Language.PureScript.CoreImp.Optimizer.Common
+import Language.PureScript.CoreImp.AST (AST(..), InitializerEffects(..), UnaryOperator(..), everything, everywhere, everywhereTopDown)
+import Language.PureScript.CoreImp.Optimizer.Common (pattern Ref)
+import Language.PureScript.Names (ModuleName)
import Language.PureScript.PSString (mkString)
-import qualified Language.PureScript.Constants as C
+import Language.PureScript.Constants.Libs qualified as C
-- | Inline type class dictionaries for >>= and return for the Eff monad
--
@@ -27,17 +27,17 @@ import qualified Language.PureScript.Constants as C
-- var x = m1();
-- ...
-- }
-magicDoEff :: AST -> AST
-magicDoEff = magicDo C.eff C.effDictionaries
+magicDoEff :: (AST -> AST) -> AST -> AST
+magicDoEff = magicDo C.M_Control_Monad_Eff C.effDictionaries
-magicDoEffect :: AST -> AST
-magicDoEffect = magicDo C.effect C.effectDictionaries
+magicDoEffect :: (AST -> AST) -> AST -> AST
+magicDoEffect = magicDo C.M_Effect C.effectDictionaries
-magicDoST :: AST -> AST
-magicDoST = magicDo C.st C.stDictionaries
+magicDoST :: (AST -> AST) -> AST -> AST
+magicDoST = magicDo C.M_Control_Monad_ST_Internal C.stDictionaries
-magicDo :: Text -> C.EffectDictionaries -> AST -> AST
-magicDo effectModule C.EffectDictionaries{..} = everywhereTopDown convert
+magicDo :: ModuleName -> C.EffectDictionaries -> (AST -> AST) -> AST -> AST
+magicDo effectModule C.EffectDictionaries{..} expander = everywhereTopDown convert
where
-- The name of the function block which is added to denote a do block
fnName = "__do"
@@ -48,9 +48,13 @@ magicDo effectModule C.EffectDictionaries{..} = everywhereTopDown convert
-- Desugar discard
convert (App _ (App _ bind [m]) [Function s1 Nothing [] (Block s2 js)]) | isDiscard bind =
Function s1 (Just fnName) [] $ Block s2 (App s2 m [] : map applyReturns js )
+ -- Desugar bind to wildcard
+ convert (App _ (App _ bind [m]) [Function s1 Nothing [] (Block s2 js)])
+ | isBind bind =
+ Function s1 (Just fnName) [] $ Block s2 (App s2 m [] : map applyReturns js )
-- Desugar bind
convert (App _ (App _ bind [m]) [Function s1 Nothing [arg] (Block s2 js)]) | isBind bind =
- Function s1 (Just fnName) [] $ Block s2 (VariableIntroduction s2 arg (Just (App s2 m [])) : map applyReturns js)
+ Function s1 (Just fnName) [] $ Block s2 (VariableIntroduction s2 arg (Just (UnknownEffects, App s2 m [])) : map applyReturns js)
-- Desugar untilE
convert (App s1 (App _ f [arg]) []) | isEffFunc edUntil f =
App s1 (Function s1 Nothing [] (Block s1 [ While s1 (Unary s1 Not (App s1 arg [])) (Block s1 []), Return s1 $ ObjectLiteral s1 []])) []
@@ -64,25 +68,16 @@ magicDo effectModule C.EffectDictionaries{..} = everywhereTopDown convert
App s1 (Function s2 Nothing [] (Block ss (applyReturns `fmap` body))) []
convert other = other
-- Check if an expression represents a monomorphic call to >>= for the Eff monad
- isBind (App _ fn [dict]) | isDict (effectModule, edBindDict) dict && isBindPoly fn = True
+ isBind (expander -> App _ (Ref C.P_bind) [Ref dict]) = (effectModule, edBindDict) == dict
isBind _ = False
-- Check if an expression represents a call to @discard@
- isDiscard (App _ (App _ fn [dict1]) [dict2])
- | isDict (C.controlBind, C.discardUnitDictionary) dict1 &&
- isDict (effectModule, edBindDict) dict2 &&
- isDiscardPoly fn = True
+ isDiscard (expander -> App _ (expander -> App _ (Ref C.P_discard) [Ref C.P_discardUnit]) [Ref dict]) = (effectModule, edBindDict) == dict
isDiscard _ = False
-- Check if an expression represents a monomorphic call to pure or return for the Eff applicative
- isPure (App _ fn [dict]) | isDict (effectModule, edApplicativeDict) dict && isPurePoly fn = True
+ isPure (expander -> App _ (Ref C.P_pure) [Ref dict]) = (effectModule, edApplicativeDict) == dict
isPure _ = False
- -- Check if an expression represents the polymorphic >>= function
- isBindPoly = isDict (C.controlBind, C.bind)
- -- Check if an expression represents the polymorphic pure function
- isPurePoly = isDict (C.controlApplicative, C.pure')
- -- Check if an expression represents the polymorphic discard function
- isDiscardPoly = isDict (C.controlBind, C.discard)
-- Check if an expression represents a function in the Effect module
- isEffFunc name (Indexer _ (StringLiteral _ name') (Var _ eff)) = eff == effectModule && name == name'
+ isEffFunc name (Ref fn) = (effectModule, name) == fn
isEffFunc _ _ = False
applyReturns :: AST -> AST
@@ -98,10 +93,10 @@ magicDo effectModule C.EffectDictionaries{..} = everywhereTopDown convert
inlineST :: AST -> AST
inlineST = everywhere convertBlock
where
- -- Look for runST blocks and inline the STRefs there.
- -- If all STRefs are used in the scope of the same runST, only using { read, write, modify }STRef then
+ -- Look for run blocks and inline the STRefs there.
+ -- If all STRefs are used in the scope of the same run, only using { read, write, modify } then
-- we can be more aggressive about inlining, and actually turn STRefs into local variables.
- convertBlock (App s1 f [arg]) | isSTFunc C.runST f =
+ convertBlock (App s1 (Ref C.P_run) [arg]) =
let refs = ordNub . findSTRefsIn $ arg
usages = findAllSTUsagesIn arg
allUsagesAreLocalVars = all (\u -> let v = toVar u in isJust v && fromJust v `elem` refs) usages
@@ -111,28 +106,25 @@ inlineST = everywhere convertBlock
-- Convert a block in a safe way, preserving object wrappers of references,
-- or in a more aggressive way, turning wrappers into local variables depending on the
-- agg(ressive) parameter.
- convert agg (App s1 f [arg]) | isSTFunc C.newSTRef f =
+ convert agg (App s1 (Ref C.P_new) [arg]) =
Function s1 Nothing [] (Block s1 [Return s1 $ if agg then arg else ObjectLiteral s1 [(mkString C.stRefValue, arg)]])
- convert agg (App _ (App s1 f [ref]) []) | isSTFunc C.readSTRef f =
+ convert agg (App _ (App s1 (Ref C.P_read) [ref]) []) =
if agg then ref else Indexer s1 (StringLiteral s1 C.stRefValue) ref
- convert agg (App _ (App _ (App s1 f [arg]) [ref]) []) | isSTFunc C.writeSTRef f =
+ convert agg (App _ (App _ (App s1 (Ref C.P_write) [arg]) [ref]) []) =
if agg then Assignment s1 ref arg else Assignment s1 (Indexer s1 (StringLiteral s1 C.stRefValue) ref) arg
- convert agg (App _ (App _ (App s1 f [func]) [ref]) []) | isSTFunc C.modifySTRef f =
+ convert agg (App _ (App _ (App s1 (Ref C.P_modify) [func]) [ref]) []) =
if agg then Assignment s1 ref (App s1 func [ref]) else Assignment s1 (Indexer s1 (StringLiteral s1 C.stRefValue) ref) (App s1 func [Indexer s1 (StringLiteral s1 C.stRefValue) ref])
convert _ other = other
- -- Check if an expression represents a function in the ST module
- isSTFunc name (Indexer _ (StringLiteral _ name') (Var _ st)) = st == C.st && name == name'
- isSTFunc _ _ = False
-- Find all ST Refs initialized in this block
findSTRefsIn = everything (++) isSTRef
where
- isSTRef (VariableIntroduction _ ident (Just (App _ (App _ f [_]) []))) | isSTFunc C.newSTRef f = [ident]
+ isSTRef (VariableIntroduction _ ident (Just (_, App _ (App _ (Ref C.P_new) [_]) []))) = [ident]
isSTRef _ = []
- -- Find all STRefs used as arguments to readSTRef, writeSTRef, modifySTRef
+ -- Find all STRefs used as arguments to read, write, modify
findAllSTUsagesIn = everything (++) isSTUsage
where
- isSTUsage (App _ (App _ f [ref]) []) | isSTFunc C.readSTRef f = [ref]
- isSTUsage (App _ (App _ (App _ f [_]) [ref]) []) | isSTFunc C.writeSTRef f || isSTFunc C.modifySTRef f = [ref]
+ isSTUsage (App _ (App _ (Ref C.P_read) [ref]) []) = [ref]
+ isSTUsage (App _ (App _ (App _ (Ref f) [_]) [ref]) []) | f `elem` [C.P_write, C.P_modify] = [ref]
isSTUsage _ = []
-- Find all uses of a variable
appearingIn ref = everything (++) isVar
diff --git a/src/Language/PureScript/CoreImp/Optimizer/TCO.hs b/src/Language/PureScript/CoreImp/Optimizer/TCO.hs
index fcf49fcbef..db133f5ac8 100644
--- a/src/Language/PureScript/CoreImp/Optimizer/TCO.hs
+++ b/src/Language/PureScript/CoreImp/Optimizer/TCO.hs
@@ -1,24 +1,30 @@
-- | This module implements tail call elimination.
module Language.PureScript.CoreImp.Optimizer.TCO (tco) where
-import Prelude.Compat
-
-import Data.Text (Text)
-import Language.PureScript.CoreImp.AST
+import Prelude
+
+import Control.Applicative (empty)
+import Control.Monad (guard)
+import Control.Monad.State (State, evalState, gets, modify)
+import Data.Functor (($>))
+import Data.Set qualified as S
+import Data.Text (Text, pack)
+import Language.PureScript.CoreImp.AST (AST(..), InitializerEffects(..), UnaryOperator(..), everything, everywhereTopDownM)
import Language.PureScript.AST.SourcePos (SourceSpan)
import Safe (headDef, tailSafe)
-- | Eliminate tail calls
tco :: AST -> AST
-tco = everywhere convert where
+tco = flip evalState 0 . everywhereTopDownM convert where
tcoVar :: Text -> Text
tcoVar arg = "$tco_var_" <> arg
copyVar :: Text -> Text
copyVar arg = "$copy_" <> arg
- tcoDone :: Text
- tcoDone = "$tco_done"
+ tcoDoneM :: State Int Text
+ tcoDoneM = gets $ \count -> "$tco_done" <>
+ if count == 0 then "" else pack . show $ count
tcoLoop :: Text
tcoLoop = "$tco_loop"
@@ -26,104 +32,160 @@ tco = everywhere convert where
tcoResult :: Text
tcoResult = "$tco_result"
- convert :: AST -> AST
- convert (VariableIntroduction ss name (Just fn@Function {}))
- | isTailRecursive name body'
- = VariableIntroduction ss name (Just (replace (toLoop name outerArgs innerArgs body')))
+ convert :: AST -> State Int AST
+ convert (VariableIntroduction ss name (Just (p, fn@Function {})))
+ | Just trFns <- findTailRecursiveFns name arity body'
+ = VariableIntroduction ss name . Just . (p,) . replace <$> toLoop trFns name arity outerArgs innerArgs body'
where
innerArgs = headDef [] argss
outerArgs = concat . reverse $ tailSafe argss
- (argss, body', replace) = collectAllFunctionArgs [] id fn
- convert js = js
-
- collectAllFunctionArgs :: [[Text]] -> (AST -> AST) -> AST -> ([[Text]], AST, AST -> AST)
- collectAllFunctionArgs allArgs f (Function s1 ident args (Block s2 (body@(Return _ _):_))) =
- collectAllFunctionArgs (args : allArgs) (\b -> f (Function s1 ident (map copyVar args) (Block s2 [b]))) body
- collectAllFunctionArgs allArgs f (Function ss ident args body@(Block _ _)) =
- (args : allArgs, body, f . Function ss ident (map copyVar args))
- collectAllFunctionArgs allArgs f (Return s1 (Function s2 ident args (Block s3 [body]))) =
- collectAllFunctionArgs (args : allArgs) (\b -> f (Return s1 (Function s2 ident (map copyVar args) (Block s3 [b])))) body
- collectAllFunctionArgs allArgs f (Return s1 (Function s2 ident args body@(Block _ _))) =
- (args : allArgs, body, f . Return s1 . Function s2 ident (map copyVar args))
- collectAllFunctionArgs allArgs f body = (allArgs, body, f)
-
- isTailRecursive :: Text -> AST -> Bool
- isTailRecursive ident js = countSelfReferences js > 0 && allInTailPosition js where
- countSelfReferences = everything (+) match where
- match :: AST -> Int
- match (Var _ ident') | ident == ident' = 1
- match _ = 0
+ arity = length argss
+ -- this is the number of calls, not the number of arguments, if there's
+ -- ever a practical difference.
+ (argss, body', replace) = topCollectAllFunctionArgs [] id fn
+ convert js = pure js
+
+ rewriteFunctionsWith :: ([Text] -> [Text]) -> [[Text]] -> (AST -> AST) -> AST -> ([[Text]], AST, AST -> AST)
+ rewriteFunctionsWith argMapper = collectAllFunctionArgs
+ where
+ collectAllFunctionArgs allArgs f (Function s1 ident args (Block s2 (body@(Return _ _):_))) =
+ collectAllFunctionArgs (args : allArgs) (\b -> f (Function s1 ident (argMapper args) (Block s2 [b]))) body
+ collectAllFunctionArgs allArgs f (Function ss ident args body@(Block _ _)) =
+ (args : allArgs, body, f . Function ss ident (argMapper args))
+ collectAllFunctionArgs allArgs f (Return s1 (Function s2 ident args (Block s3 [body]))) =
+ collectAllFunctionArgs (args : allArgs) (\b -> f (Return s1 (Function s2 ident (argMapper args) (Block s3 [b])))) body
+ collectAllFunctionArgs allArgs f (Return s1 (Function s2 ident args body@(Block _ _))) =
+ (args : allArgs, body, f . Return s1 . Function s2 ident (argMapper args))
+ collectAllFunctionArgs allArgs f body = (allArgs, body, f)
+
+ topCollectAllFunctionArgs :: [[Text]] -> (AST -> AST) -> AST -> ([[Text]], AST, AST -> AST)
+ topCollectAllFunctionArgs = rewriteFunctionsWith (map copyVar)
+
+ innerCollectAllFunctionArgs :: [[Text]] -> (AST -> AST) -> AST -> ([[Text]], AST, AST -> AST)
+ innerCollectAllFunctionArgs = rewriteFunctionsWith id
+
+ countReferences :: Text -> AST -> Int
+ countReferences ident = everything (+) match where
+ match :: AST -> Int
+ match (Var _ ident') | ident == ident' = 1
+ match _ = 0
+
+ -- If `ident` is a tail-recursive function, returns a set of identifiers
+ -- that are locally bound to functions participating in the tail recursion.
+ -- Otherwise, returns Nothing.
+ findTailRecursiveFns :: Text -> Int -> AST -> Maybe (S.Set Text)
+ findTailRecursiveFns ident arity js = guard (countReferences ident js > 0) *> go (S.empty, S.singleton (ident, arity))
+ where
+
+ go :: (S.Set Text, S.Set (Text, Int)) -> Maybe (S.Set Text)
+ go (known, required) =
+ case S.minView required of
+ Just (r, required') -> do
+ required'' <- findTailPositionDeps r js
+ go (S.insert (fst r) known, required' <> S.filter (not . (`S.member` known) . fst) required'')
+ Nothing ->
+ pure known
+
+ -- Returns set of identifiers (with their arities) that need to be used
+ -- exclusively in tail calls using their full arity in order for this
+ -- identifier to be considered in tail position (or Nothing if this
+ -- identifier is used somewhere not as a tail call with full arity).
+ findTailPositionDeps :: (Text, Int) -> AST -> Maybe (S.Set (Text, Int))
+ findTailPositionDeps (ident, arity) = allInTailPosition where
+ countSelfReferences = countReferences ident
allInTailPosition (Return _ expr)
- | isSelfCall ident expr = countSelfReferences expr == 1
- | otherwise = countSelfReferences expr == 0
+ | isSelfCall ident arity expr = guard (countSelfReferences expr == 1) $> S.empty
+ | otherwise = guard (countSelfReferences expr == 0) $> S.empty
allInTailPosition (While _ js1 body)
- = countSelfReferences js1 == 0 && allInTailPosition body
+ = guard (countSelfReferences js1 == 0) *> allInTailPosition body
allInTailPosition (For _ _ js1 js2 body)
- = countSelfReferences js1 == 0 && countSelfReferences js2 == 0 && allInTailPosition body
+ = guard (countSelfReferences js1 == 0 && countSelfReferences js2 == 0) *> allInTailPosition body
allInTailPosition (ForIn _ _ js1 body)
- = countSelfReferences js1 == 0 && allInTailPosition body
+ = guard (countSelfReferences js1 == 0) *> allInTailPosition body
allInTailPosition (IfElse _ js1 body el)
- = countSelfReferences js1 == 0 && allInTailPosition body && all allInTailPosition el
+ = guard (countSelfReferences js1 == 0) *> liftA2 mappend (allInTailPosition body) (foldMapA allInTailPosition el)
allInTailPosition (Block _ body)
- = all allInTailPosition body
+ = foldMapA allInTailPosition body
allInTailPosition (Throw _ js1)
- = countSelfReferences js1 == 0
+ = guard (countSelfReferences js1 == 0) $> S.empty
allInTailPosition (ReturnNoResult _)
- = True
- allInTailPosition (VariableIntroduction _ _ js1)
- = all ((== 0) . countSelfReferences) js1
+ = pure S.empty
+ allInTailPosition (VariableIntroduction _ _ Nothing)
+ = pure S.empty
+ allInTailPosition (VariableIntroduction _ ident' (Just (_, js1)))
+ | countSelfReferences js1 == 0 = pure S.empty
+ | Function _ Nothing _ _ <- js1
+ , (argss, body, _) <- innerCollectAllFunctionArgs [] id js1
+ = S.insert (ident', length argss) <$> allInTailPosition body
+ | otherwise = empty
allInTailPosition (Assignment _ _ js1)
- = countSelfReferences js1 == 0
- allInTailPosition (Comment _ _ js1)
+ = guard (countSelfReferences js1 == 0) $> S.empty
+ allInTailPosition (Comment _ js1)
= allInTailPosition js1
allInTailPosition _
- = False
-
- toLoop :: Text -> [Text] -> [Text] -> AST -> AST
- toLoop ident outerArgs innerArgs js =
- Block rootSS $
- map (\arg -> VariableIntroduction rootSS (tcoVar arg) (Just (Var rootSS (copyVar arg)))) outerArgs ++
- [ VariableIntroduction rootSS tcoDone (Just (BooleanLiteral rootSS False))
+ = empty
+
+ toLoop :: S.Set Text -> Text -> Int -> [Text] -> [Text] -> AST -> State Int AST
+ toLoop trFns ident arity outerArgs innerArgs js = do
+ tcoDone <- tcoDoneM
+ modify (+ 1)
+
+ let
+ markDone :: Maybe SourceSpan -> AST
+ markDone ss = Assignment ss (Var ss tcoDone) (BooleanLiteral ss True)
+
+ loopify :: AST -> AST
+ loopify (Return ss ret)
+ | isSelfCall ident arity ret =
+ let
+ allArgumentValues = concat $ collectArgs [] ret
+ in
+ Block ss $
+ zipWith (\val arg ->
+ Assignment ss (Var ss (tcoVar arg)) val) allArgumentValues outerArgs
+ ++ zipWith (\val arg ->
+ Assignment ss (Var ss (copyVar arg)) val) (drop (length outerArgs) allArgumentValues) innerArgs
+ ++ [ ReturnNoResult ss ]
+ | isIndirectSelfCall ret = Return ss ret
+ | otherwise = Block ss [ markDone ss, Return ss ret ]
+ loopify (ReturnNoResult ss) = Block ss [ markDone ss, ReturnNoResult ss ]
+ loopify (While ss cond body) = While ss cond (loopify body)
+ loopify (For ss i js1 js2 body) = For ss i js1 js2 (loopify body)
+ loopify (ForIn ss i js1 body) = ForIn ss i js1 (loopify body)
+ loopify (IfElse ss cond body el) = IfElse ss cond (loopify body) (fmap loopify el)
+ loopify (Block ss body) = Block ss (map loopify body)
+ loopify (VariableIntroduction ss f (Just (p, fn@(Function _ Nothing _ _))))
+ | (_, body, replace) <- innerCollectAllFunctionArgs [] id fn
+ , f `S.member` trFns = VariableIntroduction ss f (Just (p, replace (loopify body)))
+ loopify other = other
+
+ pure $ Block rootSS $
+ map (\arg -> VariableIntroduction rootSS (tcoVar arg) (Just (UnknownEffects, Var rootSS (copyVar arg)))) outerArgs ++
+ [ VariableIntroduction rootSS tcoDone (Just (UnknownEffects, BooleanLiteral rootSS False))
, VariableIntroduction rootSS tcoResult Nothing
, Function rootSS (Just tcoLoop) (outerArgs ++ innerArgs) (Block rootSS [loopify js])
, While rootSS (Unary rootSS Not (Var rootSS tcoDone))
(Block rootSS
- [(Assignment rootSS (Var rootSS tcoResult) (App rootSS (Var rootSS tcoLoop) ((map (Var rootSS . tcoVar) outerArgs) ++ (map (Var rootSS . copyVar) innerArgs))))])
+ [Assignment rootSS (Var rootSS tcoResult) (App rootSS (Var rootSS tcoLoop) (map (Var rootSS . tcoVar) outerArgs ++ map (Var rootSS . copyVar) innerArgs))])
, Return rootSS (Var rootSS tcoResult)
]
where
rootSS = Nothing
- loopify :: AST -> AST
- loopify (Return ss ret)
- | isSelfCall ident ret =
- let
- allArgumentValues = concat $ collectArgs [] ret
- in
- Block ss $
- zipWith (\val arg ->
- Assignment ss (Var ss (tcoVar arg)) val) allArgumentValues outerArgs
- ++ zipWith (\val arg ->
- Assignment ss (Var ss (copyVar arg)) val) (drop (length outerArgs) allArgumentValues) innerArgs
- ++ [ ReturnNoResult ss ]
- | otherwise = Block ss [ markDone ss, Return ss ret ]
- loopify (ReturnNoResult ss) = Block ss [ markDone ss, ReturnNoResult ss ]
- loopify (While ss cond body) = While ss cond (loopify body)
- loopify (For ss i js1 js2 body) = For ss i js1 js2 (loopify body)
- loopify (ForIn ss i js1 body) = ForIn ss i js1 (loopify body)
- loopify (IfElse ss cond body el) = IfElse ss cond (loopify body) (fmap loopify el)
- loopify (Block ss body) = Block ss (map loopify body)
- loopify other = other
-
- markDone :: Maybe SourceSpan -> AST
- markDone ss = Assignment ss (Var ss tcoDone) (BooleanLiteral ss True)
-
collectArgs :: [[AST]] -> AST -> [[AST]]
collectArgs acc (App _ fn args') = collectArgs (args' : acc) fn
collectArgs acc _ = acc
- isSelfCall :: Text -> AST -> Bool
- isSelfCall ident (App _ (Var _ ident') _) = ident == ident'
- isSelfCall ident (App _ fn _) = isSelfCall ident fn
- isSelfCall _ _ = False
+ isIndirectSelfCall :: AST -> Bool
+ isIndirectSelfCall (App _ (Var _ ident') _) = ident' `S.member` trFns
+ isIndirectSelfCall (App _ fn _) = isIndirectSelfCall fn
+ isIndirectSelfCall _ = False
+
+ isSelfCall :: Text -> Int -> AST -> Bool
+ isSelfCall ident 1 (App _ (Var _ ident') _) = ident == ident'
+ isSelfCall ident arity (App _ fn _) = isSelfCall ident (arity - 1) fn
+ isSelfCall _ _ _ = False
+
+foldMapA :: (Applicative f, Monoid w, Foldable t) => (a -> f w) -> t a -> f w
+foldMapA f = foldr (liftA2 mappend . f) (pure mempty)
diff --git a/src/Language/PureScript/CoreImp/Optimizer/Unused.hs b/src/Language/PureScript/CoreImp/Optimizer/Unused.hs
index 4dc5ceb0cf..7b7acd1279 100644
--- a/src/Language/PureScript/CoreImp/Optimizer/Unused.hs
+++ b/src/Language/PureScript/CoreImp/Optimizer/Unused.hs
@@ -2,20 +2,29 @@
module Language.PureScript.CoreImp.Optimizer.Unused
( removeCodeAfterReturnStatements
, removeUndefinedApp
+ , removeUnusedEffectFreeVars
) where
-import Prelude.Compat
+import Prelude
-import Language.PureScript.CoreImp.AST
-import Language.PureScript.CoreImp.Optimizer.Common
-import qualified Language.PureScript.Constants as C
+import Control.Monad (filterM)
+import Data.Monoid (Any(..))
+import Data.Set qualified as S
+import Data.Text (Text)
+
+import Language.PureScript.CoreImp.AST (AST(..), InitializerEffects(..), everything, everywhere)
+import Language.PureScript.CoreImp.Optimizer.Common (removeFromBlock)
+import Language.PureScript.Constants.Prim qualified as C
removeCodeAfterReturnStatements :: AST -> AST
removeCodeAfterReturnStatements = everywhere (removeFromBlock go)
where
go :: [AST] -> [AST]
- go jss | not (any isReturn jss) = jss
- | otherwise = let (body, ret : _) = break isReturn jss in body ++ [ret]
+ go jss =
+ case break isReturn jss of
+ (_, []) -> jss
+ (body, ret : _ ) -> body ++ [ret]
+
isReturn (Return _ _) = True
isReturn (ReturnNoResult _) = True
isReturn _ = False
@@ -23,5 +32,24 @@ removeCodeAfterReturnStatements = everywhere (removeFromBlock go)
removeUndefinedApp :: AST -> AST
removeUndefinedApp = everywhere convert
where
- convert (App ss fn [Var _ arg]) | arg == C.undefined = App ss fn []
+ convert (App ss fn [Var _ C.S_undefined]) = App ss fn []
convert js = js
+
+removeUnusedEffectFreeVars :: [Text] -> [[AST]] -> [[AST]]
+removeUnusedEffectFreeVars exps = loop
+ where
+ expsSet = S.fromList exps
+
+ loop :: [[AST]] -> [[AST]]
+ loop asts = if changed then loop (filter (not . null) asts') else asts
+ where
+ used = expsSet <> foldMap (foldMap (everything (<>) (\case Var _ x -> S.singleton x; _ -> S.empty))) asts
+ (Any changed, asts') = traverse (filterM (anyFalses . isInUsedSet used)) asts
+
+ isInUsedSet :: S.Set Text -> AST -> Bool
+ isInUsedSet used = \case
+ VariableIntroduction _ var (Just (NoEffects, _)) -> var `S.member` used
+ _ -> True
+
+ anyFalses :: Bool -> (Any, Bool)
+ anyFalses x = (Any (not x), x)
diff --git a/src/Language/PureScript/Crash.hs b/src/Language/PureScript/Crash.hs
index 1ce2f09f60..9b04126202 100644
--- a/src/Language/PureScript/Crash.hs
+++ b/src/Language/PureScript/Crash.hs
@@ -1,22 +1,8 @@
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE ImplicitParams #-}
+module Language.PureScript.Crash (HasCallStack, internalError) where
-module Language.PureScript.Crash where
+import Prelude
-import Prelude.Compat
-
-import qualified GHC.Stack
-
--- | A compatibility wrapper for the @GHC.Stack.HasCallStack@ constraint.
-#if __GLASGOW_HASKELL__ >= 800
-type HasCallStack = GHC.Stack.HasCallStack
-#elif MIN_VERSION_GLASGOW_HASKELL(7,10,2,0)
-type HasCallStack = (?callStack :: GHC.Stack.CallStack)
-#else
-import GHC.Exts (Constraint)
--- CallStack wasn't present in GHC 7.10.1
-type HasCallStack = (() :: Constraint)
-#endif
+import GHC.Stack (HasCallStack)
-- | Exit with an error message and a crash report link.
internalError :: HasCallStack => String -> a
@@ -24,4 +10,3 @@ internalError =
error
. ("An internal error occurred during compilation: " ++)
. (++ "\nPlease report this at https://github.com/purescript/purescript/issues")
- . show
diff --git a/src/Language/PureScript/Docs.hs b/src/Language/PureScript/Docs.hs
index 16673c053e..417c98f3d3 100644
--- a/src/Language/PureScript/Docs.hs
+++ b/src/Language/PureScript/Docs.hs
@@ -2,13 +2,13 @@
-- | Data types and functions for rendering generated documentation from
-- PureScript code, in a variety of formats.
-module Language.PureScript.Docs (
- module Docs
-) where
+module Language.PureScript.Docs
+ ( module Docs
+ ) where
+import Language.PureScript.Docs.Collect as Docs
import Language.PureScript.Docs.Convert as Docs
import Language.PureScript.Docs.Prim as Docs
-import Language.PureScript.Docs.ParseInPackage as Docs
import Language.PureScript.Docs.Render as Docs
import Language.PureScript.Docs.RenderedCode as Docs
import Language.PureScript.Docs.Tags as Docs
diff --git a/src/Language/PureScript/Docs/AsHtml.hs b/src/Language/PureScript/Docs/AsHtml.hs
index cc9c3b7302..df7b55f3e3 100644
--- a/src/Language/PureScript/Docs/AsHtml.hs
+++ b/src/Language/PureScript/Docs/AsHtml.hs
@@ -7,7 +7,6 @@ module Language.PureScript.Docs.AsHtml (
HtmlOutputModule(..),
HtmlRenderContext(..),
nullRenderContext,
- declNamespace,
packageAsHtml,
moduleAsHtml,
makeFragment,
@@ -17,28 +16,27 @@ module Language.PureScript.Docs.AsHtml (
import Prelude
import Control.Category ((>>>))
import Control.Monad (unless)
+import Data.Bifunctor (bimap)
import Data.Char (isUpper)
import Data.Either (isRight)
+import Data.List.NonEmpty qualified as NE
import Data.Maybe (fromMaybe)
import Data.Foldable (for_)
import Data.String (fromString)
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
import Text.Blaze.Html5 as H hiding (map)
-import qualified Text.Blaze.Html5.Attributes as A
-import qualified Cheapskate
-import Text.Parsec (eof)
+import Text.Blaze.Html5.Attributes qualified as A
+import Cheapskate qualified
-import qualified Language.PureScript as P
+import Language.PureScript qualified as P
import Language.PureScript.Docs.Types
-import Language.PureScript.Docs.RenderedCode hiding (sp)
-import qualified Language.PureScript.Docs.Render as Render
-
-declNamespace :: Declaration -> Namespace
-declNamespace = declInfoNamespace . declInfo
+import Language.PureScript.Docs.RenderedCode (Link(..), outputWith)
+import Language.PureScript.Docs.Render qualified as Render
+import Language.PureScript.CST qualified as CST
data HtmlOutput a = HtmlOutput
{ htmlIndex :: [(Maybe Char, a)]
@@ -69,7 +67,7 @@ nullRenderContext = HtmlRenderContext
packageAsHtml
:: (InPackage P.ModuleName -> Maybe HtmlRenderContext)
- -> Package a
+ -> Package x
-> HtmlOutput Html
packageAsHtml getHtmlCtx Package{..} =
HtmlOutput indexFile modules
@@ -135,17 +133,19 @@ declAsHtml r d@Declaration{..} = do
h3 ! A.class_ "decl__title clearfix" $ do
a ! A.class_ "decl__anchor" ! A.href (v declFragment) $ "#"
H.span $ text declTitle
- text " " -- prevent browser from treating
- -- declTitle + linkToSource as one word
+ text "\x200b" -- Zero-width space to allow double-click selection of title
for_ declSourceSpan (linkToSource r)
H.div ! A.class_ "decl__body" $ do
case declInfo of
AliasDeclaration fixity alias_ ->
renderAlias fixity alias_
- _ ->
- pre ! A.class_ "decl__signature" $ code $
- codeAsHtml r (Render.renderDeclaration d)
+ _ -> do
+ pre ! A.class_ "decl__signature" $ do
+ for_ declKind $ \kindInfo -> do
+ code ! A.class_ "decl__kind" $ do
+ codeAsHtml r (Render.renderKindSig declTitle kindInfo)
+ code $ codeAsHtml r (Render.renderDeclaration d)
for_ declComments renderMarkdown
@@ -210,21 +210,42 @@ codeAsHtml r = outputWith elemAsHtml
linkToDecl ns target mn (withClass class_ (text name))
NoLink ->
text name
+ Role role ->
+ case role of
+ "nominal" -> renderRole describeNominal "decl__role_nominal"
+ "phantom" -> renderRole describePhantom "decl__role_phantom"
+
+ -- representational is intentionally not rendered
+ "representational" -> toHtml ("" :: Text)
+
+ x -> P.internalError $ "codeAsHtml: unknown value for role annotation: '" <> T.unpack x <> "'"
+ where
+ renderRole hoverTextContent className =
+ H.a ! A.href (v docRepoRolePage) ! A.target (v "_blank") ! A.class_ "decl__role" $ do
+ H.abbr ! A.class_ "decl__role_hover" ! A.title (v hoverTextContent) $ do
+ H.sub ! A.class_ className $ do
+ toHtml ("" :: Text)
+
+ docRepoRolePage =
+ "https://github.com/purescript/documentation/blob/master/language/Roles.md"
+
+ describeNominal =
+ "The 'nominal' role means this argument may not change when coercing the type."
+ describePhantom =
+ "The 'phantom' role means this argument can change freely when coercing the type."
linkToDecl = linkToDeclaration r
startsWithUpper :: Text -> Bool
- startsWithUpper str =
- if T.null str
- then False
- else isUpper (T.index str 0)
+ startsWithUpper str = not (T.null str) && isUpper (T.index str 0)
- isOp = isRight . runParser P.symbol
+ isOp = isRight . runParser CST.parseOperator
- runParser :: P.TokenParser a -> Text -> Either String a
- runParser p' s = either (Left . show) Right $ do
- ts <- P.lex "" s
- P.runTokenParser "" (p' <* eof) ts
+ runParser :: CST.Parser x -> Text -> Either String x
+ runParser p' =
+ bimap (CST.prettyPrintError . NE.head) snd
+ . CST.runTokenParser p'
+ . CST.lex
renderLink :: HtmlRenderContext -> DocLink -> Html -> Html
renderLink r link_@DocLink{..} =
@@ -245,7 +266,6 @@ makeFragment ns = (prefix <>) . escape
prefix = case ns of
TypeLevel -> "#t:"
ValueLevel -> "#v:"
- KindLevel -> "#k:"
-- TODO
escape = id
@@ -317,7 +337,7 @@ v :: Text -> AttributeValue
v = toValue
withClass :: String -> Html -> Html
-withClass className content = H.span ! A.class_ (fromString className) $ content
+withClass className = H.span ! A.class_ (fromString className)
partitionChildren ::
[ChildDeclaration] ->
diff --git a/src/Language/PureScript/Docs/AsMarkdown.hs b/src/Language/PureScript/Docs/AsMarkdown.hs
index 6765217ba5..82139ccbe4 100644
--- a/src/Language/PureScript/Docs/AsMarkdown.hs
+++ b/src/Language/PureScript/Docs/AsMarkdown.hs
@@ -1,41 +1,24 @@
module Language.PureScript.Docs.AsMarkdown
- ( renderModulesAsMarkdown
- , Docs
+ ( Docs
, runDocs
- , modulesAsMarkdown
+ , moduleAsMarkdown
, codeToString
) where
-import Prelude.Compat
+import Prelude
import Control.Monad (unless, zipWithM_)
-import Control.Monad.Error.Class (MonadError)
import Control.Monad.Writer (Writer, tell, execWriter)
import Data.Foldable (for_)
import Data.List (partition)
import Data.Text (Text)
-import qualified Data.Text as T
-
-import Language.PureScript.Docs.RenderedCode
-import Language.PureScript.Docs.Types
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Docs.Convert as Convert
-import qualified Language.PureScript.Docs.Render as Render
-
--- |
--- Take a list of modules and render them all in order, returning a single
--- Markdown-formatted Text.
---
-renderModulesAsMarkdown ::
- (MonadError P.MultipleErrors m) =>
- [P.Module] ->
- m Text
-renderModulesAsMarkdown =
- fmap (runDocs . modulesAsMarkdown) . Convert.convertModules Local
-
-modulesAsMarkdown :: [Module] -> Docs
-modulesAsMarkdown = mapM_ moduleAsMarkdown
+import Data.Text qualified as T
+
+import Language.PureScript.Docs.RenderedCode (RenderedCode, RenderedCodeElement(..), outputWith)
+import Language.PureScript.Docs.Types (ChildDeclaration(..), ChildDeclarationInfo(..), Declaration(..), Module(..), ignorePackage)
+import Language.PureScript qualified as P
+import Language.PureScript.Docs.Render qualified as Render
moduleAsMarkdown :: Module -> Docs
moduleAsMarkdown Module{..} = do
@@ -80,6 +63,9 @@ codeToString = outputWith elemAsMarkdown
elemAsMarkdown Space = " "
elemAsMarkdown (Symbol _ x _) = x
+ -- roles aren't rendered in markdown
+ elemAsMarkdown (Role _) = ""
+
-- fixityAsMarkdown :: P.Fixity -> Docs
-- fixityAsMarkdown (P.Fixity associativity precedence) =
-- tell' $ concat [ "_"
diff --git a/src/Language/PureScript/Docs/Collect.hs b/src/Language/PureScript/Docs/Collect.hs
new file mode 100644
index 0000000000..0da65d2251
--- /dev/null
+++ b/src/Language/PureScript/Docs/Collect.hs
@@ -0,0 +1,225 @@
+
+module Language.PureScript.Docs.Collect
+ ( collectDocs
+ ) where
+
+import Protolude hiding (check)
+
+import Control.Arrow ((&&&))
+import Data.Aeson.BetterErrors qualified as ABE
+import Data.ByteString qualified as BS
+import Data.Map qualified as Map
+import Data.Set qualified as Set
+import Data.Text qualified as T
+import Data.Text.IO qualified as TIO
+import System.FilePath ((>))
+import System.IO.UTF8 (readUTF8FileT, readUTF8FilesT)
+
+import Language.PureScript.Docs.Convert.ReExports (updateReExports)
+import Language.PureScript.Docs.Prim (primModules)
+import Language.PureScript.Docs.Types (InPackage(..), Module(..), asModule, displayPackageError, ignorePackage)
+
+import Language.PureScript.AST qualified as P
+import Language.PureScript.CST qualified as P
+import Language.PureScript.Crash qualified as P
+import Language.PureScript.Errors qualified as P
+import Language.PureScript.Externs qualified as P
+import Language.PureScript.Make qualified as P
+import Language.PureScript.Names qualified as P
+import Language.PureScript.Options qualified as P
+
+import Web.Bower.PackageMeta (PackageName)
+
+-- |
+-- Given a compiler output directory, a list of input PureScript source files,
+-- and a list of dependency PureScript source files, produce documentation for
+-- the input files in the intermediate documentation format. Note that
+-- dependency files are not included in the result.
+--
+-- If the output directory is not up to date with respect to the provided input
+-- and dependency files, the files will be built as if with just the "docs"
+-- codegen target, i.e. "purs compile --codegen docs".
+--
+collectDocs ::
+ forall m.
+ (MonadError P.MultipleErrors m, MonadIO m) =>
+ FilePath ->
+ [FilePath] ->
+ [(PackageName, FilePath)] ->
+ m ([(FilePath, Module)], Map P.ModuleName PackageName)
+collectDocs outputDir inputFiles depsFiles = do
+ (modulePaths, modulesDeps) <- getModulePackageInfo inputFiles depsFiles
+ externs <- compileForDocs outputDir (map fst modulePaths)
+
+ let (withPackage, shouldKeep) =
+ packageDiscriminators modulesDeps
+ let go =
+ operateAndRetag identity modName $ \mns -> do
+ docsModules <- traverse (liftIO . parseDocsJsonFile outputDir) mns
+ addReExports withPackage docsModules externs
+
+ docsModules <- go modulePaths
+ pure (filter (shouldKeep . modName . snd) docsModules, modulesDeps)
+
+ where
+ packageDiscriminators modulesDeps =
+ let
+ shouldKeep mn = isLocal mn && not (P.isBuiltinModuleName mn)
+
+ withPackage :: P.ModuleName -> InPackage P.ModuleName
+ withPackage mn =
+ case Map.lookup mn modulesDeps of
+ Just pkgName -> FromDep pkgName mn
+ Nothing -> Local mn
+
+ isLocal :: P.ModuleName -> Bool
+ isLocal = not . flip Map.member modulesDeps
+ in
+ (withPackage, shouldKeep)
+
+-- |
+-- Compile with just the 'docs' codegen target, writing results into the given
+-- output directory.
+--
+compileForDocs ::
+ forall m.
+ (MonadError P.MultipleErrors m, MonadIO m) =>
+ FilePath ->
+ [FilePath] ->
+ m [P.ExternsFile]
+compileForDocs outputDir inputFiles = do
+ result <- liftIO $ do
+ moduleFiles <- readUTF8FilesT inputFiles
+ fmap fst $ P.runMake testOptions $ do
+ ms <- P.parseModulesFromFiles identity moduleFiles
+ let filePathMap = Map.fromList $ map (\(fp, pm) -> (P.getModuleName $ P.resPartial pm, Right fp)) ms
+ foreigns <- P.inferForeignModules filePathMap
+ let makeActions =
+ (P.buildMakeActions outputDir filePathMap foreigns False)
+ { P.progress = liftIO . TIO.hPutStr stdout . (<> "\n") . P.renderProgressMessage "Compiling documentation for "
+ }
+ P.make makeActions (map snd ms)
+ either throwError return result
+
+ where
+ testOptions :: P.Options
+ testOptions = P.defaultOptions { P.optionsCodegenTargets = Set.singleton P.Docs }
+
+parseDocsJsonFile :: FilePath -> P.ModuleName -> IO Module
+parseDocsJsonFile outputDir mn =
+ let
+ filePath = outputDir > T.unpack (P.runModuleName mn) > "docs.json"
+ in do
+ str <- BS.readFile filePath
+ case ABE.parseStrict asModule str of
+ Right m -> pure m
+ Left err -> P.internalError $
+ "Failed to decode: " ++ filePath ++
+ intercalate "\n" (map T.unpack (ABE.displayError displayPackageError err))
+
+addReExports ::
+ (MonadError P.MultipleErrors m) =>
+ (P.ModuleName -> InPackage P.ModuleName) ->
+ [Module] ->
+ [P.ExternsFile] ->
+ m [Module]
+addReExports withPackage docsModules externs = do
+ -- We add the Prim docs modules here, so that docs generation is still
+ -- possible if the modules we are generating docs for re-export things from
+ -- Prim submodules. Note that the Prim modules do not exist as
+ -- @Language.PureScript.Module@ values because they do not contain anything
+ -- that exists at runtime. However, we have pre-constructed
+ -- @Language.PureScript.Docs.Types.Module@ values for them, which we use
+ -- here.
+ let moduleMap =
+ Map.fromList
+ (map (modName &&& identity)
+ (docsModules ++ primModules))
+
+ let withReExports = updateReExports externs withPackage moduleMap
+ pure (Map.elems withReExports)
+
+-- |
+-- Perform an operation on a list of things which are tagged, and reassociate
+-- the things with their tags afterwards.
+--
+operateAndRetag ::
+ forall m a b key tag.
+ Monad m =>
+ Ord key =>
+ Show key =>
+ (a -> key) ->
+ (b -> key) ->
+ ([a] -> m [b]) ->
+ [(tag, a)] ->
+ m [(tag, b)]
+operateAndRetag keyA keyB operation input =
+ map retag <$> operation (map snd input)
+ where
+ tags :: Map key tag
+ tags = Map.fromList $ map (\(tag, a) -> (keyA a, tag)) input
+
+ findTag :: key -> tag
+ findTag key =
+ case Map.lookup key tags of
+ Just tag -> tag
+ Nothing -> P.internalError ("Missing tag for: " ++ show key)
+
+ retag :: b -> (tag, b)
+ retag b = (findTag (keyB b), b)
+
+-- |
+-- Given:
+--
+-- * A list of local source files
+-- * A list of source files from external dependencies, together with their
+-- package names
+--
+-- This function does the following:
+--
+-- * Partially parse all of the input and dependency source files to get
+-- the module name of each module
+-- * Associate each dependency module with its package name, thereby
+-- distinguishing these from local modules
+-- * Return the file paths paired with the names of the modules they
+-- contain, and a Map of module names to package names for modules which
+-- come from dependencies. If a module does not exist in the map, it can
+-- safely be
+-- assumed to be local.
+getModulePackageInfo ::
+ (MonadError P.MultipleErrors m, MonadIO m) =>
+ [FilePath]
+ -> [(PackageName, FilePath)]
+ -> m ([(FilePath, P.ModuleName)], Map P.ModuleName PackageName)
+getModulePackageInfo inputFiles depsFiles = do
+ inputFiles' <- traverse (readFileAs . Local) inputFiles
+ depsFiles' <- traverse (readFileAs . uncurry FromDep) depsFiles
+
+ moduleNames <- getModuleNames (inputFiles' ++ depsFiles')
+
+ let mnMap =
+ Map.fromList $
+ mapMaybe (\(pkgPath, mn) -> (mn,) <$> getPkgName pkgPath) moduleNames
+
+ pure (map (first ignorePackage) moduleNames, mnMap)
+
+ where
+ getModuleNames ::
+ (MonadError P.MultipleErrors m) =>
+ [(InPackage FilePath, Text)]
+ -> m [(InPackage FilePath, P.ModuleName)]
+ getModuleNames =
+ fmap (map (second (P.getModuleName . P.resPartial)))
+ . either throwError return
+ . P.parseModulesFromFiles ignorePackage
+
+ getPkgName = \case
+ Local _ -> Nothing
+ FromDep pkgName _ -> Just pkgName
+
+ readFileAs ::
+ (MonadIO m) =>
+ InPackage FilePath ->
+ m (InPackage FilePath, Text)
+ readFileAs fi =
+ liftIO . fmap (fi,) $ readUTF8FileT (ignorePackage fi)
diff --git a/src/Language/PureScript/Docs/Convert.hs b/src/Language/PureScript/Docs/Convert.hs
index 79d7160e9a..a7dc1758c7 100644
--- a/src/Language/PureScript/Docs/Convert.hs
+++ b/src/Language/PureScript/Docs/Convert.hs
@@ -2,240 +2,251 @@
-- from Language.PureScript.Docs.
module Language.PureScript.Docs.Convert
- ( convertModules
- , convertModulesWithEnv
- , convertTaggedModulesInPackage
- , convertModulesInPackage
- , convertModulesInPackageWithEnv
+ ( convertModule
) where
import Protolude hiding (check)
-import Control.Arrow ((&&&))
import Control.Category ((>>>))
import Control.Monad.Writer.Strict (runWriterT)
-import Data.Functor (($>))
-import qualified Data.Map as Map
+import Control.Monad.Supply (evalSupplyT)
+import Data.List.NonEmpty qualified as NE
+import Data.Map qualified as Map
import Data.String (String)
+import Data.Text qualified as T
-import Language.PureScript.Docs.Convert.ReExports (updateReExports)
import Language.PureScript.Docs.Convert.Single (convertSingleModule)
-import Language.PureScript.Docs.Prim (primModules)
-import Language.PureScript.Docs.Types
-import qualified Language.PureScript as P
-
-import Web.Bower.PackageMeta (PackageName)
-
-import Text.Parsec (eof)
-
--- |
--- Like convertModuleInPackage, but with the modules tagged by their
--- file paths.
---
-convertTaggedModulesInPackage ::
- (MonadError P.MultipleErrors m) =>
- [(FilePath, P.Module)] ->
- Map P.ModuleName PackageName ->
- m [(FilePath, Module)]
-convertTaggedModulesInPackage taggedModules modulesDeps =
- traverse pairDocModule =<< convertModulesInPackage modules modulesDeps
- where
- modules = map snd taggedModules
-
- moduleNameToFileMap =
- Map.fromList $ swap . fmap P.getModuleName <$> taggedModules
-
- getModuleFile docModule =
- case Map.lookup (modName docModule) moduleNameToFileMap of
- Just filePath -> pure filePath
- Nothing -> throwError . P.errorMessage $
- P.ModuleNotFound $ modName docModule
-
- pairDocModule docModule = (, docModule) <$> getModuleFile docModule
-
--- |
--- Like convertModules, except that it takes a list of modules, together with
--- their dependency status, and discards dependency modules in the resulting
--- documentation.
---
-convertModulesInPackage ::
- (MonadError P.MultipleErrors m) =>
- [P.Module] ->
- Map P.ModuleName PackageName ->
- m [Module]
-convertModulesInPackage modules modulesDeps =
- fmap fst (convertModulesInPackageWithEnv modules modulesDeps)
-
-convertModulesInPackageWithEnv ::
- (MonadError P.MultipleErrors m) =>
- [P.Module] ->
- Map P.ModuleName PackageName ->
- m ([Module], P.Env)
-convertModulesInPackageWithEnv modules modulesDeps =
- go modules
- where
- go =
- convertModulesWithEnv withPackage
- >>> fmap (first (filter (shouldKeep . modName)))
-
- shouldKeep mn = isLocal mn && not (P.isBuiltinModuleName mn)
-
- withPackage :: P.ModuleName -> InPackage P.ModuleName
- withPackage mn =
- case Map.lookup mn modulesDeps of
- Just pkgName -> FromDep pkgName mn
- Nothing -> Local mn
-
- isLocal :: P.ModuleName -> Bool
- isLocal = not . flip Map.member modulesDeps
-
--- |
--- Convert a group of modules to the intermediate format, designed for
--- producing documentation from.
---
--- Note that the whole module dependency graph must be included in the list; if
--- some modules import things from other modules, then those modules must also
--- be included.
---
--- For value declarations, if explicit type signatures are omitted, or a
--- wildcard type is used, then we typecheck the modules and use the inferred
--- types.
---
-convertModules ::
- (MonadError P.MultipleErrors m) =>
- (P.ModuleName -> InPackage P.ModuleName) ->
- [P.Module] ->
- m [Module]
-convertModules withPackage =
- fmap fst . convertModulesWithEnv withPackage
-
-convertModulesWithEnv ::
- (MonadError P.MultipleErrors m) =>
- (P.ModuleName -> InPackage P.ModuleName) ->
- [P.Module] ->
- m ([Module], P.Env)
-convertModulesWithEnv withPackage =
- P.sortModules P.moduleSignature
- >>> fmap (fst >>> map P.importPrim)
- >=> convertSorted withPackage
+import Language.PureScript.Docs.Types (Declaration(..), DeclarationInfo(..), KindInfo(..), Module(..), Type')
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.AST qualified as P
+import Language.PureScript.Crash qualified as P
+import Language.PureScript.Errors qualified as P
+import Language.PureScript.Externs qualified as P
+import Language.PureScript.Environment qualified as P
+import Language.PureScript.Names qualified as P
+import Language.PureScript.Roles qualified as P
+import Language.PureScript.Sugar qualified as P
+import Language.PureScript.Types qualified as P
+import Language.PureScript.Constants.Prim qualified as Prim
+import Language.PureScript.Sugar (RebracketCaller(CalledByDocs))
-- |
--- Convert a sorted list of modules, returning both the list of converted
--- modules and the Env produced during desugaring.
+-- Convert a single module to a Docs.Module, making use of a pre-existing
+-- type-checking environment in order to fill in any missing types. Note that
+-- re-exports will not be included.
--
-convertSorted ::
- (MonadError P.MultipleErrors m) =>
- (P.ModuleName -> InPackage P.ModuleName) ->
- [P.Module] ->
- m ([Module], P.Env)
-convertSorted withPackage modules = do
- (env, convertedModules) <- second (map convertSingleModule) <$> partiallyDesugar modules
-
- modulesWithTypes <- typeCheckIfNecessary modules convertedModules
-
- -- We add the Prim docs modules here, so that docs generation is still
- -- possible if the modules we are generating docs for re-export things from
- -- Prim submodules. Note that the Prim modules do not exist as
- -- @Language.PureScript.Module@ values because they do not contain anything
- -- that exists at runtime. However, we have pre-constructed
- -- @Language.PureScript.Docs.Types.Module@ values for them, which we use
- -- here.
- let moduleMap =
- Map.fromList
- (map (modName &&& identity)
- (modulesWithTypes ++ primModules))
-
- -- Set up the traversal order for re-export handling so that Prim modules
- -- come first.
- let primModuleNames = Map.keys P.primEnv
- let traversalOrder = primModuleNames ++ map P.getModuleName modules
- let withReExports = updateReExports env traversalOrder withPackage moduleMap
- pure (Map.elems withReExports, env)
+convertModule ::
+ MonadError P.MultipleErrors m =>
+ [P.ExternsFile] ->
+ P.Env ->
+ P.Environment ->
+ P.Module ->
+ m Module
+convertModule externs env checkEnv =
+ fmap (insertValueTypesAndAdjustKinds checkEnv . convertSingleModule) . partiallyDesugar externs env
-- |
--- If any exported value declarations have either wildcard type signatures, or
--- none at all, then typecheck in order to fill them in with the inferred
--- types.
+-- Convert FFI declarations into `DataDeclaration` so that the declaration's
+-- roles (if any) can annotate the generated type parameter names.
--
-typeCheckIfNecessary ::
- (MonadError P.MultipleErrors m) =>
- [P.Module] ->
- [Module] ->
- m [Module]
-typeCheckIfNecessary modules convertedModules =
- if any hasWildcards convertedModules
- then go
- else pure convertedModules
-
- where
- hasWildcards = any (isWild . declInfo) . modDeclarations
- isWild (ValueDeclaration P.TypeWildcard{}) = True
- isWild _ = False
-
- go = do
- checkEnv <- snd <$> typeCheck modules
- pure (map (insertValueTypes checkEnv) convertedModules)
-
--- |
--- Typechecks all the modules together. Also returns the final 'P.Environment',
--- which is useful for adding in inferred types where explicit declarations
--- were not provided.
+-- Inserts all data declarations inferred roles if none were specified
+-- explicitly.
--
-typeCheck ::
- (MonadError P.MultipleErrors m) =>
- [P.Module] ->
- m ([P.Module], P.Environment)
-typeCheck =
- (P.desugar [] >=> check)
- >>> fmap (second P.checkEnv)
- >>> P.evalSupplyT 0
- >>> ignoreWarnings
-
- where
- check ms =
- runStateT
- (traverse P.typeCheckModule ms)
- (P.emptyCheckState P.initEnvironment)
-
- ignoreWarnings =
- fmap fst . runWriterT
-
--- |
-- Updates all the types of the ValueDeclarations inside the module based on
-- their types inside the given Environment.
--
-insertValueTypes ::
+-- Removes explicit kind signatures if they are "uninteresting."
+--
+-- Inserts inferred kind signatures into the corresponding declarations
+-- if no kind signature was declared explicitly and the kind
+-- signature is "interesting."
+--
+insertValueTypesAndAdjustKinds ::
P.Environment -> Module -> Module
-insertValueTypes env m =
- m { modDeclarations = map go (modDeclarations m) }
+insertValueTypesAndAdjustKinds env m =
+ m { modDeclarations = map (go . insertInferredRoles . convertFFIDecl) (modDeclarations m) }
where
- go (d@Declaration { declInfo = ValueDeclaration P.TypeWildcard{} }) =
+ -- Convert FFI declarations into data declaration
+ -- by generating the type parameters' names based on its kind signature.
+ -- Note: `Prim` modules' docs don't go through this conversion process
+ -- so `ExternDataDeclaration` values will still exist beyond this point.
+ convertFFIDecl d@Declaration { declInfo = ExternDataDeclaration kind roles } =
+ d { declInfo = DataDeclaration P.Data (genTypeParams kind) roles
+ , declKind = Just (KindInfo P.DataSig kind)
+ }
+
+ convertFFIDecl other = other
+
+ insertInferredRoles d@Declaration { declInfo = DataDeclaration dataDeclType args [] } =
+ d { declInfo = DataDeclaration dataDeclType args inferredRoles }
+
+ where
+ inferredRoles :: [P.Role]
+ inferredRoles = do
+ let key = P.Qualified (P.ByModuleName (modName m)) (P.ProperName (declTitle d))
+ case Map.lookup key (P.types env) of
+ Just (_, tyKind) -> case tyKind of
+ P.DataType _ tySourceTyRole _ ->
+ map (\(_,_,r) -> r) tySourceTyRole
+ P.ExternData rs ->
+ rs
+ _ ->
+ []
+ Nothing ->
+ err $ "type not found: " <> show key
+
+ insertInferredRoles other =
+ other
+
+ -- Given an FFI declaration like this
+ -- ```
+ -- foreign import data Foo
+ -- :: forall a b c d
+ -- . MyKind a b
+ -- -> OtherKind c d
+ -- -> Symbol
+ -- -> (Type -> Type)
+ -- -> (Type) -- unneeded parens a developer typo
+ -- -> Type
+ -- ```
+ -- Return a list of values, one for each implicit type parameter
+ -- of `(tX, Nothing)` where `X` refers to the index of he parameter
+ -- in that list, matching the values expected by `Render.toTypeVar`
+ genTypeParams :: Type' -> [(Text, Maybe Type')]
+ genTypeParams kind = do
+ let n = countParams 0 kind
+ map (\(i :: Int) -> ("t" <> T.pack (show i), Nothing)) $ take n [0..]
+ where
+ countParams :: Int -> Type' -> Int
+ countParams acc = \case
+ P.ForAll _ _ _ _ rest _ ->
+ countParams acc rest
+
+ P.TypeApp _ f a | isFunctionApplication f ->
+ countParams (acc + 1) a
+
+ P.ParensInType _ ty ->
+ countParams acc ty
+
+ _ ->
+ acc
+
+ isFunctionApplication = \case
+ P.TypeApp _ (P.TypeConstructor () Prim.Function) _ -> True
+ P.ParensInType _ ty -> isFunctionApplication ty
+ _ -> False
+
+ -- insert value types
+ go d@Declaration { declInfo = ValueDeclaration P.TypeWildcard{} } =
let
- ident = parseIdent (declTitle d)
+ ident = P.Ident . CST.getIdent . CST.nameValue . parseIdent $ declTitle d
ty = lookupName ident
in
d { declInfo = ValueDeclaration (ty $> ()) }
+
+ go d@Declaration{..} | Just keyword <- extractKeyword declInfo =
+ case declKind of
+ Just ks ->
+ -- hide explicit kind signatures that are "uninteresting"
+ if isUninteresting keyword $ kiKind ks
+ then d { declKind = Nothing }
+ else d
+ Nothing ->
+ -- insert inferred kinds so long as they are "interesting"
+ insertInferredKind d declTitle keyword
+
go other =
other
parseIdent =
- either (err . ("failed to parse Ident: " ++)) identity . runParser P.parseIdent
+ either (err . ("failed to parse Ident: " ++)) identity . runParser CST.parseIdent
lookupName name =
- let key = P.Qualified (Just (modName m)) name
+ let key = P.Qualified (P.ByModuleName (modName m)) name
in case Map.lookup key (P.names env) of
Just (ty, _, _) ->
ty
Nothing ->
err ("name not found: " ++ show key)
+ -- Extracts the keyword for a declaration (if there is one)
+ extractKeyword :: DeclarationInfo -> Maybe P.KindSignatureFor
+ extractKeyword = \case
+ DataDeclaration dataDeclType _ _ -> Just $ case dataDeclType of
+ P.Data -> P.DataSig
+ P.Newtype -> P.NewtypeSig
+ TypeSynonymDeclaration _ _ -> Just P.TypeSynonymSig
+ TypeClassDeclaration _ _ _ -> Just P.ClassSig
+ _ -> Nothing
+
+ -- Returns True if the kind signature is "uninteresting", which
+ -- is a kind that follows this form:
+ -- - `Type`
+ -- - `Constraint` (class declaration only)
+ -- - `Type -> K` where `K` is an "uninteresting" kind
+ isUninteresting
+ :: P.KindSignatureFor -> Type' -> Bool
+ isUninteresting keyword = \case
+ -- `Type -> ...`
+ P.TypeApp _ f a | isTypeAppFunctionType f -> isUninteresting keyword a
+ P.ParensInType _ ty -> isUninteresting keyword ty
+ x -> isKindPrimType x || (isClassKeyword && isKindPrimConstraint x)
+ where
+ isClassKeyword = case keyword of
+ P.ClassSig -> True
+ _ -> False
+
+ isTypeAppFunctionType = \case
+ P.TypeApp _ f a -> isKindFunction f && isKindPrimType a
+ P.ParensInType _ ty -> isTypeAppFunctionType ty
+ _ -> False
+
+ isKindFunction = isTypeConstructor Prim.Function
+ isKindPrimType = isTypeConstructor Prim.Type
+ isKindPrimConstraint = isTypeConstructor Prim.Constraint
+
+ isTypeConstructor k = \case
+ P.TypeConstructor _ k' -> k' == k
+ P.ParensInType _ ty -> isTypeConstructor k ty
+ _ -> False
+
+ insertInferredKind :: Declaration -> Text -> P.KindSignatureFor -> Declaration
+ insertInferredKind d name keyword =
+ let
+ key = P.Qualified (P.ByModuleName (modName m)) (P.ProperName name)
+ in case Map.lookup key (P.types env) of
+ Just (inferredKind, _) ->
+ if isUninteresting keyword inferredKind'
+ then d
+ else d { declKind = Just $ KindInfo
+ { kiKeyword = keyword
+ , kiKind = dropTypeSortAnnotation inferredKind'
+ }
+ }
+ where
+ inferredKind' = inferredKind $> ()
+
+ -- Note: the below change to the final kind used is intentionally
+ -- NOT being done for explicit kind signatures:
+ --
+ -- changes `forall (k :: Type). k -> ...`
+ -- to `forall k . k -> ...`
+ dropTypeSortAnnotation = \case
+ P.ForAll sa vis txt (Just (P.TypeConstructor _ Prim.Type)) rest skol ->
+ P.ForAll sa vis txt Nothing (dropTypeSortAnnotation rest) skol
+ rest -> rest
+
+ Nothing ->
+ err ("type not found: " ++ show key)
+
err msg =
P.internalError ("Docs.Convert.insertValueTypes: " ++ msg)
-runParser :: P.TokenParser a -> Text -> Either String a
-runParser p s = either (Left . show) Right $ do
- ts <- P.lex "" s
- P.runTokenParser "" (p <* eof) ts
+runParser :: CST.Parser a -> Text -> Either String a
+runParser p =
+ bimap (CST.prettyPrintError . NE.head) snd
+ . CST.runTokenParser p
+ . CST.lex
-- |
-- Partially desugar modules so that they are suitable for extracting
@@ -243,20 +254,20 @@ runParser p s = either (Left . show) Right $ do
--
partiallyDesugar ::
(MonadError P.MultipleErrors m) =>
- [P.Module]
- -> m (P.Env, [P.Module])
-partiallyDesugar = P.evalSupplyT 0 . desugar'
+ [P.ExternsFile] ->
+ P.Env ->
+ P.Module ->
+ m P.Module
+partiallyDesugar externs env = evalSupplyT 0 . desugar'
where
desugar' =
- traverse P.desugarDoModule
- >=> traverse P.desugarAdoModule
- >=> map P.desugarLetPatternModule
- >>> traverse P.desugarCasesModule
- >=> traverse P.desugarTypeDeclarationsModule
- >=> ignoreWarnings . P.desugarImportsWithEnv []
- >=> traverse (P.rebracketFiltered isInstanceDecl [])
-
- ignoreWarnings = fmap fst . runWriterT
-
- isInstanceDecl (P.TypeInstanceDeclaration {}) = True
+ P.desugarDoModule
+ >=> P.desugarAdoModule
+ >=> P.desugarLetPatternModule
+ >>> P.desugarCasesModule
+ >=> P.desugarTypeDeclarationsModule
+ >=> fmap fst . runWriterT . flip evalStateT (env, mempty) . P.desugarImports
+ >=> P.rebracketFiltered CalledByDocs isInstanceDecl externs
+
+ isInstanceDecl P.TypeInstanceDeclaration {} = True
isInstanceDecl _ = False
diff --git a/src/Language/PureScript/Docs/Convert/ReExports.hs b/src/Language/PureScript/Docs/Convert/ReExports.hs
index 1ad897ecd9..600b343a5b 100644
--- a/src/Language/PureScript/Docs/Convert/ReExports.hs
+++ b/src/Language/PureScript/Docs/Convert/ReExports.hs
@@ -2,49 +2,57 @@ module Language.PureScript.Docs.Convert.ReExports
( updateReExports
) where
-import Prelude.Compat
+import Prelude
import Control.Arrow ((&&&), first, second)
-import Control.Monad
+import Control.Monad (foldM, (<=<))
import Control.Monad.Reader.Class (MonadReader, ask)
import Control.Monad.State.Class (MonadState, gets, modify)
import Control.Monad.Trans.Reader (runReaderT)
import Control.Monad.Trans.State.Strict (execState)
-import Data.Either
+import Data.Either (partitionEithers)
+import Data.Foldable (fold, traverse_)
import Data.Map (Map)
import Data.Maybe (mapMaybe)
-import qualified Data.Map as Map
+import Data.Map qualified as Map
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
import Language.PureScript.Docs.Types
-import qualified Language.PureScript as P
+
+import Language.PureScript.AST qualified as P
+import Language.PureScript.Crash qualified as P
+import Language.PureScript.Errors qualified as P
+import Language.PureScript.Externs qualified as P
+import Language.PureScript.ModuleDependencies qualified as P
+import Language.PureScript.Names qualified as P
+import Language.PureScript.Types qualified as P
+
-- |
-- Given:
--
--- * The Imports/Exports Env
--- * An order to traverse the modules (which must be topological)
+-- * A list of externs files
+-- * A function for tagging a module with the package it comes from
-- * A map of modules, indexed by their names, which are assumed to not
-- have their re-exports listed yet
--
-- This function adds all the missing re-exports.
--
updateReExports ::
- P.Env ->
- [P.ModuleName] ->
+ [P.ExternsFile] ->
(P.ModuleName -> InPackage P.ModuleName) ->
Map P.ModuleName Module ->
Map P.ModuleName Module
-updateReExports env order withPackage = execState action
+updateReExports externs withPackage = execState action
where
action =
- void (traverse go order)
+ traverse_ go traversalOrder
go mn = do
mdl <- lookup' mn
- reExports <- getReExports env mn
+ reExports <- getReExports externsEnv mn
let mdl' = mdl { modReExports = map (first withPackage) reExports }
modify (Map.insert mn mdl')
@@ -56,6 +64,25 @@ updateReExports env order withPackage = execState action
Nothing ->
internalError ("Module missing: " ++ T.unpack (P.runModuleName mn))
+ externsEnv :: Map P.ModuleName P.ExternsFile
+ externsEnv = Map.fromList $ map (P.efModuleName &&& id) externs
+
+ traversalOrder :: [P.ModuleName]
+ traversalOrder =
+ case P.sortModules P.Transitive externsSignature externs of
+ Right (es, _) -> map P.efModuleName es
+ Left errs -> internalError $
+ "failed to sortModules: " ++
+ P.prettyPrintMultipleErrors P.defaultPPEOptions errs
+
+ externsSignature :: P.ExternsFile -> P.ModuleSignature
+ externsSignature ef =
+ P.ModuleSignature
+ { P.sigSourceSpan = P.efSourceSpan ef
+ , P.sigModuleName = P.efModuleName ef
+ , P.sigImports = map (\ei -> (P.eiModule ei, P.nullSourceSpan)) (P.efImports ef)
+ }
+
-- |
-- Collect all of the re-exported declarations for a single module.
--
@@ -65,19 +92,20 @@ updateReExports env order withPackage = execState action
--
getReExports ::
(MonadState (Map P.ModuleName Module) m) =>
- P.Env ->
+ Map P.ModuleName P.ExternsFile ->
P.ModuleName ->
m [(P.ModuleName, [Declaration])]
-getReExports env mn =
- case Map.lookup mn env of
+getReExports externsEnv mn =
+ case Map.lookup mn externsEnv of
Nothing ->
internalError ("Module missing: " ++ T.unpack (P.runModuleName mn))
- Just (_, _, exports) -> do
- allExports <- runReaderT (collectDeclarations exports) mn
- pure (filter notLocal allExports)
+ Just P.ExternsFile { P.efExports = refs } -> do
+ let reExpRefs = mapMaybe toReExportRef refs
+ runReaderT (collectDeclarations reExpRefs) mn
- where
- notLocal = (/= mn) . fst
+toReExportRef :: P.DeclarationRef -> Maybe (P.ExportSource, P.DeclarationRef)
+toReExportRef (P.ReExportRef _ source ref) = Just (source, ref)
+toReExportRef _ = Nothing
-- |
-- Assemble a list of declarations re-exported from a particular module, based
@@ -100,28 +128,26 @@ getReExports env mn =
--
collectDeclarations :: forall m.
(MonadState (Map P.ModuleName Module) m, MonadReader P.ModuleName m) =>
- P.Exports ->
+ [(P.ExportSource, P.DeclarationRef)] ->
m [(P.ModuleName, [Declaration])]
-collectDeclarations exports = do
+collectDeclarations reExports = do
valsAndMembers <- collect lookupValueDeclaration expVals
valOps <- collect lookupValueOpDeclaration expValOps
typeClasses <- collect lookupTypeClassDeclaration expTCs
types <- collect lookupTypeDeclaration expTypes
typeOps <- collect lookupTypeOpDeclaration expTypeOps
- kinds <- collect lookupKindDeclaration expKinds
(vals, classes) <- handleTypeClassMembers valsAndMembers typeClasses
let filteredTypes = filterDataConstructors expCtors types
let filteredClasses = filterTypeClassMembers (Map.keys expVals) classes
- pure (Map.toList (Map.unionsWith (<>) [filteredTypes, filteredClasses, vals, valOps, typeOps, kinds]))
+ pure (Map.toList (Map.unionsWith (<>) [filteredTypes, filteredClasses, vals, valOps, typeOps]))
where
collect
- :: (Eq a, Show a)
- => (P.ModuleName -> a -> m (P.ModuleName, [b]))
+ :: (P.ModuleName -> a -> m (P.ModuleName, [b]))
-> Map a P.ExportSource
-> m (Map P.ModuleName [b])
collect lookup' exps = do
@@ -129,15 +155,31 @@ collectDeclarations exports = do
decls <- traverse (uncurry (flip lookup')) reExps
return $ Map.fromListWith (<>) decls
- expVals = P.exportedValues exports
- expValOps = P.exportedValueOps exports
- expTypes = Map.map snd (P.exportedTypes exports)
- expTypeOps = P.exportedTypeOps exports
- expCtors = concatMap fst (Map.elems (P.exportedTypes exports))
- expTCs = P.exportedTypeClasses exports
- expKinds = P.exportedKinds exports
+ expVals :: Map P.Ident P.ExportSource
+ expVals = mkExportMap P.getValueRef
+
+ expValOps :: Map (P.OpName 'P.ValueOpName) P.ExportSource
+ expValOps = mkExportMap P.getValueOpRef
+
+ expTCs :: Map (P.ProperName 'P.ClassName) P.ExportSource
+ expTCs = mkExportMap P.getTypeClassRef
+
+ expTypes :: Map (P.ProperName 'P.TypeName) P.ExportSource
+ expTypes = mkExportMap (fmap fst . P.getTypeRef)
+
+ expTypeOps :: Map (P.OpName 'P.TypeOpName) P.ExportSource
+ expTypeOps = mkExportMap P.getTypeOpRef
+
+ mkExportMap :: Ord name => (P.DeclarationRef -> Maybe name) -> Map name P.ExportSource
+ mkExportMap f =
+ Map.fromList $
+ mapMaybe (\(exportSrc, ref) -> (,exportSrc) <$> f ref) reExports
+
+ expCtors :: [P.ProperName 'P.ConstructorName]
+ expCtors = concatMap (fold . (snd <=< P.getTypeRef . snd)) reExports
lookupValueDeclaration ::
+ forall m.
(MonadState (Map P.ModuleName Module) m,
MonadReader P.ModuleName m) =>
P.ModuleName ->
@@ -149,6 +191,7 @@ lookupValueDeclaration importedFrom ident = do
rs =
filter (\d -> declTitle d == P.showIdent ident
&& (isValue d || isValueAlias d)) decls
+ errOther :: Show a => a -> m b
errOther other =
internalErrorInModule
("lookupValueDeclaration: unexpected result:\n" ++
@@ -267,24 +310,6 @@ lookupTypeClassDeclaration importedFrom tyClass = do
++ show tyClass ++ ": "
++ (unlines . map show) other)
-lookupKindDeclaration
- :: (MonadState (Map P.ModuleName Module) m, MonadReader P.ModuleName m)
- => P.ModuleName
- -> P.ProperName 'P.KindName
- -> m (P.ModuleName, [Declaration])
-lookupKindDeclaration importedFrom kind = do
- decls <- lookupModuleDeclarations "lookupKindDeclaration" importedFrom
- let
- ds = filter (\d -> declTitle d == P.runProperName kind
- && isKind d)
- decls
- case ds of
- [d] ->
- pure (importedFrom, [d])
- other ->
- internalErrorInModule
- ("lookupKindDeclaration: unexpected result: " ++ show other)
-
-- |
-- Get the full list of declarations for a particular module out of the
-- state, or raise an internal error if it is not there.
@@ -408,6 +433,7 @@ handleEnv TypeClassEnv{..} =
, declSourceSpan = cdeclSourceSpan
, declChildren = []
, declInfo = ValueDeclaration (addConstraint constraint typ)
+ , declKind = Nothing
}
_ ->
internalErrorInModule
@@ -415,7 +441,7 @@ handleEnv TypeClassEnv{..} =
++ T.unpack cdeclTitle)
addConstraint constraint =
- P.quantify . P.moveQuantifiersToFront . P.ConstrainedType () constraint
+ P.quantify . P.moveQuantifiersToFront () . P.ConstrainedType () constraint
splitMap :: Map k (v1, v2) -> (Map k v1, Map k v2)
splitMap = fmap fst &&& fmap snd
@@ -485,7 +511,7 @@ typeClassConstraintFor :: Declaration -> Maybe Constraint'
typeClassConstraintFor Declaration{..} =
case declInfo of
TypeClassDeclaration tyArgs _ _ ->
- Just (P.Constraint () (P.Qualified Nothing (P.ProperName declTitle)) (mkConstraint tyArgs) Nothing)
+ Just (P.Constraint () (P.Qualified P.ByNullSourcePos (P.ProperName declTitle)) [] (mkConstraint tyArgs) Nothing)
_ ->
Nothing
where
diff --git a/src/Language/PureScript/Docs/Convert/Single.hs b/src/Language/PureScript/Docs/Convert/Single.hs
index b4ed0b3b03..b3b15e7b4f 100644
--- a/src/Language/PureScript/Docs/Convert/Single.hs
+++ b/src/Language/PureScript/Docs/Convert/Single.hs
@@ -7,11 +7,16 @@ import Protolude hiding (moduleName)
import Control.Category ((>>>))
-import Data.Functor (($>))
-import qualified Data.Text as T
+import Data.Text qualified as T
-import Language.PureScript.Docs.Types
-import qualified Language.PureScript as P
+import Language.PureScript.Docs.Types (ChildDeclaration(..), ChildDeclarationInfo(..), Declaration(..), DeclarationInfo(..), KindInfo(..), Module(..), Type', convertFundepsToStrings, isType, isTypeClass)
+
+import Language.PureScript.AST qualified as P
+import Language.PureScript.Comments qualified as P
+import Language.PureScript.Crash qualified as P
+import Language.PureScript.Names qualified as P
+import Language.PureScript.Roles qualified as P
+import Language.PureScript.Types qualified as P
-- |
-- Convert a single Module, but ignore re-exports; any re-exported types or
@@ -62,8 +67,20 @@ type IntermediateDeclaration
-- since they appear at the top level in the AST, and since they might need to
-- appear as children in two places (for example, if a data type defined in a
-- module is an instance of a type class also defined in that module).
+--
+-- The AugmentKindSig constructor allows us to add a kind signature
+-- to its corresponding declaration. Comments for both declarations
+-- are also merged together.
data DeclarationAugment
= AugmentChild ChildDeclaration
+ | AugmentKindSig KindSignatureInfo
+ | AugmentRole (Maybe Text) [P.Role]
+
+data KindSignatureInfo = KindSignatureInfo
+ { ksiComments :: Maybe Text
+ , ksiKeyword :: P.KindSignatureFor
+ , ksiKind :: Type'
+ }
-- | Augment top-level declarations; the second pass. See the comments under
-- the type synonym IntermediateDeclaration for more information.
@@ -82,18 +99,46 @@ augmentDeclarations (partitionEithers -> (augments, toplevels)) =
augmentWith (AugmentChild child) d =
d { declChildren = declChildren d ++ [child] }
+ augmentWith (AugmentKindSig KindSignatureInfo{..}) d =
+ d { declComments = mergeComments ksiComments $ declComments d
+ , declKind = Just $ KindInfo { kiKeyword = ksiKeyword, kiKind = ksiKind }
+ }
+ augmentWith (AugmentRole comms roles) d =
+ d { declComments = mergeComments (declComments d) comms
+ , declInfo = insertRoles
+ }
+ where
+ insertRoles = case declInfo d of
+ DataDeclaration dataDeclType args [] ->
+ DataDeclaration dataDeclType args roles
+ DataDeclaration _ _ _ ->
+ P.internalError "augmentWith: could not add a second role declaration to a data declaration"
+
+ ExternDataDeclaration kind [] ->
+ ExternDataDeclaration kind roles
+ ExternDataDeclaration _ _ ->
+ P.internalError "augmentWith: could not add a second role declaration to an FFI declaration"
+
+ _ -> P.internalError "augmentWith: could not add role to declaration"
+
+ mergeComments :: Maybe Text -> Maybe Text -> Maybe Text
+ mergeComments Nothing bot = bot
+ mergeComments top Nothing = top
+ mergeComments (Just topComs) (Just bottomComs) =
+ Just $ topComs <> "\n" <> bottomComs
getDeclarationTitle :: P.Declaration -> Maybe Text
getDeclarationTitle (P.ValueDeclaration vd) = Just (P.showIdent (P.valdeclIdent vd))
getDeclarationTitle (P.ExternDeclaration _ name _) = Just (P.showIdent name)
getDeclarationTitle (P.DataDeclaration _ _ name _ _) = Just (P.runProperName name)
getDeclarationTitle (P.ExternDataDeclaration _ name _) = Just (P.runProperName name)
-getDeclarationTitle (P.ExternKindDeclaration _ name) = Just (P.runProperName name)
getDeclarationTitle (P.TypeSynonymDeclaration _ name _ _) = Just (P.runProperName name)
getDeclarationTitle (P.TypeClassDeclaration _ name _ _ _ _) = Just (P.runProperName name)
-getDeclarationTitle (P.TypeInstanceDeclaration _ _ _ name _ _ _ _) = Just (P.showIdent name)
+getDeclarationTitle (P.TypeInstanceDeclaration _ _ _ _ name _ _ _ _) = Just $ either (const "") P.showIdent name
getDeclarationTitle (P.TypeFixityDeclaration _ _ _ op) = Just ("type " <> P.showOp op)
getDeclarationTitle (P.ValueFixityDeclaration _ _ _ op) = Just (P.showOp op)
+getDeclarationTitle (P.KindDeclaration _ _ n _) = Just (P.runProperName n)
+getDeclarationTitle (P.RoleDeclaration P.RoleDeclarationData{..}) = Just (P.runProperName rdeclIdent)
getDeclarationTitle _ = Nothing
-- | Create a basic Declaration value.
@@ -104,6 +149,7 @@ mkDeclaration (ss, com) title info =
, declSourceSpan = Just ss -- TODO: make this non-optional when we next break the format
, declChildren = []
, declInfo = info
+ , declKind = Nothing -- kind sigs are added in augment pass
}
basicDeclaration :: P.SourceAnn -> Text -> DeclarationInfo -> Maybe IntermediateDeclaration
@@ -115,21 +161,20 @@ convertDeclaration (P.ValueDecl sa _ _ _ [P.MkUnguarded (P.TypedValue _ _ ty)])
convertDeclaration (P.ValueDecl sa _ _ _ _) title =
-- If no explicit type declaration was provided, insert a wildcard, so that
-- the actual type will be added during type checking.
- basicDeclaration sa title (ValueDeclaration (P.TypeWildcard () Nothing))
+ basicDeclaration sa title (ValueDeclaration (P.TypeWildcard () P.UnnamedWildcard))
convertDeclaration (P.ExternDeclaration sa _ ty) title =
basicDeclaration sa title (ValueDeclaration (ty $> ()))
convertDeclaration (P.DataDeclaration sa dtype _ args ctors) title =
Just (Right (mkDeclaration sa title info) { declChildren = children })
where
- info = DataDeclaration dtype (fmap (fmap (fmap ($> ()))) args)
+ info = DataDeclaration dtype (fmap (fmap (fmap ($> ()))) args) []
children = map convertCtor ctors
- convertCtor :: (P.ProperName 'P.ConstructorName, [(P.Ident, P.SourceType)]) -> ChildDeclaration
- convertCtor (ctor', tys) =
- ChildDeclaration (P.runProperName ctor') Nothing Nothing (ChildDataConstructor (fmap (($> ()) . snd) tys))
+ convertCtor :: P.DataConstructorDeclaration -> ChildDeclaration
+ convertCtor P.DataConstructorDeclaration{..} =
+ let (sourceSpan, comments) = dataCtorAnn
+ in ChildDeclaration (P.runProperName dataCtorName) (convertComments comments) (Just sourceSpan) (ChildDataConstructor (fmap (($> ()) . snd) dataCtorFields))
convertDeclaration (P.ExternDataDeclaration sa _ kind') title =
- basicDeclaration sa title (ExternDataDeclaration (kind' $> ()))
-convertDeclaration (P.ExternKindDeclaration sa _) title =
- basicDeclaration sa title ExternKindDeclaration
+ basicDeclaration sa title (ExternDataDeclaration (kind' $> ()) [])
convertDeclaration (P.TypeSynonymDeclaration sa _ args ty) title =
basicDeclaration sa title (TypeSynonymDeclaration (fmap (fmap (fmap ($> ()))) args) (ty $> ()))
convertDeclaration (P.TypeClassDeclaration sa _ args implies fundeps ds) title =
@@ -142,7 +187,7 @@ convertDeclaration (P.TypeClassDeclaration sa _ args implies fundeps ds) title =
ChildDeclaration (P.showIdent ident') (convertComments com) (Just ss) (ChildTypeClassMember (ty $> ()))
convertClassMember _ =
P.internalError "convertDeclaration: Invalid argument to convertClassMember."
-convertDeclaration (P.TypeInstanceDeclaration (ss, com) _ _ _ constraints className tys _) title =
+convertDeclaration (P.TypeInstanceDeclaration (ss, com) _ _ _ _ constraints className tys _) title =
Just (Left ((classNameString, AugmentClass) : map (, AugmentType) typeNameStrings, AugmentChild childDecl))
where
classNameString = unQual className
@@ -158,6 +203,16 @@ convertDeclaration (P.ValueFixityDeclaration sa fixity (P.Qualified mn alias) _)
Just . Right $ mkDeclaration sa title (AliasDeclaration fixity (P.Qualified mn (Right alias)))
convertDeclaration (P.TypeFixityDeclaration sa fixity (P.Qualified mn alias) _) title =
Just . Right $ mkDeclaration sa title (AliasDeclaration fixity (P.Qualified mn (Left alias)))
+convertDeclaration (P.KindDeclaration sa keyword _ kind) title =
+ Just $ Left ([(title, AugmentType), (title, AugmentClass)], AugmentKindSig ksi)
+ where
+ comms = convertComments $ snd sa
+ ksi = KindSignatureInfo { ksiComments = comms, ksiKeyword = keyword, ksiKind = kind $> () }
+convertDeclaration (P.RoleDeclaration P.RoleDeclarationData{..}) title =
+ Just $ Left ([(title, AugmentType)], AugmentRole comms rdeclRoles)
+ where
+ comms = convertComments $ snd rdeclSourceAnn
+
convertDeclaration _ _ = Nothing
convertComments :: [P.Comment] -> Maybe Text
diff --git a/src/Language/PureScript/Docs/ParseInPackage.hs b/src/Language/PureScript/Docs/ParseInPackage.hs
deleted file mode 100644
index 86ea0dc745..0000000000
--- a/src/Language/PureScript/Docs/ParseInPackage.hs
+++ /dev/null
@@ -1,75 +0,0 @@
-module Language.PureScript.Docs.ParseInPackage
- ( parseFilesInPackages
- ) where
-
-import Protolude
-
-import qualified Data.Map as M
-
-import Language.PureScript.Docs.Types
-import qualified Language.PureScript as P
-import qualified Language.PureScript.CST as CST
-import System.IO.UTF8 (readUTF8FileT)
-import Web.Bower.PackageMeta (PackageName)
-
--- |
--- Given:
---
--- * A list of local source files
--- * A list of source files from external dependencies, together with their
--- package names
---
--- This function does the following:
---
--- * Parse all of the input and dependency source files
--- * Associate each dependency module with its package name, thereby
--- distinguishing these from local modules
--- * Return the paths paired with parsed modules, and a Map of module names
--- to package names for modules which come from dependencies.
--- If a module does not exist in the map, it can safely be assumed to be
--- local.
-parseFilesInPackages ::
- (MonadError P.MultipleErrors m, MonadIO m) =>
- [FilePath]
- -> [(PackageName, FilePath)]
- -> m ([(FilePath, P.Module)], Map P.ModuleName PackageName)
-parseFilesInPackages inputFiles depsFiles = do
- inputFiles' <- traverse (readFileAs . Local) inputFiles
- depsFiles' <- traverse (readFileAs . uncurry FromDep) depsFiles
-
- modules <- parse (inputFiles' ++ depsFiles')
-
- let mnMap = M.fromList (mapMaybe (\(inpkg, m) -> (P.getModuleName m,) <$> inPkgToMaybe inpkg) modules)
-
- pure (map (first fileInfoToString) modules, mnMap)
-
- where
- parse ::
- (MonadError P.MultipleErrors m) =>
- [(FileInfo, Text)]
- -> m [(FileInfo, P.Module)]
- parse =
- throwLeft . CST.parseFromFiles fileInfoToString
-
- inPkgToMaybe = \case
- Local _ -> Nothing
- FromDep pkgName _ -> Just pkgName
-
-throwLeft :: (MonadError l m) => Either l r -> m r
-throwLeft = either throwError return
-
--- | Specifies whether a PureScript source file is considered as:
---
--- 1) with the `Local` constructor, a target source file, i.e., we want to see
--- its modules in the output
--- 2) with the `FromDep` constructor, a dependencies source file, i.e. we do
--- not want its modules in the output; it is there to enable desugaring, and
--- to ensure that links between modules are constructed correctly.
-type FileInfo = InPackage FilePath
-
-fileInfoToString :: FileInfo -> FilePath
-fileInfoToString (Local fn) = fn
-fileInfoToString (FromDep _ fn) = fn
-
-readFileAs :: (MonadIO m) => FileInfo -> m (FileInfo, Text)
-readFileAs fi = liftIO . fmap ((fi,)) $ readUTF8FileT (ignorePackage fi)
diff --git a/src/Language/PureScript/Docs/Prim.hs b/src/Language/PureScript/Docs/Prim.hs
index 9d1b04df78..801a64bc6f 100644
--- a/src/Language/PureScript/Docs/Prim.hs
+++ b/src/Language/PureScript/Docs/Prim.hs
@@ -6,23 +6,28 @@ module Language.PureScript.Docs.Prim
, primModules
) where
-import Prelude.Compat hiding (fail)
+import Prelude hiding (fail)
import Data.Functor (($>))
import Data.Text (Text)
-import qualified Data.Text as T
-import qualified Data.Map as Map
-import qualified Data.Set as Set
-import Language.PureScript.Docs.Types
-import qualified Language.PureScript as P
+import Data.Text qualified as T
+import Data.Map qualified as Map
+import Language.PureScript.Docs.Types (Declaration(..), DeclarationInfo(..), Module(..), Type', convertFundepsToStrings)
+
+import Language.PureScript.Constants.Prim qualified as P
+import Language.PureScript.Crash qualified as P
+import Language.PureScript.Environment qualified as P
+import Language.PureScript.Names qualified as P
primModules :: [Module]
primModules =
[ primDocsModule
, primBooleanDocsModule
+ , primCoerceDocsModule
, primOrderingDocsModule
, primRowDocsModule
, primRowListDocsModule
, primSymbolDocsModule
+ , primIntDocsModule
, primTypeErrorDocsModule
]
@@ -32,7 +37,7 @@ primDocsModule = Module
, modComments = Just $ T.unlines
[ "The `Prim` module is embedded in the PureScript compiler in order to provide compiler support for certain types — for example, value literals, or syntax sugar. It is implicitly imported unqualified in every module except those that list it as a qualified import."
, ""
- , "`Prim` does not include additional built-in types and kinds that are defined deeper in the compiler. For example, row kinds (e.g. `# Type`, which is the kind of types such as `(name :: String, age :: Int)`), Type wildcards (e.g. `f :: _ -> Int`), and Quantified Types. Rather, these are documented in [the PureScript language reference](https://github.com/purescript/documentation/blob/master/language/Types.md)."
+ , "`Prim` does not include additional built-in types and kinds that are defined deeper in the compiler such as Type wildcards (e.g. `f :: _ -> Int`) and Quantified Types. Rather, these are documented in [the PureScript language reference](https://github.com/purescript/documentation/blob/master/language/Types.md)."
]
, modDeclarations =
[ function
@@ -45,7 +50,9 @@ primDocsModule = Module
, boolean
, partial
, kindType
+ , kindConstraint
, kindSymbol
+ , kindRow
]
, modReExports = []
}
@@ -55,13 +62,22 @@ primBooleanDocsModule = Module
{ modName = P.moduleNameFromString "Prim.Boolean"
, modComments = Just "The Prim.Boolean module is embedded in the PureScript compiler. Unlike `Prim`, it is not imported implicitly. It contains a type level `Boolean` data structure."
, modDeclarations =
- [ kindBoolean
- , booleanTrue
+ [ booleanTrue
, booleanFalse
]
, modReExports = []
}
+primCoerceDocsModule :: Module
+primCoerceDocsModule = Module
+ { modName = P.moduleNameFromString "Prim.Coerce"
+ , modComments = Just "The Prim.Coerce module is embedded in the PureScript compiler. Unlike `Prim`, it is not imported implicitly. It contains an automatically solved type class for coercing types that have provably-identical runtime representations with [purescript-safe-coerce](https://pursuit.purescript.org/packages/purescript-safe-coerce)."
+ , modDeclarations =
+ [ coercible
+ ]
+ , modReExports = []
+ }
+
primOrderingDocsModule :: Module
primOrderingDocsModule = Module
{ modName = P.moduleNameFromString "Prim.Ordering"
@@ -113,6 +129,19 @@ primSymbolDocsModule = Module
, modReExports = []
}
+primIntDocsModule :: Module
+primIntDocsModule = Module
+ { modName = P.moduleNameFromString "Prim.Int"
+ , modComments = Just "The Prim.Int module is embedded in the PureScript compiler. Unlike `Prim`, it is not imported implicitly. It contains automatically solved type classes for working with type-level intural numbers."
+ , modDeclarations =
+ [ intAdd
+ , intCompare
+ , intMul
+ , intToString
+ ]
+ , modReExports = []
+ }
+
primTypeErrorDocsModule :: Module
primTypeErrorDocsModule = Module
{ modName = P.moduleNameFromString "Prim.TypeError"
@@ -130,46 +159,23 @@ primTypeErrorDocsModule = Module
, modReExports = []
}
-type NameGen a = Text -> P.Qualified (P.ProperName a)
-
-unsafeLookupOf
+unsafeLookup
:: forall v (a :: P.ProperNameType)
- . NameGen a
- -> Map.Map (P.Qualified (P.ProperName a)) v
+ . Map.Map (P.Qualified (P.ProperName a)) v
-> String
- -> Text
+ -> P.Qualified (P.ProperName a)
-> v
-unsafeLookupOf k m errorMsg name = go name
+unsafeLookup m errorMsg name = go name
where
- go = fromJust' . flip Map.lookup m . k
+ go = fromJust' . flip Map.lookup m
fromJust' (Just x) = x
- fromJust' _ = P.internalError $ errorMsg ++ show name
-
-primKindOf
- :: NameGen 'P.KindName
- -> Text
- -> Text
- -> Declaration
-primKindOf g title comments =
- if Set.member (g title) P.allPrimKinds
- then Declaration
- { declTitle = title
- , declComments = Just comments
- , declSourceSpan = Nothing
- , declChildren = []
- , declInfo = ExternKindDeclaration
- }
- else P.internalError $ "Docs.Prim: No such Prim kind: " ++ T.unpack title
-
-primKind :: Text -> Text -> Declaration
-primKind = primKindOf P.primName
-
-lookupPrimTypeKindOf
- :: NameGen 'P.TypeName
- -> Text
- -> Kind'
-lookupPrimTypeKindOf k = ($> ()) . fst . unsafeLookupOf k
+ fromJust' _ = P.internalError $ errorMsg ++ show (P.runProperName $ P.disqualify name)
+
+lookupPrimTypeKind
+ :: P.Qualified (P.ProperName 'P.TypeName)
+ -> Type'
+lookupPrimTypeKind = ($> ()) . fst . unsafeLookup
( P.primTypes <>
P.primBooleanTypes <>
P.primOrderingTypes <>
@@ -178,64 +184,91 @@ lookupPrimTypeKindOf k = ($> ()) . fst . unsafeLookupOf k
P.primTypeErrorTypes
) "Docs.Prim: No such Prim type: "
-primType :: Text -> Text -> Declaration
-primType = primTypeOf P.primName
-
-primTypeOf :: NameGen 'P.TypeName -> Text -> Text -> Declaration
-primTypeOf gen title comments = Declaration
- { declTitle = title
+primType :: P.Qualified (P.ProperName 'P.TypeName) -> Text -> Declaration
+primType tn comments = Declaration
+ { declTitle = P.runProperName $ P.disqualify tn
, declComments = Just comments
, declSourceSpan = Nothing
, declChildren = []
- , declInfo = ExternDataDeclaration (lookupPrimTypeKindOf gen title)
+ , declInfo = ExternDataDeclaration (lookupPrimTypeKind tn) []
+ , declKind = Nothing
}
-- | Lookup the TypeClassData of a Prim class. This function is specifically
-- not exported because it is partial.
-lookupPrimClassOf :: NameGen 'P.ClassName -> Text -> P.TypeClassData
-lookupPrimClassOf g = unsafeLookupOf g
+lookupPrimClass :: P.Qualified (P.ProperName 'P.ClassName) -> P.TypeClassData
+lookupPrimClass = unsafeLookup
( P.primClasses <>
+ P.primCoerceClasses <>
P.primRowClasses <>
P.primRowListClasses <>
P.primSymbolClasses <>
+ P.primIntClasses <>
P.primTypeErrorClasses
) "Docs.Prim: No such Prim class: "
-primClass :: Text -> Text -> Declaration
-primClass = primClassOf P.primName
-
-primClassOf :: NameGen 'P.ClassName -> Text -> Text -> Declaration
-primClassOf gen title comments = Declaration
- { declTitle = title
+primClass :: P.Qualified (P.ProperName 'P.ClassName) -> Text -> Declaration
+primClass cn comments = Declaration
+ { declTitle = P.runProperName $ P.disqualify cn
, declComments = Just comments
, declSourceSpan = Nothing
, declChildren = []
, declInfo =
let
- tcd = lookupPrimClassOf gen title
- args = fmap (fmap (fmap ($> ()))) $ P.typeClassArguments tcd
- superclasses = fmap ($> ()) $ P.typeClassSuperclasses tcd
+ tcd = lookupPrimClass cn
+ args = fmap (fmap ($> ())) <$> P.typeClassArguments tcd
+ superclasses = ($> ()) <$> P.typeClassSuperclasses tcd
fundeps = convertFundepsToStrings args (P.typeClassDependencies tcd)
in
TypeClassDeclaration args superclasses fundeps
+ , declKind = Nothing
}
kindType :: Declaration
-kindType = primKind "Type" $ T.unlines
+kindType = primType P.Type $ T.unlines
[ "`Type` is the kind of all proper types: those that classify value-level terms."
, "For example the type `Boolean` has kind `Type`; denoted by `Boolean :: Type`."
]
+kindConstraint :: Declaration
+kindConstraint = primType P.Constraint $ T.unlines
+ [ "`Constraint` is the kind of type class constraints."
+ , "For example, a type class declaration like this:"
+ , ""
+ , " class Semigroup a where"
+ , " append :: a -> a -> a"
+ , ""
+ , "has the kind signature:"
+ , ""
+ , " class Semigroup :: Type -> Constraint"
+ ]
+
kindSymbol :: Declaration
-kindSymbol = primKind "Symbol" $ T.unlines
+kindSymbol = primType P.Symbol $ T.unlines
[ "`Symbol` is the kind of type-level strings."
, ""
, "Construct types of this kind using the same literal syntax as documented"
, "for strings."
+ , ""
+ , " type Hello :: Symbol"
+ , " type Hello = \"Hello, world\""
+ , ""
+ ]
+
+kindRow :: Declaration
+kindRow = primType P.Row $ T.unlines
+ [ "`Row` is the kind constructor of label-indexed types which map type-level strings to other types."
+ , "The most common use of `Row` is `Row Type`, a row mapping labels to basic (of kind `Type`) types:"
+ , ""
+ , " type ExampleRow :: Row Type"
+ , " type ExampleRow = ( name :: String, values :: Array Int )"
+ , ""
+ , "This is the kind of `Row` expected by the `Record` type constructor."
+ , "More advanced row kinds like `Row (Type -> Type)` are used much less frequently."
]
function :: Declaration
-function = primType "Function" $ T.unlines
+function = primType P.Function $ T.unlines
[ "A function, which takes values of the type specified by the first type"
, "parameter, and returns values of the type specified by the second."
, "In the JavaScript backend, this is a standard JavaScript Function."
@@ -254,7 +287,7 @@ function = primType "Function" $ T.unlines
]
array :: Declaration
-array = primType "Array" $ T.unlines
+array = primType P.Array $ T.unlines
[ "An Array: a data structure supporting efficient random access. In"
, "the JavaScript backend, values of this type are represented as JavaScript"
, "Arrays at runtime."
@@ -265,7 +298,7 @@ array = primType "Array" $ T.unlines
]
record :: Declaration
-record = primType "Record" $ T.unlines
+record = primType P.Record $ T.unlines
[ "The type of records whose fields are known at compile time. In the"
, "JavaScript backend, values of this type are represented as JavaScript"
, "Objects at runtime."
@@ -287,27 +320,53 @@ record = primType "Record" $ T.unlines
]
number :: Declaration
-number = primType "Number" $ T.unlines
+number = primType P.Number $ T.unlines
[ "A double precision floating point number (IEEE 754)."
, ""
- , "Construct values of this type with literals:"
+ , "Construct values of this type with literals."
+ , "Negative literals must be wrapped in parentheses if the negation sign could be mistaken"
+ , "for an infix operator:"
, ""
- , " y = 35.23 :: Number"
- , " z = 1.224e6 :: Number"
+ , " x = 35.23 :: Number"
+ , " y = -1.224e6 :: Number"
+ , " z = exp (-1.0) :: Number"
]
int :: Declaration
-int = primType "Int" $ T.unlines
- [ "A 32-bit signed integer. See the purescript-integers package for details"
+int = primType P.Int $ T.unlines
+ [ "A 32-bit signed integer. See the `purescript-integers` package for details"
, "of how this is accomplished when compiling to JavaScript."
, ""
- , "Construct values of this type with literals:"
+ , "Construct values of this type with literals. Hexadecimal syntax is supported."
+ , "Negative literals must be wrapped in parentheses if the negation sign could be mistaken"
+ , "for an infix operator:"
+ , ""
+ , " x = -23 :: Int"
+ , " y = 0x17 :: Int"
+ , " z = complement (-24) :: Int"
+ , ""
+ , "Integers used as types are considered to have kind `Int`."
+ , "Unlike value-level `Int`s, which must be representable as a 32-bit signed integer,"
+ , "type-level `Int`s are unbounded. Hexadecimal support is also supported at the type level."
, ""
- , " x = 23 :: Int"
+ , " type One :: Int"
+ , " type One = 1"
+ , " "
+ , " type Beyond32BitSignedInt :: Int"
+ , " type Beyond32BitSignedInt = 2147483648"
+ , " "
+ , " type HexInt :: Int"
+ , " type HexInt = 0x17"
+ , ""
+ , "Negative integer literals at the type level must be"
+ , "wrapped in parentheses if the negation sign could be mistaken for an infix operator."
+ , ""
+ , " type NegativeOne = -1"
+ , " foo :: Proxy (-1) -> ..."
]
string :: Declaration
-string = primType "String" $ T.unlines
+string = primType P.String $ T.unlines
[ "A String. As in JavaScript, String values represent sequences of UTF-16"
, "code units, which are not required to form a valid encoding of Unicode"
, "text (for example, lone surrogates are permitted)."
@@ -316,77 +375,139 @@ string = primType "String" $ T.unlines
, ""
, " x = \"hello, world\" :: String"
, ""
- , "Multi-line string literals are also supported with triple quotes (`\"\"\"`)."
+ , "Multi-line string literals are also supported with triple quotes (`\"\"\"`):"
+ , ""
+ , " x = \"\"\"multi"
+ , " line\"\"\""
+ , ""
+ , "At the type level, string literals represent types with kind `Symbol`."
+ , "These types will have kind `String` in a future release:"
+ , ""
+ , " type Hello :: Symbol"
+ , " type Hello = \"Hello, world\""
]
char :: Declaration
-char = primType "Char" $ T.unlines
- [ "A single character (UTF-16 code unit). The JavaScript representation is a"
- , "normal String, which is guaranteed to contain one code unit. This means"
- , "that astral plane characters (i.e. those with code point values greater"
- , "than 0xFFFF) cannot be represented as Char values."
- , ""
- , "Construct values of this type with literals, using single quotes `'`:"
- , ""
- , " x = 'a' :: Char"
- ]
+char = primType P.Char $ T.unlines
+ [ "A single character (UTF-16 code unit). The JavaScript representation is a"
+ , "normal `String`, which is guaranteed to contain one code unit. This means"
+ , "that astral plane characters (i.e. those with code point values greater"
+ , "than `0xFFFF`) cannot be represented as `Char` values."
+ , ""
+ , "Construct values of this type with literals, using single quotes `'`:"
+ , ""
+ , " x = 'a' :: Char"
+ ]
boolean :: Declaration
-boolean = primType "Boolean" $ T.unlines
+boolean = primType P.Boolean $ T.unlines
[ "A JavaScript Boolean value."
, ""
, "Construct values of this type with the literals `true` and `false`."
+ , ""
+ , "The `True` and `False` types defined in `Prim.Boolean` have this type as their kind."
]
partial :: Declaration
-partial = primClass "Partial" $ T.unlines
+partial = primClass P.Partial $ T.unlines
[ "The Partial type class is used to indicate that a function is *partial,*"
, "that is, it is not defined for all inputs. In practice, attempting to use"
, "a partial function with a bad input will usually cause an error to be"
, "thrown, although it is not safe to assume that this will happen in all"
, "cases. For more information, see"
- , "[the Partial type class guide](https://github.com/purescript/documentation/blob/master/guides/The-Partial-type-class.md)."
- ]
-
-kindBoolean :: Declaration
-kindBoolean = primKindOf (P.primSubName "Boolean") "Boolean" $ T.unlines
- [ "The `Boolean` kind provides True/False types at the type level"
+ , "[purescript-partial](https://pursuit.purescript.org/packages/purescript-partial/)."
]
booleanTrue :: Declaration
-booleanTrue = primTypeOf (P.primSubName "Boolean") "True" $ T.unlines
+booleanTrue = primType P.True $ T.unlines
[ "The 'True' boolean type."
]
booleanFalse :: Declaration
-booleanFalse = primTypeOf (P.primSubName "Boolean") "False" $ T.unlines
+booleanFalse = primType P.False $ T.unlines
[ "The 'False' boolean type."
]
+coercible :: Declaration
+coercible = primClass P.Coercible $ T.unlines
+ [ "Coercible is a two-parameter type class that has instances for types `a`"
+ , "and `b` if the compiler can infer that they have the same representation."
+ , "Coercible constraints are solved according to the following rules:"
+ , ""
+ , "* _reflexivity_, any type has the same representation as itself:"
+ , "`Coercible a a` holds."
+ , ""
+ , "* _symmetry_, if a type `a` can be coerced to some other type `b`, then `b`"
+ , "can also be coerced back to `a`: `Coercible a b` implies `Coercible b a`."
+ , ""
+ , "* _transitivity_, if a type `a` can be coerced to some other type `b` which"
+ , "can be coerced to some other type `c`, then `a` can also be coerced to `c`:"
+ , "`Coercible a b` and `Coercible b c` imply `Coercible a c`."
+ , ""
+ , "* Newtypes can be freely wrapped and unwrapped when their constructor is"
+ , "in scope:"
+ , ""
+ , " newtype Age = Age Int"
+ , ""
+ , "`Coercible Int Age` and `Coercible Age Int` hold since `Age` has the same"
+ , "runtime representation than `Int`."
+ , ""
+ , "Newtype constructors have to be in scope to preserve abstraction. It's"
+ , "common to declare a newtype to encode some invariants (non emptiness of"
+ , "arrays with `Data.Array.NonEmpty.NonEmptyArray` for example), hide its"
+ , "constructor and export smart constructors instead. Without this restriction,"
+ , "the guarantees provided by such newtypes would be void."
+ , ""
+ , "* If none of the above are applicable, two types of kind `Type` may be"
+ , "coercible, but only if their heads are the same. For example,"
+ , "`Coercible (Maybe a) (Either a b)` does not hold because `Maybe` and"
+ , "`Either` are different. Those types don't share a common runtime"
+ , "representation so coercing between them would be unsafe. In addition their"
+ , "arguments may need to be identical or coercible, depending on the _roles_"
+ , "of the head's type parameters. Roles are documented in [the PureScript"
+ , "language reference](https://github.com/purescript/documentation/blob/master/language/Roles.md)."
+ , ""
+ , "Coercible being polykinded, we can also coerce more than types of kind `Type`:"
+ , ""
+ , "* Rows are coercible when they have the same labels, when the corresponding"
+ , "pairs of types are coercible and when their tails are coercible:"
+ , "`Coercible ( label :: a | r ) ( label :: b | s )` holds when"
+ , "`Coercible a b` and `Coercible r s` do. Closed rows cannot be coerced to"
+ , "open rows."
+ , ""
+ , "* Higher kinded types are coercible if they are coercible when fully"
+ , "saturated: `Coercible (f :: _ -> Type) (g :: _ -> Type)` holds when"
+ , "`Coercible (f a) (g a)` does."
+ , ""
+ , "This rule may seem puzzling since there is no term of type `_ -> Type` to"
+ , "apply `coerce` to, but it is necessary when coercing types with higher"
+ , "kinded parameters."
+ ]
+
kindOrdering :: Declaration
-kindOrdering = primKindOf (P.primSubName "Ordering") "Ordering" $ T.unlines
- [ "The `Ordering` kind represents the three possibilites of comparing two"
+kindOrdering = primType P.TypeOrdering $ T.unlines
+ [ "The `Ordering` kind represents the three possibilities of comparing two"
, "types of the same kind: `LT` (less than), `EQ` (equal to), and"
, "`GT` (greater than)."
]
orderingLT :: Declaration
-orderingLT = primTypeOf (P.primSubName "Ordering") "LT" $ T.unlines
+orderingLT = primType P.LT $ T.unlines
[ "The 'less than' ordering type."
]
orderingEQ :: Declaration
-orderingEQ = primTypeOf (P.primSubName "Ordering") "EQ" $ T.unlines
+orderingEQ = primType P.EQ $ T.unlines
[ "The 'equal to' ordering type."
]
orderingGT :: Declaration
-orderingGT = primTypeOf (P.primSubName "Ordering") "GT" $ T.unlines
+orderingGT = primType P.GT $ T.unlines
[ "The 'greater than' ordering type."
]
union :: Declaration
-union = primClassOf (P.primSubName "Row") "Union" $ T.unlines
+union = primClass P.RowUnion $ T.unlines
[ "The Union type class is used to compute the union of two rows of types"
, "(left-biased, including duplicates)."
, ""
@@ -394,66 +515,87 @@ union = primClassOf (P.primSubName "Row") "Union" $ T.unlines
]
nub :: Declaration
-nub = primClassOf (P.primSubName "Row") "Nub" $ T.unlines
+nub = primClass P.RowNub $ T.unlines
[ "The Nub type class is used to remove duplicate labels from rows."
]
lacks :: Declaration
-lacks = primClassOf (P.primSubName "Row") "Lacks" $ T.unlines
+lacks = primClass P.RowLacks $ T.unlines
[ "The Lacks type class asserts that a label does not occur in a given row."
]
rowCons :: Declaration
-rowCons = primClassOf (P.primSubName "Row") "Cons" $ T.unlines
+rowCons = primClass P.RowCons $ T.unlines
[ "The Cons type class is a 4-way relation which asserts that one row of"
, "types can be obtained from another by inserting a new label/type pair on"
, "the left."
]
kindRowList :: Declaration
-kindRowList = primKindOf (P.primSubName "RowList") "RowList" $ T.unlines
+kindRowList = primType P.RowList $ T.unlines
[ "A type level list representation of a row of types."
]
rowListCons :: Declaration
-rowListCons = primTypeOf (P.primSubName "RowList") "Cons" $ T.unlines
+rowListCons = primType P.RowListCons $ T.unlines
[ "Constructs a new `RowList` from a label, a type, and an existing tail"
, "`RowList`. E.g: `Cons \"x\" Int (Cons \"y\" Int Nil)`."
]
rowListNil :: Declaration
-rowListNil = primTypeOf (P.primSubName "RowList") "Nil" $ T.unlines
+rowListNil = primType P.RowListNil $ T.unlines
[ "The empty `RowList`."
]
rowToList :: Declaration
-rowToList = primClassOf (P.primSubName "RowList") "RowToList" $ T.unlines
+rowToList = primClass P.RowToList $ T.unlines
[ "Compiler solved type class for generating a `RowList` from a closed row"
, "of types. Entries are sorted by label and duplicates are preserved in"
, "the order they appeared in the row."
]
symbolAppend :: Declaration
-symbolAppend = primClassOf (P.primSubName "Symbol") "Append" $ T.unlines
+symbolAppend = primClass P.SymbolAppend $ T.unlines
[ "Compiler solved type class for appending `Symbol`s together."
]
symbolCompare :: Declaration
-symbolCompare = primClassOf (P.primSubName "Symbol") "Compare" $ T.unlines
+symbolCompare = primClass P.SymbolCompare $ T.unlines
[ "Compiler solved type class for comparing two `Symbol`s."
, "Produces an `Ordering`."
]
symbolCons :: Declaration
-symbolCons = primClassOf (P.primSubName "Symbol") "Cons" $ T.unlines
+symbolCons = primClass P.SymbolCons $ T.unlines
[ "Compiler solved type class for either splitting up a symbol into its"
, "head and tail or for combining a head and tail into a new symbol."
, "Requires the head to be a single character and the combined string"
, "cannot be empty."
]
+intAdd :: Declaration
+intAdd = primClass P.IntAdd $ T.unlines
+ [ "Compiler solved type class for adding type-level `Int`s."
+ ]
+
+intCompare :: Declaration
+intCompare = primClass P.IntCompare $ T.unlines
+ [ "Compiler solved type class for comparing two type-level `Int`s."
+ , "Produces an `Ordering`."
+ ]
+
+intMul :: Declaration
+intMul = primClass P.IntMul $ T.unlines
+ [ "Compiler solved type class for multiplying type-level `Int`s."
+ ]
+
+intToString :: Declaration
+intToString = primClass P.IntToString $ T.unlines
+ [ "Compiler solved type class for converting a type-level `Int` into a type-level `String` (i.e. `Symbol`)."
+ ]
+
fail :: Declaration
-fail = primClassOf (P.primSubName "TypeError") "Fail" $ T.unlines
+fail = primClass P.Fail $ T.unlines
[ "The Fail type class is part of the custom type errors feature. To provide"
, "a custom type error when someone tries to use a particular instance,"
, "write that instance out with a Fail constraint."
@@ -463,7 +605,7 @@ fail = primClassOf (P.primSubName "TypeError") "Fail" $ T.unlines
]
warn :: Declaration
-warn = primClassOf (P.primSubName "TypeError") "Warn" $ T.unlines
+warn = primClass P.Warn $ T.unlines
[ "The Warn type class allows a custom compiler warning to be displayed."
, ""
, "For more information, see"
@@ -471,15 +613,15 @@ warn = primClassOf (P.primSubName "TypeError") "Warn" $ T.unlines
]
kindDoc :: Declaration
-kindDoc = primKindOf (P.primSubName "TypeError") "Doc" $ T.unlines
+kindDoc = primType P.Doc $ T.unlines
[ "`Doc` is the kind of type-level documents."
, ""
- , "This kind is used with the `Fail` and `Warn` type clases."
+ , "This kind is used with the `Fail` and `Warn` type classes."
, "Build up a `Doc` with `Text`, `Quote`, `QuoteLabel`, `Beside`, and `Above`."
]
textDoc :: Declaration
-textDoc = primTypeOf (P.primSubName "TypeError") "Text" $ T.unlines
+textDoc = primType P.Text $ T.unlines
[ "The Text type constructor makes a Doc from a Symbol"
, "to be used in a custom type error."
, ""
@@ -488,7 +630,7 @@ textDoc = primTypeOf (P.primSubName "TypeError") "Text" $ T.unlines
]
quoteDoc :: Declaration
-quoteDoc = primTypeOf (P.primSubName "TypeError") "Quote" $ T.unlines
+quoteDoc = primType P.Quote $ T.unlines
[ "The Quote type constructor renders any concrete type as a Doc"
, "to be used in a custom type error."
, ""
@@ -497,7 +639,7 @@ quoteDoc = primTypeOf (P.primSubName "TypeError") "Quote" $ T.unlines
]
quoteLabelDoc :: Declaration
-quoteLabelDoc = primTypeOf (P.primSubName "TypeError") "QuoteLabel" $ T.unlines
+quoteLabelDoc = primType P.QuoteLabel $ T.unlines
[ "The `QuoteLabel` type constructor will produce a `Doc` when given a `Symbol`. When the resulting `Doc` is rendered"
, "for a `Warn` or `Fail` constraint, a syntactically valid label will be produced, escaping with quotes as needed."
, ""
@@ -506,7 +648,7 @@ quoteLabelDoc = primTypeOf (P.primSubName "TypeError") "QuoteLabel" $ T.unlines
]
besideDoc :: Declaration
-besideDoc = primTypeOf (P.primSubName "TypeError") "Beside" $ T.unlines
+besideDoc = primType P.Beside $ T.unlines
[ "The Beside type constructor combines two Docs horizontally"
, "to be used in a custom type error."
, ""
@@ -515,7 +657,7 @@ besideDoc = primTypeOf (P.primSubName "TypeError") "Beside" $ T.unlines
]
aboveDoc :: Declaration
-aboveDoc = primTypeOf (P.primSubName "TypeError") "Above" $ T.unlines
+aboveDoc = primType P.Above $ T.unlines
[ "The Above type constructor combines two Docs vertically"
, "in a custom type error."
, ""
diff --git a/src/Language/PureScript/Docs/Render.hs b/src/Language/PureScript/Docs/Render.hs
index 6e37c202b4..3a0038d989 100644
--- a/src/Language/PureScript/Docs/Render.hs
+++ b/src/Language/PureScript/Docs/Render.hs
@@ -9,16 +9,29 @@
module Language.PureScript.Docs.Render where
-import Prelude.Compat
+import Prelude
import Data.Maybe (maybeToList)
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
import Language.PureScript.Docs.RenderedCode
-import Language.PureScript.Docs.Types
-import Language.PureScript.Docs.Utils.MonoidExtras
-import qualified Language.PureScript as P
+import Language.PureScript.Docs.Types (ChildDeclaration(..), ChildDeclarationInfo(..), Constraint', Declaration(..), DeclarationInfo(..), KindInfo(..), Type', isTypeClassMember, kindSignatureForKeyword)
+import Language.PureScript.Docs.Utils.MonoidExtras (mintersperse)
+
+import Language.PureScript.AST qualified as P
+import Language.PureScript.Environment qualified as P
+import Language.PureScript.Names qualified as P
+import Language.PureScript.Types qualified as P
+
+renderKindSig :: Text -> KindInfo -> RenderedCode
+renderKindSig declTitle KindInfo{..} =
+ mintersperse sp
+ [ keyword $ kindSignatureForKeyword kiKeyword
+ , renderType (P.TypeConstructor () (notQualified declTitle))
+ , syntax "::"
+ , renderType kiKind
+ ]
renderDeclaration :: Declaration -> RenderedCode
renderDeclaration Declaration{..} =
@@ -28,15 +41,18 @@ renderDeclaration Declaration{..} =
, syntax "::"
, renderType ty
]
- DataDeclaration dtype args ->
+ DataDeclaration dtype args roles ->
[ keyword (P.showDataDeclType dtype)
- , renderType (typeApp declTitle args)
+ , renderTypeWithRole roles (typeApp declTitle args)
]
- ExternDataDeclaration kind' ->
+
+ -- All FFI declarations, except for `Prim` modules' doc declarations,
+ -- will have been converted to `DataDeclaration`s by this point.
+ ExternDataDeclaration kind' _ ->
[ keywordData
, renderType (P.TypeConstructor () (notQualified declTitle))
, syntax "::"
- , renderKind kind'
+ , renderType kind'
]
TypeSynonymDeclaration args ty ->
[ keywordType
@@ -76,19 +92,13 @@ renderDeclaration Declaration{..} =
, aliasName for declTitle
]
- ExternKindDeclaration ->
- [ keywordKind
- , kind (notQualified declTitle)
- ]
-
renderChildDeclaration :: ChildDeclaration -> RenderedCode
renderChildDeclaration ChildDeclaration{..} =
mintersperse sp $ case cdeclInfo of
ChildInstance constraints ty ->
maybeToList (renderConstraints constraints) ++ [ renderType ty ]
ChildDataConstructor args ->
- [ dataCtor' cdeclTitle ]
- ++ map renderTypeAtom args
+ dataCtor' cdeclTitle : map renderTypeAtom args
ChildTypeClassMember ty ->
[ ident' cdeclTitle
@@ -97,8 +107,8 @@ renderChildDeclaration ChildDeclaration{..} =
]
renderConstraint :: Constraint' -> RenderedCode
-renderConstraint (P.Constraint ann pn tys _) =
- renderType $ foldl (P.TypeApp ann) (P.TypeConstructor ann (fmap P.coerceProperName pn)) tys
+renderConstraint (P.Constraint ann pn kinds tys _) =
+ renderType $ foldl (P.TypeApp ann) (foldl (P.KindApp ann) (P.TypeConstructor ann (fmap P.coerceProperName pn)) kinds) tys
renderConstraints :: [Constraint'] -> Maybe RenderedCode
renderConstraints constraints
@@ -113,20 +123,20 @@ renderConstraints constraints
(map renderConstraint constraints)
notQualified :: Text -> P.Qualified (P.ProperName a)
-notQualified = P.Qualified Nothing . P.ProperName
+notQualified = P.Qualified P.ByNullSourcePos . P.ProperName
ident' :: Text -> RenderedCode
-ident' = ident . P.Qualified Nothing . P.Ident
+ident' = ident . P.Qualified P.ByNullSourcePos . P.Ident
dataCtor' :: Text -> RenderedCode
dataCtor' = dataCtor . notQualified
-typeApp :: Text -> [(Text, Maybe Kind')] -> Type'
+typeApp :: Text -> [(Text, Maybe Type')] -> Type'
typeApp title typeArgs =
foldl (P.TypeApp ())
(P.TypeConstructor () (notQualified title))
(map toTypeVar typeArgs)
-toTypeVar :: (Text, Maybe Kind') -> Type'
+toTypeVar :: (Text, Maybe Type') -> Type'
toTypeVar (s, Nothing) = P.TypeVar () s
toTypeVar (s, Just k) = P.KindedType () (P.TypeVar () s) k
diff --git a/src/Language/PureScript/Docs/RenderedCode.hs b/src/Language/PureScript/Docs/RenderedCode.hs
index 216eba39ba..2d8d0253e8 100644
--- a/src/Language/PureScript/Docs/RenderedCode.hs
+++ b/src/Language/PureScript/Docs/RenderedCode.hs
@@ -6,4 +6,3 @@ module Language.PureScript.Docs.RenderedCode (module RenderedCode) where
import Language.PureScript.Docs.RenderedCode.Types as RenderedCode
import Language.PureScript.Docs.RenderedCode.RenderType as RenderedCode
-import Language.PureScript.Docs.RenderedCode.RenderKind as RenderedCode
diff --git a/src/Language/PureScript/Docs/RenderedCode/RenderKind.hs b/src/Language/PureScript/Docs/RenderedCode/RenderKind.hs
deleted file mode 100644
index f4c3862aa7..0000000000
--- a/src/Language/PureScript/Docs/RenderedCode/RenderKind.hs
+++ /dev/null
@@ -1,57 +0,0 @@
-{-# LANGUAGE ScopedTypeVariables #-}
--- | Functions for producing RenderedCode values from PureScript Kind values.
---
-module Language.PureScript.Docs.RenderedCode.RenderKind
- ( renderKind
- ) where
-
--- TODO: This is pretty much copied from Language.PureScript.Pretty.Kinds.
--- Ideally we would unify the two.
-
-import Prelude.Compat
-
-import Control.Arrow (ArrowPlus(..))
-import Control.PatternArrows as PA
-
-import Data.Maybe (fromMaybe)
-import qualified Data.Text as T
-
-import Language.PureScript.Crash
-import Language.PureScript.Kinds
-
-import Language.PureScript.Docs.RenderedCode.Types
-
-typeLiterals :: Pattern () (Kind a) RenderedCode
-typeLiterals = mkPattern match
- where
- match (KUnknown _ u) =
- Just $ typeVar $ T.cons 'k' (T.pack (show u))
- match (NamedKind _ n) =
- Just $ kind n
- match _ = Nothing
-
-matchRow :: Pattern () (Kind a) ((), Kind a)
-matchRow = mkPattern match
- where
- match (Row _ k) = Just ((), k)
- match _ = Nothing
-
-funKind :: Pattern () (Kind a) (Kind a, Kind a)
-funKind = mkPattern match
- where
- match (FunKind _ arg ret) = Just (arg, ret)
- match _ = Nothing
-
--- | Generate RenderedCode value representing a Kind
-renderKind :: forall a. Kind a -> RenderedCode
-renderKind
- = fromMaybe (internalError "Incomplete pattern")
- . PA.pattern matchKind ()
- where
- matchKind :: Pattern () (Kind a) RenderedCode
- matchKind = buildPrettyPrinter operators (typeLiterals <+> fmap parens matchKind)
-
- operators :: OperatorTable () (Kind a) RenderedCode
- operators =
- OperatorTable [ [ Wrap matchRow $ \_ k -> syntax "#" <> sp <> k]
- , [ AssocR funKind $ \arg ret -> arg <> sp <> syntax "->" <> sp <> ret ] ]
diff --git a/src/Language/PureScript/Docs/RenderedCode/RenderType.hs b/src/Language/PureScript/Docs/RenderedCode/RenderType.hs
index 242f8a4685..c6a985b09b 100644
--- a/src/Language/PureScript/Docs/RenderedCode/RenderType.hs
+++ b/src/Language/PureScript/Docs/RenderedCode/RenderType.hs
@@ -1,40 +1,44 @@
+-- HLint is confused by the identifier `pattern` if PatternSynonyms is enabled.
+{-# LANGUAGE NoPatternSynonyms #-}
+
-- | Functions for producing RenderedCode values from PureScript Type values.
module Language.PureScript.Docs.RenderedCode.RenderType
( renderType
+ , renderTypeWithRole
, renderType'
, renderTypeAtom
, renderTypeAtom'
, renderRow
) where
-import Prelude.Compat
+import Prelude
import Data.Maybe (fromMaybe)
-import Data.Text (Text)
+import Data.Text (Text, pack)
+import Data.List (uncons)
import Control.Arrow ((<+>))
import Control.PatternArrows as PA
-import Language.PureScript.Crash
-import Language.PureScript.Kinds
-import Language.PureScript.Label
-import Language.PureScript.Names
-import Language.PureScript.Pretty.Types
-import Language.PureScript.Types
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Label (Label)
+import Language.PureScript.Names (coerceProperName)
+import Language.PureScript.Pretty.Types (PrettyPrintConstraint, PrettyPrintType(..), convertPrettyPrintType, prettyPrintLabel)
+import Language.PureScript.Roles (Role, displayRole)
+import Language.PureScript.Types (Type, TypeVarVisibility, typeVarVisibilityPrefix)
import Language.PureScript.PSString (prettyPrintString)
-import Language.PureScript.Docs.RenderedCode.Types
-import Language.PureScript.Docs.Utils.MonoidExtras
-import Language.PureScript.Docs.RenderedCode.RenderKind (renderKind)
+import Language.PureScript.Docs.RenderedCode.Types (RenderedCode, keywordForall, roleAnn, sp, syntax, typeCtor, typeOp, typeVar)
+import Language.PureScript.Docs.Utils.MonoidExtras (mintersperse)
typeLiterals :: Pattern () PrettyPrintType RenderedCode
typeLiterals = mkPattern match
where
match (PPTypeWildcard name) =
- Just $ maybe (syntax "_") (syntax . ("?" <>)) name
- match (PPTypeVar var) =
- Just (typeVar var)
+ Just $ syntax $ maybe "_" ("?" <>) name
+ match (PPTypeVar var role) =
+ Just $ typeVar var <> roleAnn role
match (PPRecord labels tail_) =
Just $ mintersperse sp
[ syntax "{"
@@ -51,12 +55,14 @@ typeLiterals = mkPattern match
Just (typeOp n)
match (PPTypeLevelString str) =
Just (syntax (prettyPrintString str))
+ match (PPTypeLevelInt nat) =
+ Just (syntax $ pack $ show nat)
match _ =
Nothing
renderConstraint :: PrettyPrintConstraint -> RenderedCode
-renderConstraint (pn, tys) =
- let instApp = foldl PPTypeApp (PPTypeConstructor (fmap coerceProperName pn)) tys
+renderConstraint (pn, ks, tys) =
+ let instApp = foldl PPTypeApp (foldl (\a b -> PPTypeApp a (PPKindArg b)) (PPTypeConstructor (fmap coerceProperName pn)) ks) tys
in renderType' instApp
renderConstraints :: PrettyPrintConstraint -> RenderedCode -> RenderedCode
@@ -94,16 +100,22 @@ typeApp = mkPattern match
match (PPTypeApp f x) = Just (f, x)
match _ = Nothing
+kindArg :: Pattern () PrettyPrintType ((), PrettyPrintType)
+kindArg = mkPattern match
+ where
+ match (PPKindArg ty) = Just ((), ty)
+ match _ = Nothing
+
appliedFunction :: Pattern () PrettyPrintType (PrettyPrintType, PrettyPrintType)
appliedFunction = mkPattern match
where
match (PPFunction arg ret) = Just (arg, ret)
match _ = Nothing
-kinded :: Pattern () PrettyPrintType (Kind (), PrettyPrintType)
+kinded :: Pattern () PrettyPrintType (PrettyPrintType, PrettyPrintType)
kinded = mkPattern match
where
- match (PPKindedType t k) = Just (k, t)
+ match (PPKindedType t k) = Just (t, k)
match _ = Nothing
constrained :: Pattern () PrettyPrintType (PrettyPrintConstraint, PrettyPrintType)
@@ -128,38 +140,108 @@ matchType = buildPrettyPrinter operators matchTypeAtom
where
operators :: OperatorTable () PrettyPrintType RenderedCode
operators =
- OperatorTable [ [ AssocL typeApp $ \f x -> f <> sp <> x ]
+ OperatorTable [ [ Wrap kindArg $ \_ ty -> syntax "@" <> ty ]
+ , [ AssocL typeApp $ \f x -> f <> sp <> x ]
, [ AssocR appliedFunction $ \arg ret -> mintersperse sp [arg, syntax "->", ret] ]
, [ Wrap constrained $ \deps ty -> renderConstraints deps ty ]
, [ Wrap forall_ $ \tyVars ty -> mconcat [ keywordForall, sp, renderTypeVars tyVars, syntax ".", sp, ty ] ]
- , [ Wrap kinded $ \k ty -> mintersperse sp [ty, syntax "::", renderKind k] ]
+ , [ Wrap kinded $ \ty k -> mintersperse sp [renderType' ty, syntax "::", k] ]
, [ Wrap explicitParens $ \_ ty -> ty ]
]
-forall_ :: Pattern () PrettyPrintType ([(Text, Maybe (Kind ()))], PrettyPrintType)
+forall_ :: Pattern () PrettyPrintType ([(TypeVarVisibility, Text, Maybe PrettyPrintType)], PrettyPrintType)
forall_ = mkPattern match
where
match (PPForAll mbKindedIdents ty) = Just (mbKindedIdents, ty)
match _ = Nothing
+renderTypeInternal :: (PrettyPrintType -> PrettyPrintType) -> Type a -> RenderedCode
+renderTypeInternal insertRolesIfAny =
+ renderType' . insertRolesIfAny . convertPrettyPrintType maxBound
+
-- |
-- Render code representing a Type
--
renderType :: Type a -> RenderedCode
-renderType = renderType' . convertPrettyPrintType maxBound
+renderType = renderTypeInternal id
+
+-- |
+-- Render code representing a Type
+-- but augment the `TypeVar`s with their `Role` if they have one
+--
+renderTypeWithRole :: [Role] -> Type a -> RenderedCode
+renderTypeWithRole = \case
+ [] -> renderType
+ roleList -> renderTypeInternal (addRole roleList [] . Left)
+ where
+ -- `data Foo first second = Foo` will produce
+ -- ```
+ -- PPTypeApp
+ -- (PPTypeApp (PPTypeConstructor fooName) (PPTypeVar "first" Nothing))
+ -- (PPTypeVar "second" Nothing)
+ -- ```
+ -- So, we recurse down the left side of `TypeApp` first before
+ -- recursing down the right side. To make this stack-safe,
+ -- we use a tail-recursive function with its own stack.
+ -- - Left = values that have not yet been examined and need
+ -- a role added to them (if any). There's still work "left" to do.
+ -- - Right = values that have been examined and now need to be
+ -- reassembled into their original value
+ addRole
+ :: [Role]
+ -> [Either PrettyPrintType PrettyPrintType]
+ -> Either PrettyPrintType PrettyPrintType
+ -> PrettyPrintType
+ addRole roles stack pp = case pp of
+ Left next -> case next of
+ PPTypeVar t Nothing
+ | Just (x, xs) <- uncons roles ->
+ addRole xs stack (Right $ PPTypeVar t (Just $ displayRole x))
+ | otherwise ->
+ internalError "addRole: invalid arguments - number of roles doesn't match number of type parameters"
+
+ PPTypeVar _ (Just _) ->
+ internalError "addRole: attempted to add a second role to a type parameter that already has one"
+
+ PPTypeApp leftSide rightSide -> do
+ -- push right-side to stack and continue recursing on left-side
+ addRole roles (Left rightSide : stack) (Left leftSide)
+
+ other ->
+ -- nothing to check, so move on
+ addRole roles stack (Right other)
+
+
+ pendingAssembly@(Right rightSideOrFinalValue) -> case stack of
+ (unfinishedRightSide@(Left _) : remaining) ->
+ -- We've finished recursing through the left-side of a `TypeApp`.
+ -- Now we'll recurse through the right-side.
+ -- We push `pendingAssembly` onto the stack so we can assemble
+ -- the `PPTypeApp` together once it's right-side is done.
+ addRole roles (pendingAssembly : remaining) unfinishedRightSide
+
+ (Right leftSide : remaining) ->
+ -- We've finished recursing through the right-side of a `TypeApp`
+ -- We'll rebulid it and wrap it in `Right` so any other higher-level
+ -- `TypeApp`s can be reassembled now, too.
+ addRole roles remaining (Right (PPTypeApp leftSide rightSideOrFinalValue))
+
+ [] ->
+ -- We've reassembled everything. It's time to return.
+ rightSideOrFinalValue
renderType' :: PrettyPrintType -> RenderedCode
renderType'
= fromMaybe (internalError "Incomplete pattern")
- . PA.pattern matchType ()
+ . PA.pattern_ matchType ()
-renderTypeVars :: [(Text, Maybe (Kind a))] -> RenderedCode
+renderTypeVars :: [(TypeVarVisibility, Text, Maybe PrettyPrintType)] -> RenderedCode
renderTypeVars tyVars = mintersperse sp (map renderTypeVar tyVars)
-renderTypeVar :: (Text, Maybe (Kind a)) -> RenderedCode
-renderTypeVar (v, mbK) = case mbK of
- Nothing -> typeVar v
- Just k -> mintersperse sp [ mconcat [syntax "(", typeVar v], syntax "::", mconcat [renderKind k, syntax ")"] ]
+renderTypeVar :: (TypeVarVisibility, Text, Maybe PrettyPrintType) -> RenderedCode
+renderTypeVar (vis, v, mbK) = case mbK of
+ Nothing -> syntax (typeVarVisibilityPrefix vis) <> typeVar v
+ Just k -> mintersperse sp [ mconcat [syntax "(", syntax $ typeVarVisibilityPrefix vis, typeVar v], syntax "::", mconcat [renderType' k, syntax ")"] ]
-- |
-- Render code representing a Type, as it should appear inside parentheses
@@ -170,4 +252,4 @@ renderTypeAtom = renderTypeAtom' . convertPrettyPrintType maxBound
renderTypeAtom' :: PrettyPrintType -> RenderedCode
renderTypeAtom'
= fromMaybe (internalError "Incomplete pattern")
- . PA.pattern matchTypeAtom ()
+ . PA.pattern_ matchTypeAtom ()
diff --git a/src/Language/PureScript/Docs/RenderedCode/Types.hs b/src/Language/PureScript/Docs/RenderedCode/Types.hs
index ecf1b0a9fb..c1374899f5 100644
--- a/src/Language/PureScript/Docs/RenderedCode/Types.hs
+++ b/src/Language/PureScript/Docs/RenderedCode/Types.hs
@@ -1,64 +1,52 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE DeriveGeneric #-}
-
-- | Data types and functions for representing a simplified form of PureScript
-- code, intended for use in e.g. HTML documentation.
module Language.PureScript.Docs.RenderedCode.Types
( RenderedCodeElement(..)
- , asRenderedCodeElement
, ContainingModule(..)
, asContainingModule
- , containingModuleToMaybe
, maybeToContainingModule
- , fromContainingModule
, fromQualified
, Namespace(..)
, Link(..)
, FixityAlias
, RenderedCode
- , asRenderedCode
, outputWith
, sp
- , parens
, syntax
, keyword
, keywordForall
, keywordData
- , keywordNewtype
, keywordType
, keywordClass
- , keywordInstance
, keywordWhere
, keywordFixity
- , keywordKind
, keywordAs
, ident
, dataCtor
, typeCtor
, typeOp
, typeVar
- , kind
+ , roleAnn
, alias
, aliasName
) where
-import Prelude.Compat
+import Prelude
import GHC.Generics (Generic)
import Control.DeepSeq (NFData)
import Control.Monad.Error.Class (MonadError(..))
-import Data.Aeson.BetterErrors (Parse, nth, withText, withValue, toAesonParser, perhaps, asText, eachInArray)
-import qualified Data.Aeson as A
+import Data.Aeson.BetterErrors (Parse, nth, withText, withValue, toAesonParser, perhaps, asText)
+import Data.Aeson qualified as A
import Data.Text (Text)
-import qualified Data.Text as T
-import qualified Data.ByteString.Lazy as BS
-import qualified Data.Text.Encoding as TE
+import Data.Text qualified as T
+import Data.ByteString.Lazy qualified as BS
+import Data.Text.Encoding qualified as TE
-import Language.PureScript.Names
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName, OpName(..), OpNameType(..), ProperName(..), ProperNameType(..), Qualified(..), QualifiedBy(..), moduleNameFromString, runIdent, runModuleName)
import Language.PureScript.AST (Associativity(..))
-import Language.PureScript.Crash (internalError)
-- | Given a list of actions, attempt them all, returning the first success.
-- If all the actions fail, 'tryAll' returns the first argument.
@@ -128,24 +116,9 @@ maybeToContainingModule :: Maybe ModuleName -> ContainingModule
maybeToContainingModule Nothing = ThisModule
maybeToContainingModule (Just mn) = OtherModule mn
--- |
--- Convert a 'ContainingModule' to a 'Maybe' 'ModuleName', using the obvious
--- isomorphism.
---
-containingModuleToMaybe :: ContainingModule -> Maybe ModuleName
-containingModuleToMaybe ThisModule = Nothing
-containingModuleToMaybe (OtherModule mn) = Just mn
-
--- |
--- A version of 'fromMaybe' for 'ContainingModule' values.
---
-fromContainingModule :: ModuleName -> ContainingModule -> ModuleName
-fromContainingModule def ThisModule = def
-fromContainingModule _ (OtherModule mn) = mn
-
fromQualified :: Qualified a -> (ContainingModule, a)
-fromQualified (Qualified mn x) =
- (maybeToContainingModule mn, x)
+fromQualified (Qualified (ByModuleName mn) x) = (OtherModule mn, x)
+fromQualified (Qualified _ x) = (ThisModule, x)
data Link
= NoLink
@@ -170,7 +143,6 @@ instance A.FromJSON Link where
data Namespace
= ValueLevel
| TypeLevel
- | KindLevel
deriving (Show, Eq, Ord, Generic)
instance NFData Namespace
@@ -184,7 +156,6 @@ asNamespace =
[ withText $ \case
"ValueLevel" -> Right ValueLevel
"TypeLevel" -> Right TypeLevel
- "KindLevel" -> Right KindLevel
_ -> Left ""
]
@@ -203,6 +174,7 @@ data RenderedCodeElement
-- namespace (value, type, or kind). Note that this is not related to the
-- kind called Symbol for type-level strings.
| Symbol Namespace Text Link
+ | Role Text
deriving (Show, Eq, Ord)
instance A.ToJSON RenderedCodeElement where
@@ -214,32 +186,8 @@ instance A.ToJSON RenderedCodeElement where
A.toJSON ["space" :: Text]
toJSON (Symbol ns str link) =
A.toJSON ["symbol", A.toJSON ns, A.toJSON str, A.toJSON link]
-
-asRenderedCodeElement :: Parse Text RenderedCodeElement
-asRenderedCodeElement =
- tryParse "RenderedCodeElement" $
- [ a Syntax "syntax"
- , a Keyword "keyword"
- , asSpace
- , asSymbol
- ] ++ backwardsCompat
- where
- a ctor' ctorStr = firstEq ctorStr (ctor' <$> nth 1 asText)
- asSymbol = firstEq "symbol" (Symbol <$> nth 1 asNamespace <*> nth 2 asText <*> nth 3 asLink)
- asSpace = firstEq "space" (pure Space)
-
- -- These will make some mistakes e.g. treating data constructors as types,
- -- because the old code did not save information which is necessary to
- -- distinguish these cases. This is the best we can do.
- backwardsCompat =
- [ oldAsIdent
- , oldAsCtor
- , oldAsKind
- ]
-
- oldAsIdent = firstEq "ident" (Symbol ValueLevel <$> nth 1 asText <*> nth 2 (Link <$> asContainingModule))
- oldAsCtor = firstEq "ctor" (Symbol TypeLevel <$> nth 1 asText <*> nth 2 (Link <$> asContainingModule))
- oldAsKind = firstEq "kind" (Symbol KindLevel <$> nth 1 asText <*> pure (Link ThisModule))
+ toJSON (Role role) =
+ A.toJSON ["role", role]
-- |
-- A type representing a highly simplified version of PureScript code, intended
@@ -252,9 +200,6 @@ newtype RenderedCode
instance A.ToJSON RenderedCode where
toJSON (RC elems) = A.toJSON elems
-asRenderedCode :: Parse Text RenderedCode
-asRenderedCode = RC <$> eachInArray asRenderedCodeElement
-
-- |
-- This function allows conversion of a 'RenderedCode' value into a value of
-- some other type (for example, plain text, or HTML). The first argument
@@ -270,11 +215,6 @@ outputWith f = foldMap f . unRC
sp :: RenderedCode
sp = RC [Space]
--- |
--- Wrap a RenderedCode value in parens.
-parens :: RenderedCode -> RenderedCode
-parens x = syntax "(" <> x <> syntax ")"
-
-- possible TODO: instead of this function, export RenderedCode values for
-- each syntax element, eg syntaxArr (== syntax "->"), syntaxLBrace,
-- syntaxRBrace, etc.
@@ -290,18 +230,12 @@ keywordForall = keyword "forall"
keywordData :: RenderedCode
keywordData = keyword "data"
-keywordNewtype :: RenderedCode
-keywordNewtype = keyword "newtype"
-
keywordType :: RenderedCode
keywordType = keyword "type"
keywordClass :: RenderedCode
keywordClass = keyword "class"
-keywordInstance :: RenderedCode
-keywordInstance = keyword "instance"
-
keywordWhere :: RenderedCode
keywordWhere = keyword "where"
@@ -310,9 +244,6 @@ keywordFixity Infixl = keyword "infixl"
keywordFixity Infixr = keyword "infixr"
keywordFixity Infix = keyword "infix"
-keywordKind :: RenderedCode
-keywordKind = keyword "kind"
-
keywordAs :: RenderedCode
keywordAs = keyword "as"
@@ -335,9 +266,13 @@ typeOp (fromQualified -> (mn, name)) =
typeVar :: Text -> RenderedCode
typeVar x = RC [Symbol TypeLevel x NoLink]
-kind :: Qualified (ProperName 'KindName) -> RenderedCode
-kind (fromQualified -> (mn, name)) =
- RC [Symbol KindLevel (runProperName name) (Link mn)]
+roleAnn :: Maybe Text -> RenderedCode
+roleAnn = RC . maybe [] renderRole
+ where
+ renderRole = \case
+ "nominal" -> [Role "nominal"]
+ "phantom" -> [Role "phantom"]
+ _ -> []
type FixityAlias = Qualified (Either (ProperName 'TypeName) (Either Ident (ProperName 'ConstructorName)))
@@ -361,11 +296,9 @@ aliasName for name' =
in
case ns of
ValueLevel ->
- ident (Qualified Nothing (Ident name))
+ ident (Qualified ByNullSourcePos (Ident name))
TypeLevel ->
- typeCtor (Qualified Nothing (ProperName name))
- KindLevel ->
- internalError "Kind aliases are not supported"
+ typeCtor (Qualified ByNullSourcePos (ProperName name))
-- | Converts a FixityAlias into a different representation which is more
-- useful to other functions in this module.
diff --git a/src/Language/PureScript/Docs/Tags.hs b/src/Language/PureScript/Docs/Tags.hs
index 0310bb7a63..e3651c9fa0 100644
--- a/src/Language/PureScript/Docs/Tags.hs
+++ b/src/Language/PureScript/Docs/Tags.hs
@@ -6,19 +6,19 @@ module Language.PureScript.Docs.Tags
import Prelude
-import Control.Arrow (first)
-import Data.List (sort)
-import Data.Maybe (mapMaybe)
-import qualified Data.Text as T
+import Control.Arrow (first)
+import Data.List (sort)
+import Data.Maybe (mapMaybe)
+import Data.Text qualified as T
import Language.PureScript.AST (SourceSpan, sourcePosLine, spanStart)
-import Language.PureScript.Docs.Types
+import Language.PureScript.Docs.Types (ChildDeclaration(..), Declaration(..), Module(..))
tags :: Module -> [(String, Int)]
tags = map (first T.unpack) . concatMap dtags . modDeclarations
where
dtags :: Declaration -> [(T.Text, Int)]
dtags decl = case declSourceSpan decl of
- Just ss -> (declTitle decl, pos ss):(mapMaybe subtag $ declChildren decl)
+ Just ss -> (declTitle decl, pos ss):mapMaybe subtag (declChildren decl)
Nothing -> mapMaybe subtag $ declChildren decl
subtag :: ChildDeclaration -> Maybe (T.Text, Int)
diff --git a/src/Language/PureScript/Docs/Types.hs b/src/Language/PureScript/Docs/Types.hs
index 16a18d54a8..ea13066556 100644
--- a/src/Language/PureScript/Docs/Types.hs
+++ b/src/Language/PureScript/Docs/Types.hs
@@ -1,46 +1,48 @@
-{-# LANGUAGE DeriveGeneric #-}
-
module Language.PureScript.Docs.Types
( module Language.PureScript.Docs.Types
, module ReExports
)
where
-import Protolude hiding (to, from)
+import Protolude hiding (to, from, unlines)
import Prelude (String, unlines, lookup)
-import GHC.Generics (Generic)
-import Control.DeepSeq (NFData)
import Control.Arrow ((***))
import Data.Aeson ((.=))
+import Data.Aeson.Key qualified as A.Key
import Data.Aeson.BetterErrors
- (Parse, ParseError, parse, keyOrDefault, throwCustomError, key, asText,
+ (Parse, keyOrDefault, throwCustomError, key, asText,
keyMay, withString, eachInArray, asNull, (.!), toAesonParser, toAesonParser',
fromAesonParser, perhaps, withText, asIntegral, nth, eachInObjectWithKey,
asString)
-import qualified Data.Map as Map
+import Data.Map qualified as Map
import Data.Time.Clock (UTCTime)
-import qualified Data.Time.Format as TimeFormat
-import Data.Version
-import qualified Data.Aeson as A
-import qualified Data.Text as T
-import qualified Data.Vector as V
-
-import qualified Language.PureScript as P
-
-import Text.ParserCombinators.ReadP (readP_to_S)
-
-import Web.Bower.PackageMeta hiding (Version, displayError)
+import Data.Time.Format qualified as TimeFormat
+import Data.Version (Version(..), showVersion)
+import Data.Aeson qualified as A
+import Data.Text qualified as T
+import Data.Vector qualified as V
+
+import Language.PureScript.AST qualified as P
+import Language.PureScript.CoreFn.FromJSON qualified as P
+import Language.PureScript.Crash qualified as P
+import Language.PureScript.Environment qualified as P
+import Language.PureScript.Names qualified as P
+import Language.PureScript.Roles qualified as P
+import Language.PureScript.Types qualified as P
+import Paths_purescript qualified as Paths
+
+import Web.Bower.PackageMeta (BowerError, PackageMeta(..), PackageName, asPackageMeta, parsePackageName, runPackageName, showBowerError)
import Language.PureScript.Docs.RenderedCode as ReExports
- (RenderedCode, asRenderedCode,
+ (RenderedCode,
ContainingModule(..), asContainingModule,
- RenderedCodeElement(..), asRenderedCodeElement,
+ RenderedCodeElement(..),
Namespace(..), FixityAlias)
+import Language.PureScript.Publish.Registry.Compat (PursJsonError, showPursJsonError)
type Type' = P.Type ()
-type Kind' = P.Kind ()
type Constraint' = P.Constraint ()
--------------------
@@ -75,7 +77,17 @@ instance NFData NotYetKnown
type UploadedPackage = Package NotYetKnown
type VerifiedPackage = Package GithubUser
-type ManifestError = BowerError
+data ManifestError
+ = BowerManifest BowerError
+ | PursManifest PursJsonError
+ deriving (Show, Eq, Ord, Generic)
+
+instance NFData ManifestError
+
+showManifestError :: ManifestError -> Text
+showManifestError = \case
+ BowerManifest err -> showBowerError err
+ PursManifest err -> showPursJsonError err
verifyPackage :: GithubUser -> UploadedPackage -> VerifiedPackage
verifyPackage verifiedUser Package{..} =
@@ -133,6 +145,7 @@ data Declaration = Declaration
, declSourceSpan :: Maybe P.SourceSpan
, declChildren :: [ChildDeclaration]
, declInfo :: DeclarationInfo
+ , declKind :: Maybe KindInfo
}
deriving (Show, Eq, Ord, Generic)
@@ -158,39 +171,45 @@ data DeclarationInfo
-- newtype) and its type arguments. Constructors are represented as child
-- declarations.
--
- | DataDeclaration P.DataDeclType [(Text, Maybe Kind')]
+ | DataDeclaration P.DataDeclType [(Text, Maybe Type')] [P.Role]
-- |
-- A data type foreign import, with its kind.
--
- | ExternDataDeclaration Kind'
+ | ExternDataDeclaration Type' [P.Role]
-- |
-- A type synonym, with its type arguments and its type.
--
- | TypeSynonymDeclaration [(Text, Maybe Kind')] Type'
+ | TypeSynonymDeclaration [(Text, Maybe Type')] Type'
-- |
-- A type class, with its type arguments, its superclasses and functional
-- dependencies. Instances and members are represented as child declarations.
--
- | TypeClassDeclaration [(Text, Maybe Kind')] [Constraint'] [([Text], [Text])]
+ | TypeClassDeclaration [(Text, Maybe Type')] [Constraint'] [([Text], [Text])]
-- |
-- An operator alias declaration, with the member the alias is for and the
-- operator's fixity.
--
| AliasDeclaration P.Fixity FixityAlias
-
- -- |
- -- A kind declaration
- --
- | ExternKindDeclaration
deriving (Show, Eq, Ord, Generic)
instance NFData DeclarationInfo
-convertFundepsToStrings :: [(Text, Maybe Kind')] -> [P.FunctionalDependency] -> [([Text], [Text])]
+-- |
+-- Wraps enough information to properly render the kind signature
+-- of a data/newtype/type/class declaration.
+data KindInfo = KindInfo
+ { kiKeyword :: P.KindSignatureFor
+ , kiKind :: Type'
+ }
+ deriving (Show, Eq, Ord, Generic)
+
+instance NFData KindInfo
+
+convertFundepsToStrings :: [(Text, Maybe Type')] -> [P.FunctionalDependency] -> [([Text], [Text])]
convertFundepsToStrings args fundeps =
map (\(P.FunctionalDependency from to) -> toArgs from to) fundeps
where
@@ -210,12 +229,11 @@ convertFundepsToStrings args fundeps =
declInfoToString :: DeclarationInfo -> Text
declInfoToString (ValueDeclaration _) = "value"
-declInfoToString (DataDeclaration _ _) = "data"
-declInfoToString (ExternDataDeclaration _) = "externData"
+declInfoToString (DataDeclaration _ _ _) = "data"
+declInfoToString (ExternDataDeclaration _ _) = "externData"
declInfoToString (TypeSynonymDeclaration _ _) = "typeSynonym"
declInfoToString (TypeClassDeclaration _ _ _) = "typeClass"
declInfoToString (AliasDeclaration _ _) = "alias"
-declInfoToString ExternKindDeclaration = "kind"
declInfoNamespace :: DeclarationInfo -> Namespace
declInfoNamespace = \case
@@ -231,8 +249,6 @@ declInfoNamespace = \case
TypeLevel
AliasDeclaration _ alias ->
either (const TypeLevel) (const ValueLevel) (P.disqualify alias)
- ExternKindDeclaration{} ->
- KindLevel
isTypeClass :: Declaration -> Bool
isTypeClass Declaration{..} =
@@ -266,12 +282,6 @@ isTypeAlias Declaration{..} =
AliasDeclaration _ (P.Qualified _ d) -> isLeft d
_ -> False
-isKind :: Declaration -> Bool
-isKind Declaration{..} =
- case declInfo of
- ExternKindDeclaration{} -> True
- _ -> False
-
-- | Discard any children which do not satisfy the given predicate.
filterChildren :: (ChildDeclaration -> Bool) -> Declaration -> Declaration
filterChildren p decl =
@@ -362,7 +372,9 @@ data PackageError
| InvalidFixity
| InvalidKind Text
| InvalidDataDeclType Text
+ | InvalidKindSignatureFor Text
| InvalidTime
+ | InvalidRole Text
deriving (Show, Eq, Ord, Generic)
instance NFData PackageError
@@ -378,13 +390,6 @@ instance Functor InPackage where
fmap f (Local x) = Local (f x)
fmap f (FromDep pkgName x) = FromDep pkgName (f x)
-takeLocal :: InPackage a -> Maybe a
-takeLocal (Local a) = Just a
-takeLocal _ = Nothing
-
-takeLocals :: [InPackage a] -> [a]
-takeLocals = mapMaybe takeLocal
-
ignorePackage :: InPackage a -> a
ignorePackage (Local x) = x
ignorePackage (FromDep _ x) = x
@@ -479,12 +484,6 @@ getLinksContext Package{..} =
----------------------
-- Parsing
-parseUploadedPackage :: Version -> LByteString -> Either (ParseError PackageError) UploadedPackage
-parseUploadedPackage minVersion = parse $ asUploadedPackage minVersion
-
-parseVerifiedPackage :: Version -> LByteString -> Either (ParseError PackageError) VerifiedPackage
-parseVerifiedPackage minVersion = parse $ asVerifiedPackage minVersion
-
asPackage :: Version -> (forall e. Parse e a) -> Parse PackageError (Package a)
asPackage minimumVersion uploader = do
-- If the compilerVersion key is missing, we can be sure that it was produced
@@ -494,7 +493,7 @@ asPackage minimumVersion uploader = do
when (compilerVersion < minimumVersion)
(throwCustomError $ CompilerTooOld minimumVersion compilerVersion)
- Package <$> key "packageMeta" asPackageMeta .! ErrorInPackageMeta
+ Package <$> key "packageMeta" asPackageMeta .! (ErrorInPackageMeta . BowerManifest)
<*> key "version" asVersion
<*> key "versionTag" asText
<*> keyMay "tagTime" (withString parseTimeEither)
@@ -522,9 +521,6 @@ asNotYetKnown = NotYetKnown <$ asNull
instance A.FromJSON NotYetKnown where
parseJSON = toAesonParser' asNotYetKnown
-asVerifiedPackage :: Version -> Parse PackageError VerifiedPackage
-asVerifiedPackage minVersion = asPackage minVersion asGithubUser
-
displayPackageError :: PackageError -> Text
displayPackageError e = case e of
CompilerTooOld minV usedV ->
@@ -532,7 +528,7 @@ displayPackageError e = case e of
<> " of the compiler, but it appears that " <> T.pack (showVersion usedV)
<> " was used."
ErrorInPackageMeta err ->
- "Error in package metadata: " <> showBowerError err
+ "Error in package metadata: " <> showManifestError err
InvalidVersion ->
"Invalid version"
InvalidDeclarationType str ->
@@ -545,8 +541,12 @@ displayPackageError e = case e of
"Invalid kind: \"" <> str <> "\""
InvalidDataDeclType str ->
"Invalid data declaration type: \"" <> str <> "\""
+ InvalidKindSignatureFor str ->
+ "Invalid kind signature keyword: \"" <> str <> "\""
InvalidTime ->
"Invalid time"
+ InvalidRole str ->
+ "Invalid role keyword: \"" <> str <> "\""
instance A.FromJSON a => A.FromJSON (Package a) where
parseJSON = toAesonParser displayPackageError
@@ -559,13 +559,7 @@ instance A.FromJSON GithubUser where
parseJSON = toAesonParser' asGithubUser
asVersion :: Parse PackageError Version
-asVersion = withString (maybe (Left InvalidVersion) Right . parseVersion')
-
-parseVersion' :: String -> Maybe Version
-parseVersion' str =
- case filter (null . snd) $ readP_to_S parseVersion str of
- [(vers, "")] -> Just vers
- _ -> Nothing
+asVersion = withString (maybe (Left InvalidVersion) Right . P.parseVersion')
asModule :: Parse PackageError Module
asModule =
@@ -581,6 +575,7 @@ asDeclaration =
<*> key "sourceSpan" (perhaps asSourceSpan)
<*> key "children" (eachInArray asChildDeclaration)
<*> key "info" asDeclarationInfo
+ <*> keyOrDefault "kind" Nothing (perhaps asKindInfo)
asReExport :: Parse PackageError (InPackage P.ModuleName, [Declaration])
asReExport =
@@ -601,7 +596,7 @@ p `pOr` q = catchError p (const q)
asInPackage :: Parse ManifestError a -> Parse ManifestError (InPackage a)
asInPackage inner =
- build <$> key "package" (perhaps (withText parsePackageName))
+ build <$> key "package" (perhaps (withText (mapLeft BowerManifest . parsePackageName)))
<*> key "item" inner
where
build Nothing = Local
@@ -634,8 +629,10 @@ asDeclarationInfo = do
"data" ->
DataDeclaration <$> key "dataDeclType" asDataDeclType
<*> key "typeArguments" asTypeArguments
+ <*> keyOrDefault "roles" [] (eachInArray asRole)
"externData" ->
- ExternDataDeclaration <$> key "kind" asKind
+ ExternDataDeclaration <$> key "kind" asType
+ <*> keyOrDefault "roles" [] (eachInArray asRole)
"typeSynonym" ->
TypeSynonymDeclaration <$> key "arguments" asTypeArguments
<*> key "type" asType
@@ -646,18 +643,38 @@ asDeclarationInfo = do
"alias" ->
AliasDeclaration <$> key "fixity" asFixity
<*> key "alias" asFixityAlias
+ -- Backwards compat: kinds are extern data
"kind" ->
- pure ExternKindDeclaration
+ pure $ ExternDataDeclaration (P.kindType $> ()) []
other ->
throwCustomError (InvalidDeclarationType other)
-asTypeArguments :: Parse PackageError [(Text, Maybe Kind')]
+asKindInfo :: Parse PackageError KindInfo
+asKindInfo =
+ KindInfo <$> key "keyword" asKindSignatureFor
+ <*> key "kind" asType
+
+asKindSignatureFor :: Parse PackageError P.KindSignatureFor
+asKindSignatureFor =
+ withText $ \case
+ "data" -> Right P.DataSig
+ "newtype" -> Right P.NewtypeSig
+ "class" -> Right P.ClassSig
+ "type" -> Right P.TypeSynonymSig
+ x -> Left (InvalidKindSignatureFor x)
+
+asTypeArguments :: Parse PackageError [(Text, Maybe Type')]
asTypeArguments = eachInArray asTypeArgument
where
- asTypeArgument = (,) <$> nth 0 asText <*> nth 1 (perhaps asKind)
+ asTypeArgument = (,) <$> nth 0 asText <*> nth 1 (perhaps asType)
-asKind :: Parse PackageError Kind'
-asKind = fromAesonParser .! InvalidKind
+asRole :: Parse PackageError P.Role
+asRole =
+ withText $ \case
+ "Representational" -> Right P.Representational
+ "Nominal" -> Right P.Nominal
+ "Phantom" -> Right P.Phantom
+ other -> Left (InvalidRole other)
asType :: Parse e Type'
asType = fromAesonParser
@@ -669,7 +686,7 @@ asFunDeps = eachInArray asFunDep
asDataDeclType :: Parse PackageError P.DataDeclType
asDataDeclType =
- withText $ \s -> case s of
+ withText $ \case
"data" -> Right P.Data
"newtype" -> Right P.Newtype
other -> Left (InvalidDataDeclType other)
@@ -701,18 +718,13 @@ asSourcePos = P.SourcePos <$> nth 0 asIntegral
asConstraint :: Parse PackageError Constraint'
asConstraint = P.Constraint () <$> key "constraintClass" asQualifiedProperName
+ <*> keyOrDefault "constraintKindArgs" [] (eachInArray asType)
<*> key "constraintArgs" (eachInArray asType)
<*> pure Nothing
asQualifiedProperName :: Parse e (P.Qualified (P.ProperName a))
asQualifiedProperName = fromAesonParser
-asQualifiedIdent :: Parse e (P.Qualified P.Ident)
-asQualifiedIdent = fromAesonParser
-
-asSourceAnn :: Parse e (P.SourceAnn)
-asSourceAnn = fromAesonParser
-
asModuleMap :: Parse PackageError (Map P.ModuleName PackageName)
asModuleMap =
Map.fromList <$>
@@ -740,7 +752,7 @@ asResolvedDependencies =
parsePackageName' :: Text -> Either PackageError PackageName
parsePackageName' =
- mapLeft ErrorInPackageMeta . parsePackageName
+ mapLeft ErrorInPackageMeta . (mapLeft BowerManifest . parsePackageName)
mapLeft :: (a -> a') -> Either a b -> Either a' b
mapLeft f (Left x) = Left (f x)
@@ -765,15 +777,15 @@ instance A.ToJSON a => A.ToJSON (Package a) where
, "version" .= showVersion pkgVersion
, "versionTag" .= pkgVersionTag
, "modules" .= pkgModules
- , "moduleMap" .= assocListToJSON P.runModuleName
+ , "moduleMap" .= assocListToJSON (A.Key.fromText . P.runModuleName)
runPackageName
(Map.toList pkgModuleMap)
- , "resolvedDependencies" .= assocListToJSON runPackageName
+ , "resolvedDependencies" .= assocListToJSON (A.Key.fromText . runPackageName)
(T.pack . showVersion)
pkgResolvedDependencies
, "github" .= pkgGithub
, "uploader" .= pkgUploader
- , "compilerVersion" .= showVersion P.version
+ , "compilerVersion" .= showVersion Paths.version
] ++
fmap (\t -> "tagTime" .= formatTime t) (maybeToList pkgTagTime)
@@ -799,8 +811,22 @@ instance A.ToJSON Declaration where
, "sourceSpan" .= declSourceSpan
, "children" .= declChildren
, "info" .= declInfo
+ , "kind" .= declKind
]
+instance A.ToJSON KindInfo where
+ toJSON KindInfo{..} =
+ A.object [ "keyword" .= kindSignatureForKeyword kiKeyword
+ , "kind" .= kiKind
+ ]
+
+kindSignatureForKeyword :: P.KindSignatureFor -> Text
+kindSignatureForKeyword = \case
+ P.DataSig -> "data"
+ P.NewtypeSig -> "newtype"
+ P.TypeSynonymSig -> "type"
+ P.ClassSig -> "class"
+
instance A.ToJSON ChildDeclaration where
toJSON ChildDeclaration{..} =
A.object [ "title" .= cdeclTitle
@@ -814,12 +840,11 @@ instance A.ToJSON DeclarationInfo where
where
props = case info of
ValueDeclaration ty -> ["type" .= ty]
- DataDeclaration ty args -> ["dataDeclType" .= ty, "typeArguments" .= args]
- ExternDataDeclaration kind -> ["kind" .= kind]
+ DataDeclaration ty args roles -> ["dataDeclType" .= ty, "typeArguments" .= args, "roles" .= roles]
+ ExternDataDeclaration kind roles -> ["kind" .= kind, "roles" .= roles]
TypeSynonymDeclaration args ty -> ["arguments" .= args, "type" .= ty]
TypeClassDeclaration args super fundeps -> ["arguments" .= args, "superclasses" .= super, "fundeps" .= fundeps]
AliasDeclaration fixity alias -> ["fixity" .= fixity, "alias" .= alias]
- ExternKindDeclaration -> []
instance A.ToJSON ChildDeclarationInfo where
toJSON info = A.object $ "declType" .= childDeclInfoToString info : props
@@ -841,7 +866,7 @@ instance A.ToJSON GithubRepo where
--
-- For example:
-- @assocListToJSON T.pack T.pack [("a", "b")]@ will give @{"a": "b"}@.
-assocListToJSON :: (a -> Text) -> (b -> Text) -> [(a, b)] -> A.Value
+assocListToJSON :: (a -> A.Key) -> (b -> Text) -> [(a, b)] -> A.Value
assocListToJSON f g xs = A.object (map (uncurry (.=) . (f *** g)) xs)
instance A.ToJSON a => A.ToJSON (InPackage a) where
@@ -850,7 +875,7 @@ instance A.ToJSON a => A.ToJSON (InPackage a) where
Local y -> withPackage (Nothing :: Maybe ()) y
FromDep pn y -> withPackage (Just pn) y
where
- withPackage :: (A.ToJSON p, A.ToJSON x) => p -> x -> A.Value
+ withPackage :: (A.ToJSON p, A.ToJSON y) => p -> y -> A.Value
withPackage p y =
A.object [ "package" .= p
, "item" .= y
diff --git a/src/Language/PureScript/Docs/Utils/MonoidExtras.hs b/src/Language/PureScript/Docs/Utils/MonoidExtras.hs
index 0d4d0bfd7f..6f2bf370e7 100644
--- a/src/Language/PureScript/Docs/Utils/MonoidExtras.hs
+++ b/src/Language/PureScript/Docs/Utils/MonoidExtras.hs
@@ -1,6 +1,6 @@
module Language.PureScript.Docs.Utils.MonoidExtras where
-import Data.Monoid
+import Data.Monoid (Monoid(..), (<>))
mintersperse :: (Monoid m) => m -> [m] -> m
mintersperse _ [] = mempty
diff --git a/src/Language/PureScript/Environment.hs b/src/Language/PureScript/Environment.hs
index 3e9505aab3..e1f857031f 100644
--- a/src/Language/PureScript/Environment.hs
+++ b/src/Language/PureScript/Environment.hs
@@ -1,63 +1,63 @@
-{-# LANGUAGE DeriveGeneric #-}
-
module Language.PureScript.Environment where
-import Prelude.Compat
-import Protolude (ordNub)
-
-import GHC.Generics (Generic)
-import Control.DeepSeq (NFData)
-import Data.Aeson ((.=), (.:))
-import qualified Data.Aeson as A
-import qualified Data.Map as M
-import qualified Data.Set as S
-import Data.Maybe (fromMaybe, mapMaybe)
-import Data.Text (Text)
-import qualified Data.Text as T
-import Data.Tree (Tree, rootLabel)
-import qualified Data.Graph as G
-import Data.Foldable (toList, fold)
-import qualified Data.List.NonEmpty as NEL
-
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Crash
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.TypeClassDictionaries
-import Language.PureScript.Types
-import qualified Language.PureScript.Constants as C
+import Prelude
+
+import GHC.Generics (Generic)
+import Control.DeepSeq (NFData)
+import Control.Monad (unless)
+import Codec.Serialise (Serialise)
+import Data.Aeson ((.=), (.:))
+import Data.Aeson qualified as A
+import Data.Foldable (find, fold)
+import Data.Functor ((<&>))
+import Data.IntMap qualified as IM
+import Data.IntSet qualified as IS
+import Data.Map qualified as M
+import Data.Set qualified as S
+import Data.Maybe (fromMaybe, mapMaybe)
+import Data.Semigroup (First(..))
+import Data.Text (Text)
+import Data.Text qualified as T
+import Data.List.NonEmpty qualified as NEL
+
+import Language.PureScript.AST.SourcePos (nullSourceAnn)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Names (Ident, ProperName(..), ProperNameType(..), Qualified, QualifiedBy, coerceProperName)
+import Language.PureScript.Roles (Role(..))
+import Language.PureScript.TypeClassDictionaries (NamedDict)
+import Language.PureScript.Types (SourceConstraint, SourceType, Type(..), TypeVarVisibility(..), eqType, srcTypeConstructor, freeTypeVariables)
+import Language.PureScript.Constants.Prim qualified as C
-- | The @Environment@ defines all values and types which are currently in scope:
data Environment = Environment
{ names :: M.Map (Qualified Ident) (SourceType, NameKind, NameVisibility)
-- ^ Values currently in scope
- , types :: M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
+ , types :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
-- ^ Type names currently in scope
, dataConstructors :: M.Map (Qualified (ProperName 'ConstructorName)) (DataDeclType, ProperName 'TypeName, SourceType, [Ident])
-- ^ Data constructors currently in scope, along with their associated type
-- constructor name, argument types and return type.
- , typeSynonyms :: M.Map (Qualified (ProperName 'TypeName)) ([(Text, Maybe SourceKind)], SourceType)
+ , typeSynonyms :: M.Map (Qualified (ProperName 'TypeName)) ([(Text, Maybe SourceType)], SourceType)
-- ^ Type synonyms currently in scope
- , typeClassDictionaries :: M.Map (Maybe ModuleName) (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict)))
+ , typeClassDictionaries :: M.Map QualifiedBy (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict)))
-- ^ Available type class dictionaries. When looking up 'Nothing' in the
-- outer map, this returns the map of type class dictionaries in local
-- scope (ie dictionaries brought in by a constrained type).
, typeClasses :: M.Map (Qualified (ProperName 'ClassName)) TypeClassData
-- ^ Type classes
- , kinds :: S.Set (Qualified (ProperName 'KindName))
- -- ^ Kinds in scope
} deriving (Show, Generic)
instance NFData Environment
-- | Information about a type class
data TypeClassData = TypeClassData
- { typeClassArguments :: [(Text, Maybe SourceKind)]
+ { typeClassArguments :: [(Text, Maybe SourceType)]
-- ^ A list of type argument names, and their kinds, where kind annotations
-- were provided.
- , typeClassMembers :: [(Ident, SourceType)]
- -- ^ A list of type class members and their types. Type arguments listed above
- -- are considered bound in these types.
+ , typeClassMembers :: [(Ident, SourceType, Maybe (S.Set (NEL.NonEmpty Int)))]
+ -- ^ A list of type class members and their types and whether or not
+ -- they have type variables that must be defined using Visible Type Applications.
+ -- Type arguments listed above are considered bound in these types.
, typeClassSuperclasses :: [SourceConstraint]
-- ^ A list of superclasses of this type class. Type arguments listed above
-- are considered bound in the types appearing in these constraints.
@@ -69,6 +69,8 @@ data TypeClassData = TypeClassData
-- typeClassArguments and typeClassDependencies.
, typeClassCoveringSets :: S.Set (S.Set Int)
-- ^ A sets of arguments that can be used to infer all other arguments.
+ , typeClassIsEmpty :: Bool
+ -- ^ Whether or not dictionaries for this type class are necessarily empty.
} deriving (Show, Generic)
instance NFData TypeClassData
@@ -83,6 +85,7 @@ data FunctionalDependency = FunctionalDependency
} deriving (Show, Generic)
instance NFData FunctionalDependency
+instance Serialise FunctionalDependency
instance A.FromJSON FunctionalDependency where
parseJSON = A.withObject "FunctionalDependency" $ \o ->
@@ -98,7 +101,7 @@ instance A.ToJSON FunctionalDependency where
-- | The initial environment with no values and only the default javascript types defined
initEnvironment :: Environment
-initEnvironment = Environment M.empty allPrimTypes M.empty M.empty M.empty allPrimClasses allPrimKinds
+initEnvironment = Environment M.empty allPrimTypes M.empty M.empty M.empty allPrimClasses
-- | A constructor for TypeClassData that computes which type class arguments are fully determined
-- and argument covering sets.
@@ -121,56 +124,108 @@ initEnvironment = Environment M.empty allPrimTypes M.empty M.empty M.empty allPr
-- determine X that X does not determine. This is the same thing: everything X determines includes everything
-- in its SCC, and everything determining X is either before it in an SCC path, or in the same SCC.
makeTypeClassData
- :: [(Text, Maybe SourceKind)]
+ :: [(Text, Maybe SourceType)]
-> [(Ident, SourceType)]
-> [SourceConstraint]
-> [FunctionalDependency]
+ -> Bool
-> TypeClassData
-makeTypeClassData args m s deps = TypeClassData args m s deps determinedArgs coveringSets
+makeTypeClassData args m s deps = TypeClassData args m' s deps determinedArgs coveringSets
+ where
+ ( determinedArgs, coveringSets ) = computeCoveringSets (length args) deps
+
+ coveringSets' = S.toList coveringSets
+
+ m' = map (\(a, b) -> (a, b, addVtaInfo b)) m
+
+ addVtaInfo :: SourceType -> Maybe (S.Set (NEL.NonEmpty Int))
+ addVtaInfo memberTy = do
+ let mentionedArgIndexes = S.fromList (mapMaybe argToIndex $ freeTypeVariables memberTy)
+ let leftovers = map (`S.difference` mentionedArgIndexes) coveringSets'
+ S.fromList <$> traverse (NEL.nonEmpty . S.toList) leftovers
+
+ argToIndex :: Text -> Maybe Int
+ argToIndex = flip M.lookup $ M.fromList (zipWith ((,) . fst) args [0..])
+
+-- A moving frontier of sets to consider, along with the fundeps that can be
+-- applied in each case. At each stage, all sets in the frontier will be the
+-- same size, decreasing by 1 each time.
+type Frontier = M.Map IS.IntSet (First (IM.IntMap (NEL.NonEmpty IS.IntSet)))
+-- ^ ^ ^ ^
+-- when *these* parameters | | |
+-- are still needed, | | |
+-- *these* parameters | |
+-- can be determined | |
+-- from a non-zero |
+-- number of fundeps, |
+-- which accept *these*
+-- parameters as inputs.
+
+computeCoveringSets :: Int -> [FunctionalDependency] -> (S.Set Int, S.Set (S.Set Int))
+computeCoveringSets nargs deps = ( determinedArgs, coveringSets )
where
- argumentIndicies = [0 .. length args - 1]
-
- -- each argument determines themselves
- identities = (\i -> (i, [i])) <$> argumentIndicies
-
- -- list all the edges in the graph: for each fundep an edge exists for each determiner to each determined
- contributingDeps = M.fromListWith (++) $ identities ++ do
- fd <- deps
- src <- fdDeterminers fd
- (src, fdDetermined fd) : map (, []) (fdDetermined fd)
-
- -- build a graph of which arguments determine other arguments
- (depGraph, fromVertex, fromKey) = G.graphFromEdges ((\(n, v) -> (n, n, ordNub v)) <$> M.toList contributingDeps)
-
- -- do there exist any arguments that contribute to `arg` that `arg` doesn't contribute to
- isFunDepDetermined :: Int -> Bool
- isFunDepDetermined arg = case fromKey arg of
- Nothing -> internalError "Unknown argument index in makeTypeClassData"
- Just v -> let contributesToVar = G.reachable (G.transposeG depGraph) v
- varContributesTo = G.reachable depGraph v
- in any (\r -> not (r `elem` varContributesTo)) contributesToVar
-
- -- find all the arguments that are determined
- determinedArgs :: S.Set Int
- determinedArgs = S.fromList $ filter isFunDepDetermined argumentIndicies
-
- argFromVertex :: G.Vertex -> Int
- argFromVertex index = let (_, arg, _) = fromVertex index in arg
-
- isVertexDetermined :: G.Vertex -> Bool
- isVertexDetermined = isFunDepDetermined . argFromVertex
-
- -- from an scc find the non-determined args
- sccNonDetermined :: Tree G.Vertex -> Maybe [Int]
- sccNonDetermined tree
- -- if any arg in an scc is determined then all of them are
- | isVertexDetermined (rootLabel tree) = Nothing
- | otherwise = Just (argFromVertex <$> toList tree)
-
- -- find the covering sets
- coveringSets :: S.Set (S.Set Int)
- coveringSets = let funDepSets = sequence (mapMaybe sccNonDetermined (G.scc depGraph))
- in S.fromList (S.fromList <$> funDepSets)
+ argumentIndices = S.fromList [0 .. nargs - 1]
+
+ -- Compute all sets of arguments that determine the remaining arguments via
+ -- functional dependencies. This is done in stages, where each stage
+ -- considers sets of the same size to share work.
+ allCoveringSets :: S.Set (S.Set Int)
+ allCoveringSets = S.map (S.fromDistinctAscList . IS.toAscList) $ fst $ search $
+ -- The initial frontier consists of just the set of all parameters and all
+ -- fundeps organized into the map structure.
+ M.singleton
+ (IS.fromList [0 .. nargs - 1]) $
+ First $ IM.fromListWith (<>) $ do
+ fd <- deps
+ let srcs = pure (IS.fromList (fdDeterminers fd))
+ tgt <- fdDetermined fd
+ pure (tgt, srcs)
+
+ where
+
+ -- Recursively advance the frontier until all frontiers are exhausted
+ -- and coverings sets found. The covering sets found during the process
+ -- are locally-minimal, in that none can be reduced by a fundep, but
+ -- there may be subsets found from other frontiers.
+ search :: Frontier -> (S.Set IS.IntSet, ())
+ search frontier = unless (null frontier) $ M.foldMapWithKey step frontier >>= search
+
+ -- The input set from the frontier is known to cover all parameters, but
+ -- it may be able to be reduced by more fundeps.
+ step :: IS.IntSet -> First (IM.IntMap (NEL.NonEmpty IS.IntSet)) -> (S.Set IS.IntSet, Frontier)
+ step needed (First inEdges)
+ -- If there are no applicable fundeps, record it as a locally minimal
+ -- covering set. This has already been reduced to only applicable fundeps
+ | IM.null inEdges = (S.singleton needed, M.empty)
+ | otherwise = (S.empty, foldMap removeParameter paramsToTry)
+
+ where
+
+ determined = IM.keys inEdges
+ -- If there is an acyclically determined functional dependency, prefer
+ -- it to reduce the number of cases to check. That is a dependency
+ -- that does not help determine other parameters.
+ acycDetermined = find (`IS.notMember` (IS.unions $ concatMap NEL.toList $ IM.elems inEdges)) determined
+ paramsToTry = maybe determined pure acycDetermined
+
+ -- For each parameter to be removed to build the next frontier,
+ -- delete the fundeps that determine it and filter out the fundeps
+ -- that make use of it. Of course, if it an acyclic fundep we already
+ -- found that there are none that use it.
+ removeParameter :: Int -> Frontier
+ removeParameter y =
+ M.singleton
+ (IS.delete y needed) $
+ case acycDetermined of
+ Just _ -> First $ IM.delete y inEdges
+ Nothing ->
+ First $ IM.mapMaybe (NEL.nonEmpty . NEL.filter (y `IS.notMember`)) $ IM.delete y inEdges
+
+ -- Reduce to the inclusion-minimal sets
+ coveringSets = S.filter (\v -> not (any (\c -> c `S.isProperSubsetOf` v) allCoveringSets)) allCoveringSets
+
+ -- An argument is determined if it is in no covering set
+ determinedArgs = argumentIndices `S.difference` fold coveringSets
-- | The visibility of a name in scope
data NameVisibility
@@ -181,6 +236,7 @@ data NameVisibility
deriving (Show, Eq, Generic)
instance NFData NameVisibility
+instance Serialise NameVisibility
-- | A flag for whether a name is for an private or public value - only public values will be
-- included in a generated externs file.
@@ -189,20 +245,21 @@ data NameKind
-- ^ A private value introduced as an artifact of code generation (class instances, class member
-- accessors, etc.)
| Public
- -- ^ A public value for a module member or foreing import declaration
+ -- ^ A public value for a module member or foreign import declaration
| External
-- ^ A name for member introduced by foreign import
deriving (Show, Eq, Generic)
instance NFData NameKind
+instance Serialise NameKind
-- | The kinds of a type
data TypeKind
- = DataType [(Text, Maybe SourceKind)] [(ProperName 'ConstructorName, [SourceType])]
+ = DataType DataDeclType [(Text, Maybe SourceType, Role)] [(ProperName 'ConstructorName, [SourceType])]
-- ^ Data type
| TypeSynonym
-- ^ Type synonym
- | ExternData
+ | ExternData [Role]
-- ^ Foreign data
| LocalTypeVariable
-- ^ A local type variable
@@ -211,29 +268,7 @@ data TypeKind
deriving (Show, Eq, Generic)
instance NFData TypeKind
-
-instance A.ToJSON TypeKind where
- toJSON (DataType args ctors) =
- A.object [ T.pack "DataType" .= A.object ["args" .= args, "ctors" .= ctors] ]
- toJSON TypeSynonym = A.toJSON (T.pack "TypeSynonym")
- toJSON ExternData = A.toJSON (T.pack "ExternData")
- toJSON LocalTypeVariable = A.toJSON (T.pack "LocalTypeVariable")
- toJSON ScopedTypeVar = A.toJSON (T.pack "ScopedTypeVar")
-
-instance A.FromJSON TypeKind where
- parseJSON (A.Object o) = do
- args <- o .: "DataType"
- A.withObject "args" (\o1 ->
- DataType <$> o1 .: "args"
- <*> o1 .: "ctors") args
- parseJSON (A.String s) =
- case s of
- "TypeSynonym" -> pure TypeSynonym
- "ExternData" -> pure ExternData
- "LocalTypeVariable" -> pure LocalTypeVariable
- "ScopedTypeVar" -> pure ScopedTypeVar
- _ -> fail "Unknown TypeKind"
- parseJSON _ = fail "Invalid TypeKind"
+instance Serialise TypeKind
-- | The type ('data' or 'newtype') of a data type declaration
data DataDeclType
@@ -244,6 +279,7 @@ data DataDeclType
deriving (Show, Eq, Ord, Generic)
instance NFData DataDeclType
+instance Serialise DataDeclType
showDataDeclType :: DataDeclType -> Text
showDataDeclType Data = "data"
@@ -253,232 +289,198 @@ instance A.ToJSON DataDeclType where
toJSON = A.toJSON . showDataDeclType
instance A.FromJSON DataDeclType where
- parseJSON = A.withText "DataDeclType" $ \str ->
- case str of
- "data" -> return Data
- "newtype" -> return Newtype
- other -> fail $ "invalid type: '" ++ T.unpack other ++ "'"
-
--- | Construct a ProperName in the Prim module
-primName :: Text -> Qualified (ProperName a)
-primName = Qualified (Just $ ModuleName [ProperName C.prim]) . ProperName
-
--- | Construct a 'ProperName' in the @Prim.NAME@ module.
-primSubName :: Text -> Text -> Qualified (ProperName a)
-primSubName sub =
- Qualified (Just $ ModuleName [ProperName C.prim, ProperName sub]) . ProperName
-
-primKind :: Text -> SourceKind
-primKind = NamedKind nullSourceAnn . primName
-
-primSubKind :: Text -> Text -> SourceKind
-primSubKind sub = NamedKind nullSourceAnn . primSubName sub
+ parseJSON = A.withText "DataDeclType" $ \case
+ "data" -> return Data
+ "newtype" -> return Newtype
+ other -> fail $ "invalid type: '" ++ T.unpack other ++ "'"
-- | Kind of ground types
-kindType :: SourceKind
-kindType = primKind C.typ
-
-kindConstraint :: SourceKind
-kindConstraint = kindType
+kindType :: SourceType
+kindType = srcTypeConstructor C.Type
-isKindType :: Kind a -> Bool
-isKindType (NamedKind _ n) = n == primName C.typ
-isKindType _ = False
+kindConstraint :: SourceType
+kindConstraint = srcTypeConstructor C.Constraint
--- To make reading the kind signatures below easier
-(-:>) :: SourceKind -> SourceKind -> SourceKind
-(-:>) = FunKind nullSourceAnn
-infixr 4 -:>
-
-kindSymbol :: SourceKind
-kindSymbol = primKind C.symbol
-
-kindDoc :: SourceKind
-kindDoc = primSubKind C.typeError C.doc
+kindSymbol :: SourceType
+kindSymbol = srcTypeConstructor C.Symbol
-kindBoolean :: SourceKind
-kindBoolean = primSubKind C.moduleBoolean C.kindBoolean
+kindDoc :: SourceType
+kindDoc = srcTypeConstructor C.Doc
-kindOrdering :: SourceKind
-kindOrdering = primSubKind C.moduleOrdering C.kindOrdering
+kindOrdering :: SourceType
+kindOrdering = srcTypeConstructor C.TypeOrdering
-kindRowList :: SourceKind
-kindRowList = primSubKind C.moduleRowList C.kindRowList
+kindRowList :: SourceType -> SourceType
+kindRowList = TypeApp nullSourceAnn (srcTypeConstructor C.RowList)
-kindRow :: SourceKind -> SourceKind
-kindRow = Row nullSourceAnn
+kindRow :: SourceType -> SourceType
+kindRow = TypeApp nullSourceAnn (srcTypeConstructor C.Row)
--- | Construct a type in the Prim module
-primTy :: Text -> SourceType
-primTy = TypeConstructor nullSourceAnn . primName
+kindOfREmpty :: SourceType
+kindOfREmpty = tyForall "k" kindType (kindRow (tyVar "k"))
-- | Type constructor for functions
tyFunction :: SourceType
-tyFunction = primTy "Function"
+tyFunction = srcTypeConstructor C.Function
-- | Type constructor for strings
tyString :: SourceType
-tyString = primTy "String"
+tyString = srcTypeConstructor C.String
-- | Type constructor for strings
tyChar :: SourceType
-tyChar = primTy "Char"
+tyChar = srcTypeConstructor C.Char
-- | Type constructor for numbers
tyNumber :: SourceType
-tyNumber = primTy "Number"
+tyNumber = srcTypeConstructor C.Number
-- | Type constructor for integers
tyInt :: SourceType
-tyInt = primTy "Int"
+tyInt = srcTypeConstructor C.Int
-- | Type constructor for booleans
tyBoolean :: SourceType
-tyBoolean = primTy "Boolean"
+tyBoolean = srcTypeConstructor C.Boolean
-- | Type constructor for arrays
tyArray :: SourceType
-tyArray = primTy "Array"
+tyArray = srcTypeConstructor C.Array
-- | Type constructor for records
tyRecord :: SourceType
-tyRecord = primTy "Record"
+tyRecord = srcTypeConstructor C.Record
--- | Check whether a type is a record
-isObject :: Type a -> Bool
-isObject = isTypeOrApplied tyRecord
+tyVar :: Text -> SourceType
+tyVar = TypeVar nullSourceAnn
--- | Check whether a type is a function
-isFunction :: Type a -> Bool
-isFunction = isTypeOrApplied tyFunction
-
-isTypeOrApplied :: Type a -> Type b -> Bool
-isTypeOrApplied t1 (TypeApp _ t2 _) = eqType t1 t2
-isTypeOrApplied t1 t2 = eqType t1 t2
+tyForall :: Text -> SourceType -> SourceType -> SourceType
+tyForall var k ty = ForAll nullSourceAnn TypeVarInvisible var (Just k) ty Nothing
-- | Smart constructor for function types
function :: SourceType -> SourceType -> SourceType
-function t1 t2 = TypeApp nullSourceAnn (TypeApp nullSourceAnn tyFunction t1) t2
-
--- | Kinds in @Prim@
-primKinds :: S.Set (Qualified (ProperName 'KindName))
-primKinds = S.fromList
- [ primName C.typ
- , primName C.symbol
- ]
+function = TypeApp nullSourceAnn . TypeApp nullSourceAnn tyFunction
--- | Kinds in @Prim.Boolean@
-primBooleanKinds :: S.Set (Qualified (ProperName 'KindName))
-primBooleanKinds = S.fromList
- [ primSubName C.moduleBoolean C.kindBoolean
- ]
-
--- | Kinds in @Prim.Ordering@
-primOrderingKinds :: S.Set (Qualified (ProperName 'KindName))
-primOrderingKinds = S.fromList
- [ primSubName C.moduleOrdering C.kindOrdering
- ]
-
--- | Kinds in @Prim.RowList@
-primRowListKinds :: S.Set (Qualified (ProperName 'KindName))
-primRowListKinds = S.fromList
- [ primSubName C.moduleRowList C.kindRowList
- ]
-
--- | Kinds in @Prim.TypeError@
-primTypeErrorKinds :: S.Set (Qualified (ProperName 'KindName))
-primTypeErrorKinds = S.fromList
- [ primSubName C.typeError C.doc
- ]
+-- To make reading the kind signatures below easier
+(-:>) :: SourceType -> SourceType -> SourceType
+(-:>) = function
+infixr 4 -:>
--- | All primitive kinds
-allPrimKinds :: S.Set (Qualified (ProperName 'KindName))
-allPrimKinds = fold
- [ primKinds
- , primBooleanKinds
- , primOrderingKinds
- , primRowListKinds
- , primTypeErrorKinds
+primClass :: Qualified (ProperName 'ClassName) -> (SourceType -> SourceType) -> [(Qualified (ProperName 'TypeName), (SourceType, TypeKind))]
+primClass name mkKind =
+ [ let k = mkKind kindConstraint
+ in (coerceProperName <$> name, (k, ExternData (nominalRolesForKind k)))
+ , let k = mkKind kindType
+ in (dictTypeName . coerceProperName <$> name, (k, TypeSynonym))
]
--- | The primitive types in the external javascript environment with their
+-- | The primitive types in the external environment with their
-- associated kinds. There are also pseudo `Fail`, `Warn`, and `Partial` types
-- that correspond to the classes with the same names.
-primTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
-primTypes = M.fromList
- [ (primName "Function", (kindType -:> kindType -:> kindType, ExternData))
- , (primName "Array", (kindType -:> kindType, ExternData))
- , (primName "Record", (kindRow kindType -:> kindType, ExternData))
- , (primName "String", (kindType, ExternData))
- , (primName "Char", (kindType, ExternData))
- , (primName "Number", (kindType, ExternData))
- , (primName "Int", (kindType, ExternData))
- , (primName "Boolean", (kindType, ExternData))
- , (primName "Partial", (kindConstraint, ExternData))
- ]
+primTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
+primTypes =
+ M.fromList
+ [ (C.Type, (kindType, ExternData []))
+ , (C.Constraint, (kindType, ExternData []))
+ , (C.Symbol, (kindType, ExternData []))
+ , (C.Row, (kindType -:> kindType, ExternData [Phantom]))
+ , (C.Function, (kindType -:> kindType -:> kindType, ExternData [Representational, Representational]))
+ , (C.Array, (kindType -:> kindType, ExternData [Representational]))
+ , (C.Record, (kindRow kindType -:> kindType, ExternData [Representational]))
+ , (C.String, (kindType, ExternData []))
+ , (C.Char, (kindType, ExternData []))
+ , (C.Number, (kindType, ExternData []))
+ , (C.Int, (kindType, ExternData []))
+ , (C.Boolean, (kindType, ExternData []))
+ , (C.Partial <&> coerceProperName, (kindConstraint, ExternData []))
+ ]
-- | This 'Map' contains all of the prim types from all Prim modules.
-allPrimTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
+allPrimTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
allPrimTypes = M.unions
[ primTypes
, primBooleanTypes
+ , primCoerceTypes
, primOrderingTypes
, primRowTypes
, primRowListTypes
, primSymbolTypes
+ , primIntTypes
, primTypeErrorTypes
]
-primBooleanTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
+primBooleanTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
primBooleanTypes =
M.fromList
- [ (primSubName C.moduleBoolean "True", (kindBoolean, ExternData))
- , (primSubName C.moduleBoolean "False", (kindBoolean, ExternData))
+ [ (C.True, (tyBoolean, ExternData []))
+ , (C.False, (tyBoolean, ExternData []))
]
-primOrderingTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
+primCoerceTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
+primCoerceTypes =
+ M.fromList $ mconcat
+ [ primClass C.Coercible (\kind -> tyForall "k" kindType $ tyVar "k" -:> tyVar "k" -:> kind)
+ ]
+
+primOrderingTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
primOrderingTypes =
M.fromList
- [ (primSubName C.moduleOrdering "LT", (kindOrdering, ExternData))
- , (primSubName C.moduleOrdering "EQ", (kindOrdering, ExternData))
- , (primSubName C.moduleOrdering "GT", (kindOrdering, ExternData))
+ [ (C.TypeOrdering, (kindType, ExternData []))
+ , (C.LT, (kindOrdering, ExternData []))
+ , (C.EQ, (kindOrdering, ExternData []))
+ , (C.GT, (kindOrdering, ExternData []))
]
-primRowTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
+primRowTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
primRowTypes =
- M.fromList
- [ (primSubName C.moduleRow "Union", (kindRow kindType -:> kindRow kindType -:> kindRow kindType -:> kindConstraint, ExternData))
- , (primSubName C.moduleRow "Nub", (kindRow kindType -:> kindRow kindType -:> kindConstraint, ExternData))
- , (primSubName C.moduleRow "Lacks", (kindSymbol -:> kindRow kindType -:> kindConstraint, ExternData))
- , (primSubName C.moduleRow "Cons", (kindSymbol -:> kindType -:> kindRow kindType -:> kindRow kindType -:> kindConstraint, ExternData))
+ M.fromList $ mconcat
+ [ primClass C.RowUnion (\kind -> tyForall "k" kindType $ kindRow (tyVar "k") -:> kindRow (tyVar "k") -:> kindRow (tyVar "k") -:> kind)
+ , primClass C.RowNub (\kind -> tyForall "k" kindType $ kindRow (tyVar "k") -:> kindRow (tyVar "k") -:> kind)
+ , primClass C.RowLacks (\kind -> tyForall "k" kindType $ kindSymbol -:> kindRow (tyVar "k") -:> kind)
+ , primClass C.RowCons (\kind -> tyForall "k" kindType $ kindSymbol -:> tyVar "k" -:> kindRow (tyVar "k") -:> kindRow (tyVar "k") -:> kind)
]
-primRowListTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
+primRowListTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
primRowListTypes =
- M.fromList
- [ (primSubName C.moduleRowList "Cons", (kindSymbol -:> kindType -:> kindRowList -:> kindRowList, ExternData))
- , (primSubName C.moduleRowList "Nil", (kindRowList, ExternData))
- , (primSubName C.moduleRowList "RowToList", (kindRow kindType -:> kindRowList -:> kindConstraint, ExternData))
+ M.fromList $
+ [ (C.RowList, (kindType -:> kindType, ExternData [Phantom]))
+ , (C.RowListCons, (tyForall "k" kindType $ kindSymbol -:> tyVar "k" -:> kindRowList (tyVar "k") -:> kindRowList (tyVar "k"), ExternData [Phantom, Phantom, Phantom]))
+ , (C.RowListNil, (tyForall "k" kindType $ kindRowList (tyVar "k"), ExternData []))
+ ] <> mconcat
+ [ primClass C.RowToList (\kind -> tyForall "k" kindType $ kindRow (tyVar "k") -:> kindRowList (tyVar "k") -:> kind)
]
-primSymbolTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
+primSymbolTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
primSymbolTypes =
- M.fromList
- [ (primSubName C.moduleSymbol "Append", (kindSymbol -:> kindSymbol -:> kindSymbol -:> kindConstraint, ExternData))
- , (primSubName C.moduleSymbol "Compare", (kindSymbol -:> kindSymbol -:> kindOrdering -:> kindConstraint, ExternData))
- , (primSubName C.moduleSymbol "Cons", (kindSymbol -:> kindSymbol -:> kindSymbol -:> kindConstraint, ExternData))
+ M.fromList $ mconcat
+ [ primClass C.SymbolAppend (\kind -> kindSymbol -:> kindSymbol -:> kindSymbol -:> kind)
+ , primClass C.SymbolCompare (\kind -> kindSymbol -:> kindSymbol -:> kindOrdering -:> kind)
+ , primClass C.SymbolCons (\kind -> kindSymbol -:> kindSymbol -:> kindSymbol -:> kind)
+ ]
+
+primIntTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
+primIntTypes =
+ M.fromList $ mconcat
+ [ primClass C.IntAdd (\kind -> tyInt -:> tyInt -:> tyInt -:> kind)
+ , primClass C.IntCompare (\kind -> tyInt -:> tyInt -:> kindOrdering -:> kind)
+ , primClass C.IntMul (\kind -> tyInt -:> tyInt -:> tyInt -:> kind)
+ , primClass C.IntToString (\kind -> tyInt -:> kindSymbol -:> kind)
]
-primTypeErrorTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
+primTypeErrorTypes :: M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
primTypeErrorTypes =
- M.fromList
- [ (primSubName C.typeError "Fail", (kindDoc -:> kindConstraint, ExternData))
- , (primSubName C.typeError "Warn", (kindDoc -:> kindConstraint, ExternData))
- , (primSubName C.typeError "Text", (kindSymbol -:> kindDoc, ExternData))
- , (primSubName C.typeError "Quote", (kindType -:> kindDoc, ExternData))
- , (primSubName C.typeError "QuoteLabel", (kindSymbol -:> kindDoc, ExternData))
- , (primSubName C.typeError "Beside", (kindDoc -:> kindDoc -:> kindDoc, ExternData))
- , (primSubName C.typeError "Above", (kindDoc -:> kindDoc -:> kindDoc, ExternData))
+ M.fromList $
+ [ (C.Doc, (kindType, ExternData []))
+ , (C.Fail <&> coerceProperName, (kindDoc -:> kindConstraint, ExternData [Nominal]))
+ , (C.Warn <&> coerceProperName, (kindDoc -:> kindConstraint, ExternData [Nominal]))
+ , (C.Text, (kindSymbol -:> kindDoc, ExternData [Phantom]))
+ , (C.Quote, (tyForall "k" kindType $ tyVar "k" -:> kindDoc, ExternData [Phantom]))
+ , (C.QuoteLabel, (kindSymbol -:> kindDoc, ExternData [Phantom]))
+ , (C.Beside, (kindDoc -:> kindDoc -:> kindDoc, ExternData [Phantom, Phantom]))
+ , (C.Above, (kindDoc -:> kindDoc -:> kindDoc, ExternData [Phantom, Phantom]))
+ ] <> mconcat
+ [ primClass C.Fail (\kind -> kindDoc -:> kind)
+ , primClass C.Warn (\kind -> kindDoc -:> kind)
]
-- | The primitive class map. This just contains the `Partial` class.
@@ -486,76 +488,88 @@ primTypeErrorTypes =
primClasses :: M.Map (Qualified (ProperName 'ClassName)) TypeClassData
primClasses =
M.fromList
- [ (primName "Partial", (makeTypeClassData [] [] [] []))
+ [ (C.Partial, makeTypeClassData [] [] [] [] True)
]
-- | This contains all of the type classes from all Prim modules.
allPrimClasses :: M.Map (Qualified (ProperName 'ClassName)) TypeClassData
allPrimClasses = M.unions
[ primClasses
+ , primCoerceClasses
, primRowClasses
, primRowListClasses
, primSymbolClasses
+ , primIntClasses
, primTypeErrorClasses
]
+primCoerceClasses :: M.Map (Qualified (ProperName 'ClassName)) TypeClassData
+primCoerceClasses =
+ M.fromList
+ -- class Coercible (a :: k) (b :: k)
+ [ (C.Coercible, makeTypeClassData
+ [ ("a", Just (tyVar "k"))
+ , ("b", Just (tyVar "k"))
+ ] [] [] [] True)
+ ]
+
primRowClasses :: M.Map (Qualified (ProperName 'ClassName)) TypeClassData
primRowClasses =
M.fromList
- -- class Union (left :: # Type) (right :: # Type) (union :: # Type) | left right -> union, right union -> left, union left -> right
- [ (primSubName C.moduleRow "Union", makeTypeClassData
- [ ("left", Just (kindRow kindType))
- , ("right", Just (kindRow kindType))
- , ("union", Just (kindRow kindType))
+ -- class Union (left :: Row k) (right :: Row k) (union :: Row k) | left right -> union, right union -> left, union left -> right
+ [ (C.RowUnion, makeTypeClassData
+ [ ("left", Just (kindRow (tyVar "k")))
+ , ("right", Just (kindRow (tyVar "k")))
+ , ("union", Just (kindRow (tyVar "k")))
] [] []
[ FunctionalDependency [0, 1] [2]
, FunctionalDependency [1, 2] [0]
, FunctionalDependency [2, 0] [1]
- ])
+ ] True)
- -- class Nub (original :: # Type) (nubbed :: # Type) | i -> o
- , (primSubName C.moduleRow "Nub", makeTypeClassData
- [ ("original", Just (kindRow kindType))
- , ("nubbed", Just (kindRow kindType))
+ -- class Nub (original :: Row k) (nubbed :: Row k) | original -> nubbed
+ , (C.RowNub, makeTypeClassData
+ [ ("original", Just (kindRow (tyVar "k")))
+ , ("nubbed", Just (kindRow (tyVar "k")))
] [] []
[ FunctionalDependency [0] [1]
- ])
+ ] True)
- -- class Lacks (label :: Symbol) (row :: # Type)
- , (primSubName C.moduleRow "Lacks", makeTypeClassData
+ -- class Lacks (label :: Symbol) (row :: Row k)
+ , (C.RowLacks, makeTypeClassData
[ ("label", Just kindSymbol)
- , ("row", Just (kindRow kindType))
- ] [] [] [])
+ , ("row", Just (kindRow (tyVar "k")))
+ ] [] [] [] True)
- -- class RowCons (label :: Symbol) (a :: Type) (tail :: # Type) (row :: # Type) | label tail a -> row, label row -> tail a
- , (primSubName C.moduleRow "Cons", makeTypeClassData
+ -- class RowCons (label :: Symbol) (a :: k) (tail :: Row k) (row :: Row k) | label tail a -> row, label row -> tail a
+ , (C.RowCons, makeTypeClassData
[ ("label", Just kindSymbol)
- , ("a", Just kindType)
- , ("tail", Just (kindRow kindType))
- , ("row", Just (kindRow kindType))
+ , ("a", Just (tyVar "k"))
+ , ("tail", Just (kindRow (tyVar "k")))
+ , ("row", Just (kindRow (tyVar "k")))
] [] []
[ FunctionalDependency [0, 1, 2] [3]
, FunctionalDependency [0, 3] [1, 2]
- ])
+ ] True)
]
primRowListClasses :: M.Map (Qualified (ProperName 'ClassName)) TypeClassData
primRowListClasses =
M.fromList
- -- class RowToList (row :: # Type) (list :: RowList) | row -> list
- [ (primSubName C.moduleRowList "RowToList", makeTypeClassData
- [ ("row", Just (kindRow kindType))
- , ("list", Just kindRowList)
+ -- class RowToList (row :: Row k) (list :: RowList k) | row -> list
+ [ (C.RowToList, makeTypeClassData
+ [ ("row", Just (kindRow (tyVar "k")))
+ , ("list", Just (kindRowList (tyVar "k")))
] [] []
[ FunctionalDependency [0] [1]
- ])
+ ] True)
]
primSymbolClasses :: M.Map (Qualified (ProperName 'ClassName)) TypeClassData
primSymbolClasses =
M.fromList
-- class Append (left :: Symbol) (right :: Symbol) (appended :: Symbol) | left right -> appended, right appended -> left, appended left -> right
- [ (primSubName C.moduleSymbol "Append", makeTypeClassData
+ [ (C.SymbolAppend, makeTypeClassData
[ ("left", Just kindSymbol)
, ("right", Just kindSymbol)
, ("appended", Just kindSymbol)
@@ -563,38 +577,79 @@ primSymbolClasses =
[ FunctionalDependency [0, 1] [2]
, FunctionalDependency [1, 2] [0]
, FunctionalDependency [2, 0] [1]
- ])
+ ] True)
-- class Compare (left :: Symbol) (right :: Symbol) (ordering :: Ordering) | left right -> ordering
- , (primSubName C.moduleSymbol "Compare", makeTypeClassData
+ , (C.SymbolCompare, makeTypeClassData
[ ("left", Just kindSymbol)
, ("right", Just kindSymbol)
, ("ordering", Just kindOrdering)
] [] []
[ FunctionalDependency [0, 1] [2]
- ])
+ ] True)
-- class Cons (head :: Symbol) (tail :: Symbol) (symbol :: Symbol) | head tail -> symbol, symbol -> head tail
- , (primSubName C.moduleSymbol "Cons", makeTypeClassData
+ , (C.SymbolCons, makeTypeClassData
[ ("head", Just kindSymbol)
, ("tail", Just kindSymbol)
, ("symbol", Just kindSymbol)
] [] []
[ FunctionalDependency [0, 1] [2]
, FunctionalDependency [2] [0, 1]
- ])
+ ] True)
+ ]
+
+primIntClasses :: M.Map (Qualified (ProperName 'ClassName)) TypeClassData
+primIntClasses =
+ M.fromList
+ -- class Add (left :: Int) (right :: Int) (sum :: Int) | left right -> sum, left sum -> right, right sum -> left
+ [ (C.IntAdd, makeTypeClassData
+ [ ("left", Just tyInt)
+ , ("right", Just tyInt)
+ , ("sum", Just tyInt)
+ ] [] []
+ [ FunctionalDependency [0, 1] [2]
+ , FunctionalDependency [0, 2] [1]
+ , FunctionalDependency [1, 2] [0]
+ ] True)
+
+ -- class Compare (left :: Int) (right :: Int) (ordering :: Ordering) | left right -> ordering
+ , (C.IntCompare, makeTypeClassData
+ [ ("left", Just tyInt)
+ , ("right", Just tyInt)
+ , ("ordering", Just kindOrdering)
+ ] [] []
+ [ FunctionalDependency [0, 1] [2]
+ ] True)
+
+ -- class Mul (left :: Int) (right :: Int) (product :: Int) | left right -> product
+ , (C.IntMul, makeTypeClassData
+ [ ("left", Just tyInt)
+ , ("right", Just tyInt)
+ , ("product", Just tyInt)
+ ] [] []
+ [ FunctionalDependency [0, 1] [2]
+ ] True)
+
+ -- class ToString (int :: Int) (string :: Symbol) | int -> string
+ , (C.IntToString, makeTypeClassData
+ [ ("int", Just tyInt)
+ , ("string", Just kindSymbol)
+ ] [] []
+ [ FunctionalDependency [0] [1]
+ ] True)
]
primTypeErrorClasses :: M.Map (Qualified (ProperName 'ClassName)) TypeClassData
primTypeErrorClasses =
M.fromList
-- class Fail (message :: Symbol)
- [ (primSubName C.typeError "Fail", makeTypeClassData
- [("message", Just kindDoc)] [] [] [])
+ [ (C.Fail, makeTypeClassData
+ [("message", Just kindDoc)] [] [] [] True)
-- class Warn (message :: Symbol)
- , (primSubName C.typeError "Warn", makeTypeClassData
- [("message", Just kindDoc)] [] [] [])
+ , (C.Warn, makeTypeClassData
+ [("message", Just kindDoc)] [] [] [] True)
]
-- | Finds information about data constructors from the current environment.
@@ -602,12 +657,31 @@ lookupConstructor :: Environment -> Qualified (ProperName 'ConstructorName) -> (
lookupConstructor env ctor =
fromMaybe (internalError "Data constructor not found") $ ctor `M.lookup` dataConstructors env
--- | Checks whether a data constructor is for a newtype.
-isNewtypeConstructor :: Environment -> Qualified (ProperName 'ConstructorName) -> Bool
-isNewtypeConstructor e ctor = case lookupConstructor e ctor of
- (Newtype, _, _, _) -> True
- (Data, _, _, _) -> False
-
-- | Finds information about values from the current environment.
lookupValue :: Environment -> Qualified Ident -> Maybe (SourceType, NameKind, NameVisibility)
lookupValue env ident = ident `M.lookup` names env
+
+dictTypeName' :: Text -> Text
+dictTypeName' = (<> "$Dict")
+
+dictTypeName :: ProperName a -> ProperName a
+dictTypeName = ProperName . dictTypeName' . runProperName
+
+isDictTypeName :: ProperName a -> Bool
+isDictTypeName = T.isSuffixOf "$Dict" . runProperName
+
+-- |
+-- Given the kind of a type, generate a list @Nominal@ roles. This is used for
+-- opaque foreign types as well as type classes.
+nominalRolesForKind :: Type a -> [Role]
+nominalRolesForKind k = replicate (kindArity k) Nominal
+
+kindArity :: Type a -> Int
+kindArity = length . fst . unapplyKinds
+
+unapplyKinds :: Type a -> ([Type a], Type a)
+unapplyKinds = go [] where
+ go kinds (TypeApp _ (TypeApp _ fn k1) k2)
+ | eqType fn tyFunction = go (k1 : kinds) k2
+ go kinds (ForAll _ _ _ _ k _) = go kinds k
+ go kinds k = (reverse kinds, k)
diff --git a/src/Language/PureScript/Errors.hs b/src/Language/PureScript/Errors.hs
index 7157f0db72..6a15c3690c 100644
--- a/src/Language/PureScript/Errors.hs
+++ b/src/Language/PureScript/Errors.hs
@@ -1,59 +1,221 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE NamedFieldPuns #-}
-
+{-# LANGUAGE DeriveAnyClass #-}
module Language.PureScript.Errors
( module Language.PureScript.AST
, module Language.PureScript.Errors
) where
-import Prelude.Compat
-import Protolude (ordNub)
-
-import Control.Arrow ((&&&))
-import Control.Monad
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.Trans.State.Lazy
-import Control.Monad.Writer
-import Data.Char (isSpace)
-import Data.Either (partitionEithers)
-import Data.Foldable (fold)
-import Data.Functor.Identity (Identity(..))
-import Data.List (transpose, nubBy, partition, dropWhileEnd, sort, sortBy)
-import qualified Data.List.NonEmpty as NEL
-import Data.Maybe (maybeToList, fromMaybe, mapMaybe)
-import qualified Data.Map as M
-import Data.Ord (comparing)
-import qualified Data.Set as S
-import qualified Data.Text as T
-import Data.Text (Text)
-import Language.PureScript.AST
-import qualified Language.PureScript.Bundle as Bundle
-import qualified Language.PureScript.Constants as C
-import Language.PureScript.Crash
-import qualified Language.PureScript.CST.Errors as CST
-import Language.PureScript.Environment
-import Language.PureScript.Label (Label(..))
-import Language.PureScript.Names
-import Language.PureScript.Pretty
-import Language.PureScript.Pretty.Common (endWith)
-import Language.PureScript.PSString (decodeStringWithReplacement)
-import Language.PureScript.Traversals
-import Language.PureScript.Types
-import qualified Language.PureScript.Publish.BoxesHelpers as BoxHelpers
-import qualified System.Console.ANSI as ANSI
-import qualified Text.Parsec as P
-import qualified Text.Parsec.Error as PE
-import Text.Parsec.Error (Message(..))
-import qualified Text.PrettyPrint.Boxes as Box
+import Prelude
+import Protolude (unsnoc)
+
+import Control.Arrow ((&&&))
+import Control.DeepSeq (NFData)
+import Control.Lens (both, head1, over)
+import Control.Monad (forM, unless)
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.Trans.State.Lazy (State, evalState, get, put)
+import Control.Monad.Writer (MonadWriter(..), censor)
+import Data.Monoid (Last(..))
+import Data.Bifunctor (first, second)
+import Data.Bitraversable (bitraverse)
+import Data.Char (isSpace)
+import Data.Containers.ListUtils (nubOrdOn)
+import Data.Either (partitionEithers)
+import Data.Foldable (fold)
+import Data.Function (on)
+import Data.Functor (($>))
+import Data.Functor.Identity (Identity(..))
+import Data.List (transpose, nubBy, partition, dropWhileEnd, sortOn, uncons)
+import Data.List.NonEmpty qualified as NEL
+import Data.List.NonEmpty (NonEmpty((:|)))
+import Data.Maybe (maybeToList, fromMaybe, isJust, mapMaybe)
+import Data.Map qualified as M
+import Data.Ord (Down(..))
+import Data.Set qualified as S
+import Data.Text qualified as T
+import Data.Text (Text)
+import Data.Traversable (for)
+import GHC.Generics (Generic)
+import GHC.Stack qualified
+import Language.PureScript.AST
+import Language.PureScript.Bundle qualified as Bundle
+import Language.PureScript.Constants.Libs qualified as C
+import Language.PureScript.Constants.Prim qualified as C
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.CST.Errors qualified as CST
+import Language.PureScript.CST.Print qualified as CST
+import Language.PureScript.Label (Label(..))
+import Language.PureScript.Names
+import Language.PureScript.Pretty (prettyPrintBinderAtom, prettyPrintLabel, prettyPrintObjectKey, prettyPrintSuggestedType, prettyPrintValue, typeAsBox, typeAtomAsBox, typeDiffAsBox)
+import Language.PureScript.Pretty.Common (endWith)
+import Language.PureScript.PSString (decodeStringWithReplacement)
+import Language.PureScript.Roles (Role, displayRole)
+import Language.PureScript.Traversals (sndM)
+import Language.PureScript.Types (Constraint(..), ConstraintData(..), RowListItem(..), SourceConstraint, SourceType, Type(..), eraseForAllKindAnnotations, eraseKindApps, everywhereOnTypesTopDownM, getAnnForType, isMonoType, overConstraintArgs, rowFromList, rowToList, srcTUnknown)
+import Language.PureScript.Publish.BoxesHelpers qualified as BoxHelpers
+import System.Console.ANSI qualified as ANSI
+import System.FilePath (makeRelative)
+import Text.PrettyPrint.Boxes qualified as Box
+import Witherable (wither)
+
+-- | A type of error messages
+data SimpleErrorMessage
+ = InternalCompilerError Text Text
+ | ModuleNotFound ModuleName
+ | ErrorParsingFFIModule FilePath (Maybe Bundle.ErrorMessage)
+ | ErrorParsingCSTModule CST.ParserError
+ | WarningParsingCSTModule CST.ParserWarning
+ | MissingFFIModule ModuleName
+ | UnnecessaryFFIModule ModuleName FilePath
+ | MissingFFIImplementations ModuleName [Ident]
+ | UnusedFFIImplementations ModuleName [Ident]
+ | InvalidFFIIdentifier ModuleName Text
+ | DeprecatedFFIPrime ModuleName Text
+ | DeprecatedFFICommonJSModule ModuleName FilePath
+ | UnsupportedFFICommonJSExports ModuleName [Text]
+ | UnsupportedFFICommonJSImports ModuleName [Text]
+ | FileIOError Text Text -- ^ A description of what we were trying to do, and the error which occurred
+ | InfiniteType SourceType
+ | InfiniteKind SourceType
+ | MultipleValueOpFixities (OpName 'ValueOpName)
+ | MultipleTypeOpFixities (OpName 'TypeOpName)
+ | OrphanTypeDeclaration Ident
+ | OrphanKindDeclaration (ProperName 'TypeName)
+ | OrphanRoleDeclaration (ProperName 'TypeName)
+ | RedefinedIdent Ident
+ | OverlappingNamesInLet Ident
+ | UnknownName (Qualified Name)
+ | UnknownImport ModuleName Name
+ | UnknownImportDataConstructor ModuleName (ProperName 'TypeName) (ProperName 'ConstructorName)
+ | UnknownExport Name
+ | UnknownExportDataConstructor (ProperName 'TypeName) (ProperName 'ConstructorName)
+ | ScopeConflict Name [ModuleName]
+ | ScopeShadowing Name (Maybe ModuleName) [ModuleName]
+ | DeclConflict Name Name
+ | ExportConflict (Qualified Name) (Qualified Name)
+ | DuplicateModule ModuleName
+ | DuplicateTypeClass (ProperName 'ClassName) SourceSpan
+ | DuplicateInstance Ident SourceSpan
+ | DuplicateTypeArgument Text
+ | InvalidDoBind
+ | InvalidDoLet
+ | CycleInDeclaration Ident
+ | CycleInTypeSynonym (NEL.NonEmpty (ProperName 'TypeName))
+ | CycleInTypeClassDeclaration (NEL.NonEmpty (Qualified (ProperName 'ClassName)))
+ | CycleInKindDeclaration (NEL.NonEmpty (Qualified (ProperName 'TypeName)))
+ | CycleInModules (NEL.NonEmpty ModuleName)
+ | NameIsUndefined Ident
+ | UndefinedTypeVariable (ProperName 'TypeName)
+ | PartiallyAppliedSynonym (Qualified (ProperName 'TypeName))
+ | EscapedSkolem Text (Maybe SourceSpan) SourceType
+ | TypesDoNotUnify SourceType SourceType
+ | KindsDoNotUnify SourceType SourceType
+ | ConstrainedTypeUnified SourceType SourceType
+ | OverlappingInstances (Qualified (ProperName 'ClassName)) [SourceType] [Qualified (Either SourceType Ident)]
+ | NoInstanceFound
+ SourceConstraint -- ^ constraint that could not be solved
+ [Qualified (Either SourceType Ident)] -- ^ a list of instances that stopped further progress in instance chains due to ambiguity
+ UnknownsHint -- ^ whether eliminating unknowns with annotations might help or if visible type applications are required
+ | AmbiguousTypeVariables SourceType [(Text, Int)]
+ | UnknownClass (Qualified (ProperName 'ClassName))
+ | PossiblyInfiniteInstance (Qualified (ProperName 'ClassName)) [SourceType]
+ | PossiblyInfiniteCoercibleInstance
+ | CannotDerive (Qualified (ProperName 'ClassName)) [SourceType]
+ | InvalidDerivedInstance (Qualified (ProperName 'ClassName)) [SourceType] Int
+ | ExpectedTypeConstructor (Qualified (ProperName 'ClassName)) [SourceType] SourceType
+ | InvalidNewtypeInstance (Qualified (ProperName 'ClassName)) [SourceType]
+ | MissingNewtypeSuperclassInstance (Qualified (ProperName 'ClassName)) (Qualified (ProperName 'ClassName)) [SourceType]
+ | UnverifiableSuperclassInstance (Qualified (ProperName 'ClassName)) (Qualified (ProperName 'ClassName)) [SourceType]
+ | CannotFindDerivingType (ProperName 'TypeName)
+ | DuplicateLabel Label (Maybe Expr)
+ | DuplicateValueDeclaration Ident
+ | ArgListLengthsDiffer Ident
+ | OverlappingArgNames (Maybe Ident)
+ | MissingClassMember (NEL.NonEmpty (Ident, SourceType))
+ | ExtraneousClassMember Ident (Qualified (ProperName 'ClassName))
+ | ExpectedType SourceType SourceType
+ -- | constructor name, expected argument count, actual argument count
+ | IncorrectConstructorArity (Qualified (ProperName 'ConstructorName)) Int Int
+ | ExprDoesNotHaveType Expr SourceType
+ | PropertyIsMissing Label
+ | AdditionalProperty Label
+ | OrphanInstance Ident (Qualified (ProperName 'ClassName)) (S.Set ModuleName) [SourceType]
+ | InvalidNewtype (ProperName 'TypeName)
+ | InvalidInstanceHead SourceType
+ | TransitiveExportError DeclarationRef [DeclarationRef]
+ | TransitiveDctorExportError DeclarationRef [ProperName 'ConstructorName]
+ | HiddenConstructors DeclarationRef (Qualified (ProperName 'ClassName))
+ | ShadowedName Ident
+ | ShadowedTypeVar Text
+ | UnusedTypeVar Text
+ | UnusedName Ident
+ | UnusedDeclaration Ident
+ | WildcardInferredType SourceType Context
+ | HoleInferredType Text SourceType Context (Maybe TypeSearch)
+ | MissingTypeDeclaration Ident SourceType
+ | MissingKindDeclaration KindSignatureFor (ProperName 'TypeName) SourceType
+ | OverlappingPattern [[Binder]] Bool
+ | IncompleteExhaustivityCheck
+ | ImportHidingModule ModuleName
+ | UnusedImport ModuleName (Maybe ModuleName)
+ | UnusedExplicitImport ModuleName [Name] (Maybe ModuleName) [DeclarationRef]
+ | UnusedDctorImport ModuleName (ProperName 'TypeName) (Maybe ModuleName) [DeclarationRef]
+ | UnusedDctorExplicitImport ModuleName (ProperName 'TypeName) [ProperName 'ConstructorName] (Maybe ModuleName) [DeclarationRef]
+ | DuplicateSelectiveImport ModuleName
+ | DuplicateImport ModuleName ImportDeclarationType (Maybe ModuleName)
+ | DuplicateImportRef Name
+ | DuplicateExportRef Name
+ | IntOutOfRange Integer Text Integer Integer
+ | ImplicitQualifiedImport ModuleName ModuleName [DeclarationRef]
+ | ImplicitQualifiedImportReExport ModuleName ModuleName [DeclarationRef]
+ | ImplicitImport ModuleName [DeclarationRef]
+ | HidingImport ModuleName [DeclarationRef]
+ | CaseBinderLengthDiffers Int [Binder]
+ | IncorrectAnonymousArgument
+ | InvalidOperatorInBinder (Qualified (OpName 'ValueOpName)) (Qualified Ident)
+ | CannotGeneralizeRecursiveFunction Ident SourceType
+ | CannotDeriveNewtypeForData (ProperName 'TypeName)
+ | ExpectedWildcard (ProperName 'TypeName)
+ | CannotUseBindWithDo Ident
+ -- | instance name, type class, expected argument count, actual argument count
+ | ClassInstanceArityMismatch Ident (Qualified (ProperName 'ClassName)) Int Int
+ -- | a user-defined warning raised by using the Warn type class
+ | UserDefinedWarning SourceType
+ | CannotDefinePrimModules ModuleName
+ | MixedAssociativityError (NEL.NonEmpty (Qualified (OpName 'AnyOpName), Associativity))
+ | NonAssociativeError (NEL.NonEmpty (Qualified (OpName 'AnyOpName)))
+ | QuantificationCheckFailureInKind Text
+ | QuantificationCheckFailureInType [Int] SourceType
+ | VisibleQuantificationCheckFailureInType Text
+ | UnsupportedTypeInKind SourceType
+ -- | Declared role was more permissive than inferred.
+ | RoleMismatch
+ Text -- ^ Type variable in question
+ Role -- ^ inferred role
+ Role -- ^ declared role
+ | InvalidCoercibleInstanceDeclaration [SourceType]
+ | UnsupportedRoleDeclaration
+ | RoleDeclarationArityMismatch (ProperName 'TypeName) Int Int
+ | DuplicateRoleDeclaration (ProperName 'TypeName)
+ | CannotDeriveInvalidConstructorArg (Qualified (ProperName 'ClassName)) [Qualified (ProperName 'ClassName)] Bool
+ | CannotSkipTypeApplication SourceType
+ | CannotApplyExpressionOfTypeOnType SourceType SourceType
+ deriving (Show, Generic, NFData)
+
+data ErrorMessage = ErrorMessage
+ [ErrorMessageHint]
+ SimpleErrorMessage
+ deriving (Show, Generic, NFData)
newtype ErrorSuggestion = ErrorSuggestion Text
-- | Get the source span for an error
errorSpan :: ErrorMessage -> Maybe (NEL.NonEmpty SourceSpan)
-errorSpan = findHint matchSpan
+errorSpan = findHint matchPE <> findHint matchRP
where
- matchSpan (PositionedError ss) = Just ss
- matchSpan _ = Nothing
+ matchPE (PositionedError sss) = Just sss
+ matchPE _ = Nothing
+ matchRP (RelatedPositions sss) = Just sss
+ matchRP _ = Nothing
-- | Get the module name for an error
errorModule :: ErrorMessage -> Maybe ModuleName
@@ -76,25 +238,30 @@ stripModuleAndSpan (ErrorMessage hints e) = ErrorMessage (filter (not . shouldSt
-- | Get the error code for a particular error type
errorCode :: ErrorMessage -> Text
errorCode em = case unwrapErrorMessage em of
+ InternalCompilerError{} -> "InternalCompilerError"
ModuleNotFound{} -> "ModuleNotFound"
ErrorParsingFFIModule{} -> "ErrorParsingFFIModule"
- ErrorParsingModule{} -> "ErrorParsingModule"
ErrorParsingCSTModule{} -> "ErrorParsingModule"
+ WarningParsingCSTModule{} -> "WarningParsingModule"
MissingFFIModule{} -> "MissingFFIModule"
UnnecessaryFFIModule{} -> "UnnecessaryFFIModule"
MissingFFIImplementations{} -> "MissingFFIImplementations"
UnusedFFIImplementations{} -> "UnusedFFIImplementations"
InvalidFFIIdentifier{} -> "InvalidFFIIdentifier"
- CannotGetFileInfo{} -> "CannotGetFileInfo"
- CannotReadFile{} -> "CannotReadFile"
- CannotWriteFile{} -> "CannotWriteFile"
+ DeprecatedFFIPrime{} -> "DeprecatedFFIPrime"
+ DeprecatedFFICommonJSModule {} -> "DeprecatedFFICommonJSModule"
+ UnsupportedFFICommonJSExports {} -> "UnsupportedFFICommonJSExports"
+ UnsupportedFFICommonJSImports {} -> "UnsupportedFFICommonJSImports"
+ FileIOError{} -> "FileIOError"
InfiniteType{} -> "InfiniteType"
InfiniteKind{} -> "InfiniteKind"
MultipleValueOpFixities{} -> "MultipleValueOpFixities"
MultipleTypeOpFixities{} -> "MultipleTypeOpFixities"
OrphanTypeDeclaration{} -> "OrphanTypeDeclaration"
+ OrphanKindDeclaration{} -> "OrphanKindDeclaration"
+ OrphanRoleDeclaration{} -> "OrphanRoleDeclaration"
RedefinedIdent{} -> "RedefinedIdent"
- OverlappingNamesInLet -> "OverlappingNamesInLet"
+ OverlappingNamesInLet{} -> "OverlappingNamesInLet"
UnknownName{} -> "UnknownName"
UnknownImport{} -> "UnknownImport"
UnknownImportDataConstructor{} -> "UnknownImportDataConstructor"
@@ -113,6 +280,7 @@ errorCode em = case unwrapErrorMessage em of
CycleInDeclaration{} -> "CycleInDeclaration"
CycleInTypeSynonym{} -> "CycleInTypeSynonym"
CycleInTypeClassDeclaration{} -> "CycleInTypeClassDeclaration"
+ CycleInKindDeclaration{} -> "CycleInKindDeclaration"
CycleInModules{} -> "CycleInModules"
NameIsUndefined{} -> "NameIsUndefined"
UndefinedTypeVariable{} -> "UndefinedTypeVariable"
@@ -126,6 +294,7 @@ errorCode em = case unwrapErrorMessage em of
AmbiguousTypeVariables{} -> "AmbiguousTypeVariables"
UnknownClass{} -> "UnknownClass"
PossiblyInfiniteInstance{} -> "PossiblyInfiniteInstance"
+ PossiblyInfiniteCoercibleInstance -> "PossiblyInfiniteCoercibleInstance"
CannotDerive{} -> "CannotDerive"
InvalidNewtypeInstance{} -> "InvalidNewtypeInstance"
MissingNewtypeSuperclassInstance{} -> "MissingNewtypeSuperclassInstance"
@@ -144,21 +313,23 @@ errorCode em = case unwrapErrorMessage em of
ExprDoesNotHaveType{} -> "ExprDoesNotHaveType"
PropertyIsMissing{} -> "PropertyIsMissing"
AdditionalProperty{} -> "AdditionalProperty"
- TypeSynonymInstance -> "TypeSynonymInstance"
OrphanInstance{} -> "OrphanInstance"
InvalidNewtype{} -> "InvalidNewtype"
InvalidInstanceHead{} -> "InvalidInstanceHead"
TransitiveExportError{} -> "TransitiveExportError"
TransitiveDctorExportError{} -> "TransitiveDctorExportError"
+ HiddenConstructors{} -> "HiddenConstructors"
ShadowedName{} -> "ShadowedName"
+ UnusedName{} -> "UnusedName"
+ UnusedDeclaration{} -> "UnusedDeclaration"
ShadowedTypeVar{} -> "ShadowedTypeVar"
UnusedTypeVar{} -> "UnusedTypeVar"
WildcardInferredType{} -> "WildcardInferredType"
HoleInferredType{} -> "HoleInferredType"
MissingTypeDeclaration{} -> "MissingTypeDeclaration"
+ MissingKindDeclaration{} -> "MissingKindDeclaration"
OverlappingPattern{} -> "OverlappingPattern"
IncompleteExhaustivityCheck{} -> "IncompleteExhaustivityCheck"
- MisleadingEmptyTypeImport{} -> "MisleadingEmptyTypeImport"
ImportHidingModule{} -> "ImportHidingModule"
UnusedImport{} -> "UnusedImport"
UnusedExplicitImport{} -> "UnusedExplicitImport"
@@ -182,15 +353,28 @@ errorCode em = case unwrapErrorMessage em of
CannotUseBindWithDo{} -> "CannotUseBindWithDo"
ClassInstanceArityMismatch{} -> "ClassInstanceArityMismatch"
UserDefinedWarning{} -> "UserDefinedWarning"
- UnusableDeclaration{} -> "UnusableDeclaration"
CannotDefinePrimModules{} -> "CannotDefinePrimModules"
MixedAssociativityError{} -> "MixedAssociativityError"
NonAssociativeError{} -> "NonAssociativeError"
+ QuantificationCheckFailureInKind {} -> "QuantificationCheckFailureInKind"
+ QuantificationCheckFailureInType {} -> "QuantificationCheckFailureInType"
+ VisibleQuantificationCheckFailureInType {} -> "VisibleQuantificationCheckFailureInType"
+ UnsupportedTypeInKind {} -> "UnsupportedTypeInKind"
+ RoleMismatch {} -> "RoleMismatch"
+ InvalidCoercibleInstanceDeclaration {} -> "InvalidCoercibleInstanceDeclaration"
+ UnsupportedRoleDeclaration {} -> "UnsupportedRoleDeclaration"
+ RoleDeclarationArityMismatch {} -> "RoleDeclarationArityMismatch"
+ DuplicateRoleDeclaration {} -> "DuplicateRoleDeclaration"
+ CannotDeriveInvalidConstructorArg{} -> "CannotDeriveInvalidConstructorArg"
+ CannotSkipTypeApplication{} -> "CannotSkipTypeApplication"
+ CannotApplyExpressionOfTypeOnType{} -> "CannotApplyExpressionOfTypeOnType"
-- | A stack trace for an error
newtype MultipleErrors = MultipleErrors
{ runMultipleErrors :: [ErrorMessage]
- } deriving (Show, Semigroup, Monoid)
+ }
+ deriving stock (Show)
+ deriving newtype (Semigroup, Monoid, NFData)
-- | Check whether a collection of errors is empty or not.
nonEmpty :: MultipleErrors -> Bool
@@ -213,8 +397,7 @@ errorMessage''' :: [SourceSpan] -> SimpleErrorMessage -> MultipleErrors
errorMessage''' sss err =
maybe (errorMessage err) (flip errorMessage'' err)
. NEL.nonEmpty
- . reverse
- . sort
+ . sortOn Down
$ filter (/= NullSourceSpan) sss
-- | Create an error set from a single error message
@@ -255,7 +438,7 @@ unwrapErrorMessage :: ErrorMessage -> SimpleErrorMessage
unwrapErrorMessage (ErrorMessage _ se) = se
replaceUnknowns :: SourceType -> State TypeMap SourceType
-replaceUnknowns = everywhereOnTypesM replaceTypes where
+replaceUnknowns = everywhereOnTypesTopDownM replaceTypes where
replaceTypes :: SourceType -> State TypeMap SourceType
replaceTypes (TUnknown ann u) = do
m <- get
@@ -265,14 +448,17 @@ replaceUnknowns = everywhereOnTypesM replaceTypes where
put $ m { umUnknownMap = M.insert u u' (umUnknownMap m), umNextIndex = u' + 1 }
return (TUnknown ann u')
Just u' -> return (TUnknown ann u')
- replaceTypes (Skolem ann name s sko) = do
+ -- We intentionally remove the kinds from skolems, because they are never
+ -- presented when pretty-printing. Any unknowns in those kinds shouldn't
+ -- appear in the list of unknowns unless used somewhere else.
+ replaceTypes (Skolem ann name _ s sko) = do
m <- get
case M.lookup s (umSkolemMap m) of
Nothing -> do
let s' = umNextIndex m
put $ m { umSkolemMap = M.insert s (T.unpack name, s', Just (fst ann)) (umSkolemMap m), umNextIndex = s' + 1 }
- return (Skolem ann name s' sko)
- Just (_, s', _) -> return (Skolem ann name s' sko)
+ return (Skolem ann name Nothing s' sko)
+ Just (_, s', _) -> return (Skolem ann name Nothing s' sko)
replaceTypes other = return other
onTypesInErrorMessage :: (SourceType -> SourceType) -> ErrorMessage -> ErrorMessage
@@ -286,9 +472,9 @@ onTypesInErrorMessageM f (ErrorMessage hints simple) = ErrorMessage <$> traverse
gSimple (ConstrainedTypeUnified t1 t2) = ConstrainedTypeUnified <$> f t1 <*> f t2
gSimple (ExprDoesNotHaveType e t) = ExprDoesNotHaveType e <$> f t
gSimple (InvalidInstanceHead t) = InvalidInstanceHead <$> f t
- gSimple (NoInstanceFound con) = NoInstanceFound <$> overConstraintArgs (traverse f) con
- gSimple (AmbiguousTypeVariables t con) = AmbiguousTypeVariables <$> f t <*> pure con
- gSimple (OverlappingInstances cl ts insts) = OverlappingInstances cl <$> traverse f ts <*> pure insts
+ gSimple (NoInstanceFound con ambig unks) = NoInstanceFound <$> overConstraintArgs (traverse f) con <*> pure ambig <*> pure unks
+ gSimple (AmbiguousTypeVariables t uis) = AmbiguousTypeVariables <$> f t <*> pure uis
+ gSimple (OverlappingInstances cl ts insts) = OverlappingInstances cl <$> traverse f ts <*> traverse (traverse $ bitraverse f pure) insts
gSimple (PossiblyInfiniteInstance cl ts) = PossiblyInfiniteInstance cl <$> traverse f ts
gSimple (CannotDerive cl ts) = CannotDerive cl <$> traverse f ts
gSimple (InvalidNewtypeInstance cl ts) = InvalidNewtypeInstance cl <$> traverse f ts
@@ -301,13 +487,16 @@ onTypesInErrorMessageM f (ErrorMessage hints simple) = ErrorMessage <$> traverse
gSimple (WildcardInferredType ty ctx) = WildcardInferredType <$> f ty <*> traverse (sndM f) ctx
gSimple (HoleInferredType name ty ctx env) = HoleInferredType name <$> f ty <*> traverse (sndM f) ctx <*> traverse (onTypeSearchTypesM f) env
gSimple (MissingTypeDeclaration nm ty) = MissingTypeDeclaration nm <$> f ty
+ gSimple (MissingKindDeclaration sig nm ty) = MissingKindDeclaration sig nm <$> f ty
gSimple (CannotGeneralizeRecursiveFunction nm ty) = CannotGeneralizeRecursiveFunction nm <$> f ty
+ gSimple (InvalidCoercibleInstanceDeclaration tys) = InvalidCoercibleInstanceDeclaration <$> traverse f tys
gSimple other = pure other
gHint (ErrorInSubsumption t1 t2) = ErrorInSubsumption <$> f t1 <*> f t2
gHint (ErrorUnifyingTypes t1 t2) = ErrorUnifyingTypes <$> f t1 <*> f t2
gHint (ErrorCheckingType e t) = ErrorCheckingType e <$> f t
- gHint (ErrorCheckingKind t) = ErrorCheckingKind <$> f t
+ gHint (ErrorCheckingKind t k) = ErrorCheckingKind <$> f t <*> f k
+ gHint (ErrorInferringKind t) = ErrorInferringKind <$> f t
gHint (ErrorInApplication e1 t1 e2) = ErrorInApplication e1 <$> f t1 <*> pure e2
gHint (ErrorInInstance cl ts) = ErrorInInstance cl <$> traverse f ts
gHint (ErrorSolvingConstraint con) = ErrorSolvingConstraint <$> overConstraintArgs (traverse f) con
@@ -331,8 +520,21 @@ errorSuggestion err =
ImplicitQualifiedImport mn asModule refs -> suggest $ importSuggestion mn refs (Just asModule)
ImplicitQualifiedImportReExport mn asModule refs -> suggest $ importSuggestion mn refs (Just asModule)
HidingImport mn refs -> suggest $ importSuggestion mn refs Nothing
- MissingTypeDeclaration ident ty -> suggest $ showIdent ident <> " :: " <> T.pack (prettyPrintSuggestedType ty)
- WildcardInferredType ty _ -> suggest $ T.pack (prettyPrintSuggestedType ty)
+ MissingTypeDeclaration ident ty -> suggest $ showIdent ident <> " :: " <> T.pack (prettyPrintSuggestedTypeSimplified ty) <> "\n"
+ MissingKindDeclaration sig name ty -> suggest $ prettyPrintKindSignatureFor sig <> " " <> runProperName name <> " :: " <> T.pack (prettyPrintSuggestedTypeSimplified ty) <> "\n"
+ WildcardInferredType ty _ -> suggest $ T.pack (prettyPrintSuggestedTypeSimplified ty)
+ WarningParsingCSTModule pe -> do
+ let toks = CST.errToks pe
+ case CST.errType pe of
+ CST.WarnDeprecatedRowSyntax -> do
+ let kind = CST.printTokens $ drop 1 toks
+ sugg | " " `T.isPrefixOf` kind = "Row" <> kind
+ | otherwise = "Row " <> kind
+ suggest sugg
+ CST.WarnDeprecatedForeignKindSyntax -> suggest $ "data " <> CST.printTokens (drop 3 toks)
+ CST.WarnDeprecatedKindImportSyntax -> suggest $ CST.printTokens $ drop 1 toks
+ CST.WarnDeprecatedKindExportSyntax -> suggest $ CST.printTokens $ drop 1 toks
+ CST.WarnDeprecatedCaseOfOffsideSyntax -> Nothing
_ -> Nothing
where
emptySuggestion = Just $ ErrorSuggestion ""
@@ -358,6 +560,7 @@ suggestionSpan e =
getSpan simple ss =
case simple of
MissingTypeDeclaration{} -> startOnly ss
+ MissingKindDeclaration{} -> startOnly ss
_ -> ss
showSuggestion :: SimpleErrorMessage -> Text
@@ -366,8 +569,8 @@ showSuggestion suggestion = case errorSuggestion suggestion of
_ -> ""
ansiColor :: (ANSI.ColorIntensity, ANSI.Color) -> String
-ansiColor (intesity, color) =
- ANSI.setSGRCode [ANSI.SetColor ANSI.Foreground intesity color]
+ansiColor (intensity, color) =
+ ANSI.setSGRCode [ANSI.SetColor ANSI.Foreground intensity color]
ansiColorReset :: String
ansiColorReset =
@@ -391,8 +594,14 @@ colorCodeBox codeColor b = case codeColor of
, Box.vcat Box.top $ replicate (Box.rows b) $ Box.text ansiColorReset
]
+commasAndConjunction :: Text -> [Text] -> Text
+commasAndConjunction conj = \case
+ [x] -> x
+ [x, y] -> x <> " " <> conj <> " " <> y
+ (unsnoc -> Just (rest, z)) -> foldMap (<> ", ") rest <> conj <> " " <> z
+ _ -> ""
--- | Default color intesity and color for code
+-- | Default color intensity and color for code
defaultCodeColor :: (ANSI.ColorIntensity, ANSI.Color)
defaultCodeColor = (ANSI.Dull, ANSI.Yellow)
@@ -403,6 +612,7 @@ data PPEOptions = PPEOptions
, ppeLevel :: Level -- ^ Should this report an error or a warning?
, ppeShowDocs :: Bool -- ^ Should show a link to error message's doc page?
, ppeRelativeDirectory :: FilePath -- ^ FilePath to which the errors are relative
+ , ppeFileContents :: [(FilePath, Text)] -- ^ Unparsed contents of source files
}
-- | Default options for PPEOptions
@@ -413,11 +623,12 @@ defaultPPEOptions = PPEOptions
, ppeLevel = Error
, ppeShowDocs = True
, ppeRelativeDirectory = mempty
+ , ppeFileContents = []
}
-- | Pretty print a single error, simplifying if necessary
prettyPrintSingleError :: PPEOptions -> ErrorMessage -> Box.Box
-prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = flip evalState defaultUnknownMap $ do
+prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath fileContents) e = flip evalState defaultUnknownMap $ do
em <- onTypesInErrorMessageM replaceUnknowns (if full then e else simplifyErrorMessage e)
um <- get
return (prettyPrintErrorMessage um em)
@@ -456,6 +667,12 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
unknownInfo u = line $ markCode ("t" <> T.pack (show u)) <> " is an unknown type"
renderSimpleErrorMessage :: SimpleErrorMessage -> Box.Box
+ renderSimpleErrorMessage (InternalCompilerError ctx err) =
+ paras [ line "Internal compiler error:"
+ , indent $ line err
+ , line ctx
+ , line "Please report this at https://github.com/purescript/purescript/issues"
+ ]
renderSimpleErrorMessage (ModuleNotFound mn) =
paras [ line $ "Module " <> markCode (runModuleName mn) <> " was not found."
, line $
@@ -465,31 +682,22 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
else
"Make sure the source file exists, and that it has been provided as an input to the compiler."
]
- renderSimpleErrorMessage (CannotGetFileInfo path) =
- paras [ line "Unable to read file info: "
- , indent . lineS $ path
- ]
- renderSimpleErrorMessage (CannotReadFile path) =
- paras [ line "Unable to read file: "
- , indent . lineS $ path
- ]
- renderSimpleErrorMessage (CannotWriteFile path) =
- paras [ line "Unable to write file: "
- , indent . lineS $ path
+ renderSimpleErrorMessage (FileIOError doWhat err) =
+ paras [ line $ "I/O error while trying to " <> doWhat
+ , indent . line $ err
]
renderSimpleErrorMessage (ErrorParsingFFIModule path extra) =
paras $ [ line "Unable to parse foreign module:"
, indent . lineS $ path
] ++
map (indent . lineS) (concatMap Bundle.printErrorMessage (maybeToList extra))
- renderSimpleErrorMessage (ErrorParsingModule err) =
- paras [ line "Unable to parse module: "
- , prettyPrintParseError err
- ]
renderSimpleErrorMessage (ErrorParsingCSTModule err) =
paras [ line "Unable to parse module: "
, line $ T.pack $ CST.prettyPrintErrorMessage err
]
+ renderSimpleErrorMessage (WarningParsingCSTModule err) =
+ paras [ line $ T.pack $ CST.prettyPrintWarningMessage err
+ ]
renderSimpleErrorMessage (MissingFFIModule mn) =
line $ "The foreign module implementation for module " <> markCode (runModuleName mn) <> " is missing."
renderSimpleErrorMessage (UnnecessaryFFIModule mn path) =
@@ -512,19 +720,39 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
, line "Note that exported identifiers in FFI modules must be valid PureScript identifiers."
]
]
+ renderSimpleErrorMessage (DeprecatedFFIPrime mn ident) =
+ paras [ line $ "In the FFI module for " <> markCode (runModuleName mn) <> ":"
+ , indent . paras $
+ [ line $ "The identifier " <> markCode ident <> " contains a prime (" <> markCode "'" <> ")."
+ , line "Primes are not allowed in identifiers exported from FFI modules."
+ ]
+ ]
+ renderSimpleErrorMessage (DeprecatedFFICommonJSModule mn path) =
+ paras [ line $ "A CommonJS foreign module implementation was provided for module " <> markCode (runModuleName mn) <> ": "
+ , indent . lineS $ path
+ , line "CommonJS foreign modules are no longer supported. Use native JavaScript/ECMAScript module syntax instead."
+ ]
+ renderSimpleErrorMessage (UnsupportedFFICommonJSExports mn idents) =
+ paras [ line $ "The following CommonJS exports are not supported in the ES foreign module for module " <> markCode (runModuleName mn) <> ": "
+ , indent . paras $ map line idents
+ ]
+ renderSimpleErrorMessage (UnsupportedFFICommonJSImports mn mids) =
+ paras [ line $ "The following CommonJS imports are not supported in the ES foreign module for module " <> markCode (runModuleName mn) <> ": "
+ , indent . paras $ map line mids
+ ]
renderSimpleErrorMessage InvalidDoBind =
line "The last statement in a 'do' block must be an expression, but this block ends with a binder."
renderSimpleErrorMessage InvalidDoLet =
line "The last statement in a 'do' block must be an expression, but this block ends with a let binding."
- renderSimpleErrorMessage OverlappingNamesInLet =
- line "The same name was used more than once in a let binding."
+ renderSimpleErrorMessage (OverlappingNamesInLet name) =
+ line $ "The name " <> markCode (showIdent name) <> " was defined multiple times in a binding group"
renderSimpleErrorMessage (InfiniteType ty) =
paras [ line "An infinite type was inferred for an expression: "
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
]
renderSimpleErrorMessage (InfiniteKind ki) =
paras [ line "An infinite kind was inferred for a type: "
- , indent $ line $ markCode $ prettyPrintKind ki
+ , markCodeBox $ indent $ prettyType ki
]
renderSimpleErrorMessage (MultipleValueOpFixities op) =
line $ "There are multiple fixity/precedence declarations for operator " <> markCode (showOp op)
@@ -532,37 +760,43 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
line $ "There are multiple fixity/precedence declarations for type operator " <> markCode (showOp op)
renderSimpleErrorMessage (OrphanTypeDeclaration nm) =
line $ "The type declaration for " <> markCode (showIdent nm) <> " should be followed by its definition."
+ renderSimpleErrorMessage (OrphanKindDeclaration nm) =
+ line $ "The kind declaration for " <> markCode (runProperName nm) <> " should be followed by its definition."
+ renderSimpleErrorMessage (OrphanRoleDeclaration nm) =
+ line $ "The role declaration for " <> markCode (runProperName nm) <> " should follow its definition."
renderSimpleErrorMessage (RedefinedIdent name) =
line $ "The value " <> markCode (showIdent name) <> " has been defined multiple times"
- renderSimpleErrorMessage (UnknownName name@(Qualified Nothing (IdentName (Ident i)))) | i `elem` [ C.bind, C.discard ] =
- line $ "Unknown " <> printName name <> ". You're probably using do-notation, which the compiler replaces with calls to the " <> markCode i <> " function. Please import " <> markCode i <> " from module " <> markCode "Prelude"
+ renderSimpleErrorMessage (UnknownName name@(Qualified (BySourcePos _) (IdentName (Ident i)))) | i `elem` [ C.S_bind, C.S_discard ] =
+ line $ "Unknown " <> printName name <> ". You're probably using do-notation, which the compiler replaces with calls to the " <> markCode "bind" <> " and " <> markCode "discard" <> " functions. Please import " <> markCode i <> " from module " <> markCode "Prelude"
+ renderSimpleErrorMessage (UnknownName name@(Qualified (BySourcePos _) (IdentName (Ident C.S_negate)))) =
+ line $ "Unknown " <> printName name <> ". You're probably using numeric negation (the unary " <> markCode "-" <> " operator), which the compiler replaces with calls to the " <> markCode C.S_negate <> " function. Please import " <> markCode C.S_negate <> " from module " <> markCode "Prelude"
renderSimpleErrorMessage (UnknownName name) =
line $ "Unknown " <> printName name
renderSimpleErrorMessage (UnknownImport mn name) =
- paras [ line $ "Cannot import " <> printName (Qualified Nothing name) <> " from module " <> markCode (runModuleName mn)
+ paras [ line $ "Cannot import " <> printName (Qualified ByNullSourcePos name) <> " from module " <> markCode (runModuleName mn)
, line "It either does not exist or the module does not export it."
]
renderSimpleErrorMessage (UnknownImportDataConstructor mn tcon dcon) =
line $ "Module " <> runModuleName mn <> " does not export data constructor " <> markCode (runProperName dcon) <> " for type " <> markCode (runProperName tcon)
renderSimpleErrorMessage (UnknownExport name) =
- line $ "Cannot export unknown " <> printName (Qualified Nothing name)
+ line $ "Cannot export unknown " <> printName (Qualified ByNullSourcePos name)
renderSimpleErrorMessage (UnknownExportDataConstructor tcon dcon) =
line $ "Cannot export data constructor " <> markCode (runProperName dcon) <> " for type " <> markCode (runProperName tcon) <> ", as it has not been declared."
renderSimpleErrorMessage (ScopeConflict nm ms) =
- paras [ line $ "Conflicting definitions are in scope for " <> printName (Qualified Nothing nm) <> " from the following modules:"
+ paras [ line $ "Conflicting definitions are in scope for " <> printName (Qualified ByNullSourcePos nm) <> " from the following modules:"
, indent $ paras $ map (line . markCode . runModuleName) ms
]
renderSimpleErrorMessage (ScopeShadowing nm exmn ms) =
- paras [ line $ "Shadowed definitions are in scope for " <> printName (Qualified Nothing nm) <> " from the following open imports:"
+ paras [ line $ "Shadowed definitions are in scope for " <> printName (Qualified ByNullSourcePos nm) <> " from the following open imports:"
, indent $ paras $ map (line . markCode . ("import " <>) . runModuleName) ms
, line $ "These will be ignored and the " <> case exmn of
Just exmn' -> "declaration from " <> markCode (runModuleName exmn') <> " will be used."
Nothing -> "local declaration will be used."
]
renderSimpleErrorMessage (DeclConflict new existing) =
- line $ "Declaration for " <> printName (Qualified Nothing new) <> " conflicts with an existing " <> nameType existing <> " of the same name."
+ line $ "Declaration for " <> printName (Qualified ByNullSourcePos new) <> " conflicts with an existing " <> nameType existing <> " of the same name."
renderSimpleErrorMessage (ExportConflict new existing) =
- line $ "Export for " <> printName new <> " conflicts with " <> runName existing
+ line $ "Export for " <> printName new <> " conflicts with " <> printName existing
renderSimpleErrorMessage (DuplicateModule mn) =
line $ "Module " <> markCode (runModuleName mn) <> " has been defined multiple times"
renderSimpleErrorMessage (DuplicateTypeClass pn ss) =
@@ -577,26 +811,37 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
line $ "The value of " <> markCode (showIdent nm) <> " is undefined here, so this reference is not allowed."
renderSimpleErrorMessage (CycleInModules mns) =
case mns of
- [mn] ->
+ mn :| [] ->
line $ "Module " <> markCode (runModuleName mn) <> " imports itself."
_ ->
paras [ line "There is a cycle in module dependencies in these modules: "
- , indent $ paras (map (line . markCode . runModuleName) mns)
+ , indent $ paras (line . markCode . runModuleName <$> NEL.toList mns)
]
- renderSimpleErrorMessage (CycleInTypeSynonym name) =
- paras [ line $ case name of
- Just pn -> "A cycle appears in the definition of type synonym " <> markCode (runProperName pn)
- Nothing -> "A cycle appears in a set of type synonym definitions."
- , line "Cycles are disallowed because they can lead to loops in the type checker."
+ renderSimpleErrorMessage (CycleInTypeSynonym names) =
+ paras $ cycleError <>
+ [ line "Cycles are disallowed because they can lead to loops in the type checker."
, line "Consider using a 'newtype' instead."
]
- renderSimpleErrorMessage (CycleInTypeClassDeclaration [name]) =
+ where
+ cycleError = case names of
+ pn :| [] -> pure . line $ "A cycle appears in the definition of type synonym " <> markCode (runProperName pn)
+ _ -> [ line " A cycle appears in a set of type synonym definitions:"
+ , indent $ line $ "{" <> T.intercalate ", " (markCode . runProperName <$> NEL.toList names) <> "}"
+ ]
+ renderSimpleErrorMessage (CycleInTypeClassDeclaration (name :| [])) =
paras [ line $ "A type class '" <> markCode (runProperName (disqualify name)) <> "' may not have itself as a superclass." ]
renderSimpleErrorMessage (CycleInTypeClassDeclaration names) =
- paras [ line $ "A cycle appears in a set of type class definitions:"
- , indent $ line $ "{" <> (T.intercalate ", " (map (markCode . runProperName . disqualify) names)) <> "}"
+ paras [ line "A cycle appears in a set of type class definitions:"
+ , indent $ line $ "{" <> T.intercalate ", " (markCode . runProperName . disqualify <$> NEL.toList names) <> "}"
, line "Cycles are disallowed because they can lead to loops in the type checker."
]
+ renderSimpleErrorMessage (CycleInKindDeclaration (name :| [])) =
+ paras [ line $ "A kind declaration '" <> markCode (runProperName (disqualify name)) <> "' may not refer to itself in its own signature." ]
+ renderSimpleErrorMessage (CycleInKindDeclaration names) =
+ paras [ line "A cycle appears in a set of kind declarations:"
+ , indent $ line $ "{" <> T.intercalate ", " (markCode . runProperName . disqualify <$> NEL.toList names) <> "}"
+ , line "Kind declarations may not refer to themselves in their own signatures."
+ ]
renderSimpleErrorMessage (NameIsUndefined ident) =
line $ "Value " <> markCode (showIdent ident) <> " is undefined."
renderSimpleErrorMessage (UndefinedTypeVariable name) =
@@ -607,71 +852,58 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
]
renderSimpleErrorMessage (EscapedSkolem name Nothing ty) =
paras [ line $ "The type variable " <> markCode name <> " has escaped its scope, appearing in the type"
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
]
renderSimpleErrorMessage (EscapedSkolem name (Just srcSpan) ty) =
paras [ line $ "The type variable " <> markCode name <> ", bound at"
, indent $ line $ displaySourceSpan relPath srcSpan
, line "has escaped its scope, appearing in the type"
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
]
renderSimpleErrorMessage (TypesDoNotUnify u1 u2)
- = let (sorted1, sorted2) = sortRows u1 u2
-
- sortRows :: Ord a => Type a -> Type a -> (Type a, Type a)
- sortRows r1@RCons{} r2@RCons{} = sortRows' (rowToList r1) (rowToList r2)
- sortRows t1 t2 = (t1, t2)
-
- -- Put the common labels last
- sortRows' :: Ord a => ([RowListItem a], Type a) -> ([RowListItem a], Type a) -> (Type a, Type a)
- sortRows' (s1, r1) (s2, r2) =
- let elem' s (RowListItem _ name ty) = any (\(RowListItem _ name' ty') -> name == name' && eqType ty ty') s
- sort' = sortBy (comparing $ \(RowListItem _ name ty) -> (name, ty))
- (common1, unique1) = partition (elem' s2) s1
- (common2, unique2) = partition (elem' s1) s2
- in ( rowFromList (sort' unique1 ++ sort' common1, r1)
- , rowFromList (sort' unique2 ++ sort' common2, r2)
- )
+ = let (row1Box, row2Box) = printRows u1 u2
+
in paras [ line "Could not match type"
- , markCodeBox $ indent $ typeAsBox prettyDepth sorted1
+ , row1Box
, line "with type"
- , markCodeBox $ indent $ typeAsBox prettyDepth sorted2
+ , row2Box
]
renderSimpleErrorMessage (KindsDoNotUnify k1 k2) =
paras [ line "Could not match kind"
- , indent $ line $ markCode $ prettyPrintKind k1
+ , markCodeBox $ indent $ prettyType k1
, line "with kind"
- , indent $ line $ markCode $ prettyPrintKind k2
+ , markCodeBox $ indent $ prettyType k2
]
renderSimpleErrorMessage (ConstrainedTypeUnified t1 t2) =
paras [ line "Could not match constrained type"
- , markCodeBox $ indent $ typeAsBox prettyDepth t1
+ , markCodeBox $ indent $ prettyType t1
, line "with type"
- , markCodeBox $ indent $ typeAsBox prettyDepth t2
+ , markCodeBox $ indent $ prettyType t2
]
renderSimpleErrorMessage (OverlappingInstances _ _ []) = internalError "OverlappingInstances: empty instance list"
renderSimpleErrorMessage (OverlappingInstances nm ts ds) =
paras [ line "Overlapping type class instances found for"
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName nm)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
, line "The following instances were found:"
- , indent $ paras (map (line . showQualified showIdent) ds)
+ , indent $ paras (map prettyInstanceName ds)
]
renderSimpleErrorMessage (UnknownClass nm) =
paras [ line "No type class instance was found for class"
, markCodeBox $ indent $ line (showQualified runProperName nm)
, line "because the class was not in scope. Perhaps it was not exported."
]
- renderSimpleErrorMessage (NoInstanceFound (Constraint _ C.Fail [ ty ] _)) | Just box <- toTypelevelString ty =
- paras [ line "A custom type error occurred while solving type class constraints:"
+ renderSimpleErrorMessage (NoInstanceFound (Constraint _ C.Fail _ [ ty ] _) _ _) | Just box <- toTypelevelString ty =
+ paras [ line "Custom error:"
, indent box
]
renderSimpleErrorMessage (NoInstanceFound (Constraint _ C.Partial
_
- (Just (PartialConstraintData bs b)))) =
+ _
+ (Just (PartialConstraintData bs b))) _ _) =
paras [ line "A case expression could not be determined to cover all inputs."
, line "The following additional cases are required to cover all inputs:"
, indent $ paras $
@@ -680,46 +912,79 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
: [line "..." | not b]
, line "Alternatively, add a Partial constraint to the type of the enclosing value."
]
- renderSimpleErrorMessage (NoInstanceFound (Constraint _ C.Discard [ty] _)) =
+ renderSimpleErrorMessage (NoInstanceFound (Constraint _ C.Discard _ [ty] _) _ _) =
paras [ line "A result of type"
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
, line "was implicitly discarded in a do notation block."
, line ("You can use " <> markCode "_ <- ..." <> " to explicitly discard the result.")
]
- renderSimpleErrorMessage (NoInstanceFound (Constraint _ nm ts _)) =
- paras [ line "No type class instance was found for"
+ renderSimpleErrorMessage (NoInstanceFound (Constraint _ nm _ ts _) ambiguous unks) =
+ paras $
+ [ line "No type class instance was found for"
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName nm)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
- , paras [ line "The instance head contains unknown type variables. Consider adding a type annotation."
- | any containsUnknowns ts
- ]
- ]
- where
- containsUnknowns :: Type a -> Bool
- containsUnknowns = everythingOnTypes (||) go
- where
- go TUnknown{} = True
- go _ = False
- renderSimpleErrorMessage (AmbiguousTypeVariables t _) =
+ , paras $ let useMessage msg =
+ [ line msg
+ , indent $ paras (map prettyInstanceName ambiguous)
+ ]
+ in case ambiguous of
+ [] -> []
+ [_] -> useMessage "The following instance partially overlaps the above constraint, which means the rest of its instance chain will not be considered:"
+ _ -> useMessage "The following instances partially overlap the above constraint, which means the rest of their instance chains will not be considered:"
+ ] <> case unks of
+ NoUnknowns ->
+ []
+ Unknowns ->
+ [ line "The instance head contains unknown type variables. Consider adding a type annotation." ]
+ UnknownsWithVtaRequiringArgs tyClassMembersRequiringVtas ->
+ let
+ renderSingleTyClassMember (tyClassMember, argsRequiringVtas) =
+ Box.moveRight 2 $ paras $
+ [ line $ markCode (showQualified showIdent tyClassMember) ]
+ <> case argsRequiringVtas of
+ [required] ->
+ [ Box.moveRight 2 $ line $ T.intercalate ", " required ]
+ options ->
+ [ Box.moveRight 2 $ line "One of the following sets of type variables:"
+ , Box.moveRight 2 $ paras $
+ map (\set -> Box.moveRight 2 $ line $ T.intercalate ", " set) options
+ ]
+ in
+ [ paras
+ [ line "The instance head contains unknown type variables."
+ , Box.moveDown 1 $ paras $
+ [ line $ "Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. " <> markCode "tyClassMember @Int" <> ")."]
+ <> map renderSingleTyClassMember (NEL.toList tyClassMembersRequiringVtas)
+ ]
+ ]
+ renderSimpleErrorMessage (AmbiguousTypeVariables t uis) =
paras [ line "The inferred type"
- , markCodeBox $ indent $ typeAsBox prettyDepth t
- , line "has type variables which are not mentioned in the body of the type. Consider adding a type annotation."
+ , markCodeBox $ indent $ prettyType t
+ , line "has type variables which are not determined by those mentioned in the body of the type:"
+ , indent $ Box.hsep 1 Box.left
+ [ Box.vcat Box.left
+ [ line $ markCode (u <> T.pack (show i)) <> " could not be determined"
+ | (u, i) <- uis ]
+ ]
+ , line "Consider adding a type annotation."
]
renderSimpleErrorMessage (PossiblyInfiniteInstance nm ts) =
paras [ line "Type class instance for"
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName nm)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
, line "is possibly infinite."
]
+ renderSimpleErrorMessage PossiblyInfiniteCoercibleInstance =
+ line $ "A " <> markCode "Coercible" <> " instance is possibly infinite."
renderSimpleErrorMessage (CannotDerive nm ts) =
paras [ line "Cannot derive a type class instance for"
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName nm)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
, line "since instances of this type class are not derivable."
]
@@ -727,7 +992,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
paras [ line "Cannot derive newtype instance for"
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName nm)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
, line "Make sure this is a newtype."
]
@@ -735,7 +1000,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
paras [ line "The derived newtype instance for"
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName cl)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
, line $ "does not include a derived superclass instance for " <> markCode (showQualified runProperName su) <> "."
]
@@ -743,7 +1008,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
paras [ line "The derived newtype instance for"
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName cl)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
, line $ "implies an superclass instance for " <> markCode (showQualified runProperName su) <> " which could not be verified."
]
@@ -751,9 +1016,9 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
paras [ line "Cannot derive the type class instance"
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName nm)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
- , line $ fold $
+ , line $ fold
[ "because the "
, markCode (showQualified runProperName nm)
, " type class has "
@@ -767,10 +1032,10 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
paras [ line "Cannot derive the type class instance"
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName nm)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
, "because the type"
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
, line "is not of the required form T a_1 ... a_n, where T is a type constructor defined in the same module."
]
renderSimpleErrorMessage (CannotFindDerivingType nm) =
@@ -789,19 +1054,19 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
renderSimpleErrorMessage (OverlappingArgNames ident) =
line $ "Overlapping names in function/binder" <> foldMap ((" in declaration " <>) . showIdent) ident
renderSimpleErrorMessage (MissingClassMember identsAndTypes) =
- paras $ [ line "The following type class members have not been implemented:"
- , Box.vcat Box.left
- [ markCodeBox $ Box.text (T.unpack (showIdent ident)) Box.<> " :: " Box.<> typeAsBox prettyDepth ty
- | (ident, ty) <- NEL.toList identsAndTypes ]
- ]
+ paras [ line "The following type class members have not been implemented:"
+ , Box.vcat Box.left
+ [ markCodeBox $ Box.text (T.unpack (showIdent ident)) Box.<> " :: " Box.<> prettyType ty
+ | (ident, ty) <- NEL.toList identsAndTypes ]
+ ]
renderSimpleErrorMessage (ExtraneousClassMember ident className) =
line $ "" <> markCode (showIdent ident) <> " is not a member of type class " <> markCode (showQualified runProperName className)
renderSimpleErrorMessage (ExpectedType ty kind) =
- paras [ line $ "In a type-annotated expression " <> markCode "x :: t" <> ", the type " <> markCode "t" <> " must have kind " <> markCode (prettyPrintKind kindType) <> "."
+ paras [ line $ "In a type-annotated expression " <> markCode "x :: t" <> ", the type " <> markCode "t" <> " must have kind " <> markCode (runProperName . disqualify $ C.Type) <> "."
, line "The error arises from the type"
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
, line "having the kind"
- , indent $ line $ markCode $ prettyPrintKind kind
+ , markCodeBox $ indent $ prettyType kind
, line "instead."
]
renderSimpleErrorMessage (IncorrectConstructorArity nm expected actual) =
@@ -812,19 +1077,17 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
paras [ line "Expression"
, markCodeBox $ indent $ prettyPrintValue prettyDepth expr
, line "does not have type"
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
]
renderSimpleErrorMessage (PropertyIsMissing prop) =
line $ "Type of expression lacks required label " <> markCode (prettyPrintLabel prop) <> "."
renderSimpleErrorMessage (AdditionalProperty prop) =
line $ "Type of expression contains additional label " <> markCode (prettyPrintLabel prop) <> "."
- renderSimpleErrorMessage TypeSynonymInstance =
- line "Type class instances for type synonyms are disallowed."
renderSimpleErrorMessage (OrphanInstance nm cnm nonOrphanModules ts) =
- paras [ line $ "Orphan instance " <> markCode (showIdent nm) <> " found for "
+ paras [ line $ "Orphan instance" <> prettyPrintPlainIdent nm <> " found for "
, markCodeBox $ indent $ Box.hsep 1 Box.left
[ line (showQualified runProperName cnm)
- , Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
+ , Box.vcat Box.left (map prettyTypeAtom ts)
]
, Box.vcat Box.left $ case modulesToList of
[] -> [ line "There is nowhere this instance can be placed without being an orphan."
@@ -837,51 +1100,57 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
]
where
modulesToList = S.toList $ S.delete (moduleNameFromString "Prim") nonOrphanModules
- formattedModules = T.intercalate " or " ((markCode . runModuleName) <$> modulesToList)
+ formattedModules = T.intercalate " or " (markCode . runModuleName <$> modulesToList)
renderSimpleErrorMessage (InvalidNewtype name) =
paras [ line $ "Newtype " <> markCode (runProperName name) <> " is invalid."
, line "Newtypes must define a single constructor with a single argument."
]
renderSimpleErrorMessage (InvalidInstanceHead ty) =
paras [ line "Type class instance head is invalid due to use of type"
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
, line "All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form, unless the type is fully determined by other type class arguments via functional dependencies."
]
renderSimpleErrorMessage (TransitiveExportError x ys) =
paras [ line $ "An export for " <> markCode (prettyPrintExport x) <> " requires the following to also be exported: "
, indent $ paras $ map (line . markCode . prettyPrintExport) ys
]
- renderSimpleErrorMessage (TransitiveDctorExportError x ctor) =
- paras [ line $ "An export for " <> markCode (prettyPrintExport x) <> " requires the following data constructor to also be exported: "
- , indent $ line $ markCode $ runProperName ctor
+ renderSimpleErrorMessage (TransitiveDctorExportError x ctors) =
+ paras [ line $ "An export for " <> markCode (prettyPrintExport x) <> " requires the following data constructor" <> (if length ctors == 1 then "" else "s") <> " to also be exported: "
+ , indent $ paras $ map (line . markCode . runProperName) ctors
+ ]
+ renderSimpleErrorMessage (HiddenConstructors x className) =
+ paras [ line $ "An export for " <> markCode (prettyPrintExport x) <> " hides data constructors but the type declares an instance of " <> markCode (showQualified runProperName className) <> "."
+ , line "Such instance allows to match and construct values of this type, effectively making the constructors public."
]
renderSimpleErrorMessage (ShadowedName nm) =
line $ "Name " <> markCode (showIdent nm) <> " was shadowed."
renderSimpleErrorMessage (ShadowedTypeVar tv) =
line $ "Type variable " <> markCode tv <> " was shadowed."
+ renderSimpleErrorMessage (UnusedName nm) =
+ line $ "Name " <> markCode (showIdent nm) <> " was introduced but not used."
+ renderSimpleErrorMessage (UnusedDeclaration nm) =
+ line $ "Declaration " <> markCode (showIdent nm) <> " was not used, and is not exported."
renderSimpleErrorMessage (UnusedTypeVar tv) =
line $ "Type variable " <> markCode tv <> " is ambiguous, since it is unused in the polymorphic type which introduces it."
- renderSimpleErrorMessage (MisleadingEmptyTypeImport mn name) =
- line $ "Importing type " <> markCode (runProperName name <> "(..)") <> " from " <> markCode (runModuleName mn) <> " is misleading as it has no exported data constructors."
renderSimpleErrorMessage (ImportHidingModule name) =
paras [ line "hiding imports cannot be used to hide modules."
, line $ "An attempt was made to hide the import of " <> markCode (runModuleName name)
]
renderSimpleErrorMessage (WildcardInferredType ty ctx) =
paras $ [ line "Wildcard type definition has the inferred type "
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
] <> renderContext ctx
renderSimpleErrorMessage (HoleInferredType name ty ctx ts) =
let
maxTSResults = 15
tsResult = case ts of
- Just (TSAfter{tsAfterIdentifiers=idents}) | not (null idents) ->
+ Just TSAfter{tsAfterIdentifiers=idents} | not (null idents) ->
let
formatTS (names, types) =
let
idBoxes = Box.text . T.unpack . showQualified id <$> names
tyBoxes = (\t -> BoxHelpers.indented
- (Box.text ":: " Box.<> typeAsBox prettyDepth t)) <$> types
+ (Box.text ":: " Box.<> prettyType t)) <$> types
longestId = maximum (map Box.cols idBoxes)
in
Box.vcat Box.top $
@@ -894,13 +1163,22 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
_ -> []
in
paras $ [ line $ "Hole '" <> markCode name <> "' has the inferred type "
- , markCodeBox (indent (typeAsBox maxBound ty))
+ , markCodeBox (indent (prettyTypeWithDepth maxBound ty))
] ++ tsResult ++ renderContext ctx
renderSimpleErrorMessage (MissingTypeDeclaration ident ty) =
paras [ line $ "No type declaration was provided for the top-level declaration of " <> markCode (showIdent ident) <> "."
, line "It is good practice to provide type declarations as a form of documentation."
, line $ "The inferred type of " <> markCode (showIdent ident) <> " was:"
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyTypeWithDepth maxBound ty
+ ]
+ renderSimpleErrorMessage (MissingKindDeclaration sig name ty) =
+ let sigKw = prettyPrintKindSignatureFor sig in
+ paras [ line $ "The inferred kind for the " <> sigKw <> " declaration " <> markCode (runProperName name) <> " contains polymorphic kinds."
+ , line "Consider adding a top-level kind signature as a form of documentation."
+ , markCodeBox $ indent $ Box.hsep 1 Box.left
+ [ line $ sigKw <> " " <> runProperName name <> " ::"
+ , prettyTypeWithDepth maxBound ty
+ ]
]
renderSimpleErrorMessage (OverlappingPattern bs b) =
paras $ [ line "A case expression contains unreachable cases:\n"
@@ -911,12 +1189,18 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
paras [ line "An exhaustivity check was abandoned due to too many possible cases."
, line "You may want to decompose your data types into smaller types."
]
- renderSimpleErrorMessage (UnusedImport name) =
- line $ "The import of module " <> markCode (runModuleName name) <> " is redundant"
+
+ renderSimpleErrorMessage (UnusedImport mn qualifier) =
+ let
+ mark = markCode . runModuleName
+ unqualified = "The import of " <> mark mn <> " is redundant"
+ msg' q = "The qualified import of " <> mark mn <> " as " <> mark q <> " is redundant"
+ msg = maybe unqualified msg'
+ in line $ msg qualifier
renderSimpleErrorMessage msg@(UnusedExplicitImport mn names _ _) =
paras [ line $ "The import of module " <> markCode (runModuleName mn) <> " contains the following unused references:"
- , indent $ paras $ map (line . markCode . runName . Qualified Nothing) names
+ , indent $ paras $ map (line . markCode . runName . Qualified ByNullSourcePos) names
, line "It could be replaced with:"
, indent $ line $ markCode $ showSuggestion msg ]
@@ -940,10 +1224,10 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
line $ "Duplicate import of " <> markCode (prettyPrintImport name imp qual)
renderSimpleErrorMessage (DuplicateImportRef name) =
- line $ "Import list contains multiple references to " <> printName (Qualified Nothing name)
+ line $ "Import list contains multiple references to " <> printName (Qualified ByNullSourcePos name)
renderSimpleErrorMessage (DuplicateExportRef name) =
- line $ "Export list contains multiple references to " <> printName (Qualified Nothing name)
+ line $ "Export list contains multiple references to " <> printName (Qualified ByNullSourcePos name)
renderSimpleErrorMessage (IntOutOfRange value backend lo hi) =
paras [ line $ "Integer value " <> markCode (T.pack (show value)) <> " is out of range for the " <> backend <> " backend."
@@ -956,7 +1240,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
]
renderSimpleErrorMessage msg@(ImplicitQualifiedImportReExport importedModule asModule _) =
paras [ line $ "Module " <> markCode (runModuleName importedModule) <> " was imported as " <> markCode (runModuleName asModule) <> " with unspecified imports."
- , line $ "As this module is being re-exported, consider using the explicit form:"
+ , line "As this module is being re-exported, consider using the explicit form:"
, indent $ line $ markCode $ showSuggestion msg
]
@@ -987,7 +1271,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
renderSimpleErrorMessage (CannotGeneralizeRecursiveFunction ident ty) =
paras [ line $ "Unable to generalize the type of the recursive function " <> markCode (showIdent ident) <> "."
, line $ "The inferred type of " <> markCode (showIdent ident) <> " was:"
- , markCodeBox $ indent $ typeAsBox prettyDepth ty
+ , markCodeBox $ indent $ prettyType ty
, line "Try adding a type signature."
]
@@ -1006,38 +1290,22 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
renderSimpleErrorMessage (ClassInstanceArityMismatch dictName className expected actual) =
paras [ line $ "The type class " <> markCode (showQualified runProperName className) <>
" expects " <> T.pack (show expected) <> " " <> argsMsg <> "."
- , line $ "But the instance " <> markCode (showIdent dictName) <> mismatchMsg <> T.pack (show actual) <> "."
+ , line $ "But the instance" <> prettyPrintPlainIdent dictName <> mismatchMsg <> T.pack (show actual) <> "."
]
where
mismatchMsg = if actual > expected then " provided " else " only provided "
argsMsg = if expected > 1 then "arguments" else "argument"
renderSimpleErrorMessage (UserDefinedWarning msgTy) =
- let msg = fromMaybe (typeAsBox prettyDepth msgTy) (toTypelevelString msgTy) in
+ let msg = fromMaybe (prettyType msgTy) (toTypelevelString msgTy) in
paras [ line "A custom warning occurred while solving type class constraints:"
, indent msg
]
- renderSimpleErrorMessage (UnusableDeclaration ident unexplained) =
- paras $
- [ line $ "The declaration " <> markCode (showIdent ident) <> " contains arguments that couldn't be determined."
- ] <>
-
- case unexplained of
- [required] ->
- [ line $ "These arguments are: { " <> T.intercalate ", " required <> " }"
- ]
-
- options ->
- [ line "To fix this, one of the following sets of variables must be determined:"
- , Box.moveRight 2 . Box.vsep 0 Box.top $
- map (\set -> line $ "{ " <> T.intercalate ", " set <> " }") options
- ]
-
renderSimpleErrorMessage (CannotDefinePrimModules mn) =
- paras $
+ paras
[ line $ "The module name " <> markCode (runModuleName mn) <> " is in the Prim namespace."
- , line $ "The Prim namespace is reserved for compiler-defined terms."
+ , line "The Prim namespace is reserved for compiler-defined terms."
]
renderSimpleErrorMessage (MixedAssociativityError opsWithAssoc) =
@@ -1061,7 +1329,121 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
, line "Use parentheses to resolve this ambiguity."
]
+ renderSimpleErrorMessage (QuantificationCheckFailureInKind var) =
+ paras
+ [ line $ "Cannot generalize the kind of type variable " <> markCode var <> " since it would not be well-scoped."
+ , line "Try adding a kind annotation."
+ ]
+
+ renderSimpleErrorMessage (QuantificationCheckFailureInType us ty) =
+ let unks =
+ fmap (\u -> Box.hsep 1 Box.top [ "where"
+ , markCodeBox (prettyType (srcTUnknown u))
+ , "is an unknown kind."
+ ]) us
+ in paras
+ [ line "Cannot unambiguously generalize kinds appearing in the elaborated type:"
+ , indent $ markCodeBox $ typeAsBox prettyDepth ty
+ , paras unks
+ , line "Try adding additional kind signatures or polymorphic kind variables."
+ ]
+
+ renderSimpleErrorMessage (VisibleQuantificationCheckFailureInType var) =
+ paras
+ [ line $ "Visible dependent quantification of type variable " <> markCode var <> " is not supported."
+ , line "If you would like this feature supported, please bother Liam Goodacre (@LiamGoodacre)."
+ ]
+
+ renderSimpleErrorMessage (UnsupportedTypeInKind ty) =
+ paras
+ [ line "The type:"
+ , indent $ markCodeBox $ prettyType ty
+ , line "is not supported in kinds."
+ ]
+
+ renderSimpleErrorMessage (RoleMismatch var inferred declared) =
+ paras
+ [ line $ "Role mismatch for the type parameter " <> markCode var <> ":"
+ , indent . line $
+ "The annotation says " <> markCode (displayRole declared) <>
+ " but the role " <> markCode (displayRole inferred) <>
+ " is required."
+ ]
+
+ renderSimpleErrorMessage (InvalidCoercibleInstanceDeclaration tys) =
+ paras
+ [ line "Invalid type class instance declaration for"
+ , markCodeBox $ indent $ Box.hsep 1 Box.left
+ [ line (showQualified runProperName C.Coercible)
+ , Box.vcat Box.left (map prettyTypeAtom tys)
+ ]
+ , line "Instance declarations of this type class are disallowed."
+ ]
+
+ renderSimpleErrorMessage UnsupportedRoleDeclaration =
+ line "Role declarations are only supported for data types, not for type synonyms nor type classes."
+
+ renderSimpleErrorMessage (RoleDeclarationArityMismatch name expected actual) =
+ line $ T.intercalate " "
+ [ "The type"
+ , markCode (runProperName name)
+ , "expects"
+ , T.pack (show expected)
+ , if expected == 1 then "argument" else "arguments"
+ , "but its role declaration lists"
+ <> if actual > expected then "" else " only"
+ , T.pack (show actual)
+ , if actual > 1 then "roles" else "role"
+ ] <> "."
+
+ renderSimpleErrorMessage (DuplicateRoleDeclaration name) =
+ line $ "Duplicate role declaration for " <> markCode (runProperName name) <> "."
+
+ renderSimpleErrorMessage (CannotDeriveInvalidConstructorArg className relatedClasses checkVariance) =
+ paras
+ [ line $ "One or more type variables are in positions that prevent " <> markCode (runProperName $ disqualify className) <> " from being derived."
+ , line $ "To derive this class, make sure that these variables are only used as the final arguments to type constructors, "
+ <> (if checkVariance then "that their variance matches the variance of " <> markCode (runProperName $ disqualify className) <> ", " else "")
+ <> "and that those type constructors themselves have instances of " <> commasAndConjunction "or" (markCode . showQualified runProperName <$> relatedClasses) <> "."
+ ]
+
+ renderSimpleErrorMessage (CannotSkipTypeApplication tyFn) =
+ paras
+ [ "An expression of type:"
+ , markCodeBox $ indent $ prettyType tyFn
+ , "cannot be skipped."
+ ]
+
+ renderSimpleErrorMessage (CannotApplyExpressionOfTypeOnType tyFn tyAr) =
+ paras $ infoLine <>
+ [ markCodeBox $ indent $ prettyType tyFn
+ , "cannot be applied to:"
+ , markCodeBox $ indent $ prettyType tyAr
+ ]
+ where
+ infoLine =
+ if isMonoType tyFn then
+ [ "An expression of monomorphic type:" ]
+ else
+ [ "An expression of polymorphic type"
+ , line $ "with the invisible type variable " <> markCode typeVariable <> ":"
+ ]
+
+ typeVariable = case tyFn of
+ ForAll _ _ v _ _ _ -> v
+ _ -> internalError "renderSimpleErrorMessage: Impossible!"
+
renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
+ renderHint (ErrorUnifyingTypes t1@RCons{} t2@RCons{}) detail =
+ let (row1Box, row2Box) = printRows t1 t2
+ in paras [ detail
+ , Box.hsep 1 Box.top [ line "while trying to match type"
+ , row1Box
+ ]
+ , Box.moveRight 2 $ Box.hsep 1 Box.top [ line "with type"
+ , row2Box
+ ]
+ ]
renderHint (ErrorUnifyingTypes t1 t2) detail =
paras [ detail
, Box.hsep 1 Box.top [ line "while trying to match type"
@@ -1090,6 +1472,12 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
, markCodeBox $ typeAsBox prettyDepth t2
]
]
+ renderHint (ErrorInRowLabel lb) detail =
+ paras [ detail
+ , Box.hsep 1 Box.top [ line "while matching label"
+ , markCodeBox $ line $ prettyPrintObjectKey (runLabel lb)
+ ]
+ ]
renderHint (ErrorInInstance nm ts) detail =
paras [ detail
, line "in type class instance"
@@ -1098,9 +1486,18 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
, Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
]
]
- renderHint (ErrorCheckingKind ty) detail =
+ renderHint (ErrorCheckingKind ty kd) detail =
paras [ detail
- , Box.hsep 1 Box.top [ line "while checking the kind of"
+ , Box.hsep 1 Box.top [ line "while checking that type"
+ , markCodeBox $ typeAsBox prettyDepth ty
+ ]
+ , Box.moveRight 2 $ Box.hsep 1 Box.top [ line "has kind"
+ , markCodeBox $ typeAsBox prettyDepth kd
+ ]
+ ]
+ renderHint (ErrorInferringKind ty) detail =
+ paras [ detail
+ , Box.hsep 1 Box.top [ line "while inferring the kind of"
, markCodeBox $ typeAsBox prettyDepth ty
]
]
@@ -1173,11 +1570,23 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
paras [ detail
, line $ "in type class declaration for " <> markCode (runProperName name)
]
+ renderHint (ErrorInKindDeclaration name) detail =
+ paras [ detail
+ , line $ "in kind declaration for " <> markCode (runProperName name)
+ ]
+ renderHint (ErrorInRoleDeclaration name) detail =
+ paras [ detail
+ , line $ "in role declaration for " <> markCode (runProperName name)
+ ]
renderHint (ErrorInForeignImport nm) detail =
paras [ detail
, line $ "in foreign import " <> markCode (showIdent nm)
]
- renderHint (ErrorSolvingConstraint (Constraint _ nm ts _)) detail =
+ renderHint (ErrorInForeignImportData nm) detail =
+ paras [ detail
+ , line $ "in foreign data type declaration for " <> markCode (runProperName nm)
+ ]
+ renderHint (ErrorSolvingConstraint (Constraint _ nm _ ts _)) detail =
paras [ detail
, line "while solving type class constraint"
, markCodeBox $ indent $ Box.hsep 1 Box.left
@@ -1185,10 +1594,59 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
, Box.vcat Box.left (map (typeAtomAsBox prettyDepth) ts)
]
]
+ renderHint (MissingConstructorImportForCoercible name) detail =
+ paras
+ [ detail
+ , Box.moveUp 1 $ Box.moveRight 2 $ line $ "Solving this instance requires the newtype constructor " <> markCode (showQualified runProperName name) <> " to be in scope."
+ ]
renderHint (PositionedError srcSpan) detail =
paras [ line $ "at " <> displaySourceSpan relPath (NEL.head srcSpan)
, detail
]
+ renderHint (RelatedPositions srcSpans) detail =
+ paras
+ [ detail
+ , Box.moveRight 2 $ showSourceSpansInContext srcSpans
+ ]
+
+ printRow :: (Int -> Type a -> Box.Box) -> Type a -> Box.Box
+ printRow f = markCodeBox . indent . f prettyDepth .
+ if full then id else eraseForAllKindAnnotations . eraseKindApps
+
+ -- If both rows are not empty, print them as diffs
+ -- If verbose print all rows else only print unique rows
+ printRows :: Type a -> Type a -> (Box.Box, Box.Box)
+ printRows r1 r2 = case (full, r1, r2) of
+ (True, _ , _) -> (printRow typeAsBox r1, printRow typeAsBox r2)
+
+ (_, RCons{}, RCons{}) ->
+ let (sorted1, sorted2) = filterRows (rowToList r1) (rowToList r2)
+ in (printRow typeDiffAsBox sorted1, printRow typeDiffAsBox sorted2)
+
+ (_, _, _) -> (printRow typeAsBox r1, printRow typeAsBox r2)
+
+
+ -- Keep the unique labels only
+ filterRows :: ([RowListItem a], Type a) -> ([RowListItem a], Type a) -> (Type a, Type a)
+ filterRows (s1, r1) (s2, r2) =
+ let sort' = sortOn $ \(RowListItem _ name ty) -> (name, ty)
+ (unique1, unique2) = diffSortedRowLists (sort' s1, sort' s2)
+ in ( rowFromList (unique1, r1)
+ , rowFromList (unique2, r2)
+ )
+
+ -- Importantly, this removes exactly the same number of elements from
+ -- both lists, even if there are repeated (name, ty) keys. It requires
+ -- the inputs to be sorted but ensures that the outputs remain sorted.
+ diffSortedRowLists :: ([RowListItem a], [RowListItem a]) -> ([RowListItem a], [RowListItem a])
+ diffSortedRowLists = go where
+ go = \case
+ (s1@(h1@(RowListItem _ name1 ty1) : t1), s2@(h2@(RowListItem _ name2 ty2) : t2)) ->
+ case (name1, ty1) `compare` (name2, ty2) of
+ EQ -> go (t1, t2)
+ LT -> first (h1:) $ go (t1, s2)
+ GT -> second (h2:) $ go (s1, t2)
+ other -> other
renderContext :: Context -> [Box.Box]
renderContext [] = []
@@ -1198,7 +1656,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
[ Box.hcat Box.left [ Box.text (T.unpack (showIdent ident) ++ " :: ")
, markCodeBox $ typeAsBox prettyDepth ty'
]
- | (ident, ty') <- take 5 ctx
+ | (ident, ty') <- take 30 ctx
]
]
@@ -1213,24 +1671,21 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
nameType (DctorName _) = "data constructor"
nameType (TyClassName _) = "type class"
nameType (ModName _) = "module"
- nameType (KiName _) = "kind"
runName :: Qualified Name -> Text
- runName (Qualified mn (IdentName name)) =
- showQualified showIdent (Qualified mn name)
- runName (Qualified mn (ValOpName op)) =
- showQualified showOp (Qualified mn op)
- runName (Qualified mn (TyName name)) =
- showQualified runProperName (Qualified mn name)
- runName (Qualified mn (TyOpName op)) =
- showQualified showOp (Qualified mn op)
- runName (Qualified mn (DctorName name)) =
- showQualified runProperName (Qualified mn name)
- runName (Qualified mn (TyClassName name)) =
- showQualified runProperName (Qualified mn name)
- runName (Qualified mn (KiName name)) =
- showQualified runProperName (Qualified mn name)
- runName (Qualified Nothing (ModName name)) =
+ runName (Qualified qb (IdentName name)) =
+ showQualified showIdent (Qualified qb name)
+ runName (Qualified qb (ValOpName op)) =
+ showQualified showOp (Qualified qb op)
+ runName (Qualified qb (TyName name)) =
+ showQualified runProperName (Qualified qb name)
+ runName (Qualified qb (TyOpName op)) =
+ showQualified showOp (Qualified qb op)
+ runName (Qualified qb (DctorName name)) =
+ showQualified runProperName (Qualified qb name)
+ runName (Qualified qb (TyClassName name)) =
+ showQualified runProperName (Qualified qb name)
+ runName (Qualified (BySourcePos _) (ModName name)) =
runModuleName name
runName (Qualified _ ModName{}) =
internalError "qualified ModName in runName"
@@ -1239,21 +1694,34 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
prettyDepth | full = 1000
| otherwise = 3
+ prettyType :: Type a -> Box.Box
+ prettyType = prettyTypeWithDepth prettyDepth
+
+ prettyTypeWithDepth :: Int -> Type a -> Box.Box
+ prettyTypeWithDepth depth
+ | full = typeAsBox depth
+ | otherwise = typeAsBox depth . eraseForAllKindAnnotations . eraseKindApps
+
+ prettyTypeAtom :: Type a -> Box.Box
+ prettyTypeAtom
+ | full = typeAtomAsBox prettyDepth
+ | otherwise = typeAtomAsBox prettyDepth . eraseForAllKindAnnotations . eraseKindApps
+
levelText :: Text
levelText = case level of
Error -> "error"
Warning -> "warning"
- paras :: [Box.Box] -> Box.Box
+ paras :: forall f. Foldable f => f Box.Box -> Box.Box
paras = Box.vcat Box.left
- -- | Simplify an error message
+ -- Simplify an error message
simplifyErrorMessage :: ErrorMessage -> ErrorMessage
simplifyErrorMessage (ErrorMessage hints simple) = ErrorMessage (simplifyHints hints) simple
where
-- Take the last instance of each "hint category"
simplifyHints :: [ErrorMessageHint] -> [ErrorMessageHint]
- simplifyHints = reverse . nubBy categoriesEqual . stripRedudantHints simple . reverse
+ simplifyHints = reverse . nubBy categoriesEqual . stripRedundantHints simple . reverse
-- Don't remove hints in the "other" category
categoriesEqual :: ErrorMessageHint -> ErrorMessageHint -> Bool
@@ -1263,21 +1731,25 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
(_, OtherHint) -> False
(c1, c2) -> c1 == c2
- -- | See https://github.com/purescript/purescript/issues/1802
- stripRedudantHints :: SimpleErrorMessage -> [ErrorMessageHint] -> [ErrorMessageHint]
- stripRedudantHints ExprDoesNotHaveType{} = stripFirst isCheckHint
+ -- See https://github.com/purescript/purescript/issues/1802
+ stripRedundantHints :: SimpleErrorMessage -> [ErrorMessageHint] -> [ErrorMessageHint]
+ stripRedundantHints ExprDoesNotHaveType{} = stripFirst isCheckHint
where
isCheckHint ErrorCheckingType{} = True
isCheckHint _ = False
- stripRedudantHints TypesDoNotUnify{} = stripFirst isUnifyHint
+ stripRedundantHints TypesDoNotUnify{} = stripFirst isUnifyHint
where
isUnifyHint ErrorUnifyingTypes{} = True
isUnifyHint _ = False
- stripRedudantHints NoInstanceFound{} = stripFirst isSolverHint
+ stripRedundantHints (NoInstanceFound (Constraint _ C.Coercible _ args _) _ _) = filter (not . isSolverHint)
+ where
+ isSolverHint (ErrorSolvingConstraint (Constraint _ C.Coercible _ args' _)) = args == args'
+ isSolverHint _ = False
+ stripRedundantHints NoInstanceFound{} = stripFirst isSolverHint
where
isSolverHint ErrorSolvingConstraint{} = True
isSolverHint _ = False
- stripRedudantHints _ = id
+ stripRedundantHints _ = id
stripFirst :: (ErrorMessageHint -> Bool) -> [ErrorMessageHint] -> [ErrorMessageHint]
stripFirst p (PositionedError pos : hs) = PositionedError pos : stripFirst p hs
@@ -1297,8 +1769,128 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs relPath) e = fl
hintCategory ErrorCheckingKind{} = CheckHint
hintCategory ErrorSolvingConstraint{} = SolverHint
hintCategory PositionedError{} = PositionHint
+ hintCategory ErrorInDataConstructor{} = DeclarationHint
+ hintCategory ErrorInTypeConstructor{} = DeclarationHint
+ hintCategory ErrorInBindingGroup{} = DeclarationHint
+ hintCategory ErrorInDataBindingGroup{} = DeclarationHint
+ hintCategory ErrorInTypeSynonym{} = DeclarationHint
+ hintCategory ErrorInValueDeclaration{} = DeclarationHint
+ hintCategory ErrorInTypeDeclaration{} = DeclarationHint
+ hintCategory ErrorInTypeClassDeclaration{} = DeclarationHint
+ hintCategory ErrorInKindDeclaration{} = DeclarationHint
+ hintCategory ErrorInRoleDeclaration{} = DeclarationHint
+ hintCategory ErrorInForeignImport{} = DeclarationHint
hintCategory _ = OtherHint
+ prettyPrintPlainIdent :: Ident -> Text
+ prettyPrintPlainIdent ident =
+ if isPlainIdent ident
+ then " " <> markCode (showIdent ident)
+ else ""
+
+ prettyInstanceName :: Qualified (Either SourceType Ident) -> Box.Box
+ prettyInstanceName = \case
+ Qualified qb (Left ty) ->
+ "instance "
+ Box.<> (case qb of
+ ByModuleName mn -> "in module "
+ Box.<> line (markCode $ runModuleName mn)
+ Box.<> " "
+ _ -> Box.nullBox)
+ Box.<> "with type "
+ Box.<> markCodeBox (prettyType ty)
+ Box.<> " "
+ Box.<> (line . displayStartEndPos . fst $ getAnnForType ty)
+ Qualified mn (Right inst) -> line . markCode . showQualified showIdent $ Qualified mn inst
+
+ -- As of this writing, this function assumes that all provided SourceSpans
+ -- are non-overlapping (except for exact duplicates) and span no line breaks. A
+ -- more sophisticated implementation without this limitation would be possible
+ -- but isn't yet needed.
+ showSourceSpansInContext :: NonEmpty SourceSpan -> Box.Box
+ showSourceSpansInContext
+ = maybe Box.nullBox (paras . fmap renderFile . NEL.groupWith1 spanName . NEL.sort)
+ . NEL.nonEmpty
+ . NEL.filter ((> 0) . sourcePosLine . spanStart)
+ where
+ renderFile :: NonEmpty SourceSpan -> Box.Box
+ renderFile sss = maybe Box.nullBox (linesToBox . T.lines) $ lookup fileName fileContents
+ where
+ fileName = spanName $ NEL.head sss
+ header = lineS . (<> ":") . makeRelative relPath $ fileName
+ lineBlocks = makeLineBlocks $ NEL.groupWith1 (sourcePosLine . spanStart) sss
+
+ linesToBox fileLines = Box.moveUp 1 $ header Box.// body
+ where
+ body
+ = Box.punctuateV Box.left (lineNumberStyle "...")
+ . map (paras . fmap renderLine)
+ . flip evalState (fileLines, 1)
+ . traverse (wither (\(i, x) -> fmap (i, , x) <$> ascLookupInState i) . NEL.toList)
+ $ NEL.toList lineBlocks
+
+ makeLineBlocks :: NonEmpty (NonEmpty SourceSpan) -> NonEmpty (NonEmpty (Int, [SourceSpan]))
+ makeLineBlocks = startBlock
+ where
+ startBlock (h :| t) = over head1 (NEL.cons (pred $ headLineNumber h, [])) $ continueBlock h t
+
+ continueBlock :: NonEmpty SourceSpan -> [NonEmpty SourceSpan] -> NonEmpty (NonEmpty (Int, [SourceSpan]))
+ continueBlock lineGroup = \case
+ [] ->
+ endBlock lineGroup []
+ nextGroup : groups -> case pred $ ((-) `on` headLineNumber) nextGroup lineGroup of
+ n | n <= 3 ->
+ over head1 (appendExtraLines n lineGroup <>) $ continueBlock nextGroup groups
+ _ ->
+ endBlock lineGroup . NEL.toList . startBlock $ nextGroup :| groups
+
+ endBlock :: NonEmpty SourceSpan -> [NonEmpty (Int, [SourceSpan])] -> NonEmpty (NonEmpty (Int, [SourceSpan]))
+ endBlock h t = appendExtraLines 1 h :| t
+
+ headLineNumber = sourcePosLine . spanStart . NEL.head
+
+ appendExtraLines :: Int -> NonEmpty SourceSpan -> NonEmpty (Int, [SourceSpan])
+ appendExtraLines n lineGroup = (lineNum, NEL.toList lineGroup) :| [(lineNum + i, []) | i <- [1..n]]
+ where
+ lineNum = headLineNumber lineGroup
+
+ renderLine :: (Int, Text, [SourceSpan]) -> Box.Box
+ renderLine (lineNum, text, sss) = numBox Box.<+> lineBox
+ where
+ colSpans = nubOrdOn fst $ map (over both (pred . sourcePosColumn) . (spanStart &&& spanEnd)) sss
+ numBox = lineNumberStyle $ show lineNum
+ lineBox =
+ if isJust codeColor
+ then colorCodeBox codeColor $ line $ foldr highlightSpan text colSpans
+ else line text Box.// line (finishUnderline $ foldr underlineSpan (T.length text, "") colSpans)
+
+ highlightSpan :: (Int, Int) -> Text -> Text
+ highlightSpan (startCol, endCol) text
+ = prefix
+ <> T.pack (ANSI.setSGRCode [ANSI.SetSwapForegroundBackground True])
+ <> spanText
+ <> T.pack (ANSI.setSGRCode [ANSI.SetSwapForegroundBackground False])
+ <> suffix
+ where
+ (prefix, rest) = T.splitAt startCol text
+ (spanText, suffix) = T.splitAt (endCol - startCol) rest
+
+ underlineSpan :: (Int, Int) -> (Int, Text) -> (Int, Text)
+ underlineSpan (startCol, endCol) (len, accum) = (startCol, T.replicate (endCol - startCol) "^" <> T.replicate (len - endCol) " " <> accum)
+
+ finishUnderline :: (Int, Text) -> Text
+ finishUnderline (len, accum) = T.replicate len " " <> accum
+
+ lineNumberStyle :: String -> Box.Box
+ lineNumberStyle = colorCodeBox (codeColor $> (ANSI.Vivid, ANSI.Black)) . Box.alignHoriz Box.right 5 . lineS
+
+ -- Lookup the nth element of a list, but without retraversing the list every
+ -- time, by instead keeping a tail of the list and the current element number
+ -- in State. Only works if the argument provided is strictly ascending over
+ -- the life of the State.
+ ascLookupInState :: forall a. Int -> State ([a], Int) (Maybe a)
+ ascLookupInState j = get >>= \(as, i) -> for (uncons $ drop (j - i) as) $ \(a, as') -> put (as', succ j) $> a
+
-- Pretty print and export declaration
prettyPrintExport :: DeclarationRef -> Text
prettyPrintExport (TypeRef _ pn _) = runProperName pn
@@ -1312,7 +1904,7 @@ prettyPrintImport mn idt qual =
let i = case idt of
Implicit -> runModuleName mn
Explicit refs -> runModuleName mn <> " (" <> T.intercalate ", " (mapMaybe prettyPrintRef refs) <> ")"
- Hiding refs -> runModuleName mn <> " hiding (" <> T.intercalate "," (mapMaybe prettyPrintRef refs) <> ")"
+ Hiding refs -> runModuleName mn <> " hiding (" <> T.intercalate ", " (mapMaybe prettyPrintRef refs) <> ")"
in i <> maybe "" (\q -> " as " <> runModuleName q) qual
prettyPrintRef :: DeclarationRef -> Maybe Text
@@ -1330,15 +1922,24 @@ prettyPrintRef (ValueOpRef _ op) =
Just $ showOp op
prettyPrintRef (TypeClassRef _ pn) =
Just $ "class " <> runProperName pn
-prettyPrintRef (TypeInstanceRef _ ident) =
+prettyPrintRef (TypeInstanceRef _ ident UserNamed) =
Just $ showIdent ident
+prettyPrintRef (TypeInstanceRef _ _ CompilerNamed) =
+ Nothing
prettyPrintRef (ModuleRef _ name) =
Just $ "module " <> runModuleName name
-prettyPrintRef (KindRef _ pn) =
- Just $ "kind " <> runProperName pn
prettyPrintRef ReExportRef{} =
Nothing
+prettyPrintKindSignatureFor :: KindSignatureFor -> Text
+prettyPrintKindSignatureFor DataSig = "data"
+prettyPrintKindSignatureFor NewtypeSig = "newtype"
+prettyPrintKindSignatureFor TypeSynonymSig = "type"
+prettyPrintKindSignatureFor ClassSig = "class"
+
+prettyPrintSuggestedTypeSimplified :: Type a -> String
+prettyPrintSuggestedTypeSimplified = prettyPrintSuggestedType . eraseForAllKindAnnotations . eraseKindApps
+
-- | Pretty print multiple errors
prettyPrintMultipleErrors :: PPEOptions -> MultipleErrors -> String
prettyPrintMultipleErrors ppeOptions = unlines . map renderBox . prettyPrintMultipleErrorsBox ppeOptions
@@ -1370,53 +1971,6 @@ prettyPrintMultipleErrorsWith ppeOptions _ intro (MultipleErrors es) =
, Box.moveRight 2 err
]
--- | Pretty print a Parsec ParseError as a Box
-prettyPrintParseError :: P.ParseError -> Box.Box
-prettyPrintParseError = prettyPrintParseErrorMessages "or" "unknown parse error" "expecting" "unexpected" "end of input" . PE.errorMessages
-
--- | Pretty print 'ParseError' detail messages.
---
--- Adapted from 'Text.Parsec.Error.showErrorMessages'.
--- See .
-prettyPrintParseErrorMessages :: String -> String -> String -> String -> String -> [Message] -> Box.Box
-prettyPrintParseErrorMessages msgOr msgUnknown msgExpecting msgUnExpected msgEndOfInput msgs
- | null msgs = Box.text msgUnknown
- | otherwise = Box.vcat Box.left $ map Box.text $ clean [showSysUnExpect,showUnExpect,showExpect,showMessages]
-
- where
- (sysUnExpect,msgs1) = span (SysUnExpect "" ==) msgs
- (unExpect,msgs2) = span (UnExpect "" ==) msgs1
- (expect,messages) = span (Expect "" ==) msgs2
-
- showExpect = showMany msgExpecting expect
- showUnExpect = showMany msgUnExpected unExpect
- showSysUnExpect | not (null unExpect) ||
- null sysUnExpect = ""
- | null firstMsg = msgUnExpected ++ " " ++ msgEndOfInput
- | otherwise = msgUnExpected ++ " " ++ firstMsg
- where
- firstMsg = PE.messageString (head sysUnExpect)
-
- showMessages = showMany "" messages
-
- -- helpers
- showMany pre msgs' = case clean (map PE.messageString msgs') of
- [] -> ""
- ms | null pre -> commasOr ms
- | otherwise -> pre ++ " " ++ commasOr ms
-
- commasOr [] = ""
- commasOr [m] = m
- commasOr ms = commaSep (init ms) ++ " " ++ msgOr ++ " " ++ last ms
-
- commaSep = separate ", " . clean
-
- separate _ [] = ""
- separate _ [m] = m
- separate sep (m:ms) = m ++ sep ++ separate sep ms
-
- clean = ordNub . filter (not . null)
-
-- | Indent to the right, and pad on top and bottom.
indent :: Box.Box -> Box.Box
indent = Box.moveUp 1 . Box.moveDown 1 . Box.moveRight 2
@@ -1440,30 +1994,22 @@ renderBox = unlines
toTypelevelString :: Type a -> Maybe Box.Box
toTypelevelString (TypeLevelString _ s) =
Just . Box.text $ decodeStringWithReplacement s
-toTypelevelString (TypeApp _ (TypeConstructor _ f) x)
- | f == primSubName C.typeError "Text" = toTypelevelString x
-toTypelevelString (TypeApp _ (TypeConstructor _ f) x)
- | f == primSubName C.typeError "Quote" = Just (typeAsBox maxBound x)
-toTypelevelString (TypeApp _ (TypeConstructor _ f) (TypeLevelString _ x))
- | f == primSubName C.typeError "QuoteLabel" = Just . line . prettyPrintLabel . Label $ x
-toTypelevelString (TypeApp _ (TypeApp _ (TypeConstructor _ f) x) ret)
- | f == primSubName C.typeError "Beside" =
- (Box.<>) <$> toTypelevelString x <*> toTypelevelString ret
-toTypelevelString (TypeApp _ (TypeApp _ (TypeConstructor _ f) x) ret)
- | f == primSubName C.typeError "Above" =
- (Box.//) <$> toTypelevelString x <*> toTypelevelString ret
+toTypelevelString (TypeApp _ (TypeConstructor _ C.Text) x) =
+ toTypelevelString x
+toTypelevelString (TypeApp _ (KindApp _ (TypeConstructor _ C.Quote) _) x) =
+ Just (typeAsBox maxBound x)
+toTypelevelString (TypeApp _ (TypeConstructor _ C.QuoteLabel) (TypeLevelString _ x)) =
+ Just . line . prettyPrintLabel . Label $ x
+toTypelevelString (TypeApp _ (TypeApp _ (TypeConstructor _ C.Beside) x) ret) =
+ (Box.<>) <$> toTypelevelString x <*> toTypelevelString ret
+toTypelevelString (TypeApp _ (TypeApp _ (TypeConstructor _ C.Above) x) ret) =
+ (Box.//) <$> toTypelevelString x <*> toTypelevelString ret
toTypelevelString _ = Nothing
-- | Rethrow an error with a more detailed error message in the case of failure
rethrow :: (MonadError e m) => (e -> e) -> m a -> m a
rethrow f = flip catchError (throwError . f)
-reifyErrors :: (MonadError e m) => m a -> m (Either e a)
-reifyErrors ma = catchError (fmap Right ma) (return . Left)
-
-reflectErrors :: (MonadError e m) => m (Either e a) -> m a
-reflectErrors ma = ma >>= either throwError return
-
warnAndRethrow :: (MonadError e m, MonadWriter e m) => (e -> e) -> m a -> m a
warnAndRethrow f = rethrow f . censor f
@@ -1481,12 +2027,15 @@ withPosition :: SourceSpan -> ErrorMessage -> ErrorMessage
withPosition NullSourceSpan err = err
withPosition pos (ErrorMessage hints se) = ErrorMessage (positionedError pos : hints) se
+withoutPosition :: ErrorMessage -> ErrorMessage
+withoutPosition (ErrorMessage hints se) = ErrorMessage (filter go hints) se
+ where
+ go (PositionedError _) = False
+ go _ = True
+
positionedError :: SourceSpan -> ErrorMessageHint
positionedError = PositionedError . pure
-filterErrors :: (ErrorMessage -> Bool) -> MultipleErrors -> MultipleErrors
-filterErrors f = MultipleErrors . filter f . runMultipleErrors
-
-- | Runs a computation listening for warnings and then escalating any warnings
-- that match the predicate to error status.
escalateWarningWhen
@@ -1518,3 +2067,12 @@ parU xs f =
collectErrors es = case partitionEithers es of
([], rs) -> return rs
(errs, _) -> throwError $ fold errs
+
+internalCompilerError
+ :: (MonadError MultipleErrors m, GHC.Stack.HasCallStack)
+ => Text
+ -> m a
+internalCompilerError =
+ throwError
+ . errorMessage
+ . InternalCompilerError (T.pack (GHC.Stack.prettyCallStack GHC.Stack.callStack))
diff --git a/src/Language/PureScript/Errors/JSON.hs b/src/Language/PureScript/Errors/JSON.hs
index f552f91f03..9e2af78668 100644
--- a/src/Language/PureScript/Errors/JSON.hs
+++ b/src/Language/PureScript/Errors/JSON.hs
@@ -2,14 +2,13 @@
module Language.PureScript.Errors.JSON where
-import Prelude.Compat
+import Prelude
-import qualified Data.Aeson.TH as A
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Text as T
+import Data.Aeson.TH qualified as A
+import Data.List.NonEmpty qualified as NEL
import Data.Text (Text)
-import qualified Language.PureScript as P
+import Language.PureScript qualified as P
data ErrorPosition = ErrorPosition
{ startLine :: Int
@@ -40,17 +39,17 @@ data JSONResult = JSONResult
} deriving (Show, Eq)
$(A.deriveJSON A.defaultOptions ''ErrorPosition)
+$(A.deriveJSON A.defaultOptions ''ErrorSuggestion)
$(A.deriveJSON A.defaultOptions ''JSONError)
$(A.deriveJSON A.defaultOptions ''JSONResult)
-$(A.deriveJSON A.defaultOptions ''ErrorSuggestion)
-toJSONErrors :: Bool -> P.Level -> P.MultipleErrors -> [JSONError]
-toJSONErrors verbose level = map (toJSONError verbose level) . P.runMultipleErrors
+toJSONErrors :: Bool -> P.Level -> [(FilePath, Text)] -> P.MultipleErrors -> [JSONError]
+toJSONErrors verbose level files = map (toJSONError verbose level files) . P.runMultipleErrors
-toJSONError :: Bool -> P.Level -> P.ErrorMessage -> JSONError
-toJSONError verbose level e =
+toJSONError :: Bool -> P.Level -> [(FilePath, Text)] -> P.ErrorMessage -> JSONError
+toJSONError verbose level files e =
JSONError (toErrorPosition <$> fmap NEL.head spans)
- (P.renderBox (P.prettyPrintSingleError (P.PPEOptions Nothing verbose level False mempty) (P.stripModuleAndSpan e)))
+ (P.renderBox (P.prettyPrintSingleError (P.PPEOptions Nothing verbose level False mempty files) (P.stripModuleAndSpan e)))
(P.errorCode e)
(P.errorDocUri e)
(P.spanName <$> fmap NEL.head spans)
@@ -73,5 +72,4 @@ toJSONError verbose level e =
Nothing -> Nothing
Just s -> Just $ ErrorSuggestion (suggestionText s) (toErrorPosition <$> P.suggestionSpan em)
- -- TODO: Adding a newline because source spans chomp everything up to the next character
- suggestionText (P.ErrorSuggestion s) = if T.null s then s else s <> "\n"
+ suggestionText (P.ErrorSuggestion s) = s
diff --git a/src/Language/PureScript/Externs.hs b/src/Language/PureScript/Externs.hs
index 7de92875c2..a9669a9995 100644
--- a/src/Language/PureScript/Externs.hs
+++ b/src/Language/PureScript/Externs.hs
@@ -1,5 +1,4 @@
-{-# LANGUAGE TemplateHaskell #-}
-
+{-# Language DeriveAnyClass #-}
-- |
-- This module generates code for \"externs\" files, i.e. files containing only
-- foreign import declarations.
@@ -10,35 +9,42 @@ module Language.PureScript.Externs
, ExternsFixity(..)
, ExternsTypeFixity(..)
, ExternsDeclaration(..)
+ , externsIsCurrentVersion
, moduleToExternsFile
, applyExternsFileToEnvironment
+ , externsFileName
) where
-import Prelude.Compat
+import Prelude
-import Data.Aeson.TH
+import Codec.Serialise (Serialise)
+import Control.DeepSeq (NFData)
+import Control.Monad (join)
import Data.Maybe (fromMaybe, mapMaybe, maybeToList)
import Data.List (foldl', find)
import Data.Foldable (fold)
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
import Data.Version (showVersion)
-import qualified Data.Map as M
-import qualified Data.Set as S
-import qualified Data.List.NonEmpty as NEL
-
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.TypeClassDictionaries
-import Language.PureScript.Types
+import Data.Map qualified as M
+import Data.List.NonEmpty qualified as NEL
+import GHC.Generics (Generic)
+
+import Language.PureScript.AST (Associativity, Declaration(..), DeclarationRef(..), Fixity(..), ImportDeclarationType, Module(..), NameSource(..), Precedence, SourceSpan, pattern TypeFixityDeclaration, pattern ValueFixityDeclaration, getTypeOpRef, getValueOpRef)
+import Language.PureScript.AST.Declarations.ChainId (ChainId)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (DataDeclType, Environment(..), FunctionalDependency, NameKind(..), NameVisibility(..), TypeClassData(..), TypeKind(..), dictTypeName, makeTypeClassData)
+import Language.PureScript.Names (Ident, ModuleName, OpName, OpNameType(..), ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), coerceProperName, isPlainIdent)
+import Language.PureScript.TypeClassDictionaries (NamedDict, TypeClassDictionaryInScope(..))
+import Language.PureScript.Types (SourceConstraint, SourceType, srcInstanceType)
import Paths_purescript as Paths
-- | The data which will be serialized to an externs file
data ExternsFile = ExternsFile
+ -- NOTE: Make sure to keep `efVersion` as the first field in this
+ -- record, so the derived Serialise instance produces CBOR that can
+ -- be checked for its version independent of the remaining format
{ efVersion :: Text
-- ^ The externs version
, efModuleName :: ModuleName
@@ -55,7 +61,9 @@ data ExternsFile = ExternsFile
-- ^ List of type and value declaration
, efSourceSpan :: SourceSpan
-- ^ Source span for error reporting
- } deriving (Show)
+ } deriving (Show, Generic, NFData)
+
+instance Serialise ExternsFile
-- | A module import in an externs file
data ExternsImport = ExternsImport
@@ -66,7 +74,9 @@ data ExternsImport = ExternsImport
, eiImportType :: ImportDeclarationType
-- | The imported-as name, for qualified imports
, eiImportedAs :: Maybe ModuleName
- } deriving (Show)
+ } deriving (Show, Generic, NFData)
+
+instance Serialise ExternsImport
-- | A fixity declaration in an externs file
data ExternsFixity = ExternsFixity
@@ -79,7 +89,9 @@ data ExternsFixity = ExternsFixity
, efOperator :: OpName 'ValueOpName
-- | The value the operator is an alias for
, efAlias :: Qualified (Either Ident (ProperName 'ConstructorName))
- } deriving (Show)
+ } deriving (Show, Generic, NFData)
+
+instance Serialise ExternsFixity
-- | A type fixity declaration in an externs file
data ExternsTypeFixity = ExternsTypeFixity
@@ -92,23 +104,25 @@ data ExternsTypeFixity = ExternsTypeFixity
, efTypeOperator :: OpName 'TypeOpName
-- | The value the operator is an alias for
, efTypeAlias :: Qualified (ProperName 'TypeName)
- } deriving (Show)
+ } deriving (Show, Generic, NFData)
+
+instance Serialise ExternsTypeFixity
-- | A type or value declaration appearing in an externs file
data ExternsDeclaration =
-- | A type declaration
EDType
{ edTypeName :: ProperName 'TypeName
- , edTypeKind :: SourceKind
+ , edTypeKind :: SourceType
, edTypeDeclarationKind :: TypeKind
}
-- | A type synonym
| EDTypeSynonym
{ edTypeSynonymName :: ProperName 'TypeName
- , edTypeSynonymArguments :: [(Text, Maybe SourceKind)]
+ , edTypeSynonymArguments :: [(Text, Maybe SourceType)]
, edTypeSynonymType :: SourceType
}
- -- | A data construtor
+ -- | A data constructor
| EDDataConstructor
{ edDataCtorName :: ProperName 'ConstructorName
, edDataCtorOrigin :: DataDeclType
@@ -124,25 +138,34 @@ data ExternsDeclaration =
-- | A type class declaration
| EDClass
{ edClassName :: ProperName 'ClassName
- , edClassTypeArguments :: [(Text, Maybe SourceKind)]
+ , edClassTypeArguments :: [(Text, Maybe SourceType)]
, edClassMembers :: [(Ident, SourceType)]
, edClassConstraints :: [SourceConstraint]
, edFunctionalDependencies :: [FunctionalDependency]
+ , edIsEmpty :: Bool
}
-- | An instance declaration
| EDInstance
{ edInstanceClassName :: Qualified (ProperName 'ClassName)
, edInstanceName :: Ident
+ , edInstanceForAll :: [(Text, SourceType)]
+ , edInstanceKinds :: [SourceType]
, edInstanceTypes :: [SourceType]
, edInstanceConstraints :: Maybe [SourceConstraint]
- , edInstanceChain :: [Qualified Ident]
+ , edInstanceChain :: Maybe ChainId
, edInstanceChainIndex :: Integer
+ , edInstanceNameSource :: NameSource
+ , edInstanceSourceSpan :: SourceSpan
}
- -- | A kind declaration
- | EDKind
- { edKindName :: ProperName 'KindName
- }
- deriving Show
+ deriving (Show, Generic, NFData)
+
+instance Serialise ExternsDeclaration
+
+-- | Check whether the version in an externs file matches the currently running
+-- version.
+externsIsCurrentVersion :: ExternsFile -> Bool
+externsIsCurrentVersion ef =
+ T.unpack (efVersion ef) == showVersion Paths.version
-- | Convert an externs file back into a module
applyExternsFileToEnvironment :: ExternsFile -> Environment -> Environment
@@ -152,93 +175,106 @@ applyExternsFileToEnvironment ExternsFile{..} = flip (foldl' applyDecl) efDeclar
applyDecl env (EDType pn kind tyKind) = env { types = M.insert (qual pn) (kind, tyKind) (types env) }
applyDecl env (EDTypeSynonym pn args ty) = env { typeSynonyms = M.insert (qual pn) (args, ty) (typeSynonyms env) }
applyDecl env (EDDataConstructor pn dTy tNm ty nms) = env { dataConstructors = M.insert (qual pn) (dTy, tNm, ty, nms) (dataConstructors env) }
- applyDecl env (EDValue ident ty) = env { names = M.insert (Qualified (Just efModuleName) ident) (ty, External, Defined) (names env) }
- applyDecl env (EDClass pn args members cs deps) = env { typeClasses = M.insert (qual pn) (makeTypeClassData args members cs deps) (typeClasses env) }
- applyDecl env (EDKind pn) = env { kinds = S.insert (qual pn) (kinds env) }
- applyDecl env (EDInstance className ident tys cs ch idx) =
+ applyDecl env (EDValue ident ty) = env { names = M.insert (Qualified (ByModuleName efModuleName) ident) (ty, External, Defined) (names env) }
+ applyDecl env (EDClass pn args members cs deps tcIsEmpty) = env { typeClasses = M.insert (qual pn) (makeTypeClassData args members cs deps tcIsEmpty) (typeClasses env) }
+ applyDecl env (EDInstance className ident vars kinds tys cs ch idx ns ss) =
env { typeClassDictionaries =
updateMap
(updateMap (M.insertWith (<>) (qual ident) (pure dict)) className)
- (Just efModuleName) (typeClassDictionaries env) }
+ (ByModuleName efModuleName) (typeClassDictionaries env) }
where
dict :: NamedDict
- dict = TypeClassDictionaryInScope ch idx (qual ident) [] className tys cs
+ dict = TypeClassDictionaryInScope ch idx (qual ident) [] className vars kinds tys cs instTy
updateMap :: (Ord k, Monoid a) => (a -> a) -> k -> M.Map k a -> M.Map k a
updateMap f = M.alter (Just . f . fold)
+ instTy :: Maybe SourceType
+ instTy = case ns of
+ CompilerNamed -> Just $ srcInstanceType ss vars className tys
+ UserNamed -> Nothing
+
qual :: a -> Qualified a
- qual = Qualified (Just efModuleName)
+ qual = Qualified (ByModuleName efModuleName)
--- | Generate an externs file for all declarations in a module
-moduleToExternsFile :: Module -> Environment -> ExternsFile
-moduleToExternsFile (Module _ _ _ _ Nothing) _ = internalError "moduleToExternsFile: module exports were not elaborated"
-moduleToExternsFile (Module ss _ mn ds (Just exps)) env = ExternsFile{..}
+-- | Generate an externs file for all declarations in a module.
+--
+-- The `Map Ident Ident` argument should contain any top-level `GenIdent`s that
+-- were rewritten to `Ident`s when the module was compiled; this rewrite only
+-- happens in the CoreFn, not the original module AST, so it needs to be
+-- applied to the exported names here also. (The appropriate map is returned by
+-- `L.P.Renamer.renameInModule`.)
+moduleToExternsFile :: Module -> Environment -> M.Map Ident Ident -> ExternsFile
+moduleToExternsFile (Module _ _ _ _ Nothing) _ _ = internalError "moduleToExternsFile: module exports were not elaborated"
+moduleToExternsFile (Module ss _ mn ds (Just exps)) env renamedIdents = ExternsFile{..}
where
efVersion = T.pack (showVersion Paths.version)
efModuleName = mn
- efExports = exps
+ efExports = map renameRef exps
efImports = mapMaybe importDecl ds
efFixities = mapMaybe fixityDecl ds
efTypeFixities = mapMaybe typeFixityDecl ds
- efDeclarations = concatMap toExternsDeclaration efExports
+ efDeclarations = concatMap toExternsDeclaration exps
efSourceSpan = ss
fixityDecl :: Declaration -> Maybe ExternsFixity
fixityDecl (ValueFixityDeclaration _ (Fixity assoc prec) name op) =
- fmap (const (ExternsFixity assoc prec op name)) (find (findOp getValueOpRef op) exps)
+ fmap (const (ExternsFixity assoc prec op name)) (find ((== Just op) . getValueOpRef) exps)
fixityDecl _ = Nothing
typeFixityDecl :: Declaration -> Maybe ExternsTypeFixity
typeFixityDecl (TypeFixityDeclaration _ (Fixity assoc prec) name op) =
- fmap (const (ExternsTypeFixity assoc prec op name)) (find (findOp getTypeOpRef op) exps)
+ fmap (const (ExternsTypeFixity assoc prec op name)) (find ((== Just op) . getTypeOpRef) exps)
typeFixityDecl _ = Nothing
- findOp :: (DeclarationRef -> Maybe (OpName a)) -> OpName a -> DeclarationRef -> Bool
- findOp g op = maybe False (== op) . g
-
importDecl :: Declaration -> Maybe ExternsImport
importDecl (ImportDeclaration _ m mt qmn) = Just (ExternsImport m mt qmn)
importDecl _ = Nothing
toExternsDeclaration :: DeclarationRef -> [ExternsDeclaration]
toExternsDeclaration (TypeRef _ pn dctors) =
- case Qualified (Just mn) pn `M.lookup` types env of
+ case Qualified (ByModuleName mn) pn `M.lookup` types env of
Nothing -> internalError "toExternsDeclaration: no kind in toExternsDeclaration"
Just (kind, TypeSynonym)
- | Just (args, synTy) <- Qualified (Just mn) pn `M.lookup` typeSynonyms env -> [ EDType pn kind TypeSynonym, EDTypeSynonym pn args synTy ]
- Just (kind, ExternData) -> [ EDType pn kind ExternData ]
- Just (kind, tk@(DataType _ tys)) ->
+ | Just (args, synTy) <- Qualified (ByModuleName mn) pn `M.lookup` typeSynonyms env -> [ EDType pn kind TypeSynonym, EDTypeSynonym pn args synTy ]
+ Just (kind, ExternData rs) -> [ EDType pn kind (ExternData rs) ]
+ Just (kind, tk@(DataType _ _ tys)) ->
EDType pn kind tk : [ EDDataConstructor dctor dty pn ty args
| dctor <- fromMaybe (map fst tys) dctors
- , (dty, _, ty, args) <- maybeToList (Qualified (Just mn) dctor `M.lookup` dataConstructors env)
+ , (dty, _, ty, args) <- maybeToList (Qualified (ByModuleName mn) dctor `M.lookup` dataConstructors env)
]
_ -> internalError "toExternsDeclaration: Invalid input"
toExternsDeclaration (ValueRef _ ident)
- | Just (ty, _, _) <- Qualified (Just mn) ident `M.lookup` names env
- = [ EDValue ident ty ]
+ | Just (ty, _, _) <- Qualified (ByModuleName mn) ident `M.lookup` names env
+ = [ EDValue (lookupRenamedIdent ident) ty ]
toExternsDeclaration (TypeClassRef _ className)
- | Just TypeClassData{..} <- Qualified (Just mn) className `M.lookup` typeClasses env
- , Just (kind, TypeSynonym) <- Qualified (Just mn) (coerceProperName className) `M.lookup` types env
- , Just (_, synTy) <- Qualified (Just mn) (coerceProperName className) `M.lookup` typeSynonyms env
- = [ EDType (coerceProperName className) kind TypeSynonym
- , EDTypeSynonym (coerceProperName className) typeClassArguments synTy
- , EDClass className typeClassArguments typeClassMembers typeClassSuperclasses typeClassDependencies
+ | let dictName = dictTypeName . coerceProperName $ className
+ , Just TypeClassData{..} <- Qualified (ByModuleName mn) className `M.lookup` typeClasses env
+ , Just (kind, tk) <- Qualified (ByModuleName mn) (coerceProperName className) `M.lookup` types env
+ , Just (dictKind, dictData@(DataType _ _ [(dctor, _)])) <- Qualified (ByModuleName mn) dictName `M.lookup` types env
+ , Just (dty, _, ty, args) <- Qualified (ByModuleName mn) dctor `M.lookup` dataConstructors env
+ = [ EDType (coerceProperName className) kind tk
+ , EDType dictName dictKind dictData
+ , EDDataConstructor dctor dty dictName ty args
+ , EDClass className typeClassArguments ((\(a, b, _) -> (a, b)) <$> typeClassMembers) typeClassSuperclasses typeClassDependencies typeClassIsEmpty
]
- toExternsDeclaration (TypeInstanceRef _ ident)
- = [ EDInstance tcdClassName ident tcdInstanceTypes tcdDependencies tcdChain tcdIndex
- | m1 <- maybeToList (M.lookup (Just mn) (typeClassDictionaries env))
+ toExternsDeclaration (TypeInstanceRef ss' ident ns)
+ = [ EDInstance tcdClassName (lookupRenamedIdent ident) tcdForAll tcdInstanceKinds tcdInstanceTypes tcdDependencies tcdChain tcdIndex ns ss'
+ | m1 <- maybeToList (M.lookup (ByModuleName mn) (typeClassDictionaries env))
, m2 <- M.elems m1
- , nel <- maybeToList (M.lookup (Qualified (Just mn) ident) m2)
+ , nel <- maybeToList (M.lookup (Qualified (ByModuleName mn) ident) m2)
, TypeClassDictionaryInScope{..} <- NEL.toList nel
]
- toExternsDeclaration (KindRef _ pn)
- | Qualified (Just mn) pn `S.member` kinds env
- = [ EDKind pn ]
toExternsDeclaration _ = []
-$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExternsImport)
-$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExternsFixity)
-$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExternsTypeFixity)
-$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExternsDeclaration)
-$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExternsFile)
+ renameRef :: DeclarationRef -> DeclarationRef
+ renameRef = \case
+ ValueRef ss' ident -> ValueRef ss' $ lookupRenamedIdent ident
+ TypeInstanceRef ss' ident _ | not $ isPlainIdent ident -> TypeInstanceRef ss' (lookupRenamedIdent ident) CompilerNamed
+ other -> other
+
+ lookupRenamedIdent :: Ident -> Ident
+ lookupRenamedIdent = flip (join M.findWithDefault) renamedIdents
+
+externsFileName :: FilePath
+externsFileName = "externs.cbor"
diff --git a/src/Language/PureScript/Glob.hs b/src/Language/PureScript/Glob.hs
new file mode 100644
index 0000000000..3493cd969d
--- /dev/null
+++ b/src/Language/PureScript/Glob.hs
@@ -0,0 +1,44 @@
+module Language.PureScript.Glob where
+
+import Prelude
+
+import Control.Monad (when)
+import Data.List (nub, (\\))
+import Data.Text qualified as T
+import System.FilePath.Glob (glob)
+import System.IO (hPutStrLn, stderr)
+import System.IO.UTF8 (readUTF8FileT)
+
+data PSCGlobs = PSCGlobs
+ { pscInputGlobs :: [FilePath]
+ , pscInputGlobsFromFile :: Maybe FilePath
+ , pscExcludeGlobs :: [FilePath]
+ , pscWarnFileTypeNotFound :: FilePath -> IO ()
+ }
+
+toInputGlobs :: PSCGlobs -> IO [FilePath]
+toInputGlobs (PSCGlobs {..}) = do
+ globsFromFile <- inputGlobsFromFile pscInputGlobsFromFile
+ included <- globWarningOnMisses pscWarnFileTypeNotFound $ nub $ pscInputGlobs <> globsFromFile
+ excluded <- globWarningOnMisses pscWarnFileTypeNotFound pscExcludeGlobs
+ pure $ included \\ excluded
+
+inputGlobsFromFile :: Maybe FilePath -> IO [FilePath]
+inputGlobsFromFile globsFromFile = do
+ mbInputsFromFile <- traverse readUTF8FileT globsFromFile
+ let
+ excludeBlankLines = not . T.null . T.strip
+ excludeComments = not . T.isPrefixOf "#"
+ toInputs = map (T.unpack . T.strip) . filter (\x -> excludeBlankLines x && excludeComments x) . T.lines
+ pure $ foldMap toInputs mbInputsFromFile
+
+globWarningOnMisses :: (String -> IO ()) -> [FilePath] -> IO [FilePath]
+globWarningOnMisses warn = foldMap globWithWarning
+ where
+ globWithWarning pattern' = do
+ paths <- glob pattern'
+ when (null paths) $ warn pattern'
+ return paths
+
+warnFileTypeNotFound :: String -> String -> IO ()
+warnFileTypeNotFound pursCmd = hPutStrLn stderr . ("purs " <> pursCmd <> ": No files found using pattern: " ++)
diff --git a/src/Language/PureScript/Graph.hs b/src/Language/PureScript/Graph.hs
new file mode 100644
index 0000000000..fc2ae68fcb
--- /dev/null
+++ b/src/Language/PureScript/Graph.hs
@@ -0,0 +1,58 @@
+module Language.PureScript.Graph (graph) where
+
+import Prelude
+
+import Data.Aeson qualified as Json
+import Data.Aeson.Key qualified as Json.Key
+import Data.Aeson.KeyMap qualified as Json.Map
+import Data.Map qualified as Map
+
+import Control.Monad (forM)
+import Data.Aeson ((.=))
+import Data.Foldable (foldl')
+import Data.Map (Map)
+import Data.Maybe (fromMaybe)
+import Data.Text (Text)
+import System.IO.UTF8 (readUTF8FileT)
+
+import Language.PureScript.Crash qualified as Crash
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Make qualified as Make
+import Language.PureScript.ModuleDependencies qualified as Dependencies
+import Language.PureScript.Options qualified as Options
+
+import Language.PureScript.Errors (MultipleErrors)
+import Language.PureScript.Names (ModuleName, runModuleName)
+
+
+-- | Given a set of filepaths, try to build the dependency graph and return
+-- that as its JSON representation (or a bunch of errors, if any)
+graph :: [FilePath] -> IO (Either MultipleErrors Json.Value, MultipleErrors)
+graph input = do
+ moduleFiles <- readInput input
+ Make.runMake Options.defaultOptions $ do
+ ms <- CST.parseModulesFromFiles id moduleFiles
+ let parsedModuleSig = Dependencies.moduleSignature . CST.resPartial
+ (_sorted, moduleGraph) <- Dependencies.sortModules Dependencies.Direct (parsedModuleSig . snd) ms
+ let pathMap = Map.fromList $
+ map (\(p, m) -> (Dependencies.sigModuleName (parsedModuleSig m), p)) ms
+ pure (moduleGraphToJSON pathMap moduleGraph)
+
+moduleGraphToJSON
+ :: Map ModuleName FilePath
+ -> Dependencies.ModuleGraph
+ -> Json.Value
+moduleGraphToJSON paths = Json.Object . foldl' insert mempty
+ where
+ insert :: Json.Object -> (ModuleName, [ModuleName]) -> Json.Object
+ insert obj (mn, depends) = Json.Map.insert (Json.Key.fromText (runModuleName mn)) value obj
+ where
+ path = fromMaybe (Crash.internalError "missing module name in graph") $ Map.lookup mn paths
+ value = Json.object
+ [ "path" .= path
+ , "depends" .= fmap runModuleName depends
+ ]
+
+readInput :: [FilePath] -> IO [(FilePath, Text)]
+readInput inputFiles =
+ forM inputFiles $ \inFile -> (inFile, ) <$> readUTF8FileT inFile
diff --git a/src/Language/PureScript/Hierarchy.hs b/src/Language/PureScript/Hierarchy.hs
index 0bbe7650b9..c4919fb60d 100644
--- a/src/Language/PureScript/Hierarchy.hs
+++ b/src/Language/PureScript/Hierarchy.hs
@@ -15,12 +15,12 @@
module Language.PureScript.Hierarchy where
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
+import Protolude (ordNub)
-import Data.List (sort)
-import qualified Data.Text as T
-import qualified Language.PureScript as P
+import Data.List (sort)
+import Data.Text qualified as T
+import Language.PureScript qualified as P
newtype SuperMap = SuperMap
{ _unSuperMap :: Either (P.ProperName 'P.ClassName) (P.ProperName 'P.ClassName, P.ProperName 'P.ClassName)
@@ -54,8 +54,8 @@ prettyPrint (SuperMap (Right (super, sub))) =
" " <> P.runProperName super <> " -> " <> P.runProperName sub <> ";"
runModuleName :: P.ModuleName -> GraphName
-runModuleName (P.ModuleName pns) =
- GraphName $ T.intercalate "_" (P.runProperName <$> pns)
+runModuleName (P.ModuleName name) =
+ GraphName $ T.replace "." "_" name
typeClasses :: Functor f => f P.Module -> f (Maybe Graph)
typeClasses =
@@ -80,6 +80,6 @@ typeClassEpilogue = "\n}"
superClasses :: P.Declaration -> [SuperMap]
superClasses (P.TypeClassDeclaration _ sub _ supers@(_:_) _ _) =
- fmap (\(P.Constraint _ (P.Qualified _ super) _ _) -> SuperMap (Right (super, sub))) supers
+ fmap (\(P.Constraint _ (P.Qualified _ super) _ _ _) -> SuperMap (Right (super, sub))) supers
superClasses (P.TypeClassDeclaration _ sub _ _ _ _) = [SuperMap (Left sub)]
superClasses _ = []
diff --git a/src/Language/PureScript/Ide.hs b/src/Language/PureScript/Ide.hs
index 58aafac16f..57601c3d45 100644
--- a/src/Language/PureScript/Ide.hs
+++ b/src/Language/PureScript/Ide.hs
@@ -18,32 +18,33 @@ module Language.PureScript.Ide
( handleCommand
) where
-import Protolude hiding (moduleName)
-
-import "monad-logger" Control.Monad.Logger
-import qualified Data.Map as Map
-import qualified Data.Text as T
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Ide.CaseSplit as CS
-import Language.PureScript.Ide.Command
-import Language.PureScript.Ide.Completion
-import Language.PureScript.Ide.Error
-import Language.PureScript.Ide.Externs
-import Language.PureScript.Ide.Filter
-import Language.PureScript.Ide.Imports hiding (Import)
-import Language.PureScript.Ide.Matcher
-import Language.PureScript.Ide.Prim
-import Language.PureScript.Ide.Rebuild
-import Language.PureScript.Ide.SourceFile
-import Language.PureScript.Ide.State
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import Language.PureScript.Ide.Usage (findUsages)
-import System.Directory (getCurrentDirectory, getDirectoryContents, doesDirectoryExist, doesFileExist)
-import System.FilePath ((>), normalise)
-import System.FilePath.Glob (glob)
-
--- | Accepts a Commmand and runs it against psc-ide's State. This is the main
+import Protolude hiding (moduleName)
+
+import "monad-logger" Control.Monad.Logger (MonadLogger, logWarnN)
+import Data.Map qualified as Map
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.Glob (toInputGlobs, PSCGlobs(..))
+import Language.PureScript.Ide.CaseSplit qualified as CS
+import Language.PureScript.Ide.Command (Command(..), ImportCommand(..), ListType(..))
+import Language.PureScript.Ide.Completion (CompletionOptions, completionFromMatch, getCompletions, getExactCompletions, simpleExport)
+import Language.PureScript.Ide.Error (IdeError(..))
+import Language.PureScript.Ide.Externs (readExternFile)
+import Language.PureScript.Ide.Filter (Filter)
+import Language.PureScript.Ide.Imports (parseImportsFromFile)
+import Language.PureScript.Ide.Imports.Actions (addImplicitImport, addImportForIdentifier, addQualifiedImport, answerRequest)
+import Language.PureScript.Ide.Matcher (Matcher)
+import Language.PureScript.Ide.Prim (idePrimDeclarations)
+import Language.PureScript.Ide.Rebuild (rebuildFileAsync, rebuildFileSync)
+import Language.PureScript.Ide.SourceFile (parseModulesFromFiles)
+import Language.PureScript.Ide.State (getAllModules, getLoadedModulenames, insertExterns, insertModule, populateVolatileState, populateVolatileStateSync, resetIdeState)
+import Language.PureScript.Ide.Types (Annotation(..), Ide, IdeConfiguration(..), IdeDeclarationAnn(..), IdeEnvironment(..), Success(..))
+import Language.PureScript.Ide.Util (discardAnn, identifierFromIdeDeclaration, namespaceForDeclaration, withEmptyAnn)
+import Language.PureScript.Ide.Usage (findUsages)
+import System.Directory (getCurrentDirectory, getDirectoryContents, doesDirectoryExist, doesFileExist)
+import System.FilePath ((>), normalise)
+
+-- | Accepts a Command and runs it against psc-ide's State. This is the main
-- entry point for the server.
handleCommand
:: (Ide m, MonadLogger m, MonadError IdeError m)
@@ -51,7 +52,8 @@ handleCommand
-> m Success
handleCommand c = case c of
Load [] ->
- findAvailableExterns >>= loadModulesAsync
+ -- Clearing the State before populating it to avoid a space leak
+ resetIdeState *> findAvailableExterns >>= loadModulesAsync
Load modules ->
loadModulesAsync modules
LoadSync [] ->
@@ -153,32 +155,38 @@ caseSplit l b e csa t = do
patterns <- CS.makePattern l b e csa <$> CS.caseSplit t
pure (MultilineTextResult patterns)
--- | Finds all the externs.json files inside the output folder and returns the
--- corresponding Modulenames
+-- | Finds all the externs inside the output folder and returns the
+-- corresponding module names
findAvailableExterns :: (Ide m, MonadError IdeError m) => m [P.ModuleName]
findAvailableExterns = do
oDir <- outputDirectory
unlessM (liftIO (doesDirectoryExist oDir))
- (throwError (GeneralError $ "Couldn't locate your output directory at: " <> (T.pack (normalise oDir))))
+ (throwError (GeneralError $ "Couldn't locate your output directory at: " <> T.pack (normalise oDir)))
liftIO $ do
directories <- getDirectoryContents oDir
moduleNames <- filterM (containsExterns oDir) directories
pure (P.moduleNameFromString . toS <$> moduleNames)
where
- -- Takes the output directory and a filepath like "Monad.Control.Eff" and
- -- looks up, whether that folder contains an externs.json
+ -- Takes the output directory and a filepath like "Data.Array" and
+ -- looks up, whether that folder contains an externs file
containsExterns :: FilePath -> FilePath -> IO Bool
containsExterns oDir d
| d `elem` [".", ".."] = pure False
| otherwise = do
- let file = oDir > d > "externs.json"
+ let file = oDir > d > P.externsFileName
doesFileExist file
-- | Finds all matches for the globs specified at the commandline
findAllSourceFiles :: Ide m => m [FilePath]
findAllSourceFiles = do
- globs <- confGlobs . ideConfiguration <$> ask
- liftIO (concatMapM glob globs)
+ IdeConfiguration{..} <- ideConfiguration <$> ask
+ liftIO $ toInputGlobs $ PSCGlobs
+ { pscInputGlobs = confGlobs
+ , pscInputGlobsFromFile = confGlobsFromFile
+ , pscExcludeGlobs = confGlobsExclude
+ , pscWarnFileTypeNotFound = const $ pure ()
+ }
+
-- | Looks up the ExternsFiles for the given Modulenames and loads them into the
-- server state. Then proceeds to parse all the specified sourcefiles and
@@ -210,7 +218,7 @@ loadModules moduleNames = do
-- We resolve all the modulenames to externs files and load these into memory.
oDir <- outputDirectory
let efPaths =
- map (\mn -> oDir > toS (P.runModuleName mn) > "externs.json") moduleNames
+ map (\mn -> oDir > toS (P.runModuleName mn) > P.externsFileName) moduleNames
efiles <- traverse readExternFile efPaths
traverse_ insertExterns efiles
diff --git a/src/Language/PureScript/Ide/CaseSplit.hs b/src/Language/PureScript/Ide/CaseSplit.hs
index a617ba08ef..8c66f55457 100644
--- a/src/Language/PureScript/Ide/CaseSplit.hs
+++ b/src/Language/PureScript/Ide/CaseSplit.hs
@@ -21,19 +21,18 @@ module Language.PureScript.Ide.CaseSplit
, caseSplit
) where
-import Protolude hiding (Constructor)
+import Protolude hiding (Constructor)
-import qualified Data.Map as M
-import qualified Data.Text as T
-import qualified Language.PureScript as P
+import Data.List.NonEmpty qualified as NE
+import Data.Map qualified as M
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
-import Language.PureScript.Externs
-import Language.PureScript.Ide.Error
-import Language.PureScript.Ide.State
-import Language.PureScript.Ide.Types
-
-import Text.Parsec as Parsec
-import qualified Text.PrettyPrint.Boxes as Box
+import Language.PureScript.Externs (ExternsDeclaration(..), ExternsFile(..))
+import Language.PureScript.Ide.Error (IdeError(..))
+import Language.PureScript.Ide.State (cachedRebuild, getExternFiles)
+import Language.PureScript.Ide.Types (Ide)
type Constructor = (P.ProperName 'P.ConstructorName, [P.SourceType])
@@ -45,7 +44,7 @@ explicitAnnotations = WildcardAnnotations True
noAnnotations :: WildcardAnnotations
noAnnotations = WildcardAnnotations False
-type DataType = ([(Text, Maybe P.SourceKind)], [(P.ProperName 'P.ConstructorName, [P.SourceType])])
+type DataType = ([(Text, Maybe P.SourceType, P.Role)], [(P.ProperName 'P.ConstructorName, [P.SourceType])])
caseSplit
:: (Ide m, MonadError IdeError m)
@@ -55,7 +54,7 @@ caseSplit q = do
type' <- parseType' q
(tc, args) <- splitTypeConstructor type'
(typeVars, ctors) <- findTypeDeclaration tc
- let applyTypeVars = P.everywhereOnTypes (P.replaceAllTypeVars (zip (map fst typeVars) args))
+ let applyTypeVars = P.everywhereOnTypes (P.replaceAllTypeVars (zip (map (\(name, _, _) -> name) typeVars) args))
let appliedCtors = map (second (map applyTypeVars)) ctors
pure appliedCtors
@@ -77,7 +76,7 @@ findTypeDeclaration'
-> First DataType
findTypeDeclaration' t ExternsFile{..} =
First $ head $ mapMaybe (\case
- EDType tn _ (P.DataType typeVars ctors)
+ EDType tn _ (P.DataType _ typeVars ctors)
| tn == t -> Just (typeVars, ctors)
_ -> Nothing) efDeclarations
@@ -92,8 +91,8 @@ splitTypeConstructor = go []
prettyCtor :: WildcardAnnotations -> Constructor -> Text
prettyCtor _ (ctorName, []) = P.runProperName ctorName
prettyCtor wsa (ctorName, ctorArgs) =
- "("<> P.runProperName ctorName <> " "
- <> T.unwords (map (prettyPrintWildcard wsa) ctorArgs) <>")"
+ "(" <> P.runProperName ctorName <> " "
+ <> T.unwords (map (prettyPrintWildcard wsa) ctorArgs) <> ")"
prettyPrintWildcard :: WildcardAnnotations -> P.Type a -> Text
prettyPrintWildcard (WildcardAnnotations True) = prettyWildcard
@@ -125,31 +124,31 @@ addClause s wca = do
parseType' :: (MonadError IdeError m) =>
Text -> m P.SourceType
parseType' s =
- case P.lex "" (toS s) >>= P.runTokenParser "" (P.parseType <* Parsec.eof) of
- Right type' -> pure type'
+ case CST.runTokenParser CST.parseType $ CST.lex s of
+ Right type' -> pure $ CST.convertType "" $ snd type'
Left err ->
throwError (GeneralError ("Parsing the splittype failed with:"
<> show err))
parseTypeDeclaration' :: (MonadError IdeError m) => Text -> m (P.Ident, P.SourceType)
parseTypeDeclaration' s =
- let x = do
- ts <- P.lex "" (toS s)
- P.runTokenParser "" (P.parseDeclaration <* Parsec.eof) ts
+ let x = fmap (CST.convertDeclaration "" . snd)
+ $ CST.runTokenParser CST.parseDecl
+ $ CST.lex s
in
case x of
- Right (P.TypeDeclaration td : _) -> pure (P.unwrapTypeDeclaration td)
+ Right [P.TypeDeclaration td] -> pure (P.unwrapTypeDeclaration td)
Right _ -> throwError (GeneralError "Found a non-type-declaration")
- Left err ->
+ Left errs ->
throwError (GeneralError ("Parsing the type signature failed with: "
- <> toS (Box.render (P.prettyPrintParseError err))))
+ <> toS (CST.prettyPrintErrorMessage $ NE.head errs)))
splitFunctionType :: P.Type a -> [P.Type a]
splitFunctionType t = fromMaybe [] arguments
where
arguments = initMay splitted
splitted = splitType' t
- splitType' (P.ForAll _ _ _ t' _) = splitType' t'
+ splitType' (P.ForAll _ _ _ _ t' _) = splitType' t'
splitType' (P.ConstrainedType _ _ t') = splitType' t'
splitType' (P.TypeApp _ (P.TypeApp _ t' lhs) rhs)
| P.eqType t' P.tyFunction = lhs : splitType' rhs
diff --git a/src/Language/PureScript/Ide/Command.hs b/src/Language/PureScript/Ide/Command.hs
index ac6991b694..ae4b6c9d8e 100644
--- a/src/Language/PureScript/Ide/Command.hs
+++ b/src/Language/PureScript/Ide/Command.hs
@@ -14,17 +14,18 @@
module Language.PureScript.Ide.Command where
-import Protolude
+import Protolude
-import Data.Aeson
-import qualified Data.Map as Map
-import qualified Data.Set as Set
-import qualified Language.PureScript as P
-import Language.PureScript.Ide.CaseSplit
-import Language.PureScript.Ide.Completion
-import Language.PureScript.Ide.Filter
-import Language.PureScript.Ide.Matcher
-import Language.PureScript.Ide.Types
+import Control.Monad.Fail (fail)
+import Data.Aeson (FromJSON(..), withObject, (.!=), (.:), (.:?))
+import Data.Map qualified as Map
+import Data.Set qualified as Set
+import Language.PureScript qualified as P
+import Language.PureScript.Ide.CaseSplit (WildcardAnnotations, explicitAnnotations, noAnnotations)
+import Language.PureScript.Ide.Completion (CompletionOptions, defaultCompletionOptions)
+import Language.PureScript.Ide.Filter (Filter)
+import Language.PureScript.Ide.Matcher (Matcher)
+import Language.PureScript.Ide.Types (IdeDeclarationAnn, IdeNamespace)
data Command
= Load [P.ModuleName]
@@ -103,7 +104,7 @@ instance FromJSON ImportCommand where
<$> (o .: "identifier")
<*> (fmap P.moduleNameFromString <$> o .:? "qualifier")
- _ -> mzero
+ s -> fail ("Unknown import command: " <> show s)
data ListType = LoadedModules | Imports FilePath | AvailableModules
@@ -114,7 +115,7 @@ instance FromJSON ListType where
"import" -> Imports <$> o .: "file"
"loadedModules" -> pure LoadedModules
"availableModules" -> pure AvailableModules
- _ -> mzero
+ s -> fail ("Unknown list type: " <> show s)
instance FromJSON Command where
parseJSON = withObject "command" $ \o -> do
@@ -159,7 +160,7 @@ instance FromJSON Command where
"usages" -> do
params <- o .: "params"
FindUsages
- <$> (map P.moduleNameFromString (params .: "module"))
+ <$> map P.moduleNameFromString (params .: "module")
<*> params .: "identifier"
<*> params .: "namespace"
"import" -> do
@@ -175,10 +176,14 @@ instance FromJSON Command where
<$> params .: "file"
<*> params .:? "actualFile"
<*> (parseCodegenTargets =<< params .:? "codegen" .!= [ "js" ])
- _ -> mzero
+ c -> fail ("Unknown command: " <> show c)
where
- parseCodegenTargets =
- maybe mzero (pure . Set.fromList) . traverse (flip Map.lookup P.codegenTargets)
+ parseCodegenTargets ts =
+ case traverse (\t -> Map.lookup t P.codegenTargets) ts of
+ Nothing ->
+ fail ("Failed to parse codegen targets: " <> show ts)
+ Just ts' ->
+ pure (Set.fromList ts')
mkAnnotations True = explicitAnnotations
mkAnnotations False = noAnnotations
diff --git a/src/Language/PureScript/Ide/Completion.hs b/src/Language/PureScript/Ide/Completion.hs
index 56affea2dd..87fe81de9b 100644
--- a/src/Language/PureScript/Ide/Completion.hs
+++ b/src/Language/PureScript/Ide/Completion.hs
@@ -9,18 +9,18 @@ module Language.PureScript.Ide.Completion
, applyCompletionOptions
) where
-import Protolude hiding ((<&>), moduleName)
-
-import Data.Aeson
-import qualified Data.Map as Map
-import qualified Data.Text as T
-import qualified Language.PureScript as P
-import Language.PureScript.Ide.Error (prettyPrintTypeSingleLine)
-import Language.PureScript.Ide.Filter
-import Language.PureScript.Ide.Matcher
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import Lens.Micro.Platform hiding ((&))
+import Protolude hiding ((<&>), moduleName)
+
+import Control.Lens ((.~), (<&>), (^.))
+import Data.Aeson (FromJSON(..), withObject, (.!=), (.:?))
+import Data.Map qualified as Map
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.Ide.Error (prettyPrintTypeSingleLine)
+import Language.PureScript.Ide.Filter (Filter, applyFilters, exactFilter)
+import Language.PureScript.Ide.Matcher (Matcher, runMatcher)
+import Language.PureScript.Ide.Types
+import Language.PureScript.Ide.Util (identT, identifierFromIdeDeclaration, namespaceForDeclaration, properNameT, typeOperatorAliasT, valueOperatorAliasT)
-- | Applies the CompletionFilters and the Matcher to the given Modules
-- and sorts the found Completions according to the Matching Score
@@ -54,8 +54,8 @@ getExactCompletions search filters modules =
matchesFromModules :: ModuleMap [IdeDeclarationAnn] -> [Match IdeDeclarationAnn]
matchesFromModules = Map.foldMapWithKey completionFromModule
where
- completionFromModule moduleName decls =
- map (\x -> Match (moduleName, x)) decls
+ completionFromModule moduleName =
+ map $ \x -> Match (moduleName, x)
data CompletionOptions = CompletionOptions
{ coMaxResults :: Maybe Int
@@ -89,14 +89,14 @@ groupCompletionReexports initial =
where
go (Match (moduleName, d@(IdeDeclarationAnn ann decl))) =
let
- origin = fromMaybe moduleName (ann^.annExportedFrom)
+ origin = fromMaybe moduleName (ann ^. annExportedFrom)
in
Map.alter
(insertDeclaration moduleName origin d)
(Namespaced (namespaceForDeclaration decl)
(P.runModuleName origin <> "." <> identifierFromIdeDeclaration decl))
insertDeclaration moduleName origin d old = case old of
- Nothing -> Just ( Match (origin, d & idaAnnotation.annExportedFrom .~ Nothing)
+ Nothing -> Just ( Match (origin, d & idaAnnotation . annExportedFrom .~ Nothing)
, [moduleName]
)
Just x -> Just (second (moduleName :) x)
@@ -110,15 +110,14 @@ completionFromMatch (Match (m, IdeDeclarationAnn ann decl), mns) =
where
(complIdentifier, complExpandedType) = case decl of
IdeDeclValue v -> (v ^. ideValueIdent . identT, v ^. ideValueType & prettyPrintTypeSingleLine)
- IdeDeclType t -> (t ^. ideTypeName . properNameT, t ^. ideTypeKind & P.prettyPrintKind)
+ IdeDeclType t -> (t ^. ideTypeName . properNameT, t ^. ideTypeKind & prettyPrintTypeSingleLine)
IdeDeclTypeSynonym s -> (s ^. ideSynonymName . properNameT, s ^. ideSynonymType & prettyPrintTypeSingleLine)
IdeDeclDataConstructor d -> (d ^. ideDtorName . properNameT, d ^. ideDtorType & prettyPrintTypeSingleLine)
- IdeDeclTypeClass d -> (d ^. ideTCName . properNameT, d ^. ideTCKind & P.prettyPrintKind)
+ IdeDeclTypeClass d -> (d ^. ideTCName . properNameT, d ^. ideTCKind & prettyPrintTypeSingleLine)
IdeDeclValueOperator (IdeValueOperator op ref precedence associativity typeP) ->
(P.runOpName op, maybe (showFixity precedence associativity (valueOperatorAliasT ref) op) prettyPrintTypeSingleLine typeP)
IdeDeclTypeOperator (IdeTypeOperator op ref precedence associativity kind) ->
- (P.runOpName op, maybe (showFixity precedence associativity (typeOperatorAliasT ref) op) P.prettyPrintKind kind)
- IdeDeclKind k -> (P.runProperName k, "kind")
+ (P.runOpName op, maybe (showFixity precedence associativity (typeOperatorAliasT ref) op) prettyPrintTypeSingleLine kind)
IdeDeclModule mn -> (P.runModuleName mn, "module")
complExportedFrom = mns
@@ -131,6 +130,8 @@ completionFromMatch (Match (m, IdeDeclarationAnn ann decl), mns) =
complDocumentation = _annDocumentation ann
+ complDeclarationType = Just (declarationType decl)
+
showFixity p a r o =
let asso = case a of
P.Infix -> "infix"
diff --git a/src/Language/PureScript/Ide/Error.hs b/src/Language/PureScript/Ide/Error.hs
index 3a3645a804..8a23f574e0 100644
--- a/src/Language/PureScript/Ide/Error.hs
+++ b/src/Language/PureScript/Ide/Error.hs
@@ -17,70 +17,81 @@ module Language.PureScript.Ide.Error
, prettyPrintTypeSingleLine
) where
-import Data.Aeson
-import qualified Data.Aeson.Types as Aeson
-import qualified Data.HashMap.Lazy as HM
-import qualified Data.Text as T
-import qualified Language.PureScript as P
-import Language.PureScript.Errors.JSON
-import Language.PureScript.Ide.Types (ModuleIdent, Completion(..))
-import Protolude
-import qualified Text.Parsec.Error as Parsec
+import Data.Aeson (KeyValue(..), ToJSON(..), Value, object)
+import Data.Aeson.Types qualified as Aeson
+import Data.Aeson.KeyMap qualified as KM
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.Errors.JSON (toJSONError)
+import Language.PureScript.Ide.Types (ModuleIdent, Completion(..))
+import Protolude
data IdeError
= GeneralError Text
| NotFound Text
| ModuleNotFound ModuleIdent
| ModuleFileNotFound ModuleIdent
- | ParseError Parsec.ParseError Text
- | RebuildError P.MultipleErrors
+ | RebuildError [(FilePath, Text)] P.MultipleErrors
deriving (Show)
instance ToJSON IdeError where
- toJSON (RebuildError errs) = object
+ toJSON (RebuildError files errs) = object
[ "resultType" .= ("error" :: Text)
- , "result" .= encodeRebuildErrors errs
+ , "result" .= encodeRebuildErrors files errs
]
toJSON err = object
[ "resultType" .= ("error" :: Text)
, "result" .= textError err
]
-encodeRebuildErrors :: P.MultipleErrors -> Value
-encodeRebuildErrors = toJSON . map encodeRebuildError . P.runMultipleErrors
+encodeRebuildErrors :: [(FilePath, Text)] -> P.MultipleErrors -> Value
+encodeRebuildErrors files = toJSON . map encodeRebuildError . P.runMultipleErrors
where
encodeRebuildError err = case err of
(P.ErrorMessage _
((P.HoleInferredType name _ _
- (Just (P.TSAfter{tsAfterIdentifiers=idents, tsAfterRecordFields=fields}))))) ->
- insertTSCompletions name idents (fromMaybe [] fields) (toJSON (toJSONError False P.Error err))
+ (Just P.TSAfter{tsAfterIdentifiers=idents, tsAfterRecordFields=fields})))) ->
+ insertTSCompletions name idents (fromMaybe [] fields) (toJSON (toJSONError False P.Error files err))
_ ->
- (toJSON . toJSONError False P.Error) err
+ (toJSON . toJSONError False P.Error files) err
insertTSCompletions name idents fields (Aeson.Object value) =
Aeson.Object
- (HM.insert "pursIde"
+ (KM.insert "pursIde"
(object [ "name" .= name
- , "completions" .= (ordNub (map identCompletion idents ++ map fieldCompletion fields))
+ , "completions" .= ordNub (map identCompletion idents ++ map fieldCompletion fields)
]) value)
insertTSCompletions _ _ _ v = v
identCompletion (P.Qualified mn i, ty) =
- Completion (maybe "" P.runModuleName mn) i (prettyPrintTypeSingleLine ty) (prettyPrintTypeSingleLine ty) Nothing Nothing (maybe [] (\x -> [x]) mn)
+ Completion
+ { complModule = maybe "" P.runModuleName $ P.toMaybeModuleName mn
+ , complIdentifier = i
+ , complType = prettyPrintTypeSingleLine ty
+ , complExpandedType = prettyPrintTypeSingleLine ty
+ , complLocation = Nothing
+ , complDocumentation = Nothing
+ , complExportedFrom = toList $ P.toMaybeModuleName mn
+ , complDeclarationType = Nothing
+ }
fieldCompletion (label, ty) =
- Completion "" ("_." <> P.prettyPrintLabel label) (prettyPrintTypeSingleLine ty) (prettyPrintTypeSingleLine ty) Nothing Nothing []
+ Completion
+ { complModule = ""
+ , complIdentifier = "_." <> P.prettyPrintLabel label
+ , complType = prettyPrintTypeSingleLine ty
+ , complExpandedType = prettyPrintTypeSingleLine ty
+ , complLocation = Nothing
+ , complDocumentation = Nothing
+ , complExportedFrom = []
+ , complDeclarationType = Nothing
+ }
textError :: IdeError -> Text
textError (GeneralError msg) = msg
textError (NotFound ident) = "Symbol '" <> ident <> "' not found."
textError (ModuleNotFound ident) = "Module '" <> ident <> "' not found."
-textError (ModuleFileNotFound ident) = "Extern file for module " <> ident <>" could not be found"
-textError (ParseError parseError msg) = let escape = show
- -- escape newlines and other special
- -- chars so we can send the error
- -- over the socket as a single line
- in msg <> ": " <> escape parseError
-textError (RebuildError err) = show err
+textError (ModuleFileNotFound ident) = "Extern file for module " <> ident <> " could not be found"
+textError (RebuildError _ err) = show err
prettyPrintTypeSingleLine :: P.Type a -> Text
prettyPrintTypeSingleLine = T.unwords . map T.strip . T.lines . T.pack . P.prettyPrintTypeWithUnicode maxBound
diff --git a/src/Language/PureScript/Ide/Externs.hs b/src/Language/PureScript/Ide/Externs.hs
index ae5d2b5aa9..120c2da4f6 100644
--- a/src/Language/PureScript/Ide/Externs.hs
+++ b/src/Language/PureScript/Ide/Externs.hs
@@ -1,61 +1,46 @@
------------------------------------------------------------------------------
---
--- Module : Language.PureScript.Ide.Externs
--- Description : Handles externs files for psc-ide
--- Copyright : Christoph Hegemann 2016
--- License : MIT (http://opensource.org/licenses/MIT)
---
--- Maintainer : Christoph Hegemann
--- Stability : experimental
---
--- |
--- Handles externs files for psc-ide
------------------------------------------------------------------------------
-
-{-# LANGUAGE PackageImports #-}
+{-# language PackageImports, BlockArguments #-}
module Language.PureScript.Ide.Externs
( readExternFile
, convertExterns
) where
-import Protolude hiding (to, from, (&))
-
-import "monad-logger" Control.Monad.Logger
-import Data.Aeson (decodeStrict)
-import Data.Aeson.Types (withObject, parseMaybe, (.:))
-import qualified Data.ByteString as BS
-import Data.Version (showVersion)
-import Language.PureScript.Ide.Error (IdeError (..))
-import Language.PureScript.Ide.Types
-import Lens.Micro.Platform
+import Protolude hiding (to, from, (&))
-import qualified Language.PureScript as P
+import Codec.CBOR.Term as Term
+import Control.Lens (preview, view, (&), (^.))
+import "monad-logger" Control.Monad.Logger (MonadLogger, logErrorN)
+import Data.Version (showVersion)
+import Data.Text qualified as Text
+import Language.PureScript qualified as P
+import Language.PureScript.Make.Monad qualified as Make
+import Language.PureScript.Ide.Error (IdeError (..))
+import Language.PureScript.Ide.Types (IdeDataConstructor(..), IdeDeclaration(..), IdeDeclarationAnn(..), IdeType(..), IdeTypeClass(..), IdeTypeOperator(..), IdeTypeSynonym(..), IdeValue(..), IdeValueOperator(..), _IdeDeclType, anyOf, emptyAnn, ideTypeKind, ideTypeName)
+import Language.PureScript.Ide.Util (properNameT)
readExternFile
:: (MonadIO m, MonadError IdeError m, MonadLogger m)
=> FilePath
-> m P.ExternsFile
readExternFile fp = do
- externsFile <- liftIO (BS.readFile fp)
- case decodeStrict externsFile of
- Nothing ->
- let parser = withObject "ExternsFileVersion" $ \o -> o .: "efVersion"
- maybeEFVersion = parseMaybe parser =<< decodeStrict externsFile
- in case maybeEFVersion of
- Nothing ->
- throwError (GeneralError
- ("Parsing the extern at: " <> toS fp <> " failed"))
- Just efVersion -> do
- let errMsg = "Version mismatch for the externs at: " <> toS fp
- <> " Expected: " <> version
- <> " Found: " <> efVersion
- logErrorN errMsg
- throwError (GeneralError errMsg)
- Just externs -> pure externs
-
- where
- version = toS (showVersion P.version)
+ externsFile <- liftIO (Make.readCborFileIO fp)
+ case externsFile of
+ Just externs | version == P.efVersion externs ->
+ pure externs
+ _ ->
+ liftIO (Make.readCborFileIO fp) >>= \case
+ Just (Term.TList (_tag : Term.TString efVersion : _rest)) -> do
+ let errMsg =
+ "Version mismatch for the externs at: "
+ <> toS fp
+ <> " Expected: " <> version
+ <> " Found: " <> efVersion
+ logErrorN errMsg
+ throwError (GeneralError errMsg)
+ _ ->
+ throwError (GeneralError ("Parsing the extern at: " <> toS fp <> " failed"))
+ where
+ version = toS (showVersion P.version)
convertExterns :: P.ExternsFile -> ([IdeDeclarationAnn], [(P.ModuleName, P.DeclarationRef)])
convertExterns ef =
@@ -70,51 +55,40 @@ convertExterns ef =
moduleDecl = IdeDeclarationAnn emptyAnn (IdeDeclModule (P.efModuleName ef))
(toResolve, declarations) =
second catMaybes (partitionEithers (map convertDecl (P.efDeclarations ef)))
+ resolvedDeclarations = resolveSynonymsAndClasses toResolve declarations
- -- It's important that we resolve synonyms first, because that resolving
- -- process removes the corresponding type declarations. This way we don't
- -- leave any stray type declarations for type classes around since they have
- -- already been cleaned up in the type synonym pass.
- resolver = resolveTypeClasses toResolve <> resolveSynonyms toResolve
- resolvedDeclarations = appEndo resolver declarations
-
-resolveSynonyms :: [ToResolve] -> Endo [IdeDeclaration]
-resolveSynonyms = foldMap resolveSynonym
+resolveSynonymsAndClasses
+ :: [ToResolve]
+ -> [IdeDeclaration]
+ -> [IdeDeclaration]
+resolveSynonymsAndClasses trs decls = foldr go decls trs
where
- resolveSynonym tr = case tr of
- TypeClassToResolve _ -> mempty
- SynonymToResolve tn ty -> Endo $ \decls ->
- case findType tn decls of
- Nothing -> decls
+ go tr acc = case tr of
+ TypeClassToResolve tcn ->
+ case findType (P.coerceProperName tcn) acc of
+ Nothing ->
+ acc
+ Just tyDecl -> IdeDeclTypeClass
+ (IdeTypeClass tcn (tyDecl ^. ideTypeKind) [])
+ : filter (not . anyOf (_IdeDeclType . ideTypeName) (== P.coerceProperName tcn)) acc
+ SynonymToResolve tn ty ->
+ case findType tn acc of
+ Nothing ->
+ acc
Just tyDecl ->
- IdeDeclTypeSynonym (IdeTypeSynonym tn ty (tyDecl^.ideTypeKind))
- : filter (not . anyOf (_IdeDeclType.ideTypeName) (== tn)) decls
-
-resolveTypeClasses :: [ToResolve] -> Endo [IdeDeclaration]
-resolveTypeClasses = foldMap resolveTypeClass
- where
- resolveTypeClass tr = case tr of
- SynonymToResolve _ _ -> mempty
- TypeClassToResolve tcn -> Endo $ \decls ->
- case findSynonym (P.coerceProperName tcn) decls of
- Nothing -> decls
- Just tySyn -> IdeDeclTypeClass
- (IdeTypeClass tcn (tySyn^.ideSynonymKind) [])
- : filter (not . anyOf (_IdeDeclTypeSynonym.ideSynonymName) (== P.coerceProperName tcn)) decls
+ IdeDeclTypeSynonym (IdeTypeSynonym tn ty (tyDecl ^. ideTypeKind))
+ : filter (not . anyOf (_IdeDeclType . ideTypeName) (== tn)) acc
findType :: P.ProperName 'P.TypeName -> [IdeDeclaration] -> Maybe IdeType
-findSynonym :: P.ProperName 'P.TypeName -> [IdeDeclaration] -> Maybe IdeTypeSynonym
-(findType, findSynonym) = ( findDecl _IdeDeclType ideTypeName
- , findDecl _IdeDeclTypeSynonym ideSynonymName
- )
- where
- findDecl p l tn decls = decls
- & mapMaybe (preview p)
- & find ((==) tn . view l)
-
--- The Externs format splits information about synonyms across EDType and
--- EDTypeSynonym declarations. For type classes there are three declarations
--- involved. We collect these and resolve them at the end of the conversion process.
+findType tn decls =
+ decls
+ & mapMaybe (preview _IdeDeclType)
+ & find ((==) tn . view ideTypeName)
+
+-- The Externs format splits information about synonyms across EDType
+-- and EDTypeSynonym declarations. For type classes it split them
+-- across an EDType and an EDClass . We collect these and resolve them
+-- at the end of the conversion process.
data ToResolve
= TypeClassToResolve (P.ProperName 'P.ClassName)
| SynonymToResolve (P.ProperName 'P.TypeName) P.SourceType
@@ -125,21 +99,25 @@ convertExport _ = Nothing
convertDecl :: P.ExternsDeclaration -> Either ToResolve (Maybe IdeDeclaration)
convertDecl ed = case ed of
- P.EDType{..} ->
- Right (Just (IdeDeclType (IdeType edTypeName edTypeKind [])))
+ -- We need to filter all types and synonyms that contain a '$'
+ -- because those are typechecker internal definitions that shouldn't
+ -- be user facing
+ P.EDType{..} -> Right do
+ guard (isNothing (Text.find (== '$') (edTypeName ^. properNameT)))
+ Just (IdeDeclType (IdeType edTypeName edTypeKind []))
P.EDTypeSynonym{..} ->
- Left (SynonymToResolve edTypeSynonymName edTypeSynonymType)
- P.EDDataConstructor{..} ->
- Right
- (Just
- (IdeDeclDataConstructor
- (IdeDataConstructor edDataCtorName edDataCtorTypeCtor edDataCtorType)))
+ if isNothing (Text.find (== '$') (edTypeSynonymName ^. properNameT))
+ then Left (SynonymToResolve edTypeSynonymName edTypeSynonymType)
+ else Right Nothing
+ P.EDDataConstructor{..} -> Right do
+ guard (isNothing (Text.find (== '$') (edDataCtorName ^. properNameT)))
+ Just
+ (IdeDeclDataConstructor
+ (IdeDataConstructor edDataCtorName edDataCtorTypeCtor edDataCtorType))
P.EDValue{..} ->
Right (Just (IdeDeclValue (IdeValue edValueName edValueType)))
P.EDClass{..} ->
Left (TypeClassToResolve edClassName)
- P.EDKind{..} ->
- Right (Just (IdeDeclKind edKindName))
P.EDInstance{} ->
Right Nothing
diff --git a/src/Language/PureScript/Ide/Filter.hs b/src/Language/PureScript/Ide/Filter.hs
index 83829a75d8..9bb29d6e49 100644
--- a/src/Language/PureScript/Ide/Filter.hs
+++ b/src/Language/PureScript/Ide/Filter.hs
@@ -12,8 +12,6 @@
-- Filters for psc-ide commands
-----------------------------------------------------------------------------
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-
module Language.PureScript.Ide.Filter
( Filter
, moduleFilter
@@ -21,20 +19,26 @@ module Language.PureScript.Ide.Filter
, exactFilter
, prefixFilter
, declarationTypeFilter
+ , dependencyFilter
, applyFilters
) where
-import Protolude hiding (isPrefixOf, Prefix)
+import Protolude hiding (isPrefixOf, Prefix)
+
+import Control.Monad.Fail (fail)
+import Data.Aeson (FromJSON(..), withObject, (.:), (.:?))
+import Data.Text (isPrefixOf)
+import Data.Set qualified as Set
+import Data.Map qualified as Map
+import Language.PureScript.Ide.Filter.Declaration (DeclarationType)
+import Language.PureScript.Ide.Types (IdeDeclarationAnn, IdeNamespace, ModuleMap, declarationType)
+import Language.PureScript.Ide.Imports (Import, sliceImportSection)
+import Language.PureScript.Ide.Util (discardAnn, identifierFromIdeDeclaration, namespaceForDeclaration)
-import Data.Bifunctor (first)
-import Data.Aeson
-import Data.Text (isPrefixOf)
-import qualified Data.Set as Set
-import qualified Data.Map as Map
-import Language.PureScript.Ide.Filter.Declaration (DeclarationType, declarationType)
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import qualified Language.PureScript as P
+import Language.PureScript qualified as P
+import Data.Text qualified as T
+
+import Language.PureScript.Ide.Filter.Imports (matchImport)
newtype Filter = Filter (Either (Set P.ModuleName) DeclarationFilter)
deriving Show
@@ -47,6 +51,7 @@ data DeclarationFilter
| Exact Text
| Namespace (Set IdeNamespace)
| DeclType (Set DeclarationType)
+ | Dependencies { qualifier :: Maybe P.ModuleName, currentModuleName :: P.ModuleName, dependencyImports :: [Import] }
deriving Show
-- | Only keeps Declarations in the given modules
@@ -69,6 +74,9 @@ prefixFilter t = Filter (Right (Prefix t))
declarationTypeFilter :: Set DeclarationType -> Filter
declarationTypeFilter dts = Filter (Right (DeclType dts))
+dependencyFilter :: Maybe P.ModuleName -> P.ModuleName -> [Import] -> Filter
+dependencyFilter q m f = Filter (Right (Dependencies q m f))
+
optimizeFilters :: [Filter] -> (Maybe (Set P.ModuleName), [DeclarationFilter])
optimizeFilters = first smashModuleFilters . partitionEithers . map unFilter
where
@@ -90,21 +98,23 @@ applyDeclarationFilters
-> ModuleMap [IdeDeclarationAnn]
applyDeclarationFilters fs =
Map.filter (not . null)
- . Map.map (foldr (.) identity (map applyDeclarationFilter fs))
+ . Map.mapWithKey (\modl decls -> foldr (.) identity (map (applyDeclarationFilter modl) fs) decls)
applyDeclarationFilter
- :: DeclarationFilter
+ :: P.ModuleName
+ -> DeclarationFilter
-> [IdeDeclarationAnn]
-> [IdeDeclarationAnn]
-applyDeclarationFilter f = case f of
+applyDeclarationFilter modl f = case f of
Prefix prefix -> prefixFilter' prefix
Exact t -> exactFilter' t
Namespace namespaces -> namespaceFilter' namespaces
DeclType dts -> declarationTypeFilter' dts
+ Dependencies qual currentModuleName imps -> dependencyFilter' modl qual currentModuleName imps
namespaceFilter' :: Set IdeNamespace -> [IdeDeclarationAnn] -> [IdeDeclarationAnn]
namespaceFilter' namespaces =
- filter (\decl -> elem (namespaceForDeclaration (discardAnn decl)) namespaces)
+ filter (\decl -> namespaceForDeclaration (discardAnn decl) `elem` namespaces)
exactFilter' :: Text -> [IdeDeclarationAnn] -> [IdeDeclarationAnn]
exactFilter' search =
@@ -118,6 +128,13 @@ declarationTypeFilter' :: Set DeclarationType -> [IdeDeclarationAnn] -> [IdeDecl
declarationTypeFilter' declTypes =
filter (\decl -> declarationType (discardAnn decl) `Set.member` declTypes)
+dependencyFilter' :: P.ModuleName -> Maybe P.ModuleName -> P.ModuleName -> [Import] -> [IdeDeclarationAnn] -> [IdeDeclarationAnn]
+dependencyFilter' modl qual currentModuleName imports =
+ if modl == currentModuleName && isNothing qual then
+ identity
+ else
+ filter (\decl -> any (matchImport qual modl decl) imports)
+
instance FromJSON Filter where
parseJSON = withObject "filter" $ \o -> do
(filter' :: Text) <- o .: "filter"
@@ -131,7 +148,7 @@ instance FromJSON Filter where
search <- params .: "search"
pure (exactFilter search)
"prefix" -> do
- params <- o.: "params"
+ params <- o .: "params"
search <- params .: "search"
pure (prefixFilter search)
"namespace" -> do
@@ -139,6 +156,13 @@ instance FromJSON Filter where
namespaces <- params .: "namespaces"
pure (namespaceFilter (Set.fromList namespaces))
"declarations" -> do
- declarations <- o.: "params"
+ declarations <- o .: "params"
pure (declarationTypeFilter (Set.fromList declarations))
- _ -> mzero
+ "dependencies" -> do
+ params <- o .: "params"
+ moduleText <- params .: "moduleText"
+ qualifier <- fmap P.moduleNameFromString <$> params .:? "qualifier"
+ case sliceImportSection (T.lines moduleText) of
+ Left err -> fail ("Couldn't parse module imports: " <> T.unpack err)
+ Right (currentModuleName, _, imports, _ ) -> pure (dependencyFilter qualifier currentModuleName imports)
+ s -> fail ("Unknown filter: " <> show s)
diff --git a/src/Language/PureScript/Ide/Filter/Declaration.hs b/src/Language/PureScript/Ide/Filter/Declaration.hs
index 5c04fd3512..7875f7851c 100644
--- a/src/Language/PureScript/Ide/Filter/Declaration.hs
+++ b/src/Language/PureScript/Ide/Filter/Declaration.hs
@@ -1,14 +1,11 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-
module Language.PureScript.Ide.Filter.Declaration
( DeclarationType(..)
- , declarationType
) where
-import Protolude hiding (isPrefixOf)
+import Protolude hiding (isPrefixOf)
-import Data.Aeson
-import qualified Language.PureScript.Ide.Types as PI
+import Control.Monad.Fail (fail)
+import Data.Aeson (FromJSON(..), ToJSON(..), withText)
data DeclarationType
= Value
@@ -18,32 +15,28 @@ data DeclarationType
| TypeClass
| ValueOperator
| TypeOperator
- | Kind
| Module
deriving (Show, Eq, Ord)
instance FromJSON DeclarationType where
- parseJSON = withText "Declaration type tag" $ \str ->
- case str of
- "value" -> pure Value
- "type" -> pure Type
- "synonym" -> pure Synonym
- "dataconstructor" -> pure DataConstructor
- "typeclass" -> pure TypeClass
- "valueoperator" -> pure ValueOperator
- "typeoperator" -> pure TypeOperator
- "kind" -> pure Kind
- "module" -> pure Module
- _ -> mzero
+ parseJSON = withText "Declaration type tag" $ \case
+ "value" -> pure Value
+ "type" -> pure Type
+ "synonym" -> pure Synonym
+ "dataconstructor" -> pure DataConstructor
+ "typeclass" -> pure TypeClass
+ "valueoperator" -> pure ValueOperator
+ "typeoperator" -> pure TypeOperator
+ "module" -> pure Module
+ s -> fail ("Unknown declaration type: " <> show s)
-declarationType :: PI.IdeDeclaration -> DeclarationType
-declarationType decl = case decl of
- PI.IdeDeclValue _ -> Value
- PI.IdeDeclType _ -> Type
- PI.IdeDeclTypeSynonym _ -> Synonym
- PI.IdeDeclDataConstructor _ -> DataConstructor
- PI.IdeDeclTypeClass _ -> TypeClass
- PI.IdeDeclValueOperator _ -> ValueOperator
- PI.IdeDeclTypeOperator _ -> TypeOperator
- PI.IdeDeclKind _ -> Kind
- PI.IdeDeclModule _ -> Module
+instance ToJSON DeclarationType where
+ toJSON = toJSON . \case
+ Value -> "value" :: Text
+ Type -> "type"
+ Synonym -> "synonym"
+ DataConstructor -> "dataconstructor"
+ TypeClass -> "typeclass"
+ ValueOperator -> "valueoperator"
+ TypeOperator -> "typeoperator"
+ Module -> "module"
diff --git a/src/Language/PureScript/Ide/Filter/Imports.hs b/src/Language/PureScript/Ide/Filter/Imports.hs
new file mode 100644
index 0000000000..bd1d70065d
--- /dev/null
+++ b/src/Language/PureScript/Ide/Filter/Imports.hs
@@ -0,0 +1,31 @@
+module Language.PureScript.Ide.Filter.Imports where
+
+
+import Protolude hiding (isPrefixOf)
+
+import Language.PureScript.Ide.Types (IdeDataConstructor(..), IdeDeclaration(..), IdeDeclarationAnn(..), IdeType(..), IdeTypeClass(..), IdeTypeOperator(..), IdeTypeSynonym(..), IdeValue(..), IdeValueOperator(..))
+import Language.PureScript.Ide.Imports (Import(..))
+
+import Language.PureScript qualified as P
+
+matchImport :: Maybe P.ModuleName -> P.ModuleName -> IdeDeclarationAnn -> Import -> Bool
+matchImport matchQualifier declMod (IdeDeclarationAnn _ decl) (Import importMod declTy qualifier) | declMod == importMod && matchQualifier == qualifier =
+ case declTy of
+ P.Implicit -> True
+ P.Explicit refs -> any (matchRef decl) refs
+ P.Hiding refs -> not $ any (matchRef decl) refs
+ where
+ matchRef (IdeDeclValue (IdeValue ident _)) (P.ValueRef _ ident') = ident == ident'
+ matchRef (IdeDeclType (IdeType tname _kind _dctors)) (P.TypeRef _ tname' _dctors') = tname == tname'
+ matchRef (IdeDeclTypeSynonym (IdeTypeSynonym tname _type _kind)) (P.TypeRef _ tname' _dctors) = tname == tname' -- Can this occur?
+
+ matchRef (IdeDeclDataConstructor (IdeDataConstructor dcname tname _type)) (P.TypeRef _ tname' dctors) =
+ tname == tname'
+ && maybe True (dcname `elem`) dctors -- (..) or explicitly lists constructor
+
+ matchRef (IdeDeclTypeClass (IdeTypeClass tcname _kind _instances)) (P.TypeClassRef _ tcname') = tcname == tcname'
+ matchRef (IdeDeclValueOperator (IdeValueOperator{ _ideValueOpName })) (P.ValueOpRef _ opname) = _ideValueOpName == opname
+ matchRef (IdeDeclTypeOperator (IdeTypeOperator{ _ideTypeOpName })) (P.TypeOpRef _ opname) = _ideTypeOpName == opname
+ matchRef _ _ = False
+
+matchImport _ _ _ _ = False
diff --git a/src/Language/PureScript/Ide/Imports.hs b/src/Language/PureScript/Ide/Imports.hs
index e880248323..b96f090a7f 100644
--- a/src/Language/PureScript/Ide/Imports.hs
+++ b/src/Language/PureScript/Ide/Imports.hs
@@ -13,40 +13,27 @@
-----------------------------------------------------------------------------
module Language.PureScript.Ide.Imports
- ( addImplicitImport
- , addQualifiedImport
- , addImportForIdentifier
- , answerRequest
- , parseImportsFromFile
+ ( parseImportsFromFile
+ , parseImportsFromFile'
-- for tests
, parseImport
, prettyPrintImportSection
- , addImplicitImport'
- , addQualifiedImport'
- , addExplicitImport'
, sliceImportSection
, prettyPrintImport'
, Import(Import)
)
where
-import Protolude hiding (moduleName)
+import Protolude hiding (moduleName)
-import Data.List (findIndex, nubBy, partition)
-import qualified Data.Map as Map
-import qualified Data.Text as T
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Constants as C
-import Language.PureScript.Ide.Completion
-import Language.PureScript.Ide.Error
-import Language.PureScript.Ide.Filter
-import Language.PureScript.Ide.State
-import Language.PureScript.Ide.Prim
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import Lens.Micro.Platform ((^.), (%~), ix, has)
-import System.IO.UTF8 (writeUTF8FileT)
-import qualified Text.Parsec as Parsec
+import Control.Lens ((^.), (%~), ix)
+import Data.List (partition)
+import Data.List.NonEmpty qualified as NE
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Ide.Error (IdeError(..))
+import Language.PureScript.Ide.Util (ideReadFile)
data Import = Import P.ModuleName P.ImportDeclarationType (Maybe P.ModuleName)
deriving (Eq, Show)
@@ -90,21 +77,27 @@ data ImportParse = ImportParse
-- ^ the extracted import declarations
}
-parseModuleHeader :: P.TokenParser ImportParse
-parseModuleHeader = do
- _ <- P.readComments
- (mn, _) <- P.parseModuleDeclaration
- (ipStart, ipEnd, decls) <- P.withSourceSpan (\(P.SourceSpan _ start end) _ -> (start, end,))
- (P.mark (Parsec.many (P.same *> P.parseImportDeclaration')))
- pure (ImportParse mn ipStart ipEnd (map mkImport decls))
- where
- mkImport (mn, (P.Explicit refs), qual) = Import mn (P.Explicit refs) qual
- mkImport (mn, it, qual) = Import mn it qual
+parseModuleHeader :: Text -> Either (NE.NonEmpty CST.ParserError) ImportParse
+parseModuleHeader src = do
+ CST.PartialResult md _ <- CST.parseModule $ CST.lenient $ CST.lexModule src
+ let
+ mn = CST.nameValue $ CST.modNamespace md
+ decls = flip fmap (CST.modImports md) $ \decl -> do
+ let ((ss, _), mn', it, qual) = CST.convertImportDecl "" decl
+ (ss, Import mn' it qual)
+ case (head decls, lastMay decls) of
+ (Just hd, Just ls) -> do
+ let
+ ipStart = P.spanStart $ fst hd
+ ipEnd = P.spanEnd $ fst ls
+ pure $ ImportParse mn ipStart ipEnd $ snd <$> decls
+ _ -> do
+ let pos = CST.sourcePos . CST.srcEnd . CST.tokRange . CST.tokAnn $ CST.modWhere md
+ pure $ ImportParse mn pos pos []
sliceImportSection :: [Text] -> Either Text (P.ModuleName, [Text], [Import], [Text])
-sliceImportSection fileLines = first show $ do
- tokens <- P.lexLenient "" file
- ImportParse{..} <- P.runTokenParser "" parseModuleHeader tokens
+sliceImportSection fileLines = first (toS . CST.prettyPrintError . NE.head) $ do
+ ImportParse{..} <- parseModuleHeader file
pure
( ipModuleName
, sliceFile (P.SourcePos 1 1) (prevPos ipStart)
@@ -129,205 +122,6 @@ sliceImportSection fileLines = first show $ do
& ix 0 %~ T.drop (c1 - 1)
& ix (l2 - l1) %~ T.take c2
--- | Adds an implicit import like @import Prelude@ to a Sourcefile.
-addImplicitImport
- :: (MonadIO m, MonadError IdeError m)
- => FilePath -- ^ The source file read from
- -> P.ModuleName -- ^ The module to import
- -> m [Text]
-addImplicitImport fp mn = do
- (_, pre, imports, post) <- parseImportsFromFile' fp
- let newImportSection = addImplicitImport' imports mn
- pure (pre ++ newImportSection ++ post)
-
-addImplicitImport' :: [Import] -> P.ModuleName -> [Text]
-addImplicitImport' imports mn =
- prettyPrintImportSection (Import mn P.Implicit Nothing : imports)
-
--- | Adds a qualified import like @import Data.Map as Map@ to a source file.
-addQualifiedImport
- :: (MonadIO m, MonadError IdeError m)
- => FilePath
- -- ^ The sourcefile read from
- -> P.ModuleName
- -- ^ The module to import
- -> P.ModuleName
- -- ^ The qualifier under which to import
- -> m [Text]
-addQualifiedImport fp mn qualifier = do
- (_, pre, imports, post) <- parseImportsFromFile' fp
- let newImportSection = addQualifiedImport' imports mn qualifier
- pure (pre ++ newImportSection ++ post)
-
-addQualifiedImport' :: [Import] -> P.ModuleName -> P.ModuleName -> [Text]
-addQualifiedImport' imports mn qualifier =
- prettyPrintImportSection (Import mn P.Implicit (Just qualifier) : imports)
-
--- | Adds an explicit import like @import Prelude (unit)@ to a Sourcefile. If an
--- explicit import already exists for the given module, it adds the identifier
--- to that imports list.
---
--- So @addExplicitImport "/File.purs" "bind" "Prelude"@ with an already existing
--- @import Prelude (bind)@ in the file File.purs returns @["import Prelude
--- (bind, unit)"]@
-addExplicitImport :: (MonadIO m, MonadError IdeError m) =>
- FilePath -> IdeDeclaration -> P.ModuleName -> Maybe P.ModuleName -> m [Text]
-addExplicitImport fp decl moduleName qualifier = do
- (mn, pre, imports, post) <- parseImportsFromFile' fp
- let newImportSection =
- -- TODO: Open an issue when this PR is merged, we should optimise this
- -- so that this case does not write to disc
- if mn == moduleName
- then imports
- else addExplicitImport' decl moduleName qualifier imports
- pure (pre ++ prettyPrintImportSection newImportSection ++ post)
-
-addExplicitImport' :: IdeDeclaration -> P.ModuleName -> Maybe P.ModuleName -> [Import] -> [Import]
-addExplicitImport' decl moduleName qualifier imports =
- let
- isImplicitlyImported =
- any (\case
- Import mn P.Implicit qualifier' -> mn == moduleName && qualifier == qualifier'
- _ -> False) imports
- isNotExplicitlyImportedFromPrim =
- moduleName == C.Prim &&
- not (any (\case
- Import C.Prim (P.Explicit _) Nothing -> True
- _ -> False) imports)
- -- We can't import Modules from other modules
- isModule = has _IdeDeclModule decl
-
- matches (Import mn (P.Explicit _) qualifier') = mn == moduleName && qualifier == qualifier'
- matches _ = False
- freshImport = Import moduleName (P.Explicit [refFromDeclaration decl]) qualifier
- in
- if isImplicitlyImported || isNotExplicitlyImportedFromPrim || isModule
- then imports
- else updateAtFirstOrPrepend matches (insertDeclIntoImport decl) freshImport imports
- where
- refFromDeclaration (IdeDeclTypeClass tc) =
- P.TypeClassRef ideSpan (tc ^. ideTCName)
- refFromDeclaration (IdeDeclDataConstructor dtor) =
- P.TypeRef ideSpan (dtor ^. ideDtorTypeName) Nothing
- refFromDeclaration (IdeDeclType t) =
- P.TypeRef ideSpan (t ^. ideTypeName) (Just [])
- refFromDeclaration (IdeDeclValueOperator op) =
- P.ValueOpRef ideSpan (op ^. ideValueOpName)
- refFromDeclaration (IdeDeclTypeOperator op) =
- P.TypeOpRef ideSpan (op ^. ideTypeOpName)
- refFromDeclaration (IdeDeclKind kn) =
- P.KindRef ideSpan kn
- refFromDeclaration d =
- P.ValueRef ideSpan (P.Ident (identifierFromIdeDeclaration d))
-
- -- | Adds a declaration to an import:
- -- TypeDeclaration "Maybe" + Data.Maybe (maybe) -> Data.Maybe(Maybe, maybe)
- insertDeclIntoImport :: IdeDeclaration -> Import -> Import
- insertDeclIntoImport decl' (Import mn (P.Explicit refs) qual) =
- Import mn (P.Explicit (sortBy P.compDecRef (insertDeclIntoRefs decl' refs))) qual
- insertDeclIntoImport _ is = is
-
- insertDeclIntoRefs :: IdeDeclaration -> [P.DeclarationRef] -> [P.DeclarationRef]
- insertDeclIntoRefs d@(IdeDeclDataConstructor dtor) refs =
- updateAtFirstOrPrepend
- (matchType (dtor ^. ideDtorTypeName))
- (insertDtor (dtor ^. ideDtorName))
- (refFromDeclaration d)
- refs
- insertDeclIntoRefs (IdeDeclType t) refs
- | any matches refs = refs
- where
- matches (P.TypeRef _ typeName _) = _ideTypeName t == typeName
- matches _ = False
- insertDeclIntoRefs dr refs = nubBy ((==) `on` P.prettyPrintRef) (refFromDeclaration dr : refs)
-
- insertDtor _ (P.TypeRef ss tn' _) = P.TypeRef ss tn' Nothing
- insertDtor _ refs = refs
-
- matchType :: P.ProperName 'P.TypeName -> P.DeclarationRef -> Bool
- matchType tn (P.TypeRef _ n _) = tn == n
- matchType _ _ = False
-
-ideSpan :: P.SourceSpan
-ideSpan = P.internalModuleSourceSpan ""
-
-updateAtFirstOrPrepend :: (a -> Bool) -> (a -> a) -> a -> [a] -> [a]
-updateAtFirstOrPrepend p t d l =
- case findIndex p l of
- Nothing -> d : l
- Just i ->
- let (x, a : y) = splitAt i l
- in x ++ [t a] ++ y
-
--- | Looks up the given identifier in the currently loaded modules.
---
--- * Throws an error if the identifier cannot be found.
---
--- * If exactly one match is found, adds an explicit import to the importsection
---
--- * If more than one possible imports are found, reports the possibilities as a
--- list of completions.
-addImportForIdentifier
- :: (Ide m, MonadError IdeError m)
- => FilePath -- ^ The Sourcefile to read from
- -> Text -- ^ The identifier to import
- -> Maybe P.ModuleName -- ^ The optional qualifier under which to import
- -> [Filter] -- ^ Filters to apply before searching for the identifier
- -> m (Either [Match IdeDeclaration] [Text])
-addImportForIdentifier fp ident qual filters = do
- let addPrim = Map.union idePrimDeclarations
- modules <- getAllModules Nothing
- let
- matches =
- getExactMatches ident filters (addPrim modules)
- & map (fmap discardAnn)
- & filter (\(Match (_, d)) -> not (has _IdeDeclModule d))
-
- case matches of
- [] ->
- throwError (NotFound "Couldn't find the given identifier. \
- \Have you loaded the corresponding module?")
-
- -- Only one match was found for the given identifier, so we can insert it
- -- right away
- [Match (m, decl)] ->
- Right <$> addExplicitImport fp decl m qual
-
- -- This case comes up for newtypes and dataconstructors. Because values and
- -- types don't share a namespace we can get multiple matches from the same
- -- module. This also happens for parameterized types, as these generate both
- -- a type aswell as a type synonym.
-
- ms@[Match (m1, d1), Match (m2, d2)] ->
- if m1 /= m2
- -- If the modules don't line up we just ask the user to specify the
- -- module
- then pure (Left ms)
- else case decideRedundantCase d1 d2 <|> decideRedundantCase d2 d1 of
- -- If dataconstructor and type line up we just import the
- -- dataconstructor as that will give us an unnecessary import warning at
- -- worst
- Just decl ->
- Right <$> addExplicitImport fp decl m1 qual
- -- Here we need the user to specify whether he wanted a dataconstructor
- -- or a type
-
- -- TODO: With the new namespace filter, this can actually be a
- -- request for the user to specify which of the two was wanted.
- Nothing ->
- throwError (GeneralError "Undecidable between type and dataconstructor")
-
- -- Multiple matches were found so we need to ask the user to clarify which
- -- module he meant
- xs ->
- pure (Left xs)
- where
- decideRedundantCase d@(IdeDeclDataConstructor dtor) (IdeDeclType t) =
- if dtor ^. ideDtorTypeName == t ^. ideTypeName then Just d else Nothing
- decideRedundantCase IdeDeclType{} ts@IdeDeclTypeSynonym{} =
- Just ts
- decideRedundantCase _ _ = Nothing
-
prettyPrintImport' :: Import -> Text
prettyPrintImport' (Import mn idt qual) =
"import " <> P.prettyPrintImport mn idt qual
@@ -349,24 +143,12 @@ prettyPrintImportSection imports =
Import _ (P.Hiding _) Nothing -> True
_ -> False
-
--- | Writes a list of lines to @Just filepath@ and responds with a @TextResult@,
--- or returns the lines as a @MultilineTextResult@ if @Nothing@ was given as the
--- first argument.
-answerRequest :: (MonadIO m) => Maybe FilePath -> [Text] -> m Success
-answerRequest outfp rs =
- case outfp of
- Nothing -> pure (MultilineTextResult rs)
- Just outfp' -> do
- liftIO (writeUTF8FileT outfp' (T.unlines rs))
- pure (TextResult ("Written to " <> T.pack outfp'))
-
-- | Test and ghci helper
parseImport :: Text -> Maybe Import
parseImport t =
- case P.lex "" t
- >>= P.runTokenParser "" P.parseImportDeclaration' of
- Right (mn, P.Explicit refs, mmn) ->
- Just (Import mn (P.Explicit refs) mmn)
- Right (mn, idt, mmn) -> Just (Import mn idt mmn)
- Left _ -> Nothing
+ case fmap (CST.convertImportDecl "" . snd)
+ $ CST.runTokenParser CST.parseImportDeclP
+ $ CST.lex t of
+ Right (_, mn, idt, mmn) ->
+ Just (Import mn idt mmn)
+ _ -> Nothing
diff --git a/src/Language/PureScript/Ide/Imports/Actions.hs b/src/Language/PureScript/Ide/Imports/Actions.hs
new file mode 100644
index 0000000000..bc79f2184d
--- /dev/null
+++ b/src/Language/PureScript/Ide/Imports/Actions.hs
@@ -0,0 +1,251 @@
+module Language.PureScript.Ide.Imports.Actions
+ ( addImplicitImport
+ , addQualifiedImport
+ , addImportForIdentifier
+ , answerRequest
+
+ -- for tests
+ , addImplicitImport'
+ , addQualifiedImport'
+ , addExplicitImport'
+ )
+where
+
+import Protolude hiding (moduleName)
+
+import Control.Lens ((^.), has)
+import Data.List (nubBy)
+import Data.Map qualified as Map
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.Constants.Prim qualified as C
+import Language.PureScript.Ide.Completion (getExactMatches)
+import Language.PureScript.Ide.Error (IdeError(..))
+import Language.PureScript.Ide.Filter (Filter)
+import Language.PureScript.Ide.Imports (Import(..), parseImportsFromFile', prettyPrintImportSection)
+import Language.PureScript.Ide.State (getAllModules)
+import Language.PureScript.Ide.Prim (idePrimDeclarations)
+import Language.PureScript.Ide.Types (Ide, IdeDeclaration(..), IdeType(..), Match(..), Success(..), _IdeDeclModule, ideDtorName, ideDtorTypeName, ideTCName, ideTypeName, ideTypeOpName, ideValueOpName)
+import Language.PureScript.Ide.Util (discardAnn, identifierFromIdeDeclaration)
+import System.IO.UTF8 (writeUTF8FileT)
+
+-- | Adds an implicit import like @import Prelude@ to a Sourcefile.
+addImplicitImport
+ :: (MonadIO m, MonadError IdeError m)
+ => FilePath -- ^ The source file read from
+ -> P.ModuleName -- ^ The module to import
+ -> m [Text]
+addImplicitImport fp mn = do
+ (_, pre, imports, post) <- parseImportsFromFile' fp
+ let newImportSection = addImplicitImport' imports mn
+ pure $ joinSections (pre, newImportSection, post)
+
+addImplicitImport' :: [Import] -> P.ModuleName -> [Text]
+addImplicitImport' imports mn =
+ prettyPrintImportSection (Import mn P.Implicit Nothing : imports)
+
+-- | Adds a qualified import like @import Data.Map as Map@ to a source file.
+addQualifiedImport
+ :: (MonadIO m, MonadError IdeError m)
+ => FilePath
+ -- ^ The sourcefile read from
+ -> P.ModuleName
+ -- ^ The module to import
+ -> P.ModuleName
+ -- ^ The qualifier under which to import
+ -> m [Text]
+addQualifiedImport fp mn qualifier = do
+ (_, pre, imports, post) <- parseImportsFromFile' fp
+ let newImportSection = addQualifiedImport' imports mn qualifier
+ pure $ joinSections (pre, newImportSection, post)
+
+addQualifiedImport' :: [Import] -> P.ModuleName -> P.ModuleName -> [Text]
+addQualifiedImport' imports mn qualifier =
+ prettyPrintImportSection (Import mn P.Implicit (Just qualifier) : imports)
+
+-- | Adds an explicit import like @import Prelude (unit)@ to a Sourcefile. If an
+-- explicit import already exists for the given module, it adds the identifier
+-- to that imports list.
+--
+-- So @addExplicitImport "/File.purs" "bind" "Prelude"@ with an already existing
+-- @import Prelude (bind)@ in the file File.purs returns @["import Prelude
+-- (bind, unit)"]@
+addExplicitImport :: (MonadIO m, MonadError IdeError m) =>
+ FilePath -> IdeDeclaration -> P.ModuleName -> Maybe P.ModuleName -> m [Text]
+addExplicitImport fp decl moduleName qualifier = do
+ (mn, pre, imports, post) <- parseImportsFromFile' fp
+ let newImportSection =
+ -- TODO: Open an issue when this PR is merged, we should optimise this
+ -- so that this case does not write to disc
+ if mn == moduleName
+ then imports
+ else addExplicitImport' decl moduleName qualifier imports
+ pure $ joinSections (pre, prettyPrintImportSection newImportSection, post)
+
+addExplicitImport' :: IdeDeclaration -> P.ModuleName -> Maybe P.ModuleName -> [Import] -> [Import]
+addExplicitImport' decl moduleName qualifier imports =
+ let
+ isImplicitlyImported =
+ any (\case
+ Import mn P.Implicit qualifier' -> mn == moduleName && qualifier == qualifier'
+ _ -> False) imports
+ isNotExplicitlyImportedFromPrim =
+ moduleName == C.M_Prim &&
+ not (any (\case
+ Import C.M_Prim (P.Explicit _) Nothing -> True
+ _ -> False) imports)
+ -- We can't import Modules from other modules
+ isModule = has _IdeDeclModule decl
+
+ matches (Import mn (P.Explicit _) qualifier') = mn == moduleName && qualifier == qualifier'
+ matches _ = False
+ freshImport = Import moduleName (P.Explicit [refFromDeclaration decl]) qualifier
+ in
+ if isImplicitlyImported || isNotExplicitlyImportedFromPrim || isModule
+ then imports
+ else updateAtFirstOrPrepend matches (insertDeclIntoImport decl) freshImport imports
+ where
+ refFromDeclaration (IdeDeclTypeClass tc) =
+ P.TypeClassRef ideSpan (tc ^. ideTCName)
+ refFromDeclaration (IdeDeclDataConstructor dtor) =
+ P.TypeRef ideSpan (dtor ^. ideDtorTypeName) Nothing
+ refFromDeclaration (IdeDeclType t) =
+ P.TypeRef ideSpan (t ^. ideTypeName) (Just [])
+ refFromDeclaration (IdeDeclValueOperator op) =
+ P.ValueOpRef ideSpan (op ^. ideValueOpName)
+ refFromDeclaration (IdeDeclTypeOperator op) =
+ P.TypeOpRef ideSpan (op ^. ideTypeOpName)
+ refFromDeclaration d =
+ P.ValueRef ideSpan (P.Ident (identifierFromIdeDeclaration d))
+
+ -- Adds a declaration to an import:
+ -- TypeDeclaration "Maybe" + Data.Maybe (maybe) -> Data.Maybe(Maybe, maybe)
+ insertDeclIntoImport :: IdeDeclaration -> Import -> Import
+ insertDeclIntoImport decl' (Import mn (P.Explicit refs) qual) =
+ Import mn (P.Explicit (sort (insertDeclIntoRefs decl' refs))) qual
+ insertDeclIntoImport _ is = is
+
+ insertDeclIntoRefs :: IdeDeclaration -> [P.DeclarationRef] -> [P.DeclarationRef]
+ insertDeclIntoRefs d@(IdeDeclDataConstructor dtor) refs =
+ updateAtFirstOrPrepend
+ (matchType (dtor ^. ideDtorTypeName))
+ (insertDtor (dtor ^. ideDtorName))
+ (refFromDeclaration d)
+ refs
+ insertDeclIntoRefs (IdeDeclType t) refs
+ | any matches refs = refs
+ where
+ matches (P.TypeRef _ typeName _) = _ideTypeName t == typeName
+ matches _ = False
+ insertDeclIntoRefs dr refs = nubBy ((==) `on` P.prettyPrintRef) (refFromDeclaration dr : refs)
+
+ insertDtor _ (P.TypeRef ss tn' _) = P.TypeRef ss tn' Nothing
+ insertDtor _ refs = refs
+
+ matchType :: P.ProperName 'P.TypeName -> P.DeclarationRef -> Bool
+ matchType tn (P.TypeRef _ n _) = tn == n
+ matchType _ _ = False
+
+
+-- | Looks up the given identifier in the currently loaded modules.
+--
+-- * Throws an error if the identifier cannot be found.
+--
+-- * If exactly one match is found, adds an explicit import to the importsection
+--
+-- * If more than one possible imports are found, reports the possibilities as a
+-- list of completions.
+addImportForIdentifier
+ :: (Ide m, MonadError IdeError m)
+ => FilePath -- ^ The Sourcefile to read from
+ -> Text -- ^ The identifier to import
+ -> Maybe P.ModuleName -- ^ The optional qualifier under which to import
+ -> [Filter] -- ^ Filters to apply before searching for the identifier
+ -> m (Either [Match IdeDeclaration] [Text])
+addImportForIdentifier fp ident qual filters = do
+ let addPrim = Map.union idePrimDeclarations
+ modules <- getAllModules Nothing
+ let
+ matches =
+ getExactMatches ident filters (addPrim modules)
+ & map (fmap discardAnn)
+ & filter (\(Match (_, d)) -> not (has _IdeDeclModule d))
+
+ case matches of
+ [] ->
+ throwError (NotFound "Couldn't find the given identifier. \
+ \Have you loaded the corresponding module?")
+
+ -- Only one match was found for the given identifier, so we can insert it
+ -- right away
+ [Match (m, decl)] ->
+ Right <$> addExplicitImport fp decl m qual
+
+ -- This case comes up for newtypes and dataconstructors. Because values and
+ -- types don't share a namespace we can get multiple matches from the same
+ -- module. This also happens for parameterized types, as these generate both
+ -- a type as well as a type synonym.
+
+ ms@[Match (m1, d1), Match (m2, d2)] ->
+ if m1 /= m2
+ -- If the modules don't line up we just ask the user to specify the
+ -- module
+ then pure (Left ms)
+ else case decideRedundantCase d1 d2 <|> decideRedundantCase d2 d1 of
+ -- If dataconstructor and type line up we just import the
+ -- dataconstructor as that will give us an unnecessary import warning at
+ -- worst
+ Just decl ->
+ Right <$> addExplicitImport fp decl m1 qual
+ -- Here we need the user to specify whether they wanted a
+ -- dataconstructor or a type
+ Nothing ->
+ throwError (GeneralError "Undecidable between type and dataconstructor")
+
+ -- Multiple matches were found so we need to ask the user to clarify which
+ -- module they meant
+ xs ->
+ pure (Left xs)
+ where
+ decideRedundantCase d@(IdeDeclDataConstructor dtor) (IdeDeclType t) =
+ if dtor ^. ideDtorTypeName == t ^. ideTypeName then Just d else Nothing
+ decideRedundantCase IdeDeclType{} ts@IdeDeclTypeSynonym{} =
+ Just ts
+ decideRedundantCase _ _ = Nothing
+
+-- | Writes a list of lines to @Just filepath@ and responds with a @TextResult@,
+-- or returns the lines as a @MultilineTextResult@ if @Nothing@ was given as the
+-- first argument.
+answerRequest :: (MonadIO m) => Maybe FilePath -> [Text] -> m Success
+answerRequest outfp rs =
+ case outfp of
+ Nothing -> pure (MultilineTextResult rs)
+ Just outfp' -> do
+ liftIO (writeUTF8FileT outfp' (T.unlines rs))
+ pure (TextResult ("Written to " <> T.pack outfp'))
+
+
+-- | If none of the elements of the list satisfy the given predicate 'predicate', then prepend the default value 'def'
+-- to the given list. Otherwise, update the first element of the list that satisfies 'predicate' with the updating
+-- function 'update'.
+updateAtFirstOrPrepend :: (a -> Bool) -> (a -> a) -> a -> [a] -> [a]
+updateAtFirstOrPrepend predicate update def xs =
+ case break predicate xs of
+ (before, []) -> def : before
+ (before, x : after) -> before ++ [update x] ++ after
+
+
+ideSpan :: P.SourceSpan
+ideSpan = P.internalModuleSourceSpan ""
+
+joinSections :: ([Text], [Text], [Text]) -> [Text]
+joinSections (pre, decls, post) = pre `joinLine` (decls `joinLine` post)
+ where
+ isBlank = T.all (== ' ')
+ joinLine as bs
+ | Just ln1 <- lastMay as
+ , Just ln2 <- head bs
+ , not (isBlank ln1) && not (isBlank ln2) =
+ as ++ [""] ++ bs
+ | otherwise =
+ as ++ bs
diff --git a/src/Language/PureScript/Ide/Logging.hs b/src/Language/PureScript/Ide/Logging.hs
index 33fc3c2bdd..925881b2d0 100644
--- a/src/Language/PureScript/Ide/Logging.hs
+++ b/src/Language/PureScript/Ide/Logging.hs
@@ -7,13 +7,13 @@ module Language.PureScript.Ide.Logging
, labelTimespec
) where
-import Protolude
+import Protolude
-import "monad-logger" Control.Monad.Logger
-import qualified Data.Text as T
-import Language.PureScript.Ide.Types
-import System.Clock
-import Text.Printf
+import "monad-logger" Control.Monad.Logger (LogLevel(..), LoggingT, MonadLogger, filterLogger, logOtherN, runStdoutLoggingT)
+import Data.Text qualified as T
+import Language.PureScript.Ide.Types (IdeLogLevel(..))
+import System.Clock (Clock(..), TimeSpec, diffTimeSpec, getTime, toNanoSecs)
+import Text.Printf (printf)
runLogger :: MonadIO m => IdeLogLevel -> LoggingT m a -> m a
runLogger logLevel' =
@@ -22,7 +22,7 @@ runLogger logLevel' =
LogAll -> True
LogDefault -> not (logLevel == LevelOther "perf" || logLevel == LevelDebug)
LogNone -> False
- LogDebug -> not (logLevel == LevelOther "perf")
+ LogDebug -> logLevel /= LevelOther "perf"
LogPerf -> logLevel == LevelOther "perf")
labelTimespec :: Text -> TimeSpec -> Text
diff --git a/src/Language/PureScript/Ide/Matcher.hs b/src/Language/PureScript/Ide/Matcher.hs
index e5bf21e504..d77516bd32 100644
--- a/src/Language/PureScript/Ide/Matcher.hs
+++ b/src/Language/PureScript/Ide/Matcher.hs
@@ -12,9 +12,6 @@
-- Matchers for psc-ide commands
-----------------------------------------------------------------------------
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-
module Language.PureScript.Ide.Matcher
( Matcher
, runMatcher
@@ -22,15 +19,16 @@ module Language.PureScript.Ide.Matcher
, flexMatcher
) where
-import Protolude
+import Protolude
-import Data.Aeson
-import qualified Data.Text as T
-import qualified Data.Text.Encoding as TE
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import Text.EditDistance
-import Text.Regex.TDFA ((=~))
+import Control.Monad.Fail (fail)
+import Data.Aeson (FromJSON(..), withObject, (.:), (.:?))
+import Data.Text qualified as T
+import Data.Text.Encoding qualified as TE
+import Language.PureScript.Ide.Types (IdeDeclarationAnn, Match)
+import Language.PureScript.Ide.Util (discardAnn, identifierFromIdeDeclaration, unwrapMatch)
+import Text.EditDistance (defaultEditCosts, levenshteinDistance)
+import Text.Regex.TDFA ((=~))
type ScoredMatch a = (Match a, Double)
@@ -49,10 +47,10 @@ instance FromJSON (Matcher IdeDeclarationAnn) where
distanceMatcher
<$> params .: "search"
<*> params .: "maximumDistance"
- Just _ -> mzero
+ Just s -> fail ("Unknown matcher: " <> show s)
Nothing -> return mempty
--- | Matches any occurence of the search string with intersections
+-- | Matches any occurrence of the search string with intersections
--
-- The scoring measures how far the matches span the string where
-- closer is better.
@@ -82,7 +80,7 @@ runMatcher :: Matcher a -> [Match a] -> [Match a]
runMatcher (Matcher m)= appEndo m
sortCompletions :: [ScoredMatch a] -> [ScoredMatch a]
-sortCompletions = sortBy (flip compare `on` snd)
+sortCompletions = sortOn (Down . snd)
flexMatch :: Text -> [Match IdeDeclarationAnn] -> [ScoredMatch IdeDeclarationAnn]
flexMatch = mapMaybe . flexRate
@@ -96,7 +94,7 @@ flexRate p c = do
-- Borrowed from: http://cdewaka.com/2013/06/fuzzy-pattern-matching-in-haskell/
--
-- By string =~ pattern we'll get the start of the match and the length of
--- the matchas a (start, length) tuple if there's a match.
+-- the matches a (start, length) tuple if there's a match.
-- If match fails then it would be (-1,0)
flexScore :: Text -> Text -> Maybe Double
flexScore pat str =
diff --git a/src/Language/PureScript/Ide/Prim.hs b/src/Language/PureScript/Ide/Prim.hs
index c58550c918..398c013755 100644
--- a/src/Language/PureScript/Ide/Prim.hs
+++ b/src/Language/PureScript/Ide/Prim.hs
@@ -1,40 +1,48 @@
module Language.PureScript.Ide.Prim (idePrimDeclarations) where
-import Protolude
-import qualified Data.Map as Map
-import qualified Data.Set as Set
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Constants as C
-import qualified Language.PureScript.Environment as PEnv
-import Language.PureScript.Ide.Types
+import Protolude
+
+import Data.Text qualified as T
+import Data.Map qualified as Map
+import Language.PureScript qualified as P
+import Language.PureScript.Constants.Prim qualified as C
+import Language.PureScript.Environment qualified as PEnv
+import Language.PureScript.Ide.Types (IdeDeclaration(..), IdeDeclarationAnn(..), IdeType(..), IdeTypeClass(..), ModuleMap, emptyAnn)
idePrimDeclarations :: ModuleMap [IdeDeclarationAnn]
idePrimDeclarations = Map.fromList
- [ ( C.Prim
- , mconcat [primTypes, primKinds, primClasses]
+ [ ( C.M_Prim
+ , mconcat [primTypes, primClasses]
)
- , ( C.PrimBoolean
- , mconcat [primBooleanTypes, primBooleanKinds]
+ , ( C.M_Prim_Boolean
+ , mconcat [primBooleanTypes]
)
- , ( C.PrimOrdering
- , mconcat [primOrderingTypes, primOrderingKinds]
+ , ( C.M_Prim_Ordering
+ , mconcat [primOrderingTypes]
)
- , ( C.PrimRow
+ , ( C.M_Prim_Row
, mconcat [primRowTypes, primRowClasses]
)
- , ( C.PrimRowList
- , mconcat [primRowListTypes, primRowListClasses, primRowListKinds]
+ , ( C.M_Prim_RowList
+ , mconcat [primRowListTypes, primRowListClasses]
)
- , ( C.PrimSymbol
+ , ( C.M_Prim_Symbol
, mconcat [primSymbolTypes, primSymbolClasses]
)
- , ( C.PrimTypeError
- , mconcat [primTypeErrorTypes, primTypeErrorClasses, primTypeErrorKinds]
+ , ( C.M_Prim_Int
+ , mconcat [primIntTypes, primIntClasses]
+ )
+ , ( C.M_Prim_TypeError
+ , mconcat [primTypeErrorTypes, primTypeErrorClasses]
)
]
where
- annType tys = foreach (Map.toList tys) $ \(tn, (kind, _)) ->
- IdeDeclarationAnn emptyAnn (IdeDeclType (IdeType (P.disqualify tn) kind []))
+ annType tys = flip mapMaybe (Map.toList tys) $ \(tn, (kind, _)) -> do
+ let name = P.disqualify tn
+ -- We need to remove the ClassName$Dict synonyms, because we
+ -- don't want them to show up in completions
+ guard (isNothing (T.find (== '$') (P.runProperName name)))
+ Just (IdeDeclarationAnn emptyAnn (IdeDeclType (IdeType name kind [])))
annClass cls = foreach (Map.toList cls) $ \(cn, _) ->
-- Dummy kind and instances here, but we primarily care about the name completion
IdeDeclarationAnn emptyAnn (IdeDeclTypeClass (IdeTypeClass (P.disqualify cn) P.kindType []) )
@@ -50,25 +58,12 @@ idePrimDeclarations = Map.fromList
primRowTypes = annType (removeClasses PEnv.primRowTypes PEnv.primRowClasses)
primRowListTypes = annType (removeClasses PEnv.primRowListTypes PEnv.primRowListClasses)
primSymbolTypes = annType (removeClasses PEnv.primSymbolTypes PEnv.primSymbolClasses)
+ primIntTypes = annType (removeClasses PEnv.primIntTypes PEnv.primIntClasses)
primTypeErrorTypes = annType (removeClasses PEnv.primTypeErrorTypes PEnv.primTypeErrorClasses)
primClasses = annClass PEnv.primClasses
primRowClasses = annClass PEnv.primRowClasses
primRowListClasses = annClass PEnv.primRowListClasses
primSymbolClasses = annClass PEnv.primSymbolClasses
+ primIntClasses = annClass PEnv.primIntClasses
primTypeErrorClasses = annClass PEnv.primTypeErrorClasses
-
- primKinds = foreach (Set.toList PEnv.primKinds) $ \kn ->
- IdeDeclarationAnn emptyAnn (IdeDeclKind (P.disqualify kn))
-
- primBooleanKinds = foreach (Set.toList PEnv.primBooleanKinds) $ \kn ->
- IdeDeclarationAnn emptyAnn (IdeDeclKind (P.disqualify kn))
-
- primOrderingKinds = foreach (Set.toList PEnv.primOrderingKinds) $ \kn ->
- IdeDeclarationAnn emptyAnn (IdeDeclKind (P.disqualify kn))
-
- primRowListKinds = foreach (Set.toList PEnv.primRowListKinds) $ \kn ->
- IdeDeclarationAnn emptyAnn (IdeDeclKind (P.disqualify kn))
-
- primTypeErrorKinds = foreach (Set.toList PEnv.primTypeErrorKinds) $ \kn ->
- IdeDeclarationAnn emptyAnn (IdeDeclKind (P.disqualify kn))
diff --git a/src/Language/PureScript/Ide/Rebuild.hs b/src/Language/PureScript/Ide/Rebuild.hs
index 9e38117de3..ebc34339eb 100644
--- a/src/Language/PureScript/Ide/Rebuild.hs
+++ b/src/Language/PureScript/Ide/Rebuild.hs
@@ -1,5 +1,4 @@
-{-# LANGUAGE PackageImports #-}
-{-# LANGUAGE TemplateHaskell #-}
+{-# language PackageImports, TemplateHaskell, BlockArguments #-}
module Language.PureScript.Ide.Rebuild
( rebuildFileSync
@@ -7,20 +6,26 @@ module Language.PureScript.Ide.Rebuild
, rebuildFile
) where
-import Protolude
-
-import "monad-logger" Control.Monad.Logger
-import qualified Data.List as List
-import qualified Data.Map.Lazy as M
-import Data.Maybe (fromJust)
-import qualified Data.Set as S
-import qualified Language.PureScript as P
-import qualified Language.PureScript.CST as CST
-import Language.PureScript.Ide.Error
-import Language.PureScript.Ide.Logging
-import Language.PureScript.Ide.State
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
+import Protolude hiding (moduleName)
+
+import "monad-logger" Control.Monad.Logger (LoggingT, MonadLogger, logDebug)
+import Data.List qualified as List
+import Data.Map.Lazy qualified as M
+import Data.Maybe (fromJust)
+import Data.Set qualified as S
+import Data.Time qualified as Time
+import Data.Text qualified as Text
+import Language.PureScript qualified as P
+import Language.PureScript.Make (ffiCodegen')
+import Language.PureScript.Make.Cache (CacheInfo(..), normaliseForCache)
+import Language.PureScript.CST qualified as CST
+
+import Language.PureScript.Ide.Error (IdeError(..))
+import Language.PureScript.Ide.Logging (labelTimespec, logPerf, runLogger)
+import Language.PureScript.Ide.State (cacheRebuild, getExternFiles, insertExterns, insertModule, populateVolatileState, updateCacheTimestamp)
+import Language.PureScript.Ide.Types (Ide, IdeConfiguration(..), IdeEnvironment(..), ModuleMap, Success(..))
+import Language.PureScript.Ide.Util (ideReadFile)
+import System.Directory (getCurrentDirectory)
-- | Given a filepath performs the following steps:
--
@@ -49,43 +54,85 @@ rebuildFile
-- ^ A runner for the second build with open exports
-> m Success
rebuildFile file actualFile codegenTargets runOpenBuild = do
- (fp, input) <- ideReadFile file
+ (fp, input) <-
+ case List.stripPrefix "data:" file of
+ Just source -> pure ("", Text.pack source)
+ _ -> ideReadFile file
let fp' = fromMaybe fp actualFile
- m <- case CST.parseFromFile fp' input of
+ (pwarnings, m) <- case sequence $ CST.parseFromFile fp' input of
Left parseError ->
- throwError $ RebuildError $ CST.toMultipleErrors fp' parseError
+ throwError $ RebuildError [(fp', input)] $ CST.toMultipleErrors fp' parseError
Right m -> pure m
-
+ let moduleName = P.getModuleName m
-- Externs files must be sorted ahead of time, so that they get applied
-- in the right order (bottom up) to the 'Environment'.
externs <- logPerf (labelTimespec "Sorting externs") (sortExterns m =<< getExternFiles)
-
outputDirectory <- confOutputPath . ideConfiguration <$> ask
-
-- For rebuilding, we want to 'RebuildAlways', but for inferring foreign
-- modules using their file paths, we need to specify the path in the 'Map'.
- let filePathMap = M.singleton (P.getModuleName m) (Left P.RebuildAlways)
- foreigns <- P.inferForeignModules (M.singleton (P.getModuleName m) (Right file))
-
- let makeEnv = MakeActionsEnv outputDirectory filePathMap foreigns False
+ let filePathMap = M.singleton moduleName (Left P.RebuildAlways)
+ let pureRebuild = fp == ""
+ let modulePath = if pureRebuild then fp' else file
+ foreigns <- P.inferForeignModules (M.singleton moduleName (Right modulePath))
+ let makeEnv = P.buildMakeActions outputDirectory filePathMap foreigns False
+ & (if pureRebuild then enableForeignCheck foreigns codegenTargets . shushCodegen else identity)
+ & shushProgress
-- Rebuild the single module using the cached externs
(result, warnings) <- logPerf (labelTimespec "Rebuilding Module") $
- liftIO
- . P.runMake (P.defaultOptions { P.optionsCodegenTargets = codegenTargets })
- . P.rebuildModule (buildMakeActions
- >>= shushProgress $ makeEnv) externs $ m
+ liftIO $ P.runMake (P.defaultOptions { P.optionsCodegenTargets = codegenTargets }) do
+ newExterns <- P.rebuildModule makeEnv externs m
+ unless pureRebuild
+ $ updateCacheDb codegenTargets outputDirectory file actualFile moduleName
+ pure newExterns
case result of
- Left errors -> throwError (RebuildError errors)
+ Left errors ->
+ throwError (RebuildError [(fp', input)] errors)
Right newExterns -> do
- whenM isEditorMode $ do
- insertModule (fromMaybe file actualFile, m)
- insertExterns newExterns
- void populateVolatileState
+ insertModule (fromMaybe file actualFile, m)
+ insertExterns newExterns
+ void populateVolatileState
+ _ <- updateCacheTimestamp
runOpenBuild (rebuildModuleOpen makeEnv externs m)
- pure (RebuildSuccess warnings)
-
-isEditorMode :: Ide m => m Bool
-isEditorMode = asks (confEditorMode . ideConfiguration)
+ pure (RebuildSuccess (CST.toMultipleWarnings fp pwarnings <> warnings))
+
+-- | When adjusting the cache db file after a rebuild we always pick a
+-- non-sensical timestamp ("1858-11-17T00:00:00Z"), and rely on the
+-- content hash to tell whether the module needs rebuilding. This is
+-- because IDE rebuilds may be triggered on temporary files to not
+-- force editors to save the actual source file to get at diagnostics
+dayZero :: Time.UTCTime
+dayZero = Time.UTCTime (Time.ModifiedJulianDay 0) 0
+
+updateCacheDb
+ :: MonadIO m
+ => MonadError P.MultipleErrors m
+ => Set P.CodegenTarget
+ -> FilePath
+ -- ^ The output directory
+ -> FilePath
+ -- ^ The file to read the content hash from
+ -> Maybe FilePath
+ -- ^ The file name to update in the cache
+ -> P.ModuleName
+ -- ^ The module name to update in the cache
+ -> m ()
+updateCacheDb codegenTargets outputDirectory file actualFile moduleName = do
+ cwd <- liftIO getCurrentDirectory
+ contentHash <- P.hashFile file
+ let moduleCacheInfo = (normaliseForCache cwd (fromMaybe file actualFile), (dayZero, contentHash))
+
+ foreignCacheInfo <-
+ if S.member P.JS codegenTargets then do
+ foreigns' <- P.inferForeignModules (M.singleton moduleName (Right (fromMaybe file actualFile)))
+ for (M.lookup moduleName foreigns') \foreignPath -> do
+ foreignHash <- P.hashFile foreignPath
+ pure (normaliseForCache cwd foreignPath, (dayZero, foreignHash))
+ else
+ pure Nothing
+
+ let cacheInfo = M.fromList (moduleCacheInfo : maybeToList foreignCacheInfo)
+ cacheDb <- P.readCacheDb' outputDirectory
+ P.writeCacheDb' outputDirectory (M.insert moduleName (CacheInfo cacheInfo) cacheDb)
rebuildFileAsync
:: forall m. (Ide m, MonadLogger m, MonadError IdeError m)
@@ -109,22 +156,17 @@ rebuildFileSync fp fp' ts = rebuildFile fp fp' ts syncRun
let ll = confLogLevel (ideConfiguration env)
void (liftIO (runLogger ll (runReaderT action env)))
-
-- | Rebuilds a module but opens up its export list first and stores the result
-- inside the rebuild cache
rebuildModuleOpen
:: (Ide m, MonadLogger m)
- => MakeActionsEnv
+ => P.MakeActions P.Make
-> [P.ExternsFile]
-> P.Module
-> m ()
-rebuildModuleOpen makeEnv externs m = void $ runExceptT $ do
- (openResult, _) <- liftIO
- . P.runMake P.defaultOptions
- . P.rebuildModule (buildMakeActions
- >>= shushProgress
- >>= shushCodegen
- $ makeEnv) externs $ openModuleExports m
+rebuildModuleOpen makeEnv externs m = void $ runExceptT do
+ (openResult, _) <- liftIO $ P.runMake P.defaultOptions $
+ P.rebuildModule (shushProgress (shushCodegen makeEnv)) externs (openModuleExports m)
case openResult of
Left _ ->
throwError (GeneralError "Failed when rebuilding with open exports")
@@ -133,36 +175,28 @@ rebuildModuleOpen makeEnv externs m = void $ runExceptT $ do
("Setting Rebuild cache: " <> P.runModuleName (P.efModuleName result))
cacheRebuild result
--- | Parameters we can access while building our @MakeActions@
-data MakeActionsEnv =
- MakeActionsEnv
- { maeOutputDirectory :: FilePath
- , maeFilePathMap :: ModuleMap (Either P.RebuildPolicy FilePath)
- , maeForeignPathMap :: ModuleMap FilePath
- , maePrefixComment :: Bool
- }
-
--- | Builds the default @MakeActions@ from a @MakeActionsEnv@
-buildMakeActions :: MakeActionsEnv -> P.MakeActions P.Make
-buildMakeActions MakeActionsEnv{..} =
- P.buildMakeActions
- maeOutputDirectory
- maeFilePathMap
- maeForeignPathMap
- maePrefixComment
-
-- | Shuts the compiler up about progress messages
-shushProgress :: P.MakeActions P.Make -> MakeActionsEnv -> P.MakeActions P.Make
-shushProgress ma _ =
+shushProgress :: Monad m => P.MakeActions m -> P.MakeActions m
+shushProgress ma =
ma { P.progress = \_ -> pure () }
-- | Stops any kind of codegen
-shushCodegen :: P.MakeActions P.Make -> MakeActionsEnv -> P.MakeActions P.Make
-shushCodegen ma MakeActionsEnv{..} =
+shushCodegen :: Monad m => P.MakeActions m -> P.MakeActions m
+shushCodegen ma =
ma { P.codegen = \_ _ _ -> pure ()
, P.ffiCodegen = \_ -> pure ()
}
+-- | Enables foreign module check without actual codegen.
+enableForeignCheck
+ :: M.Map P.ModuleName FilePath
+ -> S.Set P.CodegenTarget
+ -> P.MakeActions P.Make
+ -> P.MakeActions P.Make
+enableForeignCheck foreigns codegenTargets ma =
+ ma { P.ffiCodegen = ffiCodegen' foreigns codegenTargets Nothing
+ }
+
-- | Returns a topologically sorted list of dependent ExternsFiles for the given
-- module. Throws an error if there is a cyclic dependency within the
-- ExternsFiles
@@ -173,14 +207,14 @@ sortExterns
-> m [P.ExternsFile]
sortExterns m ex = do
sorted' <- runExceptT
- . P.sortModules P.moduleSignature
+ . P.sortModules P.Transitive P.moduleSignature
. (:) m
. map mkShallowModule
. M.elems
. M.delete (P.getModuleName m) $ ex
case sorted' of
Left err ->
- throwError (RebuildError err)
+ throwError (RebuildError [] err)
Right (sorted, graph) -> do
let deps = fromJust (List.lookup (P.getModuleName m) graph)
pure $ mapMaybe getExtern (deps `inOrderOf` map P.getModuleName sorted)
diff --git a/src/Language/PureScript/Ide/Reexports.hs b/src/Language/PureScript/Ide/Reexports.hs
index 71c73d4a1d..3da2a0a82e 100644
--- a/src/Language/PureScript/Ide/Reexports.hs
+++ b/src/Language/PureScript/Ide/Reexports.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
--
-- Module : Language.PureScript.Ide.Reexports
@@ -23,22 +22,21 @@ module Language.PureScript.Ide.Reexports
, resolveReexports'
) where
-import Protolude hiding (moduleName)
+import Protolude hiding (moduleName)
-import qualified Data.Map as Map
-import qualified Language.PureScript as P
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import Lens.Micro.Platform hiding ((&))
+import Control.Lens (set)
+import Data.Map qualified as Map
+import Language.PureScript qualified as P
+import Language.PureScript.Ide.Types
+import Language.PureScript.Ide.Util (discardAnn)
-- | Contains the module with resolved reexports, and possible failures
data ReexportResult a
= ReexportResult
{ reResolved :: a
, reFailed :: [(P.ModuleName, P.DeclarationRef)]
- } deriving (Show, Eq, Functor, Generic)
+ } deriving (Show, Eq, Functor)
-instance NFData a => NFData (ReexportResult a)
-- | Uses the passed formatter to format the resolved module, and adds possible
-- failures
@@ -86,7 +84,7 @@ resolveReexports' modules refs =
Nothing -> Left x
Just decls' ->
let
- setExportedFrom = set (idaAnnotation.annExportedFrom) . Just
+ setExportedFrom = set (idaAnnotation . annExportedFrom) . Just
in
bimap (mn,) (map (setExportedFrom mn)) (resolveRef decls' r)
@@ -104,7 +102,7 @@ resolveRef decls ref = case ref of
Nothing ->
-- If the dataconstructor field inside the TypeRef is Nothing, that
-- means that all data constructors are exported, so we need to look
- -- those up ourselfes
+ -- those up ourselves
findDtors tn
Just dtors -> mapMaybe lookupDtor dtors
P.ValueRef _ i ->
@@ -115,8 +113,6 @@ resolveRef decls ref = case ref of
findWrapped (anyOf (_IdeDeclTypeOperator . ideTypeOpName) (== name))
P.TypeClassRef _ name ->
findWrapped (anyOf (_IdeDeclTypeClass . ideTCName) (== name))
- P.KindRef _ name ->
- findWrapped (anyOf _IdeDeclKind (== name))
_ ->
Left ref
where
diff --git a/src/Language/PureScript/Ide/SourceFile.hs b/src/Language/PureScript/Ide/SourceFile.hs
index bda321206c..ea49fd6a55 100644
--- a/src/Language/PureScript/Ide/SourceFile.hs
+++ b/src/Language/PureScript/Ide/SourceFile.hs
@@ -13,35 +13,26 @@
-----------------------------------------------------------------------------
module Language.PureScript.Ide.SourceFile
- ( parseModule
- , parseModulesFromFiles
+ ( parseModulesFromFiles
, extractAstInformation
-- for tests
, extractSpans
, extractTypeAnnotations
) where
-import Protolude
+import Protolude
-import Control.Parallel.Strategies (withStrategy, parList, rseq)
-import qualified Data.Map as Map
-import qualified Language.PureScript as P
-import qualified Language.PureScript.CST as CST
-import Language.PureScript.Ide.Error
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
+import Control.Parallel.Strategies (withStrategy, parList, rseq)
+import Data.Map qualified as Map
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Ide.Error (IdeError)
+import Language.PureScript.Ide.Types (DefinitionSites, IdeNamespace(..), IdeNamespaced(..), TypeAnnotations)
+import Language.PureScript.Ide.Util (ideReadFile)
-parseModule
- :: (MonadIO m, MonadError IdeError m)
- => FilePath
- -> m (Either FilePath (FilePath, P.Module))
-parseModule path = do
- (absPath, contents) <- ideReadFile path
- pure (parseModule' absPath contents)
-
-parseModule' :: FilePath -> Text -> Either FilePath (FilePath, P.Module)
-parseModule' path file =
- case CST.parseFromFile path file of
+parseModule :: FilePath -> Text -> Either FilePath (FilePath, P.Module)
+parseModule path file =
+ case snd $ CST.parseFromFile path file of
Left _ -> Left path
Right m -> Right (path, m)
@@ -51,7 +42,7 @@ parseModulesFromFiles
-> m [Either FilePath (FilePath, P.Module)]
parseModulesFromFiles paths = do
files <- traverse ideReadFile paths
- pure (inParallel (map (uncurry parseModule') files))
+ pure (inParallel (map (uncurry parseModule) files))
where
inParallel :: [Either e (k, a)] -> [Either e (k, a)]
inParallel = withStrategy (parList rseq)
@@ -87,8 +78,7 @@ extractSpans d = case d of
P.TypeClassDeclaration (ss, _) name _ _ _ members ->
(IdeNamespaced IdeNSType (P.runProperName name), ss) : concatMap extractSpans' members
P.DataDeclaration (ss, _) _ name _ ctors ->
- (IdeNamespaced IdeNSType (P.runProperName name), ss)
- : map (\(cname, _) -> (IdeNamespaced IdeNSValue (P.runProperName cname), ss)) ctors
+ (IdeNamespaced IdeNSType (P.runProperName name), ss) : map dtorSpan ctors
P.FixityDeclaration (ss, _) (Left (P.ValueFixity _ _ opName)) ->
[(IdeNamespaced IdeNSValue (P.runOpName opName), ss)]
P.FixityDeclaration (ss, _) (Right (P.TypeFixity _ _ opName)) ->
@@ -97,10 +87,11 @@ extractSpans d = case d of
[(IdeNamespaced IdeNSValue (P.runIdent ident), ss)]
P.ExternDataDeclaration (ss, _) name _ ->
[(IdeNamespaced IdeNSType (P.runProperName name), ss)]
- P.ExternKindDeclaration (ss, _) name ->
- [(IdeNamespaced IdeNSKind (P.runProperName name), ss)]
_ -> []
where
+ dtorSpan :: P.DataConstructorDeclaration -> (IdeNamespaced, P.SourceSpan)
+ dtorSpan P.DataConstructorDeclaration{ P.dataCtorName = name, P.dataCtorAnn = (ss, _) } =
+ (IdeNamespaced IdeNSValue (P.runProperName name), ss)
-- We need this special case to be able to also get the position info for
-- typeclass member functions. Typedeclarations would clash with value
-- declarations for non-typeclass members, which is why we can't handle them
diff --git a/src/Language/PureScript/Ide/State.hs b/src/Language/PureScript/Ide/State.hs
index d29f44634c..32478d7000 100644
--- a/src/Language/PureScript/Ide/State.hs
+++ b/src/Language/PureScript/Ide/State.hs
@@ -12,10 +12,8 @@
-- Functions to access psc-ide's state
-----------------------------------------------------------------------------
-{-# LANGUAGE PackageImports #-}
-{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE NamedFieldPuns #-}
-{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE PackageImports #-}
+{-# LANGUAGE TypeApplications #-}
module Language.PureScript.Ide.State
( getLoadedModulenames
@@ -31,27 +29,33 @@ module Language.PureScript.Ide.State
, populateVolatileState
, populateVolatileStateSync
, populateVolatileStateSTM
+ , getOutputDirectory
+ , updateCacheTimestamp
-- for tests
, resolveOperatorsForModule
, resolveInstances
, resolveDataConstructorsForModule
) where
-import Protolude hiding (moduleName)
-
-import Control.Arrow
-import Control.Concurrent.STM
-import "monad-logger" Control.Monad.Logger
-import qualified Data.Map.Lazy as Map
-import qualified Language.PureScript as P
-import Language.PureScript.Docs.Convert.Single (convertComments)
-import Language.PureScript.Externs
-import Language.PureScript.Ide.Externs
-import Language.PureScript.Ide.Reexports
-import Language.PureScript.Ide.SourceFile
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import Lens.Micro.Platform hiding ((&))
+import Protolude hiding (moduleName, unzip)
+
+import Control.Concurrent.STM (TVar, modifyTVar, readTVar, readTVarIO, writeTVar)
+import Control.Lens (Ixed(..), preview, view, (%~), (.~), (^.))
+import "monad-logger" Control.Monad.Logger (MonadLogger, logWarnN)
+import Data.IORef (readIORef, writeIORef)
+import Data.Map.Lazy qualified as Map
+import Data.Time.Clock (UTCTime)
+import Data.Zip (unzip)
+import Language.PureScript qualified as P
+import Language.PureScript.Docs.Convert.Single (convertComments)
+import Language.PureScript.Externs (ExternsDeclaration(..), ExternsFile(..))
+import Language.PureScript.Make.Actions (cacheDbFile)
+import Language.PureScript.Ide.Externs (convertExterns)
+import Language.PureScript.Ide.Reexports (ReexportResult(..), prettyPrintReexportResult, reexportHasFailures, resolveReexports)
+import Language.PureScript.Ide.SourceFile (extractAstInformation)
+import Language.PureScript.Ide.Types
+import Language.PureScript.Ide.Util (discardAnn, opNameT, properNameT, runLogger)
+import System.Directory (getModificationTime)
-- | Resets all State inside psc-ide
resetIdeState :: Ide m => m ()
@@ -59,6 +63,31 @@ resetIdeState = do
ideVar <- ideStateVar <$> ask
liftIO (atomically (writeTVar ideVar emptyIdeState))
+getOutputDirectory :: Ide m => m FilePath
+getOutputDirectory = do
+ confOutputPath . ideConfiguration <$> ask
+
+getCacheTimestamp :: Ide m => m (Maybe UTCTime)
+getCacheTimestamp = do
+ x <- ideCacheDbTimestamp <$> ask
+ liftIO (readIORef x)
+
+readCacheTimestamp :: Ide m => m (Maybe UTCTime)
+readCacheTimestamp = do
+ cacheDb <- cacheDbFile <$> getOutputDirectory
+ liftIO (hush <$> try @SomeException (getModificationTime cacheDb))
+
+updateCacheTimestamp :: Ide m => m (Maybe (Maybe UTCTime, Maybe UTCTime))
+updateCacheTimestamp = do
+ old <- getCacheTimestamp
+ new <- readCacheTimestamp
+ if old == new
+ then pure Nothing
+ else do
+ ts <- ideCacheDbTimestamp <$> ask
+ liftIO (writeIORef ts new)
+ pure (Just (old, new))
+
-- | Gets the loaded Modulenames
getLoadedModulenames :: Ide m => m [P.ModuleName]
getLoadedModulenames = Map.keys <$> getExternFiles
@@ -170,15 +199,12 @@ cachedRebuild = vsCachedRebuild <$> getVolatileState
populateVolatileStateSync :: (Ide m, MonadLogger m) => m ()
populateVolatileStateSync = do
st <- ideStateVar <$> ask
- let message duration = "Finished populating volatile state in: " <> displayTimeSpec duration
- results <- logPerf message $ do
- !r <- liftIO (atomically (populateVolatileStateSTM st))
- pure r
+ results <- liftIO (atomically (populateVolatileStateSTM st))
void $ Map.traverseWithKey
(\mn -> logWarnN . prettyPrintReexportResult (const (P.runModuleName mn)))
(Map.filter reexportHasFailures results)
-populateVolatileState :: (Ide m, MonadLogger m) => m (Async ())
+populateVolatileState :: Ide m => m (Async ())
populateVolatileState = do
env <- ask
let ll = confLogLevel (ideConfiguration env)
@@ -196,7 +222,7 @@ populateVolatileStateSTM ref = do
-- through the repopulation
rebuildCache <- vsCachedRebuild <$> getVolatileStateSTM ref
let asts = map (extractAstInformation . fst) modules
- let (moduleDeclarations, reexportRefs) = (map fst &&& map snd) (Map.map convertExterns externs)
+ let (moduleDeclarations, reexportRefs) = unzip (Map.map convertExterns externs)
results =
moduleDeclarations
& map resolveDataConstructorsForModule
@@ -206,7 +232,7 @@ populateVolatileStateSTM ref = do
& resolveOperators
& resolveReexports reexportRefs
setVolatileStateSTM ref (IdeVolatileState (AstData asts) (map reResolved results) rebuildCache)
- pure (force results)
+ pure results
resolveLocations
:: ModuleMap (DefinitionSites P.SourceSpan, TypeAnnotations)
@@ -220,15 +246,16 @@ resolveLocationsForModule
:: (DefinitionSites P.SourceSpan, TypeAnnotations)
-> [IdeDeclarationAnn]
-> [IdeDeclarationAnn]
-resolveLocationsForModule (defs, types) decls =
- map convertDeclaration decls
+resolveLocationsForModule (defs, types) =
+ map convertDeclaration
where
convertDeclaration :: IdeDeclarationAnn -> IdeDeclarationAnn
convertDeclaration (IdeDeclarationAnn ann d) = convertDeclaration'
annotateFunction
annotateValue
+ annotateDataConstructor
annotateType
- annotateKind
+ annotateType -- type classes live in the type namespace
annotateModule
d
where
@@ -236,8 +263,8 @@ resolveLocationsForModule (defs, types) decls =
, _annTypeAnnotation = Map.lookup x types
})
annotateValue x = IdeDeclarationAnn (ann {_annLocation = Map.lookup (IdeNamespaced IdeNSValue x) defs})
+ annotateDataConstructor x = IdeDeclarationAnn (ann {_annLocation = Map.lookup (IdeNamespaced IdeNSValue x) defs})
annotateType x = IdeDeclarationAnn (ann {_annLocation = Map.lookup (IdeNamespaced IdeNSType x) defs})
- annotateKind x = IdeDeclarationAnn (ann {_annLocation = Map.lookup (IdeNamespaced IdeNSKind x) defs})
annotateModule x = IdeDeclarationAnn (ann {_annLocation = Map.lookup (IdeNamespaced IdeNSModule x) defs})
convertDeclaration'
@@ -246,9 +273,10 @@ convertDeclaration'
-> (Text -> IdeDeclaration -> IdeDeclarationAnn)
-> (Text -> IdeDeclaration -> IdeDeclarationAnn)
-> (Text -> IdeDeclaration -> IdeDeclarationAnn)
+ -> (Text -> IdeDeclaration -> IdeDeclarationAnn)
-> IdeDeclaration
-> IdeDeclarationAnn
-convertDeclaration' annotateFunction annotateValue annotateType annotateKind annotateModule d =
+convertDeclaration' annotateFunction annotateValue annotateDataConstructor annotateType annotateClass annotateModule d =
case d of
IdeDeclValue v ->
annotateFunction (v ^. ideValueIdent) d
@@ -257,15 +285,13 @@ convertDeclaration' annotateFunction annotateValue annotateType annotateKind ann
IdeDeclTypeSynonym s ->
annotateType (s ^. ideSynonymName . properNameT) d
IdeDeclDataConstructor dtor ->
- annotateValue (dtor ^. ideDtorName . properNameT) d
+ annotateDataConstructor (dtor ^. ideDtorName . properNameT) d
IdeDeclTypeClass tc ->
- annotateType (tc ^. ideTCName . properNameT) d
+ annotateClass (tc ^. ideTCName . properNameT) d
IdeDeclValueOperator operator ->
annotateValue (operator ^. ideValueOpName . opNameT) d
IdeDeclTypeOperator operator ->
annotateType (operator ^. ideTypeOpName . opNameT) d
- IdeDeclKind i ->
- annotateKind (i ^. properNameT) d
IdeDeclModule mn ->
annotateModule (P.runModuleName mn) d
@@ -281,14 +307,24 @@ resolveDocumentationForModule
:: P.Module
-> [IdeDeclarationAnn]
-> [IdeDeclarationAnn]
-resolveDocumentationForModule (P.Module _ moduleComments moduleName sdecls _) decls = map convertDecl decls
+resolveDocumentationForModule (P.Module _ moduleComments moduleName sdecls _) =
+ map convertDecl
where
+ extractDeclComments :: P.Declaration -> [(P.Name, [P.Comment])]
+ extractDeclComments = \case
+ P.DataDeclaration (_, cs) _ ctorName _ ctors ->
+ (P.TyName ctorName, cs) : map dtorComments ctors
+ P.TypeClassDeclaration (_, cs) tyClassName _ _ _ members ->
+ (P.TyClassName tyClassName, cs) : concatMap extractDeclComments members
+ decl ->
+ maybe [] (\name' -> [(name', snd (P.declSourceAnn decl))]) (name decl)
+
comments :: Map P.Name [P.Comment]
- comments = Map.insert (P.ModName moduleName) moduleComments $ Map.fromListWith (flip (<>)) $ mapMaybe (\d ->
- case name d of
- Just name' -> Just (name', snd $ P.declSourceAnn d)
- _ -> Nothing)
- sdecls
+ comments = Map.insert (P.ModName moduleName) moduleComments $
+ Map.fromListWith (flip (<>)) $ concatMap extractDeclComments sdecls
+
+ dtorComments :: P.DataConstructorDeclaration -> (P.Name, [P.Comment])
+ dtorComments dcd = (P.DctorName (P.dataCtorName dcd), snd (P.dataCtorAnn dcd))
name :: P.Declaration -> Maybe P.Name
name (P.TypeDeclaration d) = Just $ P.IdentName $ P.tydeclIdent d
@@ -299,8 +335,9 @@ resolveDocumentationForModule (P.Module _ moduleComments moduleName sdecls _) de
convertDeclaration'
(annotateValue . P.IdentName)
(annotateValue . P.IdentName . P.Ident)
+ (annotateValue . P.DctorName . P.ProperName)
(annotateValue . P.TyName . P.ProperName)
- (annotateValue . P.KiName . P.ProperName)
+ (annotateValue . P.TyClassName . P.ProperName)
(annotateValue . P.ModName . P.moduleNameFromString)
d
where
@@ -320,7 +357,7 @@ resolveInstances externs declarations =
where
extractInstances mn P.EDInstance{..} =
case edInstanceClassName of
- P.Qualified (Just classModule) className ->
+ P.Qualified (P.ByModuleName classModule) className ->
Just (IdeInstance mn
edInstanceName
edInstanceTypes
@@ -361,18 +398,17 @@ resolveOperatorsForModule modules = map (idaDeclaration %~ resolveOperator)
getDeclarations :: P.ModuleName -> [IdeDeclaration]
getDeclarations moduleName =
Map.lookup moduleName modules
- & fromMaybe []
- & map discardAnn
+ & foldMap (map discardAnn)
resolveOperator (IdeDeclValueOperator op)
- | (P.Qualified (Just mn) (Left ident)) <- op ^. ideValueOpAlias =
+ | (P.Qualified (P.ByModuleName mn) (Left ident)) <- op ^. ideValueOpAlias =
let t = getDeclarations mn
& mapMaybe (preview _IdeDeclValue)
& filter (anyOf ideValueIdent (== ident))
& map (view ideValueType)
& listToMaybe
in IdeDeclValueOperator (op & ideValueOpType .~ t)
- | (P.Qualified (Just mn) (Right dtor)) <- op ^. ideValueOpAlias =
+ | (P.Qualified (P.ByModuleName mn) (Right dtor)) <- op ^. ideValueOpAlias =
let t = getDeclarations mn
& mapMaybe (preview _IdeDeclDataConstructor)
& filter (anyOf ideDtorName (== dtor))
@@ -380,7 +416,7 @@ resolveOperatorsForModule modules = map (idaDeclaration %~ resolveOperator)
& listToMaybe
in IdeDeclValueOperator (op & ideValueOpType .~ t)
resolveOperator (IdeDeclTypeOperator op)
- | P.Qualified (Just mn) properName <- op ^. ideTypeOpAlias =
+ | P.Qualified (P.ByModuleName mn) properName <- op ^. ideTypeOpAlias =
let k = getDeclarations mn
& mapMaybe (preview _IdeDeclType)
& filter (anyOf ideTypeName (== properName))
@@ -402,12 +438,12 @@ resolveDataConstructorsForModule decls =
resolveDataConstructors :: IdeDeclaration -> IdeDeclaration
resolveDataConstructors decl = case decl of
IdeDeclType ty ->
- IdeDeclType (ty & ideTypeDtors .~ fromMaybe [] (Map.lookup (ty^.ideTypeName) dtors))
+ IdeDeclType (ty & ideTypeDtors .~ fromMaybe [] (Map.lookup (ty ^. ideTypeName) dtors))
_ ->
decl
dtors =
decls
- & mapMaybe (preview (idaDeclaration._IdeDeclDataConstructor))
+ & mapMaybe (preview (idaDeclaration . _IdeDeclDataConstructor))
& foldr (\(IdeDataConstructor name typeName type') ->
Map.insertWith (<>) typeName [(name, type')]) Map.empty
diff --git a/src/Language/PureScript/Ide/Types.hs b/src/Language/PureScript/Ide/Types.hs
index 82cfed9b03..41532a3c51 100644
--- a/src/Language/PureScript/Ide/Types.hs
+++ b/src/Language/PureScript/Ide/Types.hs
@@ -1,32 +1,23 @@
------------------------------------------------------------------------------
---
--- Module : Language.PureScript.Ide.Types
--- Description : Type definitions for psc-ide
--- Copyright : Christoph Hegemann 2016
--- License : MIT (http://opensource.org/licenses/MIT)
---
--- Maintainer : Christoph Hegemann
--- Stability : experimental
---
-- |
-- Type definitions for psc-ide
------------------------------------------------------------------------------
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE DeriveAnyClass #-}
-{-# LANGUAGE DeriveFoldable #-}
-{-# LANGUAGE TemplateHaskell #-}
+{-# language DeriveAnyClass, NoGeneralizedNewtypeDeriving, TemplateHaskell #-}
module Language.PureScript.Ide.Types where
-import Protolude hiding (moduleName)
+import Protolude hiding (moduleName)
-import Control.Concurrent.STM
-import Data.Aeson
-import qualified Data.Map.Lazy as M
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Errors.JSON as P
-import Lens.Micro.Platform hiding ((.=))
+import Control.Concurrent.STM (TVar)
+import Control.Lens (Getting, Traversal', makeLenses)
+import Control.Monad.Fail (fail)
+import Data.Aeson (ToJSON, FromJSON, (.=))
+import Data.Aeson qualified as Aeson
+import Data.IORef (IORef)
+import Data.Time.Clock (UTCTime)
+import Data.Map.Lazy qualified as M
+import Language.PureScript qualified as P
+import Language.PureScript.Errors.JSON qualified as P
+import Language.PureScript.Ide.Filter.Declaration (DeclarationType(..))
type ModuleIdent = Text
type ModuleMap a = Map P.ModuleName a
@@ -40,60 +31,59 @@ data IdeDeclaration
| IdeDeclValueOperator IdeValueOperator
| IdeDeclTypeOperator IdeTypeOperator
| IdeDeclModule P.ModuleName
- | IdeDeclKind (P.ProperName 'P.KindName)
- deriving (Show, Eq, Ord, Generic, NFData)
+ deriving (Show, Eq, Ord)
data IdeValue = IdeValue
{ _ideValueIdent :: P.Ident
- , _ideValueType :: P.SourceType
- } deriving (Show, Eq, Ord, Generic, NFData)
+ , _ideValueType :: P.SourceType
+ } deriving (Show, Eq, Ord)
data IdeType = IdeType
{ _ideTypeName :: P.ProperName 'P.TypeName
- , _ideTypeKind :: P.SourceKind
+ , _ideTypeKind :: P.SourceType
, _ideTypeDtors :: [(P.ProperName 'P.ConstructorName, P.SourceType)]
- } deriving (Show, Eq, Ord, Generic, NFData)
+ } deriving (Show, Eq, Ord)
data IdeTypeSynonym = IdeTypeSynonym
{ _ideSynonymName :: P.ProperName 'P.TypeName
, _ideSynonymType :: P.SourceType
- , _ideSynonymKind :: P.SourceKind
- } deriving (Show, Eq, Ord, Generic, NFData)
+ , _ideSynonymKind :: P.SourceType
+ } deriving (Show, Eq, Ord)
data IdeDataConstructor = IdeDataConstructor
- { _ideDtorName :: P.ProperName 'P.ConstructorName
+ { _ideDtorName :: P.ProperName 'P.ConstructorName
, _ideDtorTypeName :: P.ProperName 'P.TypeName
- , _ideDtorType :: P.SourceType
- } deriving (Show, Eq, Ord, Generic, NFData)
+ , _ideDtorType :: P.SourceType
+ } deriving (Show, Eq, Ord)
data IdeTypeClass = IdeTypeClass
{ _ideTCName :: P.ProperName 'P.ClassName
- , _ideTCKind :: P.SourceKind
+ , _ideTCKind :: P.SourceType
, _ideTCInstances :: [IdeInstance]
- } deriving (Show, Eq, Ord, Generic, NFData)
+ } deriving (Show, Eq, Ord)
data IdeInstance = IdeInstance
- { _ideInstanceModule :: P.ModuleName
- , _ideInstanceName :: P.Ident
- , _ideInstanceTypes :: [P.SourceType]
+ { _ideInstanceModule :: P.ModuleName
+ , _ideInstanceName :: P.Ident
+ , _ideInstanceTypes :: [P.SourceType]
, _ideInstanceConstraints :: Maybe [P.SourceConstraint]
- } deriving (Show, Eq, Ord, Generic, NFData)
+ } deriving (Show, Eq, Ord)
data IdeValueOperator = IdeValueOperator
- { _ideValueOpName :: P.OpName 'P.ValueOpName
- , _ideValueOpAlias :: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName))
- , _ideValueOpPrecedence :: P.Precedence
+ { _ideValueOpName :: P.OpName 'P.ValueOpName
+ , _ideValueOpAlias :: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName))
+ , _ideValueOpPrecedence :: P.Precedence
, _ideValueOpAssociativity :: P.Associativity
- , _ideValueOpType :: Maybe P.SourceType
- } deriving (Show, Eq, Ord, Generic, NFData)
+ , _ideValueOpType :: Maybe P.SourceType
+ } deriving (Show, Eq, Ord)
data IdeTypeOperator = IdeTypeOperator
- { _ideTypeOpName :: P.OpName 'P.TypeOpName
- , _ideTypeOpAlias :: P.Qualified (P.ProperName 'P.TypeName)
- , _ideTypeOpPrecedence :: P.Precedence
+ { _ideTypeOpName :: P.OpName 'P.TypeOpName
+ , _ideTypeOpAlias :: P.Qualified (P.ProperName 'P.TypeName)
+ , _ideTypeOpPrecedence :: P.Precedence
, _ideTypeOpAssociativity :: P.Associativity
- , _ideTypeOpKind :: Maybe P.SourceKind
- } deriving (Show, Eq, Ord, Generic, NFData)
+ , _ideTypeOpKind :: Maybe P.SourceType
+ } deriving (Show, Eq, Ord)
_IdeDeclValue :: Traversal' IdeDeclaration IdeValue
_IdeDeclValue f (IdeDeclValue x) = map IdeDeclValue (f x)
@@ -123,10 +113,6 @@ _IdeDeclTypeOperator :: Traversal' IdeDeclaration IdeTypeOperator
_IdeDeclTypeOperator f (IdeDeclTypeOperator x) = map IdeDeclTypeOperator (f x)
_IdeDeclTypeOperator _ x = pure x
-_IdeDeclKind :: Traversal' IdeDeclaration (P.ProperName 'P.KindName)
-_IdeDeclKind f (IdeDeclKind x) = map IdeDeclKind (f x)
-_IdeDeclKind _ x = pure x
-
_IdeDeclModule :: Traversal' IdeDeclaration P.ModuleName
_IdeDeclModule f (IdeDeclModule x) = map IdeDeclModule (f x)
_IdeDeclModule _ x = pure x
@@ -139,22 +125,21 @@ makeLenses ''IdeType
makeLenses ''IdeTypeSynonym
makeLenses ''IdeDataConstructor
makeLenses ''IdeTypeClass
-makeLenses ''IdeInstance
makeLenses ''IdeValueOperator
makeLenses ''IdeTypeOperator
data IdeDeclarationAnn = IdeDeclarationAnn
- { _idaAnnotation :: Annotation
+ { _idaAnnotation :: Annotation
, _idaDeclaration :: IdeDeclaration
- } deriving (Show, Eq, Ord, Generic, NFData)
+ } deriving (Show, Eq, Ord)
data Annotation
= Annotation
- { _annLocation :: Maybe P.SourceSpan
- , _annExportedFrom :: Maybe P.ModuleName
+ { _annLocation :: Maybe P.SourceSpan
+ , _annExportedFrom :: Maybe P.ModuleName
, _annTypeAnnotation :: Maybe P.SourceType
- , _annDocumentation :: Maybe Text
- } deriving (Show, Eq, Ord, Generic, NFData)
+ , _annDocumentation :: Maybe Text
+ } deriving (Show, Eq, Ord)
makeLenses ''Annotation
makeLenses ''IdeDeclarationAnn
@@ -167,7 +152,7 @@ type TypeAnnotations = Map P.Ident P.SourceType
newtype AstData a = AstData (ModuleMap (DefinitionSites a, TypeAnnotations))
-- ^ SourceSpans for the definition sites of values and types as well as type
-- annotations found in a module
- deriving (Show, Eq, Ord, Generic, NFData, Functor, Foldable)
+ deriving (Show, Eq, Ord, Functor, Foldable)
data IdeLogLevel = LogDebug | LogPerf | LogAll | LogDefault | LogNone
deriving (Show, Eq)
@@ -175,21 +160,23 @@ data IdeLogLevel = LogDebug | LogPerf | LogAll | LogDefault | LogNone
data IdeConfiguration =
IdeConfiguration
{ confOutputPath :: FilePath
- , confLogLevel :: IdeLogLevel
- , confGlobs :: [FilePath]
- , confEditorMode :: Bool
+ , confLogLevel :: IdeLogLevel
+ , confGlobs :: [FilePath]
+ , confGlobsFromFile :: Maybe FilePath
+ , confGlobsExclude :: [FilePath]
}
data IdeEnvironment =
IdeEnvironment
- { ideStateVar :: TVar IdeState
+ { ideStateVar :: TVar IdeState
, ideConfiguration :: IdeConfiguration
+ , ideCacheDbTimestamp :: IORef (Maybe UTCTime)
}
type Ide m = (MonadIO m, MonadReader IdeEnvironment m)
data IdeState = IdeState
- { ideFileState :: IdeFileState
+ { ideFileState :: IdeFileState
, ideVolatileState :: IdeVolatileState
} deriving (Show)
@@ -221,8 +208,8 @@ data IdeFileState = IdeFileState
-- with open imports which is used to provide completions for module private
-- declarations
data IdeVolatileState = IdeVolatileState
- { vsAstData :: AstData P.SourceSpan
- , vsDeclarations :: ModuleMap [IdeDeclarationAnn]
+ { vsAstData :: AstData P.SourceSpan
+ , vsDeclarations :: ModuleMap [IdeDeclarationAnn]
, vsCachedRebuild :: Maybe (P.ModuleName, P.ExternsFile)
} deriving (Show)
@@ -231,35 +218,48 @@ newtype Match a = Match (P.ModuleName, a)
-- | A completion as it gets sent to the editors
data Completion = Completion
- { complModule :: Text
- , complIdentifier :: Text
- , complType :: Text
- , complExpandedType :: Text
- , complLocation :: Maybe P.SourceSpan
+ { complModule :: Text
+ , complIdentifier :: Text
+ , complType :: Text
+ , complExpandedType :: Text
+ , complLocation :: Maybe P.SourceSpan
, complDocumentation :: Maybe Text
- , complExportedFrom :: [P.ModuleName]
+ , complExportedFrom :: [P.ModuleName]
+ , complDeclarationType :: Maybe DeclarationType
} deriving (Show, Eq, Ord)
instance ToJSON Completion where
- toJSON (Completion {..}) =
- object [ "module" .= complModule
- , "identifier" .= complIdentifier
- , "type" .= complType
- , "expandedType" .= complExpandedType
- , "definedAt" .= complLocation
- , "documentation" .= complDocumentation
- , "exportedFrom" .= map P.runModuleName complExportedFrom
- ]
+ toJSON Completion {..} =
+ Aeson.object
+ [ "module" .= complModule
+ , "identifier" .= complIdentifier
+ , "type" .= complType
+ , "expandedType" .= complExpandedType
+ , "definedAt" .= complLocation
+ , "documentation" .= complDocumentation
+ , "exportedFrom" .= map P.runModuleName complExportedFrom
+ , "declarationType" .= complDeclarationType
+ ]
identifierFromDeclarationRef :: P.DeclarationRef -> Text
-identifierFromDeclarationRef (P.TypeRef _ name _) = P.runProperName name
-identifierFromDeclarationRef (P.ValueRef _ ident) = P.runIdent ident
-identifierFromDeclarationRef (P.TypeClassRef _ name) = P.runProperName name
-identifierFromDeclarationRef (P.KindRef _ name) = P.runProperName name
-identifierFromDeclarationRef (P.ValueOpRef _ op) = P.showOp op
-identifierFromDeclarationRef (P.TypeOpRef _ op) = P.showOp op
-identifierFromDeclarationRef _ = ""
-
+identifierFromDeclarationRef = \case
+ P.TypeRef _ name _ -> P.runProperName name
+ P.ValueRef _ ident -> P.runIdent ident
+ P.TypeClassRef _ name -> P.runProperName name
+ P.ValueOpRef _ op -> P.showOp op
+ P.TypeOpRef _ op -> P.showOp op
+ _ -> ""
+
+declarationType :: IdeDeclaration -> DeclarationType
+declarationType decl = case decl of
+ IdeDeclValue _ -> Value
+ IdeDeclType _ -> Type
+ IdeDeclTypeSynonym _ -> Synonym
+ IdeDeclDataConstructor _ -> DataConstructor
+ IdeDeclTypeClass _ -> TypeClass
+ IdeDeclValueOperator _ -> ValueOperator
+ IdeDeclTypeOperator _ -> TypeOperator
+ IdeDeclModule _ -> Module
data Success =
CompletionResult [Completion]
| TextResult Text
@@ -270,51 +270,58 @@ data Success =
| RebuildSuccess P.MultipleErrors
deriving (Show)
-encodeSuccess :: (ToJSON a) => a -> Value
+encodeSuccess :: ToJSON a => a -> Aeson.Value
encodeSuccess res =
- object ["resultType" .= ("success" :: Text), "result" .= res]
+ Aeson.object ["resultType" .= ("success" :: Text), "result" .= res]
instance ToJSON Success where
- toJSON (CompletionResult cs) = encodeSuccess cs
- toJSON (TextResult t) = encodeSuccess t
- toJSON (UsagesResult ssp) = encodeSuccess ssp
- toJSON (MultilineTextResult ts) = encodeSuccess ts
- toJSON (ImportList (moduleName, imports)) = object [ "resultType" .= ("success" :: Text)
- , "result" .= object [ "imports" .= map encodeImport imports
- , "moduleName" .= P.runModuleName moduleName]]
- toJSON (ModuleList modules) = encodeSuccess modules
- toJSON (RebuildSuccess warnings) = encodeSuccess (P.toJSONErrors False P.Warning warnings)
-
-encodeImport :: (P.ModuleName, P.ImportDeclarationType, Maybe P.ModuleName) -> Value
+ toJSON = \case
+ CompletionResult cs -> encodeSuccess cs
+ TextResult t -> encodeSuccess t
+ UsagesResult ssp -> encodeSuccess ssp
+ MultilineTextResult ts -> encodeSuccess ts
+ ImportList (moduleName, imports) ->
+ Aeson.object
+ [ "resultType" .= ("success" :: Text)
+ , "result" .= Aeson.object
+ [ "imports" .= map encodeImport imports
+ , "moduleName" .= P.runModuleName moduleName
+ ]
+ ]
+ ModuleList modules -> encodeSuccess modules
+ RebuildSuccess warnings -> encodeSuccess (P.toJSONErrors False P.Warning [] warnings)
+
+encodeImport :: (P.ModuleName, P.ImportDeclarationType, Maybe P.ModuleName) -> Aeson.Value
encodeImport (P.runModuleName -> mn, importType, map P.runModuleName -> qualifier) = case importType of
P.Implicit ->
- object $ [ "module" .= mn
- , "importType" .= ("implicit" :: Text)
- ] ++ map (\x -> "qualifier" .= x) (maybeToList qualifier)
+ Aeson.object $
+ [ "module" .= mn
+ , "importType" .= ("implicit" :: Text)
+ ] ++ map ("qualifier" .=) (maybeToList qualifier)
P.Explicit refs ->
- object $ [ "module" .= mn
- , "importType" .= ("explicit" :: Text)
- , "identifiers" .= (identifierFromDeclarationRef <$> refs)
- ] ++ map (\x -> "qualifier" .= x) (maybeToList qualifier)
+ Aeson.object $
+ [ "module" .= mn
+ , "importType" .= ("explicit" :: Text)
+ , "identifiers" .= (identifierFromDeclarationRef <$> refs)
+ ] ++ map ("qualifier" .=) (maybeToList qualifier)
P.Hiding refs ->
- object $ [ "module" .= mn
- , "importType" .= ("hiding" :: Text)
- , "identifiers" .= (identifierFromDeclarationRef <$> refs)
- ] ++ map (\x -> "qualifier" .= x) (maybeToList qualifier)
+ Aeson.object $
+ [ "module" .= mn
+ , "importType" .= ("hiding" :: Text)
+ , "identifiers" .= (identifierFromDeclarationRef <$> refs)
+ ] ++ map ("qualifier" .=) (maybeToList qualifier)
-- | Denotes the different namespaces a name in PureScript can reside in.
-data IdeNamespace = IdeNSValue | IdeNSType | IdeNSKind | IdeNSModule
- deriving (Show, Eq, Ord, Generic, NFData)
+data IdeNamespace = IdeNSValue | IdeNSType | IdeNSModule
+ deriving (Show, Eq, Ord)
instance FromJSON IdeNamespace where
- parseJSON (String s) = case s of
+ parseJSON = Aeson.withText "Namespace" $ \case
"value" -> pure IdeNSValue
"type" -> pure IdeNSType
- "kind" -> pure IdeNSKind
"module" -> pure IdeNSModule
- _ -> mzero
- parseJSON _ = mzero
+ s -> fail ("Unknown namespace: " <> show s)
-- | A name tagged with a namespace
data IdeNamespaced = IdeNamespaced IdeNamespace Text
- deriving (Show, Eq, Ord, Generic, NFData)
+ deriving (Show, Eq, Ord)
diff --git a/src/Language/PureScript/Ide/Usage.hs b/src/Language/PureScript/Ide/Usage.hs
index 8db7f36f5b..3e773efe5a 100644
--- a/src/Language/PureScript/Ide/Usage.hs
+++ b/src/Language/PureScript/Ide/Usage.hs
@@ -6,15 +6,15 @@ module Language.PureScript.Ide.Usage
, findUsages
) where
-import Protolude hiding (moduleName)
+import Protolude hiding (moduleName)
-import qualified Data.Map as Map
-import qualified Data.Set as Set
-import qualified Language.PureScript as P
-import Language.PureScript.Ide.State (getAllModules, getFileState)
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import Lens.Micro.Platform (preview)
+import Control.Lens (preview)
+import Data.Map qualified as Map
+import Data.Set qualified as Set
+import Language.PureScript qualified as P
+import Language.PureScript.Ide.State (getAllModules, getFileState)
+import Language.PureScript.Ide.Types
+import Language.PureScript.Ide.Util (identifierFromIdeDeclaration, namespaceForDeclaration)
-- |
-- How we find usages, given an IdeDeclaration and the module it was defined in:
@@ -25,7 +25,7 @@ import Lens.Micro.Platform (preview)
-- module.
-- 3. Apply the collected search specifications and collect the results
findUsages
- :: (MonadIO m, Ide m)
+ :: Ide m
=> IdeDeclaration
-> P.ModuleName
-> m (ModuleMap (NonEmpty P.SourceSpan))
@@ -67,7 +67,7 @@ directDependants declaration modules mn = Map.mapMaybe (nonEmpty . go) modules
go = foldMap isImporting . P.getModuleDeclarations
isImporting d = case d of
- P.ImportDeclaration _ mn' it qual | mn == mn' -> P.Qualified qual <$> case it of
+ P.ImportDeclaration _ mn' it qual | mn == mn' -> P.Qualified (P.byMaybeModuleName qual) <$> case it of
P.Implicit -> pure declaration
P.Explicit refs
| any (declaration `matchesRef`) refs -> pure declaration
@@ -109,9 +109,6 @@ matchesRef declaration ref = case declaration of
IdeDeclTypeOperator typeOperator -> case ref of
P.TypeOpRef _ opName -> opName == _ideTypeOpName typeOperator
_ -> False
- IdeDeclKind kind -> case ref of
- P.KindRef _ kindName -> kindName == kind
- _ -> False
IdeDeclModule m -> case ref of
P.ModuleRef _ mn -> m == mn
_ -> False
@@ -123,7 +120,7 @@ eligibleModules
-> ModuleMap (NonEmpty Search)
eligibleModules query@(moduleName, declaration) decls modules =
let
- searchDefiningModule = P.Qualified Nothing declaration :| []
+ searchDefiningModule = P.Qualified P.ByNullSourcePos declaration :| []
in
Map.insert moduleName searchDefiningModule $
foldMap (directDependants declaration modules) (moduleName :| findReexportingModules query decls)
diff --git a/src/Language/PureScript/Ide/Util.hs b/src/Language/PureScript/Ide/Util.hs
index d25a8708d7..854391dcae 100644
--- a/src/Language/PureScript/Ide/Util.hs
+++ b/src/Language/PureScript/Ide/Util.hs
@@ -29,19 +29,20 @@ module Language.PureScript.Ide.Util
, module Language.PureScript.Ide.Logging
) where
-import Protolude hiding (decodeUtf8,
+import Protolude hiding (decodeUtf8,
encodeUtf8, to)
-import Data.Aeson
-import qualified Data.Text.Lazy as TL
-import Data.Text.Lazy.Encoding as TLE
-import qualified Language.PureScript as P
-import Language.PureScript.Ide.Error (IdeError(..))
-import Language.PureScript.Ide.Logging
-import Language.PureScript.Ide.Types
-import Lens.Micro.Platform hiding ((&))
-import System.IO.UTF8 (readUTF8FileT)
-import System.Directory (makeAbsolute)
+import Control.Lens (Getting, to, (^.))
+import Data.Aeson (FromJSON, ToJSON, eitherDecode, encode)
+import Data.Text qualified as T
+import Data.Text.Lazy qualified as TL
+import Data.Text.Lazy.Encoding as TLE
+import Language.PureScript qualified as P
+import Language.PureScript.Ide.Error (IdeError(..))
+import Language.PureScript.Ide.Logging
+import Language.PureScript.Ide.Types (IdeDeclaration(..), IdeDeclarationAnn(..), IdeNamespace(..), Match(..), emptyAnn, ideDtorName, ideSynonymName, ideTCName, ideTypeName, ideTypeOpName, ideValueIdent, ideValueOpName)
+import System.IO.UTF8 (readUTF8FileT)
+import System.Directory (makeAbsolute)
identifierFromIdeDeclaration :: IdeDeclaration -> Text
identifierFromIdeDeclaration d = case d of
@@ -52,7 +53,6 @@ identifierFromIdeDeclaration d = case d of
IdeDeclTypeClass tc -> tc ^. ideTCName . properNameT
IdeDeclValueOperator op -> op ^. ideValueOpName & P.runOpName
IdeDeclTypeOperator op -> op ^. ideTypeOpName & P.runOpName
- IdeDeclKind name -> P.runProperName name
IdeDeclModule name -> P.runModuleName name
namespaceForDeclaration :: IdeDeclaration -> IdeNamespace
@@ -64,7 +64,6 @@ namespaceForDeclaration d = case d of
IdeDeclTypeClass _ -> IdeNSType
IdeDeclValueOperator _ -> IdeNSValue
IdeDeclTypeOperator _ -> IdeNSType
- IdeDeclKind _ -> IdeNSKind
IdeDeclModule _ -> IdeNSModule
discardAnn :: IdeDeclarationAnn -> IdeDeclaration
@@ -78,19 +77,19 @@ unwrapMatch (Match (_, ed)) = ed
valueOperatorAliasT
:: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName)) -> Text
-valueOperatorAliasT i =
- P.showQualified (either P.runIdent P.runProperName) i
+valueOperatorAliasT =
+ P.showQualified $ either P.runIdent P.runProperName
typeOperatorAliasT
:: P.Qualified (P.ProperName 'P.TypeName) -> Text
-typeOperatorAliasT i =
- P.showQualified P.runProperName i
+typeOperatorAliasT =
+ P.showQualified P.runProperName
encodeT :: (ToJSON a) => a -> Text
encodeT = TL.toStrict . TLE.decodeUtf8 . encode
-decodeT :: (FromJSON a) => Text -> Maybe a
-decodeT = decode . TLE.encodeUtf8 . TL.fromStrict
+decodeT :: (FromJSON a) => Text -> Either Text a
+decodeT = first T.pack . eitherDecode . TLE.encodeUtf8 . TL.fromStrict
properNameT :: Getting r (P.ProperName a) Text
properNameT = to P.runProperName
diff --git a/src/Language/PureScript/Ide/Watcher.hs b/src/Language/PureScript/Ide/Watcher.hs
deleted file mode 100644
index 9d42ef9e38..0000000000
--- a/src/Language/PureScript/Ide/Watcher.hs
+++ /dev/null
@@ -1,56 +0,0 @@
-{-# LANGUAGE PackageImports #-}
------------------------------------------------------------------------------
---
--- Module : Language.PureScript.Ide.Watcher
--- Description : File watcher for externs files
--- Copyright : Christoph Hegemann 2016
--- License : MIT (http://opensource.org/licenses/MIT)
---
--- Maintainer : Christoph Hegemann
--- Stability : experimental
---
--- |
--- File watcher for externs files
------------------------------------------------------------------------------
-
-module Language.PureScript.Ide.Watcher
- ( watcher
- ) where
-
-import Protolude
-
-import Control.Concurrent.STM
-import "monad-logger" Control.Monad.Logger
-import Language.PureScript.Ide.Externs
-import Language.PureScript.Ide.State
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import System.FSNotify
-import System.FilePath
-
--- | Reloads an ExternsFile from Disc. If the Event indicates the ExternsFile
--- was deleted we don't do anything.
-reloadFile :: IdeLogLevel -> TVar IdeState -> Event -> IO ()
-reloadFile _ _ Removed{} = pure ()
-reloadFile logLevel ref ev = runLogger logLevel $ do
- let fp = eventPath ev
- ef' <- runExceptT (readExternFile fp)
- case ef' of
- Left err ->
- logErrorN ("Failed to reload file at: " <> toS fp <> " with error: " <> show err)
- Right ef -> do
- lift $ void $ atomically (insertExternsSTM ref ef *> populateVolatileStateSTM ref)
- logDebugN ("Reloaded File at: " <> toS fp)
-
--- | Installs filewatchers for the given directory and reloads ExternsFiles when
--- they change on disc
-watcher :: Bool -> IdeLogLevel -> TVar IdeState -> FilePath -> IO ()
-watcher polling logLevel stateVar fp =
- withManagerConf
- (defaultConfig { confDebounce = NoDebounce
- , confUsePolling = polling
- }) $ \mgr -> do
- _ <- watchTree mgr fp
- (\ev -> takeFileName (eventPath ev) == "externs.json")
- (reloadFile logLevel stateVar)
- forever (threadDelay 100000)
diff --git a/src/Language/PureScript/Interactive.hs b/src/Language/PureScript/Interactive.hs
index c4b2f8e2f6..5f88b079c3 100644
--- a/src/Language/PureScript/Interactive.hs
+++ b/src/Language/PureScript/Interactive.hs
@@ -9,40 +9,39 @@ module Language.PureScript.Interactive
, runMake
) where
-import Prelude ()
-import Prelude.Compat
-import Protolude (ordNub)
-
-import Data.List (sort, find, foldl')
-import Data.Maybe (fromMaybe, mapMaybe)
-import qualified Data.Map as M
-import qualified Data.Set as S
-import Data.Text (Text)
-import qualified Data.Text as T
-
-import Control.Monad.IO.Class (MonadIO, liftIO)
-import Control.Monad.State.Class
-import Control.Monad.Reader.Class
-import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
-import Control.Monad.Trans.State.Strict (StateT, runStateT, evalStateT)
-import Control.Monad.Writer.Strict (Writer(), runWriter)
-
-import qualified Language.PureScript as P
-import qualified Language.PureScript.CST as CST
-import qualified Language.PureScript.Names as N
-import qualified Language.PureScript.Constants as C
-
-import Language.PureScript.Interactive.Completion as Interactive
-import Language.PureScript.Interactive.IO as Interactive
-import Language.PureScript.Interactive.Message as Interactive
-import Language.PureScript.Interactive.Module as Interactive
-import Language.PureScript.Interactive.Parser as Interactive
-import Language.PureScript.Interactive.Printer as Interactive
-import Language.PureScript.Interactive.Types as Interactive
-
-import System.Directory (getCurrentDirectory)
-import System.FilePath ((>))
-import System.FilePath.Glob (glob)
+import Prelude
+import Protolude (ordNub)
+
+import Data.List (sort, find, foldl')
+import Data.Maybe (fromMaybe, mapMaybe)
+import Data.Map qualified as M
+import Data.Set qualified as S
+import Data.Text (Text)
+import Data.Text qualified as T
+
+import Control.Monad.IO.Class (MonadIO, liftIO)
+import Control.Monad.State.Class (MonadState(..), gets, modify)
+import Control.Monad.Reader.Class (MonadReader, asks)
+import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
+import Control.Monad.Trans.State.Strict (StateT, runStateT, evalStateT)
+import Control.Monad.Writer.Strict (Writer(), runWriter)
+
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Names qualified as N
+import Language.PureScript.Constants.Prim qualified as C
+
+import Language.PureScript.Interactive.Completion as Interactive
+import Language.PureScript.Interactive.IO as Interactive
+import Language.PureScript.Interactive.Message as Interactive
+import Language.PureScript.Interactive.Module as Interactive
+import Language.PureScript.Interactive.Parser as Interactive
+import Language.PureScript.Interactive.Printer as Interactive
+import Language.PureScript.Interactive.Types as Interactive
+
+import System.Directory (getCurrentDirectory)
+import System.FilePath ((>))
+import System.FilePath.Glob (glob)
-- | Pretty-print errors
printErrors :: MonadIO m => P.MultipleErrors -> m ()
@@ -179,7 +178,7 @@ handleDecls ds = do
-- | Show actual loaded modules in psci.
handleShowLoadedModules
- :: (MonadState PSCiState m, MonadIO m)
+ :: MonadState PSCiState m
=> (String -> m ())
-> m ()
handleShowLoadedModules print' = do
@@ -190,7 +189,7 @@ handleShowLoadedModules print' = do
-- | Show the imported modules in psci.
handleShowImportedModules
- :: (MonadState PSCiState m, MonadIO m)
+ :: MonadState PSCiState m
=> (String -> m ())
-> m ()
handleShowImportedModules print' = do
@@ -218,12 +217,12 @@ handleShowImportedModules print' = do
Just $ N.showOp op
showRef (P.TypeClassRef _ pn) =
Just $ "class " <> N.runProperName pn
- showRef (P.TypeInstanceRef _ ident) =
+ showRef (P.TypeInstanceRef _ ident P.UserNamed) =
Just $ N.runIdent ident
+ showRef (P.TypeInstanceRef _ _ P.CompilerNamed) =
+ Nothing
showRef (P.ModuleRef _ name) =
Just $ "module " <> N.runModuleName name
- showRef (P.KindRef _ pn) =
- Just $ "kind " <> N.runProperName pn
showRef (P.ReExportRef _ _ _) =
Nothing
@@ -231,7 +230,7 @@ handleShowImportedModules print' = do
commaList = T.intercalate ", "
handleShowPrint
- :: (MonadState PSCiState m, MonadIO m)
+ :: MonadState PSCiState m
=> (String -> m ())
-> m ()
handleShowPrint print' = do
@@ -274,7 +273,7 @@ handleTypeOf print' val = do
case e of
Left errs -> printErrors errs
Right (_, env') ->
- case M.lookup (P.mkQualified (P.Ident "it") (P.ModuleName [P.ProperName "$PSCI"])) (P.names env') of
+ case M.lookup (P.mkQualified (P.Ident "it") (P.ModuleName "$PSCI")) (P.names env') of
Just (ty, _, _) -> print' . P.prettyPrintType maxBound $ ty
Nothing -> print' "Could not find type"
@@ -287,26 +286,26 @@ handleKindOf
handleKindOf print' typ = do
st <- get
let m = createTemporaryModuleForKind st typ
- mName = P.ModuleName [P.ProperName "$PSCI"]
+ mName = P.ModuleName "$PSCI"
e <- liftIO . runMake $ rebuild (map snd (psciLoadedExterns st)) m
case e of
Left errs -> printErrors errs
Right (_, env') ->
- case M.lookup (P.Qualified (Just mName) $ P.ProperName "IT") (P.typeSynonyms env') of
+ case M.lookup (P.Qualified (P.ByModuleName mName) $ P.ProperName "IT") (P.typeSynonyms env') of
Just (_, typ') -> do
let chk = (P.emptyCheckState env') { P.checkCurrentModule = Just mName }
- k = check (P.kindOf typ') chk
+ k = check (snd <$> P.kindOf typ') chk
check :: StateT P.CheckState (ExceptT P.MultipleErrors (Writer P.MultipleErrors)) a -> P.CheckState -> Either P.MultipleErrors (a, P.CheckState)
check sew = fst . runWriter . runExceptT . runStateT sew
case k of
Left err -> printErrors err
- Right (kind, _) -> print' . T.unpack . P.prettyPrintKind $ kind
+ Right (kind, _) -> print' . P.prettyPrintType 1024 $ kind
Nothing -> print' "Could not find kind"
-- | Browse a module and displays its signature
handleBrowse
- :: (MonadReader PSCiConfig m, MonadState PSCiState m, MonadIO m)
+ :: (MonadReader PSCiConfig m, MonadState PSCiState m)
=> (String -> m ())
-> P.ModuleName
-> m ()
diff --git a/src/Language/PureScript/Interactive/Completion.hs b/src/Language/PureScript/Interactive/Completion.hs
index eccbcfcf2d..d9e61e9cca 100644
--- a/src/Language/PureScript/Interactive/Completion.hs
+++ b/src/Language/PureScript/Interactive/Completion.hs
@@ -6,20 +6,20 @@ module Language.PureScript.Interactive.Completion
, formatCompletions
) where
-import Prelude.Compat
+import Prelude
import Protolude (ordNub)
-import Control.Monad.IO.Class (MonadIO(..))
-import Control.Monad.State.Class (MonadState(..))
-import Control.Monad.Trans.Reader (asks, runReaderT, ReaderT)
-import Data.List (nub, isPrefixOf, isInfixOf, isSuffixOf, sortBy, stripPrefix)
-import Data.Map (keys)
-import Data.Maybe (mapMaybe)
-import qualified Data.Text as T
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Interactive.Directive as D
-import Language.PureScript.Interactive.Types
-import System.Console.Haskeline
+import Control.Monad.IO.Class (MonadIO(..))
+import Control.Monad.State.Class (MonadState(..))
+import Control.Monad.Trans.Reader (asks, runReaderT, ReaderT)
+import Data.List (nub, isPrefixOf, isInfixOf, isSuffixOf, sortBy, stripPrefix)
+import Data.Map (keys)
+import Data.Maybe (mapMaybe)
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.Interactive.Directive qualified as D
+import Language.PureScript.Interactive.Types (Directive(..), PSCiState, psciExports, psciImports, psciLoadedExterns, replQueryStrings)
+import System.Console.Haskeline (Completion(..), CompletionFunc, completeWordWithPrev, listFiles, simpleCompletion)
-- Completions may read the state, but not modify it.
type CompletionM = ReaderT PSCiState IO
diff --git a/src/Language/PureScript/Interactive/Directive.hs b/src/Language/PureScript/Interactive/Directive.hs
index 5538315e40..a8a0ce1307 100644
--- a/src/Language/PureScript/Interactive/Directive.hs
+++ b/src/Language/PureScript/Interactive/Directive.hs
@@ -3,64 +3,54 @@
--
module Language.PureScript.Interactive.Directive where
-import Prelude.Compat
+import Prelude
-import Data.Maybe (fromJust, listToMaybe)
+import Data.Maybe (fromJust)
import Data.List (isPrefixOf)
import Data.Tuple (swap)
+import Data.List.NonEmpty (NonEmpty(..))
+import Data.List.NonEmpty qualified as NEL
-import Language.PureScript.Interactive.Types
-
--- |
--- List of all avaliable directives.
---
-directives :: [Directive]
-directives = map fst directiveStrings
+import Language.PureScript.Interactive.Types (Directive(..))
-- |
-- A mapping of directives to the different strings that can be used to invoke
-- them.
--
-directiveStrings :: [(Directive, [String])]
+directiveStrings :: [(Directive, NonEmpty String)]
directiveStrings =
- [ (Help , ["?", "help"])
- , (Quit , ["quit"])
- , (Reload , ["reload"])
- , (Clear , ["clear"])
- , (Browse , ["browse"])
- , (Type , ["type"])
- , (Kind , ["kind"])
- , (Show , ["show"])
- , (Paste , ["paste"])
- , (Complete , ["complete"])
- , (Print , ["print"])
+ [ (Help , NEL.fromList ["?", "help"])
+ , (Quit , NEL.singleton "quit")
+ , (Reload , NEL.singleton "reload")
+ , (Clear , NEL.singleton "clear")
+ , (Browse , NEL.singleton "browse")
+ , (Type , NEL.singleton "type")
+ , (Kind , NEL.singleton "kind")
+ , (Show , NEL.singleton "show")
+ , (Paste , NEL.singleton "paste")
+ , (Complete , NEL.singleton "complete")
+ , (Print , NEL.singleton "print")
]
-- |
--- Like directiveStrings, but the other way around.
+-- Like `directiveStrings`, but the other way around.
--
directiveStrings' :: [(String, Directive)]
directiveStrings' = concatMap go directiveStrings
where
- go (dir, strs) = map (\s -> (s, dir)) strs
-
--- |
--- List of all directive strings.
---
-strings :: [String]
-strings = concatMap snd directiveStrings
+ go (dir, strs) = map (, dir) $ NEL.toList strs
-- |
-- Returns all possible string representations of a directive.
--
-stringsFor :: Directive -> [String]
+stringsFor :: Directive -> NonEmpty String
stringsFor d = fromJust (lookup d directiveStrings)
-- |
-- Returns the default string representation of a directive.
--
stringFor :: Directive -> String
-stringFor = head . stringsFor
+stringFor = NEL.head . stringsFor
-- |
-- Returns the list of directives which could be expanded from the string
@@ -77,9 +67,6 @@ directivesFor = map fst . directivesFor'
directiveStringsFor :: String -> [String]
directiveStringsFor = map snd . directivesFor'
-parseDirective :: String -> Maybe Directive
-parseDirective = listToMaybe . directivesFor
-
-- |
-- The help menu.
--
@@ -99,4 +86,3 @@ help =
, (Complete, "", "Show completions for as if pressing tab")
, (Print, "", "Set the repl's printing function to (which must be fully qualified)")
]
-
diff --git a/src/Language/PureScript/Interactive/IO.hs b/src/Language/PureScript/Interactive/IO.hs
index 92a2e8dc64..34c9a287a5 100644
--- a/src/Language/PureScript/Interactive/IO.hs
+++ b/src/Language/PureScript/Interactive/IO.hs
@@ -1,13 +1,25 @@
-module Language.PureScript.Interactive.IO (findNodeProcess, getHistoryFilename) where
+{-# LANGUAGE TypeApplications #-}
-import Prelude.Compat
+module Language.PureScript.Interactive.IO (findNodeProcess, readNodeProcessWithExitCode, getHistoryFilename) where
-import Control.Monad (msum)
+import Prelude
+
+import Control.Monad (msum, void)
+import Control.Monad.Error.Class (throwError)
+import Control.Monad.Trans.Class (lift)
+import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
+import Data.Functor ((<&>))
+import Data.List (isInfixOf)
import System.Directory (XdgDirectory (..), createDirectoryIfMissing,
getAppUserDataDirectory, getXdgDirectory,
findExecutable, doesFileExist)
+import System.Exit (ExitCode(ExitFailure, ExitSuccess))
import System.FilePath (takeDirectory, (>))
+import System.Process (readProcessWithExitCode)
+import Text.Parsec ((>), many1, parse, sepBy)
+import Text.Parsec.Char (char, digit)
+import Protolude (note)
mkdirp :: FilePath -> IO ()
mkdirp = createDirectoryIfMissing True . takeDirectory
@@ -21,9 +33,42 @@ onFirstFileMatching f pathVariants = runMaybeT . msum $ map (MaybeT . f) pathVar
-- Locates the node executable.
-- Checks for either @nodejs@ or @node@.
--
-findNodeProcess :: IO (Maybe String)
-findNodeProcess = onFirstFileMatching findExecutable names
- where names = ["nodejs", "node"]
+findNodeProcess :: IO (Either String String)
+findNodeProcess = onFirstFileMatching findExecutable ["nodejs", "node"] <&>
+ note "Could not find Node.js. Do you have Node.js installed and available in your PATH?"
+
+findNodeVersion :: String -> IO (Maybe String)
+findNodeVersion node = do
+ result <- readProcessWithExitCode node ["--version"] ""
+ return $ case result of
+ (ExitSuccess, version, _) -> Just version
+ (ExitFailure _, _, _) -> Nothing
+
+readNodeProcessWithExitCode :: Maybe FilePath -> [String] -> String -> IO (Either String (ExitCode, String, String))
+readNodeProcessWithExitCode nodePath nodeArgs stdin = runExceptT $ do
+ process <- maybe (ExceptT findNodeProcess) pure nodePath
+ (major, _, _) <- lift (findNodeVersion process) >>= \case
+ Nothing -> throwError "Could not find Node.js version."
+ Just version -> do
+ let semver = do
+ void $ char 'v'
+ major : minor : patch : _ <- fmap (read @Int) (many1 digit) `sepBy` void (char '.')
+ pure (major, minor, patch)
+ case parse (semver > "Could not parse Node.js version.") "" version of
+ Left err -> throwError $ show err
+ Right (major, minor, patch)
+ | major < 12 -> throwError $ "Unsupported Node.js version " <> show major <> ". Required Node.js version >=12."
+ | otherwise -> pure (major, minor, patch)
+ let nodeArgs' = if major < 13 then "--experimental-modules" : nodeArgs else nodeArgs
+ lift (readProcessWithExitCode process nodeArgs' stdin) <&> \case
+ (ExitSuccess, out, err) ->
+ (ExitSuccess, out, censorExperimentalWarnings err)
+ (ExitFailure code, out, err) ->
+ (ExitFailure code, out, err)
+
+censorExperimentalWarnings :: String -> String
+censorExperimentalWarnings =
+ unlines . filter (not . ("ExperimentalWarning" `isInfixOf`)) . lines
-- |
-- Grabs the filename where the history is stored.
diff --git a/src/Language/PureScript/Interactive/Message.hs b/src/Language/PureScript/Interactive/Message.hs
index 24a5b3737a..800b614758 100644
--- a/src/Language/PureScript/Interactive/Message.hs
+++ b/src/Language/PureScript/Interactive/Message.hs
@@ -1,12 +1,12 @@
module Language.PureScript.Interactive.Message where
-import Prelude.Compat
+import Prelude
-import Data.List (intercalate)
-import Data.Version (showVersion)
-import qualified Paths_purescript as Paths
-import qualified Language.PureScript.Interactive.Directive as D
-import Language.PureScript.Interactive.Types
+import Data.List (intercalate)
+import Data.Version (showVersion)
+import Paths_purescript qualified as Paths
+import Language.PureScript.Interactive.Directive qualified as D
+import Language.PureScript.Interactive.Types (Directive)
-- Messages
diff --git a/src/Language/PureScript/Interactive/Module.hs b/src/Language/PureScript/Interactive/Module.hs
index a2bf230ea9..61083eee2e 100644
--- a/src/Language/PureScript/Interactive/Module.hs
+++ b/src/Language/PureScript/Interactive/Module.hs
@@ -1,14 +1,13 @@
module Language.PureScript.Interactive.Module where
-import Prelude.Compat
+import Prelude
-import Control.Monad
-import qualified Language.PureScript as P
-import qualified Language.PureScript.CST as CST
-import Language.PureScript.Interactive.Types
-import System.Directory (getCurrentDirectory)
-import System.FilePath (pathSeparator, makeRelative)
-import System.IO.UTF8 (readUTF8FileT)
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Interactive.Types (ImportedModule, PSCiState, initialInteractivePrint, psciImportedModules, psciInteractivePrint, psciLetBindings)
+import System.Directory (getCurrentDirectory)
+import System.FilePath (pathSeparator, makeRelative)
+import System.IO.UTF8 (readUTF8FilesT)
-- * Support Module
@@ -18,27 +17,16 @@ supportModuleName = fst initialInteractivePrint
-- | Checks if the Console module is defined
supportModuleIsDefined :: [P.ModuleName] -> Bool
-supportModuleIsDefined = any ((== supportModuleName))
+supportModuleIsDefined = elem supportModuleName
-- * Module Management
--- | Loads a file for use with imports.
-loadModule :: FilePath -> IO (Either String [P.Module])
-loadModule filename = do
- pwd <- getCurrentDirectory
- content <- readUTF8FileT filename
- return $
- either (Left . P.prettyPrintMultipleErrors P.defaultPPEOptions {P.ppeRelativeDirectory = pwd}) (Right . map snd) $
- CST.parseFromFiles id [(filename, content)]
-
-- | Load all modules.
loadAllModules :: [FilePath] -> IO (Either P.MultipleErrors [(FilePath, P.Module)])
loadAllModules files = do
pwd <- getCurrentDirectory
- filesAndContent <- forM files $ \filename -> do
- content <- readUTF8FileT filename
- return (filename, content)
- return $ CST.parseFromFiles (makeRelative pwd) filesAndContent
+ filesAndContent <- readUTF8FilesT files
+ return $ fmap (fmap snd) <$> CST.parseFromFiles (makeRelative pwd) filesAndContent
-- |
-- Makes a volatile module to execute the current expression.
@@ -48,18 +36,18 @@ createTemporaryModule exec st val =
let
imports = psciImportedModules st
lets = psciLetBindings st
- moduleName = P.ModuleName [P.ProperName "$PSCI"]
- effModuleName = P.moduleNameFromString "Effect"
- effImport = (effModuleName, P.Implicit, Just (P.ModuleName [P.ProperName "$Effect"]))
- supportImport = (fst (psciInteractivePrint st), P.Implicit, Just (P.ModuleName [P.ProperName "$Support"]))
- eval = P.Var internalSpan (P.Qualified (Just (P.ModuleName [P.ProperName "$Support"])) (snd (psciInteractivePrint st)))
- mainValue = P.App eval (P.Var internalSpan (P.Qualified Nothing (P.Ident "it")))
+ moduleName = P.ModuleName "$PSCI"
+ effModuleName = P.ModuleName "Effect"
+ effImport = (effModuleName, P.Implicit, Just (P.ModuleName "$Effect"))
+ supportImport = (fst (psciInteractivePrint st), P.Implicit, Just (P.ModuleName "$Support"))
+ eval = P.Var internalSpan (P.Qualified (P.ByModuleName (P.ModuleName "$Support")) (snd (psciInteractivePrint st)))
+ mainValue = P.App eval (P.Var internalSpan (P.Qualified P.ByNullSourcePos (P.Ident "it")))
itDecl = P.ValueDecl (internalSpan, []) (P.Ident "it") P.Public [] [P.MkUnguarded val]
typeDecl = P.TypeDeclaration
(P.TypeDeclarationData (internalSpan, []) (P.Ident "$main")
(P.srcTypeApp
(P.srcTypeConstructor
- (P.Qualified (Just (P.ModuleName [P.ProperName "$Effect"])) (P.ProperName "Effect")))
+ (P.Qualified (P.ByModuleName (P.ModuleName "$Effect")) (P.ProperName "Effect")))
P.srcTypeWildcard))
mainDecl = P.ValueDecl (internalSpan, []) (P.Ident "$main") P.Public [] [P.MkUnguarded mainValue]
decls = if exec then [itDecl, typeDecl, mainDecl] else [itDecl]
@@ -78,7 +66,7 @@ createTemporaryModuleForKind st typ =
let
imports = psciImportedModules st
lets = psciLetBindings st
- moduleName = P.ModuleName [P.ProperName "$PSCI"]
+ moduleName = P.ModuleName "$PSCI"
itDecl = P.TypeSynonymDeclaration (internalSpan, []) (P.ProperName "IT") [] typ
in
P.Module internalSpan [] moduleName ((importDecl `map` imports) ++ lets ++ [itDecl]) Nothing
@@ -90,7 +78,7 @@ createTemporaryModuleForImports :: PSCiState -> P.Module
createTemporaryModuleForImports st =
let
imports = psciImportedModules st
- moduleName = P.ModuleName [P.ProperName "$PSCI"]
+ moduleName = P.ModuleName "$PSCI"
in
P.Module internalSpan [] moduleName (importDecl `map` imports) Nothing
@@ -101,7 +89,7 @@ indexFile :: FilePath
indexFile = ".psci_modules" ++ pathSeparator : "index.js"
modulesDir :: FilePath
-modulesDir = ".psci_modules" ++ pathSeparator : "node_modules"
+modulesDir = ".psci_modules"
internalSpan :: P.SourceSpan
internalSpan = P.internalModuleSourceSpan ""
diff --git a/src/Language/PureScript/Interactive/Parser.hs b/src/Language/PureScript/Interactive/Parser.hs
index cefec9ff72..d888683b6d 100644
--- a/src/Language/PureScript/Interactive/Parser.hs
+++ b/src/Language/PureScript/Interactive/Parser.hs
@@ -6,29 +6,36 @@ module Language.PureScript.Interactive.Parser
, parseCommand
) where
-import Prelude.Compat hiding (lex)
-
-import Control.Applicative ((<|>))
-import Control.Monad (join)
-import Data.Bifunctor (first)
-import Data.Char (isSpace)
-import Data.List (intercalate)
-import qualified Data.Text as T
-import Text.Parsec hiding ((<|>))
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Interactive.Directive as D
-import Language.PureScript.Interactive.Types
-import Language.PureScript.Parser.Common (mark, same)
+import Prelude
+
+import Control.Monad (join)
+import Data.Bifunctor (bimap)
+import Data.Char (isSpace)
+import Data.List (intercalate)
+import Data.List.NonEmpty qualified as NE
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.CST.Monad qualified as CSTM
+import Language.PureScript.Interactive.Directive qualified as D
+import Language.PureScript.Interactive.Types (Command(..), Directive(..), ReplQuery(..), parseReplQuery, replQueryStrings)
-- |
-- Parses a limited set of commands from from .purs-repl
--
parseDotFile :: FilePath -> String -> Either String [Command]
-parseDotFile filePath s = first show $ do
- ts <- P.lex filePath (T.pack s)
- P.runTokenParser filePath (many parser <* eof) ts
+parseDotFile filePath =
+ bimap (CST.prettyPrintError . NE.head) snd
+ . CST.runTokenParser (parseMany parser <* CSTM.token CST.TokEof)
+ . CST.lexTopLevel
+ . T.pack
where
- parser = psciImport <|> fail "The .purs-repl file only supports import declarations"
+ parser = CSTM.oneOf $ NE.fromList
+ [ psciImport filePath
+ , do
+ tok <- CSTM.munch
+ CSTM.parseFail tok $ CST.ErrCustom "The .purs-repl file only supports import declarations"
+ ]
-- |
-- Parses PSCI metacommands or expressions input from the user.
@@ -37,21 +44,37 @@ parseCommand :: String -> Either String [Command]
parseCommand cmdString =
case cmdString of
(':' : cmd) -> pure <$> parseDirective cmd
- _ -> parseRest (many1 psciCommand) cmdString
-
-parseRest :: P.TokenParser a -> String -> Either String a
-parseRest p s = first show $ do
- ts <- P.lex "" (T.pack s)
- P.runTokenParser "" (p <* eof) ts
-
-psciCommand :: P.TokenParser Command
-psciCommand = choice (map try parsers)
+ _ -> parseRest (mergeDecls <$> parseMany psciCommand) cmdString
where
- parsers =
- [ psciImport
+ mergeDecls (Decls as : bs) =
+ case mergeDecls bs of
+ Decls bs' : cs' ->
+ Decls (as <> bs') : cs'
+ cs' ->
+ Decls as : cs'
+ mergeDecls (a : bs) =
+ a : mergeDecls bs
+ mergeDecls [] = []
+
+parseMany :: CST.Parser a -> CST.Parser [a]
+parseMany = CSTM.manyDelimited CST.TokLayoutStart CST.TokLayoutEnd CST.TokLayoutSep
+
+parseOne :: CST.Parser a -> CST.Parser a
+parseOne p = CSTM.token CST.TokLayoutStart *> p <* CSTM.token CST.TokLayoutEnd
+
+parseRest :: CST.Parser a -> String -> Either String a
+parseRest p =
+ bimap (CST.prettyPrintError . NE.head) snd
+ . CST.runTokenParser (p <* CSTM.token CST.TokEof)
+ . CST.lexTopLevel
+ . T.pack
+
+psciCommand :: CST.Parser Command
+psciCommand =
+ CSTM.oneOf $ NE.fromList
+ [ psciImport ""
, psciDeclaration
, psciExpression
- , psciDeprecatedLet
]
trim :: String -> String
@@ -79,50 +102,32 @@ parseDirective cmd =
Reload -> return ReloadState
Clear -> return ClearState
Paste -> return PasteLines
- Browse -> BrowseModule <$> parseRest P.moduleName arg
+ Browse -> BrowseModule . CST.nameValue <$> parseRest (parseOne CST.parseModuleNameP) arg
Show -> ShowInfo <$> parseReplQuery' arg
- Type -> TypeOf <$> parseRest P.parseValue arg
- Kind -> KindOf <$> parseRest P.parseType arg
+ Type -> TypeOf . CST.convertExpr "" <$> parseRest (parseOne CST.parseExprP) arg
+ Kind -> KindOf . CST.convertType "" <$> parseRest (parseOne CST.parseTypeP) arg
Complete -> return (CompleteStr arg)
- Print -> parseRest
- ((eof *> return (ShowInfo QueryPrint))
- <|> (SetInteractivePrint <$> parseFullyQualifiedIdent))
- arg
+ Print
+ | arg == "" -> return $ ShowInfo QueryPrint
+ | otherwise -> SetInteractivePrint <$> parseRest (parseOne parseFullyQualifiedIdent) arg
-- |
-- Parses expressions entered at the PSCI repl.
--
-psciExpression :: P.TokenParser Command
-psciExpression = Expression <$> P.parseValue
+psciExpression :: CST.Parser Command
+psciExpression = Expression . CST.convertExpr "" <$> CST.parseExprP
-- | Imports must be handled separately from other declarations, so that
-- :show import works, for example.
-psciImport :: P.TokenParser Command
-psciImport = do
- (mn, declType, asQ) <- P.parseImportDeclaration'
- return $ Import (mn, declType, asQ)
+psciImport :: FilePath -> CST.Parser Command
+psciImport filePath = do
+ (_, mn, declType, asQ) <- CST.convertImportDecl filePath <$> CST.parseImportDeclP
+ pure $ Import (mn, declType, asQ)
-- | Any declaration that we don't need a 'special case' parser for
-- (like import declarations).
-psciDeclaration :: P.TokenParser Command
-psciDeclaration = fmap Decls $ mark $ fmap join (many1 $ same *>
- (traverse accept =<< P.parseDeclaration))
- where
- accept decl
- | acceptable decl = return decl
- | otherwise = fail "this kind of declaration is not supported in psci"
-
-acceptable :: P.Declaration -> Bool
-acceptable P.DataDeclaration{} = True
-acceptable P.TypeSynonymDeclaration{} = True
-acceptable P.ExternDeclaration{} = True
-acceptable P.ExternDataDeclaration{} = True
-acceptable P.TypeClassDeclaration{} = True
-acceptable P.TypeInstanceDeclaration{} = True
-acceptable P.ExternKindDeclaration{} = True
-acceptable P.TypeDeclaration{} = True
-acceptable P.ValueDeclaration{} = True
-acceptable _ = False
+psciDeclaration :: CST.Parser Command
+psciDeclaration = Decls . CST.convertDeclaration "" <$> CST.parseDeclP
parseReplQuery' :: String -> Either String ReplQuery
parseReplQuery' str =
@@ -131,21 +136,12 @@ parseReplQuery' str =
intercalate ", " replQueryStrings ++ ".")
Just query -> Right query
--- | To show error message when 'let' is used for declaration in PSCI,
--- which is deprecated.
-psciDeprecatedLet :: P.TokenParser Command
-psciDeprecatedLet = do
- P.reserved "let"
- P.indented
- _ <- mark (many1 (same *> P.parseLocalDeclaration))
- notFollowedBy $ P.reserved "in"
- fail "Declarations in PSCi no longer require \"let\", as of version 0.11.0"
-
-parseFullyQualifiedIdent :: P.TokenParser (P.ModuleName, P.Ident)
-parseFullyQualifiedIdent = do
- qname <- P.parseQualified P.parseIdent
- case qname of
- P.Qualified (Just mn) ident ->
- pure (mn, ident)
- P.Qualified Nothing _ ->
- fail "Expected a fully-qualified name (eg: PSCI.Support.eval)"
+parseFullyQualifiedIdent :: CST.Parser (P.ModuleName, P.Ident)
+parseFullyQualifiedIdent = join $ CST.Parser $ \st _ ksucc ->
+ case CST.runParser st CST.parseQualIdentP of
+ (st', Right (CST.QualifiedName _ (Just mn) ident)) ->
+ ksucc st' $ pure (mn, P.Ident $ CST.getIdent ident)
+ _ ->
+ ksucc st $ do
+ tok <- CSTM.munch
+ CSTM.parseFail tok $ CST.ErrCustom "Expected a fully-qualified name (eg: PSCI.Support.eval)"
diff --git a/src/Language/PureScript/Interactive/Printer.hs b/src/Language/PureScript/Interactive/Printer.hs
index 8a7dce4db6..ed2d145219 100644
--- a/src/Language/PureScript/Interactive/Printer.hs
+++ b/src/Language/PureScript/Interactive/Printer.hs
@@ -1,14 +1,14 @@
module Language.PureScript.Interactive.Printer where
-import Prelude.Compat
+import Prelude
-import Data.List (intersperse)
-import qualified Data.Map as M
-import Data.Maybe (mapMaybe)
-import qualified Data.Text as T
-import Data.Text (Text)
-import qualified Language.PureScript as P
-import qualified Text.PrettyPrint.Boxes as Box
+import Data.List (intersperse)
+import Data.Map qualified as M
+import Data.Maybe (mapMaybe)
+import Data.Text qualified as T
+import Data.Text (Text)
+import Language.PureScript qualified as P
+import Text.PrettyPrint.Boxes qualified as Box
-- TODO (Christoph): Text version of boxes
textT :: Text -> Box.Box
@@ -25,6 +25,8 @@ printModuleSignatures moduleName P.Environment{..} =
let moduleNamesIdent = byModuleName names
moduleTypeClasses = byModuleName typeClasses
moduleTypes = byModuleName types
+
+ byModuleName :: M.Map (P.Qualified a) b -> [P.Qualified a]
byModuleName = filter ((== Just moduleName) . P.getQual) . M.keys
in
@@ -61,13 +63,13 @@ printModuleSignatures moduleName P.Environment{..} =
if null typeClassSuperclasses
then Box.text ""
else Box.text "("
- Box.<> Box.hcat Box.left (intersperse (Box.text ", ") $ map (\(P.Constraint _ (P.Qualified _ pn) lt _) -> textT (P.runProperName pn) Box.<+> Box.hcat Box.left (map (P.typeAtomAsBox maxBound) lt)) typeClassSuperclasses)
+ Box.<> Box.hcat Box.left (intersperse (Box.text ", ") $ map (\(P.Constraint _ (P.Qualified _ pn) _ lt _) -> textT (P.runProperName pn) Box.<+> Box.hcat Box.left (map (P.typeAtomAsBox maxBound) lt)) typeClassSuperclasses)
Box.<> Box.text ") <= "
className =
textT (P.runProperName name)
Box.<> textT (foldMap ((" " <>) . fst) typeClassArguments)
classBody =
- Box.vcat Box.top (map (\(i, t) -> textT (P.showIdent i <> " ::") Box.<+> P.typeAsBox maxBound t) typeClassMembers)
+ Box.vcat Box.top (map (\(i, t, _) -> textT (P.showIdent i <> " ::") Box.<+> P.typeAsBox maxBound t) typeClassMembers)
in
Just $
@@ -79,16 +81,16 @@ printModuleSignatures moduleName P.Environment{..} =
findType
- :: M.Map (P.Qualified (P.ProperName 'P.TypeName)) (P.SourceKind, P.TypeKind)
+ :: M.Map (P.Qualified (P.ProperName 'P.TypeName)) (P.SourceType, P.TypeKind)
-> P.Qualified (P.ProperName 'P.TypeName)
- -> (P.Qualified (P.ProperName 'P.TypeName), Maybe (P.SourceKind, P.TypeKind))
+ -> (P.Qualified (P.ProperName 'P.TypeName), Maybe (P.SourceType, P.TypeKind))
findType envTypes name = (name, M.lookup name envTypes)
showType
:: M.Map (P.Qualified (P.ProperName 'P.ClassName)) P.TypeClassData
-> M.Map (P.Qualified (P.ProperName 'P.ConstructorName)) (P.DataDeclType, P.ProperName 'P.TypeName, P.SourceType, [P.Ident])
- -> M.Map (P.Qualified (P.ProperName 'P.TypeName)) ([(Text, Maybe P.SourceKind)], P.SourceType)
- -> (P.Qualified (P.ProperName 'P.TypeName), Maybe (P.SourceKind, P.TypeKind))
+ -> M.Map (P.Qualified (P.ProperName 'P.TypeName)) ([(Text, Maybe P.SourceType)], P.SourceType)
+ -> (P.Qualified (P.ProperName 'P.TypeName), Maybe (P.SourceType, P.TypeKind))
-> Maybe Box.Box
showType typeClassesEnv dataConstructorsEnv typeSynonymsEnv (n@(P.Qualified modul name), typ) =
case (typ, M.lookup n typeSynonymsEnv) of
@@ -101,7 +103,7 @@ printModuleSignatures moduleName P.Environment{..} =
textT ("type " <> P.runProperName name <> foldMap ((" " <>) . fst) typevars)
Box.// Box.moveRight 2 (Box.text "=" Box.<+> P.typeAsBox maxBound dtType)
- (Just (_, P.DataType typevars pt), _) ->
+ (Just (_, P.DataType _ typevars pt), _) ->
let prefix =
case pt of
[(dtProperName,_)] ->
@@ -111,7 +113,7 @@ printModuleSignatures moduleName P.Environment{..} =
_ -> "data"
in
- Just $ textT (prefix <> " " <> P.runProperName name <> foldMap ((" " <>) . fst) typevars) Box.// printCons pt
+ Just $ textT (prefix <> " " <> P.runProperName name <> foldMap ((" " <>) . (\(v, _, _) -> v)) typevars) Box.// printCons pt
_ ->
Nothing
@@ -120,7 +122,7 @@ printModuleSignatures moduleName P.Environment{..} =
Box.moveRight 2 $
Box.vcat Box.left $
mapFirstRest (Box.text "=" Box.<+>) (Box.text "|" Box.<+>) $
- map (\(cons,idents) -> (textT (P.runProperName cons) Box.<> Box.hcat Box.left (map prettyPrintType idents))) pt
+ map (\(cons,idents) -> textT (P.runProperName cons) Box.<> Box.hcat Box.left (map prettyPrintType idents)) pt
prettyPrintType t = Box.text " " Box.<> P.typeAtomAsBox maxBound t
diff --git a/src/Language/PureScript/Interactive/Types.hs b/src/Language/PureScript/Interactive/Types.hs
index 84e926b914..83fedf811d 100644
--- a/src/Language/PureScript/Interactive/Types.hs
+++ b/src/Language/PureScript/Interactive/Types.hs
@@ -15,7 +15,6 @@ module Language.PureScript.Interactive.Types
, psciLetBindings
, initialPSCiState
, initialInteractivePrint
- , psciImportedModuleNames
, updateImportedModules
, updateLoadedExterns
, updateLets
@@ -29,14 +28,16 @@ module Language.PureScript.Interactive.Types
, Directive(..)
) where
-import Prelude.Compat
+import Prelude
-import qualified Language.PureScript as P
-import qualified Data.Map as M
-import Data.List (foldl')
-import Language.PureScript.Sugar.Names.Env (nullImports, primExports)
-import Control.Monad.Trans.Except (runExceptT)
-import Control.Monad.Writer.Strict (runWriterT)
+import Language.PureScript qualified as P
+import Data.Map qualified as M
+import Data.List (foldl')
+import Language.PureScript.Sugar.Names.Env (nullImports, primExports)
+import Control.Monad (foldM)
+import Control.Monad.Trans.Except (runExceptT)
+import Control.Monad.Trans.State (execStateT)
+import Control.Monad.Writer.Strict (runWriterT)
-- | The PSCI configuration.
@@ -107,10 +108,6 @@ psciEnvironment st = foldl' (flip P.applyExternsFileToEnvironment) P.initEnviron
--
type ImportedModule = (P.ModuleName, P.ImportDeclarationType, Maybe P.ModuleName)
-psciImportedModuleNames :: PSCiState -> [P.ModuleName]
-psciImportedModuleNames st =
- map (\(mn, _, _) -> mn) (psciImportedModules st)
-
-- * State helpers
-- This function updates the Imports and Exports values in the PSCiState, which are used for
@@ -118,25 +115,27 @@ psciImportedModuleNames st =
-- ensure that completions remain accurate.
updateImportExports :: PSCiState -> PSCiState
updateImportExports st@(PSCiState modules lets externs iprint _ _) =
- case desugarModule [temporaryModule] of
+ case createEnv (map snd externs) >>= flip desugarModule temporaryModule of
Left _ -> st -- TODO: can this fail and what should we do?
- Right (env, _) ->
+ Right env ->
case M.lookup temporaryName env of
Just (_, is, es) -> PSCiState modules lets externs iprint is es
_ -> st -- impossible
where
- desugarModule :: [P.Module] -> Either P.MultipleErrors (P.Env, [P.Module])
- desugarModule = runExceptT =<< hushWarnings . P.desugarImportsWithEnv (map snd externs)
- hushWarnings = fmap fst . runWriterT
+ desugarModule :: P.Env -> P.Module -> Either P.MultipleErrors P.Env
+ desugarModule e = runExceptT =<< fmap (fst . fst) . runWriterT . flip execStateT (e, mempty) . P.desugarImports
+
+ createEnv :: [P.ExternsFile] -> Either P.MultipleErrors P.Env
+ createEnv = runExceptT =<< fmap fst . runWriterT . foldM P.externsEnv P.primEnv
temporaryName :: P.ModuleName
- temporaryName = P.ModuleName [P.ProperName "$PSCI"]
+ temporaryName = P.ModuleName "$PSCI"
temporaryModule :: P.Module
temporaryModule =
let
- prim = (P.ModuleName [P.ProperName "Prim"], P.Implicit, Nothing)
+ prim = (P.ModuleName "Prim", P.Implicit, Nothing)
decl = (importDecl `map` (prim : modules)) ++ lets
in
P.Module internalSpan [] temporaryName decl Nothing
diff --git a/src/Language/PureScript/Kinds.hs b/src/Language/PureScript/Kinds.hs
deleted file mode 100644
index 86686d65d0..0000000000
--- a/src/Language/PureScript/Kinds.hs
+++ /dev/null
@@ -1,183 +0,0 @@
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE DeriveFoldable #-}
-{-# LANGUAGE DeriveTraversable #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-
-module Language.PureScript.Kinds where
-
-import Prelude.Compat
-
-import GHC.Generics (Generic)
-import Control.Applicative ((<|>))
-import Control.DeepSeq (NFData)
-import Data.Text (Text)
-import Data.Aeson (Value, toJSON, (.=), (.:))
-import Data.Aeson.Types (Parser)
-import qualified Data.Aeson as A
-
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Names
-
-import Lens.Micro.Platform (Lens', (^.), set)
-
-type SourceKind = Kind SourceAnn
-
--- | The data type of kinds
-data Kind a
- -- | Unification variable of type Kind
- = KUnknown a Int
- -- | Kinds for labelled, unordered rows without duplicates
- | Row a (Kind a)
- -- | Function kinds
- | FunKind a (Kind a) (Kind a)
- -- | A named kind
- | NamedKind a (Qualified (ProperName 'KindName))
- deriving (Show, Generic, Functor, Foldable, Traversable)
-
-instance NFData a => NFData (Kind a)
-
-srcKUnknown :: Int -> SourceKind
-srcKUnknown = KUnknown NullSourceAnn
-
-srcRow :: SourceKind -> SourceKind
-srcRow = Row NullSourceAnn
-
-srcFunKind :: SourceKind -> SourceKind -> SourceKind
-srcFunKind = FunKind NullSourceAnn
-
-srcNamedKind :: Qualified (ProperName 'KindName) -> SourceKind
-srcNamedKind = NamedKind NullSourceAnn
-
-kindToJSON :: forall a. (a -> Value) -> Kind a -> Value
-kindToJSON annToJSON kind =
- case kind of
- KUnknown a i ->
- variant "KUnknown" a i
- Row a k ->
- variant "Row" a (go k)
- FunKind a k1 k2 ->
- variant "FunKind" a (go k1, go k2)
- NamedKind a n ->
- variant "NamedKind" a n
- where
- go :: Kind a -> Value
- go = kindToJSON annToJSON
-
- variant :: A.ToJSON b => Text -> a -> b -> A.Value
- variant tag ann contents =
- A.object
- [ "tag" .= tag
- , "annotation" .= annToJSON ann
- , "contents" .= contents
- ]
-
-instance A.ToJSON a => A.ToJSON (Kind a) where
- toJSON = kindToJSON toJSON
-
-kindFromJSON :: forall a. Parser a -> (Value -> Parser a) -> Value -> Parser (Kind a)
-kindFromJSON defaultAnn annFromJSON = A.withObject "Kind" $ \o -> do
- tag <- o .: "tag"
- a <- (o .: "annotation" >>= annFromJSON) <|> defaultAnn
- let
- contents :: A.FromJSON b => Parser b
- contents = o .: "contents"
- case tag of
- "KUnknown" ->
- KUnknown a <$> contents
- "Row" ->
- Row a <$> (go =<< contents)
- "FunKind" -> do
- (b, c) <- contents
- FunKind a <$> go b <*> go c
- "NamedKind" ->
- NamedKind a <$> contents
- other ->
- fail $ "Unrecognised tag: " ++ other
- where
- go :: Value -> Parser (Kind a)
- go = kindFromJSON defaultAnn annFromJSON
-
--- These overlapping instances exist to preserve compatability for common
--- instances which have a sensible default for missing annotations.
-instance {-# OVERLAPPING #-} A.FromJSON (Kind SourceAnn) where
- parseJSON = kindFromJSON (pure NullSourceAnn) A.parseJSON
-
-instance {-# OVERLAPPING #-} A.FromJSON (Kind ()) where
- parseJSON = kindFromJSON (pure ()) A.parseJSON
-
-instance {-# OVERLAPPING #-} A.FromJSON a => A.FromJSON (Kind a) where
- parseJSON = kindFromJSON (fail "Invalid annotation") A.parseJSON
-
-everywhereOnKinds :: (Kind a -> Kind a) -> Kind a -> Kind a
-everywhereOnKinds f = go
- where
- go (Row ann k1) = f (Row ann (go k1))
- go (FunKind ann k1 k2) = f (FunKind ann (go k1) (go k2))
- go other = f other
-
-everywhereOnKindsM :: Monad m => (Kind a -> m (Kind a)) -> Kind a -> m (Kind a)
-everywhereOnKindsM f = go
- where
- go (Row ann k1) = (Row ann <$> go k1) >>= f
- go (FunKind ann k1 k2) = (FunKind ann <$> go k1 <*> go k2) >>= f
- go other = f other
-
-everythingOnKinds :: (r -> r -> r) -> (Kind a -> r) -> Kind a -> r
-everythingOnKinds (<>.) f = go
- where
- go k@(Row _ k1) = f k <>. go k1
- go k@(FunKind _ k1 k2) = f k <>. go k1 <>. go k2
- go other = f other
-
-annForKind :: Lens' (Kind a) a
-annForKind k (KUnknown a b) = (\z -> KUnknown z b) <$> k a
-annForKind k (Row a b) = (\z -> Row z b) <$> k a
-annForKind k (FunKind a b c) = (\z -> FunKind z b c) <$> k a
-annForKind k (NamedKind a b) = (\z -> NamedKind z b) <$> k a
-
-getAnnForKind :: Kind a -> a
-getAnnForKind = (^. annForKind)
-
-setAnnForKind :: a -> Kind a -> Kind a
-setAnnForKind = set annForKind
-
-instance Eq (Kind a) where
- (==) = eqKind
-
-instance Ord (Kind a) where
- compare = compareKind
-
-eqKind :: Kind a -> Kind b -> Bool
-eqKind (KUnknown _ a) (KUnknown _ a') = a == a'
-eqKind (Row _ a) (Row _ a') = eqKind a a'
-eqKind (FunKind _ a b) (FunKind _ a' b') = eqKind a a' && eqKind b b'
-eqKind (NamedKind _ a) (NamedKind _ a') = a == a'
-eqKind _ _ = False
-
-eqMaybeKind :: Maybe (Kind a) -> Maybe (Kind b) -> Bool
-eqMaybeKind Nothing (Just _) = False
-eqMaybeKind (Just _) Nothing = False
-eqMaybeKind Nothing Nothing = True
-eqMaybeKind (Just a) (Just b) = eqKind a b
-
-compareKind :: Kind a -> Kind b -> Ordering
-compareKind (KUnknown _ a) (KUnknown _ a') = compare a a'
-compareKind (KUnknown {}) _ = LT
-
-compareKind (Row _ a) (Row _ a') = compareKind a a'
-compareKind (Row {}) _ = LT
-compareKind _ (Row {}) = GT
-
-compareKind (FunKind _ a b) (FunKind _ a' b') = compareKind a b <> compareKind a' b'
-compareKind (FunKind {}) _ = LT
-compareKind _ (FunKind {}) = GT
-
-compareKind (NamedKind _ a) (NamedKind _ a') = compare a a'
-compareKind (NamedKind {}) _ = GT
-
-compareMaybeKind :: Maybe (Kind a) -> Maybe (Kind b) -> Ordering
-compareMaybeKind Nothing Nothing = EQ
-compareMaybeKind Nothing (Just _) = LT
-compareMaybeKind (Just _) Nothing = GT
-compareMaybeKind (Just a) (Just b) = compareKind a b
diff --git a/src/Language/PureScript/Label.hs b/src/Language/PureScript/Label.hs
index accd31463e..a5d080a76c 100644
--- a/src/Language/PureScript/Label.hs
+++ b/src/Language/PureScript/Label.hs
@@ -1,14 +1,12 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE DeriveGeneric #-}
-
module Language.PureScript.Label (Label(..)) where
-import Prelude.Compat hiding (lex)
+import Prelude
import GHC.Generics (Generic)
+import Codec.Serialise (Serialise)
import Control.DeepSeq (NFData)
import Data.Monoid ()
import Data.String (IsString(..))
-import qualified Data.Aeson as A
+import Data.Aeson qualified as A
import Language.PureScript.PSString (PSString)
@@ -20,3 +18,4 @@ newtype Label = Label { runLabel :: PSString }
deriving (Show, Eq, Ord, IsString, Semigroup, Monoid, A.ToJSON, A.FromJSON, Generic)
instance NFData Label
+instance Serialise Label
diff --git a/src/Language/PureScript/Linter.hs b/src/Language/PureScript/Linter.hs
index fefed909ad..9bce1909de 100644
--- a/src/Language/PureScript/Linter.hs
+++ b/src/Language/PureScript/Linter.hs
@@ -3,37 +3,38 @@
--
module Language.PureScript.Linter (lint, module L) where
-import Prelude.Compat
+import Prelude
-import Control.Monad.Writer.Class
+import Control.Monad.Writer.Class (MonadWriter(..), censor)
import Data.Maybe (mapMaybe)
-import qualified Data.Set as S
+import Data.Set qualified as S
import Data.Text (Text)
+import Data.Text qualified as Text
+import Control.Monad ((<=<))
import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Errors
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, errorMessage')
import Language.PureScript.Linter.Exhaustive as L
import Language.PureScript.Linter.Imports as L
-import Language.PureScript.Names
-import Language.PureScript.Types
+import Language.PureScript.Names (Ident(..), Qualified(..), QualifiedBy(..), getIdentName, runIdent)
+import Language.PureScript.Types (Constraint(..), SourceType, Type(..), everythingWithContextOnTypes)
+import Language.PureScript.Constants.Libs qualified as C
-- | Lint the PureScript AST.
-- |
--- | Right now, this pass only performs a shadowing check.
+-- | Right now, this pass performs a shadowing check and a check for unused bindings.
lint :: forall m. (MonadWriter MultipleErrors m) => Module -> m ()
-lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDeclaration ds
+lint modl@(Module _ _ mn ds _) = do
+ lintUnused modl
+ censor (addHint (ErrorInModule mn)) $ mapM_ lintDeclaration ds
+
where
moduleNames :: S.Set ScopedIdent
moduleNames = S.fromList (map ToplevelIdent (mapMaybe getDeclIdent ds))
getDeclIdent :: Declaration -> Maybe Ident
- getDeclIdent (ValueDeclaration vd) = Just (valdeclIdent vd)
- getDeclIdent (ExternDeclaration _ ident _) = Just ident
- getDeclIdent (TypeInstanceDeclaration _ _ _ ident _ _ _ _) = Just ident
- getDeclIdent BindingGroupDeclaration{} = internalError "lint: binding groups should not be desugared yet."
- getDeclIdent _ = Nothing
+ getDeclIdent = getIdentName <=< declName
lintDeclaration :: Declaration -> m ()
lintDeclaration = tell . f
@@ -85,7 +86,7 @@ lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDecl
where
step :: S.Set Text -> SourceType -> (S.Set Text, MultipleErrors)
- step s (ForAll _ tv _ _ _) = bindVar s tv
+ step s (ForAll _ _ tv _ _ _) = bindVar s tv
step s _ = (s, mempty)
bindVar :: S.Set Text -> Text -> (S.Set Text, MultipleErrors)
@@ -96,12 +97,15 @@ lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDecl
-- Recursively walk the type and prune used variables from `unused`
go :: S.Set Text -> SourceType -> (S.Set Text, MultipleErrors)
go unused (TypeVar _ v) = (S.delete v unused, mempty)
- go unused (ForAll _ tv _ t1 _) =
- let (nowUnused, errors) = go (S.insert tv unused) t1
+ go unused (ForAll _ _ tv mbK t1 _) =
+ let (nowUnused, errors)
+ | Just k <- mbK = go unused k `combine` go (S.insert tv unused) t1
+ | otherwise = go (S.insert tv unused) t1
restoredUnused = if S.member tv unused then S.insert tv nowUnused else nowUnused
combinedErrors = if S.member tv nowUnused then errors <> errorMessage' ss (UnusedTypeVar tv) else errors
in (restoredUnused, combinedErrors)
go unused (TypeApp _ f x) = go unused f `combine` go unused x
+ go unused (KindApp _ f x) = go unused f `combine` go unused x
go unused (ConstrainedType _ c t1) = foldl combine (unused, mempty) $ map (go unused) (constraintArgs c <> [t1])
go unused (RCons _ _ t1 rest) = go unused t1 `combine` go unused rest
go unused (KindedType _ t1 _) = go unused t1
@@ -109,6 +113,7 @@ lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDecl
go unused (BinaryNoParensType _ t1 t2 t3) = go unused t1 `combine` go unused t2 `combine` go unused t3
go unused TUnknown{} = (unused, mempty)
go unused TypeLevelString{} = (unused, mempty)
+ go unused TypeLevelInt{} = (unused, mempty)
go unused TypeWildcard{} = (unused, mempty)
go unused TypeConstructor{} = (unused, mempty)
go unused TypeOp{} = (unused, mempty)
@@ -126,3 +131,169 @@ lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDecl
| name `S.member` s = (s, errorMessage' ss (mkError name))
| otherwise = (S.insert name s, mempty)
+
+
+lintUnused :: forall m. (MonadWriter MultipleErrors m) => Module -> m ()
+lintUnused (Module modSS _ mn modDecls exports) =
+ censor (addHint (ErrorInModule mn)) $ do
+ topVars <- traverse lintDeclaration modDecls
+ let allVars = S.unions topVars
+ case exports of
+ Nothing ->
+ pure ()
+ Just exports'
+ | any thisModuleRef exports' -> pure ()
+ | otherwise -> do
+ let exportIds = S.fromList $ mapMaybe getValueRef exports'
+ expectedUsedDecls = S.fromList (mapMaybe getDeclIdent $ filter isValueDecl modDecls) `S.difference` exportIds
+ unused = (expectedUsedDecls `S.difference` allVars) `S.difference` rebindable
+ newErrs = mconcat $ map unusedDeclError $ S.toList unused
+ tell newErrs
+ pure ()
+ where
+ unusedDeclError ident = errorMessage' ss $ UnusedDeclaration ident
+ where
+ ss = case filter ((== Just ident) . getDeclIdent) modDecls of
+ decl:_ -> declSourceSpan decl
+ _ -> modSS
+
+ thisModuleRef :: DeclarationRef -> Bool
+ thisModuleRef (ModuleRef _ mn') = mn == mn'
+ thisModuleRef _ = False
+
+ rebindable :: S.Set Ident
+ rebindable = S.fromList [ Ident C.S_bind, Ident C.S_discard ]
+
+ getDeclIdent :: Declaration -> Maybe Ident
+ getDeclIdent = getIdentName <=< declName
+
+ lintDeclaration :: Declaration -> m (S.Set Ident)
+ lintDeclaration declToLint = do
+ let (vars, errs) = goDecl declToLint
+ tell errs
+ pure vars
+ where
+
+ goDecl :: Declaration -> (S.Set Ident, MultipleErrors)
+ goDecl (ValueDeclaration vd) =
+ let allExprs = concatMap unguard $ valdeclExpression vd
+ bindNewNames = S.fromList (concatMap binderNamesWithSpans $ valdeclBinders vd)
+ (vars, errs) = removeAndWarn bindNewNames $ mconcat $ map go allExprs
+ errs' = addHint (ErrorInValueDeclaration $ valdeclIdent vd) errs
+ in
+ (vars, errs')
+
+ goDecl (ValueFixityDeclaration _ _ (Qualified _ (Left v)) _) = (S.singleton v, mempty)
+
+ goDecl (TypeInstanceDeclaration _ _ _ _ _ _ _ _ (ExplicitInstance decls)) = mconcat $ map goDecl decls
+ goDecl _ = mempty
+
+ go :: Expr -> (S.Set Ident, MultipleErrors)
+ go (Var _ (Qualified (BySourcePos _) v)) = (S.singleton v, mempty)
+ go (Var _ _) = (S.empty, mempty)
+
+ go (Let _ ds e) = onDecls ds (go e)
+
+ go (Abs binder v1) =
+ let newNames = S.fromList (binderNamesWithSpans binder)
+ in
+ removeAndWarn newNames $ go v1
+
+ go (UnaryMinus _ v1) = go v1
+ go (BinaryNoParens v0 v1 v2) = go v0 <> go v1 <> go v2
+ go (Parens v1) = go v1
+ go (Accessor _ v1) = go v1
+
+ go (ObjectUpdate obj vs) = mconcat (go obj : map (go . snd) vs)
+ go (ObjectUpdateNested obj vs) = go obj <> goTree vs
+ where
+ goTree (PathTree tree) = mconcat $ map (goNode . snd) (runAssocList tree)
+ goNode (Leaf val) = go val
+ goNode (Branch val) = goTree val
+
+ go (App v1 v2) = go v1 <> go v2
+ go (VisibleTypeApp v _) = go v
+ go (Unused v) = go v
+ go (IfThenElse v1 v2 v3) = go v1 <> go v2 <> go v3
+ go (Case vs alts) =
+ let f (CaseAlternative binders gexprs) =
+ let bindNewNames = S.fromList (concatMap binderNamesWithSpans binders)
+ allExprs = concatMap unguard gexprs
+ in
+ removeAndWarn bindNewNames $ mconcat $ map go allExprs
+ in
+ mconcat $ map go vs ++ map f alts
+
+ go (TypedValue _ v1 _) = go v1
+ go (Do _ es) = doElts es Nothing
+ go (Ado _ es v1) = doElts es (Just v1)
+
+ go (Literal _ (ArrayLiteral es)) = mconcat $ map go es
+ go (Literal _ (ObjectLiteral oo)) = mconcat $ map (go . snd) oo
+
+ go (PositionedValue _ _ v1) = go v1
+
+ go (Literal _ _) = mempty
+ go (Op _ _) = mempty
+ go (Constructor _ _) = mempty
+ go (TypeClassDictionary _ _ _) = mempty
+ go (DeferredDictionary _ _) = mempty
+ go (DerivedInstancePlaceholder _ _) = mempty
+ go AnonymousArgument = mempty
+ go (Hole _) = mempty
+
+
+ doElts :: [DoNotationElement] -> Maybe Expr -> (S.Set Ident, MultipleErrors)
+ doElts (DoNotationValue e : rest) v = go e <> doElts rest v
+ doElts (DoNotationBind binder e : rest) v =
+ let bindNewNames = S.fromList (binderNamesWithSpans binder)
+ in go e <> removeAndWarn bindNewNames (doElts rest v)
+
+ doElts (DoNotationLet ds : rest) v = onDecls ds (doElts rest v)
+
+ doElts (PositionedDoNotationElement _ _ e : rest) v = doElts (e : rest) v
+ doElts [] (Just e) = go e <> (rebindable, mempty)
+ doElts [] Nothing = (rebindable, mempty)
+
+ -- (non-recursively, recursively) bound idents in decl
+ declIdents :: Declaration -> (S.Set (SourceSpan, Ident), S.Set (SourceSpan, Ident))
+ declIdents (ValueDecl (ss,_) ident _ _ _) = (S.empty, S.singleton (ss, ident))
+ declIdents (BoundValueDeclaration _ binders _) = (S.fromList $ binderNamesWithSpans binders, S.empty)
+ declIdents _ = (S.empty, S.empty)
+
+ onDecls :: [ Declaration ] -> (S.Set Ident, MultipleErrors) -> (S.Set Ident, MultipleErrors)
+ onDecls ds errs =
+ let
+ onDecl d (accErrs, accLetNamesRec) =
+ let (letNames, recNames) = declIdents d
+ dErrs = underDecl d
+ errs' = dErrs <> removeAndWarn letNames accErrs
+ in
+ (errs', accLetNamesRec <> recNames)
+ (errs'', letNamesRec) = foldr onDecl (errs, S.empty) ds
+ in
+ removeAndWarn letNamesRec errs''
+
+ -- let f x = e -- check the x in e (but not the f)
+ underDecl (ValueDecl _ _ _ binders gexprs) =
+ let bindNewNames = S.fromList (concatMap binderNamesWithSpans binders)
+ allExprs = concatMap unguard gexprs
+ in
+ removeAndWarn bindNewNames $ foldr1 (<>) $ map go allExprs
+ -- let {x} = e -- no binding to check inside e
+ underDecl (BoundValueDeclaration _ _ expr) = go expr
+ underDecl _ = (mempty, mempty)
+
+ unguard (GuardedExpr guards expr) = map unguard' guards ++ [expr]
+ unguard' (ConditionGuard ee) = ee
+ unguard' (PatternGuard _ ee) = ee
+
+ removeAndWarn :: S.Set (SourceSpan, Ident) -> (S.Set Ident, MultipleErrors) -> (S.Set Ident, MultipleErrors)
+ removeAndWarn newNamesWithSpans (used, errors) =
+ let newNames = S.map snd newNamesWithSpans
+ filteredUsed = used `S.difference` newNames
+ warnUnused = S.filter (not . Text.isPrefixOf "_" . runIdent) (newNames `S.difference` used)
+ warnUnusedSpans = S.filter (\(_,ident) -> ident `elem` warnUnused) newNamesWithSpans
+ combinedErrors = if not $ S.null warnUnusedSpans then errors <> mconcat (map (\(ss,ident) -> errorMessage' ss $ UnusedName ident) $ S.toList warnUnusedSpans) else errors
+ in
+ (filteredUsed, combinedErrors)
diff --git a/src/Language/PureScript/Linter/Exhaustive.hs b/src/Language/PureScript/Linter/Exhaustive.hs
index 27562b435a..eb03da41e0 100644
--- a/src/Language/PureScript/Linter/Exhaustive.hs
+++ b/src/Language/PureScript/Linter/Exhaustive.hs
@@ -8,34 +8,29 @@ module Language.PureScript.Linter.Exhaustive
( checkExhaustiveExpr
) where
-import Prelude.Compat
+import Prelude
import Protolude (ordNub)
-import Control.Applicative
import Control.Arrow (first, second)
import Control.Monad (unless)
-import Control.Monad.Writer.Class
-import Control.Monad.Supply.Class (MonadSupply, fresh, freshName)
+import Control.Monad.Writer.Class (MonadWriter(..))
-import Data.Function (on)
-import Data.List (foldl', sortBy)
+import Data.List (foldl', sortOn)
import Data.Maybe (fromMaybe)
-import qualified Data.Map as M
-import Data.Text (Text)
-import qualified Data.Text as T
-
-import Language.PureScript.AST.Binders
-import Language.PureScript.AST.Declarations
-import Language.PureScript.AST.Literals
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Kinds
+import Data.Map qualified as M
+import Data.Text qualified as T
+
+import Language.PureScript.AST.Binders (Binder(..))
+import Language.PureScript.AST.Declarations (CaseAlternative(..), Expr(..), Guard(..), GuardedExpr(..), pattern MkUnguarded, isTrueExpr)
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.AST.Traversals (everywhereOnValuesM)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (DataDeclType, Environment(..), TypeKind(..))
+import Language.PureScript.Errors (MultipleErrors, pattern NullSourceAnn, SimpleErrorMessage(..), SourceSpan, errorMessage')
import Language.PureScript.Names as P
import Language.PureScript.Pretty.Values (prettyPrintBinderAtom)
-import Language.PureScript.Traversals
import Language.PureScript.Types as P
-import qualified Language.PureScript.Constants as C
+import Language.PureScript.Constants.Prim qualified as C
-- | There are two modes of failure for the redundancy check:
--
@@ -53,7 +48,7 @@ qualifyName
-> ModuleName
-> Qualified (ProperName b)
-> Qualified (ProperName a)
-qualifyName n defmn qn = Qualified (Just mn) n
+qualifyName n defmn qn = Qualified (ByModuleName mn) n
where
(mn, _) = qualify defmn qn
@@ -67,11 +62,11 @@ getConstructors :: Environment -> ModuleName -> Qualified (ProperName 'Construct
getConstructors env defmn n = extractConstructors lnte
where
- extractConstructors :: Maybe (SourceKind, TypeKind) -> [(ProperName 'ConstructorName, [SourceType])]
- extractConstructors (Just (_, DataType _ pt)) = pt
+ extractConstructors :: Maybe (SourceType, TypeKind) -> [(ProperName 'ConstructorName, [SourceType])]
+ extractConstructors (Just (_, DataType _ _ pt)) = pt
extractConstructors _ = internalError "Data name not in the scope of the current environment in extractConstructors"
- lnte :: Maybe (SourceKind, TypeKind)
+ lnte :: Maybe (SourceType, TypeKind)
lnte = M.lookup qpn (types env)
qpn :: Qualified (ProperName 'TypeName)
@@ -134,7 +129,7 @@ missingCasesSingle env mn (LiteralBinder _ (ObjectLiteral bs)) (LiteralBinder ss
where
(allMisses, pr) = uncurry (missingCasesMultiple env mn) (unzip binders)
- sortNames = sortBy (compare `on` fst)
+ sortNames = sortOn fst
(sbs, sbs') = (sortNames bs, sortNames bs')
@@ -207,7 +202,7 @@ missingCasesMultiple env mn = go
isExhaustiveGuard :: Environment -> ModuleName -> [GuardedExpr] -> Bool
isExhaustiveGuard _ _ [MkUnguarded _] = True
isExhaustiveGuard env moduleName gs =
- not . null $ filter (\(GuardedExpr grd _) -> isExhaustive grd) gs
+ any (\(GuardedExpr grd _) -> isExhaustive grd) gs
where
isExhaustive :: [Guard] -> Bool
isExhaustive = all checkGuard
@@ -240,7 +235,7 @@ missingAlternative env mn ca uncovered
--
checkExhaustive
:: forall m
- . (MonadWriter MultipleErrors m, MonadSupply m)
+ . MonadWriter MultipleErrors m
=> SourceSpan
-> Environment
-> ModuleName
@@ -258,7 +253,7 @@ checkExhaustive ss env mn numArgs cas expr = makeResult . first ordNub $ foldl'
in (missed', ( if null approx
then liftA2 (&&) cond nec
else Left Incomplete
- , if either (const True) id cond
+ , if and cond
then redundant
else caseAlternativeBinders ca : redundant
)
@@ -270,49 +265,22 @@ checkExhaustive ss env mn numArgs cas expr = makeResult . first ordNub $ foldl'
case rr of
Left Incomplete -> tellIncomplete
_ -> return ()
- if null bss
- then return expr
+ return $ if null bss
+ then expr
else addPartialConstraint (second null (splitAt 5 bss)) expr
where
tellRedundant = tell . errorMessage' ss . uncurry OverlappingPattern . second null . splitAt 5 $ bss'
tellIncomplete = tell . errorMessage' ss $ IncompleteExhaustivityCheck
- -- | We add a Partial constraint by adding a call to the following identity function:
- --
- -- partial :: forall a. Partial => a -> a
+ -- We add a Partial constraint by annotating the expression to have type `Partial => _`.
--
-- The binder information is provided so that it can be embedded in the constraint,
-- and then included in the error message.
- addPartialConstraint :: ([[Binder]], Bool) -> Expr -> m Expr
- addPartialConstraint (bss, complete) e = do
- tyVar <- ("p" <>) . T.pack . show <$> fresh
- var <- freshName
- return $
- Let
- FromLet
- [ partial var tyVar ]
- $ App (Var ss (Qualified Nothing UnusedIdent)) e
+ addPartialConstraint :: ([[Binder]], Bool) -> Expr -> Expr
+ addPartialConstraint (bss, complete) e =
+ TypedValue True e $
+ srcConstrainedType (srcConstraint C.Partial [] [] (Just constraintData)) $ TypeWildcard NullSourceAnn IgnoredWildcard
where
- partial :: Text -> Text -> Declaration
- partial var tyVar =
- ValueDecl (ss, []) UnusedIdent Private [] $
- [MkUnguarded
- (TypedValue
- True
- (Abs (VarBinder ss (Ident var)) (Var ss (Qualified Nothing (Ident var))))
- (ty tyVar))
- ]
-
- ty :: Text -> SourceType
- ty tyVar =
- srcForAll tyVar
- Nothing
- ( srcConstrainedType
- (srcConstraint C.Partial [] (Just constraintData))
- $ srcTypeApp (srcTypeApp tyFunction (srcTypeVar tyVar)) (srcTypeVar tyVar)
- )
- Nothing
-
constraintData :: ConstraintData
constraintData =
PartialConstraintData (map (map prettyPrintBinderAtom) bss) complete
@@ -322,43 +290,19 @@ checkExhaustive ss env mn numArgs cas expr = makeResult . first ordNub $ foldl'
--
checkExhaustiveExpr
:: forall m
- . (MonadWriter MultipleErrors m, MonadSupply m)
+ . MonadWriter MultipleErrors m
=> SourceSpan
-> Environment
-> ModuleName
-> Expr
-> m Expr
-checkExhaustiveExpr initSS env mn = onExpr initSS
+checkExhaustiveExpr ss env mn = onExpr'
where
- onDecl :: Declaration -> m Declaration
- onDecl (BindingGroupDeclaration bs) = BindingGroupDeclaration <$> mapM (\(sai@((ss, _), _), nk, expr) -> (sai, nk,) <$> onExpr ss expr) bs
- onDecl (ValueDecl sa@(ss, _) name x y [MkUnguarded e]) =
- ValueDecl sa name x y . mkUnguardedExpr <$> censor (addHint (ErrorInValueDeclaration name)) (onExpr ss e)
- onDecl decl = return decl
-
- onExpr :: SourceSpan -> Expr -> m Expr
- onExpr _ (UnaryMinus ss e) = UnaryMinus ss <$> onExpr ss e
- onExpr _ (Literal ss (ArrayLiteral es)) = Literal ss . ArrayLiteral <$> mapM (onExpr ss) es
- onExpr _ (Literal ss (ObjectLiteral es)) = Literal ss . ObjectLiteral <$> mapM (sndM (onExpr ss)) es
- onExpr ss (TypeClassDictionaryConstructorApp x e) = TypeClassDictionaryConstructorApp x <$> onExpr ss e
- onExpr ss (Accessor x e) = Accessor x <$> onExpr ss e
- onExpr ss (ObjectUpdate o es) = ObjectUpdate <$> onExpr ss o <*> mapM (sndM (onExpr ss)) es
- onExpr ss (Abs x e) = Abs x <$> onExpr ss e
- onExpr ss (App e1 e2) = App <$> onExpr ss e1 <*> onExpr ss e2
- onExpr ss (IfThenElse e1 e2 e3) = IfThenElse <$> onExpr ss e1 <*> onExpr ss e2 <*> onExpr ss e3
- onExpr ss (Case es cas) = do
- case' <- Case <$> mapM (onExpr ss) es <*> mapM (onCaseAlternative ss) cas
- checkExhaustive ss env mn (length es) cas case'
- onExpr ss (TypedValue x e y) = TypedValue x <$> onExpr ss e <*> pure y
- onExpr ss (Let w ds e) = Let w <$> mapM onDecl ds <*> onExpr ss e
- onExpr _ (PositionedValue ss x e) = PositionedValue ss x <$> onExpr ss e
- onExpr _ expr = return expr
-
- onCaseAlternative :: SourceSpan -> CaseAlternative -> m CaseAlternative
- onCaseAlternative ss (CaseAlternative x [MkUnguarded e]) = CaseAlternative x . mkUnguardedExpr <$> onExpr ss e
- onCaseAlternative ss (CaseAlternative x es) = CaseAlternative x <$> mapM (onGuardedExpr ss) es
-
- onGuardedExpr :: SourceSpan -> GuardedExpr -> m GuardedExpr
- onGuardedExpr ss (GuardedExpr guard rhs) = GuardedExpr guard <$> onExpr ss rhs
-
- mkUnguardedExpr = pure . MkUnguarded
+ (_, onExpr', _) = everywhereOnValuesM pure onExpr pure
+
+ onExpr :: Expr -> m Expr
+ onExpr e = case e of
+ Case es cas ->
+ checkExhaustive ss env mn (length es) cas e
+ _ ->
+ pure e
diff --git a/src/Language/PureScript/Linter/Imports.hs b/src/Language/PureScript/Linter/Imports.hs
index 3aa8bf6787..10f0aec7a7 100644
--- a/src/Language/PureScript/Linter/Imports.hs
+++ b/src/Language/PureScript/Linter/Imports.hs
@@ -4,30 +4,30 @@ module Language.PureScript.Linter.Imports
, UsedImports()
) where
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
+import Protolude (ordNub, tailDef, headDef)
import Control.Monad (join, unless, foldM, (<=<))
-import Control.Monad.Writer.Class
+import Control.Monad.Writer.Class (MonadWriter(..))
import Data.Function (on)
import Data.Foldable (for_)
-import Data.List (find, intersect, groupBy, sortBy, (\\))
+import Data.List (find, intersect, groupBy, sort, sortOn, (\\))
import Data.Maybe (mapMaybe)
import Data.Monoid (Sum(..))
import Data.Traversable (forM)
-import qualified Data.Text as T
-import qualified Data.Map as M
+import Data.Text qualified as T
+import Data.Map qualified as M
-import Language.PureScript.AST.Declarations
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Crash
-import Language.PureScript.Errors
+import Language.PureScript.AST.Declarations (Declaration(..), DeclarationRef(..), ExportSource, ImportDeclarationType(..), Module(..), getTypeRef, isExplicit)
+import Language.PureScript.AST.SourcePos (SourceSpan)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), errorMessage')
import Language.PureScript.Names
import Language.PureScript.Sugar.Names.Common (warnDuplicateRefs)
-import Language.PureScript.Sugar.Names.Env
-import Language.PureScript.Sugar.Names.Imports
-import qualified Language.PureScript.Constants as C
+import Language.PureScript.Sugar.Names.Env (Env, Exports(..), ImportRecord(..), Imports(..), envModuleExports, nullImports)
+import Language.PureScript.Sugar.Names.Imports (ImportDef, findImports)
+import Language.PureScript.Constants.Prim qualified as C
-- |
-- Map of module name to list of imported names from that module which have
@@ -91,10 +91,10 @@ lintImports (Module _ _ mn mdecls (Just mexports)) env usedImps = do
let unwarned = imps \\ warned
duplicates
= join
- . map tail
+ . map (tailDef $ internalError "lintImports: duplicates")
. filter ((> 1) . length)
. groupBy ((==) `on` defQual)
- . sortBy (compare `on` defQual)
+ . sortOn defQual
$ unwarned
for_ duplicates $ \(pos, _, _) ->
@@ -142,7 +142,7 @@ lintImports (Module _ _ mn mdecls (Just mexports)) env usedImps = do
-- Checks whether a module is the Prim module - used to suppress any checks
-- made, as Prim is always implicitly imported.
isPrim :: ModuleName -> Bool
- isPrim = (== ModuleName [ProperName C.prim])
+ isPrim = (== C.M_Prim)
-- Creates a map of virtual modules mapped to all the declarations that
-- import to that module, with the corresponding source span, import type,
@@ -195,14 +195,14 @@ lintImports (Module _ _ mn mdecls (Just mexports)) env usedImps = do
Just (Qualified _ name) -> Just (k, Qualified mnq (toName name))
_ -> Nothing
| isQualifiedWith k q =
- case importName (head is) of
- Qualified (Just mn') name -> Just (mn', Qualified mnq (toName name))
+ case importName (headDef (internalError "extractByQual: empty import list") is) of
+ Qualified (ByModuleName mn') name -> Just (mn', Qualified mnq (toName name))
_ -> internalError "unqualified name in extractByQual"
go _ = Nothing
-- Replace explicit type refs with data constructor lists from listing the
--- used constructors explicity `T(X, Y, [...])` to `T(..)` for suggestion
+-- used constructors explicitly `T(X, Y, [...])` to `T(..)` for suggestion
-- message.
-- Done everywhere when suggesting a completely new explicit imports list, otherwise
-- maintain the existing form.
@@ -279,7 +279,7 @@ lintImportDecl env mni qualifierName names ss declType allowImplicit =
isMatch _ _ = False
unused :: m Bool
- unused = warn (UnusedImport mni)
+ unused = warn (UnusedImport mni qualifierName)
warn :: SimpleErrorMessage -> m Bool
warn err = tell (errorMessage' ss err) >> return True
@@ -300,7 +300,7 @@ lintImportDecl env mni qualifierName names ss declType allowImplicit =
dtys
:: ModuleName
-> M.Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ExportSource)
- dtys mn = maybe M.empty exportedTypes $ envModuleExports <$> mn `M.lookup` env
+ dtys mn = foldMap (exportedTypes . envModuleExports) $ mn `M.lookup` env
dctorsForType
:: ModuleName
@@ -328,14 +328,13 @@ findUsedRefs ss env mni qn names =
valueOpRefs = ValueOpRef ss <$> mapMaybe (getValOpName <=< disqualifyFor qn) names
typeOpRefs = TypeOpRef ss <$> mapMaybe (getTypeOpName <=< disqualifyFor qn) names
types = mapMaybe (getTypeName <=< disqualifyFor qn) names
- kindRefs = KindRef ss <$> mapMaybe (getKindName <=< disqualifyFor qn) names
dctors = mapMaybe (getDctorName <=< disqualifyFor qn) names
typesWithDctors = reconstructTypeRefs dctors
typesWithoutDctors = filter (`M.notMember` typesWithDctors) types
typesRefs
= map (flip (TypeRef ss) (Just [])) typesWithoutDctors
++ map (\(ty, ds) -> TypeRef ss ty (Just ds)) (M.toList typesWithDctors)
- in sortBy compDecRef $ classRefs ++ typeOpRefs ++ typesRefs ++ kindRefs ++ valueRefs ++ valueOpRefs
+ in sort $ classRefs ++ typeOpRefs ++ typesRefs ++ valueRefs ++ valueOpRefs
where
diff --git a/src/Language/PureScript/Linter/Wildcards.hs b/src/Language/PureScript/Linter/Wildcards.hs
new file mode 100644
index 0000000000..a8b5fcf23e
--- /dev/null
+++ b/src/Language/PureScript/Linter/Wildcards.hs
@@ -0,0 +1,47 @@
+module Language.PureScript.Linter.Wildcards
+ ( ignoreWildcardsUnderCompleteTypeSignatures
+ ) where
+
+import Protolude hiding (Type)
+
+import Language.PureScript.AST (Binder(..), Declaration, Expr(..), everywhereWithContextOnValues)
+import Language.PureScript.Types (Type(..), WildcardData(..), everythingOnTypes, everywhereOnTypes)
+
+-- |
+-- Replaces `TypeWildcard _ UnnamedWildcard` with
+-- `TypeWildcard _ IgnoredWildcard` in places where we don't want to emit a
+-- warning about wildcards.
+--
+-- The guiding principle here is that a wildcard can be ignored if there is a
+-- complete (wildcard-free) type signature on a binding somewhere between the
+-- type in which the wildcard occurs and the top level of the module. In
+-- particular, this means that top-level signatures containing wildcards are
+-- always warnings, and a top-level signature always prevents wildcards on
+-- inner bindings from emitting warnings.
+--
+ignoreWildcardsUnderCompleteTypeSignatures :: Declaration -> Declaration
+ignoreWildcardsUnderCompleteTypeSignatures = onDecl
+ where
+ (onDecl, _, _, _, _, _) = everywhereWithContextOnValues False (,) handleExpr handleBinder (,) (,) (,)
+
+ handleExpr isCovered = \case
+ tv@(TypedValue chk v ty)
+ | isCovered -> (True, TypedValue chk v $ ignoreWildcards ty)
+ | otherwise -> (isComplete ty, tv)
+ other -> (isCovered, other)
+
+ handleBinder isCovered = \case
+ tb@(TypedBinder ty b)
+ | isCovered -> (True, TypedBinder (ignoreWildcards ty) b)
+ | otherwise -> (isComplete ty, tb)
+ other -> (isCovered, other)
+
+ignoreWildcards :: Type a -> Type a
+ignoreWildcards = everywhereOnTypes $ \case
+ TypeWildcard a UnnamedWildcard -> TypeWildcard a IgnoredWildcard
+ other -> other
+
+isComplete :: Type a -> Bool
+isComplete = everythingOnTypes (&&) $ \case
+ TypeWildcard{} -> False
+ _ -> True
diff --git a/src/Language/PureScript/Make.hs b/src/Language/PureScript/Make.hs
index abc2914ef5..5228dc86e6 100644
--- a/src/Language/PureScript/Make.hs
+++ b/src/Language/PureScript/Make.hs
@@ -2,68 +2,108 @@ module Language.PureScript.Make
(
-- * Make API
rebuildModule
+ , rebuildModule'
, make
, inferForeignModules
, module Monad
, module Actions
) where
-import Prelude.Compat
-
-import Control.Concurrent.Lifted as C
-import Control.Monad hiding (sequence)
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.IO.Class
-import Control.Monad.Supply
-import Control.Monad.Trans.Control (MonadBaseControl(..))
-import Control.Monad.Writer.Class (MonadWriter(..))
-import Data.Aeson (encode)
-import Data.Function (on)
-import Data.Foldable (for_)
-import Data.List (foldl', sortBy)
-import qualified Data.List.NonEmpty as NEL
-import Data.Maybe (fromMaybe)
-import qualified Data.Map as M
-import qualified Data.Set as S
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import qualified Language.PureScript.CST as CST
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Externs
-import Language.PureScript.Linter
-import Language.PureScript.ModuleDependencies
-import Language.PureScript.Names
-import Language.PureScript.Renamer
-import Language.PureScript.Sugar
-import Language.PureScript.TypeChecker
-import Language.PureScript.Make.BuildPlan
-import qualified Language.PureScript.Make.BuildPlan as BuildPlan
-import Language.PureScript.Make.Actions as Actions
-import Language.PureScript.Make.Monad as Monad
-import qualified Language.PureScript.CoreFn as CF
-import System.Directory (doesFileExist)
-import System.FilePath (replaceExtension)
+import Prelude
+
+import Control.Concurrent.Lifted as C
+import Control.DeepSeq (force)
+import Control.Exception.Lifted (onException, bracket_, evaluate)
+import Control.Monad (foldM, unless, when, (<=<))
+import Control.Monad.Base (MonadBase(liftBase))
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.IO.Class (MonadIO(..))
+import Control.Monad.Supply (evalSupplyT, runSupply, runSupplyT)
+import Control.Monad.Trans.Control (MonadBaseControl(..))
+import Control.Monad.Trans.State (runStateT)
+import Control.Monad.Writer.Class (MonadWriter(..), censor)
+import Control.Monad.Writer.Strict (runWriterT)
+import Data.Function (on)
+import Data.Foldable (fold, for_)
+import Data.List (foldl', sortOn)
+import Data.List.NonEmpty qualified as NEL
+import Data.Maybe (fromMaybe)
+import Data.Map qualified as M
+import Data.Set qualified as S
+import Data.Text qualified as T
+import Debug.Trace (traceMarkerIO)
+import Language.PureScript.AST (ErrorMessageHint(..), Module(..), SourceSpan(..), getModuleName, getModuleSourceSpan, importPrim)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Docs.Convert qualified as Docs
+import Language.PureScript.Environment (initEnvironment)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, defaultPPEOptions, errorMessage', errorMessage'', prettyPrintMultipleErrors)
+import Language.PureScript.Externs (ExternsFile, applyExternsFileToEnvironment, moduleToExternsFile)
+import Language.PureScript.Linter (Name(..), lint, lintImports)
+import Language.PureScript.ModuleDependencies (DependencyDepth(..), moduleSignature, sortModules)
+import Language.PureScript.Names (ModuleName, isBuiltinModuleName, runModuleName)
+import Language.PureScript.Renamer (renameInModule)
+import Language.PureScript.Sugar (Env, collapseBindingGroups, createBindingGroups, desugar, desugarCaseGuards, externsEnv, primEnv)
+import Language.PureScript.TypeChecker (CheckState(..), emptyCheckState, typeCheckModule)
+import Language.PureScript.Make.BuildPlan (BuildJobResult(..), BuildPlan(..), getResult)
+import Language.PureScript.Make.BuildPlan qualified as BuildPlan
+import Language.PureScript.Make.Cache qualified as Cache
+import Language.PureScript.Make.Actions as Actions
+import Language.PureScript.Make.Monad as Monad
+import Language.PureScript.CoreFn qualified as CF
+import System.Directory (doesFileExist)
+import System.FilePath (replaceExtension)
-- | Rebuild a single module.
--
-- This function is used for fast-rebuild workflows (PSCi and psc-ide are examples).
rebuildModule
:: forall m
- . (Monad m, MonadBaseControl IO m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
+ => MakeActions m
+ -> [ExternsFile]
+ -> Module
+ -> m ExternsFile
+rebuildModule actions externs m = do
+ env <- fmap fst . runWriterT $ foldM externsEnv primEnv externs
+ rebuildModule' actions env externs m
+
+rebuildModule'
+ :: forall m
+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
+ => MakeActions m
+ -> Env
+ -> [ExternsFile]
+ -> Module
+ -> m ExternsFile
+rebuildModule' act env ext mdl = rebuildModuleWithIndex act env ext mdl Nothing
+
+rebuildModuleWithIndex
+ :: forall m
+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
=> MakeActions m
+ -> Env
-> [ExternsFile]
-> Module
+ -> Maybe (Int, Int)
-> m ExternsFile
-rebuildModule MakeActions{..} externs m@(Module _ _ moduleName _ _) = do
- progress $ CompilingModule moduleName
+rebuildModuleWithIndex MakeActions{..} exEnv externs m@(Module _ _ moduleName _ _) moduleIndex = do
+ progress $ CompilingModule moduleName moduleIndex
let env = foldl' (flip applyExternsFileToEnvironment) initEnvironment externs
withPrim = importPrim m
lint withPrim
+
((Module ss coms _ elaborated exps, env'), nextVar) <- runSupplyT 0 $ do
- desugar externs [withPrim] >>= \case
- [desugared] -> runCheck' (emptyCheckState env) $ typeCheckModule desugared
- _ -> internalError "desugar did not return a singleton"
+ (desugared, (exEnv', usedImports)) <- runStateT (desugar externs withPrim) (exEnv, mempty)
+ let modulesExports = (\(_, _, exports) -> exports) <$> exEnv'
+ (checked, CheckState{..}) <- runStateT (typeCheckModule modulesExports desugared) $ emptyCheckState env
+ let usedImports' = foldl' (flip $ \(fromModuleName, newtypeCtorName) ->
+ M.alter (Just . (fmap DctorName newtypeCtorName :) . fold) fromModuleName) usedImports checkConstructorImportsForCoercible
+ -- Imports cannot be linted before type checking because we need to
+ -- known which newtype constructors are used to solve Coercible
+ -- constraints in order to not report them as unused.
+ censor (addHint (ErrorInModule moduleName)) $ lintImports checked exEnv' usedImports'
+ return (checked, checkEnv)
-- desugar case declarations *after* type- and exhaustiveness checking
-- since pattern guards introduces cases which the exhaustiveness checker
@@ -74,50 +114,98 @@ rebuildModule MakeActions{..} externs m@(Module _ _ moduleName _ _) = do
regrouped <- createBindingGroups moduleName . collapseBindingGroups $ deguarded
let mod' = Module ss coms moduleName regrouped exps
corefn = CF.moduleToCoreFn env' mod'
- optimized = CF.optimizeCoreFn corefn
- [renamed] = renameInModules [optimized]
- exts = moduleToExternsFile mod' env'
+ (optimized, nextVar'') = runSupply nextVar' $ CF.optimizeCoreFn corefn
+ (renamedIdents, renamed) = renameInModule optimized
+ exts = moduleToExternsFile mod' env' renamedIdents
ffiCodegen renamed
- evalSupplyT nextVar' . codegen renamed env' . encode $ exts
+
+ -- It may seem more obvious to write `docs <- Docs.convertModule m env' here,
+ -- but I have not done so for two reasons:
+ -- 1. This should never fail; any genuine errors in the code should have been
+ -- caught earlier in this function. Therefore if we do fail here it indicates
+ -- a bug in the compiler, which should be reported as such.
+ -- 2. We do not want to perform any extra work generating docs unless the
+ -- user has asked for docs to be generated.
+ let docs = case Docs.convertModule externs exEnv env' m of
+ Left errs -> internalError $
+ "Failed to produce docs for " ++ T.unpack (runModuleName moduleName)
+ ++ "; details:\n" ++ prettyPrintMultipleErrors defaultPPEOptions errs
+ Right d -> d
+
+ evalSupplyT nextVar'' $ codegen renamed docs exts
return exts
--- | Compiles in "make" mode, compiling each module separately to a @.js@ file and an @externs.json@ file.
+-- | Compiles in "make" mode, compiling each module separately to a @.js@ file and an @externs.cbor@ file.
--
--- If timestamps have not changed, the externs file can be used to provide the module's types without
--- having to typecheck the module again.
-make :: forall m. (Monad m, MonadBaseControl IO m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
+-- If timestamps or hashes have not changed, existing externs files can be used to provide upstream modules' types without
+-- having to typecheck those modules again.
+make :: forall m. (MonadBaseControl IO m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
=> MakeActions m
-> [CST.PartialResult Module]
-> m [ExternsFile]
make ma@MakeActions{..} ms = do
checkModuleNames
+ cacheDb <- readCacheDb
- (sorted, graph) <- sortModules (moduleSignature . CST.resPartial) ms
+ (sorted, graph) <- sortModules Transitive (moduleSignature . CST.resPartial) ms
- buildPlan <- BuildPlan.construct ma (sorted, graph)
+ (buildPlan, newCacheDb) <- BuildPlan.construct ma cacheDb (sorted, graph)
+
+ -- Limit concurrent module builds to the number of capabilities as
+ -- (by default) inferred from `+RTS -N -RTS` or set explicitly like `-N4`.
+ -- This is to ensure that modules complete fully before moving on, to avoid
+ -- holding excess memory during compilation from modules that were paused
+ -- by the Haskell runtime.
+ capabilities <- getNumCapabilities
+ let concurrency = max 1 capabilities
+ lock <- C.newQSem concurrency
let toBeRebuilt = filter (BuildPlan.needsRebuild buildPlan . getModuleName . CST.resPartial) sorted
+ let totalModuleCount = length toBeRebuilt
for_ toBeRebuilt $ \m -> fork $ do
let moduleName = getModuleName . CST.resPartial $ m
let deps = fromMaybe (internalError "make: module not found in dependency graph.") (lookup moduleName graph)
- buildModule buildPlan moduleName
+ buildModule lock buildPlan moduleName totalModuleCount
(spanName . getModuleSourceSpan . CST.resPartial $ m)
- (importPrim <$> CST.resFull m)
+ (fst $ CST.resFull m)
+ (fmap importPrim . snd $ CST.resFull m)
(deps `inOrderOf` map (getModuleName . CST.resPartial) sorted)
- -- Wait for all threads to complete, and collect errors.
- errors <- BuildPlan.collectErrors buildPlan
+ -- Prevent hanging on other modules when there is an internal error
+ -- (the exception is thrown, but other threads waiting on MVars are released)
+ `onException` BuildPlan.markComplete buildPlan moduleName (BuildJobFailed mempty)
+
+ -- Wait for all threads to complete, and collect results (and errors).
+ (failures, successes) <-
+ let
+ splitResults = \case
+ BuildJobSucceeded _ exts ->
+ Right exts
+ BuildJobFailed errs ->
+ Left errs
+ BuildJobSkipped ->
+ Left mempty
+ in
+ M.mapEither splitResults <$> BuildPlan.collectResults buildPlan
+
+ -- Write the updated build cache database to disk
+ writeCacheDb $ Cache.removeModules (M.keysSet failures) newCacheDb
+
+ writePackageJson
+
+ -- If generating docs, also generate them for the Prim modules
+ outputPrimDocs
-- All threads have completed, rethrow any caught errors.
+ let errors = M.elems failures
unless (null errors) $ throwError (mconcat errors)
- -- Collect all ExternsFiles
- results <- BuildPlan.collectResults buildPlan
-
-- Here we return all the ExternsFile in the ordering of the topological sort,
-- so they can be folded into an Environment. This result is used in the tests
-- and in PSCI.
- let lookupResult mn = fromMaybe (internalError "make: module not found in results") (M.lookup mn results)
+ let lookupResult mn =
+ fromMaybe (internalError "make: module not found in results")
+ $ M.lookup mn successes
return (map (lookupResult . getModuleName . CST.resPartial) sorted)
where
@@ -143,7 +231,7 @@ make ma@MakeActions{..} ms = do
-- Find all groups of duplicate values in a list based on a projection.
findDuplicates :: Ord b => (a -> b) -> [a] -> Maybe [NEL.NonEmpty a]
findDuplicates f xs =
- case filter ((> 1) . length) . NEL.groupBy ((==) `on` f) . sortBy (compare `on` f) $ xs of
+ case filter ((> 1) . length) . NEL.groupBy ((==) `on` f) . sortOn f $ xs of
[] -> Nothing
xss -> Just xss
@@ -151,22 +239,48 @@ make ma@MakeActions{..} ms = do
inOrderOf :: (Ord a) => [a] -> [a] -> [a]
inOrderOf xs ys = let s = S.fromList xs in filter (`S.member` s) ys
- buildModule :: BuildPlan -> ModuleName -> FilePath -> Either (NEL.NonEmpty CST.ParserError) Module -> [ModuleName] -> m ()
- buildModule buildPlan moduleName fp mres deps = flip catchError (complete Nothing . Just) $ do
- m <- CST.unwrapParserError fp mres
- -- We need to wait for dependencies to be built, before checking if the current
- -- module should be rebuilt, so the first thing to do is to wait on the
- -- MVars for the module's dependencies.
- mexterns <- fmap unzip . sequence <$> traverse (getResult buildPlan) deps
-
- case mexterns of
- Just (_, externs) -> do
- (exts, warnings) <- listen $ rebuildModule ma externs m
- complete (Just (warnings, exts)) Nothing
- Nothing -> complete Nothing Nothing
- where
- complete :: Maybe (MultipleErrors, ExternsFile) -> Maybe MultipleErrors -> m ()
- complete = BuildPlan.markComplete buildPlan moduleName
+ buildModule :: QSem -> BuildPlan -> ModuleName -> Int -> FilePath -> [CST.ParserWarning] -> Either (NEL.NonEmpty CST.ParserError) Module -> [ModuleName] -> m ()
+ buildModule lock buildPlan moduleName cnt fp pwarnings mres deps = do
+ result <- flip catchError (return . BuildJobFailed) $ do
+ let pwarnings' = CST.toMultipleWarnings fp pwarnings
+ tell pwarnings'
+ m <- CST.unwrapParserError fp mres
+ -- We need to wait for dependencies to be built, before checking if the current
+ -- module should be rebuilt, so the first thing to do is to wait on the
+ -- MVars for the module's dependencies.
+ mexterns <- fmap unzip . sequence <$> traverse (getResult buildPlan) deps
+
+ case mexterns of
+ Just (_, externs) -> do
+ -- We need to ensure that all dependencies have been included in Env
+ C.modifyMVar_ (bpEnv buildPlan) $ \env -> do
+ let
+ go :: Env -> ModuleName -> m Env
+ go e dep = case lookup dep (zip deps externs) of
+ Just exts
+ | not (M.member dep e) -> externsEnv e exts
+ _ -> return e
+ foldM go env deps
+ env <- C.readMVar (bpEnv buildPlan)
+ idx <- C.takeMVar (bpIndex buildPlan)
+ C.putMVar (bpIndex buildPlan) (idx + 1)
+
+ -- Bracket all of the per-module work behind the semaphore, including
+ -- forcing the result. This is done to limit concurrency and keep
+ -- memory usage down; see comments above.
+ (exts, warnings) <- bracket_ (C.waitQSem lock) (C.signalQSem lock) $ do
+ -- Eventlog markers for profiling; see debug/eventlog.js
+ liftBase $ traceMarkerIO $ T.unpack (runModuleName moduleName) <> " start"
+ -- Force the externs and warnings to avoid retaining excess module
+ -- data after the module is finished compiling.
+ extsAndWarnings <- evaluate . force <=< listen $ do
+ rebuildModuleWithIndex ma env externs m (Just (idx, cnt))
+ liftBase $ traceMarkerIO $ T.unpack (runModuleName moduleName) <> " end"
+ return extsAndWarnings
+ return $ BuildJobSucceeded (pwarnings' <> warnings) exts
+ Nothing -> return BuildJobSkipped
+
+ BuildPlan.markComplete buildPlan moduleName result
-- | Infer the module name for a module by looking for the same filename with
-- a .js extension.
diff --git a/src/Language/PureScript/Make/Actions.hs b/src/Language/PureScript/Make/Actions.hs
index f7c6d5eaee..f138327c8d 100644
--- a/src/Language/PureScript/Make/Actions.hs
+++ b/src/Language/PureScript/Make/Actions.hs
@@ -1,58 +1,63 @@
module Language.PureScript.Make.Actions
( MakeActions(..)
, RebuildPolicy(..)
- , Externs()
, ProgressMessage(..)
+ , renderProgressMessage
, buildMakeActions
, checkForeignDecls
+ , cacheDbFile
+ , readCacheDb'
+ , writeCacheDb'
+ , ffiCodegen'
) where
-import Prelude
-
-import Control.Monad hiding (sequence)
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.IO.Class
-import Control.Monad.Reader (asks)
-import Control.Monad.Supply
-import Control.Monad.Trans.Class (MonadTrans(..))
-import Control.Monad.Writer.Class (MonadWriter(..))
-import Data.Aeson (encode)
-import qualified Data.ByteString.Lazy as B
-import qualified Data.ByteString.Lazy as LB
-import qualified Data.ByteString.Lazy.UTF8 as LBU8
-import Data.Either (partitionEithers)
-import Data.Foldable (for_, minimum)
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Map as M
-import Data.Maybe (fromMaybe)
-import qualified Data.Set as S
-import qualified Data.Text as T
-import qualified Data.Text.Encoding as TE
-import Data.Time.Clock (UTCTime)
-import Data.Version (showVersion)
-import qualified Language.JavaScript.Parser as JS
-import Language.PureScript.AST
-import qualified Language.PureScript.Bundle as Bundle
-import qualified Language.PureScript.CodeGen.JS as J
-import Language.PureScript.CodeGen.JS.Printer
-import qualified Language.PureScript.CoreFn as CF
-import qualified Language.PureScript.CoreFn.ToJSON as CFJ
-import qualified Language.PureScript.CoreImp.AST as Imp
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Make.Monad
-import Language.PureScript.Names
-import Language.PureScript.Names (runModuleName, ModuleName)
-import Language.PureScript.Options hiding (codegenTargets)
-import qualified Language.PureScript.Parser as PSParser
-import Language.PureScript.Pretty.Common (SMap(..))
-import qualified Paths_purescript as Paths
-import SourceMap
-import SourceMap.Types
-import System.Directory (doesFileExist, getModificationTime, createDirectoryIfMissing, getCurrentDirectory)
-import System.FilePath ((>), takeDirectory, makeRelative, splitPath, normalise)
-import qualified Text.Parsec as Parsec
+import Prelude
+
+import Control.Monad (unless, when)
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.IO.Class (MonadIO(..))
+import Control.Monad.Reader (asks)
+import Control.Monad.Supply (SupplyT)
+import Control.Monad.Trans.Class (MonadTrans(..))
+import Control.Monad.Writer.Class (MonadWriter(..))
+import Data.Aeson (Value(String), (.=), object)
+import Data.Bifunctor (bimap, first)
+import Data.Either (partitionEithers)
+import Data.Foldable (for_)
+import Data.List.NonEmpty qualified as NEL
+import Data.Map qualified as M
+import Data.Maybe (fromMaybe, maybeToList)
+import Data.Set qualified as S
+import Data.Text qualified as T
+import Data.Text.IO qualified as TIO
+import Data.Text.Encoding qualified as TE
+import Data.Time.Clock (UTCTime)
+import Data.Version (showVersion)
+import Language.JavaScript.Parser qualified as JS
+import Language.PureScript.AST (SourcePos(..))
+import Language.PureScript.Bundle qualified as Bundle
+import Language.PureScript.CodeGen.JS qualified as J
+import Language.PureScript.CodeGen.JS.Printer (prettyPrintJS, prettyPrintJSWithSourceMaps)
+import Language.PureScript.CoreFn qualified as CF
+import Language.PureScript.CoreFn.ToJSON qualified as CFJ
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Docs.Prim qualified as Docs.Prim
+import Language.PureScript.Docs.Types qualified as Docs
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), errorMessage, errorMessage')
+import Language.PureScript.Externs (ExternsFile, externsFileName)
+import Language.PureScript.Make.Monad (Make, copyFile, getTimestamp, getTimestampMaybe, hashFile, makeIO, readExternsFile, readJSONFile, readTextFile, writeCborFile, writeJSONFile, writeTextFile)
+import Language.PureScript.Make.Cache (CacheDb, ContentHash, normaliseForCache)
+import Language.PureScript.Names (Ident(..), ModuleName, runModuleName)
+import Language.PureScript.Options (CodegenTarget(..), Options(..))
+import Language.PureScript.Pretty.Common (SMap(..))
+import Paths_purescript qualified as Paths
+import SourceMap (generate)
+import SourceMap.Types (Mapping(..), Pos(..), SourceMapping(..))
+import System.Directory (getCurrentDirectory)
+import System.FilePath ((>), makeRelative, splitPath, normalise, splitDirectories)
+import System.FilePath.Posix qualified as Posix
+import System.IO (stderr)
-- | Determines when to rebuild a module
data RebuildPolicy
@@ -64,16 +69,25 @@ data RebuildPolicy
-- | Progress messages from the make process
data ProgressMessage
- = CompilingModule ModuleName
+ = CompilingModule ModuleName (Maybe (Int, Int))
-- ^ Compilation started for the specified module
deriving (Show, Eq, Ord)
--- | Generated code for an externs file.
-type Externs = LB.ByteString
-
-- | Render a progress message
-renderProgressMessage :: ProgressMessage -> String
-renderProgressMessage (CompilingModule mn) = "Compiling " ++ T.unpack (runModuleName mn)
+renderProgressMessage :: T.Text -> ProgressMessage -> T.Text
+renderProgressMessage infx (CompilingModule mn mi) =
+ T.concat
+ [ renderProgressIndex mi
+ , infx
+ , runModuleName mn
+ ]
+ where
+ renderProgressIndex :: Maybe (Int, Int) -> T.Text
+ renderProgressIndex = maybe "" $ \(start, end) ->
+ let start' = T.pack (show start)
+ end' = T.pack (show end)
+ preSpace = T.replicate (T.length end' - T.length start') " "
+ in "[" <> preSpace <> start' <> " of " <> end' <> "] "
-- | Actions that require implementations when running in "make" mode.
--
@@ -83,25 +97,71 @@ renderProgressMessage (CompilingModule mn) = "Compiling " ++ T.unpack (runModule
--
-- * The details of how files are read/written etc.
data MakeActions m = MakeActions
- { getInputTimestamp :: ModuleName -> m (Either RebuildPolicy (Maybe UTCTime))
- -- ^ Get the timestamp for the input file(s) for a module. If there are multiple
- -- files (@.purs@ and foreign files, for example) the timestamp should be for
- -- the most recently modified file.
+ { getInputTimestampsAndHashes :: ModuleName -> m (Either RebuildPolicy (M.Map FilePath (UTCTime, m ContentHash)))
+ -- ^ Get the timestamps and content hashes for the input files for a module.
+ -- The content hash is returned as a monadic action so that the file does not
+ -- have to be read if it's not necessary.
, getOutputTimestamp :: ModuleName -> m (Maybe UTCTime)
- -- ^ Get the timestamp for the output files for a module. This should be the
- -- timestamp for the oldest modified file, or 'Nothing' if any of the required
- -- output files are missing.
- , readExterns :: ModuleName -> m (FilePath, Externs)
+ -- ^ Get the time this module was last compiled, provided that all of the
+ -- requested codegen targets were also produced then. The defaultMakeActions
+ -- implementation uses the modification time of the externs file, because the
+ -- externs file is written first and we always write one. If there is no
+ -- externs file, or if any of the requested codegen targets were not produced
+ -- the last time this module was compiled, this function must return Nothing;
+ -- this indicates that the module will have to be recompiled.
+ , readExterns :: ModuleName -> m (FilePath, Maybe ExternsFile)
-- ^ Read the externs file for a module as a string and also return the actual
-- path for the file.
- , codegen :: CF.Module CF.Ann -> Environment -> Externs -> SupplyT m ()
+ , codegen :: CF.Module CF.Ann -> Docs.Module -> ExternsFile -> SupplyT m ()
-- ^ Run the code generator for the module and write any required output files.
, ffiCodegen :: CF.Module CF.Ann -> m ()
-- ^ Check ffi and print it in the output directory.
, progress :: ProgressMessage -> m ()
-- ^ Respond to a progress update.
+ , readCacheDb :: m CacheDb
+ -- ^ Read the cache database (which contains timestamps and hashes for input
+ -- files) from some external source, e.g. a file on disk.
+ , writeCacheDb :: CacheDb -> m ()
+ -- ^ Write the given cache database to some external source (e.g. a file on
+ -- disk).
+ , writePackageJson :: m ()
+ -- ^ Write to the output directory the package.json file allowing Node.js to
+ -- load .js files as ES modules.
+ , outputPrimDocs :: m ()
+ -- ^ If generating docs, output the documentation for the Prim modules
}
+-- | Given the output directory, determines the location for the
+-- CacheDb file
+cacheDbFile :: FilePath -> FilePath
+cacheDbFile = (> "cache-db.json")
+
+readCacheDb'
+ :: (MonadIO m, MonadError MultipleErrors m)
+ => FilePath
+ -- ^ The path to the output directory
+ -> m CacheDb
+readCacheDb' outputDir =
+ fromMaybe mempty <$> readJSONFile (cacheDbFile outputDir)
+
+writeCacheDb'
+ :: (MonadIO m, MonadError MultipleErrors m)
+ => FilePath
+ -- ^ The path to the output directory
+ -> CacheDb
+ -- ^ The CacheDb to be written
+ -> m ()
+writeCacheDb' = writeJSONFile . cacheDbFile
+
+writePackageJson'
+ :: (MonadIO m, MonadError MultipleErrors m)
+ => FilePath
+ -- ^ The path to the output directory
+ -> m ()
+writePackageJson' outputDir = writeJSONFile (outputDir > "package.json") $ object
+ [ "type" .= String "module"
+ ]
+
-- | A set of make actions that read and write modules from the given directory.
buildMakeActions
:: FilePath
@@ -114,15 +174,25 @@ buildMakeActions
-- ^ Generate a prefix comment?
-> MakeActions Make
buildMakeActions outputDir filePathMap foreigns usePrefix =
- MakeActions getInputTimestamp getOutputTimestamp readExterns codegen ffiCodegen progress
+ MakeActions getInputTimestampsAndHashes getOutputTimestamp readExterns codegen ffiCodegen progress readCacheDb writeCacheDb writePackageJson outputPrimDocs
where
- getInputTimestamp :: ModuleName -> Make (Either RebuildPolicy (Maybe UTCTime))
- getInputTimestamp mn = do
+ getInputTimestampsAndHashes
+ :: ModuleName
+ -> Make (Either RebuildPolicy (M.Map FilePath (UTCTime, Make ContentHash)))
+ getInputTimestampsAndHashes mn = do
let path = fromMaybe (internalError "Module has no filename in 'make'") $ M.lookup mn filePathMap
- e1 <- traverse getTimestamp path
- fPath <- maybe (return Nothing) getTimestamp $ M.lookup mn foreigns
- return $ fmap (max fPath) e1
+ case path of
+ Left policy ->
+ return (Left policy)
+ Right filePath -> do
+ cwd <- makeIO "Getting the current directory" getCurrentDirectory
+ let inputPaths = map (normaliseForCache cwd) (filePath : maybeToList (M.lookup mn foreigns))
+ getInfo fp = do
+ ts <- getTimestamp fp
+ return (ts, hashFile fp)
+ pathsWithInfo <- traverse (\fp -> (fp,) <$> getInfo fp) inputPaths
+ return $ Right $ M.fromList pathsWithInfo
outputFilename :: ModuleName -> String -> FilePath
outputFilename mn fn =
@@ -134,39 +204,67 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
JS -> outputFilename mn "index.js"
JSSourceMap -> outputFilename mn "index.js.map"
CoreFn -> outputFilename mn "corefn.json"
+ Docs -> outputFilename mn "docs.json"
getOutputTimestamp :: ModuleName -> Make (Maybe UTCTime)
getOutputTimestamp mn = do
codegenTargets <- asks optionsCodegenTargets
- let outputPaths = [outputFilename mn "externs.json"] <> fmap (targetFilename mn) (S.toList codegenTargets)
- timestamps <- traverse getTimestamp outputPaths
- pure $ fmap minimum . NEL.nonEmpty =<< sequence timestamps
+ mExternsTimestamp <- getTimestampMaybe (outputFilename mn externsFileName)
+ case mExternsTimestamp of
+ Nothing ->
+ -- If there is no externs file, we will need to compile the module in
+ -- order to produce one.
+ pure Nothing
+ Just externsTimestamp ->
+ case NEL.nonEmpty (fmap (targetFilename mn) (S.toList codegenTargets)) of
+ Nothing ->
+ -- If the externs file exists and no other codegen targets have
+ -- been requested, then we can consider the module up-to-date
+ pure (Just externsTimestamp)
+ Just outputPaths -> do
+ -- If any of the other output paths are nonexistent or older than
+ -- the externs file, then they should be considered outdated, and
+ -- so the module will need rebuilding.
+ mmodTimes <- traverse getTimestampMaybe outputPaths
+ pure $ case sequence mmodTimes of
+ Nothing ->
+ Nothing
+ Just modTimes ->
+ if externsTimestamp <= minimum modTimes
+ then Just externsTimestamp
+ else Nothing
- readExterns :: ModuleName -> Make (FilePath, Externs)
+ readExterns :: ModuleName -> Make (FilePath, Maybe ExternsFile)
readExterns mn = do
- let path = outputDir > T.unpack (runModuleName mn) > "externs.json"
- (path, ) <$> readTextFile path
+ let path = outputDir > T.unpack (runModuleName mn) > externsFileName
+ (path, ) <$> readExternsFile path
+
+ outputPrimDocs :: Make ()
+ outputPrimDocs = do
+ codegenTargets <- asks optionsCodegenTargets
+ when (S.member Docs codegenTargets) $ for_ Docs.Prim.primModules $ \docsMod@Docs.Module{..} ->
+ writeJSONFile (outputFilename modName "docs.json") docsMod
- codegen :: CF.Module CF.Ann -> Environment -> Externs -> SupplyT Make ()
- codegen m _ exts = do
+ codegen :: CF.Module CF.Ann -> Docs.Module -> ExternsFile -> SupplyT Make ()
+ codegen m docs exts = do
let mn = CF.moduleName m
- lift $ writeTextFile (outputFilename mn "externs.json") exts
+ lift $ writeCborFile (outputFilename mn externsFileName) exts
codegenTargets <- lift $ asks optionsCodegenTargets
when (S.member CoreFn codegenTargets) $ do
let coreFnFile = targetFilename mn CoreFn
json = CFJ.moduleToJSON Paths.version m
- lift $ writeTextFile coreFnFile (encode json)
+ lift $ writeJSONFile coreFnFile json
when (S.member JS codegenTargets) $ do
foreignInclude <- case mn `M.lookup` foreigns of
Just _
| not $ requiresForeign m -> do
return Nothing
| otherwise -> do
- return $ Just $ Imp.App Nothing (Imp.Var Nothing "require") [Imp.StringLiteral Nothing "./foreign.js"]
+ return $ Just "./foreign.js"
Nothing | requiresForeign m -> throwError . errorMessage' (CF.moduleSourceSpan m) $ MissingFFIModule mn
| otherwise -> return Nothing
rawJs <- J.moduleToJs m foreignInclude
- dir <- lift $ makeIO (const (ErrorMessage [] $ CannotGetFileInfo ".")) getCurrentDirectory
+ dir <- lift $ makeIO "get the current directory" getCurrentDirectory
let sourceMaps = S.member JSSourceMap codegenTargets
(pjs, mappings) = if sourceMaps then prettyPrintJSWithSourceMaps rawJs else (prettyPrintJS rawJs, [])
jsFile = targetFilename mn JS
@@ -175,108 +273,140 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
js = T.unlines $ map ("// " <>) prefix ++ [pjs]
mapRef = if sourceMaps then "//# sourceMappingURL=index.js.map\n" else ""
lift $ do
- writeTextFile jsFile (B.fromStrict $ TE.encodeUtf8 $ js <> mapRef)
+ writeTextFile jsFile (TE.encodeUtf8 $ js <> mapRef)
when sourceMaps $ genSourceMap dir mapFile (length prefix) mappings
+ when (S.member Docs codegenTargets) $ do
+ lift $ writeJSONFile (outputFilename mn "docs.json") docs
ffiCodegen :: CF.Module CF.Ann -> Make ()
ffiCodegen m = do
codegenTargets <- asks optionsCodegenTargets
- when (S.member JS codegenTargets) $ do
- let mn = CF.moduleName m
- foreignFile = outputFilename mn "foreign.js"
- case mn `M.lookup` foreigns of
- Just path
- | not $ requiresForeign m ->
- tell $ errorMessage' (CF.moduleSourceSpan m) $ UnnecessaryFFIModule mn path
- | otherwise ->
- checkForeignDecls m path
- Nothing | requiresForeign m -> throwError . errorMessage' (CF.moduleSourceSpan m) $ MissingFFIModule mn
- | otherwise -> return ()
- for_ (mn `M.lookup` foreigns) (readTextFile >=> writeTextFile foreignFile)
+ ffiCodegen' foreigns codegenTargets (Just outputFilename) m
genSourceMap :: String -> String -> Int -> [SMap] -> Make ()
genSourceMap dir mapFile extraLines mappings = do
- let pathToDir = iterate (".." >) ".." !! length (splitPath $ normalise outputDir)
+ let pathToDir = iterate (".." Posix.>) ".." !! length (splitPath $ normalise outputDir)
sourceFile = case mappings of
- (SMap file _ _ : _) -> Just $ pathToDir > makeRelative dir (T.unpack file)
+ (SMap file _ _ : _) -> Just $ pathToDir Posix.> normalizeSMPath (makeRelative dir (T.unpack file))
_ -> Nothing
let rawMapping = SourceMapping { smFile = "index.js", smSourceRoot = Nothing, smMappings =
map (\(SMap _ orig gen) -> Mapping {
mapOriginal = Just $ convertPos $ add 0 (-1) orig
, mapSourceFile = sourceFile
- , mapGenerated = convertPos $ add (extraLines+1) 0 gen
+ , mapGenerated = convertPos $ add (extraLines + 1) 0 gen
, mapName = Nothing
}) mappings
}
let mapping = generate rawMapping
- writeTextFile mapFile (encode mapping)
+ writeJSONFile mapFile mapping
where
add :: Int -> Int -> SourcePos -> SourcePos
- add n m (SourcePos n' m') = SourcePos (n+n') (m+m')
+ add n m (SourcePos n' m') = SourcePos (n + n') (m + m')
convertPos :: SourcePos -> Pos
convertPos SourcePos { sourcePosLine = l, sourcePosColumn = c } =
Pos { posLine = fromIntegral l, posColumn = fromIntegral c }
+ normalizeSMPath :: FilePath -> FilePath
+ normalizeSMPath = Posix.joinPath . splitDirectories
+
requiresForeign :: CF.Module a -> Bool
requiresForeign = not . null . CF.moduleForeign
- getTimestamp :: FilePath -> Make (Maybe UTCTime)
- getTimestamp path = makeIO (const (ErrorMessage [] $ CannotGetFileInfo path)) $ do
- exists <- doesFileExist path
- if exists
- then Just <$> getModificationTime path
- else pure Nothing
-
- writeTextFile :: FilePath -> B.ByteString -> Make ()
- writeTextFile path text = makeIO (const (ErrorMessage [] $ CannotWriteFile path)) $ do
- mkdirp path
- B.writeFile path text
- where
- mkdirp :: FilePath -> IO ()
- mkdirp = createDirectoryIfMissing True . takeDirectory
-
progress :: ProgressMessage -> Make ()
- progress = liftIO . putStrLn . renderProgressMessage
+ progress = liftIO . TIO.hPutStr stderr . (<> "\n") . renderProgressMessage "Compiling "
+
+ readCacheDb :: Make CacheDb
+ readCacheDb = readCacheDb' outputDir
+
+ writeCacheDb :: CacheDb -> Make ()
+ writeCacheDb = writeCacheDb' outputDir
+
+ writePackageJson :: Make ()
+ writePackageJson = writePackageJson' outputDir
+
+data ForeignModuleType = ESModule | CJSModule deriving (Show)
-- | Check that the declarations in a given PureScript module match with those
-- in its corresponding foreign module.
-checkForeignDecls :: CF.Module ann -> FilePath -> Make ()
+checkForeignDecls :: CF.Module ann -> FilePath -> Make (Either MultipleErrors (ForeignModuleType, S.Set Ident))
checkForeignDecls m path = do
- jsStr <- readTextFile path
- js <- either (errorParsingModule . Bundle.UnableToParseModule) pure $ JS.parse (LBU8.toString jsStr) path
-
- foreignIdentsStrs <- either errorParsingModule pure $ getExps js
- foreignIdents <- either
- errorInvalidForeignIdentifiers
- (pure . S.fromList)
- (parseIdents foreignIdentsStrs)
- let importedIdents = S.fromList (CF.moduleForeign m)
-
- let unusedFFI = foreignIdents S.\\ importedIdents
- unless (null unusedFFI) $
- tell . errorMessage' modSS . UnusedFFIImplementations mname $
- S.toList unusedFFI
-
- let missingFFI = importedIdents S.\\ foreignIdents
- unless (null missingFFI) $
- throwError . errorMessage' modSS . MissingFFIImplementations mname $
- S.toList missingFFI
+ jsStr <- T.unpack <$> readTextFile path
+
+ let
+ parseResult :: Either MultipleErrors JS.JSAST
+ parseResult = first (errorParsingModule . Bundle.UnableToParseModule) $ JS.parseModule jsStr path
+ traverse checkFFI parseResult
where
mname = CF.moduleName m
modSS = CF.moduleSourceSpan m
- errorParsingModule :: Bundle.ErrorMessage -> Make a
- errorParsingModule = throwError . errorMessage' modSS . ErrorParsingFFIModule path . Just
+ checkFFI :: JS.JSAST -> Make (ForeignModuleType, S.Set Ident)
+ checkFFI js = do
+ (foreignModuleType, foreignIdentsStrs) <-
+ case (,) <$> getForeignModuleExports js <*> getForeignModuleImports js of
+ Left reason -> throwError $ errorParsingModule reason
+ Right (Bundle.ForeignModuleExports{..}, Bundle.ForeignModuleImports{..})
+ | not (null cjsExports && null cjsImports)
+ , null esExports
+ , null esImports -> do
+ let deprecatedFFI = filter (elem '\'') cjsExports
+ unless (null deprecatedFFI) $
+ errorDeprecatedForeignPrimes deprecatedFFI
+
+ pure (CJSModule, cjsExports)
+ | otherwise -> do
+ unless (null cjsImports) $
+ errorUnsupportedFFICommonJSImports cjsImports
+
+ unless (null cjsExports) $
+ errorUnsupportedFFICommonJSExports cjsExports
+
+ pure (ESModule, esExports)
+
+ foreignIdents <- either
+ errorInvalidForeignIdentifiers
+ (pure . S.fromList)
+ (parseIdents foreignIdentsStrs)
+ let importedIdents = S.fromList (CF.moduleForeign m)
+
+ let unusedFFI = foreignIdents S.\\ importedIdents
+ unless (null unusedFFI) $
+ tell . errorMessage' modSS . UnusedFFIImplementations mname $
+ S.toList unusedFFI
+
+ let missingFFI = importedIdents S.\\ foreignIdents
+ unless (null missingFFI) $
+ throwError . errorMessage' modSS . MissingFFIImplementations mname $
+ S.toList missingFFI
+ pure (foreignModuleType, foreignIdents)
+
+ errorParsingModule :: Bundle.ErrorMessage -> MultipleErrors
+ errorParsingModule = errorMessage' modSS . ErrorParsingFFIModule path . Just
+
+ getForeignModuleExports :: JS.JSAST -> Either Bundle.ErrorMessage Bundle.ForeignModuleExports
+ getForeignModuleExports = Bundle.getExportedIdentifiers (T.unpack (runModuleName mname))
- getExps :: JS.JSAST -> Either Bundle.ErrorMessage [String]
- getExps = Bundle.getExportedIdentifiers (T.unpack (runModuleName mname))
+ getForeignModuleImports :: JS.JSAST -> Either Bundle.ErrorMessage Bundle.ForeignModuleImports
+ getForeignModuleImports = Bundle.getImportedModules (T.unpack (runModuleName mname))
errorInvalidForeignIdentifiers :: [String] -> Make a
errorInvalidForeignIdentifiers =
throwError . mconcat . map (errorMessage . InvalidFFIIdentifier mname . T.pack)
+ errorDeprecatedForeignPrimes :: [String] -> Make a
+ errorDeprecatedForeignPrimes =
+ throwError . mconcat . map (errorMessage' modSS . DeprecatedFFIPrime mname . T.pack)
+
+ errorUnsupportedFFICommonJSExports :: [String] -> Make a
+ errorUnsupportedFFICommonJSExports =
+ throwError . errorMessage' modSS . UnsupportedFFICommonJSExports mname . map T.pack
+
+ errorUnsupportedFFICommonJSImports :: [String] -> Make a
+ errorUnsupportedFFICommonJSImports =
+ throwError . errorMessage' modSS . UnsupportedFFICommonJSImports mname . map T.pack
+
parseIdents :: [String] -> Either [String] [Ident]
parseIdents strs =
case partitionEithers (map parseIdent strs) of
@@ -288,8 +418,38 @@ checkForeignDecls m path = do
-- We ignore the error message here, just being told it's an invalid
-- identifier should be enough.
parseIdent :: String -> Either String Ident
- parseIdent str = try (T.pack str)
- where
- try s = either (const (Left str)) Right $ do
- ts <- PSParser.lex "" s
- PSParser.runTokenParser "" (PSParser.parseIdent <* Parsec.eof) ts
+ parseIdent str =
+ bimap (const str) (Ident . CST.getIdent . CST.nameValue . snd)
+ . CST.runTokenParser CST.parseIdent
+ . CST.lex
+ $ T.pack str
+
+-- | FFI check and codegen action.
+-- If path maker is supplied copies foreign module to the output.
+ffiCodegen'
+ :: M.Map ModuleName FilePath
+ -> S.Set CodegenTarget
+ -> Maybe (ModuleName -> String -> FilePath)
+ -> CF.Module CF.Ann
+ -> Make ()
+ffiCodegen' foreigns codegenTargets makeOutputPath m = do
+ when (S.member JS codegenTargets) $ do
+ let mn = CF.moduleName m
+ case mn `M.lookup` foreigns of
+ Just path
+ | not $ requiresForeign m ->
+ tell $ errorMessage' (CF.moduleSourceSpan m) $ UnnecessaryFFIModule mn path
+ | otherwise -> do
+ checkResult <- checkForeignDecls m path
+ case checkResult of
+ Left _ -> copyForeign path mn
+ Right (ESModule, _) -> copyForeign path mn
+ Right (CJSModule, _) -> do
+ throwError $ errorMessage' (CF.moduleSourceSpan m) $ DeprecatedFFICommonJSModule mn path
+ Nothing | requiresForeign m -> throwError . errorMessage' (CF.moduleSourceSpan m) $ MissingFFIModule mn
+ | otherwise -> return ()
+ where
+ requiresForeign = not . null . CF.moduleForeign
+
+ copyForeign path mn =
+ for_ makeOutputPath (\outputFilename -> copyFile path (outputFilename mn "foreign.js"))
diff --git a/src/Language/PureScript/Make/BuildPlan.hs b/src/Language/PureScript/Make/BuildPlan.hs
index d2bb88cdbc..3eba2359a3 100644
--- a/src/Language/PureScript/Make/BuildPlan.hs
+++ b/src/Language/PureScript/Make/BuildPlan.hs
@@ -1,42 +1,44 @@
module Language.PureScript.Make.BuildPlan
- ( BuildPlan()
+ ( BuildPlan(bpEnv, bpIndex)
+ , BuildJobResult(..)
+ , buildJobSuccess
, construct
, getResult
- , collectErrors
, collectResults
, markComplete
, needsRebuild
) where
-import Prelude
-
-import Control.Concurrent.Async.Lifted as A
-import Control.Concurrent.Lifted as C
-import Control.Monad hiding (sequence)
-import Control.Monad.Trans.Class (lift)
-import Control.Monad.Trans.Control (MonadBaseControl(..))
-import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
-import Data.Aeson (decode)
-import Data.Foldable (foldl')
-import qualified Data.Map as M
-import Data.Maybe (catMaybes, fromMaybe)
-import qualified Data.Text as T
-import Data.Time.Clock (UTCTime)
-import Data.Version (showVersion)
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import qualified Language.PureScript.CST as CST
-import Language.PureScript.Errors
-import Language.PureScript.Externs
-import Language.PureScript.Make.Actions as Actions
-import Language.PureScript.Names (ModuleName)
-import qualified Paths_purescript as Paths
+import Prelude
+
+import Control.Concurrent.Async.Lifted as A
+import Control.Concurrent.Lifted as C
+import Control.Monad.Base (liftBase)
+import Control.Monad (foldM)
+import Control.Monad.Trans.Control (MonadBaseControl(..))
+import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
+import Data.Foldable (foldl')
+import Data.Map qualified as M
+import Data.Maybe (fromMaybe, mapMaybe)
+import Data.Time.Clock (UTCTime)
+import Language.PureScript.AST (Module, getModuleName)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Errors (MultipleErrors(..))
+import Language.PureScript.Externs (ExternsFile)
+import Language.PureScript.Make.Actions as Actions
+import Language.PureScript.Make.Cache (CacheDb, CacheInfo, checkChanged)
+import Language.PureScript.Names (ModuleName)
+import Language.PureScript.Sugar.Names.Env (Env, primEnv)
+import System.Directory (getCurrentDirectory)
-- | The BuildPlan tracks information about our build progress, and holds all
-- prebuilt modules for incremental builds.
data BuildPlan = BuildPlan
{ bpPrebuilt :: M.Map ModuleName Prebuilt
, bpBuildJobs :: M.Map ModuleName BuildJob
+ , bpEnv :: C.MVar Env
+ , bpIndex :: C.MVar Int
}
data Prebuilt = Prebuilt
@@ -44,9 +46,37 @@ data Prebuilt = Prebuilt
, pbExternsFile :: ExternsFile
}
-data BuildJob = BuildJob
- { bjResult :: C.MVar (Maybe (MultipleErrors, ExternsFile))
- , bjErrors :: C.MVar (Maybe MultipleErrors)
+newtype BuildJob = BuildJob
+ { bjResult :: C.MVar BuildJobResult
+ -- ^ Note: an empty MVar indicates that the build job has not yet finished.
+ }
+
+data BuildJobResult
+ = BuildJobSucceeded !MultipleErrors !ExternsFile
+ -- ^ Succeeded, with warnings and externs
+ --
+ | BuildJobFailed !MultipleErrors
+ -- ^ Failed, with errors
+
+ | BuildJobSkipped
+ -- ^ The build job was not run, because an upstream build job failed
+
+buildJobSuccess :: BuildJobResult -> Maybe (MultipleErrors, ExternsFile)
+buildJobSuccess (BuildJobSucceeded warnings externs) = Just (warnings, externs)
+buildJobSuccess _ = Nothing
+
+-- | Information obtained about a particular module while constructing a build
+-- plan; used to decide whether a module needs rebuilding.
+data RebuildStatus = RebuildStatus
+ { statusModuleName :: ModuleName
+ , statusRebuildNever :: Bool
+ , statusNewCacheInfo :: Maybe CacheInfo
+ -- ^ New cache info for this module which should be stored for subsequent
+ -- incremental builds. A value of Nothing indicates that cache info for
+ -- this module should not be stored in the build cache, because it is being
+ -- rebuilt according to a RebuildPolicy instead.
+ , statusPrebuilt :: Maybe Prebuilt
+ -- ^ Prebuilt externs and timestamp for this module, if any.
}
-- | Called when we finished compiling a module and want to report back the
@@ -55,39 +85,27 @@ markComplete
:: (MonadBaseControl IO m)
=> BuildPlan
-> ModuleName
- -> Maybe (MultipleErrors, ExternsFile)
- -> Maybe MultipleErrors
+ -> BuildJobResult
-> m ()
-markComplete buildPlan moduleName result errors = do
- let BuildJob rVar eVar = fromMaybe (internalError "make: markComplete no barrier") $ M.lookup moduleName (bpBuildJobs buildPlan)
+markComplete buildPlan moduleName result = do
+ let BuildJob rVar = fromMaybe (internalError "make: markComplete no barrier") $ M.lookup moduleName (bpBuildJobs buildPlan)
putMVar rVar result
- putMVar eVar errors
-- | Whether or not the module with the given ModuleName needs to be rebuilt
needsRebuild :: BuildPlan -> ModuleName -> Bool
needsRebuild bp moduleName = M.member moduleName (bpBuildJobs bp)
--- | Collects errors for all modules that have been rebuilt. This will block
--- until all outstanding build jobs are finished.
-collectErrors
- :: (MonadBaseControl IO m)
- => BuildPlan
- -> m [MultipleErrors]
-collectErrors buildPlan = do
- errors <- traverse readMVar $ map bjErrors $ M.elems (bpBuildJobs buildPlan)
- pure (catMaybes errors)
-
--- | Collects ExternsFiles for all prebuilt as well as rebuilt modules. Panics
--- if any build job returned an error.
+-- | Collects results for all prebuilt as well as rebuilt modules. This will
+-- block until all build jobs are finished. Prebuilt modules always return no
+-- warnings.
collectResults
:: (MonadBaseControl IO m)
=> BuildPlan
- -> m (M.Map ModuleName ExternsFile)
+ -> m (M.Map ModuleName BuildJobResult)
collectResults buildPlan = do
- let externs = M.map pbExternsFile (bpPrebuilt buildPlan)
- barrierResults <- traverse (takeMVar . bjResult) $ bpBuildJobs buildPlan
- let barrierExterns = M.map (snd . fromMaybe (internalError "make: externs were missing but no errors reported.")) barrierResults
- pure (M.union externs barrierExterns)
+ let prebuiltResults = M.map (BuildJobSucceeded (MultipleErrors []) . pbExternsFile) (bpPrebuilt buildPlan)
+ barrierResults <- traverse (readMVar . bjResult) $ bpBuildJobs buildPlan
+ pure (M.union prebuiltResults barrierResults)
-- | Gets the the build result for a given module name independent of whether it
-- was rebuilt or prebuilt. Prebuilt modules always return no warnings.
@@ -100,42 +118,81 @@ getResult buildPlan moduleName =
case M.lookup moduleName (bpPrebuilt buildPlan) of
Just es ->
pure (Just (MultipleErrors [], pbExternsFile es))
- Nothing ->
- readMVar $ bjResult $ fromMaybe (internalError "make: no barrier") $ M.lookup moduleName (bpBuildJobs buildPlan)
+ Nothing -> do
+ r <- readMVar $ bjResult $ fromMaybe (internalError "make: no barrier") $ M.lookup moduleName (bpBuildJobs buildPlan)
+ pure $ buildJobSuccess r
-- | Constructs a BuildPlan for the given module graph.
--
-- The given MakeActions are used to collect various timestamps in order to
-- determine whether a module needs rebuilding.
construct
- :: forall m. (Monad m, MonadBaseControl IO m)
+ :: forall m. MonadBaseControl IO m
=> MakeActions m
+ -> CacheDb
-> ([CST.PartialResult Module], [(ModuleName, [ModuleName])])
- -> m BuildPlan
-construct MakeActions{..} (sorted, graph) = do
- prebuilt <- foldl' collectPrebuiltModules M.empty . catMaybes <$> A.forConcurrently sorted findExistingExtern
- let toBeRebuilt = filter (not . flip M.member prebuilt . getModuleName . CST.resPartial) sorted
- buildJobs <- foldM makeBuildJob M.empty (map (getModuleName . CST.resPartial) toBeRebuilt)
- pure $ BuildPlan prebuilt buildJobs
+ -> m (BuildPlan, CacheDb)
+construct MakeActions{..} cacheDb (sorted, graph) = do
+ let sortedModuleNames = map (getModuleName . CST.resPartial) sorted
+ rebuildStatuses <- A.forConcurrently sortedModuleNames getRebuildStatus
+ let prebuilt =
+ foldl' collectPrebuiltModules M.empty $
+ mapMaybe (\s -> (statusModuleName s, statusRebuildNever s,) <$> statusPrebuilt s) rebuildStatuses
+ let toBeRebuilt = filter (not . flip M.member prebuilt) sortedModuleNames
+ buildJobs <- foldM makeBuildJob M.empty toBeRebuilt
+ env <- C.newMVar primEnv
+ idx <- C.newMVar 1
+ pure
+ ( BuildPlan prebuilt buildJobs env idx
+ , let
+ update = flip $ \s ->
+ M.alter (const (statusNewCacheInfo s)) (statusModuleName s)
+ in
+ foldl' update cacheDb rebuildStatuses
+ )
where
makeBuildJob prev moduleName = do
- buildJob <- BuildJob <$> C.newEmptyMVar <*> C.newEmptyMVar
+ buildJob <- BuildJob <$> C.newEmptyMVar
pure (M.insert moduleName buildJob prev)
- findExistingExtern :: CST.PartialResult Module -> m (Maybe (ModuleName, Bool, Prebuilt))
- findExistingExtern (getModuleName . CST.resPartial -> moduleName) = runMaybeT $ do
- inputTimestamp <- lift $ getInputTimestamp moduleName
- (rebuildNever, existingTimestamp) <-
- case inputTimestamp of
- Left RebuildNever ->
- fmap (True,) $ MaybeT $ getOutputTimestamp moduleName
- Right (Just t1) -> do
- outputTimestamp <- MaybeT $ getOutputTimestamp moduleName
- guard (t1 < outputTimestamp)
- pure (False, outputTimestamp)
- _ -> mzero
- externsFile <- MaybeT $ decodeExterns . snd <$> readExterns moduleName
- pure (moduleName, rebuildNever, Prebuilt existingTimestamp externsFile)
+ getRebuildStatus :: ModuleName -> m RebuildStatus
+ getRebuildStatus moduleName = do
+ inputInfo <- getInputTimestampsAndHashes moduleName
+ case inputInfo of
+ Left RebuildNever -> do
+ prebuilt <- findExistingExtern moduleName
+ pure (RebuildStatus
+ { statusModuleName = moduleName
+ , statusRebuildNever = True
+ , statusPrebuilt = prebuilt
+ , statusNewCacheInfo = Nothing
+ })
+ Left RebuildAlways -> do
+ pure (RebuildStatus
+ { statusModuleName = moduleName
+ , statusRebuildNever = False
+ , statusPrebuilt = Nothing
+ , statusNewCacheInfo = Nothing
+ })
+ Right cacheInfo -> do
+ cwd <- liftBase getCurrentDirectory
+ (newCacheInfo, isUpToDate) <- checkChanged cacheDb moduleName cwd cacheInfo
+ prebuilt <-
+ if isUpToDate
+ then findExistingExtern moduleName
+ else pure Nothing
+ pure (RebuildStatus
+ { statusModuleName = moduleName
+ , statusRebuildNever = False
+ , statusPrebuilt = prebuilt
+ , statusNewCacheInfo = Just newCacheInfo
+ })
+
+ findExistingExtern :: ModuleName -> m (Maybe Prebuilt)
+ findExistingExtern moduleName = runMaybeT $ do
+ timestamp <- MaybeT $ getOutputTimestamp moduleName
+ externs <- MaybeT $ snd <$> readExterns moduleName
+ pure (Prebuilt timestamp externs)
collectPrebuiltModules :: M.Map ModuleName Prebuilt -> (ModuleName, Bool, Prebuilt) -> M.Map ModuleName Prebuilt
collectPrebuiltModules prev (moduleName, rebuildNever, pb)
@@ -157,9 +214,3 @@ construct MakeActions{..} (sorted, graph) = do
maximumMaybe :: Ord a => [a] -> Maybe a
maximumMaybe [] = Nothing
maximumMaybe xs = Just $ maximum xs
-
-decodeExterns :: Externs -> Maybe ExternsFile
-decodeExterns bs = do
- externs <- decode bs
- guard $ T.unpack (efVersion externs) == showVersion Paths.version
- return externs
diff --git a/src/Language/PureScript/Make/Cache.hs b/src/Language/PureScript/Make/Cache.hs
new file mode 100644
index 0000000000..092544fa73
--- /dev/null
+++ b/src/Language/PureScript/Make/Cache.hs
@@ -0,0 +1,149 @@
+module Language.PureScript.Make.Cache
+ ( ContentHash
+ , hash
+ , CacheDb
+ , CacheInfo(..)
+ , checkChanged
+ , removeModules
+ , normaliseForCache
+ ) where
+
+import Prelude
+
+import Control.Category ((>>>))
+import Control.Monad ((>=>))
+import Crypto.Hash (HashAlgorithm, Digest, SHA512)
+import Crypto.Hash qualified as Hash
+import Data.Aeson qualified as Aeson
+import Data.Align (align)
+import Data.ByteArray.Encoding (Base(Base16), convertToBase, convertFromBase)
+import Data.ByteString qualified as BS
+import Data.Map (Map)
+import Data.Map qualified as Map
+import Data.Maybe (fromMaybe)
+import Data.Monoid (All(..))
+import Data.Set (Set)
+import Data.Text (Text)
+import Data.Text.Encoding (encodeUtf8, decodeUtf8)
+import Data.These (These(..))
+import Data.Time.Clock (UTCTime)
+import Data.Traversable (for)
+import System.FilePath qualified as FilePath
+
+import Language.PureScript.Names (ModuleName)
+
+digestToHex :: Digest a -> Text
+digestToHex = decodeUtf8 . convertToBase Base16
+
+digestFromHex :: forall a. HashAlgorithm a => Text -> Maybe (Digest a)
+digestFromHex =
+ encodeUtf8
+ >>> either (const Nothing) Just . convertFromBase Base16
+ >=> (Hash.digestFromByteString :: BS.ByteString -> Maybe (Digest a))
+
+-- | Defines the hash algorithm we use for cache invalidation of input files.
+newtype ContentHash = ContentHash
+ { unContentHash :: Digest SHA512 }
+ deriving (Show, Eq, Ord)
+
+instance Aeson.ToJSON ContentHash where
+ toJSON = Aeson.toJSON . digestToHex . unContentHash
+
+instance Aeson.FromJSON ContentHash where
+ parseJSON x = do
+ str <- Aeson.parseJSON x
+ case digestFromHex str of
+ Just digest ->
+ pure $ ContentHash digest
+ Nothing ->
+ fail "Unable to decode ContentHash"
+
+hash :: BS.ByteString -> ContentHash
+hash = ContentHash . Hash.hash
+
+type CacheDb = Map ModuleName CacheInfo
+
+-- | A CacheInfo contains all of the information we need to store about a
+-- particular module in the cache database.
+newtype CacheInfo = CacheInfo
+ { unCacheInfo :: Map FilePath (UTCTime, ContentHash) }
+ deriving stock (Show)
+ deriving newtype (Eq, Ord, Semigroup, Monoid, Aeson.FromJSON, Aeson.ToJSON)
+
+-- | Given a module name, and a map containing the associated input files
+-- together with current metadata i.e. timestamps and hashes, check whether the
+-- input files have changed, based on comparing with the database stored in the
+-- monadic state.
+--
+-- The CacheInfo in the return value should be stored in the cache for future
+-- builds.
+--
+-- The Bool in the return value indicates whether it is safe to use existing
+-- build artifacts for this module, at least based on the timestamps and hashes
+-- of the module's input files.
+--
+-- If the timestamps are the same as those in the database, assume the file is
+-- unchanged, and return True without checking hashes.
+--
+-- If any of the timestamps differ from what is in the database, check the
+-- hashes of those files. In this case, update the database with any changed
+-- timestamps and hashes, and return True if and only if all of the hashes are
+-- unchanged.
+checkChanged
+ :: Monad m
+ => CacheDb
+ -> ModuleName
+ -> FilePath
+ -> Map FilePath (UTCTime, m ContentHash)
+ -> m (CacheInfo, Bool)
+checkChanged cacheDb mn basePath currentInfo = do
+
+ let dbInfo = unCacheInfo $ fromMaybe mempty (Map.lookup mn cacheDb)
+ (newInfo, isUpToDate) <-
+ fmap mconcat $
+ for (Map.toList (align dbInfo currentInfo)) $ \(normaliseForCache basePath -> fp, aligned) -> do
+ case aligned of
+ This _ -> do
+ -- One of the input files listed in the cache no longer exists;
+ -- remove that file from the cache and note that the module needs
+ -- rebuilding
+ pure (Map.empty, All False)
+ That (timestamp, getHash) -> do
+ -- The module has a new input file; add it to the cache and
+ -- note that the module needs rebuilding.
+ newHash <- getHash
+ pure (Map.singleton fp (timestamp, newHash), All False)
+ These db@(dbTimestamp, _) (newTimestamp, _) | dbTimestamp == newTimestamp -> do
+ -- This file exists both currently and in the cache database,
+ -- and the timestamp is unchanged, so we skip checking the
+ -- hash.
+ pure (Map.singleton fp db, mempty)
+ These (_, dbHash) (newTimestamp, getHash) -> do
+ -- This file exists both currently and in the cache database,
+ -- but the timestamp has changed, so we need to check the hash.
+ newHash <- getHash
+ pure (Map.singleton fp (newTimestamp, newHash), All (dbHash == newHash))
+
+ pure (CacheInfo newInfo, getAll isUpToDate)
+
+-- | Remove any modules from the given set from the cache database; used when
+-- they failed to build.
+removeModules :: Set ModuleName -> CacheDb -> CacheDb
+removeModules = flip Map.withoutKeys
+
+-- | 1. Any path that is beneath our current working directory will be
+-- stored as a normalised relative path
+-- 2. Any path that isn't will be stored as an absolute path
+normaliseForCache :: FilePath -> FilePath -> FilePath
+normaliseForCache basePath fp =
+ if FilePath.isRelative fp then
+ FilePath.normalise fp
+ else
+ let relativePath = FilePath.makeRelative basePath fp in
+ if FilePath.isRelative relativePath then
+ FilePath.normalise relativePath
+ else
+ -- If the path is still absolute after trying to make it
+ -- relative to the base that means it is not underneath
+ -- the base path
+ FilePath.normalise fp
diff --git a/src/Language/PureScript/Make/Monad.hs b/src/Language/PureScript/Make/Monad.hs
index bbc737e7b3..8c86144e9a 100644
--- a/src/Language/PureScript/Make/Monad.hs
+++ b/src/Language/PureScript/Make/Monad.hs
@@ -1,28 +1,52 @@
-{-# LANGUAGE TypeFamilies #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Language.PureScript.Make.Monad
( -- * Implementation of Make API using files on disk
Make(..)
, runMake
, makeIO
+ , getTimestamp
+ , getTimestampMaybe
, readTextFile
+ , readJSONFile
+ , readJSONFileIO
+ , readCborFile
+ , readCborFileIO
+ , readExternsFile
+ , hashFile
+ , writeTextFile
+ , writeJSONFile
+ , writeCborFile
+ , writeCborFileIO
+ , copyFile
) where
-import Prelude
-
-import Control.Monad.Base (MonadBase(..))
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.IO.Class
-import Control.Monad.Logger
-import Control.Monad.Reader (MonadReader(..), ReaderT(..))
-import Control.Monad.Trans.Control (MonadBaseControl(..))
-import Control.Monad.Trans.Except
-import Control.Monad.Writer.Class (MonadWriter(..))
-import qualified Data.ByteString.Lazy as B
-import Language.PureScript.AST
-import Language.PureScript.Errors
-import Language.PureScript.Options
-import System.IO.Error (tryIOError)
+import Prelude
+
+import Codec.Serialise (Serialise)
+import Codec.Serialise qualified as Serialise
+import Control.Exception (fromException, tryJust, Exception (displayException))
+import Control.Monad (join, guard)
+import Control.Monad.Base (MonadBase(..))
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.IO.Class (MonadIO(..))
+import Control.Monad.Logger (Logger, runLogger')
+import Control.Monad.Reader (MonadReader(..), ReaderT(..))
+import Control.Monad.Trans.Control (MonadBaseControl(..))
+import Control.Monad.Trans.Except (ExceptT, runExceptT)
+import Control.Monad.Writer.Class (MonadWriter(..))
+import Data.Aeson qualified as Aeson
+import Data.ByteString qualified as B
+import Data.Text (Text)
+import Data.Text qualified as Text
+import Data.Time.Clock (UTCTime)
+import Language.PureScript.Errors (ErrorMessage(..), MultipleErrors, SimpleErrorMessage(..), singleError)
+import Language.PureScript.Externs (ExternsFile, externsIsCurrentVersion)
+import Language.PureScript.Make.Cache (ContentHash, hash)
+import Language.PureScript.Options (Options)
+import System.Directory (createDirectoryIfMissing, getModificationTime)
+import System.Directory qualified as Directory
+import System.FilePath (takeDirectory)
+import System.IO.Error (tryIOError, isDoesNotExistError)
+import System.IO.UTF8 (readUTF8FileT)
-- | A monad for running make actions
newtype Make a = Make
@@ -41,14 +65,123 @@ instance MonadBaseControl IO Make where
runMake :: Options -> Make a -> IO (Either MultipleErrors a, MultipleErrors)
runMake opts = runLogger' . runExceptT . flip runReaderT opts . unMake
--- | Run an 'IO' action in the 'Make' monad, by specifying how IO errors should
--- be rendered as 'ErrorMessage' values.
-makeIO :: (IOError -> ErrorMessage) -> IO a -> Make a
-makeIO f io = do
- e <- liftIO $ tryIOError io
- either (throwError . singleError . f) return e
+-- | Run an 'IO' action in the 'Make' monad. The 'String' argument should
+-- describe what we were trying to do; it is used for rendering errors in the
+-- case that an IOException is thrown.
+makeIO :: (MonadIO m, MonadError MultipleErrors m) => Text -> IO a -> m a
+makeIO description io = do
+ res <- liftIO (tryIOError io)
+ either (throwError . singleError . ErrorMessage [] . FileIOError description . Text.pack . displayException) pure res
+
+-- | Get a file's modification time in the 'Make' monad, capturing any errors
+-- using the 'MonadError' instance.
+getTimestamp :: (MonadIO m, MonadError MultipleErrors m) => FilePath -> m UTCTime
+getTimestamp path =
+ makeIO ("get a timestamp for file: " <> Text.pack path) $ getModificationTime path
+
+-- | Get a file's modification time in the 'Make' monad, returning Nothing if
+-- the file does not exist.
+getTimestampMaybe :: (MonadIO m, MonadError MultipleErrors m) => FilePath -> m (Maybe UTCTime)
+getTimestampMaybe path =
+ makeIO ("get a timestamp for file: " <> Text.pack path) $ catchDoesNotExist $ getModificationTime path
+
+-- | Read a text file strictly in the 'Make' monad, capturing any errors using
+-- the 'MonadError' instance.
+readTextFile :: (MonadIO m, MonadError MultipleErrors m) => FilePath -> m Text
+readTextFile path =
+ makeIO ("read file: " <> Text.pack path) $
+ readUTF8FileT path
+
+-- | Read a JSON file in the 'Make' monad, returning 'Nothing' if the file does
+-- not exist or could not be parsed. Errors are captured using the 'MonadError'
+-- instance.
+readJSONFile :: (MonadIO m, MonadError MultipleErrors m) => Aeson.FromJSON a => FilePath -> m (Maybe a)
+readJSONFile path =
+ makeIO ("read JSON file: " <> Text.pack path) (readJSONFileIO path)
+
+readJSONFileIO :: Aeson.FromJSON a => FilePath -> IO (Maybe a)
+readJSONFileIO path = do
+ r <- catchDoesNotExist $ Aeson.decodeFileStrict' path
+ return $ join r
+
+-- | Read a Cbor encoded file in the 'Make' monad, returning
+-- 'Nothing' if the file does not exist or could not be parsed. Errors
+-- are captured using the 'MonadError' instance.
+readCborFile :: (MonadIO m, MonadError MultipleErrors m) => Serialise a => FilePath -> m (Maybe a)
+readCborFile path =
+ makeIO ("read Binary file: " <> Text.pack path) (readCborFileIO path)
+
+readCborFileIO :: Serialise a => FilePath -> IO (Maybe a)
+readCborFileIO path = do
+ r <- catchDoesNotExist $ catchDeserialiseFailure $ Serialise.readFileDeserialise path
+ return (join r)
+
+-- | Read an externs file, returning 'Nothing' if the file does not exist,
+-- could not be parsed, or was generated by a different version of the
+-- compiler.
+readExternsFile :: (MonadIO m, MonadError MultipleErrors m) => FilePath -> m (Maybe ExternsFile)
+readExternsFile path = do
+ mexterns <- readCborFile path
+ return $ do
+ externs <- mexterns
+ guard $ externsIsCurrentVersion externs
+ return externs
+
+hashFile :: (MonadIO m, MonadError MultipleErrors m) => FilePath -> m ContentHash
+hashFile path = do
+ makeIO ("hash file: " <> Text.pack path)
+ (hash <$> B.readFile path)
--- | Read a text file in the 'Make' monad, capturing any errors using the
+-- | If the provided action threw an 'isDoesNotExist' error, catch it and
+-- return Nothing. Otherwise return Just the result of the inner action.
+catchDoesNotExist :: IO a -> IO (Maybe a)
+catchDoesNotExist inner = do
+ r <- tryJust (guard . isDoesNotExistError) inner
+ case r of
+ Left () ->
+ return Nothing
+ Right x ->
+ return (Just x)
+
+catchDeserialiseFailure :: IO a -> IO (Maybe a)
+catchDeserialiseFailure inner = do
+ r <- tryJust fromException inner
+ case r of
+ Left (_ :: Serialise.DeserialiseFailure) ->
+ return Nothing
+ Right x ->
+ return (Just x)
+
+-- | Write a text file in the 'Make' monad, capturing any errors using the
-- 'MonadError' instance.
-readTextFile :: FilePath -> Make B.ByteString
-readTextFile path = makeIO (const (ErrorMessage [] $ CannotReadFile path)) $ B.readFile path
+writeTextFile :: FilePath -> B.ByteString -> Make ()
+writeTextFile path text = makeIO ("write file: " <> Text.pack path) $ do
+ createParentDirectory path
+ B.writeFile path text
+
+-- | Write a JSON file in the 'Make' monad, capturing any errors using the
+-- 'MonadError' instance.
+writeJSONFile :: (MonadIO m, MonadError MultipleErrors m) => Aeson.ToJSON a => FilePath -> a -> m ()
+writeJSONFile path value = makeIO ("write JSON file: " <> Text.pack path) $ do
+ createParentDirectory path
+ Aeson.encodeFile path value
+
+writeCborFile :: (MonadIO m, MonadError MultipleErrors m) => Serialise a => FilePath -> a -> m ()
+writeCborFile path value =
+ makeIO ("write Cbor file: " <> Text.pack path) (writeCborFileIO path value)
+
+writeCborFileIO :: Serialise a => FilePath -> a -> IO ()
+writeCborFileIO path value = do
+ createParentDirectory path
+ Serialise.writeFileSerialise path value
+
+-- | Copy a file in the 'Make' monad, capturing any errors using the
+-- 'MonadError' instance.
+copyFile :: (MonadIO m, MonadError MultipleErrors m) => FilePath -> FilePath -> m ()
+copyFile src dest =
+ makeIO ("copy file: " <> Text.pack src <> " -> " <> Text.pack dest) $ do
+ createParentDirectory dest
+ Directory.copyFile src dest
+
+createParentDirectory :: FilePath -> IO ()
+createParentDirectory = createDirectoryIfMissing True . takeDirectory
diff --git a/src/Language/PureScript/ModuleDependencies.hs b/src/Language/PureScript/ModuleDependencies.hs
index 1152de2527..3bcb914fb6 100644
--- a/src/Language/PureScript/ModuleDependencies.hs
+++ b/src/Language/PureScript/ModuleDependencies.hs
@@ -1,20 +1,22 @@
-- | Provides the ability to sort modules based on module dependencies
module Language.PureScript.ModuleDependencies
- ( sortModules
+ ( DependencyDepth(..)
+ , sortModules
, ModuleGraph
, ModuleSignature(..)
, moduleSignature
) where
-import Protolude hiding (head)
+import Protolude hiding (head)
-import Data.Graph
-import qualified Data.Set as S
-import Language.PureScript.AST
-import qualified Language.PureScript.Constants as C
-import Language.PureScript.Crash
-import Language.PureScript.Errors hiding (nonEmpty)
-import Language.PureScript.Names
+import Data.Array ((!))
+import Data.Graph (SCC(..), graphFromEdges, reachable, stronglyConnComp)
+import Data.Set qualified as S
+import Language.PureScript.AST (Declaration(..), ErrorMessageHint(..), Module(..), SourceSpan)
+import Language.PureScript.Constants.Prim qualified as C
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, errorMessage', errorMessage'', parU)
+import Language.PureScript.Names (ModuleName)
-- | A list of modules with their transitive dependencies
type ModuleGraph = [(ModuleName, [ModuleName])]
@@ -23,19 +25,22 @@ type ModuleGraph = [(ModuleName, [ModuleName])]
data ModuleSignature = ModuleSignature
{ sigSourceSpan :: SourceSpan
, sigModuleName :: ModuleName
- , sigDecls :: [Declaration]
+ , sigImports :: [(ModuleName, SourceSpan)]
}
+data DependencyDepth = Direct | Transitive
+
-- | Sort a collection of modules based on module dependencies.
--
-- Reports an error if the module graph contains a cycle.
sortModules
:: forall m a
. MonadError MultipleErrors m
- => (a -> ModuleSignature)
+ => DependencyDepth
+ -> (a -> ModuleSignature)
-> [a]
-> m ([a], ModuleGraph)
-sortModules toSig ms = do
+sortModules dependencyDepth toSig ms = do
let
ms' = (\m -> (m, toSig m)) <$> ms
mns = S.fromList $ map (sigModuleName . snd) ms'
@@ -44,14 +49,15 @@ sortModules toSig ms = do
let (graph, fromVertex, toVertex) = graphFromEdges verts
moduleGraph = do (_, mn, _) <- verts
let v = fromMaybe (internalError "sortModules: vertex not found") (toVertex mn)
- deps = reachable graph v
+ deps = case dependencyDepth of
+ Direct -> graph ! v
+ Transitive -> reachable graph v
toKey i = case fromVertex i of (_, key, _) -> key
return (mn, filter (/= mn) (map toKey deps))
return (fst <$> ms'', moduleGraph)
where
toGraphNode :: S.Set ModuleName -> (a, ModuleSignature) -> m ((a, ModuleSignature), ModuleName, [ModuleName])
- toGraphNode mns m@(_, ModuleSignature _ mn ds) = do
- let deps = ordNub (mapMaybe usedModules ds)
+ toGraphNode mns m@(_, ModuleSignature _ mn deps) = do
void . parU deps $ \(dep, pos) ->
when (dep `notElem` C.primModules && S.notMember dep mns) .
throwError
@@ -77,7 +83,7 @@ toModule (CyclicSCC ms) =
Just ms' ->
throwError
. errorMessage'' (fmap (sigSourceSpan . snd) ms')
- $ CycleInModules (map (sigModuleName . snd) ms)
+ $ CycleInModules (map (sigModuleName . snd) ms')
moduleSignature :: Module -> ModuleSignature
-moduleSignature (Module ss _ mn ds _) = ModuleSignature ss mn ds
+moduleSignature (Module ss _ mn ds _) = ModuleSignature ss mn (ordNub (mapMaybe usedModules ds))
diff --git a/src/Language/PureScript/Names.hs b/src/Language/PureScript/Names.hs
index e2327c1cc1..e5df3610bf 100644
--- a/src/Language/PureScript/Names.hs
+++ b/src/Language/PureScript/Names.hs
@@ -1,23 +1,26 @@
{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE DeriveTraversable #-}
-{-# LANGUAGE DeriveFoldable #-}
-- |
-- Data types for names
--
module Language.PureScript.Names where
-import Prelude.Compat
+import Prelude
-import Control.Monad.Supply.Class
+import Codec.Serialise (Serialise)
+import Control.Applicative ((<|>))
+import Control.Monad.Supply.Class (MonadSupply(..))
import Control.DeepSeq (NFData)
+import Data.Functor.Contravariant (contramap)
+import Data.Vector qualified as V
import GHC.Generics (Generic)
-import Data.Aeson
-import Data.Aeson.TH
+import Data.Aeson (FromJSON(..), FromJSONKey(..), Options(..), SumEncoding(..), ToJSON(..), ToJSONKey(..), defaultOptions, parseJSON2, toJSON2, withArray)
+import Data.Aeson.TH (deriveJSON)
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
+
+import Language.PureScript.AST.SourcePos (SourcePos, pattern SourcePos)
-- | A sum of the possible name types, useful for error and lint messages.
data Name
@@ -28,10 +31,10 @@ data Name
| DctorName (ProperName 'ConstructorName)
| TyClassName (ProperName 'ClassName)
| ModName ModuleName
- | KiName (ProperName 'KindName)
deriving (Eq, Ord, Show, Generic)
instance NFData Name
+instance Serialise Name
getIdentName :: Name -> Maybe Ident
getIdentName (IdentName name) = Just name
@@ -45,10 +48,6 @@ getTypeName :: Name -> Maybe (ProperName 'TypeName)
getTypeName (TyName name) = Just name
getTypeName _ = Nothing
-getKindName :: Name -> Maybe (ProperName 'KindName)
-getKindName (KiName name) = Just name
-getKindName _ = Nothing
-
getTypeOpName :: Name -> Maybe (OpName 'TypeOpName)
getTypeOpName (TyOpName name) = Just name
getTypeOpName _ = Nothing
@@ -61,9 +60,20 @@ getClassName :: Name -> Maybe (ProperName 'ClassName)
getClassName (TyClassName name) = Just name
getClassName _ = Nothing
-getModName :: Name -> Maybe ModuleName
-getModName (ModName name) = Just name
-getModName _ = Nothing
+-- |
+-- This type is meant to be extended with any new uses for idents that come
+-- along. Adding constructors to this type is cheaper than adding them to
+-- `Ident` because functions that match on `Ident` can ignore all
+-- `InternalIdent`s with a single pattern, and thus don't have to change if
+-- a new `InternalIdentData` constructor is created.
+--
+data InternalIdentData
+ -- Used by CoreFn.Laziness
+ = RuntimeLazyFactory | Lazy !Text
+ deriving (Show, Eq, Ord, Generic)
+
+instance NFData InternalIdentData
+instance Serialise InternalIdentData
-- |
-- Names for value identifiers
@@ -81,15 +91,24 @@ data Ident
-- A generated name used only for type-checking
--
| UnusedIdent
+ -- |
+ -- A generated name used only for internal transformations
+ --
+ | InternalIdent !InternalIdentData
deriving (Show, Eq, Ord, Generic)
instance NFData Ident
+instance Serialise Ident
+
+unusedIdent :: Text
+unusedIdent = "$__unused"
runIdent :: Ident -> Text
runIdent (Ident i) = i
runIdent (GenIdent Nothing n) = "$" <> T.pack (show n)
runIdent (GenIdent (Just name) n) = "$" <> name <> T.pack (show n)
-runIdent UnusedIdent = "$__unused"
+runIdent UnusedIdent = unusedIdent
+runIdent InternalIdent{} = error "unexpected InternalIdent"
showIdent :: Ident -> Text
showIdent = runIdent
@@ -100,6 +119,10 @@ freshIdent name = GenIdent (Just name) <$> fresh
freshIdent' :: MonadSupply m => m Ident
freshIdent' = GenIdent Nothing <$> fresh
+isPlainIdent :: Ident -> Bool
+isPlainIdent Ident{} = True
+isPlainIdent _ = False
+
-- |
-- Operator alias names.
--
@@ -107,6 +130,7 @@ newtype OpName (a :: OpNameType) = OpName { runOpName :: Text }
deriving (Show, Eq, Ord, Generic)
instance NFData (OpName a)
+instance Serialise (OpName a)
instance ToJSON (OpName a) where
toJSON = toJSON . runOpName
@@ -125,6 +149,9 @@ data OpNameType = ValueOpName | TypeOpName | AnyOpName
eraseOpName :: OpName a -> OpName 'AnyOpName
eraseOpName = OpName . runOpName
+coerceOpName :: OpName a -> OpName b
+coerceOpName = OpName . runOpName
+
-- |
-- Proper names, i.e. capitalized names for e.g. module names, type//data constructors.
--
@@ -132,6 +159,7 @@ newtype ProperName (a :: ProperNameType) = ProperName { runProperName :: Text }
deriving (Show, Eq, Ord, Generic)
instance NFData (ProperName a)
+instance Serialise (ProperName a)
instance ToJSON (ProperName a) where
toJSON = toJSON . runProperName
@@ -146,7 +174,6 @@ data ProperNameType
= TypeName
| ConstructorName
| ClassName
- | KindName
| Namespace
-- |
@@ -160,53 +187,72 @@ coerceProperName = ProperName . runProperName
-- |
-- Module names
--
-newtype ModuleName = ModuleName [ProperName 'Namespace]
+newtype ModuleName = ModuleName Text
deriving (Show, Eq, Ord, Generic)
+ deriving newtype Serialise
instance NFData ModuleName
runModuleName :: ModuleName -> Text
-runModuleName (ModuleName pns) = T.intercalate "." (runProperName <$> pns)
+runModuleName (ModuleName name) = name
moduleNameFromString :: Text -> ModuleName
-moduleNameFromString = ModuleName . splitProperNames
- where
- splitProperNames s = case T.dropWhile (== '.') s of
- "" -> []
- s' -> ProperName w : splitProperNames s''
- where (w, s'') = T.break (== '.') s'
+moduleNameFromString = ModuleName
isBuiltinModuleName :: ModuleName -> Bool
-isBuiltinModuleName (ModuleName (ProperName "Prim" : _)) = True
-isBuiltinModuleName _ = False
+isBuiltinModuleName (ModuleName mn) = mn == "Prim" || "Prim." `T.isPrefixOf` mn
+
+data QualifiedBy
+ = BySourcePos SourcePos
+ | ByModuleName ModuleName
+ deriving (Show, Eq, Ord, Generic)
+
+pattern ByNullSourcePos :: QualifiedBy
+pattern ByNullSourcePos = BySourcePos (SourcePos 0 0)
+
+instance NFData QualifiedBy
+instance Serialise QualifiedBy
+
+isBySourcePos :: QualifiedBy -> Bool
+isBySourcePos (BySourcePos _) = True
+isBySourcePos _ = False
+
+byMaybeModuleName :: Maybe ModuleName -> QualifiedBy
+byMaybeModuleName (Just mn) = ByModuleName mn
+byMaybeModuleName Nothing = ByNullSourcePos
+
+toMaybeModuleName :: QualifiedBy -> Maybe ModuleName
+toMaybeModuleName (ByModuleName mn) = Just mn
+toMaybeModuleName (BySourcePos _) = Nothing
-- |
-- A qualified name, i.e. a name with an optional module name
--
-data Qualified a = Qualified (Maybe ModuleName) a
+data Qualified a = Qualified QualifiedBy a
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
instance NFData a => NFData (Qualified a)
+instance Serialise a => Serialise (Qualified a)
showQualified :: (a -> Text) -> Qualified a -> Text
-showQualified f (Qualified Nothing a) = f a
-showQualified f (Qualified (Just name) a) = runModuleName name <> "." <> f a
+showQualified f (Qualified (BySourcePos _) a) = f a
+showQualified f (Qualified (ByModuleName name) a) = runModuleName name <> "." <> f a
getQual :: Qualified a -> Maybe ModuleName
-getQual (Qualified mn _) = mn
+getQual (Qualified qb _) = toMaybeModuleName qb
-- |
-- Provide a default module name, if a name is unqualified
--
qualify :: ModuleName -> Qualified a -> (ModuleName, a)
-qualify m (Qualified Nothing a) = (m, a)
-qualify _ (Qualified (Just m) a) = (m, a)
+qualify m (Qualified (BySourcePos _) a) = (m, a)
+qualify _ (Qualified (ByModuleName m) a) = (m, a)
-- |
-- Makes a qualified value from a name and module name.
--
mkQualified :: a -> ModuleName -> Qualified a
-mkQualified name mn = Qualified (Just mn) name
+mkQualified name mn = Qualified (ByModuleName mn) name
-- | Remove the module name from a qualified name
disqualify :: Qualified a -> a
@@ -217,14 +263,14 @@ disqualify (Qualified _ a) = a
-- module name.
--
disqualifyFor :: Maybe ModuleName -> Qualified a -> Maybe a
-disqualifyFor mn (Qualified mn' a) | mn == mn' = Just a
+disqualifyFor mn (Qualified qb a) | mn == toMaybeModuleName qb = Just a
disqualifyFor _ _ = Nothing
-- |
-- Checks whether a qualified value is actually qualified with a module reference
--
isQualified :: Qualified a -> Bool
-isQualified (Qualified Nothing _) = False
+isQualified (Qualified (BySourcePos _) _) = False
isQualified _ = True
-- |
@@ -237,9 +283,40 @@ isUnqualified = not . isQualified
-- Checks whether a qualified value is qualified with a particular module
--
isQualifiedWith :: ModuleName -> Qualified a -> Bool
-isQualifiedWith mn (Qualified (Just mn') _) = mn == mn'
+isQualifiedWith mn (Qualified (ByModuleName mn') _) = mn == mn'
isQualifiedWith _ _ = False
-$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''Qualified)
+instance ToJSON a => ToJSON (Qualified a) where
+ toJSON (Qualified qb a) = case qb of
+ ByModuleName mn -> toJSON2 (mn, a)
+ BySourcePos ss -> toJSON2 (ss, a)
+
+instance FromJSON a => FromJSON (Qualified a) where
+ parseJSON v = byModule <|> bySourcePos <|> byMaybeModuleName'
+ where
+ byModule = do
+ (mn, a) <- parseJSON2 v
+ pure $ Qualified (ByModuleName mn) a
+ bySourcePos = do
+ (ss, a) <- parseJSON2 v
+ pure $ Qualified (BySourcePos ss) a
+ byMaybeModuleName' = do
+ (mn, a) <- parseJSON2 v
+ pure $ Qualified (byMaybeModuleName mn) a
+
+instance ToJSON ModuleName where
+ toJSON (ModuleName name) = toJSON (T.splitOn "." name)
+
+instance FromJSON ModuleName where
+ parseJSON = withArray "ModuleName" $ \names -> do
+ names' <- traverse parseJSON names
+ pure (ModuleName (T.intercalate "." (V.toList names')))
+
+instance ToJSONKey ModuleName where
+ toJSONKey = contramap runModuleName toJSONKey
+
+instance FromJSONKey ModuleName where
+ fromJSONKey = fmap moduleNameFromString fromJSONKey
+
+$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''InternalIdentData)
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''Ident)
-$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ModuleName)
diff --git a/src/Language/PureScript/Options.hs b/src/Language/PureScript/Options.hs
index 1de91c9e5b..d94d344cf0 100644
--- a/src/Language/PureScript/Options.hs
+++ b/src/Language/PureScript/Options.hs
@@ -1,10 +1,10 @@
-- | The data type of compiler options
module Language.PureScript.Options where
-import Prelude.Compat
-import qualified Data.Set as S
+import Prelude
+import Data.Set qualified as S
import Data.Map (Map)
-import qualified Data.Map as Map
+import Data.Map qualified as Map
-- | The data type of compiler options
data Options = Options
@@ -20,7 +20,7 @@ data Options = Options
defaultOptions :: Options
defaultOptions = Options False False (S.singleton JS)
-data CodegenTarget = JS | JSSourceMap | CoreFn
+data CodegenTarget = JS | JSSourceMap | CoreFn | Docs
deriving (Eq, Ord, Show)
codegenTargets :: Map String CodegenTarget
@@ -28,4 +28,5 @@ codegenTargets = Map.fromList
[ ("js", JS)
, ("sourcemaps", JSSourceMap)
, ("corefn", CoreFn)
+ , ("docs", Docs)
]
diff --git a/src/Language/PureScript/PSString.hs b/src/Language/PureScript/PSString.hs
index f466257f2a..2ceb481181 100644
--- a/src/Language/PureScript/PSString.hs
+++ b/src/Language/PureScript/PSString.hs
@@ -1,7 +1,3 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE DeriveGeneric #-}
-
module Language.PureScript.PSString
( PSString
, toUTF16CodeUnits
@@ -13,28 +9,30 @@ module Language.PureScript.PSString
, mkString
) where
-import Prelude.Compat
+import Prelude
import GHC.Generics (Generic)
+import Codec.Serialise (Serialise)
import Control.DeepSeq (NFData)
import Control.Exception (try, evaluate)
import Control.Applicative ((<|>))
-import Data.Char (chr)
+import Data.Char qualified as Char
import Data.Bits (shiftR)
+import Data.Either (fromRight)
import Data.List (unfoldr)
import Data.Scientific (toBoundedInteger)
import Data.String (IsString(..))
import Data.ByteString (ByteString)
-import qualified Data.ByteString as BS
+import Data.ByteString qualified as BS
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
import Data.Text.Encoding (decodeUtf16BE)
import Data.Text.Encoding.Error (UnicodeException)
-import qualified Data.Vector as V
+import Data.Vector qualified as V
import Data.Word (Word16, Word8)
import Numeric (showHex)
import System.IO.Unsafe (unsafePerformIO)
-import qualified Data.Aeson as A
-import qualified Data.Aeson.Types as A
+import Data.Aeson qualified as A
+import Data.Aeson.Types qualified as A
-- |
-- Strings in PureScript are sequences of UTF-16 code units, which do not
@@ -54,6 +52,7 @@ newtype PSString = PSString { toUTF16CodeUnits :: [Word16] }
deriving (Eq, Ord, Semigroup, Monoid, Generic)
instance NFData PSString
+instance Serialise PSString
instance Show PSString where
show = show . codePoints
@@ -67,14 +66,14 @@ instance Show PSString where
-- we do not export it.
--
codePoints :: PSString -> String
-codePoints = map (either (chr . fromIntegral) id) . decodeStringEither
+codePoints = map (either (Char.chr . fromIntegral) id) . decodeStringEither
-- |
-- Decode a PSString as UTF-16 text. Lone surrogates will be replaced with
-- U+FFFD REPLACEMENT CHARACTER
--
decodeStringWithReplacement :: PSString -> String
-decodeStringWithReplacement = map (either (const '\xFFFD') id) . decodeStringEither
+decodeStringWithReplacement = map (fromRight '\xFFFD') . decodeStringEither
-- |
-- Decode a PSString as UTF-16. Lone surrogates in the input are represented in
@@ -93,14 +92,6 @@ decodeStringEither = unfoldr decode . toUTF16CodeUnits
unsurrogate :: Word16 -> Word16 -> Char
unsurrogate h l = toEnum ((toInt h - 0xD800) * 0x400 + (toInt l - 0xDC00) + 0x10000)
--- |
--- Pretty print a PSString, using Haskell/PureScript escape sequences.
--- This is identical to the Show instance except that we get a Text out instead
--- of a String.
---
-prettyPrintString :: PSString -> Text
-prettyPrintString = T.pack . show
-
-- |
-- Attempt to decode a PSString as UTF-16 text. This will fail (returning
-- Nothing) if the argument contains lone surrogates.
@@ -155,6 +146,53 @@ instance A.FromJSON PSString where
parseCodeUnit :: A.Value -> A.Parser Word16
parseCodeUnit b = A.withScientific "two-byte non-negative integer" (maybe (A.typeMismatch "" b) return . toBoundedInteger) b
+-- |
+-- Pretty print a PSString, using PureScript escape sequences.
+--
+prettyPrintString :: PSString -> Text
+prettyPrintString s = "\"" <> foldMap encodeChar (decodeStringEither s) <> "\""
+ where
+ encodeChar :: Either Word16 Char -> Text
+ encodeChar (Left c) = "\\x" <> showHex' 6 c
+ encodeChar (Right c)
+ | c == '\t' = "\\t"
+ | c == '\r' = "\\r"
+ | c == '\n' = "\\n"
+ | c == '"' = "\\\""
+ | c == '\'' = "\\\'"
+ | c == '\\' = "\\\\"
+ | shouldPrint c = T.singleton c
+ | otherwise = "\\x" <> showHex' 6 (Char.ord c)
+
+ -- Note we do not use Data.Char.isPrint here because that includes things
+ -- like zero-width spaces and combining punctuation marks, which could be
+ -- confusing to print unescaped.
+ shouldPrint :: Char -> Bool
+ -- The standard space character, U+20 SPACE, is the only space char we should
+ -- print without escaping
+ shouldPrint ' ' = True
+ shouldPrint c =
+ Char.generalCategory c `elem`
+ [ Char.UppercaseLetter
+ , Char.LowercaseLetter
+ , Char.TitlecaseLetter
+ , Char.OtherLetter
+ , Char.DecimalNumber
+ , Char.LetterNumber
+ , Char.OtherNumber
+ , Char.ConnectorPunctuation
+ , Char.DashPunctuation
+ , Char.OpenPunctuation
+ , Char.ClosePunctuation
+ , Char.InitialQuote
+ , Char.FinalQuote
+ , Char.OtherPunctuation
+ , Char.MathSymbol
+ , Char.CurrencySymbol
+ , Char.ModifierSymbol
+ , Char.OtherSymbol
+ ]
+
-- |
-- Pretty print a PSString, using JavaScript escape sequences. Intended for
-- use in compiled JS output.
@@ -163,8 +201,8 @@ prettyPrintStringJS :: PSString -> Text
prettyPrintStringJS s = "\"" <> foldMap encodeChar (toUTF16CodeUnits s) <> "\""
where
encodeChar :: Word16 -> Text
- encodeChar c | c > 0xFF = "\\u" <> hex 4 c
- encodeChar c | c > 0x7E || c < 0x20 = "\\x" <> hex 2 c
+ encodeChar c | c > 0xFF = "\\u" <> showHex' 4 c
+ encodeChar c | c > 0x7E || c < 0x20 = "\\x" <> showHex' 2 c
encodeChar c | toChar c == '\b' = "\\b"
encodeChar c | toChar c == '\t' = "\\t"
encodeChar c | toChar c == '\n' = "\\n"
@@ -175,10 +213,10 @@ prettyPrintStringJS s = "\"" <> foldMap encodeChar (toUTF16CodeUnits s) <> "\""
encodeChar c | toChar c == '\\' = "\\\\"
encodeChar c = T.singleton $ toChar c
- hex :: (Enum a) => Int -> a -> Text
- hex width c =
- let hs = showHex (fromEnum c) "" in
- T.pack (replicate (width - length hs) '0' <> hs)
+showHex' :: Enum a => Int -> a -> Text
+showHex' width c =
+ let hs = showHex (fromEnum c) "" in
+ T.pack (replicate (width - length hs) '0' <> hs)
isLead :: Word16 -> Bool
isLead h = h >= 0xD800 && h <= 0xDBFF
diff --git a/src/Language/PureScript/Parser.hs b/src/Language/PureScript/Parser.hs
deleted file mode 100644
index c7ac55a3dd..0000000000
--- a/src/Language/PureScript/Parser.hs
+++ /dev/null
@@ -1,23 +0,0 @@
--- |
--- A collection of parsers for core data types:
---
--- [@Language.PureScript.Parser.Kinds@] Parser for kinds
---
--- [@Language.PureScript.Parser.Values@] Parser for values
---
--- [@Language.PureScript.Parser.Types@] Parser for types
---
--- [@Language.PureScript.Parser.Declaration@] Parsers for declarations and modules
---
--- [@Language.PureScript.Parser.State@] Parser state, including indentation
---
--- [@Language.PureScript.Parser.Common@] Common parsing utility functions
---
-module Language.PureScript.Parser (module P) where
-
-import Language.PureScript.Parser.Common as P
-import Language.PureScript.Parser.Declarations as P
-import Language.PureScript.Parser.Kinds as P
-import Language.PureScript.Parser.Lexer as P
-import Language.PureScript.Parser.State as P
-import Language.PureScript.Parser.Types as P
diff --git a/src/Language/PureScript/Parser/Common.hs b/src/Language/PureScript/Parser/Common.hs
deleted file mode 100644
index 0b430baabe..0000000000
--- a/src/Language/PureScript/Parser/Common.hs
+++ /dev/null
@@ -1,160 +0,0 @@
--- | Useful common functions for building parsers
-module Language.PureScript.Parser.Common where
-
-import Prelude.Compat
-
-import Control.Applicative ((<|>))
-import Control.Monad (guard)
-import Data.Maybe (fromMaybe)
-import Data.Text (Text)
-import qualified Data.Text as T
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Comments
-import Language.PureScript.Names
-import Language.PureScript.Parser.Lexer
-import Language.PureScript.Parser.State
-import Language.PureScript.PSString (PSString, mkString)
-import qualified Text.Parsec as P
-
--- | Parse a general proper name.
-properName :: TokenParser (ProperName a)
-properName = ProperName <$> uname
-
--- | Parse a proper name for a type.
-typeName :: TokenParser (ProperName 'TypeName)
-typeName = ProperName <$> tyname
-
--- | Parse a proper name for a kind.
-kindName :: TokenParser (ProperName 'KindName)
-kindName = ProperName <$> kiname
-
--- | Parse a proper name for a data constructor.
-dataConstructorName :: TokenParser (ProperName 'ConstructorName)
-dataConstructorName = ProperName <$> dconsname
-
--- | Parse a module name
-moduleName :: TokenParser ModuleName
-moduleName = part []
- where
- part path = (do name <- ProperName <$> P.try qualifier
- part (path `snoc` name))
- <|> (ModuleName . snoc path . ProperName <$> mname)
- snoc path name = path ++ [name]
-
--- | Parse a qualified name, i.e. M.name or just name
-parseQualified :: TokenParser a -> TokenParser (Qualified a)
-parseQualified parser = part []
- where
- part path = (do name <- ProperName <$> P.try qualifier
- part (updatePath path name))
- <|> (Qualified (qual path) <$> P.try parser)
- updatePath path name = path ++ [name]
- qual path = if null path then Nothing else Just $ ModuleName path
-
--- | Parse an identifier.
-parseIdent :: TokenParser Ident
-parseIdent = Ident <$> identifier
-
--- | Parse a label, which may look like an identifier or a string
-parseLabel :: TokenParser PSString
-parseLabel = (mkString <$> lname) <|> stringLiteral
-
--- | Parse an operator.
-parseOperator :: TokenParser (OpName a)
-parseOperator = OpName <$> symbol
-
--- | Run the first parser, then match the second if possible, applying the specified function on a successful match
-augment :: P.Stream s m t => P.ParsecT s u m a -> P.ParsecT s u m b -> (a -> b -> a) -> P.ParsecT s u m a
-augment p q f = flip (maybe id $ flip f) <$> p <*> P.optionMaybe q
-
--- | Run the first parser, then match the second zero or more times, applying the specified function for each match
-fold :: P.ParsecT s u m a -> P.ParsecT s u m b -> (a -> b -> a) -> P.ParsecT s u m a
-fold first' more combine = do
- a <- first'
- bs <- P.many more
- return $ foldl combine a bs
-
--- | Build a parser from a smaller parser and a list of parsers for postfix operators
-buildPostfixParser :: P.Stream s m t => [a -> P.ParsecT s u m a] -> P.ParsecT s u m a -> P.ParsecT s u m a
-buildPostfixParser fs first' = do
- a <- first'
- go a
- where
- go a = do
- maybeA <- P.optionMaybe $ P.choice (map ($ a) fs)
- case maybeA of
- Nothing -> return a
- Just a' -> go a'
-
--- | Mark the current indentation level
-mark :: P.Parsec s ParseState a -> P.Parsec s ParseState a
-mark p = do
- current <- indentationLevel <$> P.getState
- pos <- P.sourceColumn <$> P.getPosition
- P.modifyState $ \st -> st { indentationLevel = pos }
- a <- p
- P.modifyState $ \st -> st { indentationLevel = current }
- return a
-
--- | Check that the current identation level matches a predicate
-checkIndentation
- :: (P.Column -> Text)
- -> (P.Column -> P.Column -> Bool)
- -> P.Parsec s ParseState ()
-checkIndentation mkMsg rel = do
- col <- P.sourceColumn <$> P.getPosition
- current <- indentationLevel <$> P.getState
- guard (col `rel` current) P.> T.unpack (mkMsg current)
-
--- | Check that the current indentation level is past the current mark
-indented :: P.Parsec s ParseState ()
-indented = checkIndentation (("indentation past column " <>) . (T.pack . show)) (>)
-
--- | Check that the current indentation level is at the same indentation as the current mark
-same :: P.Parsec s ParseState ()
-same = checkIndentation (("indentation at column " <>) . (T.pack . show)) (==)
-
--- | Read the comments from the the next token, without consuming it
-readComments :: P.Parsec [PositionedToken] u [Comment]
-readComments = P.lookAhead $ ptComments <$> P.anyToken
-
--- | Run a parser
-runTokenParser :: FilePath -> TokenParser a -> [PositionedToken] -> Either P.ParseError a
-runTokenParser filePath p = P.runParser p (ParseState 0) filePath
-
--- | Convert from Parsec sourcepos
-toSourcePos :: P.SourcePos -> SourcePos
-toSourcePos pos = SourcePos (P.sourceLine pos) (P.sourceColumn pos)
-
--- | Read source position information and comments
-withSourceSpan
- :: (SourceSpan -> [Comment] -> a -> b)
- -> P.Parsec [PositionedToken] u a
- -> P.Parsec [PositionedToken] u b
-withSourceSpan f p = do
- comments <- readComments
- start <- P.getPosition
- x <- p
- end <- P.getPosition
- input <- P.getInput
- let end' = case input of
- pt:_ -> ptPrevEndPos pt
- _ -> Nothing
- let sp = SourceSpan (P.sourceName start) (toSourcePos start) (toSourcePos $ fromMaybe end end')
- return $ f sp comments x
-
-withSourceAnnF
- :: P.Parsec [PositionedToken] u (SourceAnn -> a)
- -> P.Parsec [PositionedToken] u a
-withSourceAnnF = withSourceSpan (\ss com f -> f (ss, com))
-
-withSourceSpan'
- :: (SourceSpan -> a -> b)
- -> P.Parsec [PositionedToken] u a
- -> P.Parsec [PositionedToken] u b
-withSourceSpan' f = withSourceSpan (\ss _ -> f ss)
-
-withSourceSpanF
- :: P.Parsec [PositionedToken] u (SourceSpan -> a)
- -> P.Parsec [PositionedToken] u a
-withSourceSpanF = withSourceSpan (\ss _ f -> f ss)
diff --git a/src/Language/PureScript/Parser/Declarations.hs b/src/Language/PureScript/Parser/Declarations.hs
deleted file mode 100644
index f1cf76eda3..0000000000
--- a/src/Language/PureScript/Parser/Declarations.hs
+++ /dev/null
@@ -1,617 +0,0 @@
--- | Parsers for module definitions and declarations
-module Language.PureScript.Parser.Declarations
- ( parseDeclaration
- , parseDeclarationRef
- , parseModule
- , parseModuleDeclaration
- , parseValue
- , parseGuard
- , parseBinder
- , parseBinderNoParens
- , parseImportDeclaration'
- , parseLocalDeclaration
- ) where
-
-import Prelude hiding (lex)
-import Protolude (ordNub)
-
-import Control.Applicative
-import Control.Arrow ((+++))
-import Control.Monad (foldM, join, zipWithM)
-import Data.Functor (($>))
-import Data.Maybe (fromMaybe)
-import qualified Data.Set as S
-import Data.Text (pack)
-import Language.PureScript.AST
-import Language.PureScript.Environment
-import Language.PureScript.Names
-import Language.PureScript.Parser.Common
-import Language.PureScript.Parser.Kinds
-import Language.PureScript.Parser.Lexer
-import Language.PureScript.Parser.Types
-import Language.PureScript.PSString (PSString, mkString)
-import Language.PureScript.Types
-import qualified Text.Parsec as P
-import qualified Text.Parsec.Expr as P
-
-fields :: [Ident]
-fields = [ Ident ("value" <> pack (show (n :: Integer))) | n <- [0..] ]
-
-parseDataDeclaration :: TokenParser Declaration
-parseDataDeclaration = withSourceAnnF $ do
- dtype <- (reserved "data" *> return Data) <|> (reserved "newtype" *> return Newtype)
- name <- indented *> typeName
- tyArgs <- many (indented *> kindedIdent)
- ctors <- P.option [] $ do
- indented *> equals
- flip P.sepBy1 pipe $ do
- ctorName <- dataConstructorName
- tys <- P.many (indented *> noWildcards parseTypeAtom)
- return (ctorName, zip fields tys)
- return $ \sa -> DataDeclaration sa dtype name tyArgs ctors
-
-parseTypeDeclaration :: TokenParser Declaration
-parseTypeDeclaration = withSourceAnnF $ do
- name <- P.try (parseIdent <* indented <* doubleColon)
- ty <- parsePolyType
- return $ \sa -> TypeDeclaration (TypeDeclarationData sa name ty)
-
-parseTypeSynonymDeclaration :: TokenParser Declaration
-parseTypeSynonymDeclaration = withSourceAnnF $ do
- name <- reserved "type" *> indented *> typeName
- vars <- many (indented *> kindedIdent)
- ty <- indented *> equals *> noWildcards parsePolyType
- return $ \sa -> TypeSynonymDeclaration sa name vars ty
-
-parseValueWithWhereClause :: TokenParser Expr
-parseValueWithWhereClause = do
- indented
- value <- parseValue
- whereClause <- P.optionMaybe $ do
- indented
- reserved "where"
- indented
- mark $ P.many1 (same *> parseLocalDeclaration)
- return $ maybe value (\ds -> Let FromWhere ds value) whereClause
-
-parseValueWithIdentAndBinders :: Ident -> [Binder] -> TokenParser (SourceAnn -> Declaration)
-parseValueWithIdentAndBinders ident bs = do
- value <- indented *> (
- (\v -> [MkUnguarded v]) <$> (equals *> withSourceSpan PositionedValue parseValueWithWhereClause) <|>
- P.many1 (GuardedExpr <$> parseGuard
- <*> (indented *> equals
- *> withSourceSpan PositionedValue parseValueWithWhereClause))
- )
- return $ \sa -> ValueDecl sa ident Public bs value
-
-parseValueDeclaration :: TokenParser Declaration
-parseValueDeclaration = withSourceAnnF $ do
- ident <- parseIdent
- binders <- P.many parseBinderNoParens
- parseValueWithIdentAndBinders ident binders
-
-parseLocalValueDeclaration :: TokenParser Declaration
-parseLocalValueDeclaration = withSourceAnnF .
- join $ go <$> parseBinder <*> P.many parseBinderNoParens
- where
- go :: Binder -> [Binder] -> TokenParser (SourceAnn -> Declaration)
- go (VarBinder _ ident) bs = parseValueWithIdentAndBinders ident bs
- go (PositionedBinder _ _ b) bs = go b bs
- go binder [] = do
- boot <- indented *> equals *> parseValueWithWhereClause
- return $ \sa -> BoundValueDeclaration sa binder boot
- go _ _ = P.unexpected "patterns in local value declaration"
-
-parseExternDeclaration :: TokenParser Declaration
-parseExternDeclaration = withSourceAnnF $
- reserved "foreign" *>
- indented *> reserved "import" *>
- indented *> (parseExternData <|> P.try parseExternKind <|> parseExternTerm)
- where
- parseExternData =
- (\name kind sa -> ExternDataDeclaration sa name kind)
- <$> (reserved "data" *> indented *> typeName)
- <*> (indented *> doubleColon *> parseKind)
- parseExternKind =
- flip ExternKindDeclaration
- <$> (reserved "kind" *> indented *> kindName)
- parseExternTerm =
- (\name ty sa -> ExternDeclaration sa name ty)
- <$> parseIdent
- <*> (indented *> doubleColon *> noWildcards parsePolyType)
-
-parseAssociativity :: TokenParser Associativity
-parseAssociativity =
- (reserved "infixl" *> return Infixl) <|>
- (reserved "infixr" *> return Infixr) <|>
- (reserved "infix" *> return Infix)
-
-parseFixity :: TokenParser Fixity
-parseFixity = Fixity <$> parseAssociativity <*> (indented *> natural)
-
-parseFixityDeclaration :: TokenParser Declaration
-parseFixityDeclaration = withSourceAnnF $ do
- fixity <- parseFixity
- indented
- def <- (Right <$> typeFixity fixity) <|> (Left <$> valueFixity fixity)
- return $ \sa -> FixityDeclaration sa def
- where
- typeFixity fixity =
- TypeFixity fixity
- <$> (reserved "type" *> parseQualified typeName)
- <*> (reserved "as" *> parseOperator)
- valueFixity fixity =
- ValueFixity fixity
- <$> parseQualified ((Left <$> parseIdent) <|> (Right <$> dataConstructorName))
- <*> (reserved "as" *> parseOperator)
-
-parseImportDeclaration :: TokenParser Declaration
-parseImportDeclaration = withSourceAnnF $ do
- (mn, declType, asQ) <- parseImportDeclaration'
- return $ \sa -> ImportDeclaration sa mn declType asQ
-
-parseImportDeclaration' :: TokenParser (ModuleName, ImportDeclarationType, Maybe ModuleName)
-parseImportDeclaration' = do
- reserved "import"
- indented
- moduleName' <- moduleName
- declType <- reserved "hiding" *> qualifyingList Hiding <|> qualifyingList Explicit
- qName <- P.optionMaybe qualifiedName
- return (moduleName', declType, qName)
- where
- qualifiedName = reserved "as" *> moduleName
- qualifyingList expectedType = do
- declType <- P.optionMaybe (expectedType <$> (indented *> parens (commaSep parseDeclarationRef)))
- return $ fromMaybe Implicit declType
-
-parseDeclarationRef :: TokenParser DeclarationRef
-parseDeclarationRef =
- withSourceSpan' KindRef (P.try (reserved "kind" *> kindName))
- <|> withSourceSpan' ValueRef parseIdent
- <|> withSourceSpan' ValueOpRef (parens parseOperator)
- <|> withSourceSpan' (\sa -> ($ TypeRef sa)) parseTypeRef
- <|> withSourceSpan' TypeClassRef (reserved "class" *> properName)
- <|> withSourceSpan' ModuleRef (indented *> reserved "module" *> moduleName)
- <|> withSourceSpan' TypeOpRef (indented *> reserved "type" *> parens parseOperator)
- where
- parseTypeRef = do
- name <- typeName
- dctors <- P.optionMaybe $ parens (symbol' ".." *> pure Nothing <|> Just <$> commaSep dataConstructorName)
- return $ \f -> f name (fromMaybe (Just []) dctors)
-
-parseTypeClassDeclaration :: TokenParser Declaration
-parseTypeClassDeclaration = withSourceAnnF $ do
- reserved "class"
- implies <- P.option [] . P.try $ do
- indented
- implies <- (return <$> parseConstraint) <|> parens (commaSep1 parseConstraint)
- lfatArrow
- return implies
- className <- indented *> properName
- idents <- P.many (indented *> kindedIdent)
- let parseNamedIdent = foldl (<|>) empty (zipWith (\(name, _) index -> lname' name $> index) idents [0..])
- parseFunctionalDependency =
- FunctionalDependency <$> P.many parseNamedIdent <* rarrow
- <*> P.many parseNamedIdent
- dependencies <- P.option [] (indented *> pipe *> commaSep1 parseFunctionalDependency)
- members <- P.option [] $ do
- indented *> reserved "where"
- indented *> mark (P.many (same *> parseTypeDeclaration))
- return $ \sa -> TypeClassDeclaration sa className idents implies dependencies members
-
-parseConstraint :: TokenParser SourceConstraint
-parseConstraint = withSourceAnnF $ do
- name <- parseQualified properName
- args <- P.many (noWildcards $ noForAll parseTypeAtom)
- return $ \ann -> Constraint ann name args Nothing
-
-parseInstanceDeclaration :: TokenParser (TypeInstanceBody -> Declaration)
-parseInstanceDeclaration = withSourceAnnF $ do
- reserved "instance"
- name <- parseIdent <* indented <* doubleColon
- deps <- P.optionMaybe . P.try $ do
- deps <- (return <$> parseConstraint) <|> parens (commaSep1 parseConstraint)
- indented
- rfatArrow
- return deps
- className <- indented *> parseQualified properName
- ty <- P.many (indented *> parseTypeAtom)
- return $ \sa -> TypeInstanceDeclaration sa [] 0 name (fromMaybe [] deps) className ty
-
-parseTypeInstanceDeclaration :: TokenParser Declaration
-parseTypeInstanceDeclaration = do
- instanceDecl <- parseInstanceDeclaration
- members <- P.option [] $ do
- indented *> reserved "where"
- indented *> mark (P.many (same *> declsInInstance))
- return $ instanceDecl (ExplicitInstance members)
- where
- declsInInstance :: TokenParser Declaration
- declsInInstance = P.choice
- [ parseTypeDeclaration
- , parseValueDeclaration
- ] P.> "type declaration or value declaration in instance"
-
-parseTypeInstanceChainDeclaration :: TokenParser [Declaration]
-parseTypeInstanceChainDeclaration = do
- instances <- P.sepBy1 parseTypeInstanceDeclaration (reserved "else")
- ensureSameTypeClass instances
- chainId <- traverse getTypeInstanceName instances
- zipWithM (setTypeInstanceChain chainId) instances [0..]
- where
- getTypeInstanceName :: Declaration -> TokenParser Ident
- getTypeInstanceName (TypeInstanceDeclaration _ _ _ name _ _ _ _) = return name
- getTypeInstanceName _ = P.unexpected "Found non-instance in chain declaration."
-
- setTypeInstanceChain :: [Ident] -> Declaration -> Integer -> TokenParser Declaration
- setTypeInstanceChain chain (TypeInstanceDeclaration sa _ _ n d c t b) index = return (TypeInstanceDeclaration sa chain index n d c t b)
- setTypeInstanceChain _ _ _ = P.unexpected "Found non-instance in chain declaration."
-
- getTypeInstanceClass :: Declaration -> TokenParser (Qualified (ProperName 'ClassName))
- getTypeInstanceClass (TypeInstanceDeclaration _ _ _ _ _ tc _ _) = return tc
- getTypeInstanceClass _ = P.unexpected "Found non-instance in chain declaration."
-
- ensureSameTypeClass :: [Declaration] -> TokenParser ()
- ensureSameTypeClass xs = do
- classNames <- ordNub <$> traverse getTypeInstanceClass xs
- case classNames of
- [_] -> return ()
- _ -> P.unexpected "All instances in a chain must implement the same type class."
-
-parseDerivingInstanceDeclaration :: TokenParser Declaration
-parseDerivingInstanceDeclaration = do
- reserved "derive"
- ty <- P.option DerivedInstance (reserved "newtype" $> NewtypeInstance)
- instanceDecl <- parseInstanceDeclaration
- return $ instanceDecl ty
-
--- | Parse a single declaration. May include a collection of instances in a chain.
-parseDeclaration :: TokenParser [Declaration]
-parseDeclaration =
- P.choice
- [ pure <$> parseDataDeclaration
- , pure <$> parseTypeDeclaration
- , pure <$> parseTypeSynonymDeclaration
- , pure <$> parseValueDeclaration
- , pure <$> parseExternDeclaration
- , pure <$> parseFixityDeclaration
- , pure <$> parseTypeClassDeclaration
- , parseTypeInstanceChainDeclaration
- , pure <$> parseDerivingInstanceDeclaration
- ] P.> "declaration"
-
-parseLocalDeclaration :: TokenParser Declaration
-parseLocalDeclaration =
- P.choice
- [ parseTypeDeclaration
- , parseLocalValueDeclaration
- ] P.> "local declaration"
-
--- | Parse a module declaration and its export declarations
-parseModuleDeclaration :: TokenParser (ModuleName, Maybe [DeclarationRef])
-parseModuleDeclaration = do
- reserved "module"
- indented
- name <- moduleName
- exports <- P.optionMaybe . parens $ commaSep1 parseDeclarationRef
- reserved "where"
- pure (name, exports)
-
--- | Parse a module header and a collection of declarations
-parseModule :: TokenParser Module
-parseModule = do
- comments <- readComments
- start <- P.getPosition
- (name, exports) <- parseModuleDeclaration
- decls <- mark $ do
- -- TODO: extract a module header structure here, and provide a
- -- parseModuleHeader function. This should allow us to speed up rebuilds
- -- by only parsing as far as the module header. See PR #2054.
- imports <- P.many (same *> parseImportDeclaration)
- decls <- join <$> P.many (same *> parseDeclaration)
- return (imports <> decls)
- _ <- P.eof
- end <- P.getPosition
- let ss = SourceSpan (P.sourceName start) (toSourcePos start) (toSourcePos end)
- return $ Module ss comments name decls exports
-
-booleanLiteral :: TokenParser Bool
-booleanLiteral = (reserved "true" >> return True) P.<|> (reserved "false" >> return False)
-
-parseNumericLiteral :: TokenParser (Literal a)
-parseNumericLiteral = NumericLiteral <$> number
-
-parseCharLiteral :: TokenParser (Literal a)
-parseCharLiteral = CharLiteral <$> charLiteral
-
-parseStringLiteral :: TokenParser (Literal a)
-parseStringLiteral = StringLiteral <$> stringLiteral
-
-parseBooleanLiteral :: TokenParser (Literal a)
-parseBooleanLiteral = BooleanLiteral <$> booleanLiteral
-
-parseArrayLiteral :: TokenParser a -> TokenParser (Literal a)
-parseArrayLiteral p = ArrayLiteral <$> squares (commaSep p)
-
-parseObjectLiteral :: TokenParser (PSString, a) -> TokenParser (Literal a)
-parseObjectLiteral p = ObjectLiteral <$> braces (commaSep p)
-
-parseIdentifierAndValue :: TokenParser (PSString, Expr)
-parseIdentifierAndValue =
- do
- (ss, name) <- indented *> withSourceSpan' (,) lname
- b <- P.option (Var ss $ Qualified Nothing (Ident name)) rest
- return (mkString name, b)
- <|> (,) <$> (indented *> stringLiteral) <*> rest
- where
- rest = indented *> colon *> indented *> parseValue
-
-parseAbs :: TokenParser Expr
-parseAbs = do
- symbol' "\\"
- args <- P.many1 (indented *> (Abs <$> parseBinderNoParens))
- indented *> rarrow
- value <- parseValue
- return $ toFunction args value
- where
- toFunction :: [Expr -> Expr] -> Expr -> Expr
- toFunction args value = foldr ($) value args
-
-parseVar :: TokenParser Expr
-parseVar = withSourceSpan' Var $ parseQualified parseIdent
-
-parseConstructor :: TokenParser Expr
-parseConstructor = withSourceSpan' Constructor $ parseQualified dataConstructorName
-
-parseCase :: TokenParser Expr
-parseCase = Case <$> P.between (reserved "case") (indented *> reserved "of") (commaSep1 parseValue)
- <*> (indented *> mark (P.many1 (same *> mark parseCaseAlternative)))
-
-parseCaseAlternative :: TokenParser CaseAlternative
-parseCaseAlternative = CaseAlternative <$> commaSep1 parseBinder
- <*> (indented *> (
- (pure . MkUnguarded) <$> (rarrow *> parseValue)
- <|> (P.many1 (GuardedExpr <$> parseGuard
- <*> (indented
- *> rarrow
- *> parseValue)
- ))))
- P.> "case alternative"
-
-parseIfThenElse :: TokenParser Expr
-parseIfThenElse = IfThenElse <$> (P.try (reserved "if") *> indented *> parseValue)
- <*> (indented *> reserved "then" *> indented *> parseValue)
- <*> (indented *> reserved "else" *> indented *> parseValue)
-
-parseLet :: TokenParser Expr
-parseLet = do
- reserved "let"
- indented
- ds <- mark $ P.many1 (same *> parseLocalDeclaration)
- indented
- reserved "in"
- result <- parseValue
- return $ Let FromLet ds result
-
-parseValueAtom :: TokenParser Expr
-parseValueAtom = withSourceSpan PositionedValue $ P.choice
- [ parseAnonymousArgument
- , withSourceSpan' Literal $ parseNumericLiteral
- , withSourceSpan' Literal $ parseCharLiteral
- , withSourceSpan' Literal $ parseStringLiteral
- , withSourceSpan' Literal $ parseBooleanLiteral
- , withSourceSpan' Literal $ parseArrayLiteral parseValue
- , withSourceSpan' Literal $ parseObjectLiteral parseIdentifierAndValue
- , parseAbs
- , P.try parseConstructor
- , P.try parseVar
- , parseCase
- , parseIfThenElse
- , parseDo
- , parseAdo
- , parseLet
- , P.try $ Parens <$> parens parseValue
- , withSourceSpan' Op $ parseQualified (parens parseOperator)
- , parseHole
- ]
-
--- | Parse an expression in backticks or an operator
-parseInfixExpr :: TokenParser Expr
-parseInfixExpr
- = P.between tick tick parseValue
- <|> withSourceSpan' Op (parseQualified parseOperator)
-
-parseHole :: TokenParser Expr
-parseHole = Hole <$> holeLit
-
-parsePropertyUpdate :: TokenParser (PSString, PathNode Expr)
-parsePropertyUpdate = do
- name <- parseLabel
- updates <- parseShallowUpdate <|> parseNestedUpdate
- return (name, updates)
- where
- parseShallowUpdate :: TokenParser (PathNode Expr)
- parseShallowUpdate = Leaf <$> (indented *> equals *> indented *> parseValue)
-
- parseNestedUpdate :: TokenParser (PathNode Expr)
- parseNestedUpdate = Branch <$> parseUpdaterBodyFields
-
-parseAccessor :: Expr -> TokenParser Expr
-parseAccessor (Constructor _ _) = P.unexpected "constructor"
-parseAccessor obj = P.try $ Accessor <$> (indented *> dot *> indented *> parseLabel) <*> pure obj
-
-parseDo :: TokenParser Expr
-parseDo = do
- m <- P.try (getQual <$> parseQualified (reserved "do")) <|> (reserved "do" *> pure Nothing)
- indented
- Do m <$> mark (P.many1 (same *> mark parseDoNotationElement))
-
-parseAdo :: TokenParser Expr
-parseAdo = do
- m <- P.try (getQual <$> parseQualified (reserved "ado")) <|> (reserved "ado" *> pure Nothing)
- indented
- elements <- mark (P.many (same *> mark parseDoNotationElement))
- yield <- mark (reserved "in" *> parseValue)
- pure $ Ado m elements yield
-
-parseDoNotationLet :: TokenParser DoNotationElement
-parseDoNotationLet = DoNotationLet <$> (reserved "let" *> indented *> mark (P.many1 (same *> parseLocalDeclaration)))
-
-parseDoNotationBind :: TokenParser DoNotationElement
-parseDoNotationBind = DoNotationBind <$> P.try (parseBinder <* indented <* larrow) <*> parseValue
-
-parseDoNotationElement :: TokenParser DoNotationElement
-parseDoNotationElement = withSourceSpan PositionedDoNotationElement $ P.choice
- [ parseDoNotationBind
- , parseDoNotationLet
- , DoNotationValue <$> parseValue
- ]
-
--- | Expressions including indexers and record updates
-indexersAndAccessors :: TokenParser Expr
-indexersAndAccessors = buildPostfixParser postfixTable parseValueAtom
- where
- postfixTable = [ parseAccessor
- , P.try . parseUpdaterBody
- ]
-
--- | Parse an expression
-parseValue :: TokenParser Expr
-parseValue =
- P.buildExpressionParser operators
- (buildPostfixParser postfixTable indexersAndAccessors)
- P.> "expression"
- where
- postfixTable = [ \v -> P.try (flip App <$> (indented *> indexersAndAccessors)) <*> pure v
- , \v -> flip (TypedValue True) <$> (indented *> doubleColon *> parsePolyType) <*> pure v
- ]
- operators = [ [ P.Prefix (indented *> withSourceSpan' (\ss _ -> UnaryMinus ss) (symbol' "-"))
- ]
- , [ P.Infix (P.try (indented *> parseInfixExpr P.> "infix expression") >>= \ident ->
- return (BinaryNoParens ident)) P.AssocRight
- ]
- ]
-
-parseUpdaterBodyFields :: TokenParser (PathTree Expr)
-parseUpdaterBodyFields = do
- updates <- indented *> braces (commaSep1 (indented *> parsePropertyUpdate))
- (_, tree) <- foldM insertUpdate (S.empty, []) updates
- return (PathTree (AssocList (reverse tree)))
- where
- insertUpdate (seen, xs) (key, node)
- | S.member key seen = P.unexpected ("Duplicate key in record update: " <> show key)
- | otherwise = return (S.insert key seen, (key, node) : xs)
-
-parseUpdaterBody :: Expr -> TokenParser Expr
-parseUpdaterBody v = ObjectUpdateNested v <$> parseUpdaterBodyFields
-
-parseAnonymousArgument :: TokenParser Expr
-parseAnonymousArgument = underscore *> pure AnonymousArgument
-
-parseNumberLiteral :: TokenParser Binder
-parseNumberLiteral = withSourceSpanF $
- (\n ss -> LiteralBinder ss (NumericLiteral n)) <$> (sign <*> number)
- where
- sign :: TokenParser (Either Integer Double -> Either Integer Double)
- sign = (symbol' "-" >> return (negate +++ negate))
- <|> (symbol' "+" >> return id)
- <|> return id
-
-parseNullaryConstructorBinder :: TokenParser Binder
-parseNullaryConstructorBinder = withSourceSpanF $
- (\name ss -> ConstructorBinder ss name [])
- <$> parseQualified dataConstructorName
-
-parseConstructorBinder :: TokenParser Binder
-parseConstructorBinder = withSourceSpanF $
- (\name args ss -> ConstructorBinder ss name args)
- <$> parseQualified dataConstructorName
- <*> many (indented *> parseBinderNoParens)
-
-parseObjectBinder:: TokenParser Binder
-parseObjectBinder = withSourceSpanF $
- flip LiteralBinder <$> parseObjectLiteral (indented *> parseEntry)
- where
- parseEntry :: TokenParser (PSString, Binder)
- parseEntry = var <|> (,) <$> stringLiteral <*> rest
- where
- var = withSourceSpanF $ do
- name <- lname
- b <- P.option (\ss -> VarBinder ss (Ident name)) (const <$> rest)
- return $ \ss -> (mkString name, b ss)
- rest = indented *> colon *> indented *> parseBinder
-
-parseArrayBinder :: TokenParser Binder
-parseArrayBinder = withSourceSpanF $
- flip LiteralBinder <$> parseArrayLiteral (indented *> parseBinder)
-
-parseVarOrNamedBinder :: TokenParser Binder
-parseVarOrNamedBinder = withSourceSpanF $ do
- name <- parseIdent
- let parseNamedBinder = (\b ss -> NamedBinder ss name b) <$> (at *> indented *> parseBinderAtom)
- parseNamedBinder <|> return (`VarBinder` name)
-
-parseNullBinder :: TokenParser Binder
-parseNullBinder = underscore *> return NullBinder
-
--- | Parse a binder
-parseBinder :: TokenParser Binder
-parseBinder =
- withSourceSpan
- PositionedBinder
- ( P.buildExpressionParser operators
- . buildPostfixParser postfixTable
- $ parseBinderAtom
- )
- where
- operators =
- [ [ P.Infix (P.try (indented *> parseOpBinder P.> "binder operator") >>= \op ->
- return (BinaryNoParensBinder op)) P.AssocRight
- ]
- ]
-
- postfixTable = [ \b -> flip TypedBinder b <$> (indented *> doubleColon *> parsePolyType) ]
-
- parseOpBinder :: TokenParser Binder
- parseOpBinder = withSourceSpan' OpBinder $ parseQualified parseOperator
-
-parseBinderAtom :: TokenParser Binder
-parseBinderAtom = withSourceSpan PositionedBinder
- (P.choice
- [ parseNullBinder
- , withSourceSpanF $ flip LiteralBinder <$> parseCharLiteral
- , withSourceSpanF $ flip LiteralBinder <$> parseStringLiteral
- , withSourceSpanF $ flip LiteralBinder <$> parseBooleanLiteral
- , parseNumberLiteral
- , parseVarOrNamedBinder
- , parseConstructorBinder
- , parseObjectBinder
- , parseArrayBinder
- , ParensInBinder <$> parens parseBinder
- ] P.> "binder")
-
--- | Parse a binder as it would appear in a top level declaration
-parseBinderNoParens :: TokenParser Binder
-parseBinderNoParens = withSourceSpan PositionedBinder
- (P.choice
- [ parseNullBinder
- , withSourceSpanF $ flip LiteralBinder <$> parseCharLiteral
- , withSourceSpanF $ flip LiteralBinder <$> parseStringLiteral
- , withSourceSpanF $ flip LiteralBinder <$> parseBooleanLiteral
- , parseNumberLiteral
- , parseVarOrNamedBinder
- , parseNullaryConstructorBinder
- , parseObjectBinder
- , parseArrayBinder
- , ParensInBinder <$> parens parseBinder
- ] P.> "binder")
-
--- | Parse a guard
-parseGuard :: TokenParser [Guard]
-parseGuard =
- pipe *> indented *> P.sepBy1 (parsePatternGuard <|> parseConditionGuard) comma
- where
- parsePatternGuard =
- PatternGuard <$> P.try (parseBinder <* indented <* larrow) <*> parseValue
- parseConditionGuard =
- ConditionGuard <$> parseValue
diff --git a/src/Language/PureScript/Parser/Kinds.hs b/src/Language/PureScript/Parser/Kinds.hs
deleted file mode 100644
index abdc810957..0000000000
--- a/src/Language/PureScript/Parser/Kinds.hs
+++ /dev/null
@@ -1,34 +0,0 @@
--- |
--- A parser for kinds
---
-module Language.PureScript.Parser.Kinds (parseKind) where
-
-import Prelude.Compat
-
-import Language.PureScript.Kinds
-import Language.PureScript.Parser.Common
-import Language.PureScript.Parser.Lexer
-
-import qualified Text.Parsec as P
-import qualified Text.Parsec.Expr as P
-
-parseNamedKind :: TokenParser SourceKind
-parseNamedKind = withSourceAnnF $ do
- name <- parseQualified kindName
- return $ \ann -> NamedKind ann name
-
-parseKindAtom :: TokenParser SourceKind
-parseKindAtom =
- indented *> P.choice
- [ parseNamedKind
- , parens parseKind
- ]
-
--- |
--- Parse a kind
---
-parseKind :: TokenParser SourceKind
-parseKind = P.buildExpressionParser operators parseKindAtom P.> "kind"
- where
- operators = [ [ P.Prefix (withSourceAnnF $ symbol' "#" >> return Row) ]
- , [ P.Infix (withSourceAnnF $ rarrow >> return FunKind) P.AssocRight ] ]
diff --git a/src/Language/PureScript/Parser/Lexer.hs b/src/Language/PureScript/Parser/Lexer.hs
deleted file mode 100644
index cc615ff53f..0000000000
--- a/src/Language/PureScript/Parser/Lexer.hs
+++ /dev/null
@@ -1,610 +0,0 @@
--- |
--- The first step in the parsing process - turns source code into a list of lexemes
---
-module Language.PureScript.Parser.Lexer
- ( PositionedToken(..)
- , Token()
- , TokenParser()
- , lex
- , lexLenient
- , anyToken
- , token
- , match
- , lparen
- , rparen
- , parens
- , lbrace
- , rbrace
- , braces
- , lsquare
- , rsquare
- , squares
- , indent
- , indentAt
- , larrow
- , rarrow
- , lfatArrow
- , rfatArrow
- , colon
- , doubleColon
- , equals
- , pipe
- , tick
- , dot
- , comma
- , semi
- , at
- , underscore
- , holeLit
- , semiSep
- , semiSep1
- , commaSep
- , commaSep1
- , lname
- , lname'
- , qualifier
- , tyname
- , kiname
- , dconsname
- , uname
- , uname'
- , mname
- , reserved
- , symbol
- , symbol'
- , identifier
- , charLiteral
- , stringLiteral
- , number
- , natural
- , reservedPsNames
- , reservedTypeNames
- , isSymbolChar
- , isUnquotedKey
- )
- where
-
-import Prelude.Compat hiding (lex)
-
-import Control.Applicative ((<|>))
-import Control.Monad (void, guard)
-import Control.Monad.Identity (Identity)
-import Data.Char (isSpace, isAscii, isSymbol, isAlphaNum, isAlpha, isLower)
-import Data.String (fromString)
-import Data.Text (Text)
-import qualified Data.Text as T
-
-import Language.PureScript.Comments
-import Language.PureScript.Parser.State
-import Language.PureScript.PSString (PSString)
-
-import qualified Text.Parsec as P
-import qualified Text.Parsec.Token as PT
-
-data Token
- = LParen
- | RParen
- | LBrace
- | RBrace
- | LSquare
- | RSquare
- | Indent Int
- | LArrow
- | RArrow
- | LFatArrow
- | RFatArrow
- | Colon
- | DoubleColon
- | Equals
- | Pipe
- | Tick
- | Dot
- | Comma
- | Semi
- | At
- | Underscore
- | LName Text
- | UName Text
- | Qualifier Text
- | Symbol Text
- | CharLiteral Char
- | StringLiteral PSString
- | Number (Either Integer Double)
- | HoleLit Text
- deriving (Show, Eq, Ord)
-
-prettyPrintToken :: Token -> Text
-prettyPrintToken LParen = "("
-prettyPrintToken RParen = ")"
-prettyPrintToken LBrace = "{"
-prettyPrintToken RBrace = "}"
-prettyPrintToken LSquare = "["
-prettyPrintToken RSquare = "]"
-prettyPrintToken LArrow = "<-"
-prettyPrintToken RArrow = "->"
-prettyPrintToken LFatArrow = "<="
-prettyPrintToken RFatArrow = "=>"
-prettyPrintToken Colon = ":"
-prettyPrintToken DoubleColon = "::"
-prettyPrintToken Equals = "="
-prettyPrintToken Pipe = "|"
-prettyPrintToken Tick = "`"
-prettyPrintToken Dot = "."
-prettyPrintToken Comma = ","
-prettyPrintToken Semi = ";"
-prettyPrintToken At = "@"
-prettyPrintToken Underscore = "_"
-prettyPrintToken (Indent n) = "indentation at level " <> T.pack (show n)
-prettyPrintToken (LName s) = T.pack (show s)
-prettyPrintToken (UName s) = T.pack (show s)
-prettyPrintToken (Qualifier _) = "qualifier"
-prettyPrintToken (Symbol s) = s
-prettyPrintToken (CharLiteral c) = T.pack (show c)
-prettyPrintToken (StringLiteral s) = T.pack (show s)
-prettyPrintToken (Number n) = T.pack (either show show n)
-prettyPrintToken (HoleLit name) = "?" <> name
-
-data PositionedToken = PositionedToken
- { -- | Start position of this token
- ptSourcePos :: P.SourcePos
- -- | End position of this token (not including whitespace)
- , ptEndPos :: P.SourcePos
- -- | End position of the previous token
- , ptPrevEndPos :: Maybe P.SourcePos
- , ptToken :: Token
- , ptComments :: [Comment]
- } deriving (Eq)
-
--- Parsec requires this instance for various token-level combinators
-instance Show PositionedToken where
- show = T.unpack . prettyPrintToken . ptToken
-
-type Lexer u a = P.Parsec Text u a
-
-lex :: FilePath -> Text -> Either P.ParseError [PositionedToken]
-lex f s = updatePositions <$> P.parse parseTokens f s
-
-updatePositions :: [PositionedToken] -> [PositionedToken]
-updatePositions [] = []
-updatePositions (x:xs) = x : zipWith update (x:xs) xs
- where
- update PositionedToken { ptEndPos = pos } pt = pt { ptPrevEndPos = Just pos }
-
-parseTokens :: Lexer u [PositionedToken]
-parseTokens = whitespace *> P.many parsePositionedToken <* P.skipMany parseComment <* P.eof
-
--- | Lexes the given file, and on encountering a parse error, returns the
--- progress made up to that point, instead of returning an error
-lexLenient :: FilePath -> Text -> Either P.ParseError [PositionedToken]
-lexLenient f s = updatePositions <$> P.parse parseTokensLenient f s
-
-parseTokensLenient :: Lexer u [PositionedToken]
-parseTokensLenient = whitespace *> P.many parsePositionedToken <* P.skipMany parseComment
-
-whitespace :: Lexer u ()
-whitespace = P.skipMany (P.satisfy isSpace)
-
-parseComment :: Lexer u Comment
-parseComment = (BlockComment <$> blockComment <|> LineComment <$> lineComment) <* whitespace
- where
- blockComment :: Lexer u Text
- blockComment = P.try $ P.string "{-" *> (T.pack <$> P.manyTill P.anyChar (P.try (P.string "-}")))
-
- lineComment :: Lexer u Text
- lineComment = P.try $ P.string "--" *> (T.pack <$> P.manyTill P.anyChar (P.try (void (P.char '\n') <|> P.eof)))
-
-parsePositionedToken :: Lexer u PositionedToken
-parsePositionedToken = P.try $ do
- comments <- P.many parseComment
- pos <- P.getPosition
- tok <- parseToken
- pos' <- P.getPosition
- whitespace
- return $ PositionedToken pos pos' Nothing tok comments
-
-parseToken :: Lexer u Token
-parseToken = P.choice
- [ P.try $ P.string "<-" *> P.notFollowedBy symbolChar *> pure LArrow
- , P.try $ P.string "←" *> P.notFollowedBy symbolChar *> pure LArrow
- , P.try $ P.string "<=" *> P.notFollowedBy symbolChar *> pure LFatArrow
- , P.try $ P.string "⇐" *> P.notFollowedBy symbolChar *> pure LFatArrow
- , P.try $ P.string "->" *> P.notFollowedBy symbolChar *> pure RArrow
- , P.try $ P.string "→" *> P.notFollowedBy symbolChar *> pure RArrow
- , P.try $ P.string "=>" *> P.notFollowedBy symbolChar *> pure RFatArrow
- , P.try $ P.string "⇒" *> P.notFollowedBy symbolChar *> pure RFatArrow
- , P.try $ P.string "::" *> P.notFollowedBy symbolChar *> pure DoubleColon
- , P.try $ P.string "∷" *> P.notFollowedBy symbolChar *> pure DoubleColon
- , P.try $ P.char '(' *> pure LParen
- , P.try $ P.char ')' *> pure RParen
- , P.try $ P.char '{' *> pure LBrace
- , P.try $ P.char '}' *> pure RBrace
- , P.try $ P.char '[' *> pure LSquare
- , P.try $ P.char ']' *> pure RSquare
- , P.try $ P.char '`' *> pure Tick
- , P.try $ P.char ',' *> pure Comma
- , P.try $ P.char '=' *> P.notFollowedBy symbolChar *> pure Equals
- , P.try $ P.char ':' *> P.notFollowedBy symbolChar *> pure Colon
- , P.try $ P.char '|' *> P.notFollowedBy symbolChar *> pure Pipe
- , P.try $ P.char '.' *> P.notFollowedBy symbolChar *> pure Dot
- , P.try $ P.char ';' *> P.notFollowedBy symbolChar *> pure Semi
- , P.try $ P.char '@' *> P.notFollowedBy symbolChar *> pure At
- , P.try $ P.char '_' *> P.notFollowedBy identLetter *> pure Underscore
- , HoleLit <$> P.try (P.char '?' *> (T.pack <$> P.many1 identLetter))
- , LName <$> parseLName
- , parseUName >>= \uName ->
- guard (validModuleName uName) *> (Qualifier uName <$ P.char '.')
- <|> pure (UName uName)
- , Symbol <$> parseSymbol
- , CharLiteral <$> parseCharLiteral
- , StringLiteral <$> parseStringLiteral
- , Number <$> parseNumber
- ]
-
- where
- parseLName :: Lexer u Text
- parseLName = T.cons <$> identStart <*> (T.pack <$> P.many identLetter)
-
- parseUName :: Lexer u Text
- parseUName = T.cons <$> P.upper <*> (T.pack <$> P.many identLetter)
-
- parseSymbol :: Lexer u Text
- parseSymbol = T.pack <$> P.many1 symbolChar
-
- identStart :: Lexer u Char
- identStart = P.lower <|> P.oneOf "_"
-
- identLetter :: Lexer u Char
- identLetter = P.alphaNum <|> P.oneOf "_'"
-
- symbolChar :: Lexer u Char
- symbolChar = P.satisfy isSymbolChar
-
- parseCharLiteral :: Lexer u Char
- parseCharLiteral = P.try $ do {
- c <- PT.charLiteral tokenParser;
- if fromEnum c > 0xFFFF
- then P.unexpected "astral code point in character literal; characters must be valid UTF-16 code units"
- else return c
- }
-
- parseStringLiteral :: Lexer u PSString
- parseStringLiteral = fromString <$> (blockString <|> PT.stringLiteral tokenParser)
- where
- delimiter = P.try (P.string "\"\"\"")
- blockString = delimiter *> P.manyTill P.anyChar delimiter
-
- parseNumber :: Lexer u (Either Integer Double)
- parseNumber = (consumeLeadingZero *> P.parserZero) <|>
- (Right <$> P.try (PT.float tokenParser) <|>
- Left <$> P.try (PT.natural tokenParser))
- P.> "number"
- where
- -- lookAhead doesn't consume any input if its parser succeeds
- -- if notFollowedBy fails though, the consumed '0' will break the choice chain
- consumeLeadingZero = P.lookAhead (P.char '0' *>
- (P.notFollowedBy P.digit P.> "no leading zero in number literal"))
-
--- |
--- We use Text.Parsec.Token to implement the string and number lexemes
---
-langDef :: PT.GenLanguageDef Text u Identity
-langDef = PT.LanguageDef
- { PT.reservedNames = []
- , PT.reservedOpNames = []
- , PT.commentStart = ""
- , PT.commentEnd = ""
- , PT.commentLine = ""
- , PT.nestedComments = True
- , PT.identStart = P.parserFail "Identifiers not supported"
- , PT.identLetter = P.parserFail "Identifiers not supported"
- , PT.opStart = P.parserFail "Operators not supported"
- , PT.opLetter = P.parserFail "Operators not supported"
- , PT.caseSensitive = True
- }
-
--- |
--- A token parser based on the language definition
---
-tokenParser :: PT.GenTokenParser Text u Identity
-tokenParser = PT.makeTokenParser langDef
-
-type TokenParser a = P.Parsec [PositionedToken] ParseState a
-
-anyToken :: TokenParser PositionedToken
-anyToken = P.token (T.unpack . prettyPrintToken . ptToken) ptSourcePos Just
-
-token :: (Token -> Maybe a) -> TokenParser a
-token f = P.token (T.unpack . prettyPrintToken . ptToken) ptSourcePos (f . ptToken)
-
-match :: Token -> TokenParser ()
-match tok = token (\tok' -> if tok == tok' then Just () else Nothing) P.> T.unpack (prettyPrintToken tok)
-
-lparen :: TokenParser ()
-lparen = match LParen
-
-rparen :: TokenParser ()
-rparen = match RParen
-
-parens :: TokenParser a -> TokenParser a
-parens = P.between lparen rparen
-
-lbrace :: TokenParser ()
-lbrace = match LBrace
-
-rbrace :: TokenParser ()
-rbrace = match RBrace
-
-braces :: TokenParser a -> TokenParser a
-braces = P.between lbrace rbrace
-
-lsquare :: TokenParser ()
-lsquare = match LSquare
-
-rsquare :: TokenParser ()
-rsquare = match RSquare
-
-squares :: TokenParser a -> TokenParser a
-squares = P.between lsquare rsquare
-
-indent :: TokenParser Int
-indent = token go P.> "indentation"
- where
- go (Indent n) = Just n
- go _ = Nothing
-
-indentAt :: P.Column -> TokenParser ()
-indentAt n = token go P.> "indentation at level " ++ show n
- where
- go (Indent n') | n == n' = Just ()
- go _ = Nothing
-
-larrow :: TokenParser ()
-larrow = match LArrow
-
-rarrow :: TokenParser ()
-rarrow = match RArrow
-
-lfatArrow :: TokenParser ()
-lfatArrow = match LFatArrow
-
-rfatArrow :: TokenParser ()
-rfatArrow = match RFatArrow
-
-colon :: TokenParser ()
-colon = match Colon
-
-doubleColon :: TokenParser ()
-doubleColon = match DoubleColon
-
-equals :: TokenParser ()
-equals = match Equals
-
-pipe :: TokenParser ()
-pipe = match Pipe
-
-tick :: TokenParser ()
-tick = match Tick
-
-dot :: TokenParser ()
-dot = match Dot
-
-comma :: TokenParser ()
-comma = match Comma
-
-semi :: TokenParser ()
-semi = match Semi
-
-at :: TokenParser ()
-at = match At
-
-underscore :: TokenParser ()
-underscore = match Underscore
-
-holeLit :: TokenParser Text
-holeLit = token go P.> "hole literal"
- where
- go (HoleLit n) = Just n
- go _ = Nothing
-
--- |
--- Parse zero or more values separated by semicolons
---
-semiSep :: TokenParser a -> TokenParser [a]
-semiSep = flip P.sepBy semi
-
--- |
--- Parse one or more values separated by semicolons
---
-semiSep1 :: TokenParser a -> TokenParser [a]
-semiSep1 = flip P.sepBy1 semi
-
--- |
--- Parse zero or more values separated by commas
---
-commaSep :: TokenParser a -> TokenParser [a]
-commaSep = flip P.sepBy comma
-
--- |
--- Parse one or more values separated by commas
---
-commaSep1 :: TokenParser a -> TokenParser [a]
-commaSep1 = flip P.sepBy1 comma
-
-lname :: TokenParser Text
-lname = token go P.> "identifier"
- where
- go (LName s) = Just s
- go _ = Nothing
-
-lname' :: Text -> TokenParser ()
-lname' s = token go P.> show s
- where
- go (LName s') | s == s' = Just ()
- go _ = Nothing
-
-qualifier :: TokenParser Text
-qualifier = token go P.> "qualifier"
- where
- go (Qualifier s) = Just s
- go _ = Nothing
-
-reserved :: Text -> TokenParser ()
-reserved s = token go P.> show s
- where
- go (LName s') | s == s' = Just ()
- go (Symbol s') | s == s' = Just ()
- go _ = Nothing
-
-uname :: TokenParser Text
-uname = token go P.> "proper name"
- where
- go (UName s) | validUName s = Just s
- go _ = Nothing
-
-uname' :: Text -> TokenParser ()
-uname' s = token go P.> "proper name"
- where
- go (UName s') | s == s' = Just ()
- go _ = Nothing
-
-tyname :: TokenParser Text
-tyname = token go P.> "type name"
- where
- go (UName s) = Just s
- go _ = Nothing
-
-kiname :: TokenParser Text
-kiname = token go P.> "kind name"
- where
- go (UName s) = Just s
- go _ = Nothing
-
-dconsname :: TokenParser Text
-dconsname = token go P.> "data constructor name"
- where
- go (UName s) = Just s
- go _ = Nothing
-
-mname :: TokenParser Text
-mname = token go P.> "module name"
- where
- go (UName s) | validModuleName s = Just s
- go _ = Nothing
-
-symbol :: TokenParser Text
-symbol = token go P.> "symbol"
- where
- go (Symbol s) = Just s
- go Colon = Just ":"
- go LFatArrow = Just "<="
- go At = Just "@"
- go _ = Nothing
-
-symbol' :: Text -> TokenParser ()
-symbol' s = token go P.> show s
- where
- go (Symbol s') | s == s' = Just ()
- go Colon | s == ":" = Just ()
- go LFatArrow | s == "<=" = Just ()
- go _ = Nothing
-
-charLiteral :: TokenParser Char
-charLiteral = token go P.> "char literal"
- where
- go (CharLiteral c) = Just c
- go _ = Nothing
-
-stringLiteral :: TokenParser PSString
-stringLiteral = token go P.> "string literal"
- where
- go (StringLiteral s) = Just s
- go _ = Nothing
-
-number :: TokenParser (Either Integer Double)
-number = token go P.> "number"
- where
- go (Number n) = Just n
- go _ = Nothing
-
-natural :: TokenParser Integer
-natural = token go P.> "natural"
- where
- go (Number (Left n)) = Just n
- go _ = Nothing
-
-identifier :: TokenParser Text
-identifier = token go P.> "identifier"
- where
- go (LName s) | s `notElem` reservedPsNames = Just s
- go _ = Nothing
-
-validModuleName :: Text -> Bool
-validModuleName s = '_' `notElemT` s
-
-validUName :: Text -> Bool
-validUName s = '\'' `notElemT` s
-
-notElemT :: Char -> Text -> Bool
-notElemT c = not . T.any (== c)
-
--- |
--- A list of purescript reserved identifiers
---
-reservedPsNames :: [Text]
-reservedPsNames = [ "data"
- , "newtype"
- , "type"
- , "foreign"
- , "import"
- , "infixl"
- , "infixr"
- , "infix"
- , "class"
- , "instance"
- , "derive"
- , "module"
- , "case"
- , "of"
- , "if"
- , "then"
- , "else"
- , "do"
- , "ado"
- , "let"
- , "true"
- , "false"
- , "in"
- , "where"
- ]
-
-reservedTypeNames :: [Text]
-reservedTypeNames = [ "forall", "where" ]
-
--- |
--- The characters allowed for use in operators
---
-isSymbolChar :: Char -> Bool
-isSymbolChar c = (c `elem` (":!#$%&*+./<=>?@\\^|-~" :: [Char])) || (not (isAscii c) && isSymbol c)
-
-
--- |
--- The characters allowed in the head of an unquoted record key
---
-isUnquotedKeyHeadChar :: Char -> Bool
-isUnquotedKeyHeadChar c = (c == '_') || (isAlpha c && isLower c)
-
--- |
--- The characters allowed in the tail of an unquoted record key
---
-isUnquotedKeyTailChar :: Char -> Bool
-isUnquotedKeyTailChar c = (c `elem` ("_'" :: [Char])) || isAlphaNum c
-
--- |
--- Strings allowed to be left unquoted in a record key
---
-isUnquotedKey :: Text -> Bool
-isUnquotedKey t =
- case T.uncons t of
- Nothing -> False
- Just (hd, tl) -> isUnquotedKeyHeadChar hd &&
- T.all isUnquotedKeyTailChar tl
diff --git a/src/Language/PureScript/Parser/State.hs b/src/Language/PureScript/Parser/State.hs
deleted file mode 100644
index e72903f16d..0000000000
--- a/src/Language/PureScript/Parser/State.hs
+++ /dev/null
@@ -1,18 +0,0 @@
--- |
--- State for the parser monad
---
-module Language.PureScript.Parser.State where
-
-import Prelude.Compat
-
-import qualified Text.Parsec as P
-
--- |
--- State for the parser monad
---
-data ParseState = ParseState {
- -- |
- -- The most recently marked indentation level
- --
- indentationLevel :: P.Column
- } deriving Show
diff --git a/src/Language/PureScript/Parser/Types.hs b/src/Language/PureScript/Parser/Types.hs
deleted file mode 100644
index a83ecdc9c6..0000000000
--- a/src/Language/PureScript/Parser/Types.hs
+++ /dev/null
@@ -1,189 +0,0 @@
-module Language.PureScript.Parser.Types
- ( kindedIdent
- , parseType
- , parsePolyType
- , noForAll
- , noWildcards
- , parseTypeAtom
- ) where
-
-import Prelude.Compat
-
-import Control.Monad (when, unless)
-import Control.Applicative ((<|>))
-import Data.Functor (($>))
-import qualified Data.Text as T
-
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Environment
-import Language.PureScript.Kinds
-import Language.PureScript.Parser.Common
-import Language.PureScript.Parser.Kinds
-import Language.PureScript.Parser.Lexer
-import Language.PureScript.Types
-import Language.PureScript.Label (Label(..))
-
-import qualified Text.Parsec as P
-import qualified Text.Parsec.Expr as P
-
-parseFunction :: TokenParser SourceType
-parseFunction = parens rarrow *> return tyFunction
-
-parseObject :: TokenParser SourceType
-parseObject = withSourceAnnF $ braces $ do
- rows <- parseRow
- return $ \ann -> TypeApp ann tyRecord rows
-
-parseTypeLevelString :: TokenParser SourceType
-parseTypeLevelString = withSourceAnnF $ flip TypeLevelString <$> stringLiteral
-
-parseTypeWildcard :: TokenParser SourceType
-parseTypeWildcard = withSourceAnnF $ do
- name <- Just <$> holeLit
- <|> Nothing <$ underscore
- return $ flip TypeWildcard name
-
-parseTypeVariable :: TokenParser SourceType
-parseTypeVariable = withSourceAnnF $ do
- ident <- identifier
- when (ident `elem` reservedTypeNames) $ P.unexpected (T.unpack ident)
- return $ \ann -> TypeVar ann ident
-
-parseTypeConstructor :: TokenParser SourceType
-parseTypeConstructor = withSourceAnnF $ flip TypeConstructor <$> parseQualified typeName
-
-kindedIdent :: TokenParser (T.Text, Maybe SourceKind)
-kindedIdent = (, Nothing) <$> identifier
- <|> parens ((,) <$> identifier <*> (Just <$> (indented *> doubleColon *> indented *> parseKind)))
-
-parseForAll :: TokenParser SourceType
-parseForAll =
- mkForAll
- <$> ((reserved "forall" <|> reserved "∀")
- *> (P.many1 $ indented *> (withSourceAnnF $ flip (,) <$> kindedIdent))
- <* indented <* dot)
- <*> parseType
-
--- |
--- Parse an atomic type with no `forall`
---
-noForAll :: TokenParser SourceType -> TokenParser SourceType
-noForAll p = do
- ty <- p
- when (containsForAll ty) $ P.unexpected "forall"
- return ty
-
--- |
--- Parse a type as it appears in e.g. a data constructor
---
-parseTypeAtom :: TokenParser SourceType
-parseTypeAtom = indented *> P.choice
- [ P.try parseFunction
- , parseTypeLevelString
- , parseObject
- , parseTypeWildcard
- , parseForAll
- , parseTypeVariable
- , parseTypeConstructor
- -- This try is needed due to some unfortunate ambiguities between rows and kinded types
- , P.try (parens parseRow)
- , parseParensInType
- ]
-
-parseParensInType :: TokenParser SourceType
-parseParensInType = withSourceAnnF $ flip ParensInType <$> parens parsePolyType
-
-parseConstrainedType :: TokenParser (SourceAnn, [SourceConstraint], SourceType)
-parseConstrainedType = withSourceAnnF $ do
- constraints <- parens (commaSep1 parseConstraint) <|> pure <$> parseConstraint
- _ <- rfatArrow
- indented
- ty <- parseType
- return (, constraints, ty)
- where
- parseConstraint = withSourceAnnF $ do
- className <- parseQualified properName
- indented
- ty <- P.many parseTypeAtom
- return $ \ann -> Constraint ann className ty Nothing
-
--- This is here to improve the error message when the user
--- tries to use the old style constraint contexts.
--- TODO: Remove this before 1.0
-typeOrConstrainedType :: TokenParser SourceType
-typeOrConstrainedType = do
- e <- P.try (Left <$> parseConstrainedType) <|> Right <$> parseTypeAtom
- case e of
- Left (ann, [c], ty) -> pure (ConstrainedType ann c ty)
- Left _ ->
- P.unexpected $
- unlines [ "comma in constraints."
- , ""
- , "Class constraints in type annotations can no longer be grouped in parentheses."
- , "Each constraint should now be separated by `=>`, for example:"
- , " `(Applicative f, Semigroup a) => a -> f a -> f a`"
- , " would now be written as:"
- , " `Applicative f => Semigroup a => a -> f a -> f a`."
- ]
- Right ty -> pure ty
-
-parseAnyType :: TokenParser SourceType
-parseAnyType = P.buildExpressionParser operators (buildPostfixParser postfixTable typeOrConstrainedType) P.> "type"
- where
- operators = [ [ P.Infix (return mkTypeApp) P.AssocLeft ]
- , [ P.Infix parseTypeOp P.AssocRight
- ]
- , [ P.Infix (rarrow $> function) P.AssocRight ]
- ]
- postfixTable = [ parseKindedType
- ]
-
- mkTypeApp lhs rhs =
- TypeApp (widenSourceAnn (getAnnForType lhs) (getAnnForType rhs)) lhs rhs
-
- parseTypeOp = withSourceAnnF $ do
- ident <- P.try (parseQualified parseOperator)
- return $ \ann lhs rhs ->
- BinaryNoParensType (widenSourceAnn (getAnnForType lhs) (getAnnForType rhs)) (TypeOp ann ident) lhs rhs
-
- parseKindedType ty = do
- kind <- indented *> doubleColon *> parseKind
- return $ KindedType (widenSourceAnn (getAnnForType ty) (getAnnForKind kind)) ty kind
-
-
--- |
--- Parse a monotype
---
-parseType :: TokenParser SourceType
-parseType = do
- ty <- parseAnyType
- unless (isMonoType ty) $ P.unexpected "polymorphic type"
- return ty
-
--- |
--- Parse a polytype
---
-parsePolyType :: TokenParser SourceType
-parsePolyType = parseAnyType
-
--- |
--- Parse an atomic type with no wildcards
---
-noWildcards :: TokenParser SourceType -> TokenParser SourceType
-noWildcards p = do
- ty <- p
- when (containsWildcards ty) $ P.unexpected "type wildcard"
- return ty
-
-parseRowListItem :: TokenParser SourceType -> TokenParser (RowListItem SourceAnn)
-parseRowListItem p = withSourceAnnF $
- (\name ty ann -> RowListItem ann name ty)
- <$> (indented *> (Label <$> parseLabel) <* indented <* doubleColon) <*> p
-
-parseRowEnding :: TokenParser SourceType
-parseRowEnding =
- (indented *> pipe *> indented *> parseType)
- <|> withSourceAnnF (return REmpty)
-
-parseRow :: TokenParser SourceType
-parseRow = (curry rowFromList <$> commaSep (parseRowListItem parsePolyType) <*> parseRowEnding) P.> "row"
diff --git a/src/Language/PureScript/Pretty.hs b/src/Language/PureScript/Pretty.hs
index b993595121..87c42cf754 100644
--- a/src/Language/PureScript/Pretty.hs
+++ b/src/Language/PureScript/Pretty.hs
@@ -7,7 +7,6 @@
-- * [@Language.PureScript.Pretty.Types@] Pretty printer for types
module Language.PureScript.Pretty (module P) where
-import Language.PureScript.Pretty.Kinds as P
import Language.PureScript.Pretty.Types as P
import Language.PureScript.Pretty.Values as P
import Language.PureScript.PSString as P (prettyPrintString)
diff --git a/src/Language/PureScript/Pretty/Common.hs b/src/Language/PureScript/Pretty/Common.hs
index d284597a3c..a62e776cad 100644
--- a/src/Language/PureScript/Pretty/Common.hs
+++ b/src/Language/PureScript/Pretty/Common.hs
@@ -1,29 +1,21 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-
-- |
-- Common pretty-printing utility functions
--
module Language.PureScript.Pretty.Common where
-import Prelude.Compat
+import Prelude
import Control.Monad.State (StateT, modify, get)
import Data.List (elemIndices, intersperse)
import Data.Text (Text)
-import qualified Data.Text as T
-
-import Language.PureScript.AST (SourcePos(..), SourceSpan(..))
-import Language.PureScript.Parser.Lexer (isUnquotedKey)
+import Data.Text qualified as T
-import Text.PrettyPrint.Boxes hiding ((<>))
-import qualified Text.PrettyPrint.Boxes as Box
+import Language.PureScript.AST (SourcePos(..), SourceSpan(..), nullSourceSpan)
+import Language.PureScript.CST.Lexer (isUnquotedKey)
--- |
--- Wrap a string in parentheses
---
-parens :: String -> String
-parens s = "(" <> s <> ")"
+import Text.PrettyPrint.Boxes (Box(..), emptyBox, text, top, vcat, (//))
+import Text.PrettyPrint.Boxes qualified as Box
parensT :: Text -> Text
parensT s = "(" <> s <> ")"
@@ -69,9 +61,7 @@ instance Monoid StrPos where
plus (a, c) (StrPos (a', _, c')) = (a `addPos` a', (bumpPos a <$> c') : c)
instance Emit StrPos where
- -- |
-- Augment a string with its length (rows/column)
- --
emit str =
-- TODO(Christoph): get rid of T.unpack
let newlines = elemIndices '\n' (T.unpack str)
@@ -79,10 +69,8 @@ instance Emit StrPos where
in
StrPos (SourcePos { sourcePosLine = length newlines, sourcePosColumn = T.length str - index }, str, [])
- -- |
-- Add a new mapping entry for given source position with initially zero generated position
- --
- addMapping SourceSpan { spanName = file, spanStart = startPos } = StrPos (zeroPos, mempty, [mapping])
+ addMapping ss@SourceSpan { spanName = file, spanStart = startPos } = StrPos (zeroPos, mempty, [ mapping | ss /= nullSourceSpan ])
where
mapping = SMap (T.pack file) startPos zeroPos
zeroPos = SourcePos 0 0
@@ -104,17 +92,14 @@ bumpPos :: SourcePos -> SMap -> SMap
bumpPos p (SMap f s g) = SMap f s $ p `addPos` g
addPos :: SourcePos -> SourcePos -> SourcePos
-addPos (SourcePos n m) (SourcePos 0 m') = SourcePos n (m+m')
-addPos (SourcePos n _) (SourcePos n' m') = SourcePos (n+n') m'
+addPos (SourcePos n m) (SourcePos 0 m') = SourcePos n (m + m')
+addPos (SourcePos n _) (SourcePos n' m') = SourcePos (n + n') m'
data PrinterState = PrinterState { indent :: Int }
-emptyPrinterState :: PrinterState
-emptyPrinterState = PrinterState { indent = 0 }
-
-- |
--- Number of characters per identation level
+-- Number of characters per indentation level
--
blockIndent :: Int
blockIndent = 4
@@ -137,15 +122,6 @@ currentIndent = do
current <- get
return $ emit $ T.replicate (indent current) " "
--- |
--- Print many lines
---
-prettyPrintMany :: (Emit gen) => (a -> StateT PrinterState Maybe gen) -> [a] -> StateT PrinterState Maybe gen
-prettyPrintMany f xs = do
- ss <- mapM f xs
- indentString <- currentIndent
- return $ intercalate (emit "\n") $ map (mappend indentString) ss
-
objectKeyRequiresQuoting :: Text -> Bool
objectKeyRequiresQuoting = not . isUnquotedKey
diff --git a/src/Language/PureScript/Pretty/Kinds.hs b/src/Language/PureScript/Pretty/Kinds.hs
deleted file mode 100644
index 275f5e33c9..0000000000
--- a/src/Language/PureScript/Pretty/Kinds.hs
+++ /dev/null
@@ -1,57 +0,0 @@
--- |
--- Pretty printer for kinds
---
-module Language.PureScript.Pretty.Kinds
- ( prettyPrintKind
- ) where
-
-import Prelude.Compat
-
-import Control.Arrow (ArrowPlus(..))
-import Control.PatternArrows as PA
-
-import Data.Maybe (fromMaybe)
-import qualified Data.Text as T
-import Data.Text (Text)
-
-import Language.PureScript.Crash
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.Pretty.Common
-
-typeLiterals :: Pattern () (Kind a) Text
-typeLiterals = mkPattern match
- where
- match (KUnknown _ u) =
- Just $ T.cons 'k' (T.pack (show u))
- match (NamedKind _ name) =
- Just $ if isQualifiedWith (moduleNameFromString "Prim") name
- then runProperName (disqualify name)
- else showQualified runProperName name
- match _ = Nothing
-
-matchRow :: Pattern () (Kind a) ((), Kind a)
-matchRow = mkPattern match
- where
- match (Row _ k) = Just ((), k)
- match _ = Nothing
-
-funKind :: Pattern () (Kind a) (Kind a, Kind a)
-funKind = mkPattern match
- where
- match (FunKind _ arg ret) = Just (arg, ret)
- match _ = Nothing
-
--- | Generate a pretty-printed string representing a Kind
-prettyPrintKind :: Kind a -> Text
-prettyPrintKind
- = fromMaybe (internalError "Incomplete pattern")
- . PA.pattern matchKind ()
- where
- matchKind :: Pattern () (Kind a) Text
- matchKind = buildPrettyPrinter operators (typeLiterals <+> fmap parensT matchKind)
-
- operators :: OperatorTable () (Kind a) Text
- operators =
- OperatorTable [ [ Wrap matchRow $ \_ k -> "# " <> k]
- , [ AssocR funKind $ \arg ret -> arg <> " -> " <> ret ] ]
diff --git a/src/Language/PureScript/Pretty/Types.hs b/src/Language/PureScript/Pretty/Types.hs
index aabd707b12..9b3be46937 100644
--- a/src/Language/PureScript/Pretty/Types.hs
+++ b/src/Language/PureScript/Pretty/Types.hs
@@ -6,7 +6,7 @@ module Language.PureScript.Pretty.Types
, PrettyPrintConstraint
, convertPrettyPrintType
, typeAsBox
- , suggestedTypeAsBox
+ , typeDiffAsBox
, prettyPrintType
, prettyPrintTypeWithUnicode
, prettyPrintSuggestedType
@@ -16,80 +16,83 @@ module Language.PureScript.Pretty.Types
, prettyPrintObjectKey
) where
-import Prelude.Compat hiding ((<>))
+import Prelude hiding ((<>))
import Control.Arrow ((<+>))
+import Control.Lens (_2, (%~))
import Control.PatternArrows as PA
-import Data.Functor (($>))
-import Data.Maybe (fromMaybe)
+import Data.Maybe (fromMaybe, catMaybes)
import Data.Text (Text)
-import qualified Data.Text as T
-
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.Pretty.Common
-import Language.PureScript.Pretty.Kinds
-import Language.PureScript.Types
+import Data.Text qualified as T
+
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (tyFunction, tyRecord)
+import Language.PureScript.Names (OpName(..), OpNameType(..), ProperName(..), ProperNameType(..), Qualified, coerceProperName, disqualify, showQualified)
+import Language.PureScript.Pretty.Common (before, objectKeyRequiresQuoting)
+import Language.PureScript.Types (Constraint(..), pattern REmptyKinded, RowListItem(..), Type(..), TypeVarVisibility(..), WildcardData(..), eqType, rowToSortedList, typeVarVisibilityPrefix)
import Language.PureScript.PSString (PSString, prettyPrintString, decodeString)
import Language.PureScript.Label (Label(..))
-import Text.PrettyPrint.Boxes hiding ((<+>))
+import Text.PrettyPrint.Boxes (Box(..), hcat, hsep, left, moveRight, nullBox, render, text, top, vcat, (<>))
data PrettyPrintType
= PPTUnknown Int
- | PPTypeVar Text
+ | PPTypeVar Text (Maybe Text)
| PPTypeLevelString PSString
+ | PPTypeLevelInt Integer
| PPTypeWildcard (Maybe Text)
| PPTypeConstructor (Qualified (ProperName 'TypeName))
| PPTypeOp (Qualified (OpName 'TypeOpName))
| PPSkolem Text Int
| PPTypeApp PrettyPrintType PrettyPrintType
+ | PPKindArg PrettyPrintType
| PPConstrainedType PrettyPrintConstraint PrettyPrintType
- | PPKindedType PrettyPrintType (Kind ())
+ | PPKindedType PrettyPrintType PrettyPrintType
| PPBinaryNoParensType PrettyPrintType PrettyPrintType PrettyPrintType
| PPParensInType PrettyPrintType
- | PPForAll [(Text, Maybe (Kind ()))] PrettyPrintType
+ | PPForAll [(TypeVarVisibility, Text, Maybe PrettyPrintType)] PrettyPrintType
| PPFunction PrettyPrintType PrettyPrintType
| PPRecord [(Label, PrettyPrintType)] (Maybe PrettyPrintType)
| PPRow [(Label, PrettyPrintType)] (Maybe PrettyPrintType)
| PPTruncated
-type PrettyPrintConstraint = (Qualified (ProperName 'ClassName), [PrettyPrintType])
+type PrettyPrintConstraint = (Qualified (ProperName 'ClassName), [PrettyPrintType], [PrettyPrintType])
convertPrettyPrintType :: Int -> Type a -> PrettyPrintType
convertPrettyPrintType = go
where
go _ (TUnknown _ n) = PPTUnknown n
- go _ (TypeVar _ t) = PPTypeVar t
+ go _ (TypeVar _ t) = PPTypeVar t Nothing
go _ (TypeLevelString _ s) = PPTypeLevelString s
- go _ (TypeWildcard _ n) = PPTypeWildcard n
+ go _ (TypeLevelInt _ n) = PPTypeLevelInt n
+ go _ (TypeWildcard _ (HoleWildcard n)) = PPTypeWildcard (Just n)
+ go _ (TypeWildcard _ _) = PPTypeWildcard Nothing
go _ (TypeConstructor _ c) = PPTypeConstructor c
go _ (TypeOp _ o) = PPTypeOp o
- go _ (Skolem _ t n _) = PPSkolem t n
+ go _ (Skolem _ t _ n _) = PPSkolem t n
go _ (REmpty _) = PPRow [] Nothing
-- Guard the remaining "complex" type atoms on the current depth value. The
-- prior constructors can all be printed simply so it's not really helpful to
-- truncate them.
go d _ | d < 0 = PPTruncated
- go d (ConstrainedType _ (Constraint _ cls args _) ty) = PPConstrainedType (cls, go (d-1) <$> args) (go d ty)
- go d (KindedType _ ty k) = PPKindedType (go (d-1) ty) (k $> ())
+ go d (ConstrainedType _ (Constraint _ cls kargs args _) ty) = PPConstrainedType (cls, go (d-1) <$> kargs, go (d-1) <$> args) (go d ty)
+ go d (KindedType _ ty k) = PPKindedType (go (d-1) ty) (go (d-1) k)
go d (BinaryNoParensType _ ty1 ty2 ty3) = PPBinaryNoParensType (go (d-1) ty1) (go (d-1) ty2) (go (d-1) ty3)
go d (ParensInType _ ty) = PPParensInType (go (d-1) ty)
go d ty@RCons{} = uncurry PPRow (goRow d ty)
- go d (ForAll _ v mbK ty _) = goForAll d [(v, fmap ($> ()) mbK)] ty
+ go d (ForAll _ vis v mbK ty _) = goForAll d [(vis, v, fmap (go (d-1)) mbK)] ty
go d (TypeApp _ a b) = goTypeApp d a b
+ go d (KindApp _ a b) = PPTypeApp (go (d-1) a) (PPKindArg (go (d-1) b))
- goForAll d vs (ForAll _ v mbK ty _) = goForAll d ((v, fmap ($> ()) mbK) : vs) ty
- goForAll d vs ty = PPForAll vs (go (d-1) ty)
+ goForAll d vs (ForAll _ vis v mbK ty _) = goForAll d ((vis, v, fmap (go (d-1)) mbK) : vs) ty
+ goForAll d vs ty = PPForAll (reverse vs) (go (d-1) ty)
goRow d ty =
let (items, tail_) = rowToSortedList ty
in ( map (\item -> (rowListLabel item, go (d-1) (rowListType item))) items
, case tail_ of
- REmpty _ -> Nothing
+ REmptyKinded _ _ -> Nothing
_ -> Just (go (d-1) tail_)
)
@@ -109,7 +112,7 @@ constraintsAsBox tro con ty =
doubleRightArrow = if troUnicode tro then "⇒" else "=>"
constraintAsBox :: PrettyPrintConstraint -> Box
-constraintAsBox (pn, tys) = typeAsBox' (foldl PPTypeApp (PPTypeConstructor (fmap coerceProperName pn)) tys)
+constraintAsBox (pn, ks, tys) = typeAsBox' (foldl PPTypeApp (foldl (\a b -> PPTypeApp a (PPKindArg b)) (PPTypeConstructor (fmap coerceProperName pn)) ks) tys)
-- |
-- Generate a pretty-printed string representing a Row
@@ -118,13 +121,13 @@ prettyPrintRowWith :: TypeRenderOptions -> Char -> Char -> [(Label, PrettyPrintT
prettyPrintRowWith tro open close labels rest =
case (labels, rest) of
([], Nothing) ->
- text [open, close]
+ if troRowAsDiff tro then text [ open, ' ' ] <> text "..." <> text [ ' ', close ] else text [ open, close ]
([], Just _) ->
text [ open, ' ' ] <> tailToPs rest <> text [ ' ', close ]
_ ->
vcat left $
zipWith (\(nm, ty) i -> nameAndTypeToPs (if i == 0 then open else ',') nm ty) labels [0 :: Int ..] ++
- [ tailToPs rest, text [close] ]
+ catMaybes [ rowDiff, pure $ tailToPs rest, pure $ text [close] ]
where
nameAndTypeToPs :: Char -> Label -> PrettyPrintType -> Box
@@ -132,6 +135,8 @@ prettyPrintRowWith tro open close labels rest =
doubleColon = if troUnicode tro then "∷" else "::"
+ rowDiff = if troRowAsDiff tro then Just (text "...") else Nothing
+
tailToPs :: Maybe PrettyPrintType -> Box
tailToPs Nothing = nullBox
tailToPs (Just other) = text "| " <> typeAsBox' other
@@ -142,16 +147,22 @@ typeApp = mkPattern match
match (PPTypeApp f x) = Just (f, x)
match _ = Nothing
+kindArg :: Pattern () PrettyPrintType ((), PrettyPrintType)
+kindArg = mkPattern match
+ where
+ match (PPKindArg ty) = Just ((), ty)
+ match _ = Nothing
+
appliedFunction :: Pattern () PrettyPrintType (PrettyPrintType, PrettyPrintType)
appliedFunction = mkPattern match
where
match (PPFunction arg ret) = Just (arg, ret)
match _ = Nothing
-kinded :: Pattern () PrettyPrintType (Kind (), PrettyPrintType)
+kinded :: Pattern () PrettyPrintType (PrettyPrintType, PrettyPrintType)
kinded = mkPattern match
where
- match (PPKindedType t k) = Just (k, t)
+ match (PPKindedType t k) = Just (t, k)
match _ = Nothing
constrained :: Pattern () PrettyPrintType (PrettyPrintConstraint, PrettyPrintType)
@@ -168,13 +179,14 @@ explicitParens = mkPattern match
matchTypeAtom :: TypeRenderOptions -> Pattern () PrettyPrintType Box
matchTypeAtom tro@TypeRenderOptions{troSuggesting = suggesting} =
- typeLiterals <+> fmap ((`before` (text ")")) . (text "(" <>)) (matchType tro)
+ typeLiterals <+> fmap ((`before` text ")") . (text "(" <>)) (matchType tro)
where
typeLiterals :: Pattern () PrettyPrintType Box
typeLiterals = mkPattern match where
- match (PPTypeWildcard name) = Just $ maybe (text "_") (text . ('?' :) . T.unpack) name
- match (PPTypeVar var) = Just $ text $ T.unpack var
+ match (PPTypeWildcard name) = Just $ text $ maybe "_" (('?' :) . T.unpack) name
+ match (PPTypeVar var _) = Just $ text $ T.unpack var
match (PPTypeLevelString s) = Just $ text $ T.unpack $ prettyPrintString s
+ match (PPTypeLevelInt n) = Just $ text $ show n
match (PPTypeConstructor ctor) = Just $ text $ T.unpack $ runProperName $ disqualify ctor
match (PPTUnknown u)
| suggesting = Just $ text "_"
@@ -194,18 +206,21 @@ matchType :: TypeRenderOptions -> Pattern () PrettyPrintType Box
matchType tro = buildPrettyPrinter operators (matchTypeAtom tro) where
operators :: OperatorTable () PrettyPrintType Box
operators =
- OperatorTable [ [ AssocL typeApp $ \f x -> keepSingleLinesOr (moveRight 2) f x ]
+ OperatorTable [ [ Wrap kindArg $ \_ ty -> text "@" <> ty ]
+ , [ AssocL typeApp $ \f x -> keepSingleLinesOr (moveRight 2) f x ]
, [ AssocR appliedFunction $ \arg ret -> keepSingleLinesOr id arg (text rightArrow <> " " <> ret) ]
, [ Wrap constrained $ \deps ty -> constraintsAsBox tro deps ty ]
- , [ Wrap forall_ $ \idents ty -> keepSingleLinesOr (moveRight 2) (text (forall' ++ " " ++ unwords (fmap printMbKindedType idents) ++ ".")) ty ]
- , [ Wrap kinded $ \k ty -> keepSingleLinesOr (moveRight 2) ty (text (doubleColon ++ " " ++ T.unpack (prettyPrintKind k))) ]
+ , [ Wrap forall_ $ \idents ty -> keepSingleLinesOr (moveRight 2) (hsep 1 top (text forall' : fmap printMbKindedType idents) <> text ".") ty ]
+ , [ Wrap kinded $ \ty k -> keepSingleLinesOr (moveRight 2) (typeAsBox' ty) (text (doubleColon ++ " ") <> k) ]
, [ Wrap explicitParens $ \_ ty -> ty ]
]
rightArrow = if troUnicode tro then "→" else "->"
forall' = if troUnicode tro then "∀" else "forall"
doubleColon = if troUnicode tro then "∷" else "::"
- printMbKindedType (v, mbK) = maybe v (\k -> unwords ["(" ++ v, doubleColon, T.unpack (prettyPrintKind k) ++ ")"]) mbK
+
+ printMbKindedType (vis, v, Nothing) = text (T.unpack $ typeVarVisibilityPrefix vis) <> text v
+ printMbKindedType (vis, v, Just k) = text ("(" ++ T.unpack (typeVarVisibilityPrefix vis) ++ v ++ " " ++ doubleColon ++ " ") <> typeAsBox' k <> text ")"
-- If both boxes span a single line, keep them on the same line, or else
-- use the specified function to modify the second box, then combine vertically.
@@ -214,16 +229,16 @@ matchType tro = buildPrettyPrinter operators (matchTypeAtom tro) where
| rows b1 > 1 || rows b2 > 1 = vcat left [ b1, f b2 ]
| otherwise = hcat top [ b1, text " ", b2]
-forall_ :: Pattern () PrettyPrintType ([(String, Maybe (Kind ()))], PrettyPrintType)
+forall_ :: Pattern () PrettyPrintType ([(TypeVarVisibility, String, Maybe PrettyPrintType)], PrettyPrintType)
forall_ = mkPattern match
where
- match (PPForAll idents ty) = Just (map (\(v, mbK) -> (T.unpack v, mbK)) idents, ty)
+ match (PPForAll idents ty) = Just ((_2 %~ T.unpack) <$> idents, ty)
match _ = Nothing
typeAtomAsBox' :: PrettyPrintType -> Box
typeAtomAsBox'
= fromMaybe (internalError "Incomplete pattern")
- . PA.pattern (matchTypeAtom defaultOptions) ()
+ . PA.pattern_ (matchTypeAtom defaultOptions) ()
typeAtomAsBox :: Int -> Type a -> Box
typeAtomAsBox maxDepth = typeAtomAsBox' . convertPrettyPrintType maxDepth
@@ -238,27 +253,34 @@ typeAsBox' = typeAsBoxImpl defaultOptions
typeAsBox :: Int -> Type a -> Box
typeAsBox maxDepth = typeAsBox' . convertPrettyPrintType maxDepth
-suggestedTypeAsBox :: PrettyPrintType -> Box
-suggestedTypeAsBox = typeAsBoxImpl suggestingOptions
+typeDiffAsBox' :: PrettyPrintType -> Box
+typeDiffAsBox' = typeAsBoxImpl diffOptions
+
+typeDiffAsBox :: Int -> Type a -> Box
+typeDiffAsBox maxDepth = typeDiffAsBox' . convertPrettyPrintType maxDepth
data TypeRenderOptions = TypeRenderOptions
{ troSuggesting :: Bool
, troUnicode :: Bool
+ , troRowAsDiff :: Bool
}
suggestingOptions :: TypeRenderOptions
-suggestingOptions = TypeRenderOptions True False
+suggestingOptions = TypeRenderOptions True False False
defaultOptions :: TypeRenderOptions
-defaultOptions = TypeRenderOptions False False
+defaultOptions = TypeRenderOptions False False False
+
+diffOptions :: TypeRenderOptions
+diffOptions = TypeRenderOptions False False True
unicodeOptions :: TypeRenderOptions
-unicodeOptions = TypeRenderOptions False True
+unicodeOptions = TypeRenderOptions False True False
typeAsBoxImpl :: TypeRenderOptions -> PrettyPrintType -> Box
typeAsBoxImpl tro
= fromMaybe (internalError "Incomplete pattern")
- . PA.pattern (matchType tro) ()
+ . PA.pattern_ (matchType tro) ()
-- | Generate a pretty-printed string representing a 'Type'
prettyPrintType :: Int -> Type a -> String
diff --git a/src/Language/PureScript/Pretty/Values.hs b/src/Language/PureScript/Pretty/Values.hs
index fe9592d7b4..4d5a5ec604 100644
--- a/src/Language/PureScript/Pretty/Values.hs
+++ b/src/Language/PureScript/Pretty/Values.hs
@@ -7,25 +7,24 @@ module Language.PureScript.Pretty.Values
, prettyPrintBinderAtom
) where
-import Prelude.Compat hiding ((<>))
+import Prelude hiding ((<>))
import Control.Arrow (second)
-import Data.Maybe (maybe)
import Data.Text (Text)
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Monoid as Monoid ((<>))
-import qualified Data.Text as T
-
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Names
-import Language.PureScript.Pretty.Common
+import Data.List.NonEmpty qualified as NEL
+import Data.Monoid qualified as Monoid ((<>))
+import Data.Text qualified as T
+
+import Language.PureScript.AST (AssocList(..), Binder(..), CaseAlternative(..), Declaration(..), DoNotationElement(..), Expr(..), Guard(..), GuardedExpr(..), Literal(..), PathNode(..), PathTree(..), TypeDeclarationData(..), pattern ValueDecl, WhereProvenance(..))
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Names (OpName(..), ProperName(..), Qualified(..), disqualify, runModuleName, showIdent)
+import Language.PureScript.Pretty.Common (before, beforeWithSpace, parensT)
import Language.PureScript.Pretty.Types (typeAsBox, typeAtomAsBox, prettyPrintObjectKey)
import Language.PureScript.Types (Constraint(..))
import Language.PureScript.PSString (PSString, prettyPrintString)
-import Text.PrettyPrint.Boxes
+import Text.PrettyPrint.Boxes (Box, left, moveRight, text, vcat, vsep, (//), (<>))
-- TODO(Christoph): remove T.unpack s
@@ -67,9 +66,9 @@ prettyPrintValue d (ObjectUpdateNested o ps) = prettyPrintValueAtom (d - 1) o `b
printNode (key, Leaf val) = prettyPrintUpdateEntry d key val
printNode (key, Branch val) = textT (prettyPrintObjectKey key) `beforeWithSpace` prettyPrintUpdate val
prettyPrintValue d (App val arg) = prettyPrintValueAtom (d - 1) val `beforeWithSpace` prettyPrintValueAtom (d - 1) arg
+prettyPrintValue d (VisibleTypeApp val _) = prettyPrintValueAtom (d - 1) val
+prettyPrintValue d (Unused val) = prettyPrintValue d val
prettyPrintValue d (Abs arg val) = text ('\\' : T.unpack (prettyPrintBinder arg) ++ " -> ") // moveRight 2 (prettyPrintValue (d - 1) val)
-prettyPrintValue d (TypeClassDictionaryConstructorApp className ps) =
- text (T.unpack (runProperName (disqualify className)) ++ " ") <> prettyPrintValueAtom (d - 1) ps
prettyPrintValue d (Case values binders) =
(text "case " <> foldr beforeWithSpace (text "of") (map (prettyPrintValueAtom (d - 1)) values)) //
moveRight 2 (vcat left (map (prettyPrintCaseAlternative (d - 1)) binders))
@@ -86,10 +85,10 @@ prettyPrintValue d (Do m els) =
prettyPrintValue d (Ado m els yield) =
textT (maybe "" ((Monoid.<> ".") . runModuleName) m) <> text "ado " <> vcat left (map (prettyPrintDoNotationElement (d - 1)) els) //
(text "in " <> prettyPrintValue (d - 1) yield)
-prettyPrintValue d (TypeClassDictionary (Constraint _ name tys _) _ _) = foldl1 beforeWithSpace $ text ("#dict " ++ T.unpack (runProperName (disqualify name))) : map (typeAtomAsBox d) tys
+-- TODO: constraint kind args
+prettyPrintValue d (TypeClassDictionary (Constraint _ name _ tys _) _ _) = foldl1 beforeWithSpace $ text ("#dict " ++ T.unpack (runProperName (disqualify name))) : map (typeAtomAsBox d) tys
prettyPrintValue _ (DeferredDictionary name _) = text $ "#dict " ++ T.unpack (runProperName (disqualify name))
-prettyPrintValue _ (TypeClassDictionaryAccessor className ident) =
- text "#dict-accessor " <> text (T.unpack (runProperName (disqualify className))) <> text "." <> text (T.unpack (showIdent ident)) <> text ">"
+prettyPrintValue _ (DerivedInstancePlaceholder name _) = text $ "#derived " ++ T.unpack (runProperName (disqualify name))
prettyPrintValue d (TypedValue _ val _) = prettyPrintValue d val
prettyPrintValue d (PositionedValue _ _ val) = prettyPrintValue d val
prettyPrintValue d (Literal _ l) = prettyPrintLiteralValue d l
@@ -225,7 +224,7 @@ prettyPrintLiteralBinder (ArrayLiteral bs) =
--
prettyPrintBinder :: Binder -> Text
prettyPrintBinder (ConstructorBinder _ ctor []) = runProperName (disqualify ctor)
-prettyPrintBinder (ConstructorBinder _ ctor args) = (runProperName (disqualify ctor)) Monoid.<> " " Monoid.<> T.unwords (map prettyPrintBinderAtom args)
+prettyPrintBinder (ConstructorBinder _ ctor args) = runProperName (disqualify ctor) Monoid.<> " " Monoid.<> T.unwords (map prettyPrintBinderAtom args)
prettyPrintBinder (PositionedBinder _ _ binder) = prettyPrintBinder binder
prettyPrintBinder (TypedBinder _ binder) = prettyPrintBinder binder
prettyPrintBinder b = prettyPrintBinderAtom b
diff --git a/src/Language/PureScript/Publish.hs b/src/Language/PureScript/Publish.hs
index fc149595c8..ed3dd4aba6 100644
--- a/src/Language/PureScript/Publish.hs
+++ b/src/Language/PureScript/Publish.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-
module Language.PureScript.Publish
( preparePackage
, preparePackage'
@@ -19,44 +17,55 @@ module Language.PureScript.Publish
, getModules
) where
-import Protolude hiding (stdin)
+import Protolude hiding (stdin, lines)
import Control.Arrow ((***))
import Control.Category ((>>>))
import Control.Monad.Writer.Strict (MonadWriter, WriterT, runWriterT, tell)
-import Data.Aeson.BetterErrors (Parse, parse, keyMay, eachInObjectWithKey, eachInObject, key, keyOrDefault, asBool, asString, withString, asText, withText)
-import qualified Data.ByteString.Lazy as BL
-import Data.Char (isSpace)
+import Data.ByteString.Lazy qualified as BL
import Data.String (String, lines)
-import Data.List (stripPrefix, (\\), nubBy)
-import Data.List.NonEmpty (NonEmpty(..))
-import qualified Data.Text as T
+import Data.List (stripPrefix, (\\))
+import Data.Text qualified as T
import Data.Time.Clock (UTCTime)
import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
-import Data.Version
-import qualified Distribution.SPDX as SPDX
-import qualified Distribution.Parsec.Class as CabalParsec
+import Data.Version (Version)
+import Distribution.SPDX qualified as SPDX
+import Distribution.Parsec qualified as CabalParsec
import System.Directory (doesFileExist)
import System.FilePath.Glob (globDir1)
import System.Process (readProcess)
import Web.Bower.PackageMeta (PackageMeta(..), PackageName, Repository(..))
-import qualified Web.Bower.PackageMeta as Bower
+import Web.Bower.PackageMeta qualified as Bower
-import Language.PureScript.Publish.ErrorsWarnings
-import Language.PureScript.Publish.Utils
-import qualified Language.PureScript as P (version, ModuleName)
-import qualified Language.PureScript.Docs as D
+import Language.PureScript.Publish.ErrorsWarnings (InternalError(..), OtherError(..), PackageError(..), PackageWarning(..), RepositoryFieldError(..), UserError(..), printError, printWarnings)
+import Language.PureScript.Publish.Registry.Compat (asPursJson, toBowerPackage)
+import Language.PureScript.Publish.Utils (globRelative, purescriptSourceFiles)
+import Language.PureScript qualified as P (version, ModuleName)
+import Language.PureScript.CoreFn.FromJSON qualified as P
+import Language.PureScript.Docs qualified as D
+import Data.Aeson.BetterErrors (Parse, withString, eachInObjectWithKey, asString, key, keyMay, parse, mapError)
+import Language.PureScript.Docs.Types (ManifestError(BowerManifest, PursManifest))
data PublishOptions = PublishOptions
{ -- | How to obtain the version tag and version that the data being
-- generated will refer to.
publishGetVersion :: PrepareM (Text, Version)
+ -- | How to obtain at what time the version was committed
, publishGetTagTime :: Text -> PrepareM UTCTime
, -- | What to do when the working tree is dirty
publishWorkingTreeDirty :: PrepareM ()
+ , -- | Compiler output directory (which must include up-to-date docs.json
+ -- files for any modules we are producing docs for).
+ publishCompileOutputDir :: FilePath
+ , -- | Path to the manifest file; a JSON file including information about the
+ -- package, such as name, author, dependency version bounds.
+ publishManifestFile :: FilePath
+ , -- | Path to the resolutions file; a JSON file containing all of the
+ -- package's dependencies, their versions, and their paths on the disk.
+ publishResolutionsFile :: FilePath
}
defaultPublishOptions :: PublishOptions
@@ -64,20 +73,23 @@ defaultPublishOptions = PublishOptions
{ publishGetVersion = getVersionFromGitTag
, publishGetTagTime = getTagTime
, publishWorkingTreeDirty = userError DirtyWorkingTree
+ , publishCompileOutputDir = "output"
+ , publishManifestFile = "bower.json"
+ , publishResolutionsFile = "resolutions.json"
}
-- | Attempt to retrieve package metadata from the current directory.
-- Calls exitFailure if no package metadata could be retrieved.
-unsafePreparePackage :: FilePath -> FilePath -> PublishOptions -> IO D.UploadedPackage
-unsafePreparePackage manifestFile resolutionsFile opts =
+unsafePreparePackage :: PublishOptions -> IO D.UploadedPackage
+unsafePreparePackage opts =
either (\e -> printError e >> exitFailure) pure
- =<< preparePackage manifestFile resolutionsFile opts
+ =<< preparePackage opts
-- | Attempt to retrieve package metadata from the current directory.
-- Returns a PackageError on failure
-preparePackage :: FilePath -> FilePath -> PublishOptions -> IO (Either PackageError D.UploadedPackage)
-preparePackage manifestFile resolutionsFile opts =
- runPrepareM (preparePackage' manifestFile resolutionsFile opts)
+preparePackage :: PublishOptions -> IO (Either PackageError D.UploadedPackage)
+preparePackage opts =
+ runPrepareM (preparePackage' opts)
>>= either (pure . Left) (fmap Right . handleWarnings)
where
@@ -117,67 +129,76 @@ otherError = throwError . OtherError
catchLeft :: Applicative f => Either a b -> (a -> f b) -> f b
catchLeft a f = either f pure a
-preparePackage' :: FilePath -> FilePath -> PublishOptions -> PrepareM D.UploadedPackage
-preparePackage' manifestFile resolutionsFile opts = do
- unlessM (liftIO (doesFileExist manifestFile)) (userError PackageManifestNotFound)
+preparePackage' :: PublishOptions -> PrepareM D.UploadedPackage
+preparePackage' opts = do
checkCleanWorkingTree opts
- pkgMeta <- liftIO (Bower.decodeFile manifestFile)
- >>= flip catchLeft (userError . CouldntDecodePackageManifest)
+ let manifestPath = publishManifestFile opts
+ pkgMeta <- liftIO (try (BL.readFile manifestPath)) >>= \case
+ Left (_ :: IOException) ->
+ userError $ PackageManifestNotFound manifestPath
+ Right found -> do
+ -- We can determine the type of the manifest file based on the file path,
+ -- as both the PureScript and Bower registries require their manifest
+ -- files to have specific names.
+ let isPursJson = "purs.json" `T.isInfixOf` T.pack manifestPath
+ if isPursJson then do
+ pursJson <- catchLeft (parse (mapError PursManifest asPursJson) found) (userError . CouldntDecodePackageManifest)
+ catchLeft (toBowerPackage pursJson) (userError . CouldntConvertPackageManifest)
+ else
+ catchLeft (parse (mapError BowerManifest Bower.asPackageMeta) found) (userError . CouldntDecodePackageManifest)
+
checkLicense pkgMeta
(pkgVersionTag, pkgVersion) <- publishGetVersion opts
pkgTagTime <- Just <$> publishGetTagTime opts pkgVersionTag
pkgGithub <- getManifestRepositoryInfo pkgMeta
- resolvedDeps <- parseResolutionsFile resolutionsFile
+ resolvedDeps <- parseResolutionsFile (publishResolutionsFile opts)
- (pkgModules, pkgModuleMap) <- getModules (map (second fst) resolvedDeps)
+ (pkgModules, pkgModuleMap) <- getModules opts (map (second fst) resolvedDeps)
- let declaredDeps = map fst $
- Bower.bowerDependencies pkgMeta
- ++ Bower.bowerDevDependencies pkgMeta
+ let declaredDeps = map fst $ Bower.bowerDependencies pkgMeta
pkgResolvedDependencies <- handleDeps declaredDeps (map (second snd) resolvedDeps)
let pkgUploader = D.NotYetKnown
let pkgCompilerVersion = P.version
-
return D.Package{..}
getModules
- :: [(PackageName, FilePath)]
+ :: PublishOptions
+ -> [(PackageName, FilePath)]
-> PrepareM ([D.Module], Map P.ModuleName PackageName)
-getModules paths = do
+getModules opts paths = do
(inputFiles, depsFiles) <- liftIO (getInputAndDepsFiles paths)
- (modules', moduleMap) <- parseFilesInPackages inputFiles depsFiles
- case runExcept (D.convertModulesInPackage (map snd modules') moduleMap) of
- Right modules -> return (modules, moduleMap)
- Left err -> userError (CompileError err)
+ (modules, moduleMap) <-
+ liftIO (runExceptT (D.collectDocs (publishCompileOutputDir opts) inputFiles depsFiles))
+ >>= either (userError . CompileError) return
- where
- parseFilesInPackages inputFiles depsFiles = do
- r <- liftIO . runExceptT $ D.parseFilesInPackages inputFiles depsFiles
- case r of
- Right r' ->
- return r'
- Left err ->
- userError (CompileError err)
+ pure (map snd modules, moduleMap)
data TreeStatus = Clean | Dirty deriving (Show, Eq, Ord, Enum)
-getGitWorkingTreeStatus :: PrepareM TreeStatus
-getGitWorkingTreeStatus = do
- out <- readProcess' "git" ["status", "--porcelain"] ""
+getGitWorkingTreeStatus :: FilePath -> PrepareM TreeStatus
+getGitWorkingTreeStatus manifestFilePath = do
+ output <- lines <$> readProcess' "git" ["status", "--porcelain"] ""
+ -- The PureScript registry generates purs.json files when publishing legacy
+ -- packages. To ensure these packages can also be published to Pursuit, we
+ -- include an exemption to the working tree status check that will ignore
+ -- untracked purs.json files. Note that _modified_ purs.json files will
+ -- still fail this check.
+ let untrackedPursJson = "?? " <> manifestFilePath
+ let filtered = filter (/= untrackedPursJson) output
return $
- if all null . lines $ out
+ if all null filtered
then Clean
else Dirty
checkCleanWorkingTree :: PublishOptions -> PrepareM ()
checkCleanWorkingTree opts = do
- status <- getGitWorkingTreeStatus
+ status <- getGitWorkingTreeStatus (publishManifestFile opts)
unless (status == Clean) $
publishWorkingTreeDirty opts
@@ -194,7 +215,7 @@ getVersionFromGitTag = do
dropWhile isSpace >>> reverse >>> dropWhile isSpace >>> reverse
parseMay str = do
digits <- stripPrefix "v" str
- (str,) <$> D.parseVersion' digits
+ (str,) <$> P.parseVersion' digits
-- | Given a git tag, get the time it was created.
getTagTime :: Text -> PrepareM UTCTime
@@ -210,7 +231,7 @@ getManifestRepositoryInfo pkgMeta =
Nothing -> do
giturl <- catchError (Just . T.strip . T.pack <$> readProcess' "git" ["config", "remote.origin.url"] "")
(const (return Nothing))
- userError (BadRepositoryField (RepositoryFieldMissing (giturl >>= extractGithub >>= return . format)))
+ userError (BadRepositoryField (RepositoryFieldMissing (giturl >>= extractGithub <&> format)))
Just Repository{..} -> do
unless (repositoryType == "git")
(userError (BadRepositoryField (BadRepositoryType repositoryType)))
@@ -291,12 +312,7 @@ parseResolutionsFile resolutionsFile = do
Right res ->
pure res
Left err ->
- case parse asLegacyResolutions depsBS of
- Right res -> do
- warn $ LegacyResolutionsFormat resolutionsFile
- pure res
- Left _ ->
- userError $ ResolutionsFileError resolutionsFile err
+ userError $ ResolutionsFileError resolutionsFile err
-- | Parser for resolutions files, which contain information about the packages
-- which this package depends on. A resolutions file should look something like
@@ -330,51 +346,10 @@ asResolutions =
asVersion :: Parse D.PackageError Version
asVersion =
- withString (note D.InvalidVersion . D.parseVersion')
-
--- | Extracts all dependencies and their versions from a legacy resolutions
--- file, which is based on the output of `bower list --json --offline`.
-asLegacyResolutions :: Parse D.PackageError [(PackageName, (FilePath, DependencyStatus))]
-asLegacyResolutions =
- nubBy ((==) `on` fst) <$> go True
- where
- go isToplevel =
- keyDependencies isToplevel $
- (++) <$> (takeJusts <$> eachInObjectWithKey parsePackageName asDirectoryAndDependencyStatus)
- <*> (concatMap snd <$> eachInObject (go False))
-
-
- keyDependencies isToplevel =
- if isToplevel
- then key "dependencies"
- else fmap (fromMaybe []) . keyMay "dependencies"
-
- takeJusts :: [(a, Maybe b)] -> [(a,b)]
- takeJusts = mapMaybe $ \(x,y) -> (x,) <$> y
-
- asDirectoryAndDependencyStatus :: Parse D.PackageError (Maybe (FilePath, DependencyStatus))
- asDirectoryAndDependencyStatus = do
- isMissing <- keyOrDefault "missing" False asBool
- if isMissing
- then return Nothing
- else do
- directory <- key "canonicalDir" asString
- status <- key "pkgMeta" $
- keyOrDefault "_resolution" NoResolution $ do
- type_ <- key "type" asText
- case type_ of
- "version" ->
- key "tag" $ fmap ResolvedVersion $ withText $ \tag ->
- let
- tag' = fromMaybe tag (T.stripPrefix "v" tag)
- in
- note D.InvalidVersion (D.parseVersion' (T.unpack tag'))
- other ->
- return (ResolvedOther other)
- return $ Just (directory, status)
+ withString (note D.InvalidVersion . P.parseVersion')
parsePackageName :: Text -> Either D.PackageError PackageName
-parsePackageName = first D.ErrorInPackageMeta . Bower.parsePackageName
+parsePackageName = first D.ErrorInPackageMeta . D.mapLeft BowerManifest . Bower.parsePackageName
handleDeps
:: [PackageName]
diff --git a/src/Language/PureScript/Publish/BoxesHelpers.hs b/src/Language/PureScript/Publish/BoxesHelpers.hs
index 0fe2b0f1a7..36d9a180b9 100644
--- a/src/Language/PureScript/Publish/BoxesHelpers.hs
+++ b/src/Language/PureScript/Publish/BoxesHelpers.hs
@@ -4,13 +4,13 @@ module Language.PureScript.Publish.BoxesHelpers
, module Language.PureScript.Publish.BoxesHelpers
) where
-import Prelude.Compat
+import Prelude
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
import System.IO (hPutStr, stderr)
-import qualified Text.PrettyPrint.Boxes as Boxes
+import Text.PrettyPrint.Boxes qualified as Boxes
width :: Int
width = 79
@@ -44,6 +44,3 @@ bulletedListT f = bulletedList (T.unpack . f)
printToStderr :: Boxes.Box -> IO ()
printToStderr = hPutStr stderr . Boxes.render
-
-printToStdout :: Boxes.Box -> IO ()
-printToStdout = putStr . Boxes.render
diff --git a/src/Language/PureScript/Publish/ErrorsWarnings.hs b/src/Language/PureScript/Publish/ErrorsWarnings.hs
index 84ec99957d..b855f68a41 100644
--- a/src/Language/PureScript/Publish/ErrorsWarnings.hs
+++ b/src/Language/PureScript/Publish/ErrorsWarnings.hs
@@ -7,32 +7,32 @@ module Language.PureScript.Publish.ErrorsWarnings
, RepositoryFieldError(..)
, JSONSource(..)
, printError
- , printErrorToStdout
, renderError
, printWarnings
, renderWarnings
) where
-import Prelude.Compat
+import Prelude
import Control.Exception (IOException)
import Data.Aeson.BetterErrors (ParseError, displayError)
import Data.List (intersperse)
import Data.List.NonEmpty (NonEmpty(..))
-import Data.Maybe
-import Data.Monoid hiding (First, getFirst)
-import Data.Semigroup (First(..))
-import Data.Version
-import qualified Data.List.NonEmpty as NonEmpty
+import Data.Maybe (catMaybes, fromMaybe)
+import Data.Monoid (Any(..))
+import Data.Version (Version, showVersion)
+import Data.List.NonEmpty qualified as NonEmpty
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
-import qualified Language.PureScript.Docs.Types as D
-import qualified Language.PureScript as P
-import Language.PureScript.Publish.BoxesHelpers
+import Language.PureScript.Docs.Types qualified as D
+import Language.PureScript qualified as P
+import Language.PureScript.Publish.BoxesHelpers (Box, bulletedList, bulletedListT, indented, nullBox, para, printToStderr, spacer, successivelyIndented, vcat)
import Web.Bower.PackageMeta (PackageName, runPackageName, showBowerError)
+import Web.Bower.PackageMeta qualified as Bower
+import Language.PureScript.Docs.Types (showManifestError)
-- | An error which meant that it was not possible to retrieve metadata for a
-- package.
@@ -45,14 +45,14 @@ data PackageError
data PackageWarning
= NoResolvedVersion PackageName
| UnacceptableVersion (PackageName, Text)
- | DirtyWorkingTree_Warn
- | LegacyResolutionsFormat FilePath
+ | DirtyWorkingTreeWarn
deriving (Show)
-- | An error that should be fixed by the user.
data UserError
- = PackageManifestNotFound
+ = PackageManifestNotFound FilePath
| ResolutionsFileNotFound
+ | CouldntConvertPackageManifest Bower.BowerError
| CouldntDecodePackageManifest (ParseError D.ManifestError)
| TagMustBeCheckedOut
| AmbiguousVersions [Version] -- Invariant: should contain at least two elements
@@ -89,9 +89,6 @@ data OtherError
printError :: PackageError -> IO ()
printError = printToStderr . renderError
-printErrorToStdout :: PackageError -> IO ()
-printErrorToStdout = printToStdout . renderError
-
renderError :: PackageError -> Box
renderError err =
case err of
@@ -121,17 +118,26 @@ renderError err =
displayUserError :: UserError -> Box
displayUserError e = case e of
- PackageManifestNotFound ->
- para (
- "The package manifest file was not found. Please create one, or run " ++
- "`pulp init`."
- )
+ PackageManifestNotFound path -> do
+ vcat
+ [ para "The package manifest file was not found:"
+ , indented (para path)
+ , spacer
+ , para "Please create either a bower.json or purs.json manifest file."
+ ]
ResolutionsFileNotFound ->
para "The resolutions file was not found."
+ CouldntConvertPackageManifest err ->
+ vcat
+ [ para "Unable to convert your package manifest file to the Bower format:"
+ , indented ((para . T.unpack) (showBowerError err))
+ , spacer
+ , para "Please ensure that your package manifest file is valid."
+ ]
CouldntDecodePackageManifest err ->
vcat
[ para "There was a problem with your package manifest file:"
- , indented (vcat (map (para . T.unpack) (displayError showBowerError err)))
+ , indented (vcat (map (para . T.unpack) (displayError showManifestError err)))
, spacer
, para "Please ensure that your package manifest file is valid."
]
@@ -159,7 +165,7 @@ displayUserError e = case e of
[ "The currently checked out commit seems to have been tagged with "
, "more than 1 version, and I don't know which one should be used. "
, "Please either delete some of the tags, or create a new commit "
- , "to tag the desired verson with."
+ , "to tag the desired version with."
])
, spacer
, para "Tags for the currently checked out commit:"
@@ -168,32 +174,34 @@ displayUserError e = case e of
displayRepositoryError err
NoLicenseSpecified ->
vcat $
- [ para (concat
- [ "No license is specified in package manifest. Please add one, using the "
- , "SPDX license expression format. For example, any of the "
- , "following would be acceptable:"
- ])
+ [ para $ concat
+ [ "No license is specified in package manifest. Please add a "
+ , "\"license\" property with a SPDX license expression. For example, "
+ , "any of the following would be acceptable:"
+ ]
, spacer
] ++ spdxExamples ++
[ spacer
- , para (
- "Note that distributing code without a license means that nobody "
- ++ "will (legally) be able to use it."
- )
+ , para $
+ "See https://spdx.org/licenses/ for a full list of licenses. For more " ++
+ "information on SPDX license expressions, see https://spdx.org/ids-how"
, spacer
- , para (concat
- [ "It is also recommended to add a LICENSE file to the repository, "
- , "including your name and the current year, although this is not "
- , "necessary."
- ])
+ , para $
+ "Note that distributing code without a license means that nobody will " ++
+ "(legally) be able to use it."
+ , spacer
+ , para $
+ "It is also recommended to add a LICENSE file to the repository, " ++
+ "including your name and the current year, although this is not necessary."
]
InvalidLicense ->
vcat $
- [ para (concat
- [ "The license specified in package manifest is not a valid SPDX license "
- , "expression. Please use the SPDX license expression format. For "
- , "example, any of the following would be acceptable:"
- ])
+ [ para $ concat
+ [ "The license specified in package manifest is not a valid SPDX "
+ , "license expression. Please update the \"license\" property so that "
+ , "it is a valid SPDX license expression. For example, any of the "
+ , "following would be acceptable:"
+ ]
, spacer
] ++
spdxExamples
@@ -203,12 +211,11 @@ displayUserError e = case e of
do_ = pl "do" "does"
dependencies = pl "dependencies" "dependency"
in vcat $
- [ para (concat
+ para (concat
[ "The following ", dependencies, " ", do_, " not appear to be "
, "installed:"
- ])
- ] ++
- bulletedListT runPackageName (NonEmpty.toList pkgs)
+ ]) :
+ bulletedListT runPackageName (NonEmpty.toList pkgs)
CompileError err ->
vcat
[ para "Compile error:"
@@ -221,8 +228,8 @@ displayUserError e = case e of
)
ResolutionsFileError path err ->
successivelyIndented $
- [ "Error in resolutions file (" ++ path ++ "):" ]
- ++ map T.unpack (displayError D.displayPackageError err)
+ ("Error in resolutions file (" ++ path ++ "):") :
+ map T.unpack (displayError D.displayPackageError err)
spdxExamples :: [Box]
spdxExamples =
@@ -230,8 +237,8 @@ spdxExamples =
[ "* \"MIT\""
, "* \"Apache-2.0\""
, "* \"BSD-2-Clause\""
- , "* \"GPL-2.0+\""
- , "* \"(GPL-3.0 OR MIT)\""
+ , "* \"GPL-2.0-or-later\""
+ , "* \"(GPL-3.0-only OR MIT)\""
]
displayRepositoryError :: RepositoryFieldError -> Box
@@ -239,10 +246,10 @@ displayRepositoryError err = case err of
RepositoryFieldMissing giturl ->
vcat
[ para (concat
- [ "The 'repository' field is not present in your package manifest file. "
+ [ "The 'repository' or 'location' field is not present in your package manifest file. "
, "Without this information, Pursuit would not be able to generate "
, "source links in your package's documentation. Please add one - like "
- , "this, for example:"
+ , "this, if you are using the bower.json format:"
])
, spacer
, indented (vcat
@@ -252,6 +259,15 @@ displayRepositoryError err = case err of
, para "}"
]
)
+ , para "or like this, if you are using the purs.json format:"
+ , spacer
+ , indented (vcat
+ [ para "\"location\": {"
+ , indented (para "\"githubOwner\": \"USER\",")
+ , indented (para "\"githubRepo\": \"REPO\",")
+ , para "}"
+ ]
+ )
]
BadRepositoryType ty ->
para (concat
@@ -297,16 +313,15 @@ data CollectedWarnings = CollectedWarnings
{ noResolvedVersions :: [PackageName]
, unacceptableVersions :: [(PackageName, Text)]
, dirtyWorkingTree :: Any
- , legacyResolutionsFormat :: Maybe (First FilePath)
}
deriving (Show, Eq, Ord)
instance Semigroup CollectedWarnings where
- (<>) (CollectedWarnings a b c d) (CollectedWarnings a' b' c' d') =
- CollectedWarnings (a <> a') (b <> b') (c <> c') (d <> d')
+ (<>) (CollectedWarnings a b c) (CollectedWarnings a' b' c') =
+ CollectedWarnings (a <> a') (b <> b') (c <> c')
instance Monoid CollectedWarnings where
- mempty = CollectedWarnings mempty mempty mempty mempty
+ mempty = CollectedWarnings mempty mempty mempty
collectWarnings :: [PackageWarning] -> CollectedWarnings
collectWarnings = foldMap singular
@@ -316,10 +331,8 @@ collectWarnings = foldMap singular
mempty { noResolvedVersions = [pn] }
UnacceptableVersion t ->
mempty { unacceptableVersions = [t] }
- DirtyWorkingTree_Warn ->
+ DirtyWorkingTreeWarn ->
mempty { dirtyWorkingTree = Any True }
- LegacyResolutionsFormat path ->
- mempty { legacyResolutionsFormat = Just (First path) }
renderWarnings :: [PackageWarning] -> Box
renderWarnings warns =
@@ -330,7 +343,6 @@ renderWarnings warns =
, if getAny dirtyWorkingTree
then Just warnDirtyWorkingTree
else Nothing
- , fmap (warnLegacyResolutions . getFirst) legacyResolutionsFormat
]
in case catMaybes mboxes of
[] -> nullBox
@@ -396,20 +408,5 @@ warnDirtyWorkingTree =
++ "were not a dry run)"
)
-warnLegacyResolutions :: FilePath -> Box
-warnLegacyResolutions path =
- vcat $
- [ para (concat
- [ "Your resolutions file (" ++ path ++ ") is using the deprecated "
- , "legacy format. Support for this format will be dropped in a future "
- , "version."
- ])
- , spacer
- , para (concat
- [ "In most cases, all you need to do to use the new format and silence "
- , "this warning is to upgrade Pulp."
- ])
- ]
-
printWarnings :: [PackageWarning] -> IO ()
printWarnings = printToStderr . renderWarnings
diff --git a/src/Language/PureScript/Publish/Registry/Compat.hs b/src/Language/PureScript/Publish/Registry/Compat.hs
new file mode 100644
index 0000000000..a1a01ed9a4
--- /dev/null
+++ b/src/Language/PureScript/Publish/Registry/Compat.hs
@@ -0,0 +1,98 @@
+-- | A compatibility module that allows a restricted set of purs.json manifest
+-- | files to be used for publishing. The manifest must described a package
+-- | available on GitHub, and it must be convertable to a Bower manifest.
+-- |
+-- | Fully supporting the registry manifest format will require `purs publish`
+-- | and by extension Pursuit to relax the requirement that packages are hosted
+-- | on GitHub, because the registry does not have this requirement.
+module Language.PureScript.Publish.Registry.Compat where
+
+import Protolude
+import Data.Map qualified as Map
+import Web.Bower.PackageMeta qualified as Bower
+import Data.Bitraversable (Bitraversable(..))
+import Data.Aeson.BetterErrors (key, asText, keyMay, eachInObject, Parse, throwCustomError)
+
+-- | Convert a valid purs.json manifest into a bower.json manifest
+toBowerPackage :: PursJson -> Either Bower.BowerError Bower.PackageMeta
+toBowerPackage PursJson{..} = do
+ bowerName <- Bower.parsePackageName ("purescript-" <> pursJsonName)
+ let
+ bowerDescription = pursJsonDescription
+ bowerMain = []
+ bowerModuleType = []
+ bowerLicense = [ pursJsonLicense ]
+ bowerIgnore = []
+ bowerKeywords = []
+ bowerAuthors = []
+ bowerHomepage = Just pursJsonLocation
+ bowerRepository = Just $ Bower.Repository { repositoryUrl = pursJsonLocation, repositoryType = "git" }
+ bowerDevDependencies = []
+ bowerResolutions = []
+ bowerPrivate = False
+
+ let parseDependencies = traverse (bitraverse (Bower.parsePackageName . ("purescript-" <>)) (pure . Bower.VersionRange))
+ bowerDependencies <- parseDependencies $ Map.toAscList pursJsonDependencies
+ pure $ Bower.PackageMeta {..}
+
+-- | A partial representation of the purs.json manifest format, including only
+-- | the fields required for publishing.
+-- |
+-- | https://github.com/purescript/registry/blob/master/v1/Manifest.dhall
+--
+-- This type is intended for compatibility with the Bower publishing pipeline,
+-- and does not accurately reflect all possible purs.json manifests. However,
+-- supporting purs.json manifests properly introduces breaking changes to the
+-- compiler and to Pursuit.
+data PursJson = PursJson
+ { -- | The name of the package
+ pursJsonName :: Text
+ -- | The SPDX identifier representing the package license
+ , pursJsonLicense :: Text
+ -- | The GitHub repository hosting the package
+ , pursJsonLocation :: Text
+ -- | An optional description of the package
+ , pursJsonDescription :: Maybe Text
+ -- | A map of dependencies, where keys are package names and values are
+ -- | dependency ranges of the form '>=X.Y.Z Text
+showPursJsonError = \case
+ MalformedLocationField ->
+ "The 'location' field must be either '{ \"githubOwner\": OWNER, \"githubRepo\": REPO }' or '{ \"gitUrl\": URL }'."
+
+asPursJson :: Parse PursJsonError PursJson
+asPursJson = do
+ pursJsonName <- key "name" asText
+ pursJsonDescription <- keyMay "description" asText
+ pursJsonLicense <- key "license" asText
+ pursJsonDependencies <- key "dependencies" (Map.fromAscList <$> eachInObject asText)
+ -- Packages are required to come from GitHub in PureScript 0.14.x, but the
+ -- PureScript registry does not require this, nor does it require that
+ -- packages are Git repositories. This restriction should be lifted when
+ -- we fully support purs.json manifests in the compiler and on Pursuit.
+ --
+ -- For the time being, we only parse manifests that include a GitHub owner
+ -- and repo pair, or which specify a Git URL, which we use to try and get
+ -- the package from GitHub.
+ pursJsonLocation <- key "location" asOwnerRepoOrGitUrl
+ pure $ PursJson{..}
+ where
+ asOwnerRepoOrGitUrl =
+ catchError asOwnerRepo (\_ -> catchError asGitUrl (\_ -> throwCustomError MalformedLocationField))
+
+ asGitUrl =
+ key "gitUrl" asText
+
+ asOwnerRepo = do
+ githubOwner <- key "githubOwner" asText
+ githubRepo <- key "githubRepo" asText
+ pure $ "https://github.com/" <> githubOwner <> "/" <> githubRepo <> ".git"
diff --git a/src/Language/PureScript/Publish/Utils.hs b/src/Language/PureScript/Publish/Utils.hs
index 46c736d5e8..3760729518 100644
--- a/src/Language/PureScript/Publish/Utils.hs
+++ b/src/Language/PureScript/Publish/Utils.hs
@@ -1,8 +1,8 @@
module Language.PureScript.Publish.Utils where
-import Prelude.Compat
+import Prelude
-import System.Directory
+import System.Directory (getCurrentDirectory)
import System.FilePath.Glob (Pattern, compile, globDir1)
-- | Glob relative to the current directory, and produce relative pathnames.
diff --git a/src/Language/PureScript/Renamer.hs b/src/Language/PureScript/Renamer.hs
index 4ee82ad0d3..aff42ca288 100644
--- a/src/Language/PureScript/Renamer.hs
+++ b/src/Language/PureScript/Renamer.hs
@@ -1,21 +1,23 @@
-- |
-- Renaming pass that prevents shadowing of local identifiers.
--
-module Language.PureScript.Renamer (renameInModules) where
+module Language.PureScript.Renamer (renameInModule) where
-import Prelude.Compat
+import Prelude
-import Control.Monad.State
+import Control.Monad.State (MonadState(..), State, gets, modify, runState)
+import Control.Monad ((>=>))
+import Data.Functor ((<&>))
import Data.List (find)
import Data.Maybe (fromJust, fromMaybe)
-import qualified Data.Map as M
-import qualified Data.Set as S
-import qualified Data.Text as T
+import Data.Map qualified as M
+import Data.Set qualified as S
+import Data.Text qualified as T
-import Language.PureScript.CoreFn
-import Language.PureScript.Names
-import Language.PureScript.Traversals
+import Language.PureScript.CoreFn (Ann, Bind(..), Binder(..), CaseAlternative(..), Expr(..), Literal(..), Module(..))
+import Language.PureScript.Names (Ident(..), Qualified(..), isBySourcePos, isPlainIdent, runIdent, showIdent)
+import Language.PureScript.Traversals (eitherM, pairM, sndM)
-- |
-- The state object used in this module
@@ -39,8 +41,8 @@ initState scope = RenameState (M.fromList (zip scope scope)) (S.fromList scope)
-- |
-- Runs renaming starting with a list of idents for the initial scope.
--
-runRename :: [Ident] -> Rename a -> a
-runRename scope = flip evalState (initState scope)
+runRename :: [Ident] -> Rename a -> (a, RenameState)
+runRename scope = flip runState (initState scope)
-- |
-- Creates a new renaming scope using the current as a basis. Used to backtrack
@@ -93,48 +95,68 @@ lookupIdent name = do
Just name'' -> return name''
Nothing -> error $ "Rename scope is missing ident '" ++ T.unpack (showIdent name) ++ "'"
--- |
--- Finds idents introduced by declarations.
---
-findDeclIdents :: [Bind Ann] -> [Ident]
-findDeclIdents = concatMap go
- where
- go (NonRec _ ident _) = [ident]
- go (Rec ds) = map (snd . fst) ds
-- |
--- Renames within each declaration in a module.
+-- Renames within each declaration in a module. Returns the map of renamed
+-- identifiers in the top-level scope, so that they can be renamed in the
+-- externs files as well.
--
-renameInModules :: [Module Ann] -> [Module Ann]
-renameInModules = map go
+renameInModule :: Module Ann -> (M.Map Ident Ident, Module Ann)
+renameInModule m@(Module _ _ _ _ _ exports _ foreigns decls) = (rsBoundNames, m { moduleExports, moduleDecls })
where
- go :: Module Ann -> Module Ann
- go m@(Module _ _ _ _ _ _ _ decls) = m { moduleDecls = map (renameInDecl' (findDeclIdents decls)) decls }
-
- renameInDecl' :: [Ident] -> Bind Ann -> Bind Ann
- renameInDecl' scope = runRename scope . renameInDecl True
+ ((moduleDecls, moduleExports), RenameState{..}) = runRename foreigns $
+ (,) <$> renameInDecls decls <*> traverse lookupIdent exports
-- |
--- Renames within a declaration. isTopLevel is used to determine whether the
--- declaration is a module member or appearing within a Let. At the top level
--- declarations are not renamed or added to the scope (they should already have
--- been added), whereas in a Let declarations are renamed if their name shadows
--- another in the current scope.
+-- Renames within a list of declarations. The list is processed in three
+-- passes:
+--
+-- 1) Declarations with user-provided names are added to the scope, renaming
+-- them only if necessary to prevent shadowing.
+-- 2) Declarations with compiler-provided names are added to the scope,
+-- renaming them to prevent shadowing or collision with a user-provided
+-- name.
+-- 3) The bodies of the declarations are processed recursively.
--
-renameInDecl :: Bool -> Bind Ann -> Rename (Bind Ann)
-renameInDecl isTopLevel (NonRec a name val) = do
- name' <- if isTopLevel then return name else updateScope name
- NonRec a name' <$> renameInValue val
-renameInDecl isTopLevel (Rec ds) = do
- ds' <- traverse updateNames ds
- Rec <$> traverse updateValues ds'
+-- The distinction between passes 1 and 2 is critical in the top-level module
+-- scope, where declarations can be exported and named declarations must not
+-- be renamed. Below the top level, this only matters for programmers looking
+-- at the generated code or using a debugger; we want them to see the names
+-- they used as much as possible.
+--
+-- The distinction between the first two passes and pass 3 is important because
+-- a `GenIdent` can appear before its declaration in a depth-first traversal,
+-- and we need to visit the declaration first in order to rename all of its
+-- uses. Similarly, a plain `Ident` could shadow another declared in an outer
+-- scope but later in a depth-first traversal, and we need to visit the
+-- outer declaration first in order to know to rename the inner one.
+--
+renameInDecls :: [Bind Ann] -> Rename [Bind Ann]
+renameInDecls =
+ traverse (renameDecl False)
+ >=> traverse (renameDecl True)
+ >=> traverse renameValuesInDecl
+
where
- updateNames :: ((Ann, Ident), Expr Ann) -> Rename ((Ann, Ident), Expr Ann)
- updateNames ((a, name), val) = do
- name' <- if isTopLevel then return name else updateScope name
- return ((a, name'), val)
- updateValues :: ((Ann, Ident), Expr Ann) -> Rename ((Ann, Ident), Expr Ann)
- updateValues (aname, val) = (,) aname <$> renameInValue val
+
+ renameDecl :: Bool -> Bind Ann -> Rename (Bind Ann)
+ renameDecl isSecondPass = \case
+ NonRec a name val -> updateName name <&> \name' -> NonRec a name' val
+ Rec ds -> Rec <$> traverse updateNames ds
+ where
+ updateName :: Ident -> Rename Ident
+ updateName name = (if isSecondPass == isPlainIdent name then pure else updateScope) name
+
+ updateNames :: ((Ann, Ident), Expr Ann) -> Rename ((Ann, Ident), Expr Ann)
+ updateNames ((a, name), val) = updateName name <&> \name' -> ((a, name'), val)
+
+ renameValuesInDecl :: Bind Ann -> Rename (Bind Ann)
+ renameValuesInDecl = \case
+ NonRec a name val -> NonRec a name <$> renameInValue val
+ Rec ds -> Rec <$> traverse updateValues ds
+ where
+ updateValues :: ((Ann, Ident), Expr Ann) -> Rename ((Ann, Ident), Expr Ann)
+ updateValues (aname, val) = (aname, ) <$> renameInValue val
-- |
-- Renames within a value.
@@ -145,20 +167,23 @@ renameInValue (Literal ann l) =
renameInValue c@Constructor{} = return c
renameInValue (Accessor ann prop v) =
Accessor ann prop <$> renameInValue v
-renameInValue (ObjectUpdate ann obj vs) =
- ObjectUpdate ann <$> renameInValue obj <*> traverse (\(name, v) -> (,) name <$> renameInValue v) vs
-renameInValue e@(Abs (_, _, _, Just IsTypeClassConstructor) _ _) = return e
+renameInValue (ObjectUpdate ann obj copy vs) =
+ (\obj' -> ObjectUpdate ann obj' copy) <$> renameInValue obj <*> traverse (\(name, v) -> (name, ) <$> renameInValue v) vs
renameInValue (Abs ann name v) =
newScope $ Abs ann <$> updateScope name <*> renameInValue v
renameInValue (App ann v1 v2) =
App ann <$> renameInValue v1 <*> renameInValue v2
-renameInValue (Var ann (Qualified Nothing name)) =
- Var ann . Qualified Nothing <$> lookupIdent name
+renameInValue (Var ann (Qualified qb name)) | isBySourcePos qb || not (isPlainIdent name) =
+ -- This should only rename identifiers local to the current module: either
+ -- they aren't qualified, or they are but they have a name that should not
+ -- have appeared in a module's externs, so they must be from this module's
+ -- top-level scope.
+ Var ann . Qualified qb <$> lookupIdent name
renameInValue v@Var{} = return v
renameInValue (Case ann vs alts) =
newScope $ Case ann <$> traverse renameInValue vs <*> traverse renameInCaseAlternative alts
renameInValue (Let ann ds v) =
- newScope $ Let ann <$> traverse (renameInDecl False) ds <*> renameInValue v
+ newScope $ Let ann <$> renameInDecls ds <*> renameInValue v
-- |
-- Renames within literals.
diff --git a/src/Language/PureScript/Roles.hs b/src/Language/PureScript/Roles.hs
new file mode 100644
index 0000000000..7a73062993
--- /dev/null
+++ b/src/Language/PureScript/Roles.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+-- |
+-- Data types for roles.
+--
+module Language.PureScript.Roles
+ ( Role(..)
+ , displayRole
+ ) where
+
+import Prelude
+
+import Codec.Serialise (Serialise)
+import Control.DeepSeq (NFData)
+import Data.Aeson qualified as A
+import Data.Aeson.TH qualified as A
+import Data.Text (Text)
+import GHC.Generics (Generic)
+
+-- |
+-- The role of a type constructor's parameter.
+data Role
+ = Nominal
+ -- ^ This parameter's identity affects the representation of the type it is
+ -- parameterising.
+ | Representational
+ -- ^ This parameter's representation affects the representation of the type it
+ -- is parameterising.
+ | Phantom
+ -- ^ This parameter has no effect on the representation of the type it is
+ -- parameterising.
+ deriving (Show, Eq, Ord, Generic)
+
+instance NFData Role
+instance Serialise Role
+
+$(A.deriveJSON A.defaultOptions ''Role)
+
+displayRole :: Role -> Text
+displayRole r = case r of
+ Nominal -> "nominal"
+ Representational -> "representational"
+ Phantom -> "phantom"
diff --git a/src/Language/PureScript/Sugar.hs b/src/Language/PureScript/Sugar.hs
index 99d422c76c..4d713d5418 100644
--- a/src/Language/PureScript/Sugar.hs
+++ b/src/Language/PureScript/Sugar.hs
@@ -4,17 +4,16 @@
module Language.PureScript.Sugar (desugar, module S) where
import Control.Category ((>>>))
-import Control.Monad
-import Control.Monad.Error.Class (MonadError())
-import Control.Monad.Supply.Class
-import Control.Monad.Writer.Class (MonadWriter())
+import Control.Monad ((>=>))
+import Control.Monad.Error.Class (MonadError)
+import Control.Monad.Supply.Class (MonadSupply)
+import Control.Monad.State.Class (MonadState)
+import Control.Monad.Writer.Class (MonadWriter)
-import Data.List (map)
-import Data.Traversable (traverse)
-
-import Language.PureScript.AST
-import Language.PureScript.Errors
-import Language.PureScript.Externs
+import Language.PureScript.AST (Module)
+import Language.PureScript.Errors (MultipleErrors)
+import Language.PureScript.Externs (ExternsFile)
+import Language.PureScript.Linter.Imports (UsedImports)
import Language.PureScript.Sugar.BindingGroups as S
import Language.PureScript.Sugar.CaseDeclarations as S
import Language.PureScript.Sugar.DoNotation as S
@@ -48,26 +47,29 @@ import Language.PureScript.Sugar.TypeDeclarations as S
--
-- * Rebracket user-defined binary operators
--
--- * Introduce type synonyms for type class dictionaries
+-- * Introduce newtypes for type class dictionaries and value declarations for instances
--
-- * Group mutually recursive value and data declarations into binding groups.
--
desugar
- :: (MonadSupply m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
+ :: MonadSupply m
+ => MonadError MultipleErrors m
+ => MonadWriter MultipleErrors m
+ => MonadState (Env, UsedImports) m
=> [ExternsFile]
- -> [Module]
- -> m [Module]
+ -> Module
+ -> m Module
desugar externs =
- map desugarSignedLiterals
- >>> traverse desugarObjectConstructors
- >=> traverse desugarDoModule
- >=> traverse desugarAdoModule
- >=> map desugarLetPatternModule
- >>> traverse desugarCasesModule
- >=> traverse desugarTypeDeclarationsModule
- >=> desugarImports externs
+ desugarSignedLiterals
+ >>> desugarObjectConstructors
+ >=> desugarDoModule
+ >=> desugarAdoModule
+ >=> desugarLetPatternModule
+ >>> desugarCasesModule
+ >=> desugarTypeDeclarationsModule
+ >=> desugarImports
>=> rebracket externs
- >=> traverse checkFixityExports
- >=> traverse (deriveInstances externs)
+ >=> checkFixityExports
+ >=> deriveInstances
>=> desugarTypeClasses externs
- >=> traverse createBindingGroupsModule
+ >=> createBindingGroupsModule
diff --git a/src/Language/PureScript/Sugar/AdoNotation.hs b/src/Language/PureScript/Sugar/AdoNotation.hs
index f7e84bccc2..3ac5373621 100644
--- a/src/Language/PureScript/Sugar/AdoNotation.hs
+++ b/src/Language/PureScript/Sugar/AdoNotation.hs
@@ -1,20 +1,18 @@
-- | This module implements the desugaring pass which replaces ado-notation statements with
-- appropriate calls to pure and apply.
-{-# LANGUAGE PatternGuards #-}
-
module Language.PureScript.Sugar.AdoNotation (desugarAdoModule) where
-import Prelude.Compat hiding (abs)
+import Prelude hiding (abs)
-import Control.Monad (foldM)
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.Supply.Class
-import Data.List (foldl')
-import Language.PureScript.AST
-import Language.PureScript.Errors
-import Language.PureScript.Names
-import qualified Language.PureScript.Constants as C
+import Control.Monad (foldM)
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.Supply.Class (MonadSupply)
+import Data.List (foldl')
+import Language.PureScript.AST (Binder(..), CaseAlternative(..), Declaration, DoNotationElement(..), Expr(..), pattern MkUnguarded, Module(..), SourceSpan, WhereProvenance(..), declSourceSpan, everywhereOnValuesM)
+import Language.PureScript.Errors (MultipleErrors, parU, rethrowWithPosition)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName, Qualified(..), byMaybeModuleName, freshIdent')
+import Language.PureScript.Constants.Libs qualified as C
-- | Replace all @AdoNotationBind@ and @AdoNotationValue@ constructors with
-- applications of the pure and apply functions in scope, and all @AdoNotationLet@
@@ -25,43 +23,44 @@ desugarAdoModule (Module ss coms mn ds exts) = Module ss coms mn <$> parU ds des
-- | Desugar a single ado statement
desugarAdo :: forall m. (MonadSupply m, MonadError MultipleErrors m) => Declaration -> m Declaration
desugarAdo d =
- let (f, _, _) = everywhereOnValuesM return replace return
- in f d
+ let ss = declSourceSpan d
+ (f, _, _) = everywhereOnValuesM return (replace ss) return
+ in rethrowWithPosition ss $ f d
where
- pure' :: Maybe ModuleName -> Expr
- pure' m = Var nullSourceSpan (Qualified m (Ident C.pure'))
+ pure' :: SourceSpan -> Maybe ModuleName -> Expr
+ pure' ss m = Var ss (Qualified (byMaybeModuleName m) (Ident C.S_pure))
- map' :: Maybe ModuleName -> Expr
- map' m = Var nullSourceSpan (Qualified m (Ident C.map))
+ map' :: SourceSpan -> Maybe ModuleName -> Expr
+ map' ss m = Var ss (Qualified (byMaybeModuleName m) (Ident C.S_map))
- apply :: Maybe ModuleName -> Expr
- apply m = Var nullSourceSpan (Qualified m (Ident C.apply))
+ apply :: SourceSpan -> Maybe ModuleName -> Expr
+ apply ss m = Var ss (Qualified (byMaybeModuleName m) (Ident C.S_apply))
- replace :: Expr -> m Expr
- replace (Ado m els yield) = do
- (func, args) <- foldM go (yield, []) (reverse els)
+ replace :: SourceSpan -> Expr -> m Expr
+ replace pos (Ado m els yield) = do
+ (func, args) <- foldM (go pos) (yield, []) (reverse els)
return $ case args of
- [] -> App (pure' m) func
- hd : tl -> foldl' (\a b -> App (App (apply m) a) b) (App (App (map' m) func) hd) tl
- replace (PositionedValue pos com v) = PositionedValue pos com <$> rethrowWithPosition pos (replace v)
- replace other = return other
+ [] -> App (pure' pos m) func
+ hd : tl -> foldl' (\a b -> App (App (apply pos m) a) b) (App (App (map' pos m) func) hd) tl
+ replace _ (PositionedValue pos com v) = PositionedValue pos com <$> rethrowWithPosition pos (replace pos v)
+ replace _ other = return other
- go :: (Expr, [Expr]) -> DoNotationElement -> m (Expr, [Expr])
- go (yield, args) (DoNotationValue val) =
+ go :: SourceSpan -> (Expr, [Expr]) -> DoNotationElement -> m (Expr, [Expr])
+ go _ (yield, args) (DoNotationValue val) =
return (Abs NullBinder yield, val : args)
- go (yield, args) (DoNotationBind (VarBinder ss ident) val) =
+ go _ (yield, args) (DoNotationBind (VarBinder ss ident) val) =
return (Abs (VarBinder ss ident) yield, val : args)
- go (yield, args) (DoNotationBind binder val) = do
+ go ss (yield, args) (DoNotationBind binder val) = do
ident <- freshIdent'
- let abs = Abs (VarBinder nullSourceSpan ident)
- (Case [Var nullSourceSpan (Qualified Nothing ident)]
+ let abs = Abs (VarBinder ss ident)
+ (Case [Var ss (Qualified ByNullSourcePos ident)]
[CaseAlternative [binder] [MkUnguarded yield]])
return (abs, val : args)
- go (yield, args) (DoNotationLet ds) = do
+ go _ (yield, args) (DoNotationLet ds) = do
return (Let FromLet ds yield, args)
- go acc (PositionedDoNotationElement pos com el) =
+ go _ acc (PositionedDoNotationElement pos com el) =
rethrowWithPosition pos $ do
- (yield, args) <- go acc el
+ (yield, args) <- go pos acc el
return $ case args of
[] -> (PositionedValue pos com yield, args)
(a : as) -> (yield, PositionedValue pos com a : as)
diff --git a/src/Language/PureScript/Sugar/BindingGroups.hs b/src/Language/PureScript/Sugar/BindingGroups.hs
index a4efc201d6..835e775f81 100644
--- a/src/Language/PureScript/Sugar/BindingGroups.hs
+++ b/src/Language/PureScript/Sugar/BindingGroups.hs
@@ -6,27 +6,36 @@ module Language.PureScript.Sugar.BindingGroups
( createBindingGroups
, createBindingGroupsModule
, collapseBindingGroups
- , collapseBindingGroupsModule
) where
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
+import Protolude (ordNub, swap)
-import Control.Monad ((<=<))
+import Control.Monad ((<=<), guard)
import Control.Monad.Error.Class (MonadError(..))
-import Data.Graph
-import Data.List (intersect)
+import Data.Graph (SCC(..), stronglyConnComp, stronglyConnCompR)
+import Data.List (intersect, (\\))
+import Data.List.NonEmpty (NonEmpty((:|)), nonEmpty)
+import Data.Foldable (find)
+import Data.Functor (($>))
import Data.Maybe (isJust, mapMaybe)
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Set as S
+import Data.List.NonEmpty qualified as NEL
+import Data.Map qualified as M
+import Data.Set qualified as S
import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Names
-import Language.PureScript.Types
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (NameKind)
+import Language.PureScript.Errors (ErrorMessage(..), MultipleErrors(..), SimpleErrorMessage(..), errorMessage', parU, positionedError)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident, ModuleName, ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), coerceProperName)
+import Language.PureScript.Types (Constraint(..), SourceConstraint, SourceType, Type(..), everythingOnTypes)
+
+data VertexType
+ = VertexDefinition
+ | VertexKindSignature
+ | VertexRoleDeclaration
+ deriving (Eq, Ord, Show)
-- |
-- Replace all sets of mutually-recursive declarations in a module with binding groups
@@ -38,14 +47,6 @@ createBindingGroupsModule
createBindingGroupsModule (Module ss coms name ds exps) =
Module ss coms name <$> createBindingGroups name ds <*> pure exps
--- |
--- Collapse all binding groups in a module to individual declarations
---
-collapseBindingGroupsModule :: [Module] -> [Module]
-collapseBindingGroupsModule =
- fmap $ \(Module ss coms name ds exps) ->
- Module ss coms name (collapseBindingGroups ds) exps
-
createBindingGroups
:: forall m
. (MonadError MultipleErrors m)
@@ -61,25 +62,67 @@ createBindingGroups moduleName = mapM f <=< handleDecls
handleExprs (Let w ds val) = (\ds' -> Let w ds' val) <$> handleDecls ds
handleExprs other = return other
- -- |
-- Replace all sets of mutually-recursive declarations with binding groups
- --
handleDecls :: [Declaration] -> m [Declaration]
handleDecls ds = do
let values = mapMaybe (fmap (fmap extractGuardedExpr) . getValueDeclaration) ds
- dataDecls = filter isDataDecl ds
- allProperNames = fmap declTypeName dataDecls
- dataVerts = fmap (\d -> (d, declTypeName d, usedTypeNames moduleName d `intersect` allProperNames)) dataDecls
- dataBindingGroupDecls <- parU (stronglyConnComp dataVerts) toDataBindingGroup
- let allIdents = fmap valdeclIdent values
- valueVerts = fmap (\d -> (d, valdeclIdent d, usedIdents moduleName d `intersect` allIdents)) values
- bindingGroupDecls <- parU (stronglyConnComp valueVerts) (toBindingGroup moduleName)
+ kindDecls = (,VertexKindSignature) <$> filter isKindDecl ds
+ dataDecls = (,VertexDefinition) <$> filter (\a -> isDataDecl a || isExternDataDecl a || isTypeSynonymDecl a || isTypeClassDecl a) ds
+ roleDecls = (,VertexRoleDeclaration) <$> filter isRoleDecl ds
+ roleAnns = declTypeName . fst <$> roleDecls
+ kindSigs = declTypeName . fst <$> kindDecls
+ typeSyns = declTypeName <$> filter isTypeSynonymDecl ds
+ nonTypeSynKindSigs = kindSigs \\ typeSyns
+ allDecls = kindDecls ++ dataDecls ++ roleDecls
+ allProperNames = declTypeName . fst <$> allDecls
+ mkVert (d, vty) =
+ let names = usedTypeNames moduleName d `intersect` allProperNames
+ name = declTypeName d
+ -- If a dependency of a kind signature has a kind signature, than that's all we need to
+ -- depend on, except in the case that we are using a type synonym. In order to expand
+ -- the type synonym, we must depend on the synonym declaration itself.
+ --
+ -- Arguably, type declarations (as opposed to just kind signatures) could also depend
+ -- on kind signatures when present. Attempting this caused one known issue (#4038); the
+ -- type checker might not expect type declarations not to be preceded or grouped by
+ -- their actual dependencies in all cases. But in principle, if done carefully, this
+ -- approach could be used to reduce the number or size of data binding group cycles.
+ -- (It's critical that kind signatures not appear in groups, which is why they get
+ -- special treatment.)
+ vtype n
+ | vty == VertexKindSignature && n `elem` nonTypeSynKindSigs = VertexKindSignature
+ | otherwise = VertexDefinition
+ deps = fmap (\n -> (n, vtype n)) names
+ self
+ | vty == VertexDefinition =
+ (guard (name `elem` kindSigs) $> (name, VertexKindSignature))
+ ++ (guard (name `elem` roleAnns && not (isExternDataDecl d)) $> (name, VertexRoleDeclaration))
+ | vty == VertexRoleDeclaration = [(name, VertexDefinition)]
+ | otherwise = []
+ in (d, (name, vty), self ++ deps)
+ dataVerts = fmap mkVert allDecls
+ dataBindingGroupDecls <- parU (stronglyConnCompR dataVerts) toDataBindingGroup
+ let
+ -- #4437
+ --
+ -- The idea here is to create a `Graph` whose `key` is a tuple: `(Bool, Ident)`,
+ -- where the `Bool` encodes the absence of a type hole. This relies on an implementation
+ -- detail for `stronglyConnComp` which allows identifiers with no type holes to "float"
+ -- and get checked before those that do, while preserving reverse topological sorting.
+ makeValueDeclarationKey = (,) <$> exprHasNoTypeHole . valdeclExpression <*> valdeclIdent
+ valueDeclarationKeys = makeValueDeclarationKey <$> values
+
+ valueDeclarationInfo = M.fromList $ swap <$> valueDeclarationKeys
+ findDeclarationInfo i = (M.findWithDefault False i valueDeclarationInfo, i)
+ computeValueDependencies = (`intersect` valueDeclarationKeys) . fmap findDeclarationInfo . usedIdents moduleName
+
+ makeValueDeclarationVert = (,,) <$> id <*> makeValueDeclarationKey <*> computeValueDependencies
+ valueDeclarationVerts = makeValueDeclarationVert <$> values
+
+ bindingGroupDecls <- parU (stronglyConnComp valueDeclarationVerts) (toBindingGroup moduleName)
return $ filter isImportDecl ds ++
- filter isExternKindDecl ds ++
- filter isExternDataDecl ds ++
dataBindingGroupDecls ++
- filter isTypeClassDeclaration ds ++
- filter isTypeClassInstanceDeclaration ds ++
+ filter isTypeClassInstanceDecl ds ++
filter isFixityDecl ds ++
filter isExternDecl ds ++
bindingGroupDecls
@@ -87,13 +130,33 @@ createBindingGroups moduleName = mapM f <=< handleDecls
extractGuardedExpr [MkUnguarded expr] = expr
extractGuardedExpr _ = internalError "Expected Guards to have been desugared in handleDecls."
+ exprHasNoTypeHole :: Expr -> Bool
+ exprHasNoTypeHole = not . exprHasTypeHole
+ where
+ exprHasTypeHole :: Expr -> Bool
+ (_, exprHasTypeHole, _, _, _) = everythingOnValues (||) goDefault goExpr goDefault goDefault goDefault
+ where
+ goExpr :: Expr -> Bool
+ goExpr (Hole _) = True
+ goExpr _ = False
+
+ goDefault :: forall a. a -> Bool
+ goDefault = const False
+
-- |
-- Collapse all binding groups to individual declarations
--
collapseBindingGroups :: [Declaration] -> [Declaration]
collapseBindingGroups =
- let (f, _, _) = everywhereOnValues id collapseBindingGroupsForValue id
- in fmap f . concatMap go
+ let (f, _, _) = everywhereOnValues id flattenBindingGroupsForValue id
+ in fmap f . flattenBindingGroups
+
+flattenBindingGroupsForValue :: Expr -> Expr
+flattenBindingGroupsForValue (Let w ds val) = Let w (flattenBindingGroups ds) val
+flattenBindingGroupsForValue other = other
+
+flattenBindingGroups :: [Declaration] -> [Declaration]
+flattenBindingGroups = concatMap go
where
go (DataBindingGroupDeclaration ds) = NEL.toList ds
go (BindingGroupDeclaration ds) =
@@ -101,10 +164,6 @@ collapseBindingGroups =
ValueDecl sa ident nameKind [] [MkUnguarded val]) ds
go other = [other]
-collapseBindingGroupsForValue :: Expr -> Expr
-collapseBindingGroupsForValue (Let w ds val) = Let w (collapseBindingGroups ds) val
-collapseBindingGroupsForValue other = other
-
usedIdents :: ModuleName -> ValueDeclarationData Expr -> [Ident]
usedIdents moduleName = ordNub . usedIdents' S.empty . valdeclExpression
where
@@ -113,9 +172,9 @@ usedIdents moduleName = ordNub . usedIdents' S.empty . valdeclExpression
(_, usedIdents', _, _, _) = everythingWithScope def usedNamesE def def def
usedNamesE :: S.Set ScopedIdent -> Expr -> [Ident]
- usedNamesE scope (Var _ (Qualified Nothing name))
+ usedNamesE scope (Var _ (Qualified (BySourcePos _) name))
| LocalIdent name `S.notMember` scope = [name]
- usedNamesE scope (Var _ (Qualified (Just moduleName') name))
+ usedNamesE scope (Var _ (Qualified (ByModuleName moduleName') name))
| moduleName == moduleName' && ToplevelIdent name `S.notMember` scope = [name]
usedNamesE _ _ = []
@@ -127,30 +186,42 @@ usedImmediateIdents moduleName =
def s _ = (s, [])
usedNamesE :: Bool -> Expr -> (Bool, [Ident])
- usedNamesE True (Var _ (Qualified Nothing name)) = (True, [name])
- usedNamesE True (Var _ (Qualified (Just moduleName') name))
+ usedNamesE True (Var _ (Qualified (BySourcePos _) name)) = (True, [name])
+ usedNamesE True (Var _ (Qualified (ByModuleName moduleName') name))
| moduleName == moduleName' = (True, [name])
usedNamesE True (Abs _ _) = (False, [])
usedNamesE scope _ = (scope, [])
usedTypeNames :: ModuleName -> Declaration -> [ProperName 'TypeName]
-usedTypeNames moduleName =
- let (f, _, _, _, _) = accumTypes (everythingOnTypes (++) usedNames)
- in ordNub . f
+usedTypeNames moduleName = go
where
+ (f, _, _, _, _) = accumTypes (everythingOnTypes (++) usedNames)
+
+ go :: Declaration -> [ProperName 'TypeName]
+ go decl = ordNub (f decl <> usedNamesForTypeClassDeps decl)
+
usedNames :: SourceType -> [ProperName 'TypeName]
- usedNames (ConstrainedType _ con _) =
- case con of
- (Constraint _ (Qualified (Just moduleName') name) _ _)
- | moduleName == moduleName' -> [coerceProperName name]
- _ -> []
- usedNames (TypeConstructor _ (Qualified (Just moduleName') name))
+ usedNames (ConstrainedType _ con _) = usedConstraint con
+ usedNames (TypeConstructor _ (Qualified (ByModuleName moduleName') name))
| moduleName == moduleName' = [name]
usedNames _ = []
+ usedConstraint :: SourceConstraint -> [ProperName 'TypeName]
+ usedConstraint (Constraint _ (Qualified (ByModuleName moduleName') name) _ _ _)
+ | moduleName == moduleName' = [coerceProperName name]
+ usedConstraint _ = []
+
+ usedNamesForTypeClassDeps :: Declaration -> [ProperName 'TypeName]
+ usedNamesForTypeClassDeps (TypeClassDeclaration _ _ _ deps _ _) = foldMap usedConstraint deps
+ usedNamesForTypeClassDeps _ = []
+
declTypeName :: Declaration -> ProperName 'TypeName
declTypeName (DataDeclaration _ _ pn _ _) = pn
+declTypeName (ExternDataDeclaration _ pn _) = pn
declTypeName (TypeSynonymDeclaration _ pn _ _) = pn
+declTypeName (TypeClassDeclaration _ pn _ _ _ _) = coerceProperName pn
+declTypeName (KindDeclaration _ _ pn _) = pn
+declTypeName (RoleDeclaration (RoleDeclarationData _ pn _)) = pn
declTypeName _ = internalError "Expected DataDeclaration"
-- |
@@ -191,15 +262,36 @@ toBindingGroup moduleName (CyclicSCC ds') = do
toDataBindingGroup
:: MonadError MultipleErrors m
- => SCC Declaration
+ => Ord a
+ => SCC (Declaration, (ProperName 'TypeName, a), [(ProperName 'TypeName, a)])
-> m Declaration
-toDataBindingGroup (AcyclicSCC d) = return d
-toDataBindingGroup (CyclicSCC [d]) = case isTypeSynonym d of
- Just pn -> throwError . errorMessage' (declSourceSpan d) $ CycleInTypeSynonym (Just pn)
- _ -> return d
+toDataBindingGroup (AcyclicSCC (d, _, _)) = return d
toDataBindingGroup (CyclicSCC ds')
- | all (isJust . isTypeSynonym) ds' = throwError . errorMessage' (declSourceSpan (head ds')) $ CycleInTypeSynonym Nothing
- | otherwise = return . DataBindingGroupDeclaration $ NEL.fromList ds'
+ | Just kds@((ss, _) :| _) <- nonEmpty $ concatMap (kindDecl . getDecl) ds' = throwError . errorMessage' ss . CycleInKindDeclaration $ fmap snd kds
+ | not (null typeSynonymCycles) =
+ throwError
+ . MultipleErrors
+ . fmap (\syns -> ErrorMessage [positionedError . declSourceSpan . getDecl $ NEL.head syns] . CycleInTypeSynonym $ fmap (fst . getName) syns)
+ $ typeSynonymCycles
+ | otherwise = return . DataBindingGroupDeclaration . NEL.fromList $ getDecl <$> ds'
+ where
+ kindDecl (KindDeclaration sa _ pn _) = [(fst sa, Qualified ByNullSourcePos pn)]
+ kindDecl (ExternDataDeclaration sa pn _) = [(fst sa, Qualified ByNullSourcePos pn)]
+ kindDecl _ = []
+
+ getDecl (decl, _, _) = decl
+ getName (_, name, _) = name
+ lookupVert name = find ((==) name . getName) ds'
+
+ onlySynonyms (decl, name, deps) = do
+ guard . isJust $ isTypeSynonym decl
+ pure (decl, name, filter (maybe False (isJust . isTypeSynonym . getDecl) . lookupVert) deps)
+
+ isCycle (CyclicSCC c) = nonEmpty c
+ isCycle _ = Nothing
+
+ typeSynonymCycles =
+ mapMaybe isCycle . stronglyConnCompR . mapMaybe onlySynonyms $ ds'
isTypeSynonym :: Declaration -> Maybe (ProperName 'TypeName)
isTypeSynonym (TypeSynonymDeclaration _ pn _ _) = Just pn
diff --git a/src/Language/PureScript/Sugar/CaseDeclarations.hs b/src/Language/PureScript/Sugar/CaseDeclarations.hs
index 6199de9701..bcae767715 100644
--- a/src/Language/PureScript/Sugar/CaseDeclarations.hs
+++ b/src/Language/PureScript/Sugar/CaseDeclarations.hs
@@ -8,7 +8,7 @@ module Language.PureScript.Sugar.CaseDeclarations
, desugarCaseGuards
) where
-import Prelude.Compat
+import Prelude
import Protolude (ordNub)
import Data.List (groupBy, foldl1')
@@ -16,13 +16,13 @@ import Data.Maybe (catMaybes, mapMaybe)
import Control.Monad ((<=<), forM, replicateM, join, unless)
import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.Supply.Class
+import Control.Monad.Supply.Class (MonadSupply)
import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Names
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (NameKind(..))
+import Language.PureScript.Errors (ErrorMessage(..), MultipleErrors(..), SimpleErrorMessage(..), addHint, errorMessage', parU, rethrow, withPosition)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident, Qualified(..), freshIdent')
import Language.PureScript.TypeChecker.Monad (guardWith)
-- |
@@ -58,13 +58,13 @@ desugarGuardedExprs
-> Expr
-> m Expr
desugarGuardedExprs ss (Case scrut alternatives)
- | any (not . isTrivialExpr) scrut = do
+ | not $ all isTrivialExpr scrut = do
-- in case the scrutinee is non trivial (e.g. not a Var or Literal)
- -- we may evaluate the scrutinee more than once when a guard occurrs.
+ -- we may evaluate the scrutinee more than once when a guard occurs.
-- We bind the scrutinee to Vars here to mitigate this case.
(scrut', scrut_decls) <- unzip <$> forM scrut (\e -> do
scrut_id <- freshIdent'
- pure ( Var ss (Qualified Nothing scrut_id)
+ pure ( Var ss (Qualified ByNullSourcePos scrut_id)
, ValueDecl (ss, []) scrut_id Private [] [MkUnguarded e]
)
)
@@ -171,8 +171,8 @@ desugarGuardedExprs ss (Case scrut alternatives) =
-- if the binder is a var binder we must not add
-- the fail case as it results in unreachable
-- alternative
- alt_fail' | all isIrrefutable vb = []
- | otherwise = alt_fail
+ alt_fail' n | all isIrrefutable vb = []
+ | otherwise = alt_fail n
-- we are here:
@@ -186,18 +186,18 @@ desugarGuardedExprs ss (Case scrut alternatives) =
--
in Case scrut
(CaseAlternative vb [MkUnguarded (desugarGuard gs e alt_fail)]
- : alt_fail')
+ : alt_fail' (length scrut))
return [ CaseAlternative scrut_nullbinder [MkUnguarded rhs]]
- desugarGuard :: [Guard] -> Expr -> [CaseAlternative] -> Expr
+ desugarGuard :: [Guard] -> Expr -> (Int ->[CaseAlternative]) -> Expr
desugarGuard [] e _ = e
desugarGuard (ConditionGuard c : gs) e match_failed
| isTrueExpr c = desugarGuard gs e match_failed
| otherwise =
Case [c]
(CaseAlternative [LiteralBinder ss (BooleanLiteral True)]
- [MkUnguarded (desugarGuard gs e match_failed)] : match_failed)
+ [MkUnguarded (desugarGuard gs e match_failed)] : match_failed 1)
desugarGuard (PatternGuard vb g : gs) e match_failed =
Case [g]
@@ -206,7 +206,7 @@ desugarGuardedExprs ss (Case scrut alternatives) =
where
-- don't consider match_failed case if the binder is irrefutable
match_failed' | isIrrefutable vb = []
- | otherwise = match_failed
+ | otherwise = match_failed 1
-- we generate a let-binding for the remaining guards
-- and alternatives. A CaseAlternative is passed (or in
@@ -215,7 +215,7 @@ desugarGuardedExprs ss (Case scrut alternatives) =
desugarAltOutOfLine :: [Binder]
-> [GuardedExpr]
-> [CaseAlternative]
- -> ([CaseAlternative] -> Expr)
+ -> ((Int -> [CaseAlternative]) -> Expr)
-> m Expr
desugarAltOutOfLine alt_binder rem_guarded rem_alts mk_body
| Just rem_case <- mkCaseOfRemainingGuardsAndAlts = do
@@ -226,9 +226,10 @@ desugarGuardedExprs ss (Case scrut alternatives) =
let
goto_rem_case :: Expr
- goto_rem_case = Var ss (Qualified Nothing rem_case_id)
+ goto_rem_case = Var ss (Qualified ByNullSourcePos rem_case_id)
`App` Literal ss (BooleanLiteral True)
- alt_fail = [CaseAlternative [NullBinder] [MkUnguarded goto_rem_case]]
+ alt_fail :: Int -> [CaseAlternative]
+ alt_fail n = [CaseAlternative (replicate n NullBinder) [MkUnguarded goto_rem_case]]
pure $ Let FromLet [
ValueDecl (ss, []) rem_case_id Private []
@@ -236,7 +237,7 @@ desugarGuardedExprs ss (Case scrut alternatives) =
] (mk_body alt_fail)
| otherwise
- = pure $ mk_body []
+ = pure $ mk_body (const [])
where
mkCaseOfRemainingGuardsAndAlts
| not (null rem_guarded)
@@ -251,7 +252,7 @@ desugarGuardedExprs ss (Case scrut alternatives) =
-- case expressions with a single alternative which have
-- a NullBinder occur frequently after desugaring
- -- complex guards. This function removes these superflous
+ -- complex guards. This function removes these superfluous
-- cases.
optimize :: Expr -> Expr
optimize (Case _ [CaseAlternative vb [MkUnguarded v]])
@@ -266,8 +267,8 @@ desugarGuardedExprs ss (Case scrut alternatives) =
alts' <- desugarAlternatives alternatives
return $ optimize (Case scrut alts')
-desugarGuardedExprs ss (TypedValue infered e ty) =
- TypedValue infered <$> desugarGuardedExprs ss e <*> pure ty
+desugarGuardedExprs ss (TypedValue inferred e ty) =
+ TypedValue inferred <$> desugarGuardedExprs ss e <*> pure ty
desugarGuardedExprs _ (PositionedValue ss comms e) =
PositionedValue ss comms <$> desugarGuardedExprs ss e
@@ -312,7 +313,7 @@ desugarAbs = flip parU f
pure (Abs (VarBinder ss i) val)
replace (Abs binder val) = do
ident <- freshIdent'
- return $ Abs (VarBinder nullSourceSpan ident) $ Case [Var nullSourceSpan (Qualified Nothing ident)] [CaseAlternative [binder] [MkUnguarded val]]
+ return $ Abs (VarBinder nullSourceSpan ident) $ Case [Var nullSourceSpan (Qualified ByNullSourcePos ident)] [CaseAlternative [binder] [MkUnguarded val]]
replace other = return other
stripPositioned :: Binder -> Binder
@@ -326,8 +327,8 @@ desugarCases :: forall m. (MonadSupply m, MonadError MultipleErrors m) => [Decla
desugarCases = desugarRest <=< fmap join . flip parU toDecls . groupBy inSameGroup
where
desugarRest :: [Declaration] -> m [Declaration]
- desugarRest (TypeInstanceDeclaration sa cd idx name constraints className tys ds : rest) =
- (:) <$> (TypeInstanceDeclaration sa cd idx name constraints className tys <$> traverseTypeInstanceBody desugarCases ds) <*> desugarRest rest
+ desugarRest (TypeInstanceDeclaration sa na cd idx name constraints className tys ds : rest) =
+ (:) <$> (TypeInstanceDeclaration sa na cd idx name constraints className tys <$> traverseTypeInstanceBody desugarCases ds) <*> desugarRest rest
desugarRest (ValueDecl sa name nameKind bs result : rest) =
let (_, f, _) = everywhereOnValuesTopDownM return go return
f' = mapM (\(GuardedExpr gs e) -> GuardedExpr gs <$> f e)
@@ -379,10 +380,10 @@ makeCaseDeclaration ss ident alternatives = do
argNames = foldl1 resolveNames namedArgs
args <- if allUnique (catMaybes argNames)
then mapM argName argNames
- else replicateM (length argNames) freshIdent'
- let vars = map (Var ss . Qualified Nothing) args
+ else replicateM (length argNames) ((nullSourceSpan, ) <$> freshIdent')
+ let vars = map (Var ss . Qualified ByNullSourcePos . snd) args
binders = [ CaseAlternative bs result | (bs, result) <- alternatives ]
- let value = foldr (Abs . VarBinder ss) (Case vars binders) args
+ let value = foldr (Abs . uncurry VarBinder) (Case vars binders) args
return $ ValueDecl (ss, []) ident Public [] [MkUnguarded value]
where
@@ -390,8 +391,8 @@ makeCaseDeclaration ss ident alternatives = do
-- VarBinders will become Just _ which is a potential name.
-- Everything else becomes Nothing, which indicates that we
-- have to generate a name.
- findName :: Binder -> Maybe Ident
- findName (VarBinder _ name) = Just name
+ findName :: Binder -> Maybe (SourceSpan, Ident)
+ findName (VarBinder ss' name) = Just (ss', name)
findName (PositionedBinder _ _ binder) = findName binder
findName _ = Nothing
@@ -400,18 +401,18 @@ makeCaseDeclaration ss ident alternatives = do
allUnique :: (Ord a) => [a] -> Bool
allUnique xs = length xs == length (ordNub xs)
- argName :: Maybe Ident -> m Ident
- argName (Just name) = return name
- argName _ = freshIdent'
+ argName :: Maybe (SourceSpan, Ident) -> m (SourceSpan, Ident)
+ argName (Just (ss', name)) = return (ss', name)
+ argName _ = (nullSourceSpan, ) <$> freshIdent'
-- Combine two lists of potential names from two case alternatives
- -- by zipping correspoding columns.
- resolveNames :: [Maybe Ident] -> [Maybe Ident] -> [Maybe Ident]
+ -- by zipping corresponding columns.
+ resolveNames :: [Maybe (SourceSpan, Ident)] -> [Maybe (SourceSpan, Ident)] -> [Maybe (SourceSpan, Ident)]
resolveNames = zipWith resolveName
-- Resolve a pair of names. VarBinder beats NullBinder, and everything
-- else results in Nothing.
- resolveName :: Maybe Ident -> Maybe Ident -> Maybe Ident
+ resolveName :: Maybe (SourceSpan, Ident) -> Maybe (SourceSpan, Ident) -> Maybe (SourceSpan, Ident)
resolveName (Just a) (Just b)
| a == b = Just a
| otherwise = Nothing
diff --git a/src/Language/PureScript/Sugar/DoNotation.hs b/src/Language/PureScript/Sugar/DoNotation.hs
index 003580c15d..8542a5a790 100644
--- a/src/Language/PureScript/Sugar/DoNotation.hs
+++ b/src/Language/PureScript/Sugar/DoNotation.hs
@@ -1,20 +1,20 @@
-- | This module implements the desugaring pass which replaces do-notation statements with
-- appropriate calls to bind.
-{-# LANGUAGE PatternGuards #-}
-
module Language.PureScript.Sugar.DoNotation (desugarDoModule) where
-import Prelude.Compat
+import Prelude
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.Supply.Class
-import Data.Monoid (First(..))
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Errors
-import Language.PureScript.Names
-import qualified Language.PureScript.Constants as C
+import Control.Applicative ((<|>))
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.Supply.Class (MonadSupply)
+import Data.Maybe (fromMaybe)
+import Data.Monoid (First(..))
+import Language.PureScript.AST (Binder(..), CaseAlternative(..), Declaration, DoNotationElement(..), Expr(..), pattern MkUnguarded, Module(..), SourceSpan, pattern ValueDecl, WhereProvenance(..), binderNames, declSourceSpan, everywhereOnValuesM)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), errorMessage, errorMessage', parU, rethrowWithPosition)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName, Qualified(..), byMaybeModuleName, freshIdent')
+import Language.PureScript.Constants.Libs qualified as C
-- | Replace all @DoNotationBind@ and @DoNotationValue@ constructors with
-- applications of the bind function in scope, and all @DoNotationLet@
@@ -30,16 +30,23 @@ desugarDo d =
in rethrowWithPosition ss $ f d
where
bind :: SourceSpan -> Maybe ModuleName -> Expr
- bind ss m = Var ss (Qualified m (Ident C.bind))
+ bind ss m = Var ss (Qualified (byMaybeModuleName m) (Ident C.S_bind))
discard :: SourceSpan -> Maybe ModuleName -> Expr
- discard ss m = Var ss (Qualified m (Ident C.discard))
+ discard ss m = Var ss (Qualified (byMaybeModuleName m) (Ident C.S_discard))
replace :: SourceSpan -> Expr -> m Expr
replace pos (Do m els) = go pos m els
replace _ (PositionedValue pos com v) = PositionedValue pos com <$> rethrowWithPosition pos (replace pos v)
replace _ other = return other
+ stripPositionedBinder :: Binder -> (Maybe SourceSpan, Binder)
+ stripPositionedBinder (PositionedBinder ss _ b) =
+ let (ss', b') = stripPositionedBinder b
+ in (ss' <|> Just ss, b')
+ stripPositionedBinder b =
+ (Nothing, b)
+
go :: SourceSpan -> Maybe ModuleName -> [DoNotationElement] -> m Expr
go _ _ [] = internalError "The impossible happened in desugarDo"
go _ _ [DoNotationValue val] = return val
@@ -50,20 +57,25 @@ desugarDo d =
go _ _ (DoNotationBind b _ : _) | First (Just ident) <- foldMap fromIdent (binderNames b) =
throwError . errorMessage $ CannotUseBindWithDo (Ident ident)
where
- fromIdent (Ident i) | i `elem` [ C.bind, C.discard ] = First (Just i)
+ fromIdent (Ident i) | i `elem` [ C.S_bind, C.S_discard ] = First (Just i)
fromIdent _ = mempty
- go pos m (DoNotationBind (VarBinder ss ident) val : rest) = do
- rest' <- go pos m rest
- return $ App (App (bind pos m) val) (Abs (VarBinder ss ident) rest')
go pos m (DoNotationBind binder val : rest) = do
rest' <- go pos m rest
- ident <- freshIdent'
- return $ App (App (bind pos m) val) (Abs (VarBinder pos ident) (Case [Var pos (Qualified Nothing ident)] [CaseAlternative [binder] [MkUnguarded rest']]))
+ let (mss, binder') = stripPositionedBinder binder
+ let ss = fromMaybe pos mss
+ case binder' of
+ NullBinder ->
+ return $ App (App (bind pos m) val) (Abs (VarBinder ss UnusedIdent) rest')
+ VarBinder _ ident ->
+ return $ App (App (bind pos m) val) (Abs (VarBinder ss ident) rest')
+ _ -> do
+ ident <- freshIdent'
+ return $ App (App (bind pos m) val) (Abs (VarBinder pos ident) (Case [Var pos (Qualified ByNullSourcePos ident)] [CaseAlternative [binder] [MkUnguarded rest']]))
go _ _ [DoNotationLet _] = throwError . errorMessage $ InvalidDoLet
go pos m (DoNotationLet ds : rest) = do
let checkBind :: Declaration -> m ()
checkBind (ValueDecl (ss, _) i@(Ident name) _ _ _)
- | name `elem` [ C.bind, C.discard ] = throwError . errorMessage' ss $ CannotUseBindWithDo i
+ | name `elem` [ C.S_bind, C.S_discard ] = throwError . errorMessage' ss $ CannotUseBindWithDo i
checkBind _ = pure ()
mapM_ checkBind ds
rest' <- go pos m rest
diff --git a/src/Language/PureScript/Sugar/LetPattern.hs b/src/Language/PureScript/Sugar/LetPattern.hs
index 58944c67f0..519487d912 100644
--- a/src/Language/PureScript/Sugar/LetPattern.hs
+++ b/src/Language/PureScript/Sugar/LetPattern.hs
@@ -4,13 +4,13 @@
--
module Language.PureScript.Sugar.LetPattern (desugarLetPatternModule) where
-import Prelude.Compat
+import Prelude
-import Data.List (groupBy, concatMap)
+import Data.List (groupBy)
import Data.Function (on)
-import Language.PureScript.AST
-import Language.PureScript.Crash
+import Language.PureScript.AST (Binder, CaseAlternative(..), Declaration(..), Expr(..), pattern MkUnguarded, Module(..), SourceAnn, WhereProvenance, everywhereOnValues)
+import Language.PureScript.Crash (internalError)
-- | Replace every @BoundValueDeclaration@ in @Let@ expressions with @Case@
-- expressions.
@@ -28,11 +28,11 @@ desugarLetPattern decl =
replace other = other
go :: WhereProvenance
- -- ^ Metadata about whether the let-in was a where clause
+ -- Metadata about whether the let-in was a where clause
-> [Either [Declaration] (SourceAnn, Binder, Expr)]
- -- ^ Declarations to desugar
+ -- Declarations to desugar
-> Expr
- -- ^ The original let-in result expression
+ -- The original let-in result expression
-> Expr
go _ [] e = e
go w (Right ((pos, com), binder, boundE) : ds) e =
diff --git a/src/Language/PureScript/Sugar/Names.hs b/src/Language/PureScript/Sugar/Names.hs
index 063979a8d7..d081764d7f 100644
--- a/src/Language/PureScript/Sugar/Names.hs
+++ b/src/Language/PureScript/Sugar/Names.hs
@@ -1,7 +1,7 @@
module Language.PureScript.Sugar.Names
( desugarImports
- , desugarImportsWithEnv
, Env
+ , externsEnv
, primEnv
, ImportRecord(..)
, ImportProvenance(..)
@@ -9,122 +9,108 @@ module Language.PureScript.Sugar.Names
, Exports(..)
) where
-import Prelude.Compat
-import Protolude (ordNub, sortBy, on)
+import Prelude
+import Protolude (sortOn, swap, foldl')
-import Control.Arrow (first)
-import Control.Monad
+import Control.Arrow (first, second, (&&&))
+import Control.Monad (foldM, when, (>=>))
import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.State.Lazy
-import Control.Monad.Writer (MonadWriter(..), censor)
+import Control.Monad.State.Lazy (MonadState, StateT(..), gets, modify)
+import Control.Monad.Writer (MonadWriter(..))
+import Data.List.NonEmpty qualified as NEL
import Data.Maybe (fromMaybe, mapMaybe)
-import qualified Data.Map as M
-import qualified Data.Set as S
+import Data.Map qualified as M
+import Data.Set qualified as S
import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Errors
-import Language.PureScript.Externs
-import Language.PureScript.Kinds
-import Language.PureScript.Linter.Imports
-import Language.PureScript.Names
-import Language.PureScript.Sugar.Names.Env
-import Language.PureScript.Sugar.Names.Exports
-import Language.PureScript.Sugar.Names.Imports
-import Language.PureScript.Traversals
-import Language.PureScript.Types
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, errorMessage, errorMessage'', nonEmpty, parU, warnAndRethrow, warnAndRethrowWithPosition)
+import Language.PureScript.Externs (ExternsDeclaration(..), ExternsFile(..), ExternsImport(..))
+import Language.PureScript.Linter.Imports (Name(..), UsedImports)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident, OpName, OpNameType(..), ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..))
+import Language.PureScript.Sugar.Names.Env (Env, Exports(..), ImportProvenance(..), ImportRecord(..), Imports(..), checkImportConflicts, nullImports, primEnv)
+import Language.PureScript.Sugar.Names.Exports (findExportable, resolveExports)
+import Language.PureScript.Sugar.Names.Imports (resolveImports, resolveModuleImport)
+import Language.PureScript.Traversals (defS, sndM)
+import Language.PureScript.Types (Constraint(..), SourceConstraint, SourceType, Type(..), everywhereOnTypesM)
-- |
--- Replaces all local names with qualified names within a list of modules. The
--- modules should be topologically sorted beforehand.
+-- Replaces all local names with qualified names.
--
desugarImports
:: forall m
- . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
- => [ExternsFile]
- -> [Module]
- -> m [Module]
-desugarImports externs modules =
- fmap snd (desugarImportsWithEnv externs modules)
+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadState (Env, UsedImports) m)
+ => Module
+ -> m Module
+desugarImports = updateEnv >=> renameInModule'
+ where
+ updateEnv :: Module -> m Module
+ updateEnv m@(Module ss _ mn _ refs) = do
+ members <- findExportable m
+ env' <- gets $ M.insert mn (ss, nullImports, members) . fst
+ (m', imps) <- resolveImports env' m
+ exps <- maybe (return members) (resolveExports env' ss mn imps members) refs
+ modify . first $ M.insert mn (ss, imps, exps)
+ return m'
-desugarImportsWithEnv
+ renameInModule' :: Module -> m Module
+ renameInModule' m@(Module _ _ mn _ _) =
+ warnAndRethrow (addHint (ErrorInModule mn)) $ do
+ env <- gets fst
+ let (_, imps, exps) = fromMaybe (internalError "Module is missing in renameInModule'") $ M.lookup mn env
+ (m', used) <- flip runStateT M.empty $ renameInModule imps m
+ modify . second $ M.unionWith (<>) used
+ return $ elaborateExports exps m'
+
+-- | Create an environment from a collection of externs files
+externsEnv
:: forall m
- . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
- => [ExternsFile]
- -> [Module]
- -> m (Env, [Module])
-desugarImportsWithEnv externs modules = do
- env <- silence $ foldM externsEnv primEnv externs
- (modules', env') <- first reverse <$> foldM updateEnv ([], env) modules
- (env',) <$> traverse (renameInModule' env') modules'
+ . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
+ => Env
+ -> ExternsFile
+ -> m Env
+externsEnv env ExternsFile{..} = do
+ let members = Exports{..}
+ env' = M.insert efModuleName (efSourceSpan, nullImports, members) env
+ fromEFImport (ExternsImport mn mt qmn) = (mn, [(efSourceSpan, Just mt, qmn)])
+ imps <- foldM (resolveModuleImport env') nullImports (map fromEFImport efImports)
+ exps <- resolveExports env' efSourceSpan efModuleName imps members efExports
+ return $ M.insert efModuleName (efSourceSpan, imps, exps) env
where
- silence :: m a -> m a
- silence = censor (const mempty)
-
- -- | Create an environment from a collection of externs files
- externsEnv :: Env -> ExternsFile -> m Env
- externsEnv env ExternsFile{..} = do
- let members = Exports{..}
- env' = M.insert efModuleName (efSourceSpan, nullImports, members) env
- fromEFImport (ExternsImport mn mt qmn) = (mn, [(efSourceSpan, Just mt, qmn)])
- imps <- foldM (resolveModuleImport env') nullImports (map fromEFImport efImports)
- exps <- resolveExports env' efSourceSpan efModuleName imps members efExports
- return $ M.insert efModuleName (efSourceSpan, imps, exps) env
- where
- -- An ExportSource for declarations local to the module which the given
- -- ExternsFile corresponds to.
- localExportSource =
- ExportSource { exportSourceDefinedIn = efModuleName
- , exportSourceImportedFrom = Nothing
- }
+ -- An ExportSource for declarations local to the module which the given
+ -- ExternsFile corresponds to.
+ localExportSource =
+ ExportSource { exportSourceDefinedIn = efModuleName
+ , exportSourceImportedFrom = Nothing
+ }
- exportedTypes :: M.Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ExportSource)
- exportedTypes = M.fromList $ mapMaybe toExportedType efExports
+ exportedTypes :: M.Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ExportSource)
+ exportedTypes = M.fromList $ mapMaybe toExportedType efExports
+ where
+ toExportedType (TypeRef _ tyCon dctors) = Just (tyCon, (fromMaybe (mapMaybe forTyCon efDeclarations) dctors, localExportSource))
where
- toExportedType (TypeRef _ tyCon dctors) = Just (tyCon, (fromMaybe (mapMaybe forTyCon efDeclarations) dctors, localExportSource))
- where
- forTyCon :: ExternsDeclaration -> Maybe (ProperName 'ConstructorName)
- forTyCon (EDDataConstructor pn _ tNm _ _) | tNm == tyCon = Just pn
- forTyCon _ = Nothing
- toExportedType _ = Nothing
-
- exportedTypeOps :: M.Map (OpName 'TypeOpName) ExportSource
- exportedTypeOps = exportedRefs getTypeOpRef
+ forTyCon :: ExternsDeclaration -> Maybe (ProperName 'ConstructorName)
+ forTyCon (EDDataConstructor pn _ tNm _ _) | tNm == tyCon = Just pn
+ forTyCon _ = Nothing
+ toExportedType _ = Nothing
- exportedTypeClasses :: M.Map (ProperName 'ClassName) ExportSource
- exportedTypeClasses = exportedRefs getTypeClassRef
+ exportedTypeOps :: M.Map (OpName 'TypeOpName) ExportSource
+ exportedTypeOps = exportedRefs getTypeOpRef
- exportedValues :: M.Map Ident ExportSource
- exportedValues = exportedRefs getValueRef
+ exportedTypeClasses :: M.Map (ProperName 'ClassName) ExportSource
+ exportedTypeClasses = exportedRefs getTypeClassRef
- exportedValueOps :: M.Map (OpName 'ValueOpName) ExportSource
- exportedValueOps = exportedRefs getValueOpRef
+ exportedValues :: M.Map Ident ExportSource
+ exportedValues = exportedRefs getValueRef
- exportedKinds :: M.Map (ProperName 'KindName) ExportSource
- exportedKinds = exportedRefs getKindRef
+ exportedValueOps :: M.Map (OpName 'ValueOpName) ExportSource
+ exportedValueOps = exportedRefs getValueOpRef
- exportedRefs :: Ord a => (DeclarationRef -> Maybe a) -> M.Map a ExportSource
- exportedRefs f =
- M.fromList $ (, localExportSource) <$> mapMaybe f efExports
-
- updateEnv :: ([Module], Env) -> Module -> m ([Module], Env)
- updateEnv (ms, env) m@(Module ss _ mn _ refs) = do
- members <- findExportable m
- let env' = M.insert mn (ss, nullImports, members) env
- (m', imps) <- resolveImports env' m
- exps <- maybe (return members) (resolveExports env' ss mn imps members) refs
- return (m' : ms, M.insert mn (ss, imps, exps) env)
-
- renameInModule' :: Env -> Module -> m Module
- renameInModule' env m@(Module _ _ mn _ _) =
- warnAndRethrow (addHint (ErrorInModule mn)) $ do
- let (_, imps, exps) = fromMaybe (internalError "Module is missing in renameInModule'") $ M.lookup mn env
- (m', used) <- flip runStateT M.empty $ renameInModule imps m
- let m'' = elaborateExports exps m'
- lintImports m'' env used
- return m''
+ exportedRefs :: Ord a => (DeclarationRef -> Maybe a) -> M.Map a ExportSource
+ exportedRefs f =
+ M.fromList $ (, localExportSource) <$> mapMaybe f efExports
-- |
-- Make all exports for a module explicit. This may still affect modules that
@@ -143,7 +129,6 @@ elaborateExports exps (Module ss coms mn decls refs) =
++ go (TypeClassRef ss) exportedTypeClasses
++ go (ValueRef ss) exportedValues
++ go (ValueOpRef ss) exportedValueOps
- ++ go (KindRef ss) exportedKinds
++ maybe [] (filter isModuleRef) refs
where
@@ -165,7 +150,7 @@ elaborateExports exps (Module ss coms mn decls refs) =
-- their order in the source file.
reorderExports :: [Declaration] -> Maybe [DeclarationRef] -> [DeclarationRef] -> [DeclarationRef]
reorderExports decls originalRefs =
- sortBy (compare `on` originalIndex)
+ sortOn originalIndex
where
names =
maybe (mapMaybe declName decls) (map declRefName) originalRefs
@@ -188,55 +173,60 @@ renameInModule imports (Module modSS coms mn decls exps) =
Module modSS coms mn <$> parU decls go <*> pure exps
where
- (go, _, _, _, _) =
+ (go, _, _, _, _, _) =
everywhereWithContextOnValuesM
- (modSS, [])
+ (modSS, M.empty)
(\(_, bound) d -> (\(bound', d') -> ((declSourceSpan d', bound'), d')) <$> updateDecl bound d)
updateValue
updateBinder
updateCase
defS
+ updateGuard
updateDecl
- :: [Ident]
+ :: M.Map Ident SourcePos
-> Declaration
- -> m ([Ident], Declaration)
+ -> m (M.Map Ident SourcePos, Declaration)
updateDecl bound (DataDeclaration sa dtype name args dctors) =
fmap (bound,) $
DataDeclaration sa dtype name
<$> updateTypeArguments args
- <*> traverse (sndM (traverse (sndM updateTypesEverywhere))) dctors
+ <*> traverse (traverseDataCtorFields (traverse (sndM updateTypesEverywhere))) dctors
updateDecl bound (TypeSynonymDeclaration sa name ps ty) =
fmap (bound,) $
TypeSynonymDeclaration sa name
<$> updateTypeArguments ps
<*> updateTypesEverywhere ty
- updateDecl bound (TypeClassDeclaration sa@(ss, _) className args implies deps ds) =
+ updateDecl bound (TypeClassDeclaration sa className args implies deps ds) =
fmap (bound,) $
TypeClassDeclaration sa className
<$> updateTypeArguments args
- <*> updateConstraints ss implies
+ <*> updateConstraints implies
<*> pure deps
<*> pure ds
- updateDecl bound (TypeInstanceDeclaration sa@(ss, _) ch idx name cs cn ts ds) =
+ updateDecl bound (TypeInstanceDeclaration sa na@(ss, _) ch idx name cs cn ts ds) =
fmap (bound,) $
- TypeInstanceDeclaration sa ch idx name
- <$> updateConstraints ss cs
+ TypeInstanceDeclaration sa na ch idx name
+ <$> updateConstraints cs
<*> updateClassName cn ss
<*> traverse updateTypesEverywhere ts
<*> pure ds
+ updateDecl bound (KindDeclaration sa kindFor name ty) =
+ fmap (bound,) $
+ KindDeclaration sa kindFor name
+ <$> updateTypesEverywhere ty
updateDecl bound (TypeDeclaration (TypeDeclarationData sa name ty)) =
fmap (bound,) $
TypeDeclaration . TypeDeclarationData sa name
<$> updateTypesEverywhere ty
updateDecl bound (ExternDeclaration sa name ty) =
- fmap (name : bound,) $
+ fmap (M.insert name (spanStart $ fst sa) bound,) $
ExternDeclaration sa name
<$> updateTypesEverywhere ty
updateDecl bound (ExternDataDeclaration sa name ki) =
fmap (bound,) $
ExternDataDeclaration sa name
- <$> updateKindsEverywhere ki
+ <$> updateTypesEverywhere ki
updateDecl bound (TypeFixityDeclaration sa@(ss, _) fixity alias op) =
fmap (bound,) $
TypeFixityDeclaration sa fixity
@@ -256,40 +246,63 @@ renameInModule imports (Module modSS coms mn decls exps) =
return (b, d)
updateValue
- :: (SourceSpan, [Ident])
+ :: (SourceSpan, M.Map Ident SourcePos)
-> Expr
- -> m ((SourceSpan, [Ident]), Expr)
+ -> m ((SourceSpan, M.Map Ident SourcePos), Expr)
updateValue (_, bound) v@(PositionedValue pos' _ _) =
return ((pos', bound), v)
updateValue (pos, bound) (Abs (VarBinder ss arg) val') =
- return ((pos, arg : bound), Abs (VarBinder ss arg) val')
+ return ((pos, M.insert arg (spanStart ss) bound), Abs (VarBinder ss arg) val')
updateValue (pos, bound) (Let w ds val') = do
- let args = mapMaybe letBoundVariable ds
- unless (length (ordNub args) == length args) .
- throwError . errorMessage' pos $ OverlappingNamesInLet
- return ((pos, args ++ bound), Let w ds val')
- updateValue (_, bound) (Var ss name'@(Qualified Nothing ident)) | ident `notElem` bound =
- (,) (ss, bound) <$> (Var ss <$> updateValueName name' ss)
- updateValue (_, bound) (Var ss name'@(Qualified (Just _) _)) =
- (,) (ss, bound) <$> (Var ss <$> updateValueName name' ss)
+ let
+ args = mapMaybe letBoundVariable ds
+ groupByFst = map (\ts -> (fst (NEL.head ts), snd <$> ts)) . NEL.groupAllWith fst
+ duplicateArgsErrs = foldMap mkArgError $ groupByFst args
+ mkArgError (ident, poses)
+ | NEL.length poses < 2 = mempty
+ | otherwise = errorMessage'' (NEL.reverse poses) (OverlappingNamesInLet ident)
+ when (nonEmpty duplicateArgsErrs) $
+ throwError duplicateArgsErrs
+ return ((pos, declarationsToMap ds `M.union` bound), Let w ds val')
+ updateValue (_, bound) (Var ss name'@(Qualified qualifiedBy ident)) =
+ ((ss, bound), ) <$> case (M.lookup ident bound, qualifiedBy) of
+ -- bound idents that have yet to be locally qualified.
+ (Just sourcePos, ByNullSourcePos) ->
+ pure $ Var ss (Qualified (BySourcePos sourcePos) ident)
+ -- unbound idents are likely import unqualified imports, so we
+ -- handle them through updateValueName if they don't exist as a
+ -- local binding.
+ (Nothing, ByNullSourcePos) ->
+ Var ss <$> updateValueName name' ss
+ -- bound/unbound idents with explicit qualification is still
+ -- handled through updateValueName, as it fully resolves the
+ -- ModuleName.
+ (_, ByModuleName _) ->
+ Var ss <$> updateValueName name' ss
+ -- encountering non-null source spans may be a bug in previous
+ -- desugaring steps or with the AST traversals.
+ (_, BySourcePos _) ->
+ internalError "updateValue: ident is locally-qualified by a non-null source position"
updateValue (_, bound) (Op ss op) =
- (,) (ss, bound) <$> (Op ss <$> updateValueOpName op ss)
+ ((ss, bound), ) <$> (Op ss <$> updateValueOpName op ss)
updateValue (_, bound) (Constructor ss name) =
- (,) (ss, bound) <$> (Constructor ss <$> updateDataConstructorName name ss)
+ ((ss, bound), ) <$> (Constructor ss <$> updateDataConstructorName name ss)
updateValue s (TypedValue check val ty) =
- (,) s <$> (TypedValue check val <$> updateTypesEverywhere ty)
+ (s, ) <$> (TypedValue check val <$> updateTypesEverywhere ty)
+ updateValue s (VisibleTypeApp val ty) =
+ (s, ) <$> VisibleTypeApp val <$> updateTypesEverywhere ty
updateValue s v = return (s, v)
updateBinder
- :: (SourceSpan, [Ident])
+ :: (SourceSpan, M.Map Ident SourcePos)
-> Binder
- -> m ((SourceSpan, [Ident]), Binder)
+ -> m ((SourceSpan, M.Map Ident SourcePos), Binder)
updateBinder (_, bound) v@(PositionedBinder pos _ _) =
return ((pos, bound), v)
updateBinder (_, bound) (ConstructorBinder ss name b) =
- (,) (ss, bound) <$> (ConstructorBinder ss <$> updateDataConstructorName name ss <*> pure b)
+ ((ss, bound), ) <$> (ConstructorBinder ss <$> updateDataConstructorName name ss <*> pure b)
updateBinder (_, bound) (OpBinder ss op) =
- (,) (ss, bound) <$> (OpBinder ss <$> updateValueOpName op ss)
+ ((ss, bound), ) <$> (OpBinder ss <$> updateValueOpName op ss)
updateBinder s (TypedBinder t b) = do
t' <- updateTypesEverywhere t
return (s, TypedBinder t' b)
@@ -297,34 +310,44 @@ renameInModule imports (Module modSS coms mn decls exps) =
return (s, v)
updateCase
- :: (SourceSpan, [Ident])
+ :: (SourceSpan, M.Map Ident SourcePos)
-> CaseAlternative
- -> m ((SourceSpan, [Ident]), CaseAlternative)
- updateCase (pos, bound) c@(CaseAlternative bs gs) =
- return ((pos, concatMap binderNames bs ++ updateGuard gs ++ bound), c)
+ -> m ((SourceSpan, M.Map Ident SourcePos), CaseAlternative)
+ updateCase (pos, bound) c@(CaseAlternative bs _) =
+ return ((pos, rUnionMap binderNamesWithSpans' bs `M.union` bound), c)
where
- updateGuard :: [GuardedExpr] -> [Ident]
- updateGuard [] = []
- updateGuard (GuardedExpr g _ : xs) =
- concatMap updatePatGuard g ++ updateGuard xs
- where
- updatePatGuard (PatternGuard b _) = binderNames b
- updatePatGuard _ = []
-
- letBoundVariable :: Declaration -> Maybe Ident
- letBoundVariable = fmap valdeclIdent . getValueDeclaration
-
- updateKindsEverywhere :: SourceKind -> m SourceKind
- updateKindsEverywhere = everywhereOnKindsM updateKind
+ rUnionMap f = foldl' (flip (M.union . f)) M.empty
+
+ updateGuard
+ :: (SourceSpan, M.Map Ident SourcePos)
+ -> Guard
+ -> m ((SourceSpan, M.Map Ident SourcePos), Guard)
+ updateGuard (pos, bound) g@(ConditionGuard _) =
+ return ((pos, bound), g)
+ updateGuard (pos, bound) g@(PatternGuard b _) =
+ return ((pos, binderNamesWithSpans' b `M.union` bound), g)
+
+ binderNamesWithSpans' :: Binder -> M.Map Ident SourcePos
+ binderNamesWithSpans'
+ = M.fromList
+ . fmap (second spanStart . swap)
+ . binderNamesWithSpans
+
+ letBoundVariable :: Declaration -> Maybe (Ident, SourceSpan)
+ letBoundVariable = fmap (valdeclIdent &&& (fst . valdeclSourceAnn)) . getValueDeclaration
+
+ declarationsToMap :: [Declaration] -> M.Map Ident SourcePos
+ declarationsToMap = foldl goDTM M.empty
where
- updateKind :: SourceKind -> m SourceKind
- updateKind (NamedKind ann@(ss, _) name) = NamedKind ann <$> updateKindName name ss
- updateKind k = return k
+ goDTM a (ValueDeclaration ValueDeclarationData {..}) =
+ M.insert valdeclIdent (spanStart $ fst valdeclSourceAnn) a
+ goDTM a _ =
+ a
updateTypeArguments
:: (Traversable f, Traversable g)
- => f (a, g SourceKind) -> m (f (a, g SourceKind))
- updateTypeArguments = traverse (sndM (traverse updateKindsEverywhere))
+ => f (a, g SourceType) -> m (f (a, g SourceType))
+ updateTypeArguments = traverse (sndM (traverse updateTypesEverywhere))
updateTypesEverywhere :: SourceType -> m SourceType
updateTypesEverywhere = everywhereOnTypesM updateType
@@ -333,19 +356,16 @@ renameInModule imports (Module modSS coms mn decls exps) =
updateType (TypeOp ann@(ss, _) name) = TypeOp ann <$> updateTypeOpName name ss
updateType (TypeConstructor ann@(ss, _) name) = TypeConstructor ann <$> updateTypeName name ss
updateType (ConstrainedType ann c t) = ConstrainedType ann <$> updateInConstraint c <*> pure t
- updateType (ForAll ann v mbK t sco) = case mbK of
- Nothing -> pure $ ForAll ann v Nothing t sco
- Just k -> ForAll ann v <$> fmap pure (updateKindsEverywhere k) <*> pure t <*> pure sco
- updateType (KindedType ann t k) = KindedType ann t <$> updateKindsEverywhere k
updateType t = return t
updateInConstraint :: SourceConstraint -> m SourceConstraint
- updateInConstraint (Constraint ann@(ss, _) name ts info) =
- Constraint ann <$> updateClassName name ss <*> pure ts <*> pure info
+ updateInConstraint (Constraint ann@(ss, _) name ks ts info) =
+ Constraint ann <$> updateClassName name ss <*> pure ks <*> pure ts <*> pure info
- updateConstraints :: SourceSpan -> [SourceConstraint] -> m [SourceConstraint]
- updateConstraints pos = traverse $ \(Constraint ann name ts info) ->
+ updateConstraints :: [SourceConstraint] -> m [SourceConstraint]
+ updateConstraints = traverse $ \(Constraint ann@(pos, _) name ks ts info) ->
Constraint ann
<$> updateClassName name pos
+ <*> traverse updateTypesEverywhere ks
<*> traverse updateTypesEverywhere ts
<*> pure info
@@ -382,14 +402,8 @@ renameInModule imports (Module modSS coms mn decls exps) =
-> m (Qualified (OpName 'ValueOpName))
updateValueOpName = update (importedValueOps imports) ValOpName
- updateKindName
- :: Qualified (ProperName 'KindName)
- -> SourceSpan
- -> m (Qualified (ProperName 'KindName))
- updateKindName = update (importedKinds imports) KiName
-
-- Update names so unqualified references become qualified, and locally
- -- qualified references are replaced with their canoncial qualified names
+ -- qualified references are replaced with their canonical qualified names
-- (e.g. M.Map -> Data.Map.Map).
update
:: (Ord a)
@@ -410,16 +424,16 @@ renameInModule imports (Module modSS coms mn decls exps) =
(mnNew, mnOrig) <- checkImportConflicts pos mn toName options
modify $ \usedImports ->
M.insertWith (++) mnNew [fmap toName qname] usedImports
- return $ Qualified (Just mnOrig) name
+ return $ Qualified (ByModuleName mnOrig) name
-- If the name wasn't found in our imports but was qualified then we need
-- to check whether it's a failed import from a "pseudo" module (created
-- by qualified importing). If that's not the case, then we just need to
-- check it refers to a symbol in another module.
- (Nothing, Just mn'') ->
+ (Nothing, ByModuleName mn'') ->
if mn'' `S.member` importedQualModules imports || mn'' `S.member` importedModules imports
then throwUnknown
- else throwError . errorMessage . UnknownName . Qualified Nothing $ ModName mn''
+ else throwError . errorMessage . UnknownName . Qualified ByNullSourcePos $ ModName mn''
-- If neither of the above cases are true then it's an undefined or
-- unimported symbol.
diff --git a/src/Language/PureScript/Sugar/Names/Common.hs b/src/Language/PureScript/Sugar/Names/Common.hs
index 6a681401e2..572d35eb23 100644
--- a/src/Language/PureScript/Sugar/Names/Common.hs
+++ b/src/Language/PureScript/Sugar/Names/Common.hs
@@ -1,17 +1,17 @@
module Language.PureScript.Sugar.Names.Common (warnDuplicateRefs) where
-import Prelude.Compat
+import Prelude
import Protolude (ordNub)
import Control.Monad.Writer (MonadWriter(..))
import Data.Foldable (for_)
-import Data.List (nub, (\\))
+import Data.List (group, sort, (\\))
import Data.Maybe (mapMaybe)
-import Language.PureScript.AST
-import Language.PureScript.Errors
-import Language.PureScript.Names
+import Language.PureScript.AST (DeclarationRef(..), SourceSpan)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage, errorMessage, warnWithPosition)
+import Language.PureScript.Names (Name(..))
-- |
-- Warns about duplicate values in a list of declaration refs.
@@ -24,7 +24,7 @@ warnDuplicateRefs
-> m ()
warnDuplicateRefs pos toError refs = do
let withoutCtors = deleteCtors `map` refs
- dupeRefs = mapMaybe (refToName pos) $ withoutCtors \\ nub withoutCtors
+ dupeRefs = mapMaybe (refToName pos) $ removeUnique withoutCtors
dupeCtors = concat $ mapMaybe (extractCtors pos) refs
for_ (dupeRefs ++ dupeCtors) $ \(pos', name) ->
@@ -32,6 +32,17 @@ warnDuplicateRefs pos toError refs = do
where
+ -- Removes all unique elements from list
+ -- as well as one of each duplicate.
+ -- Example:
+ -- removeUnique [1,2,2,3,3,3,4] == [2,3,3]
+ -- Note that it may be more correct to keep ALL duplicates,
+ -- but that requires additional changes in how warnings are printed.
+ -- Example of keeping all duplicates (not what this code currently does):
+ -- removeUnique [1,2,2,3,3,3,4] == [2,2,3,3,3]
+ removeUnique :: Ord a => [a] -> [a]
+ removeUnique = concatMap (drop 1) . group . sort
+
-- Deletes the constructor information from TypeRefs so that only the
-- referenced type is used in the duplicate check - constructors are handled
-- separately
@@ -43,7 +54,7 @@ warnDuplicateRefs pos toError refs = do
extractCtors :: SourceSpan -> DeclarationRef -> Maybe [(SourceSpan, Name)]
extractCtors pos' (TypeRef _ _ (Just dctors)) =
let dupes = dctors \\ ordNub dctors
- in if null dupes then Nothing else Just $ ((pos',) . DctorName) <$> dupes
+ in if null dupes then Nothing else Just $ (pos',) . DctorName <$> dupes
extractCtors _ _ = Nothing
-- Converts a DeclarationRef into a name for an error message.
diff --git a/src/Language/PureScript/Sugar/Names/Env.hs b/src/Language/PureScript/Sugar/Names/Env.hs
index bdfa99155d..092b8e2478 100644
--- a/src/Language/PureScript/Sugar/Names/Env.hs
+++ b/src/Language/PureScript/Sugar/Names/Env.hs
@@ -8,8 +8,6 @@ module Language.PureScript.Sugar.Names.Env
, Env
, primEnv
, primExports
- , envModuleSourceSpan
- , envModuleImports
, envModuleExports
, ExportMode(..)
, exportType
@@ -17,30 +15,29 @@ module Language.PureScript.Sugar.Names.Env
, exportTypeClass
, exportValue
, exportValueOp
- , exportKind
- , getExports
, checkImportConflicts
) where
-import Prelude.Compat
+import Prelude
-import Control.Monad
+import Control.Monad (forM_, when, (>=>))
import Control.Monad.Error.Class (MonadError(..))
import Control.Monad.Writer.Class (MonadWriter(..))
import Data.Function (on)
import Data.Foldable (find)
-import Data.List (groupBy, sortBy, delete)
-import Data.Maybe (fromJust, mapMaybe)
-import Safe (headMay)
-import qualified Data.Map as M
-import qualified Data.Set as S
-
-import qualified Language.PureScript.Constants as C
-import Language.PureScript.AST
+import Data.List (groupBy, sortOn, delete)
+import Data.Maybe (mapMaybe)
+import Safe (headMay, headDef)
+import Data.Map qualified as M
+import Data.Set qualified as S
+
+import Language.PureScript.Constants.Prim qualified as C
+import Language.PureScript.AST (ExportSource(..), SourceSpan, internalModuleSourceSpan, nullSourceSpan)
+import Language.PureScript.Crash (internalError)
import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Names
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), errorMessage, errorMessage')
+import Language.PureScript.Names (Ident, ModuleName, Name(..), OpName, OpNameType(..), ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), coerceProperName, disqualify, getQual)
-- |
-- The details for an import: the name of the thing that is being imported
@@ -112,7 +109,7 @@ data Imports = Imports
-- |
-- Local names for kinds within a module mapped to their qualified names
--
- , importedKinds :: ImportMap (ProperName 'KindName)
+ , importedKinds :: ImportMap (ProperName 'TypeName)
} deriving (Show)
nullImports :: Imports
@@ -145,17 +142,13 @@ data Exports = Exports
-- from.
--
, exportedValueOps :: M.Map (OpName 'ValueOpName) ExportSource
- -- |
- -- The exported kinds along with the module they originally came from.
- --
- , exportedKinds :: M.Map (ProperName 'KindName) ExportSource
} deriving (Show)
-- |
-- An empty 'Exports' value.
--
nullExports :: Exports
-nullExports = Exports M.empty M.empty M.empty M.empty M.empty M.empty
+nullExports = Exports M.empty M.empty M.empty M.empty M.empty
-- |
-- The imports and exports for a collection of modules. The 'SourceSpan' is used
@@ -164,18 +157,6 @@ nullExports = Exports M.empty M.empty M.empty M.empty M.empty M.empty
--
type Env = M.Map ModuleName (SourceSpan, Imports, Exports)
--- |
--- Extracts the 'SourceSpan' from an 'Env' value.
---
-envModuleSourceSpan :: (SourceSpan, a, b) -> SourceSpan
-envModuleSourceSpan (ss, _, _) = ss
-
--- |
--- Extracts the 'Imports' from an 'Env' value.
---
-envModuleImports :: (a, Imports, b) -> Imports
-envModuleImports (_, imps, _) = imps
-
-- |
-- Extracts the 'Exports' from an 'Env' value.
--
@@ -186,43 +167,54 @@ envModuleExports (_, _, exps) = exps
-- The exported types from the @Prim@ module
--
primExports :: Exports
-primExports = mkPrimExports primTypes primClasses primKinds
+primExports = mkPrimExports primTypes primClasses
-- |
-- The exported types from the @Prim.Boolean@ module
--
primBooleanExports :: Exports
-primBooleanExports = mkPrimExports primBooleanTypes mempty primBooleanKinds
+primBooleanExports = mkPrimExports primBooleanTypes mempty
+
+-- |
+-- The exported types from the @Prim.Coerce@ module
+--
+primCoerceExports :: Exports
+primCoerceExports = mkPrimExports primCoerceTypes primCoerceClasses
-- |
-- The exported types from the @Prim.Ordering@ module
--
primOrderingExports :: Exports
-primOrderingExports = mkPrimExports primOrderingTypes mempty primOrderingKinds
+primOrderingExports = mkPrimExports primOrderingTypes mempty
-- |
-- The exported types from the @Prim.Row@ module
--
primRowExports :: Exports
-primRowExports = mkPrimExports primRowTypes primRowClasses mempty
+primRowExports = mkPrimExports primRowTypes primRowClasses
-- |
-- The exported types from the @Prim.RowList@ module
--
primRowListExports :: Exports
-primRowListExports = mkPrimExports primRowListTypes primRowListClasses primRowListKinds
+primRowListExports = mkPrimExports primRowListTypes primRowListClasses
-- |
-- The exported types from the @Prim.Symbol@ module
--
primSymbolExports :: Exports
-primSymbolExports = mkPrimExports primSymbolTypes primSymbolClasses mempty
+primSymbolExports = mkPrimExports primSymbolTypes primSymbolClasses
+
+-- |
+-- The exported types from the @Prim.Int@ module
+primIntExports :: Exports
+primIntExports = mkPrimExports primIntTypes primIntClasses
-- |
-- The exported types from the @Prim.TypeError@ module
--
primTypeErrorExports :: Exports
-primTypeErrorExports = mkPrimExports primTypeErrorTypes primTypeErrorClasses primTypeErrorKinds
+primTypeErrorExports = mkPrimExports primTypeErrorTypes primTypeErrorClasses
-- |
-- Create a set of exports for a Prim module.
@@ -230,47 +222,55 @@ primTypeErrorExports = mkPrimExports primTypeErrorTypes primTypeErrorClasses pri
mkPrimExports
:: M.Map (Qualified (ProperName 'TypeName)) a
-> M.Map (Qualified (ProperName 'ClassName)) b
- -> S.Set (Qualified (ProperName 'KindName))
-> Exports
-mkPrimExports ts cs ks =
+mkPrimExports ts cs =
nullExports
{ exportedTypes = M.fromList $ mkTypeEntry `map` M.keys ts
, exportedTypeClasses = M.fromList $ mkClassEntry `map` M.keys cs
- , exportedKinds = M.fromList $ mkKindEntry `map` S.toList ks
}
where
- mkTypeEntry (Qualified mn name) = (name, ([], primExportSource mn))
- mkClassEntry (Qualified mn name) = (name, primExportSource mn)
- mkKindEntry (Qualified mn name) = (name, primExportSource mn)
+ mkTypeEntry (Qualified (ByModuleName mn) name) = (name, ([], primExportSource mn))
+ mkTypeEntry _ = internalError
+ "mkPrimExports.mkTypeEntry: a name is qualified BySourcePos instead of ByModuleName"
+
+ mkClassEntry (Qualified (ByModuleName mn) name) = (name, primExportSource mn)
+ mkClassEntry _ = internalError
+ "mkPrimExports.mkClassEntry: a name is qualified BySourcePos instead of ByModuleName"
primExportSource mn =
ExportSource
{ exportSourceImportedFrom = Nothing
- , exportSourceDefinedIn = fromJust mn
+ , exportSourceDefinedIn = mn
}
-- | Environment which only contains the Prim modules.
primEnv :: Env
primEnv = M.fromList
- [ ( C.Prim
+ [ ( C.M_Prim
, (internalModuleSourceSpan "", nullImports, primExports)
)
- , ( C.PrimBoolean
+ , ( C.M_Prim_Boolean
, (internalModuleSourceSpan "", nullImports, primBooleanExports)
)
- , ( C.PrimOrdering
+ , ( C.M_Prim_Coerce
+ , (internalModuleSourceSpan "", nullImports, primCoerceExports)
+ )
+ , ( C.M_Prim_Ordering
, (internalModuleSourceSpan "", nullImports, primOrderingExports)
)
- , ( C.PrimRow
+ , ( C.M_Prim_Row
, (internalModuleSourceSpan "", nullImports, primRowExports)
)
- , ( C.PrimRowList
+ , ( C.M_Prim_RowList
, (internalModuleSourceSpan "", nullImports, primRowListExports)
)
- , ( C.PrimSymbol
+ , ( C.M_Prim_Symbol
, (internalModuleSourceSpan "", nullImports, primSymbolExports)
)
- , ( C.PrimTypeError
+ , ( C.M_Prim_Int
+ , (internalModuleSourceSpan "", nullImports, primIntExports)
+ )
+ , ( C.M_Prim_TypeError
, (internalModuleSourceSpan "", nullImports, primTypeErrorExports)
)
]
@@ -318,6 +318,9 @@ exportType ss exportMode exps name dctors src = do
throwDeclConflict (DctorName dctor) (TyClassName (coerceProperName dctor))
ReExport -> do
let mn = exportSourceDefinedIn src
+ forM_ (coerceProperName name `M.lookup` exClasses) $ \src' ->
+ let mn' = exportSourceDefinedIn src' in
+ throwExportConflict' ss mn mn' (TyName name) (TyClassName (coerceProperName name))
forM_ (name `M.lookup` exTypes) $ \(_, src') ->
let mn' = exportSourceDefinedIn src' in
when (mn /= mn') $
@@ -397,20 +400,6 @@ exportValueOp ss exps op src = do
valueOps <- addExport ss ValOpName op src (exportedValueOps exps)
return $ exps { exportedValueOps = valueOps }
--- |
--- Safely adds a kind to some exports, returning an error if a conflict occurs.
---
-exportKind
- :: MonadError MultipleErrors m
- => SourceSpan
- -> Exports
- -> ProperName 'KindName
- -> ExportSource
- -> m Exports
-exportKind ss exps name src = do
- kinds <- addExport ss KiName name src (exportedKinds exps)
- return $ exps { exportedKinds = kinds }
-
-- |
-- Adds an entry to a list of exports unless it is already present, in which
-- case an error is returned.
@@ -458,18 +447,23 @@ throwExportConflict
-> Name
-> m a
throwExportConflict ss new existing name =
- throwError . errorMessage' ss $
- ExportConflict (Qualified (Just new) name) (Qualified (Just existing) name)
+ throwExportConflict' ss new existing name name
-- |
--- Gets the exports for a module, or raise an error if the module doesn't exist.
+-- Raises an error for when there are conflicting names in the exports. Allows
+-- different categories of names. E.g. class and type names conflicting.
--
-getExports :: MonadError MultipleErrors m => Env -> ModuleName -> m Exports
-getExports env mn =
- maybe
- (throwError . errorMessage . UnknownName . Qualified Nothing $ ModName mn)
- (return . envModuleExports)
- $ M.lookup mn env
+throwExportConflict'
+ :: MonadError MultipleErrors m
+ => SourceSpan
+ -> ModuleName
+ -> ModuleName
+ -> Name
+ -> Name
+ -> m a
+throwExportConflict' ss new existing newName existingName =
+ throwError . errorMessage' ss $
+ ExportConflict (Qualified (ByModuleName new) newName) (Qualified (ByModuleName existing) existingName)
-- |
-- When reading a value from the imports, check that there are no conflicts in
@@ -485,20 +479,24 @@ checkImportConflicts
-> m (ModuleName, ModuleName)
checkImportConflicts ss currentModule toName xs =
let
- byOrig = sortBy (compare `on` importSourceModule) xs
+ byOrig = sortOn importSourceModule xs
groups = groupBy ((==) `on` importSourceModule) byOrig
nonImplicit = filter ((/= FromImplicit) . importProvenance) xs
- name = toName . disqualify . importName $ head xs
- conflictModules = mapMaybe (getQual . importName . head) groups
+ name = toName . disqualify . importName $
+ headDef (internalError "checkImportConflicts: No imports found") xs
+ conflictModules = mapMaybe (headMay >=> (getQual . importName)) groups
in
if length groups > 1
then case nonImplicit of
- [ImportRecord (Qualified (Just mnNew) _) mnOrig _ _] -> do
+ [ImportRecord (Qualified (ByModuleName mnNew) _) mnOrig _ _] -> do
let warningModule = if mnNew == currentModule then Nothing else Just mnNew
ss' = maybe nullSourceSpan importSourceSpan . headMay . filter ((== FromImplicit) . importProvenance) $ xs
tell . errorMessage' ss' $ ScopeShadowing name warningModule $ delete mnNew conflictModules
return (mnNew, mnOrig)
_ -> throwError . errorMessage' ss $ ScopeConflict name conflictModules
else
- let ImportRecord (Qualified (Just mnNew) _) mnOrig _ _ = head byOrig
- in return (mnNew, mnOrig)
+ case headMay byOrig of
+ Just (ImportRecord (Qualified (ByModuleName mnNew) _) mnOrig _ _) ->
+ return (mnNew, mnOrig)
+ _ ->
+ internalError "checkImportConflicts: ImportRecord should be qualified"
diff --git a/src/Language/PureScript/Sugar/Names/Exports.hs b/src/Language/PureScript/Sugar/Names/Exports.hs
index 7480ecc07f..67b1560a77 100644
--- a/src/Language/PureScript/Sugar/Names/Exports.hs
+++ b/src/Language/PureScript/Sugar/Names/Exports.hs
@@ -3,23 +3,24 @@ module Language.PureScript.Sugar.Names.Exports
, resolveExports
) where
-import Prelude.Compat
+import Prelude
+import Protolude (headDef)
-import Control.Monad
+import Control.Monad (filterM, foldM, liftM2, unless, void, when)
import Control.Monad.Writer.Class (MonadWriter(..))
import Control.Monad.Error.Class (MonadError(..))
import Data.Function (on)
import Data.Foldable (traverse_)
-import Data.List (intersect, groupBy, sortBy)
+import Data.List (intersect, groupBy, sortOn)
import Data.Maybe (fromMaybe, mapMaybe)
-import qualified Data.Map as M
+import Data.Map qualified as M
import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Errors
-import Language.PureScript.Names
-import Language.PureScript.Sugar.Names.Env
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, errorMessage', rethrow, rethrowWithPosition, warnAndRethrow)
+import Language.PureScript.Names (Ident, ModuleName, Name(..), OpName, OpNameType(..), ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), disqualifyFor, isQualifiedWith, isUnqualified)
+import Language.PureScript.Sugar.Names.Env (Env, ExportMode(..), Exports(..), ImportRecord(..), Imports(..), checkImportConflicts, envModuleExports, exportType, exportTypeClass, exportTypeOp, exportValue, exportValueOp, nullExports)
import Language.PureScript.Sugar.Names.Common (warnDuplicateRefs)
-- |
@@ -46,7 +47,7 @@ findExportable (Module _ _ mn ds _) =
go exps'' (TypeDeclaration (TypeDeclarationData (ss', _) name _)) = exportValue ss' exps'' name source
go _ _ = internalError "Invalid declaration in TypeClassDeclaration"
updateExports exps (DataDeclaration (ss, _) _ tn _ dcs) =
- exportType ss Internal exps tn (map fst dcs) source
+ exportType ss Internal exps tn (map dataCtorName dcs) source
updateExports exps (TypeSynonymDeclaration (ss, _) tn _ _) =
exportType ss Internal exps tn [] source
updateExports exps (ExternDataDeclaration (ss, _) tn _) =
@@ -59,8 +60,6 @@ findExportable (Module _ _ mn ds _) =
exportTypeOp ss exps op source
updateExports exps (ExternDeclaration (ss, _) name _) =
exportValue ss exps name source
- updateExports exps (ExternKindDeclaration (ss, _) pn) =
- exportKind ss exps pn source
updateExports exps _ = return exps
-- |
@@ -96,14 +95,12 @@ resolveExports env ss mn imps exps refs =
let classes' = exportedTypeClasses result `M.union` exportedTypeClasses exps
let values' = exportedValues result `M.union` exportedValues exps
let valueOps' = exportedValueOps result `M.union` exportedValueOps exps
- let kinds' = exportedKinds result `M.union` exportedKinds exps
return result
{ exportedTypes = types'
, exportedTypeOps = typeOps'
, exportedTypeClasses = classes'
, exportedValues = values'
, exportedValueOps = valueOps'
- , exportedKinds = kinds'
}
elaborateModuleExports result (ModuleRef ss' name) = do
let isPseudo = isPseudoModule name
@@ -115,13 +112,11 @@ resolveExports env ss mn imps exps refs =
reClasses <- extract ss' isPseudo name TyClassName (importedTypeClasses imps)
reValues <- extract ss' isPseudo name IdentName (importedValues imps)
reValueOps <- extract ss' isPseudo name ValOpName (importedValueOps imps)
- reKinds <- extract ss' isPseudo name KiName (importedKinds imps)
foldM (\exps' ((tctor, dctors), src) -> exportType ss' ReExport exps' tctor dctors src) result (resolveTypeExports reTypes reDctors)
>>= flip (foldM (uncurry . exportTypeOp ss')) (map resolveTypeOp reTypeOps)
>>= flip (foldM (uncurry . exportTypeClass ss' ReExport)) (map resolveClass reClasses)
>>= flip (foldM (uncurry . exportValue ss')) (map resolveValue reValues)
>>= flip (foldM (uncurry . exportValueOp ss')) (map resolveValueOp reValueOps)
- >>= flip (foldM (uncurry . exportKind ss')) (map resolveKind reKinds)
elaborateModuleExports result _ = return result
-- Extracts a list of values for a module based on a lookup table. If the
@@ -133,7 +128,8 @@ resolveExports env ss mn imps exps refs =
-> (a -> Name)
-> M.Map (Qualified a) [ImportRecord a]
-> m [Qualified a]
- extract ss' useQual name toName = fmap (map (importName . head . snd)) . go . M.toList
+ extract ss' useQual name toName =
+ fmap (map (importName . headDef (internalError "Missing value in extract") . snd)) . go . M.toList
where
go = filterM $ \(name', options) -> do
let isMatch = if useQual then isQualifiedWith name name' else any (checkUnqual name') options
@@ -176,7 +172,7 @@ resolveExports env ss mn imps exps refs =
go
:: Qualified (ProperName 'TypeName)
-> ((ProperName 'TypeName, [ProperName 'ConstructorName]), ExportSource)
- go (Qualified (Just mn'') name) =
+ go (Qualified (ByModuleName mn'') name) =
fromMaybe (internalError "Missing value in resolveTypeExports") $ do
exps' <- envModuleExports <$> mn'' `M.lookup` env
(dctors', src) <- name `M.lookup` exportedTypes exps'
@@ -185,7 +181,7 @@ resolveExports env ss mn imps exps refs =
( (name, relevantDctors `intersect` dctors')
, src { exportSourceImportedFrom = Just mn'' }
)
- go (Qualified Nothing _) = internalError "Unqualified value in resolveTypeExports"
+ go (Qualified _ _) = internalError "Unqualified value in resolveTypeExports"
-- Looks up an imported type operator and re-qualifies it with the original
-- module it came from.
@@ -215,22 +211,15 @@ resolveExports env ss mn imps exps refs =
= fromMaybe (internalError "Missing value in resolveValueOp")
$ resolve exportedValueOps op
- -- Looks up an imported kind and re-qualifies it with the original
- -- module it came from.
- resolveKind :: Qualified (ProperName 'KindName) -> (ProperName 'KindName, ExportSource)
- resolveKind kind
- = fromMaybe (internalError "Missing value in resolveKind")
- $ resolve exportedKinds kind
-
resolve
:: Ord a
=> (Exports -> M.Map a ExportSource)
-> Qualified a
-> Maybe (a, ExportSource)
- resolve f (Qualified (Just mn'') a) = do
+ resolve f (Qualified (ByModuleName mn'') a) = do
exps' <- envModuleExports <$> mn'' `M.lookup` env
src <- a `M.lookup` f exps'
- return $ (a, src { exportSourceImportedFrom = Just mn'' })
+ return (a, src { exportSourceImportedFrom = Just mn'' })
resolve _ _ = internalError "Unqualified value in resolve"
-- |
@@ -250,14 +239,12 @@ filterModule mn exps refs = do
classes <- foldM (filterExport TyClassName getTypeClassRef exportedTypeClasses) M.empty refs
values <- foldM (filterExport IdentName getValueRef exportedValues) M.empty refs
valueOps <- foldM (filterExport ValOpName getValueOpRef exportedValueOps) M.empty refs
- kinds <- foldM (filterExport KiName getKindRef exportedKinds) M.empty refs
return Exports
{ exportedTypes = types
, exportedTypeOps = typeOps
, exportedTypeClasses = classes
, exportedValues = values
, exportedValueOps = valueOps
- , exportedKinds = kinds
}
where
@@ -271,7 +258,7 @@ filterModule mn exps refs = do
= fmap (\(ss', (tc, dcs)) -> TypeRef ss' tc dcs)
. fmap (foldr1 $ \(ss, (tc, dcs1)) (_, (_, dcs2)) -> (ss, (tc, liftM2 (++) dcs1 dcs2)))
. groupBy ((==) `on` (fst . snd))
- . sortBy (compare `on` (fst . snd))
+ . sortOn (fst . snd)
. mapMaybe (\ref -> (declRefSourceSpan ref,) <$> getTypeRef ref)
filterTypes
diff --git a/src/Language/PureScript/Sugar/Names/Imports.hs b/src/Language/PureScript/Sugar/Names/Imports.hs
index 4253709055..77c65ba3c5 100644
--- a/src/Language/PureScript/Sugar/Names/Imports.hs
+++ b/src/Language/PureScript/Sugar/Names/Imports.hs
@@ -5,21 +5,21 @@ module Language.PureScript.Sugar.Names.Imports
, findImports
) where
-import Prelude.Compat
+import Prelude
-import Control.Monad
+import Control.Monad (foldM, when, unless)
import Control.Monad.Error.Class (MonadError(..))
import Data.Foldable (for_, traverse_)
import Data.Maybe (fromMaybe)
-import qualified Data.Map as M
-import qualified Data.Set as S
+import Data.Map qualified as M
+import Data.Set qualified as S
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Errors
-import Language.PureScript.Names
-import Language.PureScript.Sugar.Names.Env
+import Language.PureScript.AST (Declaration(..), DeclarationRef(..), ErrorMessageHint(..), ExportSource(..), ImportDeclarationType(..), Module(..), SourceSpan, internalModuleSourceSpan)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, errorMessage', rethrow)
+import Language.PureScript.Names (pattern ByNullSourcePos, ModuleName, Name(..), ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), byMaybeModuleName)
+import Language.PureScript.Sugar.Names.Env (Env, Exports(..), ImportProvenance(..), ImportRecord(..), Imports(..), envModuleExports, nullImports)
type ImportDef = (SourceSpan, ImportDeclarationType, Maybe ModuleName)
@@ -32,10 +32,9 @@ findImports
-> M.Map ModuleName [ImportDef]
findImports = foldr go M.empty
where
- go (ImportDeclaration (pos, _) mn typ qual) result =
- let imp = (pos, typ, qual)
- in M.insert mn (maybe [imp] (imp :) (mn `M.lookup` result)) result
- go _ result = result
+ go (ImportDeclaration (pos, _) mn typ qual) =
+ M.alter (return . ((pos, typ, qual) :) . fromMaybe []) mn
+ go _ = id
-- |
-- Constructs a set of imports for a module.
@@ -70,7 +69,7 @@ resolveModuleImport env ie (mn, imps) = foldM go ie imps
go ie' (ss, typ, impQual) = do
modExports <-
maybe
- (throwError . errorMessage' ss . UnknownName . Qualified Nothing $ ModName mn)
+ (throwError . errorMessage' ss . UnknownName . Qualified ByNullSourcePos $ ModName mn)
(return . envModuleExports)
(mn `M.lookup` env)
let impModules = importedModules ie'
@@ -124,8 +123,6 @@ resolveImport importModule exps imps impQual = resolveByType
checkImportExists ss TyClassName (exportedTypeClasses exps) name
check (ModuleRef ss name) | isHiding =
throwError . errorMessage' ss $ ImportHidingModule name
- check (KindRef ss name) =
- checkImportExists ss KiName (exportedKinds exps) name
check r = internalError $ "Invalid argument to checkRefs: " ++ show r
-- Check that an explicitly imported item exists in the module it is being imported from
@@ -150,7 +147,7 @@ resolveImport importModule exps imps impQual = resolveByType
-> ProperName 'ConstructorName
-> m ()
checkDctorExists ss tcon exports dctor
- = when (dctor `notElem` exports)
+ = unless (dctor `elem` exports)
. throwError . errorMessage' ss
$ UnknownImportDataConstructor importModule tcon dctor
@@ -177,7 +174,6 @@ resolveImport importModule exps imps impQual = resolveByType
>>= flip (foldM (\m (name, _) -> importer m (ValueRef ss name))) (M.toList (exportedValues exps))
>>= flip (foldM (\m (name, _) -> importer m (ValueOpRef ss name))) (M.toList (exportedValueOps exps))
>>= flip (foldM (\m (name, _) -> importer m (TypeClassRef ss name))) (M.toList (exportedTypeClasses exps))
- >>= flip (foldM (\m (name, _) -> importer m (KindRef ss name))) (M.toList (exportedKinds exps))
importRef :: ImportProvenance -> Imports -> DeclarationRef -> m Imports
importRef prov imp (ValueRef ss name) = do
@@ -200,9 +196,6 @@ resolveImport importModule exps imps impQual = resolveByType
importRef prov imp (TypeClassRef ss name) = do
let typeClasses' = updateImports (importedTypeClasses imp) (exportedTypeClasses exps) id name ss prov
return $ imp { importedTypeClasses = typeClasses' }
- importRef prov imp (KindRef ss name) = do
- let kinds' = updateImports (importedKinds imp) (exportedKinds exps) id name ss prov
- return $ imp { importedKinds = kinds' }
importRef _ _ TypeInstanceRef{} = internalError "TypeInstanceRef in importRef"
importRef _ _ ModuleRef{} = internalError "ModuleRef in importRef"
importRef _ _ ReExportRef{} = internalError "ReExportRef in importRef"
@@ -228,9 +221,9 @@ resolveImport importModule exps imps impQual = resolveByType
updateImports imps' exps' expName name ss prov =
let
src = maybe (internalError "Invalid state in updateImports") expName (name `M.lookup` exps')
- rec = ImportRecord (Qualified (Just importModule) name) (exportSourceDefinedIn src) ss prov
+ rec = ImportRecord (Qualified (ByModuleName importModule) name) (exportSourceDefinedIn src) ss prov
in
M.alter
(\currNames -> Just $ rec : fromMaybe [] currNames)
- (Qualified impQual name)
+ (Qualified (byMaybeModuleName impQual) name)
imps'
diff --git a/src/Language/PureScript/Sugar/ObjectWildcards.hs b/src/Language/PureScript/Sugar/ObjectWildcards.hs
index 6c629c0698..88b93b899c 100644
--- a/src/Language/PureScript/Sugar/ObjectWildcards.hs
+++ b/src/Language/PureScript/Sugar/ObjectWildcards.hs
@@ -3,19 +3,19 @@ module Language.PureScript.Sugar.ObjectWildcards
, desugarDecl
) where
-import Prelude.Compat
+import Prelude
-import Control.Monad (forM)
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.Supply.Class
-import Data.Foldable (toList)
-import Data.List (foldl')
-import Data.Maybe (catMaybes)
-import Language.PureScript.AST
-import Language.PureScript.Environment (NameKind(..))
-import Language.PureScript.Errors
-import Language.PureScript.Names
-import Language.PureScript.PSString (PSString)
+import Control.Monad (forM)
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.Supply.Class (MonadSupply)
+import Data.Foldable (toList)
+import Data.List (foldl')
+import Data.Maybe (catMaybes)
+import Language.PureScript.AST
+import Language.PureScript.Environment (NameKind(..))
+import Language.PureScript.Errors (MultipleErrors, rethrowWithPosition)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident, Qualified(..), freshIdent')
+import Language.PureScript.PSString (PSString)
desugarObjectConstructors
@@ -31,16 +31,6 @@ desugarDecl d = rethrowWithPosition (declSourceSpan d) $ fn d
(fn, _, _) = everywhereOnValuesTopDownM return desugarExpr return
desugarExpr :: Expr -> m Expr
- desugarExpr AnonymousArgument = throwError . errorMessage $ IncorrectAnonymousArgument
- desugarExpr (Parens b)
- | b' <- stripPositionInfo b
- , BinaryNoParens op val u <- b'
- , isAnonymousArgument u = do arg <- freshIdent'
- return $ Abs (VarBinder nullSourceSpan arg) $ App (App op val) (Var nullSourceSpan (Qualified Nothing arg))
- | b' <- stripPositionInfo b
- , BinaryNoParens op u val <- b'
- , isAnonymousArgument u = do arg <- freshIdent'
- return $ Abs (VarBinder nullSourceSpan arg) $ App (App op (Var nullSourceSpan (Qualified Nothing arg))) val
desugarExpr (Literal ss (ObjectLiteral ps)) = wrapLambdaAssoc (Literal ss . ObjectLiteral) ps
desugarExpr (ObjectUpdateNested obj ps) = transformNestedUpdate obj ps
desugarExpr (Accessor prop u)
@@ -96,25 +86,16 @@ desugarDecl d = rethrowWithPosition (declSourceSpan d) $ fn d
wrapLambdaAssoc :: ([(PSString, Expr)] -> Expr) -> [(PSString, Expr)] -> m Expr
wrapLambdaAssoc mkVal = wrapLambda (mkVal . runAssocList) . AssocList
- stripPositionInfo :: Expr -> Expr
- stripPositionInfo (PositionedValue _ _ e) = stripPositionInfo e
- stripPositionInfo e = e
-
peelAnonAccessorChain :: Expr -> Maybe [PSString]
peelAnonAccessorChain (Accessor p e) = (p :) <$> peelAnonAccessorChain e
peelAnonAccessorChain (PositionedValue _ _ e) = peelAnonAccessorChain e
peelAnonAccessorChain AnonymousArgument = Just []
peelAnonAccessorChain _ = Nothing
- isAnonymousArgument :: Expr -> Bool
- isAnonymousArgument AnonymousArgument = True
- isAnonymousArgument (PositionedValue _ _ e) = isAnonymousArgument e
- isAnonymousArgument _ = False
-
freshIfAnon :: Expr -> m (Maybe Ident)
freshIfAnon u
| isAnonymousArgument u = Just <$> freshIdent'
| otherwise = return Nothing
argToExpr :: Ident -> Expr
- argToExpr = Var nullSourceSpan . Qualified Nothing
+ argToExpr = Var nullSourceSpan . Qualified ByNullSourcePos
diff --git a/src/Language/PureScript/Sugar/Operators.hs b/src/Language/PureScript/Sugar/Operators.hs
index 20a2e04272..93028d7e22 100644
--- a/src/Language/PureScript/Sugar/Operators.hs
+++ b/src/Language/PureScript/Sugar/Operators.hs
@@ -7,37 +7,40 @@
--
module Language.PureScript.Sugar.Operators
( desugarSignedLiterals
+ , RebracketCaller(..)
, rebracket
, rebracketFiltered
, checkFixityExports
) where
-import Prelude.Compat
+import Prelude
import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Errors
-import Language.PureScript.Externs
-import Language.PureScript.Names
-import Language.PureScript.Sugar.Operators.Binders
-import Language.PureScript.Sugar.Operators.Expr
-import Language.PureScript.Sugar.Operators.Types
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, errorMessage, errorMessage', parU, rethrow, rethrowWithPosition)
+import Language.PureScript.Externs (ExternsFile(..), ExternsFixity(..), ExternsTypeFixity(..))
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), Name(..), OpName, OpNameType(..), ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), freshIdent')
+import Language.PureScript.Sugar.Operators.Binders (matchBinderOperators)
+import Language.PureScript.Sugar.Operators.Expr (matchExprOperators)
+import Language.PureScript.Sugar.Operators.Types (matchTypeOperators)
import Language.PureScript.Traversals (defS, sndM)
-import Language.PureScript.Types
+import Language.PureScript.Types (Constraint(..), SourceType, Type(..), everywhereOnTypesTopDownM, overConstraintArgs)
import Control.Monad (unless, (<=<))
import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.Supply.Class (MonadSupply)
import Data.Either (partitionEithers)
import Data.Foldable (for_, traverse_)
import Data.Function (on)
+import Data.Functor (($>))
import Data.Functor.Identity (Identity(..), runIdentity)
-import Data.List (groupBy, sortBy)
+import Data.List (groupBy, sortOn)
import Data.Maybe (mapMaybe, listToMaybe)
-import Data.Traversable (for)
-import qualified Data.Map as M
+import Data.Map qualified as M
+import Data.Ord (Down(..))
-import qualified Language.PureScript.Constants as C
+import Language.PureScript.Constants.Libs qualified as C
-- |
-- Removes unary negation operators and replaces them with calls to `negate`.
@@ -47,7 +50,7 @@ desugarSignedLiterals (Module ss coms mn ds exts) =
Module ss coms mn (map f' ds) exts
where
(f', _, _) = everywhereOnValues id go id
- go (UnaryMinus ss' val) = App (Var ss' (Qualified Nothing (Ident C.negate))) val
+ go (UnaryMinus ss' val) = App (Var ss' (Qualified ByNullSourcePos (Ident C.S_negate))) val
go other = other
-- |
@@ -66,11 +69,12 @@ type TypeFixityRecord = FixityRecord (OpName 'TypeOpName) (ProperName 'TypeName)
rebracket
:: forall m
. MonadError MultipleErrors m
+ => MonadSupply m
=> [ExternsFile]
- -> [Module]
- -> m [Module]
+ -> Module
+ -> m Module
rebracket =
- rebracketFiltered (const True)
+ rebracketFiltered CalledByCompile (const True)
-- |
-- A version of `rebracket` which allows you to choose which declarations
@@ -82,15 +86,17 @@ rebracket =
rebracketFiltered
:: forall m
. MonadError MultipleErrors m
- => (Declaration -> Bool)
+ => MonadSupply m
+ => RebracketCaller
+ -> (Declaration -> Bool)
-> [ExternsFile]
- -> [Module]
- -> m [Module]
-rebracketFiltered pred_ externs modules = do
+ -> Module
+ -> m Module
+rebracketFiltered !caller pred_ externs m = do
let (valueFixities, typeFixities) =
partitionEithers
$ concatMap externsFixities externs
- ++ concatMap collectFixities modules
+ ++ collectFixities m
ensureNoDuplicates' MultipleValueOpFixities valueFixities
ensureNoDuplicates' MultipleTypeOpFixities typeFixities
@@ -100,9 +106,8 @@ rebracketFiltered pred_ externs modules = do
let typeOpTable = customOperatorTable' typeFixities
let typeAliased = M.fromList (map makeLookupEntry typeFixities)
- for modules
- $ renameAliasedOperators valueAliased typeAliased
- <=< rebracketModule pred_ valueOpTable typeOpTable
+ rebracketModule caller pred_ valueOpTable typeOpTable m >>=
+ renameAliasedOperators valueAliased typeAliased
where
@@ -131,7 +136,7 @@ rebracketFiltered pred_ externs modules = do
Module ss coms mn <$> mapM (usingPredicate pred_ f') ds <*> pure exts
where
(goDecl', goExpr', goBinder') = updateTypes goType
- (f', _, _, _, _) =
+ (f', _, _, _, _, _) =
everywhereWithContextOnValuesM
ss
(\_ d -> (declSourceSpan d,) <$> goDecl' d)
@@ -139,6 +144,7 @@ rebracketFiltered pred_ externs modules = do
(\pos -> uncurry goBinder <=< goBinder' pos)
defS
defS
+ defS
goExpr :: SourceSpan -> Expr -> m (SourceSpan, Expr)
goExpr _ e@(PositionedValue pos _ _) = return (pos, e)
@@ -167,31 +173,60 @@ rebracketFiltered pred_ externs modules = do
goBinder pos other = return (pos, other)
goType :: SourceSpan -> SourceType -> m SourceType
- goType pos (BinaryNoParensType ann (TypeOp ann2 op) lhs rhs) =
+ goType pos (TypeOp ann2 op) =
case op `M.lookup` typeAliased of
Just alias ->
- return $ TypeApp ann (TypeApp ann (TypeConstructor ann2 alias) lhs) rhs
+ return $ TypeConstructor ann2 alias
Nothing ->
throwError . errorMessage' pos $ UnknownName $ fmap TyOpName op
goType _ other = return other
+-- | Indicates whether the `rebracketModule`
+-- is being called with the full desugar pass
+-- run via `purs compile` or whether
+-- only the partial desugar pass is run
+-- via `purs docs`.
+-- This indication is needed to prevent
+-- a `purs docs` error when using
+-- `case _ of` syntax in a type class instance.
+data RebracketCaller
+ = CalledByCompile
+ | CalledByDocs
+ deriving (Eq, Show)
+
rebracketModule
:: forall m
. (MonadError MultipleErrors m)
- => (Declaration -> Bool)
+ => MonadSupply m
+ => RebracketCaller
+ -> (Declaration -> Bool)
-> [[(Qualified (OpName 'ValueOpName), Associativity)]]
-> [[(Qualified (OpName 'TypeOpName), Associativity)]]
-> Module
-> m Module
-rebracketModule pred_ valueOpTable typeOpTable (Module ss coms mn ds exts) =
+rebracketModule !caller pred_ valueOpTable typeOpTable (Module ss coms mn ds exts) =
Module ss coms mn <$> f' ds <*> pure exts
where
f' :: [Declaration] -> m [Declaration]
f' =
fmap (map (\d -> if pred_ d then removeParens d else d)) .
- flip parU (usingPredicate pred_ f)
-
- (f, _, _, _, _) =
+ flip parU (usingPredicate pred_ h)
+
+ -- The AST will run through all the desugar passes when compiling
+ -- and only some of the desugar passes when generating docs.
+ -- When generating docs, `case _ of` syntax used in an instance declaration
+ -- can trigger the `IncorrectAnonymousArgument` error because it does not
+ -- run the same passes that the compile desugaring does. Since `purs docs`
+ -- will only succeed once `purs compile` succeeds, we can ignore this check
+ -- when running `purs docs`.
+ -- See https://github.com/purescript/purescript/issues/4274#issuecomment-1087730651=
+ -- for more info.
+ h :: Declaration -> m Declaration
+ h = case caller of
+ CalledByDocs -> f
+ CalledByCompile -> g <=< f
+
+ (f, _, _, _, _, _) =
everywhereWithContextOnValuesM
ss
(\_ d -> (declSourceSpan d,) <$> goDecl d)
@@ -199,6 +234,9 @@ rebracketModule pred_ valueOpTable typeOpTable (Module ss coms mn ds exts) =
(\pos -> wrap (matchBinderOperators valueOpTable) <=< goBinder' pos)
defS
defS
+ defS
+
+ (g, _, _) = everywhereOnValuesTopDownM pure removeBinaryNoParens pure
(goDecl, goExpr', goBinder') = updateTypes goType
@@ -208,6 +246,24 @@ rebracketModule pred_ valueOpTable typeOpTable (Module ss coms mn ds exts) =
wrap :: (a -> m a) -> (SourceSpan, a) -> m (SourceSpan, a)
wrap go (ss', a) = (ss',) <$> go a
+removeBinaryNoParens :: (MonadError MultipleErrors m, MonadSupply m) => Expr -> m Expr
+removeBinaryNoParens u
+ | isAnonymousArgument u = case u of
+ PositionedValue p _ _ -> rethrowWithPosition p err
+ _ -> err
+ where err = throwError . errorMessage $ IncorrectAnonymousArgument
+removeBinaryNoParens (Parens (stripPositionInfo -> BinaryNoParens op l r))
+ | isAnonymousArgument r = do arg <- freshIdent'
+ return $ Abs (VarBinder nullSourceSpan arg) $ App (App op l) (Var nullSourceSpan (Qualified ByNullSourcePos arg))
+ | isAnonymousArgument l = do arg <- freshIdent'
+ return $ Abs (VarBinder nullSourceSpan arg) $ App (App op (Var nullSourceSpan (Qualified ByNullSourcePos arg))) r
+removeBinaryNoParens (BinaryNoParens op l r) = return $ App (App op l) r
+removeBinaryNoParens e = return e
+
+stripPositionInfo :: Expr -> Expr
+stripPositionInfo (PositionedValue _ _ e) = stripPositionInfo e
+stripPositionInfo e = e
+
removeParens :: Declaration -> Declaration
removeParens = f
where
@@ -247,7 +303,7 @@ externsFixities ExternsFile{..} =
-> Either ValueFixityRecord TypeFixityRecord
fromFixity (ExternsFixity assoc prec op name) =
Left
- ( Qualified (Just efModuleName) op
+ ( Qualified (ByModuleName efModuleName) op
, internalModuleSourceSpan ""
, Fixity assoc prec
, name
@@ -258,7 +314,7 @@ externsFixities ExternsFile{..} =
-> Either ValueFixityRecord TypeFixityRecord
fromTypeFixity (ExternsTypeFixity assoc prec op name) =
Right
- ( Qualified (Just efModuleName) op
+ ( Qualified (ByModuleName efModuleName) op
, internalModuleSourceSpan ""
, Fixity assoc prec
, name
@@ -269,9 +325,9 @@ collectFixities (Module _ _ moduleName ds _) = concatMap collect ds
where
collect :: Declaration -> [Either ValueFixityRecord TypeFixityRecord]
collect (ValueFixityDeclaration (ss, _) fixity name op) =
- [Left (Qualified (Just moduleName) op, ss, fixity, name)]
+ [Left (Qualified (ByModuleName moduleName) op, ss, fixity, name)]
collect (TypeFixityDeclaration (ss, _) fixity name op) =
- [Right (Qualified (Just moduleName) op, ss, fixity, name)]
+ [Right (Qualified (ByModuleName moduleName) op, ss, fixity, name)]
collect _ = []
ensureNoDuplicates
@@ -279,11 +335,11 @@ ensureNoDuplicates
=> (a -> SimpleErrorMessage)
-> [(Qualified a, SourceSpan)]
-> m ()
-ensureNoDuplicates toError m = go $ sortBy (compare `on` fst) m
+ensureNoDuplicates toError m = go $ sortOn fst m
where
go [] = return ()
go [_] = return ()
- go ((x@(Qualified (Just mn) op), _) : (y, pos) : _) | x == y =
+ go ((x@(Qualified (ByModuleName mn) op), _) : (y, pos) : _) | x == y =
rethrow (addHint (ErrorInModule mn)) $
rethrowWithPosition pos $ throwError . errorMessage $ toError op
go (_ : rest) = go rest
@@ -294,7 +350,7 @@ customOperatorTable
customOperatorTable fixities =
let
userOps = map (\(name, Fixity a p) -> (name, p, a)) fixities
- sorted = sortBy (flip compare `on` (\(_, p, _) -> p)) userOps
+ sorted = sortOn (Down . (\(_, p, _) -> p)) userOps
groups = groupBy ((==) `on` (\(_, p, _) -> p)) sorted
in
map (map (\(name, _, a) -> (name, a))) groups
@@ -315,34 +371,47 @@ updateTypes goType = (goDecl, goExpr, goBinder)
goDecl :: Declaration -> m Declaration
goDecl (DataDeclaration sa@(ss, _) ddt name args dctors) =
- DataDeclaration sa ddt name args <$> traverse (sndM (traverse (sndM (goType' ss)))) dctors
+ DataDeclaration sa ddt name
+ <$> traverse (traverse (traverse (goType' ss))) args
+ <*> traverse (traverseDataCtorFields (traverse (sndM (goType' ss)))) dctors
goDecl (ExternDeclaration sa@(ss, _) name ty) =
ExternDeclaration sa name <$> goType' ss ty
goDecl (TypeClassDeclaration sa@(ss, _) name args implies deps decls) = do
implies' <- traverse (overConstraintArgs (traverse (goType' ss))) implies
- return $ TypeClassDeclaration sa name args implies' deps decls
- goDecl (TypeInstanceDeclaration sa@(ss, _) ch idx name cs className tys impls) = do
+ args' <- traverse (traverse (traverse (goType' ss))) args
+ return $ TypeClassDeclaration sa name args' implies' deps decls
+ goDecl (TypeInstanceDeclaration sa@(ss, _) na ch idx name cs className tys impls) = do
cs' <- traverse (overConstraintArgs (traverse (goType' ss))) cs
tys' <- traverse (goType' ss) tys
- return $ TypeInstanceDeclaration sa ch idx name cs' className tys' impls
+ return $ TypeInstanceDeclaration sa na ch idx name cs' className tys' impls
goDecl (TypeSynonymDeclaration sa@(ss, _) name args ty) =
- TypeSynonymDeclaration sa name args <$> goType' ss ty
+ TypeSynonymDeclaration sa name
+ <$> traverse (traverse (traverse (goType' ss))) args
+ <*> goType' ss ty
goDecl (TypeDeclaration (TypeDeclarationData sa@(ss, _) expr ty)) =
TypeDeclaration . TypeDeclarationData sa expr <$> goType' ss ty
+ goDecl (KindDeclaration sa@(ss, _) sigFor name ty) =
+ KindDeclaration sa sigFor name <$> goType' ss ty
+ goDecl (ExternDataDeclaration sa@(ss, _) name ty) =
+ ExternDataDeclaration sa name <$> goType' ss ty
goDecl other =
return other
goExpr :: SourceSpan -> Expr -> m (SourceSpan, Expr)
goExpr _ e@(PositionedValue pos _ _) = return (pos, e)
- goExpr pos (TypeClassDictionary (Constraint ann name tys info) dicts hints) = do
+ goExpr pos (TypeClassDictionary (Constraint ann name kinds tys info) dicts hints) = do
+ kinds' <- traverse (goType' pos) kinds
tys' <- traverse (goType' pos) tys
- return (pos, TypeClassDictionary (Constraint ann name tys' info) dicts hints)
+ return (pos, TypeClassDictionary (Constraint ann name kinds' tys' info) dicts hints)
goExpr pos (DeferredDictionary cls tys) = do
tys' <- traverse (goType' pos) tys
return (pos, DeferredDictionary cls tys')
goExpr pos (TypedValue check v ty) = do
ty' <- goType' pos ty
return (pos, TypedValue check v ty')
+ goExpr pos (VisibleTypeApp v ty) = do
+ ty' <- goType' pos ty
+ return (pos, VisibleTypeApp v ty')
goExpr pos other = return (pos, other)
goBinder :: SourceSpan -> Binder -> m (SourceSpan, Binder)
@@ -368,7 +437,7 @@ checkFixityExports (Module _ _ _ _ Nothing) =
checkFixityExports m@(Module ss _ mn ds (Just exps)) =
rethrow (addHint (ErrorInModule mn))
$ rethrowWithPosition ss (traverse_ checkRef exps)
- *> return m
+ $> m
where
checkRef :: DeclarationRef -> m ()
@@ -381,7 +450,7 @@ checkFixityExports m@(Module ss _ mn ds (Just exps)) =
Right ctor ->
unless (anyTypeRef (maybe False (elem ctor) . snd))
. throwError . errorMessage' ss
- $ TransitiveDctorExportError dr ctor
+ $ TransitiveDctorExportError dr [ctor]
checkRef dr@(TypeOpRef ss' op) =
for_ (getTypeOpAlias op) $ \ty ->
unless (anyTypeRef ((== ty) . fst))
@@ -395,7 +464,7 @@ checkFixityExports m@(Module ss _ mn ds (Just exps)) =
getTypeOpAlias op =
listToMaybe (mapMaybe (either (const Nothing) go <=< getFixityDecl) ds)
where
- go (TypeFixity _ (Qualified (Just mn') ident) op')
+ go (TypeFixity _ (Qualified (ByModuleName mn') ident) op')
| mn == mn' && op == op' = Just ident
go _ = Nothing
@@ -407,7 +476,7 @@ checkFixityExports m@(Module ss _ mn ds (Just exps)) =
getValueOpAlias op =
listToMaybe (mapMaybe (either go (const Nothing) <=< getFixityDecl) ds)
where
- go (ValueFixity _ (Qualified (Just mn') ident) op')
+ go (ValueFixity _ (Qualified (ByModuleName mn') ident) op')
| mn == mn' && op == op' = Just ident
go _ = Nothing
diff --git a/src/Language/PureScript/Sugar/Operators/Binders.hs b/src/Language/PureScript/Sugar/Operators/Binders.hs
index c3f54e7384..29725c711a 100644
--- a/src/Language/PureScript/Sugar/Operators/Binders.hs
+++ b/src/Language/PureScript/Sugar/Operators/Binders.hs
@@ -1,13 +1,13 @@
module Language.PureScript.Sugar.Operators.Binders where
-import Prelude.Compat
+import Prelude
-import Control.Monad.Except
+import Control.Monad.Except (MonadError)
-import Language.PureScript.AST
-import Language.PureScript.Errors
-import Language.PureScript.Names
-import Language.PureScript.Sugar.Operators.Common
+import Language.PureScript.AST (Associativity, Binder(..), SourceSpan)
+import Language.PureScript.Errors (MultipleErrors)
+import Language.PureScript.Names (OpName(..), OpNameType(..), Qualified(..))
+import Language.PureScript.Sugar.Operators.Common (matchOperators)
matchBinderOperators
:: MonadError MultipleErrors m
diff --git a/src/Language/PureScript/Sugar/Operators/Common.hs b/src/Language/PureScript/Sugar/Operators/Common.hs
index 5cf68517da..7fd6df9645 100644
--- a/src/Language/PureScript/Sugar/Operators/Common.hs
+++ b/src/Language/PureScript/Sugar/Operators/Common.hs
@@ -1,25 +1,25 @@
module Language.PureScript.Sugar.Operators.Common where
-import Prelude.Compat
+import Prelude
-import Control.Monad.State
-import Control.Monad.Except
+import Control.Monad (guard, join)
+import Control.Monad.Except (MonadError(..))
import Data.Either (rights)
-import Data.Functor.Identity
+import Data.Functor.Identity (Identity)
import Data.List (sortOn)
import Data.Maybe (mapMaybe, fromJust)
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Map as M
+import Data.List.NonEmpty qualified as NEL
+import Data.Map qualified as M
-import qualified Text.Parsec as P
-import qualified Text.Parsec.Pos as P
-import qualified Text.Parsec.Expr as P
+import Text.Parsec qualified as P
+import Text.Parsec.Pos qualified as P
+import Text.Parsec.Expr qualified as P
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Errors
-import Language.PureScript.Names
+import Language.PureScript.AST (Associativity(..), ErrorMessageHint(..), SourceSpan)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Errors (ErrorMessage(..), MultipleErrors(..), SimpleErrorMessage(..))
+import Language.PureScript.Names (OpName, Qualified, eraseOpName)
type Chain a = [Either a a]
@@ -96,7 +96,7 @@ matchOperators isBinOp extractOp fromOp reapply modOpTable ops = parseChains
-- grouping them by shared precedence, then if any of the following conditions
-- are met, we have something to report:
-- 1. any of the groups have mixed associativity
- -- 2. there is more than one occurance of a non-associative operator in a
+ -- 2. there is more than one occurrence of a non-associative operator in a
-- precedence group
mkErrors :: Chain a -> [ErrorMessage]
mkErrors chain =
@@ -104,9 +104,9 @@ matchOperators isBinOp extractOp fromOp reapply modOpTable ops = parseChains
opInfo :: M.Map (Qualified (OpName nameType)) (Integer, Associativity)
opInfo = M.fromList $ concatMap (\(n, o) -> map (\(name, assoc) -> (name, (n, assoc))) o) (zip [0..] ops)
opPrec :: Qualified (OpName nameType) -> Integer
- opPrec = fromJust . fmap fst . flip M.lookup opInfo
+ opPrec = fst . fromJust . flip M.lookup opInfo
opAssoc :: Qualified (OpName nameType) -> Associativity
- opAssoc = fromJust . fmap snd . flip M.lookup opInfo
+ opAssoc = snd . fromJust . flip M.lookup opInfo
chainOpSpans :: M.Map (Qualified (OpName nameType)) (NEL.NonEmpty SourceSpan)
chainOpSpans = foldr (\(ss, name) -> M.alter (Just . maybe (pure ss) (NEL.cons ss)) name) M.empty . mapMaybe fromOp $ rights chain
opUsages :: Qualified (OpName nameType) -> Int
@@ -118,7 +118,7 @@ matchOperators isBinOp extractOp fromOp reapply modOpTable ops = parseChains
mixedAssoc :: [NEL.NonEmpty (Qualified (OpName nameType))]
mixedAssoc = fmap join . filter (\precGroup -> NEL.length precGroup > 1) $ assocGrouped
nonAssoc :: [NEL.NonEmpty (Qualified (OpName nameType))]
- nonAssoc = join $ fmap (NEL.filter (\assocGroup -> opAssoc (NEL.head assocGroup) == Infix && sum (fmap opUsages assocGroup) > 1)) assocGrouped
+ nonAssoc = NEL.filter (\assocGroup -> opAssoc (NEL.head assocGroup) == Infix && sum (fmap opUsages assocGroup) > 1) =<< assocGrouped
in
if null (nonAssoc ++ mixedAssoc)
then internalError "matchOperators: cannot reorder operators"
@@ -141,4 +141,4 @@ matchOperators isBinOp extractOp fromOp reapply modOpTable ops = parseChains
-> ErrorMessage
mkPositionedError chainOpSpans grp =
ErrorMessage
- [PositionedError (join . fmap (fromJust . flip M.lookup chainOpSpans) $ grp)]
+ [PositionedError (fromJust . flip M.lookup chainOpSpans =<< grp)]
diff --git a/src/Language/PureScript/Sugar/Operators/Expr.hs b/src/Language/PureScript/Sugar/Operators/Expr.hs
index d01c89e521..0815eb1610 100644
--- a/src/Language/PureScript/Sugar/Operators/Expr.hs
+++ b/src/Language/PureScript/Sugar/Operators/Expr.hs
@@ -1,17 +1,17 @@
module Language.PureScript.Sugar.Operators.Expr where
-import Prelude.Compat
+import Prelude
-import Control.Monad.Except
-import Data.Functor.Identity
+import Control.Monad.Except (MonadError)
+import Data.Functor.Identity (Identity)
-import qualified Text.Parsec as P
-import qualified Text.Parsec.Expr as P
+import Text.Parsec qualified as P
+import Text.Parsec.Expr qualified as P
-import Language.PureScript.AST
-import Language.PureScript.Names
-import Language.PureScript.Sugar.Operators.Common
-import Language.PureScript.Errors
+import Language.PureScript.AST (Associativity, Expr(..), SourceSpan)
+import Language.PureScript.Names (OpName(..), OpNameType(..), Qualified(..))
+import Language.PureScript.Sugar.Operators.Common (Chain, matchOperators, token)
+import Language.PureScript.Errors (MultipleErrors)
matchExprOperators
:: MonadError MultipleErrors m
@@ -36,13 +36,13 @@ matchExprOperators = matchOperators isBinOp extractOp fromOp reapply modOpTable
fromOp _ = Nothing
reapply :: SourceSpan -> Qualified (OpName 'ValueOpName) -> Expr -> Expr -> Expr
- reapply ss op t1 = App (App (Op ss op) t1)
+ reapply ss = BinaryNoParens . Op ss
modOpTable
:: [[P.Operator (Chain Expr) () Identity Expr]]
-> [[P.Operator (Chain Expr) () Identity Expr]]
modOpTable table =
- [ P.Infix (P.try (parseTicks >>= \op -> return (\t1 t2 -> App (App op t1) t2))) P.AssocLeft ]
+ [ P.Infix (P.try (BinaryNoParens <$> parseTicks)) P.AssocLeft ]
: table
parseTicks :: P.Parsec (Chain Expr) () Expr
diff --git a/src/Language/PureScript/Sugar/Operators/Types.hs b/src/Language/PureScript/Sugar/Operators/Types.hs
index fd2e1a188d..81001511cb 100644
--- a/src/Language/PureScript/Sugar/Operators/Types.hs
+++ b/src/Language/PureScript/Sugar/Operators/Types.hs
@@ -1,13 +1,13 @@
module Language.PureScript.Sugar.Operators.Types where
-import Prelude.Compat
+import Prelude
-import Control.Monad.Except
-import Language.PureScript.AST
-import Language.PureScript.Errors
-import Language.PureScript.Names
-import Language.PureScript.Sugar.Operators.Common
-import Language.PureScript.Types
+import Control.Monad.Except (MonadError)
+import Language.PureScript.AST (Associativity, SourceSpan)
+import Language.PureScript.Errors (MultipleErrors)
+import Language.PureScript.Names (OpName(..), OpNameType(..), Qualified(..))
+import Language.PureScript.Sugar.Operators.Common (matchOperators)
+import Language.PureScript.Types (SourceType, Type(..), srcTypeApp)
matchTypeOperators
:: MonadError MultipleErrors m
@@ -31,4 +31,4 @@ matchTypeOperators ss = matchOperators isBinOp extractOp fromOp reapply id
fromOp _ = Nothing
reapply :: a -> Qualified (OpName 'TypeOpName) -> SourceType -> SourceType -> SourceType
- reapply _ = srcBinaryNoParensType . srcTypeOp
+ reapply _ op = srcTypeApp . srcTypeApp (TypeOp (ss, []) op)
diff --git a/src/Language/PureScript/Sugar/TypeClasses.hs b/src/Language/PureScript/Sugar/TypeClasses.hs
index 7686e710e4..d24485e044 100644
--- a/src/Language/PureScript/Sugar/TypeClasses.hs
+++ b/src/Language/PureScript/Sugar/TypeClasses.hs
@@ -1,6 +1,6 @@
-- |
--- This module implements the desugaring pass which creates type synonyms for type class dictionaries
--- and dictionary expressions for type class instances.
+-- This module implements the desugaring pass which creates newtypes for type class dictionaries
+-- and value declarations for type class instances.
--
module Language.PureScript.Sugar.TypeClasses
( desugarTypeClasses
@@ -8,31 +8,33 @@ module Language.PureScript.Sugar.TypeClasses
, superClassDictionaryNames
) where
-import Prelude.Compat
-
-import Control.Arrow (first, second)
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.State
-import Control.Monad.Supply.Class
-import Data.Graph
-import Data.List (find, partition)
-import qualified Data.Map as M
-import Data.Maybe (catMaybes, mapMaybe, isJust, fromMaybe)
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Set as S
-import Data.Text (Text)
-import qualified Language.PureScript.Constants as C
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Errors hiding (isExported)
-import Language.PureScript.Externs
-import Language.PureScript.Kinds
-import Language.PureScript.Label (Label(..))
-import Language.PureScript.Names
-import Language.PureScript.PSString (mkString)
-import Language.PureScript.Sugar.CaseDeclarations
-import Language.PureScript.Types
-import Language.PureScript.TypeClassDictionaries (superclassName)
+import Prelude
+
+import Control.Arrow (first, second)
+import Control.Monad (unless)
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.State (MonadState(..), StateT, evalStateT, modify)
+import Control.Monad.Supply.Class (MonadSupply)
+import Data.Graph (SCC(..), stronglyConnComp)
+import Data.List (find, partition)
+import Data.List.NonEmpty (nonEmpty)
+import Data.Map qualified as M
+import Data.Maybe (catMaybes, mapMaybe, isJust)
+import Data.List.NonEmpty qualified as NEL
+import Data.Set qualified as S
+import Data.Text (Text)
+import Data.Traversable (for)
+import Language.PureScript.Constants.Prim qualified as C
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (DataDeclType(..), NameKind(..), TypeClassData(..), dictTypeName, function, makeTypeClassData, primClasses, primCoerceClasses, primIntClasses, primRowClasses, primRowListClasses, primSymbolClasses, primTypeErrorClasses, tyRecord)
+import Language.PureScript.Errors hiding (isExported, nonEmpty)
+import Language.PureScript.Externs (ExternsDeclaration(..), ExternsFile(..))
+import Language.PureScript.Label (Label(..))
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName, Name(..), ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), coerceProperName, freshIdent, qualify, runIdent)
+import Language.PureScript.PSString (mkString)
+import Language.PureScript.Sugar.CaseDeclarations (desugarCases)
+import Language.PureScript.TypeClassDictionaries (superclassName)
+import Language.PureScript.Types
type MemberMap = M.Map (ModuleName, ProperName 'ClassName) TypeClassData
@@ -45,18 +47,20 @@ type Desugar = StateT MemberMap
desugarTypeClasses
:: (MonadSupply m, MonadError MultipleErrors m)
=> [ExternsFile]
- -> [Module]
- -> m [Module]
-desugarTypeClasses externs = flip evalStateT initialState . traverse desugarModule
+ -> Module
+ -> m Module
+desugarTypeClasses externs = flip evalStateT initialState . desugarModule
where
initialState :: MemberMap
initialState =
mconcat
- [ M.mapKeys (qualify (ModuleName [ProperName C.prim])) primClasses
- , M.mapKeys (qualify C.PrimRow) primRowClasses
- , M.mapKeys (qualify C.PrimRowList) primRowListClasses
- , M.mapKeys (qualify C.PrimSymbol) primSymbolClasses
- , M.mapKeys (qualify C.PrimTypeError) primTypeErrorClasses
+ [ M.mapKeys (qualify C.M_Prim) primClasses
+ , M.mapKeys (qualify C.M_Prim_Coerce) primCoerceClasses
+ , M.mapKeys (qualify C.M_Prim_Row) primRowClasses
+ , M.mapKeys (qualify C.M_Prim_RowList) primRowListClasses
+ , M.mapKeys (qualify C.M_Prim_Symbol) primSymbolClasses
+ , M.mapKeys (qualify C.M_Prim_Int) primIntClasses
+ , M.mapKeys (qualify C.M_Prim_TypeError) primTypeErrorClasses
, M.fromList (externs >>= \ExternsFile{..} -> mapMaybe (fromExternsDecl efModuleName) efDeclarations)
]
@@ -64,8 +68,8 @@ desugarTypeClasses externs = flip evalStateT initialState . traverse desugarModu
:: ModuleName
-> ExternsDeclaration
-> Maybe ((ModuleName, ProperName 'ClassName), TypeClassData)
- fromExternsDecl mn (EDClass name args members implies deps) = Just ((mn, name), typeClass) where
- typeClass = makeTypeClassData args members implies deps
+ fromExternsDecl mn (EDClass name args members implies deps tcIsEmpty) = Just ((mn, name), typeClass) where
+ typeClass = makeTypeClassData args members implies deps tcIsEmpty
fromExternsDecl _ _ = Nothing
desugarModule
@@ -73,7 +77,7 @@ desugarModule
=> Module
-> Desugar m Module
desugarModule (Module ss coms name decls (Just exps)) = do
- let (classDecls, restDecls) = partition isTypeClassDeclaration decls
+ let (classDecls, restDecls) = partition isTypeClassDecl decls
classVerts = fmap (\d -> (d, classDeclName d, superClassesNames d)) classDecls
(classNewExpss, classDeclss) <- unzip <$> parU (stronglyConnComp classVerts) (desugarClassDecl name exps)
(restNewExpss, restDeclss) <- unzip <$> parU restDecls (desugarDecl name exps)
@@ -85,24 +89,26 @@ desugarModule (Module ss coms name decls (Just exps)) = do
-> SCC Declaration
-> Desugar m (Maybe DeclarationRef, [Declaration])
desugarClassDecl name' exps' (AcyclicSCC d) = desugarDecl name' exps' d
- desugarClassDecl _ _ (CyclicSCC ds') = throwError . errorMessage' (declSourceSpan (head ds')) $ CycleInTypeClassDeclaration (map classDeclName ds')
+ desugarClassDecl _ _ (CyclicSCC ds')
+ | Just ds'' <- nonEmpty ds' = throwError . errorMessage' (declSourceSpan (NEL.head ds'')) $ CycleInTypeClassDeclaration (NEL.map classDeclName ds'')
+ | otherwise = internalError "desugarClassDecl: empty CyclicSCC"
superClassesNames :: Declaration -> [Qualified (ProperName 'ClassName)]
superClassesNames (TypeClassDeclaration _ _ _ implies _ _) = fmap constraintName implies
superClassesNames _ = []
constraintName :: SourceConstraint -> Qualified (ProperName 'ClassName)
- constraintName (Constraint _ cName _ _) = cName
+ constraintName (Constraint _ cName _ _ _) = cName
classDeclName :: Declaration -> Qualified (ProperName 'ClassName)
- classDeclName (TypeClassDeclaration _ pn _ _ _ _) = Qualified (Just name) pn
+ classDeclName (TypeClassDeclaration _ pn _ _ _ _) = Qualified (ByModuleName name) pn
classDeclName _ = internalError "Expected TypeClassDeclaration"
desugarModule _ = internalError "Exports should have been elaborated in name desugaring"
{- Desugar type class and type class instance declarations
--
--- Type classes become type synonyms for their dictionaries, and type instances become dictionary declarations.
+-- Type classes become newtypes for their dictionaries, and type instances become dictionary declarations.
-- Additional values are generated to access individual members of a dictionary, with the appropriate type.
--
-- E.g. the following
@@ -130,68 +136,64 @@ desugarModule _ = internalError "Exports should have been elaborated in name des
--
--
--
--- type Foo a = { foo :: a -> a }
+-- newtype Foo$Dict a = Foo$Dict { foo :: a -> a }
--
-- -- this following type is marked as not needing to be checked so a new Abs
-- -- is not introduced around the definition in type checking, but when
-- -- called the dictionary value is still passed in for the `dict` argument
--- foo :: forall a. (Foo a) => a -> a
--- foo dict = dict.foo
+-- foo :: forall a. (Foo$Dict a) => a -> a
+-- foo (Foo$Dict dict) = dict.foo
--
--- fooString :: {} -> Foo String
--- fooString _ = s ++ s }>
+-- fooString :: Foo$Dict String
+-- fooString = Foo$Dict { foo: \s -> s ++ s }
--
--- fooArray :: forall a. (Foo a) => Foo [a]
--- fooArray =
+-- fooArray :: forall a. (Foo$Dict a) => Foo$Dict [a]
+-- fooArray = Foo$Dict { foo: map foo }
--
-- {- Superclasses -}
--
--
--
--- type Sub a = { sub :: a
--- , "Foo0" :: {} -> Foo a
--- }
+-- newtype Sub$Dict a = Sub$Dict { sub :: a
+-- , "Foo0" :: {} -> Foo$Dict a
+-- }
--
-- -- As with `foo` above, this type is unchecked at the declaration
--- sub :: forall a. (Sub a) => a
--- sub dict = dict.sub
+-- sub :: forall a. (Sub$Dict a) => a
+-- sub (Sub$Dict dict) = dict.sub
--
--- subString :: {} -> Sub String
--- subString _ = { sub: "",
--- , "Foo0": \_ ->
--- }
+-- subString :: Sub$Dict String
+-- subString = Sub$Dict { sub: "",
+-- , "Foo0": \_ ->
+-- }
--
-- and finally as the generated javascript:
--
--- function Foo(foo) {
--- this.foo = foo;
--- };
---
-- var foo = function (dict) {
-- return dict.foo;
-- };
--
--- var fooString = function (_) {
--- return new Foo(function (s) {
--- return s + s;
--- });
--- };
---
--- var fooArray = function (__dict_Foo_15) {
--- return new Foo(map(foo(__dict_Foo_15)));
+-- var fooString = {
+-- foo: function (s) {
+-- return s + s;
+-- }
-- };
--
--- function Sub(Foo0, sub) {
--- this["Foo0"] = Foo0;
--- this.sub = sub;
+-- var fooArray = function (dictFoo) {
+-- return {
+-- foo: map(foo(dictFoo))
+-- };
-- };
--
-- var sub = function (dict) {
-- return dict.sub;
-- };
--
--- var subString = function (_) {
--- return new Sub(fooString, "");
+-- var subString = {
+-- sub: "",
+-- Foo0: function () {
+-- return fooString;
+-- }
-- };
-}
desugarDecl
@@ -203,22 +205,40 @@ desugarDecl
desugarDecl mn exps = go
where
go d@(TypeClassDeclaration sa name args implies deps members) = do
- modify (M.insert (mn, name) (makeTypeClassData args (map memberToNameAndType members) implies deps))
+ modify (M.insert (mn, name) (makeTypeClassData args (map memberToNameAndType members) implies deps False))
return (Nothing, d : typeClassDictionaryDeclaration sa name args implies members : map (typeClassMemberToDictionaryAccessor mn name args) members)
- go (TypeInstanceDeclaration _ _ _ _ _ _ _ DerivedInstance) = internalError "Derived instanced should have been desugared"
- go d@(TypeInstanceDeclaration sa _ _ name deps className tys (ExplicitInstance members)) = do
- desugared <- desugarCases members
- dictDecl <- typeInstanceDictionaryDeclaration sa name mn deps className tys desugared
- return (expRef name className tys, [d, dictDecl])
- go d@(TypeInstanceDeclaration sa _ _ name deps className tys (NewtypeInstanceWithDictionary dict)) = do
- let dictTy = foldl srcTypeApp (srcTypeConstructor (fmap coerceProperName className)) tys
- constrainedTy = quantify (foldr (srcConstrainedType) dictTy deps)
- return (expRef name className tys, [d, ValueDecl sa name Private [] [MkUnguarded (TypedValue True dict constrainedTy)]])
+ go (TypeInstanceDeclaration sa na chainId idx name deps className tys body) = do
+ name' <- desugarInstName name
+ let d = TypeInstanceDeclaration sa na chainId idx (Right name') deps className tys body
+ let explicitOrNot = case body of
+ DerivedInstance -> Left $ DerivedInstancePlaceholder className KnownClassStrategy
+ NewtypeInstance -> Left $ DerivedInstancePlaceholder className NewtypeStrategy
+ ExplicitInstance members -> Right members
+ dictDecl <- case explicitOrNot of
+ Right members
+ | className == C.Coercible ->
+ throwError . errorMessage' (fst sa) $ InvalidCoercibleInstanceDeclaration tys
+ | otherwise -> do
+ desugared <- desugarCases members
+ typeInstanceDictionaryDeclaration sa name' mn deps className tys desugared
+ Left dict ->
+ let
+ dictTy = foldl srcTypeApp (srcTypeConstructor (fmap (coerceProperName . dictTypeName) className)) tys
+ constrainedTy = quantify (foldr srcConstrainedType dictTy deps)
+ in
+ return $ ValueDecl sa name' Private [] [MkUnguarded (TypedValue True dict constrainedTy)]
+ return (expRef name' className tys, [d, dictDecl])
go other = return (Nothing, [other])
+ -- Completes the name generation for type class instances that do not have
+ -- a unique name defined in source code.
+ desugarInstName :: MonadSupply m => Either Text Ident -> Desugar m Ident
+ desugarInstName = either freshIdent pure
+
expRef :: Ident -> Qualified (ProperName 'ClassName) -> [SourceType] -> Maybe DeclarationRef
expRef name className tys
- | isExportedClass className && all isExportedType (getConstructors `concatMap` tys) = Just $ TypeInstanceRef genSpan name
+ | isExportedClass className && all (all isExportedType . getConstructors) tys =
+ Just $ TypeInstanceRef genSpan name UserNamed
| otherwise = Nothing
isExportedClass :: Qualified (ProperName 'ClassName) -> Bool
@@ -231,7 +251,7 @@ desugarDecl mn exps = go
:: (ProperName a -> [DeclarationRef] -> Bool)
-> Qualified (ProperName a)
-> Bool
- isExported test (Qualified (Just mn') pn) = mn /= mn' || test pn exps
+ isExported test (Qualified (ByModuleName mn') pn) = mn /= mn' || test pn exps
isExported _ _ = internalError "Names should have been qualified in name desugaring"
matchesTypeRef :: ProperName 'TypeName -> DeclarationRef -> Bool
@@ -254,32 +274,39 @@ memberToNameAndType _ = internalError "Invalid declaration in type class definit
typeClassDictionaryDeclaration
:: SourceAnn
-> ProperName 'ClassName
- -> [(Text, Maybe SourceKind)]
+ -> [(Text, Maybe SourceType)]
-> [SourceConstraint]
-> [Declaration]
-> Declaration
typeClassDictionaryDeclaration sa name args implies members =
let superclassTypes = superClassDictionaryNames implies `zip`
- [ function unit (foldl srcTypeApp (srcTypeConstructor (fmap coerceProperName superclass)) tyArgs)
- | (Constraint _ superclass tyArgs _) <- implies
+ [ function unit (foldl srcTypeApp (srcTypeConstructor (fmap (coerceProperName . dictTypeName) superclass)) tyArgs)
+ | (Constraint _ superclass _ tyArgs _) <- implies
]
members' = map (first runIdent . memberToNameAndType) members
mtys = members' ++ superclassTypes
toRowListItem (l, t) = srcRowListItem (Label $ mkString l) t
- in TypeSynonymDeclaration sa (coerceProperName name) args (srcTypeApp tyRecord $ rowFromList (map toRowListItem mtys, srcREmpty))
+ ctor = DataConstructorDeclaration sa (coerceProperName $ dictTypeName name)
+ [(Ident "dict", srcTypeApp tyRecord $ rowFromList (map toRowListItem mtys, srcREmpty))]
+ in DataDeclaration sa Newtype (coerceProperName $ dictTypeName name) args [ctor]
typeClassMemberToDictionaryAccessor
:: ModuleName
-> ProperName 'ClassName
- -> [(Text, Maybe SourceKind)]
+ -> [(Text, Maybe SourceType)]
-> Declaration
-> Declaration
-typeClassMemberToDictionaryAccessor mn name args (TypeDeclaration (TypeDeclarationData sa ident ty)) =
- let className = Qualified (Just mn) name
- in ValueDecl sa ident Private [] $
+typeClassMemberToDictionaryAccessor mn name args (TypeDeclaration (TypeDeclarationData sa@(ss, _) ident ty)) =
+ let className = Qualified (ByModuleName mn) name
+ dictIdent = Ident "dict"
+ dictObjIdent = Ident "v"
+ ctor = ConstructorBinder ss (coerceProperName . dictTypeName <$> className) [VarBinder ss dictObjIdent]
+ acsr = Accessor (mkString $ runIdent ident) (Var ss (Qualified ByNullSourcePos dictObjIdent))
+ visibility = second (const TypeVarVisible) <$> args
+ in ValueDecl sa ident Private []
[MkUnguarded (
- TypedValue False (TypeClassDictionaryAccessor className ident) $
- moveQuantifiersToFront (quantify (srcConstrainedType (srcConstraint className (map (srcTypeVar . fst) args) Nothing) ty))
+ TypedValue False (Abs (VarBinder ss dictIdent) (Case [Var ss $ Qualified ByNullSourcePos dictIdent] [CaseAlternative [ctor] [MkUnguarded acsr]])) $
+ addVisibility visibility (moveQuantifiersToFront NullSourceAnn (quantify (srcConstrainedType (srcConstraint className [] (map (srcTypeVar . fst) args) Nothing) ty)))
)]
typeClassMemberToDictionaryAccessor _ _ _ _ = internalError "Invalid declaration in type class definition"
@@ -288,7 +315,7 @@ unit = srcTypeApp tyRecord srcREmpty
typeInstanceDictionaryDeclaration
:: forall m
- . (MonadSupply m, MonadError MultipleErrors m)
+ . MonadError MultipleErrors m
=> SourceAnn
-> Ident
-> ModuleName
@@ -307,31 +334,37 @@ typeInstanceDictionaryDeclaration sa@(ss, _) name mn deps className tys decls =
M.lookup (qualify mn className) m
-- Replace the type arguments with the appropriate types in the member types
- let memberTypes = map (second (replaceAllTypeVars (zip (map fst typeClassArguments) tys))) typeClassMembers
+ let memberTypes = map (second (replaceAllTypeVars (zip (map fst typeClassArguments) tys)) . tuple3To2) typeClassMembers
let declaredMembers = S.fromList $ mapMaybe declIdent decls
- case filter (\(ident, _) -> not $ S.member ident declaredMembers) memberTypes of
- hd : tl -> throwError . errorMessage' ss $ MissingClassMember (hd NEL.:| tl)
- [] -> do
- -- Create values for the type instance members
- members <- zip (map typeClassMemberName decls) <$> traverse (memberToValue memberTypes) decls
-
- -- Create the type of the dictionary
- -- The type is a record type, but depending on type instance dependencies, may be constrained.
- -- The dictionary itself is a record literal.
- let superclasses = superClassDictionaryNames typeClassSuperclasses `zip`
- [ Abs (VarBinder ss UnusedIdent) (DeferredDictionary superclass tyArgs)
- | (Constraint _ superclass suTyArgs _) <- typeClassSuperclasses
- , let tyArgs = map (replaceAllTypeVars (zip (map fst typeClassArguments) tys)) suTyArgs
- ]
-
- let props = Literal ss $ ObjectLiteral $ map (first mkString) (members ++ superclasses)
- dictTy = foldl srcTypeApp (srcTypeConstructor (fmap coerceProperName className)) tys
- constrainedTy = quantify (foldr srcConstrainedType dictTy deps)
- dict = TypeClassDictionaryConstructorApp className props
- result = ValueDecl sa name Private [] [MkUnguarded (TypedValue True dict constrainedTy)]
- return result
+ -- Instance declarations with a Fail constraint are unreachable code, so
+ -- we allow them to be empty.
+ let unreachable = any ((C.Fail ==) . constraintClass) deps && null decls
+
+ unless unreachable $
+ case filter (\(ident, _) -> not $ S.member ident declaredMembers) memberTypes of
+ hd : tl -> throwError . errorMessage' ss $ MissingClassMember (hd NEL.:| tl)
+ [] -> pure ()
+
+ -- Create values for the type instance members
+ members <- zip (map typeClassMemberName decls) <$> traverse (memberToValue memberTypes) decls
+
+ -- Create the type of the dictionary
+ -- The type is a record type, but depending on type instance dependencies, may be constrained.
+ -- The dictionary itself is a record literal (unless unreachable, in which case it's undefined).
+ superclassesDicts <- for typeClassSuperclasses $ \(Constraint _ superclass _ suTyArgs _) -> do
+ let tyArgs = map (replaceAllTypeVars (zip (map fst typeClassArguments) tys)) suTyArgs
+ pure $ Abs (VarBinder ss UnusedIdent) (DeferredDictionary superclass tyArgs)
+ let superclasses = superClassDictionaryNames typeClassSuperclasses `zip` superclassesDicts
+
+ let props = Literal ss $ ObjectLiteral $ map (first mkString) (members ++ superclasses)
+ dictTy = foldl srcTypeApp (srcTypeConstructor (fmap (coerceProperName . dictTypeName) className)) tys
+ constrainedTy = quantify (foldr srcConstrainedType dictTy deps)
+ dict = App (Constructor ss (fmap (coerceProperName . dictTypeName) className)) props
+ mkTV = if unreachable then TypedValue False (Var nullSourceSpan C.I_undefined) else TypedValue True dict
+ result = ValueDecl sa name Private [] [MkUnguarded (mkTV constrainedTy)]
+ return result
where
@@ -347,10 +380,13 @@ declIdent (TypeDeclaration td) = Just (tydeclIdent td)
declIdent _ = Nothing
typeClassMemberName :: Declaration -> Text
-typeClassMemberName = fromMaybe (internalError "typeClassMemberName: Invalid declaration in type class definition") . fmap runIdent . declIdent
+typeClassMemberName = maybe (internalError "typeClassMemberName: Invalid declaration in type class definition") runIdent . declIdent
superClassDictionaryNames :: [Constraint a] -> [Text]
superClassDictionaryNames supers =
[ superclassName pn index
- | (index, Constraint _ pn _ _) <- zip [0..] supers
+ | (index, Constraint _ pn _ _ _) <- zip [0..] supers
]
+
+tuple3To2 :: (a, b, c) -> (a, b)
+tuple3To2 (a, b, _) = (a, b)
diff --git a/src/Language/PureScript/Sugar/TypeClasses/Deriving.hs b/src/Language/PureScript/Sugar/TypeClasses/Deriving.hs
index fa10eb6693..ddbc9097a0 100755
--- a/src/Language/PureScript/Sugar/TypeClasses/Deriving.hs
+++ b/src/Language/PureScript/Sugar/TypeClasses/Deriving.hs
@@ -1,325 +1,125 @@
-- | This module implements the generic deriving elaboration that takes place during desugaring.
module Language.PureScript.Sugar.TypeClasses.Deriving (deriveInstances) where
-import Prelude.Compat
-import Protolude (ordNub)
-
-import Control.Arrow (second)
-import Control.Monad (replicateM, zipWithM, unless, when)
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.Writer.Class (MonadWriter(..))
-import Control.Monad.Supply.Class (MonadSupply)
-import Data.Foldable (for_)
-import Data.List (foldl', find, sortBy, unzip5)
-import qualified Data.Map as M
-import Data.Maybe (fromMaybe, mapMaybe)
-import Data.Ord (comparing)
-import qualified Data.Set as S
-import Data.Text (Text)
-import Language.PureScript.AST
-import qualified Language.PureScript.Constants as C
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Externs
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.Label (Label(..))
-import Language.PureScript.PSString (mkString)
-import Language.PureScript.Types
-import Language.PureScript.TypeChecker (checkNewtype)
-import Language.PureScript.TypeChecker.Synonyms (SynonymMap, replaceAllTypeSynonymsM)
-
--- | When deriving an instance for a newtype, we must ensure that all superclass
--- instances were derived in the same way. This data structure is used to ensure
--- this property.
-data NewtypeDerivedInstances = NewtypeDerivedInstances
- { ndiClasses :: M.Map (ModuleName, ProperName 'ClassName) ([Text], [SourceConstraint], [FunctionalDependency])
- -- ^ A list of superclass constraints for each type class. Since type classes
- -- have not been desugared here, we need to track this.
- , ndiDerivedInstances :: S.Set ((ModuleName, ProperName 'ClassName), (ModuleName, ProperName 'TypeName))
- -- ^ A list of newtype instances which were derived in this module.
- } deriving Show
-
-instance Semigroup NewtypeDerivedInstances where
- x <> y =
- NewtypeDerivedInstances { ndiClasses = ndiClasses x <> ndiClasses y
- , ndiDerivedInstances = ndiDerivedInstances x <> ndiDerivedInstances y
- }
-
-instance Monoid NewtypeDerivedInstances where
- mempty = NewtypeDerivedInstances mempty mempty
-
--- | Extract the name of the newtype appearing in the last type argument of
--- a derived newtype instance.
---
--- Note: since newtypes in newtype instances can only be applied to type arguments
--- (no flexible instances allowed), we don't need to bother with unification when
--- looking for matching superclass instances, which saves us a lot of work. Instead,
--- we just match the newtype name.
-extractNewtypeName :: ModuleName -> [SourceType] -> Maybe (ModuleName, ProperName 'TypeName)
-extractNewtypeName _ [] = Nothing
-extractNewtypeName mn xs = go (last xs) where
- go (TypeApp _ ty (TypeVar _ _)) = go ty
- go (TypeConstructor _ name) = Just (qualify mn name)
- go _ = Nothing
+import Prelude
+import Protolude (note)
+
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.Supply.Class (MonadSupply)
+import Data.List (foldl', find, unzip5)
+import Language.PureScript.AST (Binder(..), CaseAlternative(..), DataConstructorDeclaration(..), Declaration(..), Expr(..), pattern MkUnguarded, Module(..), SourceSpan(..), TypeInstanceBody(..), pattern ValueDecl)
+import Language.PureScript.AST.Utils (UnwrappedTypeConstructor(..), lamCase, unguarded, unwrapTypeConstructor)
+import Language.PureScript.Constants.Libs qualified as Libs
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (DataDeclType(..), NameKind(..))
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), errorMessage')
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName, ProperName(..), ProperNameType(..), Qualified(..), QualifiedBy(..), freshIdent)
+import Language.PureScript.PSString (mkString)
+import Language.PureScript.Types (SourceType, Type(..), WildcardData(..), replaceAllTypeVars, srcTypeApp, srcTypeConstructor, srcTypeLevelString, srcTypeVar)
+import Language.PureScript.TypeChecker (checkNewtype)
-- | Elaborates deriving instance declarations by code generation.
deriveInstances
:: forall m
- . (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m)
- => [ExternsFile]
- -> Module
+ . (MonadError MultipleErrors m, MonadSupply m)
+ => Module
-> m Module
-deriveInstances externs (Module ss coms mn ds exts) =
- Module ss coms mn <$> mapM (deriveInstance mn synonyms instanceData ds) ds <*> pure exts
- where
- -- We need to collect type synonym information, since synonyms will not be
- -- removed until later, during type checking.
- synonyms :: SynonymMap
- synonyms =
- M.fromList $ (externs >>= \ExternsFile{..} -> mapMaybe (fromExternsDecl efModuleName) efDeclarations)
- ++ mapMaybe fromLocalDecl ds
- where
- fromExternsDecl mn' (EDTypeSynonym name args ty) = Just (Qualified (Just mn') name, (args, ty))
- fromExternsDecl _ _ = Nothing
-
- fromLocalDecl (TypeSynonymDeclaration _ name args ty) =
- Just (Qualified (Just mn) name, (args, ty))
- fromLocalDecl _ = Nothing
-
- instanceData :: NewtypeDerivedInstances
- instanceData =
- foldMap (\ExternsFile{..} -> foldMap (fromExternsDecl efModuleName) efDeclarations) externs <> foldMap fromLocalDecl ds
- where
- fromExternsDecl mn' EDClass{..} =
- NewtypeDerivedInstances (M.singleton (mn', edClassName) (map fst edClassTypeArguments, edClassConstraints, edFunctionalDependencies)) mempty
- fromExternsDecl mn' EDInstance{..} =
- foldMap (\nm -> NewtypeDerivedInstances mempty (S.singleton (qualify mn' edInstanceClassName, nm))) (extractNewtypeName mn' edInstanceTypes)
- fromExternsDecl _ _ = mempty
-
- fromLocalDecl (TypeClassDeclaration _ cl args cons deps _) =
- NewtypeDerivedInstances (M.singleton (mn, cl) (map fst args, cons, deps)) mempty
- fromLocalDecl (TypeInstanceDeclaration _ _ _ _ _ cl tys _) =
- foldMap (\nm -> NewtypeDerivedInstances mempty (S.singleton (qualify mn cl, nm))) (extractNewtypeName mn tys)
- fromLocalDecl _ = mempty
+deriveInstances (Module ss coms mn ds exts) =
+ Module ss coms mn <$> mapM (deriveInstance mn ds) ds <*> pure exts
-- | Takes a declaration, and if the declaration is a deriving TypeInstanceDeclaration,
-- elaborates that into an instance declaration via code generation.
+--
+-- More instance deriving happens during type checking. The instances
+-- derived here are special for two reasons:
+-- * they depend only on the structure of the data, not types; and
+-- * they expect wildcard types from the user and generate type expressions
+-- to replace them.
+--
deriveInstance
- :: (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m)
+ :: forall m
+ . (MonadError MultipleErrors m, MonadSupply m)
=> ModuleName
- -> SynonymMap
- -> NewtypeDerivedInstances
-> [Declaration]
-> Declaration
-> m Declaration
-deriveInstance mn syns _ ds (TypeInstanceDeclaration sa@(ss, _) ch idx nm deps className tys DerivedInstance)
- | className == Qualified (Just dataEq) (ProperName "Eq")
- = case tys of
- [ty] | Just (Qualified mn' tyCon, _) <- unwrapTypeConstructor ty
- , mn == fromMaybe mn mn'
- -> TypeInstanceDeclaration sa ch idx nm deps className tys . ExplicitInstance <$> deriveEq ss mn syns ds tyCon
- | otherwise -> throwError . errorMessage' ss $ ExpectedTypeConstructor className tys ty
- _ -> throwError . errorMessage' ss $ InvalidDerivedInstance className tys 1
- | className == Qualified (Just dataEq) (ProperName "Eq1")
- = case tys of
- [ty] | Just (Qualified mn' _, _) <- unwrapTypeConstructor ty
- , mn == fromMaybe mn mn'
- -> pure . TypeInstanceDeclaration sa ch idx nm deps className tys . ExplicitInstance $ deriveEq1 ss
- | otherwise -> throwError . errorMessage' ss $ ExpectedTypeConstructor className tys ty
- _ -> throwError . errorMessage' ss $ InvalidDerivedInstance className tys 1
- | className == Qualified (Just dataOrd) (ProperName "Ord")
- = case tys of
- [ty] | Just (Qualified mn' tyCon, _) <- unwrapTypeConstructor ty
- , mn == fromMaybe mn mn'
- -> TypeInstanceDeclaration sa ch idx nm deps className tys . ExplicitInstance <$> deriveOrd ss mn syns ds tyCon
- | otherwise -> throwError . errorMessage' ss $ ExpectedTypeConstructor className tys ty
- _ -> throwError . errorMessage' ss $ InvalidDerivedInstance className tys 1
- | className == Qualified (Just dataOrd) (ProperName "Ord1")
- = case tys of
- [ty] | Just (Qualified mn' _, _) <- unwrapTypeConstructor ty
- , mn == fromMaybe mn mn'
- -> pure . TypeInstanceDeclaration sa ch idx nm deps className tys . ExplicitInstance $ deriveOrd1 ss
- | otherwise -> throwError . errorMessage' ss $ ExpectedTypeConstructor className tys ty
- _ -> throwError . errorMessage' ss $ InvalidDerivedInstance className tys 1
- | className == Qualified (Just dataFunctor) (ProperName "Functor")
- = case tys of
- [ty] | Just (Qualified mn' tyCon, _) <- unwrapTypeConstructor ty
- , mn == fromMaybe mn mn'
- -> TypeInstanceDeclaration sa ch idx nm deps className tys . ExplicitInstance <$> deriveFunctor ss mn syns ds tyCon
- | otherwise -> throwError . errorMessage' ss $ ExpectedTypeConstructor className tys ty
- _ -> throwError . errorMessage' ss $ InvalidDerivedInstance className tys 1
- | className == Qualified (Just dataNewtype) (ProperName "Newtype")
- = case tys of
- [wrappedTy, unwrappedTy]
- | Just (Qualified mn' tyCon, args) <- unwrapTypeConstructor wrappedTy
- , mn == fromMaybe mn mn'
- -> do (inst, actualUnwrappedTy) <- deriveNewtype ss mn syns ds tyCon args unwrappedTy
- return $ TypeInstanceDeclaration sa ch idx nm deps className [wrappedTy, actualUnwrappedTy] (ExplicitInstance inst)
- | otherwise -> throwError . errorMessage' ss $ ExpectedTypeConstructor className tys wrappedTy
- _ -> throwError . errorMessage' ss $ InvalidDerivedInstance className tys 2
- | className == Qualified (Just dataGenericRep) (ProperName C.generic)
- = case tys of
- [actualTy, repTy]
- | Just (Qualified mn' tyCon, args) <- unwrapTypeConstructor actualTy
- , mn == fromMaybe mn mn'
- -> do (inst, inferredRepTy) <- deriveGenericRep ss mn syns ds tyCon args repTy
- return $ TypeInstanceDeclaration sa ch idx nm deps className [actualTy, inferredRepTy] (ExplicitInstance inst)
- | otherwise -> throwError . errorMessage' ss $ ExpectedTypeConstructor className tys actualTy
- _ -> throwError . errorMessage' ss $ InvalidDerivedInstance className tys 2
- | otherwise = throwError . errorMessage' ss $ CannotDerive className tys
-deriveInstance mn syns ndis ds (TypeInstanceDeclaration sa@(ss, _) ch idx nm deps className tys NewtypeInstance) =
- case tys of
- _ : _ | Just (Qualified mn' tyCon, args) <- unwrapTypeConstructor (last tys)
- , mn == fromMaybe mn mn'
- -> TypeInstanceDeclaration sa ch idx nm deps className tys . NewtypeInstanceWithDictionary <$> deriveNewtypeInstance ss mn syns ndis className ds tys tyCon args
- | otherwise -> throwError . errorMessage' ss $ ExpectedTypeConstructor className tys (last tys)
- _ -> throwError . errorMessage' ss $ InvalidNewtypeInstance className tys
-deriveInstance _ _ _ _ e = return e
-
-unwrapTypeConstructor :: SourceType -> Maybe (Qualified (ProperName 'TypeName), [SourceType])
-unwrapTypeConstructor = fmap (second reverse) . go
- where
- go (TypeConstructor _ tyCon) = Just (tyCon, [])
- go (TypeApp _ ty arg) = do
- (tyCon, args) <- go ty
- return (tyCon, arg : args)
- go _ = Nothing
-
-deriveNewtypeInstance
- :: forall m
- . (MonadError MultipleErrors m, MonadWriter MultipleErrors m)
- => SourceSpan
- -> ModuleName
- -> SynonymMap
- -> NewtypeDerivedInstances
- -> Qualified (ProperName 'ClassName)
- -> [Declaration]
- -> [SourceType]
- -> ProperName 'TypeName
- -> [SourceType]
- -> m Expr
-deriveNewtypeInstance ss mn syns ndis className ds tys tyConNm dargs = do
- verifySuperclasses
- tyCon <- findTypeDecl ss tyConNm ds
- go tyCon
- where
- go (DataDeclaration _ Newtype _ tyArgNames [(_, [(_, wrapped)])]) = do
- -- The newtype might not be applied to all type arguments.
- -- This is okay as long as the newtype wraps something which ends with
- -- sufficiently many type applications to variables.
- -- For example, we can derive Functor for
- --
- -- newtype MyArray a = MyArray (Array a)
- --
- -- since Array a is a type application which uses the last
- -- type argument
- wrapped' <- replaceAllTypeSynonymsM syns wrapped
- case stripRight (takeReverse (length tyArgNames - length dargs) tyArgNames) wrapped' of
- Just wrapped'' -> do
- let subst = zipWith (\(name, _) t -> (name, t)) tyArgNames dargs
- return (DeferredDictionary className (init tys ++ [replaceAllTypeVars subst wrapped'']))
- Nothing -> throwError . errorMessage' ss $ InvalidNewtypeInstance className tys
- go _ = throwError . errorMessage' ss $ InvalidNewtypeInstance className tys
-
- takeReverse :: Int -> [a] -> [a]
- takeReverse n = take n . reverse
-
- stripRight :: [(Text, Maybe kind)] -> SourceType -> Maybe SourceType
- stripRight [] ty = Just ty
- stripRight ((arg, _) : args) (TypeApp _ t (TypeVar _ arg'))
- | arg == arg' = stripRight args t
- stripRight _ _ = Nothing
-
- verifySuperclasses :: m ()
- verifySuperclasses =
- for_ (M.lookup (qualify mn className) (ndiClasses ndis)) $ \(args, superclasses, _) ->
- for_ superclasses $ \Constraint{..} -> do
- let constraintClass' = qualify (error "verifySuperclasses: unknown class module") constraintClass
- for_ (M.lookup constraintClass' (ndiClasses ndis)) $ \(_, _, deps) ->
- -- We need to check whether the newtype is mentioned, because of classes like MonadWriter
- -- with its Monoid superclass constraint.
- when (not (null args) && any ((last args `elem`) . usedTypeVariables) constraintArgs) $ do
- -- For now, we only verify superclasses where the newtype is the only argument,
- -- or for which all other arguments are determined by functional dependencies.
- -- Everything else raises a UnverifiableSuperclassInstance warning.
- -- This covers pretty much all cases we're interested in, but later we might want to do
- -- more work to extend this to other superclass relationships.
- let determined = map (srcTypeVar . (args !!)) . ordNub . concatMap fdDetermined . filter ((== [length args - 1]) . fdDeterminers) $ deps
- if eqType (last constraintArgs) (srcTypeVar (last args)) && all (`elem` determined) (init constraintArgs)
- then do
- -- Now make sure that a superclass instance was derived. Again, this is not a complete
- -- check, since the superclass might have multiple type arguments, so overlaps might still
- -- be possible, so we warn again.
- for_ (extractNewtypeName mn tys) $ \nm ->
- unless ((constraintClass', nm) `S.member` ndiDerivedInstances ndis) $
- tell . errorMessage' ss $ MissingNewtypeSuperclassInstance constraintClass className tys
- else tell . errorMessage' ss $ UnverifiableSuperclassInstance constraintClass className tys
-
-dataGenericRep :: ModuleName
-dataGenericRep = ModuleName [ ProperName "Data", ProperName "Generic", ProperName "Rep" ]
-
-dataEq :: ModuleName
-dataEq = ModuleName [ ProperName "Data", ProperName "Eq" ]
-
-dataOrd :: ModuleName
-dataOrd = ModuleName [ ProperName "Data", ProperName "Ord" ]
-
-dataNewtype :: ModuleName
-dataNewtype = ModuleName [ ProperName "Data", ProperName "Newtype" ]
-
-dataFunctor :: ModuleName
-dataFunctor = ModuleName [ ProperName "Data", ProperName "Functor" ]
-
-unguarded :: Expr -> [GuardedExpr]
-unguarded e = [MkUnguarded e]
+deriveInstance mn ds decl =
+ case decl of
+ TypeInstanceDeclaration sa@(ss, _) na ch idx nm deps className tys DerivedInstance -> let
+ -- Attached `derive (Generic)` / `derive (Newtype)` produces `[T]`.
+ -- These two classes need the fully-applied type plus a trailing
+ -- wildcard, so pad the args before falling into the standard handler.
+ paddedTys = case tys of
+ [bareTy]
+ | className == Libs.Generic || className == Libs.Newtype
+ , Just utc <- unwrapTypeConstructor bareTy
+ , mn == utcModuleName utc
+ , null (utcArgs utc)
+ , Just (DataDeclaration _ _ _ tyVars _) <- find (matchesTyName (utcTyCon utc)) ds ->
+ let applied = foldl srcTypeApp bareTy (map (srcTypeVar . fst) tyVars)
+ in [applied, TypeWildcard sa UnnamedWildcard]
+ _ -> tys
+ matchesTyName n (DataDeclaration _ _ n' _ _) = n == n'
+ matchesTyName _ _ = False
+
+ binaryWildcardClass :: (Declaration -> [SourceType] -> m ([Declaration], SourceType)) -> m Declaration
+ binaryWildcardClass f = case paddedTys of
+ [ty1, ty2] -> case unwrapTypeConstructor ty1 of
+ Just UnwrappedTypeConstructor{..} | mn == utcModuleName -> do
+ checkIsWildcard ss utcTyCon ty2
+ tyConDecl <- findTypeDecl ss utcTyCon ds
+ (members, ty2') <- f tyConDecl utcArgs
+ pure $ TypeInstanceDeclaration sa na ch idx nm deps className [ty1, ty2'] (ExplicitInstance members)
+ _ -> throwError . errorMessage' ss $ ExpectedTypeConstructor className paddedTys ty1
+ _ -> throwError . errorMessage' ss $ InvalidDerivedInstance className paddedTys 2
+
+ in case className of
+ Libs.Generic -> binaryWildcardClass (deriveGenericRep ss mn)
+ Libs.Newtype -> binaryWildcardClass deriveNewtype
+ _ -> pure decl
+ _ -> pure decl
deriveGenericRep
:: forall m
. (MonadError MultipleErrors m, MonadSupply m)
=> SourceSpan
-> ModuleName
- -> SynonymMap
- -> [Declaration]
- -> ProperName 'TypeName
+ -> Declaration
-> [SourceType]
- -> SourceType
-> m ([Declaration], SourceType)
-deriveGenericRep ss mn syns ds tyConNm tyConArgs repTy = do
- checkIsWildcard ss tyConNm repTy
- go =<< findTypeDecl ss tyConNm ds
- where
- go :: Declaration -> m ([Declaration], SourceType)
- go (DataDeclaration (ss', _) _ _ args dctors) = do
+deriveGenericRep ss mn tyCon tyConArgs =
+ case tyCon of
+ DataDeclaration (ss', _) _ _ args dctors -> do
x <- freshIdent "x"
(reps, to, from) <- unzip3 <$> traverse makeInst dctors
let rep = toRepTy reps
inst | null reps =
-- If there are no cases, spin
[ ValueDecl (ss', []) (Ident "to") Public [] $ unguarded $
- lamCase ss' x
+ lamCase x
[ CaseAlternative
[NullBinder]
- (unguarded (App toName (Var ss' (Qualified Nothing x))))
+ (unguarded (App (Var ss Libs.I_to) (Var ss' (Qualified ByNullSourcePos x))))
]
, ValueDecl (ss', []) (Ident "from") Public [] $ unguarded $
- lamCase ss' x
+ lamCase x
[ CaseAlternative
[NullBinder]
- (unguarded (App fromName (Var ss' (Qualified Nothing x))))
+ (unguarded (App (Var ss Libs.I_from) (Var ss' (Qualified ByNullSourcePos x))))
]
]
| otherwise =
[ ValueDecl (ss', []) (Ident "to") Public [] $ unguarded $
- lamCase ss' x (zipWith ($) (map underBinder (sumBinders (length dctors))) to)
+ lamCase x (zipWith ($) (map underBinder (sumBinders (length dctors))) to)
, ValueDecl (ss', []) (Ident "from") Public [] $ unguarded $
- lamCase ss' x (zipWith ($) (map underExpr (sumExprs (length dctors))) from)
+ lamCase x (zipWith ($) (map underExpr (sumExprs (length dctors))) from)
]
subst = zipWith ((,) . fst) args tyConArgs
return (inst, replaceAllTypeVars subst rep)
- go _ = internalError "deriveGenericRep go: expected DataDeclaration"
+ _ -> internalError "deriveGenericRep: expected DataDeclaration"
+
+ where
select :: (a -> a) -> (a -> a) -> Int -> [a -> a]
select _ _ 0 = []
@@ -327,52 +127,54 @@ deriveGenericRep ss mn syns ds tyConNm tyConArgs repTy = do
select l r n = take (n - 1) (iterate (r .) l) ++ [compN (n - 1) r]
sumBinders :: Int -> [Binder -> Binder]
- sumBinders = select (ConstructorBinder ss inl . pure) (ConstructorBinder ss inr . pure)
+ sumBinders = select (ConstructorBinder ss Libs.C_Inl . pure)
+ (ConstructorBinder ss Libs.C_Inr . pure)
sumExprs :: Int -> [Expr -> Expr]
- sumExprs = select (App (Constructor ss inl)) (App (Constructor ss inr))
+ sumExprs = select (App (Constructor ss Libs.C_Inl))
+ (App (Constructor ss Libs.C_Inr))
compN :: Int -> (a -> a) -> a -> a
compN 0 _ = id
compN n f = f . compN (n - 1) f
makeInst
- :: (ProperName 'ConstructorName, [(Ident, SourceType)])
+ :: DataConstructorDeclaration
-> m (SourceType, CaseAlternative, CaseAlternative)
- makeInst (ctorName, args) = do
- args' <- mapM (replaceAllTypeSynonymsM syns . snd) args
+ makeInst (DataConstructorDeclaration _ ctorName args) = do
+ let args' = map snd args
(ctorTy, matchProduct, ctorArgs, matchCtor, mkProduct) <- makeProduct args'
- return ( srcTypeApp (srcTypeApp (srcTypeConstructor constructor)
+ return ( srcTypeApp (srcTypeApp (srcTypeConstructor Libs.Constructor)
(srcTypeLevelString $ mkString (runProperName ctorName)))
ctorTy
- , CaseAlternative [ ConstructorBinder ss constructor [matchProduct] ]
- (unguarded (foldl' App (Constructor ss (Qualified (Just mn) ctorName)) ctorArgs))
- , CaseAlternative [ ConstructorBinder ss (Qualified (Just mn) ctorName) matchCtor ]
- (unguarded (constructor' mkProduct))
+ , CaseAlternative [ ConstructorBinder ss Libs.C_Constructor [matchProduct] ]
+ (unguarded (foldl' App (Constructor ss (Qualified (ByModuleName mn) ctorName)) ctorArgs))
+ , CaseAlternative [ ConstructorBinder ss (Qualified (ByModuleName mn) ctorName) matchCtor ]
+ (unguarded (App (Constructor ss Libs.C_Constructor) mkProduct))
)
makeProduct
:: [SourceType]
-> m (SourceType, Binder, [Expr], [Binder], Expr)
makeProduct [] =
- pure (noArgs, NullBinder, [], [], noArgs')
+ pure (srcTypeConstructor Libs.NoArguments, NullBinder, [], [], Constructor ss Libs.C_NoArguments)
makeProduct args = do
(tys, bs1, es1, bs2, es2) <- unzip5 <$> traverse makeArg args
- pure ( foldr1 (\f -> srcTypeApp (srcTypeApp (srcTypeConstructor productName) f)) tys
- , foldr1 (\b1 b2 -> ConstructorBinder ss productName [b1, b2]) bs1
+ pure ( foldr1 (\f -> srcTypeApp (srcTypeApp (srcTypeConstructor Libs.Product) f)) tys
+ , foldr1 (\b1 b2 -> ConstructorBinder ss Libs.C_Product [b1, b2]) bs1
, es1
, bs2
- , foldr1 (\e1 -> App (App (Constructor ss productName) e1)) es2
+ , foldr1 (\e1 -> App (App (Constructor ss Libs.C_Product) e1)) es2
)
makeArg :: SourceType -> m (SourceType, Binder, Expr, Binder, Expr)
makeArg arg = do
argName <- freshIdent "arg"
- pure ( srcTypeApp (srcTypeConstructor argument) arg
- , ConstructorBinder ss argument [ VarBinder ss argName ]
- , Var ss (Qualified Nothing argName)
+ pure ( srcTypeApp (srcTypeConstructor Libs.Argument) arg
+ , ConstructorBinder ss Libs.C_Argument [ VarBinder ss argName ]
+ , Var ss (Qualified (BySourcePos $ spanStart ss) argName)
, VarBinder ss argName
- , argument' (Var ss (Qualified Nothing argName))
+ , App (Constructor ss Libs.C_Argument) (Var ss (Qualified (BySourcePos $ spanStart ss) argName))
)
underBinder :: (Binder -> Binder) -> CaseAlternative -> CaseAlternative
@@ -383,260 +185,30 @@ deriveGenericRep ss mn syns ds tyConNm tyConArgs repTy = do
underExpr _ _ = internalError "underExpr: expected unguarded alternative"
toRepTy :: [SourceType] -> SourceType
- toRepTy [] = noCtors
+ toRepTy [] = srcTypeConstructor Libs.NoConstructors
toRepTy [only] = only
- toRepTy ctors = foldr1 (\f -> srcTypeApp (srcTypeApp sumCtor f)) ctors
-
- toName :: Expr
- toName = Var ss (Qualified (Just dataGenericRep) (Ident "to"))
-
- fromName :: Expr
- fromName = Var ss (Qualified (Just dataGenericRep) (Ident "from"))
-
- noCtors :: SourceType
- noCtors = srcTypeConstructor (Qualified (Just dataGenericRep) (ProperName "NoConstructors"))
-
- noArgs :: SourceType
- noArgs = srcTypeConstructor (Qualified (Just dataGenericRep) (ProperName "NoArguments"))
-
- noArgs' :: Expr
- noArgs' = Constructor ss (Qualified (Just dataGenericRep) (ProperName "NoArguments"))
-
- sumCtor :: SourceType
- sumCtor = srcTypeConstructor (Qualified (Just dataGenericRep) (ProperName "Sum"))
-
- inl :: Qualified (ProperName 'ConstructorName)
- inl = Qualified (Just dataGenericRep) (ProperName "Inl")
-
- inr :: Qualified (ProperName 'ConstructorName)
- inr = Qualified (Just dataGenericRep) (ProperName "Inr")
-
- productName :: Qualified (ProperName ty)
- productName = Qualified (Just dataGenericRep) (ProperName "Product")
-
- constructor :: Qualified (ProperName ty)
- constructor = Qualified (Just dataGenericRep) (ProperName "Constructor")
-
- constructor' :: Expr -> Expr
- constructor' = App (Constructor ss constructor)
-
- argument :: Qualified (ProperName ty)
- argument = Qualified (Just dataGenericRep) (ProperName "Argument")
-
- argument' :: Expr -> Expr
- argument' = App (Constructor ss argument)
+ toRepTy ctors = foldr1 (\f -> srcTypeApp (srcTypeApp (srcTypeConstructor Libs.Sum) f)) ctors
checkIsWildcard :: MonadError MultipleErrors m => SourceSpan -> ProperName 'TypeName -> SourceType -> m ()
-checkIsWildcard _ _ (TypeWildcard _ Nothing) = return ()
+checkIsWildcard _ _ (TypeWildcard _ UnnamedWildcard) = return ()
checkIsWildcard ss tyConNm _ =
throwError . errorMessage' ss $ ExpectedWildcard tyConNm
-deriveEq
- :: forall m
- . (MonadError MultipleErrors m, MonadSupply m)
- => SourceSpan
- -> ModuleName
- -> SynonymMap
- -> [Declaration]
- -> ProperName 'TypeName
- -> m [Declaration]
-deriveEq ss mn syns ds tyConNm = do
- tyCon <- findTypeDecl ss tyConNm ds
- eqFun <- mkEqFunction tyCon
- return [ ValueDecl (ss, []) (Ident C.eq) Public [] (unguarded eqFun) ]
- where
- mkEqFunction :: Declaration -> m Expr
- mkEqFunction (DataDeclaration (ss', _) _ _ _ args) = do
- x <- freshIdent "x"
- y <- freshIdent "y"
- lamCase2 ss' x y <$> (addCatch <$> mapM mkCtorClause args)
- mkEqFunction _ = internalError "mkEqFunction: expected DataDeclaration"
-
- preludeConj :: Expr -> Expr -> Expr
- preludeConj = App . App (Var ss (Qualified (Just (ModuleName [ProperName "Data", ProperName "HeytingAlgebra"])) (Ident C.conj)))
-
- preludeEq :: Expr -> Expr -> Expr
- preludeEq = App . App (Var ss (Qualified (Just dataEq) (Ident C.eq)))
-
- preludeEq1 :: Expr -> Expr -> Expr
- preludeEq1 = App . App (Var ss (Qualified (Just dataEq) (Ident C.eq1)))
-
- addCatch :: [CaseAlternative] -> [CaseAlternative]
- addCatch xs
- | length xs /= 1 = xs ++ [catchAll]
- | otherwise = xs -- Avoid redundant case
- where
- catchAll = CaseAlternative [NullBinder, NullBinder] (unguarded (Literal ss (BooleanLiteral False)))
-
- mkCtorClause :: (ProperName 'ConstructorName, [(Ident, SourceType)]) -> m CaseAlternative
- mkCtorClause (ctorName, tys) = do
- identsL <- replicateM (length tys) (freshIdent "l")
- identsR <- replicateM (length tys) (freshIdent "r")
- tys' <- mapM (replaceAllTypeSynonymsM syns . snd) tys
- let tests = zipWith3 toEqTest (map (Var ss . Qualified Nothing) identsL) (map (Var ss . Qualified Nothing) identsR) tys'
- return $ CaseAlternative [caseBinder identsL, caseBinder identsR] (unguarded (conjAll tests))
- where
- caseBinder idents = ConstructorBinder ss (Qualified (Just mn) ctorName) (map (VarBinder ss) idents)
-
- conjAll :: [Expr] -> Expr
- conjAll [] = Literal ss (BooleanLiteral True)
- conjAll xs = foldl1 preludeConj xs
-
- toEqTest :: Expr -> Expr -> SourceType -> Expr
- toEqTest l r ty
- | Just rec <- objectType ty
- , Just fields <- decomposeRec rec =
- conjAll
- . map (\((Label str), typ) -> toEqTest (Accessor str l) (Accessor str r) typ)
- $ fields
- | isAppliedVar ty = preludeEq1 l r
- | otherwise = preludeEq l r
-
-deriveEq1 :: SourceSpan -> [Declaration]
-deriveEq1 ss =
- [ ValueDecl (ss, []) (Ident C.eq1) Public [] (unguarded preludeEq)]
- where
- preludeEq :: Expr
- preludeEq = Var ss (Qualified (Just dataEq) (Ident C.eq))
-
-deriveOrd
- :: forall m
- . (MonadError MultipleErrors m, MonadSupply m)
- => SourceSpan
- -> ModuleName
- -> SynonymMap
- -> [Declaration]
- -> ProperName 'TypeName
- -> m [Declaration]
-deriveOrd ss mn syns ds tyConNm = do
- tyCon <- findTypeDecl ss tyConNm ds
- compareFun <- mkCompareFunction tyCon
- return [ ValueDecl (ss, []) (Ident C.compare) Public [] (unguarded compareFun) ]
- where
- mkCompareFunction :: Declaration -> m Expr
- mkCompareFunction (DataDeclaration (ss', _) _ _ _ args) = do
- x <- freshIdent "x"
- y <- freshIdent "y"
- lamCase2 ss' x y <$> (addCatch . concat <$> mapM mkCtorClauses (splitLast args))
- mkCompareFunction _ = internalError "mkCompareFunction: expected DataDeclaration"
-
- splitLast :: [a] -> [(a, Bool)]
- splitLast [] = []
- splitLast [x] = [(x, True)]
- splitLast (x : xs) = (x, False) : splitLast xs
-
- addCatch :: [CaseAlternative] -> [CaseAlternative]
- addCatch xs
- | null xs = [catchAll] -- No type constructors
- | otherwise = xs
- where
- catchAll = CaseAlternative [NullBinder, NullBinder] (unguarded (orderingCtor "EQ"))
-
- orderingName :: Text -> Qualified (ProperName a)
- orderingName = Qualified (Just (ModuleName [ProperName "Data", ProperName "Ordering"])) . ProperName
-
- orderingCtor :: Text -> Expr
- orderingCtor = Constructor ss . orderingName
-
- orderingBinder :: Text -> Binder
- orderingBinder name = ConstructorBinder ss (orderingName name) []
-
- ordCompare :: Expr -> Expr -> Expr
- ordCompare = App . App (Var ss (Qualified (Just dataOrd) (Ident C.compare)))
-
- ordCompare1 :: Expr -> Expr -> Expr
- ordCompare1 = App . App (Var ss (Qualified (Just dataOrd) (Ident C.compare1)))
-
- mkCtorClauses :: ((ProperName 'ConstructorName, [(Ident, SourceType)]), Bool) -> m [CaseAlternative]
- mkCtorClauses ((ctorName, tys), isLast) = do
- identsL <- replicateM (length tys) (freshIdent "l")
- identsR <- replicateM (length tys) (freshIdent "r")
- tys' <- mapM (replaceAllTypeSynonymsM syns . snd) tys
- let tests = zipWith3 toOrdering (map (Var ss . Qualified Nothing) identsL) (map (Var ss . Qualified Nothing) identsR) tys'
- extras | not isLast = [ CaseAlternative [ ConstructorBinder ss (Qualified (Just mn) ctorName) (replicate (length tys) NullBinder)
- , NullBinder
- ]
- (unguarded (orderingCtor "LT"))
- , CaseAlternative [ NullBinder
- , ConstructorBinder ss (Qualified (Just mn) ctorName) (replicate (length tys) NullBinder)
- ]
- (unguarded (orderingCtor "GT"))
- ]
- | otherwise = []
- return $ CaseAlternative [ caseBinder identsL
- , caseBinder identsR
- ]
- (unguarded (appendAll tests))
- : extras
-
- where
- caseBinder idents = ConstructorBinder ss (Qualified (Just mn) ctorName) (map (VarBinder ss) idents)
-
- appendAll :: [Expr] -> Expr
- appendAll [] = orderingCtor "EQ"
- appendAll [x] = x
- appendAll (x : xs) = Case [x] [ CaseAlternative [orderingBinder "LT"]
- (unguarded (orderingCtor "LT"))
- , CaseAlternative [orderingBinder "GT"]
- (unguarded (orderingCtor "GT"))
- , CaseAlternative [ NullBinder ]
- (unguarded (appendAll xs))
- ]
-
- toOrdering :: Expr -> Expr -> SourceType -> Expr
- toOrdering l r ty
- | Just rec <- objectType ty
- , Just fields <- decomposeRec rec =
- appendAll
- . map (\((Label str), typ) -> toOrdering (Accessor str l) (Accessor str r) typ)
- $ fields
- | isAppliedVar ty = ordCompare1 l r
- | otherwise = ordCompare l r
-
-deriveOrd1 :: SourceSpan -> [Declaration]
-deriveOrd1 ss =
- [ ValueDecl (ss, []) (Ident C.compare1) Public [] (unguarded dataOrdCompare)]
- where
- dataOrdCompare :: Expr
- dataOrdCompare = Var ss (Qualified (Just dataOrd) (Ident C.compare))
-
deriveNewtype
:: forall m
- . (MonadError MultipleErrors m, MonadSupply m)
- => SourceSpan
- -> ModuleName
- -> SynonymMap
- -> [Declaration]
- -> ProperName 'TypeName
+ . MonadError MultipleErrors m
+ => Declaration
-> [SourceType]
- -> SourceType
-> m ([Declaration], SourceType)
-deriveNewtype ss mn syns ds tyConNm tyConArgs unwrappedTy = do
- checkIsWildcard ss tyConNm unwrappedTy
- go =<< findTypeDecl ss tyConNm ds
- where
- go :: Declaration -> m ([Declaration], SourceType)
- go (DataDeclaration (ss', _) Data name _ _) =
+deriveNewtype tyCon tyConArgs =
+ case tyCon of
+ DataDeclaration (ss', _) Data name _ _ ->
throwError . errorMessage' ss' $ CannotDeriveNewtypeForData name
- go (DataDeclaration (ss', _) Newtype name args dctors) = do
- checkNewtype name dctors
- wrappedIdent <- freshIdent "n"
- unwrappedIdent <- freshIdent "a"
- let (ctorName, [(_, ty)]) = head dctors
- ty' <- replaceAllTypeSynonymsM syns ty
- let inst =
- [ ValueDecl (ss', []) (Ident "wrap") Public [] $ unguarded $
- Constructor ss' (Qualified (Just mn) ctorName)
- , ValueDecl (ss', []) (Ident "unwrap") Public [] $ unguarded $
- lamCase ss' wrappedIdent
- [ CaseAlternative
- [ConstructorBinder ss' (Qualified (Just mn) ctorName) [VarBinder ss' unwrappedIdent]]
- (unguarded (Var ss' (Qualified Nothing unwrappedIdent)))
- ]
- ]
- subst = zipWith ((,) . fst) args tyConArgs
- return (inst, replaceAllTypeVars subst ty')
- go _ = internalError "deriveNewtype go: expected DataDeclaration"
+ DataDeclaration _ Newtype name args dctors -> do
+ (_, (_, ty)) <- checkNewtype name dctors
+ let subst = zipWith ((,) . fst) args tyConArgs
+ return ([], replaceAllTypeVars subst ty)
+ _ -> internalError "deriveNewtype: expected DataDeclaration"
findTypeDecl
:: (MonadError MultipleErrors m)
@@ -644,116 +216,8 @@ findTypeDecl
-> ProperName 'TypeName
-> [Declaration]
-> m Declaration
-findTypeDecl ss tyConNm = maybe (throwError . errorMessage' ss $ CannotFindDerivingType tyConNm) return . find isTypeDecl
+findTypeDecl ss tyConNm = note (errorMessage' ss $ CannotFindDerivingType tyConNm) . find isTypeDecl
where
isTypeDecl :: Declaration -> Bool
- isTypeDecl (DataDeclaration _ _ nm _ _) | nm == tyConNm = True
+ isTypeDecl (DataDeclaration _ _ nm _ _) = nm == tyConNm
isTypeDecl _ = False
-
-lam :: SourceSpan -> Ident -> Expr -> Expr
-lam ss = Abs . VarBinder ss
-
-lamCase :: SourceSpan -> Ident -> [CaseAlternative] -> Expr
-lamCase ss s = lam ss s . Case [mkVar ss s]
-
-lamCase2 :: SourceSpan -> Ident -> Ident -> [CaseAlternative] -> Expr
-lamCase2 ss s t = lam ss s . lam ss t . Case [mkVar ss s, mkVar ss t]
-
-mkVarMn :: SourceSpan -> Maybe ModuleName -> Ident -> Expr
-mkVarMn ss mn = Var ss . Qualified mn
-
-mkVar :: SourceSpan -> Ident -> Expr
-mkVar ss = mkVarMn ss Nothing
-
-isAppliedVar :: Type a -> Bool
-isAppliedVar (TypeApp _ (TypeVar _ _) _) = True
-isAppliedVar _ = False
-
-objectType :: Type a -> Maybe (Type a)
-objectType (TypeApp _ (TypeConstructor _ C.Record) rec) = Just rec
-objectType _ = Nothing
-
-decomposeRec :: SourceType -> Maybe [(Label, SourceType)]
-decomposeRec = fmap (sortBy (comparing fst)) . go
- where go (RCons _ str typ typs) = fmap ((str, typ) :) (go typs)
- go (REmpty _) = Just []
- go _ = Nothing
-
-decomposeRec' :: SourceType -> [(Label, SourceType)]
-decomposeRec' = sortBy (comparing fst) . go
- where go (RCons _ str typ typs) = (str, typ) : go typs
- go _ = []
-
-deriveFunctor
- :: forall m
- . (MonadError MultipleErrors m, MonadSupply m)
- => SourceSpan
- -> ModuleName
- -> SynonymMap
- -> [Declaration]
- -> ProperName 'TypeName
- -> m [Declaration]
-deriveFunctor ss mn syns ds tyConNm = do
- tyCon <- findTypeDecl ss tyConNm ds
- mapFun <- mkMapFunction tyCon
- return [ ValueDecl (ss, []) (Ident C.map) Public [] (unguarded mapFun) ]
- where
- mkMapFunction :: Declaration -> m Expr
- mkMapFunction (DataDeclaration (ss', _) _ _ tys ctors) = case reverse tys of
- [] -> throwError . errorMessage' ss' $ KindsDoNotUnify (FunKind nullSourceAnn kindType kindType) kindType
- ((iTy, _) : _) -> do
- f <- freshIdent "f"
- m <- freshIdent "m"
- lam ss' f . lamCase ss' m <$> mapM (mkCtorClause iTy f) ctors
- mkMapFunction _ = internalError "mkMapFunction: expected DataDeclaration"
-
- mkCtorClause :: Text -> Ident -> (ProperName 'ConstructorName, [(Ident, SourceType)]) -> m CaseAlternative
- mkCtorClause iTyName f (ctorName, ctorTys) = do
- idents <- replicateM (length ctorTys) (freshIdent "v")
- ctorTys' <- mapM (replaceAllTypeSynonymsM syns . snd) ctorTys
- args <- zipWithM transformArg idents ctorTys'
- let ctor = Constructor ss (Qualified (Just mn) ctorName)
- rebuilt = foldl' App ctor args
- caseBinder = ConstructorBinder ss (Qualified (Just mn) ctorName) (VarBinder ss <$> idents)
- return $ CaseAlternative [caseBinder] (unguarded rebuilt)
- where
- fVar = mkVar ss f
- mapVar = mkVarMn ss (Just dataFunctor) (Ident C.map)
-
- -- TODO: deal with type synonyms, ala https://github.com/purescript/purescript/pull/2516
- transformArg :: Ident -> SourceType -> m Expr
- transformArg ident = fmap (foldr App (mkVar ss ident)) . goType where
-
- goType :: SourceType -> m (Maybe Expr)
- -- argument matches the index type
- goType (TypeVar _ t) | t == iTyName = return (Just fVar)
-
- -- records
- goType recTy | Just row <- objectType recTy =
- traverse buildUpdate (decomposeRec' row) >>= (traverse buildRecord . justUpdates)
- where
- justUpdates :: [Maybe (Label, Expr)] -> Maybe [(Label, Expr)]
- justUpdates = foldMap (fmap return)
-
- buildUpdate :: (Label, SourceType) -> m (Maybe (Label, Expr))
- buildUpdate (lbl, ty) = do upd <- goType ty
- return ((lbl,) <$> upd)
-
- buildRecord :: [(Label, Expr)] -> m Expr
- buildRecord updates = do
- arg <- freshIdent "o"
- let argVar = mkVar ss arg
- mkAssignment ((Label l), x) = (l, App x (Accessor l argVar))
- return (lam ss arg (ObjectUpdate argVar (mkAssignment <$> updates)))
-
- -- quantifiers
- goType (ForAll _ scopedVar _ t _) | scopedVar /= iTyName = goType t
-
- -- constraints
- goType (ConstrainedType _ _ t) = goType t
-
- -- under a `* -> *`, just assume functor for now
- goType (TypeApp _ _ t) = fmap (App mapVar) <$> goType t
-
- -- otherwise do nothing - will fail type checking if type does actually contain index
- goType _ = return Nothing
diff --git a/src/Language/PureScript/Sugar/TypeDeclarations.hs b/src/Language/PureScript/Sugar/TypeDeclarations.hs
index 37e8d1b3cc..ef00748d67 100644
--- a/src/Language/PureScript/Sugar/TypeDeclarations.hs
+++ b/src/Language/PureScript/Sugar/TypeDeclarations.hs
@@ -6,14 +6,15 @@ module Language.PureScript.Sugar.TypeDeclarations
( desugarTypeDeclarationsModule
) where
-import Prelude.Compat
+import Prelude
+import Control.Monad (unless)
import Control.Monad.Error.Class (MonadError(..))
-import Language.PureScript.AST
-import Language.PureScript.Names
-import Language.PureScript.Environment
-import Language.PureScript.Errors
+import Language.PureScript.AST (Declaration(..), ErrorMessageHint(..), Expr(..), GuardedExpr(..), KindSignatureFor(..), pattern MkUnguarded, Module(..), RoleDeclarationData(..), TypeDeclarationData(..), TypeInstanceBody(..), pattern ValueDecl, declSourceSpan, everywhereOnValuesTopDownM)
+import Language.PureScript.Names (Ident, coerceProperName)
+import Language.PureScript.Environment (DataDeclType(..), NameKind)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, errorMessage', rethrow)
-- |
-- Replace all top level type declarations in a module with type annotations
@@ -24,7 +25,9 @@ desugarTypeDeclarationsModule
=> Module
-> m Module
desugarTypeDeclarationsModule (Module modSS coms name ds exps) =
- rethrow (addHint (ErrorInModule name)) $
+ rethrow (addHint (ErrorInModule name)) $ do
+ checkKindDeclarations ds
+ checkRoleDeclarations Nothing ds
Module modSS coms name <$> desugarTypeDeclarations ds <*> pure exps
where
@@ -48,8 +51,47 @@ desugarTypeDeclarationsModule (Module modSS coms name ds exps) =
where
go (Let w ds' val') = Let w <$> desugarTypeDeclarations ds' <*> pure val'
go other = return other
- desugarTypeDeclarations (TypeInstanceDeclaration sa ch idx nm deps cls args (ExplicitInstance ds') : rest) =
- (:) <$> (TypeInstanceDeclaration sa ch idx nm deps cls args . ExplicitInstance <$> desugarTypeDeclarations ds')
+ desugarTypeDeclarations (TypeInstanceDeclaration sa na ch idx nm deps cls args (ExplicitInstance ds') : rest) =
+ (:) <$> (TypeInstanceDeclaration sa na ch idx nm deps cls args . ExplicitInstance <$> desugarTypeDeclarations ds')
<*> desugarTypeDeclarations rest
desugarTypeDeclarations (d:rest) = (:) d <$> desugarTypeDeclarations rest
desugarTypeDeclarations [] = return []
+
+ checkKindDeclarations :: [Declaration] -> m ()
+ checkKindDeclarations (KindDeclaration sa kindFor name' _ : d : rest) = do
+ unless (matchesDeclaration d) . throwError . errorMessage' (fst sa) $ OrphanKindDeclaration name'
+ checkKindDeclarations rest
+ where
+ matchesDeclaration :: Declaration -> Bool
+ matchesDeclaration (DataDeclaration _ Data name'' _ _) = kindFor == DataSig && name' == name''
+ matchesDeclaration (DataDeclaration _ Newtype name'' _ _) = kindFor == NewtypeSig && name' == name''
+ matchesDeclaration (TypeSynonymDeclaration _ name'' _ _) = kindFor == TypeSynonymSig && name' == name''
+ matchesDeclaration (TypeClassDeclaration _ name'' _ _ _ _) = kindFor == ClassSig && name' == coerceProperName name''
+ matchesDeclaration _ = False
+ checkKindDeclarations (KindDeclaration sa _ name' _ : _) = do
+ throwError . errorMessage' (fst sa) $ OrphanKindDeclaration name'
+ checkKindDeclarations (_ : rest) = checkKindDeclarations rest
+ checkKindDeclarations [] = return ()
+
+ checkRoleDeclarations :: Maybe Declaration -> [Declaration] -> m ()
+ checkRoleDeclarations Nothing (RoleDeclaration RoleDeclarationData{..} : _) =
+ throwError . errorMessage' (fst rdeclSourceAnn) $ OrphanRoleDeclaration rdeclIdent
+ checkRoleDeclarations (Just (RoleDeclaration (RoleDeclarationData _ name' _))) ((RoleDeclaration RoleDeclarationData{..}) : _) | name' == rdeclIdent =
+ throwError . errorMessage' (fst rdeclSourceAnn) $ DuplicateRoleDeclaration rdeclIdent
+ checkRoleDeclarations (Just d) (rd@(RoleDeclaration RoleDeclarationData{..}) : rest) = do
+ unless (matchesDeclaration d) . throwError . errorMessage' (fst rdeclSourceAnn) $ OrphanRoleDeclaration rdeclIdent
+ unless (isSupported d) . throwError . errorMessage' (fst rdeclSourceAnn) $ UnsupportedRoleDeclaration
+ checkRoleDeclarations (Just rd) rest
+ where
+ isSupported :: Declaration -> Bool
+ isSupported DataDeclaration{} = True
+ isSupported ExternDataDeclaration{} = True
+ isSupported _ = False
+ matchesDeclaration :: Declaration -> Bool
+ matchesDeclaration (DataDeclaration _ _ name' _ _) = rdeclIdent == name'
+ matchesDeclaration (ExternDataDeclaration _ name' _) = rdeclIdent == name'
+ matchesDeclaration (TypeSynonymDeclaration _ name' _ _) = rdeclIdent == name'
+ matchesDeclaration (TypeClassDeclaration _ name' _ _ _ _) = rdeclIdent == coerceProperName name'
+ matchesDeclaration _ = False
+ checkRoleDeclarations _ (d : rest) = checkRoleDeclarations (Just d) rest
+ checkRoleDeclarations _ [] = return ()
diff --git a/src/Language/PureScript/Traversals.hs b/src/Language/PureScript/Traversals.hs
index c40f91c04e..1226342c71 100644
--- a/src/Language/PureScript/Traversals.hs
+++ b/src/Language/PureScript/Traversals.hs
@@ -1,27 +1,23 @@
--- | Common functions for implementing generic traversals
-module Language.PureScript.Traversals where
-
-import Prelude.Compat
-
-fstM :: (Functor f) => (a -> f c) -> (a, b) -> f (c, b)
-fstM f (a, b) = flip (,) b <$> f a
-
-sndM :: (Functor f) => (b -> f c) -> (a, b) -> f (a, c)
-sndM f (a, b) = (,) a <$> f b
-
-thirdM :: (Functor f) => (c -> f d) -> (a, b, c) -> f (a, b, d)
-thirdM f (a, b, c) = (,,) a b <$> f c
-
-pairM :: (Applicative f) => (a -> f c) -> (b -> f d) -> (a, b) -> f (c, d)
-pairM f g (a, b) = (,) <$> f a <*> g b
-
-maybeM :: (Applicative f) => (a -> f b) -> Maybe a -> f (Maybe b)
-maybeM _ Nothing = pure Nothing
-maybeM f (Just a) = Just <$> f a
-
-eitherM :: (Applicative f) => (a -> f c) -> (b -> f d) -> Either a b -> f (Either c d)
-eitherM f _ (Left a) = Left <$> f a
-eitherM _ g (Right b) = Right <$> g b
-
-defS :: (Monad m) => st -> val -> m (st, val)
-defS s val = return (s, val)
+-- | Common functions for implementing generic traversals
+module Language.PureScript.Traversals where
+
+import Prelude
+
+sndM :: (Functor f) => (b -> f c) -> (a, b) -> f (a, c)
+sndM f (a, b) = (a, ) <$> f b
+
+sndM' :: (Functor f) => (a -> b -> f c) -> (a, b) -> f (a, c)
+sndM' f (a, b) = (a, ) <$> f a b
+
+thirdM :: (Functor f) => (c -> f d) -> (a, b, c) -> f (a, b, d)
+thirdM f (a, b, c) = (a, b, ) <$> f c
+
+pairM :: (Applicative f) => (a -> f c) -> (b -> f d) -> (a, b) -> f (c, d)
+pairM f g (a, b) = (,) <$> f a <*> g b
+
+eitherM :: (Applicative f) => (a -> f c) -> (b -> f d) -> Either a b -> f (Either c d)
+eitherM f _ (Left a) = Left <$> f a
+eitherM _ g (Right b) = Right <$> g b
+
+defS :: (Monad m) => st -> val -> m (st, val)
+defS s val = return (s, val)
diff --git a/src/Language/PureScript/TypeChecker.hs b/src/Language/PureScript/TypeChecker.hs
index ecfdeb9b79..d0d122206a 100644
--- a/src/Language/PureScript/TypeChecker.hs
+++ b/src/Language/PureScript/TypeChecker.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE FlexibleInstances #-}
-
-- |
-- The top-level type checker, which checks all declarations in a module.
--
@@ -9,88 +7,119 @@ module Language.PureScript.TypeChecker
, checkNewtype
) where
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
+import Protolude (headMay, maybeToLeft, ordNub, headDef)
-import Control.Arrow (second)
-import Control.Monad (when, unless, void, forM)
+import Control.Lens ((^..), _2)
+import Control.Monad (when, unless, void, forM, zipWithM_)
import Control.Monad.Error.Class (MonadError(..))
import Control.Monad.State.Class (MonadState(..), modify, gets)
import Control.Monad.Supply.Class (MonadSupply)
-import Control.Monad.Writer.Class (MonadWriter(..), censor)
+import Control.Monad.Writer.Class (MonadWriter, tell)
import Data.Foldable (for_, traverse_, toList)
-import Data.List (nub, nubBy, (\\), sort, group, intersect)
-import Data.Maybe
+import Data.List (nubBy, (\\), sort, group)
+import Data.Maybe (fromMaybe, listToMaybe, mapMaybe)
+import Data.Either (partitionEithers)
import Data.Text (Text)
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Map as M
-import qualified Data.Set as S
-import qualified Data.Text as T
+import Data.List.NonEmpty qualified as NEL
+import Data.Map qualified as M
+import Data.Set qualified as S
+import Data.Text qualified as T
import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Kinds
-import Language.PureScript.Linter
-import Language.PureScript.Names
+import Language.PureScript.AST.Declarations.ChainId (ChainId)
+import Language.PureScript.Constants.Libs qualified as Libs
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (DataDeclType(..), Environment(..), FunctionalDependency, NameKind(..), NameVisibility(..), TypeClassData(..), TypeKind(..), isDictTypeName, kindArity, makeTypeClassData, nominalRolesForKind, tyFunction)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, errorMessage, errorMessage', positionedError, rethrow, warnAndRethrow)
+import Language.PureScript.Linter (checkExhaustiveExpr)
+import Language.PureScript.Linter.Wildcards (ignoreWildcardsUnderCompleteTypeSignatures)
+import Language.PureScript.Names (Ident, ModuleName, ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..), coerceProperName, disqualify, isPlainIdent, mkQualified)
+import Language.PureScript.Roles (Role)
+import Language.PureScript.Sugar.Names.Env (Exports(..))
import Language.PureScript.TypeChecker.Kinds as T
import Language.PureScript.TypeChecker.Monad as T
+import Language.PureScript.TypeChecker.Roles as T
import Language.PureScript.TypeChecker.Synonyms as T
import Language.PureScript.TypeChecker.Types as T
-import Language.PureScript.TypeClassDictionaries
-import Language.PureScript.Types
-
-import Lens.Micro.Platform ((^..), _2, _3)
+import Language.PureScript.TypeChecker.Unify (varIfUnknown)
+import Language.PureScript.TypeClassDictionaries (NamedDict, TypeClassDictionaryInScope(..))
+import Language.PureScript.Types (Constraint(..), SourceConstraint, SourceType, Type(..), containsForAll, eqType, everythingOnTypes, overConstraintArgs, srcInstanceType, unapplyTypes)
addDataType
:: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
=> ModuleName
-> DataDeclType
-> ProperName 'TypeName
- -> [(Text, Maybe SourceKind)]
- -> [(ProperName 'ConstructorName, [(Ident, SourceType)])]
- -> SourceKind
+ -> [(Text, Maybe SourceType, Role)]
+ -> [(DataConstructorDeclaration, SourceType)]
+ -> SourceType
-> m ()
addDataType moduleName dtype name args dctors ctorKind = do
env <- getEnv
- putEnv $ env { types = M.insert (Qualified (Just moduleName) name) (ctorKind, DataType args (map (second (map snd)) dctors)) (types env) }
- for_ dctors $ \(dctor, fields) ->
+ let mapDataCtor (DataConstructorDeclaration _ ctorName vars) = (ctorName, snd <$> vars)
+ qualName = Qualified (ByModuleName moduleName) name
+ hasSig = qualName `M.member` types env
+ putEnv $ env { types = M.insert qualName (ctorKind, DataType dtype args (map (mapDataCtor . fst) dctors)) (types env) }
+ unless (hasSig || isDictTypeName name || not (containsForAll ctorKind)) $ do
+ tell . errorMessage $ MissingKindDeclaration (if dtype == Newtype then NewtypeSig else DataSig) name ctorKind
+ for_ dctors $ \(DataConstructorDeclaration _ dctor fields, polyType) ->
warnAndRethrow (addHint (ErrorInDataConstructor dctor)) $
- addDataConstructor moduleName dtype name (map fst args) dctor fields
+ addDataConstructor moduleName dtype name dctor fields polyType
addDataConstructor
:: (MonadState CheckState m, MonadError MultipleErrors m)
=> ModuleName
-> DataDeclType
-> ProperName 'TypeName
- -> [Text]
-> ProperName 'ConstructorName
-> [(Ident, SourceType)]
+ -> SourceType
-> m ()
-addDataConstructor moduleName dtype name args dctor dctorArgs = do
- let (fields, tys) = unzip dctorArgs
+addDataConstructor moduleName dtype name dctor dctorArgs polyType = do
+ let fields = fst <$> dctorArgs
env <- getEnv
- traverse_ checkTypeSynonyms tys
- let retTy = foldl srcTypeApp (srcTypeConstructor (Qualified (Just moduleName) name)) (map srcTypeVar args)
- let dctorTy = foldr function retTy tys
- let polyType = mkForAll (map (\i -> (NullSourceAnn, (i, Nothing))) args) dctorTy
- putEnv $ env { dataConstructors = M.insert (Qualified (Just moduleName) dctor) (dtype, name, polyType, fields) (dataConstructors env) }
+ checkTypeSynonyms polyType
+ putEnv $ env { dataConstructors = M.insert (Qualified (ByModuleName moduleName) dctor) (dtype, name, polyType, fields) (dataConstructors env) }
+
+checkRoleDeclaration
+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
+ => ModuleName
+ -> RoleDeclarationData
+ -> m ()
+checkRoleDeclaration moduleName (RoleDeclarationData (ss, _) name declaredRoles) = do
+ warnAndRethrow (addHint (ErrorInRoleDeclaration name) . addHint (positionedError ss)) $ do
+ env <- getEnv
+ let qualName = Qualified (ByModuleName moduleName) name
+ case M.lookup qualName (types env) of
+ Just (kind, DataType dtype args dctors) -> do
+ checkRoleDeclarationArity name declaredRoles (length args)
+ checkRoles args declaredRoles
+ let args' = zipWith (\(v, k, _) r -> (v, k, r)) args declaredRoles
+ putEnv $ env { types = M.insert qualName (kind, DataType dtype args' dctors) (types env) }
+ Just (kind, ExternData _) -> do
+ checkRoleDeclarationArity name declaredRoles (kindArity kind)
+ putEnv $ env { types = M.insert qualName (kind, ExternData declaredRoles) (types env) }
+ _ -> internalError "Unsupported role declaration"
addTypeSynonym
- :: (MonadState CheckState m, MonadError MultipleErrors m)
+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
=> ModuleName
-> ProperName 'TypeName
- -> [(Text, Maybe SourceKind)]
+ -> [(Text, Maybe SourceType)]
+ -> SourceType
-> SourceType
- -> SourceKind
-> m ()
addTypeSynonym moduleName name args ty kind = do
env <- getEnv
checkTypeSynonyms ty
- putEnv $ env { types = M.insert (Qualified (Just moduleName) name) (kind, TypeSynonym) (types env)
- , typeSynonyms = M.insert (Qualified (Just moduleName) name) (args, ty) (typeSynonyms env) }
+ let qualName = Qualified (ByModuleName moduleName) name
+ hasSig = qualName `M.member` types env
+ unless (hasSig || not (containsForAll kind)) $ do
+ tell . errorMessage $ MissingKindDeclaration TypeSynonymSig name kind
+ putEnv $ env { types = M.insert qualName (kind, TypeSynonym) (types env)
+ , typeSynonyms = M.insert qualName (args, ty) (typeSynonyms env) }
valueIsNotDefined
:: (MonadState CheckState m, MonadError MultipleErrors m)
@@ -99,7 +128,7 @@ valueIsNotDefined
-> m ()
valueIsNotDefined moduleName name = do
env <- getEnv
- case M.lookup (Qualified (Just moduleName) name) (names env) of
+ case M.lookup (Qualified (ByModuleName moduleName) name) (names env) of
Just _ -> throwError . errorMessage $ RedefinedIdent name
Nothing -> return ()
@@ -112,55 +141,49 @@ addValue
-> m ()
addValue moduleName name ty nameKind = do
env <- getEnv
- putEnv (env { names = M.insert (Qualified (Just moduleName) name) (ty, nameKind, Defined) (names env) })
+ putEnv (env { names = M.insert (Qualified (ByModuleName moduleName) name) (ty, nameKind, Defined) (names env) })
addTypeClass
:: forall m
- . (MonadState CheckState m, MonadError MultipleErrors m)
- => Qualified (ProperName 'ClassName)
- -> [(Text, Maybe SourceKind)]
+ . (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
+ => ModuleName
+ -> Qualified (ProperName 'ClassName)
+ -> [(Text, Maybe SourceType)]
-> [SourceConstraint]
-> [FunctionalDependency]
-> [Declaration]
+ -> SourceType
-> m ()
-addTypeClass qualifiedClassName args implies dependencies ds = do
+addTypeClass _ qualifiedClassName args implies dependencies ds kind = do
env <- getEnv
- traverse_ (checkMemberIsUsable (typeSynonyms env)) classMembers
- modify $ \st -> st { checkEnv = (checkEnv st) { typeClasses = M.insert qualifiedClassName newClass (typeClasses . checkEnv $ st) } }
+ newClass <- mkNewClass
+ let qualName = fmap coerceProperName qualifiedClassName
+ hasSig = qualName `M.member` types env
+ unless (hasSig || not (containsForAll kind)) $ do
+ tell . errorMessage $ MissingKindDeclaration ClassSig (disqualify qualName) kind
+ putEnv $ env { types = M.insert qualName (kind, ExternData (nominalRolesForKind kind)) (types env)
+ , typeClasses = M.insert qualifiedClassName newClass (typeClasses env) }
where
classMembers :: [(Ident, SourceType)]
classMembers = map toPair ds
- newClass :: TypeClassData
- newClass = makeTypeClassData args classMembers implies dependencies
-
- coveringSets :: [S.Set Int]
- coveringSets = S.toList (typeClassCoveringSets newClass)
-
- argToIndex :: Text -> Maybe Int
- argToIndex = flip M.lookup $ M.fromList (zipWith ((,) . fst) args [0..])
+ mkNewClass :: m TypeClassData
+ mkNewClass = do
+ env <- getEnv
+ implies' <- (traverse . overConstraintArgs . traverse) replaceAllTypeSynonyms implies
+ let ctIsEmpty = null classMembers && all (typeClassIsEmpty . findSuperClass env) implies'
+ pure $ makeTypeClassData args classMembers implies' dependencies ctIsEmpty
+ where
+ findSuperClass env c = case M.lookup (constraintClass c) (typeClasses env) of
+ Just tcd -> tcd
+ Nothing -> internalError "Unknown super class in TypeClassDeclaration"
toPair (TypeDeclaration (TypeDeclarationData _ ident ty)) = (ident, ty)
toPair _ = internalError "Invalid declaration in TypeClassDeclaration"
- -- Currently we are only checking usability based on the type class currently
- -- being defined. If the mentioned arguments don't include a covering set,
- -- then we won't be able to find a instance.
- checkMemberIsUsable :: T.SynonymMap -> (Ident, SourceType) -> m ()
- checkMemberIsUsable syns (ident, memberTy) = do
- memberTy' <- T.replaceAllTypeSynonymsM syns memberTy
- let mentionedArgIndexes = S.fromList (mapMaybe argToIndex (freeTypeVariables memberTy'))
- let leftovers = map (`S.difference` mentionedArgIndexes) coveringSets
-
- unless (any null leftovers) . throwError . errorMessage $
- let
- solutions = map (map (fst . (args !!)) . S.toList) leftovers
- in
- UnusableDeclaration ident (nub solutions)
-
addTypeClassDictionaries
:: (MonadState CheckState m)
- => Maybe ModuleName
+ => QualifiedBy
-> M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict))
-> m ()
addTypeClassDictionaries mn entries =
@@ -192,11 +215,11 @@ checkTypeClassInstance cls i = check where
check = \case
TypeVar _ _ -> return ()
TypeLevelString _ _ -> return ()
- TypeConstructor _ ctor -> do
- env <- getEnv
- when (ctor `M.member` typeSynonyms env) . throwError . errorMessage $ TypeSynonymInstance
- return ()
+ TypeLevelInt _ _ -> return ()
+ TypeConstructor _ _ -> return ()
TypeApp _ t1 t2 -> check t1 >> check t2
+ KindApp _ t k -> check t >> check k
+ KindedType _ t _ -> check t
REmpty _ | isFunDepDetermined -> return ()
RCons _ _ hd tl | isFunDepDetermined -> check hd >> check tl
ty -> throwError . errorMessage $ InvalidInstanceHead ty
@@ -219,6 +242,8 @@ checkTypeSynonyms = void . replaceAllTypeSynonyms
--
-- * Type-check all values and add them to the @Environment@
--
+-- * Infer all type roles and add them to the @Environment@
+--
-- * Bring type class instances into scope
--
-- * Process module imports
@@ -227,55 +252,85 @@ typeCheckAll
:: forall m
. (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
=> ModuleName
- -> [DeclarationRef]
-> [Declaration]
-> m [Declaration]
-typeCheckAll moduleName _ = traverse go
+typeCheckAll moduleName = traverse go
where
go :: Declaration -> m Declaration
go (DataDeclaration sa@(ss, _) dtype name args dctors) = do
warnAndRethrow (addHint (ErrorInTypeConstructor name) . addHint (positionedError ss)) $ do
- when (dtype == Newtype) $ checkNewtype name dctors
+ when (dtype == Newtype) $ void $ checkNewtype name dctors
checkDuplicateTypeArguments $ map fst args
- ctorKind <- kindsOf True moduleName name args (concatMap (fmap snd . snd) dctors)
+ (dataCtors, ctorKind) <- kindOfData moduleName (sa, name, args, dctors)
let args' = args `withKinds` ctorKind
- addDataType moduleName dtype name args' dctors ctorKind
+ env <- getEnv
+ dctors' <- traverse (replaceTypeSynonymsInDataConstructor . fst) dataCtors
+ let args'' = args' `withRoles` inferRoles env moduleName name args' dctors'
+ addDataType moduleName dtype name args'' dataCtors ctorKind
return $ DataDeclaration sa dtype name args dctors
- go (d@(DataBindingGroupDeclaration tys)) = do
+ go d@(DataBindingGroupDeclaration tys) = do
let tysList = NEL.toList tys
syns = mapMaybe toTypeSynonym tysList
dataDecls = mapMaybe toDataDecl tysList
- bindingGroupNames = ordNub ((syns^..traverse._2) ++ (dataDecls^..traverse._3))
+ roleDecls = mapMaybe toRoleDecl tysList
+ clss = mapMaybe toClassDecl tysList
+ bindingGroupNames = ordNub ((syns ^.. traverse . _2) ++ (dataDecls ^.. traverse . _2 . _2) ++ fmap coerceProperName (clss ^.. traverse . _2 . _2))
sss = fmap declSourceSpan tys
warnAndRethrow (addHint (ErrorInDataBindingGroup bindingGroupNames) . addHint (PositionedError sss)) $ do
- (syn_ks, data_ks) <- kindsOfAll moduleName syns (map (\(sa, _, name, args, dctors) -> (sa, name, args, concatMap (fmap snd . snd) dctors)) dataDecls)
- for_ (zip dataDecls data_ks) $ \((_, dtype, name, args, dctors), ctorKind) -> do
- when (dtype == Newtype) $ checkNewtype name dctors
- checkDuplicateTypeArguments $ map fst args
- let args' = args `withKinds` ctorKind
- addDataType moduleName dtype name args' dctors ctorKind
- for_ (zip syns syn_ks) $ \((_, name, args, ty), kind) -> do
+ env <- getEnv
+ (syn_ks, data_ks, cls_ks) <- kindsOfAll moduleName syns (fmap snd dataDecls) (fmap snd clss)
+ for_ (zip syns syn_ks) $ \((_, name, args, _), (elabTy, kind)) -> do
checkDuplicateTypeArguments $ map fst args
let args' = args `withKinds` kind
- addTypeSynonym moduleName name args' ty kind
+ addTypeSynonym moduleName name args' elabTy kind
+ let dataDeclsWithKinds = zipWith (\(dtype, (_, name, args, _)) (dataCtors, ctorKind) ->
+ (dtype, name, args `withKinds` ctorKind, dataCtors, ctorKind)) dataDecls data_ks
+ inferRoles' <- fmap (inferDataBindingGroupRoles env moduleName roleDecls) .
+ forM dataDeclsWithKinds $ \(_, name, args, dataCtors, _) ->
+ (name, args,) <$> traverse (replaceTypeSynonymsInDataConstructor . fst) dataCtors
+ for_ dataDeclsWithKinds $ \(dtype, name, args', dataCtors, ctorKind) -> do
+ when (dtype == Newtype) $ void $ checkNewtype name (map fst dataCtors)
+ checkDuplicateTypeArguments $ map fst args'
+ let args'' = args' `withRoles` inferRoles' name args'
+ addDataType moduleName dtype name args'' dataCtors ctorKind
+ for_ roleDecls $ checkRoleDeclaration moduleName
+ for_ (zip clss cls_ks) $ \((deps, (sa, pn, _, _, _)), (args', implies', tys', kind)) -> do
+ let qualifiedClassName = Qualified (ByModuleName moduleName) pn
+ guardWith (errorMessage (DuplicateTypeClass pn (fst sa))) $
+ not (M.member qualifiedClassName (typeClasses env))
+ addTypeClass moduleName qualifiedClassName (fmap Just <$> args') implies' deps tys' kind
return d
where
toTypeSynonym (TypeSynonymDeclaration sa nm args ty) = Just (sa, nm, args, ty)
toTypeSynonym _ = Nothing
- toDataDecl (DataDeclaration sa dtype nm args dctors) = Just (sa, dtype, nm, args, dctors)
+ toDataDecl (DataDeclaration sa dtype nm args dctors) = Just (dtype, (sa, nm, args, dctors))
toDataDecl _ = Nothing
+ toRoleDecl (RoleDeclaration rdd) = Just rdd
+ toRoleDecl _ = Nothing
+ toClassDecl (TypeClassDeclaration sa nm args implies deps decls) = Just (deps, (sa, nm, args, implies, decls))
+ toClassDecl _ = Nothing
go (TypeSynonymDeclaration sa@(ss, _) name args ty) = do
warnAndRethrow (addHint (ErrorInTypeSynonym name) . addHint (positionedError ss) ) $ do
checkDuplicateTypeArguments $ map fst args
- kind <- kindsOf False moduleName name args [ty]
+ (elabTy, kind) <- kindOfTypeSynonym moduleName (sa, name, args, ty)
let args' = args `withKinds` kind
- addTypeSynonym moduleName name args' ty kind
+ addTypeSynonym moduleName name args' elabTy kind
return $ TypeSynonymDeclaration sa name args ty
+ go (KindDeclaration sa@(ss, _) kindFor name ty) = do
+ warnAndRethrow (addHint (ErrorInKindDeclaration name) . addHint (positionedError ss)) $ do
+ elabTy <- withFreshSubstitution $ checkKindDeclaration moduleName ty
+ env <- getEnv
+ putEnv $ env { types = M.insert (Qualified (ByModuleName moduleName) name) (elabTy, LocalTypeVariable) (types env) }
+ return $ KindDeclaration sa kindFor name elabTy
+ go d@(RoleDeclaration rdd) = do
+ checkRoleDeclaration moduleName rdd
+ return d
go TypeDeclaration{} =
internalError "Type declarations should have been removed before typeCheckAlld"
go (ValueDecl sa@(ss, _) name nameKind [] [MkUnguarded val]) = do
env <- getEnv
- warnAndRethrow (addHint (ErrorInValueDeclaration name) . addHint (positionedError ss)) . censorLocalUnnamedWildcards val $ do
+ let declHint = if isPlainIdent name then addHint (ErrorInValueDeclaration name) else id
+ warnAndRethrow (declHint . addHint (positionedError ss)) $ do
val' <- checkExhaustiveExpr ss env moduleName val
valueIsNotDefined moduleName name
typesOf NonRecursiveBindingGroup moduleName [((sa, name), val')] >>= \case
@@ -283,7 +338,6 @@ typeCheckAll moduleName _ = traverse go
addValue moduleName name ty nameKind
return $ ValueDecl sa name nameKind [] [MkUnguarded val'']
_ -> internalError "typesOf did not return a singleton"
- where
go ValueDeclaration{} = internalError "Binders were not desugared"
go BoundValueDeclaration{} = internalError "BoundValueDeclaration should be desugared"
go (BindingGroupDeclaration vals) = do
@@ -301,37 +355,42 @@ typeCheckAll moduleName _ = traverse go
addValue moduleName name ty nameKind
return (sai, nameKind, val)
return . BindingGroupDeclaration $ NEL.fromList vals''
- go (d@(ExternDataDeclaration _ name kind)) = do
- env <- getEnv
- putEnv $ env { types = M.insert (Qualified (Just moduleName) name) (kind, ExternData) (types env) }
- return d
- go (d@(ExternKindDeclaration _ name)) = do
- env <- getEnv
- putEnv $ env { kinds = S.insert (Qualified (Just moduleName) name) (kinds env) }
- return d
- go (d@(ExternDeclaration (ss, _) name ty)) = do
+ go d@(ExternDataDeclaration (ss, _) name kind) = do
+ warnAndRethrow (addHint (ErrorInForeignImportData name) . addHint (positionedError ss)) $ do
+ elabKind <- withFreshSubstitution $ checkKindDeclaration moduleName kind
+ env <- getEnv
+ let qualName = Qualified (ByModuleName moduleName) name
+ roles = nominalRolesForKind elabKind
+ putEnv $ env { types = M.insert qualName (elabKind, ExternData roles) (types env) }
+ return d
+ go d@(ExternDeclaration (ss, _) name ty) = do
warnAndRethrow (addHint (ErrorInForeignImport name) . addHint (positionedError ss)) $ do
env <- getEnv
- kind <- kindOf ty
- guardWith (errorMessage (ExpectedType ty kind)) $ kind == kindType
- case M.lookup (Qualified (Just moduleName) name) (names env) of
+ (elabTy, kind) <- withFreshSubstitution $ do
+ ((unks, ty'), kind) <- kindOfWithUnknowns ty
+ ty'' <- varIfUnknown unks ty'
+ pure (ty'', kind)
+ checkTypeKind elabTy kind
+ case M.lookup (Qualified (ByModuleName moduleName) name) (names env) of
Just _ -> throwError . errorMessage $ RedefinedIdent name
- Nothing -> putEnv (env { names = M.insert (Qualified (Just moduleName) name) (ty, External, Defined) (names env) })
+ Nothing -> putEnv (env { names = M.insert (Qualified (ByModuleName moduleName) name) (elabTy, External, Defined) (names env) })
return d
go d@FixityDeclaration{} = return d
go d@ImportDeclaration{} = return d
- go d@(TypeClassDeclaration (ss, _) pn args implies deps tys) = do
+ go d@(TypeClassDeclaration sa@(ss, _) pn args implies deps tys) = do
warnAndRethrow (addHint (ErrorInTypeClassDeclaration pn) . addHint (positionedError ss)) $ do
env <- getEnv
- let qualifiedClassName = Qualified (Just moduleName) pn
+ let qualifiedClassName = Qualified (ByModuleName moduleName) pn
guardWith (errorMessage (DuplicateTypeClass pn ss)) $
not (M.member qualifiedClassName (typeClasses env))
- addTypeClass qualifiedClassName args implies deps tys
+ (args', implies', tys', kind) <- kindOfClass moduleName (sa, pn, args, implies, tys)
+ addTypeClass moduleName qualifiedClassName (fmap Just <$> args') implies' deps tys' kind
return d
- go (d@(TypeInstanceDeclaration (ss, _) ch idx dictName deps className tys body)) =
+ go (TypeInstanceDeclaration _ _ _ _ (Left _) _ _ _ _) = internalError "typeCheckAll: type class instance generated name should have been desugared"
+ go d@(TypeInstanceDeclaration sa@(ss, _) _ ch idx (Right dictName) deps className tys body) =
rethrow (addHint (ErrorInInstance className tys) . addHint (positionedError ss)) $ do
env <- getEnv
- let qualifiedDictName = Qualified (Just moduleName) dictName
+ let qualifiedDictName = Qualified (ByModuleName moduleName) dictName
flip (traverse_ . traverse_) (typeClassDictionaries env) $ \dictionaries ->
guardWith (errorMessage (DuplicateInstance dictName ss)) $
not (M.member qualifiedDictName dictionaries)
@@ -339,15 +398,19 @@ typeCheckAll moduleName _ = traverse go
Nothing -> internalError "typeCheckAll: Encountered unknown type class in instance declaration"
Just typeClass -> do
checkInstanceArity dictName className typeClass tys
- sequence_ (zipWith (checkTypeClassInstance typeClass) [0..] tys)
- let nonOrphanModules = findNonOrphanModules className typeClass tys
- checkOrphanInstance dictName className tys nonOrphanModules
- let qualifiedChain = Qualified (Just moduleName) <$> ch
- checkOverlappingInstance qualifiedChain dictName className typeClass tys nonOrphanModules
+ (deps', kinds', tys', vars) <- withFreshSubstitution $ checkInstanceDeclaration moduleName (sa, deps, className, tys)
+ tys'' <- traverse replaceAllTypeSynonyms tys'
+ zipWithM_ (checkTypeClassInstance typeClass) [0..] tys''
+ let nonOrphanModules = findNonOrphanModules className typeClass tys''
+ checkOrphanInstance dictName className tys'' nonOrphanModules
+ let chainId = Just ch
+ checkOverlappingInstance ss chainId dictName vars className typeClass tys'' nonOrphanModules
_ <- traverseTypeInstanceBody checkInstanceMembers body
- deps' <- (traverse . overConstraintArgs . traverse) replaceAllTypeSynonyms deps
- let dict = TypeClassDictionaryInScope qualifiedChain idx qualifiedDictName [] className tys (Just deps')
- addTypeClassDictionaries (Just moduleName) . M.singleton className $ M.singleton (tcdValue dict) (pure dict)
+ deps'' <- (traverse . overConstraintArgs . traverse) replaceAllTypeSynonyms deps'
+ let dict =
+ TypeClassDictionaryInScope chainId idx qualifiedDictName [] className vars kinds' tys'' (Just deps'') $
+ if isPlainIdent dictName then Nothing else Just $ srcInstanceType ss vars className tys''
+ addTypeClassDictionaries (ByModuleName moduleName) . M.singleton className $ M.singleton (tcdValue dict) (pure dict)
return d
checkInstanceArity :: Ident -> Qualified (ProperName 'ClassName) -> TypeClassData -> [SourceType] -> m ()
@@ -359,7 +422,9 @@ typeCheckAll moduleName _ = traverse go
checkInstanceMembers :: [Declaration] -> m [Declaration]
checkInstanceMembers instDecls = do
- let idents = sort . map head . group . map memberName $ instDecls
+ let idents = sort
+ . map (headDef $ internalError "checkInstanceMembers: Empty instance declaration list")
+ . group . map memberName $ instDecls
for_ (firstDuplicate idents) $ \ident ->
throwError . errorMessage $ DuplicateValueDeclaration ident
return instDecls
@@ -379,7 +444,7 @@ typeCheckAll moduleName _ = traverse go
-> TypeClassData
-> [SourceType]
-> S.Set ModuleName
- findNonOrphanModules (Qualified (Just mn') _) typeClass tys' = nonOrphanModules
+ findNonOrphanModules (Qualified (ByModuleName mn') _) typeClass tys' = nonOrphanModules
where
nonOrphanModules :: S.Set ModuleName
nonOrphanModules = S.insert mn' nonOrphanModules'
@@ -387,9 +452,12 @@ typeCheckAll moduleName _ = traverse go
typeModule :: SourceType -> Maybe ModuleName
typeModule (TypeVar _ _) = Nothing
typeModule (TypeLevelString _ _) = Nothing
- typeModule (TypeConstructor _ (Qualified (Just mn'') _)) = Just mn''
- typeModule (TypeConstructor _ (Qualified Nothing _)) = internalError "Unqualified type name in findNonOrphanModules"
+ typeModule (TypeLevelInt _ _) = Nothing
+ typeModule (TypeConstructor _ (Qualified (ByModuleName mn'') _)) = Just mn''
+ typeModule (TypeConstructor _ (Qualified (BySourcePos _) _)) = internalError "Unqualified type name in findNonOrphanModules"
typeModule (TypeApp _ t1 _) = typeModule t1
+ typeModule (KindApp _ t1 _) = typeModule t1
+ typeModule (KindedType _ t1 _) = typeModule t1
typeModule _ = internalError "Invalid type in instance in findNonOrphanModules"
modulesByTypeIndex :: M.Map Int (Maybe ModuleName)
@@ -411,31 +479,36 @@ typeCheckAll moduleName _ = traverse go
-- Check that the instance currently being declared doesn't overlap with any
-- other instance in any module that this instance wouldn't be considered an
-- orphan in. There are overlapping instance situations that won't be caught
- -- by this, for example when combining multiparametr type classes with
+ -- by this, for example when combining multiparameter type classes with
-- flexible instances: the instances `Cls X y` and `Cls x Y` overlap and
-- could live in different modules but won't be caught here.
checkOverlappingInstance
- :: [Qualified Ident]
+ :: SourceSpan
+ -> Maybe ChainId
-> Ident
+ -> [(Text, SourceType)]
-> Qualified (ProperName 'ClassName)
-> TypeClassData
-> [SourceType]
-> S.Set ModuleName
-> m ()
- checkOverlappingInstance ch dictName className typeClass tys' nonOrphanModules = do
+ checkOverlappingInstance ss ch dictName vars className typeClass tys' nonOrphanModules = do
for_ nonOrphanModules $ \m -> do
- dicts <- M.toList <$> lookupTypeClassDictionariesForClass (Just m) className
+ dicts <- M.toList <$> lookupTypeClassDictionariesForClass (ByModuleName m) className
- for_ dicts $ \(ident, dictNel) -> do
+ for_ dicts $ \(Qualified mn' ident, dictNel) -> do
for_ dictNel $ \dict -> do
-- ignore instances in the same instance chain
if ch == tcdChain dict ||
instancesAreApart (typeClassCoveringSets typeClass) tys' (tcdInstanceTypes dict)
then return ()
- else throwError . errorMessage $
- OverlappingInstances className
- tys'
- [ident, Qualified (Just moduleName) dictName]
+ else do
+ let this = if isPlainIdent dictName then Right dictName else Left $ srcInstanceType ss vars className tys'
+ let that = Qualified mn' . maybeToLeft ident $ tcdDescription dict
+ throwError . errorMessage $
+ OverlappingInstances className
+ tys'
+ [that, Qualified (ByModuleName moduleName) this]
instancesAreApart
:: S.Set (S.Set Int)
@@ -468,38 +541,38 @@ typeCheckAll moduleName _ = traverse go
| moduleName `S.member` nonOrphanModules = return ()
| otherwise = throwError . errorMessage $ OrphanInstance dictName className nonOrphanModules tys'
- censorLocalUnnamedWildcards :: Expr -> m a -> m a
- censorLocalUnnamedWildcards (TypedValue _ _ ty) = censor (filterErrors (not . isLocalUnnamedWildcardError ty))
- censorLocalUnnamedWildcards _ = id
-
- isLocalUnnamedWildcardError :: SourceType -> ErrorMessage -> Bool
- isLocalUnnamedWildcardError ty err@(ErrorMessage _ (WildcardInferredType _ _)) =
- let
- ssWildcard (TypeWildcard (ss', _) Nothing) = [ss']
- ssWildcard _ = []
- sssWildcards = everythingOnTypes (<>) ssWildcard ty
- sss = maybe [] NEL.toList $ errorSpan err
- in
- null $ intersect sss sssWildcards
- isLocalUnnamedWildcardError _ _ = False
-
- -- |
-- This function adds the argument kinds for a type constructor so that they may appear in the externs file,
-- extracted from the kind of the type constructor itself.
--
- withKinds :: [(Text, Maybe SourceKind)] -> SourceKind -> [(Text, Maybe SourceKind)]
- withKinds [] _ = []
- withKinds (s@(_, Just _ ):ss) (FunKind _ _ k) = s : withKinds ss k
- withKinds ( (s, Nothing):ss) (FunKind _ k1 k2) = (s, Just k1) : withKinds ss k2
- withKinds _ _ = internalError "Invalid arguments to peelKinds"
-
+ withKinds :: [(Text, Maybe SourceType)] -> SourceType -> [(Text, Maybe SourceType)]
+ withKinds [] _ = []
+ withKinds ss (ForAll _ _ _ _ k _) = withKinds ss k
+ withKinds (s@(_, Just _):ss) (TypeApp _ (TypeApp _ tyFn _) k2) | eqType tyFn tyFunction = s : withKinds ss k2
+ withKinds ((s, Nothing):ss) (TypeApp _ (TypeApp _ tyFn k1) k2) | eqType tyFn tyFunction = (s, Just k1) : withKinds ss k2
+ withKinds _ _ = internalError "Invalid arguments to withKinds"
+
+ withRoles :: [(Text, Maybe SourceType)] -> [Role] -> [(Text, Maybe SourceType, Role)]
+ withRoles = zipWith $ \(v, k) r -> (v, k, r)
+
+ replaceTypeSynonymsInDataConstructor :: DataConstructorDeclaration -> m DataConstructorDeclaration
+ replaceTypeSynonymsInDataConstructor DataConstructorDeclaration{..} = do
+ dataCtorFields' <- traverse (traverse replaceAllTypeSynonyms) dataCtorFields
+ return DataConstructorDeclaration
+ { dataCtorFields = dataCtorFields'
+ , ..
+ }
+
+-- | Check that a newtype has just one data constructor with just one field, or
+-- throw an error. If the newtype is valid, this function returns the single
+-- data constructor declaration and the single field, as a 'proof' that the
+-- newtype was indeed a valid newtype.
checkNewtype
:: forall m
. MonadError MultipleErrors m
=> ProperName 'TypeName
- -> [(ProperName 'ConstructorName, [(Ident, SourceType)])]
- -> m ()
-checkNewtype _ [(_, [_])] = return ()
+ -> [DataConstructorDeclaration]
+ -> m (DataConstructorDeclaration, (Ident, SourceType))
+checkNewtype _ [decl@(DataConstructorDeclaration _ _ [field])] = return (decl, field)
checkNewtype name _ = throwError . errorMessage $ InvalidNewtype name
-- |
@@ -509,30 +582,58 @@ checkNewtype name _ = throwError . errorMessage $ InvalidNewtype name
typeCheckModule
:: forall m
. (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
- => Module
+ => M.Map ModuleName Exports
+ -> Module
-> m Module
-typeCheckModule (Module _ _ _ _ Nothing) =
+typeCheckModule _ (Module _ _ _ _ Nothing) =
internalError "exports should have been elaborated before typeCheckModule"
-typeCheckModule (Module ss coms mn decls (Just exps)) =
+typeCheckModule modulesExports (Module ss coms mn decls (Just exps)) =
warnAndRethrow (addHint (ErrorInModule mn)) $ do
- modify (\s -> s { checkCurrentModule = Just mn })
- decls' <- typeCheckAll mn exps decls
+ let (decls', imports) = partitionEithers $ fromImportDecl <$> decls
+ modify (\s -> s { checkCurrentModule = Just mn, checkCurrentModuleImports = imports })
+ decls'' <- typeCheckAll mn $ ignoreWildcardsUnderCompleteTypeSignatures <$> decls'
checkSuperClassesAreExported <- getSuperClassExportCheck
for_ exps $ \e -> do
checkTypesAreExported e
checkClassMembersAreExported e
checkClassesAreExported e
checkSuperClassesAreExported e
- return $ Module ss coms mn decls' (Just exps)
+ checkDataConstructorsAreExported e
+ return $ Module ss coms mn (map toImportDecl imports ++ decls'') (Just exps)
where
+
+ fromImportDecl
+ :: Declaration
+ -> Either Declaration
+ ( SourceAnn
+ , ModuleName
+ , ImportDeclarationType
+ , Maybe ModuleName
+ , M.Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ExportSource)
+ )
+ fromImportDecl (ImportDeclaration sa moduleName importDeclarationType asModuleName) =
+ Right (sa, moduleName, importDeclarationType, asModuleName, foldMap exportedTypes $ M.lookup moduleName modulesExports)
+ fromImportDecl decl = Left decl
+
+ toImportDecl
+ :: ( SourceAnn
+ , ModuleName
+ , ImportDeclarationType
+ , Maybe ModuleName
+ , M.Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ExportSource)
+ )
+ -> Declaration
+ toImportDecl (sa, moduleName, importDeclarationType, asModuleName, _) =
+ ImportDeclaration sa moduleName importDeclarationType asModuleName
+
qualify' :: a -> Qualified a
- qualify' = Qualified (Just mn)
+ qualify' = Qualified (ByModuleName mn)
getSuperClassExportCheck = do
classesToSuperClasses <- gets
( M.map
( S.fromList
- . filter (\(Qualified mn' _) -> mn' == Just mn)
+ . filter (\(Qualified mn' _) -> mn' == ByModuleName mn)
. fmap constraintClass
. typeClassSuperclasses
)
@@ -556,7 +657,7 @@ typeCheckModule (Module ss coms mn decls (Just exps)) =
pure $ checkSuperClassExport superClassesFor transitiveSuperClassesFor
moduleClassExports :: S.Set (Qualified (ProperName 'ClassName))
- moduleClassExports = S.fromList $ mapMaybe (\x -> case x of
+ moduleClassExports = S.fromList $ mapMaybe (\case
TypeClassRef _ name -> Just (qualify' name)
_ -> Nothing) exps
@@ -567,10 +668,11 @@ typeCheckModule (Module ss coms mn decls (Just exps)) =
checkMemberExport extract dr@(TypeRef _ name dctors) = do
env <- getEnv
for_ (M.lookup (qualify' name) (types env)) $ \(k, _) -> do
- let findModuleKinds = everythingOnKinds (++) $ \case
- NamedKind _ (Qualified (Just mn') kindName) | mn' == mn -> [kindName]
- _ -> []
- checkExport dr $ KindRef (declRefSourceSpan dr) <$> findModuleKinds k
+ -- TODO: remove?
+ -- let findModuleKinds = everythingOnTypes (++) $ \case
+ -- TypeConstructor _ (Qualified (ByModuleName mn') kindName) | mn' == mn -> [kindName]
+ -- _ -> []
+ checkExport dr (extract k)
for_ (M.lookup (qualify' name) (typeSynonyms env)) $ \(_, ty) ->
checkExport dr (extract ty)
for_ dctors $ \dctors' ->
@@ -610,7 +712,6 @@ typeCheckModule (Module ss coms mn decls (Just exps)) =
where
exported e = any (exports e) exps
exports (TypeRef _ pn1 _) (TypeRef _ pn2 _) = pn1 == pn2
- exports (KindRef _ pn1) (KindRef _ pn2) = pn1 == pn2
exports (ValueRef _ id1) (ValueRef _ id2) = id1 == id2
exports (TypeClassRef _ pn1) (TypeClassRef _ pn2) = pn1 == pn2
exports _ _ = False
@@ -628,7 +729,7 @@ typeCheckModule (Module ss coms mn decls (Just exps)) =
findTcons :: SourceType -> [DeclarationRef]
findTcons = everythingOnTypes (++) go
where
- go (TypeConstructor _ (Qualified (Just mn') name)) | mn' == mn =
+ go (TypeConstructor _ (Qualified (ByModuleName mn') name)) | mn' == mn =
[TypeRef (declRefSourceSpan ref) name (internalError "Data constructors unused in checkTypesAreExported")]
go _ = []
@@ -643,19 +744,54 @@ typeCheckModule (Module ss coms mn decls (Just exps)) =
go (ConstrainedType _ c _) = (fmap (TypeClassRef (declRefSourceSpan ref)) . extractCurrentModuleClass . constraintClass) c
go _ = []
extractCurrentModuleClass :: Qualified (ProperName 'ClassName) -> [ProperName 'ClassName]
- extractCurrentModuleClass (Qualified (Just mn') name) | mn == mn' = [name]
+ extractCurrentModuleClass (Qualified (ByModuleName mn') name) | mn == mn' = [name]
extractCurrentModuleClass _ = []
checkClassMembersAreExported :: DeclarationRef -> m ()
checkClassMembersAreExported dr@(TypeClassRef ss' name) = do
- let members = ValueRef ss' `map` head (mapMaybe findClassMembers decls)
+ let members = ValueRef ss' `map`
+ (headDef $ internalError "checkClassMembersAreExported: Empty class member list")
+ (mapMaybe findClassMembers decls)
let missingMembers = members \\ exps
unless (null missingMembers) . throwError . errorMessage' ss' $ TransitiveExportError dr missingMembers
where
findClassMembers :: Declaration -> Maybe [Ident]
findClassMembers (TypeClassDeclaration _ name' _ _ _ ds) | name == name' = Just $ map extractMemberName ds
+ findClassMembers (DataBindingGroupDeclaration decls') = headMay . mapMaybe findClassMembers $ NEL.toList decls'
findClassMembers _ = Nothing
extractMemberName :: Declaration -> Ident
extractMemberName (TypeDeclaration td) = tydeclIdent td
extractMemberName _ = internalError "Unexpected declaration in typeclass member list"
checkClassMembersAreExported _ = return ()
+
+ -- If a type is exported without data constructors, we warn on `Generic` or `Newtype` instances.
+ -- On the other hand if any data constructors are exported, we require all of them to be exported.
+ checkDataConstructorsAreExported :: DeclarationRef -> m ()
+ checkDataConstructorsAreExported dr@(TypeRef ss' name (fromMaybe [] -> exportedDataConstructorsNames))
+ | null exportedDataConstructorsNames = for_
+ [ Libs.Generic
+ , Libs.Newtype
+ ] $ \className -> do
+ env <- getEnv
+ let dicts = foldMap (foldMap NEL.toList) $
+ M.lookup (ByModuleName mn) (typeClassDictionaries env) >>= M.lookup className
+ when (any isDictOfTypeRef dicts) $
+ tell . errorMessage' ss' $ HiddenConstructors dr className
+ | otherwise = do
+ env <- getEnv
+ let dataConstructorNames = fromMaybe [] $
+ M.lookup (mkQualified name mn) (types env) >>= getDataConstructorNames . snd
+ missingDataConstructorsNames = dataConstructorNames \\ exportedDataConstructorsNames
+ unless (null missingDataConstructorsNames) $
+ throwError . errorMessage' ss' $ TransitiveDctorExportError dr missingDataConstructorsNames
+ where
+ isDictOfTypeRef :: TypeClassDictionaryInScope a -> Bool
+ isDictOfTypeRef dict
+ | (TypeConstructor _ qualTyName, _, _) : _ <- unapplyTypes <$> tcdInstanceTypes dict
+ , qualTyName == Qualified (ByModuleName mn) name
+ = True
+ isDictOfTypeRef _ = False
+ getDataConstructorNames :: TypeKind -> Maybe [ProperName 'ConstructorName]
+ getDataConstructorNames (DataType _ _ constructors) = Just $ fst <$> constructors
+ getDataConstructorNames _ = Nothing
+ checkDataConstructorsAreExported _ = return ()
diff --git a/src/Language/PureScript/TypeChecker/Deriving.hs b/src/Language/PureScript/TypeChecker/Deriving.hs
new file mode 100644
index 0000000000..eaac3cff51
--- /dev/null
+++ b/src/Language/PureScript/TypeChecker/Deriving.hs
@@ -0,0 +1,837 @@
+{- HLINT ignore "Unused LANGUAGE pragma" -} -- HLint doesn't recognize that TypeApplications is used in a pattern
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE TypeAbstractions #-}
+module Language.PureScript.TypeChecker.Deriving (deriveInstance) where
+
+import Protolude hiding (Type)
+
+import Control.Lens (both, over)
+import Control.Monad.Error.Class (liftEither)
+import Control.Monad.Trans.Writer (Writer, WriterT, runWriter, runWriterT)
+import Control.Monad.Writer.Class (MonadWriter(..))
+import Data.Align (align, unalign)
+import Data.Foldable (foldl1, foldr1)
+import Data.List (init, last, zipWith3, (!!))
+import Data.Map qualified as M
+import Data.These (These(..), mergeTheseWith, these)
+
+import Control.Monad.Supply.Class (MonadSupply)
+import Language.PureScript.AST (Binder(..), CaseAlternative(..), ErrorMessageHint(..), Expr(..), InstanceDerivationStrategy(..), Literal(..), SourceSpan, nullSourceSpan)
+import Language.PureScript.AST.Utils (UnwrappedTypeConstructor(..), lam, lamCase, lamCase2, mkBinder, mkCtor, mkCtorBinder, mkLit, mkRef, mkVar, unguarded, unwrapTypeConstructor, utcQTyCon)
+import Language.PureScript.Constants.Libs qualified as Libs
+import Language.PureScript.Constants.Prim qualified as Prim
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (DataDeclType(..), Environment(..), FunctionalDependency(..), TypeClassData(..), TypeKind(..), kindType, (-:>))
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, errorMessage, internalCompilerError)
+import Language.PureScript.Label (Label(..))
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName(..), Name(..), ProperName(..), ProperNameType(..), Qualified(..), QualifiedBy(..), coerceProperName, freshIdent, qualify)
+import Language.PureScript.PSString (PSString, mkString)
+import Language.PureScript.Sugar.TypeClasses (superClassDictionaryNames)
+import Language.PureScript.TypeChecker.Entailment (InstanceContext, findDicts)
+import Language.PureScript.TypeChecker.Monad (CheckState, getEnv, getTypeClassDictionaries, unsafeCheckCurrentModule)
+import Language.PureScript.TypeChecker.Synonyms (replaceAllTypeSynonyms)
+import Language.PureScript.TypeClassDictionaries (TypeClassDictionaryInScope(..))
+import Language.PureScript.Types (Constraint(..), pattern REmptyKinded, SourceType, Type(..), completeBinderList, eqType, everythingOnTypes, replaceAllTypeVars, srcTypeVar, usedTypeVariables)
+
+-- | Extract the name of the newtype appearing in the last type argument of
+-- a derived newtype instance.
+--
+-- Note: since newtypes in newtype instances can only be applied to type arguments
+-- (no flexible instances allowed), we don't need to bother with unification when
+-- looking for matching superclass instances, which saves us a lot of work. Instead,
+-- we just match the newtype name.
+extractNewtypeName :: ModuleName -> [SourceType] -> Maybe (ModuleName, ProperName 'TypeName)
+extractNewtypeName mn
+ = fmap (qualify mn . utcQTyCon)
+ . (unwrapTypeConstructor <=< lastMay)
+
+deriveInstance
+ :: forall m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => MonadSupply m
+ => MonadWriter MultipleErrors m
+ => SourceType
+ -> Qualified (ProperName 'ClassName)
+ -> InstanceDerivationStrategy
+ -> m Expr
+deriveInstance instType className strategy = do
+ mn <- unsafeCheckCurrentModule
+ env <- getEnv
+ instUtc@UnwrappedTypeConstructor{ utcArgs = tys } <- maybe (internalCompilerError "invalid instance type") pure $ unwrapTypeConstructor instType
+ let ctorName = coerceProperName <$> utcQTyCon instUtc
+
+ TypeClassData{..} <-
+ note (errorMessage . UnknownName $ fmap TyClassName className) $
+ className `M.lookup` typeClasses env
+
+ case strategy of
+ KnownClassStrategy -> let
+ unaryClass :: (UnwrappedTypeConstructor -> m [(PSString, Expr)]) -> m Expr
+ unaryClass f = case tys of
+ [ty] -> case unwrapTypeConstructor ty of
+ Just utc | mn == utcModuleName utc -> do
+ let superclassesDicts = flip map typeClassSuperclasses $ \(Constraint _ superclass _ suTyArgs _) ->
+ let tyArgs = map (replaceAllTypeVars (zip (map fst typeClassArguments) tys)) suTyArgs
+ in lam UnusedIdent (DeferredDictionary superclass tyArgs)
+ let superclasses = map mkString (superClassDictionaryNames typeClassSuperclasses) `zip` superclassesDicts
+ App (Constructor nullSourceSpan ctorName) . mkLit . ObjectLiteral . (++ superclasses) <$> f utc
+ _ -> throwError . errorMessage $ ExpectedTypeConstructor className tys ty
+ _ -> throwError . errorMessage $ InvalidDerivedInstance className tys 1
+
+ unaryClass' f = unaryClass (f className)
+
+ in case className of
+ Libs.Bifoldable -> unaryClass' $ deriveFoldable True
+ Libs.Bifunctor -> unaryClass' $ deriveFunctor (Just False) False Libs.S_bimap
+ Libs.Bitraversable -> unaryClass' $ deriveTraversable True
+ Libs.Contravariant -> unaryClass' $ deriveFunctor Nothing True Libs.S_cmap
+ Libs.Eq -> unaryClass deriveEq
+ Libs.Eq1 -> unaryClass $ const deriveEq1
+ Libs.Foldable -> unaryClass' $ deriveFoldable False
+ Libs.Functor -> unaryClass' $ deriveFunctor Nothing False Libs.S_map
+ Libs.Ord -> unaryClass deriveOrd
+ Libs.Ord1 -> unaryClass $ const deriveOrd1
+ Libs.Profunctor -> unaryClass' $ deriveFunctor (Just True) False Libs.S_dimap
+ Libs.Traversable -> unaryClass' $ deriveTraversable False
+ -- See L.P.Sugar.TypeClasses.Deriving for the classes that can be
+ -- derived prior to type checking.
+ _ -> throwError . errorMessage $ CannotDerive className tys
+
+ NewtypeStrategy ->
+ case tys of
+ _ : _ | Just utc <- unwrapTypeConstructor (last tys)
+ , mn == utcModuleName utc
+ -> deriveNewtypeInstance className tys utc
+ | otherwise -> throwError . errorMessage $ ExpectedTypeConstructor className tys (last tys)
+ _ -> throwError . errorMessage $ InvalidNewtypeInstance className tys
+
+deriveNewtypeInstance
+ :: forall m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => MonadWriter MultipleErrors m
+ => Qualified (ProperName 'ClassName)
+ -> [SourceType]
+ -> UnwrappedTypeConstructor
+ -> m Expr
+deriveNewtypeInstance className tys (UnwrappedTypeConstructor mn tyConNm dkargs dargs) = do
+ verifySuperclasses
+ (dtype, tyKindNames, tyArgNames, ctors) <- lookupTypeDecl mn tyConNm
+ go dtype tyKindNames tyArgNames ctors
+ where
+ go (Just Newtype) tyKindNames tyArgNames [(_, [wrapped])] = do
+ -- The newtype might not be applied to all type arguments.
+ -- This is okay as long as the newtype wraps something which ends with
+ -- sufficiently many type applications to variables.
+ -- For example, we can derive Functor for
+ --
+ -- newtype MyArray a = MyArray (Array a)
+ --
+ -- since Array a is a type application which uses the last
+ -- type argument
+ wrapped' <- replaceAllTypeSynonyms wrapped
+ case stripRight (takeReverse (length tyArgNames - length dargs) tyArgNames) wrapped' of
+ Just wrapped'' -> do
+ let subst = zipWith (\(name, _) t -> (name, t)) tyArgNames dargs <> zip tyKindNames dkargs
+ wrapped''' <- replaceAllTypeSynonyms $ replaceAllTypeVars subst wrapped''
+ tys' <- mapM replaceAllTypeSynonyms tys
+ return (DeferredDictionary className (init tys' ++ [wrapped''']))
+ Nothing -> throwError . errorMessage $ InvalidNewtypeInstance className tys
+ go _ _ _ _ = throwError . errorMessage $ InvalidNewtypeInstance className tys
+
+ takeReverse :: Int -> [a] -> [a]
+ takeReverse n = take n . reverse
+
+ stripRight :: [(Text, Maybe kind)] -> SourceType -> Maybe SourceType
+ stripRight [] ty = Just ty
+ stripRight ((arg, _) : args) (TypeApp _ t (TypeVar _ arg'))
+ | arg == arg' = stripRight args t
+ stripRight _ _ = Nothing
+
+ verifySuperclasses :: m ()
+ verifySuperclasses = do
+ env <- getEnv
+ for_ (M.lookup className (typeClasses env)) $ \TypeClassData{ typeClassArguments = args, typeClassSuperclasses = superclasses } ->
+ for_ superclasses $ \Constraint{..} -> do
+ let constraintClass' = qualify (internalError "verifySuperclasses: unknown class module") constraintClass
+ for_ (M.lookup constraintClass (typeClasses env)) $ \TypeClassData{ typeClassDependencies = deps } ->
+ -- We need to check whether the newtype is mentioned, because of classes like MonadWriter
+ -- with its Monoid superclass constraint.
+ when (not (null args) && any ((fst (last args) `elem`) . usedTypeVariables) constraintArgs) $ do
+ -- For now, we only verify superclasses where the newtype is the only argument,
+ -- or for which all other arguments are determined by functional dependencies.
+ -- Everything else raises a UnverifiableSuperclassInstance warning.
+ -- This covers pretty much all cases we're interested in, but later we might want to do
+ -- more work to extend this to other superclass relationships.
+ let determined = map (srcTypeVar . fst . (args !!)) . ordNub . concatMap fdDetermined . filter ((== [length args - 1]) . fdDeterminers) $ deps
+ if eqType (last constraintArgs) (srcTypeVar . fst $ last args) && all (`elem` determined) (init constraintArgs)
+ then do
+ -- Now make sure that a superclass instance was derived. Again, this is not a complete
+ -- check, since the superclass might have multiple type arguments, so overlaps might still
+ -- be possible, so we warn again.
+ for_ (extractNewtypeName mn tys) $ \nm -> do
+ unless (hasNewtypeSuperclassInstance constraintClass' nm (typeClassDictionaries env)) $
+ tell . errorMessage $ MissingNewtypeSuperclassInstance constraintClass className tys
+ else tell . errorMessage $ UnverifiableSuperclassInstance constraintClass className tys
+
+ -- Note that this check doesn't actually verify that the superclass is
+ -- newtype-derived; see #3168. The whole verifySuperclasses feature
+ -- is pretty sketchy, and could use a thorough review and probably rewrite.
+ hasNewtypeSuperclassInstance (suModule, suClass) nt@(newtypeModule, _) dicts =
+ let su = Qualified (ByModuleName suModule) suClass
+ lookIn mn'
+ = elem nt
+ . (toList . extractNewtypeName mn' . tcdInstanceTypes
+ <=< foldMap toList . M.elems
+ <=< toList . (M.lookup su <=< M.lookup (ByModuleName mn')))
+ $ dicts
+ in lookIn suModule || lookIn newtypeModule
+
+data TypeInfo = TypeInfo
+ { tiTypeParams :: [Text]
+ , tiCtors :: [(ProperName 'ConstructorName, [SourceType])]
+ , tiArgSubst :: [(Text, SourceType)]
+ }
+
+lookupTypeInfo
+ :: forall m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => UnwrappedTypeConstructor
+ -> m TypeInfo
+lookupTypeInfo UnwrappedTypeConstructor{..} = do
+ (_, kindParams, map fst -> tiTypeParams, tiCtors) <- lookupTypeDecl utcModuleName utcTyCon
+ let tiArgSubst = zip tiTypeParams utcArgs <> zip kindParams utcKindArgs
+ pure TypeInfo{..}
+
+deriveEq
+ :: forall m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => MonadSupply m
+ => UnwrappedTypeConstructor
+ -> m [(PSString, Expr)]
+deriveEq utc = do
+ TypeInfo{..} <- lookupTypeInfo utc
+ eqFun <- mkEqFunction tiCtors
+ pure [(Libs.S_eq, eqFun)]
+ where
+ mkEqFunction :: [(ProperName 'ConstructorName, [SourceType])] -> m Expr
+ mkEqFunction ctors = do
+ x <- freshIdent "x"
+ y <- freshIdent "y"
+ lamCase2 x y . addCatch <$> mapM mkCtorClause ctors
+
+ preludeConj :: Expr -> Expr -> Expr
+ preludeConj = App . App (mkRef Libs.I_conj)
+
+ preludeEq :: Expr -> Expr -> Expr
+ preludeEq = App . App (mkRef Libs.I_eq)
+
+ preludeEq1 :: Expr -> Expr -> Expr
+ preludeEq1 = App . App (mkRef Libs.I_eq1)
+
+ addCatch :: [CaseAlternative] -> [CaseAlternative]
+ addCatch xs
+ | length xs /= 1 = xs ++ [catchAll]
+ | otherwise = xs -- Avoid redundant case
+ where
+ catchAll = CaseAlternative [NullBinder, NullBinder] (unguarded (mkLit (BooleanLiteral False)))
+
+ mkCtorClause :: (ProperName 'ConstructorName, [SourceType]) -> m CaseAlternative
+ mkCtorClause (ctorName, tys) = do
+ identsL <- replicateM (length tys) (freshIdent "l")
+ identsR <- replicateM (length tys) (freshIdent "r")
+ tys' <- mapM replaceAllTypeSynonyms tys
+ let tests = zipWith3 toEqTest (map mkVar identsL) (map mkVar identsR) tys'
+ return $ CaseAlternative [caseBinder identsL, caseBinder identsR] (unguarded (conjAll tests))
+ where
+ caseBinder idents = mkCtorBinder (utcModuleName utc) ctorName $ map mkBinder idents
+
+ conjAll :: [Expr] -> Expr
+ conjAll = \case
+ [] -> mkLit (BooleanLiteral True)
+ xs -> foldl1 preludeConj xs
+
+ toEqTest :: Expr -> Expr -> SourceType -> Expr
+ toEqTest l r ty
+ | Just fields <- decomposeRec <=< objectType $ ty
+ = conjAll
+ . map (\(Label str, typ) -> toEqTest (Accessor str l) (Accessor str r) typ)
+ $ fields
+ | isAppliedVar ty = preludeEq1 l r
+ | otherwise = preludeEq l r
+
+deriveEq1 :: forall m. Applicative m => m [(PSString, Expr)]
+deriveEq1 = pure [(Libs.S_eq1, mkRef Libs.I_eq)]
+
+deriveOrd
+ :: forall m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => MonadSupply m
+ => UnwrappedTypeConstructor
+ -> m [(PSString, Expr)]
+deriveOrd utc = do
+ TypeInfo{..} <- lookupTypeInfo utc
+ compareFun <- mkCompareFunction tiCtors
+ pure [(Libs.S_compare, compareFun)]
+ where
+ mkCompareFunction :: [(ProperName 'ConstructorName, [SourceType])] -> m Expr
+ mkCompareFunction ctors = do
+ x <- freshIdent "x"
+ y <- freshIdent "y"
+ lamCase2 x y <$> (addCatch . concat <$> mapM mkCtorClauses (splitLast ctors))
+
+ splitLast :: [a] -> [(a, Bool)]
+ splitLast [] = []
+ splitLast [x] = [(x, True)]
+ splitLast (x : xs) = (x, False) : splitLast xs
+
+ addCatch :: [CaseAlternative] -> [CaseAlternative]
+ addCatch xs
+ | null xs = [catchAll] -- No type constructors
+ | otherwise = xs
+ where
+ catchAll = CaseAlternative [NullBinder, NullBinder] (unguarded (orderingCtor "EQ"))
+
+ orderingMod :: ModuleName
+ orderingMod = ModuleName "Data.Ordering"
+
+ orderingCtor :: Text -> Expr
+ orderingCtor = mkCtor orderingMod . ProperName
+
+ orderingBinder :: Text -> Binder
+ orderingBinder name = mkCtorBinder orderingMod (ProperName name) []
+
+ ordCompare :: Expr -> Expr -> Expr
+ ordCompare = App . App (mkRef Libs.I_compare)
+
+ ordCompare1 :: Expr -> Expr -> Expr
+ ordCompare1 = App . App (mkRef Libs.I_compare1)
+
+ mkCtorClauses :: ((ProperName 'ConstructorName, [SourceType]), Bool) -> m [CaseAlternative]
+ mkCtorClauses ((ctorName, tys), isLast) = do
+ identsL <- replicateM (length tys) (freshIdent "l")
+ identsR <- replicateM (length tys) (freshIdent "r")
+ tys' <- mapM replaceAllTypeSynonyms tys
+ let tests = zipWith3 toOrdering (map mkVar identsL) (map mkVar identsR) tys'
+ extras | not isLast = [ CaseAlternative [nullCaseBinder, NullBinder] (unguarded (orderingCtor "LT"))
+ , CaseAlternative [NullBinder, nullCaseBinder] (unguarded (orderingCtor "GT"))
+ ]
+ | otherwise = []
+ return $ CaseAlternative [ caseBinder identsL
+ , caseBinder identsR
+ ]
+ (unguarded (appendAll tests))
+ : extras
+
+ where
+ mn = utcModuleName utc
+ caseBinder idents = mkCtorBinder mn ctorName $ map mkBinder idents
+ nullCaseBinder = mkCtorBinder mn ctorName $ replicate (length tys) NullBinder
+
+ appendAll :: [Expr] -> Expr
+ appendAll = \case
+ [] -> orderingCtor "EQ"
+ [x] -> x
+ (x : xs) -> Case [x] [ CaseAlternative [orderingBinder "LT"] (unguarded (orderingCtor "LT"))
+ , CaseAlternative [orderingBinder "GT"] (unguarded (orderingCtor "GT"))
+ , CaseAlternative [NullBinder] (unguarded (appendAll xs))
+ ]
+
+ toOrdering :: Expr -> Expr -> SourceType -> Expr
+ toOrdering l r ty
+ | Just fields <- decomposeRec <=< objectType $ ty
+ = appendAll
+ . map (\(Label str, typ) -> toOrdering (Accessor str l) (Accessor str r) typ)
+ $ fields
+ | isAppliedVar ty = ordCompare1 l r
+ | otherwise = ordCompare l r
+
+deriveOrd1 :: forall m. Applicative m => m [(PSString, Expr)]
+deriveOrd1 = pure [(Libs.S_compare1, mkRef Libs.I_compare)]
+
+lookupTypeDecl
+ :: forall m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => ModuleName
+ -> ProperName 'TypeName
+ -> m (Maybe DataDeclType, [Text], [(Text, Maybe SourceType)], [(ProperName 'ConstructorName, [SourceType])])
+lookupTypeDecl mn typeName = do
+ env <- getEnv
+ note (errorMessage $ CannotFindDerivingType typeName) $ do
+ (kind, DataType _ args dctors) <- Qualified (ByModuleName mn) typeName `M.lookup` types env
+ (kargs, _) <- completeBinderList kind
+ let dtype = do
+ (ctorName, _) <- headMay dctors
+ (a, _, _, _) <- Qualified (ByModuleName mn) ctorName `M.lookup` dataConstructors env
+ pure a
+ pure (dtype, fst . snd <$> kargs, map (\(v, k, _) -> (v, k)) args, dctors)
+
+isAppliedVar :: Type a -> Bool
+isAppliedVar (TypeApp _ (TypeVar _ _) _) = True
+isAppliedVar _ = False
+
+objectType :: Type a -> Maybe (Type a)
+objectType (TypeApp _ (TypeConstructor _ Prim.Record) rec) = Just rec
+objectType _ = Nothing
+
+decomposeRec :: SourceType -> Maybe [(Label, SourceType)]
+decomposeRec = fmap (sortOn fst) . go
+ where go (RCons _ str typ typs) = fmap ((str, typ) :) (go typs)
+ go (REmptyKinded _ _) = Just []
+ go _ = Nothing
+
+decomposeRec' :: SourceType -> [(Label, SourceType)]
+decomposeRec' = sortOn fst . go
+ where go (RCons _ str typ typs) = (str, typ) : go typs
+ go _ = []
+
+-- | The parameter `c` is used to allow or forbid contravariance for different
+-- type classes. When deriving a type class that is a variation on Functor, a
+-- witness for `c` will be provided; when deriving a type class that is a
+-- variation on Foldable or Traversable, `c` will be Void and the contravariant
+-- ParamUsage constructor can be skipped in pattern matching.
+data ParamUsage c
+ = IsParam
+ | IsLParam
+ -- ^ enables biparametric classes (of any variance) to be derived
+ | MentionsParam (ParamUsage c)
+ -- ^ enables monoparametric classes to be used in a derivation
+ | MentionsParamBi (These (ParamUsage c) (ParamUsage c))
+ -- ^ enables biparametric classes to be used in a derivation
+ | MentionsParamContravariantly !c (ContravariantParamUsage c)
+ -- ^ enables contravariant classes (of either parametricity) to be used in a derivation
+ | IsRecord (NonEmpty (PSString, ParamUsage c))
+
+data ContravariantParamUsage c
+ = MentionsParamContra (ParamUsage c)
+ -- ^ enables Contravariant to be used in a derivation
+ | MentionsParamPro (These (ParamUsage c) (ParamUsage c))
+ -- ^ enables Profunctor to be used in a derivation
+
+data CovariantClasses = CovariantClasses
+ { monoClass :: Qualified (ProperName 'ClassName)
+ , biClass :: Qualified (ProperName 'ClassName)
+ }
+
+data ContravariantClasses = ContravariantClasses
+ { contraClass :: Qualified (ProperName 'ClassName)
+ , proClass :: Qualified (ProperName 'ClassName)
+ }
+
+data ContravarianceSupport c = ContravarianceSupport
+ { contravarianceWitness :: c
+ , paramIsContravariant :: Bool
+ , lparamIsContravariant :: Bool
+ , contravariantClasses :: ContravariantClasses
+ }
+
+-- | Return, if possible, a These the contents of which each satisfy the
+-- predicate.
+filterThese :: forall a. (a -> Bool) -> These a a -> Maybe (These a a)
+filterThese p = uncurry align . over both (mfilter p) . unalign . Just
+
+validateParamsInTypeConstructors
+ :: forall c m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => Qualified (ProperName 'ClassName)
+ -> UnwrappedTypeConstructor
+ -> Bool
+ -> CovariantClasses
+ -> Maybe (ContravarianceSupport c)
+ -> m [(ProperName 'ConstructorName, [Maybe (ParamUsage c)])]
+validateParamsInTypeConstructors derivingClass utc isBi CovariantClasses{..} contravarianceSupport = do
+ TypeInfo{..} <- lookupTypeInfo utc
+ (mbLParam, param) <- liftEither . first (errorMessage . flip KindsDoNotUnify kindType . (kindType -:>)) $
+ case (isBi, reverse tiTypeParams) of
+ (False, x : _) -> Right (Nothing, x)
+ (False, _) -> Left kindType
+ (True, y : x : _) -> Right (Just x, y)
+ (True, _ : _) -> Left kindType
+ (True, _) -> Left $ kindType -:> kindType
+ ctors <- traverse (traverse $ traverse replaceAllTypeSynonyms) tiCtors
+ tcds <- getTypeClassDictionaries
+ let (ctorUsages, problemSpans) = runWriter $ traverse (traverse . traverse $ typeToUsageOf tcds tiArgSubst (maybe That These mbLParam param) False) ctors
+ let relatedClasses = [monoClass, biClass] ++ ([contraClass, proClass] <*> (contravariantClasses <$> toList contravarianceSupport))
+ for_ (nonEmpty $ ordNub problemSpans) $ \sss ->
+ throwError . addHint (RelatedPositions sss) . errorMessage $ CannotDeriveInvalidConstructorArg derivingClass relatedClasses (isJust contravarianceSupport)
+ pure ctorUsages
+
+ where
+ typeToUsageOf :: InstanceContext -> [(Text, SourceType)] -> These Text Text -> Bool -> SourceType -> Writer [SourceSpan] (Maybe (ParamUsage c))
+ typeToUsageOf tcds subst = fix $ \go params isNegative -> let
+ goCo = go params isNegative
+ goContra = go params $ not isNegative
+
+ assertNoParamUsedIn :: SourceType -> Writer [SourceSpan] ()
+ assertNoParamUsedIn ty = void $ both (flip assertParamNotUsedIn ty) params
+
+ assertParamNotUsedIn :: Text -> SourceType -> Writer [SourceSpan] ()
+ assertParamNotUsedIn param = everythingOnTypes (*>) $ \case
+ TypeVar (ss, _) name | name == param -> tell [ss]
+ _ -> pure ()
+
+ tryBiClasses ht tyLArg tyArg
+ | hasInstance tcds ht biClass
+ = goCo tyLArg >>= preferMonoClass MentionsParamBi
+ | Just (ContravarianceSupport c _ _ ContravariantClasses{..}) <- contravarianceSupport, hasInstance tcds ht proClass
+ = goContra tyLArg >>= preferMonoClass (MentionsParamContravariantly c . MentionsParamPro)
+ | otherwise
+ = assertNoParamUsedIn tyLArg *> tryMonoClasses ht tyArg
+ where
+ preferMonoClass f lUsage =
+ (if isNothing lUsage && hasInstance tcds ht monoClass then fmap MentionsParam else fmap f . align lUsage) <$> goCo tyArg
+
+ tryMonoClasses ht tyArg
+ | hasInstance tcds ht monoClass
+ = fmap MentionsParam <$> goCo tyArg
+ | Just (ContravarianceSupport c _ _ ContravariantClasses{..}) <- contravarianceSupport, hasInstance tcds ht contraClass
+ = fmap (MentionsParamContravariantly c . MentionsParamContra) <$> goContra tyArg
+ | otherwise
+ = assertNoParamUsedIn tyArg $> Nothing
+
+ headOfTypeWithSubst :: SourceType -> Qualified (Either Text (ProperName 'TypeName))
+ headOfTypeWithSubst = headOfType . replaceAllTypeVars subst
+
+ in \case
+ ForAll _ _ name _ ty _ ->
+ fmap join . traverse (\params' -> go params' isNegative ty) $ filterThese (/= name) params
+
+ ConstrainedType _ _ ty ->
+ goCo ty
+
+ TypeApp _ (TypeConstructor _ Prim.Record) row ->
+ fmap (fmap IsRecord . nonEmpty . catMaybes) . for (decomposeRec' row) $ \(Label lbl, ty) ->
+ fmap (lbl, ) <$> goCo ty
+
+ TypeApp _ (TypeApp _ tyFn tyLArg) tyArg ->
+ assertNoParamUsedIn tyFn *> tryBiClasses (headOfTypeWithSubst tyFn) tyLArg tyArg
+
+ TypeApp _ tyFn tyArg ->
+ assertNoParamUsedIn tyFn *> tryMonoClasses (headOfTypeWithSubst tyFn) tyArg
+
+ TypeVar (ss, _) name -> mergeTheseWith (checkName lparamIsContra IsLParam) (checkName paramIsContra IsParam) (liftA2 (<|>)) params
+ where
+ checkName thisParamIsContra usage param
+ | name == param = when (thisParamIsContra /= isNegative) (tell [ss]) $> Just usage
+ | otherwise = pure Nothing
+
+ ty ->
+ assertNoParamUsedIn ty $> Nothing
+
+ paramIsContra = any paramIsContravariant contravarianceSupport
+ lparamIsContra = any lparamIsContravariant contravarianceSupport
+
+ hasInstance :: InstanceContext -> Qualified (Either Text (ProperName 'TypeName)) -> Qualified (ProperName 'ClassName) -> Bool
+ hasInstance tcds ht@(Qualified qb _) cn@(Qualified cqb _) =
+ any (any tcdAppliesToType . findDicts tcds cn) (ordNub [ByNullSourcePos, cqb, qb])
+ where
+ tcdAppliesToType tcd = case tcdInstanceTypes tcd of
+ [headOfType -> ht'] -> ht == ht'
+ -- It's possible that, if ht and ht' are Lefts, this might require
+ -- verifying that the name isn't shadowed by something in tcdForAll. I
+ -- can't devise a legal program that causes this issue, but if in the
+ -- future it seems like a good idea, it probably is.
+ _ -> False
+
+ headOfType :: SourceType -> Qualified (Either Text (ProperName 'TypeName))
+ headOfType = fix $ \go -> \case
+ TypeApp _ ty _ -> go ty
+ KindApp _ ty _ -> go ty
+ TypeVar _ nm -> Qualified ByNullSourcePos (Left nm)
+ Skolem _ nm _ _ _ -> Qualified ByNullSourcePos (Left nm)
+ TypeConstructor _ (Qualified qb nm) -> Qualified qb (Right nm)
+ ty -> internalError $ "headOfType missing a case: " <> show (void ty)
+
+usingLamIdent :: forall m. MonadSupply m => (Expr -> m Expr) -> m Expr
+usingLamIdent cb = do
+ ident <- freshIdent "v"
+ lam ident <$> cb (mkVar ident)
+
+traverseFields :: forall c f. Applicative f => (ParamUsage c -> Expr -> f Expr) -> NonEmpty (PSString, ParamUsage c) -> Expr -> f Expr
+traverseFields f fields r = fmap (ObjectUpdate r) . for (toList fields) $ \(lbl, usage) -> (lbl, ) <$> f usage (Accessor lbl r)
+
+unnestRecords :: forall c f. Applicative f => (ParamUsage c -> Expr -> f Expr) -> ParamUsage c -> Expr -> f Expr
+unnestRecords f = fix $ \go -> \case
+ IsRecord fields -> traverseFields go fields
+ usage -> f usage
+
+mkCasesForTraversal
+ :: forall c f m
+ . Applicative f -- this effect distinguishes the semantics of maps, folds, and traversals
+ => MonadSupply m
+ => ModuleName
+ -> (ParamUsage c -> Expr -> f Expr) -- how to handle constructor arguments
+ -> (f Expr -> m Expr) -- resolve the applicative effect into an expression
+ -> [(ProperName 'ConstructorName, [Maybe (ParamUsage c)])]
+ -> m Expr
+mkCasesForTraversal mn handleArg extractExpr ctors = do
+ m <- freshIdent "m"
+ fmap (lamCase m) . for ctors $ \(ctorName, ctorUsages) -> do
+ ctorArgs <- for ctorUsages $ \usage -> freshIdent "v" <&> (, usage)
+ let ctor = mkCtor mn ctorName
+ let caseBinder = mkCtorBinder mn ctorName $ map (mkBinder . fst) ctorArgs
+ fmap (CaseAlternative [caseBinder] . unguarded) . extractExpr $
+ fmap (foldl' App ctor) . for ctorArgs $ \(ident, mbUsage) -> maybe pure handleArg mbUsage $ mkVar ident
+
+data TraversalExprs = TraversalExprs
+ { recurseVar :: Expr -- a var representing map, foldMap, or traverse, for handling structured values
+ , birecurseVar :: Expr -- same, but bimap, bifoldMap, or bitraverse
+ , lrecurseExpr :: Expr -- same, but lmap or ltraverse (there is no lfoldMap, but we can use `flip bifoldMap mempty`)
+ , rrecurseExpr :: Expr -- same, but rmap or rtraverse etc., which conceptually should be the same as recurseVar but the bi classes aren't subclasses of the mono classes
+ }
+
+data ContraversalExprs = ContraversalExprs
+ { crecurseVar :: Expr
+ , direcurseVar :: Expr
+ , lcrecurseVar :: Expr
+ , rprorecurseVar :: Expr
+ }
+
+appBirecurseExprs :: TraversalExprs -> These Expr Expr -> Expr
+appBirecurseExprs TraversalExprs{..} = these (App lrecurseExpr) (App rrecurseExpr) (App . App birecurseVar)
+
+appDirecurseExprs :: ContraversalExprs -> These Expr Expr -> Expr
+appDirecurseExprs ContraversalExprs{..} = these (App lcrecurseVar) (App rprorecurseVar) (App . App direcurseVar)
+
+data TraversalOps m = forall f. Applicative f => TraversalOps
+ { visitExpr :: m Expr -> f Expr -- lift an expression into the applicative effect defining the traversal
+ , extractExpr :: f Expr -> m Expr -- resolve the applicative effect into an expression
+ }
+
+mkTraversal
+ :: forall c m
+ . MonadSupply m
+ => ModuleName
+ -> Bool
+ -> TraversalExprs
+ -> (c -> ContraversalExprs)
+ -> TraversalOps m
+ -> [(ProperName 'ConstructorName, [Maybe (ParamUsage c)])]
+ -> m Expr
+mkTraversal mn isBi te@TraversalExprs{..} getContraversalExprs (TraversalOps @_ @f visitExpr extractExpr) ctors = do
+ f <- freshIdent "f"
+ g <- if isBi then freshIdent "g" else pure f
+ let
+ handleValue :: ParamUsage c -> Expr -> f Expr
+ handleValue = unnestRecords $ \usage inputExpr -> visitExpr $ flip App inputExpr <$> mkFnExprForValue usage
+
+ mkFnExprForValue :: ParamUsage c -> m Expr
+ mkFnExprForValue = \case
+ IsParam ->
+ pure $ mkVar g
+ IsLParam ->
+ pure $ mkVar f
+ MentionsParam innerUsage ->
+ App recurseVar <$> mkFnExprForValue innerUsage
+ MentionsParamBi theseInnerUsages ->
+ appBirecurseExprs te <$> both mkFnExprForValue theseInnerUsages
+ MentionsParamContravariantly c contraUsage -> do
+ let ce@ContraversalExprs{..} = getContraversalExprs c
+ case contraUsage of
+ MentionsParamContra innerUsage ->
+ App crecurseVar <$> mkFnExprForValue innerUsage
+ MentionsParamPro theseInnerUsages ->
+ appDirecurseExprs ce <$> both mkFnExprForValue theseInnerUsages
+ IsRecord fields ->
+ usingLamIdent $ extractExpr . traverseFields handleValue fields
+
+ lam f . applyWhen isBi (lam g) <$> mkCasesForTraversal mn handleValue extractExpr ctors
+
+deriveFunctor
+ :: forall m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => MonadSupply m
+ => Maybe Bool -- does left parameter exist, and is it contravariant?
+ -> Bool -- is the (right) parameter contravariant?
+ -> PSString -- name of the map function for this functor type
+ -> Qualified (ProperName 'ClassName)
+ -> UnwrappedTypeConstructor
+ -> m [(PSString, Expr)]
+deriveFunctor mbLParamIsContravariant paramIsContravariant mapName nm utc = do
+ ctors <- validateParamsInTypeConstructors nm utc isBi functorClasses $ Just $ ContravarianceSupport
+ { contravarianceWitness = ()
+ , paramIsContravariant
+ , lparamIsContravariant = or mbLParamIsContravariant
+ , contravariantClasses
+ }
+ mapFun <- mkTraversal (utcModuleName utc) isBi mapExprs (const cmapExprs) (TraversalOps identity identity) ctors
+ pure [(mapName, mapFun)]
+ where
+ isBi = isJust mbLParamIsContravariant
+ mapExprs = TraversalExprs
+ { recurseVar = mkRef Libs.I_map
+ , birecurseVar = mkRef Libs.I_bimap
+ , lrecurseExpr = mkRef Libs.I_lmap
+ , rrecurseExpr = mkRef Libs.I_rmap
+ }
+ cmapExprs = ContraversalExprs
+ { crecurseVar = mkRef Libs.I_cmap
+ , direcurseVar = mkRef Libs.I_dimap
+ , lcrecurseVar = mkRef Libs.I_lcmap
+ , rprorecurseVar = mkRef Libs.I_profunctorRmap
+ }
+ functorClasses = CovariantClasses Libs.Functor Libs.Bifunctor
+ contravariantClasses = ContravariantClasses Libs.Contravariant Libs.Profunctor
+
+toConst :: forall f a b. f a -> Const [f a] b
+toConst = Const . pure
+
+consumeConst :: forall f a b c. Applicative f => ([a] -> b) -> Const [f a] c -> f b
+consumeConst f = fmap f . sequenceA . getConst
+
+applyWhen :: forall a. Bool -> (a -> a) -> a -> a
+applyWhen cond f = if cond then f else identity
+
+deriveFoldable
+ :: forall m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => MonadSupply m
+ => Bool -- is there a left parameter (are we deriving Bifoldable)?
+ -> Qualified (ProperName 'ClassName)
+ -> UnwrappedTypeConstructor
+ -> m [(PSString, Expr)]
+deriveFoldable isBi nm utc = do
+ ctors <- validateParamsInTypeConstructors nm utc isBi foldableClasses Nothing
+ foldlFun <- mkAsymmetricFoldFunction False foldlExprs ctors
+ foldrFun <- mkAsymmetricFoldFunction True foldrExprs ctors
+ foldMapFun <- mkTraversal mn isBi foldMapExprs absurd foldMapOps ctors
+ pure
+ [ (if isBi then Libs.S_bifoldl else Libs.S_foldl, foldlFun)
+ , (if isBi then Libs.S_bifoldr else Libs.S_foldr, foldrFun)
+ , (if isBi then Libs.S_bifoldMap else Libs.S_foldMap, foldMapFun)
+ ]
+ where
+ mn = utcModuleName utc
+ foldableClasses = CovariantClasses Libs.Foldable Libs.Bifoldable
+ foldlExprs = TraversalExprs
+ { recurseVar = mkRef Libs.I_foldl
+ , birecurseVar = bifoldlVar
+ , lrecurseExpr = App (App flipVar bifoldlVar) constVar
+ , rrecurseExpr = App bifoldlVar constVar
+ }
+ foldrExprs = TraversalExprs
+ { recurseVar = mkRef Libs.I_foldr
+ , birecurseVar = bifoldrVar
+ , lrecurseExpr = App (App flipVar bifoldrVar) (App constVar identityVar)
+ , rrecurseExpr = App bifoldrVar (App constVar identityVar)
+ }
+ foldMapExprs = TraversalExprs
+ { recurseVar = mkRef Libs.I_foldMap
+ , birecurseVar = bifoldMapVar
+ , lrecurseExpr = App (App flipVar bifoldMapVar) memptyVar
+ , rrecurseExpr = App bifoldMapVar memptyVar
+ }
+ bifoldlVar = mkRef Libs.I_bifoldl
+ bifoldrVar = mkRef Libs.I_bifoldr
+ bifoldMapVar = mkRef Libs.I_bifoldMap
+ constVar = mkRef Libs.I_const
+ flipVar = mkRef Libs.I_flip
+ identityVar = mkRef Libs.I_identity
+ memptyVar = mkRef Libs.I_mempty
+
+ mkAsymmetricFoldFunction :: Bool -> TraversalExprs -> [(ProperName 'ConstructorName, [Maybe (ParamUsage Void)])] -> m Expr
+ mkAsymmetricFoldFunction isRightFold te@TraversalExprs{..} ctors = do
+ f <- freshIdent "f"
+ g <- if isBi then freshIdent "g" else pure f
+ z <- freshIdent "z"
+ let
+ appCombiner :: (Bool, Expr) -> Expr -> Expr -> Expr
+ appCombiner (isFlipped, fn) = applyWhen (isFlipped == isRightFold) flip $ App . App fn
+
+ mkCombinerExpr :: ParamUsage Void -> m Expr
+ mkCombinerExpr = fmap (uncurry $ \isFlipped -> applyWhen isFlipped $ App flipVar) . getCombiner
+
+ handleValue :: ParamUsage Void -> Expr -> Const [m (Expr -> Expr)] Expr
+ handleValue = unnestRecords $ \usage inputExpr -> toConst $ flip appCombiner inputExpr <$> getCombiner usage
+
+ getCombiner :: ParamUsage Void -> m (Bool, Expr)
+ getCombiner = \case
+ IsParam ->
+ pure (False, mkVar g)
+ IsLParam ->
+ pure (False, mkVar f)
+ MentionsParam innerUsage ->
+ (isRightFold, ) . App recurseVar <$> mkCombinerExpr innerUsage
+ MentionsParamBi theseInnerUsages ->
+ (isRightFold, ) . appBirecurseExprs te <$> both mkCombinerExpr theseInnerUsages
+ IsRecord fields -> do
+ let foldFieldsOf = traverseFields handleValue fields
+ fmap (False, ) . usingLamIdent $ \lVar ->
+ usingLamIdent $
+ if isRightFold
+ then flip extractExprStartingWith $ foldFieldsOf lVar
+ else extractExprStartingWith lVar . foldFieldsOf
+
+ extractExprStartingWith :: Expr -> Const [m (Expr -> Expr)] Expr -> m Expr
+ extractExprStartingWith = consumeConst . if isRightFold then foldr ($) else foldl' (&)
+
+ lam f . applyWhen isBi (lam g) . lam z <$> mkCasesForTraversal mn handleValue (extractExprStartingWith $ mkVar z) ctors
+
+foldMapOps :: forall m. Applicative m => TraversalOps m
+foldMapOps = TraversalOps { visitExpr = toConst, .. }
+ where
+ appendVar = mkRef Libs.I_append
+ memptyVar = mkRef Libs.I_mempty
+
+ extractExpr :: Const [m Expr] Expr -> m Expr
+ extractExpr = consumeConst $ \case
+ [] -> memptyVar
+ exprs -> foldr1 (App . App appendVar) exprs
+
+deriveTraversable
+ :: forall m
+ . MonadError MultipleErrors m
+ => MonadState CheckState m
+ => MonadSupply m
+ => Bool -- is there a left parameter (are we deriving Bitraversable)?
+ -> Qualified (ProperName 'ClassName)
+ -> UnwrappedTypeConstructor
+ -> m [(PSString, Expr)]
+deriveTraversable isBi nm utc = do
+ ctors <- validateParamsInTypeConstructors nm utc isBi traversableClasses Nothing
+ traverseFun <- mkTraversal (utcModuleName utc) isBi traverseExprs absurd traverseOps ctors
+ sequenceFun <- usingLamIdent $ pure . App (App (if isBi then App bitraverseVar identityVar else traverseVar) identityVar)
+ pure
+ [ (if isBi then Libs.S_bitraverse else Libs.S_traverse, traverseFun)
+ , (if isBi then Libs.S_bisequence else Libs.S_sequence, sequenceFun)
+ ]
+ where
+ traversableClasses = CovariantClasses Libs.Traversable Libs.Bitraversable
+ traverseExprs = TraversalExprs
+ { recurseVar = traverseVar
+ , birecurseVar = bitraverseVar
+ , lrecurseExpr = mkRef Libs.I_ltraverse
+ , rrecurseExpr = mkRef Libs.I_rtraverse
+ }
+ traverseVar = mkRef Libs.I_traverse
+ bitraverseVar = mkRef Libs.I_bitraverse
+ identityVar = mkRef Libs.I_identity
+
+traverseOps :: forall m. MonadSupply m => TraversalOps m
+traverseOps = TraversalOps { .. }
+ where
+ pureVar = mkRef Libs.I_pure
+ mapVar = mkRef Libs.I_map
+ applyVar = mkRef Libs.I_apply
+
+ visitExpr :: m Expr -> WriterT [(Ident, m Expr)] m Expr
+ visitExpr traversedExpr = do
+ ident <- freshIdent "v"
+ tell [(ident, traversedExpr)] $> mkVar ident
+
+ extractExpr :: WriterT [(Ident, m Expr)] m Expr -> m Expr
+ extractExpr = runWriterT >=> \(result, unzip -> (ctx, args)) -> flip mkApps (foldr lam result ctx) <$> sequenceA args
+
+ mkApps :: [Expr] -> Expr -> Expr
+ mkApps = \case
+ [] -> App pureVar
+ h : t -> \l -> foldl' (App . App applyVar) (App (App mapVar l) h) t
diff --git a/src/Language/PureScript/TypeChecker/Entailment.hs b/src/Language/PureScript/TypeChecker/Entailment.hs
index 23f62f9e34..6cdd98c407 100644
--- a/src/Language/PureScript/TypeChecker/Entailment.hs
+++ b/src/Language/PureScript/TypeChecker/Entailment.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE NamedFieldPuns #-}
-
-- |
-- Type class entailment
--
@@ -9,41 +7,52 @@ module Language.PureScript.TypeChecker.Entailment
, replaceTypeClassDictionaries
, newDictionaries
, entails
+ , findDicts
) where
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
+import Protolude (ordNub, headMay, headDef)
import Control.Arrow (second, (&&&))
import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.State
+import Control.Monad.State (MonadState(..), MonadTrans(..), StateT(..), evalStateT, execStateT, gets, modify)
+import Control.Monad (foldM, guard, join, zipWithM, zipWithM_, (<=<))
import Control.Monad.Supply.Class (MonadSupply(..))
-import Control.Monad.Writer
+import Control.Monad.Writer (MonadWriter(..), WriterT(..))
+import Data.Monoid (Any(..))
+import Data.Either (lefts, partitionEithers)
import Data.Foldable (for_, fold, toList)
import Data.Function (on)
-import Data.Functor (($>))
-import Data.List (minimumBy, groupBy, nubBy, sortBy)
-import Data.Maybe (fromMaybe, mapMaybe)
-import qualified Data.Map as M
-import qualified Data.Set as S
+import Data.Functor (($>), (<&>))
+import Data.List (delete, findIndices, minimumBy, nubBy, sortOn, tails)
+import Data.Maybe (catMaybes, fromMaybe, listToMaybe, mapMaybe)
+import Data.Map qualified as M
+import Data.Set qualified as S
import Data.Traversable (for)
import Data.Text (Text, stripPrefix, stripSuffix)
-import qualified Data.Text as T
-import qualified Data.List.NonEmpty as NEL
-
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Names
-import Language.PureScript.TypeChecker.Monad
-import Language.PureScript.TypeChecker.Unify
-import Language.PureScript.TypeClassDictionaries
+import Data.Text qualified as T
+import Data.List.NonEmpty (NonEmpty(..))
+import Data.List.NonEmpty qualified as NEL
+
+import Language.PureScript.AST (Binder(..), ErrorMessageHint(..), Expr(..), Literal(..), pattern NullSourceSpan, everywhereOnValuesTopDownM, nullSourceSpan, everythingOnValues)
+import Language.PureScript.AST.Declarations (UnknownsHint(..))
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (Environment(..), FunctionalDependency(..), TypeClassData(..), dictTypeName, kindRow, tyBoolean, tyInt, tyString)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHint, addHints, errorMessage, rethrow)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName, ProperName(..), ProperNameType(..), Qualified(..), QualifiedBy(..), byMaybeModuleName, coerceProperName, disqualify, freshIdent, getQual)
+import Language.PureScript.TypeChecker.Entailment.Coercible (GivenSolverState(..), WantedSolverState(..), initialGivenSolverState, initialWantedSolverState, insoluble, solveGivens, solveWanteds)
+import Language.PureScript.TypeChecker.Entailment.IntCompare (mkFacts, mkRelation, solveRelation)
+import Language.PureScript.TypeChecker.Kinds (elaborateKind, unifyKinds')
+import Language.PureScript.TypeChecker.Monad (CheckState(..), withErrorMessageHint)
+import Language.PureScript.TypeChecker.Synonyms (replaceAllTypeSynonyms)
+import Language.PureScript.TypeChecker.Unify (freshTypeWithKind, substituteType, unifyTypes)
+import Language.PureScript.TypeClassDictionaries (NamedDict, TypeClassDictionaryInScope(..), superclassName)
import Language.PureScript.Types
import Language.PureScript.Label (Label(..))
import Language.PureScript.PSString (PSString, mkString, decodeString)
-import qualified Language.PureScript.Constants as C
+import Language.PureScript.Constants.Libs qualified as C
+import Language.PureScript.Constants.Prim qualified as C
-- | Describes what sort of dictionary to generate for type class instances
data Evidence
@@ -53,9 +62,29 @@ data Evidence
-- | Computed instances
| WarnInstance SourceType -- ^ Warn type class with a user-defined warning message
| IsSymbolInstance PSString -- ^ The IsSymbol type class for a given Symbol literal
+ | ReflectableInstance Reflectable -- ^ The Reflectable type class for a reflectable kind
| EmptyClassInstance -- ^ For any solved type class with no members
deriving (Show, Eq)
+-- | Describes kinds that are reflectable to the term-level
+data Reflectable
+ = ReflectableInt Integer -- ^ For type-level numbers
+ | ReflectableString PSString -- ^ For type-level strings
+ | ReflectableBoolean Bool -- ^ For type-level booleans
+ | ReflectableOrdering Ordering -- ^ For type-level orderings
+ deriving (Show, Eq)
+
+-- | Reflect a reflectable type into an expression
+asExpression :: Reflectable -> Expr
+asExpression = \case
+ ReflectableInt n -> Literal NullSourceSpan $ NumericLiteral $ Left n
+ ReflectableString s -> Literal NullSourceSpan $ StringLiteral s
+ ReflectableBoolean b -> Literal NullSourceSpan $ BooleanLiteral b
+ ReflectableOrdering o -> Constructor NullSourceSpan $ case o of
+ LT -> C.C_LT
+ EQ -> C.C_EQ
+ GT -> C.C_GT
+
-- | Extract the identifier of a named instance
namedInstanceIdentifier :: Evidence -> Maybe (Qualified Ident)
namedInstanceIdentifier (NamedInstance i) = Just i
@@ -65,9 +94,12 @@ namedInstanceIdentifier _ = Nothing
type TypeClassDict = TypeClassDictionaryInScope Evidence
-- | The 'InstanceContext' tracks those constraints which can be satisfied.
-type InstanceContext = M.Map (Maybe ModuleName)
+type InstanceContext = M.Map QualifiedBy
(M.Map (Qualified (ProperName 'ClassName))
- (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict)))
+ (M.Map (Qualified Ident) (NonEmpty NamedDict)))
+
+findDicts :: InstanceContext -> Qualified (ProperName 'ClassName) -> QualifiedBy -> [TypeClassDict]
+findDicts ctx cn = fmap (fmap NamedInstance) . foldMap NEL.toList . foldMap M.elems . (M.lookup cn <=< flip M.lookup ctx)
-- | A type substitution which makes an instance head match a list of types.
--
@@ -160,72 +192,98 @@ entails
-- ^ Error message hints to apply to any instance errors
-> WriterT (Any, [(Ident, InstanceContext, SourceConstraint)]) (StateT InstanceContext m) Expr
entails SolverOptions{..} constraint context hints =
- solve constraint
+ overConstraintArgsAll (lift . lift . traverse replaceAllTypeSynonyms) constraint >>= solve
where
- forClassName :: InstanceContext -> Qualified (ProperName 'ClassName) -> [SourceType] -> [TypeClassDict]
- forClassName ctx cn@C.Warn [msg] =
+ forClassNameM :: Environment -> InstanceContext -> Qualified (ProperName 'ClassName) -> [SourceType] -> [SourceType] -> m [TypeClassDict]
+ forClassNameM env ctx cn@C.Coercible kinds args =
+ fromMaybe (forClassName env ctx cn kinds args) <$>
+ solveCoercible env ctx kinds args
+ forClassNameM env ctx cn kinds args =
+ pure $ forClassName env ctx cn kinds args
+
+ forClassName :: Environment -> InstanceContext -> Qualified (ProperName 'ClassName) -> [SourceType] -> [SourceType] -> [TypeClassDict]
+ forClassName _ ctx cn@C.Warn _ [msg] =
-- Prefer a warning dictionary in scope if there is one available.
-- This allows us to defer a warning by propagating the constraint.
- findDicts ctx cn Nothing ++ [TypeClassDictionaryInScope [] 0 (WarnInstance msg) [] C.Warn [msg] Nothing]
- forClassName _ C.IsSymbol args | Just dicts <- solveIsSymbol args = dicts
- forClassName _ C.SymbolCompare args | Just dicts <- solveSymbolCompare args = dicts
- forClassName _ C.SymbolAppend args | Just dicts <- solveSymbolAppend args = dicts
- forClassName _ C.SymbolCons args | Just dicts <- solveSymbolCons args = dicts
- forClassName _ C.RowUnion args | Just dicts <- solveUnion args = dicts
- forClassName _ C.RowNub args | Just dicts <- solveNub args = dicts
- forClassName _ C.RowLacks args | Just dicts <- solveLacks args = dicts
- forClassName _ C.RowCons args | Just dicts <- solveRowCons args = dicts
- forClassName _ C.RowToList args | Just dicts <- solveRowToList args = dicts
- forClassName ctx cn@(Qualified (Just mn) _) tys = concatMap (findDicts ctx cn) (ordNub (Nothing : Just mn : map Just (mapMaybe ctorModules tys)))
- forClassName _ _ _ = internalError "forClassName: expected qualified class name"
+ findDicts ctx cn ByNullSourcePos ++ [TypeClassDictionaryInScope Nothing 0 (WarnInstance msg) [] C.Warn [] [] [msg] Nothing Nothing]
+ forClassName _ _ C.IsSymbol _ args | Just dicts <- solveIsSymbol args = dicts
+ forClassName _ _ C.SymbolCompare _ args | Just dicts <- solveSymbolCompare args = dicts
+ forClassName _ _ C.SymbolAppend _ args | Just dicts <- solveSymbolAppend args = dicts
+ forClassName _ _ C.SymbolCons _ args | Just dicts <- solveSymbolCons args = dicts
+ forClassName _ _ C.IntAdd _ args | Just dicts <- solveIntAdd args = dicts
+ forClassName _ ctx C.IntCompare _ args | Just dicts <- solveIntCompare ctx args = dicts
+ forClassName _ _ C.IntMul _ args | Just dicts <- solveIntMul args = dicts
+ forClassName _ _ C.IntToString _ args | Just dicts <- solveIntToString args = dicts
+ forClassName _ _ C.Reflectable _ args | Just dicts <- solveReflectable args = dicts
+ forClassName _ _ C.RowUnion kinds args | Just dicts <- solveUnion kinds args = dicts
+ forClassName _ _ C.RowNub kinds args | Just dicts <- solveNub kinds args = dicts
+ forClassName _ _ C.RowLacks kinds args | Just dicts <- solveLacks kinds args = dicts
+ forClassName _ _ C.RowCons kinds args | Just dicts <- solveRowCons kinds args = dicts
+ forClassName _ _ C.RowToList kinds args | Just dicts <- solveRowToList kinds args = dicts
+ forClassName _ ctx cn@(Qualified (ByModuleName mn) _) _ tys = concatMap (findDicts ctx cn) (ordNub (ByNullSourcePos : ByModuleName mn : map ByModuleName (mapMaybe ctorModules tys)))
+ forClassName _ _ _ _ _ = internalError "forClassName: expected qualified class name"
ctorModules :: SourceType -> Maybe ModuleName
- ctorModules (TypeConstructor _ (Qualified (Just mn) _)) = Just mn
- ctorModules (TypeConstructor _ (Qualified Nothing _)) = internalError "ctorModules: unqualified type name"
+ ctorModules (TypeConstructor _ (Qualified (ByModuleName mn) _)) = Just mn
+ ctorModules (TypeConstructor _ (Qualified (BySourcePos _) _)) = internalError "ctorModules: unqualified type name"
ctorModules (TypeApp _ ty _) = ctorModules ty
+ ctorModules (KindApp _ ty _) = ctorModules ty
ctorModules (KindedType _ ty _) = ctorModules ty
ctorModules _ = Nothing
- findDicts :: InstanceContext -> Qualified (ProperName 'ClassName) -> Maybe ModuleName -> [TypeClassDict]
- findDicts ctx cn = fmap (fmap NamedInstance) . foldMap NEL.toList . foldMap M.elems . (>>= M.lookup cn) . flip M.lookup ctx
-
valUndefined :: Expr
- valUndefined = Var nullSourceSpan (Qualified (Just (ModuleName [ProperName C.prim])) (Ident C.undefined))
+ valUndefined = Var nullSourceSpan C.I_undefined
solve :: SourceConstraint -> WriterT (Any, [(Ident, InstanceContext, SourceConstraint)]) (StateT InstanceContext m) Expr
- solve con = go 0 con
+ solve = go 0 hints
where
- go :: Int -> SourceConstraint -> WriterT (Any, [(Ident, InstanceContext, SourceConstraint)]) (StateT InstanceContext m) Expr
- go work (Constraint _ className' tys' _) | work > 1000 = throwError . errorMessage $ PossiblyInfiniteInstance className' tys'
- go work con'@(Constraint _ className' tys' conInfo) = WriterT . StateT . (withErrorMessageHint (ErrorSolvingConstraint con') .) . runStateT . runWriterT $ do
+ go :: Int -> [ErrorMessageHint] -> SourceConstraint -> WriterT (Any, [(Ident, InstanceContext, SourceConstraint)]) (StateT InstanceContext m) Expr
+ go work _ (Constraint _ className' _ tys' _) | work > 1000 = throwError . errorMessage $ PossiblyInfiniteInstance className' tys'
+ go work hints' con@(Constraint _ className' kinds' tys' conInfo) = WriterT . StateT . (withErrorMessageHint (ErrorSolvingConstraint con) .) . runStateT . runWriterT $ do
-- We might have unified types by solving other constraints, so we need to
-- apply the latest substitution.
latestSubst <- lift . lift $ gets checkSubstitution
- let tys'' = map (substituteType latestSubst) tys'
+ let kinds'' = map (substituteType latestSubst) kinds'
+ tys'' = map (substituteType latestSubst) tys'
+
-- Get the inferred constraint context so far, and merge it with the global context
inferred <- lift get
-- We need information about functional dependencies, so we have to look up the class
-- name in the environment:
- classesInScope <- lift . lift $ gets (typeClasses . checkEnv)
- TypeClassData{ typeClassDependencies } <- case M.lookup className' classesInScope of
- Nothing -> throwError . errorMessage $ UnknownClass className'
- Just tcd -> pure tcd
- let instances = do
- chain <- groupBy ((==) `on` tcdChain) $
- sortBy (compare `on` (tcdChain &&& tcdIndex)) $
- forClassName (combineContexts context inferred) className' tys''
+ env <- lift . lift $ gets checkEnv
+ let classesInScope = typeClasses env
+ TypeClassData
+ { typeClassArguments
+ , typeClassDependencies
+ , typeClassIsEmpty
+ , typeClassCoveringSets
+ , typeClassMembers
+ } <- case M.lookup className' classesInScope of
+ Nothing -> throwError . errorMessage $ UnknownClass className'
+ Just tcd -> pure tcd
+
+ dicts <- lift . lift $ forClassNameM env (combineContexts context inferred) className' kinds'' tys''
+
+ let (catMaybes -> ambiguous, instances) = partitionEithers $ do
+ chain :: NonEmpty TypeClassDict <-
+ NEL.groupBy ((==) `on` tcdChain) $
+ sortOn (tcdChain &&& tcdIndex)
+ dicts
-- process instances in a chain in index order
- let found = for chain $ \tcd ->
+ let found = for (tails1 chain) $ \(tcd :| tl) ->
-- Make sure the type unifies with the type in the type instance definition
case matches typeClassDependencies tcd tys'' of
- Apart -> Right () -- keep searching
- Match substs -> Left (Just (substs, tcd)) -- found a match
- Unknown -> Left Nothing -- can't continue with this chain yet, need proof of apartness
- case found of
- Right _ -> [] -- all apart
- Left Nothing -> [] -- last unknown
- Left (Just substsTcd) -> [substsTcd] -- found a match
- solution <- lift . lift $ unique tys'' instances
+ Apart -> Right () -- keep searching
+ Match substs -> Left (Right (substs, tcd)) -- found a match
+ Unknown ->
+ if null (tcdChain tcd) || null tl
+ then Right () -- need proof of apartness but this is either not in a chain or at the end
+ else Left (Left (tcdToInstanceDescription tcd)) -- can't continue with this chain yet, need proof of apartness
+
+ lefts [found]
+ solution <- lift . lift
+ $ unique kinds'' tys'' ambiguous instances
+ $ unknownsInAllCoveringSets (fst . (typeClassArguments !!)) typeClassMembers tys'' typeClassCoveringSets
case solution of
Solved substs tcd -> do
-- Note that we solved something.
@@ -235,7 +293,7 @@ entails SolverOptions{..} constraint context hints =
-- Now enforce any functional dependencies, using unification
-- Note: we need to generate fresh types for any unconstrained
-- type variables before unifying.
- let subst = fmap head substs
+ let subst = fmap (headDef $ internalError "entails: empty substitution") substs
currentSubst <- lift . lift $ gets checkSubstitution
subst' <- lift . lift $ withFreshTypes tcd (fmap (substituteType currentSubst) subst)
lift . lift $ zipWithM_ (\t1 t2 -> do
@@ -244,16 +302,19 @@ entails SolverOptions{..} constraint context hints =
currentSubst' <- lift . lift $ gets checkSubstitution
let subst'' = fmap (substituteType currentSubst') subst'
-- Solve any necessary subgoals
- args <- solveSubgoals subst'' (tcdDependencies tcd)
+ args <- solveSubgoals subst'' (ErrorSolvingConstraint con) (tcdDependencies tcd)
+
initDict <- lift . lift $ mkDictionary (tcdValue tcd) args
+
let match = foldr (\(className, index) dict -> subclassDictionaryValue dict className index)
initDict
(tcdPath tcd)
- return match
+
+ return (if typeClassIsEmpty then Unused match else match)
Unsolved unsolved -> do
-- Generate a fresh name for the unsolved constraint's new dictionary
ident <- freshIdent ("dict" <> runProperName (disqualify (constraintClass unsolved)))
- let qident = Qualified Nothing ident
+ let qident = Qualified ByNullSourcePos ident
-- Store the new dictionary in the InstanceContext so that we can solve this goal in
-- future.
newDicts <- lift . lift $ newDictionaries [] qident unsolved
@@ -265,11 +326,11 @@ entails SolverOptions{..} constraint context hints =
Deferred ->
-- Constraint was deferred, just return the dictionary unchanged,
-- with no unsolved constraints. Hopefully, we can solve this later.
- return (TypeClassDictionary (srcConstraint className' tys'' conInfo) context hints)
+ return (TypeClassDictionary (srcConstraint className' kinds'' tys'' conInfo) context hints')
where
- -- | When checking functional dependencies, we need to use unification to make
+ -- When checking functional dependencies, we need to use unification to make
-- sure it is safe to use the selected instance. We will unify the solved type with
- -- the type in the instance head under the substition inferred from its instantiation.
+ -- the type in the instance head under the substitution inferred from its instantiation.
-- As an example, when solving MonadState t0 (State Int), we choose the
-- MonadState s (State s) instance, and we unify t0 with Int, since the functional
-- dependency from MonadState dictates that t0 should unify with s\[s -> Int], which is
@@ -277,46 +338,55 @@ entails SolverOptions{..} constraint context hints =
-- from the type, so we end up with a unification error. So, any type arguments which
-- appear in the instance head, but not in the substitution need to be replaced with
-- fresh type variables. This function extends a substitution with fresh type variables
- -- as necessary, based on the types in the instance head.
+ -- as necessary, based on the types in the instance head. It also unifies kinds based on
+ -- the substitution so kind information propagates correctly through the solver.
withFreshTypes
:: TypeClassDict
-> Matching SourceType
-> m (Matching SourceType)
- withFreshTypes TypeClassDictionaryInScope{..} subst = do
- let onType = everythingOnTypes S.union fromTypeVar
- typeVarsInHead = foldMap onType tcdInstanceTypes
- <> foldMap (foldMap (foldMap onType . constraintArgs)) tcdDependencies
- typeVarsInSubst = S.fromList (M.keys subst)
- uninstantiatedTypeVars = typeVarsInHead S.\\ typeVarsInSubst
- newSubst <- traverse withFreshType (S.toList uninstantiatedTypeVars)
- return (subst <> M.fromList newSubst)
+ withFreshTypes TypeClassDictionaryInScope{..} initSubst = do
+ subst <- foldM withFreshType initSubst $ filter (flip M.notMember initSubst . fst) tcdForAll
+ for_ (M.toList initSubst) $ unifySubstKind subst
+ pure subst
where
- fromTypeVar (TypeVar _ v) = S.singleton v
- fromTypeVar _ = S.empty
-
- withFreshType s = do
- t <- freshType
- return (s, t)
-
- unique :: [SourceType] -> [(a, TypeClassDict)] -> m (EntailsResult a)
- unique tyArgs []
+ withFreshType subst (var, kind) = do
+ ty <- freshTypeWithKind $ replaceAllTypeVars (M.toList subst) kind
+ pure $ M.insert var ty subst
+
+ unifySubstKind subst (var, ty) =
+ for_ (lookup var tcdForAll) $ \instKind -> do
+ tyKind <- elaborateKind ty
+ currentSubst <- gets checkSubstitution
+ unifyKinds'
+ (substituteType currentSubst . replaceAllTypeVars (M.toList subst) $ instKind)
+ (substituteType currentSubst tyKind)
+
+ unique :: [SourceType] -> [SourceType] -> [Qualified (Either SourceType Ident)] -> [(a, TypeClassDict)] -> UnknownsHint -> m (EntailsResult a)
+ unique kindArgs tyArgs ambiguous [] unks
| solverDeferErrors = return Deferred
-- We need a special case for nullary type classes, since we want
-- to generalize over Partial constraints.
- | solverShouldGeneralize && (null tyArgs || any canBeGeneralized tyArgs) = return (Unsolved (srcConstraint className' tyArgs conInfo))
- | otherwise = throwError . errorMessage $ NoInstanceFound (srcConstraint className' tyArgs conInfo)
- unique _ [(a, dict)] = return $ Solved a dict
- unique tyArgs tcds
+ | solverShouldGeneralize && ((null kindArgs && null tyArgs) || any canBeGeneralized kindArgs || any canBeGeneralized tyArgs) =
+ return (Unsolved (srcConstraint className' kindArgs tyArgs conInfo))
+ | otherwise = throwError . errorMessage $ NoInstanceFound (srcConstraint className' kindArgs tyArgs conInfo) ambiguous unks
+ unique _ _ _ [(a, dict)] _ = return $ Solved a dict
+ unique _ tyArgs _ tcds _
| pairwiseAny overlapping (map snd tcds) =
- throwError . errorMessage $ OverlappingInstances className' tyArgs (tcds >>= (toList . namedInstanceIdentifier . tcdValue . snd))
+ throwError . errorMessage $ OverlappingInstances className' tyArgs (tcds >>= (toList . tcdToInstanceDescription . snd))
| otherwise = return $ uncurry Solved (minimumBy (compare `on` length . tcdPath . snd) tcds)
+ tcdToInstanceDescription :: TypeClassDict -> Maybe (Qualified (Either SourceType Ident))
+ tcdToInstanceDescription TypeClassDictionaryInScope{ tcdDescription, tcdValue } =
+ let nii = namedInstanceIdentifier tcdValue
+ in case tcdDescription of
+ Just ty -> flip Qualified (Left ty) <$> fmap (byMaybeModuleName . getQual) nii
+ Nothing -> fmap Right <$> nii
+
canBeGeneralized :: Type a -> Bool
canBeGeneralized TUnknown{} = True
canBeGeneralized (KindedType _ t _) = canBeGeneralized t
canBeGeneralized _ = False
- -- |
-- Check if two dictionaries are overlapping
--
-- Dictionaries which are subclass dictionaries cannot overlap, since otherwise the overlap would have
@@ -331,15 +401,15 @@ entails SolverOptions{..} constraint context hints =
-- Create dictionaries for subgoals which still need to be solved by calling go recursively
-- E.g. the goal (Show a, Show b) => Show (Either a b) can be satisfied if the current type
-- unifies with Either a b, and we can satisfy the subgoals Show a and Show b recursively.
- solveSubgoals :: Matching SourceType -> Maybe [SourceConstraint] -> WriterT (Any, [(Ident, InstanceContext, SourceConstraint)]) (StateT InstanceContext m) (Maybe [Expr])
- solveSubgoals _ Nothing = return Nothing
- solveSubgoals subst (Just subgoals) =
- Just <$> traverse (go (work + 1) . mapConstraintArgs (map (replaceAllTypeVars (M.toList subst)))) subgoals
+ solveSubgoals :: Matching SourceType -> ErrorMessageHint -> Maybe [SourceConstraint] -> WriterT (Any, [(Ident, InstanceContext, SourceConstraint)]) (StateT InstanceContext m) (Maybe [Expr])
+ solveSubgoals _ _ Nothing = return Nothing
+ solveSubgoals subst hint (Just subgoals) =
+ Just <$> traverse (rethrow (addHint hint) . go (work + 1) (hints' <> [hint]) . mapConstraintArgsAll (map (replaceAllTypeVars (M.toList subst)))) subgoals
-- We need subgoal dictionaries to appear in the term somewhere
-- If there aren't any then the dictionary is just undefined
useEmptyDict :: Maybe [Expr] -> Expr
- useEmptyDict args = foldl (App . Abs (VarBinder nullSourceSpan UnusedIdent)) valUndefined (fold args)
+ useEmptyDict args = Unused (foldl (App . Abs (VarBinder nullSourceSpan UnusedIdent)) valUndefined (fold args))
-- Make a dictionary from subgoal dictionaries by applying the correct function
mkDictionary :: Evidence -> Maybe [Expr] -> m Expr
@@ -353,35 +423,98 @@ entails SolverOptions{..} constraint context hints =
return (useEmptyDict args)
mkDictionary (IsSymbolInstance sym) _ =
let fields = [ ("reflectSymbol", Abs (VarBinder nullSourceSpan UnusedIdent) (Literal nullSourceSpan (StringLiteral sym))) ] in
- return $ TypeClassDictionaryConstructorApp C.IsSymbol (Literal nullSourceSpan (ObjectLiteral fields))
+ return $ App (Constructor nullSourceSpan (coerceProperName . dictTypeName <$> C.IsSymbol)) (Literal nullSourceSpan (ObjectLiteral fields))
+ mkDictionary (ReflectableInstance ref) _ =
+ let fields = [ ("reflectType", Abs (VarBinder nullSourceSpan UnusedIdent) (asExpression ref)) ] in
+ pure $ App (Constructor nullSourceSpan (coerceProperName . dictTypeName <$> C.Reflectable)) (Literal nullSourceSpan (ObjectLiteral fields))
+
+ unknownsInAllCoveringSets :: (Int -> Text) -> [(Ident, SourceType, Maybe (S.Set (NEL.NonEmpty Int)))] -> [SourceType] -> S.Set (S.Set Int) -> UnknownsHint
+ unknownsInAllCoveringSets indexToArgText tyClassMembers tyArgs coveringSets = do
+ let unkIndices = findIndices containsUnknowns tyArgs
+ if all (\s -> any (`S.member` s) unkIndices) coveringSets then
+ fromMaybe Unknowns unknownsRequiringVtas
+ else
+ NoUnknowns
+ where
+ unknownsRequiringVtas = do
+ tyClassModuleName <- getQual className'
+ let
+ tyClassMemberVta :: M.Map (Qualified Ident) [[Text]]
+ tyClassMemberVta = M.fromList $ mapMaybe qualifyAndFilter tyClassMembers
+ where
+ -- Only keep type class members that need VTAs to resolve their type class instances
+ qualifyAndFilter (ident, _, mbVtaRequiredArgs) = mbVtaRequiredArgs <&> \vtaRequiredArgs ->
+ (Qualified (ByModuleName tyClassModuleName) ident, map (map indexToArgText . NEL.toList) $ S.toList vtaRequiredArgs)
+
+ tyClassMembersInExpr :: Expr -> [(Qualified Ident, [[Text]])]
+ tyClassMembersInExpr = getVars
+ where
+ (_, getVars, _, _, _) = everythingOnValues (++) ignore getVarIdents ignore ignore ignore
+ ignore = const []
+ getVarIdents = \case
+ Var _ ident | Just vtas <- M.lookup ident tyClassMemberVta ->
+ [(ident, vtas)]
+ _ ->
+ []
+
+ getECTExpr = \case
+ ErrorCheckingType expr _ -> Just expr
+ _ -> Nothing
+
+ tyClassMembers' <- headMay $ mapMaybe (fmap tyClassMembersInExpr . getECTExpr) hints
+ membersWithVtas <- NEL.nonEmpty tyClassMembers'
+ pure $ UnknownsWithVtaRequiringArgs membersWithVtas
-- Turn a DictionaryValue into a Expr
subclassDictionaryValue :: Expr -> Qualified (ProperName 'ClassName) -> Integer -> Expr
subclassDictionaryValue dict className index =
App (Accessor (mkString (superclassName className index)) dict) valUndefined
+ solveCoercible :: Environment -> InstanceContext -> [SourceType] -> [SourceType] -> m (Maybe [TypeClassDict])
+ solveCoercible env ctx kinds [a, b] = do
+ let coercibleDictsInScope = findDicts ctx C.Coercible ByNullSourcePos
+ givens = flip mapMaybe coercibleDictsInScope $ \case
+ dict | [a', b'] <- tcdInstanceTypes dict -> Just (a', b')
+ | otherwise -> Nothing
+ GivenSolverState{ inertGivens } <- execStateT (solveGivens env) $
+ initialGivenSolverState givens
+ (WantedSolverState{ inertWanteds }, hints') <- runWriterT . execStateT (solveWanteds env) $
+ initialWantedSolverState inertGivens a b
+ -- Solving fails when there's irreducible wanteds left.
+ --
+ -- We report the first residual constraint instead of the initial wanted,
+ -- unless we just swapped its arguments.
+ --
+ -- We may have collected hints for the solving failure along the way, in
+ -- which case we decorate the error with the first one.
+ maybe id addHint (listToMaybe hints') `rethrow` case inertWanteds of
+ [] -> pure $ Just [TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.Coercible [] kinds [a, b] Nothing Nothing]
+ (k, a', b') : _ | a' == b && b' == a -> throwError $ insoluble k b' a'
+ (k, a', b') : _ -> throwError $ insoluble k a' b'
+ solveCoercible _ _ _ _ = pure Nothing
+
solveIsSymbol :: [SourceType] -> Maybe [TypeClassDict]
- solveIsSymbol [TypeLevelString ann sym] = Just [TypeClassDictionaryInScope [] 0 (IsSymbolInstance sym) [] C.IsSymbol [TypeLevelString ann sym] Nothing]
+ solveIsSymbol [TypeLevelString ann sym] = Just [TypeClassDictionaryInScope Nothing 0 (IsSymbolInstance sym) [] C.IsSymbol [] [] [TypeLevelString ann sym] Nothing Nothing]
solveIsSymbol _ = Nothing
solveSymbolCompare :: [SourceType] -> Maybe [TypeClassDict]
solveSymbolCompare [arg0@(TypeLevelString _ lhs), arg1@(TypeLevelString _ rhs), _] =
let ordering = case compare lhs rhs of
- LT -> C.orderingLT
- EQ -> C.orderingEQ
- GT -> C.orderingGT
+ LT -> C.LT
+ EQ -> C.EQ
+ GT -> C.GT
args' = [arg0, arg1, srcTypeConstructor ordering]
- in Just [TypeClassDictionaryInScope [] 0 EmptyClassInstance [] C.SymbolCompare args' Nothing]
+ in Just [TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.SymbolCompare [] [] args' Nothing Nothing]
solveSymbolCompare _ = Nothing
solveSymbolAppend :: [SourceType] -> Maybe [TypeClassDict]
solveSymbolAppend [arg0, arg1, arg2] = do
(arg0', arg1', arg2') <- appendSymbols arg0 arg1 arg2
let args' = [arg0', arg1', arg2']
- pure [TypeClassDictionaryInScope [] 0 EmptyClassInstance [] C.SymbolAppend args' Nothing]
+ pure [TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.SymbolAppend [] [] args' Nothing Nothing]
solveSymbolAppend _ = Nothing
- -- | Append type level symbols, or, run backwards, strip a prefix or suffix
+ -- Append type level symbols, or, run backwards, strip a prefix or suffix
appendSymbols :: SourceType -> SourceType -> SourceType -> Maybe (SourceType, SourceType, SourceType)
appendSymbols arg0@(TypeLevelString _ lhs) arg1@(TypeLevelString _ rhs) _ = Just (arg0, arg1, srcTypeLevelString (lhs <> rhs))
appendSymbols arg0@(TypeLevelString _ lhs) _ arg2@(TypeLevelString _ out) = do
@@ -400,7 +533,7 @@ entails SolverOptions{..} constraint context hints =
solveSymbolCons [arg0, arg1, arg2] = do
(arg0', arg1', arg2') <- consSymbol arg0 arg1 arg2
let args' = [arg0', arg1', arg2']
- pure [TypeClassDictionaryInScope [] 0 EmptyClassInstance [] C.SymbolCons args' Nothing]
+ pure [TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.SymbolCons [] [] args' Nothing Nothing]
solveSymbolCons _ = Nothing
consSymbol :: SourceType -> SourceType -> SourceType -> Maybe (SourceType, SourceType, SourceType)
@@ -415,89 +548,186 @@ entails SolverOptions{..} constraint context hints =
pure (arg1, arg2, srcTypeLevelString (mkString $ h' <> t'))
consSymbol _ _ _ = Nothing
- solveUnion :: [SourceType] -> Maybe [TypeClassDict]
- solveUnion [l, r, u] = do
- (lOut, rOut, uOut, cst) <- unionRows l r u
- pure [ TypeClassDictionaryInScope [] 0 EmptyClassInstance [] C.RowUnion [lOut, rOut, uOut] cst ]
- solveUnion _ = Nothing
-
- -- | Left biased union of two row types
- unionRows :: SourceType -> SourceType -> SourceType -> Maybe (SourceType, SourceType, SourceType, Maybe [SourceConstraint])
- unionRows l r _ =
- guard canMakeProgress $> (l, r, rowFromList out, cons)
+ solveIntToString :: [SourceType] -> Maybe [TypeClassDict]
+ solveIntToString [arg0, _] = do
+ (arg0', arg1') <- printIntToString arg0
+ let args' = [arg0', arg1']
+ pure [TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.IntToString [] [] args' Nothing Nothing]
+ solveIntToString _ = Nothing
+
+ printIntToString :: SourceType -> Maybe (SourceType, SourceType)
+ printIntToString arg0@(TypeLevelInt _ i) = do
+ pure (arg0, srcTypeLevelString $ mkString $ T.pack $ show i)
+ printIntToString _ = Nothing
+
+ solveReflectable :: [SourceType] -> Maybe [TypeClassDict]
+ solveReflectable [typeLevel, _] = do
+ (ref, typ) <- case typeLevel of
+ TypeLevelInt _ i -> pure (ReflectableInt i, tyInt)
+ TypeLevelString _ s -> pure (ReflectableString s, tyString)
+ TypeConstructor _ n
+ | n == C.True -> pure (ReflectableBoolean True, tyBoolean)
+ | n == C.False -> pure (ReflectableBoolean False, tyBoolean)
+ | n == C.LT -> pure (ReflectableOrdering LT, srcTypeConstructor C.Ordering)
+ | n == C.EQ -> pure (ReflectableOrdering EQ, srcTypeConstructor C.Ordering)
+ | n == C.GT -> pure (ReflectableOrdering GT, srcTypeConstructor C.Ordering)
+ _ -> Nothing
+ pure [TypeClassDictionaryInScope Nothing 0 (ReflectableInstance ref) [] C.Reflectable [] [] [typeLevel, typ] Nothing Nothing]
+ solveReflectable _ = Nothing
+
+ solveIntAdd :: [SourceType] -> Maybe [TypeClassDict]
+ solveIntAdd [arg0, arg1, arg2] = do
+ (arg0', arg1', arg2') <- addInts arg0 arg1 arg2
+ let args' = [arg0', arg1', arg2']
+ pure [TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.IntAdd [] [] args' Nothing Nothing]
+ solveIntAdd _ = Nothing
+
+ addInts :: SourceType -> SourceType -> SourceType -> Maybe (SourceType, SourceType, SourceType)
+ -- l r -> o, l + r = o
+ addInts arg0@(TypeLevelInt _ l) arg1@(TypeLevelInt _ r) _ = pure (arg0, arg1, srcTypeLevelInt (l + r))
+ -- l o -> r, o - l = r
+ addInts arg0@(TypeLevelInt _ l) _ arg2@(TypeLevelInt _ o) = pure (arg0, srcTypeLevelInt (o - l), arg2)
+ -- r o -> l, o - r = l
+ addInts _ arg1@(TypeLevelInt _ r) arg2@(TypeLevelInt _ o) = pure (srcTypeLevelInt (o - r), arg1, arg2)
+ addInts _ _ _ = Nothing
+
+ solveIntCompare :: InstanceContext -> [SourceType] -> Maybe [TypeClassDict]
+ solveIntCompare _ [arg0@(TypeLevelInt _ a), arg1@(TypeLevelInt _ b), _] =
+ let ordering = case compare a b of
+ EQ -> C.EQ
+ LT -> C.LT
+ GT -> C.GT
+ args' = [arg0, arg1, srcTypeConstructor ordering]
+ in pure [TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.IntCompare [] [] args' Nothing Nothing]
+ solveIntCompare ctx args@[a, b, _] = do
+ let compareDictsInScope = findDicts ctx C.IntCompare ByNullSourcePos
+ givens = flip mapMaybe compareDictsInScope $ \case
+ dict | [a', b', c'] <- tcdInstanceTypes dict -> mkRelation a' b' c'
+ | otherwise -> Nothing
+ facts = mkFacts (args : (tcdInstanceTypes <$> compareDictsInScope))
+ c' <- solveRelation (givens <> facts) a b
+ pure [TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.IntCompare [] [] [a, b, srcTypeConstructor c'] Nothing Nothing]
+ solveIntCompare _ _ = Nothing
+
+ solveIntMul :: [SourceType] -> Maybe [TypeClassDict]
+ solveIntMul [arg0@(TypeLevelInt _ l), arg1@(TypeLevelInt _ r), _] =
+ let args' = [arg0, arg1, srcTypeLevelInt (l * r)]
+ in pure [TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.IntMul [] [] args' Nothing Nothing]
+ solveIntMul _ = Nothing
+
+ solveUnion :: [SourceType] -> [SourceType] -> Maybe [TypeClassDict]
+ solveUnion kinds [l, r, u] = do
+ (lOut, rOut, uOut, cst, vars) <- unionRows kinds l r u
+ pure [ TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.RowUnion vars kinds [lOut, rOut, uOut] cst Nothing ]
+ solveUnion _ _ = Nothing
+
+ -- Left biased union of two row types
+
+ unionRows :: [SourceType] -> SourceType -> SourceType -> SourceType -> Maybe (SourceType, SourceType, SourceType, Maybe [SourceConstraint], [(Text, SourceType)])
+ unionRows kinds l r u =
+ guard canMakeProgress $> (lOut, rOut, uOut, cons, vars)
where
(fixed, rest) = rowToList l
rowVar = srcTypeVar "r"
- (canMakeProgress, out, cons) =
+ (canMakeProgress, lOut, rOut, uOut, cons, vars) =
case rest of
-- If the left hand side is a closed row, then we can merge
-- its labels into the right hand side.
- REmpty _ -> (True, (fixed, r), Nothing)
+ REmptyKinded _ _ -> (True, l, r, rowFromList (fixed, r), Nothing, [])
+ -- If the right hand side and output are closed rows, then we can
+ -- compute the left hand side by subtracting the right hand side
+ -- from the output.
+ _ | (right, rightu@(REmptyKinded _ _)) <- rowToList r
+ , (output, restu@(REmptyKinded _ _)) <- rowToList u ->
+ let
+ -- Partition the output rows into those that belong in right
+ -- (taken off the end) and those that must end up in left.
+ grabLabel e (left', right', remaining)
+ | rowListLabel e `elem` remaining =
+ (left', e : right', delete (rowListLabel e) remaining)
+ | otherwise =
+ (e : left', right', remaining)
+ (outL, outR, leftover) =
+ foldr grabLabel ([], [], fmap rowListLabel right) output
+ in ( null leftover
+ , rowFromList (outL, restu)
+ , rowFromList (outR, rightu)
+ , u
+ , Nothing
+ , []
+ )
-- If the left hand side is not definitely closed, then the only way we
-- can safely make progress is to move any known labels from the left
-- input into the output, and add a constraint for any remaining labels.
-- Otherwise, the left hand tail might contain the same labels as on
-- the right hand side, and we can't be certain we won't reorder the
-- types for such labels.
- _ -> (not (null fixed), (fixed, rowVar), Just [ srcConstraint C.RowUnion [rest, r, rowVar] Nothing ])
-
- solveRowCons :: [SourceType] -> Maybe [TypeClassDict]
- solveRowCons [TypeLevelString ann sym, ty, r, _] =
- Just [ TypeClassDictionaryInScope [] 0 EmptyClassInstance [] C.RowCons [TypeLevelString ann sym, ty, r, srcRCons (Label sym) ty r] Nothing ]
- solveRowCons _ = Nothing
-
- solveRowToList :: [SourceType] -> Maybe [TypeClassDict]
- solveRowToList [r, _] = do
- entries <- rowToRowList r
- pure [ TypeClassDictionaryInScope [] 0 EmptyClassInstance [] C.RowToList [r, entries] Nothing ]
- solveRowToList _ = Nothing
-
- -- | Convert a closed row to a sorted list of entries
- rowToRowList :: SourceType -> Maybe SourceType
- rowToRowList r =
- guard (eqType rest $ REmpty ()) $>
- foldr rowListCons (srcTypeConstructor C.RowListNil) fixed
+ _ -> ( not (null fixed)
+ , l, r
+ , rowFromList (fixed, rowVar)
+ , Just [ srcConstraint C.RowUnion kinds [rest, r, rowVar] Nothing ]
+ , [("r", kindRow (headDef (internalError "unionRows: empty kinds") kinds))]
+ )
+
+ solveRowCons :: [SourceType] -> [SourceType] -> Maybe [TypeClassDict]
+ solveRowCons kinds [TypeLevelString ann sym, ty, r, _] =
+ Just [ TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.RowCons [] kinds [TypeLevelString ann sym, ty, r, srcRCons (Label sym) ty r] Nothing Nothing ]
+ solveRowCons _ _ = Nothing
+
+ solveRowToList :: [SourceType] -> [SourceType] -> Maybe [TypeClassDict]
+ solveRowToList [kind] [r, _] = do
+ entries <- rowToRowList kind r
+ pure [ TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.RowToList [] [kind] [r, entries] Nothing Nothing ]
+ solveRowToList _ _ = Nothing
+
+ -- Convert a closed row to a sorted list of entries
+ rowToRowList :: SourceType -> SourceType -> Maybe SourceType
+ rowToRowList kind r =
+ guard (isREmpty rest) $>
+ foldr rowListCons (srcKindApp (srcTypeConstructor C.RowListNil) kind) fixed
where
(fixed, rest) = rowToSortedList r
rowListCons (RowListItem _ lbl ty) tl =
- foldl srcTypeApp (srcTypeConstructor C.RowListCons)
+ foldl srcTypeApp (srcKindApp (srcTypeConstructor C.RowListCons) kind)
[ srcTypeLevelString (runLabel lbl)
, ty
, tl ]
- solveNub :: [SourceType] -> Maybe [TypeClassDict]
- solveNub [r, _] = do
+ solveNub :: [SourceType] -> [SourceType] -> Maybe [TypeClassDict]
+ solveNub kinds [r, _] = do
r' <- nubRows r
- pure [ TypeClassDictionaryInScope [] 0 EmptyClassInstance [] C.RowNub [r, r'] Nothing ]
- solveNub _ = Nothing
+ pure [ TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.RowNub [] kinds [r, r'] Nothing Nothing ]
+ solveNub _ _ = Nothing
nubRows :: SourceType -> Maybe SourceType
nubRows r =
- guard (eqType rest $ REmpty ()) $>
+ guard (isREmpty rest) $>
rowFromList (nubBy ((==) `on` rowListLabel) fixed, rest)
where
(fixed, rest) = rowToSortedList r
- solveLacks :: [SourceType] -> Maybe [TypeClassDict]
- solveLacks [TypeLevelString ann sym, r] = do
- (r', cst) <- rowLacks sym r
- pure [ TypeClassDictionaryInScope [] 0 EmptyClassInstance [] C.RowLacks [TypeLevelString ann sym, r'] cst ]
- solveLacks _ = Nothing
+ solveLacks :: [SourceType] -> [SourceType] -> Maybe [TypeClassDict]
+ solveLacks kinds tys@[_, REmptyKinded _ _] =
+ pure [ TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.RowLacks [] kinds tys Nothing Nothing ]
+ solveLacks kinds [TypeLevelString ann sym, r] = do
+ (r', cst) <- rowLacks kinds sym r
+ pure [ TypeClassDictionaryInScope Nothing 0 EmptyClassInstance [] C.RowLacks [] kinds [TypeLevelString ann sym, r'] cst Nothing ]
+ solveLacks _ _ = Nothing
- rowLacks :: PSString -> SourceType -> Maybe (SourceType, Maybe [SourceConstraint])
- rowLacks sym r =
+ rowLacks :: [SourceType] -> PSString -> SourceType -> Maybe (SourceType, Maybe [SourceConstraint])
+ rowLacks kinds sym r =
guard (lacksSym && canMakeProgress) $> (r, cst)
where
(fixed, rest) = rowToList r
lacksSym =
- not $ sym `elem` (runLabel . rowListLabel <$> fixed)
+ sym `notElem` (runLabel . rowListLabel <$> fixed)
(canMakeProgress, cst) = case rest of
- REmpty _ -> (True, Nothing)
- _ -> (not (null fixed), Just [ srcConstraint C.RowLacks [srcTypeLevelString sym, rest] Nothing ])
+ REmptyKinded _ _ -> (True, Nothing)
+ _ -> (not (null fixed), Just [ srcConstraint C.RowLacks kinds [srcTypeLevelString sym, rest] Nothing ])
-- Check if an instance matches our list of types, allowing for types
-- to be solved via functional dependencies. If the types match, we return a
@@ -514,7 +744,7 @@ matches deps TypeClassDictionaryInScope{..} tys =
solved = map snd . filter ((`S.notMember` determinedSet) . fst) $ zipWith (\(_, ts) i -> (i, ts)) matched [0..]
in verifySubstitution (M.unionsWith (++) solved)
where
- -- | Find the closure of a set of functional dependencies.
+ -- Find the closure of a set of functional dependencies.
covers :: [(Matched (), subst)] -> Bool
covers ms = finalSet == S.fromList [0..length ms - 1]
where
@@ -547,32 +777,36 @@ matches deps TypeClassDictionaryInScope{..} tys =
typeHeadsAreEqual (KindedType _ t1 _) t2 = typeHeadsAreEqual t1 t2
typeHeadsAreEqual t1 (KindedType _ t2 _) = typeHeadsAreEqual t1 t2
typeHeadsAreEqual (TUnknown _ u1) (TUnknown _ u2) | u1 == u2 = (Match (), M.empty)
- typeHeadsAreEqual (Skolem _ _ s1 _) (Skolem _ _ s2 _) | s1 == s2 = (Match (), M.empty)
+ typeHeadsAreEqual (Skolem _ _ _ s1 _) (Skolem _ _ _ s2 _) | s1 == s2 = (Match (), M.empty)
typeHeadsAreEqual t (TypeVar _ v) = (Match (), M.singleton v [t])
typeHeadsAreEqual (TypeConstructor _ c1) (TypeConstructor _ c2) | c1 == c2 = (Match (), M.empty)
typeHeadsAreEqual (TypeLevelString _ s1) (TypeLevelString _ s2) | s1 == s2 = (Match (), M.empty)
+ typeHeadsAreEqual (TypeLevelInt _ n1) (TypeLevelInt _ n2) | n1 == n2 = (Match (), M.empty)
typeHeadsAreEqual (TypeApp _ h1 t1) (TypeApp _ h2 t2) =
both (typeHeadsAreEqual h1 h2) (typeHeadsAreEqual t1 t2)
+ typeHeadsAreEqual (KindApp _ h1 t1) (KindApp _ h2 t2) =
+ both (typeHeadsAreEqual h1 h2) (typeHeadsAreEqual t1 t2)
typeHeadsAreEqual (REmpty _) (REmpty _) = (Match (), M.empty)
typeHeadsAreEqual r1@RCons{} r2@RCons{} =
foldr both (uncurry go rest) common
where
- (common, rest) = alignRowsWith typeHeadsAreEqual r1 r2
+ (common, rest) = alignRowsWith (const typeHeadsAreEqual) r1 r2
go :: ([RowListItem a], Type a) -> ([RowListItem a], Type a) -> (Matched (), Matching [Type a])
go (l, KindedType _ t1 _) (r, t2) = go (l, t1) (r, t2)
go (l, t1) (r, KindedType _ t2 _) = go (l, t1) (r, t2)
+ go (l, KindApp _ t1 k1) (r, KindApp _ t2 k2) | eqType k1 k2 = go (l, t1) (r, t2)
go ([], REmpty _) ([], REmpty _) = (Match (), M.empty)
go ([], TUnknown _ u1) ([], TUnknown _ u2) | u1 == u2 = (Match (), M.empty)
go ([], TypeVar _ v1) ([], TypeVar _ v2) | v1 == v2 = (Match (), M.empty)
- go ([], Skolem _ _ sk1 _) ([], Skolem _ _ sk2 _) | sk1 == sk2 = (Match (), M.empty)
+ go ([], Skolem _ _ _ sk1 _) ([], Skolem _ _ _ sk2 _) | sk1 == sk2 = (Match (), M.empty)
go ([], TUnknown _ _) _ = (Unknown, M.empty)
go (sd, r) ([], TypeVar _ v) = (Match (), M.singleton v [rowFromList (sd, r)])
go _ _ = (Apart, M.empty)
typeHeadsAreEqual (TUnknown _ _) _ = (Unknown, M.empty)
+ typeHeadsAreEqual Skolem{} _ = (Unknown, M.empty)
typeHeadsAreEqual _ _ = (Apart, M.empty)
-
both :: (Matched (), Matching [Type a]) -> (Matched (), Matching [Type a]) -> (Matched (), Matching [Type a])
both (b1, m1) (b2, m2) = (b1 <> b2, M.unionWith (++) m1 m2)
@@ -588,25 +822,32 @@ matches deps TypeClassDictionaryInScope{..} tys =
typesAreEqual (KindedType _ t1 _) t2 = typesAreEqual t1 t2
typesAreEqual t1 (KindedType _ t2 _) = typesAreEqual t1 t2
typesAreEqual (TUnknown _ u1) (TUnknown _ u2) | u1 == u2 = Match ()
- typesAreEqual (Skolem _ _ s1 _) (Skolem _ _ s2 _) | s1 == s2 = Match ()
- typesAreEqual (Skolem _ _ _ _) _ = Unknown
- typesAreEqual _ (Skolem _ _ _ _) = Unknown
+ typesAreEqual (TUnknown _ u1) t2 = if t2 `containsUnknown` u1 then Apart else Unknown
+ typesAreEqual t1 (TUnknown _ u2) = if t1 `containsUnknown` u2 then Apart else Unknown
+ typesAreEqual (Skolem _ _ _ s1 _) (Skolem _ _ _ s2 _) | s1 == s2 = Match ()
+ typesAreEqual (Skolem _ _ _ s1 _) t2 = if t2 `containsSkolem` s1 then Apart else Unknown
+ typesAreEqual t1 (Skolem _ _ _ s2 _) = if t1 `containsSkolem` s2 then Apart else Unknown
typesAreEqual (TypeVar _ v1) (TypeVar _ v2) | v1 == v2 = Match ()
typesAreEqual (TypeLevelString _ s1) (TypeLevelString _ s2) | s1 == s2 = Match ()
+ typesAreEqual (TypeLevelInt _ n1) (TypeLevelInt _ n2) | n1 == n2 = Match ()
typesAreEqual (TypeConstructor _ c1) (TypeConstructor _ c2) | c1 == c2 = Match ()
typesAreEqual (TypeApp _ h1 t1) (TypeApp _ h2 t2) = typesAreEqual h1 h2 <> typesAreEqual t1 t2
+ typesAreEqual (KindApp _ h1 t1) (KindApp _ h2 t2) = typesAreEqual h1 h2 <> typesAreEqual t1 t2
typesAreEqual (REmpty _) (REmpty _) = Match ()
typesAreEqual r1 r2 | isRCons r1 || isRCons r2 =
- let (common, rest) = alignRowsWith typesAreEqual r1 r2
+ let (common, rest) = alignRowsWith (const typesAreEqual) r1 r2
in fold common <> uncurry go rest
where
go :: ([RowListItem a], Type a) -> ([RowListItem a], Type a) -> Matched ()
go (l, KindedType _ t1 _) (r, t2) = go (l, t1) (r, t2)
go (l, t1) (r, KindedType _ t2 _) = go (l, t1) (r, t2)
+ go ([], KindApp _ t1 k1) ([], KindApp _ t2 k2) = typesAreEqual t1 t2 <> typesAreEqual k1 k2
go ([], TUnknown _ u1) ([], TUnknown _ u2) | u1 == u2 = Match ()
- go ([], Skolem _ _ s1 _) ([], Skolem _ _ s2 _) | s1 == s2 = Match ()
- go ([], Skolem _ _ _ _) _ = Unknown
- go _ ([], Skolem _ _ _ _) = Unknown
+ go ([], TUnknown _ _) ([], _) = Unknown
+ go ([], _) ([], TUnknown _ _) = Unknown
+ go ([], Skolem _ _ _ s1 _) ([], Skolem _ _ _ s2 _) | s1 == s2 = Match ()
+ go ([], Skolem _ _ _ _ _) _ = Unknown
+ go _ ([], Skolem _ _ _ _ _) = Unknown
go ([], REmpty _) ([], REmpty _) = Match ()
go ([], TypeVar _ v1) ([], TypeVar _ v2) | v1 == v2 = Match ()
go _ _ = Apart
@@ -616,6 +857,12 @@ matches deps TypeClassDictionaryInScope{..} tys =
isRCons RCons{} = True
isRCons _ = False
+ containsSkolem :: Type a -> Int -> Bool
+ containsSkolem t s = everythingOnTypes (||) (\case Skolem _ _ _ s' _ -> s == s'; _ -> False) t
+
+ containsUnknown :: Type a -> Int -> Bool
+ containsUnknown t u = everythingOnTypes (||) (\case TUnknown _ u' -> u == u'; _ -> False) t
+
-- | Add a dictionary for the constraint to the scope, and dictionaries
-- for all implied superclass instances.
newDictionaries
@@ -624,22 +871,23 @@ newDictionaries
-> Qualified Ident
-> SourceConstraint
-> m [NamedDict]
-newDictionaries path name (Constraint _ className instanceTy _) = do
+newDictionaries path name (Constraint _ className instanceKinds instanceTy _) = do
tcs <- gets (typeClasses . checkEnv)
let TypeClassData{..} = fromMaybe (internalError "newDictionaries: type class lookup failed") $ M.lookup className tcs
- supDicts <- join <$> zipWithM (\(Constraint ann supName supArgs _) index ->
+ supDicts <- join <$> zipWithM (\(Constraint ann supName supKinds supArgs _) index ->
+ let sub = zip (map fst typeClassArguments) instanceTy in
newDictionaries ((supName, index) : path)
name
- (Constraint ann supName (instantiateSuperclass (map fst typeClassArguments) supArgs instanceTy) Nothing)
+ (Constraint ann supName
+ (replaceAllTypeVars sub <$> supKinds)
+ (replaceAllTypeVars sub <$> supArgs)
+ Nothing)
) typeClassSuperclasses [0..]
- return (TypeClassDictionaryInScope [] 0 name path className instanceTy Nothing : supDicts)
- where
- instantiateSuperclass :: [Text] -> [SourceType] -> [SourceType] -> [SourceType]
- instantiateSuperclass args supArgs tys = map (replaceAllTypeVars (zip args tys)) supArgs
+ return (TypeClassDictionaryInScope Nothing 0 name path className [] instanceKinds instanceTy Nothing Nothing : supDicts)
mkContext :: [NamedDict] -> InstanceContext
mkContext = foldr combineContexts M.empty . map fromDict where
- fromDict d = M.singleton Nothing (M.singleton (tcdClassName d) (M.singleton (tcdValue d) (pure d)))
+ fromDict d = M.singleton ByNullSourcePos (M.singleton (tcdClassName d) (M.singleton (tcdValue d) (pure d)))
-- | Check all pairs of values in a list match a predicate
pairwiseAll :: Monoid m => (a -> a -> m) -> [a] -> m
@@ -657,3 +905,19 @@ pairwiseM :: Applicative m => (a -> a -> m ()) -> [a] -> m ()
pairwiseM _ [] = pure ()
pairwiseM _ [_] = pure ()
pairwiseM p (x : xs) = traverse (p x) xs *> pairwiseM p xs
+
+-- | Return all nonempty tails of a nonempty list. For example:
+--
+-- tails1 (fromList [1]) == fromList [fromList [1]]
+-- tails1 (fromList [1,2]) == fromList [fromList [1,2], fromList [2]]
+-- tails1 (fromList [1,2,3]) == fromList [fromList [1,2,3], fromList [2,3], fromList [3]]
+tails1 :: NonEmpty a -> NonEmpty (NonEmpty a)
+tails1 =
+ -- NEL.fromList is an unsafe function, but this usage should be safe, since:
+ -- - `tails xs = [xs, tail xs, tail (tail xs), ..., []]`
+ -- - If `xs` is nonempty, it follows that `tails xs` contains at least one nonempty
+ -- list, since `head (tails xs) = xs`.
+ -- - The only empty element of `tails xs` is the last one (by the definition of `tails`)
+ -- - Therefore, if we take all but the last element of `tails xs` i.e.
+ -- `init (tails xs)`, we have a nonempty list of nonempty lists
+ NEL.fromList . map NEL.fromList . init . tails . NEL.toList
diff --git a/src/Language/PureScript/TypeChecker/Entailment/Coercible.hs b/src/Language/PureScript/TypeChecker/Entailment/Coercible.hs
new file mode 100644
index 0000000000..8abaac31ca
--- /dev/null
+++ b/src/Language/PureScript/TypeChecker/Entailment/Coercible.hs
@@ -0,0 +1,946 @@
+{-# LANGUAGE DuplicateRecordFields #-}
+
+-- |
+-- Interaction solver for Coercible constraints
+--
+module Language.PureScript.TypeChecker.Entailment.Coercible
+ ( GivenSolverState(..)
+ , initialGivenSolverState
+ , solveGivens
+ , WantedSolverState(..)
+ , initialWantedSolverState
+ , solveWanteds
+ , insoluble
+ ) where
+
+import Prelude hiding (interact)
+
+import Control.Applicative ((<|>), empty)
+import Control.Arrow ((&&&))
+import Control.Monad ((<=<), guard, unless, when)
+import Control.Monad.Error.Class (MonadError, catchError, throwError)
+import Control.Monad.State (MonadState, StateT, get, gets, modify, put)
+import Control.Monad.Trans.Class (lift)
+import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
+import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
+import Control.Monad.Writer.Strict (MonadWriter, Writer, execWriter, runWriter, runWriterT, tell)
+import Data.Either (partitionEithers)
+import Data.Foldable (fold, foldl', for_, toList)
+import Data.Functor (($>))
+import Data.List (find)
+import Data.Maybe (fromMaybe, isJust)
+import Data.Monoid (Any(..))
+import Data.Text (Text)
+
+import Data.Map qualified as M
+import Data.Set qualified as S
+
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (DataDeclType(..), Environment(..), TypeKind(..), unapplyKinds)
+import Language.PureScript.Errors (DeclarationRef(..), ErrorMessageHint(..), ExportSource, ImportDeclarationType(..), MultipleErrors, SimpleErrorMessage(..), SourceAnn, errorMessage, UnknownsHint(..))
+import Language.PureScript.Names (ModuleName, ProperName, ProperNameType(..), Qualified(..), byMaybeModuleName, toMaybeModuleName)
+import Language.PureScript.TypeChecker.Kinds (elaborateKind, freshKindWithKind, unifyKinds')
+import Language.PureScript.TypeChecker.Monad (CheckState(..))
+import Language.PureScript.TypeChecker.Roles (lookupRoles)
+import Language.PureScript.TypeChecker.Synonyms (replaceAllTypeSynonyms)
+import Language.PureScript.TypeChecker.Unify (alignRowsWith, freshTypeWithKind, substituteType)
+import Language.PureScript.Roles (Role(..))
+import Language.PureScript.Types (Constraint(..), SourceType, Type(..), completeBinderList, containsUnknowns, everythingOnTypes, isMonoType, replaceAllTypeVars, rowFromList, srcConstraint, srcTypeApp, unapplyTypes)
+import Language.PureScript.Constants.Prim qualified as Prim
+
+-- | State of the given constraints solver.
+data GivenSolverState =
+ GivenSolverState
+ { inertGivens :: [(SourceType, SourceType, SourceType)]
+ -- ^ A set of irreducible given constraints which do not interact together.
+ , unsolvedGivens :: [(SourceType, SourceType)]
+ -- ^ Given constraints yet to be solved.
+ }
+
+-- | Initialize the given constraints solver state with the givens to solve.
+initialGivenSolverState :: [(SourceType, SourceType)] -> GivenSolverState
+initialGivenSolverState =
+ GivenSolverState []
+
+-- | The given constraints solver follows these steps:
+--
+-- 1. Solving can diverge for recursive newtypes, so we check the solver depth
+-- and abort if we crossed an arbitrary limit.
+--
+-- For instance the declarations:
+--
+-- @
+-- newtype N a = N (a -> N a)
+--
+-- example :: forall a b. N a -> N b
+-- example = coerce
+-- @
+--
+-- yield the wanted @Coercible (N a) (N b)@ which we can unwrap on both sides
+-- to yield @Coercible (a -> N a) (b -> N b)@, which we can then decompose back
+-- to @Coercible a b@ and @Coercible (N a) (N b)@.
+--
+-- 2. We pick a constraint from the unsolved queue. If the queue is empty we are
+-- done, otherwise we unify the constraint arguments kinds and continue.
+--
+-- 3. Then we try to canonicalize the constraint.
+
+-- 3a. Canonicalization can fail, in which case we swallow the error and pretend
+-- the constraint is irreducible because it is possible to eventually solve it.
+--
+-- For instance the declarations:
+--
+-- @
+-- data D a = D a
+-- type role D nominal
+--
+-- example :: forall a b. Coercible (D a) (D b) => D a -> D b
+-- example = coerce
+-- @
+--
+-- yield an insoluble given @Coercible (D a) (D b)@ which discharges the wanted
+-- constraint regardless, because the given can be solved if @a@ and @b@ turn
+-- out to be equal: @example (D true) :: D Boolean@ should compile.
+--
+-- 3b. Canonicalization can succeed with an irreducible constraint which we
+-- then interact with the inert set.
+--
+-- 3bi. These interactions can yield a derived constraint which we add to the
+-- unsolved queue and then go back to 1.
+--
+-- 3bii. These interactions can discharge the constraint, in which case we go
+-- back to 1.
+--
+-- 3biii The constraint may not react to the inert set, in which case we add it
+-- to the inert set, kick out any constraint that can be rewritten by the new
+-- inert, add them to the unsolved queue and then go back to 1.
+--
+-- 3c. Otherwise canonicalization can succeed with derived constraints which we
+-- add to the unsolved queue and then go back to 1.
+solveGivens
+ :: MonadError MultipleErrors m
+ => MonadState CheckState m
+ => Environment
+ -> StateT GivenSolverState m ()
+solveGivens env = go (0 :: Int) where
+ go n = do
+ when (n > 1000) . throwError . errorMessage $ PossiblyInfiniteCoercibleInstance
+ gets unsolvedGivens >>= \case
+ [] -> pure ()
+ given : unsolved -> do
+ (k, a, b) <- lift $ unify given
+ GivenSolverState{..} <- get
+ lift (fst <$> runWriterT (canon env Nothing k a b `catchError` recover)) >>= \case
+ Irreducible -> case interact env (a, b) inertGivens of
+ Just (Simplified (a', b')) ->
+ put $ GivenSolverState { unsolvedGivens = (a', b') : unsolved, .. }
+ Just Discharged ->
+ put $ GivenSolverState { unsolvedGivens = unsolved, .. }
+ Nothing -> do
+ let (kickedOut, kept) = partitionEithers $ kicksOut env (a, b) <$> inertGivens
+ put $ GivenSolverState
+ { inertGivens = (k, a, b) : kept
+ , unsolvedGivens = kickedOut <> unsolved
+ }
+ Canonicalized deriveds ->
+ put $ GivenSolverState { unsolvedGivens = toList deriveds <> unsolved, .. }
+ go (n + 1)
+ recover _ = pure Irreducible
+
+-- | State of the wanted constraints solver.
+data WantedSolverState =
+ WantedSolverState
+ { inertGivens :: [(SourceType, SourceType, SourceType)]
+ -- ^ A set of irreducible given constraints which do not interact together,
+ -- but which could interact with the wanteds.
+ , inertWanteds :: [(SourceType, SourceType, SourceType)]
+ -- ^ A set of irreducible wanted constraints which do not interact together,
+ -- nor with any given.
+ , unsolvedWanteds :: [(SourceType, SourceType)]
+ -- ^ Wanted constraints yet to be solved.
+ }
+
+-- | Initialize the wanted constraints solver state with an inert set of givens
+-- and the two parameters of the wanted to solve.
+initialWantedSolverState
+ :: [(SourceType, SourceType, SourceType)]
+ -> SourceType
+ -> SourceType
+ -> WantedSolverState
+initialWantedSolverState givens a b =
+ WantedSolverState givens [] [(a, b)]
+
+-- | The wanted constraints solver follows similar steps than the given solver,
+-- except for:
+--
+-- 1. When canonicalization fails we can swallow the error, but only if the
+-- wanted interacts with the givens.
+--
+-- For instance the declarations:
+--
+-- @
+-- data D a = D a
+-- type role D nominal
+--
+-- example :: forall a b. Coercible (D a) (D b) => D a -> D b
+-- example = coerce
+-- @
+--
+-- yield an insoluble wanted @Coercible (D a) (D b)@ which is discharged by
+-- the given. But we want @example :: forall a b. D a -> D b@ to fail.
+--
+-- 2. Irreducible wanted constraints don't interact with the inert wanteds set,
+-- because doing so would yield confusing error messages.
+--
+-- For instance the declarations:
+--
+-- @
+-- data D a = D a
+--
+-- example :: forall a. D a a -> D Boolean Char
+-- example = coerce
+-- @
+--
+-- yield the wanted @Coercible (D a a) (D Boolean Char)@, which is decomposed to
+-- the irreducibles @Coercible a Boolean@ and @Coercible a Char@. Would we
+-- interact the latter with the former, we would report an insoluble
+-- @Coercible Boolean Char@.
+solveWanteds
+ :: MonadError MultipleErrors m
+ => MonadWriter [ErrorMessageHint] m
+ => MonadState CheckState m
+ => Environment
+ -> StateT WantedSolverState m ()
+solveWanteds env = go (0 :: Int) where
+ go n = do
+ when (n > 1000) . throwError . errorMessage $ PossiblyInfiniteCoercibleInstance
+ gets unsolvedWanteds >>= \case
+ [] -> pure ()
+ wanted : unsolved -> do
+ (k, a, b) <- lift $ unify wanted
+ WantedSolverState{..} <- get
+ lift (canon env (Just inertGivens) k a b `catchError` recover (a, b) inertGivens) >>= \case
+ Irreducible -> case interact env (a, b) inertGivens of
+ Just (Simplified (a', b')) ->
+ put $ WantedSolverState { unsolvedWanteds = (a', b') : unsolved, .. }
+ Just Discharged ->
+ put $ WantedSolverState { unsolvedWanteds = unsolved, .. }
+ Nothing ->
+ put $ WantedSolverState
+ { inertWanteds = (k, a, b) : inertWanteds
+ , unsolvedWanteds = unsolved
+ , ..
+ }
+ Canonicalized deriveds ->
+ put $ WantedSolverState { unsolvedWanteds = toList deriveds <> unsolved, .. }
+ go (n + 1)
+ recover wanted givens errors =
+ case interact env wanted givens of
+ Nothing -> throwError errors
+ Just (Simplified wanted') -> pure . Canonicalized $ S.singleton wanted'
+ Just Discharged -> pure $ Canonicalized mempty
+
+-- | Unifying constraints arguments kinds isn't strictly necessary but yields
+-- better error messages. For instance we cannot solve the constraint
+-- @Coercible (D :: Type -> Type) (D a :: Type)@ because its arguments kinds
+-- don't match and trying to unify them will say so, which is more helpful than
+-- simply saying that no type class instance was found.
+--
+-- A subtle thing to note is that types with polymorphic kinds can be annotated
+-- with kind applications mentioning unknowns that we may have solved by
+-- unifying the kinds.
+--
+-- For instance the declarations:
+--
+-- @
+-- data D :: forall k. k -> Type
+-- data D a = D
+--
+-- type role D representational
+--
+-- example :: D D -> D D
+-- example = coerce
+-- @
+--
+-- yield a wanted
+-- @Coercible (D \@(k1 -> Type) (D \@k1)) (D \@(k2 -> Type) (D \@k2))@, which we
+-- decompose to @Coercible (D \@k1) (D \@k2)@, where @k1@ and @k2@ are unknowns.
+-- This constraint is not reflexive because @D \@k1@ and @D \@k2@ are differents
+-- but both arguments kinds unify with @k -> Type@, where @k@ is a fresh unknown,
+-- so applying the substitution to @D \@k1@ and @D \@k2@ yields a
+-- @Coercible (D \@k) (D \@k)@ constraint which could be trivially solved by
+-- reflexivity instead of having to saturate the type constructors.
+unify
+ :: MonadError MultipleErrors m
+ => MonadState CheckState m
+ => (SourceType, SourceType)
+ -> m (SourceType, SourceType, SourceType)
+unify (a, b) = do
+ let kindOf = sequence . (id &&& elaborateKind) <=< replaceAllTypeSynonyms
+ (a', kind) <- kindOf a
+ (b', kind') <- kindOf b
+ unifyKinds' kind kind'
+ subst <- gets checkSubstitution
+ pure ( substituteType subst kind
+ , substituteType subst a'
+ , substituteType subst b'
+ )
+
+-- | A successful interaction between an irreducible constraint and an inert
+-- given constraint has two possible outcomes:
+data Interaction
+ = Simplified (SourceType, SourceType)
+ -- ^ The interaction can yield a derived constraint,
+ | Discharged
+ -- ^ or we can learn the irreducible constraint is redundant and discharge it.
+
+-- | Interact an irreducible constraint with an inert set of givens.
+interact
+ :: Environment
+ -> (SourceType, SourceType)
+ -> [(SourceType, SourceType, SourceType)]
+ -> Maybe Interaction
+interact env irred = go where
+ go [] = Nothing
+ go (inert : _)
+ | canDischarge inert irred = Just Discharged
+ | Just derived <- interactSameTyVar inert irred = Just $ Simplified derived
+ | Just derived <- interactDiffTyVar env inert irred = Just $ Simplified derived
+ go (_ : inerts) = go inerts
+
+-- | A given constraint of the form @Coercible a b@ can discharge constraints
+-- of the form @Coercible a b@ and @Coercible b a@.
+canDischarge
+ :: (SourceType, SourceType, SourceType)
+ -> (SourceType, SourceType)
+ -> Bool
+canDischarge (_, a, b) constraint =
+ (a, b) == constraint || (b, a) == constraint
+
+-- | Two canonical constraints of the form @Coercible tv ty1@ and
+-- @Coercible tv ty2@ can interact together and yield a new constraint
+-- @Coercible ty1 ty2@. Canonicality matters to avoid loops.
+--
+-- For instance the declarations:
+--
+-- @
+-- data D a = D a
+-- newtype N a = N (D (N a))
+--
+-- example :: forall a. Coercible a (D a) => a -> N a
+-- example = coerce
+-- @
+--
+-- yield a non canonical wanted @Coercible a (N a)@ that we can unwrap on the
+-- right to yield @Coercible a (D (N a))@. Would it interact with the non
+-- canonical given @Coercible a (D a)@ it would give @Coercible (D a) (D (N a))@,
+-- then decompose back to @Coercible a (N a)@.
+interactSameTyVar
+ :: (SourceType, SourceType, SourceType)
+ -> (SourceType, SourceType)
+ -> Maybe (SourceType, SourceType)
+interactSameTyVar (_, tv1, ty1) (tv2, ty2)
+ | tv1 == tv2 && isCanonicalTyVarEq (tv1, ty1) && isCanonicalTyVarEq (tv2, ty2)
+ = Just (ty1, ty2)
+ | otherwise = Nothing
+
+-- | Two canonical constraints of the form @Coercible tv1 ty1@ and
+-- @Coercible tv2 ty2@ can interact together and yield a new constraint
+-- @Coercible tv2 ty2[ty1/tv1]@. Once again, canonicality matters to avoid loops.
+--
+-- For instance the declarations:
+--
+-- @
+-- data D a = D a
+--
+-- example :: forall a b. Coercible b (D b) => a -> b
+-- example = coerce
+-- @
+--
+-- yield an irreducible canonical wanted @Coercible a b@. Would it interact with
+-- the non canonical given @Coercible b (D b)@ it would give @Coercible a (D b)@,
+-- which would keep interacting indefinitely with the given.
+interactDiffTyVar
+ :: Environment
+ -> (SourceType, SourceType, SourceType)
+ -> (SourceType, SourceType)
+ -> Maybe (SourceType, SourceType)
+interactDiffTyVar env (_, tv1, ty1) (tv2, ty2)
+ | tv1 /= tv2 && isCanonicalTyVarEq (tv2, ty2)
+ , (ty2', Any True) <- runWriter $ rewrite env (tv1, ty1) ty2
+ = Just (tv2, ty2')
+ | otherwise = Nothing
+
+-- | A canonical constraint of the form @Coercible tv1 ty1@ can rewrite the
+-- right hand side of an irreducible constraint of the form @Coercible tv2 ty2@
+-- by substituting @ty1@ for every occurrence of @tv1@ at representational and
+-- phantom role in @ty2@. Nominal occurrences are left untouched.
+rewrite :: Environment -> (SourceType, SourceType) -> SourceType -> Writer Any SourceType
+rewrite env (Skolem _ _ _ s1 _, ty1) | not $ occurs s1 ty1 = go where
+ go (Skolem _ _ _ s2 _) | s1 == s2 = tell (Any True) $> ty1
+ go ty2 | (Skolem{}, _, xs) <- unapplyTypes ty2, not $ null xs =
+ rewriteTyVarApp go ty2
+ | (TypeConstructor _ tyName, _, _) <- unapplyTypes ty2 = do
+ rewriteTyConApp go (lookupRoles env tyName) ty2
+ go (KindApp sa ty k) = KindApp sa <$> go ty <*> pure k
+ go (ForAll sa vis tv k ty scope) = ForAll sa vis tv k <$> go ty <*> pure scope
+ go (ConstrainedType sa Constraint{..} ty) | s1 `S.notMember` foldMap skolems constraintArgs =
+ ConstrainedType sa Constraint{..} <$> go ty
+ go (RCons sa label ty rest) = RCons sa label <$> go ty <*> go rest
+ go (KindedType sa ty k) = KindedType sa <$> go ty <*> pure k
+ go ty2 = pure ty2
+rewrite _ _ = pure
+
+-- | Rewrite the head of a type application of the form @tv a_0 .. a_n@.
+rewriteTyVarApp
+ :: Applicative m
+ => (SourceType -> m SourceType)
+ -> SourceType
+ -> m SourceType
+rewriteTyVarApp f = go where
+ go (TypeApp sa lhs rhs) =
+ TypeApp sa <$> go lhs <*> pure rhs
+ go (KindApp sa ty k) =
+ KindApp sa <$> go ty <*> pure k
+ go ty = f ty
+
+-- | Rewrite the representational and phantom arguments of a type application
+-- of the form @D a_0 .. a_n@.
+rewriteTyConApp
+ :: Applicative m
+ => (SourceType -> m SourceType)
+ -> [Role]
+ -> SourceType
+ -> m SourceType
+rewriteTyConApp f = go where
+ go (role : roles) (TypeApp sa lhs rhs) =
+ TypeApp sa <$> go roles lhs <*> case role of
+ Nominal -> pure rhs
+ _ -> f rhs
+ go roles (KindApp sa ty k) =
+ KindApp sa <$> go roles ty <*> pure k
+ go _ ty = pure ty
+
+canRewrite :: Environment -> (SourceType, SourceType) -> SourceType -> Bool
+canRewrite env irred = getAny . execWriter . rewrite env irred
+
+-- | An irreducible given constraint must kick out of the inert set any
+-- constraint it can rewrite when it becomes inert, otherwise solving would be
+-- sensitive to the order of constraints. Wanteds cannot rewrite other wanteds
+-- so this applies only to givens.
+--
+-- For instance the declaration:
+--
+-- @
+-- example :: forall f g a b. Coercible a (f b) => Coercible f g => Proxy f -> a -> g b
+-- example _ = coerce
+-- @
+--
+-- yields the irreducible givens @Coercible a (f b)@ and @Coercible f g@. Would
+-- we not kick out the former when adding the latter to the inert set we would
+-- not be able to rewrite it to @Coercible a (g b)@ and discharge the wanted,
+-- but inverting the givens would work.
+kicksOut
+ :: Environment
+ -> (SourceType, SourceType)
+ -> (SourceType, SourceType, SourceType)
+ -> Either (SourceType, SourceType) (SourceType, SourceType, SourceType)
+kicksOut env irred (_, tv2, ty2)
+ | isCanonicalTyVarEq (tv2, ty2) && canRewrite env irred ty2
+ = Left (tv2, ty2)
+kicksOut _ _ inert = Right inert
+
+-- | A constraint of the form @Coercible tv ty@ is canonical when @tv@ does not
+-- occur in @ty@. Non canonical constraints do not interact to prevent loops.
+isCanonicalTyVarEq :: (SourceType, SourceType) -> Bool
+isCanonicalTyVarEq (Skolem _ _ _ s _, ty) = not $ occurs s ty
+isCanonicalTyVarEq _ = False
+
+occurs :: Int -> SourceType -> Bool
+occurs s1 = everythingOnTypes (||) go where
+ go (Skolem _ _ _ s2 _) | s1 == s2 = True
+ go _ = False
+
+skolems :: SourceType -> S.Set Int
+skolems = everythingOnTypes (<>) go where
+ go (Skolem _ _ _ s _) = S.singleton s
+ go _ = mempty
+
+-- | A successful canonicalization result has two possible outcomes:
+data Canonicalized
+ = Canonicalized (S.Set (SourceType, SourceType))
+ -- ^ Canonicalization can yield a set of derived constraints,
+ | Irreducible
+ -- ^ or we can learn the constraint is irreducible. Irreducibility is not
+ -- necessarily an error, we may make further progress by interacting with
+ -- inerts.
+
+-- | Canonicalization takes a wanted constraint and try to reduce it to a set of
+-- simpler constraints whose satisfaction will imply the goal.
+canon
+ :: MonadError MultipleErrors m
+ => MonadWriter [ErrorMessageHint] m
+ => MonadState CheckState m
+ => Environment
+ -> Maybe [(SourceType, SourceType, SourceType)]
+ -> SourceType
+ -> SourceType
+ -> SourceType
+ -> m Canonicalized
+canon env givens k a b =
+ maybe (throwError $ insoluble k a b) pure <=< runMaybeT $
+ canonRefl a b
+ <|> canonUnsaturatedHigherKindedType env a b
+ <|> canonRow a b
+ -- We unwrap newtypes before trying the decomposition rules because it let
+ -- us solve more constraints.
+ --
+ -- For instance the declarations:
+ --
+ -- @
+ -- newtype N f a = N (f a)
+ --
+ -- example :: forall a b. Coercible a b => N Maybe a -> N Maybe b
+ -- example = coerce
+ -- @
+ --
+ -- yield the wanted @Coercible (N Maybe a) (N Maybe b)@ which we cannot
+ -- decompose because the second parameter of @N@ is nominal. On the other
+ -- hand, unwrapping on both sides yields @Coercible (Maybe a) (Maybe b)@
+ -- which we can then decompose to @Coercible a b@ and discharge with the
+ -- given.
+ <|> canonNewtypeLeft env a b
+ <|> canonNewtypeRight env a b
+ <|> canonDecomposition env a b
+ <|> canonDecompositionFailure env k a b
+ <|> canonNewtypeDecomposition env givens a b
+ <|> canonNewtypeDecompositionFailure a b
+ <|> canonTypeVars a b
+ <|> canonTypeVarLeft a b
+ <|> canonTypeVarRight a b
+ <|> canonApplicationLeft a b
+ <|> canonApplicationRight a b
+
+insoluble
+ :: SourceType
+ -> SourceType
+ -> SourceType
+ -> MultipleErrors
+insoluble k a b =
+ -- We can erase kind applications when determining whether to show the
+ -- "Consider adding a type annotation" hint, because annotating kinds to
+ -- instantiate unknowns in Coercible constraints should never resolve
+ -- NoInstanceFound errors.
+ errorMessage $ NoInstanceFound (srcConstraint Prim.Coercible [k] [a, b] Nothing) []
+ $ if any containsUnknowns [a, b] then Unknowns else NoUnknowns
+
+-- | Constraints of the form @Coercible a b@ can be solved if the two arguments
+-- are the same. Since we currently don't support higher-rank arguments in
+-- instance heads, term equality is a sufficient notion of "the same".
+canonRefl
+ :: Monad m
+ => SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonRefl a b =
+ guard (a == b) $> Canonicalized mempty
+
+-- | Constraints of the form @Coercible (T1 a_0 .. a_n) (T2 b_0 .. b_n)@, where
+-- both arguments have kind @k1 -> k2@, yield a constraint
+-- @Coercible (T1 a_0 .. a_n c_0 .. c_m) (T2 b_0 .. b_n c_0 .. c_m)@, where both
+-- arguments are fully saturated with the same unknowns and have kind @Type@.
+canonUnsaturatedHigherKindedType
+ :: MonadError MultipleErrors m
+ => MonadState CheckState m
+ => Environment
+ -> SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonUnsaturatedHigherKindedType env a b
+ | (TypeConstructor _ aTyName, akapps, axs) <- unapplyTypes a
+ , (ak, _) <- fromMaybe (internalError "canonUnsaturatedHigherKindedType: type lookup failed") $ M.lookup aTyName (types env)
+ , (aks, _) <- unapplyKinds ak
+ , length axs < length aks = do
+ ak' <- lift $ do
+ let (kvs, ak') = fromMaybe (internalError "canonUnsaturatedHigherKindedType: unkinded forall binder") $ completeBinderList ak
+ instantiatedKinds = zipWith (\(_, (kv, _)) k -> (kv, k)) kvs akapps
+ unknownKinds <- traverse (\((ss, _), (kv, k)) -> (kv,) <$> freshKindWithKind ss k) $ drop (length akapps) kvs
+ pure $ replaceAllTypeVars (instantiatedKinds <> unknownKinds) ak'
+ let (aks', _) = unapplyKinds ak'
+ tys <- traverse freshTypeWithKind $ drop (length axs) aks'
+ let a' = foldl' srcTypeApp a tys
+ b' = foldl' srcTypeApp b tys
+ pure . Canonicalized $ S.singleton (a', b')
+ | otherwise = empty
+
+-- | Constraints of the form
+-- @Coercible ( label_0 :: a_0, .. label_n :: a_n | r ) ( label_0 :: b_0, .. label_n :: b_n | s )@
+-- yield a constraint @Coercible r s@ and constraints on the types for each
+-- label in both rows. Labels exclusive to one row yield a failure.
+canonRow
+ :: MonadError MultipleErrors m
+ => MonadState CheckState m
+ => SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonRow a b
+ | RCons{} <- a =
+ case alignRowsWith (const (,)) a b of
+ -- We throw early when a bare unknown remains on either side after
+ -- aligning the rows because we don't know how to canonicalize them yet
+ -- and the unification error thrown when the rows are misaligned should
+ -- not mention unknowns.
+ (_, (([], u@TUnknown{}), rl2)) -> do
+ k <- elaborateKind u
+ throwError $ insoluble k u (rowFromList rl2)
+ (_, (rl1, ([], u@TUnknown{}))) -> do
+ k <- elaborateKind u
+ throwError $ insoluble k (rowFromList rl1) u
+ (deriveds, (([], tail1), ([], tail2))) -> do
+ pure . Canonicalized . S.fromList $ (tail1, tail2) : deriveds
+ (_, (rl1, rl2)) ->
+ throwError . errorMessage $ TypesDoNotUnify (rowFromList rl1) (rowFromList rl2)
+ | otherwise = empty
+
+-- | Unwrapping a newtype can fails in two ways:
+data UnwrapNewtypeError
+ = CannotUnwrapInfiniteNewtypeChain
+ -- ^ The newtype might wrap an infinite newtype chain. We may think that this
+ -- is already handled by the solver depth check, but failing to unwrap
+ -- infinite chains of newtypes let us try other rules.
+ --
+ -- For instance the declarations:
+ --
+ -- @
+ -- newtype N a = N (N a)
+ -- type role N representational
+ --
+ -- example :: forall a b. Coercible a b => N a -> N b
+ -- example = coerce
+ -- @
+ --
+ -- yield a wanted @Coercible (N a) (N b)@ that we can decompose to
+ -- @Coercible a b@ then discharge with the given if the newtype
+ -- unwrapping rules do not apply.
+ | CannotUnwrapConstructor
+ -- ^ The constructor may not be in scope or may not belong to a newtype.
+
+-- | Unwraps a newtype and yields its underlying type with the newtype arguments
+-- substituted in (e.g. @N[D/a] = D@ given @newtype N a = N a@ and @data D = D@).
+unwrapNewtype
+ :: MonadState CheckState m
+ => MonadWriter [ErrorMessageHint] m
+ => Environment
+ -> SourceType
+ -> m (Either UnwrapNewtypeError SourceType)
+unwrapNewtype env = go (0 :: Int) where
+ go n ty = runExceptT $ do
+ when (n > 1000) $ throwError CannotUnwrapInfiniteNewtypeChain
+ (currentModuleName, currentModuleImports) <- gets $ checkCurrentModule &&& checkCurrentModuleImports
+ case unapplyTypes ty of
+ (TypeConstructor _ newtypeName, ks, xs)
+ | Just (inScope, fromModuleName, tvs, newtypeCtorName, wrappedTy) <-
+ lookupNewtypeConstructorInScope env currentModuleName currentModuleImports newtypeName ks
+ -- We refuse to unwrap newtypes over polytypes because we don't know how
+ -- to canonicalize them yet and we'd rather try to make progress with
+ -- another rule.
+ , isMonoType wrappedTy -> do
+ unless inScope $ do
+ tell [MissingConstructorImportForCoercible newtypeCtorName]
+ throwError CannotUnwrapConstructor
+ for_ fromModuleName $ flip addConstructorImportForCoercible newtypeCtorName
+ let wrappedTySub = replaceAllTypeVars (zip tvs xs) wrappedTy
+ ExceptT (go (n + 1) wrappedTySub) `catchError` \case
+ CannotUnwrapInfiniteNewtypeChain -> throwError CannotUnwrapInfiniteNewtypeChain
+ CannotUnwrapConstructor -> pure wrappedTySub
+ _ -> throwError CannotUnwrapConstructor
+ addConstructorImportForCoercible fromModuleName newtypeCtorName = modify $ \st ->
+ st { checkConstructorImportsForCoercible = S.insert (fromModuleName, newtypeCtorName) $ checkConstructorImportsForCoercible st }
+
+-- | Looks up a given name and, if it names a newtype, returns the names of the
+-- type's parameters, the type the newtype wraps and the names of the type's
+-- fields.
+lookupNewtypeConstructor
+ :: Environment
+ -> Qualified (ProperName 'TypeName)
+ -> [SourceType]
+ -> Maybe ([Text], ProperName 'ConstructorName, SourceType)
+lookupNewtypeConstructor env qualifiedNewtypeName ks = do
+ (newtyk, DataType Newtype tvs [(ctorName, [wrappedTy])]) <- M.lookup qualifiedNewtypeName (types env)
+ let (kvs, _) = fromMaybe (internalError "lookupNewtypeConstructor: unkinded forall binder") $ completeBinderList newtyk
+ instantiatedKinds = zipWith (\(_, (kv, _)) k -> (kv, k)) kvs ks
+ pure (map (\(name, _, _) -> name) tvs, ctorName, replaceAllTypeVars instantiatedKinds wrappedTy)
+
+-- | Behaves like 'lookupNewtypeConstructor' but also returns whether the
+-- newtype constructor is in scope and the module from which it is imported, or
+-- 'Nothing' if it is defined in the current module.
+lookupNewtypeConstructorInScope
+ :: Environment
+ -> Maybe ModuleName
+ -> [ ( SourceAnn
+ , ModuleName
+ , ImportDeclarationType
+ , Maybe ModuleName
+ , M.Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ExportSource)
+ )
+ ]
+ -> Qualified (ProperName 'TypeName)
+ -> [SourceType]
+ -> Maybe (Bool, Maybe ModuleName, [Text], Qualified (ProperName 'ConstructorName), SourceType)
+lookupNewtypeConstructorInScope env currentModuleName currentModuleImports qualifiedNewtypeName@(Qualified newtypeModuleName newtypeName) ks = do
+ let fromModule = find isNewtypeCtorImported currentModuleImports
+ fromModuleName = (\(_, n, _, _, _) -> n) <$> fromModule
+ asModuleName = (\(_, _, _, n, _) -> n) =<< fromModule
+ isDefinedInCurrentModule = toMaybeModuleName newtypeModuleName == currentModuleName
+ isImported = isJust fromModule
+ inScope = isDefinedInCurrentModule || isImported
+ (tvs, ctorName, wrappedTy) <- lookupNewtypeConstructor env qualifiedNewtypeName ks
+ pure (inScope, fromModuleName, tvs, Qualified (byMaybeModuleName asModuleName) ctorName, wrappedTy)
+ where
+ isNewtypeCtorImported (_, _, importDeclType, _, exportedTypes) =
+ case M.lookup newtypeName exportedTypes of
+ Just ([_], _) -> case importDeclType of
+ Implicit -> True
+ Explicit refs -> any isNewtypeCtorRef refs
+ Hiding refs -> not $ any isNewtypeCtorRef refs
+ _ -> False
+ isNewtypeCtorRef = \case
+ TypeRef _ importedTyName Nothing -> importedTyName == newtypeName
+ TypeRef _ importedTyName (Just [_]) -> importedTyName == newtypeName
+ _ -> False
+
+-- | Constraints of the form @Coercible (N a_0 .. a_n) b@ yield a constraint
+-- @Coercible a b@ if unwrapping the newtype yields @a@.
+canonNewtypeLeft
+ :: MonadState CheckState m
+ => MonadWriter [ErrorMessageHint] m
+ => Environment
+ -> SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonNewtypeLeft env a b =
+ unwrapNewtype env a >>= \case
+ Left CannotUnwrapInfiniteNewtypeChain -> empty
+ Left CannotUnwrapConstructor -> empty
+ Right a' -> pure . Canonicalized $ S.singleton (a', b)
+
+-- | Constraints of the form @Coercible a (N b_0 .. b_n)@ yield a constraint
+-- @Coercible a b@ if unwrapping the newtype yields @b@.
+canonNewtypeRight
+ :: MonadState CheckState m
+ => MonadWriter [ErrorMessageHint] m
+ => Environment
+ -> SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonNewtypeRight env =
+ flip $ canonNewtypeLeft env
+
+-- | Decomposes constraints of the form @Coercible (D a_0 .. a_n) (D b_0 .. b_n)@
+-- into constraints on their representational arguments, ignoring phantom
+-- arguments and failing on unequal nominal arguments.
+--
+-- For instance given the declarations:
+--
+-- @
+-- data D a b c = D a b
+-- type role D nominal representational phantom
+-- @
+--
+-- We can decompose @Coercible (D a b d) (D a c e)@ into @Coercible b c@, but
+-- decomposing @Coercible (D a c d) (D b c d)@ would fail.
+decompose
+ :: MonadError MultipleErrors m
+ => Environment
+ -> Qualified (ProperName 'TypeName)
+ -> [SourceType]
+ -> [SourceType]
+ -> m Canonicalized
+decompose env tyName axs bxs = do
+ let roles = lookupRoles env tyName
+ f role ax bx = case role of
+ Nominal
+ -- If we had first-class equality constraints, we'd just
+ -- emit one of the form @(a ~ b)@ here and let the solver
+ -- recurse. Since we don't we must compare the types at
+ -- this point and fail if they don't match. This likely
+ -- means there are cases we should be able to handle that
+ -- we currently can't, but is at least sound.
+ | ax == bx ->
+ pure mempty
+ | otherwise ->
+ throwError . errorMessage $ TypesDoNotUnify ax bx
+ Representational ->
+ pure $ S.singleton (ax, bx)
+ Phantom ->
+ pure mempty
+ fmap (Canonicalized . fold) $ sequence $ zipWith3 f roles axs bxs
+
+-- | Constraints of the form @Coercible (D a_0 .. a_n) (D b_0 .. b_n)@, where
+-- @D@ is not a newtype, yield constraints on their arguments.
+canonDecomposition
+ :: MonadError MultipleErrors m
+ => Environment
+ -> SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonDecomposition env a b
+ | (TypeConstructor _ aTyName, _, axs) <- unapplyTypes a
+ , (TypeConstructor _ bTyName, _, bxs) <- unapplyTypes b
+ , aTyName == bTyName
+ , Nothing <- lookupNewtypeConstructor env aTyName [] =
+ decompose env aTyName axs bxs
+ | otherwise = empty
+
+-- | Constraints of the form @Coercible (D1 a_0 .. a_n) (D2 b_0 .. b_n)@, where
+-- @D1@ and @D2@ are different type constructors and neither of them are
+-- newtypes, are insoluble.
+canonDecompositionFailure
+ :: MonadError MultipleErrors m
+ => Environment
+ -> SourceType
+ -> SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonDecompositionFailure env k a b
+ | (TypeConstructor _ aTyName, _, _) <- unapplyTypes a
+ , (TypeConstructor _ bTyName, _, _) <- unapplyTypes b
+ , aTyName /= bTyName
+ , Nothing <- lookupNewtypeConstructor env aTyName []
+ , Nothing <- lookupNewtypeConstructor env bTyName [] =
+ throwError $ insoluble k a b
+ | otherwise = empty
+
+-- | Wanted constraints of the form @Coercible (N a_0 .. a_n) (N b_0 .. b_n)@,
+-- where @N@ is a newtype whose constructor is out of scope, yield constraints
+-- on their arguments only when no given constraint can discharge them.
+--
+-- We cannot decompose given constraints because newtypes are not necessarily
+-- injective with respect to representational equality.
+--
+-- For instance given the declaration:
+--
+-- @
+-- newtype Const a b = MkConst a
+-- type role Const representational representational
+-- @
+--
+-- Decomposing a given @Coercible (Const a a) (Const a b)@ constraint to
+-- @Coercible a b@ when @MkConst@ is out of scope would let us coerce arbitrary
+-- types in modules where @MkConst@ is imported, because the given is easily
+-- satisfied with the newtype unwrapping rules.
+--
+-- Moreover we do not decompose wanted constraints if they could be discharged
+-- by a given constraint.
+--
+-- For instance the declaration:
+--
+-- @
+-- example :: forall a b. Coercible (Const a a) (Const a b) => Const a a -> Const a b
+-- example = coerce
+-- @
+--
+-- yield an irreducible given @Coercible (Const a a) (Const a b)@ when @MkConst@
+-- is out of scope. Would we decompose the wanted
+-- @Coercible (Const a a) (Const a b)@ to @Coercible a b@ we would not be able
+-- to discharge it with the given.
+canonNewtypeDecomposition
+ :: MonadError MultipleErrors m
+ => Environment
+ -> Maybe [(SourceType, SourceType, SourceType)]
+ -> SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonNewtypeDecomposition env (Just givens) a b
+ | (TypeConstructor _ aTyName, _, axs) <- unapplyTypes a
+ , (TypeConstructor _ bTyName, _, bxs) <- unapplyTypes b
+ , aTyName == bTyName
+ , Just _ <- lookupNewtypeConstructor env aTyName [] = do
+ let givensCanDischarge = any (\given -> canDischarge given (a, b)) givens
+ guard $ not givensCanDischarge
+ decompose env aTyName axs bxs
+canonNewtypeDecomposition _ _ _ _ = empty
+
+-- | Constraints of the form @Coercible (N1 a_0 .. a_n) (N2 b_0 .. b_n)@, where
+-- @N1@ and @N2@ are different type constructors and either of them is a
+-- newtype whose constructor is out of scope, are irreducible.
+canonNewtypeDecompositionFailure
+ :: Monad m
+ => SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonNewtypeDecompositionFailure a b
+ | (TypeConstructor{}, _, _) <- unapplyTypes a
+ , (TypeConstructor{}, _, _) <- unapplyTypes b
+ = pure Irreducible
+ | otherwise = empty
+
+-- | Constraints of the form @Coercible tv1 tv2@ may be irreducibles, but only
+-- when the variables are lexicographically ordered. Reordering variables is
+-- necessary to prevent loops.
+--
+-- For instance the declaration:
+--
+-- @
+-- example :: forall a b. Coercible a b => Coercible b a => a -> b
+-- example = coerce
+-- @
+--
+-- yields the irreducible givens @Coercible a b@ and @Coercible b a@ which would
+-- repeatedly kick each other out the inert set whereas reordering the latter to
+-- @Coercible a b@ makes it redundant and let us discharge it.
+canonTypeVars
+ :: Monad m
+ => SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonTypeVars a b
+ | Skolem _ tv1 _ _ _ <- a
+ , Skolem _ tv2 _ _ _ <- b
+ , tv2 < tv1
+ = pure . Canonicalized $ S.singleton (b, a)
+ | Skolem{} <- a, Skolem{} <- b
+ = pure Irreducible
+ | otherwise = empty
+
+-- | Constraints of the form @Coercible tv ty@ are irreducibles.
+canonTypeVarLeft
+ :: Monad m
+ => SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonTypeVarLeft a _
+ | Skolem{} <- a = pure Irreducible
+ | otherwise = empty
+
+-- | Constraints of the form @Coercible ty tv@ are reordered to
+-- @Coercible tv ty@ to satisfy the canonicality requirement of having the type
+-- variable on the left.
+canonTypeVarRight
+ :: Monad m
+ => SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonTypeVarRight a b
+ | Skolem{} <- b = pure . Canonicalized $ S.singleton (b, a)
+ | otherwise = empty
+
+-- | Constraints of the form @Coercible (f a_0 .. a_n) b@ are irreducibles.
+canonApplicationLeft
+ :: Monad m
+ => SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonApplicationLeft a _
+ | TypeApp{} <- a = pure Irreducible
+ | otherwise = empty
+
+-- | Constraints of the form @Coercible a (f b_0 .. b_n) b@ are irreducibles.
+canonApplicationRight
+ :: Monad m
+ => SourceType
+ -> SourceType
+ -> MaybeT m Canonicalized
+canonApplicationRight _ b
+ | TypeApp{} <- b = pure Irreducible
+ | otherwise = empty
diff --git a/src/Language/PureScript/TypeChecker/Entailment/IntCompare.hs b/src/Language/PureScript/TypeChecker/Entailment/IntCompare.hs
new file mode 100644
index 0000000000..802e9d611e
--- /dev/null
+++ b/src/Language/PureScript/TypeChecker/Entailment/IntCompare.hs
@@ -0,0 +1,102 @@
+-- |
+-- Graph-based solver for comparing type-level numbers with respect to
+-- reflexivity, symmetry, and transitivity properties.
+--
+module Language.PureScript.TypeChecker.Entailment.IntCompare where
+
+import Protolude
+
+import Data.Graph qualified as G
+import Data.Map qualified as M
+
+import Language.PureScript.Names qualified as P
+import Language.PureScript.Types qualified as P
+import Language.PureScript.Constants.Prim qualified as P
+
+data Relation a
+ = Equal a a
+ | LessThan a a
+ deriving (Functor, Show, Eq, Ord)
+
+type Context a = [Relation a]
+
+type PSOrdering = P.Qualified (P.ProperName 'P.TypeName)
+
+-- Commentary:
+--
+-- In essence, this solver builds a directed graph using the provided
+-- context, which is then used to determine the relationship between
+-- the two elements being compared.
+--
+-- Given the context [a < b, b < c], we can infer that a < c as a
+-- path exists from a to c. Likewise, we can also infer that c > a
+-- as a path exists from c to a.
+--
+-- ╔═══╗ ╔═══╗ ╔═══╗
+-- ║ a ║ -> ║ b ║ -> ║ c ║
+-- ╚═══╝ ╚═══╝ ╚═══╝
+--
+-- Introducing equality to the context augments the graph further,
+-- and it is represented by creating cycles between equal nodes.
+-- For example, [a < b, b < c, c = d] yields the following graph:
+--
+-- ╔═══╗ ╔═══╗ ╔═══╗ ╔═══╗
+-- ║ a ║ -> ║ b ║ -> ║ c ║ <-> ║ d ║
+-- ╚═══╝ ╚═══╝ ╚═══╝ ╚═══╝
+solveRelation :: forall a. Ord a => Context a -> a -> a -> Maybe PSOrdering
+solveRelation context lhs rhs =
+ if lhs == rhs then
+ pure P.EQ
+ else do
+ let (graph, search) = inequalities
+ lhs' <- search lhs
+ rhs' <- search rhs
+ case (G.path graph lhs' rhs', G.path graph rhs' lhs') of
+ (True, True) ->
+ pure P.EQ
+ (True, False) ->
+ pure P.LT
+ (False, True) ->
+ pure P.GT
+ _ ->
+ Nothing
+ where
+ inequalities :: (G.Graph, a -> Maybe G.Vertex)
+ inequalities = makeGraph $ clean $ foldMap convert context
+ where
+ convert :: Relation a -> [(a, [a])]
+ convert (Equal a b) = [(a, [b]), (b, [a])]
+ convert (LessThan a b) = [(a, [b]), (b, [])]
+
+ makeGraph :: [(a, [a])] -> (G.Graph, a -> Maybe G.Vertex)
+ makeGraph m =
+ case G.graphFromEdges $ (\(a, b) -> (a, a, b)) <$> m of
+ (g, _, f) -> (g, f)
+
+ clean :: forall k. Ord k => [(k, [k])] -> [(k, [k])]
+ clean = M.toList . M.fromListWith (<>)
+
+mkRelation :: P.Type a -> P.Type a -> P.Type a -> Maybe (Relation (P.Type a))
+mkRelation lhs rhs rel = case rel of
+ P.TypeConstructor _ ordering
+ | ordering == P.EQ -> pure $ Equal lhs rhs
+ | ordering == P.LT -> pure $ LessThan lhs rhs
+ | ordering == P.GT -> pure $ LessThan rhs lhs
+ _ ->
+ Nothing
+
+mkFacts :: [[P.Type a]] -> [Relation (P.Type a)]
+mkFacts = mkRels [] . sort . findFacts
+ where
+ mkRels a [] = concat a
+ mkRels a (x : xs) = mkRels (map (LessThan x) xs : a) xs
+
+ findFacts = mapMaybe $ \case
+ [P.TypeLevelInt _ _, P.TypeLevelInt _ _, _] ->
+ Nothing
+ [i@(P.TypeLevelInt _ _), _, _] ->
+ Just i
+ [_, i@(P.TypeLevelInt _ _), _] ->
+ Just i
+ _ ->
+ Nothing
diff --git a/src/Language/PureScript/TypeChecker/Kinds.hs b/src/Language/PureScript/TypeChecker/Kinds.hs
index 28a4009b52..1a758aab48 100644
--- a/src/Language/PureScript/TypeChecker/Kinds.hs
+++ b/src/Language/PureScript/TypeChecker/Kinds.hs
@@ -1,276 +1,1021 @@
-{-# LANGUAGE FlexibleInstances #-}
-
-- |
-- This module implements the kind checker
--
module Language.PureScript.TypeChecker.Kinds
( kindOf
+ , kindOfWithUnknowns
, kindOfWithScopedVars
- , kindsOf
+ , kindOfData
+ , kindOfTypeSynonym
+ , kindOfClass
, kindsOfAll
+ , unifyKinds
+ , unifyKinds'
+ , subsumesKind
+ , instantiateKind
+ , checkKind
+ , inferKind
+ , elaborateKind
+ , checkConstraint
+ , checkInstanceDeclaration
+ , checkKindDeclaration
+ , checkTypeKind
+ , unknownsWithKinds
+ , freshKind
+ , freshKindWithKind
) where
-import Prelude.Compat
+import Prelude
+import Protolude (headDef)
-import Control.Arrow (second)
-import Control.Monad
+import Control.Arrow ((***))
+import Control.Lens ((^.), _1, _2, _3)
+import Control.Monad (join, unless, void, when, (<=<))
import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.State
+import Control.Monad.State (MonadState, gets, modify)
+import Control.Monad.Supply.Class (MonadSupply(..))
+import Data.Bifunctor (first, second)
+import Data.Bitraversable (bitraverse)
+import Data.Foldable (for_, traverse_)
+import Data.Function (on)
import Data.Functor (($>))
-import qualified Data.Map as M
+import Data.IntSet qualified as IS
+import Data.List (nubBy, sortOn, (\\))
+import Data.Map qualified as M
+import Data.Maybe (fromJust, fromMaybe)
import Data.Text (Text)
+import Data.Text qualified as T
import Data.Traversable (for)
-import Language.PureScript.Crash
-import Language.PureScript.Environment
+import Language.PureScript.Crash (HasCallStack, internalError)
+import Language.PureScript.Environment qualified as E
import Language.PureScript.Errors
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.TypeChecker.Monad
+import Language.PureScript.Names (pattern ByNullSourcePos, ModuleName, Name(..), ProperName(..), ProperNameType(..), Qualified(..), QualifiedBy(..), coerceProperName, mkQualified)
+import Language.PureScript.TypeChecker.Monad (CheckState(..), Substitution(..), UnkLevel(..), Unknown, bindLocalTypeVariables, debugType, getEnv, lookupTypeVariable, unsafeCheckCurrentModule, withErrorMessageHint, withFreshSubstitution)
+import Language.PureScript.TypeChecker.Skolems (newSkolemConstant, newSkolemScope, skolemize)
+import Language.PureScript.TypeChecker.Synonyms (replaceAllTypeSynonyms)
import Language.PureScript.Types
+import Language.PureScript.Pretty.Types (prettyPrintType)
--- | Generate a fresh kind variable
-freshKind :: (MonadState CheckState m) => SourceAnn -> m SourceKind
-freshKind ann = do
- k <- gets checkNextKind
- modify $ \st -> st { checkNextKind = k + 1 }
- return $ KUnknown ann k
-
-freshKind' :: (MonadState CheckState m) => m SourceKind
-freshKind' = freshKind NullSourceAnn
-
--- | Update the substitution to solve a kind constraint
-solveKind
- :: (MonadError MultipleErrors m, MonadState CheckState m)
- => Int
- -> SourceKind
- -> m ()
-solveKind u k = do
- occursCheck u k
- modify $ \cs -> cs { checkSubstitution =
- (checkSubstitution cs) { substKind =
- M.insert u k $ substKind $ checkSubstitution cs
- }
- }
-
--- | Apply a substitution to a kind
-substituteKind :: Substitution -> SourceKind -> SourceKind
-substituteKind sub = everywhereOnKinds go
+generalizeUnknowns :: [(Unknown, SourceType)] -> SourceType -> SourceType
+generalizeUnknowns unks ty =
+ generalizeUnknownsWithVars (unknownVarNames (usedTypeVariables ty) unks) ty
+
+generalizeUnknownsWithVars :: [(Unknown, (Text, SourceType))] -> SourceType -> SourceType
+generalizeUnknownsWithVars binders ty =
+ mkForAll ((getAnnForType ty,) . fmap (Just . replaceUnknownsWithVars binders) . snd <$> binders) . replaceUnknownsWithVars binders $ ty
+
+replaceUnknownsWithVars :: [(Unknown, (Text, a))] -> SourceType -> SourceType
+replaceUnknownsWithVars binders ty
+ | null binders = ty
+ | otherwise = go ty
+ where
+ go :: SourceType -> SourceType
+ go = everywhereOnTypes $ \case
+ TUnknown ann unk | Just (name, _) <- lookup unk binders -> TypeVar ann name
+ other -> other
+
+unknownVarNames :: [Text] -> [(Unknown, SourceType)] -> [(Unknown, (Text, SourceType))]
+unknownVarNames used unks =
+ zipWith (\(a, b) n -> (a, (n, b))) unks $ allVars \\ used
+ where
+ allVars :: [Text]
+ allVars
+ | [_] <- unks = "k" : vars
+ | otherwise = vars
+
+ vars :: [Text]
+ vars = fmap (("k" <>) . T.pack . show) ([1..] :: [Int])
+
+apply :: (MonadState CheckState m) => SourceType -> m SourceType
+apply ty = flip substituteType ty <$> gets checkSubstitution
+
+substituteType :: Substitution -> SourceType -> SourceType
+substituteType sub = everywhereOnTypes $ \case
+ TUnknown ann u ->
+ case M.lookup u (substType sub) of
+ Nothing -> TUnknown ann u
+ Just (TUnknown ann' u1) | u1 == u -> TUnknown ann' u1
+ Just t -> substituteType sub t
+ other ->
+ other
+
+freshUnknown :: (MonadState CheckState m) => m Unknown
+freshUnknown = do
+ k <- gets checkNextType
+ modify $ \st -> st { checkNextType = k + 1 }
+ pure k
+
+freshKind :: (MonadState CheckState m) => SourceSpan -> m SourceType
+freshKind ss = freshKindWithKind ss E.kindType
+
+freshKindWithKind :: (MonadState CheckState m) => SourceSpan -> SourceType -> m SourceType
+freshKindWithKind ss kind = do
+ u <- freshUnknown
+ addUnsolved Nothing u kind
+ pure $ TUnknown (ss, []) u
+
+addUnsolved :: (MonadState CheckState m) => Maybe UnkLevel -> Unknown -> SourceType -> m ()
+addUnsolved lvl unk kind = modify $ \st -> do
+ let
+ newLvl = UnkLevel $ case lvl of
+ Nothing -> pure unk
+ Just (UnkLevel lvl') -> lvl' <> pure unk
+ subs = checkSubstitution st
+ uns = M.insert unk (newLvl, kind) $ substUnsolved subs
+ st { checkSubstitution = subs { substUnsolved = uns } }
+
+solve :: (MonadState CheckState m) => Unknown -> SourceType -> m ()
+solve unk solution = modify $ \st -> do
+ let
+ subs = checkSubstitution st
+ tys = M.insert unk solution $ substType subs
+ st { checkSubstitution = subs { substType = tys } }
+
+lookupUnsolved
+ :: (MonadState CheckState m, MonadError MultipleErrors m, HasCallStack)
+ => Unknown
+ -> m (UnkLevel, SourceType)
+lookupUnsolved u = do
+ uns <- gets (substUnsolved . checkSubstitution)
+ case M.lookup u uns of
+ Nothing -> internalCompilerError $ "Unsolved unification variable ?" <> T.pack (show u) <> " is not bound"
+ Just res -> return res
+
+unknownsWithKinds
+ :: forall m. (MonadState CheckState m, MonadError MultipleErrors m, HasCallStack)
+ => [Unknown]
+ -> m [(Unknown, SourceType)]
+unknownsWithKinds = fmap (fmap snd . nubBy ((==) `on` fst) . sortOn fst . join) . traverse go
+ where
+ go u = do
+ (lvl, ty) <- traverse apply =<< lookupUnsolved u
+ rest <- fmap join . traverse go . IS.toList . unknowns $ ty
+ pure $ (lvl, (u, ty)) : rest
+
+inferKind
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> m (SourceType, SourceType)
+inferKind = \tyToInfer ->
+ withErrorMessageHint (ErrorInferringKind tyToInfer)
+ . rethrowWithPosition (fst $ getAnnForType tyToInfer)
+ $ go tyToInfer
+ where
+ go = \case
+ ty@(TypeConstructor ann v) -> do
+ env <- getEnv
+ case M.lookup v (E.types env) of
+ Nothing ->
+ throwError . errorMessage' (fst ann) . UnknownName . fmap TyName $ v
+ Just (kind, E.LocalTypeVariable) -> do
+ kind' <- apply kind
+ pure (ty, kind' $> ann)
+ Just (kind, _) -> do
+ pure (ty, kind $> ann)
+ ConstrainedType ann' con@(Constraint ann v _ _ _) ty -> do
+ env <- getEnv
+ con' <- case M.lookup (coerceProperName <$> v) (E.types env) of
+ Nothing ->
+ throwError . errorMessage' (fst ann) . UnknownName . fmap TyClassName $ v
+ Just _ ->
+ checkConstraint con
+ ty' <- checkIsSaturatedType ty
+ con'' <- applyConstraint con'
+ pure (ConstrainedType ann' con'' ty', E.kindType $> ann')
+ ty@(TypeLevelString ann _) ->
+ pure (ty, E.kindSymbol $> ann)
+ ty@(TypeLevelInt ann _) ->
+ pure (ty, E.tyInt $> ann)
+ ty@(TypeVar ann v) -> do
+ moduleName <- unsafeCheckCurrentModule
+ kind <- apply =<< lookupTypeVariable moduleName (Qualified ByNullSourcePos $ ProperName v)
+ pure (ty, kind $> ann)
+ ty@(Skolem ann _ mbK _ _) -> do
+ kind <- apply $ fromMaybe (internalError "Skolem has no kind") mbK
+ pure (ty, kind $> ann)
+ ty@(TUnknown ann u) -> do
+ kind <- apply . snd =<< lookupUnsolved u
+ pure (ty, kind $> ann)
+ ty@(TypeWildcard ann _) -> do
+ k <- freshKind (fst ann)
+ pure (ty, k $> ann)
+ ty@(REmpty ann) -> do
+ pure (ty, E.kindOfREmpty $> ann)
+ ty@(RCons ann _ _ _) | (rowList, rowTail) <- rowToList ty -> do
+ kr <- freshKind (fst ann)
+ rowList' <- for rowList $ \(RowListItem a lbl t) ->
+ RowListItem a lbl <$> checkKind t kr
+ rowTail' <- checkKind rowTail $ E.kindRow kr
+ kr' <- apply kr
+ pure (rowFromList (rowList', rowTail'), E.kindRow kr' $> ann)
+ TypeApp ann t1 t2 -> do
+ (t1', k1) <- go t1
+ inferAppKind ann (t1', k1) t2
+ KindApp ann t1 t2 -> do
+ (t1', kind) <- bitraverse pure apply =<< go t1
+ case kind of
+ ForAll _ _ arg (Just argKind) resKind _ -> do
+ t2' <- checkKind t2 argKind
+ pure (KindApp ann t1' t2', replaceTypeVars arg t2' resKind)
+ _ ->
+ internalError "inferKind: unkinded forall binder"
+ KindedType _ t1 t2 -> do
+ t2' <- replaceAllTypeSynonyms . fst =<< go t2
+ t1' <- checkKind t1 t2'
+ t2'' <- apply t2'
+ pure (t1', t2'')
+ ForAll ann vis arg mbKind ty sc -> do
+ moduleName <- unsafeCheckCurrentModule
+ kind <- case mbKind of
+ Just k -> replaceAllTypeSynonyms =<< checkIsSaturatedType k
+ Nothing -> freshKind (fst ann)
+ (ty', unks) <- bindLocalTypeVariables moduleName [(ProperName arg, kind)] $ do
+ ty' <- apply =<< checkIsSaturatedType ty
+ unks <- unknownsWithKinds . IS.toList $ unknowns ty'
+ pure (ty', unks)
+ for_ unks . uncurry $ addUnsolved Nothing
+ pure (ForAll ann vis arg (Just kind) ty' sc, E.kindType $> ann)
+ ParensInType _ ty ->
+ go ty
+ ty ->
+ internalError $ "inferKind: Unimplemented case \n" <> prettyPrintType 100 ty
+
+inferAppKind
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceAnn
+ -> (SourceType, SourceType)
+ -> SourceType
+ -> m (SourceType, SourceType)
+inferAppKind ann (fn, fnKind) arg = case fnKind of
+ TypeApp _ (TypeApp _ arrKind argKind) resKind | eqType arrKind E.tyFunction -> do
+ expandSynonyms <- requiresSynonymsToExpand fn
+ arg' <- checkKind' expandSynonyms arg argKind
+ (TypeApp ann fn arg',) <$> apply resKind
+ TUnknown _ u -> do
+ (lvl, _) <- lookupUnsolved u
+ u1 <- freshUnknown
+ u2 <- freshUnknown
+ addUnsolved (Just lvl) u1 E.kindType
+ addUnsolved (Just lvl) u2 E.kindType
+ solve u $ (TUnknown ann u1 E.-:> TUnknown ann u2) $> ann
+ arg' <- checkKind arg $ TUnknown ann u1
+ pure (TypeApp ann fn arg', TUnknown ann u2)
+ ForAll _ _ a (Just k) ty _ -> do
+ u <- freshUnknown
+ addUnsolved Nothing u k
+ inferAppKind ann (KindApp ann fn (TUnknown ann u), replaceTypeVars a (TUnknown ann u) ty) arg
+ _ ->
+ cannotApplyTypeToType fn arg
+ where
+ requiresSynonymsToExpand = \case
+ TypeConstructor _ v -> M.notMember v . E.typeSynonyms <$> getEnv
+ TypeApp _ l _ -> requiresSynonymsToExpand l
+ KindApp _ l _ -> requiresSynonymsToExpand l
+ _ -> pure True
+
+cannotApplyTypeToType
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> SourceType
+ -> m a
+cannotApplyTypeToType fn arg = do
+ argKind <- snd <$> inferKind arg
+ _ <- checkKind fn . srcTypeApp (srcTypeApp E.tyFunction argKind) =<< freshKind nullSourceSpan
+ internalCompilerError . T.pack $ "Cannot apply type to type: " <> debugType (srcTypeApp fn arg)
+
+cannotApplyKindToType
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> SourceType
+ -> m a
+cannotApplyKindToType poly arg = do
+ let ann = getAnnForType arg
+ argKind <- snd <$> inferKind arg
+ _ <- checkKind poly . mkForAll [(ann, ("k", Just argKind))] =<< freshKind nullSourceSpan
+ internalCompilerError . T.pack $ "Cannot apply kind to type: " <> debugType (srcKindApp poly arg)
+
+checkKind
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> SourceType
+ -> m SourceType
+checkKind = checkKind' False
+
+-- | `checkIsSaturatedType t` is identical to `checkKind t E.kindType` except
+-- that the former checks that the type synonyms in `t` expand completely. This
+-- is the appropriate function to use when expanding the types of type
+-- parameter kinds, arguments to data constructors, etc., in order for the
+-- PartiallyAppliedSynonym error to take precedence over the KindsDoNotUnify
+-- error.
+--
+checkIsSaturatedType
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> m SourceType
+checkIsSaturatedType ty = checkKind' True ty E.kindType
+
+checkKind'
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => Bool
+ -> SourceType
+ -> SourceType
+ -> m SourceType
+checkKind' requireSynonymsToExpand ty kind2 = do
+ withErrorMessageHint (ErrorCheckingKind ty kind2)
+ . rethrowWithPosition (fst $ getAnnForType ty) $ do
+ (ty', kind1) <- inferKind ty
+ kind1' <- apply kind1
+ kind2' <- apply kind2
+ when requireSynonymsToExpand $ void $ replaceAllTypeSynonyms ty'
+ instantiateKind (ty', kind1') kind2'
+
+instantiateKind
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => (SourceType, SourceType)
+ -> SourceType
+ -> m SourceType
+instantiateKind (ty, kind1) kind2 = case kind1 of
+ ForAll _ _ a (Just k) t _ | shouldInstantiate kind2 -> do
+ let ann = getAnnForType ty
+ u <- freshKindWithKind (fst ann) k
+ instantiateKind (KindApp ann ty u, replaceTypeVars a u t) kind2
+ _ -> do
+ subsumesKind kind1 kind2
+ pure ty
where
- go (KUnknown ann u) =
- case M.lookup u (substKind sub) of
- Nothing -> KUnknown ann u
- Just (KUnknown ann' u1) | u1 == u -> KUnknown ann' u1
- Just t -> substituteKind sub t
- go other = other
-
--- | Make sure that an unknown does not occur in a kind
-occursCheck
- :: (MonadError MultipleErrors m)
- => Int
- -> SourceKind
+ shouldInstantiate = not . \case
+ ForAll _ _ _ _ _ _ -> True
+ _ -> False
+
+subsumesKind
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> SourceType
-> m ()
-occursCheck _ KUnknown{} = return ()
-occursCheck u k = void $ everywhereOnKindsM go k
+subsumesKind = go
where
- go (KUnknown _ u') | u == u' = throwError . errorMessage . InfiniteKind $ k
- go other = return other
+ go = curry $ \case
+ (TypeApp _ (TypeApp _ arr1 a1) a2, TypeApp _ (TypeApp _ arr2 b1) b2)
+ | eqType arr1 E.tyFunction
+ , eqType arr2 E.tyFunction -> do
+ go b1 a1
+ join $ go <$> apply a2 <*> apply b2
+ (a, ForAll ann _ var mbKind b mbScope) -> do
+ scope <- maybe newSkolemScope pure mbScope
+ skolc <- newSkolemConstant
+ go a $ skolemize ann var mbKind skolc scope b
+ (ForAll ann _ var (Just kind) a _, b) -> do
+ a' <- freshKindWithKind (fst ann) kind
+ go (replaceTypeVars var a' a) b
+ (TUnknown ann u, b@(TypeApp _ (TypeApp _ arr _) _))
+ | eqType arr E.tyFunction
+ , IS.notMember u (unknowns b) ->
+ join $ go <$> solveUnknownAsFunction ann u <*> pure b
+ (a@(TypeApp _ (TypeApp _ arr _) _), TUnknown ann u)
+ | eqType arr E.tyFunction
+ , IS.notMember u (unknowns a) ->
+ join $ go <$> pure a <*> solveUnknownAsFunction ann u
+ (a, b) ->
+ unifyKinds a b
--- | Unify two kinds
unifyKinds
- :: (MonadError MultipleErrors m, MonadState CheckState m)
- => SourceKind
- -> SourceKind
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> SourceType
+ -> m ()
+unifyKinds = unifyKindsWithFailure $ \w1 w2 ->
+ throwError
+ . errorMessage''' (fst . getAnnForType <$> [w1, w2])
+ $ KindsDoNotUnify w1 w2
+
+-- | Does not attach positions to the error node, instead relies on the
+-- | local position context. This is useful when invoking kind unification
+-- | outside of kind checker internals.
+unifyKinds'
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> SourceType
+ -> m ()
+unifyKinds' = unifyKindsWithFailure $ \w1 w2 ->
+ throwError
+ . errorMessage
+ $ KindsDoNotUnify w1 w2
+
+-- | Check the kind of a type, failing if it is not of kind *.
+checkTypeKind
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> SourceType
+ -> m ()
+checkTypeKind ty kind =
+ unifyKindsWithFailure (\_ _ -> throwError . errorMessage $ ExpectedType ty kind) kind E.kindType
+
+unifyKindsWithFailure
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => (SourceType -> SourceType -> m ())
+ -> SourceType
+ -> SourceType
-> m ()
-unifyKinds k1 k2 = do
- sub <- gets checkSubstitution
- go (substituteKind sub k1) (substituteKind sub k2)
+unifyKindsWithFailure onFailure = go
where
- go (KUnknown _ u1) (KUnknown _ u2) | u1 == u2 = return ()
- go (KUnknown _ u) k = solveKind u k
- go k (KUnknown _ u) = solveKind u k
- go (NamedKind _ k1') (NamedKind _ k2') | k1' == k2' = return ()
- go (Row _ k1') (Row _ k2') = unifyKinds k1' k2'
- go (FunKind _ k1' k2') (FunKind _ k3 k4) = do
- unifyKinds k1' k3
- unifyKinds k2' k4
- go k1' k2' =
- throwError
- . errorMessage''' (fst . getAnnForKind <$> [k1', k2'])
- $ KindsDoNotUnify k1' k2'
+ goWithLabel l t1 t2 = withErrorMessageHint (ErrorInRowLabel l) $ go t1 t2
+ go = curry $ \case
+ (TypeApp _ p1 p2, TypeApp _ p3 p4) -> do
+ go p1 p3
+ join $ go <$> apply p2 <*> apply p4
+ (KindApp _ p1 p2, KindApp _ p3 p4) -> do
+ go p1 p3
+ join $ go <$> apply p2 <*> apply p4
+ (r1@(RCons _ _ _ _), r2) ->
+ unifyRows r1 r2
+ (r1, r2@(RCons _ _ _ _)) ->
+ unifyRows r1 r2
+ (r1@(REmpty _), r2) ->
+ unifyRows r1 r2
+ (r1, r2@(REmpty _)) ->
+ unifyRows r1 r2
+ (w1, w2) | eqType w1 w2 ->
+ pure ()
+ (TUnknown _ a', p1) ->
+ solveUnknown a' p1
+ (p1, TUnknown _ a') ->
+ solveUnknown a' p1
+ (w1, w2) ->
+ onFailure w1 w2
+
+ unifyRows r1 r2 = do
+ let (matches, rest) = alignRowsWith goWithLabel r1 r2
+ sequence_ matches
+ unifyTails rest
+
+ unifyTails = \case
+ (([], TUnknown _ a'), (rs, p1)) ->
+ solveUnknown a' $ rowFromList (rs, p1)
+ ((rs, p1), ([], TUnknown _ a')) ->
+ solveUnknown a' $ rowFromList (rs, p1)
+ (([], w1), ([], w2)) | eqType w1 w2 ->
+ pure ()
+ ((rs1, TUnknown _ u1), (rs2, TUnknown _ u2)) | u1 /= u2 -> do
+ rest <- freshKind nullSourceSpan
+ solveUnknown u1 $ rowFromList (rs2, rest)
+ solveUnknown u2 $ rowFromList (rs1, rest)
+ (w1, w2) ->
+ onFailure (rowFromList w1) (rowFromList w2)
+
+solveUnknown
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => Unknown
+ -> SourceType
+ -> m ()
+solveUnknown a' p1 = do
+ p2 <- promoteKind a' p1
+ w1 <- snd <$> lookupUnsolved a'
+ join $ unifyKinds <$> apply w1 <*> elaborateKind p2
+ solve a' p2
+
+solveUnknownAsFunction
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceAnn
+ -> Unknown
+ -> m SourceType
+solveUnknownAsFunction ann u = do
+ lvl <- fst <$> lookupUnsolved u
+ u1 <- freshUnknown
+ u2 <- freshUnknown
+ addUnsolved (Just lvl) u1 E.kindType
+ addUnsolved (Just lvl) u2 E.kindType
+ let uarr = (TUnknown ann u1 E.-:> TUnknown ann u2) $> ann
+ solve u uarr
+ pure uarr
+
+promoteKind
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => Unknown
+ -> SourceType
+ -> m SourceType
+promoteKind u2 ty = do
+ lvl2 <- fst <$> lookupUnsolved u2
+ flip everywhereOnTypesM ty $ \case
+ ty'@(TUnknown ann u1) -> do
+ when (u1 == u2) . throwError . errorMessage . InfiniteKind $ ty
+ (lvl1, k) <- lookupUnsolved u1
+ if lvl1 < lvl2 then
+ pure ty'
+ else do
+ k' <- promoteKind u2 =<< apply k
+ u1' <- freshUnknown
+ addUnsolved (Just lvl2) u1' k'
+ solve u1 $ TUnknown ann u1'
+ pure $ TUnknown ann u1'
+ ty' ->
+ pure ty'
+
+elaborateKind
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> m SourceType
+elaborateKind = \case
+ TypeLevelString ann _ ->
+ pure $ E.kindSymbol $> ann
+ TypeLevelInt ann _ ->
+ pure $ E.tyInt $> ann
+ TypeConstructor ann v -> do
+ env <- getEnv
+ case M.lookup v (E.types env) of
+ Nothing ->
+ throwError . errorMessage' (fst ann) . UnknownName . fmap TyName $ v
+ Just (kind, _) ->
+ ($> ann) <$> apply kind
+ TypeVar ann a -> do
+ moduleName <- unsafeCheckCurrentModule
+ kind <- apply =<< lookupTypeVariable moduleName (Qualified ByNullSourcePos $ ProperName a)
+ pure (kind $> ann)
+ (Skolem ann _ mbK _ _) -> do
+ kind <- apply $ fromMaybe (internalError "Skolem has no kind") mbK
+ pure $ kind $> ann
+ TUnknown ann a' -> do
+ kind <- snd <$> lookupUnsolved a'
+ ($> ann) <$> apply kind
+ REmpty ann -> do
+ pure $ E.kindOfREmpty $> ann
+ RCons ann _ t1 _ -> do
+ k1 <- elaborateKind t1
+ pure $ E.kindRow k1 $> ann
+ ty@(TypeApp ann t1 t2) -> do
+ k1 <- elaborateKind t1
+ case k1 of
+ TypeApp _ (TypeApp _ k _) w2 | eqType k E.tyFunction -> do
+ pure $ w2 $> ann
+ -- Normally we wouldn't unify in `elaborateKind`, since an unknown should
+ -- always have a known kind. However, since type holes are fully inference
+ -- driven, they are unknowns with unknown kinds, which may require some
+ -- late unification here.
+ TUnknown a u -> do
+ _ <- solveUnknownAsFunction a u
+ elaborateKind ty
+ _ ->
+ cannotApplyTypeToType t1 t2
+ KindApp ann t1 t2 -> do
+ k1 <- elaborateKind t1
+ case k1 of
+ ForAll _ _ a _ n _ -> do
+ flip (replaceTypeVars a) n . ($> ann) <$> apply t2
+ _ ->
+ cannotApplyKindToType t1 t2
+ ForAll ann _ _ _ _ _ -> do
+ pure $ E.kindType $> ann
+ ConstrainedType ann _ _ ->
+ pure $ E.kindType $> ann
+ KindedType ann _ k ->
+ pure $ k $> ann
+ ty ->
+ throwError . errorMessage' (fst (getAnnForType ty)) $ UnsupportedTypeInKind ty
+
+checkEscapedSkolems :: MonadError MultipleErrors m => SourceType -> m ()
+checkEscapedSkolems ty =
+ traverse_ (throwError . toSkolemError)
+ . everythingWithContextOnTypes ty [] (<>) go
+ $ ty
+ where
+ go :: SourceType -> SourceType -> (SourceType, [(SourceSpan, Text, SourceType)])
+ go ty' = \case
+ Skolem ss name _ _ _ -> (ty', [(fst ss, name, ty')])
+ ty''@(KindApp _ _ _) -> (ty'', [])
+ _ -> (ty', [])
+
+ toSkolemError (ss, name, ty') =
+ errorMessage' (fst $ getAnnForType ty') $ EscapedSkolem name (Just ss) ty'
+
+kindOfWithUnknowns
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> m (([(Unknown, SourceType)], SourceType), SourceType)
+kindOfWithUnknowns ty = do
+ (ty', kind) <- kindOf ty
+ unks <- unknownsWithKinds . IS.toList $ unknowns ty'
+ pure ((unks, ty'), kind)
-- | Infer the kind of a single type
kindOf
- :: (MonadError MultipleErrors m, MonadState CheckState m)
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
=> SourceType
- -> m SourceKind
-kindOf ty = fst <$> kindOfWithScopedVars ty
+ -> m (SourceType, SourceType)
+kindOf = fmap (first snd) . kindOfWithScopedVars
-- | Infer the kind of a single type, returning the kinds of any scoped type variables
-kindOfWithScopedVars ::
- (MonadError MultipleErrors m, MonadState CheckState m) =>
- SourceType ->
- m (SourceKind, [(Text, SourceKind)])
-kindOfWithScopedVars ty =
- withErrorMessageHint (ErrorCheckingKind ty) $
- fmap tidyUp . withFreshSubstitution . captureSubstitution $ infer ty
- where
- tidyUp ((k, args), sub) = ( starIfUnknown (substituteKind sub k)
- , map (second (starIfUnknown . substituteKind sub)) args
- )
+kindOfWithScopedVars
+ :: (MonadError MultipleErrors m, MonadState CheckState m, HasCallStack)
+ => SourceType
+ -> m (([(Text, SourceType)], SourceType), SourceType)
+kindOfWithScopedVars ty = do
+ (ty', kind) <- bitraverse apply (replaceAllTypeSynonyms <=< apply) =<< inferKind ty
+ let binders = fst . fromJust $ completeBinderList ty'
+ pure ((snd <$> binders, ty'), kind)
--- | Infer the kind of a type constructor with a collection of arguments and a collection of associated data constructors
-kindsOf
- :: (MonadError MultipleErrors m, MonadState CheckState m)
- => Bool
- -> ModuleName
- -> ProperName 'TypeName
- -> [(Text, Maybe SourceKind)]
- -> [SourceType]
- -> m SourceKind
-kindsOf isData moduleName name args ts = fmap tidyUp . withFreshSubstitution . captureSubstitution $ do
- tyCon <- freshKind'
- kargs <- replicateM (length args) $ freshKind'
- rest <- zipWithM freshKindVar args kargs
- let dict = (name, tyCon) : rest
- bindLocalTypeVariables moduleName dict $
- solveTypes isData ts kargs tyCon
- where
- tidyUp (k, sub) = starIfUnknown $ substituteKind sub k
-
-freshKindVar
- :: (MonadError MultipleErrors m, MonadState CheckState m)
- => (Text, Maybe SourceKind)
- -> SourceKind
- -> m (ProperName 'TypeName, SourceKind)
-freshKindVar (arg, Nothing) kind = return (ProperName arg, kind)
-freshKindVar (arg, Just kind') kind = do
- unifyKinds kind kind'
- return (ProperName arg, kind')
-
--- | Simultaneously infer the kinds of several mutually recursive type constructors
-kindsOfAll
- :: (MonadError MultipleErrors m, MonadState CheckState m)
+type DataDeclarationArgs =
+ ( SourceAnn
+ , ProperName 'TypeName
+ , [(Text, Maybe SourceType)]
+ , [DataConstructorDeclaration]
+ )
+
+type DataDeclarationResult =
+ ( [(DataConstructorDeclaration, SourceType)]
+ -- The infered type signatures of data constructors
+ , SourceType
+ -- The inferred kind of the declaration
+ )
+
+kindOfData
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => ModuleName
+ -> DataDeclarationArgs
+ -> m DataDeclarationResult
+kindOfData moduleName dataDecl =
+ headDef (internalError "kindOfData: empty list") . (^. _2) <$> kindsOfAll moduleName [] [dataDecl] []
+
+inferDataDeclaration
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => ModuleName
+ -> DataDeclarationArgs
+ -> m [(DataConstructorDeclaration, SourceType)]
+inferDataDeclaration moduleName (ann, tyName, tyArgs, ctors) = do
+ tyKind <- apply =<< lookupTypeVariable moduleName (Qualified ByNullSourcePos tyName)
+ let (sigBinders, tyKind') = fromJust . completeBinderList $ tyKind
+ bindLocalTypeVariables moduleName (first ProperName . snd <$> sigBinders) $ do
+ tyArgs' <- for tyArgs . traverse . maybe (freshKind (fst ann)) $ replaceAllTypeSynonyms <=< apply <=< checkIsSaturatedType
+ subsumesKind (foldr ((E.-:>) . snd) E.kindType tyArgs') tyKind'
+ bindLocalTypeVariables moduleName (first ProperName <$> tyArgs') $ do
+ let tyCtorName = srcTypeConstructor $ mkQualified tyName moduleName
+ tyCtor = foldl (\ty -> srcKindApp ty . srcTypeVar . fst . snd) tyCtorName sigBinders
+ tyCtor' = foldl (\ty -> srcTypeApp ty . srcTypeVar . fst) tyCtor tyArgs'
+ ctorBinders = fmap (fmap (fmap Just)) $ sigBinders <> fmap (nullSourceAnn,) tyArgs'
+ visibility = second (const TypeVarVisible) <$> tyArgs
+ for ctors $
+ fmap (fmap (addVisibility visibility . mkForAll ctorBinders)) . inferDataConstructor tyCtor'
+
+inferDataConstructor
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => SourceType
+ -> DataConstructorDeclaration
+ -> m (DataConstructorDeclaration, SourceType)
+inferDataConstructor tyCtor DataConstructorDeclaration{..} = do
+ dataCtorFields' <- traverse (traverse checkIsSaturatedType) dataCtorFields
+ dataCtor <- flip (foldr ((E.-:>) . snd)) dataCtorFields' <$> checkKind tyCtor E.kindType
+ pure ( DataConstructorDeclaration { dataCtorFields = dataCtorFields', .. }, dataCtor )
+
+type TypeDeclarationArgs =
+ ( SourceAnn
+ , ProperName 'TypeName
+ , [(Text, Maybe SourceType)]
+ , SourceType
+ )
+
+type TypeDeclarationResult =
+ ( SourceType
+ -- The elaborated rhs of the declaration
+ , SourceType
+ -- The inferred kind of the declaration
+ )
+
+kindOfTypeSynonym
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => ModuleName
+ -> TypeDeclarationArgs
+ -> m TypeDeclarationResult
+kindOfTypeSynonym moduleName typeDecl =
+ headDef (internalError "kindOfTypeSynonym: empty list") . (^. _1) <$> kindsOfAll moduleName [typeDecl] [] []
+
+inferTypeSynonym
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
=> ModuleName
- -> [(SourceAnn, ProperName 'TypeName, [(Text, Maybe SourceKind)], SourceType)]
- -> [(SourceAnn, ProperName 'TypeName, [(Text, Maybe SourceKind)], [SourceType])]
- -> m ([SourceKind], [SourceKind])
-kindsOfAll moduleName syns tys = fmap tidyUp . withFreshSubstitution . captureSubstitution $ do
- synVars <- for syns $ \(sa, _, _, _) -> freshKind sa
- let dict = zipWith (\(_, name, _, _) var -> (name, var)) syns synVars
- bindLocalTypeVariables moduleName dict $ do
- tyCons <- for tys $ \(sa, _, _, _) -> freshKind sa
- let dict' = zipWith (\(_, name, _, _) tyCon -> (name, tyCon)) tys tyCons
- bindLocalTypeVariables moduleName dict' $ do
- data_ks <- zipWithM (\tyCon (_, _, args, ts) -> do
- kargs <- for args $ \(_, kind) -> maybe freshKind' (freshKind . getAnnForKind) kind
- argDict <- zipWithM freshKindVar args kargs
- bindLocalTypeVariables moduleName argDict $
- solveTypes True ts kargs tyCon) tyCons tys
- syn_ks <- zipWithM (\synVar (_, _, args, ty) -> do
- kargs <- for args $ \(_, kind) -> maybe freshKind' (freshKind . getAnnForKind) kind
- argDict <- zipWithM freshKindVar args kargs
- bindLocalTypeVariables moduleName argDict $
- solveTypes False [ty] kargs synVar) synVars syns
- return (syn_ks, data_ks)
+ -> TypeDeclarationArgs
+ -> m SourceType
+inferTypeSynonym moduleName (ann, tyName, tyArgs, tyBody) = do
+ tyKind <- apply =<< lookupTypeVariable moduleName (Qualified ByNullSourcePos tyName)
+ let (sigBinders, tyKind') = fromJust . completeBinderList $ tyKind
+ bindLocalTypeVariables moduleName (first ProperName . snd <$> sigBinders) $ do
+ kindRes <- freshKind (fst ann)
+ tyArgs' <- for tyArgs . traverse . maybe (freshKind (fst ann)) $ replaceAllTypeSynonyms <=< apply <=< checkIsSaturatedType
+ unifyKinds tyKind' $ foldr ((E.-:>) . snd) kindRes tyArgs'
+ bindLocalTypeVariables moduleName (first ProperName <$> tyArgs') $ do
+ tyBodyAndKind <- traverse apply =<< inferKind tyBody
+ instantiateKind tyBodyAndKind =<< apply kindRes
+
+-- | Checks that a particular generalization is valid and well-scoped.
+-- | Implicitly generalized kinds are always elaborated before explicitly
+-- | quantified type variables. It's possible that such a kind can be
+-- | inserted before other variables that it depends on, making it
+-- | ill-scoped. We require that users explicitly generalize this kind
+-- | in such a case.
+checkQuantification
+ :: forall m. (MonadError MultipleErrors m)
+ => SourceType
+ -> m ()
+checkQuantification =
+ collectErrors . go [] [] . fst . fromJust . completeBinderList
where
- tidyUp ((ks1, ks2), sub) = (map (starIfUnknown . substituteKind sub) ks1, map (starIfUnknown . substituteKind sub) ks2)
+ collectErrors vars =
+ unless (null vars)
+ . throwError
+ . foldMap (\(ann, arg) -> errorMessage' (fst ann) $ QuantificationCheckFailureInKind arg)
+ $ vars
--- | Solve the set of kind constraints associated with the data constructors for a type constructor
-solveTypes
- :: (MonadError MultipleErrors m, MonadState CheckState m)
- => Bool
- -> [SourceType]
- -> [SourceKind]
- -> SourceKind
- -> m SourceKind
-solveTypes isData ts kargs tyCon = do
- ks <- traverse (fmap fst . infer) ts
- when isData $ do
- unifyKinds tyCon (foldr srcFunKind kindType kargs)
- forM_ ks $ \k -> unifyKinds k (kindType $> getAnnForKind k)
- unless isData $
- unifyKinds tyCon (foldr srcFunKind (head ks) kargs)
- return tyCon
-
--- | Default all unknown kinds to the kindType kind of types
-starIfUnknown :: Kind a -> Kind a
-starIfUnknown (KUnknown ann _) = kindType $> ann
-starIfUnknown (Row ann k) = Row ann (starIfUnknown k)
-starIfUnknown (FunKind ann k1 k2) = FunKind ann (starIfUnknown k1) (starIfUnknown k2)
-starIfUnknown k = k
-
--- | Infer a kind for a type
-infer
- :: (MonadError MultipleErrors m, MonadState CheckState m)
+ go acc _ [] = reverse acc
+ go acc sco ((_, (arg, k)) : rest)
+ | not . all (flip elem sco) $ freeTypeVariables k = goDeps acc arg rest
+ | otherwise = go acc (arg : sco) rest
+
+ goDeps acc _ [] = acc
+ goDeps acc karg ((ann, (arg, k)) : rest)
+ | isDep && arg == karg = (ann, arg) : acc
+ | isDep = goDeps ((ann, arg) : acc) karg rest
+ | otherwise = goDeps acc karg rest
+ where
+ isDep =
+ elem karg $ freeTypeVariables k
+
+checkVisibleTypeQuantification
+ :: forall m. (MonadError MultipleErrors m)
=> SourceType
- -> m (SourceKind, [(Text, SourceKind)])
-infer ty =
- withErrorMessageHint (ErrorCheckingKind ty)
- . rethrowWithPosition (fst $ getAnnForType ty)
- $ infer' ty
-
-infer'
- :: forall m
- . (MonadError MultipleErrors m, MonadState CheckState m)
+ -> m ()
+checkVisibleTypeQuantification =
+ collectErrors . freeTypeVariables
+ where
+ collectErrors vars =
+ unless (null vars)
+ . throwError
+ . foldMap (errorMessage . VisibleQuantificationCheckFailureInType)
+ $ vars
+
+-- | Checks that there are no remaining unknowns in a type, and if so
+-- | throws an error. This is necessary for contexts where we can't
+-- | implicitly generalize unknowns, such as on the right-hand-side of
+-- | a type synonym, or in arguments to data constructors.
+checkTypeQuantification
+ :: forall m. (MonadError MultipleErrors m)
=> SourceType
- -> m (SourceKind, [(Text, SourceKind)])
-infer' (ForAll ann ident mbK ty _) = do
- k1 <- maybe (freshKind ann) pure mbK
- moduleName <- unsafeCheckCurrentModule
- (k2, args) <- bindLocalTypeVariables moduleName [(ProperName ident, k1)] $ infer ty
- unifyKinds k2 kindType
- return (kindType, (ident, k1) : args)
-infer' (KindedType _ ty k) = do
- (k', args) <- infer ty
- unifyKinds k k'
- return (k', args)
-infer' other = (, []) <$> go other
+ -> m ()
+checkTypeQuantification =
+ collectErrors . everythingWithContextOnTypes True [] (<>) unknownsInKinds
where
- go :: SourceType -> m SourceKind
- go (ForAll ann ident mbK ty _) = do
- k1 <- maybe (freshKind ann) pure mbK
- moduleName <- unsafeCheckCurrentModule
- k2 <- bindLocalTypeVariables moduleName [(ProperName ident, k1)] $ go ty
- unifyKinds k2 kindType
- return $ kindType $> ann
- go (KindedType _ ty k) = do
- k' <- go ty
- unifyKinds k k'
- return k'
- go (TypeWildcard ann _) = freshKind ann
- go (TUnknown ann _) = freshKind ann
- go (TypeLevelString ann _) = return $ kindSymbol $> ann
- go (TypeVar ann v) = do
- moduleName <- unsafeCheckCurrentModule
- ($> ann) <$> lookupTypeVariable moduleName (Qualified Nothing (ProperName v))
- go (Skolem ann v _ _) = do
- moduleName <- unsafeCheckCurrentModule
- ($> ann) <$> lookupTypeVariable moduleName (Qualified Nothing (ProperName v))
- go (TypeConstructor ann v) = do
- env <- getEnv
- case M.lookup v (types env) of
- Nothing -> throwError . errorMessage' (fst ann) . UnknownName $ fmap TyName v
- Just (kind, _) -> return $ kind $> ann
- go (TypeApp ann t1 t2) = do
- k0 <- freshKind ann
- k1 <- go t1
- k2 <- go t2
- unifyKinds k1 (FunKind ann k2 k0)
- return k0
- go (REmpty ann) = do
- k <- freshKind ann
- return $ Row ann k
- go (RCons ann _ ty row) = do
- k1 <- go ty
- k2 <- go row
- unifyKinds k2 (Row ann k1)
- return $ Row ann k1
- go (ConstrainedType ann2 (Constraint ann1 className tys _) ty) = do
- k1 <- go $ foldl (TypeApp ann2) (TypeConstructor ann1 (fmap coerceProperName className)) tys
- unifyKinds k1 kindType
- k2 <- go ty
- unifyKinds k2 kindType
- return $ kindType $> ann2
- go ty = internalError $ "Invalid argument to infer: " ++ show ty
+ collectErrors tysWithUnks =
+ unless (null tysWithUnks) . throwError . foldMap toMultipleErrors $ tysWithUnks
+
+ toMultipleErrors (ss, unks, ty) =
+ errorMessage' ss $ QuantificationCheckFailureInType (IS.toList unks) ty
+
+ unknownsInKinds False _ = (False, [])
+ unknownsInKinds _ ty = case ty of
+ ForAll sa _ _ _ _ _ | unks <- unknowns ty, not (IS.null unks) ->
+ (False, [(fst sa, unks, ty)])
+ KindApp sa _ _ | unks <- unknowns ty, not (IS.null unks) ->
+ (False, [(fst sa, unks, ty)])
+ ConstrainedType sa _ _ | unks <- unknowns ty, not (IS.null unks) ->
+ (False, [(fst sa, unks, ty)])
+ _ ->
+ (True, [])
+
+type ClassDeclarationArgs =
+ ( SourceAnn
+ , ProperName 'ClassName
+ , [(Text, Maybe SourceType)]
+ , [SourceConstraint]
+ , [Declaration]
+ )
+
+type ClassDeclarationResult =
+ ( [(Text, SourceType)]
+ -- The kind annotated class arguments
+ , [SourceConstraint]
+ -- The kind annotated superclass constraints
+ , [Declaration]
+ -- The kind annotated declarations
+ , SourceType
+ -- The inferred kind of the declaration
+ )
+
+kindOfClass
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => ModuleName
+ -> ClassDeclarationArgs
+ -> m ClassDeclarationResult
+kindOfClass moduleName clsDecl =
+ headDef (internalError "kindOfClass: empty list") . (^. _3) <$> kindsOfAll moduleName [] [] [clsDecl]
+
+inferClassDeclaration
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => ModuleName
+ -> ClassDeclarationArgs
+ -> m ([(Text, SourceType)], [SourceConstraint], [Declaration])
+inferClassDeclaration moduleName (ann, clsName, clsArgs, superClasses, decls) = do
+ clsKind <- apply =<< lookupTypeVariable moduleName (Qualified ByNullSourcePos $ coerceProperName clsName)
+ let (sigBinders, clsKind') = fromJust . completeBinderList $ clsKind
+ bindLocalTypeVariables moduleName (first ProperName . snd <$> sigBinders) $ do
+ clsArgs' <- for clsArgs . traverse . maybe (freshKind (fst ann)) $ replaceAllTypeSynonyms <=< apply <=< checkIsSaturatedType
+ unifyKinds clsKind' $ foldr ((E.-:>) . snd) E.kindConstraint clsArgs'
+ bindLocalTypeVariables moduleName (first ProperName <$> clsArgs') $ do
+ (clsArgs',,)
+ <$> for superClasses checkConstraint
+ <*> for decls checkClassMemberDeclaration
+
+checkClassMemberDeclaration
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => Declaration
+ -> m Declaration
+checkClassMemberDeclaration = \case
+ TypeDeclaration (TypeDeclarationData ann ident ty) ->
+ TypeDeclaration . TypeDeclarationData ann ident <$> checkKind ty E.kindType
+ _ -> internalError "Invalid class member declaration"
+
+applyClassMemberDeclaration
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => Declaration
+ -> m Declaration
+applyClassMemberDeclaration = \case
+ TypeDeclaration (TypeDeclarationData ann ident ty) ->
+ TypeDeclaration . TypeDeclarationData ann ident <$> apply ty
+ _ -> internalError "Invalid class member declaration"
+
+mapTypeDeclaration :: (SourceType -> SourceType) -> Declaration -> Declaration
+mapTypeDeclaration f = \case
+ TypeDeclaration (TypeDeclarationData ann ident ty) ->
+ TypeDeclaration . TypeDeclarationData ann ident $ f ty
+ other ->
+ other
+
+checkConstraint
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => SourceConstraint
+ -> m SourceConstraint
+checkConstraint (Constraint ann clsName kinds args dat) = do
+ let ty = foldl (TypeApp ann) (foldl (KindApp ann) (TypeConstructor ann (fmap coerceProperName clsName)) kinds) args
+ (_, kinds', args') <- unapplyTypes <$> checkKind ty E.kindConstraint
+ pure $ Constraint ann clsName kinds' args' dat
+
+applyConstraint
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => SourceConstraint
+ -> m SourceConstraint
+applyConstraint (Constraint ann clsName kinds args dat) = do
+ let ty = foldl (TypeApp ann) (foldl (KindApp ann) (TypeConstructor ann (fmap coerceProperName clsName)) kinds) args
+ (_, kinds', args') <- unapplyTypes <$> apply ty
+ pure $ Constraint ann clsName kinds' args' dat
+
+type InstanceDeclarationArgs =
+ ( SourceAnn
+ , [SourceConstraint]
+ , Qualified (ProperName 'ClassName)
+ , [SourceType]
+ )
+
+type InstanceDeclarationResult =
+ ( [SourceConstraint]
+ , [SourceType]
+ , [SourceType]
+ , [(Text, SourceType)]
+ )
+
+checkInstanceDeclaration
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => ModuleName
+ -> InstanceDeclarationArgs
+ -> m InstanceDeclarationResult
+checkInstanceDeclaration moduleName (ann, constraints, clsName, args) = do
+ let ty = foldl (TypeApp ann) (TypeConstructor ann (fmap coerceProperName clsName)) args
+ tyWithConstraints = foldr srcConstrainedType ty constraints
+ freeVars = freeTypeVariables tyWithConstraints
+ freeVarsDict <- for freeVars $ \v -> (ProperName v,) <$> freshKind (fst ann)
+ bindLocalTypeVariables moduleName freeVarsDict $ do
+ ty' <- checkKind ty E.kindConstraint
+ constraints' <- for constraints checkConstraint
+ allTy <- apply $ foldr srcConstrainedType ty' constraints'
+ allUnknowns <- unknownsWithKinds . IS.toList . foldMap unknowns . (allTy :) =<< traverse (apply . snd) freeVarsDict
+ let unknownVars = unknownVarNames (usedTypeVariables allTy) allUnknowns
+ let allWithVars = replaceUnknownsWithVars unknownVars allTy
+ let (allConstraints, (_, allKinds, allArgs)) = unapplyTypes <$> unapplyConstraints allWithVars
+ varKinds <- traverse (traverse (fmap (replaceUnknownsWithVars unknownVars) . apply)) $ (snd <$> unknownVars) <> (first runProperName <$> freeVarsDict)
+ pure (allConstraints, allKinds, allArgs, varKinds)
+
+checkKindDeclaration
+ :: forall m. (MonadSupply m, MonadError MultipleErrors m, MonadState CheckState m)
+ => ModuleName
+ -> SourceType
+ -> m SourceType
+checkKindDeclaration _ ty = do
+ (ty', kind) <- kindOf ty
+ checkTypeKind kind E.kindType
+ ty'' <- replaceAllTypeSynonyms ty'
+ unks <- unknownsWithKinds . IS.toList $ unknowns ty''
+ finalTy <- generalizeUnknowns unks <$> freshenForAlls ty' ty''
+ checkQuantification finalTy
+ checkValidKind finalTy
+ where
+ -- When expanding type synonyms and generalizing, we need to generate more
+ -- unique names so that they don't clash or shadow other names, or can
+ -- be referenced (easily).
+ freshVar arg = (arg <>) . T.pack . show <$> fresh
+ freshenForAlls = curry $ \case
+ (ForAll _ _ v1 _ ty1 _, ForAll a2 vis v2 k2 ty2 sc2) | v1 == v2 -> do
+ ty2' <- freshenForAlls ty1 ty2
+ pure $ ForAll a2 vis v2 k2 ty2' sc2
+ (_, ty2) -> go ty2 where
+ go = \case
+ ForAll a' vis v' k' ty' sc' -> do
+ v'' <- freshVar v'
+ ty'' <- go (replaceTypeVars v' (TypeVar a' v'') ty')
+ pure $ ForAll a' vis v'' k' ty'' sc'
+ other -> pure other
+
+ checkValidKind = everywhereOnTypesM $ \case
+ ty'@(ConstrainedType ann _ _) ->
+ throwError . errorMessage' (fst ann) $ UnsupportedTypeInKind ty'
+ other -> pure other
+
+existingSignatureOrFreshKind
+ :: forall m. MonadState CheckState m
+ => ModuleName
+ -> SourceSpan
+ -> ProperName 'TypeName
+ -> m SourceType
+existingSignatureOrFreshKind moduleName ss name = do
+ env <- getEnv
+ case M.lookup (Qualified (ByModuleName moduleName) name) (E.types env) of
+ Nothing -> freshKind ss
+ Just (kind, _) -> pure kind
+
+kindsOfAll
+ :: forall m. (MonadError MultipleErrors m, MonadState CheckState m)
+ => ModuleName
+ -> [TypeDeclarationArgs]
+ -> [DataDeclarationArgs]
+ -> [ClassDeclarationArgs]
+ -> m ([TypeDeclarationResult], [DataDeclarationResult], [ClassDeclarationResult])
+kindsOfAll moduleName syns dats clss = withFreshSubstitution $ do
+ synDict <- for syns $ \(sa, synName, _, _) -> (synName,) <$> existingSignatureOrFreshKind moduleName (fst sa) synName
+ datDict <- for dats $ \(sa, datName, _, _) -> (datName,) <$> existingSignatureOrFreshKind moduleName (fst sa) datName
+ clsDict <- for clss $ \(sa, clsName, _, _, _) -> fmap (coerceProperName clsName,) $ existingSignatureOrFreshKind moduleName (fst sa) $ coerceProperName clsName
+ let bindingGroup = synDict <> datDict <> clsDict
+ bindLocalTypeVariables moduleName bindingGroup $ do
+ synResults <- for syns (inferTypeSynonym moduleName)
+ datResults <- for dats (inferDataDeclaration moduleName)
+ clsResults <- for clss (inferClassDeclaration moduleName)
+ synResultsWithUnks <- for (zip synDict synResults) $ \((synName, synKind), synBody) -> do
+ synKind' <- apply synKind
+ synBody' <- apply synBody
+ pure (((synName, synKind'), synBody'), unknowns synKind')
+ datResultsWithUnks <- for (zip datDict datResults) $ \((datName, datKind), ctors) -> do
+ datKind' <- apply datKind
+ ctors' <- traverse (bitraverse (traverseDataCtorFields (traverse (traverse apply))) apply) ctors
+ pure (((datName, datKind'), ctors'), unknowns datKind')
+ clsResultsWithUnks <- for (zip clsDict clsResults) $ \((clsName, clsKind), (args, supers, decls)) -> do
+ clsKind' <- apply clsKind
+ args' <- traverse (traverse apply) args
+ supers' <- traverse applyConstraint supers
+ decls' <- traverse applyClassMemberDeclaration decls
+ pure (((clsName, clsKind'), (args', supers', decls')), unknowns clsKind')
+ let synUnks = fmap (\(((synName, _), _), unks) -> (synName, unks)) synResultsWithUnks
+ datUnks = fmap (\(((datName, _), _), unks) -> (datName, unks)) datResultsWithUnks
+ clsUnks = fmap (\(((clsName, _), _), unks) -> (clsName, unks)) clsResultsWithUnks
+ tysUnks = synUnks <> datUnks <> clsUnks
+ allUnks <- unknownsWithKinds . IS.toList $ foldMap snd tysUnks
+ let mkTySub (name, unks) = do
+ let tyCtorName = mkQualified name moduleName
+ tyUnks = filter (flip IS.member unks . fst) allUnks
+ tyCtor = foldl (\ty -> srcKindApp ty . TUnknown nullSourceAnn . fst) (srcTypeConstructor tyCtorName) tyUnks
+ (tyCtorName, (tyCtor, tyUnks))
+ tySubs = fmap mkTySub tysUnks
+ replaceTypeCtors = everywhereOnTypes $ \case
+ TypeConstructor _ name
+ | Just (tyCtor, _) <- lookup name tySubs -> tyCtor
+ other -> other
+ clsResultsWithKinds = flip fmap clsResultsWithUnks $ \(((clsName, clsKind), (args, supers, decls)), _) -> do
+ let tyUnks = snd . fromJust $ lookup (mkQualified clsName moduleName) tySubs
+ (usedTypeVariablesInDecls, _, _, _, _) = accumTypes usedTypeVariables
+ usedVars = usedTypeVariables clsKind
+ <> foldMap (usedTypeVariables . snd) args
+ <> foldMap (foldMap usedTypeVariables . (\c -> constraintKindArgs c <> constraintArgs c)) supers
+ <> foldMap usedTypeVariablesInDecls decls
+ unkBinders = unknownVarNames usedVars tyUnks
+ args' = fmap (replaceUnknownsWithVars unkBinders . replaceTypeCtors) <$> args
+ supers' = mapConstraintArgsAll (fmap (replaceUnknownsWithVars unkBinders . replaceTypeCtors)) <$> supers
+ decls' = mapTypeDeclaration (replaceUnknownsWithVars unkBinders . replaceTypeCtors) <$> decls
+ (args', supers', decls', generalizeUnknownsWithVars unkBinders clsKind)
+ datResultsWithKinds <- for datResultsWithUnks $ \(((datName, datKind), ctors), _) -> do
+ let tyUnks = snd . fromJust $ lookup (mkQualified datName moduleName) tySubs
+ replaceDataCtorField ty = replaceUnknownsWithVars (unknownVarNames (usedTypeVariables ty) tyUnks) $ replaceTypeCtors ty
+ ctors' = fmap (mapDataCtorFields (fmap (fmap replaceDataCtorField)) *** generalizeUnknowns tyUnks . replaceTypeCtors) ctors
+ traverse_ (traverse_ checkTypeQuantification) ctors'
+ pure (ctors', generalizeUnknowns tyUnks datKind)
+ synResultsWithKinds <- for synResultsWithUnks $ \(((synName, synKind), synBody), _) -> do
+ let tyUnks = snd . fromJust $ lookup (mkQualified synName moduleName) tySubs
+ unkBinders = unknownVarNames (usedTypeVariables synKind <> usedTypeVariables synBody) tyUnks
+ genBody = replaceUnknownsWithVars unkBinders $ replaceTypeCtors synBody
+ genSig = generalizeUnknownsWithVars unkBinders synKind
+ checkEscapedSkolems genBody
+ checkTypeQuantification genBody
+ checkVisibleTypeQuantification genSig
+ pure (genBody, genSig)
+ pure (synResultsWithKinds, datResultsWithKinds, clsResultsWithKinds)
diff --git a/src/Language/PureScript/TypeChecker/Monad.hs b/src/Language/PureScript/TypeChecker/Monad.hs
index 2933173d5b..b33127200d 100644
--- a/src/Language/PureScript/TypeChecker/Monad.hs
+++ b/src/Language/PureScript/TypeChecker/Monad.hs
@@ -1,40 +1,76 @@
-{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
+{-# LANGUAGE TypeOperators #-}
-- |
-- Monads for type checking and type inference and associated data types
--
module Language.PureScript.TypeChecker.Monad where
-import Prelude.Compat
+import Prelude
import Control.Arrow (second)
import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.State
+import Control.Monad.State (MonadState(..), StateT(..), gets, modify)
+import Control.Monad (forM_, guard, join, when, (<=<))
import Control.Monad.Writer.Class (MonadWriter(..), censor)
-import Data.Maybe
-import qualified Data.Map as M
-import Data.Text (Text)
-import qualified Data.List.NonEmpty as NEL
+import Data.Maybe (fromMaybe)
+import Data.Map qualified as M
+import Data.Set qualified as S
+import Data.Text (Text, isPrefixOf, unpack)
+import Data.List.NonEmpty qualified as NEL
import Language.PureScript.Crash (internalError)
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.TypeClassDictionaries
-import Language.PureScript.Types
-
--- | A substitution of unification variables for types or kinds
+import Language.PureScript.Environment (Environment(..), NameKind(..), NameVisibility(..), TypeClassData(..), TypeKind(..))
+import Language.PureScript.Errors (Context, ErrorMessageHint, ExportSource, Expr, ImportDeclarationType, MultipleErrors, SimpleErrorMessage(..), SourceAnn, SourceSpan(..), addHint, errorMessage, positionedError, rethrow, warnWithPosition)
+import Language.PureScript.Names (Ident(..), ModuleName, ProperName(..), ProperNameType(..), Qualified(..), QualifiedBy(..), coerceProperName, disqualify, runIdent, runModuleName, showQualified, toMaybeModuleName)
+import Language.PureScript.Pretty.Types (prettyPrintType)
+import Language.PureScript.Pretty.Values (prettyPrintValue)
+import Language.PureScript.TypeClassDictionaries (NamedDict, TypeClassDictionaryInScope(..))
+import Language.PureScript.Types (Constraint(..), SourceType, Type(..), srcKindedType, srcTypeVar)
+import Text.PrettyPrint.Boxes (render)
+
+newtype UnkLevel = UnkLevel (NEL.NonEmpty Unknown)
+ deriving (Eq, Show)
+
+-- This instance differs from the NEL instance in that longer but otherwise
+-- equal paths are LT rather than GT. An extended path puts it *before* its root.
+instance Ord UnkLevel where
+ compare (UnkLevel a) (UnkLevel b) =
+ go (NEL.toList a) (NEL.toList b)
+ where
+ go [] [] = EQ
+ go _ [] = LT
+ go [] _ = GT
+ go (x:xs) (y:ys) =
+ compare x y <> go xs ys
+
+-- | A substitution of unification variables for types.
data Substitution = Substitution
- { substType :: M.Map Int SourceType -- ^ Type substitution
- , substKind :: M.Map Int SourceKind -- ^ Kind substitution
+ { substType :: M.Map Int SourceType
+ -- ^ Type substitution
+ , substUnsolved :: M.Map Int (UnkLevel, SourceType)
+ -- ^ Unsolved unification variables with their level (scope ordering) and kind
+ , substNames :: M.Map Int Text
+ -- ^ The original names of unknowns
}
+insertUnkName :: (MonadState CheckState m) => Unknown -> Text -> m ()
+insertUnkName u t = do
+ modify (\s ->
+ s { checkSubstitution =
+ (checkSubstitution s) { substNames =
+ M.insert u t $ substNames $ checkSubstitution s
+ }
+ }
+ )
+
+lookupUnkName :: (MonadState CheckState m) => Unknown -> m (Maybe Text)
+lookupUnkName u = gets $ M.lookup u . substNames . checkSubstitution
+
-- | An empty substitution
emptySubstitution :: Substitution
-emptySubstitution = Substitution M.empty M.empty
+emptySubstitution = Substitution M.empty M.empty M.empty
-- | State required for type checking
data CheckState = CheckState
@@ -42,14 +78,24 @@ data CheckState = CheckState
-- ^ The current @Environment@
, checkNextType :: Int
-- ^ The next type unification variable
- , checkNextKind :: Int
- -- ^ The next kind unification variable
, checkNextSkolem :: Int
-- ^ The next skolem variable
, checkNextSkolemScope :: Int
-- ^ The next skolem scope constant
, checkCurrentModule :: Maybe ModuleName
-- ^ The current module
+ , checkCurrentModuleImports ::
+ [ ( SourceAnn
+ , ModuleName
+ , ImportDeclarationType
+ , Maybe ModuleName
+ , M.Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ExportSource)
+ )
+ ]
+ -- ^ The current module imports and their exported types.
+ -- Newtype constructors have to be in scope for some Coercible constraints to
+ -- be solvable, so we need to know which constructors are imported and whether
+ -- they are actually defined in or re-exported from the imported modules.
, checkSubstitution :: Substitution
-- ^ The current substitution
, checkHints :: [ErrorMessageHint]
@@ -57,11 +103,14 @@ data CheckState = CheckState
-- This goes into state, rather than using 'rethrow',
-- since this way, we can provide good error messages
-- during instance resolution.
+ , checkConstructorImportsForCoercible :: S.Set (ModuleName, Qualified (ProperName 'ConstructorName))
+ -- ^ Newtype constructors imports required to solve Coercible constraints.
+ -- We have to keep track of them so that we don't emit unused import warnings.
}
-- | Create an empty @CheckState@
emptyCheckState :: Environment -> CheckState
-emptyCheckState env = CheckState env 0 0 0 0 Nothing emptySubstitution []
+emptyCheckState env = CheckState env 0 0 0 Nothing [] emptySubstitution [] mempty
-- | Unification variables
type Unknown = Int
@@ -82,7 +131,7 @@ bindNames newNames action = do
-- | Temporarily bind a collection of names to types
bindTypes
:: MonadState CheckState m
- => M.Map (Qualified (ProperName 'TypeName)) (SourceKind, TypeKind)
+ => M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
-> m a
-> m a
bindTypes newNames action = do
@@ -96,15 +145,15 @@ bindTypes newNames action = do
withScopedTypeVars
:: (MonadState CheckState m, MonadWriter MultipleErrors m)
=> ModuleName
- -> [(Text, SourceKind)]
+ -> [(Text, SourceType)]
-> m a
-> m a
withScopedTypeVars mn ks ma = do
orig <- get
forM_ ks $ \(name, _) ->
- when (Qualified (Just mn) (ProperName name) `M.member` types (checkEnv orig)) $
+ when (Qualified (ByModuleName mn) (ProperName name) `M.member` types (checkEnv orig)) $
tell . errorMessage $ ShadowedTypeVar name
- bindTypes (M.fromList (map (\(name, k) -> (Qualified (Just mn) (ProperName name), (k, ScopedTypeVar))) ks)) ma
+ bindTypes (M.fromList (map (\(name, k) -> (Qualified (ByModuleName mn) (ProperName name), (k, ScopedTypeVar))) ks)) ma
withErrorMessageHint
:: (MonadState CheckState m, MonadError MultipleErrors m)
@@ -149,8 +198,8 @@ withTypeClassDictionaries entries action = do
let mentries =
M.fromListWith (M.unionWith (M.unionWith (<>)))
- [ (mn, M.singleton className (M.singleton (tcdValue entry) (pure entry)))
- | entry@TypeClassDictionaryInScope{ tcdValue = Qualified mn _, tcdClassName = className }
+ [ (qb, M.singleton className (M.singleton tcdValue (pure entry)))
+ | entry@TypeClassDictionaryInScope{ tcdValue = tcdValue@(Qualified qb _), tcdClassName = className }
<- entries
]
@@ -162,20 +211,20 @@ withTypeClassDictionaries entries action = do
-- | Get the currently available map of type class dictionaries
getTypeClassDictionaries
:: (MonadState CheckState m)
- => m (M.Map (Maybe ModuleName) (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict))))
-getTypeClassDictionaries = typeClassDictionaries . checkEnv <$> get
+ => m (M.Map QualifiedBy (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict))))
+getTypeClassDictionaries = gets $ typeClassDictionaries . checkEnv
-- | Lookup type class dictionaries in a module.
lookupTypeClassDictionaries
:: (MonadState CheckState m)
- => Maybe ModuleName
+ => QualifiedBy
-> m (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict)))
-lookupTypeClassDictionaries mn = fromMaybe M.empty . M.lookup mn . typeClassDictionaries . checkEnv <$> get
+lookupTypeClassDictionaries mn = gets $ fromMaybe M.empty . M.lookup mn . typeClassDictionaries . checkEnv
-- | Lookup type class dictionaries in a module.
lookupTypeClassDictionariesForClass
:: (MonadState CheckState m)
- => Maybe ModuleName
+ => QualifiedBy
-> Qualified (ProperName 'ClassName)
-> m (M.Map (Qualified Ident) (NEL.NonEmpty NamedDict))
lookupTypeClassDictionariesForClass mn cn = fromMaybe M.empty . M.lookup cn <$> lookupTypeClassDictionaries mn
@@ -183,21 +232,21 @@ lookupTypeClassDictionariesForClass mn cn = fromMaybe M.empty . M.lookup cn <$>
-- | Temporarily bind a collection of names to local variables
bindLocalVariables
:: (MonadState CheckState m)
- => [(Ident, SourceType, NameVisibility)]
+ => [(SourceSpan, Ident, SourceType, NameVisibility)]
-> m a
-> m a
bindLocalVariables bindings =
- bindNames (M.fromList $ flip map bindings $ \(name, ty, visibility) -> (Qualified Nothing name, (ty, Private, visibility)))
+ bindNames (M.fromList $ flip map bindings $ \(ss, name, ty, visibility) -> (Qualified (BySourcePos $ spanStart ss) name, (ty, Private, visibility)))
-- | Temporarily bind a collection of names to local type variables
bindLocalTypeVariables
:: (MonadState CheckState m)
=> ModuleName
- -> [(ProperName 'TypeName, SourceKind)]
+ -> [(ProperName 'TypeName, SourceType)]
-> m a
-> m a
bindLocalTypeVariables moduleName bindings =
- bindTypes (M.fromList $ flip map bindings $ \(pn, kind) -> (Qualified (Just moduleName) pn, (kind, LocalTypeVariable)))
+ bindTypes (M.fromList $ flip map bindings $ \(pn, kind) -> (Qualified (ByModuleName moduleName) pn, (kind, LocalTypeVariable)))
-- | Update the visibility of all names to Defined
makeBindingGroupVisible :: (MonadState CheckState m) => m ()
@@ -253,22 +302,26 @@ lookupTypeVariable
:: (e ~ MultipleErrors, MonadState CheckState m, MonadError e m)
=> ModuleName
-> Qualified (ProperName 'TypeName)
- -> m SourceKind
-lookupTypeVariable currentModule (Qualified moduleName name) = do
+ -> m SourceType
+lookupTypeVariable currentModule (Qualified qb name) = do
env <- getEnv
- case M.lookup (Qualified (Just $ fromMaybe currentModule moduleName) name) (types env) of
+ case M.lookup (Qualified qb' name) (types env) of
Nothing -> throwError . errorMessage $ UndefinedTypeVariable name
Just (k, _) -> return k
+ where
+ qb' = ByModuleName $ case qb of
+ ByModuleName m -> m
+ BySourcePos _ -> currentModule
-- | Get the current @Environment@
getEnv :: (MonadState CheckState m) => m Environment
-getEnv = checkEnv <$> get
+getEnv = gets checkEnv
-- | Get locally-bound names in context, to create an error message.
getLocalContext :: MonadState CheckState m => m Context
getLocalContext = do
env <- getEnv
- return [ (ident, ty') | (Qualified Nothing ident@Ident{}, (ty', _, Defined)) <- M.toList (names env) ]
+ return [ (ident, ty') | (Qualified (BySourcePos _) ident@Ident{}, (ty', _, Defined)) <- M.toList (names env) ]
-- | Update the @Environment@
putEnv :: (MonadState CheckState m) => Environment -> m ()
@@ -278,26 +331,15 @@ putEnv env = modify (\s -> s { checkEnv = env })
modifyEnv :: (MonadState CheckState m) => (Environment -> Environment) -> m ()
modifyEnv f = modify (\s -> s { checkEnv = f (checkEnv s) })
--- | Run a computation in the typechecking monad, starting with an empty @Environment@
-runCheck :: (Functor m) => StateT CheckState m a -> m (a, Environment)
-runCheck = runCheck' (emptyCheckState initEnvironment)
-
-- | Run a computation in the typechecking monad, failing with an error, or succeeding with a return value and the final @Environment@.
-runCheck' :: (Functor m) => CheckState -> StateT CheckState m a -> m (a, Environment)
-runCheck' st check = second checkEnv <$> runStateT check st
+runCheck :: (Functor m) => CheckState -> StateT CheckState m a -> m (a, Environment)
+runCheck st check = second checkEnv <$> runStateT check st
-- | Make an assertion, failing with an error message
guardWith :: (MonadError e m) => e -> Bool -> m ()
guardWith _ True = return ()
guardWith e False = throwError e
--- | Run a computation in the substitution monad, generating a return value and the final substitution.
-captureSubstitution
- :: MonadState CheckState m
- => m a
- -> m (a, Substitution)
-captureSubstitution = capturingSubstitution (,)
-
capturingSubstitution
:: MonadState CheckState m
=> (a -> Substitution -> b)
@@ -329,6 +371,116 @@ unsafeCheckCurrentModule
:: forall m
. (MonadError MultipleErrors m, MonadState CheckState m)
=> m ModuleName
-unsafeCheckCurrentModule = checkCurrentModule <$> get >>= \case
+unsafeCheckCurrentModule = gets checkCurrentModule >>= \case
Nothing -> internalError "No module name set in scope"
Just name -> pure name
+
+debugEnv :: Environment -> [String]
+debugEnv env = join
+ [ debugTypes env
+ , debugTypeSynonyms env
+ , debugTypeClasses env
+ , debugTypeClassDictionaries env
+ , debugDataConstructors env
+ , debugNames env
+ ]
+
+debugType :: Type a -> String
+debugType = init . prettyPrintType 100
+
+debugConstraint :: Constraint a -> String
+debugConstraint (Constraint ann clsName kinds args _) =
+ debugType $ foldl (TypeApp ann) (foldl (KindApp ann) (TypeConstructor ann (fmap coerceProperName clsName)) kinds) args
+
+debugTypes :: Environment -> [String]
+debugTypes = go <=< M.toList . types
+ where
+ go (qual, (srcTy, which)) = do
+ let
+ ppTy = prettyPrintType 100 srcTy
+ name = showQualified runProperName qual
+ decl = case which of
+ DataType _ _ _ -> "data"
+ TypeSynonym -> "type"
+ ExternData _ -> "extern"
+ LocalTypeVariable -> "local"
+ ScopedTypeVar -> "scoped"
+ guard (not ("Prim" `isPrefixOf` name))
+ pure $ decl <> " " <> unpack name <> " :: " <> init ppTy
+
+debugNames :: Environment -> [String]
+debugNames = fmap go . M.toList . names
+ where
+ go (qual, (srcTy, _, _)) = do
+ let
+ ppTy = prettyPrintType 100 srcTy
+ name = showQualified runIdent qual
+ unpack name <> " :: " <> init ppTy
+
+debugDataConstructors :: Environment -> [String]
+debugDataConstructors = fmap go . M.toList . dataConstructors
+ where
+ go (qual, (_, _, ty, _)) = do
+ let
+ ppTy = prettyPrintType 100 ty
+ name = showQualified runProperName qual
+ unpack name <> " :: " <> init ppTy
+
+debugTypeSynonyms :: Environment -> [String]
+debugTypeSynonyms = fmap go . M.toList . typeSynonyms
+ where
+ go (qual, (binders, subTy)) = do
+ let
+ vars = unwords $ flip fmap binders $ \case
+ (v, Just k) -> "(" <> unpack v <> " :: " <> init (prettyPrintType 100 k) <> ")"
+ (v, Nothing) -> unpack v
+ ppTy = prettyPrintType 100 subTy
+ name = showQualified runProperName qual
+ "type " <> unpack name <> " " <> vars <> " = " <> init ppTy
+
+debugTypeClassDictionaries :: Environment -> [String]
+debugTypeClassDictionaries = go . typeClassDictionaries
+ where
+ go tcds = do
+ (mbModuleName, classes) <- M.toList tcds
+ (className, instances) <- M.toList classes
+ (ident, dicts) <- M.toList instances
+ let
+ moduleName = maybe "" (\m -> "[" <> runModuleName m <> "] ") (toMaybeModuleName mbModuleName)
+ className' = showQualified runProperName className
+ ident' = showQualified runIdent ident
+ kds = unwords $ fmap ((\a -> "@(" <> a <> ")") . debugType) $ tcdInstanceKinds $ NEL.head dicts
+ tys = unwords $ fmap ((\a -> "(" <> a <> ")") . debugType) $ tcdInstanceTypes $ NEL.head dicts
+ pure $ "dict " <> unpack moduleName <> unpack className' <> " " <> unpack ident' <> " (" <> show (length dicts) <> ")" <> " " <> kds <> " " <> tys
+
+debugTypeClasses :: Environment -> [String]
+debugTypeClasses = fmap go . M.toList . typeClasses
+ where
+ go (className, tc) = do
+ let
+ className' = showQualified runProperName className
+ args = unwords $ (\(a, b) -> "(" <> debugType (maybe (srcTypeVar a) (srcKindedType (srcTypeVar a)) b) <> ")") <$> typeClassArguments tc
+ "class " <> unpack className' <> " " <> args
+
+debugValue :: Expr -> String
+debugValue = init . render . prettyPrintValue 100
+
+debugSubstitution :: Substitution -> [String]
+debugSubstitution (Substitution solved unsolved names) =
+ concat
+ [ fmap go1 (M.toList solved)
+ , fmap go2 (M.toList unsolved')
+ , fmap go3 (M.toList names)
+ ]
+ where
+ unsolved' =
+ M.filterWithKey (\k _ -> M.notMember k solved) unsolved
+
+ go1 (u, ty) =
+ "?" <> show u <> " = " <> debugType ty
+
+ go2 (u, (_, k)) =
+ "?" <> show u <> " :: " <> debugType k
+
+ go3 (u, t) =
+ unpack t <> show u
diff --git a/src/Language/PureScript/TypeChecker/Roles.hs b/src/Language/PureScript/TypeChecker/Roles.hs
new file mode 100644
index 0000000000..7b38a317b7
--- /dev/null
+++ b/src/Language/PureScript/TypeChecker/Roles.hs
@@ -0,0 +1,263 @@
+{-# LANGUAGE TypeApplications #-}
+
+-- |
+-- Role inference
+--
+module Language.PureScript.TypeChecker.Roles
+ ( lookupRoles
+ , checkRoles
+ , checkRoleDeclarationArity
+ , inferRoles
+ , inferDataBindingGroupRoles
+ ) where
+
+import Prelude
+
+import Control.Arrow ((&&&))
+import Control.Monad (unless, when, zipWithM_)
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.State (MonadState(..), runState, state)
+import Data.Coerce (coerce)
+import Data.Map qualified as M
+import Data.Maybe (fromMaybe)
+import Data.Set qualified as S
+import Data.Semigroup (Any(..))
+import Data.Text (Text)
+
+import Language.PureScript.Environment (Environment(..), TypeKind(..))
+import Language.PureScript.Errors (DataConstructorDeclaration(..), MultipleErrors, RoleDeclarationData(..), SimpleErrorMessage(..), errorMessage)
+import Language.PureScript.Names (ModuleName, ProperName, ProperNameType(..), Qualified(..), QualifiedBy(..))
+import Language.PureScript.Roles (Role(..))
+import Language.PureScript.Types (Constraint(..), SourceType, Type(..), freeTypeVariables, unapplyTypes)
+
+-- |
+-- A map of a type's formal parameter names to their roles. This type's
+-- @Semigroup@ and @Monoid@ instances preserve the least-permissive role
+-- ascribed to any given variable, as defined by the @Role@ type's @Ord@
+-- instance. That is, a variable that has been marked as @Nominal@ can not
+-- later be marked @Representational@, and so on.
+newtype RoleMap = RoleMap { getRoleMap :: M.Map Text Role }
+
+instance Semigroup RoleMap where
+ (<>) =
+ coerce @(M.Map Text Role -> _ -> _) @(RoleMap -> _ -> _) (M.unionWith min)
+
+instance Monoid RoleMap where
+ mempty =
+ RoleMap M.empty
+
+type RoleEnv = M.Map (Qualified (ProperName 'TypeName)) [Role]
+
+typeKindRoles :: TypeKind -> Maybe [Role]
+typeKindRoles = \case
+ DataType _ args _ ->
+ Just $ map (\(_, _, role) -> role) args
+ ExternData roles ->
+ Just roles
+ _ ->
+ Nothing
+
+getRoleEnv :: Environment -> RoleEnv
+getRoleEnv env =
+ M.mapMaybe (typeKindRoles . snd) (types env)
+
+updateRoleEnv
+ :: Qualified (ProperName 'TypeName)
+ -> [Role]
+ -> RoleEnv
+ -> (Any, RoleEnv)
+updateRoleEnv qualTyName roles' roleEnv =
+ let roles = fromMaybe (repeat Phantom) $ M.lookup qualTyName roleEnv
+ mostRestrictiveRoles = zipWith min roles roles'
+ didRolesChange = any (uncurry (<)) $ zip mostRestrictiveRoles roles
+ in (Any didRolesChange, M.insert qualTyName mostRestrictiveRoles roleEnv)
+
+-- |
+-- Lookup the roles for a type in the environment. If the type does not have
+-- roles (e.g. is a type synonym or a type variable), then this function
+-- returns an empty list.
+--
+lookupRoles
+ :: Environment
+ -> Qualified (ProperName 'TypeName)
+ -> [Role]
+lookupRoles env tyName =
+ fromMaybe [] $ M.lookup tyName (types env) >>= typeKindRoles . snd
+
+-- |
+-- Compares the inferred roles to the explicitly declared roles and ensures
+-- that the explicitly declared roles are not more permissive than the
+-- inferred ones.
+--
+checkRoles
+ :: forall m
+ . (MonadError MultipleErrors m)
+ => [(Text, Maybe SourceType, Role)]
+ -- ^ type parameters for the data type whose roles we are checking
+ -> [Role]
+ -- ^ roles declared for the data type
+ -> m ()
+checkRoles tyArgs declaredRoles = do
+ let k (var, _, inf) dec =
+ when (inf < dec) . throwError . errorMessage $ RoleMismatch var inf dec
+ zipWithM_ k tyArgs declaredRoles
+
+checkRoleDeclarationArity
+ :: forall m
+ . (MonadError MultipleErrors m)
+ => ProperName 'TypeName
+ -> [Role]
+ -> Int
+ -> m ()
+checkRoleDeclarationArity tyName roles expected = do
+ let actual = length roles
+ unless (expected == actual) $
+ throwError . errorMessage $
+ RoleDeclarationArityMismatch tyName expected actual
+
+-- |
+-- Infers roles for the given data type declaration.
+--
+inferRoles
+ :: Environment
+ -> ModuleName
+ -> ProperName 'TypeName
+ -- ^ The name of the data type whose roles we are checking
+ -> [(Text, Maybe SourceType)]
+ -- ^ type parameters for the data type whose roles we are checking
+ -> [DataConstructorDeclaration]
+ -- ^ constructors of the data type whose roles we are checking
+ -> [Role]
+inferRoles env moduleName tyName tyArgs ctors =
+ inferDataBindingGroupRoles env moduleName [] [(tyName, tyArgs, ctors)] tyName tyArgs
+
+inferDataBindingGroupRoles
+ :: Environment
+ -> ModuleName
+ -> [RoleDeclarationData]
+ -> [DataDeclaration]
+ -> ProperName 'TypeName
+ -> [(Text, Maybe SourceType)]
+ -> [Role]
+inferDataBindingGroupRoles env moduleName roleDeclarations group =
+ let declaredRoleEnv = M.fromList $ map (Qualified (ByModuleName moduleName) . rdeclIdent &&& rdeclRoles) roleDeclarations
+ inferredRoleEnv = getRoleEnv env
+ initialRoleEnv = declaredRoleEnv `M.union` inferredRoleEnv
+ inferredRoleEnv' = inferDataBindingGroupRoles' moduleName group initialRoleEnv
+ in \tyName tyArgs ->
+ let qualTyName = Qualified (ByModuleName moduleName) tyName
+ inferredRoles = M.lookup qualTyName inferredRoleEnv'
+ in fromMaybe (Phantom <$ tyArgs) inferredRoles
+
+type DataDeclaration =
+ ( ProperName 'TypeName
+ , [(Text, Maybe SourceType)]
+ , [DataConstructorDeclaration]
+ )
+
+inferDataBindingGroupRoles'
+ :: ModuleName
+ -> [DataDeclaration]
+ -> RoleEnv
+ -> RoleEnv
+inferDataBindingGroupRoles' moduleName group roleEnv =
+ let (Any didRolesChange, roleEnv') = flip runState roleEnv $
+ mconcat <$> traverse (state . inferDataDeclarationRoles moduleName) group
+ in if didRolesChange
+ then inferDataBindingGroupRoles' moduleName group roleEnv'
+ else roleEnv'
+
+-- |
+-- Infers roles for the given data type declaration, along with a flag to tell
+-- if more restrictive roles were added to the environment.
+--
+inferDataDeclarationRoles
+ :: ModuleName
+ -> DataDeclaration
+ -> RoleEnv
+ -> (Any, RoleEnv)
+inferDataDeclarationRoles moduleName (tyName, tyArgs, ctors) roleEnv =
+ let qualTyName = Qualified (ByModuleName moduleName) tyName
+ ctorRoles = getRoleMap . foldMap (walk mempty . snd) $ ctors >>= dataCtorFields
+ inferredRoles = map (\(arg, _) -> fromMaybe Phantom (M.lookup arg ctorRoles)) tyArgs
+ in updateRoleEnv qualTyName inferredRoles roleEnv
+ where
+ -- This function is named @walk@ to match the specification given in the
+ -- "Role inference" section of the paper "Safe Zero-cost Coercions for
+ -- Haskell".
+ walk :: S.Set Text -> SourceType -> RoleMap
+ walk btvs (TypeVar _ v)
+ -- A type variable standing alone (e.g. @a@ in @data D a b = D a@) is
+ -- representational, _unless_ it has been bound by a quantifier, in which
+ -- case it is not actually a parameter to the type (e.g. @z@ in
+ -- @data T z = T (forall z. z -> z)@).
+ | S.member v btvs =
+ mempty
+ | otherwise =
+ RoleMap $ M.singleton v Representational
+ walk btvs (ForAll _ _ tv _ t _) =
+ -- We can walk under universal quantifiers as long as we make note of the
+ -- variables that they bind. For instance, given a definition
+ -- @data T z = T (forall z. z -> z)@, we will make note that @z@ is bound
+ -- by a quantifier so that we do not mark @T@'s parameter as
+ -- representational later on. Similarly, given a definition like
+ -- @data D a = D (forall r. r -> a)@, we'll mark @r@ as bound so that it
+ -- doesn't appear as a spurious parameter to @D@ when we complete
+ -- inference.
+ walk (S.insert tv btvs) t
+ walk btvs (ConstrainedType _ Constraint{..} t) =
+ -- For constrained types, mark all free variables in the constraint
+ -- arguments as nominal and recurse on the type beneath the constraint.
+ walk btvs t <> foldMap (freeNominals btvs) constraintArgs
+ walk btvs (RCons _ _ thead ttail) = do
+ -- For row types, we just walk along them and collect the results.
+ walk btvs thead <> walk btvs ttail
+ walk btvs (KindedType _ t _k) =
+ -- For kind-annotated types, discard the annotation and recurse on the
+ -- type beneath.
+ walk btvs t
+ walk btvs t
+ | (t1, _, t2s) <- unapplyTypes t
+ , not $ null t2s =
+ case t1 of
+ -- If the type is an application of a type constructor to some
+ -- arguments, recursively infer the roles of the type constructor's
+ -- arguments. For each (role, argument) pair:
+ --
+ -- - If the role is nominal, mark all free variables in the argument
+ -- as nominal also, since they cannot be coerced if the
+ -- argument's nominality is to be preserved.
+ --
+ -- - If the role is representational, recurse on the argument, since
+ -- its use of our parameters is important.
+ --
+ -- - If the role is phantom, terminate, since the argument's use of
+ -- our parameters is unimportant.
+ TypeConstructor _ t1Name ->
+ let
+ t1Roles = fromMaybe (repeat Phantom) $ M.lookup t1Name roleEnv
+ k role ti = case role of
+ Nominal ->
+ freeNominals btvs ti
+ Representational ->
+ go ti
+ Phantom ->
+ mempty
+ in mconcat (zipWith k t1Roles t2s)
+ -- If the type is an application of any other type-level term, walk
+ -- that term to collect its roles and mark all free variables in
+ -- its argument as nominal.
+ _ -> do
+ go t1 <> foldMap (freeNominals btvs) t2s
+ | otherwise =
+ mempty
+ where
+ go = walk btvs
+
+-- Given a type, computes the list of free variables in that type
+-- (taking into account those bound in @walk@) and returns a @RoleMap@
+-- ascribing a nominal role to each of those variables.
+freeNominals :: S.Set Text -> SourceType -> RoleMap
+freeNominals btvs x =
+ let ftvs = filter (flip S.notMember btvs) (freeTypeVariables x)
+ in RoleMap (M.fromList $ map (, Nominal) ftvs)
diff --git a/src/Language/PureScript/TypeChecker/Skolems.hs b/src/Language/PureScript/TypeChecker/Skolems.hs
index 170ea7ebcd..aa49997fd6 100644
--- a/src/Language/PureScript/TypeChecker/Skolems.hs
+++ b/src/Language/PureScript/TypeChecker/Skolems.hs
@@ -8,7 +8,7 @@ module Language.PureScript.TypeChecker.Skolems
, skolemEscapeCheck
) where
-import Prelude.Compat
+import Prelude
import Control.Monad.Error.Class (MonadError(..))
import Control.Monad.State.Class (MonadState(..), gets, modify)
@@ -16,12 +16,12 @@ import Data.Foldable (traverse_)
import Data.Functor.Identity (Identity(), runIdentity)
import Data.Set (Set, fromList, notMember)
import Data.Text (Text)
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Errors
+import Language.PureScript.AST (Binder(..), ErrorMessageHint(..), Expr(..), SourceAnn, SourceSpan, everythingWithContextOnValues, everywhereWithContextOnValuesM, nonEmptySpan)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Errors (ErrorMessage(..), MultipleErrors, SimpleErrorMessage(..), positionedError, singleError)
import Language.PureScript.Traversals (defS)
-import Language.PureScript.TypeChecker.Monad
-import Language.PureScript.Types
+import Language.PureScript.TypeChecker.Monad (CheckState(..))
+import Language.PureScript.Types (SkolemScope(..), SourceType, Type(..), everythingOnTypes, everywhereOnTypesM, replaceTypeVars)
-- | Generate a new skolem constant
newSkolemConstant :: MonadState CheckState m => m Int
@@ -30,11 +30,11 @@ newSkolemConstant = do
modify $ \st -> st { checkNextSkolem = s + 1 }
return s
--- | Introduce skolem scope at every occurence of a ForAll
+-- | Introduce skolem scope at every occurrence of a ForAll
introduceSkolemScope :: MonadState CheckState m => Type a -> m (Type a)
introduceSkolemScope = everywhereOnTypesM go
where
- go (ForAll ann ident mbK ty Nothing) = ForAll ann ident mbK ty <$> (Just <$> newSkolemScope)
+ go (ForAll ann vis ident mbK ty Nothing) = ForAll ann vis ident mbK ty <$> (Just <$> newSkolemScope)
go other = return other
-- | Generate a new skolem scope
@@ -45,33 +45,35 @@ newSkolemScope = do
return $ SkolemScope s
-- | Skolemize a type variable by replacing its instances with fresh skolem constants
-skolemize :: a -> Text -> Int -> SkolemScope -> Type a -> Type a
-skolemize ann ident sko scope = replaceTypeVars ident (Skolem ann ident sko scope)
+skolemize :: a -> Text -> Maybe (Type a) -> Int -> SkolemScope -> Type a -> Type a
+skolemize ann ident mbK sko scope = replaceTypeVars ident (Skolem ann ident mbK sko scope)
-- | This function skolemizes type variables appearing in any type signatures or
-- 'DeferredDictionary' placeholders. These type variables are the only places
-- where scoped type variables can appear in expressions.
-skolemizeTypesInValue :: SourceAnn -> Text -> Int -> SkolemScope -> Expr -> Expr
-skolemizeTypesInValue ann ident sko scope =
+skolemizeTypesInValue :: SourceAnn -> Text -> Maybe SourceType -> Int -> SkolemScope -> Expr -> Expr
+skolemizeTypesInValue ann ident mbK sko scope =
runIdentity . onExpr'
where
onExpr' :: Expr -> Identity Expr
- (_, onExpr', _, _, _) = everywhereWithContextOnValuesM [] defS onExpr onBinder defS defS
+ (_, onExpr', _, _, _, _) = everywhereWithContextOnValuesM [] defS onExpr onBinder defS defS defS
onExpr :: [Text] -> Expr -> Identity ([Text], Expr)
onExpr sco (DeferredDictionary c ts)
- | ident `notElem` sco = return (sco, DeferredDictionary c (map (skolemize ann ident sko scope) ts))
+ | ident `notElem` sco = return (sco, DeferredDictionary c (map (skolemize ann ident mbK sko scope) ts))
onExpr sco (TypedValue check val ty)
- | ident `notElem` sco = return (sco ++ peelTypeVars ty, TypedValue check val (skolemize ann ident sko scope ty))
+ | ident `notElem` sco = return (sco ++ peelTypeVars ty, TypedValue check val (skolemize ann ident mbK sko scope ty))
+ onExpr sco (VisibleTypeApp val ty)
+ | ident `notElem` sco = return (sco ++ peelTypeVars ty, VisibleTypeApp val (skolemize ann ident mbK sko scope ty))
onExpr sco other = return (sco, other)
onBinder :: [Text] -> Binder -> Identity ([Text], Binder)
onBinder sco (TypedBinder ty b)
- | ident `notElem` sco = return (sco ++ peelTypeVars ty, TypedBinder (skolemize ann ident sko scope ty) b)
+ | ident `notElem` sco = return (sco ++ peelTypeVars ty, TypedBinder (skolemize ann ident mbK sko scope ty) b)
onBinder sco other = return (sco, other)
peelTypeVars :: SourceType -> [Text]
- peelTypeVars (ForAll _ i _ ty _) = i : peelTypeVars ty
+ peelTypeVars (ForAll _ _ i _ ty _) = i : peelTypeVars ty
peelTypeVars _ = []
-- | Ensure skolem variables do not escape their scope
@@ -116,14 +118,14 @@ skolemEscapeCheck expr@TypedValue{} =
-- Collect any scopes appearing in quantifiers at the top level
collectScopes :: SourceType -> [SkolemScope]
- collectScopes (ForAll _ _ _ t (Just sco)) = sco : collectScopes t
+ collectScopes (ForAll _ _ _ _ t (Just sco)) = sco : collectScopes t
collectScopes ForAll{} = internalError "skolemEscapeCheck: No skolem scope"
collectScopes _ = []
-- Collect any skolem variables appearing in a type
collectSkolems :: SourceType -> [(SourceAnn, Text, SkolemScope)]
collectSkolems = everythingOnTypes (++) collect where
- collect (Skolem ss name _ scope) = [(ss, name, scope)]
+ collect (Skolem ss name _ _ scope) = [(ss, name, scope)]
collect _ = []
go scos _ = (scos, [])
skolemEscapeCheck _ = internalError "skolemEscapeCheck: untyped value"
diff --git a/src/Language/PureScript/TypeChecker/Subsumption.hs b/src/Language/PureScript/TypeChecker/Subsumption.hs
index d85d905144..26da5e980f 100644
--- a/src/Language/PureScript/TypeChecker/Subsumption.hs
+++ b/src/Language/PureScript/TypeChecker/Subsumption.hs
@@ -1,12 +1,11 @@
{-# LANGUAGE GADTs #-}
-{-# LANGUAGE TypeFamilies #-}
-- | Subsumption checking
module Language.PureScript.TypeChecker.Subsumption
( subsumes
) where
-import Prelude.Compat
+import Prelude
import Control.Monad (when)
import Control.Monad.Error.Class (MonadError(..))
@@ -17,14 +16,14 @@ import Data.List (uncons)
import Data.List.Ordered (minusBy')
import Data.Ord (comparing)
-import Language.PureScript.AST
-import Language.PureScript.Crash
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.TypeChecker.Monad
-import Language.PureScript.TypeChecker.Skolems
-import Language.PureScript.TypeChecker.Unify
-import Language.PureScript.Types
+import Language.PureScript.AST (ErrorMessageHint(..), Expr(..), pattern NullSourceAnn)
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment (tyFunction, tyRecord)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), errorMessage, internalCompilerError)
+import Language.PureScript.TypeChecker.Monad (CheckState, getHints, getTypeClassDictionaries, withErrorMessageHint)
+import Language.PureScript.TypeChecker.Skolems (newSkolemConstant, skolemize)
+import Language.PureScript.TypeChecker.Unify (alignRowsWith, freshTypeWithKind, unifyTypes)
+import Language.PureScript.Types (RowListItem(..), SourceType, Type(..), eqType, isREmpty, replaceTypeVars, rowFromList)
-- | Subsumption can operate in two modes:
--
@@ -75,14 +74,15 @@ subsumes'
-> SourceType
-> SourceType
-> m (Coercion mode)
-subsumes' mode (ForAll _ ident _ ty1 _) ty2 = do
- replaced <- replaceVarWithUnknown ident ty1
+subsumes' mode (ForAll _ _ ident mbK ty1 _) ty2 = do
+ u <- maybe (internalCompilerError "Unelaborated forall") freshTypeWithKind mbK
+ let replaced = replaceTypeVars ident u ty1
subsumes' mode replaced ty2
-subsumes' mode ty1 (ForAll _ ident _ ty2 sco) =
+subsumes' mode ty1 (ForAll _ _ ident mbK ty2 sco) =
case sco of
Just sco' -> do
sko <- newSkolemConstant
- let sk = skolemize NullSourceAnn ident sko sco' ty2
+ let sk = skolemize NullSourceAnn ident mbK sko sco' ty2
subsumes' mode ty1 sk
Nothing -> internalError "subsumes: unspecified skolem scope"
subsumes' mode (TypeApp _ (TypeApp _ f1 arg1) ret1) (TypeApp _ (TypeApp _ f2 arg2) ret2) | eqType f1 tyFunction && eqType f2 tyFunction = do
@@ -103,17 +103,19 @@ subsumes' SElaborate (ConstrainedType _ con ty1) ty2 = do
let addDicts val = App val (TypeClassDictionary con dicts hints)
return (elaborate . addDicts)
subsumes' mode (TypeApp _ f1 r1) (TypeApp _ f2 r2) | eqType f1 tyRecord && eqType f2 tyRecord = do
- let (common, ((ts1', r1'), (ts2', r2'))) = alignRowsWith (subsumes' SNoElaborate) r1 r2
+ let goWithLabel l t1 t2 = withErrorMessageHint (ErrorInRowLabel l) $ subsumes' SNoElaborate t1 t2
+ let (common, ((ts1', r1'), (ts2', r2'))) = alignRowsWith goWithLabel r1 r2
-- For { ts1 | r1 } to subsume { ts2 | r2 } when r1 is empty (= we're working with a closed row),
-- every property in ts2 must appear in ts1. If not, then the candidate expression is missing a required property.
-- Conversely, when r2 is empty, every property in ts1 must appear in ts2, or else the expression has
-- an additional property which is not allowed.
- when (eqType r1' $ REmpty ())
+ when (isREmpty r1')
(for_ (firstMissingProp ts2' ts1') (throwError . errorMessage . PropertyIsMissing . rowListLabel))
- when (eqType r2' $ REmpty ())
+ when (isREmpty r2')
(for_ (firstMissingProp ts1' ts2') (throwError . errorMessage . AdditionalProperty . rowListLabel))
-- Check subsumption for common labels
sequence_ common
+ -- Inject the info here
unifyTypes (rowFromList (ts1', r1')) (rowFromList (ts2', r2'))
-- Nothing was elaborated, return the default coercion
return (defaultCoercion mode)
diff --git a/src/Language/PureScript/TypeChecker/Synonyms.hs b/src/Language/PureScript/TypeChecker/Synonyms.hs
index 7d5d250e94..8d2cf7886c 100644
--- a/src/Language/PureScript/TypeChecker/Synonyms.hs
+++ b/src/Language/PureScript/TypeChecker/Synonyms.hs
@@ -1,62 +1,63 @@
{-# LANGUAGE GADTs #-}
+{-# LANGUAGE TypeOperators #-}
-- |
-- Functions for replacing fully applied type synonyms
--
module Language.PureScript.TypeChecker.Synonyms
( SynonymMap
+ , KindMap
, replaceAllTypeSynonyms
- , replaceAllTypeSynonymsM
) where
-import Prelude.Compat
+import Prelude
-import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.State
-import Data.Maybe (fromMaybe)
-import qualified Data.Map as M
-import Data.Text (Text)
-import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.TypeChecker.Monad
-import Language.PureScript.Types
+import Control.Monad.Error.Class (MonadError(..))
+import Control.Monad.State (MonadState)
+import Data.Maybe (fromMaybe)
+import Data.Map qualified as M
+import Data.Text (Text)
+import Language.PureScript.Environment (Environment(..), TypeKind)
+import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), SourceSpan, errorMessage')
+import Language.PureScript.Names (ProperName, ProperNameType(..), Qualified)
+import Language.PureScript.TypeChecker.Monad (CheckState, getEnv)
+import Language.PureScript.Types (SourceType, Type(..), completeBinderList, everywhereOnTypesTopDownM, getAnnForType, replaceAllTypeVars)
-- | Type synonym information (arguments with kinds, aliased type), indexed by name
-type SynonymMap = M.Map (Qualified (ProperName 'TypeName)) ([(Text, Maybe SourceKind)], SourceType)
+type SynonymMap = M.Map (Qualified (ProperName 'TypeName)) ([(Text, Maybe SourceType)], SourceType)
+
+type KindMap = M.Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
replaceAllTypeSynonyms'
:: SynonymMap
+ -> KindMap
-> SourceType
-> Either MultipleErrors SourceType
-replaceAllTypeSynonyms' syns = everywhereOnTypesTopDownM try
+replaceAllTypeSynonyms' syns kinds = everywhereOnTypesTopDownM try
where
try :: SourceType -> Either MultipleErrors SourceType
- try t = fromMaybe t <$> go 0 [] t
+ try t = fromMaybe t <$> go (fst $ getAnnForType t) 0 [] [] t
- go :: Int -> [SourceType] -> SourceType -> Either MultipleErrors (Maybe SourceType)
- go c args (TypeConstructor _ ctor)
+ go :: SourceSpan -> Int -> [SourceType] -> [SourceType] -> SourceType -> Either MultipleErrors (Maybe SourceType)
+ go ss c kargs args (TypeConstructor _ ctor)
| Just (synArgs, body) <- M.lookup ctor syns
, c == length synArgs
- = let repl = replaceAllTypeVars (zip (map fst synArgs) args) body
+ , kindArgs <- lookupKindArgs ctor
+ , length kargs == length kindArgs
+ = let repl = replaceAllTypeVars (zip (map fst synArgs) args <> zip kindArgs kargs) body
in Just <$> try repl
| Just (synArgs, _) <- M.lookup ctor syns
, length synArgs > c
- = throwError . errorMessage $ PartiallyAppliedSynonym ctor
- go c args (TypeApp _ f arg) = go (c + 1) (arg : args) f
- go _ _ _ = return Nothing
+ = throwError . errorMessage' ss $ PartiallyAppliedSynonym ctor
+ go ss c kargs args (TypeApp _ f arg) = go ss (c + 1) kargs (arg : args) f
+ go ss c kargs args (KindApp _ f arg) = go ss c (arg : kargs) args f
+ go _ _ _ _ _ = return Nothing
+
+ lookupKindArgs :: Qualified (ProperName 'TypeName) -> [Text]
+ lookupKindArgs ctor = fromMaybe [] $ fmap (fmap (fst . snd) . fst) . completeBinderList . fst =<< M.lookup ctor kinds
-- | Replace fully applied type synonyms
replaceAllTypeSynonyms :: (e ~ MultipleErrors, MonadState CheckState m, MonadError e m) => SourceType -> m SourceType
replaceAllTypeSynonyms d = do
env <- getEnv
- either throwError return $ replaceAllTypeSynonyms' (typeSynonyms env) d
-
--- | Replace fully applied type synonyms by explicitly providing a 'SynonymMap'.
-replaceAllTypeSynonymsM
- :: MonadError MultipleErrors m
- => SynonymMap
- -> SourceType
- -> m SourceType
-replaceAllTypeSynonymsM syns = either throwError pure . replaceAllTypeSynonyms' syns
+ either throwError return $ replaceAllTypeSynonyms' (typeSynonyms env) (types env) d
diff --git a/src/Language/PureScript/TypeChecker/TypeSearch.hs b/src/Language/PureScript/TypeChecker/TypeSearch.hs
index a636e3503f..6158f48a82 100644
--- a/src/Language/PureScript/TypeChecker/TypeSearch.hs
+++ b/src/Language/PureScript/TypeChecker/TypeSearch.hs
@@ -2,26 +2,26 @@ module Language.PureScript.TypeChecker.TypeSearch
( typeSearch
) where
-import Protolude
-
-import Control.Monad.Writer (WriterT, runWriterT)
-import qualified Data.Map as Map
-import qualified Language.PureScript.TypeChecker.Entailment as Entailment
-
-import qualified Language.PureScript.TypeChecker.Monad as TC
-import Language.PureScript.TypeChecker.Subsumption
-import Language.PureScript.TypeChecker.Unify as P
-
-import Control.Monad.Supply as P
-import Language.PureScript.AST as P
-import Language.PureScript.Environment as P
-import Language.PureScript.Errors as P
-import Language.PureScript.Label
-import Language.PureScript.Names as P
-import Language.PureScript.Pretty.Types as P
-import Language.PureScript.TypeChecker.Skolems as Skolem
-import Language.PureScript.TypeChecker.Synonyms as P
-import Language.PureScript.Types as P
+import Protolude
+
+import Control.Monad.Writer (WriterT, runWriterT)
+import Data.Map qualified as Map
+import Language.PureScript.TypeChecker.Entailment qualified as Entailment
+
+import Language.PureScript.TypeChecker.Monad qualified as TC
+import Language.PureScript.TypeChecker.Subsumption (subsumes)
+import Language.PureScript.TypeChecker.Unify as P
+
+import Control.Monad.Supply as P
+import Language.PureScript.AST as P
+import Language.PureScript.Environment as P
+import Language.PureScript.Errors as P
+import Language.PureScript.Label (Label)
+import Language.PureScript.Names as P
+import Language.PureScript.Pretty.Types as P
+import Language.PureScript.TypeChecker.Skolems as Skolem
+import Language.PureScript.TypeChecker.Synonyms as P
+import Language.PureScript.Types as P
checkInEnvironment
:: Environment
@@ -33,10 +33,10 @@ checkInEnvironment env st =
. runExcept
. evalWriterT
. P.evalSupplyT 0
- . TC.runCheck' (st { TC.checkEnv = env })
+ . TC.runCheck (st { TC.checkEnv = env })
evalWriterT :: Monad m => WriterT b m r -> m r
-evalWriterT m = liftM fst (runWriterT m)
+evalWriterT m = fmap fst (runWriterT m)
checkSubsume
:: Maybe [(P.Ident, Entailment.InstanceContext, P.SourceConstraint)]
@@ -59,7 +59,7 @@ checkSubsume unsolved env st userT envT = checkInEnvironment env st $ do
userT' <- initializeSkolems userT
envT' <- initializeSkolems envT
- let dummyExpression = P.Var nullSourceSpan (P.Qualified Nothing (P.Ident "x"))
+ let dummyExpression = P.Var nullSourceSpan (P.Qualified P.ByNullSourcePos (P.Ident "x"))
elab <- subsumes envT' userT'
subst <- gets TC.checkSubstitution
@@ -93,8 +93,8 @@ accessorSearch unsolved env st userT = maybe ([], []) fst $ checkInEnvironment e
userT' <- initializeSkolems userT
- rowType <- freshType
- resultType <- freshType
+ rowType <- freshTypeWithKind (P.kindRow P.kindType)
+ resultType <- freshTypeWithKind P.kindType
let recordFunction = srcTypeApp (srcTypeApp tyFunction (srcTypeApp tyRecord rowType)) resultType
_ <- subsumes recordFunction userT'
subst <- gets TC.checkSubstitution
@@ -123,8 +123,11 @@ typeSearch unsolved env st type' =
matchingNames = runTypeSearch (Map.map (\(ty, _, _) -> ty) (P.names env))
matchingConstructors = runTypeSearch (Map.map (\(_, _, ty, _) -> ty) (P.dataConstructors env))
(allLabels, matchingLabels) = accessorSearch unsolved env st type'
+
+ runPlainIdent (Qualified m (Ident k), v) = Just (Qualified m k, v)
+ runPlainIdent _ = Nothing
in
- ( (first (P.Qualified Nothing . ("_." <>) . P.prettyPrintLabel) <$> matchingLabels)
- <> (first (map P.runIdent) <$> Map.toList matchingNames)
+ ( (first (P.Qualified P.ByNullSourcePos . ("_." <>) . P.prettyPrintLabel) <$> matchingLabels)
+ <> mapMaybe runPlainIdent (Map.toList matchingNames)
<> (first (map P.runProperName) <$> Map.toList matchingConstructors)
, if null allLabels then Nothing else Just allLabels)
diff --git a/src/Language/PureScript/TypeChecker/Types.hs b/src/Language/PureScript/TypeChecker/Types.hs
index e4491359f2..3f758805c6 100644
--- a/src/Language/PureScript/TypeChecker/Types.hs
+++ b/src/Language/PureScript/TypeChecker/Types.hs
@@ -1,11 +1,10 @@
-{-# LANGUAGE NamedFieldPuns #-}
-
-- |
-- This module implements the type checker
--
module Language.PureScript.TypeChecker.Types
( BindingGroupType(..)
, typesOf
+ , checkTypeKind
) where
{-
@@ -24,11 +23,11 @@ module Language.PureScript.TypeChecker.Types
Check a function of a given type returns a value of another type when applied to its arguments
-}
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
+import Protolude (ordNub, fold, atMay)
import Control.Arrow (first, second, (***))
-import Control.Monad
+import Control.Monad (forM, forM_, guard, replicateM, unless, when, zipWithM, (<=<))
import Control.Monad.Error.Class (MonadError(..))
import Control.Monad.State.Class (MonadState(..), gets)
import Control.Monad.Supply.Class (MonadSupply)
@@ -39,26 +38,27 @@ import Data.Either (partitionEithers)
import Data.Functor (($>))
import Data.List (transpose, (\\), partition, delete)
import Data.Maybe (fromMaybe)
+import Data.Text (Text)
import Data.Traversable (for)
-import qualified Data.List.NonEmpty as NEL
-import qualified Data.Map as M
-import qualified Data.Set as S
+import Data.List.NonEmpty qualified as NEL
+import Data.Map qualified as M
+import Data.Set qualified as S
+import Data.IntSet qualified as IS
import Language.PureScript.AST
-import Language.PureScript.Crash
+import Language.PureScript.Crash (internalError)
import Language.PureScript.Environment
-import Language.PureScript.Errors
-import Language.PureScript.Kinds
-import Language.PureScript.Names
-import Language.PureScript.Traversals
-import Language.PureScript.TypeChecker.Entailment
-import Language.PureScript.TypeChecker.Kinds
+import Language.PureScript.Errors (ErrorMessage(..), MultipleErrors, SimpleErrorMessage(..), errorMessage, errorMessage', escalateWarningWhen, internalCompilerError, onErrorMessages, onTypesInErrorMessage, parU)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName, Name(..), ProperName(..), ProperNameType(..), Qualified(..), QualifiedBy(..), byMaybeModuleName, coerceProperName, freshIdent)
+import Language.PureScript.TypeChecker.Deriving (deriveInstance)
+import Language.PureScript.TypeChecker.Entailment (InstanceContext, newDictionaries, replaceTypeClassDictionaries)
+import Language.PureScript.TypeChecker.Kinds (checkConstraint, checkKind, checkTypeKind, kindOf, kindOfWithScopedVars, unifyKinds', unknownsWithKinds)
import Language.PureScript.TypeChecker.Monad
-import Language.PureScript.TypeChecker.Skolems
-import Language.PureScript.TypeChecker.Subsumption
-import Language.PureScript.TypeChecker.Synonyms
-import Language.PureScript.TypeChecker.TypeSearch
-import Language.PureScript.TypeChecker.Unify
+import Language.PureScript.TypeChecker.Skolems (introduceSkolemScope, newSkolemConstant, newSkolemScope, skolemEscapeCheck, skolemize, skolemizeTypesInValue)
+import Language.PureScript.TypeChecker.Subsumption (subsumes)
+import Language.PureScript.TypeChecker.Synonyms (replaceAllTypeSynonyms)
+import Language.PureScript.TypeChecker.TypeSearch (typeSearch)
+import Language.PureScript.TypeChecker.Unify (freshTypeWithKind, replaceTypeWildcards, substituteType, unifyTypes, unknownsInType, varIfUnknown)
import Language.PureScript.Types
import Language.PureScript.Label (Label(..))
import Language.PureScript.PSString (PSString)
@@ -75,6 +75,12 @@ data TypedValue' = TypedValue' Bool Expr SourceType
tvToExpr :: TypedValue' -> Expr
tvToExpr (TypedValue' c e t) = TypedValue c e t
+-- | Lookup data about a type class in the @Environment@
+lookupTypeClass :: MonadState CheckState m => Qualified (ProperName 'ClassName) -> m TypeClassData
+lookupTypeClass name =
+ let findClass = fromMaybe (internalError "entails: type class not found in environment") . M.lookup name
+ in gets (findClass . typeClasses . checkEnv)
+
-- | Infer the types of multiple mutually-recursive values, and return elaborated values including
-- type class dictionaries and type annotations.
typesOf
@@ -96,8 +102,11 @@ typesOf bindingGroupType moduleName vals = withFreshSubstitution $ do
-- Generalize and constrain the type
currentSubst <- gets checkSubstitution
let ty' = substituteType currentSubst ty
- unsolvedTypeVars = ordNub $ unknownsInType ty'
- generalized = generalize unsolved ty'
+ ty'' = constrain unsolved ty'
+ unsolvedTypeVarsWithKinds <- unknownsWithKinds . IS.toList . unknowns $ constrain unsolved ty''
+ let unsolvedTypeVars = IS.toList $ unknowns ty'
+
+ generalized <- varIfUnknown unsolvedTypeVarsWithKinds ty''
when shouldGeneralize $ do
-- Show the inferred type in a warning
@@ -110,21 +119,59 @@ typesOf bindingGroupType moduleName vals = withFreshSubstitution $ do
. throwError
. errorMessage' ss
$ CannotGeneralizeRecursiveFunction ident generalized
- -- Make sure any unsolved type constraints only use type variables which appear
- -- unknown in the inferred type.
- forM_ unsolved $ \(_, _, con) -> do
- -- We need information about functional dependencies, since we allow
- -- ambiguous types to be inferred if they can be solved by some functional
- -- dependency.
- let findClass = fromMaybe (internalError "entails: type class not found in environment") . M.lookup (constraintClass con)
- TypeClassData{ typeClassDependencies } <- gets (findClass . typeClasses . checkEnv)
- let solved = foldMap (S.fromList . fdDetermined) typeClassDependencies
- let constraintTypeVars = ordNub . foldMap (unknownsInType . fst) . filter ((`notElem` solved) . snd) $ zip (constraintArgs con) [0..]
- when (any (`notElem` unsolvedTypeVars) constraintTypeVars) .
- throwError
- . onErrorMessages (replaceTypes currentSubst)
- . errorMessage' ss
- $ AmbiguousTypeVariables generalized con
+ -- We need information about functional dependencies, since we allow
+ -- ambiguous types to be inferred if they can be solved by some functional
+ -- dependency.
+ conData <- forM unsolved $ \(_, _, con) -> do
+ TypeClassData{ typeClassDependencies } <- lookupTypeClass $ constraintClass con
+ let
+ -- The set of unknowns mentioned in each argument.
+ unknownsForArg :: [S.Set Int]
+ unknownsForArg =
+ map (S.fromList . map snd . unknownsInType) (constraintArgs con)
+ pure (typeClassDependencies, unknownsForArg)
+ -- Make sure any unsolved type constraints are determined by the
+ -- type variables which appear unknown in the inferred type.
+ let
+ -- Take the closure of fundeps across constraints, to get more
+ -- and more solved variables until reaching a fixpoint.
+ solveFrom :: S.Set Int -> S.Set Int
+ solveFrom determined = do
+ let solved = solve1 determined
+ if solved `S.isSubsetOf` determined
+ then determined
+ else solveFrom (determined <> solved)
+ solve1 :: S.Set Int -> S.Set Int
+ solve1 determined = fold $ do
+ (tcDeps, conArgUnknowns) <- conData
+ let
+ lookupUnknowns :: Int -> Maybe (S.Set Int)
+ lookupUnknowns = atMay conArgUnknowns
+ unknownsDetermined :: Maybe (S.Set Int) -> Bool
+ unknownsDetermined Nothing = False
+ unknownsDetermined (Just unks) =
+ unks `S.isSubsetOf` determined
+ -- If all of the determining arguments of a particular fundep are
+ -- already determined, add the determined arguments from the fundep
+ tcDep <- tcDeps
+ guard $ all (unknownsDetermined . lookupUnknowns) (fdDeterminers tcDep)
+ map (fromMaybe S.empty . lookupUnknowns) (fdDetermined tcDep)
+ -- These unknowns can be determined from the body of the inferred
+ -- type (i.e. excluding the unknowns mentioned in the constraints)
+ let determinedFromType = S.fromList unsolvedTypeVars
+ -- These are all the unknowns mentioned in the constraints
+ let constraintTypeVars = fold (conData >>= snd)
+ let solved = solveFrom determinedFromType
+ let unsolvedVars = S.difference constraintTypeVars solved
+ let lookupUnkName' i = do
+ mn <- lookupUnkName i
+ pure (fromMaybe "t" mn, i)
+ unsolvedVarNames <- traverse lookupUnkName' (S.toList unsolvedVars)
+ unless (S.null unsolvedVars) .
+ throwError
+ . onErrorMessages (replaceTypes currentSubst)
+ . errorMessage' ss
+ $ AmbiguousTypeVariables generalized unsolvedVarNames
-- Check skolem variables did not escape their scope
skolemEscapeCheck val'
@@ -135,7 +182,7 @@ typesOf bindingGroupType moduleName vals = withFreshSubstitution $ do
finalState <- get
let replaceTypes' = replaceTypes (checkSubstitution finalState)
runTypeSearch' gen = runTypeSearch (guard gen $> foldMap snd inferred) finalState
- raisePreviousWarnings gen = (escalateWarningWhen isHoleError . tell . onErrorMessages (runTypeSearch' gen . replaceTypes'))
+ raisePreviousWarnings gen = escalateWarningWhen isHoleError . tell . onErrorMessages (runTypeSearch' gen . replaceTypes')
raisePreviousWarnings False wInfer
forM_ tys $ \(shouldGeneralize, ((_, (_, _)), w)) ->
@@ -149,12 +196,12 @@ typesOf bindingGroupType moduleName vals = withFreshSubstitution $ do
-> ErrorMessage
replaceTypes subst = onTypesInErrorMessage (substituteType subst)
- -- | Run type search to complete any typed hole error messages
+ -- Run type search to complete any typed hole error messages
runTypeSearch
:: Maybe [(Ident, InstanceContext, SourceConstraint)]
- -- ^ Any unsolved constraints which we need to continue to satisfy
+ -- Any unsolved constraints which we need to continue to satisfy
-> CheckState
- -- ^ The final type checker state
+ -- The final type checker state
-> ErrorMessage
-> ErrorMessage
runTypeSearch cons st = \case
@@ -166,13 +213,11 @@ typesOf bindingGroupType moduleName vals = withFreshSubstitution $ do
in ErrorMessage hints (HoleInferredType x ty y (Just searchResult))
other -> other
- -- | Generalize type vars using forall and add inferred constraints
- generalize unsolved = varIfUnknown . constrain unsolved
-
- -- | Add any unsolved constraints
+ -- Add any unsolved constraints
constrain cs ty = foldr srcConstrainedType ty (map (\(_, _, x) -> x) cs)
-- Apply the substitution that was returned from runUnify to both types and (type-annotated) values
+
tidyUp ts sub = first (map (second (first (second (overTypes (substituteType sub) *** substituteType sub))))) ts
isHoleError :: ErrorMessage -> Bool
@@ -186,7 +231,7 @@ typesOf bindingGroupType moduleName vals = withFreshSubstitution $ do
data SplitBindingGroup = SplitBindingGroup
{ _splitBindingGroupUntyped :: [((SourceAnn, Ident), (Expr, SourceType))]
-- ^ The untyped expressions
- , _splitBindingGroupTyped :: [((SourceAnn, Ident), (Expr, SourceType, Bool))]
+ , _splitBindingGroupTyped :: [((SourceAnn, Ident), (Expr, [(Text, SourceType)], SourceType, Bool))]
-- ^ The typed expressions, along with their type annotations
, _splitBindingGroupNames :: M.Map (Qualified Ident) (SourceType, NameKind, NameVisibility)
-- ^ A map containing all expressions and their assigned types (which might be
@@ -200,7 +245,7 @@ data SplitBindingGroup = SplitBindingGroup
-- This function also generates fresh unification variables for the types of
-- declarations without type annotations, returned in the 'UntypedData' structure.
typeDictionaryForBindingGroup
- :: (MonadState CheckState m, MonadWriter MultipleErrors m)
+ :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
=> Maybe ModuleName
-> [((SourceAnn, Ident), Expr)]
-> m SplitBindingGroup
@@ -210,20 +255,22 @@ typeDictionaryForBindingGroup moduleName vals = do
-- fully expanded types.
let (untyped, typed) = partitionEithers (map splitTypeAnnotation vals)
(typedDict, typed') <- fmap unzip . for typed $ \(sai, (expr, ty, checkType)) -> do
- ty' <- replaceTypeWildcards ty
- return ((sai, ty'), (sai, (expr, ty', checkType)))
+ ((args, elabTy), kind) <- kindOfWithScopedVars ty
+ checkTypeKind ty kind
+ elabTy' <- replaceTypeWildcards elabTy
+ return ((sai, elabTy'), (sai, (expr, args, elabTy', checkType)))
-- Create fresh unification variables for the types of untyped declarations
(untypedDict, untyped') <- fmap unzip . for untyped $ \(sai, expr) -> do
- ty <- freshType
+ ty <- freshTypeWithKind kindType
return ((sai, ty), (sai, (expr, ty)))
-- Create the dictionary of all name/type pairs, which will be added to the
-- environment during type checking
- let dict = M.fromList [ (Qualified moduleName ident, (ty, Private, Undefined))
- | ((_, ident), ty) <- typedDict <> untypedDict
+ let dict = M.fromList [ (Qualified (maybe (BySourcePos $ spanStart ss) ByModuleName moduleName) ident, (ty, Private, Undefined))
+ | (((ss, _), ident), ty) <- typedDict <> untypedDict
]
return (SplitBindingGroup untyped' typed' dict)
where
- -- | Check if a value contains a type annotation, and if so, separate it
+ -- Check if a value contains a type annotation, and if so, separate it
-- from the value itself.
splitTypeAnnotation :: (a, Expr) -> Either (a, Expr) (a, (Expr, SourceType, Bool))
splitTypeAnnotation (a, TypedValue checkType value ty) = Right (a, (value, ty, checkType))
@@ -237,15 +284,12 @@ typeDictionaryForBindingGroup moduleName vals = do
checkTypedBindingGroupElement
:: (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
=> ModuleName
- -> ((SourceAnn, Ident), (Expr, SourceType, Bool))
+ -> ((SourceAnn, Ident), (Expr, [(Text, SourceType)], SourceType, Bool))
-- ^ The identifier we are trying to define, along with the expression and its type annotation
-> M.Map (Qualified Ident) (SourceType, NameKind, NameVisibility)
-- ^ Names brought into scope in this binding group
-> m ((SourceAnn, Ident), (Expr, SourceType))
-checkTypedBindingGroupElement mn (ident, (val, ty, checkType)) dict = do
- -- Kind check
- (kind, args) <- kindOfWithScopedVars ty
- checkTypeKind ty kind
+checkTypedBindingGroupElement mn (ident, (val, args, ty, checkType)) dict = do
-- We replace type synonyms _after_ kind-checking, since we don't want type
-- synonym expansion to bring type variables into scope. See #2542.
ty' <- introduceSkolemScope <=< replaceAllTypeSynonyms $ ty
@@ -271,14 +315,6 @@ typeForBindingGroupElement (ident, (val, ty)) dict = do
unifyTypes ty ty'
return (ident, (TypedValue True val' ty', ty'))
--- | Check the kind of a type, failing if it is not of kind *.
-checkTypeKind
- :: MonadError MultipleErrors m
- => SourceType
- -> SourceKind
- -> m ()
-checkTypeKind ty kind = guardWith (errorMessage (ExpectedType ty kind)) $ isKindType kind
-
-- | Remove any ForAlls and ConstrainedType constructors in a type by introducing new unknowns
-- or TypeClassDictionary values.
--
@@ -289,15 +325,39 @@ instantiatePolyTypeWithUnknowns
=> Expr
-> SourceType
-> m (Expr, SourceType)
-instantiatePolyTypeWithUnknowns val (ForAll _ ident _ ty _) = do
- ty' <- replaceVarWithUnknown ident ty
- instantiatePolyTypeWithUnknowns val ty'
+instantiatePolyTypeWithUnknowns val (ForAll _ _ ident mbK ty _) = do
+ u <- maybe (internalCompilerError "Unelaborated forall") freshTypeWithKind mbK
+ insertUnkName' u ident
+ instantiatePolyTypeWithUnknowns val $ replaceTypeVars ident u ty
instantiatePolyTypeWithUnknowns val (ConstrainedType _ con ty) = do
- dicts <- getTypeClassDictionaries
- hints <- getHints
- instantiatePolyTypeWithUnknowns (App val (TypeClassDictionary con dicts hints)) ty
+ dicts <- getTypeClassDictionaries
+ hints <- getHints
+ instantiatePolyTypeWithUnknowns (App val (TypeClassDictionary con dicts hints)) ty
instantiatePolyTypeWithUnknowns val ty = return (val, ty)
+instantiatePolyTypeWithUnknownsUntilVisible
+ :: (MonadState CheckState m, MonadError MultipleErrors m)
+ => Expr
+ -> SourceType
+ -> m (Expr, SourceType)
+instantiatePolyTypeWithUnknownsUntilVisible val (ForAll _ TypeVarInvisible ident mbK ty _) = do
+ u <- maybe (internalCompilerError "Unelaborated forall") freshTypeWithKind mbK
+ insertUnkName' u ident
+ instantiatePolyTypeWithUnknownsUntilVisible val $ replaceTypeVars ident u ty
+instantiatePolyTypeWithUnknownsUntilVisible val ty = return (val, ty)
+
+instantiateConstraint :: MonadState CheckState m => Expr -> Type SourceAnn -> m (Expr, Type SourceAnn)
+instantiateConstraint val (ConstrainedType _ con ty) = do
+ dicts <- getTypeClassDictionaries
+ hints <- getHints
+ instantiateConstraint (App val (TypeClassDictionary con dicts hints)) ty
+instantiateConstraint val ty = pure (val, ty)
+
+-- | Match against TUnknown and call insertUnkName, failing otherwise.
+insertUnkName' :: (MonadState CheckState m, MonadError MultipleErrors m) => SourceType -> Text -> m ()
+insertUnkName' (TUnknown _ i) n = insertUnkName i n
+insertUnkName' _ _ = internalCompilerError "type is not TUnknown"
+
-- | Infer a type for a value, rethrowing any error to provide a more useful error message
infer
:: (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
@@ -318,7 +378,7 @@ infer' v@(Literal _ (CharLiteral _)) = return $ TypedValue' True v tyChar
infer' v@(Literal _ (BooleanLiteral _)) = return $ TypedValue' True v tyBoolean
infer' (Literal ss (ArrayLiteral vals)) = do
ts <- traverse infer vals
- els <- freshType
+ els <- freshTypeWithKind kindType
ts' <- forM ts $ \(TypedValue' ch val t) -> do
(val', t') <- instantiatePolyTypeWithUnknowns val t
unifyTypes els t'
@@ -326,47 +386,71 @@ infer' (Literal ss (ArrayLiteral vals)) = do
return $ TypedValue' True (Literal ss (ArrayLiteral ts')) (srcTypeApp tyArray els)
infer' (Literal ss (ObjectLiteral ps)) = do
ensureNoDuplicateProperties ps
- -- We make a special case for Vars in record labels, since these are the
- -- only types of expressions for which 'infer' can return a polymorphic type.
- -- They need to be instantiated here.
- let shouldInstantiate :: Expr -> Bool
- shouldInstantiate Var{} = True
- shouldInstantiate (PositionedValue _ _ e) = shouldInstantiate e
- shouldInstantiate _ = False
-
- inferProperty :: (PSString, Expr) -> m (PSString, (Expr, SourceType))
- inferProperty (name, val) = do
- TypedValue' _ val' ty <- infer val
- valAndType <- if shouldInstantiate val
- then instantiatePolyTypeWithUnknowns val' ty
- else pure (val', ty)
- pure (name, valAndType)
-
- toRowListItem (lbl, (_, ty)) = srcRowListItem (Label lbl) ty
-
- fields <- forM ps inferProperty
- let ty = srcTypeApp tyRecord $ rowFromList (map toRowListItem fields, srcREmpty)
- return $ TypedValue' True (Literal ss (ObjectLiteral (map (fmap (uncurry (TypedValue True))) fields))) ty
-infer' (ObjectUpdate o ps) = do
+ typedFields <- inferProperties ps
+ let
+ toRowListItem :: (PSString, (Expr, SourceType)) -> RowListItem SourceAnn
+ toRowListItem (l, (_, t)) = srcRowListItem (Label l) t
+
+ recordType :: SourceType
+ recordType = srcTypeApp tyRecord $ rowFromList (toRowListItem <$> typedFields, srcKindApp srcREmpty kindType)
+
+ typedProperties :: [(PSString, Expr)]
+ typedProperties = fmap (fmap (uncurry (TypedValue True))) typedFields
+ pure $ TypedValue' True (Literal ss (ObjectLiteral typedProperties)) recordType
+infer' (ObjectUpdate ob ps) = do
ensureNoDuplicateProperties ps
- row <- freshType
- typedVals <- zipWith (\(name, _) t -> (name, t)) ps <$> traverse (infer . snd) ps
- let toRowListItem = uncurry srcRowListItem
- let newTys = map (\(name, TypedValue' _ _ ty) -> (Label name, ty)) typedVals
- oldTys <- zip (map (Label . fst) ps) <$> replicateM (length ps) freshType
- let oldTy = srcTypeApp tyRecord $ rowFromList (toRowListItem <$> oldTys, row)
- o' <- TypedValue True <$> (tvToExpr <$> check o oldTy) <*> pure oldTy
- let newVals = map (fmap tvToExpr) typedVals
- return $ TypedValue' True (ObjectUpdate o' newVals) $ srcTypeApp tyRecord $ rowFromList (toRowListItem <$> newTys, row)
+ -- This "tail" holds all other fields not being updated.
+ rowType <- freshTypeWithKind (kindRow kindType)
+ let updateLabels = Label . fst <$> ps
+ -- Generate unification variables for each field in ps.
+ --
+ -- Given:
+ --
+ -- ob { a = 0, b = 0 }
+ --
+ -- Then:
+ --
+ -- obTypes = [(a, ?0), (b, ?1)]
+ obTypes <- zip updateLabels <$> replicateM (length updateLabels) (freshTypeWithKind kindType)
+ let obItems :: [RowListItem SourceAnn]
+ obItems = uncurry srcRowListItem <$> obTypes
+ -- Create a record type that contains the unification variables.
+ --
+ -- obRecordType = Record ( a :: ?0, b :: ?1 | rowType )
+ obRecordType :: SourceType
+ obRecordType = srcTypeApp tyRecord $ rowFromList (obItems, rowType)
+ -- Check ob against obRecordType.
+ --
+ -- Given:
+ --
+ -- ob : { a :: Int, b :: Int }
+ --
+ -- Then:
+ --
+ -- ?0 ~ Int
+ -- ?1 ~ Int
+ -- ob' : { a :: ?0, b :: ?1 }
+ ob' <- TypedValue True <$> (tvToExpr <$> check ob obRecordType) <*> pure obRecordType
+ -- Infer the types of the values used for the record update.
+ typedFields <- inferProperties ps
+ let newItems :: [RowListItem SourceAnn]
+ newItems = (\(l, (_, t)) -> srcRowListItem (Label l) t) <$> typedFields
+
+ ps' :: [(PSString, Expr)]
+ ps' = (\(l, (e, t)) -> (l, TypedValue True e t)) <$> typedFields
+
+ newRecordType :: SourceType
+ newRecordType = srcTypeApp tyRecord $ rowFromList (newItems, rowType)
+ pure $ TypedValue' True (ObjectUpdate ob' ps') newRecordType
infer' (Accessor prop val) = withErrorMessageHint (ErrorCheckingAccessor val prop) $ do
- field <- freshType
- rest <- freshType
+ field <- freshTypeWithKind kindType
+ rest <- freshTypeWithKind (kindRow kindType)
typed <- tvToExpr <$> check val (srcTypeApp tyRecord (srcRCons (Label prop) field rest))
return $ TypedValue' True (Accessor prop typed) field
infer' (Abs binder ret)
| VarBinder ss arg <- binder = do
- ty <- freshType
- withBindingGroupVisible $ bindLocalVariables [(arg, ty, Defined)] $ do
+ ty <- freshTypeWithKind kindType
+ withBindingGroupVisible $ bindLocalVariables [(ss, arg, ty, Defined)] $ do
body@(TypedValue' _ _ bodyTy) <- infer' ret
(body', bodyTy') <- instantiatePolyTypeWithUnknowns (tvToExpr body) bodyTy
return $ TypedValue' True (Abs (VarBinder ss arg) body') (function ty bodyTy')
@@ -375,6 +459,26 @@ infer' (App f arg) = do
f'@(TypedValue' _ _ ft) <- infer f
(ret, app) <- checkFunctionApplication (tvToExpr f') ft arg
return $ TypedValue' True app ret
+infer' (VisibleTypeApp valFn (TypeWildcard _ _)) = do
+ TypedValue' _ valFn' valTy <- infer valFn
+ (valFn'', valTy') <- instantiatePolyTypeWithUnknownsUntilVisible valFn' valTy
+ case valTy' of
+ ForAll qAnn _ qName qKind qBody qSko -> do
+ pure $ TypedValue' True valFn'' (ForAll qAnn TypeVarInvisible qName qKind qBody qSko)
+ _ ->
+ throwError $ errorMessage $ CannotSkipTypeApplication valTy'
+infer' (VisibleTypeApp valFn tyArg) = do
+ TypedValue' _ valFn' valTy <- infer valFn
+ tyArg' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ tyArg
+ (valFn'', valTy') <- instantiatePolyTypeWithUnknownsUntilVisible valFn' valTy
+ case valTy' of
+ ForAll _ _ qName (Just qKind) qBody _ -> do
+ tyArg'' <- replaceAllTypeSynonyms <=< checkKind tyArg' $ qKind
+ let resTy = replaceTypeVars qName tyArg'' qBody
+ (valFn''', resTy') <- instantiateConstraint valFn'' resTy
+ pure $ TypedValue' True valFn''' resTy'
+ _ ->
+ throwError $ errorMessage $ CannotApplyExpressionOfTypeOnType valTy tyArg
infer' (Var ss var) = do
checkVisibility var
ty <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards <=< lookupVariable $ var
@@ -388,11 +492,10 @@ infer' v@(Constructor _ c) = do
env <- getEnv
case M.lookup c (dataConstructors env) of
Nothing -> throwError . errorMessage . UnknownName . fmap DctorName $ c
- Just (_, _, ty, _) -> do (v', ty') <- sndM (introduceSkolemScope <=< replaceAllTypeSynonyms) <=< instantiatePolyTypeWithUnknowns v $ ty
- return $ TypedValue' True v' ty'
+ Just (_, _, ty, _) -> TypedValue' True v <$> (introduceSkolemScope <=< replaceAllTypeSynonyms $ ty)
infer' (Case vals binders) = do
(vals', ts) <- instantiateForBinders vals binders
- ret <- freshType
+ ret <- freshTypeWithKind kindType
binders' <- checkBinders ts ret binders
return $ TypedValue' True (Case vals' binders') ret
infer' (IfThenElse cond th el) = do
@@ -409,18 +512,19 @@ infer' (Let w ds val) = do
infer' (DeferredDictionary className tys) = do
dicts <- getTypeClassDictionaries
hints <- getHints
+ con <- checkConstraint (srcConstraint className [] tys Nothing)
return $ TypedValue' False
- (TypeClassDictionary (srcConstraint className tys Nothing) dicts hints)
+ (TypeClassDictionary con dicts hints)
(foldl srcTypeApp (srcTypeConstructor (fmap coerceProperName className)) tys)
infer' (TypedValue checkType val ty) = do
moduleName <- unsafeCheckCurrentModule
- (kind, args) <- kindOfWithScopedVars ty
+ ((args, elabTy), kind) <- kindOfWithScopedVars ty
checkTypeKind ty kind
- ty' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ ty
+ ty' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ elabTy
tv <- if checkType then withScopedTypeVars moduleName args (check val ty') else return (TypedValue' False val ty)
return $ TypedValue' True (tvToExpr tv) ty'
infer' (Hole name) = do
- ty <- freshType
+ ty <- freshTypeWithKind kindType
ctx <- getLocalContext
env <- getEnv
tell . errorMessage $ HoleInferredType name ty ctx . Just $ TSBefore env
@@ -430,6 +534,45 @@ infer' (PositionedValue pos c val) = warnAndRethrowWithPositionTC pos $ do
return $ TypedValue' t (PositionedValue pos c v) ty
infer' v = internalError $ "Invalid argument to infer: " ++ show v
+-- |
+-- Infer the types of named record fields.
+inferProperties
+ :: ( MonadSupply m
+ , MonadState CheckState m
+ , MonadError MultipleErrors m
+ , MonadWriter MultipleErrors m
+ )
+ => [(PSString, Expr)]
+ -> m [(PSString, (Expr, SourceType))]
+inferProperties = traverse (traverse inferWithinRecord)
+
+-- |
+-- Infer the type of a value when used as a record field.
+inferWithinRecord
+ :: ( MonadSupply m
+ , MonadState CheckState m
+ , MonadError MultipleErrors m
+ , MonadWriter MultipleErrors m
+ )
+ => Expr
+ -> m (Expr, SourceType)
+inferWithinRecord e = do
+ TypedValue' _ v t <- infer e
+ if propertyShouldInstantiate e
+ then instantiatePolyTypeWithUnknowns v t
+ else pure (v, t)
+
+-- |
+-- Determines if a value's type needs to be monomorphized when
+-- used inside of a record.
+propertyShouldInstantiate :: Expr -> Bool
+propertyShouldInstantiate = \case
+ Var{} -> True
+ Constructor{} -> True
+ VisibleTypeApp e _ -> propertyShouldInstantiate e
+ PositionedValue _ _ e -> propertyShouldInstantiate e
+ _ -> False
+
inferLetBinding
:: (MonadSupply m, MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
=> [Declaration]
@@ -437,26 +580,26 @@ inferLetBinding
-> Expr
-> (Expr -> m TypedValue')
-> m ([Declaration], TypedValue')
-inferLetBinding seen [] ret j = (,) seen <$> withBindingGroupVisible (j ret)
+inferLetBinding seen [] ret j = (seen, ) <$> withBindingGroupVisible (j ret)
inferLetBinding seen (ValueDecl sa@(ss, _) ident nameKind [] [MkUnguarded (TypedValue checkType val ty)] : rest) ret j = do
moduleName <- unsafeCheckCurrentModule
TypedValue' _ val' ty'' <- warnAndRethrowWithPositionTC ss $ do
- (kind, args) <- kindOfWithScopedVars ty
+ ((args, elabTy), kind) <- kindOfWithScopedVars ty
checkTypeKind ty kind
- let dict = M.singleton (Qualified Nothing ident) (ty, nameKind, Undefined)
- ty' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ ty
+ let dict = M.singleton (Qualified (BySourcePos $ spanStart ss) ident) (elabTy, nameKind, Undefined)
+ ty' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ elabTy
if checkType
then withScopedTypeVars moduleName args (bindNames dict (check val ty'))
- else return (TypedValue' checkType val ty)
- bindNames (M.singleton (Qualified Nothing ident) (ty'', nameKind, Defined))
+ else return (TypedValue' checkType val elabTy)
+ bindNames (M.singleton (Qualified (BySourcePos $ spanStart ss) ident) (ty'', nameKind, Defined))
$ inferLetBinding (seen ++ [ValueDecl sa ident nameKind [] [MkUnguarded (TypedValue checkType val' ty'')]]) rest ret j
inferLetBinding seen (ValueDecl sa@(ss, _) ident nameKind [] [MkUnguarded val] : rest) ret j = do
- valTy <- freshType
+ valTy <- freshTypeWithKind kindType
TypedValue' _ val' valTy' <- warnAndRethrowWithPositionTC ss $ do
- let dict = M.singleton (Qualified Nothing ident) (valTy, nameKind, Undefined)
+ let dict = M.singleton (Qualified (BySourcePos $ spanStart ss) ident) (valTy, nameKind, Undefined)
bindNames dict $ infer val
warnAndRethrowWithPositionTC ss $ unifyTypes valTy valTy'
- bindNames (M.singleton (Qualified Nothing ident) (valTy', nameKind, Defined))
+ bindNames (M.singleton (Qualified (BySourcePos $ spanStart ss) ident) (valTy', nameKind, Defined))
$ inferLetBinding (seen ++ [ValueDecl sa ident nameKind [] [MkUnguarded val']]) rest ret j
inferLetBinding seen (BindingGroupDeclaration ds : rest) ret j = do
moduleName <- unsafeCheckCurrentModule
@@ -475,14 +618,14 @@ inferBinder
. (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
=> SourceType
-> Binder
- -> m (M.Map Ident SourceType)
+ -> m (M.Map Ident (SourceSpan, SourceType))
inferBinder _ NullBinder = return M.empty
inferBinder val (LiteralBinder _ (StringLiteral _)) = unifyTypes val tyString >> return M.empty
inferBinder val (LiteralBinder _ (CharLiteral _)) = unifyTypes val tyChar >> return M.empty
inferBinder val (LiteralBinder _ (NumericLiteral (Left _))) = unifyTypes val tyInt >> return M.empty
inferBinder val (LiteralBinder _ (NumericLiteral (Right _))) = unifyTypes val tyNumber >> return M.empty
inferBinder val (LiteralBinder _ (BooleanLiteral _)) = unifyTypes val tyBoolean >> return M.empty
-inferBinder val (VarBinder _ name) = return $ M.singleton name val
+inferBinder val (VarBinder ss name) = return $ M.singleton name (ss, val)
inferBinder val (ConstructorBinder ss ctor binders) = do
env <- getEnv
case M.lookup ctor (dataConstructors env) of
@@ -503,34 +646,34 @@ inferBinder val (ConstructorBinder ss ctor binders) = do
go args (TypeApp _ (TypeApp _ fn arg) ret) | eqType fn tyFunction = go (arg : args) ret
go args ret = (args, ret)
inferBinder val (LiteralBinder _ (ObjectLiteral props)) = do
- row <- freshType
- rest <- freshType
+ row <- freshTypeWithKind (kindRow kindType)
+ rest <- freshTypeWithKind (kindRow kindType)
m1 <- inferRowProperties row rest props
unifyTypes val (srcTypeApp tyRecord row)
return m1
where
- inferRowProperties :: SourceType -> SourceType -> [(PSString, Binder)] -> m (M.Map Ident SourceType)
+ inferRowProperties :: SourceType -> SourceType -> [(PSString, Binder)] -> m (M.Map Ident (SourceSpan, SourceType))
inferRowProperties nrow row [] = unifyTypes nrow row >> return M.empty
inferRowProperties nrow row ((name, binder):binders) = do
- propTy <- freshType
+ propTy <- freshTypeWithKind kindType
m1 <- inferBinder propTy binder
m2 <- inferRowProperties nrow (srcRCons (Label name) propTy row) binders
return $ m1 `M.union` m2
inferBinder val (LiteralBinder _ (ArrayLiteral binders)) = do
- el <- freshType
+ el <- freshTypeWithKind kindType
m1 <- M.unions <$> traverse (inferBinder el) binders
unifyTypes val (srcTypeApp tyArray el)
return m1
inferBinder val (NamedBinder ss name binder) =
warnAndRethrowWithPositionTC ss $ do
m <- inferBinder val binder
- return $ M.insert name val m
+ return $ M.insert name (ss, val) m
inferBinder val (PositionedBinder pos _ binder) =
warnAndRethrowWithPositionTC pos $ inferBinder val binder
inferBinder val (TypedBinder ty binder) = do
- kind <- kindOf ty
+ (elabTy, kind) <- kindOf ty
checkTypeKind ty kind
- ty1 <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ ty
+ ty1 <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ elabTy
unifyTypes val ty1
inferBinder ty1 binder
inferBinder _ OpBinder{} =
@@ -579,7 +722,7 @@ checkBinders nvals ret (CaseAlternative binders result : bs) = do
guardWith (errorMessage $ OverlappingArgNames Nothing) $
let ns = concatMap binderNames binders in length (ordNub ns) == length ns
m1 <- M.unions <$> zipWithM inferBinder nvals binders
- r <- bindLocalVariables [ (name, ty, Defined) | (name, ty) <- M.toList m1 ] $
+ r <- bindLocalVariables [ (ss, name, ty, Defined) | (name, (ss, ty)) <- M.toList m1 ] $
CaseAlternative binders <$> forM result (\ge -> checkGuardedRhs ge ret)
rs <- checkBinders nvals ret bs
return $ r : rs
@@ -599,8 +742,8 @@ checkGuardedRhs (GuardedExpr (ConditionGuard cond : guards) rhs) ret = do
checkGuardedRhs (GuardedExpr (PatternGuard binder expr : guards) rhs) ret = do
tv@(TypedValue' _ _ ty) <- infer expr
variables <- inferBinder ty binder
- GuardedExpr guards' rhs' <- bindLocalVariables [ (name, bty, Defined)
- | (name, bty) <- M.toList variables
+ GuardedExpr guards' rhs' <- bindLocalVariables [ (ss, name, bty, Defined)
+ | (name, (ss, bty)) <- M.toList variables
] $
checkGuardedRhs (GuardedExpr guards rhs) ret
return $ GuardedExpr (PatternGuard binder (tvToExpr tv) : guards') rhs'
@@ -613,7 +756,7 @@ check
=> Expr
-> SourceType
-> m TypedValue'
-check val ty = withErrorMessageHint (ErrorCheckingType val ty) $ check' val ty
+check val ty = withErrorMessageHint' val (ErrorCheckingType val ty) $ check' val ty
-- |
-- Check the type of a value
@@ -624,19 +767,31 @@ check'
=> Expr
-> SourceType
-> m TypedValue'
-check' val (ForAll ann ident mbK ty _) = do
+check' val (ForAll ann vis ident mbK ty _) = do
+ env <- getEnv
+ mn <- gets checkCurrentModule
scope <- newSkolemScope
sko <- newSkolemConstant
let ss = case val of
PositionedValue pos c _ -> (pos, c)
_ -> NullSourceAnn
- sk = skolemize ss ident sko scope ty
- skVal = skolemizeTypesInValue ss ident sko scope val
+ sk = skolemize ss ident mbK sko scope ty
+ -- We should only skolemize types in values when the type variable
+ -- was actually brought into scope. Otherwise we can end up skolemizing
+ -- an undefined type variable that happens to clash with the variable we
+ -- want to skolemize. This can happen due to synonym expansion (see 2542).
+ skVal
+ | Just _ <- M.lookup (Qualified (byMaybeModuleName mn) (ProperName ident)) $ types env =
+ skolemizeTypesInValue ss ident mbK sko scope val
+ | otherwise = val
val' <- tvToExpr <$> check skVal sk
- return $ TypedValue' True val' (ForAll ann ident mbK ty (Just scope))
-check' val t@(ConstrainedType _ con@(Constraint _ (Qualified _ (ProperName className)) _ _) ty) = do
- dictName <- freshIdent ("dict" <> className)
- dicts <- newDictionaries [] (Qualified Nothing dictName) con
+ return $ TypedValue' True val' (ForAll ann vis ident mbK ty (Just scope))
+check' val t@(ConstrainedType _ con@(Constraint _ cls@(Qualified _ (ProperName className)) _ _ _) ty) = do
+ TypeClassData{ typeClassIsEmpty } <- lookupTypeClass cls
+ -- An empty class dictionary is never used; see code in `TypeChecker.Entailment`
+ -- that wraps empty dictionary solutions in `Unused`.
+ dictName <- if typeClassIsEmpty then pure UnusedIdent else freshIdent ("dict" <> className)
+ dicts <- newDictionaries [] (Qualified ByNullSourcePos dictName) con
val' <- withBindingGroupVisible $ withTypeClassDictionaries dicts $ check val ty
return $ TypedValue' True (Abs (VarBinder nullSourceSpan dictName) (tvToExpr val')) t
check' val u@(TUnknown _ _) = do
@@ -662,7 +817,7 @@ check' (Literal ss (ArrayLiteral vals)) t@(TypeApp _ a ty) = do
check' (Abs binder ret) ty@(TypeApp _ (TypeApp _ t argTy) retTy)
| VarBinder ss arg <- binder = do
unifyTypes t tyFunction
- ret' <- withBindingGroupVisible $ bindLocalVariables [(arg, argTy, Defined)] $ check ret retTy
+ ret' <- withBindingGroupVisible $ bindLocalVariables [(ss, arg, argTy, Defined)] $ check ret retTy
return $ TypedValue' True (Abs (VarBinder ss arg) (tvToExpr ret')) ty
| otherwise = internalError "Binder was not desugared"
check' (App f arg) ret = do
@@ -685,17 +840,21 @@ check' (DeferredDictionary className tys) ty = do
-}
dicts <- getTypeClassDictionaries
hints <- getHints
+ con <- checkConstraint (srcConstraint className [] tys Nothing)
return $ TypedValue' False
- (TypeClassDictionary (srcConstraint className tys Nothing) dicts hints)
+ (TypeClassDictionary con dicts hints)
ty
check' (TypedValue checkType val ty1) ty2 = do
- kind <- kindOf ty1
- checkTypeKind ty1 kind
- ty1' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ ty1
- ty2' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ ty2
+ moduleName <- unsafeCheckCurrentModule
+ ((args, elabTy1), kind1) <- kindOfWithScopedVars ty1
+ (elabTy2, kind2) <- kindOf ty2
+ unifyKinds' kind1 kind2
+ checkTypeKind ty1 kind1
+ ty1' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ elabTy1
+ ty2' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ elabTy2
elaborate <- subsumes ty1' ty2'
val' <- if checkType
- then tvToExpr <$> check val ty1'
+ then withScopedTypeVars moduleName args $ tvToExpr <$> check val ty1'
else pure val
return $ TypedValue' True (TypedValue checkType (elaborate val') ty1') ty2'
check' (Case vals binders) ret = do
@@ -711,21 +870,22 @@ check' e@(Literal ss (ObjectLiteral ps)) t@(TypeApp _ obj row) | obj == tyRecord
ensureNoDuplicateProperties ps
ps' <- checkProperties e ps row False
return $ TypedValue' True (Literal ss (ObjectLiteral ps')) t
-check' (TypeClassDictionaryConstructorApp name ps) t = do
- ps' <- tvToExpr <$> check' ps t
- return $ TypedValue' True (TypeClassDictionaryConstructorApp name ps') t
+check' (DerivedInstancePlaceholder name strategy) t = do
+ d <- deriveInstance t name strategy
+ d' <- tvToExpr <$> check' d t
+ return $ TypedValue' True d' t
check' e@(ObjectUpdate obj ps) t@(TypeApp _ o row) | o == tyRecord = do
ensureNoDuplicateProperties ps
-- We need to be careful to avoid duplicate labels here.
-- We check _obj_ against the type _t_ with the types in _ps_ replaced with unknowns.
let (propsToCheck, rest) = rowToList row
(removedProps, remainingProps) = partition (\(RowListItem _ p _) -> p `elem` map (Label . fst) ps) propsToCheck
- us <- zipWith srcRowListItem (map rowListLabel removedProps) <$> replicateM (length ps) freshType
+ us <- zipWith srcRowListItem (map rowListLabel removedProps) <$> replicateM (length ps) (freshTypeWithKind kindType)
obj' <- tvToExpr <$> check obj (srcTypeApp tyRecord (rowFromList (us ++ remainingProps, rest)))
ps' <- checkProperties e ps row True
return $ TypedValue' True (ObjectUpdate obj' ps') t
check' (Accessor prop val) ty = withErrorMessageHint (ErrorCheckingAccessor val prop) $ do
- rest <- freshType
+ rest <- freshTypeWithKind (kindRow kindType)
val' <- tvToExpr <$> check val (srcTypeApp tyRecord (srcRCons (Label prop) ty rest))
return $ TypedValue' True (Accessor prop val') ty
check' v@(Constructor _ c) ty = do
@@ -734,7 +894,7 @@ check' v@(Constructor _ c) ty = do
Nothing -> throwError . errorMessage . UnknownName . fmap DctorName $ c
Just (_, _, ty1, _) -> do
repl <- introduceSkolemScope <=< replaceAllTypeSynonyms $ ty1
- ty' <- introduceSkolemScope ty
+ ty' <- introduceSkolemScope <=< replaceAllTypeSynonyms $ ty
elaborate <- subsumes repl ty'
return $ TypedValue' True (elaborate v) ty'
check' (Let w ds val) ty = do
@@ -768,7 +928,7 @@ checkProperties expr ps row lax = convert <$> go ps (toRowPair <$> ts') r' where
convert = fmap (fmap tvToExpr)
(ts', r') = rowToList row
toRowPair (RowListItem _ lbl ty) = (lbl, ty)
- go [] [] (REmpty _) = return []
+ go [] [] (REmptyKinded _ _) = return []
go [] [] u@(TUnknown _ _)
| lax = return []
| otherwise = do unifyTypes u srcREmpty
@@ -776,15 +936,15 @@ checkProperties expr ps row lax = convert <$> go ps (toRowPair <$> ts') r' where
go [] [] Skolem{} | lax = return []
go [] ((p, _): _) _ | lax = return []
| otherwise = throwError . errorMessage $ PropertyIsMissing p
- go ((p,_):_) [] (REmpty _) = throwError . errorMessage $ AdditionalProperty $ Label p
+ go ((p,_):_) [] (REmptyKinded _ _) = throwError . errorMessage $ AdditionalProperty $ Label p
go ((p,v):ps') ts r =
case lookup (Label p) ts of
Nothing -> do
- v'@(TypedValue' _ _ ty) <- infer v
- rest <- freshType
+ (v', ty) <- inferWithinRecord v
+ rest <- freshTypeWithKind (kindRow kindType)
unifyTypes r (srcRCons (Label p) ty rest)
ps'' <- go ps' ts rest
- return $ (p, v') : ps''
+ return $ (p, TypedValue' True v' ty) : ps''
Just ty -> do
v' <- check v ty
ps'' <- go ps' (delete (Label p, ty) ts) r
@@ -814,7 +974,7 @@ checkFunctionApplication
-- ^ The argument expression
-> m (SourceType, Expr)
-- ^ The result type, and the elaborated term
-checkFunctionApplication fn fnTy arg = withErrorMessageHint (ErrorInApplication fn fnTy arg) $ do
+checkFunctionApplication fn fnTy arg = withErrorMessageHint' fn (ErrorInApplication fn fnTy arg) $ do
subst <- gets checkSubstitution
checkFunctionApplication' fn (substituteType subst fnTy) arg
@@ -829,8 +989,10 @@ checkFunctionApplication' fn (TypeApp _ (TypeApp _ tyFunction' argTy) retTy) arg
unifyTypes tyFunction' tyFunction
arg' <- tvToExpr <$> check arg argTy
return (retTy, App fn arg')
-checkFunctionApplication' fn (ForAll _ ident _ ty _) arg = do
- replaced <- replaceVarWithUnknown ident ty
+checkFunctionApplication' fn (ForAll _ _ ident mbK ty _) arg = do
+ u <- maybe (internalCompilerError "Unelaborated forall") freshTypeWithKind mbK
+ insertUnkName' u ident
+ let replaced = replaceTypeVars ident u ty
checkFunctionApplication fn replaced arg
checkFunctionApplication' fn (KindedType _ ty _) arg =
checkFunctionApplication fn ty arg
@@ -845,7 +1007,7 @@ checkFunctionApplication' fn u arg = do
TypedValue' _ arg' t <- infer arg
(arg'', t') <- instantiatePolyTypeWithUnknowns arg' t
return $ TypedValue' True arg'' t'
- ret <- freshType
+ ret <- freshTypeWithKind kindType
unifyTypes u (function ty ret)
return (ret, App fn (tvToExpr tv))
@@ -858,3 +1020,21 @@ ensureNoDuplicateProperties ps =
case ls \\ ordNub ls of
l : _ -> throwError . errorMessage $ DuplicateLabel (Label l) Nothing
_ -> return ()
+
+-- | Test if this is an internal value to be excluded from error hints
+isInternal :: Expr -> Bool
+isInternal = \case
+ PositionedValue _ _ v -> isInternal v
+ TypedValue _ v _ -> isInternal v
+ Constructor _ (Qualified _ name) -> isDictTypeName name
+ DerivedInstancePlaceholder{} -> True
+ _ -> False
+
+-- | Introduce a hint only if the given expression is not internal
+withErrorMessageHint'
+ :: (MonadState CheckState m, MonadError MultipleErrors m)
+ => Expr
+ -> ErrorMessageHint
+ -> m a
+ -> m a
+withErrorMessageHint' expr = if isInternal expr then const id else withErrorMessageHint
diff --git a/src/Language/PureScript/TypeChecker/Unify.hs b/src/Language/PureScript/TypeChecker/Unify.hs
index 65625f4b96..e4f1040ebf 100644
--- a/src/Language/PureScript/TypeChecker/Unify.hs
+++ b/src/Language/PureScript/TypeChecker/Unify.hs
@@ -1,57 +1,80 @@
-{-# LANGUAGE FlexibleInstances #-}
-
-- |
-- Functions and instances relating to unification
--
module Language.PureScript.TypeChecker.Unify
( freshType
+ , freshTypeWithKind
, solveType
, substituteType
, unknownsInType
, unifyTypes
, unifyRows
, alignRowsWith
- , replaceVarWithUnknown
, replaceTypeWildcards
, varIfUnknown
) where
-import Prelude.Compat
+import Prelude
-import Control.Arrow (first, second)
-import Control.Monad
+import Control.Monad (forM_, void)
import Control.Monad.Error.Class (MonadError(..))
-import Control.Monad.State.Class (MonadState(..), gets, modify)
+import Control.Monad.State.Class (MonadState(..), gets, modify, state)
import Control.Monad.Writer.Class (MonadWriter(..))
import Data.Foldable (traverse_)
-import Data.Function (on)
-import Data.List (sortBy, nubBy)
-import qualified Data.Map as M
-import Data.Ord (comparing)
-import Data.Text (Text)
-import qualified Data.Text as T
-
-import Language.PureScript.Crash
-import Language.PureScript.Errors
-import Language.PureScript.TypeChecker.Monad
-import Language.PureScript.TypeChecker.Skolems
-import Language.PureScript.Types
-
--- | Generate a fresh type variable
+import Data.Maybe (fromMaybe)
+import Data.Map qualified as M
+import Data.Text qualified as T
+
+import Language.PureScript.Crash (internalError)
+import Language.PureScript.Environment qualified as E
+import Language.PureScript.Errors (ErrorMessageHint(..), MultipleErrors, SimpleErrorMessage(..), SourceAnn, errorMessage, internalCompilerError, onErrorMessages, rethrow, warnWithPosition, withoutPosition)
+import Language.PureScript.TypeChecker.Kinds (elaborateKind, instantiateKind, unifyKinds')
+import Language.PureScript.TypeChecker.Monad (CheckState(..), Substitution(..), UnkLevel(..), Unknown, getLocalContext, guardWith, lookupUnkName, withErrorMessageHint)
+import Language.PureScript.TypeChecker.Skolems (newSkolemConstant, skolemize)
+import Language.PureScript.Types (Constraint(..), pattern REmptyKinded, RowListItem(..), SourceType, Type(..), WildcardData(..), alignRowsWith, everythingOnTypes, everywhereOnTypes, everywhereOnTypesM, getAnnForType, mkForAll, rowFromList, srcTUnknown)
+
+-- | Generate a fresh type variable with an unknown kind. Avoid this if at all possible.
freshType :: (MonadState CheckState m) => m SourceType
-freshType = do
- t <- gets checkNextType
- modify $ \st -> st { checkNextType = t + 1 }
- return $ srcTUnknown t
+freshType = state $ \st -> do
+ let
+ t = checkNextType st
+ st' = st { checkNextType = t + 2
+ , checkSubstitution =
+ (checkSubstitution st) { substUnsolved = M.insert t (UnkLevel (pure t), E.kindType)
+ . M.insert (t + 1) (UnkLevel (pure (t + 1)), srcTUnknown t)
+ . substUnsolved
+ $ checkSubstitution st
+ }
+ }
+ (srcTUnknown (t + 1), st')
+
+-- | Generate a fresh type variable with a known kind.
+freshTypeWithKind :: (MonadState CheckState m) => SourceType -> m SourceType
+freshTypeWithKind kind = state $ \st -> do
+ let
+ t = checkNextType st
+ st' = st { checkNextType = t + 1
+ , checkSubstitution =
+ (checkSubstitution st) { substUnsolved = M.insert t (UnkLevel (pure t), kind) (substUnsolved (checkSubstitution st)) }
+ }
+ (srcTUnknown t, st')
-- | Update the substitution to solve a type constraint
solveType :: (MonadError MultipleErrors m, MonadState CheckState m) => Int -> SourceType -> m ()
-solveType u t = do
+solveType u t = rethrow (onErrorMessages withoutPosition) $ do
+ -- We strip the position so that any errors get rethrown with the position of
+ -- the original unification constraint. Otherwise errors may arise from arbitrary
+ -- locations. We don't otherwise have the "correct" position on hand, since it
+ -- is maintained as part of the type-checker stack.
occursCheck u t
+ k1 <- elaborateKind t
+ subst <- gets checkSubstitution
+ k2 <- maybe (internalCompilerError ("No kind for unification variable ?" <> T.pack (show u))) (pure . substituteType subst . snd) . M.lookup u . substUnsolved $ subst
+ t' <- instantiateKind (t, k1) k2
modify $ \cs -> cs { checkSubstitution =
(checkSubstitution cs) { substType =
- M.insert u t $ substType $ checkSubstitution cs
+ M.insert u t' $ substType $ checkSubstitution cs
}
}
@@ -91,17 +114,17 @@ unifyTypes t1 t2 = do
unifyTypes' (TUnknown _ u1) (TUnknown _ u2) | u1 == u2 = return ()
unifyTypes' (TUnknown _ u) t = solveType u t
unifyTypes' t (TUnknown _ u) = solveType u t
- unifyTypes' (ForAll ann1 ident1 _ ty1 sc1) (ForAll ann2 ident2 _ ty2 sc2) =
+ unifyTypes' (ForAll ann1 _ ident1 mbK1 ty1 sc1) (ForAll ann2 _ ident2 mbK2 ty2 sc2) =
case (sc1, sc2) of
(Just sc1', Just sc2') -> do
sko <- newSkolemConstant
- let sk1 = skolemize ann1 ident1 sko sc1' ty1
- let sk2 = skolemize ann2 ident2 sko sc2' ty2
+ let sk1 = skolemize ann1 ident1 mbK1 sko sc1' ty1
+ let sk2 = skolemize ann2 ident2 mbK2 sko sc2' ty2
sk1 `unifyTypes` sk2
_ -> internalError "unifyTypes: unspecified skolem scope"
- unifyTypes' (ForAll ann ident _ ty1 (Just sc)) ty2 = do
+ unifyTypes' (ForAll ann _ ident mbK ty1 (Just sc)) ty2 = do
sko <- newSkolemConstant
- let sk = skolemize ann ident sko sc ty1
+ let sk = skolemize ann ident mbK sko sc ty1
sk `unifyTypes` ty2
unifyTypes' ForAll{} _ = internalError "unifyTypes: unspecified skolem scope"
unifyTypes' ty f@ForAll{} = f `unifyTypes` ty
@@ -109,16 +132,20 @@ unifyTypes t1 t2 = do
unifyTypes' ty1@(TypeConstructor _ c1) ty2@(TypeConstructor _ c2) =
guardWith (errorMessage (TypesDoNotUnify ty1 ty2)) (c1 == c2)
unifyTypes' (TypeLevelString _ s1) (TypeLevelString _ s2) | s1 == s2 = return ()
+ unifyTypes' (TypeLevelInt _ n1) (TypeLevelInt _ n2) | n1 == n2 = return ()
unifyTypes' (TypeApp _ t3 t4) (TypeApp _ t5 t6) = do
t3 `unifyTypes` t5
t4 `unifyTypes` t6
- unifyTypes' (Skolem _ _ s1 _) (Skolem _ _ s2 _) | s1 == s2 = return ()
+ unifyTypes' (KindApp _ t3 t4) (KindApp _ t5 t6) = do
+ t3 `unifyKinds'` t5
+ t4 `unifyTypes` t6
+ unifyTypes' (Skolem _ _ _ s1 _) (Skolem _ _ _ s2 _) | s1 == s2 = return ()
unifyTypes' (KindedType _ ty1 _) ty2 = ty1 `unifyTypes` ty2
unifyTypes' ty1 (KindedType _ ty2 _) = ty1 `unifyTypes` ty2
unifyTypes' r1@RCons{} r2 = unifyRows r1 r2
unifyTypes' r1 r2@RCons{} = unifyRows r1 r2
- unifyTypes' r1@REmpty{} r2 = unifyRows r1 r2
- unifyTypes' r1 r2@REmpty{} = unifyRows r1 r2
+ unifyTypes' r1@REmptyKinded{} r2 = unifyRows r1 r2
+ unifyTypes' r1 r2@REmptyKinded{} = unifyRows r1 r2
unifyTypes' (ConstrainedType _ c1 ty1) (ConstrainedType _ c2 ty2)
| constraintClass c1 == constraintClass c2 && constraintData c1 == constraintData c2 = do
traverse_ (uncurry unifyTypes) (constraintArgs c1 `zip` constraintArgs c2)
@@ -129,84 +156,68 @@ unifyTypes t1 t2 = do
unifyTypes' t3 t4 =
throwError . errorMessage $ TypesDoNotUnify t3 t4
--- | Align two rows of types, splitting them into three parts:
---
--- * Those types which appear in both rows
--- * Those which appear only on the left
--- * Those which appear only on the right
---
--- Note: importantly, we preserve the order of the types with a given label.
-alignRowsWith
- :: (Type a -> Type a -> r)
- -> Type a
- -> Type a
- -> ([r], (([RowListItem a], Type a), ([RowListItem a], Type a)))
-alignRowsWith f ty1 ty2 = go s1 s2 where
- (s1, tail1) = rowToSortedList ty1
- (s2, tail2) = rowToSortedList ty2
-
- go [] r = ([], (([], tail1), (r, tail2)))
- go r [] = ([], ((r, tail1), ([], tail2)))
- go lhs@(RowListItem a1 l1 t1 : r1) rhs@(RowListItem a2 l2 t2 : r2)
- | l1 < l2 = (second . first . first) (RowListItem a1 l1 t1 :) (go r1 rhs)
- | l2 < l1 = (second . second . first) (RowListItem a2 l2 t2 :) (go lhs r2)
- | otherwise = first (f t1 t2 :) (go r1 r2)
-
-- | Unify two rows, updating the current substitution
--
-- Common labels are identified and unified. Remaining labels and types are unified with a
-- trailing row unification variable, if appropriate.
unifyRows :: forall m. (MonadError MultipleErrors m, MonadState CheckState m) => SourceType -> SourceType -> m ()
unifyRows r1 r2 = sequence_ matches *> uncurry unifyTails rest where
- (matches, rest) = alignRowsWith unifyTypes r1 r2
+ unifyTypesWithLabel l t1 t2 = withErrorMessageHint (ErrorInRowLabel l) $ unifyTypes t1 t2
+
+ (matches, rest) = alignRowsWith unifyTypesWithLabel r1 r2
unifyTails :: ([RowListItem SourceAnn], SourceType) -> ([RowListItem SourceAnn], SourceType) -> m ()
unifyTails ([], TUnknown _ u) (sd, r) = solveType u (rowFromList (sd, r))
unifyTails (sd, r) ([], TUnknown _ u) = solveType u (rowFromList (sd, r))
- unifyTails ([], REmpty _) ([], REmpty _) = return ()
+ unifyTails ([], REmptyKinded _ _) ([], REmptyKinded _ _) = return ()
unifyTails ([], TypeVar _ v1) ([], TypeVar _ v2) | v1 == v2 = return ()
- unifyTails ([], Skolem _ s1 _ _) ([], Skolem _ s2 _ _) | s1 == s2 = return ()
- unifyTails (sd1, TUnknown _ u1) (sd2, TUnknown _ u2) = do
+ unifyTails ([], Skolem _ _ _ s1 _) ([], Skolem _ _ _ s2 _) | s1 == s2 = return ()
+ unifyTails (sd1, TUnknown a u1) (sd2, TUnknown _ u2) | u1 /= u2 = do
forM_ sd1 $ occursCheck u2 . rowListType
forM_ sd2 $ occursCheck u1 . rowListType
- rest' <- freshType
+ rest' <- freshTypeWithKind =<< elaborateKind (TUnknown a u1)
solveType u1 (rowFromList (sd2, rest'))
solveType u2 (rowFromList (sd1, rest'))
unifyTails _ _ =
throwError . errorMessage $ TypesDoNotUnify r1 r2
--- |
--- Replace a single type variable with a new unification variable
---
-replaceVarWithUnknown :: (MonadState CheckState m) => Text -> SourceType -> m SourceType
-replaceVarWithUnknown ident ty = do
- tu <- freshType
- return $ replaceTypeVars ident tu ty
-
-- |
-- Replace type wildcards with unknowns
--
replaceTypeWildcards :: (MonadWriter MultipleErrors m, MonadState CheckState m) => SourceType -> m SourceType
replaceTypeWildcards = everywhereOnTypesM replace
where
- replace (TypeWildcard ann name) = do
+ replace (TypeWildcard ann wdata) = do
t <- freshType
ctx <- getLocalContext
- let err = maybe (WildcardInferredType t ctx) (\n -> HoleInferredType n t ctx Nothing) name
- warnWithPosition (fst ann) $ tell $ errorMessage err
+ let err = case wdata of
+ HoleWildcard n -> Just $ HoleInferredType n t ctx Nothing
+ UnnamedWildcard -> Just $ WildcardInferredType t ctx
+ IgnoredWildcard -> Nothing
+ forM_ err $ warnWithPosition (fst ann) . tell . errorMessage
return t
replace other = return other
-- |
-- Replace outermost unsolved unification variables with named type variables
--
-varIfUnknown :: SourceType -> SourceType
-varIfUnknown ty =
- let unks = nubBy ((==) `on` snd) $ unknownsInType ty
- toName = T.cons 't' . T.pack . show
- addKind a = (a, Nothing)
- ty' = everywhereOnTypes typeToVar ty
- typeToVar :: SourceType -> SourceType
- typeToVar (TUnknown ann u) = TypeVar ann (toName u)
- typeToVar t = t
- in mkForAll (fmap (fmap addKind) . sortBy (comparing snd) . fmap (fmap toName) $ unks) ty'
+varIfUnknown :: forall m. (MonadState CheckState m) => [(Unknown, SourceType)] -> SourceType -> m SourceType
+varIfUnknown unks ty = do
+ bn' <- traverse toBinding unks
+ ty' <- go ty
+ pure $ mkForAll bn' ty'
+ where
+ toName :: Unknown -> m T.Text
+ toName u = (<> T.pack (show u)) . fromMaybe "t" <$> lookupUnkName u
+
+ toBinding :: (Unknown, SourceType) -> m (SourceAnn, (T.Text, Maybe SourceType))
+ toBinding (u, k) = do
+ u' <- toName u
+ k' <- go k
+ pure (getAnnForType ty, (u', Just k'))
+
+ go :: SourceType -> m SourceType
+ go = everywhereOnTypesM $ \case
+ (TUnknown ann u) ->
+ TypeVar ann <$> toName u
+ t -> pure t
diff --git a/src/Language/PureScript/TypeClassDictionaries.hs b/src/Language/PureScript/TypeClassDictionaries.hs
index 7f1ad25f09..593e8c1a8d 100644
--- a/src/Language/PureScript/TypeClassDictionaries.hs
+++ b/src/Language/PureScript/TypeClassDictionaries.hs
@@ -1,24 +1,22 @@
-{-# LANGUAGE DeriveFoldable #-}
-{-# LANGUAGE DeriveTraversable #-}
-{-# LANGUAGE DeriveGeneric #-}
module Language.PureScript.TypeClassDictionaries where
-import Prelude.Compat
+import Prelude
import GHC.Generics (Generic)
import Control.DeepSeq (NFData)
import Data.Text (Text, pack)
-import Language.PureScript.Names
-import Language.PureScript.Types
+import Language.PureScript.AST.Declarations.ChainId (ChainId)
+import Language.PureScript.Names (Ident, ProperName(..), ProperNameType(..), Qualified, disqualify)
+import Language.PureScript.Types (SourceConstraint, SourceType)
--- |
+--
-- Data representing a type class dictionary which is in scope
--
data TypeClassDictionaryInScope v
= TypeClassDictionaryInScope {
-- | The instance chain
- tcdChain :: [Qualified Ident]
+ tcdChain :: Maybe ChainId
-- | Index of the instance chain
, tcdIndex :: Integer
-- | The value with which the dictionary can be accessed at runtime
@@ -27,10 +25,17 @@ data TypeClassDictionaryInScope v
, tcdPath :: [(Qualified (ProperName 'ClassName), Integer)]
-- | The name of the type class to which this type class instance applies
, tcdClassName :: Qualified (ProperName 'ClassName)
+ -- | Quantification of type variables in the instance head and dependencies
+ , tcdForAll :: [(Text, SourceType)]
+ -- | The kinds to which this type class instance applies
+ , tcdInstanceKinds :: [SourceType]
-- | The types to which this type class instance applies
, tcdInstanceTypes :: [SourceType]
-- | Type class dependencies which must be satisfied to construct this dictionary
, tcdDependencies :: Maybe [SourceConstraint]
+ -- | If this instance was unnamed, the type to use when describing it in
+ -- error messages
+ , tcdDescription :: Maybe SourceType
}
deriving (Show, Functor, Foldable, Traversable, Generic)
diff --git a/src/Language/PureScript/Types.hs b/src/Language/PureScript/Types.hs
index ae22b11b65..ef00e21a07 100644
--- a/src/Language/PureScript/Types.hs
+++ b/src/Language/PureScript/Types.hs
@@ -1,41 +1,34 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE DeriveFoldable #-}
-{-# LANGUAGE DeriveTraversable #-}
-{-# LANGUAGE FlexibleInstances #-}
-
-- |
-- Data types for types
--
module Language.PureScript.Types where
-import Prelude.Compat
-import Protolude (ordNub)
+import Prelude
+import Protolude (ordNub, fromMaybe)
+import Codec.Serialise (Serialise)
import Control.Applicative ((<|>))
-import Control.Arrow (first)
+import Control.Arrow (first, second)
import Control.DeepSeq (NFData)
-import Control.Monad ((<=<))
-import Data.Aeson ((.:), (.=))
-import qualified Data.Aeson as A
-import qualified Data.Aeson.Types as A
-import Data.Foldable (fold)
-import Data.List (sortBy)
-import Data.Ord (comparing)
-import Data.Maybe (fromMaybe)
+import Control.Lens (Lens', (^.), set)
+import Control.Monad ((<=<), (>=>))
+import Data.Aeson ((.:), (.:?), (.!=), (.=))
+import Data.Aeson qualified as A
+import Data.Aeson.Types qualified as A
+import Data.Foldable (fold, foldl')
+import Data.IntSet qualified as IS
+import Data.List (sortOn)
+import Data.Maybe (isJust)
import Data.Text (Text)
-import qualified Data.Text as T
+import Data.Text qualified as T
import GHC.Generics (Generic)
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Kinds
-import Language.PureScript.Names
+import Language.PureScript.AST.SourcePos (pattern NullSourceAnn, SourceAnn, SourceSpan)
+import Language.PureScript.Constants.Prim qualified as C
+import Language.PureScript.Names (OpName, OpNameType(..), ProperName, ProperNameType(..), Qualified, coerceProperName)
import Language.PureScript.Label (Label)
import Language.PureScript.PSString (PSString)
-import Lens.Micro.Platform (Lens', (^.), set)
-
type SourceType = Type SourceAnn
type SourceConstraint = Constraint SourceAnn
@@ -46,6 +39,32 @@ newtype SkolemScope = SkolemScope { runSkolemScope :: Int }
deriving (Show, Eq, Ord, A.ToJSON, A.FromJSON, Generic)
instance NFData SkolemScope
+instance Serialise SkolemScope
+
+-- |
+-- Describes how a TypeWildcard should be presented to the user during
+-- type checking: holes (?foo) are always emitted as errors, whereas unnamed
+-- wildcards (_) default to warnings, but are ignored entirely if they are
+-- contained by a binding with a complete (wildcard-free) type signature.
+--
+data WildcardData = HoleWildcard Text | UnnamedWildcard | IgnoredWildcard
+ deriving (Show, Eq, Ord, Generic)
+
+instance NFData WildcardData
+instance Serialise WildcardData
+
+data TypeVarVisibility
+ = TypeVarVisible
+ | TypeVarInvisible
+ deriving (Show, Eq, Ord, Generic)
+
+instance NFData TypeVarVisibility
+instance Serialise TypeVarVisibility
+
+typeVarVisibilityPrefix :: TypeVarVisibility -> Text
+typeVarVisibilityPrefix = \case
+ TypeVarVisible -> "@"
+ TypeVarInvisible -> mempty
-- |
-- The type of types
@@ -57,8 +76,10 @@ data Type a
| TypeVar a Text
-- | A type-level string
| TypeLevelString a PSString
+ -- | A type-level natural
+ | TypeLevelInt a Integer
-- | A type wildcard, as would appear in a partial type synonym
- | TypeWildcard a (Maybe Text)
+ | TypeWildcard a WildcardData
-- | A type constructor
| TypeConstructor a (Qualified (ProperName 'TypeName))
-- | A type operator. This will be desugared into a type constructor during the
@@ -66,18 +87,20 @@ data Type a
| TypeOp a (Qualified (OpName 'TypeOpName))
-- | A type application
| TypeApp a (Type a) (Type a)
+ -- | Explicit kind application
+ | KindApp a (Type a) (Type a)
-- | Forall quantifier
- | ForAll a Text (Maybe (Kind a)) (Type a) (Maybe SkolemScope)
+ | ForAll a TypeVarVisibility Text (Maybe (Type a)) (Type a) (Maybe SkolemScope)
-- | A type with a set of type class constraints
| ConstrainedType a (Constraint a) (Type a)
-- | A skolem constant
- | Skolem a Text Int SkolemScope
+ | Skolem a Text (Maybe (Type a)) Int SkolemScope
-- | An empty row
| REmpty a
-- | A non-empty row
| RCons a Label (Type a) (Type a)
-- | A type with a kind annotation
- | KindedType a (Type a) (Kind a)
+ | KindedType a (Type a) (Type a)
-- | Binary operator application. During the rebracketing phase of desugaring,
-- this data constructor will be removed.
| BinaryNoParensType a (Type a) (Type a) (Type a)
@@ -90,6 +113,7 @@ data Type a
deriving (Show, Generic, Functor, Foldable, Traversable)
instance NFData a => NFData (Type a)
+instance Serialise a => Serialise (Type a)
srcTUnknown :: Int -> SourceType
srcTUnknown = TUnknown NullSourceAnn
@@ -100,41 +124,46 @@ srcTypeVar = TypeVar NullSourceAnn
srcTypeLevelString :: PSString -> SourceType
srcTypeLevelString = TypeLevelString NullSourceAnn
+srcTypeLevelInt :: Integer -> SourceType
+srcTypeLevelInt = TypeLevelInt NullSourceAnn
+
srcTypeWildcard :: SourceType
-srcTypeWildcard = TypeWildcard NullSourceAnn Nothing
+srcTypeWildcard = TypeWildcard NullSourceAnn UnnamedWildcard
srcTypeConstructor :: Qualified (ProperName 'TypeName) -> SourceType
srcTypeConstructor = TypeConstructor NullSourceAnn
-srcTypeOp :: Qualified (OpName 'TypeOpName) -> SourceType
-srcTypeOp = TypeOp NullSourceAnn
-
srcTypeApp :: SourceType -> SourceType -> SourceType
srcTypeApp = TypeApp NullSourceAnn
-srcForAll :: Text -> Maybe SourceKind -> SourceType -> Maybe SkolemScope -> SourceType
+srcKindApp :: SourceType -> SourceType -> SourceType
+srcKindApp = KindApp NullSourceAnn
+
+srcForAll :: TypeVarVisibility -> Text -> Maybe SourceType -> SourceType -> Maybe SkolemScope -> SourceType
srcForAll = ForAll NullSourceAnn
srcConstrainedType :: SourceConstraint -> SourceType -> SourceType
srcConstrainedType = ConstrainedType NullSourceAnn
-srcSkolem :: Text -> Int -> SkolemScope -> SourceType
-srcSkolem = Skolem NullSourceAnn
-
srcREmpty :: SourceType
srcREmpty = REmpty NullSourceAnn
srcRCons :: Label -> SourceType -> SourceType -> SourceType
srcRCons = RCons NullSourceAnn
-srcKindedType :: SourceType -> SourceKind -> SourceType
+srcKindedType :: SourceType -> SourceType -> SourceType
srcKindedType = KindedType NullSourceAnn
-srcBinaryNoParensType :: SourceType -> SourceType -> SourceType -> SourceType
-srcBinaryNoParensType = BinaryNoParensType NullSourceAnn
+pattern REmptyKinded :: forall a. a -> Maybe (Type a) -> Type a
+pattern REmptyKinded ann mbK <- (toREmptyKinded -> Just (ann, mbK))
-srcParensInType :: SourceType -> SourceType
-srcParensInType = ParensInType NullSourceAnn
+toREmptyKinded :: forall a. Type a -> Maybe (a, Maybe (Type a))
+toREmptyKinded (REmpty ann) = Just (ann, Nothing)
+toREmptyKinded (KindApp _ (REmpty ann) k) = Just (ann, Just k)
+toREmptyKinded _ = Nothing
+
+isREmpty :: forall a. Type a -> Bool
+isREmpty = isJust . toREmptyKinded
-- | Additional data relevant to type class constraints
data ConstraintData
@@ -147,6 +176,7 @@ data ConstraintData
deriving (Show, Eq, Ord, Generic)
instance NFData ConstraintData
+instance Serialise ConstraintData
-- | A typeclass constraint
data Constraint a = Constraint
@@ -154,6 +184,8 @@ data Constraint a = Constraint
-- ^ constraint annotation
, constraintClass :: Qualified (ProperName 'ClassName)
-- ^ constraint class name
+ , constraintKindArgs :: [Type a]
+ -- ^ kind arguments
, constraintArgs :: [Type a]
-- ^ type arguments
, constraintData :: Maybe ConstraintData
@@ -161,8 +193,9 @@ data Constraint a = Constraint
} deriving (Show, Generic, Functor, Foldable, Traversable)
instance NFData a => NFData (Constraint a)
+instance Serialise a => Serialise (Constraint a)
-srcConstraint :: Qualified (ProperName 'ClassName) -> [SourceType] -> Maybe ConstraintData -> SourceConstraint
+srcConstraint :: Qualified (ProperName 'ClassName) -> [SourceType] -> [SourceType] -> Maybe ConstraintData -> SourceConstraint
srcConstraint = Constraint NullSourceAnn
mapConstraintArgs :: ([Type a] -> [Type a]) -> Constraint a -> Constraint a
@@ -171,6 +204,18 @@ mapConstraintArgs f c = c { constraintArgs = f (constraintArgs c) }
overConstraintArgs :: Functor f => ([Type a] -> f [Type a]) -> Constraint a -> f (Constraint a)
overConstraintArgs f c = (\args -> c { constraintArgs = args }) <$> f (constraintArgs c)
+mapConstraintArgsAll :: ([Type a] -> [Type a]) -> Constraint a -> Constraint a
+mapConstraintArgsAll f c =
+ c { constraintKindArgs = f (constraintKindArgs c)
+ , constraintArgs = f (constraintArgs c)
+ }
+
+overConstraintArgsAll :: Applicative f => ([Type a] -> f [Type a]) -> Constraint a -> f (Constraint a)
+overConstraintArgsAll f c =
+ (\a b -> c { constraintKindArgs = a, constraintArgs = b })
+ <$> f (constraintKindArgs c)
+ <*> f (constraintArgs c)
+
constraintDataToJSON :: ConstraintData -> A.Value
constraintDataToJSON (PartialConstraintData bs trunc) =
A.object
@@ -178,14 +223,20 @@ constraintDataToJSON (PartialConstraintData bs trunc) =
]
constraintToJSON :: (a -> A.Value) -> Constraint a -> A.Value
-constraintToJSON annToJSON (Constraint {..}) =
+constraintToJSON annToJSON Constraint {..} =
A.object
[ "constraintAnn" .= annToJSON constraintAnn
, "constraintClass" .= constraintClass
+ , "constraintKindArgs" .= fmap (typeToJSON annToJSON) constraintKindArgs
, "constraintArgs" .= fmap (typeToJSON annToJSON) constraintArgs
, "constraintData" .= fmap constraintDataToJSON constraintData
]
+typeVarVisToJSON :: TypeVarVisibility -> A.Value
+typeVarVisToJSON = \case
+ TypeVarVisible -> A.toJSON ("TypeVarVisible" :: Text)
+ TypeVarInvisible -> A.toJSON ("TypeVarInvisible" :: Text)
+
typeToJSON :: forall a. (a -> A.Value) -> Type a -> A.Value
typeToJSON annToJSON ty =
case ty of
@@ -195,6 +246,8 @@ typeToJSON annToJSON ty =
variant "TypeVar" a b
TypeLevelString a b ->
variant "TypeLevelString" a b
+ TypeLevelInt a b ->
+ variant "TypeLevelInt" a b
TypeWildcard a b ->
variant "TypeWildcard" a b
TypeConstructor a b ->
@@ -203,20 +256,26 @@ typeToJSON annToJSON ty =
variant "TypeOp" a b
TypeApp a b c ->
variant "TypeApp" a (go b, go c)
- ForAll a b c d e ->
- case c of
- Nothing -> variant "ForAll" a (b, go d, e)
- Just k -> variant "ForAll" a (b, kindToJSON annToJSON k, go d, e)
+ KindApp a b c ->
+ variant "KindApp" a (go b, go c)
+ ForAll a b c d e f ->
+ variant "ForAll" a $ A.object
+ [ "visibility" .= b
+ , "identifier" .= c
+ , "kind" .= fmap go d
+ , "type" .= go e
+ , "skolem" .= f
+ ]
ConstrainedType a b c ->
variant "ConstrainedType" a (constraintToJSON annToJSON b, go c)
- Skolem a b c d ->
- variant "Skolem" a (b, c, d)
+ Skolem a b c d e ->
+ variant "Skolem" a (b, go <$> c, d, e)
REmpty a ->
nullary "REmpty" a
RCons a b c d ->
variant "RCons" a (b, go c, go d)
KindedType a b c ->
- variant "KindedType" a (go b, kindToJSON annToJSON c)
+ variant "KindedType" a (go b, go c)
BinaryNoParensType a b c d ->
variant "BinaryNoParensType" a (go b, go c, go d)
ParensInType a b ->
@@ -240,6 +299,12 @@ typeToJSON annToJSON ty =
, "annotation" .= annToJSON ann
]
+instance A.ToJSON WildcardData where
+ toJSON = \case
+ HoleWildcard name -> A.String name
+ UnnamedWildcard -> A.Null
+ IgnoredWildcard -> A.object [ "ignored" .= True ]
+
instance A.ToJSON a => A.ToJSON (Type a) where
toJSON = typeToJSON A.toJSON
@@ -249,6 +314,9 @@ instance A.ToJSON a => A.ToJSON (Constraint a) where
instance A.ToJSON ConstraintData where
toJSON = constraintDataToJSON
+instance A.ToJSON TypeVarVisibility where
+ toJSON = typeVarVisToJSON
+
constraintDataFromJSON :: A.Value -> A.Parser ConstraintData
constraintDataFromJSON = A.withObject "PartialConstraintData" $ \o -> do
(bs, trunc) <- o .: "contents"
@@ -258,10 +326,19 @@ constraintFromJSON :: forall a. A.Parser a -> (A.Value -> A.Parser a) -> A.Value
constraintFromJSON defaultAnn annFromJSON = A.withObject "Constraint" $ \o -> do
constraintAnn <- (o .: "constraintAnn" >>= annFromJSON) <|> defaultAnn
constraintClass <- o .: "constraintClass"
+ constraintKindArgs <- o .:? "constraintKindArgs" .!= [] >>= traverse (typeFromJSON defaultAnn annFromJSON)
constraintArgs <- o .: "constraintArgs" >>= traverse (typeFromJSON defaultAnn annFromJSON)
constraintData <- o .: "constraintData" >>= traverse constraintDataFromJSON
pure $ Constraint {..}
+typeVarVisFromJSON :: A.Value -> A.Parser TypeVarVisibility
+typeVarVisFromJSON v = do
+ v' <- A.parseJSON v
+ case v' of
+ "TypeVarVisible" -> pure TypeVarVisible
+ "TypeVarInvisible" -> pure TypeVarInvisible
+ _ -> fail $ "Unrecognized TypeVarVisibility: " <> v'
+
typeFromJSON :: forall a. A.Parser a -> (A.Value -> A.Parser a) -> A.Value -> A.Parser (Type a)
typeFromJSON defaultAnn annFromJSON = A.withObject "Type" $ \o -> do
tag <- o .: "tag"
@@ -276,8 +353,10 @@ typeFromJSON defaultAnn annFromJSON = A.withObject "Type" $ \o -> do
TypeVar a <$> contents
"TypeLevelString" ->
TypeLevelString a <$> contents
+ "TypeLevelInt" ->
+ TypeLevelInt a <$> contents
"TypeWildcard" -> do
- b <- contents <|> pure Nothing
+ b <- contents <|> pure UnnamedWildcard
pure $ TypeWildcard a b
"TypeConstructor" ->
TypeConstructor a <$> contents
@@ -286,21 +365,35 @@ typeFromJSON defaultAnn annFromJSON = A.withObject "Type" $ \o -> do
"TypeApp" -> do
(b, c) <- contents
TypeApp a <$> go b <*> go c
+ "KindApp" -> do
+ (b, c) <- contents
+ KindApp a <$> go b <*> go c
"ForAll" -> do
let
+ asObject = do
+ f <- contents
+ v <- f .: "visibility"
+ i <- f .: "identifier"
+ k <- f .:? "kind"
+ t <- f .: "type"
+ s <- f .: "skolem"
+ ForAll a v i <$> traverse go k <*> go t <*> pure s
+
withoutMbKind = do
(b, c, d) <- contents
- ForAll a b Nothing <$> go c <*> pure d
+ ForAll a TypeVarInvisible b Nothing <$> go c <*> pure d
+
withMbKind = do
(b, c, d, e) <- contents
- ForAll a b <$> (Just <$> kindFromJSON defaultAnn annFromJSON c) <*> go d <*> pure e
- withMbKind <|> withoutMbKind
+ ForAll a TypeVarInvisible b <$> (Just <$> go c) <*> go d <*> pure e
+ asObject <|> withMbKind <|> withoutMbKind
"ConstrainedType" -> do
(b, c) <- contents
ConstrainedType a <$> constraintFromJSON defaultAnn annFromJSON b <*> go c
"Skolem" -> do
- (b, c, d) <- contents
- pure $ Skolem a b c d
+ (b, c, d, e) <- contents
+ c' <- traverse go c
+ pure $ Skolem a b c' d e
"REmpty" ->
pure $ REmpty a
"RCons" -> do
@@ -308,20 +401,30 @@ typeFromJSON defaultAnn annFromJSON = A.withObject "Type" $ \o -> do
RCons a b <$> go c <*> go d
"KindedType" -> do
(b, c) <- contents
- KindedType a <$> go b <*> kindFromJSON defaultAnn annFromJSON c
+ KindedType a <$> go b <*> go c
"BinaryNoParensType" -> do
(b, c, d) <- contents
BinaryNoParensType a <$> go b <*> go c <*> go d
"ParensInType" -> do
b <- contents
ParensInType a <$> go b
+ -- Backwards compatibility for kinds
+ "KUnknown" ->
+ TUnknown a <$> contents
+ "Row" ->
+ TypeApp a (TypeConstructor a C.Row) <$> (go =<< contents)
+ "FunKind" -> do
+ (b, c) <- contents
+ TypeApp a . TypeApp a (TypeConstructor a C.Function) <$> go b <*> go c
+ "NamedKind" ->
+ TypeConstructor a <$> contents
other ->
fail $ "Unrecognised tag: " ++ other
where
go :: A.Value -> A.Parser (Type a)
go = typeFromJSON defaultAnn annFromJSON
--- These overlapping instances exist to preserve compatability for common
+-- These overlapping instances exist to preserve compatibility for common
-- instances which have a sensible default for missing annotations.
instance {-# OVERLAPPING #-} A.FromJSON (Type SourceAnn) where
parseJSON = typeFromJSON (pure NullSourceAnn) A.parseJSON
@@ -344,6 +447,16 @@ instance {-# OVERLAPPING #-} A.FromJSON a => A.FromJSON (Constraint a) where
instance A.FromJSON ConstraintData where
parseJSON = constraintDataFromJSON
+instance A.FromJSON WildcardData where
+ parseJSON = \case
+ A.String name -> pure $ HoleWildcard name
+ A.Object _ -> pure IgnoredWildcard
+ A.Null -> pure UnnamedWildcard
+ _ -> fail "Unrecognized WildcardData"
+
+instance A.FromJSON TypeVarVisibility where
+ parseJSON = typeVarVisFromJSON
+
data RowListItem a = RowListItem
{ rowListAnn :: a
, rowListLabel :: Label
@@ -362,12 +475,36 @@ rowToList = go where
-- | Convert a row to a list of pairs of labels and types, sorted by the labels.
rowToSortedList :: Type a -> ([RowListItem a], Type a)
-rowToSortedList = first (sortBy (comparing rowListLabel)) . rowToList
+rowToSortedList = first (sortOn rowListLabel) . rowToList
-- | Convert a list of labels and types to a row
rowFromList :: ([RowListItem a], Type a) -> Type a
rowFromList (xs, r) = foldr (\(RowListItem ann name ty) -> RCons ann name ty) r xs
+-- | Align two rows of types, splitting them into three parts:
+--
+-- * Those types which appear in both rows
+-- * Those which appear only on the left
+-- * Those which appear only on the right
+--
+-- Note: importantly, we preserve the order of the types with a given label.
+alignRowsWith
+ :: (Label -> Type a -> Type a -> r)
+ -> Type a
+ -> Type a
+ -> ([r], (([RowListItem a], Type a), ([RowListItem a], Type a)))
+alignRowsWith f ty1 ty2 = go s1 s2 where
+ (s1, tail1) = rowToSortedList ty1
+ (s2, tail2) = rowToSortedList ty2
+
+ go [] r = ([], (([], tail1), (r, tail2)))
+ go r [] = ([], ((r, tail1), ([], tail2)))
+ go lhs@(RowListItem a1 l1 t1 : r1) rhs@(RowListItem a2 l2 t2 : r2) =
+ case compare l1 l2 of
+ LT -> (second . first . first) (RowListItem a1 l1 t1 :) (go r1 rhs)
+ GT -> (second . second . first) (RowListItem a2 l2 t2 :) (go lhs r2)
+ EQ -> first (f l1 t1 t2 :) (go r1 r2)
+
-- | Check whether a type is a monotype
isMonoType :: Type a -> Bool
isMonoType ForAll{} = False
@@ -376,8 +513,8 @@ isMonoType (KindedType _ t _) = isMonoType t
isMonoType _ = True
-- | Universally quantify a type
-mkForAll :: [(a, (Text, Maybe (Kind a)))] -> Type a -> Type a
-mkForAll args ty = foldl (\t (ann, (arg, mbK)) -> ForAll ann arg mbK t Nothing) ty args
+mkForAll :: [(a, (Text, Maybe (Type a)))] -> Type a -> Type a
+mkForAll args ty = foldr (\(ann, (arg, mbK)) t -> ForAll ann TypeVarInvisible arg mbK t Nothing) ty args
-- | Replace a type variable, taking into account variable shadowing
replaceTypeVars :: Text -> Type a -> Type a -> Type a
@@ -389,27 +526,42 @@ replaceAllTypeVars = go [] where
go :: [Text] -> [(Text, Type a)] -> Type a -> Type a
go _ m (TypeVar ann v) = fromMaybe (TypeVar ann v) (v `lookup` m)
go bs m (TypeApp ann t1 t2) = TypeApp ann (go bs m t1) (go bs m t2)
- go bs m f@(ForAll ann v mbK t sco)
- | v `elem` keys = go bs (filter ((/= v) . fst) m) f
+ go bs m (KindApp ann t1 t2) = KindApp ann (go bs m t1) (go bs m t2)
+ go bs m (ForAll ann vis v mbK t sco)
+ | v `elem` keys = go bs (filter ((/= v) . fst) m) $ ForAll ann vis v mbK' t sco
| v `elem` usedVars =
- let v' = genName v (keys ++ bs ++ usedVars)
+ let v' = genPureName v (keys ++ bs ++ usedVars)
t' = go bs [(v, TypeVar ann v')] t
- in ForAll ann v' mbK (go (v' : bs) m t') sco
- | otherwise = ForAll ann v mbK (go (v : bs) m t) sco
+ in ForAll ann vis v' mbK' (go (v' : bs) m t') sco
+ | otherwise = ForAll ann vis v mbK' (go (v : bs) m t) sco
where
+ mbK' = go bs m <$> mbK
keys = map fst m
usedVars = concatMap (usedTypeVariables . snd) m
- go bs m (ConstrainedType ann c t) = ConstrainedType ann (mapConstraintArgs (map (go bs m)) c) (go bs m t)
+ go bs m (ConstrainedType ann c t) = ConstrainedType ann (mapConstraintArgsAll (map (go bs m)) c) (go bs m t)
go bs m (RCons ann name' t r) = RCons ann name' (go bs m t) (go bs m r)
- go bs m (KindedType ann t k) = KindedType ann (go bs m t) k
+ go bs m (KindedType ann t k) = KindedType ann (go bs m t) (go bs m k)
go bs m (BinaryNoParensType ann t1 t2 t3) = BinaryNoParensType ann (go bs m t1) (go bs m t2) (go bs m t3)
go bs m (ParensInType ann t) = ParensInType ann (go bs m t)
go _ _ ty = ty
- genName orig inUse = try' 0 where
- try' :: Integer -> Text
- try' n | (orig <> T.pack (show n)) `elem` inUse = try' (n + 1)
- | otherwise = orig <> T.pack (show n)
+genPureName :: Text -> [Text] -> Text
+genPureName orig inUse = try' 0
+ where
+ try' :: Integer -> Text
+ try' n | (orig <> T.pack (show n)) `elem` inUse = try' (n + 1)
+ | otherwise = orig <> T.pack (show n)
+
+-- | Add visible type abstractions to top-level foralls.
+addVisibility :: [(Text, TypeVarVisibility)] -> Type a -> Type a
+addVisibility v = go where
+ go (ForAll ann vis arg mbK ty sco) = case lookup arg v of
+ Just vis' ->
+ ForAll ann vis' arg mbK (go ty) sco
+ Nothing ->
+ ForAll ann vis arg mbK (go ty) sco
+ go (ParensInType ann ty) = ParensInType ann (go ty)
+ go ty = ty
-- | Collect all type variables appearing in a type
usedTypeVariables :: Type a -> [Text]
@@ -419,35 +571,52 @@ usedTypeVariables = ordNub . everythingOnTypes (++) go where
-- | Collect all free type variables appearing in a type
freeTypeVariables :: Type a -> [Text]
-freeTypeVariables = ordNub . go [] where
- go :: [Text] -> Type a -> [Text]
- go bound (TypeVar _ v) | v `notElem` bound = [v]
- go bound (TypeApp _ t1 t2) = go bound t1 ++ go bound t2
- go bound (ForAll _ v _ t _) = go (v : bound) t
- go bound (ConstrainedType _ c t) = concatMap (go bound) (constraintArgs c) ++ go bound t
- go bound (RCons _ _ t r) = go bound t ++ go bound r
- go bound (KindedType _ t _) = go bound t
- go bound (BinaryNoParensType _ t1 t2 t3) = go bound t1 ++ go bound t2 ++ go bound t3
- go bound (ParensInType _ t) = go bound t
- go _ _ = []
+freeTypeVariables = ordNub . fmap snd . sortOn fst . go 0 [] where
+ -- Tracks kind levels so that variables appearing in kind annotations are listed first.
+ go :: Int -> [Text] -> Type a -> [(Int, Text)]
+ go lvl bound (TypeVar _ v) | v `notElem` bound = [(lvl, v)]
+ go lvl bound (TypeApp _ t1 t2) = go lvl bound t1 ++ go lvl bound t2
+ go lvl bound (KindApp _ t1 t2) = go lvl bound t1 ++ go (lvl - 1) bound t2
+ go lvl bound (ForAll _ _ v mbK t _) = foldMap (go (lvl - 1) bound) mbK ++ go lvl (v : bound) t
+ go lvl bound (ConstrainedType _ c t) = foldMap (go (lvl - 1) bound) (constraintKindArgs c) ++ foldMap (go lvl bound) (constraintArgs c) ++ go lvl bound t
+ go lvl bound (RCons _ _ t r) = go lvl bound t ++ go lvl bound r
+ go lvl bound (KindedType _ t k) = go lvl bound t ++ go (lvl - 1) bound k
+ go lvl bound (BinaryNoParensType _ t1 t2 t3) = go lvl bound t1 ++ go lvl bound t2 ++ go lvl bound t3
+ go lvl bound (ParensInType _ t) = go lvl bound t
+ go _ _ _ = []
+
+-- | Collect a complete set of kind-annotated quantifiers at the front of a type.
+completeBinderList :: Type a -> Maybe ([(a, (Text, Type a))], Type a)
+completeBinderList = go []
+ where
+ go acc = \case
+ ForAll _ _ _ Nothing _ _ -> Nothing
+ ForAll ann _ var (Just k) ty _ -> go ((ann, (var, k)) : acc) ty
+ ty -> Just (reverse acc, ty)
-- | Universally quantify over all type variables appearing free in a type
quantify :: Type a -> Type a
-quantify ty = foldr (\arg t -> ForAll (getAnnForType ty) arg Nothing t Nothing) ty $ freeTypeVariables ty
+quantify ty = foldr (\arg t -> ForAll (getAnnForType ty) TypeVarInvisible arg Nothing t Nothing) ty $ freeTypeVariables ty
-- | Move all universal quantifiers to the front of a type
-moveQuantifiersToFront :: Type a -> Type a
-moveQuantifiersToFront = go [] [] where
- go qs cs (ForAll ann q mbK ty sco) = go ((ann, q, sco, mbK) : qs) cs ty
- go qs cs (ConstrainedType ann c ty) = go qs ((ann, c) : cs) ty
- go qs cs ty = foldl (\ty' (ann, q, sco, mbK) -> ForAll ann q mbK ty' sco) (foldl (\ty' (ann, c) -> ConstrainedType ann c ty') ty cs) qs
-
--- | Check if a type contains wildcards
-containsWildcards :: Type a -> Bool
-containsWildcards = everythingOnTypes (||) go where
- go :: Type a -> Bool
- go TypeWildcard{} = True
- go _ = False
+moveQuantifiersToFront :: a -> Type a -> Type a
+moveQuantifiersToFront syntheticAnn = go [] []
+ where
+ go qs cs = \case
+ ForAll ann vis q mbK ty sco -> do
+ let
+ cArgs :: [Text] = cs >>= constraintArgs . snd >>= freeTypeVariables
+ (q'', ty')
+ | q `elem` cArgs = do
+ let q' = genPureName q $ cArgs <> freeTypeVariables ty
+ (q', replaceTypeVars q (TypeVar syntheticAnn q') ty)
+ | otherwise =
+ (q, ty)
+ go ((ann, q'', sco, mbK, vis) : qs) cs ty'
+ ConstrainedType ann c ty ->
+ go qs ((ann, c) : cs) ty
+ ty ->
+ foldl (\ty' (ann, q, sco, mbK, vis) -> ForAll ann vis q mbK ty' sco) (foldl (\ty' (ann, c) -> ConstrainedType ann c ty') ty cs) qs
-- | Check if a type contains `forall`
containsForAll :: Type a -> Bool
@@ -456,35 +625,94 @@ containsForAll = everythingOnTypes (||) go where
go ForAll{} = True
go _ = False
+unknowns :: Type a -> IS.IntSet
+unknowns = everythingOnTypes (<>) go where
+ go :: Type a -> IS.IntSet
+ go (TUnknown _ u) = IS.singleton u
+ go _ = mempty
+
+-- | Check if a type contains unknowns in a position that is relevant to
+-- constraint solving. (Kinds are not.)
+containsUnknowns :: Type a -> Bool
+containsUnknowns = everythingOnTypes (||) go . eraseKindApps where
+ go :: Type a -> Bool
+ go TUnknown{} = True
+ go _ = False
+
+eraseKindApps :: Type a -> Type a
+eraseKindApps = everywhereOnTypes $ \case
+ KindApp _ ty _ -> ty
+ ConstrainedType ann con ty ->
+ ConstrainedType ann (con { constraintKindArgs = [] }) ty
+ Skolem ann name _ i sc ->
+ Skolem ann name Nothing i sc
+ other -> other
+
+eraseForAllKindAnnotations :: Type a -> Type a
+eraseForAllKindAnnotations = removeAmbiguousVars . removeForAllKinds
+ where
+ removeForAllKinds = everywhereOnTypes $ \case
+ ForAll ann vis arg _ ty sco ->
+ ForAll ann vis arg Nothing ty sco
+ other -> other
+
+ removeAmbiguousVars = everywhereOnTypes $ \case
+ fa@(ForAll _ _ arg _ ty _)
+ | arg `elem` freeTypeVariables ty -> fa
+ | otherwise -> ty
+ other -> other
+
+unapplyTypes :: Type a -> (Type a, [Type a], [Type a])
+unapplyTypes = goTypes []
+ where
+ goTypes acc (TypeApp _ a b) = goTypes (b : acc) a
+ goTypes acc a = let (ty, kinds) = goKinds [] a in (ty, kinds, acc)
+
+ goKinds acc (KindApp _ a b) = goKinds (b : acc) a
+ goKinds acc a = (a, acc)
+
+unapplyConstraints :: Type a -> ([Constraint a], Type a)
+unapplyConstraints = go []
+ where
+ go acc (ConstrainedType _ con ty) = go (con : acc) ty
+ go acc ty = (reverse acc, ty)
+
+-- | Construct the type of an instance declaration from its parts. Used in
+-- error messages describing unnamed instances.
+srcInstanceType
+ :: SourceSpan
+ -> [(Text, SourceType)]
+ -> Qualified (ProperName 'ClassName)
+ -> [SourceType]
+ -> SourceType
+srcInstanceType ss vars className tys
+ = setAnnForType (ss, [])
+ . flip (foldr $ \(tv, k) ty -> srcForAll TypeVarInvisible tv (Just k) ty Nothing) vars
+ . flip (foldl' srcTypeApp) tys
+ $ srcTypeConstructor $ coerceProperName <$> className
+
everywhereOnTypes :: (Type a -> Type a) -> Type a -> Type a
everywhereOnTypes f = go where
go (TypeApp ann t1 t2) = f (TypeApp ann (go t1) (go t2))
- go (ForAll ann arg mbK ty sco) = f (ForAll ann arg mbK (go ty) sco)
- go (ConstrainedType ann c ty) = f (ConstrainedType ann (mapConstraintArgs (map go) c) (go ty))
+ go (KindApp ann t1 t2) = f (KindApp ann (go t1) (go t2))
+ go (ForAll ann vis arg mbK ty sco) = f (ForAll ann vis arg (go <$> mbK) (go ty) sco)
+ go (ConstrainedType ann c ty) = f (ConstrainedType ann (mapConstraintArgsAll (map go) c) (go ty))
+ go (Skolem ann name mbK i sc) = f (Skolem ann name (go <$> mbK) i sc)
go (RCons ann name ty rest) = f (RCons ann name (go ty) (go rest))
- go (KindedType ann ty k) = f (KindedType ann (go ty) k)
+ go (KindedType ann ty k) = f (KindedType ann (go ty) (go k))
go (BinaryNoParensType ann t1 t2 t3) = f (BinaryNoParensType ann (go t1) (go t2) (go t3))
go (ParensInType ann t) = f (ParensInType ann (go t))
go other = f other
-everywhereOnTypesTopDown :: (Type a -> Type a) -> Type a -> Type a
-everywhereOnTypesTopDown f = go . f where
- go (TypeApp ann t1 t2) = TypeApp ann (go (f t1)) (go (f t2))
- go (ForAll ann arg mbK ty sco) = ForAll ann arg mbK (go (f ty)) sco
- go (ConstrainedType ann c ty) = ConstrainedType ann (mapConstraintArgs (map (go . f)) c) (go (f ty))
- go (RCons ann name ty rest) = RCons ann name (go (f ty)) (go (f rest))
- go (KindedType ann ty k) = KindedType ann (go (f ty)) k
- go (BinaryNoParensType ann t1 t2 t3) = BinaryNoParensType ann (go (f t1)) (go (f t2)) (go (f t3))
- go (ParensInType ann t) = ParensInType ann (go (f t))
- go other = f other
-
everywhereOnTypesM :: Monad m => (Type a -> m (Type a)) -> Type a -> m (Type a)
everywhereOnTypesM f = go where
go (TypeApp ann t1 t2) = (TypeApp ann <$> go t1 <*> go t2) >>= f
- go (ForAll ann arg mbK ty sco) = (ForAll ann arg mbK <$> go ty <*> pure sco) >>= f
- go (ConstrainedType ann c ty) = (ConstrainedType ann <$> overConstraintArgs (mapM go) c <*> go ty) >>= f
+ go (KindApp ann t1 t2) = (KindApp ann <$> go t1 <*> go t2) >>= f
+ go (ForAll ann vis arg mbK ty sco) = (ForAll ann vis arg <$> traverse go mbK <*> go ty <*> pure sco) >>= f
+ go (ConstrainedType ann c ty) = (ConstrainedType ann <$> overConstraintArgsAll (mapM go) c <*> go ty) >>= f
+ go (Skolem ann name mbK i sc) = (Skolem ann name <$> traverse go mbK <*> pure i <*> pure sc) >>= f
go (RCons ann name ty rest) = (RCons ann name <$> go ty <*> go rest) >>= f
- go (KindedType ann ty k) = (KindedType ann <$> go ty <*> pure k) >>= f
+ go (KindedType ann ty k) = (KindedType ann <$> go ty <*> go k) >>= f
go (BinaryNoParensType ann t1 t2 t3) = (BinaryNoParensType ann <$> go t1 <*> go t2 <*> go t3) >>= f
go (ParensInType ann t) = (ParensInType ann <$> go t) >>= f
go other = f other
@@ -492,21 +720,26 @@ everywhereOnTypesM f = go where
everywhereOnTypesTopDownM :: Monad m => (Type a -> m (Type a)) -> Type a -> m (Type a)
everywhereOnTypesTopDownM f = go <=< f where
go (TypeApp ann t1 t2) = TypeApp ann <$> (f t1 >>= go) <*> (f t2 >>= go)
- go (ForAll ann arg mbK ty sco) = ForAll ann arg mbK <$> (f ty >>= go) <*> pure sco
- go (ConstrainedType ann c ty) = ConstrainedType ann <$> overConstraintArgs (mapM (go <=< f)) c <*> (f ty >>= go)
+ go (KindApp ann t1 t2) = KindApp ann <$> (f t1 >>= go) <*> (f t2 >>= go)
+ go (ForAll ann vis arg mbK ty sco) = ForAll ann vis arg <$> traverse (f >=> go) mbK <*> (f ty >>= go) <*> pure sco
+ go (ConstrainedType ann c ty) = ConstrainedType ann <$> overConstraintArgsAll (mapM (go <=< f)) c <*> (f ty >>= go)
+ go (Skolem ann name mbK i sc) = Skolem ann name <$> traverse (f >=> go) mbK <*> pure i <*> pure sc
go (RCons ann name ty rest) = RCons ann name <$> (f ty >>= go) <*> (f rest >>= go)
- go (KindedType ann ty k) = KindedType ann <$> (f ty >>= go) <*> pure k
+ go (KindedType ann ty k) = KindedType ann <$> (f ty >>= go) <*> (f k >>= go)
go (BinaryNoParensType ann t1 t2 t3) = BinaryNoParensType ann <$> (f t1 >>= go) <*> (f t2 >>= go) <*> (f t3 >>= go)
go (ParensInType ann t) = ParensInType ann <$> (f t >>= go)
- go other = f other
+ go other = pure other
everythingOnTypes :: (r -> r -> r) -> (Type a -> r) -> Type a -> r
everythingOnTypes (<+>) f = go where
go t@(TypeApp _ t1 t2) = f t <+> go t1 <+> go t2
- go t@(ForAll _ _ _ ty _) = f t <+> go ty
- go t@(ConstrainedType _ c ty) = foldl (<+>) (f t) (map go (constraintArgs c)) <+> go ty
+ go t@(KindApp _ t1 t2) = f t <+> go t1 <+> go t2
+ go t@(ForAll _ _ _ (Just k) ty _) = f t <+> go k <+> go ty
+ go t@(ForAll _ _ _ _ ty _) = f t <+> go ty
+ go t@(ConstrainedType _ c ty) = foldl (<+>) (f t) (map go (constraintKindArgs c) ++ map go (constraintArgs c)) <+> go ty
+ go t@(Skolem _ _ (Just k) _ _) = f t <+> go k
go t@(RCons _ _ ty rest) = f t <+> go ty <+> go rest
- go t@(KindedType _ ty _) = f t <+> go ty
+ go t@(KindedType _ ty k) = f t <+> go ty <+> go k
go t@(BinaryNoParensType _ t1 t2 t3) = f t <+> go t1 <+> go t2 <+> go t3
go t@(ParensInType _ t1) = f t <+> go t1
go other = f other
@@ -515,10 +748,13 @@ everythingWithContextOnTypes :: s -> r -> (r -> r -> r) -> (s -> Type a -> (s, r
everythingWithContextOnTypes s0 r0 (<+>) f = go' s0 where
go' s t = let (s', r) = f s t in r <+> go s' t
go s (TypeApp _ t1 t2) = go' s t1 <+> go' s t2
- go s (ForAll _ _ _ ty _) = go' s ty
- go s (ConstrainedType _ c ty) = foldl (<+>) r0 (map (go' s) (constraintArgs c)) <+> go' s ty
+ go s (KindApp _ t1 t2) = go' s t1 <+> go' s t2
+ go s (ForAll _ _ _ (Just k) ty _) = go' s k <+> go' s ty
+ go s (ForAll _ _ _ _ ty _) = go' s ty
+ go s (ConstrainedType _ c ty) = foldl (<+>) r0 (map (go' s) (constraintKindArgs c) ++ map (go' s) (constraintArgs c)) <+> go' s ty
+ go s (Skolem _ _ (Just k) _ _) = go' s k
go s (RCons _ _ ty rest) = go' s ty <+> go' s rest
- go s (KindedType _ ty _) = go' s ty
+ go s (KindedType _ ty k) = go' s ty <+> go' s k
go s (BinaryNoParensType _ t1 t2 t3) = go' s t1 <+> go' s t2 <+> go' s t3
go s (ParensInType _ t1) = go' s t1
go _ _ = r0
@@ -527,13 +763,15 @@ annForType :: Lens' (Type a) a
annForType k (TUnknown a b) = (\z -> TUnknown z b) <$> k a
annForType k (TypeVar a b) = (\z -> TypeVar z b) <$> k a
annForType k (TypeLevelString a b) = (\z -> TypeLevelString z b) <$> k a
+annForType k (TypeLevelInt a b) = (\z -> TypeLevelInt z b) <$> k a
annForType k (TypeWildcard a b) = (\z -> TypeWildcard z b) <$> k a
annForType k (TypeConstructor a b) = (\z -> TypeConstructor z b) <$> k a
annForType k (TypeOp a b) = (\z -> TypeOp z b) <$> k a
annForType k (TypeApp a b c) = (\z -> TypeApp z b c) <$> k a
-annForType k (ForAll a b c d e) = (\z -> ForAll z b c d e) <$> k a
+annForType k (KindApp a b c) = (\z -> KindApp z b c) <$> k a
+annForType k (ForAll a b c d e f) = (\z -> ForAll z b c d e f) <$> k a
annForType k (ConstrainedType a b c) = (\z -> ConstrainedType z b c) <$> k a
-annForType k (Skolem a b c d) = (\z -> Skolem z b c d) <$> k a
+annForType k (Skolem a b c d e) = (\z -> Skolem z b c d e) <$> k a
annForType k (REmpty a) = REmpty <$> k a
annForType k (RCons a b c d) = (\z -> RCons z b c d) <$> k a
annForType k (KindedType a b c) = (\z -> KindedType z b c) <$> k a
@@ -556,78 +794,72 @@ eqType :: Type a -> Type b -> Bool
eqType (TUnknown _ a) (TUnknown _ a') = a == a'
eqType (TypeVar _ a) (TypeVar _ a') = a == a'
eqType (TypeLevelString _ a) (TypeLevelString _ a') = a == a'
+eqType (TypeLevelInt _ a) (TypeLevelInt _ a') = a == a'
eqType (TypeWildcard _ a) (TypeWildcard _ a') = a == a'
eqType (TypeConstructor _ a) (TypeConstructor _ a') = a == a'
eqType (TypeOp _ a) (TypeOp _ a') = a == a'
eqType (TypeApp _ a b) (TypeApp _ a' b') = eqType a a' && eqType b b'
-eqType (ForAll _ a b c d) (ForAll _ a' b' c' d') = a == a' && eqMaybeKind b b' && eqType c c' && d == d'
+eqType (KindApp _ a b) (KindApp _ a' b') = eqType a a' && eqType b b'
+eqType (ForAll _ _ a b c d) (ForAll _ _ a' b' c' d') = a == a' && eqMaybeType b b' && eqType c c' && d == d'
eqType (ConstrainedType _ a b) (ConstrainedType _ a' b') = eqConstraint a a' && eqType b b'
-eqType (Skolem _ a b c) (Skolem _ a' b' c') = a == a' && b == b' && c == c'
+eqType (Skolem _ a b c d) (Skolem _ a' b' c' d') = a == a' && eqMaybeType b b' && c == c' && d == d'
eqType (REmpty _) (REmpty _) = True
eqType (RCons _ a b c) (RCons _ a' b' c') = a == a' && eqType b b' && eqType c c'
-eqType (KindedType _ a b) (KindedType _ a' b') = eqType a a' && eqKind b b'
+eqType (KindedType _ a b) (KindedType _ a' b') = eqType a a' && eqType b b'
eqType (BinaryNoParensType _ a b c) (BinaryNoParensType _ a' b' c') = eqType a a' && eqType b b' && eqType c c'
eqType (ParensInType _ a) (ParensInType _ a') = eqType a a'
eqType _ _ = False
+eqMaybeType :: Maybe (Type a) -> Maybe (Type b) -> Bool
+eqMaybeType (Just a) (Just b) = eqType a b
+eqMaybeType Nothing Nothing = True
+eqMaybeType _ _ = False
+
compareType :: Type a -> Type b -> Ordering
compareType (TUnknown _ a) (TUnknown _ a') = compare a a'
-compareType (TUnknown {}) _ = LT
-
compareType (TypeVar _ a) (TypeVar _ a') = compare a a'
-compareType (TypeVar {}) _ = LT
-compareType _ (TypeVar {}) = GT
-
compareType (TypeLevelString _ a) (TypeLevelString _ a') = compare a a'
-compareType (TypeLevelString {}) _ = LT
-compareType _ (TypeLevelString {}) = GT
-
+compareType (TypeLevelInt _ a) (TypeLevelInt _ a') = compare a a'
compareType (TypeWildcard _ a) (TypeWildcard _ a') = compare a a'
-compareType (TypeWildcard {}) _ = LT
-compareType _ (TypeWildcard {}) = GT
-
compareType (TypeConstructor _ a) (TypeConstructor _ a') = compare a a'
-compareType (TypeConstructor {}) _ = LT
-compareType _ (TypeConstructor {}) = GT
-
compareType (TypeOp _ a) (TypeOp _ a') = compare a a'
-compareType (TypeOp {}) _ = LT
-compareType _ (TypeOp {}) = GT
-
compareType (TypeApp _ a b) (TypeApp _ a' b') = compareType a a' <> compareType b b'
-compareType (TypeApp {}) _ = LT
-compareType _ (TypeApp {}) = GT
-
-compareType (ForAll _ a b c d) (ForAll _ a' b' c' d') = compare a a' <> compareMaybeKind b b' <> compareType c c' <> compare d d'
-compareType (ForAll {}) _ = LT
-compareType _ (ForAll {}) = GT
-
+compareType (KindApp _ a b) (KindApp _ a' b') = compareType a a' <> compareType b b'
+compareType (ForAll _ _ a b c d) (ForAll _ _ a' b' c' d') = compare a a' <> compareMaybeType b b' <> compareType c c' <> compare d d'
compareType (ConstrainedType _ a b) (ConstrainedType _ a' b') = compareConstraint a a' <> compareType b b'
-compareType (ConstrainedType {}) _ = LT
-compareType _ (ConstrainedType {}) = GT
-
-compareType (Skolem _ a b c) (Skolem _ a' b' c') = compare a a' <> compare b b' <> compare c c'
-compareType (Skolem {}) _ = LT
-compareType _ (Skolem {}) = GT
-
+compareType (Skolem _ a b c d) (Skolem _ a' b' c' d') = compare a a' <> compareMaybeType b b' <> compare c c' <> compare d d'
compareType (REmpty _) (REmpty _) = EQ
-compareType (REmpty _) _ = LT
-compareType _ (REmpty _) = GT
-
compareType (RCons _ a b c) (RCons _ a' b' c') = compare a a' <> compareType b b' <> compareType c c'
-compareType (RCons {}) _ = LT
-compareType _ (RCons {}) = GT
-
-compareType (KindedType _ a b) (KindedType _ a' b') = compareType a a' <> compareKind b b'
-compareType (KindedType {}) _ = LT
-compareType _ (KindedType {}) = GT
-
+compareType (KindedType _ a b) (KindedType _ a' b') = compareType a a' <> compareType b b'
compareType (BinaryNoParensType _ a b c) (BinaryNoParensType _ a' b' c') = compareType a a' <> compareType b b' <> compareType c c'
-compareType (BinaryNoParensType {}) _ = LT
-compareType _ (BinaryNoParensType {}) = GT
-
compareType (ParensInType _ a) (ParensInType _ a') = compareType a a'
-compareType (ParensInType {}) _ = GT
+compareType typ typ' =
+ compare (orderOf typ) (orderOf typ')
+ where
+ orderOf :: Type a -> Int
+ orderOf TUnknown{} = 0
+ orderOf TypeVar{} = 1
+ orderOf TypeLevelString{} = 2
+ orderOf TypeLevelInt{} = 3
+ orderOf TypeWildcard{} = 4
+ orderOf TypeConstructor{} = 5
+ orderOf TypeOp{} = 6
+ orderOf TypeApp{} = 7
+ orderOf KindApp{} = 8
+ orderOf ForAll{} = 9
+ orderOf ConstrainedType{} = 10
+ orderOf Skolem{} = 11
+ orderOf REmpty{} = 12
+ orderOf RCons{} = 13
+ orderOf KindedType{} = 14
+ orderOf BinaryNoParensType{} = 15
+ orderOf ParensInType{} = 16
+
+compareMaybeType :: Maybe (Type a) -> Maybe (Type b) -> Ordering
+compareMaybeType (Just a) (Just b) = compareType a b
+compareMaybeType Nothing Nothing = EQ
+compareMaybeType Nothing _ = LT
+compareMaybeType _ _ = GT
instance Eq (Constraint a) where
(==) = eqConstraint
@@ -636,7 +868,7 @@ instance Ord (Constraint a) where
compare = compareConstraint
eqConstraint :: Constraint a -> Constraint b -> Bool
-eqConstraint (Constraint _ a b c) (Constraint _ a' b' c') = a == a' && and (zipWith eqType b b') && c == c'
+eqConstraint (Constraint _ a b c d) (Constraint _ a' b' c' d') = a == a' && and (zipWith eqType b b') && and (zipWith eqType c c') && d == d'
compareConstraint :: Constraint a -> Constraint b -> Ordering
-compareConstraint (Constraint _ a b c) (Constraint _ a' b' c') = compare a a' <> fold (zipWith compareType b b') <> compare c c'
+compareConstraint (Constraint _ a b c d) (Constraint _ a' b' c' d') = compare a a' <> fold (zipWith compareType b b') <> fold (zipWith compareType c c') <> compare d d'
diff --git a/src/System/IO/UTF8.hs b/src/System/IO/UTF8.hs
index f3c1838d43..9ac916cf93 100644
--- a/src/System/IO/UTF8.hs
+++ b/src/System/IO/UTF8.hs
@@ -1,19 +1,24 @@
module System.IO.UTF8 where
-import Prelude.Compat
+import Prelude
-import qualified Data.ByteString as BS
-import qualified Data.ByteString.Lazy as BSL
-import qualified Data.ByteString.Search as BSS
-import qualified Data.ByteString.UTF8 as UTF8
-import Data.Text (Text)
-import qualified Data.Text.Encoding as TE
+import Data.ByteString qualified as BS
+import Data.ByteString.Lazy qualified as BSL
+import Data.ByteString.Search qualified as BSS
+import Data.ByteString.UTF8 qualified as UTF8
+import Data.Text (Text)
+import Data.Text.Encoding qualified as TE
+import Protolude (ordNub)
-- | Unfortunately ByteString's readFile does not convert line endings on
-- Windows, so we have to do it ourselves
fixCRLF :: BS.ByteString -> BS.ByteString
fixCRLF = BSL.toStrict . BSS.replace "\r\n" ("\n" :: BS.ByteString)
+readUTF8FilesT :: [FilePath] -> IO [(FilePath, Text)]
+readUTF8FilesT =
+ traverse (\inFile -> (inFile, ) <$> readUTF8FileT inFile) . ordNub
+
readUTF8FileT :: FilePath -> IO Text
readUTF8FileT inFile =
fmap (TE.decodeUtf8 . fixCRLF) (BS.readFile inFile)
@@ -25,7 +30,3 @@ writeUTF8FileT inFile text =
readUTF8File :: FilePath -> IO String
readUTF8File inFile =
fmap (UTF8.toString . fixCRLF) (BS.readFile inFile)
-
-writeUTF8File :: FilePath -> String -> IO ()
-writeUTF8File inFile text =
- BS.writeFile inFile (UTF8.fromString text)
diff --git a/stack.yaml b/stack.yaml
index 09abdb9be9..e87d094bcf 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -1,13 +1,32 @@
-resolver: lts-13.12
+# Please update Haskell image versions under .github/workflows/ci.yml together to use the same GHC version
+# (or the CI build will fail)
+resolver: lts-23.18
+pvp-bounds: both
packages:
- '.'
+ghc-options:
+ # Build with advanced optimizations enabled by default
+ "$locals": -O2 -Werror -fspecialize-aggressively -fexpose-all-unfoldings
extra-deps:
-- network-3.0.1.1
+# As of 2021-11-08, the latest release of `language-javascript` is 0.7.1.0,
+# but it has a problem with parsing the `async` keyword. It doesn't allow
+# `async` to be used as an object key:
+# https://github.com/erikd/language-javascript/issues/131
+- language-javascript-0.7.0.0
+- bower-json-1.1.0.0
+- these-1.2.1
+- aeson-better-errors-0.9.1.3
+
+- github: purescript/cheapskate
+ commit: 633c69024e061ad956f1aecfc137fb99a7a7a20b
+
nix:
- enable: false
packages:
- zlib
# Test dependencies
- nodejs
- nodePackages.npm
- nodePackages.bower
+flags:
+ aeson-pretty:
+ lib-only: true
diff --git a/stack.yaml.lock b/stack.yaml.lock
new file mode 100644
index 0000000000..57dab5ca82
--- /dev/null
+++ b/stack.yaml.lock
@@ -0,0 +1,51 @@
+# This file was autogenerated by Stack.
+# You should not edit this file by hand.
+# For more information, please see the documentation at:
+# https://docs.haskellstack.org/en/stable/topics/lock_files
+
+packages:
+- completed:
+ hackage: language-javascript-0.7.0.0@sha256:3eab0262b8ac5621936a4beab6a0f97d0e00a63455a8b0e3ac1547b4088dae7d,3898
+ pantry-tree:
+ sha256: b0f28d836cb3fbde203fd7318a896c3a20acd8653a905e1950ae2d9a64bccebf
+ size: 2244
+ original:
+ hackage: language-javascript-0.7.0.0
+- completed:
+ hackage: bower-json-1.1.0.0@sha256:a136aaca67bf0d15c336f5864f7e9d40ebe046ca2cb4b25bc4895617ea35f9f6,1864
+ pantry-tree:
+ sha256: 3acd48e7012f246ad44c7c17cd6340362b1dc448c1d93156280814e76d9e0589
+ size: 419
+ original:
+ hackage: bower-json-1.1.0.0
+- completed:
+ hackage: these-1.2.1@sha256:35c57aede96c15ea1fed559ac287b1168eb2b2869d79e62ed8c845780b7ea136,2294
+ pantry-tree:
+ sha256: dc6366ac715dfdf5338a615f71b9ed0542c403a6afcbedcddbc879e947aea6b3
+ size: 351
+ original:
+ hackage: these-1.2.1
+- completed:
+ hackage: aeson-better-errors-0.9.1.3@sha256:1bfdda3982368cafc7317b9f0c1f7267a6b0bbac9515ae1fad37f2b19178f567,2071
+ pantry-tree:
+ sha256: 1c14247866dfb8052506c179e4725b8a7ce1472a4fb227d61576d862d9494551
+ size: 492
+ original:
+ hackage: aeson-better-errors-0.9.1.3
+- completed:
+ name: cheapskate
+ pantry-tree:
+ sha256: b130a35ad29a61ac64c2d29bb09309ddf07b139342c67ef01ccc59ad4167d529
+ size: 12069
+ sha256: 2b495e2b6d571c33b91ebb76c1b7fe9c9b56ff90ca0804106a3260f2bbdc9a9a
+ size: 62489
+ url: https://github.com/purescript/cheapskate/archive/633c69024e061ad956f1aecfc137fb99a7a7a20b.tar.gz
+ version: 0.1.1.2
+ original:
+ url: https://github.com/purescript/cheapskate/archive/633c69024e061ad956f1aecfc137fb99a7a7a20b.tar.gz
+snapshots:
+- completed:
+ sha256: d133abe75e408a407cce3f032c96ac1bbadf474a93b5156ebf4135b53382d56b
+ size: 683827
+ url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/18.yaml
+ original: lts-23.18
diff --git a/tests/Language/PureScript/Ide/CompletionSpec.hs b/tests/Language/PureScript/Ide/CompletionSpec.hs
index 0a85fda69b..6ab1d89585 100644
--- a/tests/Language/PureScript/Ide/CompletionSpec.hs
+++ b/tests/Language/PureScript/Ide/CompletionSpec.hs
@@ -1,17 +1,14 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE NoImplicitPrelude #-}
module Language.PureScript.Ide.CompletionSpec where
import Protolude
-import qualified Data.Set as Set
-import qualified Language.PureScript as P
+import Language.PureScript qualified as P
import Language.PureScript.Ide.Test as Test
import Language.PureScript.Ide.Command as Command
-import Language.PureScript.Ide.Completion
-import Language.PureScript.Ide.Types
-import Test.Hspec
-import System.FilePath
+import Language.PureScript.Ide.Completion (CompletionOptions(..), applyCompletionOptions, defaultCompletionOptions)
+import Language.PureScript.Ide.Filter.Declaration qualified as DeclarationType
+import Language.PureScript.Ide.Types (Completion(..), IdeDeclarationAnn, Match(..), Success(..))
+import Test.Hspec (Spec, describe, it, shouldBe, shouldMatchList, shouldSatisfy)
reexportMatches :: [Match IdeDeclarationAnn]
reexportMatches =
@@ -30,9 +27,6 @@ typ txt = Type txt [] Nothing
load :: [Text] -> Command
load = LoadSync . map Test.mn
-rebuildSync :: FilePath -> Command
-rebuildSync fp = RebuildSync ("src" > fp) Nothing (Set.singleton P.JS)
-
spec :: Spec
spec = describe "Applying completion options" $ do
it "keeps all matches if maxResults is not specified" $ do
@@ -46,29 +40,106 @@ spec = describe "Applying completion options" $ do
reexportMatches `shouldBe` [(Match (mn "A", ideKind "Kind"), [mn "A", mn "B"])]
it "gets simple docs on definition itself" $ do
- ([_, (Right (CompletionResult [ result ]))], _) <- Test.inProject $
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
Test.runIde [ load ["CompletionSpecDocs"]
, typ "something"
]
result `shouldSatisfy` \res -> complDocumentation res == Just "Doc x\n"
it "gets multiline docs" $ do
- ([_, (Right (CompletionResult [ result ]))], _) <- Test.inProject $
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
Test.runIde [ load ["CompletionSpecDocs"]
, typ "multiline"
]
result `shouldSatisfy` \res -> complDocumentation res == Just "This is\na multi-line\ncomment\n"
it "gets simple docs on type annotation" $ do
- ([_, (Right (CompletionResult [ result ]))], _) <- Test.inProject $
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
Test.runIde [ load ["CompletionSpecDocs"]
, typ "withType"
]
result `shouldSatisfy` \res -> complDocumentation res == Just "Doc *123*\n"
it "gets docs on module declaration" $ do
- ([_, (Right (CompletionResult [ result ]))], _) <- Test.inProject $
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
Test.runIde [ load ["CompletionSpecDocs"]
, typ "CompletionSpecDocs"
]
result `shouldSatisfy` \res -> complDocumentation res == Just "Module Documentation\n"
+
+ it "gets docs on type class declaration" $ do
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
+ Test.runIde [ load ["CompletionSpecDocs"]
+ , typ "DocClass"
+ ]
+ result `shouldSatisfy` \res -> complDocumentation res == Just "Doc for class\n"
+
+ it "gets docs on type class members" $ do
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
+ Test.runIde [ load ["CompletionSpecDocs"]
+ , typ "member"
+ ]
+ result `shouldSatisfy` \res -> complDocumentation res == Just "doc for member\n"
+
+ it "includes declarationType in completions for values" $ do
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
+ Test.runIde [ load ["CompletionSpec"]
+ , typ "exampleValue"
+ ]
+ result `shouldSatisfy` \res ->
+ complDeclarationType res == Just DeclarationType.Value
+
+ it "includes declarationType in completions for functions" $ do
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
+ Test.runIde [ load ["CompletionSpec"]
+ , typ "exampleFunction"
+ ]
+ result `shouldSatisfy` \res ->
+ complDeclarationType res == Just DeclarationType.Value
+
+ it "includes declarationType in completions for inferred values" $ do
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
+ Test.runIde [ load ["CompletionSpec"]
+ , typ "exampleInferredString"
+ ]
+ result `shouldSatisfy` \res ->
+ complDeclarationType res == Just DeclarationType.Value
+
+ it "includes declarationType in completions for operators" $ do
+ ([_, Right (CompletionResult results)], _) <- Test.inProject $
+ Test.runIde [ load ["CompletionSpec"]
+ , typ "\\°/"
+ ]
+ length results `shouldBe` 2
+ results `shouldSatisfy` any (\res ->
+ complDeclarationType res == Just DeclarationType.ValueOperator)
+ results `shouldSatisfy` any (\res ->
+ complDeclarationType res == Just DeclarationType.TypeOperator)
+
+ it "includes declarationType in completions for type constructors with \
+ \conflicting names" $ do
+ ([_, Right (CompletionResult results)], _) <- Test.inProject $
+ Test.runIde [ load ["CompletionSpec"]
+ , typ "ExampleTypeConstructor"
+ ]
+ length results `shouldBe` 2
+ results `shouldSatisfy` any (\res ->
+ complDeclarationType res == Just DeclarationType.DataConstructor)
+ results `shouldSatisfy` any (\res ->
+ complDeclarationType res == Just DeclarationType.Type)
+
+ it "includes declarationType in completions for type classes" $ do
+ ([_, Right (CompletionResult [result])], _) <- Test.inProject $
+ Test.runIde [ load ["CompletionSpec"]
+ , typ "ExampleClass"
+ ]
+ result `shouldSatisfy` \res ->
+ complDeclarationType res == Just DeclarationType.TypeClass
+
+ it "includes declarationType in completions for type class members" $ do
+ ([_, Right (CompletionResult [result])], _) <- Test.inProject $
+ Test.runIde [ load ["CompletionSpec"]
+ , typ "exampleMember"
+ ]
+ result `shouldSatisfy` \res ->
+ complDeclarationType res == Just DeclarationType.Value
diff --git a/tests/Language/PureScript/Ide/FilterSpec.hs b/tests/Language/PureScript/Ide/FilterSpec.hs
index 84a0e50747..80eb127bd8 100644
--- a/tests/Language/PureScript/Ide/FilterSpec.hs
+++ b/tests/Language/PureScript/Ide/FilterSpec.hs
@@ -1,33 +1,36 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE NoImplicitPrelude #-}
module Language.PureScript.Ide.FilterSpec where
-import Protolude
-import qualified Data.Map as Map
-import qualified Data.Set as Set
-import Language.PureScript.Ide.Filter
-import Language.PureScript.Ide.Filter.Declaration as D
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Test as T
-import qualified Language.PureScript as P
-import Test.Hspec
+import Protolude
+import Data.Map qualified as Map
+import Data.Set qualified as Set
+import Language.PureScript.Ide.Filter (applyFilters, declarationTypeFilter, dependencyFilter, exactFilter, moduleFilter, namespaceFilter, prefixFilter)
+import Language.PureScript.Ide.Filter.Declaration as D
+import Language.PureScript.Ide.Types (IdeDeclarationAnn, IdeNamespace(..), ModuleMap)
+import Language.PureScript.Ide.Imports (Import, sliceImportSection)
+import Language.PureScript.Ide.Test as T
+import Language.PureScript qualified as P
+import Test.Hspec (Spec, describe, it, shouldBe)
type Module = (P.ModuleName, [IdeDeclarationAnn])
-moduleA, moduleB, moduleC, moduleD, moduleE, moduleF, moduleG, moduleH, moduleI :: Module
+moduleA, moduleB, moduleC, moduleD, moduleE, moduleF, moduleG, moduleH, moduleI, moduleDCtors :: Module
moduleA = (P.moduleNameFromString "Module.A", [T.ideValue "function1" Nothing])
moduleB = (P.moduleNameFromString "Module.B", [T.ideValue "data1" Nothing])
moduleC = (P.moduleNameFromString "Module.C", [T.ideType "List" Nothing []])
-moduleD = (P.moduleNameFromString "Module.D", [T.ideKind "kind1"])
+moduleD = (P.moduleNameFromString "Module.D", [T.ideType "kind1" Nothing []])
moduleE = (P.moduleNameFromString "Module.E", [T.ideSynonym "SFType" Nothing Nothing `annLoc` synonymSS])
moduleF = (P.moduleNameFromString "Module.F", [T.ideDtor "DtorA" "TypeA" Nothing])
moduleG = (P.moduleNameFromString "Module.G", [T.ideTypeClass "MyClass" P.kindType []])
-moduleH = (P.moduleNameFromString "Module.H", [T.ideValueOp "<$>" (P.Qualified Nothing (Left "")) 0 Nothing Nothing])
-moduleI = (P.moduleNameFromString "Module.I", [T.ideTypeOp "~>" (P.Qualified Nothing "") 0 Nothing Nothing])
+moduleH = (P.moduleNameFromString "Module.H", [T.ideValueOp "<$>" (P.Qualified P.ByNullSourcePos (Left "")) 0 Nothing Nothing])
+moduleI = (P.moduleNameFromString "Module.I", [T.ideTypeOp "~>" (P.Qualified P.ByNullSourcePos "") 0 Nothing Nothing])
+moduleDCtors = (P.moduleNameFromString "Module.WithDC", [T.ideType "Foo" Nothing [(P.ProperName "A", P.tyString), (P.ProperName "B", P.tyString)] ])
modules :: ModuleMap [IdeDeclarationAnn]
modules = Map.fromList [moduleA, moduleB]
+allModules :: ModuleMap [IdeDeclarationAnn]
+allModules = Map.fromList [moduleA, moduleB,moduleC,moduleD,moduleE,moduleF,moduleG,moduleH,moduleI,moduleDCtors]
+
runEq :: Text -> [Module]
runEq s = Map.toList (applyFilters [exactFilter s] modules)
@@ -43,6 +46,20 @@ runNamespace namespaces = Map.toList . applyFilters [namespaceFilter namespaces]
runDeclaration :: [D.DeclarationType] -> [Module] -> [Module]
runDeclaration decls = Map.toList . applyFilters [declarationTypeFilter (Set.fromList decls)] . Map.fromList
+runDependency :: [Text] -> [Module]
+runDependency = runDependency' "Whatever"
+
+runDependency' :: Text -> [Text] -> [Module]
+runDependency' currentModuleName imports = Map.toList $ applyFilters [dependencyFilter Nothing (P.ModuleName currentModuleName) (testParseImports currentModuleName imports)] allModules
+
+runDependencyQualified :: Text -> [Text] -> [Module]
+runDependencyQualified qualifier imports = Map.toList $ applyFilters [dependencyFilter (Just $ P.ModuleName qualifier) (P.ModuleName "Whatever") (testParseImports "Whatever" imports)] allModules
+
+testParseImports :: Text -> [Text] -> [Import]
+testParseImports currentModuleName imports = either (const []) (\(_, _, x, _) -> x) $ sliceImportSection moduleLines
+ where
+ moduleLines = "module " <> currentModuleName <> " where" : (imports <> [ "", "blah = 42" ])
+
spec :: Spec
spec = do
describe "equality Filter" $ do
@@ -79,26 +96,8 @@ spec = do
it "extracts no modules by filtering `type` namespaces" $
runNamespace (Set.fromList [IdeNSType])
[moduleA, moduleB] `shouldBe` []
- it "extracts modules by filtering `kind` namespaces" $
- runNamespace (Set.fromList [IdeNSKind])
- [moduleA, moduleB, moduleD] `shouldBe` [moduleD]
- it "extracts no modules by filtering `kind` namespaces" $
- runNamespace (Set.fromList [IdeNSKind])
- [moduleA, moduleB] `shouldBe` []
it "extracts modules by filtering `value` and `type` namespaces" $
runNamespace (Set.fromList [ IdeNSValue, IdeNSType])
- [moduleA, moduleB, moduleC, moduleD]
- `shouldBe` [moduleA, moduleB, moduleC]
- it "extracts modules by filtering `value` and `kind` namespaces" $
- runNamespace (Set.fromList [ IdeNSValue, IdeNSKind])
- [moduleA, moduleB, moduleC, moduleD]
- `shouldBe` [moduleA, moduleB, moduleD]
- it "extracts modules by filtering `type` and `kind` namespaces" $
- runNamespace (Set.fromList [ IdeNSType, IdeNSKind])
- [moduleA, moduleB, moduleC, moduleD]
- `shouldBe` [moduleC, moduleD]
- it "extracts modules by filtering `value`, `type` and `kind` namespaces" $
- runNamespace (Set.fromList [ IdeNSValue, IdeNSType, IdeNSKind])
[moduleA, moduleB, moduleC, moduleD]
`shouldBe` [moduleA, moduleB, moduleC, moduleD]
describe "declarationTypeFilter" $ do
@@ -110,7 +109,7 @@ spec = do
[moduleD, moduleG, moduleE, moduleH] `shouldBe` []
it "extracts module by filtering `type` declarations" $
runDeclaration [D.Type]
- [moduleA, moduleB, moduleC, moduleD, moduleE] `shouldBe` [moduleC]
+ [moduleA, moduleB, moduleC, moduleD, moduleE] `shouldBe` [moduleC, moduleD]
it "removes everything if a `type` declaration have not been found" $
runDeclaration [D.Type]
[moduleA, moduleG, moduleE, moduleH] `shouldBe` []
@@ -144,15 +143,51 @@ spec = do
it "removes everything if a `typeoperator` declaration have not been found" $
runDeclaration [D.TypeOperator]
[moduleA, moduleD] `shouldBe` []
- it "extracts module by filtering `kind` declarations" $
- runDeclaration [D.Kind]
- [moduleA, moduleD, moduleG, moduleI, moduleF] `shouldBe` [moduleD]
- it "removes everything if a `kind` declaration have not been found" $
- runDeclaration [D.Kind]
- [moduleA, moduleC] `shouldBe` []
it "extracts modules by filtering `value` and `synonym` declarations" $
runDeclaration [D.Value, D.Synonym]
[moduleA, moduleB, moduleD, moduleE] `shouldBe` [moduleA, moduleB, moduleE]
- it "extracts modules by filtering `value`, `kind`, and `valueoperator` declarations" $
- runDeclaration [D.Value, D.Kind, D.ValueOperator]
- [moduleA, moduleB, moduleD, moduleG, moduleE, moduleH] `shouldBe` [moduleA, moduleB, moduleD, moduleH]
+ it "extracts modules by filtering `value`, and `valueoperator` declarations" $
+ runDeclaration [D.Value, D.ValueOperator]
+ [moduleA, moduleB, moduleD, moduleG, moduleE, moduleH] `shouldBe` [moduleA, moduleB, moduleH]
+ describe "dependencyFilter" $ do
+ describe "import types" $ do
+ it "filters by implicit imports" $ do
+ runDependency ["import Module.A", "import Module.C"] `shouldBe` [moduleA, moduleC]
+ it "filters by matching explicit value import" $ do
+ runDependency ["import Module.A (function1)"] `shouldBe` [moduleA]
+ it "filters by matching explicit value import from correct module" $ do
+ runDependency ["import Module.B (function1)"] `shouldBe` []
+ it "filters not matching explicit value import" $ do
+ runDependency ["import Module.A (function2)"] `shouldBe` []
+ it "filters out names in hiding import" $ do
+ runDependency ["import Module.A hiding (function1)"] `shouldBe` []
+ it "doesn't filter out not matching names in hiding import" $ do
+ runDependency ["import Module.A hiding (nonsense)"] `shouldBe` [moduleA]
+ it "filters by containing module" $ do
+ runDependency' "Module.A" ["import Module.Blah"] `shouldBe` [moduleA]
+ describe "declaration types" $ do
+ it "matches type" $ do
+ runDependency ["import Module.C (List)"] `shouldBe` [moduleC]
+ it "includes data constructor with (..)" $ do
+ runDependency ["import Module.F (TypeA(..))"] `shouldBe` [moduleF]
+ it "includes data constructor explicitly listed" $ do
+ runDependency ["import Module.F (TypeA(DtorA))"] `shouldBe` [moduleF]
+ it "does not include data constructor not explicitly listed" $ do
+ runDependency ["import Module.F (TypeA(BogusOtherConstructor))"] `shouldBe` []
+ it "does not include data constructor when only the type is imported" $ do
+ runDependency ["import Module.F (TypeA)"] `shouldBe` []
+ it "includes synonym" $ do
+ runDependency ["import Module.E (SFType)"] `shouldBe` [moduleE]
+ it "includes typeclass" $ do
+ runDependency ["import Module.G (class MyClass)"] `shouldBe` [moduleG]
+ it "includes value op" $ do
+ runDependency ["import Module.H ((<$>))"] `shouldBe` [moduleH]
+ it "includes type op" $ do
+ runDependency ["import Module.I (type (~>))"] `shouldBe` [moduleI]
+ describe "qualifiers" $ do
+ it "includes single qualified import and not unqualified things" $ do
+ runDependencyQualified "AA" [ "import Module.A as AA", "import Module.C"] `shouldBe` [moduleA]
+ it "includes multiple qualified imports" $ do
+ runDependencyQualified "Combined.Thing" [ "import Module.A as Combined.Thing", "import Module.C as Combined.Thing", "import Module.F"] `shouldBe` [moduleA, moduleC]
+ it "doesn't include qualified import when qualifier not specified" $ do
+ runDependency [ "import Module.AA as A"] `shouldBe` []
diff --git a/tests/Language/PureScript/Ide/ImportsSpec.hs b/tests/Language/PureScript/Ide/ImportsSpec.hs
index 5c29c86ac8..b12aeea352 100644
--- a/tests/Language/PureScript/Ide/ImportsSpec.hs
+++ b/tests/Language/PureScript/Ide/ImportsSpec.hs
@@ -1,20 +1,19 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE NoImplicitPrelude #-}
module Language.PureScript.Ide.ImportsSpec where
-import Protolude hiding (moduleName)
-import Data.Maybe (fromJust)
-import qualified Data.Set as Set
+import Protolude hiding (moduleName)
+import Data.Maybe (fromJust)
+import Data.Set qualified as Set
-import qualified Language.PureScript as P
-import Language.PureScript.Ide.Command as Command
-import Language.PureScript.Ide.Error
-import Language.PureScript.Ide.Imports
-import Language.PureScript.Ide.Filter (moduleFilter)
-import qualified Language.PureScript.Ide.Test as Test
-import Language.PureScript.Ide.Types
-import System.FilePath
-import Test.Hspec
+import Language.PureScript qualified as P
+import Language.PureScript.Ide.Command as Command
+import Language.PureScript.Ide.Error (IdeError)
+import Language.PureScript.Ide.Imports (Import, parseImport, prettyPrintImport', prettyPrintImportSection, sliceImportSection)
+import Language.PureScript.Ide.Imports.Actions (addExplicitImport', addImplicitImport', addQualifiedImport')
+import Language.PureScript.Ide.Filter (moduleFilter)
+import Language.PureScript.Ide.Test qualified as Test
+import Language.PureScript.Ide.Types (IdeDeclarationAnn(..), Success(..))
+import System.FilePath ((>))
+import Test.Hspec (Expectation, Spec, describe, it, shouldBe, shouldSatisfy)
noImportsFile :: [Text]
noImportsFile =
@@ -35,7 +34,7 @@ hidingFile :: [Text]
hidingFile =
[ "module Main where"
, "import Prelude"
- , "import Data.Maybe hiding (maybe)"
+ , "import Data.Maybe hiding (maybe, maybe')"
, ""
, "myFunc x y = x + y"
]
@@ -72,9 +71,9 @@ spec = do
describe "determining the importsection" $ do
let moduleSkeleton imports =
Right (P.moduleNameFromString "Main", take 1 simpleFile, imports, drop 2 simpleFile)
- it "slices a file without imports and adds a newline after the module declaration" $
+ it "slices a file without imports" $
shouldBe (sliceImportSection noImportsFile)
- (Right (P.moduleNameFromString "Main", take 1 noImportsFile ++ [""], [], drop 1 noImportsFile))
+ (Right (P.moduleNameFromString "Main", take 1 noImportsFile, [], drop 1 noImportsFile))
it "handles a file with syntax errors just fine" $
shouldBe (sliceImportSection syntaxErrorFile)
@@ -115,13 +114,11 @@ spec = do
addValueImport i mn q is =
prettyPrintImportSection (addExplicitImport' (_idaDeclaration (Test.ideValue i Nothing)) mn q is)
addOpImport op mn q is =
- prettyPrintImportSection (addExplicitImport' (_idaDeclaration (Test.ideValueOp op (P.Qualified q (Left "")) 2 Nothing Nothing)) mn q is)
+ prettyPrintImportSection (addExplicitImport' (_idaDeclaration (Test.ideValueOp op (P.Qualified (P.byMaybeModuleName q) (Left "")) 2 Nothing Nothing)) mn q is)
addDtorImport i t mn q is =
prettyPrintImportSection (addExplicitImport' (_idaDeclaration (Test.ideDtor i t Nothing)) mn q is)
addTypeImport i mn q is =
prettyPrintImportSection (addExplicitImport' (_idaDeclaration (Test.ideType i Nothing [])) mn q is)
- addKindImport i mn q is =
- prettyPrintImportSection (addExplicitImport' (_idaDeclaration (Test.ideKind i)) mn q is)
qualify s = Just (Test.mn s)
it "adds an implicit unqualified import to a file without any imports" $
shouldBe
@@ -140,10 +137,10 @@ spec = do
, ""
, "import Data.Map as Map"
]
- it "adds a qualified import and maintains proper grouping for implicit hiding imports" $
+ it "adds a qualified import and maintains proper grouping and formatting for implicit hiding imports" $
shouldBe
(addQualifiedImport' hidingFileImports (Test.mn "Data.Map") (Test.mn "Map"))
- [ "import Data.Maybe hiding (maybe)"
+ [ "import Data.Maybe hiding (maybe, maybe')"
, "import Prelude"
, ""
, "import Data.Map as Map"
@@ -197,20 +194,6 @@ spec = do
, ""
, "import Data.Array (head, tail) as Array"
]
- it "adds a kind to an explicit import list" $
- shouldBe
- (addKindImport "Effect" (P.moduleNameFromString "Control.Monad.Eff") Nothing simpleFileImports)
- [ "import Prelude"
- , ""
- , "import Control.Monad.Eff (kind Effect)"
- ]
- it "adds a kind to an explicit qualified import list" $
- shouldBe
- (addKindImport "Effect" (P.moduleNameFromString "Control.Monad.Eff") (qualify "Eff") simpleFileImports)
- [ "import Prelude"
- , ""
- , "import Control.Monad.Eff (kind Effect) as Eff"
- ]
it "adds an operator to an explicit import list" $
shouldBe
(addOpImport "<~>" (P.moduleNameFromString "Data.Array") Nothing explicitImports)
@@ -304,7 +287,7 @@ spec = do
describe "explicit import sorting" $ do
-- given some basic import skeleton
let Right (_, _, baseImports, _) = sliceImportSection $ withImports ["import Control.Monad (ap)"]
- moduleName = (P.moduleNameFromString "Control.Monad")
+ moduleName = P.moduleNameFromString "Control.Monad"
addImport imports import' = addExplicitImport' import' moduleName Nothing imports
valueImport ident = _idaDeclaration (Test.ideValue ident Nothing)
typeImport name = _idaDeclaration (Test.ideType name Nothing [])
@@ -324,11 +307,11 @@ spec = do
["import Prelude", "", "import Control.Monad (ap, unless, where)"]
it "sorts type, value" $
expectSorted
- ((map valueImport ["unless", "where"]) ++ (map typeImport ["Foo", "Bar"]))
+ (map valueImport ["unless", "where"] ++ map typeImport ["Foo", "Bar"])
["import Prelude", "", "import Control.Monad (Bar, Foo, ap, unless, where)"]
it "sorts class, type, value" $
expectSorted
- ((map valueImport ["unless", "where"]) ++ (map typeImport ["Foo", "Bar"]) ++ (map classImport ["Applicative", "Bind"]))
+ (map valueImport ["unless", "where"] ++ map typeImport ["Foo", "Bar"] ++ map classImport ["Applicative", "Bind"])
["import Prelude", "", "import Control.Monad (class Applicative, class Bind, Bar, Foo, ap, unless, where)"]
it "sorts types with constructors, using open imports for the constructors" $
expectSorted
@@ -351,7 +334,12 @@ addExplicitImportFiltered i ms =
importShouldBe :: [Text] -> [Text] -> Expectation
importShouldBe res importSection =
- res `shouldBe` [ "module ImportsSpec where" , ""] ++ importSection ++ [ "" , "myId x = x"]
+ res `shouldBe`
+ [ "module ImportsSpec where" ]
+ ++ (if null importSection then [] else "" : importSection)
+ ++ [ ""
+ , "myId x = x"
+ ]
runIdeLoaded :: Command -> IO (Either IdeError Success)
runIdeLoaded c = do
diff --git a/tests/Language/PureScript/Ide/MatcherSpec.hs b/tests/Language/PureScript/Ide/MatcherSpec.hs
index 22eb860e12..306e3ca321 100644
--- a/tests/Language/PureScript/Ide/MatcherSpec.hs
+++ b/tests/Language/PureScript/Ide/MatcherSpec.hs
@@ -1,15 +1,12 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE NoImplicitPrelude #-}
-
module Language.PureScript.Ide.MatcherSpec where
-import Protolude
+import Protolude
-import qualified Language.PureScript as P
-import Language.PureScript.Ide.Matcher
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Util
-import Test.Hspec
+import Language.PureScript qualified as P
+import Language.PureScript.Ide.Matcher (flexMatcher, runMatcher)
+import Language.PureScript.Ide.Types (IdeDeclaration(..), IdeDeclarationAnn, IdeValue(..), Match(..))
+import Language.PureScript.Ide.Util (withEmptyAnn)
+import Test.Hspec (Spec, describe, it, shouldBe)
value :: Text -> IdeDeclarationAnn
value s = withEmptyAnn (IdeDeclValue (IdeValue (P.Ident (toS s)) P.srcREmpty))
diff --git a/tests/Language/PureScript/Ide/RebuildSpec.hs b/tests/Language/PureScript/Ide/RebuildSpec.hs
index 0aea8e2a83..93a0cabe51 100644
--- a/tests/Language/PureScript/Ide/RebuildSpec.hs
+++ b/tests/Language/PureScript/Ide/RebuildSpec.hs
@@ -1,20 +1,18 @@
-{-# LANGUAGE NoImplicitPrelude #-}
-{-# LANGUAGE OverloadedStrings #-}
module Language.PureScript.Ide.RebuildSpec where
-import Protolude
+import Protolude
-import qualified Data.Set as Set
-import qualified Language.PureScript as P
-import Language.PureScript.AST.SourcePos (spanName)
-import Language.PureScript.Ide.Command
-import Language.PureScript.Ide.Completion
-import Language.PureScript.Ide.Matcher
-import Language.PureScript.Ide.Types
-import qualified Language.PureScript.Ide.Test as Test
-import System.FilePath
-import System.Directory (doesFileExist, removePathForcibly)
-import Test.Hspec
+import Data.Set qualified as Set
+import Language.PureScript qualified as P
+import Language.PureScript.AST.SourcePos (spanName)
+import Language.PureScript.Ide.Command (Command(..))
+import Language.PureScript.Ide.Completion (defaultCompletionOptions)
+import Language.PureScript.Ide.Matcher (flexMatcher)
+import Language.PureScript.Ide.Types (Completion(..), Success(..), emptyIdeState)
+import Language.PureScript.Ide.Test qualified as Test
+import System.FilePath ((>))
+import System.Directory (doesFileExist, removePathForcibly)
+import Test.Hspec (Spec, describe, it, shouldBe, shouldSatisfy)
defaultTarget :: Set P.CodegenTarget
defaultTarget = Set.singleton P.JS
@@ -63,15 +61,14 @@ spec = describe "Rebuilding single modules" $ do
Test.runIde [ rebuild "RebuildSpecWithMissingForeign.fail" ]
result `shouldSatisfy` isLeft
it "completes a hidden identifier after rebuilding" $ do
- ([_, (Right (CompletionResult [ result ]))], _) <- Test.inProject $
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
Test.runIde [ rebuildSync "RebuildSpecWithHiddenIdent.purs"
, Complete [] (flexMatcher "hid") (Just (Test.mn "RebuildSpecWithHiddenIdent")) defaultCompletionOptions]
complIdentifier result `shouldBe` "hidden"
- it "uses the specified `actualFile` for location information (in editor mode)" $ do
- let editorConfig = Test.defConfig { confEditorMode = True }
- ([_, (Right (CompletionResult [ result ]))], _) <- Test.inProject $
+ it "uses the specified `actualFile` for location information" $ do
+ ([_, Right (CompletionResult [ result ])], _) <- Test.inProject $
Test.runIde'
- editorConfig
+ Test.defConfig
emptyIdeState
[ RebuildSync ("src" > "RebuildSpecWithHiddenIdent.purs") (Just "actualFile") defaultTarget
, Complete [] (flexMatcher "hid") (Just (Test.mn "RebuildSpecWithHiddenIdent")) defaultCompletionOptions]
diff --git a/tests/Language/PureScript/Ide/ReexportsSpec.hs b/tests/Language/PureScript/Ide/ReexportsSpec.hs
index 731672a58c..77265987d1 100644
--- a/tests/Language/PureScript/Ide/ReexportsSpec.hs
+++ b/tests/Language/PureScript/Ide/ReexportsSpec.hs
@@ -1,15 +1,13 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE NoImplicitPrelude #-}
module Language.PureScript.Ide.ReexportsSpec where
-import Protolude
+import Protolude
-import qualified Data.Map as Map
-import Language.PureScript.Ide.Reexports
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Test
-import qualified Language.PureScript as P
-import Test.Hspec
+import Data.Map qualified as Map
+import Language.PureScript.Ide.Reexports (ReexportResult(..), reexportHasFailures, resolveReexports')
+import Language.PureScript.Ide.Types (IdeDeclarationAnn, ModuleMap)
+import Language.PureScript.Ide.Test (annExp, ideDtor, ideKind, ideSynonym, ideType, ideTypeClass, ideValue, mn)
+import Language.PureScript qualified as P
+import Test.Hspec (Spec, describe, it, shouldBe, shouldSatisfy)
valueA, typeA, synonymA, classA, dtorA1, dtorA2, kindA :: IdeDeclarationAnn
valueA = ideValue "valueA" Nothing
@@ -40,7 +38,6 @@ succTestCases =
, ("resolves a synonym reexport"
, [(mn "A", P.TypeRef testSpan (P.ProperName "SynonymA") Nothing)], [synonymA `annExp` "A"])
, ("resolves a class reexport", [(mn "A", P.TypeClassRef testSpan (P.ProperName "ClassA"))], [classA `annExp` "A"])
- , ("resolves a kind reexport", [(mn "A", P.KindRef testSpan (P.ProperName "KindA"))], [kindA `annExp` "A"])
]
failTestCases :: [(Text, Refs)]
diff --git a/tests/Language/PureScript/Ide/SourceFileSpec.hs b/tests/Language/PureScript/Ide/SourceFileSpec.hs
index 20a625856c..f7de445c0e 100644
--- a/tests/Language/PureScript/Ide/SourceFileSpec.hs
+++ b/tests/Language/PureScript/Ide/SourceFileSpec.hs
@@ -1,49 +1,44 @@
-{-# LANGUAGE NoImplicitPrelude #-}
-{-# LANGUAGE OverloadedStrings #-}
module Language.PureScript.Ide.SourceFileSpec where
-import Protolude
+import Protolude
-import qualified Language.PureScript as P
-import Language.PureScript.Ide.Command
-import Language.PureScript.Ide.SourceFile
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.Test
-import Test.Hspec
+import Language.PureScript qualified as P
+import Language.PureScript.Ide.Command (Command(..))
+import Language.PureScript.Ide.SourceFile (extractSpans, extractTypeAnnotations)
+import Language.PureScript.Ide.Types (Completion(..), IdeNamespace(..), IdeNamespaced(..), Success(..), emptyIdeState)
+import Language.PureScript.Ide.Test
+import Test.Hspec (Spec, describe, it, shouldBe)
-span0, span1, span2 :: P.SourceSpan
-span0 = P.SourceSpan "ModuleLevel" (P.SourcePos 0 0) (P.SourcePos 1 1)
+span1, span2 :: P.SourceSpan
span1 = P.SourceSpan "" (P.SourcePos 1 1) (P.SourcePos 2 2)
span2 = P.SourceSpan "" (P.SourcePos 2 2) (P.SourcePos 3 3)
-ann0, ann1, ann2 :: P.SourceAnn
-ann0 = (span0, [])
+ann1, ann2 :: P.SourceAnn
ann1 = (span1, [])
ann2 = (span2, [])
-typeAnnotation1, value1, synonym1, class1, class2, data1, data2, valueFixity, typeFixity, foreign1, foreign2, foreign3, member1 :: P.Declaration
+typeAnnotation1, value1, synonym1, class1, class2, data1, data2, valueFixity, typeFixity, foreign1, foreign2, member1 :: P.Declaration
typeAnnotation1 = P.TypeDeclaration (P.TypeDeclarationData ann1 (P.Ident "value1") P.srcREmpty)
value1 = P.ValueDecl ann1 (P.Ident "value1") P.Public [] []
synonym1 = P.TypeSynonymDeclaration ann1 (P.ProperName "Synonym1") [] P.srcREmpty
class1 = P.TypeClassDeclaration ann1 (P.ProperName "Class1") [] [] [] []
class2 = P.TypeClassDeclaration ann1 (P.ProperName "Class2") [] [] [] [member1]
data1 = P.DataDeclaration ann1 P.Newtype (P.ProperName "Data1") [] []
-data2 = P.DataDeclaration ann1 P.Data (P.ProperName "Data2") [] [(P.ProperName "Cons1", [])]
+data2 = P.DataDeclaration ann1 P.Data (P.ProperName "Data2") [] [P.DataConstructorDeclaration ann2 (P.ProperName "Cons1") []]
valueFixity =
P.ValueFixityDeclaration
ann1
(P.Fixity P.Infix 0)
- (P.Qualified Nothing (Left (P.Ident "")))
+ (P.Qualified P.ByNullSourcePos (Left (P.Ident "")))
(P.OpName "<$>")
typeFixity =
P.TypeFixityDeclaration
ann1
(P.Fixity P.Infix 0)
- (P.Qualified Nothing (P.ProperName ""))
+ (P.Qualified P.ByNullSourcePos (P.ProperName ""))
(P.OpName "~>")
foreign1 = P.ExternDeclaration ann1 (P.Ident "foreign1") P.srcREmpty
foreign2 = P.ExternDataDeclaration ann1 (P.ProperName "Foreign2") P.kindType
-foreign3 = P.ExternKindDeclaration ann1 (P.ProperName "Foreign3")
member1 = P.TypeDeclaration (P.TypeDeclarationData ann2 (P.Ident "member1") P.srcREmpty)
spec :: Spec
@@ -60,7 +55,7 @@ spec = do
it "extracts a span for a data declaration" $
extractSpans data1 `shouldBe` [(IdeNamespaced IdeNSType "Data1", span1)]
it "extracts spans for a data declaration and its constructors" $
- extractSpans data2 `shouldBe` [(IdeNamespaced IdeNSType "Data2", span1), (IdeNamespaced IdeNSValue "Cons1", span1)]
+ extractSpans data2 `shouldBe` [(IdeNamespaced IdeNSType "Data2", span1), (IdeNamespaced IdeNSValue "Cons1", span2)]
it "extracts a span for a value operator fixity declaration" $
extractSpans valueFixity `shouldBe` [(IdeNamespaced IdeNSValue "<$>", span1)]
it "extracts a span for a type operator fixity declaration" $
@@ -69,8 +64,6 @@ spec = do
extractSpans foreign1 `shouldBe` [(IdeNamespaced IdeNSValue "foreign1", span1)]
it "extracts a span for a data foreign declaration" $
extractSpans foreign2 `shouldBe` [(IdeNamespaced IdeNSType "Foreign2", span1)]
- it "extracts a span for a foreign kind declaration" $
- extractSpans foreign3 `shouldBe` [(IdeNamespaced IdeNSKind "Foreign3", span1)]
describe "Type annotations" $ do
it "extracts a type annotation" $
extractTypeAnnotations [typeAnnotation1] `shouldBe` [(P.Ident "value1", P.srcREmpty)]
@@ -83,7 +76,7 @@ spec = do
r `shouldBe` synonymSS
it "finds a data declaration and its constructors" $ do
rs <- traverse getLocation ["SFData", "SFOne", "SFTwo", "SFThree"]
- traverse_ (`shouldBe` (Just typeSS)) rs
+ traverse_ (`shouldBe` Just typeSS) rs
it "finds a class declaration" $ do
Just r <- getLocation "SFClass"
r `shouldBe` classSS
@@ -113,9 +106,9 @@ getLocation s = do
, ideDtor "SFTwo" "SFData" Nothing `annLoc` typeSS
, ideDtor "SFThree" "SFData" Nothing `annLoc` typeSS
, ideTypeClass "SFClass" P.kindType [] `annLoc` classSS
- , ideValueOp "<$>" (P.Qualified Nothing (Left "")) 0 Nothing Nothing
+ , ideValueOp "<$>" (P.Qualified P.ByNullSourcePos (Left "")) 0 Nothing Nothing
`annLoc` valueOpSS
- , ideTypeOp "~>" (P.Qualified Nothing "") 0 Nothing Nothing
+ , ideTypeOp "~>" (P.Qualified P.ByNullSourcePos "") 0 Nothing Nothing
`annLoc` typeOpSS
])
]
diff --git a/tests/Language/PureScript/Ide/StateSpec.hs b/tests/Language/PureScript/Ide/StateSpec.hs
index 4775a67fc7..5ece522c34 100644
--- a/tests/Language/PureScript/Ide/StateSpec.hs
+++ b/tests/Language/PureScript/Ide/StateSpec.hs
@@ -1,27 +1,25 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE NoImplicitPrelude #-}
module Language.PureScript.Ide.StateSpec where
-import Protolude
-import Language.PureScript.Ide.Types
-import Language.PureScript.Ide.State
-import Language.PureScript.Ide.Test
-import qualified Language.PureScript as P
-import Lens.Micro.Platform hiding ((&))
-import Test.Hspec
-import qualified Data.Map as Map
+import Protolude
+import Control.Lens (Ixed(..), folded)
+import Language.PureScript.Ide.Types (IdeDeclarationAnn, IdeInstance(..), ModuleMap, _IdeDeclTypeClass, anyOf, idaDeclaration, ideTCInstances)
+import Language.PureScript.Ide.State (resolveDataConstructorsForModule, resolveInstances, resolveOperatorsForModule)
+import Language.PureScript.Ide.Test (ideDtor, ideType, ideTypeClass, ideTypeOp, ideValue, ideValueOp, mn)
+import Language.PureScript qualified as P
+import Test.Hspec (Spec, describe, it, shouldSatisfy)
+import Data.Map qualified as Map
valueOperator :: Maybe P.SourceType -> IdeDeclarationAnn
valueOperator =
- ideValueOp "<$>" (P.Qualified (Just (mn "Test")) (Left "function")) 2 Nothing
+ ideValueOp "<$>" (P.Qualified (P.ByModuleName (mn "Test")) (Left "function")) 2 Nothing
ctorOperator :: Maybe P.SourceType -> IdeDeclarationAnn
ctorOperator =
- ideValueOp ":" (P.Qualified (Just (mn "Test")) (Right "Cons")) 2 Nothing
+ ideValueOp ":" (P.Qualified (P.ByModuleName (mn "Test")) (Right "Cons")) 2 Nothing
-typeOperator :: Maybe P.SourceKind -> IdeDeclarationAnn
+typeOperator :: Maybe P.SourceType -> IdeDeclarationAnn
typeOperator =
- ideTypeOp ":" (P.Qualified (Just (mn "Test")) "List") 2 Nothing
+ ideTypeOp ":" (P.Qualified (P.ByModuleName (mn "Test")) "List") 2 Nothing
testModule :: (P.ModuleName, [IdeDeclarationAnn])
testModule =
@@ -55,17 +53,25 @@ ef = P.ExternsFile
--, efDeclarations =
[ P.EDInstance
-- { edInstanceClassName =
- (P.Qualified (Just (mn "ClassModule")) (P.ProperName "MyClass"))
+ (P.Qualified (P.ByModuleName (mn "ClassModule")) (P.ProperName "MyClass"))
-- , edInstanceName =
(P.Ident "myClassInstance")
+ -- . edInstanceForAll =
+ []
+ -- , edInstanceKinds =
+ mempty
-- , edInstanceTypes =
mempty
-- , edInstanceConstraints =
mempty
-- , edInstanceChain =
- mempty
+ Nothing
-- , edInstanceChainIndex =
0
+ -- , edInstanceNameSource =
+ P.UserNamed
+ -- , edInstanceSourceSpan =
+ P.NullSourceSpan
-- }
]
--, efSourceSpan =
diff --git a/tests/Language/PureScript/Ide/Test.hs b/tests/Language/PureScript/Ide/Test.hs
index 6164e02722..17998d63d1 100644
--- a/tests/Language/PureScript/Ide/Test.hs
+++ b/tests/Language/PureScript/Ide/Test.hs
@@ -1,22 +1,20 @@
-{-# LANGUAGE NoImplicitPrelude #-}
-{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
-{-# LANGUAGE DataKinds #-}
module Language.PureScript.Ide.Test where
-import Control.Concurrent.STM
-import "monad-logger" Control.Monad.Logger
-import qualified Data.Map as Map
-import Language.PureScript.Ide
-import Language.PureScript.Ide.Command
-import Language.PureScript.Ide.Error
-import Language.PureScript.Ide.Types
-import Protolude
-import System.Directory
-import System.FilePath
-import System.Process
-
-import qualified Language.PureScript as P
+import Control.Concurrent.STM (newTVarIO, readTVarIO)
+import "monad-logger" Control.Monad.Logger (NoLoggingT(..))
+import Data.IORef (newIORef)
+import Data.Map qualified as Map
+import Language.PureScript.Ide (handleCommand)
+import Language.PureScript.Ide.Command (Command)
+import Language.PureScript.Ide.Error (IdeError)
+import Language.PureScript.Ide.Types
+import Protolude
+import System.Directory (doesDirectoryExist, getCurrentDirectory, makeAbsolute, removeDirectoryRecursive, setCurrentDirectory)
+import System.FilePath ((>))
+import System.Process (createProcess, getProcessExitCode, shell)
+
+import Language.PureScript qualified as P
defConfig :: IdeConfiguration
defConfig =
@@ -24,13 +22,15 @@ defConfig =
{ confLogLevel = LogNone
, confOutputPath = "output/"
, confGlobs = ["src/**/*.purs"]
- , confEditorMode = False
+ , confGlobsFromFile = Nothing
+ , confGlobsExclude = []
}
runIde' :: IdeConfiguration -> IdeState -> [Command] -> IO ([Either IdeError Success], IdeState)
runIde' conf s cs = do
stateVar <- newTVarIO s
- let env' = IdeEnvironment {ideStateVar = stateVar, ideConfiguration = conf}
+ ts <- newIORef Nothing
+ let env' = IdeEnvironment {ideStateVar = stateVar, ideConfiguration = conf, ideCacheDbTimestamp = ts}
r <- runNoLoggingT (runReaderT (traverse (runExceptT . handleCommand) cs) env')
newState <- readTVarIO stateVar
pure (r, newState)
@@ -45,19 +45,12 @@ volatileState s ds =
vs = IdeVolatileState (AstData Map.empty) (Map.fromList decls) Nothing
decls = map (first P.moduleNameFromString) ds
--- | Adding Annotations to IdeDeclarations
-ann :: IdeDeclarationAnn -> Annotation -> IdeDeclarationAnn
-ann (IdeDeclarationAnn _ d) a = IdeDeclarationAnn a d
-
annLoc :: IdeDeclarationAnn -> P.SourceSpan -> IdeDeclarationAnn
annLoc (IdeDeclarationAnn a d) loc = IdeDeclarationAnn a {_annLocation = Just loc} d
annExp :: IdeDeclarationAnn -> Text -> IdeDeclarationAnn
annExp (IdeDeclarationAnn a d) e = IdeDeclarationAnn a {_annExportedFrom = Just (mn e)} d
-annTyp :: IdeDeclarationAnn -> P.SourceType -> IdeDeclarationAnn
-annTyp (IdeDeclarationAnn a d) ta = IdeDeclarationAnn a {_annTypeAnnotation = Just ta} d
-
ida :: IdeDeclaration -> IdeDeclarationAnn
ida = IdeDeclarationAnn emptyAnn
@@ -66,13 +59,13 @@ ida = IdeDeclarationAnn emptyAnn
ideValue :: Text -> Maybe P.SourceType -> IdeDeclarationAnn
ideValue i ty = ida (IdeDeclValue (IdeValue (P.Ident i) (fromMaybe P.tyString ty)))
-ideType :: Text -> Maybe P.SourceKind -> [(P.ProperName 'P.ConstructorName, P.SourceType)] -> IdeDeclarationAnn
+ideType :: Text -> Maybe P.SourceType -> [(P.ProperName 'P.ConstructorName, P.SourceType)] -> IdeDeclarationAnn
ideType pn ki dtors = ida (IdeDeclType (IdeType (P.ProperName pn) (fromMaybe P.kindType ki) dtors))
-ideSynonym :: Text -> Maybe P.SourceType -> Maybe P.SourceKind -> IdeDeclarationAnn
+ideSynonym :: Text -> Maybe P.SourceType -> Maybe P.SourceType -> IdeDeclarationAnn
ideSynonym pn ty kind = ida (IdeDeclTypeSynonym (IdeTypeSynonym (P.ProperName pn) (fromMaybe P.tyString ty) (fromMaybe P.kindType kind)))
-ideTypeClass :: Text -> P.SourceKind -> [IdeInstance] -> IdeDeclarationAnn
+ideTypeClass :: Text -> P.SourceType -> [IdeInstance] -> IdeDeclarationAnn
ideTypeClass pn kind instances = ida (IdeDeclTypeClass (IdeTypeClass (P.ProperName pn) kind instances))
ideDtor :: Text -> Text -> Maybe P.SourceType -> IdeDeclarationAnn
@@ -84,22 +77,22 @@ ideValueOp opName ident precedence assoc t =
(IdeValueOperator
(P.OpName opName)
(bimap P.Ident P.ProperName <$> ident)
- (precedence)
+ precedence
(fromMaybe P.Infix assoc)
t))
-ideTypeOp :: Text -> P.Qualified Text -> Integer -> Maybe P.Associativity -> Maybe P.SourceKind -> IdeDeclarationAnn
+ideTypeOp :: Text -> P.Qualified Text -> Integer -> Maybe P.Associativity -> Maybe P.SourceType -> IdeDeclarationAnn
ideTypeOp opName ident precedence assoc k =
ida (IdeDeclTypeOperator
(IdeTypeOperator
(P.OpName opName)
(P.ProperName <$> ident)
- (precedence)
+ precedence
(fromMaybe P.Infix assoc)
k))
ideKind :: Text -> IdeDeclarationAnn
-ideKind pn = ida (IdeDeclKind (P.ProperName pn))
+ideKind pn = ideType pn (Just P.kindType) []
ideModule :: Text -> IdeDeclarationAnn
ideModule name = ida (IdeDeclModule (mn name))
@@ -136,9 +129,9 @@ inProject f = do
compileTestProject :: IO Bool
compileTestProject = inProject $ do
(_, _, _, procHandle) <-
- createProcess $ (shell $ "purs compile \"src/**/*.purs\"")
+ createProcess $ shell "purs compile \"src/**/*.purs\""
r <- tryNTimes 10 (getProcessExitCode procHandle)
- pure (fromMaybe False (isSuccess <$> r))
+ pure (maybe False isSuccess r)
isSuccess :: ExitCode -> Bool
isSuccess ExitSuccess = True
diff --git a/tests/Language/PureScript/Ide/UsageSpec.hs b/tests/Language/PureScript/Ide/UsageSpec.hs
index 3c619dce3b..0c399dfbf7 100644
--- a/tests/Language/PureScript/Ide/UsageSpec.hs
+++ b/tests/Language/PureScript/Ide/UsageSpec.hs
@@ -1,23 +1,21 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE NoImplicitPrelude #-}
module Language.PureScript.Ide.UsageSpec where
-import Protolude
+import Protolude
-import qualified Data.Text as Text
-import Language.PureScript.Ide.Command
-import Language.PureScript.Ide.Types
-import qualified Language.PureScript.Ide.Test as Test
-import qualified Language.PureScript as P
-import Test.Hspec
-import Data.Text.Read (decimal)
-import System.FilePath
+import Data.Text qualified as Text
+import Language.PureScript.Ide.Command (Command(..))
+import Language.PureScript.Ide.Types (IdeNamespace(..), Success(..))
+import Language.PureScript.Ide.Test qualified as Test
+import Language.PureScript qualified as P
+import Test.Hspec (Expectation, Spec, describe, it, shouldBe)
+import Data.Text.Read (decimal)
+import System.FilePath ((>))
load :: [Text] -> Command
load = LoadSync . map Test.mn
usage :: P.ModuleName -> Text -> IdeNamespace -> Command
-usage mn ident ns = FindUsages mn ident ns
+usage = FindUsages
shouldBeUsage :: P.SourceSpan -> (FilePath, Text) -> Expectation
shouldBeUsage usage' (fp, range) =
diff --git a/tests/Main.hs b/tests/Main.hs
index 37bf70b20a..a01dc09e1b 100644
--- a/tests/Main.hs
+++ b/tests/Main.hs
@@ -1,26 +1,27 @@
-{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DoAndIfThenElse #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE FlexibleInstances #-}
module Main (main) where
-import Prelude ()
-import Prelude.Compat
-
-import Test.Tasty
-
-import qualified TestCst
-import qualified TestCompiler
-import qualified TestCoreFn
-import qualified TestDocs
-import qualified TestHierarchy
-import qualified TestPrimDocs
-import qualified TestPsci
-import qualified TestIde
-import qualified TestPscPublish
-import qualified TestBundle
-import qualified TestUtils
+import Prelude
+
+import Test.Hspec
+
+import TestAst qualified
+import TestCompiler qualified
+import TestCoreFn qualified
+import TestCst qualified
+import TestDocs qualified
+import TestHierarchy qualified
+import TestInteractive qualified
+import TestPrimDocs qualified
+import TestPsci qualified
+import TestIde qualified
+import TestPscPublish qualified
+import TestSourceMaps qualified
+-- import TestBundle qualified
+import TestMake qualified
+import TestUtils qualified
+import TestGraph qualified
import System.IO (hSetEncoding, stdout, stderr, utf8)
@@ -29,39 +30,21 @@ main = do
hSetEncoding stdout utf8
hSetEncoding stderr utf8
- heading "Updating support code"
TestUtils.updateSupportCode
- cstTests <- TestCst.main
- ideTests <- TestIde.main
- compilerTests <- TestCompiler.main
- psciTests <- TestPsci.main
- pscBundleTests <- TestBundle.main
- coreFnTests <- TestCoreFn.main
- docsTests <- TestDocs.main
- primDocsTests <- TestPrimDocs.main
- publishTests <- TestPscPublish.main
- hierarchyTests <- TestHierarchy.main
-
- defaultMain $
- testGroup
- "Tests"
- [ cstTests
- , compilerTests
- , psciTests
- , pscBundleTests
- , ideTests
- , coreFnTests
- , docsTests
- , primDocsTests
- , publishTests
- , hierarchyTests
- ]
-
- where
- heading msg = do
- putStrLn ""
- putStrLn $ replicate 79 '#'
- putStrLn $ "# " ++ msg
- putStrLn $ replicate 79 '#'
- putStrLn ""
+ hspec $ do
+ describe "cst" TestCst.spec
+ describe "ast" TestAst.spec
+ describe "ide" TestIde.spec
+ beforeAll TestUtils.setupSupportModules $ do
+ describe "compiler" TestCompiler.spec
+ describe "sourcemaps" TestSourceMaps.spec
+ describe "make" TestMake.spec
+ describe "psci" TestPsci.spec
+ describe "interactive" TestInteractive.spec
+ describe "corefn" TestCoreFn.spec
+ describe "docs" TestDocs.spec
+ describe "prim-docs" TestPrimDocs.spec
+ describe "publish" TestPscPublish.spec
+ describe "hierarchy" TestHierarchy.spec
+ describe "graph" TestGraph.spec
diff --git a/tests/TestAst.hs b/tests/TestAst.hs
new file mode 100644
index 0000000000..bb2e880443
--- /dev/null
+++ b/tests/TestAst.hs
@@ -0,0 +1,98 @@
+{-# LANGUAGE TypeApplications #-}
+module TestAst where
+
+import Protolude hiding (Constraint, Type, (:+))
+
+import Control.Lens ((+~))
+import Control.Newtype (ala')
+import Generic.Random (genericArbitraryRecG, genericArbitraryUG, listOf', uniform, withBaseCase, (:+)(..))
+import Test.Hspec (Spec, describe, it)
+import Test.QuickCheck (Arbitrary(..), Gen, Property, Testable, counterexample, forAllShrink, subterms, (===))
+
+import Language.PureScript.Label (Label(..))
+import Language.PureScript.Names (pattern ByNullSourcePos, OpName(..), OpNameType(..), ProperName(..), ProperNameType(..), Qualified(..))
+import Language.PureScript.PSString (PSString)
+import Language.PureScript.Types (Constraint, ConstraintData, SkolemScope(..), Type(..), TypeVarVisibility(..), WildcardData, annForType, everythingOnTypes, everythingWithContextOnTypes, everywhereOnTypes, everywhereOnTypesM, everywhereOnTypesTopDownM, getAnnForType)
+
+spec :: Spec
+spec = do
+ describe "Language.PureScript.Types" $ do
+ describe "everywhereOnTypes" $ do
+ everywhereOnTypesSpec everywhereOnTypes
+ describe "everywhereOnTypesM" $ do
+ everywhereOnTypesSpec $ ala' Identity everywhereOnTypesM
+ describe "everywhereOnTypesTopDownM" $ do
+ everywhereOnTypesSpec $ ala' Identity everywhereOnTypesTopDownM
+ describe "everythingOnTypes" $ do
+ everythingOnTypesSpec everythingOnTypes
+ describe "everythingWithContextOnTypes" $ do
+ everythingOnTypesSpec $ \f g -> everythingWithContextOnTypes () [] f $ \s -> (s, ) . g
+
+everywhereOnTypesSpec :: ((Type Int -> Type Int) -> Type Int -> Type Int) -> Spec
+everywhereOnTypesSpec everywhereOnTypesUnderTest = do
+ it "should visit each type once" $
+ forAllShrink (genTypeAnnotatedWith (pure 0) (pure 1)) subterms $ \t ->
+ all (== 1) `isSatisfiedBy` everywhereOnTypesUnderTest (annForType +~ 1) t
+
+everythingOnTypesSpec :: (([Int] -> [Int] -> [Int]) -> (Type Int -> [Int]) -> Type Int -> [Int]) -> Spec
+everythingOnTypesSpec everythingOnTypesUnderTest = do
+ it "should visit each type once" $
+ forAllShrink (genTypeAnnotatedWith (pure 1) (pure 0)) subterms $ \t ->
+ everythingOnTypesUnderTest (++) (pure . getAnnForType) t ===
+ filter (== 1) (toList t)
+
+
+infixr 0 `isSatisfiedBy`
+isSatisfiedBy :: forall a p. Show a => Testable p => (a -> p) -> a -> Property
+isSatisfiedBy = liftA2 counterexample show
+
+genTypeAnnotatedWith :: forall a. Gen a -> Gen a -> Gen (Type a)
+genTypeAnnotatedWith genTypeAnn genConstraintAnn = genType where
+ generatorEnvironment
+ = genConstraint
+ :+ maybeOf genConstraintData
+ :+ Label <$> genPSString
+ :+ genPSString
+ :+ genQualified (OpName @'TypeOpName)
+ :+ genQualified (ProperName @'ClassName)
+ :+ genQualified (ProperName @'TypeName)
+ :+ genSkolemScope
+ :+ maybeOf genSkolemScope
+ :+ genText
+ :+ listOf' (listOf' genText)
+ :+ maybeOf genText
+ :+ genType
+ :+ listOf' genType
+ :+ maybeOf genType
+ :+ genWildcardData
+ :+ genVisibility
+
+ genConstraint :: Gen (Constraint a)
+ genConstraint = genericArbitraryUG (genConstraintAnn :+ generatorEnvironment)
+
+ genConstraintData :: Gen ConstraintData
+ genConstraintData = genericArbitraryUG generatorEnvironment
+
+ genQualified :: forall b. (Text -> b) -> Gen (Qualified b)
+ genQualified ctor = Qualified ByNullSourcePos . ctor <$> genText
+
+ genSkolemScope :: Gen SkolemScope
+ genSkolemScope = SkolemScope <$> arbitrary
+
+ genType :: Gen (Type a)
+ genType = genericArbitraryRecG (genTypeAnn :+ generatorEnvironment) uniform `withBaseCase` (TypeVar <$> genTypeAnn <*> genText)
+
+ genWildcardData :: Gen WildcardData
+ genWildcardData = genericArbitraryUG genText
+
+ maybeOf :: forall b. Gen b -> Gen (Maybe b)
+ maybeOf = genericArbitraryUG
+
+ genText :: Gen Text
+ genText = pure "x" -- Feel free to make this random if it matters at some point.
+
+ genPSString :: Gen PSString
+ genPSString = pure "x" -- Ditto.
+
+ genVisibility :: Gen TypeVarVisibility
+ genVisibility = pure TypeVarInvisible
diff --git a/tests/TestBundle.hs b/tests/TestBundle.hs
deleted file mode 100644
index cbdcf68e1c..0000000000
--- a/tests/TestBundle.hs
+++ /dev/null
@@ -1,95 +0,0 @@
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE DoAndIfThenElse #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE OverloadedStrings #-}
-
-module TestBundle where
-
-import Prelude ()
-import Prelude.Compat
-
-import qualified Language.PureScript as P
-import Language.PureScript.Bundle
-
-import Data.Function (on)
-import Data.List (minimumBy)
-
-import qualified Data.Map as M
-
-import Control.Monad
-import Control.Monad.IO.Class (liftIO)
-import Control.Monad.Trans.Except
-
-import System.Exit
-import System.Process
-import System.FilePath
-import System.IO
-import System.IO.UTF8
-import qualified System.FilePath.Glob as Glob
-
-import TestUtils
-import Test.Tasty
-import Test.Tasty.Hspec
-
-main :: IO TestTree
-main = testSpec "bundle" spec
-
-spec :: Spec
-spec = do
- (supportModules, supportExterns, supportForeigns) <- runIO $ setupSupportModules
- bundleTestCases <- runIO $ getTestFiles "bundle"
- outputFile <- runIO $ createOutputFile logfile
-
- context "Bundle examples" $
- forM_ bundleTestCases $ \testPurs -> do
- it ("'" <> takeFileName (getTestMain testPurs) <> "' should compile, bundle and run without error") $
- assertBundles supportModules supportExterns supportForeigns testPurs outputFile
- where
-
- -- Takes the test entry point from a group of purs files - this is determined
- -- by the file with the shortest path name, as everything but the main file
- -- will be under a subdirectory.
- getTestMain :: [FilePath] -> FilePath
- getTestMain = minimumBy (compare `on` length)
-
-assertBundles
- :: [P.Module]
- -> [P.ExternsFile]
- -> M.Map P.ModuleName FilePath
- -> [FilePath]
- -> Handle
- -> Expectation
-assertBundles supportModules supportExterns supportForeigns inputFiles outputFile =
- assert supportModules supportExterns supportForeigns inputFiles checkMain $ \e ->
- case e of
- Left errs -> return . Just . P.prettyPrintMultipleErrors P.defaultPPEOptions $ errs
- Right _ -> do
- process <- findNodeProcess
- jsFiles <- Glob.globDir1 (Glob.compile "**/*.js") modulesDir
- let entryPoint = modulesDir > "index.js"
- let entryModule = map (`ModuleIdentifier` Regular) ["Main"]
- bundled <- runExceptT $ do
- input <- forM jsFiles $ \filename -> do
- js <- liftIO $ readUTF8File filename
- mid <- guessModuleIdentifier filename
- length js `seq` return (mid, Just filename, js)
- bundleSM input entryModule (Just $ "Main") "PS" (Just entryPoint)
- case bundled of
- Right (_, js) -> do
- writeUTF8File entryPoint js
- result <- traverse (\node -> readProcessWithExitCode node [entryPoint] "") process
- hPutStrLn outputFile $ "\n" <> takeFileName (last inputFiles) <> ":"
- case result of
- Just (ExitSuccess, out, err)
- | not (null err) -> return $ Just $ "Test wrote to stderr:\n\n" <> err
- | not (null out) && trim (last (lines out)) == "Done" -> do
- hPutStr outputFile out
- return Nothing
- | otherwise -> return $ Just $ "Test did not finish with 'Done':\n\n" <> out
- Just (ExitFailure _, _, err) -> return $ Just err
- Nothing -> return $ Just "Couldn't find node.js executable"
- Left err -> return . Just $ "Coud not bundle: " ++ show err
-
-logfile :: FilePath
-logfile = "bundle-tests.out"
diff --git a/tests/TestCompiler.hs b/tests/TestCompiler.hs
index 5c082dafa3..c13ca20104 100644
--- a/tests/TestCompiler.hs
+++ b/tests/TestCompiler.hs
@@ -1,8 +1,4 @@
-{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DoAndIfThenElse #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE OverloadedStrings #-}
module TestCompiler where
@@ -20,111 +16,109 @@ module TestCompiler where
-- -- @shouldFailWith TypesDoNotUnify
-- -- @shouldFailWith TypesDoNotUnify
-- -- @shouldFailWith TransitiveExportError
+--
+-- Warning and failing tests also check their output against the relative
+-- golden files (`.out`). The golden files are generated automatically when
+-- missing, and can be updated by setting the "HSPEC_ACCEPT" environment
+-- variable, e.g. by running `HSPEC_ACCEPT=true stack test`.
-import Prelude ()
-import Prelude.Compat
+import Prelude
-import qualified Language.PureScript as P
+import Language.PureScript qualified as P
+import Language.PureScript.Interactive.IO (readNodeProcessWithExitCode)
import Control.Arrow ((>>>))
+import Data.ByteString qualified as BS
import Data.Function (on)
-import Data.List (sort, stripPrefix, intercalate, minimumBy)
+import Data.List (sort, stripPrefix, minimumBy)
import Data.Maybe (mapMaybe)
-import qualified Data.Text as T
+import Data.Text qualified as T
+import Data.Text.Encoding qualified as T
-import qualified Data.Map as M
-import Control.Monad
+import Control.Monad (forM_, when)
-import System.Exit
-import System.Process
-import System.FilePath
-import System.IO
+import System.Exit (ExitCode(..))
+import System.FilePath (pathSeparator, replaceExtension, takeFileName, (>))
+import System.IO (Handle, hPutStr, hPutStrLn)
import System.IO.UTF8 (readUTF8File)
-import TestUtils
-import Test.Tasty
-import Test.Tasty.Hspec
+import Text.Regex.Base (RegexContext(..), RegexMaker(..))
+import Text.Regex.TDFA (Regex)
-main :: IO TestTree
-main = testSpec "compiler" spec
+import TestUtils (ExpectedModuleName(..), SupportModules, compile, createOutputFile, getTestFiles, goldenVsString, modulesDir, trim)
+import Test.Hspec (Expectation, SpecWith, beforeAllWith, describe, expectationFailure, it, runIO)
-spec :: Spec
+spec :: SpecWith SupportModules
spec = do
- (supportModules, supportExterns, supportForeigns) <- runIO $ setupSupportModules
-
- (passingTestCases, warningTestCases, failingTestCases) <- runIO $
- (,,) <$> getTestFiles "passing"
- <*> getTestFiles "warning"
- <*> getTestFiles "failing"
-
- outputFile <- runIO $ createOutputFile logfile
-
- context "Passing examples" $
- forM_ passingTestCases $ \testPurs ->
- it ("'" <> takeFileName (getTestMain testPurs) <> "' should compile and run without error") $
- assertCompiles supportModules supportExterns supportForeigns testPurs outputFile
-
- context "Warning examples" $
+ passingTests
+ warningTests
+ failingTests
+ optimizeTests
+
+passingTests :: SpecWith SupportModules
+passingTests = do
+ passingTestCases <- runIO $ getTestFiles "passing"
+
+ describe "Passing examples" $
+ beforeAllWith ((<$> createOutputFile logfile) . (,)) $
+ forM_ passingTestCases $ \testPurs ->
+ it ("'" <> takeFileName (getTestMain testPurs) <> "' should compile and run without error") $ \(support, outputFile) ->
+ assertCompiles support testPurs outputFile
+
+warningTests :: SpecWith SupportModules
+warningTests = do
+ warningTestCases <- runIO $ getTestFiles "warning"
+
+ describe "Warning examples" $
forM_ warningTestCases $ \testPurs -> do
let mainPath = getTestMain testPurs
- expectedWarnings <- runIO $ getShouldWarnWith mainPath
- it ("'" <> takeFileName mainPath <> "' should compile with warning(s) '" <> intercalate "', '" expectedWarnings <> "'") $
- assertCompilesWithWarnings supportModules supportExterns supportForeigns testPurs expectedWarnings
+ it ("'" <> takeFileName mainPath <> "' should compile with expected warning(s)") $ \support -> do
+ expectedWarnings <- getShouldWarnWith mainPath
+ assertCompilesWithWarnings support testPurs expectedWarnings
- context "Failing examples" $
+failingTests :: SpecWith SupportModules
+failingTests = do
+ failingTestCases <- runIO $ getTestFiles "failing"
+
+ describe "Failing examples" $ do
forM_ failingTestCases $ \testPurs -> do
let mainPath = getTestMain testPurs
- expectedFailures <- runIO $ getShouldFailWith mainPath
- it ("'" <> takeFileName mainPath <> "' should fail with '" <> intercalate "', '" expectedFailures <> "'") $
- assertDoesNotCompile supportModules supportExterns supportForeigns testPurs expectedFailures
-
- where
-
- -- Takes the test entry point from a group of purs files - this is determined
- -- by the file with the shortest path name, as everything but the main file
- -- will be under a subdirectory.
- getTestMain :: [FilePath] -> FilePath
- getTestMain = minimumBy (compare `on` length)
-
- -- Scans a file for @shouldFailWith directives in the comments, used to
- -- determine expected failures
- getShouldFailWith :: FilePath -> IO [String]
- getShouldFailWith = extractPragma "shouldFailWith"
+ it ("'" <> takeFileName mainPath <> "' should fail to compile") $ \support -> do
+ expectedFailures <- getShouldFailWith mainPath
+ assertDoesNotCompile support testPurs expectedFailures
- -- Scans a file for @shouldWarnWith directives in the comments, used to
- -- determine expected warnings
- getShouldWarnWith :: FilePath -> IO [String]
- getShouldWarnWith = extractPragma "shouldWarnWith"
+optimizeTests :: SpecWith SupportModules
+optimizeTests = do
+ optimizeTestCases <- runIO $ getTestFiles "optimize"
- extractPragma :: String -> FilePath -> IO [String]
- extractPragma pragma = fmap go . readUTF8File
- where
- go = lines >>> mapMaybe (stripPrefix ("-- @" ++ pragma ++ " ")) >>> map trim
+ describe "Optimization examples" $
+ forM_ optimizeTestCases $ \testPurs ->
+ it ("'" <> takeFileName (getTestMain testPurs) <> "' should compile to expected output") $ \support ->
+ assertCompilesToExpectedOutput support testPurs
-
-checkShouldFailWith :: [String] -> P.MultipleErrors -> Maybe String
-checkShouldFailWith expected errs =
+checkShouldReport :: [String] -> (P.MultipleErrors -> String) -> P.MultipleErrors -> Expectation
+checkShouldReport expected prettyPrintDiagnostics errs =
let actual = map P.errorCode $ P.runMultipleErrors errs
in if sort expected == sort (map T.unpack actual)
then checkPositioned errs
- else Just $ "Expected these errors: " ++ show expected ++ ", but got these: "
- ++ show actual ++ ", full error messages: \n"
- ++ unlines (map (P.renderBox . P.prettyPrintSingleError P.defaultPPEOptions) (P.runMultipleErrors errs))
+ else expectationFailure $ "Expected these diagnostics: " ++ show expected ++ ", but got these: "
+ ++ show actual ++ ", full diagnostic messages: \n"
+ ++ prettyPrintDiagnostics errs
-checkPositioned :: P.MultipleErrors -> Maybe String
+checkPositioned :: P.MultipleErrors -> Expectation
checkPositioned errs =
case mapMaybe guardSpans (P.runMultipleErrors errs) of
[] ->
- Nothing
+ pure ()
errs' ->
- Just
- $ "Found errors with missing source spans:\n"
+ expectationFailure
+ $ "Found diagnostics with missing source spans:\n"
++ unlines (map (P.renderBox . P.prettyPrintSingleError P.defaultPPEOptions) errs')
where
guardSpans :: P.ErrorMessage -> Maybe P.ErrorMessage
guardSpans err = case P.errorSpan err of
- Just ss | any (not . isNonsenseSpan) ss -> Nothing
+ Just ss | not $ all isNonsenseSpan ss -> Nothing
_ -> Just err
isNonsenseSpan :: P.SourceSpan -> Bool
@@ -135,74 +129,135 @@ checkPositioned errs =
emptyPos = P.SourcePos 0 0
assertCompiles
- :: [P.Module]
- -> [P.ExternsFile]
- -> M.Map P.ModuleName FilePath
+ :: SupportModules
-> [FilePath]
-> Handle
-> Expectation
-assertCompiles supportModules supportExterns supportForeigns inputFiles outputFile =
- assert supportModules supportExterns supportForeigns inputFiles checkMain $ \e ->
- case e of
- Left errs -> return . Just . P.prettyPrintMultipleErrors P.defaultPPEOptions $ errs
- Right _ -> do
- process <- findNodeProcess
- let entryPoint = modulesDir > "index.js"
- writeFile entryPoint "require('Main').main()"
- result <- traverse (\node -> readProcessWithExitCode node [entryPoint] "") process
- hPutStrLn outputFile $ "\n" <> takeFileName (last inputFiles) <> ":"
- case result of
- Just (ExitSuccess, out, err)
- | not (null err) -> return $ Just $ "Test wrote to stderr:\n\n" <> err
- | not (null out) && trim (last (lines out)) == "Done" -> do
- hPutStr outputFile out
- return Nothing
- | otherwise -> return $ Just $ "Test did not finish with 'Done':\n\n" <> out
- Just (ExitFailure _, _, err) -> return $ Just err
- Nothing -> return $ Just "Couldn't find node.js executable"
+assertCompiles support inputFiles outputFile = do
+ (fileContents, (result, _)) <- compile (Just IsMain) support inputFiles
+ let errorOptions = P.defaultPPEOptions { P.ppeFileContents = fileContents }
+ case result of
+ Left errs -> expectationFailure . P.prettyPrintMultipleErrors errorOptions $ errs
+ Right _ -> do
+ let entryPoint = modulesDir > "index.js"
+ writeFile entryPoint "import('./Main/index.js').then(({ main }) => main());"
+ nodeResult <- readNodeProcessWithExitCode Nothing [entryPoint] ""
+ hPutStrLn outputFile $ "\n" <> takeFileName (last inputFiles) <> ":"
+ case nodeResult of
+ Right (ExitSuccess, out, err)
+ | not (null err) -> expectationFailure $ "Test wrote to stderr:\n\n" <> err
+ | not (null out) && trim (last (lines out)) == "Done" -> hPutStr outputFile out
+ | otherwise -> expectationFailure $ "Test did not finish with 'Done':\n\n" <> out
+ Right (ExitFailure _, _, err) -> expectationFailure err
+ Left err -> expectationFailure err
assertCompilesWithWarnings
- :: [P.Module]
- -> [P.ExternsFile]
- -> M.Map P.ModuleName FilePath
+ :: SupportModules
-> [FilePath]
-> [String]
-> Expectation
-assertCompilesWithWarnings supportModules supportExterns supportForeigns inputFiles shouldWarnWith =
- assert supportModules supportExterns supportForeigns inputFiles checkMain $ \e ->
- case e of
- Left errs ->
- return . Just . P.prettyPrintMultipleErrors P.defaultPPEOptions $ errs
- Right warnings ->
- return
- . fmap (printAllWarnings warnings)
- $ checkShouldFailWith shouldWarnWith warnings
-
- where
- printAllWarnings warnings =
- (<> "\n\n" <> P.prettyPrintMultipleErrors P.defaultPPEOptions warnings)
+assertCompilesWithWarnings support inputFiles shouldWarnWith = do
+ (fileContents, result'@(result, warnings)) <- compile Nothing support inputFiles
+ let errorOptions = P.defaultPPEOptions { P.ppeFileContents = fileContents }
+ case result of
+ Left errs ->
+ expectationFailure . P.prettyPrintMultipleErrors errorOptions $ errs
+ Right _ -> do
+ checkShouldReport shouldWarnWith (P.prettyPrintMultipleWarnings errorOptions) warnings
+ goldenVsString
+ (replaceExtension (getTestMain inputFiles) ".out")
+ (return . T.encodeUtf8 . T.pack $ printDiagnosticsForGoldenTest fileContents result')
assertDoesNotCompile
- :: [P.Module]
- -> [P.ExternsFile]
- -> M.Map P.ModuleName FilePath
+ :: SupportModules
-> [FilePath]
-> [String]
-> Expectation
-assertDoesNotCompile supportModules supportExterns supportForeigns inputFiles shouldFailWith =
- assert supportModules supportExterns supportForeigns inputFiles noPreCheck $ \e ->
- case e of
- Left errs ->
- return $ if null shouldFailWith
- then Just $ "shouldFailWith declaration is missing (errors were: "
- ++ show (map P.errorCode (P.runMultipleErrors errs))
- ++ ")"
- else checkShouldFailWith shouldFailWith errs
- Right _ ->
- return $ Just "Should not have compiled"
+assertDoesNotCompile support inputFiles shouldFailWith = do
+ (fileContents, result) <- compile Nothing support inputFiles
+ let errorOptions = P.defaultPPEOptions { P.ppeFileContents = fileContents }
+ case fst result of
+ Left errs -> do
+ when (null shouldFailWith)
+ (expectationFailure $
+ "shouldFailWith declaration is missing (errors were: "
+ ++ show (map P.errorCode (P.runMultipleErrors errs))
+ ++ ")")
+ checkShouldReport shouldFailWith (P.prettyPrintMultipleErrors errorOptions) errs
+ goldenVsString
+ (replaceExtension (getTestMain inputFiles) ".out")
+ (return . T.encodeUtf8 . T.pack $ printDiagnosticsForGoldenTest fileContents result)
+ Right _ ->
+ expectationFailure "Should not have compiled"
+
+assertCompilesToExpectedOutput
+ :: SupportModules
+ -> [FilePath]
+ -> Expectation
+assertCompilesToExpectedOutput support inputFiles = do
+ (fileContents, (result, _)) <- compile Nothing support inputFiles
+ let errorOptions = P.defaultPPEOptions { P.ppeFileContents = fileContents }
+ case result of
+ Left errs -> expectationFailure . P.prettyPrintMultipleErrors errorOptions $ errs
+ Right _ ->
+ goldenVsString
+ (replaceExtension (getTestMain inputFiles) ".out.js")
+ (BS.readFile $ modulesDir > "Main/index.js")
+
+-- Prints a set of diagnostics (i.e. errors or warnings) as a string, in order
+-- to compare it to the contents of a golden test file.
+printDiagnosticsForGoldenTest :: [(FilePath, T.Text)] -> (Either P.MultipleErrors a, P.MultipleErrors) -> String
+printDiagnosticsForGoldenTest fileContents (result, warnings) =
+ normalizePaths $ case result of
+ Left errs ->
+ -- TODO: should probably include warnings when failing?
+ P.prettyPrintMultipleErrors errorOptions errs
+ Right _ ->
+ P.prettyPrintMultipleWarnings errorOptions warnings
+ where
+ errorOptions = P.defaultPPEOptions { P.ppeFileContents = fileContents }
+
+-- Replaces Windows-style paths in an error or warning with POSIX paths
+normalizePaths :: String -> String
+normalizePaths = if pathSeparator == '\\'
+ then replaceMatches " [0-9A-Za-z_-]+(\\\\[0-9A-Za-z_-]+)+\\.[A-Za-z]+\\>" (map turnSlash)
+ else id
+ where
+ turnSlash '\\' = '/'
+ turnSlash c = c
+-- Uses a function to replace all matches of a regular expression in a string
+replaceMatches :: String -> (String -> String) -> String -> String
+replaceMatches reString phi = go
where
- noPreCheck = const (return ())
+ re :: Regex
+ re = makeRegex reString
+ go :: String -> String
+ go haystack =
+ let (prefix, needle, suffix) = match re haystack
+ in prefix ++ (if null needle then "" else phi needle ++ go suffix)
+
+-- Takes the test entry point from a group of purs files - this is determined
+-- by the file with the shortest path name, as everything but the main file
+-- will be under a subdirectory.
+getTestMain :: [FilePath] -> FilePath
+getTestMain = minimumBy (compare `on` length)
+
+-- Scans a file for @shouldFailWith directives in the comments, used to
+-- determine expected failures
+getShouldFailWith :: FilePath -> IO [String]
+getShouldFailWith = extractPragma "shouldFailWith"
+
+-- Scans a file for @shouldWarnWith directives in the comments, used to
+-- determine expected warnings
+getShouldWarnWith :: FilePath -> IO [String]
+getShouldWarnWith = extractPragma "shouldWarnWith"
+
+extractPragma :: String -> FilePath -> IO [String]
+extractPragma pragma = fmap go . readUTF8File
+ where
+ go = lines >>> mapMaybe (stripPrefix ("-- @" ++ pragma ++ " ")) >>> map trim
+
logfile :: FilePath
logfile = "psc-tests.out"
diff --git a/tests/TestCoreFn.hs b/tests/TestCoreFn.hs
index 2fcb158291..588c6817b4 100644
--- a/tests/TestCoreFn.hs
+++ b/tests/TestCoreFn.hs
@@ -1,31 +1,24 @@
-{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DoAndIfThenElse #-}
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE OverloadedStrings #-}
-module TestCoreFn (main) where
+module TestCoreFn (spec) where
-import Prelude ()
-import Prelude.Compat
+import Prelude
-import Data.Aeson
-import Data.Aeson.Types as Aeson
-import Data.Version
+import Data.Aeson (Result(..), Value)
+import Data.Aeson.Types (parse)
+import Data.Map as M
+import Data.Version (Version(..))
-import Language.PureScript.AST.Literals
-import Language.PureScript.AST.SourcePos
-import Language.PureScript.Comments
-import Language.PureScript.CoreFn
-import Language.PureScript.CoreFn.FromJSON
-import Language.PureScript.CoreFn.ToJSON
-import Language.PureScript.Names
-import Language.PureScript.PSString
+import Language.PureScript.AST.Literals (Literal(..))
+import Language.PureScript.AST.SourcePos (SourcePos(..), SourceSpan(..))
+import Language.PureScript.Comments (Comment(..))
+import Language.PureScript.CoreFn (Ann, Bind(..), Binder(..), CaseAlternative(..), ConstructorType(..), Expr(..), Meta(..), Module(..), ssAnn)
+import Language.PureScript.CoreFn.FromJSON (moduleFromJSON)
+import Language.PureScript.CoreFn.ToJSON (moduleToJSON)
+import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName(..), ProperName(..), Qualified(..), QualifiedBy(..))
+import Language.PureScript.PSString (mkString)
-import Test.Tasty
-import Test.Tasty.Hspec
-
-main :: IO TestTree
-main = testSpec "corefn" spec
+import Test.Hspec (Spec, context, shouldBe, shouldSatisfy, specify)
parseModule :: Value -> Result (Version, Module Ann)
parseModule = parse moduleFromJSON
@@ -37,61 +30,78 @@ parseMod m =
in snd <$> parseModule (moduleToJSON v m)
isSuccess :: Result a -> Bool
-isSuccess (Aeson.Success _) = True
+isSuccess (Success _) = True
isSuccess _ = False
spec :: Spec
-spec = context "CoreFnFromJsonTest" $ do
- let mn = ModuleName [ProperName "Example", ProperName "Main"]
+spec = context "CoreFnFromJson" $ do
+ let mn = ModuleName "Example.Main"
mp = "src/Example/Main.purs"
ss = SourceSpan mp (SourcePos 0 0) (SourcePos 0 0)
ann = ssAnn ss
+ specify "should parse version" $ do
+ let v = Version [0, 13, 6] []
+ m = Module ss [] mn mp [] [] M.empty [] []
+ r = fst <$> parseModule (moduleToJSON v m)
+ r `shouldSatisfy` isSuccess
+ case r of
+ Error _ -> return ()
+ Success v' -> v' `shouldBe` v
+
specify "should parse an empty module" $ do
- let r = parseMod $ Module ss [] mn mp [] [] [] []
+ let r = parseMod $ Module ss [] mn mp [] [] M.empty [] []
r `shouldSatisfy` isSuccess
case r of
Error _ -> return ()
- Aeson.Success m -> moduleName m `shouldBe` mn
+ Success m -> moduleName m `shouldBe` mn
specify "should parse source span" $ do
- let r = parseMod $ Module ss [] mn mp [] [] [] []
+ let r = parseMod $ Module ss [] mn mp [] [] M.empty [] []
r `shouldSatisfy` isSuccess
case r of
Error _ -> return ()
- Aeson.Success m -> moduleSourceSpan m `shouldBe` ss
+ Success m -> moduleSourceSpan m `shouldBe` ss
specify "should parse module path" $ do
- let r = parseMod $ Module ss [] mn mp [] [] [] []
+ let r = parseMod $ Module ss [] mn mp [] [] M.empty [] []
r `shouldSatisfy` isSuccess
case r of
Error _ -> return ()
- Aeson.Success m -> modulePath m `shouldBe` mp
+ Success m -> modulePath m `shouldBe` mp
specify "should parse imports" $ do
- let r = parseMod $ Module ss [] mn mp [(ann, mn)] [] [] []
+ let r = parseMod $ Module ss [] mn mp [(ann, mn)] [] M.empty [] []
r `shouldSatisfy` isSuccess
case r of
Error _ -> return ()
- Aeson.Success m -> moduleImports m `shouldBe` [(ann, mn)]
+ Success m -> moduleImports m `shouldBe` [(ann, mn)]
specify "should parse exports" $ do
- let r = parseMod $ Module ss [] mn mp [] [Ident "exp"] [] []
+ let r = parseMod $ Module ss [] mn mp [] [Ident "exp"] M.empty [] []
r `shouldSatisfy` isSuccess
case r of
Error _ -> return ()
- Aeson.Success m -> moduleExports m `shouldBe` [Ident "exp"]
+ Success m -> moduleExports m `shouldBe` [Ident "exp"]
+
+ specify "should parse re-exports" $ do
+ let r = parseMod $ Module ss [] mn mp [] [] (M.singleton (ModuleName "Example.A") [Ident "exp"]) [] []
+ r `shouldSatisfy` isSuccess
+ case r of
+ Error _ -> return ()
+ Success m -> moduleReExports m `shouldBe` M.singleton (ModuleName "Example.A") [Ident "exp"]
+
specify "should parse foreign" $ do
- let r = parseMod $ Module ss [] mn mp [] [] [Ident "exp"] []
+ let r = parseMod $ Module ss [] mn mp [] [] M.empty [Ident "exp"] []
r `shouldSatisfy` isSuccess
case r of
Error _ -> return ()
- Aeson.Success m -> moduleForeign m `shouldBe` [Ident "exp"]
+ Success m -> moduleForeign m `shouldBe` [Ident "exp"]
context "Expr" $ do
specify "should parse literals" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "x1") $ Literal ann (NumericLiteral (Left 1))
, NonRec ann (Ident "x2") $ Literal ann (NumericLiteral (Right 1.0))
, NonRec ann (Ident "x3") $ Literal ann (StringLiteral (mkString "abc"))
@@ -103,45 +113,55 @@ spec = context "CoreFnFromJsonTest" $ do
parseMod m `shouldSatisfy` isSuccess
specify "should parse Constructor" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "constructor") $ Constructor ann (ProperName "Either") (ProperName "Left") [Ident "value0"] ]
parseMod m `shouldSatisfy` isSuccess
specify "should parse Accessor" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "x") $
Accessor ann (mkString "field") (Literal ann $ ObjectLiteral [(mkString "field", Literal ann (NumericLiteral (Left 1)))]) ]
parseMod m `shouldSatisfy` isSuccess
specify "should parse ObjectUpdate" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "objectUpdate") $
ObjectUpdate ann
(Literal ann $ ObjectLiteral [(mkString "field", Literal ann (StringLiteral (mkString "abc")))])
+ (Just [mkString "unchangedField"])
[(mkString "field", Literal ann (StringLiteral (mkString "xyz")))]
]
parseMod m `shouldSatisfy` isSuccess
specify "should parse Abs" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "abs")
- $ Abs ann (Ident "x") (Var ann (Qualified (Just mn) (Ident "x")))
+ $ Abs ann (Ident "x") (Var ann (Qualified (ByModuleName mn) (Ident "x")))
]
parseMod m `shouldSatisfy` isSuccess
specify "should parse App" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "app")
$ App ann
- (Abs ann (Ident "x") (Var ann (Qualified Nothing (Ident "x"))))
+ (Abs ann (Ident "x") (Var ann (Qualified ByNullSourcePos (Ident "x"))))
(Literal ann (CharLiteral 'c'))
]
parseMod m `shouldSatisfy` isSuccess
+ specify "should parse UnusedIdent in Abs" $ do
+ let i = NonRec ann (Ident "f") (Abs ann UnusedIdent (Var ann (Qualified ByNullSourcePos (Ident "x"))))
+ let r = parseMod $ Module ss [] mn mp [] [] M.empty [] [i]
+ r `shouldSatisfy` isSuccess
+ case r of
+ Error _ -> pure ()
+ Success Module{..} ->
+ moduleDecls `shouldBe` [i]
+
specify "should parse Case" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "case") $
- Case ann [Var ann (Qualified Nothing (Ident "x"))]
+ Case ann [Var ann (Qualified ByNullSourcePos (Ident "x"))]
[ CaseAlternative
[ NullBinder ann ]
(Right (Literal ann (CharLiteral 'a')))
@@ -150,9 +170,9 @@ spec = context "CoreFnFromJsonTest" $ do
parseMod m `shouldSatisfy` isSuccess
specify "should parse Case with guards" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "case") $
- Case ann [Var ann (Qualified Nothing (Ident "x"))]
+ Case ann [Var ann (Qualified ByNullSourcePos (Ident "x"))]
[ CaseAlternative
[ NullBinder ann ]
(Left [(Literal ann (BooleanLiteral True), Literal ann (CharLiteral 'a'))])
@@ -161,48 +181,48 @@ spec = context "CoreFnFromJsonTest" $ do
parseMod m `shouldSatisfy` isSuccess
specify "should parse Let" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "case") $
Let ann
- [ Rec [((ann, Ident "a"), Var ann (Qualified Nothing (Ident "x")))] ]
+ [ Rec [((ann, Ident "a"), Var ann (Qualified ByNullSourcePos (Ident "x")))] ]
(Literal ann (BooleanLiteral True))
]
parseMod m `shouldSatisfy` isSuccess
context "Meta" $ do
specify "should parse IsConstructor" $ do
- let m = Module ss [] mn mp [] [] []
- [ NonRec (ss, [], Nothing, Just (IsConstructor ProductType [Ident "x"])) (Ident "x") $
- Literal (ss, [], Nothing, Just (IsConstructor SumType [])) (CharLiteral 'a')
+ let m = Module ss [] mn mp [] [] M.empty []
+ [ NonRec (ss, [], Just (IsConstructor ProductType [Ident "x"])) (Ident "x") $
+ Literal (ss, [], Just (IsConstructor SumType [])) (CharLiteral 'a')
]
parseMod m `shouldSatisfy` isSuccess
specify "should parse IsNewtype" $ do
- let m = Module ss [] mn mp [] [] []
- [ NonRec (ss, [], Nothing, Just IsNewtype) (Ident "x") $
+ let m = Module ss [] mn mp [] [] M.empty []
+ [ NonRec (ss, [], Just IsNewtype) (Ident "x") $
Literal ann (CharLiteral 'a')
]
parseMod m `shouldSatisfy` isSuccess
specify "should parse IsTypeClassConstructor" $ do
- let m = Module ss [] mn mp [] [] []
- [ NonRec (ss, [], Nothing, Just IsTypeClassConstructor) (Ident "x") $
+ let m = Module ss [] mn mp [] [] M.empty []
+ [ NonRec (ss, [], Just IsTypeClassConstructor) (Ident "x") $
Literal ann (CharLiteral 'a')
]
parseMod m `shouldSatisfy` isSuccess
specify "should parse IsForeign" $ do
- let m = Module ss [] mn mp [] [] []
- [ NonRec (ss, [], Nothing, Just IsForeign) (Ident "x") $
+ let m = Module ss [] mn mp [] [] M.empty []
+ [ NonRec (ss, [], Just IsForeign) (Ident "x") $
Literal ann (CharLiteral 'a')
]
parseMod m `shouldSatisfy` isSuccess
context "Binders" $ do
specify "should parse LiteralBinder" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "case") $
- Case ann [Var ann (Qualified Nothing (Ident "x"))]
+ Case ann [Var ann (Qualified ByNullSourcePos (Ident "x"))]
[ CaseAlternative
[ LiteralBinder ann (BooleanLiteral True) ]
(Right (Literal ann (CharLiteral 'a')))
@@ -211,14 +231,14 @@ spec = context "CoreFnFromJsonTest" $ do
parseMod m `shouldSatisfy` isSuccess
specify "should parse VarBinder" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "case") $
- Case ann [Var ann (Qualified Nothing (Ident "x"))]
+ Case ann [Var ann (Qualified ByNullSourcePos (Ident "x"))]
[ CaseAlternative
[ ConstructorBinder
ann
- (Qualified (Just (ModuleName [ProperName "Data", ProperName "Either"])) (ProperName "Either"))
- (Qualified Nothing (ProperName "Left"))
+ (Qualified (ByModuleName (ModuleName "Data.Either")) (ProperName "Either"))
+ (Qualified ByNullSourcePos (ProperName "Left"))
[VarBinder ann (Ident "z")]
]
(Right (Literal ann (CharLiteral 'a')))
@@ -227,9 +247,9 @@ spec = context "CoreFnFromJsonTest" $ do
parseMod m `shouldSatisfy` isSuccess
specify "should parse NamedBinder" $ do
- let m = Module ss [] mn mp [] [] []
+ let m = Module ss [] mn mp [] [] M.empty []
[ NonRec ann (Ident "case") $
- Case ann [Var ann (Qualified Nothing (Ident "x"))]
+ Case ann [Var ann (Qualified ByNullSourcePos (Ident "x"))]
[ CaseAlternative
[ NamedBinder ann (Ident "w") (NamedBinder ann (Ident "w'") (VarBinder ann (Ident "w''"))) ]
(Right (Literal ann (CharLiteral 'a')))
@@ -239,9 +259,9 @@ spec = context "CoreFnFromJsonTest" $ do
context "Comments" $ do
specify "should parse LineComment" $ do
- let m = Module ss [ LineComment "line" ] mn mp [] [] [] []
+ let m = Module ss [ LineComment "line" ] mn mp [] [] M.empty [] []
parseMod m `shouldSatisfy` isSuccess
specify "should parse BlockComment" $ do
- let m = Module ss [ BlockComment "block" ] mn mp [] [] [] []
+ let m = Module ss [ BlockComment "block" ] mn mp [] [] M.empty [] []
parseMod m `shouldSatisfy` isSuccess
diff --git a/tests/TestCst.hs b/tests/TestCst.hs
index abaddc07c1..6f4a227e63 100644
--- a/tests/TestCst.hs
+++ b/tests/TestCst.hs
@@ -1,43 +1,37 @@
-{-# LANGUAGE LambdaCase #-}
-{-# LANGUAGE OverloadedStrings #-}
module TestCst where
import Prelude
-import Control.Monad (when)
-import qualified Data.ByteString.Lazy as BS
+import Control.Monad (when, forM_)
import Data.Maybe (fromMaybe)
import Data.Text (Text)
-import qualified Data.Text as Text
-import qualified Data.Text.Encoding as Text
-import qualified Data.Text.IO as Text
-import Test.Tasty (TestTree, testGroup)
-import Test.Tasty.Golden (goldenVsString, findByExtension)
-import Test.Tasty.QuickCheck
+import Data.Text qualified as Text
+import Data.Text.Encoding qualified as Text
+import Data.Text.IO qualified as Text
+import Test.Hspec (Spec, describe, it, runIO, specify)
+import Test.QuickCheck (Arbitrary(..), Gen, Testable(..), arbitrarySizedNatural, arbitraryUnicodeChar, discard, elements, frequency, listOf, listOf1, oneof, resize)
+import TestUtils (getTestFiles, goldenVsString)
import Text.Read (readMaybe)
import Language.PureScript.CST.Errors as CST
import Language.PureScript.CST.Lexer as CST
import Language.PureScript.CST.Print as CST
-import Language.PureScript.CST.Types
+import Language.PureScript.CST.Types (SourceToken(..), Token(..))
import System.FilePath (takeBaseName, replaceExtension)
-main :: IO TestTree
-main = do
- lytTests <- layoutTests
- pure $ testGroup "cst"
- [ lytTests
- , litTests
- ]
-
-layoutTests :: IO TestTree
-layoutTests = do
- pursFiles <- findByExtension [".purs"] "./tests/purs/layout"
- return $ testGroup "Layout golden tests" $ do
- file <- pursFiles
- pure $ goldenVsString
- (takeBaseName file)
- (replaceExtension file ".out")
- (BS.fromStrict . Text.encodeUtf8 <$> runLexer file)
+spec :: Spec
+spec = do
+ layoutSpec
+ literalsSpec
+
+layoutSpec :: Spec
+layoutSpec = do
+ pursFiles <- runIO $ concat <$> getTestFiles "layout"
+ describe "Layout golden tests" $ do
+ forM_ pursFiles $ \file ->
+ it (takeBaseName file) $
+ goldenVsString
+ (replaceExtension file ".out")
+ (Text.encodeUtf8 <$> runLexer file)
where
runLexer file = do
src <- Text.readFile file
@@ -47,34 +41,39 @@ layoutTests = do
Right toks -> do
pure $ CST.printTokens toks
-litTests :: TestTree
-litTests = testGroup "Literals"
- [ testProperty "Integer" $
- checkTok checkReadNum (\case TokInt _ a -> Just a; _ -> Nothing) . unInt
- , testProperty "Hex" $
- checkTok checkReadNum (\case TokInt _ a -> Just a; _ -> Nothing) . unHex
- , testProperty "Number" $
- checkTok checkReadNum (\case TokNumber _ a -> Just a; _ -> Nothing) . unFloat
- , testProperty "Exponent" $
- checkTok checkReadNum (\case TokNumber _ a -> Just a; _ -> Nothing) . unExponent
-
- , testProperty "Integer (round trip)" $ roundTripTok . unInt
- , testProperty "Hex (round trip)" $ roundTripTok . unHex
- , testProperty "Number (round trip)" $ roundTripTok . unFloat
- , testProperty "Exponent (round trip)" $ roundTripTok . unExponent
- , testProperty "Char (round trip)" $ roundTripTok . unChar
- , testProperty "String (round trip)" $ roundTripTok . unString
- , testProperty "Raw String (round trip)" $ roundTripTok . unRawString
- ]
+literalsSpec :: Spec
+literalsSpec = describe "Literals" $ do
+ testProperty "Integer" $
+ checkTok checkReadNum (\case TokInt _ a -> Just a; _ -> Nothing) . unInt
+ testProperty "Hex" $
+ checkTok checkReadNum (\case TokInt _ a -> Just a; _ -> Nothing) . unHex
+ testProperty "Number" $
+ checkTok checkReadNum (\case TokNumber _ a -> Just a; _ -> Nothing) . unFloat
+ testProperty "Exponent" $
+ checkTok checkReadNum (\case TokNumber _ a -> Just a; _ -> Nothing) . unExponent
+
+ testProperty "Integer (round trip)" $ roundTripTok . unInt
+ testProperty "Hex (round trip)" $ roundTripTok . unHex
+ testProperty "Number (round trip)" $ roundTripTok . unFloat
+ testProperty "Exponent (round trip)" $ roundTripTok . unExponent
+ testProperty "Char (round trip)" $ roundTripTok . unChar
+ testProperty "String (round trip)" $ roundTripTok . unString
+ testProperty "Raw String (round trip)" $ roundTripTok . unRawString
-readTok :: Text -> Gen SourceToken
-readTok t = case CST.lex t of
+ where
+ testProperty name test = specify name (property test)
+
+readTok' :: String -> Text -> Gen SourceToken
+readTok' failMsg t = case CST.lex t of
Right tok : _ ->
pure tok
Left (_, err) : _ ->
- fail $ "Failed to parse: " <> CST.prettyPrintError err
+ error $ failMsg <> ": " <> CST.prettyPrintError err
[] ->
- fail "Empty token stream"
+ error "Empty token stream"
+
+readTok :: Text -> Gen SourceToken
+readTok = readTok' "Failed to parse"
checkTok
:: (Text -> a -> Gen Bool)
@@ -85,13 +84,13 @@ checkTok p f t = do
SourceToken _ tok <- readTok t
case f tok of
Just a -> p t a
- Nothing -> fail $ "Failed to lex correctly: " <> show tok
+ Nothing -> error $ "Failed to lex correctly: " <> show tok
roundTripTok :: Text -> Gen Bool
roundTripTok t = do
tok <- readTok t
let t' = CST.printTokens [tok]
- tok' <- readTok t'
+ tok' <- readTok' "Failed to re-parse" t'
pure $ tok == tok'
checkReadNum :: (Eq a, Read a) => Text -> a -> Gen Bool
@@ -102,7 +101,7 @@ checkReadNum t a = do
chs' -> chs'
case (== a) <$> readMaybe chs of
Just a' -> pure a'
- Nothing -> fail "Failed to `read`"
+ Nothing -> error "Failed to `read`"
newtype PSSourceInt = PSSourceInt { unInt :: Text }
deriving (Show, Eq)
@@ -168,26 +167,26 @@ genHex = PSSourceHex <$> do
genChar :: Gen PSSourceChar
genChar = PSSourceChar <$> do
- ch <- (toEnum :: Int -> Char) <$> resize 0xFFFF arbitrarySizedNatural
- ch' <- case ch of
- '\'' -> discard
- '\\' -> genCharEscape
- c -> pure $ Text.singleton c
- pure $ "'" <> ch' <> "'"
+ ch <- resize 0xFFFF arbitrarySizedNatural >>= (genStringChar '\'' . toEnum)
+ pure $ "'" <> ch <> "'"
genString :: Gen PSSourceString
genString = PSSourceString <$> do
- chs <- listOf $ arbitraryUnicodeChar >>= \case
- '"' -> discard
- '\n' -> discard
- '\r' -> discard
- '\\' -> genCharEscape
- c -> pure $ Text.singleton c
+ chs <- listOf $ arbitraryUnicodeChar >>= genStringChar '"'
pure $ "\"" <> Text.concat chs <> "\""
+genStringChar :: Char -> Char -> Gen Text
+genStringChar delimiter ch = frequency
+ [ (1, genCharEscape)
+ , (10, if ch `elem` [delimiter, '\n', '\r', '\\']
+ then discard
+ else pure $ Text.singleton ch
+ )
+ ]
+
genRawString :: Gen PSSourceRawString
genRawString = PSSourceRawString <$> do
- chs <- listOf $ arbitraryUnicodeChar
+ chs <- listOf arbitraryUnicodeChar
let
k1 acc qs cs = do
let (cs', q) = span (/= '"') cs
diff --git a/tests/TestDocs.hs b/tests/TestDocs.hs
index aa9e55cf25..09a76ceb7a 100644
--- a/tests/TestDocs.hs
+++ b/tests/TestDocs.hs
@@ -1,120 +1,62 @@
-{-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE ViewPatterns #-}
-{-# LANGUAGE LambdaCase #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE OverloadedStrings #-}
-
module TestDocs where
-import Prelude ()
-import Prelude.Compat
-
-import Control.Arrow (first)
-import Control.Monad.IO.Class (liftIO)
+import Prelude
+import Protolude (tailDef)
+import Data.Bifunctor (first)
import Data.List (findIndex)
-import Data.Foldable
+import Data.Foldable (find, forM_)
import Safe (headMay)
-import qualified Data.Map as Map
-import Data.Maybe (fromMaybe, mapMaybe)
-import Data.Monoid
+import Data.Map qualified as Map
+import Data.Maybe (fromMaybe, isNothing, mapMaybe)
+import Data.Monoid (Any(..), First(..))
import Data.Text (Text)
-import qualified Data.Text as T
-import Data.Time.Clock (getCurrentTime)
-import Data.Version (Version(..))
-import System.Exit
+import Data.Text qualified as T
+import Text.PrettyPrint.Boxes qualified as Boxes
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Docs as Docs
+import Language.PureScript qualified as P
+import Language.PureScript.Docs qualified as Docs
import Language.PureScript.Docs.AsMarkdown (codeToString)
-import qualified Language.PureScript.Publish as Publish
-import qualified Language.PureScript.Publish.ErrorsWarnings as Publish
+import Language.PureScript.Publish.ErrorsWarnings qualified as Publish
import Web.Bower.PackageMeta (parsePackageName, runPackageName)
-import TestUtils
-
-import Test.Tasty
-import Test.Tasty.Hspec (Spec, it, context, expectationFailure, runIO, testSpec)
-
-publishOpts :: Publish.PublishOptions
-publishOpts = Publish.defaultPublishOptions
- { Publish.publishGetVersion = return testVersion
- , Publish.publishGetTagTime = const (liftIO getCurrentTime)
- , Publish.publishWorkingTreeDirty = return ()
- }
- where testVersion = ("v999.0.0", Version [999,0,0] [])
-
-getPackage :: IO (Either Publish.PackageError (Docs.Package Docs.NotYetKnown))
-getPackage =
- pushd "tests/purs/docs" $
- Publish.preparePackage "bower.json" "resolutions.json" publishOpts
+import TestPscPublish (preparePackage)
-main :: IO TestTree
-main = testSpec "docs" spec
+import Test.Hspec (Spec, beforeAll, context, expectationFailure, it)
spec :: Spec
-spec = do
- pkg@Docs.Package{..} <- runIO $ do
- res <- getPackage
- case res of
- Left e ->
- Publish.printErrorToStdout e >> exitFailure
- Right p ->
- pure p
-
- let linksCtx = Docs.getLinksContext pkg
-
+spec = beforeAll (handleDocPrepFailure <$> preparePackage "tests/purs/docs" "purs.json" "resolutions.json") $
context "Language.PureScript.Docs" $ do
context "Doc generation tests:" $
- forM_ testCases $ \(mnString, assertions) -> do
- let mn = P.moduleNameFromString mnString
- mdl = find ((==) mn . Docs.modName) pkgModules
-
- context ("in module " ++ T.unpack mnString) $
- case mdl of
- Nothing ->
- it "exists in docs output" $
- expectationFailure ("module not found in docs: " ++ T.unpack mnString)
- Just mdl' ->
- toHspec linksCtx mdl' assertions
-
- context "Tag generation tests:" $
- forM_ testTagsCases $ \(mnString, assertions) -> do
- let mn = P.moduleNameFromString mnString
- mdl = find ((==) mn . Docs.modName) pkgModules
- context ("in module " ++ T.unpack mnString) $
- case mdl of
- Nothing ->
- it "exists in docs output" $
- expectationFailure ("module not found in docs: " ++ T.unpack mnString)
- Just mdl' ->
- tagAssertionsToHspec mdl' assertions
-
- where
- toHspec :: Docs.LinksContext -> Docs.Module -> [DocsAssertion] -> Spec
- toHspec linksCtx mdl assertions =
- forM_ assertions $ \a ->
- it (T.unpack (displayAssertion a)) $ do
- case runAssertion a linksCtx mdl of
+ mkSpec testCases displayAssertion $ \a pkg mdl ->
+ case runAssertion a (Docs.getLinksContext pkg) mdl of
Pass ->
pure ()
Fail reason ->
expectationFailure (T.unpack (displayAssertionFailure reason))
- tagAssertionsToHspec :: Docs.Module -> [TagsAssertion] -> Spec
- tagAssertionsToHspec mdl assertions =
- let tags = Map.fromList $ Docs.tags mdl
- in forM_ assertions $ \a ->
- it (T.unpack (displayTagsAssertion a)) $ do
- case runTagsAssertion a tags of
+ context "Tag generation tests:" $
+ mkSpec testTagsCases displayTagsAssertion $ \a _ mdl ->
+ case runTagsAssertion a (Map.fromList $ Docs.tags mdl) of
TagsPass ->
pure ()
TagsFail reason ->
expectationFailure (T.unpack (displayTagsAssertionFailure reason))
-
-takeJust :: String -> Maybe a -> a
-takeJust msg = fromMaybe (error msg)
+ where
+ handleDocPrepFailure = first (expectationFailure . ("failed to produce docs: " <>) . Boxes.render . Publish.renderError)
+
+ mkSpec cases displayAssertion' runner =
+ forM_ cases $ \(mnString, assertions) -> do
+ let mn = P.moduleNameFromString mnString
+ context ("in module " ++ T.unpack mnString) $
+ forM_ assertions $ \a ->
+ it (T.unpack (displayAssertion' a)) . either id $ \pkg@Docs.Package{..} ->
+ case find ((==) mn . Docs.modName) pkgModules of
+ Nothing ->
+ expectationFailure ("module not found in docs: " ++ T.unpack mnString)
+ Just mdl ->
+ runner a pkg mdl
data DocsAssertion
-- | Assert that a particular declaration is documented with the given
@@ -144,6 +86,16 @@ data DocsAssertion
-- | Assert that a documented declaration includes a documentation comment
-- containing a particular string
| ShouldHaveDocComment P.ModuleName Text Text
+ -- | Assert that a documented data declaration includes a documentation comment
+ -- | containing a particular string
+ | ShouldHaveDataConstructorDocComment P.ModuleName Text Text Text
+ -- | Assert that a documented data declaration has no documentation comment
+ | ShouldHaveNoDataConstructorDocComment P.ModuleName Text Text
+ -- | Assert that a documented class method includes a documentation comment
+ -- | containing a particular string
+ | ShouldHaveClassMethodDocComment P.ModuleName Text Text Text
+ -- | Assert that a class method has no documentation comment
+ | ShouldNotHaveClassMethodDocComment P.ModuleName Text Text
-- | Assert that there should be some declarations re-exported from a
-- particular module in a particular package.
| ShouldHaveReExport (Docs.InPackage P.ModuleName)
@@ -154,6 +106,19 @@ data DocsAssertion
| ShouldHaveLink P.ModuleName Text Text Docs.Namespace Docs.LinkLocation
-- | Assert that a given declaration comes before another in the output
| ShouldComeBefore P.ModuleName Text Text
+ -- | Assert that a given declaration has the given kind signature
+ | ShouldHaveKindSignature P.ModuleName Text Text
+ -- | Assert that a given declaration does not have a kind signature
+ | ShouldNotHaveKindSignature P.ModuleName Text
+ -- | Assert that a given declaration with doc-comments on its
+ -- kind signature, type declaration, and role declaration are properly
+ -- merged into one doc-comment.
+ | ShouldMergeDocComments P.ModuleName Text (Maybe Text)
+ -- | Assert that a given declaration's type parameters have the
+ -- given role annotations
+ | ShouldHaveRoleAnnotation P.ModuleName Text [P.Role]
+ -- | Assert that a given module has the expected doc comments
+ | ShouldHaveModuleDocs P.ModuleName (Maybe Text)
data TagsAssertion
-- | Assert that a particular declaration is tagged
@@ -188,6 +153,18 @@ displayAssertion = \case
ShouldHaveDocComment mn decl excerpt ->
"the string " <> T.pack (show excerpt) <> " should appear in the" <>
" doc-comments for " <> showQual mn decl
+ ShouldHaveDataConstructorDocComment mn decl constr excerpt ->
+ "the string " <> T.pack (show excerpt) <> " should appear in the" <>
+ " doc-comments for data constructor " <> T.pack (show constr) <> " for " <> showQual mn decl
+ ShouldHaveNoDataConstructorDocComment mn decl constr ->
+ "Doc-comments for data constructor " <> T.pack (show constr) <> " for " <> showQual mn decl <>
+ " should be empty"
+ ShouldHaveClassMethodDocComment mn decl method excerpt ->
+ "the string " <> T.pack (show excerpt) <> " should appear in the" <>
+ " doc-comment for class method " <> T.pack (show method) <> " for " <> showQual mn decl
+ ShouldNotHaveClassMethodDocComment mn decl method ->
+ "Doc-comments for class method " <> T.pack (show method) <> " for " <> showQual mn decl <>
+ " should be empty"
ShouldHaveReExport inPkg ->
"there should be some re-exports from " <>
showInPkg P.runModuleName inPkg
@@ -197,6 +174,20 @@ displayAssertion = \case
ShouldComeBefore mn declA declB ->
showQual mn declA <> " should come before " <> showQual mn declB <>
" in the docs"
+ ShouldHaveKindSignature mn decl expected ->
+ showQual mn decl <> " should have the kind signature `" <> expected <> "`"
+ ShouldNotHaveKindSignature mn decl ->
+ showQual mn decl <> " should not have a kind signature."
+ ShouldMergeDocComments mn decl _ ->
+ showQual mn decl <> " should merge the doc-comments of its kind " <>
+ "declaration (if any), type declaration, and role declaration (if any) " <>
+ "into one doc-comment."
+ ShouldHaveRoleAnnotation mn decl expected ->
+ showQual mn decl <> " should have the expected role annotations: " <>
+ T.intercalate ", " (fmap P.displayRole expected)
+ ShouldHaveModuleDocs mn expected ->
+ "Module doc comments for module `" <> P.runModuleName mn <> "` should be " <>
+ maybe "empty" (\t -> "'" <> t <> "`") expected
displayTagsAssertion :: TagsAssertion -> Text
displayTagsAssertion = \case
@@ -232,6 +223,9 @@ data DocsAssertionFailure
-- | A doc comment was not found or did not match what was expected
-- Fields: module name, declaration, actual comments
| DocCommentMissing P.ModuleName Text (Maybe Text)
+ -- | A doc comment was found where none was expected
+ -- Fields: module name, declaration, actual comments
+ | DocCommentPresent P.ModuleName Text (Maybe Text)
-- | A module was missing re-exports from a particular module.
-- Fields: module name, expected re-export, actual re-exports.
| ReExportMissing P.ModuleName (Docs.InPackage P.ModuleName) [Docs.InPackage P.ModuleName]
@@ -248,6 +242,32 @@ data DocsAssertionFailure
| BadLinkLocation P.ModuleName Text Text Docs.LinkLocation Docs.LinkLocation
-- | Declarations were in the wrong order
| WrongOrder P.ModuleName Text Text
+ -- | Expected a kind signature for a declaration, but did not find one
+ -- Fields: module name, declaration title.
+ | KindSignatureMissing P.ModuleName Text
+ -- | The rendered kind signature did not match the expected one.
+ -- Fields: module name, declaration title, expected kind signature (text),
+ -- actual kind signature (text), actual kind signature (structure)
+ | KindSignatureMismatch P.ModuleName Text Text Text (P.Type ())
+ -- | A kind signature was found where none was expected.
+ -- Fields: module name, declaration title, actual kind signature (text),
+ -- actual kind signature (structure)
+ | KindSignaturePresent P.ModuleName Text Text (P.Type ())
+ -- | The doc comments for the kind signature (if any), type declaration, and
+ -- role declaration (if any) were not properly merged into the expected one.
+ -- Fields: module name, declaration title, expected doc-comments,
+ -- actual doc-comments
+ | DocCommentMergeFailure P.ModuleName Text Text Text
+ -- | The given declaration cannot have role annotations.
+ -- Fields: module name, declaration title
+ | CannotHaveRoles P.ModuleName Text
+ -- | The list of expected roles did not match the list of actual roles
+ -- fields: module name, declaration title, expected role list,
+ -- actual role list
+ | RoleMismatch P.ModuleName Text [P.Role] [P.Role]
+ -- | The module's doc comments should be the expected
+ -- fields: module name, expected docs, actual docs
+ | WrongModuleDocs P.ModuleName (Maybe Text) (Maybe Text)
data TagsAssertionFailure
-- | A declaration was not tagged, but should have been
@@ -282,6 +302,8 @@ displayAssertionFailure = \case
DocCommentMissing _ decl actual ->
"the doc-comment for " <> decl <> " did not contain the expected substring;" <>
" got " <> T.pack (show actual)
+ DocCommentPresent _ decl actual ->
+ "the doc-comment for " <> decl <> " was not empty. Got " <> T.pack (show actual)
ReExportMissing _ expected actuals ->
"expected to see some re-exports from " <>
showInPkg P.runModuleName expected <>
@@ -294,8 +316,34 @@ displayAssertionFailure = \case
"in rendered code for " <> decl <> ", bad link location for " <> target <>
": expected " <> T.pack (show expected) <>
" got " <> T.pack (show actual)
- WrongOrder _ before after' ->
- "expected to see " <> before <> " before " <> after'
+ WrongOrder _ before' after' ->
+ "expected to see " <> before' <> " before " <> after'
+ KindSignatureMissing _ decl ->
+ "the kind signature for " <> decl <> " is missing."
+ KindSignatureMismatch _ decl expected actualTxt actualKind ->
+ "expected the kind signature for " <> decl <> "\n" <>
+ "to be `" <> expected <> "`\n" <>
+ " got `" <> actualTxt <> "`\n" <>
+ "Structure of kind: " <> T.pack (show actualKind)
+ KindSignaturePresent _ decl actualTxt actualKind ->
+ "the kind signature for " <> decl <> " was not empty.\n" <>
+ "got `" <> actualTxt <> "`\n" <>
+ "Structure of kind: " <> T.pack (show actualKind)
+ DocCommentMergeFailure _ decl expected actual ->
+ "Expected the doc-comment for " <> decl <> " to merge comments and be `" <>
+ expected <> "`; got `" <> actual <> "`"
+ CannotHaveRoles _ decl ->
+ decl <> " is a type of declaration that cannot have roles."
+ RoleMismatch _ decl expected actual ->
+ "Expected the role annotations for " <> decl <> " to be \n" <>
+ "`" <> displayRoleList expected <> "`, but got\n" <>
+ "`" <> displayRoleList actual <> "`"
+ where
+ displayRoleList = T.intercalate ", " . fmap P.displayRole
+ WrongModuleDocs mn expected actual ->
+ "Expected module docs for " <> P.runModuleName mn <> "\n" <>
+ "to be `" <> fromMaybe "" expected <> "`\n" <>
+ " got `" <> fromMaybe "" actual <> "`"
displayTagsAssertionFailure :: TagsAssertionFailure -> Text
displayTagsAssertionFailure = \case
@@ -417,6 +465,18 @@ runAssertion assertion linksCtx Docs.Module{..} =
then Pass
else Fail (DocCommentMissing mn decl declComments)
+ ShouldHaveDataConstructorDocComment mn decl constr expected ->
+ findDeclChildrenComment mn decl constr expected
+
+ ShouldHaveNoDataConstructorDocComment mn decl constr ->
+ findDeclChildrenNoComment mn decl constr
+
+ ShouldHaveClassMethodDocComment mn decl constr expected ->
+ findDeclChildrenComment mn decl constr expected
+
+ ShouldNotHaveClassMethodDocComment mn decl method ->
+ findDeclChildrenNoComment mn decl method
+
ShouldHaveReExport reExp ->
let
reExps = map fst modReExports
@@ -438,23 +498,62 @@ runAssertion assertion linksCtx Docs.Module{..} =
Nothing ->
Fail (LinkedDeclarationMissing mn decl destTitle)
- ShouldComeBefore mn before after' ->
+ ShouldComeBefore mn before' after' ->
let
decls = declarationsFor mn
indexOf :: Text -> Maybe Int
indexOf title = findIndex ((==) title . Docs.declTitle) decls
in
- case (indexOf before, indexOf after') of
+ case (indexOf before', indexOf after') of
(Just i, Just j) ->
if i < j
then Pass
- else Fail (WrongOrder mn before after')
+ else Fail (WrongOrder mn before' after')
(Nothing, _) ->
- Fail (NotDocumented mn before)
+ Fail (NotDocumented mn before')
(_, Nothing) ->
Fail (NotDocumented mn after')
+ ShouldHaveKindSignature mn decl expected ->
+ findDeclKinds mn decl $ \case
+ Just Docs.KindInfo{..} ->
+ if expected /= actual
+ then Fail (KindSignatureMismatch mn decl expected actual kiKind)
+ else Pass
+ where
+ actual = codeToString $ Docs.renderKindSig decl $
+ Docs.KindInfo kiKeyword kiKind
+ Nothing -> Fail (KindSignatureMissing mn decl)
+
+ ShouldNotHaveKindSignature mn decl ->
+ findDeclKinds mn decl $ \case
+ Just Docs.KindInfo{..} ->
+ Fail (KindSignaturePresent mn decl actual kiKind)
+ where
+ actual = codeToString $ Docs.renderKindSig decl $
+ Docs.KindInfo kiKeyword kiKind
+ Nothing -> Pass
+
+ ShouldMergeDocComments mn decl expected ->
+ findDecl mn decl $ \Docs.Declaration{..} ->
+ if expected == declComments
+ then Pass
+ else Fail (DocCommentMergeFailure mn decl (display expected) (display declComments))
+ where
+ display = fromMaybe ""
+
+ ShouldHaveRoleAnnotation mn decl expected ->
+ findDeclRoles mn decl $ \actual ->
+ if expected == actual
+ then Pass
+ else Fail (RoleMismatch mn decl expected actual)
+
+ ShouldHaveModuleDocs mn expected ->
+ if expected == modComments then
+ Pass
+ else
+ Fail (WrongModuleDocs mn expected modComments)
where
declarationsFor mn =
if mn == modName
@@ -471,8 +570,51 @@ runAssertion assertion linksCtx Docs.Module{..} =
Just decl ->
f decl
+ findDeclKinds mn title f =
+ case find ((==) title . Docs.declTitle) (declarationsFor mn) of
+ Nothing ->
+ Fail (NotDocumented mn title)
+ Just Docs.Declaration{..} ->
+ f declKind
+
+ findDeclRoles mn title f =
+ case find ((==) title . Docs.declTitle) (declarationsFor mn) of
+ Nothing ->
+ Fail (NotDocumented mn title)
+ Just Docs.Declaration{..} ->
+ case getRoles declInfo of
+ Nothing ->
+ Fail (CannotHaveRoles mn title)
+ Just roles ->
+ f roles
+
+ findDeclChildren mn title child f =
+ findDecl mn title $ \Docs.Declaration{..} ->
+ case find ((==) child . Docs.cdeclTitle) declChildren of
+ Nothing ->
+ Fail (NotDocumented mn child)
+ Just decl ->
+ f decl
+
+ findDeclChildrenComment mn decl constr expected =
+ findDeclChildren mn decl constr $ \Docs.ChildDeclaration{..} ->
+ if maybe False (expected `T.isInfixOf`) cdeclComments
+ then Pass
+ else Fail (DocCommentMissing mn constr cdeclComments)
+
+ findDeclChildrenNoComment mn decl constr =
+ findDeclChildren mn decl constr $ \Docs.ChildDeclaration{..} ->
+ if isNothing cdeclComments
+ then Pass
+ else Fail (DocCommentPresent mn constr cdeclComments)
+
childrenTitles = map Docs.cdeclTitle . Docs.declChildren
+ getRoles :: Docs.DeclarationInfo -> Maybe [P.Role]
+ getRoles = \case
+ Docs.DataDeclaration _ _ roles -> Just roles
+ _ -> Nothing
+
extract :: Docs.RenderedCode -> Docs.Namespace -> Text -> Maybe Docs.DocLink
extract rc ns title = getFirst (Docs.outputWith (First . go) rc) >>= getLink
where
@@ -506,7 +648,7 @@ checkConstrained ty tyClass =
P.ConstrainedType _ c ty'
| matches tyClass c -> True
| otherwise -> checkConstrained ty' tyClass
- P.ForAll _ _ _ ty' _ ->
+ P.ForAll _ _ _ _ ty' _ ->
checkConstrained ty' tyClass
_ ->
False
@@ -564,7 +706,7 @@ testCases =
, ("Clash",
[ ShouldBeDocumented (n "Clash1") "value" []
- , ShouldBeDocumented (n "Clash1") "Type" []
+ , ShouldBeDocumented (n "Clash1") "Type'" []
, ShouldBeDocumented (n "Clash1") "TypeClass" ["typeClassMember"]
])
@@ -623,6 +765,19 @@ testCases =
[ ShouldHaveDocComment (n "DocComments") "example" " example == 0"
])
+ , ("DocCommentsDataConstructor",
+ [ ShouldHaveDataConstructorDocComment (n "DocCommentsDataConstructor") "Foo" "Bar" "data constructor comment"
+ , ShouldHaveNoDataConstructorDocComment (n "DocCommentsDataConstructor") "Foo" "Baz"
+ , ShouldHaveNoDataConstructorDocComment (n "DocCommentsDataConstructor") "ComplexFoo" "ComplexBar"
+ , ShouldHaveDataConstructorDocComment (n "DocCommentsDataConstructor") "ComplexFoo" "ComplexBaz" "another data constructor comment"
+ , ShouldHaveDataConstructorDocComment (n "DocCommentsDataConstructor") "NewtypeFoo" "NewtypeFoo" "newtype data constructor comment"
+ ])
+
+ , ("DocCommentsClassMethod",
+ [ ShouldHaveClassMethodDocComment (n "DocCommentsClassMethod") "Foo" "bar" "class method comment"
+ , ShouldNotHaveClassMethodDocComment (n "DocCommentsClassMethod") "Foo" "baz"
+ ])
+
, ("TypeLevelString",
[ ShouldBeDocumented (n "TypeLevelString") "Foo" ["fooBar"]
])
@@ -648,6 +803,140 @@ testCases =
[ ValueShouldHaveTypeSignature (n "Ado") "test" (renderedType "Int")
]
)
+
+ , ("TypeSynonymInstance",
+ [ ShouldBeDocumented (n "TypeSynonymInstance") "MyNT" ["MyNT", "ntMyNT"]
+ ]
+ )
+ , ("KindSignatureDocs",
+ -- expected kind signatures
+ [ ShouldHaveKindSignature (n "KindSignatureDocs") "DKindAndType" "data DKindAndType :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "TKindAndType" "type TKindAndType :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "NKindAndType" "newtype NKindAndType :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "CKindAndType" "class CKindAndType :: forall k. (k -> Type) -> k -> Constraint"
+
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "DKindOnly" "data DKindOnly :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "TKindOnly" "type TKindOnly :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "NKindOnly" "newtype NKindOnly :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "CKindOnly" "class CKindOnly :: forall k. (k -> Type) -> k -> Constraint"
+
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "DTypeOnly" "data DTypeOnly :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "TTypeOnly" "type TTypeOnly :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "NTypeOnly" "newtype NTypeOnly :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "CTypeOnly" "class CTypeOnly :: forall k. (k -> Type) -> k -> Constraint"
+
+ -- Declarations with no explicit kind signatures should still have
+ -- their inferred kind signatures displayed as long as at least one
+ -- type parameter does not have kind `Type`.
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "DImplicit" "data DImplicit :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "TImplicit" "type TImplicit :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "NImplicit" "newtype NImplicit :: forall k. k -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "CImplicit" "class CImplicit :: forall k1. (k1 -> Type) -> k1 -> Constraint"
+
+ -- Declarations with no explicit kind signatures should not be displayed
+ -- if each type parameter in their inferred kind signature
+ -- has kind `Type`.
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "DHidden"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "DNothing"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "THidden"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "NHidden"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "CHidden"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "CNothing"
+
+ -- FFI declarations always have an explicit kind signature
+ -- but only show them if they are "interesting."
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "FFI_Hidden"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "FFI_Shown" "data FFI_Shown :: (Type -> Type) -> Type"
+
+ -- Declarations with an explicit kind signature that is wrapped
+ -- in parenthesis at various points, but which "desugars" so to speak
+ -- to an uninteresting kind signature should not be displayed.
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "FFI_RedundantParenthesis"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "DataRedundantParenthesis"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "ClassRedundantParenthesis"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "DataHeadParens"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "DataTailParens"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "DataWholeParens"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "DataSelfParens"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "ClassSelfParens"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "DataKindAnnotation"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "DataKindAnnotationWithParens"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "FunctionParens1"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "FunctionParens2"
+ , ShouldNotHaveKindSignature (n "KindSignatureDocs") "FunctionParens3"
+
+ -- Declarations with no explicit kind signatures should be displayed
+ -- if at least one type parameter has a kind other than `Type`
+ -- despite all others having kind `Type`.
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "DShown" "data DShown :: Type -> Type -> (Type -> Type) -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "TShown" "type TShown :: (Type -> Type) -> Type -> Type -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "NShown" "newtype NShown :: Type -> (Type -> Type) -> Type -> Type"
+ , ShouldHaveKindSignature (n "KindSignatureDocs") "CShown" "class CShown :: (Type -> Type) -> Type -> Type -> Constraint"
+ ]
+ )
+ , ("RoleAnnotationDocs",
+ [ ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "D_RNP" [P.Representational, P.Nominal, P.Phantom]
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "D_NPR" [P.Nominal, P.Phantom, P.Representational]
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "D_PRN" [P.Phantom, P.Representational, P.Nominal]
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "FFI_NNN" [P.Nominal, P.Nominal, P.Nominal]
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "FFI_RNP" [P.Representational, P.Nominal, P.Phantom]
+
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "FFI_Higher1" [P.Representational, P.Nominal, P.Phantom]
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "FFI_Higher2" [P.Representational, P.Nominal, P.Phantom]
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "FFI_Higher3" [P.Representational, P.Nominal, P.Phantom]
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "FFI_Higher4" [P.Representational, P.Nominal, P.Phantom]
+
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "FFI_HeadParens" [P.Representational, P.Nominal, P.Phantom]
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "FFI_TailParens" [P.Representational, P.Nominal, P.Phantom]
+ , ShouldHaveRoleAnnotation (n "RoleAnnotationDocs") "FFI_WholeParens" [P.Representational, P.Nominal, P.Phantom]
+ ]
+ )
+ , ("DocCommentsMerge",
+ [ ShouldMergeDocComments (n "DocCommentsMerge") "DataOnly" $ Just "decl\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindOnlyData" $ Just "kind\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindAndData" $ Just "kind\n\ndecl\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "DataRoleOnly" $ Just "role\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "DataAndRole" $ Just "decl\n\nrole\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindOnlyDataRoleOnly" $ Just "kind\n\nrole\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindDataAndRole" $ Just "kind\n\ndecl\n\nrole\n"
+
+ , ShouldMergeDocComments (n "DocCommentsMerge") "FFIOnly" $ Just "decl\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "FFIRoleOnly" $ Just "role\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "FFIAndRole" $ Just "decl\n\nrole\n"
+
+ , ShouldMergeDocComments (n "DocCommentsMerge") "NewtypeOnly" $ Just "decl\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindOnlyNewtype" $ Just "kind\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindAndNewtype" $ Just "kind\n\ndecl\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "NewtypeRoleOnly" $ Just "role\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "NewtypeAndRole" $ Just "decl\n\nrole\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindOnlyNewtypeRoleOnly" $ Just "kind\n\nrole\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindNewtypeAndRole" $ Just "kind\n\ndecl\n\nrole\n"
+
+ , ShouldMergeDocComments (n "DocCommentsMerge") "TypeOnly" $ Just "decl\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindOnlyType" $ Just "kind\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindAndType" $ Just "kind\n\ndecl\n"
+
+ , ShouldMergeDocComments (n "DocCommentsMerge") "ClassOnly" $ Just "decl\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindOnlyClass" $ Just "kind\n"
+ , ShouldMergeDocComments (n "DocCommentsMerge") "KindAndClass" $ Just "kind\n\ndecl\n"
+ ]
+ )
+ , ("Shebang1Undocumented",
+ [ ShouldHaveModuleDocs (n "Shebang1Undocumented") Nothing
+ ]
+ )
+ , ("Shebang2Undocumented",
+ [ ShouldHaveModuleDocs (n "Shebang2Undocumented") Nothing
+ ]
+ )
+ , ("Shebang3Undocumented",
+ [ ShouldHaveModuleDocs (n "Shebang3Undocumented") $ Just "Normal doc comment\n"
+ ]
+ )
+ , ("Shebang4Undocumented",
+ [ ShouldHaveModuleDocs (n "Shebang4Undocumented") $ Just "Normal doc comment\n"
+ ]
+ )
]
where
@@ -664,7 +953,7 @@ testCases =
codeToString (Docs.renderType ty) == expected
shouldBeOrdered mn declNames =
- zipWith (ShouldComeBefore mn) declNames (tail declNames)
+ zipWith (ShouldComeBefore mn) declNames (tailDef mempty declNames)
testTagsCases :: [(Text, [TagsAssertion])]
testTagsCases =
diff --git a/tests/TestGraph.hs b/tests/TestGraph.hs
new file mode 100644
index 0000000000..087bbc3601
--- /dev/null
+++ b/tests/TestGraph.hs
@@ -0,0 +1,28 @@
+module TestGraph where
+
+import Prelude
+
+import Test.Hspec (Spec, it, shouldBe, shouldSatisfy)
+import Data.Either (isLeft)
+
+import Data.Aeson qualified as Json
+import Language.PureScript qualified as P
+
+spec :: Spec
+spec = do
+ let baseDir = "tests/purs/graph/"
+ let sourcesDir = baseDir <> "src/"
+ it "should match the graph fixture" $ do
+ let modulePaths = (sourcesDir <>) <$> ["Module.purs", "Module2.purs", "Module3.purs"]
+ let graphFixtureName = "graph.json"
+
+ graphFixture <- Json.decodeFileStrict' (baseDir <> graphFixtureName)
+ eitherGraph <- fst <$> P.graph modulePaths
+ case eitherGraph of
+ Left err -> error $ "Graph creation failed. Errors: " <> show err
+ Right res -> graphFixture `shouldBe` Just res
+
+ it "should fail when trying to include non-existing modules in the graph" $ do
+ let modulePath = sourcesDir <> "ModuleFailing.purs"
+ graph <- fst <$> P.graph [modulePath]
+ graph `shouldSatisfy` isLeft
diff --git a/tests/TestHierarchy.hs b/tests/TestHierarchy.hs
index 3cbf612193..2ba3e82946 100644
--- a/tests/TestHierarchy.hs
+++ b/tests/TestHierarchy.hs
@@ -1,16 +1,14 @@
-{-# LANGUAGE OverloadedStrings #-}
module TestHierarchy where
import Prelude
-import Language.PureScript.Hierarchy
-import qualified Language.PureScript as P
+import Language.PureScript.Hierarchy (Digraph(..), Graph(..), GraphName(..), SuperMap(..), prettyPrint, typeClassGraph)
+import Language.PureScript qualified as P
-import Test.Tasty
-import Test.Tasty.Hspec (describe, it, shouldBe, testSpec)
+import Test.Hspec (Spec, describe, it, shouldBe)
-main :: IO TestTree
-main = testSpec "hierarchy" $ do
+spec :: Spec
+spec = describe "hierarchy" $ do
describe "Language.PureScript.Hierarchy" $ do
describe "prettyPrint" $ do
it "creates just the node when there is no relation" $ do
@@ -21,7 +19,7 @@ main = testSpec "hierarchy" $ do
prettyPrinted `shouldBe` " A;"
it "creates a relation when there is one" $ do
- let superMap = SuperMap (Right $ (P.ProperName "A", P.ProperName "B"))
+ let superMap = SuperMap (Right (P.ProperName "A", P.ProperName "B"))
let prettyPrinted = prettyPrint superMap
@@ -32,7 +30,7 @@ main = testSpec "hierarchy" $ do
let mainModule = P.Module
(P.internalModuleSourceSpan "")
[]
- (P.ModuleName [P.ProperName "Main"])
+ (P.ModuleName "Main")
[]
Nothing
@@ -53,14 +51,14 @@ main = testSpec "hierarchy" $ do
(P.internalModuleSourceSpan "", [])
(P.ProperName "B")
[]
- [P.srcConstraint (P.Qualified Nothing $ P.ProperName "A") [] Nothing]
+ [P.srcConstraint (P.Qualified P.ByNullSourcePos $ P.ProperName "A") [] [] Nothing]
[]
[]
]
let mainModule = P.Module
(P.internalModuleSourceSpan "")
[]
- (P.ModuleName [P.ProperName "Main"])
+ (P.ModuleName "Main")
declarations
Nothing
diff --git a/tests/TestIde.hs b/tests/TestIde.hs
index 8879d85a1e..1d505456c9 100644
--- a/tests/TestIde.hs
+++ b/tests/TestIde.hs
@@ -1,16 +1,15 @@
module TestIde where
-import Prelude
+import Prelude
-import Control.Monad (unless)
-import Language.PureScript.Ide.Test
-import qualified PscIdeSpec
-import Test.Tasty
-import Test.Tasty.Hspec
+import Control.Monad (unless)
+import Language.PureScript.Ide.Test
+import PscIdeSpec qualified
+import Test.Hspec
-main :: IO TestTree
-main =
- testSpec "ide" (beforeAll_ setup PscIdeSpec.spec)
+spec :: Spec
+spec =
+ beforeAll_ setup PscIdeSpec.spec
where
setup = do
deleteOutputFolder
diff --git a/tests/TestInteractive.hs b/tests/TestInteractive.hs
new file mode 100644
index 0000000000..13fdb806ce
--- /dev/null
+++ b/tests/TestInteractive.hs
@@ -0,0 +1,97 @@
+module TestInteractive where
+
+import Prelude
+
+import Test.Hspec (Spec, describe, it, shouldBe, shouldSatisfy)
+import Data.List.NonEmpty qualified as NEL
+import Data.List (nub)
+
+import Language.PureScript.Interactive.Directive
+ ( directiveStrings
+ , directiveStrings'
+ , stringsFor
+ , stringFor
+ , directivesFor
+ , directivesFor'
+ , help
+ )
+import Language.PureScript.Interactive.Types (Directive(..))
+
+spec :: Spec
+spec = do
+ describe "Interactive.Directive" $ do
+ directiveStringsTests
+ directiveStrings'Tests
+ stringsForTests
+ stringForTests
+ directivesFor'Tests
+ directivesForTests
+ helpTests
+
+directiveStringsTests :: Spec
+directiveStringsTests = describe "directiveStrings" $ do
+ it "should have non-empty string lists for each directive" $ do
+ let allHaveElements = not (any (null . NEL.toList . snd) directiveStrings)
+ allHaveElements `shouldBe` True
+
+directiveStrings'Tests :: Spec
+directiveStrings'Tests = describe "directiveStrings'" $ do
+ it "should be a flattened version of directiveStrings" $ do
+ let expectedLength = sum (length . NEL.toList . snd <$> directiveStrings)
+ length directiveStrings' `shouldBe` expectedLength
+
+ it "should contain appropriate directives" $ do
+ lookup "help" directiveStrings' `shouldBe` Just Help
+ lookup "?" directiveStrings' `shouldBe` Just Help
+ lookup "quit" directiveStrings' `shouldBe` Just Quit
+ lookup "reload" directiveStrings' `shouldBe` Just Reload
+
+stringsForTests :: Spec
+stringsForTests = describe "stringsFor" $ do
+ it "should return all strings for a directive" $ do
+ NEL.toList (stringsFor Help) `shouldBe` ["?", "help"]
+ NEL.toList (stringsFor Quit) `shouldBe` ["quit"]
+ NEL.toList (stringsFor Reload) `shouldBe` ["reload"]
+
+stringForTests :: Spec
+stringForTests = describe "stringFor" $ do
+ it "should return the first string for a directive" $ do
+ stringFor Help `shouldBe` "?"
+ stringFor Quit `shouldBe` "quit"
+ stringFor Reload `shouldBe` "reload"
+
+directivesFor'Tests :: Spec
+directivesFor'Tests = describe "directivesFor'" $ do
+ it "should return matching directives and their string representations" $ do
+ directivesFor' "h" `shouldBe` [(Help, "help")]
+ directivesFor' "he" `shouldBe` [(Help, "help")]
+ directivesFor' "?" `shouldBe` [(Help, "?")]
+ directivesFor' "q" `shouldBe` [(Quit, "quit")]
+
+ it "should handle ambiguous prefixes" $ do
+ directivesFor' "" `shouldSatisfy` (not . null)
+ length (directivesFor' "") `shouldBe` length directiveStrings'
+
+ it "should return empty list for non-matching prefixes" $ do
+ directivesFor' "xyz" `shouldBe` []
+
+directivesForTests :: Spec
+directivesForTests = describe "directivesFor" $ do
+ it "should return just the directive part" $ do
+ directivesFor "h" `shouldBe` [Help]
+ directivesFor "q" `shouldBe` [Quit]
+ directivesFor "xyz" `shouldBe` []
+
+helpTests :: Spec
+helpTests = describe "help" $ do
+ it "should contain help for all directives" $ do
+ let helpDirectives = map (\(d, _, _) -> d) help
+ length (nub helpDirectives) `shouldBe` length directiveStrings
+
+ it "should contain descriptive help text" $ do
+ let helpTexts = map (\(_, _, text) -> text) help
+ not (any null helpTexts) `shouldBe` True
+
+ it "should include parameters where needed" $ do
+ lookup Browse (map (\(d, a, _) -> (d, a)) help) `shouldBe` Just ""
+ lookup Type (map (\(d, a, _) -> (d, a)) help) `shouldBe` Just ""
diff --git a/tests/TestMake.hs b/tests/TestMake.hs
new file mode 100644
index 0000000000..610e8465c8
--- /dev/null
+++ b/tests/TestMake.hs
@@ -0,0 +1,276 @@
+-- Tests for the compiler's handling of incremental builds, i.e. the code in
+-- Language.PureScript.Make.
+
+module TestMake where
+
+import Prelude
+
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+
+import Control.Concurrent (threadDelay)
+import Control.Monad (guard, void)
+import Control.Exception (tryJust)
+import Control.Monad.IO.Class (liftIO)
+import Control.Concurrent.MVar (readMVar, newMVar, modifyMVar_)
+import Data.Time.Calendar (fromGregorian)
+import Data.Time.Clock (UTCTime(..), secondsToDiffTime)
+import Data.Text qualified as T
+import Data.Set (Set)
+import Data.Set qualified as Set
+import Data.Map qualified as M
+
+import System.FilePath ((>))
+import System.Directory (createDirectory, removeDirectoryRecursive, removeFile, setModificationTime)
+import System.IO.Error (isDoesNotExistError)
+import System.IO.UTF8 (readUTF8FilesT, writeUTF8FileT)
+
+import Test.Hspec (Spec, before_, it, shouldReturn)
+
+utcMidnightOnDate :: Integer -> Int -> Int -> UTCTime
+utcMidnightOnDate year month day = UTCTime (fromGregorian year month day) (secondsToDiffTime 0)
+
+timestampA, timestampB, timestampC, timestampD :: UTCTime
+timestampA = utcMidnightOnDate 2019 1 1
+timestampB = utcMidnightOnDate 2019 1 2
+timestampC = utcMidnightOnDate 2019 1 3
+timestampD = utcMidnightOnDate 2019 1 4
+
+spec :: Spec
+spec = do
+ let sourcesDir = "tests/purs/make"
+ let moduleNames = Set.fromList . map P.moduleNameFromString
+ before_ (rimraf modulesDir >> rimraf sourcesDir >> createDirectory sourcesDir) $ do
+ it "does not recompile if there are no changes" $ do
+ let modulePath = sourcesDir > "Module.purs"
+
+ writeFileWithTimestamp modulePath timestampA "module Module where\nfoo = 0\n"
+ compile [modulePath] `shouldReturn` moduleNames ["Module"]
+ compile [modulePath] `shouldReturn` moduleNames []
+
+ it "recompiles if files have changed" $ do
+ let modulePath = sourcesDir > "Module.purs"
+
+ writeFileWithTimestamp modulePath timestampA "module Module where\nfoo = 0\n"
+ compile [modulePath] `shouldReturn` moduleNames ["Module"]
+ writeFileWithTimestamp modulePath timestampB "module Module where\nfoo = 1\n"
+ compile [modulePath] `shouldReturn` moduleNames ["Module"]
+
+ it "does not recompile if hashes have not changed" $ do
+ let modulePath = sourcesDir > "Module.purs"
+ moduleContent = "module Module where\nfoo = 0\n"
+
+ writeFileWithTimestamp modulePath timestampA moduleContent
+ compile [modulePath] `shouldReturn` moduleNames ["Module"]
+ writeFileWithTimestamp modulePath timestampB moduleContent
+ compile [modulePath] `shouldReturn` moduleNames []
+
+ it "recompiles if the file path for a module has changed" $ do
+ let modulePath1 = sourcesDir > "Module1.purs"
+ modulePath2 = sourcesDir > "Module2.purs"
+ moduleContent = "module Module where\nfoo = 0\n"
+
+ writeFileWithTimestamp modulePath1 timestampA moduleContent
+ writeFileWithTimestamp modulePath2 timestampA moduleContent
+
+ compile [modulePath1] `shouldReturn` moduleNames ["Module"]
+ compile [modulePath2] `shouldReturn` moduleNames ["Module"]
+
+ it "recompiles if an FFI file was added" $ do
+ let moduleBasePath = sourcesDir > "Module"
+ modulePath = moduleBasePath ++ ".purs"
+ moduleFFIPath = moduleBasePath ++ ".js"
+ moduleContent = "module Module where\nfoo = 0\n"
+
+ writeFileWithTimestamp modulePath timestampA moduleContent
+ compile [modulePath] `shouldReturn` moduleNames ["Module"]
+
+ writeFileWithTimestamp moduleFFIPath timestampB "export var bar = 1;\n"
+ compile [modulePath] `shouldReturn` moduleNames ["Module"]
+
+ it "recompiles if an FFI file was removed" $ do
+ let moduleBasePath = sourcesDir > "Module"
+ modulePath = moduleBasePath ++ ".purs"
+ moduleFFIPath = moduleBasePath ++ ".js"
+ moduleContent = "module Module where\nfoo = 0\n"
+
+ writeFileWithTimestamp modulePath timestampA moduleContent
+ writeFileWithTimestamp moduleFFIPath timestampB "export var bar = 1;\n"
+ compile [modulePath] `shouldReturn` moduleNames ["Module"]
+
+ removeFile moduleFFIPath
+ compile [modulePath] `shouldReturn` moduleNames ["Module"]
+
+ it "recompiles downstream modules when a module is rebuilt" $ do
+ let moduleAPath = sourcesDir > "A.purs"
+ moduleBPath = sourcesDir > "B.purs"
+ moduleAContent1 = "module A where\nfoo = 0\n"
+ moduleAContent2 = "module A where\nfoo = 1\n"
+ moduleBContent = "module B where\nimport A (foo)\nbar = foo\n"
+
+ writeFileWithTimestamp moduleAPath timestampA moduleAContent1
+ writeFileWithTimestamp moduleBPath timestampB moduleBContent
+ compile [moduleAPath, moduleBPath] `shouldReturn` moduleNames ["A", "B"]
+
+ writeFileWithTimestamp moduleAPath timestampC moduleAContent2
+ compile [moduleAPath, moduleBPath] `shouldReturn` moduleNames ["A", "B"]
+
+ it "only recompiles downstream modules when a module is rebuilt" $ do
+ let moduleAPath = sourcesDir > "A.purs"
+ moduleBPath = sourcesDir > "B.purs"
+ moduleCPath = sourcesDir > "C.purs"
+ modulePaths = [moduleAPath, moduleBPath, moduleCPath]
+ moduleAContent1 = "module A where\nfoo = 0\n"
+ moduleAContent2 = "module A where\nfoo = 1\n"
+ moduleBContent = "module B where\nimport A (foo)\nbar = foo\n"
+ moduleCContent = "module C where\nbaz = 3\n"
+
+ writeFileWithTimestamp moduleAPath timestampA moduleAContent1
+ writeFileWithTimestamp moduleBPath timestampB moduleBContent
+ writeFileWithTimestamp moduleCPath timestampC moduleCContent
+ compile modulePaths `shouldReturn` moduleNames ["A", "B", "C"]
+
+ writeFileWithTimestamp moduleAPath timestampD moduleAContent2
+ compile modulePaths `shouldReturn` moduleNames ["A", "B"]
+
+ it "does not necessarily recompile modules which were not part of the previous batch" $ do
+ let moduleAPath = sourcesDir > "A.purs"
+ moduleBPath = sourcesDir > "B.purs"
+ moduleCPath = sourcesDir > "C.purs"
+ modulePaths = [moduleAPath, moduleBPath, moduleCPath]
+ batch1 = [moduleAPath, moduleBPath]
+ batch2 = [moduleAPath, moduleCPath]
+ moduleAContent = "module A where\nfoo = 0\n"
+ moduleBContent = "module B where\nimport A (foo)\nbar = foo\n"
+ moduleCContent = "module C where\nbaz = 3\n"
+
+ writeFileWithTimestamp moduleAPath timestampA moduleAContent
+ writeFileWithTimestamp moduleBPath timestampB moduleBContent
+ writeFileWithTimestamp moduleCPath timestampC moduleCContent
+ compile modulePaths `shouldReturn` moduleNames ["A", "B", "C"]
+
+ compile batch1 `shouldReturn` moduleNames []
+ compile batch2 `shouldReturn` moduleNames []
+
+ it "recompiles if a module fails to compile" $ do
+ let modulePath = sourcesDir > "Module.purs"
+ moduleContent = "module Module where\nfoo :: Int\nfoo = \"not an int\"\n"
+
+ writeFileWithTimestamp modulePath timestampA moduleContent
+ compileAllowingFailures [modulePath] `shouldReturn` moduleNames ["Module"]
+ compileAllowingFailures [modulePath] `shouldReturn` moduleNames ["Module"]
+
+ it "recompiles if docs are requested but not up to date" $ do
+ let modulePath = sourcesDir > "Module.purs"
+ moduleContent1 = "module Module where\nx :: Int\nx = 1"
+ moduleContent2 = moduleContent1 <> "\ny :: Int\ny = 1"
+ optsWithDocs = P.defaultOptions { P.optionsCodegenTargets = Set.fromList [P.JS, P.Docs] }
+ go opts = compileWithOptions opts [modulePath] >>= assertSuccess
+ oneSecond = 10 ^ (6::Int) -- microseconds.
+
+ writeFileWithTimestamp modulePath timestampA moduleContent1
+ go optsWithDocs `shouldReturn` moduleNames ["Module"]
+ writeFileWithTimestamp modulePath timestampB moduleContent2
+ -- See Note [Sleeping to avoid flaky tests]
+ threadDelay oneSecond
+ go P.defaultOptions `shouldReturn` moduleNames ["Module"]
+ -- Since the existing docs.json is now outdated, the module should be
+ -- recompiled.
+ go optsWithDocs `shouldReturn` moduleNames ["Module"]
+
+ it "recompiles if corefn is requested but not up to date" $ do
+ let modulePath = sourcesDir > "Module.purs"
+ moduleContent1 = "module Module where\nx :: Int\nx = 1"
+ moduleContent2 = moduleContent1 <> "\ny :: Int\ny = 1"
+ optsCorefnOnly = P.defaultOptions { P.optionsCodegenTargets = Set.singleton P.CoreFn }
+ go opts = compileWithOptions opts [modulePath] >>= assertSuccess
+ oneSecond = 10 ^ (6::Int) -- microseconds.
+
+ writeFileWithTimestamp modulePath timestampA moduleContent1
+ go optsCorefnOnly `shouldReturn` moduleNames ["Module"]
+ writeFileWithTimestamp modulePath timestampB moduleContent2
+ -- See Note [Sleeping to avoid flaky tests]
+ threadDelay oneSecond
+ go P.defaultOptions `shouldReturn` moduleNames ["Module"]
+ -- Since the existing corefn.json is now outdated, the module should be
+ -- recompiled.
+ go optsCorefnOnly `shouldReturn` moduleNames ["Module"]
+
+-- Note [Sleeping to avoid flaky tests]
+--
+-- One of the things we want to test here is that all requested output files
+-- (via the --codegen CLI option) must be up to date if we are to skip
+-- recompiling a particular module. Since we check for outdatedness by
+-- comparing the timestamp of the output files (eg. corefn.json, index.js) to
+-- the timestamp of the externs file, this check is susceptible to flakiness
+-- if the timestamp resolution is sufficiently coarse. To get around this, we
+-- delay for one second.
+--
+-- Note that most of the compiler behaviour here doesn't depend on file
+-- timestamps (instead, content hashes are usually more important) and so
+-- sleeping should not be necessary in most of these tests.
+--
+-- See also discussion on https://github.com/purescript/purescript/pull/4053
+
+rimraf :: FilePath -> IO ()
+rimraf =
+ void . tryJust (guard . isDoesNotExistError) . removeDirectoryRecursive
+
+-- | Compile a group of modules, returning a set of the modules for which a
+-- rebuild was attempted, allowing the caller to set the compiler options and
+-- including the make result in the return value.
+compileWithOptions ::
+ P.Options ->
+ [FilePath] ->
+ IO (Either P.MultipleErrors [P.ExternsFile], Set P.ModuleName)
+compileWithOptions opts input = do
+ recompiled <- newMVar Set.empty
+ moduleFiles <- readUTF8FilesT input
+ (makeResult, _) <- P.runMake opts $ do
+ ms <- CST.parseModulesFromFiles id moduleFiles
+ let filePathMap = M.fromList $ map (\(fp, pm) -> (P.getModuleName $ CST.resPartial pm, Right fp)) ms
+ foreigns <- P.inferForeignModules filePathMap
+ let makeActions =
+ (P.buildMakeActions modulesDir filePathMap foreigns True)
+ { P.progress = \(P.CompilingModule mn _) ->
+ liftIO $ modifyMVar_ recompiled (return . Set.insert mn)
+ }
+ P.make makeActions (map snd ms)
+
+ recompiledModules <- readMVar recompiled
+ pure (makeResult, recompiledModules)
+
+-- | Compile a group of modules using the default options, and including the
+-- make result in the return value.
+compileWithResult ::
+ [FilePath] ->
+ IO (Either P.MultipleErrors [P.ExternsFile], Set P.ModuleName)
+compileWithResult = compileWithOptions P.defaultOptions
+
+assertSuccess :: (Either P.MultipleErrors a, Set P.ModuleName) -> IO (Set P.ModuleName)
+assertSuccess (result, recompiled) =
+ case result of
+ Left errs ->
+ fail (P.prettyPrintMultipleErrors P.defaultPPEOptions errs)
+ Right _ ->
+ pure recompiled
+
+-- | Compile, returning the set of modules which were rebuilt, and failing if
+-- any errors occurred.
+compile :: [FilePath] -> IO (Set P.ModuleName)
+compile input =
+ compileWithResult input >>= assertSuccess
+
+compileAllowingFailures :: [FilePath] -> IO (Set P.ModuleName)
+compileAllowingFailures input = fmap snd (compileWithResult input)
+
+writeFileWithTimestamp :: FilePath -> UTCTime -> T.Text -> IO ()
+writeFileWithTimestamp path mtime contents = do
+ writeUTF8FileT path contents
+ setModificationTime path mtime
+
+-- | Use a different output directory to ensure that we don't get interference
+-- from other test results
+modulesDir :: FilePath
+modulesDir = ".test_modules" > "make"
+
diff --git a/tests/TestPrimDocs.hs b/tests/TestPrimDocs.hs
index 03d94d891a..3e702786a0 100644
--- a/tests/TestPrimDocs.hs
+++ b/tests/TestPrimDocs.hs
@@ -5,17 +5,12 @@ import Prelude
import Data.List (sort)
import Control.Exception (evaluate)
import Control.DeepSeq (force)
-import qualified Data.Map as Map
-import qualified Data.Set as Set
-import qualified Language.PureScript as P
-import qualified Language.PureScript.Docs as D
+import Data.Map qualified as Map
+import Data.Text qualified as Text
+import Language.PureScript qualified as P
+import Language.PureScript.Docs qualified as D
-import Test.Tasty
-import Test.Tasty.Hspec (Spec, testSpec, it)
-import Test.Hspec (shouldBe)
-
-main :: IO TestTree
-main = testSpec "prim docs" spec
+import Test.Hspec (Spec, it, shouldBe)
spec :: Spec
spec = do
@@ -26,15 +21,16 @@ spec = do
it "all Prim modules are fully documented" $ do
let actualPrimNames =
-- note that prim type classes are listed in P.primTypes
- (map (P.runProperName . P.disqualify . fst) $ Map.toList
+ filter (not . Text.any (== '$')) . map (P.runProperName . P.disqualify . fst) $ Map.toList
( P.primTypes <>
P.primBooleanTypes <>
+ P.primCoerceTypes <>
P.primOrderingTypes <>
P.primRowTypes <>
P.primRowListTypes <>
P.primTypeErrorTypes <>
- P.primSymbolTypes )) ++
- (map (P.runProperName . P.disqualify) $ Set.toList P.allPrimKinds)
+ P.primSymbolTypes <>
+ P.primIntTypes )
let documentedPrimNames =
map D.declTitle (concatMap D.modDeclarations D.primModules)
diff --git a/tests/TestPscPublish.hs b/tests/TestPscPublish.hs
index 64dda760b9..d6a0f70bb5 100644
--- a/tests/TestPscPublish.hs
+++ b/tests/TestPscPublish.hs
@@ -1,31 +1,27 @@
-{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE OverloadedStrings #-}
-
module TestPscPublish where
import Prelude
+import Control.Exception (tryJust)
+import Control.Monad (void, guard)
import Control.Monad.IO.Class (liftIO)
import Data.ByteString.Lazy (ByteString)
import Data.Time.Clock (getCurrentTime)
-import qualified Data.Aeson as A
-import Data.Version
+import Data.Aeson qualified as A
+import Data.Version (Version(..))
import Data.Foldable (forM_)
-import qualified Text.PrettyPrint.Boxes as Boxes
-import System.Directory (listDirectory)
+import Text.PrettyPrint.Boxes qualified as Boxes
+import System.Directory (listDirectory, removeDirectoryRecursive)
import System.FilePath ((>))
+import System.IO.Error (isDoesNotExistError)
-import Language.PureScript.Docs
-import Language.PureScript.Publish
-import Language.PureScript.Publish.ErrorsWarnings as Publish
-
-import Test.Tasty
-import Test.Tasty.Hspec (Spec, Expectation, runIO, context, it, expectationFailure, testSpec)
-import TestUtils
+import Language.PureScript.Docs (UploadedPackage, VerifiedPackage)
+import Language.PureScript.Publish (PublishOptions(..), defaultPublishOptions)
+import Language.PureScript.Publish qualified as Publish
+import Language.PureScript.Publish.ErrorsWarnings qualified as Publish
-main :: IO TestTree
-main = testSpec "publish" spec
+import Test.Hspec (Expectation, Spec, context, expectationFailure, it, runIO)
+import TestUtils (pushd)
spec :: Spec
spec = do
@@ -33,17 +29,20 @@ spec = do
it "purescript-prelude" $ do
testPackage
"tests/support/bower_components/purescript-prelude"
+ "bower.json"
"../../prelude-resolutions.json"
- it "basic example" $ do
+ it "basic example (bower.json)" $ do
testPackage
"tests/purs/publish/basic-example"
+ "bower.json"
"resolutions.json"
- it "basic example with legacy resolutions file" $ do
+ it "basic example (purs.json)" $ do
testPackage
"tests/purs/publish/basic-example"
- "resolutions-legacy.json"
+ "purs.json"
+ "resolutions.json"
context "json compatibility" $ do
let compatDir = "tests" > "json-compat"
@@ -68,18 +67,20 @@ data TestResult
roundTrip :: UploadedPackage -> TestResult
roundTrip pkg =
- let before = A.encode pkg
- in case A.eitherDecode before of
+ let before' = A.encode pkg
+ in case A.eitherDecode before' of
Left err -> ParseFailed err
Right parsed -> do
let after' = A.encode (parsed :: UploadedPackage)
- if before == after'
- then Pass before
- else Mismatch before after'
+ if before' == after'
+ then Pass before'
+ else Mismatch before' after'
-testRunOptions :: PublishOptions
-testRunOptions = defaultPublishOptions
- { publishGetVersion = return testVersion
+testRunOptions :: FilePath -> FilePath -> PublishOptions
+testRunOptions manifestFile resolutionsFile = defaultPublishOptions
+ { publishResolutionsFile = resolutionsFile
+ , publishManifestFile = manifestFile
+ , publishGetVersion = return testVersion
, publishGetTagTime = const (liftIO getCurrentTime)
, publishWorkingTreeDirty = return ()
}
@@ -87,13 +88,13 @@ testRunOptions = defaultPublishOptions
-- | Given a directory which contains a package, produce JSON from it, and then
-- | attempt to parse it again, and ensure that it doesn't change.
-testPackage :: FilePath -> FilePath -> Expectation
-testPackage dir resolutionsFile = do
- res <- pushd dir (preparePackage "bower.json" resolutionsFile testRunOptions)
+testPackage :: FilePath -> FilePath -> FilePath -> Expectation
+testPackage packageDir manifestFile resolutionsFile = do
+ res <- preparePackage packageDir manifestFile resolutionsFile
case res of
Left err ->
expectationFailure $
- "Failed to produce JSON from " ++ dir ++ ":\n" ++
+ "Failed to produce JSON from " ++ packageDir ++ ":\n" ++
Boxes.render (Publish.renderError err)
Right package ->
case roundTrip package of
@@ -103,3 +104,17 @@ testPackage dir resolutionsFile = do
expectationFailure ("Failed to re-parse: " ++ msg)
Mismatch _ _ ->
expectationFailure "JSON did not match"
+
+-- A version of Publish.preparePackage suitable for use in tests. We remove the
+-- output directory each time to ensure that we are actually testing the docs
+-- code in the working tree as it is now (as opposed to how it was at some
+-- point in the past when the tests were previously successfully run).
+preparePackage :: FilePath -> FilePath -> FilePath -> IO (Either Publish.PackageError UploadedPackage)
+preparePackage packageDir manifestFile resolutionsFile =
+ pushd packageDir $ do
+ removeDirectoryRecursiveIfPresent "output"
+ Publish.preparePackage (testRunOptions manifestFile resolutionsFile)
+
+removeDirectoryRecursiveIfPresent :: FilePath -> IO ()
+removeDirectoryRecursiveIfPresent =
+ void . tryJust (guard . isDoesNotExistError) . removeDirectoryRecursive
diff --git a/tests/TestPsci.hs b/tests/TestPsci.hs
index 1f985c194f..b2dfa0dbd5 100644
--- a/tests/TestPsci.hs
+++ b/tests/TestPsci.hs
@@ -1,17 +1,14 @@
module TestPsci where
-import Prelude ()
-import Prelude.Compat
import TestPsci.CommandTest (commandTests)
import TestPsci.CompletionTest (completionTests)
import TestPsci.EvalTest (evalTests)
-import Test.Tasty
-import Test.Tasty.Hspec
+import Test.Hspec (Spec)
-main :: IO TestTree
-main = testSpec "repl" $ do
+spec :: Spec
+spec = do
completionTests
commandTests
evalTests
diff --git a/tests/TestPsci/CommandTest.hs b/tests/TestPsci/CommandTest.hs
index 758cfbc982..da68b9cd3a 100644
--- a/tests/TestPsci/CommandTest.hs
+++ b/tests/TestPsci/CommandTest.hs
@@ -1,18 +1,15 @@
-{-# LANGUAGE OverloadedStrings #-}
-
module TestPsci.CommandTest where
-import Prelude ()
-import Prelude.Compat
+import Prelude
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.RWS.Strict (get)
import Language.PureScript (moduleNameFromString)
-import Language.PureScript.Interactive
+import Language.PureScript.Interactive (psciImportedModules, psciInteractivePrint)
import System.FilePath ((>))
import System.Directory (getCurrentDirectory)
-import Test.Hspec
-import TestPsci.TestEnv
+import Test.Hspec (Spec, context, shouldContain, shouldNotContain, specify)
+import TestPsci.TestEnv (TestPSCi, equalsTo, execTestPSCi, printed, prints, run, simulateModuleEdit)
specPSCi :: String -> TestPSCi () -> Spec
specPSCi label = specify label . execTestPSCi
@@ -69,7 +66,7 @@ commandTests = context "commandTests" $ do
specPSCi ":print" $ do
let failMsg = "Unable to set the repl's printing function"
let interactivePrintModuleShouldBe modName = do
- modName' <- (fst . psciInteractivePrint) <$> get
+ modName' <- fst . psciInteractivePrint <$> get
modName' `equalsTo` modName
run "import Prelude"
diff --git a/tests/TestPsci/CompletionTest.hs b/tests/TestPsci/CompletionTest.hs
index 7cf9ba7dcb..e1fe2af592 100644
--- a/tests/TestPsci/CompletionTest.hs
+++ b/tests/TestPsci/CompletionTest.hs
@@ -1,108 +1,106 @@
-{-# LANGUAGE OverloadedStrings #-}
module TestPsci.CompletionTest where
-import Prelude ()
-import Prelude.Compat
+import Prelude
-import Test.Hspec
+import Test.Hspec (Spec, SpecWith, beforeAll, context, shouldBe, specify)
-import Control.Monad (mapM_)
-import Control.Monad.Trans.State.Strict (evalStateT)
-import Data.List (sort)
-import qualified Data.Text as T
-import qualified Language.PureScript as P
-import Language.PureScript.Interactive
-import TestPsci.TestEnv (initTestPSCiEnv)
-import TestUtils (getSupportModuleNames)
+import Control.Monad.Trans.State.Strict (evalStateT)
+import Data.Functor ((<&>))
+import Data.List (sort)
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.Interactive (CompletionM, PSCiState, completion', formatCompletions, liftCompletionM, updateImportedModules)
+import TestPsci.TestEnv (initTestPSCiEnv)
+import TestUtils (getSupportModuleNames)
completionTests :: Spec
-completionTests = context "completionTests" $ do
- mns <- runIO getSupportModuleNames
- psciState <- runIO getPSCiStateForCompletion
- mapM_ (assertCompletedOk psciState) (completionTestData mns)
+completionTests = context "completionTests" $
+ beforeAll getPSCiStateForCompletion $
+ mapM_ assertCompletedOk completionTestData
-- If the cursor is at the right end of the line, with the 1st element of the
-- pair as the text in the line, then pressing tab should offer all the
-- elements of the list (which is the 2nd element) as completions.
-completionTestData :: [T.Text] -> [(String, [String])]
-completionTestData supportModuleNames =
+completionTestData :: [(String, IO [String])]
+completionTestData =
-- basic directives
- [ (":h", [":help"])
- , (":r", [":reload"])
- , (":c", [":clear", ":complete"])
- , (":q", [":quit"])
- , (":b", [":browse"])
+ [ (":h", pure [":help"])
+ , (":r", pure [":reload"])
+ , (":c", pure [":clear", ":complete"])
+ , (":q", pure [":quit"])
+ , (":b", pure [":browse"])
-- :browse should complete module names
- , (":b Eff", map (":b Effect" ++) ["", ".Unsafe", ".Class", ".Class.Console", ".Console", ".Uncurried", ".Ref"])
- , (":b Effect.", map (":b Effect" ++) [".Unsafe", ".Class", ".Class.Console", ".Console", ".Uncurried", ".Ref"])
+ , (":b Eff", pure $ map (":b Effect" ++) ["", ".Unsafe", ".Class", ".Class.Console", ".Console", ".Uncurried", ".Ref"])
+ , (":b Effect.", pure $ map (":b Effect" ++) [".Unsafe", ".Class", ".Class.Console", ".Console", ".Uncurried", ".Ref"])
-- import should complete module names
- , ("import Eff", map ("import Effect" ++) ["", ".Unsafe", ".Class", ".Class.Console", ".Console", ".Uncurried", ".Ref"])
- , ("import Effect.", map ("import Effect" ++) [".Unsafe", ".Class", ".Class.Console", ".Console", ".Uncurried", ".Ref"])
+ , ("import Eff", pure $ map ("import Effect" ++) ["", ".Unsafe", ".Class", ".Class.Console", ".Console", ".Uncurried", ".Ref"])
+ , ("import Effect.", pure $ map ("import Effect" ++) [".Unsafe", ".Class", ".Class.Console", ".Console", ".Uncurried", ".Ref"])
-- :quit, :help, :reload, :clear should not complete
- , (":help ", [])
- , (":quit ", [])
- , (":reload ", [])
- , (":clear ", [])
+ , (":help ", pure [])
+ , (":quit ", pure [])
+ , (":reload ", pure [])
+ , (":clear ", pure [])
-- :show should complete its available arguments
- , (":show ", [":show import", ":show loaded", ":show print"])
- , (":show a", [])
+ , (":show ", pure [":show import", ":show loaded", ":show print"])
+ , (":show a", pure [])
-- :type should complete next word from values and constructors in scope
- , (":type uni", [":type unit"])
- , (":type E", [":type EQ"])
- , (":type P.", map (":type P." ++) ["EQ", "GT", "LT", "unit"]) -- import Prelude (unit, Ordering(..)) as P
- , (":type Effect.Console.lo", [])
- , (":type voi", [])
+ , (":type uni", pure [":type unit"])
+ , (":type E", pure [":type EQ"])
+ , (":type P.", pure $ map (":type P." ++) ["EQ", "GT", "LT", "unit"]) -- import Prelude (unit, Ordering(..)) as P
+ , (":type Effect.Console.lo", pure [])
+ , (":type voi", pure [])
-- :kind should complete next word from types in scope
- , (":kind Str", [":kind String"])
- , (":kind ST.", [":kind ST.ST"]) -- import Control.Monad.ST as ST
- , (":kind STRef.", [":kind STRef.STRef"]) -- import Control.Monad.ST.Ref as STRef
- , (":kind Effect.", [])
+ , (":kind Str", pure [":kind String"])
+ , (":kind ST.", pure [":kind ST.Region", ":kind ST.ST"]) -- import Control.Monad.ST as ST
+ , (":kind STRef.", pure [":kind STRef.STRef"]) -- import Control.Monad.ST.Ref as STRef
+ , (":kind Effect.", pure [])
-- Only one argument for these directives should be completed
- , (":show import ", [])
- , (":browse Data.List ", [])
+ , (":show import ", pure [])
+ , (":browse Data.List ", pure [])
-- These directives take any number of completable terms
- , (":type const compa", [":type const compare", ":type const comparing"])
- , (":kind Array In", [":kind Array Int"])
+ , (":type const compa", pure [":type const compare", ":type const comparing"])
+ , (":kind Array In", pure [":kind Array Int"])
-- a few other import tests
- , ("impor", ["import"])
- , ("import ", map (T.unpack . mappend "import ") supportModuleNames)
- , ("import Prelude ", [])
+ , ("impor", pure ["import"])
+ , ("import ", getSupportModuleNames <&> map (T.unpack . mappend "import "))
+ , ("import Prelude ", pure [])
-- String and number literals should not be completed
- , ("\"hi", [])
- , ("34", [])
+ , ("\"hi", pure [])
+ , ("34", pure [])
-- Identifiers and data constructors in scope should be completed
- , ("uni", ["unit"])
- , ("G", ["GT"])
- , ("P.G", ["P.GT"])
- , ("P.uni", ["P.unit"])
- , ("voi", []) -- import Prelude hiding (void)
- , ("Effect.Class.", [])
+ , ("uni", pure ["unit"])
+ , ("G", pure ["GT"])
+ , ("P.G", pure ["P.GT"])
+ , ("P.uni", pure ["P.unit"])
+ , ("voi", pure []) -- import Prelude hiding (void)
+ , ("Effect.Class.", pure [])
-- complete first name after type annotation symbol
- , ("1 :: I", ["1 :: Int"])
- , ("1 ::I", ["1 ::Int"])
- , ("1:: I", ["1:: Int"])
- , ("1::I", ["1::Int"])
- , ("(1::Int) uni", ["(1::Int) unit"]) -- back to completing values
+ , ("1 :: I", pure ["1 :: Int"])
+ , ("1 ::I", pure ["1 ::Int"])
+ , ("1:: I", pure ["1:: Int"])
+ , ("1::I", pure ["1::Int"])
+ , ("(1::Int) uni", pure ["(1::Int) unit"]) -- back to completing values
-- Parens and brackets aren't considered part of the current identifier
- , ("map id [uni", ["map id [unit"])
- , ("map (cons", ["map (const"])
+ , ("map id [uni", pure ["map id [unit"])
+ , ("map (cons", pure ["map (const"])
]
-assertCompletedOk :: PSCiState -> (String, [String]) -> Spec
-assertCompletedOk psciState (line, expecteds) = specify line $ do
+assertCompletedOk :: (String, IO [String]) -> SpecWith PSCiState
+assertCompletedOk (line, expectedsM) = specify line $ \psciState -> do
+ expecteds <- expectedsM
results <- runCM psciState (completion' (reverse line, ""))
let actuals = formatCompletions results
sort actuals `shouldBe` sort expecteds
diff --git a/tests/TestPsci/EvalTest.hs b/tests/TestPsci/EvalTest.hs
index 5aae8ab90a..b46b3492f9 100644
--- a/tests/TestPsci/EvalTest.hs
+++ b/tests/TestPsci/EvalTest.hs
@@ -1,19 +1,18 @@
module TestPsci.EvalTest where
-import Prelude ()
-import Prelude.Compat
+import Prelude
-import Control.Monad (forM_, foldM_)
-import Control.Monad.IO.Class (liftIO)
-import Data.List (stripPrefix, intercalate)
-import Data.List.Split (splitOn)
-import System.Directory (getCurrentDirectory)
-import System.Exit (exitFailure)
-import System.FilePath ((>), takeFileName)
-import qualified System.FilePath.Glob as Glob
-import System.IO.UTF8 (readUTF8File)
-import Test.Hspec
-import TestPsci.TestEnv
+import Control.Monad (forM_, foldM_)
+import Control.Monad.IO.Class (liftIO)
+import Data.List (stripPrefix, intercalate)
+import Data.List.Split (splitOn)
+import System.Directory (getCurrentDirectory)
+import System.Exit (exitFailure)
+import System.FilePath ((>), takeFileName)
+import System.FilePath.Glob qualified as Glob
+import System.IO.UTF8 (readUTF8File)
+import Test.Hspec (Spec, context, runIO, specify)
+import TestPsci.TestEnv (TestPSCi, evaluatesTo, execTestPSCi, run)
evalTests :: Spec
evalTests = context "evalTests" $ do
@@ -46,8 +45,8 @@ parseEvalLine line =
case stripPrefix evalCommentPrefix line of
Just rest ->
case splitOn " " rest of
- "shouldEvaluateTo" : args -> Comment (ShouldEvaluateTo $ intercalate " " args)
- "paste" : [] -> Comment (Paste [])
+ "shouldEvaluateTo" : args -> Comment (ShouldEvaluateTo $ unwords args)
+ ["paste"] -> Comment (Paste [])
_ -> Invalid line
Nothing -> Line line
diff --git a/tests/TestPsci/TestEnv.hs b/tests/TestPsci/TestEnv.hs
index 31d5fdc591..b79b4c2220 100644
--- a/tests/TestPsci/TestEnv.hs
+++ b/tests/TestPsci/TestEnv.hs
@@ -1,26 +1,22 @@
-{-# LANGUAGE OverloadedStrings #-}
-
module TestPsci.TestEnv where
-import Prelude ()
-import Prelude.Compat
-
-import Control.Exception.Lifted (bracket_)
-import Control.Monad (void, when)
-import Control.Monad.IO.Class (liftIO)
-import Control.Monad.Trans.RWS.Strict (evalRWST, asks, local, RWST)
-import Data.Foldable (traverse_)
-import Data.List (isSuffixOf)
-import qualified Data.Text as T
-import qualified Language.PureScript as P
-import qualified Language.PureScript.CST as CST
-import Language.PureScript.Interactive
-import System.Directory (getCurrentDirectory, doesPathExist, removeFile)
-import System.Exit
-import System.FilePath ((>), pathSeparator)
-import qualified System.FilePath.Glob as Glob
-import System.Process (readProcessWithExitCode)
-import Test.Hspec (shouldBe, Expectation)
+import Prelude
+
+import Control.Exception.Lifted (bracket_)
+import Control.Monad (void, when)
+import Control.Monad.IO.Class (liftIO)
+import Control.Monad.Trans.RWS.Strict (evalRWST, asks, local, RWST)
+import Data.Foldable (traverse_)
+import Data.List (isSuffixOf)
+import Data.Text qualified as T
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.Interactive (Command(..), PSCiConfig(..), PSCiState, handleCommand, indexFile, initialPSCiState, loadAllModules, make, modulesDir, parseCommand, readNodeProcessWithExitCode, runMake, updateLoadedExterns)
+import System.Directory (getCurrentDirectory, doesPathExist, removeFile)
+import System.Exit
+import System.FilePath ((>), pathSeparator)
+import System.FilePath.Glob qualified as Glob
+import Test.Hspec (shouldBe, Expectation)
-- | A monad transformer for handle PSCi actions in tests
type TestPSCi a = RWST PSCiConfig () PSCiState IO a
@@ -57,13 +53,12 @@ execTestPSCi i = do
-- command evaluation.
jsEval :: TestPSCi String
jsEval = liftIO $ do
- writeFile indexFile "require('$PSCI')['$main']();"
- process <- findNodeProcess
- result <- traverse (\node -> readProcessWithExitCode node [indexFile] "") process
+ writeFile indexFile "import('./$PSCI/index.js').then(({ $main }) => $main());"
+ result <- readNodeProcessWithExitCode Nothing [indexFile] ""
case result of
- Just (ExitSuccess, out, _) -> return out
- Just (ExitFailure _, _, err) -> putStrLn err >> exitFailure
- Nothing -> putStrLn "Couldn't find node.js" >> exitFailure
+ Right (ExitSuccess, out, _) -> return out
+ Right (ExitFailure _, _, err) -> putStrLn err >> exitFailure
+ Left err -> putStrLn err >> exitFailure
-- | Run a PSCi command and evaluate its outputs:
-- * jsOutputEval is used to evaluate compiled JS output by PSCi
@@ -75,7 +70,7 @@ runAndEval comm jsOutputEval textOutputEval =
Right commands ->
-- The JS result is ignored, as it's already written in a JS source file.
-- For the detail, please refer to Interactive.hs
- traverse_ (handleCommand (\_ -> jsOutputEval) (return ()) textOutputEval) commands
+ traverse_ (handleCommand (const jsOutputEval) (return ()) textOutputEval) commands
-- | Run a PSCi command, evaluate compiled JS, and ignore evaluation output and printed output
run :: String -> TestPSCi ()
diff --git a/tests/TestSourceMaps.hs b/tests/TestSourceMaps.hs
new file mode 100644
index 0000000000..5b91017d52
--- /dev/null
+++ b/tests/TestSourceMaps.hs
@@ -0,0 +1,77 @@
+module TestSourceMaps where
+
+import Prelude
+
+import Control.Monad (void, forM_)
+import Data.Aeson as Json
+import Test.Hspec (Expectation, SpecWith, describe, expectationFailure, it, runIO, shouldBe)
+import System.FilePath (replaceExtension, takeFileName, (>), (<.>))
+import Language.PureScript qualified as P
+import Data.ByteString qualified as BS
+import Data.ByteString.Lazy qualified as LBS
+import Data.Foldable (fold)
+import TestUtils (getTestFiles, SupportModules (..), compile', ExpectedModuleName (IsSourceMap))
+import Data.Set qualified as Set
+import TestCompiler (getTestMain)
+import System.Process.Typed (proc, readProcess_)
+
+spec :: SpecWith SupportModules
+spec =
+ goldenFiles
+
+-- See the CONTRIBUTING.md file for why the below requirements are needed.
+-- Test files and their module names must abide by the following requirements:
+-- - Test files must reside in the @tests/purs/sourcemaps/@ directory
+-- - Module names must be prefixed with "SourceMaps." with the remainder
+-- matching the file name. For example:
+-- - File Name: @tests/purs/sourcemaps/Test123.purs@
+-- - Module Name: @SourceMaps.Test123@
+-- - File Name: @tests/purs/sourcemaps/Bug1234.purs@
+-- - Module Name: @SourceMaps.Bug1234@
+goldenFiles :: SpecWith SupportModules
+goldenFiles = do
+ sourceMapsFiles <- runIO $ getTestFiles "sourcemaps"
+
+ describe "golden files" $
+ forM_ sourceMapsFiles $ \inputFiles -> do
+ let
+ testName = fold
+ [ "'"
+ , takeFileName (getTestMain inputFiles)
+ , "' should compile to expected output and produce a valid source map file"
+ ]
+ it testName $ \support -> do
+ assertCompilesToExpectedValidOutput support inputFiles
+
+assertCompilesToExpectedValidOutput
+ :: SupportModules
+ -> [FilePath]
+ -> Expectation
+assertCompilesToExpectedValidOutput support inputFiles = do
+
+ let
+ modulePath = getTestMain inputFiles
+
+ (fileContents, (result, _)) <- compile' compilationOptions (Just (IsSourceMap modulePath)) support inputFiles
+ let errorOptions = P.defaultPPEOptions { P.ppeFileContents = fileContents }
+ case result of
+ Left errs -> expectationFailure . P.prettyPrintMultipleErrors errorOptions $ errs
+ Right actualSourceMapFile -> do
+ let
+ readAndDecode :: FilePath -> IO (Maybe Json.Value)
+ readAndDecode = fmap (Json.decode . LBS.fromStrict) . BS.readFile
+ goldenFile <- readAndDecode $ replaceExtension modulePath ".out.js.map"
+ actualFile <- readAndDecode actualSourceMapFile
+ goldenFile `shouldBe` actualFile
+ sourceMapIsValid actualSourceMapFile
+
+ where
+ compilationOptions :: P.Options
+ compilationOptions = P.defaultOptions { P.optionsCodegenTargets = Set.fromList [P.JS, P.JSSourceMap] }
+
+-- | Fails the test if the produced source maps are not valid.
+sourceMapIsValid :: FilePath -> Expectation
+sourceMapIsValid sourceMapFilePath = do
+ let
+ scriptPath = "tests" > "support" > "checkSourceMapValidity" <.> "js"
+ void $ readProcess_ (proc "node" [scriptPath, sourceMapFilePath])
diff --git a/tests/TestUtils.hs b/tests/TestUtils.hs
index fe0c14d41d..146093c452 100644
--- a/tests/TestUtils.hs
+++ b/tests/TestUtils.hs
@@ -1,43 +1,41 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE OverloadedStrings #-}
-
-
module TestUtils where
-import Prelude ()
-import Prelude.Compat
+import Prelude
-import qualified Language.PureScript as P
-import qualified Language.PureScript.CST as CST
+import Language.PureScript qualified as P
+import Language.PureScript.CST qualified as CST
+import Language.PureScript.AST qualified as AST
+import Language.PureScript.Names qualified as N
+import Language.PureScript.Interactive.IO (findNodeProcess)
import Control.Arrow ((***), (>>>))
-import Control.Monad
-import Control.Monad.Reader
-import Control.Monad.Trans.Except
-import Control.Monad.Trans.Maybe
-import Control.Exception
+import Control.Monad (forM, guard, unless)
+import Control.Monad.Reader (MonadIO(..), MonadTrans(..))
+import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
+import Control.Monad.Trans.Maybe (MaybeT(..))
+import Control.Monad.Writer.Class (tell)
+import Control.Exception (IOException, catch, throw, throwIO, try, tryJust)
+import Data.ByteString (ByteString)
+import Data.ByteString qualified as BS
import Data.Char (isSpace)
import Data.Function (on)
-import Data.List (sort, sortBy, stripPrefix, groupBy)
-import qualified Data.Map as M
-import qualified Data.Text as T
-import Data.Time.Clock (UTCTime())
+import Data.List (sort, sortBy, stripPrefix, groupBy, find)
+import Data.Map qualified as M
+import Data.Maybe (isJust)
+import Data.Text qualified as T
+import Data.Text.Encoding qualified as T
+import Data.Time.Clock (UTCTime(), diffUTCTime, getCurrentTime, nominalDay)
import Data.Tuple (swap)
-import System.Process hiding (cwd)
-import System.Directory
-import System.Info
-import System.IO.UTF8 (readUTF8FileT)
+import System.Directory (createDirectoryIfMissing, doesDirectoryExist, getCurrentDirectory, getModificationTime, getTemporaryDirectory, listDirectory, setCurrentDirectory, withCurrentDirectory)
import System.Exit (exitFailure)
-import System.FilePath
-import qualified System.FilePath.Glob as Glob
-import System.IO
-import Test.Tasty.Hspec
-
-
-findNodeProcess :: IO (Maybe String)
-findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
- where
- names = ["nodejs", "node"]
+import System.Environment (lookupEnv)
+import System.FilePath (dropExtensions, makeRelative, takeDirectory, takeExtensions, takeFileName, (>))
+import System.IO.Error (isDoesNotExistError)
+import System.IO.UTF8 (readUTF8FileT)
+import System.Process (callCommand, callProcess)
+import System.FilePath.Glob qualified as Glob
+import System.IO (Handle, IOMode(..), hPutStrLn, openFile, stderr)
+import Test.Hspec (Expectation, HasCallStack, expectationFailure, pendingWith)
-- |
-- Fetches code necessary to run the tests with. The resulting support code
@@ -48,24 +46,55 @@ findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
-- updating.
--
updateSupportCode :: IO ()
-updateSupportCode = do
- setCurrentDirectory "tests/support"
- if System.Info.os == "mingw32"
- then callProcess "setup-win.cmd" []
- else do
- callProcess "npm" ["install"]
- -- bower uses shebang "/usr/bin/env node", but we might have nodejs
- node <- maybe cannotFindNode pure =<< findNodeProcess
- -- Sometimes we run as a root (e.g. in simple docker containers)
- -- And we are non-interactive: https://github.com/bower/bower/issues/1162
- callProcess node ["node_modules/.bin/bower", "--allow-root", "install", "--config.interactive=false"]
- setCurrentDirectory "../.."
+updateSupportCode = withCurrentDirectory "tests/support" $ do
+ let lastUpdatedFile = ".last_updated"
+ skipUpdate <- fmap isJust . runMaybeT $ do
+ -- We skip the update if: `.last_updated` exists,
+ lastUpdated <- MaybeT $ getModificationTimeMaybe lastUpdatedFile
+
+ -- ... and it was modified less than a day ago (no particular reason why
+ -- "one day" specifically),
+ now <- lift getCurrentTime
+ guard $ now `diffUTCTime` lastUpdated < nominalDay
+
+ -- ... and the needed directories exist,
+ contents <- lift $ listDirectory "."
+ guard $ "node_modules" `elem` contents && "bower_components" `elem` contents
+
+ -- ... and everything else in `tests/support` is at least as old as
+ -- `.last_updated`.
+ modTimes <- lift $ traverse getModificationTime . filter (/= lastUpdatedFile) $ contents
+ guard $ all (<= lastUpdated) modTimes
+
+ pure ()
+
+ unless skipUpdate $ do
+ heading "Updating support code"
+ callCommand "npm install"
+ -- bower uses shebang "/usr/bin/env node", but we might have nodejs
+ node <- either cannotFindNode pure =<< findNodeProcess
+ -- Sometimes we run as a root (e.g. in simple docker containers)
+ -- And we are non-interactive: https://github.com/bower/bower/issues/1162
+ callProcess node ["node_modules/bower/bin/bower", "--allow-root", "install", "--config.interactive=false"]
+ writeFile lastUpdatedFile ""
where
- cannotFindNode :: IO a
- cannotFindNode = do
- hPutStrLn stderr "Cannot find node (or nodejs) executable"
+ cannotFindNode :: String -> IO a
+ cannotFindNode message = do
+ hPutStrLn stderr message
exitFailure
+ getModificationTimeMaybe :: FilePath -> IO (Maybe UTCTime)
+ getModificationTimeMaybe f = catch (Just <$> getModificationTime f) $ \case
+ e | isDoesNotExistError e -> pure Nothing
+ | otherwise -> throw e
+
+ heading msg = do
+ putStrLn ""
+ putStrLn $ replicate 79 '#'
+ putStrLn $ "# " ++ msg
+ putStrLn $ replicate 79 '#'
+ putStrLn ""
+
readInput :: [FilePath] -> IO [(FilePath, T.Text)]
readInput inputFiles = forM inputFiles $ \inputFile -> do
text <- readUTF8FileT inputFile
@@ -85,7 +114,7 @@ getSupportModuleTuples = do
fileContents <- readInput pursFiles
modules <- runExceptT $ ExceptT . return $ CST.parseFromFiles id fileContents
case modules of
- Right ms -> return ms
+ Right ms -> return (fmap (fmap snd) ms)
Left errs -> fail (P.prettyPrintMultipleErrors P.defaultPPEOptions errs)
getSupportModuleNames :: IO [T.Text]
@@ -106,7 +135,13 @@ createOutputFile logfileName = do
createDirectoryIfMissing False (tmp > logpath)
openFile (tmp > logpath > logfileName) WriteMode
-setupSupportModules :: IO ([P.Module], [P.ExternsFile], M.Map P.ModuleName FilePath)
+data SupportModules = SupportModules
+ { supportModules :: [P.Module]
+ , supportExterns :: [P.ExternsFile]
+ , supportForeigns :: M.Map P.ModuleName FilePath
+ }
+
+setupSupportModules :: IO SupportModules
setupSupportModules = do
ms <- getSupportModuleTuples
let modules = map snd ms
@@ -116,27 +151,12 @@ setupSupportModules = do
return (externs, foreigns)
case supportExterns of
Left errs -> fail (P.prettyPrintMultipleErrors P.defaultPPEOptions errs)
- Right (externs, foreigns) -> return (modules, externs, foreigns)
+ Right (externs, foreigns) -> return $ SupportModules modules externs foreigns
getTestFiles :: FilePath -> IO [[FilePath]]
getTestFiles testDir = do
- cwd <- getCurrentDirectory
- let dir = cwd > "tests" > "purs" > testDir
- testsInPath <- getFiles dir <$> testGlob dir
- let rerunPath = dir > "RerunCompilerTests.txt"
- hasRerunFile <- doesFileExist rerunPath
- rerunTests <-
- if hasRerunFile
- then let compilerTestDir = cwd > "tests" > "purs" > "passing"
- textToTestFiles
- = mapM (\path -> ((path ++ ".purs") :) <$> testGlob path)
- . map ((compilerTestDir >) . T.unpack)
- . filter (not . T.null)
- . map (T.strip . fst . T.breakOn "--")
- . T.lines
- in readUTF8FileT rerunPath >>= textToTestFiles
- else return []
- return $ testsInPath ++ rerunTests
+ let dir = "tests" > "purs" > testDir
+ getFiles dir <$> testGlob dir
where
-- A glob for all purs and js files within a test directory
testGlob :: FilePath -> IO [FilePath]
@@ -160,51 +180,72 @@ getTestFiles testDir = do
then maybe fp reverse $ stripPrefix ext $ reverse fp
else dir
+data ExpectedModuleName
+ = IsMain
+ | IsSourceMap FilePath
+
compile
- :: [P.Module]
- -> [P.ExternsFile]
- -> M.Map P.ModuleName FilePath
+ :: Maybe ExpectedModuleName
+ -> SupportModules
-> [FilePath]
- -> ([P.Module] -> IO ())
- -> IO (Either P.MultipleErrors [P.ExternsFile], P.MultipleErrors)
-compile supportModules supportExterns supportForeigns inputFiles check = runTest $ do
- fs <- liftIO $ readInput inputFiles
- ms <- CST.parseFromFiles id fs
- foreigns <- inferForeignModules ms
- liftIO (check (map snd ms))
- let actions = makeActions supportModules (foreigns `M.union` supportForeigns)
- case ms of
- [singleModule] -> pure <$> P.rebuildModule actions supportExterns (snd singleModule)
- _ -> P.make actions (CST.pureResult <$> supportModules ++ map snd ms)
-
-assert
- :: [P.Module]
- -> [P.ExternsFile]
- -> M.Map P.ModuleName FilePath
+ -> IO ([(FilePath, T.Text)], (Either P.MultipleErrors FilePath, P.MultipleErrors))
+compile = compile' P.defaultOptions
+
+compile'
+ :: P.Options
+ -> Maybe ExpectedModuleName
+ -> SupportModules
-> [FilePath]
- -> ([P.Module] -> IO ())
- -> (Either P.MultipleErrors P.MultipleErrors -> IO (Maybe String))
- -> Expectation
-assert supportModules supportExterns supportForeigns inputFiles check f = do
- (e, w) <- compile supportModules supportExterns supportForeigns inputFiles check
- maybeErr <- f (const w <$> e)
- maybe (return ()) expectationFailure maybeErr
+ -> IO ([(FilePath, T.Text)], (Either P.MultipleErrors FilePath, P.MultipleErrors))
+compile' options expectedModule SupportModules{..} inputFiles = do
+ -- Sorting the input files makes some messages (e.g., duplicate module) deterministic
+ fs <- readInput (sort inputFiles)
+ fmap (fs, ) . P.runMake options $ do
+ msWithWarnings <- CST.parseFromFiles id fs
+ tell $ foldMap (\(fp, (ws, _)) -> CST.toMultipleWarnings fp ws) msWithWarnings
+ let ms = fmap snd <$> msWithWarnings
+ foreigns <- inferForeignModules ms
+ let
+ actions = makeActions supportModules (foreigns `M.union` supportForeigns)
+ (hasExpectedModuleName, expectedModuleName, compiledModulePath) = case expectedModule of
+ -- Check if there is one (and only one) module called "Main"
+ Just IsMain ->
+ let
+ moduleName = "Main"
+ compiledPath = modulesDir > moduleName > "index.js"
+ in ((==) 1 $ length $ filter (== moduleName) $ fmap (T.unpack . getPsModuleName) ms, moduleName, compiledPath)
+ -- Check if main sourcemap module starts with "SourceMaps." and matches its file name
+ Just (IsSourceMap modulePath) ->
+ let
+ moduleName = "SourceMaps." <> (dropExtensions . takeFileName $ modulePath)
+ compiledPath = modulesDir > moduleName > "index.js.map"
+ in (maybe False ((==) moduleName . T.unpack . getPsModuleName) (find ((==) modulePath . fst) ms), moduleName, compiledPath)
+ Nothing -> (True, mempty, mempty)
-checkMain :: [P.Module] -> IO ()
-checkMain ms =
- unless (any ((== P.moduleNameFromString "Main") . P.getModuleName) ms)
- (fail "Main module missing")
+ case ms of
+ [singleModule] -> do
+ unless hasExpectedModuleName $
+ error ("While testing a single PureScript file, the expected module name was '" <> expectedModuleName <>
+ "' but got '" <> T.unpack (getPsModuleName singleModule) <> "'.")
+ compiledModulePath <$ P.rebuildModule actions supportExterns (snd singleModule)
+ _ -> do
+ unless hasExpectedModuleName $
+ error $ "While testing multiple PureScript files, the expected main module was not found: '" <> expectedModuleName <> "'."
+ compiledModulePath <$ P.make actions (CST.pureResult <$> supportModules ++ map snd ms)
+getPsModuleName :: (a, AST.Module) -> T.Text
+getPsModuleName psModule = case snd psModule of
+ AST.Module _ _ (N.ModuleName t) _ _ -> t
makeActions :: [P.Module] -> M.Map P.ModuleName FilePath -> P.MakeActions P.Make
makeActions modules foreigns = (P.buildMakeActions modulesDir (P.internalError "makeActions: input file map was read.") foreigns False)
- { P.getInputTimestamp = getInputTimestamp
+ { P.getInputTimestampsAndHashes = getInputTimestampsAndHashes
, P.getOutputTimestamp = getOutputTimestamp
, P.progress = const (pure ())
}
where
- getInputTimestamp :: P.ModuleName -> P.Make (Either P.RebuildPolicy (Maybe UTCTime))
- getInputTimestamp mn
+ getInputTimestampsAndHashes :: P.ModuleName -> P.Make (Either P.RebuildPolicy a)
+ getInputTimestampsAndHashes mn
| isSupportModule (P.runModuleName mn) = return (Left P.RebuildNever)
| otherwise = return (Left P.RebuildAlways)
where
@@ -233,7 +274,45 @@ trim :: String -> String
trim = dropWhile isSpace >>> reverse >>> dropWhile isSpace >>> reverse
modulesDir :: FilePath
-modulesDir = ".test_modules" > "node_modules"
+modulesDir = ".test_modules"
logpath :: FilePath
logpath = "purescript-output"
+
+-- | Assert that the contents of the provided file path match the result of the
+-- provided action. If the "HSPEC_ACCEPT" environment variable is set, or if the
+-- file does not already exist, we write the resulting ByteString out to the
+-- provided file path instead. However, if the "CI" environment variable is
+-- set, "HSPEC_ACCEPT" is ignored and we require that the file does exist with
+-- the correct contents (see #3808). Based (very loosely) on the tasty-golden
+-- package.
+goldenVsString
+ :: HasCallStack -- For expectationFailure; use the call site for better failure locations
+ => FilePath
+ -> IO ByteString
+ -> Expectation
+goldenVsString goldenFile testAction = do
+ accept <- isJust <$> lookupEnv "HSPEC_ACCEPT"
+ ci <- isJust <$> lookupEnv "CI"
+ goldenContents <- tryJust (guard . isDoesNotExistError) (BS.readFile goldenFile)
+ case goldenContents of
+ Left () ->
+ -- The golden file does not exist
+ if ci
+ then expectationFailure $ "Missing golden file: " ++ goldenFile
+ else createOrReplaceGoldenFile
+
+ Right _ | not ci && accept ->
+ createOrReplaceGoldenFile
+
+ Right expected -> do
+ actual <- testAction
+ if expected == actual
+ then pure ()
+ else expectationFailure $
+ "Test output differed from '" ++ goldenFile ++ "'; got:\n" ++
+ T.unpack (T.decodeUtf8With (\_ _ -> Just '\xFFFD') actual)
+ where
+ createOrReplaceGoldenFile = do
+ testAction >>= BS.writeFile goldenFile
+ pendingWith "Accepting new output"
diff --git a/tests/json-compat/v0.14.0/prelude-5.0.1.json b/tests/json-compat/v0.14.0/prelude-5.0.1.json
new file mode 100644
index 0000000000..cdfa5a0930
--- /dev/null
+++ b/tests/json-compat/v0.14.0/prelude-5.0.1.json
@@ -0,0 +1 @@
+{"uploader":"thomashoneyman","packageMeta":{"homepage":"https://github.com/purescript/purescript-prelude","repository":{"url":"https://github.com/purescript/purescript-prelude.git","type":"git"},"ignore":["**/.*","bower_components","node_modules","output","test","bower.json","package.json"],"name":"purescript-prelude","license":["BSD-3-Clause"],"description":"The PureScript Prelude"},"tagTime":"2021-05-11T21:10:31+0000","modules":[{"reExports":[{"moduleName":{"package":null,"item":["Control","Apply"]},"declarations":[{"children":[{"comments":null,"title":"apply","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[46,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"comments":null,"title":"applyFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[51,26]}},{"comments":null,"title":"applyArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[54,21]}},{"comments":null,"title":"applyProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[59,20]}}],"comments":"The `Apply` class provides the `(<*>)` which is used to apply a function\nto an argument under a type constructor.\n\n`Apply` can be used to lift functions of two or more arguments to work on\nvalues wrapped with the type constructor `f`. It might also be understood\nin terms of the `lift2` function:\n\n```purescript\nlift2 :: forall f a b c. Apply f => (a -> b -> c) -> f a -> f b -> f c\nlift2 f a b = f <$> a <*> b\n```\n\n`(<*>)` is recovered from `lift2` as `lift2 ($)`. That is, `(<*>)` lifts\nthe function application operator `($)` to arguments wrapped with the\ntype constructor `f`.\n\nPut differently...\n```\nfoo =\n functionTakingNArguments <$> computationProducingArg1\n <*> computationProducingArg2\n <*> ...\n <*> computationProducingArgN\n```\n\nInstances must satisfy the following law in addition to the `Functor`\nlaws:\n\n- Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`\n\nFormally, `Apply` represents a strong lax semi-monoidal endofunctor.\n","title":"Apply","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"children":[],"comments":null,"title":"(<*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"apply"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[48,22]}},{"children":[],"comments":null,"title":"(<*)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applyFirst"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[65,26]}},{"children":[],"comments":null,"title":"(*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applySecond"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[71,27]}}]},{"moduleName":{"package":null,"item":["Data","Functor"]},"declarations":[{"children":[{"comments":null,"title":"map","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[26,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"comments":null,"title":"functorFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[41,16]}},{"comments":null,"title":"functorArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[44,17]}},{"comments":null,"title":"functorProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[47,18]}}],"comments":"A `Functor` is a type constructor which supports a mapping operation\n`map`.\n\n`map` can be used to turn functions `a -> b` into functions\n`f a -> f b` whose argument and return types use the type constructor `f`\nto represent some computational context.\n\nInstances must satisfy the following laws:\n\n- Identity: `map identity = identity`\n- Composition: `map (f <<< g) = map f <<< map g`\n","title":"Functor","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"children":[],"comments":"The `void` function is used to ignore the type wrapped by a\n[`Functor`](#functor), replacing it with `Unit` and keeping only the type\ninformation provided by the type constructor itself.\n\n`void` is often useful when using `do` notation to change the return type\nof a monadic computation:\n\n```purescript\nmain = forE 1 10 \\n -> void do\n print n\n print (n * n)\n```\n","title":"void","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]},null]},null]}},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[63,47]}},{"children":[],"comments":null,"title":"(<$>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"map"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[28,20]}},{"children":[],"comments":null,"title":"(<$)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidRight"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[71,25]}},{"children":[],"comments":null,"title":"(<#>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"mapFlipped"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[38,27]}},{"children":[],"comments":null,"title":"($>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidLeft"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[77,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[77,24]}}]}],"name":"Control.Applicative","comments":null,"declarations":[{"children":[{"comments":null,"title":"pure","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]}},"sourceSpan":{"start":[34,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[34,29]}},{"comments":null,"title":"applicativeFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[37,15]}},{"comments":null,"title":"applicativeArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[40,15]}},{"comments":null,"title":"applicativeProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[43,17]}}],"comments":"The `Applicative` type class extends the [`Apply`](#apply) type class\nwith a `pure` function, which can be used to create values of type `f a`\nfrom values of type `a`.\n\nWhere [`Apply`](#apply) provides the ability to lift functions of two or\nmore arguments to functions whose arguments are wrapped using `f`, and\n[`Functor`](#functor) provides the ability to lift functions of one\nargument, `pure` can be seen as the function which lifts functions of\n_zero_ arguments. That is, `Applicative` functors support a lifting\noperation for any number of function arguments.\n\nInstances must satisfy the following laws in addition to the `Apply`\nlaws:\n\n- Identity: `(pure identity) <*> v = v`\n- Composition: `pure (<<<) <*> f <*> g <*> h = f <*> (g <*> h)`\n- Homomorphism: `(pure f) <*> (pure x) = pure (f x)`\n- Interchange: `u <*> (pure y) = (pure (_ $ y)) <*> u`\n","title":"Applicative","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[34,29]}},{"children":[],"comments":"`liftA1` provides a default implementation of `(<$>)` for any\n[`Applicative`](#applicative) functor, without using `(<$>)` as provided\nby the [`Functor`](#functor)-[`Applicative`](#applicative) superclass\nrelationship.\n\n`liftA1` can therefore be used to write [`Functor`](#functor) instances\nas follows:\n\n```purescript\ninstance functorF :: Functor F where\n map = liftA1\n```\n","title":"liftA1","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[57,64]}},{"children":[],"comments":"Perform an applicative action unless a condition is true.\n","title":"unless","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[66,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[66,65]}},{"children":[],"comments":"Perform an applicative action when a condition is true.\n","title":"when","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[61,63]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","Functor"]},"declarations":[{"children":[{"comments":null,"title":"map","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[26,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"comments":null,"title":"functorFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[41,16]}},{"comments":null,"title":"functorArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[44,17]}},{"comments":null,"title":"functorProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[47,18]}}],"comments":"A `Functor` is a type constructor which supports a mapping operation\n`map`.\n\n`map` can be used to turn functions `a -> b` into functions\n`f a -> f b` whose argument and return types use the type constructor `f`\nto represent some computational context.\n\nInstances must satisfy the following laws:\n\n- Identity: `map identity = identity`\n- Composition: `map (f <<< g) = map f <<< map g`\n","title":"Functor","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"children":[],"comments":"The `void` function is used to ignore the type wrapped by a\n[`Functor`](#functor), replacing it with `Unit` and keeping only the type\ninformation provided by the type constructor itself.\n\n`void` is often useful when using `do` notation to change the return type\nof a monadic computation:\n\n```purescript\nmain = forE 1 10 \\n -> void do\n print n\n print (n * n)\n```\n","title":"void","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]},null]},null]}},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[63,47]}},{"children":[],"comments":null,"title":"(<$>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"map"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[28,20]}},{"children":[],"comments":null,"title":"(<$)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidRight"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[71,25]}},{"children":[],"comments":null,"title":"(<#>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"mapFlipped"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[38,27]}},{"children":[],"comments":null,"title":"($>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidLeft"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[77,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[77,24]}}]}],"name":"Control.Apply","comments":null,"declarations":[{"children":[{"comments":null,"title":"apply","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[46,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"comments":null,"title":"applyFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[51,26]}},{"comments":null,"title":"applyArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[54,21]}},{"comments":null,"title":"applyProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[59,20]}}],"comments":"The `Apply` class provides the `(<*>)` which is used to apply a function\nto an argument under a type constructor.\n\n`Apply` can be used to lift functions of two or more arguments to work on\nvalues wrapped with the type constructor `f`. It might also be understood\nin terms of the `lift2` function:\n\n```purescript\nlift2 :: forall f a b c. Apply f => (a -> b -> c) -> f a -> f b -> f c\nlift2 f a b = f <$> a <*> b\n```\n\n`(<*>)` is recovered from `lift2` as `lift2 ($)`. That is, `(<*>)` lifts\nthe function application operator `($)` to arguments wrapped with the\ntype constructor `f`.\n\nPut differently...\n```\nfoo =\n functionTakingNArguments <$> computationProducingArg1\n <*> computationProducingArg2\n <*> ...\n <*> computationProducingArgN\n```\n\nInstances must satisfy the following law in addition to the `Functor`\nlaws:\n\n- Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`\n\nFormally, `Apply` represents a strong lax semi-monoidal endofunctor.\n","title":"Apply","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"children":[],"comments":null,"title":"(<*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"apply"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[48,22]}},{"children":[],"comments":"Combine two effectful actions, keeping only the result of the first.\n","title":"applyFirst","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[62,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[62,57]}},{"children":[],"comments":null,"title":"(<*)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applyFirst"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[65,26]}},{"children":[],"comments":"Combine two effectful actions, keeping only the result of the second.\n","title":"applySecond","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[68,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[68,58]}},{"children":[],"comments":null,"title":"(*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applySecond"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[71,27]}},{"children":[],"comments":"Lift a function of two arguments to a function which accepts and returns\nvalues wrapped with the type constructor `f`.\n\n```purescript\nlift2 add (Just 1) (Just 2) == Just 3\nlift2 add Nothing (Just 2) == Nothing\n```\n\n","title":"lift2","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}]}]}]},null]},null]},null]},null]}},"sourceSpan":{"start":[81,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[81,71]}},{"children":[],"comments":"Lift a function of three arguments to a function which accepts and returns\nvalues wrapped with the type constructor `f`.\n","title":"lift3","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["d",{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]}]}]}]}]},null]},null]},null]},null]},null]}},"sourceSpan":{"start":[86,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[86,85]}},{"children":[],"comments":"Lift a function of four arguments to a function which accepts and returns\nvalues wrapped with the type constructor `f`.\n","title":"lift4","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["d",{"annotation":[],"tag":"ForAll","contents":["e",{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"d"}]},{"annotation":[],"tag":"TypeVar","contents":"e"}]}]}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"e"}]}]}]}]}]}]}]},null]},null]},null]},null]},null]},null]}},"sourceSpan":{"start":[91,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[91,99]}},{"children":[],"comments":"Lift a function of five arguments to a function which accepts and returns\nvalues wrapped with the type constructor `f`.\n","title":"lift5","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["d",{"annotation":[],"tag":"ForAll","contents":["e",{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["g",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"d"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"e"}]},{"annotation":[],"tag":"TypeVar","contents":"g"}]}]}]}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"e"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"g"}]}]}]}]}]}]}]}]},null]},null]},null]},null]},null]},null]},null]}},"sourceSpan":{"start":[96,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[96,113]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Control","Applicative"]},"declarations":[{"children":[{"comments":null,"title":"pure","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]}},"sourceSpan":{"start":[34,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[34,29]}},{"comments":null,"title":"applicativeFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[37,15]}},{"comments":null,"title":"applicativeArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[40,15]}},{"comments":null,"title":"applicativeProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[43,17]}}],"comments":"The `Applicative` type class extends the [`Apply`](#apply) type class\nwith a `pure` function, which can be used to create values of type `f a`\nfrom values of type `a`.\n\nWhere [`Apply`](#apply) provides the ability to lift functions of two or\nmore arguments to functions whose arguments are wrapped using `f`, and\n[`Functor`](#functor) provides the ability to lift functions of one\nargument, `pure` can be seen as the function which lifts functions of\n_zero_ arguments. That is, `Applicative` functors support a lifting\noperation for any number of function arguments.\n\nInstances must satisfy the following laws in addition to the `Apply`\nlaws:\n\n- Identity: `(pure identity) <*> v = v`\n- Composition: `pure (<<<) <*> f <*> g <*> h = f <*> (g <*> h)`\n- Homomorphism: `(pure f) <*> (pure x) = pure (f x)`\n- Interchange: `u <*> (pure y) = (pure (_ $ y)) <*> u`\n","title":"Applicative","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[34,29]}},{"children":[],"comments":"Perform an applicative action when a condition is true.\n","title":"when","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[61,63]}},{"children":[],"comments":"Perform an applicative action unless a condition is true.\n","title":"unless","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[66,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[66,65]}},{"children":[],"comments":"`liftA1` provides a default implementation of `(<$>)` for any\n[`Applicative`](#applicative) functor, without using `(<$>)` as provided\nby the [`Functor`](#functor)-[`Applicative`](#applicative) superclass\nrelationship.\n\n`liftA1` can therefore be used to write [`Functor`](#functor) instances\nas follows:\n\n```purescript\ninstance functorF :: Functor F where\n map = liftA1\n```\n","title":"liftA1","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[57,64]}}]},{"moduleName":{"package":null,"item":["Control","Apply"]},"declarations":[{"children":[{"comments":null,"title":"apply","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[46,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"comments":null,"title":"applyFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[51,26]}},{"comments":null,"title":"applyArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[54,21]}},{"comments":null,"title":"applyProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[59,20]}}],"comments":"The `Apply` class provides the `(<*>)` which is used to apply a function\nto an argument under a type constructor.\n\n`Apply` can be used to lift functions of two or more arguments to work on\nvalues wrapped with the type constructor `f`. It might also be understood\nin terms of the `lift2` function:\n\n```purescript\nlift2 :: forall f a b c. Apply f => (a -> b -> c) -> f a -> f b -> f c\nlift2 f a b = f <$> a <*> b\n```\n\n`(<*>)` is recovered from `lift2` as `lift2 ($)`. That is, `(<*>)` lifts\nthe function application operator `($)` to arguments wrapped with the\ntype constructor `f`.\n\nPut differently...\n```\nfoo =\n functionTakingNArguments <$> computationProducingArg1\n <*> computationProducingArg2\n <*> ...\n <*> computationProducingArgN\n```\n\nInstances must satisfy the following law in addition to the `Functor`\nlaws:\n\n- Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`\n\nFormally, `Apply` represents a strong lax semi-monoidal endofunctor.\n","title":"Apply","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"children":[],"comments":null,"title":"(<*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"apply"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[48,22]}},{"children":[],"comments":null,"title":"(<*)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applyFirst"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[65,26]}},{"children":[],"comments":null,"title":"(*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applySecond"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[71,27]}}]},{"moduleName":{"package":null,"item":["Data","Functor"]},"declarations":[{"children":[{"comments":null,"title":"map","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[26,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"comments":null,"title":"functorFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[41,16]}},{"comments":null,"title":"functorArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[44,17]}},{"comments":null,"title":"functorProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[47,18]}}],"comments":"A `Functor` is a type constructor which supports a mapping operation\n`map`.\n\n`map` can be used to turn functions `a -> b` into functions\n`f a -> f b` whose argument and return types use the type constructor `f`\nto represent some computational context.\n\nInstances must satisfy the following laws:\n\n- Identity: `map identity = identity`\n- Composition: `map (f <<< g) = map f <<< map g`\n","title":"Functor","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"children":[],"comments":"The `void` function is used to ignore the type wrapped by a\n[`Functor`](#functor), replacing it with `Unit` and keeping only the type\ninformation provided by the type constructor itself.\n\n`void` is often useful when using `do` notation to change the return type\nof a monadic computation:\n\n```purescript\nmain = forE 1 10 \\n -> void do\n print n\n print (n * n)\n```\n","title":"void","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]},null]},null]}},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[63,47]}},{"children":[],"comments":null,"title":"(<$>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"map"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[28,20]}},{"children":[],"comments":null,"title":"(<$)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidRight"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[71,25]}},{"children":[],"comments":null,"title":"(<#>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"mapFlipped"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[38,27]}},{"children":[],"comments":null,"title":"($>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidLeft"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[77,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[77,24]}}]}],"name":"Control.Bind","comments":null,"declarations":[{"children":[{"comments":null,"title":"bind","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[51,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[51,47]}},{"comments":null,"title":"bindFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[66,25]}},{"comments":"The `bind`/`>>=` function for `Array` works by applying a function to\neach element in the array, and flattening the results into a single,\nnew array.\n\nArray's `bind`/`>>=` works like a nested for loop. Each `bind` adds\nanother level of nesting in the loop. For example:\n```\nfoo :: Array String\nfoo =\n [\"a\", \"b\"] >>= \\eachElementInArray1 ->\n [\"c\", \"d\"] >>= \\eachElementInArray2\n pure (eachElementInArray1 <> eachElementInArray2)\n\n-- In other words...\nfoo\n-- ... is the same as...\n[ (\"a\" <> \"c\"), (\"a\" <> \"d\"), (\"b\" <> \"c\"), (\"b\" <> \"d\") ]\n-- which simplifies to...\n[ \"ac\", \"ad\", \"bc\", \"bd\" ]\n```\n","title":"bindArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[88,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[89,19]}},{"comments":null,"title":"bindProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[93,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[94,19]}}],"comments":"The `Bind` type class extends the [`Apply`](#apply) type class with a\n\"bind\" operation `(>>=)` which composes computations in sequence, using\nthe return value of one computation to determine the next computation.\n\nThe `>>=` operator can also be expressed using `do` notation, as follows:\n\n```purescript\nx >>= f = do y <- x\n f y\n```\n\nwhere the function argument of `f` is given the name `y`.\n\nInstances must satisfy the following laws in addition to the `Apply`\nlaws:\n\n- Associativity: `(x >>= f) >>= g = x >>= (\\k -> f k >>= g)`\n- Apply Superclass: `apply f x = f >>= \\f’ -> map f’ x`\n\nAssociativity tells us that we can regroup operations which use `do`\nnotation so that we can unambiguously write, for example:\n\n```purescript\ndo x <- m1\n y <- m2 x\n m3 x y\n```\n","title":"Bind","info":{"fundeps":[],"arguments":[["m",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[51,47]}},{"children":[],"comments":null,"title":"(>>=)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"bind"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[53,21]}},{"children":[],"comments":"`bindFlipped` is `bind` with its arguments reversed. For example:\n\n```purescript\nprint =<< random\n```\n","title":"bindFlipped","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[60,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[60,64]}},{"children":[],"comments":null,"title":"(=<<)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"bindFlipped"}}}],"fixity":{"associativity":"infixr","precedence":1}},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[63,28]}},{"children":[{"comments":null,"title":"discard","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]}},"sourceSpan":{"start":[102,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[102,60]}},{"comments":null,"title":"discardUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Discard"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[104,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[105,17]}},{"comments":null,"title":"discardProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Discard"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[107,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[108,17]}},{"comments":null,"title":"discardProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Discard"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[110,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[111,17]}},{"comments":null,"title":"discardProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Discard"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[113,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[114,17]}}],"comments":"A class for types whose values can safely be discarded\nin a `do` notation block.\n\nAn example is the `Unit` type, since there is only one\npossible value which can be returned.\n","title":"Discard","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[101,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[102,60]}},{"children":[],"comments":"Collapse two applications of a monadic type constructor into one.\n","title":"join","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]},null]}},"sourceSpan":{"start":[117,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[117,45]}},{"children":[],"comments":"Forwards Kleisli composition.\n\nFor example:\n\n```purescript\nimport Data.Array (head, tail)\n\nthird = tail >=> tail >=> head\n```\n","title":"composeKleisli","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}]}]}]},null]},null]},null]},null]}},"sourceSpan":{"start":[129,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[129,81]}},{"children":[],"comments":null,"title":"(>=>)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"composeKleisli"}}}],"fixity":{"associativity":"infixr","precedence":1}},"sourceSpan":{"start":[132,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[132,31]}},{"children":[],"comments":"Backwards Kleisli composition.\n","title":"composeKleisliFlipped","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}]}]}]},null]},null]},null]},null]}},"sourceSpan":{"start":[135,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[135,88]}},{"children":[],"comments":null,"title":"(<=<)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"composeKleisliFlipped"}}}],"fixity":{"associativity":"infixr","precedence":1}},"sourceSpan":{"start":[138,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[138,38]}},{"children":[],"comments":"Execute a monadic action if a condition holds.\n\nFor example:\n\n```purescript\nmain = ifM ((< 0.5) <$> random)\n (trace \"Heads\")\n (trace \"Tails\")\n```\n","title":"ifM","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]}]},null]},null]}},"sourceSpan":{"start":[149,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[149,60]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Control","Semigroupoid"]},"declarations":[{"children":[{"comments":null,"title":"compose","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["d",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[14,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[14,51]}},{"comments":null,"title":"semigroupoidFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Semigroupoid"],"Semigroupoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[17,26]}}],"comments":null,"title":"Semigroupoid","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[14,51]}},{"children":[],"comments":null,"title":"(>>>)","info":{"declType":"alias","alias":[["Control","Semigroupoid"],{"Right":{"Left":{"Ident":"composeFlipped"}}}],"fixity":{"associativity":"infixr","precedence":9}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[25,31]}},{"children":[],"comments":null,"title":"(<<<)","info":{"declType":"alias","alias":[["Control","Semigroupoid"],{"Right":{"Left":{"Ident":"compose"}}}],"fixity":{"associativity":"infixr","precedence":9}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[19,24]}}]}],"name":"Control.Category","comments":null,"declarations":[{"children":[{"comments":null,"title":"identity","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["t",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"t"}]},{"annotation":[],"tag":"TypeVar","contents":"t"}]},null]}},"sourceSpan":{"start":[18,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Category.purs","end":[18,30]}},{"comments":null,"title":"categoryFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Category"],"Category"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Category.purs","end":[21,17]}}],"comments":null,"title":"Category","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Semigroupoid"],"Semigroupoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Category.purs","end":[18,30]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Control","Applicative"]},"declarations":[{"children":[{"comments":null,"title":"pure","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]}},"sourceSpan":{"start":[34,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[34,29]}},{"comments":null,"title":"applicativeFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[37,15]}},{"comments":null,"title":"applicativeArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[40,15]}},{"comments":null,"title":"applicativeProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[43,17]}}],"comments":"The `Applicative` type class extends the [`Apply`](#apply) type class\nwith a `pure` function, which can be used to create values of type `f a`\nfrom values of type `a`.\n\nWhere [`Apply`](#apply) provides the ability to lift functions of two or\nmore arguments to functions whose arguments are wrapped using `f`, and\n[`Functor`](#functor) provides the ability to lift functions of one\nargument, `pure` can be seen as the function which lifts functions of\n_zero_ arguments. That is, `Applicative` functors support a lifting\noperation for any number of function arguments.\n\nInstances must satisfy the following laws in addition to the `Apply`\nlaws:\n\n- Identity: `(pure identity) <*> v = v`\n- Composition: `pure (<<<) <*> f <*> g <*> h = f <*> (g <*> h)`\n- Homomorphism: `(pure f) <*> (pure x) = pure (f x)`\n- Interchange: `u <*> (pure y) = (pure (_ $ y)) <*> u`\n","title":"Applicative","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[34,29]}},{"children":[],"comments":"Perform an applicative action when a condition is true.\n","title":"when","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[61,63]}},{"children":[],"comments":"Perform an applicative action unless a condition is true.\n","title":"unless","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[66,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[66,65]}},{"children":[],"comments":"`liftA1` provides a default implementation of `(<$>)` for any\n[`Applicative`](#applicative) functor, without using `(<$>)` as provided\nby the [`Functor`](#functor)-[`Applicative`](#applicative) superclass\nrelationship.\n\n`liftA1` can therefore be used to write [`Functor`](#functor) instances\nas follows:\n\n```purescript\ninstance functorF :: Functor F where\n map = liftA1\n```\n","title":"liftA1","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[57,64]}}]},{"moduleName":{"package":null,"item":["Control","Apply"]},"declarations":[{"children":[{"comments":null,"title":"apply","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[46,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"comments":null,"title":"applyFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[51,26]}},{"comments":null,"title":"applyArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[54,21]}},{"comments":null,"title":"applyProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[59,20]}}],"comments":"The `Apply` class provides the `(<*>)` which is used to apply a function\nto an argument under a type constructor.\n\n`Apply` can be used to lift functions of two or more arguments to work on\nvalues wrapped with the type constructor `f`. It might also be understood\nin terms of the `lift2` function:\n\n```purescript\nlift2 :: forall f a b c. Apply f => (a -> b -> c) -> f a -> f b -> f c\nlift2 f a b = f <$> a <*> b\n```\n\n`(<*>)` is recovered from `lift2` as `lift2 ($)`. That is, `(<*>)` lifts\nthe function application operator `($)` to arguments wrapped with the\ntype constructor `f`.\n\nPut differently...\n```\nfoo =\n functionTakingNArguments <$> computationProducingArg1\n <*> computationProducingArg2\n <*> ...\n <*> computationProducingArgN\n```\n\nInstances must satisfy the following law in addition to the `Functor`\nlaws:\n\n- Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`\n\nFormally, `Apply` represents a strong lax semi-monoidal endofunctor.\n","title":"Apply","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"children":[],"comments":null,"title":"(<*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"apply"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[48,22]}},{"children":[],"comments":null,"title":"(<*)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applyFirst"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[65,26]}},{"children":[],"comments":null,"title":"(*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applySecond"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[71,27]}}]},{"moduleName":{"package":null,"item":["Control","Bind"]},"declarations":[{"children":[{"comments":null,"title":"bind","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[51,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[51,47]}},{"comments":null,"title":"bindFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[66,25]}},{"comments":"The `bind`/`>>=` function for `Array` works by applying a function to\neach element in the array, and flattening the results into a single,\nnew array.\n\nArray's `bind`/`>>=` works like a nested for loop. Each `bind` adds\nanother level of nesting in the loop. For example:\n```\nfoo :: Array String\nfoo =\n [\"a\", \"b\"] >>= \\eachElementInArray1 ->\n [\"c\", \"d\"] >>= \\eachElementInArray2\n pure (eachElementInArray1 <> eachElementInArray2)\n\n-- In other words...\nfoo\n-- ... is the same as...\n[ (\"a\" <> \"c\"), (\"a\" <> \"d\"), (\"b\" <> \"c\"), (\"b\" <> \"d\") ]\n-- which simplifies to...\n[ \"ac\", \"ad\", \"bc\", \"bd\" ]\n```\n","title":"bindArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[88,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[89,19]}},{"comments":null,"title":"bindProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[93,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[94,19]}}],"comments":"The `Bind` type class extends the [`Apply`](#apply) type class with a\n\"bind\" operation `(>>=)` which composes computations in sequence, using\nthe return value of one computation to determine the next computation.\n\nThe `>>=` operator can also be expressed using `do` notation, as follows:\n\n```purescript\nx >>= f = do y <- x\n f y\n```\n\nwhere the function argument of `f` is given the name `y`.\n\nInstances must satisfy the following laws in addition to the `Apply`\nlaws:\n\n- Associativity: `(x >>= f) >>= g = x >>= (\\k -> f k >>= g)`\n- Apply Superclass: `apply f x = f >>= \\f’ -> map f’ x`\n\nAssociativity tells us that we can regroup operations which use `do`\nnotation so that we can unambiguously write, for example:\n\n```purescript\ndo x <- m1\n y <- m2 x\n m3 x y\n```\n","title":"Bind","info":{"fundeps":[],"arguments":[["m",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[51,47]}},{"children":[],"comments":"Collapse two applications of a monadic type constructor into one.\n","title":"join","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]},null]}},"sourceSpan":{"start":[117,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[117,45]}},{"children":[],"comments":"Execute a monadic action if a condition holds.\n\nFor example:\n\n```purescript\nmain = ifM ((< 0.5) <$> random)\n (trace \"Heads\")\n (trace \"Tails\")\n```\n","title":"ifM","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]}]},null]},null]}},"sourceSpan":{"start":[149,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[149,60]}},{"children":[],"comments":null,"title":"(>>=)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"bind"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[53,21]}},{"children":[],"comments":null,"title":"(>=>)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"composeKleisli"}}}],"fixity":{"associativity":"infixr","precedence":1}},"sourceSpan":{"start":[132,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[132,31]}},{"children":[],"comments":null,"title":"(=<<)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"bindFlipped"}}}],"fixity":{"associativity":"infixr","precedence":1}},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[63,28]}},{"children":[],"comments":null,"title":"(<=<)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"composeKleisliFlipped"}}}],"fixity":{"associativity":"infixr","precedence":1}},"sourceSpan":{"start":[138,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[138,38]}}]},{"moduleName":{"package":null,"item":["Data","Functor"]},"declarations":[{"children":[{"comments":null,"title":"map","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[26,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"comments":null,"title":"functorFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[41,16]}},{"comments":null,"title":"functorArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[44,17]}},{"comments":null,"title":"functorProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[47,18]}}],"comments":"A `Functor` is a type constructor which supports a mapping operation\n`map`.\n\n`map` can be used to turn functions `a -> b` into functions\n`f a -> f b` whose argument and return types use the type constructor `f`\nto represent some computational context.\n\nInstances must satisfy the following laws:\n\n- Identity: `map identity = identity`\n- Composition: `map (f <<< g) = map f <<< map g`\n","title":"Functor","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"children":[],"comments":"The `void` function is used to ignore the type wrapped by a\n[`Functor`](#functor), replacing it with `Unit` and keeping only the type\ninformation provided by the type constructor itself.\n\n`void` is often useful when using `do` notation to change the return type\nof a monadic computation:\n\n```purescript\nmain = forE 1 10 \\n -> void do\n print n\n print (n * n)\n```\n","title":"void","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]},null]},null]}},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[63,47]}},{"children":[],"comments":null,"title":"(<$>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"map"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[28,20]}},{"children":[],"comments":null,"title":"(<$)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidRight"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[71,25]}},{"children":[],"comments":null,"title":"(<#>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"mapFlipped"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[38,27]}},{"children":[],"comments":null,"title":"($>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidLeft"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[77,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[77,24]}}]}],"name":"Control.Monad","comments":null,"declarations":[{"children":[{"comments":null,"title":"monadFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[33,35]}},{"comments":null,"title":"monadArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[35,35]}},{"comments":null,"title":"monadProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[37,35]}}],"comments":"The `Monad` type class combines the operations of the `Bind` and\n`Applicative` type classes. Therefore, `Monad` instances represent type\nconstructors which support sequential composition, and also lifting of\nfunctions of arbitrary arity.\n\nInstances must satisfy the following laws in addition to the\n`Applicative` and `Bind` laws:\n\n- Left Identity: `pure x >>= f = f x`\n- Right Identity: `x >>= pure = x`\n","title":"Monad","info":{"fundeps":[],"arguments":[["m",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[31,41]}},{"children":[],"comments":"`liftM1` provides a default implementation of `(<$>)` for any\n[`Monad`](#monad), without using `(<$>)` as provided by the\n[`Functor`](#functor)-[`Monad`](#monad) superclass relationship.\n\n`liftM1` can therefore be used to write [`Functor`](#functor) instances\nas follows:\n\n```purescript\ninstance functorF :: Functor F where\n map = liftM1\n```\n","title":"liftM1","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Monad"],"Monad"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[50,58]}},{"children":[],"comments":"Perform a monadic action when a condition is true, where the conditional\nvalue is also in a monadic context.\n","title":"whenM","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Monad"],"Monad"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[57,60]}},{"children":[],"comments":"Perform a monadic action unless a condition is true, where the conditional\nvalue is also in a monadic context.\n","title":"unlessM","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Monad"],"Monad"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[64,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[64,62]}},{"children":[],"comments":"`ap` provides a default implementation of `(<*>)` for any `Monad`, without\nusing `(<*>)` as provided by the `Apply`-`Monad` superclass relationship.\n\n`ap` can therefore be used to write `Apply` instances as follows:\n\n```purescript\ninstance applyF :: Apply F where\n apply = ap\n```\n","title":"ap","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Monad"],"Monad"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[82,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[82,56]}}]},{"reExports":[],"name":"Control.Semigroupoid","comments":null,"declarations":[{"children":[{"comments":null,"title":"compose","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["d",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[14,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[14,51]}},{"comments":null,"title":"semigroupoidFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Semigroupoid"],"Semigroupoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[17,26]}}],"comments":null,"title":"Semigroupoid","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[14,51]}},{"children":[],"comments":null,"title":"(<<<)","info":{"declType":"alias","alias":[["Control","Semigroupoid"],{"Right":{"Left":{"Ident":"compose"}}}],"fixity":{"associativity":"infixr","precedence":9}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[19,24]}},{"children":[],"comments":"Forwards composition, or `compose` with its arguments reversed.\n","title":"composeFlipped","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["d",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Semigroupoid"],"Semigroupoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]}]}]},null]},null]},null]},null]}},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[22,76]}},{"children":[],"comments":null,"title":"(>>>)","info":{"declType":"alias","alias":[["Control","Semigroupoid"],{"Right":{"Left":{"Ident":"composeFlipped"}}}],"fixity":{"associativity":"infixr","precedence":9}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[25,31]}}]},{"reExports":[],"name":"Data.Boolean","comments":null,"declarations":[{"children":[],"comments":"An alias for `true`, which can be useful in guard clauses:\n\n```purescript\nmax x y | x >= y = x\n | otherwise = y\n```\n","title":"otherwise","info":{"declType":"value","type":{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}},"sourceSpan":{"start":[9,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Boolean.purs","end":[9,21]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","HeytingAlgebra"]},"declarations":[{"children":[{"comments":null,"title":"ff","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[39,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[39,10]}},{"comments":null,"title":"tt","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[40,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[40,10]}},{"comments":null,"title":"implies","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[41,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[41,25]}},{"comments":null,"title":"conj","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[42,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[42,22]}},{"comments":null,"title":"disj","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[43,22]}},{"comments":null,"title":"not","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[44,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[44,16]}},{"comments":null,"title":"heytingAlgebraBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[55,16]}},{"comments":null,"title":"heytingAlgebraUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[63,15]}},{"comments":null,"title":"heytingAlgebraFunction","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[71,22]}},{"comments":null,"title":"heytingAlgebraProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[79,13]}},{"comments":null,"title":"heytingAlgebraProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[81,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[87,14]}},{"comments":null,"title":"heytingAlgebraProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[89,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[95,14]}},{"comments":null,"title":"heytingAlgebraRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[97,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[103,41]}}],"comments":"The `HeytingAlgebra` type class represents types that are bounded lattices with\nan implication operator such that the following laws hold:\n\n- Associativity:\n - `a || (b || c) = (a || b) || c`\n - `a && (b && c) = (a && b) && c`\n- Commutativity:\n - `a || b = b || a`\n - `a && b = b && a`\n- Absorption:\n - `a || (a && b) = a`\n - `a && (a || b) = a`\n- Idempotent:\n - `a || a = a`\n - `a && a = a`\n- Identity:\n - `a || ff = a`\n - `a && tt = a`\n- Implication:\n - ``a `implies` a = tt``\n - ``a && (a `implies` b) = a && b``\n - ``b && (a `implies` b) = b``\n - ``a `implies` (b && c) = (a `implies` b) && (a `implies` c)``\n- Complemented:\n - ``not a = a `implies` ff``\n","title":"HeytingAlgebra","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[44,16]}},{"children":[{"comments":null,"title":"heytingAlgebraRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[120,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[126,20]}},{"comments":null,"title":"heytingAlgebraRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[128,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[174,55]}}],"comments":null,"title":"HeytingAlgebraRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[112,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[118,78]}},{"children":[],"comments":null,"title":"(||)","info":{"declType":"alias","alias":[["Data","HeytingAlgebra"],{"Right":{"Left":{"Ident":"disj"}}}],"fixity":{"associativity":"infixr","precedence":2}},"sourceSpan":{"start":[47,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[47,20]}},{"children":[],"comments":null,"title":"(&&)","info":{"declType":"alias","alias":[["Data","HeytingAlgebra"],{"Right":{"Left":{"Ident":"conj"}}}],"fixity":{"associativity":"infixr","precedence":3}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[46,20]}}]}],"name":"Data.BooleanAlgebra","comments":null,"declarations":[{"children":[{"comments":null,"title":"booleanAlgebraBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[24,57]}},{"comments":null,"title":"booleanAlgebraUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[25,51]}},{"comments":null,"title":"booleanAlgebraFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","BooleanAlgebra"],"BooleanAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[26,73]}},{"comments":null,"title":"booleanAlgebraRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","BooleanAlgebra"],"BooleanAlgebraRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[27,123]}},{"comments":null,"title":"booleanAlgebraProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[28,57]}},{"comments":null,"title":"booleanAlgebraProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[29,59]}},{"comments":null,"title":"booleanAlgebraProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[30,59]}}],"comments":"The `BooleanAlgebra` type class represents types that behave like boolean\nvalues.\n\nInstances should satisfy the following laws in addition to the\n`HeytingAlgebra` law:\n\n- Excluded middle:\n - `a || not a = tt`\n","title":"BooleanAlgebra","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[22,43]}},{"children":[{"comments":null,"title":"booleanAlgebraRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebraRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[37,71]}},{"comments":null,"title":"booleanAlgebraRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","BooleanAlgebra"],"BooleanAlgebraRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","BooleanAlgebra"],"BooleanAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebraRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[45,71]}}],"comments":null,"title":"BooleanAlgebraRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlist"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[35,109]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","Ord"]},"declarations":[{"children":[{"comments":null,"title":"LT","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"GT","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"EQ","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[19,19]}},{"comments":null,"title":"semigroupOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[24,18]}},{"comments":null,"title":"showOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[29,17]}}],"comments":"The `Ordering` data type represents the three possible outcomes of\ncomparing two values:\n\n`LT` - The first value is _less than_ the second.\n`GT` - The first value is _greater than_ the second.\n`EQ` - The first value is _equal to_ the second.\n","title":"Ordering","info":{"declType":"data","dataDeclType":"data","typeArguments":[]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[13,29]}},{"children":[{"comments":null,"title":"compare","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}]}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[38,32]}},{"comments":null,"title":"ordBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[41,36]}},{"comments":null,"title":"ordInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[44,32]}},{"comments":null,"title":"ordNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[47,35]}},{"comments":null,"title":"ordString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[50,35]}},{"comments":null,"title":"ordChar","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Char"]}]}},"sourceSpan":{"start":[52,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[53,33]}},{"comments":null,"title":"ordUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[56,19]}},{"comments":null,"title":"ordVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[59,19]}},{"comments":null,"title":"ordProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[62,19]}},{"comments":null,"title":"ordProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[64,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[65,19]}},{"comments":null,"title":"ordProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[68,19]}},{"comments":null,"title":"ordArray","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[70,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[77,17]}},{"comments":null,"title":"ordOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[121,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[128,21]}},{"comments":null,"title":"ordRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ord"],"OrdRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[249,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[254,48]}}],"comments":"The `Ord` type class represents types which support comparisons with a\n_total order_.\n\n`Ord` instances should satisfy the laws of total orderings:\n\n- Reflexivity: `a <= a`\n- Antisymmetry: if `a <= b` and `b <= a` then `a = b`\n- Transitivity: if `a <= b` and `b <= c` then `a <= c`\n","title":"Ord","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[38,32]}},{"children":[{"comments":null,"title":"ordRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"OrdRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}},"sourceSpan":{"start":[230,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[231,27]}},{"comments":null,"title":"ordRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"OrdRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"rowTail"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"OrdRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}},"sourceSpan":{"start":[233,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[247,59]}}],"comments":null,"title":"OrdRecord","info":{"fundeps":[],"arguments":[["rowlist",null],["row",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"EqRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlist"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[227,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[228,91]}},{"children":[],"comments":null,"title":"(>=)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"greaterThanOrEq"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[157,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[157,31]}},{"children":[],"comments":null,"title":"(>)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"greaterThan"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[156,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[156,26]}},{"children":[],"comments":null,"title":"(<=)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"lessThanOrEq"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[155,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[155,28]}},{"children":[],"comments":null,"title":"(<)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"lessThan"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[154,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[154,23]}}]}],"name":"Data.Bounded","comments":null,"declarations":[{"children":[{"comments":null,"title":"top","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[24,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[24,11]}},{"comments":null,"title":"bottom","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[25,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[25,14]}},{"comments":null,"title":"boundedBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[29,17]}},{"comments":"The `Bounded` `Int` instance has `top :: Int` equal to 2^31 - 1,\nand `bottom :: Int` equal to -2^31, since these are the largest and smallest\nintegers representable by twos-complement 32-bit integers, respectively.\n","title":"boundedInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[36,21]}},{"comments":"Characters fall within the Unicode range.\n","title":"boundedChar","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Char"]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[44,22]}},{"comments":null,"title":"boundedOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[51,14]}},{"comments":null,"title":"boundedUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[55,16]}},{"comments":null,"title":"boundedNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[60,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[62,24]}},{"comments":null,"title":"boundedProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[64,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[66,14]}},{"comments":null,"title":"boundedProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[68,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[70,15]}},{"comments":null,"title":"boundedProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[72,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[74,15]}},{"comments":null,"title":"boundedRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"BoundedRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[107,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[113,67]}}],"comments":"The `Bounded` type class represents totally ordered types that have an\nupper and lower boundary.\n\nInstances should satisfy the following law in addition to the `Ord` laws:\n\n- Bounded: `bottom <= a <= top`\n","title":"Bounded","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[25,14]}},{"children":[{"comments":null,"title":"topRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"ForAll","contents":["rproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rproxy"},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]},null]},null]}},"sourceSpan":{"start":[78,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[78,85]}},{"comments":null,"title":"bottomRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"ForAll","contents":["rproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rproxy"},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]},null]},null]}},"sourceSpan":{"start":[79,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[79,88]}},{"comments":null,"title":"boundedRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"BoundedRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[81,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[83,24]}},{"comments":null,"title":"boundedRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"rowTail"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"BoundedRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"BoundedRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[85,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[105,64]}}],"comments":null,"title":"BoundedRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"OrdRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlist"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[77,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[79,88]}}]},{"reExports":[],"name":"Data.Bounded.Generic","comments":null,"declarations":[{"children":[{"comments":null,"title":"genericBottom'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[15,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[15,22]}},{"comments":null,"title":"genericBottomNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericBottom"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[18,31]}},{"comments":null,"title":"genericBottomArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericBottom"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[21,35]}},{"comments":null,"title":"genericBottomSum","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericBottom"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericBottom"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Sum"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[24,38]}},{"comments":null,"title":"genericBottomProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericBottom"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericBottom"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericBottom"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[27,57]}},{"comments":null,"title":"genericBottomConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericBottom"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericBottom"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[30,46]}}],"comments":null,"title":"GenericBottom","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[14,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[15,22]}},{"children":[],"comments":"A `Generic` implementation of the `bottom` member from the `Bounded` type class.\n","title":"genericBottom","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericBottom"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[51,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[51,71]}},{"children":[{"comments":null,"title":"genericTop'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[33,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[33,19]}},{"comments":null,"title":"genericTopNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericTop"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[36,28]}},{"comments":null,"title":"genericTopArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericTop"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[39,29]}},{"comments":null,"title":"genericTopSum","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericTop"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericTop"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Sum"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[42,32]}},{"comments":null,"title":"genericTopProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericTop"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericTop"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericTop"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[44,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[45,48]}},{"comments":null,"title":"genericTopConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericTop"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded","Generic"],"GenericTop"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[47,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[48,40]}}],"comments":null,"title":"GenericTop","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[32,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[33,19]}},{"children":[],"comments":"A `Generic` implementation of the `top` member from the `Bounded` type class.\n","title":"genericTop","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Bounded","Generic"],"GenericTop"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded/Generic.purs","end":[55,65]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","Ring"]},"declarations":[{"children":[{"comments":null,"title":"ringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[29,15]}},{"comments":null,"title":"ringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[32,15]}},{"comments":null,"title":"ringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[35,17]}},{"comments":null,"title":"ringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[38,24]}},{"comments":null,"title":"ringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[41,18]}},{"comments":null,"title":"ringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[44,19]}},{"comments":null,"title":"ringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[47,19]}},{"comments":null,"title":"ringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"RingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[50,40]}}],"comments":"The `Ring` class is for types that support addition, multiplication,\nand subtraction operations.\n\nInstances must satisfy the following laws in addition to the `Semiring`\nlaws:\n\n- Additive inverse: `a - a = zero`\n- Compatibility of `sub` and `negate`: `a - b = a + (zero - b)`\n","title":"Ring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"children":[{"comments":null,"title":"ringRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"RingRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[66,23]}},{"comments":null,"title":"ringRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"RingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"RingRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[68,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[80,58]}}],"comments":null,"title":"RingRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlist"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[62,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[63,92]}}]},{"moduleName":{"package":null,"item":["Data","Semiring"]},"declarations":[{"children":[{"comments":null,"title":"add","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[35,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[35,22]}},{"comments":null,"title":"zero","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[36,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[36,12]}},{"comments":null,"title":"mul","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[37,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[37,22]}},{"comments":null,"title":"one","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"comments":null,"title":"semiringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[47,10]}},{"comments":null,"title":"semiringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[53,12]}},{"comments":null,"title":"semiringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[59,18]}},{"comments":null,"title":"semiringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[65,13]}},{"comments":null,"title":"semiringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[71,15]}},{"comments":null,"title":"semiringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[77,16]}},{"comments":null,"title":"semiringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[79,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[83,16]}},{"comments":null,"title":"semiringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[85,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[89,63]}}],"comments":"The `Semiring` class is for types that support an addition and\nmultiplication operation.\n\nInstances must satisfy the following laws:\n\n- Commutative monoid under addition:\n - Associativity: `(a + b) + c = a + (b + c)`\n - Identity: `zero + a = a + zero = a`\n - Commutative: `a + b = b + a`\n- Monoid under multiplication:\n - Associativity: `(a * b) * c = a * (b * c)`\n - Identity: `one * a = a * one = a`\n- Multiplication distributes over addition:\n - Left distributivity: `a * (b + c) = (a * b) + (a * c)`\n - Right distributivity: `(a + b) * c = (a * c) + (b * c)`\n- Annihilation: `zero * a = a * zero = zero`\n\n**Note:** The `Number` and `Int` types are not fully law abiding\nmembers of this class hierarchy due to the potential for arithmetic\noverflows, and in the case of `Number`, the presence of `NaN` and\n`Infinity` values. The behaviour is unspecified in these cases.\n","title":"Semiring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"children":[],"comments":null,"title":"(+)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"add"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[40,18]}},{"children":[],"comments":null,"title":"(*)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"mul"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[41,18]}}]}],"name":"Data.CommutativeRing","comments":null,"declarations":[{"children":[{"comments":null,"title":"commutativeRingInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[25,51]}},{"comments":null,"title":"commutativeRingNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[26,57]}},{"comments":null,"title":"commutativeRingUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[27,53]}},{"comments":null,"title":"commutativeRingFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[28,76]}},{"comments":null,"title":"commutativeRingRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[29,126]}},{"comments":null,"title":"commutativeRingProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[30,59]}},{"comments":null,"title":"commutativeRingProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[31,61]}},{"comments":null,"title":"commutativeRingProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[32,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[32,61]}}],"comments":"The `CommutativeRing` class is for rings where multiplication is\ncommutative.\n\nInstances must satisfy the following law in addition to the `Ring`\nlaws:\n\n- Commutative multiplication: `a * b = b * a`\n","title":"CommutativeRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[23,34]}},{"children":[{"comments":null,"title":"commutativeRingRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRingRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[38,73]}},{"comments":null,"title":"commutativeRingRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRingRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[46,72]}}],"comments":"A class for records where all fields have `CommutativeRing` instances, used\nto implement the `CommutativeRing` instance for records.\n","title":"CommutativeRingRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"RingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlist"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[36,100]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","Ring"]},"declarations":[{"children":[{"comments":null,"title":"sub","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[24,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"comments":null,"title":"ringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[29,15]}},{"comments":null,"title":"ringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[32,15]}},{"comments":null,"title":"ringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[35,17]}},{"comments":null,"title":"ringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[38,24]}},{"comments":null,"title":"ringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[41,18]}},{"comments":null,"title":"ringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[44,19]}},{"comments":null,"title":"ringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[47,19]}},{"comments":null,"title":"ringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"RingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[50,40]}}],"comments":"The `Ring` class is for types that support addition, multiplication,\nand subtraction operations.\n\nInstances must satisfy the following laws in addition to the `Semiring`\nlaws:\n\n- Additive inverse: `a - a = zero`\n- Compatibility of `sub` and `negate`: `a - b = a + (zero - b)`\n","title":"Ring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"children":[],"comments":"`negate x` can be used as a shorthand for `zero - x`.\n","title":"negate","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[53,37]}}]},{"moduleName":{"package":null,"item":["Data","Semiring"]},"declarations":[{"children":[{"comments":null,"title":"add","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[35,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[35,22]}},{"comments":null,"title":"zero","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[36,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[36,12]}},{"comments":null,"title":"mul","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[37,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[37,22]}},{"comments":null,"title":"one","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"comments":null,"title":"semiringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[47,10]}},{"comments":null,"title":"semiringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[53,12]}},{"comments":null,"title":"semiringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[59,18]}},{"comments":null,"title":"semiringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[65,13]}},{"comments":null,"title":"semiringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[71,15]}},{"comments":null,"title":"semiringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[77,16]}},{"comments":null,"title":"semiringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[79,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[83,16]}},{"comments":null,"title":"semiringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[85,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[89,63]}}],"comments":"The `Semiring` class is for types that support an addition and\nmultiplication operation.\n\nInstances must satisfy the following laws:\n\n- Commutative monoid under addition:\n - Associativity: `(a + b) + c = a + (b + c)`\n - Identity: `zero + a = a + zero = a`\n - Commutative: `a + b = b + a`\n- Monoid under multiplication:\n - Associativity: `(a * b) * c = a * (b * c)`\n - Identity: `one * a = a * one = a`\n- Multiplication distributes over addition:\n - Left distributivity: `a * (b + c) = (a * b) + (a * c)`\n - Right distributivity: `(a + b) * c = (a * c) + (b * c)`\n- Annihilation: `zero * a = a * zero = zero`\n\n**Note:** The `Number` and `Int` types are not fully law abiding\nmembers of this class hierarchy due to the potential for arithmetic\noverflows, and in the case of `Number`, the presence of `NaN` and\n`Infinity` values. The behaviour is unspecified in these cases.\n","title":"Semiring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"children":[],"comments":null,"title":"(+)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"add"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[40,18]}},{"children":[],"comments":null,"title":"(*)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"mul"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[41,18]}}]}],"name":"Data.DivisionRing","comments":null,"declarations":[{"children":[{"comments":null,"title":"recip","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[30,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[30,18]}},{"comments":null,"title":"divisionringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","DivisionRing"],"DivisionRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[54,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[55,20]}}],"comments":"The `DivisionRing` class is for non-zero rings in which every non-zero\nelement has a multiplicative inverse. Division rings are sometimes also\ncalled *skew fields*.\n\nInstances must satisfy the following laws in addition to the `Ring` laws:\n\n- Non-zero ring: `one /= zero`\n- Non-zero multiplicative inverse: `recip a * a = a * recip a = one` for\n all non-zero `a`\n\nThe result of `recip zero` is left undefined; individual instances may\nchoose how to handle this case.\n\nIf a type has both `DivisionRing` and `CommutativeRing` instances, then\nit is a field and should have a `Field` instance.\n","title":"DivisionRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[30,18]}},{"children":[],"comments":"Left division, defined as `leftDiv a b = recip b * a`. Left and right\ndivision are distinct in this module because a `DivisionRing` is not\nnecessarily commutative.\n\nIf the type `a` is also a `EuclideanRing`, then this function is\nequivalent to `div` from the `EuclideanRing` class. When working\nabstractly, `div` should generally be preferred, unless you know that you\nneed your code to work with noncommutative rings.\n","title":"leftDiv","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","DivisionRing"],"DivisionRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[40,51]}},{"children":[],"comments":"Right division, defined as `rightDiv a b = a * recip b`. Left and right\ndivision are distinct in this module because a `DivisionRing` is not\nnecessarily commutative.\n\nIf the type `a` is also a `EuclideanRing`, then this function is\nequivalent to `div` from the `EuclideanRing` class. When working\nabstractly, `div` should generally be preferred, unless you know that you\nneed your code to work with noncommutative rings.\n","title":"rightDiv","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","DivisionRing"],"DivisionRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]}},"sourceSpan":{"start":[51,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[51,52]}}]},{"reExports":[],"name":"Data.Eq","comments":null,"declarations":[{"children":[{"comments":null,"title":"eq","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}},"sourceSpan":{"start":[29,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[29,26]}},{"comments":null,"title":"eqBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[41,21]}},{"comments":null,"title":"eqInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[44,17]}},{"comments":null,"title":"eqNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[47,20]}},{"comments":null,"title":"eqChar","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Char"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[50,18]}},{"comments":null,"title":"eqString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[52,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[53,20]}},{"comments":null,"title":"eqUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[56,16]}},{"comments":null,"title":"eqVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[59,16]}},{"comments":null,"title":"eqArray","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[62,22]}},{"comments":null,"title":"eqRec","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Eq"],"EqRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[64,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[65,38]}},{"comments":null,"title":"eqProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[68,16]}},{"comments":null,"title":"eqProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[70,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[71,16]}},{"comments":null,"title":"eqProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[74,16]}}],"comments":"The `Eq` type class represents types which support decidable equality.\n\n`Eq` instances should satisfy the following laws:\n\n- Reflexivity: `x == x = true`\n- Symmetry: `x == y = y == x`\n- Transitivity: if `x == y` and `y == z` then `x == z`\n\n**Note:** The `Number` type is not an entirely law abiding member of this\nclass due to the presence of `NaN`, since `NaN /= NaN`. Additionally,\ncomputing with `Number` can result in a loss of precision, so sometimes\nvalues that should be equivalent are not.\n","title":"Eq","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[29,26]}},{"children":[],"comments":null,"title":"(==)","info":{"declType":"alias","alias":[["Data","Eq"],{"Right":{"Left":{"Ident":"eq"}}}],"fixity":{"associativity":"infix","precedence":4}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[31,17]}},{"children":[],"comments":"`notEq` tests whether one value is _not equal_ to another. Shorthand for\n`not (eq x y)`.\n","title":"notEq","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]},null]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[35,45]}},{"children":[],"comments":null,"title":"(/=)","info":{"declType":"alias","alias":[["Data","Eq"],{"Right":{"Left":{"Ident":"notEq"}}}],"fixity":{"associativity":"infix","precedence":4}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[38,20]}},{"children":[{"comments":null,"title":"eq1","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]},null]}},"sourceSpan":{"start":[86,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[86,49]}},{"comments":null,"title":"eq1Array","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[88,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[89,11]}}],"comments":"The `Eq1` type class represents type constructors with decidable equality.\n","title":"Eq1","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[85,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[86,49]}},{"children":[],"comments":null,"title":"notEq1","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq1"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]}]},null]},null]}},"sourceSpan":{"start":[91,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[91,61]}},{"children":[{"comments":null,"title":"eqRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]},null]}},"sourceSpan":{"start":[98,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[98,85]}},{"comments":null,"title":"eqRowNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"EqRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}},"sourceSpan":{"start":[100,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[101,24]}},{"comments":null,"title":"eqRowCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"EqRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"rowTail"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"EqRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}},"sourceSpan":{"start":[103,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[114,57]}}],"comments":null,"title":"EqRecord","info":{"fundeps":[],"arguments":[["rowlist",null],["row",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[97,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[98,85]}}]},{"reExports":[],"name":"Data.Eq.Generic","comments":null,"declarations":[{"children":[{"comments":null,"title":"genericEq'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}},"sourceSpan":{"start":[11,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq/Generic.purs","end":[11,34]}},{"comments":null,"title":"genericEqNoConstructors","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq","Generic"],"GenericEq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoConstructors"]}]}},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq/Generic.purs","end":[14,24]}},{"comments":null,"title":"genericEqNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq","Generic"],"GenericEq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq/Generic.purs","end":[17,24]}},{"comments":null,"title":"genericEqSum","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq","Generic"],"GenericEq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Eq","Generic"],"GenericEq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq","Generic"],"GenericEq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Sum"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq/Generic.purs","end":[22,25]}},{"comments":null,"title":"genericEqProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq","Generic"],"GenericEq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Eq","Generic"],"GenericEq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq","Generic"],"GenericEq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq/Generic.purs","end":[25,84]}},{"comments":null,"title":"genericEqConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq","Generic"],"GenericEq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq","Generic"],"GenericEq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq/Generic.purs","end":[28,66]}},{"comments":null,"title":"genericEqArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq","Generic"],"GenericEq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq/Generic.purs","end":[31,52]}}],"comments":null,"title":"GenericEq","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[10,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq/Generic.purs","end":[11,34]}},{"children":[],"comments":"A `Generic` implementation of the `eq` member from the `Eq` type class.\n","title":"genericEq","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq","Generic"],"GenericEq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]}]},null]},null]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq/Generic.purs","end":[34,79]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","CommutativeRing"]},"declarations":[{"children":[{"comments":null,"title":"commutativeRingInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[25,51]}},{"comments":null,"title":"commutativeRingNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[26,57]}},{"comments":null,"title":"commutativeRingUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[27,53]}},{"comments":null,"title":"commutativeRingFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[28,76]}},{"comments":null,"title":"commutativeRingRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[29,126]}},{"comments":null,"title":"commutativeRingProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[30,59]}},{"comments":null,"title":"commutativeRingProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[31,61]}},{"comments":null,"title":"commutativeRingProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[32,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[32,61]}}],"comments":"The `CommutativeRing` class is for rings where multiplication is\ncommutative.\n\nInstances must satisfy the following law in addition to the `Ring`\nlaws:\n\n- Commutative multiplication: `a * b = b * a`\n","title":"CommutativeRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[23,34]}}]},{"moduleName":{"package":null,"item":["Data","Ring"]},"declarations":[{"children":[{"comments":null,"title":"sub","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[24,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"comments":null,"title":"ringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[29,15]}},{"comments":null,"title":"ringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[32,15]}},{"comments":null,"title":"ringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[35,17]}},{"comments":null,"title":"ringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[38,24]}},{"comments":null,"title":"ringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[41,18]}},{"comments":null,"title":"ringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[44,19]}},{"comments":null,"title":"ringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[47,19]}},{"comments":null,"title":"ringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"RingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[50,40]}}],"comments":"The `Ring` class is for types that support addition, multiplication,\nand subtraction operations.\n\nInstances must satisfy the following laws in addition to the `Semiring`\nlaws:\n\n- Additive inverse: `a - a = zero`\n- Compatibility of `sub` and `negate`: `a - b = a + (zero - b)`\n","title":"Ring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"children":[],"comments":null,"title":"(-)","info":{"declType":"alias","alias":[["Data","Ring"],{"Right":{"Left":{"Ident":"sub"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[26,18]}}]},{"moduleName":{"package":null,"item":["Data","Semiring"]},"declarations":[{"children":[{"comments":null,"title":"add","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[35,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[35,22]}},{"comments":null,"title":"zero","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[36,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[36,12]}},{"comments":null,"title":"mul","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[37,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[37,22]}},{"comments":null,"title":"one","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"comments":null,"title":"semiringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[47,10]}},{"comments":null,"title":"semiringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[53,12]}},{"comments":null,"title":"semiringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[59,18]}},{"comments":null,"title":"semiringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[65,13]}},{"comments":null,"title":"semiringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[71,15]}},{"comments":null,"title":"semiringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[77,16]}},{"comments":null,"title":"semiringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[79,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[83,16]}},{"comments":null,"title":"semiringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[85,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[89,63]}}],"comments":"The `Semiring` class is for types that support an addition and\nmultiplication operation.\n\nInstances must satisfy the following laws:\n\n- Commutative monoid under addition:\n - Associativity: `(a + b) + c = a + (b + c)`\n - Identity: `zero + a = a + zero = a`\n - Commutative: `a + b = b + a`\n- Monoid under multiplication:\n - Associativity: `(a * b) * c = a * (b * c)`\n - Identity: `one * a = a * one = a`\n- Multiplication distributes over addition:\n - Left distributivity: `a * (b + c) = (a * b) + (a * c)`\n - Right distributivity: `(a + b) * c = (a * c) + (b * c)`\n- Annihilation: `zero * a = a * zero = zero`\n\n**Note:** The `Number` and `Int` types are not fully law abiding\nmembers of this class hierarchy due to the potential for arithmetic\noverflows, and in the case of `Number`, the presence of `NaN` and\n`Infinity` values. The behaviour is unspecified in these cases.\n","title":"Semiring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"children":[],"comments":null,"title":"(+)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"add"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[40,18]}},{"children":[],"comments":null,"title":"(*)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"mul"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[41,18]}}]}],"name":"Data.EuclideanRing","comments":null,"declarations":[{"children":[{"comments":null,"title":"degree","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[64,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[64,21]}},{"comments":null,"title":"div","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[65,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[65,21]}},{"comments":null,"title":"mod","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[66,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[66,21]}},{"comments":null,"title":"euclideanRingInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","EuclideanRing"],"EuclideanRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[70,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[73,15]}},{"comments":null,"title":"euclideanRingNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","EuclideanRing"],"EuclideanRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[75,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[78,16]}}],"comments":"The `EuclideanRing` class is for commutative rings that support division.\nThe mathematical structure this class is based on is sometimes also called\na *Euclidean domain*.\n\nInstances must satisfy the following laws in addition to the `Ring`\nlaws:\n\n- Integral domain: `one /= zero`, and if `a` and `b` are both nonzero then\n so is their product `a * b`\n- Euclidean function `degree`:\n - Nonnegativity: For all nonzero `a`, `degree a >= 0`\n - Quotient/remainder: For all `a` and `b`, where `b` is nonzero,\n let `q = a / b` and ``r = a `mod` b``; then `a = q*b + r`, and also\n either `r = zero` or `degree r < degree b`\n- Submultiplicative euclidean function:\n - For all nonzero `a` and `b`, `degree a <= degree (a * b)`\n\nThe behaviour of division by `zero` is unconstrained by these laws,\nmeaning that individual instances are free to choose how to behave in this\ncase. Similarly, there are no restrictions on what the result of\n`degree zero` is; it doesn't make sense to ask for `degree zero` in the\nsame way that it doesn't make sense to divide by `zero`, so again,\nindividual instances may choose how to handle this case.\n\nFor any `EuclideanRing` which is also a `Field`, one valid choice\nfor `degree` is simply `const 1`. In fact, unless there's a specific\nreason not to, `Field` types should normally use this definition of\n`degree`.\n\nThe `EuclideanRing Int` instance is one of the most commonly used\n`EuclideanRing` instances and deserves a little more discussion. In\nparticular, there are a few different sensible law-abiding implementations\nto choose from, with slightly different behaviour in the presence of\nnegative dividends or divisors. The most common definitions are \"truncating\"\ndivision, where the result of `a / b` is rounded towards 0, and \"Knuthian\"\nor \"flooring\" division, where the result of `a / b` is rounded towards\nnegative infinity. A slightly less common, but arguably more useful, option\nis \"Euclidean\" division, which is defined so as to ensure that ``a `mod` b``\nis always nonnegative. With Euclidean division, `a / b` rounds towards\nnegative infinity if the divisor is positive, and towards positive infinity\nif the divisor is negative. Note that all three definitions are identical if\nwe restrict our attention to nonnegative dividends and divisors.\n\nIn versions 1.x, 2.x, and 3.x of the Prelude, the `EuclideanRing Int`\ninstance used truncating division. As of 4.x, the `EuclideanRing Int`\ninstance uses Euclidean division. Additional functions `quot` and `rem` are\nsupplied if truncating division is desired.\n","title":"EuclideanRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[66,21]}},{"children":[],"comments":null,"title":"(/)","info":{"declType":"alias","alias":[["Data","EuclideanRing"],{"Right":{"Left":{"Ident":"div"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[68,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[68,18]}},{"children":[],"comments":"The *greatest common divisor* of two values.\n","title":"gcd","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]}},"sourceSpan":{"start":[87,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[87,56]}},{"children":[],"comments":"The *least common multiple* of two values.\n","title":"lcm","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]}},"sourceSpan":{"start":[94,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[94,56]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","CommutativeRing"]},"declarations":[{"children":[{"comments":null,"title":"commutativeRingInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[25,51]}},{"comments":null,"title":"commutativeRingNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[26,57]}},{"comments":null,"title":"commutativeRingUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[27,53]}},{"comments":null,"title":"commutativeRingFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[28,76]}},{"comments":null,"title":"commutativeRingRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[29,126]}},{"comments":null,"title":"commutativeRingProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[30,59]}},{"comments":null,"title":"commutativeRingProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[31,61]}},{"comments":null,"title":"commutativeRingProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[32,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[32,61]}}],"comments":"The `CommutativeRing` class is for rings where multiplication is\ncommutative.\n\nInstances must satisfy the following law in addition to the `Ring`\nlaws:\n\n- Commutative multiplication: `a * b = b * a`\n","title":"CommutativeRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[23,34]}}]},{"moduleName":{"package":null,"item":["Data","DivisionRing"]},"declarations":[{"children":[{"comments":null,"title":"recip","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[30,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[30,18]}},{"comments":null,"title":"divisionringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","DivisionRing"],"DivisionRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[54,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[55,20]}}],"comments":"The `DivisionRing` class is for non-zero rings in which every non-zero\nelement has a multiplicative inverse. Division rings are sometimes also\ncalled *skew fields*.\n\nInstances must satisfy the following laws in addition to the `Ring` laws:\n\n- Non-zero ring: `one /= zero`\n- Non-zero multiplicative inverse: `recip a * a = a * recip a = one` for\n all non-zero `a`\n\nThe result of `recip zero` is left undefined; individual instances may\nchoose how to handle this case.\n\nIf a type has both `DivisionRing` and `CommutativeRing` instances, then\nit is a field and should have a `Field` instance.\n","title":"DivisionRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[30,18]}}]},{"moduleName":{"package":null,"item":["Data","EuclideanRing"]},"declarations":[{"children":[{"comments":null,"title":"degree","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[64,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[64,21]}},{"comments":null,"title":"div","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[65,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[65,21]}},{"comments":null,"title":"mod","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[66,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[66,21]}},{"comments":null,"title":"euclideanRingInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","EuclideanRing"],"EuclideanRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[70,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[73,15]}},{"comments":null,"title":"euclideanRingNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","EuclideanRing"],"EuclideanRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[75,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[78,16]}}],"comments":"The `EuclideanRing` class is for commutative rings that support division.\nThe mathematical structure this class is based on is sometimes also called\na *Euclidean domain*.\n\nInstances must satisfy the following laws in addition to the `Ring`\nlaws:\n\n- Integral domain: `one /= zero`, and if `a` and `b` are both nonzero then\n so is their product `a * b`\n- Euclidean function `degree`:\n - Nonnegativity: For all nonzero `a`, `degree a >= 0`\n - Quotient/remainder: For all `a` and `b`, where `b` is nonzero,\n let `q = a / b` and ``r = a `mod` b``; then `a = q*b + r`, and also\n either `r = zero` or `degree r < degree b`\n- Submultiplicative euclidean function:\n - For all nonzero `a` and `b`, `degree a <= degree (a * b)`\n\nThe behaviour of division by `zero` is unconstrained by these laws,\nmeaning that individual instances are free to choose how to behave in this\ncase. Similarly, there are no restrictions on what the result of\n`degree zero` is; it doesn't make sense to ask for `degree zero` in the\nsame way that it doesn't make sense to divide by `zero`, so again,\nindividual instances may choose how to handle this case.\n\nFor any `EuclideanRing` which is also a `Field`, one valid choice\nfor `degree` is simply `const 1`. In fact, unless there's a specific\nreason not to, `Field` types should normally use this definition of\n`degree`.\n\nThe `EuclideanRing Int` instance is one of the most commonly used\n`EuclideanRing` instances and deserves a little more discussion. In\nparticular, there are a few different sensible law-abiding implementations\nto choose from, with slightly different behaviour in the presence of\nnegative dividends or divisors. The most common definitions are \"truncating\"\ndivision, where the result of `a / b` is rounded towards 0, and \"Knuthian\"\nor \"flooring\" division, where the result of `a / b` is rounded towards\nnegative infinity. A slightly less common, but arguably more useful, option\nis \"Euclidean\" division, which is defined so as to ensure that ``a `mod` b``\nis always nonnegative. With Euclidean division, `a / b` rounds towards\nnegative infinity if the divisor is positive, and towards positive infinity\nif the divisor is negative. Note that all three definitions are identical if\nwe restrict our attention to nonnegative dividends and divisors.\n\nIn versions 1.x, 2.x, and 3.x of the Prelude, the `EuclideanRing Int`\ninstance used truncating division. As of 4.x, the `EuclideanRing Int`\ninstance uses Euclidean division. Additional functions `quot` and `rem` are\nsupplied if truncating division is desired.\n","title":"EuclideanRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[66,21]}},{"children":[],"comments":"The *least common multiple* of two values.\n","title":"lcm","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]}},"sourceSpan":{"start":[94,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[94,56]}},{"children":[],"comments":"The *greatest common divisor* of two values.\n","title":"gcd","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]}},"sourceSpan":{"start":[87,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[87,56]}},{"children":[],"comments":null,"title":"(/)","info":{"declType":"alias","alias":[["Data","EuclideanRing"],{"Right":{"Left":{"Ident":"div"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[68,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[68,18]}}]},{"moduleName":{"package":null,"item":["Data","Ring"]},"declarations":[{"children":[{"comments":null,"title":"sub","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[24,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"comments":null,"title":"ringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[29,15]}},{"comments":null,"title":"ringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[32,15]}},{"comments":null,"title":"ringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[35,17]}},{"comments":null,"title":"ringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[38,24]}},{"comments":null,"title":"ringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[41,18]}},{"comments":null,"title":"ringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[44,19]}},{"comments":null,"title":"ringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[47,19]}},{"comments":null,"title":"ringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"RingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[50,40]}}],"comments":"The `Ring` class is for types that support addition, multiplication,\nand subtraction operations.\n\nInstances must satisfy the following laws in addition to the `Semiring`\nlaws:\n\n- Additive inverse: `a - a = zero`\n- Compatibility of `sub` and `negate`: `a - b = a + (zero - b)`\n","title":"Ring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"children":[],"comments":"`negate x` can be used as a shorthand for `zero - x`.\n","title":"negate","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[53,37]}}]},{"moduleName":{"package":null,"item":["Data","Semiring"]},"declarations":[{"children":[{"comments":null,"title":"add","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[35,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[35,22]}},{"comments":null,"title":"zero","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[36,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[36,12]}},{"comments":null,"title":"mul","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[37,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[37,22]}},{"comments":null,"title":"one","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"comments":null,"title":"semiringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[47,10]}},{"comments":null,"title":"semiringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[53,12]}},{"comments":null,"title":"semiringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[59,18]}},{"comments":null,"title":"semiringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[65,13]}},{"comments":null,"title":"semiringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[71,15]}},{"comments":null,"title":"semiringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[77,16]}},{"comments":null,"title":"semiringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[79,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[83,16]}},{"comments":null,"title":"semiringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[85,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[89,63]}}],"comments":"The `Semiring` class is for types that support an addition and\nmultiplication operation.\n\nInstances must satisfy the following laws:\n\n- Commutative monoid under addition:\n - Associativity: `(a + b) + c = a + (b + c)`\n - Identity: `zero + a = a + zero = a`\n - Commutative: `a + b = b + a`\n- Monoid under multiplication:\n - Associativity: `(a * b) * c = a * (b * c)`\n - Identity: `one * a = a * one = a`\n- Multiplication distributes over addition:\n - Left distributivity: `a * (b + c) = (a * b) + (a * c)`\n - Right distributivity: `(a + b) * c = (a * c) + (b * c)`\n- Annihilation: `zero * a = a * zero = zero`\n\n**Note:** The `Number` and `Int` types are not fully law abiding\nmembers of this class hierarchy due to the potential for arithmetic\noverflows, and in the case of `Number`, the presence of `NaN` and\n`Infinity` values. The behaviour is unspecified in these cases.\n","title":"Semiring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"children":[],"comments":null,"title":"(+)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"add"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[40,18]}},{"children":[],"comments":null,"title":"(*)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"mul"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[41,18]}}]}],"name":"Data.Field","comments":null,"declarations":[{"children":[{"comments":null,"title":"field","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","DivisionRing"],"DivisionRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Field"],"Field"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Field.purs","end":[41,63]}}],"comments":"The `Field` class is for types that are (commutative) fields.\n\nMathematically, a field is a ring which is commutative and in which every\nnonzero element has a multiplicative inverse; these conditions correspond\nto the `CommutativeRing` and `DivisionRing` classes in PureScript\nrespectively. However, the `Field` class has `EuclideanRing` and\n`DivisionRing` as superclasses, which seems like a stronger requirement\n(since `CommutativeRing` is a superclass of `EuclideanRing`). In fact, it\nis not stronger, since any type which has law-abiding `CommutativeRing`\nand `DivisionRing` instances permits exactly one law-abiding\n`EuclideanRing` instance. We use a `EuclideanRing` superclass here in\norder to ensure that a `Field` constraint on a function permits you to use\n`div` on that type, since `div` is a member of `EuclideanRing`.\n\nThis class has no laws or members of its own; it exists as a convenience,\nso a single constraint can be used when field-like behaviour is expected.\n\nThis module also defines a single `Field` instance for any type which has\nboth `EuclideanRing` and `DivisionRing` instances. Any other instance\nwould overlap with this instance, so no other `Field` instances should be\ndefined in libraries. Instead, simply define `EuclideanRing` and\n`DivisionRing` instances, and this will permit your type to be used with a\n`Field` constraint.\n","title":"Field","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","DivisionRing"],"DivisionRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Field.purs","end":[39,51]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Control","Category"]},"declarations":[{"children":[],"comments":null,"title":"compose","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["d",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[null,"Semigroupoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]}]}]},null]},null]},null]},null]}},"sourceSpan":{"start":[14,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[14,51]}},{"children":[],"comments":null,"title":"identity","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["t",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[null,"Category"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"t"}]},{"annotation":[],"tag":"TypeVar","contents":"t"}]}]},null]},null]}},"sourceSpan":{"start":[18,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Category.purs","end":[18,30]}},{"children":[],"comments":null,"title":"(>>>)","info":{"declType":"alias","alias":[["Control","Semigroupoid"],{"Right":{"Left":{"Ident":"composeFlipped"}}}],"fixity":{"associativity":"infixr","precedence":9}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[25,31]}},{"children":[],"comments":null,"title":"(<<<)","info":{"declType":"alias","alias":[["Control","Semigroupoid"],{"Right":{"Left":{"Ident":"compose"}}}],"fixity":{"associativity":"infixr","precedence":9}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[19,24]}}]}],"name":"Data.Function","comments":null,"declarations":[{"children":[],"comments":"Flips the order of the arguments to a function of two arguments.\n\n```purescript\nflip const 1 2 = const 2 1 = 2\n```\n","title":"flip","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[21,51]}},{"children":[],"comments":"Returns its first argument and ignores its second.\n\n```purescript\nconst 1 \"hello\" = 1\n```\n\nIt can also be thought of as creating a function that ignores its argument:\n\n```purescript\nconst 1 = \\_ -> 1\n```\n","title":"const","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[35,33]}},{"children":[],"comments":"Applies a function to an argument. This is primarily used as the operator\n`($)` which allows parentheses to be omitted in some cases, or as a\nnatural way to apply a chain of composed functions to a value.\n","title":"apply","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]},null]},null]}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[41,40]}},{"children":[],"comments":"Applies a function to an argument: the reverse of `(#)`.\n\n```purescript\nlength $ groupBy productCategory $ filter isInStock $ products\n```\n\nis equivalent to:\n\n```purescript\nlength (groupBy productCategory (filter isInStock products))\n```\n\nOr another alternative equivalent, applying chain of composed functions to\na value:\n\n```purescript\nlength <<< groupBy productCategory <<< filter isInStock $ products\n```\n","title":"($)","info":{"declType":"alias","alias":[["Data","Function"],{"Right":{"Left":{"Ident":"apply"}}}],"fixity":{"associativity":"infixr","precedence":0}},"sourceSpan":{"start":[62,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[62,20]}},{"children":[],"comments":"Applies an argument to a function. This is primarily used as the `(#)`\noperator, which allows parentheses to be omitted in some cases, or as a\nnatural way to apply a value to a chain of composed functions.\n","title":"applyFlipped","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]},null]},null]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[67,47]}},{"children":[],"comments":"Applies an argument to a function: the reverse of `($)`.\n\n```purescript\nproducts # filter isInStock # groupBy productCategory # length\n```\n\nis equivalent to:\n\n```purescript\nlength (groupBy productCategory (filter isInStock products))\n```\n\nOr another alternative equivalent, applying a value to a chain of composed\nfunctions:\n\n```purescript\nproducts # filter isInStock >>> groupBy productCategory >>> length\n```\n","title":"(#)","info":{"declType":"alias","alias":[["Data","Function"],{"Right":{"Left":{"Ident":"applyFlipped"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[88,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[88,27]}},{"children":[],"comments":"`applyN f n` applies the function `f` to its argument `n` times.\n\nIf n is less than or equal to 0, the function is not applied.\n\n```purescript\napplyN (_ + 1) 10 0 == 10\n```\n","title":"applyN","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]}},"sourceSpan":{"start":[97,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[97,46]}},{"children":[],"comments":"The `on` function is used to change the domain of a binary operator.\n\nFor example, we can create a function which compares two records based on the values of their `x` properties:\n\n```purescript\ncompareX :: forall r. { x :: Number | r } -> { x :: Number | r } -> Ordering\ncompareX = compare `on` _.x\n```\n","title":"on","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[112,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[112,61]}}]},{"reExports":[],"name":"Data.Functor","comments":null,"declarations":[{"children":[{"comments":null,"title":"map","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[26,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"comments":null,"title":"functorFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[41,16]}},{"comments":null,"title":"functorArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[44,17]}},{"comments":null,"title":"functorProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[47,18]}}],"comments":"A `Functor` is a type constructor which supports a mapping operation\n`map`.\n\n`map` can be used to turn functions `a -> b` into functions\n`f a -> f b` whose argument and return types use the type constructor `f`\nto represent some computational context.\n\nInstances must satisfy the following laws:\n\n- Identity: `map identity = identity`\n- Composition: `map (f <<< g) = map f <<< map g`\n","title":"Functor","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"children":[],"comments":null,"title":"(<$>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"map"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[28,20]}},{"children":[],"comments":"`mapFlipped` is `map` with its arguments reversed. For example:\n\n```purescript\n[1, 2, 3] <#> \\n -> n * n\n```\n","title":"mapFlipped","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[35,64]}},{"children":[],"comments":null,"title":"(<#>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"mapFlipped"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[38,27]}},{"children":[],"comments":"The `void` function is used to ignore the type wrapped by a\n[`Functor`](#functor), replacing it with `Unit` and keeping only the type\ninformation provided by the type constructor itself.\n\n`void` is often useful when using `do` notation to change the return type\nof a monadic computation:\n\n```purescript\nmain = forE 1 10 \\n -> void do\n print n\n print (n * n)\n```\n","title":"void","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]},null]},null]}},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[63,47]}},{"children":[],"comments":"Ignore the return value of a computation, using the specified return value\ninstead.\n","title":"voidRight","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[68,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[68,56]}},{"children":[],"comments":null,"title":"(<$)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidRight"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[71,25]}},{"children":[],"comments":"A version of `voidRight` with its arguments flipped.\n","title":"voidLeft","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[74,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[74,55]}},{"children":[],"comments":null,"title":"($>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidLeft"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[77,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[77,24]}},{"children":[],"comments":"Apply a value in a computational context to a value in no context.\n\nGeneralizes `flip`.\n\n```purescript\nlongEnough :: String -> Bool\nhasSymbol :: String -> Bool\nhasDigit :: String -> Bool\npassword :: String\n\nvalidate :: String -> Array Bool\nvalidate = flap [longEnough, hasSymbol, hasDigit]\n```\n\n```purescript\nflap (-) 3 4 == 1\nthreeve <$> Just 1 <@> 'a' <*> Just true == Just (threeve 1 'a' true)\n```\n","title":"flap","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[97,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[97,58]}},{"children":[],"comments":null,"title":"(<@>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"flap"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[100,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[100,21]}}]},{"reExports":[],"name":"Data.Generic.Rep","comments":null,"declarations":[{"children":[{"comments":null,"title":"to","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"rep"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[57,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[57,17]}},{"comments":null,"title":"from","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"rep"}]}},"sourceSpan":{"start":[58,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[58,19]}}],"comments":"The `Generic` class asserts the existence of a type function from types\nto their representations using the type constructors defined in this module.\n","title":"Generic","info":{"fundeps":[[["a"],["rep"]]],"arguments":[["a",null],["rep",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[56,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[58,19]}},{"children":[],"comments":null,"title":"repOf","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"rep"}]}]}]},null]},null]}},"sourceSpan":{"start":[60,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[60,61]}},{"children":[],"comments":"A representation for types with no constructors.\n","title":"NoConstructors","info":{"declType":"data","dataDeclType":"data","typeArguments":[]},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[20,20]}},{"children":[{"comments":null,"title":"NoArguments","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"showNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[26,25]}}],"comments":"A representation for constructors with no arguments.\n","title":"NoArguments","info":{"declType":"data","dataDeclType":"data","typeArguments":[]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[23,31]}},{"children":[{"comments":null,"title":"Inl","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"Inr","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"showSum","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Sum"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[33,42]}}],"comments":"A representation for types with multiple constructors.\n","title":"Sum","info":{"declType":"data","dataDeclType":"data","typeArguments":[["a",null],["b",null]]},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[29,29]}},{"children":[{"comments":null,"title":"Product","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"showProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[39,69]}}],"comments":"A representation for constructors with multiple fields.\n","title":"Product","info":{"declType":"data","dataDeclType":"data","typeArguments":[["a",null],["b",null]]},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[36,31]}},{"children":[{"comments":null,"title":"Constructor","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"showConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"name"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[46,112]}}],"comments":"A representation for constructors which includes the data constructor name\nas a type-level string.\n","title":"Constructor","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["name",{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Symbol"]}],["a",null]]},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[43,55]}},{"children":[{"comments":null,"title":"Argument","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"showArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[51,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[52,52]}}],"comments":"A representation for an argument in a data constructor.\n","title":"Argument","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["a",null]]},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Generic/Rep.purs","end":[49,32]}}]},{"reExports":[],"name":"Data.HeytingAlgebra","comments":null,"declarations":[{"children":[{"comments":null,"title":"ff","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[39,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[39,10]}},{"comments":null,"title":"tt","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[40,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[40,10]}},{"comments":null,"title":"implies","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[41,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[41,25]}},{"comments":null,"title":"conj","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[42,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[42,22]}},{"comments":null,"title":"disj","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[43,22]}},{"comments":null,"title":"not","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[44,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[44,16]}},{"comments":null,"title":"heytingAlgebraBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[55,16]}},{"comments":null,"title":"heytingAlgebraUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[63,15]}},{"comments":null,"title":"heytingAlgebraFunction","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[71,22]}},{"comments":null,"title":"heytingAlgebraProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[79,13]}},{"comments":null,"title":"heytingAlgebraProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[81,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[87,14]}},{"comments":null,"title":"heytingAlgebraProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[89,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[95,14]}},{"comments":null,"title":"heytingAlgebraRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[97,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[103,41]}}],"comments":"The `HeytingAlgebra` type class represents types that are bounded lattices with\nan implication operator such that the following laws hold:\n\n- Associativity:\n - `a || (b || c) = (a || b) || c`\n - `a && (b && c) = (a && b) && c`\n- Commutativity:\n - `a || b = b || a`\n - `a && b = b && a`\n- Absorption:\n - `a || (a && b) = a`\n - `a && (a || b) = a`\n- Idempotent:\n - `a || a = a`\n - `a && a = a`\n- Identity:\n - `a || ff = a`\n - `a && tt = a`\n- Implication:\n - ``a `implies` a = tt``\n - ``a && (a `implies` b) = a && b``\n - ``b && (a `implies` b) = b``\n - ``a `implies` (b && c) = (a `implies` b) && (a `implies` c)``\n- Complemented:\n - ``not a = a `implies` ff``\n","title":"HeytingAlgebra","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[44,16]}},{"children":[],"comments":null,"title":"(&&)","info":{"declType":"alias","alias":[["Data","HeytingAlgebra"],{"Right":{"Left":{"Ident":"conj"}}}],"fixity":{"associativity":"infixr","precedence":3}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[46,20]}},{"children":[],"comments":null,"title":"(||)","info":{"declType":"alias","alias":[["Data","HeytingAlgebra"],{"Right":{"Left":{"Ident":"disj"}}}],"fixity":{"associativity":"infixr","precedence":2}},"sourceSpan":{"start":[47,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[47,20]}},{"children":[{"comments":null,"title":"ffRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"ForAll","contents":["rproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rproxy"},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]},null]},null]}},"sourceSpan":{"start":[113,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[113,84]}},{"comments":null,"title":"ttRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"ForAll","contents":["rproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rproxy"},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]},null]},null]}},"sourceSpan":{"start":[114,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[114,84]}},{"comments":null,"title":"impliesRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]}]},null]}},"sourceSpan":{"start":[115,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[115,96]}},{"comments":null,"title":"disjRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]}]},null]}},"sourceSpan":{"start":[116,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[116,93]}},{"comments":null,"title":"conjRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]}]},null]}},"sourceSpan":{"start":[117,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[117,93]}},{"comments":null,"title":"notRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]},null]}},"sourceSpan":{"start":[118,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[118,78]}},{"comments":null,"title":"heytingAlgebraRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[120,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[126,20]}},{"comments":null,"title":"heytingAlgebraRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[128,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[174,55]}}],"comments":null,"title":"HeytingAlgebraRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[112,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[118,78]}}]},{"reExports":[],"name":"Data.HeytingAlgebra.Generic","comments":null,"declarations":[{"children":[{"comments":null,"title":"genericFF'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[9,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[9,18]}},{"comments":null,"title":"genericTT'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[10,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[10,18]}},{"comments":null,"title":"genericImplies'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[11,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[11,33]}},{"comments":null,"title":"genericConj'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[12,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[12,30]}},{"comments":null,"title":"genericDisj'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[13,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[13,30]}},{"comments":null,"title":"genericNot'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[14,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[14,24]}},{"comments":null,"title":"genericHeytingAlgebraNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[22,30]}},{"comments":null,"title":"genericHeytingAlgebraArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[30,46]}},{"comments":null,"title":"genericHeytingAlgebraProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[32,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[38,70]}},{"comments":null,"title":"genericHeytingAlgebraConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[46,60]}}],"comments":null,"title":"GenericHeytingAlgebra","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[8,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[14,24]}},{"children":[],"comments":"A `Generic` implementation of the `ff` member from the `HeytingAlgebra` type class.\n","title":"genericFF","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[49,75]}},{"children":[],"comments":"A `Generic` implementation of the `tt` member from the `HeytingAlgebra` type class.\n","title":"genericTT","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[53,75]}},{"children":[],"comments":"A `Generic` implementation of the `implies` member from the `HeytingAlgebra` type class.\n","title":"genericImplies","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]},null]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[57,90]}},{"children":[],"comments":"A `Generic` implementation of the `conj` member from the `HeytingAlgebra` type class.\n","title":"genericConj","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]},null]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[61,87]}},{"children":[],"comments":"A `Generic` implementation of the `disj` member from the `HeytingAlgebra` type class.\n","title":"genericDisj","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]},null]}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[65,87]}},{"children":[],"comments":"A `Generic` implementation of the `not` member from the `HeytingAlgebra` type class.\n","title":"genericNot","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra","Generic"],"GenericHeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]},null]}},"sourceSpan":{"start":[69,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra/Generic.purs","end":[69,81]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","Semigroup"]},"declarations":[{"children":[{"comments":null,"title":"semigroupString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[37,24]}},{"comments":null,"title":"semigroupUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[40,20]}},{"comments":null,"title":"semigroupVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[43,20]}},{"comments":null,"title":"semigroupFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"Semigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"s'"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"s"}]},{"annotation":[],"tag":"TypeVar","contents":"s'"}]}]}},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[46,28]}},{"comments":null,"title":"semigroupArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[49,23]}},{"comments":null,"title":"semigroupProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[51,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[52,21]}},{"comments":null,"title":"semigroupProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[54,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[55,22]}},{"comments":null,"title":"semigroupProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[58,22]}},{"comments":null,"title":"semigroupRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"SemigroupRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[60,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[61,46]}}],"comments":"The `Semigroup` type class identifies an associative operation on a type.\n\nInstances are required to satisfy the following law:\n\n- Associativity: `(x <> y) <> z = x <> (y <> z)`\n\nOne example of a `Semigroup` is `String`, with `(<>)` defined as string\nconcatenation. Another example is `List a`, with `(<>)` defined as\nlist concatenation.\n\n### Newtypes for Semigroup\n\nThere are two other ways to implement an instance for this type class\nregardless of which type is used. These instances can be used by\nwrapping the values in one of the two newtypes below:\n1. `First` - Use the first argument every time: `append first _ = first`.\n2. `Last` - Use the last argument every time: `append _ last = last`.\n","title":"Semigroup","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[32,24]}},{"children":[{"comments":null,"title":"semigroupRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"SemigroupRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[72,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[73,26]}},{"comments":null,"title":"semigroupRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"SemigroupRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"Semigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"SemigroupRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[75,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[87,61]}}],"comments":null,"title":"SemigroupRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[69,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[70,95]}},{"children":[],"comments":null,"title":"(<>)","info":{"declType":"alias","alias":[["Data","Semigroup"],{"Right":{"Left":{"Ident":"append"}}}],"fixity":{"associativity":"infixr","precedence":5}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[34,22]}}]}],"name":"Data.Monoid","comments":null,"declarations":[{"children":[{"comments":null,"title":"mempty","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"m"}},"sourceSpan":{"start":[45,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[45,14]}},{"comments":null,"title":"monoidUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[47,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[48,16]}},{"comments":null,"title":"monoidOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[51,14]}},{"comments":null,"title":"monoidFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"Monoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[54,20]}},{"comments":null,"title":"monoidString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[56,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[57,14]}},{"comments":null,"title":"monoidArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[59,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[60,14]}},{"comments":null,"title":"monoidRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"MonoidRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[62,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[63,46]}}],"comments":"A `Monoid` is a `Semigroup` with a value `mempty`, which is both a\nleft and right unit for the associative operation `<>`:\n\n- Left unit: `(mempty <> x) = x`\n- Right unit: `(x <> mempty) = x`\n\n`Monoid`s are commonly used as the result of fold operations, where\n`<>` is used to combine individual results, and `mempty` gives the result\nof folding an empty collection of elements.\n\n### Newtypes for Monoid\n\nSome types (e.g. `Int`, `Boolean`) can implement multiple law-abiding\ninstances for `Monoid`. Let's use `Int` as an example\n1. `<>` could be `+` and `mempty` could be `0`\n2. `<>` could be `*` and `mempty` could be `1`.\n\nTo clarify these ambiguous situations, one should use the newtypes\ndefined in `Data.Monoid.` modules.\n\nIn the above ambiguous situation, we could use `Additive`\nfor the first situation or `Multiplicative` for the second one.\n","title":"Monoid","info":{"fundeps":[],"arguments":[["m",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"Semigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[44,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[45,14]}},{"children":[],"comments":"Append a value to itself a certain number of times. For the\n`Multiplicative` type, and for a non-negative power, this is the same as\nnormal number exponentiation.\n\nIf the second argument is negative this function will return `mempty`\n(*unlike* normal number exponentiation). The `Monoid` constraint alone\nis not enough to write a `power` function with the property that `power x\nn` cancels with `power x (-n)`, i.e. `power x n <> power x (-n) = mempty`.\nFor that, we would additionally need the ability to invert elements, i.e.\na Group.\n\n```purescript\npower [1,2] 3 == [1,2,1,2,1,2]\npower [1,2] 1 == [1,2]\npower [1,2] 0 == []\npower [1,2] (-3) == []\n```\n\n","title":"power","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"Monoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"m"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]},{"annotation":[],"tag":"TypeVar","contents":"m"}]}]}]},null]}},"sourceSpan":{"start":[83,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[83,45]}},{"children":[],"comments":"Allow or \"truncate\" a Monoid to its `mempty` value based on a condition.\n","title":"guard","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"Monoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"m"}]},{"annotation":[],"tag":"TypeVar","contents":"m"}]}]}]},null]}},"sourceSpan":{"start":[94,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[94,49]}},{"children":[{"comments":null,"title":"memptyRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]},null]}},"sourceSpan":{"start":[102,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[102,67]}},{"comments":null,"title":"monoidRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"MonoidRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[104,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[105,22]}},{"comments":null,"title":"monoidRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"Monoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"MonoidRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"MonoidRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[107,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[119,55]}}],"comments":null,"title":"MonoidRecord","info":{"fundeps":[[["rowlist"],["row","subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"SemigroupRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlist"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[101,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[102,67]}}]},{"reExports":[],"name":"Data.Monoid.Additive","comments":null,"declarations":[{"children":[{"comments":null,"title":"Additive","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqAdditive","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[16,62]}},{"comments":null,"title":"eq1Additive","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]}]}},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[17,44]}},{"comments":null,"title":"ordAdditive","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[19,65]}},{"comments":null,"title":"ord1Additive","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[20,46]}},{"comments":null,"title":"boundedAdditive","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[22,77]}},{"comments":null,"title":"showAdditive","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[25,52]}},{"comments":null,"title":"functorAdditive","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[27,52]}},{"comments":null,"title":"applyAdditive","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[30,51]}},{"comments":null,"title":"applicativeAdditive","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]}]}},"sourceSpan":{"start":[32,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[33,18]}},{"comments":null,"title":"bindAdditive","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]}]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[36,28]}},{"comments":null,"title":"monadAdditive","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]}]}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[38,41]}},{"comments":null,"title":"semigroupAdditive","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[41,54]}},{"comments":null,"title":"monoidAdditive","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Additive"],"Additive"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[44,25]}}],"comments":"Monoid and semigroup for semirings under addition.\n\n``` purescript\nAdditive x <> Additive y == Additive (x + y)\n(mempty :: Additive _) == Additive zero\n```\n","title":"Additive","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["a",null]]},"sourceSpan":{"start":[14,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Additive.purs","end":[14,32]}}]},{"reExports":[],"name":"Data.Monoid.Conj","comments":null,"declarations":[{"children":[{"comments":null,"title":"Conj","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqConj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[17,54]}},{"comments":null,"title":"eq1Conj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]}]}},"sourceSpan":{"start":[18,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[18,36]}},{"comments":null,"title":"ordConj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[20,57]}},{"comments":null,"title":"ord1Conj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]}]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[21,38]}},{"comments":null,"title":"boundedConj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[23,69]}},{"comments":null,"title":"showConj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[26,44]}},{"comments":null,"title":"functorConj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[28,44]}},{"comments":null,"title":"applyConj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[31,39]}},{"comments":null,"title":"applicativeConj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]}]}},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[34,14]}},{"comments":null,"title":"bindConj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[37,24]}},{"comments":null,"title":"monadConj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[39,33]}},{"comments":null,"title":"semigroupConj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[42,45]}},{"comments":null,"title":"monoidConj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[44,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[45,19]}},{"comments":null,"title":"semiringConj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Conj"],"Conj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[47,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[51,42]}}],"comments":"Monoid and semigroup for conjunction.\n\n``` purescript\nConj x <> Conj y == Conj (x && y)\n(mempty :: Conj _) == Conj tt\n```\n","title":"Conj","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["a",null]]},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Conj.purs","end":[15,24]}}]},{"reExports":[],"name":"Data.Monoid.Disj","comments":null,"declarations":[{"children":[{"comments":null,"title":"Disj","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqDisj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[17,54]}},{"comments":null,"title":"eq1Disj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]}]}},"sourceSpan":{"start":[18,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[18,36]}},{"comments":null,"title":"ordDisj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[20,57]}},{"comments":null,"title":"ord1Disj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]}]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[21,38]}},{"comments":null,"title":"boundedDisj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[23,69]}},{"comments":null,"title":"showDisj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[26,44]}},{"comments":null,"title":"functorDisj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[28,44]}},{"comments":null,"title":"applyDisj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[31,39]}},{"comments":null,"title":"applicativeDisj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]}]}},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[34,14]}},{"comments":null,"title":"bindDisj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[37,24]}},{"comments":null,"title":"monadDisj","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[39,33]}},{"comments":null,"title":"semigroupDisj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[42,45]}},{"comments":null,"title":"monoidDisj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[44,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[45,19]}},{"comments":null,"title":"semiringDisj","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Disj"],"Disj"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[47,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[51,42]}}],"comments":"Monoid and semigroup for disjunction.\n\n``` purescript\nDisj x <> Disj y == Disj (x || y)\n(mempty :: Disj _) == Disj bottom\n```\n","title":"Disj","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["a",null]]},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Disj.purs","end":[15,24]}}]},{"reExports":[],"name":"Data.Monoid.Dual","comments":null,"declarations":[{"children":[{"comments":null,"title":"Dual","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqDual","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[16,54]}},{"comments":null,"title":"eq1Dual","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]}]}},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[17,36]}},{"comments":null,"title":"ordDual","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[19,57]}},{"comments":null,"title":"ord1Dual","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[20,38]}},{"comments":null,"title":"boundedDual","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[22,69]}},{"comments":null,"title":"showDual","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[25,44]}},{"comments":null,"title":"functorDual","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[27,44]}},{"comments":null,"title":"applyDual","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[30,39]}},{"comments":null,"title":"applicativeDual","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]}]}},"sourceSpan":{"start":[32,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[33,14]}},{"comments":null,"title":"bindDual","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]}]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[36,24]}},{"comments":null,"title":"monadDual","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]}]}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[38,33]}},{"comments":null,"title":"semigroupDual","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"Semigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[41,43]}},{"comments":null,"title":"monoidDual","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"Monoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Dual"],"Dual"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[44,23]}}],"comments":"The dual of a monoid.\n\n``` purescript\nDual x <> Dual y == Dual (y <> x)\n(mempty :: Dual _) == Dual mempty\n```\n","title":"Dual","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["a",null]]},"sourceSpan":{"start":[14,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Dual.purs","end":[14,24]}}]},{"reExports":[],"name":"Data.Monoid.Endo","comments":null,"declarations":[{"children":[{"comments":null,"title":"Endo","info":{"arguments":[{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"c"},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqEndo","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"c"},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Endo"],"Endo"]},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Endo.purs","end":[17,62]}},{"comments":null,"title":"ordEndo","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"c"},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Endo"],"Endo"]},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Endo.purs","end":[19,65]}},{"comments":null,"title":"boundedEndo","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"c"},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Endo"],"Endo"]},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Endo.purs","end":[21,77]}},{"comments":null,"title":"showEndo","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"c"},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Endo"],"Endo"]},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Endo.purs","end":[24,44]}},{"comments":null,"title":"semigroupEndo","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Control","Semigroupoid"],"Semigroupoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"c"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Endo"],"Endo"]},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Endo.purs","end":[27,44]}},{"comments":null,"title":"monoidEndo","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Control","Category"],"Category"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"c"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Endo"],"Endo"]},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Endo.purs","end":[30,25]}}],"comments":null,"title":"Endo","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["c",null],["a",null]]},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Endo.purs","end":[15,32]}}]},{"reExports":[],"name":"Data.Monoid.Generic","comments":null,"declarations":[{"children":[{"comments":null,"title":"genericMempty'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[11,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Generic.purs","end":[11,22]}},{"comments":null,"title":"genericMonoidNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Generic"],"GenericMonoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Generic.purs","end":[14,31]}},{"comments":null,"title":"genericMonoidProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Monoid","Generic"],"GenericMonoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Monoid","Generic"],"GenericMonoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Generic"],"GenericMonoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Generic.purs","end":[17,57]}},{"comments":null,"title":"genericMonoidConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Monoid","Generic"],"GenericMonoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Generic"],"GenericMonoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Generic.purs","end":[20,46]}},{"comments":null,"title":"genericMonoidArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"Monoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Generic"],"GenericMonoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Generic.purs","end":[23,35]}}],"comments":null,"title":"GenericMonoid","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[10,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Generic.purs","end":[11,22]}},{"children":[],"comments":"A `Generic` implementation of the `mempty` member from the `Monoid` type class.\n","title":"genericMempty","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Monoid","Generic"],"GenericMonoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Generic.purs","end":[26,71]}}]},{"reExports":[],"name":"Data.Monoid.Multiplicative","comments":null,"declarations":[{"children":[{"comments":null,"title":"Multiplicative","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqMultiplicative","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[16,74]}},{"comments":null,"title":"eq1Multiplicative","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]}]}},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[17,56]}},{"comments":null,"title":"ordMultiplicative","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[19,77]}},{"comments":null,"title":"ord1Multiplicative","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[20,58]}},{"comments":null,"title":"boundedMultiplicative","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[22,89]}},{"comments":null,"title":"showMultiplicative","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[25,64]}},{"comments":null,"title":"functorMultiplicative","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[27,64]}},{"comments":null,"title":"applyMultiplicative","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[30,69]}},{"comments":null,"title":"applicativeMultiplicative","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]}]}},"sourceSpan":{"start":[32,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[33,24]}},{"comments":null,"title":"bindMultiplicative","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]}]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[36,34]}},{"comments":null,"title":"monadMultiplicative","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]}]}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[38,53]}},{"comments":null,"title":"semigroupMultiplicative","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[41,72]}},{"comments":null,"title":"monoidMultiplicative","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid","Multiplicative"],"Multiplicative"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[44,30]}}],"comments":"Monoid and semigroup for semirings under multiplication.\n\n``` purescript\nMultiplicative x <> Multiplicative y == Multiplicative (x * y)\n(mempty :: Multiplicative _) == Multiplicative one\n```\n","title":"Multiplicative","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["a",null]]},"sourceSpan":{"start":[14,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid/Multiplicative.purs","end":[14,44]}}]},{"reExports":[],"name":"Data.NaturalTransformation","comments":null,"declarations":[{"children":[],"comments":null,"title":"NaturalTransformation","info":{"arguments":[["f",null],["g",null]],"declType":"typeSynonym","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"g"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]}},"sourceSpan":{"start":[18,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/NaturalTransformation.purs","end":[18,54]}},{"children":[],"comments":null,"title":"type (~>)","info":{"declType":"alias","alias":[["Data","NaturalTransformation"],{"Left":"NaturalTransformation"}],"fixity":{"associativity":"infixr","precedence":4}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/NaturalTransformation.purs","end":[20,42]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","Ordering"]},"declarations":[{"children":[{"comments":null,"title":"LT","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"GT","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"EQ","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[19,19]}},{"comments":null,"title":"semigroupOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[24,18]}},{"comments":null,"title":"showOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[29,17]}}],"comments":"The `Ordering` data type represents the three possible outcomes of\ncomparing two values:\n\n`LT` - The first value is _less than_ the second.\n`GT` - The first value is _greater than_ the second.\n`EQ` - The first value is _equal to_ the second.\n","title":"Ordering","info":{"declType":"data","dataDeclType":"data","typeArguments":[]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[13,29]}}]}],"name":"Data.Ord","comments":null,"declarations":[{"children":[{"comments":null,"title":"compare","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}]}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[38,32]}},{"comments":null,"title":"ordBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[41,36]}},{"comments":null,"title":"ordInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[44,32]}},{"comments":null,"title":"ordNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[47,35]}},{"comments":null,"title":"ordString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[50,35]}},{"comments":null,"title":"ordChar","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Char"]}]}},"sourceSpan":{"start":[52,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[53,33]}},{"comments":null,"title":"ordUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[56,19]}},{"comments":null,"title":"ordVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[59,19]}},{"comments":null,"title":"ordProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[62,19]}},{"comments":null,"title":"ordProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[64,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[65,19]}},{"comments":null,"title":"ordProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[68,19]}},{"comments":null,"title":"ordArray","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[70,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[77,17]}},{"comments":null,"title":"ordOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[121,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[128,21]}},{"comments":null,"title":"ordRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ord"],"OrdRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[249,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[254,48]}}],"comments":"The `Ord` type class represents types which support comparisons with a\n_total order_.\n\n`Ord` instances should satisfy the laws of total orderings:\n\n- Reflexivity: `a <= a`\n- Antisymmetry: if `a <= b` and `b <= a` then `a = b`\n- Transitivity: if `a <= b` and `b <= c` then `a <= c`\n","title":"Ord","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[38,32]}},{"children":[{"comments":null,"title":"compare1","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}]}]},null]}},"sourceSpan":{"start":[221,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[221,56]}},{"comments":null,"title":"ord1Array","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[223,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[224,21]}}],"comments":"The `Ord1` type class represents totally ordered type constructors.\n","title":"Ord1","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq1"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[220,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[221,56]}},{"children":[],"comments":"Test whether one value is _strictly less than_ another.\n","title":"lessThan","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]},null]}},"sourceSpan":{"start":[131,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[131,49]}},{"children":[],"comments":null,"title":"(<)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"lessThan"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[154,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[154,23]}},{"children":[],"comments":"Test whether one value is _non-strictly less than_ another.\n","title":"lessThanOrEq","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]},null]}},"sourceSpan":{"start":[143,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[143,53]}},{"children":[],"comments":null,"title":"(<=)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"lessThanOrEq"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[155,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[155,28]}},{"children":[],"comments":"Test whether one value is _strictly greater than_ another.\n","title":"greaterThan","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]},null]}},"sourceSpan":{"start":[137,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[137,52]}},{"children":[],"comments":null,"title":"(>)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"greaterThan"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[156,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[156,26]}},{"children":[],"comments":"Test whether one value is _non-strictly greater than_ another.\n","title":"greaterThanOrEq","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]},null]}},"sourceSpan":{"start":[149,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[149,56]}},{"children":[],"comments":null,"title":"(>=)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"greaterThanOrEq"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[157,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[157,31]}},{"children":[],"comments":"Compares two values by mapping them to a type with an `Ord` instance.\n","title":"comparing","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}]}}]}]},null]},null]}},"sourceSpan":{"start":[160,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[160,67]}},{"children":[],"comments":"Take the minimum of two values. If they are considered equal, the first\nargument is chosen.\n","title":"min","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]}},"sourceSpan":{"start":[165,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[165,38]}},{"children":[],"comments":"Take the maximum of two values. If they are considered equal, the first\nargument is chosen.\n","title":"max","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]}},"sourceSpan":{"start":[174,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[174,38]}},{"children":[],"comments":"Clamp a value between a minimum and a maximum. For example:\n\n``` purescript\nlet f = clamp 0 10\nf (-5) == 0\nf 5 == 5\nf 15 == 10\n```\n","title":"clamp","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]}},"sourceSpan":{"start":[189,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[189,45]}},{"children":[],"comments":"Test whether a value is between a minimum and a maximum (inclusive).\nFor example:\n\n``` purescript\nlet f = between 0 10\nf 0 == true\nf (-5) == false\nf 5 == true\nf 10 == true\nf 15 == false\n```\n","title":"between","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]}]},null]}},"sourceSpan":{"start":[203,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[203,53]}},{"children":[],"comments":"The absolute value function. `abs x` is defined as `if x >= zero then x\nelse negate x`.\n","title":"abs","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]}},"sourceSpan":{"start":[211,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[211,43]}},{"children":[],"comments":"The sign function; always evaluates to either `one` or `negate one`. For\nany `x`, we should have `signum x * abs x == x`.\n","title":"signum","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]}},"sourceSpan":{"start":[216,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[216,46]}},{"children":[{"comments":null,"title":"compareRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}]}]},null]}},"sourceSpan":{"start":[228,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[228,91]}},{"comments":null,"title":"ordRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"OrdRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}},"sourceSpan":{"start":[230,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[231,27]}},{"comments":null,"title":"ordRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"OrdRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"rowTail"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"OrdRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}},"sourceSpan":{"start":[233,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[247,59]}}],"comments":null,"title":"OrdRecord","info":{"fundeps":[],"arguments":[["rowlist",null],["row",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"EqRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlist"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[227,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[228,91]}}]},{"reExports":[],"name":"Data.Ord.Generic","comments":null,"declarations":[{"children":[{"comments":null,"title":"genericCompare'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}]}},"sourceSpan":{"start":[11,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord/Generic.purs","end":[11,40]}},{"comments":null,"title":"genericOrdNoConstructors","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord","Generic"],"GenericOrd"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoConstructors"]}]}},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord/Generic.purs","end":[14,27]}},{"comments":null,"title":"genericOrdNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord","Generic"],"GenericOrd"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord/Generic.purs","end":[17,27]}},{"comments":null,"title":"genericOrdSum","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord","Generic"],"GenericOrd"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ord","Generic"],"GenericOrd"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord","Generic"],"GenericOrd"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Sum"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord/Generic.purs","end":[23,39]}},{"comments":null,"title":"genericOrdProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord","Generic"],"GenericOrd"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ord","Generic"],"GenericOrd"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord","Generic"],"GenericOrd"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord/Generic.purs","end":[29,21]}},{"comments":null,"title":"genericOrdConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord","Generic"],"GenericOrd"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord","Generic"],"GenericOrd"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord/Generic.purs","end":[32,76]}},{"comments":null,"title":"genericOrdArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord","Generic"],"GenericOrd"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord/Generic.purs","end":[35,62]}}],"comments":null,"title":"GenericOrd","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[10,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord/Generic.purs","end":[11,40]}},{"children":[],"comments":"A `Generic` implementation of the `compare` member from the `Ord` type class.\n","title":"genericCompare","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord","Generic"],"GenericOrd"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}]}]}]},null]},null]}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord/Generic.purs","end":[38,86]}}]},{"reExports":[],"name":"Data.Ordering","comments":null,"declarations":[{"children":[{"comments":null,"title":"LT","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"GT","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"EQ","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[19,19]}},{"comments":null,"title":"semigroupOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[24,18]}},{"comments":null,"title":"showOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[29,17]}}],"comments":"The `Ordering` data type represents the three possible outcomes of\ncomparing two values:\n\n`LT` - The first value is _less than_ the second.\n`GT` - The first value is _greater than_ the second.\n`EQ` - The first value is _equal to_ the second.\n","title":"Ordering","info":{"declType":"data","dataDeclType":"data","typeArguments":[]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[13,29]}},{"children":[],"comments":"Reverses an `Ordering` value, flipping greater than for less than while\npreserving equality.\n","title":"invert","info":{"declType":"value","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[33,31]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Data","Semiring"]},"declarations":[{"children":[{"comments":null,"title":"add","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[35,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[35,22]}},{"comments":null,"title":"zero","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[36,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[36,12]}},{"comments":null,"title":"mul","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[37,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[37,22]}},{"comments":null,"title":"one","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"comments":null,"title":"semiringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[47,10]}},{"comments":null,"title":"semiringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[53,12]}},{"comments":null,"title":"semiringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[59,18]}},{"comments":null,"title":"semiringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[65,13]}},{"comments":null,"title":"semiringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[71,15]}},{"comments":null,"title":"semiringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[77,16]}},{"comments":null,"title":"semiringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[79,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[83,16]}},{"comments":null,"title":"semiringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[85,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[89,63]}}],"comments":"The `Semiring` class is for types that support an addition and\nmultiplication operation.\n\nInstances must satisfy the following laws:\n\n- Commutative monoid under addition:\n - Associativity: `(a + b) + c = a + (b + c)`\n - Identity: `zero + a = a + zero = a`\n - Commutative: `a + b = b + a`\n- Monoid under multiplication:\n - Associativity: `(a * b) * c = a * (b * c)`\n - Identity: `one * a = a * one = a`\n- Multiplication distributes over addition:\n - Left distributivity: `a * (b + c) = (a * b) + (a * c)`\n - Right distributivity: `(a + b) * c = (a * c) + (b * c)`\n- Annihilation: `zero * a = a * zero = zero`\n\n**Note:** The `Number` and `Int` types are not fully law abiding\nmembers of this class hierarchy due to the potential for arithmetic\noverflows, and in the case of `Number`, the presence of `NaN` and\n`Infinity` values. The behaviour is unspecified in these cases.\n","title":"Semiring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"children":[{"comments":null,"title":"semiringRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"SemiringRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[105,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[109,22]}},{"comments":null,"title":"semiringRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"SemiringRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[111,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[142,76]}}],"comments":null,"title":"SemiringRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[99,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[103,86]}},{"children":[],"comments":null,"title":"(+)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"add"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[40,18]}},{"children":[],"comments":null,"title":"(*)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"mul"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[41,18]}}]}],"name":"Data.Ring","comments":null,"declarations":[{"children":[{"comments":null,"title":"sub","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[24,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"comments":null,"title":"ringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[29,15]}},{"comments":null,"title":"ringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[32,15]}},{"comments":null,"title":"ringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[35,17]}},{"comments":null,"title":"ringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[38,24]}},{"comments":null,"title":"ringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[41,18]}},{"comments":null,"title":"ringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[44,19]}},{"comments":null,"title":"ringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[47,19]}},{"comments":null,"title":"ringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"RingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[50,40]}}],"comments":"The `Ring` class is for types that support addition, multiplication,\nand subtraction operations.\n\nInstances must satisfy the following laws in addition to the `Semiring`\nlaws:\n\n- Additive inverse: `a - a = zero`\n- Compatibility of `sub` and `negate`: `a - b = a + (zero - b)`\n","title":"Ring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"children":[],"comments":"`negate x` can be used as a shorthand for `zero - x`.\n","title":"negate","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[53,37]}},{"children":[],"comments":null,"title":"(-)","info":{"declType":"alias","alias":[["Data","Ring"],{"Right":{"Left":{"Ident":"sub"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[26,18]}},{"children":[{"comments":null,"title":"subRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]}]},null]}},"sourceSpan":{"start":[63,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[63,92]}},{"comments":null,"title":"ringRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"RingRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[66,23]}},{"comments":null,"title":"ringRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"RingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"RingRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[68,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[80,58]}}],"comments":null,"title":"RingRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlist"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[62,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[63,92]}}]},{"reExports":[],"name":"Data.Ring.Generic","comments":null,"declarations":[{"children":[{"comments":null,"title":"genericSub'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[8,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring/Generic.purs","end":[8,29]}},{"comments":null,"title":"genericRingNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring","Generic"],"GenericRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[10,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring/Generic.purs","end":[11,32]}},{"comments":null,"title":"genericRingArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring","Generic"],"GenericRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring/Generic.purs","end":[14,61]}},{"comments":null,"title":"genericRingProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ring","Generic"],"GenericRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring","Generic"],"GenericRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring","Generic"],"GenericRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring/Generic.purs","end":[17,96]}},{"comments":null,"title":"genericRingConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ring","Generic"],"GenericRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring","Generic"],"GenericRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring/Generic.purs","end":[20,82]}}],"comments":null,"title":"GenericRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[7,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring/Generic.purs","end":[8,29]}},{"children":[],"comments":"A `Generic` implementation of the `sub` member from the `Ring` type class.\n","title":"genericSub","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ring","Generic"],"GenericRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]},null]}},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring/Generic.purs","end":[23,76]}}]},{"reExports":[],"name":"Data.Semigroup","comments":null,"declarations":[{"children":[{"comments":null,"title":"append","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[32,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[32,24]}},{"comments":null,"title":"semigroupString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[37,24]}},{"comments":null,"title":"semigroupUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[40,20]}},{"comments":null,"title":"semigroupVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[43,20]}},{"comments":null,"title":"semigroupFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"Semigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"s'"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"s"}]},{"annotation":[],"tag":"TypeVar","contents":"s'"}]}]}},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[46,28]}},{"comments":null,"title":"semigroupArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[49,23]}},{"comments":null,"title":"semigroupProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[51,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[52,21]}},{"comments":null,"title":"semigroupProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[54,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[55,22]}},{"comments":null,"title":"semigroupProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[58,22]}},{"comments":null,"title":"semigroupRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"SemigroupRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[60,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[61,46]}}],"comments":"The `Semigroup` type class identifies an associative operation on a type.\n\nInstances are required to satisfy the following law:\n\n- Associativity: `(x <> y) <> z = x <> (y <> z)`\n\nOne example of a `Semigroup` is `String`, with `(<>)` defined as string\nconcatenation. Another example is `List a`, with `(<>)` defined as\nlist concatenation.\n\n### Newtypes for Semigroup\n\nThere are two other ways to implement an instance for this type class\nregardless of which type is used. These instances can be used by\nwrapping the values in one of the two newtypes below:\n1. `First` - Use the first argument every time: `append first _ = first`.\n2. `Last` - Use the last argument every time: `append _ last = last`.\n","title":"Semigroup","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[32,24]}},{"children":[],"comments":null,"title":"(<>)","info":{"declType":"alias","alias":[["Data","Semigroup"],{"Right":{"Left":{"Ident":"append"}}}],"fixity":{"associativity":"infixr","precedence":5}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[34,22]}},{"children":[{"comments":null,"title":"appendRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]}]},null]}},"sourceSpan":{"start":[70,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[70,95]}},{"comments":null,"title":"semigroupRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"SemigroupRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[72,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[73,26]}},{"comments":null,"title":"semigroupRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"SemigroupRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"Semigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"SemigroupRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[75,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[87,61]}}],"comments":null,"title":"SemigroupRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[69,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[70,95]}}]},{"reExports":[],"name":"Data.Semigroup.First","comments":null,"declarations":[{"children":[{"comments":null,"title":"First","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqFirst","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[15,56]}},{"comments":null,"title":"eq1First","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[16,38]}},{"comments":null,"title":"ordFirst","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[18,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[18,59]}},{"comments":null,"title":"ord1First","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[19,40]}},{"comments":null,"title":"boundedFirst","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[21,71]}},{"comments":null,"title":"showFirst","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[24,46]}},{"comments":null,"title":"functorFirst","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[26,46]}},{"comments":null,"title":"applyFirst","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[29,42]}},{"comments":null,"title":"applicativeFirst","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[32,15]}},{"comments":null,"title":"bindFirst","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[35,25]}},{"comments":null,"title":"monadFirst","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[37,35]}},{"comments":null,"title":"semigroupFirst","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","First"],"First"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[40,17]}}],"comments":"Semigroup where `append` always takes the first option.\n\n``` purescript\nFirst x <> First y == First x\n```\n","title":"First","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["a",null]]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/First.purs","end":[13,26]}}]},{"reExports":[],"name":"Data.Semigroup.Generic","comments":null,"declarations":[{"children":[{"comments":null,"title":"genericAppend'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[11,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Generic.purs","end":[11,32]}},{"comments":null,"title":"genericSemigroupNoConstructors","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Generic"],"GenericSemigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoConstructors"]}]}},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Generic.purs","end":[14,25]}},{"comments":null,"title":"genericSemigroupNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Generic"],"GenericSemigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Generic.purs","end":[17,25]}},{"comments":null,"title":"genericSemigroupProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup","Generic"],"GenericSemigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semigroup","Generic"],"GenericSemigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Generic"],"GenericSemigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Generic.purs","end":[21,58]}},{"comments":null,"title":"genericSemigroupConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup","Generic"],"GenericSemigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Generic"],"GenericSemigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Generic.purs","end":[24,88]}},{"comments":null,"title":"genericSemigroupArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"Semigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Generic"],"GenericSemigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Generic.purs","end":[27,71]}}],"comments":null,"title":"GenericSemigroup","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[10,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Generic.purs","end":[11,32]}},{"children":[],"comments":"A `Generic` implementation of the `append` member from the `Semigroup` type class.\n","title":"genericAppend","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup","Generic"],"GenericSemigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]},null]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Generic.purs","end":[30,84]}}]},{"reExports":[],"name":"Data.Semigroup.Last","comments":null,"declarations":[{"children":[{"comments":null,"title":"Last","info":{"arguments":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqLast","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[15,54]}},{"comments":null,"title":"eq1Last","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[16,36]}},{"comments":null,"title":"ordLast","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[18,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[18,57]}},{"comments":null,"title":"ord1Last","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord1"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[19,38]}},{"comments":null,"title":"boundedLast","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"Bounded"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[21,69]}},{"comments":null,"title":"showLast","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[24,44]}},{"comments":null,"title":"functorLast","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[26,44]}},{"comments":null,"title":"applyLast","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[29,39]}},{"comments":null,"title":"applicativeLast","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[32,14]}},{"comments":null,"title":"bindLast","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[35,24]}},{"comments":null,"title":"monadLast","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[37,33]}},{"comments":null,"title":"semigroupLast","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup","Last"],"Last"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[40,17]}}],"comments":"Semigroup where `append` always takes the second option.\n\n``` purescript\nLast x <> Last y == Last y\n```\n","title":"Last","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[["a",null]]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup/Last.purs","end":[13,24]}}]},{"reExports":[],"name":"Data.Semiring","comments":null,"declarations":[{"children":[{"comments":null,"title":"add","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[35,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[35,22]}},{"comments":null,"title":"zero","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[36,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[36,12]}},{"comments":null,"title":"mul","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[37,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[37,22]}},{"comments":null,"title":"one","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"comments":null,"title":"semiringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[47,10]}},{"comments":null,"title":"semiringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[53,12]}},{"comments":null,"title":"semiringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[59,18]}},{"comments":null,"title":"semiringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[65,13]}},{"comments":null,"title":"semiringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[71,15]}},{"comments":null,"title":"semiringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[77,16]}},{"comments":null,"title":"semiringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[79,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[83,16]}},{"comments":null,"title":"semiringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[85,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[89,63]}}],"comments":"The `Semiring` class is for types that support an addition and\nmultiplication operation.\n\nInstances must satisfy the following laws:\n\n- Commutative monoid under addition:\n - Associativity: `(a + b) + c = a + (b + c)`\n - Identity: `zero + a = a + zero = a`\n - Commutative: `a + b = b + a`\n- Monoid under multiplication:\n - Associativity: `(a * b) * c = a * (b * c)`\n - Identity: `one * a = a * one = a`\n- Multiplication distributes over addition:\n - Left distributivity: `a * (b + c) = (a * b) + (a * c)`\n - Right distributivity: `(a + b) * c = (a * c) + (b * c)`\n- Annihilation: `zero * a = a * zero = zero`\n\n**Note:** The `Number` and `Int` types are not fully law abiding\nmembers of this class hierarchy due to the potential for arithmetic\noverflows, and in the case of `Number`, the presence of `NaN` and\n`Infinity` values. The behaviour is unspecified in these cases.\n","title":"Semiring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"children":[],"comments":null,"title":"(+)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"add"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[40,18]}},{"children":[],"comments":null,"title":"(*)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"mul"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[41,18]}},{"children":[{"comments":null,"title":"addRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]}]},null]}},"sourceSpan":{"start":[100,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[100,92]}},{"comments":null,"title":"mulRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]}]},null]}},"sourceSpan":{"start":[101,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[101,92]}},{"comments":null,"title":"oneRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"ForAll","contents":["rproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rproxy"},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]},null]},null]}},"sourceSpan":{"start":[102,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[102,85]}},{"comments":null,"title":"zeroRecord","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"ForAll","contents":["rproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rproxy"},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}]}]},null]},null]}},"sourceSpan":{"start":[103,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[103,86]}},{"comments":null,"title":"semiringRecordNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"SemiringRecord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"REmpty"}]}},"sourceSpan":{"start":[105,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[109,22]}},{"comments":null,"title":"semiringRecordCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Prim","Row"],"Cons"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"},{"annotation":[],"tag":"TypeVar","contents":"focus"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"},{"annotation":[],"tag":"TypeVar","contents":"subrow"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"subrowTail"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"SemiringRecord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]},{"annotation":[],"tag":"TypeVar","contents":"subrow"}]}},"sourceSpan":{"start":[111,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[142,76]}}],"comments":null,"title":"SemiringRecord","info":{"fundeps":[[["rowlist"],["subrow"]]],"arguments":[["rowlist",null],["row",null],["subrow",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[99,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[103,86]}}]},{"reExports":[],"name":"Data.Semiring.Generic","comments":null,"declarations":[{"children":[{"comments":null,"title":"genericAdd'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[8,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[8,30]}},{"comments":null,"title":"genericZero'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[9,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[9,20]}},{"comments":null,"title":"genericMul'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[10,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[10,30]}},{"comments":null,"title":"genericOne'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[11,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[11,20]}},{"comments":null,"title":"genericSemiringNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring","Generic"],"GenericSemiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[17,28]}},{"comments":null,"title":"genericSemiringArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring","Generic"],"GenericSemiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[23,29]}},{"comments":null,"title":"genericSemiringProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring","Generic"],"GenericSemiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring","Generic"],"GenericSemiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring","Generic"],"GenericSemiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[29,48]}},{"comments":null,"title":"genericSemiringConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring","Generic"],"GenericSemiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring","Generic"],"GenericSemiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[35,40]}}],"comments":null,"title":"GenericSemiring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[7,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[11,20]}},{"children":[],"comments":"A `Generic` implementation of the `zero` member from the `Semiring` type class.\n","title":"genericZero","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Semiring","Generic"],"GenericSemiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[38,71]}},{"children":[],"comments":"A `Generic` implementation of the `one` member from the `Semiring` type class.\n","title":"genericOne","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Semiring","Generic"],"GenericSemiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[42,70]}},{"children":[],"comments":"A `Generic` implementation of the `add` member from the `Semiring` type class.\n","title":"genericAdd","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Semiring","Generic"],"GenericSemiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]},null]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[46,80]}},{"children":[],"comments":"A `Generic` implementation of the `mul` member from the `Semiring` type class.\n","title":"genericMul","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Semiring","Generic"],"GenericSemiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]},null]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring/Generic.purs","end":[50,80]}}]},{"reExports":[],"name":"Data.Show","comments":null,"declarations":[{"children":[{"comments":null,"title":"show","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[18,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[18,22]}},{"comments":null,"title":"showBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[22,23]}},{"comments":null,"title":"showInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[25,21]}},{"comments":null,"title":"showNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[28,24]}},{"comments":null,"title":"showChar","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Char"]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[31,22]}},{"comments":null,"title":"showString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[34,24]}},{"comments":null,"title":"showArray","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[37,28]}},{"comments":null,"title":"showProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[40,19]}},{"comments":null,"title":"showProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[43,20]}},{"comments":null,"title":"showProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[46,20]}},{"comments":null,"title":"showRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rs"},{"annotation":[],"tag":"TypeVar","contents":"ls"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Show"],"ShowRecordFields"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"ls"},{"annotation":[],"tag":"TypeVar","contents":"rs"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"rs"}]}]}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[51,52]}}],"comments":"The `Show` type class represents those types which can be converted into\na human-readable `String` representation.\n\nWhile not required, it is recommended that for any expression `x`, the\nstring `show x` be executable PureScript code which evaluates to the same\nvalue as the expression `x`.\n","title":"Show","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[18,22]}},{"children":[{"comments":null,"title":"showRecordFields","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["rlproxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"rlproxy"},{"annotation":[],"tag":"TypeVar","contents":"rowlist"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}]}]},null]}},"sourceSpan":{"start":[57,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[57,84]}},{"comments":null,"title":"showRecordFieldsNil","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"ShowRecordFields"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Nil"]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}},"sourceSpan":{"start":[59,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[60,28]}},{"comments":null,"title":"showRecordFieldsCons","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"key"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Show"],"ShowRecordFields"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"focus"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"ShowRecordFields"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim","RowList"],"Cons"]},{"annotation":[],"tag":"TypeVar","contents":"key"}]},{"annotation":[],"tag":"TypeVar","contents":"focus"}]},{"annotation":[],"tag":"TypeVar","contents":"rowlistTail"}]}]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}},"sourceSpan":{"start":[62,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[73,66]}}],"comments":null,"title":"ShowRecordFields","info":{"fundeps":[],"arguments":[["rowlist",null],["row",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[56,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[57,84]}}]},{"reExports":[],"name":"Data.Show.Generic","comments":null,"declarations":[{"children":[{"comments":null,"title":"genericShow'","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[15,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[15,30]}},{"comments":null,"title":"genericShowNoConstructors","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show","Generic"],"GenericShow"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoConstructors"]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[21,34]}},{"comments":null,"title":"genericShowSum","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show","Generic"],"GenericShow"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Show","Generic"],"GenericShow"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show","Generic"],"GenericShow"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Sum"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[28,40]}},{"comments":null,"title":"genericShowConstructor","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show","Generic"],"GenericShowArgs"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"name"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show","Generic"],"GenericShow"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Constructor"]},{"annotation":[],"tag":"TypeVar","contents":"name"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[44,49]}}],"comments":null,"title":"GenericShow","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[14,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[15,30]}},{"children":[],"comments":"A `Generic` implementation of the `show` member from the `Show` type class.\n","title":"genericShow","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["rep",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Generic","Rep"],"Generic"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Show","Generic"],"GenericShow"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rep"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}]}]},null]},null]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[50,77]}},{"children":[{"comments":null,"title":"genericShowArgs","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}]}},"sourceSpan":{"start":[18,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[18,39]}},{"comments":null,"title":"genericShowArgsNoArguments","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show","Generic"],"GenericShowArgs"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"NoArguments"]}]}},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[24,25]}},{"comments":null,"title":"genericShowArgsProduct","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show","Generic"],"GenericShowArgs"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Show","Generic"],"GenericShowArgs"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show","Generic"],"GenericShowArgs"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Product"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[33,73]}},{"comments":null,"title":"genericShowArgsArgument","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show","Generic"],"GenericShowArgs"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Generic","Rep"],"Argument"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[47,42]}}],"comments":null,"title":"GenericShowArgs","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show/Generic.purs","end":[18,39]}}]},{"reExports":[],"name":"Data.Symbol","comments":null,"declarations":[{"children":[{"comments":null,"title":"reflectSymbol","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["proxy",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"proxy"},{"annotation":[],"tag":"TypeVar","contents":"sym"}]}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]},null]}},"sourceSpan":{"start":[24,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Symbol.purs","end":[24,53]}}],"comments":"A class for known symbols\n","title":"IsSymbol","info":{"fundeps":[],"arguments":[["sym",{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Symbol"]}]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Symbol.purs","end":[24,53]}},{"children":[],"comments":null,"title":"reifySymbol","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["proxy",{"annotation":[],"tag":"ForAll","contents":["r",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"ForAll","contents":["sym",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"sym"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"proxy"},{"annotation":[],"tag":"TypeVar","contents":"sym"}]}]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]},null]}}]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]},null]},null]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Symbol.purs","end":[29,91]}},{"children":[{"comments":null,"title":"SProxy","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null}],"comments":null,"title":"SProxy","info":{"declType":"data","dataDeclType":"data","typeArguments":[["sym",null]]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Symbol.purs","end":[13,25]}}]},{"reExports":[],"name":"Data.Unit","comments":null,"declarations":[{"children":[{"comments":null,"title":"showUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[18,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Unit.purs","end":[19,18]}}],"comments":"The `Unit` type has a single inhabitant, called `unit`. It represents\nvalues with no computational content.\n\n`Unit` is often used, wrapped in a monadic type constructor, as the\nreturn type of a computation where only the _effects_ are important.\n\nWhen returning a value of type `Unit` from an FFI function, it is\nrecommended to use `undefined`, or not return a value at all.\n","title":"Unit","info":{"kind":{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Type"]},"declType":"externData"},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Unit.purs","end":[13,33]}},{"children":[],"comments":"`unit` is the sole inhabitant of the `Unit` type.\n","title":"unit","info":{"declType":"value","type":{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Unit.purs","end":[16,28]}}]},{"reExports":[],"name":"Data.Void","comments":null,"declarations":[{"children":[{"comments":null,"title":"showVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Void.purs","end":[25,16]}}],"comments":"An uninhabited data type. In other words, one can never create\na runtime value of type `Void` becaue no such value exists.\n\n`Void` is useful to eliminate the possibility of a value being created.\nFor example, a value of type `Either Void Boolean` can never have\na Left value created in PureScript.\n\nThis should not be confused with the keyword `void` that commonly appears in\nC-family languages, such as Java:\n```\npublic class Foo {\n void doSomething() { System.out.println(\"hello world!\"); }\n}\n```\n\nIn PureScript, one often uses `Unit` to achieve similar effects as\nthe `void` of C-family languages above.\n","title":"Void","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[]},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Void.purs","end":[22,25]}},{"children":[],"comments":"Eliminator for the `Void` type.\nUseful for stating that some code branch is impossible because you've\n\"acquired\" a value of type `Void` (which you can't).\n\n```purescript\nrightOnly :: forall t . Either Void t -> t\nrightOnly (Left v) = absurd v\nrightOnly (Right t) = t\n```\n","title":"absurd","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},null]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Void.purs","end":[36,30]}}]},{"reExports":[{"moduleName":{"package":null,"item":["Control","Applicative"]},"declarations":[{"children":[{"comments":null,"title":"pure","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]}},"sourceSpan":{"start":[34,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[34,29]}},{"comments":null,"title":"applicativeFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[37,15]}},{"comments":null,"title":"applicativeArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[40,15]}},{"comments":null,"title":"applicativeProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Applicative"],"Applicative"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[43,17]}}],"comments":"The `Applicative` type class extends the [`Apply`](#apply) type class\nwith a `pure` function, which can be used to create values of type `f a`\nfrom values of type `a`.\n\nWhere [`Apply`](#apply) provides the ability to lift functions of two or\nmore arguments to functions whose arguments are wrapped using `f`, and\n[`Functor`](#functor) provides the ability to lift functions of one\nargument, `pure` can be seen as the function which lifts functions of\n_zero_ arguments. That is, `Applicative` functors support a lifting\noperation for any number of function arguments.\n\nInstances must satisfy the following laws in addition to the `Apply`\nlaws:\n\n- Identity: `(pure identity) <*> v = v`\n- Composition: `pure (<<<) <*> f <*> g <*> h = f <*> (g <*> h)`\n- Homomorphism: `(pure f) <*> (pure x) = pure (f x)`\n- Interchange: `u <*> (pure y) = (pure (_ $ y)) <*> u`\n","title":"Applicative","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[34,29]}},{"children":[],"comments":"Perform an applicative action when a condition is true.\n","title":"when","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[61,63]}},{"children":[],"comments":"Perform an applicative action unless a condition is true.\n","title":"unless","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[66,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[66,65]}},{"children":[],"comments":"`liftA1` provides a default implementation of `(<$>)` for any\n[`Applicative`](#applicative) functor, without using `(<$>)` as provided\nby the [`Functor`](#functor)-[`Applicative`](#applicative) superclass\nrelationship.\n\n`liftA1` can therefore be used to write [`Functor`](#functor) instances\nas follows:\n\n```purescript\ninstance functorF :: Functor F where\n map = liftA1\n```\n","title":"liftA1","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Applicative.purs","end":[57,64]}}]},{"moduleName":{"package":null,"item":["Control","Apply"]},"declarations":[{"children":[{"comments":null,"title":"apply","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[46,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"comments":null,"title":"applyFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[51,26]}},{"comments":null,"title":"applyArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[54,21]}},{"comments":null,"title":"applyProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Apply"],"Apply"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[59,20]}}],"comments":"The `Apply` class provides the `(<*>)` which is used to apply a function\nto an argument under a type constructor.\n\n`Apply` can be used to lift functions of two or more arguments to work on\nvalues wrapped with the type constructor `f`. It might also be understood\nin terms of the `lift2` function:\n\n```purescript\nlift2 :: forall f a b c. Apply f => (a -> b -> c) -> f a -> f b -> f c\nlift2 f a b = f <$> a <*> b\n```\n\n`(<*>)` is recovered from `lift2` as `lift2 ($)`. That is, `(<*>)` lifts\nthe function application operator `($)` to arguments wrapped with the\ntype constructor `f`.\n\nPut differently...\n```\nfoo =\n functionTakingNArguments <$> computationProducingArg1\n <*> computationProducingArg2\n <*> ...\n <*> computationProducingArgN\n```\n\nInstances must satisfy the following law in addition to the `Functor`\nlaws:\n\n- Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`\n\nFormally, `Apply` represents a strong lax semi-monoidal endofunctor.\n","title":"Apply","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[46,48]}},{"children":[],"comments":null,"title":"(<*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"apply"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[48,22]}},{"children":[],"comments":null,"title":"(<*)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applyFirst"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[65,26]}},{"children":[],"comments":null,"title":"(*>)","info":{"declType":"alias","alias":[["Control","Apply"],{"Right":{"Left":{"Ident":"applySecond"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Apply.purs","end":[71,27]}}]},{"moduleName":{"package":null,"item":["Control","Bind"]},"declarations":[{"children":[{"comments":null,"title":"bind","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[51,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[51,47]}},{"comments":null,"title":"bindFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[66,25]}},{"comments":"The `bind`/`>>=` function for `Array` works by applying a function to\neach element in the array, and flattening the results into a single,\nnew array.\n\nArray's `bind`/`>>=` works like a nested for loop. Each `bind` adds\nanother level of nesting in the loop. For example:\n```\nfoo :: Array String\nfoo =\n [\"a\", \"b\"] >>= \\eachElementInArray1 ->\n [\"c\", \"d\"] >>= \\eachElementInArray2\n pure (eachElementInArray1 <> eachElementInArray2)\n\n-- In other words...\nfoo\n-- ... is the same as...\n[ (\"a\" <> \"c\"), (\"a\" <> \"d\"), (\"b\" <> \"c\"), (\"b\" <> \"d\") ]\n-- which simplifies to...\n[ \"ac\", \"ad\", \"bc\", \"bd\" ]\n```\n","title":"bindArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[88,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[89,19]}},{"comments":null,"title":"bindProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Bind"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[93,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[94,19]}}],"comments":"The `Bind` type class extends the [`Apply`](#apply) type class with a\n\"bind\" operation `(>>=)` which composes computations in sequence, using\nthe return value of one computation to determine the next computation.\n\nThe `>>=` operator can also be expressed using `do` notation, as follows:\n\n```purescript\nx >>= f = do y <- x\n f y\n```\n\nwhere the function argument of `f` is given the name `y`.\n\nInstances must satisfy the following laws in addition to the `Apply`\nlaws:\n\n- Associativity: `(x >>= f) >>= g = x >>= (\\k -> f k >>= g)`\n- Apply Superclass: `apply f x = f >>= \\f’ -> map f’ x`\n\nAssociativity tells us that we can regroup operations which use `do`\nnotation so that we can unambiguously write, for example:\n\n```purescript\ndo x <- m1\n y <- m2 x\n m3 x y\n```\n","title":"Bind","info":{"fundeps":[],"arguments":[["m",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Apply"],"Apply"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[51,47]}},{"children":[{"comments":null,"title":"discard","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]}},"sourceSpan":{"start":[102,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[102,60]}},{"comments":null,"title":"discardUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Discard"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[104,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[105,17]}},{"comments":null,"title":"discardProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Discard"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[107,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[108,17]}},{"comments":null,"title":"discardProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Discard"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[110,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[111,17]}},{"comments":null,"title":"discardProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Bind"],"Discard"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[113,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[114,17]}}],"comments":"A class for types whose values can safely be discarded\nin a `do` notation block.\n\nAn example is the `Unit` type, since there is only one\npossible value which can be returned.\n","title":"Discard","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[101,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[102,60]}},{"children":[],"comments":"Collapse two applications of a monadic type constructor into one.\n","title":"join","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]},null]}},"sourceSpan":{"start":[117,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[117,45]}},{"children":[],"comments":"Execute a monadic action if a condition holds.\n\nFor example:\n\n```purescript\nmain = ifM ((< 0.5) <$> random)\n (trace \"Heads\")\n (trace \"Tails\")\n```\n","title":"ifM","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]}]},null]},null]}},"sourceSpan":{"start":[149,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[149,60]}},{"children":[],"comments":null,"title":"(>>=)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"bind"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[53,21]}},{"children":[],"comments":null,"title":"(>=>)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"composeKleisli"}}}],"fixity":{"associativity":"infixr","precedence":1}},"sourceSpan":{"start":[132,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[132,31]}},{"children":[],"comments":null,"title":"(=<<)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"bindFlipped"}}}],"fixity":{"associativity":"infixr","precedence":1}},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[63,28]}},{"children":[],"comments":null,"title":"(<=<)","info":{"declType":"alias","alias":[["Control","Bind"],{"Right":{"Left":{"Ident":"composeKleisliFlipped"}}}],"fixity":{"associativity":"infixr","precedence":1}},"sourceSpan":{"start":[138,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Bind.purs","end":[138,38]}}]},{"moduleName":{"package":null,"item":["Control","Category"]},"declarations":[{"children":[{"comments":null,"title":"identity","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["t",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"t"}]},{"annotation":[],"tag":"TypeVar","contents":"t"}]},null]}},"sourceSpan":{"start":[18,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Category.purs","end":[18,30]}},{"comments":null,"title":"categoryFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Category"],"Category"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Category.purs","end":[21,17]}}],"comments":null,"title":"Category","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Semigroupoid"],"Semigroupoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Category.purs","end":[18,30]}}]},{"moduleName":{"package":null,"item":["Control","Monad"]},"declarations":[{"children":[{"comments":null,"title":"monadFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[33,35]}},{"comments":null,"title":"monadArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[35,35]}},{"comments":null,"title":"monadProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Monad"],"Monad"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[37,35]}}],"comments":"The `Monad` type class combines the operations of the `Bind` and\n`Applicative` type classes. Therefore, `Monad` instances represent type\nconstructors which support sequential composition, and also lifting of\nfunctions of arbitrary arity.\n\nInstances must satisfy the following laws in addition to the\n`Applicative` and `Bind` laws:\n\n- Left Identity: `pure x >>= f = f x`\n- Right Identity: `x >>= pure = x`\n","title":"Monad","info":{"fundeps":[],"arguments":[["m",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Control","Applicative"],"Applicative"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Control","Bind"],"Bind"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[31,41]}},{"children":[],"comments":"Perform a monadic action when a condition is true, where the conditional\nvalue is also in a monadic context.\n","title":"whenM","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Monad"],"Monad"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[57,60]}},{"children":[],"comments":"Perform a monadic action unless a condition is true, where the conditional\nvalue is also in a monadic context.\n","title":"unlessM","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Monad"],"Monad"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]}]},null]}},"sourceSpan":{"start":[64,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[64,62]}},{"children":[],"comments":"`liftM1` provides a default implementation of `(<$>)` for any\n[`Monad`](#monad), without using `(<$>)` as provided by the\n[`Functor`](#functor)-[`Monad`](#monad) superclass relationship.\n\n`liftM1` can therefore be used to write [`Functor`](#functor) instances\nas follows:\n\n```purescript\ninstance functorF :: Functor F where\n map = liftM1\n```\n","title":"liftM1","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Monad"],"Monad"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[50,58]}},{"children":[],"comments":"`ap` provides a default implementation of `(<*>)` for any `Monad`, without\nusing `(<*>)` as provided by the `Apply`-`Monad` superclass relationship.\n\n`ap` can therefore be used to write `Apply` instances as follows:\n\n```purescript\ninstance applyF :: Apply F where\n apply = ap\n```\n","title":"ap","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["m",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Control","Monad"],"Monad"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"m"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[82,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Monad.purs","end":[82,56]}}]},{"moduleName":{"package":null,"item":["Control","Semigroupoid"]},"declarations":[{"children":[{"comments":null,"title":"compose","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"ForAll","contents":["d",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"c"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"a"},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"d"}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[14,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[14,51]}},{"comments":null,"title":"semigroupoidFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Control","Semigroupoid"],"Semigroupoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]}]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[17,26]}}],"comments":null,"title":"Semigroupoid","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[14,51]}},{"children":[],"comments":null,"title":"(>>>)","info":{"declType":"alias","alias":[["Control","Semigroupoid"],{"Right":{"Left":{"Ident":"composeFlipped"}}}],"fixity":{"associativity":"infixr","precedence":9}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[25,31]}},{"children":[],"comments":null,"title":"(<<<)","info":{"declType":"alias","alias":[["Control","Semigroupoid"],{"Right":{"Left":{"Ident":"compose"}}}],"fixity":{"associativity":"infixr","precedence":9}},"sourceSpan":{"start":[19,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Control/Semigroupoid.purs","end":[19,24]}}]},{"moduleName":{"package":null,"item":["Data","Boolean"]},"declarations":[{"children":[],"comments":"An alias for `true`, which can be useful in guard clauses:\n\n```purescript\nmax x y | x >= y = x\n | otherwise = y\n```\n","title":"otherwise","info":{"declType":"value","type":{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}},"sourceSpan":{"start":[9,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Boolean.purs","end":[9,21]}}]},{"moduleName":{"package":null,"item":["Data","BooleanAlgebra"]},"declarations":[{"children":[{"comments":null,"title":"booleanAlgebraBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[24,57]}},{"comments":null,"title":"booleanAlgebraUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[25,51]}},{"comments":null,"title":"booleanAlgebraFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","BooleanAlgebra"],"BooleanAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[26,73]}},{"comments":null,"title":"booleanAlgebraRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","BooleanAlgebra"],"BooleanAlgebraRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[27,123]}},{"comments":null,"title":"booleanAlgebraProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[28,57]}},{"comments":null,"title":"booleanAlgebraProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[29,59]}},{"comments":null,"title":"booleanAlgebraProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","BooleanAlgebra"],"BooleanAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[30,59]}}],"comments":"The `BooleanAlgebra` type class represents types that behave like boolean\nvalues.\n\nInstances should satisfy the following laws in addition to the\n`HeytingAlgebra` law:\n\n- Excluded middle:\n - `a || not a = tt`\n","title":"BooleanAlgebra","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/BooleanAlgebra.purs","end":[22,43]}}]},{"moduleName":{"package":null,"item":["Data","Bounded"]},"declarations":[{"children":[{"comments":null,"title":"top","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[24,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[24,11]}},{"comments":null,"title":"bottom","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[25,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[25,14]}},{"comments":null,"title":"boundedBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[29,17]}},{"comments":"The `Bounded` `Int` instance has `top :: Int` equal to 2^31 - 1,\nand `bottom :: Int` equal to -2^31, since these are the largest and smallest\nintegers representable by twos-complement 32-bit integers, respectively.\n","title":"boundedInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[36,21]}},{"comments":"Characters fall within the Unicode range.\n","title":"boundedChar","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Char"]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[44,22]}},{"comments":null,"title":"boundedOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[51,14]}},{"comments":null,"title":"boundedUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[55,16]}},{"comments":null,"title":"boundedNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[60,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[62,24]}},{"comments":null,"title":"boundedProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[64,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[66,14]}},{"comments":null,"title":"boundedProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[68,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[70,15]}},{"comments":null,"title":"boundedProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[72,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[74,15]}},{"comments":null,"title":"boundedRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Bounded"],"BoundedRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Bounded"],"Bounded"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[107,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[113,67]}}],"comments":"The `Bounded` type class represents totally ordered types that have an\nupper and lower boundary.\n\nInstances should satisfy the following law in addition to the `Ord` laws:\n\n- Bounded: `bottom <= a <= top`\n","title":"Bounded","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Bounded.purs","end":[25,14]}}]},{"moduleName":{"package":null,"item":["Data","CommutativeRing"]},"declarations":[{"children":[{"comments":null,"title":"commutativeRingInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[25,51]}},{"comments":null,"title":"commutativeRingNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[26,57]}},{"comments":null,"title":"commutativeRingUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[27,53]}},{"comments":null,"title":"commutativeRingFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[28,76]}},{"comments":null,"title":"commutativeRingRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[29,126]}},{"comments":null,"title":"commutativeRingProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[30,59]}},{"comments":null,"title":"commutativeRingProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[31,61]}},{"comments":null,"title":"commutativeRingProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","CommutativeRing"],"CommutativeRing"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[32,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[32,61]}}],"comments":"The `CommutativeRing` class is for rings where multiplication is\ncommutative.\n\nInstances must satisfy the following law in addition to the `Ring`\nlaws:\n\n- Commutative multiplication: `a * b = b * a`\n","title":"CommutativeRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/CommutativeRing.purs","end":[23,34]}}]},{"moduleName":{"package":null,"item":["Data","DivisionRing"]},"declarations":[{"children":[{"comments":null,"title":"recip","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[30,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[30,18]}},{"comments":null,"title":"divisionringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","DivisionRing"],"DivisionRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[54,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[55,20]}}],"comments":"The `DivisionRing` class is for non-zero rings in which every non-zero\nelement has a multiplicative inverse. Division rings are sometimes also\ncalled *skew fields*.\n\nInstances must satisfy the following laws in addition to the `Ring` laws:\n\n- Non-zero ring: `one /= zero`\n- Non-zero multiplicative inverse: `recip a * a = a * recip a = one` for\n all non-zero `a`\n\nThe result of `recip zero` is left undefined; individual instances may\nchoose how to handle this case.\n\nIf a type has both `DivisionRing` and `CommutativeRing` instances, then\nit is a field and should have a `Field` instance.\n","title":"DivisionRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[29,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/DivisionRing.purs","end":[30,18]}}]},{"moduleName":{"package":null,"item":["Data","Eq"]},"declarations":[{"children":[{"comments":null,"title":"eq","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}},"sourceSpan":{"start":[29,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[29,26]}},{"comments":null,"title":"eqBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[41,21]}},{"comments":null,"title":"eqInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[44,17]}},{"comments":null,"title":"eqNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[47,20]}},{"comments":null,"title":"eqChar","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Char"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[50,18]}},{"comments":null,"title":"eqString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[52,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[53,20]}},{"comments":null,"title":"eqUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[56,16]}},{"comments":null,"title":"eqVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[59,16]}},{"comments":null,"title":"eqArray","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[62,22]}},{"comments":null,"title":"eqRec","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Eq"],"EqRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[64,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[65,38]}},{"comments":null,"title":"eqProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[68,16]}},{"comments":null,"title":"eqProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[70,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[71,16]}},{"comments":null,"title":"eqProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[74,16]}}],"comments":"The `Eq` type class represents types which support decidable equality.\n\n`Eq` instances should satisfy the following laws:\n\n- Reflexivity: `x == x = true`\n- Symmetry: `x == y = y == x`\n- Transitivity: if `x == y` and `y == z` then `x == z`\n\n**Note:** The `Number` type is not an entirely law abiding member of this\nclass due to the presence of `NaN`, since `NaN /= NaN`. Additionally,\ncomputing with `Number` can result in a loss of precision, so sometimes\nvalues that should be equivalent are not.\n","title":"Eq","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[29,26]}},{"children":[],"comments":"`notEq` tests whether one value is _not equal_ to another. Shorthand for\n`not (eq x y)`.\n","title":"notEq","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]},null]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[35,45]}},{"children":[],"comments":null,"title":"(==)","info":{"declType":"alias","alias":[["Data","Eq"],{"Right":{"Left":{"Ident":"eq"}}}],"fixity":{"associativity":"infix","precedence":4}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[31,17]}},{"children":[],"comments":null,"title":"(/=)","info":{"declType":"alias","alias":[["Data","Eq"],{"Right":{"Left":{"Ident":"notEq"}}}],"fixity":{"associativity":"infix","precedence":4}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Eq.purs","end":[38,20]}}]},{"moduleName":{"package":null,"item":["Data","EuclideanRing"]},"declarations":[{"children":[{"comments":null,"title":"degree","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[64,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[64,21]}},{"comments":null,"title":"div","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[65,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[65,21]}},{"comments":null,"title":"mod","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[66,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[66,21]}},{"comments":null,"title":"euclideanRingInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","EuclideanRing"],"EuclideanRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[70,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[73,15]}},{"comments":null,"title":"euclideanRingNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","EuclideanRing"],"EuclideanRing"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[75,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[78,16]}}],"comments":"The `EuclideanRing` class is for commutative rings that support division.\nThe mathematical structure this class is based on is sometimes also called\na *Euclidean domain*.\n\nInstances must satisfy the following laws in addition to the `Ring`\nlaws:\n\n- Integral domain: `one /= zero`, and if `a` and `b` are both nonzero then\n so is their product `a * b`\n- Euclidean function `degree`:\n - Nonnegativity: For all nonzero `a`, `degree a >= 0`\n - Quotient/remainder: For all `a` and `b`, where `b` is nonzero,\n let `q = a / b` and ``r = a `mod` b``; then `a = q*b + r`, and also\n either `r = zero` or `degree r < degree b`\n- Submultiplicative euclidean function:\n - For all nonzero `a` and `b`, `degree a <= degree (a * b)`\n\nThe behaviour of division by `zero` is unconstrained by these laws,\nmeaning that individual instances are free to choose how to behave in this\ncase. Similarly, there are no restrictions on what the result of\n`degree zero` is; it doesn't make sense to ask for `degree zero` in the\nsame way that it doesn't make sense to divide by `zero`, so again,\nindividual instances may choose how to handle this case.\n\nFor any `EuclideanRing` which is also a `Field`, one valid choice\nfor `degree` is simply `const 1`. In fact, unless there's a specific\nreason not to, `Field` types should normally use this definition of\n`degree`.\n\nThe `EuclideanRing Int` instance is one of the most commonly used\n`EuclideanRing` instances and deserves a little more discussion. In\nparticular, there are a few different sensible law-abiding implementations\nto choose from, with slightly different behaviour in the presence of\nnegative dividends or divisors. The most common definitions are \"truncating\"\ndivision, where the result of `a / b` is rounded towards 0, and \"Knuthian\"\nor \"flooring\" division, where the result of `a / b` is rounded towards\nnegative infinity. A slightly less common, but arguably more useful, option\nis \"Euclidean\" division, which is defined so as to ensure that ``a `mod` b``\nis always nonnegative. With Euclidean division, `a / b` rounds towards\nnegative infinity if the divisor is positive, and towards positive infinity\nif the divisor is negative. Note that all three definitions are identical if\nwe restrict our attention to nonnegative dividends and divisors.\n\nIn versions 1.x, 2.x, and 3.x of the Prelude, the `EuclideanRing Int`\ninstance used truncating division. As of 4.x, the `EuclideanRing Int`\ninstance uses Euclidean division. Additional functions `quot` and `rem` are\nsupplied if truncating division is desired.\n","title":"EuclideanRing","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","CommutativeRing"],"CommutativeRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[66,21]}},{"children":[],"comments":"The *least common multiple* of two values.\n","title":"lcm","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]}},"sourceSpan":{"start":[94,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[94,56]}},{"children":[],"comments":"The *greatest common divisor* of two values.\n","title":"gcd","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]}},"sourceSpan":{"start":[87,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[87,56]}},{"children":[],"comments":null,"title":"(/)","info":{"declType":"alias","alias":[["Data","EuclideanRing"],{"Right":{"Left":{"Ident":"div"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[68,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/EuclideanRing.purs","end":[68,18]}}]},{"moduleName":{"package":null,"item":["Data","Field"]},"declarations":[{"children":[{"comments":null,"title":"field","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","DivisionRing"],"DivisionRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Field"],"Field"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Field.purs","end":[41,63]}}],"comments":"The `Field` class is for types that are (commutative) fields.\n\nMathematically, a field is a ring which is commutative and in which every\nnonzero element has a multiplicative inverse; these conditions correspond\nto the `CommutativeRing` and `DivisionRing` classes in PureScript\nrespectively. However, the `Field` class has `EuclideanRing` and\n`DivisionRing` as superclasses, which seems like a stronger requirement\n(since `CommutativeRing` is a superclass of `EuclideanRing`). In fact, it\nis not stronger, since any type which has law-abiding `CommutativeRing`\nand `DivisionRing` instances permits exactly one law-abiding\n`EuclideanRing` instance. We use a `EuclideanRing` superclass here in\norder to ensure that a `Field` constraint on a function permits you to use\n`div` on that type, since `div` is a member of `EuclideanRing`.\n\nThis class has no laws or members of its own; it exists as a convenience,\nso a single constraint can be used when field-like behaviour is expected.\n\nThis module also defines a single `Field` instance for any type which has\nboth `EuclideanRing` and `DivisionRing` instances. Any other instance\nwould overlap with this instance, so no other `Field` instances should be\ndefined in libraries. Instead, simply define `EuclideanRing` and\n`DivisionRing` instances, and this will permit your type to be used with a\n`Field` constraint.\n","title":"Field","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","EuclideanRing"],"EuclideanRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","DivisionRing"],"DivisionRing"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Field.purs","end":[39,51]}}]},{"moduleName":{"package":null,"item":["Data","Function"]},"declarations":[{"children":[],"comments":"Flips the order of the arguments to a function of two arguments.\n\n```purescript\nflip const 1 2 = const 2 1 = 2\n```\n","title":"flip","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ForAll","contents":["c",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"c"}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[21,51]}},{"children":[],"comments":"Returns its first argument and ignores its second.\n\n```purescript\nconst 1 \"hello\" = 1\n```\n\nIt can also be thought of as creating a function that ignores its argument:\n\n```purescript\nconst 1 = \\_ -> 1\n```\n","title":"const","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"b"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[35,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[35,33]}},{"children":[],"comments":"Applies a function to an argument: the reverse of `(#)`.\n\n```purescript\nlength $ groupBy productCategory $ filter isInStock $ products\n```\n\nis equivalent to:\n\n```purescript\nlength (groupBy productCategory (filter isInStock products))\n```\n\nOr another alternative equivalent, applying chain of composed functions to\na value:\n\n```purescript\nlength <<< groupBy productCategory <<< filter isInStock $ products\n```\n","title":"($)","info":{"declType":"alias","alias":[["Data","Function"],{"Right":{"Left":{"Ident":"apply"}}}],"fixity":{"associativity":"infixr","precedence":0}},"sourceSpan":{"start":[62,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[62,20]}},{"children":[],"comments":"Applies an argument to a function: the reverse of `($)`.\n\n```purescript\nproducts # filter isInStock # groupBy productCategory # length\n```\n\nis equivalent to:\n\n```purescript\nlength (groupBy productCategory (filter isInStock products))\n```\n\nOr another alternative equivalent, applying a value to a chain of composed\nfunctions:\n\n```purescript\nproducts # filter isInStock >>> groupBy productCategory >>> length\n```\n","title":"(#)","info":{"declType":"alias","alias":[["Data","Function"],{"Right":{"Left":{"Ident":"applyFlipped"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[88,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Function.purs","end":[88,27]}}]},{"moduleName":{"package":null,"item":["Data","Functor"]},"declarations":[{"children":[{"comments":null,"title":"map","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]},null]},null]}},"sourceSpan":{"start":[26,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"comments":null,"title":"functorFn","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[41,16]}},{"comments":null,"title":"functorArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[44,17]}},{"comments":null,"title":"functorProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Functor"],"Functor"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[47,18]}}],"comments":"A `Functor` is a type constructor which supports a mapping operation\n`map`.\n\n`map` can be used to turn functions `a -> b` into functions\n`f a -> f b` whose argument and return types use the type constructor `f`\nto represent some computational context.\n\nInstances must satisfy the following laws:\n\n- Identity: `map identity = identity`\n- Composition: `map (f <<< g) = map f <<< map g`\n","title":"Functor","info":{"fundeps":[],"arguments":[["f",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[25,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[26,44]}},{"children":[],"comments":"The `void` function is used to ignore the type wrapped by a\n[`Functor`](#functor), replacing it with `Unit` and keeping only the type\ninformation provided by the type constructor itself.\n\n`void` is often useful when using `do` notation to change the return type\nof a monadic computation:\n\n```purescript\nmain = forE 1 10 \\n -> void do\n print n\n print (n * n)\n```\n","title":"void","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}]}]},null]},null]}},"sourceSpan":{"start":[63,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[63,47]}},{"children":[],"comments":"Apply a value in a computational context to a value in no context.\n\nGeneralizes `flip`.\n\n```purescript\nlongEnough :: String -> Bool\nhasSymbol :: String -> Bool\nhasDigit :: String -> Bool\npassword :: String\n\nvalidate :: String -> Array Bool\nvalidate = flap [longEnough, hasSymbol, hasDigit]\n```\n\n```purescript\nflap (-) 3 4 == 1\nthreeve <$> Just 1 <@> 'a' <*> Just true == Just (threeve 1 'a' true)\n```\n","title":"flap","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["f",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Functor"],"Functor"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"f"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeVar","contents":"f"},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[97,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[97,58]}},{"children":[],"comments":null,"title":"(<@>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"flap"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[100,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[100,21]}},{"children":[],"comments":null,"title":"(<$>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"map"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[28,20]}},{"children":[],"comments":null,"title":"(<$)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidRight"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[71,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[71,25]}},{"children":[],"comments":null,"title":"(<#>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"mapFlipped"}}}],"fixity":{"associativity":"infixl","precedence":1}},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[38,27]}},{"children":[],"comments":null,"title":"($>)","info":{"declType":"alias","alias":[["Data","Functor"],{"Right":{"Left":{"Ident":"voidLeft"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[77,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Functor.purs","end":[77,24]}}]},{"moduleName":{"package":null,"item":["Data","HeytingAlgebra"]},"declarations":[{"children":[{"comments":null,"title":"conj","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[42,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[42,22]}},{"comments":null,"title":"disj","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[43,22]}},{"comments":null,"title":"not","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}},"sourceSpan":{"start":[44,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[44,16]}},{"comments":null,"title":"heytingAlgebraBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[55,16]}},{"comments":null,"title":"heytingAlgebraUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[63,15]}},{"comments":null,"title":"heytingAlgebraFunction","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebra"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[65,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[71,22]}},{"comments":null,"title":"heytingAlgebraProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[79,13]}},{"comments":null,"title":"heytingAlgebraProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[81,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[87,14]}},{"comments":null,"title":"heytingAlgebraProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[89,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[95,14]}},{"comments":null,"title":"heytingAlgebraRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","HeytingAlgebra"],"HeytingAlgebraRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","HeytingAlgebra"],"HeytingAlgebra"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[97,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[103,41]}}],"comments":"The `HeytingAlgebra` type class represents types that are bounded lattices with\nan implication operator such that the following laws hold:\n\n- Associativity:\n - `a || (b || c) = (a || b) || c`\n - `a && (b && c) = (a && b) && c`\n- Commutativity:\n - `a || b = b || a`\n - `a && b = b && a`\n- Absorption:\n - `a || (a && b) = a`\n - `a && (a || b) = a`\n- Idempotent:\n - `a || a = a`\n - `a && a = a`\n- Identity:\n - `a || ff = a`\n - `a && tt = a`\n- Implication:\n - ``a `implies` a = tt``\n - ``a && (a `implies` b) = a && b``\n - ``b && (a `implies` b) = b``\n - ``a `implies` (b && c) = (a `implies` b) && (a `implies` c)``\n- Complemented:\n - ``not a = a `implies` ff``\n","title":"HeytingAlgebra","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[38,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[44,16]}},{"children":[],"comments":null,"title":"(||)","info":{"declType":"alias","alias":[["Data","HeytingAlgebra"],{"Right":{"Left":{"Ident":"disj"}}}],"fixity":{"associativity":"infixr","precedence":2}},"sourceSpan":{"start":[47,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[47,20]}},{"children":[],"comments":null,"title":"(&&)","info":{"declType":"alias","alias":[["Data","HeytingAlgebra"],{"Right":{"Left":{"Ident":"conj"}}}],"fixity":{"associativity":"infixr","precedence":3}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/HeytingAlgebra.purs","end":[46,20]}}]},{"moduleName":{"package":null,"item":["Data","Monoid"]},"declarations":[{"children":[{"comments":null,"title":"mempty","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"m"}},"sourceSpan":{"start":[45,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[45,14]}},{"comments":null,"title":"monoidUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[47,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[48,16]}},{"comments":null,"title":"monoidOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[50,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[51,14]}},{"comments":null,"title":"monoidFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"Monoid"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[54,20]}},{"comments":null,"title":"monoidString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[56,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[57,14]}},{"comments":null,"title":"monoidArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[59,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[60,14]}},{"comments":null,"title":"monoidRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Monoid"],"MonoidRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Monoid"],"Monoid"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[62,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[63,46]}}],"comments":"A `Monoid` is a `Semigroup` with a value `mempty`, which is both a\nleft and right unit for the associative operation `<>`:\n\n- Left unit: `(mempty <> x) = x`\n- Right unit: `(x <> mempty) = x`\n\n`Monoid`s are commonly used as the result of fold operations, where\n`<>` is used to combine individual results, and `mempty` gives the result\nof folding an empty collection of elements.\n\n### Newtypes for Monoid\n\nSome types (e.g. `Int`, `Boolean`) can implement multiple law-abiding\ninstances for `Monoid`. Let's use `Int` as an example\n1. `<>` could be `+` and `mempty` could be `0`\n2. `<>` could be `*` and `mempty` could be `1`.\n\nTo clarify these ambiguous situations, one should use the newtypes\ndefined in `Data.Monoid.` modules.\n\nIn the above ambiguous situation, we could use `Additive`\nfor the first situation or `Multiplicative` for the second one.\n","title":"Monoid","info":{"fundeps":[],"arguments":[["m",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"Semigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"m"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[44,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Monoid.purs","end":[45,14]}}]},{"moduleName":{"package":null,"item":["Data","NaturalTransformation"]},"declarations":[{"children":[],"comments":null,"title":"type (~>)","info":{"declType":"alias","alias":[["Data","NaturalTransformation"],{"Left":"NaturalTransformation"}],"fixity":{"associativity":"infixr","precedence":4}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/NaturalTransformation.purs","end":[20,42]}}]},{"moduleName":{"package":null,"item":["Data","Ord"]},"declarations":[{"children":[{"comments":null,"title":"compare","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}]}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[38,32]}},{"comments":null,"title":"ordBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[41,36]}},{"comments":null,"title":"ordInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[44,32]}},{"comments":null,"title":"ordNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[47,35]}},{"comments":null,"title":"ordString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[50,35]}},{"comments":null,"title":"ordChar","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Char"]}]}},"sourceSpan":{"start":[52,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[53,33]}},{"comments":null,"title":"ordUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[56,19]}},{"comments":null,"title":"ordVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[59,19]}},{"comments":null,"title":"ordProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[62,19]}},{"comments":null,"title":"ordProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[64,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[65,19]}},{"comments":null,"title":"ordProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[68,19]}},{"comments":null,"title":"ordArray","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[70,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[77,17]}},{"comments":null,"title":"ordOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[121,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[128,21]}},{"comments":null,"title":"ordRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ord"],"OrdRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ord"],"Ord"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[249,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[254,48]}}],"comments":"The `Ord` type class represents types which support comparisons with a\n_total order_.\n\n`Ord` instances should satisfy the laws of total orderings:\n\n- Reflexivity: `a <= a`\n- Antisymmetry: if `a <= b` and `b <= a` then `a = b`\n- Transitivity: if `a <= b` and `b <= c` then `a <= c`\n","title":"Ord","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Eq"],"Eq"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[38,32]}},{"children":[],"comments":"Take the minimum of two values. If they are considered equal, the first\nargument is chosen.\n","title":"min","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]}},"sourceSpan":{"start":[165,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[165,38]}},{"children":[],"comments":"Take the maximum of two values. If they are considered equal, the first\nargument is chosen.\n","title":"max","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]},null]}},"sourceSpan":{"start":[174,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[174,38]}},{"children":[],"comments":"Compares two values by mapping them to a type with an `Ord` instance.\n","title":"comparing","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ForAll","contents":["b",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}}]},{"annotation":[],"tag":"ParensInType","contents":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}]}}]}]},null]},null]}},"sourceSpan":{"start":[160,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[160,67]}},{"children":[],"comments":"Clamp a value between a minimum and a maximum. For example:\n\n``` purescript\nlet f = clamp 0 10\nf (-5) == 0\nf 5 == 5\nf 15 == 10\n```\n","title":"clamp","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}]}]},null]}},"sourceSpan":{"start":[189,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[189,45]}},{"children":[],"comments":"Test whether a value is between a minimum and a maximum (inclusive).\nFor example:\n\n``` purescript\nlet f = between 0 10\nf 0 == true\nf (-5) == false\nf 5 == true\nf 10 == true\nf 15 == false\n```\n","title":"between","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ord"],"Ord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]}]}]},null]}},"sourceSpan":{"start":[203,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[203,53]}},{"children":[],"comments":null,"title":"(>=)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"greaterThanOrEq"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[157,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[157,31]}},{"children":[],"comments":null,"title":"(>)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"greaterThan"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[156,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[156,26]}},{"children":[],"comments":null,"title":"(<=)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"lessThanOrEq"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[155,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[155,28]}},{"children":[],"comments":null,"title":"(<)","info":{"declType":"alias","alias":[["Data","Ord"],{"Right":{"Left":{"Ident":"lessThan"}}}],"fixity":{"associativity":"infixl","precedence":4}},"sourceSpan":{"start":[154,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ord.purs","end":[154,23]}}]},{"moduleName":{"package":null,"item":["Data","Ordering"]},"declarations":[{"children":[{"comments":null,"title":"LT","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"GT","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"EQ","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null},{"comments":null,"title":"eqOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Eq"],"Eq"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[19,19]}},{"comments":null,"title":"semigroupOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[24,18]}},{"comments":null,"title":"showOrdering","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ordering"],"Ordering"]}]}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[29,17]}}],"comments":"The `Ordering` data type represents the three possible outcomes of\ncomparing two values:\n\n`LT` - The first value is _less than_ the second.\n`GT` - The first value is _greater than_ the second.\n`EQ` - The first value is _equal to_ the second.\n","title":"Ordering","info":{"declType":"data","dataDeclType":"data","typeArguments":[]},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ordering.purs","end":[13,29]}}]},{"moduleName":{"package":null,"item":["Data","Ring"]},"declarations":[{"children":[{"comments":null,"title":"sub","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[24,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"comments":null,"title":"ringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[28,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[29,15]}},{"comments":null,"title":"ringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[32,15]}},{"comments":null,"title":"ringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[35,17]}},{"comments":null,"title":"ringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[37,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[38,24]}},{"comments":null,"title":"ringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[41,18]}},{"comments":null,"title":"ringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[44,19]}},{"comments":null,"title":"ringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[46,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[47,19]}},{"comments":null,"title":"ringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Ring"],"RingRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Ring"],"Ring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[50,40]}}],"comments":"The `Ring` class is for types that support addition, multiplication,\nand subtraction operations.\n\nInstances must satisfy the following laws in addition to the `Semiring`\nlaws:\n\n- Additive inverse: `a - a = zero`\n- Compatibility of `sub` and `negate`: `a - b = a + (zero - b)`\n","title":"Ring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}]},"sourceSpan":{"start":[23,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[24,21]}},{"children":[],"comments":"`negate x` can be used as a shorthand for `zero - x`.\n","title":"negate","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"ConstrainedType","contents":[{"constraintAnn":[],"constraintClass":[["Data","Ring"],"Ring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]}},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[53,37]}},{"children":[],"comments":null,"title":"(-)","info":{"declType":"alias","alias":[["Data","Ring"],{"Right":{"Left":{"Ident":"sub"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[26,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Ring.purs","end":[26,18]}}]},{"moduleName":{"package":null,"item":["Data","Semigroup"]},"declarations":[{"children":[{"comments":null,"title":"append","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[32,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[32,24]}},{"comments":null,"title":"semigroupString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[37,24]}},{"comments":null,"title":"semigroupUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[40,20]}},{"comments":null,"title":"semigroupVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[43,20]}},{"comments":null,"title":"semigroupFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"Semigroup"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"s'"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"s"}]},{"annotation":[],"tag":"TypeVar","contents":"s'"}]}]}},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[46,28]}},{"comments":null,"title":"semigroupArray","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[49,23]}},{"comments":null,"title":"semigroupProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[51,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[52,21]}},{"comments":null,"title":"semigroupProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[54,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[55,22]}},{"comments":null,"title":"semigroupProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[57,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[58,22]}},{"comments":null,"title":"semigroupRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semigroup"],"SemigroupRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semigroup"],"Semigroup"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[60,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[61,46]}}],"comments":"The `Semigroup` type class identifies an associative operation on a type.\n\nInstances are required to satisfy the following law:\n\n- Associativity: `(x <> y) <> z = x <> (y <> z)`\n\nOne example of a `Semigroup` is `String`, with `(<>)` defined as string\nconcatenation. Another example is `List a`, with `(<>)` defined as\nlist concatenation.\n\n### Newtypes for Semigroup\n\nThere are two other ways to implement an instance for this type class\nregardless of which type is used. These instances can be used by\nwrapping the values in one of the two newtypes below:\n1. `First` - Use the first argument every time: `append first _ = first`.\n2. `Last` - Use the last argument every time: `append _ last = last`.\n","title":"Semigroup","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[31,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[32,24]}},{"children":[],"comments":null,"title":"(<>)","info":{"declType":"alias","alias":[["Data","Semigroup"],{"Right":{"Left":{"Ident":"append"}}}],"fixity":{"associativity":"infixr","precedence":5}},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semigroup.purs","end":[34,22]}}]},{"moduleName":{"package":null,"item":["Data","Semiring"]},"declarations":[{"children":[{"comments":null,"title":"add","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[35,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[35,22]}},{"comments":null,"title":"zero","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[36,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[36,12]}},{"comments":null,"title":"mul","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[37,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[37,22]}},{"comments":null,"title":"one","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeVar","contents":"a"}},"sourceSpan":{"start":[38,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"comments":null,"title":"semiringInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[43,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[47,10]}},{"comments":null,"title":"semiringNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[49,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[53,12]}},{"comments":null,"title":"semiringFn","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"Semiring"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"b"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeVar","contents":"b"}]}]}},"sourceSpan":{"start":[55,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[59,18]}},{"comments":null,"title":"semiringUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[61,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[65,13]}},{"comments":null,"title":"semiringProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[67,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[71,15]}},{"comments":null,"title":"semiringProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[73,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[77,16]}},{"comments":null,"title":"semiringProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[79,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[83,16]}},{"comments":null,"title":"semiringRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"list"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Semiring"],"SemiringRecord"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"list"},{"annotation":[],"tag":"TypeVar","contents":"row"},{"annotation":[],"tag":"TypeVar","contents":"row"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Semiring"],"Semiring"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"row"}]}]}},"sourceSpan":{"start":[85,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[89,63]}}],"comments":"The `Semiring` class is for types that support an addition and\nmultiplication operation.\n\nInstances must satisfy the following laws:\n\n- Commutative monoid under addition:\n - Associativity: `(a + b) + c = a + (b + c)`\n - Identity: `zero + a = a + zero = a`\n - Commutative: `a + b = b + a`\n- Monoid under multiplication:\n - Associativity: `(a * b) * c = a * (b * c)`\n - Identity: `one * a = a * one = a`\n- Multiplication distributes over addition:\n - Left distributivity: `a * (b + c) = (a * b) + (a * c)`\n - Right distributivity: `(a + b) * c = (a * c) + (b * c)`\n- Annihilation: `zero * a = a * zero = zero`\n\n**Note:** The `Number` and `Int` types are not fully law abiding\nmembers of this class hierarchy due to the potential for arithmetic\noverflows, and in the case of `Number`, the presence of `NaN` and\n`Infinity` values. The behaviour is unspecified in these cases.\n","title":"Semiring","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[34,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[38,12]}},{"children":[],"comments":null,"title":"(+)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"add"}}}],"fixity":{"associativity":"infixl","precedence":6}},"sourceSpan":{"start":[40,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[40,18]}},{"children":[],"comments":null,"title":"(*)","info":{"declType":"alias","alias":[["Data","Semiring"],{"Right":{"Left":{"Ident":"mul"}}}],"fixity":{"associativity":"infixl","precedence":7}},"sourceSpan":{"start":[41,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Semiring.purs","end":[41,18]}}]},{"moduleName":{"package":null,"item":["Data","Show"]},"declarations":[{"children":[{"comments":null,"title":"show","info":{"declType":"typeClassMember","type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[18,3],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[18,22]}},{"comments":null,"title":"showBoolean","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}},"sourceSpan":{"start":[20,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[22,23]}},{"comments":null,"title":"showInt","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Int"]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[25,21]}},{"comments":null,"title":"showNumber","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Number"]}]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[28,24]}},{"comments":null,"title":"showChar","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Char"]}]}},"sourceSpan":{"start":[30,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[31,22]}},{"comments":null,"title":"showString","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":{"start":[33,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[34,24]}},{"comments":null,"title":"showArray","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Data","Show"],"Show"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"a"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Array"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[37,28]}},{"comments":null,"title":"showProxy","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[39,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[40,19]}},{"comments":null,"title":"showProxy2","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy2"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[42,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[43,20]}},{"comments":null,"title":"showProxy3","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Type","Proxy"],"Proxy3"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]}},"sourceSpan":{"start":[45,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[46,20]}},{"comments":null,"title":"showRecord","info":{"declType":"instance","dependencies":[{"constraintAnn":[],"constraintClass":[["Prim","RowList"],"RowToList"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"rs"},{"annotation":[],"tag":"TypeVar","contents":"ls"}],"constraintKindArgs":[],"constraintData":null},{"constraintAnn":[],"constraintClass":[["Data","Show"],"ShowRecordFields"],"constraintArgs":[{"annotation":[],"tag":"TypeVar","contents":"ls"},{"annotation":[],"tag":"TypeVar","contents":"rs"}],"constraintKindArgs":[],"constraintData":null}],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"rs"}]}]}},"sourceSpan":{"start":[48,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[51,52]}}],"comments":"The `Show` type class represents those types which can be converted into\na human-readable `String` representation.\n\nWhile not required, it is recommended that for any expression `x`, the\nstring `show x` be executable PureScript code which evaluates to the same\nvalue as the expression `x`.\n","title":"Show","info":{"fundeps":[],"arguments":[["a",null]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[17,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Show.purs","end":[18,22]}}]},{"moduleName":{"package":null,"item":["Data","Unit"]},"declarations":[{"children":[{"comments":null,"title":"showUnit","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}]}},"sourceSpan":{"start":[18,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Unit.purs","end":[19,18]}}],"comments":"The `Unit` type has a single inhabitant, called `unit`. It represents\nvalues with no computational content.\n\n`Unit` is often used, wrapped in a monadic type constructor, as the\nreturn type of a computation where only the _effects_ are important.\n\nWhen returning a value of type `Unit` from an FFI function, it is\nrecommended to use `undefined`, or not return a value at all.\n","title":"Unit","info":{"kind":{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Type"]},"declType":"externData"},"sourceSpan":{"start":[13,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Unit.purs","end":[13,33]}},{"children":[],"comments":"`unit` is the sole inhabitant of the `Unit` type.\n","title":"unit","info":{"declType":"value","type":{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Unit"],"Unit"]}},"sourceSpan":{"start":[16,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Unit.purs","end":[16,28]}}]},{"moduleName":{"package":null,"item":["Data","Void"]},"declarations":[{"children":[{"comments":null,"title":"showVoid","info":{"declType":"instance","dependencies":[],"type":{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Show"],"Show"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]}},"sourceSpan":{"start":[24,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Void.purs","end":[25,16]}}],"comments":"An uninhabited data type. In other words, one can never create\na runtime value of type `Void` becaue no such value exists.\n\n`Void` is useful to eliminate the possibility of a value being created.\nFor example, a value of type `Either Void Boolean` can never have\na Left value created in PureScript.\n\nThis should not be confused with the keyword `void` that commonly appears in\nC-family languages, such as Java:\n```\npublic class Foo {\n void doSomething() { System.out.println(\"hello world!\"); }\n}\n```\n\nIn PureScript, one often uses `Unit` to achieve similar effects as\nthe `void` of C-family languages above.\n","title":"Void","info":{"declType":"data","dataDeclType":"newtype","typeArguments":[]},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Void.purs","end":[22,25]}},{"children":[],"comments":"Eliminator for the `Void` type.\nUseful for stating that some code branch is impossible because you've\n\"acquired\" a value of type `Void` (which you can't).\n\n```purescript\nrightOnly :: forall t . Either Void t -> t\nrightOnly (Left v) = absurd v\nrightOnly (Right t) = t\n```\n","title":"absurd","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Data","Void"],"Void"]}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},null]}},"sourceSpan":{"start":[36,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Data/Void.purs","end":[36,30]}}]}],"name":"Prelude","comments":null,"declarations":[]},{"reExports":[],"name":"Record.Unsafe","comments":"The functions in this module are highly unsafe as they treat records like\nstringly-keyed maps and can coerce the row of labels that a record has.\n\nThese function are intended for situations where there is some other way of\nproving things about the structure of the record - for example, when using\n`RowToList`. **They should never be used for general record manipulation.**\n","declarations":[{"children":[],"comments":"Checks if a record has a key, using a string for the key.\n","title":"unsafeHas","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["r1",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"r1"}]}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Boolean"]}]}]},null]}},"sourceSpan":{"start":[10,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Record/Unsafe.purs","end":[10,70]}},{"children":[],"comments":"Unsafely gets a value from a record, using a string for the key.\n\nIf the key does not exist this will cause a runtime error elsewhere.\n","title":"unsafeGet","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["r",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"r"}]}]},{"annotation":[],"tag":"TypeVar","contents":"a"}]}]},null]},null]}},"sourceSpan":{"start":[15,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Record/Unsafe.purs","end":[15,64]}},{"children":[],"comments":"Unsafely sets a value on a record, using a string for the key.\n\nThe output record's row is unspecified so can be coerced to any row. If the\noutput type is incorrect it will cause a runtime error elsewhere.\n","title":"unsafeSet","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["r1",{"annotation":[],"tag":"ForAll","contents":["r2",{"annotation":[],"tag":"ForAll","contents":["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeVar","contents":"a"}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"r1"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"r2"}]}]}]}]},null]},null]},null]}},"sourceSpan":{"start":[21,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Record/Unsafe.purs","end":[21,82]}},{"children":[],"comments":"Unsafely removes a value on a record, using a string for the key.\n\nThe output record's row is unspecified so can be coerced to any row. If the\noutput type is incorrect it will cause a runtime error elsewhere.\n","title":"unsafeDelete","info":{"declType":"value","type":{"annotation":[],"tag":"ForAll","contents":["r1",{"annotation":[],"tag":"ForAll","contents":["r2",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"String"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"r1"}]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Record"]},{"annotation":[],"tag":"TypeVar","contents":"r2"}]}]}]},null]},null]}},"sourceSpan":{"start":[27,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Record/Unsafe.purs","end":[27,78]}}]},{"reExports":[],"name":"Type.Data.Row","comments":null,"declarations":[{"children":[{"comments":null,"title":"RProxy","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null}],"comments":null,"title":"RProxy","info":{"declType":"data","dataDeclType":"data","typeArguments":[["row",null]]},"sourceSpan":{"start":[22,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Type/Data/Row.purs","end":[22,25]}}]},{"reExports":[],"name":"Type.Data.RowList","comments":null,"declarations":[{"children":[{"comments":null,"title":"RLProxy","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null}],"comments":null,"title":"RLProxy","info":{"declType":"data","dataDeclType":"data","typeArguments":[["rowlist",null]]},"sourceSpan":{"start":[8,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Type/Data/RowList.purs","end":[8,31]}}]},{"reExports":[],"name":"Type.Proxy","comments":"The `Proxy` type and values are for situations where type information is\nrequired for an input to determine the type of an output, but where it is\nnot possible or convenient to provide a _value_ for the input.\n\nA hypothetical example: if you have a class that is used to handle the\nresult of an AJAX request, you may want to use this information to set the\nexpected content type of the request, so you might have a class something\nlike this:\n\n``` purescript\nclass AjaxResponse a where\n responseType :: a -> ResponseType\n fromResponse :: Foreign -> a\n```\n\nThe problem here is `responseType` requires a value of type `a`, but we\nwon't have a value of that type until the request has been completed. The\nsolution is to use a `Proxy` type instead:\n\n``` purescript\nclass AjaxResponse a where\n responseType :: Proxy a -> ResponseType\n fromResponse :: Foreign -> a\n```\n\nWe can now call `responseType (Proxy :: Proxy SomeContentType)` to produce\na `ResponseType` for `SomeContentType` without having to construct some\nempty version of `SomeContentType` first. In situations like this where\nthe `Proxy` type can be statically determined, it is recommended to pull\nout the definition to the top level and make a declaration like:\n\n``` purescript\n_SomeContentType :: Proxy SomeContentType\n_SomeContentType = Proxy\n```\n\nThat way the proxy value can be used as `responseType _SomeContentType`\nfor improved readability. However, this is not always possible, sometimes\nthe type required will be determined by a type variable. As PureScript has\nscoped type variables, we can do things like this:\n\n``` purescript\nmakeRequest :: URL -> ResponseType -> Aff _ Foreign\nmakeRequest = ...\n\nfetchData :: forall a. (AjaxResponse a) => URL -> Aff _ a\nfetchData url = fromResponse <$> makeRequest url (responseType (Proxy :: Proxy a))\n```\n","declarations":[{"children":[{"comments":null,"title":"Proxy","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null}],"comments":null,"title":"Proxy","info":{"declType":"data","dataDeclType":"data","typeArguments":[["a",null]]},"sourceSpan":{"start":[53,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Type/Proxy.purs","end":[53,21]}},{"children":[{"comments":null,"title":"Proxy2","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null}],"comments":null,"title":"Proxy2","info":{"declType":"data","dataDeclType":"data","typeArguments":[["f",null]]},"sourceSpan":{"start":[58,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Type/Proxy.purs","end":[58,23]}},{"children":[{"comments":null,"title":"Proxy3","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null}],"comments":"Value proxy for kind `Type -> Type -> Type` types.\n**Deprecated as of v0.14.0 PureScript release**: use `Proxy` instead.\n","title":"Proxy3","info":{"declType":"data","dataDeclType":"data","typeArguments":[["a",{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Type"]}]},{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeApp","contents":[{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Type"]}]},{"annotation":[],"tag":"TypeConstructor","contents":[["Prim"],"Type"]}]}]}]]},"sourceSpan":{"start":[62,1],"name":"/Users/trh/Desktop/release/purescript-prelude/src/Type/Proxy.purs","end":[62,49]}}]}],"resolvedDependencies":{},"version":"5.0.1","github":["purescript","purescript-prelude"],"versionTag":"v5.0.1","moduleMap":{},"compilerVersion":"0.14.0"}
\ No newline at end of file
diff --git a/tests/purs/.gitattributes b/tests/purs/.gitattributes
new file mode 100644
index 0000000000..5fa9fa7340
--- /dev/null
+++ b/tests/purs/.gitattributes
@@ -0,0 +1 @@
+*.out.js -text
diff --git a/tests/purs/bundle/RerunCompilerTests.txt b/tests/purs/bundle/RerunCompilerTests.txt
deleted file mode 100644
index ab8991352a..0000000000
--- a/tests/purs/bundle/RerunCompilerTests.txt
+++ /dev/null
@@ -1,27 +0,0 @@
--- Each line in this file that doesn't start with "--" is the name of a test
--- in purs/passing which should be rerun during bundle testing. Rerunning
--- every test in purs/passing would take more time than it's worth, so these
--- tests have been cherry-picked for having moderately complex imports.
-
-Collatz
-DctorOperatorAlias
-EffFn
-ExtendedInfixOperators
-Fib
-ForeignKind
-FunWithFunDeps
-GenericsRep
-Import
-ImportExplicit
-ImportQualified
-Let
-Operators
-QualifiedAdo
-QualifiedDo
-SolvingAppendSymbol
-SolvingCompareSymbol
-SolvingIsSymbol
-TCO
-TransitiveImport
-TypeOperators
-TypeWithoutParens
diff --git a/tests/purs/docs/bower_components/purescript-newtype/src/Data/Newtype.purs b/tests/purs/docs/bower_components/purescript-newtype/src/Data/Newtype.purs
new file mode 100644
index 0000000000..336e5b36ba
--- /dev/null
+++ b/tests/purs/docs/bower_components/purescript-newtype/src/Data/Newtype.purs
@@ -0,0 +1,6 @@
+module Data.Newtype where
+
+import Prim.Coerce (class Coercible)
+
+class Newtype :: Type -> Type -> Constraint
+class Coercible t a <= Newtype t a | t -> a
diff --git a/tests/purs/docs/purs.json b/tests/purs/docs/purs.json
new file mode 100644
index 0000000000..4125508db4
--- /dev/null
+++ b/tests/purs/docs/purs.json
@@ -0,0 +1,11 @@
+{
+ "name": "docs-test-package",
+ "license": "MIT",
+ "version": "1.0.0",
+ "location": {
+ "gitUrl": "https://github.com/not-real/not-a-real-repo.git"
+ },
+ "dependencies": {
+ "prelude": ">=1.0.0 <2.0.0"
+ }
+}
diff --git a/tests/purs/docs/resolutions.json b/tests/purs/docs/resolutions.json
index c3fced5666..dbfb5eaf21 100644
--- a/tests/purs/docs/resolutions.json
+++ b/tests/purs/docs/resolutions.json
@@ -1,21 +1,10 @@
{
- "canonicalDir": ".",
- "pkgMeta": {
- "dependencies": {
- "purescript-prelude": "./bower_components/purescript-prelude"
- }
+ "purescript-prelude": {
+ "version": "1.0.0",
+ "path": "bower_components/purescript-prelude"
},
- "dependencies": {
- "purescript-prelude": {
- "canonicalDir": "bower_components/purescript-prelude",
- "pkgMeta": {
- "_resolution": {
- "type": "version",
- "tag": "v2.4.0",
- "commit": "21067a4c782f42d08bc877214f85b92ce6769b21"
- }
- },
- "dependencies": {}
- }
+ "purescript-newtype": {
+ "version": "1.0.0",
+ "path": "bower_components/purescript-newtype"
}
}
diff --git a/tests/purs/docs/src/Clash1a.purs b/tests/purs/docs/src/Clash1a.purs
index c21260f562..77804573c7 100644
--- a/tests/purs/docs/src/Clash1a.purs
+++ b/tests/purs/docs/src/Clash1a.purs
@@ -3,7 +3,7 @@ module Clash1a where
value :: Int
value = 0
-type Type = Int
+type Type' = Int
class TypeClass a where
typeClassMember :: a
diff --git a/tests/purs/docs/src/Clash2a.purs b/tests/purs/docs/src/Clash2a.purs
index 5405daf9ed..8c394a7c69 100644
--- a/tests/purs/docs/src/Clash2a.purs
+++ b/tests/purs/docs/src/Clash2a.purs
@@ -3,7 +3,7 @@ module Clash2a where
value :: String
value = "hello"
-type Type = String
+type Type' = String
class TypeClass a b where
typeClassMember :: a -> b
diff --git a/tests/purs/docs/src/ConstrainedArgument.purs b/tests/purs/docs/src/ConstrainedArgument.purs
index 00bc5be0bc..d56ef76225 100644
--- a/tests/purs/docs/src/ConstrainedArgument.purs
+++ b/tests/purs/docs/src/ConstrainedArgument.purs
@@ -1,6 +1,6 @@
module ConstrainedArgument where
-class Foo t
+class Foo (t :: Type)
type WithoutArgs = forall a. (Partial => a) -> a
type WithArgs = forall a. (Foo a => a) -> a
diff --git a/tests/purs/docs/src/DocCommentsClassMethod.purs b/tests/purs/docs/src/DocCommentsClassMethod.purs
new file mode 100644
index 0000000000..99d1375628
--- /dev/null
+++ b/tests/purs/docs/src/DocCommentsClassMethod.purs
@@ -0,0 +1,6 @@
+module DocCommentsClassMethod where
+
+class Foo a where
+ -- | class method comment
+ bar :: a
+ baz :: String -> a
diff --git a/tests/purs/docs/src/DocCommentsDataConstructor.purs b/tests/purs/docs/src/DocCommentsDataConstructor.purs
new file mode 100644
index 0000000000..34823bccc4
--- /dev/null
+++ b/tests/purs/docs/src/DocCommentsDataConstructor.purs
@@ -0,0 +1,15 @@
+module DocCommentsDataConstructor where
+
+data Foo
+ -- | data constructor comment
+ = Bar
+ | Baz
+
+data ComplexFoo a b
+ = ComplexBar a
+ -- | another data constructor comment
+ | ComplexBaz a b
+
+newtype NewtypeFoo
+ -- | newtype data constructor comment
+ = NewtypeFoo { newtypeBar :: String }
diff --git a/tests/purs/docs/src/DocCommentsMerge.purs b/tests/purs/docs/src/DocCommentsMerge.purs
new file mode 100644
index 0000000000..b160560a4a
--- /dev/null
+++ b/tests/purs/docs/src/DocCommentsMerge.purs
@@ -0,0 +1,118 @@
+module DocCommentsMerge where
+
+-- | decl
+data DataOnly = DataOnly
+
+-- | kind
+data KindOnlyData :: Type
+data KindOnlyData = KindOnlyData
+
+-- | kind
+data KindAndData :: Type
+-- | decl
+data KindAndData = KindAndData
+
+data DataRoleOnly a b = DataRoleOnly a b
+-- | role
+type role DataRoleOnly representational representational
+
+-- | decl
+data DataAndRole a b = DataAndRole a b
+-- | role
+type role DataAndRole representational representational
+
+-- | kind
+data KindOnlyDataRoleOnly :: Type -> Type
+data KindOnlyDataRoleOnly a = KindOnlyDataRoleOnly
+-- | role
+type role KindOnlyDataRoleOnly representational
+
+-- | kind
+data KindDataAndRole :: Type -> Type
+-- | decl
+data KindDataAndRole a = KindDataAndRole
+-- | role
+type role KindDataAndRole representational
+
+---
+
+-- | decl
+foreign import data FFIOnly :: Type
+
+foreign import data FFIRoleOnly :: Type -> Type
+-- | role
+type role FFIRoleOnly representational
+
+-- | decl
+foreign import data FFIAndRole :: Type -> Type
+-- | role
+type role FFIAndRole representational
+
+---
+
+-- | decl
+newtype NewtypeOnly = NewtypeOnly Int
+
+-- | kind
+newtype KindOnlyNewtype :: Type
+newtype KindOnlyNewtype = KindOnlyNewtype Int
+
+-- | kind
+newtype KindAndNewtype :: Type -> Type -> Type
+-- | decl
+newtype KindAndNewtype a b = KindAndNewtype Int
+
+newtype NewtypeRoleOnly a b = NewtypeRoleOnly Int
+-- | role
+type role NewtypeRoleOnly representational representational
+
+-- | decl
+newtype NewtypeAndRole a b = NewtypeAndRole Int
+-- | role
+type role NewtypeAndRole representational representational
+
+-- | kind
+newtype KindOnlyNewtypeRoleOnly :: Type -> Type -> Type
+newtype KindOnlyNewtypeRoleOnly a b = KindOnlyNewtypeRoleOnly Int
+-- | role
+type role KindOnlyNewtypeRoleOnly representational representational
+
+-- | kind
+newtype KindNewtypeAndRole :: Type -> Type -> Type
+-- | decl
+newtype KindNewtypeAndRole a b = KindNewtypeAndRole Int
+-- | role
+type role KindNewtypeAndRole representational representational
+
+---
+
+-- | decl
+type TypeOnly = Int
+
+-- | kind
+type KindOnlyType :: Type -> Type -> Type
+type KindOnlyType a b = Int
+
+-- | kind
+type KindAndType :: Type -> Type -> Type
+-- | decl
+type KindAndType a b = Int
+
+-- type can't have role annotations
+
+---
+
+-- | decl
+class ClassOnly
+
+-- | kind
+class KindOnlyClass :: Constraint
+class KindOnlyClass
+
+-- | kind
+class KindAndClass :: Type -> Constraint
+-- | decl
+class KindAndClass a where
+ fooKindAndClass :: a -> String
+
+-- class can't have role declarations
diff --git a/tests/purs/docs/src/KindSignatureDocs.purs b/tests/purs/docs/src/KindSignatureDocs.purs
new file mode 100644
index 0000000000..4d487efb64
--- /dev/null
+++ b/tests/purs/docs/src/KindSignatureDocs.purs
@@ -0,0 +1,123 @@
+module KindSignatureDocs where
+
+data DKindAndType :: forall k. k -> Type
+data DKindAndType a = DKindAndType
+
+type TKindAndType :: forall k. k -> Type
+type TKindAndType a = Int
+
+newtype NKindAndType :: forall k. k -> Type
+newtype NKindAndType a = NKindAndType Int
+
+class CKindAndType :: forall k. (k -> Type) -> k -> Constraint
+class CKindAndType a k where
+ fooKindAndType :: a k -> String
+
+----------
+
+data DKindOnly :: forall k. k -> Type
+data DKindOnly a = DKindOnly
+
+type TKindOnly :: forall k. k -> Type
+type TKindOnly a = Int
+
+newtype NKindOnly :: forall k. k -> Type
+newtype NKindOnly a = NKindOnly Int
+
+class CKindOnly :: forall k. (k -> Type) -> k -> Constraint
+class CKindOnly a k where
+ fooKindOnly :: a k -> String
+
+----------
+
+data DTypeOnly :: forall k. k -> Type
+data DTypeOnly a = DTypeOnly
+
+type TTypeOnly :: forall k. k -> Type
+type TTypeOnly a = Int
+
+newtype NTypeOnly :: forall k. k -> Type
+newtype NTypeOnly a = NTypeOnly Int
+
+class CTypeOnly :: forall k. (k -> Type) -> k -> Constraint
+class CTypeOnly a k where
+ fooTypeOnly :: a k -> String
+
+----------
+
+data DImplicit a = DImplicit
+
+type TImplicit a = Int
+
+newtype NImplicit a = NImplicit Int
+
+class CImplicit a k where
+ fooImplicit :: a k -> String
+
+----------
+
+data DHidden a b c = DHidden a b c
+
+data DNothing
+
+type THidden a b c = DHidden b c a
+
+newtype NHidden a b c = NHidden (DHidden a c b)
+
+class CHidden a b c where
+ fooHidden :: a -> b -> c -> String
+
+class CNothing
+
+----------
+
+foreign import data FFI_Hidden :: Type -> Type -> Type
+foreign import data FFI_Shown :: (Type -> Type) -> Type
+
+----------
+
+foreign import data FFI_RedundantParenthesis :: (Type) -> Type
+
+data DataRedundantParenthesis :: (Type) -> (Type)
+data DataRedundantParenthesis a = DataRedundantParenthesis
+
+class ClassRedundantParenthesis :: (Type) -> (Constraint)
+class ClassRedundantParenthesis a
+
+data DataHeadParens :: (Type) -> Type -> Type
+data DataHeadParens a b = DataHeadParens
+
+data DataTailParens :: Type -> (Type -> Type)
+data DataTailParens a b = DataTailParens
+
+data DataWholeParens :: (Type -> Type -> Type)
+data DataWholeParens a b = DataWholeParens
+
+data DataSelfParens :: (Type)
+data DataSelfParens = DataSelfParens
+
+class ClassSelfParens :: (Constraint)
+class ClassSelfParens
+
+data DataKindAnnotation (a :: Type) = DataKindAnnotation a
+
+data DataKindAnnotationWithParens (a :: (Type)) = DataKindAnnotationWithParens a
+
+data FunctionParens1 :: (->) Type Type
+data FunctionParens1 a = FunctionParens1 a
+
+data FunctionParens2 :: ((->) Type) Type
+data FunctionParens2 a = FunctionParens2 a
+
+data FunctionParens3 :: (((->) Type)) Type
+data FunctionParens3 a = FunctionParens3 a
+----------
+
+data DShown a b f = DShown (f Int) a b
+
+type TShown f b c = DShown b c f
+
+newtype NShown a f c = NShown (DShown a c f)
+
+class CShown f a b where
+ fooShown :: f Int -> a -> b -> String
diff --git a/tests/purs/docs/src/OperatorSection.purs b/tests/purs/docs/src/OperatorSection.purs
new file mode 100644
index 0000000000..d8c718f3f1
--- /dev/null
+++ b/tests/purs/docs/src/OperatorSection.purs
@@ -0,0 +1,16 @@
+module OperatorSection where
+
+data List a = Nil | Cons a (List a)
+
+infixr 6 Cons as :
+
+class Foldable f where
+ foldl :: forall a b. (b -> a -> b) -> b -> f a -> b
+
+instance Foldable List where
+ -- Note: this is not a valid `Foldable` instance,
+ -- but it verifies that producing docs for
+ -- this file still works. See #4274 for more details.
+ foldl f b = case _ of
+ Nil -> b
+ a : _as -> f b a
diff --git a/tests/purs/docs/src/PrimSubmodules.purs b/tests/purs/docs/src/PrimSubmodules.purs
index ee3c4fdec0..2b34bc231e 100644
--- a/tests/purs/docs/src/PrimSubmodules.purs
+++ b/tests/purs/docs/src/PrimSubmodules.purs
@@ -1,6 +1,6 @@
module PrimSubmodules (Lol(..), x, y, module O) where
-import Prim.Ordering (kind Ordering, LT, EQ, GT) as O
+import Prim.Ordering (Ordering, LT, EQ, GT) as O
data Lol (a :: O.Ordering) = Lol Int
diff --git a/tests/purs/docs/src/RoleAnnotationDocs.purs b/tests/purs/docs/src/RoleAnnotationDocs.purs
new file mode 100644
index 0000000000..e94453c8a1
--- /dev/null
+++ b/tests/purs/docs/src/RoleAnnotationDocs.purs
@@ -0,0 +1,36 @@
+module RoleAnnotationDocs where
+
+data D_RNP a b c = D_RNP
+type role D_RNP representational nominal phantom
+
+data D_NPR a b c = D_NPR
+type role D_NPR nominal phantom representational
+
+data D_PRN a b c = D_PRN
+type role D_PRN phantom representational nominal
+
+foreign import data FFI_NNN :: Type -> Type -> Type -> Type
+
+foreign import data FFI_RNP :: Type -> Type -> Type -> Type
+type role FFI_RNP representational nominal phantom
+
+foreign import data FFI_Higher1 :: (Type -> Type) -> Type -> Type -> Type
+type role FFI_Higher1 representational nominal phantom
+
+foreign import data FFI_Higher2 :: Type -> (Type -> Type) -> Type -> Type
+type role FFI_Higher2 representational nominal phantom
+
+foreign import data FFI_Higher3 :: Type -> Type -> (Type -> Type) -> Type
+type role FFI_Higher3 representational nominal phantom
+
+foreign import data FFI_Higher4 :: Type -> (Type -> (Type -> Type)) -> Type -> Type
+type role FFI_Higher4 representational nominal phantom
+
+foreign import data FFI_HeadParens :: (Type) -> Type -> Type -> Type
+type role FFI_HeadParens representational nominal phantom
+
+foreign import data FFI_TailParens :: Type -> (Type -> Type -> Type)
+type role FFI_TailParens representational nominal phantom
+
+foreign import data FFI_WholeParens :: (Type -> Type -> Type -> Type)
+type role FFI_WholeParens representational nominal phantom
diff --git a/tests/purs/docs/src/Shebang1Undocumented.purs b/tests/purs/docs/src/Shebang1Undocumented.purs
new file mode 100644
index 0000000000..089c4b8759
--- /dev/null
+++ b/tests/purs/docs/src/Shebang1Undocumented.purs
@@ -0,0 +1,4 @@
+#! a single shebang comment
+module Shebang1Undocumented where
+
+import Prelude
diff --git a/tests/purs/docs/src/Shebang2Undocumented.purs b/tests/purs/docs/src/Shebang2Undocumented.purs
new file mode 100644
index 0000000000..db453c9f8b
--- /dev/null
+++ b/tests/purs/docs/src/Shebang2Undocumented.purs
@@ -0,0 +1,8 @@
+#! a
+#! multi
+#! line
+#! shebang
+#! comment
+module Shebang2Undocumented where
+
+import Prelude
diff --git a/tests/purs/docs/src/Shebang3Undocumented.purs b/tests/purs/docs/src/Shebang3Undocumented.purs
new file mode 100644
index 0000000000..3202e7d06e
--- /dev/null
+++ b/tests/purs/docs/src/Shebang3Undocumented.purs
@@ -0,0 +1,9 @@
+#! a
+#! multi
+#! line
+#! shebang
+#! comment
+-- | Normal doc comment
+module Shebang3Undocumented where
+
+import Prelude
diff --git a/tests/purs/docs/src/Shebang4Undocumented.purs b/tests/purs/docs/src/Shebang4Undocumented.purs
new file mode 100644
index 0000000000..dc3a6b9fe1
--- /dev/null
+++ b/tests/purs/docs/src/Shebang4Undocumented.purs
@@ -0,0 +1,10 @@
+#! a
+#! multi
+#! line
+#! shebang
+#! comment
+-- Normal comment
+-- | Normal doc comment
+module Shebang4Undocumented where
+
+import Prelude
diff --git a/tests/purs/docs/src/TypeSynonym.purs b/tests/purs/docs/src/TypeSynonym.purs
new file mode 100644
index 0000000000..a67fb59a88
--- /dev/null
+++ b/tests/purs/docs/src/TypeSynonym.purs
@@ -0,0 +1,3 @@
+module TypeSynonym where
+
+type MyInt = Int
diff --git a/tests/purs/docs/src/TypeSynonymInstance.purs b/tests/purs/docs/src/TypeSynonymInstance.purs
new file mode 100644
index 0000000000..d832d7eba7
--- /dev/null
+++ b/tests/purs/docs/src/TypeSynonymInstance.purs
@@ -0,0 +1,11 @@
+-- see #3624
+module TypeSynonymInstance where
+
+import Data.Newtype (class Newtype)
+import TypeSynonym (MyInt)
+
+newtype MyNT = MyNT MyInt
+
+derive instance ntMyNT :: Newtype MyNT _
+
+foo = 0
diff --git a/tests/purs/failing/.gitattributes b/tests/purs/failing/.gitattributes
new file mode 100644
index 0000000000..d0b673f439
--- /dev/null
+++ b/tests/purs/failing/.gitattributes
@@ -0,0 +1 @@
+*.out -merge -text
diff --git a/tests/purs/failing/1071.out b/tests/purs/failing/1071.out
new file mode 100644
index 0000000000..48744d8fb7
--- /dev/null
+++ b/tests/purs/failing/1071.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/1071.purs:7:18 - 7:23 (line 7, column 18 - line 7, column 23)
+
+ Could not match kind
+ [33m [0m
+ [33m Type -> Constraint[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Constraint[0m
+ [33m [0m
+
+while checking that type [33mFoo a[0m
+ has kind [33mConstraint[0m
+while inferring the kind of [33mFoo a => a -> a[0m
+while inferring the kind of [33mforall a. Foo a => a -> a[0m
+in value declaration [33mbar[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/1169.out b/tests/purs/failing/1169.out
new file mode 100644
index 0000000000..cce63555c0
--- /dev/null
+++ b/tests/purs/failing/1169.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mTest[0m
+at tests/purs/failing/1169.purs:12:8 - 12:15 (line 12, column 8 - line 12, column 15)
+
+ Data constructor [33mTest.Inner[0m was given 1 arguments in a case expression, but expected 2 arguments.
+ This problem can be fixed by giving [33mTest.Inner[0m 2 arguments.
+
+while checking that expression [33mcase $1 of [0m
+ [33m (Inner _) -> true[0m
+ has type [33mBoolean[0m
+in value declaration [33mtest2[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/IncorrectConstructorArity.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/1175.out b/tests/purs/failing/1175.out
new file mode 100644
index 0000000000..5d8ca2447e
--- /dev/null
+++ b/tests/purs/failing/1175.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mX[0m
+at tests/purs/failing/1175.purs:11:11 - 11:12 (line 11, column 11 - line 11, column 12)
+
+ Could not match type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+
+while checking that type [33mInt[0m
+ is at least as general as type [33mString[0m
+while checking that expression [33m1[0m
+ has type [33mString[0m
+in value declaration [33mf[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/1310.out b/tests/purs/failing/1310.out
new file mode 100644
index 0000000000..4e558ad248
--- /dev/null
+++ b/tests/purs/failing/1310.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mIssue1310[0m
+at tests/purs/failing/1310.purs:18:8 - 18:31 (line 18, column 8 - line 18, column 31)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Issue1310.Inject Oops [0m
+ [33m Effect[0m
+ [33m [0m
+
+while applying a function [33minj[0m
+ of type [33mInject @t0 t1 t2 => t1 t3 -> t2 t3[0m
+ to argument [33mOops (log "Oops")[0m
+while checking that expression [33minj (Oops (log "Oops"))[0m
+ has type [33mEffect Unit[0m
+in value declaration [33mmain[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+ [33mt3[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/1570.out b/tests/purs/failing/1570.out
new file mode 100644
index 0000000000..1b1a0fde57
--- /dev/null
+++ b/tests/purs/failing/1570.out
@@ -0,0 +1,23 @@
+Error found:
+in module [33mM[0m
+at tests/purs/failing/1570.purs:6:10 - 6:16 (line 6, column 10 - line 6, column 16)
+
+ In a type-annotated expression [33mx :: t[0m, the type [33mt[0m must have kind [33mType[0m.
+ The error arises from the type
+ [33m [0m
+ [33m F[0m
+ [33m [0m
+ having the kind
+ [33m [0m
+ [33m Type -> Type[0m
+ [33m [0m
+ instead.
+
+while inferring the type of [33m\$0 -> [0m
+ [33m case $0 of[0m
+ [33m x -> x [0m
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ExpectedType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/1733.out b/tests/purs/failing/1733.out
new file mode 100644
index 0000000000..0410a74fc3
--- /dev/null
+++ b/tests/purs/failing/1733.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/1733.purs:6:8 - 6:25 (line 6, column 8 - line 6, column 25)
+
+ Unknown value [33mThing.doesntExist[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/1825.out b/tests/purs/failing/1825.out
new file mode 100644
index 0000000000..94b78a5ec7
--- /dev/null
+++ b/tests/purs/failing/1825.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/1825.purs:8:11 - 8:12 (line 8, column 11 - line 8, column 12)
+
+ Unknown value [33ma[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/1881.out b/tests/purs/failing/1881.out
new file mode 100644
index 0000000000..709ba17aed
--- /dev/null
+++ b/tests/purs/failing/1881.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/1881.purs:5:1 - 5:1 (line 5, column 1 - line 5, column 1)
+
+ Unable to parse module:
+ Unexpected or mismatched indentation
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2109-bind.out b/tests/purs/failing/2109-bind.out
new file mode 100644
index 0000000000..ad8804be6b
--- /dev/null
+++ b/tests/purs/failing/2109-bind.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2109-bind.purs:8:3 - 8:14 (line 8, column 3 - line 8, column 14)
+
+ Unknown value [33mbind[0m. You're probably using do-notation, which the compiler replaces with calls to the [33mbind[0m and [33mdiscard[0m functions. Please import [33mbind[0m from module [33mPrelude[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2109-bind.purs b/tests/purs/failing/2109-bind.purs
new file mode 100644
index 0000000000..8b2ea0cd20
--- /dev/null
+++ b/tests/purs/failing/2109-bind.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith UnknownName
+module Main where
+
+import Data.Maybe (Maybe(..))
+import Prelude (pure)
+
+x = do
+ x <- Just 1
+ pure x
diff --git a/tests/purs/failing/2109-discard.out b/tests/purs/failing/2109-discard.out
new file mode 100644
index 0000000000..08cc768e5f
--- /dev/null
+++ b/tests/purs/failing/2109-discard.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2109-discard.purs:7:3 - 7:12 (line 7, column 3 - line 7, column 12)
+
+ Unknown value [33mdiscard[0m. You're probably using do-notation, which the compiler replaces with calls to the [33mbind[0m and [33mdiscard[0m functions. Please import [33mdiscard[0m from module [33mPrelude[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2109-discard.purs b/tests/purs/failing/2109-discard.purs
new file mode 100644
index 0000000000..1770690ec9
--- /dev/null
+++ b/tests/purs/failing/2109-discard.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith UnknownName
+module Main where
+
+import Prelude (unit, pure)
+
+main = do
+ pure unit
+ pure unit
diff --git a/tests/purs/failing/2109-negate.out b/tests/purs/failing/2109-negate.out
new file mode 100644
index 0000000000..18c42ee9cd
--- /dev/null
+++ b/tests/purs/failing/2109-negate.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2109-negate.purs:4:5 - 4:7 (line 4, column 5 - line 4, column 7)
+
+ Unknown value [33mnegate[0m. You're probably using numeric negation (the unary [33m-[0m operator), which the compiler replaces with calls to the [33mnegate[0m function. Please import [33mnegate[0m from module [33mPrelude[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2109-negate.purs b/tests/purs/failing/2109-negate.purs
new file mode 100644
index 0000000000..f7dbd1116a
--- /dev/null
+++ b/tests/purs/failing/2109-negate.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith UnknownName
+module Main where
+
+x = -5
diff --git a/tests/purs/failing/2128-class.out b/tests/purs/failing/2128-class.out
new file mode 100644
index 0000000000..63e230a84f
--- /dev/null
+++ b/tests/purs/failing/2128-class.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/2128-class.purs:5:15 - 5:18 (line 5, column 15 - line 5, column 18)
+
+ Unable to parse module:
+ Unexpected token '!!!'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2128-instance.out b/tests/purs/failing/2128-instance.out
new file mode 100644
index 0000000000..9b90fd6fba
--- /dev/null
+++ b/tests/purs/failing/2128-instance.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/2128-instance.purs:8:9 - 8:12 (line 8, column 9 - line 8, column 12)
+
+ Unable to parse module:
+ Unexpected token '!!!'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2197-shouldFail.out b/tests/purs/failing/2197-shouldFail.out
new file mode 100644
index 0000000000..21a39aeb3d
--- /dev/null
+++ b/tests/purs/failing/2197-shouldFail.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2197-shouldFail.purs:9:6 - 9:12 (line 9, column 6 - line 9, column 12)
+
+ Conflicting definitions are in scope for type [33mNumber[0m from the following modules:
+
+ [33mMain[0m
+ [33mPrim[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2197-shouldFail2.out b/tests/purs/failing/2197-shouldFail2.out
new file mode 100644
index 0000000000..6036f08bfb
--- /dev/null
+++ b/tests/purs/failing/2197-shouldFail2.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2197-shouldFail2.purs:6:6 - 6:12 (line 6, column 6 - line 6, column 12)
+
+ Unknown type [33mNumber[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2378.out b/tests/purs/failing/2378.out
new file mode 100644
index 0000000000..445fc10d01
--- /dev/null
+++ b/tests/purs/failing/2378.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2378.purs:6:1 - 6:25 (line 6, column 1 - line 6, column 25)
+
+ Orphan instance [33mfooX[0m found for
+ [33m [0m
+ [33m Lib.Foo "x"[0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mLib[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Lib.Foo "x"[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2379.out b/tests/purs/failing/2379.out
new file mode 100644
index 0000000000..96e9e7b248
--- /dev/null
+++ b/tests/purs/failing/2379.out
@@ -0,0 +1,31 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2379.purs:6:8 - 6:19 (line 6, column 8 - line 6, column 19)
+
+ No type class instance was found for class
+ [33m [0m
+ [33m Lib.Y[0m
+ [33m [0m
+ because the class was not in scope. Perhaps it was not exported.
+
+while solving type class constraint
+[33m [0m
+[33m Lib.Y Int[0m
+[33m [0m
+while applying a function [33mx[0m
+ of type [33mX t0 => t0 -> String[0m
+ to argument [33m[ 1[0m
+ [33m, 2[0m
+ [33m, 3[0m
+ [33m] [0m
+while inferring the type of [33mx [ 1[0m
+ [33m , 2[0m
+ [33m , 3[0m
+ [33m ] [0m
+in value declaration [33mtest[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownClass.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2434.out b/tests/purs/failing/2434.out
new file mode 100644
index 0000000000..d2e2671399
--- /dev/null
+++ b/tests/purs/failing/2434.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/2434.purs:5:13 - 5:14 (line 5, column 13 - line 5, column 14)
+
+ Unable to parse module:
+ Illegal astral code point in character literal
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2534.out b/tests/purs/failing/2534.out
new file mode 100644
index 0000000000..14b4ad800d
--- /dev/null
+++ b/tests/purs/failing/2534.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2534.purs:8:14 - 8:18 (line 8, column 14 - line 8, column 18)
+
+ An infinite type was inferred for an expression:
+ [33m [0m
+ [33m Array t0[0m
+ [33m [0m
+
+while trying to match type [33mArray t1[0m
+ with type [33mt0[0m
+while checking that expression [33mxs[0m
+ has type [33mt0[0m
+in value declaration [33mfoo[0m
+
+where [33mt1[0m is an unknown type
+ [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/InfiniteType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2542.out b/tests/purs/failing/2542.out
new file mode 100644
index 0000000000..29c9769f23
--- /dev/null
+++ b/tests/purs/failing/2542.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2542.purs:8:16 - 8:17 (line 8, column 16 - line 8, column 17)
+
+ Type variable [33ma[0m is undefined.
+
+while inferring the kind of [33ma[0m
+while checking that type [33ma[0m
+ has kind [33mType[0m
+while inferring the kind of [33mArray a[0m
+while checking that expression [33mbar [0m
+ [33m where [0m
+ [33m bar = [][0m
+ has type [33mArray a0[0m
+in value declaration [33mfoo[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 7, column 7 - line 7, column 10)
+
+See https://github.com/purescript/documentation/blob/master/errors/UndefinedTypeVariable.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2567.out b/tests/purs/failing/2567.out
new file mode 100644
index 0000000000..76c6520f82
--- /dev/null
+++ b/tests/purs/failing/2567.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2567.purs:7:8 - 7:67 (line 7, column 8 - line 7, column 67)
+
+ Custom error:
+
+ This constraint should be checked
+
+
+while checking that type [33mFail (Text "This constraint should be checked") => Int[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33m0[0m
+ has type [33mInt[0m
+in value declaration [33mfoo[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2601.out b/tests/purs/failing/2601.out
new file mode 100644
index 0000000000..3c5e3d4270
--- /dev/null
+++ b/tests/purs/failing/2601.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2601.purs:6:12 - 6:15 (line 6, column 12 - line 6, column 15)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type -> Type[0m
+ [33m [0m
+
+while checking that type [33mInt[0m
+ has kind [33mType -> Type[0m
+while inferring the kind of [33mSyn Int[0m
+in value declaration [33mval[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2616.out b/tests/purs/failing/2616.out
new file mode 100644
index 0000000000..1307985fbc
--- /dev/null
+++ b/tests/purs/failing/2616.out
@@ -0,0 +1,28 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/2616.purs:9:1 - 9:38 (line 9, column 1 - line 9, column 38)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.RowList.RowToList r1[0m
+ [33m t2[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Data.Ord.Ord (Record r1)[0m
+[33m [0m
+while applying a function [33mcompare[0m
+ of type [33mOrd t0 => t0 -> t0 -> Ordering[0m
+ to argument [33m$l2[0m
+while inferring the type of [33mcompare $l2[0m
+in value declaration [33mordFoo[0m
+
+where [33mr1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mt0[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2806.out b/tests/purs/failing/2806.out
new file mode 100644
index 0000000000..f5daaaf170
--- /dev/null
+++ b/tests/purs/failing/2806.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mX[0m
+at tests/purs/failing/2806.purs:6:1 - 6:29 (line 6, column 1 - line 6, column 29)
+
+ A case expression could not be determined to cover all inputs.
+ The following additional cases are required to cover all inputs:
+
+ [33m_[0m
+
+ Alternatively, add a Partial constraint to the type of the enclosing value.
+
+while checking that type [33mPartial => t1[0m
+ is at least as general as type [33ma0[0m
+while checking that expression [33mcase e of [0m
+ [33m e | L x <- e -> x[0m
+ has type [33ma0[0m
+in value declaration [33mg[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2874-forall.out b/tests/purs/failing/2874-forall.out
new file mode 100644
index 0000000000..d6e86aff7d
--- /dev/null
+++ b/tests/purs/failing/2874-forall.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/2874-forall.purs:5:24 - 5:30 (line 5, column 24 - line 5, column 30)
+
+ Unable to parse module:
+ Unexpected token 'forall'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2874-forall2.out b/tests/purs/failing/2874-forall2.out
new file mode 100644
index 0000000000..60a5d2be68
--- /dev/null
+++ b/tests/purs/failing/2874-forall2.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/2874-forall2.purs:5:12 - 5:18 (line 5, column 12 - line 5, column 18)
+
+ Unable to parse module:
+ Unexpected token 'forall'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2874-wildcard.out b/tests/purs/failing/2874-wildcard.out
new file mode 100644
index 0000000000..6298b37122
--- /dev/null
+++ b/tests/purs/failing/2874-wildcard.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/2874-wildcard.purs:10:25 - 10:26 (line 10, column 25 - line 10, column 26)
+
+ Unable to parse module:
+ Unexpected wildcard in type; type wildcards are only allowed in value annotations
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/2947.out b/tests/purs/failing/2947.out
new file mode 100644
index 0000000000..f6019f6390
--- /dev/null
+++ b/tests/purs/failing/2947.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/2947.purs:10:1 - 10:1 (line 10, column 1 - line 10, column 1)
+
+ Unable to parse module:
+ Unexpected or mismatched indentation
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3077.out b/tests/purs/failing/3077.out
new file mode 100644
index 0000000000..15fe3f3d33
--- /dev/null
+++ b/tests/purs/failing/3077.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3077.purs:11:14 - 11:38 (line 11, column 14 - line 11, column 38)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Symbol[0m
+ [33m [0m
+
+while trying to match type [33mSProxy[0m
+ with type [33mt0[0m
+while checking that expression [33mSProxy[0m
+ has type [33mt0 t1[0m
+in value declaration [33mwrong[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3077.purs b/tests/purs/failing/3077.purs
new file mode 100644
index 0000000000..b1564d73b6
--- /dev/null
+++ b/tests/purs/failing/3077.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+data TProxy (t :: Type) = TProxy
+data SProxy (s :: Symbol) = SProxy
+
+put :: forall proxy a. proxy a -> TProxy a
+put _ = TProxy
+
+--wrong :: TProxy "apple"
+wrong = put (SProxy :: SProxy "apple")
diff --git a/tests/purs/failing/3132.out b/tests/purs/failing/3132.out
new file mode 100644
index 0000000000..22643d23e5
--- /dev/null
+++ b/tests/purs/failing/3132.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3132.purs:2:1 - 18:13 (line 2, column 1 - line 18, column 13)
+
+ An export for [33mclass C3[0m requires the following to also be exported:
+
+ [33mclass C1[0m
+ [33mclass C2[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3275-BindingGroupErrorPos.out b/tests/purs/failing/3275-BindingGroupErrorPos.out
new file mode 100644
index 0000000000..99207ba3b2
--- /dev/null
+++ b/tests/purs/failing/3275-BindingGroupErrorPos.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mBindingGroupErrorPos[0m
+at tests/purs/failing/3275-BindingGroupErrorPos.purs:11:17 - 11:23 (line 11, column 17 - line 11, column 23)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type -> t3[0m
+ [33m [0m
+
+while checking that type [33mResult[0m
+ has kind [33mType -> t0[0m
+while inferring the kind of [33mResult String[0m
+while inferring the kind of [33mInt -> Result String[0m
+in binding group wrong
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3275-DataBindingGroupErrorPos.out b/tests/purs/failing/3275-DataBindingGroupErrorPos.out
new file mode 100644
index 0000000000..1039d74617
--- /dev/null
+++ b/tests/purs/failing/3275-DataBindingGroupErrorPos.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mDataBindingGroupErrorPos[0m
+at tests/purs/failing/3275-DataBindingGroupErrorPos.purs:7:19 - 7:22 (line 7, column 19 - line 7, column 22)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m t10 -> t11[0m
+ [33m [0m
+
+while checking that type [33mBar a[0m
+ has kind [33mt0 -> t1[0m
+while inferring the kind of [33mBar a a[0m
+in data binding group Bar, Foo
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3329.out b/tests/purs/failing/3329.out
new file mode 100644
index 0000000000..d176c58889
--- /dev/null
+++ b/tests/purs/failing/3329.out
@@ -0,0 +1,28 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3329.purs:24:8 - 24:11 (line 24, column 8 - line 24, column 11)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.Inject g0 [0m
+ [33m (Either f1 g0)[0m
+ [33m [0m
+ The following instance partially overlaps the above constraint, which means the rest of its instance chain will not be considered:
+
+ [33mMain.injectLeft[0m
+
+
+while checking that type [33mforall (@f :: Type) (@g :: Type). Inject f g => f -> g[0m
+ is at least as general as type [33mg0 -> Either f1 g0[0m
+while checking that expression [33minj[0m
+ has type [33mg0 -> Either f1 g0[0m
+in value declaration [33minjR[0m
+
+where [33mf1[0m is a rigid type variable
+ bound at (line 24, column 8 - line 24, column 11)
+ [33mg0[0m is a rigid type variable
+ bound at (line 24, column 8 - line 24, column 11)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3329.purs b/tests/purs/failing/3329.purs
new file mode 100644
index 0000000000..7beb876929
--- /dev/null
+++ b/tests/purs/failing/3329.purs
@@ -0,0 +1,24 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Data.Either (Either(..))
+import Data.Maybe (Maybe(..))
+
+class Inject f g where
+ inj :: f -> g
+ prj :: g -> Maybe f
+
+instance injectRefl :: Inject x x where
+ inj x = x
+ prj x = Just x
+else instance injectLeft :: Inject l (Either l r) where
+ inj x = Left x
+ prj (Left x) = Just x
+ prj _ = Nothing
+else instance injectRight :: Inject x r => Inject x (Either l r) where
+ inj x = Right (inj x)
+ prj (Right x) = prj x
+ prj _ = Nothing
+
+injR :: forall f g. g -> Either f g
+injR = inj
diff --git a/tests/purs/failing/3335-TypeOpAssociativityError.out b/tests/purs/failing/3335-TypeOpAssociativityError.out
new file mode 100644
index 0000000000..7d6ecb7891
--- /dev/null
+++ b/tests/purs/failing/3335-TypeOpAssociativityError.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/3335-TypeOpAssociativityError.purs:6:1 - 6:33 (line 6, column 1 - line 6, column 33)
+
+ Cannot parse an expression that uses multiple instances of the non-associative operator [33mMain.(>>)[0m.
+ Use parentheses to resolve this ambiguity.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/NonAssociativeError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3405.out b/tests/purs/failing/3405.out
new file mode 100644
index 0000000000..551254cbc0
--- /dev/null
+++ b/tests/purs/failing/3405.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3405.purs:8:1 - 8:43 (line 8, column 1 - line 8, column 43)
+
+ Orphan instance [33meqSomething[0m found for
+ [33m [0m
+ [33m Data.Eq.Eq Int[0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mData.Eq[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Data.Eq.Eq Something[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3405.purs b/tests/purs/failing/3405.purs
index de7ab7ca02..431e5a3dee 100644
--- a/tests/purs/failing/3405.purs
+++ b/tests/purs/failing/3405.purs
@@ -1,4 +1,4 @@
--- @shouldFailWith CannotFindDerivingType
+-- @shouldFailWith OrphanInstance
module Main where
import Prelude
diff --git a/tests/purs/failing/3453.out b/tests/purs/failing/3453.out
new file mode 100644
index 0000000000..e5bcd23b41
--- /dev/null
+++ b/tests/purs/failing/3453.out
@@ -0,0 +1,11 @@
+Error found:
+at tests/purs/failing/3453.purs:6:1 - 6:11 (line 6, column 1 - line 6, column 11)
+
+ A cycle appears in the definition of type synonym [33mS[0m
+ Cycles are disallowed because they can lead to loops in the type checker.
+ Consider using a 'newtype' instead.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInTypeSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3453.purs b/tests/purs/failing/3453.purs
new file mode 100644
index 0000000000..8bc3d6cbe7
--- /dev/null
+++ b/tests/purs/failing/3453.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith CycleInTypeSynonym
+module Main where
+
+import Data.Newtype (class Newtype)
+
+type S = S
+newtype Z = Z S
+derive instance newtypeZ :: Newtype Z _
diff --git a/tests/purs/failing/3510.out b/tests/purs/failing/3510.out
new file mode 100644
index 0000000000..d1a9d57fc9
--- /dev/null
+++ b/tests/purs/failing/3510.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3510.purs:7:1 - 7:28 (line 7, column 1 - line 7, column 28)
+
+ Type class instance head is invalid due to use of type
+ [33m [0m
+ [33m ()[0m
+ [33m [0m
+ All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form, unless the type is fully determined by other type class arguments via functional dependencies.
+
+in type class instance
+[33m [0m
+[33m Data.Eq.Eq T[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidInstanceHead.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3510.purs b/tests/purs/failing/3510.purs
new file mode 100644
index 0000000000..aa608ccd41
--- /dev/null
+++ b/tests/purs/failing/3510.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith InvalidInstanceHead
+module Main where
+
+import Prelude (class Eq)
+
+type T = {}
+derive instance eqT :: Eq T
diff --git a/tests/purs/failing/3531-2.out b/tests/purs/failing/3531-2.out
new file mode 100644
index 0000000000..dcb39d4592
--- /dev/null
+++ b/tests/purs/failing/3531-2.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3531-2.purs:22:11 - 22:22 (line 22, column 11 - line 22, column 22)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.C (X t2 Int)[0m
+ [33m [0m
+ The following instance partially overlaps the above constraint, which means the rest of its instance chain will not be considered:
+
+ [33mMain.cx[0m
+
+ The instance head contains unknown type variables. Consider adding a type annotation.
+
+while applying a function [33mthing[0m
+ of type [33mC t0 => t0 -> t0[0m
+ to argument [33mtest1[0m
+while inferring the type of [33mthing test1[0m
+in value declaration [33mtest2[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3531-2.purs b/tests/purs/failing/3531-2.purs
new file mode 100644
index 0000000000..ed20e5f1cc
--- /dev/null
+++ b/tests/purs/failing/3531-2.purs
@@ -0,0 +1,23 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Prim.TypeError (class Fail, Text)
+
+class C x where
+ thing :: x -> x
+
+data X a b = X
+
+test1 :: forall a. X a Int
+test1 = X
+
+instance cx :: C (X x x) where
+ thing x = x
+
+else instance cxFail :: Fail (Text "Fell through") => C (X x y) where
+ thing x = x
+
+test2 :: Boolean
+test2 = do
+ let X = thing test1
+ true
diff --git a/tests/purs/failing/3531-3.out b/tests/purs/failing/3531-3.out
new file mode 100644
index 0000000000..8f52a662cc
--- /dev/null
+++ b/tests/purs/failing/3531-3.out
@@ -0,0 +1,32 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3531-3.purs:22:11 - 22:22 (line 22, column 11 - line 22, column 22)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.C (X [0m
+ [33m { foo :: Int[0m
+ [33m | t1 [0m
+ [33m } [0m
+ [33m { foo :: Int[0m
+ [33m } [0m
+ [33m ) [0m
+ [33m [0m
+ The following instance partially overlaps the above constraint, which means the rest of its instance chain will not be considered:
+
+ [33mMain.cx[0m
+
+ The instance head contains unknown type variables. Consider adding a type annotation.
+
+while applying a function [33mthing[0m
+ of type [33mC t0 => t0 -> t0[0m
+ to argument [33mtest1[0m
+while inferring the type of [33mthing test1[0m
+in value declaration [33mtest2[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3531-3.purs b/tests/purs/failing/3531-3.purs
new file mode 100644
index 0000000000..5d3704101c
--- /dev/null
+++ b/tests/purs/failing/3531-3.purs
@@ -0,0 +1,23 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Prim.TypeError (class Fail, Text)
+
+class C x where
+ thing :: x -> x
+
+data X a b = X
+
+test1 :: forall r. X { foo :: Int | r } { foo :: Int }
+test1 = X
+
+instance cx :: C (X x x) where
+ thing x = x
+
+else instance cxFail :: Fail (Text "Fell through") => C (X x y) where
+ thing x = x
+
+test2 :: Boolean
+test2 = do
+ let X = thing test1
+ true
diff --git a/tests/purs/failing/3531-4.out b/tests/purs/failing/3531-4.out
new file mode 100644
index 0000000000..04b5b756d5
--- /dev/null
+++ b/tests/purs/failing/3531-4.out
@@ -0,0 +1,33 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3531-4.purs:21:7 - 21:27 (line 21, column 7 - line 21, column 27)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.C a4[0m
+ [33m b5[0m
+ [33m [0m
+ The following instances partially overlap the above constraint, which means the rest of their instance chains will not be considered:
+
+ [33mMain.c1[0m
+ [33mMain.c3[0m
+
+
+while applying a function [33mc[0m
+ of type [33mC @t0 @t1 t2 t3 => Proxy @t0 t2 -> Proxy @t1 t3 -> Boolean[0m
+ to argument [33mProxy[0m
+while inferring the type of [33mc Proxy[0m
+in value declaration [33mfn[0m
+
+where [33ma4[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mb5[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+ [33mt3[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3531-4.purs b/tests/purs/failing/3531-4.purs
new file mode 100644
index 0000000000..46c73fd52e
--- /dev/null
+++ b/tests/purs/failing/3531-4.purs
@@ -0,0 +1,21 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+data Proxy a = Proxy
+
+class C a b where
+ c :: Proxy a -> Proxy b -> Boolean
+
+instance c1 :: C String String where
+ c _ _ = true
+else instance c2 :: C String a where
+ c _ _ = false
+
+instance c3 :: C Int Int where
+ c _ _ = true
+else instance c4 :: C Int a where
+ c _ _ = false
+
+fn :: forall a b. Proxy a -> Proxy b -> Int
+fn _ _ = 42 where
+ x = c (Proxy :: Proxy a) (Proxy :: Proxy b)
diff --git a/tests/purs/failing/3531-5.out b/tests/purs/failing/3531-5.out
new file mode 100644
index 0000000000..f82fb0d6a1
--- /dev/null
+++ b/tests/purs/failing/3531-5.out
@@ -0,0 +1,32 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3531-5.purs:16:7 - 16:27 (line 16, column 7 - line 16, column 27)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.C a4[0m
+ [33m b5[0m
+ [33m [0m
+ The following instance partially overlaps the above constraint, which means the rest of its instance chain will not be considered:
+
+ instance in module [33mMain[0m with type [33mforall a. C String (Array a)[0m (line 9, column 1 - line 10, column 15)
+
+
+while applying a function [33mc[0m
+ of type [33mC @t0 @t1 t2 t3 => Proxy @t0 t2 -> Proxy @t1 t3 -> Boolean[0m
+ to argument [33mProxy[0m
+while inferring the type of [33mc Proxy[0m
+in value declaration [33mfn[0m
+
+where [33ma4[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mb5[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+ [33mt3[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3531-5.purs b/tests/purs/failing/3531-5.purs
new file mode 100644
index 0000000000..5c19ed374e
--- /dev/null
+++ b/tests/purs/failing/3531-5.purs
@@ -0,0 +1,16 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+data Proxy a = Proxy
+
+class C a b where
+ c :: Proxy a -> Proxy b -> Boolean
+
+instance C String (Array a) where
+ c _ _ = true
+else instance c2 :: C String a where
+ c _ _ = false
+
+fn :: forall a b. Proxy a -> Proxy b -> Int
+fn _ _ = 42 where
+ x = c (Proxy :: Proxy a) (Proxy :: Proxy b)
diff --git a/tests/purs/failing/3531-6.out b/tests/purs/failing/3531-6.out
new file mode 100644
index 0000000000..f454d0679e
--- /dev/null
+++ b/tests/purs/failing/3531-6.out
@@ -0,0 +1,33 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3531-6.purs:21:7 - 21:27 (line 21, column 7 - line 21, column 27)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.C a4[0m
+ [33m b5[0m
+ [33m [0m
+ The following instances partially overlap the above constraint, which means the rest of their instance chains will not be considered:
+
+ instance in module [33mMain[0m with type [33mforall a. C String (Array a)[0m (line 9, column 1 - line 10, column 15)
+ instance in module [33mMain[0m with type [33mC Int Int[0m (line 14, column 1 - line 15, column 15)
+
+
+while applying a function [33mc[0m
+ of type [33mC @t0 @t1 t2 t3 => Proxy @t0 t2 -> Proxy @t1 t3 -> Boolean[0m
+ to argument [33mProxy[0m
+while inferring the type of [33mc Proxy[0m
+in value declaration [33mfn[0m
+
+where [33ma4[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mb5[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+ [33mt3[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3531-6.purs b/tests/purs/failing/3531-6.purs
new file mode 100644
index 0000000000..204ef158a1
--- /dev/null
+++ b/tests/purs/failing/3531-6.purs
@@ -0,0 +1,21 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+data Proxy a = Proxy
+
+class C a b where
+ c :: Proxy a -> Proxy b -> Boolean
+
+instance C String (Array a) where
+ c _ _ = true
+else instance c2 :: C String a where
+ c _ _ = false
+
+instance C Int Int where
+ c _ _ = true
+else instance c4 :: C Int a where
+ c _ _ = false
+
+fn :: forall a b. Proxy a -> Proxy b -> Int
+fn _ _ = 42 where
+ x = c (Proxy :: Proxy a) (Proxy :: Proxy b)
diff --git a/tests/purs/failing/3531.out b/tests/purs/failing/3531.out
new file mode 100644
index 0000000000..71e3f55972
--- /dev/null
+++ b/tests/purs/failing/3531.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3531.purs:16:7 - 16:27 (line 16, column 7 - line 16, column 27)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.C a2[0m
+ [33m [0m
+ The following instance partially overlaps the above constraint, which means the rest of its instance chain will not be considered:
+
+ [33mMain.c1[0m
+
+
+while applying a function [33mc[0m
+ of type [33mC @t0 t1 => Proxy @t0 t1 -> Boolean[0m
+ to argument [33mProxy[0m
+while inferring the type of [33mc Proxy[0m
+in value declaration [33mfn[0m
+
+where [33ma2[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3531.purs b/tests/purs/failing/3531.purs
new file mode 100644
index 0000000000..b7d28a2c96
--- /dev/null
+++ b/tests/purs/failing/3531.purs
@@ -0,0 +1,16 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+data Proxy a = Proxy
+
+class C a where
+ c :: Proxy a -> Boolean
+
+instance c1 :: C String where
+ c _ = true
+else instance c2 :: C a where
+ c _ = false
+
+fn :: forall a. Proxy a -> Int
+fn _ = 42 where
+ x = c (Proxy :: Proxy a)
diff --git a/tests/purs/failing/3549-a.out b/tests/purs/failing/3549-a.out
new file mode 100644
index 0000000000..f8062ff3d1
--- /dev/null
+++ b/tests/purs/failing/3549-a.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3549-a.purs:6:26 - 6:29 (line 6, column 26 - line 6, column 29)
+
+ Unknown type [33mTyp[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3549.out b/tests/purs/failing/3549.out
new file mode 100644
index 0000000000..da4a38f2ab
--- /dev/null
+++ b/tests/purs/failing/3549.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3549.purs:8:78 - 8:79 (line 8, column 78 - line 8, column 79)
+
+ Could not match kind
+ [33m [0m
+ [33m Type -> Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33mf[0m
+ has kind [33mType -> Type[0m
+while inferring the kind of [33mFunctor f[0m
+while inferring the kind of [33mFunctor f => (a -> b) -> f a -> f b[0m
+while inferring the kind of [33mforall (b :: Type). Functor f => (a -> b) -> f a -> f b[0m
+while inferring the kind of [33mforall (a :: Type) (b :: Type). Functor f => (a -> b) -> f a -> f b[0m
+while inferring the kind of [33mforall (f :: Type -> Type -> Type) (a :: Type) (b :: Type). Functor f => (a -> b) -> f a -> f b[0m
+in value declaration [33mmap'[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/365.out b/tests/purs/failing/365.out
new file mode 100644
index 0000000000..c24e5e19d0
--- /dev/null
+++ b/tests/purs/failing/365.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/365.purs:10:1 - 12:8 (line 10, column 1 - line 12, column 8)
+
+ The value of [33mcS[0m is undefined here, so this reference is not allowed.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3689.out b/tests/purs/failing/3689.out
new file mode 100644
index 0000000000..aa542205e3
--- /dev/null
+++ b/tests/purs/failing/3689.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/3689.purs:5:5 - 5:10 (line 5, column 5 - line 5, column 10)
+
+ Unable to parse module:
+ Unexpected quoted label in record pun, perhaps due to a missing ':'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3689.purs b/tests/purs/failing/3689.purs
new file mode 100644
index 0000000000..f11a5816e0
--- /dev/null
+++ b/tests/purs/failing/3689.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith ErrorParsingModule
+module Main where
+
+test =
+ { "bad"
+ }
diff --git a/tests/purs/failing/3701.out b/tests/purs/failing/3701.out
new file mode 100644
index 0000000000..cee399f617
--- /dev/null
+++ b/tests/purs/failing/3701.out
@@ -0,0 +1,64 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3701.purs:39:8 - 39:34 (line 39, column 8 - line 39, column 34)
+
+ Could not match type
+ [33m [0m
+ [33m ( ... )[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m ( thing1 :: String[0m
+ [33m ... [0m
+ [33m ) [0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Row.Nub ( thing1 :: String[0m
+[33m , thing1 :: String[0m
+[33m , thing2 :: Int [0m
+[33m ) [0m
+[33m ( thing1 :: String[0m
+[33m , thing1 :: String[0m
+[33m , thing2 :: Int [0m
+[33m ) [0m
+[33m [0m
+while applying a function [33mfooMerge[0m
+ of type [33mUnion @Type t0 [0m
+ [33m ( thing1 :: String [0m
+ [33m , thing2 :: Int [0m
+ [33m ) [0m
+ [33m ( thing1 :: String [0m
+ [33m , thing2 :: Int [0m
+ [33m | t0 [0m
+ [33m ) [0m
+ [33m => Nub @Type [0m
+ [33m ( thing1 :: String [0m
+ [33m , thing2 :: Int [0m
+ [33m | t0 [0m
+ [33m ) [0m
+ [33m ( thing1 :: String [0m
+ [33m , thing2 :: Int [0m
+ [33m | t0 [0m
+ [33m ) [0m
+ [33m => Record t0 [0m
+ [33m -> { thing1 :: String[0m
+ [33m , thing2 :: Int [0m
+ [33m | t0 [0m
+ [33m } [0m
+ to argument [33m{ thing1: "foo"[0m
+ [33m} [0m
+while checking that expression [33mfooMerge { thing1: "foo"[0m
+ [33m } [0m
+ has type [33m{ thing1 :: String[0m
+ [33m, thing1 :: String[0m
+ [33m, thing2 :: Int [0m
+ [33m} [0m
+in value declaration [33mfoo2[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3701.purs b/tests/purs/failing/3701.purs
new file mode 100644
index 0000000000..7ab525c55a
--- /dev/null
+++ b/tests/purs/failing/3701.purs
@@ -0,0 +1,39 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Row as Row
+
+merge
+ :: forall r1 r2 r3 r4
+ . Row.Union r1 r2 r3
+ => Row.Nub r3 r4
+ => Record r1
+ -> Record r2
+ -> Record r4
+merge r = merge r
+
+
+type FooRow r =
+ ( thing1 :: String
+ , thing2 :: Int
+ | r
+ )
+
+type AddedRow =
+ ( thing3 :: String )
+
+type AddedRow2 =
+ ( thing1 :: String )
+
+fooMerge :: forall addedRow.
+ Row.Union addedRow (FooRow ()) (FooRow addedRow) =>
+ Row.Nub (FooRow addedRow) (FooRow addedRow) =>
+ Record addedRow ->
+ Record (FooRow addedRow)
+fooMerge addedRow = merge addedRow {thing1: "foo", thing2: 1}
+
+foo1 :: Record (FooRow (AddedRow))
+foo1 = fooMerge { thing3: "foo" }
+
+foo2 :: Record (FooRow (AddedRow2))
+foo2 = fooMerge { thing1: "foo" }
diff --git a/tests/purs/failing/3765-kinds.out b/tests/purs/failing/3765-kinds.out
new file mode 100644
index 0000000000..138b69ba35
--- /dev/null
+++ b/tests/purs/failing/3765-kinds.out
@@ -0,0 +1,29 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3765-kinds.purs:7:28 - 7:29 (line 7, column 28 - line 7, column 29)
+
+ Could not match kind
+ [33m [0m
+ [33m ( a :: Int[0m
+ [33m | t11 [0m
+ [33m ) [0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m ( b :: Int[0m
+ [33m | t11 [0m
+ [33m ) [0m
+ [33m [0m
+
+while checking that type [33mx[0m
+ has kind [33m{ b :: Int[0m
+ [33m| t0 [0m
+ [33m} [0m
+while inferring the kind of [33mTricky x x[0m
+in type synonym [33mMkTricky[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3765-kinds.purs b/tests/purs/failing/3765-kinds.purs
new file mode 100644
index 0000000000..cff2cd9ca5
--- /dev/null
+++ b/tests/purs/failing/3765-kinds.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+data Tricky :: forall r. {a :: Int | r} -> {b :: Int | r} -> Type
+data Tricky x y = Tricky
+
+type MkTricky x = Tricky x x
diff --git a/tests/purs/failing/3765.out b/tests/purs/failing/3765.out
new file mode 100644
index 0000000000..1ae4deb72f
--- /dev/null
+++ b/tests/purs/failing/3765.out
@@ -0,0 +1,35 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3765.purs:6:23 - 6:24 (line 6, column 23 - line 6, column 24)
+
+ Could not match type
+ [33m [0m
+ [33m ( b :: Int[0m
+ [33m ... [0m
+ [33m | t0 [0m
+ [33m ) [0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m ( a :: Int[0m
+ [33m ... [0m
+ [33m | t0 [0m
+ [33m ) [0m
+ [33m [0m
+
+while trying to match type [33m{ b :: Int[0m
+ [33m| t0 [0m
+ [33m} [0m
+ with type [33mt1[0m
+while checking that expression [33mx[0m
+ has type [33m{ b :: Int[0m
+ [33m| t0 [0m
+ [33m} [0m
+in value declaration [33mmkTricky[0m
+
+where [33mt1[0m is an unknown type
+ [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3765.purs b/tests/purs/failing/3765.purs
new file mode 100644
index 0000000000..c58af85885
--- /dev/null
+++ b/tests/purs/failing/3765.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+data Tricky r = Tricky {a :: Int | r} {b :: Int | r}
+
+mkTricky x = Tricky x x
diff --git a/tests/purs/failing/3891.out b/tests/purs/failing/3891.out
new file mode 100644
index 0000000000..7aebfb1c40
--- /dev/null
+++ b/tests/purs/failing/3891.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/3891.purs:4:8 - 4:15 (line 4, column 8 - line 4, column 15)
+
+ Could not match type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m String -> t0[0m
+ [33m [0m
+
+while applying a function [33m"("[0m
+ of type [33mString[0m
+ to argument [33m")"[0m
+while inferring the type of [33m"(" ")"[0m
+in value declaration [33moops[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/3891.purs b/tests/purs/failing/3891.purs
new file mode 100644
index 0000000000..c9681fa328
--- /dev/null
+++ b/tests/purs/failing/3891.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+oops = "(" ")"
diff --git a/tests/purs/failing/4019-1.out b/tests/purs/failing/4019-1.out
new file mode 100644
index 0000000000..667e2d453e
--- /dev/null
+++ b/tests/purs/failing/4019-1.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4019-1.purs:26:21 - 26:24 (line 26, column 21 - line 26, column 24)
+
+ Could not match kind
+ [33m [0m
+ [33m K1[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m K2[0m
+ [33m [0m
+
+while trying to match type [33mIndexed @Type @K1 @K2 Array[0m
+ with type [33mt0[0m
+while checking that expression [33mfoo[0m
+ has type [33mt0 t1 t2 t3[0m
+in value declaration [33mbar[0m
+
+where [33mt0[0m is an unknown type
+ [33mt3[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4019-1.purs b/tests/purs/failing/4019-1.purs
new file mode 100644
index 0000000000..8b79a99084
--- /dev/null
+++ b/tests/purs/failing/4019-1.purs
@@ -0,0 +1,26 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+import Prelude
+
+newtype Indexed ∷ forall k1 k2 k3. (k1 → Type) → k2 → k3 → k1 → Type
+newtype Indexed m x y a = Indexed (m a)
+
+class IxFunctor ∷ ∀ ix. (ix → ix → Type → Type) → Constraint
+class IxFunctor f where
+ imap ∷ ∀ a b x y. (a → b) → f x y a → f x y b
+
+instance ixFunctorIndexed ∷ Functor m ⇒ IxFunctor (Indexed m) where
+ imap f (Indexed ma) = Indexed (map f ma)
+
+foreign import data K1 :: Type
+foreign import data K2 :: Type
+
+foreign import data D1 :: K1
+foreign import data D2 :: K2
+
+foo :: Indexed Array D1 D2 Int
+foo = Indexed [1]
+
+bar :: Indexed Array D1 D2 Int
+bar = imap identity foo
diff --git a/tests/purs/failing/4019-2.out b/tests/purs/failing/4019-2.out
new file mode 100644
index 0000000000..6b1ee3d2d2
--- /dev/null
+++ b/tests/purs/failing/4019-2.out
@@ -0,0 +1,28 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4019-2.purs:26:22 - 26:60 (line 26, column 22 - line 26, column 60)
+
+ Could not match kind
+ [33m [0m
+ [33m K1[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m K2[0m
+ [33m [0m
+
+while trying to match type [33mIndexed @Type @K1 @K2 Array[0m
+ with type [33mt0[0m
+while checking that expression [33mIndexed [ 1[0m
+ [33m ] [0m
+ has type [33mt0 t1 t2 t3[0m
+in value declaration [33mbar[0m
+
+where [33mt0[0m is an unknown type
+ [33mt3[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4019-2.purs b/tests/purs/failing/4019-2.purs
new file mode 100644
index 0000000000..f30ea61280
--- /dev/null
+++ b/tests/purs/failing/4019-2.purs
@@ -0,0 +1,26 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+import Prelude
+
+newtype Indexed ∷ forall k1 k2 k3. (k1 → Type) → k2 → k3 → k1 → Type
+newtype Indexed m x y a = Indexed (m a)
+
+class IxFunctor ∷ ∀ ix. (ix → ix → Type → Type) → Constraint
+class IxFunctor f where
+ imap ∷ ∀ a b x y. (a → b) → f x y a → f x y b
+
+instance ixFunctorIndexed ∷ Functor m ⇒ IxFunctor (Indexed m) where
+ imap f (Indexed ma) = Indexed (map f ma)
+
+foreign import data K1 :: Type
+foreign import data K2 :: Type
+
+foreign import data D1 :: K1
+foreign import data D2 :: K2
+
+foo :: Indexed Array D1 D2 Int
+foo = Indexed [1]
+
+bar :: Indexed Array D1 D2 Int
+bar = imap identity (Indexed [1] :: Indexed Array D1 D2 Int)
diff --git a/tests/purs/failing/4024-2.out b/tests/purs/failing/4024-2.out
new file mode 100644
index 0000000000..af53a798d9
--- /dev/null
+++ b/tests/purs/failing/4024-2.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4024-2.purs:10:8 - 10:13 (line 10, column 8 - line 10, column 13)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.Foo t2 [0m
+ [33m t3 [0m
+ [33m String[0m
+ [33m [0m
+ The instance head contains unknown type variables. Consider adding a type annotation.
+
+while applying a function [33mbar[0m
+ of type [33mFoo @t0 @t1 @Type t2 t3 String => Int -> String[0m
+ to argument [33m0[0m
+while checking that expression [33mbar 0[0m
+ has type [33mString[0m
+in value declaration [33mtest[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+ [33mt3[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4024-2.purs b/tests/purs/failing/4024-2.purs
new file mode 100644
index 0000000000..0a0cdaefa3
--- /dev/null
+++ b/tests/purs/failing/4024-2.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+class Foo a b c | a -> b c, b -> a c
+
+bar :: forall a b. Foo a b String => Int -> String
+bar _ = ""
+
+test :: String
+test = bar 0
+
diff --git a/tests/purs/failing/4024.out b/tests/purs/failing/4024.out
new file mode 100644
index 0000000000..15184fe83e
--- /dev/null
+++ b/tests/purs/failing/4024.out
@@ -0,0 +1,26 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4024.purs:10:8 - 10:13 (line 10, column 8 - line 10, column 13)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.Foo String[0m
+ [33m t2 [0m
+ [33m t3 [0m
+ [33m [0m
+
+while applying a function [33mbar[0m
+ of type [33mFoo @Type @t0 @t1 String t2 t3 => Int -> String[0m
+ to argument [33m0[0m
+while checking that expression [33mbar 0[0m
+ has type [33mString[0m
+in value declaration [33mtest[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+ [33mt3[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4024.purs b/tests/purs/failing/4024.purs
new file mode 100644
index 0000000000..3ee64b827c
--- /dev/null
+++ b/tests/purs/failing/4024.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+class Foo a b c | a -> b c, b -> a c
+
+bar :: forall a b. Foo String a b => Int -> String
+bar _ = ""
+
+test :: String
+test = bar 0
diff --git a/tests/purs/failing/4028.out b/tests/purs/failing/4028.out
new file mode 100644
index 0000000000..477c18364a
--- /dev/null
+++ b/tests/purs/failing/4028.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4028.purs:29:12 - 29:37 (line 29, column 12 - line 29, column 37)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.TLShow (S i2)[0m
+ [33m [0m
+ The following instance partially overlaps the above constraint, which means the rest of its instance chain will not be considered:
+
+ [33mMain.tlShow2[0m
+
+
+while applying a function [33mgo[0m
+ of type [33mTLShow @t0 t1 => Proxy @t0 t1 -> Int -> String[0m
+ to argument [33mProxy[0m
+while inferring the type of [33mgo Proxy[0m
+in value declaration [33mpeano[0m
+
+where [33mi2[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4028.purs b/tests/purs/failing/4028.purs
new file mode 100644
index 0000000000..590d85d42b
--- /dev/null
+++ b/tests/purs/failing/4028.purs
@@ -0,0 +1,29 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Prelude
+
+import Type.Proxy (Proxy(..))
+
+foreign import data Peano :: Type
+
+foreign import data Z :: Peano
+foreign import data S :: Peano -> Peano
+
+class TLShow :: forall k. k -> Constraint
+class TLShow i where
+ tlShow :: Proxy i -> String
+
+instance tlShow2 :: TLShow (S (S Z)) where
+ tlShow _ = "2"
+else instance tlShow0 :: TLShow Z where
+ tlShow _ = "0"
+else instance tlShowS :: TLShow x => TLShow (S x) where
+ tlShow _ = "S" <> tlShow (Proxy :: Proxy x)
+
+peano :: Int -> String
+peano = go (Proxy :: Proxy Z)
+ where
+ go :: forall i. TLShow i => Proxy i -> Int -> String
+ go p 0 = tlShow p
+ go _ n = go (Proxy :: Proxy (S i)) (n - 1)
diff --git a/tests/purs/failing/4158.out b/tests/purs/failing/4158.out
new file mode 100644
index 0000000000..9639711b3c
--- /dev/null
+++ b/tests/purs/failing/4158.out
@@ -0,0 +1,34 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4158.purs:9:10 - 9:11 (line 9, column 10 - line 9, column 11)
+
+ Could not match type
+ [33m [0m
+ [33m a1[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m b0[0m
+ [33m [0m
+
+while trying to match type [33m{ foo :: Int[0m
+ [33m| a1 [0m
+ [33m} [0m
+ with type [33m{ foo :: Int[0m
+ [33m| b0 [0m
+ [33m} [0m
+while checking that expression [33mr[0m
+ has type [33mMaybe [0m
+ [33m { foo :: Int[0m
+ [33m | b0 [0m
+ [33m } [0m
+in value declaration [33mevil[0m
+
+where [33ma1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mb0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4158.purs b/tests/purs/failing/4158.purs
new file mode 100644
index 0000000000..93e22ddfc8
--- /dev/null
+++ b/tests/purs/failing/4158.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prelude
+
+data Maybe a = Just a | Nothing
+
+evil :: forall a b. Maybe (Record (foo :: Int | a)) -> Maybe (Record (foo :: Int | b))
+evil r = r
diff --git a/tests/purs/failing/438.out b/tests/purs/failing/438.out
new file mode 100644
index 0000000000..cb02bdfa01
--- /dev/null
+++ b/tests/purs/failing/438.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/438.purs:15:11 - 15:25 (line 15, column 11 - line 15, column 25)
+
+ Type class instance for
+ [33m [0m
+ [33m Data.Eq.Eq (Array (Fix Array))[0m
+ [33m [0m
+ is possibly infinite.
+
+while solving type class constraint
+[33m [0m
+[33m Data.Eq.Eq (Fix Array)[0m
+[33m [0m
+while applying a function [33meq[0m
+ of type [33mEq t0 => t0 -> t0 -> Boolean[0m
+ to argument [33mIn [][0m
+while inferring the type of [33meq (In [])[0m
+in value declaration [33mexample[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/PossiblyInfiniteInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4382.out b/tests/purs/failing/4382.out
new file mode 100644
index 0000000000..2e3ccee3fc
--- /dev/null
+++ b/tests/purs/failing/4382.out
@@ -0,0 +1,55 @@
+Error 1 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/failing/4382.purs:10:7 - 10:14 (line 10, column 7 - line 10, column 14)
+
+ Unknown type class [33mRinku[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/failing/4382.purs:13:10 - 13:17 (line 13, column 10 - line 13, column 17)
+
+ Unknown type class [33mRinku[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+ or to contribute content related to this error.
+
+Error 3 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/failing/4382.purs:16:10 - 16:17 (line 16, column 10 - line 16, column 17)
+
+ Unknown type class [33mRinku[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+ or to contribute content related to this error.
+
+Error 4 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/failing/4382.purs:18:17 - 18:28 (line 18, column 17 - line 18, column 28)
+
+ Unknown type class [33mRinku[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+ or to contribute content related to this error.
+
+Error 5 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/failing/4382.purs:20:25 - 20:36 (line 20, column 25 - line 20, column 36)
+
+ Unknown type class [33mRinku[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4382.purs b/tests/purs/failing/4382.purs
new file mode 100644
index 0000000000..f1ebae9da0
--- /dev/null
+++ b/tests/purs/failing/4382.purs
@@ -0,0 +1,20 @@
+-- @shouldFailWith UnknownName
+-- @shouldFailWith UnknownName
+-- @shouldFailWith UnknownName
+-- @shouldFailWith UnknownName
+-- @shouldFailWith UnknownName
+module Main where
+
+newtype T a = T a
+
+class Rinku a <= Maho a where
+ tPose :: a -> a
+
+instance Rinku a => Maho a where
+ tPose = \a -> a
+
+instance Rinku a
+
+derive instance Rinku (T a)
+
+derive newtype instance Rinku (T a)
diff --git a/tests/purs/failing/4408Acyclic.out b/tests/purs/failing/4408Acyclic.out
new file mode 100644
index 0000000000..b5decae42a
--- /dev/null
+++ b/tests/purs/failing/4408Acyclic.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4408Acyclic.purs:16:9 - 16:14 (line 16, column 9 - line 16, column 14)
+
+ Hole '[33mhelp[0m' has the inferred type
+ [33m [0m
+ [33m Int -> K[0m
+ [33m [0m
+ You could substitute the hole with one of these values:
+ [33m [0m
+ [33m Main.aRinku :: Int -> K [0m
+ [33m Main.cMuni :: Int -> K [0m
+ [33m Safe.Coerce.coerce :: forall a b. Coercible a b => a -> b[0m
+ [33m Unsafe.Coerce.unsafeCoerce :: forall a b. a -> b [0m
+ [33m Main.K :: Int -> K [0m
+ [33m [0m
+
+in value declaration [33mbMaho[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4408Acyclic.purs b/tests/purs/failing/4408Acyclic.purs
new file mode 100644
index 0000000000..df5a7ea8e3
--- /dev/null
+++ b/tests/purs/failing/4408Acyclic.purs
@@ -0,0 +1,22 @@
+-- @shouldFailWith HoleInferredType
+module Main where
+
+-- Expected:
+--
+-- aRinku+cMuni -> bMaho -> dRei
+--
+-- Both aRinku and cMuni is suggested
+
+newtype K = K Int
+
+aRinku :: Int -> K
+aRinku = K
+
+bMaho :: K
+bMaho = ?help 0
+
+cMuni :: Int -> K
+cMuni = K
+
+dRei :: Int -> K
+dRei _ = bMaho
diff --git a/tests/purs/failing/4408AcyclicRecursive.out b/tests/purs/failing/4408AcyclicRecursive.out
new file mode 100644
index 0000000000..fbfe1db8c8
--- /dev/null
+++ b/tests/purs/failing/4408AcyclicRecursive.out
@@ -0,0 +1,23 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4408AcyclicRecursive.purs:17:11 - 17:16 (line 17, column 11 - line 17, column 16)
+
+ Hole '[33mhelp[0m' has the inferred type
+ [33m [0m
+ [33m Int -> K[0m
+ [33m [0m
+ You could substitute the hole with one of these values:
+ [33m [0m
+ [33m Main.aRinku :: Int -> K [0m
+ [33m Main.bMaho :: Int -> K [0m
+ [33m Main.cMuni :: Int -> K [0m
+ [33m Safe.Coerce.coerce :: forall a b. Coercible a b => a -> b[0m
+ [33m Unsafe.Coerce.unsafeCoerce :: forall a b. a -> b [0m
+ [33m Main.K :: Int -> K [0m
+ [33m [0m
+
+in value declaration [33mbMaho[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4408AcyclicRecursive.purs b/tests/purs/failing/4408AcyclicRecursive.purs
new file mode 100644
index 0000000000..c4d7ad140b
--- /dev/null
+++ b/tests/purs/failing/4408AcyclicRecursive.purs
@@ -0,0 +1,23 @@
+-- @shouldFailWith HoleInferredType
+module Main where
+
+-- Expected:
+--
+-- aRinku+cMuni -> bMaho -> dRei
+--
+-- aRinku, cMuni, and bMaho are all suggested.
+-- bMaho can be aware of itself during checking.
+
+newtype K = K Int
+
+aRinku :: Int -> K
+aRinku = K
+
+bMaho :: Int -> K
+bMaho _ = ?help 0
+
+cMuni :: Int -> K
+cMuni = K
+
+dRei :: Int -> K
+dRei _ = bMaho
diff --git a/tests/purs/failing/4408Cyclic.out b/tests/purs/failing/4408Cyclic.out
new file mode 100644
index 0000000000..24aed1b1c1
--- /dev/null
+++ b/tests/purs/failing/4408Cyclic.out
@@ -0,0 +1,31 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4408Cyclic.purs:23:29 - 23:34 (line 23, column 29 - line 23, column 34)
+
+ Hole '[33mhelp[0m' has the inferred type
+ [33m [0m
+ [33m Int -> K[0m
+ [33m [0m
+ You could substitute the hole with one of these values:
+ [33m [0m
+ [33m Main.aSaki :: Int -> K [0m
+ [33m Main.bNoa :: forall a. a -> K [0m
+ [33m Main.cTowa :: forall a. a -> K [0m
+ [33m Main.eSaki :: Int -> K [0m
+ [33m Safe.Coerce.coerce :: forall a b. Coercible a b => a -> b[0m
+ [33m Unsafe.Coerce.unsafeCoerce :: forall a b. a -> b [0m
+ [33m Main.K :: Int -> K [0m
+ [33m [0m
+ in the following context:
+
+ a :: [33ma0[0m
+
+
+in binding group cTowa, bNoa
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4408Cyclic.purs b/tests/purs/failing/4408Cyclic.purs
new file mode 100644
index 0000000000..96d15e4532
--- /dev/null
+++ b/tests/purs/failing/4408Cyclic.purs
@@ -0,0 +1,29 @@
+-- @shouldFailWith HoleInferredType
+module Main where
+
+-- Expected:
+--
+-- aSaki/eSaki -> bNoa~cTowa -> dIbuki
+--
+-- Only aSaki/eSaki, bNoa, and cTowa is suggested.
+--
+-- The mutual recursion between bNoa and cTowa
+-- ensures they exist "at the same time". dIbuki
+-- depends on cTowa, so it's checked much later.
+
+newtype K = K Int
+
+aSaki :: Int -> K
+aSaki = K
+
+bNoa :: forall a. a -> K
+bNoa a = let _ = cTowa a in K 0
+
+cTowa :: forall a. a -> K
+cTowa a = let _ = bNoa a in ?help 0
+
+dIbuki :: Int -> K
+dIbuki = bNoa
+
+eSaki :: Int -> K
+eSaki = K
diff --git a/tests/purs/failing/4408CyclicTail.out b/tests/purs/failing/4408CyclicTail.out
new file mode 100644
index 0000000000..9dfe2fa39d
--- /dev/null
+++ b/tests/purs/failing/4408CyclicTail.out
@@ -0,0 +1,26 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4408CyclicTail.purs:22:11 - 22:16 (line 22, column 11 - line 22, column 16)
+
+ Hole '[33mhelp[0m' has the inferred type
+ [33m [0m
+ [33m Int -> K[0m
+ [33m [0m
+ You could substitute the hole with one of these values:
+ [33m [0m
+ [33m Main.aKyoko :: Int -> K [0m
+ [33m Main.bShinobu :: forall a. a -> K [0m
+ [33m Main.cEsora :: forall a. a -> K [0m
+ [33m Main.dYuka :: Int -> K [0m
+ [33m Main.eShinobu :: forall a. a -> K [0m
+ [33m Main.fEsora :: forall a. a -> K [0m
+ [33m Safe.Coerce.coerce :: forall a b. Coercible a b => a -> b[0m
+ [33m Unsafe.Coerce.unsafeCoerce :: forall a b. a -> b [0m
+ [33m Main.K :: Int -> K [0m
+ [33m [0m
+
+in value declaration [33mdYuka[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4408CyclicTail.purs b/tests/purs/failing/4408CyclicTail.purs
new file mode 100644
index 0000000000..17347d43b0
--- /dev/null
+++ b/tests/purs/failing/4408CyclicTail.purs
@@ -0,0 +1,28 @@
+-- @shouldFailWith HoleInferredType
+module Main where
+
+-- Expected:
+--
+-- aKyoko -> bShinobu~cEsora/eShinobu~fEsora -> dYuka
+--
+-- All are suggested, as dYuka is also recursive.
+
+newtype K = K Int
+
+aKyoko :: Int -> K
+aKyoko = K
+
+bShinobu :: forall a. a -> K
+bShinobu a = let _ = cEsora a in K 0
+
+cEsora :: forall a. a -> K
+cEsora a = let _ = bShinobu a in K 0
+
+dYuka :: Int -> K
+dYuka _ = ?help 0
+
+eShinobu :: forall a. a -> K
+eShinobu a = let _ = fEsora a in K 0
+
+fEsora :: forall a. a -> K
+fEsora a = let _ = eShinobu a in K 0
diff --git a/tests/purs/failing/4408CyclicTriple.out b/tests/purs/failing/4408CyclicTriple.out
new file mode 100644
index 0000000000..d6d0925b8a
--- /dev/null
+++ b/tests/purs/failing/4408CyclicTriple.out
@@ -0,0 +1,32 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4408CyclicTriple.purs:22:33 - 22:38 (line 22, column 33 - line 22, column 38)
+
+ Hole '[33mhelp[0m' has the inferred type
+ [33m [0m
+ [33m Int -> K[0m
+ [33m [0m
+ You could substitute the hole with one of these values:
+ [33m [0m
+ [33m Main.aHaruna :: Int -> K [0m
+ [33m Main.bMiyu :: forall a. a -> K [0m
+ [33m Main.cKurumi :: forall a. a -> K [0m
+ [33m Main.dMiiko :: forall a. a -> K [0m
+ [33m Main.eHaruna :: Int -> K [0m
+ [33m Safe.Coerce.coerce :: forall a b. Coercible a b => a -> b[0m
+ [33m Unsafe.Coerce.unsafeCoerce :: forall a b. a -> b [0m
+ [33m Main.K :: Int -> K [0m
+ [33m [0m
+ in the following context:
+
+ a :: [33ma0[0m
+
+
+in binding group dMiiko, cKurumi, bMiyu
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4408CyclicTriple.purs b/tests/purs/failing/4408CyclicTriple.purs
new file mode 100644
index 0000000000..d0b3d35a80
--- /dev/null
+++ b/tests/purs/failing/4408CyclicTriple.purs
@@ -0,0 +1,25 @@
+-- @shouldFailWith HoleInferredType
+module Main where
+
+-- Expected:
+--
+-- aHaruna/eHaruna -> bMiyu~cKurumi~dMiiko
+--
+-- All are suggested.
+
+newtype K = K Int
+
+aHaruna :: Int -> K
+aHaruna = K
+
+bMiyu :: forall a. a -> K
+bMiyu a = let _ = dMiiko a in K 0
+
+cKurumi :: forall a. a -> K
+cKurumi a = let _ = bMiyu a in K 0
+
+dMiiko :: forall a. a -> K
+dMiiko a = let _ = cKurumi a in ?help 0
+
+eHaruna :: Int -> K
+eHaruna = K
diff --git a/tests/purs/failing/4466.out b/tests/purs/failing/4466.out
new file mode 100644
index 0000000000..77b1cf3ea8
--- /dev/null
+++ b/tests/purs/failing/4466.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/4466.purs:15:44 - 15:67 (line 15, column 44 - line 15, column 67)
+
+ A case expression could not be determined to cover all inputs.
+ The following additional cases are required to cover all inputs:
+
+ [33m{ sound: Quack }[0m
+ [33m{ sound: Bark }[0m
+
+ Alternatively, add a Partial constraint to the type of the enclosing value.
+
+while checking that type [33mPartial => t0[0m
+ is at least as general as type [33mBoolean[0m
+while checking that expression [33mcase $0 of [0m
+ [33m { sound: Moo } -> true[0m
+ has type [33mBoolean[0m
+in value declaration [33manimalFunc[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4466.purs b/tests/purs/failing/4466.purs
new file mode 100644
index 0000000000..1c3d75db36
--- /dev/null
+++ b/tests/purs/failing/4466.purs
@@ -0,0 +1,16 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Prelude
+
+import Data.Array as Array
+import Data.Maybe (Maybe(..))
+
+data Sound = Moo | Quack | Bark
+
+type Animal = { sound :: Sound }
+
+animalFunc :: Array Animal -> Unit
+animalFunc animals
+ | Just { sound } <- animals # Array.find \{ sound: Moo } -> true = unit
+ | otherwise = unit
diff --git a/tests/purs/failing/4483.out b/tests/purs/failing/4483.out
new file mode 100644
index 0000000000..ccc01dfb59
--- /dev/null
+++ b/tests/purs/failing/4483.out
@@ -0,0 +1,14 @@
+Error found:
+at tests/purs/failing/4483.purs:10:1 - 11:24 (line 10, column 1 - line 11, column 24)
+
+ The following type class members have not been implemented:
+ [33mbar :: Int -> Int[0m
+
+in type class instance
+[33m [0m
+[33m Main.Foo Int[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingClassMember.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4483.purs b/tests/purs/failing/4483.purs
new file mode 100644
index 0000000000..970c7887e1
--- /dev/null
+++ b/tests/purs/failing/4483.purs
@@ -0,0 +1,13 @@
+-- @shouldFailWith MissingClassMember
+module Main where
+
+import Prim.TypeError
+
+class Foo t where
+ foo :: t -> String
+ bar :: Int -> t
+
+instance fooInt :: Fail (Text "can't use this") => Foo Int where
+ foo _ = "unreachable"
+ -- bar is missing; you can get away with an empty instance here but not a
+ -- half-implemented one
diff --git a/tests/purs/failing/4522.out b/tests/purs/failing/4522.out
new file mode 100644
index 0000000000..75e072315d
--- /dev/null
+++ b/tests/purs/failing/4522.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/4522.purs:4:11 - 4:12 (line 4, column 11 - line 4, column 12)
+
+ Unable to parse module:
+ Unexpected token '@'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/4522.purs b/tests/purs/failing/4522.purs
new file mode 100644
index 0000000000..78fc65f03a
--- /dev/null
+++ b/tests/purs/failing/4522.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith ErrorParsingModule
+module Main where
+
+class Foo @a
\ No newline at end of file
diff --git a/tests/purs/failing/881.out b/tests/purs/failing/881.out
new file mode 100644
index 0000000000..1ee0d7d23c
--- /dev/null
+++ b/tests/purs/failing/881.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/881.purs:10:1 - 13:12 (line 10, column 1 - line 13, column 12)
+
+ Multiple value declarations exist for [33mfoo[0m.
+
+in type class instance
+[33m [0m
+[33m Main.Foo X[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/DuplicateValueDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/AnonArgument1.out b/tests/purs/failing/AnonArgument1.out
new file mode 100644
index 0000000000..4cdd9330fa
--- /dev/null
+++ b/tests/purs/failing/AnonArgument1.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/AnonArgument1.purs:5:8 - 5:9 (line 5, column 8 - line 5, column 9)
+
+ An anonymous function argument appears in an invalid context.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/IncorrectAnonymousArgument.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/AnonArgument2.out b/tests/purs/failing/AnonArgument2.out
new file mode 100644
index 0000000000..84030b05d1
--- /dev/null
+++ b/tests/purs/failing/AnonArgument2.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/AnonArgument2.purs:7:16 - 7:17 (line 7, column 16 - line 7, column 17)
+
+ An anonymous function argument appears in an invalid context.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/IncorrectAnonymousArgument.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/AnonArgument3.out b/tests/purs/failing/AnonArgument3.out
new file mode 100644
index 0000000000..bc6413c8fc
--- /dev/null
+++ b/tests/purs/failing/AnonArgument3.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/AnonArgument3.purs:7:12 - 7:13 (line 7, column 12 - line 7, column 13)
+
+ An anonymous function argument appears in an invalid context.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/IncorrectAnonymousArgument.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/AnonArgument3.purs b/tests/purs/failing/AnonArgument3.purs
index 34f9814cf3..ac185fde17 100644
--- a/tests/purs/failing/AnonArgument3.purs
+++ b/tests/purs/failing/AnonArgument3.purs
@@ -1,5 +1,7 @@
-- @shouldFailWith IncorrectAnonymousArgument
module Main where
+import Prelude
+
test :: Int -> Int
test = 1 + _
diff --git a/tests/purs/failing/ApostropheModuleName.out b/tests/purs/failing/ApostropheModuleName.out
new file mode 100644
index 0000000000..06e1774bc6
--- /dev/null
+++ b/tests/purs/failing/ApostropheModuleName.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/ApostropheModuleName.purs:3:8 - 3:18 (line 3, column 8 - line 3, column 18)
+
+ Unable to parse module:
+ Invalid module name; underscores and primes are not allowed in module names
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ArgLengthMismatch.out b/tests/purs/failing/ArgLengthMismatch.out
new file mode 100644
index 0000000000..f146af501f
--- /dev/null
+++ b/tests/purs/failing/ArgLengthMismatch.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mArgLengthMismatch[0m
+at tests/purs/failing/ArgLengthMismatch.purs:6:1 - 6:13 (line 6, column 1 - line 6, column 13)
+
+ Argument list lengths differ in declaration [33mf[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ArgListLengthsDiffer.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ArrayType.out b/tests/purs/failing/ArrayType.out
new file mode 100644
index 0000000000..3c892bd842
--- /dev/null
+++ b/tests/purs/failing/ArrayType.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ArrayType.purs:10:7 - 10:8 (line 10, column 7 - line 10, column 8)
+
+ Could not match type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Number[0m
+ [33m [0m
+
+while checking that type [33mInt[0m
+ is at least as general as type [33mNumber[0m
+while checking that expression [33mx[0m
+ has type [33mNumber[0m
+in value declaration [33mfoo[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/Arrays.out b/tests/purs/failing/Arrays.out
new file mode 100644
index 0000000000..276ed08504
--- /dev/null
+++ b/tests/purs/failing/Arrays.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/Arrays.purs:6:26 - 6:27 (line 6, column 26 - line 6, column 27)
+
+ Could not match type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Array t0[0m
+ [33m [0m
+
+while checking that type [33mInt[0m
+ is at least as general as type [33mArray t0[0m
+while checking that expression [33m0[0m
+ has type [33mArray t0[0m
+in value declaration [33mtest[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/AtPatternPrecedence.out b/tests/purs/failing/AtPatternPrecedence.out
new file mode 100644
index 0000000000..5db798b828
--- /dev/null
+++ b/tests/purs/failing/AtPatternPrecedence.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/AtPatternPrecedence.purs:11:1 - 11:15 (line 11, column 1 - line 11, column 15)
+
+ Argument list lengths differ in declaration [33moops[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ArgListLengthsDiffer.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/BifunctorInstance1.out b/tests/purs/failing/BifunctorInstance1.out
new file mode 100644
index 0000000000..db6922613c
--- /dev/null
+++ b/tests/purs/failing/BifunctorInstance1.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mBifunctorInstance1[0m
+at tests/purs/failing/BifunctorInstance1.purs:10:1 - 10:31 (line 10, column 1 - line 10, column 31)
+
+ One or more type variables are in positions that prevent [33mBifunctor[0m from being derived.
+ To derive this class, make sure that these variables are only used as the final arguments to type constructors, that their variance matches the variance of [33mBifunctor[0m, and that those type constructors themselves have instances of [33mData.Functor.Functor[0m, [33mData.Bifunctor.Bifunctor[0m, [33mData.Functor.Contravariant.Contravariant[0m, or [33mData.Profunctor.Profunctor[0m.
+
+ tests/purs/failing/BifunctorInstance1.purs:
+ [90m 8[0m [33m[0m
+ [90m 9[0m [33mdata Test a b = Test (Tuple (Predicate [7ma[27m) (Predicate [7mb[27m)) (Tuple a b)[0m
+ [90m 10[0m [33mderive instance Bifunctor Test[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDeriveInvalidConstructorArg.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/BifunctorInstance1.purs b/tests/purs/failing/BifunctorInstance1.purs
new file mode 100644
index 0000000000..264cae5708
--- /dev/null
+++ b/tests/purs/failing/BifunctorInstance1.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith CannotDeriveInvalidConstructorArg
+module BifunctorInstance1 where
+
+import Prelude
+import Data.Bifunctor (class Bifunctor)
+import Data.Predicate (Predicate)
+import Data.Tuple (Tuple)
+
+data Test a b = Test (Tuple (Predicate a) (Predicate b)) (Tuple a b)
+derive instance Bifunctor Test
diff --git a/tests/purs/failing/BindInDo-2.out b/tests/purs/failing/BindInDo-2.out
new file mode 100644
index 0000000000..7379090786
--- /dev/null
+++ b/tests/purs/failing/BindInDo-2.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/BindInDo-2.purs:7:7 - 7:16 (line 7, column 7 - line 7, column 16)
+
+ The name [33mbind[0m cannot be brought into scope in a do notation block, since do notation uses the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotUseBindWithDo.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/BindInDo.out b/tests/purs/failing/BindInDo.out
new file mode 100644
index 0000000000..87be256e78
--- /dev/null
+++ b/tests/purs/failing/BindInDo.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/BindInDo.purs:7:3 - 7:18 (line 7, column 3 - line 7, column 18)
+
+ The name [33mbind[0m cannot be brought into scope in a do notation block, since do notation uses the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotUseBindWithDo.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CannotDeriveNewtypeForData.out b/tests/purs/failing/CannotDeriveNewtypeForData.out
new file mode 100644
index 0000000000..2b78aebc75
--- /dev/null
+++ b/tests/purs/failing/CannotDeriveNewtypeForData.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/CannotDeriveNewtypeForData.purs:6:1 - 6:24 (line 6, column 1 - line 6, column 24)
+
+ Cannot derive an instance of the [33mNewtype[0m class for non-newtype [33mTest[0m.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDeriveNewtypeForData.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CaseBinderLengthsDiffer.out b/tests/purs/failing/CaseBinderLengthsDiffer.out
new file mode 100644
index 0000000000..8fcae58ff1
--- /dev/null
+++ b/tests/purs/failing/CaseBinderLengthsDiffer.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CaseBinderLengthsDiffer.purs:5:3 - 5:10 (line 5, column 3 - line 5, column 10)
+
+ Binder list length differs in case alternative:
+
+ 1, 2, 3
+
+ Expecting 2 binders.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CaseBinderLengthDiffers.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CaseDoesNotMatchAllConstructorArgs.out b/tests/purs/failing/CaseDoesNotMatchAllConstructorArgs.out
new file mode 100644
index 0000000000..5a060f27a5
--- /dev/null
+++ b/tests/purs/failing/CaseDoesNotMatchAllConstructorArgs.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CaseDoesNotMatchAllConstructorArgs.purs:11:9 - 11:17 (line 11, column 9 - line 11, column 17)
+
+ Data constructor [33mMain.Person[0m was given 1 arguments in a case expression, but expected 2 arguments.
+ This problem can be fixed by giving [33mMain.Person[0m 2 arguments.
+
+while inferring the type of [33m\p -> [0m
+ [33m case p of [0m
+ [33m (Two (Person n) (Person n2 a2)) -> n[0m
+ [33m _ -> "Unknown" [0m
+in value declaration [33mgetName[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/IncorrectConstructorArity.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA1.out b/tests/purs/failing/ClassHeadNoVTA1.out
new file mode 100644
index 0000000000..dc5cde2c6d
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA1.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ClassHeadNoVTA1.purs:8:10 - 8:19 (line 8, column 10 - line 8, column 19)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.Single t0[0m
+ [33m [0m
+ The instance head contains unknown type variables.
+
+ Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. [33mtyClassMember @Int[0m).
+ [33mMain.useSingle[0m
+ tyNotAppearInBody
+
+while checking that type [33mforall (t12 :: Type) (@tyNotAppearInBody :: t12). Single @t12 tyNotAppearInBody => Int[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33museSingle[0m
+ has type [33mInt[0m
+in value declaration [33msingle[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA1.purs b/tests/purs/failing/ClassHeadNoVTA1.purs
new file mode 100644
index 0000000000..0c297337b8
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA1.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+class Single tyNotAppearInBody where
+ useSingle :: Int
+
+single :: Int
+single = useSingle
diff --git a/tests/purs/failing/ClassHeadNoVTA2.out b/tests/purs/failing/ClassHeadNoVTA2.out
new file mode 100644
index 0000000000..c0d5fd94c1
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA2.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ClassHeadNoVTA2.purs:10:9 - 10:17 (line 10, column 9 - line 10, column 17)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.Multi t0[0m
+ [33m t1[0m
+ [33m [0m
+ The instance head contains unknown type variables.
+
+ Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. [33mtyClassMember @Int[0m).
+ [33mMain.useMulti[0m
+ tyNotAppearInBody, norThisOne
+
+while checking that type [33mforall (t20 :: Type) (t21 :: Type) (@tyNotAppearInBody :: t20) (@norThisOne :: t21). Multi @t20 @t21 tyNotAppearInBody norThisOne => Int[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33museMulti[0m
+ has type [33mInt[0m
+in value declaration [33mmulti[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA2.purs b/tests/purs/failing/ClassHeadNoVTA2.purs
new file mode 100644
index 0000000000..8efba3f771
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA2.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Prelude
+
+class Multi tyNotAppearInBody norThisOne where
+ useMulti :: Int
+
+multi :: Int
+multi = useMulti
+
diff --git a/tests/purs/failing/ClassHeadNoVTA3.out b/tests/purs/failing/ClassHeadNoVTA3.out
new file mode 100644
index 0000000000..7e8edd3209
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA3.out
@@ -0,0 +1,28 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ClassHeadNoVTA3.purs:8:16 - 8:36 (line 8, column 16 - line 8, column 36)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.MultiMissing Int[0m
+ [33m t2 [0m
+ [33m [0m
+ The instance head contains unknown type variables.
+
+ Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. [33mtyClassMember @Int[0m).
+ [33mMain.useMultiMissing[0m
+ tyNotAppearInBody, norThisOne
+
+while checking that type [33mforall (@norThisOne :: t0). MultiMissing @t1 @t0 Int norThisOne => Int[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33museMultiMissing[0m
+ has type [33mInt[0m
+in value declaration [33mmultiMissing[0m
+
+where [33mt1[0m is an unknown type
+ [33mt0[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA3.purs b/tests/purs/failing/ClassHeadNoVTA3.purs
new file mode 100644
index 0000000000..00179dd9b5
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA3.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+class MultiMissing tyNotAppearInBody norThisOne where
+ useMultiMissing :: Int
+
+multiMissing :: Int
+multiMissing = useMultiMissing @Int
+
diff --git a/tests/purs/failing/ClassHeadNoVTA4.out b/tests/purs/failing/ClassHeadNoVTA4.out
new file mode 100644
index 0000000000..010993f201
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA4.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ClassHeadNoVTA4.purs:8:11 - 8:21 (line 8, column 11 - line 8, column 21)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.MultiFd t0[0m
+ [33m t1[0m
+ [33m [0m
+ The instance head contains unknown type variables.
+
+ Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. [33mtyClassMember @Int[0m).
+ [33mMain.useMultiFd[0m
+ tyNotAppearInBody
+
+while checking that type [33mforall (t20 :: Type) (t21 :: Type) (@tyNotAppearInBody :: t20) (@norThisOne :: t21). MultiFd @t20 @t21 tyNotAppearInBody norThisOne => Int[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33museMultiFd[0m
+ has type [33mInt[0m
+in value declaration [33mmultiFd[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA4.purs b/tests/purs/failing/ClassHeadNoVTA4.purs
new file mode 100644
index 0000000000..f0444af0c6
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA4.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+class MultiFd tyNotAppearInBody norThisOne | tyNotAppearInBody -> norThisOne where
+ useMultiFd :: Int
+
+multiFd :: Int
+multiFd = useMultiFd
diff --git a/tests/purs/failing/ClassHeadNoVTA5.out b/tests/purs/failing/ClassHeadNoVTA5.out
new file mode 100644
index 0000000000..cfe69013dd
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA5.out
@@ -0,0 +1,29 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ClassHeadNoVTA5.purs:10:15 - 10:29 (line 10, column 15 - line 10, column 29)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.MultiFdBidi t0[0m
+ [33m t1[0m
+ [33m [0m
+ The instance head contains unknown type variables.
+
+ Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. [33mtyClassMember @Int[0m).
+ [33mMain.useMultiFdBidi[0m
+ One of the following sets of type variables:
+ tyNotAppearInBody
+ norThisOne
+
+while checking that type [33mforall (t20 :: Type) (t21 :: Type) (@tyNotAppearInBody :: t20) (@norThisOne :: t21). MultiFdBidi @t20 @t21 tyNotAppearInBody norThisOne => Int[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33museMultiFdBidi[0m
+ has type [33mInt[0m
+in value declaration [33mmultiFdBidi[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA5.purs b/tests/purs/failing/ClassHeadNoVTA5.purs
new file mode 100644
index 0000000000..421b2c8590
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA5.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+-- Verify that args in output match order defined here:
+-- `tyNotAppearInBody` appears before `norThisOne`
+class MultiFdBidi tyNotAppearInBody norThisOne | tyNotAppearInBody -> norThisOne, norThisOne -> tyNotAppearInBody where
+ useMultiFdBidi :: Int
+
+multiFdBidi :: Int
+multiFdBidi = useMultiFdBidi
diff --git a/tests/purs/failing/ClassHeadNoVTA6a.out b/tests/purs/failing/ClassHeadNoVTA6a.out
new file mode 100644
index 0000000000..9827276902
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA6a.out
@@ -0,0 +1,37 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ClassHeadNoVTA6a.purs:12:15 - 12:25 (line 12, column 15 - line 12, column 25)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.MultiCoveringSets t0[0m
+ [33m t1[0m
+ [33m t2[0m
+ [33m t3[0m
+ [33m t4[0m
+ [33m t5[0m
+ [33m [0m
+ The instance head contains unknown type variables.
+
+ Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. [33mtyClassMember @Int[0m).
+ [33mMain.noneOfSets[0m
+ One of the following sets of type variables:
+ a, b
+ e, f
+
+while checking that type [33mforall (t82 :: Type) (t83 :: Type) (@a :: Type) (@b :: t82) (@c :: Type) (@d :: Type) (@e :: t83) (@f :: Type). MultiCoveringSets @t82 @t83 a b c d e f => Int[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33mnoneOfSets[0m
+ has type [33mInt[0m
+in value declaration [33mnoneOfSets'[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+ [33mt3[0m is an unknown type
+ [33mt4[0m is an unknown type
+ [33mt5[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA6a.purs b/tests/purs/failing/ClassHeadNoVTA6a.purs
new file mode 100644
index 0000000000..b3aef76875
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA6a.purs
@@ -0,0 +1,12 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+class MultiCoveringSets a b c d e f | a b -> c d e f, f e -> a b c d where
+ noneOfSets :: Int
+
+ partialOfABSet :: a -> { c :: c, d :: d }
+
+ partialOfFESet :: f -> { c :: c, d :: d }
+
+noneOfSets' :: Int
+noneOfSets' = noneOfSets
diff --git a/tests/purs/failing/ClassHeadNoVTA6b.out b/tests/purs/failing/ClassHeadNoVTA6b.out
new file mode 100644
index 0000000000..ea4034dc77
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA6b.out
@@ -0,0 +1,50 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ClassHeadNoVTA6b.purs:16:19 - 16:33 (line 16, column 19 - line 16, column 33)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.MultiCoveringSets a0[0m
+ [33m t3[0m
+ [33m c1[0m
+ [33m d2[0m
+ [33m t4[0m
+ [33m t5[0m
+ [33m [0m
+ The instance head contains unknown type variables.
+
+ Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. [33mtyClassMember @Int[0m).
+ [33mMain.partialOfABSet[0m
+ One of the following sets of type variables:
+ b
+ e, f
+
+while checking that type [33mforall (t70 :: Type) (t71 :: Type) (@a :: Type) (@b :: t70) (@c :: Type) (@d :: Type) (@e :: t71) (@f :: Type).[0m
+ [33m MultiCoveringSets @t70 @t71 a b c d e f => a [0m
+ [33m -> { c :: c [0m
+ [33m , d :: d [0m
+ [33m } [0m
+ is at least as general as type [33ma0 [0m
+ [33m-> { c :: c1[0m
+ [33m , d :: d2[0m
+ [33m } [0m
+while checking that expression [33mpartialOfABSet[0m
+ has type [33ma0 [0m
+ [33m-> { c :: c1[0m
+ [33m , d :: d2[0m
+ [33m } [0m
+in value declaration [33mpartialOfABSet'[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 16, column 19 - line 16, column 33)
+ [33mc1[0m is a rigid type variable
+ bound at (line 16, column 19 - line 16, column 33)
+ [33md2[0m is a rigid type variable
+ bound at (line 16, column 19 - line 16, column 33)
+ [33mt3[0m is an unknown type
+ [33mt4[0m is an unknown type
+ [33mt5[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA6b.purs b/tests/purs/failing/ClassHeadNoVTA6b.purs
new file mode 100644
index 0000000000..3da5823d0d
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA6b.purs
@@ -0,0 +1,16 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+class MultiCoveringSets a b c d e f | a b -> c d e f, f e -> a b c d where
+ noneOfSets :: Int
+
+ partialOfABSet :: a -> { c :: c, d :: d }
+
+ partialOfFESet :: f -> { c :: c, d :: d }
+
+partialOfABSet'
+ :: forall a b c d e f
+ . MultiCoveringSets a b c d e f
+ => a
+ -> { c :: c, d :: d }
+partialOfABSet' = partialOfABSet
diff --git a/tests/purs/failing/ClassHeadNoVTA6c.out b/tests/purs/failing/ClassHeadNoVTA6c.out
new file mode 100644
index 0000000000..b8e3d95daf
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA6c.out
@@ -0,0 +1,50 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ClassHeadNoVTA6c.purs:16:19 - 16:33 (line 16, column 19 - line 16, column 33)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.MultiCoveringSets t3[0m
+ [33m t4[0m
+ [33m c1[0m
+ [33m d2[0m
+ [33m t5[0m
+ [33m f0[0m
+ [33m [0m
+ The instance head contains unknown type variables.
+
+ Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. [33mtyClassMember @Int[0m).
+ [33mMain.partialOfFESet[0m
+ One of the following sets of type variables:
+ a, b
+ e
+
+while checking that type [33mforall (t58 :: Type) (t59 :: Type) (@a :: Type) (@b :: t58) (@c :: Type) (@d :: Type) (@e :: t59) (@f :: Type).[0m
+ [33m MultiCoveringSets @t58 @t59 a b c d e f => f [0m
+ [33m -> { c :: c [0m
+ [33m , d :: d [0m
+ [33m } [0m
+ is at least as general as type [33mf0 [0m
+ [33m-> { c :: c1[0m
+ [33m , d :: d2[0m
+ [33m } [0m
+while checking that expression [33mpartialOfFESet[0m
+ has type [33mf0 [0m
+ [33m-> { c :: c1[0m
+ [33m , d :: d2[0m
+ [33m } [0m
+in value declaration [33mpartialOfFESet'[0m
+
+where [33mc1[0m is a rigid type variable
+ bound at (line 16, column 19 - line 16, column 33)
+ [33md2[0m is a rigid type variable
+ bound at (line 16, column 19 - line 16, column 33)
+ [33mf0[0m is a rigid type variable
+ bound at (line 16, column 19 - line 16, column 33)
+ [33mt3[0m is an unknown type
+ [33mt4[0m is an unknown type
+ [33mt5[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA6c.purs b/tests/purs/failing/ClassHeadNoVTA6c.purs
new file mode 100644
index 0000000000..9d6710d26f
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA6c.purs
@@ -0,0 +1,16 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+class MultiCoveringSets a b c d e f | a b -> c d e f, f e -> a b c d where
+ noneOfSets :: Int
+
+ partialOfABSet :: a -> { c :: c, d :: d }
+
+ partialOfFESet :: f -> { c :: c, d :: d }
+
+partialOfFESet'
+ :: forall a b c d e f
+ . MultiCoveringSets a b c d e f
+ => f
+ -> { c :: c, d :: d }
+partialOfFESet' = partialOfFESet
diff --git a/tests/purs/failing/ClassHeadNoVTA7.out b/tests/purs/failing/ClassHeadNoVTA7.out
new file mode 100644
index 0000000000..b44c3e8f44
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA7.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mClassHeadNoVTA7[0m
+at tests/purs/failing/ClassHeadNoVTA7.purs:12:8 - 12:26 (line 12, column 8 - line 12, column 26)
+
+ No type class instance was found for
+ [33m [0m
+ [33m ClassHeadNoVTA7.TestClass t1[0m
+ [33m t2[0m
+ [33m [0m
+ The instance head contains unknown type variables. Consider adding a type annotation.
+
+while applying a function [33mtestMethod[0m
+ of type [33mTestClass @t0 t1 t2 => Maybe t1 -> Int[0m
+ to argument [33mNothing[0m
+while checking that expression [33mtestMethod Nothing[0m
+ has type [33mInt[0m
+in value declaration [33mtest[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ClassHeadNoVTA7.purs b/tests/purs/failing/ClassHeadNoVTA7.purs
new file mode 100644
index 0000000000..d492ce722d
--- /dev/null
+++ b/tests/purs/failing/ClassHeadNoVTA7.purs
@@ -0,0 +1,12 @@
+-- @shouldFailWith NoInstanceFound
+module ClassHeadNoVTA7 where
+
+import Prelude
+
+import Data.Maybe (Maybe(..))
+
+class TestClass a b | a -> b, b -> a where
+ testMethod :: Maybe a -> Int
+
+test :: Int
+test = testMethod Nothing
diff --git a/tests/purs/failing/CoercibleClosedRowsDoNotUnify.out b/tests/purs/failing/CoercibleClosedRowsDoNotUnify.out
new file mode 100644
index 0000000000..9f4d67230b
--- /dev/null
+++ b/tests/purs/failing/CoercibleClosedRowsDoNotUnify.out
@@ -0,0 +1,39 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleClosedRowsDoNotUnify.purs:7:12 - 7:18 (line 7, column 12 - line 7, column 18)
+
+ Could not match type
+ [33m [0m
+ [33m ( x :: Int[0m
+ [33m ... [0m
+ [33m ) [0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m ( y :: String[0m
+ [33m ... [0m
+ [33m ) [0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible { x :: Int [0m
+[33m } [0m
+[33m { y :: String[0m
+[33m } [0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33m{ x :: Int [0m
+ [33m} [0m
+ [33m-> { y :: String[0m
+ [33m } [0m
+while checking that expression [33mcoerce[0m
+ has type [33m{ x :: Int [0m
+ [33m} [0m
+ [33m-> { y :: String[0m
+ [33m } [0m
+in value declaration [33mrecToRec[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleClosedRowsDoNotUnify.purs b/tests/purs/failing/CoercibleClosedRowsDoNotUnify.purs
new file mode 100644
index 0000000000..202ee0d87a
--- /dev/null
+++ b/tests/purs/failing/CoercibleClosedRowsDoNotUnify.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+recToRec :: { x :: Int } -> { y :: String }
+recToRec = coerce
diff --git a/tests/purs/failing/CoercibleConstrained1.out b/tests/purs/failing/CoercibleConstrained1.out
new file mode 100644
index 0000000000..d5a0e44f0d
--- /dev/null
+++ b/tests/purs/failing/CoercibleConstrained1.out
@@ -0,0 +1,29 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleConstrained1.purs:11:28 - 11:34 (line 11, column 28 - line 11, column 34)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible a0[0m
+ [33m b1[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Constrained a0)[0m
+[33m (Constrained b1)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mConstrained a0 -> Constrained b1[0m
+while checking that expression [33mcoerce[0m
+ has type [33mConstrained a0 -> Constrained b1[0m
+in value declaration [33mconstrainedToConstrained[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 11, column 28 - line 11, column 34)
+ [33mb1[0m is a rigid type variable
+ bound at (line 11, column 28 - line 11, column 34)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleConstrained1.purs b/tests/purs/failing/CoercibleConstrained1.purs
new file mode 100644
index 0000000000..cf462c6aa9
--- /dev/null
+++ b/tests/purs/failing/CoercibleConstrained1.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+class Nullary
+
+data Constrained a = Constrained (Nullary => a)
+
+constrainedToConstrained :: forall a b. Constrained a -> Constrained b
+constrainedToConstrained = coerce
diff --git a/tests/purs/failing/CoercibleConstrained2.out b/tests/purs/failing/CoercibleConstrained2.out
new file mode 100644
index 0000000000..0887faab0b
--- /dev/null
+++ b/tests/purs/failing/CoercibleConstrained2.out
@@ -0,0 +1,32 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleConstrained2.purs:11:28 - 11:34 (line 11, column 28 - line 11, column 34)
+
+ Could not match type
+ [33m [0m
+ [33m a0[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m b1[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Constrained a0)[0m
+[33m (Constrained b1)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mConstrained a0 -> Constrained b1[0m
+while checking that expression [33mcoerce[0m
+ has type [33mConstrained a0 -> Constrained b1[0m
+in value declaration [33mconstrainedToConstrained[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 11, column 28 - line 11, column 34)
+ [33mb1[0m is a rigid type variable
+ bound at (line 11, column 28 - line 11, column 34)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleConstrained2.purs b/tests/purs/failing/CoercibleConstrained2.purs
new file mode 100644
index 0000000000..71b4cd45ae
--- /dev/null
+++ b/tests/purs/failing/CoercibleConstrained2.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+class Unary a
+
+data Constrained a = Constrained (Unary a => a)
+
+constrainedToConstrained :: forall a b. Constrained a -> Constrained b
+constrainedToConstrained = coerce
diff --git a/tests/purs/failing/CoercibleConstrained3.out b/tests/purs/failing/CoercibleConstrained3.out
new file mode 100644
index 0000000000..91118d3bb7
--- /dev/null
+++ b/tests/purs/failing/CoercibleConstrained3.out
@@ -0,0 +1,30 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleConstrained3.purs:13:28 - 13:34 (line 13, column 28 - line 13, column 34)
+
+ Could not match type
+ [33m [0m
+ [33m a0[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m N a0[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Constrained a0) [0m
+[33m (Constrained (N a0))[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mConstrained a0 -> Constrained (N a0)[0m
+while checking that expression [33mcoerce[0m
+ has type [33mConstrained a0 -> Constrained (N a0)[0m
+in value declaration [33mconstrainedToConstrained[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 13, column 28 - line 13, column 34)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleConstrained3.purs b/tests/purs/failing/CoercibleConstrained3.purs
new file mode 100644
index 0000000000..04f059c2b4
--- /dev/null
+++ b/tests/purs/failing/CoercibleConstrained3.purs
@@ -0,0 +1,13 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+class Unary a
+
+data Constrained a = Constrained (Unary a => a)
+
+newtype N a = N a
+
+constrainedToConstrained :: forall a. Constrained a -> Constrained (N a)
+constrainedToConstrained = coerce
diff --git a/tests/purs/failing/CoercibleForeign.out b/tests/purs/failing/CoercibleForeign.out
new file mode 100644
index 0000000000..a1f33a778c
--- /dev/null
+++ b/tests/purs/failing/CoercibleForeign.out
@@ -0,0 +1,32 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleForeign.purs:11:20 - 11:26 (line 11, column 20 - line 11, column 26)
+
+ Could not match type
+ [33m [0m
+ [33m a0[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Id a0[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Foreign a0 b1) [0m
+[33m (Foreign (Id a0) (Id b1))[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mForeign a0 b1 -> Foreign (Id a0) (Id b1)[0m
+while checking that expression [33mcoerce[0m
+ has type [33mForeign a0 b1 -> Foreign (Id a0) (Id b1)[0m
+in value declaration [33mforeignToForeign[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 11, column 20 - line 11, column 26)
+ [33mb1[0m is a rigid type variable
+ bound at (line 11, column 20 - line 11, column 26)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleForeign.purs b/tests/purs/failing/CoercibleForeign.purs
new file mode 100644
index 0000000000..dc3dc5a675
--- /dev/null
+++ b/tests/purs/failing/CoercibleForeign.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+foreign import data Foreign :: Type -> Type -> Type
+
+newtype Id a = Id a
+
+foreignToForeign :: forall a b. Foreign a b -> Foreign (Id a) (Id b)
+foreignToForeign = coerce
diff --git a/tests/purs/failing/CoercibleForeign2.out b/tests/purs/failing/CoercibleForeign2.out
new file mode 100644
index 0000000000..ff43ac7059
--- /dev/null
+++ b/tests/purs/failing/CoercibleForeign2.out
@@ -0,0 +1,36 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleForeign2.purs:9:20 - 9:26 (line 9, column 20 - line 9, column 26)
+
+ Could not match type
+ [33m [0m
+ [33m c2[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m d3[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Foreign a0 b1 c2)[0m
+[33m (Foreign a0 b1 d3)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mForeign a0 b1 c2 -> Foreign a0 b1 d3[0m
+while checking that expression [33mcoerce[0m
+ has type [33mForeign a0 b1 c2 -> Foreign a0 b1 d3[0m
+in value declaration [33mforeignToForeign[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 9, column 20 - line 9, column 26)
+ [33mb1[0m is a rigid type variable
+ bound at (line 9, column 20 - line 9, column 26)
+ [33mc2[0m is a rigid type variable
+ bound at (line 9, column 20 - line 9, column 26)
+ [33md3[0m is a rigid type variable
+ bound at (line 9, column 20 - line 9, column 26)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleForeign2.purs b/tests/purs/failing/CoercibleForeign2.purs
new file mode 100644
index 0000000000..6200d49a71
--- /dev/null
+++ b/tests/purs/failing/CoercibleForeign2.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+foreign import data Foreign :: Type -> Type -> Type -> Type
+
+foreignToForeign :: forall a b c d. Foreign a b c -> Foreign a b d
+foreignToForeign = coerce
diff --git a/tests/purs/failing/CoercibleForeign3.out b/tests/purs/failing/CoercibleForeign3.out
new file mode 100644
index 0000000000..da20cd1011
--- /dev/null
+++ b/tests/purs/failing/CoercibleForeign3.out
@@ -0,0 +1,36 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleForeign3.purs:9:20 - 9:26 (line 9, column 20 - line 9, column 26)
+
+ Could not match type
+ [33m [0m
+ [33m b2[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m c3[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Foreign @k0 a1 b2)[0m
+[33m (Foreign @k0 a1 c3)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mForeign @k0 a1 b2 -> Foreign @k0 a1 c3[0m
+while checking that expression [33mcoerce[0m
+ has type [33mForeign @k0 a1 b2 -> Foreign @k0 a1 c3[0m
+in value declaration [33mforeignToForeign[0m
+
+where [33mk0[0m is a rigid type variable
+ bound at (line 9, column 20 - line 9, column 26)
+ [33ma1[0m is a rigid type variable
+ bound at (line 9, column 20 - line 9, column 26)
+ [33mb2[0m is a rigid type variable
+ bound at (line 9, column 20 - line 9, column 26)
+ [33mc3[0m is a rigid type variable
+ bound at (line 9, column 20 - line 9, column 26)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleForeign3.purs b/tests/purs/failing/CoercibleForeign3.purs
new file mode 100644
index 0000000000..af9859fe6b
--- /dev/null
+++ b/tests/purs/failing/CoercibleForeign3.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+foreign import data Foreign :: ∀ k. k -> k -> Type
+
+foreignToForeign :: ∀ k (a :: k) (b :: k) (c :: k). Foreign a b -> Foreign a c
+foreignToForeign = coerce
diff --git a/tests/purs/failing/CoercibleHigherKindedData.out b/tests/purs/failing/CoercibleHigherKindedData.out
new file mode 100644
index 0000000000..afad7f895c
--- /dev/null
+++ b/tests/purs/failing/CoercibleHigherKindedData.out
@@ -0,0 +1,33 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleHigherKindedData.purs:13:17 - 13:23 (line 13, column 17 - line 13, column 23)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible (Unary t5) [0m
+ [33m (Binary a3 t5)[0m
+ [33m [0m
+ The instance head contains unknown type variables. Consider adding a type annotation.
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Proxy @(t0 -> Type) (Unary @t0)) [0m
+[33m (Proxy @(t1 -> Type) (Binary @t2 @t1 a3))[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mProxy @(t0 -> Type) (Unary @t0) -> Proxy @(t1 -> Type) (... @t1 a3)[0m
+while checking that expression [33mcoerce[0m
+ has type [33mProxy @(t0 -> Type) (Unary @t0) -> Proxy @(t1 -> Type) (... @t1 a3)[0m
+in value declaration [33munaryToBinary[0m
+
+where [33ma3[0m is a rigid type variable
+ bound at (line 13, column 17 - line 13, column 23)
+ [33mt0[0m is an unknown type
+ [33mt2[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt4[0m is an unknown type
+ [33mt5[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleHigherKindedData.purs b/tests/purs/failing/CoercibleHigherKindedData.purs
new file mode 100644
index 0000000000..bb0f718010
--- /dev/null
+++ b/tests/purs/failing/CoercibleHigherKindedData.purs
@@ -0,0 +1,13 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+data Unary a
+data Binary a b
+
+data Proxy a = Proxy
+type role Proxy representational
+
+unaryToBinary :: forall a. Proxy Unary -> Proxy (Binary a)
+unaryToBinary = coerce
diff --git a/tests/purs/failing/CoercibleHigherKindedNewtypes.out b/tests/purs/failing/CoercibleHigherKindedNewtypes.out
new file mode 100644
index 0000000000..39c89d83dc
--- /dev/null
+++ b/tests/purs/failing/CoercibleHigherKindedNewtypes.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleHigherKindedNewtypes.purs:13:8 - 13:14 (line 13, column 8 - line 13, column 14)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible Int [0m
+ [33m String[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Ap @Type @Type N1 Int String)[0m
+[33m (Ap @Type @Type N2 Int String)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mAp @Type @Type N1 Int String -> Ap @Type @Type N2 Int String[0m
+while checking that expression [33mcoerce[0m
+ has type [33mAp @Type @Type N1 Int String -> Ap @Type @Type N2 Int String[0m
+in value declaration [33mswap[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleHigherKindedNewtypes.purs b/tests/purs/failing/CoercibleHigherKindedNewtypes.purs
new file mode 100644
index 0000000000..39dc2563f1
--- /dev/null
+++ b/tests/purs/failing/CoercibleHigherKindedNewtypes.purs
@@ -0,0 +1,13 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+newtype Ap f a b = Ap (f a b)
+
+data Tuple a b = Tuple a b
+newtype N1 a b = N1 (Tuple a b)
+newtype N2 b a = N2 (Tuple a b)
+
+swap :: Ap N1 Int String -> Ap N2 Int String
+swap = coerce
diff --git a/tests/purs/failing/CoercibleKindMismatch.out b/tests/purs/failing/CoercibleKindMismatch.out
new file mode 100644
index 0000000000..30ef9b17fc
--- /dev/null
+++ b/tests/purs/failing/CoercibleKindMismatch.out
@@ -0,0 +1,31 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleKindMismatch.purs:15:17 - 15:23 (line 15, column 17 - line 15, column 23)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m t29 -> Type[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Proxy @(t0 -> Type) (Unary @t0)) [0m
+[33m (Proxy @(t1 -> t2 -> Type) (Binary @t1 @t2))[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mProxy @(t0 -> Type) (Unary @t0) -> Proxy @(t1 -> ...) (Binary @t1 @t2)[0m
+while checking that expression [33mcoerce[0m
+ has type [33mProxy @(t0 -> Type) (Unary @t0) -> Proxy @(t1 -> ...) (Binary @t1 @t2)[0m
+in value declaration [33munaryToBinary[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleKindMismatch.purs b/tests/purs/failing/CoercibleKindMismatch.purs
new file mode 100644
index 0000000000..32a91f633a
--- /dev/null
+++ b/tests/purs/failing/CoercibleKindMismatch.purs
@@ -0,0 +1,15 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+data Unary a
+data Binary a b
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+type role Proxy representational
+
+unaryToBinary :: Proxy Unary -> Proxy Binary
+unaryToBinary = coerce
diff --git a/tests/purs/failing/CoercibleNominal.out b/tests/purs/failing/CoercibleNominal.out
new file mode 100644
index 0000000000..77bfb12e17
--- /dev/null
+++ b/tests/purs/failing/CoercibleNominal.out
@@ -0,0 +1,34 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleNominal.purs:11:20 - 11:26 (line 11, column 20 - line 11, column 26)
+
+ Could not match type
+ [33m [0m
+ [33m a0[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m b2[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Nominal a0 c1)[0m
+[33m (Nominal b2 c1)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mNominal a0 c1 -> Nominal b2 c1[0m
+while checking that expression [33mcoerce[0m
+ has type [33mNominal a0 c1 -> Nominal b2 c1[0m
+in value declaration [33mnominalToNominal[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 11, column 20 - line 11, column 26)
+ [33mb2[0m is a rigid type variable
+ bound at (line 11, column 20 - line 11, column 26)
+ [33mc1[0m is a rigid type variable
+ bound at (line 11, column 20 - line 11, column 26)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleNominal.purs b/tests/purs/failing/CoercibleNominal.purs
new file mode 100644
index 0000000000..13c7da8144
--- /dev/null
+++ b/tests/purs/failing/CoercibleNominal.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+data Nominal a (b :: Type) = Nominal a
+
+type role Nominal nominal phantom
+
+nominalToNominal :: forall a b c. Nominal a c -> Nominal b c
+nominalToNominal = coerce
diff --git a/tests/purs/failing/CoercibleNominalTypeApp.out b/tests/purs/failing/CoercibleNominalTypeApp.out
new file mode 100644
index 0000000000..2cc4b5a2a9
--- /dev/null
+++ b/tests/purs/failing/CoercibleNominalTypeApp.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleNominalTypeApp.purs:13:8 - 13:14 (line 13, column 8 - line 13, column 14)
+
+ Could not match type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (G @Type Maybe Int) [0m
+[33m (G @Type Maybe String)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mG @Type Maybe Int -> G @Type Maybe String[0m
+while checking that expression [33mcoerce[0m
+ has type [33mG @Type Maybe Int -> G @Type Maybe String[0m
+in value declaration [33mgToG[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleNominalTypeApp.purs b/tests/purs/failing/CoercibleNominalTypeApp.purs
new file mode 100644
index 0000000000..80112d2c8e
--- /dev/null
+++ b/tests/purs/failing/CoercibleNominalTypeApp.purs
@@ -0,0 +1,13 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+data Phantom a = Phantom
+
+data Maybe a = Nothing | Just a
+
+data G a b = G (a (Phantom b))
+
+gToG :: G Maybe Int -> G Maybe String
+gToG = coerce
diff --git a/tests/purs/failing/CoercibleNominalWrapped.out b/tests/purs/failing/CoercibleNominalWrapped.out
new file mode 100644
index 0000000000..31b820a455
--- /dev/null
+++ b/tests/purs/failing/CoercibleNominalWrapped.out
@@ -0,0 +1,32 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleNominalWrapped.purs:15:14 - 15:20 (line 15, column 14 - line 15, column 20)
+
+ Could not match type
+ [33m [0m
+ [33m a0[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Id a0[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Wrap a0 b1) [0m
+[33m (Wrap (Id a0) b1)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mWrap a0 b1 -> Wrap (Id a0) b1[0m
+while checking that expression [33mcoerce[0m
+ has type [33mWrap a0 b1 -> Wrap (Id a0) b1[0m
+in value declaration [33mwrapToWrap[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 15, column 14 - line 15, column 20)
+ [33mb1[0m is a rigid type variable
+ bound at (line 15, column 14 - line 15, column 20)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleNominalWrapped.purs b/tests/purs/failing/CoercibleNominalWrapped.purs
new file mode 100644
index 0000000000..04edff6650
--- /dev/null
+++ b/tests/purs/failing/CoercibleNominalWrapped.purs
@@ -0,0 +1,15 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Safe.Coerce (coerce)
+
+data Nominal a (b :: Type) = Nominal a
+
+type role Nominal nominal phantom
+
+newtype Id a = Id a
+
+data Wrap a b = Wrap (Nominal a b)
+
+wrapToWrap :: forall a b. Wrap a b -> Wrap (Id a) b
+wrapToWrap = coerce
diff --git a/tests/purs/failing/CoercibleNonCanonical1.out b/tests/purs/failing/CoercibleNonCanonical1.out
new file mode 100644
index 0000000000..80405754e0
--- /dev/null
+++ b/tests/purs/failing/CoercibleNonCanonical1.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleNonCanonical1.purs:11:27 - 11:33 (line 11, column 27 - line 11, column 33)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible a0 [0m
+ [33m (D (N a0))[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible a0 [0m
+[33m (N @Type a0)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33ma0 -> N @Type a0[0m
+while checking that expression [33mcoerce[0m
+ has type [33ma0 -> N @Type a0[0m
+in value declaration [33mnonCanonicalSameTyVarEq[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 11, column 27 - line 11, column 33)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleNonCanonical1.purs b/tests/purs/failing/CoercibleNonCanonical1.purs
new file mode 100644
index 0000000000..bd2a4f1b6b
--- /dev/null
+++ b/tests/purs/failing/CoercibleNonCanonical1.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Prim.Coerce (class Coercible)
+import Safe.Coerce (coerce)
+
+data D a = D a
+newtype N a = N (D (N a))
+
+nonCanonicalSameTyVarEq :: forall a. Coercible a (D a) => a -> N a
+nonCanonicalSameTyVarEq = coerce
diff --git a/tests/purs/failing/CoercibleNonCanonical2.out b/tests/purs/failing/CoercibleNonCanonical2.out
new file mode 100644
index 0000000000..b1bb270ff2
--- /dev/null
+++ b/tests/purs/failing/CoercibleNonCanonical2.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleNonCanonical2.purs:10:27 - 10:33 (line 10, column 27 - line 10, column 33)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible a0[0m
+ [33m b1[0m
+ [33m [0m
+
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33ma0 -> b1[0m
+while checking that expression [33mcoerce[0m
+ has type [33ma0 -> b1[0m
+in value declaration [33mnonCanonicalDiffTyVarEq[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 10, column 27 - line 10, column 33)
+ [33mb1[0m is a rigid type variable
+ bound at (line 10, column 27 - line 10, column 33)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleNonCanonical2.purs b/tests/purs/failing/CoercibleNonCanonical2.purs
new file mode 100644
index 0000000000..4743ae0a79
--- /dev/null
+++ b/tests/purs/failing/CoercibleNonCanonical2.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Prim.Coerce (class Coercible)
+import Safe.Coerce (coerce)
+
+data D a = D a
+
+nonCanonicalDiffTyVarEq :: forall a b. Coercible b (D b) => a -> b
+nonCanonicalDiffTyVarEq = coerce
diff --git a/tests/purs/failing/CoercibleOpenRowsDoNotUnify.out b/tests/purs/failing/CoercibleOpenRowsDoNotUnify.out
new file mode 100644
index 0000000000..4e96f7e13d
--- /dev/null
+++ b/tests/purs/failing/CoercibleOpenRowsDoNotUnify.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleOpenRowsDoNotUnify.purs:7:12 - 7:18 (line 7, column 12 - line 7, column 18)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible r0[0m
+ [33m s1[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible { x :: Int[0m
+[33m | r0 [0m
+[33m } [0m
+[33m { x :: Int[0m
+[33m | s1 [0m
+[33m } [0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33m{ x :: Int [0m
+ [33m| r0 [0m
+ [33m} [0m
+ [33m-> { x :: Int[0m
+ [33m | s1 [0m
+ [33m } [0m
+while checking that expression [33mcoerce[0m
+ has type [33m{ x :: Int [0m
+ [33m| r0 [0m
+ [33m} [0m
+ [33m-> { x :: Int[0m
+ [33m | s1 [0m
+ [33m } [0m
+in value declaration [33mrecToRec[0m
+
+where [33mr0[0m is a rigid type variable
+ bound at (line 7, column 12 - line 7, column 18)
+ [33ms1[0m is a rigid type variable
+ bound at (line 7, column 12 - line 7, column 18)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleOpenRowsDoNotUnify.purs b/tests/purs/failing/CoercibleOpenRowsDoNotUnify.purs
new file mode 100644
index 0000000000..d9d0782381
--- /dev/null
+++ b/tests/purs/failing/CoercibleOpenRowsDoNotUnify.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+recToRec :: forall r s. { x :: Int | r } -> { x :: Int | s }
+recToRec = coerce
diff --git a/tests/purs/failing/CoercibleRepresentational.out b/tests/purs/failing/CoercibleRepresentational.out
new file mode 100644
index 0000000000..42a657e6ca
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational.out
@@ -0,0 +1,31 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRepresentational.purs:11:20 - 11:26 (line 11, column 20 - line 11, column 26)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible a1[0m
+ [33m b3[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Phantom @t0 a1)[0m
+[33m (Phantom @t2 b3)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mPhantom @t0 a1 -> Phantom @t2 b3[0m
+while checking that expression [33mcoerce[0m
+ has type [33mPhantom @t0 a1 -> Phantom @t2 b3[0m
+in value declaration [33mphantomToPhantom[0m
+
+where [33ma1[0m is a rigid type variable
+ bound at (line 11, column 20 - line 11, column 26)
+ [33mb3[0m is a rigid type variable
+ bound at (line 11, column 20 - line 11, column 26)
+ [33mt0[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRepresentational.purs b/tests/purs/failing/CoercibleRepresentational.purs
new file mode 100644
index 0000000000..5ba2c08179
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+data Phantom a = Phantom
+
+type role Phantom representational
+
+phantomToPhantom :: forall a b. Phantom a -> Phantom b
+phantomToPhantom = coerce
diff --git a/tests/purs/failing/CoercibleRepresentational2.out b/tests/purs/failing/CoercibleRepresentational2.out
new file mode 100644
index 0000000000..435c8421cc
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational2.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRepresentational2.purs:9:14 - 9:20 (line 9, column 14 - line 9, column 20)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible Int [0m
+ [33m String[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Arr1 Int) [0m
+[33m (Arr1 String)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mArr1 Int -> Arr1 String[0m
+while checking that expression [33mcoerce[0m
+ has type [33mArr1 Int -> Arr1 String[0m
+in value declaration [33marr1ToArr1[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRepresentational2.purs b/tests/purs/failing/CoercibleRepresentational2.purs
new file mode 100644
index 0000000000..e74d5a0093
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational2.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+data Arr1 a = Arr1 (Array a)
+
+arr1ToArr1 :: Arr1 Int -> Arr1 String
+arr1ToArr1 = coerce
diff --git a/tests/purs/failing/CoercibleRepresentational3.out b/tests/purs/failing/CoercibleRepresentational3.out
new file mode 100644
index 0000000000..f718b3c4cb
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational3.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRepresentational3.purs:9:14 - 9:20 (line 9, column 14 - line 9, column 20)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible Int [0m
+ [33m String[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Rec1 Int) [0m
+[33m (Rec1 String)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mRec1 Int -> Rec1 String[0m
+while checking that expression [33mcoerce[0m
+ has type [33mRec1 Int -> Rec1 String[0m
+in value declaration [33marr1ToArr1[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRepresentational3.purs b/tests/purs/failing/CoercibleRepresentational3.purs
new file mode 100644
index 0000000000..5265b7987b
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational3.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+data Rec1 a = Rec1 { f :: a }
+
+arr1ToArr1 :: Rec1 Int -> Rec1 String
+arr1ToArr1 = coerce
diff --git a/tests/purs/failing/CoercibleRepresentational4.out b/tests/purs/failing/CoercibleRepresentational4.out
new file mode 100644
index 0000000000..50d61e5c8b
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational4.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRepresentational4.purs:11:38 - 11:44 (line 11, column 38 - line 11, column 44)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible Int [0m
+ [33m String[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (Representational Int) [0m
+[33m (Representational String)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mRepresentational Int -> Representational String[0m
+while checking that expression [33mcoerce[0m
+ has type [33mRepresentational Int -> Representational String[0m
+in value declaration [33mrepresentationalToRepresentational[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRepresentational4.purs b/tests/purs/failing/CoercibleRepresentational4.purs
new file mode 100644
index 0000000000..d8383b8d15
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational4.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+data F a = F a
+type Synonym a = F a
+data Representational a = Representational (Synonym a)
+
+representationalToRepresentational :: Representational Int -> Representational String
+representationalToRepresentational = coerce
diff --git a/tests/purs/failing/CoercibleRepresentational5.out b/tests/purs/failing/CoercibleRepresentational5.out
new file mode 100644
index 0000000000..6c215721cf
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational5.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRepresentational5.purs:15:38 - 15:44 (line 15, column 38 - line 15, column 44)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible Int [0m
+ [33m String[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (MutuallyRecursiveRepresentational2 Int) [0m
+[33m (MutuallyRecursiveRepresentational2 String)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mMutuallyRecursiveRepresentational2 Int -> MutuallyRecursiveRepresentational2 String[0m
+while checking that expression [33mcoerce[0m
+ has type [33mMutuallyRecursiveRepresentational2 Int -> MutuallyRecursiveRepresentational2 String[0m
+in value declaration [33mrepresentationalToRepresentational[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRepresentational5.purs b/tests/purs/failing/CoercibleRepresentational5.purs
new file mode 100644
index 0000000000..d073c29946
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational5.purs
@@ -0,0 +1,15 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+data MutuallyRecursiveRepresentational1 a
+ = MutuallyRecursiveRepresentational1 a (MutuallyRecursiveRepresentational2 a)
+
+type MutuallyRecursiveRepresentational1Synonym a = MutuallyRecursiveRepresentational1 a
+
+data MutuallyRecursiveRepresentational2 a
+ = MutuallyRecursiveRepresentational2 (MutuallyRecursiveRepresentational1Synonym a)
+
+representationalToRepresentational :: MutuallyRecursiveRepresentational2 Int -> MutuallyRecursiveRepresentational2 String
+representationalToRepresentational = coerce
diff --git a/tests/purs/failing/CoercibleRepresentational6.out b/tests/purs/failing/CoercibleRepresentational6.out
new file mode 100644
index 0000000000..a587159c40
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational6.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRepresentational6.purs:8:10 - 8:16 (line 8, column 10 - line 8, column 16)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible (N a0)[0m
+ [33m a0 [0m
+ [33m [0m
+
+ Solving this instance requires the newtype constructor [33mN[0m to be in scope.
+
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mN a0 -> a0[0m
+while checking that expression [33mcoerce[0m
+ has type [33mN a0 -> a0[0m
+in value declaration [33munwrap[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 8, column 10 - line 8, column 16)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRepresentational6.purs b/tests/purs/failing/CoercibleRepresentational6.purs
new file mode 100644
index 0000000000..ab0f36919e
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational6.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+import N (N(..))
+
+unwrap :: forall a. N a -> a
+unwrap = coerce
diff --git a/tests/purs/failing/CoercibleRepresentational6/N.purs b/tests/purs/failing/CoercibleRepresentational6/N.purs
new file mode 100644
index 0000000000..6ef0e199d4
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational6/N.purs
@@ -0,0 +1,3 @@
+module N (N) where
+
+newtype N a = N a
diff --git a/tests/purs/failing/CoercibleRepresentational7.out b/tests/purs/failing/CoercibleRepresentational7.out
new file mode 100644
index 0000000000..0c5c1005a5
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational7.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRepresentational7.purs:8:10 - 8:16 (line 8, column 10 - line 8, column 16)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible (N a0)[0m
+ [33m a0 [0m
+ [33m [0m
+
+ Solving this instance requires the newtype constructor [33mN[0m to be in scope.
+
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mN a0 -> a0[0m
+while checking that expression [33mcoerce[0m
+ has type [33mN a0 -> a0[0m
+in value declaration [33munwrap[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 8, column 10 - line 8, column 16)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRepresentational7.purs b/tests/purs/failing/CoercibleRepresentational7.purs
new file mode 100644
index 0000000000..ad21472176
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational7.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+import N (N)
+
+unwrap :: forall a. N a -> a
+unwrap = coerce
diff --git a/tests/purs/failing/CoercibleRepresentational7/N.purs b/tests/purs/failing/CoercibleRepresentational7/N.purs
new file mode 100644
index 0000000000..fe6de00d5d
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational7/N.purs
@@ -0,0 +1,3 @@
+module N (N(..)) where
+
+newtype N a = N a
diff --git a/tests/purs/failing/CoercibleRepresentational8.out b/tests/purs/failing/CoercibleRepresentational8.out
new file mode 100644
index 0000000000..cb5275fcbf
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational8.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRepresentational8.purs:9:16 - 9:22 (line 9, column 16 - line 9, column 22)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible a0[0m
+ [33m b1[0m
+ [33m [0m
+
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33ma0 -> b1[0m
+while checking that expression [33mcoerce[0m
+ has type [33ma0 -> b1[0m
+in value declaration [33munsafeCoerce[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 9, column 16 - line 9, column 22)
+ [33mb1[0m is a rigid type variable
+ bound at (line 9, column 16 - line 9, column 22)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRepresentational8.purs b/tests/purs/failing/CoercibleRepresentational8.purs
new file mode 100644
index 0000000000..b9c52cafae
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational8.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import UnsafeCoerce (UnsafeCoerce)
+import Prim.Coerce (class Coercible)
+import Safe.Coerce (coerce)
+
+unsafeCoerce :: forall a b. Coercible (UnsafeCoerce a) (UnsafeCoerce b) => a -> b
+unsafeCoerce = coerce
diff --git a/tests/purs/failing/CoercibleRepresentational8/UnsafeCoerce.purs b/tests/purs/failing/CoercibleRepresentational8/UnsafeCoerce.purs
new file mode 100644
index 0000000000..0764bdda0a
--- /dev/null
+++ b/tests/purs/failing/CoercibleRepresentational8/UnsafeCoerce.purs
@@ -0,0 +1,7 @@
+module UnsafeCoerce where
+
+import Data.Unit (Unit)
+
+newtype UnsafeCoerce a = UnsafeCoerce Unit
+
+type role UnsafeCoerce representational
diff --git a/tests/purs/failing/CoercibleRoleMismatch1.out b/tests/purs/failing/CoercibleRoleMismatch1.out
new file mode 100644
index 0000000000..bdfe5f8970
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch1.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRoleMismatch1.purs:6:1 - 6:27 (line 6, column 1 - line 6, column 27)
+
+ Role mismatch for the type parameter [33ma[0m:
+
+ The annotation says [33mphantom[0m but the role [33mrepresentational[0m is required.
+
+
+in role declaration for [33mIdentity[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRoleMismatch1.purs b/tests/purs/failing/CoercibleRoleMismatch1.purs
new file mode 100644
index 0000000000..d7980a9ad6
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch1.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith RoleMismatch
+module Main where
+
+data Identity a = Identity a
+
+type role Identity phantom
diff --git a/tests/purs/failing/CoercibleRoleMismatch2.out b/tests/purs/failing/CoercibleRoleMismatch2.out
new file mode 100644
index 0000000000..c4e42541fb
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch2.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRoleMismatch2.purs:10:1 - 10:20 (line 10, column 1 - line 10, column 20)
+
+ Role mismatch for the type parameter [33ma[0m:
+
+ The annotation says [33mphantom[0m but the role [33mnominal[0m is required.
+
+
+in role declaration for [33mV[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRoleMismatch2.purs b/tests/purs/failing/CoercibleRoleMismatch2.purs
new file mode 100644
index 0000000000..65d499fae5
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch2.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith RoleMismatch
+module Main where
+
+data T r (p :: Type) n = T r n
+
+type role T representational phantom nominal
+
+data V a = V (T a a a)
+
+type role V phantom
diff --git a/tests/purs/failing/CoercibleRoleMismatch3.out b/tests/purs/failing/CoercibleRoleMismatch3.out
new file mode 100644
index 0000000000..f9ee257468
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch3.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRoleMismatch3.purs:10:1 - 10:29 (line 10, column 1 - line 10, column 29)
+
+ Role mismatch for the type parameter [33ma[0m:
+
+ The annotation says [33mrepresentational[0m but the role [33mnominal[0m is required.
+
+
+in role declaration for [33mU[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRoleMismatch3.purs b/tests/purs/failing/CoercibleRoleMismatch3.purs
new file mode 100644
index 0000000000..d19b6d1993
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch3.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith RoleMismatch
+module Main where
+
+data T r (p :: Type) n = T r n
+
+type role T representational phantom nominal
+
+data U a = U (T a a a)
+
+type role U representational
diff --git a/tests/purs/failing/CoercibleRoleMismatch4.out b/tests/purs/failing/CoercibleRoleMismatch4.out
new file mode 100644
index 0000000000..2ea0f9b791
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch4.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRoleMismatch4.purs:5:1 - 5:29 (line 5, column 1 - line 5, column 29)
+
+ Role mismatch for the type parameter [33ma[0m:
+
+ The annotation says [33mrepresentational[0m but the role [33mnominal[0m is required.
+
+
+in role declaration for [33mF[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRoleMismatch4.purs b/tests/purs/failing/CoercibleRoleMismatch4.purs
new file mode 100644
index 0000000000..cb31fa590b
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch4.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith RoleMismatch
+module Main where
+
+data F a = F (G a)
+type role F representational
+
+data G a = G (F a)
+type role G nominal
diff --git a/tests/purs/failing/CoercibleRoleMismatch5.out b/tests/purs/failing/CoercibleRoleMismatch5.out
new file mode 100644
index 0000000000..c862f32351
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch5.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleRoleMismatch5.purs:5:1 - 5:20 (line 5, column 1 - line 5, column 20)
+
+ Role mismatch for the type parameter [33ma[0m:
+
+ The annotation says [33mphantom[0m but the role [33mrepresentational[0m is required.
+
+
+in role declaration for [33mF[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleRoleMismatch5.purs b/tests/purs/failing/CoercibleRoleMismatch5.purs
new file mode 100644
index 0000000000..f656f507eb
--- /dev/null
+++ b/tests/purs/failing/CoercibleRoleMismatch5.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith RoleMismatch
+module Main where
+
+data F a = F a (G a)
+type role F phantom
+
+data G a = G (F a)
diff --git a/tests/purs/failing/CoercibleUnknownRowTail1.out b/tests/purs/failing/CoercibleUnknownRowTail1.out
new file mode 100644
index 0000000000..b89412208d
--- /dev/null
+++ b/tests/purs/failing/CoercibleUnknownRowTail1.out
@@ -0,0 +1,41 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleUnknownRowTail1.purs:7:9 - 7:24 (line 7, column 9 - line 7, column 24)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible ()[0m
+ [33m t0[0m
+ [33m [0m
+ The instance head contains unknown type variables. Consider adding a type annotation.
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible { a :: Int[0m
+[33m } [0m
+[33m { a :: Int[0m
+[33m | t0 [0m
+[33m } [0m
+[33m [0m
+while applying a function [33mcoerce[0m
+ of type [33mCoercible @Type t1 t2 => t1 -> t2[0m
+ to argument [33m{ a: 0[0m
+ [33m} [0m
+while checking that expression [33mcoerce { a: 0[0m
+ [33m } [0m
+ has type [33m{ a :: Int[0m
+ [33m| t0 [0m
+ [33m} [0m
+while checking type of property accessor [33m(coerce { a: ...[0m
+ [33m } [0m
+ [33m) [0m
+ [33m.a [0m
+in value declaration [33mzero[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleUnknownRowTail1.purs b/tests/purs/failing/CoercibleUnknownRowTail1.purs
new file mode 100644
index 0000000000..d17b51d96f
--- /dev/null
+++ b/tests/purs/failing/CoercibleUnknownRowTail1.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+zero :: Int
+zero = (coerce { a: 0 }).a
diff --git a/tests/purs/failing/CoercibleUnknownRowTail2.out b/tests/purs/failing/CoercibleUnknownRowTail2.out
new file mode 100644
index 0000000000..079d79368f
--- /dev/null
+++ b/tests/purs/failing/CoercibleUnknownRowTail2.out
@@ -0,0 +1,46 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CoercibleUnknownRowTail2.purs:7:9 - 7:30 (line 7, column 9 - line 7, column 30)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Coerce.Coercible ( b :: Int[0m
+ [33m ) [0m
+ [33m t0 [0m
+ [33m [0m
+ The instance head contains unknown type variables. Consider adding a type annotation.
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible { a :: Int[0m
+[33m , b :: Int[0m
+[33m } [0m
+[33m { a :: Int[0m
+[33m | t0 [0m
+[33m } [0m
+[33m [0m
+while applying a function [33mcoerce[0m
+ of type [33mCoercible @Type t1 t2 => t1 -> t2[0m
+ to argument [33m{ a: 0[0m
+ [33m, b: 1[0m
+ [33m} [0m
+while checking that expression [33mcoerce { a: 0[0m
+ [33m , b: 1[0m
+ [33m } [0m
+ has type [33m{ a :: Int[0m
+ [33m| t0 [0m
+ [33m} [0m
+while checking type of property accessor [33m(coerce { a: ...[0m
+ [33m , b: ...[0m
+ [33m } [0m
+ [33m) [0m
+ [33m.a [0m
+in value declaration [33mzero[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CoercibleUnknownRowTail2.purs b/tests/purs/failing/CoercibleUnknownRowTail2.purs
new file mode 100644
index 0000000000..9ab45b9705
--- /dev/null
+++ b/tests/purs/failing/CoercibleUnknownRowTail2.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Safe.Coerce (coerce)
+
+zero :: Int
+zero = (coerce { a: 0, b: 1 }).a
diff --git a/tests/purs/failing/CompareInt1.out b/tests/purs/failing/CompareInt1.out
new file mode 100644
index 0000000000..452403b8b6
--- /dev/null
+++ b/tests/purs/failing/CompareInt1.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt1.purs:14:16 - 14:29 (line 14, column 16 - line 14, column 29)
+
+ Could not match type
+ [33m [0m
+ [33m EQ[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m GT[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare a0[0m
+[33m b1[0m
+[33m GT[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r GT => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: b1 [0m
+ [33m ) [0m
+while checking that expression [33massertGreater[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: b1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mb1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt1.purs b/tests/purs/failing/CompareInt1.purs
new file mode 100644
index 0000000000..d53a28c5f7
--- /dev/null
+++ b/tests/purs/failing/CompareInt1.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertGreater :: forall l r. Compare l r GT => Proxy ( left :: l, right :: r )
+assertGreater = Proxy
+
+impossible :: forall a b c. Compare a b EQ => Compare b c GT => Proxy c -> Proxy ( left :: a, right :: b )
+impossible _ = assertGreater
diff --git a/tests/purs/failing/CompareInt10.out b/tests/purs/failing/CompareInt10.out
new file mode 100644
index 0000000000..35b30cb145
--- /dev/null
+++ b/tests/purs/failing/CompareInt10.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt10.purs:14:16 - 14:27 (line 14, column 16 - line 14, column 27)
+
+ Could not match type
+ [33m [0m
+ [33m LT[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m EQ[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare c0[0m
+[33m a1[0m
+[33m EQ[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r EQ => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: c0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+while checking that expression [33massertEqual[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: c0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mc0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt10.purs b/tests/purs/failing/CompareInt10.purs
new file mode 100644
index 0000000000..fef893fbcf
--- /dev/null
+++ b/tests/purs/failing/CompareInt10.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertEqual :: forall l r. Compare l r EQ => Proxy ( left :: l, right :: r )
+assertEqual = Proxy
+
+impossible :: forall a b c. Compare a b GT => Compare b c GT => Proxy c -> Proxy ( left :: c, right :: a )
+impossible _ = assertEqual
diff --git a/tests/purs/failing/CompareInt11.out b/tests/purs/failing/CompareInt11.out
new file mode 100644
index 0000000000..930710c038
--- /dev/null
+++ b/tests/purs/failing/CompareInt11.out
@@ -0,0 +1,33 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt11.purs:14:14 - 14:26 (line 14, column 14 - line 14, column 26)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Int.Compare a0[0m
+ [33m 5 [0m
+ [33m LT[0m
+ [33m [0m
+
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r LT => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: 5 [0m
+ [33m ) [0m
+while checking that expression [33massertLesser[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: 5 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 14, column 14 - line 14, column 26)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt11.purs b/tests/purs/failing/CompareInt11.purs
new file mode 100644
index 0000000000..a5ae237841
--- /dev/null
+++ b/tests/purs/failing/CompareInt11.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertLesser :: forall l r. Compare l r LT => Proxy ( left :: l, right :: r )
+assertLesser = Proxy
+
+impossible :: forall a. Compare a 10 LT => Proxy ( left :: a, right :: 5 )
+impossible = assertLesser
diff --git a/tests/purs/failing/CompareInt12.out b/tests/purs/failing/CompareInt12.out
new file mode 100644
index 0000000000..8a56b46db2
--- /dev/null
+++ b/tests/purs/failing/CompareInt12.out
@@ -0,0 +1,33 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt12.purs:14:14 - 14:27 (line 14, column 14 - line 14, column 27)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Int.Compare a0[0m
+ [33m 20[0m
+ [33m GT[0m
+ [33m [0m
+
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r GT => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: 20 [0m
+ [33m ) [0m
+while checking that expression [33massertGreater[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: 20 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 14, column 14 - line 14, column 27)
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt12.purs b/tests/purs/failing/CompareInt12.purs
new file mode 100644
index 0000000000..9e1bbef689
--- /dev/null
+++ b/tests/purs/failing/CompareInt12.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith NoInstanceFound
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertGreater :: forall l r. Compare l r GT => Proxy ( left :: l, right :: r )
+assertGreater = Proxy
+
+impossible :: forall a. Compare a 10 GT => Proxy ( left :: a, right :: 20 )
+impossible = assertGreater
diff --git a/tests/purs/failing/CompareInt2.out b/tests/purs/failing/CompareInt2.out
new file mode 100644
index 0000000000..8817b303d9
--- /dev/null
+++ b/tests/purs/failing/CompareInt2.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt2.purs:14:14 - 14:27 (line 14, column 14 - line 14, column 27)
+
+ Could not match type
+ [33m [0m
+ [33m LT[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m GT[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare b0[0m
+[33m a1[0m
+[33m GT[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r GT => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: b0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+while checking that expression [33massertGreater[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: b0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma1[0m is a rigid type variable
+ bound at (line 14, column 14 - line 14, column 27)
+ [33mb0[0m is a rigid type variable
+ bound at (line 14, column 14 - line 14, column 27)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt2.purs b/tests/purs/failing/CompareInt2.purs
new file mode 100644
index 0000000000..06ba919f83
--- /dev/null
+++ b/tests/purs/failing/CompareInt2.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertGreater :: forall l r. Compare l r GT => Proxy ( left :: l, right :: r )
+assertGreater = Proxy
+
+impossible :: forall a b. Compare a b GT => Proxy ( left :: b, right :: a )
+impossible = assertGreater
diff --git a/tests/purs/failing/CompareInt3.out b/tests/purs/failing/CompareInt3.out
new file mode 100644
index 0000000000..35c8a1d0da
--- /dev/null
+++ b/tests/purs/failing/CompareInt3.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt3.purs:14:16 - 14:28 (line 14, column 16 - line 14, column 28)
+
+ Could not match type
+ [33m [0m
+ [33m EQ[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m LT[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare a0[0m
+[33m b1[0m
+[33m LT[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r LT => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: b1 [0m
+ [33m ) [0m
+while checking that expression [33massertLesser[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: b1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mb1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt3.purs b/tests/purs/failing/CompareInt3.purs
new file mode 100644
index 0000000000..93bc00b8c2
--- /dev/null
+++ b/tests/purs/failing/CompareInt3.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertLesser :: forall l r. Compare l r LT => Proxy ( left :: l, right :: r )
+assertLesser = Proxy
+
+impossible :: forall a b c. Compare a b EQ => Compare b c LT => Proxy c -> Proxy ( left :: a, right :: b )
+impossible _ = assertLesser
diff --git a/tests/purs/failing/CompareInt4.out b/tests/purs/failing/CompareInt4.out
new file mode 100644
index 0000000000..d2c7f2956d
--- /dev/null
+++ b/tests/purs/failing/CompareInt4.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt4.purs:14:14 - 14:26 (line 14, column 14 - line 14, column 26)
+
+ Could not match type
+ [33m [0m
+ [33m GT[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m LT[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare b0[0m
+[33m a1[0m
+[33m LT[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r LT => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: b0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+while checking that expression [33massertLesser[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: b0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma1[0m is a rigid type variable
+ bound at (line 14, column 14 - line 14, column 26)
+ [33mb0[0m is a rigid type variable
+ bound at (line 14, column 14 - line 14, column 26)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt4.purs b/tests/purs/failing/CompareInt4.purs
new file mode 100644
index 0000000000..fca2e6d42a
--- /dev/null
+++ b/tests/purs/failing/CompareInt4.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertLesser :: forall l r. Compare l r LT => Proxy ( left :: l, right :: r )
+assertLesser = Proxy
+
+impossible :: forall a b. Compare a b LT => Proxy ( left :: b, right :: a )
+impossible = assertLesser
diff --git a/tests/purs/failing/CompareInt5.out b/tests/purs/failing/CompareInt5.out
new file mode 100644
index 0000000000..a7e90314c4
--- /dev/null
+++ b/tests/purs/failing/CompareInt5.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt5.purs:14:16 - 14:29 (line 14, column 16 - line 14, column 29)
+
+ Could not match type
+ [33m [0m
+ [33m LT[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m GT[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare c0[0m
+[33m a1[0m
+[33m GT[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r GT => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: c0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+while checking that expression [33massertGreater[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: c0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mc0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt5.purs b/tests/purs/failing/CompareInt5.purs
new file mode 100644
index 0000000000..f4f8fba8a8
--- /dev/null
+++ b/tests/purs/failing/CompareInt5.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertGreater :: forall l r. Compare l r GT => Proxy ( left :: l, right :: r )
+assertGreater = Proxy
+
+impossible :: forall a b c. Compare a b GT => Compare b c GT => Proxy c -> Proxy ( left :: c, right :: a )
+impossible _ = assertGreater
diff --git a/tests/purs/failing/CompareInt6.out b/tests/purs/failing/CompareInt6.out
new file mode 100644
index 0000000000..a355c5dba3
--- /dev/null
+++ b/tests/purs/failing/CompareInt6.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt6.purs:14:16 - 14:28 (line 14, column 16 - line 14, column 28)
+
+ Could not match type
+ [33m [0m
+ [33m GT[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m LT[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare c0[0m
+[33m a1[0m
+[33m LT[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r LT => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: c0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+while checking that expression [33massertLesser[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: c0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mc0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt6.purs b/tests/purs/failing/CompareInt6.purs
new file mode 100644
index 0000000000..d9ba79f870
--- /dev/null
+++ b/tests/purs/failing/CompareInt6.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertLesser :: forall l r. Compare l r LT => Proxy ( left :: l, right :: r )
+assertLesser = Proxy
+
+impossible :: forall a b c. Compare a b LT => Compare b c LT => Proxy c -> Proxy ( left :: c, right :: a )
+impossible _ = assertLesser
diff --git a/tests/purs/failing/CompareInt7.out b/tests/purs/failing/CompareInt7.out
new file mode 100644
index 0000000000..f065e86703
--- /dev/null
+++ b/tests/purs/failing/CompareInt7.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt7.purs:14:16 - 14:27 (line 14, column 16 - line 14, column 27)
+
+ Could not match type
+ [33m [0m
+ [33m LT[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m EQ[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare a0[0m
+[33m c1[0m
+[33m EQ[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r EQ => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: c1 [0m
+ [33m ) [0m
+while checking that expression [33massertEqual[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: c1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mc1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt7.purs b/tests/purs/failing/CompareInt7.purs
new file mode 100644
index 0000000000..2155a911d2
--- /dev/null
+++ b/tests/purs/failing/CompareInt7.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertEqual :: forall l r. Compare l r EQ => Proxy ( left :: l, right :: r )
+assertEqual = Proxy
+
+impossible :: forall a b c. Compare a b LT => Compare b c LT => Proxy c -> Proxy ( left :: a, right :: c )
+impossible _ = assertEqual
diff --git a/tests/purs/failing/CompareInt8.out b/tests/purs/failing/CompareInt8.out
new file mode 100644
index 0000000000..e7c4cbd1d0
--- /dev/null
+++ b/tests/purs/failing/CompareInt8.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt8.purs:14:16 - 14:27 (line 14, column 16 - line 14, column 27)
+
+ Could not match type
+ [33m [0m
+ [33m GT[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m EQ[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare a0[0m
+[33m c1[0m
+[33m EQ[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r EQ => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: c1 [0m
+ [33m ) [0m
+while checking that expression [33massertEqual[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: a0 [0m
+ [33m , right :: c1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mc1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt8.purs b/tests/purs/failing/CompareInt8.purs
new file mode 100644
index 0000000000..85bf481870
--- /dev/null
+++ b/tests/purs/failing/CompareInt8.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertEqual :: forall l r. Compare l r EQ => Proxy ( left :: l, right :: r )
+assertEqual = Proxy
+
+impossible :: forall a b c. Compare a b GT => Compare b c GT => Proxy c -> Proxy ( left :: a, right :: c )
+impossible _ = assertEqual
diff --git a/tests/purs/failing/CompareInt9.out b/tests/purs/failing/CompareInt9.out
new file mode 100644
index 0000000000..9e55dcf883
--- /dev/null
+++ b/tests/purs/failing/CompareInt9.out
@@ -0,0 +1,43 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/CompareInt9.purs:14:16 - 14:27 (line 14, column 16 - line 14, column 27)
+
+ Could not match type
+ [33m [0m
+ [33m GT[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m EQ[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.Compare c0[0m
+[33m a1[0m
+[33m EQ[0m
+[33m [0m
+while checking that type [33mforall (l :: Int) (r :: Int). [0m
+ [33m Compare l r EQ => Proxy @(Row Int)[0m
+ [33m ( left :: l [0m
+ [33m , right :: r [0m
+ [33m ) [0m
+ is at least as general as type [33mProxy @(Row Int)[0m
+ [33m ( left :: c0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+while checking that expression [33massertEqual[0m
+ has type [33mProxy @(Row Int)[0m
+ [33m ( left :: c0 [0m
+ [33m , right :: a1 [0m
+ [33m ) [0m
+in value declaration [33mimpossible[0m
+
+where [33ma1[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mc0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CompareInt9.purs b/tests/purs/failing/CompareInt9.purs
new file mode 100644
index 0000000000..21743243b2
--- /dev/null
+++ b/tests/purs/failing/CompareInt9.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertEqual :: forall l r. Compare l r EQ => Proxy ( left :: l, right :: r )
+assertEqual = Proxy
+
+impossible :: forall a b c. Compare a b LT => Compare b c LT => Proxy c -> Proxy ( left :: c, right :: a )
+impossible _ = assertEqual
diff --git a/tests/purs/failing/ConflictingExports.out b/tests/purs/failing/ConflictingExports.out
new file mode 100644
index 0000000000..daea92c591
--- /dev/null
+++ b/tests/purs/failing/ConflictingExports.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConflictingExports.purs:3:14 - 3:22 (line 3, column 14 - line 3, column 22)
+
+ Conflicting definitions are in scope for value [33mthing[0m from the following modules:
+
+ [33mA[0m
+ [33mB[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConflictingImports.out b/tests/purs/failing/ConflictingImports.out
new file mode 100644
index 0000000000..7fc2a98d51
--- /dev/null
+++ b/tests/purs/failing/ConflictingImports.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConflictingImports.purs:9:8 - 9:13 (line 9, column 8 - line 9, column 13)
+
+ Conflicting definitions are in scope for value [33mthing[0m from the following modules:
+
+ [33mA[0m
+ [33mB[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConflictingImports/B.out b/tests/purs/failing/ConflictingImports/B.out
new file mode 100644
index 0000000000..7fc2a98d51
--- /dev/null
+++ b/tests/purs/failing/ConflictingImports/B.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConflictingImports.purs:9:8 - 9:13 (line 9, column 8 - line 9, column 13)
+
+ Conflicting definitions are in scope for value [33mthing[0m from the following modules:
+
+ [33mA[0m
+ [33mB[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConflictingImports2.out b/tests/purs/failing/ConflictingImports2.out
new file mode 100644
index 0000000000..626414bbcd
--- /dev/null
+++ b/tests/purs/failing/ConflictingImports2.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConflictingImports2.purs:10:8 - 10:13 (line 10, column 8 - line 10, column 13)
+
+ Conflicting definitions are in scope for value [33mthing[0m from the following modules:
+
+ [33mA[0m
+ [33mB[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConflictingImports2/B.out b/tests/purs/failing/ConflictingImports2/B.out
new file mode 100644
index 0000000000..626414bbcd
--- /dev/null
+++ b/tests/purs/failing/ConflictingImports2/B.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConflictingImports2.purs:10:8 - 10:13 (line 10, column 8 - line 10, column 13)
+
+ Conflicting definitions are in scope for value [33mthing[0m from the following modules:
+
+ [33mA[0m
+ [33mB[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConflictingQualifiedImports.out b/tests/purs/failing/ConflictingQualifiedImports.out
new file mode 100644
index 0000000000..9b97c8aa64
--- /dev/null
+++ b/tests/purs/failing/ConflictingQualifiedImports.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConflictingQualifiedImports.purs:7:7 - 7:14 (line 7, column 7 - line 7, column 14)
+
+ Conflicting definitions are in scope for value [33mthing[0m from the following modules:
+
+ [33mA[0m
+ [33mB[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConflictingQualifiedImports2.out b/tests/purs/failing/ConflictingQualifiedImports2.out
new file mode 100644
index 0000000000..cbac1abae7
--- /dev/null
+++ b/tests/purs/failing/ConflictingQualifiedImports2.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConflictingQualifiedImports2.purs:2:14 - 2:22 (line 2, column 14 - line 2, column 22)
+
+ Conflicting definitions are in scope for value [33mthing[0m from the following modules:
+
+ [33mA[0m
+ [33mB[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConflictingQualifiedImports2/B.out b/tests/purs/failing/ConflictingQualifiedImports2/B.out
new file mode 100644
index 0000000000..cbac1abae7
--- /dev/null
+++ b/tests/purs/failing/ConflictingQualifiedImports2/B.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConflictingQualifiedImports2.purs:2:14 - 2:22 (line 2, column 14 - line 2, column 22)
+
+ Conflicting definitions are in scope for value [33mthing[0m from the following modules:
+
+ [33mA[0m
+ [33mB[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConstraintFailure.out b/tests/purs/failing/ConstraintFailure.out
new file mode 100644
index 0000000000..f6207999b7
--- /dev/null
+++ b/tests/purs/failing/ConstraintFailure.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConstraintFailure.purs:12:8 - 12:12 (line 12, column 8 - line 12, column 12)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Data.Show.Show Foo[0m
+ [33m [0m
+
+while checking that type [33mforall (@a :: Type). Show a => a -> String[0m
+ is at least as general as type [33mt0 t1 t2[0m
+while checking that expression [33mshow[0m
+ has type [33mt0 t1 t2[0m
+in value declaration [33mmain[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConstraintInForeignImport.js b/tests/purs/failing/ConstraintInForeignImport.js
new file mode 100644
index 0000000000..8e629a2a03
--- /dev/null
+++ b/tests/purs/failing/ConstraintInForeignImport.js
@@ -0,0 +1,5 @@
+export var show = function (showDict) {
+ return function (a) {
+ return showDict.show(a);
+ };
+};
diff --git a/tests/purs/failing/ConstraintInForeignImport.out b/tests/purs/failing/ConstraintInForeignImport.out
new file mode 100644
index 0000000000..f50837b3a1
--- /dev/null
+++ b/tests/purs/failing/ConstraintInForeignImport.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/ConstraintInForeignImport.purs:6:1 - 6:50 (line 6, column 1 - line 6, column 50)
+
+ Unable to parse module:
+ Constraints are not allowed in foreign imports. Omit the constraint instead and update the foreign module accordingly.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ConstraintInForeignImport.purs b/tests/purs/failing/ConstraintInForeignImport.purs
new file mode 100644
index 0000000000..81677f8bb5
--- /dev/null
+++ b/tests/purs/failing/ConstraintInForeignImport.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith ErrorParsingModule
+module Main where
+
+import Data.Show (class Show)
+
+foreign import show :: ∀ a. Show a => a -> String
diff --git a/tests/purs/failing/ConstraintInference.out b/tests/purs/failing/ConstraintInference.out
new file mode 100644
index 0000000000..b927321573
--- /dev/null
+++ b/tests/purs/failing/ConstraintInference.out
@@ -0,0 +1,19 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ConstraintInference.purs:10:1 - 10:21 (line 10, column 1 - line 10, column 21)
+
+ The inferred type
+ [33m [0m
+ [33m forall c8 t11. Show c8 => t11 -> String[0m
+ [33m [0m
+ has type variables which are not determined by those mentioned in the body of the type:
+
+ [33mc8[0m could not be determined
+
+ Consider adding a type annotation.
+
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/AmbiguousTypeVariables.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ContravariantInstance1.out b/tests/purs/failing/ContravariantInstance1.out
new file mode 100644
index 0000000000..e539305cf8
--- /dev/null
+++ b/tests/purs/failing/ContravariantInstance1.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mContravariantInstance1[0m
+at tests/purs/failing/ContravariantInstance1.purs:9:1 - 9:35 (line 9, column 1 - line 9, column 35)
+
+ One or more type variables are in positions that prevent [33mContravariant[0m from being derived.
+ To derive this class, make sure that these variables are only used as the final arguments to type constructors, that their variance matches the variance of [33mContravariant[0m, and that those type constructors themselves have instances of [33mData.Functor.Functor[0m, [33mData.Bifunctor.Bifunctor[0m, [33mData.Functor.Contravariant.Contravariant[0m, or [33mData.Profunctor.Profunctor[0m.
+
+ tests/purs/failing/ContravariantInstance1.purs:
+ [90m 6[0m [33m[0m
+ [90m 7[0m [33mnewtype Test a = Test (Predicate (Predicate [7ma[27m))[0m
+ [90m 8[0m [33m[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDeriveInvalidConstructorArg.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ContravariantInstance1.purs b/tests/purs/failing/ContravariantInstance1.purs
new file mode 100644
index 0000000000..ddd318e0d9
--- /dev/null
+++ b/tests/purs/failing/ContravariantInstance1.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith CannotDeriveInvalidConstructorArg
+module ContravariantInstance1 where
+
+import Data.Functor.Contravariant (class Contravariant)
+import Data.Predicate (Predicate)
+
+newtype Test a = Test (Predicate (Predicate a))
+
+derive instance Contravariant Test
diff --git a/tests/purs/failing/CycleInForeignDataKinds.out b/tests/purs/failing/CycleInForeignDataKinds.out
new file mode 100644
index 0000000000..0f52489413
--- /dev/null
+++ b/tests/purs/failing/CycleInForeignDataKinds.out
@@ -0,0 +1,13 @@
+Error found:
+at tests/purs/failing/CycleInForeignDataKinds.purs:5:1 - 5:31 (line 5, column 1 - line 5, column 31)
+
+ A cycle appears in a set of kind declarations:
+
+ {[33mBar[0m, [33mFoo[0m}
+
+ Kind declarations may not refer to themselves in their own signatures.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInKindDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CycleInForeignDataKinds.purs b/tests/purs/failing/CycleInForeignDataKinds.purs
new file mode 100644
index 0000000000..0328c410d0
--- /dev/null
+++ b/tests/purs/failing/CycleInForeignDataKinds.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith CycleInKindDeclaration
+module Main where
+
+foreign import data Foo :: Bar
+foreign import data Bar :: Foo
diff --git a/tests/purs/failing/CycleInKindDeclaration.out b/tests/purs/failing/CycleInKindDeclaration.out
new file mode 100644
index 0000000000..9c532d4c92
--- /dev/null
+++ b/tests/purs/failing/CycleInKindDeclaration.out
@@ -0,0 +1,13 @@
+Error found:
+at tests/purs/failing/CycleInKindDeclaration.purs:7:1 - 7:24 (line 7, column 1 - line 7, column 24)
+
+ A cycle appears in a set of kind declarations:
+
+ {[33mBar[0m, [33mFoo[0m}
+
+ Kind declarations may not refer to themselves in their own signatures.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInKindDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/CycleInKindDeclaration.purs b/tests/purs/failing/CycleInKindDeclaration.purs
new file mode 100644
index 0000000000..04c46e56f4
--- /dev/null
+++ b/tests/purs/failing/CycleInKindDeclaration.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith CycleInKindDeclaration
+module Main where
+
+data Foo :: Bar -> Type
+data Foo a = Foo
+
+data Bar :: Foo -> Type
+data Bar a = Bar
diff --git a/tests/purs/failing/DctorOperatorAliasExport.out b/tests/purs/failing/DctorOperatorAliasExport.out
new file mode 100644
index 0000000000..166409aee7
--- /dev/null
+++ b/tests/purs/failing/DctorOperatorAliasExport.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mData.List[0m
+at tests/purs/failing/DctorOperatorAliasExport.purs:2:1 - 6:21 (line 2, column 1 - line 6, column 21)
+
+ An export for [33m(:)[0m requires the following data constructor to also be exported:
+
+ [33mCons[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveDctorExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictClassCtor.out b/tests/purs/failing/DeclConflictClassCtor.out
new file mode 100644
index 0000000000..1255cf83fd
--- /dev/null
+++ b/tests/purs/failing/DeclConflictClassCtor.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictClassCtor.purs:6:1 - 6:11 (line 6, column 1 - line 6, column 11)
+
+ Declaration for type class [33mFail[0m conflicts with an existing data constructor of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictClassSynonym.out b/tests/purs/failing/DeclConflictClassSynonym.out
new file mode 100644
index 0000000000..d702725c8e
--- /dev/null
+++ b/tests/purs/failing/DeclConflictClassSynonym.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictClassSynonym.purs:8:1 - 8:11 (line 8, column 1 - line 8, column 11)
+
+ Declaration for type class [33mFail[0m conflicts with an existing type of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictClassType.out b/tests/purs/failing/DeclConflictClassType.out
new file mode 100644
index 0000000000..c7d9bcc3e3
--- /dev/null
+++ b/tests/purs/failing/DeclConflictClassType.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictClassType.purs:6:1 - 6:10 (line 6, column 1 - line 6, column 10)
+
+ Declaration for type [33mFail[0m conflicts with an existing type class of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictCtorClass.out b/tests/purs/failing/DeclConflictCtorClass.out
new file mode 100644
index 0000000000..6154617500
--- /dev/null
+++ b/tests/purs/failing/DeclConflictCtorClass.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictCtorClass.purs:6:1 - 6:14 (line 6, column 1 - line 6, column 14)
+
+ Declaration for data constructor [33mFail[0m conflicts with an existing type class of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictCtorCtor.out b/tests/purs/failing/DeclConflictCtorCtor.out
new file mode 100644
index 0000000000..eb449fd223
--- /dev/null
+++ b/tests/purs/failing/DeclConflictCtorCtor.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictCtorCtor.purs:6:1 - 6:15 (line 6, column 1 - line 6, column 15)
+
+ Declaration for data constructor [33mFail[0m conflicts with an existing data constructor of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictDuplicateCtor.out b/tests/purs/failing/DeclConflictDuplicateCtor.out
new file mode 100644
index 0000000000..dd1e822bee
--- /dev/null
+++ b/tests/purs/failing/DeclConflictDuplicateCtor.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictDuplicateCtor.purs:4:1 - 4:21 (line 4, column 1 - line 4, column 21)
+
+ Declaration for data constructor [33mFail[0m conflicts with an existing data constructor of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictSynonymClass.out b/tests/purs/failing/DeclConflictSynonymClass.out
new file mode 100644
index 0000000000..a2c7f59b2e
--- /dev/null
+++ b/tests/purs/failing/DeclConflictSynonymClass.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictSynonymClass.purs:8:1 - 8:17 (line 8, column 1 - line 8, column 17)
+
+ Declaration for type [33mFail[0m conflicts with an existing type class of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictSynonymType.out b/tests/purs/failing/DeclConflictSynonymType.out
new file mode 100644
index 0000000000..a4d2112e19
--- /dev/null
+++ b/tests/purs/failing/DeclConflictSynonymType.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictSynonymType.purs:8:1 - 8:17 (line 8, column 1 - line 8, column 17)
+
+ Declaration for type [33mFail[0m conflicts with an existing type of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictTypeClass.out b/tests/purs/failing/DeclConflictTypeClass.out
new file mode 100644
index 0000000000..1e1c9edb98
--- /dev/null
+++ b/tests/purs/failing/DeclConflictTypeClass.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictTypeClass.purs:6:1 - 6:10 (line 6, column 1 - line 6, column 10)
+
+ Declaration for type [33mFail[0m conflicts with an existing type class of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictTypeSynonym.out b/tests/purs/failing/DeclConflictTypeSynonym.out
new file mode 100644
index 0000000000..a80b3db1c6
--- /dev/null
+++ b/tests/purs/failing/DeclConflictTypeSynonym.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictTypeSynonym.purs:8:1 - 8:10 (line 8, column 1 - line 8, column 10)
+
+ Declaration for type [33mFail[0m conflicts with an existing type of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeclConflictTypeType.out b/tests/purs/failing/DeclConflictTypeType.out
new file mode 100644
index 0000000000..33ee9ea366
--- /dev/null
+++ b/tests/purs/failing/DeclConflictTypeType.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeclConflictTypeType.purs:6:1 - 6:10 (line 6, column 1 - line 6, column 10)
+
+ Declaration for type [33mFail[0m conflicts with an existing type of the same name.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeclConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeprecatedFFICommonJSModule.js b/tests/purs/failing/DeprecatedFFICommonJSModule.js
new file mode 100644
index 0000000000..45e5121ffc
--- /dev/null
+++ b/tests/purs/failing/DeprecatedFFICommonJSModule.js
@@ -0,0 +1,4 @@
+"use strict";
+
+exports.yes = true;
+exports.no = true;
diff --git a/tests/purs/failing/DeprecatedFFICommonJSModule.out b/tests/purs/failing/DeprecatedFFICommonJSModule.out
new file mode 100644
index 0000000000..60ae55d931
--- /dev/null
+++ b/tests/purs/failing/DeprecatedFFICommonJSModule.out
@@ -0,0 +1,13 @@
+Error found:
+at tests/purs/failing/DeprecatedFFICommonJSModule.purs:2:1 - 5:29 (line 2, column 1 - line 5, column 29)
+
+ A CommonJS foreign module implementation was provided for module [33mMain[0m:
+
+ tests/purs/failing/DeprecatedFFICommonJSModule.js
+
+ CommonJS foreign modules are no longer supported. Use native JavaScript/ECMAScript module syntax instead.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeprecatedFFICommonJSModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeprecatedFFICommonJSModule.purs b/tests/purs/failing/DeprecatedFFICommonJSModule.purs
new file mode 100644
index 0000000000..6c5f21e6d5
--- /dev/null
+++ b/tests/purs/failing/DeprecatedFFICommonJSModule.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith DeprecatedFFICommonJSModule
+module Main where
+
+foreign import yes :: Boolean
+foreign import no :: Boolean
diff --git a/tests/purs/passing/2172.js b/tests/purs/failing/DeprecatedFFIPrime.js
similarity index 100%
rename from tests/purs/passing/2172.js
rename to tests/purs/failing/DeprecatedFFIPrime.js
diff --git a/tests/purs/failing/DeprecatedFFIPrime.out b/tests/purs/failing/DeprecatedFFIPrime.out
new file mode 100644
index 0000000000..fd22d4708b
--- /dev/null
+++ b/tests/purs/failing/DeprecatedFFIPrime.out
@@ -0,0 +1,56 @@
+Error 1 of 4:
+
+ at tests/purs/failing/DeprecatedFFIPrime.purs:5:1 - 10:28 (line 5, column 1 - line 10, column 28)
+
+ In the FFI module for [33mMain[0m:
+
+ The identifier [33ma'[0m contains a prime ([33m'[0m).
+ Primes are not allowed in identifiers exported from FFI modules.
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DeprecatedFFIPrime.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 4:
+
+ at tests/purs/failing/DeprecatedFFIPrime.purs:5:1 - 10:28 (line 5, column 1 - line 10, column 28)
+
+ In the FFI module for [33mMain[0m:
+
+ The identifier [33mb'[0m contains a prime ([33m'[0m).
+ Primes are not allowed in identifiers exported from FFI modules.
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DeprecatedFFIPrime.md for more information,
+ or to contribute content related to this error.
+
+Error 3 of 4:
+
+ at tests/purs/failing/DeprecatedFFIPrime.purs:5:1 - 10:28 (line 5, column 1 - line 10, column 28)
+
+ In the FFI module for [33mMain[0m:
+
+ The identifier [33mc'[0m contains a prime ([33m'[0m).
+ Primes are not allowed in identifiers exported from FFI modules.
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DeprecatedFFIPrime.md for more information,
+ or to contribute content related to this error.
+
+Error 4 of 4:
+
+ at tests/purs/failing/DeprecatedFFIPrime.purs:5:1 - 10:28 (line 5, column 1 - line 10, column 28)
+
+ In the FFI module for [33mMain[0m:
+
+ The identifier [33md'[0m contains a prime ([33m'[0m).
+ Primes are not allowed in identifiers exported from FFI modules.
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DeprecatedFFIPrime.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeprecatedFFIPrime.purs b/tests/purs/failing/DeprecatedFFIPrime.purs
new file mode 100644
index 0000000000..0100e1fad8
--- /dev/null
+++ b/tests/purs/failing/DeprecatedFFIPrime.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith DeprecatedFFIPrime
+-- @shouldFailWith DeprecatedFFIPrime
+-- @shouldFailWith DeprecatedFFIPrime
+-- @shouldFailWith DeprecatedFFIPrime
+module Main where
+
+foreign import a' :: Number
+foreign import b' :: Number
+foreign import c' :: Number
+foreign import d' :: Number
diff --git a/tests/purs/failing/DeriveClauseCannotDerive.out b/tests/purs/failing/DeriveClauseCannotDerive.out
new file mode 100644
index 0000000000..a654d7db7e
--- /dev/null
+++ b/tests/purs/failing/DeriveClauseCannotDerive.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeriveClauseCannotDerive.purs:7:11 - 7:18 (line 7, column 11 - line 7, column 18)
+
+ Cannot derive a type class instance for
+ [33m [0m
+ [33m Main.MyClass Foo[0m
+ [33m [0m
+ since instances of this type class are not derivable.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDerive.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeriveClauseCannotDerive.purs b/tests/purs/failing/DeriveClauseCannotDerive.purs
new file mode 100644
index 0000000000..7ca01a293e
--- /dev/null
+++ b/tests/purs/failing/DeriveClauseCannotDerive.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith CannotDerive
+module Main where
+
+class MyClass a
+
+data Foo a = Foo a
+ derive (MyClass)
diff --git a/tests/purs/failing/DeriveClauseEither2.out b/tests/purs/failing/DeriveClauseEither2.out
new file mode 100644
index 0000000000..9ed2a40315
--- /dev/null
+++ b/tests/purs/failing/DeriveClauseEither2.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeriveClauseEither2.purs:7:11 - 7:13 (line 7, column 11 - line 7, column 13)
+
+ Could not match kind
+ [33m [0m
+ [33m Type -> Type -> Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33mEither2[0m
+ has kind [33mType[0m
+while inferring the kind of [33mEq Either2[0m
+in type class instance
+[33m [0m
+[33m Data.Eq.Eq Either2[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeriveClauseEither2.purs b/tests/purs/failing/DeriveClauseEither2.purs
new file mode 100644
index 0000000000..24a0c00053
--- /dev/null
+++ b/tests/purs/failing/DeriveClauseEither2.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+import Prelude
+
+data Either2 a b = Left2 a | Right2 b
+ derive (Eq)
diff --git a/tests/purs/failing/DeriveClauseKindMismatch.out b/tests/purs/failing/DeriveClauseKindMismatch.out
new file mode 100644
index 0000000000..65799ec128
--- /dev/null
+++ b/tests/purs/failing/DeriveClauseKindMismatch.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeriveClauseKindMismatch.purs:7:11 - 7:13 (line 7, column 11 - line 7, column 13)
+
+ Could not match kind
+ [33m [0m
+ [33m Type -> Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33mBox[0m
+ has kind [33mType[0m
+while inferring the kind of [33mEq Box[0m
+in type class instance
+[33m [0m
+[33m Data.Eq.Eq Box[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeriveClauseKindMismatch.purs b/tests/purs/failing/DeriveClauseKindMismatch.purs
new file mode 100644
index 0000000000..5404a49dee
--- /dev/null
+++ b/tests/purs/failing/DeriveClauseKindMismatch.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+import Prelude
+
+data Box a = Box a
+ derive (Eq)
diff --git a/tests/purs/failing/DeriveClauseNewtypeOverlap.out b/tests/purs/failing/DeriveClauseNewtypeOverlap.out
new file mode 100644
index 0000000000..fcbfbb733e
--- /dev/null
+++ b/tests/purs/failing/DeriveClauseNewtypeOverlap.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DeriveClauseNewtypeOverlap.purs:10:1 - 10:34 (line 10, column 1 - line 10, column 34)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m Data.Newtype.Newtype Wrapper[0m
+ [33m String [0m
+ [33m [0m
+ The following instances were found:
+
+ instance in module [33mMain[0m with type [33mNewtype Wrapper String[0m (line 8, column 11 - line 8, column 18)
+ instance in module [33mMain[0m with type [33mNewtype Wrapper String[0m (line 10, column 1 - line 10, column 34)
+
+
+in type class instance
+[33m [0m
+[33m Data.Newtype.Newtype Wrapper[0m
+[33m String [0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DeriveClauseNewtypeOverlap.purs b/tests/purs/failing/DeriveClauseNewtypeOverlap.purs
new file mode 100644
index 0000000000..0ba9b83cfb
--- /dev/null
+++ b/tests/purs/failing/DeriveClauseNewtypeOverlap.purs
@@ -0,0 +1,13 @@
+-- @shouldFailWith OverlappingInstances
+module Main where
+
+import Prelude
+import Data.Newtype (class Newtype, unwrap)
+
+newtype Wrapper = Wrapper String
+ derive (Newtype)
+
+derive instance Newtype Wrapper _
+
+value :: String
+value = unwrap (Wrapper "hi")
diff --git a/tests/purs/failing/DiffKindsSameName.out b/tests/purs/failing/DiffKindsSameName.out
new file mode 100644
index 0000000000..13f180f524
--- /dev/null
+++ b/tests/purs/failing/DiffKindsSameName.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mDiffKindsSameName[0m
+at tests/purs/failing/DiffKindsSameName.purs:13:18 - 13:31 (line 13, column 18 - line 13, column 31)
+
+ Could not match kind
+ [33m [0m
+ [33m DemoKind[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m DemoKind[0m
+ [33m [0m
+
+while checking that type [33mDemoData[0m
+ has kind [33mDemoKind[0m
+while inferring the kind of [33mAProxy DemoData[0m
+in value declaration [33mbProxy[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DiffKindsSameName/LibA.out b/tests/purs/failing/DiffKindsSameName/LibA.out
new file mode 100644
index 0000000000..89355c1062
--- /dev/null
+++ b/tests/purs/failing/DiffKindsSameName/LibA.out
@@ -0,0 +1,19 @@
+Error found:
+in module [33mDiffKindsSameName[0m
+at tests/purs/failing/DiffKindsSameName.purs:13:18 - 13:31 (line 13, column 18 - line 13, column 31)
+
+ Could not match kind
+
+ [33mDiffKindsSameName.LibA.DemoKind[0m
+
+ with kind
+
+ [33mDiffKindsSameName.LibB.DemoKind[0m
+
+
+while checking the kind of [33mAProxy DemoData[0m
+in value declaration [33mbProxy[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DiffKindsSameName/LibA.purs b/tests/purs/failing/DiffKindsSameName/LibA.purs
index d36b2ec15b..a87a610c0b 100644
--- a/tests/purs/failing/DiffKindsSameName/LibA.purs
+++ b/tests/purs/failing/DiffKindsSameName/LibA.purs
@@ -1,4 +1,4 @@
module DiffKindsSameName.LibA where
-foreign import kind DemoKind
+data DemoKind
diff --git a/tests/purs/failing/DiffKindsSameName/LibB.purs b/tests/purs/failing/DiffKindsSameName/LibB.purs
index 52bcb0f42b..9bfeddeb50 100644
--- a/tests/purs/failing/DiffKindsSameName/LibB.purs
+++ b/tests/purs/failing/DiffKindsSameName/LibB.purs
@@ -1,6 +1,6 @@
module DiffKindsSameName.LibB where
-foreign import kind DemoKind
+data DemoKind
foreign import data DemoData :: DemoKind
diff --git a/tests/purs/failing/Do.out b/tests/purs/failing/Do.out
new file mode 100644
index 0000000000..1305beb431
--- /dev/null
+++ b/tests/purs/failing/Do.out
@@ -0,0 +1,20 @@
+Error 1 of 2:
+
+ at tests/purs/failing/Do.purs:7:12 - 7:21 (line 7, column 12 - line 7, column 21)
+
+ The last statement in a 'do' block must be an expression, but this block ends with a let binding.
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/InvalidDoLet.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 2:
+
+ at tests/purs/failing/Do.purs:9:14 - 9:20 (line 9, column 14 - line 9, column 20)
+
+ The last statement in a 'do' block must be an expression, but this block ends with a binder.
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/InvalidDoBind.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DoNotSuggestComposition.out b/tests/purs/failing/DoNotSuggestComposition.out
new file mode 100644
index 0000000000..3f9019412d
--- /dev/null
+++ b/tests/purs/failing/DoNotSuggestComposition.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mDoNotSuggestComposition[0m
+at tests/purs/failing/DoNotSuggestComposition.purs:13:11 - 13:12 (line 13, column 11 - line 13, column 12)
+
+ Could not match type
+ [33m [0m
+ [33m { y :: Int[0m
+ [33m } [0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+
+while checking that type [33m{ y :: Int[0m
+ [33m} [0m
+ is at least as general as type [33mString[0m
+while checking that expression [33mx[0m
+ has type [33mString[0m
+in value declaration [33mbar[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DoNotSuggestComposition2.out b/tests/purs/failing/DoNotSuggestComposition2.out
new file mode 100644
index 0000000000..5126c8a650
--- /dev/null
+++ b/tests/purs/failing/DoNotSuggestComposition2.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mDoNotSuggestComposition2[0m
+at tests/purs/failing/DoNotSuggestComposition2.purs:7:27 - 7:30 (line 7, column 27 - line 7, column 30)
+
+ Could not match type
+ [33m [0m
+ [33m Record[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Function Int[0m
+ [33m [0m
+
+while trying to match type [33m{ y :: Int[0m
+ [33m} [0m
+ with type [33mInt -> t0[0m
+while inferring the type of [33mx 2[0m
+in value declaration [33mfoo[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DuplicateDeclarationsInLet.out b/tests/purs/failing/DuplicateDeclarationsInLet.out
new file mode 100644
index 0000000000..038e5e23c9
--- /dev/null
+++ b/tests/purs/failing/DuplicateDeclarationsInLet.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DuplicateDeclarationsInLet.purs:9:3 - 9:14 (line 9, column 3 - line 9, column 14)
+
+ The name [33ma[0m was defined multiple times in a binding group
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingNamesInLet.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DuplicateDeclarationsInLet.purs b/tests/purs/failing/DuplicateDeclarationsInLet.purs
index fed163d7aa..861a607d42 100644
--- a/tests/purs/failing/DuplicateDeclarationsInLet.purs
+++ b/tests/purs/failing/DuplicateDeclarationsInLet.purs
@@ -1,8 +1,6 @@
-- @shouldFailWith OverlappingNamesInLet
module Main where
-import Prelude
-
foo = a
where
a :: Number
diff --git a/tests/purs/failing/DuplicateDeclarationsInLet2.out b/tests/purs/failing/DuplicateDeclarationsInLet2.out
new file mode 100644
index 0000000000..25957ecbc8
--- /dev/null
+++ b/tests/purs/failing/DuplicateDeclarationsInLet2.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DuplicateDeclarationsInLet2.purs:10:3 - 10:24 (line 10, column 3 - line 10, column 24)
+
+ The name [33minterrupted[0m was defined multiple times in a binding group
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingNamesInLet.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DuplicateDeclarationsInLet2.purs b/tests/purs/failing/DuplicateDeclarationsInLet2.purs
new file mode 100644
index 0000000000..98549b3b1f
--- /dev/null
+++ b/tests/purs/failing/DuplicateDeclarationsInLet2.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith OverlappingNamesInLet
+module Main where
+
+foo = interrupted
+ where
+ interrupted true = 1
+
+ interrupter = 2
+
+ interrupted false = 3
diff --git a/tests/purs/failing/DuplicateDeclarationsInLet3.out b/tests/purs/failing/DuplicateDeclarationsInLet3.out
new file mode 100644
index 0000000000..33d911057f
--- /dev/null
+++ b/tests/purs/failing/DuplicateDeclarationsInLet3.out
@@ -0,0 +1,22 @@
+Error 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/failing/DuplicateDeclarationsInLet3.purs:9:3 - 9:11 (line 9, column 3 - line 9, column 11)
+
+ The name [33ma[0m was defined multiple times in a binding group
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/OverlappingNamesInLet.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/failing/DuplicateDeclarationsInLet3.purs:16:3 - 16:24 (line 16, column 3 - line 16, column 24)
+
+ The name [33minterrupted[0m was defined multiple times in a binding group
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/OverlappingNamesInLet.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DuplicateDeclarationsInLet3.purs b/tests/purs/failing/DuplicateDeclarationsInLet3.purs
new file mode 100644
index 0000000000..9ca900ea58
--- /dev/null
+++ b/tests/purs/failing/DuplicateDeclarationsInLet3.purs
@@ -0,0 +1,16 @@
+-- @shouldFailWith OverlappingNamesInLet
+-- @shouldFailWith OverlappingNamesInLet
+module Main where
+
+-- Should see separate errors for `a` and `interrupted`
+foo = interrupter + a
+ where
+ a = 0
+ a :: Int
+ a = 0
+
+ interrupted true = 1
+
+ interrupter = 2
+
+ interrupted false = 3
diff --git a/tests/purs/failing/DuplicateInstance.out b/tests/purs/failing/DuplicateInstance.out
new file mode 100644
index 0000000000..8125e48b55
--- /dev/null
+++ b/tests/purs/failing/DuplicateInstance.out
@@ -0,0 +1,17 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DuplicateInstance.purs:6:1 - 6:16 (line 6, column 1 - line 6, column 16)
+
+ Instance [33mi[0m has been defined multiple times:
+
+ tests/purs/failing/DuplicateInstance.purs:6:1 - 6:16 (line 6, column 1 - line 6, column 16)
+
+
+in type class instance
+[33m [0m
+[33m Main.Y [0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/DuplicateInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DuplicateModule.out b/tests/purs/failing/DuplicateModule.out
new file mode 100644
index 0000000000..7e66ff75bd
--- /dev/null
+++ b/tests/purs/failing/DuplicateModule.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/DuplicateModule.purs:2:1 - 2:16 (line 2, column 1 - line 2, column 16)
+
+ Module [33mM1[0m has been defined multiple times
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DuplicateModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DuplicateProperties.out b/tests/purs/failing/DuplicateProperties.out
new file mode 100644
index 0000000000..fb826e01aa
--- /dev/null
+++ b/tests/purs/failing/DuplicateProperties.out
@@ -0,0 +1,36 @@
+Error found:
+in module [33mDuplicateProperties[0m
+at tests/purs/failing/DuplicateProperties.purs:12:18 - 12:32 (line 12, column 18 - line 12, column 32)
+
+ Could not match type
+ [33m [0m
+ [33m ( y :: Unit[0m
+ [33m ... [0m
+ [33m ) [0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m ( x :: Unit[0m
+ [33m ... [0m
+ [33m | t0 [0m
+ [33m ) [0m
+ [33m [0m
+
+while trying to match type [33mTest t1[0m
+ with type [33mTest [0m
+ [33m ( x :: Unit[0m
+ [33m | t0 [0m
+ [33m ) [0m
+while checking that expression [33msubtractX hasX[0m
+ has type [33mTest [0m
+ [33m ( x :: Unit[0m
+ [33m | t0 [0m
+ [33m ) [0m
+in value declaration [33mbaz[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DuplicateProperties.purs b/tests/purs/failing/DuplicateProperties.purs
index 6349b30356..32c1552a7d 100644
--- a/tests/purs/failing/DuplicateProperties.purs
+++ b/tests/purs/failing/DuplicateProperties.purs
@@ -3,7 +3,7 @@ module DuplicateProperties where
import Prelude
-foreign import data Test :: # Type -> Type
+foreign import data Test :: Row Type -> Type
foreign import subtractX :: forall r. Test (x :: Unit | r) -> Test r
diff --git a/tests/purs/failing/DuplicateRoleDeclaration.out b/tests/purs/failing/DuplicateRoleDeclaration.out
new file mode 100644
index 0000000000..3c4a29664f
--- /dev/null
+++ b/tests/purs/failing/DuplicateRoleDeclaration.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DuplicateRoleDeclaration.purs:6:1 - 6:20 (line 6, column 1 - line 6, column 20)
+
+ Duplicate role declaration for [33mA[0m.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DuplicateRoleDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DuplicateRoleDeclaration.purs b/tests/purs/failing/DuplicateRoleDeclaration.purs
new file mode 100644
index 0000000000..590b24a4fa
--- /dev/null
+++ b/tests/purs/failing/DuplicateRoleDeclaration.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith DuplicateRoleDeclaration
+module Main where
+
+data A a = A
+type role A nominal
+type role A phantom
diff --git a/tests/purs/failing/DuplicateTypeClass.out b/tests/purs/failing/DuplicateTypeClass.out
new file mode 100644
index 0000000000..ddc9e92c1a
--- /dev/null
+++ b/tests/purs/failing/DuplicateTypeClass.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DuplicateTypeClass.purs:4:1 - 4:8 (line 4, column 1 - line 4, column 8)
+
+ Type class [33mC[0m has been defined multiple times:
+
+ tests/purs/failing/DuplicateTypeClass.purs:4:1 - 4:8 (line 4, column 1 - line 4, column 8)
+
+
+in type class declaration for [33mC[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/DuplicateTypeClass.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/DuplicateTypeVars.out b/tests/purs/failing/DuplicateTypeVars.out
new file mode 100644
index 0000000000..7fe945070b
--- /dev/null
+++ b/tests/purs/failing/DuplicateTypeVars.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/DuplicateTypeVars.purs:6:1 - 6:17 (line 6, column 1 - line 6, column 17)
+
+ Type argument [33ma[0m appears more than once.
+
+in type synonym [33mFoo[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/DuplicateTypeArgument.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/EmptyCase.out b/tests/purs/failing/EmptyCase.out
new file mode 100644
index 0000000000..8cd02d79ef
--- /dev/null
+++ b/tests/purs/failing/EmptyCase.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/EmptyCase.purs:4:25 - 4:26 (line 4, column 25 - line 4, column 26)
+
+ Unable to parse module:
+ Unexpected token '\'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/EmptyClass.out b/tests/purs/failing/EmptyClass.out
new file mode 100644
index 0000000000..6c85282245
--- /dev/null
+++ b/tests/purs/failing/EmptyClass.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/EmptyClass.purs:6:1 - 6:1 (line 6, column 1 - line 6, column 1)
+
+ Unable to parse module:
+ Unexpected or mismatched indentation
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/EmptyDo.out b/tests/purs/failing/EmptyDo.out
new file mode 100644
index 0000000000..fbedcb0d6f
--- /dev/null
+++ b/tests/purs/failing/EmptyDo.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/EmptyDo.purs:7:1 - 7:1 (line 7, column 1 - line 7, column 1)
+
+ Unable to parse module:
+ Unexpected or mismatched indentation
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExpectedWildcard.out b/tests/purs/failing/ExpectedWildcard.out
new file mode 100644
index 0000000000..d450d19332
--- /dev/null
+++ b/tests/purs/failing/ExpectedWildcard.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/ExpectedWildcard.purs:8:1 - 8:51 (line 8, column 1 - line 8, column 51)
+
+ Expected a type wildcard (_) when deriving an instance for [33mTest[0m.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExpectedWildcard.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictClass.out b/tests/purs/failing/ExportConflictClass.out
new file mode 100644
index 0000000000..42d80e6017
--- /dev/null
+++ b/tests/purs/failing/ExportConflictClass.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictClass.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for type class [33mB.X[0m conflicts with type class [33mA.X[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictClass/B.out b/tests/purs/failing/ExportConflictClass/B.out
new file mode 100644
index 0000000000..42d80e6017
--- /dev/null
+++ b/tests/purs/failing/ExportConflictClass/B.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictClass.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for type class [33mB.X[0m conflicts with type class [33mA.X[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictClassAndType.out b/tests/purs/failing/ExportConflictClassAndType.out
new file mode 100644
index 0000000000..ed620fa4c7
--- /dev/null
+++ b/tests/purs/failing/ExportConflictClassAndType.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictClassAndType.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for type [33mB.X[0m conflicts with type class [33mA.X[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictClassAndType.purs b/tests/purs/failing/ExportConflictClassAndType.purs
new file mode 100644
index 0000000000..fa6e746ade
--- /dev/null
+++ b/tests/purs/failing/ExportConflictClassAndType.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith ExportConflict
+module C (module A, module B) where
+
+import A as A
+import B as B
diff --git a/tests/purs/failing/ExportConflictClassAndType/A.purs b/tests/purs/failing/ExportConflictClassAndType/A.purs
new file mode 100644
index 0000000000..48354f7b1b
--- /dev/null
+++ b/tests/purs/failing/ExportConflictClassAndType/A.purs
@@ -0,0 +1,3 @@
+module A where
+
+class X
diff --git a/tests/purs/failing/ExportConflictClassAndType/B.out b/tests/purs/failing/ExportConflictClassAndType/B.out
new file mode 100644
index 0000000000..ed620fa4c7
--- /dev/null
+++ b/tests/purs/failing/ExportConflictClassAndType/B.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictClassAndType.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for type [33mB.X[0m conflicts with type class [33mA.X[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictClassAndType/B.purs b/tests/purs/failing/ExportConflictClassAndType/B.purs
new file mode 100644
index 0000000000..3a594f220c
--- /dev/null
+++ b/tests/purs/failing/ExportConflictClassAndType/B.purs
@@ -0,0 +1,3 @@
+module B where
+
+data X
diff --git a/tests/purs/failing/ExportConflictCtor.out b/tests/purs/failing/ExportConflictCtor.out
new file mode 100644
index 0000000000..05fbfaf7b2
--- /dev/null
+++ b/tests/purs/failing/ExportConflictCtor.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictCtor.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for data constructor [33mB.X[0m conflicts with data constructor [33mA.X[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictType.out b/tests/purs/failing/ExportConflictType.out
new file mode 100644
index 0000000000..742d37d744
--- /dev/null
+++ b/tests/purs/failing/ExportConflictType.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictType.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for type [33mB.T[0m conflicts with type [33mA.T[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictType/B.out b/tests/purs/failing/ExportConflictType/B.out
new file mode 100644
index 0000000000..742d37d744
--- /dev/null
+++ b/tests/purs/failing/ExportConflictType/B.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictType.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for type [33mB.T[0m conflicts with type [33mA.T[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictTypeOp.out b/tests/purs/failing/ExportConflictTypeOp.out
new file mode 100644
index 0000000000..109b5fa317
--- /dev/null
+++ b/tests/purs/failing/ExportConflictTypeOp.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictTypeOp.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for type operator [33mB.(??)[0m conflicts with type operator [33mA.(??)[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictValue.out b/tests/purs/failing/ExportConflictValue.out
new file mode 100644
index 0000000000..1a4c14908b
--- /dev/null
+++ b/tests/purs/failing/ExportConflictValue.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictValue.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for value [33mB.x[0m conflicts with value [33mA.x[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictValueOp.out b/tests/purs/failing/ExportConflictValueOp.out
new file mode 100644
index 0000000000..2a75e447a5
--- /dev/null
+++ b/tests/purs/failing/ExportConflictValueOp.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictValueOp.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for operator [33mB.(!!)[0m conflicts with operator [33mA.(!!)[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportConflictValueOp/B.out b/tests/purs/failing/ExportConflictValueOp/B.out
new file mode 100644
index 0000000000..2a75e447a5
--- /dev/null
+++ b/tests/purs/failing/ExportConflictValueOp/B.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mC[0m
+at tests/purs/failing/ExportConflictValueOp.purs:2:21 - 2:29 (line 2, column 21 - line 2, column 29)
+
+ Export for operator [33mB.(!!)[0m conflicts with operator [33mA.(!!)[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportExplicit.out b/tests/purs/failing/ExportExplicit.out
new file mode 100644
index 0000000000..13bc578507
--- /dev/null
+++ b/tests/purs/failing/ExportExplicit.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mM1[0m
+at tests/purs/failing/ExportExplicit.purs:3:18 - 3:19 (line 3, column 18 - line 3, column 19)
+
+ Cannot export unknown value [33mz[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownExport.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportExplicit1.out b/tests/purs/failing/ExportExplicit1.out
new file mode 100644
index 0000000000..962a855db1
--- /dev/null
+++ b/tests/purs/failing/ExportExplicit1.out
@@ -0,0 +1,22 @@
+Error 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/failing/ExportExplicit1.purs:9:9 - 9:10 (line 9, column 9 - line 9, column 10)
+
+ Unknown data constructor [33mX[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/failing/ExportExplicit1.purs:10:9 - 10:10 (line 10, column 9 - line 10, column 10)
+
+ Unknown data constructor [33mY[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportExplicit1.purs b/tests/purs/failing/ExportExplicit1.purs
index 574a12a7c6..def6510f04 100644
--- a/tests/purs/failing/ExportExplicit1.purs
+++ b/tests/purs/failing/ExportExplicit1.purs
@@ -1,12 +1,12 @@
-- @shouldFailWith UnknownName
+-- @shouldFailWith UnknownName
+-- should fail as X and Y constructors are not exported from M1
module Main where
import M1
import Effect.Console (log)
testX = X
-
--- should fail as Y constructor is not exported from M1
testY = Y
main = log "Done"
diff --git a/tests/purs/failing/ExportExplicit1/M1.purs b/tests/purs/failing/ExportExplicit1/M1.purs
index f20006fb4b..fbf0956463 100644
--- a/tests/purs/failing/ExportExplicit1/M1.purs
+++ b/tests/purs/failing/ExportExplicit1/M1.purs
@@ -1,3 +1,3 @@
-module M1 (X(X)) where
+module M1 (X) where
data X = X | Y
diff --git a/tests/purs/failing/ExportExplicit2.out b/tests/purs/failing/ExportExplicit2.out
new file mode 100644
index 0000000000..c251493c37
--- /dev/null
+++ b/tests/purs/failing/ExportExplicit2.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mM1[0m
+at tests/purs/failing/ExportExplicit2.purs:3:12 - 3:16 (line 3, column 12 - line 3, column 16)
+
+ Cannot export data constructor [33mY[0m for type [33mX[0m, as it has not been declared.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownExportDataConstructor.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExportExplicit3.out b/tests/purs/failing/ExportExplicit3.out
new file mode 100644
index 0000000000..51b722c39b
--- /dev/null
+++ b/tests/purs/failing/ExportExplicit3.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ExportExplicit3.purs:8:9 - 8:12 (line 8, column 9 - line 8, column 12)
+
+ Unknown data constructor [33mM.Z[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExtraRecordField.out b/tests/purs/failing/ExtraRecordField.out
new file mode 100644
index 0000000000..a4b1ed0d1a
--- /dev/null
+++ b/tests/purs/failing/ExtraRecordField.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mExtraRecordField[0m
+at tests/purs/failing/ExtraRecordField.purs:9:13 - 9:54 (line 9, column 13 - line 9, column 54)
+
+ Type of expression contains additional label [33mage[0m.
+
+while checking that expression [33m{ first: "Jane"[0m
+ [33m, last: "Smith"[0m
+ [33m, age: 29 [0m
+ [33m} [0m
+ has type [33m{ first :: String[0m
+ [33m, last :: String [0m
+ [33m} [0m
+while applying a function [33mfull[0m
+ of type [33m{ first :: String[0m
+ [33m, last :: String [0m
+ [33m} [0m
+ [33m-> String [0m
+ to argument [33m{ first: "Jane"[0m
+ [33m, last: "Smith"[0m
+ [33m, age: 29 [0m
+ [33m} [0m
+in value declaration [33moops[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/AdditionalProperty.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ExtraneousClassMember.out b/tests/purs/failing/ExtraneousClassMember.out
new file mode 100644
index 0000000000..75c34372d9
--- /dev/null
+++ b/tests/purs/failing/ExtraneousClassMember.out
@@ -0,0 +1,13 @@
+Error found:
+at tests/purs/failing/ExtraneousClassMember.purs:11:3 - 11:10 (line 11, column 3 - line 11, column 10)
+
+ [33mb[0m is not a member of type class [33mMain.A[0m
+
+in type class instance
+[33m [0m
+[33m Main.A String[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ExtraneousClassMember.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FFIDefaultCJSExport.js b/tests/purs/failing/FFIDefaultCJSExport.js
new file mode 100644
index 0000000000..873a59a12b
--- /dev/null
+++ b/tests/purs/failing/FFIDefaultCJSExport.js
@@ -0,0 +1 @@
+exports.default = "Done";
diff --git a/tests/purs/failing/FFIDefaultCJSExport.out b/tests/purs/failing/FFIDefaultCJSExport.out
new file mode 100644
index 0000000000..90ce31fd7d
--- /dev/null
+++ b/tests/purs/failing/FFIDefaultCJSExport.out
@@ -0,0 +1,13 @@
+Error found:
+at tests/purs/failing/FFIDefaultCJSExport.purs:2:1 - 8:19 (line 2, column 1 - line 8, column 19)
+
+ A CommonJS foreign module implementation was provided for module [33mMain[0m:
+
+ tests/purs/failing/FFIDefaultCJSExport.js
+
+ CommonJS foreign modules are no longer supported. Use native JavaScript/ECMAScript module syntax instead.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DeprecatedFFICommonJSModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FFIDefaultCJSExport.purs b/tests/purs/failing/FFIDefaultCJSExport.purs
new file mode 100644
index 0000000000..93de635f63
--- /dev/null
+++ b/tests/purs/failing/FFIDefaultCJSExport.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith DeprecatedFFICommonJSModule
+module Main where
+
+import Effect.Console (log)
+
+foreign import default :: String
+
+main = log default
diff --git a/tests/purs/failing/Foldable.out b/tests/purs/failing/Foldable.out
new file mode 100644
index 0000000000..5ddfefcc76
--- /dev/null
+++ b/tests/purs/failing/Foldable.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/Foldable.purs:12:1 - 15:36 (line 12, column 1 - line 15, column 36)
+
+ The value of [33mfoldableL[0m is undefined here, so this reference is not allowed.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FoldableInstance1.out b/tests/purs/failing/FoldableInstance1.out
new file mode 100644
index 0000000000..0066c5f5bc
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance1.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/FoldableInstance1.purs:9:26 - 9:29 (line 9, column 26 - line 9, column 29)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type -> Type[0m
+ [33m [0m
+
+while checking that type [33mFoo[0m
+ has kind [33mType -> Type[0m
+while inferring the kind of [33mFoldable Foo[0m
+in type class instance
+[33m [0m
+[33m Data.Foldable.Foldable Foo[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FoldableInstance1.purs b/tests/purs/failing/FoldableInstance1.purs
new file mode 100644
index 0000000000..d8c230c714
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance1.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+import Prelude
+import Data.Foldable (class Foldable)
+
+data Foo = Bar
+
+derive instance Foldable Foo
diff --git a/tests/purs/failing/FoldableInstance10.out b/tests/purs/failing/FoldableInstance10.out
new file mode 100644
index 0000000000..089056df60
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance10.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mFoldableInstance10[0m
+at tests/purs/failing/FoldableInstance10.purs:11:1 - 11:30 (line 11, column 1 - line 11, column 30)
+
+ One or more type variables are in positions that prevent [33mFoldable[0m from being derived.
+ To derive this class, make sure that these variables are only used as the final arguments to type constructors, and that those type constructors themselves have instances of [33mData.Foldable.Foldable[0m or [33mData.Bifoldable.Bifoldable[0m.
+
+ tests/purs/failing/FoldableInstance10.purs:
+ [90m 9[0m [33m[0m
+ [90m 10[0m [33mdata Test a = Test (Variant (left :: [7ma[27m, right :: Array [7ma[27m))[0m
+ [90m 11[0m [33mderive instance Foldable Test[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDeriveInvalidConstructorArg.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FoldableInstance10.purs b/tests/purs/failing/FoldableInstance10.purs
new file mode 100644
index 0000000000..c191a4d46b
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance10.purs
@@ -0,0 +1,11 @@
+-- @shouldFailWith CannotDeriveInvalidConstructorArg
+module FoldableInstance10 where
+
+import Prelude
+import Data.Tuple (Tuple)
+import Data.Foldable (class Foldable)
+
+foreign import data Variant :: Row Type -> Type
+
+data Test a = Test (Variant (left :: a, right :: Array a))
+derive instance Foldable Test
diff --git a/tests/purs/failing/FoldableInstance2.out b/tests/purs/failing/FoldableInstance2.out
new file mode 100644
index 0000000000..c5ac122c50
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance2.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/FoldableInstance2.purs:10:26 - 10:29 (line 10, column 26 - line 10, column 29)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type -> Type[0m
+ [33m [0m
+
+while checking that type [33mFoo[0m
+ has kind [33mType -> Type[0m
+while inferring the kind of [33mFoldable Foo[0m
+in type class instance
+[33m [0m
+[33m Data.Foldable.Foldable Foo[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FoldableInstance2.purs b/tests/purs/failing/FoldableInstance2.purs
new file mode 100644
index 0000000000..477033c0b4
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance2.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+import Prelude
+import Data.Foldable (class Foldable)
+
+data Foo :: (Type -> Type) -> Type
+data Foo a = Bar
+
+derive instance Foldable Foo
diff --git a/tests/purs/failing/FoldableInstance3.out b/tests/purs/failing/FoldableInstance3.out
new file mode 100644
index 0000000000..e64875d220
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance3.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/FoldableInstance3.purs:9:26 - 9:29 (line 9, column 26 - line 9, column 29)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type -> Type[0m
+ [33m [0m
+
+while checking that type [33mFoo[0m
+ has kind [33mType -> Type[0m
+while inferring the kind of [33mFoldable Foo[0m
+in type class instance
+[33m [0m
+[33m Data.Foldable.Foldable Foo[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FoldableInstance3.purs b/tests/purs/failing/FoldableInstance3.purs
new file mode 100644
index 0000000000..7ce3298aee
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance3.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+import Prelude
+import Data.Foldable (class Foldable)
+
+data Foo f = Bar (f Int)
+
+derive instance Foldable Foo
diff --git a/tests/purs/failing/FoldableInstance4.out b/tests/purs/failing/FoldableInstance4.out
new file mode 100644
index 0000000000..693fa4b766
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance4.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mFoldableInstance4[0m
+at tests/purs/failing/FoldableInstance4.purs:8:1 - 8:27 (line 8, column 1 - line 8, column 27)
+
+ One or more type variables are in positions that prevent [33mFoldable[0m from being derived.
+ To derive this class, make sure that these variables are only used as the final arguments to type constructors, and that those type constructors themselves have instances of [33mData.Foldable.Foldable[0m or [33mData.Bifoldable.Bifoldable[0m.
+
+ tests/purs/failing/FoldableInstance4.purs:
+ [90m 6[0m [33m[0m
+ [90m 7[0m [33mdata T a = T (forall t. Show t => t -> [7ma[27m)[0m
+ [90m 8[0m [33mderive instance Foldable T[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDeriveInvalidConstructorArg.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FoldableInstance4.purs b/tests/purs/failing/FoldableInstance4.purs
new file mode 100644
index 0000000000..ad01c8be93
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance4.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith CannotDeriveInvalidConstructorArg
+module FoldableInstance4 where
+
+import Prelude
+import Data.Foldable (class Foldable)
+
+data T a = T (forall t. Show t => t -> a)
+derive instance Foldable T
diff --git a/tests/purs/failing/FoldableInstance6.out b/tests/purs/failing/FoldableInstance6.out
new file mode 100644
index 0000000000..31028db8eb
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance6.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mFoldableInstance6[0m
+at tests/purs/failing/FoldableInstance6.purs:8:1 - 8:30 (line 8, column 1 - line 8, column 30)
+
+ One or more type variables are in positions that prevent [33mFoldable[0m from being derived.
+ To derive this class, make sure that these variables are only used as the final arguments to type constructors, and that those type constructors themselves have instances of [33mData.Foldable.Foldable[0m or [33mData.Bifoldable.Bifoldable[0m.
+
+ tests/purs/failing/FoldableInstance6.purs:
+ [90m 6[0m [33m[0m
+ [90m 7[0m [33mdata Test a = Test ([7ma[27m -> Int)[0m
+ [90m 8[0m [33mderive instance Foldable Test[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDeriveInvalidConstructorArg.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FoldableInstance6.purs b/tests/purs/failing/FoldableInstance6.purs
new file mode 100644
index 0000000000..cba388ae23
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance6.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith CannotDeriveInvalidConstructorArg
+module FoldableInstance6 where
+
+import Prelude
+import Data.Foldable (class Foldable)
+
+data Test a = Test (a -> Int)
+derive instance Foldable Test
diff --git a/tests/purs/failing/FoldableInstance8.out b/tests/purs/failing/FoldableInstance8.out
new file mode 100644
index 0000000000..9199ad2211
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance8.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mFoldableInstance6[0m
+at tests/purs/failing/FoldableInstance8.purs:8:1 - 8:34 (line 8, column 1 - line 8, column 34)
+
+ One or more type variables are in positions that prevent [33mFoldable[0m from being derived.
+ To derive this class, make sure that these variables are only used as the final arguments to type constructors, and that those type constructors themselves have instances of [33mData.Foldable.Foldable[0m or [33mData.Bifoldable.Bifoldable[0m.
+
+ tests/purs/failing/FoldableInstance8.purs:
+ [90m 6[0m [33m[0m
+ [90m 7[0m [33mdata Test f a = Test (f [7ma[27m [7ma[27m)[0m
+ [90m 8[0m [33mderive instance Foldable (Test f)[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDeriveInvalidConstructorArg.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FoldableInstance8.purs b/tests/purs/failing/FoldableInstance8.purs
new file mode 100644
index 0000000000..1ae6cebe6f
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance8.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith CannotDeriveInvalidConstructorArg
+module FoldableInstance6 where
+
+import Prelude
+import Data.Foldable (class Foldable)
+
+data Test f a = Test (f a a)
+derive instance Foldable (Test f)
diff --git a/tests/purs/failing/FoldableInstance9.out b/tests/purs/failing/FoldableInstance9.out
new file mode 100644
index 0000000000..f48b5fc556
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance9.out
@@ -0,0 +1,51 @@
+Error found:
+in module [33mFoldableInstance9[0m
+at tests/purs/failing/FoldableInstance9.purs:53:1 - 53:38 (line 53, column 1 - line 53, column 38)
+
+ One or more type variables are in positions that prevent [33mFoldable[0m from being derived.
+ To derive this class, make sure that these variables are only used as the final arguments to type constructors, and that those type constructors themselves have instances of [33mData.Foldable.Foldable[0m or [33mData.Bifoldable.Bifoldable[0m.
+
+ tests/purs/failing/FoldableInstance9.purs:
+ [90m 15[0m [33mdata Test f g h a[0m
+ [90m 16[0m [33m = Test1 (f [7ma[27m [7ma[27m [7ma[27m) (f Int [7ma[27m [7ma[27m) (f [7ma[27m [7ma[27m Int) (f Int [7ma[27m Int) (f Int Int Int)[0m
+ [90m 17[0m [33m | Test2 { all :: f [7ma[27m [7ma[27m [7ma[27m[0m
+ [90m 18[0m [33m , rights :: f Int [7ma[27m [7ma[27m[0m
+ [90m 19[0m [33m , lefts :: f [7ma[27m [7ma[27m Int[0m
+ [90m 20[0m [33m , middle :: f Int [7ma[27m Int[0m
+ [90m 21[0m [33m , none :: f Int Int Int[0m
+ [90m 22[0m [33m }[0m
+ [90m 23[0m [33m | Test3 (g[0m
+ [90m 24[0m [33m { all :: f [7ma[27m [7ma[27m [7ma[27m[0m
+ [90m 25[0m [33m , rights :: f Int [7ma[27m [7ma[27m[0m
+ [90m 26[0m [33m , lefts :: f [7ma[27m [7ma[27m Int[0m
+ [90m 27[0m [33m , middle :: f Int [7ma[27m Int[0m
+ [90m 28[0m [33m , none :: f Int Int Int[0m
+ [90m 29[0m [33m }[0m
+ [90m 30[0m [33m [7ma[27m)[0m
+ [90m 31[0m [33m | Test4 (h[0m
+ [90m 32[0m [33m { nested1 ::[0m
+ [90m 33[0m [33m { all :: f [7ma[27m [7ma[27m [7ma[27m[0m
+ [90m 34[0m [33m , rights :: f Int [7ma[27m [7ma[27m[0m
+ [90m 35[0m [33m , lefts :: f [7ma[27m [7ma[27m Int[0m
+ [90m 36[0m [33m , middle :: f Int [7ma[27m Int[0m
+ [90m 37[0m [33m , none :: f Int Int Int[0m
+ [90m ...[0m
+ [90m 40[0m [33m g[0m
+ [90m 41[0m [33m { all :: f [7ma[27m [7ma[27m [7ma[27m[0m
+ [90m 42[0m [33m , rights :: f Int [7ma[27m [7ma[27m[0m
+ [90m 43[0m [33m , lefts :: f [7ma[27m [7ma[27m Int[0m
+ [90m 44[0m [33m , middle :: f Int [7ma[27m Int[0m
+ [90m 45[0m [33m , none :: f Int Int Int[0m
+ [90m 46[0m [33m }[0m
+ [90m 47[0m [33m [7ma[27m[0m
+ [90m 48[0m [33m }[0m
+ [90m 49[0m [33m [7ma[27m)[0m
+ [90m 50[0m [33m | Test5 (Rec f [7ma[27m)[0m
+ [90m 51[0m [33m | Test6 (g (Rec f [7ma[27m) [7ma[27m)[0m
+ [90m 52[0m [33m | Test7 (h { nested1 :: Rec f [7ma[27m, nested2 :: g (Rec f [7ma[27m) [7ma[27m } [7ma[27m)[0m
+ [90m 53[0m [33mderive instance Foldable (Test f g h)[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDeriveInvalidConstructorArg.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FoldableInstance9.purs b/tests/purs/failing/FoldableInstance9.purs
new file mode 100644
index 0000000000..164c6858b3
--- /dev/null
+++ b/tests/purs/failing/FoldableInstance9.purs
@@ -0,0 +1,53 @@
+-- @shouldFailWith CannotDeriveInvalidConstructorArg
+module FoldableInstance9 where
+
+import Prelude
+import Data.Tuple (Tuple)
+import Data.Foldable (class Foldable)
+
+type Rec f a =
+ { all :: f a a a
+ , rights :: f Int a a
+ , lefts :: f a a Int
+ , middle :: f Int a Int
+ , none :: f Int Int Int
+ }
+data Test f g h a
+ = Test1 (f a a a) (f Int a a) (f a a Int) (f Int a Int) (f Int Int Int)
+ | Test2 { all :: f a a a
+ , rights :: f Int a a
+ , lefts :: f a a Int
+ , middle :: f Int a Int
+ , none :: f Int Int Int
+ }
+ | Test3 (g
+ { all :: f a a a
+ , rights :: f Int a a
+ , lefts :: f a a Int
+ , middle :: f Int a Int
+ , none :: f Int Int Int
+ }
+ a)
+ | Test4 (h
+ { nested1 ::
+ { all :: f a a a
+ , rights :: f Int a a
+ , lefts :: f a a Int
+ , middle :: f Int a Int
+ , none :: f Int Int Int
+ }
+ , nested2 ::
+ g
+ { all :: f a a a
+ , rights :: f Int a a
+ , lefts :: f a a Int
+ , middle :: f Int a Int
+ , none :: f Int Int Int
+ }
+ a
+ }
+ a)
+ | Test5 (Rec f a)
+ | Test6 (g (Rec f a) a)
+ | Test7 (h { nested1 :: Rec f a, nested2 :: g (Rec f a) a } a)
+derive instance Foldable (Test f g h)
diff --git a/tests/purs/failing/FunctorInstance1.out b/tests/purs/failing/FunctorInstance1.out
new file mode 100644
index 0000000000..0f2e05c6d8
--- /dev/null
+++ b/tests/purs/failing/FunctorInstance1.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mFunctorInstance1[0m
+at tests/purs/failing/FunctorInstance1.purs:8:1 - 8:29 (line 8, column 1 - line 8, column 29)
+
+ One or more type variables are in positions that prevent [33mFunctor[0m from being derived.
+ To derive this class, make sure that these variables are only used as the final arguments to type constructors, that their variance matches the variance of [33mFunctor[0m, and that those type constructors themselves have instances of [33mData.Functor.Functor[0m, [33mData.Bifunctor.Bifunctor[0m, [33mData.Functor.Contravariant.Contravariant[0m, or [33mData.Profunctor.Profunctor[0m.
+
+ tests/purs/failing/FunctorInstance1.purs:
+ [90m 6[0m [33m[0m
+ [90m 7[0m [33mdata Test a = Test (Predicate [7ma[27m)[0m
+ [90m 8[0m [33mderive instance Functor Test[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDeriveInvalidConstructorArg.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/FunctorInstance1.purs b/tests/purs/failing/FunctorInstance1.purs
new file mode 100644
index 0000000000..2883d98528
--- /dev/null
+++ b/tests/purs/failing/FunctorInstance1.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith CannotDeriveInvalidConstructorArg
+module FunctorInstance1 where
+
+import Prelude
+import Data.Predicate (Predicate)
+
+data Test a = Test (Predicate a)
+derive instance Functor Test
diff --git a/tests/purs/failing/Generalization1.out b/tests/purs/failing/Generalization1.out
new file mode 100644
index 0000000000..1f41f27288
--- /dev/null
+++ b/tests/purs/failing/Generalization1.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/Generalization1.purs:6:1 - 6:14 (line 6, column 1 - line 6, column 14)
+
+ Unable to generalize the type of the recursive function [33mfoo[0m.
+ The inferred type of [33mfoo[0m was:
+ [33m [0m
+ [33m forall t4. Semigroup t4 => Int -> t4 -> t4 -> t4[0m
+ [33m [0m
+ Try adding a type signature.
+
+in binding group foo, bar
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotGeneralizeRecursiveFunction.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/Generalization2.out b/tests/purs/failing/Generalization2.out
new file mode 100644
index 0000000000..65cb6c97c7
--- /dev/null
+++ b/tests/purs/failing/Generalization2.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/Generalization2.purs:6:1 - 7:45 (line 6, column 1 - line 7, column 45)
+
+ Unable to generalize the type of the recursive function [33mtest[0m.
+ The inferred type of [33mtest[0m was:
+ [33m [0m
+ [33m forall a7. Semigroup a7 => Int -> a7 -> a7[0m
+ [33m [0m
+ Try adding a type signature.
+
+in binding group test
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotGeneralizeRecursiveFunction.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ImportExplicit.out b/tests/purs/failing/ImportExplicit.out
new file mode 100644
index 0000000000..d130697ebf
--- /dev/null
+++ b/tests/purs/failing/ImportExplicit.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ImportExplicit.purs:4:12 - 4:17 (line 4, column 12 - line 4, column 17)
+
+ Cannot import type [33mX[0m from module [33mM1[0m
+ It either does not exist or the module does not export it.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownImport.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ImportExplicit/M1.out b/tests/purs/failing/ImportExplicit/M1.out
new file mode 100644
index 0000000000..d130697ebf
--- /dev/null
+++ b/tests/purs/failing/ImportExplicit/M1.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ImportExplicit.purs:4:12 - 4:17 (line 4, column 12 - line 4, column 17)
+
+ Cannot import type [33mX[0m from module [33mM1[0m
+ It either does not exist or the module does not export it.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownImport.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ImportExplicit2.out b/tests/purs/failing/ImportExplicit2.out
new file mode 100644
index 0000000000..2647d0a0c9
--- /dev/null
+++ b/tests/purs/failing/ImportExplicit2.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ImportExplicit2.purs:4:12 - 4:19 (line 4, column 12 - line 4, column 19)
+
+ Module M1 does not export data constructor [33mZ[0m for type [33mX[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownImportDataConstructor.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ImportHidingModule.out b/tests/purs/failing/ImportHidingModule.out
new file mode 100644
index 0000000000..bc493691da
--- /dev/null
+++ b/tests/purs/failing/ImportHidingModule.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/ImportHidingModule.purs:4:18 - 4:24 (line 4, column 18 - line 4, column 24)
+
+ Unable to parse module:
+ Unexpected token 'module'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ImportModule.out b/tests/purs/failing/ImportModule.out
new file mode 100644
index 0000000000..76e22a6dc0
--- /dev/null
+++ b/tests/purs/failing/ImportModule.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ImportModule.purs:4:1 - 4:10 (line 4, column 1 - line 4, column 10)
+
+ Module [33mM1[0m was not found.
+ Make sure the source file exists, and that it has been provided as an input to the compiler.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InfiniteKind.out b/tests/purs/failing/InfiniteKind.out
new file mode 100644
index 0000000000..3bb4745c23
--- /dev/null
+++ b/tests/purs/failing/InfiniteKind.out
@@ -0,0 +1,19 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/InfiniteKind.purs:5:17 - 5:18 (line 5, column 17 - line 5, column 18)
+
+ An infinite kind was inferred for a type:
+ [33m [0m
+ [33m t5 -> t6[0m
+ [33m [0m
+
+while checking that type [33ma[0m
+ has kind [33mt0[0m
+while inferring the kind of [33ma a[0m
+in type constructor [33mF[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/InfiniteKind.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InfiniteKind2.out b/tests/purs/failing/InfiniteKind2.out
new file mode 100644
index 0000000000..c06581ce76
--- /dev/null
+++ b/tests/purs/failing/InfiniteKind2.out
@@ -0,0 +1,19 @@
+Error found:
+in module [33mInfiniteKind2[0m
+at tests/purs/failing/InfiniteKind2.purs:5:23 - 5:27 (line 5, column 23 - line 5, column 27)
+
+ An infinite kind was inferred for a type:
+ [33m [0m
+ [33m (t5 -> t6) -> Type[0m
+ [33m [0m
+
+while checking that type [33mTree[0m
+ has kind [33mt0[0m
+while inferring the kind of [33mm Tree[0m
+in data binding group Tree
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/InfiniteKind.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InfiniteKind2.purs b/tests/purs/failing/InfiniteKind2.purs
index 63c910400a..170cd8576b 100644
--- a/tests/purs/failing/InfiniteKind2.purs
+++ b/tests/purs/failing/InfiniteKind2.purs
@@ -2,4 +2,4 @@
module InfiniteKind2 where
-data Tree m a = Tree a (m (Tree a))
+data Tree m = Tree (m Tree)
diff --git a/tests/purs/failing/InfiniteType.out b/tests/purs/failing/InfiniteType.out
new file mode 100644
index 0000000000..996bfc9272
--- /dev/null
+++ b/tests/purs/failing/InfiniteType.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/InfiniteType.purs:5:7 - 5:10 (line 5, column 7 - line 5, column 10)
+
+ An infinite type was inferred for an expression:
+ [33m [0m
+ [33m t0 -> t1[0m
+ [33m [0m
+
+while trying to match type [33mt0[0m
+ with type [33mt0 -> t1[0m
+while inferring the type of [33m\a -> [0m
+ [33m a a [0m
+in value declaration [33mf[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/InfiniteType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InstanceChainBothUnknownAndMatch.out b/tests/purs/failing/InstanceChainBothUnknownAndMatch.out
new file mode 100644
index 0000000000..a097d1936c
--- /dev/null
+++ b/tests/purs/failing/InstanceChainBothUnknownAndMatch.out
@@ -0,0 +1,39 @@
+Error found:
+in module [33mInstanceChains.BothUnknownAndMatch[0m
+at tests/purs/failing/InstanceChainBothUnknownAndMatch.purs:15:13 - 15:53 (line 15, column 13 - line 15, column 53)
+
+ No type class instance was found for
+ [33m [0m
+ [33m InstanceChains.BothUnknownAndMatch.Same (Proxy [0m
+ [33m ( m :: Int[0m
+ [33m , u :: t3 [0m
+ [33m ) [0m
+ [33m ) [0m
+ [33m (Proxy [0m
+ [33m ( m :: Int[0m
+ [33m , u :: Int[0m
+ [33m ) [0m
+ [33m ) [0m
+ [33m t4 [0m
+ [33m [0m
+ The following instance partially overlaps the above constraint, which means the rest of its instance chain will not be considered:
+
+ [33mInstanceChains.BothUnknownAndMatch.sameY[0m
+
+
+while applying a function [33msame[0m
+ of type [33mSame @Type @Type t0 t1 t2 => t0 -> t1 -> Proxy @Symbol t2[0m
+ to argument [33mProxy[0m
+while inferring the type of [33msame Proxy[0m
+in value declaration [33mexample[0m
+
+where [33mt3[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mt4[0m is an unknown type
+ [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InstanceChainBothUnknownAndMatch.purs b/tests/purs/failing/InstanceChainBothUnknownAndMatch.purs
index 2c9cf6ef06..ff1254c7df 100644
--- a/tests/purs/failing/InstanceChainBothUnknownAndMatch.purs
+++ b/tests/purs/failing/InstanceChainBothUnknownAndMatch.purs
@@ -1,18 +1,16 @@
-- @shouldFailWith NoInstanceFound
module InstanceChains.BothUnknownAndMatch where
-import Type.Proxy (Proxy)
-import Type.Row (RProxy(..))
-import Data.Symbol (SProxy(..))
+import Type.Proxy (Proxy(..))
class Same l r (o :: Symbol) | l r -> o
instance sameY :: Same t t "Y" else instance sameN :: Same l r "N"
-same :: forall l r o. Same l r o => l -> r -> SProxy o
-same _ _ = SProxy
+same :: forall l r o. Same l r o => l -> r -> Proxy o
+same _ _ = Proxy
-- for label `u`, `t ~ Int` should be Unknown
-- for label `m`, `Int ~ Int` should be a match
-- together they should be Unknown
-example :: forall t. Proxy t -> SProxy _
-example _ = same (RProxy :: RProxy (u :: t, m :: Int))
- (RProxy :: RProxy (u :: Int, m :: Int))
+example :: forall t. Proxy t -> Proxy _
+example _ = same (Proxy :: Proxy (u :: t, m :: Int))
+ (Proxy :: Proxy (u :: Int, m :: Int))
diff --git a/tests/purs/failing/InstanceChainSkolemUnknownMatch.out b/tests/purs/failing/InstanceChainSkolemUnknownMatch.out
new file mode 100644
index 0000000000..82e1ace510
--- /dev/null
+++ b/tests/purs/failing/InstanceChainSkolemUnknownMatch.out
@@ -0,0 +1,31 @@
+Error found:
+in module [33mInstanceChainSkolemUnknownMatch[0m
+at tests/purs/failing/InstanceChainSkolemUnknownMatch.purs:13:13 - 13:36 (line 13, column 13 - line 13, column 36)
+
+ No type class instance was found for
+ [33m [0m
+ [33m InstanceChainSkolemUnknownMatch.Same (Proxy t3) [0m
+ [33m (Proxy Int)[0m
+ [33m t4 [0m
+ [33m [0m
+ The following instance partially overlaps the above constraint, which means the rest of its instance chain will not be considered:
+
+ [33mInstanceChainSkolemUnknownMatch.sameY[0m
+
+
+while applying a function [33msame[0m
+ of type [33mSame @Type @Type t0 t1 t2 => t0 -> t1 -> Proxy @Symbol t2[0m
+ to argument [33mProxy[0m
+while inferring the type of [33msame Proxy[0m
+in value declaration [33mexample[0m
+
+where [33mt3[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+ [33mt4[0m is an unknown type
+ [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InstanceChainSkolemUnknownMatch.purs b/tests/purs/failing/InstanceChainSkolemUnknownMatch.purs
index a3111f307b..e291c47993 100644
--- a/tests/purs/failing/InstanceChainSkolemUnknownMatch.purs
+++ b/tests/purs/failing/InstanceChainSkolemUnknownMatch.purs
@@ -2,14 +2,13 @@
module InstanceChainSkolemUnknownMatch where
import Type.Proxy (Proxy(..))
-import Data.Symbol (SProxy(..))
class Same l r (o :: Symbol) | l r -> o
instance sameY :: Same t t "Y" else instance sameN :: Same l r "N"
-same :: forall l r o. Same l r o => l -> r -> SProxy o
-same _ _ = SProxy
+same :: forall l r o. Same l r o => l -> r -> Proxy o
+same _ _ = Proxy
-- shouldn't discard sameY as Apart
-example :: forall t. Proxy t -> SProxy _
+example :: forall (t :: Type). Proxy t -> Proxy _
example _ = same (Proxy :: Proxy t) (Proxy :: Proxy Int)
diff --git a/tests/purs/failing/InstanceExport.out b/tests/purs/failing/InstanceExport.out
new file mode 100644
index 0000000000..a7a57f49b8
--- /dev/null
+++ b/tests/purs/failing/InstanceExport.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mInstanceExport[0m
+at tests/purs/failing/InstanceExport/InstanceExport.purs:1:1 - 11:14 (line 1, column 1 - line 11, column 14)
+
+ An export for [33mf[0m requires the following to also be exported:
+
+ [33mclass F[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InstanceNamedWithoutSeparator.out b/tests/purs/failing/InstanceNamedWithoutSeparator.out
new file mode 100644
index 0000000000..2cc0ea01ca
--- /dev/null
+++ b/tests/purs/failing/InstanceNamedWithoutSeparator.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/InstanceNamedWithoutSeparator.purs:9:23 - 9:26 (line 9, column 23 - line 9, column 26)
+
+ Unable to parse module:
+ Unexpected token 'Foo'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InstanceNamedWithoutSeparator.purs b/tests/purs/failing/InstanceNamedWithoutSeparator.purs
new file mode 100644
index 0000000000..3d9689ebe5
--- /dev/null
+++ b/tests/purs/failing/InstanceNamedWithoutSeparator.purs
@@ -0,0 +1,12 @@
+-- @shouldFailWith ErrorParsingModule
+module Main where
+
+import Effect.Console (log)
+
+class Foo a
+-- the "::" separator between the name and class name
+-- needs to be added.
+instance instanceName Foo x
+-- else instance Foo x
+
+main = log "Done"
diff --git a/tests/purs/failing/InstanceSigsBodyIncorrect.out b/tests/purs/failing/InstanceSigsBodyIncorrect.out
new file mode 100644
index 0000000000..d29e6cddbc
--- /dev/null
+++ b/tests/purs/failing/InstanceSigsBodyIncorrect.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/InstanceSigsBodyIncorrect.purs:10:9 - 10:13 (line 10, column 9 - line 10, column 13)
+
+ Could not match type
+ [33m [0m
+ [33m Boolean[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Number[0m
+ [33m [0m
+
+while checking that type [33mBoolean[0m
+ is at least as general as type [33mNumber[0m
+while checking that expression [33mtrue[0m
+ has type [33mNumber[0m
+in value declaration [33mfooNumber[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InstanceSigsDifferentTypes.out b/tests/purs/failing/InstanceSigsDifferentTypes.out
new file mode 100644
index 0000000000..f06904a946
--- /dev/null
+++ b/tests/purs/failing/InstanceSigsDifferentTypes.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/InstanceSigsDifferentTypes.purs:10:9 - 10:12 (line 10, column 9 - line 10, column 12)
+
+ Could not match type
+ [33m [0m
+ [33m Number[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+while checking that type [33mNumber[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33m0.0[0m
+ has type [33mInt[0m
+in value declaration [33mfooNumber[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InstanceSigsIncorrectType.out b/tests/purs/failing/InstanceSigsIncorrectType.out
new file mode 100644
index 0000000000..c8779b4aab
--- /dev/null
+++ b/tests/purs/failing/InstanceSigsIncorrectType.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/InstanceSigsIncorrectType.purs:8:1 - 10:13 (line 8, column 1 - line 10, column 13)
+
+ Could not match type
+ [33m [0m
+ [33m Boolean[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Number[0m
+ [33m [0m
+
+while trying to match type [33mFoo$Dict t0[0m
+ with type [33mFoo$Dict Number[0m
+while checking that expression [33mFoo$Dict { foo: true[0m
+ [33m } [0m
+ has type [33mFoo$Dict Number[0m
+in value declaration [33mfooNumber[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InstanceSigsOrphanTypeDeclaration.out b/tests/purs/failing/InstanceSigsOrphanTypeDeclaration.out
new file mode 100644
index 0000000000..5acb034332
--- /dev/null
+++ b/tests/purs/failing/InstanceSigsOrphanTypeDeclaration.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/InstanceSigsOrphanTypeDeclaration.purs:10:3 - 10:12 (line 10, column 3 - line 10, column 12)
+
+ The type declaration for [33mbar[0m should be followed by its definition.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanTypeDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/IntAsRecordLabel.out b/tests/purs/failing/IntAsRecordLabel.out
new file mode 100644
index 0000000000..c991b689b9
--- /dev/null
+++ b/tests/purs/failing/IntAsRecordLabel.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/IntAsRecordLabel.purs:4:27 - 4:29 (line 4, column 27 - line 4, column 29)
+
+ Unable to parse module:
+ Unexpected token '42'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/IntAsRecordLabel.purs b/tests/purs/failing/IntAsRecordLabel.purs
new file mode 100644
index 0000000000..27f2fadeb3
--- /dev/null
+++ b/tests/purs/failing/IntAsRecordLabel.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith ErrorParsingModule
+module Main where
+
+type IntAsRecordLabel = { 42 :: Int }
diff --git a/tests/purs/failing/IntOutOfRange.out b/tests/purs/failing/IntOutOfRange.out
new file mode 100644
index 0000000000..da5a10b480
--- /dev/null
+++ b/tests/purs/failing/IntOutOfRange.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/IntOutOfRange.purs:6:5 - 6:15 (line 6, column 5 - line 6, column 15)
+
+ Integer value [33m2147483648[0m is out of range for the JavaScript backend.
+ Acceptable values fall within the range [33m-2147483648[0m to [33m2147483647[0m (inclusive).
+
+
+See https://github.com/purescript/documentation/blob/master/errors/IntOutOfRange.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/IntToString1.out b/tests/purs/failing/IntToString1.out
new file mode 100644
index 0000000000..c816d7e9a1
--- /dev/null
+++ b/tests/purs/failing/IntToString1.out
@@ -0,0 +1,31 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/IntToString1.purs:14:15 - 14:46 (line 14, column 15 - line 14, column 46)
+
+ Could not match type
+ [33m [0m
+ [33m "1"[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m "a"[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.ToString 1 [0m
+[33m "a"[0m
+[33m [0m
+while applying a function [33mtestToString[0m
+ of type [33mToString t0 t1 => Proxy @Int t0 -> Proxy @Symbol t1[0m
+ to argument [33mProxy[0m
+while checking that expression [33mtestToString Proxy[0m
+ has type [33mProxy @Symbol "a"[0m
+in value declaration [33mposToString[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/IntToString1.purs b/tests/purs/failing/IntToString1.purs
new file mode 100644
index 0000000000..4c5d6b2a31
--- /dev/null
+++ b/tests/purs/failing/IntToString1.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prelude
+import Prim.Int (class ToString)
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+testToString :: forall i s. ToString i s => Proxy i -> Proxy s
+testToString _ = Proxy
+
+posToString :: Proxy "a"
+posToString = testToString (Proxy :: Proxy 1)
diff --git a/tests/purs/failing/IntToString2.out b/tests/purs/failing/IntToString2.out
new file mode 100644
index 0000000000..24e24d0d44
--- /dev/null
+++ b/tests/purs/failing/IntToString2.out
@@ -0,0 +1,31 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/IntToString2.purs:14:15 - 14:49 (line 14, column 15 - line 14, column 49)
+
+ Could not match type
+ [33m [0m
+ [33m "-1"[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m "a"[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.ToString -1 [0m
+[33m "a"[0m
+[33m [0m
+while applying a function [33mtestToString[0m
+ of type [33mToString t0 t1 => Proxy @Int t0 -> Proxy @Symbol t1[0m
+ to argument [33mProxy[0m
+while checking that expression [33mtestToString Proxy[0m
+ has type [33mProxy @Symbol "a"[0m
+in value declaration [33mnegToString[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/IntToString2.purs b/tests/purs/failing/IntToString2.purs
new file mode 100644
index 0000000000..05f977d530
--- /dev/null
+++ b/tests/purs/failing/IntToString2.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prelude
+import Prim.Int (class ToString)
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+testToString :: forall i s. ToString i s => Proxy i -> Proxy s
+testToString _ = Proxy
+
+negToString :: Proxy "a"
+negToString = testToString (Proxy :: Proxy (-1))
diff --git a/tests/purs/failing/IntToString3.out b/tests/purs/failing/IntToString3.out
new file mode 100644
index 0000000000..7008f15fec
--- /dev/null
+++ b/tests/purs/failing/IntToString3.out
@@ -0,0 +1,31 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/IntToString3.purs:14:16 - 14:47 (line 14, column 16 - line 14, column 47)
+
+ Could not match type
+ [33m [0m
+ [33m "0"[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m "a"[0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Int.ToString 0 [0m
+[33m "a"[0m
+[33m [0m
+while applying a function [33mtestToString[0m
+ of type [33mToString t0 t1 => Proxy @Int t0 -> Proxy @Symbol t1[0m
+ to argument [33mProxy[0m
+while checking that expression [33mtestToString Proxy[0m
+ has type [33mProxy @Symbol "a"[0m
+in value declaration [33mzeroToString[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/IntToString3.purs b/tests/purs/failing/IntToString3.purs
new file mode 100644
index 0000000000..71a58be7b0
--- /dev/null
+++ b/tests/purs/failing/IntToString3.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+import Prelude
+import Prim.Int (class ToString)
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+testToString :: forall i s. ToString i s => Proxy i -> Proxy s
+testToString _ = Proxy
+
+zeroToString :: Proxy "a"
+zeroToString = testToString (Proxy :: Proxy 0)
diff --git a/tests/purs/failing/InvalidCoercibleInstanceDeclaration.out b/tests/purs/failing/InvalidCoercibleInstanceDeclaration.out
new file mode 100644
index 0000000000..34e8147142
--- /dev/null
+++ b/tests/purs/failing/InvalidCoercibleInstanceDeclaration.out
@@ -0,0 +1,14 @@
+Error found:
+at tests/purs/failing/InvalidCoercibleInstanceDeclaration.purs:8:1 - 8:36 (line 8, column 1 - line 8, column 36)
+
+ Invalid type class instance declaration for
+ [33m [0m
+ [33m Prim.Coerce.Coercible D[0m
+ [33m D[0m
+ [33m [0m
+ Instance declarations of this type class are disallowed.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidCoercibleInstanceDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InvalidCoercibleInstanceDeclaration.purs b/tests/purs/failing/InvalidCoercibleInstanceDeclaration.purs
new file mode 100644
index 0000000000..38a28a1af6
--- /dev/null
+++ b/tests/purs/failing/InvalidCoercibleInstanceDeclaration.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith InvalidCoercibleInstanceDeclaration
+module Main where
+
+import Prim.Coerce (class Coercible)
+
+data D
+
+instance coercible :: Coercible D D
diff --git a/tests/purs/failing/InvalidDerivedInstance.out b/tests/purs/failing/InvalidDerivedInstance.out
new file mode 100644
index 0000000000..46ac3b7ffe
--- /dev/null
+++ b/tests/purs/failing/InvalidDerivedInstance.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/InvalidDerivedInstance.purs:8:1 - 8:30 (line 8, column 1 - line 8, column 30)
+
+ The type class [33mData.Eq.Eq[0m expects 1 argument.
+ But the instance [33meqX[0m provided 2.
+
+in type class instance
+[33m [0m
+[33m Data.Eq.Eq X[0m
+[33m X[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ClassInstanceArityMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InvalidDerivedInstance.purs b/tests/purs/failing/InvalidDerivedInstance.purs
index 11b1b46613..68714c7f62 100644
--- a/tests/purs/failing/InvalidDerivedInstance.purs
+++ b/tests/purs/failing/InvalidDerivedInstance.purs
@@ -1,4 +1,4 @@
--- @shouldFailWith InvalidDerivedInstance
+-- @shouldFailWith ClassInstanceArityMismatch
module Main where
import Prelude
diff --git a/tests/purs/failing/InvalidDerivedInstance2.out b/tests/purs/failing/InvalidDerivedInstance2.out
new file mode 100644
index 0000000000..842629b933
--- /dev/null
+++ b/tests/purs/failing/InvalidDerivedInstance2.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/InvalidDerivedInstance2.purs:6:1 - 6:34 (line 6, column 1 - line 6, column 34)
+
+ Type class instance head is invalid due to use of type
+ [33m [0m
+ [33m ()[0m
+ [33m [0m
+ All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form, unless the type is fully determined by other type class arguments via functional dependencies.
+
+in type class instance
+[33m [0m
+[33m Data.Eq.Eq (Record ())[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidInstanceHead.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InvalidDerivedInstance2.purs b/tests/purs/failing/InvalidDerivedInstance2.purs
index ec467337a7..e5d3f52d60 100644
--- a/tests/purs/failing/InvalidDerivedInstance2.purs
+++ b/tests/purs/failing/InvalidDerivedInstance2.purs
@@ -1,4 +1,4 @@
--- @shouldFailWith ExpectedTypeConstructor
+-- @shouldFailWith InvalidInstanceHead
module Main where
import Prelude
diff --git a/tests/purs/failing/InvalidDerivedInstance3.out b/tests/purs/failing/InvalidDerivedInstance3.out
new file mode 100644
index 0000000000..ded7378003
--- /dev/null
+++ b/tests/purs/failing/InvalidDerivedInstance3.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/InvalidDerivedInstance3.purs:8:15 - 8:16 (line 8, column 15 - line 8, column 16)
+
+ Type synonym [33mMain.S[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mS[0m
+ has kind [33mType[0m
+in type constructor [33mN[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/InvalidDerivedInstance3.purs b/tests/purs/failing/InvalidDerivedInstance3.purs
new file mode 100644
index 0000000000..5b676951f2
--- /dev/null
+++ b/tests/purs/failing/InvalidDerivedInstance3.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+import Data.Newtype (class Newtype)
+
+data D a
+type S a = D a
+newtype N = N S
+
+derive instance newtypeN :: Newtype N _
diff --git a/tests/purs/failing/InvalidOperatorInBinder.out b/tests/purs/failing/InvalidOperatorInBinder.out
new file mode 100644
index 0000000000..0b0541276d
--- /dev/null
+++ b/tests/purs/failing/InvalidOperatorInBinder.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/InvalidOperatorInBinder.purs:12:12 - 12:13 (line 12, column 12 - line 12, column 13)
+
+ Operator [33mMain.(:)[0m cannot be used in a pattern as it is an alias for function Main.cons.
+ Only aliases for data constructors may be used in patterns.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidOperatorInBinder.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/KindError.out b/tests/purs/failing/KindError.out
new file mode 100644
index 0000000000..fe56bd3e06
--- /dev/null
+++ b/tests/purs/failing/KindError.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/KindError.purs:6:35 - 6:36 (line 6, column 35 - line 6, column 36)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m t8 -> t9[0m
+ [33m [0m
+
+while checking that type [33mf[0m
+ has kind [33mt0 -> t1[0m
+while inferring the kind of [33mf a[0m
+in type constructor [33mKindError[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/KindStar.out b/tests/purs/failing/KindStar.out
new file mode 100644
index 0000000000..03dc0acb69
--- /dev/null
+++ b/tests/purs/failing/KindStar.out
@@ -0,0 +1,20 @@
+Error found:
+in module [33mX[0m
+at tests/purs/failing/KindStar.purs:7:1 - 7:13 (line 7, column 1 - line 7, column 13)
+
+ In a type-annotated expression [33mx :: t[0m, the type [33mt[0m must have kind [33mType[0m.
+ The error arises from the type
+ [33m [0m
+ [33m List[0m
+ [33m [0m
+ having the kind
+ [33m [0m
+ [33m Type -> Type[0m
+ [33m [0m
+ instead.
+
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ExpectedType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/LacksWithSubGoal.out b/tests/purs/failing/LacksWithSubGoal.out
new file mode 100644
index 0000000000..4938a23c86
--- /dev/null
+++ b/tests/purs/failing/LacksWithSubGoal.out
@@ -0,0 +1,35 @@
+Error found:
+in module [33mLacksWithSubGoal[0m
+at tests/purs/failing/LacksWithSubGoal.purs:14:11 - 14:33 (line 14, column 11 - line 14, column 33)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Row.Lacks "hello"[0m
+ [33m r0 [0m
+ [33m [0m
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Row.Lacks "hello" [0m
+[33m ( k :: Int[0m
+[33m | r0 [0m
+[33m ) [0m
+[33m [0m
+while applying a function [33munion[0m
+ of type [33mLacks @Type t1 t2 => S t1 -> R t2[0m
+ to argument [33mS[0m
+while checking that expression [33munion S[0m
+ has type [33mR [0m
+ [33m ( k :: Int[0m
+ [33m | r0 [0m
+ [33m ) [0m
+in value declaration [33mexample[0m
+
+where [33mr0[0m is a rigid type variable
+ bound at (line 14, column 11 - line 14, column 33)
+ [33mt1[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/LacksWithSubGoal.purs b/tests/purs/failing/LacksWithSubGoal.purs
index 40db3afd4f..4e5428234d 100644
--- a/tests/purs/failing/LacksWithSubGoal.purs
+++ b/tests/purs/failing/LacksWithSubGoal.purs
@@ -5,7 +5,7 @@ import Prim.Row (class Lacks)
data S (r :: Symbol) = S
-data R (r :: # Type) = R
+data R (r :: Row Type) = R
union :: forall s r. Lacks s r => S s -> R r
union S = R
diff --git a/tests/purs/failing/LeadingZeros1.out b/tests/purs/failing/LeadingZeros1.out
new file mode 100644
index 0000000000..c383f62eac
--- /dev/null
+++ b/tests/purs/failing/LeadingZeros1.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/LeadingZeros1.purs:6:6 - 6:7 (line 6, column 6 - line 6, column 7)
+
+ Unable to parse module:
+ Unexpected leading zeros
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/LeadingZeros2.out b/tests/purs/failing/LeadingZeros2.out
new file mode 100644
index 0000000000..276c4a4f65
--- /dev/null
+++ b/tests/purs/failing/LeadingZeros2.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/LeadingZeros2.purs:6:6 - 6:7 (line 6, column 6 - line 6, column 7)
+
+ Unable to parse module:
+ Unexpected leading zeros
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/Let.out b/tests/purs/failing/Let.out
new file mode 100644
index 0000000000..1cb58cd24e
--- /dev/null
+++ b/tests/purs/failing/Let.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/Let.purs:6:12 - 6:17 (line 6, column 12 - line 6, column 17)
+
+ The value of [33mx[0m is undefined here, so this reference is not allowed.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/LetPatterns1.out b/tests/purs/failing/LetPatterns1.out
new file mode 100644
index 0000000000..c5ad32edb2
--- /dev/null
+++ b/tests/purs/failing/LetPatterns1.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/LetPatterns1.purs:8:7 - 8:14 (line 8, column 7 - line 8, column 14)
+
+ Unable to parse module:
+ Expected pattern, saw expression
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/LetPatterns2.out b/tests/purs/failing/LetPatterns2.out
new file mode 100644
index 0000000000..b68af65d9f
--- /dev/null
+++ b/tests/purs/failing/LetPatterns2.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/LetPatterns2.purs:11:9 - 11:10 (line 11, column 9 - line 11, column 10)
+
+ Unknown value [33ma[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/LetPatterns3.out b/tests/purs/failing/LetPatterns3.out
new file mode 100644
index 0000000000..e778d9a3f4
--- /dev/null
+++ b/tests/purs/failing/LetPatterns3.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/LetPatterns3.purs:11:7 - 11:8 (line 11, column 7 - line 11, column 8)
+
+ Data constructor [33mMain.X[0m was given 0 arguments in a case expression, but expected 1 arguments.
+ This problem can be fixed by giving [33mMain.X[0m 1 arguments.
+
+while inferring the type of [33m\$0 -> [0m
+ [33m \b -> [0m
+ [33m case $0 b of[0m
+ [33m X b -> ...[0m
+in value declaration [33mx[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/IncorrectConstructorArity.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/LetPatterns4.out b/tests/purs/failing/LetPatterns4.out
new file mode 100644
index 0000000000..7fbf0354a2
--- /dev/null
+++ b/tests/purs/failing/LetPatterns4.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/LetPatterns4.purs:6:1 - 6:2 (line 6, column 1 - line 6, column 2)
+
+ Unable to parse module:
+ Unexpected token 'X'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MPTCs.out b/tests/purs/failing/MPTCs.out
new file mode 100644
index 0000000000..477771d4ab
--- /dev/null
+++ b/tests/purs/failing/MPTCs.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/MPTCs.purs:9:1 - 10:10 (line 9, column 1 - line 10, column 10)
+
+ The type class [33mMain.Foo[0m expects 1 argument.
+ But the instance [33mfooStringString[0m provided 2.
+
+in type class instance
+[33m [0m
+[33m Main.Foo String[0m
+[33m String[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ClassInstanceArityMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MissingClassExport.out b/tests/purs/failing/MissingClassExport.out
new file mode 100644
index 0000000000..ffee75853b
--- /dev/null
+++ b/tests/purs/failing/MissingClassExport.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mTest[0m
+at tests/purs/failing/MissingClassExport.purs:2:1 - 7:16 (line 2, column 1 - line 7, column 16)
+
+ An export for [33mbar[0m requires the following to also be exported:
+
+ [33mclass Foo[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MissingClassMember.out b/tests/purs/failing/MissingClassMember.out
new file mode 100644
index 0000000000..fcbd3dcf19
--- /dev/null
+++ b/tests/purs/failing/MissingClassMember.out
@@ -0,0 +1,15 @@
+Error found:
+at tests/purs/failing/MissingClassMember.purs:9:1 - 10:10 (line 9, column 1 - line 10, column 10)
+
+ The following type class members have not been implemented:
+ [33mb :: String -> Number[0m
+ [33mc :: forall f. String -> f String[0m
+
+in type class instance
+[33m [0m
+[33m Main.A String[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingClassMember.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MissingClassMemberExport.out b/tests/purs/failing/MissingClassMemberExport.out
new file mode 100644
index 0000000000..3b15f091fa
--- /dev/null
+++ b/tests/purs/failing/MissingClassMemberExport.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mTest[0m
+at tests/purs/failing/MissingClassMemberExport.purs:2:1 - 7:16 (line 2, column 1 - line 7, column 16)
+
+ An export for [33mclass Foo[0m requires the following to also be exported:
+
+ [33mbar[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MissingFFIImplementations.js b/tests/purs/failing/MissingFFIImplementations.js
index d29ee4cff9..ccb7243f7e 100644
--- a/tests/purs/failing/MissingFFIImplementations.js
+++ b/tests/purs/failing/MissingFFIImplementations.js
@@ -1 +1 @@
-exports.yes = true;
+export var yes = true;
diff --git a/tests/purs/failing/MissingFFIImplementations.out b/tests/purs/failing/MissingFFIImplementations.out
new file mode 100644
index 0000000000..1dd5b4f2f0
--- /dev/null
+++ b/tests/purs/failing/MissingFFIImplementations.out
@@ -0,0 +1,12 @@
+Error found:
+at tests/purs/failing/MissingFFIImplementations.purs:2:1 - 5:29 (line 2, column 1 - line 5, column 29)
+
+ The following values are not defined in the foreign module for module [33mMain[0m:
+
+ no
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingFFIImplementations.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MissingRecordField.out b/tests/purs/failing/MissingRecordField.out
new file mode 100644
index 0000000000..c6aff99a3e
--- /dev/null
+++ b/tests/purs/failing/MissingRecordField.out
@@ -0,0 +1,23 @@
+Error found:
+in module [33mMissingRecordField[0m
+at tests/purs/failing/MissingRecordField.purs:10:19 - 10:23 (line 10, column 19 - line 10, column 23)
+
+ Type of expression lacks required label [33mage[0m.
+
+while checking that type [33m{ first :: String[0m
+ [33m, last :: String [0m
+ [33m} [0m
+ is at least as general as type [33m{ age :: Number[0m
+ [33m| t0 [0m
+ [33m} [0m
+while checking that expression [33mjohn[0m
+ has type [33m{ age :: Number[0m
+ [33m| t0 [0m
+ [33m} [0m
+in value declaration [33mresult[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/PropertyIsMissing.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MixedAssociativityError.out b/tests/purs/failing/MixedAssociativityError.out
new file mode 100644
index 0000000000..d0076650b7
--- /dev/null
+++ b/tests/purs/failing/MixedAssociativityError.out
@@ -0,0 +1,14 @@
+Error found:
+at tests/purs/failing/MixedAssociativityError.purs:6:15 - 6:18 (line 6, column 15 - line 6, column 18)
+
+ Cannot parse an expression that uses operators of the same precedence but mixed associativity:
+
+ [33mData.Functor.(<$>)[0m is [33minfixl[0m
+ [33mData.Eq.(==)[0m is [33minfix[0m
+
+ Use parentheses to resolve this ambiguity.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/MixedAssociativityError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MonoKindDataBindingGroup.out b/tests/purs/failing/MonoKindDataBindingGroup.out
new file mode 100644
index 0000000000..d83be0b41a
--- /dev/null
+++ b/tests/purs/failing/MonoKindDataBindingGroup.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/MonoKindDataBindingGroup.purs:8:12 - 8:17 (line 8, column 12 - line 8, column 17)
+
+ Could not match kind
+ [33m [0m
+ [33m Symbol[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33m"bad"[0m
+ has kind [33mType[0m
+while inferring the kind of [33mA "bad"[0m
+in type synonym [33mX[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MonoKindDataBindingGroup.purs b/tests/purs/failing/MonoKindDataBindingGroup.purs
new file mode 100644
index 0000000000..3060e6e9b5
--- /dev/null
+++ b/tests/purs/failing/MonoKindDataBindingGroup.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+data F (a :: Type -> Type) = F
+data A a = A (B a)
+type B a = F A
+
+type X = A "bad"
diff --git a/tests/purs/failing/MultipleErrors.out b/tests/purs/failing/MultipleErrors.out
new file mode 100644
index 0000000000..b33b1ad362
--- /dev/null
+++ b/tests/purs/failing/MultipleErrors.out
@@ -0,0 +1,46 @@
+Error 1 of 2:
+
+ in module [33mMultipleErrors[0m
+ at tests/purs/failing/MultipleErrors.purs:8:9 - 8:15 (line 8, column 9 - line 8, column 15)
+
+ Could not match type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+ while checking that type [33mString[0m
+ is at least as general as type [33mInt[0m
+ while checking that expression [33m"Test"[0m
+ has type [33mInt[0m
+ in binding group foo, bar
+
+ See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 2:
+
+ in module [33mMultipleErrors[0m
+ at tests/purs/failing/MultipleErrors.purs:12:9 - 12:15 (line 12, column 9 - line 12, column 15)
+
+ Could not match type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+ while checking that type [33mString[0m
+ is at least as general as type [33mInt[0m
+ while checking that expression [33m"Test"[0m
+ has type [33mInt[0m
+ in binding group foo, bar
+
+ See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MultipleErrors2.out b/tests/purs/failing/MultipleErrors2.out
new file mode 100644
index 0000000000..73bc7e58a3
--- /dev/null
+++ b/tests/purs/failing/MultipleErrors2.out
@@ -0,0 +1,22 @@
+Error 1 of 2:
+
+ in module [33mMultipleErrors2[0m
+ at tests/purs/failing/MultipleErrors2.purs:7:7 - 7:20 (line 7, column 7 - line 7, column 20)
+
+ Unknown value [33mitDoesntExist[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 2:
+
+ in module [33mMultipleErrors2[0m
+ at tests/purs/failing/MultipleErrors2.purs:9:7 - 9:22 (line 9, column 7 - line 9, column 22)
+
+ Unknown value [33mneitherDoesThis[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MultipleTypeOpFixities.out b/tests/purs/failing/MultipleTypeOpFixities.out
new file mode 100644
index 0000000000..dde78d37cd
--- /dev/null
+++ b/tests/purs/failing/MultipleTypeOpFixities.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMultipleTypeOpFixities[0m
+at tests/purs/failing/MultipleTypeOpFixities.purs:9:1 - 9:22 (line 9, column 1 - line 9, column 22)
+
+ There are multiple fixity/precedence declarations for type operator [33m(!?)[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/MultipleTypeOpFixities.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MultipleValueOpFixities.out b/tests/purs/failing/MultipleValueOpFixities.out
new file mode 100644
index 0000000000..6a6fbbb290
--- /dev/null
+++ b/tests/purs/failing/MultipleValueOpFixities.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMultipleValueOpFixities[0m
+at tests/purs/failing/MultipleValueOpFixities.purs:9:1 - 9:18 (line 9, column 1 - line 9, column 18)
+
+ There are multiple fixity/precedence declarations for operator [33m(!?)[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/MultipleValueOpFixities.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MutRec.out b/tests/purs/failing/MutRec.out
new file mode 100644
index 0000000000..3fbe1496c3
--- /dev/null
+++ b/tests/purs/failing/MutRec.out
@@ -0,0 +1,20 @@
+Error 1 of 2:
+
+ at tests/purs/failing/MutRec.purs:7:1 - 7:6 (line 7, column 1 - line 7, column 6)
+
+ The value of [33mx[0m is undefined here, so this reference is not allowed.
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/CycleInDeclaration.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 2:
+
+ at tests/purs/failing/MutRec.purs:9:1 - 9:6 (line 9, column 1 - line 9, column 6)
+
+ The value of [33my[0m is undefined here, so this reference is not allowed.
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/CycleInDeclaration.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/MutRec2.out b/tests/purs/failing/MutRec2.out
new file mode 100644
index 0000000000..e76435f4df
--- /dev/null
+++ b/tests/purs/failing/MutRec2.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/MutRec2.purs:6:1 - 6:6 (line 6, column 1 - line 6, column 6)
+
+ The value of [33mx[0m is undefined here, so this reference is not allowed.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NestedRecordLabelOnTypeError.out b/tests/purs/failing/NestedRecordLabelOnTypeError.out
new file mode 100644
index 0000000000..911ad038f4
--- /dev/null
+++ b/tests/purs/failing/NestedRecordLabelOnTypeError.out
@@ -0,0 +1,34 @@
+Error found:
+in module [33mNestedRecordLabelOnTypeError[0m
+at tests/purs/failing/NestedRecordLabelOnTypeError.purs:8:9 - 8:15 (line 8, column 9 - line 8, column 15)
+
+ Could not match type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+
+while matching label [33mc[0m
+while matching label [33mb[0m
+while matching label [33ma[0m
+while checking that type [33m{ a :: { b :: { c :: Int[0m
+ [33m } [0m
+ [33m } [0m
+ [33m} [0m
+ is at least as general as type [33m{ a :: { b :: { c :: String[0m
+ [33m } [0m
+ [33m } [0m
+ [33m} [0m
+while checking that expression [33mrecord[0m
+ has type [33m{ a :: { b :: { c :: String[0m
+ [33m } [0m
+ [33m } [0m
+ [33m} [0m
+in value declaration [33merror[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NestedRecordLabelOnTypeError.purs b/tests/purs/failing/NestedRecordLabelOnTypeError.purs
new file mode 100644
index 0000000000..b91481cbe2
--- /dev/null
+++ b/tests/purs/failing/NestedRecordLabelOnTypeError.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith TypesDoNotUnify
+module NestedRecordLabelOnTypeError where
+
+record :: { a :: { b :: { c :: Int } } }
+record = { a: { b: { c: 1 } } }
+
+error :: { a :: { b :: { c :: String } } }
+error = record -- this should trigger an error, telling us there's a mismatch in the field `a > b > c`
diff --git a/tests/purs/failing/NewtypeInstance.out b/tests/purs/failing/NewtypeInstance.out
new file mode 100644
index 0000000000..efb1dae92f
--- /dev/null
+++ b/tests/purs/failing/NewtypeInstance.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/NewtypeInstance.purs:8:1 - 8:40 (line 8, column 1 - line 8, column 40)
+
+ Cannot derive newtype instance for
+ [33m [0m
+ [33m Data.Show.Show X[0m
+ [33m [0m
+ Make sure this is a newtype.
+
+in value declaration [33mshowX[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidNewtypeInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NewtypeInstance2.out b/tests/purs/failing/NewtypeInstance2.out
new file mode 100644
index 0000000000..f8f48e1695
--- /dev/null
+++ b/tests/purs/failing/NewtypeInstance2.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/NewtypeInstance2.purs:8:1 - 8:54 (line 8, column 1 - line 8, column 54)
+
+ Cannot derive newtype instance for
+ [33m [0m
+ [33m Data.Show.Show (X a0)[0m
+ [33m [0m
+ Make sure this is a newtype.
+
+in value declaration [33mshowX[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidNewtypeInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NewtypeInstance3.out b/tests/purs/failing/NewtypeInstance3.out
new file mode 100644
index 0000000000..ba27672759
--- /dev/null
+++ b/tests/purs/failing/NewtypeInstance3.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/NewtypeInstance3.purs:8:1 - 8:43 (line 8, column 1 - line 8, column 43)
+
+ Cannot derive newtype instance for
+ [33m [0m
+ [33m Main.Nullary [0m
+ [33m [0m
+ Make sure this is a newtype.
+
+in value declaration [33mnullary[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidNewtypeInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NewtypeInstance4.out b/tests/purs/failing/NewtypeInstance4.out
new file mode 100644
index 0000000000..2446c82964
--- /dev/null
+++ b/tests/purs/failing/NewtypeInstance4.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/NewtypeInstance4.purs:8:1 - 8:40 (line 8, column 1 - line 8, column 40)
+
+ Cannot derive newtype instance for
+ [33m [0m
+ [33m Data.Show.Show X[0m
+ [33m [0m
+ Make sure this is a newtype.
+
+in value declaration [33mshowX[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidNewtypeInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NewtypeInstance5.out b/tests/purs/failing/NewtypeInstance5.out
new file mode 100644
index 0000000000..335096de25
--- /dev/null
+++ b/tests/purs/failing/NewtypeInstance5.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/NewtypeInstance5.purs:8:1 - 8:46 (line 8, column 1 - line 8, column 46)
+
+ Cannot derive newtype instance for
+ [33m [0m
+ [33m Data.Functor.Functor X[0m
+ [33m [0m
+ Make sure this is a newtype.
+
+in value declaration [33mfunctorX[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidNewtypeInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NewtypeInstance6.out b/tests/purs/failing/NewtypeInstance6.out
new file mode 100644
index 0000000000..d135cf3c83
--- /dev/null
+++ b/tests/purs/failing/NewtypeInstance6.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/NewtypeInstance6.purs:8:45 - 8:46 (line 8, column 45 - line 8, column 46)
+
+ Could not match kind
+ [33m [0m
+ [33m Type -> Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33mX[0m
+ has kind [33mType -> Type[0m
+while inferring the kind of [33mFunctor X[0m
+in type class instance
+[33m [0m
+[33m Data.Functor.Functor X[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NewtypeInstance6.purs b/tests/purs/failing/NewtypeInstance6.purs
index fe7136661d..5833b1a382 100644
--- a/tests/purs/failing/NewtypeInstance6.purs
+++ b/tests/purs/failing/NewtypeInstance6.purs
@@ -1,4 +1,4 @@
--- @shouldFailWith InvalidNewtypeInstance
+-- @shouldFailWith KindsDoNotUnify
module Main where
import Prelude
diff --git a/tests/purs/failing/NewtypeMultiArgs.out b/tests/purs/failing/NewtypeMultiArgs.out
new file mode 100644
index 0000000000..c193cb6bc3
--- /dev/null
+++ b/tests/purs/failing/NewtypeMultiArgs.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/NewtypeMultiArgs.purs:6:30 - 6:37 (line 6, column 30 - line 6, column 37)
+
+ Unable to parse module:
+ Unexpected token 'Boolean'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NewtypeMultiCtor.out b/tests/purs/failing/NewtypeMultiCtor.out
new file mode 100644
index 0000000000..49419a338f
--- /dev/null
+++ b/tests/purs/failing/NewtypeMultiCtor.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/NewtypeMultiCtor.purs:6:30 - 6:31 (line 6, column 30 - line 6, column 31)
+
+ Unable to parse module:
+ Unexpected token '|'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NewtypeUnnamedInstance.out b/tests/purs/failing/NewtypeUnnamedInstance.out
new file mode 100644
index 0000000000..4ba7a4072f
--- /dev/null
+++ b/tests/purs/failing/NewtypeUnnamedInstance.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/NewtypeUnnamedInstance.purs:8:1 - 8:31 (line 8, column 1 - line 8, column 31)
+
+ Cannot derive newtype instance for
+ [33m [0m
+ [33m Data.Show.Show X[0m
+ [33m [0m
+ Make sure this is a newtype.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidNewtypeInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NewtypeUnnamedInstance.purs b/tests/purs/failing/NewtypeUnnamedInstance.purs
new file mode 100644
index 0000000000..b308b1cebc
--- /dev/null
+++ b/tests/purs/failing/NewtypeUnnamedInstance.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith InvalidNewtypeInstance
+module Main where
+
+import Prelude
+
+data X = X
+
+derive newtype instance Show X
diff --git a/tests/purs/failing/NonAssociativeError.out b/tests/purs/failing/NonAssociativeError.out
new file mode 100644
index 0000000000..7d7e56c1c6
--- /dev/null
+++ b/tests/purs/failing/NonAssociativeError.out
@@ -0,0 +1,26 @@
+Error 1 of 2:
+
+ at tests/purs/failing/NonAssociativeError.purs:7:10 - 7:12 (line 7, column 10 - line 7, column 12)
+
+ Cannot parse an expression that uses multiple instances of the non-associative operator [33mData.Eq.(==)[0m.
+ Use parentheses to resolve this ambiguity.
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/NonAssociativeError.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 2:
+
+ at tests/purs/failing/NonAssociativeError.purs:8:19 - 8:21 (line 8, column 19 - line 8, column 21)
+
+ Cannot parse an expression that uses multiple non-associative operators of the same precedence:
+
+ [33mData.Eq.(/=)[0m
+ [33mData.Eq.(==)[0m
+
+ Use parentheses to resolve this ambiguity.
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/NonAssociativeError.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NonExhaustivePatGuard.out b/tests/purs/failing/NonExhaustivePatGuard.out
new file mode 100644
index 0000000000..18d547672b
--- /dev/null
+++ b/tests/purs/failing/NonExhaustivePatGuard.out
@@ -0,0 +1,23 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/NonExhaustivePatGuard.purs:4:1 - 4:16 (line 4, column 1 - line 4, column 16)
+
+ A case expression could not be determined to cover all inputs.
+ The following additional cases are required to cover all inputs:
+
+ [33m_[0m
+
+ Alternatively, add a Partial constraint to the type of the enclosing value.
+
+while checking that type [33mPartial => t0[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33mcase x of [0m
+ [33m x | 1 <- x -> x[0m
+ has type [33mInt[0m
+in value declaration [33mf[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/NullaryAbs.out b/tests/purs/failing/NullaryAbs.out
new file mode 100644
index 0000000000..41bc8cbb89
--- /dev/null
+++ b/tests/purs/failing/NullaryAbs.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/NullaryAbs.purs:6:10 - 6:12 (line 6, column 10 - line 6, column 12)
+
+ Unable to parse module:
+ Unexpected token '->'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/Object.out b/tests/purs/failing/Object.out
new file mode 100644
index 0000000000..ef5e99d965
--- /dev/null
+++ b/tests/purs/failing/Object.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/Object.purs:8:14 - 8:16 (line 8, column 14 - line 8, column 16)
+
+ Type of expression lacks required label [33mfoo[0m.
+
+while checking that expression [33m{}[0m
+ has type [33m{ foo :: t0[0m
+ [33m| t1 [0m
+ [33m} [0m
+while applying a function [33mtest[0m
+ of type [33m{ foo :: t0[0m
+ [33m| t1 [0m
+ [33m} [0m
+ [33m-> t0 [0m
+ to argument [33m{}[0m
+in value declaration [33mtest1[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/PropertyIsMissing.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OperatorAliasNoExport.out b/tests/purs/failing/OperatorAliasNoExport.out
new file mode 100644
index 0000000000..2607f55955
--- /dev/null
+++ b/tests/purs/failing/OperatorAliasNoExport.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mTest[0m
+at tests/purs/failing/OperatorAliasNoExport.purs:2:1 - 7:13 (line 2, column 1 - line 7, column 13)
+
+ An export for [33m(?!)[0m requires the following to also be exported:
+
+ [33mwhat[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OperatorAt.out b/tests/purs/failing/OperatorAt.out
new file mode 100644
index 0000000000..4be88f6432
--- /dev/null
+++ b/tests/purs/failing/OperatorAt.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/OperatorAt.purs:6:18 - 6:19 (line 6, column 18 - line 6, column 19)
+
+ Unable to parse module:
+ Unexpected token '@'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OperatorBackslash.out b/tests/purs/failing/OperatorBackslash.out
new file mode 100644
index 0000000000..5759b77042
--- /dev/null
+++ b/tests/purs/failing/OperatorBackslash.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/OperatorBackslash.purs:6:18 - 6:19 (line 6, column 18 - line 6, column 19)
+
+ Unable to parse module:
+ Unexpected token '\'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OperatorSections.out b/tests/purs/failing/OperatorSections.out
new file mode 100644
index 0000000000..38b55b7111
--- /dev/null
+++ b/tests/purs/failing/OperatorSections.out
@@ -0,0 +1,27 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OperatorSections.purs:7:3 - 7:17 (line 7, column 3 - line 7, column 17)
+
+ Could not match type
+ [33m [0m
+ [33m Boolean[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m t1 -> t2[0m
+ [33m [0m
+
+while applying a function [33m(not (#dict HeytingAlgebra t2)) true[0m
+ of type [33mt0[0m
+ to argument [33m$0[0m
+while inferring the type of [33m\$0 -> [0m
+ [33m (not true) $0[0m
+in value declaration [33mmain[0m
+
+where [33mt1[0m is an unknown type
+ [33mt0[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OperatorSections2.out b/tests/purs/failing/OperatorSections2.out
new file mode 100644
index 0000000000..4371430edf
--- /dev/null
+++ b/tests/purs/failing/OperatorSections2.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/OperatorSections2.purs:6:10 - 6:11 (line 6, column 10 - line 6, column 11)
+
+ An anonymous function argument appears in an invalid context.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/IncorrectAnonymousArgument.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OperatorSections2.purs b/tests/purs/failing/OperatorSections2.purs
new file mode 100644
index 0000000000..3c69430271
--- /dev/null
+++ b/tests/purs/failing/OperatorSections2.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith IncorrectAnonymousArgument
+module Main where
+
+import Prelude
+
+test = ( _ * 4 + 1 ) 50
diff --git a/tests/purs/failing/OrphanInstance.out b/tests/purs/failing/OrphanInstance.out
new file mode 100644
index 0000000000..356d84cb09
--- /dev/null
+++ b/tests/purs/failing/OrphanInstance.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mTest[0m
+at tests/purs/failing/OrphanInstance.purs:6:1 - 7:11 (line 6, column 1 - line 7, column 11)
+
+ Orphan instance [33mcBoolean[0m found for
+ [33m [0m
+ [33m Class.C Boolean[0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mClass[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Class.C Boolean[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanInstanceFunDepCycle.out b/tests/purs/failing/OrphanInstanceFunDepCycle.out
new file mode 100644
index 0000000000..617efc66f6
--- /dev/null
+++ b/tests/purs/failing/OrphanInstanceFunDepCycle.out
@@ -0,0 +1,20 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OrphanInstanceFunDepCycle.purs:5:1 - 5:22 (line 5, column 1 - line 5, column 22)
+
+ Orphan instance [33mclr[0m found for
+ [33m [0m
+ [33m Lib.C L[0m
+ [33m R[0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mLib[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Lib.C L[0m
+[33m R[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanInstanceFunDepCycle/Lib.out b/tests/purs/failing/OrphanInstanceFunDepCycle/Lib.out
new file mode 100644
index 0000000000..617efc66f6
--- /dev/null
+++ b/tests/purs/failing/OrphanInstanceFunDepCycle/Lib.out
@@ -0,0 +1,20 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OrphanInstanceFunDepCycle.purs:5:1 - 5:22 (line 5, column 1 - line 5, column 22)
+
+ Orphan instance [33mclr[0m found for
+ [33m [0m
+ [33m Lib.C L[0m
+ [33m R[0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mLib[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Lib.C L[0m
+[33m R[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanInstanceNullary.out b/tests/purs/failing/OrphanInstanceNullary.out
new file mode 100644
index 0000000000..abc12fbc63
--- /dev/null
+++ b/tests/purs/failing/OrphanInstanceNullary.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mTest[0m
+at tests/purs/failing/OrphanInstanceNullary.purs:4:1 - 4:16 (line 4, column 1 - line 4, column 16)
+
+ Orphan instance [33mc[0m found for
+ [33m [0m
+ [33m Lib.C [0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mLib[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Lib.C [0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanInstanceNullary/Lib.out b/tests/purs/failing/OrphanInstanceNullary/Lib.out
new file mode 100644
index 0000000000..abc12fbc63
--- /dev/null
+++ b/tests/purs/failing/OrphanInstanceNullary/Lib.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mTest[0m
+at tests/purs/failing/OrphanInstanceNullary.purs:4:1 - 4:16 (line 4, column 1 - line 4, column 16)
+
+ Orphan instance [33mc[0m found for
+ [33m [0m
+ [33m Lib.C [0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mLib[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Lib.C [0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanInstanceWithDetermined.out b/tests/purs/failing/OrphanInstanceWithDetermined.out
new file mode 100644
index 0000000000..c5bbe45254
--- /dev/null
+++ b/tests/purs/failing/OrphanInstanceWithDetermined.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OrphanInstanceWithDetermined.purs:5:1 - 5:25 (line 5, column 1 - line 5, column 25)
+
+ Orphan instance [33mcflr[0m found for
+ [33m [0m
+ [33m Lib.C F[0m
+ [33m L[0m
+ [33m R[0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mLib[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Lib.C F[0m
+[33m L[0m
+[33m R[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanInstanceWithDetermined/Lib.out b/tests/purs/failing/OrphanInstanceWithDetermined/Lib.out
new file mode 100644
index 0000000000..c5bbe45254
--- /dev/null
+++ b/tests/purs/failing/OrphanInstanceWithDetermined/Lib.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OrphanInstanceWithDetermined.purs:5:1 - 5:25 (line 5, column 1 - line 5, column 25)
+
+ Orphan instance [33mcflr[0m found for
+ [33m [0m
+ [33m Lib.C F[0m
+ [33m L[0m
+ [33m R[0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mLib[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Lib.C F[0m
+[33m L[0m
+[33m R[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanKindDeclaration1.out b/tests/purs/failing/OrphanKindDeclaration1.out
new file mode 100644
index 0000000000..2aab0aa74a
--- /dev/null
+++ b/tests/purs/failing/OrphanKindDeclaration1.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OrphanKindDeclaration1.purs:4:1 - 4:17 (line 4, column 1 - line 4, column 17)
+
+ The kind declaration for [33mFoo[0m should be followed by its definition.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanKindDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanKindDeclaration1.purs b/tests/purs/failing/OrphanKindDeclaration1.purs
new file mode 100644
index 0000000000..6760f449e8
--- /dev/null
+++ b/tests/purs/failing/OrphanKindDeclaration1.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith OrphanKindDeclaration
+module Main where
+
+type Foo :: Type
diff --git a/tests/purs/failing/OrphanKindDeclaration2.out b/tests/purs/failing/OrphanKindDeclaration2.out
new file mode 100644
index 0000000000..f8ac604975
--- /dev/null
+++ b/tests/purs/failing/OrphanKindDeclaration2.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OrphanKindDeclaration2.purs:4:1 - 4:17 (line 4, column 1 - line 4, column 17)
+
+ The kind declaration for [33mFoo[0m should be followed by its definition.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanKindDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanKindDeclaration2.purs b/tests/purs/failing/OrphanKindDeclaration2.purs
new file mode 100644
index 0000000000..3c8599f5d5
--- /dev/null
+++ b/tests/purs/failing/OrphanKindDeclaration2.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith OrphanKindDeclaration
+module Main where
+
+type Foo :: Type
+data Foo = Foo Int
diff --git a/tests/purs/failing/OrphanRoleDeclaration1.out b/tests/purs/failing/OrphanRoleDeclaration1.out
new file mode 100644
index 0000000000..754bc4bb57
--- /dev/null
+++ b/tests/purs/failing/OrphanRoleDeclaration1.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OrphanRoleDeclaration1.purs:4:1 - 4:20 (line 4, column 1 - line 4, column 20)
+
+ The role declaration for [33mD[0m should follow its definition.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanRoleDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanRoleDeclaration1.purs b/tests/purs/failing/OrphanRoleDeclaration1.purs
new file mode 100644
index 0000000000..5ca3d6e55d
--- /dev/null
+++ b/tests/purs/failing/OrphanRoleDeclaration1.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith OrphanRoleDeclaration
+module Main where
+
+type role D nominal
diff --git a/tests/purs/failing/OrphanRoleDeclaration2.out b/tests/purs/failing/OrphanRoleDeclaration2.out
new file mode 100644
index 0000000000..6809df3c8b
--- /dev/null
+++ b/tests/purs/failing/OrphanRoleDeclaration2.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OrphanRoleDeclaration2.purs:4:1 - 4:20 (line 4, column 1 - line 4, column 20)
+
+ The role declaration for [33mD[0m should follow its definition.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanRoleDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanRoleDeclaration2.purs b/tests/purs/failing/OrphanRoleDeclaration2.purs
new file mode 100644
index 0000000000..d850506354
--- /dev/null
+++ b/tests/purs/failing/OrphanRoleDeclaration2.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith OrphanRoleDeclaration
+module Main where
+
+type role D nominal
+data D a = D a
diff --git a/tests/purs/failing/OrphanRoleDeclaration3.out b/tests/purs/failing/OrphanRoleDeclaration3.out
new file mode 100644
index 0000000000..4440913933
--- /dev/null
+++ b/tests/purs/failing/OrphanRoleDeclaration3.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OrphanRoleDeclaration3.purs:8:1 - 8:21 (line 8, column 1 - line 8, column 21)
+
+ The role declaration for [33mD1[0m should follow its definition.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanRoleDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanRoleDeclaration3.purs b/tests/purs/failing/OrphanRoleDeclaration3.purs
new file mode 100644
index 0000000000..7671c11d9f
--- /dev/null
+++ b/tests/purs/failing/OrphanRoleDeclaration3.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith OrphanRoleDeclaration
+module Main where
+
+data D1 a = D1 a
+
+data D2 a = D2 a
+
+type role D1 nominal
diff --git a/tests/purs/failing/OrphanTypeDecl.out b/tests/purs/failing/OrphanTypeDecl.out
new file mode 100644
index 0000000000..8ecc69800b
--- /dev/null
+++ b/tests/purs/failing/OrphanTypeDecl.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mOrphanTypeDecl[0m
+at tests/purs/failing/OrphanTypeDecl.purs:4:1 - 4:24 (line 4, column 1 - line 4, column 24)
+
+ The type declaration for [33mfn[0m should be followed by its definition.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanTypeDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanUnnamedInstance.out b/tests/purs/failing/OrphanUnnamedInstance.out
new file mode 100644
index 0000000000..52447d1cca
--- /dev/null
+++ b/tests/purs/failing/OrphanUnnamedInstance.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mTest[0m
+at tests/purs/failing/OrphanUnnamedInstance.purs:6:1 - 7:11 (line 6, column 1 - line 7, column 11)
+
+ Orphan instance found for
+ [33m [0m
+ [33m Class.C Boolean[0m
+ [33m [0m
+ This problem can be resolved by declaring the instance in [33mClass[0m, or by defining the instance on a newtype wrapper.
+
+in type class instance
+[33m [0m
+[33m Class.C Boolean[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OrphanInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OrphanUnnamedInstance.purs b/tests/purs/failing/OrphanUnnamedInstance.purs
new file mode 100644
index 0000000000..c5a7db3969
--- /dev/null
+++ b/tests/purs/failing/OrphanUnnamedInstance.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith OrphanInstance
+module Test where
+
+import Class
+
+instance C Boolean where
+ op a = a
diff --git a/tests/purs/failing/OrphanUnnamedInstance/Class.purs b/tests/purs/failing/OrphanUnnamedInstance/Class.purs
new file mode 100644
index 0000000000..0b482d48a1
--- /dev/null
+++ b/tests/purs/failing/OrphanUnnamedInstance/Class.purs
@@ -0,0 +1,4 @@
+module Class where
+
+class C a where
+ op :: a -> a
diff --git a/tests/purs/failing/OverlapAcrossModules.out b/tests/purs/failing/OverlapAcrossModules.out
new file mode 100644
index 0000000000..1da4826c5f
--- /dev/null
+++ b/tests/purs/failing/OverlapAcrossModules.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mOverlapAcrossModules[0m
+at tests/purs/failing/OverlapAcrossModules.purs:6:1 - 6:22 (line 6, column 1 - line 6, column 22)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m OverlapAcrossModules.Class.C X[0m
+ [33m Y[0m
+ [33m [0m
+ The following instances were found:
+
+ [33mOverlapAcrossModules.X.cxy[0m
+ [33mOverlapAcrossModules.cxy[0m
+
+
+in type class instance
+[33m [0m
+[33m OverlapAcrossModules.Class.C X[0m
+[33m Y[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OverlapAcrossModules/Class.out b/tests/purs/failing/OverlapAcrossModules/Class.out
new file mode 100644
index 0000000000..ae7c7037f3
--- /dev/null
+++ b/tests/purs/failing/OverlapAcrossModules/Class.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mOverlapAcrossModules[0m
+at tests/purs/failing/OverlapAcrossModules.purs:6:1 - 6:22 (line 6, column 1 - line 6, column 22)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m OverlapAcrossModules.Class.C X[0m
+ [33m Y[0m
+ [33m [0m
+ The following instances were found:
+
+ OverlapAcrossModules.X.cxy
+ OverlapAcrossModules.cxy
+
+
+in type class instance
+[33m [0m
+[33m OverlapAcrossModules.Class.C X[0m
+[33m Y[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OverlapAcrossModulesUnnamedInstance.out b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance.out
new file mode 100644
index 0000000000..9ea61e29b4
--- /dev/null
+++ b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mOverlapAcrossModules[0m
+at tests/purs/failing/OverlapAcrossModulesUnnamedInstance.purs:6:1 - 6:15 (line 6, column 1 - line 6, column 15)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m OverlapAcrossModules.Class.C X[0m
+ [33m Y[0m
+ [33m [0m
+ The following instances were found:
+
+ [33mOverlapAcrossModules.X.cX[0m
+ instance in module [33mOverlapAcrossModules[0m with type [33mC X Y[0m (line 6, column 1 - line 6, column 15)
+
+
+in type class instance
+[33m [0m
+[33m OverlapAcrossModules.Class.C X[0m
+[33m Y[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OverlapAcrossModulesUnnamedInstance.purs b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance.purs
new file mode 100644
index 0000000000..030cfd2351
--- /dev/null
+++ b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith OverlappingInstances
+module OverlapAcrossModules where
+import OverlapAcrossModules.Class
+import OverlapAcrossModules.X
+data Y
+instance C X Y
+
diff --git a/tests/purs/failing/OverlapAcrossModulesUnnamedInstance/Class.out b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance/Class.out
new file mode 100644
index 0000000000..ae7c7037f3
--- /dev/null
+++ b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance/Class.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mOverlapAcrossModules[0m
+at tests/purs/failing/OverlapAcrossModules.purs:6:1 - 6:22 (line 6, column 1 - line 6, column 22)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m OverlapAcrossModules.Class.C X[0m
+ [33m Y[0m
+ [33m [0m
+ The following instances were found:
+
+ OverlapAcrossModules.X.cxy
+ OverlapAcrossModules.cxy
+
+
+in type class instance
+[33m [0m
+[33m OverlapAcrossModules.Class.C X[0m
+[33m Y[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OverlapAcrossModulesUnnamedInstance/Class.purs b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance/Class.purs
new file mode 100644
index 0000000000..6b4699a9a1
--- /dev/null
+++ b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance/Class.purs
@@ -0,0 +1,2 @@
+module OverlapAcrossModules.Class where
+class C x y
diff --git a/tests/purs/failing/OverlapAcrossModulesUnnamedInstance/X.purs b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance/X.purs
new file mode 100644
index 0000000000..79692c813b
--- /dev/null
+++ b/tests/purs/failing/OverlapAcrossModulesUnnamedInstance/X.purs
@@ -0,0 +1,4 @@
+module OverlapAcrossModules.X where
+import OverlapAcrossModules.Class
+data X
+instance C X y
diff --git a/tests/purs/failing/OverlappingArguments.out b/tests/purs/failing/OverlappingArguments.out
new file mode 100644
index 0000000000..cbb05dd064
--- /dev/null
+++ b/tests/purs/failing/OverlappingArguments.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mOverlappingArguments[0m
+at tests/purs/failing/OverlappingArguments.purs:6:1 - 6:10 (line 6, column 1 - line 6, column 10)
+
+ Overlapping names in function/binder in declaration f
+
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingArgNames.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OverlappingBinders.out b/tests/purs/failing/OverlappingBinders.out
new file mode 100644
index 0000000000..bc02334154
--- /dev/null
+++ b/tests/purs/failing/OverlappingBinders.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mOverlappingBinders[0m
+at tests/purs/failing/OverlappingBinders.purs:8:7 - 9:28 (line 8, column 7 - line 9, column 28)
+
+ Overlapping names in function/binder
+
+while inferring the type of [33m\x -> [0m
+ [33m case x of [0m
+ [33m (S y (S y@S z zs)) -> y[0m
+in value declaration [33mf[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingArgNames.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OverlappingInstances.out b/tests/purs/failing/OverlappingInstances.out
new file mode 100644
index 0000000000..f4c096b695
--- /dev/null
+++ b/tests/purs/failing/OverlappingInstances.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OverlappingInstances.purs:10:1 - 11:13 (line 10, column 1 - line 11, column 13)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m Main.Test Int[0m
+ [33m [0m
+ The following instances were found:
+
+ [33mMain.testRefl[0m
+ [33mMain.testInt[0m
+
+
+in type class instance
+[33m [0m
+[33m Main.Test Int[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OverlappingInstances.purs b/tests/purs/failing/OverlappingInstances.purs
index 9ae7230584..c6c51d0a2f 100644
--- a/tests/purs/failing/OverlappingInstances.purs
+++ b/tests/purs/failing/OverlappingInstances.purs
@@ -12,6 +12,6 @@ instance testInt :: Test Int where
-- The OverlappingInstances instances error only arises when there are two
-- choices for a dictionary, not when the instances are defined. So without
--- `value` this module would not raise a warning.
+-- `value` this module would not raise an error.
value :: Int
value = test 1
diff --git a/tests/purs/failing/OverlappingUnnamedInstances.out b/tests/purs/failing/OverlappingUnnamedInstances.out
new file mode 100644
index 0000000000..22f0525f1c
--- /dev/null
+++ b/tests/purs/failing/OverlappingUnnamedInstances.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OverlappingUnnamedInstances.purs:10:1 - 11:13 (line 10, column 1 - line 11, column 13)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m Main.Test Int[0m
+ [33m [0m
+ The following instances were found:
+
+ instance in module [33mMain[0m with type [33mforall a. Test a[0m (line 7, column 1 - line 8, column 13)
+ instance in module [33mMain[0m with type [33mTest Int[0m (line 10, column 1 - line 11, column 13)
+
+
+in type class instance
+[33m [0m
+[33m Main.Test Int[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/OverlappingUnnamedInstances.purs b/tests/purs/failing/OverlappingUnnamedInstances.purs
new file mode 100644
index 0000000000..92e85ec3bd
--- /dev/null
+++ b/tests/purs/failing/OverlappingUnnamedInstances.purs
@@ -0,0 +1,17 @@
+-- @shouldFailWith OverlappingInstances
+module Main where
+
+class Test a where
+ test :: a -> a
+
+instance Test a where
+ test x = x
+
+instance Test Int where
+ test _ = 0
+
+-- The OverlappingInstances instances error only arises when there are two
+-- choices for a dictionary, not when the instances are defined. So without
+-- `value` this module would not raise an error.
+value :: Int
+value = test 1
diff --git a/tests/purs/failing/OverlappingVars.out b/tests/purs/failing/OverlappingVars.out
new file mode 100644
index 0000000000..8f49802299
--- /dev/null
+++ b/tests/purs/failing/OverlappingVars.out
@@ -0,0 +1,20 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/OverlappingVars.purs:14:8 - 14:20 (line 14, column 8 - line 14, column 20)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.OverlappingVars (Foo String Int)[0m
+ [33m [0m
+
+while applying a function [33mf[0m
+ of type [33mOverlappingVars t0 => t0 -> t0[0m
+ to argument [33m(Foo "") 0[0m
+while inferring the type of [33mf ((Foo "") 0)[0m
+in value declaration [33mtest[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PASTrumpsKDNU1.out b/tests/purs/failing/PASTrumpsKDNU1.out
new file mode 100644
index 0000000000..4f66aff0ce
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU1.out
@@ -0,0 +1,17 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PASTrumpsKDNU1.purs:14:33 - 14:43 (line 14, column 33 - line 14, column 43)
+
+ Type synonym [33mData.NaturalTransformation.NaturalTransformation[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mNaturalTransformation Array[0m
+ has kind [33mType[0m
+while inferring the kind of [33mShow a => NaturalTransformation Array[0m
+while inferring the kind of [33mProxy (Show a => NaturalTransformation Array)[0m
+while inferring the kind of [33mforall a. Proxy (Show a => NaturalTransformation Array)[0m
+in value declaration [33mf[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PASTrumpsKDNU1.purs b/tests/purs/failing/PASTrumpsKDNU1.purs
new file mode 100644
index 0000000000..e12b642aac
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU1.purs
@@ -0,0 +1,15 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+import Prelude
+
+-- The PASTrumpsKDNU series of tests check a number of situations in which
+-- both PartiallyAppliedSynonym and KindsDoNotUnify would be reasonable
+-- errors to show; in these situtations, PartiallyAppliedSynonym is likely to
+-- be the more useful error.
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+f :: forall a. Proxy (Show a => (~>) Array)
+f = Proxy
diff --git a/tests/purs/failing/PASTrumpsKDNU2.out b/tests/purs/failing/PASTrumpsKDNU2.out
new file mode 100644
index 0000000000..930028b8df
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU2.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PASTrumpsKDNU2.purs:9:19 - 9:29 (line 9, column 19 - line 9, column 29)
+
+ Type synonym [33mData.NaturalTransformation.NaturalTransformation[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mNaturalTransformation Array[0m
+ has kind [33mType[0m
+while inferring the kind of [33mforall (a :: NaturalTransformation Array). Proxy a -> Proxy a[0m
+in value declaration [33mf[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PASTrumpsKDNU2.purs b/tests/purs/failing/PASTrumpsKDNU2.purs
new file mode 100644
index 0000000000..00fb71a694
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU2.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+import Prelude
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+f :: forall (a :: (~>) Array). Proxy a -> Proxy a
+f x = x
diff --git a/tests/purs/failing/PASTrumpsKDNU3.out b/tests/purs/failing/PASTrumpsKDNU3.out
new file mode 100644
index 0000000000..8de6b8a59e
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU3.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PASTrumpsKDNU3.purs:9:23 - 9:33 (line 9, column 23 - line 9, column 33)
+
+ Type synonym [33mData.NaturalTransformation.NaturalTransformation[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mNaturalTransformation Array[0m
+ has kind [33mType[0m
+while inferring the kind of [33mforall a. NaturalTransformation Array[0m
+while inferring the kind of [33mProxy (forall a. NaturalTransformation Array)[0m
+in value declaration [33mp[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PASTrumpsKDNU3.purs b/tests/purs/failing/PASTrumpsKDNU3.purs
new file mode 100644
index 0000000000..fddb4a547b
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU3.purs
@@ -0,0 +1,10 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+import Prelude
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+p :: Proxy (forall a. (~>) Array)
+p = Proxy
diff --git a/tests/purs/failing/PASTrumpsKDNU4.out b/tests/purs/failing/PASTrumpsKDNU4.out
new file mode 100644
index 0000000000..b6f519f728
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU4.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PASTrumpsKDNU4.purs:6:14 - 6:24 (line 6, column 14 - line 6, column 24)
+
+ Type synonym [33mData.NaturalTransformation.NaturalTransformation[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mNaturalTransformation Array[0m
+ has kind [33mType[0m
+in type constructor [33mD[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PASTrumpsKDNU4.purs b/tests/purs/failing/PASTrumpsKDNU4.purs
new file mode 100644
index 0000000000..13f9a0f2ae
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU4.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+import Prelude
+
+data D (a :: (~>) Array) = D
diff --git a/tests/purs/failing/PASTrumpsKDNU5.out b/tests/purs/failing/PASTrumpsKDNU5.out
new file mode 100644
index 0000000000..f8b55fdeb5
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU5.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PASTrumpsKDNU5.purs:6:16 - 6:26 (line 6, column 16 - line 6, column 26)
+
+ Type synonym [33mData.NaturalTransformation.NaturalTransformation[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mNaturalTransformation Array[0m
+ has kind [33mType[0m
+in type constructor [33mN[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PASTrumpsKDNU5.purs b/tests/purs/failing/PASTrumpsKDNU5.purs
new file mode 100644
index 0000000000..99bfa4ab46
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU5.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+import Prelude
+
+newtype N = N ((~>) Array)
diff --git a/tests/purs/failing/PASTrumpsKDNU6.out b/tests/purs/failing/PASTrumpsKDNU6.out
new file mode 100644
index 0000000000..8b45d68af2
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU6.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PASTrumpsKDNU6.purs:6:14 - 6:24 (line 6, column 14 - line 6, column 24)
+
+ Type synonym [33mData.NaturalTransformation.NaturalTransformation[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mNaturalTransformation Array[0m
+ has kind [33mType[0m
+in type synonym [33mT[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PASTrumpsKDNU6.purs b/tests/purs/failing/PASTrumpsKDNU6.purs
new file mode 100644
index 0000000000..5bfb6a80e8
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU6.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+import Prelude
+
+type T (a :: (~>) Array) = Int
diff --git a/tests/purs/failing/PASTrumpsKDNU7.out b/tests/purs/failing/PASTrumpsKDNU7.out
new file mode 100644
index 0000000000..3ea32bb392
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU7.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PASTrumpsKDNU7.purs:6:15 - 6:25 (line 6, column 15 - line 6, column 25)
+
+ Type synonym [33mData.NaturalTransformation.NaturalTransformation[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mNaturalTransformation Array[0m
+ has kind [33mType[0m
+in type constructor [33mC$Dict[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PASTrumpsKDNU7.purs b/tests/purs/failing/PASTrumpsKDNU7.purs
new file mode 100644
index 0000000000..434ed11409
--- /dev/null
+++ b/tests/purs/failing/PASTrumpsKDNU7.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+import Prelude
+
+class C (a :: (~>) Array)
diff --git a/tests/purs/failing/PolykindGeneralizationLet.out b/tests/purs/failing/PolykindGeneralizationLet.out
new file mode 100644
index 0000000000..7547a0b8ea
--- /dev/null
+++ b/tests/purs/failing/PolykindGeneralizationLet.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PolykindGeneralizationLet.purs:14:10 - 14:26 (line 14, column 10 - line 14, column 26)
+
+ Could not match type
+ [33m [0m
+ [33m "foo"[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+while trying to match type [33mt0 "foo"[0m
+ with type [33mProxy @Type Int[0m
+while checking that expression [33mProxy[0m
+ has type [33mProxy @Type Int[0m
+in value declaration [33mtest[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PolykindGeneralizationLet.purs b/tests/purs/failing/PolykindGeneralizationLet.purs
new file mode 100644
index 0000000000..9192f096c1
--- /dev/null
+++ b/tests/purs/failing/PolykindGeneralizationLet.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith TypesDoNotUnify
+module Main where
+
+data Proxy a = Proxy
+data F f a = F (f a)
+
+fproxy :: forall f a. Proxy f -> Proxy a -> Proxy (F f a)
+fproxy _ _ = Proxy
+
+test = c
+ where
+ a = fproxy (Proxy :: _ Proxy)
+ b = a (Proxy :: _ Int)
+ c = a (Proxy :: _ "foo")
diff --git a/tests/purs/failing/PolykindInstanceOverlapping.out b/tests/purs/failing/PolykindInstanceOverlapping.out
new file mode 100644
index 0000000000..866b9af3a9
--- /dev/null
+++ b/tests/purs/failing/PolykindInstanceOverlapping.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PolykindInstanceOverlapping.purs:12:1 - 13:19 (line 12, column 1 - line 13, column 19)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m Main.ShowP (Proxy a)[0m
+ [33m [0m
+ The following instances were found:
+
+ [33mMain.test1[0m
+ [33mMain.test2[0m
+
+
+in type class instance
+[33m [0m
+[33m Main.ShowP (Proxy (a :: k))[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PolykindInstanceOverlapping.purs b/tests/purs/failing/PolykindInstanceOverlapping.purs
new file mode 100644
index 0000000000..0625e65d44
--- /dev/null
+++ b/tests/purs/failing/PolykindInstanceOverlapping.purs
@@ -0,0 +1,13 @@
+-- @shouldFailWith OverlappingInstances
+module Main where
+
+data Proxy a = Proxy
+
+class ShowP a where
+ showP :: a -> String
+
+instance test1 :: ShowP (Proxy ((a) :: k)) where
+ showP _ = "Type"
+
+instance test2 :: ShowP (Proxy ((a) :: k)) where
+ showP _ = "Type"
diff --git a/tests/purs/failing/PolykindInstantiatedInstance.out b/tests/purs/failing/PolykindInstantiatedInstance.out
new file mode 100644
index 0000000000..b2f7aa07e0
--- /dev/null
+++ b/tests/purs/failing/PolykindInstantiatedInstance.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PolykindInstantiatedInstance.purs:12:26 - 12:42 (line 12, column 26 - line 12, column 42)
+
+ Could not match kind
+ [33m [0m
+ [33m Symbol[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while trying to match type [33m"foo"[0m
+ with type [33mt1[0m
+while checking that expression [33mProxy[0m
+ has type [33mt0 t1[0m
+in value declaration [33mtest1[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PolykindInstantiatedInstance.purs b/tests/purs/failing/PolykindInstantiatedInstance.purs
new file mode 100644
index 0000000000..5304fcaaed
--- /dev/null
+++ b/tests/purs/failing/PolykindInstantiatedInstance.purs
@@ -0,0 +1,12 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+data Proxy a = Proxy
+
+class F f where
+ f :: forall a b. (a -> b) -> f a -> f b
+
+instance fProxy :: F Proxy where
+ f _ _ = Proxy
+
+test1 = f (\a -> "foo") (Proxy :: _ "foo")
diff --git a/tests/purs/failing/PolykindInstantiation.out b/tests/purs/failing/PolykindInstantiation.out
new file mode 100644
index 0000000000..bf95fdc892
--- /dev/null
+++ b/tests/purs/failing/PolykindInstantiation.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PolykindInstantiation.purs:8:33 - 8:38 (line 8, column 33 - line 8, column 38)
+
+ Could not match kind
+ [33m [0m
+ [33m Symbol[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33m"foo"[0m
+ has kind [33mType[0m
+while inferring the kind of [33mF Proxy "foo"[0m
+while inferring the kind of [33mProxy (F Proxy "foo")[0m
+in value declaration [33mtest2[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PolykindInstantiation.purs b/tests/purs/failing/PolykindInstantiation.purs
new file mode 100644
index 0000000000..207423eb1b
--- /dev/null
+++ b/tests/purs/failing/PolykindInstantiation.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+data Proxy a = Proxy
+data F f (a :: Type) = F (f a)
+
+test1 = Proxy :: Proxy (F Proxy Int)
+test2 = Proxy :: Proxy (F Proxy "foo")
diff --git a/tests/purs/failing/PolykindUnnamedInstanceOverlapping.out b/tests/purs/failing/PolykindUnnamedInstanceOverlapping.out
new file mode 100644
index 0000000000..5e84fbb8e9
--- /dev/null
+++ b/tests/purs/failing/PolykindUnnamedInstanceOverlapping.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PolykindUnnamedInstanceOverlapping.purs:12:1 - 13:19 (line 12, column 1 - line 13, column 19)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m Main.ShowP (Proxy a)[0m
+ [33m [0m
+ The following instances were found:
+
+ instance in module [33mMain[0m with type [33mforall a. ShowP (Proxy a)[0m (line 9, column 1 - line 10, column 19)
+ instance in module [33mMain[0m with type [33mforall a. ShowP (Proxy a)[0m (line 12, column 1 - line 13, column 19)
+
+
+in type class instance
+[33m [0m
+[33m Main.ShowP (Proxy (a :: k))[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PolykindUnnamedInstanceOverlapping.purs b/tests/purs/failing/PolykindUnnamedInstanceOverlapping.purs
new file mode 100644
index 0000000000..13c18dbf5d
--- /dev/null
+++ b/tests/purs/failing/PolykindUnnamedInstanceOverlapping.purs
@@ -0,0 +1,13 @@
+-- @shouldFailWith OverlappingInstances
+module Main where
+
+data Proxy a = Proxy
+
+class ShowP a where
+ showP :: a -> String
+
+instance ShowP (Proxy ((a) :: k)) where
+ showP _ = "Type"
+
+instance ShowP (Proxy ((a) :: k)) where
+ showP _ = "Type"
diff --git a/tests/purs/failing/PossiblyInfiniteCoercibleInstance.out b/tests/purs/failing/PossiblyInfiniteCoercibleInstance.out
new file mode 100644
index 0000000000..1538fff462
--- /dev/null
+++ b/tests/purs/failing/PossiblyInfiniteCoercibleInstance.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PossiblyInfiniteCoercibleInstance.purs:9:12 - 9:18 (line 9, column 12 - line 9, column 18)
+
+ A [33mCoercible[0m instance is possibly infinite.
+
+while solving type class constraint
+[33m [0m
+[33m Prim.Coerce.Coercible (N a0)[0m
+[33m (N b1)[0m
+[33m [0m
+while checking that type [33mforall (a :: Type) (b :: Type). Coercible @Type a b => a -> b[0m
+ is at least as general as type [33mN a0 -> N b1[0m
+while checking that expression [33mcoerce[0m
+ has type [33mN a0 -> N b1[0m
+in value declaration [33minfinite[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 9, column 12 - line 9, column 18)
+ [33mb1[0m is a rigid type variable
+ bound at (line 9, column 12 - line 9, column 18)
+
+See https://github.com/purescript/documentation/blob/master/errors/PossiblyInfiniteCoercibleInstance.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PossiblyInfiniteCoercibleInstance.purs b/tests/purs/failing/PossiblyInfiniteCoercibleInstance.purs
new file mode 100644
index 0000000000..1d172dfcc5
--- /dev/null
+++ b/tests/purs/failing/PossiblyInfiniteCoercibleInstance.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith PossiblyInfiniteCoercibleInstance
+module Main where
+
+import Safe.Coerce (coerce)
+
+newtype N a = N (a -> N a)
+
+infinite :: forall a b. N a -> N b
+infinite = coerce
diff --git a/tests/purs/failing/PrimModuleReserved.out b/tests/purs/failing/PrimModuleReserved.out
new file mode 100644
index 0000000000..67794c66d5
--- /dev/null
+++ b/tests/purs/failing/PrimModuleReserved.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/PrimModuleReserved/Prim.purs:1:1 - 1:18 (line 1, column 1 - line 1, column 18)
+
+ The module name [33mPrim[0m is in the Prim namespace.
+ The Prim namespace is reserved for compiler-defined terms.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDefinePrimModules.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PrimRow.out b/tests/purs/failing/PrimRow.out
new file mode 100644
index 0000000000..dab89b6ec1
--- /dev/null
+++ b/tests/purs/failing/PrimRow.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/PrimRow.purs:8:6 - 8:42 (line 8, column 6 - line 8, column 42)
+
+ Unknown type class [33mCons[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PrimSubModuleReserved.out b/tests/purs/failing/PrimSubModuleReserved.out
new file mode 100644
index 0000000000..75c385feea
--- /dev/null
+++ b/tests/purs/failing/PrimSubModuleReserved.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/PrimSubModuleReserved/Prim_Foobar.purs:1:1 - 1:25 (line 1, column 1 - line 1, column 25)
+
+ The module name [33mPrim.Foobar[0m is in the Prim namespace.
+ The Prim namespace is reserved for compiler-defined terms.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDefinePrimModules.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/PrimSubModuleReserved/Prim_Foobar.out b/tests/purs/failing/PrimSubModuleReserved/Prim_Foobar.out
new file mode 100644
index 0000000000..75c385feea
--- /dev/null
+++ b/tests/purs/failing/PrimSubModuleReserved/Prim_Foobar.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/PrimSubModuleReserved/Prim_Foobar.purs:1:1 - 1:25 (line 1, column 1 - line 1, column 25)
+
+ The module name [33mPrim.Foobar[0m is in the Prim namespace.
+ The Prim namespace is reserved for compiler-defined terms.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotDefinePrimModules.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.out b/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.out
new file mode 100644
index 0000000000..e938446ba6
--- /dev/null
+++ b/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.purs:23:7 - 23:17 (line 23, column 7 - line 23, column 17)
+
+ Custom error:
+
+ Don't want to show Just @Type String because.
+
+
+while checking that type [33mFail (Beside (Beside (Text "Don\'t want to show ") (... ...)) (Text " because.")) => String[0m
+ is at least as general as type [33mString[0m
+while checking that expression [33msomeString[0m
+ has type [33mString[0m
+in value declaration [33mmain[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.purs b/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.purs
new file mode 100644
index 0000000000..575251c093
--- /dev/null
+++ b/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.purs
@@ -0,0 +1,23 @@
+-- @shouldFailWith NoInstanceFound
+
+module Main where
+
+import Prelude
+import Prim.TypeError
+import Effect (Effect)
+import Effect.Console (log)
+
+data Maybe :: forall k. k -> Type
+data Maybe a
+
+foreign import data Nothing :: forall k. Maybe k
+foreign import data Just :: forall k. k -> Maybe k
+
+someString :: Fail (Text "Don't want to show " <> Quote (Just String) <> Text " because.") => String
+someString = "someString"
+
+infixl 6 type Beside as <>
+
+main :: Effect Unit
+main = do
+ log someString
diff --git a/tests/purs/failing/ProgrammableTypeErrors.out b/tests/purs/failing/ProgrammableTypeErrors.out
new file mode 100644
index 0000000000..3c48205c4c
--- /dev/null
+++ b/tests/purs/failing/ProgrammableTypeErrors.out
@@ -0,0 +1,28 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ProgrammableTypeErrors.purs:17:13 - 17:27 (line 17, column 13 - line 17, column 27)
+
+ Custom error:
+
+ Cannot show functions
+
+
+while solving type class constraint
+[33m [0m
+[33m Main.MyShow (Int -> Int)[0m
+[33m [0m
+while applying a function [33mmyShow[0m
+ of type [33mMyShow t0 => t0 -> String[0m
+ to argument [33m\$1 -> [0m
+ [33m (add $1) 1[0m
+while checking that expression [33mmyShow (\$1 -> [0m
+ [33m (add $1) 1[0m
+ [33m ) [0m
+ has type [33mString[0m
+in value declaration [33mmain[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ProgrammableTypeErrorsTypeString.out b/tests/purs/failing/ProgrammableTypeErrorsTypeString.out
new file mode 100644
index 0000000000..bb5045ce43
--- /dev/null
+++ b/tests/purs/failing/ProgrammableTypeErrorsTypeString.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ProgrammableTypeErrorsTypeString.purs:24:9 - 24:24 (line 24, column 9 - line 24, column 24)
+
+ Custom error:
+
+ Don't want to show MyType Int because.
+
+
+while solving type class constraint
+[33m [0m
+[33m Data.Show.Show (MyType Int)[0m
+[33m [0m
+while applying a function [33mshow[0m
+ of type [33mShow t0 => t0 -> String[0m
+ to argument [33mMyType 2[0m
+while checking that expression [33mshow (MyType 2)[0m
+ has type [33mString[0m
+in value declaration [33mmain[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/QualifiedOperators.out b/tests/purs/failing/QualifiedOperators.out
new file mode 100644
index 0000000000..25f703dbdc
--- /dev/null
+++ b/tests/purs/failing/QualifiedOperators.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/QualifiedOperators.purs:4:10 - 4:21 (line 4, column 10 - line 4, column 21)
+
+ Unknown module [33mFoo.Bar[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/QualifiedOperators.purs b/tests/purs/failing/QualifiedOperators.purs
new file mode 100644
index 0000000000..36d80e12f5
--- /dev/null
+++ b/tests/purs/failing/QualifiedOperators.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith UnknownName
+module Main where
+
+test = 4 Foo.Bar.-#- 10
diff --git a/tests/purs/failing/QualifiedOperators2.out b/tests/purs/failing/QualifiedOperators2.out
new file mode 100644
index 0000000000..5de5724b29
--- /dev/null
+++ b/tests/purs/failing/QualifiedOperators2.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/QualifiedOperators2.purs:4:8 - 4:21 (line 4, column 8 - line 4, column 21)
+
+ Unknown module [33mFoo.Bar[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/QualifiedOperators2.purs b/tests/purs/failing/QualifiedOperators2.purs
new file mode 100644
index 0000000000..62d908d7f5
--- /dev/null
+++ b/tests/purs/failing/QualifiedOperators2.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith UnknownName
+module Main where
+
+test = Foo.Bar.(-#-) 4 10
diff --git a/tests/purs/failing/QuantificationCheckFailure.out b/tests/purs/failing/QuantificationCheckFailure.out
new file mode 100644
index 0000000000..de7b5fcc30
--- /dev/null
+++ b/tests/purs/failing/QuantificationCheckFailure.out
@@ -0,0 +1,12 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/QuantificationCheckFailure.purs:13:48 - 13:69 (line 13, column 48 - line 13, column 69)
+
+ Cannot generalize the kind of type variable [33md[0m since it would not be well-scoped.
+ Try adding a kind annotation.
+
+in kind declaration for [33mT[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/QuantificationCheckFailureInKind.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/QuantificationCheckFailure.purs b/tests/purs/failing/QuantificationCheckFailure.purs
new file mode 100644
index 0000000000..4a600ff119
--- /dev/null
+++ b/tests/purs/failing/QuantificationCheckFailure.purs
@@ -0,0 +1,14 @@
+-- @shouldFailWith QuantificationCheckFailureInKind
+module Main where
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+data Relate :: forall a (b :: a). a -> Proxy b -> Type
+data Relate x y = Relate
+
+-- Inferring and generalizing the kind of `d` such that implicitly generalized
+-- variables appear first would result in a reference to `a` before `a` is
+-- declared. See "Kind Inference for Datatypes" Section 7.2
+data T :: forall (a :: Type) (b :: a) (c :: a) d. Relate b d -> Type
+data T a = T
diff --git a/tests/purs/failing/QuantificationCheckFailure2.out b/tests/purs/failing/QuantificationCheckFailure2.out
new file mode 100644
index 0000000000..09e3c6177a
--- /dev/null
+++ b/tests/purs/failing/QuantificationCheckFailure2.out
@@ -0,0 +1,16 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/QuantificationCheckFailure2.purs:6:13 - 6:30 (line 6, column 13 - line 6, column 30)
+
+ Cannot unambiguously generalize kinds appearing in the elaborated type:
+
+ [33mforall (a :: t8). Proxy @t8 a[0m
+
+ where [33mt8[0m is an unknown kind.
+ Try adding additional kind signatures or polymorphic kind variables.
+
+in type constructor [33mP[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/QuantificationCheckFailureInType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/QuantificationCheckFailure2.purs b/tests/purs/failing/QuantificationCheckFailure2.purs
new file mode 100644
index 0000000000..d38a9088ef
--- /dev/null
+++ b/tests/purs/failing/QuantificationCheckFailure2.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith QuantificationCheckFailureInType
+module Main where
+
+data Proxy a = Proxy
+
+data P = P (forall a. Proxy a)
diff --git a/tests/purs/failing/QuantificationCheckFailure3.out b/tests/purs/failing/QuantificationCheckFailure3.out
new file mode 100644
index 0000000000..a713fc6a2a
--- /dev/null
+++ b/tests/purs/failing/QuantificationCheckFailure3.out
@@ -0,0 +1,12 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/QuantificationCheckFailure3.purs:7:1 - 7:34 (line 7, column 1 - line 7, column 34)
+
+ Visible dependent quantification of type variable [33mk[0m is not supported.
+ If you would like this feature supported, please bother Liam Goodacre (@LiamGoodacre).
+
+in type synonym [33mHmm[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/VisibleQuantificationCheckFailureInType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/QuantificationCheckFailure3.purs b/tests/purs/failing/QuantificationCheckFailure3.purs
new file mode 100644
index 0000000000..c5fc58f743
--- /dev/null
+++ b/tests/purs/failing/QuantificationCheckFailure3.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith VisibleQuantificationCheckFailureInType
+module Main where
+
+foreign import data KProxy :: forall (k :: Type) . k -> Type
+foreign import data TProxy :: forall (k :: Type) (t :: k) . KProxy t
+
+type Hmm k = (TProxy :: KProxy k)
diff --git a/tests/purs/failing/QuantifiedKind.out b/tests/purs/failing/QuantifiedKind.out
new file mode 100644
index 0000000000..420c85ab12
--- /dev/null
+++ b/tests/purs/failing/QuantifiedKind.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/QuantifiedKind.purs:6:22 - 6:23 (line 6, column 22 - line 6, column 23)
+
+ Type variable [33mk[0m is undefined.
+
+while inferring the kind of [33mk[0m
+while checking that type [33mk[0m
+ has kind [33mType[0m
+while inferring the kind of [33mforall (a :: k) k. Proxy a[0m
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/UndefinedTypeVariable.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/QuantifiedKind.purs b/tests/purs/failing/QuantifiedKind.purs
new file mode 100644
index 0000000000..bd46b3621c
--- /dev/null
+++ b/tests/purs/failing/QuantifiedKind.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith UndefinedTypeVariable
+module Main where
+
+data Proxy a = Proxy
+
+test :: forall (a :: k) k. Proxy a
+test = Proxy
diff --git a/tests/purs/failing/Rank2Types.out b/tests/purs/failing/Rank2Types.out
new file mode 100644
index 0000000000..07ee13d5af
--- /dev/null
+++ b/tests/purs/failing/Rank2Types.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/Rank2Types.purs:8:25 - 8:26 (line 8, column 25 - line 8, column 26)
+
+ Could not match type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m a0[0m
+ [33m [0m
+
+while checking that type [33mInt[0m
+ is at least as general as type [33ma0[0m
+while checking that expression [33m1[0m
+ has type [33ma0[0m
+in value declaration [33mtest1[0m
+
+where [33ma0[0m is a rigid type variable
+ bound at (line 8, column 14 - line 8, column 27)
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RecordLabelOnTypeError.out b/tests/purs/failing/RecordLabelOnTypeError.out
new file mode 100644
index 0000000000..78088babe2
--- /dev/null
+++ b/tests/purs/failing/RecordLabelOnTypeError.out
@@ -0,0 +1,26 @@
+Error found:
+in module [33mRecordLabelOnTypeError[0m
+at tests/purs/failing/RecordLabelOnTypeError.purs:8:5 - 8:6 (line 8, column 5 - line 8, column 6)
+
+ Could not match type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+
+while matching label [33mfield[0m
+while checking that type [33m{ field :: Int[0m
+ [33m} [0m
+ is at least as general as type [33m{ field :: String[0m
+ [33m} [0m
+while checking that expression [33ma[0m
+ has type [33m{ field :: String[0m
+ [33m} [0m
+in value declaration [33mb[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RecordLabelOnTypeError.purs b/tests/purs/failing/RecordLabelOnTypeError.purs
new file mode 100644
index 0000000000..8c8fb5ce13
--- /dev/null
+++ b/tests/purs/failing/RecordLabelOnTypeError.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith TypesDoNotUnify
+module RecordLabelOnTypeError where
+
+a :: { field :: Int }
+a = { field: 1 }
+
+b :: { field :: String }
+b = a -- this should trigger an error, telling us the `field` tag where the type discrepancy happened
diff --git a/tests/purs/failing/RecordLabelOnTypeErrorImmediate.out b/tests/purs/failing/RecordLabelOnTypeErrorImmediate.out
new file mode 100644
index 0000000000..d846482602
--- /dev/null
+++ b/tests/purs/failing/RecordLabelOnTypeErrorImmediate.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mNestedRecordLabelOnTypeError[0m
+at tests/purs/failing/RecordLabelOnTypeErrorImmediate.purs:5:15 - 5:18 (line 5, column 15 - line 5, column 18)
+
+ Could not match type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+while checking that type [33mString[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33m"a"[0m
+ has type [33mInt[0m
+in value declaration [33mrecord[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RecordLabelOnTypeErrorImmediate.purs b/tests/purs/failing/RecordLabelOnTypeErrorImmediate.purs
new file mode 100644
index 0000000000..02333b244b
--- /dev/null
+++ b/tests/purs/failing/RecordLabelOnTypeErrorImmediate.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith TypesDoNotUnify
+module NestedRecordLabelOnTypeError where
+
+record :: { a :: Int }
+record = { a: "a" } -- Triggers an error, but the label is explicitly not added since it caused other errors to be worse. See https://github.com/purescript/purescript/pull/4411 for more information.
diff --git a/tests/purs/failing/RequiredHiddenType.out b/tests/purs/failing/RequiredHiddenType.out
new file mode 100644
index 0000000000..aa8d284345
--- /dev/null
+++ b/tests/purs/failing/RequiredHiddenType.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mFoo[0m
+at tests/purs/failing/RequiredHiddenType.purs:3:1 - 9:6 (line 3, column 1 - line 9, column 6)
+
+ An export for [33ma[0m requires the following to also be exported:
+
+ [33mA[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/Reserved.out b/tests/purs/failing/Reserved.out
new file mode 100644
index 0000000000..36fa33d773
--- /dev/null
+++ b/tests/purs/failing/Reserved.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/Reserved.purs:6:1 - 6:4 (line 6, column 1 - line 6, column 4)
+
+ Unable to parse module:
+ Unexpected token '(<)'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RoleDeclarationArityMismatch.out b/tests/purs/failing/RoleDeclarationArityMismatch.out
new file mode 100644
index 0000000000..17527a4706
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatch.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RoleDeclarationArityMismatch.purs:5:1 - 5:20 (line 5, column 1 - line 5, column 20)
+
+ The type [33mA[0m expects 0 arguments but its role declaration lists 1 role.
+
+in role declaration for [33mA[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleDeclarationArityMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RoleDeclarationArityMismatch.purs b/tests/purs/failing/RoleDeclarationArityMismatch.purs
new file mode 100644
index 0000000000..80c1f34ece
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatch.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith RoleDeclarationArityMismatch
+module Main where
+
+data A = A
+type role A nominal
diff --git a/tests/purs/failing/RoleDeclarationArityMismatchForeign.out b/tests/purs/failing/RoleDeclarationArityMismatchForeign.out
new file mode 100644
index 0000000000..81aa291b57
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatchForeign.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RoleDeclarationArityMismatchForeign.purs:5:1 - 5:20 (line 5, column 1 - line 5, column 20)
+
+ The type [33mA[0m expects 0 arguments but its role declaration lists 1 role.
+
+in role declaration for [33mA[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleDeclarationArityMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RoleDeclarationArityMismatchForeign.purs b/tests/purs/failing/RoleDeclarationArityMismatchForeign.purs
new file mode 100644
index 0000000000..5eb29f8665
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatchForeign.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith RoleDeclarationArityMismatch
+module Main where
+
+foreign import data A :: Type
+type role A nominal
diff --git a/tests/purs/failing/RoleDeclarationArityMismatchForeign2.out b/tests/purs/failing/RoleDeclarationArityMismatchForeign2.out
new file mode 100644
index 0000000000..ac07e8bea7
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatchForeign2.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RoleDeclarationArityMismatchForeign2.purs:5:1 - 5:20 (line 5, column 1 - line 5, column 20)
+
+ The type [33mA[0m expects 2 arguments but its role declaration lists only 1 role.
+
+in role declaration for [33mA[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleDeclarationArityMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RoleDeclarationArityMismatchForeign2.purs b/tests/purs/failing/RoleDeclarationArityMismatchForeign2.purs
new file mode 100644
index 0000000000..3e35171ccc
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatchForeign2.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith RoleDeclarationArityMismatch
+module Main where
+
+foreign import data A :: Type -> (Type -> Type)
+type role A nominal
diff --git a/tests/purs/failing/RoleDeclarationArityMismatchForeign3.out b/tests/purs/failing/RoleDeclarationArityMismatchForeign3.out
new file mode 100644
index 0000000000..0c02428e0e
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatchForeign3.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RoleDeclarationArityMismatchForeign3.purs:5:1 - 5:20 (line 5, column 1 - line 5, column 20)
+
+ The type [33mA[0m expects 2 arguments but its role declaration lists only 1 role.
+
+in role declaration for [33mA[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleDeclarationArityMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RoleDeclarationArityMismatchForeign3.purs b/tests/purs/failing/RoleDeclarationArityMismatchForeign3.purs
new file mode 100644
index 0000000000..1bcc9dc38c
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatchForeign3.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith RoleDeclarationArityMismatch
+module Main where
+
+foreign import data A :: (Type -> Type -> Type)
+type role A nominal
diff --git a/tests/purs/failing/RoleDeclarationArityMismatchForeign4.out b/tests/purs/failing/RoleDeclarationArityMismatchForeign4.out
new file mode 100644
index 0000000000..911863747a
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatchForeign4.out
@@ -0,0 +1,11 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RoleDeclarationArityMismatchForeign4.purs:7:1 - 7:20 (line 7, column 1 - line 7, column 20)
+
+ The type [33mA[0m expects 2 arguments but its role declaration lists only 1 role.
+
+in role declaration for [33mA[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/RoleDeclarationArityMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RoleDeclarationArityMismatchForeign4.purs b/tests/purs/failing/RoleDeclarationArityMismatchForeign4.purs
new file mode 100644
index 0000000000..9d600c13ab
--- /dev/null
+++ b/tests/purs/failing/RoleDeclarationArityMismatchForeign4.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith RoleDeclarationArityMismatch
+module Main where
+
+type To = Function
+
+foreign import data A :: To Type (To Type Type)
+type role A nominal
diff --git a/tests/purs/failing/RowConstructors1.out b/tests/purs/failing/RowConstructors1.out
new file mode 100644
index 0000000000..5558dec917
--- /dev/null
+++ b/tests/purs/failing/RowConstructors1.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RowConstructors1.purs:7:16 - 7:19 (line 7, column 16 - line 7, column 19)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Row Type[0m
+ [33m [0m
+
+while checking that type [33mFoo[0m
+ has kind [33mRow Type[0m
+while inferring the kind of [33mRecord Foo[0m
+in type synonym [33mBaz[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RowConstructors2.out b/tests/purs/failing/RowConstructors2.out
new file mode 100644
index 0000000000..05ddf97853
--- /dev/null
+++ b/tests/purs/failing/RowConstructors2.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RowConstructors2.purs:7:16 - 7:19 (line 7, column 16 - line 7, column 19)
+
+ Type synonym [33mMain.Foo[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mFoo[0m
+ has kind [33mRow Type[0m
+while inferring the kind of [33mRecord Foo[0m
+in type synonym [33mBar[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RowConstructors2.purs b/tests/purs/failing/RowConstructors2.purs
index aeec350276..778f92cd44 100644
--- a/tests/purs/failing/RowConstructors2.purs
+++ b/tests/purs/failing/RowConstructors2.purs
@@ -1,4 +1,4 @@
--- @shouldFailWith KindsDoNotUnify
+-- @shouldFailWith PartiallyAppliedSynonym
module Main where
import Effect.Console (log)
diff --git a/tests/purs/failing/RowConstructors3.out b/tests/purs/failing/RowConstructors3.out
new file mode 100644
index 0000000000..f359a21d4f
--- /dev/null
+++ b/tests/purs/failing/RowConstructors3.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RowConstructors3.purs:7:16 - 7:19 (line 7, column 16 - line 7, column 19)
+
+ Could not match kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Row Type[0m
+ [33m [0m
+
+while checking that type [33mFoo[0m
+ has kind [33mRow Type[0m
+while inferring the kind of [33mRecord Foo[0m
+in type synonym [33mBar[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RowInInstanceNotDetermined0.out b/tests/purs/failing/RowInInstanceNotDetermined0.out
new file mode 100644
index 0000000000..9a99061579
--- /dev/null
+++ b/tests/purs/failing/RowInInstanceNotDetermined0.out
@@ -0,0 +1,19 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RowInInstanceNotDetermined0.purs:8:1 - 8:24 (line 8, column 1 - line 8, column 24)
+
+ Type class instance head is invalid due to use of type
+ [33m [0m
+ [33m ()[0m
+ [33m [0m
+ All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form, unless the type is fully determined by other type class arguments via functional dependencies.
+
+in type class instance
+[33m [0m
+[33m Main.C Unit [0m
+[33m (Record ())[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidInstanceHead.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RowInInstanceNotDetermined1.out b/tests/purs/failing/RowInInstanceNotDetermined1.out
new file mode 100644
index 0000000000..96d6ae3512
--- /dev/null
+++ b/tests/purs/failing/RowInInstanceNotDetermined1.out
@@ -0,0 +1,20 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RowInInstanceNotDetermined1.purs:8:1 - 8:29 (line 8, column 1 - line 8, column 29)
+
+ Type class instance head is invalid due to use of type
+ [33m [0m
+ [33m ()[0m
+ [33m [0m
+ All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form, unless the type is fully determined by other type class arguments via functional dependencies.
+
+in type class instance
+[33m [0m
+[33m Main.C Unit [0m
+[33m Unit [0m
+[33m (Record ())[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidInstanceHead.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RowInInstanceNotDetermined2.out b/tests/purs/failing/RowInInstanceNotDetermined2.out
new file mode 100644
index 0000000000..bd54f1bb10
--- /dev/null
+++ b/tests/purs/failing/RowInInstanceNotDetermined2.out
@@ -0,0 +1,19 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RowInInstanceNotDetermined2.purs:8:1 - 8:24 (line 8, column 1 - line 8, column 24)
+
+ Type class instance head is invalid due to use of type
+ [33m [0m
+ [33m ()[0m
+ [33m [0m
+ All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form, unless the type is fully determined by other type class arguments via functional dependencies.
+
+in type class instance
+[33m [0m
+[33m Main.C Unit [0m
+[33m (Record ())[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidInstanceHead.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RowLacks.out b/tests/purs/failing/RowLacks.out
new file mode 100644
index 0000000000..bd424a618a
--- /dev/null
+++ b/tests/purs/failing/RowLacks.out
@@ -0,0 +1,28 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RowLacks.purs:16:9 - 16:66 (line 16, column 9 - line 16, column 66)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Prim.Row.Lacks "x" [0m
+ [33m ( x :: Int [0m
+ [33m , y :: Int [0m
+ [33m , z :: String[0m
+ [33m ) [0m
+ [33m [0m
+
+while applying a function [33mlacksX[0m
+ of type [33mLacks @t1 "x" t2 => Proxy @(Row t1) t2 -> Proxy @(Row t3) (() @t3)[0m
+ to argument [33mProxy[0m
+while checking that expression [33mlacksX Proxy[0m
+ has type [33mProxy @(Row t0) (() @t0)[0m
+in value declaration [33mtest1[0m
+
+where [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+ [33mt3[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RowLacks.purs b/tests/purs/failing/RowLacks.purs
index 7805872e63..c2e4b497de 100644
--- a/tests/purs/failing/RowLacks.purs
+++ b/tests/purs/failing/RowLacks.purs
@@ -3,16 +3,16 @@ module Main where
import Effect.Console (log)
import Prim.Row (class Lacks)
-import Type.Row (RProxy(..))
+import Type.Proxy (Proxy(..))
lacksX
:: forall r
. Lacks "x" r
- => RProxy r
- -> RProxy ()
-lacksX _ = RProxy
+ => Proxy r
+ -> Proxy ()
+lacksX _ = Proxy
-test1 :: RProxy ()
-test1 = lacksX (RProxy :: RProxy (x :: Int, y :: Int, z :: String))
+test1 :: Proxy ()
+test1 = lacksX (Proxy :: Proxy (x :: Int, y :: Int, z :: String))
main = log "Done"
diff --git a/tests/purs/failing/RowsInKinds.out b/tests/purs/failing/RowsInKinds.out
new file mode 100644
index 0000000000..a226e71125
--- /dev/null
+++ b/tests/purs/failing/RowsInKinds.out
@@ -0,0 +1,28 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/RowsInKinds.purs:14:16 - 14:17 (line 14, column 16 - line 14, column 17)
+
+ Could not match kind
+ [33m [0m
+ [33m ( z :: Type[0m
+ [33m | t25 [0m
+ [33m ) [0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m ( x :: Type[0m
+ [33m , y :: Type[0m
+ [33m ) [0m
+ [33m [0m
+
+while checking that type [33mZ[0m
+ has kind [33mR @Type [0m
+ [33m ( x :: Type[0m
+ [33m , y :: Type[0m
+ [33m ) [0m
+while inferring the kind of [33mP Z[0m
+in type synonym [33mTest3[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/RowsInKinds.purs b/tests/purs/failing/RowsInKinds.purs
new file mode 100644
index 0000000000..0853fa0487
--- /dev/null
+++ b/tests/purs/failing/RowsInKinds.purs
@@ -0,0 +1,15 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+foreign import data R :: forall k. Row k -> Type
+foreign import data X :: forall r. R (x :: Type | r)
+foreign import data Y :: forall r. R (y :: Type | r)
+foreign import data Z :: forall r. R (z :: Type | r)
+
+data P :: R (x :: Type, y :: Type) -> Type
+data P a = P
+
+type Test1 = P X
+type Test2 = P Y
+type Test3 = P Z
+
diff --git a/tests/purs/failing/ScopedKindVariableSynonym.out b/tests/purs/failing/ScopedKindVariableSynonym.out
new file mode 100644
index 0000000000..096a622818
--- /dev/null
+++ b/tests/purs/failing/ScopedKindVariableSynonym.out
@@ -0,0 +1,12 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/ScopedKindVariableSynonym.purs:7:14 - 7:15 (line 7, column 14 - line 7, column 15)
+
+ Type variable [33ma[0m is undefined.
+
+while inferring the kind of [33ma[0m
+in type synonym [33mB[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/UndefinedTypeVariable.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/ScopedKindVariableSynonym.purs b/tests/purs/failing/ScopedKindVariableSynonym.purs
new file mode 100644
index 0000000000..8eeefcf08f
--- /dev/null
+++ b/tests/purs/failing/ScopedKindVariableSynonym.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith UndefinedTypeVariable
+module Main where
+
+type A x = forall a. a -> x -> Type
+
+type B :: forall x. A x
+type B y z = a
diff --git a/tests/purs/failing/SelfCycleInForeignDataKinds.out b/tests/purs/failing/SelfCycleInForeignDataKinds.out
new file mode 100644
index 0000000000..7bcf09c5ef
--- /dev/null
+++ b/tests/purs/failing/SelfCycleInForeignDataKinds.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/SelfCycleInForeignDataKinds.purs:4:1 - 4:31 (line 4, column 1 - line 4, column 31)
+
+ A kind declaration '[33mFoo[0m' may not refer to itself in its own signature.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInKindDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/SelfCycleInForeignDataKinds.purs b/tests/purs/failing/SelfCycleInForeignDataKinds.purs
new file mode 100644
index 0000000000..170be42a81
--- /dev/null
+++ b/tests/purs/failing/SelfCycleInForeignDataKinds.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith CycleInKindDeclaration
+module Main where
+
+foreign import data Foo :: Foo
diff --git a/tests/purs/failing/SelfCycleInKindDeclaration.out b/tests/purs/failing/SelfCycleInKindDeclaration.out
new file mode 100644
index 0000000000..ee5a95b15c
--- /dev/null
+++ b/tests/purs/failing/SelfCycleInKindDeclaration.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/SelfCycleInKindDeclaration.purs:4:1 - 4:24 (line 4, column 1 - line 4, column 24)
+
+ A kind declaration '[33mFoo[0m' may not refer to itself in its own signature.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInKindDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/SelfCycleInKindDeclaration.purs b/tests/purs/failing/SelfCycleInKindDeclaration.purs
new file mode 100644
index 0000000000..39e20da613
--- /dev/null
+++ b/tests/purs/failing/SelfCycleInKindDeclaration.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith CycleInKindDeclaration
+module Main where
+
+data Foo :: Foo -> Type
+data Foo a = Foo
diff --git a/tests/purs/failing/SelfCycleInTypeClassDeclaration.out b/tests/purs/failing/SelfCycleInTypeClassDeclaration.out
new file mode 100644
index 0000000000..d8b91a5226
--- /dev/null
+++ b/tests/purs/failing/SelfCycleInTypeClassDeclaration.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/SelfCycleInTypeClassDeclaration.purs:4:1 - 4:23 (line 4, column 1 - line 4, column 23)
+
+ A type class '[33mFoo[0m' may not have itself as a superclass.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInTypeClassDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/SelfCycleInTypeClassDeclaration.purs b/tests/purs/failing/SelfCycleInTypeClassDeclaration.purs
new file mode 100644
index 0000000000..98153bb5f9
--- /dev/null
+++ b/tests/purs/failing/SelfCycleInTypeClassDeclaration.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith CycleInTypeClassDeclaration
+module Main where
+
+class (Foo a) <= Foo a
diff --git a/tests/purs/failing/SelfImport.out b/tests/purs/failing/SelfImport.out
new file mode 100644
index 0000000000..333f985641
--- /dev/null
+++ b/tests/purs/failing/SelfImport.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/SelfImport.purs:3:1 - 9:12 (line 3, column 1 - line 9, column 12)
+
+ Module [33mMain[0m imports itself.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInModules.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/SelfImport/Dummy.out b/tests/purs/failing/SelfImport/Dummy.out
new file mode 100644
index 0000000000..333f985641
--- /dev/null
+++ b/tests/purs/failing/SelfImport/Dummy.out
@@ -0,0 +1,9 @@
+Error found:
+at tests/purs/failing/SelfImport.purs:3:1 - 9:12 (line 3, column 1 - line 9, column 12)
+
+ Module [33mMain[0m imports itself.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInModules.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/SkolemEscape.out b/tests/purs/failing/SkolemEscape.out
new file mode 100644
index 0000000000..8217eff0aa
--- /dev/null
+++ b/tests/purs/failing/SkolemEscape.out
@@ -0,0 +1,20 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/SkolemEscape.purs:8:1 - 8:19 (line 8, column 1 - line 8, column 19)
+
+ The type variable [33ma[0m, bound at
+
+ tests/purs/failing/SkolemEscape.purs:8:18 - 8:19 (line 8, column 18 - line 8, column 19)
+
+ has escaped its scope, appearing in the type
+ [33m [0m
+ [33m (a0 -> a0) -> Number[0m
+ [33m [0m
+
+in the expression [33m[33m\x -> [0m[0m
+ [33m[33m foo x[0m[0m
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/EscapedSkolem.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/SkolemEscape2.out b/tests/purs/failing/SkolemEscape2.out
new file mode 100644
index 0000000000..98f7d3ad24
--- /dev/null
+++ b/tests/purs/failing/SkolemEscape2.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/SkolemEscape2.purs:9:1 - 11:9 (line 9, column 1 - line 11, column 9)
+
+ The type variable [33mr[0m, bound at
+
+ tests/purs/failing/SkolemEscape2.purs:10:21 - 10:34 (line 10, column 21 - line 10, column 34)
+
+ has escaped its scope, appearing in the type
+ [33m [0m
+ [33m t1 -> t2 (STRef r0 Int)[0m
+ [33m [0m
+
+in the expression [33m[33m\$0 -> [0m[0m
+ [33m[33m ((bind $dictBind1) ((...) (...))) (\r -> [0m[0m
+ [33m[33m (...) r[0m[0m
+ [33m[33m ) [0m[0m
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/EscapedSkolem.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/SkolemEscapeKinds.out b/tests/purs/failing/SkolemEscapeKinds.out
new file mode 100644
index 0000000000..a1732cc381
--- /dev/null
+++ b/tests/purs/failing/SkolemEscapeKinds.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/SkolemEscapeKinds.purs:8:10 - 8:17 (line 8, column 10 - line 8, column 17)
+
+ The type variable [33mk[0m, bound at
+
+ tests/purs/failing/SkolemEscapeKinds.purs:8:16 - 8:17 (line 8, column 16 - line 8, column 17)
+
+ has escaped its scope, appearing in the type
+ [33m [0m
+ [33m Proxy[0m
+ [33m [0m
+
+in type synonym [33mB[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/EscapedSkolem.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/SkolemEscapeKinds.purs b/tests/purs/failing/SkolemEscapeKinds.purs
new file mode 100644
index 0000000000..3b838657dd
--- /dev/null
+++ b/tests/purs/failing/SkolemEscapeKinds.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith EscapedSkolem
+module Main where
+
+data Proxy a = Proxy
+
+data A (a :: forall k. k -> Type) = A
+
+type B = Proxy A
diff --git a/tests/purs/failing/StandaloneKindSignatures1.out b/tests/purs/failing/StandaloneKindSignatures1.out
new file mode 100644
index 0000000000..ea8a49861e
--- /dev/null
+++ b/tests/purs/failing/StandaloneKindSignatures1.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/StandaloneKindSignatures1.purs:7:25 - 7:30 (line 7, column 25 - line 7, column 30)
+
+ Could not match kind
+ [33m [0m
+ [33m Symbol[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33m"foo"[0m
+ has kind [33mType[0m
+while inferring the kind of [33mPair Int "foo"[0m
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/StandaloneKindSignatures1.purs b/tests/purs/failing/StandaloneKindSignatures1.purs
new file mode 100644
index 0000000000..55689cd929
--- /dev/null
+++ b/tests/purs/failing/StandaloneKindSignatures1.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+data Pair :: forall k. k -> k -> Type
+data Pair a b = Pair
+
+test = Pair :: Pair Int "foo"
diff --git a/tests/purs/failing/StandaloneKindSignatures2.out b/tests/purs/failing/StandaloneKindSignatures2.out
new file mode 100644
index 0000000000..0835b79c5b
--- /dev/null
+++ b/tests/purs/failing/StandaloneKindSignatures2.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/StandaloneKindSignatures2.purs:8:35 - 8:36 (line 8, column 35 - line 8, column 36)
+
+ Could not match kind
+ [33m [0m
+ [33m k2[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m k1[0m
+ [33m [0m
+
+while checking that type [33mb[0m
+ has kind [33mk1[0m
+while inferring the kind of [33mPair a b[0m
+in type constructor [33mPair'[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/StandaloneKindSignatures2.purs b/tests/purs/failing/StandaloneKindSignatures2.purs
new file mode 100644
index 0000000000..26ae48bd6c
--- /dev/null
+++ b/tests/purs/failing/StandaloneKindSignatures2.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+data Pair :: forall k. k -> k -> Type
+data Pair a b = Pair
+
+newtype Pair' :: forall k1 k2. k1 -> k2 -> Type
+newtype Pair' a b = Pair' (Pair a b)
diff --git a/tests/purs/failing/StandaloneKindSignatures3.out b/tests/purs/failing/StandaloneKindSignatures3.out
new file mode 100644
index 0000000000..db86c16e24
--- /dev/null
+++ b/tests/purs/failing/StandaloneKindSignatures3.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/StandaloneKindSignatures3.purs:7:18 - 7:23 (line 7, column 18 - line 7, column 23)
+
+ Could not match kind
+ [33m [0m
+ [33m Symbol[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33m"foo"[0m
+ has kind [33mType[0m
+while inferring the kind of [33mFst Int "foo"[0m
+in type synonym [33mF[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/StandaloneKindSignatures3.purs b/tests/purs/failing/StandaloneKindSignatures3.purs
new file mode 100644
index 0000000000..c3f2f3ea9d
--- /dev/null
+++ b/tests/purs/failing/StandaloneKindSignatures3.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+type Fst :: forall k. k -> k -> k
+type Fst a b = a
+
+type F = Fst Int "foo"
diff --git a/tests/purs/failing/StandaloneKindSignatures4.out b/tests/purs/failing/StandaloneKindSignatures4.out
new file mode 100644
index 0000000000..a1fa795428
--- /dev/null
+++ b/tests/purs/failing/StandaloneKindSignatures4.out
@@ -0,0 +1,25 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/StandaloneKindSignatures4.purs:7:24 - 7:29 (line 7, column 24 - line 7, column 29)
+
+ Could not match kind
+ [33m [0m
+ [33m Symbol[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33m"foo"[0m
+ has kind [33mType[0m
+while inferring the kind of [33mTo Int "foo"[0m
+in type class instance
+[33m [0m
+[33m Main.To Int [0m
+[33m "foo"[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/StandaloneKindSignatures4.purs b/tests/purs/failing/StandaloneKindSignatures4.purs
new file mode 100644
index 0000000000..4ae1bb8e88
--- /dev/null
+++ b/tests/purs/failing/StandaloneKindSignatures4.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+class To :: forall k. k -> k -> Constraint
+class To a b | a -> b
+
+instance to1 :: To Int "foo"
diff --git a/tests/purs/failing/SuggestComposition.out b/tests/purs/failing/SuggestComposition.out
new file mode 100644
index 0000000000..a588608250
--- /dev/null
+++ b/tests/purs/failing/SuggestComposition.out
@@ -0,0 +1,32 @@
+Error found:
+in module [33mSuggestComposition[0m
+at tests/purs/failing/SuggestComposition.purs:7:5 - 7:6 (line 7, column 5 - line 7, column 6)
+
+ Could not match type
+ [33m [0m
+ [33m Record[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Function Int[0m
+ [33m [0m
+
+while trying to match type [33m{ g :: t0[0m
+ [33m| t1 [0m
+ [33m} [0m
+ with type [33mt2 -> t3[0m
+while checking that expression [33mg[0m
+ has type [33m{ g :: t0[0m
+ [33m| t1 [0m
+ [33m} [0m
+while checking type of property accessor [33mg.g[0m
+in value declaration [33mf[0m
+
+where [33mt2[0m is an unknown type
+ [33mt3[0m is an unknown type
+ [33mt0[0m is an unknown type
+ [33mt1[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/Superclasses1.out b/tests/purs/failing/Superclasses1.out
new file mode 100644
index 0000000000..ed16d56c71
--- /dev/null
+++ b/tests/purs/failing/Superclasses1.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/Superclasses1.purs:12:1 - 13:17 (line 12, column 1 - line 13, column 17)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.Su Number[0m
+ [33m [0m
+
+while checking that expression [33m#dict Su[0m
+ has type [33mSu$Dict t0[0m
+in value declaration [33mclNumber[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/Superclasses2.out b/tests/purs/failing/Superclasses2.out
new file mode 100644
index 0000000000..e5b35b5221
--- /dev/null
+++ b/tests/purs/failing/Superclasses2.out
@@ -0,0 +1,13 @@
+Error found:
+at tests/purs/failing/Superclasses2.purs:6:1 - 6:23 (line 6, column 1 - line 6, column 23)
+
+ A cycle appears in a set of type class definitions:
+
+ {[33mBar[0m, [33mFoo[0m}
+
+ Cycles are disallowed because they can lead to loops in the type checker.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInTypeClassDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/Superclasses3.out b/tests/purs/failing/Superclasses3.out
new file mode 100644
index 0000000000..45a682d7a4
--- /dev/null
+++ b/tests/purs/failing/Superclasses3.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mUnknownSuperclassTypeVar[0m
+at tests/purs/failing/Superclasses3.purs:8:12 - 8:13 (line 8, column 12 - line 8, column 13)
+
+ Type variable [33mb[0m is undefined.
+
+while inferring the kind of [33mb[0m
+while checking that type [33mb[0m
+ has kind [33mt0[0m
+while inferring the kind of [33mFoo$Dict b[0m
+while inferring the kind of [33mRecord () -> Foo$Dict b[0m
+while inferring the kind of [33m( "Foo0" :: Record () -> Foo$Dict b[0m
+ [33m) [0m
+while inferring the kind of [33m{ "Foo0" :: Record () -> Foo$Dict b[0m
+ [33m} [0m
+in type constructor [33mBar$Dict[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/UndefinedTypeVariable.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/Superclasses5.out b/tests/purs/failing/Superclasses5.out
new file mode 100644
index 0000000000..9514bdf756
--- /dev/null
+++ b/tests/purs/failing/Superclasses5.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/Superclasses5.purs:17:1 - 18:18 (line 17, column 1 - line 18, column 18)
+
+ A case expression could not be determined to cover all inputs.
+ The following additional cases are required to cover all inputs:
+
+ [33m_[0m
+
+ Alternatively, add a Partial constraint to the type of the enclosing value.
+
+while checking that expression [33mcase $0 of [0m
+ [33m [ x ] -> [ su x[0m
+ [33m ] [0m
+ has type [33mt0[0m
+in value declaration [33msuArray[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TooFewClassInstanceArgs.out b/tests/purs/failing/TooFewClassInstanceArgs.out
new file mode 100644
index 0000000000..459c13ccaa
--- /dev/null
+++ b/tests/purs/failing/TooFewClassInstanceArgs.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TooFewClassInstanceArgs.purs:8:1 - 8:33 (line 8, column 1 - line 8, column 33)
+
+ The type class [33mMain.Foo[0m expects 2 arguments.
+ But the instance [33mfooString[0m only provided 1.
+
+in type class instance
+[33m [0m
+[33m Main.Foo String[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ClassInstanceArityMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TooFewUnnamedClassInstanceArgs.out b/tests/purs/failing/TooFewUnnamedClassInstanceArgs.out
new file mode 100644
index 0000000000..589715e368
--- /dev/null
+++ b/tests/purs/failing/TooFewUnnamedClassInstanceArgs.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TooFewUnnamedClassInstanceArgs.purs:8:1 - 8:20 (line 8, column 1 - line 8, column 20)
+
+ The type class [33mMain.Foo[0m expects 2 arguments.
+ But the instance only provided 1.
+
+in type class instance
+[33m [0m
+[33m Main.Foo String[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ClassInstanceArityMismatch.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TooFewUnnamedClassInstanceArgs.purs b/tests/purs/failing/TooFewUnnamedClassInstanceArgs.purs
new file mode 100644
index 0000000000..140b60b4a2
--- /dev/null
+++ b/tests/purs/failing/TooFewUnnamedClassInstanceArgs.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith ClassInstanceArityMismatch
+module Main where
+
+import Prelude
+
+class Foo a b
+
+instance Foo String
diff --git a/tests/purs/failing/TopLevelCaseNoArgs.out b/tests/purs/failing/TopLevelCaseNoArgs.out
new file mode 100644
index 0000000000..d4d17e9b8f
--- /dev/null
+++ b/tests/purs/failing/TopLevelCaseNoArgs.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TopLevelCaseNoArgs.purs:7:1 - 7:8 (line 7, column 1 - line 7, column 8)
+
+ Multiple value declarations exist for [33mfoo[0m.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DuplicateValueDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TransitiveDctorExport.out b/tests/purs/failing/TransitiveDctorExport.out
new file mode 100644
index 0000000000..5fb3502987
--- /dev/null
+++ b/tests/purs/failing/TransitiveDctorExport.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TransitiveDctorExport.purs:2:1 - 5:13 (line 2, column 1 - line 5, column 13)
+
+ An export for [33mY[0m requires the following to also be exported:
+
+ [33mX[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TransitiveDctorExportError.out b/tests/purs/failing/TransitiveDctorExportError.out
new file mode 100644
index 0000000000..e1748b9289
--- /dev/null
+++ b/tests/purs/failing/TransitiveDctorExportError.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TransitiveDctorExportError.purs:2:1 - 4:15 (line 2, column 1 - line 4, column 15)
+
+ An export for [33mT[0m requires the following data constructor to also be exported:
+
+ [33mB[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveDctorExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TransitiveDctorExportError.purs b/tests/purs/failing/TransitiveDctorExportError.purs
new file mode 100644
index 0000000000..21d5f4624b
--- /dev/null
+++ b/tests/purs/failing/TransitiveDctorExportError.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith TransitiveDctorExportError
+module Main (T(A)) where
+
+data T = A | B
diff --git a/tests/purs/failing/TransitiveKindExport.out b/tests/purs/failing/TransitiveKindExport.out
new file mode 100644
index 0000000000..620e552b12
--- /dev/null
+++ b/tests/purs/failing/TransitiveKindExport.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TransitiveKindExport.purs:2:1 - 6:39 (line 2, column 1 - line 6, column 39)
+
+ An export for [33mTestProxy[0m requires the following to also be exported:
+
+ [33mTest[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TransitiveKindExport.purs b/tests/purs/failing/TransitiveKindExport.purs
index 7aba655967..f1d0c47a86 100644
--- a/tests/purs/failing/TransitiveKindExport.purs
+++ b/tests/purs/failing/TransitiveKindExport.purs
@@ -1,6 +1,6 @@
-- @shouldFailWith TransitiveExportError
module Main (TestProxy(..)) where
-foreign import kind Test
+data Test
data TestProxy (p :: Test) = TestProxy
diff --git a/tests/purs/failing/TransitiveSynonymExport.out b/tests/purs/failing/TransitiveSynonymExport.out
new file mode 100644
index 0000000000..4275828e31
--- /dev/null
+++ b/tests/purs/failing/TransitiveSynonymExport.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TransitiveSynonymExport.purs:2:1 - 5:11 (line 2, column 1 - line 5, column 11)
+
+ An export for [33mY[0m requires the following to also be exported:
+
+ [33mX[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeClasses2.out b/tests/purs/failing/TypeClasses2.out
new file mode 100644
index 0000000000..799aff9e9d
--- /dev/null
+++ b/tests/purs/failing/TypeClasses2.out
@@ -0,0 +1,20 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypeClasses2.purs:7:8 - 7:22 (line 7, column 8 - line 7, column 22)
+
+ No type class instance was found for
+ [33m [0m
+ [33m Main.Show String[0m
+ [33m [0m
+
+while applying a function [33mshow[0m
+ of type [33mShow t0 => t0 -> String[0m
+ to argument [33m"testing"[0m
+while inferring the type of [33mshow "testing"[0m
+in value declaration [33mtest[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeError.out b/tests/purs/failing/TypeError.out
new file mode 100644
index 0000000000..0cc707d1bd
--- /dev/null
+++ b/tests/purs/failing/TypeError.out
@@ -0,0 +1,22 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypeError.purs:6:13 - 6:16 (line 6, column 13 - line 6, column 16)
+
+ Could not match type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+while checking that type [33mString[0m
+ is at least as general as type [33mInt[0m
+while checking that expression [33m"A"[0m
+ has type [33mInt[0m
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeOperatorAliasNoExport.out b/tests/purs/failing/TypeOperatorAliasNoExport.out
new file mode 100644
index 0000000000..b339e348fb
--- /dev/null
+++ b/tests/purs/failing/TypeOperatorAliasNoExport.out
@@ -0,0 +1,13 @@
+Error found:
+in module [33mTest[0m
+at tests/purs/failing/TypeOperatorAliasNoExport.purs:2:1 - 6:25 (line 2, column 1 - line 6, column 25)
+
+ An export for [33mtype (×)[0m requires the following to also be exported:
+
+ [33mTuple[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/TransitiveExportError.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonymCycle.out b/tests/purs/failing/TypeSynonymCycle.out
new file mode 100644
index 0000000000..4deaff3f40
--- /dev/null
+++ b/tests/purs/failing/TypeSynonymCycle.out
@@ -0,0 +1,14 @@
+Error found:
+at tests/purs/failing/TypeSynonymCycle.purs:4:1 - 4:11 (line 4, column 1 - line 4, column 11)
+
+ A cycle appears in a set of type synonym definitions:
+
+ {[33mA[0m, [33mB[0m}
+
+ Cycles are disallowed because they can lead to loops in the type checker.
+ Consider using a 'newtype' instead.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInTypeSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonymCycle.purs b/tests/purs/failing/TypeSynonymCycle.purs
new file mode 100644
index 0000000000..ca2a131ec1
--- /dev/null
+++ b/tests/purs/failing/TypeSynonymCycle.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith CycleInTypeSynonym
+module Main where
+
+type A = B
+type B = { a :: A, b :: Loop }
+data Loop = Loop B
diff --git a/tests/purs/failing/TypeSynonyms.out b/tests/purs/failing/TypeSynonyms.out
new file mode 100644
index 0000000000..6ad26b001e
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms.out
@@ -0,0 +1,14 @@
+Error found:
+at tests/purs/failing/TypeSynonyms.purs:6:1 - 6:19 (line 6, column 1 - line 6, column 19)
+
+ A cycle appears in a set of type synonym definitions:
+
+ {[33mT1[0m, [33mT2[0m}
+
+ Cycles are disallowed because they can lead to loops in the type checker.
+ Consider using a 'newtype' instead.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInTypeSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonyms10.out b/tests/purs/failing/TypeSynonyms10.out
new file mode 100644
index 0000000000..8a9e2ecaf3
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms10.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypeSynonyms10.purs:8:19 - 8:23 (line 8, column 19 - line 8, column 23)
+
+ Could not match kind
+ [33m [0m
+ [33m (Type -> Type) -> Type[0m
+ [33m [0m
+ with kind
+ [33m [0m
+ [33m Type[0m
+ [33m [0m
+
+while checking that type [33mNaturalTransformation Array[0m
+ has kind [33mType[0m
+while inferring the kind of [33mF (NaturalTransformation Array)[0m
+in type constructor [33mN[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/KindsDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonyms10.purs b/tests/purs/failing/TypeSynonyms10.purs
new file mode 100644
index 0000000000..85c490b0c7
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms10.purs
@@ -0,0 +1,8 @@
+-- @shouldFailWith KindsDoNotUnify
+module Main where
+
+import Prelude
+
+type F (a :: Type) = a
+
+newtype N = N (F ((~>) Array))
diff --git a/tests/purs/failing/TypeSynonyms2.purs b/tests/purs/failing/TypeSynonyms2.purs
deleted file mode 100644
index e129df2a9a..0000000000
--- a/tests/purs/failing/TypeSynonyms2.purs
+++ /dev/null
@@ -1,12 +0,0 @@
--- @shouldFailWith TypeSynonymInstance
-module Main where
-
-import Prelude
-
-class Foo a where
- foo :: a -> String
-
-type Bar = String
-
-instance fooBar :: Foo Bar where
- foo s = s
diff --git a/tests/purs/failing/TypeSynonyms3.purs b/tests/purs/failing/TypeSynonyms3.purs
deleted file mode 100644
index e129df2a9a..0000000000
--- a/tests/purs/failing/TypeSynonyms3.purs
+++ /dev/null
@@ -1,12 +0,0 @@
--- @shouldFailWith TypeSynonymInstance
-module Main where
-
-import Prelude
-
-class Foo a where
- foo :: a -> String
-
-type Bar = String
-
-instance fooBar :: Foo Bar where
- foo s = s
diff --git a/tests/purs/failing/TypeSynonyms4.out b/tests/purs/failing/TypeSynonyms4.out
new file mode 100644
index 0000000000..6ff9926c75
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms4.out
@@ -0,0 +1,12 @@
+Error found:
+in module [33mTypeSynonyms4[0m
+at tests/purs/failing/TypeSynonyms4.purs:8:12 - 8:15 (line 8, column 12 - line 8, column 15)
+
+ Type synonym [33mTypeSynonyms4.F[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+in type synonym [33mG[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonyms5.out b/tests/purs/failing/TypeSynonyms5.out
new file mode 100644
index 0000000000..4c8b93fcfc
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms5.out
@@ -0,0 +1,11 @@
+Error found:
+at tests/purs/failing/TypeSynonyms5.purs:6:1 - 6:11 (line 6, column 1 - line 6, column 11)
+
+ A cycle appears in the definition of type synonym [33mT[0m
+ Cycles are disallowed because they can lead to loops in the type checker.
+ Consider using a 'newtype' instead.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/CycleInTypeSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonyms7.out b/tests/purs/failing/TypeSynonyms7.out
new file mode 100644
index 0000000000..f944d13844
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms7.out
@@ -0,0 +1,20 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypeSynonyms7.purs:8:1 - 9:14 (line 8, column 1 - line 9, column 14)
+
+ Type class instance head is invalid due to use of type
+ [33m [0m
+ [33m ( x :: Int[0m
+ [33m | r [0m
+ [33m ) [0m
+ [33m [0m
+ All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form, unless the type is fully determined by other type class arguments via functional dependencies.
+
+in type class instance
+[33m [0m
+[33m Data.Show.Show (X r)[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidInstanceHead.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonyms7.purs b/tests/purs/failing/TypeSynonyms7.purs
new file mode 100644
index 0000000000..11855aef3b
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms7.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith InvalidInstanceHead
+module Main where
+
+import Prelude
+
+type X r = {x :: Int | r}
+
+instance showX :: Show (X r) where
+ show _ = ""
diff --git a/tests/purs/failing/TypeSynonyms8.out b/tests/purs/failing/TypeSynonyms8.out
new file mode 100644
index 0000000000..7e07f48615
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms8.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypeSynonyms8.purs:6:15 - 6:16 (line 6, column 15 - line 6, column 16)
+
+ Type synonym [33mMain.S[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mS[0m
+ has kind [33mType[0m
+in type constructor [33mN[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonyms8.purs b/tests/purs/failing/TypeSynonyms8.purs
new file mode 100644
index 0000000000..3690ea973f
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms8.purs
@@ -0,0 +1,6 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+data D a
+type S a = D a
+newtype N = N S
diff --git a/tests/purs/failing/TypeSynonyms9.out b/tests/purs/failing/TypeSynonyms9.out
new file mode 100644
index 0000000000..cba09b84b3
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms9.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypeSynonyms9.purs:7:19 - 7:29 (line 7, column 19 - line 7, column 29)
+
+ Type synonym [33mData.NaturalTransformation.NaturalTransformation[0m is partially applied.
+ Type synonyms must be applied to all of their type arguments.
+
+while checking that type [33mNaturalTransformation Array[0m
+ has kind [33m(Type -> Type) -> Type -> Type[0m
+while inferring the kind of [33mA (NaturalTransformation Array)[0m
+in type constructor [33mB[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/PartiallyAppliedSynonym.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonyms9.purs b/tests/purs/failing/TypeSynonyms9.purs
new file mode 100644
index 0000000000..e80ce7871e
--- /dev/null
+++ b/tests/purs/failing/TypeSynonyms9.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith PartiallyAppliedSynonym
+module Main where
+
+import Prelude
+
+newtype A (a :: (Type -> Type) -> Type -> Type) = A String
+newtype B = B (A ((~>) Array))
diff --git a/tests/purs/failing/TypeSynonymsOverlappingInstance.out b/tests/purs/failing/TypeSynonymsOverlappingInstance.out
new file mode 100644
index 0000000000..7365f496a1
--- /dev/null
+++ b/tests/purs/failing/TypeSynonymsOverlappingInstance.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypeSynonymsOverlappingInstance.purs:14:1 - 15:16 (line 14, column 1 - line 15, column 16)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m Main.Convert String[0m
+ [33m String[0m
+ [33m [0m
+ The following instances were found:
+
+ [33mMain.convertSB[0m
+ [33mMain.convertSS[0m
+
+
+in type class instance
+[33m [0m
+[33m Main.Convert String[0m
+[33m String[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonymsOverlappingInstance.purs b/tests/purs/failing/TypeSynonymsOverlappingInstance.purs
new file mode 100644
index 0000000000..9a31b7324f
--- /dev/null
+++ b/tests/purs/failing/TypeSynonymsOverlappingInstance.purs
@@ -0,0 +1,15 @@
+-- @shouldFailWith OverlappingInstances
+module Main where
+
+import Prelude
+
+class Convert a b | a -> b where
+ convert :: a -> b
+
+type Bar = String
+
+instance convertSB :: Convert String Bar where
+ convert s = s
+
+instance convertSS :: Convert String String where
+ convert s = s
diff --git a/tests/purs/failing/TypeSynonymsOverlappingUnnamedInstance.out b/tests/purs/failing/TypeSynonymsOverlappingUnnamedInstance.out
new file mode 100644
index 0000000000..d510bad034
--- /dev/null
+++ b/tests/purs/failing/TypeSynonymsOverlappingUnnamedInstance.out
@@ -0,0 +1,24 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypeSynonymsOverlappingUnnamedInstance.purs:14:1 - 15:16 (line 14, column 1 - line 15, column 16)
+
+ Overlapping type class instances found for
+ [33m [0m
+ [33m Main.Convert String[0m
+ [33m String[0m
+ [33m [0m
+ The following instances were found:
+
+ instance in module [33mMain[0m with type [33mConvert String String[0m (line 11, column 1 - line 12, column 16)
+ instance in module [33mMain[0m with type [33mConvert String String[0m (line 14, column 1 - line 15, column 16)
+
+
+in type class instance
+[33m [0m
+[33m Main.Convert String[0m
+[33m String[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeSynonymsOverlappingUnnamedInstance.purs b/tests/purs/failing/TypeSynonymsOverlappingUnnamedInstance.purs
new file mode 100644
index 0000000000..856edbc86f
--- /dev/null
+++ b/tests/purs/failing/TypeSynonymsOverlappingUnnamedInstance.purs
@@ -0,0 +1,15 @@
+-- @shouldFailWith OverlappingInstances
+module Main where
+
+import Prelude
+
+class Convert a b | a -> b where
+ convert :: a -> b
+
+type Bar = String
+
+instance Convert String Bar where
+ convert s = s
+
+instance Convert String String where
+ convert s = s
diff --git a/tests/purs/failing/TypeWildcards1.out b/tests/purs/failing/TypeWildcards1.out
new file mode 100644
index 0000000000..89282731f6
--- /dev/null
+++ b/tests/purs/failing/TypeWildcards1.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/TypeWildcards1.purs:6:13 - 6:14 (line 6, column 13 - line 6, column 14)
+
+ Unable to parse module:
+ Unexpected wildcard in type; type wildcards are only allowed in value annotations
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeWildcards2.out b/tests/purs/failing/TypeWildcards2.out
new file mode 100644
index 0000000000..2c97acab5a
--- /dev/null
+++ b/tests/purs/failing/TypeWildcards2.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/TypeWildcards2.purs:6:18 - 6:19 (line 6, column 18 - line 6, column 19)
+
+ Unable to parse module:
+ Unexpected wildcard in type; type wildcards are only allowed in value annotations
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeWildcards3.out b/tests/purs/failing/TypeWildcards3.out
new file mode 100644
index 0000000000..989e062934
--- /dev/null
+++ b/tests/purs/failing/TypeWildcards3.out
@@ -0,0 +1,18 @@
+Error found:
+in module [33mTypeWildcards[0m
+at tests/purs/failing/TypeWildcards3.purs:8:1 - 9:19 (line 8, column 1 - line 9, column 19)
+
+ Type class instance head is invalid due to use of type
+ [33m [0m
+ [33m _[0m
+ [33m [0m
+ All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form, unless the type is fully determined by other type class arguments via functional dependencies.
+
+in type class instance
+[33m [0m
+[33m Data.Show.Show (Foo _)[0m
+[33m [0m
+
+See https://github.com/purescript/documentation/blob/master/errors/InvalidInstanceHead.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeWildcards4.out b/tests/purs/failing/TypeWildcards4.out
new file mode 100644
index 0000000000..7aa287990f
--- /dev/null
+++ b/tests/purs/failing/TypeWildcards4.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/TypeWildcards4.purs:4:23 - 4:24 (line 4, column 23 - line 4, column 24)
+
+ Unable to parse module:
+ Unexpected wildcard in type; type wildcards are only allowed in value annotations
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypeWildcards4.purs b/tests/purs/failing/TypeWildcards4.purs
new file mode 100644
index 0000000000..674c2f3f0c
--- /dev/null
+++ b/tests/purs/failing/TypeWildcards4.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith ErrorParsingModule
+module Main where
+
+type OhNo = ((Int) :: _)
diff --git a/tests/purs/failing/TypedBinders.out b/tests/purs/failing/TypedBinders.out
new file mode 100644
index 0000000000..e8832ec5e7
--- /dev/null
+++ b/tests/purs/failing/TypedBinders.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/TypedBinders.purs:6:12 - 6:14 (line 6, column 12 - line 6, column 14)
+
+ Unable to parse module:
+ Unexpected token '::'
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypedBinders2.out b/tests/purs/failing/TypedBinders2.out
new file mode 100644
index 0000000000..ca46c046b8
--- /dev/null
+++ b/tests/purs/failing/TypedBinders2.out
@@ -0,0 +1,30 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypedBinders2.purs:8:3 - 8:14 (line 8, column 3 - line 8, column 14)
+
+ Could not match type
+ [33m [0m
+ [33m Unit[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+
+while checking that expression [33mcase $0 of [0m
+ [33m s -> log "Done"[0m
+ has type [33mEffect t2[0m
+while applying a function [33m(bind (#dict Bind t1)) (log "Foo")[0m
+ of type [33m(t0 -> t1 t2) -> t1 t2[0m
+ to argument [33m\$0 -> [0m
+ [33m case $0 of [0m
+ [33m s -> log "Done"[0m
+in value declaration [33mmain[0m
+
+where [33mt1[0m is an unknown type
+ [33mt0[0m is an unknown type
+ [33mt2[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypedBinders3.out b/tests/purs/failing/TypedBinders3.out
new file mode 100644
index 0000000000..0d061f3555
--- /dev/null
+++ b/tests/purs/failing/TypedBinders3.out
@@ -0,0 +1,21 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypedBinders3.purs:8:4 - 8:15 (line 8, column 4 - line 8, column 15)
+
+ Could not match type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ with type
+ [33m [0m
+ [33m String[0m
+ [33m [0m
+
+while inferring the type of [33mcase 1 of [0m
+ [33m 0 -> true [0m
+ [33m _ -> false[0m
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypedHole.out b/tests/purs/failing/TypedHole.out
new file mode 100644
index 0000000000..f502390e07
--- /dev/null
+++ b/tests/purs/failing/TypedHole.out
@@ -0,0 +1,23 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypedHole.purs:8:8 - 8:13 (line 8, column 8 - line 8, column 13)
+
+ Hole '[33mummm[0m' has the inferred type
+ [33m [0m
+ [33m Effect Unit[0m
+ [33m [0m
+ You could substitute the hole with one of these values:
+ [33m [0m
+ [33m Data.Monoid.mempty :: forall @m. Monoid m => m [0m
+ [33m Effect.Class.Console.clear :: forall m. MonadEffect m => m Unit[0m
+ [33m Effect.Class.Console.groupEnd :: forall m. MonadEffect m => m Unit[0m
+ [33m Effect.Console.clear :: Effect Unit [0m
+ [33m Effect.Console.groupEnd :: Effect Unit [0m
+ [33m Main.main :: Effect Unit [0m
+ [33m [0m
+
+in value declaration [33mmain[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypedHole2.out b/tests/purs/failing/TypedHole2.out
new file mode 100644
index 0000000000..e8ef3673df
--- /dev/null
+++ b/tests/purs/failing/TypedHole2.out
@@ -0,0 +1,14 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypedHole2.purs:7:16 - 7:21 (line 7, column 16 - line 7, column 21)
+
+ Hole '[33mummm[0m' has the inferred type
+ [33m [0m
+ [33m Unit[0m
+ [33m [0m
+
+in value declaration [33mmain[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypedHole3.out b/tests/purs/failing/TypedHole3.out
new file mode 100644
index 0000000000..02677b82b9
--- /dev/null
+++ b/tests/purs/failing/TypedHole3.out
@@ -0,0 +1,34 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/TypedHole3.purs:4:10 - 4:15 (line 4, column 10 - line 4, column 15)
+
+ Hole '[33mhelp[0m' has the inferred type
+ [33m [0m
+ [33m t0[0m
+ [33m [0m
+ You could substitute the hole with one of these values:
+ [33m [0m
+ [33m Control.Alt.alt :: forall @f a. Alt f => f a -> f a -> f a [0m
+ [33m Control.Alternative.guard :: forall m. Alternative m => Boolean -> m Unit [0m
+ [33m Control.Applicative.liftA1 :: forall f a b. Applicative f => (a -> b) -> f a -> f b [0m
+ [33m Control.Applicative.pure :: forall @f a. Applicative f => a -> f a [0m
+ [33m Control.Applicative.unless :: forall m. Applicative m => Boolean -> m Unit -> m Unit [0m
+ [33m Control.Applicative.when :: forall m. Applicative m => Boolean -> m Unit -> m Unit [0m
+ [33m Control.Apply.apply :: forall @f a b. Apply f => f (a -> b) -> f a -> f b [0m
+ [33m Control.Apply.applyFirst :: forall a b f. Apply f => f a -> f b -> f a [0m
+ [33m Control.Apply.applySecond :: forall a b f. Apply f => f a -> f b -> f b [0m
+ [33m Control.Apply.lift2 :: forall a b c f. Apply f => (a -> b -> c) -> f a -> ... -> ... [0m
+ [33m Control.Apply.lift3 :: forall a b c d f. Apply f => (a -> b -> ...) -> f a -> ... -> ... [0m
+ [33m Control.Apply.lift4 :: forall a b c d e f. Apply f => (a -> b -> ...) -> f a -> ... -> ... [0m
+ [33m Control.Apply.lift5 :: forall a b c d e f g. Apply f => (a -> b -> ...) -> f a -> ... -> ...[0m
+ [33m Control.Biapplicative.bipure :: forall @w a b. Biapplicative w => a -> b -> w a b [0m
+ [33m Control.Biapply.biapply :: forall @w a b c d. Biapply w => w (a -> b) (c -> d) -> w a c -> w b d[0m
+ [33m [0m
+
+in value declaration [33mfn[0m
+
+where [33mt0[0m is an unknown type
+
+See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypedHole3.purs b/tests/purs/failing/TypedHole3.purs
new file mode 100644
index 0000000000..03050c96ba
--- /dev/null
+++ b/tests/purs/failing/TypedHole3.purs
@@ -0,0 +1,4 @@
+-- @shouldFailWith HoleInferredType
+module Main where
+
+fn _ _ = ?help
diff --git a/tests/purs/failing/TypedHole4.out b/tests/purs/failing/TypedHole4.out
new file mode 100644
index 0000000000..ee25e2c2d5
--- /dev/null
+++ b/tests/purs/failing/TypedHole4.out
@@ -0,0 +1,52 @@
+Error 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/failing/TypedHole4.purs:8:9 - 8:14 (line 8, column 9 - line 8, column 14)
+
+ Hole '[33mhelp[0m' has the inferred type
+ [33m [0m
+ [33m a0[0m
+ [33m [0m
+ You could substitute the hole with one of these values:
+ [33m [0m
+ [33m b :: a0[0m
+ [33m [0m
+ in the following context:
+
+ b :: [33ma0[0m
+
+
+ in value declaration [33mf[0m
+
+ where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+ See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+ or to contribute content related to this error.
+
+Error 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/failing/TypedHole4.purs:9:9 - 9:14 (line 9, column 9 - line 9, column 14)
+
+ Hole '[33mhelp[0m' has the inferred type
+ [33m [0m
+ [33m a0[0m
+ [33m [0m
+ You could substitute the hole with one of these values:
+ [33m [0m
+ [33m b :: a0[0m
+ [33m [0m
+ in the following context:
+
+ b :: [33ma0[0m
+
+
+ in value declaration [33mf[0m
+
+ where [33ma0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+ See https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md for more information,
+ or to contribute content related to this error.
+
diff --git a/tests/purs/failing/TypedHole4.purs b/tests/purs/failing/TypedHole4.purs
new file mode 100644
index 0000000000..3b8043069c
--- /dev/null
+++ b/tests/purs/failing/TypedHole4.purs
@@ -0,0 +1,9 @@
+-- @shouldFailWith HoleInferredType
+-- @shouldFailWith HoleInferredType
+module Main where
+
+data F = X | Y
+
+f :: forall a. F -> a -> a
+f X b = ?help
+f Y b = ?help
diff --git a/tests/purs/failing/UnderscoreModuleName.out b/tests/purs/failing/UnderscoreModuleName.out
new file mode 100644
index 0000000000..47ccfd2f0c
--- /dev/null
+++ b/tests/purs/failing/UnderscoreModuleName.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/UnderscoreModuleName.purs:2:8 - 2:18 (line 2, column 8 - line 2, column 18)
+
+ Unable to parse module:
+ Invalid module name; underscores and primes are not allowed in module names
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/UnknownType.out b/tests/purs/failing/UnknownType.out
new file mode 100644
index 0000000000..2393965238
--- /dev/null
+++ b/tests/purs/failing/UnknownType.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/UnknownType.purs:6:19 - 6:28 (line 6, column 19 - line 6, column 28)
+
+ Unknown type [33mSomething[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnknownName.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/UnsupportedFFICommonJSExports1.js b/tests/purs/failing/UnsupportedFFICommonJSExports1.js
new file mode 100644
index 0000000000..a74e1904db
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSExports1.js
@@ -0,0 +1,2 @@
+export var yes = true;
+exports.no = false;
diff --git a/tests/purs/failing/UnsupportedFFICommonJSExports1.out b/tests/purs/failing/UnsupportedFFICommonJSExports1.out
new file mode 100644
index 0000000000..d39cd8ad0b
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSExports1.out
@@ -0,0 +1,12 @@
+Error found:
+at tests/purs/failing/UnsupportedFFICommonJSExports1.purs:2:1 - 5:29 (line 2, column 1 - line 5, column 29)
+
+ The following CommonJS exports are not supported in the ES foreign module for module [33mMain[0m:
+
+ no
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnsupportedFFICommonJSExports.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/UnsupportedFFICommonJSExports1.purs b/tests/purs/failing/UnsupportedFFICommonJSExports1.purs
new file mode 100644
index 0000000000..fc64c41988
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSExports1.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith UnsupportedFFICommonJSExports
+module Main where
+
+foreign import yes :: Boolean
+foreign import no :: Boolean
diff --git a/tests/purs/failing/UnsupportedFFICommonJSExports2.js b/tests/purs/failing/UnsupportedFFICommonJSExports2.js
new file mode 100644
index 0000000000..10854c8a3b
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSExports2.js
@@ -0,0 +1,4 @@
+import { yes, no } from "some ES module";
+
+exports.yes = yes;
+exports.no = no;
diff --git a/tests/purs/failing/UnsupportedFFICommonJSExports2.out b/tests/purs/failing/UnsupportedFFICommonJSExports2.out
new file mode 100644
index 0000000000..d06dad5f4d
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSExports2.out
@@ -0,0 +1,13 @@
+Error found:
+at tests/purs/failing/UnsupportedFFICommonJSExports2.purs:2:1 - 5:29 (line 2, column 1 - line 5, column 29)
+
+ The following CommonJS exports are not supported in the ES foreign module for module [33mMain[0m:
+
+ yes
+ no
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnsupportedFFICommonJSExports.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/UnsupportedFFICommonJSExports2.purs b/tests/purs/failing/UnsupportedFFICommonJSExports2.purs
new file mode 100644
index 0000000000..fc64c41988
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSExports2.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith UnsupportedFFICommonJSExports
+module Main where
+
+foreign import yes :: Boolean
+foreign import no :: Boolean
diff --git a/tests/purs/failing/UnsupportedFFICommonJSImports1.js b/tests/purs/failing/UnsupportedFFICommonJSImports1.js
new file mode 100644
index 0000000000..c34d89c38c
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSImports1.js
@@ -0,0 +1,4 @@
+var cjsImports = require("some CJS module");
+
+export var yes = cjsImports.yes;
+export var no = cjsImports.no;
diff --git a/tests/purs/failing/UnsupportedFFICommonJSImports1.out b/tests/purs/failing/UnsupportedFFICommonJSImports1.out
new file mode 100644
index 0000000000..59d0cf4351
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSImports1.out
@@ -0,0 +1,12 @@
+Error found:
+at tests/purs/failing/UnsupportedFFICommonJSImports1.purs:2:1 - 5:29 (line 2, column 1 - line 5, column 29)
+
+ The following CommonJS imports are not supported in the ES foreign module for module [33mMain[0m:
+
+ some CJS module
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnsupportedFFICommonJSImports.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/UnsupportedFFICommonJSImports1.purs b/tests/purs/failing/UnsupportedFFICommonJSImports1.purs
new file mode 100644
index 0000000000..85e64dc9f3
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSImports1.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith UnsupportedFFICommonJSImports
+module Main where
+
+foreign import yes :: Boolean
+foreign import no :: Boolean
diff --git a/tests/purs/failing/UnsupportedFFICommonJSImports2.js b/tests/purs/failing/UnsupportedFFICommonJSImports2.js
new file mode 100644
index 0000000000..7d4b8973b5
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSImports2.js
@@ -0,0 +1,5 @@
+import { yes } from "some ES module";
+var cjsImports = require("some CJS module");
+
+exports.yes = yes;
+exports.no = cjsImports.no;
diff --git a/tests/purs/failing/UnsupportedFFICommonJSImports2.out b/tests/purs/failing/UnsupportedFFICommonJSImports2.out
new file mode 100644
index 0000000000..605a493420
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSImports2.out
@@ -0,0 +1,12 @@
+Error found:
+at tests/purs/failing/UnsupportedFFICommonJSImports2.purs:2:1 - 5:29 (line 2, column 1 - line 5, column 29)
+
+ The following CommonJS imports are not supported in the ES foreign module for module [33mMain[0m:
+
+ some CJS module
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnsupportedFFICommonJSImports.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/UnsupportedFFICommonJSImports2.purs b/tests/purs/failing/UnsupportedFFICommonJSImports2.purs
new file mode 100644
index 0000000000..85e64dc9f3
--- /dev/null
+++ b/tests/purs/failing/UnsupportedFFICommonJSImports2.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith UnsupportedFFICommonJSImports
+module Main where
+
+foreign import yes :: Boolean
+foreign import no :: Boolean
diff --git a/tests/purs/failing/UnsupportedRoleDeclarationTypeClass.out b/tests/purs/failing/UnsupportedRoleDeclarationTypeClass.out
new file mode 100644
index 0000000000..91751a89d5
--- /dev/null
+++ b/tests/purs/failing/UnsupportedRoleDeclarationTypeClass.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/UnsupportedRoleDeclarationTypeClass.purs:5:1 - 5:29 (line 5, column 1 - line 5, column 29)
+
+ Role declarations are only supported for data types, not for type synonyms nor type classes.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnsupportedRoleDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/UnsupportedRoleDeclarationTypeClass.purs b/tests/purs/failing/UnsupportedRoleDeclarationTypeClass.purs
new file mode 100644
index 0000000000..58416510bd
--- /dev/null
+++ b/tests/purs/failing/UnsupportedRoleDeclarationTypeClass.purs
@@ -0,0 +1,5 @@
+-- @shouldFailWith UnsupportedRoleDeclaration
+module Main where
+
+class C a
+type role C representational
diff --git a/tests/purs/failing/UnsupportedRoleDeclarationTypeSynonym.out b/tests/purs/failing/UnsupportedRoleDeclarationTypeSynonym.out
new file mode 100644
index 0000000000..b1886dece5
--- /dev/null
+++ b/tests/purs/failing/UnsupportedRoleDeclarationTypeSynonym.out
@@ -0,0 +1,10 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/UnsupportedRoleDeclarationTypeSynonym.purs:7:1 - 7:20 (line 7, column 1 - line 7, column 20)
+
+ Role declarations are only supported for data types, not for type synonyms nor type classes.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnsupportedRoleDeclaration.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/UnsupportedRoleDeclarationTypeSynonym.purs b/tests/purs/failing/UnsupportedRoleDeclarationTypeSynonym.purs
new file mode 100644
index 0000000000..921402541e
--- /dev/null
+++ b/tests/purs/failing/UnsupportedRoleDeclarationTypeSynonym.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith UnsupportedRoleDeclaration
+module Main where
+
+data A a = A
+
+type B a = A a
+type role B nominal
diff --git a/tests/purs/failing/UnsupportedTypeInKind.out b/tests/purs/failing/UnsupportedTypeInKind.out
new file mode 100644
index 0000000000..b811914f36
--- /dev/null
+++ b/tests/purs/failing/UnsupportedTypeInKind.out
@@ -0,0 +1,15 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/UnsupportedTypeInKind.purs:7:28 - 7:38 (line 7, column 28 - line 7, column 38)
+
+ The type:
+
+ [33mOk => Type[0m
+
+ is not supported in kinds.
+
+in foreign data type declaration for [33mBad[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/UnsupportedTypeInKind.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/UnsupportedTypeInKind.purs b/tests/purs/failing/UnsupportedTypeInKind.purs
new file mode 100644
index 0000000000..46198033f3
--- /dev/null
+++ b/tests/purs/failing/UnsupportedTypeInKind.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith UnsupportedTypeInKind
+module Main where
+
+class Ok
+instance ok :: Ok
+
+foreign import data Bad :: Ok => Type
diff --git a/tests/purs/failing/UnusableTypeClassMethod.purs b/tests/purs/failing/UnusableTypeClassMethod.purs
deleted file mode 100644
index 058f504338..0000000000
--- a/tests/purs/failing/UnusableTypeClassMethod.purs
+++ /dev/null
@@ -1,7 +0,0 @@
--- @shouldFailWith UnusableDeclaration
-module Main where
-
-class C a b where
- -- type doesn't contain `a`, which is also required to determine an instance
- c :: b
-
diff --git a/tests/purs/failing/UnusableTypeClassMethodConflictingIdent.purs b/tests/purs/failing/UnusableTypeClassMethodConflictingIdent.purs
deleted file mode 100644
index 08ed602ab8..0000000000
--- a/tests/purs/failing/UnusableTypeClassMethodConflictingIdent.purs
+++ /dev/null
@@ -1,7 +0,0 @@
--- @shouldFailWith UnusableDeclaration
-module Main where
-
-class C a where
- -- type doesn't contain the type class var `a`
- c :: forall a. a
-
diff --git a/tests/purs/failing/UnusableTypeClassMethodSynonym.purs b/tests/purs/failing/UnusableTypeClassMethodSynonym.purs
deleted file mode 100644
index aae1e3379c..0000000000
--- a/tests/purs/failing/UnusableTypeClassMethodSynonym.purs
+++ /dev/null
@@ -1,9 +0,0 @@
--- @shouldFailWith UnusableDeclaration
-module Main where
-
-type M x = forall a. a
-
-class C a where
- -- after synonym expansion, the type doesn't actually contain an `a`
- c :: M a
-
diff --git a/tests/purs/failing/VisibleTypeApplications1.out b/tests/purs/failing/VisibleTypeApplications1.out
new file mode 100644
index 0000000000..db1974405c
--- /dev/null
+++ b/tests/purs/failing/VisibleTypeApplications1.out
@@ -0,0 +1,20 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/VisibleTypeApplications1.purs:7:11 - 7:18 (line 7, column 11 - line 7, column 18)
+
+ An expression of polymorphic type
+ with the invisible type variable [33ma[0m:
+ [33m [0m
+ [33m forall a. a -> a[0m
+ [33m [0m
+ cannot be applied to:
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+while inferring the type of [33mid[0m
+in value declaration [33mfailOne[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotApplyExpressionOfTypeOnType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/VisibleTypeApplications1.purs b/tests/purs/failing/VisibleTypeApplications1.purs
new file mode 100644
index 0000000000..463750fdf3
--- /dev/null
+++ b/tests/purs/failing/VisibleTypeApplications1.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith CannotApplyExpressionOfTypeOnType
+module Main where
+
+id :: forall a. a -> a
+id a = a
+
+failOne = id @Int
diff --git a/tests/purs/failing/VisibleTypeApplications2.out b/tests/purs/failing/VisibleTypeApplications2.out
new file mode 100644
index 0000000000..bb14c33dfd
--- /dev/null
+++ b/tests/purs/failing/VisibleTypeApplications2.out
@@ -0,0 +1,19 @@
+Error found:
+in module [33mMain[0m
+at tests/purs/failing/VisibleTypeApplications2.purs:7:11 - 7:18 (line 7, column 11 - line 7, column 18)
+
+ An expression of monomorphic type:
+ [33m [0m
+ [33m Int -> Int[0m
+ [33m [0m
+ cannot be applied to:
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+while inferring the type of [33mid[0m
+in value declaration [33mfailTwo[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/CannotApplyExpressionOfTypeOnType.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/failing/VisibleTypeApplications2.purs b/tests/purs/failing/VisibleTypeApplications2.purs
new file mode 100644
index 0000000000..9cd202b221
--- /dev/null
+++ b/tests/purs/failing/VisibleTypeApplications2.purs
@@ -0,0 +1,7 @@
+-- @shouldFailWith CannotApplyExpressionOfTypeOnType
+module Main where
+
+id :: Int -> Int
+id a = a
+
+failTwo = id @Int
diff --git a/tests/purs/failing/Whitespace1.out b/tests/purs/failing/Whitespace1.out
new file mode 100644
index 0000000000..299c3ddb53
--- /dev/null
+++ b/tests/purs/failing/Whitespace1.out
@@ -0,0 +1,10 @@
+Error found:
+at tests/purs/failing/Whitespace1.purs:5:1 - 5:2 (line 5, column 1 - line 5, column 2)
+
+ Unable to parse module:
+ Illegal whitespace character U+0009
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
+or to contribute content related to this error.
+
diff --git a/tests/purs/graph/graph.json b/tests/purs/graph/graph.json
new file mode 100644
index 0000000000..0e6725089d
--- /dev/null
+++ b/tests/purs/graph/graph.json
@@ -0,0 +1 @@
+{"Module2":{"path":"tests/purs/graph/src/Module2.purs","depends":["Module3"]},"Module3":{"path":"tests/purs/graph/src/Module3.purs","depends":[]},"Module":{"path":"tests/purs/graph/src/Module.purs","depends":["Module2"]}}
\ No newline at end of file
diff --git a/tests/purs/graph/src/Module.purs b/tests/purs/graph/src/Module.purs
new file mode 100644
index 0000000000..567c661a41
--- /dev/null
+++ b/tests/purs/graph/src/Module.purs
@@ -0,0 +1,9 @@
+module Module (foo) where
+
+import Module2 (bar)
+
+foo :: Int
+foo = 0
+
+baz :: Int
+baz = foo + bar
diff --git a/tests/purs/graph/src/Module2.purs b/tests/purs/graph/src/Module2.purs
new file mode 100644
index 0000000000..547419beb4
--- /dev/null
+++ b/tests/purs/graph/src/Module2.purs
@@ -0,0 +1,6 @@
+module Module2 (bar) where
+
+import Module3 (baz)
+
+bar :: Int
+bar = 1
diff --git a/tests/purs/graph/src/Module3.purs b/tests/purs/graph/src/Module3.purs
new file mode 100644
index 0000000000..15905130a2
--- /dev/null
+++ b/tests/purs/graph/src/Module3.purs
@@ -0,0 +1,4 @@
+module Module3 (baz) where
+
+baz :: Int
+baz = 3
diff --git a/tests/purs/graph/src/ModuleFailing.purs b/tests/purs/graph/src/ModuleFailing.purs
new file mode 100644
index 0000000000..3346af5f70
--- /dev/null
+++ b/tests/purs/graph/src/ModuleFailing.purs
@@ -0,0 +1,5 @@
+module ModuleFailing where
+
+import NonExistent as M
+
+bat = M.nonExistent
diff --git a/tests/purs/layout/.gitattributes b/tests/purs/layout/.gitattributes
new file mode 100644
index 0000000000..d0b673f439
--- /dev/null
+++ b/tests/purs/layout/.gitattributes
@@ -0,0 +1 @@
+*.out -merge -text
diff --git a/tests/purs/layout/AdoIn.out b/tests/purs/layout/AdoIn.out
index 134ef8fc61..b089bd6b59 100644
--- a/tests/purs/layout/AdoIn.out
+++ b/tests/purs/layout/AdoIn.out
@@ -10,5 +10,11 @@ test = ado {}in foo;
test = ado{
foo <- bar $ let {a = 42 }in a;
baz <- b}
+ in bar;
+
+test = ado{
+ foo;
+ let {bar = let {a = 42 }in a};
+ let {baz = 42}}
in bar}
\ No newline at end of file
diff --git a/tests/purs/layout/AdoIn.purs b/tests/purs/layout/AdoIn.purs
index ba7a736619..6513ee8e0d 100644
--- a/tests/purs/layout/AdoIn.purs
+++ b/tests/purs/layout/AdoIn.purs
@@ -11,3 +11,9 @@ test = ado
foo <- bar $ let a = 42 in a
baz <- b
in bar
+
+test = ado
+ foo
+ let bar = let a = 42 in a
+ let baz = 42
+ in bar
diff --git a/tests/purs/layout/BacktickOperator.out b/tests/purs/layout/BacktickOperator.out
new file mode 100644
index 0000000000..068b8298d2
--- /dev/null
+++ b/tests/purs/layout/BacktickOperator.out
@@ -0,0 +1,22 @@
+module Test where{
+
+example1 = do{
+ foo bar}
+ <|> baz;
+
+example2 = do{
+ foo bar}
+ `wat` baz;
+
+example3 =
+ case _ of{
+ Foo a -> 1;
+ Bar b -> 2}
+ `append` 3;
+
+example4 =
+ case _ of{
+ Foo a -> 1;
+ Bar b -> 2}
+ + 3}
+
\ No newline at end of file
diff --git a/tests/purs/layout/BacktickOperator.purs b/tests/purs/layout/BacktickOperator.purs
new file mode 100644
index 0000000000..81be3e37e4
--- /dev/null
+++ b/tests/purs/layout/BacktickOperator.purs
@@ -0,0 +1,21 @@
+module Test where
+
+example1 = do
+ foo bar
+ <|> baz
+
+example2 = do
+ foo bar
+ `wat` baz
+
+example3 =
+ case _ of
+ Foo a -> 1
+ Bar b -> 2
+ `append` 3
+
+example4 =
+ case _ of
+ Foo a -> 1
+ Bar b -> 2
+ + 3
diff --git a/tests/purs/layout/IntType.out b/tests/purs/layout/IntType.out
new file mode 100644
index 0000000000..b05e2ac44a
--- /dev/null
+++ b/tests/purs/layout/IntType.out
@@ -0,0 +1,8 @@
+module Test where{
+
+type IntType = (-1);
+
+type IntType' = (-
+ -- here's a comment
+ 1)}
+
\ No newline at end of file
diff --git a/tests/purs/layout/IntType.purs b/tests/purs/layout/IntType.purs
new file mode 100644
index 0000000000..b6e70dc476
--- /dev/null
+++ b/tests/purs/layout/IntType.purs
@@ -0,0 +1,7 @@
+module Test where
+
+type IntType = (-1)
+
+type IntType' = (-
+ -- here's a comment
+ 1)
diff --git a/tests/purs/layout/LetGuards.out b/tests/purs/layout/LetGuards.out
new file mode 100644
index 0000000000..9c01aeb0ee
--- /dev/null
+++ b/tests/purs/layout/LetGuards.out
@@ -0,0 +1,30 @@
+module Test where{
+
+test =
+ let{
+ foo
+ | bar
+ , baz =
+ 42
+ | otherwise = 100}
+ in
+ foo;
+
+test = do{
+ let{
+ foo
+ | bar
+ , baz =
+ 42
+ | otherwise = 100};
+ foo};
+
+test = ado{
+ let{
+ foo
+ | bar
+ , baz =
+ 42
+ | otherwise = 100};
+ foo}}
+
\ No newline at end of file
diff --git a/tests/purs/layout/LetGuards.purs b/tests/purs/layout/LetGuards.purs
new file mode 100644
index 0000000000..8555a75e81
--- /dev/null
+++ b/tests/purs/layout/LetGuards.purs
@@ -0,0 +1,29 @@
+module Test where
+
+test =
+ let
+ foo
+ | bar
+ , baz =
+ 42
+ | otherwise = 100
+ in
+ foo
+
+test = do
+ let
+ foo
+ | bar
+ , baz =
+ 42
+ | otherwise = 100
+ foo
+
+test = ado
+ let
+ foo
+ | bar
+ , baz =
+ 42
+ | otherwise = 100
+ foo
diff --git a/tests/purs/layout/Shebang.out b/tests/purs/layout/Shebang.out
new file mode 100644
index 0000000000..c2c867c2ee
--- /dev/null
+++ b/tests/purs/layout/Shebang.out
@@ -0,0 +1,7 @@
+#! shebang line 1
+#! shebang line 2
+
+module Test where{
+
+foo = 42}
+
\ No newline at end of file
diff --git a/tests/purs/layout/Shebang.purs b/tests/purs/layout/Shebang.purs
new file mode 100644
index 0000000000..63986ee496
--- /dev/null
+++ b/tests/purs/layout/Shebang.purs
@@ -0,0 +1,6 @@
+#! shebang line 1
+#! shebang line 2
+
+module Test where
+
+foo = 42
diff --git a/tests/purs/optimize/2866.out.js b/tests/purs/optimize/2866.out.js
new file mode 100644
index 0000000000..f0854cce7d
--- /dev/null
+++ b/tests/purs/optimize/2866.out.js
@@ -0,0 +1,13 @@
+// Canonical test for #2866. This doesn't need to test whether `apply`s
+// defined from modules other than `Data.Function` are incorrectly
+// optimized since the rest of the test suite seemingly catches it.
+var Area = function (x) {
+ return x;
+};
+var areaFlipped = 42;
+var area = 42;
+export {
+ Area,
+ area,
+ areaFlipped
+};
diff --git a/tests/purs/optimize/2866.purs b/tests/purs/optimize/2866.purs
new file mode 100644
index 0000000000..8341433354
--- /dev/null
+++ b/tests/purs/optimize/2866.purs
@@ -0,0 +1,12 @@
+-- Canonical test for #2866. This doesn't need to test whether `apply`s
+-- defined from modules other than `Data.Function` are incorrectly
+-- optimized since the rest of the test suite seemingly catches it.
+module Main where
+
+import Prelude
+
+newtype Area = Area Int
+
+area = Area $ 42
+
+areaFlipped = 42 # Area
diff --git a/tests/purs/optimize/4179.out.js b/tests/purs/optimize/4179.out.js
new file mode 100644
index 0000000000..992b422a1f
--- /dev/null
+++ b/tests/purs/optimize/4179.out.js
@@ -0,0 +1,101 @@
+var $runtime_lazy = function (name, moduleName, init) {
+ var state = 0;
+ var val;
+ return function (lineNumber) {
+ if (state === 2) return val;
+ if (state === 1) throw new ReferenceError(name + " was needed before it finished initializing (module " + moduleName + ", line " + lineNumber + ")", moduleName, lineNumber);
+ state = 1;
+ val = init();
+ state = 2;
+ return val;
+ };
+};
+
+// This is a test that TCO isn't broken by unsafePartial.
+var tcoable = function ($copy_v) {
+ var $tco_done = false;
+ var $tco_result;
+ function $tco_loop(v) {
+ if (v === 0) {
+ $tco_done = true;
+ return "done";
+ };
+ if (v > 0) {
+ $copy_v = v - 1 | 0;
+ return;
+ };
+ throw new Error("Failed pattern match at Main (line 43, column 25 - line 45, column 31): " + [ v.constructor.name ]);
+ };
+ while (!$tco_done) {
+ $tco_result = $tco_loop($copy_v);
+ };
+ return $tco_result;
+};
+var isOdd = function (n) {
+ return n > 0 && !isEven(n - 1 | 0);
+};
+var isEven = function (n) {
+ return n === 0 || isOdd(n - 1 | 0);
+};
+
+// This is an example of four mutually recursive bindings with a complex
+// run-time dependency structure. The expected result is:
+// alpha is defined without any laziness
+// bravo and charlie are lazily initialized in a group
+// and then delta is lazily initialized
+var alpha = function (v) {
+ if (v === 0) {
+ return $lazy_bravo(18);
+ };
+ if (v === 1) {
+ return $lazy_charlie(19);
+ };
+ if (v === 2) {
+ return function (y) {
+ var $13 = y > 0;
+ if ($13) {
+ return bravo(y);
+ };
+ return charlie(y);
+ };
+ };
+ return function (y) {
+ return $lazy_delta(21)(y)(v);
+ };
+};
+var $lazy_charlie = /* #__PURE__ */ $runtime_lazy("charlie", "Main", function () {
+ return (function (v) {
+ return alpha;
+ })({})(4);
+});
+var $lazy_bravo = /* #__PURE__ */ $runtime_lazy("bravo", "Main", function () {
+ return (function (v) {
+ return alpha;
+ })({})(3);
+});
+var charlie = /* #__PURE__ */ $lazy_charlie(31);
+var bravo = /* #__PURE__ */ $lazy_bravo(28);
+var $lazy_delta = /* #__PURE__ */ $runtime_lazy("delta", "Main", function () {
+ var b = (function (v) {
+ return bravo;
+ })({});
+ return function (x) {
+ return function (y) {
+ var $14 = x === y;
+ if ($14) {
+ return b(0);
+ };
+ return 1.0;
+ };
+ };
+});
+var delta = /* #__PURE__ */ $lazy_delta(34);
+export {
+ isEven,
+ isOdd,
+ alpha,
+ bravo,
+ charlie,
+ delta,
+ tcoable
+};
diff --git a/tests/purs/optimize/4179.purs b/tests/purs/optimize/4179.purs
new file mode 100644
index 0000000000..30fc6aed4d
--- /dev/null
+++ b/tests/purs/optimize/4179.purs
@@ -0,0 +1,45 @@
+module Main where
+
+import Prelude
+
+import Partial.Unsafe (unsafePartial)
+
+isEven n = n == 0 || isOdd (n - 1)
+isOdd n = n > 0 && not (isEven (n - 1))
+
+-- This is an example of four mutually recursive bindings with a complex
+-- run-time dependency structure. The expected result is:
+-- alpha is defined without any laziness
+-- bravo and charlie are lazily initialized in a group
+-- and then delta is lazily initialized
+
+alpha :: Int -> Int -> Number
+alpha = case _ of
+ 0 -> bravo
+ 1 -> charlie
+ 2 -> \y -> if y > 0 then bravo y else charlie y
+ x -> \y -> delta y x
+
+-- Me: `alpha`
+-- purs: The value of alpha is undefined here, so this reference is not allowed.
+-- Me: `(\_ -> alpha) {}`
+-- purs: LGTM!
+
+bravo :: Int -> Number
+bravo = (\_ -> alpha) {} 3
+
+charlie :: Int -> Number
+charlie = (\_ -> alpha) {} 4
+
+delta :: Int -> Int -> Number
+delta =
+ let b = (\_ -> bravo) {}
+ in \x y -> if x == y then b 0 else 1.0
+
+
+-- This is a test that TCO isn't broken by unsafePartial.
+
+tcoable :: Int -> String
+tcoable = unsafePartial case _ of
+ 0 -> "done"
+ n | n > 0 -> tcoable (n - 1)
diff --git a/tests/purs/optimize/4229.out.js b/tests/purs/optimize/4229.out.js
new file mode 100644
index 0000000000..3fa9e5659f
--- /dev/null
+++ b/tests/purs/optimize/4229.out.js
@@ -0,0 +1,17 @@
+import * as Data_Unit from "../Data.Unit/index.js";
+import * as Effect_Console from "../Effect.Console/index.js";
+var Control_Bind = /* #__PURE__ */ (function () {
+ function Control_Bind() {
+
+ };
+ Control_Bind.value = new Control_Bind();
+ return Control_Bind;
+})();
+var main = function __do() {
+ Data_Unit.unit;
+ return Effect_Console.log("Done")();
+};
+export {
+ Control_Bind,
+ main
+};
diff --git a/tests/purs/bundle/PSasConstructor.purs b/tests/purs/optimize/4229.purs
similarity index 78%
rename from tests/purs/bundle/PSasConstructor.purs
rename to tests/purs/optimize/4229.purs
index d30721ae39..77b2a8c5ff 100644
--- a/tests/purs/bundle/PSasConstructor.purs
+++ b/tests/purs/optimize/4229.purs
@@ -1,11 +1,13 @@
module Main where
import Prelude
+
import Effect (Effect)
import Effect.Console (log)
-data P = PS
+data X = Control_Bind
main :: Effect Unit
main = do
+ pure unit
log "Done"
diff --git a/tests/purs/optimize/4386.out.js b/tests/purs/optimize/4386.out.js
new file mode 100644
index 0000000000..e2a2f80c7b
--- /dev/null
+++ b/tests/purs/optimize/4386.out.js
@@ -0,0 +1,26 @@
+var mySTFn2 = function (a, b) {
+ return a + b | 0;
+};
+var mySTFn1 = function (a) {
+ return a + 1 | 0;
+};
+var myInt2 = function () {
+ return mySTFn2(0, 1);
+};
+var myInt1 = function () {
+ return mySTFn1(0);
+};
+var otherTest = function __do() {
+ var a = mySTFn2(0, 1);
+ var b = mySTFn1(2);
+ var c = myInt1();
+ var d = myInt2();
+ return ((a + b | 0) + c | 0) + d | 0;
+};
+export {
+ mySTFn1,
+ mySTFn2,
+ myInt1,
+ myInt2,
+ otherTest
+};
diff --git a/tests/purs/optimize/4386.purs b/tests/purs/optimize/4386.purs
new file mode 100644
index 0000000000..be3832cce1
--- /dev/null
+++ b/tests/purs/optimize/4386.purs
@@ -0,0 +1,25 @@
+module Main where
+
+import Prelude
+import Control.Monad.ST (ST)
+import Control.Monad.ST.Uncurried (STFn1, STFn2, mkSTFn1, mkSTFn2, runSTFn1, runSTFn2)
+
+mySTFn1 :: forall r. STFn1 Int r Int
+mySTFn1 = mkSTFn1 \a -> pure (a + 1)
+
+mySTFn2 :: forall r. STFn2 Int Int r Int
+mySTFn2 = mkSTFn2 \a b -> pure (a + b)
+
+myInt1 :: forall r. ST r Int
+myInt1 = runSTFn1 mySTFn1 0
+
+myInt2 :: forall r. ST r Int
+myInt2 = runSTFn2 mySTFn2 0 1
+
+otherTest :: forall r. ST r Int
+otherTest = do
+ a <- runSTFn2 mySTFn2 0 1
+ b <- runSTFn1 mySTFn1 2
+ c <- myInt1
+ d <- myInt2
+ pure $ a + b + c + d
diff --git a/tests/purs/optimize/Foreign.js b/tests/purs/optimize/Foreign.js
new file mode 100644
index 0000000000..9d7381d29f
--- /dev/null
+++ b/tests/purs/optimize/Foreign.js
@@ -0,0 +1 @@
+export const foo = 42;
diff --git a/tests/purs/optimize/Foreign.out.js b/tests/purs/optimize/Foreign.out.js
new file mode 100644
index 0000000000..610605c4ed
--- /dev/null
+++ b/tests/purs/optimize/Foreign.out.js
@@ -0,0 +1,5 @@
+import * as $foreign from "./foreign.js";
+var bar = $foreign.foo;
+export {
+ bar
+};
diff --git a/tests/purs/optimize/Foreign.purs b/tests/purs/optimize/Foreign.purs
new file mode 100644
index 0000000000..3c496aea24
--- /dev/null
+++ b/tests/purs/optimize/Foreign.purs
@@ -0,0 +1,5 @@
+module Main (bar) where
+
+foreign import foo :: Int
+
+bar = foo
diff --git a/tests/purs/optimize/Monad.out.js b/tests/purs/optimize/Monad.out.js
new file mode 100644
index 0000000000..1a823571af
--- /dev/null
+++ b/tests/purs/optimize/Monad.out.js
@@ -0,0 +1,30 @@
+import * as Control_Applicative from "../Control.Applicative/index.js";
+import * as Control_Bind from "../Control.Bind/index.js";
+var liftM1 = function (dictMonad) {
+ var bind = Control_Bind.bind(dictMonad.Bind1());
+ var pure = Control_Applicative.pure(dictMonad.Applicative0());
+ return function (f) {
+ return function (a) {
+ return bind(a)(function (a$prime) {
+ return pure(f(a$prime));
+ });
+ };
+ };
+};
+var ap = function (dictMonad) {
+ var bind = Control_Bind.bind(dictMonad.Bind1());
+ var pure = Control_Applicative.pure(dictMonad.Applicative0());
+ return function (f) {
+ return function (a) {
+ return bind(f)(function (f$prime) {
+ return bind(a)(function (a$prime) {
+ return pure(f$prime(a$prime));
+ });
+ });
+ };
+ };
+};
+export {
+ liftM1,
+ ap
+};
diff --git a/tests/purs/optimize/Monad.purs b/tests/purs/optimize/Monad.purs
new file mode 100644
index 0000000000..931572be84
--- /dev/null
+++ b/tests/purs/optimize/Monad.purs
@@ -0,0 +1,17 @@
+module Main where
+
+import Control.Applicative (class Applicative, pure)
+import Control.Bind (class Bind, bind)
+
+class (Applicative m, Bind m) <= Monad m
+
+liftM1 :: forall m a b. Monad m => (a -> b) -> m a -> m b
+liftM1 f a = do
+ a' <- a
+ pure (f a')
+
+ap :: forall m a b. Monad m => m (a -> b) -> m a -> m b
+ap f a = do
+ f' <- f
+ a' <- a
+ pure (f' a')
diff --git a/tests/purs/optimize/ObjectUpdate.out.js b/tests/purs/optimize/ObjectUpdate.out.js
new file mode 100644
index 0000000000..37356ae668
--- /dev/null
+++ b/tests/purs/optimize/ObjectUpdate.out.js
@@ -0,0 +1,27 @@
+var staticUpdate2 = function (x) {
+ return {
+ alpha: x.alpha,
+ bravo: true
+ };
+};
+var staticUpdate1 = function (x) {
+ return {
+ alpha: x.alpha,
+ bravo: "replaced"
+ };
+};
+var dynamicUpdate1 = function (x) {
+ var $3 = {};
+ for (var $4 in x) {
+ if ({}.hasOwnProperty.call(x, $4)) {
+ $3[$4] = x[$4];
+ };
+ };
+ $3.bravo = true;
+ return $3;
+};
+export {
+ staticUpdate1,
+ staticUpdate2,
+ dynamicUpdate1
+};
diff --git a/tests/purs/optimize/ObjectUpdate.purs b/tests/purs/optimize/ObjectUpdate.purs
new file mode 100644
index 0000000000..862638fa83
--- /dev/null
+++ b/tests/purs/optimize/ObjectUpdate.purs
@@ -0,0 +1,10 @@
+module Main where
+
+staticUpdate1 :: { alpha :: Int, bravo :: String } -> { alpha :: Int, bravo :: String }
+staticUpdate1 x = x { bravo = "replaced" }
+
+staticUpdate2 :: { alpha :: Int, bravo :: String } -> { alpha :: Int, bravo :: Boolean }
+staticUpdate2 x = x { bravo = true }
+
+dynamicUpdate1 :: forall r. { alpha :: Int, bravo :: String | r } -> { alpha :: Int, bravo :: Boolean | r }
+dynamicUpdate1 x = x { bravo = true }
diff --git a/tests/purs/optimize/Primitives.out.js b/tests/purs/optimize/Primitives.out.js
new file mode 100644
index 0000000000..20907cc483
--- /dev/null
+++ b/tests/purs/optimize/Primitives.out.js
@@ -0,0 +1,10 @@
+// This test checks that no unused Semiring abstractions are introduced when
+// the operators are compiled to JS primitives.
+var f = function (x) {
+ return function (y) {
+ return x * (y + 1 | 0) | 0;
+ };
+};
+export {
+ f
+};
diff --git a/tests/purs/optimize/Primitives.purs b/tests/purs/optimize/Primitives.purs
new file mode 100644
index 0000000000..7a7df2ffa7
--- /dev/null
+++ b/tests/purs/optimize/Primitives.purs
@@ -0,0 +1,9 @@
+-- This test checks that no unused Semiring abstractions are introduced when
+-- the operators are compiled to JS primitives.
+
+module Main where
+
+import Prelude
+
+f :: Int -> Int -> Int
+f x y = x * (y + 1)
diff --git a/tests/purs/optimize/RecursiveInstances.out.js b/tests/purs/optimize/RecursiveInstances.out.js
new file mode 100644
index 0000000000..bac3268850
--- /dev/null
+++ b/tests/purs/optimize/RecursiveInstances.out.js
@@ -0,0 +1,107 @@
+import * as Data_Semigroup from "../Data.Semigroup/index.js";
+import * as Data_Symbol from "../Data.Symbol/index.js";
+import * as Type_Proxy from "../Type.Proxy/index.js";
+var append = /* #__PURE__ */ Data_Semigroup.append(Data_Semigroup.semigroupArray);
+var findKeysAuxNil = {
+ findKeysAux: function (v) {
+ return [ ];
+ }
+};
+var findKeysAux = function (dict) {
+ return dict.findKeysAux;
+};
+var findKeysAuxCons = function (dictIsSymbol) {
+ var reflectSymbol = Data_Symbol.reflectSymbol(dictIsSymbol);
+ return function (dictFindKeysAux) {
+ var findKeysAux1 = findKeysAux(dictFindKeysAux);
+ return {
+ findKeysAux: function (v) {
+ return append([ reflectSymbol(Type_Proxy["Proxy"].value) ])(findKeysAux1(Type_Proxy["Proxy"].value));
+ }
+ };
+ };
+};
+var findKeysAuxCons1 = /* #__PURE__ */ findKeysAuxCons({
+ reflectSymbol: function () {
+ return "a";
+ }
+});
+var findKeysAuxCons2 = /* #__PURE__ */ findKeysAuxCons({
+ reflectSymbol: function () {
+ return "b";
+ }
+});
+var findKeysAuxCons3 = /* #__PURE__ */ findKeysAuxCons({
+ reflectSymbol: function () {
+ return "c";
+ }
+});
+var findKeysAuxCons4 = /* #__PURE__ */ findKeysAuxCons({
+ reflectSymbol: function () {
+ return "d";
+ }
+});
+var findKeys = function () {
+ return function (dictFindKeysAux) {
+ var findKeysAux1 = findKeysAux(dictFindKeysAux);
+ return function (v) {
+ return findKeysAux1(Type_Proxy["Proxy"].value);
+ };
+ };
+};
+var findKeys11 = /* #__PURE__ */ findKeys();
+var findKeys12 = /* #__PURE__ */ findKeys11(/* #__PURE__ */ findKeysAuxCons1(findKeysAuxNil));
+var findKeys13 = /* #__PURE__ */ findKeys11(/* #__PURE__ */ findKeysAuxCons1(/* #__PURE__ */ findKeysAuxCons2(/* #__PURE__ */ findKeysAuxCons3(/* #__PURE__ */ findKeysAuxCons4(/* #__PURE__ */ findKeysAuxCons({
+ reflectSymbol: function () {
+ return "e";
+ }
+})(findKeysAuxNil))))));
+var findKeys14 = /* #__PURE__ */ findKeys11(/* #__PURE__ */ findKeysAuxCons1(/* #__PURE__ */ findKeysAuxCons2(findKeysAuxNil)));
+var findKeys15 = /* #__PURE__ */ findKeys11(/* #__PURE__ */ findKeysAuxCons1(/* #__PURE__ */ findKeysAuxCons2(/* #__PURE__ */ findKeysAuxCons3(findKeysAuxNil))));
+var findKeys16 = /* #__PURE__ */ findKeys11(/* #__PURE__ */ findKeysAuxCons1(/* #__PURE__ */ findKeysAuxCons2(/* #__PURE__ */ findKeysAuxCons3(/* #__PURE__ */ findKeysAuxCons4(findKeysAuxNil)))));
+var findKeys1 = /* #__PURE__ */ (function () {
+ return findKeys12(Type_Proxy["Proxy"].value);
+})();
+var findKeys10 = /* #__PURE__ */ (function () {
+ return findKeys13(Type_Proxy["Proxy"].value);
+})();
+var findKeys2 = /* #__PURE__ */ (function () {
+ return findKeys14(Type_Proxy["Proxy"].value);
+})();
+var findKeys3 = /* #__PURE__ */ (function () {
+ return findKeys15(Type_Proxy["Proxy"].value);
+})();
+var findKeys4 = /* #__PURE__ */ (function () {
+ return findKeys16(Type_Proxy["Proxy"].value);
+})();
+var findKeys5 = /* #__PURE__ */ (function () {
+ return findKeys13(Type_Proxy["Proxy"].value);
+})();
+var findKeys6 = /* #__PURE__ */ (function () {
+ return findKeys12(Type_Proxy["Proxy"].value);
+})();
+var findKeys7 = /* #__PURE__ */ (function () {
+ return findKeys14(Type_Proxy["Proxy"].value);
+})();
+var findKeys8 = /* #__PURE__ */ (function () {
+ return findKeys15(Type_Proxy["Proxy"].value);
+})();
+var findKeys9 = /* #__PURE__ */ (function () {
+ return findKeys16(Type_Proxy["Proxy"].value);
+})();
+export {
+ findKeysAux,
+ findKeys,
+ findKeys1,
+ findKeys2,
+ findKeys3,
+ findKeys4,
+ findKeys5,
+ findKeys6,
+ findKeys7,
+ findKeys8,
+ findKeys9,
+ findKeys10,
+ findKeysAuxNil,
+ findKeysAuxCons
+};
diff --git a/tests/purs/optimize/RecursiveInstances.purs b/tests/purs/optimize/RecursiveInstances.purs
new file mode 100644
index 0000000000..0719609037
--- /dev/null
+++ b/tests/purs/optimize/RecursiveInstances.purs
@@ -0,0 +1,31 @@
+module Main where
+
+import Prelude
+
+import Prim.Row as R
+import Prim.RowList as RL
+import Type.Prelude (class IsSymbol, Proxy(..), reflectSymbol)
+
+class FindKeysAux :: forall k. RL.RowList k -> Constraint
+class FindKeysAux a where
+ findKeysAux :: Proxy a -> Array String
+
+instance FindKeysAux RL.Nil where
+ findKeysAux _ = []
+
+else instance (IsSymbol l, FindKeysAux r) => FindKeysAux (RL.Cons l t r) where
+ findKeysAux _ = [ reflectSymbol (Proxy :: Proxy l) ] <> findKeysAux (Proxy :: Proxy r)
+
+findKeys :: forall r rl. RL.RowToList r rl => FindKeysAux rl => Proxy r -> Array String
+findKeys _ = findKeysAux (Proxy :: Proxy rl)
+
+findKeys1 = findKeys (Proxy :: Proxy (a :: Unit))
+findKeys2 = findKeys (Proxy :: Proxy (a :: Unit, b :: Unit))
+findKeys3 = findKeys (Proxy :: Proxy (a :: Unit, b :: Unit, c :: Unit))
+findKeys4 = findKeys (Proxy :: Proxy (a :: Unit, b :: Unit, c :: Unit, d :: Unit))
+findKeys5 = findKeys (Proxy :: Proxy (a :: Unit, b :: Unit, c :: Unit, d :: Unit, e :: Unit))
+findKeys6 = findKeys (Proxy :: Proxy (a :: Unit))
+findKeys7 = findKeys (Proxy :: Proxy (a :: Unit, b :: Unit))
+findKeys8 = findKeys (Proxy :: Proxy (a :: Unit, b :: Unit, c :: Unit))
+findKeys9 = findKeys (Proxy :: Proxy (a :: Unit, b :: Unit, c :: Unit, d :: Unit))
+findKeys10 = findKeys (Proxy :: Proxy (a :: Unit, b :: Unit, c :: Unit, d :: Unit, e :: Unit))
diff --git a/tests/purs/optimize/Symbols.out.js b/tests/purs/optimize/Symbols.out.js
new file mode 100644
index 0000000000..8025617462
--- /dev/null
+++ b/tests/purs/optimize/Symbols.out.js
@@ -0,0 +1,68 @@
+import * as Data_Symbol from "../Data.Symbol/index.js";
+import * as Record_Unsafe from "../Record.Unsafe/index.js";
+import * as Type_Proxy from "../Type.Proxy/index.js";
+var fooIsSymbol = {
+ reflectSymbol: function () {
+ return "foo";
+ }
+};
+var set = function (dictIsSymbol) {
+ var reflectSymbol = Data_Symbol.reflectSymbol(dictIsSymbol);
+ return function () {
+ return function (l) {
+ return function (a) {
+ return function (r) {
+ return Record_Unsafe.unsafeSet(reflectSymbol(l))(a)(r);
+ };
+ };
+ };
+ };
+};
+var set1 = /* #__PURE__ */ set(fooIsSymbol)();
+var get = function (dictIsSymbol) {
+ var reflectSymbol = Data_Symbol.reflectSymbol(dictIsSymbol);
+ return function () {
+ return function (l) {
+ return function (r) {
+ return Record_Unsafe.unsafeGet(reflectSymbol(l))(r);
+ };
+ };
+ };
+};
+var get1 = /* #__PURE__ */ get(fooIsSymbol)();
+var get2 = /* #__PURE__ */ get({
+ reflectSymbol: function () {
+ return "bar";
+ }
+})();
+var foo = /* #__PURE__ */ (function () {
+ return Type_Proxy["Proxy"].value;
+})();
+var h = function (n) {
+ return set1(foo)(n)({
+ foo: 0
+ });
+};
+var f = function (n) {
+ return get1(foo)({
+ foo: n
+ });
+};
+var bar = /* #__PURE__ */ (function () {
+ return Type_Proxy["Proxy"].value;
+})();
+var g = function (n) {
+ return get2(bar)({
+ foo: 0,
+ bar: n
+ });
+};
+export {
+ get,
+ set,
+ foo,
+ bar,
+ f,
+ g,
+ h
+};
diff --git a/tests/purs/optimize/Symbols.purs b/tests/purs/optimize/Symbols.purs
new file mode 100644
index 0000000000..578d225a02
--- /dev/null
+++ b/tests/purs/optimize/Symbols.purs
@@ -0,0 +1,40 @@
+module Main where
+
+import Data.Symbol (class IsSymbol, reflectSymbol)
+import Prim.Row (class Cons)
+import Record.Unsafe (unsafeGet, unsafeSet)
+import Type.Proxy (Proxy(..))
+
+get
+ :: forall r r' l a
+ . IsSymbol l
+ => Cons l a r' r
+ => Proxy l
+ -> Record r
+ -> a
+get l r = unsafeGet (reflectSymbol l) r
+
+set
+ :: forall r r' l a
+ . IsSymbol l
+ => Cons l a r' r
+ => Proxy l
+ -> a
+ -> Record r
+ -> Record r
+set l a r = unsafeSet (reflectSymbol l) a r
+
+foo :: Proxy "foo"
+foo = Proxy
+
+bar :: Proxy "bar"
+bar = Proxy
+
+f :: Int -> Int
+f n = get foo { foo: n }
+
+g :: Int -> Int
+g n = get bar { foo: 0, bar: n }
+
+h :: Int -> { foo :: Int }
+h n = set foo n { foo: 0 }
diff --git a/tests/purs/passing/2172.purs b/tests/purs/passing/2172.purs
deleted file mode 100644
index 34580ccd3d..0000000000
--- a/tests/purs/passing/2172.purs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Main where
-
-import Effect.Console (log)
-
-foreign import a' :: Number
-foreign import b' :: Number
-foreign import c' :: Number
-foreign import d' :: Number
-
-main = log "Done"
diff --git a/tests/purs/passing/2941.purs b/tests/purs/passing/2941.purs
new file mode 100644
index 0000000000..126cd024ff
--- /dev/null
+++ b/tests/purs/passing/2941.purs
@@ -0,0 +1,18 @@
+module Main where
+
+import Effect.Console (log)
+
+test0 = ((((\_ -> 0) :: b -> Int) :: forall b. b -> Int) :: forall a. a -> Int)
+
+test1 :: {attr :: forall a. a -> Int}
+test1 = {attr: ((\_ -> 0) :: b -> Int) :: forall b. b -> Int}
+
+class Test2 where
+ f :: forall a. a -> a
+
+instance test2 :: Test2 where
+ f :: forall a. a -> a
+ f x = (x :: a)
+
+
+main = log "Done"
diff --git a/tests/purs/passing/3114.purs b/tests/purs/passing/3114.purs
index 5d9d2af4c8..f49e7e6a39 100644
--- a/tests/purs/passing/3114.purs
+++ b/tests/purs/passing/3114.purs
@@ -9,17 +9,18 @@ import Effect
import Effect.Console (log)
import VendoredVariant
import Data.Symbol
+import Type.Proxy (Proxy(..))
type TestVariants =
- ( foo :: FProxy Maybe
- , bar :: FProxy (Tuple String)
+ ( foo :: Proxy Maybe
+ , bar :: Proxy (Tuple String)
)
-_foo :: SProxy "foo"
-_foo = SProxy
+_foo :: Proxy "foo"
+_foo = Proxy
-_bar :: SProxy "bar"
-_bar = SProxy
+_bar :: Proxy "bar"
+_bar = Proxy
main :: Effect Unit
main = do
diff --git a/tests/purs/passing/3114/VendoredVariant.purs b/tests/purs/passing/3114/VendoredVariant.purs
index 2442e99a96..7582bc5933 100644
--- a/tests/purs/passing/3114/VendoredVariant.purs
+++ b/tests/purs/passing/3114/VendoredVariant.purs
@@ -7,9 +7,9 @@ import Prim.Row as Row
import Unsafe.Coerce (unsafeCoerce)
import Partial.Unsafe (unsafeCrashWith)
import Data.Symbol
+import Type.Proxy (Proxy(..))
-data FProxy (k :: Type -> Type) = FProxy
-data VariantF (f :: # Type) a
+data VariantF (f :: Row Type) a
newtype VariantFRep f a = VariantFRep
{ type :: String
@@ -23,9 +23,9 @@ case_ r = unsafeCrashWith case unsafeCoerce r of
on
:: forall sym f a b r1 r2
- . Row.Cons sym (FProxy f) r1 r2
+ . Row.Cons sym (Proxy f) r1 r2
=> IsSymbol sym
- => SProxy sym
+ => Proxy sym
-> (f a -> b)
-> (VariantF r1 a -> b)
-> VariantF r2 a
diff --git a/tests/purs/passing/3238.purs b/tests/purs/passing/3238.purs
new file mode 100644
index 0000000000..5c40f2379f
--- /dev/null
+++ b/tests/purs/passing/3238.purs
@@ -0,0 +1,14 @@
+module Main where
+
+import Effect.Console (log)
+
+class C a
+
+class FD a b | a -> b
+
+fn1 :: forall a b. FD a b => C b => a -> String
+fn1 _ = ""
+
+fn2 x = fn1 x
+
+main = log "Done"
diff --git a/tests/purs/passing/3329.purs b/tests/purs/passing/3329.purs
new file mode 100644
index 0000000000..5d531182d5
--- /dev/null
+++ b/tests/purs/passing/3329.purs
@@ -0,0 +1,34 @@
+module Main where
+
+import Prelude
+
+import Data.Either (Either(..))
+import Data.Maybe (Maybe(..))
+import Effect (Effect)
+import Effect.Console (log)
+
+class Inject f g where
+ inj :: f -> g
+ prj :: g -> Maybe f
+
+instance injectRefl :: Inject x x where
+ inj x = x
+ prj x = Just x
+else instance injectLeft :: Inject l (Either l r) where
+ inj x = Left x
+ prj (Left x) = Just x
+ prj _ = Nothing
+else instance injectRight :: Inject x r => Inject x (Either l r) where
+ inj x = Right (inj x)
+ prj (Right x) = prj x
+ prj _ = Nothing
+
+injL :: forall f g. f -> Either f g
+injL = inj
+
+main :: Effect Unit
+main = log "Done"
+ where
+ testInjLWithUnknowns a = case inj a of
+ Left a' -> a'
+ Right _ -> a
diff --git a/tests/purs/passing/3510.purs b/tests/purs/passing/3510.purs
new file mode 100644
index 0000000000..d3c0bf650c
--- /dev/null
+++ b/tests/purs/passing/3510.purs
@@ -0,0 +1,11 @@
+module Main where
+
+import Prelude (class Eq)
+import Effect.Console (log)
+
+data Maybe a = Just a | Nothing
+
+type T = Maybe Int
+derive instance eqT :: Eq T
+
+main = log "Done"
diff --git a/tests/purs/passing/3558-UpToDateDictsForHigherOrderFns.purs b/tests/purs/passing/3558-UpToDateDictsForHigherOrderFns.purs
new file mode 100644
index 0000000000..d5f067df92
--- /dev/null
+++ b/tests/purs/passing/3558-UpToDateDictsForHigherOrderFns.purs
@@ -0,0 +1,34 @@
+module Main where
+
+import Prelude (Unit)
+import Effect (Effect)
+import Effect.Console (log)
+import Record.Unsafe (unsafeGet)
+import Type.Data.Symbol (class IsSymbol, reflectSymbol)
+import Type.Row (class Cons) as Row
+import Type.Proxy (Proxy)
+
+newtype LBox row a = LBox (∀ r. (∀ lbl _1. Row.Cons lbl a _1 row ⇒ IsSymbol lbl ⇒ Proxy lbl → r) → r)
+
+unLBox ∷ ∀ row a r. (∀ lbl _1. Row.Cons lbl a _1 row ⇒ IsSymbol lbl ⇒ Proxy lbl → r) → LBox row a → r
+unLBox g (LBox f) = f g
+
+-- Example 1
+lboxIdentity ∷ ∀ row a. LBox row a → LBox row a
+lboxIdentity = unLBox \lbl → LBox \f → f lbl
+
+-- Example 2
+read ∷ ∀ row a. Record row → LBox row a → a
+read rec = unLBox \lbl → get lbl rec
+
+get
+ :: forall r r' l a
+ . IsSymbol l
+ => Row.Cons l a r' r
+ => Proxy l
+ -> Record r
+ -> a
+get l r = unsafeGet (reflectSymbol l) r
+
+main :: Effect Unit
+main = log "Done"
diff --git a/tests/purs/passing/3830.purs b/tests/purs/passing/3830.purs
new file mode 100644
index 0000000000..05d040fe78
--- /dev/null
+++ b/tests/purs/passing/3830.purs
@@ -0,0 +1,16 @@
+module Main where
+
+import Effect.Console (log)
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+data PProxy :: forall k1 (k2 :: k1). (Proxy k2 -> Type) -> Type
+data PProxy p = PProxy
+
+type PProxy' = PProxy
+
+test :: PProxy' Proxy
+test = PProxy
+
+main = log "Done"
diff --git a/tests/purs/passing/3941.purs b/tests/purs/passing/3941.purs
new file mode 100644
index 0000000000..321ccedacb
--- /dev/null
+++ b/tests/purs/passing/3941.purs
@@ -0,0 +1,25 @@
+module Main where
+
+import Effect.Console (log)
+import Unsafe.Coerce (unsafeCoerce)
+
+class TwoParams a b where
+ func :: a -> b
+
+instance equals :: TwoParams a a where
+ func a = a
+else
+instance any :: TwoParams a b where
+ func = unsafeCoerce
+
+testEquals :: forall a. a -> a
+testEquals = func -- with instance `equals`
+testAny :: Int -> Boolean
+testAny = func -- with instance `any`
+
+-- `a` and `m a` are never unifiable unless we have infinite types (and of course not)
+-- so expected that the instance `any` is chosen.
+thisShouldBeCompiled :: forall m a. a -> m a
+thisShouldBeCompiled = func
+
+main = log "Done"
diff --git a/tests/purs/passing/3957.purs b/tests/purs/passing/3957.purs
new file mode 100644
index 0000000000..159abead92
--- /dev/null
+++ b/tests/purs/passing/3957.purs
@@ -0,0 +1,39 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+import Test.Assert (assertEqual)
+
+data Maybe a = Nothing | Just a
+
+f :: Int -> Int
+f x = case x of
+ 0 -> 0
+ n | _ <- n -> f (x - 1)
+ _ -> f (x - 2)
+
+g :: Int -> Int
+g x = case x of
+ 0 -> 0
+ n | n == n, true -> g (x - 1)
+ _ -> g (x - 2)
+
+weirdsum :: Int -> (Int -> Maybe Int) -> Int -> Int
+weirdsum accum f n = case n of
+ 0 -> accum
+ x | Just y <- f x -> weirdsum (accum + y) f (n - 1)
+ _ -> weirdsum accum f (n - 1)
+
+tricksyinners :: Int -> Int -> Int
+tricksyinners accum x = case x of
+ 0 -> accum + f' x * f' x
+ n -> tricksyinners (accum + 2) (n - 1)
+ where
+ f' y = y + 3
+
+main = do
+ assertEqual { expected: 0, actual: f 100000 }
+ assertEqual { expected: 0, actual: g 100000 }
+ assertEqual { expected: 20, actual: weirdsum 0 (\x -> if x < 5 then Just (2 * x) else Nothing) 100000 }
+ assertEqual { expected: 200009, actual: tricksyinners 0 100000 }
+ log "Done"
diff --git a/tests/purs/passing/4035.purs b/tests/purs/passing/4035.purs
new file mode 100644
index 0000000000..2c40f30ce4
--- /dev/null
+++ b/tests/purs/passing/4035.purs
@@ -0,0 +1,14 @@
+module Main where
+
+import Effect.Console (log)
+import Other (Id)
+
+type Alias = Int
+
+type Wrapped :: forall k. (Type -> k) -> Row k -> Row k
+type Wrapped f r = (key :: f Alias | r)
+
+type Unwrapped :: Row Type -> Row Type
+type Unwrapped r = Wrapped Id r
+
+main = log "Done"
diff --git a/tests/purs/passing/4035/Other.purs b/tests/purs/passing/4035/Other.purs
new file mode 100644
index 0000000000..055b3c7831
--- /dev/null
+++ b/tests/purs/passing/4035/Other.purs
@@ -0,0 +1,4 @@
+module Other where
+
+type Id :: forall k. k -> k
+type Id a = a
diff --git a/tests/purs/passing/4038.purs b/tests/purs/passing/4038.purs
new file mode 100644
index 0000000000..e25ec5c383
--- /dev/null
+++ b/tests/purs/passing/4038.purs
@@ -0,0 +1,11 @@
+module Main where
+
+import Effect.Console (log)
+
+class A :: Constraint
+class A
+
+class B :: Constraint
+class A <= B
+
+main = log "Done"
diff --git a/tests/purs/passing/4101.purs b/tests/purs/passing/4101.purs
new file mode 100644
index 0000000000..41ffc77c7d
--- /dev/null
+++ b/tests/purs/passing/4101.purs
@@ -0,0 +1,20 @@
+module Main where
+
+import Effect.Console (log)
+
+import Lib
+
+class ClassA :: Type -> Type -> Constraint
+class ClassA t a
+
+class ClassB :: Type -> Type -> Constraint
+class ClassA t a <= ClassB t a
+
+data VariantF :: (Type -> Type) -> Type
+data VariantF fs
+data Expr
+
+instance a :: ClassA Expr (VariantF UNIT)
+instance b :: ClassB Expr (VariantF UNIT)
+
+main = log "Done"
diff --git a/tests/purs/passing/4101/Lib.purs b/tests/purs/passing/4101/Lib.purs
new file mode 100644
index 0000000000..fc5f850e7d
--- /dev/null
+++ b/tests/purs/passing/4101/Lib.purs
@@ -0,0 +1,9 @@
+module Lib where
+
+newtype Const :: forall k. Type -> k -> Type
+newtype Const a b = Const a
+
+data Unit = Unit
+
+type CONST = Const
+type UNIT = CONST Unit
diff --git a/tests/purs/passing/4105.purs b/tests/purs/passing/4105.purs
new file mode 100644
index 0000000000..4eb266baec
--- /dev/null
+++ b/tests/purs/passing/4105.purs
@@ -0,0 +1,12 @@
+module Main where
+
+import Prelude
+
+import Effect.Console (log)
+
+import Lib (Patch)
+
+newtype UpdateDto = UpdateDto Patch
+derive instance eqUpdateDto :: Eq UpdateDto
+
+main = log "Done"
diff --git a/tests/purs/passing/4105/Lib.purs b/tests/purs/passing/4105/Lib.purs
new file mode 100644
index 0000000000..89ccc3043d
--- /dev/null
+++ b/tests/purs/passing/4105/Lib.purs
@@ -0,0 +1,5 @@
+module Lib where
+
+type Template col = { bio :: col String }
+type Identity a = a
+type Patch = Template Identity
diff --git a/tests/purs/passing/4174.purs b/tests/purs/passing/4174.purs
new file mode 100644
index 0000000000..cf73216985
--- /dev/null
+++ b/tests/purs/passing/4174.purs
@@ -0,0 +1,16 @@
+module Main where
+
+import Data.Unit (Unit, unit)
+import Effect.Console (log)
+
+data Effect_Console = Effect_Console
+
+d :: Effect_Console
+d = Effect_Console
+
+newtype Data_Unit = Data_Unit Unit
+
+n :: Data_Unit
+n = Data_Unit unit
+
+main = log "Done"
diff --git a/tests/purs/passing/4179.js b/tests/purs/passing/4179.js
new file mode 100644
index 0000000000..e31f09f618
--- /dev/null
+++ b/tests/purs/passing/4179.js
@@ -0,0 +1,2 @@
+export const runtimeImportImpl = nothing => just => moduleName => body => () =>
+ import(`../${moduleName}/index.js`).then(() => body(nothing)(), err => body(just(err.toString()))());
diff --git a/tests/purs/passing/4179.purs b/tests/purs/passing/4179.purs
new file mode 100644
index 0000000000..4d105ede52
--- /dev/null
+++ b/tests/purs/passing/4179.purs
@@ -0,0 +1,73 @@
+module Main where
+
+import Prelude
+
+import Data.Maybe (Maybe(..))
+import Effect (Effect)
+import Effect.Console (log)
+import Test.Assert (assertEqual)
+import CustomAssert (assertThrows)
+
+force :: forall a b. (Unit -> b) -> b
+force f = f unit
+
+alpha = { backref: \_ -> bravo, x: 1 }
+bravo = force \_ -> alpha.x
+
+
+complicatedIdentity :: forall a. a -> a
+complicatedIdentity = h
+ where
+ -- This highly contrived function tests that escalating force is caught and
+ -- doesn't cause an infinite loop during compilation. ("Escalating force"
+ -- means that invoking `f` with two argument leads to `f` being invoked with
+ -- three arguments, and so on.)
+
+ -- If the escalating loop in `f` isn't taken into account, `h` might be
+ -- initialized before `g`, which will lead to a run-time error. The intended
+ -- behavior is to lazily initialize `g` and `h` together, and let the fact
+ -- that at run time `g` never actually dereferences `h` resolve the
+ -- initialization ordering.
+
+ f :: forall a. Int -> { tick :: a -> a, tock :: a -> a }
+ f n = { tick: if n <= 0 then identity else (f (n - 1)).tock identity, tock: \a -> g n a }
+
+ g :: forall a. Int -> a -> a
+ g = (\bit -> if bit then \n -> (f n).tick else const h) true
+
+ h :: forall a. a -> a
+ h = (\n -> (f n).tick) 10
+
+
+foreign import runtimeImportImpl :: forall a. Maybe String -> (String -> Maybe String) -> String -> (Maybe String -> Effect a) -> Effect a
+
+runtimeImport :: forall a. String -> (Maybe String -> Effect a) -> Effect a
+runtimeImport = runtimeImportImpl Nothing Just
+
+type ID = forall a. a -> a
+
+main = do
+ err <- assertThrows \_ ->
+ let
+ selfOwn = { a: 1, b: force \_ -> selfOwn.a }
+ in selfOwn
+ assertEqual { actual: err, expected: "ReferenceError: selfOwn was needed before it finished initializing (module Main, line 52)" }
+
+ err2 <- assertThrows \_ ->
+ let
+ f = (\_ -> { left: g identity, right: h identity }) unit
+
+ g :: ID -> ID
+ g x = (j x x x).right
+
+ h :: ID -> ID -> { left :: ID, right :: ID }
+ h x = j x x
+
+ j x y z = { left: x y z, right: f.left }
+ in f
+ assertEqual { actual: err2, expected: "ReferenceError: f was needed before it finished initializing (module Main, line 66)" }
+
+ assertEqual { actual: bravo, expected: 1 }
+ runtimeImport "InitializationError" \err3 -> do
+ assertEqual { actual: err3, expected: Just "ReferenceError: alphaArray was needed before it finished initializing (module InitializationError, line 0)" } -- TODO: fix the 0
+ log "Done"
diff --git a/tests/purs/passing/4179/CustomAssert.js b/tests/purs/passing/4179/CustomAssert.js
new file mode 100644
index 0000000000..24a6e2ab4d
--- /dev/null
+++ b/tests/purs/passing/4179/CustomAssert.js
@@ -0,0 +1,12 @@
+export var assertThrowsImpl = function (arg) {
+ return function (f) {
+ return function () {
+ try {
+ f(arg);
+ } catch (e) {
+ return e.toString();
+ }
+ throw new Error("Assertion failed: An error should have been thrown");
+ };
+ };
+};
diff --git a/tests/purs/passing/4179/CustomAssert.purs b/tests/purs/passing/4179/CustomAssert.purs
new file mode 100644
index 0000000000..16047a035c
--- /dev/null
+++ b/tests/purs/passing/4179/CustomAssert.purs
@@ -0,0 +1,10 @@
+module CustomAssert (assertThrows) where
+
+import Prelude
+
+import Effect (Effect)
+
+assertThrows :: forall a. (Unit -> a) -> Effect String
+assertThrows = assertThrowsImpl unit
+
+foreign import assertThrowsImpl :: forall a b. a -> (a -> b) -> Effect String
diff --git a/tests/purs/passing/4179/InitializationError.purs b/tests/purs/passing/4179/InitializationError.purs
new file mode 100644
index 0000000000..0368b48ead
--- /dev/null
+++ b/tests/purs/passing/4179/InitializationError.purs
@@ -0,0 +1,14 @@
+module InitializationError where
+
+class Alpha a where
+ alpha :: a Int -> a Int
+class Alpha a <= Bravo a
+class Bravo a <= Charlie a
+
+charlieAlpha :: forall a. Charlie a => a Int -> a Int
+charlieAlpha = alpha
+
+instance alphaArray :: Alpha Array where
+ alpha = charlieAlpha
+instance Bravo Array
+instance Charlie Array
diff --git a/tests/purs/passing/4180.purs b/tests/purs/passing/4180.purs
new file mode 100644
index 0000000000..aff735959f
--- /dev/null
+++ b/tests/purs/passing/4180.purs
@@ -0,0 +1,14 @@
+module Main where
+
+import Effect.Console (log)
+
+class C (t :: Type)
+instance C (f a)
+
+f :: C (Array String) => Int
+f = 0
+
+v :: Int
+v = f
+
+main = log "Done"
diff --git a/tests/purs/passing/4194.purs b/tests/purs/passing/4194.purs
new file mode 100644
index 0000000000..30ecb21e6b
--- /dev/null
+++ b/tests/purs/passing/4194.purs
@@ -0,0 +1,14 @@
+module Main where
+
+import Effect.Console (log)
+
+data Identity a
+data Maybe a
+
+class ErrorSemigroup o m w | w -> o m, o m -> w
+
+instance ErrorSemigroup (Identity o) (Identity m) (Identity w)
+
+instance ErrorSemigroup o (Maybe m) (Maybe w)
+
+main = log "Done"
diff --git a/tests/purs/passing/4200.purs b/tests/purs/passing/4200.purs
new file mode 100644
index 0000000000..5bcd6e4df9
--- /dev/null
+++ b/tests/purs/passing/4200.purs
@@ -0,0 +1,11 @@
+module Main where
+
+import Data.Newtype (class Newtype)
+import Effect.Console (log)
+import Lib (TAlias)
+
+newtype NewA a = NewA (TAlias Int)
+
+derive instance Newtype (NewA a) _
+
+main = log "Done"
diff --git a/tests/purs/passing/4200/Lib.purs b/tests/purs/passing/4200/Lib.purs
new file mode 100644
index 0000000000..645940a232
--- /dev/null
+++ b/tests/purs/passing/4200/Lib.purs
@@ -0,0 +1,7 @@
+module Lib where
+
+data T :: forall m. m -> Type
+data T msg = E
+
+type TAlias :: forall k. k -> Type
+type TAlias msg = T msg
diff --git a/tests/purs/passing/4229.purs b/tests/purs/passing/4229.purs
new file mode 100644
index 0000000000..4b254a442c
--- /dev/null
+++ b/tests/purs/passing/4229.purs
@@ -0,0 +1,13 @@
+module Main where
+
+import Effect.Console (log)
+import Partial.Unsafe (unsafePartial)
+
+data X = Prim
+
+f :: Partial => Int -> Int
+f 0 = 0
+
+f' = unsafePartial f
+
+main = log "Done"
diff --git a/tests/purs/passing/4310.purs b/tests/purs/passing/4310.purs
new file mode 100644
index 0000000000..9bbeda84d6
--- /dev/null
+++ b/tests/purs/passing/4310.purs
@@ -0,0 +1,8 @@
+module Main where
+
+import Effect.Console (log)
+import Lib
+
+main = do
+ let q = runTest (4 /\ 4)
+ log "Done"
diff --git a/tests/purs/passing/4310/Lib.purs b/tests/purs/passing/4310/Lib.purs
new file mode 100644
index 0000000000..1ccf3afd49
--- /dev/null
+++ b/tests/purs/passing/4310/Lib.purs
@@ -0,0 +1,17 @@
+module Lib where
+
+import Prelude
+
+data Tuple a b = Tuple a b
+
+infixr 6 Tuple as /\
+infixr 6 type Tuple as /\
+
+class Test a where
+ runTest :: a -> String
+
+instance Test Int where
+ runTest _ = "4"
+
+instance (Test a, Test b) => Test (a /\ b) where
+ runTest (a /\ b) = runTest a <> runTest b
diff --git a/tests/purs/passing/4357.purs b/tests/purs/passing/4357.purs
new file mode 100644
index 0000000000..65678d7c48
--- /dev/null
+++ b/tests/purs/passing/4357.purs
@@ -0,0 +1,29 @@
+module Main where
+
+import Prelude
+
+import Data.Foldable (fold)
+import Data.Maybe (Maybe(..))
+import Data.Monoid.Additive (Additive(..))
+import Effect.Console (log)
+
+data Foo = Foo Int | Bar Int
+
+g :: Foo -> Int
+g =
+ case _ of
+ a
+ | Bar z <- a
+ -> z
+ | Foo z <- a
+ -> z
+ | otherwise
+ -> 42
+
+-- solved as a consequence of #4358
+test :: Maybe Int -> Int
+test = case _ of
+ m | Just fold <- m -> fold
+ | otherwise -> case fold [] of Additive x -> x
+
+main = log "Done"
diff --git a/tests/purs/passing/4376.purs b/tests/purs/passing/4376.purs
new file mode 100644
index 0000000000..46c3463a00
--- /dev/null
+++ b/tests/purs/passing/4376.purs
@@ -0,0 +1,29 @@
+module Main where
+
+import Prelude
+import Prim.Row (class Union)
+
+import Data.Maybe (Maybe(..))
+import Data.Monoid (mempty)
+import Effect.Console (log)
+import Type.Proxy (Proxy(..))
+
+-- Make sure that record updates get monomorphized.
+asNothing :: forall a. { a :: Maybe a } -> { a :: Maybe a }
+asNothing = _ { a = Nothing }
+
+union :: forall a b c. Union a b c => Record a -> Record b -> Proxy c
+union _ _ = Proxy
+
+-- This fails to solve if neither is monomorphized.
+shouldSolve :: forall a b. Proxy ( a :: Maybe a, b :: Maybe b )
+shouldSolve = { a: Nothing } `union` { b: Nothing }
+
+-- Removes ConstrainedTypeUnified
+v1 :: { a :: Maybe Unit }
+v1 = { a : Just unit }
+
+v2 :: { a :: Maybe Unit }
+v2 = let v3 = v1 { a = mempty } in v3
+
+main = log "Done"
diff --git a/tests/purs/passing/4431-2.purs b/tests/purs/passing/4431-2.purs
new file mode 100644
index 0000000000..5d0d9823d6
--- /dev/null
+++ b/tests/purs/passing/4431-2.purs
@@ -0,0 +1,12 @@
+module Main where
+
+import Prelude
+import Data.Const (Const)
+import Effect.Console (log)
+
+data TypedCache :: (Type -> Type) -> Type -> Type
+data TypedCache key a = Get (key a)
+
+derive instance Functor (TypedCache (Const k))
+
+main = log "Done"
diff --git a/tests/purs/passing/4431.purs b/tests/purs/passing/4431.purs
new file mode 100644
index 0000000000..682117ef52
--- /dev/null
+++ b/tests/purs/passing/4431.purs
@@ -0,0 +1,11 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+data TypedCache :: (Type -> Type) -> Type -> Type
+data TypedCache key a = Get (key a)
+
+derive instance Functor k => Functor (TypedCache k)
+
+main = log "Done"
diff --git a/tests/purs/passing/4483.purs b/tests/purs/passing/4483.purs
new file mode 100644
index 0000000000..f2f202e304
--- /dev/null
+++ b/tests/purs/passing/4483.purs
@@ -0,0 +1,12 @@
+module Main where
+
+import Effect.Console (log)
+import Prim.TypeError
+
+class Foo t where
+ foo :: t -> String
+ bar :: Int -> t
+
+instance fooInt :: Fail (Text "can't use this") => Foo Int
+
+main = log "Done"
diff --git a/tests/purs/passing/4500.purs b/tests/purs/passing/4500.purs
new file mode 100644
index 0000000000..2e11a30d44
--- /dev/null
+++ b/tests/purs/passing/4500.purs
@@ -0,0 +1,15 @@
+module Main where
+
+import Prelude
+
+import Data.Reflectable (class Reflectable, reflectType)
+import Type.Proxy (Proxy(..))
+import Effect.Console (log)
+
+reflect :: forall @t v . Reflectable t v => v
+reflect = reflectType (Proxy @t)
+
+use :: String
+use = show { asdf: reflect @"asdf" }
+
+main = log "Done"
diff --git a/tests/purs/passing/4535.purs b/tests/purs/passing/4535.purs
new file mode 100644
index 0000000000..424ba6e7e5
--- /dev/null
+++ b/tests/purs/passing/4535.purs
@@ -0,0 +1,43 @@
+module Main where
+
+import Prelude
+
+import Data.Maybe (Maybe(..))
+import Data.Tuple.Nested ((/\), type (/\))
+import Effect (Effect)
+import Effect.Console (log)
+import Type.Proxy (Proxy(..))
+
+singleArgument :: forall @a. a -> Unit
+singleArgument _ = unit
+
+multiArgument :: forall @a @b. a -> b -> Unit
+multiArgument _ _ = unit
+
+singleApplication :: Int /\ Number -> Unit
+singleApplication = singleArgument @(Int /\ Number)
+
+-- Like expression applications, visible type applications are left-associative.
+-- This test accounts for subsequent type applications nested in this manner.
+appNestingWorks :: Int /\ Number -> Number /\ Int -> Unit
+appNestingWorks = multiArgument @(Int /\ Number) @(Number /\ Int)
+
+-- This test accounts for type applications nested within other AST nodes.
+otherNestingWorks :: Array (Maybe (Int /\ Number))
+otherNestingWorks = [Just @(Int /\ Number) (0 /\ 0.0), Just @(Int /\ Number) (1 /\ 1.0)]
+
+type InSynonym = Int /\ Number
+
+-- This test accounts for type synonyms used as type arguments.
+-- Since expansion happens during checking, InSynonym would expand
+-- to an already-desugared type operator. This test exists for the
+-- sake of redundancy.
+inSynonym :: InSynonym -> Unit
+inSynonym = singleArgument @InSynonym
+
+-- This test accounts for type operators used as type arguments directly.
+operatorAsArgument :: Proxy (/\)
+operatorAsArgument = Proxy @(/\)
+
+main :: Effect Unit
+main = log "Done"
diff --git a/tests/purs/passing/AppendInReverse.purs b/tests/purs/passing/AppendInReverse.purs
index b900657e59..572d531aa5 100644
--- a/tests/purs/passing/AppendInReverse.purs
+++ b/tests/purs/passing/AppendInReverse.purs
@@ -1,9 +1,9 @@
module Main where
import Prelude
-import Data.Symbol (SProxy(..))
import Prim.Symbol (class Append)
import Effect.Console (log)
+import Type.Proxy (Proxy(..))
class Balanced (sym :: Symbol)
@@ -15,20 +15,20 @@ instance balanced2
, Balanced sym2
) => Balanced sym
-balanced :: forall sym. Balanced sym => SProxy sym -> String
+balanced :: forall sym. Balanced sym => Proxy sym -> String
balanced _ = "ok"
b0 :: String
-b0 = balanced (SProxy :: SProxy "")
+b0 = balanced (Proxy :: Proxy "")
b1 :: String
-b1 = balanced (SProxy :: SProxy "()")
+b1 = balanced (Proxy :: Proxy "()")
b2 :: String
-b2 = balanced (SProxy :: SProxy "(())")
+b2 = balanced (Proxy :: Proxy "(())")
b3 :: String
-b3 = balanced (SProxy :: SProxy "((()))")
+b3 = balanced (Proxy :: Proxy "((()))")
main = do
log b0
diff --git a/tests/purs/passing/BigFunction.purs b/tests/purs/passing/BigFunction.purs
new file mode 100644
index 0000000000..b83642c4b4
--- /dev/null
+++ b/tests/purs/passing/BigFunction.purs
@@ -0,0 +1,140 @@
+module Main where
+
+import Prelude
+import Data.Maybe
+import Data.Array(index)
+import Effect.Console(log)
+
+main = let x = f [] in log "Done"
+
+lookup :: forall a. Int -> Array a -> Maybe a
+lookup = flip index
+
+f :: Array (Array Int) -> Int
+f [] = 0
+f [m] | Just x <- lookup 1 m = x
+f [m, mm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm = x + xx
+f [m, mm, mmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm = x + xx + xxx
+f [m, mm, mmm, mmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm = x + xx + xxx + xxxx
+f [m, mm, mmm, mmmm, mmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm = x + xx + xxx + xxxx + xxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [] = 0
+f [m] | Just x <- lookup 1 m = x
+f [m, mm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm = x + xx
+f [m, mm, mmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm = x + xx + xxx
+f [m, mm, mmm, mmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm = x + xx + xxx + xxxx
+f [m, mm, mmm, mmmm, mmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm = x + xx + xxx + xxxx + xxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f [m, mm, mmm, mmmm, mmmmm, mmmmmm, mmmmmmm, mmmmmmmm, mmmmmmmmm, mmmmmmmmmm, mmmmmmmmmmm, mmmmmmmmmmmm, mmmmmmmmmmmmm, mmmmmmmmmmmmmm, mmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] | Just x <- lookup 1 m, Just xx <- lookup 11 mm, Just xxx <- lookup 111 mmm, Just xxxx <- lookup 1111 mmmm, Just xxxxx <- lookup 11111 mmmmm, Just xxxxxx <- lookup 6 mmmmmm, Just xxxxxxx <- lookup 5 mmmmmmm, Just xxxxxxxx <- lookup 4 mmmmmmmm, Just xxxxxxxxx <- lookup 3 mmmmmmmmm, Just xxxxxxxxxx <- lookup 2 mmmmmmmmmm, Just xxxxxxxxxxx <- lookup 2 mmmmmmmmmmm, Just xxxxxxxxxxxx <- lookup 21 mmmmmmmmmmmm, Just xxxxxxxxxxxxx <- lookup 211 mmmmmmmmmmmmm, Just xxxxxxxxxxxxxx <- lookup 2111 mmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxx <- lookup 21111 mmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxx <- lookup 211111 mmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxx <- lookup 26 mmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxx <- lookup 25 mmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxx <- lookup 24 mmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxx <- lookup 23 mmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxx <- lookup 22 mmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxx <- lookup 221 mmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211 mmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22111 mmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 221111 mmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2211111 mmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 226 mmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2224 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2223 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 2222111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22221111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 222211111 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22226 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm, Just xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <- lookup 22225 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = x + xx + xxx + xxxx + xxxxx + xxxxxx + xxxxxxx + xxxxxxxx + xxxxxxxxx + xxxxxxxxxx + xxxxxxxxxxx + xxxxxxxxxxxx + xxxxxxxxxxxxx + xxxxxxxxxxxxxx + xxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+f _ = 2137
diff --git a/tests/purs/passing/BlockStringEdgeCases.purs b/tests/purs/passing/BlockStringEdgeCases.purs
new file mode 100644
index 0000000000..469df80274
--- /dev/null
+++ b/tests/purs/passing/BlockStringEdgeCases.purs
@@ -0,0 +1,30 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+import Test.Assert (assert')
+
+data Tuple a b = Tuple a b
+derive instance tupleEq :: (Eq a, Eq b) => Eq (Tuple a b)
+
+main = do
+ assert' "empty string" ("""""" == "")
+ assert' "quote" (""""""" == "\"")
+ assert' "starts with quote" (""""x""" == "\"x")
+ assert' "ends with quote" ("""x"""" == "x\"")
+ assert' "two quotes" ("""""""" == "\"\"")
+ assert' "starts with two quotes" ("""""x""" == "\"\"x")
+ assert' "ends with two quotes" ("""x""""" == "x\"\"")
+ assert' "starts and ends with two quotes" ("""""x""""" == "\"\"x\"\"")
+ assert' "mixture 1" ("""""x"y""z"""" == "\"\"x\"y\"\"z\"")
+ assert' "mixture 2" ("""x"y""z""" == "x\"y\"\"z")
+
+ -- These last tests are more about forbidding certain raw string literal
+ -- edge cases than about wanting to support mashing string literals against.
+ -- each other, which is techically legal but generally, if not universally,
+ -- a bad idea.
+ assert' "too many quotes 1" (Tuple """"""""" " == Tuple "\"\"" " ")
+ assert' "too many quotes 2" (Tuple """""""""" == Tuple "\"\"" "")
+ assert' "too many quotes 3" (Tuple """x"""""" " == Tuple "x\"\"" " ")
+ assert' "too many quotes 4" (Tuple """x""""""" == Tuple "x\"\"" "")
+ log "Done"
diff --git a/tests/purs/passing/CSEInitialDigitSymbols.purs b/tests/purs/passing/CSEInitialDigitSymbols.purs
new file mode 100644
index 0000000000..0a015754bc
--- /dev/null
+++ b/tests/purs/passing/CSEInitialDigitSymbols.purs
@@ -0,0 +1,16 @@
+module Main where
+
+import Data.Symbol (class IsSymbol, reflectSymbol)
+import Effect.Console (log)
+import Type.Proxy (Proxy(..))
+
+reflectSymbol' :: forall s. IsSymbol s => Proxy s -> String
+reflectSymbol' = reflectSymbol
+
+two = reflectSymbol (Proxy :: _ "2")
+two2 = reflectSymbol' (Proxy :: _ "2")
+
+twoThirty = reflectSymbol (Proxy :: _ "2:30")
+twoThirty2 = reflectSymbol' (Proxy :: _ "2:30")
+
+main = log "Done"
diff --git a/tests/purs/passing/Coercible.purs b/tests/purs/passing/Coercible.purs
new file mode 100644
index 0000000000..62e5507f92
--- /dev/null
+++ b/tests/purs/passing/Coercible.purs
@@ -0,0 +1,290 @@
+module Main where
+
+import Coercible.Lib (NTLib1(..), NTLib2(..), NTLib3)
+
+import Effect.Console (log)
+import Prim.Coerce (class Coercible)
+import Safe.Coerce (coerce)
+import Type.Proxy (Proxy)
+
+refl :: forall a. a -> a
+refl = coerce
+
+symm :: forall a b. Coercible a b => b -> a
+symm = coerce
+
+trans :: forall a b c. Coercible a b => Coercible b c => Proxy b -> a -> c
+trans _ = coerce
+
+trans' :: forall a b c. Coercible a b => Coercible c b => Proxy b -> a -> c
+trans' _ = coerce
+
+trans'' :: forall a b c d. Coercible a c => Coercible a d => Coercible d b => Proxy c -> Proxy d -> a -> b
+trans'' _ _ = coerce
+
+transSymm :: forall a b c. Coercible a b => Coercible b c => Proxy b -> c -> a
+transSymm _ = coerce
+
+type SynString = String
+
+newtype NTString1 = NTString1 SynString
+
+nt1ToString :: NTString1 -> String
+nt1ToString = coerce
+
+stringToNt1 :: String -> NTString1
+stringToNt1 = coerce
+
+toNT1 :: forall a. Coercible a String => a -> NTString1
+toNT1 = coerce
+
+toNT1Array :: forall a. Coercible a (Array String) => a -> Array NTString1
+toNT1Array = coerce
+
+newtype NTString2 = NTString2 String
+
+nt2ToNT1 :: NTString2 -> NTString1
+nt2ToNT1 = coerce
+
+newtype Id1 a = Id1 a
+newtype Id2 b = Id2 b
+
+id1ToId2 :: forall a. Id1 a -> Id2 a
+id1ToId2 = coerce
+
+id12ToId21 :: forall b. Id1 (Id2 b) -> Id2 (Id1 b)
+id12ToId21 = coerce
+
+newtype Ap f a = Ap (f a)
+
+apId1ToApId1 :: forall a b. Coercible a b => Ap Id1 a -> Ap Id1 b
+apId1ToApId1 = coerce
+
+apId1ToApId2 :: forall a. Ap Id1 a -> Ap Id2 a
+apId1ToApId2 = coerce
+
+newtype ApPolykind f = ApPolykind (f ())
+
+apPolykind :: forall f. ApPolykind f -> f ()
+apPolykind = coerce
+
+newtype Phantom1 a b = Phantom1 a
+
+phantom1TypeToPhantom1Symbol :: forall x (y :: Type) (z :: Symbol). Phantom1 x y -> Phantom1 x z
+phantom1TypeToPhantom1Symbol = coerce
+
+phantom1ToId12 :: forall x y. Phantom1 x y -> Id1 (Id2 x)
+phantom1ToId12 = coerce
+
+nested :: forall x y z. Phantom1 (Id1 (Phantom1 x y)) y -> Id2 (Phantom1 x (Phantom1 z z))
+nested = coerce
+
+id1IntToInt :: Id1 Int -> Int
+id1IntToInt = coerce
+
+id2IntToId1Int :: Id2 Int -> Id1 Int
+id2IntToId1Int = coerce
+
+newtype NTInt1 = NTInt1 Int
+
+id2NTToId1Nt :: Id2 NTInt1 -> Id1 NTInt1
+id2NTToId1Nt = coerce
+
+id2NTToId1Int :: Id2 NTInt1 -> Id1 Int
+id2NTToId1Int = coerce
+
+newtype NTFn1 a b = NTFn1 (a -> Int -> b)
+newtype NTFn2 x a b = NTFn2 (a -> x -> b)
+
+ntFn1ToNTFn2 :: forall a b. NTFn1 a b -> NTFn2 Int a b
+ntFn1ToNTFn2 = coerce
+
+libExposedCtorToId2 :: forall z. NTLib1 z -> Id2 z
+libExposedCtorToId2 = coerce
+
+libReExportedCtorToId2 :: forall z. NTLib2 z -> Id2 z
+libReExportedCtorToId2 = coerce
+
+libHiddenCtorRepresentational :: forall a b. Coercible (NTLib3 a a) (NTLib3 a b) => NTLib3 a a -> NTLib3 a b
+libHiddenCtorRepresentational = coerce
+
+newtype Roles1 a b c = Roles1 (Phantom1 b c)
+
+roles1ToSecond :: forall r s t. Roles1 r s t -> s
+roles1ToSecond = coerce
+
+data D a b = D a
+
+underD :: D NTString1 Boolean -> D NTString2 Int
+underD = coerce
+
+givenCanonicalSameTyVarEq :: forall a b c d e. Coercible a (D b c) => Coercible a (D d e) => Proxy a -> b -> d
+givenCanonicalSameTyVarEq _ = coerce
+
+givenCanonicalDiffTyVarEq1 :: forall a b c d e. Coercible a (D b c) => Coercible b d => a -> D d e
+givenCanonicalDiffTyVarEq1 = coerce
+
+givenCanonicalDiffTyVarEq2 :: forall f g a b. Coercible a (f b) => Coercible f g => Proxy f -> a -> g b
+givenCanonicalDiffTyVarEq2 _ = coerce
+
+newtype NTD a b c d = NTD (D b d)
+
+dToNTD :: forall i j k l. D j l -> NTD i (Id1 j) k (Phantom1 l k)
+dToNTD = coerce
+
+ntdToNTD :: forall i j k l. NTD i j k l -> NTD (Id1 k) (Phantom1 j k) Int Boolean
+ntdToNTD = coerce
+
+newtype RankN1 a b = RankN1 (forall r. r -> a)
+
+rankN1ToRankN1 :: RankN1 NTString1 Int -> RankN1 String Boolean
+rankN1ToRankN1 = coerce
+
+data RankN2 a = RankN2 (forall a. a -> a)
+
+rankN2ToRankN2 :: forall x y. RankN2 x -> RankN2 y
+rankN2ToRankN2 = coerce
+
+data RankN3 c = RankN3 (forall c. (forall c. c -> c) -> c)
+
+rankN3ToRankN3 :: forall x y. RankN3 x -> RankN3 y
+rankN3ToRankN3 = coerce
+
+data RankN4 z = RankN4 (forall c. (forall z. c -> z) -> c)
+
+rankN4ToRankN4 :: forall x y. RankN4 x -> RankN4 y
+rankN4ToRankN4 = coerce
+
+data Phantom2 a = Phantom
+
+data Rec1 a = Rec1 { f :: a }
+
+rec1ToRec1 :: Rec1 Int -> Rec1 (Id1 Int)
+rec1ToRec1 = coerce
+
+data Rec2 a b = Rec2 { f :: a, g :: Int, h :: b }
+
+rec2ToRec2 :: Rec2 Int (Phantom2 String) -> Rec2 (Id1 Int) (Phantom2 Int)
+rec2ToRec2 = coerce
+
+data Rec3 a = Rec3 {}
+
+rec3ToRec3 :: forall m n. Rec3 m -> Rec3 n
+rec3ToRec3 = coerce
+
+newtype Rec4 f = Rec4 (f {})
+
+unwrapRec4 :: forall f. Rec4 f -> f {}
+unwrapRec4 = coerce
+
+newtype Rec5 a f = Rec5 (f {})
+
+apRec4ToApRec5 :: forall a. Ap Rec4 Id1 -> Ap (Rec5 a) Id1
+apRec4ToApRec5 = coerce
+
+type Rec6 a = { f :: a }
+
+rec6ToRec6 :: Rec6 Int -> Rec6 (Id1 Int)
+rec6ToRec6 = coerce
+
+type Rec7 a b = { f :: a, g :: Int, h :: b }
+
+rec7ToRec7 :: Rec7 Int (Phantom2 String) -> Rec7 (Id1 Int) (Phantom2 Int)
+rec7ToRec7 = coerce
+
+type Rec8 r a = { f :: a | r }
+
+rec8ToRec8 :: forall r. Rec8 r Int -> Rec8 r (Id1 Int)
+rec8ToRec8 = coerce
+
+rec8ToRec8' :: forall r s. Coercible r s => Rec8 r Int -> Rec8 s (Id1 Int)
+rec8ToRec8' = coerce
+
+data Arr1 a b = Arr1 (Array a) (Array b)
+
+arr1ToArr1 :: Arr1 Int String -> Arr1 (Id1 Int) (Id2 String)
+arr1ToArr1 = coerce
+
+arr1ToArr1Phantom :: forall a. Arr1 (Phantom2 Int) String -> Arr1 (Phantom2 a) (Id2 String)
+arr1ToArr1Phantom = coerce
+
+foreign import data Foreign1 :: Type -> Type -> Type
+
+type role Foreign1 representational representational
+
+foreign1ToForeign1 :: Foreign1 NTString1 (Phantom2 Int) -> Foreign1 String (Phantom2 Boolean)
+foreign1ToForeign1 = coerce
+
+foreign import data Foreign2 :: Type -> Type -> Type
+
+type role Foreign2 phantom representational
+
+foreign2ToForeign2 :: Foreign2 NTString2 (Phantom2 Int) -> Foreign2 Int (Phantom2 Boolean)
+foreign2ToForeign2 = coerce
+
+data MyMap k v = MyMap k v
+
+type role MyMap nominal representational
+
+mapToMap :: forall k1 k2 a b. Coercible (MyMap k1 a) (MyMap k2 b) => MyMap k1 a -> MyMap k2 b
+mapToMap = coerce
+
+mapStringToMapString :: MyMap String String -> MyMap String NTString1
+mapStringToMapString = mapToMap
+
+class Unary a
+
+data Constrained1 a b = Constrained1 (Unary a => b)
+
+constrained1ToConstrained1 :: forall a b. Constrained1 a b -> Constrained1 a (Id1 b)
+constrained1ToConstrained1 = coerce
+
+data Constrained2 a = Constrained2 a (forall a. Unary a => a)
+
+type role Constrained2 representational
+
+-- "role" should only be a reserved word after "type"
+testRoleNotReserved :: String -> String
+testRoleNotReserved role = role
+
+-- "nominal", "representational" and "phantom" should only be reserved when in
+-- role signatures
+testRolesNotReserved :: String -> String -> String -> String
+testRolesNotReserved nominal representational phantom = ""
+
+data RoleNotReserved role = RoleNotReserved role
+
+-- Contextual keywords should be allowed unquoted in rows.
+type ContextualKeywords =
+ ( nominal :: String
+ , phantom :: String
+ , representational :: String
+ , role :: String
+ )
+
+newtype RecursiveRepresentational a
+ = RecursiveRepresentational (RecursiveRepresentational a)
+type role RecursiveRepresentational representational
+
+recursiveRepresentational :: forall a b. Coercible a b => RecursiveRepresentational a -> RecursiveRepresentational b
+recursiveRepresentational = coerce
+
+data MutuallyRecursivePhantom1 a
+ = MutuallyRecursivePhantom1 (MutuallyRecursivePhantom2 a)
+
+data MutuallyRecursivePhantom2 a
+ = MutuallyRecursivePhantom2 (MutuallyRecursivePhantom1 a)
+
+mutuallyRecursivePhantom :: forall a b. MutuallyRecursivePhantom1 a -> MutuallyRecursivePhantom1 b
+mutuallyRecursivePhantom = coerce
+
+data MutuallyRecursiveRepresentational1 a
+ = MutuallyRecursiveRepresentational1 a (MutuallyRecursiveRepresentational2 a)
+
+data MutuallyRecursiveRepresentational2 a
+ = MutuallyRecursiveRepresentational2 (MutuallyRecursiveRepresentational1 a)
+
+mutuallyRecursiveRepresentational :: forall a. MutuallyRecursiveRepresentational1 a -> MutuallyRecursiveRepresentational1 (Id1 a)
+mutuallyRecursiveRepresentational = coerce
+
+main = log (coerce (NTString1 "Done") :: String)
diff --git a/tests/purs/passing/Coercible/Lib.purs b/tests/purs/passing/Coercible/Lib.purs
new file mode 100644
index 0000000000..cca268cfba
--- /dev/null
+++ b/tests/purs/passing/Coercible/Lib.purs
@@ -0,0 +1,12 @@
+module Coercible.Lib
+ ( module Coercible.Lib2
+ , NTLib1 (..)
+ , NTLib3 (..)
+ ) where
+
+import Coercible.Lib2
+
+newtype NTLib1 a = NTLib1 a
+
+newtype NTLib3 a b = NTLib3 a
+type role NTLib3 representational representational
diff --git a/tests/purs/passing/Coercible/Lib2.purs b/tests/purs/passing/Coercible/Lib2.purs
new file mode 100644
index 0000000000..3fdef618d6
--- /dev/null
+++ b/tests/purs/passing/Coercible/Lib2.purs
@@ -0,0 +1,3 @@
+module Coercible.Lib2 where
+
+newtype NTLib2 a = NTLib2 a
diff --git a/tests/purs/passing/CyclicInstances.purs b/tests/purs/passing/CyclicInstances.purs
new file mode 100644
index 0000000000..f50358aa7e
--- /dev/null
+++ b/tests/purs/passing/CyclicInstances.purs
@@ -0,0 +1,29 @@
+module Main where
+
+import Prelude
+
+import Data.Generic.Rep (class Generic)
+import Data.Show.Generic (genericShow)
+import Effect.Console (log)
+
+newtype A = A B
+derive newtype instance Show A
+data B = B C
+ | Z
+derive instance Generic B _
+instance Show B where show x = genericShow x
+newtype C = C A
+derive instance Generic C _
+instance Show C where show = genericShow
+
+newtype A2 = A2 { x :: B2 }
+derive newtype instance Show A2
+data B2 = B2 C2
+ | Z2
+derive instance Generic B2 _
+instance Show B2 where show x = genericShow x
+newtype C2 = C2 A2
+derive instance Generic C2 _
+instance Show C2 where show = genericShow
+
+main = log "Done"
diff --git a/tests/purs/passing/DerivingBifunctor.purs b/tests/purs/passing/DerivingBifunctor.purs
new file mode 100644
index 0000000000..e5f7fc86a8
--- /dev/null
+++ b/tests/purs/passing/DerivingBifunctor.purs
@@ -0,0 +1,26 @@
+module Main where
+
+import Prelude
+
+import Data.Bifoldable (class Bifoldable)
+import Data.Bifunctor (class Bifunctor)
+import Data.Bitraversable (class Bitraversable)
+import Data.Predicate (Predicate)
+import Data.Tuple (Tuple)
+import Effect.Console (log)
+
+data Test f a b
+ = Test0
+ | Test1 (Array a) b
+ | Test2 Int (forall a. Array a -> Array a)
+ | Test3 Int (f a b) (f a Int) (f Int b)
+ | Test4 (Array (Tuple a Int)) (Tuple b Int)
+ | Test5 { nested :: Array { x :: f { a :: a } { b :: b } } }
+derive instance Bifunctor f => Bifunctor (Test f)
+derive instance Bifoldable f => Bifoldable (Test f)
+derive instance Bitraversable f => Bitraversable (Test f)
+
+data FromProAndContra a b = FromProAndContra (Predicate (a -> Int)) (Predicate b -> Int)
+derive instance Bifunctor FromProAndContra
+
+main = log "Done"
diff --git a/tests/purs/passing/DerivingClause.purs b/tests/purs/passing/DerivingClause.purs
new file mode 100644
index 0000000000..a7f5ed2adb
--- /dev/null
+++ b/tests/purs/passing/DerivingClause.purs
@@ -0,0 +1,53 @@
+module Main where
+
+import Prelude
+
+import Data.Bifunctor (class Bifunctor, bimap)
+import Data.Generic.Rep (class Generic)
+import Data.Newtype (class Newtype)
+import Data.Foldable (class Foldable, foldMap)
+import Data.Traversable (class Traversable)
+import Effect (Effect)
+import Effect.Console (log)
+import Test.Assert
+
+data Color = Red | Green | Blue
+ derive (Eq, Ord)
+
+newtype Name = Name String
+ derive (Eq, Ord)
+
+data List a = Nil | Cons a (List a)
+ derive (Functor, Foldable, Traversable)
+
+data Either2 a b = Left2 a | Right2 b
+ derive (Bifunctor)
+
+derive instance Eq a => Eq (Either2 a a)
+
+data Direction = North | South | East | West
+ derive (Generic)
+
+newtype Wrapper = Wrapper String
+ derive (Newtype)
+
+data Pair a = Pair a a
+ derive (Functor)
+
+data Box a = Empty | Full a
+ derive (Functor)
+
+derive instance Eq a => Eq (Box a)
+
+main :: Effect Unit
+main = do
+ assert $ Red == Red
+ assert $ Red < Green
+ assert $ Name "Alice" == Name "Alice"
+ assert $ foldMap show (Cons 1 (Cons 2 Nil)) == "12"
+ assert $ bimap (_ + 1) (_ * 2) (Left2 3) == Left2 4
+ assert $ map (_ + 1) (Full 1) == Full 2
+ assert $ case map (_ + 1) (Pair 1 2) of
+ Pair 2 3 -> true
+ _ -> false
+ log "Done"
diff --git a/tests/purs/passing/DerivingContravariant.purs b/tests/purs/passing/DerivingContravariant.purs
new file mode 100644
index 0000000000..7816e5b319
--- /dev/null
+++ b/tests/purs/passing/DerivingContravariant.purs
@@ -0,0 +1,20 @@
+module Main where
+
+import Prelude
+
+import Data.Functor.Contravariant (class Contravariant)
+import Data.Predicate (Predicate)
+import Data.Tuple (Tuple)
+import Effect.Console (log)
+
+data Test f a
+ = Test0
+ | Test1 (Predicate a)
+ | Test2 (Predicate (Predicate (Predicate a)))
+ | Test3 Int (forall a. Array a -> Array a)
+ | Test4 Int (f a)
+ | Test5 (Array (a -> Int)) (Tuple (Predicate a) Int)
+ | Test6 { nested :: Array { x :: f { a :: a } } }
+derive instance Contravariant f => Contravariant (Test f)
+
+main = log "Done"
diff --git a/tests/purs/passing/DerivingFoldable.purs b/tests/purs/passing/DerivingFoldable.purs
new file mode 100644
index 0000000000..0b9461c660
--- /dev/null
+++ b/tests/purs/passing/DerivingFoldable.purs
@@ -0,0 +1,89 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+import Data.Foldable (class Foldable, foldl, foldr, foldMap)
+import Test.Assert
+
+-- Fold is done in alphabetical ordering of labels,
+-- not their order in definition
+type RecordFields f a =
+ { a :: a
+ , zArrayA :: Array a
+ , fa :: f a
+ , ignore :: Int
+ , arrayIgnore :: Array Int
+ , fIgnore :: f Int
+ }
+
+data M f a
+ = M0
+ | M1 a (Array a)
+ | M2 Int (forall a. Array a -> Array a)
+ | M3 (f a)
+ | M4 (RecordFields f a)
+ | M5 { nested :: RecordFields f a }
+ | M6 Int a (Array Int) (Array a) (f a) (f Int) (RecordFields f a) { nested :: RecordFields f a }
+ | M7 (f (f { nested :: RecordFields f a }))
+
+derive instance foldableM :: Foldable f => Foldable (M f)
+
+type MArrStr = M Array String
+
+foldlStr :: forall f. Foldable f => f String -> String
+foldlStr = foldl (\acc next -> acc <> "<" <> next) "Start"
+
+foldrStr :: forall f. Foldable f => f String -> String
+foldrStr = foldr (\next acc -> next <> ">" <> acc) "Start"
+
+foldMapStr :: forall f. Foldable f => f String -> String
+foldMapStr = foldMap identity
+
+m0 = M0 :: MArrStr
+m1 = M1 "a" ["b", "c"] :: MArrStr
+m2 = M2 0 identity :: MArrStr
+m3 = M3 ["a", "b", "c"] :: MArrStr
+m4 = M4 recordValue :: MArrStr
+m5 = M5 { nested: recordValue } :: MArrStr
+m6 = M6 1 "a" [] ["b"] ["c"] [] recordValue { nested: recordValue } :: MArrStr
+m7 = M7 [[{ nested: recordValue }]] :: MArrStr
+
+recordValue :: RecordFields Array String
+recordValue =
+ { a: "a"
+ , zArrayA: ["c"]
+ , fa: ["b"]
+ , ignore: 1
+ , arrayIgnore: [2, 3]
+ , fIgnore: [4]
+ }
+
+main = do
+ assertEqual' "foldl - M0" { expected: "Start", actual: foldlStr m0 }
+ assertEqual' "foldl - M1" { expected: "Startb>c>Start", actual: foldrStr m1 }
+ assertEqual' "foldr - M2" { expected: "Start", actual: foldrStr m2 }
+ assertEqual' "foldr - M3" { expected: "a>b>c>Start", actual: foldrStr m3 }
+ assertEqual' "foldr - M4" { expected: "a>b>c>Start", actual: foldrStr m4 }
+ assertEqual' "foldr - M5" { expected: "a>b>c>Start", actual: foldrStr m5 }
+ assertEqual' "foldr - M6" { expected: "a>b>c>a>b>c>a>b>c>Start", actual: foldrStr m6 }
+ assertEqual' "foldr - M7" { expected: "a>b>c>Start", actual: foldrStr m7 }
+
+ assertEqual' "foldMap - M0" { expected: "", actual: foldMapStr m0 }
+ assertEqual' "foldMap - M1" { expected: "abc", actual: foldMapStr m1 }
+ assertEqual' "foldMap - M2" { expected: "", actual: foldMapStr m2 }
+ assertEqual' "foldMap - M3" { expected: "abc", actual: foldMapStr m3 }
+ assertEqual' "foldMap - M4" { expected: "abc", actual: foldMapStr m4 }
+ assertEqual' "foldMap - M5" { expected: "abc", actual: foldMapStr m5 }
+ assertEqual' "foldMap - M6" { expected: "abcabcabc", actual: foldMapStr m6 }
+ assertEqual' "foldMap - M7" { expected: "abc", actual: foldMapStr m7 }
+
+ log "Done"
diff --git a/tests/purs/passing/DerivingFunctor.purs b/tests/purs/passing/DerivingFunctor.purs
index f46c7c8d5f..de40593ad2 100644
--- a/tests/purs/passing/DerivingFunctor.purs
+++ b/tests/purs/passing/DerivingFunctor.purs
@@ -3,34 +3,122 @@ module Main where
import Prelude
import Data.Eq (class Eq1)
import Effect.Console (log)
+import Data.List (List(..), (:))
+import Data.Tuple (Tuple(..))
import Test.Assert
-type MyRecord a = { myField :: a }
+type RecordFields f a =
+ { a :: a
+ , zArrayA :: Array a
+ , fa :: f a
+ , ignore :: Int
+ , recursiveA :: Array (Tuple Int (Array a))
+ , arrayIgnore :: Array Int
+ , fIgnore :: f Int
+ , empty :: {}
+ }
data M f a
= M0 a (Array a)
| M1 Int
| M2 (f a)
- | M3 { foo :: Int, bar :: a, baz :: f a }
- | M4 (MyRecord a)
+ | M3 (RecordFields f a)
+ | M4 { nested :: RecordFields f a }
+ | M5 Int a (Array Int) (Array a) (f a) (f Int) (RecordFields f a) { nested :: RecordFields f a }
+ | M6 (Array (Array (Array a)))
derive instance eqM :: (Eq1 f, Eq a) => Eq (M f a)
derive instance functorM :: Functor f => Functor (M f)
+type MA = M Array
+
+m0L = M0 0 [1, 2] :: MA Int
+m0R = M0 "0" ["1", "2"] :: MA String
+
+m1L = M1 0 :: MA Int
+m1R = M1 0 :: MA String
+
+m2L = M2 [0, 1] :: MA Int
+m2R = M2 ["0", "1"] :: MA String
+
+m3L = M3 recordValueL :: MA Int
+m3R = M3 recordValueR :: MA String
+
+m4L = M4 { nested: recordValueL } :: MA Int
+m4R = M4 { nested: recordValueR } :: MA String
+
+m5L = M5 0 1 [2, 3] [3, 4] [5, 6] [7, 8] recordValueL { nested: recordValueL } :: MA Int
+m5R = M5 0 "1" [2, 3] ["3", "4"] ["5", "6"] [7, 8] recordValueR { nested: recordValueR } :: MA String
+
+recordValueL :: RecordFields Array Int
+recordValueL = { a: 71, zArrayA: [72], fa: [73], ignore: 91, recursiveA: [ Tuple 1 [1], Tuple 2 [2] ], arrayIgnore: [92, 93], fIgnore: [94], empty: {} }
+
+recordValueR :: RecordFields Array String
+recordValueR = { a: "71", zArrayA: ["72"], fa: ["73"], ignore: 91, recursiveA: [ Tuple 1 ["1"], Tuple 2 ["2"] ], arrayIgnore: [92, 93], fIgnore: [94], empty: {} }
+
+m6L = M6 [[[1, 2]]] :: MA Int
+m6R = M6 [[["1", "2"]]] :: MA String
+
+maTests = do
+ assert' "map - M0" $ map show m0L == m0R
+ assert' "map - M1" $ map show m1L == m1R
+ assert' "map - M2" $ map show m2L == m2R
+ assert' "map - M3" $ map show m3L == m3R
+ assert' "map - M4" $ map show m4L == m4R
+ assert' "map - M5" $ map show m5L == m5R
+ assert' "map - M6" $ map show m6L == m6R
+
+data Fun1 a = Fun1 (Int -> Int -> a)
+derive instance Functor Fun1
+
+f1Test = do
+ assert' "map - Fun1" do
+ let
+ fn = show
+ left a b = a + b
+ right a b = fn $ left a b
+ Fun1 left' = map fn $ Fun1 left
+ left' 1 2 == right 1 2
+
+data Fun2 a = Fun2 (Int -> Int -> Array (Array a))
+derive instance Functor Fun2
+
+f2Test = do
+ assert' "map - Fun2" do
+ let
+ fn = show
+ left a b = [[a + b]]
+ right a b = map (map fn) $ left a b
+ Fun2 left' = map fn $ Fun2 left
+ left' 1 2 == right 1 2
+
+data Fun3 f a = Fun3 (Unit -> Array (f (Array { nested :: RecordFields f a })))
+derive instance Functor f => Functor (Fun3 f)
+
+f3Test = do
+ assert' "map - Fun3" do
+ let
+ left _ = [[[{ nested: recordValueL }]]]
+ right _ = [[[{ nested: recordValueR }]]]
+ Fun3 left' = map show $ Fun3 left
+ left' unit == right unit
+
data T a = T (forall t. Show t => t -> a)
derive instance functorT :: Functor T
-type MA = M Array
+taTests = do
+ case map show (T \_ -> 42) of
+ T f -> assert' "map show T" $ f "hello" == "42"
+ _ -> assert' "map show T" false
-main = do
- assert $ map show (M0 0 [1, 2] :: MA Int) == M0 "0" ["1", "2"]
- assert $ map show (M1 0 :: MA Int) == M1 0
- assert $ map show (M2 [0, 1] :: MA Int) == M2 ["0", "1"]
- assert $ map show (M3 {foo: 0, bar: 1, baz: [2, 3]} :: MA Int) == M3 {foo: 0, bar: "1", baz: ["2", "3"]}
- assert $ map show (M4 { myField: 42 }) == (M4 { myField: "42" } :: MA String)
+funTests = do
+ f1Test
+ f2Test
+ f3Test
+ taTests
- case map show (T \_ -> 42) of
- T f -> assert $ f "hello" == "42"
- _ -> assert false
+main = do
+ maTests
+ funTests
log "Done"
diff --git a/tests/purs/passing/DerivingFunctorFromBi.purs b/tests/purs/passing/DerivingFunctorFromBi.purs
new file mode 100644
index 0000000000..f19bc3c913
--- /dev/null
+++ b/tests/purs/passing/DerivingFunctorFromBi.purs
@@ -0,0 +1,18 @@
+module Main where
+
+import Prelude
+
+import Data.Foldable (class Foldable)
+import Data.Traversable (class Traversable)
+import Data.Tuple (Tuple)
+import Effect.Console (log)
+
+data Test a
+ = Test1 (Tuple a Int)
+ | Test2 (Tuple (Array a) a)
+ | Test3 { x :: Tuple { a :: a } Int, y :: Tuple { a :: Array a } { a :: a } }
+derive instance Functor Test
+derive instance Foldable Test
+derive instance Traversable Test
+
+main = log "Done"
diff --git a/tests/purs/passing/DerivingFunctorFromContra.purs b/tests/purs/passing/DerivingFunctorFromContra.purs
new file mode 100644
index 0000000000..0eed77feb8
--- /dev/null
+++ b/tests/purs/passing/DerivingFunctorFromContra.purs
@@ -0,0 +1,13 @@
+module Main where
+
+import Prelude
+
+import Data.Predicate (Predicate)
+import Effect.Console (log)
+
+data Test a
+ = Test1 (Predicate (Predicate a))
+ | Test2 { x :: Predicate { y :: Predicate a } }
+derive instance Functor Test
+
+main = log "Done"
diff --git a/tests/purs/passing/DerivingFunctorFromPro.purs b/tests/purs/passing/DerivingFunctorFromPro.purs
new file mode 100644
index 0000000000..dc038e9c09
--- /dev/null
+++ b/tests/purs/passing/DerivingFunctorFromPro.purs
@@ -0,0 +1,16 @@
+module Main where
+
+-- Note that Data.Profunctor is not in the dependencies of any types imported
+-- here. The package that contains that module must be a dependency of the test
+-- project.
+
+import Prelude
+
+import Effect.Console (log)
+
+data Test a
+ = Test1 ((Array a -> Int) -> Int)
+ | Test2 { f :: ({ a :: a } -> Int) -> Int }
+derive instance Functor Test
+
+main = log "Done"
diff --git a/tests/purs/passing/DerivingFunctorPrefersSimplerClasses.purs b/tests/purs/passing/DerivingFunctorPrefersSimplerClasses.purs
new file mode 100644
index 0000000000..5051f5d145
--- /dev/null
+++ b/tests/purs/passing/DerivingFunctorPrefersSimplerClasses.purs
@@ -0,0 +1,46 @@
+module Main where
+
+import Prelude
+
+import Data.Bifunctor (class Bifunctor)
+import Data.Profunctor (class Profunctor)
+import Effect (Effect)
+import Effect.Console (log)
+import Test.Assert (assert')
+
+newtype MonoAndBi a b = MonoAndBi (Effect Unit)
+derive instance Functor (MonoAndBi a)
+instance Bifunctor MonoAndBi where
+ bimap _ _ _ = MonoAndBi (assert' "Bifunctor instance was used but the Functor instance was expected" false)
+
+newtype Test1 a = Test1 (MonoAndBi Int a)
+derive instance Functor Test1
+
+data ExclusivelyBi a b
+derive instance Bifunctor ExclusivelyBi
+
+newtype Test2 a = Test2 (ExclusivelyBi Int a)
+derive instance Functor Test2
+
+newtype MonoAndPro a b = MonoAndPro (Effect Unit)
+derive instance Functor (MonoAndPro a)
+instance Profunctor MonoAndPro where
+ dimap _ _ _ = MonoAndPro (assert' "Profunctor instance was used but the Functor instance was expected" false)
+
+newtype Test3 a = Test3 (MonoAndPro Int a)
+derive instance Functor Test3
+
+data ExclusivelyPro a b
+derive instance Profunctor ExclusivelyPro
+
+newtype Test4 a = Test4 (ExclusivelyPro Int a)
+derive instance Functor Test4
+
+main = do
+ let t = Test1 (MonoAndBi (pure unit))
+ let Test1 (MonoAndBi result1) = map identity t
+ result1
+ let t = Test3 (MonoAndPro (pure unit))
+ let Test3 (MonoAndPro result3) = map identity t
+ result3
+ log "Done"
diff --git a/tests/purs/passing/DerivingProfunctor.purs b/tests/purs/passing/DerivingProfunctor.purs
new file mode 100644
index 0000000000..b8a1cf95b9
--- /dev/null
+++ b/tests/purs/passing/DerivingProfunctor.purs
@@ -0,0 +1,19 @@
+module Main where
+
+import Prelude
+
+import Data.Predicate (Predicate)
+import Data.Profunctor (class Profunctor)
+import Data.Tuple (Tuple)
+import Effect.Console (log)
+
+data Test f a b
+ = Test0
+ | Test1 (Predicate a) b
+ | Test2 Int (forall a. Array a -> Array a)
+ | Test3 Int (f a b) (f a Int) (f Int b)
+ | Test4 (Array (a -> Int)) (Tuple b Int)
+ | Test5 { nested :: Array { x :: f { a :: a } { b :: b } } }
+derive instance Profunctor f => Profunctor (Test f)
+
+main = log "Done"
diff --git a/tests/purs/passing/DerivingTraversable.purs b/tests/purs/passing/DerivingTraversable.purs
new file mode 100644
index 0000000000..c7ef3cb8a7
--- /dev/null
+++ b/tests/purs/passing/DerivingTraversable.purs
@@ -0,0 +1,110 @@
+module Main where
+
+import Prelude
+
+import Effect.Console (log)
+import Data.Eq (class Eq1)
+import Data.Foldable (class Foldable)
+import Data.Traversable (class Traversable, traverse, sequence)
+import Test.Assert
+
+-- Traverse order is done in alphabetical ordering of labels,
+-- not their order in definition
+type RecordFields f a =
+ { a :: a
+ , zArrayA :: Array a
+ , fa :: f a
+ , ignore :: Int
+ , arrayIgnore :: Array Int
+ , fIgnore :: f Int
+ }
+
+data M f a
+ = M0
+ | M1 a (Array a)
+ | M2 Int
+ | M3 (f a)
+ | M4 (RecordFields f a)
+ | M5 { nested :: RecordFields f a }
+ | M6 Int a (Array Int) (Array a) (f a) (f Int) (RecordFields f a) { nested :: RecordFields f a }
+ | M7 (f (f { nested :: RecordFields f a }))
+
+-- Note: all 4 of these constraints are needed to compile this code
+derive instance
+ ( Eq1 f
+ , Eq (f (f { nested :: RecordFields f a }))
+ , Eq (f { nested :: RecordFields f a })
+ , Eq a
+ ) => Eq (M f a)
+derive instance Functor f => Functor (M f)
+derive instance Foldable f => Foldable (M f)
+derive instance Traversable f => Traversable (M f)
+
+type MArrStr = M Array String
+
+traverseStr :: forall f. Traversable f => f String -> Array (f String)
+traverseStr = traverse pure
+
+sequenceStr :: forall f. Traversable f => f (Array String) -> Array (f String)
+sequenceStr = sequence
+
+m0 = M0 :: MArrStr
+m1 = M1 "a" ["b", "c"] :: MArrStr
+m2 = M2 0 :: MArrStr
+m3 = M3 ["a", "b", "c"] :: MArrStr
+m4 = M4 recordValue :: MArrStr
+m5 = M5 { nested: recordValue } :: MArrStr
+m6 = M6 1 "a" [] ["b"] ["c"] [] recordValue { nested: recordValue } :: MArrStr
+m7 = M7 [ [ { nested: recordValue } ] ] :: MArrStr
+
+recordValue :: RecordFields Array String
+recordValue =
+ { a: "a"
+ , zArrayA: ["c"]
+ , fa: ["b"]
+ , ignore: 1
+ , arrayIgnore: [2, 3]
+ , fIgnore: [4]
+ }
+
+type MArrArrStr = M Array (Array String)
+
+m0' = M0 :: MArrArrStr
+m1' = M1 ["a"] [["b"], ["c"]] :: MArrArrStr
+m2' = M2 0 :: MArrArrStr
+m3' = M3 [["a"], ["b"], ["c"]] :: MArrArrStr
+m4' = M4 recordValue' :: MArrArrStr
+m5' = M5 { nested: recordValue' } :: MArrArrStr
+m6' = M6 1 ["a"] [] [["b"]] [["c"]] [] recordValue' { nested: recordValue' } :: MArrArrStr
+m7' = M7 [ [ { nested: recordValue' } ] ] :: MArrArrStr
+
+recordValue' :: RecordFields Array (Array String)
+recordValue' =
+ { a: ["a"]
+ , zArrayA: [["c"]]
+ , fa: [["b"]]
+ , ignore: 1
+ , arrayIgnore: [2, 3]
+ , fIgnore: [4]
+ }
+
+main = do
+ assert' "traverse - m0" $ traverseStr m0 == [m0]
+ assert' "traverse - m1" $ traverseStr m1 == [m1]
+ assert' "traverse - m2" $ traverseStr m2 == [m2]
+ assert' "traverse - m3" $ traverseStr m3 == [m3]
+ assert' "traverse - m4" $ traverseStr m4 == [m4]
+ assert' "traverse - m5" $ traverseStr m5 == [m5]
+ assert' "traverse - m6" $ traverseStr m6 == [m6]
+ assert' "traverse - m7" $ traverseStr m7 == [m7]
+
+ assert' "sequence - m0" $ sequenceStr m0' == [m0]
+ assert' "sequence - m1" $ sequenceStr m1' == [m1]
+ assert' "sequence - m2" $ sequenceStr m2' == [m2]
+ assert' "sequence - m3" $ sequenceStr m3' == [m3]
+ assert' "sequence - m4" $ sequenceStr m4' == [m4]
+ assert' "sequence - m5" $ sequenceStr m5' == [m5]
+ assert' "sequence - m6" $ sequenceStr m6' == [m6]
+ assert' "sequence - m7" $ sequenceStr m7' == [m7]
+
+ log "Done"
diff --git a/tests/purs/passing/DuplicateProperties.purs b/tests/purs/passing/DuplicateProperties.purs
index 238a9f221b..d98d14be54 100644
--- a/tests/purs/passing/DuplicateProperties.purs
+++ b/tests/purs/passing/DuplicateProperties.purs
@@ -2,25 +2,22 @@ module Main where
import Prelude
import Effect.Console (log)
+import Type.Proxy (Proxy(..))
-data RProxy (r :: # Type) = RProxy
+subtractX :: forall r a. Proxy (x :: a | r) -> Proxy r
+subtractX Proxy = Proxy
-data Proxy (a :: Type) = Proxy
+extractX :: forall r a. Proxy (x :: a | r) -> Proxy a
+extractX Proxy = Proxy
-subtractX :: forall r a. RProxy (x :: a | r) -> RProxy r
-subtractX RProxy = RProxy
-
-extractX :: forall r a. RProxy (x :: a | r) -> Proxy a
-extractX RProxy = Proxy
-
-hasX :: forall r a b. RProxy (x :: a, y :: b | r)
-hasX = RProxy
+hasX :: forall r a b. Proxy (x :: a, y :: b | r)
+hasX = Proxy
test1 = subtractX (subtractX hasX)
test2
:: forall r a b
- . RProxy (x :: a, x :: b, x :: Int | r)
+ . Proxy (x :: a, x :: b, x :: Int | r)
-> Proxy Int
test2 x = extractX (subtractX (subtractX x))
diff --git a/tests/purs/passing/ESFFIFunctionConst.js b/tests/purs/passing/ESFFIFunctionConst.js
new file mode 100644
index 0000000000..d09301bc40
--- /dev/null
+++ b/tests/purs/passing/ESFFIFunctionConst.js
@@ -0,0 +1,3 @@
+export const functionName = function (a) {
+ return a;
+}
diff --git a/tests/purs/passing/ESFFIFunctionConst.purs b/tests/purs/passing/ESFFIFunctionConst.purs
new file mode 100644
index 0000000000..ad59f5d8ab
--- /dev/null
+++ b/tests/purs/passing/ESFFIFunctionConst.purs
@@ -0,0 +1,8 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+foreign import functionName :: forall a. a -> a
+
+main = log "Done"
diff --git a/tests/purs/passing/ESFFIFunctionFunction.js b/tests/purs/passing/ESFFIFunctionFunction.js
new file mode 100644
index 0000000000..b77cd5a262
--- /dev/null
+++ b/tests/purs/passing/ESFFIFunctionFunction.js
@@ -0,0 +1,3 @@
+export function functionName(a) {
+ return a;
+}
diff --git a/tests/purs/passing/ESFFIFunctionFunction.purs b/tests/purs/passing/ESFFIFunctionFunction.purs
new file mode 100644
index 0000000000..ad59f5d8ab
--- /dev/null
+++ b/tests/purs/passing/ESFFIFunctionFunction.purs
@@ -0,0 +1,8 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+foreign import functionName :: forall a. a -> a
+
+main = log "Done"
diff --git a/tests/purs/passing/ESFFIFunctionVar.js b/tests/purs/passing/ESFFIFunctionVar.js
new file mode 100644
index 0000000000..e2a2a85d8d
--- /dev/null
+++ b/tests/purs/passing/ESFFIFunctionVar.js
@@ -0,0 +1,3 @@
+export var functionName = function (a) {
+ return a;
+}
diff --git a/tests/purs/passing/ESFFIFunctionVar.purs b/tests/purs/passing/ESFFIFunctionVar.purs
new file mode 100644
index 0000000000..ad59f5d8ab
--- /dev/null
+++ b/tests/purs/passing/ESFFIFunctionVar.purs
@@ -0,0 +1,8 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+foreign import functionName :: forall a. a -> a
+
+main = log "Done"
diff --git a/tests/purs/passing/ESFFIValueConst1.js b/tests/purs/passing/ESFFIValueConst1.js
new file mode 100644
index 0000000000..efeee5db16
--- /dev/null
+++ b/tests/purs/passing/ESFFIValueConst1.js
@@ -0,0 +1 @@
+export const value = 1;
diff --git a/tests/purs/passing/ESFFIValueConst1.purs b/tests/purs/passing/ESFFIValueConst1.purs
new file mode 100644
index 0000000000..f2b492eb75
--- /dev/null
+++ b/tests/purs/passing/ESFFIValueConst1.purs
@@ -0,0 +1,8 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+foreign import value :: Int
+
+main = log "Done"
diff --git a/tests/purs/passing/ESFFIValueVar.js b/tests/purs/passing/ESFFIValueVar.js
new file mode 100644
index 0000000000..7a5eae2dbb
--- /dev/null
+++ b/tests/purs/passing/ESFFIValueVar.js
@@ -0,0 +1 @@
+export var value = 1;
diff --git a/tests/purs/passing/ESFFIValueVar.purs b/tests/purs/passing/ESFFIValueVar.purs
new file mode 100644
index 0000000000..f2b492eb75
--- /dev/null
+++ b/tests/purs/passing/ESFFIValueVar.purs
@@ -0,0 +1,8 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+foreign import value :: Int
+
+main = log "Done"
diff --git a/tests/purs/passing/EffFn.js b/tests/purs/passing/EffFn.js
index b645b0527e..8360cbe7cd 100644
--- a/tests/purs/passing/EffFn.js
+++ b/tests/purs/passing/EffFn.js
@@ -1 +1 @@
-exports.add3 = function (a,b,c) { return a + b + c; };
\ No newline at end of file
+export var add3 = function (a,b,c) { return a + b + c; };
diff --git a/tests/purs/passing/EmptyDicts.purs b/tests/purs/passing/EmptyDicts.purs
new file mode 100644
index 0000000000..157af7bc52
--- /dev/null
+++ b/tests/purs/passing/EmptyDicts.purs
@@ -0,0 +1,77 @@
+-- |
+-- The purpose of this test is to make sure that the empty type class
+-- dictionary elimination code doesn't change semantics.
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+-- |
+-- Data type to check that the result of expressions with eliminated
+-- dictionaries are as expected.
+data Check = Check
+derive instance eqCheck :: Eq Check
+
+-- |
+-- This type class has no constraints and no members.
+-- Is is therefore considered empty.
+class EmptyClass
+instance emptyDictInst :: EmptyClass
+
+-- |
+-- This type class is not empty as it has members, but it has an empty super
+-- class.
+class EmptyClass <= HasEmptySuper where
+ hasEmptySuper :: Check
+instance hasEmptySuperInst :: HasEmptySuper where
+ hasEmptySuper = Check
+
+-- |
+-- This type class has no members, but has a non-empty super class.
+-- It is therefore not empty.
+class HasEmptySuper <= HasNonEmptySuper
+instance hasNonEmptySuperInst :: HasEmptySuper => HasNonEmptySuper
+
+-- |
+-- This type class is empty because all it's super classes are empty and it
+-- has no members.
+class EmptyClass <= AliasEmptyClass
+instance aliasEmptyClassInst :: AliasEmptyClass
+
+whenEmpty :: Check
+whenEmpty = Check :: EmptyClass => Check
+
+whenHasEmptySuper :: Check
+whenHasEmptySuper = Check :: HasEmptySuper => Check
+
+whenHasNonEmptySuper :: Check
+whenHasNonEmptySuper = Check :: HasNonEmptySuper => Check
+
+whenAliasEmptyClass :: Check
+whenAliasEmptyClass = Check :: AliasEmptyClass => Check
+
+class WithArgEmpty t
+instance withArgEmptyCheck :: WithArgEmpty Check
+class WithArgEmpty t <= WithArgHasEmptySuper t where
+ withArgHasEmptySuper :: t
+instance withArgHasEmptySuperCheck :: WithArgHasEmptySuper Check where
+ withArgHasEmptySuper = Check
+
+whenAccessingSuperDict :: Check
+whenAccessingSuperDict = foo Check where
+
+ bar :: forall t . WithArgEmpty t => t -> t
+ bar x = x
+
+ foo :: forall t . WithArgHasEmptySuper t => t -> t
+ foo x = bar x
+
+main =
+ if Check == whenEmpty &&
+ Check == whenHasEmptySuper &&
+ Check == whenHasNonEmptySuper &&
+ Check == whenAliasEmptyClass &&
+ Check == whenAccessingSuperDict
+ then log "Done"
+ else pure unit
+
diff --git a/tests/purs/passing/ExportExplicit/M1.purs b/tests/purs/passing/ExportExplicit/M1.purs
index 273f1002fd..5195d0e96b 100644
--- a/tests/purs/passing/ExportExplicit/M1.purs
+++ b/tests/purs/passing/ExportExplicit/M1.purs
@@ -1,4 +1,4 @@
-module M1 (X(X), Z(..), foo) where
+module M1 (X(X, Y), Z(..), foo) where
data X = X | Y
data Z = Z
diff --git a/tests/purs/passing/FFIConstraintWorkaround.js b/tests/purs/passing/FFIConstraintWorkaround.js
new file mode 100644
index 0000000000..755092a488
--- /dev/null
+++ b/tests/purs/passing/FFIConstraintWorkaround.js
@@ -0,0 +1,5 @@
+export function showImpl(showFn) {
+ return function (val) {
+ return showFn(val);
+ };
+};
diff --git a/tests/purs/passing/FFIConstraintWorkaround.purs b/tests/purs/passing/FFIConstraintWorkaround.purs
new file mode 100644
index 0000000000..54b7d3fe2e
--- /dev/null
+++ b/tests/purs/passing/FFIConstraintWorkaround.purs
@@ -0,0 +1,22 @@
+module Main where
+
+import Prelude
+import Effect
+import Effect.Console
+import Test.Assert
+
+main :: Effect Unit
+main = do
+ assert' "Showing Int is correct" $ showFFI 4 == "4"
+ assert' "Showing String is correct" $ showFFI "string" == "\"string\""
+ assert' "Showing Record is correct" $
+ showFFI { a: 1, b: true, c: 'd', e: 4.0 } == "{ a: 1, b: true, c: 'd', e: 4.0 }"
+ log "Done"
+
+showFFI :: forall a. Show a => a -> String
+showFFI = showImpl show
+
+-- Since type class constraints are not allowed
+-- in FFI declarations, we have to pass members
+-- we want to use into the function itself.
+foreign import showImpl :: forall a. (a -> String) -> a -> String
diff --git a/tests/purs/passing/FFIDefaultESExport.js b/tests/purs/passing/FFIDefaultESExport.js
new file mode 100644
index 0000000000..ab294f31ea
--- /dev/null
+++ b/tests/purs/passing/FFIDefaultESExport.js
@@ -0,0 +1,3 @@
+var message = "Done";
+
+export { message as default };
diff --git a/tests/purs/passing/FFIDefaultESExport.purs b/tests/purs/passing/FFIDefaultESExport.purs
new file mode 100644
index 0000000000..1d084b6d8d
--- /dev/null
+++ b/tests/purs/passing/FFIDefaultESExport.purs
@@ -0,0 +1,7 @@
+module Main where
+
+import Effect.Console (log)
+
+foreign import default :: String
+
+main = log default
diff --git a/tests/purs/passing/ForeignDataInKind.purs b/tests/purs/passing/ForeignDataInKind.purs
new file mode 100644
index 0000000000..664da3ccd1
--- /dev/null
+++ b/tests/purs/passing/ForeignDataInKind.purs
@@ -0,0 +1,9 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+foreign import data A :: Type
+data B (x :: A)
+
+main = log "Done"
diff --git a/tests/purs/passing/ForeignKind.purs b/tests/purs/passing/ForeignKind.purs
index c2d4421f2b..54eb08766c 100644
--- a/tests/purs/passing/ForeignKind.purs
+++ b/tests/purs/passing/ForeignKind.purs
@@ -1,7 +1,7 @@
module Main where
import Prelude
-import ForeignKinds.Lib (kind Nat, Zero, Succ, N3, NatProxy, class AddNat, addNat, proxy1, proxy2)
+import ForeignKinds.Lib (Nat, Zero, Succ, N3, NatProxy, class AddNat, addNat, proxy1, proxy2)
import Effect.Console (log)
proxy1Add2Is3 :: NatProxy N3
diff --git a/tests/purs/passing/ForeignKind/Lib.purs b/tests/purs/passing/ForeignKind/Lib.purs
index 0ca2c13638..d28a9a5ccd 100644
--- a/tests/purs/passing/ForeignKind/Lib.purs
+++ b/tests/purs/passing/ForeignKind/Lib.purs
@@ -1,8 +1,8 @@
-module ForeignKinds.Lib (kind Nat, Kinded, Zero, Succ, N0, N1, N2, N3, NatProxy(..), class AddNat, addNat, proxy1, proxy2) where
+module ForeignKinds.Lib (Nat, Kinded, Zero, Succ, N0, N1, N2, N3, NatProxy(..), class AddNat, addNat, proxy1, proxy2) where
-- declaration
-foreign import kind Nat
+data Nat
-- use in foreign data
diff --git a/tests/purs/passing/FunWithFunDeps.js b/tests/purs/passing/FunWithFunDeps.js
index dea73d18fe..322903a11b 100644
--- a/tests/purs/passing/FunWithFunDeps.js
+++ b/tests/purs/passing/FunWithFunDeps.js
@@ -1,32 +1,28 @@
//: forall e. FVect Z e
-exports.fnil = [];
+export var fnil = [];
//: forall n e. e -> FVect n e -> FVect (S n) e
-exports.fcons = function (hd) {
+export var fcons = function (hd) {
return function (tl) {
return [hd].concat(tl);
};
};
-exports.fappend = function (dict) {
- return function (left) {
- return function (right) {
- return left.concat(right);
- };
+export var fappendImpl = function (left) {
+ return function (right) {
+ return left.concat(right);
};
};
-exports.fflatten = function (dict) {
- return function (v) {
- var accRef = [];
- for (var indexRef = 0; indexRef < v.length; indexRef += 1) {
- accRef = accRef.concat(v[indexRef]);
- }
- return accRef;
- };
+export var fflattenImpl = function (v) {
+ var accRef = [];
+ for (var indexRef = 0; indexRef < v.length; indexRef += 1) {
+ accRef = accRef.concat(v[indexRef]);
+ }
+ return accRef;
};
-exports.ftoArray = function (vect) {
+export var ftoArray = function (vect) {
return vect;
};
diff --git a/tests/purs/passing/FunWithFunDeps.purs b/tests/purs/passing/FunWithFunDeps.purs
index 9b9a99145d..7a3e90eff9 100644
--- a/tests/purs/passing/FunWithFunDeps.purs
+++ b/tests/purs/passing/FunWithFunDeps.purs
@@ -26,8 +26,12 @@ instance natMultS :: (NatMult m n r, NatPlus n r s) => NatMult (S m) n s
foreign import data FVect :: Type -> Type -> Type
foreign import fnil :: forall e. FVect Z e
foreign import fcons :: forall n e. e -> FVect n e -> FVect (S n) e
-foreign import fappend :: forall l r o e. NatPlus l r o => FVect l e -> FVect r e -> FVect o e
-foreign import fflatten :: forall f s t o. NatMult f s o => FVect f (FVect s t) -> FVect o t
+fappend :: forall l r o e. NatPlus l r o => FVect l e -> FVect r e -> FVect o e
+fappend = fappendImpl
+foreign import fappendImpl :: forall l r o e. FVect l e -> FVect r e -> FVect o e
+fflatten :: forall f s t o. NatMult f s o => FVect f (FVect s t) -> FVect o t
+fflatten = fflattenImpl
+foreign import fflattenImpl :: forall f s t o. FVect f (FVect s t) -> FVect o t
foreign import ftoArray :: forall n e. FVect n e -> Array e
-- should be able to figure these out
diff --git a/tests/purs/passing/GenericsRep.purs b/tests/purs/passing/GenericsRep.purs
index 3126768cf9..1535382ed9 100644
--- a/tests/purs/passing/GenericsRep.purs
+++ b/tests/purs/passing/GenericsRep.purs
@@ -4,7 +4,7 @@ import Prelude
import Effect (Effect)
import Effect.Console (log, logShow)
import Data.Generic.Rep (class Generic)
-import Data.Generic.Rep.Eq (genericEq)
+import Data.Eq.Generic (genericEq)
data X a = X a
diff --git a/tests/purs/passing/Guards.purs b/tests/purs/passing/Guards.purs
index 2894d2e9c8..8e3a20e233 100644
--- a/tests/purs/passing/Guards.purs
+++ b/tests/purs/passing/Guards.purs
@@ -34,6 +34,12 @@ clunky1 a b | x <- max a b
= x
clunky1 a _ = a
+clunky1_refutable :: Int -> Int -> Int
+clunky1_refutable 0 a | x <- max a a
+ , x > 5
+ = x
+clunky1_refutable a _ = a
+
clunky2 :: Int -> Int -> Int
clunky2 a b | x <- max a b
, x > 5
@@ -41,7 +47,7 @@ clunky2 a b | x <- max a b
| otherwise
= a + b
--- pattern guards on case epxressions
+-- pattern guards on case expressions
clunky_case1 :: Int -> Int -> Int
clunky_case1 a b =
case unit of
diff --git a/tests/purs/passing/InstanceNamesGenerated.purs b/tests/purs/passing/InstanceNamesGenerated.purs
new file mode 100644
index 0000000000..21e7981a90
--- /dev/null
+++ b/tests/purs/passing/InstanceNamesGenerated.purs
@@ -0,0 +1,98 @@
+module Main where
+
+import Prelude
+
+import Effect.Console (log)
+import Data.Generic.Rep (class Generic)
+
+import Lib (namedExportStillWorksUnit)
+
+-- This file verifies that unnamed instances will produce
+-- completely-generated instance names without problems.
+
+class NoTypeParams
+instance NoTypeParams
+
+
+class OneTypeParam a
+instance OneTypeParam Boolean
+
+
+class OneTypeParamChain a
+instance OneTypeParamChain Boolean
+else instance OneTypeParamChain String
+
+
+class MultipleTypeParams :: Type -> Type -> Type -> Type -> Type -> Constraint
+class MultipleTypeParams a b c d e
+
+instance MultipleTypeParams Boolean Int Number Char String
+
+
+class MultipleTypeParamsChain :: Type -> Type -> Type -> Type -> Type -> Constraint
+class MultipleTypeParamsChain a b c d e
+
+instance MultipleTypeParamsChain Boolean Int Number Char Boolean
+else instance MultipleTypeParamsChain Boolean Int Number Char Int
+else instance MultipleTypeParamsChain Boolean Int Number Char Number
+else instance MultipleTypeParamsChain Boolean Int Number Char Char
+else instance MultipleTypeParamsChain Boolean Int Number Char String
+
+
+class HigherKindedTypeParams :: (Type -> Type) -> (Type -> Type) -> Constraint
+class HigherKindedTypeParams f g where
+ hktp :: f Int -> g Int -> Int
+
+instance HigherKindedTypeParams Array (Either Int) where
+ hktp _ _ = 0
+
+
+class HigherKindedTypeParamsChain :: (Type -> Type) -> (Type -> Type) -> Constraint
+class HigherKindedTypeParamsChain f g where
+ hktpChain :: f Int -> g Int -> Int
+
+instance HigherKindedTypeParamsChain Array (Either Int) where
+ hktpChain _ _ = 0
+else instance HigherKindedTypeParamsChain (Either Int) Array where
+ hktpChain _ _ = 0
+
+
+data CustomKind
+foreign import data Constructor1 :: CustomKind
+foreign import data Constructor2 :: CustomKind
+foreign import data Constructor3 :: CustomKind
+
+class MultipleKindParams :: CustomKind -> Constraint
+class MultipleKindParams customKind
+
+instance MultipleKindParams Constructor1
+
+
+class MultipleKindParamsChain :: CustomKind -> Constraint
+class MultipleKindParamsChain customKind
+
+instance MultipleKindParamsChain Constructor1
+else instance MultipleKindParamsChain Constructor2
+else instance MultipleKindParamsChain Constructor3
+
+
+data Arrow a b = Foo a b
+class ReservedWord a
+instance ReservedWord (Arrow a b)
+instance ReservedWord ((->) a b)
+
+
+data GenericFoo = GenericFoo
+derive instance Generic GenericFoo _
+
+
+class OverlappingStillCompiles a
+instance OverlappingStillCompiles x
+else instance OverlappingStillCompiles x
+
+
+main = do
+ namedExportStillWorksUnit 0
+ log "Done"
+
+data Either l r = Left l | Right r
diff --git a/tests/purs/passing/InstanceNamesGenerated/Lib.purs b/tests/purs/passing/InstanceNamesGenerated/Lib.purs
new file mode 100644
index 0000000000..321e5fb1af
--- /dev/null
+++ b/tests/purs/passing/InstanceNamesGenerated/Lib.purs
@@ -0,0 +1,20 @@
+module Lib where
+
+import Prelude
+
+import Effect (Effect)
+
+class NamedExportStillWorks a where
+ doTest :: Effect a
+
+-- This test expects the generated name of this instance to be
+-- namedExportStillWorksUnit in the absence of another identifier with that
+-- name (as we have here).
+-- The test ensures that the instance doesn't preempt the named declaration.
+-- (If the naming scheme for unnamed instances ever changes, the name of the
+-- exported declaration in this test should change with it.)
+instance NamedExportStillWorks Unit where
+ doTest = pure unit
+
+namedExportStillWorksUnit :: Int -> Effect Unit
+namedExportStillWorksUnit _ = doTest
diff --git a/tests/purs/passing/InstanceUnnamedSimilarClassName.purs b/tests/purs/passing/InstanceUnnamedSimilarClassName.purs
new file mode 100644
index 0000000000..5fb4193152
--- /dev/null
+++ b/tests/purs/passing/InstanceUnnamedSimilarClassName.purs
@@ -0,0 +1,16 @@
+module Main where
+
+import Effect.Console (log)
+import ImportedClassName as I
+
+data Foo = Foo
+
+class ClassName a where
+ foo :: a -> Int
+
+instance ClassName Foo where
+ foo _ = 0
+instance I.ClassName Foo where
+ foo _ = 0
+
+main = log "Done"
diff --git a/tests/purs/passing/InstanceUnnamedSimilarClassName/ImportedClassName.purs b/tests/purs/passing/InstanceUnnamedSimilarClassName/ImportedClassName.purs
new file mode 100644
index 0000000000..c966693350
--- /dev/null
+++ b/tests/purs/passing/InstanceUnnamedSimilarClassName/ImportedClassName.purs
@@ -0,0 +1,4 @@
+module ImportedClassName where
+
+class ClassName a where
+ foo :: a -> Int
diff --git a/tests/purs/passing/IntToString.purs b/tests/purs/passing/IntToString.purs
new file mode 100644
index 0000000000..736706e6d4
--- /dev/null
+++ b/tests/purs/passing/IntToString.purs
@@ -0,0 +1,71 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+import Prim.Int (class Add, class Mul, class ToString)
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+type One = 1
+type NegOne = (-1)
+type Zero = 0
+
+testToString :: forall i s. ToString i s => Proxy i -> Proxy s
+testToString _ = Proxy
+
+posToString :: Proxy "1"
+posToString = testToString (Proxy :: Proxy 1)
+
+negToString :: Proxy "-1"
+negToString = testToString (Proxy :: Proxy (-1))
+
+zeroToString :: Proxy "0"
+zeroToString = testToString (Proxy :: Proxy 0)
+
+posToStringTA :: Proxy "1"
+posToStringTA = testToString (Proxy :: Proxy One)
+
+negToStringTA :: Proxy "-1"
+negToStringTA = testToString (Proxy :: Proxy NegOne)
+
+zeroToStringTA :: Proxy "0"
+zeroToStringTA = testToString (Proxy :: Proxy Zero)
+
+intAdd
+ :: forall i1 i2 i3
+ . Add i1 i2 i3
+ => Proxy i1
+ -> Proxy i2
+ -> Proxy i3
+intAdd _ _ = Proxy
+
+intMul
+ :: forall i1 i2 i3
+ . Mul i1 i2 i3
+ => Proxy i1
+ -> Proxy i2
+ -> Proxy i3
+intMul _ _ = Proxy
+
+testAdd :: Proxy "4"
+testAdd = testToString (intAdd (Proxy :: _ 1) (Proxy :: _ 3))
+
+testMul :: Proxy "6"
+testMul = testToString (intMul (Proxy :: _ 2) (Proxy :: _ 3))
+
+testMulAdd :: Proxy "10"
+testMulAdd = testToString (intAdd (Proxy :: _ 4) (intMul (Proxy :: _ 2) (Proxy :: _ 3)))
+
+testAddMul :: Proxy "20"
+testAddMul = testToString (intMul (Proxy :: _ 4) (intAdd (Proxy :: _ 2) (Proxy :: _ 3)))
+
+_maxInt = Proxy :: _ 2147483647
+
+testMax :: Proxy "2147483647"
+testMax = testToString _maxInt
+
+testBeyondMax :: Proxy "4294967294"
+testBeyondMax = testToString (intMul _maxInt (Proxy :: _ 2))
+
+main = log "Done"
diff --git a/tests/purs/passing/KindUnificationInSolver.purs b/tests/purs/passing/KindUnificationInSolver.purs
new file mode 100644
index 0000000000..74850311f3
--- /dev/null
+++ b/tests/purs/passing/KindUnificationInSolver.purs
@@ -0,0 +1,21 @@
+module Main where
+
+import Effect.Console (log)
+
+data Proxy a = Proxy
+
+class CtorKind ctor (kind :: Type) | ctor -> kind
+
+instance ctorKind0 :: CtorKind f z => CtorKind (f a) z
+else instance ctorKind1 :: CtorKind ((a) :: t) t
+
+data Test a b
+
+ctorKind :: forall t k. CtorKind t k => Proxy t -> Proxy k
+ctorKind _ = Proxy
+
+testCtor1 = ctorKind (Proxy :: Proxy (Test Int String))
+testCtor2 = ctorKind (Proxy :: Proxy (Test Int "What"))
+testCtor3 = ctorKind (Proxy :: Proxy (Test Int))
+
+main = log "Done"
diff --git a/tests/purs/passing/KindedType.purs b/tests/purs/passing/KindedType.purs
index 5898614d53..709c6a7181 100644
--- a/tests/purs/passing/KindedType.purs
+++ b/tests/purs/passing/KindedType.purs
@@ -31,9 +31,9 @@ class Clazz (a :: Type) where
instance clazzString :: Clazz String where
def = "test"
-type Type a = ((a) :: Type)
+type IsType a = ((a) :: Type)
-type TestRecord a = Record (a :: Type a)
+type TestRecord a = Record (a :: IsType a)
test5 :: Test TestRecord
test5 = { a: "test" }
diff --git a/tests/purs/passing/MinusConstructor.purs b/tests/purs/passing/MinusConstructor.purs
new file mode 100644
index 0000000000..56e5a50c6b
--- /dev/null
+++ b/tests/purs/passing/MinusConstructor.purs
@@ -0,0 +1,38 @@
+module Main where
+
+import Prelude
+
+import Effect.Console (log)
+import Test.Assert (assert)
+
+data Tuple a b = Tuple a b
+
+infixl 6 Tuple as -
+
+test1 =
+ let tuple = "" - ""
+ left - right = tuple
+ in left
+
+test2 = case 3 - 4 of
+ left-4 -> left
+ _ -> 0
+
+test3 (Tuple a b - c) = a
+test3 _ = 0
+
+test4 = case 7 - -3 of
+ left - -3 -> left
+ _ -> 0
+
+test5 = case -7 - 8 of
+ -7-right -> right
+ _ -> 0
+
+main = do
+ assert $ test1 == ""
+ assert $ test2 == 3
+ assert $ test3 (5-10-15) == 5
+ assert $ test4 == 7
+ assert $ test5 == 8
+ log "Done"
diff --git a/tests/purs/passing/NegativeBinder.purs b/tests/purs/passing/NegativeBinder.purs
index 2d4e36b52a..46a791c660 100644
--- a/tests/purs/passing/NegativeBinder.purs
+++ b/tests/purs/passing/NegativeBinder.purs
@@ -4,7 +4,12 @@ import Prelude
import Effect.Console (log)
test :: Number -> Boolean
-test -1.0 = false
+test (-1.0) = false
test _ = true
+test2 :: Number -> Number -> Boolean
+test2 x y = case x, y of
+ -1.0, -1.0 -> false
+ _, _ -> true
+
main = log "Done"
diff --git a/tests/purs/passing/NewtypeClass.purs b/tests/purs/passing/NewtypeClass.purs
index 47ce815d7b..43799eb51e 100644
--- a/tests/purs/passing/NewtypeClass.purs
+++ b/tests/purs/passing/NewtypeClass.purs
@@ -3,16 +3,20 @@ module Main where
import Prelude
import Effect
import Effect.Console
+import Safe.Coerce (class Coercible, coerce)
-class Newtype t a | t -> a where
- wrap :: a -> t
- unwrap :: t -> a
+class Newtype :: Type -> Type -> Constraint
+class Coercible t a <= Newtype t a | t -> a
-instance newtypeMultiplicative :: Newtype (Multiplicative a) a where
- wrap = Multiplicative
- unwrap (Multiplicative a) = a
+wrap :: forall t a. Newtype t a => a -> t
+wrap = coerce
-data Multiplicative a = Multiplicative a
+unwrap :: forall t a. Newtype t a => t -> a
+unwrap = coerce
+
+instance newtypeMultiplicative :: Newtype (Multiplicative a) a
+
+newtype Multiplicative a = Multiplicative a
instance semiringMultiplicative :: Semiring a => Semigroup (Multiplicative a) where
append (Multiplicative a) (Multiplicative b) = Multiplicative (a * b)
diff --git a/tests/purs/passing/NewtypeInstance.purs b/tests/purs/passing/NewtypeInstance.purs
index e16e574360..d2a1b333f0 100644
--- a/tests/purs/passing/NewtypeInstance.purs
+++ b/tests/purs/passing/NewtypeInstance.purs
@@ -54,6 +54,13 @@ type Syn' w a = MyWriter w a
newtype Syn a = Syn (Syn' (MyArray Int) a)
derive newtype instance functorSyn :: Functor Syn
+data Proxy2 a b = Proxy2
+derive instance Functor (Proxy2 x)
+
+newtype Foo :: forall k. k -> Type
+newtype Foo a = Foo (Proxy2 k a)
+derive newtype instance Functor Foo
+
main = do
logShow (X "test")
logShow (singleton "test" :: Y String)
diff --git a/tests/purs/passing/OperatorSections.purs b/tests/purs/passing/OperatorSections.purs
index 00538142eb..20c1e166ac 100644
--- a/tests/purs/passing/OperatorSections.purs
+++ b/tests/purs/passing/OperatorSections.purs
@@ -15,4 +15,6 @@ main = do
let div x y = x.x / y.x
assert $ (_ `div` foo { x = 4.0 }) { x: 4.0 } == 1.0
assert $ (foo { x = 4.0 } `div` _) { x: 4.0 } == 1.0
+ assert $ (_ + 2 * 3) 1 == 7
+ assert $ (3 * 2 + _) 1 == 7
log "Done"
diff --git a/tests/purs/passing/ParseTypeInt.purs b/tests/purs/passing/ParseTypeInt.purs
new file mode 100644
index 0000000000..edd7d89d6c
--- /dev/null
+++ b/tests/purs/passing/ParseTypeInt.purs
@@ -0,0 +1,28 @@
+module Main where
+
+import Effect.Console (log)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+a :: Proxy 42
+a = Proxy
+
+b :: Proxy (-42)
+b = Proxy
+
+c :: Proxy (42 :: Int)
+c = Proxy
+
+d :: Proxy ((42) :: Int)
+d = Proxy
+
+e :: Proxy ((-42) :: Int)
+e = Proxy
+
+f :: Proxy (-
+ -- here's a comment
+ 1)
+f = Proxy
+
+main = log "Done"
diff --git a/tests/purs/passing/PolyLabels.js b/tests/purs/passing/PolyLabels.js
index b9900e4d3b..115375cd48 100644
--- a/tests/purs/passing/PolyLabels.js
+++ b/tests/purs/passing/PolyLabels.js
@@ -1,12 +1,10 @@
-"use strict";
-
-exports.unsafeGet = function (s) {
+export var unsafeGet = function (s) {
return function (o) {
return o[s];
};
};
-exports.unsafeSet = function(s) {
+export var unsafeSet = function (s) {
return function(a) {
return function (o) {
var o1 = {};
diff --git a/tests/purs/passing/PolyLabels.purs b/tests/purs/passing/PolyLabels.purs
index 15caed8e8d..95b915ae5d 100644
--- a/tests/purs/passing/PolyLabels.purs
+++ b/tests/purs/passing/PolyLabels.purs
@@ -4,7 +4,8 @@ import Prelude
import Prim.Row
import Effect
import Effect.Console
-import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
+import Data.Symbol (class IsSymbol, reflectSymbol)
+import Type.Proxy (Proxy(..))
foreign import unsafeGet
:: forall r a
@@ -23,7 +24,7 @@ get
:: forall r r' l a
. IsSymbol l
=> Cons l a r' r
- => SProxy l
+ => Proxy l
-> Record r
-> a
get l = unsafeGet (reflectSymbol l)
@@ -33,7 +34,7 @@ set
. IsSymbol l
=> Cons l a r r1
=> Cons l b r r2
- => SProxy l
+ => Proxy l
-> b
-> Record r1
-> Record r2
@@ -45,20 +46,20 @@ lens
=> Cons l a r r1
=> Cons l b r r2
=> Functor f
- => SProxy l
+ => Proxy l
-> (a -> f b)
-> Record r1
-> f (Record r2)
lens l f r = flip (set l) r <$> f (get l r)
getFoo :: forall a r. { foo :: a | r } -> a
-getFoo = get (SProxy :: SProxy "foo")
+getFoo = get (Proxy :: Proxy "foo")
setFoo :: forall a b r. b -> { foo :: a | r } -> { foo :: b | r }
-setFoo = set (SProxy :: SProxy "foo")
+setFoo = set (Proxy :: Proxy "foo")
fooLens :: forall f a b r. Functor f => (a -> f b) -> { foo :: a | r } -> f { foo :: b | r }
-fooLens = lens (SProxy :: SProxy "foo")
+fooLens = lens (Proxy :: Proxy "foo")
main :: Effect Unit
main = do
diff --git a/tests/purs/passing/PolykindBindingGroup1.purs b/tests/purs/passing/PolykindBindingGroup1.purs
new file mode 100644
index 0000000000..51db49e420
--- /dev/null
+++ b/tests/purs/passing/PolykindBindingGroup1.purs
@@ -0,0 +1,13 @@
+module Main where
+
+import Effect.Console (log)
+
+data X a = X (Y a) | Z
+data Y a = Y (X a)
+
+test1 = X (Y Z) :: X Int
+test2 = X (Y Z) :: X "foo"
+test3 = Y (X (Y Z)) :: Y Int
+test4 = Y (X (Y Z)) :: Y "foo"
+
+main = log "Done"
diff --git a/tests/purs/passing/PolykindBindingGroup2.purs b/tests/purs/passing/PolykindBindingGroup2.purs
new file mode 100644
index 0000000000..d7d24e75d9
--- /dev/null
+++ b/tests/purs/passing/PolykindBindingGroup2.purs
@@ -0,0 +1,16 @@
+module Main where
+
+import Effect.Console (log)
+
+data Proxy a = Proxy
+
+data X a = X (Y a => Proxy a)
+
+class Z (X a) <= Y a
+
+class Z a
+
+test1 = X (Proxy :: _ Int)
+test2 = X (Proxy :: _ "foo")
+
+main = log "Done"
diff --git a/tests/purs/passing/PolykindGeneralization.purs b/tests/purs/passing/PolykindGeneralization.purs
new file mode 100644
index 0000000000..c9b0d59fc8
--- /dev/null
+++ b/tests/purs/passing/PolykindGeneralization.purs
@@ -0,0 +1,15 @@
+module Main where
+
+import Effect.Console (log)
+
+data Proxy a = Proxy
+data F f a = F (f a)
+
+fproxy :: forall f a. Proxy f -> Proxy a -> Proxy (F f a)
+fproxy _ _ = Proxy
+
+a = fproxy (Proxy :: _ Proxy)
+b = a (Proxy :: _ Int)
+c = a (Proxy :: _ "foo")
+
+main = log "Done"
diff --git a/tests/purs/passing/PolykindGeneralizationHygiene.purs b/tests/purs/passing/PolykindGeneralizationHygiene.purs
new file mode 100644
index 0000000000..75eadbef75
--- /dev/null
+++ b/tests/purs/passing/PolykindGeneralizationHygiene.purs
@@ -0,0 +1,11 @@
+module Main where
+
+import Effect.Console (log)
+
+-- First argument needs to be `k`.
+type F k t = forall proxy. proxy k -> t
+
+test :: F Symbol Int
+test _ = 42
+
+main = log "Done"
diff --git a/tests/purs/passing/PolykindGeneralizedTypeSynonym.purs b/tests/purs/passing/PolykindGeneralizedTypeSynonym.purs
new file mode 100644
index 0000000000..d89ec1e9f8
--- /dev/null
+++ b/tests/purs/passing/PolykindGeneralizedTypeSynonym.purs
@@ -0,0 +1,12 @@
+module Main where
+
+import Effect.Console (log)
+
+data Proxy a = Proxy
+
+type Prozy = Proxy
+
+test1 = Proxy :: Prozy Int
+test2 = Proxy :: Prozy "foo"
+
+main = log "Done"
diff --git a/tests/purs/passing/PolykindInstanceDispatch.purs b/tests/purs/passing/PolykindInstanceDispatch.purs
new file mode 100644
index 0000000000..eeae303a8a
--- /dev/null
+++ b/tests/purs/passing/PolykindInstanceDispatch.purs
@@ -0,0 +1,21 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+import Test.Assert
+
+data Proxy a = Proxy
+
+class ShowP a where
+ showP :: a -> String
+
+instance test1 :: ShowP (Proxy ((a) :: Type)) where
+ showP _ = "Type"
+
+instance test2 :: ShowP (Proxy ((a) :: Symbol)) where
+ showP _ = "Symbol"
+
+main = do
+ assert (showP (Proxy :: _ Int) == "Type")
+ assert (showP (Proxy :: _ "foo") == "Symbol")
+ log "Done"
diff --git a/tests/purs/passing/PolykindInstantiatedInstance.purs b/tests/purs/passing/PolykindInstantiatedInstance.purs
new file mode 100644
index 0000000000..f499c5eb78
--- /dev/null
+++ b/tests/purs/passing/PolykindInstantiatedInstance.purs
@@ -0,0 +1,22 @@
+module Main where
+
+import Effect.Console (log)
+
+data Proxy a = Proxy
+
+class F f where
+ f :: forall a b. (a -> b) -> f a -> f b
+
+instance fProxy :: F Proxy where
+ f _ _ = Proxy
+
+test1 :: forall a. Proxy a
+test1 = f (\a -> a) Proxy
+
+test2 :: Proxy Int
+test2 = f (\a -> a) (Proxy :: Proxy Int)
+
+test3 :: Proxy String
+test3 = f (\a -> "foo") Proxy
+
+main = log "Done"
diff --git a/tests/purs/passing/PolykindInstantiation.purs b/tests/purs/passing/PolykindInstantiation.purs
new file mode 100644
index 0000000000..1b83b7600d
--- /dev/null
+++ b/tests/purs/passing/PolykindInstantiation.purs
@@ -0,0 +1,17 @@
+module Main where
+
+import Effect.Console (log)
+
+data Proxy a = Proxy
+data F f a = F (f a)
+
+test1 = Proxy :: Proxy Int
+test2 = Proxy :: Proxy "foo"
+test3 = Proxy :: Proxy Proxy
+test4 = Proxy :: Proxy F
+test5 = Proxy :: Proxy (F Proxy)
+test6 = Proxy :: Proxy (F (F Proxy))
+test7 = Proxy :: Proxy (F Proxy Int)
+test8 = Proxy :: Proxy (F Proxy "foo")
+
+main = log "Done"
diff --git a/tests/purs/passing/PolykindRowCons.purs b/tests/purs/passing/PolykindRowCons.purs
new file mode 100644
index 0000000000..54448c64c8
--- /dev/null
+++ b/tests/purs/passing/PolykindRowCons.purs
@@ -0,0 +1,51 @@
+module Main where
+
+import Effect.Console (log)
+import Prim.Row
+
+data Proxy a = Proxy
+data Identity a = Identity a
+data App f a = App (f a)
+
+type RowType =
+ ( a :: Int
+ , b :: String
+ , c :: Boolean
+ )
+
+type RowTypeType =
+ ( a :: Proxy
+ , b :: Identity
+ , c :: App Identity
+ )
+
+type RowSymbol =
+ ( a :: "a"
+ , b :: "b"
+ , c :: "c"
+ )
+
+lookup :: forall sym v rx r. Cons sym v rx r => Proxy sym -> Proxy r -> Proxy v
+lookup _ _ = Proxy
+
+lookup1 = lookup (Proxy :: _ "a") (Proxy :: _ RowType)
+lookup2 = lookup (Proxy :: _ "b") (Proxy :: _ RowType)
+lookup3 = lookup (Proxy :: _ "c") (Proxy :: _ RowType)
+lookup4 = lookup (Proxy :: _ "a") (Proxy :: _ RowTypeType)
+lookup5 = lookup (Proxy :: _ "b") (Proxy :: _ RowTypeType)
+lookup6 = lookup (Proxy :: _ "c") (Proxy :: _ RowTypeType)
+lookup7 = lookup (Proxy :: _ "a") (Proxy :: _ RowSymbol)
+lookup8 = lookup (Proxy :: _ "b") (Proxy :: _ RowSymbol)
+lookup9 = lookup (Proxy :: _ "c") (Proxy :: _ RowSymbol)
+
+test1 = lookup1 :: Proxy Int
+test2 = lookup2 :: Proxy String
+test3 = lookup3 :: Proxy Boolean
+test4 = lookup4 :: Proxy Proxy
+test5 = lookup5 :: Proxy Identity
+test6 = lookup6 :: Proxy (App Identity)
+test7 = lookup7 :: Proxy "a"
+test8 = lookup8 :: Proxy "b"
+test9 = lookup9 :: Proxy "c"
+
+main = log "Done"
diff --git a/tests/purs/passing/QualifiedOperators.purs b/tests/purs/passing/QualifiedOperators.purs
new file mode 100644
index 0000000000..23e54729e3
--- /dev/null
+++ b/tests/purs/passing/QualifiedOperators.purs
@@ -0,0 +1,13 @@
+module Main where
+
+import Prelude
+
+import Effect.Console (log)
+import Test.Assert (assert)
+
+import Foo as Foo.Bar
+
+main = do
+ assert $ 4 Foo.Bar.-#- 10 == 33
+ assert $ Foo.Bar.(-#-) 4 10 == 33
+ log "Done"
diff --git a/tests/purs/passing/QualifiedOperators/Foo.purs b/tests/purs/passing/QualifiedOperators/Foo.purs
new file mode 100644
index 0000000000..0d8ef9cdaf
--- /dev/null
+++ b/tests/purs/passing/QualifiedOperators/Foo.purs
@@ -0,0 +1,8 @@
+module Foo where
+
+import Prelude
+
+tie :: Int -> Int -> Int
+tie a b = (a - 1) * (b + 1)
+
+infix 5 tie as -#-
diff --git a/tests/purs/passing/QuantifiedKind.purs b/tests/purs/passing/QuantifiedKind.purs
new file mode 100644
index 0000000000..b8b107356a
--- /dev/null
+++ b/tests/purs/passing/QuantifiedKind.purs
@@ -0,0 +1,10 @@
+module Main where
+
+import Effect.Console (log)
+
+data Proxy a = Proxy
+
+test :: forall k (a :: k). Proxy a
+test = Proxy
+
+main = log "Done"
diff --git a/tests/purs/passing/Rank2Kinds.purs b/tests/purs/passing/Rank2Kinds.purs
new file mode 100644
index 0000000000..38d29641d8
--- /dev/null
+++ b/tests/purs/passing/Rank2Kinds.purs
@@ -0,0 +1,21 @@
+module Main where
+
+import Effect.Console (log)
+
+data A (a :: forall k. k -> Type) = A
+
+data B :: (forall k. k -> Type) -> Type
+data B a = B
+
+data Pair a b = Pair
+data Proxy a = Proxy
+
+type Id a = a
+type MkP (f :: forall k. k -> k) = Pair (f Int) (f "foo")
+
+k :: forall a b. Proxy (Pair Int "foo") -> Int
+k _ = 42
+
+test = k (Proxy :: Proxy (MkP Id))
+
+main = log "Done"
diff --git a/tests/purs/passing/ReExportsExported.js b/tests/purs/passing/ReExportsExported.js
new file mode 100644
index 0000000000..5ca086e78a
--- /dev/null
+++ b/tests/purs/passing/ReExportsExported.js
@@ -0,0 +1,2 @@
+// Import `A.a` which was re-exported from `B` and then again from `C`
+export { a } from '../C/index.js';
diff --git a/tests/purs/passing/ReExportsExported.purs b/tests/purs/passing/ReExportsExported.purs
new file mode 100644
index 0000000000..077e20f1c0
--- /dev/null
+++ b/tests/purs/passing/ReExportsExported.purs
@@ -0,0 +1,7 @@
+module Main where
+
+import Effect.Console (log)
+
+foreign import a :: String
+
+main = log a
diff --git a/tests/purs/passing/ReExportsExported/A.purs b/tests/purs/passing/ReExportsExported/A.purs
new file mode 100644
index 0000000000..3371489f29
--- /dev/null
+++ b/tests/purs/passing/ReExportsExported/A.purs
@@ -0,0 +1,4 @@
+module A (a) where
+
+a :: String
+a = "Done"
diff --git a/tests/purs/passing/ReExportsExported/B.purs b/tests/purs/passing/ReExportsExported/B.purs
new file mode 100644
index 0000000000..84af99b864
--- /dev/null
+++ b/tests/purs/passing/ReExportsExported/B.purs
@@ -0,0 +1,7 @@
+module B (module A, A(..)) where
+
+import A
+
+-- | Test that there's no name collision between the imported module `A` and the
+-- | data constructor `A`.
+data A = A
diff --git a/tests/purs/passing/ReExportsExported/C.purs b/tests/purs/passing/ReExportsExported/C.purs
new file mode 100644
index 0000000000..222d09c31f
--- /dev/null
+++ b/tests/purs/passing/ReExportsExported/C.purs
@@ -0,0 +1,4 @@
+module C (module B) where
+
+-- | `A.a` was re-exported from `B` and then again from `C`
+import B
diff --git a/tests/purs/passing/RowLacks.purs b/tests/purs/passing/RowLacks.purs
index 06e7b91d09..34bee65f1a 100644
--- a/tests/purs/passing/RowLacks.purs
+++ b/tests/purs/passing/RowLacks.purs
@@ -2,22 +2,32 @@ module Main where
import Effect.Console (log)
import Prim.Row (class Lacks)
-import Type.Row (RProxy(..))
+import Type.Proxy (Proxy(..))
lacksX
:: forall r
. Lacks "x" r
- => RProxy r
- -> RProxy ()
-lacksX _ = RProxy
+ => Proxy r
+ -> Proxy ()
+lacksX _ = Proxy
-test1 :: RProxy ()
-test1 = lacksX (RProxy :: RProxy (y :: Int, z :: String))
+lacksSym
+ :: forall sym (to :: Row Type)
+ . Lacks sym to
+ => Proxy sym
+ -> Proxy to
+lacksSym _ = Proxy
-test2 :: forall r. Lacks "x" r => RProxy r -> RProxy ()
-test2 _ = lacksX (RProxy :: RProxy (y :: Int, z :: String | r))
+test1 :: Proxy ()
+test1 = lacksX (Proxy :: Proxy (y :: Int, z :: String))
-test3 :: RProxy ()
-test3 = test2 (RProxy :: RProxy (a :: String))
+test2 :: forall r. Lacks "x" r => Proxy r -> Proxy ()
+test2 _ = lacksX (Proxy :: Proxy (y :: Int, z :: String | r))
+
+test3 :: Proxy ()
+test3 = test2 (Proxy :: Proxy (a :: String))
+
+test4 :: forall sym. Proxy sym -> Proxy ()
+test4 = lacksSym
main = log "Done"
diff --git a/tests/purs/passing/RowNub.purs b/tests/purs/passing/RowNub.purs
index fd9f6ca3b8..574f192c8c 100644
--- a/tests/purs/passing/RowNub.purs
+++ b/tests/purs/passing/RowNub.purs
@@ -2,22 +2,22 @@ module Main where
import Effect.Console (log)
import Prim.Row (class Nub, class Union)
-import Type.Row (RProxy(..))
+import Type.Proxy (Proxy(..))
nubUnion
:: forall r1 r2 r3 r4
. Union r1 r2 r3
=> Nub r3 r4
- => RProxy r1
- -> RProxy r2
- -> RProxy r4
-nubUnion _ _ = RProxy
+ => Proxy r1
+ -> Proxy r2
+ -> Proxy r4
+nubUnion _ _ = Proxy
type InL = (x :: Int, y :: String)
type InR = (x :: String, y :: Int, z :: Boolean)
type Out = (x :: Int, y :: String, z :: Boolean)
-test :: RProxy Out
-test = nubUnion (RProxy :: RProxy InL) (RProxy :: RProxy InR)
+test :: Proxy Out
+test = nubUnion (Proxy :: Proxy InL) (Proxy :: Proxy InR)
main = log "Done"
diff --git a/tests/purs/passing/RowUnion.js b/tests/purs/passing/RowUnion.js
index c002b18f57..17697d3263 100644
--- a/tests/purs/passing/RowUnion.js
+++ b/tests/purs/passing/RowUnion.js
@@ -1,10 +1,6 @@
-"use strict";
-
-exports.merge = function (dict) {
- return function (l) {
- return function (r) {
- var o = {};
- return Object.assign(o, r, l);
- };
+export var mergeImpl = function (l) {
+ return function (r) {
+ var o = {};
+ return Object.assign(o, r, l);
};
};
diff --git a/tests/purs/passing/RowUnion.purs b/tests/purs/passing/RowUnion.purs
index 2b921f2037..a2197f4719 100644
--- a/tests/purs/passing/RowUnion.purs
+++ b/tests/purs/passing/RowUnion.purs
@@ -5,12 +5,33 @@ import Prim.Row
import Effect
import Effect.Console
-foreign import merge
+data Proxy a = Proxy
+
+solve :: forall l r u. Union l r u => Proxy r -> Proxy u -> Proxy l
+solve _ _ = Proxy
+
+solveUnionBackwardsNil :: Proxy _
+solveUnionBackwardsNil = solve (Proxy :: Proxy ()) (Proxy :: Proxy ())
+
+solveUnionBackwardsCons :: Proxy _
+solveUnionBackwardsCons = solve (Proxy :: Proxy ( a :: Int )) (Proxy :: Proxy ( a :: Int, b :: String ))
+
+solveUnionBackwardsDblCons :: Proxy _
+solveUnionBackwardsDblCons = solve (Proxy :: Proxy ( a :: Int, a :: String )) (Proxy :: Proxy ( a :: Boolean, a :: Int, a :: String ))
+
+merge
:: forall r1 r2 r3
. Union r1 r2 r3
=> Record r1
-> Record r2
-> Record r3
+merge = mergeImpl
+
+foreign import mergeImpl
+ :: forall r1 r2 r3
+ . Record r1
+ -> Record r2
+ -> Record r3
test1 = merge { x: 1 } { y: true }
@@ -48,7 +69,7 @@ withDefaultsClosed p = merge p { y: 1, z: 1 }
test4 = withDefaults { x: 1, y: 2 }
-- r is a subrow of s if Union r t s for some t.
-class Subrow (r :: # Type) (s :: # Type)
+class Subrow (r :: Row Type) (s :: Row Type)
instance subrow :: Union r t s => Subrow r s
main :: Effect Unit
diff --git a/tests/purs/passing/RowsInInstanceContext.purs b/tests/purs/passing/RowsInInstanceContext.purs
index 19fa17f01b..5f18cefcdb 100644
--- a/tests/purs/passing/RowsInInstanceContext.purs
+++ b/tests/purs/passing/RowsInInstanceContext.purs
@@ -3,7 +3,6 @@ module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
-import Data.Newtype (class Newtype, unwrap)
class TypeEquals a b | a -> b, b -> a where
coerce :: a -> b
@@ -15,9 +14,13 @@ instance refl :: TypeEquals a a where
newtype RecordNewtype = RecordNewtype { x :: String }
+class OldStyleNewtype t a where
+ wrap :: a -> t
+ unwrap :: t -> a
+
instance newtypeRecordNewtype ::
TypeEquals inner { x :: String }
- => Newtype RecordNewtype inner where
+ => OldStyleNewtype RecordNewtype inner where
wrap = RecordNewtype <<< coerce
unwrap (RecordNewtype rec) = coerceBack rec
diff --git a/tests/purs/passing/RowsInKinds.purs b/tests/purs/passing/RowsInKinds.purs
new file mode 100644
index 0000000000..e49a687a82
--- /dev/null
+++ b/tests/purs/passing/RowsInKinds.purs
@@ -0,0 +1,15 @@
+module Main where
+
+import Effect.Console (log)
+
+foreign import data R :: forall k. Row k -> Type
+foreign import data X :: forall r. R (x :: Type | r)
+foreign import data Y :: forall r. R (y :: Type | r)
+
+data P :: R (x :: Type, y :: Type) -> Type
+data P a = P
+
+type Test1 = P X
+type Test2 = P Y
+
+main = log "Done"
diff --git a/tests/purs/passing/RowsInKinds2.purs b/tests/purs/passing/RowsInKinds2.purs
new file mode 100644
index 0000000000..c046a1fee2
--- /dev/null
+++ b/tests/purs/passing/RowsInKinds2.purs
@@ -0,0 +1,11 @@
+module Main where
+
+import Effect.Console (log)
+
+foreign import data R :: forall k. Row k -> Type
+foreign import data X :: R ()
+
+data P :: R () -> Type
+data P a = P
+
+main = log "Done"
diff --git a/tests/purs/passing/SingleInstanceFundep.purs b/tests/purs/passing/SingleInstanceFundep.purs
new file mode 100644
index 0000000000..6b60504291
--- /dev/null
+++ b/tests/purs/passing/SingleInstanceFundep.purs
@@ -0,0 +1,21 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+import Type.Proxy (Proxy(..))
+
+-- This class can only have a single instance due to the functional dependency
+class SingleInstanceFundep (r :: Row Type) | -> r where
+ unified :: Proxy r
+
+-- The row literal is valid in this instance head since it is fully determined
+instance SingleInstanceFundep ( x :: Unit ) where
+ unified = Proxy
+
+-- This should infer `test :: Proxy ( x :: Unit )` by committing to the instance
+test :: Proxy _
+test = unified
+
+main = do
+ let (Proxy :: Proxy ( x :: Unit )) = test
+ log "Done"
diff --git a/tests/purs/passing/SolvingAddInt.purs b/tests/purs/passing/SolvingAddInt.purs
new file mode 100644
index 0000000000..16c44fb5fb
--- /dev/null
+++ b/tests/purs/passing/SolvingAddInt.purs
@@ -0,0 +1,26 @@
+module Main where
+
+import Effect.Console (log)
+import Prim.Int (class Add)
+
+data Proxy k = Proxy
+
+a :: forall n. Add 21 21 n => Proxy n
+a = Proxy
+
+a' :: Proxy 42
+a' = a
+
+b :: forall n. Add 21 n 42 => Proxy n
+b = Proxy
+
+b' :: Proxy 21
+b' = b
+
+c :: forall n. Add n 21 42 => Proxy n
+c = Proxy
+
+c' :: Proxy 21
+c' = c
+
+main = log "Done"
diff --git a/tests/purs/passing/SolvingAppendSymbol.purs b/tests/purs/passing/SolvingAppendSymbol.purs
index a1656dcea5..26d957bbe8 100644
--- a/tests/purs/passing/SolvingAppendSymbol.purs
+++ b/tests/purs/passing/SolvingAppendSymbol.purs
@@ -3,31 +3,31 @@ module Main where
import Prelude
import Effect.Console (log)
import Prim.Symbol (class Append)
-import Type.Data.Symbol (SProxy(..), reflectSymbol)
-import Type.Data.Symbol (append) as Symbol
+import Type.Proxy (Proxy(..))
+import Type.Data.Symbol (append, reflectSymbol) as Symbol
-sym :: SProxy ""
-sym = SProxy
+sym :: Proxy ""
+sym = Proxy
-symA :: SProxy "A"
-symA = SProxy
+symA :: Proxy "A"
+symA = Proxy
-symB :: SProxy "B"
-symB = SProxy
+symB :: Proxy "B"
+symB = Proxy
-egAB :: SProxy "AB"
+egAB :: Proxy "AB"
egAB = Symbol.append symA symB
-egBA :: SProxy "BA"
+egBA :: Proxy "BA"
egBA = Symbol.append symB symA
-egA' :: SProxy "A"
+egA' :: Proxy "A"
egA' = Symbol.append sym (Symbol.append symA sym)
main = do
- let gotAB = reflectSymbol egAB == "AB"
- gotBA = reflectSymbol egBA == "BA"
- gotA' = reflectSymbol egA' == "A"
+ let gotAB = Symbol.reflectSymbol egAB == "AB"
+ gotBA = Symbol.reflectSymbol egBA == "BA"
+ gotA' = Symbol.reflectSymbol egA' == "A"
when (not gotAB) $ log "Did not get AB"
when (not gotBA) $ log "Did not get BA"
when (not gotA') $ log "Did not get A"
diff --git a/tests/purs/passing/SolvingCompareInt.purs b/tests/purs/passing/SolvingCompareInt.purs
new file mode 100644
index 0000000000..bfd0d9e592
--- /dev/null
+++ b/tests/purs/passing/SolvingCompareInt.purs
@@ -0,0 +1,106 @@
+module Main where
+
+import Effect.Console (log)
+import Prim.Int (class Compare)
+import Prim.Ordering (EQ, GT, LT)
+
+data Proxy :: forall k. k -> Type
+data Proxy n = Proxy
+
+assertLesser :: forall l r. Compare l r LT => Proxy ( left :: l, right :: r )
+assertLesser = Proxy
+
+assertGreater :: forall l r. Compare l r GT => Proxy ( left :: l, right :: r )
+assertGreater = Proxy
+
+assertEqual :: forall l r. Compare l r EQ => Proxy ( left :: l, right :: r )
+assertEqual = Proxy
+
+symmLt :: forall m n. Compare m n GT => Proxy ( left :: n, right :: m )
+symmLt = assertLesser
+
+symmGt :: forall m n. Compare m n LT => Proxy ( left :: n, right :: m )
+symmGt = assertGreater
+
+symmEq :: forall m n. Compare m n EQ => Proxy ( left :: n, right :: m )
+symmEq = assertEqual
+
+reflEq :: forall (n :: Int). Proxy ( left :: n, right :: n )
+reflEq = assertEqual
+
+transLt :: forall m n p. Compare m n LT => Compare n p LT => Proxy n -> Proxy ( left :: m, right :: p )
+transLt _ = assertLesser
+
+transLtEq :: forall m n p. Compare m n LT => Compare n p EQ => Proxy n -> Proxy ( left :: m, right :: p )
+transLtEq _ = assertLesser
+
+transEqLt :: forall m n p. Compare m n EQ => Compare n p LT => Proxy n -> Proxy ( left :: m, right :: p )
+transEqLt _ = assertLesser
+
+transGt :: forall m n p. Compare m n GT => Compare n p GT => Proxy n -> Proxy ( left :: m, right :: p )
+transGt _ = assertGreater
+
+transGtEq :: forall m n p. Compare m n GT => Compare n p EQ => Proxy n -> Proxy ( left :: m, right :: p )
+transGtEq _ = assertGreater
+
+transEqGt :: forall m n p. Compare m n EQ => Compare n p GT => Proxy n -> Proxy ( left :: m, right :: p )
+transEqGt _ = assertGreater
+
+transEq :: forall m n p. Compare m n EQ => Compare n p EQ => Proxy n -> Proxy ( left :: m, right :: p )
+transEq _ = assertEqual
+
+transSymmLt :: forall m n p. Compare n m GT => Compare n p LT => Proxy n -> Proxy ( left :: m, right :: p )
+transSymmLt _ = assertLesser
+
+transSymmLtEq :: forall m n p. Compare n m GT => Compare n p EQ => Proxy n -> Proxy ( left :: m, right :: p )
+transSymmLtEq _ = assertLesser
+
+transSymmEqLt :: forall m n p. Compare n m EQ => Compare n p LT => Proxy n -> Proxy ( left :: m, right :: p )
+transSymmEqLt _ = assertLesser
+
+transSymmGt :: forall m n p. Compare n m LT => Compare n p GT => Proxy n -> Proxy ( left :: m, right :: p )
+transSymmGt _ = assertGreater
+
+transSymmGtEq :: forall m n p. Compare n m LT => Compare n p EQ => Proxy n -> Proxy ( left :: m, right :: p )
+transSymmGtEq _ = assertGreater
+
+transSymmEqGt :: forall m n p. Compare n m EQ => Compare n p GT => Proxy n -> Proxy ( left :: m, right :: p )
+transSymmEqGt _ = assertGreater
+
+transSymmEq :: forall m n p. Compare n m EQ => Compare n p EQ => Proxy n -> Proxy ( left :: m, right :: p )
+transSymmEq _ = assertEqual
+
+litLt :: Proxy ( left :: 0, right :: 1 )
+litLt = assertLesser
+
+litGt :: Proxy ( left :: 1, right :: 0 )
+litGt = assertGreater
+
+litEq :: Proxy ( left :: 0, right :: 0 )
+litEq = assertEqual
+
+class AssertIsGT o where
+ assertIsGT :: Proxy o -> Boolean
+
+instance AssertIsGT GT where
+ assertIsGT _ = true
+
+infer :: forall l r o. Compare l r o => AssertIsGT o => Proxy l -> Proxy r -> Boolean
+infer _ _ = assertIsGT (Proxy :: _ o)
+
+inferSolved :: forall m n p. Compare m n GT => Compare n p GT => Proxy m -> Proxy n -> Proxy p -> Boolean
+inferSolved m _ p = infer m p
+
+litTransLT :: forall a. Compare a 10 LT => Proxy ( left :: a, right :: 20 )
+litTransLT = assertLesser
+
+litTransGT :: forall a. Compare a 10 GT => Proxy ( left :: a, right :: 0 )
+litTransGT = assertGreater
+
+litTransRange :: forall a o. Compare a 10 LT => Compare 0 a LT => Proxy ( left :: a, right :: 20 )
+litTransRange = assertLesser
+
+withFacts :: forall l r o. Compare l 10 LT => Compare r 20 GT => Proxy ( left :: l, right :: r )
+withFacts = assertLesser
+
+main = log "Done"
diff --git a/tests/purs/passing/SolvingCompareSymbol.purs b/tests/purs/passing/SolvingCompareSymbol.purs
index 0b18b12fde..a0a68df42a 100644
--- a/tests/purs/passing/SolvingCompareSymbol.purs
+++ b/tests/purs/passing/SolvingCompareSymbol.purs
@@ -3,24 +3,24 @@ module Main where
import Prelude
import Effect.Console (log)
import Prim.Symbol (class Compare)
-import Prim.Ordering (kind Ordering, LT, EQ, GT)
-import Type.Data.Symbol (SProxy(..))
+import Prim.Ordering (Ordering, LT, EQ, GT)
+import Type.Proxy (Proxy(..))
import Type.Data.Symbol (compare) as Symbol
-import Type.Data.Ordering (OProxy(..), reflectOrdering)
+import Type.Data.Ordering (reflectOrdering)
-symA :: SProxy "A"
-symA = SProxy
+symA :: Proxy "A"
+symA = Proxy
-symB :: SProxy "B"
-symB = SProxy
+symB :: Proxy "B"
+symB = Proxy
-egLT :: OProxy LT
+egLT :: Proxy LT
egLT = Symbol.compare symA symB
-egEQ :: OProxy EQ
+egEQ :: Proxy EQ
egEQ = Symbol.compare symA symA
-egGT :: OProxy GT
+egGT :: Proxy GT
egGT = Symbol.compare symB symA
main = do
diff --git a/tests/purs/passing/SolvingIsSymbol/Lib.purs b/tests/purs/passing/SolvingIsSymbol/Lib.purs
index 18ea3b2924..0ceb55b8d2 100644
--- a/tests/purs/passing/SolvingIsSymbol/Lib.purs
+++ b/tests/purs/passing/SolvingIsSymbol/Lib.purs
@@ -1,10 +1,11 @@
module SolvingIsSymbol.Lib where
import Data.Symbol
+import Type.Proxy (Proxy(..))
-literalSymbol :: SProxy "literal"
-literalSymbol = SProxy
+literalSymbol :: Proxy "literal"
+literalSymbol = Proxy
-libReflectSymbol :: forall s. IsSymbol s => SProxy s -> String
+libReflectSymbol :: forall s. IsSymbol s => Proxy s -> String
libReflectSymbol = reflectSymbol
diff --git a/tests/purs/passing/SolvingMulInt.purs b/tests/purs/passing/SolvingMulInt.purs
new file mode 100644
index 0000000000..d5e854574d
--- /dev/null
+++ b/tests/purs/passing/SolvingMulInt.purs
@@ -0,0 +1,14 @@
+module Main where
+
+import Effect.Console (log)
+import Prim.Int (class Mul)
+
+data Proxy k = Proxy
+
+a :: forall n. Mul 4 4 n => Proxy n
+a = Proxy
+
+a' :: Proxy 16
+a' = a
+
+main = log "Done"
diff --git a/tests/purs/passing/SolvingReflectable.purs b/tests/purs/passing/SolvingReflectable.purs
new file mode 100644
index 0000000000..69842befb7
--- /dev/null
+++ b/tests/purs/passing/SolvingReflectable.purs
@@ -0,0 +1,50 @@
+module Main where
+
+import Prelude
+
+import Data.Ordering (Ordering(..))
+import Data.Reflectable (reflectType)
+import Effect.Console (log)
+import Prim.Boolean (True, False)
+import Prim.Ordering (LT, EQ, GT)
+import Type.Proxy (Proxy(..))
+
+refInt :: Proxy 42
+refInt = Proxy
+
+refIntPass :: Boolean
+refIntPass = reflectType refInt == 42
+
+refString :: Proxy "PureScript"
+refString = Proxy
+
+refStringPass :: Boolean
+refStringPass = reflectType refString == "PureScript"
+
+refBooleanT :: Proxy True
+refBooleanT = Proxy
+
+refBooleanF :: Proxy False
+refBooleanF = Proxy
+
+refBooleanPass :: Boolean
+refBooleanPass = reflectType refBooleanT == true && reflectType refBooleanF == false
+
+refOrderingLT :: Proxy LT
+refOrderingLT = Proxy
+
+refOrderingEQ :: Proxy EQ
+refOrderingEQ = Proxy
+
+refOrderingGT :: Proxy GT
+refOrderingGT = Proxy
+
+refOrderingPass :: Boolean
+refOrderingPass =
+ reflectType refOrderingLT == LT
+ && reflectType refOrderingEQ == EQ
+ && reflectType refOrderingGT == GT
+
+main = do
+ when (refIntPass && refStringPass && refBooleanPass && refOrderingPass) $
+ log "Done"
diff --git a/tests/purs/passing/StandaloneKindSignatures.purs b/tests/purs/passing/StandaloneKindSignatures.purs
new file mode 100644
index 0000000000..2e15f560ee
--- /dev/null
+++ b/tests/purs/passing/StandaloneKindSignatures.purs
@@ -0,0 +1,27 @@
+module Main where
+
+import Effect.Console (log)
+
+data Pair :: forall k. k -> k -> Type
+data Pair a b = Pair
+
+newtype Pair' :: forall k. k -> k -> Type
+newtype Pair' a b = Pair' (Pair a b)
+
+type Fst :: forall k. k -> k -> k
+type Fst a b = a
+
+class To :: forall k. k -> k -> Constraint
+class To a b | a -> b
+
+test1 = Pair :: Pair Int String
+test2 = Pair :: Pair "foo" "bar"
+test3 = Pair' Pair :: Pair' Int String
+test4 = Pair' Pair :: Pair' "foo" "bar"
+test5 = 42 :: Fst Int String
+test6 = Pair :: Pair (Fst "foo" "bar") "baz"
+
+instance to1 :: To Int String
+instance to2 :: To "foo" "bar"
+
+main = log "Done"
diff --git a/tests/purs/passing/StringEdgeCases/Symbols.purs b/tests/purs/passing/StringEdgeCases/Symbols.purs
index 0289a893d0..bdcc673158 100644
--- a/tests/purs/passing/StringEdgeCases/Symbols.purs
+++ b/tests/purs/passing/StringEdgeCases/Symbols.purs
@@ -6,15 +6,16 @@ module Symbols where
import Prelude
import Effect.Console (log)
import Prim.Symbol (class Append)
-import Type.Data.Symbol (SProxy(..), reflectSymbol)
+import Type.Data.Symbol (reflectSymbol)
import Type.Data.Symbol (append) as Symbol
import Test.Assert (assert')
+import Type.Proxy (Proxy(..))
-highS :: SProxy "\xd834"
-highS = SProxy
+highS :: Proxy "\xd834"
+highS = Proxy
-lowS :: SProxy "\xdf06"
-lowS = SProxy
+lowS :: Proxy "\xdf06"
+lowS = Proxy
loneSurrogates :: Boolean
loneSurrogates = reflectSymbol (Symbol.append highS lowS) == "\x1d306"
diff --git a/tests/purs/passing/TCOFloated.purs b/tests/purs/passing/TCOFloated.purs
new file mode 100644
index 0000000000..9283ec5355
--- /dev/null
+++ b/tests/purs/passing/TCOFloated.purs
@@ -0,0 +1,11 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+main = log (looper { foo: 100000 })
+
+-- The Ord instance for { foo :: Int } will be floated to an outer scope. This
+-- test verifies that TCO happens anyway.
+looper :: { foo :: Int } -> String
+looper x = if x <= { foo: 0 } then "Done" else looper { foo: x.foo - 1 }
diff --git a/tests/purs/passing/TCOMutRec.purs b/tests/purs/passing/TCOMutRec.purs
new file mode 100644
index 0000000000..6f599c5bd6
--- /dev/null
+++ b/tests/purs/passing/TCOMutRec.purs
@@ -0,0 +1,95 @@
+module Main where
+
+import Prelude
+import Effect (Effect)
+import Effect.Console (log)
+import Test.Assert (assertEqual, assertThrows)
+
+tco1 :: Int -> Int
+tco1 = f 0
+ where
+ f x y = g (x + 2) (y - 1)
+ where
+ g x' y' = if y' <= 0 then x' else f x' y'
+
+tco2 :: Int -> Int
+tco2 = f 0
+ where
+ f x y = g (x + 2) (y - 1)
+ where
+ g x' y' = h (y' <= 0) x' y'
+ h test x' y' = if test then x' else f x' y'
+
+tco3 :: Int -> Int
+tco3 y0 = f 0 y0
+ where
+ f x y = g x (h y)
+ where
+ g x' y' =
+ if y' <= 0 then x'
+ else if y' > y0 / 2 then g (j x') (y' - 1)
+ else f (x' + 2) y'
+ h y = y - 1
+ j x = x + 3
+
+tco4 :: Int -> Int
+tco4 = f 0
+ where
+ f x y = if y <= 0 then x else g (y - 1)
+ where
+ g y' = f (x + 2) y'
+
+-- The following examples are functions which are prevented from being TCO'd
+-- because the arity of the function being looped does not match the function
+-- call. In theory, these could be made to optimize via eta-expansion in the
+-- future, in which case the assertions can change.
+
+ntco1 :: Int -> Int
+ntco1 y0 = f 0 y0
+ where
+ f x = if x > 10 * y0 then (x + _) else g x
+ where
+ g x' y' = f (x' + 10) (y' - 1)
+
+ntco2 :: Int -> Int
+ntco2 = f 0
+ where
+ f x y = if y <= 0 then x else g x (y - 1)
+ where
+ g x' = f (x' + 2)
+
+ntco3 :: Int -> Int
+ntco3 = f 0
+ where
+ f x y = if y <= 0 then x else g (y - 1)
+ where
+ g = f (x + 2)
+
+ntco4 :: Int -> Int
+ntco4 = f 0
+ where
+ f x y = if y <= 0 then x else g (y - 1)
+ where
+ g = h x
+ h x' y' = f (x' + 2) y'
+
+main :: Effect Unit
+main = do
+ assertEqual { expected: 200000, actual: tco1 100000 }
+ assertEqual { expected: 200000, actual: tco2 100000 }
+ assertEqual { expected: 249997, actual: tco3 100000 }
+ assertEqual { expected: 200000, actual: tco4 100000 }
+
+ assertEqual { expected: 1009, actual: ntco1 100 }
+ assertThrows \_ -> ntco1 100000
+
+ assertEqual { expected: 200, actual: ntco2 100 }
+ assertThrows \_ -> ntco2 100000
+
+ assertEqual { expected: 200, actual: ntco3 100 }
+ assertThrows \_ -> ntco3 100000
+
+ assertEqual { expected: 200, actual: ntco4 100 }
+ assertThrows \_ -> ntco4 100000
+
+ log "Done"
diff --git a/tests/purs/passing/TransitiveImportUnnamedInstance.purs b/tests/purs/passing/TransitiveImportUnnamedInstance.purs
new file mode 100644
index 0000000000..62830afcb7
--- /dev/null
+++ b/tests/purs/passing/TransitiveImportUnnamedInstance.purs
@@ -0,0 +1,9 @@
+module Main where
+
+ import Prelude
+ import Middle
+ import Effect.Console
+
+ main = do
+ logShow (middle unit)
+ log "Done"
diff --git a/tests/purs/passing/TransitiveImportUnnamedInstance/Middle.purs b/tests/purs/passing/TransitiveImportUnnamedInstance/Middle.purs
new file mode 100644
index 0000000000..c4b5282a75
--- /dev/null
+++ b/tests/purs/passing/TransitiveImportUnnamedInstance/Middle.purs
@@ -0,0 +1,5 @@
+module Middle where
+
+import Test (test)
+
+middle = test
diff --git a/tests/purs/passing/TransitiveImportUnnamedInstance/Test.purs b/tests/purs/passing/TransitiveImportUnnamedInstance/Test.purs
new file mode 100644
index 0000000000..0bd0f0898e
--- /dev/null
+++ b/tests/purs/passing/TransitiveImportUnnamedInstance/Test.purs
@@ -0,0 +1,9 @@
+module Test where
+
+import Prelude
+
+class TestCls a where
+ test :: a -> a
+
+instance TestCls Unit where
+ test _ = unit
diff --git a/tests/purs/passing/TypeOperators.purs b/tests/purs/passing/TypeOperators.purs
index 2c0c4df8b3..a54ecd42b0 100644
--- a/tests/purs/passing/TypeOperators.purs
+++ b/tests/purs/passing/TypeOperators.purs
@@ -14,7 +14,21 @@ testPrecedence1 x = x
testPrecedence2 ∷ ∀ f g. f ~> g → f ~> g
testPrecedence2 nat fx = nat fx
+testParens ∷ ∀ f g. (~>) f g → (~>) f g
+testParens nat = nat
+
swap ∷ ∀ a b. a /\ b → b /\ a
swap (a /\ b) = b /\ a
+foreign import data NatData ∷ ∀ f g. (f ~> g) -> f Type -> g Type
+
+type NatKind ∷ ∀ f g. (f ~> g) -> f Type -> g Type
+type NatKind k a = k a
+
+data UseOperatorInDataParamKind (a :: Type /\ Type) = UseOperatorInDataParamKind
+
+type UseOperatorInTypeParamKind (a :: Type /\ Type) = Int
+
+class UseOperatorInClassParamKind (a :: Type /\ Type)
+
main = log "Done"
diff --git a/tests/purs/passing/TypeSynonymInSuperClass.purs b/tests/purs/passing/TypeSynonymInSuperClass.purs
new file mode 100644
index 0000000000..7b23d8e969
--- /dev/null
+++ b/tests/purs/passing/TypeSynonymInSuperClass.purs
@@ -0,0 +1,18 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+type Env = { foo :: String }
+
+class Monad m <= MonadAsk r m | m -> r where
+ ask :: m r
+
+class (Monad m, MonadAsk Env m) <= MonadAskEnv m
+
+test :: forall m. MonadAskEnv m => m Boolean
+test = do
+ { foo } <- ask
+ pure (foo == "test")
+
+main = log "Done"
diff --git a/tests/purs/passing/TypeSynonymInstance.purs b/tests/purs/passing/TypeSynonymInstance.purs
new file mode 100644
index 0000000000..9bfb9b292b
--- /dev/null
+++ b/tests/purs/passing/TypeSynonymInstance.purs
@@ -0,0 +1,16 @@
+module Main where
+
+import Prelude
+
+import Effect.Console (log)
+
+class Convert a b | a -> b where
+ convert :: a -> b
+
+type Words = String
+
+instance convertSB :: Convert Int Words where
+ convert 0 = "Nope"
+ convert _ = "Done"
+
+main = log $ convert 1
diff --git a/tests/purs/passing/TypeSynonymInstance2.purs b/tests/purs/passing/TypeSynonymInstance2.purs
new file mode 100644
index 0000000000..0f16f74642
--- /dev/null
+++ b/tests/purs/passing/TypeSynonymInstance2.purs
@@ -0,0 +1,14 @@
+module Main where
+
+import Effect.Console (log)
+
+data D
+type S = D
+
+class C0 a
+class C0 a <= C1 a
+
+instance c0 :: C0 D
+instance c1 :: C1 S
+
+main = log "Done"
diff --git a/tests/purs/passing/TypeSynonymInstance3.purs b/tests/purs/passing/TypeSynonymInstance3.purs
new file mode 100644
index 0000000000..874cf0bbf7
--- /dev/null
+++ b/tests/purs/passing/TypeSynonymInstance3.purs
@@ -0,0 +1,23 @@
+module Main where
+
+import Effect.Console (log)
+
+data Cons a b
+infix 6 type Cons as :*
+
+data D2
+data D5
+data D6
+data D8
+
+type D256 = D2 :* (D5 :* D6)
+
+class LtEq a b
+
+instance ltEqD8D256 :: LtEq D8 D256
+
+class (LtEq a D256) <= Lte256 a
+
+instance lte256 :: Lte256 D8
+
+main = log "Done"
diff --git a/tests/purs/passing/TypeSynonymInstance4.purs b/tests/purs/passing/TypeSynonymInstance4.purs
new file mode 100644
index 0000000000..829db5f7ba
--- /dev/null
+++ b/tests/purs/passing/TypeSynonymInstance4.purs
@@ -0,0 +1,13 @@
+module Main where
+
+import Effect.Console (log)
+
+data D
+type S = D
+newtype N a = N a
+
+class C a
+
+derive newtype instance c :: C S => C (N S)
+
+main = log "Done"
diff --git a/tests/purs/passing/TypeSynonymInstance5.purs b/tests/purs/passing/TypeSynonymInstance5.purs
new file mode 100644
index 0000000000..e9f7ae766b
--- /dev/null
+++ b/tests/purs/passing/TypeSynonymInstance5.purs
@@ -0,0 +1,13 @@
+module Main where
+
+import Effect.Console (log)
+
+data D
+type S = D
+newtype N a = N a
+
+class C a b
+
+derive newtype instance c :: C S a => C S (N a)
+
+main = log "Done"
diff --git a/tests/purs/passing/TypeSynonyms.purs b/tests/purs/passing/TypeSynonyms.purs
index 55ddf98f79..d8567b9920 100644
--- a/tests/purs/passing/TypeSynonyms.purs
+++ b/tests/purs/passing/TypeSynonyms.purs
@@ -25,4 +25,6 @@ fst =
test1 :: forall a b c. Lens (Pair (Pair a b) c) a
test1 = composeLenses fst fst
+newtype N = N (Array ~> Array)
+
main = log "Done"
diff --git a/tests/purs/passing/TypeSynonymsInKinds.purs b/tests/purs/passing/TypeSynonymsInKinds.purs
new file mode 100644
index 0000000000..4516593293
--- /dev/null
+++ b/tests/purs/passing/TypeSynonymsInKinds.purs
@@ -0,0 +1,25 @@
+module Main where
+
+import Effect.Console (log)
+
+type Id a = a
+
+data Proxy :: forall (k :: Id Type). k -> (Id Type)
+data Proxy a = Proxy
+
+data P (a :: Id Type) = P
+
+class Test (a :: Id Type)
+
+instance testClass1 :: Test Int
+instance testClass2 :: Test (Proxy "foo")
+
+test1 = Proxy :: Proxy Int
+test2 = Proxy :: Proxy "foo"
+
+test3 :: forall k (a :: Id k). Proxy a
+test3 = Proxy
+
+test4 = P :: P Int
+
+main = log "Done"
diff --git a/tests/purs/passing/VTAsClassHeads.purs b/tests/purs/passing/VTAsClassHeads.purs
new file mode 100644
index 0000000000..a25d7c4564
--- /dev/null
+++ b/tests/purs/passing/VTAsClassHeads.purs
@@ -0,0 +1,196 @@
+module Main where
+
+import Prelude
+import Data.Array as Array
+import Data.Array.NonEmpty as NEA
+import Data.Maybe (Maybe(..))
+import Data.Either (Either(..), either)
+import Data.Foldable (traverse_)
+import Data.Traversable (sequence)
+import Effect (Effect)
+import Effect.Console (log)
+
+class Singleton x where
+ singleton :: String
+
+instance Singleton Int where
+ singleton = "int"
+
+instance Singleton String where
+ singleton = "string"
+
+singletonWorks :: Effect (Maybe String)
+singletonWorks = do
+ let
+ left = singleton @Int
+ right = singleton @String
+ pure if left /= right then Nothing else Just "Singleton failed"
+
+class ConflictingIdent :: Type -> Constraint
+class ConflictingIdent a where
+ -- The `a` in the type below should refer to the `a`
+ -- introduced by the `forall`, not the class head.
+ conflictingIdent :: forall a. a -> Int
+
+instance ConflictingIdent String where
+ conflictingIdent _ = 1
+
+instance ConflictingIdent Int where
+ conflictingIdent _ = 2
+
+conflictingIdentWorks :: Effect (Maybe String)
+conflictingIdentWorks = do
+ pure if (1 == conflictingIdent @String 4) then Nothing else Just "ConflictingIdent failed"
+
+type M :: Type -> Type
+type M x = forall a. a -> Int
+
+class ConflictingIdentSynonym :: Type -> Constraint
+class ConflictingIdentSynonym a where
+ -- The `a` in the type below should refer to the `a`
+ -- introduced by the `forall`, not the class head.
+ conflictingIdentSynonym :: M a
+
+instance ConflictingIdentSynonym String where
+ conflictingIdentSynonym _ = 1
+
+instance ConflictingIdentSynonym Int where
+ conflictingIdentSynonym _ = 2
+
+conflictingIdentSynonymWorks :: Effect (Maybe String)
+conflictingIdentSynonymWorks = do
+ pure if (1 == conflictingIdentSynonym @String 4) then Nothing else Just "ConflictingIdentSynonym failed"
+
+class MultiNoFDs a b where
+ multiNoFds :: Int
+
+instance MultiNoFDs Int Int where
+ multiNoFds = 0
+
+instance MultiNoFDs String Int where
+ multiNoFds = 1
+
+multiNoFdsWorks :: Effect (Maybe String)
+multiNoFdsWorks = do
+ let
+ left = multiNoFds @Int @Int
+ right = multiNoFds @String @Int
+ pure if left /= right then Nothing else Just "MultiNoFDs failed"
+
+class MultiWithFDs a b | a -> b where
+ multiWithFDs :: Int
+
+instance MultiWithFDs Int Int where
+ multiWithFDs = 0
+
+instance MultiWithFDs String Int where
+ multiWithFDs = 1
+
+multiWithFdsWorks :: Effect (Maybe String)
+multiWithFdsWorks = do
+ let
+ left = multiWithFDs @Int
+ right = multiWithFDs @String
+ pure if left /= right then Nothing else Just "MultiWithFds failed"
+
+class MultiWithBidiFDs a b | a -> b, b -> a where
+ multiWithBidiFDs :: Int
+
+instance MultiWithBidiFDs Int Int where
+ multiWithBidiFDs = 0
+
+instance MultiWithBidiFDs String String where
+ multiWithBidiFDs = 1
+
+multiWithBidiFDsLeftWorks :: Effect (Maybe String)
+multiWithBidiFDsLeftWorks = do
+ let
+ left = multiWithBidiFDs @Int
+ right = multiWithBidiFDs @String
+ pure if left /= right then Nothing else Just "MultiWithFds failed"
+
+multiWithBidiFDsRightWorks :: Effect (Maybe String)
+multiWithBidiFDsRightWorks = do
+ let
+ left = multiWithBidiFDs @_ @Int
+ right = multiWithBidiFDs @_ @String
+ pure if left /= right then Nothing else Just "MultiWithFds failed"
+
+class Superclass a where
+ superClassValue :: a
+
+class Superclass a <= MainClass a where
+ mainClassInt :: Int
+
+data A2 = A2
+
+derive instance Eq A2
+
+instance Superclass A2 where
+ superClassValue = A2
+
+instance MainClass A2 where
+ mainClassInt = 0
+
+data B2 = B2
+
+derive instance Eq B2
+
+instance Superclass B2 where
+ superClassValue = B2
+
+instance MainClass B2 where
+ mainClassInt = 3
+
+mainClassWorks :: Effect (Maybe String)
+mainClassWorks = do
+ let
+ test1 = 0 == mainClassInt @A2
+ test2 = A2 == superClassValue @A2
+ pure if test1 && test2 then Nothing else Just "MainClass failed"
+
+class MultiCoveringSets a b c d e f | a b -> c d e f, f e -> a b c d where
+ noneOfSets :: Int
+
+ partialOfABSet :: a -> { c :: c, d :: d }
+
+ partialOfFESet :: f -> { c :: c, d :: d }
+
+instance MultiCoveringSets Boolean Boolean String String Int Int where
+ noneOfSets = 1
+ partialOfABSet a = { c: if a then "101" else "100", d: "1" }
+ partialOfFESet f = { c: show f, d: "1" }
+
+instance MultiCoveringSets Int Int String String Boolean Boolean where
+ noneOfSets = 2
+ partialOfABSet a = { c: show a, d: "2" }
+ partialOfFESet f = { c: show f, d: "2" }
+
+multiCoveringSetsWorks :: Effect (Maybe String)
+multiCoveringSetsWorks = do
+ let
+ test1a = 1 == noneOfSets @Boolean @Boolean
+ test1b = "101" == (partialOfABSet @Boolean @Boolean true).c
+ test1c = show 3 == (partialOfFESet @_ @_ @_ @_ @Int @Int 3).c
+ test2a = 2 == noneOfSets @_ @_ @_ @_ @Boolean @Boolean
+ test2b = show 20 == (partialOfABSet @_ @_ @_ @_ @Boolean @Boolean 20).c
+ test2c = show false == (partialOfFESet @_ @_ @_ @_ @Boolean @Boolean false).c
+ passes = test1a && test1b && test1c && test2a && test2b && test2c
+ pure if passes then Nothing else Just "MultiCoveringSets failed"
+
+main = do
+ arr' <- sequence
+ [ singletonWorks
+ , conflictingIdentWorks
+ , conflictingIdentSynonymWorks
+ , multiNoFdsWorks
+ , multiWithFdsWorks
+ , multiWithBidiFDsLeftWorks
+ , multiWithBidiFDsRightWorks
+ , mainClassWorks
+ ]
+ case NEA.fromArray $ Array.catMaybes arr' of
+ Just errs ->
+ log $ "Errors..." <> (Array.intercalate "\n" $ NEA.toArray errs)
+ Nothing ->
+ log "Done"
diff --git a/tests/purs/passing/VisibleTypeApplications.purs b/tests/purs/passing/VisibleTypeApplications.purs
new file mode 100644
index 0000000000..ea555a386e
--- /dev/null
+++ b/tests/purs/passing/VisibleTypeApplications.purs
@@ -0,0 +1,40 @@
+module Main where
+
+import Prelude
+import Effect.Console (log)
+
+foreign import data Id :: forall (a :: Type). a -> a
+
+identityCheck :: forall (@f :: forall (a :: Type). a -> a). Int
+identityCheck = 0
+
+identityPass :: Int
+identityPass = identityCheck @Id
+
+foreign import data Const :: forall a b. a -> b -> a
+
+constCheck :: forall (a :: Type) (@f :: forall (b :: Type). b -> a). Int
+constCheck = 0
+
+constPass :: Int
+constPass = constCheck @(Const Int)
+
+-- Type variables in class heads and data declarations are always visible.
+
+class ConstClass a where
+ constClass :: forall @b. a -> b -> a
+
+instance ConstClass a where
+ constClass a _ = a
+
+constClassInt = constClass @Int @Number
+
+data Tree a = Leaf a | Branch (Tree a) (Tree a)
+
+treeInt :: Int -> Tree Int
+treeInt = Leaf @Int
+
+treeInt' :: Tree Int -> Tree Int -> Tree Int
+treeInt' = Branch @Int
+
+main = log "Done"
diff --git a/tests/purs/psci/BasicEval.purs b/tests/purs/psci/BasicEval.purs
index 2722a71081..1a909cd41e 100644
--- a/tests/purs/psci/BasicEval.purs
+++ b/tests/purs/psci/BasicEval.purs
@@ -8,3 +8,12 @@ fac n = foldl mul 1 (1..n)
-- @shouldEvaluateTo 3628800
fac 10
+
+infix 4 mul as |*|
+
+-- @shouldEvaluateTo 50
+5 |*| 10
+
+data X a = X
+
+type role X representational
diff --git a/tests/purs/psci/Multiline.purs b/tests/purs/psci/Multiline.purs
index c12f543732..aa023827b7 100644
--- a/tests/purs/psci/Multiline.purs
+++ b/tests/purs/psci/Multiline.purs
@@ -10,3 +10,8 @@ fac n = foldl mul 1 (1..n)
-- @shouldEvaluateTo 3628800
fac 10
+
+-- @paste
+data X :: Type -> Type
+data X a = X
+-- @paste
diff --git a/tests/purs/publish/basic-example/purs.json b/tests/purs/publish/basic-example/purs.json
new file mode 100644
index 0000000000..bed21e3be3
--- /dev/null
+++ b/tests/purs/publish/basic-example/purs.json
@@ -0,0 +1,14 @@
+{
+ "name": "basic-example",
+ "version": "1.0.0",
+ "license": "MIT",
+ "location": {
+ "githubOwner": "purescript",
+ "githubRepo": "test"
+ },
+ "dependencies": {
+ "console": ">=1.0.0 <2.0.0",
+ "prelude": ">=1.0.0 <2.0.0",
+ "effect": ">=1.0.0 <2.0.0"
+ }
+}
diff --git a/tests/purs/publish/basic-example/resolutions-legacy.json b/tests/purs/publish/basic-example/resolutions-legacy.json
deleted file mode 100644
index c08e4d9fac..0000000000
--- a/tests/purs/publish/basic-example/resolutions-legacy.json
+++ /dev/null
@@ -1,640 +0,0 @@
-{
- "endpoint": {
- "name": "basic-example",
- "source": ".",
- "target": "*"
- },
- "canonicalDir": ".",
- "pkgMeta": {
- "name": "basic-example",
- "ignore": [
- "**/.*",
- "node_modules",
- "bower_components",
- "output"
- ],
- "dependencies": {
- "purescript-prelude": "^4.1.0",
- "purescript-console": "^4.2.0",
- "purescript-effect": "^2.0.1",
- "purescript-newtype": "#master"
- },
- "devDependencies": {
- "purescript-psci-support": "^4.0.0"
- }
- },
- "dependencies": {
- "purescript-console": {
- "endpoint": {
- "name": "purescript-console",
- "source": "purescript-console",
- "target": "^4.2.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-console",
- "pkgMeta": {
- "name": "purescript-console",
- "homepage": "https://github.com/purescript/purescript-console",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-console.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "dependencies": {
- "purescript-effect": "^2.0.0",
- "purescript-prelude": "^4.0.0"
- },
- "version": "4.2.0",
- "_release": "4.2.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.2.0",
- "commit": "add2bdb8a4af2213d993b728805f1f2a5e76deb8"
- },
- "_source": "https://github.com/purescript/purescript-console.git",
- "_target": "^4.2.0",
- "_originalSource": "purescript-console"
- },
- "dependencies": {
- "purescript-effect": {
- "endpoint": {
- "name": "purescript-effect",
- "source": "purescript-effect",
- "target": "^2.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-effect",
- "pkgMeta": {
- "name": "purescript-effect",
- "homepage": "https://github.com/purescript/purescript-effect",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-effect.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "dependencies": {
- "purescript-prelude": "^4.0.0"
- },
- "version": "2.0.1",
- "_release": "2.0.1",
- "_resolution": {
- "type": "version",
- "tag": "v2.0.1",
- "commit": "d2a11e69abcda3b81c750e86e8746cda278f47bf"
- },
- "_source": "https://github.com/purescript/purescript-effect.git",
- "_target": "^2.0.1",
- "_originalSource": "purescript-effect"
- },
- "dependencies": {
- "purescript-prelude": {
- "endpoint": {
- "name": "purescript-prelude",
- "source": "purescript-prelude",
- "target": "^4.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-prelude",
- "pkgMeta": {
- "name": "purescript-prelude",
- "homepage": "https://github.com/purescript/purescript-prelude",
- "description": "The PureScript Prelude",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-prelude.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "version": "4.1.0",
- "_release": "4.1.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.1.0",
- "commit": "7a691ce2658bd8eaf28439391e29506dd154fb3d"
- },
- "_source": "https://github.com/purescript/purescript-prelude.git",
- "_target": "^4.1.0",
- "_originalSource": "purescript-prelude"
- },
- "dependencies": {},
- "nrDependants": 1
- }
- },
- "nrDependants": 1
- },
- "purescript-prelude": {
- "endpoint": {
- "name": "purescript-prelude",
- "source": "purescript-prelude",
- "target": "^4.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-prelude",
- "pkgMeta": {
- "name": "purescript-prelude",
- "homepage": "https://github.com/purescript/purescript-prelude",
- "description": "The PureScript Prelude",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-prelude.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "version": "4.1.0",
- "_release": "4.1.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.1.0",
- "commit": "7a691ce2658bd8eaf28439391e29506dd154fb3d"
- },
- "_source": "https://github.com/purescript/purescript-prelude.git",
- "_target": "^4.1.0",
- "_originalSource": "purescript-prelude"
- },
- "dependencies": {},
- "nrDependants": 1
- }
- },
- "nrDependants": 1
- },
- "purescript-effect": {
- "endpoint": {
- "name": "purescript-effect",
- "source": "purescript-effect",
- "target": "^2.0.1"
- },
- "canonicalDir": "../../../support/bower_components/purescript-effect",
- "pkgMeta": {
- "name": "purescript-effect",
- "homepage": "https://github.com/purescript/purescript-effect",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-effect.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "dependencies": {
- "purescript-prelude": "^4.0.0"
- },
- "version": "2.0.1",
- "_release": "2.0.1",
- "_resolution": {
- "type": "version",
- "tag": "v2.0.1",
- "commit": "d2a11e69abcda3b81c750e86e8746cda278f47bf"
- },
- "_source": "https://github.com/purescript/purescript-effect.git",
- "_target": "^2.0.1",
- "_originalSource": "purescript-effect"
- },
- "dependencies": {},
- "nrDependants": 1
- },
- "purescript-newtype": {
- "endpoint": {
- "name": "purescript-newtype",
- "source": "purescript-newtype",
- "target": "master"
- },
- "canonicalDir": "../../../support/bower_components/purescript-newtype",
- "pkgMeta": {
- "name": "purescript-newtype",
- "homepage": "https://github.com/purescript/purescript-newtype",
- "description": "Type class and functions for working with newtypes",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-newtype.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "dependencies": {
- "purescript-prelude": "^4.0.0"
- },
- "_release": "7d85fa6a04",
- "_resolution": {
- "type": "branch",
- "branch": "master",
- "commit": "7d85fa6a040208c010b05f7c23af6a943ba08763"
- },
- "_source": "https://github.com/garyb/purescript-newtype.git",
- "_target": "master",
- "_originalSource": "purescript-newtype"
- },
- "dependencies": {
- "purescript-prelude": {
- "endpoint": {
- "name": "purescript-prelude",
- "source": "purescript-prelude",
- "target": "^4.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-prelude",
- "pkgMeta": {
- "name": "purescript-prelude",
- "homepage": "https://github.com/purescript/purescript-prelude",
- "description": "The PureScript Prelude",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-prelude.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "version": "4.1.0",
- "_release": "4.1.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.1.0",
- "commit": "7a691ce2658bd8eaf28439391e29506dd154fb3d"
- },
- "_source": "https://github.com/purescript/purescript-prelude.git",
- "_target": "^4.1.0",
- "_originalSource": "purescript-prelude"
- },
- "dependencies": {},
- "nrDependants": 1
- }
- },
- "nrDependants": 1
- },
- "purescript-prelude": {
- "endpoint": {
- "name": "purescript-prelude",
- "source": "purescript-prelude",
- "target": "^4.1.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-prelude",
- "pkgMeta": {
- "name": "purescript-prelude",
- "homepage": "https://github.com/purescript/purescript-prelude",
- "description": "The PureScript Prelude",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-prelude.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "version": "4.1.0",
- "_release": "4.1.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.1.0",
- "commit": "7a691ce2658bd8eaf28439391e29506dd154fb3d"
- },
- "_source": "https://github.com/purescript/purescript-prelude.git",
- "_target": "^4.1.0",
- "_originalSource": "purescript-prelude"
- },
- "dependencies": {},
- "nrDependants": 1
- },
- "purescript-psci-support": {
- "endpoint": {
- "name": "purescript-psci-support",
- "source": "purescript-psci-support",
- "target": "^4.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-psci-support",
- "pkgMeta": {
- "name": "purescript-psci-support",
- "homepage": "https://github.com/purescript/purescript-psci-support",
- "description": "Support module for the PSCI interactive mode",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-psci-support.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "bower.json",
- "package.json"
- ],
- "dependencies": {
- "purescript-console": "^4.0.0",
- "purescript-effect": "^2.0.0",
- "purescript-prelude": "^4.0.0"
- },
- "version": "4.0.0",
- "_release": "4.0.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.0.0",
- "commit": "a66a0fa8661eb8b5fe75cc862f4e2df2835c058d"
- },
- "_source": "https://github.com/purescript/purescript-psci-support.git",
- "_target": "^4.0.0",
- "_originalSource": "purescript-psci-support"
- },
- "dependencies": {
- "purescript-console": {
- "endpoint": {
- "name": "purescript-console",
- "source": "purescript-console",
- "target": "^4.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-console",
- "pkgMeta": {
- "name": "purescript-console",
- "homepage": "https://github.com/purescript/purescript-console",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-console.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "dependencies": {
- "purescript-effect": "^2.0.0",
- "purescript-prelude": "^4.0.0"
- },
- "version": "4.2.0",
- "_release": "4.2.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.2.0",
- "commit": "add2bdb8a4af2213d993b728805f1f2a5e76deb8"
- },
- "_source": "https://github.com/purescript/purescript-console.git",
- "_target": "^4.2.0",
- "_originalSource": "purescript-console"
- },
- "dependencies": {
- "purescript-effect": {
- "endpoint": {
- "name": "purescript-effect",
- "source": "purescript-effect",
- "target": "^2.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-effect",
- "pkgMeta": {
- "name": "purescript-effect",
- "homepage": "https://github.com/purescript/purescript-effect",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-effect.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "dependencies": {
- "purescript-prelude": "^4.0.0"
- },
- "version": "2.0.1",
- "_release": "2.0.1",
- "_resolution": {
- "type": "version",
- "tag": "v2.0.1",
- "commit": "d2a11e69abcda3b81c750e86e8746cda278f47bf"
- },
- "_source": "https://github.com/purescript/purescript-effect.git",
- "_target": "^2.0.1",
- "_originalSource": "purescript-effect"
- },
- "dependencies": {
- "purescript-prelude": {
- "endpoint": {
- "name": "purescript-prelude",
- "source": "purescript-prelude",
- "target": "^4.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-prelude",
- "pkgMeta": {
- "name": "purescript-prelude",
- "homepage": "https://github.com/purescript/purescript-prelude",
- "description": "The PureScript Prelude",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-prelude.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "version": "4.1.0",
- "_release": "4.1.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.1.0",
- "commit": "7a691ce2658bd8eaf28439391e29506dd154fb3d"
- },
- "_source": "https://github.com/purescript/purescript-prelude.git",
- "_target": "^4.1.0",
- "_originalSource": "purescript-prelude"
- },
- "dependencies": {},
- "nrDependants": 1
- }
- },
- "nrDependants": 1
- },
- "purescript-prelude": {
- "endpoint": {
- "name": "purescript-prelude",
- "source": "purescript-prelude",
- "target": "^4.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-prelude",
- "pkgMeta": {
- "name": "purescript-prelude",
- "homepage": "https://github.com/purescript/purescript-prelude",
- "description": "The PureScript Prelude",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-prelude.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "version": "4.1.0",
- "_release": "4.1.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.1.0",
- "commit": "7a691ce2658bd8eaf28439391e29506dd154fb3d"
- },
- "_source": "https://github.com/purescript/purescript-prelude.git",
- "_target": "^4.1.0",
- "_originalSource": "purescript-prelude"
- },
- "dependencies": {},
- "nrDependants": 1
- }
- },
- "nrDependants": 1
- },
- "purescript-effect": {
- "endpoint": {
- "name": "purescript-effect",
- "source": "purescript-effect",
- "target": "^2.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-effect",
- "pkgMeta": {
- "name": "purescript-effect",
- "homepage": "https://github.com/purescript/purescript-effect",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-effect.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "dependencies": {
- "purescript-prelude": "^4.0.0"
- },
- "version": "2.0.1",
- "_release": "2.0.1",
- "_resolution": {
- "type": "version",
- "tag": "v2.0.1",
- "commit": "d2a11e69abcda3b81c750e86e8746cda278f47bf"
- },
- "_source": "https://github.com/purescript/purescript-effect.git",
- "_target": "^2.0.1",
- "_originalSource": "purescript-effect"
- },
- "dependencies": {},
- "nrDependants": 1
- },
- "purescript-prelude": {
- "endpoint": {
- "name": "purescript-prelude",
- "source": "purescript-prelude",
- "target": "^4.0.0"
- },
- "canonicalDir": "../../../support/bower_components/purescript-prelude",
- "pkgMeta": {
- "name": "purescript-prelude",
- "homepage": "https://github.com/purescript/purescript-prelude",
- "description": "The PureScript Prelude",
- "license": "BSD-3-Clause",
- "repository": {
- "type": "git",
- "url": "git://github.com/purescript/purescript-prelude.git"
- },
- "ignore": [
- "**/.*",
- "bower_components",
- "node_modules",
- "output",
- "test",
- "bower.json",
- "package.json"
- ],
- "version": "4.1.0",
- "_release": "4.1.0",
- "_resolution": {
- "type": "version",
- "tag": "v4.1.0",
- "commit": "7a691ce2658bd8eaf28439391e29506dd154fb3d"
- },
- "_source": "https://github.com/purescript/purescript-prelude.git",
- "_target": "^4.1.0",
- "_originalSource": "purescript-prelude"
- },
- "dependencies": {},
- "nrDependants": 1
- }
- },
- "nrDependants": 1
- }
- },
- "nrDependants": 0
-}
diff --git a/tests/purs/publish/basic-example/resolutions.json b/tests/purs/publish/basic-example/resolutions.json
index 2e92161913..0cdda6f269 100644
--- a/tests/purs/publish/basic-example/resolutions.json
+++ b/tests/purs/publish/basic-example/resolutions.json
@@ -13,5 +13,11 @@
},
"purescript-newtype": {
"path": "../../../support/bower_components/purescript-newtype"
+ },
+ "purescript-safe-coerce": {
+ "path": "../../../support/bower_components/purescript-safe-coerce"
+ },
+ "purescript-unsafe-coerce": {
+ "path": "../../../support/bower_components/purescript-unsafe-coerce"
}
}
diff --git a/tests/purs/sourcemaps/Bug4034.js b/tests/purs/sourcemaps/Bug4034.js
new file mode 100644
index 0000000000..b96fed8d19
--- /dev/null
+++ b/tests/purs/sourcemaps/Bug4034.js
@@ -0,0 +1,51 @@
+export const log = function (s) {
+ return function () {
+ console.log(s);
+ };
+};
+
+export const warn = function (s) {
+ return function () {
+ console.warn(s);
+ };
+};
+
+export const error = function (s) {
+ return function () {
+ console.error(s);
+ };
+};
+
+export const info = function (s) {
+ return function () {
+ console.info(s);
+ };
+};
+
+export const debug = function (s) {
+ return function () {
+ console.debug(s);
+ };
+};
+
+export const time = function (s) {
+ return function () {
+ console.time(s);
+ };
+};
+
+export const timeLog = function (s) {
+ return function () {
+ console.timeLog(s);
+ };
+};
+
+export const timeEnd = function (s) {
+ return function () {
+ console.timeEnd(s);
+ };
+};
+
+export const clear = function () {
+ console.clear();
+};
diff --git a/tests/purs/sourcemaps/Bug4034.out.js.map b/tests/purs/sourcemaps/Bug4034.out.js.map
new file mode 100644
index 0000000000..3e89a756b1
--- /dev/null
+++ b/tests/purs/sourcemaps/Bug4034.out.js.map
@@ -0,0 +1 @@
+{"file":"index.js","mappings":";;;;;;;;AA2BA,eAAA;;WAAA;kCACwB;;;;;;AAXxB,cAAA;;WAAA;iCACsB;;;;;;AA6BtB,eAAA;;WAAA;kCACwB;;;;;;AAXxB,gBAAA;;WAAA;mCAC0B;;;;;;AAmB1B,gBAAA;;WAAA;mCAC0B","names":[],"sources":["../../tests/purs/sourcemaps/Bug4034.purs"],"version":3}
\ No newline at end of file
diff --git a/tests/purs/sourcemaps/Bug4034.purs b/tests/purs/sourcemaps/Bug4034.purs
new file mode 100644
index 0000000000..14fbb70be8
--- /dev/null
+++ b/tests/purs/sourcemaps/Bug4034.purs
@@ -0,0 +1,71 @@
+-- | This module is the same as `purescript-effect@v6.0.0`'s `Effect.Console` file
+-- | under a different module name.
+-- | This verifies that null source spans are no longer emitted.
+module SourceMaps.Bug4034 where
+
+import Effect (Effect)
+
+import Data.Show (class Show, show)
+import Data.Unit (Unit)
+
+-- | Write a message to the console.
+foreign import log
+ :: String
+ -> Effect Unit
+
+-- | Write a value to the console, using its `Show` instance to produce a
+-- | `String`.
+logShow :: forall a. Show a => a -> Effect Unit
+logShow a = log (show a)
+
+-- | Write an warning to the console.
+foreign import warn
+ :: String
+ -> Effect Unit
+
+-- | Write an warning value to the console, using its `Show` instance to produce
+-- | a `String`.
+warnShow :: forall a. Show a => a -> Effect Unit
+warnShow a = warn (show a)
+
+-- | Write an error to the console.
+foreign import error
+ :: String
+ -> Effect Unit
+
+-- | Write an error value to the console, using its `Show` instance to produce a
+-- | `String`.
+errorShow :: forall a. Show a => a -> Effect Unit
+errorShow a = error (show a)
+
+-- | Write an info message to the console.
+foreign import info
+ :: String
+ -> Effect Unit
+
+-- | Write an info value to the console, using its `Show` instance to produce a
+-- | `String`.
+infoShow :: forall a. Show a => a -> Effect Unit
+infoShow a = info (show a)
+
+-- | Write an debug message to the console.
+foreign import debug
+ :: String
+ -> Effect Unit
+
+-- | Write an debug value to the console, using its `Show` instance to produce a
+-- | `String`.
+debugShow :: forall a. Show a => a -> Effect Unit
+debugShow a = debug (show a)
+
+-- | Start a named timer.
+foreign import time :: String -> Effect Unit
+
+-- | Print the time since a named timer started in milliseconds.
+foreign import timeLog :: String -> Effect Unit
+
+-- | Stop a named timer and print time since it started in milliseconds.
+foreign import timeEnd :: String -> Effect Unit
+
+-- | Clears the console
+foreign import clear :: Effect Unit
diff --git a/tests/purs/sourcemaps/Recipe.out.js.map b/tests/purs/sourcemaps/Recipe.out.js.map
new file mode 100644
index 0000000000..b296ffd692
--- /dev/null
+++ b/tests/purs/sourcemaps/Recipe.out.js.map
@@ -0,0 +1 @@
+{"file":"index.js","mappings":"","names":[],"sources":[],"version":3}
\ No newline at end of file
diff --git a/tests/purs/sourcemaps/Recipe.purs b/tests/purs/sourcemaps/Recipe.purs
new file mode 100644
index 0000000000..c6b6880dd3
--- /dev/null
+++ b/tests/purs/sourcemaps/Recipe.purs
@@ -0,0 +1,3 @@
+-- | This file demonstrates the naming convention to use for
+-- | source map tests
+module SourceMaps.Recipe where
diff --git a/tests/purs/warning/.gitattributes b/tests/purs/warning/.gitattributes
new file mode 100644
index 0000000000..d0b673f439
--- /dev/null
+++ b/tests/purs/warning/.gitattributes
@@ -0,0 +1 @@
+*.out -merge -text
diff --git a/tests/purs/warning/2140.out b/tests/purs/warning/2140.out
new file mode 100644
index 0000000000..3d81edd247
--- /dev/null
+++ b/tests/purs/warning/2140.out
@@ -0,0 +1,11 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/2140.purs:5:3 - 5:36 (line 5, column 3 - line 5, column 36)
+
+ Type variable [33ma[0m was shadowed.
+
+in type declaration for [33mf[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ShadowedTypeVar.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/2383.out b/tests/purs/warning/2383.out
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/purs/warning/2383.purs b/tests/purs/warning/2383.purs
index 855a4d6ba4..d0ab440e29 100644
--- a/tests/purs/warning/2383.purs
+++ b/tests/purs/warning/2383.purs
@@ -9,4 +9,5 @@ import Effect (Effect)
main :: Effect Unit
main = do
x <- let x = pure unit in x
+ let _ = x -- don't warn x is unused
pure unit
diff --git a/tests/purs/warning/2411.out b/tests/purs/warning/2411.out
new file mode 100644
index 0000000000..8798346cda
--- /dev/null
+++ b/tests/purs/warning/2411.out
@@ -0,0 +1,11 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/2411.purs:11:7 - 11:15 (line 11, column 7 - line 11, column 15)
+
+ Name [33mx[0m was shadowed.
+
+in value declaration [33mtest[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ShadowedName.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/2411.purs b/tests/purs/warning/2411.purs
index 581c606479..ddc267c106 100644
--- a/tests/purs/warning/2411.purs
+++ b/tests/purs/warning/2411.purs
@@ -7,6 +7,7 @@ import Effect (Effect)
test :: forall m. Monad m => Int -> m Unit
test x =
+ let _ = x in -- don't mark x unused
let x = unit
in pure x
diff --git a/tests/purs/warning/2542.out b/tests/purs/warning/2542.out
new file mode 100644
index 0000000000..1b0cef80a1
--- /dev/null
+++ b/tests/purs/warning/2542.out
@@ -0,0 +1,16 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/2542.purs:16:1 - 16:18 (line 16, column 1 - line 16, column 18)
+
+ No type declaration was provided for the top-level declaration of [33mmain[0m.
+ It is good practice to provide type declarations as a form of documentation.
+ The inferred type of [33mmain[0m was:
+ [33m [0m
+ [33m Effect Unit[0m
+ [33m [0m
+
+in value declaration [33mmain[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingTypeDeclaration.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/4183.out b/tests/purs/warning/4183.out
new file mode 100644
index 0000000000..17501978ae
--- /dev/null
+++ b/tests/purs/warning/4183.out
@@ -0,0 +1,15 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/4183.purs:4:1 - 4:21 (line 4, column 1 - line 4, column 21)
+
+ The inferred kind for the type declaration [33mT[0m contains polymorphic kinds.
+ Consider adding a top-level kind signature as a form of documentation.
+ [33m [0m
+ [33m type T :: forall k. (k -> k) -> k -> k[0m
+ [33m [0m
+
+in type synonym [33mT[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingKindDeclaration.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/4183.purs b/tests/purs/warning/4183.purs
new file mode 100644
index 0000000000..7a9b4871c4
--- /dev/null
+++ b/tests/purs/warning/4183.purs
@@ -0,0 +1,4 @@
+-- @shouldWarnWith MissingKindDeclaration
+module Main where
+
+type T f a = f (f a)
diff --git a/tests/purs/warning/4256.out b/tests/purs/warning/4256.out
new file mode 100644
index 0000000000..cbf4467e21
--- /dev/null
+++ b/tests/purs/warning/4256.out
@@ -0,0 +1,34 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/4256.purs:16:1 - 16:58 (line 16, column 1 - line 16, column 58)
+
+ No type declaration was provided for the top-level declaration of [33mbaz[0m.
+ It is good practice to provide type declarations as a form of documentation.
+ The inferred type of [33mbaz[0m was:
+ [33m [0m
+ [33m forall c14 d15 b25 d27. d27 -> c14 -> b25 -> d15 -> d27[0m
+ [33m [0m
+
+ in value declaration [33mbaz[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/MissingTypeDeclaration.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/4256.purs:8:1 - 8:37 (line 8, column 1 - line 8, column 37)
+
+ No type declaration was provided for the top-level declaration of [33maddNumberSuffix'[0m.
+ It is good practice to provide type declarations as a form of documentation.
+ The inferred type of [33maddNumberSuffix'[0m was:
+ [33m [0m
+ [33m forall b34 c35 d36. b34 -> c35 -> d36 -> Int[0m
+ [33m [0m
+
+ in value declaration [33maddNumberSuffix'[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/MissingTypeDeclaration.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/4256.purs b/tests/purs/warning/4256.purs
new file mode 100644
index 0000000000..6e0da49d05
--- /dev/null
+++ b/tests/purs/warning/4256.purs
@@ -0,0 +1,16 @@
+-- @shouldWarnWith MissingTypeDeclaration
+-- @shouldWarnWith MissingTypeDeclaration
+module Main where
+
+addNumberSuffix :: forall a b c d. a -> b -> c -> d -> a
+addNumberSuffix a _ _ _ = a
+
+addNumberSuffix' = addNumberSuffix 0
+
+foo :: forall a b c d. a -> b -> c -> d -> a
+foo a _ _ _ = a
+
+bar :: forall a b c d. a -> b -> c -> d -> a
+bar a _ _ _ = a
+
+baz a x y = bar (foo a 2 3 4) (foo a 2 3 4) (foo x y a a)
diff --git a/tests/purs/warning/4268.out b/tests/purs/warning/4268.out
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/purs/warning/4268.purs b/tests/purs/warning/4268.purs
new file mode 100644
index 0000000000..1f91ae507b
--- /dev/null
+++ b/tests/purs/warning/4268.purs
@@ -0,0 +1,4 @@
+module Main where
+
+f :: Partial => Int -> Int
+f 0 = f 1
diff --git a/tests/purs/warning/4308.out b/tests/purs/warning/4308.out
new file mode 100644
index 0000000000..37057ac6fe
--- /dev/null
+++ b/tests/purs/warning/4308.out
@@ -0,0 +1,49 @@
+Warning 1 of 3:
+
+ in module [33mMain[0m
+ at tests/purs/warning/4308.purs:13:6 - 13:7 (line 13, column 6 - line 13, column 7)
+
+ Wildcard type definition has the inferred type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+ in value declaration [33mg[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/WildcardInferredType.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 3:
+
+ in module [33mMain[0m
+ at tests/purs/warning/4308.purs:14:13 - 14:14 (line 14, column 13 - line 14, column 14)
+
+ Wildcard type definition has the inferred type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+ in value declaration [33mg[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/WildcardInferredType.md for more information,
+ or to contribute content related to this warning.
+
+Warning 3 of 3:
+
+ in module [33mMain[0m
+ at tests/purs/warning/4308.purs:14:25 - 14:26 (line 14, column 25 - line 14, column 26)
+
+ Wildcard type definition has the inferred type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ in the following context:
+
+ y :: [33mInt[0m
+
+
+ in value declaration [33mg[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/WildcardInferredType.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/4308.purs b/tests/purs/warning/4308.purs
new file mode 100644
index 0000000000..4013fa6bc5
--- /dev/null
+++ b/tests/purs/warning/4308.purs
@@ -0,0 +1,14 @@
+-- @shouldWarnWith WildcardInferredType
+-- @shouldWarnWith WildcardInferredType
+-- @shouldWarnWith WildcardInferredType
+module Main where
+
+-- No warnings expected here because `f` has full type signature
+f :: Int
+f = (\(y :: _) -> (y :: _)) 42
+
+-- All three warnings expected here because the type signature of `g` has a
+-- wildcard in it. One warning for the top-level signature wildcard, one for the
+-- wildcard in the lambda parameter pattern, and one in the lambda body.
+g :: _
+g = (\(y :: _) -> (y :: _)) 42
diff --git a/tests/purs/warning/4376.out b/tests/purs/warning/4376.out
new file mode 100644
index 0000000000..31006de8a6
--- /dev/null
+++ b/tests/purs/warning/4376.out
@@ -0,0 +1,16 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/4376.purs:6:1 - 6:16 (line 6, column 1 - line 6, column 16)
+
+ No type declaration was provided for the top-level declaration of [33mvalue[0m.
+ It is good practice to provide type declarations as a form of documentation.
+ The inferred type of [33mvalue[0m was:
+ [33m [0m
+ [33m forall @a. Maybe a[0m
+ [33m [0m
+
+in value declaration [33mvalue[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingTypeDeclaration.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/4376.purs b/tests/purs/warning/4376.purs
new file mode 100644
index 0000000000..0a6d4d535a
--- /dev/null
+++ b/tests/purs/warning/4376.purs
@@ -0,0 +1,6 @@
+-- @shouldWarnWith MissingTypeDeclaration
+module Main where
+
+data Maybe a = Just a | Nothing
+
+value = Nothing
diff --git a/tests/purs/warning/4414.out b/tests/purs/warning/4414.out
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/purs/warning/4414.purs b/tests/purs/warning/4414.purs
new file mode 100644
index 0000000000..7d9ecb2d05
--- /dev/null
+++ b/tests/purs/warning/4414.purs
@@ -0,0 +1,21 @@
+module Main
+ ( something
+ , main
+ )
+ where
+
+import Prelude
+
+import Effect (Effect)
+import Effect.Console (log)
+
+something :: Boolean
+something = 42 .?.?. 1
+
+foo :: forall a. a -> a -> Boolean
+foo _ _ = true
+
+infix 7 foo as .?.?.
+
+main :: Effect Unit
+main = log "Done"
diff --git a/tests/purs/warning/CoercibleUnusedImport.out b/tests/purs/warning/CoercibleUnusedImport.out
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/purs/warning/CoercibleUnusedImport.purs b/tests/purs/warning/CoercibleUnusedImport.purs
new file mode 100644
index 0000000000..b9f5538899
--- /dev/null
+++ b/tests/purs/warning/CoercibleUnusedImport.purs
@@ -0,0 +1,8 @@
+module Main where
+
+import N1
+import N2 (N2(..))
+import Safe.Coerce (coerce)
+
+unwrap :: forall a. N2 a -> a
+unwrap = coerce
diff --git a/tests/purs/warning/CoercibleUnusedImport/N1.purs b/tests/purs/warning/CoercibleUnusedImport/N1.purs
new file mode 100644
index 0000000000..dd69fed69e
--- /dev/null
+++ b/tests/purs/warning/CoercibleUnusedImport/N1.purs
@@ -0,0 +1,3 @@
+module N1 where
+
+newtype N1 a = N1 a
diff --git a/tests/purs/warning/CoercibleUnusedImport/N2.purs b/tests/purs/warning/CoercibleUnusedImport/N2.purs
new file mode 100644
index 0000000000..eb1255ff46
--- /dev/null
+++ b/tests/purs/warning/CoercibleUnusedImport/N2.purs
@@ -0,0 +1,5 @@
+module N2 where
+
+import N1
+
+newtype N2 a = N2 (N1 a)
diff --git a/tests/purs/warning/CoercibleUnusedNewtypeCtorExplicitImport.out b/tests/purs/warning/CoercibleUnusedNewtypeCtorExplicitImport.out
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/purs/warning/CoercibleUnusedNewtypeCtorExplicitImport.purs b/tests/purs/warning/CoercibleUnusedNewtypeCtorExplicitImport.purs
new file mode 100644
index 0000000000..ff04785899
--- /dev/null
+++ b/tests/purs/warning/CoercibleUnusedNewtypeCtorExplicitImport.purs
@@ -0,0 +1,7 @@
+module Main where
+
+import N (N(N))
+import Safe.Coerce (coerce)
+
+unwrap :: forall a. N a -> a
+unwrap = coerce
diff --git a/tests/purs/warning/CoercibleUnusedNewtypeCtorExplicitImport/N.purs b/tests/purs/warning/CoercibleUnusedNewtypeCtorExplicitImport/N.purs
new file mode 100644
index 0000000000..20ce211901
--- /dev/null
+++ b/tests/purs/warning/CoercibleUnusedNewtypeCtorExplicitImport/N.purs
@@ -0,0 +1,3 @@
+module N where
+
+newtype N a = N a
diff --git a/tests/purs/warning/CoercibleUnusedNewtypeCtorImplicitImport.out b/tests/purs/warning/CoercibleUnusedNewtypeCtorImplicitImport.out
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/purs/warning/CoercibleUnusedNewtypeCtorImplicitImport.purs b/tests/purs/warning/CoercibleUnusedNewtypeCtorImplicitImport.purs
new file mode 100644
index 0000000000..a20c70387d
--- /dev/null
+++ b/tests/purs/warning/CoercibleUnusedNewtypeCtorImplicitImport.purs
@@ -0,0 +1,7 @@
+module Main where
+
+import N (N(..))
+import Safe.Coerce (coerce)
+
+unwrap :: forall a. N a -> a
+unwrap = coerce
diff --git a/tests/purs/warning/CoercibleUnusedNewtypeCtorImplicitImport/N.purs b/tests/purs/warning/CoercibleUnusedNewtypeCtorImplicitImport/N.purs
new file mode 100644
index 0000000000..20ce211901
--- /dev/null
+++ b/tests/purs/warning/CoercibleUnusedNewtypeCtorImplicitImport/N.purs
@@ -0,0 +1,3 @@
+module N where
+
+newtype N a = N a
diff --git a/tests/purs/warning/CustomWarning.out b/tests/purs/warning/CustomWarning.out
new file mode 100644
index 0000000000..abb5b70854
--- /dev/null
+++ b/tests/purs/warning/CustomWarning.out
@@ -0,0 +1,14 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/CustomWarning.purs:9:1 - 9:11 (line 9, column 1 - line 9, column 11)
+
+ A custom warning occurred while solving type class constraints:
+
+ Custom warning Int
+
+
+in value declaration [33mbar[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/UserDefinedWarning.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/CustomWarning2.out b/tests/purs/warning/CustomWarning2.out
new file mode 100644
index 0000000000..e0031502c1
--- /dev/null
+++ b/tests/purs/warning/CustomWarning2.out
@@ -0,0 +1,14 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/CustomWarning2.purs:12:1 - 12:11 (line 12, column 1 - line 12, column 11)
+
+ A custom warning occurred while solving type class constraints:
+
+ foo
+
+
+in value declaration [33mbaz[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/UserDefinedWarning.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/CustomWarning3.out b/tests/purs/warning/CustomWarning3.out
new file mode 100644
index 0000000000..79c49af880
--- /dev/null
+++ b/tests/purs/warning/CustomWarning3.out
@@ -0,0 +1,30 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/CustomWarning3.purs:14:1 - 14:11 (line 14, column 1 - line 14, column 11)
+
+ A custom warning occurred while solving type class constraints:
+
+ foo
+
+
+ in value declaration [33mbaz[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UserDefinedWarning.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/CustomWarning3.purs:14:1 - 14:11 (line 14, column 1 - line 14, column 11)
+
+ A custom warning occurred while solving type class constraints:
+
+ bar
+
+
+ in value declaration [33mbaz[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UserDefinedWarning.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/CustomWarning4.out b/tests/purs/warning/CustomWarning4.out
new file mode 100644
index 0000000000..1ecaa3f548
--- /dev/null
+++ b/tests/purs/warning/CustomWarning4.out
@@ -0,0 +1,60 @@
+Warning 1 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/CustomWarning4.purs:21:1 - 21:15 (line 21, column 1 - line 21, column 15)
+
+ A custom warning occurred while solving type class constraints:
+
+ Custom label hello
+
+
+ in value declaration [33mbaz'[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UserDefinedWarning.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/CustomWarning4.purs:24:1 - 24:16 (line 24, column 1 - line 24, column 16)
+
+ A custom warning occurred while solving type class constraints:
+
+ Custom label hello
+
+
+ in value declaration [33mbaz''[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UserDefinedWarning.md for more information,
+ or to contribute content related to this warning.
+
+Warning 3 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/CustomWarning4.purs:27:1 - 27:17 (line 27, column 1 - line 27, column 17)
+
+ A custom warning occurred while solving type class constraints:
+
+ Custom label "h e l l o"
+
+
+ in value declaration [33mbaz'''[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UserDefinedWarning.md for more information,
+ or to contribute content related to this warning.
+
+Warning 4 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/CustomWarning4.purs:30:1 - 30:18 (line 30, column 1 - line 30, column 18)
+
+ A custom warning occurred while solving type class constraints:
+
+ Custom label "hel\"lo"
+
+
+ in value declaration [33mbaz''''[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UserDefinedWarning.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/CustomWarning4.purs b/tests/purs/warning/CustomWarning4.purs
index 5ab9de6c40..c3511ca2ac 100644
--- a/tests/purs/warning/CustomWarning4.purs
+++ b/tests/purs/warning/CustomWarning4.purs
@@ -6,7 +6,7 @@ module Main where
import Prim.TypeError (class Warn, Beside, QuoteLabel, Text)
import Prim
-import Type.Row (class RowToList, Cons, Nil)
+import Type.RowList (class RowToList, Cons, Nil)
data Label (l :: Symbol) = Label
diff --git a/tests/purs/warning/DeprecatedCaseOfOffsideSyntax1.out b/tests/purs/warning/DeprecatedCaseOfOffsideSyntax1.out
new file mode 100644
index 0000000000..1840a74fa5
--- /dev/null
+++ b/tests/purs/warning/DeprecatedCaseOfOffsideSyntax1.out
@@ -0,0 +1,9 @@
+Warning found:
+at tests/purs/warning/DeprecatedCaseOfOffsideSyntax1.purs:9:3 - 9:4 (line 9, column 3 - line 9, column 4)
+
+ Dedented expressions in case branches are deprecated and will be removed in a future release. Indent the branch's expression past it's binder instead.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/WarningParsingModule.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/DeprecatedCaseOfOffsideSyntax1.purs b/tests/purs/warning/DeprecatedCaseOfOffsideSyntax1.purs
new file mode 100644
index 0000000000..5c4d59604d
--- /dev/null
+++ b/tests/purs/warning/DeprecatedCaseOfOffsideSyntax1.purs
@@ -0,0 +1,9 @@
+-- @shouldWarnWith WarningParsingModule
+module DeprecatedCaseOfOffsideSyntax1 where
+
+data Foo = Foo Int
+
+test :: Foo -> Int
+test = case _ of
+ Foo i ->
+ i
diff --git a/tests/purs/warning/DeprecatedCaseOfOffsideSyntax2.out b/tests/purs/warning/DeprecatedCaseOfOffsideSyntax2.out
new file mode 100644
index 0000000000..b33a0b63a4
--- /dev/null
+++ b/tests/purs/warning/DeprecatedCaseOfOffsideSyntax2.out
@@ -0,0 +1,9 @@
+Warning found:
+at tests/purs/warning/DeprecatedCaseOfOffsideSyntax2.purs:8:3 - 8:4 (line 8, column 3 - line 8, column 4)
+
+ Dedented expressions in case branches are deprecated and will be removed in a future release. Indent the branch's expression past it's binder instead.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/WarningParsingModule.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/DeprecatedCaseOfOffsideSyntax2.purs b/tests/purs/warning/DeprecatedCaseOfOffsideSyntax2.purs
new file mode 100644
index 0000000000..bd994f4eb6
--- /dev/null
+++ b/tests/purs/warning/DeprecatedCaseOfOffsideSyntax2.purs
@@ -0,0 +1,8 @@
+-- @shouldWarnWith WarningParsingModule
+module DeprecatedCaseOfOffsideSyntax2 where
+
+data Foo = Foo Int
+
+test :: Foo -> Int
+test = case _ of Foo i ->
+ i
diff --git a/tests/purs/warning/DuplicateExportRef.out b/tests/purs/warning/DuplicateExportRef.out
new file mode 100644
index 0000000000..385bf8cfb2
--- /dev/null
+++ b/tests/purs/warning/DuplicateExportRef.out
@@ -0,0 +1,77 @@
+Warning 1 of 7:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateExportRef.purs:8:1 - 30:28 (line 8, column 1 - line 30, column 28)
+
+ Export list contains multiple references to type class [33mY[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateExportRef.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 7:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateExportRef.purs:8:1 - 30:28 (line 8, column 1 - line 30, column 28)
+
+ Export list contains multiple references to type operator [33m(~>)[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateExportRef.md for more information,
+ or to contribute content related to this warning.
+
+Warning 3 of 7:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateExportRef.purs:8:1 - 30:28 (line 8, column 1 - line 30, column 28)
+
+ Export list contains multiple references to type [33mX[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateExportRef.md for more information,
+ or to contribute content related to this warning.
+
+Warning 4 of 7:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateExportRef.purs:8:1 - 30:28 (line 8, column 1 - line 30, column 28)
+
+ Export list contains multiple references to value [33mfn[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateExportRef.md for more information,
+ or to contribute content related to this warning.
+
+Warning 5 of 7:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateExportRef.purs:8:1 - 30:28 (line 8, column 1 - line 30, column 28)
+
+ Export list contains multiple references to operator [33m(!)[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateExportRef.md for more information,
+ or to contribute content related to this warning.
+
+Warning 6 of 7:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateExportRef.purs:8:1 - 30:28 (line 8, column 1 - line 30, column 28)
+
+ Export list contains multiple references to module [33mPrelude[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateExportRef.md for more information,
+ or to contribute content related to this warning.
+
+Warning 7 of 7:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateExportRef.purs:8:1 - 30:28 (line 8, column 1 - line 30, column 28)
+
+ Export list contains multiple references to data constructor [33mX[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateExportRef.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/DuplicateExportRef.purs b/tests/purs/warning/DuplicateExportRef.purs
index aa70f7a732..27c075a07a 100644
--- a/tests/purs/warning/DuplicateExportRef.purs
+++ b/tests/purs/warning/DuplicateExportRef.purs
@@ -23,8 +23,8 @@ fn _ _ = X
infix 2 fn as !
-class Y a
+class Y (a :: Type)
-type Natural f g = forall a. f a -> g a
+type Natural f g = forall (a :: Type). f a -> g a
infixl 1 type Natural as ~>
diff --git a/tests/purs/warning/DuplicateImport.out b/tests/purs/warning/DuplicateImport.out
new file mode 100644
index 0000000000..916acf1d2b
--- /dev/null
+++ b/tests/purs/warning/DuplicateImport.out
@@ -0,0 +1,10 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/DuplicateImport.purs:5:1 - 5:34 (line 5, column 1 - line 5, column 34)
+
+ Duplicate import of [33mPrelude (Unit, unit, pure)[0m
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DuplicateImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/DuplicateImportRef.out b/tests/purs/warning/DuplicateImportRef.out
new file mode 100644
index 0000000000..c1ce0ba695
--- /dev/null
+++ b/tests/purs/warning/DuplicateImportRef.out
@@ -0,0 +1,44 @@
+Warning 1 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateImportRef.purs:7:1 - 12:4 (line 7, column 1 - line 12, column 4)
+
+ Import list contains multiple references to type class [33mFunctor[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateImportRef.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateImportRef.purs:7:1 - 12:4 (line 7, column 1 - line 12, column 4)
+
+ Import list contains multiple references to type [33mUnit[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateImportRef.md for more information,
+ or to contribute content related to this warning.
+
+Warning 3 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateImportRef.purs:7:1 - 12:4 (line 7, column 1 - line 12, column 4)
+
+ Import list contains multiple references to value [33munit[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateImportRef.md for more information,
+ or to contribute content related to this warning.
+
+Warning 4 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/DuplicateImportRef.purs:7:1 - 12:4 (line 7, column 1 - line 12, column 4)
+
+ Import list contains multiple references to operator [33m(<>)[0m
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/DuplicateImportRef.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/DuplicateSelectiveImport.out b/tests/purs/warning/DuplicateSelectiveImport.out
new file mode 100644
index 0000000000..3e0aef6609
--- /dev/null
+++ b/tests/purs/warning/DuplicateSelectiveImport.out
@@ -0,0 +1,10 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/DuplicateSelectiveImport.purs:5:1 - 5:22 (line 5, column 1 - line 5, column 22)
+
+ There is an existing import of [33mPrelude[0m, consider merging the import lists
+
+
+See https://github.com/purescript/documentation/blob/master/errors/DuplicateSelectiveImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/HiddenConstructorsGeneric.out b/tests/purs/warning/HiddenConstructorsGeneric.out
new file mode 100644
index 0000000000..eb4270c574
--- /dev/null
+++ b/tests/purs/warning/HiddenConstructorsGeneric.out
@@ -0,0 +1,11 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/HiddenConstructorsGeneric.purs:2:1 - 8:40 (line 2, column 1 - line 8, column 40)
+
+ An export for [33mD[0m hides data constructors but the type declares an instance of [33mData.Generic.Rep.Generic[0m.
+ Such instance allows to match and construct values of this type, effectively making the constructors public.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/HiddenConstructors.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/HiddenConstructorsGeneric.purs b/tests/purs/warning/HiddenConstructorsGeneric.purs
new file mode 100644
index 0000000000..3949f6b390
--- /dev/null
+++ b/tests/purs/warning/HiddenConstructorsGeneric.purs
@@ -0,0 +1,8 @@
+-- @shouldWarnWith HiddenConstructors
+module Main (D) where
+
+import Data.Generic.Rep (class Generic)
+
+data D = D
+
+derive instance genericD :: Generic D _
diff --git a/tests/purs/warning/HiddenConstructorsNewtype.out b/tests/purs/warning/HiddenConstructorsNewtype.out
new file mode 100644
index 0000000000..8e4c630caa
--- /dev/null
+++ b/tests/purs/warning/HiddenConstructorsNewtype.out
@@ -0,0 +1,11 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/HiddenConstructorsNewtype.purs:2:1 - 8:44 (line 2, column 1 - line 8, column 44)
+
+ An export for [33mN[0m hides data constructors but the type declares an instance of [33mData.Newtype.Newtype[0m.
+ Such instance allows to match and construct values of this type, effectively making the constructors public.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/HiddenConstructors.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/HiddenConstructorsNewtype.purs b/tests/purs/warning/HiddenConstructorsNewtype.purs
new file mode 100644
index 0000000000..3d2620656a
--- /dev/null
+++ b/tests/purs/warning/HiddenConstructorsNewtype.purs
@@ -0,0 +1,8 @@
+-- @shouldWarnWith HiddenConstructors
+module Main (N) where
+
+import Data.Newtype (class Newtype)
+
+newtype N a = N a
+
+derive instance newtypeN :: Newtype (N a) _
diff --git a/tests/purs/warning/HidingImport.out b/tests/purs/warning/HidingImport.out
new file mode 100644
index 0000000000..68171c403b
--- /dev/null
+++ b/tests/purs/warning/HidingImport.out
@@ -0,0 +1,28 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/HidingImport.purs:6:1 - 6:30 (line 6, column 1 - line 6, column 30)
+
+ Module [33mEffect[0m has unspecified imports, consider using the inclusive form:
+
+ [33mimport Effect (Effect)[0m
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/HidingImport.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/HidingImport.purs:5:1 - 5:28 (line 5, column 1 - line 5, column 28)
+
+ Module [33mPrelude[0m has unspecified imports, consider using the inclusive form:
+
+ [33mimport Prelude (Unit, pure, unit)[0m
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/HidingImport.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/ImplicitImport.out b/tests/purs/warning/ImplicitImport.out
new file mode 100644
index 0000000000..e61062fba6
--- /dev/null
+++ b/tests/purs/warning/ImplicitImport.out
@@ -0,0 +1,28 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/ImplicitImport.purs:6:1 - 6:14 (line 6, column 1 - line 6, column 14)
+
+ Module [33mEffect[0m has unspecified imports, consider using the explicit form:
+
+ [33mimport Effect (Effect)[0m
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/ImplicitImport.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/ImplicitImport.purs:5:1 - 5:15 (line 5, column 1 - line 5, column 15)
+
+ Module [33mPrelude[0m has unspecified imports, consider using the explicit form:
+
+ [33mimport Prelude (Unit, pure, unit)[0m
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/ImplicitImport.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/ImplicitQualifiedImport.out b/tests/purs/warning/ImplicitQualifiedImport.out
new file mode 100644
index 0000000000..5e8002671e
--- /dev/null
+++ b/tests/purs/warning/ImplicitQualifiedImport.out
@@ -0,0 +1,30 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/ImplicitQualifiedImport.purs:7:1 - 7:19 (line 7, column 1 - line 7, column 19)
+
+ Module [33mEffect[0m was imported as [33mE[0m with unspecified imports.
+ As there are multiple modules being imported as [33mE[0m, consider using the explicit form:
+
+ [33mimport Effect (Effect) as E[0m
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/ImplicitQualifiedImport.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/ImplicitQualifiedImport.purs:8:1 - 8:27 (line 8, column 1 - line 8, column 27)
+
+ Module [33mEffect.Console[0m was imported as [33mE[0m with unspecified imports.
+ As there are multiple modules being imported as [33mE[0m, consider using the explicit form:
+
+ [33mimport Effect.Console (log) as E[0m
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/ImplicitQualifiedImport.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/ImplicitQualifiedImportReExport.out b/tests/purs/warning/ImplicitQualifiedImportReExport.out
new file mode 100644
index 0000000000..cbf9bd416d
--- /dev/null
+++ b/tests/purs/warning/ImplicitQualifiedImportReExport.out
@@ -0,0 +1,30 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/ImplicitQualifiedImportReExport.purs:9:1 - 9:23 (line 9, column 1 - line 9, column 23)
+
+ Module [33mData.Maybe[0m was imported as [33mX[0m with unspecified imports.
+ As this module is being re-exported, consider using the explicit form:
+
+ [33mimport Data.Maybe (Maybe(..), fromJust, fromMaybe, fromMaybe', isJust, isNothing, maybe, maybe', optional) as X[0m
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/ImplicitQualifiedImportReExport.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/ImplicitQualifiedImportReExport.purs:10:1 - 10:24 (line 10, column 1 - line 10, column 24)
+
+ Module [33mData.Either[0m was imported as [33mY[0m with unspecified imports.
+ As this module is being re-exported, consider using the explicit form:
+
+ [33mimport Data.Either (Either(..), blush, choose, either, fromLeft, fromLeft', fromRight, fromRight', hush, isLeft, isRight, note, note') as Y[0m
+
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/ImplicitQualifiedImportReExport.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/Kind-UnusedExplicitImport-1.out b/tests/purs/warning/Kind-UnusedExplicitImport-1.out
new file mode 100644
index 0000000000..8560ddba83
--- /dev/null
+++ b/tests/purs/warning/Kind-UnusedExplicitImport-1.out
@@ -0,0 +1,17 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/Kind-UnusedExplicitImport-1.purs:6:1 - 6:47 (line 6, column 1 - line 6, column 47)
+
+ The import of module [33mType.RowList[0m contains the following unused references:
+
+ [33mListToRow[0m
+
+ It could be replaced with:
+
+ [33mimport Type.RowList (RowList)[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedExplicitImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/Kind-UnusedExplicitImport-1.purs b/tests/purs/warning/Kind-UnusedExplicitImport-1.purs
new file mode 100644
index 0000000000..7c7a8b335b
--- /dev/null
+++ b/tests/purs/warning/Kind-UnusedExplicitImport-1.purs
@@ -0,0 +1,11 @@
+-- @shouldWarnWith UnusedExplicitImport
+module Main where
+
+import Prelude (Unit, unit, pure)
+import Effect (Effect)
+import Type.RowList (class ListToRow, RowList)
+
+class A (a :: RowList Type)
+
+main :: Effect Unit
+main = pure unit
diff --git a/tests/purs/warning/Kind-UnusedExplicitImport-2.out b/tests/purs/warning/Kind-UnusedExplicitImport-2.out
new file mode 100644
index 0000000000..1ba9def753
--- /dev/null
+++ b/tests/purs/warning/Kind-UnusedExplicitImport-2.out
@@ -0,0 +1,17 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/Kind-UnusedExplicitImport-2.purs:6:1 - 6:47 (line 6, column 1 - line 6, column 47)
+
+ The import of module [33mType.RowList[0m contains the following unused references:
+
+ [33mRowList[0m
+
+ It could be replaced with:
+
+ [33mimport Type.RowList (class ListToRow)[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedExplicitImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/Kind-UnusedExplicitImport-2.purs b/tests/purs/warning/Kind-UnusedExplicitImport-2.purs
new file mode 100644
index 0000000000..2bbaccefe0
--- /dev/null
+++ b/tests/purs/warning/Kind-UnusedExplicitImport-2.purs
@@ -0,0 +1,13 @@
+-- @shouldWarnWith UnusedExplicitImport
+module Main where
+
+import Prelude (Unit, unit, pure)
+import Effect (Effect)
+import Type.RowList (class ListToRow, RowList)
+import Type.Proxy (Proxy)
+
+f :: forall l r. ListToRow l r => Proxy l -> Int
+f _ = 0
+
+main :: Effect Unit
+main = pure unit
diff --git a/tests/purs/warning/Kind-UnusedImport.out b/tests/purs/warning/Kind-UnusedImport.out
new file mode 100644
index 0000000000..df1908494c
--- /dev/null
+++ b/tests/purs/warning/Kind-UnusedImport.out
@@ -0,0 +1,10 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/Kind-UnusedImport.purs:6:1 - 6:30 (line 6, column 1 - line 6, column 30)
+
+ The import of [33mType.RowList[0m is redundant
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/Kind-UnusedImport.purs b/tests/purs/warning/Kind-UnusedImport.purs
new file mode 100644
index 0000000000..35881a0884
--- /dev/null
+++ b/tests/purs/warning/Kind-UnusedImport.purs
@@ -0,0 +1,9 @@
+-- @shouldWarnWith UnusedImport
+module Main where
+
+import Prelude (Unit, unit, pure)
+import Effect (Effect)
+import Type.RowList (RowList)
+
+main :: Effect Unit
+main = pure unit
diff --git a/tests/purs/warning/KindReExport.out b/tests/purs/warning/KindReExport.out
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/purs/warning/KindReExport.purs b/tests/purs/warning/KindReExport.purs
new file mode 100644
index 0000000000..88c8255ea0
--- /dev/null
+++ b/tests/purs/warning/KindReExport.purs
@@ -0,0 +1,11 @@
+-- | This test is to ensure that we do not get an incorrect 'unused kind'
+-- | warning. See #3744
+module Main (main, module X) where
+
+import Prelude
+import Effect (Effect)
+import Effect.Console (log)
+import Prim.Ordering (Ordering) as X
+
+main :: Effect Unit
+main = log "Done"
diff --git a/tests/purs/warning/MissingKindDeclaration.out b/tests/purs/warning/MissingKindDeclaration.out
new file mode 100644
index 0000000000..5174fcff24
--- /dev/null
+++ b/tests/purs/warning/MissingKindDeclaration.out
@@ -0,0 +1,64 @@
+Warning 1 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/MissingKindDeclaration.purs:7:1 - 7:21 (line 7, column 1 - line 7, column 21)
+
+ The inferred kind for the data declaration [33mProxy[0m contains polymorphic kinds.
+ Consider adding a top-level kind signature as a form of documentation.
+ [33m [0m
+ [33m data Proxy :: forall k. k -> Type[0m
+ [33m [0m
+
+ in type constructor [33mProxy[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/MissingKindDeclaration.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/MissingKindDeclaration.purs:11:1 - 11:40 (line 11, column 1 - line 11, column 40)
+
+ The inferred kind for the type declaration [33mNatural[0m contains polymorphic kinds.
+ Consider adding a top-level kind signature as a form of documentation.
+ [33m [0m
+ [33m type Natural :: forall k. (k -> Type) -> (k -> Type) -> Type[0m
+ [33m [0m
+
+ in type synonym [33mNatural[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/MissingKindDeclaration.md for more information,
+ or to contribute content related to this warning.
+
+Warning 3 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/MissingKindDeclaration.purs:9:1 - 9:20 (line 9, column 1 - line 9, column 20)
+
+ The inferred kind for the newtype declaration [33mF[0m contains polymorphic kinds.
+ Consider adding a top-level kind signature as a form of documentation.
+ [33m [0m
+ [33m newtype F :: forall k. k -> Type -> Type[0m
+ [33m [0m
+
+ in type constructor [33mF[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/MissingKindDeclaration.md for more information,
+ or to contribute content related to this warning.
+
+Warning 4 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/MissingKindDeclaration.purs:13:1 - 13:18 (line 13, column 1 - line 13, column 18)
+
+ The inferred kind for the class declaration [33mClazz[0m contains polymorphic kinds.
+ Consider adding a top-level kind signature as a form of documentation.
+ [33m [0m
+ [33m class Clazz :: forall k1 k2 k3. k1 -> k2 -> k3 -> Constraint[0m
+ [33m [0m
+
+ in type class declaration for [33mClazz[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/MissingKindDeclaration.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/MissingKindDeclaration.purs b/tests/purs/warning/MissingKindDeclaration.purs
new file mode 100644
index 0000000000..843b28f870
--- /dev/null
+++ b/tests/purs/warning/MissingKindDeclaration.purs
@@ -0,0 +1,13 @@
+-- @shouldWarnWith MissingKindDeclaration
+-- @shouldWarnWith MissingKindDeclaration
+-- @shouldWarnWith MissingKindDeclaration
+-- @shouldWarnWith MissingKindDeclaration
+module Main where
+
+data Proxy a = Proxy
+
+newtype F a b = F b
+
+type Natural f g = forall a. f a -> g a
+
+class Clazz a b c
diff --git a/tests/purs/warning/MissingTypeDeclaration.out b/tests/purs/warning/MissingTypeDeclaration.out
new file mode 100644
index 0000000000..add92fa0c7
--- /dev/null
+++ b/tests/purs/warning/MissingTypeDeclaration.out
@@ -0,0 +1,16 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/MissingTypeDeclaration.purs:4:1 - 4:6 (line 4, column 1 - line 4, column 6)
+
+ No type declaration was provided for the top-level declaration of [33mx[0m.
+ It is good practice to provide type declarations as a form of documentation.
+ The inferred type of [33mx[0m was:
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+in value declaration [33mx[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingTypeDeclaration.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/NewtypeInstance.out b/tests/purs/warning/NewtypeInstance.out
new file mode 100644
index 0000000000..b6dd688801
--- /dev/null
+++ b/tests/purs/warning/NewtypeInstance.out
@@ -0,0 +1,15 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/NewtypeInstance.purs:8:1 - 8:38 (line 8, column 1 - line 8, column 38)
+
+ The derived newtype instance for
+ [33m [0m
+ [33m Data.Ord.Ord X[0m
+ [33m [0m
+ does not include a derived superclass instance for [33mData.Eq.Eq[0m.
+
+in value declaration [33mordX[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingNewtypeSuperclassInstance.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/NewtypeInstance2.out b/tests/purs/warning/NewtypeInstance2.out
new file mode 100644
index 0000000000..e9afcb3d74
--- /dev/null
+++ b/tests/purs/warning/NewtypeInstance2.out
@@ -0,0 +1,19 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/NewtypeInstance2.purs:15:1 - 15:86 (line 15, column 1 - line 15, column 86)
+
+ The derived newtype instance for
+ [33m [0m
+ [33m Main.MonadWriter w0 [0m
+ [33m (MyWriter w0)[0m
+ [33m [0m
+ does not include a derived superclass instance for [33mControl.Monad.Monad[0m.
+
+in value declaration [33mmonadWriterMyWriter[0m
+
+where [33mw0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingNewtypeSuperclassInstance.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/NewtypeInstance3.out b/tests/purs/warning/NewtypeInstance3.out
new file mode 100644
index 0000000000..bb3e96b4db
--- /dev/null
+++ b/tests/purs/warning/NewtypeInstance3.out
@@ -0,0 +1,19 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/NewtypeInstance3.purs:21:1 - 21:86 (line 21, column 1 - line 21, column 86)
+
+ The derived newtype instance for
+ [33m [0m
+ [33m Main.MonadWriter w0 [0m
+ [33m (MyWriter w0)[0m
+ [33m [0m
+ does not include a derived superclass instance for [33mMain.MonadTell[0m.
+
+in value declaration [33mmonadWriterMyWriter[0m
+
+where [33mw0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingNewtypeSuperclassInstance.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/NewtypeInstance4.out b/tests/purs/warning/NewtypeInstance4.out
new file mode 100644
index 0000000000..2d81d13624
--- /dev/null
+++ b/tests/purs/warning/NewtypeInstance4.out
@@ -0,0 +1,19 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/NewtypeInstance4.purs:23:1 - 23:86 (line 23, column 1 - line 23, column 86)
+
+ The derived newtype instance for
+ [33m [0m
+ [33m Main.MonadWriter w0 [0m
+ [33m (MyWriter w0)[0m
+ [33m [0m
+ implies an superclass instance for [33mMain.MonadTell[0m which could not be verified.
+
+in value declaration [33mmonadWriterMyWriter[0m
+
+where [33mw0[0m is a rigid type variable
+ bound at (line 0, column 0 - line 0, column 0)
+
+See https://github.com/purescript/documentation/blob/master/errors/UnverifiableSuperclassInstance.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/OverlappingPattern.out b/tests/purs/warning/OverlappingPattern.out
new file mode 100644
index 0000000000..b5fb9ecd72
--- /dev/null
+++ b/tests/purs/warning/OverlappingPattern.out
@@ -0,0 +1,28 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/OverlappingPattern.purs:12:1 - 12:21 (line 12, column 1 - line 12, column 21)
+
+ A case expression contains unreachable cases:
+
+ B
+
+ in value declaration [33mpat2[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/OverlappingPattern.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/OverlappingPattern.purs:7:1 - 7:21 (line 7, column 1 - line 7, column 21)
+
+ A case expression contains unreachable cases:
+
+ A
+
+ in value declaration [33mpat1[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/OverlappingPattern.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/ScopeShadowing.out b/tests/purs/warning/ScopeShadowing.out
new file mode 100644
index 0000000000..b3042062b2
--- /dev/null
+++ b/tests/purs/warning/ScopeShadowing.out
@@ -0,0 +1,14 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/ScopeShadowing.purs:4:1 - 4:15 (line 4, column 1 - line 4, column 15)
+
+ Shadowed definitions are in scope for type [33mUnit[0m from the following open imports:
+
+ [33mimport Prelude[0m
+
+ These will be ignored and the local declaration will be used.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeShadowing.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/ScopeShadowing.purs b/tests/purs/warning/ScopeShadowing.purs
index 380a4eef03..848eaf93c9 100644
--- a/tests/purs/warning/ScopeShadowing.purs
+++ b/tests/purs/warning/ScopeShadowing.purs
@@ -7,7 +7,7 @@ import Prelude
data Unit = Unit
-- This is only a warning as the `Prelude` import is implicit. If `Unit` was
--- named explicitly in an import list, then this refernce to `Unit`
+-- named explicitly in an import list, then this reference to `Unit`
-- would be a `ScopeConflict` error instead.
test :: Unit
test = const Unit unit
diff --git a/tests/purs/warning/ScopeShadowing2.out b/tests/purs/warning/ScopeShadowing2.out
new file mode 100644
index 0000000000..366d459216
--- /dev/null
+++ b/tests/purs/warning/ScopeShadowing2.out
@@ -0,0 +1,14 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/ScopeShadowing2.purs:7:1 - 7:22 (line 7, column 1 - line 7, column 22)
+
+ Shadowed definitions are in scope for value [33mappend[0m from the following open imports:
+
+ [33mimport Data.Semigroup[0m
+
+ These will be ignored and the local declaration will be used.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/ScopeShadowing.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/ShadowedBinderPatternGuard.out b/tests/purs/warning/ShadowedBinderPatternGuard.out
new file mode 100644
index 0000000000..b3918f5358
--- /dev/null
+++ b/tests/purs/warning/ShadowedBinderPatternGuard.out
@@ -0,0 +1,11 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/ShadowedBinderPatternGuard.purs:6:7 - 6:8 (line 6, column 7 - line 6, column 8)
+
+ Name [33mi[0m was shadowed.
+
+in value declaration [33mf[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ShadowedName.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/ShadowedBinderPatternGuard.purs b/tests/purs/warning/ShadowedBinderPatternGuard.purs
index fa91eaec1e..6c728e2b4f 100644
--- a/tests/purs/warning/ShadowedBinderPatternGuard.purs
+++ b/tests/purs/warning/ShadowedBinderPatternGuard.purs
@@ -2,6 +2,6 @@
module Main where
f :: Int -> Int
-f n | i <- true -- this i is shadowed
+f _ | i <- true -- this i is shadowed
, i <- 1234
= i
diff --git a/tests/purs/warning/ShadowedNameParens.out b/tests/purs/warning/ShadowedNameParens.out
new file mode 100644
index 0000000000..7a0e22f64c
--- /dev/null
+++ b/tests/purs/warning/ShadowedNameParens.out
@@ -0,0 +1,11 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/ShadowedNameParens.purs:7:5 - 7:6 (line 7, column 5 - line 7, column 6)
+
+ Name [33mn[0m was shadowed.
+
+in value declaration [33mf[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ShadowedName.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/ShadowedNameParens.purs b/tests/purs/warning/ShadowedNameParens.purs
index 9241f68840..2de23917f6 100644
--- a/tests/purs/warning/ShadowedNameParens.purs
+++ b/tests/purs/warning/ShadowedNameParens.purs
@@ -2,4 +2,6 @@
module Main where
f :: Int -> Int -> Int
-f n = \(n) -> 1
+f n =
+ let _ = n in
+ \(n) -> n
diff --git a/tests/purs/warning/ShadowedTypeVar.out b/tests/purs/warning/ShadowedTypeVar.out
new file mode 100644
index 0000000000..56236409c4
--- /dev/null
+++ b/tests/purs/warning/ShadowedTypeVar.out
@@ -0,0 +1,11 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/ShadowedTypeVar.purs:4:1 - 4:44 (line 4, column 1 - line 4, column 44)
+
+ Type variable [33ma[0m was shadowed.
+
+in type declaration for [33mf[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ShadowedTypeVar.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/TypeClassMethodSynonym.out b/tests/purs/warning/TypeClassMethodSynonym.out
new file mode 100644
index 0000000000..47bb4c0796
--- /dev/null
+++ b/tests/purs/warning/TypeClassMethodSynonym.out
@@ -0,0 +1,11 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/TypeClassMethodSynonym.purs:8:3 - 8:19 (line 8, column 3 - line 8, column 19)
+
+ Type variable [33ma[0m was shadowed.
+
+in type declaration for [33mc[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/ShadowedTypeVar.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/TypeClassMethodSynonym.purs b/tests/purs/warning/TypeClassMethodSynonym.purs
new file mode 100644
index 0000000000..d290524ecc
--- /dev/null
+++ b/tests/purs/warning/TypeClassMethodSynonym.purs
@@ -0,0 +1,8 @@
+-- @shouldWarnWith ShadowedTypeVar
+module Main where
+
+class C :: Type -> Constraint
+class C a where
+ -- The `a` in the type below should refer to the `a`
+ -- introduced by the `forall`, not the class head.
+ c :: forall a. a
diff --git a/tests/purs/warning/UnambiguousQuantifiedKind.out b/tests/purs/warning/UnambiguousQuantifiedKind.out
new file mode 100644
index 0000000000..d3b70ea42e
--- /dev/null
+++ b/tests/purs/warning/UnambiguousQuantifiedKind.out
@@ -0,0 +1,16 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/UnambiguousQuantifiedKind.purs:12:1 - 12:11 (line 12, column 1 - line 12, column 11)
+
+ No type declaration was provided for the top-level declaration of [33mtest2[0m.
+ It is good practice to provide type declarations as a form of documentation.
+ The inferred type of [33mtest2[0m was:
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+in value declaration [33mtest2[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/MissingTypeDeclaration.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnambiguousQuantifiedKind.purs b/tests/purs/warning/UnambiguousQuantifiedKind.purs
new file mode 100644
index 0000000000..864bed7d26
--- /dev/null
+++ b/tests/purs/warning/UnambiguousQuantifiedKind.purs
@@ -0,0 +1,12 @@
+-- @shouldWarnWith MissingTypeDeclaration
+module Main where
+
+data Proxy :: forall k. k -> Type
+data Proxy a = Proxy
+
+-- Should not trigger a warning
+test1 :: forall k (a :: k). Proxy a
+test1 = Proxy
+
+-- Should trigger a warning
+test2 = 42
diff --git a/tests/purs/warning/UnnecessaryFFIModule.js b/tests/purs/warning/UnnecessaryFFIModule.js
index 346c8e9012..bd1835d69d 100644
--- a/tests/purs/warning/UnnecessaryFFIModule.js
+++ b/tests/purs/warning/UnnecessaryFFIModule.js
@@ -1 +1 @@
-exports.out = null;
+export var out = null;
diff --git a/tests/purs/warning/UnnecessaryFFIModule.out b/tests/purs/warning/UnnecessaryFFIModule.out
new file mode 100644
index 0000000000..d6bb02e5e9
--- /dev/null
+++ b/tests/purs/warning/UnnecessaryFFIModule.out
@@ -0,0 +1,13 @@
+Warning found:
+at tests/purs/warning/UnnecessaryFFIModule.purs:2:1 - 5:9 (line 2, column 1 - line 5, column 9)
+
+ An unnecessary foreign module implementation was provided for module [33mMain[0m:
+
+ tests/purs/warning/UnnecessaryFFIModule.js
+
+ Module [33mMain[0m does not contain any foreign import declarations, so a foreign module is not necessary.
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnnecessaryFFIModule.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedDctorExplicitImport.out b/tests/purs/warning/UnusedDctorExplicitImport.out
new file mode 100644
index 0000000000..ada78634da
--- /dev/null
+++ b/tests/purs/warning/UnusedDctorExplicitImport.out
@@ -0,0 +1,17 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/UnusedDctorExplicitImport.purs:4:1 - 4:40 (line 4, column 1 - line 4, column 40)
+
+ The import of type [33mOrdering[0m from module [33mData.Ordering[0m includes the following unused data constructors:
+
+ [33mLT[0m
+
+ It could be replaced with:
+
+ [33mimport Data.Ordering (Ordering(EQ))[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedDctorExplicitImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedDctorImportAll.out b/tests/purs/warning/UnusedDctorImportAll.out
new file mode 100644
index 0000000000..b14586f2a9
--- /dev/null
+++ b/tests/purs/warning/UnusedDctorImportAll.out
@@ -0,0 +1,14 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/UnusedDctorImportAll.purs:4:1 - 4:36 (line 4, column 1 - line 4, column 36)
+
+ The import of type [33mOrdering[0m from module [33mData.Ordering[0m includes data constructors but only the type is used
+ It could be replaced with:
+
+ [33mimport Data.Ordering (Ordering)[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedDctorImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedDctorImportExplicit.out b/tests/purs/warning/UnusedDctorImportExplicit.out
new file mode 100644
index 0000000000..b03955cafa
--- /dev/null
+++ b/tests/purs/warning/UnusedDctorImportExplicit.out
@@ -0,0 +1,14 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/UnusedDctorImportExplicit.purs:4:1 - 4:36 (line 4, column 1 - line 4, column 36)
+
+ The import of type [33mOrdering[0m from module [33mData.Ordering[0m includes data constructors but only the type is used
+ It could be replaced with:
+
+ [33mimport Data.Ordering (Ordering)[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedDctorImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedExplicitImport.out b/tests/purs/warning/UnusedExplicitImport.out
new file mode 100644
index 0000000000..622704dad0
--- /dev/null
+++ b/tests/purs/warning/UnusedExplicitImport.out
@@ -0,0 +1,17 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/UnusedExplicitImport.purs:4:1 - 4:40 (line 4, column 1 - line 4, column 40)
+
+ The import of module [33mPrelude[0m contains the following unused references:
+
+ [33mbind[0m
+
+ It could be replaced with:
+
+ [33mimport Prelude (Unit, pure, unit)[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedExplicitImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedExplicitImportTypeOp.out b/tests/purs/warning/UnusedExplicitImportTypeOp.out
new file mode 100644
index 0000000000..25dea28ea9
--- /dev/null
+++ b/tests/purs/warning/UnusedExplicitImportTypeOp.out
@@ -0,0 +1,17 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/UnusedExplicitImportTypeOp.purs:6:1 - 6:30 (line 6, column 1 - line 6, column 30)
+
+ The import of module [33mLib[0m contains the following unused references:
+
+ [33m(~>)[0m
+
+ It could be replaced with:
+
+ [33mimport Lib (natId)[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedExplicitImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedExplicitImportTypeOp/Lib.purs b/tests/purs/warning/UnusedExplicitImportTypeOp/Lib.purs
index 7a2d5239d3..18393bd6a3 100644
--- a/tests/purs/warning/UnusedExplicitImportTypeOp/Lib.purs
+++ b/tests/purs/warning/UnusedExplicitImportTypeOp/Lib.purs
@@ -1,5 +1,6 @@
module Lib where
+type Nat ∷ ∀ k. (k → Type) → (k → Type) → Type
type Nat f g = ∀ x. f x → g x
infixr 4 type Nat as ~>
diff --git a/tests/purs/warning/UnusedExplicitImportValOp.out b/tests/purs/warning/UnusedExplicitImportValOp.out
new file mode 100644
index 0000000000..3291c06a39
--- /dev/null
+++ b/tests/purs/warning/UnusedExplicitImportValOp.out
@@ -0,0 +1,17 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/UnusedExplicitImportValOp.purs:4:1 - 4:39 (line 4, column 1 - line 4, column 39)
+
+ The import of module [33mPrelude[0m contains the following unused references:
+
+ [33m(+)[0m
+
+ It could be replaced with:
+
+ [33mimport Prelude (Unit, pure, unit)[0m
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedExplicitImport.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedFFIImplementations.js b/tests/purs/warning/UnusedFFIImplementations.js
index d50f2e60a8..78ab638547 100644
--- a/tests/purs/warning/UnusedFFIImplementations.js
+++ b/tests/purs/warning/UnusedFFIImplementations.js
@@ -1,2 +1,2 @@
-exports.yes = true;
-exports.no = false;
+export var yes = true;
+export var no = false;
diff --git a/tests/purs/warning/UnusedFFIImplementations.out b/tests/purs/warning/UnusedFFIImplementations.out
new file mode 100644
index 0000000000..10cfa2df62
--- /dev/null
+++ b/tests/purs/warning/UnusedFFIImplementations.out
@@ -0,0 +1,12 @@
+Warning found:
+at tests/purs/warning/UnusedFFIImplementations.purs:2:1 - 4:30 (line 2, column 1 - line 4, column 30)
+
+ The following definitions in the foreign module for module [33mMain[0m are unused:
+
+ no
+
+
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedFFIImplementations.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedImport.out b/tests/purs/warning/UnusedImport.out
new file mode 100644
index 0000000000..7bc07c0392
--- /dev/null
+++ b/tests/purs/warning/UnusedImport.out
@@ -0,0 +1,22 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedImport.purs:8:1 - 8:14 (line 8, column 1 - line 8, column 14)
+
+ The import of [33mEffect[0m is redundant
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedImport.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedImport.purs:9:1 - 9:33 (line 9, column 1 - line 9, column 33)
+
+ The qualified import of [33mEffect.Console[0m as [33mConsole[0m is redundant
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedImport.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedTypeVar.out b/tests/purs/warning/UnusedTypeVar.out
new file mode 100644
index 0000000000..8222b07cbd
--- /dev/null
+++ b/tests/purs/warning/UnusedTypeVar.out
@@ -0,0 +1,11 @@
+Warning found:
+in module [33mMain[0m
+at tests/purs/warning/UnusedTypeVar.purs:4:1 - 4:24 (line 4, column 1 - line 4, column 24)
+
+ Type variable [33mb[0m is ambiguous, since it is unused in the polymorphic type which introduces it.
+
+in type declaration for [33mf[0m
+
+See https://github.com/purescript/documentation/blob/master/errors/UnusedTypeVar.md for more information,
+or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedVar.out b/tests/purs/warning/UnusedVar.out
new file mode 100644
index 0000000000..7556b6ebb6
--- /dev/null
+++ b/tests/purs/warning/UnusedVar.out
@@ -0,0 +1,108 @@
+Warning 1 of 9:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVar.purs:16:20 - 16:32 (line 16, column 20 - line 16, column 32)
+
+ Name [33mlambdaUnused[0m was introduced but not used.
+
+ in value declaration [33munusedInLambda[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 9:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVar.purs:20:7 - 20:20 (line 20, column 7 - line 20, column 20)
+
+ Name [33mletUnused[0m was introduced but not used.
+
+ in value declaration [33munusedLetName[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 3 of 9:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVar.purs:26:9 - 26:24 (line 26, column 9 - line 26, column 24)
+
+ Name [33mwhereUnused[0m was introduced but not used.
+
+ in value declaration [33munusedWhereIsLet[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 4 of 9:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVar.purs:30:11 - 30:23 (line 30, column 11 - line 30, column 23)
+
+ Name [33mletArgUnused[0m was introduced but not used.
+
+ in value declaration [33munusedLetArgument[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 5 of 9:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVar.purs:44:5 - 44:15 (line 44, column 5 - line 44, column 15)
+
+ Name [33mcaseUnused[0m was introduced but not used.
+
+ in value declaration [33munusedCaseBinder[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 6 of 9:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVar.purs:62:34 - 62:35 (line 62, column 34 - line 62, column 35)
+
+ Name [33mx[0m was introduced but not used.
+
+ in value declaration [33munusedShadowedByRecursiveBinding[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 7 of 9:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVar.purs:69:8 - 69:9 (line 69, column 8 - line 69, column 9)
+
+ Name [33mx[0m was introduced but not used.
+
+ in value declaration [33munusedShadowingLet[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 8 of 9:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVar.purs:87:7 - 87:8 (line 87, column 7 - line 87, column 8)
+
+ Name [33mx[0m was introduced but not used.
+
+ in value declaration [33mnotOops[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 9 of 9:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVar.purs:63:7 - 63:16 (line 63, column 7 - line 63, column 16)
+
+ Name [33mx[0m was shadowed.
+
+ in value declaration [33munusedShadowedByRecursiveBinding[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/ShadowedName.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedVar.purs b/tests/purs/warning/UnusedVar.purs
new file mode 100644
index 0000000000..6a71633bbd
--- /dev/null
+++ b/tests/purs/warning/UnusedVar.purs
@@ -0,0 +1,104 @@
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith ShadowedName
+module Main where
+
+data X = X
+
+
+unusedInLambda :: X
+unusedInLambda = (\lambdaUnused -> X) X
+
+unusedLetName :: X
+unusedLetName =
+ let letUnused = X in
+ X
+
+unusedWhereIsLet :: X
+unusedWhereIsLet =
+ X
+ where whereUnused = X
+
+unusedLetArgument :: X
+unusedLetArgument =
+ let f x letArgUnused = x
+ in f X X
+
+notUnusedLet :: X
+notUnusedLet =
+ let f x = f' x
+ f' x = f x
+ in
+ f X
+
+
+unusedCaseBinder :: X
+unusedCaseBinder =
+ case X of
+ caseUnused -> X
+
+unusedObjUpdate :: { foo :: X }
+unusedObjUpdate =
+ let x = X
+ obj = { foo: X }
+ in
+ obj { foo = x }
+
+-- The outer x is used in the let-bound expression, the let-binding variable is used in the body
+notUnusedNonRecursiveBinding :: X -> X
+notUnusedNonRecursiveBinding x =
+ let {x} = {x}
+ in x
+
+-- Almost like above but the outer x is not used, as x is bound recursively (Can also be true if there are no
+-- arguments to x but in most cases this will error due to being cyclic)
+unusedShadowedByRecursiveBinding :: X -> X
+unusedShadowedByRecursiveBinding x =
+ let x _ = x X
+ in x X
+
+-- In this case the outer x is used but the new x binding is not
+unusedShadowingLet :: X -> X
+unusedShadowingLet x =
+ let (x) = x
+ in X
+
+-- 4110
+oops ∷ { inner :: String } → String
+oops box =
+ let
+ { inner } = box
+ val = inner
+ in
+ val
+
+-- like oops but switching order to show we don't
+notOops ∷ { x :: String } -> String → String
+notOops box x =
+ let
+ val = x
+ _blah = x
+ { x } = box
+ in
+ val
+
+bindingGroupsNotRecognised :: Int
+bindingGroupsNotRecognised =
+ let
+ f n = g n
+ g n = f n
+
+ -- Second f is unused because this is multiple recursive binding groups, we don't warn because we assume
+ -- it might be one binding group so there is a usage. If it would be 1 binding group there would be an error
+ -- Shadowed variable warnings are similarly not aware of binding groups
+ { x } = { x: 2 }
+ h n = n
+ f x = x
+ in
+ h x
\ No newline at end of file
diff --git a/tests/purs/warning/UnusedVarDecls.out b/tests/purs/warning/UnusedVarDecls.out
new file mode 100644
index 0000000000..58b2f20c78
--- /dev/null
+++ b/tests/purs/warning/UnusedVarDecls.out
@@ -0,0 +1,23 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVarDecls.purs:13:15 - 13:24 (line 13, column 15 - line 13, column 24)
+
+ Name [33munusedArg[0m was introduced but not used.
+
+ in value declaration [33munusedArgDecl[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVarDecls.purs:16:1 - 17:4 (line 16, column 1 - line 17, column 4)
+
+ Declaration [33munusedDecl[0m was not used, and is not exported.
+
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedDeclaration.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedVarDecls.purs b/tests/purs/warning/UnusedVarDecls.purs
new file mode 100644
index 0000000000..4f71829279
--- /dev/null
+++ b/tests/purs/warning/UnusedVarDecls.purs
@@ -0,0 +1,17 @@
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedDeclaration
+
+module Main
+ ( unusedArgDecl
+ , X(..)
+ ) where
+
+data X = X
+
+
+unusedArgDecl :: X -> X
+unusedArgDecl unusedArg = X
+
+unusedDecl :: X
+unusedDecl =
+ X
\ No newline at end of file
diff --git a/tests/purs/warning/UnusedVarDo.out b/tests/purs/warning/UnusedVarDo.out
new file mode 100644
index 0000000000..b25475df00
--- /dev/null
+++ b/tests/purs/warning/UnusedVarDo.out
@@ -0,0 +1,48 @@
+Warning 1 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVarDo.purs:12:3 - 12:15 (line 12, column 3 - line 12, column 15)
+
+ Name [33munusedDoBind[0m was introduced but not used.
+
+ in value declaration [33munusedDoBinding[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVarDo.purs:24:7 - 24:23 (line 24, column 7 - line 24, column 23)
+
+ Name [33munusedDoLet[0m was introduced but not used.
+
+ in value declaration [33munusedDoLetBinding[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 3 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVarDo.purs:29:3 - 29:16 (line 29, column 3 - line 29, column 16)
+
+ Name [33munusedAdoBind[0m was introduced but not used.
+
+ in value declaration [33munusedAdoBinding[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
+Warning 4 of 4:
+
+ in module [33mMain[0m
+ at tests/purs/warning/UnusedVarDo.purs:34:7 - 34:24 (line 34, column 7 - line 34, column 24)
+
+ Name [33munusedAdoLet[0m was introduced but not used.
+
+ in value declaration [33munusedAdoLetBinding[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/UnusedVarDo.purs b/tests/purs/warning/UnusedVarDo.purs
new file mode 100644
index 0000000000..601d6e1d9e
--- /dev/null
+++ b/tests/purs/warning/UnusedVarDo.purs
@@ -0,0 +1,48 @@
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+-- @shouldWarnWith UnusedName
+module Main where
+
+import Prelude
+import Data.Maybe (Maybe)
+
+unusedDoBinding :: Maybe Int
+unusedDoBinding = do
+ unusedDoBind <- pure 42
+ pure 17
+
+usedDoBinding :: Maybe Int
+usedDoBinding = do
+ fine <- pure 42
+ let alsoFine = 1
+ pure $ fine + alsoFine
+
+
+unusedDoLetBinding :: Maybe Int
+unusedDoLetBinding = do
+ let unusedDoLet = 42
+ pure 17
+
+unusedAdoBinding :: Maybe Int
+unusedAdoBinding = ado
+ unusedAdoBind <- pure 42
+ in 17
+
+unusedAdoLetBinding :: Maybe Int
+unusedAdoLetBinding = ado
+ let unusedAdoLet = 42
+ in 17
+
+notUnusedNonRecursiveBinding :: Int -> Maybe Int
+notUnusedNonRecursiveBinding x = do
+ let {x} = {x}
+ pure x
+
+-- 4110 in do syntax
+oops ∷ { inner :: String } → String
+oops box = do
+ let
+ { inner } = box
+ val = inner
+ val
\ No newline at end of file
diff --git a/tests/purs/warning/VTAsWildcardInferred.out b/tests/purs/warning/VTAsWildcardInferred.out
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/purs/warning/VTAsWildcardInferred.purs b/tests/purs/warning/VTAsWildcardInferred.purs
new file mode 100644
index 0000000000..4a5da616d1
--- /dev/null
+++ b/tests/purs/warning/VTAsWildcardInferred.purs
@@ -0,0 +1,28 @@
+-- See https://github.com/purescript/purescript/issues/4487
+module Main where
+
+import Prelude
+import Effect (Effect)
+import Effect.Console (log)
+
+f :: forall @a. a -> a
+f = identity
+
+test1 :: { x :: Int }
+test1 = f @{ x :: _ } { x: 42 }
+
+class Foo :: Type -> Type -> Type -> Constraint
+class Foo a b c | a -> b c where
+ fooMember :: a -> b
+
+wrap :: forall @a. Array a -> Array (Array a)
+wrap as = [as]
+
+arrFooMember :: forall c. Array (Foo Int Boolean c => Int -> Boolean)
+arrFooMember = [fooMember]
+
+test2 :: forall c. Array (Array (Foo Int Boolean c => Int -> Boolean))
+test2 = wrap @(Foo Int Boolean _ => _) arrFooMember -- neither wildcard should warn IMO
+
+main :: Effect Unit
+main = log "Done"
diff --git a/tests/purs/warning/WildcardInferredType.out b/tests/purs/warning/WildcardInferredType.out
new file mode 100644
index 0000000000..91aabf9a1e
--- /dev/null
+++ b/tests/purs/warning/WildcardInferredType.out
@@ -0,0 +1,30 @@
+Warning 1 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/WildcardInferredType.purs:7:6 - 7:7 (line 7, column 6 - line 7, column 7)
+
+ Wildcard type definition has the inferred type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+ in value declaration [33my[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/WildcardInferredType.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 2:
+
+ in module [33mMain[0m
+ at tests/purs/warning/WildcardInferredType.purs:5:10 - 5:11 (line 5, column 10 - line 5, column 11)
+
+ Wildcard type definition has the inferred type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+ in value declaration [33mx[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/WildcardInferredType.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/WildcardInferredType2.out b/tests/purs/warning/WildcardInferredType2.out
new file mode 100644
index 0000000000..52cbc66ce7
--- /dev/null
+++ b/tests/purs/warning/WildcardInferredType2.out
@@ -0,0 +1,83 @@
+Warning 1 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/warning/WildcardInferredType2.purs:10:6 - 10:7 (line 10, column 6 - line 10, column 7)
+
+ Wildcard type definition has the inferred type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+ in value declaration [33mx[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/WildcardInferredType.md for more information,
+ or to contribute content related to this warning.
+
+Warning 2 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/warning/WildcardInferredType2.purs:51:9 - 51:10 (line 51, column 9 - line 51, column 10)
+
+ Wildcard type definition has the inferred type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+ in binding group foxtrot, echo
+
+ See https://github.com/purescript/documentation/blob/master/errors/WildcardInferredType.md for more information,
+ or to contribute content related to this warning.
+
+Warning 3 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/warning/WildcardInferredType2.purs:54:8 - 54:9 (line 54, column 8 - line 54, column 9)
+
+ Wildcard type definition has the inferred type
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+ in the following context:
+
+ m :: [33mInt[0m
+
+
+ in binding group foxtrot, echo
+
+ See https://github.com/purescript/documentation/blob/master/errors/WildcardInferredType.md for more information,
+ or to contribute content related to this warning.
+
+Warning 4 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/warning/WildcardInferredType2.purs:47:1 - 49:8 (line 47, column 1 - line 49, column 8)
+
+ No type declaration was provided for the top-level declaration of [33mdelta[0m.
+ It is good practice to provide type declarations as a form of documentation.
+ The inferred type of [33mdelta[0m was:
+ [33m [0m
+ [33m Int -> Int[0m
+ [33m [0m
+
+ in binding group delta, charlie
+
+ See https://github.com/purescript/documentation/blob/master/errors/MissingTypeDeclaration.md for more information,
+ or to contribute content related to this warning.
+
+Warning 5 of 5:
+
+ in module [33mMain[0m
+ at tests/purs/warning/WildcardInferredType2.purs:25:1 - 31:14 (line 25, column 1 - line 31, column 14)
+
+ No type declaration was provided for the top-level declaration of [33malpha[0m.
+ It is good practice to provide type declarations as a form of documentation.
+ The inferred type of [33malpha[0m was:
+ [33m [0m
+ [33m Int[0m
+ [33m [0m
+
+ in value declaration [33malpha[0m
+
+ See https://github.com/purescript/documentation/blob/master/errors/MissingTypeDeclaration.md for more information,
+ or to contribute content related to this warning.
+
diff --git a/tests/purs/warning/WildcardInferredType2.purs b/tests/purs/warning/WildcardInferredType2.purs
index 441a326c18..151bd2ddb0 100644
--- a/tests/purs/warning/WildcardInferredType2.purs
+++ b/tests/purs/warning/WildcardInferredType2.purs
@@ -1,6 +1,12 @@
-- @shouldWarnWith WildcardInferredType
+-- @shouldWarnWith MissingTypeDeclaration
+-- @shouldWarnWith WildcardInferredType
+-- @shouldWarnWith WildcardInferredType
+-- @shouldWarnWith MissingTypeDeclaration
module Main where
+import Prelude
+
x :: _
x = 42
@@ -11,4 +17,44 @@ z :: Int
z = n
where
n :: _
- n = 42
\ No newline at end of file
+ n = 42
+
+-- Inner signatures can suppress warnings from more-inner wildcards,
+-- even though a top-level signature is missing (see #4268)
+
+alpha = f 0
+ where
+ f :: Int -> Int
+ f m = n
+ where
+ n :: _
+ n = m + 1
+
+-- Tests for recursive binding groups (see #4268)
+
+bravo :: Int -> Int
+bravo m = if n > 0 then bravo (n - 1) else n
+ where
+ n :: _
+ n = m
+
+charlie :: Int -> Int
+charlie m = if n > 0 then delta (n - 1) else n
+ where
+ n :: _
+ n = m
+
+delta m = if n > 0 then charlie (n - 1) else n
+ where
+ n = m
+
+echo :: _ -> Int -- Partial signatures don't count!
+echo m = if n > 0 then foxtrot (n - 1) else n
+ where
+ n :: _
+ n = m
+
+foxtrot :: Int -> Int
+foxtrot m = if n > 0 then echo (n - 1) else n
+ where
+ n = m
diff --git a/tests/support/.gitignore b/tests/support/.gitignore
index 68b9e27759..fdd2fabfc0 100644
--- a/tests/support/.gitignore
+++ b/tests/support/.gitignore
@@ -1,2 +1,3 @@
node_modules/
bower_components/
+/.last_updated
diff --git a/tests/support/bower.json b/tests/support/bower.json
index 4d66df9c82..a0cd88be21 100644
--- a/tests/support/bower.json
+++ b/tests/support/bower.json
@@ -1,40 +1,39 @@
{
"name": "purescript-test-suite-support",
"dependencies": {
- "purescript-arrays": "5.0.0",
- "purescript-assert": "4.0.0",
- "purescript-bifunctors": "4.0.0",
- "purescript-console": "4.1.0",
- "purescript-control": "4.0.0",
- "purescript-distributive": "4.0.0",
- "purescript-effect": "2.0.0",
- "purescript-either": "4.0.0",
- "purescript-foldable-traversable": "4.0.0",
- "purescript-functions": "4.0.0",
- "purescript-gen": "2.0.0",
- "purescript-generics-rep": "6.0.0",
- "purescript-globals": "4.0.0",
- "purescript-identity": "4.0.0",
- "purescript-integers": "4.0.0",
- "purescript-invariant": "4.0.0",
- "purescript-lazy": "4.0.0",
- "purescript-lists": "5.0.0",
- "purescript-math": "2.1.1",
- "purescript-maybe": "4.0.0",
- "purescript-newtype": "3.0.0",
- "purescript-nonempty": "5.0.0",
- "purescript-partial": "2.0.0",
- "purescript-prelude": "4.0.0",
- "purescript-proxy": "3.0.0",
- "purescript-psci-support": "4.0.0",
- "purescript-refs": "4.1.0",
- "purescript-st": "4.0.0",
- "purescript-strings": "4.0.0",
- "purescript-tailrec": "4.0.0",
- "purescript-tuples": "5.0.0",
- "purescript-type-equality": "3.0.0",
- "purescript-typelevel-prelude": "3.0.0",
- "purescript-unfoldable": "4.0.0",
- "purescript-unsafe-coerce": "4.0.0"
+ "purescript-arrays": "^7.0.0",
+ "purescript-assert": "^6.0.0",
+ "purescript-bifunctors": "^6.0.0",
+ "purescript-console": "^6.0.0",
+ "purescript-control": "^6.0.0",
+ "purescript-distributive": "^6.0.0",
+ "purescript-effect": "^4.0.0",
+ "purescript-either": "^6.1.0",
+ "purescript-enums": "^6.0.0",
+ "purescript-foldable-traversable": "^6.0.0",
+ "purescript-functions": "^6.0.0",
+ "purescript-gen": "^4.0.0",
+ "purescript-identity": "^6.0.0",
+ "purescript-integers": "^6.0.0",
+ "purescript-invariant": "^6.0.0",
+ "purescript-lazy": "^6.0.0",
+ "purescript-lists": "^7.0.0",
+ "purescript-maybe": "^6.0.0",
+ "purescript-newtype": "^5.0.0",
+ "purescript-nonempty": "^7.0.0",
+ "purescript-numbers": "^9.0.0",
+ "purescript-partial": "^4.0.0",
+ "purescript-prelude": "^6.0.0",
+ "purescript-psci-support": "^6.0.0",
+ "purescript-refs": "^6.0.0",
+ "purescript-safe-coerce": "^2.0.0",
+ "purescript-st": "^6.1.0",
+ "purescript-strings": "^6.0.0",
+ "purescript-tailrec": "^6.1.0",
+ "purescript-tuples": "^7.0.0",
+ "purescript-type-equality": "^4.0.1",
+ "purescript-typelevel-prelude": "^7.0.0",
+ "purescript-unfoldable": "^6.0.0",
+ "purescript-unsafe-coerce": "^6.0.0"
}
}
diff --git a/tests/support/checkSourceMapValidity.js b/tests/support/checkSourceMapValidity.js
new file mode 100644
index 0000000000..4272b3115d
--- /dev/null
+++ b/tests/support/checkSourceMapValidity.js
@@ -0,0 +1,33 @@
+// Run as `node checkSourceMapValidity.js path/to/index.js.map`
+
+const s = require("source-map");
+const fs = require("fs");
+const process = require("process");
+
+if (process.argv.length < 3) {
+ const errMsg = [
+ "Script did not receive the source map file path as its only argument",
+ "Rerun using `node checkSourceMapValidity.js path/to/index.js.map`"
+ ].join("\n");
+ throw new Error(errMsg);
+}
+
+const sourceMapFilePath = process.argv[2];
+console.log(`Checking validity of source map for ${sourceMapFilePath}`);
+const content = fs.readFileSync(sourceMapFilePath, {encoding: "utf-8"});
+s.SourceMapConsumer.with(
+ JSON.parse(content),
+ null,
+ (consumer) => {
+ // We only use the `eachMapping` function to trigger an error
+ // if a mapping is invalid.
+ consumer.eachMapping(function () {});
+ }
+ )
+ .then(() => console.log(`${sourceMapFilePath} sourcemap is valid`))
+ .catch((e) => {
+ console.error(` ${e.message}`);
+ // See https://nodejs.org/dist/latest-v16.x/docs/api/process.html#processexitcode
+ // for why we don't call `process.exit(1)`
+ process.exitCode = 1;
+ });
diff --git a/tests/support/package.json b/tests/support/package.json
index 0e54c5ed3a..d60097eba8 100644
--- a/tests/support/package.json
+++ b/tests/support/package.json
@@ -3,6 +3,7 @@
"dependencies": {
"bower": "^1.8.8",
"glob": "^5.0.14",
- "rimraf": "^2.5.2"
+ "rimraf": "^2.5.2",
+ "source-map": "^0.7.3"
}
}
diff --git a/tests/support/pscide/src/CompletionSpec.purs b/tests/support/pscide/src/CompletionSpec.purs
new file mode 100644
index 0000000000..a6e2bae81d
--- /dev/null
+++ b/tests/support/pscide/src/CompletionSpec.purs
@@ -0,0 +1,18 @@
+module CompletionSpec where
+
+exampleValue :: Int
+exampleValue = 42
+
+exampleFunction :: Int -> Int
+exampleFunction _ = 1
+
+exampleInferredString = ""
+
+infixl 5 exampleFunction as \°/
+
+data ExampleTypeConstructor a b = ExampleTypeConstructor a b
+
+infixl 5 type ExampleTypeConstructor as \°/
+
+class ExampleClass where
+ exampleMember :: Int
diff --git a/tests/support/pscide/src/CompletionSpecDocs.purs b/tests/support/pscide/src/CompletionSpecDocs.purs
index dae3fc43c4..787113018c 100644
--- a/tests/support/pscide/src/CompletionSpecDocs.purs
+++ b/tests/support/pscide/src/CompletionSpecDocs.purs
@@ -11,4 +11,9 @@ withType = 42
-- | This is
-- | a multi-line
-- | comment
-multiline = "multiline"
\ No newline at end of file
+multiline = "multiline"
+
+-- | Doc for class
+class DocClass where
+ -- | doc for member
+ member :: Int
diff --git a/tests/support/pscide/src/RebuildSpecWithForeign.js b/tests/support/pscide/src/RebuildSpecWithForeign.js
index 8ea453ff71..577e8a5d5d 100644
--- a/tests/support/pscide/src/RebuildSpecWithForeign.js
+++ b/tests/support/pscide/src/RebuildSpecWithForeign.js
@@ -1 +1 @@
-exports.f = 5;
+export var f = 5;
diff --git a/tests/support/setup-win.cmd b/tests/support/setup-win.cmd
deleted file mode 100644
index 2b40898f9b..0000000000
--- a/tests/support/setup-win.cmd
+++ /dev/null
@@ -1,3 +0,0 @@
-@echo off
-call npm install
-call node_modules\.bin\bower install --config.interactive=false
diff --git a/update-changelog.hs b/update-changelog.hs
new file mode 100755
index 0000000000..291160ceca
--- /dev/null
+++ b/update-changelog.hs
@@ -0,0 +1,216 @@
+#!/usr/bin/env stack
+{- stack
+ --resolver lts-20.9 script
+ --package bytestring
+ --package filepath
+ --package text
+ --package github-rest
+ --package directory
+ --package simple-cmd
+ --package time
+ --package bifunctors
+ --package attoparsec
+ --package aeson
+ --package protolude
+-}
+{-# LANGUAGE
+ DeriveFoldable
+ , DeriveFunctor
+ , DeriveTraversable
+ , FlexibleContexts
+ , LambdaCase
+ , NoImplicitPrelude
+ , OverloadedStrings
+ , PackageImports
+ , RecordWildCards
+ , TupleSections
+ , ViewPatterns
+ #-} -- Hlint requires this leading space
+
+-- |
+-- This script updates CHANGELOG.md with the contents of CHANGELOG.d, and
+-- empties CHANGELOG.d. It takes care of:
+--
+-- * Sorting entries by the order in which their PRs were merged
+-- * Appending (#1234 by @author) to the first line of each fragment,
+-- optionally adding multiple PR numbers and/or authors as applicable
+-- * Grouping entries by type and adding non-empty group headings to the
+-- changelog
+-- * Syncing any affected files to the Git index, preparing for you to make
+-- your release commit
+--
+-- Be sure to run this *after* updating the version number in
+-- npm-package/package.json, as that's where this script gets the new section
+-- header from.
+--
+
+module Main (main) where
+
+import Protolude hiding (intercalate, readFile, writeFile)
+import qualified Protolude
+
+import Control.Monad.Fail (fail)
+import qualified Data.Aeson as JSON
+import qualified Data.Aeson.KeyMap as KM
+import Data.Attoparsec.ByteString (maybeResult, parse)
+import "bifunctors"
+ Data.Bifunctor.Flip (Flip(..))
+import qualified Data.ByteString as BS
+import qualified Data.List.NonEmpty as NEL
+import Data.String (String)
+import qualified Data.String as String
+import qualified Data.Text as T
+import Data.Time.Clock (UTCTime)
+import Data.Time.Format.ISO8601 (iso8601ParseM)
+import Data.Time.LocalTime (zonedTimeToUTC)
+import GitHub.REST (GHEndpoint(..), GitHubSettings(..), KeyValue(..), MonadGitHubREST, StdMethod(..), queryGitHub, runGitHubT)
+import qualified SimpleCmd.Git as IOGit
+import System.Directory (setCurrentDirectory)
+import System.FilePath (normalise, takeFileName, (>))
+
+main = runGitHubT gitHubSettings $ do
+ git "rev-parse" ["--show-toplevel"] >>= liftIO . setCurrentDirectory
+ entries <- String.lines <$> git "ls-tree" ["--name-only", "HEAD", "CHANGELOG.d/"]
+
+ breaks <- processEntriesStartingWith "break" entries
+ features <- processEntriesStartingWith "feat" entries
+ fixes <- processEntriesStartingWith "fix" entries
+ internal <- processEntriesStartingWith "int" entries
+ misc <- processEntriesStartingWith "misc" entries
+
+ let entryFiles = ceFile <$> breaks <> features <> fixes <> internal <> misc
+ unless (null entryFiles) $ do
+
+ changes <- git "status" ("-s" : "--" : "CHANGELOG.md" : entryFiles)
+ unless (null changes) . liftIO . die $
+ "You have uncommitted changes to changelog files. " <>
+ "Please commit, stash, or revert them before running this script."
+
+ version <- getVersion
+ (changelogPreamble, changelogRest) <- T.breakOn "\n## " <$> readFile "CHANGELOG.md"
+ writeFile "CHANGELOG.md" $
+ changelogPreamble
+ <> "\n## " <> version <> "\n"
+ <> conditionalSection "Breaking changes" breaks
+ <> conditionalSection "New features" features
+ <> conditionalSection "Bugfixes" fixes
+ <> conditionalSection "Other improvements" misc
+ <> conditionalSection "Internal" internal
+ <> changelogRest
+
+ git_ "add" ["CHANGELOG.md"]
+ git_ "rm" $ "-q" : entryFiles
+
+gitHubSettings :: GitHubSettings
+gitHubSettings = GitHubSettings Nothing "purescript/purescript update-changelog.hs" "v3"
+
+processEntriesStartingWith :: (MonadFail m, MonadGitHubREST m, MonadIO m) => String -> [String] -> m [ChangelogEntry]
+processEntriesStartingWith prefix
+ = fmap (sortOn ceDate)
+ . traverse updateEntry
+ . filter ((prefix `isPrefixOf`) . map toLower . takeFileName)
+
+updateEntry :: (MonadFail m, MonadGitHubREST m, MonadIO m) => String -> m ChangelogEntry
+updateEntry file = do
+ (header, body) <- T.breakOn "\n" . T.strip <$> (readFile . normalise) file
+
+ allCommits <-
+ fmap (NEL.fromList . sortOn glcTime)
+ . traverse (\(T.breakOn " " -> (h, T.breakOn " " . T.tail -> (c, s))) ->
+ GitLogCommit (T.tail s) h . zonedTimeToUTC <$> iso8601ParseM (toS c))
+ =<< gitLines "log" ["-m", "--follow", "--format=%H %cI %s", file]
+
+ prCommits <-
+ filterM isInterestingCommit
+ . mapMaybe (traverse parsePRNumber)
+ $ NEL.toList allCommits
+
+ let prNumbers = map (snd . glcData) prCommits
+
+ prAuthors <- ordNub <$> traverse lookupPRAuthor prNumbers
+
+ let headerSuffix = if null prNumbers then "" else
+ " ("
+ <> commaSeparate (map (("#" <>) . show) prNumbers)
+ <> " by "
+ <> commaSeparate (map ("@" <>) prAuthors)
+ <> ")"
+
+ pure $ ChangelogEntry file (header <> headerSuffix <> body <> "\n") (glcTime $ NEL.head allCommits)
+
+parsePRNumber :: Text -> Maybe (CommitType, Int)
+parsePRNumber = liftA2 (<|>)
+ (fmap (MergeCommit, ) . readMaybe . (toS :: T.Text -> String) . fst . T.breakOn " " <=< T.stripPrefix "Merge pull request #")
+ (fmap (SquashCommit, ) . readMaybe . (toS :: T.Text -> String) <=< T.stripSuffix ")" . snd . T.breakOnEnd "(#")
+
+-- |
+-- This function helps us exclude PRs that are just fixups of changelog
+-- wording. An interesting commit is one that has either edited a file that
+-- isn't part of the changelog, or is a merge commit.
+--
+isInterestingCommit :: MonadIO m => GitLogCommit (CommitType, Int) -> m Bool
+isInterestingCommit GitLogCommit{..} = case fst glcData of
+ MergeCommit -> pure True
+ SquashCommit ->
+ not . all (\path -> "CHANGELOG.md" == path || "CHANGELOG.d/" `T.isPrefixOf` path)
+ <$> gitLines "show" ["--format=", "--name-only", toS glcHash]
+
+lookupPRAuthor :: (MonadFail m, MonadGitHubREST m) => Int -> m Text
+lookupPRAuthor prNum =
+ queryGitHub GHEndpoint{ method = GET
+ , endpoint = "/repos/purescript/purescript/pulls/:pr"
+ , endpointVals = ["pr" := prNum]
+ , ghData = []
+ }
+ >>= \case
+ JSON.Object (KM.lookup "user" -> Just (JSON.Object (KM.lookup "login" -> Just (JSON.String name)))) -> pure name
+ _ -> fail "error accessing GitHub API"
+
+commaSeparate :: [Text] -> Text
+commaSeparate = \case
+ [] -> ""
+ [a] -> a
+ [a, b] -> a <> " and " <> b
+ more | Just (init, last) <- unsnoc more -> T.intercalate ", " init <> ", and " <> last
+
+getVersion :: (MonadFail m, MonadIO m) => m Text
+getVersion =
+ (liftIO . BS.readFile) ("npm-package" > "package.json") >>= \case
+ (maybeResult . parse JSON.json -> Just (JSON.Object (KM.lookup "version" -> Just (JSON.String v)))) -> pure v
+ _ -> fail "could not read version from npm-package/package.json"
+
+conditionalSection :: Text -> [ChangelogEntry] -> Text
+conditionalSection header = \case
+ [] -> ""
+ entries ->
+ "\n" <> header <> ":\n\n" <> T.intercalate "\n" (map ceContent entries)
+
+git :: MonadIO m => String -> [String] -> m String
+git cmd = liftIO . IOGit.git cmd
+
+git_ :: MonadIO m => String -> [String] -> m ()
+git_ cmd = liftIO . IOGit.git_ cmd
+
+gitLines :: MonadIO m => String -> [String] -> m [Text]
+gitLines cmd args = lines . toS <$> git cmd args
+
+readFile :: MonadIO m => FilePath -> m Text
+readFile = liftIO . Protolude.readFile
+
+writeFile :: MonadIO m => FilePath -> Text -> m ()
+writeFile path = liftIO . Protolude.writeFile path
+
+data ChangelogEntry = ChangelogEntry
+ { ceFile :: String
+ , ceContent :: Text
+ , ceDate :: UTCTime
+ }
+
+data GitLogCommit a = GitLogCommit
+ { glcData :: a
+ , glcHash :: Text
+ , glcTime :: UTCTime
+ }
+ deriving (Functor, Foldable, Traversable)
+
+data CommitType = MergeCommit | SquashCommit
diff --git a/weeder.toml b/weeder.toml
new file mode 100644
index 0000000000..1a8249a2e2
--- /dev/null
+++ b/weeder.toml
@@ -0,0 +1,40 @@
+roots = [
+ "^Main\\.main$",
+ "^PscIdeSpec\\.main$",
+
+ # These declarations are used in Pursuit. (The Types declarations are
+ # reexported in the L.P.Docs module, and referenced from there, but Weeder
+ # isn't that smart.)
+ "^Language\\.PureScript\\.Docs\\.AsHtml\\.packageAsHtml$",
+ "^Language\\.PureScript\\.Docs\\.Types\\.asUploadedPackage$",
+ "^Language\\.PureScript\\.Docs\\.Types\\.getLink$",
+ "^Language\\.PureScript\\.Docs\\.Types\\.getLinksContext$",
+ "^Language\\.PureScript\\.Docs\\.Types\\.packageName$",
+ "^Language\\.PureScript\\.Docs\\.Types\\.verifyPackage$",
+
+ # These declarations are believed to be used in other projects that we want
+ # to continue to support.
+ "^Language\\.PureScript\\.CoreFn\\.FromJSON\\.moduleFromJSON$",
+ "^Language\\.PureScript\\.CST\\.Print\\.printModule$",
+
+ # These declarations are there to be used during development or testing.
+ "^Language\\.PureScript\\.Ide\\.Imports\\.parseImport$",
+ "^Language\\.PureScript\\.TypeChecker\\.Monad\\.debug",
+
+ # These declarations are used by Template Haskell code.
+ "^Language\\.PureScript\\.Constants\\.TH\\.",
+
+ # These declarations are produced by Template Haskell when generating
+ # pattern synonyms; this confuses Weeder.
+ "^Language\\.PureScript\\.Constants\\..*\\.\\$[bm]",
+
+ # These declarations are unprincipled exceptions that we don't mind
+ # supporting just in case they're used now or in the future.
+ "^Language\\.PureScript\\.CST\\.Parser\\.parseExpr$",
+
+ # These declarations are generated by tools; it doesn't matter if they're
+ # unused because we can't do anything about them.
+ "^Language\\.PureScript\\.CST\\.Parser\\.happy",
+ "^Paths_purescript?\\.",
+]
+type-class-roots = true