Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  subRegex https? with anchor href tags (Shakthi Kannan)
   2. Re:  subRegex https? with anchor href tags (Daniel Fischer)
   3. Re:  subRegex https? with anchor href tags (Shakthi Kannan)
   4. Re:  subRegex https? with anchor href tags (Daniel Fischer)
   5. Re:  subRegex https? with anchor href tags (Daniel Fischer)
   6. Re:  subRegex https? with anchor href tags (Shakthi Kannan)
   7. Re:  Couple of problems with leksah (Peter Hall)
   8. Re:  Couple of problems with leksah (Daniel Fischer)
   9. Re:  subRegex https? with anchor href tags (Shakthi Kannan)


----------------------------------------------------------------------

Message: 1
Date: Sat, 12 Nov 2011 16:00:39 +0530
From: Shakthi Kannan <shakthim...@gmail.com>
Subject: [Haskell-beginners] subRegex https? with anchor href tags
To: beginners@haskell.org
Message-ID:
        <cabg-yt2tncuvtwlgba5gmq0sfc1fs-_twayqxpsoq7af1sc...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hi,

I am trying to replace every occurrence of http://URL or https://URL with:

  <a href="http://URL";>  http://URL   </a>
  <a href="https://URL";> https://URL </a>

respectively in a text file. I tried with Text.Regex with an example:

Prelude> let s = "Google website is http://www.google.com in US"

Prelude> import Text.Regex

Prelude Text.Regex> let s3 = subRegex (mkRegex "https?:[^\\s\n\r]+") s
"<a href=\"\\1\"></a>"
Prelude Text.Regex> s3
"Google website is <a href=\"*** Exception: Ix{Int}.index: Index (1)
out of range ((0,0))
Prelude Text.Regex>

I then tried a simpler example:

Prelude Text.Regex> subRegex (mkRegex "e") "hello" "\\1"
"h*** Exception: Ix{Int}.index: Index (1) out of range ((0,0))

What could I be missing? I am using GHCi 6.12.3 on Fedora 14.
Appreciate any help in this regard.

Thanks,

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com



------------------------------

Message: 2
Date: Sat, 12 Nov 2011 13:14:35 +0100
From: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Subject: Re: [Haskell-beginners] subRegex https? with anchor href tags
To: beginners@haskell.org
Message-ID: <201111121314.35899.daniel.is.fisc...@googlemail.com>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Saturday 12 November 2011, 11:30:39, Shakthi Kannan wrote:
> I then tried a simpler example:
> 
> Prelude Text.Regex> subRegex (mkRegex "e") "hello" "\\1"
> "h*** Exception: Ix{Int}.index: Index (1) out of range ((0,0))
> 
> What could I be missing?

Maybe the backreferences numbering starts at 0?
Worth a try.




------------------------------

Message: 3
Date: Sat, 12 Nov 2011 18:53:30 +0530
From: Shakthi Kannan <shakthim...@gmail.com>
Subject: Re: [Haskell-beginners] subRegex https? with anchor href tags
To: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Cc: beginners@haskell.org
Message-ID:
        <cabg-yt3rumpw3gtdnncz_kupko631ncsnmfhbuvpmjkarih...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hi,

--- On Sat, Nov 12, 2011 at 5:44 PM, Daniel Fischer
<daniel.is.fisc...@googlemail.com> wrote:
| Maybe the backreferences numbering starts at 0?
| Worth a try.
\--

\0 represents the entire string match:

  http://cvs.haskell.org/Hugs/pages/libraries/base/Text-Regex.html

Prelude Text.Regex> subRegex (mkRegex "e") "hello" "\\0"
"hello"

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com



------------------------------

Message: 4
Date: Sat, 12 Nov 2011 15:50:38 +0100
From: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Subject: Re: [Haskell-beginners] subRegex https? with anchor href tags
To: Shakthi Kannan <shakthim...@gmail.com>
Cc: beginners@haskell.org
Message-ID: <201111121550.38185.daniel.is.fisc...@googlemail.com>
Content-Type: Text/Plain;  charset="utf-8"

On Saturday 12 November 2011, 14:23:30, Shakthi Kannan wrote:
> Hi,
> 
> --- On Sat, Nov 12, 2011 at 5:44 PM, Daniel Fischer
> 
> <daniel.is.fisc...@googlemail.com> wrote:
> | Maybe the backreferences numbering starts at 0?

Not backreferences, but who cares?

> | Worth a try.
> 
> \--
> 
> \0 represents the entire string match:

The entire *match*, that is, the part of the input matched by the regexp.
The other entries correspond to parts matched by certain subregexen in the 
match.

> 
>   http://cvs.haskell.org/Hugs/pages/libraries/base/Text-Regex.html

May I suggest using the docs at hackage, hugs hasn't had a release since 
2006, I don't think the docs are up to date. Unless you're actually using 
hugs, in which case I suggest switching to ghc.

http://hackage.haskell.org/package/regex-compat

> 
> Prelude Text.Regex> subRegex (mkRegex "e") "hello" "\\0"
> "hello"

Heh, I didn't see it immediately either ;)

Prelude Text.Regex> subRegex (mkRegex "e") "hello" ">\\0<"
"h>e<llo"

Of course, if you replace a substring with itself, it doesn't change 
anything.



Prelude Text.Regex> subRegex (mkRegex "https?[^\\s\n\r]+") "The best is 
http://haskell.org"; "<a href=\"\\0\">there</a>"
"The best is <a href=\"http://ha\";>there</a>skell.org"

Not what you want, character classes don't work that way,

Prelude Text.Regex> subRegex (mkRegex "https?[^[:space:]]+") "The best is 
http://haskell.org\n"; "<a href=\"\\0\">there</a>"
"The best is <a href=\"http://haskell.org\";>there</a>\n"

but that.

However,

Prelude Text.Regex> subRegex (mkRegex "https?[^[:space:]]+") "The best is 
http://haskell.org."; "<a href=\"\\0\">there</a>"
"The best is <a href=\"http://haskell.org.\";>there</a>"

please make an effort to not include final punctuation in the href, it's 
rather annoying how many 404s I get from that.





------------------------------

Message: 5
Date: Sat, 12 Nov 2011 16:29:24 +0100
From: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Subject: Re: [Haskell-beginners] subRegex https? with anchor href tags
To: Shakthi Kannan <shakthim...@gmail.com>
Cc: beginners@haskell.org
Message-ID: <201111121629.25020.daniel.is.fisc...@googlemail.com>
Content-Type: Text/Plain;  charset="utf-8"

On Saturday 12 November 2011, 16:10:58, Shakthi Kannan wrote:
> Hi,
> 
> --- On Sat, Nov 12, 2011 at 8:20 PM, Daniel Fischer
> 
> <daniel.is.fisc...@googlemail.com> wrote:
> | Prelude Text.Regex> subRegex (mkRegex "https?[^[:space:]]+") "The best
> | is http://haskell.org\n"; "<a href=\"\\0\">there</a>"
> | "The best is <a href=\"http://haskell.org\";>there</a>\n"
> 
> \--
> 
> Is there any way we can escape the " within <a href></a>, and not get
> the \" in the output?

The \" are just because that's Haskell's way of showing Strings. Strings 
are shown enclosed in quotes, and quotes (and other characters) appearing 
in the String are escaped. You can see what would get written to the file 
by outputting the String with putStrLn,

Prelude Text.Regex> putStrLn $ subRegex (mkRegex "https?://([:alpha:]|
[0-9]|.[[:alpha:]0-9])+") "The best is http://haskell.org."; "<a 
href=\"\\0\">there</a>"
The best is <a href="http://haskell.org";>there</a>.

See, just like it should be.

> I am producing HTML in the output, and the \"
> doesn't work with the anchor tag. Expected output is:
> 
>   "The best is <a href="http://haskell.org";>there</a>\n"
> 
> Thanks for your prompt help!
> 
> SK




------------------------------

Message: 6
Date: Sat, 12 Nov 2011 20:40:58 +0530
From: Shakthi Kannan <shakthim...@gmail.com>
Subject: Re: [Haskell-beginners] subRegex https? with anchor href tags
To: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Cc: beginners@haskell.org
Message-ID:
        <cabg-yt18250qs+fc4-azuufz15gxqy5xkcsoej_npjckfmp...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hi,

--- On Sat, Nov 12, 2011 at 8:20 PM, Daniel Fischer
<daniel.is.fisc...@googlemail.com> wrote:
| Prelude Text.Regex> subRegex (mkRegex "https?[^[:space:]]+") "The best is
| http://haskell.org\n"; "<a href=\"\\0\">there</a>"
| "The best is <a href=\"http://haskell.org\";>there</a>\n"
\--

Is there any way we can escape the " within <a href></a>, and not get
the \" in the output? I am producing HTML in the output, and the \"
doesn't work with the anchor tag. Expected output is:

  "The best is <a href="http://haskell.org";>there</a>\n"

Thanks for your prompt help!

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com



------------------------------

Message: 7
Date: Sat, 12 Nov 2011 16:32:10 +0000
From: Peter Hall <peter.h...@memorphic.com>
Subject: Re: [Haskell-beginners] Couple of problems with leksah
To: beginners@haskell.org
Cc: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Message-ID:
        <caa6hak76p4ahhtxw_nvx_pqyidqwi1jyt6j_acvcq0hyczn...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I still haven't managed to resolve this. Any thoughts on the errors below?

I don't understand why packages should be on hackage in the first
place if their dependencies are not available from there either. I
feel like you should have to explicitly opt-in to get any package that
has non-hackage or unreleased dependencies.

Peter


On Tue, Nov 8, 2011 at 1:47 AM, Peter Hall <peter.h...@memorphic.com> wrote:
> Thanks. That got me a bit further, but there are a lot more errors now!
>
> cabal: Error: some packages failed to install:
> binary-shared-0.8.1 failed during the building phase. The exception was:
> ExitFailure 1
> cairo-0.12.1 failed during the configure step. The exception was:
> ExitFailure 1
> gio-0.12.1 depends on glib-0.12.1 which failed to install.
> glib-0.12.1 failed during the configure step. The exception was:
> ExitFailure 1
> gtk-0.12.1 depends on glib-0.12.1 which failed to install.
> gtksourceview2-0.12.3 depends on glib-0.12.1 which failed to install.
> haddock-2.9.3 failed during the building phase. The exception was:
> ExitFailure 1
> hslogger-1.1.5 failed during the building phase. The exception was:
> ExitFailure 1
> ige-mac-integration-0.1.0.1 depends on glib-0.12.1 which failed to install.
> leksah-0.10.0.4 depends on hslogger-1.1.5 which failed to install.
> leksah-server-0.10.0.4 depends on hslogger-1.1.5 which failed to install.
> ltk-0.10.0.4 depends on haddock-2.9.3 which failed to install.
> pango-0.12.1 depends on glib-0.12.1 which failed to install.
>
>
>
> Peter
>
>
> On Tue, Nov 8, 2011 at 1:18 AM, Daniel Fischer
> <daniel.is.fisc...@googlemail.com> wrote:
>> On Tuesday 08 November 2011, 01:59:47, Peter Hall wrote:
>>> I didn't get any response on the Leksah forum, so I hope it's ok to ask
>>> here.
>>
>> Sure. Anything Haskell-related is okay to ask here.
>>
>>>
>>> First problem, I keep seeing this in the error log:
>>> > Setup: You need to re-run the 'configure' command. The version of
>>> > Cabal being used has changed (was Cabal-1.10.2.0, now
>>> > Cabal-1.10.1.0). Additionally the compiler is different (was
>>> > ghc-6.12, now ghc-7.0) which is probably the cause of the problem.
>>>
>>> When I run configure, it just prints:
>>> > Resolving dependencies...
>>> > Configuring pokercalc-0.0.1...
>>>
>>> But it doesn't fix anything.
>>
>> Sorry, no idea for that one.
>>
>>>
>>> The other problem is when I try to update cabal:
>>> > cabal install leksah
>>>
>>> Resolving dependencies...
>>> cabal: cannot configure haddock-2.9.4. It requires ghc >=7.2 && <7.4
>>> There is no available version of ghc that satisfies >=7.2 && <7.4
>>
>> haddock-2.9.4 is exclusively for ghc-7.2, with ghc-7.0, you need
>> haddock-2.9.2, try
>>
>> $ cabal install leksah --constraint="haddock < 2.9.4"
>>
>>>
>>> I'm using Haskell Platform 2011.2.0.1 for Mac OS X 10.6
>>> Any ideas?
>>>
>>> Peter
>>
>>
>



------------------------------

Message: 8
Date: Sat, 12 Nov 2011 18:11:28 +0100
From: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Subject: Re: [Haskell-beginners] Couple of problems with leksah
To: peter.h...@memorphic.com
Cc: beginners@haskell.org
Message-ID: <201111121811.28302.daniel.is.fisc...@googlemail.com>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Saturday 12 November 2011, 17:32:10, Peter Hall wrote:
> I still haven't managed to resolve this. Any thoughts on the errors
> below?

No idea why binary-shared failed to build. For more info, try to cabal-
install it with a higher verbosity level,

$ cabal install binary-shared -v2

(perhaps even -v3).

The other errors may be cascading from failing to build any gtk2hs package.
To install gtk2hs packages, you have to first

$ cabal install gtk2hs-buildtools

(that package contains only executables, no library, hence can't be a 
build-depend in the cabal file, alas). If you already have the buildtools 
somewhere in your path,

$ which gtk2hsC2hs

would be a quick test, something else has gone awry. Then try to manually 
install one of the gtk2hs packages, iirc, cairo doesn't depend on any 
other, so

$ cabal install cairo -v2

Hopefully the messages printed to stderr would allow to find out what 
broke.

> 
> I don't understand why packages should be on hackage in the first
> place if their dependencies are not available from there either. I

Are there packages on hackage with Haskell dependencies not available on 
hackage? That would be bad. (If C dependencies are not available from 
hackage, that's inconvenient, but natural.)

> feel like you should have to explicitly opt-in to get any package that
> has non-hackage or unreleased dependencies.

Agreed.

> 
> Peter
> 
> On Tue, Nov 8, 2011 at 1:47 AM, Peter Hall <peter.h...@memorphic.com> 
wrote:
> > Thanks. That got me a bit further, but there are a lot more errors
> > now!
> > 
> > cabal: Error: some packages failed to install:
> > binary-shared-0.8.1 failed during the building phase. The exception
> > was: ExitFailure 1
> > cairo-0.12.1 failed during the configure step. The exception was:
> > ExitFailure 1
> > gio-0.12.1 depends on glib-0.12.1 which failed to install.
> > glib-0.12.1 failed during the configure step. The exception was:
> > ExitFailure 1
> > gtk-0.12.1 depends on glib-0.12.1 which failed to install.
> > gtksourceview2-0.12.3 depends on glib-0.12.1 which failed to install.
> > haddock-2.9.3 failed during the building phase. The exception was:
> > ExitFailure 1
> > hslogger-1.1.5 failed during the building phase. The exception was:
> > ExitFailure 1
> > ige-mac-integration-0.1.0.1 depends on glib-0.12.1 which failed to
> > install. leksah-0.10.0.4 depends on hslogger-1.1.5 which failed to
> > install. leksah-server-0.10.0.4 depends on hslogger-1.1.5 which
> > failed to install. ltk-0.10.0.4 depends on haddock-2.9.3 which failed
> > to install. pango-0.12.1 depends on glib-0.12.1 which failed to
> > install.
> > 
> > 
> > 
> > Peter
> > 



------------------------------

Message: 9
Date: Sat, 12 Nov 2011 22:42:28 +0530
From: Shakthi Kannan <shakthim...@gmail.com>
Subject: Re: [Haskell-beginners] subRegex https? with anchor href tags
To: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Cc: beginners@haskell.org
Message-ID:
        <CABG-yt34Dyn1x1KUiV93bKpmpFznvahObZ6udJOcR-c=hgq...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hi,

--- On Sat, Nov 12, 2011 at 8:59 PM, Daniel Fischer
<daniel.is.fisc...@googlemail.com> wrote:
| Prelude Text.Regex> putStrLn $ subRegex (mkRegex "https?://([:alpha:]|
| [0-9]|.[[:alpha:]0-9])+") "The best is http://haskell.org."; "<a
| href=\"\\0\">there</a>"
| The best is <a href="http://haskell.org";>there</a>.
\--

Thank you very much.

I have made the changes available (can be improved?) at:

  https://gitorious.org/shakthimaan-tweets/mainline/blobs/master/html.hs

The output is at:

  http://www.shakthimaan.com/links/tweets.html

Appreciate your help!

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com



------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 41, Issue 18
*****************************************

Reply via email to