Skip to content

Instantly share code, notes, and snippets.

View viercc's full-sized avatar

Koji Miyazato viercc

View GitHub Profile
Test by executing this line at shell:
$ for i in {1..10}; do ./unix-lock.hs & done
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
-- For the "Another take"
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FunctionalDependencies #-}
@viercc
viercc / narrowed-down.hs
Last active October 16, 2018 06:47
GHC's behavior is strange on this code
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main(main) where
import Data.Proxy
class Same x y where
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
module Set where
import Data.List (nub, elem)
@viercc
viercc / AutoLift.hs
Last active January 13, 2019 09:25
Automatically upgrade `∀a. Show a => Show (f a)` to `Show1 f`
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE QuantifiedConstraints #-}
module AutoLift(
name: bundle
version: 0.1.0.0
synopsis: Solve bundling problem
-- description:
homepage: https://github.com/minkless/sudoku#readme
license: BSD3
license-file: LICENSE
author: Koji Miyazato
maintainer: [email protected]
copyright: Koji Miyazato
@viercc
viercc / ProofOfContEq.md
Last active January 23, 2019 03:25
On How to define Eq on Cont r a

Let's define a type class Searchable.

class Searchable a where
    epsilon :: (a -> Bool) -> a

    -- [Law]
    --  (∃x :: a. p a == True) => p (epsilon p) = True

We want to show that the following instance is valid.

@viercc
viercc / flexible-instances-in-wild.md
Last active October 5, 2019 01:03
Flexible Instances I have found in wild
class Foo()
// フィールドが一つもないクラスを定義し、そのクラスのオブジェクトを作ると
// コンパイラ自体がSegmentation Faultを起こす
//@one_field = 0
@function g()
ans = "0"
return ans
x = Foo()
@viercc
viercc / w.hs
Created November 9, 2019 11:56
That's not ~~intuitive~~ intuitionistic
{-
@lexi_lambda (at twitter)
https://mobile.twitter.com/lexi_lambda/status/1192930938537332736?s=19
-}
{-# LANGUAGE RankNTypes #-}