- Install bloop
1.0.0-M11
by following the Bloop installation instructions. Then, make sure you start up the bloop server on the background and to generate the configuration files by runningbloopInstall
in your build tool. - Install IntelliJ 2018.2 EAP and then enable the nightly version of the Scala Plugin by opening Preferences | Languages & Frameworks | Scala | Updates tab and selecting the Nightly plugin update channel:
- check for updates and download the Scala plugin Nightly release.
- Reboot IntelliJ. The Scala plugin should now have version 2018.2.277 or higher (check in Preferences | Plugins)
- Open the "Find Action" search box (usual hotkey Shift+Ctrl+A or shift+cmd+A) and search for "bsp". The search box will show the full action name: "Enable experime
import java.math.BigInteger | |
import java.net.DatagramPacket | |
import java.net.DatagramSocket | |
import java.net.InetAddress | |
import java.security.KeyPairGenerator | |
import java.security.MessageDigest | |
import java.security.SecureRandom | |
import java.security.interfaces.ECPrivateKey | |
import java.security.interfaces.ECPublicKey | |
import java.security.spec.ECPoint |
/* Example of encoding Functor/Applicative/Monad from cats with Dotty 0.15 features. | |
* Derived in part from Cats -- see https://github.com/typelevel/cats/blob/master/COPYING for full license & copyright. | |
*/ | |
package structures | |
import scala.annotation._ | |
trait Functor[F[_]] { | |
def (fa: F[A]) map[A, B](f: A => B): F[B] | |
def (fa: F[A]) as[A, B](b: B): F[B] = |
package fpmax | |
import scala.util.Try | |
import scala.io.StdIn.readLine | |
object App0 { | |
def main: Unit = { | |
println("What is your name?") | |
val name = readLine() |
import java.io.{ File, PrintWriter } | |
/** Creates a temporary file, writes the input string to the file, and the file handle. | |
* | |
* NOTE: This funciton uses the createTempFile function from the File class. The prefix and | |
* suffix must be at least 3 characters long, otherwise this function throws an | |
* IllegalArgumentException. | |
*/ | |
def writeToTempFile(contents: String, | |
prefix: Option[String] = None, |
Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).
The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject
typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA
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
Disclaimer 1: Type classes are great but they are not the right tool for every job. Enjoy some balance and balance to your balance.
Disclaimer 2: I should tidy this up but probably won’t.
Disclaimer 3: Yeah called it, better to be realistic.
Type classes are a language of their own, this is an attempt to document features and give a name to them.
Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.
But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.
For starters, here is the sort of thing that SI-2712 affects:
def foo[F[_], A](fa: F[A]): String = fa.toString