Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: A difficult package (Daniel Fischer)
2. Re: Re: why is something different within a function when it
comes out? (Michael Mossey)
3. Re: why is something different within a function when it
comes out? (prad)
4. Re: newtype record syntax (Brandon S Allbery KF8NH)
5. deducing type of multi-parameter type class (Alex)
6. Re: deducing type of multi-parameter type class (Michael Snoyman)
7. Creating databases with sqlite3 using HDBC (George Roberts)
8. Re: Creating databases with sqlite3 using HDBC (Michael Snoyman)
----------------------------------------------------------------------
Message: 1
Date: Thu, 15 Jul 2010 00:19:03 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] A difficult package
To: [email protected], [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
On Wednesday 14 July 2010 19:20:09, Ben Wise wrote:
> Folks,
>
> I'm trying to work through Conrad Barski's Haskell tutorial,
> http://www.lisperati.com/haskell/, and I've run into a difficult package
> problem. I've googled around for two days, but nothing seems to work.
>
> Basically, I can not get it recognize matchRegex, mkRegex, and similar.
> They are all in the Text.Regex.Posix package,
hoogle and hayoo think they're not in regex-posix but in regex-compat
> and version 0.94.1 is
> installed according to 'cabal list regex'. The 'import Text.Regex.Posix'
> line compiles just fine, so it is finding the package: it just doesn't
> find the symbols in it ?!
>
> But (under all four combinations of command line ghc or Leksah on
> Windows 7 or Ubuntu), it keeps trying to use the 'base' version, not
> posix.
Text.Regex.Posix imports and re-exports Text.Regex.Base, so if you're using
Text.Regex.Posix, you're *also* using regex-base.
> At least, that's what 'ghc -v main.hs'
add --make
> seems to be saying. In
> Leksah, adding some of the suggested build dependencies fixed earlier
> problems with importing the Text and Random things, but adding
> 'regex-compat' as suggested did not help.
>
> Has anyone else gotten CB's tutorial to work?
>
> Any suggestions as to how to get Text.Regex.Posix imported?
------------------------------
Message: 2
Date: Wed, 14 Jul 2010 17:28:18 -0700
From: Michael Mossey <[email protected]>
Subject: Re: [Haskell-beginners] Re: why is something different within
a function when it comes out?
To: prad <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
prad wrote:
> i looked at
> http://hackage.haskell.org/packages/archive/regex-tdfa/1.1.3/doc/html/Text-Regex-TDFA.html
> but am having difficulty figuring things out from the documentation -
> and there doesn't seem to be any multiline feature.
> surely there is some way to do this!
>
> also, python had a re.sub so you can replace things using regex
> searchs. how would you go about doing that in haskell?
>
For a parsing job, you might consider Parsec rather than regular
expressions. Parsec is present by default with the Haskell Platform. I have
not found any single comprehensive documentation on the latest version of
Parsec... I had to ask people for help a lot.
Mike
------------------------------
Message: 3
Date: Wed, 14 Jul 2010 18:19:25 -0700
From: prad <[email protected]>
Subject: [Haskell-beginners] Re: why is something different within a
function when it comes out?
To: [email protected]
Message-ID: <20100714181925.7b513...@gom>
Content-Type: text/plain; charset=ISO-8859-1
On Wed, 14 Jul 2010 17:28:18 -0700
Michael Mossey <[email protected]> wrote:
> For a parsing job, you might consider Parsec rather than regular
> expressions.
ok thx for this, because it's bound to be useful down the road.
i'm just trying to grab lines from something like this the stuff
between the <text> ... </text>:
<text>
The Mission of the League of Humane VotersĀ® (LOHV) is to create, unite,
and strengthen local political action committees, which work to enact
animal-friendly legislation and elect candidates for public office who
will use their votes and influence for animal protection.
As election time comes around, council candidates in Independence, Ohio
have taken the typical tactic of refusing to even answer questions
regarding their position on various matters.
Their 'silence speaks volumes'.
</text>
i'm using what chaddai showed me:
xtract p c = (c =~ p :: [[String]]) !! 0 !! 1
which works fine for single lines, but produces nothing for multiple
lines - same with some of the other ways i tried it with single lines
good, nothing for multiple. python requires setting the re.S flag which
i always found strange since \n i thought is a char as well.
--
In friendship,
prad
... with you on your journey
Towards Freedom
http://www.towardsfreedom.com (website)
Information, Inspiration, Imagination - truly a site for soaring I's
------------------------------
Message: 4
Date: Thu, 15 Jul 2010 00:59:24 -0400
From: Brandon S Allbery KF8NH <[email protected]>
Subject: Re: [Haskell-beginners] newtype record syntax
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 7/14/10 07:41 , Tom Doris wrote:
> Yes, makes sense, I always thought of the projection functions as being
> secondary. Thanks
Sometimes they are; but take a look at the definitions of various state-like
monads (State, Reader, Writer; ST also fits but has other things that might
well confuse rather than enlighten). State is probably the easiest to
understand, since it's just syntactic sugar for a tuple,
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkw+lawACgkQIn7hlCsL25X1dACbBB/E6tanorQ0Vht9pS4k3GiQ
SLkAn2gTdkhN55Cl4MSCKHoCVVRcBMWX
=wpVd
-----END PGP SIGNATURE-----
------------------------------
Message: 5
Date: Thu, 15 Jul 2010 06:59:15 +0100
From: Alex <[email protected]>
Subject: [Haskell-beginners] deducing type of multi-parameter type
class
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hi,
I'm trying to get the following code to compile:
======= Main.hs ==========
import IO
data MyInt = MyInt Int
data MyString = MyString String deriving Show
class Show b => MyClass a b where
fn :: a -> b
instance MyClass MyInt MyString where
fn (MyInt i) = MyString (show i)
myprint :: (MyClass a b) => a -> IO ()
myprint a = putStrLn $ show (fn a)
main = myprint 3
======= Main.hs ==========
with |ghc Main.hs -XMultiParamTypeClasses|. However, the compiler cannot
deduce the type of the |b| type variable (which in this case is
|MyString|). How can I explicitly tell this information to the compiler?
Many thanks,
Alex.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100715/cb046987/attachment-0001.html
------------------------------
Message: 6
Date: Thu, 15 Jul 2010 09:13:34 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] deducing type of multi-parameter type
class
To: Alex <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
I think what you're looking for is functional dependencies. Basically, the
way you have the typeclass set up right now, "fn $ MyInt 5" could in theory
turn into anything; if you wanted, you could declare an "instance MyClass
MyInt Double" or anything else. You would like the compiler to be able to
automatically determine the output type. Using functional dependencies:
class Show b => MyClass a b | a -> b where
You could also use type families for this, but I believe you cannot express
the "Show" superclass:
class MyClass a where
type MyResult a
fn :: a -> MyResult a
instance MyClass MyInt where
type MyResult MyInt = MyString
fn (MyInt i) = MyString (show i)
Michael
On Thu, Jul 15, 2010 at 8:59 AM, Alex <[email protected]> wrote:
> Hi,
>
> I'm trying to get the following code to compile:
>
> ======= Main.hs ==========
>
> import IO
>
> data MyInt = MyInt Int
> data MyString = MyString String deriving Show
>
> class Show b => MyClass a b where
> fn :: a -> b
>
> instance MyClass MyInt MyString where
> fn (MyInt i) = MyString (show i)
>
> myprint :: (MyClass a b) => a -> IO ()
> myprint a = putStrLn $ show (fn a)
>
> main = myprint 3
>
> ======= Main.hs ==========
>
> with ghc Main.hs -XMultiParamTypeClasses. However, the compiler cannot
> deduce the type of the b type variable (which in this case is MyString).
> How can I explicitly tell this information to the compiler?
>
> Many thanks,
> Alex.
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100715/a85c902b/attachment-0001.html
------------------------------
Message: 7
Date: Thu, 15 Jul 2010 00:51:16 -0600
From: George Roberts <[email protected]>
Subject: [Haskell-beginners] Creating databases with sqlite3 using
HDBC
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
I'm trying to have a program attempt opening an sqlite3 database, and if it
isn't created then I need some way of creating it. However, after looking
through the HDBC api and the sqlite3 specific portion, I cannot figure out
how to create a new sqlite3 database.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100715/e3b25c4c/attachment-0001.html
------------------------------
Message: 8
Date: Thu, 15 Jul 2010 10:03:26 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] Creating databases with sqlite3 using
HDBC
To: George Roberts <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
It's created automatically for you, you don't have to worry about it at all.
This is a feature inherited directly from the C library.
Michael
On Thu, Jul 15, 2010 at 9:51 AM, George Roberts <[email protected]>wrote:
> I'm trying to have a program attempt opening an sqlite3 database, and if it
> isn't created then I need some way of creating it. However, after looking
> through the HDBC api and the sqlite3 specific portion, I cannot figure out
> how to create a new sqlite3 database.
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100715/29288c59/attachment.html
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 25, Issue 34
*****************************************