From fc0ede9499a1a768729bb8fe954b6618df05ee15 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 26 Nov 2020 14:16:23 +0100 Subject: [PATCH] Create basic lambda term type --- package.yaml | 2 ++ props.cabal | 7 ++++++- src/Props/Lambda.hs | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/Props/Lambda.hs diff --git a/package.yaml b/package.yaml index d1f1575..5062cc2 100644 --- a/package.yaml +++ b/package.yaml @@ -13,6 +13,8 @@ extra-doc-files: dependencies: - base >= 4.7 && < 5 +- containers +- text library: source-dirs: src diff --git a/props.cabal b/props.cabal index 8063c21..bc459b3 100644 --- a/props.cabal +++ b/props.cabal @@ -4,7 +4,7 @@ cabal-version: 1.18 -- -- see: https://github.com/sol/hpack -- --- hash: 057a536ac3d0fd40b3122084eee53201158527bbcd0dbac7cec33d8fd06cf208 +-- hash: 5e16e68a3016455a93f44cbee36b19144a1a414a8cb0bf4a062a1566b7119a38 name: props version: 0.1.0.0 @@ -23,12 +23,15 @@ extra-doc-files: library exposed-modules: Props + Props.Lambda other-modules: Paths_props hs-source-dirs: src build-depends: base >=4.7 && <5 + , containers + , text default-language: Haskell2010 executable props @@ -40,5 +43,7 @@ executable props ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: base >=4.7 && <5 + , containers , props + , text default-language: Haskell2010 diff --git a/src/Props/Lambda.hs b/src/Props/Lambda.hs new file mode 100644 index 0000000..1b71ce6 --- /dev/null +++ b/src/Props/Lambda.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Props.Lambda + ( Term(..) + , displayTerm + ) where + +import qualified Data.Set as Set +import qualified Data.Text as T + +type Name = T.Text +type PreferredName = Maybe Name + +-- | Lambda calculus term using De Bruijn indexing +data Term a + = Var PreferredName Int + | Lambda PreferredName (Term a) + | App (Term a) (Term a) + | Native a + deriving (Show) + +displayTerm :: (Set.Set Name -> a -> T.Text) -> Term a -> T.Text +displayTerm = undefined