Skip to content

Commit

Permalink
fix file ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellwrosen committed Aug 16, 2024
1 parent 699a16a commit 2f82c7e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions unison-syntax/src/Unison/Syntax/Lexer/Unison.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2f82c7e

Please sign in to comment.