This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sealed trait Free[F[_], A] { self => | |
| final def map[B](ab: A => B): Free[F, B] = Free.flatMap(self, ab andThen (Free.point[F, B](_))) | |
| final def flatMap[B](afb: A => Free[F, B]): Free[F, B] = Free.flatMap(self, afb) | |
| final def interpret[G[_]: Monad](fg: F ~> G): G[A] = self match { | |
| case Free.Point(a0) => a0().point[G] | |
| case Free.Effect(fa) => fg(fa) | |
| case fm : Free.FlatMap[F, A] => | |
| val ga0 = fm.fa.interpret[G](fg) | |
| ga0.flatMap(a0 => fm.afb(a0).interpret[G](fg)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env stack | |
| > -- stack --resolver lts-6 --install-ghc runghc --package classy-prelude --package lens --package wreq | |
| Blah Blah words about this single file executable README goes here. | |
| > {-# LANGUAGE DeriveAnyClass #-} | |
| > {-# LANGUAGE DeriveGeneric #-} | |
| > {-# LANGUAGE NoImplicitPrelude #-} | |
| > {-# LANGUAGE OverloadedStrings #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case class IO[A](unsafePerformIO: () => A) { | |
| def map[B](ab: A => B): IO[B] = IO(() => ab(unsafePerformIO())) | |
| def flatMap[B](afb: A => IO[B]): IO[B] =IO(() => afb(unsafePerformIO()).unsafePerformIO()) | |
| def tryIO(ta: Throwable => A): IO[A] = | |
| IO(() => IO.tryIO(unsafePerformIO()).unsafePerformIO() match { | |
| case Left(t) => ta(t) | |
| case Right(a) => a | |
| }) | |
| } | |
| object IO { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE OverlappingInstances #-} | |
| module Main where | |
| import Control.Monad.Free |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Main where | |
| import Data.Foldable | |
| import Control.Concurrent | |
| import Control.Monad | |
| import System.IO.Unsafe | |
| sleepSort :: [Int] -> [Int] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Option<A> { | |
| protected Option() { } | |
| } | |
| interface App<F, A> { | |
| F proof(); | |
| } | |
| class OptionF { | |
| private OptionF() {} | |
| private static class AppOption<A> implements App<OptionF, A> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @flow | |
| /* | |
| "Proof in functions" by @mbrandonw | |
| implemented in JavaScript and using Flow as a static type checker | |
| Original post: | |
| http://www.fewbutripe.com/swift/math/2015/01/06/proof-in-functions.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scala.language.higherKinds | |
| import scala.language.implicitConversions | |
| trait Pt[C[_[_, _]], S, T, A, B] { | |
| def apply[~>[_, _]](ex: C[~>])(p: A ~> B): S ~> T | |
| } | |
| trait Profunctor[~>[_, _]] { | |
| def dimap[X, Y, A, B](f: X => A, g: B => Y)(p: A ~> B): X ~> Y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; 1. place this in ~/.emacs.d/private/intero/packages.el | |
| ;; 2. add intero, syntax-checking and auto-completion to your | |
| ;; ~/.spacemacs layer configuration & remove the haskell layer | |
| ;; if you were using that before | |
| ;; 3. make sure you have stack installed http://haskellstack.org | |
| ;; 4. fire up emacs & open up a stack project's source files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SPC s c remove highlight | |
| **** Files manipulations key bindings | |
| Files manipulation commands (start with ~f~): | |
| | Key Binding | Description | | |
| |-------------+----------------------------------------------------------------| | |
| | ~SPC f c~ | copy current file to a different location | | |
| | ~SPC f C d~ | convert file from unix to dos encoding | | |
| | ~SPC f C u~ | convert file from dos to unix encoding | |