Skip to content

Instantly share code, notes, and snippets.

@mankyKitty
mankyKitty / gist:10569173
Last active August 29, 2015 13:59
Trying to grok Functor for (a -> m b) type....thingy
-- Working through the Yorgey lectures on Applicatives for Haskell and trying to work out the homework...
-- A parser for a value of type a is a function which takes a String
-- represnting the input to be parsed, and succeeds or fails; if it
-- succeeds, it returns the parsed value along with the remainder of
-- the input.
newtype Parser a = Parser { runParser :: String -> Maybe (a, String) }
-- For example, 'satisfy' takes a predicate on Char, and constructs a
-- parser which succeeds only if it sees a Char that satisfies the
@domgetter
domgetter / hash_compose.rb
Last active August 29, 2015 14:23
Hash#compose
# Since a key-value store is a finite, discrete function, and functions
# can be composed, then Hashes can be composed.
#
# The syntactic sugar for calling lambdas, accessing array values, and
# other objects which have a #[] method allow composition of Hashes
# with all sorts of objects and contexts with the same implementation.
#
# Play with it at https://eval.in/388458
#
class Hash
@andrewthad
andrewthad / hack_the_reader.hs
Created November 1, 2017 13:02
Benchmark queries in yesod
instance YesodPersist App where
type YesodPersistBackend App = SqlBackend
runDB action = do
master <- getYesod
runSqlPool (hackTheReader action) $ appConnPool master
newtype BenchmarkResults = BenchmarkResults [(Text,TimeSpec)]
deriving Typeable
type TypeMap = HashMap TypeRep Dynamic
DROP DATABASE IF EXISTS animalsdb;
CREATE DATABASE animalsdb;
\c animalsdb;
-- We're modeling the following Haskell datatype:
--
-- data Animal = Cat Name Age | Dog Name OwnerId
--
-- We're going to factor the common 'Name' field into the animal table.
@queertypes
queertypes / FreeCoFree.hs
Created June 5, 2015 17:11
Exploring Free Monads, Cofree Comonads, and Pairings: DSLs and Interpreters
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-
Explores Free Monads (DSLs) and Cofree Comonads (interpreters) and
their relationship.
Most of the code in this file comes from (1) below. Only minor
modifications are made - semantics are preserved.
@bishboria
bishboria / springer-free-maths-books.md
Last active April 25, 2024 06:27
Springer made a bunch of books available for free, these were the direct links