Skip to content

Instantly share code, notes, and snippets.

module Web.Scotty.Async
where
import Control.Concurrent (ThreadId, forkIO, newEmptyMVar, putMVar, takeMVar)
import Control.Concurrent.Async (async, Async(..))
import Data.Default (def)
import Network.Wai.Handler.Warp (Port, defaultSettings, setBeforeMainLoop,
setPort)
import Web.Scotty (Options(..), ScottyM, scottyOpts)
@puffnfresh
puffnfresh / SetFunctor.hs
Last active August 29, 2015 13:58
To fmap over a Data.Set just use Coyoneda!
module SetFunctor where
import Data.Functor.Coyoneda
import Data.Set
setF :: Coyoneda Set Int
setF = liftCoyoneda $ fromList [1, 2, 3]
runCoyendaSet :: Ord a => Coyoneda Set a -> Set a
runCoyendaSet (Coyoneda f s) = fromList . fmap f $ toList s
// [ Scala ]
// You need to tell compiler that F, T, and A are of kinds (*, *) -> *, * -> *, and * respectively.
// See all those underscores.
trait Foo[F[_, _], T[_], A] {
def foo: F[T[A], A]
}
// [ Haskell ]
// It can infer kinds from context.
{-# LANGUAGE MultiParamTypeClasses #-}
@cyberdelia
cyberdelia / fabfile.py
Created April 3, 2010 14:05
Fabric deploy script with : south migrations, rollback and maintenance page.
from fabric.api import env, run, sudo, local, put
def production():
"""Defines production environment"""
env.user = "deploy"
env.hosts = ['example.com',]
env.base_dir = "/var/www"
env.app_name = "app"
env.domain_name = "app.example.com"
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name }