Re: [Haskell-cafe] Re: Graphical representation of Haskell code

2010-03-24 Thread Mihai Maruseac
Hmm, I may take hints from this conversation to improve the debugger.
My program will draw only the diagrams needed for debugging, it is not
about the programmer needing to draw boxes and wires but about him
understanding his own code :)

On Thu, Mar 25, 2010 at 4:37 AM, Maciej Piechotka  wrote:
> On Wed, 2010-03-24 at 21:33 -0400, Ronald Guida wrote:
>> Those are some very interesting visual languages, Miguel!
>>
>> I remember drawing some diagrams when I was teaching myself Haskell,
>> but I never actually tried to create a formal visual language.  Since
>> my background is in hardware engineering, I would naturally gravitate
>> toward schematic diagrams.  I am also familiar with the graphical
>> programming language of LabView.
>>
>> After reading Miguel's exposition, I thought about how I might draw a
>> picture of map1.
>>
>> map1 :: (a -> b) -> [a] -> [b]
>> map1 f [] = []
>> map1 f (x:xs) = (f x) : map1 f xs
>>
>> map1.png
>> (Image created with Inkscape)
>>
>> Here is what I'm thinking:
>> * Green boxes represent inputs and outputs.
>> * Inputs are always on the left, outputs are always on the right.
>> * Inputs appear in top-to-bottom order.
>> * Data always flows left to right.
>> * Arrows represent data flow.
>> * A named white rectangle represents application of the named
>> function.
>> * A gray rectangle represents a function that arrives through data
>> flow.
>> * A filled-in arrowhead means the data "in" the arrow is to be
>> "unpacked" and used as a function.
>> * A named light-blue rectangle (such as on the left, with a colon in
>> it) represents a pattern match operation.
>>
>> In thinking about this, I can sense that there are MANY issues with
>> using a visual language to represent Haskell.  Some issues I can think
>> of:
>> * How to represent pattern matching?
>> * How to represent partial application?
>> * How to represent data types or class constraints in the diagram?
>> * How to represent a list comprehension or a do statement? (These
>> might require special visual syntax)
>> * Will the data flow always take the form of a directed acyclic graph,
>> so that data never has to flow right-to-left?  (Perhaps there's a way
>> to "tie the knot" and get a cycle in the data flow graph.)
>
> myfix f = let x = f x in x
>
>
>
> f ---\
>          |
>          v
>      /->X-X--+>
>      |       |
>      \---<---/
>
> Unless we rewrite it into:
>
> myfix' f = f (myfix' f)
>
>
> f +---\
>      |                   |
>      |                   v
>      \->X myfix' X->X-X>
>
>> * Whether to create special symbols for certain commonly used
>> functions? (In digital circuit schematics, AND, OR, and NOT gates have
>> special symbols, but most compound circuits are represented with
>> labeled rectangles.)
>>
>> Also, if I want to automatically generate an image from a Haskell
>> function, then my image generator needs to automatically place and
>> route all those boxes.
>>
>> I'll have to give more thought to the other versions of map, and maybe
>> make some more diagrams.
>>
>> -- Ron
>
> 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] ANN: Salvia-1.0.0

2010-03-24 Thread Bernie Pope
On 25 March 2010 14:23, Ivan Miljenovic  wrote:
> On 25 March 2010 12:21, Bernie Pope  wrote:
>>
>> Yes, I tried that, but unfortunately it falls over with:
>>
>> Language/Haskell/TH/Quote.hs:31:12:
>>    Not in scope: data constructor `CharConstr'
>> cabal: Error: some packages failed to install:
>> template-haskell-2.4.0.0 failed during the building phase. The exception was:
>> exit: ExitFailure 1
>
> TH-2.4 comes with/needs GHC 6.12.  The problem here appears to by with
> syb-with-class: using a lower version of that should work, as 0.6.1
> appears to be a compatability release just to get it working on 6.12
> (whereas 0.6 works with 6.10).

Thanks Ivan.

cabal install syb-with-class-0.6 fixed the problem.

I note that you did mention this before, and sorry I missed it the first time.

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


Re: [Haskell-cafe] Using Get monad to efficiently parse byte-stuffed data

2010-03-24 Thread Pom

On 10-03-24 12:44 PM, Paul Johnson wrote:

On 24/03/10 04:36, Pom Monico wrote:

Hello all,

I'm struggling to use the Get monad to efficiently parse the some
binary data of the format below. I simply can't find a way to use the
monad to parse it efficiently.

Binary data is terminated by a 0xFF marker. If the data itself
contains an 0xFF, a 0x00 is byte-stuffed after it to indicate it is
part of the data. An 0xFF followed by a non-zero byte indicates that
it is a real marker and terminates the data and the 0xFF is not part
of the data.
So the only way to find out if you have reached the end of the data is 
to read beyond it?  Yuck!


I haven't used it myself, but I suggest taking a look at Attoparsec, 
which is like Parsec but for bytestrings.  That might be able to 
handle this kind of non-determinism.

Don't know who thought it up but I have to deal with it.

The best I've gotten so far is the code below. In the Get monad, I do a 
"lookAhead getRemainingLazyByteString", call "go s 0 []" to get the 
byte-unstuffed data and #bytes consumed, and then do a "skip consumed" 
to move forward in the Get monad.


It is ugly and slow. I would like to implement this using the Get monad 
without dropping into the ByteString, and also so speed it up. In order 
of most time consuming, the sections are: go, takeToFF, ECS5-4, ECS5-2. 
But I'm also out of ideas without resorting to mutable constructs, 
esoteric tricks, or things that look like it belongs in a .c file.


Pom.

ff00 = {-# SCC "ECS5-8" #-} L.pack [0xff, 0x00]
ff   = {-# SCC "ECS5-9" #-} L.singleton 0xff
takeToFF s = case L.elemIndex 0xff s of
Nothing -> (s, L.empty, L.length s) -- Return entire string
Just x  -> let (h, t) = L.splitAt x s in (h, t, x) -- Split before 0xff
go s n acc
| L.null s= {-# SCC "ECS5-1" #-} (L.concat $ reverse 
acc, n)
| L.isPrefixOf ff00 s = {-# SCC "ECS5-2" #-} go (L.drop 2 s) (n+2) 
(ff:acc)
| L.isPrefixOf ff s   = {-# SCC "ECS5-3" #-} (L.concat $ reverse 
acc, n)
| otherwise   = {-# SCC "ECS5-4" #-} let (h, t, x) = 
takeToFF s in go t (n+x) (h:acc)


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


Re: [Haskell-cafe] ANN: Salvia-1.0.0

2010-03-24 Thread Ivan Miljenovic
On 25 March 2010 12:21, Bernie Pope  wrote:
>
> Yes, I tried that, but unfortunately it falls over with:
>
> Language/Haskell/TH/Quote.hs:31:12:
>    Not in scope: data constructor `CharConstr'
> cabal: Error: some packages failed to install:
> template-haskell-2.4.0.0 failed during the building phase. The exception was:
> exit: ExitFailure 1

TH-2.4 comes with/needs GHC 6.12.  The problem here appears to by with
syb-with-class: using a lower version of that should work, as 0.6.1
appears to be a compatability release just to get it working on 6.12
(whereas 0.6 works with 6.10).

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Graphical representation of Haskell code

2010-03-24 Thread Maciej Piechotka
On Wed, 2010-03-24 at 21:33 -0400, Ronald Guida wrote:
> Those are some very interesting visual languages, Miguel!
> 
> I remember drawing some diagrams when I was teaching myself Haskell,
> but I never actually tried to create a formal visual language.  Since
> my background is in hardware engineering, I would naturally gravitate
> toward schematic diagrams.  I am also familiar with the graphical
> programming language of LabView.
> 
> After reading Miguel's exposition, I thought about how I might draw a
> picture of map1.
> 
> map1 :: (a -> b) -> [a] -> [b]
> map1 f [] = []
> map1 f (x:xs) = (f x) : map1 f xs
> 
> map1.png
> (Image created with Inkscape)
> 
> Here is what I'm thinking:
> * Green boxes represent inputs and outputs.
> * Inputs are always on the left, outputs are always on the right.
> * Inputs appear in top-to-bottom order.
> * Data always flows left to right.
> * Arrows represent data flow.
> * A named white rectangle represents application of the named
> function.
> * A gray rectangle represents a function that arrives through data
> flow.
> * A filled-in arrowhead means the data "in" the arrow is to be
> "unpacked" and used as a function.
> * A named light-blue rectangle (such as on the left, with a colon in
> it) represents a pattern match operation.
> 
> In thinking about this, I can sense that there are MANY issues with
> using a visual language to represent Haskell.  Some issues I can think
> of:
> * How to represent pattern matching?
> * How to represent partial application?
> * How to represent data types or class constraints in the diagram?
> * How to represent a list comprehension or a do statement? (These
> might require special visual syntax)
> * Will the data flow always take the form of a directed acyclic graph,
> so that data never has to flow right-to-left?  (Perhaps there's a way
> to "tie the knot" and get a cycle in the data flow graph.)

myfix f = let x = f x in x



f ---\
  |
  v
  /->X-X--+>
  |   |
  \---<---/

Unless we rewrite it into:

myfix' f = f (myfix' f)


f +---\
  |   |
  |   v
  \->X myfix' X->X-X>

> * Whether to create special symbols for certain commonly used
> functions? (In digital circuit schematics, AND, OR, and NOT gates have
> special symbols, but most compound circuits are represented with
> labeled rectangles.)
> 
> Also, if I want to automatically generate an image from a Haskell
> function, then my image generator needs to automatically place and
> route all those boxes.
> 
> I'll have to give more thought to the other versions of map, and maybe
> make some more diagrams.
> 
> -- Ron

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Graphical representation of Haskell code

2010-03-24 Thread Ronald Guida
On Wed, Mar 24, 2010 at 9:47 PM, Richard O'Keefe  wrote:

>
> On Mar 25, 2010, at 2:33 PM, Ronald Guida wrote:
> ... a version of map as text ...
> ... a diagram ...
>
> The thing that strikes me forcibly is that the diagram
> is much bigger than the text.  Not only that, but if
> I am reading it correctly, the text has three lines,
> a type specification and two cases, and the diagram
> covers only one of the two cases.
>

I agree, absolutely!  One of the things I don't like about schematics (for
digital circuits anyway) is the fact that a schematic is often bigger than
the corresponding VHDL code, and VHDL is a *very* verbose hardware design
language.  On the other hand, sometimes one can visually "read" a schematic
faster than reading the corresponding code.  My preference is to describe
digital circuits using hardware design language.


> This isn't Ronald Guida's fault.  In fact his is a very
> nice looking diagram, and I could figure it out without
> his explanation of the notation, *given* the textual
> version to start from.
>
> I've seen several visual programming tools, including
> e-Toys in Squeak, and they tend to be really cool ways
> to quickly build programs with trivial structures.
>
> (I did not say trivial programs: you can build useful
> programs that do highly non-trivial things, when the
> things that are primitives _for the notation_ are
> capable enough.  Some data mining products have visual
> wire-up-these-tools-into-a-workflow, for example.)
>

I find it easier to "type" what I want to do, using a textual programming
language, rather than having to "drag and drop" and then draw lots of
wires.  I feel the bigger (rhetorical) question is: At the level of code,
what good are visual programming languages?  (To clarify, I know that
diagrams are indispensable for describing designs.  The question pertains to
actual source code.)

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


Re: [Haskell-cafe] Graphical representation of Haskell code

2010-03-24 Thread Richard O'Keefe


On Mar 25, 2010, at 2:33 PM, Ronald Guida wrote:
... a version of map as text ...
... a diagram ...

The thing that strikes me forcibly is that the diagram
is much bigger than the text.  Not only that, but if
I am reading it correctly, the text has three lines,
a type specification and two cases, and the diagram
covers only one of the two cases.

This isn't Ronald Guida's fault.  In fact his is a very
nice looking diagram, and I could figure it out without
his explanation of the notation, *given* the textual
version to start from.

I've seen several visual programming tools, including
e-Toys in Squeak, and they tend to be really cool ways
to quickly build programs with trivial structures.

(I did not say trivial programs: you can build useful
programs that do highly non-trivial things, when the
things that are primitives _for the notation_ are
capable enough.  Some data mining products have visual
wire-up-these-tools-into-a-workflow, for example.)


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


Re: [Haskell-cafe] Graphical representation of Haskell code

2010-03-24 Thread Ronald Guida
Those are some very interesting visual languages, Miguel!

I remember drawing some diagrams when I was teaching myself Haskell, but I
never actually tried to create a formal visual language.  Since my
background is in hardware engineering, I would naturally gravitate toward
schematic diagrams.  I am also familiar with the graphical programming
language of LabView.

After reading Miguel's exposition, I thought about how I might draw a
picture of map1.

map1 :: (a -> b) -> [a] -> [b]
map1 f [] = []
map1 f (x:xs) = (f x) : map1 f xs

[image: map1.png]
(Image created with Inkscape)

Here is what I'm thinking:
* Green boxes represent inputs and outputs.
* Inputs are always on the left, outputs are always on the right.
* Inputs appear in top-to-bottom order.
* Data always flows left to right.
* Arrows represent data flow.
* A named white rectangle represents application of the named function.
* A gray rectangle represents a function that arrives through data flow.
* A filled-in arrowhead means the data "in" the arrow is to be "unpacked"
and used as a function.
* A named light-blue rectangle (such as on the left, with a colon in it)
represents a pattern match operation.

In thinking about this, I can sense that there are MANY issues with using a
visual language to represent Haskell.  Some issues I can think of:
* How to represent pattern matching?
* How to represent partial application?
* How to represent data types or class constraints in the diagram?
* How to represent a list comprehension or a do statement? (These might
require special visual syntax)
* Will the data flow always take the form of a directed acyclic graph, so
that data never has to flow right-to-left?  (Perhaps there's a way to "tie
the knot" and get a cycle in the data flow graph.)
* Whether to create special symbols for certain commonly used functions? (In
digital circuit schematics, AND, OR, and NOT gates have special symbols, but
most compound circuits are represented with labeled rectangles.)

Also, if I want to automatically generate an image from a Haskell function,
then my image generator needs to automatically place and route all those
boxes.

I'll have to give more thought to the other versions of map, and maybe make
some more diagrams.

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


Re: [Haskell-cafe] ANN: Salvia-1.0.0

2010-03-24 Thread Bernie Pope
On 22 March 2010 11:05, Carter Schonwald  wrote:
> apparently sometimes even though cabal can figure out the dependencies for a
> package you want, it gets confused (or something) when it needs to figure
> out the "transitive" dependencies (that which needs to be installed for the
> direct dependencies to also install). So  try doing a cabal install of that
> version of template  haskell with the explicit version
> cabal install template-haskell-2.4.0.0
> that should solve it

Yes, I tried that, but unfortunately it falls over with:

Language/Haskell/TH/Quote.hs:31:12:
Not in scope: data constructor `CharConstr'
cabal: Error: some packages failed to install:
template-haskell-2.4.0.0 failed during the building phase. The exception was:
exit: ExitFailure 1

In the version of Data.Data on my machine there does not appear to be
a CharConstr.

It looks to me like there is an incorrect dependency in Template Haskell.

I can see from the hackage build logs that I'm not the only one who
has this problem. I will report a bug.

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


[Haskell-cafe] Re: Using Get monad to efficiently parse byte-stuffeddata

2010-03-24 Thread Tim Attwood

Going through the data using getWord8 is a no-go. It is just too slow.
My solution so far has been to get the underlying bytestring and work
with that, but obviously defeats the purpose of using the Get monad.
What might be a better solution?


hGetArray with IOUArrays goes perty fast.

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


Re: [Haskell-cafe] Graphical representation of Haskell code

2010-03-24 Thread Dupont Corentin
Hello,
Very interresting.
Visual Haskell seems to be very close to the thing i imagined.
Mihai what do you think?
Unfortunatly i cannot find it on the web!
There is something for MS Visual Studio but i don't think this is the
same...

Corentin



On Thu, Mar 25, 2010 at 12:07 AM, Miguel Vilaca wrote:

> Hi all,
>
> Concerning INblobs, it's again online; a fire damaged the cable that links
> the university to the world!!
> I don't update the tool for a long time... but I'll take a look on that.
>
> Concerning visual functional programming, see this small chapter of my
> thesis about some of the existing languages.
>
>
> There are more subtleties on the visual side than those expected!!
>
> If you also consider debugging tools, take a look on Ghood
> http://hackage.haskell.org/package/GHood
>
> best regards
> Miguel Vilaça
>
> A 2010/03/23, às 05:31, Ronald Guida escreveu:
>
> On Mon, Mar 22, 2010 at 7:02 PM, Dupont Corentin
>  wrote:
>
> Hello, I’m relatively new to Haskell.
>
> I’m wondering if it exist a tool to graphically represent Haskell code.
>
> ...
>
> Let’s try to do it on a simple example, as an exercise:
>
> f = Map (+1)
>
>
> Your graphic for "f = map (+1)" seems much more complex than the
> corresponding code.  I would agree with Ivan Miljenovic:
>
> I'm of the opinion that unless you just use it on small snippets,
>
> the generated images will be too large and unwieldy.
>
>
> The first question I would ask is /why/ would you like to visualize
> some Haskell code?  If you want to see the high-level structure of
> a complex program, try SourceGraph. (I have never used it though.)
>
> On the other hand, if you are trying to visualize Haskell as part of
> your efforts to learn the language, then I believe it would be best to
> draw diagrams by hand, rather than relying on an automated tool.
> The kinds of things that you'll want to depict are probably going to
> vary considerably, depending on what you're trying to understand.
>
> Consider a few different implementations of the "map" function:
>
>  -- version 1: recursion
>  map1 :: (a -> b) -> [a] -> [b]
>  map1 f [] = []
>  map1 f (x:xs) = (f x) : map1 f xs
>
>  -- version 2: fold
>  map2 :: (a -> b) -> [a] -> [b]
>  map2 f = foldr ((:) . f) []
>
>  -- version 3: continuation passing style
>  map3 :: (a -> b) -> [a] -> [b]
>  map3 f xs = map' (\x y -> f x : y) xs
>where
>  map' k [] = []
>  map' k (y:ys) = k y  (map' k ys)
>
>  -- version 4: list comprehension
>  map4 :: (a -> b) -> [a] -> [b]
>  map4 f xs = [f x | x <- xs]
>
>  -- version 5: list monad
>  map5 :: (a -> b) -> [a] -> [b]
>  map5 f xs = xs >>= (return . f)
>
> These all do exactly the same thing, but each one uses different
> techniques.  If I'm trying to learn (or teach) Haskell, I would
> probably need a slightly different visual "language" for each one
> in order to capture the most relevant concepts in a useful way.
> How would you visualize them?
>
> @Mihai Maruseac:
> I think a visual debugger would be a wonderful idea.  You may want
> to consider how a visual debugger would work with each of these
> versions of map.
>
> :-) You might also consider several versions of factorial :-)
> http://www.willamette.edu/~fruehr/haskell/evolution.html
>
> -- Ron
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] State of the Haskell Web Application Stack

2010-03-24 Thread Alp Mestanogullari
gitit [1] is happstack based and is very impressive -- you may want to read
its code to see how you can build web applications using happstack (not
*on*, for gitit).

[1] http://gitit.net/


> On Tue, Mar 23, 2010 at 7:05 PM, Ozgun Ataman  wrote:
>
>> Greetings all.
>>
>> I have been for quite some time trying to assess the feasibility of using
>> Haskell in relatively large, high volume, high availability, long-running
>> web application projects. I have enjoyed learning and using Haskell very
>> much for the past year and I often find myself missing various language
>> features when reasoning about alternatives like Ruby (on Rails). If I can
>> identify the right set of tools for the job, I would really like to take the
>> plunge and make Haskell my standard go-to language in web applications.
>>
>> Here are the couple of key questions that I wanted get your feedback on:
>>
>>
>>1. Do you consider Haskell and its environment of libraries ready for
>>prime time in web app development as defined above?
>>2. What collection of libraries would you use in such an effort?
>>3. What are the up and coming packages/technologies in Haskell-land
>>you would watch out for?
>>
>>
>> Also, here are some core requirements that I would define for such a
>> project:
>>
>>
>>- Ease/speed of development in both back and front-ends, minimal
>>boilerplate
>>- Extendability and flexibility in iterative development
>>- Robustness and reliability in production environment
>>- High performance
>>- Scalability
>>- Ability to interface with new technologies in the future: Cassandra,
>>Redis, memcached, etc.
>>- Ease of implementing common/reusable features across web
>>applications: user authentication, S3 file uploads, thumbnail/image
>>handling, exception notifications, etc.
>>
>>
>> In terms of libraries, I can think of a few key components (as pointed out
>> by several others before) that one would need to arrange:
>>
>>
>>- Choice of server (happstack vs. alternatives)
>>- Templating (xhtml vs. file templates vs. newer efforts like
>>BlazeHtml)
>>- Data/storage layer: HDBC vs. HaskellDB vs. others
>>
>>
>> I know this is a common topic in Haskell-Cafe, but I have failed to
>> identify conclusive opinions from experienced Haskellers out there in
>> previous discussions. My apologies in advance if this is a blatantly
>> redundant post.
>>
>> All the best,
>> Ozgun
>>
>>
>> ___
>> 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
>
>


-- 
Alp Mestanogullari
http://alpmestan.wordpress.com/
http://alp.developpez.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Fwd: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Alberto G. Corona
2010/3/24 Stephen Tetley 


> If you consider containers as the containers package, the data
> structures are all (?) functorial  - but they have different shapes,
> so e.g. a cons operation makes sense on the linear ones
> (Data.Sequence, Data.List) but not on Data.Map, Data.Tree. 'cons' is
> analogous to 'insert' but 'insert' exactly describes the operation on
> maps whereas 'cons' doesn't, similarly 'insert' doesn't describe the
> 'cons' operation on lists exactly as it doesn't indicate the position
> of where it adds to the list.
>

Some operations like insert in list could be inefficient, some operations
like cons in maps could be an inefficient hack, but at this does not means
that a list can do  create, insert,  map , lookup faster that a Map in the
case of sort lists, for example. A generalized cons applied to a Map can
make less sense, but a program made for lists with occasional cons's can
happen to perform better with Maps and so on.  So a library with generality
in mind can perform optimally in two or more different scenarios with
different instances/implementations.  . A genetic algoritm can have the
opportunity to detect this.

 I think also that a complex list of class hierarchies is neither necessary
nor recommended. We are not talking about mathemathical concepts. This is a
performance issue.

Even if a definitive class hierarchy is a problem, hopefully it may be worth
to define tentative and temporal classes for performance testing purposes,
that warps the common primitives with the sole purpose of executing the
testing algorithm for different instance implementations, compilation flags
and fusion rules.

>
> Now, if you partition the type classes into small groups you get over
> the fact that some operations make sense on certain 'shapes' of data
> structure, but there are still subtle type differences that aren't
> conducive to type classes - e.g. ByteString and Data.Text aren't
> functorial so map is type restricted:
>
> map  :: (Word8  -> Word8) -> ByteString  -> ByteString
>
>
For this purpose,  specific testing classes for Word8 data -with no claim to
be "official" can be defined by the programmer, leaving to the library user
to run the testing process for the different instances in his particular
program.

I know that this add extra work and that not many would do this extra level
of abstraction, but perhaps this is less work than spending even more time
exchanging emails, discussing low level issues, performing tests, trying to
figure out what will be the most common sceniarios for wich the library
could be used, testing manually what is the container that has the most
performance here and now, not tomorrow for these scenarios, to worry about
the obsolescence of the library for reasons not related with the library
algorithm  etc

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


Fwd: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Alberto G. Corona
-- Forwarded message --
From: Alberto G. Corona 
Date: 2010/3/24
Subject: Re: [Haskell-cafe] Bytestrings and [Char]
To: Stephen Tetley 




2010/3/24 Stephen Tetley 

Hi Alberto
>
> I rather doubt a valuable set of type classes that is suitable for all
> containers exists, I'm afraid.
>
> If you consider containers as the containers package, the data
> structures are all (?) functorial  - but they have different shapes,
> so e.g. a cons operation makes sense on the linear ones
> (Data.Sequence, Data.List) but not on Data.Map, Data.Tree. 'cons' is
> analogous to 'insert' but 'insert' exactly describes the operation on
> maps whereas 'cons' doesn't, similarly 'insert' doesn't describe the
> 'cons' operation on lists exactly as it doesn't indicate the position
> of where it adds to the list.
>

Some operations like insert in list could be inefficient, some operations
like cons in maps could be an inefficient hack, but at this does not means
that a list can do  create, insert,  map , lookup faster that a Map in the
case of sort lists, for example. A generalized cons applied to a Map can
make less sense, but a program made for lists with occasional cons's can
happen to perform better with Maps and so on.  So a library with generality
in mind can perform optimally in two or more different scenarios with
different instances/implementations.  . A genetic algoritm can have the
opportunity to detect this.

 I think also that a complex list of class hierarchies is neither necessary
nor recommended. We are not talking about mathemathical concepts. This is a
performance issue.

Even if a definitive class hierarchy is a problem, hopefully it may be worth
to define tentative and temporal classes for performance testing purposes,
that warps the common primitives with the sole purpose of executing the
testing algorithm for different instance implementations, compilation flags
and fusion rules.

>
> Now, if you partition the type classes into small groups you get over
> the fact that some operations make sense on certain 'shapes' of data
> structure, but there are still subtle type differences that aren't
> conducive to type classes - e.g. ByteString and Data.Text aren't
> functorial so map is type restricted:
>
> map  :: (Word8  -> Word8) -> ByteString  -> ByteString
>
>
For this purpose,  specific testing classes for Word8 data -with no claim to
be "official" can be defined by the programmer, leaving to the library user
to run the testing process for the different instances in his particular
program.

I know that this add extra work and that not many would do this extra level
of abstraction, but perhaps this is less work than spending even more time
exchanging emails, discussing low level issues, performing tests, trying to
figure out what will be the most common sceniarios for wich the library
could be used, testing manually what is the container that has the most
performance here and now, not tomorrow for these scenarios, to worry about
the obsolescence of the library for reasons not related with the library
algorithm  etc


Also, while ListLike does provide default definitions for many ops I'm
> guessing its more important for performance to redefine them, so the
> defaults definitions aren't adding much.
>
> There might be a couple of useful new type classes waiting in the
> wings, e.g a destroy one as per view in Data.Sequence, but I doubt
> that a proliferation of classes will generally make programs clearer
> or more efficient and it would introduce more instances of problems
> that we already have with Num type class.
>
> class Destroy f where
>  destroy :: f a -> (a, Maybe (f a))
>
> 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


Re: [Haskell-cafe] State of the Haskell Web Application Stack

2010-03-24 Thread Michael Snoyman
Hi Ozgun,

At the moment, I would say that Happstack is your best bet on a mature
option for Haskell web development. There are other systems being developed,
but none have been battle-tested as much as Happstack (as far as I know). I
know that patch-tag[1] was written with it, for example.

That said, there's a lot of effort right now in expanding the web
development landscape for Haskell. I suggest you subscribe to the web-devel
mailing list and follow the discussions there. Jeremy Shaw, for example, is
currently working on a package called URLT, which promises type-safe URLs.
(I know the PHP project I'm consulting on right now could *really* use this
feature.)

Things are exciting right now, and you can probably have a lot of input on
the direction of development. Also, if you want a more experimental
framework, I'll recommend you check out Yesod[2] (which I am writing).

Michael

[1] http://patch-tag.com/
[2] http://www.yesodweb.com/code.html

On Tue, Mar 23, 2010 at 7:05 PM, Ozgun Ataman  wrote:

> Greetings all.
>
> I have been for quite some time trying to assess the feasibility of using
> Haskell in relatively large, high volume, high availability, long-running
> web application projects. I have enjoyed learning and using Haskell very
> much for the past year and I often find myself missing various language
> features when reasoning about alternatives like Ruby (on Rails). If I can
> identify the right set of tools for the job, I would really like to take the
> plunge and make Haskell my standard go-to language in web applications.
>
> Here are the couple of key questions that I wanted get your feedback on:
>
>
>1. Do you consider Haskell and its environment of libraries ready for
>prime time in web app development as defined above?
>2. What collection of libraries would you use in such an effort?
>3. What are the up and coming packages/technologies in Haskell-land you
>would watch out for?
>
>
> Also, here are some core requirements that I would define for such a
> project:
>
>
>- Ease/speed of development in both back and front-ends, minimal
>boilerplate
>- Extendability and flexibility in iterative development
>- Robustness and reliability in production environment
>- High performance
>- Scalability
>- Ability to interface with new technologies in the future: Cassandra,
>Redis, memcached, etc.
>- Ease of implementing common/reusable features across web
>applications: user authentication, S3 file uploads, thumbnail/image
>handling, exception notifications, etc.
>
>
> In terms of libraries, I can think of a few key components (as pointed out
> by several others before) that one would need to arrange:
>
>
>- Choice of server (happstack vs. alternatives)
>- Templating (xhtml vs. file templates vs. newer efforts like
>BlazeHtml)
>- Data/storage layer: HDBC vs. HaskellDB vs. others
>
>
> I know this is a common topic in Haskell-Cafe, but I have failed to
> identify conclusive opinions from experienced Haskellers out there in
> previous discussions. My apologies in advance if this is a blatantly
> redundant post.
>
> All the best,
> Ozgun
>
>
> ___
> 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] Takusen sqlite3 insert is very slow

2010-03-24 Thread Vasyl Pasternak
Hi Jason,

Your recommendations worked for me. When I enclosed updating into
single transaction, the code executed in less than 0.5 seconds, which
is as fast as HDBC version. I didn't go deeper, hoping, that
everything will be OK from now.

Thank you,
Vasyl

2010/3/20 Jason Dagit :
>
>
> On Sat, Mar 20, 2010 at 3:32 AM, Vasyl Pasternak 
> wrote:
>>
>> Hi Cafe,
>>
>> I have another problem, please look at code:
>>
>> storeInDb = withSession (connect "test.db")
>>             (do
>>                 execDDL (sql "create table x (y int)")
>>                 forM_ ([1..1] :: [Int])
>>                   (\x -> do
>>                       execDML (cmdbind ("insert into x (y) values (?);")
>>                                [bindP x])
>>                       return ()))
>>
>> This code runs 16 seconds which is very slow for this simple task. RTS
>> output is below. After profiling this program I found that 85% of its
>> time it spends in  'Database.Sqlite.SqliteFunctions.stmtFetch'.
>> Currently I don't know how to make it faster, maybe anyone had this
>> problem later?
>>
>> HDBC inserts very fast, so this is not sqlite error.
>
> Can you show the HDBC version?  Maybe they make different assumptions about
> transactions or fetching the number of affected rows?
> If I'm reading the source of takusen correctly it's using a different
> transaction for each insert and stmtFetch is getting called to return the
> number of rows inserted.  Which should be 1 every time and for your
> purposes, ignorable.  You should be able to change to execDDL, but I
> seriously doubt that will have any impact on performance.  It looks like the
> only difference between execDDL and execDML is that execDDL has ">> return
> ()" at the end of it.
> You might try running your inserts inside withTransaction.  The default
> behavior of sqlite is to use a separate transaction for each statement.
>  Perhaps this is adding overhead that shows up during stmtFetch.
> How long does your HDBC version take?  Is it a factor of 10?  Factor of 2?
> Jason
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Graphical representation of Haskell code

2010-03-24 Thread Mihai Maruseac
Here[0] is a second attempt at drawing the images for the functions.
I've done only the first two versions of map, will do the others until
the end of the week.

[0]: http://pgraycode.wordpress.com/2010/03/24/visual-haskell-debugger-part-2/
-- 
Mihai Maruseac

On Tue, Mar 23, 2010 at 4:28 PM, Mihai Maruseac
 wrote:
> I'll be drawing those graphs by hand today at my Operating Systems
> course :) I'll blog them today.
>
> Making a library for transforming the source code into a graph would
> help me finish my debugger easier. But the library would have to take
> into account the fact that the output graph may be used in a wide
> range of ways from debugging to teaching (why not integrate it for
> example with LaTeX Beamer and its support for predefined image
> zooms?).
>
> On Tue, Mar 23, 2010 at 4:15 PM, Dupont Corentin
>  wrote:
>> Hello!
>> Thanks for the welcome!
>>
>> Ivan:
>> Too overcome the problem of large and messy images, i propose too have a
>> system to navigate into the code.
>> You could zoom in and out, occulting unecessary details while zooming out.
>> My big graphic of map (+1) could easely be summed up to:
>>
>> (Embedded image moved to file: pic36782.jpg)
>>
>> My idea is to provide an efficient system of zooming, as you can zoom in a
>> fractal picture, showing more or less details!
>>
>> Such a tool, if created, could be implemented as a part of, or used by
>> SourceGraph.
>>
>> In the first place i thought the GHC API would be great to infer each
>> function's type.
>> But indeed haskell-src-exts seems to be more appropriate as you get the
>> structure of the program.
>>
>> Lyndon:
>> Wahou this page (MockingBirds) his very interresting and funny!
>>
>>
>> Mihai:
>> That's funny we had the same idea quite the same time. I guess that idea is
>> "in the air" and as said one contributor on your Reddit, "a well explored
>> territory":
>> It has major pitfalls and the reason why we heard little about that wild
>> territory is because many explorers never returned :)
>> By the way, i'm interrested and i could contribute on the little spare time
>> i have.
>>
>> My idea is to make it as a library that display code as graphs. That library
>> could be used for several purposes: debugging as you proposes, but also
>> education, shows, audit (with SourceGraph), and why not construction...
>> I think this kind of visual tool could be a "plus" in Haskell popularity.
>> Despite not being that efficient, it is spectacular.
>>
>> Ronald:
>> I agree big graphs are confusing. The big point of the project is to find
>> or adapt an algorithm to simplify the graph and make it valuable.
>> I'll have to make little graphics for each of your versions of map, this
>> may be instructive to me...
>>
>> Stephen:
>> I'll have a look at those interaction nets!
>> But the home page for INBlobs seems to be down.
>>
>>
>>
>> Thank you all for you kind responses.
>> Corentin
>>
>> ___
>> 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] how to make it faster ?

2010-03-24 Thread Richard O'Keefe


On Mar 24, 2010, at 6:01 PM, 国平张 wrote:


Hi,

I wrote a type program to compute fibonacci series,


It certainly is possible to compute Fibonacci numbers
as a "type program", but what you wrote is not a type
program, just plain old Haskell.


if the max value
is big, then it becomes very slow.
like

take 100 fib

How can I make it faster :-)


Don't do it that way.  Each element of your list is
computed independently, and each computation takes
exponential time (and would in C or Java).

There are well known ways to compute Fibonacci
numbers in linear and logarithmic time (assuming
integer operations are constant time, which of course
isn't true for big enough integers).  They work well
in Haskell too.

The simplest thing -in Haskell- is to make the
list element computations share the work using
lazy evaluation.

fibs :: [Integer]
fibs = 1 : 1 : [x+y | (x,y) <- zip fibs (tail fibs)]

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


Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Don Stewart
bos:
> you end up with a fearsome and complex set of typeclasses that are
> difficult to learn and follow.

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


Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Bryan O'Sullivan
On Wed, Mar 24, 2010 at 5:48 AM, Stephen Tetley wrote:

>
> I rather doubt a valuable set of type classes that is suitable for all
> containers exists, I'm afraid.


I don't think it's so clear cut. Stepanov's "Elements of Programming" lays
out a pretty clear (and familiar to many Haskellers) path through the
algebraic thicket of types, classes, and their properties, albeit in the
much clunkier setting of C++ and traits. The disadvantage to this approach
is substantial: just as with the from-principles approaches to redoing
Haskell's numeric hierarchy, you end up with a fearsome and complex set of
typeclasses that are difficult to learn and follow.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] double existential type

2010-03-24 Thread Bas van Dijk
On Wed, Mar 24, 2010 at 6:31 PM, Ozgur Akgun  wrote:
> What was I thinking?

A sensible thought if you asked me.

It's certainly a surprise to me that this isn't allowed. Because in
any other context binders, like lambdas and foralls, may be freely
nested. For example:

{-# LANGUAGE RankNTypes #-}
swap :: forall a. forall b. a -> b -> (a, b)
swap = \x -> \y -> (x,y)

{-# LANGUAGE PolymorphicComponents #-}
data Foo = Foo (forall a. forall b. a)

regards,

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


Re: [Haskell-cafe] Using Get monad to efficiently parse byte-stuffed data

2010-03-24 Thread Paul Johnson

On 24/03/10 04:36, Pom Monico wrote:

Hello all,

I'm struggling to use the Get monad to efficiently parse the some
binary data of the format below. I simply can't find a way to use the
monad to parse it efficiently.

Binary data is terminated by a 0xFF marker. If the data itself
contains an 0xFF, a 0x00 is byte-stuffed after it to indicate it is
part of the data. An 0xFF followed by a non-zero byte indicates that
it is a real marker and terminates the data and the 0xFF is not part
of the data.

   


So the only way to find out if you have reached the end of the data is 
to read beyond it?  Yuck!


I haven't used it myself, but I suggest taking a look at Attoparsec, 
which is like Parsec but for bytestrings.  That might be able to handle 
this kind of non-determinism.


Paul.


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


Re: [Haskell-cafe] Re: really difficult for a beginner like me...

2010-03-24 Thread Daniel Fischer
-Ursprüngliche Nachricht-
Von: saaj [
Gesendet: 24.03.2010 15:17:19
An: haskell-cafe@haskell.org
Betreff: [Haskell-cafe] Re: really difficult for a beginner like me...

>Thank you.
>I will try it
>
>What about the second part, capitalisation thing? can you help me with that as 
>well?
>
>"Treat a capitalised word (one or more capitals) as being different from the 
>word in all lower case unless it is at the start of a sentence with only the 
>initial letter capitalised."
>

Well, the obvious idea is to do that by lower-casing the words which fit these 
criteria
before further processing. Identifying the start of a sentence is difficult if 
you have to
take all possibilities for dots, question marks and exclamation marks into 
account, but
probably treating just the semi-obvious cases is enough (check whether you have 
e.g.
an abbreviation instead of an end-of-sentence dot), that's not too hard.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] double existential type

2010-03-24 Thread Ozgur Akgun
Thank you very much - and for the quick response as well!
I tried putting a comma in between them, but no luck. What was I thinking?
:)

On 24 March 2010 17:25, Stephen Tetley  wrote:

> Hi Ozgur - try
>
> data Binary' = forall a b. Binary' a b
>



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


Re: [Haskell-cafe] derivable type classes

2010-03-24 Thread Ozgur Akgun
Thanks for the pointers again - you are of great help every time!


On 23 March 2010 17:44, Josef Svenningsson wrote:

> On Tue, Mar 23, 2010 at 11:52 AM, Ozgur Akgun 
> wrote:
> > Can a user define a derivable type class of her own? If yes, how?
> >
> GHC has a feature which lets you define classes such that making an
> instance of them is as easy as deriving. It's called Generic classes.
> See GHC's documentation for the details:
>
> http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-classes.html
>
> Hth,
>
> Josef
>



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


Re: [Haskell-cafe] double existential type

2010-03-24 Thread Stephen Tetley
Hi Ozgur - try

data Binary' = forall a b. Binary' a b
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] double existential type

2010-03-24 Thread Ozgur Akgun
Hello all,

I have a syntax issue (hopefully!)

-- this is perfectly fine:
data Unary = forall a. Unary a

-- this one as well:
data Binary = forall a. Binary a a

-- but not this one
-- parse error on input forall :(
data Binary' = forall a. forall b. Binary' a b

I tried different kinds of bracketings and orderings but no luck...


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


Re: [Haskell-cafe] Syntax programming with lexemes rather than trees?

2010-03-24 Thread Stephen Tetley
Hi Henning

Thanks - yes, there is a report by Matt Munz, a student of Paul Hudak's.

Last year I tried to get my library to work with Haskore, but Haskore
has numerical durations - for scores you need symbolic ones, and its a
lot of work deriving symbolic durations from numeric ones. There are
few other problems such as they way Haskore handles overlays that
don't lend well to score output, at least not for LilyPond (originally
Haskore worked with the Lisp score system CNM I believe).

There's an example here of how far I got with Haskore - I don't think
Chick Corea's publishers will be getting in touch...

http://www.flickr.com/photos/44929...@n03/

Best wishes

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


Re: [Haskell-cafe] Syntax programming with lexemes rather than trees?

2010-03-24 Thread Henning Thielemann

Stephen Tetley schrieb:

Hello All

Modern functional programming languages give you algebraic data types
that are mighty convenient for programming with syntax trees. However,
I'm working in a domain (music typesetting) where modelling syntax
with trees can be problematic and I'm wondering whether I should work
at a lower level - essentially a list / stream of lexemes and some
notion of a context stack for processing, tracking when I'm inside a
tuplet and the metrical calculation is scaled, for example.

Does anyone know of any previous work that takes a "lexical" view of
syntax rather than an abstract syntax tree view? Any domain is good -
I can't imagine there's any prior work on music typesetting.

Pointers to papers would be more digestible than code but either is
fine. Similarly, implementation in any functional language is fine.
  

There was some unpublished work to emit Lilypond code for Haskore songs.

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


Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Michael Snoyman
I have a very specific StringLike typeclass in the web-encodings package so
that I can- for example- to HTML entity encoding on String, (lazy)
bytestrings and (lazy) text. Of course, I need to make assumptions about
character encoding for the bytestring version.

Michael

On Wed, Mar 24, 2010 at 8:50 AM, John Lato  wrote:

> I still think that getting other authors to use it would be the
> biggest difficulty.  Another concern of mine is that RULEs-based
> fusion can be fragile; if the type classes prevent fusion from
> occurring you'll never approach the performance of monomorphic code.
>
> That said, I think this is worth pursuing further because of the
> benefits you describe.  I have spent a great deal of time on exactly
> this issue with the iteratee package, although my needs there are
> relatively simple.
>
> As a general question to the Haskell community: have you ever
> attempted to write container-polymorphic code?  I'd like to hear about
> either successes or stumbling blocks.
>
> On Wed, Mar 24, 2010 at 12:02 PM, Alberto G. Corona 
> wrote:
> > Once we have a  tree of type classes suitable for all containers, as you
> > said, theoretically it  shouldn't very difficult to incorporate the
> testing
> > of different instances for each class used in a program, besides  testing
> > different compilation flags in a genetic algoritm. This latter has
> already
> > been done.
> >
> http://donsbot.wordpress.com/2010/03/01/evolving-faster-haskell-programs-now-with-
> > To find automatically the best combination of class implementations and
> > compilation flags in a single process would be very useful and would save
> a
> > lot of manual testing.
> >
> > 2010/3/24 John Lato 
> >>
> >> Hi Alberto,
> >>
> >> To some extent this already exists, it's just that nobody uses it.  I
> >> believe it's the approach taken by the Edison libraries.  Also the
> >> ListLike package provides the type classes ListLike, StringLike, and a
> >> few others.  Neither seems to have become very popular despite having
> >> well-respected authors (Okasaki and Goerzon, respectively).
> >>
> >> Some container functions are already provided by other classes, namely
> >> Foldable, Traversable, and Monoid.
> >>
> >> The first bit, creating a tree of type classes suitable for all
> >> containers, is probably a few hours work.
> >>
> >> An automated system to determine the best implementation is
> >> significantly more difficult; I can't say if the scope would be
> >> appropriate for SoC.
> >>
> >> Best,
> >> John
> >>
> >> > From: "Alberto G. Corona " 
> >> >
> >> > Just a dream:
> >> > -separate interface and implementation for all containers, via type
> >> > classes
> >> > -develop, by genetic programming techniques + quickcheck, a system
> that
> >> > find
> >> > the best container implementation for a particular program.
> >> >
> >> > Is that suitable for a Google Summer of Code project?
> >> >
> >> > 2010/3/23 Alberto G. Corona 
> >> >
> >> > The question can be generalized via type classes: Is there any common
> >> > set of
> >> >> primitives encapsulated into a single type class that has instances
> for
> >> >> Strings (Data.List) ByteStrings, Data.Text, Lazy bytestrings, Arrays,
> >> >> vectors and wathever container that can store an boxed, unboxed,
> packed
> >> >> unpacked sequence of wathever including chars? All of them have
> folds,
> >> >> heads, tails and a lot of common functions with the same name, but
> >> >> since
> >> >> there is not a single type class, the library programmer can not
> >> >> abstract
> >> >> his code when it is possible, so the library user can chose the
> >> >> particular
> >> >> instance for his particular problem.
> >
> >
> ___
> 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] Bytestrings and [Char]

2010-03-24 Thread John Lato
I still think that getting other authors to use it would be the
biggest difficulty.  Another concern of mine is that RULEs-based
fusion can be fragile; if the type classes prevent fusion from
occurring you'll never approach the performance of monomorphic code.

That said, I think this is worth pursuing further because of the
benefits you describe.  I have spent a great deal of time on exactly
this issue with the iteratee package, although my needs there are
relatively simple.

As a general question to the Haskell community: have you ever
attempted to write container-polymorphic code?  I'd like to hear about
either successes or stumbling blocks.

On Wed, Mar 24, 2010 at 12:02 PM, Alberto G. Corona  wrote:
> Once we have a  tree of type classes suitable for all containers, as you
> said, theoretically it  shouldn't very difficult to incorporate the testing
> of different instances for each class used in a program, besides  testing
> different compilation flags in a genetic algoritm. This latter has already
> been done.
> http://donsbot.wordpress.com/2010/03/01/evolving-faster-haskell-programs-now-with-
> To find automatically the best combination of class implementations and
> compilation flags in a single process would be very useful and would save a
> lot of manual testing.
>
> 2010/3/24 John Lato 
>>
>> Hi Alberto,
>>
>> To some extent this already exists, it's just that nobody uses it.  I
>> believe it's the approach taken by the Edison libraries.  Also the
>> ListLike package provides the type classes ListLike, StringLike, and a
>> few others.  Neither seems to have become very popular despite having
>> well-respected authors (Okasaki and Goerzon, respectively).
>>
>> Some container functions are already provided by other classes, namely
>> Foldable, Traversable, and Monoid.
>>
>> The first bit, creating a tree of type classes suitable for all
>> containers, is probably a few hours work.
>>
>> An automated system to determine the best implementation is
>> significantly more difficult; I can't say if the scope would be
>> appropriate for SoC.
>>
>> Best,
>> John
>>
>> > From: "Alberto G. Corona " 
>> >
>> > Just a dream:
>> > -separate interface and implementation for all containers, via type
>> > classes
>> > -develop, by genetic programming techniques + quickcheck, a system that
>> > find
>> > the best container implementation for a particular program.
>> >
>> > Is that suitable for a Google Summer of Code project?
>> >
>> > 2010/3/23 Alberto G. Corona 
>> >
>> > The question can be generalized via type classes: Is there any common
>> > set of
>> >> primitives encapsulated into a single type class that has instances for
>> >> Strings (Data.List) ByteStrings, Data.Text, Lazy bytestrings, Arrays,
>> >> vectors and wathever container that can store an boxed, unboxed, packed
>> >> unpacked sequence of wathever including chars? All of them have folds,
>> >> heads, tails and a lot of common functions with the same name, but
>> >> since
>> >> there is not a single type class, the library programmer can not
>> >> abstract
>> >> his code when it is possible, so the library user can chose the
>> >> particular
>> >> instance for his particular problem.
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Problem with Haskell Platform website

2010-03-24 Thread Don Stewart
depp:
> There's a problem with the Haskell Platform website.  I'm posting the  
> message here because I gave up looking for contact information for the  
> site, maybe someone here can forward the message or tell me who to  
> forward it to?
>
> The specific page is http://hackage.haskell.org/platform/mac.html
>
> Being one of the few who still use the PPC architecture, I expect to  
> have to build my own packages from source.  Imagine my surprise when the 
> Haskell platform uses the "Universal Binary" logo on the Mac download.  
> Nowhere on the Mac download page does it specify an architecture.  
> However, the binary is i386 only and not PPC.  So I just wasted time 
> downloading something I can't install on my computer.
>
> This page shows the "Universal Binary" logo: 
> http://hackage.haskell.org/platform/
>
> Here is Apple's "Universal Binary" page, which describes what the logo  
> means: http://www.apple.com/universal/
>
> It would be nice to get rid of the "Universal Binary" logo and to mark  
> the packages as i386.

Yes, we spotted that yesterday. Expect the logo fixed shortly.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problem with Haskell Platform website

2010-03-24 Thread Dietrich Epp
There's a problem with the Haskell Platform website.  I'm posting the  
message here because I gave up looking for contact information for the  
site, maybe someone here can forward the message or tell me who to  
forward it to?


The specific page is http://hackage.haskell.org/platform/mac.html

Being one of the few who still use the PPC architecture, I expect to  
have to build my own packages from source.  Imagine my surprise when  
the Haskell platform uses the "Universal Binary" logo on the Mac  
download.  Nowhere on the Mac download page does it specify an  
architecture.  However, the binary is i386 only and not PPC.  So I  
just wasted time downloading something I can't install on my computer.


This page shows the "Universal Binary" logo: 
http://hackage.haskell.org/platform/

Here is Apple's "Universal Binary" page, which describes what the logo  
means: http://www.apple.com/universal/


It would be nice to get rid of the "Universal Binary" logo and to mark  
the packages as i386.


--Dietrich Epp

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


[Haskell-cafe] Re: really difficult for a beginner like me...

2010-03-24 Thread saaj
Thank you.
I will try it

What about the second part, capitalisation thing? can you help me with that as 
well?

"Treat a capitalised word (one or more capitals) as being different from the 
word in all lower case unless it is at the start of a sentence with only the 
initial letter capitalised."





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


Re: [Haskell-cafe] Syntax programming with lexemes rather than trees?

2010-03-24 Thread Stephen Tetley
Hi Yitzchak

Thanks for the encouragement. Funnily enough its been the working with
'repeat' syntax that has tipped the current revision of my code from
being "workable, somewhat ad-hoc, polish-able later" into "horrible -
too complex, needs a simpler foundation." As for programming to
LilyPond from Haskell, with the latest revision I've managed entirely
with the stmap class I posted above (and its pathological extension to
a 3 parameter functor - trifunctor?). There isn't a monad in sight in
currently.

While the results are disappointing at the moment, the domain has been
fruitful for cultivating some exotic functional codes: families of
unfold functions extending the skipping unfold at the heart of the
stream fusion paper [1]; traversals that separate shape from contents
[2] and more.

Best wishes

Stephen


[1] http://www.cse.unsw.edu.au/~dons/papers/stream-fusion.pdf

further elaborated by Jeremy Gibbons:
http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/adt.pdf

[2] http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/iterator-msfp.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: really difficult for a beginner like me...

2010-03-24 Thread Daniel Fischer
-Ursprüngliche Nachricht-
Von: saaj [
Gesendet: 24.03.2010 13:13:29
An: haskell-cafe@haskell.org
Betreff: [Haskell-cafe] Re: really difficult for a beginner like me...

>saaJamal [ hotmail.com> writes:
>
>U happen to find a way for your problem? I tried a lot for more than a week 
>now, but cant do it.
>
>I tried many tutorials but wasnt of any good.
>
>as per the above case study, I need to do is:
>
>
>1) Allow words to be hyphenated and treat a hyphenated
>word as a single word.  However, for those words which are split over two
>lines, treat a split word as a single word without the hyphen.
>
>for this i tried:
>   fixupHyphens :: [ (Int, Word) ] -> [ (Int, Word ) ]
>   fixupHyphens ( (line1, word1):(line2:word2):xs )
>   | if (word1, line2) /= line1 = ( line1,word2 ) : fixupHyphens xs
>   | otherwise = (line1, word1):(line2:word2): fixupHyphens xs
>   fixupHyphens xs = xs
>

It's probably easier to treat the hyphens before pairing the words with the 
line-numbers.
If you needn't care about words containing a hyphen (like line-numbers above), 
a simple preprocessor

fixHyphens :: String -> String
fixHyphens ('-':'\n':more) = (move rest of the word before the newline and 
remove hyphen)
fixHyphens (c:cs) = c: fixHyphens cs
fixHyphens "" = ""

should do the trick.

>and for including hiphens i added this to the code: 
>
>
>splitWords :: Line -> [Word]   --  a)
>
>splitWords [] = []
>splitWords  line 
>= takeWhile isLetter line :--  first word in 
> line
>   (splitWords .   --  split other words
>   dropWhile (not.isLetter) .  --  delete separators
>   dropWhile isLetter) line--  other words
>where
> isLetter ch
>=  (('a'<=ch) && (ch<='z'))
> ||(('A'<=ch) && (ch<='Z'))
> ||  ('-' = ch)
>
>
>2)Treat a capitalised word (one or more capitals) as being different from the 
>word in all lower case (but they should still be sorted alphabetically)unless 
>it is at the start of a sentence with only the initial letter capitalised. 
>
>
>___
>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] Syntax programming with lexemes rather than trees?

2010-03-24 Thread Yitzchak Gale
Stephen Tetley wrote:
> LilyPond has already answer this one...
> trying for a typed
> representation would be too restrictive - LilyPond has a very large
> LaTeX style syntax for assembling scores.

I find LilyPond's very monolithic very stateful representation
to be ugly and awkward. It clearly misses out most of the
underlying structure - and in correspondence with the authors on
the mailing list there, it is clear that they are aware of this.
They chose a certain representation philosophy based on a
weird ad hoc blend of Scheme and LaTeX, and they are sticking
with it to the bitter end only because it's far too late to turn back.

Don't get me wrong - I love LilyPond, it is an absolutely fantastic
piece of software. But the kinds of kluges and backflips that you
need to get even simple things done sometimes is staggering.

Example: when you write a simple lead sheet with named
chords, you'll always want to use "chordChanges" mode. But
then, if the first chord in the second ending of a volta repeat is
the same as the last chord in the first ending, it will be omitted.
Because after all, the whole piece is just a linear stream of
tokens with no structure. With work you can get the chord to
print, but what a mess. And then if you want to change something,
you have to undo the whole mess and do it again.

You are absolutely right that the structure of music representation
is not simple at all. But it is there. Please don't give up.

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


Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Stephen Tetley
Hi Alberto

I rather doubt a valuable set of type classes that is suitable for all
containers exists, I'm afraid.

If you consider containers as the containers package, the data
structures are all (?) functorial  - but they have different shapes,
so e.g. a cons operation makes sense on the linear ones
(Data.Sequence, Data.List) but not on Data.Map, Data.Tree. 'cons' is
analogous to 'insert' but 'insert' exactly describes the operation on
maps whereas 'cons' doesn't, similarly 'insert' doesn't describe the
'cons' operation on lists exactly as it doesn't indicate the position
of where it adds to the list.

Now, if you partition the type classes into small groups you get over
the fact that some operations make sense on certain 'shapes' of data
structure, but there are still subtle type differences that aren't
conducive to type classes - e.g. ByteString and Data.Text aren't
functorial so map is type restricted:

map  :: (Word8  -> Word8) -> ByteString  -> ByteString

Also, while ListLike does provide default definitions for many ops I'm
guessing its more important for performance to redefine them, so the
defaults definitions aren't adding much.

There might be a couple of useful new type classes waiting in the
wings, e.g a destroy one as per view in Data.Sequence, but I doubt
that a proliferation of classes will generally make programs clearer
or more efficient and it would introduce more instances of problems
that we already have with Num type class.

class Destroy f where
  destroy :: f a -> (a, Maybe (f a))

Best wishes

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


[Haskell-cafe] Re: really difficult for a beginner like me...

2010-03-24 Thread saaj
saaJamal  hotmail.com> writes:

U happen to find a way for your problem? I tried a lot for more than a week 
now, but cant do it.

I tried many tutorials but wasnt of any good.

as per the above case study, I need to do is:


1) Allow words to be hyphenated and treat a hyphenated
word as a single word.  However, for those words which are split over two
lines, treat a split word as a single word without the hyphen.

for this i tried:
   fixupHyphens :: [ (Int, Word) ] -> [ (Int, Word ) ]
   fixupHyphens ( (line1, word1):(line2:word2):xs )
   | if (word1, line2) /= line1 = ( line1,word2 ) : fixupHyphens xs
   | otherwise = (line1, word1):(line2:word2): fixupHyphens xs
   fixupHyphens xs = xs

and for including hiphens i added this to the code: 


splitWords :: Line -> [Word]--  a)

splitWords [] = []
splitWords  line 
= takeWhile isLetter line : --  first word in line
(splitWords .   --  split other words
dropWhile (not.isLetter) .  --  delete separators
dropWhile isLetter) line--  other words
where
 isLetter ch
 =  (('a'<=ch) && (ch<='z'))
  ||(('A'<=ch) && (ch<='Z'))
  ||  ('-' = ch)


2)Treat a capitalised word (one or more capitals) as being different from the 
word in all lower case (but they should still be sorted alphabetically)unless 
it is at the start of a sentence with only the initial letter capitalised. 


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


Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Alberto G. Corona
Once we have a  tree of type classes suitable for all containers, as you
said, theoretically it  shouldn't very difficult to incorporate the testing
of different instances for each class used in a program, besides  testing
different compilation flags in a genetic algoritm. This latter has already
been done.


http://donsbot.wordpress.com/2010/03/01/evolving-faster-haskell-programs-now-with-

To find automatically the best combination of class implementations and
compilation flags in a single process would be very useful and would save a
lot of manual testing.


2010/3/24 John Lato 

> Hi Alberto,
>
> To some extent this already exists, it's just that nobody uses it.  I
> believe it's the approach taken by the Edison libraries.  Also the
> ListLike package provides the type classes ListLike, StringLike, and a
> few others.  Neither seems to have become very popular despite having
> well-respected authors (Okasaki and Goerzon, respectively).
>
> Some container functions are already provided by other classes, namely
> Foldable, Traversable, and Monoid.
>
> The first bit, creating a tree of type classes suitable for all
> containers, is probably a few hours work.
>
> An automated system to determine the best implementation is
> significantly more difficult; I can't say if the scope would be
> appropriate for SoC.
>
> Best,
> John
>
> > From: "Alberto G. Corona " 
> >
> > Just a dream:
> > -separate interface and implementation for all containers, via type
> classes
> > -develop, by genetic programming techniques + quickcheck, a system that
> find
> > the best container implementation for a particular program.
> >
> > Is that suitable for a Google Summer of Code project?
> >
> > 2010/3/23 Alberto G. Corona 
> >
> > The question can be generalized via type classes: Is there any common set
> of
> >> primitives encapsulated into a single type class that has instances for
> >> Strings (Data.List) ByteStrings, Data.Text, Lazy bytestrings, Arrays,
> >> vectors and wathever container that can store an boxed, unboxed, packed
> >> unpacked sequence of wathever including chars? All of them have folds,
> >> heads, tails and a lot of common functions with the same name, but since
> >> there is not a single type class, the library programmer can not
> abstract
> >> his code when it is possible, so the library user can chose the
> particular
> >> instance for his particular problem.
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Syntax programming with lexemes rather than trees?

2010-03-24 Thread Max Rabkin
[Sorry for the accidental off-list reply, Neil]

On Tue, Mar 23, 2010 at 10:43 PM, Neil Mitchell  wrote:
> It actually sounds like your representation has structure, but you
> dislike structure because it's hard to work with.

It seems to me like the data has structure, but that data is not
treelike! Is a performance a collection of measures or a collection of
instruments? A tree-like structure makes you choose, but in truth it
is both. I'm not sure I've seen a good solution to this kind of
problem in FP.

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


Re: [Haskell-cafe] Syntax programming with lexemes rather than trees?

2010-03-24 Thread Stephen Tetley
Hi Max

LilyPond has already answer this one (and ABC can't handle it) -
scores are collections of instrument parts and parts themselves are
made of measures. In practice, I do all assembly at the score/part
level with untyped pretty printing combinators, trying for a typed
representation would be too restrictive - LilyPond has a very large
LaTeX style syntax for assembling scores.

Best wishes

Stephen

On 24 March 2010 11:25, Max Rabkin  wrote:
[Snip]
> Is a performance a collection of measures or a collection of
> instruments? A tree-like structure makes you choose, but in truth it
> is both. I'm not sure I've seen a good solution to this kind of
> problem in FP.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Are there any web server framework ?

2010-03-24 Thread Gracjan Polak


Recently I started to play with Happstack and I must say I'm amazed how good it
works for me! It has server, string templating, type safe html templating,
persistence (like a database, only more fun), email stuff.

To get a grasp at what goes under Happstack name here is a tutorial:

http://tutorial.happstack.com/

-- 
Gracjan




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


[Haskell-cafe] Re: really difficult for a beginner like me...

2010-03-24 Thread saaJamal
Ivan Amarquaye  hotmail.com> writes:

> 
> 
> thanks for the tip thereits been four gruesome days and i just don't 
seem to make any understanding of how to implement some changes or create some 
new functions due to the fact that im so new to Haskell and functional 
programming.
>  
> For the very first case of allowing hyphenated words to be treated as single 
words i manged to successfully do that by adding to the definition of the 
splitWords function to also accept characters such as "-" and it worked 
perfectly after running it.
>  
> The next case posed a headache for me as i have been on it for 3 days now. 
>From my understanding, it means in situations where your writing a  sentence 
and you get to the end of the line while writing a word, you decide to put a 
hyphen there and continue on the other line. So the case demands that i allow 
sentences that end with hyphens and continue on the next line to drop the 
hyphen and be a single word on that same line without having to continue on 
the next line so this was how i foresee the input it in hugs: 
>  
> Input:
> makeIndex "these are the very same stuff they tell each-\nother" 
>  
> output: 
> should be this: [[1]these],[[1]eachother]. 1 indicates they are on the same 
line and the others are left out as the index takes words greater than 4 
characters and i have been struggling with this since. i tried on several 
counts to include in the splitwords function to dropWhile "-" is found in the 
words but it turned out an error.I also tried creating a new function to do 
that didnt succeed either  can anybody help me out in this regard.
>  




U happen to find a way for your problem? I tried a lot for more than a week 
now, but cant do it.

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


Re: [Haskell-cafe] accents

2010-03-24 Thread Daniel Fischer
-Ursprüngliche Nachricht-
Von: Dupont Corentin 
Gesendet: 24.03.2010 11:01:32
An: haskell 
Betreff: [Haskell-cafe] accents

>Hello,
>i have a list of french words with accents.
>How could i handle them?
>If i load them with ghci i get:
>
>> a <- readFile "list.txt"
>> head $ lines a
>"abn\233gation"
>
>putStrLn displays a strange character for the "é".
>
>Cheers,
>Corentin

Encoding problem. Either you want System.IO.UTF8.putStrLn (perhaps also 
readFile), or your file is encoded in latin1 or something and ghci tries to 
output it as UTF8-encoded.
The secure way would be to iconv the file to utf-8 and use the System.IO.UTF8 
I/O-functions.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] accents

2010-03-24 Thread Ivan Lazar Miljenovic
Dupont Corentin  writes:
>> a <- readFile "list.txt"
>> head $ lines a
> "abn\233gation"
>
> putStrLn displays a strange character for the "é".

That is the escaped form of é.  You have several options:

1) Use the utf8-string package for I/O
2) Use the text package for I/O (and set an encoding)
3) GHC 6.12.1 uses the system's locale for encoding; as such if your
system normally lets you see accented characters then putStrLn,
etc. will print them out.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] accents

2010-03-24 Thread Dupont Corentin
Hello,
i have a list of french words with accents.
How could i handle them?
If i load them with ghci i get:

> a <- readFile "list.txt"
> head $ lines a
"abn\233gation"

putStrLn displays a strange character for the "é".

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


Re: [Haskell-cafe] Syntax programming with lexemes rather than trees?

2010-03-24 Thread Stephen Tetley
Hi Neil

Thanks - music has has lots of structure, true, but unfortunately the
structure is often arbitrary, sometimes even conflicting (with respect
to a nested representation).

I've tried various representations: plain algebraic data types, HOAS,
generics with KURE, tagless, attribute grammar with UUAG. From all
this, it turns out that the transformations I want to are pretty
simple:

- 'rename' pitch - two versions - one context free so I can use fmap;
the other context sensitive, so I use stmap - a variation of mapAccumL
coded as a typeclass - its surprising pleasant to use as an
alternative to a state monad when you can live with left-to-right
traversals only:

  class StateMap  f where
stmap :: (st -> a -> (b, st)) -> st -> f a -> (f b, st)

- 'rename' duration - same thing, two different traversals one context
sensitive, one context free.

- metrical splitting - more complicated - segmenting note lists into
bars and beams groups (which must be communicated to LilyPond and ABC)
somewhat reminiscent of groupBy in Data.List but more involved. I've
rewritten the algorithm about 5 times, each time a slight improvement
though it still isn't pretty (not a big deal, however, so long as it
works).

At the moment I can do quite a lot with what I've got, but its too
unwieldy for real use - recently adding support for above-staff fret
diagrams has caused a lot of duplicated code even though it should be
superficially simple (fret diagrams don't need tuplets or beam groups
in their note list syntax). So I need a more different representation.

Although Malcolm didn't mention it, his message reminded me of
streaming XML processing. I've found a few papers since by Alain
Frisch, Keisuke Nakano and colleagues that cast streaming in a
functional light, so I'll see how far I can get with a similar
approach.

Thanks again

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


Re: [Haskell-cafe] Sugar for function application

2010-03-24 Thread Tillmann Rendel

Brandon S. Allbery KF8NH wrote:

On Mar 23, 2010, at 13:39 , Ertugrul Soeylemez wrote:

layout-style syntactic sugar for function application.
Here is an example of what it might look like:

 function $$ anArgument
 sin (x^2)
 anotherArgument
 f $ x + 3


Doesn't layout already do this?

  function arg1
   arg2
   arg3


The layout rule is only triggered by a limited set of keywords (like do, 
where, let, ...), and Ertugrul's proposal is to add a keyword for 
function applicaton to this set.


I like this idea, because it would enable non-monadic embedded DSLs to 
use layout.


For example, consider setting properties in wxHaskell:

  layoutSet myButton $$
text := "Ok"
on action := doSomething

instead of

  set myButton
[ text := "Ok"
, on action := doSomething
]

Of course, this would need some type hackery à la PrintF to make set 
accept multiple arguments, and the proliferation of such type hackery 
may seem unfortunate. On the other hand, the hackery could possibly be 
encapsulated in a combinator like


  polyvariadic :: Poly a b c => ([a] -> b) -> c

so that layoutSet can be implemented as

  layoutSet widget = polyvariadic (set widget).

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


Re: Re[Haskell-cafe] mote invocations in Haskell?

2010-03-24 Thread Håkon Lorentzen
Hi

On Tue, Mar 23, 2010 at 9:46 PM, Yves Parès  wrote:
> Is there a way to perform some kind of remote method invocation in haskell?
> (Or, "remote object", but I prefer not to use this term, as there are no
> "objects" strictly speaking in Haskell)
> I would like to use a higher level API than sockets for network programing.

you could try dbus. dbus-client[1] is a relatively high-level wrapper.


[1]: http://hackage.haskell.org/package/dbus-client
[2]: http://hackage.haskell.org/package/dbus-core

-- 
Håkon Lorentzen

e-mail: hako...@gmail.com
phone: +47 90539718
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread John Lato
Hi Alberto,

To some extent this already exists, it's just that nobody uses it.  I
believe it's the approach taken by the Edison libraries.  Also the
ListLike package provides the type classes ListLike, StringLike, and a
few others.  Neither seems to have become very popular despite having
well-respected authors (Okasaki and Goerzon, respectively).

Some container functions are already provided by other classes, namely
Foldable, Traversable, and Monoid.

The first bit, creating a tree of type classes suitable for all
containers, is probably a few hours work.

An automated system to determine the best implementation is
significantly more difficult; I can't say if the scope would be
appropriate for SoC.

Best,
John

> From: "Alberto G. Corona " 
>
> Just a dream:
> -separate interface and implementation for all containers, via type classes
> -develop, by genetic programming techniques + quickcheck, a system that find
> the best container implementation for a particular program.
>
> Is that suitable for a Google Summer of Code project?
>
> 2010/3/23 Alberto G. Corona 
>
> The question can be generalized via type classes: Is there any common set of
>> primitives encapsulated into a single type class that has instances for
>> Strings (Data.List) ByteStrings, Data.Text, Lazy bytestrings, Arrays,
>> vectors and wathever container that can store an boxed, unboxed, packed
>> unpacked sequence of wathever including chars? All of them have folds,
>> heads, tails and a lot of common functions with the same name, but since
>> there is not a single type class, the library programmer can not abstract
>> his code when it is possible, so the library user can chose the particular
>> instance for his particular problem.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskell platform questions

2010-03-24 Thread wren ng thornton

Don Stewart wrote:

You should file a bug on the Haskell Platform bug tracker.

http://haskell.org/haskellwiki/Haskell_Platform#Trouble_shooting

And I'm CC'ing the dmg maintainer -- it may also be a GHC issue as well.

-- Don

warrensomebody:
I downloaded the new haskell-platform-2010.1.0.0-i386.dmg today... ran  
the uninstaller, ghc installer and the platform installer. When I run  
ghci, it seems to work fine, but when I try cabal, I get this crash:


$ cabal --version
dyld: unknown required load command 0x8022
Trace/BPT trap


Same thing here.

w...@semiramis:~ $ cabal --version
dyld: unknown required load command 0x8022
Trace/BPT trap

OSX = 10.5.8
CPU = Core 2 Duo


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskell platform questions

2010-03-24 Thread wren ng thornton

Gregory Collins wrote:

wren ng thornton  writes:


w...@semiramis:~ $ ls /usr/local
ls: /usr/local: No such file or directory
w...@semiramis:~ $ ls /usr/bin/cabal
ls: /usr/bin/cabal: No such file or directory

But http://hackage.haskell.org/platform/new/contents.html tells me
cabal-install is supposed to ship with the platform...


It should; there's an installation script that's *supposed* to put a
symlink into /usr/local/bin/cabal from
/Library/Frameworks/HaskellPlatform.framework/bin/.

Binaries should be there regardless.


Looks like they are. Perhaps the script is missing a `mkdir -p 
/usr/local/bin` ?  Does the installer keep a log anywhere? (Looks like 
neither GHC nor HP give installation receipts...)


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: State of the Haskell Web Application Stack

2010-03-24 Thread Gour
On Tue, 23 Mar 2010 21:05:51 -0500
>> "Ozgun" == Ozgun Ataman  wrote:

Ozgun> I know this is a common topic in Haskell-Cafe, but I have failed
Ozgun> to identify conclusive opinions from experienced Haskellers out
Ozgun> there in previous discussions. My apologies in advance if this
Ozgun> is a blatantly redundant post.

I suggest you to check

http://www.haskell.org/mailman/listinfo/web-devel 

mailing list where there are nice discussions about the web development
in Haskell.


Sincerely,
Gour

-- 

Gour  | Hlapicina, Croatia  | GPG key: F96FF5F6



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