Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
import Data.Proxy
import Data.Type.Equality
@Lysxia
Lysxia / P.hs
Last active November 5, 2017 19:19
module P where
import Control.Monad
-- Some monadic parser
newtype P a = P ([Word] -> (a, [Word]))
parse :: P a -> [Word] -> a
parse (P p) xs = fst (p xs)
model name : Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
stack test --ghc-options -O
benchmarking dataList/match
time 958.7 μs (950.1 μs .. 968.5 μs)
0.999 R² (0.999 R² .. 1.000 R²)
mean 974.2 μs (966.0 μs .. 986.5 μs)
std dev 37.51 μs (19.88 μs .. 59.45 μs)
variance introduced by outliers: 28% (moderately inflated)
benchmarking dataList/sub
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Data.Monoid
import GHC.Generics (Generic)
import Test.QuickCheck
import Test.QuickCheck.Function
==================== Tidy Core ====================
2018-02-16 13:58:15.651609941 UTC
Result size of Tidy Core = {terms: 277, types: 955, coercions: 640}
-- RHS size: {terms: 1, types: 0, coercions: 22}
K.$fMonadTransStateT_$clift
:: forall s_a4sc (m_a4id :: * -> *) a_a4ie.
Monad m_a4id =>
@Lysxia
Lysxia / K.hs
Created February 16, 2018 14:25
{-# LANGUAGE Strict #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module K where
import Control.Monad.Trans
import qualified Control.Monad.State.Strict as S
import Control.Monad.Primitive
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Type.Bool
import GHC.TypeLits
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
@Lysxia
Lysxia / hkd-gc.hs
Created April 2, 2018 23:59
HKD deriving ToJSON with generic constraints
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
@Lysxia
Lysxia / hkd-apply.hs
Created April 3, 2018 00:00
HKD deriving ToJSON by encoding quantified constraints
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}