Skip to content

Instantly share code, notes, and snippets.

View lotz84's full-sized avatar

Tatsuya Hirose lotz84

View GitHub Profile
@YusukeHosonuma
YusukeHosonuma / CSVFormatter.hs
Last active August 22, 2016 00:45
CSVFormatter.hs
-- CSVFormatter.hs
{-
Input:
Name,Birthday,Height
Suzukaze Aoba,2/2,149cm
Ko Yagami,8/2,164cm
Rin Toyama,12/3,158cm
@Icelandjack
Icelandjack / Constraints.org
Last active April 2, 2024 20:22
Type Classes and Constraints

Reddit discussion.

Disclaimer 1: Type classes are great but they are not the right tool for every job. Enjoy some balance and balance to your balance.

Disclaimer 2: I should tidy this up but probably won’t.

Disclaimer 3: Yeah called it, better to be realistic.

Type classes are a language of their own, this is an attempt to document features and give a name to them.

@asufana
asufana / Swagger入門.md
Last active June 7, 2020 00:26
Swagger入門

Swagger入門

Swaggerをつかってマシンリーダブルな環境を整備する

0. API仕様記述について

  • 全てがJSONになる
    • マシンリーダブルなAPI仕様の記述フォーマットが整備されればこんな喜ばしい未来が
@ericclemmons
ericclemmons / example.md
Last active September 20, 2024 12:46
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 Summary Goes Here
@phadej
phadej / overlap.hs
Created July 1, 2016 09:56
OverlappingInstance workarounds
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}
{-# LANGUAGE DataKinds, GADTs, KindSignatures, TypeOperators, UndecidableInstances #-}
#if __GLASGOW_HASKELL__ < 708
#error "requires GHC 7.10 or newer"
#endif
module Main (main) where
@phadej
phadej / existential-constraint.hs
Created June 16, 2016 09:58
This is short gist about problem I run today into, and it's solution. It feels that probably I'm over engineering stuff, so: please comment!
#!/usr/bin/env stack
-- stack --resolver=lts-6.0 runghc --package constraints --package mtl --package lens --package text --package time
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, ConstraintKinds, UndecidableInstances, ScopedTypeVariables, InstanceSigs, OverloadedStrings, TemplateHaskell #-}
-- This is short gist about problem I run today into,
@phadej
phadej / poly-nfdata.hs
Last active November 6, 2017 22:24
Example how is possible to write polykinded type-classes in GHC-8.0. It's not that bad or messy, but I'm not sure it's practical either.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
@luciferous
luciferous / Main.hs
Last active July 16, 2016 06:18
STM example
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Network ( withSocketsDo, listenOn, PortID(..) )
import Network.Socket ( accept, close, recv, send, Socket )
import Control.Concurrent ( forkIO, threadDelay, ThreadId )
import Control.Concurrent.STM ( atomically
, orElse
, newTChan
, readTChan
@nh2
nh2 / GenericsTypeName.hs
Last active May 5, 2020 15:21
Getting the name of a type with GHC.Generics
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
module GenericsTypeName
( TypeName(..)
, readBS
) where
import Data.ByteString (ByteString)
@PkmX
PkmX / loeb.md
Last active January 9, 2019 15:59
Löb with error handling

Löb with error handling

löb is a well-known function in Haskell for implementing spreadsheet-like behaviors and tying the knot. It is defined as:

loeb :: Functor f => f (f a -> a) -> f a
loeb fs = xs
  where xs = fmap ($ xs) fs