A type is a set of values.
Int -- The set of all integer values (that fit into 64 bits)
To say that a term a
has type A
is to say that a
is a member of the set of values represented by A
.
@Data(flavour = Flavour.FJ) | |
public abstract class Free<f, A> implements __2<Free.µ, f, A> { | |
Free() {} | |
interface Cases<f, A, R> { | |
R Return(A a); | |
R Suspend(__<f, A> fa); | |
R Gosub(Sub<f, A, ?> sub); | |
} | |
abstract <R> R match(Cases<f, A, R> cases); |
This document is licensed CC0.
These are some questions to give a sense of what you know about FP. This is more of a gauge of what you know, it's not necessarily expected that a single person will breeze through all questions. For each question, give your answer if you know it, say how long it took you, and say whether it was 'trivial', 'easy', 'medium', 'hard', or 'I don't know'. Give your answers in Haskell for the questions that involve code.
Please be honest, as the interviewer may do some spot checking with similar questions. It's not going to look good if you report a question as being 'trivial' but a similar question completely stumps you.
Here's a bit more guidance on how to use these labels:
protocol Expr { | |
static func lit(_ x: Int) -> Self | |
static func add(_ lhs: Self, _ rhs: Self) -> Self | |
} | |
extension Int : Expr { | |
static func lit(_ x : Int) -> Int { | |
return x; | |
} | |
static func add(_ lhs: Int, _ rhs: Int) -> Int { |
class Option<A> { | |
protected Option() { } | |
} | |
interface App<F, A> { | |
F proof(); | |
} | |
class OptionF { | |
private OptionF() {} | |
private static class AppOption<A> implements App<OptionF, A> { |
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
This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere… I hope to present the information you need without assuming anything.
Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!
One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.
# This is free and unencumbered software released into the public domain. | |
# Anyone is free to copy, modify, publish, use, compile, sell, or | |
# distribute this software, either in source code form or as a compiled | |
# binary, for any purpose, commercial or non-commercial, and by any | |
# means. | |
# In jurisdictions that recognize copyright laws, the author or authors | |
# of this software dedicate any and all copyright interest in the | |
# software to the public domain. We make this dedication for the benefit |
import java.util | |
import java.util.Map.Entry | |
import akka.http.scaladsl.model.HttpHeader | |
import io.opentracing.propagation.TextMap | |
import scala.collection.JavaConverters.asJavaIteratorConverter | |
/** | |
* Used to extract an iterator of Entry[String, String] to the |
// These lines go in ~/.sbt/0.13/global.sbt | |
watchSources ++= ( | |
(baseDirectory.value * "*.sbt").get | |
++ (baseDirectory.value / "project" * "*.scala").get | |
++ (baseDirectory.value / "project" * "*.sbt").get | |
) | |
addCommandAlias("rtu", "; reload ; test:update") | |
addCommandAlias("rtc", "; reload ; test:compile") | |
addCommandAlias("ru", "; reload ; update") |