Re: [Haskell-cafe] FRP, integration and differential equations.

2009-04-23 Thread Steve Lihn
Just my two cents. The open source project Maxima is a very successful
math engine dedicated to solving ODE PDE and integration among many
other things. It is implemented in LISP.

Steve


On 4/21/09, jean-christophe mincke  wrote:
> Peter, Paul,
>
>>But my question is, is FRP really the right setting in which to
>>explore a highly accurate ODE solver?
>
>>Well, solving the ODE is usually the task of a dedicated physics engine.
> But IMHO with FRP we try to reuse >small building blocks so we get very
> modular systems; a big physics black box seems to be against this principle?
>
> I believe it is a good question. My answer is why not. In fact when I
> discovered FRP I liked the way systems could be constructed from building
> blocks as Peter says. I have a previous experience in designing simulators
> for complex  dynamic systems and I often had to find solutions to build
> simulators from a smal set of building blocks and still keep an adequate
> accuracy.
>
> Doing so often leads to ODEs of the form:
>
> de/dt = f (de/dt, e, t)
>
> It is often possible to solve such ODE providing that we make some
> reasonable physical assumptions on the de/dt term appearing in f(). This
> comes with an acceptable decrease in accuracy. But modelling physical
> systems is always a matter of trade-off...
>
> Thus, a big physic black box containing large monolithic set of equations is
> not always needed.
>
> Regards
>
> J-C
>
>
> On Tue, Apr 21, 2009 at 1:32 PM, Peter Verswyvelen wrote:
>
>> Hey thanks for the Adam-Bashford tip, didn't know that one yet (although I
>> used similar techniques in the past, didn't know it had a name :-)
>>
>> Well, solving the ODE is usually the task of a dedicated physics engine.
>> But IMHO with FRP we try to reuse small building blocks so we get very
>> modular systems; a big physics black box seems to be against this
>> principle?
>>
>> On Tue, Apr 21, 2009 at 1:24 PM, Paul L  wrote:
>>
>>> Adam-Bashford method can be easily implemented to replace Euler's. But
>>> to really get higher accuracy, one may need variable time steps and
>>> perhaps even back tracking, which is an interesting topic on its own.
>>> But my question is, is FRP really the right setting in which to
>>> explore a highly accurate ODE solver?
>>>
>>>
>>> On 4/21/09, Peter Verswyvelen  wrote:
>>> > Well, the current FRP systems don't accurately solve this, since they
>>> just
>>> > use an Euler integrator, as do many games. As long as the time steps
>>> > are
>>> > tiny enough this usually works good enough. But I wouldn't use these
>>> FRPs
>>> > to
>>> > guide an expensive robot or spaceship at high precision :-)
>>> >
>>> >
>>> > On Tue, Apr 21, 2009 at 11:48 AM, jean-christophe mincke <
>>> > jeanchristophe.min...@gmail.com> wrote:
>>> >
>>> >> Paul,
>>> >>
>>> >> Thank you for your reply.
>>> >>
>>> >> Integration is a tool to solve a some ODEs but ot all of them. Suppose
>>> >> all
>>> >> we have is a paper and a pencil and we need to symbolically solve:
>>> >>
>>> >>
>>> >>
>>> >> /
>>> >> t
>>> >> de(t)/dt = f(t)  -> the solution is given by e(t) = |  f(t) dt +
>>> >> e(t0)
>>> >>
>>> /
>>> >> t0
>>> >>
>>> >> de(t)/dt = f(e(t), t) -> A simple integral cannot solve it, we need to
>>> >> use
>>> >> the dedicated technique appropriate to this type of ODE.
>>> >>
>>> >>
>>> >> Thus, if the intention of the expression
>>> >>
>>> >>e = integrate *something *
>>> >>
>>> >> is "I absolutely want to integrate *something* using some integration
>>> >> scheme", I am not convinced that this solution properly covers the
>>> second
>>> >> case above.
>>> >>
>>> >> However if its the meaning is "I want to solve the ODE : de(t)/dt =*
>>> >> something* " I would be pleased if the system should be clever enough
>>> to
>>> >> analyse the *something expression* and to apply or propose the most
>>> >> appropriate numerical method.
>>> >>
>>> >> Since the two kinds of ODEs require 2 specific methematical solutions,
>>> I
>>> >> do
>>> >> not find suprising that this fact is also reflected in a program.
>>> >>
>>> >> I have not the same experience as some poster/authors but I am curious
>>> >> about the way the current FRPs are able to accurately solve the most
>>> >> simple
>>> >> ODE:
>>> >>
>>> >> de(t)/dt = e
>>> >>
>>> >> All I have seen/read seems to use the Euler method. I am really
>>> >> interested
>>> >> in knowing whether anybody has implemented a higher order method?
>>> >>
>>> >> Regards
>>> >>
>>> >> J-C
>>> >>
>>> >>
>>> >> On Tue, Apr 21, 2009 at 5:03 AM, Paul L  wrote:
>>> >>
>>> >>> Trying to give different semantics to the same declarative definition
>>> >>> based
>>> >>> on whether it's recursively defined or not seems rather hack-ish,
>>> >>> although
>>> >>> I can understand what you are coming from from an implementation
>>> angle.
>>> >>>
>>> >>> Mathematically an integral operator has only one semantics regardless
>>> >>> of what's put in front of it or inside. If our implementation can't
>>> >>> 

[Haskell-cafe] ghc on CentOS 5 ?

2008-12-12 Thread Steve Lihn
I recently got a CentOS server, but noticed that ghc rpm is not available
from CentOS yum. After investigation, I found ghc is in Fedora repository,
but does not make its way to EPEL, which yum on CentOS can use. (
http://download.fedora.redhat.com/pub/epel/5/x86_64/)

Is there any plan to get it to EPEL? Or is there any missing piece
preventing it?
Thanks, Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Microsoft's Craig Mundie outlines the future of computing

2008-09-26 Thread Steve Lihn
According to this discussion, none of the corporate email is okay for
open source mailing list.
Maybe you guys should join the Vioxx lawsuit team instead of Haskell cafe.

Or maybe Haskell's strictness has trained haskell programmers to
attend such details. That is really a good training for the future of
computing :-)

On Thu, Sep 25, 2008 at 2:56 PM, Achim Schneider <[EMAIL PROTECTED]> wrote:
> "Brandon S. Allbery KF8NH" <[EMAIL PROTECTED]> wrote:
>
>>
>> On Sep 25, 2008, at 13:50 , Achim Schneider wrote:
>>
>> > "Lihn, Steve" <[EMAIL PROTECTED]> wrote:
>> >
>> >> Notice:  This e-mail message, together with any attachments,
>> >> contains information of Merck & Co., Inc. (One Merck Drive,
>> >> Whitehouse Station,
>> >>
>> > Just curious: What'd happen if I forward this message to alt.slack?
>>
>>
>> Technically if there's anyone on haskell-cafe who was not
>> specifically intended to be a recipient, they are in violation of the
>> boilerplate. (This is why lawyers who mandate such boilerplate are
>> stupid.)
>>
> Well, you could interpret the Haskell cafe as an entity, thou this:
>
> http://permalink.gmane.org/gmane.comp.lang.haskell.cafe/45155
>
> could prove problematic. Gmane doesn't delete.
>
> I'm just imagining what'd happen if Merck & Co decided to
> sack Steve for leaking information about their stance on Haskell to the
> public. Think of Steve countersueing on the grounds that the
> boilerplate is legally effective and thus no harm is done.
>
> --
> (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.
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-21 Thread Steve Lihn
Oracle OCI interface is quite different between 7/8 and 9/10. And 10
is different from 9 in some respect. I don't know much about 11.
Oracle 10.2.0.3 is a stable release, but there are some major server
bugs in it, that Oracle had to release 10.2.0.4. I'd recommend Haskell
community to focus on 10.2.0.x release. It should be good for another
2-3 years. It is too risky to venture into 11.

That said, there is a large enterprise user base that will find
Haskell useful if it works with Oracle DB (particularly on linux).

On 6/21/08, Paul Moore <[EMAIL PROTECTED]> wrote:
> 2008/6/20 Alistair Bayley <[EMAIL PROTECTED]>:
> > Having just taken a closer took at what Oracle Instant Client is, I
> > suspect that you might have some trouble getting Takusen to compile
> > against it. The Instant Client lacks header files, while Takusen's FFI
> > imports specify oci.h. I don't know what happens if ghc can't find the
> > header files. Oracle do state that the Instant Client is for
> > deployment only; developers (that means you) will need the full client
> > installation.
>
> There's an additional download for the Instant Client which includes
> the OCI headers.
>
> Paul.
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-20 Thread Steve Lihn
You may want to check this out.

http://www.orafaq.com/wiki/ODBC_FAQ#Where_can_one_get_ODBC_drivers_for_Oracle_and_Rdb.3F

As Oracle is a commercial company who is not interested in open source
historically, it is little chance that you will get robust software
for free -- from someone with many years of Oracle DBA experience :-)


On 6/19/08, Henning Thielemann <[EMAIL PROTECTED]> wrote:
>
> Is there a way of accessing a remote Oracle database by one of the common
> Haskell database interfaces (HaskellDB, Takusen, etc.) ? I tried to get
> unixODBC and Oracle's Instant Client running on a Linux machine, but I'm
> trapped in the notorious error:
>
> $ isql USER -v
> [IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV
> failed
> [ISQL]ERROR: Could not SQLConnect
>
> This error message is discussed in various web forums, but there seems to be
> no systematic way to track down the problem. So I wonder whether there is
> another way to access the Oracle data base from Haskell.
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Higher order randomness and the fat tails

2008-04-25 Thread Steve Lihn
Hi, Haskellers,
This email is only remotely connected to this list. Recently I am doing some
research on the fat tails (in fact, I simply bumped into it) on the stock
market. I came up with an equation which I think solves the fat tails --
which is really the Levy stable distribution. During the complex arguments
that led to the solution, I coined a term called "Higher order randomness".
This is inspired by the concept of higher order function in Haskell.

* Higher order function operates on another function, instead on an ordinary
value. So higher order randomness operates on another randomness, instead of
directly producing the time series.

The request is the following. I know there are many scientists on this list.
If you or your colleagues happen to be involved or know any scenario that
has fat tail distribution, can you let me know? I only "solved" one scenario
-- numerically, not even analytically. Probability-wise, it is a dangerous
thing to claim I solve "the problem". So I'd like to collect as many
scenarios as I can. It can be financial related, or in other fields of
science.

PS. I'd like to have some operational details and numbers. Not just a
general statement like "fat tail is observed in astronomy".

Thanks and sorry for the spam,
Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: Hayoo! beta 0.1

2008-04-08 Thread Steve Lihn
Bug report:
I am using IE6. The "Powered by" bar at the bottom does not reposition as I
scroll down. So there is a small portion on the page always masked by the
"Powered by" bar.

Nice work. Great google-like speed...

Steve


On 4/8/08, Timo B. Hübel <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> thanks for all the feedback so far! We have just deployed some minor
> updates
> for Hayoo!, mainly improving the ranking mechanism. It should now prefer
> modules from the Prelude as well as functions exactly matching the query
> terms.
>
> Additionally, we have started a blog about Hayoo! and Holumbus development
> which can be found here: http://holumbus.fh-wedel.de/blog
>
> Have fun using Hayoo!
>
> Timo
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Satnam Singh of Microsoft Research

2008-03-19 Thread Steve Lihn
Related news --

Intel, Microsoft choose UC-Berkeley to host $10M parallel computing center

March 19, 2008 8:36 AM ET

http://news.moneycentral.msn.com/provider/providerarticle.aspx?feed=ACBJ&date=20080319&id=8361298
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: Hoogle 3.1

2008-02-29 Thread Steve Lihn
Interesting to know people are looking for \"where\". As a fairly new
Haskeller, I bumped into frequent indentation issues (if-then-else,
case, where, let, do, etc) and sometimes not sure where to place
\"where\" properly. Maybe beginners are having problem with syntax
more than other things and they are asking Hoogle to get some
suggestions...

Or they are using Hoogle as Ask.com. Where is this? Where can I find that?

On 2/29/08, Neil Mitchell <[EMAIL PROTECTED]> wrote:
>
> The Hoogle logs suggest this wouldn\'t be that useful. The most
> commonly invoked searches are the three listed on the front page.
> After that, the most common search is actually for \"where\", at under
> 1%. However, there are other ways I think I can get the necessary
> speed, and autocomplete would be very useful.
>
> Thanks
>
> Neil
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANN: Hoogle 3.1

2008-02-28 Thread Steve Lihn
You can try aggressive caching and indexing (which google uses often)
based on 20-80 rule.

http://en.wikipedia.org/wiki/Pareto_principle

On Thu, Feb 28, 2008 at 7:49 PM, Neil Mitchell <[EMAIL PROTECTED]> wrote:
> Hi Steve,
>
> >  Would you consider adding auto-complete feature on Hoogle in the forth
> >  coming release?
> >
> >  http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter
>
> I am slightly hoping that I'll be able to remove the Search button
> entirely, and just have results as you type. Whether that becomes
> feasible depends on how quickly the Hoogle search works, at the moment
> its way too slow, but the next version has clever data structures etc.
> which should make it fast enough, at least for text searches.
>
> Thanks
>
> Neil
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANN: Hoogle 3.1

2008-02-28 Thread Steve Lihn
Neil,
Would you consider adding auto-complete feature on Hoogle in the forth
coming release?

http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ArrowChoice for simulation arrow (Sim)

2008-02-28 Thread Steve Lihn
Hi,
In John Hughes\' paper \"Programming with arrows\" [1] Section 5, the
simulation arrow is defined (Sim). All the examples went well.
However, when I want to use it beyond circuit simulation and I added a
\"if-then-else\" line, GHC is asking to define ArrowChoice for Sim.

Does anybody have the ArrowChoice definition for Sim ?

Thanks,
Steve

[1] http://www.cs.chalmers.se/~rjmh/afp-arrows.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A little toy of Haskell Trivia

2008-02-24 Thread Steve Lihn
Ross,
I changed the query to "count(distinct package)" and indeed the
"noises" of same package imports are filtered out. The two top-10
lists now look somewhat similar.

GHC only: http://haskell.ecoin.net/cgi-bin/modules.pl?src=ghc
1 Control.Monad 22
2 Data.Char 20
3 System.IO 17
4 Data.List 16
5 Data.Maybe 16
6 System.IO.Unsafe 14
7 Control.Exception 13
8 Foreign.Ptr 11
9 Data.Word 11
10 Foreign.C 11

GHC+HackageDB: http://haskell.ecoin.net/cgi-bin/modules.pl?src=both
1 Control.Monad 178
2 Data.List 132
3 Data.Maybe 113
4 Data.Char 104
5 System.IO 99
6 Control.Exception 98
7 Data.Word 83
8 System.IO.Unsafe 81
9 Foreign 74
10 Data.Map 68

Steve

On Sat, Feb 23, 2008 at 5:25 PM, Ross Paterson <[EMAIL PROTECTED]> wrote:
> On Sat, Feb 23, 2008 at 10:59:40AM -0500, Steve Lihn wrote:
> > I parsed through all the hackagedb
> > modules. I also added the display of repository source (ghc, hdb) and
> > package source. HackageDB is 3-4 times bigger than GHC core. The
> > result is interesting, looking at the most used modules move up and
> > down the rank...
> >
> > http://haskell.ecoin.net/cgi-bin/modules.pl
>
> You'd get a different picture again if you excluded same-package imports.
> Some of the high-ranking modules are used internally in large packages.
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A beginners question

2008-02-23 Thread Steve Lihn
>
> fmap (^4) [1,2,3] >>= \i -> shows i " "
>
> gives
>
> "1 16 81 "
>
You are in the list comprehension in a monadic expression. shows is
called three times (i is int).

> then why does
>
> let i = fmap (^4) [1,2,3] in shows i " "
>
> give
>
> "[1,16,81] "
>

"shows" is called once (i is a list).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A little toy of Haskell Trivia

2008-02-23 Thread Steve Lihn
>
> There's a link on the HackageDB Introduction page that gets you the
> latest versions of all packages (30MB).

Ross,
Thanks for the archive URL. I parsed through all the hackagedb
modules. I also added the display of repository source (ghc, hdb) and
package source. HackageDB is 3-4 times bigger than GHC core. The
result is interesting, looking at the most used modules move up and
down the rank...

http://haskell.ecoin.net/cgi-bin/modules.pl

As I reflect on what I did, this result is kind of useful in learning
Haskell. Haskell is about re-using modules and building on top of
them. If a module is often used by Haskell community (especially,
library writers), a beginner better understand that module first (such
as Monad, List, Map, Exception, Array, etc).

On the other hand, I am thinking to display a "eco-system" kind of
graph/chart to show how the modules are connected with each other, and
which module is on the top of the "eco-system" (either the most
advanced module, or a module no one cares about!). But my data seem to
have a recursive nature. I don't quite understand why nor how to get
by it.

> Rewriting that script in Haskell could be an
> interesting exercise.  Do you have the source code?

Ben,
I think the best way to write this parser in Haskell is to use haddock
since haddock understands Haskell syntax much better than my
hacker-style script.

Here is the source code of both the parser(s) and cgi script. The code
is very experimental and low-quality... Let me know if you have any
question.

http://haskell.ecoin.net/haskell-trivia.tgz

Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Where does ~> come from?

2008-02-20 Thread Steve Lihn
If ~> does not have any special meaning and it could be ### or xyz,
then how does GHC know to print
 a ~> b, but not ~> a b
 a ### b, but not ### a b
 xyz a b, but not a `xyz` b

Simply because xyz is alphanumeric?


On Wed, Feb 20, 2008 at 12:34 AM, David Menendez <[EMAIL PROTECTED]> wrote:
> On Feb 19, 2008 4:15 PM, Wolfgang Jeltsch <[EMAIL PROTECTED]> wrote:
> > Am Dienstag, 19. Februar 2008 18:26 schrieben Sie:
> > > […]
> >
> > > However, I was told this:  ~> a b is a ~> b, but if I write c a b and
> > > wish the effect of a `c` b. This would not work. ~> as an infix operator
> > > has a special place in GHC. It is not "just a type variable".
> >
> > Sorry, but I don't understand fully what you mean. :-(  But nevertheless,
> > a ~> b is not the same as ~> a b but as (~>) a b.  It's just like with
> > ordinary operators where a + b is the same as (+) a b.
>
> Note that some (all?) versions of GHC will incorrectly print "a ~> b"
> as "~> a b".
>
> 
>
> Prelude> :t undefined :: a + b
> undefined :: a + b :: forall (+ :: * -> * -> *) a b. + a b
>
> It mostly gets infix type constructors right, although there are
> apparently problems with precedence and associativity.
>
> --
> Dave Menendez <[EMAIL PROTECTED]>
> 
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] A little toy of Haskell Trivia

2008-02-20 Thread Steve Lihn
I proudly announce a little toy that lists the frequency of modules
being imported by other modules. Do you know Control.Monad is the most
frequently imported module? I did not!

Currently it only includes GHC 6.8 core library. If you have any idea
how to parse through HackageDB code, please let me know.

http://haskell.ecoin.net/cgi-bin/modules.pl

Disclaimer: This is entirely for fun. It is by no means accurate or
complete. I only spent a couple hours on a little perl script and a
mysql table...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Where does ~> come from?

2008-02-16 Thread Steve Lihn
While I am reading TypeCompose module, I am having trouble finding
where ~> comes from? (And its son ~~> and grandson ~~~>, etc.)  This
is my immediate question. Help is appreciated.

A bigger (higher-order?) issue I encountered and I think other people
could also have is to look up all these special "symbols" during the
learning curve. As things are getting higher and higher order in
Haskell, more inventive symbols are appearing. It becomes harder to
remember the exact definitions are. The difficulties are:

1) I used to see a page on haskell.org that lists many symbols, but I
could not find that page any more.
2) You would hope there is a quick way to search those symbols. But
most search engines do not treate symbols friendly, often just ignore
them. I typed ~> in Hoogle, it also returned nothing.
3) If the module defining the symbol is not in standard library, it is
not possible to look up the symbol in the core library index.

The only way to find the symbol seems to go to the source code, check
every module being imported and if I am lucky I will find it in the
same package. If  I am not lucky, I will have to search that module on
the Internet, and hunt it down recursively.

I wonder if anybody has the same problem. If enough crowd have the
same problem, maybe there could be a better way to handle this kind of
documentation/learning issue!

Thanks,
Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] a general question on Arrows

2008-02-14 Thread Steve Lihn
> >  1. Stream
> This is actually a comonad.

Something more to learn everyday.

> Here's another fun arrow:
>
> http://luqui.org/blog/archives/2007/09/06/quantum-entanglement-in-haskell/
>
> Luke
>
Luke,
I managed to get your quantum entanglement examples working. But
honestly, I can't quite figure out your Quantum module yet. My head is
exploding after reading the code :-) It is amazing to know it takes
several layers of arrows to simulate the quantum mechanics.

I have a small question on the simulation technique. In both John
Hughes and your code, you wrap the "print" inside the runXYZ (...) to
print out the state of simulation. It is like:

runArrow ( ... simulation ...then print ...) -< input

Why don't you structure it like

y <- runArrow ( ... simulation ... then return observation ... ) -< input
reuse y or print y

In the former, the result is printed on the screen. I can not collect
the result and do more analysis. For example, for a quantum state |0>
+ i |1>, the probability is half half. If I can repeat the simulation
1 times and collect the "observations" (y) , then I can "prove"
the correctness of experiment by observing ~5000 of |0> and ~5000 of
|1>. Or even plot the probability distribution of the experiment.

Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] a general question on Arrows

2008-02-13 Thread Steve Lihn
In John Hughes' paper [1], Programming with Arrows, p. 20,

"The truly interesting arrow types are those which do not
correspond to a monad, because it is here that arrows give us real
extra generality.
Since we know that stream functions cannot be represented as a monad,
then they are one of these "interesting" arrow types. So are the arrows used for
functional reactive programming, for building GUIs, and the arrows for discrete
event simulation we present in Section 5. And since these arrows
cannot be represented
by a monad, we know that they cannot support a sensible definition of
app either."

He described a few things that "cannot" be represented as a monad, they are:
1. Stream
2. FRP
3. GUI (request/response?)
4. Event Driven System (like circuits, robots?)

My first question is:
Are they "absolutely" outside of the realm of function + monad,
therefore, arrows are indispensable? Or it is simply because the
haskell program would be very cumbersome without arrows in these
areas? (I mean without utilizing FFI to rescue.)

The second question is:
Other than the 4 areas above, are there more? Just want to get a sense
of how useful arrows are. Not really a theoretical question.

Thanks,
Steve

[1] http://www.cs.chalmers.se/~rjmh/afp-arrows.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: nano-hmac 0.2.0

2008-02-13 Thread Steve Lihn
And in perl CPAN world, there are "bundles" that put together related
packages in one big install... Maybe there can be "Cabal bundles".
Just an idea!

On Feb 12, 2008 2:03 PM, Don Stewart <[EMAIL PROTECTED]> wrote:
> Ok, I'll leave it up there as a separate package then.  :)
>
> -- Don
>
> hitesh.jasani:
> > Don,
> >
> > It's tempting, but I would really hate to lose nano-md5 as it is
> > today.  I thought your concept was a great idea to inspire people to
> > start small to get a feel for developing Haskell libraries.  The
> > current nano-md5 serves as a really good example.
> >
> > In the Ruby community there are many small libraries that do one,
> > simple focused task.  There are times when this is a virtue over
> > libraries that try to be all encompassing.  It's weird but I would
> > have thought the Haskell community would have more embraced small
> > libraries also since they may be more composable.
> >
> > - Hitesh
> >
> >
>
> > On Feb 11, 2008 4:29 PM, Don Stewart <[EMAIL PROTECTED]> wrote:
> > > hitesh.jasani:
> > > > nano-hmac provides bindings to OpenSSL's HMAC interface.  With this 
> > > > release the
> > > > set of hashing functions supported is: MD5, SHA, SHA1, SHA224, SHA256, 
> > > > SHA384,
> > > > SHA512.
> > > >
> > > > If you're unfamiliar with HMAC's then you may want to check out the 
> > > > second link
> > > > below where I explain a little bit about them in a blog entry.
> > > >
> > > > The hackage pages mentioned that they're not running haddock 2.0, so I 
> > > > don't
> > > > know if the docs will generate.  If not, you can see the docs online at 
> > > > the
> > > > third link below.
> > > >
> > > > * 
> > > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/nano-hmac-0.2.0
> > > > * http://www.jasani.org/2008/02/nano-hmac-020-released.html
> > > > * http://docs.jasani.org/nano-hmac/0.2.0/
> > > >
> > > > Any and all comments/suggestions/criticisms/fortune-cookie-proverbs are 
> > > > welcome.
> > > >
> > >
> > > Shall we merge nano-md5 into this lib, and deprecate nano-md5 itself?
> > > Seems like a good time to consolidate, and produce a single openssl
> > > binding.
> > >
> > > -- Don
> > >
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: Finance-Treasury 0.1.1

2008-02-09 Thread Steve Lihn
A new experimental package, Finance-Treasury, has been uploaded to
hackage. It automates the fetching of Treasury's daily yield curve
data (XML) and translates the data into Data.Map representation. The
collection of historical data can go back to 1992.

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Finance-Treasury

The APIs are largely working. But the internal code still needs
improvement. Welcome suggestions and fixes. Recommendation on proper
error handling design will be particularly appreciated.

steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] How to make GHC 6.6 and 6.8 co-exist -- was: First go at reactive programming

2008-01-28 Thread Steve Lihn
I want to raise this issue again since I disagreed (see quoted text
below) that cabal-install can solve the problem of moving from one
version to another completely.

For most /pure/ packages, it is probably true. But for those packages
that have external depedencies, this is hardly so. For example,
HDBC-OBDC package depends on where the odbc driver is installled. You
actually have to modify the  file. The other package
came to mind is the pcre-regex package depending on pcre lib. On my
linux server, it is not obvious pcre-lib can be found in any standard
location specified in  file. I believe there are and
will be more packages like these.

How can cabal-install install this kind of packages without knowing
these external dependencies? They can be a path (prefix kind of
things) or an environment variable, or even an option to GHC compiler
or linker (I am not so sure about this one).

In my brief experience with Ocaml's GODI, GODI has a way to specify
them in a so-called config package. The install package then reads
what it needs from the config package. In perl's CPAN shell, you can
specify them in the cpan config file (to some extent).

I suggest cabal-install looks into this so that moving from one
version to another is indeed painless. 6.8.(1|2) is never the last
Haskell version. The fact that Cabal records the 3rd digit version in
the path indicates a diligent user has to re-install all the packages
on every new 3rd-digit dot release. That is a lot of work!

Regards,
Steve

On Jan 19, 2008 12:38 PM,  <[EMAIL PROTECTED]> wrote:
> ...
> > I am asking this question in another thread. The problem is -- I've
> > got many modules compiled under 6.6, some with much agony. If I switch
> > to 6.8, I have to recompile them again. Two issues I image:
> >
> > (1) It may take lots of effort to recompile all the modules. I have
> > forgetten how I got around some of the modules! Too bad... Got to take
> > notes next time...
>
> These days, every package you'd want to install (with the exception of GHC, 
> Darcs, and the large graphics toolkits) should be available on Hackage or at 
> least in Cabalized form.
>
> If they aren't, then that's a bug or at least missing feature. The whole 
> point of Cabal was so you don't have to take notes!
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] hxt memory useage

2008-01-27 Thread Steve Lihn
Suggestion: a binding to Expat, like perl and python did.

>
> So this is a request for an xml-light based on lazy bytestrings, designed
> for speed at all costs?
>
> -- Don
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: need help for cabal-install

2008-01-21 Thread Steve Lihn
Duncan,
I got the latest cabal. The stack overflow is fixed. But the install
command still does not work (on a very simple package). Attached is
the verbose output. It does not like to proceed somewhere between
configure and build. But the verbose is not telling why!

I also attached my cabal dance with exactly the same configure options.

/home2/ecoin/garden> cabal install -v HTTP-Simple
/home2/ecoin/ghc/bin/ghc --numeric-version
looking for package tool: ghc-pkg near compiler in /home2/ecoin/ghc/bin
found package tool in /home2/ecoin/ghc/bin/ghc-pkg
/home2/ecoin/ghc/bin/ghc-pkg --version
/home2/ecoin/ghc/bin/ghc -c /tmp/tmp26702.c -o /tmp/tmp26702.o
/usr/bin/ld -x -r /tmp/tmp26702.o -o /tmp/tmp26703.o
Reading installed packages...
/home2/ecoin/ghc/bin/ghc-pkg list --global --user
'HTTP-Simple-0.1' is cached.
Extracting /home2/ecoin/.cabal/packages/hackage.haskell.org/HTTP-Simple/0.1/HTTP
 -Simple-0.1.tar.gz to /tmp/TMPHTTP-Simple-0.1...
Creating dist/setup (and its parents)
/home2/ecoin/ghc/bin/ghc --make Setup.lhs -o dist/setup/setup -odir
dist/setup -  hidir dist/setup
[1 of 1] Compiling Main ( Setup.lhs, dist/setup/Main.o )
Linking dist/setup/setup ...
dist/setup/setup configure --verbose=2 --ghc --prefix=/home2/ecoin/htools --user
cabal: Error: some packages failed to install:
  HTTP-Simple-0.1

Configuring HTTP-Simple-0.1...
Warning: No build-type specified. If possible use build-type: Simple
Preprocessing library HTTP-Simple-0.1...
Building HTTP-Simple-0.1...
[1 of 1] Compiling Network.HTTP.Simple ( Network/HTTP/Simple.hs,
dist/build/Netw  ork/HTTP/Simple.o )
/usr/bin/ar: creating dist/build/libHSHTTP-Simple-0.1.a
Installing: /home2/ecoin/htools/lib/HTTP-Simple-0.1/ghc-6.6.1
Registering HTTP-Simple-0.1...
Reading package info from "dist/installed-pkg-config" ... done.
Saving old package config file... done.
Writing new package config file... done.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First go at reactive programming

2008-01-20 Thread Steve Lihn
This fixed the second example. Thanks.

>
> I think handleConnection should be
>
> handleConnection :: RequestHandler -> Handle -> IO ()
>
> handleConnection r h =
>  handleToRequest h >>= responseSend h . runRequestHandler r
>
>
> Levi
>
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First go at reactive programming

2008-01-19 Thread Steve Lihn
> -- | @'forever' act@ repeats the action infinitely.
> forever :: (Monad m) => m a -> m ()
> forever a   = a >> forever a

Great. The code compiled successfully by inserting this in various places.

> I'm wondering how hard to try to get these libs to work with both 6.6 and
> 6.8.  My hope has been that people will switch to 6.8, but perhaps there are
> obstacles I don't know about.  Is there something that keeps you from
> upgrading?

I am asking this question in another thread. The problem is -- I've
got many modules compiled under 6.6, some with much agony. If I switch
to 6.8, I have to recompile them again. Two issues I image:

(1) It may take lots of effort to recompile all the modules. I have
forgetten how I got around some of the modules! Too bad... Got to take
notes next time...
(2) If I got stuck in 6.8, it may not be easy to switch back.

It does not appear straightforward to me. I'd like to hear how other
people approach these issues before I jump into it. Don't want to
break the working environment that I spent months to set up!
--
Finally, get to test the Reactive sample code.

(1) Levi's first post compiled successfully and worked like charm. Congrat.
(2) Levi's second post did not compile. There is a type error...

react.hs:33:65:
Couldn't match expected type `Handle'
   against inferred type `RequestHandler'
In the first argument of `handleConnection', namely `r'
In the first argument of `fmap', namely `(handleConnection r)'
In the second argument of `(.)', namely `fmap (handleConnection r)'

Thanks.
Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] How best to make GHC 6.6 and 6.8 co-exist on one server/account

2008-01-19 Thread Steve Lihn
Hi,
It appears some of the latest hackages are moving towards 6.8 to take
advantage of the new features, while quite a few remains at 6.6. The
compatibility between the two versions has been problematic. I only
have 6.6 installed, but now thinking to add 6.8 to my account (so I
can switch between them, depending what works where).

What is the best practice to make 6.8 co-exist with 6.6 ? Specific
questions are:
1) I installed 6.6 under prefix=$HOME/ghc. If I install 6.8 to the
same prefix, it will overwrite 6.6. Correct? How do I get around it?
2) I installed additional tools and packages under $HOME/htools using
6.6. (Which I begin to wonder if that is necessary.) Do I have to use
a different directory for 6.8? I noticed that, for each package, the
path is $HOME/htools/lib//ghc-6.6.1/ etc etc. It seems
that 6.8 will create subdirectories, so they can co-exist peacefully.
Correct?

Thanks,
Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: need help for cabal-install

2008-01-19 Thread Steve Lihn
Just tried to test drive another feature and got the nasty error:

> cabal list
Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize' to increase it.


On Jan 19, 2008 9:27 AM, Steve Lihn <[EMAIL PROTECTED]> wrote:
> On Jan 19, 2008 9:18 AM, Duncan Coutts <[EMAIL PROTECTED]> wrote:
> >
> > >
> > > I think you're just missing a "--user":
> > >
> > >$ cabal install --prefix=$HOME --user foo
> >
> > The prefix can also be set in the $HOME/.cabal/config file.
> >
>
> Syntax? Something like: prefix: /path/to/my/ghc ?
>
> > BTW, In the development version of cabal-install --user is the default
> > and the default user prefix is $HOME/.cabal (though both can be changed
> > in the config file).
> >
>
> Is this newer than 12 hours ago? I tried "cabal install --prefix=/path
> package" (without --user). That did not seem to work...
>
> Steve
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: need help for cabal-install

2008-01-19 Thread Steve Lihn
On Jan 19, 2008 9:18 AM, Duncan Coutts <[EMAIL PROTECTED]> wrote:
>
> >
> > I think you're just missing a "--user":
> >
> >$ cabal install --prefix=$HOME --user foo
>
> The prefix can also be set in the $HOME/.cabal/config file.
>

Syntax? Something like: prefix: /path/to/my/ghc ?

> BTW, In the development version of cabal-install --user is the default
> and the default user prefix is $HOME/.cabal (though both can be changed
> in the config file).
>

Is this newer than 12 hours ago? I tried "cabal install --prefix=/path
package" (without --user). That did not seem to work...

Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First go at reactive programming

2008-01-19 Thread Steve Lihn
Reactive-0.3 seems to have a dependency on TypeCompose-0.3. Earlier
version does not work (for lack of Data.Pair). This probably should be
specified in Cabal file.

I aslo fixed all the LANGUAGE problems and now encountered the
following error in TypeCompose:

[4 of 9] Compiling Control.Compose  ( src/Control/Compose.hs,
dist/build/Control/Compose.o )
src/Control/Compose.hs:561:0: parse error on input `deriving'

I tried to restored the commented out "deriving Monoid" and got pass
that. Not sure if that is right though. Back to reactive-0.3, I
encountered:

src/Data/Future.hs:60:27:
Module `Control.Monad' does not export `forever'

Forever is in the latest library, but not in my GHC 6.6. I am not sure
how to get this fixed. Any suggestion?

http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html


Steve


On Jan 19, 2008 1:31 AM, Conal Elliott <[EMAIL PROTECTED]> wrote:
> Hi Steve,
>
> Thanks for letting me know about the LANGUAGE problem.  Yes, I used
> 6.8-friendly (6.6-unfriendly) LANGUAGE pragmas.  In retrospect, probably not
> such a great idea, since there seem to be many folks still on 6.6.
>
> I just changed the sources (commenting out the LANGUAGE pragmas and
> inserting -fglasgow-exts pragmas), darcs-pushed, and put a new version (0.3)
> on hackage.  Please give it another try.
>
> Cheers, - Conal
>
>
>
> On Jan 18, 2008 7:58 PM, Steve Lihn <[EMAIL PROTECTED]> wrote:
> > Tried to install reactive-0.2 on GHC-6.6, but failed.
> >
> > Building reactive-0.2...
> > src/Data/Reactive.hs:1:13: cannot parse LANGUAGE pragma
> >
> > Is the package for GHC 6.8? Is there an older version (0.0?) for GHC
> > 6.6 that I can play with your example? (Or advise how to hack that
> > file to get it work on 6.6)
> >
> > Thanks,
> > Steve
> >
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First go at reactive programming

2008-01-18 Thread Steve Lihn
Tried to install reactive-0.2 on GHC-6.6, but failed.

Building reactive-0.2...
src/Data/Reactive.hs:1:13: cannot parse LANGUAGE pragma

Is the package for GHC 6.8? Is there an older version (0.0?) for GHC
6.6 that I can play with your example? (Or advise how to hack that
file to get it work on 6.6)

Thanks,
Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] need help for cabal-install

2008-01-18 Thread Steve Lihn
Hi,
I just got cabal-install working. However, I have a problem using it.
My GHC is installed in a user-specific location, so when I do the
Cabal dance, I have to specfiy "Setup configure --prefix=$HOME/ghc".
Now with "cabal install", I can not figure out where to specify the
--prefix. Cabal always complains "failed to install package".
Help is appreciated.

Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskelldb basic documentation needed

2008-01-16 Thread Steve Lihn
For mysql (via HDBC),some documentation is available here. But it is
rather going through HDBC-ODBC-mysql. It is a bit complex than you
would normally expect with mysql.

http://en.wikibooks.org/wiki/Haskell/Database

2008/1/15 Justin Bailey <[EMAIL PROTECTED]>:
> 2008/1/15 Immanuel Normann <[EMAIL PROTECTED]>:
>
> > I don't know what pairs of strings this function needs. The API
> description is to unspecific:
> >
> >
> > > The connect function takes some driver specific name, value pairs use to
> setup the database connection, and a database action to run.
> >
> >
> > What are the specific name value pairs needed (for a connection to a mysql
> db )?
> > Immanuel
>
> Your best bet is to download the appropriate drivers - either
> haskelld-hdbc-mysql or haskelldb-hsql-mysql. If you get the haskelldb
> sources via darcs, you can also look in the test directory to see how the
> connections are established.
>
> In my specific case, I am using PostgreSQL and by login  function looks like
> this:
>
> -- ^ Returns a function which can log into the database and perform
> operations.
> login :: MonadIO m => String -> Int -> String -> String -> String ->
> (Database -> m a) -> m a
> login server port user password dbname = postgresqlConnect [("host",
> server),
>   ("port", show port),
>   ("user", user),
>   ("password", password),
>   ("dbname", dbname)]
>
> >
> > ___
> > Haskell-Cafe mailing list
> > Haskell-Cafe@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> >
>
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] How to add ENV variable in runhaskell shell script

2008-01-13 Thread Steve Lihn
Hi,
In perl scripts (unix), one can do
==
#!/usr/local/bin/perl
BEGIN {
  $ENV{LD_LIBRARY_PATH} = ...;
}
  do my perl stuff
==
The setting of ENV variable before the program runs allows me to fix
the shell environments. In this case, I need to specify where to look
for the shared library.

How do I do this in Haskell if I am writing the same script using:
==
#!/path/to/runhaskell
  {-
 how to set LD_LIBRARY_PATH = ... ?
  -}

  do my haskell stuff
==

Thanks,
Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Consensus about databases / serialization

2008-01-02 Thread Steve Lihn
I have started documenting the Database Wikibook, in particular, about
HDBC. It is still very rough at this time, but something is better
than nothing :-) If you want to add more content, certainly welcome!

http://en.wikibooks.org/wiki/Haskell/Database

On 1/2/08, Jeff Polakow <[EMAIL PROTECTED]> wrote:
> Hello,
> I use HDBC for ODBC database access,
and HAppS as a web server. I am fairly happy with both. Here are some further
thoughts...
> > Finally some practical questions:

> > ·regarding Haskell
and databases, the page http://haskell.
>
> org/haskellwiki/Libraries_and_tools/Database_interfaces describes
a
>
> few, but which are the ones that are stable and practical? Any user

>
> experiences?

> >

> HDBC is fairly stable (although its ODBC driver crashes
ghc 6.8 on windows). I think HSQL is similarly stable. Takusen offers a
slightly higher-level interface and some performance guarantees; it is
a nice system but lacks support for ODBC (supposedly this is in the works).
HaskelDB is probably the ideal database access system for Haskell, however
the distribution was in bad shape (no documentation, hard to compile, etc.)
the last I looked maybe 6 months ago.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] An interesting monad: "Prompt"

2007-12-29 Thread Steve Lihn
Ryan,
I get "cannot parse LANGUAGE pragma" on GHC 6.6.1. Does the code require 6.8 ?
Thanks,
Steve

On Dec 29, 2007 6:09 PM, Ryan Ingram <[EMAIL PROTECTED]> wrote:
> I posted the current version of this code at
> http://ryani.freeshell.org/haskell/
>
>
> On 12/28/07, Thomas Hartman <[EMAIL PROTECTED]> wrote:
> > Would you mind posting the code for Prompt used by
> >
> > import Prompt
> >
> > I tried using Prompt.lhs from your first post but it appears to be
> > incompatible with the guessing game program when I got tired of
> > reading the code and actually tried running it.
> >
> > best, thomas.
> >
> >
> >
> > 2007/12/4, Ryan Ingram <[EMAIL PROTECTED] >:
> > > Ask and ye shall receive.  A simple guess-a-number game in MonadPrompt
> > > follows.
> > >
> > > But before I get to that, I have some comments:
> > >
> > >
> > > Serializing the state at arbitrary places is hard; the Prompt contains a
> > > continuation function so unless you have a way to serialize closures it
> > > seems like you lose.  But if you have "safe points" during the execution
> at
> > > which you know all relevant state is inside your "game state", you can
> save
> > > there by serializing the state and providing a way to restart the
> > > computation at those safe points.
> > >
> > > I haven't looked at MACID at all; what's that?
> > >
> > > > {-# LANGUAGE GADTs, RankNTypes #-}
> > > > module Main where
> > > > import Prompt
> > > > import Control.Monad.State
> > > > import System.Random (randomRIO)
> > > > import System.IO
> > > > import Control.Exception (assert)
> > >
> > > Minimalist "functional references" implementation.
> > > In particular, for this example, we skip the really interesting thing:
> > > composability.
> > >
> > > See http://luqui.org/blog/archives/2007/08/05/ for a real
> > > implementation.
> > >
> > > > data FRef s a = FRef
> > > >   { frGet :: s -> a
> > > >   , frSet :: a -> s -> s
> > > >   }
> > >
> > > > fetch :: MonadState s m => FRef s a -> m a
> > > > fetch ref = get >>= return . frGet ref
> > >
> > > > infix 1 =:
> > > > infix 1 =<<:
> > > > (=:) :: MonadState s m => FRef s a -> a -> m ()
> > > > ref =: val = modify $ frSet ref val
> > > > (=<<:) :: MonadState s m => FRef s a -> m a -> m ()
> > > > ref =<<: act = act >>= modify . frSet ref
> > > > update :: MonadState s m => FRef s a -> (a -> a) -> m ()
> > > > update ref f = fetch ref >>= \a -> ref =: f a
> > >
> > > Interactions that a user can have with the game:
> > >
> > > > data GuessP a where
> > > >GetNumber :: GuessP Int
> > > >Guess :: GuessP Int
> > > >Print :: String -> GuessP ()
> > >
> > > Game state.
> > >
> > > We could do this with a lot less state, but I'm trying to show what's
> > > possible here.  In fact, for this example it's probably easier to just
> > > thread the state through the program directly, but bigger games want
> real
> > > state, so I'm showing how to do that.
> > >
> > > > data GuessS = GuessS
> > > >   { gsNumGuesses_ :: Int
> > > >   , gsTargetNumber_ :: Int
> > > >   }
> > >
> > > > -- a real implementation wouldn't do it this way :)
> > > > initialGameState :: GuessS
> > > > initialGameState = GuessS undefined undefined
> > >
> > > > gsNumGuesses, gsTargetNumber :: FRef GuessS Int
> > > > gsNumGuesses   = FRef gsNumGuesses_   $ \a s -> s { gsNumGuesses_   =
> a }
> > > > gsTargetNumber = FRef gsTargetNumber_ $ \a s -> s { gsTargetNumber_ =
> a }
> > >
> > > Game monad with some useful helper functions
> > >
> > > > type Game = StateT GuessS (Prompt GuessP)
> > >
> > > > gPrint :: String -> Game ()
> > > > gPrint = prompt . Print
> > >
> > > > gPrintLn :: String -> Game ()
> > > > gPrintLn s = gPrint (s ++ "\n")
> > >
> > > Implementation of the game:
> > >
> > > > gameLoop :: Game Int
> > > > gameLoop = do
> > > >update gsNumGuesses (+1)
> > > >guessNum <- fetch gsNumGuesses
> > > >gPrint ("Guess #" ++ show guessNum ++ ":")
> > > >guess <- prompt Guess
> > > >answer <- fetch gsTargetNumber
> > > >
> > > >if guess == answer
> > > >  then do
> > > >gPrintLn "Right!"
> > > >return guessNum
> > > >  else do
> > > >gPrintLn $ concat
> > > >[ "You guessed too "
> > > >, if guess < answer then "low" else "high"
> > > >, "! Try again."
> > > >]
> > > >gameLoop
> > >
> > > > game :: Game ()
> > > > game = do
> > > >gsNumGuesses =: 0
> > > >gsTargetNumber =<<: prompt GetNumber
> > > >gPrintLn "I'm thinking of a number.  Try to guess it!"
> > > >numGuesses <- gameLoop
> > > >gPrintLn ("It took you " ++ show numGuesses ++ " guesses!")
> > >
> > > Simple unwrapper for StateT that launches the game.
> > >
> > > > runGame :: Monad m => (forall a. GuessP a -> m a) -> m ()
> > > > runGame f = runPromptM f (evalStateT game initialGameState)
> > >
> > > Here is the magic function for interacting with the player in IO.
> Exercise
> > > for the reader: make this more robust.
> > >
> > > > g

Re: [Haskell-cafe] Interesting data structure

2007-12-29 Thread Steve Lihn
What you described has a Java parallel:

> In the first program, I am reading on-demand from a database - just
> reading, not making any changes.
>
This is similar to EJB's entity bean.  Usually EJB requires XA driver
to preserve database state across the cluster, but in your read-only
case, this is not needed. HDBC puts you into the IO monad. You need to
get yourself out of IO monad if you believe your code is "pure".

> In the second, I am requesting computations to be evaluated
> externally, in order to take advantage of a grid of machines.
>
This is similar to J2EE's clustering, where beans can sit on any node
of the cluster and be accessed via RMI. The ability to handle
(de)serialization is the key here. Java's solution is proprietary,
while Microsoft dot NET has choosen SOAP to request computation over
network. Network calls will also put you into the IO monad, which has
to be hidden in your case..

If you came up with a solution, it might have invented the H2EE.

Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: DSL question -- was: New slogan for haskell.org

2007-12-26 Thread Steve Lihn
>arising from use of `/' at DSLTest.hs:11:14-28

Thanks for the example. I am particularly amazed GHC is complaining at
'/', not '+'. The type mismatch occurs (is reported) at much lower
level. It would be nice if there is a way to bump it up a couple
levels...


On Dec 26, 2007 12:56 PM, Bjorn Buckwalter <[EMAIL PROTECTED]> wrote:
> Steve Lihn  gmail.com> writes:
>
> > I do come aross a question while reading the DSL page on Wikipedia.
> >
> > http://en.wikipedia.org/wiki/Domain-specific_programming_language
> >
> > In the Disadvantage section (near the end), there is an item -- hard
> > or impossible to debug. Can anybody explain why or what it means? And
> > how does it apply to Haskell?
>
>
> I think I can give a good example of how this can apply to EMBEDDED DSLs. My
> library Dimensional (http://dimensional.googlecode.com) defines what someone
> referred to as a EDSL for working with physical units. The library leverages 
> the
> Haskell type checker to provide static checking of physical dimensions. 
> Without
>  doing this I don't know how I could make such checking static.
>
> The downside of this is that while you will be informed at compile time if you
> physical calculations are incorrect the error message itself is rarely useful.
> Here is an example with lines numbered:
>
>  1 import Numeric.Units.Dimensional.Prelude
>  2 import qualified Prelude
>  3
>  4 -- The angular velocity of Earth's rotation (Soop p. 7).
>  5 phi = 360.985647 *~ (degree / day)
>  6
>  7 -- The gravitational parameter of Earth.
>  8 mu = 3.98600448003e14 *~ (meter ^ pos3 / second ^ pos2)
>  9
>  10 -- The ideal geostationary radius and velocity.
>  11 r_GEO = cbrt (mu / phi ^ pos2)
>  12 v_GEO = phi * r_GEO
>  13
>  14 -- Something obviously wrong.
>  15 dont_try_this_at_home = v_GEO + mu
>
> Obviously we shouldn't be adding a velocity to a gravitational parameter on 
> line
> 15 and the compiler will catch this. However, this is the error message from
> GHCi (6.6.1):
>
> DSLTest.hs:1:0:
>Couldn't match expected type `Numeric.NumType.Neg n'
>   against inferred type `Numeric.NumType.Zero'
>When using functional dependencies to combine
>  Numeric.NumType.Sub a Numeric.NumType.Zero a,
>arising from the instance declaration at Defined in Numeric.NumType
>  Numeric.NumType.Sub Numeric.NumType.Zero
>  Numeric.NumType.Zero
>  (Numeric.NumType.Neg n),
>arising from use of `/' at DSLTest.hs:11:14-28
>
> I think you will agree that this isn't very helpful in pin-pointing the 
> problem.
> The compiler is pointing at the definition of 'r_GEO' which is twice removed
> from the actual offender. Stuff like this can make EDSLs difficult to debug.
>
> (In this particular example adding type signatures to all definitions will 
> allow
> the compiler to pin-point the error to line 15, although the error message
> remains cryptic.)
>
> Hope that helps,
> Bjorn
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-26 Thread Steve Lihn
Just curious -- how can this be done in Arrows instead of Manad/T? Or can it?

On Dec 26, 2007 6:42 AM, Benja Fallenstein <[EMAIL PROTECTED]> wrote:
> On Dec 23, 2007 1:44 PM, Isaac Dupree <[EMAIL PROTECTED]> wrote:
> > parseHeader3 :: BS.ByteString -> Maybe (Int, Int)
> > parseHeader3 bs = do
> >(x, rest) <- BS.readInt $ BS.dropWhile (not . isDigit) bs
> >(y, _) <- BS.readInt $ BS.dropWhile (not . isDigit) rest
> >return (x, y)
>
> But that version still itches! :-)
>
> This is what it sounds like to me:
>
> parseHeader :: BS.ByteString -> Maybe (Int,Int)
> parseHeader = evalStateT $ liftM2 (,) parseInt parseInt where
>parseInt = StateT $ BS.readInt . BS.dropWhile (not . isDigit)
>
> - Benja
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Hoogle search scope question -- was: [HXT] Simple question

2007-12-22 Thread Steve Lihn
I have a hoogle question. While I was reading the HXT discussion
(below), I tried to search "runX" and "readString" in Hoogle (since I
am new to HXT and Arrows). But neither search yielded any result and I
had to use google to find the Haskell docs.

So I am wondering what is the scope of Hoogle that people can search?
Only things in the standard library? How much does it cover in the
Hackage? I tried to find the scope description in the Tutorial but in
vain. It is fair to say if someone needs to use Hoogle, he/she
probably has no idea what he is looking for, needless to say, what is
in scope of Hoogle or what is not.

Thanks,
Steve


On Dec 19, 2007 7:48 AM, Miguel Mitrofanov <[EMAIL PROTECTED]> wrote:
> Seems rather strange for me, I've just installed HXT and got this:
>
> Prelude Text.XML.HXT.Arrow> runX $ readString [(a_validate,"0")] " 
> " >>> writeDocumentToString []
> ["\n "]
>
> > Everything works fine except for the fact that all the nodes  
> > 
> > (that is, a space (an XML text node whose contents are a single space
> > character)
> > within a  element node) get transformed to aelement node,
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


FFI question -- was: [Haskell-cafe] New slogan for haskell.org

2007-12-19 Thread Steve Lihn
On Dec 11, 2007 11:16 PM, Don Stewart <[EMAIL PROTECTED]> wrote:
> >2. It offers strong support for integration with other languages and 
> > tools
> >(FFI? Is the support strong?)
>
>2. The FFI in Haskell is perhaps the most powerful out there.
>   You can import C or export Haskell to C with a single line FFI decl.
>
Don,
I am a newbie on FFI, but have been interested in looking into it. If
I google on "haskell FFI", what I find is typically:
1. The official Haskell 98 FFI 1.0
2. The FFI preprocessor -- greencard on haskell.org, where several
other preprocessors are listed (in the Link section): HaskellDirect, C
to Haskell, hsc2hs (included in GHC distributions), QForeign, KDirect.

The FFI 1.0 API is certainly the most robust tool. However, the
existence of preprocessors seem to suggest (at least very enticing)
that the use of a preprocessor would make life easier.

But when I dig deeper, several of them have not had any release in
(more than) 3 years. The only exception seem to be "C to Haskell",
which is part of gtk2hs, and hsc2hs, being part of GHC. It immediately
becomes confusing which tool I should use if I were to work on a FFI
project... Can you shed some light on this?

Thanks, Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] DSL question -- was: New slogan for haskell.org

2007-12-19 Thread Steve Lihn
Thanks for the explanation on DSL. It helped me understand how Haskell
works compared to other popular languages out there. It is a
programming methodology change. Or what is called paradigm change on
how to design a software with Haskell.

Haskell has its general-purpose features. Yet its strength is the
ability and ease of defining DSL by utilizing the higher order
\"stuff\" (like type class, composite function, monads, and arrows),
which to say the least, can be quite abstract and challenging.

I do come aross a question while reading the DSL page on Wikipedia.

http://en.wikipedia.org/wiki/Domain-specific_programming_language

In the Disadvantage section (near the end), there is an item -- hard
or impossible to debug. Can anybody explain why or what it means? And
how does it apply to Haskell?

-- steve

On 12/11/07, Brandon S. Allbery KF8NH <[EMAIL PROTECTED]> wrote:
>
> > * Domain Specific Language (who needs it? other than academics and
> > Wall Streeter?)
>
> DSELs can be thought of as a programming methodology; as such, it has
> wide applicability, but most programmers don\'t think that way.  Tcl
> was originally positioned as a \"DSEL enabler\" (write composable
> functions in C, tie them together in Tcl), but most programmers
> \"don\'t get it\" and so don\'t tend to use it as such.  More recently,
> Lua seems to be using a similar philosophy with a little more success
> --- but mainly by limiting it to something which most programmers can
> deal with.  Also compare how Perl and Python monoliths have replaced
> the original Unix philosophy in which the shell is a DSEL enabler
> (composing single-function programs like \"cat\" and \"sort\").
>
> When it comes down to it, Haskell\'s strengths are only realizeable if
> you approach programming problems in a different way from most common
> languages.  It\'s a fairly big leap, and arguably Haskell won\'t
> compete well in the mainstream until more programmers have made that
> leap.
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-12-11 Thread Steve Lihn
I have not used Haskell to write large scale program, but I am
certainly interested to know the answer to these questions.

Can Haskell offer the following as Pythoner boasts?
1. can be used for many kinds of software development. (some may argue yes,
but different kinds from what python is good for.)
2. It offers strong support for integration with other languages and tools
(FFI? Is the support strong?)
3. comes with extensive standard libraries (this is a yes, and is getting
better every day)
4. and can be learned in a few days (very unlikely, maybe a few months to a
year)

What is Haskell good for?
* Domain Specific Language (who needs it? other than academics and Wall
Streeter?)
* smaller program and much less bugs
* concise program logic
* program that can be reasoned (is that the reason Haskell module comes with
so few comments and documentation?)
* highly reusable code (due to higher order function and type class?)
* clear distinction between functional and imperative (is this really an
advantage? almost everything I deal with is IO, network, and db related,
what is left for purely functional?)

A person/team has to be convinced of these "high-level" questions before he
can decide to bet his project on Haskell. That is the thought process I
am struggling through right now.

steve


On Dec 11, 2007 9:12 PM, <[EMAIL PROTECTED]> wrote:

> FWIW to the discussion about changing the main page, I was reading the
> CUFP paper and I saw some germane comments (and the writer is apparently one
> Noel Welsh, whose name I don't see in the thread); the context is a
> discussion (pg 17) of various members or potential members of the Haskell
> community and how supported they are:
>
>  "What are the needs of the potential programmer? People program to solve
> prob-
>  lems; so there had better be a clear statement of what kinds of problem
> the
>  language is good for. The Python community does a good job of this on
>  python.org: "Python is a dynamic object-oriented programming language
> that can
>  be used for many kinds of software development. It offers strong support
> for
>  integration with other languages and tools, comes with extensive standard
>  libraries, and can be learned in a few days."
>
>  Compare this with the equivalent from haskell.org: "Haskell is a
>  general purpose, purely functional programming language featuring static
>  typing, higher-order functions, polymorphism, type classes, and monadic
>  effects. Haskell compilers are freely available for almost any computer."
> If
>  you understand all that, you don't need to be here: you're already a
> Haskell
>  programmer."
>
> --
> gwern
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe