Re: [Haskell-cafe] PROPOSAL: Web application interface

2010-01-17 Thread Mark Lentczner
I like this project! Thanks for resurrecting it!

Some thoughts:

Methods in HTTP are extensible. The type RequestMethod should probably have a 
"catchall" constructor
| Method B.ByteString

Other systems (the WAI proposal on the Wiki, Hack, etc...) have broken the path 
into two parts: scriptName and pathInfo. While I'm not particularly fond of 
those names, they do break the path into "traversed" and "non-traversed" 
portions of the URL. This is very useful for achieving "location independence" 
of one's code. While this API is trying to stay agnostic to the web framework, 
some degree of traversal is pretty universal, and I think it would benefit 
being in here.

The fields serverPort, serverName, and urlScheme are typically only used by an 
application to "reconstruct" URLs for inclusion in the response. This is a 
constant source of bugs in many web sites. It is also a problem in creating 
modular web frameworks, since the application can't be unaware of its context 
(unless the server interprets and re-writes HTML and other content on the fly - 
which isn't realistic.) Perhaps a better solution would be to pass a "URL 
generating" function in the Request and hide all this. Of course, web 
frameworks *could* use these data to dispatch on "virtual host" like 
configurations. Though, perhaps that is the provenance of the server side of 
the this API? I don't have a concrete proposal here, just a gut that the 
inclusion of these breaks some amount of encapsulation we'd like to achieve for 
the Applications.

The HTTP version information seems to have been dropped from Request. Alas, 
this is often needed when deciding what response headers to generate. I'm in 
favor of a simple data type for this:
data HttpVersion = Http09 | Http10 | Http11

Using ByteString for all the non-body values I find awkward. Take headers, for 
example. The header names are going to come from a list of about 50 well known 
ones. It seems a shame that applications will be littered with expressions like:

[(B.pack "Content-Type", B.pack "text/html;charset=UTF-8")]
 
Seems to me that it would be highly beneficial to include a module, say 
Network.WAI.Header, that defined these things:

[(Hdr.contentType, Hdr.mimeTextHtmlUtf8)]

Further, since non-fixed headers will be built up out of many little String 
bits, I'd just as soon have the packing and unpacking be done by the server 
side of this API, and let the applications deal with Strings for these little 
snippets both in the Request and the Response.

For header names, in particular, it might be beneficial (and faster) to treat 
them like RequestMethod and make them a data type with nullary constructors for 
all 47 defined headers, and one ExtensionHeader String constructor.

Finally, note that HTTP/1.1 actually does well define the character encoding of 
these parts of the protocol. It is a bit hard to find in the spec, but the 
request line, status line and headers are all transmitted in ISO-8859-1, (with 
some restrictions), with characters outside the set encoded as per RFC 2047 
(MIME Message Header extensions). Mind you, I believe that most web servers 
*don't* do the 2047 decoding, and only either a) pass the strings as ISO-8859-1 
strings, or decode that to native Unicode strings.

- Mark



Mark Lentczner
http://www.ozonehouse.com/mark/
IRC: mtnviewmark



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


Re: [Haskell-cafe] xmonad cannot find its library after upgrading GHC

2010-01-17 Thread Don Stewart
z_axis:
> 
> After `pacman -Syu`, the ghc is upgraded to 6.12.1
> %ghc --version
> The Glorious Glasgow Haskell Compilation System, version 6.12.1
> 
> However, the xmonad still stay as it is:
> %pacman -Q|grep -i xmonad
> xmonad 0.9-2.1
> xmonad-contrib 0.9-1.2
> 
> %pacman -Ql xmonad|more 
> ..
> xmonad /usr/lib/ghc-6.10.4/
> xmonad /usr/lib/ghc-6.10.4/site-local/
> xmonad /usr/lib/ghc-6.10.4/site-local/xmonad-0.9/
> xmonad /usr/lib/ghc-6.10.4/site-local/xmonad-0.9/HSxmonad-0.9.o
> xmonad /usr/lib/ghc-6.10.4/site-local/xmonad-0.9/XMonad.hi
> xmonad /usr/lib/ghc-6.10.4/site-local/xmonad-0.9/XMonad/
> .
> 
> So it will fail when running `xmonad --recompile` as xmonad cannot find its
> library in /usr/lib/ghc-6.12.1.
> Do i need to re-install xmonad ?
> 

Yes, that's right. You need to reinstall xmonad.

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


[Haskell-cafe] xmonad cannot find its library after upgrading GHC

2010-01-17 Thread zaxis

After `pacman -Syu`, the ghc is upgraded to 6.12.1
%ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.1

However, the xmonad still stay as it is:
%pacman -Q|grep -i xmonad
xmonad 0.9-2.1
xmonad-contrib 0.9-1.2

%pacman -Ql xmonad|more 
..
xmonad /usr/lib/ghc-6.10.4/
xmonad /usr/lib/ghc-6.10.4/site-local/
xmonad /usr/lib/ghc-6.10.4/site-local/xmonad-0.9/
xmonad /usr/lib/ghc-6.10.4/site-local/xmonad-0.9/HSxmonad-0.9.o
xmonad /usr/lib/ghc-6.10.4/site-local/xmonad-0.9/XMonad.hi
xmonad /usr/lib/ghc-6.10.4/site-local/xmonad-0.9/XMonad/
.

So it will fail when running `xmonad --recompile` as xmonad cannot find its
library in /usr/lib/ghc-6.12.1.
Do i need to re-install xmonad ?

Sincerely!

-
fac n = foldr (*) 1 [1..n]
-- 
View this message in context: 
http://old.nabble.com/xmonad-cannot-find-its-library-after-upgrading-GHC-tp27206013p27206013.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


[Haskell-cafe] parallel matrix multiply (dph, par/pseq)

2010-01-17 Thread Johannes Waldmann
Hello.

How can I multiply matrices (of Doubles)
with dph (-0.4.0)?  (ghc-6.12.1)  -  I was trying

type Vector = [:Double:]
type Matrix = [:Vector:]

times :: Matrix -> Matrix -> Matrix
times a b =
  mapP
  ( \ row -> mapP ( \ col -> sumP ( zipWithP (*) row col  ) )
  ( transposeP b )
  ) a

but there is no such thing as transposeP.

When I try any kind of index manipulations,
the compiler invariably tells me
that it does not want to build  [: :] - lists of indices
(e.g., there is no enumFromToP)
(I guess because I'm using Data.Array.Parallel.Prelude.Double)

Puzzled - J.W.


PS: what's the recommended way to multiply matrices
(better modelled as   Array (Int,Int) Double   or  [[Double]] ?)
with the  par/pseq  approach (if this is recommended at all)?

As I said earlier, I just want to have some nice and easy benchmarks
for demonstration in a lecture (to be run on 2, 4, or 8 cores).
Of course if they work, I'd use them in real life as well...





signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Arrow instance of Transducer (Was: [Haskell] ANN: Streaming Component Combinators 0.4)

2010-01-17 Thread Mario Blažević
On Sun 17/01/10  4:47 PM , Twan van Laarhoven twa...@gmail.com sent:
> The Arrow class is too big, it includes too many things and it should be
> split up. This is yet another example. You can get some of the benefits of
> standard classes by making Transducer an instance of 
> Control.Category.Category, for
> which you only need to implement (.) and id.

Yes, perhaps I'll do that. Is there any relatively accepted package that
defines PointedCategory?


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


Re: [Haskell-cafe] ANN: atom-0.1.3

2010-01-17 Thread Tom Hawkins
On Sun, Jan 17, 2010 at 1:16 PM, miaubiz  wrote:
>
> I am trying to generate a square wave.  Here's the code:
>
>    square <- bool "square" False
>
>    period 2 $ atom "square high" $ phase 0 $ do
>        square <== true
>        assert "square is low" $ not_ $ value square
>
>    period 2 $ atom "square low" $ phase 1 $ do
>        square <== false
>        assert "square is high" $ value square
>
>
> The tests fail every cycle because after each rule one of them is wrong.

If you are using the latest version of Atom, asserts are checked
between the execution of every rule.  The way you've coded it, it may
appear as if the assertions are checked along with the associated
rules, but this is not the case.  And not only are the assertions not
checked with the rules, they don't follow the period or phase
constraints either.  So what you have is essentially 2 assertions that
are being checked at every time instance and between every atom state
update.

>
> What would be the right way to formulate this code? Use cond on the rules?
>
>    period 2 $ atom "square high" $ phase 0 $ do
>        cond $ not_ $ value square
>        square <== true
>        cover "lowSquare" true
>        assert "square is low" $ not_ $ value square
>
>    period 2 $ atom "square low" $ phase 1 $ do
>        cond $ value square
>        square <== false
>        cover "highSquare" true
>        assert "square is high" $ value square
>
>

Yes, guard conditions would help.  Guards are hierarchical; they apply
to all the sub Atom rules and assertions.  As such ...

  cond $ not_ $ value square
  assert "squareIsLow" $ not_ $ value square

.. is a redundant because the guard condition is the same as the
assertion.  The guard will only allow the assertion to be checked if
'square' is false, and if it does, the assertion is guaranteed to
pass.

An easier way to write a square wave is this...

square <- bool "square" False

period 2 $ atom "toggle" $ do
  square <== not_ (value square)


> as an aside, in Unit.hs:
>         covered = [ words line !! 1 | line <- lines log, isPrefixOf
> "covered:" line ]
>
> because covered is the second word of the line from the log, the name of
> cover must be a single word. assertions and atoms can contain spaces as far
> as I can tell.

No, they really shouldn't.  I've been meaning to add some checks to
enforce some naming rules, but haven't gotten around to it.

I hope this helps.

-Tom

>
> br, miau
> --
> View this message in context: 
> http://old.nabble.com/ANN%3A-atom-0.1.3-tp26624813p27198213.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
>
> ___
> 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: Arrow instance of Transducer (Was: [Haskell] ANN: Streaming Component Combinators 0.4)

2010-01-17 Thread Twan van Laarhoven

Mario Blažević wrote:

After some investigation, I've concluded that Transducer cannot be made an
instance of Arrow in any way that's both practical and general.

the arr and (>>>) methods are trivial:

but there is no satisfactory definition for the method first.


The Arrow class is too big, it includes too many things and it should be split 
up. This is yet another example. You can get some of the benefits of standard 
classes by making Transducer an instance of Control.Category.Category, for which 
you only need to implement (.) and id.



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


Re: [Haskell-cafe] Type Inference for Overloading without Restrictions

2010-01-17 Thread Carlos Camarao
On Wed, Jan 13, 2010 at 7:57 AM, Peter Verswyvelen wrote:

> A while ago, someone provided me a link to the paper "Type Inference
> for Overloading without Restrictions"
> http://www.dcc.ufmg.br/~camarao/ct-flops99.ps.gz
>
> Although I don't understand everything in this paper, I wander what
> people's opinions are about this regarding a future Haskell language
> revision or extension?
>

System CT (as it was defined in the Flops99 paper) is a core system
for constrained (parametric + ad-hoc) polymorphism, the main
difference with respect to Haskell type classes being that it uses a
closed world approach to overloading (as it was defined in the Flops99
paper),
while Haskell type classes uses an open world.

Open means that principal types of overloaded symbols are explicitly
specified (in Haskell class declarations), and, informally speaking,
satisfiability checking is performed only when overloading is resolved
(i.e. satisfiability is delayed until it cannot be delayed any longer).

Closed, on the other hand, means that principal types are determined
(inferred) according to (definitions available in) the context (as
occurs in the normal case, of non-overloaded symbols).

For details, see e.g. [1].

A "mixed" approach, where annotation of types of overloaded symbols is
not mandatory but satisfiability checking is done as in an open world
approach, is possible and advantageous.

Only prototype implementations exist to this date of system CT.
A prototype implementation of a mixed approach is currently under way.


>
> Would a feature like this be preferable over typeclasses?


The main disadvantage of system CT's closed world approach is the cost
of satisfiability checking. (However, this does not hold in the case of a
mixed
approach, where satisfiability checking is restrictd as in an open world).
The main advantage is that annotations (type classes) need not be mandatory
and a priori determined by the programmer.

Would it be practical to implement?


Yes, I think so, in particular the mixed approach where satisfiability
checking is
delayed (it is done only if there exist "unreachable variables" in the
constraint set),
as explained in [2].  We have recently sent a message with a link to our
paper, that
describes this approach, as a proposal to solve Haskell's MPTC dilemma
(without
the need of functional dependencies or another mechanism).


> Are people working on this?
>

Yes. We are.


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

Cheers,

Carlos

[1] Open and Closed World Approaches to Overloading: a Definition and
Support for
Coexistence, Carlos Camarão, Cristiano Vasconcellos, Lucília Figueiredo,
João Nicola,
Journal of Universal Computer Science 13(6), 854-873, 2007.
http://www.dcc.ufmg.br/~camarao/CT/open-closed.pdf

[2] A Solution to Haskell's Multi-paramemeter Type Class Dilemma,
Carlos Camarão, Rodrigo Ribeiro, Lucília Figueiredo, Cristiano
Vasconcellos,
SBLP'2009 (13th Brazilian Symposium on Programming Languages), 2009.
http://www.dcc.ufmg.br/~camarao/CT/solution-to-mptc-dilemma.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why no merge and listDiff?

2010-01-17 Thread Derek Elkins
On Sun, Jan 17, 2010 at 2:22 PM, Will Ness  wrote:
> Hello cafe,
>
> I wonder, if we have List.insert and List.union, why no List.merge (:: Ord a 
> =>
> [a] -> [a] -> [a]) and no List.minus ? These seem to be pretty general
> operations.

Presumably by List.minus you mean the (\\) function in Data.List.  You
probably also want to look at the package data-ordlist on hackage
(http://hackage.haskell.org/packages/archive/data-ordlist/0.0.1/doc/html/Data-OrdList.html)
which represents sets and bags as ordered lists and has all of the
operations you mention.

> Brief look into haskell-prime-report/list.html reveals nothing.
>
> Could we please have them?

The trend is to remove things from "standard" libraries and to push
them more to 3rd party libraries hosted on hackage.

> On the wider perspective, is their a way to declare an /ordered/ list on the
> type level (e.g. [1,2,3] would be one, but not [2,3,1])? Non-decreasing lists?
> Cyclical, or of certain length? What are such types called?

There are a few ways to encode such things.  The most direct route is
to use dependent types as Miguel mentioned, but Haskell has no support
for those.  See languages like Agda or Coq.  Another approach is to
use a type that specifically represents what you want and nothing
else.  For example, a list of a set length is just a tuple.  It is
easy to make a type that represents cyclic lists.  Finally, the most
general method is to use an abstract data type to maintain the
invariant.  It is trivial to handle ordered/non-decreasing lists in
this way.  One note about the dependent types route is that the
ability to assert arbitrary properties comes with it the
responsibility to prove them later on.  So you can make a function
which only accepts ordered lists, but then the users need to pass in a
proof that their lists are ordered when they use such functions and
these proofs can be a significant burden.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why no merge and listDiff?

2010-01-17 Thread Miguel Mitrofanov


On 17 Jan 2010, at 23:22, Will Ness wrote:

What are such types called?


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


[Haskell-cafe] Why no merge and listDiff?

2010-01-17 Thread Will Ness
Hello cafe,

I wonder, if we have List.insert and List.union, why no List.merge (:: Ord a => 
[a] -> [a] -> [a]) and no List.minus ? These seem to be pretty general 
operations.

Brief look into haskell-prime-report/list.html reveals nothing.

Could we please have them?

On the wider perspective, is their a way to declare an /ordered/ list on the 
type level (e.g. [1,2,3] would be one, but not [2,3,1])? Non-decreasing lists? 
Cyclical, or of certain length? What are such types called?

TIA!


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


[Haskell-cafe] Takusen - reading from one db inserting into another

2010-01-17 Thread Günther Schmidt

Hi,

I know how to use Takusen with a *single* connection, but I cannot 
figure out how to read from one database while inserting to another.



Could someone please explain to me how I can do that?

Günther


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


Re: [Haskell-cafe] Parsers for Text Adventures

2010-01-17 Thread Tim Wawrzynczak
Hi Mark,

I recently ported Conrad Barski's 'Casting SPELs in Lisp' to Haskell (a text
adventure game).

I had some of these problems as well, and you can find my code on Hackage
(the package is called Advgame).

Some things in there might be of some help.

Cheers,
 - Tim

On Sun, Jan 17, 2010 at 7:30 AM, Mark Spezzano  wrote:

> Hi,
>
> I am writing a Text Adventure game in Haskell (like Zork)
>
> I have all of the basic parser stuff written as described in Hutton's
> Programming in Haskell and his associated papers. (I'm trying to avoid using
> 3rd party libraries, so that I can learn this myself)
>
> Everything that I have works (so far...) except for the following problem:
>
> I want to define a grammar using a series of Verbs like this:
>
> data Verb = Go | Get | Jump | Climb | Give etc, etc deriving (Show, Read)
>
> and then have my parser "get" one of these Verb tokens if possible;
> otherwise it should do something (?) else like give an error message stating
> "I don't know that command"
>
> Now, Hutton gives examples of parsing strings into string whereas I want to
> parse Strings into my Verbs
>
> So, if the user types "get sword" then it will tokenise "get" as type
> Verb's data constructor Get and perhaps "sword" into a Noun called Sword
>
> My parser is defined like this:
>
> newtype Parser a = Parser (String -> [(a, String)])
>
> So I CAN give it a Verb type
>
> but this is where I run into a problem
>
> I've written a Parser called keyword
>
> keyword :: Parser Verb
> keyword = do x <- many1 letter
>return (read x)
>
> (read this as
> "take-at-least-one-alphabetic-letter-and-convert-to-a-Verb-type")
>
> which DOES work provided that the user types in one of my Verbs. If they
> don't, well, the whole thing fails with an Exception and halts processing,
> returning to GHCi prompt.
>
> Question: Am I going about this the right way? I want to put together lots
> of "data" types like Verb and Noun etc so that I can build a kind of "BNF
> grammar".
>
> Question: If I am going about this the right way then what do I about the
> "read x" bit failing when the user stops typing in a recognised keyword. I
> could catch the exception, but typing an incorrect sentence is just a typo,
> not really appropriate for an exception, I shouldn't think. If it IS
> appropriate to do this in Haskell, then how do I catch this exception and
> continue processing.
>
> I thought that exceptions should be for exceptional circumstances, and it
> would seem that I might be misusing them in this context.
>
> Thanks
>
> Mark Spezzano
>
> ___
> 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] Parsers for Text Adventures

2010-01-17 Thread Iavor Diatchki
Hi Mark,

On Sun, Jan 17, 2010 at 5:30 AM, Mark Spezzano
 wrote:
> Question: Am I going about this the right way? I want to put together lots of 
> "data" types like Verb and Noun etc so that I can build a kind of "BNF 
> grammar".

Your basic idea to use a datatype is a good one.  You just need to
implement it in a slightly different way.  For example, you could
write a function:

string :: String -> Parser ()

Given a string, this function returns a parser that will try to
recognize the string in the input.  If successful, the parser returns
a single trivial result, otherwise it fails (i.e. returns an empty
list of result).

You will also need a function, say (<+>):

(<+>) :: Parser a -> Parser a -> Parser a

This function will apply two parser two the same input and combine
their results.  Now you can write your verb parser:


verb :: Parser Verb
verb = (string "jump" >> return Jump)
 <+>
   ((string "get" <+> string "take") >> return Get)   --
supports synonyms
<+>
  ... etc ..

Hope that this helps.
-Iavor
PS: By the way, there are a number of libraries that already implement
such basic "parser combinators" so you can use one of them if you are
not interested in the actual low level details of how the parser
works.  One such library is "parsimony", another is "parsec".








> Question: If I am going about this the right way then what do I about the 
> "read x" bit failing when the user stops typing in a recognised keyword. I 
> could catch the exception, but typing an incorrect sentence is just a typo, 
> not really appropriate for an exception, I shouldn't think. If it IS 
> appropriate to do this in Haskell, then how do I catch this exception and 
> continue processing.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: afv-0.0.2

2010-01-17 Thread Tom Hawkins
AFV is an infinite state model checker for simple, iterative C
programs.  This release adds some new name checks, a few minor bug
fixes, basic support for functions, and a little stronger type
checking.  Though most of the C language is still not supported, it
can verify a lot of interesting behavior -- including one of my bugs
that pulverized about $40K of hydraulics hardware last year.  :-)

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


[Haskell-cafe] Re: Arrow instance of Transducer (Was: [Haskell] ANN: Streaming Component Combinators 0.4)

2010-01-17 Thread Mario Blažević
>>> Stupid question: Is it related to Arrows?
>>
>> Not really. You might say it's more general than arrows, because 
>> the streaming components are not restricted to a single input and 
>> single output type. On the other hand, they are all specific to stream 
>> processing, much like Fudgets and Yampa which are arrow-based.
>
> Arrows use tuple values for multiple inputs and outputs. Actually I'm 
> using arrows this way for signal processing.
> 
>> I suppose the Transducer data type [1] could be made an Arrow 
>> instance, which would let me rename the 'connect' combinator [2] to 
>> (>>>). I'll have a look at Yampa to see if I can harvest more 
>> combinator names, thank you!

After some investigation, I've concluded that Transducer cannot be made an
instance of Arrow in any way that's both practical and general.

The reason is that a Transducer converts a finite stream to another finite
stream of arbitrary length. If we
ignore effects, it's like a function of type [a] -> [b].

When trying to define an instance of Arrow for

> newtype Transducer a b = Transducer ([a] -> [b])

the arr and (>>>) methods are trivial:

> instance Arrow Transducer where
>arr f = Transducer (map f)
>Transducer t1 >>> Transducer t2 = Transducer (t2 . t1)

but there is no satisfactory definition for the method first. A sensible
definition, IMO, would have to give rise to a pairwise (***), so if we have two
transducers t1 and t2 which respectively convert [a,b] to [c,d] and [1,2] to
[3,4], t1 *** t2 would have to map [(a,1), (b,2)] to [(c,3), (d,4)]. There is no
general way to define such a method first for the Transducer data type above. 
One
can try appending the right-hand sides of the input to a queue and adding them 
to
the outputs of the argument transducer:

>first (Transducer t) = Transducer (uncurry (zip . t) . unzip)

but this works only for injective transducers that map each new input item to
exactly one output item. If the input
stream has finite length, the input and output stream must be of equal length.

In his paper "Generalising Monads to Arrows" from 1998, John Hughes defines 
a
similar Arrow instance for stream processors operating on infinite streams which
theoretically works for non-injective transforms, but leaks infinite space and
can't be adopted to finite stream processors.

HXT defines a different kind of an Arrow instance similar to the list monad
instance. This approach can combine non-injective transforms, but in it the t1
*** t2 example above would map the input [(a,1), (b,2)] to [(c,3), (c,4), (d,3),
(d,4)]. While this is a simple and lawful Arrow instance, I don't find it useful
for stream processing.

Yampa and other Functional Reactive Programming libraries associate a unique
timestamp to each stream item. Method first can use this timestamp to associate
input and output items even if the transducer leaves out some output items, and
if the time stamps are ordered in each stream I guess it could also handle extra
output items unrelated to any input. I'm not certain to what extent the FRP
transducers (i.e., signal processors) are allowed to do this.

To summarize: while I'd love the benefits of satisifying an Arrow instance,
the loss of generality seems too high for me. SCC transducers work on finite
streams of any values, and their output stream need not have any resemblance to
the input stream. I may define an Arrow-conformant subclass of Transducer in a
future version of SCC, perhaps operating on streams with timestamped values.


>> 
>> [1] 
>>
http://hackage.haskell.org/packages/archive/scc/0.4/doc/html/Control-Concurrent-SCC-Types.html#t%3ATransducer

>> 
>> [2] 
>>
http://hackage.haskell.org/packages/archive/scc/0.4/doc/html/Control-Concurrent-SCC-Combinators.html#v%3Aconnect

> 
> In whatever way it is related to arrows, maybe you can mention it on the 
> project page.

I'll copy this message there.



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


[Haskell-cafe] PROPOSAL: Web application interface

2010-01-17 Thread Michael Snoyman
Following up on the previous thread, I've started a github project for some
ideas of a web application interface. It's borrowing from both Hyena and
Hack, with a few of its own ideas. The project is available at
http://github.com/snoyberg/wai, and the Network.Wai module is available at
http://github.com/snoyberg/wai/blob/master/Network/Wai.hs. The repository
also includes a port of hack-handler-simpleserver, and an incredibly simple
webapp to demonstrate usage. I intend to make the demonstration slightly
more sophisticated. Finally, the repository is now yet cabalized.

I consider this currently to be a straw-man proposal, intended to highlight
the issues of contention that may arise. It would be wonderful is we could
get the major players in the Haskell web space to get behind a single WAI.

The entire Network.Wai module right now weighs in at only 74 lines, so I do
not consider this to be a heavy-weight proposal. Here as some design notes:


   - Most important point: RequestBody and ResponseBody. I will explain
   below.
   - I've renamed "Env" in Hack and "Environment" in Hyena to "Request."
   This seems more consistent with other technologies out there. However, I
   have no feelings on this subject at all, and can easily bend to public
   demand.
   - I've stuck with UrlScheme from Hack, while Hyena called it protocol.
   Similar, the RequestMethod constructors are ALLCAPS like Hack, unlike
   Hyena's Uppercase. Once again, no strong feelings.
   - I've sided with Hyena as far as making all representations in
   ByteString. Current exception is remoteHost, which is a Hack-only variable
   in any event.
   - Instead of representing the response as a tuple ala Hyena, created a
   data type like Hack.
   - The only dependency for this module is bytestring. It might be tempting
   to represent RequestBody and ResponseBody with a ReaderT IO monad, but this
   would introduce a dependency on either mtl or transformers, which I would
   consider a Very Bad Idea.

The main complaint against Hack is its lack of an enumerator interface for
the request and response body. However, this simply words the complaint
incorrectly; I don't think anyone is married to the need of an enumerator.
Rather, we want to be able to efficiently handle arbitrarily lengthed
content in constant space, without necesarily resorting to
unsafeInterleaveIO (ie, lazy I/O).

There are a number of issues with left-fold enumerators IMO. It is basically
promoting an inversion of control. This may be often times valuable.
However, to make this the *only* interface precludes other use cases. The
most basic one I ran into was wanting to interleave with read processes. I
do not mean to say that it's impossible to interleave reads in such a
manner, but I think it's more natural in the approach advocated by wai.

I consider RequestBody and ResponseBody to be mirroring the CGI protocol.
Essentially, each handler (CGI, simpleserver, FastCGI, happstack server,
etc) will define data types which instanciate RequestBodyClass and
ResponseBodyClass. RequestBodyClass provides a single method,
receiveByteString, to extract a chunk of data from the request body.
ResponseBodyClass provides (currently) three methods, for sending strict
bytestrings, lazy bytestrings, and files. While default implementations are
provided for the last two based on the first, implementations can provide
more efficient versions of them if desired. For example, sendFile might be
replaced by a system call to sendfile.

Let me know your thoughts. I'm purposely leaving out many of my reasons for
the decisions I've made for brevity, since this e-mail is long enough as is.
I'm happy to answer any questions as to why I went in a certain direction.
It's also possible that I simply overlooked a detail.

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


Re: [Haskell-cafe] cabal install vacuum-cairo

2010-01-17 Thread Gwern Branwen
On Sun, Jan 17, 2010 at 9:55 AM, Ozgur Akgun  wrote:
> Cafe,
>
> I've been trying to install vacuum-cairo using cabal but I couldn't have it
> installed because of the missing packages cairo, svg and gtkcairo.
>
> What should I do to install vacuum-cairo?
>
> Thanks for any help in advance,

Those packages are provided by http://www.haskell.org/gtk2hs/

cabal-install didn't pull them in because they are too difficult to
cabalize & hence not on Hackage.

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


[Haskell-cafe] cabal install vacuum-cairo

2010-01-17 Thread Ozgur Akgun
Cafe,

I've been trying to install vacuum-cairo using cabal but I couldn't have it
installed because of the missing packages cairo, svg and gtkcairo.

What should I do to install vacuum-cairo?

Thanks for any help in advance,


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


Re[2]: [Haskell-cafe] Re: Parse error

2010-01-17 Thread Bulat Ziganshin
Hello VoidPrayer,

Sunday, January 17, 2010, 5:32:55 PM, you wrote:

> By the way, is it only valid when "let" only affects the one expression after
> that? I read "where vs let" in the HaskellWiki but all the examples are "let
> ... in".

the "let" inside "do" is just a syntax sugar:

do xxx
   let yyy
   zzz
   ttt

is equivalent to

do xxx
   let yyy in do zzz; ttt


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] Dependency trickery

2010-01-17 Thread Felipe Lessa
On Sun, Jan 17, 2010 at 02:25:39PM +, Malcolm Wallace wrote:
> Not true.  The value of the flag *is* determined automatically based
> on what packages you already have on your system.

Oh, then please forgive my mistake.  Cabal is smarter than I am :).

Thanks, Malcolm!

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


Re: [Haskell-cafe] Re: Parse error

2010-01-17 Thread VoidPrayer
Oh, I should know that. Thank you.

By the way, is it only valid when "let" only affects the one expression after 
that? I read "where vs let" in the HaskellWiki but all the examples are "let 
... in".

在 2010年 1月 17日 星期日 22:13:14,Maciej Piechotka 寫道:
> On Sun, 2010-01-17 at 18:10 +0800, VoidPrayer wrote:
> > let ...
> > in ...
> >
> > I guess GHC is finding where "in" is.
> 
> Except that:
> 
> main = do l <- getLine
>   let l' = lines l
>   print l'
> 
> Is perfectly valid without in. Similary:
> 
> something = proc (x, y) -> do x' <- someArrow -< x
>   let z = x + y + x'
>   returnA -< z
> 
> Regards
> 
> 
> ___
> 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] Dependency trickery

2010-01-17 Thread Malcolm Wallace

Suppose I write some code that can work with Gtk2hs or wxHaskell.
How do I go about making that into a package?


You just need to add a flag 'gtk2hs' and then construct the
Build-Depends depending on the value of the flag.  However, if
e.g. that flag is by default True, then users of wxHaskell will
have to manually change its value.  I.e. it is not automatic
based on what the user has on his system.


Not true.  The value of the flag *is* determined automatically based  
on what packages you already have on your system.  For instance, if  
your cabal file says


  Flag hasGTK
Default: True
  Library
if hasGTK
  Build-Depends: gtk2hs
else
  Build-Depends: wxHaskell

and your installed system has wx but not gtk, then it will still  
select the wx branch, regardless of the value of the flag default.   
The only meaning of the default value is, if *both* possible solutions  
could potentially build successfully, then which one will be preferred.


Regards,
Malcolm

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


Re: [Haskell-cafe] Parsers for Text Adventures

2010-01-17 Thread Luke Palmer
On Sun, Jan 17, 2010 at 7:02 AM, Stephen Tetley wrote:

> I wouldn't use read instead something either a simple function:
>
> > verb :: String -> Maybe Verb
> > verb "Go"  = Just Go
> > verb "Get" = Just Get
> > verb _ = Nothing


>
> Or possible a Map:
>
> > verb2 :: String -> Maybe Verb
> > verb2 s = Map.lookup s verb_map
>
> > verb_map :: Map.Map String Verb
> > verb_map = Map.fromAscList [ ("Go", Go), ("Get", Get) {- .. -} ]
>

Oh, yeah, I like these better than relying on the Read instance.  Relying on
Read and Show for program logic has been kind of an implicit smell to me,
and I can put my finger on why now: you lose alpha conversion on the program
scale.  I like the ability to rename with confidence.

Plus, this way it is natural to encode synonyms; eg. "take" and "get".
 Though depending on the vernacular of the game you might not want that.
 I'm not sure what it means to take out of bed.

Luke


>
>
> You could then do more about say case sensitivity - e.g. add ("get",Get)
> etc
> or always convert to upper before querying the map.
>
>
> > verb3 :: String -> Maybe Verb
> > verb3 s = Map.lookup (map toUpper s) verb_map2
>
> > verb_map2 :: Map.Map String Verb
> > verb_map2 = Map.fromAscList [ ("GO", Go), ("GET", Get) {- .. -} ]
>
>
> Best wishes
>
> Stephen
> ___
> 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: Parse error

2010-01-17 Thread Maciej Piechotka
On Sun, 2010-01-17 at 18:10 +0800, VoidPrayer wrote:
> let ...
> in ...
> 
> I guess GHC is finding where "in" is.

Except that:

main = do l <- getLine
  let l' = lines l
  print l'

Is perfectly valid without in. Similary:

something = proc (x, y) -> do x' <- someArrow -< x
  let z = x + y + x'
  returnA -< z

Regards


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


Re: [Haskell-cafe] Parsers for Text Adventures

2010-01-17 Thread Daniel Fischer
Am Sonntag 17 Januar 2010 14:30:36 schrieb Mark Spezzano:
> Hi,
>
> I am writing a Text Adventure game in Haskell (like Zork)
>
> I have all of the basic parser stuff written as described in Hutton's
> Programming in Haskell and his associated papers. (I'm trying to avoid
> using 3rd party libraries, so that I can learn this myself)
>
> Everything that I have works (so far...) except for the following
> problem:
>
> I want to define a grammar using a series of Verbs like this:
>
> data Verb = Go | Get | Jump | Climb | Give etc, etc deriving (Show,
> Read)
>
> and then have my parser "get" one of these Verb tokens if possible;
> otherwise it should do something (?) else like give an error message
> stating "I don't know that command"
>
> Now, Hutton gives examples of parsing strings into string whereas I want
> to parse Strings into my Verbs
>
> So, if the user types "get sword" then it will tokenise "get" as type
> Verb's data constructor Get and perhaps "sword" into a Noun called Sword

But the Read instance can only read "Get", not "get".
You'd have to capitalise the input to work with derived Read instances.

>
> My parser is defined like this:
>
> newtype Parser a = Parser (String -> [(a, String)])
>
> So I CAN give it a Verb type
>
> but this is where I run into a problem
>
> I've written a Parser called keyword
>
> keyword :: Parser Verb
> keyword = do x <- many1 letter
 case reads x of
   [(verb,"")] -> return verb
   _ -> fail "No verb"

fails gracefully (assuming your Monad instance for Parser has

fail _ = Parser (\_ -> [])

).

>   return (read x)
>
> (read this as
> "take-at-least-one-alphabetic-letter-and-convert-to-a-Verb-type")
>
> which DOES work provided that the user types in one of my Verbs. If they
> don't, well, the whole thing fails with an Exception and halts
> processing, returning to GHCi prompt.
>
> Question: Am I going about this the right way? I want to put together
> lots of "data" types like Verb and Noun etc so that I can build a kind
> of "BNF grammar".
>
> Question: If I am going about this the right way then what do I about
> the "read x" bit failing when the user stops typing in a recognised
> keyword. I could catch the exception, but typing an incorrect sentence
> is just a typo, not really appropriate for an exception, I shouldn't
> think. If it IS appropriate to do this in Haskell, then how do I catch
> this exception and continue processing.

You could try guessing what the user meant (cf. Levenshtein distance) for 
added comfort.
Or you could ask for corrected input immediately when parsing an input 
fails.
With the graceful failing of the parse as above, that doesn't need 
exceptions.

If you think catching exceptions might be preferable after all, take a look 
at Control.Exception.

>
> I thought that exceptions should be for exceptional circumstances, and
> it would seem that I might be misusing them in this context.
>
> Thanks
>
> Mark Spezzano

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


Re: [Haskell-cafe] Parsers for Text Adventures

2010-01-17 Thread Stephen Tetley
Hello Mark


[ Literate haskell follows... ]

> module Verb where

> import qualified Data.Map as Map
> import Data.Char


> data Verb = Go | Get | Jump | Climb | Give deriving (Show, Read)

I wouldn't use read instead something either a simple function:

> verb :: String -> Maybe Verb
> verb "Go"  = Just Go
> verb "Get" = Just Get
> verb _ = Nothing


Or possible a Map:

> verb2 :: String -> Maybe Verb
> verb2 s = Map.lookup s verb_map

> verb_map :: Map.Map String Verb
> verb_map = Map.fromAscList [ ("Go", Go), ("Get", Get) {- .. -} ]


You could then do more about say case sensitivity - e.g. add ("get",Get) etc
or always convert to upper before querying the map.


> verb3 :: String -> Maybe Verb
> verb3 s = Map.lookup (map toUpper s) verb_map2

> verb_map2 :: Map.Map String Verb
> verb_map2 = Map.fromAscList [ ("GO", Go), ("GET", Get) {- .. -} ]


Best wishes

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


Re: [Haskell-cafe] Parsers for Text Adventures

2010-01-17 Thread Luke Palmer
On Sun, Jan 17, 2010 at 6:30 AM, Mark Spezzano  wrote:

> I've written a Parser called keyword
>
> keyword :: Parser Verb
> keyword = do x <- many1 letter
>return (read x)
>
> (read this as
> "take-at-least-one-alphabetic-letter-and-convert-to-a-Verb-type")
>
> which DOES work provided that the user types in one of my Verbs. If they
> don't, well, the whole thing fails with an Exception and halts processing,
> returning to GHCi prompt.
>
> Question: Am I going about this the right way? I want to put together lots
> of "data" types like Verb and Noun etc so that I can build a kind of "BNF
> grammar".
>

Sounds good to me.


>
> Question: If I am going about this the right way then what do I about the
> "read x" bit failing when the user stops typing in a recognised keyword. I
> could catch the exception, but typing an incorrect sentence is just a typo,
> not really appropriate for an exception, I shouldn't think. If it IS
> appropriate to do this in Haskell, then how do I catch this exception and
> continue processing.
>

In my opinion, traditional exceptions have no place in Haskell.  In some
others' opinions, they have their place, but are infrequently used.  In any
case, you're right, this is not the time to catch an exception.

This is a usability failure on the part of the Haskell prelude.  read should
have the type Read a => String -> Maybe a, because failure is possible.  You
can write a proper version:

import Data.Maybe (listToMaybe)
maybeRead :: Read a => String -> Maybe a
maybeRead = fmap fst . listToMaybe . reads

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


Re: [Haskell-cafe] Re: AlternativePrelude extension

2010-01-17 Thread Taru Karttunen
Excerpts from Roel van Dijk's message of Sun Jan 17 13:50:22 +0200 2010:
> The "extensions" field in a cabal package description is a bit tricky.
> The documentation states "A list of Haskell extensions used by every
> module". This might give the impression that it documents the various
> extensions used in a package. What it actually does is enable those
> extensions for every module.
> 
> Duncan's comments on this ticket are enlightening:
> http://hackage.haskell.org/trac/hackage/ticket/370
> 
> I think the idea of adding a new field "used-extensions" warrants a
> separate ticket.

Why not have Cabal autogenerate that information?

Hackage already displays generated info like "Built on" and thus
it should be doable. i.e.

1) Scan all the source files used for extension pragmas
2) Generate a list of those
3) Include that on Hackage

The functionality needed for this is also needed for validating
the proposed used-extensions field is correct, and thus not harder to
implement.

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


Re: [Haskell-cafe] Dependency trickery

2010-01-17 Thread Felipe Lessa
On Sun, Jan 17, 2010 at 10:09:14AM +, Andrew Coppin wrote:
> Suppose I write some code that can work with Gtk2hs or wxHaskell.
> How do I go about making that into a package?
>
> Specifically, how do I make it so that you don't have to install
> Gtk2hs *and* wxHaskell to build it? Do I have to actually make it
> into two seperate packages to do that?

You just need to add a flag 'gtk2hs' and then construct the
Build-Depends depending on the value of the flag.  However, if
e.g. that flag is by default True, then users of wxHaskell will
have to manually change its value.  I.e. it is not automatic
based on what the user has on his system.

> Also, supposing we have another package which requires the first,
> but doesn't care whether it's using Gtk2hs or wxHaskell. How do I do
> that? Obviously the answer depends on what happens in the previous
> step. If I make two seperate packages, for example, and they both
> export the same module, can I just add optional dependancies on
> both? Does Cabal support that?

Just depend on the package :), how the first package was compiled
is out of the scope of the second one.

> Not that I'm attempting to *do* this, you understand. I'd just like
> to know if it's possible...

Another possibility is to factor out your API into an abstract
interface (maybe using type classes).  Then you would have

  firstpackage-base
  firstpackage-wx
  firstpackage-gtk
  secondpackage (depending on firstpackage-base)

But then you only factor your problem to your outmost package,
say,

  myapp (depends on -wx or -gtk depending on a flag)

HTH,

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


Re: [Haskell-cafe] Parse error

2010-01-17 Thread Hans Aberg

On 17 Jan 2010, at 11:44, Andrew Coppin wrote:


Urg, but that's *ugly*. Is there no way I can reduce the amount of
indentation to something more reasonable?


main = do
 putStrLn "Line 1"
 putStrLn "Line 2"

 let xs = do
   x <- [1..10]
   y <- [1..10]
   return (x+y)

 print xs

That better?


It's an improvement. It's still not pretty, but I guess that's as  
good as it's going to get...


Maybe this is an instance of Haskell trying to tell me "if you need  
to write a 20-line do-block in the middle of your function, you're  
doing it wrong".


Haskell starts the new indentation level where the following lexeme is  
(Haskell-98 Report, sec. 2.7). So to reduce indentation, one must  
start a new line (already mentioned in this thread). This works in Hugs:

main =
  do
  putStrLn "Line 1"
  putStrLn "Line 2"

  let
xs =
  do
  x <- [1..10]
  y <- [1..10]
  return (x+y)

  print xs

The "xs" on a new line looks a bit unusual, and it takes a bit more  
vertical space, but one gets nice indentation levels.


  Hans


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


[Haskell-cafe] Parsers for Text Adventures

2010-01-17 Thread Mark Spezzano
Hi,

I am writing a Text Adventure game in Haskell (like Zork)

I have all of the basic parser stuff written as described in Hutton's 
Programming in Haskell and his associated papers. (I'm trying to avoid using 
3rd party libraries, so that I can learn this myself)

Everything that I have works (so far...) except for the following problem:

I want to define a grammar using a series of Verbs like this:

data Verb = Go | Get | Jump | Climb | Give etc, etc deriving (Show, Read)

and then have my parser "get" one of these Verb tokens if possible; otherwise 
it should do something (?) else like give an error message stating "I don't 
know that command"

Now, Hutton gives examples of parsing strings into string whereas I want to 
parse Strings into my Verbs

So, if the user types "get sword" then it will tokenise "get" as type Verb's 
data constructor Get and perhaps "sword" into a Noun called Sword

My parser is defined like this:

newtype Parser a = Parser (String -> [(a, String)])

So I CAN give it a Verb type

but this is where I run into a problem

I've written a Parser called keyword

keyword :: Parser Verb
keyword = do x <- many1 letter
return (read x)

(read this as "take-at-least-one-alphabetic-letter-and-convert-to-a-Verb-type")

which DOES work provided that the user types in one of my Verbs. If they don't, 
well, the whole thing fails with an Exception and halts processing, returning 
to GHCi prompt.

Question: Am I going about this the right way? I want to put together lots of 
"data" types like Verb and Noun etc so that I can build a kind of "BNF grammar".

Question: If I am going about this the right way then what do I about the "read 
x" bit failing when the user stops typing in a recognised keyword. I could 
catch the exception, but typing an incorrect sentence is just a typo, not 
really appropriate for an exception, I shouldn't think. If it IS appropriate to 
do this in Haskell, then how do I catch this exception and continue processing. 

I thought that exceptions should be for exceptional circumstances, and it would 
seem that I might be misusing them in this context.

Thanks

Mark Spezzano

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


Re: [Haskell-cafe] ANN: amqp-0.1

2010-01-17 Thread Ross Paterson
On Sun, Jan 17, 2010 at 12:35:08PM +0100, Holger Reinhardt wrote:
> Get it here: http://hackage.haskell.org/package/amqp
> 
> For some reason it doesn't compile on Hackage. It says "At least the following
> dependencies are missing: network-bytestring >=0.1.2". Is there a way to solve
> this?

Sorry, that was a glitch in the upgrade to GHC 6.12.1.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: atom-0.1.3

2010-01-17 Thread miaubiz



Tom Hawkins-2 wrote:
> 
> period 20 $ atom "checkSomeStuff" $ do
>   cond ok
>   assert "A" a
>   assert "B" b
>   cover  "C" c
> 

I am trying to generate a square wave.  Here's the code:

square <- bool "square" False

period 2 $ atom "square high" $ phase 0 $ do
square <== true
assert "square is low" $ not_ $ value square

period 2 $ atom "square low" $ phase 1 $ do
square <== false
assert "square is high" $ value square


The tests fail every cycle because after each rule one of them is wrong.

What would be the right way to formulate this code? Use cond on the rules?

period 2 $ atom "square high" $ phase 0 $ do
cond $ not_ $ value square
square <== true
cover "lowSquare" true
assert "square is low" $ not_ $ value square

period 2 $ atom "square low" $ phase 1 $ do
cond $ value square
square <== false
cover "highSquare" true
assert "square is high" $ value square


as an aside, in Unit.hs:
 covered = [ words line !! 1 | line <- lines log, isPrefixOf
"covered:" line ]

because covered is the second word of the line from the log, the name of
cover must be a single word. assertions and atoms can contain spaces as far
as I can tell.

br, miau
-- 
View this message in context: 
http://old.nabble.com/ANN%3A-atom-0.1.3-tp26624813p27198213.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Re: AlternativePrelude extension

2010-01-17 Thread Roel van Dijk
On Sun, Jan 17, 2010 at 12:27 PM, Ketil Malde  wrote:
> I think there might be justification for doing it multiple places.  The
> cabal file tells you what is required to build the package, the pragmas
> what is required to build each source file.
>
> Perhaps cabal should complain when source files use pragmas not
> declared in the cabal file, and perhaps also warn about options in the
> cabal file not used in any source file.

The "extensions" field in a cabal package description is a bit tricky.
The documentation states "A list of Haskell extensions used by every
module". This might give the impression that it documents the various
extensions used in a package. What it actually does is enable those
extensions for every module.

Duncan's comments on this ticket are enlightening:
http://hackage.haskell.org/trac/hackage/ticket/370

I think the idea of adding a new field "used-extensions" warrants a
separate ticket.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language simplicity

2010-01-17 Thread Andrew Coppin

Eduard Sergeev wrote:

OK, my version of meaningless statistics:

C++ (ISO/IEC 14882:1998(E)): 325 pages (712 including standard libraries)
C# (ECMA-334): 505 pages (language only)
Java: 450 pages (language only?)
Scala (2.7): 125 pages (157 including standard library)
Eiffel (ECMA-367): 160 pages (language only) 
ANSI SQL-92: 685 pages (language only)

Haskell-98: 77 pages (247 including Prelude)
Erlang (4.7.3) 162 pages (251 including builtin functions) 
Scheme (R5RS): 17 pages (45 including standard procedures)
  


Interesting. So Scheme is the shortest by a mile, followed by Haskell 
'98, followed by another big gap.


Now is that because Haskell is simple? Or is it because the Report 
assumes that you already know what functional programming and 
Milner-Hindley type inference are?


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


[Haskell-cafe] Presentation about ICFP'09 programming contest

2010-01-17 Thread Janis Voigtländer

Hi Haskell folk,

If you are in Madrid tomorrow (Monday), you will likely not want to miss
the video presentation by Andy Gill and his group about the techniques
behind their running the ICFP'09 programming contest:

http://www.program-transformation.org/PEPM10/SpecialFeature

The presentation is scheduled to start 17:15, in the PEPM workshop room.

Ciao,
Janis.

--
Jun.-Prof. Dr. Janis Voigtländer
http://www.iai.uni-bonn.de/~jv/
mailto:j...@iai.uni-bonn.de
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: amqp-0.1

2010-01-17 Thread Holger Reinhardt
Hi,

I've built an AMQP library. It currently only works with RabbitMQ and
supports most of the 0-8 spec. If you don't know that AMQP is, this is a
good introduction:
http://blogs.digitar.com/jjww/2009/01/rabbits-and-warrens/
I have not done much testing, so this should be regarded as alpha quality.

Get it here: http://hackage.haskell.org/package/amqp

For some reason it doesn't compile on Hackage. It says "At least the
following dependencies are missing: network-bytestring >=0.1.2". Is there a
way to solve this?

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


Re: [Haskell-cafe] Re: AlternativePrelude extension

2010-01-17 Thread Ketil Malde
Maciej Piechotka  writes:

>> However, the option to set language extension globally is still
>> available, either as an option to the compiler when building, or in
>> the cabal file describing the package.

> Hmm. Since the extensions should be specified in Cabal anyway (at least
> I guess it does some detection if compiler supports them) shouldn't it
> be specified in one place?

I think there might be justification for doing it multiple places.  The
cabal file tells you what is required to build the package, the pragmas
what is required to build each source file.

Perhaps cabal should complain when source files use pragmas not
declared in the cabal file, and perhaps also warn about options in the
cabal file not used in any source file.

-k (who didn't check the current state of affairs)
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language simplicity

2010-01-17 Thread jur



Andrew Coppin wrote:


OK people, it's random statistics time!



OK, my version of meaningless statistics:



Java: 450 pages (language only?)

Which version is this?
The version of the Java Language Specification (version 3.0, 2005) I  
am currently reading has 684 pages.

I'd prefer to read only 450.

Jur

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


[Haskell-cafe] Haskell Weekly News: Issue 146 - January 17, 2010

2010-01-17 Thread jfredett

---
Haskell Weekly News
http://sequence.complete.org/hwn/20100117
Issue 146 - January 17, 2010
---
   Welcome to issue 146 of HWN, a newsletter covering developments in the
   [1]Haskell community.

   This has been a pretty light week in terms of discussion and
   announcments, but even in this comparative news lull we have the
   release of several new versions of packages. Inlcluding the start of a
   new IDE, some new job and graduate program openings, and some really
   excellent blog noise. Until next week, Haskellers, your Haskell Weekly
   News.

Announcements

   haskell-src-exts 1.7.0. Niklas Broberg [2]announced a new release of
   haskell-src-exts

   Lite Haskell IDE. Mambo Banda [3]announced a new Haskell IDE, as part
   of his effort to learn Haskell.

   Functional Programming Bibliography. James Russell [4]announced the
   Functional Programming Bibliography, a new resource for the FP
   community. It, though in it's early stages, contains oer 1500
   references (most of which are Haskell-related) to resources within the
   Functional Programming World.

   hakyll-1.0. Jasper Van der Jeugt [5]announced the release of version
   1.0 of his static site generation tool, hakyll. From all (one) of us at
   the HWN, contragulations on the big 1.0!

   afv-0.0.0. Tom Hawkins [6]announced the initial release of 'Atom's
   Formal Verifier', a tool for verifying C code generated by Atom

   chp-2.0.0, chp-plus-1.0.0. Neil Brown [7]announced released new
   versions of his Comminicating Haskell Processes (CHP) packages. CHP is
   a message-passing concurrency library for Haskell. The major change in
   this version is a split of CHP into two packages, one containing core
   functionality, and one containing additional capabilities.

   Update for type-level library (0.2.4). Seyed Hosein Attarzadeh Niaki
   [8]announced a new version of his type-level library for type-level
   programming. This is a minor update to fix compatibility issues with
   dependencies.

   Two PhD positions in theoretical computer science. Alexandra Silva
   [9]announced vacancies for PhD positions in theoretical computer
   science at Leiden University.

   HaXml-1.20.1. Malcolm Wallace [10]announced a new, stable release of
   HaXml

   AST 2010 reminder--call for papers and presentations. John Hughes
   [11]reminded us of the AST 2010 call for papers and presentations. The
   submission deadline is only one week away.

   Job at Mylife. Julien Verlaguet [12]announced an availabiity for an
   OCaml developer at MyLife.

   Open Position (PhD student or Postdoc), U Tubingen, Germany. Torsten
   Grust [13]announced an open PhD/Postdoc position at the University of
   Tubingen in Germany. (ED: Apologies for the improper 'u' -- it should
   have an umlaut, but the compilation software is not cooperating)

   Palindromes 0.2. Johan Jeuring [14]announced a new release of the
   Palindromes package, including many new features and upgrades.

Discussion

   From records to a type class. Taru Karttunen [15]asked about turning
   records into type classes, in an effort to make his bindings for Fuse
   more elegant.

   AlternativePrelude extension. Sjur Gjostein Karevoll [16]suggested a
   language pragma for alternative preludes. (ED: Again, apologies for the
   look-alike, but improper character).

Blog noise

   [17]Haskell news from the [18]blogosphere. Blog posts from people new
   to the Haskell community are marked with >>>, be sure to welcome them!
 * Holumbus: [19]Linking Hayoo! Search Results.
 * Jeff Heard: [20]SPDE, Semi-functional programming for Processing.
 * Neil Mitchell: [21]Using .ghci files to run projects.
 * Neil Mitchell: [22]Better .ghci files.
 * Neil Brown: [23]Darcs.
 * Neil Brown: [24]Splitting CHP.
 * Darcs: [25]darcs weekly news #50.
 * Bryan O'Sullivan: [26]Progress on GHC's I/O manager.
 * Michael Snoyman: [27]New blog address.
 * Conal Elliot: [28]Exact Numeric Integration. I had missed this one
   last week (amidst the myriad, I failed to see it), so it is
   presented in this week's edition.

Quotes of the Week

 * Jafet:  closures are a poor man's object  objects
   are a poor man's closure  objects are a rich man's
   structs  Poor programmers should start unions
 * monochrom: Time flies like an Arrow. Space leaks like a Monad.
 * monochrom: Haskell already has natural language support. Just
   switch your natural language to simple-typed lambda calculus.
 * edwardk: @remember Baugn @remember lambdabot fasta says: I think
   the @remember command is way overused.
 * Berengal: data Neither a b = Left | Right
 * Cale: Removing monad comprehensions was actually the snowball which
   caused the a

Re: [Haskell-cafe] Parse error

2010-01-17 Thread Andrew Coppin

Daniel Fischer wrote:

Am Sonntag 17 Januar 2010 11:33:45 schrieb Andrew Coppin:
  

Urg, but that's *ugly*. Is there no way I can reduce the amount of
indentation to something more reasonable?




main = do
  putStrLn "Line 1"
  putStrLn "Line 2"

  let xs = do
x <- [1..10]
y <- [1..10]
return (x+y)

  print xs

That better?
  


It's an improvement. It's still not pretty, but I guess that's as good 
as it's going to get...


Maybe this is an instance of Haskell trying to tell me "if you need to 
write a 20-line do-block in the middle of your function, you're doing it 
wrong".


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


Re: [Haskell-cafe] Parse error

2010-01-17 Thread Ross Paterson
On Sun, Jan 17, 2010 at 10:33:45AM +, Andrew Coppin wrote:
> Tony Morris wrote:
> >main = do
> > putStrLn "Line 1"
> > putStrLn "Line 2"
> >
> > let xs = do x <- [1..10]
> > y <- [1..10]
> > return (x+y)
> >
> > print xs
> 
> Urg, but that's *ugly*. Is there no way I can reduce the amount of
> indentation to something more reasonable?

Sure: start a new line and indentation level after every where, let, do or of.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parse error

2010-01-17 Thread Daniel Fischer
Am Sonntag 17 Januar 2010 11:33:45 schrieb Andrew Coppin:
> Tony Morris wrote:
> > No, but there's a specific reason why GHC consistently refuses to
> > accept your perfectly unreasonable code snippet :)
>
> She sells csh on the sea shore. :-)
>
> > GHC accepts the following perfectly reasonable code snippet:
> >
> > main = do
> >  putStrLn "Line 1"
> >  putStrLn "Line 2"
> >
> >  let xs = do x <- [1..10]
> >  y <- [1..10]
> >  return (x+y)
> >
> >  print xs
>
> Urg, but that's *ugly*. Is there no way I can reduce the amount of
> indentation to something more reasonable?


main = do
  putStrLn "Line 1"
  putStrLn "Line 2"

  let xs = do
x <- [1..10]
y <- [1..10]
return (x+y)

  print xs

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


Re: [Haskell-cafe] Parse error

2010-01-17 Thread Andrew Coppin

Tony Morris wrote:

No, but there's a specific reason why GHC consistently refuses to accept
your perfectly unreasonable code snippet :)
  


She sells csh on the sea shore. :-)


GHC accepts the following perfectly reasonable code snippet:

main = do
 putStrLn "Line 1"
 putStrLn "Line 2"

 let xs = do x <- [1..10]
 y <- [1..10]
 return (x+y)

 print xs
  


Urg, but that's *ugly*. Is there no way I can reduce the amount of 
indentation to something more reasonable?


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


Re: [Haskell-cafe] Parse error

2010-01-17 Thread Daniel Fischer
Am Sonntag 17 Januar 2010 11:05:47 schrieb Andrew Coppin:
> Is there a specific reason why GHC consistently refuses to accept the
> following perfectly reasonable code snippet?

Yes, you violated the layout rule.

>
> main = do
>   putStrLn "Line 1"
>   putStrLn "Line 2"
>
>   let xs = do
> x <- [1..10]
> y <- [1..10]
> return (x+y)
>
>   print xs
>
> No matter which way I rearrange this, it *insists* that there's a parse
> error. This is very frustrating, given that it's utterly clear what I
> want...

It's not.

ACLayout.hs:7:11: Empty 'do' construct

should give a hint (line 7 is "  let xs = do").
The next line after that is indented less than the "xs", so it ends the 
binding for xs (in fact, the entire let binding group) .
You have to indent the lines in the do-block defining xs more than xs 
itself.

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


Re: [Haskell-cafe] Parse error

2010-01-17 Thread Tony Morris
No, but there's a specific reason why GHC consistently refuses to accept
your perfectly unreasonable code snippet :)

GHC accepts the following perfectly reasonable code snippet:

main = do
 putStrLn "Line 1"
 putStrLn "Line 2"

 let xs = do x <- [1..10]
 y <- [1..10]
 return (x+y)

 print xs

Andrew Coppin wrote:
> Is there a specific reason why GHC consistently refuses to accept the
> following perfectly reasonable code snippet?
>
> main = do
>  putStrLn "Line 1"
>  putStrLn "Line 2"
>
>  let xs = do
>x <- [1..10]
>y <- [1..10]
>return (x+y)
>
>  print xs
>
> No matter which way I rearrange this, it *insists* that there's a
> parse error. This is very frustrating, given that it's utterly clear
> what I want...
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Parse error

2010-01-17 Thread VoidPrayer
let ...
in ...

I guess GHC is finding where "in" is.

在 2010年 1月 17日 星期日 18:05:47,Andrew Coppin 寫道:
> Is there a specific reason why GHC consistently refuses to accept the
> following perfectly reasonable code snippet?
> 
> main = do
>   putStrLn "Line 1"
>   putStrLn "Line 2"
> 
>   let xs = do
> x <- [1..10]
> y <- [1..10]
> return (x+y)
> 
>   print xs
> 
> No matter which way I rearrange this, it *insists* that there's a parse
> error. This is very frustrating, given that it's utterly clear what I
> want...
> 
> ___
> 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] Dependency trickery

2010-01-17 Thread Andrew Coppin
Suppose I write some code that can work with Gtk2hs or wxHaskell. How do 
I go about making that into a package?


Specifically, how do I make it so that you don't have to install Gtk2hs 
*and* wxHaskell to build it? Do I have to actually make it into two 
seperate packages to do that?


Also, supposing we have another package which requires the first, but 
doesn't care whether it's using Gtk2hs or wxHaskell. How do I do that? 
Obviously the answer depends on what happens in the previous step. If I 
make two seperate packages, for example, and they both export the same 
module, can I just add optional dependancies on both? Does Cabal support 
that?


Not that I'm attempting to *do* this, you understand. I'd just like to 
know if it's possible...


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


[Haskell-cafe] Parse error

2010-01-17 Thread Andrew Coppin
Is there a specific reason why GHC consistently refuses to accept the 
following perfectly reasonable code snippet?


main = do
 putStrLn "Line 1"
 putStrLn "Line 2"

 let xs = do
   x <- [1..10]
   y <- [1..10]
   return (x+y)

 print xs

No matter which way I rearrange this, it *insists* that there's a parse 
error. This is very frustrating, given that it's utterly clear what I 
want...


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