Skip to content

Instantly share code, notes, and snippets.

Sanshiro Yoshida halcat0x15a

Block or report user

Report or block halcat0x15a

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
View gist:f069da664105c184d038823a3f970f11
# 値によって変わる型
[@halcat0x15a](https://twitter.com/halcat0x15a)
---
## 今日はなすネタ
面白そうなツイートを見つけた
View pi.py
import os
import re
import time
import picamera
import slack
import RPi.GPIO as GPIO
SERVO_OUT = 2
IMAGE_FILENAME = 'test.jpg'
RECORDING_FILENAME = 'test.h264'
View EffAp.hs
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds, PolyKinds #-}
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FlexibleContexts #-}
module EffAp where
import Control.Concurrent
import Control.Concurrent.Async
import OpenUnion
View ginza_lunch.txt
八十吉 https://goo.gl/maps/xcB9bywSuVH2
パリのワイン食堂 https://goo.gl/maps/xyGtCvkXEkC2
Yellow Spice https://goo.gl/maps/EgZtWRshyNz
牛庵 https://goo.gl/maps/9SupA9A3a4m
にし邑 https://goo.gl/maps/crmh17r1kSo
築地きたろう https://goo.gl/maps/8mcNNPy37tS2
ピラミッド https://goo.gl/maps/epHvBkLVcg52
むぎとオリーブ https://goo.gl/maps/k1PjHkyrCPm
だいつねうどん https://goo.gl/maps/wi8ZrD1PM3J2
東京油組総本店 https://goo.gl/maps/UC7q3M9bnCv
View kirara.scala
package starlight
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.FileIO
import akka.stream.scaladsl.Source
import java.awt.RenderingHints
import java.awt.image.BufferedImage
View parser.rs
extern crate regex;
use regex::Regex;
#[derive(Debug)]
enum ParseResult<T> {
Success { result: T, next: String },
Failure
}
impl<T> ParseResult<T> {
View typeclassinstance.md

一つの型に対して2つのインスタンスを提供する

  • 値のwrap/unwrapがない
  • インスタンスの定義が単純
  • インスタンスが一意に定まらない

コンパニオンオブジェクトの同一階層に複数のimplicit valueを定義した場合

  • importが必須
  • エラーがわかりづらい(could not find implicit value)
View GADTs.scala
object GADTs {
sealed trait Data1[A]
case class Constructor1() extends Data1[Int]
sealed trait Data2 { type T }
case class Constructor2() extends Data2 { type T = Int }
def f1[A](data: Data1[A]): A = data match { case Constructor1() => 0 }
//def f2[A](data: Data2 { type T = A }): A = data match { case Constructor2() => 0 }
View recur.scala
import scala.annotation.tailrec
sealed abstract class Var {
def walk(subst: Subst): Var = {
@tailrec
def go(v: Var, stack: List[Var], acc: Option[Var]): Var =
v match {
case Unbound(k) =>
subst.get(k) match {
View queue.scala
import scala.annotation.tailrec
sealed abstract class Queue[U <: Union, -A, +B] {
def apply(a: A): Free[U, B] = {
@tailrec
def go(tpe: { type T })(arrows: Queue[U, tpe.T, B], value: tpe.T): Free[U, B] =
arrows.view match {
case One(f) => f(value)
case cons@Cons() =>
You can’t perform that action at this time.