Skip to content

Instantly share code, notes, and snippets.

mkModalBindings :: XConfig l -> String -> [(String, X ())] -> X ()
mkModalBindings conf exitBind xs = enterMode
where
xs' = map (\(bind,action) -> (bind,action >> enterMode)) xs
keymap = mkKeymap conf ((exitBind,return ()) : xs')
enterMode = submapDefault enterMode keymap
{-# LANGUAGE BangPatterns #-}
import Control.DeepSeq
markList n = [1..n]
josephus :: Int -> [(Int,Int)]
josephus 1 = []
josephus n = playJosephus 0 n (markList n)
where playJosephus !k !m filterList
| null (tail filterList) = []
| otherwise = (filterList!!(k `mod` m),filterList!!((k+1) `mod` m)):playJosephus ((k+1) `mod` m) (m-1) ((take ((k+1) `mod` m) filterList) ++ (drop ((k+1) `mod` m +1) filterList))
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ViewPatterns #-}
import Control.DeepSeq
markList n = [1..n]
josephus :: Int -> [(Int,Int)]
josephus 1 = []
josephus n = playJosephus 0 n (markList n)
where
playJosephus !k !m filterList
| null (tail filterList) = []
@wz1000
wz1000 / induction
Last active October 10, 2018 22:00
data Nat = Z | S Nat
data SNat (n :: Nat) where
SZ :: SNat Z
SS :: SNat n -> SNat (S n)
class Reify (n :: Nat) where
reify :: SNat n
instance Reify Z where
./A.hs:
module Main where
main = print "test"
./cabalnewbuild-test.cabal:
name: cabalnewbuild-test
version: 0.1.0.0
license: BSD3

No .hie

make -j2  585.74s user 62.01s system 179% cpu 6:00.20 total
make -j2  578.69s user 60.92s system 180% cpu 5:54.49 total
$ du -sh ./compiler/stage2/
356M

With .hie

@wz1000
wz1000 / example.hs
Last active December 25, 2018 10:44
module A where
f :: Show a => a -> String
f x = show [(x,True)]
[1 of 1] Compiling A ( b.hs, nothing )
Evidence of Show [(a, Bool)]
Constructed using:
---------------------
Evidence of Show a
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE DataKinds #-}
module GFunctor where
import Prelude hiding ((.),id)
import GHC.Types
test.hs:27:32: error:
• Illegal type synonym family application ‘Ary n’ in instance:
Category @{* -> Ary n} (Arr ('S n))
• In the instance declaration for ‘Category (Arr (S n))’
|
27 | instance (Category (Arr n)) => Category (Arr (S n)) where