Commit Graph

627 Commits

Author SHA1 Message Date
Gabriel Gonzalez
e3b54792d1 Remove List/concat
This can be implemented in terms of `List/build` and `List/fold`, and those
permit build/fold fusion, unlike `List/concat`
2016-10-14 21:13:38 -07:00
Gabriel Gonzalez
6f35500d8e Add build/fold fusion 2016-10-14 20:10:17 -07:00
Gabriel Gonzalez
4187b92a7b Fix shift error for if statements 2016-10-14 20:06:50 -07:00
Gabriel Gonzalez
7b2a418269 Go back to | as the separator for union types and literals
This is easier on the eyes when writing out sums of products, like:

    < Just = { foo = 1, bar = True } | Nothing : {} >
2016-10-11 20:21:25 -07:00
Gabriel Gonzalez
a371529a6e Add union literals
Also, replace the `|` with `,` for union types and literals
2016-10-11 20:12:40 -07:00
Gabriel Gonzalez
98ef584a67 Permit field access for unions with one element
Note that I haven't even implemented union literals, so this can't even be used,
yet!

This lets you access the field of a union if it has exactly one alternative.

The basic idea is that a subsequent change will provide an operator for merging
pattern matches with the following pseudo-type:

    a : Type, b : Type, r : Type |- (\/) : (a → r) → (b → r) → (a \/ b → r)

For example:

        (\/)
    :   (< foo : Bool > → Integer)
    →   (< bar : Text > → Integer)
    →   (< foo : Bool | bar : Text > → Integer)

You can then combine `(\/)` in conjunction with field access to implement
pattern matching:

    let example : < foo : Bool | bar : Natural > → Bool =
            (λ(x : < foo : Bool    >) → x.foo               )
        \/  (λ(x : < bar : Natural >) → Natural/even (x.bar))
    in  example
2016-10-11 17:26:11 -07:00
Gabriel Gonzalez
ebe96b3cac Update documentation 2016-10-11 09:36:29 -07:00
Gabriel Gonzalez
9505637891 Use (++) to concatenate Text instead of (<>)
This ensures that `<>` unambiguously refers to the empty sum type
2016-10-11 09:32:02 -07:00
Gabriel Gonzalez
1602f891f1 Remove (++)
There are two main reasons that I'm removing `(++)`:

* I would like to use `(++)` instead of `(<>)` for combining `Text` so that
  `<>` can be used for the empty sum type
* `(++)` leads to quadratic time complexity when used repeatedly.  `List/concat`
  is the preferred API for combining lists
2016-10-11 09:26:04 -07:00
Gabriel Gonzalez
7ea9c2a972 Remove Text/concat
The original motivation for adding `Text/concat` was to work around the
quadratic time complexity of using `(<>)` repeatedly, but this is no longer an
issue now that Dhall uses `Builder` internally to represent `Text`
2016-10-11 09:21:40 -07:00
Gabriel Gonzalez
91a933ba9a Use Builder internally for representing Text
This is more efficient since the only thing we ever do is concatenate text,
which `Builder` is optimized for.
2016-10-11 09:18:52 -07:00
Gabriel Gonzalez
a49bad9a58 Add absurd 2016-10-11 09:02:12 -07:00
Gabriel Gonzalez
718fdeb171 Add union types
Just the types for now.  No union literals or pattern matching, yet
2016-10-02 14:32:35 -07:00
Gabriel Gonzalez
89ea6b038c Polish code 2016-10-02 13:53:59 -07:00
Gabriel Gonzalez
727ffb86e1 Change {}/{:} to {=}/{}, respectively 2016-10-02 08:34:46 -07:00
Gabriel Gonzalez
03cc365e7b Revert "Add syntax for pattern types and literals (i.e. sum types)"
This reverts commit 954e8619b6.
2016-09-27 09:39:21 -07:00
Gabriel Gonzalez
954e8619b6 Add syntax for pattern types and literals (i.e. sum types) 2016-09-21 20:39:40 -07:00
Gabriel Gonzalez
f34b07be49 Remove List/splitAt and List/splitAtEnd 2016-09-20 08:46:40 -07:00
Gabriel Gonzalez
158429b988 Improved error messages for lexer 2016-09-18 22:18:36 -07:00
Gabriel Gonzalez
c199d04956 Update documentation 2016-09-18 21:36:31 -07:00
Gabriel Gonzalez
afa3844699 Add back Buildable instance for Const 2016-09-18 21:31:27 -07:00
Gabriel Gonzalez
d36eabb0af Update documentation 2016-09-18 21:28:21 -07:00
Gabriel Gonzalez
80b9b25d24 Update documentation 2016-09-18 21:13:03 -07:00
Gabriel Gonzalez
3e9d230498 Add Natural/even and Natural/odd 2016-09-18 21:07:49 -07:00
Gabriel Gonzalez
e597a97e78 Add Text/concat 2016-09-18 18:45:34 -07:00
Gabriel Gonzalez
6e74794a76 Add List/concat 2016-09-18 18:31:23 -07:00
Gabriel Gonzalez
1260b92fdc Rename ListConcat constructor to ListAppend 2016-09-18 18:18:08 -07:00
Gabriel Gonzalez
eb4e482380 Rename fields generated by List/indexed 2016-09-18 18:09:11 -07:00
Gabriel Gonzalez
324a29be12 Rename List/first to List/head 2016-09-18 17:54:58 -07:00
Gabriel Gonzalez
11a06ab540 Replace drop/dropEnd with splitAt/splitAtEnd 2016-09-18 17:50:45 -07:00
Gabriel Gonzalez
1332f6cfb0 Fix pretty-printing of (==) and (/=) to match parser 2016-09-18 17:34:56 -07:00
Gabriel Gonzalez
16c72f5a76 Add (==) and (/=) 2016-09-18 16:28:03 -07:00
Gabriel Gonzalez
076678f1de Add support for decoding Maybes 2016-09-18 15:38:36 -07:00
Gabriel Gonzalez
d39cf8876e Re-export Text 2016-09-18 15:24:54 -07:00
Gabriel Gonzalez
429dbd266b Update documentation 2016-09-18 15:24:42 -07:00
Gabriel Gonzalez
acd77292ef Reintroduce indexed variables
The simpler approach still permitted variable capture.  For example, this would
break:

    \x -> (\y -> (\x -> y)) x

That should reduce to:

    \x -> \x -> x@1  -- ... not even expressible under the simpler system

... but it actually reduced to:

    \x -> \x -> x

This also required disabling multi-`let` since in the process of fixing this I
realized that this expression is ambiguous:

    \(x : Type) ->
    let x : Type = Bool
    let f (y : x) = y
    in  f   -- ^ Which `x` does this refer to

... because it's supposed to be semantically equivalent to:

    \(x : Type) ->
    (   \(x : Type)
    ->  \(f : forall (y : x) -> x)
    ->  f              -- ^ This refers to the inner `x : Type`
    )
    Bool
    (\(y : x) -> y)
        -- ^ ... but this refers to the outer `x : Type`

Now the code only permits a single `let` binding in each `let ... in` expression
2016-09-18 14:22:45 -07:00
Gabriel Gonzalez
0da0968147 Polish documentation 2016-09-16 20:23:12 -07:00
Gabriel Gonzalez
d0a4134e25 Reintroduce Unicode support 2016-09-16 20:16:46 -07:00
Gabriel Gonzalez
f5a7e50d07 Use {} for empty record literals 2016-09-16 19:03:10 -07:00
Gabriel Gonzalez
6ea1b4ae5a Add type annotations for let results 2016-09-16 17:39:59 -07:00
Gabriel Gonzalez
47eb966f8e Reuse buildLet in Buildable instance for Let 2016-09-16 17:21:26 -07:00
Gabriel Gonzalez
d2ec1c1cc2 Space out record syntax 2016-09-16 17:11:42 -07:00
Gabriel Gonzalez
c3bbe324b3 Add List/dropEnd 2016-09-16 17:06:24 -07:00
Gabriel Gonzalez
b777f4252c Add List/reverse 2016-09-16 16:58:35 -07:00
Gabriel Gonzalez
35e03c5a02 Replace List/index with List/drop
You can implement `List/index` equally efficiently in terms of `List/drop` and
`List/first`
2016-09-16 09:48:04 -07:00
Gabriel Gonzalez
c09a586117 Add Natural/isZero 2016-09-16 09:32:50 -07:00
Gabriel Gonzalez
b8909addf4 Add List/index 2016-09-16 09:22:03 -07:00
Gabriel Gonzalez
73c817ec94 Use {:} for empty record types and {=} for empty record literals 2016-09-16 09:14:54 -07:00
Gabriel Gonzalez
d15ed8ef5e Add List/length 2016-09-16 09:10:56 -07:00
Gabriel Gonzalez
1741db3702 Add List/last 2016-09-16 09:04:08 -07:00