Skip to content

Instantly share code, notes, and snippets.

View pangaea.hs
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Monad.Random.Class
import Control.Monad.Reader
import Data.Foldable (for_)
import Graphics.Rendering.Cairo hiding (x, y)
import qualified Numeric.Noise.Perlin as P
import System.Random
View oof.sql
select (
ident || 'StandardCode :: StandardCode' || E'\n' || ident || 'StandardCode = "' || standard_code || '"' || E'\n' || E'\n' ||
ident || 'StandardId :: StandardId' || E'\n' || ident || 'StandardId = StandardKey "' || standard_id || '"' || E'\n'
) FROM
(select
(case when school_grade=1 then 'one'
when school_grade=2 then 'two'
when school_grade=3 then 'three'
when school_grade=4 then 'four'
when school_grade=5 then 'five'
View Main.hs
{-# LANGUAGE LambdaCase #-}
module Main where
import Control.Applicative
import Data.Foldable
import Data.List.Split
import Data.Maybe (fromMaybe, mapMaybe)
import Safe
@5outh
5outh / persistent-mysql.hs
Created Feb 13, 2017
persistent-mysql example
View persistent-mysql.hs
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Types
import Database.Persist.MySQL
import Control.Monad.Logger
import Control.Monad.IO.Class
@5outh
5outh / persistent-postgresql.hs
Created Feb 13, 2017
persistent-postgresq example
View persistent-postgresql.hs
{-# LANGUAGE OverloadedStrings #-}
import Types
import Database.Persist.Postgresql
import Control.Monad.Logger
import Control.Monad.IO.Class
printIO :: (MonadIO m, Show a) => a -> m ()
printIO = liftIO . print
@5outh
5outh / mysql-simple.hs
Created Feb 11, 2017
mysql-simple example
View mysql-simple.hs
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
module Main where
import Control.Monad.State
import Control.Monad.Reader
import Data.Text
import Database.MySQL.Simple
View postgresql-simple.hs
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.State
import Control.Monad.Reader
import Data.Text
import Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple.FromRow
import Database.PostgreSQL.Simple.ToRow
import Data.Maybe (fromJust)
@5outh
5outh / natstyle.hs
Created Oct 17, 2016
Style proposal
View natstyle.hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import Control.Monad.Morph
import Control.Monad.Reader hiding (reader)
import Control.Monad.State hiding (state)
import Control.Monad.Except
import Control.Monad.IO.Class
View Rational.idr
data Rational : Nat -> Nat -> Type where
MkRational : (a : Nat) -> (b : Nat) -> Rational a b
MultRat : Rational a b -> Rational c d -> Rational (a*c) (b*d)
DivRat : Rational a b -> Rational c d -> Rational (a*d) (b*c)
AddRat : Rational a b -> Rational c d -> Rational (a*d + b*c) (b*d)
Simplify : Rational a b -> Rational (divNat a (gcd a b)) (divNat b (gcd a b))
||| λΠ> :t Simplify (DivRat (MkRational 770 30) (MkRational 3 4))
||| Simplify (DivRat (MkRational 770 30) (MkRational 3 4)) : Rational 308 9
View dollabillz.hs
map ($ 1000) [(+10), (*800), (/300)]
-- [1010.0,800000.0,3.3333333333333335]
foldr ($) 8 [(+5), (*2)]
-- 21
-- (8 * 2 + 5)