This file contains 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
def tryIt[F[_] : MonadError[String, ?[_]] : MonadState[Int, ?[_]]] = { | |
val attempt = | |
for { | |
_ <- 1.put[F] | |
_ <- "oh noes".raiseError[F, Unit] | |
} yield () | |
attempt.handleError(_ => ().pure[F]) | |
} | |
def tryItSE = |
This file contains 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
{ | |
packageOverrides = super: rec { | |
/* | |
haskell = super.haskell // { | |
compiler = super.haskell.compiler // { | |
ghc801 = super.stdenv.lib.overrideDerivation super.haskell.compiler.ghc801 (oldAttrs: { | |
patches = oldAttrs.patches ++ [./ghc.801.patch]; | |
}); | |
}; | |
}; |
This file contains 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
$ nix-build -E ' | |
let n = import <nixpkgs> {}; hp = n.haskellPackages; l = n.haskell.lib; | |
in hp.aeson | |
' # MAKES HADDOCK | |
/nix/store/rxny4hw6m5hxs69pl27n48whyizx1f1y-aeson-0.11.3.0 | |
$ nix-build -E ' | |
let n = import <nixpkgs> {}; hp = n.haskellPackages; l = n.haskell.lib; | |
in l.dontHaddock (l.doHaddock hp.aeson) | |
' # MAKES HADDOCK |
This file contains 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
source "$stdenv/setup" | |
mkdir -p "$out/bin" | |
cp "$src/strings-replace" "$out/bin" | |
wrapProgram "$out/bin/strings-replace" \ | |
--prefix PATH : "${binutils}/bin" \ | |
--prefix PATH : "${coreutils}/bin" \ | |
--prefix PATH : "${gnugrep}/bin" |
This file contains 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 TemplateHaskell #-} | |
module ClassyPrisms where | |
import Control.Lens.TH (makeClassyPrisms) | |
data Foo = FooA | FooB |
This file contains 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 FlexibleInstances #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE NoImplicitPrelude #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
This file contains 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 NoImplicitPrelude #-} | |
module C12E.Exceptions where | |
import Protolude hiding (catch, onException, uninterruptibleMask) | |
import Control.Monad.Except (MonadError(catchError, throwError)) | |
import Control.Monad.Catch (MonadMask, uninterruptibleMask) |
This file contains 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 --install-ghc runghc --package safe-exceptions --package lens --package mtl | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# OPTIONS_GHC -Wall -Werror #-} | |
import Control.Exception (IOException) |
This file contains 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 | |
FlexibleInstances | |
, GeneralizedNewtypeDeriving | |
, NoImplicitPrelude | |
, OverloadedStrings | |
, RankNTypes | |
#-} | |
module C12E.Validation.ReadV where |
This file contains 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
trait Translate[A, B] { | |
def apply(a: A): B | |
} | |
trait TranslateSyntax { | |
implicit class TranslateOps[A](a: A) { | |
def translate[B](implicit tr: Translate[A, B]): B = tr(a) | |
} | |
} |