Skip to content

Instantly share code, notes, and snippets.

View lotz84's full-sized avatar

Tatsuya Hirose lotz84

View GitHub Profile
@jtobin
jtobin / pp-comonad.hs
Created October 27, 2016 00:57
Probabilistic programming using comonads.
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
import Control.Comonad
import Control.Comonad.Cofree
import Control.Monad
import Control.Monad.ST
anonymous
anonymous / Main.hs
Created January 16, 2017 12:33
-- Deep Learning from Scratch
-- Chapter 01
module Ch01.Main where
import Prelude hiding (lookup)
import Control.Monad
main :: IO ()
main = do
-- 算術計算
@chrisdone
chrisdone / FieldTH.hs
Last active February 13, 2017 22:17
$(lens 'foo) -- handy one-off lens maker for record fields
{-# LANGUAGE TemplateHaskell #-}
-- | For when you have a record that doesn't have lenses derived for
-- it and you need a lens, just use @$(lens 'thefield)@ and away you go.
module Control.Lens.FieldTH where
import Language.Haskell.TH
lens :: Name -> Q Exp
lens name = do
[|\f r ->
fmap
$(lamE
@matsu-chara
matsu-chara / FieldNameAndValuePorter.scala
Last active March 13, 2017 06:09
get field name of case class and get type checked new value. (scalameta 1.6.0, paradise 3.0.0-M7)
package scalaworld.macros
package com.folio.account.macros
import scala.collection.immutable.Seq
import scala.meta._
/**
* annotation for case class.
*
@matsu-chara
matsu-chara / gateaway.scala
Last active May 23, 2017 01:42
finatra風?コントローラ
import com.twitter.util.Future
import scala.reflect.ClassTag
// generated code
case class FooReqThrift(value: Int)
case class ThriftException(message: String, cause: Throwable) extends RuntimeException(message, cause)
// libs
abstract class RequestAdapter[ReqThrift, ReqDto] {
def adapt(a: ReqThrift): Future[ReqDto]
@morishin
morishin / spv.md
Last active December 22, 2017 17:08

※図は Mastering Bitcoin (PDF) からの引用

SPV (Simplified Payment Verification) を支える技術

Bitcoin クライアントの種類

node_types

UTXO (Unspent Transaction Output)

  • ビットコインウォレットの残高は、ビットコインネットワークから自分のビットコインアドレスが output になっているトランザクションの情報 UTXO (Unspent Transaction Output) を集めて金額を合計したもの
  • ビットコインで支払うぞってなったら、集めて使おうとしてる UTXO が本当にまだ使われてないかをチェックする必要がある
  • UTXO が使われていないかどうかの検証は、そのトランザクションより下の全てのブロックに含まれる全てのトランザクションをチェックする
  • 全部集めるにはブロックチェーン全部をダウンロードして探索しないといけない?
@voluntas
voluntas / death_march.md
Last active May 30, 2025 01:53
デスマーチが起きる理由 - 3つの指標

デスマーチが起きる理由 - 3つの指標

著者: 青い鴉(ぶるくろ)さん @bluecrow2

これは結城浩さんの運用されていた YukiWiki に当時 Coffee 様 (青い鴉(ぶるくろ)さん)がかかれていた文章です。 ただ 2018 年 3 月 7 日に YukiWiki が運用停止したため消えてしまいました。その記事のバックアップです。

今は 404 ですが、もともとの記事の URL は http://www.hyuki.com/yukiwiki/wiki.cgi?%A5%C7%A5%B9%A5%DE%A1%BC%A5%C1%A4%AC%B5%AF%A4%AD%A4%EB%CD%FD%CD%B3 になります。

昔、自分がとても感銘を受けた文章なので、このまま読めなくなるのはとてももったいないと思い、バックアップとして公開しています。

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Icelandjack
Icelandjack / Yoneda.markdown
Last active February 10, 2023 00:06
Yoneda
import Data.Functor.Yoneda
import Data.Char
import Data.Kind

infixr 5
  ·

type  List :: (Type -> Type) -> Constraint
class List f where
@Icelandjack
Icelandjack / Yoneda_II.markdown
Last active April 8, 2024 11:08
Yoneda Intuition from Humble Beginnings

(previous Yoneda blog) (reddit) (twitter)

Yoneda Intuition from Humble Beginnings

Let's explore the Yoneda lemma. You don't need to be an advanced Haskeller to understand this. In fact I claim you will understand the first section fine if you're comfortable with map/fmap and id.

I am not out to motivate it, but we will explore Yoneda at the level of terms and at the level of types.