Skip to content

Instantly share code, notes, and snippets.

View viercc's full-sized avatar

Koji Miyazato viercc

View GitHub Profile
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: viercc@gmail.com
copyright: Koji Miyazato
@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(
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
module Set where
import Data.List (nub, elem)
@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 GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
-- For the "Another take"
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FunctionalDependencies #-}
Test by executing this line at shell:
$ for i in {1..10}; do ./unix-lock.hs & done
@viercc
viercc / AdHocInstances.hs
Created June 23, 2018 07:54
Defining a instance of class without declaring newtype or instance declaration.
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
module AdHocInstances(
Group(..),
GroupExpr(),
adhocGroup
) where
@viercc
viercc / pairing-functor.lhs
Created June 23, 2018 07:53
I asked a silly question at StackOverflow long ago. This was preparation of the question & self-resolve.
During play around objective package, I noticed following type has interesting property.
> {-# LANGUAGE RankNTypes #-}
> {-# LANGUAGE GADTs #-}
> {-# LANGUAGE TypeOperators #-}
> {-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
> {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
> {-# LANGUAGE UndecidableInstances #-}
>
> import Control.Monad
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Data.Matchable(
-- * Matchable class
Matchable(..),
zipzipMatch,
traverseDefault,
eqDefault,
@viercc
viercc / ApplicativeLaw
Last active January 8, 2018 10:22
ShrinkOnce.hs
Applicative laws (in terms of 'prod'):
prod :: Applicative f => f a -> f b -> f (a,b)
prod = liftA2 (,)
(1) Left unit:
pure a `prod` fb = fmap (a,) fb