Skip to content

Instantly share code, notes, and snippets.

View pseudonom's full-sized avatar

Eric Easley pseudonom

View GitHub Profile
@pseudonom
pseudonom / hoogle.sh
Created September 9, 2016 19:18
Bash script to set up local hoogle for all packages in a stack project
#!/bin/bash
set -euxo pipefail
get_project_versions()
{
find . -path ./.stack-work -prune -o -iname '*.cabal' -exec awk '/^version:/ {print $2}' {} \+
}
get_project_names()
{
@pseudonom
pseudonom / main.hs
Last active December 16, 2015 16:41
Example of Yesod handler composition
getUsersR' :: Handler [User]
getUsersR' =
return
[ User 1 "Isaac" "Newton"
, User 2 "Albert" "Einstein"
]
getUsersR :: Handler Value
getUsersR = toJSON <$> getUsersR'
{-# LANGUAGE UndecidableInstances #-}
instance {-# OVERLAPPABLE #-} (ToJSON a) => ToContent a where
toContent = toContent . toJSON
instance {-# OVERLAPPABLE #-} (ToJSON a) => ToTypedContent a where
toTypedContent = TypedContent typeJson . toContent
getUsersR :: Handler [User]
getUsersR =
return
@pseudonom
pseudonom / main.hs
Last active December 21, 2015 22:05
Example of Yesod handler composition
-- Imagine we started with just this route
getUsersR :: Handler Value
getUsersR =
returnJson
[ User 1 "Isaac" "Newton"
, User 2 "Albert" "Einstein"
]
-- If we later try to add the following route without changing the above,
@pseudonom
pseudonom / Lib.hs
Last active December 16, 2015 23:20
Example of Servant handler composition
users :: Handler [User]
users =
return
[ User 1 "Isaac" "Newton"
, User 2 "Albert" "Einstein"
]
firstUser :: Handler User
firstUser = head <$> users
@pseudonom
pseudonom / buildpack
Created April 30, 2014 14:27
ghc-buildpack-with-icu
#!/bin/bash
# bin/compile <build-dir> <cache-dir> <env-dir>
# Heroku-provided params
BUILD_DIR="$1"
CACHE_DIR="$2"
ENV_DIR="$3"
# Default configuration which you can change by setting environment variables
# e.g. heroku config:set CLEAR_BUILDPACK_CACHE=1