I hereby claim:
- I am quelgar on github.
- I am quelgar (https://keybase.io/quelgar) on keybase.
- I have a public key whose fingerprint is 943B 4775 C45A 895B DEB2 B425 2DCC 6D93 44B3 8C1B
To claim this, I am signing this object:
package test | |
import java.net.InetSocketAddress | |
import akka.actor.{ActorLogging, ActorRef, Props} | |
import akka.io | |
import akka.stream.ActorMaterializer | |
import akka.stream.actor.ActorPublisher | |
import akka.stream.scaladsl.Source |
/** | |
* Catch exceptions to create an `Either` value. | |
* | |
* Useful when you want to deal an API that reports failure conditions using | |
* exceptions. This method allows catching exceptions and converting them to | |
* `Left` values. | |
* | |
* An advantage vs using `scala.util.Try` is that you have full control over | |
* which exceptions are caught. | |
* |
bject Tag { | |
type Tagged[T] = { | |
type Tag = T | |
} | |
type @@[A, T] = A with Tagged[T] | |
I hereby claim:
To claim this, I am signing this object:
Google also have their own C++ Style Guide that you may find more useful.
I do not use C++.
Pros:
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Functional I/O Demo</title> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.min.js"></script> | |
final case class Outer(inner: Outer#Inner) { | |
final case class Inner(a: String) | |
} |
import java.util.*; | |
import java.util.stream.Stream; | |
/** | |
* Find the most frequently occurring item that occurs more than once. | |
* Idea from http://skipoleschris.blogspot.com.au/2010/11/functional-programming-challenge-most.html | |
*/ | |
public final class Most { |
import qualified Data.Map as Map | |
-- Find the most frequently occurring item that occurs more than once | |
-- Idea from http://skipoleschris.blogspot.com.au/2010/11/functional-programming-challenge-most.html | |
most :: Ord a => [a] -> Maybe a | |
most xs = fst $ foldl most' (Nothing, Map.empty) xs where | |
most' (winning, seen) x = (winning', seen') where | |
winning' = if count > winningCount then Just x else winning |
import java.net.URI | |
/** | |
* State co-monad. | |
* | |
* `Store[F, _]` is the co-monad. | |
*/ | |
final case class Store[F, R](get: F, set: F => R) { | |
def map[S](f: R => S): Store[F, S] = Store(get, f compose set) |