From a4ff73944e8ba02f82dbfa8c7aaff20ac438ba2c Mon Sep 17 00:00:00 2001 From: Jaro Date: Sun, 12 Mar 2023 09:20:57 +0100 Subject: [PATCH] Remove (~) operator from ParagraphConstruction. The tilde operator was causing compilation errors with older versions of GHC, possibly due to a conflict with the lazy pattern match syntax. It has been replaced by a pure Haskell alternative that uses function application. --- .../ParagraphLayout/ParagraphConstruction.hs | 5 ++- .../Internal/ParagraphConstruction.hs | 6 --- .../Text/ParagraphLayout/ParagraphData.hs | 42 +++++++++---------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/lib/Data/Text/ParagraphLayout/ParagraphConstruction.hs b/lib/Data/Text/ParagraphLayout/ParagraphConstruction.hs index 6960bd1..f89448e 100644 --- a/lib/Data/Text/ParagraphLayout/ParagraphConstruction.hs +++ b/lib/Data/Text/ParagraphLayout/ParagraphConstruction.hs @@ -1,7 +1,9 @@ -- | Infix operators for construction of paragraphs with readable code. -- -- Example construction: --- @"ignored prefix" |\< en~"one two " \>|\< ja~"三四" \>| "ignored suffix"@ +-- @en = (,) SpanOptions { spanLanguage = "en" }@ +-- @ja = (,) SpanOptions { spanLanguage = "ja" }@ +-- @"ignored prefix" |\< en "one two " \>|\< ja "三四" \>| "ignored suffix"@ -- -- Special syntax for paragraphs with no contents: -- @"ignored prefix" |<>| "ignored suffix"@ @@ -10,7 +12,6 @@ module Data.Text.ParagraphLayout.ParagraphConstruction ,(>|<) ,(|<) ,(|<>|) - ,(~) ) where diff --git a/src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs b/src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs index 65e8844..908ce0d 100644 --- a/src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs +++ b/src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs @@ -3,7 +3,6 @@ module Data.Text.ParagraphLayout.Internal.ParagraphConstruction ,(>|<) ,(|<) ,(|<>|) - ,(~) ) where @@ -53,8 +52,3 @@ prefix |< (oldText, spans) = Paragraph arr afterPrefix spans infixr 5 |<>| (|<>|) :: String -> String -> ParagraphOptions -> Paragraph prefix |<>| suffix = prefix |< (chunk (pack suffix) empty, []) - --- | Combine language with text. -infix 6 ~ -(~) :: SpanOptions -> String -> (SpanOptions, String) -opts ~ txt = (opts, txt) diff --git a/test/Data/Text/ParagraphLayout/ParagraphData.hs b/test/Data/Text/ParagraphLayout/ParagraphData.hs index 597c39e..b8a89c0 100644 --- a/test/Data/Text/ParagraphLayout/ParagraphData.hs +++ b/test/Data/Text/ParagraphLayout/ParagraphData.hs @@ -18,63 +18,63 @@ import Data.Text.ParagraphLayout (Paragraph, ParagraphOptions, SpanOptions(..)) import Data.Text.ParagraphLayout.ParagraphConstruction -- | Span with text in the Czech language. -cs :: SpanOptions -cs = SpanOptions { spanLanguage = "cs" } +cs :: String -> (SpanOptions, String) +cs = (,) SpanOptions { spanLanguage = "cs" } -- | Span with text in the English language. -en :: SpanOptions -en = SpanOptions { spanLanguage = "en" } +en :: String -> (SpanOptions, String) +en = (,) SpanOptions { spanLanguage = "en" } -- | Span with text in the Japanese language. -ja :: SpanOptions -ja = SpanOptions { spanLanguage = "ja" } +ja :: String -> (SpanOptions, String) +ja = (,) SpanOptions { spanLanguage = "ja" } -- | Span with text in the Serbian language. -sr :: SpanOptions -sr = SpanOptions { spanLanguage = "sr" } +sr :: String -> (SpanOptions, String) +sr = (,) SpanOptions { spanLanguage = "sr" } -- | Span with text in no language. -zxx :: SpanOptions -zxx = SpanOptions { spanLanguage = "zxx" } +zxx :: String -> (SpanOptions, String) +zxx = (,) SpanOptions { spanLanguage = "zxx" } emptyParagraph :: ParagraphOptions -> Paragraph emptyParagraph = "x" |<>| "zzzzzzz" emptySpanParagraph :: ParagraphOptions -> Paragraph -emptySpanParagraph = "xx" |< en~"" >| "zzzzz" +emptySpanParagraph = "xx" |< en "" >| "zzzzz" trivialParagraph :: ParagraphOptions -> Paragraph -trivialParagraph = "xxx" |< en~"a" >| "zzz" +trivialParagraph = "xxx" |< en "a" >| "zzz" ligatureParagraph :: ParagraphOptions -> Paragraph -ligatureParagraph = "" |< en~"inefficient" >| "" +ligatureParagraph = "" |< en "inefficient" >| "" -- | Fillter text using the Arabic script. -- Source: arabicFillerParagraph :: ParagraphOptions -> Paragraph -arabicFillerParagraph = "xxxx" |< zxx~"إعلان بأيدي وبغطاء هذه من. عرض غينيا يتمكن واعتلاء في. و فرنسا الثانية وفي, أسر إذ السبب ارتكبها مليارات. فكان الشتاء، ما حتى, غير أن وصغار الأخذ. في الصفحة لهيمنة وتتحمّل وتم, أن أما وبداية الغالي." >| "z" +arabicFillerParagraph = "xxxx" |< zxx "إعلان بأيدي وبغطاء هذه من. عرض غينيا يتمكن واعتلاء في. و فرنسا الثانية وفي, أسر إذ السبب ارتكبها مليارات. فكان الشتاء، ما حتى, غير أن وصغار الأخذ. في الصفحة لهيمنة وتتحمّل وتم, أن أما وبداية الغالي." >| "z" spannedArabicFillerParagraph :: ParagraphOptions -> Paragraph -spannedArabicFillerParagraph = "xxxx" |< zxx~"إعلان بأيدي وبغطاء " >|< zxx~"هذه من. عرض" >|< zxx~" غينيا يتمكن واعتلاء " >|< zxx~"في. و فرنسا" >|< zxx~" الثانية وفي, أسر " >|< zxx~"إذ السبب ارتكبها" >|< zxx~" مليارات. فكان الشتاء، " >|< zxx~"ما حتى, غير" >|< zxx~" أن وصغار الأخذ. " >|< zxx~"في الصفحة لهيمنة" >|< zxx~" وتتحمّل وتم, أن " >|< zxx~"أما وبداية الغالي." >| "z" +spannedArabicFillerParagraph = "xxxx" |< zxx "إعلان بأيدي وبغطاء " >|< zxx "هذه من. عرض" >|< zxx " غينيا يتمكن واعتلاء " >|< zxx "في. و فرنسا" >|< zxx " الثانية وفي, أسر " >|< zxx "إذ السبب ارتكبها" >|< zxx " مليارات. فكان الشتاء، " >|< zxx "ما حتى, غير" >|< zxx " أن وصغار الأخذ. " >|< zxx "في الصفحة لهيمنة" >|< zxx " وتتحمّل وتم, أن " >|< zxx "أما وبداية الغالي." >| "z" -- | Fillter text using the Latin script. -- Source: loremIpsumParagraph :: ParagraphOptions -> Paragraph -loremIpsumParagraph = "xxxx" |< zxx~"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." >| "z" +loremIpsumParagraph = "xxxx" |< zxx "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." >| "z" spannedLoremIpsumParagraph :: ParagraphOptions -> Paragraph -spannedLoremIpsumParagraph = "xxxx" |< zxx~"Lorem ipsum dolor " >|< zxx~"sit amet, consectetur" >|< zxx~" adipiscing elit, sed " >|< zxx~"do eiusmod tempor" >|< zxx~" incididunt ut labore " >|< zxx~"et dolore magna" >|< zxx~" aliqua. Ut enim " >|< zxx~"ad minim veniam," >|< zxx~" quis nostrud exercitation " >|< zxx~"ullamco laboris nisi" >|< zxx~" ut aliquip ex " >|< zxx~"ea commodo consequat." >|< zxx~" Duis aute irure " >|< zxx~"dolor in reprehenderit" >|< zxx~" in voluptate velit " >|< zxx~"esse cillum dolore" >|< zxx~" eu fugiat nulla " >|< zxx~"pariatur. Excepteur" >|< zxx~" sint occaecat cupidatat " >|< zxx~"non proident, sunt" >|< zxx~" in culpa qui " >|< zxx~"officia deserunt mollit" >|< zxx~" anim id est " >|< zxx~"laborum." >| "z" +spannedLoremIpsumParagraph = "xxxx" |< zxx "Lorem ipsum dolor " >|< zxx "sit amet, consectetur" >|< zxx " adipiscing elit, sed " >|< zxx "do eiusmod tempor" >|< zxx " incididunt ut labore " >|< zxx "et dolore magna" >|< zxx " aliqua. Ut enim " >|< zxx "ad minim veniam," >|< zxx " quis nostrud exercitation " >|< zxx "ullamco laboris nisi" >|< zxx " ut aliquip ex " >|< zxx "ea commodo consequat." >|< zxx " Duis aute irure " >|< zxx "dolor in reprehenderit" >|< zxx " in voluptate velit " >|< zxx "esse cillum dolore" >|< zxx " eu fugiat nulla " >|< zxx "pariatur. Excepteur" >|< zxx " sint occaecat cupidatat " >|< zxx "non proident, sunt" >|< zxx " in culpa qui " >|< zxx "officia deserunt mollit" >|< zxx " anim id est " >|< zxx "laborum." >| "z" czechHelloParagraph :: ParagraphOptions -> Paragraph -czechHelloParagraph = "xxxxx" |< cs~"Ahoj, světe!" >| "zz" +czechHelloParagraph = "xxxxx" |< cs "Ahoj, světe!" >| "zz" mixedScriptSerbianParagraph :: ParagraphOptions -> Paragraph -mixedScriptSerbianParagraph = "xxxxxx" |< sr~"Vikipedija (Википедија)" >| "zzzz" +mixedScriptSerbianParagraph = "xxxxxx" |< sr "Vikipedija (Википедија)" >| "zzzz" -- | For testing line breaking on boundaries that are different from script -- boundaries. mixedScriptWordsParagraph :: ParagraphOptions -> Paragraph -mixedScriptWordsParagraph = "xxxxxxx" |< zxx~"jjjжжжjjj jjjжжжjjj жжжjjjжжж жжжjjjжжж jжj jжj жjж жjж" >| "zzzzzzzz" +mixedScriptWordsParagraph = "xxxxxxx" |< zxx "jjjжжжjjj jjjжжжjjj жжжjjjжжж жжжjjjжжж jжj jжj жjж жjж" >| "zzzzzzzz" mixedLanguageLTRParagraph :: ParagraphOptions -> Paragraph -mixedLanguageLTRParagraph = "Tak " |< cs~"jsem tady, " >|< ja~"世界!" >| "zzzzzz" +mixedLanguageLTRParagraph = "Tak " |< cs "jsem tady, " >|< ja "世界!" >| "zzzzzz" -- 2.30.2