Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Evaluation and visualization of simple arithmetic expressions in Haskell.

License

NotificationsYou must be signed in to change notification settings

jonathanknowles/haskell-calculator

Repository files navigation

A simple four-function visual calculator, implemented in Haskell.

This calculator is capable of evaluating (and visualizing) arithmetic expressions such as "1+1" or "(1+2)*(3+4)".

It supports:

  • natural numbers (of arbitrary size);
  • addition, subtraction, multiplication, and division;
  • sub-expressions nested within parentheses;
  • unary negation.

Demonstration

Here's aweb-based demonstration built withGHCJS andReflex.

Implementation

The implementation includes:

Also included:

  • A simple demonstration of using aGADT to restrict the shape of a tree-based data structure (theExp type).

Building

This project supports both GHC and GHCJS.

The dependencies for GHC and GHCJS are slightly different.

Building with GHC

On Debian-based systems, first install the following dependencies:

  • libcairo-dev
  • libghc-pango-dev
  • libghc-gtk3-dev
  • libwebkitgtk-3.0-dev

Then issue the following commands:

stack setupstack build

Running the command line interface

The command line interface is built with GHC.

To run it, issue the following command:

stack exec calculator-cli

Building the web-based graphical user interface

The web interface is built with GHCJS.

First ensure that you have a recent version ofNodeJS installed. (Version 6.6.0 or later should work.)

Then run:

./build-web-gui.sh

If the build is successful, it will notify you of where you can find the build output. For example:

Open the following file with your web browser to view the graphical user interface:/path/to/haskell/calculator/.stack-work/install/x86_64-linux/lts-7.15/ghcjs-0.2.1.9007015_ghc-8.0.1/bin/calculator-gui.jsexe/index.html

Copy and paste the final line into your web browser to view the user interface.

Running the test suite

The test suite is built with GHC.

To run the suite, issue the following command:

stack test

Experimenting with the calculator library

To load the calculator library into GHCI, issue the following command:

stack ghci

About

Evaluation and visualization of simple arithmetic expressions in Haskell.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp