Skip to content

Instantly share code, notes, and snippets.

View adilakhter's full-sized avatar

Adil Akhter adilakhter

View GitHub Profile
@adilakhter
adilakhter / shapeless_example.scala
Last active May 24, 2017 20:42
Shapeless : Checking of the Type Constraints of Polymorphic Functions (lifted types)
// details: https://stackoverflow.com/questions/44159203/shapeless-checking-of-the-type-constraints-of-polymorphic-functions-lifted-ty
import shapeless._
import ops.hlist._
import ops.function._
import syntax.std.function._
object ShapelessExample {
case class Place[A](a: A) extends AnyVal
package test
import scala.collection.mutable
import scala.reflect.ClassTag
/**
* A Source of elements of type [[A]].
*
* [[Source]] is basically the inverse of
* a `scala.Iterator`: instead of the core functionality being the pull-based

#Haskell, Stack and Intellij IDEA IDE setup tutorial how to get started Upon completion you will have a sane, productive Haskell environment adhering to best practices.

Basics

  • Haskell is a programming language.
  • Stack is tool for Haskell projects. (similar tools for other languages include Maven, Gradle, npm, RubyGems etc)
  • Intellij IDEA IDE is a popular IDE.

Download and extract Stack

Don't install Haskell, Stack, Cabal or any other Haskell tool or library using your OS package manager or using Cabal.

@adilakhter
adilakhter / must-watch-talks.md
Created October 8, 2016 12:38 — forked from ikhoon/must-watch-talks.md
Must watch talks - reddit /r/scala
#!/usr/bin/env amm
load.ivy("org.typelevel" %% "cats" % "0.7.0")
@
import cats.{Id, ~>}
import cats.data.State
import cats.free._
import cats.free.Free._

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@adilakhter
adilakhter / runar-io-free.scala
Created September 10, 2016 07:17 — forked from arosien/runar-io-free.scala
Translation of Runar's ScalaIO 2013 presentation on IO and Free monads (http://blog.higher-order.com/assets/scalaio.pdf) to scalaz.
import scalaz._
import Scalaz._
import Free._
/** "Pure" interactions with a console. */
sealed trait Console[+A]
case class GetLine[A](k: String => A) extends Console[A]
case class PutLine[A](s: String, a: A) extends Console[A]
object Console {
@adilakhter
adilakhter / FreeConsole.scala
Created September 9, 2016 13:17 — forked from filippovitale/FreeConsole
FreeConsole – Simplest end to end example of Coyoneda and Free Monad in Scala
import scalaz.effect.IO
import scalaz.std.function._
import scalaz.{Coyoneda, Free, Monad, State, ~>}
object NonFunctor extends App {
// my simple algebra
sealed trait Console[A]
case class PrintLine(msg: String) extends Console[Unit]
case object ReadLine extends Console[String]
@adilakhter
adilakhter / State.scala
Created June 5, 2016 23:28 — forked from mpilquist/State.scala
Example of computing Fibonacci sequence with Scala 2.10 and memoizing State monad
trait State[S, A] {
val run: S => (S, A)
def apply(s: S): (S, A) =
run(s)
def eval(s: S): A =
apply(s)._2
@adilakhter
adilakhter / ardrone.scala
Created September 11, 2015 13:25
ardrone
val drone = new ARDrone("192.168.1.1")
dron.connect();
if(drone.hasVideo) {
//
val bufferedImage = drone.video().getFrame()