Skip to content

FP in Scala course, based on "Patterns in Types (Lambda Jam 2013)" and the Data61 fp-course

Notifications You must be signed in to change notification settings

scalaz/introduction-to-fp-in-scala

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction to FP in Scala Build Status

This is the base project for the workshop.

note: please test your environment before you arrive so we can get started quickly on the day.

Getting started

Before you attend you will need to get a few things ready and ensure everything is setup properly. sbt is going to do all the heavy lifting though, so hopefully it is all straight forward, if not, file an issue.

Pre-requisites.

  1. A valid install of java 6+
  2. git
  3. if you are windows only install sbt using the msi installer

Getting scala and validating your environment:

git clone https://github.com/scalaz/introduction-to-fp-in-scala.git
cd introduction-to-fp-in-scala
./sbt "test:compile"
# For windows users just use your installed `sbt` directly without the `./`

For either platform this may take a few minutes. It will:

  1. Download the sbt build tool.
  2. Download the required versions of scala.
  3. Compile the main and test source code.

You should see no errors and an exit code of 0.

Running the tests

If you want to run all the tests once then you can simple run

./sbt test

However this can be tedious, and requires waiting for SBT to start and for all the tests to run (which might get noisy if they fail). It is recommend to start the SBT console and run specific tests in a loop, which is handy when working on a particular exercise:

# Start the SBT terminal once, and then subsequent commands are run within that program
# Be careful not to type Ctrl^C as this kills the entire session
./sbt

# Run the tests from a package containing the name "Id"
> testOnly *Id*

# Add a ~ for starting a watch daemon to recompile and re-run tests when files are changed
> ~testOnly *Result*

Working with scala.

Any good text editor will be sufficient for the course. If you prefer an IDE, you can use the eclipse based scala-ide, intellij, or emacs with ensime. There are commented out lines in project/plugins.sbt that will help you get started:

You can generate project files for eclipse with (after uncommenting sbteclipse-plugin plugin):

./sbt eclipse

If you want to use ensime (after uncommenting ensime-sbt-cmd):

./sbt 'ensime generate'

You can import the project files for intellij if you have the latest scala plugin enabled.

Just note that if you choose eclipse or intellij, have a backup texteditor as well, because there won't be enough time to debug any editor issues.

The Plan

There is about two weeks worth of material available, people with different backgrounds will progress through at different rates.

Answers

If get get stuck there is an answers folder where you can look for help or inspiration. Don't feel bad if you need to peek. ;-)

Just enough scala

What is functional programming?

Introduction to data structures and higher order functions

Examples

Exercises

Intro to Type Classes

Example

Exercises

NOTE: Applicative can often prove more tricky than Monad, feel free to flip the order if you get stuck.

Algebra for fun and profit

Parsers

If you enjoyed parsing and want some more then writing a json parser is also fun:

Zippers

Patterns in Types

About

FP in Scala course, based on "Patterns in Types (Lambda Jam 2013)" and the Data61 fp-course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 87.2%
  • Shell 12.8%