object Monad { | |
trait Monad[F[_]] { | |
def pure[A](a: A): F[A] | |
/** | |
* We can have a default implementation in terms of tailRecM | |
* and map | |
*/ | |
def flatMap[A, B](fa: F[A])(fn: A => F[B]): F[B] = { | |
def step(first: Option[A]): F[Either[Option[A], B]] = |
import cats.effect.{Effect, IO} | |
import fs2._ | |
import scala.concurrent.ExecutionContext | |
def runConcat[F[_], A](first: Stream[F, A], second: Stream[F, A])( | |
implicit F: Effect[F], | |
ec: ExecutionContext): Stream[F, A] = { | |
type Step = AsyncPull[F, Option[(Segment[A, Unit], Stream[F, A])]] | |
def readFull(s: Step): Pull[F, A, Unit] = |
From time to time, Musk will send out an e-mail to the entire company to enforce a new policy or let them know about something that's bothering him. One of the more famous e-mails arrived in May 2010 with the subject line: Acronyms Seriously Suck:
There is a creeping tendency to use made up acronyms at SpaceX. Excessive use of made up acronyms is a significant impediment to communication and keeping communication good as we grow is incredibly important. Individually, a few acronyms here and there may not seem so bad, but if a thousand people are making these up, over time the result will be a huge glossary that we have to issue to new employees. No one can actually remember all these acronyms and people don't want to seem dumb in a meeting, so they just sit there in ignorance. This is particularly tough on new employees.
That needs to stop immediately or I will take drastic action - I have given enough warning over the years. Unless an acronym is approved by me, it should not enter the SpaceX glossary.
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
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
1. Register for Microsoft account at https://signup.live.com/signup | |
2. Email verification - click link (logs you in) | |
3. Register on Azure Data Market at https://datamarket.azure.com/register | |
4. Go to: https://datamarket.azure.com/dataset/datagovuk/metofficeweatheropendata click 'Sign up' then 'agree', then 'sign up'. | |
Use Web i/f to download CSV: | |
At: https://datamarket.azure.com/dataset/explore/0f2cba12-e5cf-4c6d-83c9-83114d44387a click 'Explore', 'Three Hourly Forecast' and 'Download Excel (CSV)' | |
or by API: | |
Go to: https://datamarket.azure.com/account for account key |
import akka.http.scaladsl.model.HttpHeader | |
import akka.http.scaladsl.model.HttpMethods._ | |
import akka.http.scaladsl.model.HttpResponse | |
import akka.http.scaladsl.model.headers.`Access-Control-Allow-Credentials` | |
import akka.http.scaladsl.model.headers.`Access-Control-Allow-Methods` | |
import akka.http.scaladsl.model.headers.`Access-Control-Allow-Origin` | |
import akka.http.scaladsl.model.headers.Origin | |
import akka.http.scaladsl.server.Directive0 | |
import akka.http.scaladsl.server.Directives._ | |
import akka.http.scaladsl.server.MethodRejection |
YouTube link: https://www.youtube.com/watch?v=z1uviQbKe0U
Your hosts: Josh Suereth, Dick Wall, Daniel Spiewak, Seth Tisue
Join us during and between episodes for web-based Scalawags chat on Gitter.
target |