Here's an ADT which is not a GADT, in Haskell:
data Expr = IntExpr Int | BoolExpr Bool
;; 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: |
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 { |
#!/bin/sh | |
apt-get -y install git bc | |
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt | |
mkdir /etc/letsencrypt |
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
{-# LANGUAGE ForeignFunctionInterface #-} | |
{-# LANGUAGE JavaScriptFFI #-} | |
{-# LANGUAGE UnliftedFFITypes #-} | |
{-# LANGUAGE GHCForeignImportPrim #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE DeriveDataTypeable #-} | |
{-# LANGUAGE TypeFamilies #-} |
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] |