Skip to content

Instantly share code, notes, and snippets.

View boj's full-sized avatar

Brian Jones boj

  • Eagle River, Alaska
View GitHub Profile
@boj
boj / Main.asm
Created May 22, 2019 17:31
ghc -ddump-asm Main.hs
==================== Asm code ====================
.section .rodata.str,"aMS",@progbits,1
.align 1
.align 1
$trModule1_r1Lj_bytes:
.asciz "main"
==================== Asm code ====================
@boj
boj / Monoid.hs
Created May 17, 2019 17:00
Prove something is a Monoid
{-# LANGUAGE OverloadedStrings #-}
module Service.TypesSpec where
--------------------------------------------------------------------------------
import Test.Hspec
import Test.QuickCheck
--------------------------------------------------------------------------------
import Data.List (nub)
import Data.Text (Text)
@boj
boj / Service.TypeSpec.hs
Created April 24, 2019 17:24
Fancy Monoids
{-# LANGUAGE OverloadedStrings #-}
module Service.TypesSpec where
--------------------------------------------------------------------------------
import Test.Hspec
import Test.QuickCheck
--------------------------------------------------------------------------------
import Data.List (nub)
import Data.Text (Text)
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad.Reader
data AppContext = AppContext { a :: String, b :: Int }
newtype AppT a = AppT { runAppT :: ReaderT AppContext IO a }
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad.Reader
-- a basic IO function
f :: IO String
f = return "string"
@boj
boj / Lifty.hs
Created February 20, 2019 23:03
module Main where
import Control.Monad.Writer
import Control.Monad.Except
import Data.Functor.Identity
f :: Monad m
=> (String -> String -> m String)
-> String
-> String
@boj
boj / JWT.hs
Created February 20, 2019 22:52
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module Main where
import Control.Monad.IO.Class (MonadIO, liftIO)
import Crypto.JOSE (Error)
import Crypto.JOSE.JWK (JWK)
import Data.Aeson (FromJSON, ToJSON, decode)
@boj
boj / Main.hs
Created February 13, 2019 19:22
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad.IO.Class (liftIO)
import Crypto.JOSE (Error)
import Crypto.JOSE.JWK (JWK)
import Data.Aeson (FromJSON, ToJSON, decode)
import Data.ByteString (ByteString)
@boj
boj / Pav.hs
Created January 4, 2019 18:43
Pav based Haskell typeclasses
module Main where
import Data.Monoid
data Pav a = Pav a | EmptyPav deriving (Show)
instance Semigroup Int where
a <> b = a + b
instance Monoid Int where
mappend a b = a + b
@boj
boj / Meh.hs
Created December 6, 2018 23:48
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Main where
import Control.Monad.IO.Class
import Control.Monad.Reader
newtype A a = A { runA :: IO a } deriving (Functor, Applicative, Monad, MonadIO)
newtype B a = B { runB :: ReaderT () IO a } deriving (Functor, Applicative, Monad, MonadIO)