This blog post series has moved here.
You might also be interested in the 2016 version.
| license: gpl-3.0 |
This blog post series has moved here.
You might also be interested in the 2016 version.
| import scalaz.{ Free, Coyoneda, Monad, ~>, State, NonEmptyList } | |
| import scalaz.std.function._ | |
| import scalaz.syntax.monad._ | |
| import scalaz.effect.IO | |
| import scala.util.Random | |
| object freecoyo extends App { | |
| // An algebra of primitive operations in the context of a random number generator |
Machinist Issue #2 asks:
Is it correct, that this stuff is completely obsolete now due to value classes or are there still some use cases? An example of using value class for zero-cost implicit enrichment: [...]
The short answer is that Machinist is not obsolete: value classes existed before the Machinist macros were implemented, and they do not solve the
| # Live coding example for Retune conference 2014 | |
| # 1) Press Run (Cmd+R) to start | |
| # 2) Make changes (e.g. comment in/out various lines in :beats & :amen) | |
| # 3) Press Run again (changes will only be audible from next queue point) | |
| # compute loop length (4 bars), bar & quarter note durations | |
| dur = sample_duration :loop_compus | |
| bar = dur / 4 | |
| quart = dur / 16 |
| . 5 . | . . 1 | 4 7 9 | |
| . . 2 | 7 . . | . . 8 | |
| . . . | . 4 6 | 2 . . | |
| ------+-------+------ | |
| . 4 6 | . . 9 | 5 3 7 | |
| . . . | . 6 . | . . . | |
| 8 9 3 | 5 . . | 6 4 . | |
| ------+-------+------ | |
| . . 9 | 6 1 . | . . . | |
| 1 . . | . . 2 | 3 . . |
| # Scaladoc Developer Guide | |
| ## Introduction | |
| Scaladoc is the tool that enables developers to automatically generate documentation for their Scala (and Java) projects. It is Scala's equivalent of the widely-used Javadoc tool. This means that Javadoc (and even doxygen) users will be familiar with Scaladoc from day 1: for them, it is most beneficial to check out the Scaladoc/Javadoc comparison tables and if necessary, skim through this document to understand specific features. | |
| The rest of this tutorial is aimed at developers new to Scaladoc and other similar tools. It assumes a basic understanding of the Scala language, which is necessary to follow the examples given throughout the tutorial. For the user perspective on the Scaladoc-generated documentation, such as finding a class, understanding the page layout, navigating through diagrams, please refer to the Scaladoc User Guide. | |
| The tutorial will start by a short motivation and then will explain the main concept in Scaladoc: the doc comment. | |
| ### Why document? |
| module Date | |
| -- leap year ? | |
| leap : Integer -> Bool | |
| leap year = (mod year 4 == 0) && ((mod year 400 == 0) || not (mod year 100 == 0)) | |
| -- number of days in month/year | |
| days : Integer -> Integer -> Integer | |
| days 2 year = if leap year then 29 else 28 | |
| days month _ = if month `List.elem` [4,6,9,11] then 30 else 31 |
| scalaVersion := "2.10.2" | |
| resolvers += Resolver.sonatypeRepo("snapshots") | |
| libraryDependencies += "org.typelevel" %% "shapeless-scalaz" % "0.2-SNAPSHOT" | |
| libraryDependencies += "org.typelevel" %% "shapeless-scalacheck" % "0.2-SNAPSHOT" | |
| initialCommands in console := """ | |
| import scalaz._ |
| import shapeless._ | |
| sealed trait List[+T] | |
| case class Cons[T](hd: T, tl: List[T]) extends List[T] | |
| sealed trait Nil extends List[Nothing] | |
| case object Nil extends Nil | |
| trait Show[T] { | |
| def apply(t: T): String | |
| } |