Skip to content

Instantly share code, notes, and snippets.

💭
Writing Haskell

YAMAMOTO Yuji igrep

💭
Writing Haskell
Block or report user

Report or block igrep

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@igrep
igrep / fact.js
Last active Jul 30, 2019
Roughly simulate the difference between pointfree style and pointful style. Inspired by https://kakkun61.hatenablog.com/entry/2019/07/29/%E9%96%A2%E6%95%B0%E3%81%AE%E3%83%A1%E3%83%A2%E5%8C%96
View fact.js
/*
fact :: Int -> Integer
fact 0 = 1
fact n = fromIntegral n * fact (n-1)
*/
const fact = function(n){
if (n == 0){
return 1;
} else {
return n * fact(n - 1);
View tempering32Modified.hs
import Data.Bits
import Data.Word
import Data.STRef
import Control.Monad.ST
import Data.Function
import Test.Hspec
import Test.Hspec.QuickCheck
View array-and-pointer.c
#include "stdio.h"
int main()
{
int array[5];
int *p;
int i;
p = array; /* p = &array[0] と同じ */
for (i = 0; i < 5; i++) {
@igrep
igrep / switch-twitter.js
Created Jul 4, 2019
Switch between twitter.com and mobile.twitter.com
View switch-twitter.js
switch(location.hostname){
case 'twitter.com':
location.href = location.href.replace(/^https:\/\/twitter/, 'https://mobile.twitter');
break;
case 'mobile.twitter.com':
location.href = location.href.replace(/^https:\/\/mobile\.twitter/, 'https://twitter');
break;
}
View lens-composition.hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
@igrep
igrep / stack-setup-info.yaml
Created Apr 29, 2019
GHC 8.8.1-alpha1 for stack
View stack-setup-info.yaml
ghc:
macosx:
8.8.0.20190424:
url: https://downloads.haskell.org/ghc/8.8.1-alpha1/ghc-8.8.0.20190424-x86_64-apple-darwin.tar.xz
sha256: 563e34bb2d8a48fa5630136c5acc059bab0e807bf4f02b23d0fbc75f38500feb
windows64:
8.8.0.20190424:
url: https://downloads.haskell.org/ghc/8.8.1-alpha1/ghc-8.8.0.20190424-x86_64-unknown-mingw32.tar.xz
sha256: 1b5ff7995a07e7251b26b3c7dadba57906b7e6d236d0e94c4e92d9b5b8ee3300
@igrep
igrep / git-use-flow.svg
Last active Feb 8, 2019
前職時代、Gitの利用方法を同僚に教えるために作った、Gitを利用する際のフロー
View git-use-flow.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@igrep
igrep / save-enexs.ps1
Last active Jan 7, 2019
Export notes in evernote by date
View save-enexs.ps1
Set-PSDebug -trace 2
$FORMAT = "yyyy-MM-dd"
$QUERY_FORMAT = "yyyyMMdd"
$since = [DateTime]::ParseExact($args[0], $FORMAT, $null)
$until = if ($args[1]) {
[DateTime]::ParseExact($args[1], $FORMAT, $null)
} else {
@igrep
igrep / associative-law.hs
Created Dec 19, 2018
(HAS TYPE ERROR) Test associative law for type-level append (++)
View associative-law.hs
#!/bin/env stack
{-
stack --resolver=lts-12.24 script --package extensible
-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
import Data.Extensible
View parser-fp.rb
class Parser
attr_reader :value
def initialize string, value = nil
@string = string
@value = value
end
def self.eval string
self.new(string).expr.value
You can’t perform that action at this time.