mirror of
https://github.com/anoma/juvix.git
synced 2024-12-12 14:28:08 +03:00
2d666fd82c
- closes #1991 This pr implements named arguments as described in #1991. It does not yet implement optional arguments, which should be added in a later pr as they are not required for record syntax. # Syntax Overview Named arguments are a convenient mehcanism to provide arguments, where we give the arguments by name instead of by position. Anything with a type signature can have named arguments, i.e. functions, types, constructors and axioms. For instance, if we have (note that named arguments can also appear on the rhs of the `:`): ``` fun : {A B : Type} (f : A -> B) : (x : A) -> B := ... ; ``` With the traditional positional application, we would write ``` fun suc zero ``` With named arguments we can write the following: 1. `fun (f := suc) (x := zero)`. 2. We can change the order: `fun (x := zero) (f := suc)`. 3. We can group the arguments: `fun (x := zero; f := suc)`. 4. We can partially apply functions with named arguments: `fun (f := suc) zero`. 5. We can provide implicit arguments analogously (with braces): `fun {A := Nat; B := Nat} (f := suc; x := zero)`. 6. We can skip implicit arguments: `fun {B := Nat} (f := suc; x := zero)`. What we cannot do: 1. Skip explicit arguments. E.g. `fun (x := zero)`. 2. Mix explicit and implicit arguments in the same group. E.g. `fun (A := Nat; f := suc)` 3. Provide explicit and implicit arguments in different order. E.g. `fun (f := suc; x := zero) {A := Nat}`.
90 lines
2.9 KiB
YAML
90 lines
2.9 KiB
YAML
# Based on HLint configuration file from https://github.com/ndmitchell/hlint
|
|
|
|
- arguments: [--color]
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# RESTRICTIONS
|
|
# ------------------------------------------------------------------------------
|
|
|
|
- extensions:
|
|
- default: false
|
|
- name:
|
|
- ApplicativeDo
|
|
- DataKinds
|
|
- DerivingStrategies
|
|
- GADTs
|
|
- ImportQualifiedPost
|
|
- LambdaCase
|
|
- NoImplicitPrelude
|
|
- OverloadedStrings
|
|
- QuantifiedConstraints
|
|
- QuasiQuotes
|
|
- RecordWildCards
|
|
- StandaloneKindSignatures
|
|
- TemplateHaskell
|
|
- TypeFamilyDependencies
|
|
- UndecidableInstances
|
|
- UnicodeSyntax
|
|
- GeneralizedNewtypeDeriving
|
|
|
|
- flags:
|
|
- default: false
|
|
- name:
|
|
- -Wall
|
|
- -Wcompat
|
|
- -Wderiving-defaults
|
|
- -Widentities
|
|
- -Wincomplete-patterns
|
|
- -Wincomplete-record-updates
|
|
- -Wincomplete-uni-patterns
|
|
- -Wmissing-deriving-strategies
|
|
- -Wredundant-constraints
|
|
- -O2 -flate-specialise -fspecialise-aggressively
|
|
|
|
- modules:
|
|
# if you import Data.Set qualified, it must be as 'Set'
|
|
- { name: [Data.Set, Data.HashSet], as: Set }
|
|
- { name: [Data.Map, Data.HashMap.Strict, Data.HashMap.Lazy], as: Map }
|
|
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
|
|
|
|
- functions:
|
|
- { name: Data.List.NonEmpty.nub, within: [] }
|
|
- { name: Data.List.NonEmpty.nubBy, within: [] }
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# OTHER HINTS
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# - warn: {name: Use explicit module export list}
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# HINTS
|
|
# ------------------------------------------------------------------------------
|
|
|
|
- error: { lhs: idea Warning, rhs: warn }
|
|
- error: { lhs: idea Suggestion, rhs: suggest }
|
|
- error: { lhs: ideaN Warning, rhs: warnN }
|
|
- error: { lhs: ideaN Suggestion, rhs: suggestN }
|
|
|
|
- error: { lhs: occNameString (occName (unLoc x)), rhs: rdrNameStr x }
|
|
- error: { lhs: occNameString (occName x), rhs: occNameStr x }
|
|
- error:
|
|
{
|
|
lhs: noLoc (HsVar noExtField (noLoc (mkRdrUnqual (mkVarOcc x)))),
|
|
rhs: strToVar x,
|
|
}
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# IGNORES
|
|
# ------------------------------------------------------------------------------
|
|
|
|
- ignore: { name: Use let, within: [Test.All] }
|
|
- ignore: { name: Use String }
|
|
- ignore: { name: Avoid restricted qualification }
|
|
- ignore: { name: Redundant multi-way if }
|
|
- ignore: { name: Redundant bracket }
|
|
- ignore: { name: Eta reduce }
|
|
- ignore: { name: Avoid restricted alias }
|
|
- ignore: { name: Use tuple-section }
|
|
- ignore: { name: Use map with tuple-section }
|