Merge pull request #716 from abarbu/master

Support GHC 8
This commit is contained in:
Vaibhav Sagar 2017-06-04 18:41:37 +08:00 committed by GitHub
commit 19ba3cdf62
88 changed files with 1276 additions and 942 deletions

1
.ghci
View File

@ -1,5 +1,4 @@
:set -package ghc
:set -package ghc-paths
:set -i. -isrc -idist/build/autogen
:set -XDoAndIfThenElse -XOverloadedStrings
:set prompt "\ESC[34mλ> \ESC[m"

View File

@ -1,7 +1,6 @@
# Test against different stack LTS versions.
env:
- DISPLAY=true RESOLVER=lts-6.2 # Most recent GHC 7.10 LTS
- DISPLAY=false RESOLVER=lts-2.22 # Last GHC 7.8 LTS
- DISPLAY=true RESOLVER=lts-8.12 # GHC 8.0.2
# Choose a lightweight base image; we provide our own build tools.
language: python
@ -49,6 +48,10 @@ before_install:
cd $OLDPWD
fi
# Upgrades to avoid later build problems
- pip install -U pip
- pip install -U setuptools
# Install nbconvert for testing the notebook
- pip install jupyter notebook nbconvert
@ -56,28 +59,29 @@ before_install:
install:
# Set path for pkg-config to find zeromq, otherwise install of zeromq4-haskell fails.
- export PKG_CONFIG_PATH=$HOME/zeromq/lib/pkgconfig/
- |
echo "apply-ghc-options: everything" >> stack.yaml
- stack setup --resolver=$RESOLVER
- stack build --dependencies-only --resolver=$RESOLVER
- stack install gtk2hs-buildtools --fast
- stack build hmatrix --resolver=$RESOLVER --fast
- stack build --dependencies-only --resolver=$RESOLVER --fast
script:
- export LD_LIBRARY_PATH=$HOME/zeromq/lib
- stack test --resolver=$RESOLVER
- stack test --no-terminal --resolver=$RESOLVER --fast
- |
set -e
if $DISPLAY; then
TOP=$(pwd)
for PACKAGE in ihaskell-display/*; do
cd "$TOP/$PACKAGE";
stack build --resolver=$RESOLVER;
cd "$TOP";
done
stack build --no-terminal --resolver=$RESOLVER --fast
# Ensure that ipython-kernel examples build successfully.
stack build ipython-kernel --flag ipython-kernel:examples
stack build ipython-kernel --flag ipython-kernel:examples --fast
# Ensure that IHaskell notebook remains unchanged.
# Run the notebook to regenerate the outputs, then compare the new notebook to the old one.
stack install --stack-yaml=stack-full.yaml
stack install --fast
stack exec -- ihaskell install --stack
stack exec -- jupyter nbconvert --to=notebook --execute --stdout notebooks/IHaskell.ipynb > ~/ihaskell-out.ipynb

309
README.md
View File

@ -1,11 +1,4 @@
IHaskell is a kernel for the [Jupyter project](http://ipython.org), which allows you to use Haskell inside Jupyter frontends, including the console and in-browser notebook.
### Status
[![Join the chat at https://gitter.im/gibiansky/IHaskell](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gibiansky/IHaskell?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/gibiansky/IHaskell.svg?branch=master)](https://travis-ci.org/gibiansky/IHaskell)
![IHaskell](https://raw.github.com/gibiansky/IHaskell/master/html/logo-64x64.png)
![jupyter](https://i.imgur.com/S16l2Hw.png) ![IHaskell](https://i.imgur.com/qhXXFbA.png) [![Build Status](https://travis-ci.org/gibiansky/IHaskell.svg?branch=master)](https://travis-ci.org/gibiansky/IHaskell)
# IHaskell
@ -18,288 +11,82 @@ IHaskell is a kernel for the [Jupyter project](http://ipython.org), which allows
For a tour of some IHaskell features, check out the [demo Notebook](http://nbviewer.ipython.org/github/gibiansky/IHaskell/blob/master/notebooks/IHaskell.ipynb). More example notebooks are available on the [wiki](https://github.com/gibiansky/IHaskell/wiki).
The [wiki](https://github.com/gibiansky/IHaskell/wiki) also has more extensive documentation of IHaskell features.
### Shell Usage
![IPython Console](https://raw.github.com/gibiansky/IHaskell/master/images/ihaskell-console.png)
### Interactive In-Browser Notebook
![IPython Notebook](https://raw.github.com/gibiansky/IHaskell/master/images/ihaskell-notebook.png)
### Interactive In-Browser Notebook
# Source Installation
**Note:** IHaskell does not support Windows. To use on Windows, install
Virtualbox, install Ubuntu or another Linux distribution, and proceed with the
install instructions.
**How to get help:** Feel free to open an issue [on Github](https://github.com/gibiansky/IHaskell/issues?direction=desc&sort=updated&state=open) or join the [Gitter channel](https://gitter.im/gibiansky/IHaskell?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge).
# Installation
Arch Linux has a package for IHaskell: https://aur.archlinux.org/packages/ihaskell-git/
## Linux
Here is a blog post with step-by-step instructions for Ubuntu 14.04 (but should also work on other versions): https://remusao.github.io/install-ihaskell-on-ubuntu-1404-with-stack.html
Some prerequisites; adapt to your distribution.
### Docker Installation
The easiest way to use IHaskell is to install it inside a Docker container, which will come with the entire necessary stack, including Jupyter notebook. To install Docker, follow the [OS-specific instructions for your OS](https://docs.docker.com/engine/installation/).
To get the Docker image, pull it from the Docker Hub:
```bash
docker pull gibiansky/ihaskell:latest
sudo apt-get install -y python3-pip git libtinfo-dev libzmq3-dev libcairo2-dev libpango1.0-dev
```
You can then run IHaskell with:
```bash
docker run -it --volume $(pwd):/notebooks --publish 8888:8888 gibiansky/ihaskell:latest
```
If you wish to expose the Jupyter notebook on a port other than 8888, use the options `--publish 8888:$PORT` for any `PORT`.
If you'd like to build the image yourself, there is a provided `Dockerfile`, which you can build using:
```bash
# Build it in the repository directory
cd IHaskell/
# Building the image from scratch may take quite a while! (an hour or more)
docker build -t ihaskell:latest .
# Run the image without the gibiansky/ prefix
PORT=8888
docker run -it --volume $(pwd):/notebooks --publish 8888:$PORT ihaskell:latest
```
Open `localhost:$PORT` (`localhost:8888`) in your web browser to use IHaskell. If you are running on Mac OS X, then you will likely need to account for `docker-machine` and use the local IP of the machine instead of `localhost`.
### Install Using Installation Scripts
#### Ubuntu:
**If you are a user, and not a developer, it is recommended you use the `docker` instructions above instead of the Ubuntu installation script.**
If you are using a modern version of Ubuntu, clone the repository and then run the `ubuntu-install.sh` script:
```bash
git clone http://www.github.com/gibiansky/IHaskell
pip3 install -r requirements.txt
curl -sSL https://get.haskellstack.org/ | sh
git clone https://github.com/abarbu/IHaskell
cd IHaskell
./ubuntu-install.sh
stack install gtk2hs-buildtools
stack install --fast
stack exec ihaskell -- install
```
This script will ask you for `sudo` permissions in order to install IHaskell dependencies. The script is readable and easy to inspect if you wish to know what it does before giving it root permissions.
#### Mac OS X:
On Mac OS X, clone the repository and then run the `macos-install.sh` script:
## Mac
These haven't been tested and there may be some missing required packages. But
they will be soon.
```bash
git clone http://www.github.com/gibiansky/IHaskell
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install python3
brew install zeromq
curl -sSL https://get.haskellstack.org/ | sh
git clone https://github.com/abarbu/IHaskell
cd IHaskell
./macos-install.sh
```
Note that you must have [Homebrew](http://brew.sh/) installed for this script to work.
### Installing Manually
#### Install IPython
Install IPython 3.0 or above:
```bash
pip install ipython[all]
```
This may require root permissions on some systems, in which case put a `sudo` before that command before running it.
Once this is done, running `ipython --version` should print out `3.0` or above.
Note that IHaskell *requires* 3.0 or above; IHaskell *will not work* with IPython 2 or earlier.
#### Install Haskell
You can let [Stack](http://www.stackage.org/) take care of everything by running `stack setup` from within the IHaskell folder. Stack can also be used to build IHaskell later and will manage dependencies better than cabal (like in issue #578).
Or you can install GHC and Cabal manually. You must have appropriate versions of both:
```bash
ghc --numeric-version # Should be 7.6.* or 7.8.* or 7.10.*
cabal --version # Should be 1.18.* or newer
```
GHC and Cabal may be installed in a number of other ways, including the [Haskell Platform](http://www.haskell.org/platform/), as a [standalone Mac app](https://github.com/ghcformacosx/ghc-dot-app), via Homebrew with `brew install ghc cabal-install`, and so on.
#### Install ZeroMQ
Install ZeroMQ, a library IHaskell uses for asynchronous communication.
- **Mac OS X**:
- With [Homebrew](http://brew.sh/) installed, run `brew install zeromq`. (If using 32-bit Haskell Platform, you *may* need to use `brew install zeromq --universal`. YMMV.)
- With [MacPorts](https://www.macports.org/) installed, run `ports install zmq`
- **Ubuntu**: Run `sudo apt-get install libzmq3-dev`.
- **Other**: You can install ZeroMQ from source or use another package manager:
```bash
# Compiling from source:
git clone git@github.com:zeromq/zeromq4-x.git libzmq
cd libzmq
./autogen.sh && ./configure && make
sudo make install
sudo ldconfig
```
If your own platform has a package and I haven't included instructions for it, feel free to send me an email or a PR on this README.
#### Install Haskell Tools
*(This section can be skipped when using stack)*
First, make sure that executables installed by `cabal` are on your shell `PATH`:
```bash
# If you have a ~/.cabal/bin folder:
export PATH=~/.cabal/bin:$PATH
# If you have a ~/Library/Haskell/bin folder on OS X:
export PATH=~/Library/Haskell/bin:$PATH
stack install gtk2hs-buildtools
stack install --fast
stack exec ihaskell -- install
```
Then, install the `happy` parser generator tool and `cpphs` preprocessor:
```bash
cabal install happy cpphs
```
#### Build IHaskell
Install IHaskell! You may install it from Stackage via `stack install` (check the latest version on [http://www.stackage.org/lts]:
```bash
stack install ihaskell
```
Or you may install it from Hackage via `cabal install`:
```bash
cabal install ihaskell --reorder-goals
```
As IHaskell updates frequently, you may also want to clone the repository and install from there:
```bash
git clone http://www.github.com/gibiansky/IHaskell
cd IHaskell
./build.sh ihaskell # Build and install IHaskell
```
The build script, `build.sh`, is a script for building IHaskell and dependencies. It has the following modes:
- `ihaskell`: Build and install `ihaskell` and the two dependencies from this repository, `ipython-kernel` and `ghc-parser`.
- `quick`: Just install `ihaskell`, do not bother recompiling and reinstalling its dependencies (`ipython-kernel` and `ghc-parser`).
- `display`: Install `ihaskell` and all the support libraries in `ihaskell-display/`.
- `all`: Install everything, including `ihaskell`, the dependencies, and all the support libraries in `ihaskell-display/`.
It is run via `./build.sh all` or equivalent.
IHaskell may also be built in a sandbox, via something like:
```bash
cd IHaskell
cabal sandbox init
cabal sandbox add-source ihaskell-display/* ghc-parser ipython-kernel
cabal install . ihaskell-display/*
```
You may also need to use `--extra-lib-dirs` and `--extra-include-dirs`, if
`cabal` cannot find relevant libraries. For example:
```bash
cabal install . ihaskell-display/* --extra-lib-dirs=`brew --prefix libmagic`/lib --extra-include-dirs=`brew --prefix libmagic`/include
```
You can also build IHaskell with [stack](https://github.com/commercialhaskell/stack) instead of cabal:
```bash
cd IHaskell
stack install
```
The above will install `ihaskell`, all support libraries (specified in `stack.yaml`), and their dependencies. You can also specify which libraries to install, for example:
```bash
stack install ihaskell ihaskell-aeson ihaskell-diagrams
```
Mac OS X users using MacPorts may run into an [issue involving libiconv](http://blog.omega-prime.co.uk/?p=96). A solution is to add the following lines in the file stack.yaml:
```
extra-lib-dirs:
- /usr/lib
extra-include-dirs:
- /usr/include
```
#### Run IHaskell
Run IHaskell:
- `ihaskell install` to install the IHaskell kernel into Jupyter.
- `ipython notebook` for the browser-based interactive notebook.
- `ipython console --kernel haskell` for a REPL.
If you've installed IHaskell in a sandbox, you will need to make sure that IPython can access the contents of the sandbox. You can do this via `cabal exec`:
```bash
cabal exec ipython -- notebook
```
Likewise, if you've installed IHaskell with `stack`:
```bash
stack exec ipython -- notebook
```
#### (Optional) Install Support Libraries
IHaskell comes with many support libraries, such as `ihaskell-diagrams`, `ihaskell-parsec`, and so on, which add rich and interactive displays for common libraries.
You can install these with `cabal install`. To install all of them, clone this repository and run `./build.sh all` to install IHaskell and all of its display support libraries.
You may run into some issues with installing the `cairo` dependency on Macs. To fix this, you can install `gcc` via `brew` and then use it to install `cairo`:
```bash
brew install gcc49
cabal install cairo --with-gcc=gcc-4.9
```
### Gotchas
These are simply some problems have had and solutions to them.
**Problem**: You have Anaconda or Enthought or some other python distribution, and for unknown reasons IHaskell just hangs after the first input.
**Solution**: Anaconda and Enthought cause problems. Get rid of them.
**Problem**: You get an error when `pyzmq` is compiling that looks somewhat like
```
cc1: error: -Werror=unused-command-line-argument-hard-error-in-future: No option -Wunused-command-line-argument-hard-error-in-future
```
**Solution:** Rerun the command after changing the `ARCHFLAGS` variable via
```bash
export ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
```
**Problem**: You'd like to have IHaskell run some code every time it starts up, like `~/.ghci` or `~/.bashrc`.
**Solution**: IHaskell uses `~/.ihaskell/rc.hs` as its default configuration file; if you put code into that file (it may or may not exist), it will be loaded on startup. You can substitute a different file by passing the `--conf=myfile.hs` argument to `ihaskell install` to reconfigure the kernel.
**Note**: You may have some trouble due to browser caches with the notebook interface if you also use IPython's notebook interface or have used it in the past. If something doesn't work or IPython says it can't connect to the notebook server, make sure to clear the browser cache in whatever browser you're using, or try another browser.
# Contributing
IHaskell is a young project, and I'd love your help getting it to a stable and useful point. There's a lot to do, and if you'd like to contribute, feel free to get in touch with me via my email at andrew period gibiansky at gmail - although browsing the code should be enough to get you started, I'm more than happy to answer any questions myself.
**For package maintainers:** IHaskell has an ability to display data types it knows about with a rich format based on images or HTML. In order to do so, an external package `ihaskell-something` must be created and installed. Writing these packages is simply - they must just contain instance of the `IHaskellDisplay` typeclass, defined in `IHaskell.Display`, and for a package `ihaskell-something` should have a single module `IHaskell.Display.Something`. If you have a package with interesting data types that would benefit from a rich display format, please get in contact with me (andrew dot gibiansky at gmail) to write one of these packages! A sample package is available [here](https://github.com/gibiansky/IHaskell/tree/master/ihaskell-display/ihaskell-basic).
# Developer Notes
Before diving in, you should read the [brief description of IPython kernel architectures](http://andrew.gibiansky.com/blog/ipython/ipython-kernels/)
and read the [complete messaging protocol specification](http://ipython.org/ipython-doc/dev/development/messaging.html).
Please format your code with `hindent --style gibiansky` before submitting it; Travis CI automatically checks for code style before merging!
**Loading IHaskell into GHCi for testing:**
Use one of the methods below to access IHaskell files in GHCi. Once inside GHCi, you can load an IHaskell file; for example, `:load IHaskell/Config.hs`.
**Using cabal repl**
If you have the latest version of cabal (>v1.18.0), the simplest thing to do is
# Running
```bash
cd <path-to-IHaskell>
cabal repl
stack exec jupyter -- notebook
```
This will hide all packages not listed in `IHaskell.cabal`
## Where are my packages?
**Using GHCi directly**
Stack manages separate environments for every package. By default your notebooks
will only have access to a few packages that happen to be required for
ihaskell. To make packages available add them to the stack.yaml in the ihaskell
directory and run `stack solver && stack install`.
If you don't want to use `cabal repl`, you can just call ghci which can read the `.ghci` file included in the repository for the options.
```bash
cd <path-to-IHaskell>
chmod 600 .ghci # trust the .ghci file
ghci
```
Then in the ghci session you can type things like:
Packages should be added to the `packages:` section and can take the following
form
([reproduced here from the stack documentation](https://github.com/commercialhaskell/stack/blob/master/doc/yaml_configuration.md#packages)). If
you've already installed a package by `stack install` you can simply list its
name even if it's local.
```
:set -package setenv
:load src/Hspec.hs
hspec parserTests
:browse IHaskell.Types
- package-name
- location: .
- location: dir1/dir2
- location: https://example.com/foo/bar/baz-0.0.2.tar.gz
- location: http://github.com/yesodweb/wai/archive/2f8a8e1b771829f4a8a77c0111352ce45a14c30f.zip
- location:
git: git@github.com:commercialhaskell/stack.git
commit: 6a86ee32e5b869a877151f74064572225e1a0398
- location:
hg: https://example.com/hg/repo
commit: da39a3ee5e6b4b0d3255bfef95601890afd80709
```

24
circle.yml Normal file
View File

@ -0,0 +1,24 @@
dependencies:
cache_directories:
- ~/.stack
- .stack-work
- ~/.cache/pip
pre:
- rm -rf /opt/circleci/.pyenv
- sudo apt-get install -y python3-pip git libtinfo-dev libzmq3-dev libcairo2-dev libpango1.0-dev
- sudo pip3 install pip --upgrade
- sudo pip3 install -r requirements.txt
- curl -sSL https://get.haskellstack.org/ | sh
override:
- stack setup
- |
echo "apply-ghc-options: everything" >> stack.yaml
- stack install gtk2hs-buildtools --fast
- stack build --fast
- stack install --fast
- stack exec ihaskell -- install
- stack test --no-run-tests --fast
test:
override:
- stack test --fast

View File

@ -33,8 +33,8 @@ library
Language.Haskell.GHC.HappyParser
-- other-modules:
-- other-extensions:
build-depends: base >=4.6 && <4.9,
ghc >=7.6 && <7.11
build-depends: base >=4.6,
ghc >=7.6 && <8.1
if impl(ghc >= 7.6) && impl(ghc < 7.8)
hs-source-dirs: generic-src src-7.6
@ -45,6 +45,9 @@ library
if impl(ghc < 7.10)
hs-source-dirs: generic-src src-7.8.3
else
hs-source-dirs: generic-src src-7.10
if impl(ghc < 8.0)
hs-source-dirs: generic-src src-7.10
else
hs-source-dirs: generic-src src-8.0
default-language: Haskell2010

View File

@ -26667,8 +26667,11 @@ hintMultiWayIf span = do
{-# LINE 1 "templates/GenericTemplate.hs" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
{-# LINE 1 "<built-in>" #-}
{-# LINE 16 "<built-in>" #-}
{-# LINE 1 "/Users/silver/.stack/programs/x86_64-osx/ghc-7.10.3/lib/ghc-7.10.3/include/ghcversion.h" #-}
{-# LINE 1 "<command-line>" #-}
{-# LINE 8 "<command-line>" #-}
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 17 "/usr/include/stdc-predef.h" 3 4
@ -26687,14 +26690,207 @@ hintMultiWayIf span = do
{-# LINE 17 "<built-in>" #-}
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "/home/andrei/.stack/programs/x86_64-linux/ghc-8.0.2/lib/ghc-8.0.2/include/ghcversion.h" #-}
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "/tmp/ghc2743_0/ghc_2.h" #-}
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
-- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
{-# LINE 13 "templates/GenericTemplate.hs" #-}
{-# LINE 46 "templates/GenericTemplate.hs" #-}
@ -26704,20 +26900,11 @@ hintMultiWayIf span = do
{-# LINE 67 "templates/GenericTemplate.hs" #-}
{-# LINE 77 "templates/GenericTemplate.hs" #-}
{-# LINE 86 "templates/GenericTemplate.hs" #-}
infixr 9 `HappyStk`
data HappyStk a = HappyStk a (HappyStk a)
@ -26741,7 +26928,6 @@ happyAccept j tk st sts (HappyStk ans _) =
-----------------------------------------------------------------------------
-- Arrays only: do the next action
{-# LINE 155 "templates/GenericTemplate.hs" #-}
-----------------------------------------------------------------------------
@ -26836,14 +27022,7 @@ happyDropStk n (x `HappyStk` xs) = happyDropStk (n - ((1)::Int)) xs
-----------------------------------------------------------------------------
-- Moving to a new state after a reduction
{-# LINE 256 "templates/GenericTemplate.hs" #-}
happyGoto action j tk st = action j j tk (HappyState action)
@ -26902,14 +27081,7 @@ happyDontSeq a b = b
-- of deciding to inline happyGoto everywhere, which increases the size of
-- the generated parser quite a bit.
{-# LINE 322 "templates/GenericTemplate.hs" #-}
{-# NOINLINE happyShift #-}
{-# NOINLINE happySpecReduce_0 #-}
{-# NOINLINE happySpecReduce_1 #-}
@ -26921,4 +27093,3 @@ happyDontSeq a b = b
{-# NOINLINE happyFail #-}
-- end of Happy Template.

View File

@ -29391,8 +29391,11 @@ hintExplicitForall span = do
{-# LINE 1 "templates/GenericTemplate.hs" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
{-# LINE 1 "<built-in>" #-}
{-# LINE 16 "<built-in>" #-}
{-# LINE 1 "/Users/silver/.stack/programs/x86_64-osx/ghc-7.10.3/lib/ghc-7.10.3/include/ghcversion.h" #-}
{-# LINE 1 "<command-line>" #-}
{-# LINE 8 "<command-line>" #-}
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 17 "/usr/include/stdc-predef.h" 3 4
@ -29411,14 +29414,207 @@ hintExplicitForall span = do
{-# LINE 17 "<built-in>" #-}
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "/home/andrei/.stack/programs/x86_64-linux/ghc-8.0.2/lib/ghc-8.0.2/include/ghcversion.h" #-}
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "/tmp/ghc2743_0/ghc_2.h" #-}
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
-- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
{-# LINE 13 "templates/GenericTemplate.hs" #-}
{-# LINE 46 "templates/GenericTemplate.hs" #-}
@ -29428,20 +29624,11 @@ hintExplicitForall span = do
{-# LINE 67 "templates/GenericTemplate.hs" #-}
{-# LINE 77 "templates/GenericTemplate.hs" #-}
{-# LINE 86 "templates/GenericTemplate.hs" #-}
infixr 9 `HappyStk`
data HappyStk a = HappyStk a (HappyStk a)
@ -29465,7 +29652,6 @@ happyAccept j tk st sts (HappyStk ans _) =
-----------------------------------------------------------------------------
-- Arrays only: do the next action
{-# LINE 155 "templates/GenericTemplate.hs" #-}
-----------------------------------------------------------------------------
@ -29560,14 +29746,7 @@ happyDropStk n (x `HappyStk` xs) = happyDropStk (n - ((1)::Int)) xs
-----------------------------------------------------------------------------
-- Moving to a new state after a reduction
{-# LINE 256 "templates/GenericTemplate.hs" #-}
happyGoto action j tk st = action j j tk (HappyState action)
@ -29626,14 +29805,7 @@ happyDontSeq a b = b
-- of deciding to inline happyGoto everywhere, which increases the size of
-- the generated parser quite a bit.
{-# LINE 322 "templates/GenericTemplate.hs" #-}
{-# NOINLINE happyShift #-}
{-# NOINLINE happySpecReduce_0 #-}
{-# NOINLINE happySpecReduce_1 #-}
@ -29645,4 +29817,3 @@ happyDontSeq a b = b
{-# NOINLINE happyFail #-}
-- end of Happy Template.

View File

@ -29391,8 +29391,11 @@ hintExplicitForall span = do
{-# LINE 1 "templates/GenericTemplate.hs" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
{-# LINE 1 "<built-in>" #-}
{-# LINE 16 "<built-in>" #-}
{-# LINE 1 "/Users/silver/.stack/programs/x86_64-osx/ghc-7.10.3/lib/ghc-7.10.3/include/ghcversion.h" #-}
{-# LINE 1 "<command-line>" #-}
{-# LINE 8 "<command-line>" #-}
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 17 "/usr/include/stdc-predef.h" 3 4
@ -29411,14 +29414,207 @@ hintExplicitForall span = do
{-# LINE 17 "<built-in>" #-}
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "/home/andrei/.stack/programs/x86_64-linux/ghc-8.0.2/lib/ghc-8.0.2/include/ghcversion.h" #-}
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "/tmp/ghc2743_0/ghc_2.h" #-}
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
-- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
{-# LINE 13 "templates/GenericTemplate.hs" #-}
{-# LINE 46 "templates/GenericTemplate.hs" #-}
@ -29428,20 +29624,11 @@ hintExplicitForall span = do
{-# LINE 67 "templates/GenericTemplate.hs" #-}
{-# LINE 77 "templates/GenericTemplate.hs" #-}
{-# LINE 86 "templates/GenericTemplate.hs" #-}
infixr 9 `HappyStk`
data HappyStk a = HappyStk a (HappyStk a)
@ -29465,7 +29652,6 @@ happyAccept j tk st sts (HappyStk ans _) =
-----------------------------------------------------------------------------
-- Arrays only: do the next action
{-# LINE 155 "templates/GenericTemplate.hs" #-}
-----------------------------------------------------------------------------
@ -29560,14 +29746,7 @@ happyDropStk n (x `HappyStk` xs) = happyDropStk (n - ((1)::Int)) xs
-----------------------------------------------------------------------------
-- Moving to a new state after a reduction
{-# LINE 256 "templates/GenericTemplate.hs" #-}
happyGoto action j tk st = action j j tk (HappyState action)
@ -29626,14 +29805,7 @@ happyDontSeq a b = b
-- of deciding to inline happyGoto everywhere, which increases the size of
-- the generated parser quite a bit.
{-# LINE 322 "templates/GenericTemplate.hs" #-}
{-# NOINLINE happyShift #-}
{-# NOINLINE happySpecReduce_0 #-}
{-# NOINLINE happySpecReduce_1 #-}
@ -29645,4 +29817,3 @@ happyDontSeq a b = b
{-# NOINLINE happyFail #-}
-- end of Happy Template.

View File

@ -0,0 +1,42 @@
module Language.Haskell.GHC.HappyParser
( fullStatement
, fullImport
, fullDeclaration
, fullExpression
, fullTypeSignature
, fullModule
) where
import Parser
import SrcLoc
-- compiler/hsSyn
import HsSyn
-- compiler/utils
import OrdList
-- compiler/parser
import RdrHsSyn
import Lexer
-- compiler/basicTypes
import RdrName
fullStatement :: P (Maybe (LStmt RdrName (LHsExpr RdrName)))
fullStatement = parseStmt
fullImport :: P (LImportDecl RdrName)
fullImport = parseImport
fullDeclaration :: P (OrdList (LHsDecl RdrName))
fullDeclaration = fmap unitOL parseDeclaration
fullExpression :: P (LHsExpr RdrName)
fullExpression = parseExpression
fullTypeSignature :: P (Located (OrdList (LHsDecl RdrName)))
fullTypeSignature = fmap (noLoc . unitOL) parseTypeSignature
fullModule :: P (Located (HsModule RdrName))
fullModule = parseModule

View File

@ -51,13 +51,9 @@ library
-- Modules included in this library but not exported.
-- other-modules:
-- Language extensions.
default-extensions: DoAndIfThenElse
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base >=4.6 && <4.9,
build-depends: base >=4.6 && <4.10,
here,
text,
bytestring,

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -55,13 +55,9 @@ library
-- Modules included in this library but not exported.
-- other-modules:
-- Language extensions.
default-extensions: DoAndIfThenElse
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base >=4.6 && <4.9,
build-depends: base >=4.6,
blaze-html >= 0.6,
blaze-markup >= 0.5,
ihaskell >= 0.5

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -52,13 +52,9 @@ library
-- Modules included in this library but not exported.
-- other-modules:
-- Language extensions.
default-extensions: DoAndIfThenElse
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base >=4.6 && <4.9,
build-depends: base >=4.6,
bytestring,
data-default-class,
directory,

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -53,12 +53,8 @@ library
-- Modules included in this library but not exported.
other-modules: IHaskell.Display.Diagrams.Animation
-- Language extensions.
default-extensions: DoAndIfThenElse
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base >=4.6 && <4.9,
build-depends: base >=4.6 && <4.10,
text,
bytestring,
directory,

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -52,13 +52,9 @@ library
-- Modules included in this library but not exported.
-- other-modules:
-- Language extensions.
default-extensions: DoAndIfThenElse
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base >=4.6 && <4.9,
build-depends: base >=4.6 && <4.10,
bytestring,
gnuplot >= 0.5.4,
ihaskell >= 0.6.2

View File

@ -1,8 +1,5 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
extra-deps:
- 'gnuplot-0.5.4'
- data-accessor-transformers-0.2.1.7
resolver: lts-8.12
extra-deps: []

View File

@ -14,7 +14,7 @@ cabal-version: >=1.16
library
exposed-modules: IHaskell.Display.Hatex
build-depends: base >=4.6 && <4.9,
build-depends: base >=4.6 && <4.10,
text,
HaTeX >= 3.9,
ihaskell >= 0.5

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -58,13 +58,9 @@ library
-- Modules included in this library but not exported.
-- other-modules:
-- Language extensions.
default-extensions: DoAndIfThenElse
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base >=4.6 && <4.9,
build-depends: base >=4.6,
bytestring,
directory,
JuicyPixels >= 3.1.3,

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -55,13 +55,9 @@ library
-- Modules included in this library but not exported.
-- other-modules:
-- Language extensions.
default-extensions: DoAndIfThenElse
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base >=4.6 && <4.9,
build-depends: base >=4.6 && <4.10,
magic >= 1.0.8,
text,
bytestring,

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -52,13 +52,9 @@ library
-- Modules included in this library but not exported.
-- other-modules:
-- Language extensions.
default-extensions: DoAndIfThenElse
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base >=4.6 && <4.9,
build-depends: base >=4.6,
plot,
bytestring,
hmatrix >= 0.10,

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -14,15 +14,15 @@ library
other-extensions: TupleSections, TemplateHaskell
build-depends: base <5,
Rlang-QQ >= 0.3,
directory >=1.2 && <1.3,
filepath >=1.3 && <1.5,
bytestring >=0.10 && <0.11,
base64-bytestring >=1.0 && <1.1,
directory >=1.2,
filepath >=1.3,
bytestring >=0.10,
base64-bytestring >=1.0,
ihaskell >= 0.6.2,
ihaskell-blaze >=0.3 && <0.4,
blaze-html >=0.6 && <0.9,
split >=0.2 && <0.3,
ihaskell-blaze >=0.3,
blaze-html >=0.6,
split >=0.2,
stm -any,
xformat >=0.1 && <0.2,
xformat >=0.1,
template-haskell >= 2.8
default-language: Haskell2010

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -60,10 +60,10 @@ library
-- other-extensions:
-- Other library packages from which modules are imported.
build-depends: base >=4.7 && <4.9,
ihaskell >= 0.5,
static-canvas >= 0.2,
text >= 1.2
build-depends: base >=4.7,
ihaskell,
static-canvas,
text
-- Directories containing source files.
hs-source-dirs: src

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -57,9 +57,6 @@ library
-- Modules included in this library but not exported.
other-modules: IHaskell.Display.Widgets.Button
IHaskell.Display.Widgets.Box.Box
IHaskell.Display.Widgets.Box.Proxy
IHaskell.Display.Widgets.Box.PlaceProxy
IHaskell.Display.Widgets.Box.FlexBox
IHaskell.Display.Widgets.Box.SelectionContainer.Accordion
IHaskell.Display.Widgets.Box.SelectionContainer.Tab
IHaskell.Display.Widgets.Bool.CheckBox
@ -83,7 +80,7 @@ library
IHaskell.Display.Widgets.Selection.ToggleButtons
IHaskell.Display.Widgets.Selection.SelectMultiple
IHaskell.Display.Widgets.String.HTML
IHaskell.Display.Widgets.String.Latex
IHaskell.Display.Widgets.String.Label
IHaskell.Display.Widgets.String.Text
IHaskell.Display.Widgets.String.TextArea
@ -96,8 +93,8 @@ library
-- Other library packages from which modules are imported.
-- singletons 2.* require ghc 7.10.2
build-depends: aeson >=0.7 && < 0.12
, base >=4.7 && <4.9
build-depends: aeson >=0.7
, base >=4.7
, containers >= 0.5
, ipython-kernel >= 0.6.1.2
, text >= 0.11

View File

@ -3,9 +3,6 @@ module IHaskell.Display.Widgets (module X) where
import IHaskell.Display.Widgets.Button as X
import IHaskell.Display.Widgets.Box.Box as X
import IHaskell.Display.Widgets.Box.Proxy as X
import IHaskell.Display.Widgets.Box.PlaceProxy as X
import IHaskell.Display.Widgets.Box.FlexBox as X
import IHaskell.Display.Widgets.Box.SelectionContainer.Accordion as X
import IHaskell.Display.Widgets.Box.SelectionContainer.Tab as X
@ -36,7 +33,7 @@ import IHaskell.Display.Widgets.Selection.ToggleButtons as X
import IHaskell.Display.Widgets.Selection.SelectMultiple as X
import IHaskell.Display.Widgets.String.HTML as X
import IHaskell.Display.Widgets.String.Latex as X
import IHaskell.Display.Widgets.String.Label as X
import IHaskell.Display.Widgets.String.Text as X
import IHaskell.Display.Widgets.String.TextArea as X

View File

@ -33,7 +33,7 @@ mkCheckBox = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultBoolWidget "CheckboxView"
let widgetState = WidgetState $ defaultBoolWidget "CheckboxView" "CheckboxModel"
stateIO <- newIORef widgetState

View File

@ -34,7 +34,7 @@ mkToggleButton = do
-- Default properties, with a random uuid
uuid <- U.random
let boolState = defaultBoolWidget "ToggleButtonView"
let boolState = defaultBoolWidget "ToggleButtonView" "ToggleButtonModel"
toggleState = (Tooltip =:: "")
:& (Icon =:: "")
:& (ButtonStyle =:: DefaultButton)

View File

@ -32,7 +32,7 @@ mkValidWidget = do
-- Default properties, with a random uuid
uuid <- U.random
let boolState = defaultBoolWidget "ValidView"
let boolState = defaultBoolWidget "ValidView" "ValidModel"
validState = (ReadOutMsg =:: "") :& RNil
widgetState = WidgetState $ boolState <+> validState

View File

@ -30,7 +30,7 @@ mkBox = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultBoxWidget "BoxView"
let widgetState = WidgetState $ defaultBoxWidget "BoxView" "BoxModel"
stateIO <- newIORef widgetState

View File

@ -1,59 +0,0 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Box.FlexBox (
-- * The FlexBox widget
FlexBox,
-- * Constructor
mkFlexBox) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
import Data.Aeson
import Data.IORef (newIORef)
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | A 'FlexBox' represents a FlexBox widget from IPython.html.widgets.
type FlexBox = IPythonWidget FlexBoxType
-- | Create a new box
mkFlexBox :: IO FlexBox
mkFlexBox = do
-- Default properties, with a random uuid
uuid <- U.random
let boxAttrs = defaultBoxWidget "FlexBoxView"
flxAttrs = (Orientation =:: HorizontalOrientation)
:& (Flex =:: 0)
:& (Pack =:: StartLocation)
:& (Align =:: StartLocation)
:& RNil
widgetState = WidgetState $ boxAttrs <+> flxAttrs
stateIO <- newIORef widgetState
let box = IPythonWidget uuid stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen box $ toJSON widgetState
-- Return the widget
return box
instance IHaskellDisplay FlexBox where
display b = do
widgetSendView b
return $ Display []
instance IHaskellWidget FlexBox where
getCommUUID = uuid

View File

@ -1,57 +0,0 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Box.PlaceProxy (
-- * The PlaceProxy widget
PlaceProxy,
-- * Constructor
mkPlaceProxy) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
import Data.Aeson
import Data.IORef (newIORef)
import Data.Vinyl (Rec(..), (<+>))
import Data.Vinyl.Lens (rput)
import IHaskell.Display
import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | A 'Box' represents a Box widget from IPython.html.widgets.
type PlaceProxy = IPythonWidget PlaceProxyType
-- | Create a new box
mkPlaceProxy :: IO PlaceProxy
mkPlaceProxy = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetClassState = defaultWidget "PlaceProxyView"
baseState = rput (ModelName =:: "ProxyModel") widgetClassState
proxyState = (Child =:: Nothing) :& (Selector =:: "") :& RNil
widgetState = WidgetState $ baseState <+> proxyState
stateIO <- newIORef widgetState
let widget = IPythonWidget uuid stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget $ toJSON widgetState
-- Return the widget
return widget
instance IHaskellDisplay PlaceProxy where
display b = do
widgetSendView b
return $ Display []
instance IHaskellWidget PlaceProxy where
getCommUUID = uuid

View File

@ -1,57 +0,0 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Box.Proxy (
-- * The Proxy widget
ProxyWidget,
-- * Constructor
mkProxyWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
import Data.Aeson
import Data.IORef (newIORef)
import Data.Vinyl (Rec(..), (<+>))
import Data.Vinyl.Lens (rput)
import IHaskell.Display
import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | A 'Box' represents a Box widget from IPython.html.widgets.
type ProxyWidget = IPythonWidget ProxyType
-- | Create a new box
mkProxyWidget :: IO ProxyWidget
mkProxyWidget = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetClassState = defaultWidget "ProxyView"
baseState = rput (ModelName =:: "ProxyModel") widgetClassState
proxyState = (Child =:: Nothing) :& RNil
widgetState = WidgetState $ baseState <+> proxyState
stateIO <- newIORef widgetState
let proxy = IPythonWidget uuid stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen proxy $ toJSON widgetState
-- Return the widget
return proxy
instance IHaskellDisplay ProxyWidget where
display b = do
widgetSendView b
return $ Display []
instance IHaskellWidget ProxyWidget where
getCommUUID = uuid

View File

@ -34,7 +34,7 @@ mkAccordion = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultSelectionContainerWidget "AccordionView"
let widgetState = WidgetState $ defaultSelectionContainerWidget "AccordionView" "AccordionModel"
stateIO <- newIORef widgetState

View File

@ -34,7 +34,7 @@ mkTabWidget = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultSelectionContainerWidget "TabView"
let widgetState = WidgetState $ defaultSelectionContainerWidget "TabView" "TabModel"
stateIO <- newIORef widgetState

View File

@ -35,7 +35,7 @@ mkButton = do
-- Default properties, with a random uuid
uuid <- U.random
let dom = defaultDOMWidget "ButtonView"
let dom = defaultDOMWidget "ButtonView" "ButtonModel"
but = (Description =:: "")
:& (Tooltip =:: "")
:& (Disabled =:: False)

View File

@ -35,7 +35,7 @@ mkBoundedFloatText = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultBoundedFloatWidget "FloatTextView"
let widgetState = WidgetState $ defaultBoundedFloatWidget "FloatTextView" "FloatTextModel"
stateIO <- newIORef widgetState

View File

@ -32,7 +32,7 @@ mkFloatProgress = do
-- Default properties, with a random uuid
uuid <- U.random
let boundedFloatAttrs = defaultBoundedFloatWidget "ProgressView"
let boundedFloatAttrs = defaultBoundedFloatWidget "ProgressView" "ProgressModel"
progressAttrs = (Orientation =:: HorizontalOrientation)
:& (BarStyle =:: DefaultBar)
:& RNil

View File

@ -35,7 +35,7 @@ mkFloatSlider = do
-- Default properties, with a random uuid
uuid <- U.random
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatSliderView"
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatSliderView" "FloatSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: False)
:& (ReadOut =:: True)

View File

@ -37,7 +37,7 @@ mkFloatRangeSlider = do
-- Default properties, with a random uuid
uuid <- U.random
let boundedFloatAttrs = defaultBoundedFloatRangeWidget "FloatSliderView"
let boundedFloatAttrs = defaultBoundedFloatRangeWidget "FloatSliderView" "FloatSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: True)
:& (ReadOut =:: True)

View File

@ -34,7 +34,7 @@ mkFloatText = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultFloatWidget "FloatTextView"
let widgetState = WidgetState $ defaultFloatWidget "FloatTextView" "FloatTextModel"
stateIO <- newIORef widgetState

View File

@ -33,7 +33,7 @@ mkImageWidget = do
-- Default properties, with a random uuid
uuid <- U.random
let dom = defaultDOMWidget "ImageView"
let dom = defaultDOMWidget "ImageView" "ImageModel"
img = (ImageFormat =:: PNG)
:& (Width =:+ 0)
:& (Height =:+ 0)

View File

@ -34,7 +34,7 @@ mkBoundedIntText = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultBoundedIntWidget "IntTextView"
let widgetState = WidgetState $ defaultBoundedIntWidget "IntTextView" "IntTextModel"
stateIO <- newIORef widgetState

View File

@ -32,7 +32,7 @@ mkIntProgress = do
-- Default properties, with a random uuid
uuid <- U.random
let boundedIntAttrs = defaultBoundedIntWidget "ProgressView"
let boundedIntAttrs = defaultBoundedIntWidget "ProgressView" "ProgressModel"
progressAttrs = (Orientation =:: HorizontalOrientation)
:& (BarStyle =:: DefaultBar)
:& RNil

View File

@ -35,7 +35,7 @@ mkIntSlider = do
-- Default properties, with a random uuid
uuid <- U.random
let boundedIntAttrs = defaultBoundedIntWidget "IntSliderView"
let boundedIntAttrs = defaultBoundedIntWidget "IntSliderView" "IntSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: False)
:& (ReadOut =:: True)

View File

@ -36,7 +36,7 @@ mkIntRangeSlider = do
-- Default properties, with a random uuid
uuid <- U.random
let boundedIntAttrs = defaultBoundedIntRangeWidget "IntSliderView"
let boundedIntAttrs = defaultBoundedIntRangeWidget "IntSliderView" "IntSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: True)
:& (ReadOut =:: True)

View File

@ -34,7 +34,7 @@ mkIntText = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultIntWidget "IntTextView"
let widgetState = WidgetState $ defaultIntWidget "IntTextView" "IntTextModel"
stateIO <- newIORef widgetState

View File

@ -5,6 +5,7 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE PolyKinds #-}
module IHaskell.Display.Widgets.Interactive (interactive, uncurryHList, Rec(..), Argument(..)) where
@ -24,7 +25,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
import qualified IHaskell.Display.Widgets.Singletons as S (SField, Field(..))
import IHaskell.Display.Widgets.Box.FlexBox
import IHaskell.Display.Widgets.Box.Box
import IHaskell.Display.Widgets.Bool.CheckBox
import IHaskell.Display.Widgets.String.Text
import IHaskell.Display.Widgets.Int.BoundedInt.IntSlider
@ -119,23 +120,23 @@ instance (FromWidget t, MakeConfs ts) => MakeConfs (t ': ts) where
mkConfs _ = WidgetConf wrapped :& mkConfs (Proxy :: Proxy ts)
interactive :: (IHaskellDisplay r, MakeConfs ts)
=> (HList ts -> r) -> Rec Argument ts -> IO FlexBox
=> (HList ts -> r) -> Rec Argument ts -> IO Box
interactive func =
let confs = mkConfs Proxy
in liftToWidgets func confs
-- | Transform a function (HList ts -> r) to one which: 1) Uses widgets to accept the arguments 2)
-- Accepts initial values for the arguments 3) Creates a compound FlexBox widget with an embedded
-- Accepts initial values for the arguments 3) Creates a compound Box widget with an embedded
-- OutputWidget for display
liftToWidgets :: IHaskellDisplay r
=> (HList ts -> r) -> Rec WidgetConf ts -> Rec Argument ts -> IO FlexBox
=> (HList ts -> r) -> Rec WidgetConf ts -> Rec Argument ts -> IO Box
liftToWidgets func rc initvals = do
let constructors = rmap extractConstructor rc
getters = rmap extractGetter rc
eventSetters = rmap extractEventSetter rc
initializers = rmap extractInitializer rc
bx <- mkFlexBox
bx <- mkBox
out <- mkOutputWidget
-- Create a list of widgets
@ -152,9 +153,11 @@ liftToWidgets func rc initvals = do
setInitialValues initializers widgets initvals
-- applyValueSetters valueSetters widgets $ getList defvals
setField out Width 500
setField bx Orientation VerticalOrientation
-- TODO This can't be set right now since we switched FlexBox to a regular
-- Box. This is a styling/layout parameter now but these haven't been implemented yet.
-- setField bx Orientation VerticalOrientation
-- Set children for the FlexBox
-- Set children for the Box
let children = mkChildren widgets
setField bx Children $ children ++ [ChildWidget out]

View File

@ -36,7 +36,7 @@ mkOutputWidget = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultDOMWidget "OutputView"
let widgetState = WidgetState $ defaultDOMWidget "OutputView" "OutputModel"
stateIO <- newIORef widgetState

View File

@ -34,7 +34,7 @@ mkDropdown :: IO Dropdown
mkDropdown = do
-- Default properties, with a random uuid
uuid <- U.random
let selectionAttrs = defaultSelectionWidget "DropdownView"
let selectionAttrs = defaultSelectionWidget "DropdownView" "DropdownModel"
dropdownAttrs = (ButtonStyle =:: DefaultButton) :& RNil
widgetState = WidgetState $ selectionAttrs <+> dropdownAttrs

View File

@ -33,7 +33,7 @@ mkRadioButtons :: IO RadioButtons
mkRadioButtons = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultSelectionWidget "RadioButtonsView"
let widgetState = WidgetState $ defaultSelectionWidget "RadioButtonsView" "RadioButtonsModel"
stateIO <- newIORef widgetState

View File

@ -34,7 +34,7 @@ mkSelect :: IO Select
mkSelect = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultSelectionWidget "SelectView"
let widgetState = WidgetState $ defaultSelectionWidget "SelectView" "SelectModel"
stateIO <- newIORef widgetState

View File

@ -34,7 +34,7 @@ mkSelectMultiple :: IO SelectMultiple
mkSelectMultiple = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultMultipleSelectionWidget "SelectMultipleView"
let widgetState = WidgetState $ defaultMultipleSelectionWidget "SelectMultipleView" "SelectMultipleModel"
stateIO <- newIORef widgetState

View File

@ -34,7 +34,7 @@ mkToggleButtons :: IO ToggleButtons
mkToggleButtons = do
-- Default properties, with a random uuid
uuid <- U.random
let selectionAttrs = defaultSelectionWidget "ToggleButtonsView"
let selectionAttrs = defaultSelectionWidget "ToggleButtonsView" "ToggleButtonsModel"
toggleButtonsAttrs = (Tooltips =:: [])
:& (Icons =:: [])
:& (ButtonStyle =:: DefaultButton)

View File

@ -29,7 +29,7 @@ mkHTMLWidget :: IO HTMLWidget
mkHTMLWidget = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultStringWidget "HTMLView"
let widgetState = WidgetState $ defaultStringWidget "HTMLView" "HTMLModel"
stateIO <- newIORef widgetState

View File

@ -3,11 +3,11 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.String.Latex (
-- * The Latex Widget
LatexWidget,
module IHaskell.Display.Widgets.String.Label (
-- * The Label Widget
LabelWidget,
-- * Constructor
mkLatexWidget) where
mkLabelWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
@ -21,15 +21,15 @@ import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
-- | A 'LatexWidget' represents a Latex widget from IPython.html.widgets.
type LatexWidget = IPythonWidget LatexType
-- | A 'LabelWidget' represents a Label widget from IPython.html.widgets.
type LabelWidget = IPythonWidget LabelType
-- | Create a new Latex widget
mkLatexWidget :: IO LatexWidget
mkLatexWidget = do
-- | Create a new Label widget
mkLabelWidget :: IO LabelWidget
mkLabelWidget = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetState = WidgetState $ defaultStringWidget "LatexView"
let widgetState = WidgetState $ defaultStringWidget "LabelView" "LabelModel"
stateIO <- newIORef widgetState
@ -41,10 +41,10 @@ mkLatexWidget = do
-- Return the widget
return widget
instance IHaskellDisplay LatexWidget where
instance IHaskellDisplay LabelWidget where
display b = do
widgetSendView b
return $ Display []
instance IHaskellWidget LatexWidget where
instance IHaskellWidget LabelWidget where
getCommUUID = uuid

View File

@ -33,7 +33,7 @@ mkTextWidget :: IO TextWidget
mkTextWidget = do
-- Default properties, with a random uuid
uuid <- U.random
let strWidget = defaultStringWidget "TextView"
let strWidget = defaultStringWidget "TextView" "TextModel"
txtWidget = (SubmitHandler =:: return ()) :& (ChangeHandler =:: return ()) :& RNil
widgetState = WidgetState $ strWidget <+> txtWidget

View File

@ -33,7 +33,7 @@ mkTextArea :: IO TextArea
mkTextArea = do
-- Default properties, with a random uuid
uuid <- U.random
let strAttrs = defaultStringWidget "TextareaView"
let strAttrs = defaultStringWidget "TextareaView" "TextareaModel"
wgtAttrs = (ChangeHandler =:: return ()) :& RNil
widgetState = WidgetState $ strAttrs <+> wgtAttrs

View File

@ -241,7 +241,7 @@ data WidgetType = ButtonType
| ImageType
| OutputType
| HTMLType
| LatexType
| LabelType
| TextType
| TextAreaType
| CheckBoxType
@ -263,9 +263,6 @@ data WidgetType = ButtonType
| FloatProgressType
| FloatRangeSliderType
| BoxType
| ProxyType
| PlaceProxyType
| FlexBoxType
| AccordionType
| TabType
@ -280,7 +277,7 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
DOMWidgetClass :++ '[S.ImageFormat, S.Width, S.Height, S.B64Value]
WidgetFields OutputType = DOMWidgetClass
WidgetFields HTMLType = StringClass
WidgetFields LatexType = StringClass
WidgetFields LabelType = StringClass
WidgetFields TextType =
StringClass :++ '[S.SubmitHandler, S.ChangeHandler]
WidgetFields TextAreaType = StringClass :++ '[S.ChangeHandler]
@ -315,11 +312,6 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
BoundedFloatRangeClass :++
'[S.Orientation, S.ShowRange, S.ReadOut, S.SliderColor]
WidgetFields BoxType = BoxClass
WidgetFields ProxyType = WidgetClass :++ '[S.Child]
WidgetFields PlaceProxyType =
WidgetFields ProxyType :++ '[S.Selector]
WidgetFields FlexBoxType =
BoxClass :++ '[S.Orientation, S.Flex, S.Pack, S.Align]
WidgetFields AccordionType = SelectionContainerClass
WidgetFields TabType = SelectionContainerClass
@ -619,23 +611,23 @@ s =:+ val = Attr
(reflect s)
-- | Get a field from a singleton Adapted from: http://stackoverflow.com/a/28033250/2388535
reflect :: forall (f :: Field). (SingI f, SingKind ('KProxy :: KProxy Field)) => Sing f -> Field
reflect :: forall (f :: Field). (SingI f) => Sing f -> Field
reflect = fromSing
-- | A record representing an object of the Widget class from IPython
defaultWidget :: FieldType S.ViewName -> Rec Attr WidgetClass
defaultWidget viewName = (ViewModule =:: "")
:& (ViewName =:: viewName)
:& (ModelModule =:: "")
:& (ModelName =:: "WidgetModel")
:& (MsgThrottle =:+ 3)
:& (Version =:: 0)
:& (DisplayHandler =:: return ())
:& RNil
defaultWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr WidgetClass
defaultWidget viewName modelName = (ViewModule =:: "jupyter-js-widgets")
:& (ViewName =:: viewName)
:& (ModelModule =:: "jupyter-js-widgets")
:& (ModelName =:: modelName)
:& (MsgThrottle =:+ 3)
:& (Version =:: 0)
:& (DisplayHandler =:: return ())
:& RNil
-- | A record representing an object of the DOMWidget class from IPython
defaultDOMWidget :: FieldType S.ViewName -> Rec Attr DOMWidgetClass
defaultDOMWidget viewName = defaultWidget viewName <+> domAttrs
defaultDOMWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr DOMWidgetClass
defaultDOMWidget viewName modelName = defaultWidget viewName modelName <+> domAttrs
where
domAttrs = (Visible =:: True)
:& (CSS =:: [])
@ -657,8 +649,8 @@ defaultDOMWidget viewName = defaultWidget viewName <+> domAttrs
:& RNil
-- | A record representing a widget of the _String class from IPython
defaultStringWidget :: FieldType S.ViewName -> Rec Attr StringClass
defaultStringWidget viewName = defaultDOMWidget viewName <+> strAttrs
defaultStringWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr StringClass
defaultStringWidget viewName modelName = defaultDOMWidget viewName modelName <+> strAttrs
where
strAttrs = (StringValue =:: "")
:& (Disabled =:: False)
@ -667,8 +659,8 @@ defaultStringWidget viewName = defaultDOMWidget viewName <+> strAttrs
:& RNil
-- | A record representing a widget of the _Bool class from IPython
defaultBoolWidget :: FieldType S.ViewName -> Rec Attr BoolClass
defaultBoolWidget viewName = defaultDOMWidget viewName <+> boolAttrs
defaultBoolWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoolClass
defaultBoolWidget viewName modelName = defaultDOMWidget viewName modelName <+> boolAttrs
where
boolAttrs = (BoolValue =:: False)
:& (Disabled =:: False)
@ -677,8 +669,8 @@ defaultBoolWidget viewName = defaultDOMWidget viewName <+> boolAttrs
:& RNil
-- | A record representing a widget of the _Selection class from IPython
defaultSelectionWidget :: FieldType S.ViewName -> Rec Attr SelectionClass
defaultSelectionWidget viewName = defaultDOMWidget viewName <+> selectionAttrs
defaultSelectionWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr SelectionClass
defaultSelectionWidget viewName modelName = defaultDOMWidget viewName modelName <+> selectionAttrs
where
selectionAttrs = (Options =:: OptionLabels [])
:& (SelectedValue =:: "")
@ -689,8 +681,8 @@ defaultSelectionWidget viewName = defaultDOMWidget viewName <+> selectionAttrs
:& RNil
-- | A record representing a widget of the _MultipleSelection class from IPython
defaultMultipleSelectionWidget :: FieldType S.ViewName -> Rec Attr MultipleSelectionClass
defaultMultipleSelectionWidget viewName = defaultDOMWidget viewName <+> mulSelAttrs
defaultMultipleSelectionWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr MultipleSelectionClass
defaultMultipleSelectionWidget viewName modelName = defaultDOMWidget viewName modelName <+> mulSelAttrs
where
mulSelAttrs = (Options =:: OptionLabels [])
:& (SelectedValues =:: [])
@ -701,8 +693,8 @@ defaultMultipleSelectionWidget viewName = defaultDOMWidget viewName <+> mulSelAt
:& RNil
-- | A record representing a widget of the _Int class from IPython
defaultIntWidget :: FieldType S.ViewName -> Rec Attr IntClass
defaultIntWidget viewName = defaultDOMWidget viewName <+> intAttrs
defaultIntWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr IntClass
defaultIntWidget viewName modelName = defaultDOMWidget viewName modelName <+> intAttrs
where
intAttrs = (IntValue =:: 0)
:& (Disabled =:: False)
@ -711,8 +703,8 @@ defaultIntWidget viewName = defaultDOMWidget viewName <+> intAttrs
:& RNil
-- | A record representing a widget of the _BoundedInt class from IPython
defaultBoundedIntWidget :: FieldType S.ViewName -> Rec Attr BoundedIntClass
defaultBoundedIntWidget viewName = defaultIntWidget viewName <+> boundedIntAttrs
defaultBoundedIntWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoundedIntClass
defaultBoundedIntWidget viewName modelName = defaultIntWidget viewName modelName <+> boundedIntAttrs
where
boundedIntAttrs = (StepInt =:: 1)
:& (MinInt =:: 0)
@ -720,8 +712,8 @@ defaultBoundedIntWidget viewName = defaultIntWidget viewName <+> boundedIntAttrs
:& RNil
-- | A record representing a widget of the _BoundedInt class from IPython
defaultIntRangeWidget :: FieldType S.ViewName -> Rec Attr IntRangeClass
defaultIntRangeWidget viewName = defaultIntWidget viewName <+> rangeAttrs
defaultIntRangeWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr IntRangeClass
defaultIntRangeWidget viewName modelName = defaultIntWidget viewName modelName <+> rangeAttrs
where
rangeAttrs = (IntPairValue =:: (25, 75))
:& (LowerInt =:: 0)
@ -729,8 +721,8 @@ defaultIntRangeWidget viewName = defaultIntWidget viewName <+> rangeAttrs
:& RNil
-- | A record representing a widget of the _BoundedIntRange class from IPython
defaultBoundedIntRangeWidget :: FieldType S.ViewName -> Rec Attr BoundedIntRangeClass
defaultBoundedIntRangeWidget viewName = defaultIntRangeWidget viewName <+> boundedIntRangeAttrs
defaultBoundedIntRangeWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoundedIntRangeClass
defaultBoundedIntRangeWidget viewName modelName = defaultIntRangeWidget viewName modelName <+> boundedIntRangeAttrs
where
boundedIntRangeAttrs = (StepInt =:+ 1)
:& (MinInt =:: 0)
@ -738,8 +730,8 @@ defaultBoundedIntRangeWidget viewName = defaultIntRangeWidget viewName <+> bound
:& RNil
-- | A record representing a widget of the _Float class from IPython
defaultFloatWidget :: FieldType S.ViewName -> Rec Attr FloatClass
defaultFloatWidget viewName = defaultDOMWidget viewName <+> intAttrs
defaultFloatWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr FloatClass
defaultFloatWidget viewName modelName = defaultDOMWidget viewName modelName <+> intAttrs
where
intAttrs = (FloatValue =:: 0)
:& (Disabled =:: False)
@ -748,8 +740,8 @@ defaultFloatWidget viewName = defaultDOMWidget viewName <+> intAttrs
:& RNil
-- | A record representing a widget of the _BoundedFloat class from IPython
defaultBoundedFloatWidget :: FieldType S.ViewName -> Rec Attr BoundedFloatClass
defaultBoundedFloatWidget viewName = defaultFloatWidget viewName <+> boundedFloatAttrs
defaultBoundedFloatWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoundedFloatClass
defaultBoundedFloatWidget viewName modelName = defaultFloatWidget viewName modelName <+> boundedFloatAttrs
where
boundedFloatAttrs = (StepFloat =:+ 1)
:& (MinFloat =:: 0)
@ -757,8 +749,8 @@ defaultBoundedFloatWidget viewName = defaultFloatWidget viewName <+> boundedFloa
:& RNil
-- | A record representing a widget of the _BoundedFloat class from IPython
defaultFloatRangeWidget :: FieldType S.ViewName -> Rec Attr FloatRangeClass
defaultFloatRangeWidget viewName = defaultFloatWidget viewName <+> rangeAttrs
defaultFloatRangeWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr FloatRangeClass
defaultFloatRangeWidget viewName modelName = defaultFloatWidget viewName modelName <+> rangeAttrs
where
rangeAttrs = (FloatPairValue =:: (25, 75))
:& (LowerFloat =:: 0)
@ -766,8 +758,8 @@ defaultFloatRangeWidget viewName = defaultFloatWidget viewName <+> rangeAttrs
:& RNil
-- | A record representing a widget of the _BoundedFloatRange class from IPython
defaultBoundedFloatRangeWidget :: FieldType S.ViewName -> Rec Attr BoundedFloatRangeClass
defaultBoundedFloatRangeWidget viewName = defaultFloatRangeWidget viewName <+> boundedFloatRangeAttrs
defaultBoundedFloatRangeWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoundedFloatRangeClass
defaultBoundedFloatRangeWidget viewName modelName = defaultFloatRangeWidget viewName modelName <+> boundedFloatRangeAttrs
where
boundedFloatRangeAttrs = (StepFloat =:+ 1)
:& (MinFloat =:: 0)
@ -775,20 +767,18 @@ defaultBoundedFloatRangeWidget viewName = defaultFloatRangeWidget viewName <+> b
:& RNil
-- | A record representing a widget of the _Box class from IPython
defaultBoxWidget :: FieldType S.ViewName -> Rec Attr BoxClass
defaultBoxWidget viewName = domAttrs <+> boxAttrs
defaultBoxWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoxClass
defaultBoxWidget viewName modelName = defaultDOMWidget viewName modelName <+> intAttrs
where
defaultDOM = defaultDOMWidget viewName
domAttrs = rput (ModelName =:: "BoxModel") defaultDOM
boxAttrs = (Children =:: [])
intAttrs = (Children =:: [])
:& (OverflowX =:: DefaultOverflow)
:& (OverflowY =:: DefaultOverflow)
:& (BoxStyle =:: DefaultBox)
:& RNil
-- | A record representing a widget of the _SelectionContainer class from IPython
defaultSelectionContainerWidget :: FieldType S.ViewName -> Rec Attr SelectionContainerClass
defaultSelectionContainerWidget viewName = defaultBoxWidget viewName <+> selAttrs
defaultSelectionContainerWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr SelectionContainerClass
defaultSelectionContainerWidget viewName modelName = defaultBoxWidget viewName modelName <+> selAttrs
where
selAttrs = (Titles =:: [])
:& (SelectedIndex =:: 0)

View File

@ -1,4 +1,4 @@
flags: {}
packages:
- '.'
resolver: lts-6.2
resolver: lts-8.12

View File

@ -54,8 +54,8 @@ library
hs-source-dirs: src
default-language: Haskell2010
build-depends:
aeson >=0.7 && < 0.12,
base >=4.6 && < 4.9,
aeson >=1.0,
base >=4.6,
base64-bytestring >=1.0,
bytestring >=0.10,
cereal >=0.3,
@ -63,14 +63,14 @@ library
containers >=0.5,
directory -any,
filepath -any,
ghc >=7.6 || < 7.11,
ghc >=7.6,
ghc-parser >=0.1.7,
ghc-paths ==0.1.*,
ghc-paths >=0.1,
haskeline -any,
hlint >=1.9 && <2.0,
haskell-src-exts >=1.16 && < 1.18,
http-client == 0.4.*,
http-client-tls == 0.2.*,
hlint >=1.9,
haskell-src-exts >=1.16,
http-client >= 0.4,
http-client-tls >= 0.2,
mtl >=2.1,
parsec -any,
process >=1.1,
@ -91,6 +91,9 @@ library
if flag(binPkgDb)
build-depends: bin-package-db
if impl(ghc >= 8.0)
build-depends: ghc-boot >=8.0 && <8.1
exposed-modules: IHaskell.Display
IHaskell.Convert
IHaskell.Convert.Args
@ -118,12 +121,6 @@ library
IHaskellPrelude
StringUtils
default-extensions:
NoImplicitPrelude
DoAndIfThenElse
OverloadedStrings
ExtendedDefaultRules
executable ihaskell
-- .hs or .lhs file containing the Main module.
main-is: Main.hs
@ -137,12 +134,12 @@ executable ihaskell
default-language: Haskell2010
build-depends:
ihaskell -any,
base >=4.6 && < 4.9,
base >=4.6 && < 4.10,
text >=0.11,
transformers -any,
ghc >=7.6 || < 7.11,
process >=1.1,
aeson >=0.7 && < 0.12,
aeson >=0.7,
bytestring >=0.10,
containers >=0.5,
strict >=0.3,
@ -153,12 +150,6 @@ executable ihaskell
if flag(binPkgDb)
build-depends: bin-package-db
default-extensions:
NoImplicitPrelude
DoAndIfThenElse
OverloadedStrings
ExtendedDefaultRules
Test-Suite hspec
Type: exitcode-stdio-1.0
Ghc-Options: -threaded
@ -188,11 +179,6 @@ Test-Suite hspec
if flag(binPkgDb)
build-depends: bin-package-db
default-extensions:
DoAndIfThenElse
OverloadedStrings
ExtendedDefaultRules
source-repository head
type: git
location: git://github.com/gibiansky/IHaskell.git

View File

@ -34,34 +34,34 @@ library
other-extensions: OverloadedStrings
hs-source-dirs: src
default-language: Haskell2010
build-depends: base >=4.6 && < 4.9,
aeson >=0.6 && < 0.12,
bytestring >=0.10,
cereal >=0.3,
containers >=0.5,
directory >=1.1,
temporary >=1.2,
filepath >=1.2,
process >=1.1,
mtl >=2.1,
text >=0.11,
transformers >=0.3,
unordered-containers >= 0.2.5,
uuid >=1.3,
zeromq4-haskell >=0.1,
SHA >=1.6
build-depends: base ,
aeson ,
bytestring ,
cereal ,
containers ,
directory ,
temporary ,
filepath ,
process ,
mtl ,
text ,
transformers ,
unordered-containers,
uuid ,
zeromq4-haskell ,
SHA
-- Example program
executable simple-calc-example
hs-source-dirs: examples
main-is: Calc.hs
build-depends: ipython-kernel,
base >=4.6 && <4.9,
filepath >=1.2,
mtl >=2.1,
parsec >=3.1,
text >=0.11,
transformers >=0.3
base ,
filepath ,
mtl ,
parsec ,
text ,
transformers
if !flag(examples)
buildable: False
@ -70,12 +70,12 @@ executable fun-calc-example
hs-source-dirs: examples
main-is: Simple.hs
build-depends: ipython-kernel,
base >=4.6 && <4.9,
filepath >=1.2,
mtl >=2.1,
parsec >=3.1,
text >=0.11,
transformers >=0.3
base ,
filepath ,
mtl ,
parsec ,
text ,
transformers
if !flag(examples)
buildable: False

View File

@ -1,4 +1,4 @@
{-# LANGUAGE CPP #-}
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}{-# LANGUAGE CPP #-}
module IHaskellPrelude (
module IHaskellPrelude,
module X,
@ -78,7 +78,9 @@ import GHC.Enum as X
import GHC.Num as X
import GHC.Real as X
import GHC.Err as X hiding (absentErr)
#if MIN_VERSION_ghc(7,10,0)
#if MIN_VERSION_ghc(8,0,0)
import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>), Module(..))
#elif MIN_VERSION_ghc(7,10,0)
import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>))
#else
import GHC.Base as X hiding (Any)

View File

@ -1,3 +1,4 @@
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}
{-# LANGUAGE CPP, ScopedTypeVariables #-}
-- | Description : Argument parsing and basic messaging loop, using Haskell
@ -128,7 +129,8 @@ runKernel kernelOpts profileSrc = do
useStack = kernelSpecUseStack kernelOpts
-- Parse the profile file.
Just profile <- liftM decode $ LBS.readFile profileSrc
let profileErr = error $ "ihaskell: "++profileSrc++": Failed to parse profile file"
profile <- liftM (fromMaybe profileErr . decode) $ LBS.readFile profileSrc
-- Necessary for `getLine` and their ilk to work.
dir <- getIHaskellDir

File diff suppressed because one or more lines are too long

8
requirements.txt Normal file
View File

@ -0,0 +1,8 @@
jupyter==1.0.0
jupyter_nbextensions_configurator
jupyter_contrib_nbextensions
ipykernel
ipywidgets==6.0.0
jupyter-client==5.0.0
jupyter-console==5.1.0
jupyter-core==4.3.0

View File

@ -22,7 +22,7 @@ import qualified Data.ByteString.Char8 as CBS
import Control.Applicative ((<$>))
import Data.ByteString.UTF8 hiding (drop, take, lines, length)
import Data.Char
import Data.List (nub, init, last, head, elemIndex)
import Data.List (nub, init, last, head, elemIndex, concatMap)
import qualified Data.List.Split as Split
import qualified Data.List.Split.Internals as Split
import Data.Maybe (fromJust)
@ -88,7 +88,11 @@ complete code posOffset = do
let Just db = pkgDatabase flags
getNames = map (moduleNameString . exposedName) . exposedModules
#if MIN_VERSION_ghc(8,0,0)
moduleNames = nub $ concatMap getNames $ concatMap snd db
#else
moduleNames = nub $ concatMap getNames db
#endif
let target = completionTarget line pos
completion = completionType line pos target
@ -124,7 +128,11 @@ complete code posOffset = do
otherNames = ["-package", "-Wall", "-w"]
fNames = map extName fFlags ++
#if MIN_VERSION_ghc(8,0,0)
map extName wWarningFlags ++
#else
map extName fWarningFlags ++
#endif
map extName fLangFlags
fNoNames = map ("no" ++) fNames
fAllNames = map ("-f" ++) (fNames ++ fNoNames)

View File

@ -26,6 +26,7 @@ import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString.Char8 as CBS
import Control.Concurrent (forkIO, threadDelay)
import Data.Foldable (foldMap)
import Prelude (putChar, head, tail, last, init, (!!))
import Data.List (findIndex, and, foldl1, nubBy)
import Text.Printf
@ -77,7 +78,7 @@ import Module hiding (Module)
import qualified Pretty
import FastString
import Bag
import ErrUtils (errMsgShortDoc, errMsgExtraInfo)
import qualified ErrUtils
import IHaskell.Types
import IHaskell.IPython
@ -178,19 +179,35 @@ interpret libdir allowedStdin action = runGhc (Just libdir) $ do
dir <- liftIO getIHaskellDir
let cmd = printf "IHaskell.IPython.Stdin.fixStdin \"%s\"" dir
when (allowedStdin && hasSupportLibraries) $ void $
runStmt cmd RunToCompletion
execStmt cmd execOptions
initializeItVariable
-- Run the rest of the interpreter
action hasSupportLibraries
#if MIN_VERSION_ghc(7,10,2)
packageIdString' dflags pkg_key = fromMaybe "(unknown)" (packageKeyPackageIdString dflags pkg_key)
packageIdString' :: DynFlags -> PackageConfig -> String
packageIdString' dflags pkg_cfg =
#if MIN_VERSION_ghc(8,0,0)
fromMaybe "(unknown)" (unitIdPackageIdString dflags $ packageConfigId pkg_cfg)
#elif MIN_VERSION_ghc(7,10,2)
fromMaybe "(unknown)" (packageKeyPackageIdString dflags $ packageConfigId pkg_cfg)
#elif MIN_VERSION_ghc(7,10,0)
packageIdString' dflags = packageKeyPackageIdString dflags
packageKeyPackageIdString dflags . packageConfigId
#else
packageIdString' dflags = packageIdString
packageIdString . packageConfigId
#endif
getPackageConfigs :: DynFlags -> [PackageConfig]
getPackageConfigs dflags =
#if MIN_VERSION_ghc(8,0,0)
foldMap snd pkgDb
#else
pkgDb
#endif
where
Just pkgDb = pkgDatabase dflags
-- | Initialize our GHC session with imports and a value for 'it'. Return whether the IHaskell
-- support libraries are available.
initializeImports :: Interpreter Bool
@ -200,25 +217,29 @@ initializeImports = do
dflags <- getSessionDynFlags
broken <- liftIO getBrokenPackages
(dflags, _) <- liftIO $ initPackages dflags
let Just db = pkgDatabase dflags
packageNames = map (packageIdString' dflags . packageConfigId) db
let db = getPackageConfigs dflags
packageNames = map (packageIdString' dflags) db
initStr = "ihaskell-"
-- Name of the ihaskell package, e.g. "ihaskell-1.2.3.4"
iHaskellPkgName = initStr ++ intercalate "." (map show (versionBranch version))
#if !MIN_VERSION_ghc(8,0,0)
unitId = packageId
#endif
dependsOnRight pkg = not $ null $ do
pkg <- db
depId <- depends pkg
dep <- filter ((== depId) . installedPackageId) db
let idString = packageIdString' dflags (packageConfigId dep)
dep <- filter ((== depId) . unitId) db
let idString = packageIdString' dflags dep
guard (iHaskellPkgName `isPrefixOf` idString)
displayPkgs = [ pkgName
| pkgName <- packageNames
, Just (x:_) <- [stripPrefix initStr pkgName]
, pkgName `notElem` broken
| pkgName <- packageNames
, Just (x:_) <- [stripPrefix initStr pkgName]
, pkgName `notElem` broken
, isAlpha x ]
hasIHaskellPackage = not $ null $ filter (== iHaskellPkgName) packageNames
@ -258,7 +279,7 @@ initializeItVariable :: Interpreter ()
initializeItVariable =
-- This is required due to the way we handle `it` in the wrapper statements - if it doesn't exist,
-- the first statement will fail.
void $ runStmt "let it = ()" RunToCompletion
void $ execStmt "let it = ()" execOptions
-- | Publisher for IHaskell outputs. The first argument indicates whether this output is final
-- (true) or intermediate (false).
@ -282,7 +303,7 @@ cleanString x = if allBrackets
str = strip x
l = lines str
allBrackets = all (fAny [isPrefixOf ">", null]) l
fAny fs x = any ($x) fs
fAny fs x = any ($ x) fs
clean = unlines $ map removeBracket l
removeBracket ('>':xs) = xs
removeBracket [] = []
@ -411,6 +432,14 @@ flushWidgetMessages state evalMsgs widgetHandler = do
let commMessages = evalMsgs ++ messages
widgetHandler state commMessages
getErrMsgDoc :: ErrUtils.ErrMsg -> SDoc
#if MIN_VERSION_ghc(8,0,0)
getErrMsgDoc = ErrUtils.pprLocErrMsg
#else
getErrMsgDoc msg = ErrUtils.errMsgShortString msg $$ ErrUtils.errMsgContext msg
#endif
safely :: KernelState -> Interpreter EvalOut -> Interpreter EvalOut
safely state = ghandle handler . ghandle sourceErrorHandler
where
@ -428,10 +457,7 @@ safely state = ghandle handler . ghandle sourceErrorHandler
sourceErrorHandler :: SourceError -> Interpreter EvalOut
sourceErrorHandler srcerr = do
let msgs = bagToList $ srcErrorMessages srcerr
errStrs <- forM msgs $ \msg -> do
shortStr <- doc $ errMsgShortDoc msg
contextStr <- doc $ errMsgExtraInfo msg
return $ unlines [shortStr, contextStr]
errStrs <- forM msgs $ doc . getErrMsgDoc
let fullErr = unlines errStrs
@ -489,7 +515,7 @@ evalCommand _ (Module contents) state = wrapExecution state $ do
-- Remember which modules we've loaded before.
importedModules <- getContext
let
let
-- Get the dot-delimited pieces of the module name.
moduleNameOf :: InteractiveImport -> [String]
moduleNameOf (IIDecl decl) = split "." . moduleNameString . unLoc . ideclName $ decl
@ -668,7 +694,7 @@ evalCommand publish (Directive ShellCmd ('!':cmd)) state = wrapExecution state $
let cmd = printf "IHaskellDirectory.setCurrentDirectory \"%s\"" $
replace " " "\\ " $
replace "\"" "\\\"" directory
runStmt cmd RunToCompletion
execStmt cmd execOptions
return mempty
else return $ displayError $ printf "No such directory: '%s'" directory
cmd -> liftIO $ do
@ -685,7 +711,7 @@ evalCommand publish (Directive ShellCmd ('!':cmd)) state = wrapExecution state $
outputAccum <- liftIO $ newMVar ""
-- Start a loop to publish intermediate results.
let
let
-- Compute how long to wait between reading pieces of the output. `threadDelay` takes an
-- argument of microseconds.
ms = 1000
@ -730,7 +756,7 @@ evalCommand publish (Directive ShellCmd ('!':cmd)) state = wrapExecution state $
]
loop
where
where
#if MIN_VERSION_base(4,8,0)
createPipe' = createPipe
#else
@ -826,7 +852,7 @@ evalCommand output (Expression expr) state = do
let widgetExpr = printf "(IHaskell.Display.Widget (%s))" expr :: String
isWidget <- attempt $ exprType widgetExpr
-- Check if this is a template haskell declaration
-- Check if this is a template haskell declaration
let declExpr = printf "((id :: IHaskellTH.DecsQ -> IHaskellTH.DecsQ) (%s))" expr :: String
let anyExpr = printf "((id :: IHaskellPrelude.Int -> IHaskellPrelude.Int) (%s))" expr :: String
isTHDeclaration <- liftM2 (&&) (attempt $ exprType declExpr) (not <$> attempt (exprType anyExpr))
@ -836,7 +862,7 @@ evalCommand output (Expression expr) state = do
write state $ "Is Declaration: " ++ show isTHDeclaration
if isTHDeclaration
then
then
-- If it typechecks as a DecsQ, we do not want to display the DecsQ, we just want the
-- declaration made.
do
@ -851,7 +877,7 @@ evalCommand output (Expression expr) state = do
, evalMsgs = []
}
else if canRunDisplay
then
then
-- Use the display. As a result, `it` is set to the output.
useDisplay displayExpr
else do
@ -1027,7 +1053,11 @@ doLoadModule name modName = do
setSessionDynFlags
flags
{ hscTarget = objTarget flags
#if MIN_VERSION_ghc(8,0,0)
, log_action = \dflags sev srcspan ppr _style msg -> modifyIORef' errRef (showSDoc flags msg :)
#else
, log_action = \dflags sev srcspan ppr msg -> modifyIORef' errRef (showSDoc flags msg :)
#endif
}
-- Load the new target.
@ -1089,7 +1119,7 @@ keepingItVariable act = do
gen <- liftIO getStdGen
let rand = take 20 $ randomRs ('0', '9') gen
var name = name ++ rand
goStmt s = runStmt s RunToCompletion
goStmt s = execStmt s execOptions
itVariable = var "it_var_temp_"
goStmt $ printf "let %s = it" itVariable
@ -1102,12 +1132,12 @@ data Captured a = CapturedStmt String
capturedEval :: (String -> IO ()) -- ^ Function used to publish intermediate output.
-> Captured a -- ^ Statement to evaluate.
-> Interpreter (String, RunResult) -- ^ Return the output and result.
-> Interpreter (String, ExecResult) -- ^ Return the output and result.
capturedEval output stmt = do
-- Generate random variable names to use so that we cannot accidentally override the variables by
-- using the right names in the terminal.
gen <- liftIO getStdGen
let
let
-- Variable names generation.
rand = take 20 $ randomRs ('0', '9') gen
var name = name ++ rand
@ -1142,43 +1172,57 @@ capturedEval output stmt = do
, voidpf "IHaskellIO.closeFd %s" writeVariable
, printf "let it = %s" itVariable
]
pipeExpr = printf "let %s = %s" (var "pipe_var_") readVariable
goStmt :: String -> Ghc RunResult
goStmt s = runStmt s RunToCompletion
goStmt :: String -> Ghc ExecResult
goStmt s = execStmt s execOptions
runWithResult (CapturedStmt str) = goStmt str
runWithResult (CapturedIO io) = do
status <- gcatch (liftIO io >> return NoException) (return . AnyException)
return $
case status of
NoException -> RunOk []
AnyException e -> RunException e
NoException -> ExecComplete (Right []) 0
AnyException e -> ExecComplete (Left e) 0
-- Initialize evaluation context.
void $ forM initStmts goStmt
results <- forM initStmts goStmt
#if __GLASGOW_HASKELL__ >= 800
-- This works fine on GHC 8.0 and newer
dyn <- dynCompileExpr readVariable
pipe <- case fromDynamic dyn of
Nothing -> fail "Evaluate: Bad pipe"
Just fd -> liftIO $ do
handle <- fdToHandle fd
hSetEncoding handle utf8
return handle
#else
-- Get the pipe to read printed output from. This is effectively the source code of dynCompileExpr
-- from GHC API's InteractiveEval. However, instead of using a `Dynamic` as an intermediary, it just
-- directly reads the value. This is incredibly unsafe! However, for some reason the `getContext`
-- and `setContext` required by dynCompileExpr (to import and clear Data.Dynamic) cause issues with
-- data declarations being updated (e.g. it drops newer versions of data declarations for older ones
-- for unknown reasons). First, compile down to an HValue.
let pipeExpr = printf "let %s = %s" (var "pipe_var_") readVariable
Just (_, hValues, _) <- withSession $ liftIO . flip hscStmt pipeExpr
-- Then convert the HValue into an executable bit, and read the value.
pipe <- liftIO $ do
fd <- head <$> unsafeCoerce hValues
fds <- unsafeCoerce hValues
fd <- case fds of
fd : _ -> return fd
[] -> fail "Failed to evaluate pipes"
_ -> fail $ "Expected one fd, saw "++show (length fds)
handle <- fdToHandle fd
hSetEncoding handle utf8
return handle
#endif
-- Keep track of whether execution has completed.
completed <- liftIO $ newMVar False
finishedReading <- liftIO newEmptyMVar
outputAccum <- liftIO $ newMVar ""
-- Start a loop to publish intermediate results.
let
let
-- Compute how long to wait between reading pieces of the output. `threadDelay` takes an
-- argument of microseconds.
ms = 1000
@ -1251,7 +1295,7 @@ evalStatementOrIO publish state cmd = do
(printed, result) <- capturedEval output cmd
case result of
RunOk names -> do
ExecComplete (Right names) _ -> do
dflags <- getSessionDynFlags
let allNames = map (showPpr dflags) names
@ -1283,8 +1327,8 @@ evalStatementOrIO publish state cmd = do
-- Return plain and html versions. Previously there was only a plain version.
text -> Display [plain $ joined ++ "\n" ++ text, html $ htmled ++ mono text]
RunException exception -> throw exception
RunBreak{} -> error "Should not break."
ExecComplete (Left exception) _ -> throw exception
ExecBreak{} -> error "Should not break."
-- Read from a file handle until we hit a delimiter or until we've read as many characters as
-- requested
@ -1324,7 +1368,7 @@ formatErrorWithClass cls =
typeCleaner
where
fixDollarSigns = replace "$" "<span>&dollar;</span>"
useDashV = "\nUse -v to see a list of the files searched for."
useDashV = "\n Use -v to see a list of the files searched for."
isShowError err =
"No instance for (Show" `isPrefixOf` err &&
isInfixOf " arising from a use of `print'" err

View File

@ -37,10 +37,12 @@ data HoogleResult = SearchResult HoogleResponse
| NoResult String
deriving Show
instance FromJSON [HoogleResponse] where
data HoogleResponseList = HoogleResponseList [HoogleResponse]
instance FromJSON HoogleResponseList where
parseJSON (Object obj) = do
results <- obj .: "results"
mapM parseJSON results
HoogleResponseList <$> mapM parseJSON results
parseJSON _ = fail "Expected object with 'results' field."
@ -99,7 +101,7 @@ search string = do
case eitherDecode $ LBS.fromStrict $ CBS.pack json of
Left err -> [NoResult err]
Right results ->
case map SearchResult results of
case map SearchResult $ (\(HoogleResponseList l) -> l) results of
[] -> [NoResult "no matching identifiers found."]
res -> res

View File

@ -17,11 +17,11 @@ import Data.Monoid
import Data.Maybe (mapMaybe)
import System.IO.Unsafe (unsafePerformIO)
import Language.Haskell.Exts.Annotated.Syntax hiding (Module)
import qualified Language.Haskell.Exts.Annotated.Syntax as SrcExts
import Language.Haskell.Exts.Annotated (parseFileContentsWithMode)
import Language.Haskell.Exts.Annotated.Build (doE)
import Language.Haskell.Exts.Annotated hiding (Module)
import Language.Haskell.Exts.Syntax hiding (Module)
import qualified Language.Haskell.Exts.Syntax as SrcExts
import Language.Haskell.Exts (parseFileContentsWithMode)
import Language.Haskell.Exts.Build (doE)
import Language.Haskell.Exts hiding (Module)
import Language.Haskell.Exts.SrcLoc
import Language.Haskell.HLint as HLint
@ -149,7 +149,7 @@ createModule mode (Located line block) =
decl = SpliceDecl loc expr
expr :: Exp SrcSpanInfo
expr = doE loc [stmt, ret]
expr = Do loc [stmt, ret]
stmt :: Stmt SrcSpanInfo
ParseOk stmt = parseStmtWithMode mode stmtStr

View File

@ -59,6 +59,12 @@ import Data.List (nubBy)
import StringUtils (replace)
#if MIN_VERSION_ghc(8,0,1)
import GHC.LanguageExtensions
type ExtensionFlag = Extension
#endif
-- | A extension flag that can be set or unset.
data ExtFlag = SetFlag ExtensionFlag
| UnsetFlag ExtensionFlag
@ -97,10 +103,16 @@ pprDynFlags show_all dflags =
, O.text "other dynamic, non-language, flag settings:" O.$$
O.nest 2 (O.vcat (map (setting opt) others))
, O.text "warning settings:" O.$$
O.nest 2 (O.vcat (map (setting wopt) DynFlags.fWarningFlags))
O.nest 2 (O.vcat (map (setting wopt) warningFlags))
]
where
#if MIN_VERSION_ghc(8,0,0)
warningFlags = DynFlags.wWarningFlags
#else
warningFlags = DynFlags.fWarningFlags
#endif
#if MIN_VERSION_ghc(7,8,0)
opt = gopt
#else
@ -239,7 +251,11 @@ initGhci sandboxPackages = do
originalFlags <- getSessionDynFlags
let flag = flip xopt_set
unflag = flip xopt_unset
#if MIN_VERSION_ghc(8,0,0)
dflags = flag ExtendedDefaultRules . unflag MonomorphismRestriction $ originalFlags
#else
dflags = flag Opt_ExtendedDefaultRules . unflag Opt_MonomorphismRestriction $ originalFlags
#endif
pkgConfs =
case sandboxPackages of
Nothing -> extraPkgConfs originalFlags
@ -323,8 +339,13 @@ cleanUpDuplicateInstances = modifySession $ \hscEnv ->
in hscEnv { hsc_IC = ic { ic_instances = (clsInsts', famInsts) } }
where
instEq :: ClsInst -> ClsInst -> Bool
#if MIN_VERSION_ghc(7,8,0)
#if MIN_VERSION_ghc(8,0,0)
-- Only support replacing instances on GHC 7.8 and up
instEq c1 c2
| ClsInst { is_tvs = tpl_tvs, is_tys = tpl_tys, is_cls = cls } <- c1,
ClsInst { is_tys = tpl_tys', is_cls = cls' } <- c2
= cls == cls' && isJust (tcMatchTys tpl_tys tpl_tys')
#elif MIN_VERSION_ghc(7,8,0)
instEq c1 c2
| ClsInst { is_tvs = tpl_tvs, is_tys = tpl_tys, is_cls = cls } <- c1,
ClsInst { is_tys = tpl_tys', is_cls = cls' } <- c2
@ -333,6 +354,8 @@ cleanUpDuplicateInstances = modifySession $ \hscEnv ->
#else
instEq _ _ = False
#endif
-- | Get the type of an expression and convert it to a string.
getType :: GhcMonad m => String -> m String
getType expr = do

View File

@ -1,3 +1,4 @@
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}
module IHaskell.Eval.Widgets (
widgetSendOpen,
widgetSendView,

View File

@ -1,3 +1,4 @@
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}
{-# LANGUAGE NoImplicitPrelude, DeriveFunctor #-}
module IHaskell.Flags (

View File

@ -1,3 +1,4 @@
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}
{-# LANGUAGE CPP #-}
-- | Description : Shell scripting wrapper using @Shelly@ for the @notebook@, and
@ -28,7 +29,7 @@ import qualified System.FilePath as FP
import System.Directory
import System.Exit (exitFailure)
import Data.Aeson (toJSON)
import Data.Aeson.Encode (encodeToTextBuilder)
import Data.Aeson.Text (encodeToTextBuilder)
import Data.Text.Lazy.Builder (toLazyText)
import Control.Monad (mplus)
@ -76,9 +77,9 @@ ipythonCommand = do
locateIPython :: SH.Sh SH.FilePath
locateIPython = do
mbinary <- SH.which "ipython"
mbinary <- SH.which "jupyter"
case mbinary of
Nothing -> SH.errorExit "The IPython binary could not be located"
Nothing -> SH.errorExit "The Jupyter binary could not be located"
Just ipython -> return ipython
-- | Run the IPython command with any arguments. The kernel is set to IHaskell.

View File

@ -1,3 +1,4 @@
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}
module IHaskell.Publish (publishResult) where
import IHaskellPrelude

View File

@ -1,3 +1,4 @@
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ExistentialQuantification #-}
@ -66,9 +67,9 @@ class IHaskellDisplay a where
-- | Display as an interactive widget.
class IHaskellDisplay a => IHaskellWidget a where
-- | Target name for this widget. The actual input parameter should be ignored. By default evaluate
-- to "ipython.widget", which is used by IPython for its backbone widgets.
-- to "jupyter.widget", which is used by IPython for its backbone widgets.
targetName :: a -> String
targetName _ = "ipython.widget"
targetName _ = "jupyter.widget"
-- | Target module for this widget. Evaluates to an empty string by default.
targetModule :: a -> String

View File

@ -1,3 +1,4 @@
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}
{-# LANGUAGE CPP #-}
module IHaskellPrelude (
module IHaskellPrelude,
@ -78,7 +79,9 @@ import GHC.Enum as X
import GHC.Num as X
import GHC.Real as X
import GHC.Err as X hiding (absentErr)
#if MIN_VERSION_ghc(7,10,0)
#if MIN_VERSION_ghc(8,0,0)
import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>), Module(..))
#elif MIN_VERSION_ghc(7,10,0)
import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>))
#else
import GHC.Base as X hiding (Any)

View File

@ -1,3 +1,4 @@
{-# language NoImplicitPrelude, DoAndIfThenElse, OverloadedStrings, ExtendedDefaultRules #-}
{-# LANGUAGE CPP #-}
module IHaskell.Test.Completion (testCompletions) where

View File

@ -159,6 +159,6 @@ testEval =
"putStrLn \"Привет!\"" `becomes` ["Привет!"]
it "evaluates directives" $ do
":typ 3" `becomes` ["3 :: forall a. Num a => a"]
":typ 3" `becomes` ["3 :: forall t. Num t => t"]
":k Maybe" `becomes` ["Maybe :: * -> *"]
":in String" `pages` ["type String = [Char] \t-- Defined in \8216GHC.Base\8217"]

View File

@ -1,22 +0,0 @@
flags: {}
packages:
- .
- ./ipython-kernel
- ./ghc-parser
- ./ihaskell-display/ihaskell-aeson
- ./ihaskell-display/ihaskell-blaze
- ./ihaskell-display/ihaskell-charts
- ./ihaskell-display/ihaskell-diagrams
- ./ihaskell-display/ihaskell-gnuplot
- ./ihaskell-display/ihaskell-hatex
- ./ihaskell-display/ihaskell-juicypixels
- ./ihaskell-display/ihaskell-magic
- ./ihaskell-display/ihaskell-plot
- ./ihaskell-display/ihaskell-rlangqq
- ./ihaskell-display/ihaskell-static-canvas
- ./ihaskell-display/ihaskell-widgets
resolver: lts-6.2
extra-deps:
- system-argv0-0.1.1 # Necessary for LTS 2.22 (GHC 7.8)
- gnuplot-0.5.4
- data-accessor-transformers-0.2.1.7

View File

@ -1,8 +1,21 @@
flags: {}
packages:
- '.'
- './ipython-kernel'
- './ghc-parser'
resolver: lts-6.2
extra-deps:
- system-argv0-0.1.1 # Necessary for LTS 2.22 (GHC 7.8)
- .
- ./ipython-kernel
- ./ghc-parser
- ./ihaskell-display/ihaskell-aeson
- ./ihaskell-display/ihaskell-blaze
- ./ihaskell-display/ihaskell-charts
- ./ihaskell-display/ihaskell-diagrams
- ./ihaskell-display/ihaskell-gnuplot
- ./ihaskell-display/ihaskell-hatex
- ./ihaskell-display/ihaskell-juicypixels
- ./ihaskell-display/ihaskell-magic
- ./ihaskell-display/ihaskell-plot
- ./ihaskell-display/ihaskell-static-canvas
- ./ihaskell-display/ihaskell-widgets
resolver: lts-8.12
extra-deps: []
flags:
ihaskell:
binpkgdb: false