Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unused code in elm-format-lib #812

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion elm-format-lib/src/ElmFormat/AST/PublicAST/Module.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import AST.MatchReferences (fromMatched, matchReferences)
import Data.Text (Text)
import qualified Data.Either as Either
import qualified Data.Text as Text
import Data.Maybe (fromMaybe)


data Module
Expand Down
33 changes: 1 addition & 32 deletions elm-format-lib/src/Parse/Primitives.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import qualified Data.ByteString.Internal as B
import Data.Word (Word8, Word16)
import Foreign.Ptr (Ptr, plusPtr)
import Foreign.Storable (peek)
import Foreign.ForeignPtr (ForeignPtr, touchForeignPtr)
import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
import Foreign.ForeignPtr (ForeignPtr)

import qualified Reporting.Annotation as A

Expand Down Expand Up @@ -202,36 +201,6 @@ instance Monad (Parser x) where
parserA state cok' eok' cerr eerr



-- FROM BYTESTRING


--fromByteString :: Parser x a -> (Row -> Col -> x) -> B.ByteString -> Either x a
--fromByteString (Parser parser) toBadEnd (B.PS fptr offset length) =
-- B.accursedUnutterablePerformIO $
-- let
-- toOk' = toOk toBadEnd
-- !pos = plusPtr (unsafeForeignPtrToPtr fptr) offset
-- !end = plusPtr pos length
-- !result = parser (State fptr pos end 0 1 1) toOk' toOk' toErr toErr
-- in
-- do touchForeignPtr fptr
-- return result

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will eventually be needed; ideally https://github.com/avh4/elm-format/blob/main/elm-format-lib/src/ElmFormat/Parse.hs#L22 will change to take ByteString instead of Text, and https://github.com/avh4/elm-format/blob/aded67fb5db42afd17bfa372eab23f8a01cb635d/elm-format-lib/src/Parse/Parse.hs will change to take ByteString instead of String.

Sorry things are a bit of a mess atm.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, #301 is the blocking issue for the above mentioned ideal changes.


toOk :: (Row -> Col -> x) -> a -> State -> Either x a
toOk toBadEnd !a (State _ pos end _ row col _) =
if pos == end
then Right a
else Left (toBadEnd row col)


toErr :: Row -> Col -> (Row -> Col -> x) -> Either x a
toErr row col toError =
Left (toError row col)



-- FROM SNIPPET


Expand Down
2 changes: 1 addition & 1 deletion elm-format-lib/src/Parse/Whitespace.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Parse.IParser
import qualified Parse.Markdown as Markdown
import qualified Parse.State as State
import qualified Reporting.Error.Syntax as Syntax
import Parse.ParsecAdapter hiding (newline, spaces, State)
import Parse.ParsecAdapter


padded :: IParser a -> IParser (C2 before after a)
Expand Down
6 changes: 0 additions & 6 deletions elm-format-lib/src/Reporting/Annotation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Control.Monad (liftM2)
import Data.Coapplicative
import Data.Binary (Binary, get, put)
import Data.Word (Word16)
import Data.String (unwords)



Expand Down Expand Up @@ -58,11 +57,6 @@ instance Coapplicative Located where
{-# INLINE extract #-}


traverse :: (Functor f) => (a -> f b) -> Located a -> f (Located b)
traverse func (At region value) =
At region <$> func value
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little hesitant to remove, as it might be useful for some upcoming features. Though maybe this should be moved to a Traversable instance?



toValue :: Located a -> a
toValue (At _ value) =
value
Expand Down