Skip to content

Instantly share code, notes, and snippets.

View jvliwanag's full-sized avatar

Jan Vincent Liwanag jvliwanag

View GitHub Profile
@bontaq
bontaq / el
Created December 8, 2017 22:58
Brittany for emacs
;; brittany-hs.el --- Minor mode to format JS code on file save
;; Version: 0.1.0
;; Copyright (c) 2014 The go-mode Authors. All rights reserved.
;; Portions Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
@pchlupacek
pchlupacek / fs2Conversion.scala
Last active April 22, 2017 04:57
converting fs2 to scalaz.stream and vice versa
package spinoco.scalaz.stream
import fs2.Handle
import fs2._
import scalaz.concurrent.{Actor, Task}
import scalaz.stream.{Cause, Process, wye}
import scala.language.higherKinds
import scalaz.{-\/, \/, \/-}
-- This file is copy&pasteable into
-- http://try.purescript.org/
--
-- That fore dependencies are inlined (and renamed), i.e. Equals, Exists and Product.
module Main where
import Prelude
import Data.Either
import Data.Tuple
import Data.Maybe
import com.google.protobuf.Descriptors.{MethodDescriptor, ServiceDescriptor}
import com.trueaccord.scalapb.compiler.FunctionalPrinter.PrinterEndo
import com.trueaccord.scalapb.compiler._
import scala.collection.JavaConverters._
final class MonixGrpcPrinter(service: ServiceDescriptor,
override val params: GeneratorParams)
extends DescriptorPimps {
@smarter
smarter / gadt.md
Last active March 6, 2024 23:33
GADTs in Scala

Generalized Algebraic Data Types in Scala

Basic GADTs

Here's an ADT which is not a GADT, in Haskell:

data Expr = IntExpr Int | BoolExpr Bool
@mkubenka
mkubenka / install.sh
Created April 23, 2016 19:28
OpenVPN Access Server Letsencrypt
#!/bin/sh
apt-get -y install git bc
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
mkdir /etc/letsencrypt

Explaining Miles's Magic

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
@mmhelloworld
mmhelloworld / ConversionBetweenHaskellAndJavaLists.hs
Last active February 29, 2016 07:28
Haskell on the JVM via GHCJS and Nashorn
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE JavaScriptFFI #-}
{-# LANGUAGE UnliftedFFITypes #-}
{-# LANGUAGE GHCForeignImportPrim #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE TypeFamilies #-}
What is it?
  • Compiles to JavaScript
  • Haskell-inspired type system (with some improvements!)
  • No runtime (unlike Elm, GHCJS, etc)
  • A focus on readable and debuggable JavaScript
@jsuereth
jsuereth / freer.scala
Last active October 26, 2022 14:19
Freer monad in scala, just toying around.
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
trait Monad[F[_]] {
def apply[A](a: A): F[A]
def flatMap[A,B](fa: F[A])(f: A => F[B]): F[B]
}
sealed trait FFree[G[x], A] {}
case class FPure[G[x], A](data: A) extends FFree[G, A]