Skip to content

Instantly share code, notes, and snippets.

View viercc's full-sized avatar

Koji Miyazato viercc

View GitHub Profile
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE GADTs #-}
module CoerceUnder where
@viercc
viercc / StrangeFilterable.hs
Created October 6, 2021 01:12
StrangeFilterable.hs
{-# LANGUAGE DeriveTraqversable #-}
import Witherable
newtype T a = MkT [a]
deriving (Show, Eq, Functor, Foldable, Traversable)
instance Filterable T where
-- ひとつでもNothingがあれば空リスト、
-- すべてJustならJustを除いた元のリスト
catMaybes tpa = case sequenceA tpa of

Q: Is there an instance Monad ZipList compatible with Applicative ZipList?

A: No.

Proof.

Use these definitions

(<&>) :: Functor f => f a -> (a -> b) -> f b
@viercc
viercc / Logistic.hs
Last active November 20, 2021 16:38
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
module Logistic where
import Data.Kind ( Type )
import Data.Functor.Const
import Data.Functor.Contravariant
@viercc
viercc / angles.hs
Last active December 10, 2021 11:25
プログラム
#!/usr/bin/env cabal
{- cabal:
build-depends: base, vector
-}
module Main where
import Data.Foldable (foldl')
import Control.Monad (guard)
import qualified Data.Vector.Unboxed as V
@viercc
viercc / gist:37b66810257fce0489c7ffff05fbb873
Last active February 4, 2022 05:01
反対圏でのstrength
{-# LANGUAGE
GADTs,
RankNTypes,
PolyKinds,
DataKinds,
ScopedTypeVariables,
StandaloneKindSignatures
#-}
module DiscreteCategory where
#!/usr/bin/env cabal
{- cabal:
build-depends: base, vector, process
-}
module Main where
{-
検算
@viercc
viercc / git-status-to-check-nothing-to-commit
Created July 13, 2022 05:01
Using git-status to tell if it's "nothing-to-commit" status
$ ls
foobar.txt hoge.txt piyo.txt
$ git status
ブランチ main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: hoge.txt
追跡されていないファイル: