言語拡張は以下の2点。
- クラスにoperator doを定義できるようにする
do 型名 { 変数宣言 <- 値; 値; ...}
という構文の新設
使用イメージは以下のような感じ。
// モナドの型
template <typename T> class MyMonad {
MyMonad(const T& t) {...} // Haskellのpure(return)に相当
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
import Control.Eff | |
import Control.Monad.Free.Reflection | |
import Data.OpenUnion | |
import Data.Typeable | |
-- http://aiya000.github.io/posts/2017-08-22-my-experience-of-eff-convertion.html |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
module Main where |
{-# LANGUAGE PolyKinds, DataKinds, TypeFamilies, TypeOperators, FlexibleInstances, MultiParamTypeClasses #-} | |
{-# LANGUAGE AllowAmbiguousTypes, ScopedTypeVariables, TypeApplications, TypeInType, GADTs, RankNTypes #-} | |
import GHC.Types | |
import Data.Type.Equality | |
import Unsafe.Coerce | |
-- 仮定:Path Induction | |
indEquiv :: | |
forall k (t :: forall (x :: k) (y :: k). (x :~: y) -> Type). |
{-# LANGUAGE BangPatterns #-} | |
{-# LANGUAGE TupleSections #-} | |
module SLang where | |
import Control.Monad.State | |
import Data.Bool | |
import Data.Maybe | |
import Control.Monad.Trans.Iter | |
import Control.Monad.Identity |
言語拡張は以下の2点。
do 型名 { 変数宣言 <- 値; 値; ...}
という構文の新設使用イメージは以下のような感じ。
// モナドの型
template <typename T> class MyMonad {
MyMonad(const T& t) {...} // Haskellのpure(return)に相当
{-# LANGUAGE BangPatterns, Arrows #-} | |
module Main where | |
import Prelude hiding (id, (.)) | |
import Control.Category | |
import Control.Arrow | |
import Control.Monad.Identity | |
import qualified Data.Machine as Mc | |
import Data.Machine ((~>)) | |
import Data.Machine.Mealy |
use std::fmt; | |
const N_VALS : usize = 4; | |
type KeyT = i64; | |
enum BTreeNode<T> | |
{ | |
Nil, | |
Node |