Skip to content

Commit

Permalink
Package up and describe
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdone committed Nov 29, 2023
1 parent e3a407e commit 4339b50
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.stack-work
2 changes: 1 addition & 1 deletion Hell.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE ExistentialQuantification, TypeApplications, BlockArguments #-}
{-# LANGUAGE GADTs, PolyKinds #-}
{-# LANGUAGE GADTs, PolyKinds, TupleSections, StandaloneDeriving, Rank2Types #-}
{-# LANGUAGE LambdaCase, ScopedTypeVariables, PatternSynonyms #-}

-- * Original type checker code by Stephanie Weirich at Dagstuhl (Sept 04)
Expand Down
34 changes: 34 additions & 0 deletions brossa.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.35.1.
--
-- see: https://github.com/sol/hpack

name: brossa
version: 0
author: Chris Done
maintainer: Chris Done
copyright: 2023 Chris Done
license: BSD3
build-type: Simple

executable hell
main-is: Hell.hs
other-modules:
Paths_brossa
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
async
, base
, bytestring
, constraints
, containers
, directory
, ghc-prim
, haskell-src-exts
, hspec
, mtl
, syb
, temporary
, text
default-language: Haskell2010
1 change: 1 addition & 0 deletions examples/01-hello-world.hell
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main = Text.putStrLn "Hello, World!"
5 changes: 5 additions & 0 deletions examples/02-interaction.hell
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main = do
Text.putStrLn "Please enter your name and hit ENTER:"
name :: Text <- Text.getLine
Text.putStrLn "Thanks, your name is: "
Text.putStrLn name
28 changes: 28 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: brossa
version: 0
license: BSD3
author: "Chris Done"
copyright: "2023 Chris Done"

dependencies:
- base
- haskell-src-exts
- hspec
- ghc-prim
- containers
- text
- bytestring
- async
- mtl
- directory
- temporary
- syb
- constraints

executables:
hell:
main: Hell.hs
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
69 changes: 53 additions & 16 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,59 @@
Working example:
# hell

```haskell
foo = Main.bar
Hell is a statically-typed shell scripting language and
implementation, which re-uses Haskell's standard library and runtime.

main = Main.foo
## Running

bar = do
x :: () <- Text.putStrLn "Hello, please enter your name"
line :: Text <- Text.getLine
Text.putStrLn "Hello, "
let msg :: Text = ((\(x :: Text) (y :: Int) -> x) line 5)
Text.putStrLn msg
```
Presently the `hell` binary type-checks and interprets immediately a
program in `IO`.

$ hell examples/01-hello-world.hell
Hello, World!

## Informal description

See `examples/` for a list of example scripts.

Example program:

```haskell
main = do
Text.putStrLn "Please enter your name and hit ENTER:"
name :: Text <- Text.getLine
Text.putStrLn "Thanks, your name is: "
Text.putStrLn name
```
$ ./hell foo.hell
Hello, please enter your name
Dabe
Hello,
Dabe

## More formal description

The language is a DSL, it's the simply-typed lambda calculus, plus
some syntactic sugar and some primitives that can be polymorphic (but
require immediately applied type applications). Recursion is not
supported.

Polymorphic primitives such as `id` require passing the type of the
argument as `id @Int 123`. You cannot define polymorphic lambdas of
your own. It's not full System-F.

It will support type-classes (for equality, dictionaries, etc), but
the dictionaries must be explicitly supplied. You can't define
classes, or data types, of your own.

The types and functions available lean directly on the host language
(Haskell) and are either directly lifted, or a simplified layer over
the original things.

There is (presently) no type inference. All parameters of lambdas, or
do-notation let bindings, must have their type declared via a pattern
signature.

```haskell
\(x :: Int) -> x
```

## Building

Build statically for Linux in a musl distribution:

stack build --ghc-options="-static -optl-static"
5 changes: 5 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resolver: lts-20.24
system-ghc: true
packages:
- '.'
allow-different-user: true
12 changes: 12 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
snapshots:
- completed:
sha256: e019cd29e3f7f9dbad500225829a3f7a50f73c674614f2f452e21bb8bf5d99ea
size: 650253
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/24.yaml
original: lts-20.24

0 comments on commit 4339b50

Please sign in to comment.