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
| data Todo = Todo { | |
| id :: Text, | |
| created :: UTCTime, | |
| title :: Text, | |
| description :: Text, | |
| priority :: Int | |
| } | |
| data Command | |
| = Add Main.Todo |
Laws that apply to our industry (and others) are interesting to me, and I'm writing up here the ones that often come to mind. I usually forget the name, so writing them up might be helpful for remembering in future.
C. Northcote Parkinson's law: Work expands so as to fill the time available for its completion. Similarly, in computing, data expands to fill the space available for storage,
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
| #!/usr/bin/env hell | |
| -- How to run this: | |
| -- | |
| -- socat TCP-LISTEN:8081,fork,reuseaddr,max-children=20 EXEC:"./handler.hell" | |
| main = do | |
| line <- Text.getLine | |
| let content = | |
| Text.concat ["<h1>Hello, World!</h1><p>This is generated by Hell.</p><pre>", line, "</pre>"] |
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
| {- | |
| Examples: | |
| > reify @Int $ eval $ A (reflect (abs :: Int -> Int)) (I (-9)) | |
| 9 | |
| > reify @Int $ eval $ A (A (reflect ((*) :: Int -> Int -> Int)) (reflect @Int 3)) (reflect @Int 5) | |
| 15 |
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
| -- Credit to: https://news.ycombinator.com/item?id=15186988 | |
| let iterate | |
| : (Natural → Natural) → Natural → Natural | |
| = \f n -> | |
| fold (n + 1) f 1 | |
| let increment : Natural → Natural = \n -> n + 1 | |
| let ackermann |
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
| extern crate time; | |
| use std::fs::File; | |
| use std::io::prelude::*; | |
| fn main() { | |
| let mut inpt = File::open("input/xmas5.txt").expect("file not found"); | |
| let mut content = String::new(); | |
| inpt.read_to_string(&mut content).unwrap(); | |
| let tm = time::now(); |
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 NamedFieldPuns #-} | |
| -- The Expression Problem and my sources: | |
| -- http://stackoverflow.com/questions/3596366/what-is-the-expression-problem | |
| -- http://blog.ontoillogical.com/blog/2014/10/18/solving-the-expression-problem-in-clojure/ | |
| -- http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/ | |
| -- http://www.ibm.com/developerworks/library/j-clojure-protocols/ | |
| -- To begin demonstrating the problem, we first need some |
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 OverloadedLabels, TypeOperators, DataKinds, FlexibleContexts #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| import Labels | |
| import Labels.Cassava | |
| import Data.Vector ( Vector ) | |
| import Data.Text ( Text ) | |
| import Data.Text.Lazy.Encoding | |
| import qualified Data.Text.Lazy as LT | |
| import Data.Csv hiding ( decodeByName ) | |
| import Data.Csv.Streaming |
NewerOlder