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 FlexibleContexts, DeriveFunctor #-} | |
-------------------------------------------------------------------------------- | |
-- It's no secret - Allele Dev enjoys writing Haskell | |
-- | |
-- This is a tiny example of using Free monads + improve. | |
-------------------------------------------------------------------------------- | |
module Control.Teletype where | |
import Control.Monad | |
import Control.Monad.Free |
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
module API.Logging ( | |
-- * Initialize | |
mkLog, | |
-- * Context, Types | |
Context(..), | |
Method(..), | |
Log, | |
-- * Logging |
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
/////////////////////////////////////////////////////////// | |
// shortest: immutable data container with public data // | |
/////////////////////////////////////////////////////////// | |
public class Contact { | |
public final Name name; | |
public final Address address; | |
public final PhoneNumber phoneNumber; | |
public final Email email; | |
public Contact(Name n, Address a, PhoneNumber p, Email em) { |
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 DataKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE TypeOperators #-} | |
-- Findings: almost everything could be inferred |
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
module Boop where | |
class Bee a where | |
meep :: a -> a | |
class Boop a where | |
meep :: a -> Int -> a | |
data Cat | |
= FluffyCat |
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
#!/bin/bash | |
function get { | |
local srcfile="$1" | |
local field="$2" | |
mediainfo "$srcfile" | grep "$field" | head -n 1 | cut -d: -f 2 | xargs | |
} | |
title=$(get "$1" 'Track name ') | |
album=$(get "$1" 'Album') |
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
module TicTacToe ( | |
run | |
) where | |
import Data.Array | |
import Data.Monoid | |
-------------------------------------------------------------------------------- | |
-- Run the Game -- | |
-------------------------------------------------------------------------------- |
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
* Beauty of abstraction: https://twitter.com/queertypes/status/489135228334931968 | |
* Gay for type systems and girls: https://twitter.com/queertypes/status/654351932253978625 |
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
module PartialSuccess where | |
import Control.Applicative | |
import Control.Monad | |
import Data.Either (lefts, rights) | |
import Data.Monoid hiding (All) | |
-------------------------------------------------------------------------------- | |
-- Partial: a data type for tracking success and failure -- | |
-------------------------------------------------------------------------------- |
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
module Main where | |
import Prelude | |
import Control.Monad.Aff (runAff) | |
import Control.Monad.Eff (Eff()) | |
import Control.Monad.Eff.Exception (throwException) | |
-- *very* explicit imports for slightly easier reading in a gist | |
import Data.Maybe (Maybe(Just, Nothing), maybe) |