Skip to content

Instantly share code, notes, and snippets.

View pedrominicz's full-sized avatar

Pedro Minicz pedrominicz

View GitHub Profile
@pedrominicz
pedrominicz / General.hs
Last active September 21, 2019 19:04
Simply Typed Lambda Calculus with GADTs (doodle made while reading a SO answer).
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
-- https://stackoverflow.com/questions/27831223/simply-typed-lambda-calculus-with-failure-in-haskell
-- https://www.youtube.com/watch?v=6snteFntvjM
module General where
@pedrominicz
pedrominicz / Single.hs
Last active September 21, 2019 19:04
Simply Typed Lambda Calculus with GADTs and Singletons (doodle made while reading code that uses singletons).
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
-- https://stackoverflow.com/questions/27831223/simply-typed-lambda-calculus-with-failure-in-haskell
-- https://www.youtube.com/watch?v=6snteFntvjM
-- https://github.com/goldfirere/glambda/blob/master/src/Language/Glambda/Type.hs
-- https://github.com/goldfirere/glambda/blob/master/src/Language/Glambda/Check.hs
@pedrominicz
pedrominicz / Tree.hs
Last active September 21, 2019 19:05
Unification of Trees (doodle made while reading a tutorial).
module Tree where
-- https://crypto.stanford.edu/~blynn/lambda/hm.html
-- http://hackage.haskell.org/package/base-4.12.0.0/docs/src/Control.Arrow.html#Arrow
import Control.Arrow ((***))
import Control.Monad (join)
import Control.Monad.State
import Text.Parsec hiding (State)
import Text.Parsec.String (Parser)
@pedrominicz
pedrominicz / Infer.hs
Last active September 21, 2019 19:06
Hindley-Milner Type Inference for Lambda Calculus (doodle made while reading a tutorial).
module Infer where
-- https://crypto.stanford.edu/~blynn/lambda/hm.html
import Control.Monad.Reader
import Control.Monad.State
import Data.List (elemIndex)
import Safe (atMay)
@pedrominicz
pedrominicz / Paper.hs
Last active September 21, 2019 21:45
Haskell doodle made while studying unification-fd's source code.
-- This doesn't work correctly.
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeSynonymInstances #-}
@pedrominicz
pedrominicz / .ghci
Last active November 28, 2022 18:15
Glorious GHCi Configuration File!
:set prompt "\x03bb> "
:set prompt-cont " "
:set -Wall
:set -Wcompat
:set -Wincomplete-record-updates
:set -Wincomplete-uni-patterns
:set -Wno-name-shadowing
:set -Wredundant-constraints
@pedrominicz
pedrominicz / Librarian.hs
Last active September 22, 2019 01:54
Attempt to use unification-fd.
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Librarian where
import Control.Monad.Except
@pedrominicz
pedrominicz / Let.hs
Last active September 24, 2019 13:13
Hindley-Milner type inference.
-- https://crypto.stanford.edu/~blynn/lambda/pcf.html
-- http://dev.stephendiehl.com/fun/006_hindley_milner.html
-- https://en.wikipedia.org/wiki/Hindley–Milner_type_system#Free_type_variables
-- https://en.wikipedia.org/wiki/Hindley–Milner_type_system#Algorithm_J
module Let where
import Control.Monad.Except
import Control.Monad.Reader
import Control.Monad.State
@pedrominicz
pedrominicz / Math.hs
Created September 25, 2019 17:04
Simple arithmetic expression parsec.
module Math where
import Text.Parsec
import Text.Parsec.String
data Expr
= Num Integer
| Op Op Expr Expr
deriving Show
@pedrominicz
pedrominicz / Hal.hs
Last active October 5, 2019 23:43
Haskell doodle (dependently typed lambda calculus, very incomplete)
-- https://www.youtube.com/watch?v=AT4JJm_ujRg
-- https://en.wikiversity.org/wiki/Foundations_of_Functional_Programming/Pure_type_systems
module Hal where
import Control.Monad
import Data.Set
type Name = String