Skip to content

Commit 941a85f

Browse files
committed
handle unexpected characters in unknown comment
1 parent 4cdd1fc commit 941a85f

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/MyPrelude.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module MyPrelude (
1818
mergeList,
1919
listDisplay,
2020
getOrDft,
21-
replace,
2221
forceRight,
2322
forceJust,
2423
LoggerM,
@@ -126,9 +125,6 @@ getOrDft :: (Default a) => Maybe a -> a
126125
getOrDft (Just v) = v
127126
getOrDft Nothing = def
128127

129-
replace :: Lens' a b -> a -> a -> a
130-
replace l base new = base & l .~ new ^. l
131-
132128
getEnvDft :: (MonadIO m) => String -> String -> m String
133129
getEnvDft name dft = liftIO $ SB.getEnvDefault name dft
134130

src/Types/Record.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Types.Record where
33
import Data.ByteString.Builder (byteString)
44
import Hledger (AccountName, Status (..))
55
import MyPrelude
6+
import RIO.Text.Partial qualified as T'
67

78
separator :: Builder
89
separator = ";"
@@ -41,9 +42,9 @@ makeLenses ''ImportComment
4142
instance Display ImportComment where
4243
display (ImportComment {..}) =
4344
display
44-
-- add quotes to escape separator
45-
$ show
46-
$ show
45+
$ T'.replace "\"" ""
46+
$ T'.replace ";" "|"
47+
$ tshow
4748
$ display (maybe "" (<> ", ") _icStr)
4849
<> displayWithSep ", " ((\(tag, txt) -> tag <> ": " <> txt) <$> _icTags)
4950

0 commit comments

Comments
 (0)