Skip to content

Commit

Permalink
Merge 11226ff into e5c00ca
Browse files Browse the repository at this point in the history
  • Loading branch information
cdornan committed Dec 19, 2018
2 parents e5c00ca + 11226ff commit 79bd8b0
Show file tree
Hide file tree
Showing 21 changed files with 121 additions and 115 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -72,9 +72,9 @@ matrix:

# Linux/stack/hackage release

- env: BUILD=release-stack GHCVER=8.0.2 STACK_YAML=stack-8.0.yaml
compiler: ": #stack 8.0.2"
addons: {apt: {packages: [libgmp-dev]}}
# - env: BUILD=release-stack GHCVER=8.0.2 STACK_YAML=stack-8.0.yaml
# compiler: ": #stack 8.0.2"
# addons: {apt: {packages: [libgmp-dev]}}

# Nightly builds are allowed to fail

Expand Down
16 changes: 8 additions & 8 deletions Text/RE/ZeInternals/Replace.lhs
Expand Up @@ -43,7 +43,7 @@ import qualified Data.Foldable as F
import Data.Functor.Identity
import qualified Data.HashMap.Strict as HM
import Data.Maybe
import Data.Monoid
import qualified Data.Monoid as M
import qualified Data.Sequence as S
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
Expand Down Expand Up @@ -397,10 +397,10 @@ class (Show a,Eq a,Ord a,Extract a,Monoid a) => Replace a where
textifyR = T.pack . unpackR
detextifyR = packR . T.unpack
appendNewlineR = (<> packR "\n")
appendNewlineR = (M.<> packR "\n")
substR f m@Capture{..} =
capturePrefix m <> f capturedText <> captureSuffix m
capturePrefix m M.<> f capturedText M.<> captureSuffix m
\end{code}

\begin{code}
Expand Down Expand Up @@ -434,7 +434,7 @@ instance Replace [Char] where
detextifyR = T.unpack
linesR = lines
unlinesR = unlines
appendNewlineR = (<>"\n")
appendNewlineR = (M.<>"\n")
parseTemplateR = parseTemplateR' id
instance Replace B.ByteString where
Expand All @@ -445,7 +445,7 @@ instance Replace B.ByteString where
detextifyR = TE.encodeUtf8
linesR = B.lines
unlinesR = B.unlines
appendNewlineR = (<>"\n")
appendNewlineR = (M.<>"\n")
parseTemplateR = parseTemplateR' B.unpack
instance Replace LBS.ByteString where
Expand All @@ -456,7 +456,7 @@ instance Replace LBS.ByteString where
linesR = LBS.lines
unlinesR = LBS.unlines
detextifyR = LBS.fromStrict . TE.encodeUtf8
appendNewlineR = (<>"\n")
appendNewlineR = (M.<>"\n")
parseTemplateR = parseTemplateR' LBS.unpack
instance Replace (S.Seq Char) where
Expand All @@ -475,7 +475,7 @@ instance Replace T.Text where
detextifyR = id
linesR = T.lines
unlinesR = T.unlines
appendNewlineR = (<>"\n")
appendNewlineR = (M.<>"\n")
parseTemplateR = parseTemplateR' T.unpack
instance Replace LT.Text where
Expand All @@ -486,7 +486,7 @@ instance Replace LT.Text where
detextifyR = LT.fromStrict
linesR = LT.lines
unlinesR = LT.unlines
appendNewlineR = (<>"\n")
appendNewlineR = (M.<>"\n")
parseTemplateR = parseTemplateR' LT.unpack
\end{code}

Expand Down
5 changes: 5 additions & 0 deletions changelog
@@ -1,5 +1,10 @@
-*-change-log-*-

1.0.2.0 Chris Dornan <chris.dornan@irisconnect.co.uk> 2018-12-19
* cabal-install build with 8.0 and 8.2 failing (#163)
* Switch to GHC-8.6.3/nightly-2018-12-19 (#164)
* Switch from Default-Extensions to Other-Extensions (#165)

1.0.1.5 Chris Dornan <chris.dornan@irisconnect.co.uk> 2018-12-18
* TDFA quasi quoters not dealing with newlines (#157)

Expand Down
26 changes: 13 additions & 13 deletions examples/re-gen-cabals.lhs
Expand Up @@ -26,7 +26,7 @@ import Data.IORef
import qualified Data.List as L
import qualified Data.Map as Map
import Data.Maybe
import Data.Monoid
import qualified Data.Monoid as M
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import Prelude.Compat
Expand Down Expand Up @@ -160,9 +160,9 @@ default_gen ctx@Ctx{..} _ mtchs = do
mb <- readIORef _ctx_test_exe
case mb of
Nothing -> return $ ReplaceWith ln
Just te -> case isSpace $ LBS.head $ ln<>"\n" of
Just te -> case isSpace $ LBS.head $ ln M.<> "\n" of
True -> put ctx ln
False -> adjust_le (<>ln) <$> close_test_exe ctx te
False -> adjust_le (M.<>ln) <$> close_test_exe ctx te
where
ln = matchSource mtch
mtch = allMatches mtchs !! 0
Expand Down Expand Up @@ -203,17 +203,17 @@ put Ctx{..} lbs = do
case mb of
Nothing -> return $ ReplaceWith lbs
Just te -> do
writeIORef _ctx_test_exe $ Just te { _te_text = _te_text te <> lbs <> "\n" }
writeIORef _ctx_test_exe $ Just te { _te_text = _te_text te M.<> lbs M.<> "\n" }
return Delete
mk_test_exe :: Bool -> TestExe -> LBS.ByteString -> LBS.ByteString
mk_test_exe is_t te te_lbs_kw = (<>_te_text te) $ LBS.unlines $ concat
mk_test_exe is_t te te_lbs_kw = (M.<> _te_text te) $ LBS.unlines $ concat
[ [ LBS.pack $ printf "%s %s" (LBS.unpack te_lbs_kw) nm ]
, [ " type: exitcode-stdio-1.0" | is_t ]
]
where
nm = case is_t of
True -> LBS.unpack $ _te_name te <> "-test"
True -> LBS.unpack $ _te_name te M.<> "-test"
False -> LBS.unpack $ _te_name te
mk_build_depends :: Bool
Expand Down Expand Up @@ -255,7 +255,7 @@ mk_build_depends lb we fp mp pks0 = LBS.unlines $
[ " GHC-Options:"
, " -Wall"
, " -fwarn-tabs"
, " " <> w_error_or_warn
, " " M.<> w_error_or_warn
, ""
, " Build-depends:"
] ++ (map fmt $ zip (True : repeat False) $ L.sortBy comp pks)
Expand Down Expand Up @@ -318,7 +318,7 @@ sdist' nm readme = do
SH.cp readme "README.markdown"
SH.run_ "stack" ["sdist","--stack-yaml","stack-8.0.yaml"]
(pth,tb) <- analyse_so <$> SH.lastStderr
SH.cp (SH.fromText $ pth) $ SH.fromText $ "releases/"<>tb
SH.cp (SH.fromText $ pth) $ SH.fromText $ "releases/" M.<> tb
where
analyse_so so = (mtch!$$[cp|pth|],mtch!$$[cp|tb|])
where
Expand All @@ -333,8 +333,8 @@ establish nm nm' = SH.shelly $ SH.verbosely $ do
SH.rm_f "regex-examples.cabal"
SH.cp (SH.fromText sf) (SH.fromText df)
where
sf = "lib/"<>nm<>".cabal"
df = nm'<>".cabal"
sf = "lib/" M.<> nm M.<> ".cabal"
df = nm' M.<> ".cabal"
test_release :: T.Text -> IO ()
test_release vrn_t = do
Expand All @@ -351,10 +351,10 @@ test_release vrn_t = do
setCurrentDirectory "../.."
where
unpack rp pn = do
SH.run_ "tar" ["xzf",rp<>"/"<>pn_vrn<>".tar.gz"]
SH.mv (SH.fromText pn_vrn) (SH.fromText $ "test-"<>pn)
SH.run_ "tar" ["xzf",rp M.<> "/" M.<> pn_vrn M.<> ".tar.gz"]
SH.mv (SH.fromText pn_vrn) (SH.fromText $ "test-" M.<> pn)
where
pn_vrn = pn<>"-"<>vrn_t
pn_vrn = pn M.<> "-" M.<> vrn_t
\end{code}


Expand Down
4 changes: 2 additions & 2 deletions examples/re-gen-modules.lhs
Expand Up @@ -17,7 +17,7 @@ The tool is self-testing: run it with no arguments (or `cabal test`).
module Main (main) where
import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.Monoid
import qualified Data.Monoid as M
import qualified Data.Text as T
import Prelude.Compat
import System.Directory
Expand Down Expand Up @@ -149,7 +149,7 @@ source_api_mp :: ModPath
source_api_mp = "Text.RE.TDFA.ByteString.Lazy"
orphan_import :: ModPath -> LBS.ByteString
orphan_import mp = "import Text.Regex." <> LBS.pack mp <> "()"
orphan_import mp = "import Text.Regex." M.<> LBS.pack mp M.<> "()"
tdfa_re, module_re, import_re, bs_re, orp_re :: RE
tdfa_re = [re|TDFA|]
Expand Down
46 changes: 23 additions & 23 deletions examples/re-prep.lhs
Expand Up @@ -28,7 +28,7 @@ import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.IORef
import qualified Data.List as L
import Data.Maybe
import Data.Monoid
import qualified Data.Monoid as M
import qualified Data.Text as T
import Network.HTTP.Conduit
import Prelude.Compat
Expand Down Expand Up @@ -301,16 +301,16 @@ use these definitions instead.
\begin{code}
begin_code, end_code :: LBS.ByteString
begin_code = "\\"<>"begin{code}"
end_code = "\\"<>"end{code}"
begin_code = "\\" M.<> "begin{code}"
end_code = "\\" M.<> "end{code}"
\end{code}
\begin{code}
mk_list :: [String] -> [LBS.ByteString]
mk_list [] = [" []"]
mk_list (ide0:ides) = f "[" ide0 $ foldr (f ",") [" ]"] ides
where
f pfx ide t = (" "<>pfx<>" "<>LBS.pack ide) : t
f pfx ide t = (" " M.<> pfx M.<> " " M.<> LBS.pack ide) : t
\end{code}
Expand Down Expand Up @@ -533,7 +533,7 @@ pandoc_page :: Page -> IO ()
pandoc_page pg = do
mt_lbs <- setup_ttl <$> LBS.readFile (page_master_file pg)
(hdgs,md_lbs) <- prep_page' MM_pandoc mt_lbs
LBS.writeFile "tmp/metadata.markdown" $ LBS.unlines ["---","title: "<>page_title pg,"---"]
LBS.writeFile "tmp/metadata.markdown" $ LBS.unlines ["---","title: " M.<> page_title pg,"---"]
LBS.writeFile "tmp/heading.markdown" $ page_heading pg
LBS.writeFile "tmp/page_pre_body.html" $ mk_pre_body_html pg hdgs
LBS.writeFile "tmp/page_pst_body.html" pst_body_html
Expand Down Expand Up @@ -574,7 +574,7 @@ data MarkdownMode
page_heading :: Page -> LBS.ByteString
page_heading PG_index = ""
page_heading pg =
"<p class='pagebc'><a href='.' title='Home'>Home</a> &raquo; **"<>page_title pg<>"**</p>\n"
"<p class='pagebc'><a href='.' title='Home'>Home</a> &raquo; **" M.<> page_title pg M.<> "**</p>\n"
prep_page :: LBS.ByteString -> MarkdownMode -> FilePath -> FilePath -> IO ()
prep_page ttl mmd in_fp out_fp = do
Expand All @@ -597,7 +597,7 @@ prep_page' mmd lbs = do
lbs1 <- fmap (tweak_md mmd) $ sed' (scr rf_h rf_t) =<< include lbs
lbs2 <- fromMaybe "" <$> fin_task_list' mmd rf_t
hdgs <- reverse <$> readIORef rf_h
return (hdgs,lbs1<>lbs2)
return (hdgs,lbs1 M.<> lbs2)
where
scr rf_h rf_t = Select
[ Function [re|^%heading#${ide}(@{%id}) +${ttl}([^ ].*)$|] TOP $ heading mmd rf_t rf_h
Expand All @@ -617,32 +617,32 @@ heading :: MarkdownMode
heading mmd rf_t rf_h _ mtch _ _ = do
lbs <- fromMaybe "" <$> fin_task_list' mmd rf_t
modifyIORef rf_h (Heading ide ttl:)
return $ Just $ lbs<>h2
return $ Just $ lbs M.<> h2
where
h2 = case mmd of
MM_github -> "## "<>ttl
MM_hackage -> "## "<>ttl
MM_pandoc -> "<h2 id='"<>ide<>"'>"<>ttl<>"</h2>"
MM_github -> "## " M.<> ttl
MM_hackage -> "## " M.<> ttl
MM_pandoc -> "<h2 id='" M.<> ide M.<> "'>" M.<> ttl M.<> "</h2>"
ide = mtch !$$ [cp|ide|]
ttl = mtch !$$ [cp|ttl|]
mk_pre_body_html :: Page -> [Heading] -> LBS.ByteString
mk_pre_body_html pg hdgs = hdr <> LBS.concat (map nav [minBound..maxBound]) <> ftr
mk_pre_body_html pg hdgs = hdr M.<> LBS.concat (map nav [minBound..maxBound]) M.<> ftr
where
hdr :: LBS.ByteString
hdr = [here| <div id="container">
<div id="sidebar">
<div id="corner">
|] <> branding <> [here|
|] M.<> branding M.<> [here|
</div>
<div class="widget" id="pages">
<ul class="page-nav">
|]
nav dst_pg = LBS.unlines $
nav_li " " pg_cls pg_adr pg_ttl :
[ nav_li " " ["secnav"] ("#"<>_hdg_id) _hdg_title
[ nav_li " " ["secnav"] ("#" M.<> _hdg_id) _hdg_title
| Heading{..} <- hdgs
, is_moi
]
Expand Down Expand Up @@ -708,7 +708,7 @@ mk_pre_body_html pg hdgs = hdr <> LBS.concat (map nav [minBound..maxBound]) <> f
pst_body_html :: LBS.ByteString
pst_body_html = [here| </div>
</div>
|] <> tracking
|] M.<> tracking
\end{code}
Expand All @@ -729,7 +729,7 @@ task_list :: MarkdownMode -- ^ what flavour of md are we generatin
task_list mmd rf chk _ mtch _ _ =
case mmd of
MM_github -> return Nothing
MM_hackage -> return $ Just $ "&nbsp;&nbsp;&nbsp;&nbsp;"<>cb<>"&nbsp;&nbsp;"<>itm<>"\n"
MM_hackage -> return $ Just $ "&nbsp;&nbsp;&nbsp;&nbsp;" M.<> cb M.<> "&nbsp;&nbsp;" M.<> itm M.<> "\n"
MM_pandoc -> do
in_tl <- readIORef rf
writeIORef rf True
Expand Down Expand Up @@ -759,7 +759,7 @@ fin_task_list :: MarkdownMode -- ^ what flavour of md are we gener
-> Capture LBS.ByteString -- ^ the capture weare replacing (unsuded)
-> IO (Maybe LBS.ByteString) -- ^ the replacement text, or Nothing to indicate no change to this line
fin_task_list mmd rf_t _ mtch _ _ =
fmap (<>matchSource mtch) <$> fin_task_list' mmd rf_t
fmap ( M.<> matchSource mtch) <$> fin_task_list' mmd rf_t
-- | close any task list being processed, returning the closing text
-- as necessary
Expand Down Expand Up @@ -788,7 +788,7 @@ pandoc_lhs' title repo_path in_file out_file = do
LBS.writeFile "tmp/metadata.markdown" $
LBS.unlines
[ "---"
, "title: "<>LBS.pack title
, "title: " M.<> LBS.pack title
, "---"
]
LBS.writeFile "tmp/bc.html" bc
Expand All @@ -812,21 +812,21 @@ pandoc_lhs' title repo_path in_file out_file = do
where
bc = LBS.unlines
-- [ "<div class='brandingdiv'>"
-- , " " <> branding
-- , " " M.<> branding
-- , "</div>"
[ "<div class='bcdiv'>"
, " <ol class='breadcrumb'>"
, " <li>"<>branding<>"</li>"
, " <li><a title='source file' href='" <>
repo_url <> "'>" <> (LBS.pack title) <> "</a></li>"
, " <li>" M.<> branding M.<> "</li>"
, " <li><a title='source file' href='" M.<>
repo_url M.<> "'>" M.<> (LBS.pack title) M.<> "</a></li>"
, "</ol>"
, "</div>"
, "<div class='litcontent'>"
]
ft = LBS.concat
[ "</div>"
] <> tracking
] M.<> tracking
repo_url = LBS.concat
[ "https://github.com/iconnect/regex/blob/master/"
Expand Down
10 changes: 5 additions & 5 deletions examples/re-tests.lhs
Expand Up @@ -34,7 +34,7 @@ import Data.Char
import qualified Data.Foldable as F
import qualified Data.HashMap.Strict as HM
import Data.Maybe
import Data.Monoid
import qualified Data.Monoid as M
import qualified Data.Sequence as S
import Data.String
import qualified Data.Text as T
Expand Down Expand Up @@ -333,8 +333,8 @@ replace_methods_tests = testGroup "Replace"
, testCase "Seq Char" $ do
let ms = S.fromList str_ =~ regex_ :: Matches (S.Seq Char)
f = \_ (RELocation i j) Capture{..} -> Just $ S.fromList $
"(" <> show i <> ":" <> show_co j <> ":" <>
F.toList capturedText <> ")"
"(" M.<> show i M.<> ":" M.<> show_co j M.<> ":" M.<>
F.toList capturedText M.<> ")"
r = replaceAllCaptures ALL f ms
assertEqual "replaceAllCaptures" r $
S.fromList "(0:0:(0:1:a) (0:2:bbbb)) (1:0:(1:1:aa) (1:2:b))"
Expand All @@ -355,8 +355,8 @@ replace_methods_tests = testGroup "Replace"
"(0:0:(0:1:a) (0:2:bbbb)) (1:0:(1:1:aa) (1:2:b))"
fmt :: (IsString s,Replace s) => a -> RELocation -> Capture s -> Maybe s
fmt _ (RELocation i j) Capture{..} = Just $ "(" <> packR (show i) <> ":" <>
packR (show_co j) <> ":" <> capturedText <> ")"
fmt _ (RELocation i j) Capture{..} = Just $ "(" M.<> packR (show i) M.<> ":" M.<>
packR (show_co j) M.<> ":" M.<> capturedText M.<> ")"
show_co (CaptureOrdinal j) = show j
\end{code}
Expand Down

0 comments on commit 79bd8b0

Please sign in to comment.