From 1d1f0efc7de1eaa0c8a6b503892c2f950008fde6 Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Tue, 28 Oct 2025 20:14:16 +0100 Subject: wip: port REPL from minilang --- lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs') diff --git a/lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs b/lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs index ad06552..df66113 100644 --- a/lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs +++ b/lambda-calcul/haskell/src/Minilang/Lambda/Unify.hs @@ -1,4 +1,5 @@ -- ported from https://www.cs.cornell.edu/courses/cs3110/2011sp/Lectures/lec26-type-inference/type-inference.htm +{-# LANGUAGE LambdaCase #-} module Minilang.Lambda.Unify where import Data.Text (Text) @@ -12,6 +13,16 @@ data Type infixr 5 :-> +pretty :: Type -> Text +pretty = \case + TyVar x -> x + f :-> g -> + let left = case f of + TyVar _ -> pretty f + _ -> "(" <> pretty f <> ")" + right = pretty g + in left <> " -> " <> right + -- invariant: no identifier on the left hand-side can appear in -- an earlier term in the list, ie. the list is in "dependency order" -- and forms a DAG. -- cgit v1.3.1