Skip to content

Instantly share code, notes, and snippets.

View tomwadeson's full-sized avatar

Tom Wadeson tomwadeson

View GitHub Profile
package example
import cats.effect.{ExitCode, IO, IOApp}
import org.http4s.HttpRoutes
import org.http4s.dsl.Http4sDsl
import org.http4s.server.blaze.BlazeServerBuilder
import org.http4s.implicits._
import scala.concurrent.ExecutionContext
@tomwadeson
tomwadeson / Day2.hs
Last active February 19, 2020 19:51
Advent Of Code 2019, Day 2
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE TypeApplications #-}
module Day2
( main
)
where
import Control.Monad.State ( State
, MonadState
@tomwadeson
tomwadeson / Day1.hs
Created February 17, 2020 09:45
Advent Of Code 2019, Day 1
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
module Day1
( moduleMasses
, partOne
, partTwo
)
where
@tomwadeson
tomwadeson / ArbitraryStreams.scala
Last active November 15, 2019 00:35
Streaming generation of arbitrary (and optionally distinct) data, with a scary-looking `toIterator` to integrate with Gatling
package newbeeper.performance
import cats.effect.concurrent.{MVar, Ref}
import cats.effect.syntax.concurrent._
import cats.effect.{Concurrent, ConcurrentEffect, Sync}
import cats.syntax.flatMap._
import cats.syntax.functor._
import fs2.Stream
import org.scalacheck.Arbitrary
@tomwadeson
tomwadeson / FooRepository.scala
Created November 5, 2019 16:56
A demonstration of specifying a `FooRepository` capability and ensuring that in-memory and postgres-based interpreters are compliant
package foo
import cats.effect.{IO, Resource, Sync}
import cats.effect.concurrent.Ref
import cats.implicits._
import doobie.util.transactor.Transactor
/**
* The `Foo` domain model.
*
trait Console[F[_]] {
  def readLine: F[String]
  def printLine(s: String): F[Unit]
}
// I know that all this function can do is call `readLine`.
// What's more, it can only do it exactly (usefully) once.
import cats.effect.{ExitCode, IO, IOApp, Resource}
import org.http4s.HttpRoutes
import org.http4s.client.Client
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.dsl.Http4sDsl
import org.http4s.implicits._
import cats.implicits._
object Http4sClientTest extends IOApp {

Keybase proof

I hereby claim:

  • I am tomwadeson on github.
  • I am tomwadeson (https://keybase.io/tomwadeson) on keybase.
  • I have a public key ASBHtwj-BohXckvgbTfHp9M5a79ZrcLg8_WrLEQS07qrvgo

To claim this, I am signing this object:

module IntermediateHaskellExercises where
class Fluffy f where
furry :: (a -> b) -> f a -> f b
-- Exercise 1
instance Fluffy [] where
furry :: (a -> b) -> [a] -> [b]
furry _ [] = []
furry f (x:xs) = f x : furry f xs
package com.tomwadeson.show
import com.tomwadeson.Show.Showable
import scala.language.implicitConversions
trait Show[A] {
def show(a: A): String
}