This file contains hidden or 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, TypeFamilies, TypeOperators, GADTs, | |
| ScopedTypeVariables, TypeOperators #-} | |
| -- | Type-level natural numbers and singletons, with proofs of | |
| -- a few basic properties. | |
| module BasicNat ( | |
| -- | Type-level natural numbers | |
| Nat (..) | |
| , type (+) |
This file contains hidden or 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 Arrows #-} | |
| {-# LANGUAGE ConstraintKinds #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE InstanceSigs #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} |
This file contains hidden or 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 TemplateHaskell #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE DeriveFunctor #-} | |
| import Control.Lens | |
| import Prelude hiding (readFile, writeFile, print) | |
| import qualified Prelude as Prelude(readFile, writeFile, print) |
This file contains hidden or 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 CPP #-} | |
| {-# LANGUAGE MagicHash #-} | |
| -- | This module provide fast memchr implemented with ghc primitives. | |
| -- | |
| -- http://lemire.me/blog/2017/01/20/how-quickly-can-you-remove-spaces-from-a-string/ | |
| -- https://graphics.stanford.edu/~seander/bithacks.html | |
| -- https://jameshfisher.github.io/2017/01/24/bitwise-check-for-zero-byte.html | |
| -- | |
| -- |
This file contains hidden or 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 LispParser where | |
| import Text.Megaparsec | |
| import Text.Megaparsec.String | |
| import Text.Megaparsec.Lexer hiding (space) | |
| data E=L[E]|S String|N Integer deriving Show | |
| e=(char '('*>(L<$>some e)<*char ')'<|>N<$>integer<|>S<$>some letterChar)<*space::Parser E |
While thinking about comonads as spaces and Day convolution, I realized an interesting thing. The free applicative functor generated by a comonad f is also a comonad.
The free applicative can be defined in a few different ways, but I like to define it like this:
data FreeApplicative f a = Pure a | Free (Day f (FreeApplicative f) a)
This file contains hidden or 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 Criterion.Main | |
| import System.Random | |
| import Data.List | |
| import qualified Data.Vector.Unboxed as U | |
| rainfall1 :: [Int] -> Int | |
| rainfall1 xs = sum (zipWith (-) mins xs) | |
| where | |
| mins = zipWith min maxl maxr | |
| maxl = scanl1 max xs |
You may want a linter plugin to lint your code in Vim but you probably don't need it. At least try the built-in way before jumping on the plugin bandwagon.
autocmd FileType <filetype> setlocal makeprg=<external command>
This autocommand tells Vim to use <external command> when invoking :make % in a <filetype> buffer. You can add as many similar lines as needed for other languages.