I'd like start with Haskell, but...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

I'd like start with Haskell, but...

Waldemar Biernacki
Hello!

I'd like to start programming in Haskell.
But as an "industry programmer" I have a hope to use Haskell in my every-day
work. Big part of my every-day work are GUI applications (in MS-Windows)
working with SQL databases (PostgreSQL on Linux servers).

My question: Is there a TRUE possibility to use Haskell for such applications?
Is anybody there who have ANY experience in the field?
If answer would be positive what GUI+database libraries could be used in such
a case?

I've seen some GUI libraries web pages, but they seem to be NOT maintenanced
any more.

cheers
Waldemar
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

Duncan Coutts
On Sat, 2006-12-16 at 19:50 +0100, Waldemar Biernacki wrote:

> Hello!
>
> I'd like to start programming in Haskell.
> But as an "industry programmer" I have a hope to use Haskell in my every-day
> work. Big part of my every-day work are GUI applications (in MS-Windows)
> working with SQL databases (PostgreSQL on Linux servers).
>
> My question: Is there a TRUE possibility to use Haskell for such applications?
> Is anybody there who have ANY experience in the field?
> If answer would be positive what GUI+database libraries could be used in such
> a case?

I don't actually know of anyone using one of the GUI libs in combination
with one of the DB libs. It's an obvious thing to do but you'll not find
a lot of pre-existing examples or infrastructure to help you.

That's certainly one of the use cases that we're aiming for in the
Gtk2Hs project with our new api for the list/tree widget system. We can
now more easily implement the data model in Haskell so the obvious thing
to try would be a model based on a DB query. We're aiming for a Gtk2Hs
release with this new api before xmas.

For databases there are three major libs you could use, HDBC, HSQL, and
HaskellDB. HSQL and HDBC are in essentially the same niche, they provide
a common medium level api to a bunch of different db backends. They work
at the level of taking SQL strings and returning result sets. HaskellDB
is a higher level library (that can use HDBC or HSQL). It provides a
type safe way of constructing queries (and internally generates SQL).

So personally what I'd try would be Gtk2Hs+HDBC or Gtk2Hs+HDBC+HaskellDB.

> I've seen some GUI libraries web pages, but they seem to be NOT maintenanced
> any more.

There are several GUI libs that were started but not maintained. The
main ones that are maintained are Gtk2Hs and wxHaskell.

For platform support you're fine, all those DB libs support PostgreSQL
and both GUI libs support Windows, Linux and others.

Duncan

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

Mark Wassell
Hi,

Take a look at http://www.haskell.org/haskellwiki/HGene which uses HSQL
and Gtk2hs. I don't have any code to release yet - only parts work and
the code is in an extreme state of flux; I am currently refactoring (see
my post on monads).

More generally you might be interested in the other page that I have started

http://www.haskell.org/haskellwiki/Enterprise_Haskell

Mark


Duncan Coutts wrote:

> On Sat, 2006-12-16 at 19:50 +0100, Waldemar Biernacki wrote:
>  
>> Hello!
>>
>> I'd like to start programming in Haskell.
>> But as an "industry programmer" I have a hope to use Haskell in my every-day
>> work. Big part of my every-day work are GUI applications (in MS-Windows)
>> working with SQL databases (PostgreSQL on Linux servers).
>>
>> My question: Is there a TRUE possibility to use Haskell for such applications?
>> Is anybody there who have ANY experience in the field?
>> If answer would be positive what GUI+database libraries could be used in such
>> a case?
>>    
>
> I don't actually know of anyone using one of the GUI libs in combination
> with one of the DB libs. It's an obvious thing to do but you'll not find
> a lot of pre-existing examples or infrastructure to help you.
>
> That's certainly one of the use cases that we're aiming for in the
> Gtk2Hs project with our new api for the list/tree widget system. We can
> now more easily implement the data model in Haskell so the obvious thing
> to try would be a model based on a DB query. We're aiming for a Gtk2Hs
> release with this new api before xmas.
>
> For databases there are three major libs you could use, HDBC, HSQL, and
> HaskellDB. HSQL and HDBC are in essentially the same niche, they provide
> a common medium level api to a bunch of different db backends. They work
> at the level of taking SQL strings and returning result sets. HaskellDB
> is a higher level library (that can use HDBC or HSQL). It provides a
> type safe way of constructing queries (and internally generates SQL).
>
> So personally what I'd try would be Gtk2Hs+HDBC or Gtk2Hs+HDBC+HaskellDB.
>
>  
>> I've seen some GUI libraries web pages, but they seem to be NOT maintenanced
>> any more.
>>    
>
> There are several GUI libs that were started but not maintained. The
> main ones that are maintained are Gtk2Hs and wxHaskell.
>
> For platform support you're fine, all those DB libs support PostgreSQL
> and both GUI libs support Windows, Linux and others.
>
> Duncan
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>  
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

Neil Mitchell
In reply to this post by Duncan Coutts
Hi

> > Is anybody there who have ANY experience in the field?
> > If answer would be positive what GUI+database libraries could be used in such
> > a case?

> There are several GUI libs that were started but not maintained. The
> main ones that are maintained are Gtk2Hs and wxHaskell.

There is no current release of Gtk2Hs or wxHaskell for GHC 6.6 on
Windows (that i know about), in my opinion that means they are not
supported enough to actually use. That said, I'd use GHC 6.4.2 and
Gtk2Hs, because it is supported. Also the first person to reply to
your post was Duncan, who is one of the Gtk2Hs developers - I usually
find that he provides excellent support and help where required.

That said, if I was writing a GUI+database thing, which doesn't do a
lot of substantial processing (more just Add/Edit/Delete buttons), I'd
definately use C# over Haskell. Haskell can do this, but you are
walking a relatively new path. On the other hand C# developers do this
day in, day out, and the language is optimised towards it.

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

Bryan Burgers
> That said, if I was writing a GUI+database thing, which doesn't do a
> lot of substantial processing (more just Add/Edit/Delete buttons), I'd
> definately use C# over Haskell. Haskell can do this, but you are
> walking a relatively new path. On the other hand C# developers do this
> day in, day out, and the language is optimised towards it.

I agree with Neil here. I've been working with Haskell for a while and
I wouldn't have the foggiest idea of how to start a GUI / Database
project. After working with C# for about a week, I had a substantial
GUI / Database program going for a company I interned with last
summer. Haskell is good for a lot of things, and I'm sure somebody
someday will show me that Haskell is even great for GUI/Database, but
you should always use the right tool for the job, and for your job,
I'd say C# is the right tool.

Bryan Burgers
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

ArtemGr-2
In reply to this post by Neil Mitchell
>> There are several GUI libs that were started but not maintained. The
>> main ones that are maintained are Gtk2Hs and wxHaskell.
>
> There is no current release of Gtk2Hs or wxHaskell for GHC 6.6 on
> Windows (that i know about), in my opinion that means they are not
> supported enough to actually use. That said, I'd use GHC 6.4.2 and
> Gtk2Hs, because it is supported. Also the first person to reply to
> your post was Duncan, who is one of the Gtk2Hs developers - I usually
> find that he provides excellent support and help where required.

I use wxHaskell with GHC-6.6. It was released pretty soon after GHC-6.6
was out. The trick is that it was released by Shelarcy here:
https://sourceforge.net/project/showfiles.php?group_id=168626
I found it by Googling for this message:
http://www.mail-archive.com/haskell-cafe@.../msg14839.html
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

Joachim Breitner-2
In reply to this post by Duncan Coutts
Hi,

Am Samstag, den 16.12.2006, 20:23 +0100 schrieb Duncan Coutts:
> I don't actually know of anyone using one of the GUI libs in combination
> with one of the DB libs. It's an obvious thing to do but you'll not find
> a lot of pre-existing examples or infrastructure to help you.

Just for the record, half a year ago I wrote a Gtk-MySQL-Frontend in
Haskell, to manage the student’s exercise points, get statistics and
send out rankings by e-mail. It wasn’t really stable for me back then,
but I was a beginner in Haskell. So now you know one :-)

Greetings,
Joachim
--
Joachim "nomeata" Breitner
  mail: [hidden email] | ICQ# 74513189 | GPG-Key: 4743206C
  JID: [hidden email] | http://www.joachim-breitner.de/
  Debian Developer: [hidden email]
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

Waldemar Biernacki
In reply to this post by Bryan Burgers
Thank you Bryan!

> > That said, if I was writing a GUI+database thing, which doesn't do a
> > lot of substantial processing (more just Add/Edit/Delete buttons), I'd
> > definately use C# over Haskell.

Hmm. is that mean that the languages can be comparable?
I did some Perl applications - just GUI+database. However, my way
of solving these problems is in fact to build additional high level interface
between user and system (some kind of over 4th GL tool).
In fact, having such a tool, all what remain for peaple making end-user
application is to focus on logic not to syntactic.
The final aim of the aproach is to get a tool in which there will be no
syntactic errors during modelling bussiness logic. Recently I've finished very
primary version of the tool (0.001:-).
It works fine, but it is quite dirty inside and difficult to maintanance.
Additionally it's written in Perl and is quite slow, but usefull already.
I've hoped that Haskell is much cleaner in coding, much faster in performing
final application, can get compiled program and force me not to go too short
roads and think more about.

I do not know C#, but what was attracting me to Haskell is - as they say -
compact, clean and very functional way of programming.

> > Haskell can do this, but you are
> > walking a relatively new path.
Then the question is: Is Haskell 'freaky' enough to be a good choice :-)
I'm not afraid to go new path, I am afraid to go wrong path and to lost time
and efforts.

> I agree with Neil here. I've been working with Haskell for a while and
> I wouldn't have the foggiest idea of how to start a GUI / Database
> project. After working with C# for about a week, I had a substantial
> GUI / Database program going for a company I interned with last
> summer. Haskell is good for a lot of things, and I'm sure somebody
> someday will show me that Haskell is even great for GUI/Database, but
> you should always use the right tool for the job, and for your job,
> I'd say C# is the right tool.

Maybe, but what is still unclear for me: Haskell is wrong for GUI/Database
application because of lack of good libraries or because of it's way of
programming???

Waldemar
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

Neil Mitchell
Hi Waldemar,

> The final aim of the aproach is to get a tool in which there will be no
> syntactic errors during modelling bussiness logic. Recently I've finished very
> primary version of the tool (0.001:-).

Ah, now that sounds like Haskell might be good for :)

Haskell isn't great at writing a GUI and database combination, in my
experience. It certainly can, it just tends to be a bit of work.

Having said that, Haskell is _great_ for writing domain specific
libraries, for plugging together new applications and for modelling
business logic. It's likely that your business logic has some standard
set of operations, which you combine in some way - this is the thing
Haskell excels at - defining small things, and combining them in new
ways. The type system will help to ensure that the combinations are
good, which again helps reduce errors.

> I do not know C#, but what was attracting me to Haskell is - as they say -
> compact, clean and very functional way of programming.

Yes, a well designed Haskell program will give much better separation
of concerns. You can totally separate the logic from the user
interface gunk, and it will be more maintainable.


> Maybe, but what is still unclear for me: Haskell is wrong for GUI/Database
> application because of lack of good libraries or because of it's way of
> programming???

The libraries for GUI programming are not great - they are
progressing, and can certainly be used to develop tools, but I don't
feel they are "the good stuff" yet. Maybe I'm just setting the bar
higher because the rest of Haskell is so nice.

The current style of GUI programming in Haskell tends to be in the IO
monad, and feel very much like imperative programming. Haskell is
perfectly capable of being an imperative programming language where
required, but its not as natural as something like C# in this respect.

So in answer to your question, I'd say a little of both, but with the
optimistic view that one day someone will figure out what a GUI
program in Haskell should look like and everyone wlil be happy :)

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

Gour-2
In reply to this post by Neil Mitchell
On Sat, 2006-12-16 at 20:41 +0000, Neil Mitchell wrote:


> That said, if I was writing a GUI+database thing, which doesn't do a
> lot of substantial processing (more just Add/Edit/Delete buttons), I'd
> definately use C# over Haskell.

Oh great...

Duncan wrote: "That's certainly one of the use cases that we're aiming
for in the Gtk2Hs project with our new api for the list/tree widget
system. We can now more easily implement the data model in Haskell so
the obvious thing to try would be a model based on a DB query."

Although I'd be happy having available database-related widgets from
gnomedb available as part of gtk2hs bindings, still I'm confident that
above mentioned gtk2hs approach + eg. hdbc will be sufficient.

I'll also need database capabilities for my application and plan to use
sqlite as embedded engine, but having need for lot of calculations, I do
not want to lose Haskell purity & elegant style at any cost ;)
 

> Haskell can do this, but you are walking a relatively new path.

Someone has to pave the path, otherwise Haskell will eternally stay
niche language, or we should adjust the motto on haskell.org where it is
proudly stated: "Haskell is a general purpose, purely functional
programming language." into something more appropriate :-)

Sincerely,
Gour


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re[2]: I'd like start with Haskell, but...

Bulat Ziganshin-2
In reply to this post by Waldemar Biernacki
Hello Waldemar,

Sunday, December 17, 2006, 2:44:28 AM, you wrote:

> Maybe, but what is still unclear for me: Haskell is wrong for GUI/Database
> application because of lack of good libraries or because of it's way of
> programming???

primarily, first. to some degree, second too. Haskell doesn't provide such
elegant representation of imperative algorithms as imperative languages
does. just for example, counting sum [1..n]:

sum <- newIORef 0
i <- newIORef 1
let go = do i' <- readIORef i
            when (i'<n) $ do
                modifyIORef sum (+i')
                modifyIORef i   (+1)
                go
result <- readIORef sum

compare this to C code :)  of course, you can define a lot of
sugar/combinators that simplify such code but anyway C will be better in
this area

also:

it was several times mentioned that Haskell doesn't provide rich
environments for productive work, including lack of IDEs, bundled
"real-world" libs and so on. i want to mention alternative environments
that is better in these areas

1) F#, is Ocaml dialect integrated in .NET environment
2) Clean, very Haskell-like language with a commercial IDE, GUI libs and so on
3) Business Objects, integration of Haskell-like language into Java
environment, http://labs.businessobjects.com/cal



--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re[2]: I'd like start with Haskell, but...

Dan Mead


sum <- newIORef 0
i <- newIORef 1
let go = do i' <- readIORef i
            when (i'<n) $ do
                modifyIORef sum (+i')
                modifyIORef i   (+1)
                go
result <- readIORef sum



why in the world would you write a  summation function like that?



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re[4]: I'd like start with Haskell, but...

Bulat Ziganshin-2
Hello Dan,

Sunday, December 17, 2006, 5:46:57 PM, you wrote:

> sum <- newIORef 0

> why in the world would you write a  summation function like that?

gui/db libs are imperative ones and using them you need to deal with a lot
of mutable values. this example shows that programming with mutable data is
less better done in C than in Haskell - imperative language has a lot of
syntax sugar which allows automatic generation of all those
readIORef/writeIORef calls (or their equivalents)

--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: I'd like start with Haskell, but...

haskell-2
In reply to this post by Bulat Ziganshin-2
Bulat Ziganshin wrote:

> Hello Waldemar,
>
> Sunday, December 17, 2006, 2:44:28 AM, you wrote:
>
>> Maybe, but what is still unclear for me: Haskell is wrong for GUI/Database
>> application because of lack of good libraries or because of it's way of
>> programming???
>
> primarily, first. to some degree, second too. Haskell doesn't provide such
> elegant representation of imperative algorithms as imperative languages
> does. just for example, counting sum [1..n]:

I see that "n" is not in an IORef, and for n=1 your loop leaves sum holding 0,
which is just the kind of off-by-1 fencepost but that c excels in generating:

> sum <- newIORef 0
> i <- newIORef 1
> let go = do i' <- readIORef i
>             when (i'<n) $ do
>                 modifyIORef sum (+i')
>                 modifyIORef i   (+1)
>                 go
> result <- readIORef sum
>
> compare this to C code :)  of course, you can define a lot of
> sugar/combinators that simplify such code but anyway C will be better in
> this area
>

c code:

int sum(int n) {
  int i = 1;
  int result = 0
  for (; i<=n ; ++i) {
    result += i;
  }
  return result;
}

haskell:

You really want this to be strict, so replace modifyIORef with modifyIORef'

> modifyIORef' r f = do new <- liftM f (readIORef r)
>                       writeIORef r $! new
>                       return new

> s1 n = do
>   sum <- newIORef 0
>   forM_ [1..n] $ \i -> modifyIORef' sum (+i)
>   readIORef sum

As you mentioned, there is easy syntactic sugar definable in Haskell itself:

> a .+=. b = do new <- liftM2 (+) (readIORef a) (readIORef b)
>               writeIORef a $! new
>
> a .<=. b = liftM2 (<=) (readIORef a) (readIORef b)
>
> succ_ i = modifyIORef' i succ
>
> for init test inc block = do
>   init
>   let loop = do proceed <- test
>                 when proceed (block >> inc >> loop)
>   loop

With that sugar it becomes easy to look very much like the c-code:

> s2 n = do
>   sum <- newIORef 0
>   i <- newIORef 1
>   for (return ()) (i .<=. n) (succ_ i)
>       (sum .+=. i)
>   readIORef sum

And we do have "postfix" operators with the latest GHC:

> (.++) a = do old <- readIORef a
>              writeIORef a $! succ old
>              return old

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe