- Programming using a series of transformations and aggregations, something I've been doing for years, is known as programming in the map/reduce style.
- The more abstract the type is, the greater its cardinality, and the smaller the set of operations it supports. So make use of universal quantifiers, particularly by implementing fully parametric functions. They guide you on how to implement their term-level definitions by narrowing down the number of possible implementations. In other words, the type system of Scala (or Haskell, for that matter) is not only great for capturing compile-time errors, but is also capable of leading you to the correct solution.
- You can encode union types by combining different Scala features such as type constructors, subtyping and implicits, and by taking advantage of the Curry-Howard Isomorphism and De Morgan's Laws for neg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MIT License | |
Copyright (c) 2021 Daniel Ethridge | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ell clock https://twitter.com/cwillmore/status/1353435612636803073 | |
// developed with processing 3.5.4 (processing.org) | |
// TODO: | |
// - motion blur | |
// - ripple update of ells - one only starts rotating when it has room to (<< ... <> ... >>) | |
static final int DEPTH = 3; | |
static final int N = 1 << (DEPTH + 1); | |
static final int FRAME_RATE = 30; | |
static final float DT = 1 / (float)FRAME_RATE; |
See also List of materials about Software Design in Haskell
Junior | Middle | Senior | Architect | |
---|---|---|---|---|
Haskell level | Basic Haskell | Intermediate Haskell | Advanced Haskell | Language-agnostic |
Haskell knowledge scope | Learn you a Haskell | Get programming with Haskell | Haskell in Depth | Knows several languages from different categories |
Get programming with Haskell | Haskell in Depth | Functional Design and Architecture | ||
Soar with Haskell | [Soar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.PrintWriter | |
import java.io.StringWriter | |
// Extension property on Exception | |
val Exception.stackTraceString: String | |
get() { | |
val stringWriter = StringWriter() | |
this.printStackTrace(PrintWriter(stringWriter)) | |
return stringWriter.toString() | |
} |
There exist several DI frameworks / libraries
in the Scala
ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.
A few of the most claimed benefits are the following:
- Dependency Injection.
- Life cycle management.
- Dependency graph rewriting.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fasterparser | |
import scala.collection.mutable | |
object Parse { | |
def main(args: Array[String]): Unit = { | |
def hello[_:Ctx] = P( "hello" ) | |
def world[_:Ctx] = P( "world" ) | |
def helloWorld[_:Ctx] = P( hello.! ~ (" " | ",").rep ~ world.! ) |
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x
NewerOlder