added some build stuff

master
Rachel Lambda Samuelsson 2022-01-23 12:52:33 +01:00
parent a55ff128af
commit f0c44b9477
6 changed files with 76 additions and 9 deletions

3
.gitignore vendored 100644
View File

@ -0,0 +1,3 @@
Makefile
Hm
dist-newstyle

7
LICENSE 100644
View File

@ -0,0 +1,7 @@
ISC License
Copyright 2022 depsterr <depster at protonmail dot com>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

2
app/Main.hs 100644
View File

@ -0,0 +1,2 @@
main :: IO ()
main = pure ()

31
hm.cabal 100644
View File

@ -0,0 +1,31 @@
cabal-version: 2.4
name: hm
version: 0.1.0.0
synopsis: toy programming language
-- description:
homepage: https://githug.xyz/depsterr/hm
-- bug-reports:
license: ISC
license-file: LICENSE
author: depsterr
maintainer: depsterr@protonmail.com
-- copyright:
category: Programming Language
library
ghc-options: -Werror=incomplete-patterns -Wall -fno-warn-name-shadowing
, Simple.CC
build-tool-depends: alex:alex >= 3.0, happy:happy >= 1.19.5
build-depends: base >=4
, array
, containers
, transformers
, mtl
hs-source-dirs: src
default-language: Haskell2010
executable sexprml
main-is: Main.hs
build-depends: base >=4, hm
hs-source-dirs: app
default-language: Haskell2010

26
hm.cf
View File

@ -1,4 +1,6 @@
layout toplevel ;
layout "let" ;
layout stop "in" ;
entrypoints [Def], Exp ;
@ -7,12 +9,14 @@ token Id ((letter|digit|["[]_"])+) ;
comment "--" ;
comment "{-" "-}" ;
TypeDef. Def ::= "type" TypeSig1 "|" [Decl] ;
TypeDef. Def ::= "type" TypeSig1 [Decl] ;
VarDef. Def ::= Id ":" TypeSig ":=" Exp ;
separator Def ";" ;
Decl. Decl ::= Id ":" TypeSig ;
separator nonempty Decl "|" ;
Decl. Decl ::= Id ":" TypeSig ;
[]. [Decl] ::= ;
(:). [Decl] ::= "|" Decl [Decl];
-- todo custom [Decl]
TypeFun. TypeSig ::= TypeSig1 "" TypeSig ;
TypeApp. TypeSig1 ::= Id [TypeSig2] ;
@ -21,12 +25,16 @@ coercions TypeSig 2;
separator nonempty TypeSig2 "" ;
ExpTyped. Exp ::= Exp1 ":" TypeSig ;
ExpAbs. Exp1 ::= "λ" [Id] "." Exp2 ;
ExpApp. Exp2 ::= Exp3 [Exp3] ;
ExpVar. Exp3 ::= Id ;
ExpLet. Exp ::= "let" "{" [Assign] "}" "in" Exp2 ;
ExpTyped. Exp1 ::= Exp2 ":" TypeSig ;
ExpAbs. Exp2 ::= "λ" [Id] "." Exp3 ;
ExpApp. Exp3 ::= Exp4 [Exp4] ;
ExpVar. Exp4 ::= Id ;
separator nonempty Exp3 "" ;
coercions Exp 3;
Assign. Assign ::= Ident "=" Exp1 ;
separator nonempty Assign ";" ;
separator nonempty Exp4 "" ;
coercions Exp 4 ;
separator nonempty Id "" ;

16
readme.md 100644
View File

@ -0,0 +1,16 @@
# HM
A simple, terminating, pure, hindley milner lambda calculus with inductively defined types.
## Building
Depends:
* BNFC
* GNU make
* GHC
* Cabal
Instructions:
* Run `bnfc -dm --text-token --functor hm.cf`
* Run `make`
* Run `cabal build`