Giter Club home page Giter Club logo

gettingworkdonewithextensibleeffects's Introduction

Getting Work Done With Extensible Effects

YOW Lambdajam Sydney 2017 workshop on programming with the Eff framework.

The workshop consists of a series of practical exercises which teach the use of Eff. Each exercise is an alternate implementation of the same use case:

Ever had a full disk? Where does the space go? Implement a program that can find the largest N files in a directory tree

Setup

  • Wifi/Internet required.

  • You will need Java 8+ and Simple Build Tool (sbt) installed.

  • While SBT will download Scala and the Eff libraries on-demand, this can be a slow process. Before the workshop, it is recommended to run sbt update in the base directory to pre-download the required libraries. This may take a few minutes up to 1 hour, depending what you have cached locally in ~/.ivy2/cache.

  • Import the base SBT project into your IDE: Intellij, Eclipse ScalaIDE or Ensime.

  • Or work with any editor and the SBT command line if you prefer.

    Be warned that IDE presentation compilers don't correctly handle some Eff code, and may flag valid code as invalid. Try your code with the full Scala compiler via SBT command line before concluding there is a problem.

Exercises

The SBT base project contains five exercise projects, each with a README with instructions to attempt. Each of them contains a different implementation of a file scanner program. Do the exercises in order.

The instruction pages are best viewed in a browser; reach them here:

  • exercise1 - File Scanning without using Eff
  • exercise2 - Using Eff Reader effect for dependency injection
  • exercise3 - Using Eff Either effect for error handling
  • exercise4 - Using Eff Task effect for asynchronous & concurrent execution
  • exercise5 - Using Eff Writer effect for logging

There are three types of tasks you'll encounter

  • ๐Ÿ” Study Code Study existing application and test code
  • ๐Ÿ“ Write Code Adding missing code or changing existing code at an indicated line or method.
  • โ–ถ๏ธ Run Code Run the file scanner (eg exercise1/run) or the unit tests (eg exercise1/test) from SBT prompt.

Each project can be compiled, run or tested separately; errors in one project won't affect the others.

Solutions

There is a solutions subfolder containing 5 corresponding solution subprojects.

There is learning value in attempting a hard problem, getting stuck, then reviewing the solution. Use the solutions if you get blocked!

Using SBT

Start SBT in the base directory and then operate from the SBT prompt. Invoking each SBT command from the shell (eg sbt exercise1/compile) is slower due to JVM startup costs.

/Users/ben_hutchison/projects/GettingWorkDoneWithExtensibleEffects $ sbt
Getting org.scala-sbt sbt 0.13.13 ...
..further sbt loading omitted..
>

To list all 5 exercise and 5 solution subproject names:

> projects

Try running the file scanner (ie main method) of subproject solutionExercise1 on the current directory.

> solutionExercise1/run .`

To compile sources in subproject exercise1:

> exercise1/compile`

To run any unit tests (in src/test/scala/*) under subproject exercise1

> exercise1/test

SBT commands should be scoped to a subproject (eg exercise1/test). Running eg test at the top level will load 10 copies of the classes into the SBT JVM, potentially leading to OutOfMemoryError: Metaspace

"Learn by Doing"

This project teaches Extensible Effects in practice; what it feels like to code with the Eff framework.

It doesn't make any attempt to cover the complex, subtle theory behind Eff, a refinement of 25 years experience of programming with monads, and isn't a complete picture of Eff by any means. At the time of writing however, there are more resources available covering the theory, than practice, of Eff, including:

gettingworkdonewithextensibleeffects's People

Contributors

benhutchison avatar mmollaverdi 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.