Skip to content

Commit f74c934

Browse files
committed
Remove unused dependency
Clean up unused dedendencies, remove all uses of `RecordWildCards` and `GADTs` (the former of which made it tougher to see when fields weren't being used and made code in general less readable to me).
1 parent 5b09ca9 commit f74c934

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

language-rust.cabal

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: language-rust
22
version: 0.1.0.0
3-
synopsis: Haskell library for parsing and pretty printing Rust code.
3+
synopsis: Haskell library for parsing and pretty printing Rust source code.
44
-- description:
55
homepage: https://github.com/harpocrates/language-rust
66
license: BSD3
@@ -32,10 +32,9 @@ library
3232
Language.Rust.Data.InputStream
3333
-- other-modules:
3434

35-
other-extensions: RecordWildCards
36-
, OverloadedStrings
35+
other-extensions: OverloadedStrings
36+
, OverloadedLists
3737
, DuplicateRecordFields
38-
, GADTs
3938
, InstanceSigs
4039
, CPP
4140
, DeriveFunctor

src/Language/Rust/Data/Position.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE RecordWildCards, DeriveFunctor #-}
1+
{-# LANGUAGE DeriveFunctor #-}
22

33
module Language.Rust.Data.Position where
44

@@ -36,22 +36,22 @@ initPos = Position 0 1 1
3636
-- | advance column
3737
incPos :: Position -> Int -> Position
3838
incPos NoPosition _ = NoPosition
39-
incPos Position{..} offset = Position (absoluteOffset + offset) (row + offset) col
39+
incPos p@Position{ absoluteOffset = a, row = r } offset = p { absoluteOffset = a + offset, row = r + offset }
4040

4141
-- | advance to the next line
4242
retPos :: Position -> Position
4343
retPos NoPosition = NoPosition
44-
retPos Position{..} = Position (absoluteOffset + 1) (row + 1) 1
44+
retPos (Position a r _) = Position { absoluteOffset = a + 1, row = r + 1, col = 1 }
4545

4646
-- | advance just the offset
4747
incOffset :: Position -> Int -> Position
4848
incOffset NoPosition _ = NoPosition
49-
incOffset Position{..} offset = Position (absoluteOffset + offset) row col
49+
incOffset p@Position{ absoluteOffset = a } offset = p { absoluteOffset = a + offset }
5050

5151

5252
instance Show Position where
5353
show NoPosition = "$"
54-
show Position{..} = show row ++ ":" ++ show col
54+
show (Position _ r c) = show r ++ ":" ++ show c
5555

5656

5757
type ExpnId = Int -- https://docs.serde.rs/syntex_pos/struct.ExpnId.html
@@ -78,7 +78,7 @@ instance Monoid Span where
7878
s1 `mappend` s2 = Span (lo s1 `minPos` lo s2) (hi s1 `maxPos` hi s2)
7979

8080
instance Show Span where
81-
show (Span lo hi) = show lo ++ " - " ++ show hi
81+
show (Span lo' hi') = show lo' ++ " - " ++ show hi'
8282

8383
-- | A "tagging" of something with a 'Span' that describes its extent
8484
data Spanned a = Spanned { unspan :: a, span :: Span } deriving (Functor)

src/Language/Rust/Parser/ParseMonad.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE InstanceSigs, RecordWildCards, PatternSynonyms #-}
1+
{-# LANGUAGE InstanceSigs, PatternSynonyms #-}
22

33
module Language.Rust.Parser.ParseMonad where
44

@@ -92,7 +92,7 @@ setPosition pos = P (\s -> Ok () s{ curPos = pos })
9292

9393
-- | retrieve the input stream of the parser
9494
getInput :: P InputStream
95-
getInput = P $ (\s@PState{ curInput = i } -> Ok i s)
95+
getInput = P (\s@PState{ curInput = i } -> Ok i s)
9696

9797
-- | set the input stream of the parser
9898
setInput :: InputStream -> P ()

src/Language/Rust/Syntax/AST.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE DuplicateRecordFields, DeriveFunctor, GADTs, PatternSynonyms #-}
1+
{-# LANGUAGE DuplicateRecordFields, DeriveFunctor, PatternSynonyms #-}
22

33
module Language.Rust.Syntax.AST where
44

0 commit comments

Comments
 (0)