This file contains hidden or 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
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
call plug#begin('~/.vim/plugged') | |
Plug 'w0rp/ale' | |
Plug 'vim-airline/vim-airline' | |
Plug 'eagletmt/ghcmod-vim' | |
Plug 'Shougo/vimproc' | |
call plug#end() |
This file contains hidden or 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
object Main extends App { | |
import com.google.protobuf.util.JsonFormat | |
import example.user.User | |
val user = User(id = 1, name = "foo") | |
println(user) | |
val userJson = JsonFormat.printer.print(User.toJavaProto(user)) | |
println(userJson) |
This file contains hidden or 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
object Main extends App { | |
sealed trait VState | |
final abstract class Idle extends VState | |
final abstract class Half extends VState | |
final abstract class Ready extends VState | |
type Drink = String | |
sealed trait Coin | |
case object FiftyCents extends Coin |
This file contains hidden or 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
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
module Main where | |
import Data.Text.Lazy (Text) | |
import qualified Data.Text.Lazy as T | |
import Text.Megaparsec | |
import Text.Megaparsec.Text.Lazy | |
import qualified Text.Megaparsec.Lexer as L | |
import Text.RawString.QQ |
This file contains hidden or 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
object Main extends App { | |
case class Food(ingredients: Seq[String]) | |
class Chef[Pizza <: Chef.Pizza](ingredients: Seq[String] = Seq()) { | |
import Chef.Pizza._ | |
def addCheese(cheeseType: String): Chef[Pizza with Cheese] = new Chef(ingredients :+ cheeseType) | |
def addTopping(toppingType: String): Chef[Pizza with Topping] = new Chef(ingredients :+ toppingType) |
This file contains hidden or 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
{-# LANGUAGE OverloadedStrings, RankNTypes, FlexibleContexts #-} | |
module Main where | |
import Lucid | |
import Data.Text | |
import Network.Wai | |
import Network.Wai.Handler.Warp | |
import Network.HTTP.Types | |
main :: IO () |
This file contains hidden or 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
{-# LANGUAGE RankNTypes #-} | |
module Main where | |
import Data.Functor.Const | |
import Data.Functor.Identity | |
type SimpleLens s a = forall f. Functor f => (a -> f a) -> s -> f s | |
data Person = Person { |
This file contains hidden or 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
// scalacOptions += "-Ypartial-unification" | |
object Foo { | |
trait KVS[F[_], K, V] { | |
def put(k: K, v: V): F[Unit] | |
def get(k: K): F[Option[V]] | |
} | |
trait Repository[F[_], Id, A] { | |
def query(id: Id): F[Option[A]] |
This file contains hidden or 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 cats._, cats.data._, cats.implicits._ | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.{Await, duration} | |
object Main extends App { | |
implicit class Ops[In](in: In) { | |
def |>[Out](f: In => Out): Out = f(in) | |
} |
This file contains hidden or 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
// https://gist.github.com/tpolecat/567e45710553d1b13fda1a4354ed8c18 | |
import cats._, cats.implicits._ | |
import cats.free.Coyoneda | |
object Main extends App { | |
val c = Coyoneda.lift(Set(1, 2, 3)).fproduct(n => "x" * n) | |
assert { | |
c.fi.map(c.k) == Set((1, "x"), (2, "xx"), (3, "xxx")) |