Skip to content

Commit a8e802f

Browse files
committed
First commit
0 parents  commit a8e802f

File tree

7 files changed

+154
-0
lines changed

7 files changed

+154
-0
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for LLLang
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2021 Jean CASPAR
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included
12+
in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

LLLang.cabal

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
-- Initial Lang.cabal generated by cabal init. For further
2+
-- documentation, see http://haskell.org/cabal/users-guide/
3+
4+
name: LLLang
5+
version: 0.1.0.0
6+
synopsis: A linear logic based programming language.
7+
-- description:
8+
license: MIT
9+
license-file: LICENSE
10+
author: Jean CASPAR
11+
maintainer: 55629512+JeanCASPAR@users.noreply.github.com
12+
-- copyright:
13+
-- category:
14+
build-type: Simple
15+
extra-source-files: CHANGELOG.md
16+
cabal-version: >=2.0
17+
18+
common shared:
19+
default-language: Haskell2010
20+
build-depends:
21+
base ^>=4.12,
22+
megaparsec ^>=8.0,
23+
containers ^>=0.6,
24+
25+
library
26+
exposed-modules: Main, Parser
27+
-- other-modules:
28+
-- other-extensions:
29+
-- build-depends:
30+
import: shared
31+
hs-source-dirs: src
32+
default-language: Haskell2010
33+
34+
executable LLLang
35+
main-is: Main.hs
36+
-- other-modules:
37+
-- other-extensions:
38+
-- build-depends:
39+
import: shared
40+
hs-source-dirs: src
41+
default-language: Haskell2010

Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

flake.nix

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
description = "";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system};
13+
14+
haskellPackages = pkgs.haskellPackages;
15+
16+
jailbreakUnbreak = pkg:
17+
pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; }));
18+
19+
packageName = "LLLang";
20+
in {
21+
packages.${packageName} =
22+
haskellPackages.callCabal2nix packageName self rec {
23+
# Dependency overrides go here
24+
};
25+
26+
defaultPackage = self.packages.${system}.${packageName};
27+
28+
devShell = pkgs.mkShell {
29+
buildInputs = with haskellPackages; [
30+
haskell-language-server
31+
ghcid
32+
cabal-install
33+
];
34+
inputsFrom = builtins.attrValues self.packages.${system};
35+
};
36+
});
37+
}

src/Main.hs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Main where
2+
3+
main :: IO ()
4+
main = putStrLn "Hello, Haskell!"

src/Parser.hs

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module Parser (Parser) where
2+
3+
import Data.Text (Text)
4+
import Data.Map
5+
import Text.Megaparsec
6+
import Text.Megaparsec.Char
7+
import Control.Applicative
8+
import Control.Applicative.Combinators
9+
10+
type Parser = Parsec String Text
11+
12+
type Ident = String
13+
14+
data Type =
15+
| Named Ident
16+
| With Type Type
17+
| Plus Type Type
18+
| Tensor Type Type
19+
| Par Type Type
20+
| WhyNot Type
21+
| OfCourse Type
22+
| Fun Type Type
23+
| Zero
24+
| One
25+
| Top
26+
| Bottom.
27+
28+
data TypeDecl = Decl {
29+
name :: Ident,
30+
attrs :: Map Ident Type
31+
}
32+
33+
data FunDecl = {
34+
name :: Ident,
35+
-- Idents are assumed to be unique
36+
params :: [(Ident, Type)]
37+
ret :: Type
38+
code :: AST
39+
}
40+
41+
data AST = ()
42+
43+
data Toplevel =
44+
| Type TypeDecl
45+
| Function FunctionDecl

0 commit comments

Comments
 (0)