How to work with Data.Text via pcre-heavy












0















I need a simple example to work with Data.Text via prce-heavy. My example is not working, why?



{-# LANGUAGE OverloadedStrings, QuasiQuotes, FlexibleContexts #-}

import Data.Text
import Text.Regex.PCRE.Heavy
import qualified Data.Text.IO as TIO

main = do
let text = "xxx@yahoo.com" :: Text
let
text2 :: Text
text2 = gsub ([re|xxx|]) ("yyy" :: Text) text
TIO.putStrLn text2


But the same code with String work well:



{-# LANGUAGE QuasiQuotes, FlexibleContexts #-}

import Text.Regex.PCRE.Heavy

main = do
let text = "xxx@yahoo.com" :: String
let
text2 :: String
text2 = gsub ([re|xxx|]) ("yyy" :: String) text
putStrLn text2




Errror for 1st sampe:



textproblem.hs:11:15: error:
* No instance for (Data.String.Conversions.ConvertibleStrings
Data.String.Conversions.SBS Text)
arising from a use of `gsub'
* In the expression:
gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs ("xxx" :: String))
[read "PCREOption {unPCREOption = 2048}" :: PCREOption]))
("yyy" :: Text)
text
In an equation for `text2':
text2
= gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs ("xxx" :: String))
[read "PCREOption {unPCREOption = 2048}" :: PCREOption]))
("yyy" :: Text)
text
In the expression:
do { let text = ...;
let text2 :: Text
text2
= gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs (...)) ...))
("yyy" :: Text)
text;
TIO.putStrLn text2 }









share|improve this question




















  • 1





    Do you see an error? If so, what is it

    – pdexter
    Nov 26 '18 at 7:04











  • I've run the program successfully using stack (docs.haskellstack.org/en/stable/README) with ghc 8.4.4 and stackage 12.19. How are you trying to run the program?

    – pdexter
    Nov 26 '18 at 7:37











  • ghc 8.0.2 Haskell Platform on Windows 7 64 bit. pcre-light compiled with help of msys2

    – Vladimir
    Nov 26 '18 at 9:54











  • I'll try to install new Haskell Platform and see...

    – Vladimir
    Nov 26 '18 at 9:55
















0















I need a simple example to work with Data.Text via prce-heavy. My example is not working, why?



{-# LANGUAGE OverloadedStrings, QuasiQuotes, FlexibleContexts #-}

import Data.Text
import Text.Regex.PCRE.Heavy
import qualified Data.Text.IO as TIO

main = do
let text = "xxx@yahoo.com" :: Text
let
text2 :: Text
text2 = gsub ([re|xxx|]) ("yyy" :: Text) text
TIO.putStrLn text2


But the same code with String work well:



{-# LANGUAGE QuasiQuotes, FlexibleContexts #-}

import Text.Regex.PCRE.Heavy

main = do
let text = "xxx@yahoo.com" :: String
let
text2 :: String
text2 = gsub ([re|xxx|]) ("yyy" :: String) text
putStrLn text2




Errror for 1st sampe:



textproblem.hs:11:15: error:
* No instance for (Data.String.Conversions.ConvertibleStrings
Data.String.Conversions.SBS Text)
arising from a use of `gsub'
* In the expression:
gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs ("xxx" :: String))
[read "PCREOption {unPCREOption = 2048}" :: PCREOption]))
("yyy" :: Text)
text
In an equation for `text2':
text2
= gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs ("xxx" :: String))
[read "PCREOption {unPCREOption = 2048}" :: PCREOption]))
("yyy" :: Text)
text
In the expression:
do { let text = ...;
let text2 :: Text
text2
= gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs (...)) ...))
("yyy" :: Text)
text;
TIO.putStrLn text2 }









share|improve this question




















  • 1





    Do you see an error? If so, what is it

    – pdexter
    Nov 26 '18 at 7:04











  • I've run the program successfully using stack (docs.haskellstack.org/en/stable/README) with ghc 8.4.4 and stackage 12.19. How are you trying to run the program?

    – pdexter
    Nov 26 '18 at 7:37











  • ghc 8.0.2 Haskell Platform on Windows 7 64 bit. pcre-light compiled with help of msys2

    – Vladimir
    Nov 26 '18 at 9:54











  • I'll try to install new Haskell Platform and see...

    – Vladimir
    Nov 26 '18 at 9:55














0












0








0








I need a simple example to work with Data.Text via prce-heavy. My example is not working, why?



{-# LANGUAGE OverloadedStrings, QuasiQuotes, FlexibleContexts #-}

import Data.Text
import Text.Regex.PCRE.Heavy
import qualified Data.Text.IO as TIO

main = do
let text = "xxx@yahoo.com" :: Text
let
text2 :: Text
text2 = gsub ([re|xxx|]) ("yyy" :: Text) text
TIO.putStrLn text2


But the same code with String work well:



{-# LANGUAGE QuasiQuotes, FlexibleContexts #-}

import Text.Regex.PCRE.Heavy

main = do
let text = "xxx@yahoo.com" :: String
let
text2 :: String
text2 = gsub ([re|xxx|]) ("yyy" :: String) text
putStrLn text2




Errror for 1st sampe:



textproblem.hs:11:15: error:
* No instance for (Data.String.Conversions.ConvertibleStrings
Data.String.Conversions.SBS Text)
arising from a use of `gsub'
* In the expression:
gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs ("xxx" :: String))
[read "PCREOption {unPCREOption = 2048}" :: PCREOption]))
("yyy" :: Text)
text
In an equation for `text2':
text2
= gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs ("xxx" :: String))
[read "PCREOption {unPCREOption = 2048}" :: PCREOption]))
("yyy" :: Text)
text
In the expression:
do { let text = ...;
let text2 :: Text
text2
= gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs (...)) ...))
("yyy" :: Text)
text;
TIO.putStrLn text2 }









share|improve this question
















I need a simple example to work with Data.Text via prce-heavy. My example is not working, why?



{-# LANGUAGE OverloadedStrings, QuasiQuotes, FlexibleContexts #-}

import Data.Text
import Text.Regex.PCRE.Heavy
import qualified Data.Text.IO as TIO

main = do
let text = "xxx@yahoo.com" :: Text
let
text2 :: Text
text2 = gsub ([re|xxx|]) ("yyy" :: Text) text
TIO.putStrLn text2


But the same code with String work well:



{-# LANGUAGE QuasiQuotes, FlexibleContexts #-}

import Text.Regex.PCRE.Heavy

main = do
let text = "xxx@yahoo.com" :: String
let
text2 :: String
text2 = gsub ([re|xxx|]) ("yyy" :: String) text
putStrLn text2




Errror for 1st sampe:



textproblem.hs:11:15: error:
* No instance for (Data.String.Conversions.ConvertibleStrings
Data.String.Conversions.SBS Text)
arising from a use of `gsub'
* In the expression:
gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs ("xxx" :: String))
[read "PCREOption {unPCREOption = 2048}" :: PCREOption]))
("yyy" :: Text)
text
In an equation for `text2':
text2
= gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs ("xxx" :: String))
[read "PCREOption {unPCREOption = 2048}" :: PCREOption]))
("yyy" :: Text)
text
In the expression:
do { let text = ...;
let text2 :: Text
text2
= gsub
((Text.Regex.PCRE.Light.compile
(Data.String.Conversions.cs (...)) ...))
("yyy" :: Text)
text;
TIO.putStrLn text2 }






regex haskell text pcre






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 8:23









Micha Wiedenmann

10.4k1364104




10.4k1364104










asked Nov 26 '18 at 7:01









VladimirVladimir

1807




1807








  • 1





    Do you see an error? If so, what is it

    – pdexter
    Nov 26 '18 at 7:04











  • I've run the program successfully using stack (docs.haskellstack.org/en/stable/README) with ghc 8.4.4 and stackage 12.19. How are you trying to run the program?

    – pdexter
    Nov 26 '18 at 7:37











  • ghc 8.0.2 Haskell Platform on Windows 7 64 bit. pcre-light compiled with help of msys2

    – Vladimir
    Nov 26 '18 at 9:54











  • I'll try to install new Haskell Platform and see...

    – Vladimir
    Nov 26 '18 at 9:55














  • 1





    Do you see an error? If so, what is it

    – pdexter
    Nov 26 '18 at 7:04











  • I've run the program successfully using stack (docs.haskellstack.org/en/stable/README) with ghc 8.4.4 and stackage 12.19. How are you trying to run the program?

    – pdexter
    Nov 26 '18 at 7:37











  • ghc 8.0.2 Haskell Platform on Windows 7 64 bit. pcre-light compiled with help of msys2

    – Vladimir
    Nov 26 '18 at 9:54











  • I'll try to install new Haskell Platform and see...

    – Vladimir
    Nov 26 '18 at 9:55








1




1





Do you see an error? If so, what is it

– pdexter
Nov 26 '18 at 7:04





Do you see an error? If so, what is it

– pdexter
Nov 26 '18 at 7:04













I've run the program successfully using stack (docs.haskellstack.org/en/stable/README) with ghc 8.4.4 and stackage 12.19. How are you trying to run the program?

– pdexter
Nov 26 '18 at 7:37





I've run the program successfully using stack (docs.haskellstack.org/en/stable/README) with ghc 8.4.4 and stackage 12.19. How are you trying to run the program?

– pdexter
Nov 26 '18 at 7:37













ghc 8.0.2 Haskell Platform on Windows 7 64 bit. pcre-light compiled with help of msys2

– Vladimir
Nov 26 '18 at 9:54





ghc 8.0.2 Haskell Platform on Windows 7 64 bit. pcre-light compiled with help of msys2

– Vladimir
Nov 26 '18 at 9:54













I'll try to install new Haskell Platform and see...

– Vladimir
Nov 26 '18 at 9:55





I'll try to install new Haskell Platform and see...

– Vladimir
Nov 26 '18 at 9:55












1 Answer
1






active

oldest

votes


















0














After reinstalling Haskell Platform to recent version and adding pcre library to msys2 and some experiments, I can say, that this sample works well (Haskell Platform on Windows-7 (64-bit) with ghc 8.4.3, msys2 with pcre.h and libpcre.a added via pacman, and installed carefully pcre-light and pcre-heavy). On Debian Linux (64-bit) it works well, too, and without any tricks. Why I saw a previous error -- I have no idea, maybe, except problem with older version.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53476110%2fhow-to-work-with-data-text-via-pcre-heavy%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    After reinstalling Haskell Platform to recent version and adding pcre library to msys2 and some experiments, I can say, that this sample works well (Haskell Platform on Windows-7 (64-bit) with ghc 8.4.3, msys2 with pcre.h and libpcre.a added via pacman, and installed carefully pcre-light and pcre-heavy). On Debian Linux (64-bit) it works well, too, and without any tricks. Why I saw a previous error -- I have no idea, maybe, except problem with older version.






    share|improve this answer




























      0














      After reinstalling Haskell Platform to recent version and adding pcre library to msys2 and some experiments, I can say, that this sample works well (Haskell Platform on Windows-7 (64-bit) with ghc 8.4.3, msys2 with pcre.h and libpcre.a added via pacman, and installed carefully pcre-light and pcre-heavy). On Debian Linux (64-bit) it works well, too, and without any tricks. Why I saw a previous error -- I have no idea, maybe, except problem with older version.






      share|improve this answer


























        0












        0








        0







        After reinstalling Haskell Platform to recent version and adding pcre library to msys2 and some experiments, I can say, that this sample works well (Haskell Platform on Windows-7 (64-bit) with ghc 8.4.3, msys2 with pcre.h and libpcre.a added via pacman, and installed carefully pcre-light and pcre-heavy). On Debian Linux (64-bit) it works well, too, and without any tricks. Why I saw a previous error -- I have no idea, maybe, except problem with older version.






        share|improve this answer













        After reinstalling Haskell Platform to recent version and adding pcre library to msys2 and some experiments, I can say, that this sample works well (Haskell Platform on Windows-7 (64-bit) with ghc 8.4.3, msys2 with pcre.h and libpcre.a added via pacman, and installed carefully pcre-light and pcre-heavy). On Debian Linux (64-bit) it works well, too, and without any tricks. Why I saw a previous error -- I have no idea, maybe, except problem with older version.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 6 '18 at 11:17









        VladimirVladimir

        1807




        1807






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53476110%2fhow-to-work-with-data-text-via-pcre-heavy%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)