Skip to content

Commit

Permalink
fix: incomplete pattern matches warning
Browse files Browse the repository at this point in the history
  • Loading branch information
deemp committed Feb 8, 2024
1 parent 26127b6 commit 99c5173
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions scripts/transform-eo-tests/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module Main (main) where
import Control.Monad
import Data.Function ((&))
import Data.Functor ((<&>))
import Data.List.Extra (split)
import Data.String (IsString (..))
import Data.Text qualified as T
import Data.Yaml (FromJSON, ToJSON (..), Value (String), decodeFileThrow, encodeFile)
Expand All @@ -25,6 +24,7 @@ import GHC.Generics (Generic)
import Main.Utf8 (withUtf8)
import System.Directory.Extra (createDirectoryIfMissing, removeFile)
import System.FilePath.Posix
import Text.Read (readMaybe)

main :: IO ()
main = withUtf8 do
Expand Down Expand Up @@ -76,13 +76,11 @@ instance ToJSON Pos where

instance FromJSON Pos where
parseJSON = withText "Pos" $ \(T.unpack -> x) -> do
let ts = split (== ':') x
guard (length ts == 2)
let [file, line'] = ts
let (file, rs) = span (/= ':') x
guard (not . null $ file)
guard (not . null $ line')
let line = read line'
pure Pos{..}
guard (length rs > 1)
let line' = readMaybe (drop 1 rs)
maybe (fail $ x <> " is not a number") (\line -> pure Pos{..}) line'

data Program = Program
{ source :: Pos
Expand Down

0 comments on commit 99c5173

Please sign in to comment.