Comments (2)
There has been desire for type aliases. Implementing type aliases that expand early shouldn't be very difficult. Part of the reason I held off from implementing them, is I wanted to see if having GHC's type alias semantics was possible.
Compare the following two rather contrived programs:
enum T {
T,
}
type T2 = T;
fn main() {
let x: T2 = T::T;
let y: T2 = T::T;
x == y;
}
module Main where
data T = T
type T2 = T
main = do
let x = (T :: T2)
let y = (T :: T2)
let _ = x == y
pure ()
In both cases the program fails to compile because T
doesn't implement Eq
. In Rust's case the error looks like this:
error[E0369]: binary operation `==` cannot be applied to type `T`
--> src/main.rs:11:7
|
11 | x == y;
| - ^^ - T
| |
| T
|
In GHC the error looks like this:
main.hs:10:13: error:
• No instance for (Eq T2) arising from a use of ‘==’
• In the expression: x == y
In a pattern binding: _ = x == y
In the expression:
do let x = (T :: T2)
let y = (T :: T2)
let _ = x == y
pure ()
|
10 | let _ = x == y
| ^^
Note that Haskell tracks that the variables x and y were annotated as the type alias T2
and displays that as their type in the error message.
OTOH we could definitely implement eagerly expanding type aliases and then try to figure out the error messages later.
from coalton.
The convenience of type aliases definitely feels secondary to preserving the helpfulness of error messages.
from coalton.
Related Issues (20)
- Add documentation support for struct accessors, maybe type constructors HOT 1
- Add LISP-TOPLEVEL
- Possibly incorrect error message HOT 3
- Ensure ASDF knows about FASLs from .coal files
- Monomorphizer tests are excluded from the test suite, is this intentional? HOT 4
- Add optional docstrings for type constructors
- Method Parser Test Cases
- Class inheritance issue in `define-instance` HOT 2
- faux lisp macros don't exist for looping forms
- make a nicer printed representation for `Seq`
- add option to print types of values compiled in COALTON-TOPLEVEL HOT 1
- add `as` syntax
- Relocate AST collector to coalton-mode
- Add instances `(Into Seq List)` and `(Into Seq Vector)` HOT 1
- COALTON:LISP form should have implicit progn HOT 2
- add ZERO? POSITIVE? NEGATIVE? to prelude
- FSET has compilation errors while loading Coalton via Quicklisp HOT 3
- Coalton floating-point numerics are not at performance parity with Lisp HOT 1
- Review built-in types in the default type environment
- Review src/package.lisp for correctness of comments
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 coalton.