Skip to content

Instantly share code, notes, and snippets.

View johnny-shaman's full-sized avatar
:octocat:

Shinichi johnny-shaman

:octocat:
View GitHub Profile
@qnighy
qnighy / rust-patterns.md
Last active March 20, 2024 03:33
Rustのパターンっぽいやつメモ

パターンとはその言語が抽象化できなかった敗北の歴史である。 しかしどんなに優れた言語であってもあらゆる繰り返しに勝てるわけではない。 人は必ずメタ繰り返しを欲するからだ。 そしてそれはRustも例外ではない。

ここでは、OOPでも知られているパターンよりも、Rustに特有のパターンを思いつく限りまとめてみた。名前は適当。

  • crate splitting
    • でかいcrateを分割して、見通しを良くする・再コンパイルの分量を削減する・並列コンパイルを可能にする
  • 親玉crate(全てにdependする)と殿crate(全てにdependされる)があることが多いので、だいたい束みたいな形になる。
@autofyrsto
autofyrsto / 99-touchscreen-rotate.conf
Created June 30, 2017 00:04
Xorg configuration file to rotate touchscreen input 90 degrees right.
Section "InputClass"
Identifier "Coordinate Transformation Matrix"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
MatchDriver "libinput"
Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"
EndSection
@tlareg
tlareg / functor-monad-applicative.js
Last active March 3, 2024 09:43
functor monad applicative
// http://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Base.html
// (f, g, h) => x => h(f(g(x)))
const compose =
(...fns) =>
initial =>
fns.reduceRight(
(result, fn) => fn(result),
initial
)
@badboy
badboy / hkt.rs
Created March 26, 2016 11:33 — forked from 14427/hkt.rs
Higher-kinded type trait
use std::rc::Rc;
pub trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
@14427
14427 / hkt.rs
Last active February 7, 2024 10:18
Higher-kinded type trait
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
@necoco
necoco / flor.coffee
Last active July 30, 2017 05:39
painless FRP library Flor prototype
class FlorContinue
constructor: (key)->
@key = key
class FlorEnd
class Flor
@_id = 1
@generateId = ()->
@kohyama
kohyama / FAM.md
Last active January 28, 2024 11:51
ファンクタ, アプリカティブ, モナド

ファンクタ, アプリカティブ, モナド

はじめに

「そもそも概念が分からない」という方に向けた説明です.
簡略化のため大幅に説明を省略しています. ご容赦ください.
誤りは御指摘いただければ幸いです.

「ファンクタ」, 「アプリカティブ」, 「モナド」 などは Haskell に限定された概念・用語ではありませんが,

@eiel
eiel / maybe.rb
Last active August 1, 2018 00:40
Ruby でモナドしてみる。
# >> を *
# >>= を bind
# return を self.new
# mplus を +
# mzero を self.zero
#
# に見立てて Maybe モナド書いてみた
# bind に渡す block で Maybe と書きたくないので第二引数に型情報を付加してみた。
class Monad
def *(m)