Giter Club home page Giter Club logo

school-of-haskell's Introduction

School of Haskell

A guided tour through BiteMyApp's comprehensive Haskell tutorial.

Installing Haskell

For those just getting started, follow these steps to install the latest version of GHC. For those using OSX, the recommend package manager is Homebrew. For those using other OS's, replace brew install with your own package manager in any following shell commands (lines prefixed by a $).

  1. Install GHC (the Haskell compiler) and Cabal (the Haskell package manager)

    $ brew install ghc cabal-install
    
  2. Add $HOME/.cabal/bin to your shell's $PATH variable

  3. Install only the Haskell modules required globally. Everything else will be installed in project-specific sandboxes.

    $ cabal update
    $ cabal install hspec
    

Enabling a great Haskell toolset (using Vim)

Part of what makes Haskell so fantastic is the tooling that can be built around a compiler that can infer so much about its programs. These instructions are for those using Vim, but similar instructions should be available for Emacs or other text editors.

  1. Install GHC-mod

    $ cabal install happy
    $ cabal install ghc-mod
    
  2. Install the GHC-mod plugin for Vim. If you are inexperienced with installing Vim plugins, I recommend using Vundle.

  1. (Optional) Add shortcut keys for the GHC-mod commands. Mine are listed below, which can be listed in your $HOME/.vimrc file.

    au FileType haskell nnoremap <buffer> <Leader>ht :GhcModType<CR>
    au FileType haskell nnoremap <buffer> <Leader>hh :GhcModTypeClear<CR>
    au FileType haskell nnoremap <buffer> <Leader>hc :GhcModCheck<CR>
    au FileType haskell nnoremap <buffer> <Leader>hl :GhcModLint<CR>

NOTE: If you've installed GHC via a package manager, you're probably using version 7.8.4 or less (which you can check via $ ghc --version. If so, you must use Cabal version 1.20.0.6 or less for ghc-mod to function properly. You may force the Cabal version via $ cabal install cabal-install-1.20.0.6.

Beginning a homework assignment

Before beginning a homework, you should:

  1. Branch this project

    $ git branch [an appropriate branch name for the homework]
    
  2. Initialize a Cabal sandbox in the current homework directory and install any required packages. For example:

    $ cd cis194/homework-1
    $ cabal sandbox init
    $ cabal install --only-dependencies --enable-tests
    $ cabal configure --enable-tests
    
  3. Run the specs to ensure they fail

    $ cabal test --show-details=always --test-options="--color"
    

You're now ready to begin replacing the undefined functions with actual function definitions. Running and passing the specs as you write functions will ensure that your later work is built upon previous correct work.

Discovering functions

Haskell doesn't come packaged with a standard library as do many other languages. Instead, it has the Haskell Platformโ€”a collection of curated packages deemed most useful and of high quality. While it's not recommended that you install the platform per se, I do recommend that you consult the Haskell Platform documentation as your first place to discover new libraries and functions and install the libraries as needed.

Another great way to discover functions is via Hoogle, the Haskell function search engine. With Hoogle, functions may be discovered by name or type signature.

school-of-haskell's People

Contributors

jonplussed avatar twopoint718 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.