This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleContexts #-} | |
{- | |
runSolve (Arrow (TypeVar 0) (TypeVar 1)) (Arrow (TypeVar 1) (TypeVar 0)) | |
runSolve (Arrow IntType (TypeVar 1)) (Arrow (TypeVar 0) (TypeVar 0)) | |
runSolve (Arrow (Arrow (TypeVar 0) (TypeVar 1)) (TypeVar 2)) (Arrow (TypeVar 3) (Arrow (TypeVar 4) (TypeVar 5))) | |
runSolve (TypeVar 0) (Arrow (TypeVar 0) (TypeVar 1)) | |
runSolve (TypeVar 0) (Arrow (TypeVar 1) (TypeVar 0)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RankNTypes, KindSignatures, TypeOperators, GADTs, ScopedTypeVariables, | |
FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, OverlappingInstances #-} | |
import Data.Functor | |
import Control.Applicative -- for several functor instances | |
-- open union | |
infixr 1 :> | |
data (a :: * -> *) :> b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; See also: https://github.com/yinwang0/old-toys/blob/master/cps.ss | |
(load "prelude.ss") | |
;; Syntax: | |
;; e ::= x | |
;; | c | |
;; | (lambda (x ...) e) | |
;; | (op2 e1 e2) | |
;; | (if e0 e1 e2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; playing with miniKanren! | |
(load "mk.ss") | |
(load "mkextraforms.ss") | |
(load "mkprelude.ss") | |
; data Nat : Set where | |
(define nato | |
(lambda (n) | |
(conde [(zeroo n) succeed] ; zero : Nat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AC2DC () where | |
import Control.Monad (guard) | |
import Control.Applicative ((<$>), (<*>), (<*), (*>)) | |
import Text.ParserCombinators.Parsec | |
type Id = String | |
data ASTree = Prog ASTree ASTree | |
| Dcls [ASTree] | FloatDcl Id | IntDcl Id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* http://ideone.com/wcrspw | |
input: <ORIGIN...> | |
===== | |
<VERSION 1...> | |
===== | |
<VERSION 2...> | |
===== | |
example: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require parser-tools/lex | |
(prefix-in : parser-tools/lex-sre) ; prefix RE operators by `:` | |
racket/match | |
racket/format) | |
;;;;;;;;;;;;;;; regular expressions ;;;;;;;;;;;;;;; | |
(define-lex-abbrevs | |
(:letter (:or (char-range "A" "Z") (char-range "a" "z"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module numeral where | |
infixl 40 _∘_ | |
infixr 60 1+ⁿ_ | |
-- small prelude | |
_∘_ : {A B C : Set} → (B → C) → (A → B) → A → C | |
f ∘ g = λ x → f (g x) | |
data ℕ : Set where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
data AllType = TypeA Char | |
| TypeB String | |
| TypeC Bool | |
deriving (Show) | |
newtype S = S { unS :: String } | |
data Ii = Ii { runIi :: [AllType] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleContexts #-} | |
module Language.BLang.Homework.Homework3 ( | |
AST, | |
printAST, | |
fromAST | |
) where | |
import Control.Monad (mapM, when) | |
import Control.Monad.State (MonadState, MonadIO, liftIO, runStateT, get, modify) |