From 2f82c7eb850015350c4e9596314d35161eda85cc Mon Sep 17 00:00:00 2001 From: Mitchell Rosen Date: Fri, 16 Aug 2024 15:19:36 -0400 Subject: [PATCH] fix file ordering --- unison-syntax/src/Unison/Syntax/Lexer/Unison.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/unison-syntax/src/Unison/Syntax/Lexer/Unison.hs b/unison-syntax/src/Unison/Syntax/Lexer/Unison.hs index 781471b7a3..18a5f7d0f4 100644 --- a/unison-syntax/src/Unison/Syntax/Lexer/Unison.hs +++ b/unison-syntax/src/Unison/Syntax/Lexer/Unison.hs @@ -884,13 +884,14 @@ stanzas = reorder :: [[BlockTree (Token Lexeme)]] -> [[BlockTree (Token Lexeme)]] reorder = foldr fixup [] . sortWith f where - f [] = 3 :: Int + f [] = 4 :: Int f (t0 : _) = case payload $ headToken t0 of - Open mod | Set.member (Text.pack mod) typeModifiers -> 2 - Open typOrA | Set.member (Text.pack typOrA) typeOrAbility -> 2 + Open mod | Set.member (Text.pack mod) typeModifiers -> 3 + Open typOrA | Set.member (Text.pack typOrA) typeOrAbility -> 3 + -- put `namespace` before `use` because the file parser only accepts a namespace directive at the top of the file Reserved "namespace" -> 1 - Reserved "use" -> 1 - _ -> 3 :: Int + Reserved "use" -> 2 + _ -> 4 :: Int -- after reordering can end up with trailing semicolon at the end of -- a block, which we remove with this pass fixup stanza [] = case Lens.unsnoc stanza of