This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Control.Monad.WeightedSearch as W | |
import Data.List (sortBy) | |
import Data.Ord (comparing) | |
import Control.Applicative | |
data BTree = Leaf | Branch BTree BTree deriving (Show, Eq) | |
-- I can lazily list all the btrees | |
btrees :: W.T Integer BTree | |
btrees = pure Leaf <|> W.weight 1 (Branch <$> btrees <*> btrees) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module M = struct | |
include BasicBlock_types | |
let f X Y Z = () | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
forM_ (zip [0, 2..] (makeForm someUser)) $ \(idx, label_name) -> do | |
createLabel label_name >>= attach idx | |
Entry.entryNew >>= attach (idx+1) | |
where | |
attach idx x = Grid.gridAttach grid x 0 idx 1 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
module Arbitrary.Product where | |
import Test.QuickCheck | |
-- Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ date + date | |
Sun Mar 19 23:30:48 EDT 2017 Mon Mar 20 00:25:05 EDT 2017 | |
+ stack clean + stack clean | |
+ echo 'Build stack (fast)' + echo 'Build stack (fast)' | |
Build stack (fast) Build stack (fast) | |
+ stack build --silent --flag aeson:fast + stack build --silent --flag aeson:fast | |
real 0m17.276s real 0m16.601s | |
user 0m16.753s user 0m16.127s | |
sys 0m0.763s sys 0m0.693s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time stack build --flag aeson:-fast | |
real 2m56.368s real 3m7.390s | |
user 2m55.557s user 2m54.277s | |
sys 0m1.123s sys 0m1.503s | |
time stack ghc -- benchmarks/AesonCompareAutoInstances.hs -O0 | |
real 0m7.939s real 0m11.914s | |
user 0m7.137s user 0m7.927s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Applicative style record composition with Vinyl. | |
> {-# LANGUAGE AllowAmbiguousTypes #-} | |
> {-# LANGUAGE DataKinds #-} | |
> {-# LANGUAGE FlexibleInstances #-} | |
> {-# LANGUAGE MultiParamTypeClasses #-} | |
> {-# LANGUAGE RankNTypes #-} | |
> {-# LANGUAGE ScopedTypeVariables #-} | |
> {-# LANGUAGE TypeApplications #-} | |
> {-# LANGUAGE TypeFamilies #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE DeriveFoldable #-} | |
{-# LANGUAGE UndecidableInstances #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> {-# LANGUAGE DataKinds, FlexibleContexts, FlexibleInstances, | |
> TypeFamilies, MultiParamTypeClasses, UndecidableInstances, | |
> RankNTypes, ScopedTypeVariables, FunctionalDependencies, TypeOperators #-} | |
> | |
> module Zip where | |
> | |
> import Data.Proxy | |
> import GHC.TypeLits | |
Let's first assume that the two nested lists have the same depth. E.g., depth 2: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Knots where | |
import Data.Char (chr, ord) | |
import Data.Foldable (for_) | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
import qualified Data.Set as Set | |
-- See https://en.wikipedia.org/wiki/Combinatorial_map |
OlderNewer