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
| stack exec ghci -- -XTemplateHaskell | |
| :m Language.Haskell.TH | |
| data A = A { a :: Int, b :: String } | |
| $(stringE . show =<< reify 'A) | |
| -- prettified output | |
| DataConI | |
| Ghci12.A ( -- DataConI/Name | |
| AppT ( -- DataConI/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
| " NOTE: depends on fugitive.vim https://github.com/tpope/vim-fugitive | |
| " Show commit on the line | |
| map <Space><Space> 0w:<C-u>execute "Git! show " . expand("<cword>")<CR> |
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 stack | |
| {-# LANGUAGE DeriveGeneric #-} | |
| -- stack --resolver lts-8.4 runghc --package hood | |
| import Debug.Hood.Observe | |
| import GHC.Generics | |
| data Hoge = | |
| Hoge |
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
| #!/bin/env stack | |
| {- stack --resolver=lts-8.19 | |
| runghc | |
| --package=attoparsec | |
| --package=bytestring | |
| --package=unordered-containers | |
| --package=filepath | |
| -} | |
| {- |
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 qualified Control.Foldl as L | |
| -- https://ja.stackoverflow.com/questions/36399/%E3%81%AA%E3%81%9C%E3%81%93%E3%81%AE%E3%82%B3%E3%83%BC%E3%83%89%E3%81%AF%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%83%AA%E3%83%BC%E3%82%AF%E3%81%97%E3%81%BE%E3%81%99%E3%81%8B | |
| -- の問題を、foldlライブラリーを使ってコンスタントなメモリ消費量で計算した例 | |
| main :: IO () | |
| main = do | |
| let points = [(x,y) | x <- range 10000, y <- range 10000] | |
| let all = L.length | |
| let hit = L.handles (L.filtered ((<= 1) . distance)) L.length | |
| let pi h a = fromIntegral h * 4 / fromIntegral 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
| require 'strscan' | |
| class Parser | |
| def initialize string | |
| @scanner = StringScanner.new string | |
| end | |
| def self.eval string | |
| self.new(string).expr |
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
| (() => { | |
| const countFunds = parseInt(document.querySelector('#dataCount>span').innerHTML, 10); | |
| const a = []; | |
| for(let i = 1 ; i <= countFunds ; ++i){ a.push(i); } ; | |
| const funds = a.map((i) => { | |
| return { | |
| name: $(`#positionFundName${i} a`).text(), | |
| price: parseInt($(`#positionAppraisedAmount${i}`).text().replace(/,/g, ''), 10) | |
| }; |
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
| class Parser | |
| def initialize string | |
| @string = string | |
| # To improve performance, increments position instead of modifying @string. | |
| @position = 0 | |
| end | |
| def self.eval string |
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 ConstraintKinds #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE FunctionalDependencies #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE OverloadedLabels #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE TypeFamilies #-} |
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
| let g:neoformat_haskell_mystylishhaskell = { | |
| \ 'exe': 'stylish-haskell', | |
| \ 'args': ['2>nul'], | |
| \ 'stdin': 1, | |
| \ } | |
| let g:neoformat_enabled_haskell = ['mystylishhaskell'] | |
| augroup fmt | |
| autocmd! | |
| autocmd BufWritePre *.hs undojoin | Neoformat mystylishhaskell | |
| augroup END |