Here's an ADT which is not a GADT, in Haskell:
data Expr = IntExpr Int | BoolExpr Bool
class A | |
class A2 extends A | |
class B | |
trait M[X] | |
// | |
// Upper Type Bound | |
// | |
def upperTypeBound[AA <: A](x: AA): A = x |
object Playground extends App { | |
sealed trait IExp | |
final case class Lit(i: Int) extends IExp | |
final case class Neg(e: IExp) extends IExp | |
final case class Add(r: IExp, l: IExp) extends IExp | |
sealed trait Tree | |
final case class Leaf(s: String) extends Tree | |
final case class Node(s: String, ts: List[Tree]) extends Tree |
Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).
The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject
typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA
#!/usr/bin/env bash | |
set -x | |
NS="ns1" | |
VETH="veth1" | |
VPEER="vpeer1" | |
VETH_ADDR="10.200.1.1" | |
VPEER_ADDR="10.200.1.2" |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>Some experiments in how I might do multipart diagrams/schematics with SVG</title> | |
</head> | |
<body> | |
<h1>The problem</h1> | |
<p>I have a need/want to knock up schematic-like diagrams on the web with which I can: display either the whole or only parts of the diagram; zoom/scale or transform the part(s) being displayed. SVG seems to make sense a basis for this, so the question becomes one of: how do I do this with SVG?</p> |
object Demo { | |
// A couple of type classes with type members ... | |
trait Foo[T] { | |
type A | |
} | |
object Foo { | |
implicit val fooIS = new Foo[Int] { type A = String } | |
} |
#!/bin/sh | |
# Install stack | |
curl -sSL https://get.haskellstack.org/ | sh | |
# Install LLVM | |
sudo apt-get install llvm-3.7 | |
# Add symbolic links to opt and llc | |
ln -s /usr/bin/opt-3.7 /usr/bin/opt |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
import Control.Monad.IO.Class | |
import Control.Monad.Trans.Class | |
import Prelude hiding (log) | |
-------------------------------------------------------------------------------- | |
-- The API for cloud files. | |
class Monad m => MonadCloud m where | |
saveFile :: Path -> Bytes -> m () |