Comments (7)
Just my two cents: dot syntax would conflict with module syntax readability, composition operator ((.)
), and any potential future record syntax in the style of Elm. Not to say that these features will become available (I just discovered this project!), but using a dot in the way proposed limits other idioms more common in languages similar to Formality.
Something similar: OCaml, F#, and Elixir have a pipe operator behaves the same way, which may be a nice compromise. Elm and TypeScript also have pipes, but they do different things with order. Haskell has a library that provides them, too.
# Elixir
foo(a, b, c) == a |> foo(b, c)
This also chains applications nicely in diagrammatic order:
# Elixir
a
|> foo(b, c)
|> bar(d)
|> baz(e, f, g)
I would assume that this would be easy to implement as an infix function in Formality.
-- Formality
infixl 0 |>
let (X : Type) |> (F : X -> (Y: Type)) =>
f(x) : Y
There's probably a bunch of syntax errors — sorry! (Just working from the README examples.) I don't see any fixity declarations, so I just used the Haskell/Idris one. So maybe this isn't possible, but infix operators would be useful, and more flexible than a special "dot-call" syntax / fluent interface.
from kind.
this feels OOP-like, running counter to the order normally used for currying?
from kind.
- Formality does not have currying.
- It is a concept orthogonal to OOP, called infix operator.
- Even haskell has this:
a `foo` b
from kind.
Formality is fully curried, but I agree the syntax is misleading. (a : A, b : B) => c
is just a syntax sugar for (a : A) => (b : B) => c
. Same for forall and applications.
I like a.foo(b, c)
as a syntax sugar for foo(a, b, c)
. But that alone won't make Formality a readable language. A lot else must be done for that. I have many ideas that I want to explore when we have Ethereum's upcoming browser. For now, let's keep it simple, even if it isn't the most aesthetically appealing language. We already have Agda, which is beautiful (and, probably, for a long time, using Agda will probably be the best way to write Formality).
from kind.
-
dot syntax would conflict with module syntax
No. See Java, Python, Elm ...
-
composition operator ((.)),
No. You do not have to define composition as
.
. See Elm<<
. -
and any potential future record syntax in the style of Elm.
No. See 1). record syntax is just dot notation for autogenerated row polymorphic functions.
-
I would assume that this would be easy to implement as an infix function in Formality.
Formality does not have infix functions. Implementing custom infix functions is harder, then hard coding dot operator.
from kind.
I'm moving away from a higher-level language with (arguably very limited) native datatypes to a lower-level language with a constellation of λ-encodings. User-friendlier syntaxes such as pattern-matching, datatypes and what is proposed here should and could be added on top of Formality as a separate pre-processing step. As such, this issue is now obsolete.
from kind.
@Josef-Vonasek Just wanted you know that Formality-Lang (https://gitlab.com/moonad/formality-javascript) now allows you to address matched fields with the dot notation, which is actually kinda fake because it is just the variable name, but it is beautiful:
Nat.double :! {|*n : Nat} -> Nat
| succ = Nat.succ(Nat.succ(Nat.double(n.pred)))
| zero = Nat.zero
from kind.
Related Issues (20)
- Bump cli version to 0.3.8
- Bump cli version to 0.3.9
- "New Type" Optimization
- Improve error messages by removing things like implicit arguments
- Add type checker for erased Pi, App and Lam
- Remove old parser and stuff to use treesitter
- Add new type of error messages used for LLMs.
- error[E0599]: no method named `as_ptr` found for struct `AtomicU64` in the current scope HOT 2
- Add an API for cursor on trees
- Add slash on the end of identifiers as another type of "use"
- Add flag to remove dependency errors
- New panic hook for the language.
- Add flag to show immediate dependencies
- Inconsistency in type check messages
- Update basic function names for Kindex update HOT 1
- Create a project/package manager
- Refactor file loading and name resolution module
- Compiler crashes when using an undeclared alias
- Inconsistent arity error
- WebAssembly
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 kind.