Skip to content

Instantly share code, notes, and snippets.

View err0r500's full-sized avatar

Matthieu Jacquot err0r500

View GitHub Profile
@err0r500
err0r500 / main.hs
Created September 4, 2018 19:18
monadic business logic
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
import Control.Monad.Identity
data User = User
{ name :: String
, firstName :: String
@err0r500
err0r500 / main.hs
Created September 4, 2018 13:30
monad stacking example
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
module Main where
import Control.Monad.Except
import Control.Monad.Reader
import Control.Monad.State
import Control.Monad.Writer
@err0r500
err0r500 / main.hs
Created August 31, 2018 12:27
Haskell monadic typeclass
module Main where
import Control.Monad.Identity
-- boostrap the conditions leading to 2 different implementations of the same business logic
main :: IO ()
main = do
-- use a monad instance as 1st parameter in order to choose the implementation
expectedCalledWithMaybeInstance <- putStrLn $ getFirstName Nothing "heyhey"
expectedCalledWithIOInstance <- putStrLn $ getFirstName (Identity 0) "hoho"
@err0r500
err0r500 / main.go
Last active July 15, 2023 15:27
gin gonic with jwt from auth0 (and CORS enabled)
package main
import (
"github.com/auth0/go-jwt-middleware"
"github.com/dgrijalva/jwt-go"
"gopkg.in/gin-gonic/gin.v1"
)
func main() {
startServer()