Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Mizunashi Mana mizunashi-mana

💭
I may be slow to respond.
View GitHub Profile
@mizunashi-mana
mizunashi-mana / list.qq
Created Feb 20, 2020
List 関数群の例
View list.qq
module List where
type List : Type -> Type
data List where
Nil : List a
Cons : a -> List a -> List a
type String : Type
type String = List Char
@mizunashi-mana
mizunashi-mana / Fib.qq
Created Jan 12, 2020
An idea of new programming language
View Fib.qq
module Main where
dict Integral a = Integral {
fromInteger: Integer -> a,
+: a -> a -> a,
-: a -> a -> a,
iszero: a -> Bool,
}
impl integralForInteger: Integral Integer
View BitSeq.hs
module BitSeq where
merge :: Int -> [a] -> [a] -> [a]
merge n xs ys = goXs n xs
where
goXs 0 zs = goYs n ys zs
goXs m (z:zs) = z:goXs (m - 1) zs
goXs _ [] = error "unreachable"
goYs 0 zs r = merge (n + 1) r zs
@mizunashi-mana
mizunashi-mana / ExceptionUtil.hs
Created May 28, 2019
try で複数の例外をキャッチしたい場合
View ExceptionUtil.hs
{-# LANGUAGE GADTs #-}
module Control.ExceptionUtil where
import Control.Exception
data TrySelection a where
TrySelection :: Exception e => (e -> a) -> TrySelection a
trySelectionBuilder :: [TrySelection a] -> SomeException -> Maybe a
View MayBreakDerivingVia.hs
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE StandaloneDeriving #-}
module MayBreakDerivingVia where
import Control.Monad.Trans.Reader
newtype T m a = T (Int -> m a)
View PointerRepr.hs
{-# LANGUAGE MagicHash #-}
module Main where
import Unsafe.Coerce
import GHC.Exts
data CompactD = CA | CB | CC
deriving (Show)
View NotSpaceAsciiString.hs
module TestSpace.NotSpaceAsciiString where
import Test.QuickCheck.Arbitrary
import Test.QuickCheck.Gen
import Data.Coerce
import Data.Char (isSpace)
newtype NotSpace = NotSpace Char
deriving (Eq, Ord, Show)
View FoldlStrictness.hs
{-# LANGUAGE BangPatterns #-}
module Main where
import Criterion.Main
import Control.DeepSeq
import Data.Foldable
{-
Result:
View StateVSIORef.hs
{-# LANGUAGE LambdaCase #-}
module Bench.StateVSIORef where
import Data.IORef
import Data.IORef.Unboxed
import Control.Monad.State.Strict
n :: Int