Skip to content

Instantly share code, notes, and snippets.

Daniel P. Brice friedbrice

Block or report user

Report or block friedbrice

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
friedbrice / List.hs
Last active Jul 6, 2019
A functor whose type parameter is nominal.
View List.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RoleAnnotations #-}
module List (List, fromText, list, unList) where
import qualified Data.Text as T
type role List nominal
friedbrice / MakeImpure.hs
Last active Jun 30, 2019
the name is kind of a joke
View MakeImpure.hs
module MakeImpure where
data Key a
class Get a where get :: Key a -> IO a
friedbrice / App.hs
Last active Jun 28, 2019
View App.hs
module App where
import Labels ()
import Types
import Data.Generics.Product.Fields
main :: IO ()
main = do
friedbrice /
Last active Jun 4, 2019 — forked from fiddlerwoaroof/extend.js
Static typable EP solution
import java.util.Map;
// This is almost a solution to the expression problem, except for
// lines 47 and 74.
// Instead of raising an exception, we want the program to fail to
// compile if there are cases that we haven't considered.
class Extend {
// I can define a data structure by cases.
friedbrice / Sets.hs
Last active Jun 3, 2019
Some objecty sets in Haskell
View Sets.hs
module OOP where
import Data.Text (Text)
data Set a = Set {
isEmpty :: Maybe Bool,
contains :: a -> Bool,
intersection :: Set a -> Set a,
union :: Set a -> Set a
friedbrice / lenses-introduction.js
Last active Jun 9, 2019
Javascript has lenses?
View lenses-introduction.js
var danielsLensTalk = {
recordId: 0,
creation: {
user: '',
moment: {
date: {
year: 2019,
month: 5,
day: 29
View BooleanAlgebra.hs
{-# LANGUAGE DerivingVia, TypeApplications #-}
import Prelude hiding ((&&), (||), not)
import qualified Prelude ((&&), (||), not)
class BooleanAlgebra a where
(&&) :: a -> a -> a
(||) :: a -> a -> a
not :: a -> a
true :: a
false :: a
friedbrice / App.hs
Last active May 7, 2019
"Mmm, Cake" or "A Method of Application Wiring for Large-Scale Haskell Programs"
View App.hs
module App where
-- Write the parts of your program that do IO in MTL style,
-- but don't use the `MonadIO` class. -_-
-- This is Layer 2. Layer 3 (not shown) is business logic.
class Foo m where
foo :: String -> m ()
class Bar m where
friedbrice / LoggingExample.hs
Last active May 31, 2019
Decorating pure functions with effects
View LoggingExample.hs
module LoggingExample where
import System.Environment (getArgs)
data MyFoo
instance Read MyFoo
instance Show MyFoo
data MyBar
instance Show MyBar
friedbrice / TheRightWay.hs
Last active Apr 24, 2019
How (and how not) to make testable code in Haskell
View TheRightWay.hs
module TheRightWay where
import Control.Applicative
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.Maybe
myProgram :: Monad m => m String -> (String -> m Int) -> Int -> m String
myProgram readLine parseInt n = do
line <- readLine
You can’t perform that action at this time.