Skip to content

Instantly share code, notes, and snippets.

@suhailshergill
suhailshergill / RDDasMonadPlus.scala
Last active February 24, 2019 16:09
having monad instances for RDD like things
object RDDasMonadPlus {
import org.apache.spark.{ SparkContext }
import org.apache.spark.rdd.RDD
import scalaz._
import Scalaz._
import scala.reflect.ClassTag
// RDDMPlus is the type for which we will define the Monad instance. it can be
// constructed from an RDD using the RDDClassTag constructor. this
// implementation is based on insights from
@dpiponi
dpiponi / Main.hs
Created February 15, 2016 23:38
Haskell heat engine simulation. (Not quite complete.)
{-# LANGUAGE FlexibleContexts #-}
import Data.Array
import Data.Array.IO
import Data.Foldable
import Data.List hiding (sum)
import System.Random
import Control.Monad.State
import Prelude hiding (sum)
--import Debug.Trace

Revisiting Tagless Final Interpreters

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