[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 61, Issue 49

Mark Snyder muddsnyder at yahoo.com
Thu Sep 25 14:34:08 EDT 2008


whoops!  wow, wrong message to reply to... please disregard the previous.

Apologies,
~Mark Snyder


----- Original Message ----
From: "haskell-cafe-request at haskell.org" <haskell-cafe-request at haskell.org>
To: haskell-cafe at haskell.org
Sent: Thursday, September 25, 2008 12:13:22 PM
Subject: Haskell-Cafe Digest, Vol 61, Issue 49

Send Haskell-Cafe mailing list submissions to
    haskell-cafe at haskell.org

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

You can reach the person managing the list at
    haskell-cafe-owner at haskell.org

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


Today's Topics:

   1. RE: Injecting Haskell into C (Simon Peyton-Jones)
   2. Re: Haskell board game (Ryan Ingram)
   3. Re: Am I doing it right? (Achim Schneider)
   4. Re: if - then - else layout (Jules Bean)
   5. Re: if - then - else layout (Achim Schneider)
   6. Re: Distributing Haskell binaries as OSX App Bundles
      (Christian Maeder)
   7. Re: if - then - else layout (Achim Schneider)
   8. Re: if - then - else layout (Achim Schneider)
   9. announcing darcs 2.1.0pre2 (Eric Kow)
  10. Re: pure Haskell database (jean-christophe mincke)
  11. Re: pure Haskell database (Achim Schneider)
  12. Re: pure Haskell database (Marc Weber)
  13. Re[2]: [Haskell-cafe] pure Haskell database (Bulat Ziganshin)
  14. Re: Google Android (Adam Langley)
  15. Re: Google Android (Maarten Hazewinkel)
  16. Where is OpenGL loadMatrix ? (minh thu)
  17. Re: Where is OpenGL loadMatrix ? ( Krzysztof Skrz?tnicki )
  18. Re: Where is OpenGL loadMatrix ? (Achim Schneider)
  19. Re: Re: Where is OpenGL loadMatrix ? (minh thu)
  20. StateWriter: a monad-writing exercise (Anthony LODI)
  21. Re: StateWriter: a monad-writing exercise (Henning Thielemann)
  22. Re: Re: Where is OpenGL loadMatrix ? (Bit Connor)
  23. Re: Re: Where is OpenGL loadMatrix ? (minh thu)
  24. Re: Where is OpenGL loadMatrix ? (Achim Schneider)
  25. Re: pure Haskell database (Manlio Perillo)
  26. Microsoft's Craig Mundie outlines the future of    computing
      (Lihn, Steve)
  27. GHC 6.10, OS X, Fink and CPPFLAGS (Svein Ove Aas)
  28. Re: Climbing up the shootout... (Ketil Malde)
  29. Problem with existential quantification (Eric)


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

Message: 1
Date: Thu, 25 Sep 2008 08:32:44 +0100
From: Simon Peyton-Jones <simonpj at microsoft.com>
Subject: RE: [Haskell-cafe] Injecting Haskell into C
To: Anatoly Yakovenko <aeyakovenko at gmail.com>,    "roma at ro-che.info"
    <roma at ro-che.info>
Cc: haskell <haskell-cafe at haskell.org>
Message-ID:
    <638ABD0A29C8884A91BC5FB5C349B1C32D766E2F96 at EA-EXMSG-C334.europe.corp.microsoft.com>
    
Content-Type: text/plain; charset="us-ascii"

Anatoly

I have not been following the details, but would you consider writing up your example on the GHC user guide Wiki?
        http://haskell.org/haskellwiki/GHC/Using_the_FFI

It's a very good way to share your experience with others.

Simon

| -----Original Message-----
| From: haskell-cafe-bounces at haskell.org [mailto:haskell-cafe-
| bounces at haskell.org] On Behalf Of Anatoly Yakovenko
| Sent: 24 September 2008 22:42
| To: roma at ro-che.info
| Cc: haskell
| Subject: Re: [Haskell-cafe] Injecting Haskell into C
|
| you'll find this example really helpfull
|
|
| ---------- Forwarded message ----------
| From: Claude Heiland-Allen <claudiusmaximus at goto10.org>
| Date: 2008/6/5
| Subject: Re: [Haskell-cafe] example of FFI FunPtr
| To: "Galchin, Vasili" <vigalchin at gmail.com>
| Cc: haskell <haskell-cafe at haskell.org>
|
|
| Galchin, Vasili wrote:
| >
| > Hello,
| >
| >       I want to model a Haskell function that is a callback from C. I have
| > only found one example in the unix package's Semaphore.hsc, which
| apparently
| > is not used. I want to be able to marshall a Haskell function that is a
| > first class citizen residing in a Haskell data type and pass to a C
| function
| > via FFI. Are there examples of this?
|
| Attached is a simple example.
|
| The main thing to note is 'foreign import ccall "wrapper"' which gives
| you a factory for turning Haskell functions into foreign function
| pointers.
|
| More information:
|
| http://www.cse.unsw.edu.au/~chak/haskell/ffi/
|
|
| Claude
| --
| http://claudiusmaximus.goto10.org
|
|
| CallBacker: CallBacker.hs callerback.c callerback.h
|        ghc -O2 -Wall -fffi -o CallBacker CallBacker.hs callerback.c
|
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe at haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe


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

Message: 2
Date: Thu, 25 Sep 2008 01:09:02 -0700
From: "Ryan Ingram" <ryani.spam at gmail.com>
Subject: Re: [Haskell-cafe] Haskell board game
To: "Rafael C. de Almeida" <almeidaraf at gmail.com>
Cc: haskell-cafe at haskell.org
Message-ID:
    <2f9b2d30809250109g3f0a2359s31a003c515549875 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Bertram has put together a peg solitaire game using gtk2hs with Prompt
for control:
    http://int-e.home.tlink.de/haskell/solitaire.tar.gz

It's a good read and probably a good starting point for other board games.

  -- ryan

On Wed, Sep 24, 2008 at 7:04 PM, Rafael C. de Almeida
<almeidaraf at gmail.com> wrote:
> Hello,
>
> I'm interested in doing a simple board game on haskell. For that I want
> to be able to draw stuff like the possible player movements and I want
> to be able to display very simple animations. I want to know what
> graphical interface library you suggest to me.
>
> I have almost no prior experience with graphical interfaces of any kind,
> so I rather start with something easy and straightforward. I have no
> need for great performance or anything like that. I'd like if it runs on
> windows with much trouble, that is, it'll be easy to package it for
> windows without requiring the user to install anything besides my game.
>
> My first thought was to use GTK's gtkTable, but I'm unsure how easy it
> is to make it work on windows. Beside that, I'm not sure it would be the
>  easiest API for me to use.
>
> []'s
> Rafael
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


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

Message: 3
Date: Thu, 25 Sep 2008 10:41:38 +0200
From: Achim Schneider <barsoap at web.de>
Subject: [Haskell-cafe] Re: Am I doing it right?
To: haskell-cafe at haskell.org
Message-ID: <20080925104138.02079514 at solaris>
Content-Type: text/plain; charset=US-ASCII

Daniel Fischer <daniel.is.fischer at web.de> wrote:
> The fast searching function on ByteStrings has already been written
> for you :)
>
That's in ghc 6.8.3, which is not in gentoo but only in the haskell
overlay, which means that all blame goes to the gentoo maintainers for
being utterly out of date. 

The KMP import works like a charm.

findSubstring is only defined for strict bytestrings... try
running those benchmarks again, this time on data bigger than your ram.
Not to mention that it's deprecated.

The really interesting topic is hacking Parsec to use KMP search on
"manyTill anyChar (try string match), or rather any recursive try
involving combinators that can calculate the position for the next
candidate match as a side effect.

PS: Thank you for not pointing out that my original code crashes on
B.tail B.empty in some cases, or even just that it can't replace
overlapping matches at all.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or broadcasting of this signature prohibited.



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

Message: 4
Date: Thu, 25 Sep 2008 09:45:12 +0100
From: Jules Bean <jules at jellybean.co.uk>
Subject: Re: [Haskell-cafe] if - then - else layout
To: leledumbo <leledumbo_cool at yahoo.co.id>
Cc: haskell-cafe at haskell.org
Message-ID: <48DB4F98.9000804 at jellybean.co.uk>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

leledumbo wrote:
> consider this partial program:
> if n>5 then
>   putStrLn "big"
> else
>   putStrLn "small"
> 
> this works fine in hugs, but in ghc I must change it to:
> if n>5
>   then
>     putStrLn "big"
>   else
>     putStrLn "small"

Actually both of those are valid expressions.

And they both work in hugs and ghc.

The question I imagine you're asking involves layout mode:

do
   if n>5 then
     putStrLn "big"
   else
     putStrLn "small"

this is shorthand for

do { if n > 5 then putStrLn "big" ; else putStrLn "small" }

which is a syntax error. A statement in a do block cannot begin with the 
keyword "else".

If you indent the else a bit further than it counts and a continuation 
of the enclosing expression (beginning with if) so it desugars to

do { if n > 5 then putStrLn "big" else putStrLn "small" }

which is fine.

Haskell' is apparently going to include a hack to permit this case. I 
think that's a poor decision, because including a hack to the layout 
rule makes it harder to understand and explain the layout rule.

Jules


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

Message: 5
Date: Thu, 25 Sep 2008 10:48:21 +0200
From: Achim Schneider <barsoap at web.de>
Subject: [Haskell-cafe] Re: if - then - else layout
To: haskell-cafe at haskell.org
Message-ID: <20080925104821.09da2a93 at solaris>
Content-Type: text/plain; charset=US-ASCII

"Brandon S. Allbery KF8NH" <allbery at ece.cmu.edu> wrote:

> I think Hugs is violating the Haskell98 layout rules.
>
One could argue that GHC should, too.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or broadcasting of this signature prohibited.



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

Message: 6
Date: Thu, 25 Sep 2008 11:04:00 +0200
From: Christian Maeder <Christian.Maeder at dfki.de>
Subject: [Haskell-cafe] Re: Distributing Haskell binaries as OSX App
    Bundles
To: Stephen <analytic at gmail.com>
Cc: Haskell-Cafe at haskell.org
Message-ID: <48DB5400.4060804 at dfki.de>
Content-Type: text/plain; charset=ISO-8859-1

Stephen wrote:
> I wrote a command-line program recently for a friend in haskell. 
> However, he's far away and not particularly computer literate.  I sent
> him the raw binaries, but they came up with errors about not being able
> to find libgmp stuff.  So then I thought I should probably be able to

I usually link in libgmp.a statically. This happens automatically if
libgmp.a resides in ghc's libdir (just copy it)

Cheers Christian


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

Message: 7
Date: Thu, 25 Sep 2008 11:12:26 +0200
From: Achim Schneider <barsoap at web.de>
Subject: [Haskell-cafe] Re: if - then - else layout
To: haskell-cafe at haskell.org
Message-ID: <20080925111226.67482196 at solaris>
Content-Type: text/plain; charset=US-ASCII

Jules Bean <jules at jellybean.co.uk> wrote:

> do
>    if n>5 then
>      putStrLn "big"
>    else
>      putStrLn "small"
> 
> this is shorthand for
> 
> do { if n > 5 then putStrLn "big" ; else putStrLn "small" }
> 
> which is a syntax error. A statement in a do block cannot begin with
> the keyword "else".
> 
> Haskell' is apparently going to include a hack to permit this case. I 
> think that's a poor decision, because including a hack to the layout 
> rule makes it harder to understand and explain the layout rule.
> 
There's no need to hack the layout rule, you're even giving pointers to
the solution. Something like this:

if p = do
    (_, c, a) <- get
    put (b, c, a)
    mzero

then c = do
    (b, _, a) <- get
    put (b, c, a)
    mzero

else a = do
    (b, c, _) <- get
    put (b, c, a)
    mzero

end = do
    (b, c, a) <- get
    return if p then a else c

Advantages are obvious: Order doesn't really matter anymore, as in

then "get away"
else "or else"
if i tell you to
end

Furthermore, this scheme supports logical comments, a rare kind of
control structure enabling mindboggingly diverse rapid prototyping
options:

if i knew what i want to do
if i knew how to do it
then i'd have written the next line much earlier
if i wrote this line
then i don't need to remove the other lines
else where in other languages i'd have to do that
end

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or broadcasting of this signature prohibited.



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

Message: 8
Date: Thu, 25 Sep 2008 11:20:58 +0200
From: Achim Schneider <barsoap at web.de>
Subject: [Haskell-cafe] Re: if - then - else layout
To: haskell-cafe at haskell.org
Message-ID: <20080925112058.46e0c095 at solaris>
Content-Type: text/plain; charset=US-ASCII

Achim Schneider <barsoap at web.de> wrote:

> if i knew how to do it

Sorry, apparent mistake, besides confusing b (bool) with p (predicate):

if p _ c = do
    (_, _, a) <- get
    put (p, c, a)
    mzero

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or broadcasting of this signature prohibited.



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

Message: 9
Date: Thu, 25 Sep 2008 10:32:27 +0100
From: Eric Kow <kowey at darcs.net>
Subject: [Haskell-cafe] announcing darcs 2.1.0pre2
To: darcs-users at darcs.net
Cc: haskell-cafe at haskell.org
Message-ID: <20080925093227.GG301 at Macintosh.local>
Content-Type: text/plain; charset="utf-8"

Hi everybody,

The second pre-release of darcs 2.1 (formerly known as 2.0.3) is now
available at http://darcs.net/darcs-2.1.0pre2.tar.gz

We have increased the version number since the last pre-release because
we are adopting an important new behaviour:

  The darcs initialize command now creates darcs-2 format
  repositories by default

This will help new repositories to benefit from the improved handling of
duplicate patches and to avoid the exponential time conflicts problem.

Upcoming release schedule
-------------------------
2008-10-03: darcs 2.1.0pre3
2008-10-10: darcs 2.1.0

Work remaining
--------------
* http://bugs.darcs.net/issue971 (Petr Ročkai)
  When using hashed or repositories, allow darcs check to deal with filenames
  that differ only in case when run on a case-insensitive filesystem.  Petr
  has done 90% of the work for this -- he has implemented this for darcs
  repair -- so this shall largely be a question of refactoring.

* http://bugs.darcs.net/issue1003
  Allow darcs-transfer mode to deal with a specific set of missing files
  (namely _darcs/format) so that users can benefit from ssh connection
  sharing even if the remote end uses an old-fashioned repository.  In
  the meantime, a simple workaround is to touch the _darcs/format file in
  the remote repoistory
  
* http://bugs.darcs.net/issue1078
  Fix a corner case in paths handling that makes darcs overly
  cautious if the repository is a symbolic link

* http://bugs.darcs.net/issue1026
  Improve the error messages for 'bug in get_extra' errors, which can
  happen if darcs is fooled into thinking that two patches are the same.

Changes since the last pre-release
----------------------------------
* User Experience: Do not allow users to add files to a darcs repository if
  their filenames would be considered invalid under Windows. This can be
  overridden with the --reserved-ok flag (issue53, Eric Kow)

* Bug Fix: Do not leave behind a half-gotten directory if darcs get fails
  (issue1041, Vlad Dogaru, David Roundy)

* User Experience: notice when you are trying to pull from a seemingly
  unrelated repository, that is one with a sufficiently different history.
  This can be overridden with the --allow-unrelated-repos flag (Dmitry
  Kurochkin, David Roundy)

* Bug Fix: Fix hang after a user input error (for example, EOF) (Judah
  Jacobson)

* Quality Assurance: Improvements to documentation and online help (Simon
  Michael)

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080925/ec45f502/attachment-0001.bin

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

Message: 10
Date: Thu, 25 Sep 2008 11:52:26 +0200
From: "jean-christophe mincke" <jeanchristophe.mincke at gmail.com>
Subject: Re: [Haskell-cafe] pure Haskell database
To: "Marc Weber" <marco-oweber at gmx.de>, haskell-cafe at haskell.org
Message-ID:
    <c0727ea70809250252gb1ea978j661df85f79a529b1 at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Marc

What is this strange syntax

columns = [ ("trackId", conT *''Int* )

It looks like a not ended string literal unless I still have sth to learn
about Haskell.

Thank you

J-C



On Thu, Sep 25, 2008 at 12:03 AM, Marc Weber <marco-oweber at gmx.de> wrote:

> On Wed, Sep 24, 2008 at 11:17:01PM +0200, Manlio Perillo wrote:
> >  Hi.
> >
> >  I need a simple, concurrent safe, database, written in Haskell.
> >  A database with the interface of Data.Map would be great, since what I
> need
> >  to to is atomically increment some integer values, and I would like to
> avoid
> >  to use SQLite.
>
> I've tried writing at least part of that. But it's still higly
> experimental and uses template haskell.
> It looks like this:
> from that some datastructures are defined which look like
> tables used in traditional RDBMS such as SQLite..
> However if you don't want to use many "tables" you may be a lot faster
> writing down what you need yourself. My lib automacially generates code
> for inserting / deleting tuples into multi indexes such as (Map Int (Map
> Int PrimIdx)).
>
> $(let cds = defaultTable {
>                tblName = "cds"
>                , columns = [ ("cdId", conT ''Int) , ("title", conT ''Int) ]
>                , primary = PrimaryUniq [ "cdId" ] [| 0 |]
>                , indexes = [ Index "title" [] ]
>                , tblStates = [ ( "nextCdId", [t| Int |], [| 0 |] ) ]
>            }
>
>      tracks = let
>             a="a"
>             -- updateNumRows n = [| \n -> cdUpdateByPK (\r -> r {
> num_tracks = (num_tracks r) + $(n) } ) |]
>             in defaultTable {
>             tblName = "tracks"
>             , columns = [ ("trackId", conT ''Int )
>                       , ("name", conT ''String)
>                       , ("cd", conT ''Int) -- foreign key
>                       ]
>             , primary = PrimaryUniq [ "cd", "trackId" ] [| 0 |]
>             , indexes = [ Index "cd" [ IndexUnique "trackId" ] ] --the id
> is uniq foreach cd
>             -- checks = [ foreignConstraint "cd" "cds" "id" ]
>             -- triggers =  [ InsertUpdate  (Just ["cd"]) [| cdUpdateByPK (
> updateNum_tracks (+1) ) . pk |]
>                           -- DeleteUpdate  (Just ["cd"]) [| cdUpdateByPK (
> updateNum_tracks (-1) ) . pk |]
>                           -- ]
>                 }
>      db = defaultDB {
>              dbName = "my"
>            , tables = [ cds, tracks]
>            , statistics = True
>            }
>  in createDB db)
>
>
> If you're interested drop me a mail.
>
> Marc
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080925/86f028ab/attachment-0001.htm

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

Message: 11
Date: Thu, 25 Sep 2008 12:08:28 +0200
From: Achim Schneider <barsoap at web.de>
Subject: [Haskell-cafe] Re: pure Haskell database
To: haskell-cafe at haskell.org
Message-ID: <20080925120828.09fec80f at solaris>
Content-Type: text/plain; charset=US-ASCII

"jean-christophe mincke" <jeanchristophe.mincke at gmail.com> wrote:

> What is this strange syntax
> 
> columns = [ ("trackId", conT *''Int* )
> 
> It looks like a not ended string literal unless I still have sth to
> learn about Haskell.
> 
' isn't special in Haskell, it's idiomatic: you often see things like

foo' = bar foo

, as mathematicians and haskellers are to lazy to think of a new name
for foo just because they got a derived foo.

I, too, have no idea what *''Int* means. It's part of the "just use the
*&%*$^!#!$%!^ operator" problem.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or broadcasting of this signature prohibited.



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

Message: 12
Date: Thu, 25 Sep 2008 12:31:44 +0200
From: Marc Weber <marco-oweber at gmx.de>
Subject: Re: [Haskell-cafe] pure Haskell database
To: haskell-cafe at haskell.org
Message-ID: <20080925103144.GA18833 at gmx.de>
Content-Type: text/plain; charset=utf-8

On Thu, Sep 25, 2008 at 11:52:26AM +0200, jean-christophe mincke wrote:
>    Marc
> 
>    What is this strange syntax
> 
>    columns = [ ("trackId", conT ''Int )

Hi J-C,

I'ts part of template haskell and tells ghc to use the type
referenced by Int. There are some getting started guides on haskell.org
By the way you can enhance readability of your messages if you only keep
that part of the message you're refering to.

Sincerly
Marc Weber


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

Message: 13
Date: Thu, 25 Sep 2008 14:48:12 +0400
From: Bulat Ziganshin <bulat.ziganshin at gmail.com>
Subject: Re[2]: [Haskell-cafe] pure Haskell database
To: "jean-christophe mincke" <jeanchristophe.mincke at gmail.com>
Cc: haskell-cafe at haskell.org
Message-ID: <988210512.20080925144812 at gmail.com>
Content-Type: text/plain; charset=us-ascii

Hello jean-christophe,

Thursday, September 25, 2008, 1:52:26 PM, you wrote:

>  columns = [ ("trackId", conT ''Int )

> It looks like a not ended string literal unless I still have sth to learn about Haskell.

it's TemplateHaskell, look for Reification in http://www.haskell.org/bz/thdoc.htm


-- 
Best regards,
Bulat                            mailto:Bulat.Ziganshin at gmail.com



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

Message: 14
Date: Thu, 25 Sep 2008 04:33:09 -0700
From: "Adam Langley" <agl at imperialviolet.org>
Subject: Re: [Haskell-cafe] Google Android
To: "Galchin, Vasili" <vigalchin at gmail.com>
Cc: "haskell-cafe at haskell.org" <haskell-cafe at haskell.org>
Message-ID:
    <396556a20809250433n75d817bfr30847a0fe6334ff at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

2008/9/24 Galchin, Vasili <vigalchin at gmail.com>:
>     Do there currently (or in the works) exist FFI bindings for Google's
> Android API?

The Android API is obviously a Java API, additionally Android will
only execute DEX bytecode programs, so you would first need a way to
compile Haskell to Java, Java bytecode or DEX directly. A Google
search for "haskell java" turns up at least one good candidate[1], but
if you manage to get that working well, binding the APIs is a rather
trivial task ;)


[1] http://www.cse.unsw.edu.au/~pls/thesis-topics/ghcjava.html

AGL

-- 
Adam Langley agl at imperialviolet.org http://www.imperialviolet.org


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

Message: 15
Date: Thu, 25 Sep 2008 13:46:36 +0200
From: Maarten Hazewinkel <maarten.hazewinkel at gmail.com>
Subject: Re: [Haskell-cafe] Google Android
To: Adam Langley <agl at imperialviolet.org>
Cc: "Galchin, Vasili" <vigalchin at gmail.com>,
    "haskell-cafe at haskell.org" <haskell-cafe at haskell.org>
Message-ID: <3E3F4C9A-18F7-4C39-8701-839107B490CD at mac.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed

On 25 Sep 2008, at 13:33, Adam Langley wrote:

> A Google
> search for "haskell java" turns up at least one good candidate[1], but
> if you manage to get that working well, binding the APIs is a rather
> trivial task ;)
>
> [1] http://www.cse.unsw.edu.au/~pls/thesis-topics/ghcjava.html

That's actually just a thesis proposal, not actual work done.
Try this for something closer to realization:

http://www.cs.rit.edu/~bja8464/lambdavm/


Regards,

Maarten


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

Message: 16
Date: Thu, 25 Sep 2008 15:39:22 +0200
From: "minh thu" <noteed at gmail.com>
Subject: [Haskell-cafe] Where is OpenGL loadMatrix ?
To: "Haskell-cafe Cafe" <haskell-cafe at haskell.org>
Message-ID:
    <40a414c20809250639s2da31e6fv24c797ca3e328381 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I can't find the loadMatrix function in
http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/Graphics-Rendering-OpenGL-GL-CoordTrans.html

Should I use loadIdentity then multMatrix instead ?

Thank you,
Thu


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

Message: 17
Date: Thu, 25 Sep 2008 15:45:21 +0200
From: " Krzysztof Skrz?tnicki " <gtener at gmail.com>
Subject: Re: [Haskell-cafe] Where is OpenGL loadMatrix ?
To: "minh thu" <noteed at gmail.com>
Cc: Haskell-cafe Cafe <haskell-cafe at haskell.org>
Message-ID:
    <220e47b40809250645o51a3ab47mbde6e0b7c90e28e0 at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Thu, Sep 25, 2008 at 15:39, minh thu <noteed at gmail.com> wrote:
>
> Hi,
>
> I can't find the loadMatrix function in
> http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/Graphics-Rendering-OpenGL-GL-CoordTrans.html
>
> Should I use loadIdentity then multMatrix instead ?
>
> Thank you,
> Thu
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

>From what I can see in the source, loadMatrix is method of class
MatrixComponent [1]:

instance MatrixComponent GLfloat_ where
   getMatrix = getFloatv
   loadMatrix = glLoadMatrixf
   loadTransposeMatrix = glLoadTransposeMatrixfARB
   multMatrix_ = glMultMatrixf
   multTransposeMatrix = glMultTransposeMatrixfARB
   rotate a (Vector3 x y z) = glRotatef a x y z
   translate (Vector3 x y z) = glTranslatef x y z
   scale = glScalef

However, for some reason it is not exported:

   MatrixOrder(..), MatrixComponent(rotate,translate,scale), Matrix(..),

Best regards

Christopher Skrzętnicki

[1]: http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/src/Graphics-Rendering-OpenGL-GL-CoordTrans.html#MatrixComponent

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

Message: 18
Date: Thu, 25 Sep 2008 15:59:35 +0200
From: Achim Schneider <barsoap at web.de>
Subject: [Haskell-cafe] Re: Where is OpenGL loadMatrix ?
To: haskell-cafe at haskell.org
Message-ID: <20080925155935.7ea6f1cc at solaris>
Content-Type: text/plain; charset=US-ASCII

"minh thu" <noteed at gmail.com> wrote:

> I can't find the loadMatrix function in
> http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/Graphics-Rendering-OpenGL-GL-CoordTrans.html
> 
> Should I use loadIdentity then multMatrix instead ?
> 
You're supposed to use withMatrix and regard OpenGL not as an
imperative language, but as a markup language coincidentally using
"do" to specify (flattened) lists. I even read about some library
managing display lists transparently for you, but I can't recall where.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or broadcasting of this signature prohibited.



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

Message: 19
Date: Thu, 25 Sep 2008 16:12:31 +0200
From: "minh thu" <noteed at gmail.com>
Subject: Re: [Haskell-cafe] Re: Where is OpenGL loadMatrix ?
To: "Achim Schneider" <barsoap at web.de>
Cc: haskell-cafe at haskell.org
Message-ID:
    <40a414c20809250712m2d4f9effy35506a0934dfeaf7 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

2008/9/25 Achim Schneider <barsoap at web.de>:
> "minh thu" <noteed at gmail.com> wrote:
>
>> I can't find the loadMatrix function in
>> http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/Graphics-Rendering-OpenGL-GL-CoordTrans.html
>>
>> Should I use loadIdentity then multMatrix instead ?
>>
> You're supposed to use withMatrix and regard OpenGL not as an
> imperative language, but as a markup language coincidentally using
> "do" to specify (flattened) lists. I even read about some library
> managing display lists transparently for you, but I can't recall where.

If you're right, it's weird there are things like  loadIdentity, $=,
... and it is
even weirder to not provide loadMatrix (which can be done with
loadIdenity and multMatrix).

Anyway, the bindings are not that much functionnal, even with things
like withMatrix.

Cheers
Thu


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

Message: 20
Date: Thu, 25 Sep 2008 10:18:13 -0400
From: "Anthony LODI" <anthony.lodi at gmail.com>
Subject: [Haskell-cafe] StateWriter: a monad-writing exercise
To: haskell-cafe at haskell.org
Message-ID:
    <d58ec4e0809250718xfb315aevc567750d7f5c99dc at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hello haskell-cafe,

In my application I have a complex state threaded through long
computation chains, and I need a way to log all state changes (so that
the evolving state can be animated/replayed somewhere else).
Initially I tried combining State and Writer monads but this allows
for the possibility to change the state, and forget to write a log
entry, etc.

So I decided to write a separate monad, StateWriter l s, that takes a
state-modifying function, l->s->s (l is an ADT for all the allowable
state transitions), an initial state s, and only allows s to change by
appending 'l' log entries inside the monad.  The net result is that I
should have read-only access to the current state inside the monad,
and all state transitions should be logged (by going through the one
function, the log entries serve as witnesses to all state
transitions).

Anyway, here's my (very rough!) first stab at the problem.  This is
the first time I've tried writing a monad so any comments/critiques
are much appreciated.

Also, about the 'StateWriter' idea in general: am I just (poorly?)
reimplementing something obvious?  Is it unlikely to scale well on
real-world problems?  Is there some way to combine the existing State
and Writer monads to avoid having to do this?

If there's nothing seriously wrong here, I was thinking my next step
would be to try changing the lists to monoids (like in the Writer
monad), and then to try writing a transformer version of the whole
thing.

Cheers,

- Anthony LODI


================================================================================

{-# LANGUAGE MultiParamTypeClasses,
            FunctionalDependencies,
            FlexibleInstances #-}

newtype StateWriter l s a = StateWriter { _runSWriter :: (l -> s -> s)
                                                     -> [l]
                                                     -> s
                                                     -> (a, [l], s)
                                       }


instance Monad (StateWriter l s) where
   return a = StateWriter $ \_ ls s -> (a, ls, s)

   (StateWriter x) >>= f = StateWriter $ \fn ls s ->
                                let (v, ls', s') = x fn ls s
                                in
                                  _runSWriter (f v) fn ls' s'

class MonadStateWriter m l s | m -> l s where
put :: l -> m ()
get :: m s

instance MonadStateWriter (StateWriter l s) l s where
put l = StateWriter $ \fn ls s -> ((), ls ++ [l], fn l s)
get = StateWriter $ \fn ls s -> (s, ls, s)


runSWriter :: StateWriter l s a -> (l -> s -> s) -> s -> (a, [l], s)
runSWriter sw fn = _runSWriter sw fn []


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


data Ops = Inc
        | Dec
          deriving (Show)

test :: StateWriter Ops Int String
test = do
put Inc
put Inc
put Inc
val <- get
let op = if val == 3 then Dec else Inc
put op
return "done"

stateFn :: Ops -> Int -> Int
stateFn Inc s = s + 1
stateFn Dec s = s - 1

runtest = runSWriter test stateFn 0 -- ("done",[Inc,Inc,Inc,Dec],2)


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

Message: 21
Date: Thu, 25 Sep 2008 16:34:18 +0200 (CEST)
From: Henning Thielemann <lemming at henning-thielemann.de>
Subject: Re: [Haskell-cafe] StateWriter: a monad-writing exercise
To: Anthony LODI <anthony.lodi at gmail.com>
Cc: haskell-cafe at haskell.org
Message-ID: <Pine.SOC.4.64.0809251631320.21141 at verdi>
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed


On Thu, 25 Sep 2008, Anthony LODI wrote:

> Hello haskell-cafe,
>
> In my application I have a complex state threaded through long
> computation chains, and I need a way to log all state changes (so that
> the evolving state can be animated/replayed somewhere else).
> Initially I tried combining State and Writer monads but this allows
> for the possibility to change the state, and forget to write a log
> entry, etc.

Instead of rewriting from scratch, you can also define

   newtype StateWriter l s a = StateWriter (StateT s (Writer l) a)

and then the monad instance is just about wrapping and unwrapping. Or you 
use {-# LANGUAGE GeneralizedNewtypeDeriving #-} and 'deriving Monad'.


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

Message: 22
Date: Thu, 25 Sep 2008 17:39:26 +0300
From: "Bit Connor" <bit at mutantlemon.com>
Subject: Re: [Haskell-cafe] Re: Where is OpenGL loadMatrix ?
To: "minh thu" <noteed at gmail.com>
Cc: Achim Schneider <barsoap at web.de>, haskell-cafe at haskell.org
Message-ID:
    <6205bd290809250739u4b987f7cm285624fb9d5b6601 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

withMatrix doesn't seem to have anything to do with glLoadMatrix.

You are right that you can do glLoadMatrix with loadIdentity and multMatrix.

To directly load a matrix, use the function "matrix" (with a Nothing
argument). This will internally call the loadMatrix function that
Krzysztof mentioned (which is correctly not exported).

Note that in addition to loading a matrix, the "matrix" function is
also used for retrieving the current matrix. (glGetFloatv with
argument GL_MODELVIEW_MATRIX and friends).

On Thu, Sep 25, 2008 at 5:12 PM, minh thu <noteed at gmail.com> wrote:
> 2008/9/25 Achim Schneider <barsoap at web.de>:
>> "minh thu" <noteed at gmail.com> wrote:
>>
>>> I can't find the loadMatrix function in
>>> http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/Graphics-Rendering-OpenGL-GL-CoordTrans.html
>>>
>>> Should I use loadIdentity then multMatrix instead ?
>>>
>> You're supposed to use withMatrix and regard OpenGL not as an
>> imperative language, but as a markup language coincidentally using
>> "do" to specify (flattened) lists. I even read about some library
>> managing display lists transparently for you, but I can't recall where.
>
> If you're right, it's weird there are things like  loadIdentity, $=,
> ... and it is
> even weirder to not provide loadMatrix (which can be done with
> loadIdenity and multMatrix).
>
> Anyway, the bindings are not that much functionnal, even with things
> like withMatrix.
>
> Cheers
> Thu
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


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

Message: 23
Date: Thu, 25 Sep 2008 16:48:25 +0200
From: "minh thu" <noteed at gmail.com>
Subject: Re: [Haskell-cafe] Re: Where is OpenGL loadMatrix ?
To: "Bit Connor" <bit at mutantlemon.com>
Cc: Achim Schneider <barsoap at web.de>, haskell-cafe at haskell.org
Message-ID:
    <40a414c20809250748i2ffebafal5d20edcf7dff2bfc at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

2008/9/25 Bit Connor <bit at mutantlemon.com>:
> withMatrix doesn't seem to have anything to do with glLoadMatrix.
>
> You are right that you can do glLoadMatrix with loadIdentity and multMatrix.
>
> To directly load a matrix, use the function "matrix" (with a Nothing
> argument). This will internally call the loadMatrix function that
> Krzysztof mentioned (which is correctly not exported).
>
> Note that in addition to loading a matrix, the "matrix" function is
> also used for retrieving the current matrix. (glGetFloatv with
> argument GL_MODELVIEW_MATRIX and friends).

Ok, thank you,
Thu


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

Message: 24
Date: Thu, 25 Sep 2008 16:52:52 +0200
From: Achim Schneider <barsoap at web.de>
Subject: [Haskell-cafe] Re: Where is OpenGL loadMatrix ?
To: haskell-cafe at haskell.org
Message-ID: <20080925165252.5d88839b at solaris>
Content-Type: text/plain; charset=US-ASCII

"minh thu" <noteed at gmail.com> wrote:

> Anyway, the bindings are not that much functionnal, even with things
> like withMatrix.
>
http://thread.gmane.org/gmane.comp.lang.haskell.cafe/35444/focus=35713

Mind you: regarding 3d, I barely manage to code up camera movements.
That is, I don't use it much at all.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or broadcasting of this signature prohibited.



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

Message: 25
Date: Thu, 25 Sep 2008 18:09:18 +0200
From: Manlio Perillo <manlio_perillo at libero.it>
Subject: Re: [Haskell-cafe] pure Haskell database
To: Rich Neswold <rich.neswold at gmail.com>
Cc: Haskell Cafe mailing list <haskell-cafe at haskell.org>
Message-ID: <48DBB7AE.9010002 at libero.it>
Content-Type: text/plain; charset=UTF-8; format=flowed

Rich Neswold ha scritto:
> On Wed, Sep 24, 2008 at 4:17 PM, Manlio Perillo 
> <manlio_perillo at libero.it <mailto:manlio_perillo at libero.it>> wrote:
> 
>     I need a simple, concurrent safe, database, written in Haskell.
>     A database with the interface of Data.Map would be great, since what
>     I need to to is atomically increment some integer values, and I
>     would like to avoid to use SQLite.
> 
> 
> How about  "MVar (Map k Int)"?  or even "Map k (MVar Int)"?
> 

Yes, it is a solution; and I can run a thread that every N seconds 
writes the database to a file.

But this works only if the database is used by only one process.


Manlio Perillo


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

Message: 26
Date: Thu, 25 Sep 2008 12:14:55 -0400
From: "Lihn, Steve" <horng_twu_lihn at merck.com>
Subject: [Haskell-cafe] Microsoft's Craig Mundie outlines the future
    of    computing
To: <haskell-cafe at haskell.org>
Message-ID:
    <6BD267D89E66B9499514F119920E583C029A2E90 at usctmx1110.merck.com>
Content-Type: text/plain; charset="us-ascii"


http://news.cnet.com/8301-13953_3-10050826-80.html?part=rss&subj=news&ta
g=2547-1_3-0-5

"We have to see a paradigm change in the way we write applications." He
also said that software development hasn't graduated to become a formal
engineering discipline. "The resilience of systems is not up to the
task," he said. "We have to master the transition to a parallel
programming environment, with highly distributed, concurrent systems.
It's nascent at this point but it's required to achieve these
capabilities." 

Sounds like Haskell will fit well in this future world.

Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or
MSD and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.



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

Message: 27
Date: Thu, 25 Sep 2008 18:27:19 +0200
From: "Svein Ove Aas" <svein.ove at aas.no>
Subject: [Haskell-cafe] GHC 6.10, OS X, Fink and CPPFLAGS
To: "Haskell Cafe" <haskell-cafe at haskell.org>
Message-ID:
    <221b53ab0809250927l2caa3359pe699c7ff6c52a8d1 at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

While trying to test 6.10, I ran into the issue that a number of the
libraries it wants are not installed by default, and are most
conveniently added via Fink. This includes gmp, binutils, readline,
etc.

/sw/ is not in the default gcc path, of course, so the usual solution
is to add -I/sw/include, -L/sw/lib, etc. to it via the CPPFLAGS and
LDFLAGS environment variables, which are supported by most[1]
autoconf-based packages. The help text for ghc's configure script does
in fact suggest that this is the case, and it has some code meant to
read it; broken code, as it happens.

As it is, the script fails to propagate those variables to whatever is
responsible for compiling the RTS, which fails with a missing gmp.h,
bfd.h, and so on. All those files exist live quite happily in
/sw/include, and would no doubt appreciate visiting makefiles.

So my question is two-fold:
Is the help file wrong? Is there some other way to do it?
Or is this in fact a bug, and if so, will any of you volunteer to fix
it for me? ^_^


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

Message: 28
Date: Thu, 25 Sep 2008 18:57:05 +0200
From: Ketil Malde <ketil at malde.org>
Subject: Re: [Haskell-cafe] Climbing up the shootout...
To: "John Van Enk" <vanenkj at gmail.com>
Cc: Bulat Ziganshin <Bulat.Ziganshin at gmail.com>,
    haskell-cafe at haskell.org
Message-ID: <87skro88pq.fsf at malde.org>
Content-Type: text/plain; charset=us-ascii

"John Van Enk" <vanenkj at gmail.com> writes:

> I'm going to have to agree with David... even if you ignore the multi-threaded
> projects, why couldn't the C programs just implement very specific version of
> the third party library inside their code?

Or they could just FFI to the Haskell libraries :-)

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


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

Message: 29
Date: Thu, 25 Sep 2008 18:15:56 +0100
From: Eric <eeoam at ukfsn.org>
Subject: [Haskell-cafe] Problem with existential quantification
To: Haskell-cafe <haskell-cafe at haskell.org>
Message-ID: <48DBC74C.3030303 at ukfsn.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Dear all,

I've written a function with the following type:

build :: Bifunctor s => (forall b. (s a b  ->  b) -> b)  ->  Fix s a

When I try to compile I get the following error:

Illegal polymorphic or qualified type: forall b. (s a b -> b) -> b
In the type signature for `build':
  build :: (Bifunctor s) => (forall b. (s a b -> b) -> b) -> Fix s a

What's happening?

E.M.



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

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


End of Haskell-Cafe Digest, Vol 61, Issue 49
********************************************



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080925/a63ae980/attachment-0001.htm


More information about the Haskell-Cafe mailing list