Comments (3)
Yeah, I think it's a good idea to only make the type annotation required for empty lists
There are a couple of minor details, but I don't think they are a big deal:
- If a
List
has elements of different types there is no way to tell which element type was the intended type. In this case we can fall back on assuming that the first element type is the intended type Optional
values also use a list literal syntax, but I can just say that if a list literal with one element has no type annotation that it must be aList
and not anOptional
value
from dhall-haskell.
Ah, I get why you wouldn’t want NonEmpty
as default, because it should be able to map to programming languages easily.
from dhall-haskell.
The other reason that I avoid NonEmpty
is I would prefer Liquid-Haskell-style refinements on types if I went down that route. For example, you can model NonEmpty
using refinement types like this:
NonEmpty a = { xs : List a | 1 <= length xs }
In fact, when I was adding Optional
to the language, one of the design decisions was whether or not Optional
would be a special case of a list with a refinement like this:
Optional a = { xs : List a | length xs <= 1 }
This is one of the reasons that Optional
s use the same literal syntax as lists so that I could leave the door open to possibly adding that later if I changed my mind.
The reason I decided against it in the end was because Dhall has a pretty consistent "no subtyping" rule because subtyping makes the language harder to teach to new users and refinement types are one form of subtyping. However, a more expert-friendly fork of Dhall could add something like this to the language.
from dhall-haskell.
Related Issues (20)
- How is https://store.dhall-lang.org/ generated? HOT 2
- Question About YAML to Dhall & Dhall to YAML HOT 4
- system-filepath is deprecated HOT 1
- Produce unquoted YAML from Dhall HOT 3
- Allow `dhall format` to take multiple files as arguments HOT 2
- "Dynamic records" / --maps support in dhall-toml HOT 2
- Incorrect version number in 1.42.0 release HOT 1
- dhall-1.42.0 fails to build in Stackage Nightly HOT 7
- Feature request: dhall mv
- Dhall.TH functions should call addDependentFile HOT 1
- Generate parametrized types to inject into evaluation context HOT 2
- build failure due to `saltine` HOT 1
- No documentation for accessing nested unions HOT 4
- Failure to Decode Expression with extended Builtin Function HOT 1
- Document the significance of `Nothing :: Maybe CharacterSet`
- Please report symlink contents for `Error: Missing file` HOT 2
- Error generating docs
- combine `let` bindings in `dhall format` HOT 1
- Support request for `aeson` 2.2 in `dhall` HOT 2
- dhall-to-yaml does not properly quote strings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dhall-haskell.