Skip to content

Instantly share code, notes, and snippets.

View tallpeak's full-sized avatar

Aaron William West tallpeak

View GitHub Profile
-- decode.enable1.stm.hs
-- inspired by a word guessing game
-- https://www.futurelearn.com/courses/functional-programming-haskell/1/steps/116475
import qualified Data.ByteString.Lazy as BL
import qualified Data.ByteString as B
import Data.Binary.Get
import Data.Word
@tallpeak
tallpeak / parsing.hs
Created November 22, 2016 15:44
Parsing Stuff in Haskell - London Haskell
-- https://www.youtube.com/watch?v=r_Enynu_TV0
-- Hey, I parsed the largest JSON on my hard drive!
import Text.ParserCombinators.Parsec hiding ((<|>),many)
import Control.Applicative
import Control.Monad
matchTrue :: Parser String
matchTrue = string "true"
alwaysTrue :: Parser Bool
// from http://stackoverflow.com/questions/21194565/null-coalescing-operator-in-f
// modified to support DBNull
open System
let inline isNull value = obj.ReferenceEquals(value, null)
let inline isDBNull value = obj.ReferenceEquals(value, DBNull.Value)
type NullCoalesce =
static member Coalesce(a: 'a option, b: 'a Lazy) = match a with Some a -> a | _ -> b.Value
static member Coalesce(a: 'a Nullable, b: 'a Lazy) = if a.HasValue then a.Value else b.Value
@tallpeak
tallpeak / Livecoding_and_IFsharp.ipynb
Last active August 29, 2015 14:11
Livecoding using IFsharp notebooks
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.