From 2c6b4945998c99f5c9c7eccfba706b5445beeda2 Mon Sep 17 00:00:00 2001 From: Lukasz Czajka Date: Tue, 8 Oct 2024 19:00:33 +0200 Subject: [PATCH] update style wip --- CODING.md | 11 +++++++++++ juvix-stdlib | 2 +- src/Juvix/Compiler/Concrete/Data/NameSpace.hs | 6 ++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CODING.md b/CODING.md index 1a6e145e44..9e6827c288 100644 --- a/CODING.md +++ b/CODING.md @@ -26,6 +26,12 @@ type Transferability := Transferable | NonTransferable; - record constructors: `mk` + type name (`mkResource`) - meaningful descriptive long names for arguments of public functions, e.g., `element`, `list`, `initialValue` - exception: common abbreviations allowed: `fun`, `acc` + - exception: generic functions whose arguments have no specific meaning, e.g., + +``` +id {A} (x : A) := x +``` + - short names like `x` are okay for local definitions ## Function signatures @@ -41,6 +47,7 @@ isMember {A} (testEq : A -> A -> Bool) (element : A) : (list : List A) -> Bool ## Type variables - type variables uppercase (upper camel case, like with types) +- higher-order type variables also upper camel case (`F : Type -> Type`) - implicit type variables: use short version `{A}` in function signatures on the left - prefer `{A B}` over `{A} {B}` in function signatures - meaningful type variable names for more "high-level" functions where this makes sense @@ -81,6 +88,10 @@ find {A} (predicate : A -> Bool) : (list : List A) -> Maybe A - use iterators `for` , `map`, etc., instead of the function application syntax with `fold`, etc. - use named application when reasonable +## Type definitions + +- give meaningful names to constructor arguments + ## Documentation - the documentation string should be an English sentence diff --git a/juvix-stdlib b/juvix-stdlib index 0e143831c4..89134d6791 160000 --- a/juvix-stdlib +++ b/juvix-stdlib @@ -1 +1 @@ -Subproject commit 0e143831c4fcd4dd4cfac6c61907232f10dabcf0 +Subproject commit 89134d6791509f530b8d92d4d09d8c1e593525cb diff --git a/src/Juvix/Compiler/Concrete/Data/NameSpace.hs b/src/Juvix/Compiler/Concrete/Data/NameSpace.hs index fa9a6c3066..35cc422e72 100644 --- a/src/Juvix/Compiler/Concrete/Data/NameSpace.hs +++ b/src/Juvix/Compiler/Concrete/Data/NameSpace.hs @@ -61,7 +61,5 @@ resolveNameSpaceEntry = case sing :: SNameSpace ns of resolveFixitySymbolEntry (FixitySymbolEntry n1) (FixitySymbolEntry n2) = FixitySymbolEntry (resolveName n1 n2) resolveName :: S.Name -> S.Name -> S.Name - resolveName n1 n2 - | n1 ^. S.nameId == n2 ^. S.nameId = - over S.nameVisibilityAnn (resolveVisibility (n2 ^. S.nameVisibilityAnn)) n1 - | otherwise = impossible + resolveName n1 n2 = + over S.nameVisibilityAnn (resolveVisibility (n2 ^. S.nameVisibilityAnn)) n1