Skip to content

Instantly share code, notes, and snippets.

View rschatz's full-sized avatar

Roland Schatz rschatz

View GitHub Profile
@rschatz
rschatz / gist:738e57f305dfc2082ced
Created January 26, 2015 20:02
different handler monads in haskell-servant
{-# LANGUAGE DataKinds, DefaultSignatures, FlexibleInstances, FunctionalDependencies, TypeFamilies, TypeOperators #-}
import Control.Applicative
import Control.Monad.Trans.Class
import Control.Monad.Trans.Either
import Control.Monad.Trans.Reader
import Data.Proxy
import Network.Wai
@rschatz
rschatz / gist:5ef23f2b1f4055193293
Created February 26, 2015 21:40
playing around with monads in servant
{-# LANGUAGE DataKinds, TypeOperators, OverloadedStrings #-}
import Servant.API
import Servant.Server
import Control.Monad.Trans.Either
import Data.Proxy
import Data.Aeson
data AuthResult = AuthResult { sessionCookie :: String, message :: String }
instance ToJSON AuthResult where
@rschatz
rschatz / webapp.hs
Last active August 29, 2015 14:16
more playing around with servant (featuring different monads and cookies)
-- application specific monads and types
type ServerMonad a
type SessionMonad a
runServerMonad :: ServerContext -> ServerMonad a -> IO (Either (Int,String) a)
authenticated :: AuthData -> SessionMonad a -> ServerMonad a
data AuthData
data AuthResponse a
@rschatz
rschatz / test.cc
Last active August 17, 2018 13:52
small sample C++ program compiled to bitcode
// compile with `clang++ -stdlib=libc++ -emit-llvm -c -O1 -g test.cc -I <path-to-polyglot-h>`
// disassemble with `llvm-dis test.bc`
#include <polyglot.h>
class Test {
public:
Test();
~Test();
static void foo();