Skip to content

Instantly share code, notes, and snippets.

View arjunswaj's full-sized avatar

Arjun Shekar Bharadwaj arjunswaj

View GitHub Profile
@arjunswaj
arjunswaj / Main.java
Last active July 2, 2016 08:17
Combinations
package com.asb.algos.playground;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) throws Exception {
@arjunswaj
arjunswaj / ProgramWithErrors.scala
Created September 1, 2017 18:37
Free Monads with Errors
package com.asb.free
import cats.data.{EitherK, EitherT}
import cats.free.Free
import cats.free.Free.inject
import cats.{Id, InjectK, ~>}
/**
* Program With Errors.
* Created by arjun on 9/1/17.
@arjunswaj
arjunswaj / FreeIO.scala
Last active December 31, 2017 08:15
Free Monads for File IO
object FreeIO {
// CSV IO
sealed trait CSVIO[A]
case class ReadCSV(reader: Reader) extends CSVIO[Stream[CSVRecord]]
class CSVIOs[F[_]](implicit I: InjectK[CSVIO, F]) {
def readCSV(reader: Reader): Free[F, Stream[CSVRecord]] =
inject(ReadCSV(reader))
}