Re: [Haskell-cafe] Yet another implementation of cond

2007-06-27 Thread Andrea Rossato
On Wed, Jun 27, 2007 at 05:07:54PM -0500, Jon Cast wrote:
> I discovered this trick the other day, and didn't remember seeing it anywhere 
> as a cond implementation:
> 
> head $
>   [ e1 | cond1 ] ++
>   [ e2 | cond2 ] ++
>   [ e3 | cond3 ]

Cool!
Thanks for sharing it.

All the best,
andrea
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Updating haskell.org robots.txt

2007-06-27 Thread Justin Bailey

All,

Referencing this thread (
http://www.haskell.org/pipermail/haskell-cafe/2007-May/025769.html), I have
prepared a small update to robots.txt. It doesn't do much, but should
exclude all dynamic pages from being spidered. Please vet it and let me know
of any concerns. Note I'm not really interested in reconfiguring the wiki to
have nicer URLs - what is there is what I'm working with right now.

Here's the updated robots.txt (availabe as
http://www.haskell.org/robots2.txt right now):

 User-agent: *
 Disallow: /haskellwiki/Special:
 Disallow: /haskellwiki/Special%3A
 Disallow: /haskellwiki/?
 Disallow: /haskellwiki/%3f

Any feedback, let me know. Thanks!

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


Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Jon Cast
On Wednesday 27 June 2007, you wrote:
> Andrew: Try using catchalls in your guards
>
>
> pattern1
>
> | guard1 =
> | guard2 =
> | otherwise =
>
> This makes it much easier to use pattern guards.
> "otherwise" is a reserved word used for this stuff in ghc.

Since we're quoting the standard and all, my inner pedant can't help but 
quibble: otherwise is not a keyword, it's a synonym for True defined in the 
Standard Prelude (and, in particular, goes away if you say import Prelude 
()):

$ cat > Foo.hs
import Prelude

main = print otherwise
$ ghc Foo.hs -o foo
$ ./foo
True
$ cat > Foo.hs
import Prelude (print)

main = print otherwise
$ ghc Foo.hs -o foo

Foo.hs:3:13: Not in scope: `otherwise'


Sincerely,
Jonathan Cast
Computer Programmer
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Dan Mead

Andrew: Try using catchalls in your guards


pattern1
| guard1 =
| guard2 =
| otherwise =

This makes it much easier to use pattern guards.
"otherwise" is a reserved word used for this stuff in ghc.


-Dan


On 6/27/07, Jon Cast <[EMAIL PROTECTED]> wrote:


On Wednesday 27 June 2007, Andrew Coppin wrote:
> Stefan O'Rear wrote:
> > On Wed, Jun 27, 2007 at 09:46:41PM +0100, Andrew Coppin wrote:
> >> I have a tricky little question...
> >>
> >> Suppose I write a function like this:
> >>
> >>  foo pattern1
> >>
> >>| gard1 = ...
> >>| gard2 = ...
> >>
> >>  foo pattern2
> >>
> >>| gard3 = ...
> >>| gard4 = ...
> >>
> >> According to one tutorial I read, if pattern1 matches, pattern2 will
> >> never be tried, even if both guard1 and guard2 fail.
> >>
> >> And according to another tutorial I read, if pattern1 matches but all
> >> guards fail, pattern2 *will* be tried.
> >>
> >> Can somebody comfirm which one is actually correct?
> >
> > According to http://haskell.org/onlinereport/exps.html#sect3.17.2
> >
> > Top level patterns in case expressions and the set of top level
patterns
> > in function or pattern bindings may have zero or more associated
guards.
> > A guard is a boolean expression that is evaluated only after   all of
> > the arguments have been successfully matched, and it must be true for
> > the overall pattern match to succeed. The environment of the guard is
> > the same as the right-hand-side of the case-expression
> > alternative, function definition, or pattern binding to which it is
> > attached.
> >
> > So, if guard1 and guard2 both fail, then pattern1 doesn't match (and
> > pattern matching continues).  As such, your "corner case" cannot
> > actually exist.
>
> Wow, wait a sec - case expressions are allowed to have guards too??

Yes.  I guess I assumed you knew that, sorry.

The only syntactic (or semantic) difference between function equations and
case expressions (aside from the fact that case expressions require you to
tuple up the values you're pattern-matching on) is the fact that case
expressions use -> where function bindings use =.  Other than that, the
two
forms are exactly equivalent.

Sincerely,
Jonathan Cast
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs
___
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] New New newbie question/help

2007-06-27 Thread Balu Raman

Thanks Paul.
Yes, I was missing a node in the polygon list.
I did  change to equilateralTri :: Float -> Float -> Float -> IO() for
the scalings that you mentioned. Yes, i was doing the snowflake
problem.
thanks,
balu raman

On 6/27/07, Paul Hudak <[EMAIL PROTECTED]> wrote:

  Hi Balu.  It looks like you've gotten some excellent advice from
others, but permit me to add a further comment regarding the broader
context, now that I've had a chance to look a little closer.

 It looks like you're trying to solve the "fractal snowflake" exercise.  One
of the challenges in programming with numbers is deciding what
representation to use.  Ints are great because they are efficient, but if
you need to use trigonometric functions such as sine, etc. then you need
Floats or Doubles.  The problem here is that you need both -- you need Ints
because polygon is defined in terms of pixels, which are represented as
Ints, and you need Floats because you need to compute the coordinates of an
equilateral triangle, which (interestingly) can't be represented using
integer coordinates.  But also, in the case of the snowflake fractal, you
will need to scale the size as you recurse.  The reason that the latter is
important is that it implies that the arguments to equilateralTri should
perhaps be floats -- otherwise you will once again run into numeric
conversion problems as you try to scale the arguments (unless you always
start with a pixel size that is a multiple of six).

 So -- I would still suggest using Window -> Float -> Float -> Float -> IO()
as the type for equilateralTri.  It's only when you make the call to polygon
that you need Ints.  And there you can just use "round" to convert the
Floats to Ints.

 As an aside, looking at your code a bit closer, I see this:

 (polygon [(x,y),(a,b),(x,y)]))
 where
 b = y + side * sin(pi/3)
 a = x + side * cos(pi/3)

 Something is not right here -- you repeat (x,y) as a vertex.  Probably the
third vertex should be (x+side,y).  Also, note that sin (pi/3) and cos
(pi/3) are constants (namely 0.866... and 0.5, resp.).

 I hope this helps,

 -Paul


 Balu Raman wrote:
I am for ever obliged to this haskell community. Who would have thought that
Prof.Hudak would reply instantly, from on-the-road. I am reading his SOE.
Thanks so much.

 I went with peterv's response after trying so many things.
 I tried to change to : equilateralTri Window -> Float -> Float -> Float ->
IO()
 which bombed because polygon wants list of integer-pairs.

 I read the definitions of fromIntegral and round and they are defined as :

 fromIntegral :: (Num b, Integral a) => a -> b
 round :: (RealFrac a, Integral b) => a->b
 Is it proper/ok to defines them as :
 fromIntegral :: (a::Integral) -> (b::Num)
 and
 round :: (a::RealFrac) -> (b::Integral)  ?
 Is RealFrac is-a Num ?
 Does the order matters in (Num b,Integral a) => a -> b or
(Integral a,Num b) => a -> b

 With your encouragements, I'll keep pluuging. Thanks.
 - br


On 6/27/07, peterv <[EMAIL PROTECTED]> wrote:
I'm also a haskell newbie, but I'll try to help; the experts here will
 correct me if I'm wrong.

 The compiler cannot in all cases infer the type of a number. pi can be a
 Float, a Double, or even a complex number.

 Furthermore unlike in C/C++ you cannot just mix integer and floating
 operations.

 For example, the following works for me:

 f :: Int -> Int
 f side = round ( (fromIntegral side) * sin ( (pi::Float) / 3 ) )

 or easier

 f side = round ( (fromIntegral side) * sin (pi / 3.0) )

 I'm sure the experts here will have a better solution.

 Peter
 -Original Message-
 From:  [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Balu Raman
 Sent: Wednesday, June 27, 2007 1:25 PM
 To:  Haskell-Cafe@haskell.org
 Subject: [Haskell-cafe] New New newbie question/help

 Hi,
 Hope someone can help me, just starting out with SOE.My code :
 module Main where
 import Graphics.SOE.Gtk

 spaceClose :: WIndow -> IO()
 spaceClose w = do k <- getKey w
if k == ' ' then closeWindow w
else spaceClose w

 equilateralTri :: Window -> Int -> Int -> Int -> IO()
 equilateralTri w x y side
= drawInWindow w (withColor Red
(polygon
 [(x,y),(a,b),(x,y)]))
where
 b = y + side * sin(pi/3)
 a = x + side * cos(pi/3)
 main =
runGraphics(
   do w <- openWindow "Equilateral
 Triangle" (400,400)
 equilateralTri w 50 300 200
 spaceClose w
 )

 all of the above in file triangle.hs
 when I do a :l triangle.h in ghci,  I get the following error
 triangle.hs:17:36:
 No instance for (Floating Int)
  

RE: [Haskell-cafe] Tools for Haskell and COM

2007-06-27 Thread Tim Docker
Alistair Bayley wrote:

> I want to interface Takusen with MS Sql Server,
> but AFAICT the recommended C API is OLE DB, which
> is a COM API.

An alternative would be to write a takusen <-> freetds binding
(http://www.freetds.org/). This would have the potential benefits of
being

* cross platform (ie windows and linux)
* multi db (ie ms-sql and sybase)

I should admit that there's a bit of self-interest here... I'd use such
a binding it it existed.

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


[Haskell-cafe] Cabal Configurations - Beta-Testers Wanted

2007-06-27 Thread Thomas Schilling

Hello Cafe!

Cabal configurations are an often-requested new feature of Haskell's  
packaging system Cabal.  As part of my Google Summer of Code project  
I implemented it with the feature set of the latest proposal[1].  I  
would now like people to try it out and give some feedback if it  
solves their problems, if there are bugs with the current  
implementation, or if it breaks any install scripts.


So, if you have written a package and think your package could profit  
from Cabal configurations, please adjust your package description and  
try to build it on as many systems as possible and report any  
problems (or successes).


Following are some instructions to get started.

Thanks,

/ Thomas



INSTALLING

[Note: The following build instructions are for a recent GHC.  If you  
have another Haskell compiler/interpreter you'll probably have to  
adjust these steps a bit.  Please report any problems you encounter.]


You should be able to get Cabal with configurations via:

  $ darcs get --partial http://code.haskell.org/~nominolo/src/cabal 
+configs/


Before installing you might want to hide the current cabal package  
using (tt shouldn't be necessary, though) via


  $ ghc-pkg hide Cabal

or

  $ sudo ghc-pkg hide Cabal

depending on where Cabal is installed.

Installing the new Cabal should be as simple as:

  $ cd cabal+configs
  $ make install user=y PREF=~/sw

This will build Cabal with version 1.1.7, register it in the current  
user's package database, and install it to the "sw" directory of the  
current user home directory.  Adjust the parameters to your needs.


To remove use:

  $ make remove user=y PREF=~/sw



NEW FEATURES

The new constructs didn't integrate well with the conventional  
syntax, so I changed it to a C-style block-style syntax.  (This is  
consistent with Haskell's use of { .. } in do-blocks; adding or  
replacing this with an indentation-based approach is thinkable and  
might actually integrate better with the rest of Cabal file syntax.   
So yell if you want it--but no bike sheds please! ;)


The new syntax structures cabal files like this:

global properties

optional flags descriptions

Library {
  library build properties and conditionals
}

Executable name {
  executable build properties and conditionals
}

For an example, see below.

Inside the Library and executable sections you can now use  
conditionals with the syntax:


  body: cabal_stanza "\n" body
  | "if" conditional "{" body "}" [ "else" "{" body  
"}" ] body

  | 

  conditional:  "os(" string ")"
  | "arch(" string ")"
  | "flag(" flagname ")"
  | "True"
  | "False"
  | "!" conditional
  | conditional "||" conditional
  | conditional "&&" conditional
  | "(" conditional ")"

Note that you cannot test for dependencies directly.  The user either  
specifies certain features she wants by switching flags on or off  
during the configure step or Cabal picks a suitable flag assignment  
for you, depending on which dependencies are available.  Unless  
specified otherwise, flag assignments default to True.


ATM, the only field specifying dependencies is "build-depends".   
Options specified inside a conditional are (mostly) added to the  
values specified outside.  E.g.


  GHC-Options: -Wall
  if flag(debug) {
GHC-Options: -DDEBUG
  }

when built with flag "debug" set to True will be built with

  GHC-Options: -Wall -DDEBUG

For a more detailed description see[1].  The following example .cabal- 
file should demonstrate the features (it is also available and  
updated at[2]):


Name: Test1
Version: 0.0.1
Cabal-Version: >= 1.1.7
License: BSD3
-- License-File: LICENSE
Author: Thomas Schilling <[EMAIL PROTECTED]>
Maintainer: Thomas Schilling <[EMAIL PROTECTED]>
--Homepage: http://www.example.com/
Synopsis: Test package to test configurations
Description:
See synopsis.
.
Really.
Category: Useless

Flag Debug {
  Description: Enable debug support
  Default: False
}

Flag NoBuild {
  Description: Inhibit building this package.
  -- defaults to True
}

Library {
  Build-Depends:   base
  Exposed-Modules: Testing.Test1
  Extensions:  CPP

  -- flag names are case insensitive
  if flag(debuG) {
CC-Options: "-DDEBUG"
GHC-Options: -DDEBUG
  }

  if flag(NoBuild) {
Build-Depends: nonexistentpackage
  }
}

Executable test1e {
  Main-is: T1.hs
  Other-modules: Testing.Test1

  if flag(debug) {
CC-Options: "-DDEBUG"
GHC-Options: -DDEBUG
  }
}

When configuring it with the usual command line, you now get an  
additional line, showing which flags were chosen:


$ ./Setup.lhs configure
configure: Reading installed packages...
Configuring Test1-0.0.1...
configure: Flags chosen: nobuild=False, debug=False
Setup.lhs: Warning: No license-file field.
configure: Dependen

Re: [Haskell-cafe] Tools for Haskell and COM

2007-06-27 Thread Jon Cast
On Wednesday 27 June 2007, Andrew Coppin wrote:
> J. Garrett Morris wrote:
> > Microsoft's Component Object Model.
> >
> > http://en.wikipedia.org/wiki/Component_Object_Model
>
> ...still left feeling unenlightened.

COM documentation does seem to have that effect on people. . .

Jonathan Cast
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Running GranSim on GHC 6.6.1

2007-06-27 Thread Felipe Almeida Lessa

Hello, everybody!

I'd like to know how to compile with GranSim. When compiling anything
I get an error about package "concurrent". In fact, it complains even
something simple like

$ ghc -gransim
ghc-6.6.1: unknown package: concurrent

This happens with GHC 6.6 from Ubuntu packages and from GHC 6.6.1
compiled from the site tarballs with "./configure --enable-gransim".

Is GranSim broken? Or deprecated? Maybe on GHC from Darcs? Or do I
have to do something else? I couldn't find anything recent about
GranSim (and I've googled quite a lot =).

Any pointers are appreciated!

Thanks in advance,

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


[Haskell-cafe] Re: practicality of typeful programming

2007-06-27 Thread oleg

Daniil Elovkov wrote:
> The fact that structure is mixed with properties seems to put some
> limits on both doability and, even more, practilaty of encoding
> complex properties.

That's why phantom types, attached via a newtype wrapper, are so
appealing. If we remove the wrapper, we get the original value to be
used in other parts of the program. Adding the wrapper requires either
a dynamic test or a special way of constructing a value. Please see
the Non-empty list discussion and the example on Haskell Wiki.

> in the paper "Strongly typed heterogeneous collections" you say, that the
> given approach only works for statically specified SQL query, I mean
> encoded in the Haskell program, not parsed from the untyped input
> string? (I've just flipped through it, but failed to find this
> place...) Either in case when data schema is statically known, or,
> even worse, when it's also dynamic.
>
> Interesting, can all the assertions be proved in that case? Like
> correspondence between select field types and resultset record types.

Indeed, the assumption of the HList paper is that the query is
embedded in a program (entered by the programmer alongside the code)
and the database schema is known. This is quite a common use
case. There are cases however when the database schema is dynamic and
so is the query: that is, the query is received in a string or file,
after the (part of the) code has been compiled. Then we need to
typecheck that query. The best way of doing this is via Template
Haskell. We read the query form the string, make an AST, and then
splice it in. The latter operation implicitly invokes the Haskell
typechecker. If it is happy, the result can be used as if the query
were static to start with. Frederik Eaton used this approach for
strongly-typed linear algebra.

http://ofb.net/~frederik/stla/

In his system, the type of the matrix includes includes the matrix
size and dimensions, so invalid operations like improper matrix
multiplication can be rejected statically. And yet, his library
permits matrices read from files.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New New newbie question/help

2007-06-27 Thread Paul Hudak




Hi Balu.  It looks like you've gotten some excellent advice from
others, but permit me to add a further comment regarding the broader
context, now that I've had a chance to look a little closer.

It looks like you're trying to solve the "fractal snowflake" exercise. 
One of the challenges in programming with numbers is deciding what
representation to use.  Ints are great because they are efficient, but
if you need to use trigonometric functions such as sine, etc. then you
need Floats or Doubles.  The problem here is that you need both -- you
need Ints because polygon is defined in terms of pixels, which are
represented as Ints, and you need Floats because you need to compute
the coordinates of an equilateral triangle, which (interestingly) can't
be represented using integer coordinates.  But also, in the case of the
snowflake fractal, you will need to scale the size as you recurse.  The
reason that the latter is important is that it implies that the
arguments to equilateralTri should perhaps be floats -- otherwise you
will once again run into numeric conversion problems as you try to
scale the arguments (unless you always start with a pixel size that is
a multiple of six).

So -- I would still suggest using Window -> Float -> Float ->
Float -> IO() as the type for equilateralTri.  It's only when you
make the call to polygon that you need Ints.  And there you can just
use "round" to convert the Floats to Ints.

As an aside, looking at your code a bit closer, I see this:

    (polygon [(x,y),(a,b),(x,y)]))
    where
    b = y + side * sin(pi/3)
    a = x + side * cos(pi/3) 

Something is not right here -- you repeat (x,y) as a vertex.  Probably
the third vertex should be (x+side,y).  Also, note that sin (pi/3) and
cos (pi/3) are constants (namely 0.866... and 0.5, resp.).

I hope this helps,

    -Paul


Balu Raman wrote:
I am for ever obliged to this haskell community. Who would
have thought that Prof.Hudak would reply instantly, from on-the-road. I
am reading his SOE. Thanks so much.
  
I went with peterv's response after trying so many things. 
I tried to change to : equilateralTri Window -> Float -> Float
-> Float -> IO()
which bombed because polygon wants list of integer-pairs.
  
I read the definitions of fromIntegral and round and they are defined
as :
  
fromIntegral :: (Num b, Integral a) => a -> b
round :: (RealFrac a, Integral b) => a->b
Is it proper/ok to defines them as :
fromIntegral :: (a::Integral) -> (b::Num)
and
round :: (a::RealFrac) -> (b::Integral)  ?
  
Is RealFrac is-a Num ?
Does the order matters in (Num b,Integral a) => a -> b or
   (Integral a,Num b) => a
-> b
  
With your encouragements, I'll keep pluuging. Thanks.
  
- br
  
  On 6/27/07, peterv <[EMAIL PROTECTED]>
wrote:
  I'm
also a haskell newbie, but I'll try to help; the experts here will
correct me if I'm wrong.

The compiler cannot in all cases infer the type of a number. pi can be a
Float, a Double, or even a complex number.


Furthermore unlike in C/C++ you cannot just mix integer and floating
operations.

For example, the following works for me:

f :: Int -> Int
f side = round ( (fromIntegral side) * sin ( (pi::Float) / 3 ) )


or easier

f side = round ( (fromIntegral side) * sin (pi / 3.0) )

I'm sure the experts here will have a better solution.

Peter
-Original Message-
From: 
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
On Behalf Of Balu Raman
Sent: Wednesday, June 27, 2007 1:25 PM
To: 
Haskell-Cafe@haskell.org
Subject: [Haskell-cafe] New New newbie question/help

Hi,
Hope someone can help me, just starting out with SOE.My code :
module Main where
import Graphics.SOE.Gtk

spaceClose :: WIndow -> IO()

spaceClose w = do k <- getKey w
   if k == ' ' then closeWindow w
   else spaceClose w

equilateralTri :: Window -> Int -> Int -> Int -> IO()

equilateralTri w x y side
   = drawInWindow w (withColor Red
   (polygon
[(x,y),(a,b),(x,y)]))
   where
b = y + side * sin(pi/3)
a = x + side * cos(pi/3)
main =
   runGraphics(
  do w <- openWindow "Equilateral
Triangle" (400,400)

equilateralTri w 50 300 200
spaceClose w
)

all of the above in file triangle.hs
when I do a :l triangle.h in ghci,  I get the following error
triangle.hs:17:36:
No instance for (Floating Int)
 arising from use of 'pi' at triangle.hs:17:36-37
Probable fix: add an instance declaration for (Floating Int)

In the first argument of '(/)', namely 'pi'
In the first argument of 'cos', namely '(pi / 3)'
In

[Haskell-cafe] Yet another implementation of cond

2007-06-27 Thread Jon Cast
I discovered this trick the other day, and didn't remember seeing it anywhere 
as a cond implementation:

head $
  [ e1 | cond1 ] ++
  [ e2 | cond2 ] ++
  [ e3 | cond3 ]

etc.

You can even use full pattern guards (more powerful than GHC's) in your 
conditions!

Jonathan Cast
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Status of MIME Strike Force

2007-06-27 Thread Tony Finch
On Wed, 27 Jun 2007, Jeremy Shaw wrote:
>
> Currently I am difficulty dealing with headers that could appear more
> than once.

I recommend that you treat the header fields as an ordered list. Do not
use the latitude that the specification gives you to re-order headers, and
do not assume that messages you have to process will be within the minimum
and maximum count requirements for each field. (This rules out encoding
those requirements in the type system.) Postmasters will hate your
software if you do either of these things :-)

You need to support appending new fields to the top as well as the bottom
of the header. Although it's traditional in most situations to add a new
field to the bottom of the header, Received: fields must be added to the
start. For any application that does message processing on an MTA, it's a
*really* good idea to add new fields to the top of the header, so that
they appear interspersed amongst the Received: lines in a way that
indicates where and when the processing happened. Doing this also means
your program will play nicely with DKIM. Ignore the strict syntax in RFC
2822 that prevents arbitrary trace header fields: this is a bug that will
be fixed in the next version of the spec, and in practice software doesn't
mind unexpected trace fields.

Tony.
-- 
f.a.n.finch  <[EMAIL PROTECTED]>  http://dotat.at/
FAIR ISLE FAEROES: VARIABLE 3 OR 4, BUT NORTHERLY 5 OR 6 IN WEST FAEROES.
MODERATE OR ROUGH. RAIN OR SHOWERS. MODERATE OR GOOD.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Jon Cast
On Wednesday 27 June 2007, Andrew Coppin wrote:
> Stefan O'Rear wrote:
> > On Wed, Jun 27, 2007 at 09:46:41PM +0100, Andrew Coppin wrote:
> >> I have a tricky little question...
> >>
> >> Suppose I write a function like this:
> >>
> >>  foo pattern1
> >>
> >>| gard1 = ...
> >>| gard2 = ...
> >>
> >>  foo pattern2
> >>
> >>| gard3 = ...
> >>| gard4 = ...
> >>
> >> According to one tutorial I read, if pattern1 matches, pattern2 will
> >> never be tried, even if both guard1 and guard2 fail.
> >>
> >> And according to another tutorial I read, if pattern1 matches but all
> >> guards fail, pattern2 *will* be tried.
> >>
> >> Can somebody comfirm which one is actually correct?
> >
> > According to http://haskell.org/onlinereport/exps.html#sect3.17.2
> >
> > Top level patterns in case expressions and the set of top level patterns
> > in function or pattern bindings may have zero or more associated guards.
> > A guard is a boolean expression that is evaluated only after   all of
> > the arguments have been successfully matched, and it must be true for
> > the overall pattern match to succeed. The environment of the guard is
> > the same as the right-hand-side of the case-expression
> > alternative, function definition, or pattern binding to which it is
> > attached.
> >
> > So, if guard1 and guard2 both fail, then pattern1 doesn't match (and
> > pattern matching continues).  As such, your "corner case" cannot
> > actually exist.
>
> Wow, wait a sec - case expressions are allowed to have guards too??

Yes.  I guess I assumed you knew that, sorry.

The only syntactic (or semantic) difference between function equations and 
case expressions (aside from the fact that case expressions require you to 
tuple up the values you're pattern-matching on) is the fact that case 
expressions use -> where function bindings use =.  Other than that, the two 
forms are exactly equivalent.

Sincerely,
Jonathan Cast
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Stefan O'Rear
On Wed, Jun 27, 2007 at 10:28:05PM +0100, Andrew Coppin wrote:
> Stefan O'Rear wrote:
> >On Wed, Jun 27, 2007 at 09:46:41PM +0100, Andrew Coppin wrote:
> >  
> >>I have a tricky little question...
> >>
> >>Suppose I write a function like this:
> >>
> >> foo pattern1
> >>   | gard1 = ...
> >>   | gard2 = ...
> >> foo pattern2
> >>   | gard3 = ...
> >>   | gard4 = ...
> >>
> >>According to one tutorial I read, if pattern1 matches, pattern2 will 
> >>never be tried, even if both guard1 and guard2 fail.
> >>
> >>And according to another tutorial I read, if pattern1 matches but all 
> >>guards fail, pattern2 *will* be tried.
> >>
> >>Can somebody comfirm which one is actually correct?
> >>
> >
> >According to http://haskell.org/onlinereport/exps.html#sect3.17.2
> >
> >Top level patterns in case expressions and the set of top level patterns
> >in function or pattern bindings may have zero or more associated guards.
> >A guard is a boolean expression that is evaluated only after   all of
> >the arguments have been successfully matched, and it must be true for
> >the overall pattern match to succeed. The environment of the guard is
> >the same as the right-hand-side of the case-expression
> >alternative, function definition, or pattern binding to which it is
> >attached.
> >
> >So, if guard1 and guard2 both fail, then pattern1 doesn't match (and
> >pattern matching continues).  As such, your "corner case" cannot
> >actually exist.
> >  
> 
> Wow, wait a sec - case expressions are allowed to have guards too??

[EMAIL PROTECTED]:~$ ghci
Loading package base ... linking ... done.
   ___ ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |GHC Interactive, version 6.7.20070612, for Haskell 98.
/ /_\\/ __  / /___| |http://www.haskell.org/ghc/
\/\/ /_/\/|_|Type :? for help.

Prelude> case () of { () | True -> "x" }
"x"
Prelude> 

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


Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Andrew Coppin

Stefan O'Rear wrote:

On Wed, Jun 27, 2007 at 09:46:41PM +0100, Andrew Coppin wrote:
  

I have a tricky little question...

Suppose I write a function like this:

 foo pattern1
   | gard1 = ...
   | gard2 = ...
 foo pattern2
   | gard3 = ...
   | gard4 = ...

According to one tutorial I read, if pattern1 matches, pattern2 will 
never be tried, even if both guard1 and guard2 fail.


And according to another tutorial I read, if pattern1 matches but all 
guards fail, pattern2 *will* be tried.


Can somebody comfirm which one is actually correct?



According to http://haskell.org/onlinereport/exps.html#sect3.17.2

Top level patterns in case expressions and the set of top level patterns
in function or pattern bindings may have zero or more associated guards.
A guard is a boolean expression that is evaluated only after   all of
the arguments have been successfully matched, and it must be true for
the overall pattern match to succeed. The environment of the guard is
the same as the right-hand-side of the case-expression
alternative, function definition, or pattern binding to which it is
attached.

So, if guard1 and guard2 both fail, then pattern1 doesn't match (and
pattern matching continues).  As such, your "corner case" cannot
actually exist.
  


Wow, wait a sec - case expressions are allowed to have guards too??

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


Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Jon Cast
On Wednesday 27 June 2007, Andrew Coppin wrote:
> I have a tricky little question...
>
> Suppose I write a function like this:
>
>   foo pattern1
>
> | gard1 = ...
> | gard2 = ...
>
>   foo pattern2
>
> | gard3 = ...
> | gard4 = ...
>
> According to one tutorial I read, if pattern1 matches, pattern2 will
> never be tried, even if both guard1 and guard2 fail.
>
> And according to another tutorial I read, if pattern1 matches but all
> guards fail, pattern2 *will* be tried.
>
> Can somebody comfirm which one is actually correct?

You could just try it, you know . . .

Anyway, the second tutorial is correct: if all guards on pattern1 fail, 
pattern2 will be tried next.  See Section 3.17.3 in the Haskell Report [1].

Btw., which was the first tutorial?

Sincerely,
Jonathan Cast
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs

[1] http://haskell.org/onlinereport/exps.html#case-semantics
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Stefan O'Rear
On Wed, Jun 27, 2007 at 09:46:41PM +0100, Andrew Coppin wrote:
> I have a tricky little question...
> 
> Suppose I write a function like this:
> 
>  foo pattern1
>| gard1 = ...
>| gard2 = ...
>  foo pattern2
>| gard3 = ...
>| gard4 = ...
> 
> According to one tutorial I read, if pattern1 matches, pattern2 will 
> never be tried, even if both guard1 and guard2 fail.
> 
> And according to another tutorial I read, if pattern1 matches but all 
> guards fail, pattern2 *will* be tried.
> 
> Can somebody comfirm which one is actually correct?

According to http://haskell.org/onlinereport/exps.html#sect3.17.2

Top level patterns in case expressions and the set of top level patterns
in function or pattern bindings may have zero or more associated guards.
A guard is a boolean expression that is evaluated only after   all of
the arguments have been successfully matched, and it must be true for
the overall pattern match to succeed. The environment of the guard is
the same as the right-hand-side of the case-expression
alternative, function definition, or pattern binding to which it is
attached.

So, if guard1 and guard2 both fail, then pattern1 doesn't match (and
pattern matching continues).  As such, your "corner case" cannot
actually exist.

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


[Haskell-cafe] Language semantics

2007-06-27 Thread Andrew Coppin

I have a tricky little question...

Suppose I write a function like this:

 foo pattern1
   | gard1 = ...
   | gard2 = ...
 foo pattern2
   | gard3 = ...
   | gard4 = ...

According to one tutorial I read, if pattern1 matches, pattern2 will 
never be tried, even if both guard1 and guard2 fail.


And according to another tutorial I read, if pattern1 matches but all 
guards fail, pattern2 *will* be tried.


Can somebody comfirm which one is actually correct?

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


Re: [Haskell-cafe] Re: Reinvention

2007-06-27 Thread Tillmann Rendel

Andrew Coppin wrote:
But IIRC the Parsec library supports parsing of arbitrary tokens 
(although presumably they have to be in Eq?) so maybe I should revise 
that...


They don't have be in Eq, because you supply your own token tests, using 
the token or tokenPrim functions.


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


Re: [Haskell-cafe] Status of MIME Strike Force

2007-06-27 Thread Jeremy Shaw
At Wed, 27 Jun 2007 21:14:02 +0200,
Marc Weber wrote:
> 
> > > exampleHeaders2 :: [RawHeader]
> > > exampleHeaders2 =
> > >((Subject "whee") .+. 
> > > (Subject "bork") .+.
> > > (Keywords ["baz", "bar", "bam"]) .*.
> > > (Keywords ["zip", "zap", "zop"]) .*.
> > > empty
> > >)
> > [...] 
> > But, it is also really wonky because the operator has a bit of a
> > postfix feel to it. For example, it is the .*. at the end of this line
> > that is making it use addHeader. 
> 
> So why not use flip on each operator to get
>  empty .*. (Subject "blah") .+.  ... ?
> 
> That might be a little bit more comfortable ?

Ah, good idea. I'll play with that. Thanks!

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


Re: [Haskell-cafe] Re: Reinvention

2007-06-27 Thread Andrew Coppin

J. Garrett Morris wrote:

More generally, that's unfoldr:

Prelude> :t Data.List.unfoldr
Data.List.unfoldr :: (b -> Maybe (a, b)) -> b -> [a]

unfoldr represents the end of the unfold explicitly (using Nothing)
instead of implicitly (using the empty list).


Duh... of course it does. :-S

Silly thing is, I use unfoldr all the time - for converting integers to 
bits. *sigh*


Of course, that solves the problem of just wanting to chop the input 
into chunks. It works less well if you want to do complicated recursive 
stuff. But IIRC the Parsec library supports parsing of arbitrary tokens 
(although presumably they have to be in Eq?) so maybe I should revise 
that...


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


Re: [Haskell-cafe] Re: Reinvention

2007-06-27 Thread J. Garrett Morris

More generally, that's unfoldr:

Prelude> :t Data.List.unfoldr
Data.List.unfoldr :: (b -> Maybe (a, b)) -> b -> [a]

unfoldr represents the end of the unfold explicitly (using Nothing)
instead of implicitly (using the empty list).

/g

On 27 Jun 2007 20:26:56 +0100, Jon Fairbairn <[EMAIL PROTECTED]> wrote:

Andrew Coppin <[EMAIL PROTECTED]> writes:

> I seem to be forever writing code that looks like this:
>
> decode :: String -> (SKI,String)
> decode (c:cs) = case c of
>   'S' -> (S,cs)
>   'K' -> (K,cs)
>   'I' -> (I,cs)
>   '*' -> let (e0,cs0) = decode cs; (e1,cs1) = decode cs1 in (e0 :@: e1, cs1)

This looks like parsing to me.

--
Jón Fairbairn [EMAIL PROTECTED]

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




--
The man who'd introduced them didn't much like either of them, though
he acted as if he did, anxious as he was to preserve good relations at
all times. One never knew, after all, now did one now did one now did
one.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Reinvention

2007-06-27 Thread Jon Fairbairn
Andrew Coppin <[EMAIL PROTECTED]> writes:

> I seem to be forever writing code that looks like this:
> 
> decode :: String -> (SKI,String)
> decode (c:cs) = case c of
>   'S' -> (S,cs)
>   'K' -> (K,cs)
>   'I' -> (I,cs)
>   '*' -> let (e0,cs0) = decode cs; (e1,cs1) = decode cs1 in (e0 :@: e1, cs1)

This looks like parsing to me.

-- 
Jón Fairbairn [EMAIL PROTECTED]

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


Re: [Haskell-cafe] Status of MIME Strike Force

2007-06-27 Thread Marc Weber
> > exampleHeaders2 :: [RawHeader]
> > exampleHeaders2 =
> >((Subject "whee") .+. 
> > (Subject "bork") .+.
> > (Keywords ["baz", "bar", "bam"]) .*.
> > (Keywords ["zip", "zap", "zop"]) .*.
> > empty
> >)
> [...] 
> But, it is also really wonky because the operator has a bit of a
> postfix feel to it. For example, it is the .*. at the end of this line
> that is making it use addHeader. 

So why not use flip on each operator to get
 empty .*. (Subject "blah") .+.  ... ?

That might be a little bit more comfortable ?

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


Re: [Haskell-cafe] Tools for Haskell and COM

2007-06-27 Thread Andrew Coppin

J. Garrett Morris wrote:

Microsoft's Component Object Model.

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


...still left feeling unenlightened.

On the other hand, this is the *Haskell* mailing list, so...

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


[Haskell-cafe] Reinvention

2007-06-27 Thread Andrew Coppin

I seem to be forever writing code that looks like this:

decode :: String -> (SKI,String)
decode (c:cs) = case c of
 'S' -> (S,cs)
 'K' -> (K,cs)
 'I' -> (I,cs)
 '*' -> let (e0,cs0) = decode cs; (e1,cs1) = decode cs1 in (e0 :@: e1, cs1)

In other words, lots and lots of functions with signatures like

 foo :: [Foo] -> (Bar,[Foo])

that likes to call itself recursively, or that gets called from 
somewhere else.


Is there a Better Way(tm) to do this? It looks like such a common idiom 
that you'd expect to see "something" in the libraries somewhere.


(I remember being puzzled that there was no library function for 
creating a Cartesian product of two lists. Puzzled until I realised that 
the monadic nature of lists make it utterly trivial to do this by hand 
anyway! So it's not always obvious to know what you're looking for...)


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


Re: [Haskell-cafe] Tools for Haskell and COM

2007-06-27 Thread J. Garrett Morris

Microsoft's Component Object Model.

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

/g

On 6/27/07, Andrew Coppin <[EMAIL PROTECTED]> wrote:

Simon Peyton-Jones wrote:
>
> The biggest Haskell/COM project I know of was Krasimir's
> implementation of Visual Haskell, which was a plug-in for Visual
> Studio. The VS interfaces are COM ones, so he had to do lots of COM
> stuff. He may be able to help you. Sigbjorn Finne knows a lot about
> HDirect, but he's really busy with his day job at Galois!
>
> There's a bit of a chicken-and-egg problem here; the COM tools are not
> well maintained, so that discourages use, which in turn makes it less
> rewarding to work on them. What I don't know is the level of
> suppressed demand: if there were good tools, would lots of people
> start using them?
>
>
> Simon
>

Is now a bad time to say "what is COM?"?

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




--
The man who'd introduced them didn't much like either of them, though
he acted as if he did, anxious as he was to preserve good relations at
all times. One never knew, after all, now did one now did one now did
one.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Tools for Haskell and COM

2007-06-27 Thread Andrew Coppin

Simon Peyton-Jones wrote:


The biggest Haskell/COM project I know of was Krasimir’s 
implementation of Visual Haskell, which was a plug-in for Visual 
Studio. The VS interfaces are COM ones, so he had to do lots of COM 
stuff. He may be able to help you. Sigbjorn Finne knows a lot about 
HDirect, but he’s really busy with his day job at Galois!


There’s a bit of a chicken-and-egg problem here; the COM tools are not 
well maintained, so that discourages use, which in turn makes it less 
rewarding to work on them. What I don’t know is the level of 
suppressed demand: if there were good tools, would lots of people 
start using them?



Simon



Is now a bad time to say "what is COM?"?

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


Re: [Haskell-cafe] Status of MIME Strike Force

2007-06-27 Thread Jeremy Shaw
At Wed, 27 Jun 2007 18:54:58 +0200 (CEST),
Arie Peterson wrote:

> What is the status of the MIME Strike Force?
> 
> The goals proposed at
> 
> promise a very useful library. Has the design been initiated?

Currently it is on hold while I work on some other higher priority
projects. But, I do hope to get back to it soon. (Or, perhaps someone
else will have time to work on it).

It seems to me that the mime-string package is very close to what we
need for parsing MIME messages. If all you care about is parsing MIME
messages, I highly recommend it.

This leaves the problem of creating and transforming MIME
messages. The real difficulty in this area is creating a good API. If
you want to take a peek at what I have, take a look at:

http://www.n-heptane.com/nhlab/repos/haskell-mime/APIs.hs

Currently I am difficulty dealing with headers that could appear more
than once.

For example, the 'Keywords' header can appear multiple times. So,
there are two cases to handle:

 1. add an additional Keywords header
 2. deleted any existing Keywords headers and add the new one

Other fields, such as 'Subject', can appear only once.

One way to express a filter that modifies an existing message is the
following:

> exampleHeaders =
>( (setHeader (Subject "whee")) .
>  (setHeader (Subject "bork")).
>  (addHeader (Keywords ["baz", "bar", "bam"])) .
>  (addHeader (Keywords ["zip", "zap", "zop"]))
>)

where setHeader ensures that a header only appears once, and addHeader
appends the header, leaving existing instances alone. The type system
ensures that you can never call addHeader on (Subject
"whee"). Unfortunately, that code seems a bit verbose.

we can make some helper functions that reduce the verbosity a bit,

> subject = setHeader . Subject
> keywords = addHeader . Keywords

> exampleHeaders3 :: [RawHeader] -> [RawHeader]
> exampleHeaders3 =
>((subject "whee") .
> (subject "bork") .
> (keywords ["baz", "bar", "bam"]) .
> (keywords ["zip", "zap", "zop"]))

That is nice, except that we don't know which headers are going to use
setHeader and which are doing to use addHeader. So, the results might
be a bit suprising. Additionally, keywords always uses addHeader, but
in some cases we might want it to use setHeader.

Another option is to trying to use infix operators, such as:

(.+.) for setHeader 
(.*.) for addHeader

> exampleHeaders2 :: [RawHeader]
> exampleHeaders2 =
>((Subject "whee") .+. 
> (Subject "bork") .+.
> (Keywords ["baz", "bar", "bam"]) .*.
> (Keywords ["zip", "zap", "zop"]) .*.
> empty
>)

This is good because:

 1. is it shorter than the first example that used setHeader/addHeader

 2. the information about whether setHeader/addHeader is being used is
preserved.

 3. it is easy to choose which one you want (setHeader/addHeader)

But, it is also really wonky because the operator has a bit of a
postfix feel to it. For example, it is the .*. at the end of this line
that is making it use addHeader. 

> (Keywords ["baz", "bar", "bam"]) .*.

If we wanted to use setHeader here, we would have to change it to:

> (Keywords ["baz", "bar", "bam"]) .+.

This behaviour seems pretty unintutive.

A whole other area I have not dealt with yet is data-mining and
filters that depend on the values of existing fields. For example:

 1. find all the headers that contain the string XXX
 2. find all the Keywords fields and merge them into a single Keywords field

So, that is where I currently am. Once the API is worked out, I think
things should progress pretty easily. If you have any ideas, let me
know. I think I may be picking this up again in September or October.

HaXml, SYB, Uniplate, and HList seem like good places to get some ideas. If
anyone has suggestions for other projects to look at, let me know.

j.

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


Re: [Haskell-cafe] A Query Language for Haskell Terms

2007-06-27 Thread Alex Jacobson

Titto,

The usual tradeoff is between efficiency and queryability.  It is really 
easy to optimize graph traversal.  It is really hard to get performance 
out of the Logic model.  The traditional sweet spot has been the 
relational model, but it breaks down at very large scale.  A lot of very 
large scale web sites implement some form of relational database 
sharding which basically means partitioning the database and doing a bit 
of graph traversal to decide on the database and then relational within 
that database and then merging the results.


-Alex-

Pasqualino 'Titto' Assini wrote:

On Wednesday 27 June 2007 09:32:16 Alex Jacobson wrote:
  

Titto,

Have you looked at HAppS.DBMS.IxSet?  Right now it provides a generic
way to query indexed sets.

If you want to take a shot at making the queries serializable, I don't
think it would be that difficult (but I have not tried so YMMV).



Hi Alex, thanks for remininding me about that. It is a very nice back-end and 
as you say, it should not be too hard to design a SQL-like query language  on 
top of it. 



I am still wondering, however, what meta-model is more appropriate to 
represent the info hold in a Web app.


Unfortunately there seem to be at least 3 different ones (without considering 
mixed approaches like F-Logic):
 


1) Graph

This is really the native Haskell way of representing information: the model 
is defined using classes or data types and types are connected by direct 
uni-directional links.


So for example the Sale/Item model (from the HAppS DBMS Examples) might be 
written like:


data Item = Item {stock::Int,description::String,price::Cents}  
deriving (Ord,Eq,Read,Show)


data Sale = Sale {date::CalendarTime
 ,soldItem::Item -- NOTE: 
uni-directional link to Item
 ,qty::Int
 ,salePrice::Cents} 
deriving (Ord,Eq,Read,Show)


or in more abstract form using classes:

class Item i where
 description :: i -> String
 price :: i -> Cents

class Sale s where
 soldItem :: Item i => s -> i

This is also very much the Web-way: information is a graph of resource linked 
via uni-directional links.


Information is queried by path traversal (REST-style):

Assuming that the root "/" represents the collection of all sales then:

HTTP GET /elemAt[2345]/soldItem/description.json 

might return the JSON representation of the description of the item sold as 
part of sale 2345.



2) Relational

Information is represented as tables, that can be joined up via keys, as 
implemented  in HAppS DBMS or in any relational database.


The model becomes:

data Item = Item {itemId::Id  -- NOTE: primary key 
 ,stock::Int,description::String,price::Cents} 
deriving (Ord,Eq,Read,Show)


data Sale = Sale {date::CalendarTime,
  soldItemId::Id -- NOTE: foreign key 
  ,qty::Int,salePrice::Cents} 
deriving (Ord,Eq,Read,Show)


Plus the appropriate indexes definitions.

Information can be queried via a SQL-like language.


3) Logic

This is the "Semantic Web" way: information is broken down into assertions, 
that in their simplest form are just triples: subject predicate object, the 
model then becomes something like:


Item hasDescription String
Item hasPrice Cents
Sale hasItem Item

It can be populated piecemeal with assertions like:

item0 hasDescription "indesit cooker 34BA"
item0 hasPrice 3.5
Sale0 hasSoldItem item0

It can be queried using a logic-oriented query language (e.g SPARQL):
sale2345 hasItem ?item
?item hasDescription ?description



Moving from Graph to Relational to Logic the meta-model becomes simpler and 
more flexible. The flip-side is that the model (and the queries) become more 
verbose.  It is not clear where is the sweet spot.
 

What people think?  



Best,

titto








  


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


[Haskell-cafe] HDBC and Sqlite3: SqlValue is restricted to SqlString

2007-06-27 Thread Malte Milatz
It's always good to know there's a general Haskell mailing list to ask
questions.  I'm experimenting with the HDBC package in combination with
Sqlite3. 

Here's my example table:

sqlite> .schema foos
CREATE TABLE foos (id integer primary key, flag bool,
comment text);

sqlite> select * from foos;
id  flagcomment   
--  --  --
1   0   a 
2   1   b 

Here's my query in ghci:

Database.HDBC> quickQuery conn "select * from foos;" []
[[SqlString "1",SqlString "0",SqlString "a"],
[SqlString "2",SqlString "1",SqlString "b"]]

What strikes me is that all values are represented as SqlStrings,
although the type SqlValue would allow something more succint, e.g.
SqlBool for the flag column.  Is this a general limitation of the Sqlite
backend, or is this by design (Sqlite seems to do typing differently
than I had expected), or is it just that nobody has implemented a better
behavior yet?

Curiously, Malte

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


[Haskell-cafe] Status of MIME Strike Force

2007-06-27 Thread Arie Peterson
Hi,


What is the status of the MIME Strike Force?

The goals proposed at

promise a very useful library. Has the design been initiated?


Kind regards,

Arie

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


RE: [Haskell-cafe] New New newbie question/help

2007-06-27 Thread peterv
Newbie helping newbie, cool J And indeed, this is an amazing mailing list!

 

Personally, I prefer to read fromIntegral :: (Num b, Integral a) => a -> b
like

 

IF (b is a Num) AND (a is an Integral) THEN (fromIntegral is defined and is
a function from a to b)

 

This way it resembles the mathematical symbol for implication (=>)

 

PS: Haskells "generic number system" can be very confusing for the beginner,
but it becomes very cool when you start working with type classes. You will
see that in the later chapters of  the great SOE book (animation and
reactive behaviors). The reactive behavior chapter is really hard, but don't
give up. In my case I got a real revelation, finally understanding the real
power of streams and lazy evaluation; it really changes the way you look at
the "world". As a videogames developer, I still have a lot of unanswered
questions though (for example, how to efficiently handle events between
behaviors, like collision, but I hope to find that in Yampa or newer work)

 

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Balu Raman
Sent: Wednesday, June 27, 2007 5:37 PM
To: Haskell-Cafe@haskell.org
Subject: Re: [Haskell-cafe] New New newbie question/help

 

I am for ever obliged to this haskell community. Who would have thought that
Prof.Hudak would reply instantly, from on-the-road. I am reading his SOE.
Thanks so much.

I went with peterv's response after trying so many things. 
I tried to change to : equilateralTri Window -> Float -> Float -> Float ->
IO()
which bombed because polygon wants list of integer-pairs.

I read the definitions of fromIntegral and round and they are defined as : 
fromIntegral :: (Num b, Integral a) => a -> b
round :: (RealFrac a, Integral b) => a->b
Is it proper/ok to defines them as :
fromIntegral :: (a::Integral) -> (b::Num)
and
round :: (a::RealFrac) -> (b::Integral)  ? 
Is RealFrac is-a Num ?
Does the order matters in (Num b,Integral a) => a -> b or
   (Integral a,Num b) => a -> b

With your encouragements, I'll keep pluuging. Thanks. 
- br

On 6/27/07, peterv <[EMAIL PROTECTED]> wrote:

I'm also a haskell newbie, but I'll try to help; the experts here will
correct me if I'm wrong.

The compiler cannot in all cases infer the type of a number. pi can be a
Float, a Double, or even a complex number. 

Furthermore unlike in C/C++ you cannot just mix integer and floating
operations.

For example, the following works for me:

f :: Int -> Int
f side = round ( (fromIntegral side) * sin ( (pi::Float) / 3 ) ) 

or easier

f side = round ( (fromIntegral side) * sin (pi / 3.0) )

I'm sure the experts here will have a better solution.

Peter
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Balu Raman
Sent: Wednesday, June 27, 2007 1:25 PM
To: Haskell-Cafe@haskell.org
Subject: [Haskell-cafe] New New newbie question/help

Hi,
Hope someone can help me, just starting out with SOE.My code :
module Main where
import Graphics.SOE.Gtk

spaceClose :: WIndow -> IO() 
spaceClose w = do k <- getKey w
   if k == ' ' then closeWindow w
   else spaceClose w

equilateralTri :: Window -> Int -> Int -> Int -> IO() 
equilateralTri w x y side
   = drawInWindow w (withColor Red
   (polygon
[(x,y),(a,b),(x,y)]))
   where
b = y + side * sin(pi/3)
a = x + side * cos(pi/3)
main =
   runGraphics(
  do w <- openWindow "Equilateral
Triangle" (400,400) 
equilateralTri w 50 300 200
spaceClose w
)

all of the above in file triangle.hs
when I do a :l triangle.h in ghci,  I get the following error
triangle.hs:17:36:
No instance for (Floating Int)
 arising from use of 'pi' at triangle.hs:17:36-37
Probable fix: add an instance declaration for (Floating Int) 
In the first argument of '(/)', namely 'pi'
In the first argument of 'cos', namely '(pi / 3)'
In the second argument of '(*)', namely 'cos (pi/3)' 
Failed, modules loaded: none

Can someone help me what's going on to a brand new newbie. All I can
figure out is that some type mismatch between float and int . I tried
various
combinations of lets and wheres and I still get the same complaints. 
I am just linearly studying SOE
Thanks,
- br
___
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: Tree Guidance

2007-06-27 Thread Hans van Thiel
[snip]

Thanks, Apfelmus, for the references. Guess I'll start there, then. And
thanks, Chris, for the info and code. Read only 'up pointers' could be
what is needed. But before going on, I want first to get more
confortable with programming with trees. It's all very well to say
they're easy to roll, but lists are even simpler, and look at them...

Regards,

Hans

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


Re: [Haskell-cafe] New New newbie question/help

2007-06-27 Thread Brent Yorgey

Is it proper/ok to defines them as :
fromIntegral :: (a::Integral) -> (b::Num)
and
round :: (a::RealFrac) -> (b::Integral)  ?



No; Integral, Num and RealFrac are type classes, not types.  Think of a type
class as a "set of types" which all support certain operations.  For
example, anything in the Num class must implement +, -, *, and a few other
things.  So a type signature like (Integral a) => a means "any type a, as
long as it is in the type class Integral".

Is RealFrac is-a Num ?


Yes, any type which is in the RealFrac type class must also be in the Num
type class.

Does the order matters in (Num b,Integral a) => a -> b or

   (Integral a,Num b) => a -> b



No, the order of type class constraints doesn't matter.

With your encouragements, I'll keep pluuging. Thanks.


Good luck!
-Brent
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New New newbie question/help

2007-06-27 Thread Balu Raman

I am for ever obliged to this haskell community. Who would have thought that
Prof.Hudak would reply instantly, from on-the-road. I am reading his SOE.
Thanks so much.

I went with peterv's response after trying so many things.
I tried to change to : equilateralTri Window -> Float -> Float -> Float ->
IO()
which bombed because polygon wants list of integer-pairs.

I read the definitions of fromIntegral and round and they are defined as :
fromIntegral :: (Num b, Integral a) => a -> b
round :: (RealFrac a, Integral b) => a->b
Is it proper/ok to defines them as :
fromIntegral :: (a::Integral) -> (b::Num)
and
round :: (a::RealFrac) -> (b::Integral)  ?
Is RealFrac is-a Num ?
Does the order matters in (Num b,Integral a) => a -> b or
  (Integral a,Num b) => a -> b

With your encouragements, I'll keep pluuging. Thanks.
- br

On 6/27/07, peterv <[EMAIL PROTECTED]> wrote:


I'm also a haskell newbie, but I'll try to help; the experts here will
correct me if I'm wrong.

The compiler cannot in all cases infer the type of a number. pi can be a
Float, a Double, or even a complex number.

Furthermore unlike in C/C++ you cannot just mix integer and floating
operations.

For example, the following works for me:

f :: Int -> Int
f side = round ( (fromIntegral side) * sin ( (pi::Float) / 3 ) )

or easier

f side = round ( (fromIntegral side) * sin (pi / 3.0) )

I'm sure the experts here will have a better solution.

Peter
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Balu Raman
Sent: Wednesday, June 27, 2007 1:25 PM
To: Haskell-Cafe@haskell.org
Subject: [Haskell-cafe] New New newbie question/help

Hi,
Hope someone can help me, just starting out with SOE.My code :
module Main where
import Graphics.SOE.Gtk

spaceClose :: WIndow -> IO()
spaceClose w = do k <- getKey w
   if k == ' ' then closeWindow w
   else spaceClose w

equilateralTri :: Window -> Int -> Int -> Int -> IO()
equilateralTri w x y side
   = drawInWindow w (withColor Red
   (polygon
[(x,y),(a,b),(x,y)]))
   where
b = y + side * sin(pi/3)
a = x + side * cos(pi/3)
main =
   runGraphics(
  do w <- openWindow "Equilateral
Triangle" (400,400)
equilateralTri w 50 300 200
spaceClose w
)

all of the above in file triangle.hs
when I do a :l triangle.h in ghci,  I get the following error
triangle.hs:17:36:
No instance for (Floating Int)
 arising from use of 'pi' at triangle.hs:17:36-37
Probable fix: add an instance declaration for (Floating Int)
In the first argument of '(/)', namely 'pi'
In the first argument of 'cos', namely '(pi / 3)'
In the second argument of '(*)', namely 'cos (pi/3)'
Failed, modules loaded: none

Can someone help me what's going on to a brand new newbie. All I can
figure out is that some type mismatch between float and int . I tried
various
combinations of lets and wheres and I still get the same complaints.
I am just linearly studying SOE
Thanks,
- br
___
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] update on SoC projects?

2007-06-27 Thread Malcolm Wallace
brad clawsie <[EMAIL PROTECTED]> wrote:

> does anyone have any interesting update info on the haskell SoC
> (summer of code) projects? in particular i am intersted in the haskell
> bindings to libcurl

There are now "status report" pages/links for each project listed at
http://hackage.haskell.org/trac/summer-of-code/
and I would encourage students and mentors to write something in them!
It is good to keep the wider community involved and informed about what
the SoC'ers are doing.

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


RE: [Haskell-cafe] New New newbie question/help

2007-06-27 Thread peterv
I'm also a haskell newbie, but I'll try to help; the experts here will
correct me if I'm wrong.

The compiler cannot in all cases infer the type of a number. pi can be a
Float, a Double, or even a complex number. 

Furthermore unlike in C/C++ you cannot just mix integer and floating
operations.

For example, the following works for me:

f :: Int -> Int
f side = round ( (fromIntegral side) * sin ( (pi::Float) / 3 ) )

or easier

f side = round ( (fromIntegral side) * sin (pi / 3.0) )

I'm sure the experts here will have a better solution.

Peter
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Balu Raman
Sent: Wednesday, June 27, 2007 1:25 PM
To: Haskell-Cafe@haskell.org
Subject: [Haskell-cafe] New New newbie question/help

Hi,
Hope someone can help me, just starting out with SOE.My code :
module Main where
import Graphics.SOE.Gtk

spaceClose :: WIndow -> IO()
spaceClose w = do k <- getKey w
   if k == ' ' then closeWindow w
   else spaceClose w

equilateralTri :: Window -> Int -> Int -> Int -> IO()
equilateralTri w x y side
   = drawInWindow w (withColor Red
   (polygon
[(x,y),(a,b),(x,y)]))
   where
b = y + side * sin(pi/3)
a = x + side * cos(pi/3)
main =
   runGraphics(
  do w <- openWindow "Equilateral
Triangle" (400,400)
equilateralTri w 50 300 200
spaceClose w
)

all of the above in file triangle.hs
when I do a :l triangle.h in ghci,  I get the following error
triangle.hs:17:36:
No instance for (Floating Int)
 arising from use of 'pi' at triangle.hs:17:36-37
Probable fix: add an instance declaration for (Floating Int)
In the first argument of '(/)', namely 'pi'
In the first argument of 'cos', namely '(pi / 3)'
In the second argument of '(*)', namely 'cos (pi/3)'
Failed, modules loaded: none

Can someone help me what's going on to a brand new newbie. All I can
figure out is that some type mismatch between float and int . I tried
various
combinations of lets and wheres and I still get the same complaints.
I am just linearly studying SOE
Thanks,
- br
___
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] Tools for Haskell and COM

2007-06-27 Thread Krasimir Angelov

There's a bit of a chicken-and-egg problem here; the COM tools are not well
maintained, so that discourages use, which in turn  makes it less rewarding
to work on them.  What I don't know is the level of suppressed demand: if
there were good tools, would lots of people start using them?


I think it will be beneficial for many Windows user if there was a
good Haskell to COM integration. HDirect can be a real nightmare for a
large projects. The first step could be to build a new COM library
designed in more FFI addendum fashion.
I already have started the first step with:

http://darcs.haskell.org/packages/hscom/

It is far from complete of course. The second step should be to
reimplement the IDL->Haskell translator. The existing translator often
generate code that isn't type correct and even if you change the code
by hand there is still a chance to have an implementation errors which
can't be captured from the typechecker. The whole task isn't that hard
but still requires a volunteer willing to spend 2-3 months of full
time work.

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


Re: [Haskell-cafe] New New newbie question/help

2007-06-27 Thread Dougal Stanton

On 27/06/07, Paul Hudak <[EMAIL PROTECTED]> wrote:

I think that an easier solution is to just change the type of
equilateralTri to:

equilateralTri :: Window -> Float -> Float -> Float -> IO()

But I am on the road and wasn't able to actually run the code.


I don't have my copy of SOE to hand, so I didn't want to say that in
case it subverted the point of the exercise. But of course I will
defer to authority on this matter ;-)

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


Re: [Haskell-cafe] New New newbie question/help

2007-06-27 Thread Paul Hudak
I think that an easier solution is to just change the type of 
equilateralTri to:


equilateralTri :: Window -> Float -> Float -> Float -> IO()

But I am on the road and wasn't able to actually run the code.

   -Paul


Dougal Stanton wrote:

On 27/06/07, Balu Raman <[EMAIL PROTECTED]> wrote:


equilateralTri :: Window -> Int -> Int -> Int -> IO()
equilateralTri w x y side
   = drawInWindow w (withColor Red
   (polygon
[(x,y),(a,b),(x,y)]))
   where
b = y + side * sin(pi/3)
a = x + side * cos(pi/3)


Your problem lies in this section here. Let's look at the error message:


triangle.hs:17:36:
No instance for (Floating Int)
 arising from use of 'pi' at triangle.hs:17:36-37
Probable fix: add an instance declaration for (Floating Int)
In the first argument of '(/)', namely 'pi'
In the first argument of 'cos', namely '(pi / 3)'
In the second argument of '(*)', namely 'cos (pi/3)'
Failed, modules loaded: none


The problem comes from the calculations of 'a' and 'b'. The function
sin doesn't return an Int value. It returns types within the type
class Floating (annotated as below, for some unspecified 'a').


sin (pi/3) :: Floating a => a
side :: Int


Since the type checker has one unknown type, a, and one known, Int, it
tries to put the two together. Then it finds that Int is not an
instance of the Floating class, so a /= Int. So it asks you to make
one:


Probable fix: add an instance declaration for (Floating Int)


In this case, the advice is bad. There is no reasonable way of making
a machine integer a member of the floating class. What you need to do
instead is ensure that you're using a type that is a member of the
Floating class - that is, convert from an Int before you start the
calculation.

The function fromIntegral should come in handy:


let n = 3 :: Int
(fromIntegral n) * sin (pi/3)

2.598076211353316


Good luck!

D.


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


[Haskell-cafe] New New newbie question/help

2007-06-27 Thread Balu Raman

Hi,
Hope someone can help me, just starting out with SOE.My code :
module Main where
import Graphics.SOE.Gtk

spaceClose :: WIndow -> IO()
spaceClose w = do k <- getKey w
  if k == ' ' then closeWindow w
  else spaceClose w

equilateralTri :: Window -> Int -> Int -> Int -> IO()
equilateralTri w x y side
  = drawInWindow w (withColor Red
  (polygon
[(x,y),(a,b),(x,y)]))
  where
   b = y + side * sin(pi/3)
   a = x + side * cos(pi/3)
main =
  runGraphics(
 do w <- openWindow "Equilateral
Triangle" (400,400)
   equilateralTri w 50 300 200
   spaceClose w
   )

all of the above in file triangle.hs
when I do a :l triangle.h in ghci,  I get the following error
triangle.hs:17:36:
   No instance for (Floating Int)
arising from use of 'pi' at triangle.hs:17:36-37
   Probable fix: add an instance declaration for (Floating Int)
   In the first argument of '(/)', namely 'pi'
   In the first argument of 'cos', namely '(pi / 3)'
   In the second argument of '(*)', namely 'cos (pi/3)'
Failed, modules loaded: none

Can someone help me what's going on to a brand new newbie. All I can
figure out is that some type mismatch between float and int . I tried various
combinations of lets and wheres and I still get the same complaints.
I am just linearly studying SOE
Thanks,
- br
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[3]: [Haskell-cafe] Preferred way to get data from a socket

2007-06-27 Thread Bulat Ziganshin
Hello Bulat,

Wednesday, June 27, 2007, 3:34:02 PM, you wrote:

>> What machine did you do the IO benchmarks on? Since we get well over 10x
>> that speed word writing in Data.Binary now, for example, on a fast
>> machine. (Duncan, what's the max throughput we've seen?)

> test box was Duron 1.2 GHz with 230 mb/s raw memory copy throughput.

oh, i've said about ByteString i/o speed because it was what Chad
asked. but actually he will probably need just to (de)serialize data
and best speeds here i've seen is 40-50 mb/s on my box. when going to
(de)serialization my lib reads/writes each byte individually and it's
the reason why it should be slower than Data.Binary

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] New New newbie question/help

2007-06-27 Thread Dougal Stanton

On 27/06/07, Balu Raman <[EMAIL PROTECTED]> wrote:


equilateralTri :: Window -> Int -> Int -> Int -> IO()
equilateralTri w x y side
   = drawInWindow w (withColor Red
   (polygon
[(x,y),(a,b),(x,y)]))
   where
b = y + side * sin(pi/3)
a = x + side * cos(pi/3)


Your problem lies in this section here. Let's look at the error message:


triangle.hs:17:36:
No instance for (Floating Int)
 arising from use of 'pi' at triangle.hs:17:36-37
Probable fix: add an instance declaration for (Floating Int)
In the first argument of '(/)', namely 'pi'
In the first argument of 'cos', namely '(pi / 3)'
In the second argument of '(*)', namely 'cos (pi/3)'
Failed, modules loaded: none


The problem comes from the calculations of 'a' and 'b'. The function
sin doesn't return an Int value. It returns types within the type
class Floating (annotated as below, for some unspecified 'a').


sin (pi/3) :: Floating a => a
side :: Int


Since the type checker has one unknown type, a, and one known, Int, it
tries to put the two together. Then it finds that Int is not an
instance of the Floating class, so a /= Int. So it asks you to make
one:


Probable fix: add an instance declaration for (Floating Int)


In this case, the advice is bad. There is no reasonable way of making
a machine integer a member of the floating class. What you need to do
instead is ensure that you're using a type that is a member of the
Floating class - that is, convert from an Int before you start the
calculation.

The function fromIntegral should come in handy:


let n = 3 :: Int
(fromIntegral n) * sin (pi/3)

2.598076211353316


Good luck!

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


Re[2]: [Haskell-cafe] Preferred way to get data from a socket

2007-06-27 Thread Bulat Ziganshin
Hello Donald,

Wednesday, June 27, 2007, 11:40:28 AM, you wrote:

>> using my library should allow 30-50 mb/s i/o speed but its
>> installation may be tricky since it was not updated over a year

> That's interesting, Bulat. Two points I'd like to ask about the streams 
> library:

> What machine did you do the IO benchmarks on? Since we get well over 10x
> that speed word writing in Data.Binary now, for example, on a fast
> machine. (Duncan, what's the max throughput we've seen?)

test box was Duron 1.2 GHz with 230 mb/s raw memory copy throughput.
reading 20-byte lines: 50 mb/s
reading 80-byte lines: 70 mb/s

> And secondly, will the streams stuff be updated? I had trouble
> benchmarking against it back in January, and am wondering if it will be
> maintained?

afaik, problem is ArrayRef library which is used in Streams but not
compatible with ghc 6.6. i will look into it if it will be really
required for someone

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


RE: [Haskell-cafe] Tools for Haskell and COM

2007-06-27 Thread Bayley, Alistair
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Simon 
> Peyton-Jones
> 
> There's a bit of a chicken-and-egg problem here; the COM 
> tools are not well maintained, so that discourages use, which 
> in turn  makes it less rewarding to work on them.  What I 
> don't know is the level of suppressed demand: if there were 
> good tools, would lots of people start using them?


Um, well, yes, I demand. I want to interface Takusen with MS Sql Server,
but AFAICT the recommended C API is OLE DB, which is a COM API. Not
knowing COM at all, I assume I could program against it like a C
programmer would, using just the FFI, but I imagine it will be easier to
use a COM tool.

Alistair
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A Query Language for Haskell Terms

2007-06-27 Thread Pasqualino 'Titto' Assini
On Wednesday 27 June 2007 09:32:16 Alex Jacobson wrote:
> Titto,
>
> Have you looked at HAppS.DBMS.IxSet?  Right now it provides a generic
> way to query indexed sets.
>
> If you want to take a shot at making the queries serializable, I don't
> think it would be that difficult (but I have not tried so YMMV).

Hi Alex, thanks for remininding me about that. It is a very nice back-end and 
as you say, it should not be too hard to design a SQL-like query language  on 
top of it. 


I am still wondering, however, what meta-model is more appropriate to 
represent the info hold in a Web app.

Unfortunately there seem to be at least 3 different ones (without considering 
mixed approaches like F-Logic):
 

1) Graph

This is really the native Haskell way of representing information: the model 
is defined using classes or data types and types are connected by direct 
uni-directional links.

So for example the Sale/Item model (from the HAppS DBMS Examples) might be 
written like:

data Item = Item {stock::Int,description::String,price::Cents}  
deriving (Ord,Eq,Read,Show)

data Sale = Sale {date::CalendarTime
 ,soldItem::Item -- NOTE: 
uni-directional link to Item
 ,qty::Int
 ,salePrice::Cents} 
deriving (Ord,Eq,Read,Show)

or in more abstract form using classes:

class Item i where
 description :: i -> String
 price :: i -> Cents

class Sale s where
 soldItem :: Item i => s -> i

This is also very much the Web-way: information is a graph of resource linked 
via uni-directional links.

Information is queried by path traversal (REST-style):

Assuming that the root "/" represents the collection of all sales then:

HTTP GET /elemAt[2345]/soldItem/description.json 

might return the JSON representation of the description of the item sold as 
part of sale 2345.


2) Relational

Information is represented as tables, that can be joined up via keys, as 
implemented  in HAppS DBMS or in any relational database.

The model becomes:

data Item = Item {itemId::Id  -- NOTE: primary key 
 ,stock::Int,description::String,price::Cents} 
deriving (Ord,Eq,Read,Show)

data Sale = Sale {date::CalendarTime,
  soldItemId::Id -- NOTE: foreign key 
  ,qty::Int,salePrice::Cents} 
deriving (Ord,Eq,Read,Show)

Plus the appropriate indexes definitions.

Information can be queried via a SQL-like language.


3) Logic

This is the "Semantic Web" way: information is broken down into assertions, 
that in their simplest form are just triples: subject predicate object, the 
model then becomes something like:

Item hasDescription String
Item hasPrice Cents
Sale hasItem Item

It can be populated piecemeal with assertions like:

item0 hasDescription "indesit cooker 34BA"
item0 hasPrice 3.5
Sale0 hasSoldItem item0

It can be queried using a logic-oriented query language (e.g SPARQL):
sale2345 hasItem ?item
?item hasDescription ?description



Moving from Graph to Relational to Logic the meta-model becomes simpler and 
more flexible. The flip-side is that the model (and the queries) become more 
verbose.  It is not clear where is the sweet spot.
 

What people think?  


Best,

titto








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


RE: [Haskell-cafe] Tools for Haskell and COM

2007-06-27 Thread Simon Peyton-Jones
The biggest Haskell/COM project I know of was Krasimir's implementation of 
Visual Haskell, which was a plug-in for Visual Studio.   The VS interfaces are 
COM ones, so he had to do lots of COM stuff.  He may be able to help you.  
Sigbjorn Finne knows a lot about HDirect, but he's really busy with his day job 
at Galois!

There's a bit of a chicken-and-egg problem here; the COM tools are not well 
maintained, so that discourages use, which in turn  makes it less rewarding to 
work on them.  What I don't know is the level of suppressed demand: if there 
were good tools, would lots of people start using them?

Simon


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lewis-Sandy, 
Darrell
Sent: 25 June 2007 19:08
To: haskell-cafe@haskell.org
Subject: [Haskell-cafe] Tools for Haskell and COM

Are there any currently maintained tools for interfacing Haskell with COM 
objects?   It appears that both Haskell script and Haskell direct haven't been 
updated since the turn of the century, and have fallen out of step with recent 
library changes.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] loading an Haskell symbol at run-time

2007-06-27 Thread Donald Bruce Stewart
tittoassini:
> On Wednesday 27 June 2007 03:06:15 Donald Bruce Stewart wrote:
> > tittoassini:
> > > Hi,
> > >
> > > to load an Haskell symbol at run-time is still necessary to use the load
> > > functions from the hs-plugins library (System.Plugins.Load) or is there
> > > some function in the GHC API that does the same job?
> >
> > yes, definitely possible. i think Lemmih put an example on the wiki a
> > while ago. basically, ghc-api exposes the lower level api also used by
> > hs-plugins -- a nice project would be to provide the hs-plugins api
> > directly in ghc-api - avoiding the need for an external hs-plugins package.
> >
> > -- Don
> 
> Hi Don, thanks for the answer.
> 
> I checked again the http://haskell.org/haskellwiki/GHC/As_a_library page on 
> the wiki and there are examples of interactive evaluation but I cannot find 
> an example of loading a symbol from a compiled module.
> 

Yes, this is the part I meant about duplicating the hs-plugins API. Both
ghc-apii and hs-plugins use the following api from the runtime:

foreign import ccall unsafe "Linker.h lookupSymbol"
   pluginSym :: CString -> IO (Ptr a)

foreign import ccall unsafe "Linker.h loadObj"
   pluginLoad :: CString -> IO Bool

foreign import ccall unsafe "Linker.h initLinker"
   pluginInit :: IO ()

foreign import ccall unsafe "Linker.h resolveObjs"
   pluginResolve :: IO Bool

hs-plugins duplicates some of the ghci internals to find, resolve and load
packages and objects, and access their symbols. So that code must exist in the
ghci parts of the ghc-api. You'll have to peek around in there.

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


Re: [Haskell-cafe] loading an Haskell symbol at run-time

2007-06-27 Thread Pasqualino 'Titto' Assini
On Wednesday 27 June 2007 03:06:15 Donald Bruce Stewart wrote:
> tittoassini:
> > Hi,
> >
> > to load an Haskell symbol at run-time is still necessary to use the load
> > functions from the hs-plugins library (System.Plugins.Load) or is there
> > some function in the GHC API that does the same job?
>
> yes, definitely possible. i think Lemmih put an example on the wiki a
> while ago. basically, ghc-api exposes the lower level api also used by
> hs-plugins -- a nice project would be to provide the hs-plugins api
> directly in ghc-api - avoiding the need for an external hs-plugins package.
>
> -- Don

Hi Don, thanks for the answer.

I checked again the http://haskell.org/haskellwiki/GHC/As_a_library page on 
the wiki and there are examples of interactive evaluation but I cannot find 
an example of loading a symbol from a compiled module.

If anyone can provide one, I will be happy to test it and add it to the "GHC 
as a library" Wiki page.

Regards,

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


Re: [Haskell-cafe] A Query Language for Haskell Terms

2007-06-27 Thread Alex Jacobson

Titto,

Have you looked at HAppS.DBMS.IxSet?  Right now it provides a generic 
way to query indexed sets.


If you want to take a shot at making the queries serializable, I don't 
think it would be that difficult (but I have not tried so YMMV).


-Alex-

Pasqualino 'Titto' Assini wrote:

Hi,

I am writing a Web application using HAppS.

As all HAppS apps, it represents its internal state as a Haskell term (HAppS 
automagically provides persistence and transactions).


It is a neat and efficient solution, you can write your data model entirely in 
Haskell and, at least for read-only transactions (queries) it will be operate 
as fast as possible as all data is in memory (if your transactions modify the 
application state, the transactions has to be recorded on disk to make it 
persistent, but this is pretty fast too).


One major component, however seem to be missing, if we are effectively using 
Haskell as an in-memory database where is the "SQL for Haskell": a generic 
query language for Haskell terms?


There are three basic functions that every web app has to provide, and all of 
them could be provided by a generic "Haskell SQL":

-- query the application state
-- transform (possibly monadically) the application state : the result of the 
query is the new state
-- access control:  what an user can see is what is returned by an internal 
access control query


The availabilty of such a language would be a major boost for Haskell-based 
web applications as every application could be accessed via the same API, the 
only difference being the underlying application-specific data model.



So my question is: what ready-made solutions are there in this space, if any?

And if there are none, how would you proceed to design/implement such a 
language?




The basic requirements, in decreasing order of importance, are:

-- Safe, it must be possible to guarantee that a query:
--- cannot cause a system crash
--- completes by a fixed time of time
--- uses a 'reasonable' amount of space
--- cannot perform any unsafe operation (IO, or any unallowed read/write of 
the application state)


-- Expressive (simple queries should be simple, complex queries should be 
possible)


-- Simple to implement 


-- Efficient:
--- Repeated queries should be executed efficiently time-wise (it is 
acceptable for queries to be executed inefficiently the first time) and all 
should be space-efficient, so it should not do unnecessary copying. 


-- User friendly:
--- Simple to use for non-haskeller
--- Short queries

Ah, I almost forgot, it should also be able to make a good espresso.


The problem can be broken in two parts:

1) How to implement generic queries on nested terms in Haskell?

2) How to map the queries, written as a string, to the internal Haskell query


Regarding the first point, I am aware of with the following options:
- SYB (Data.Generics..)
- Oleg's Zipper 
- (Nested) list comprehensions (that are being extended with SQL-like order by 
and group by operators)


Being rather new to Haskell all these options are rather unfamiliar so I would 
appreciate any advice on what should be preferred and why.




Regarding the second point: 

The simplest solution would be to avoid the problem entirely by using Haskell 
directly as the query language.


This is the LambdaBot way: queries are Haskell 
expression, compiled in a limited environment (a module with a fixed set of 
imports, no TH).


Lambdabot avoids problems by executing the expression on a separate process in 
a OS-enforced sandbox that can be as restrictive as required (especially 
using something like SELinux).


However, to get the query to execute efficiently it would probably have to be 
executed in a GHC thread and I am not sure how safe that would be.


Looking at the discussion at  
http://haskell.org/haskellwiki/Safely_running_untrusted_Haskell_code 
 it seems clear that there are many open issues.


For example, how would I enforce limits on the space used by the query?

So, it would probably be better to define a separate query 
language that is  less expressive but more controllable than full Haskell, but 
what form should that take?




Any suggestion/tip/reference is very welcome,

 titto








___
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] Re: Tree Guidance

2007-06-27 Thread apfelmus
Chris Kuklewicz wrote:
> apfelmus wrote:
>> Up-pointers won't work in Haskell, you'll need a different approach. Can
>> you elaborate on what your tree looks like and what it stores?
> 
> "pointers" don't exist in Haskell, though they do exist in the Foreign.*
> interface package.
> 
> But Up-values work just fine:

Well, not really: they're read-only. To "update" a single Branch/Leaf in
the presence of up-values/"pointers" requires to update the up-values of
_every_ Branch/Leaf in the tree.

Regards,
apfelmus

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


Re: [Haskell-cafe] Preferred way to get data from a socket

2007-06-27 Thread Donald Bruce Stewart
bulat.ziganshin:
> Hello Donald,
> 
> Wednesday, June 27, 2007, 6:37:07 AM, you wrote:
> 
> >> I also know Bulat Ziganshin had put together a nice-looking Streams
> >> library (http://unix.freshmeat.net/projects/streams/) based on John
> >> Goerzen's previous HVIO work, but I wasn't sure if the ByteString
> >> stuff matches the speed and encapsulates all of the functionality of
> >> that anyway. Or can/should they be used together somehow?
> 
> > Should be similar in speed, and most high-perf stuff seems to use
> > ByteStrings now. ByteStrings also have some nice high level
> > optimisations not available to lower level libraries.
> 
> i recommend you to try ByteString own i/o capabilities at first. if it
> will not satisfy you, you can try Streams 0.2 which supports
> ByteString i/o:
> 
> http://www.haskell.org/library/StreamsBeta.tar.gz
> 
> using my library should allow 30-50 mb/s i/o speed but its
> installation may be tricky since it was not updated over a year

That's interesting, Bulat. Two points I'd like to ask about the streams library:

What machine did you do the IO benchmarks on? Since we get well over 10x
that speed word writing in Data.Binary now, for example, on a fast
machine. (Duncan, what's the max throughput we've seen?)

And secondly, will the streams stuff be updated? I had trouble
benchmarking against it back in January, and am wondering if it will be
maintained?

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


Re[2]: [Haskell-cafe] Preferred way to get data from a socket

2007-06-27 Thread Bulat Ziganshin
Hello Donald,

Wednesday, June 27, 2007, 6:37:07 AM, you wrote:

>> I also know Bulat Ziganshin had put together a nice-looking Streams
>> library (http://unix.freshmeat.net/projects/streams/) based on John
>> Goerzen's previous HVIO work, but I wasn't sure if the ByteString
>> stuff matches the speed and encapsulates all of the functionality of
>> that anyway. Or can/should they be used together somehow?

> Should be similar in speed, and most high-perf stuff seems to use
> ByteStrings now. ByteStrings also have some nice high level
> optimisations not available to lower level libraries.

i recommend you to try ByteString own i/o capabilities at first. if it
will not satisfy you, you can try Streams 0.2 which supports
ByteString i/o:

http://www.haskell.org/library/StreamsBeta.tar.gz

using my library should allow 30-50 mb/s i/o speed but its
installation may be tricky since it was not updated over a year


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


RE: [Haskell-cafe] Best idiom for avoiding Defaulting warnings with ghc -Wall -Werror ??

2007-06-27 Thread Simon Peyton-Jones
| happens because I don't want to actually use defaulting, but I would
| have no objection to the warning being suppressed if someone has
| explicitly given a "default" declaration (and thus, presumably, does
| want to use defaulting).

I'm not against this particular proposal if there's a consensus in favour of it.

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


[Haskell-cafe] Re: ANN: Scripting.Lua 0.1

2007-06-27 Thread Gracjan Polak
Andrea Rossato  istitutocolli.org> writes:

> I quote: this is a really nice news. I'll be trying to use it in
> project of mine very soon (I'm developing a sort of Ion3 like status
> bar, which is scriptable through Lua).

Exactly such a scenario I had in mind. Calling Lua from Haskell was easy, the
hard part was to call Haskell from Lua. 

Give me a sign how it worked.

> 
> Please follows Donald's suggestion and upload it on Hackage.

Uploaded. 

-- 
Gracjan




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