main reference:
https://gist.github.com/mtrsk/10a03927490f9edb1f7a2cd72792b0ec
| {-# language InstanceSigs #-} | |
| import GHC.Stack | |
| class Next v where | |
| next :: HasCallStack => v -> v | |
| instance Next Bool where | |
| next :: Bool -> Bool | |
| next x = if x < maxBound then not x else undefined |
| import GHC.Stack | |
| foo :: [Int] -> Int | |
| foo xs = last xs + 1 | |
| bar :: [Int] -> Int | |
| bar xs = foo xs | |
| xs :: [Int] | |
| xs = [] |
| //c++11 | |
| #include<cstdio> | |
| #include<string> | |
| #include<iostream> | |
| using namespace std; | |
| template<typename A> | |
| struct List { | |
| A label; |
| use std::fmt; | |
| enum List<A> { | |
| Nil, | |
| Cons(A, Box<List<A>>), | |
| } | |
| impl<A: fmt::Display> fmt::Display for List<A> { | |
| fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
| match self { |
| import GHC.Stack | |
| import Data.Time.Clock | |
| h0 :: Int -> Int | |
| h0 x = if x == 3 then errorWithoutStackTrace "abuse h" else (x + 3) `div` (x - 3) | |
| h1 :: Int -> Int | |
| h1 x = if x == 3 then withFrozenCallStack . error $ "abuse h" else (x + 3) `div` (x - 3) | |
| timeIt :: IO a -> IO a |
main reference:
https://gist.github.com/mtrsk/10a03927490f9edb1f7a2cd72792b0ec
| /* | |
| Assuming: | |
| 1. l <= r | |
| 2. forall u, v, u < v -> f(u) <= f(v) | |
| So, curve of f should looks like | |
| ______ | |
| f: ___| | |
| So we know: |
| { | |
| "$help": "https://aka.ms/terminal-documentation", | |
| "$schema": "https://aka.ms/terminal-profiles-schema", | |
| "actions": | |
| [ | |
| { | |
| "command": "unbound", | |
| "keys": "ctrl+shift+d" | |
| }, | |
| { |
| const miio = require('miio') | |
| const color = require("cli-color") | |
| miio.device({ | |
| address: '192.168.0.120', | |
| token: '0b806f990d9ca4ff7be7f07f0168dcae' | |
| }) | |
| .then(device => { | |
| console.info(color.green('> Connected to:'), device) | |
| //console.log('Device Props: ', Object.getOwnPropertyNames(device)) |
| import Data.List | |
| import Data.Maybe | |
| import Data.Ratio | |
| import Data.Char | |
| import Control.Monad (liftM2, join, forM_) | |
| import Control.Parallel.Strategies (parMap, rseq) | |
| import Control.Arrow ((&&&)) | |
| import GHC.Exts (groupWith, sortWith) | |
| type Number = Rational | |
| type VarID = Int |