Skip to content

Instantly share code, notes, and snippets.

View debasishg's full-sized avatar
🏠
Working from home

Debasish Ghosh debasishg

🏠
Working from home
View GitHub Profile
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scalaz._
import scalaz._
scala> import Scalaz._
import Scalaz._
@debasishg
debasishg / prog-lang.md
Last active July 12, 2019 15:11
a list of programming language papers that need to be read again and again ..
  1. Extensible Effects: An Alternative to Monad Transformers by Oleg Kiselyov, Amr Sabry and Cameron Swords Scala translation
  2. Modular Type Classes by Derek Dreyerm, Robert Harper and Manuel M.T. Chakravarty
  3. Data types a la carte by WOUTER SWIERSTRA. Scala translation
  4. Reflection without Remorse by Atze van der Ploeg and Oleg Kiselyov
  5. Asymptotic Improvement of Computations over Free Monads by Janis Voigtlander
  6. Finally Tagless, Partially Evaluated by Jacques Carette, Oleg Kiselyov and Chung-chieh Shan
  7. [Functional Pearl: A Smart View on Dat
@debasishg
debasishg / gist:67b16a1aa941586b7c43
Created July 4, 2015 20:53
Generalizing the definition of an F-algebra in Scala
/**
* http://stackoverflow.com/questions/16015020/what-does-coalgebra-mean-in-the-context-of-programming
**/
def op[T: Monoid](arg: \/[(T, T), T]): T = {
val m = implicitly[Monoid[T]]
arg match {
case -\/((a, b)) => m.append(a, b)
case \/-(a) => m.zero
}
}
Welcome to Scala version 2.11.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_65).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import frdomain.ch3.repository._
import frdomain.ch3.repository._
scala> import reader._
import reader._
trait Writes[T] {
def writes(o: T): JsValue
}
trait Reads[T] {
def reads(json: JsValue): T
}
trait Format[T] extends Writes[T] with Reads[T]
trait AccountRepository {
def query(no: String): \/[NonEmptyList[String], Option[Account]]
def store(a: Account): \/[NonEmptyList[String], Account]
def query(openedOn: Date): \/[NonEmptyList[String], Seq[Account]]
def all: \/[NonEmptyList[String], Seq[Account]]
}
/**
* and an implementation for this trait
**/
sealed trait Base
case class D1(...) extends Base
case class D2(...) extedns Base
// Have defined all instances of EncodeJson & DecodeJson for D1 and D2
// works in 6.0.x but does not compile in 6.1-M5 since DecodeResult is now invariant
implicit val decode: DecodeJson[Base] = DecodeJson { c =>
(c --\ "storeDelete").as[D1] |||
(c --\ "indexState").as[D2] |||
@debasishg
debasishg / gist:f14fd21a8ef14a35e65e
Created October 10, 2014 01:28
generator and property for ADTs with custom initialization logic
// the ADT
sealed trait Account {
def no: String
def name: String
def openingDate: Date
def closeDate: Option[Date]
}
final case class CheckingAccount private[prop](no: String, name: String, openingDate: Date, closeDate: Option[Date])
@debasishg
debasishg / gist:b4df1648d3f1776abdff
Last active June 20, 2025 13:59
another attempt to organize my ML readings ..
  1. Feature Learning
  1. Deep Learning
@debasishg
debasishg / gist:d9b6d984df3cc4681eb1
Last active November 23, 2022 06:26
Useful links on Convex Optimization