Re: [Haskell-cafe] haskore - lilypond - typesetting?

2013-08-21 Thread Stephen Tetley
Here's one I did earlier...

http://www.flickr.com/photos/44929957@N03/4459628487/lightbox/

This is Haskore implementation of Chick Corea's Child Song 6 rendered to
LilyPond - I don't imagine Mr. Corea's publishers will be sending me a
takedown request any time soon.

There's a lot missing from Haskore that is needed to make good scores - the
renderer of the above took a lot of effort with metrical grouping but the
result is still abysmal.

I doubt mathematics can help (common practice) music typesetting much -
Western notation has had a thousand years to develop without the constraint
of a regular syntax; so if Lilypond is horrible it is mostly the fault of
what it tries to typeset (it does make some unwarranted mistakes like
over-restricting the characters it can use for variable names and its
parenthesizing is horrible).


On 21 August 2013 14:05, Johannes Waldmann waldm...@imn.htwk-leipzig.dewrote:

 I tried using lilypond ( http://www.lilypond.org/ )
 for typesetting of sheet music.

 While the output looks nice, the input language IMHO is quite horrible,
 because the underlying data/execution model is underspecified.
 For some parts, it tries to describe the logical structure of the score;
 but for others, the layout; and in addition it has several non-obvious
 context-dependencies (but see below), preventing modularity.

 Is there a better option? E.g., starting from a clear mathematical model,
 as in Haskore, and use lilypond only as a PDF rendering engine?

 Do I want hly / hts perhaps?  http://rd.slavepianos.org/?t=hly


 As I see it, the main high-level design problem
 is that the source language needs partial evaluation annotations
 for abstractions applications: sometimes they should be expanded
 (for MIDI rendering, always) and sometimes not (in typesetting,
 to create repetition marks instead of actually repeating notes).


 PS: I agree that some of lilypond's context dependencies
 (relative pitch, implicit note length) do really save
 large amounts of tedious typing: c4 e g a c1 is much more economical
 than [c 1 qn, e 1 qn, g 1 qn , a 1 qn, c 2 fn]
 which I guess is the Haskore equivalent.




 ___
 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] Int is broken [Was: Different answers on different machines]

2013-06-02 Thread Stephen Tetley
There was a quite long discussion here:

http://conal.net/blog/posts/notions-of-purity-in-haskell


On 2 June 2013 22:02, Tommy Thorn tt1...@yahoo.com wrote:
...
 I wish this fatal flaw would be reconsidered for the next major revision.

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


Re: [Haskell-cafe] [haskell.org Google Summer of Code 2013] Approved Projects

2013-05-30 Thread Stephen Tetley
Similarly (to some degree), in the ML world John Reppy had a very nice
system that employed user customization via combinators rather than
inference to generate application/library specific FFIs, see:

http://people.cs.uchicago.edu/~jhr/papers/2006/gpce-fig.pdf

On 29 May 2013 18:57, Jason Dagit dag...@gmail.com wrote:

 Are you folks aware of the work on this topic by Tristan Ravitch?
 https://github.com/travitch/foreign-inference

 Jason

 ___
 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] Infrastructure for testing the impact of a Functor/Applicative/Monad hierarchy

2013-05-16 Thread Stephen Tetley
Has anyone surveyed the in-print textbooks, tutorials, or tried to
assess how much Haskell (H98, H2010, Glasgow Haskell?) is used in
teaching?

Having the wrong hierarchy is a minor annoyance to us members of the
cognoscenti, but a change outside a revision of the language standard
could leave a lot of beginners and the teaching material they rely on
stranded.

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


Re: [Haskell-cafe] Backward compatibility

2013-05-02 Thread Stephen Tetley
Hi Adrian

I don't want to argue against your rant for the sake of it, but
Haskell is a fairly conservative language. The Glasgow Haskell
Compiler supports it's own dialect Glasgow Haskell which is fast
moving, but the developers of GHC do work hard to maintain
compatibility with standard Haskell 98 and Haskell 2010 (optionally
enabled with compiler flags). Afterall Haskell now is fairly widely
used as a teaching language which befits stability as course
textbooks, lecture plans etc. can't be in hock to a language that
changes every year.

Best wishes

Stephen

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


Re: [Haskell-cafe] partially applied data constructor and corresponding type

2013-04-28 Thread Stephen Tetley
What you probably want are type level integers (naturals)

Yury Sulsky used them in the message above - basically you can't use
literal numbers 1,2,3,... etc as they are values of type Int (or
Integer, etc...) instead you have to use type level numbers:

data One
data Two

Work is ongoing for type level numbers in GHC and there are user
libraries on Hackage so there is a lot of work to crib from.

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


Re: [Haskell-cafe] Haskell compilation errors break the complexity encapsulation on DSLs

2013-04-23 Thread Stephen Tetley
Helium - Utrecht University's simplified Haskell - had scriptable
Type inference directives so the creator of an EDSL was able to
augment the type checker to provide better error messages, see:

Scripting the Type Inference Process
Bastiaan Heeren Jurriaan Hage S. Doaitse Swierstra

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


Re: [Haskell-cafe] Contravariant applicatives, monads and arrows (was ANN: rematch, an library for composable assertions with human readable failure messages)

2013-04-16 Thread Stephen Tetley
On 16 April 2013 16:12, Alejandro Serrano Mena trup...@gmail.com wrote:
 Hi,
 First of all, let me say that this work on matchers is really useful :)

 Following Roman advice, I'm trying to find a more principled approach
 that could be useful for this library. It seems that Match could
 easily be converted to Either and thus made into Functor, Applicative,
 Alternative and Monad. That would allow to write things like:



Have you seen Ralf Hinze, Johan Jeuring and Andreas Loeh's  paper on Contracts?

The found their Contract datatype formed a comonad - at the time this
seemed to be one of the few (non-synthetic) uses of comonads.

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


Re: [Haskell-cafe] Prolog-style patterns

2013-04-08 Thread Stephen Tetley
This is a recurring theme, see also here:

http://www.haskell.org/pipermail/haskell-cafe/2009-May/061498.html

On 8 April 2013 16:53, Tom Murphy amin...@gmail.com wrote:


 Also, for some history, this was discussed a while back:
 http://www.mail-archive.com/haskell@haskell.org/msg03721.html


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


Re: [Haskell-cafe] graphical editor links ?

2013-04-01 Thread Stephen Tetley
A while ago there was a framework Blobs for building box-connector
diagram editors.

It is probably a somewhat bit-rotted now:

http://www.cs.york.ac.uk/fp/darcs/Blobs/

I seem to remember a Haskell Workshop report about Dazzle (the
application that was the genesis of Blobs) but it doesn't appear to be
linked from that page.

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


Re: [Haskell-cafe] install cuda

2013-03-31 Thread Stephen Tetley
It looks like you are using Cygwin for a Unix-alike environment. For
building Haskell bindings to C libraries you are better off with MinGW
+ MSYS.

On 30 March 2013 19:43, Peter Caspers pcaspers1...@gmail.com wrote:

 I am trying to install the cuda package on a Windows 7 enviroment. However I
 run into an error and can not figure out, what it is.

 Can someone help ?

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


Re: [Haskell-cafe] Parser left recursion

2013-02-20 Thread Stephen Tetley
More primitively, Parsec and its predecessor Hutton-Meijer provide the
chainl/chainr combinators, these automatically remove left recursion
within the parser - i.e. you don't have to rewrite the grammar.

On 20 February 2013 08:19, Dmitry Olshansky olshansk...@gmail.com wrote:
 Did you see expression parser in parsec package? Is it not enough?


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


Re: [Haskell-cafe] searching the attic for lambada

2013-02-13 Thread Stephen Tetley
Hi John

I have a copy of version 0.1 and a related PDF - I'll email you as
attachments them offlist

On 13 February 2013 14:16, John Lask jvl...@hotmail.com wrote:

 I'm interested in resurrecting the idl generator from lambada:

 http://www.dcs.gla.ac.uk/mail-www/haskell/msg02391.html

 is the code out there in anyone's attic?


 ___
 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] CoArbitrary

2013-02-09 Thread Stephen Tetley
I think GAST - the Clean equivalent of Quickcheck - generates
functions. There are certainly quite a few papers by members of the
Clean team documenting how they generate them.

On 9 February 2013 07:07, Tony Morris tonymor...@gmail.com wrote:
[...]
 I hope I have phrased this in a way to make the point. I found it a bit
 difficult to articulate and I do wonder (hope!) that others encounter
 similar scenarios. Thanks for any tips!

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


Re: [Haskell-cafe] Parsec Vs. src exts

2013-02-03 Thread Stephen Tetley
On 2 February 2013 20:08, Sean Cormican seancormic...@gmail.com wrote:

 Can anybody provide me with some guidance on whether to try and create the
 parser using Parsec or if haskell-src is a better option.
 In the case that haskell-src is a better option, are there any tutorials or
 documents that I would benefit from reading?

As Roman Cheplyaka says, go with Haskell-src-exts...

Haskell-src-exts parses real Haskell - including most (if not all?)
GHC extensions. If you were wanting to analyze 'in the wild' Haskell
projects you might also want to use CPPHS as many Haskell projects use
the CPP preprocessor.

Once you have chosen the appropriate parse function (I remember that
haskell-src-exts provides quite a few) there is not much work to using
haskell-src-exts.

Writing your own parser with Parsec would be quite a lot of work. But
it would it might be an advantage if you want, say, custom error
reporting. Also, if your micro-Haskell is not actually a proper subset
of Haskell, then you would have to write your own parser.

The original distribution of Parsec (available from Dann Leijen's
legacy page at the Utrecht University) has parsers for two small
functional languages Mondrian and Henk that are syntactically quite
close to Haskell. These are useful starting points if you choose the
Parsec route.

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


Re: [Haskell-cafe] Monadic parser vs. combinator parser

2013-01-30 Thread Stephen Tetley
On 30 January 2013 12:38, Ertugrul Söylemez e...@ertes.de wrote:


 A monadic parser /is/ a combinator parser.  The code you linked just
 doesn't go as far as wrapping it up with a newtype and providing a monad
 instance.


Further, (+) in the linked example is monadic bind and `result` is `return`.

The code looks more succinct than early Parser combinator libraries
(like Hutton / Meijer) because it defines quite a few more
combinators. Equivalents are available if you use say Parsec plus the
usual applicative combinators.

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


Re: [Haskell-cafe] resources for learning Hindley-Milner type inference for undergraduate students

2013-01-18 Thread Stephen Tetley
There is a summary paper by Sunil Kothari and James L. Cladwell
covering the algorithms M, J and W with informal presentations plus
code available in Ocaml. Paper is on Citeseer, code is available from
Sunil Kothari's home page.

Martin Grabmueller has a tutorial implementation of algorithm W in Haskell:

http://www.grabmueller.de/martin/www/pub/pub.en.html

On 18 January 2013 10:06, Petr P petr@gmail.com wrote:
   Dear Haskellers,

 could somebody recommend me study materials for learning Hindley-Milner type
 inference algorithm I could recommend to undergraduate students?

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


Re: [Haskell-cafe] Generating random arguments for a function

2013-01-13 Thread Stephen Tetley
In general you can't do this whether you use pats of QuickCheck or not
- `randomEvalute` would need to inspect the supplied function to see
how many input parameters it has so it can list them, but there is no
such introspection in Haskell.

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


Re: [Haskell-cafe] Generating random arguments for a function

2013-01-13 Thread Stephen Tetley
Yes - I was just checking the first QuickCheck paper to see how the
authors did this.

You would need a new type class that works like `Testable` and the
versions of associated machinery `forAll` and `evaluate` to unroll
function application.


On 13 January 2013 09:28, Roman Cheplyaka r...@ro-che.info wrote:


 This can be done with relatively simple type class hackery. In fact,
 QuickCheck already does that in order to generate arguments and print
 them in case of failure.

 Roman

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


Re: [Haskell-cafe] Difference Lists versus Accumulators

2013-01-08 Thread Stephen Tetley
See the first Worker / Wrapper paper by Andy Gill and Graham Hutton.
Particularly there is exactly this derivation of reverse through
preliminarily using a Hughes (difference) list.

On 8 January 2013 12:22, Edsko de Vries edskodevr...@gmail.com wrote:
 Hey all,

 The connection between difference lists and accumulators is probably
 well known, but I only recently realized it myself and a quick Google
 search didn't find turn up any page where this was explicitly stated,
 so I thought this observation might be useful to some.

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


Re: [Haskell-cafe] Navigating 'Strategic' programming babel

2012-12-17 Thread Stephen Tetley
Strafunski is now rather out of date - it was developed before Cabal
and used a custom install depending whether or not you wanted to use
the DriFt preprocessor.

Andy Gill has a modern re-implementation of Strafuski on Hackage called KURE.

Aside from SYB, Neil Mitchell's Uniplate is popular and generally well
documented.

On 17 December 2012 11:12, Ravi Sahni ganeshsahn...@gmail.com wrote:

 However it seems that the strafunski-ecosystem being integrated with aterm
 etc, likewise stratego, are more suited to full-scale language processing.


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


Re: [Haskell-cafe] Exploring Programming Language Theory

2012-12-09 Thread Stephen Tetley
If you want compiling functional languages and can relax the
requirement for up to date:

Antoni Diller's Compiling Functional Languages is good. It is short
enough (300 pages) that you could reasonably work through it and it
includes the full source of a compiler in the appendix - written in
Pascal so translating it to something else is a sufficient exercise.
It is long out of print, but copies turn up on Amazon - I got it from
Amazon UK for a couple of pounds.

Also Franklyn Turbak and David Gifford's Design Concepts for
Programming Languages is very good (and new!) but huge. It is not
quite exhaustive - as a skim reader I wanted the specification /
translation rules for a particular compile step and frustratingly it
was left as an exercise. Otherwise it is a very good presentation - it
uses translation rules (ala the LaTeX Semantic package) rather than
source code throughout, so once you are used to the style it is both
very concise (and precise) and unlikely to go out of date any time
soon.

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


Re: [Haskell-cafe] Design of a DSL in Haskell

2012-12-04 Thread Stephen Tetley
In Haskell, shallow DSLs generate values - deep DSLs generate
structures (typically abstract syntax trees), the structure can
subsequently be used to generate a value (or a C program, or a HTML
page, etc.).

See Andy Gill and colleagues Types and Type Families for Hardware
Simulation and Synthesis, The Internals and Externals of Kansas Lava
for a fuller definition.

http://www.ittc.ku.edu/csdl/fpg/sites/default/files/Gill-10-TypesKansasLava.pdf

Other communities may have their own definitions.

On 4 December 2012 10:01, Kim-Ee Yeoh k...@atamo.com wrote:
 On Tue, Dec 4, 2012 at 4:53 PM, Joerg Fritsch frit...@joerg.cc wrote:
 is a shallow embedded DSL == an internal DSL and a deeply embedded DSL ==
 an external DSL or the other way around?

 Roughly speaking, yes. But a deep DSL doesn't mean you've got to have a
 parser  tokenizer  IO input. You can get a deep DSL merely from the free
 monad construction.

 -- Kim-Ee

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


Re: [Haskell-cafe] Is there any movement/need in new 'base' package and co?

2012-12-02 Thread Stephen Tetley
Haskell 2010 avoided library revisions - 12 years had elapsed since
the last language definition and updating the language was deemed the
priority. There have been suggestions on the Libraries list that the
next major language revision should also look at the core libraries.



On 2 December 2012 18:59, Евгений Пермяков permea...@gmail.com wrote:
 So, the questions arise:
 - When problems will ruin the language?
 - When and which actions are needed to avoid this?
 - If major rewrite will be initiated, what problems it should target?
 - And how to make the transition easier?


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


Re: [Haskell-cafe] To my boss: The code is cool, but it is about 100 times slower than the old one...

2012-11-29 Thread Stephen Tetley
On 29 November 2012 18:09, Fixie Fixie fixie.fi...@rocketmail.com wrote:


 What is your experience, dear haskellers? To me it seems this beautiful
 language is useless without a better lazy/eager-analyzer.


Since when has speed been the sole arbiter of utility?

10 years ago I switched from Clean to Haskell, even though Clean was
then faster (and included a good strictness analyser). The available
libraries for Haskell is what swung the decision for me.

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


Re: [Haskell-cafe] OpenAL - compiling problem

2012-11-28 Thread Stephen Tetley
Hi Gary

Which version of GHC are you using?

My suspicion is that ALCdevice might be a newtype falling foul of
recent changes to GHC...

v7.4.1: GHC now requires, as per the standard, that if a newtype is
used in an FFI declaration, then the constructor for that type must be
in scope. For now you only get a warning if it is not, but in the
future this will be an error.

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


Re: [Haskell-cafe] OpenAL - compiling problem

2012-11-28 Thread Stephen Tetley
I think OpenAL is now unmaintained. You could try to find AndrewMiller
who updated the last version, otherwise you might have to patch it
yourself or ask a developer of a dependent package if they would
consider pushing another unmaintained release to Hackage.

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


Re: [Haskell-cafe] Instead of Haskell running on the JVM is there a way for Haskell to call a JVM language ...

2012-11-20 Thread Stephen Tetley
There has been, as Antony Courtney was using Java2D for vector
graphics called from Haskell in his Haven system.

The FFI was GCJNI (Green Card JNI) - I'm not sure where it exists now
or how much it has bit rotted.

On 20 November 2012 05:36, KC kc1...@gmail.com wrote:
 Instead of Haskell running on the JVM is there a way for Haskell to
 call a JVM language (or generate bytecode) to access the Java class
 libraries when needed?


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


Re: [Haskell-cafe] Parsing different types, same typeclass

2012-11-18 Thread Stephen Tetley
With existentials an extesible version might look like this:

 {-# LANGUAGE ExistentialQuantification #-}
 {-# LANGUAGE ScopedTypeVariables #-}


... class Action and datatypes A and B the same as before ...


 -- some new ones...

 data C = C Int
  deriving (Read, Show)


 instance Action C where
  run (C n) = n


 data D = D Int
  deriving (Read, Show)

 instance Action D where
  run (D n) = n


The important one:

 data PolyA = forall a. Action a = PolyA a


 parseAction :: String - PolyA
 parseAction str
  | (A  `isPrefixOf` str = PolyA $ (read :: String - A) str
  | (B  `isPrefixOf` str = PolyA $ (read :: String - B) str

  -- can add new cases
  | (C  `isPrefixOf` str = PolyA $ (read :: String - C) str
  | (D  `isPrefixOf` str = PolyA $ (read :: String - D) str


This is extensible to some degree as you can add new cases of
different types, but all you can do with these different types is
run them to make an Int, so it is equivalent to the second version I
gave previously:

 parseAction :: String - Int
 parseAction str
 | (A  `isPrefixOf` str = run $ (read str :: A)
 | (B  `isPrefixOf` str = run $ (read str :: B)
 | (C  `isPrefixOf` str = run $ (read str :: C)
 | (D  `isPrefixOf` str = run $ (read str :: D)

i.e instead of using an existential type to hold something polymorphic
that can be run to produce an Int, just call run at the point of use
making an Int.

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


Re: [Haskell-cafe] Parsing different types, same typeclass

2012-11-17 Thread Stephen Tetley
Being concrete, all you can do is:

parseAction :: String - Either A B
parseAction str
| (A  `isPrefixOf` str = Left $ read str
| (B  `isPrefixOf` str = Right $ read str


parseAction :: String - Int
parseAction str
| (A  `isPrefixOf` str = run $ (read str :: A)
| (B  `isPrefixOf` str = run $ (read str :: B)

As you can't return a polymorphic /a/ when you have typed the cases to A or B.

Being less concrete, no doubt you can use existentials, but at this
point I'd recommend you re-evaluate what you are trying to do.

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


Re: [Haskell-cafe] curl package broken in Windows

2012-11-09 Thread Stephen Tetley
Isn't Curl a C library (with a Haskell binding)?

For Haskell bindings the best environment on Windows is usually MinGW
/ MSys, but your error suggests you should be building from Cygwin in
this case.

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


Re: [Haskell-cafe] curl package broken in Windows

2012-11-09 Thread Stephen Tetley
I've just checked Hackage - the Curl package (haskell) is a binding
to libcurl (c library).

It looks like MinGW / MSys is the best option - there are some notes
are written by Sigbjorn Finne (who wrote the Haskell binding) although
they are now quite old:

http://haskell.forkio.com/Home/curl-win32

It looks like Sigbjorn, was cross compiling a MinGW build for libcurl
from Cygwin, instead I'd build under a proper installation of MinGW /
MSys. The bits of MinGW that are distributed with GHC aren't
sufficient for this - you will need a proper installing of MinGW /
MSys.

On 9 November 2012 20:13, Stephen Tetley stephen.tet...@gmail.com wrote:
 Isn't Curl a C library (with a Haskell binding)?


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


Re: [Haskell-cafe] Partial application in case expression rules

2012-11-05 Thread Stephen Tetley
There's a Glasgow extension that gets you to this:

treeFold :: (a - a - a) - Tree a - a
treeFold f = \case
  Leaf {} -  id
  Node {} - f `on` treeFold f

Or maybe this if parens are needed:

treeFold :: (a - a - a) - Tree a - a
treeFold f = \case
  (Leaf {}) -  id
  (Node {}) - f `on` treeFold f

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


Re: [Haskell-cafe] Segment Tree based Set

2012-10-29 Thread Stephen Tetley
Are Martin Erwig's diets anything close?

http://web.engr.oregonstate.edu/~erwig/diet/

On 29 October 2012 04:48, Tony Morris tonymor...@gmail.com wrote:
 Hi,
 I was wondering if anyone knows of a package implementing a fast lookup
 for an element in ranges.

 For example, this operation:
 Ord a = a - [(a, a)] - Bool


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


Re: [Haskell-cafe] serialize an unknown type

2012-10-24 Thread Stephen Tetley
Hi Corentin

It looks like you are writing the event handler on the server side. If
so, the range of events you can handle is fixed to just those you
implement handlers for - having an openly extensible event type is
useless if this is the case.

Ignoring client/server for a moment, a function (State - State) would
be the most extensible API you could allow for clients. You don't
need to worry about an open set of Event types, a client knows the
state exactly and doesn't need extensibility.

Client/Server operation won't allow a state transformer API as Haskell
can't readily serialize functions. But you can implement a command
language enumerating state changing operations. The second Quickcheck
paper gives a very good example of how to implement such a command
language.


Testing Monadic Code with QuickCheck (2002)
Koen Claessen , John Hughes
www.cse.chalmers.se/~rjmh/Papers/QuickCheckST.ps

Or Citeseer if you need a PDF:
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.19.9275

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


Re: [Haskell-cafe] Which advanced Haskell topics interest you

2012-10-04 Thread Stephen Tetley
On 4 October 2012 18:04, Kim-Ee Yeoh k...@atamo.com wrote:
 Something to consider is that it's not so much whether the material is
 basic, advanced, or intermediate; it's that the way it's being presented is
 boring and ineffective.

I'd suggest there is enough range in the Haskell books now available,
that for most tastes, there's a beginners to intermediate book already
a given learner wouldn't consider boring. Of course different learners
will like different ones...

As for an advanced book, maybe limiting the subject to one domain
(concurrency / DSLs for graphics / pick a favourite ...) might
make a better book than one targeting a mix of advanced topics.

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


Re: [Haskell-cafe] type variable in class instance

2012-09-10 Thread Stephen Tetley
Whilst dynamic typing isn't idiomatic for Haskell, it seems like
you've decided you want it. So why not use Data.Dynamic rather than
roll you're own dynamic typing with Typeable?

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


Re: [Haskell-cafe] Best way to build a GHC backend?

2012-07-09 Thread Stephen Tetley
On 9 July 2012 15:38, Brent Yorgey byor...@seas.upenn.edu wrote:
 I should point out that the ball already IS rolling -- ranging from
 EDSLs that compile to JavaScript [1,2] to macro systems [3] to more
 serious full-featured efforts [4,5].

Also, a JavaScript backend has recently been developed for Clean, the
other major lazy functional language.

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


Re: [Haskell-cafe] Origin of Delimited Continuation Operators

2012-06-25 Thread Stephen Tetley
You could try working back from the references in Dorai Sitaram's
Handling Control 1993, which is an important paper in the Scheme
community covering this area.

http://www.cs.rice.edu/CS/PLT/Publications/Scheme/pldi93-s.ps.gz

Shift for instance is referenced back to at least Davy and Filinski's
Abstracting Control 1990.

On 25 June 2012 03:13, aditya siram aditya.si...@gmail.com wrote:
 Hi all,
 I working through a few papers and Oleg's delimited continuation
 implementation and I'm wondering how the operators (shift, shift0P,
 control, reset, etc) got their name.
 -deech

 ___
 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] Origin of Delimited Continuation Operators

2012-06-25 Thread Stephen Tetley
On 25 June 2012 18:02, Stephen Tetley stephen.tet...@gmail.com wrote:

 Shift for instance is referenced back to at least Davy and Filinski's
 Abstracting Control 1990.

Typo - Olivier _Danvy_ not Davy

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


Re: [Haskell-cafe] Martin Odersky on What's wrong with Monads

2012-06-24 Thread Stephen Tetley
False!

You only have to change the parts of the program that need the effect
that the monad provides. A well designed program will likely have much
of its code in pure libraries. Think of the monadic code as a
scripting language that you bind your libraries together with to
make the program.

On 24 June 2012 06:31, Jonathan Geddes geddes.jonat...@gmail.com wrote:
 Cafe,
[SNIP]

 What's wrong with Monads is that if you go into a Monad you have to change
 your whole syntax from scratch. Every single line of your program changes if
 you get it in or out of a Monad. [SNIP]

 Thoughts?


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


Re: [Haskell-cafe] Haskell is rapidly approaching the top 20

2012-06-17 Thread Stephen Tetley
Ah, enjoy it while it lasts. In April, Kuzcek PLT Institut, Kazakhstan
[*] and the Club of Rome  declared 2012 as the year of Peak FP. It's
downhill from here on…

[*] aka @plt_borat on Twitter - whose views are probably no more
unreliable than Tiobe.

On 16 June 2012 22:58, Henk-Jan van Tuyl hjgt...@chello.nl wrote:

 -✂
 TIOBE [snip]

 [Snip] what language could become the
 next big new programming language. We suggested several candidates such as
 Scala, Erlang and Clojure. Clearly, the new thing was expected to come from
 the functional programming field. ...

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


Re: [Haskell-cafe] Finding the average in constant space

2012-05-27 Thread Stephen Tetley
There are a few blog posts by Conal Elliott and Max Rabkin (I think)
reifying folds as a data type to get more composition and thus fold
different functions at the same time. Search for beautiful folding
with the above authors names.

Personally I didn't find the examples significantly more beautiful
that using regular composition in a normal fold - only that that the
helper functions to manage pairs aren't in the standard library.

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


Re: [Haskell-cafe] Building pattern and trying monads

2012-05-27 Thread Stephen Tetley
It's common to use a writer monad possibly stacked with other monads
(e.g. a state monad for fresh variable names) for code generation that
approximates macro expansion - i.e. one call in Haskell maps to
one-or-more lines of code in the output language, no global
transformations are permitted.

If you want transformations, then it is likely you will need to model
the syntax of the output language or an intermediate language to have
something concrete to transform.

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


Re: [Haskell-cafe] Can Haskell outperform C++?

2012-05-21 Thread Stephen Tetley
On 21 May 2012 17:27, Yves Parès yves.pa...@gmail.com wrote:

 I fail to see how the GUI part would suffer from lack of performance if the
 rest of the system is fine. I would hate to be bold, but to me this case
 sounds a little bit like MVC done wrong if the breaking GUI apart from the
 rest of the software is really that impossible.

A few years ago one of the architects at Adobe published some slides
on the software engineering aspects of PhotoShop, unfortunately I
couldn't find them on the web when I tried recently but I believe it
stated the codebase was well over 1 million lines of C++ and the GUI
(including Adobe's own frameworks) accounted for more than half of
that...

GUI's often *are* the program rather than a way in to use it.

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


Re: [Haskell-cafe] darcs patch dependencies in dot format

2012-05-16 Thread Stephen Tetley
 On 16 May 2012 19:43, wren ng thornton w...@freegeek.org wrote:

 You should probably farm out the toDot rendering to one of the libraries
 that focuses on that[1], since they'll have focused on the efficiency
 issues--- or if they haven't, then you can contribute improvements there,
 helping everyone win. In particular, you're using Strings which is a
 notorious performance sink. Using Text or ByteStrings would be far better.


I'm not sure swapping to Text or ByteStrings make be much great shakes
for this. If you are generating huge files, where it would count -
then the files are going to be a real problem for Graphviz to render
(unless Graphviz has seen some optimization recently...).

That said, I would recommend Sönke uses a pretty print library rather
than Printf as using the former makes for much more idiomatic for
Haskell and generally performs well enough for generational
activities even if it uses Strings internally.

Best wishes

Stephen

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


Re: [Haskell-cafe] Data-Type Serialization

2012-04-23 Thread Stephen Tetley
I think both ATerms and the Zephyr project's ASDL could handle
recursive types - certainly ASDL was a sum and product representation
like ML or Haskell's algebraic types (ATerms were a bit more like
Prolog). Both never gained much traction and for better or worse JSON
won the game.

I implemented generators for both a very long time ago when I was
staring out with Haskell. I didn't use TH or a generics library. If I
were doing it again now I'd start with a generics library and see how
that pans out - basically you want a type representation and generics
libraries have that already. Also I'm no fan of TH.

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


Re: [Haskell-cafe] prettyprint with IO

2012-04-13 Thread Stephen Tetley
Haskell-src-exts has had a monadic wrapper over HughesPJ for a long
time. It is just a Reader (not a transformer) so it can handle user
supplied spacing widths, etc.


On 13 April 2012 06:02, Warren Harris warrensomeb...@gmail.com wrote:

 Thanks for the suggestions. No sooner did I send my message than I came to
 the same conclusion of creating a monadic version of the combinators to
 simplify the migration.

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


Re: [Haskell-cafe] Mixing Unboxed Mutable Vectors and Parsers

2012-04-08 Thread Stephen Tetley
Hi Myles

It seems odd to mix parsing (consuming input) with mutation.

What problem are you trying to solve and are you sure you can't get
better phase separation than this paragraph suggests?


 My first idea was to simply parse all the deltas, and later apply them
 to the input list. However, I can't do that because the value of the
 deltas depend on the value they're modifying.

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


Re: [Haskell-cafe] Mixing Unboxed Mutable Vectors and Parsers

2012-04-08 Thread Stephen Tetley
On 8 April 2012 19:17, Myles C. Maxfield myles.maxfi...@gmail.com wrote:
 It's a JPEG parser.


Ahem, I'm a bit of of my depth then, but one thing you should consider
is that writing your own parser monad is trivial, especially for well
defined binary formats. Well defined binary formats should be
deterministic and don't need backtracking, hence you won't need to
worry about defining Alternative / MonadPlus instances which is where
the complication lies.

As you should be able to live without backtracking for JPEG it
shouldn't be hard to make the parser efficient if you stick closely to
the API of the Vector or Array library you are using - e.g. you might
want to move a cursor forward through the Array rather than
unconsing [*] at the head which would create work for the garbage
collector. This should still be amenable to streaming - you just work
at a larger chunk size.


Presumably you've seen Jeroen Fokker's paper on JPEG decoding with
Gofer? (Gofer is ~= Haskell).

[*] Parsec etc. work by unconsing the head of the input stream.

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


Re: [Haskell-cafe] Fail-back monad

2012-04-05 Thread Stephen Tetley
There is also recent work by Aaron Turon and Olin Shivers - Modular
Rollback through Control Logging

http://www.ccs.neu.edu/home/shivers/
http://www.ccs.neu.edu/home/turon/

Note that as well as the paper on Olin Shivers's site there is a more
recent monadic presentation on Aaron Turon's site with Conor
McBride...


On 28 March 2012 18:11, Stephen Tetley stephen.tet...@gmail.com wrote:
 Maybe this is a version of William Harrison's DebugT monad with
 rollback, listed in his periodic table of effects?

 http://www.cs.missouri.edu/~harrisonwl/Presentations/UIUCFM05.ppt

 I've never seen a definition of the monad itself...
 http://www.haskell.org/pipermail/beginners/2010-January/003371.html

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


Re: [Haskell-cafe] Generalizing (++) for monoids instead of using ()

2012-04-02 Thread Stephen Tetley
It is somewhat idiomatic to read it as TeX's \diamond symbol. Various
papers set with Lhs2TeX use it for general composition operator
(sometimes concat / mappend).

On 2 April 2012 10:05, Yves Parès yves.pa...@gmail.com wrote:
 Plus one might argue that using  to mean different is a bad choice, as it
 graphically means strictly inferior or strictly superior which implies
 comparability, whereas equality and comparison are two different things.
 (e.g. Eq and Ord are two distinct classes in Haskell).

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


Re: [Haskell-cafe] for = flip map

2012-03-30 Thread Stephen Tetley
I've always thought this was missing for parser combinator libraries
as there is the notational tradition from YACC etc. to have production
at the left then action at the right.

On 29 March 2012 22:03, Sjoerd Visscher sjo...@w3future.com wrote:

 or perhaps

    infixr 0 $$
    ($$) = flip ($)

    xs $$ \x - ...

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


Re: [Haskell-cafe] Fail-back monad

2012-03-28 Thread Stephen Tetley
Maybe this is a version of William Harrison's DebugT monad with
rollback, listed in his periodic table of effects?

http://www.cs.missouri.edu/~harrisonwl/Presentations/UIUCFM05.ppt

I've never seen a definition of the monad itself...
http://www.haskell.org/pipermail/beginners/2010-January/003371.html

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


Re: [Haskell-cafe] How to handle C library dependencies on Hackage?

2012-03-25 Thread Stephen Tetley
Hi Christian

Usually people host the documentation on their own site and put a link
in the description field of the cabal file, pointing users to it.

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


Re: [Haskell-cafe] Un-memoization

2012-03-22 Thread Stephen Tetley
Hi Victor

There was a paper at one of the early PADL conferences describing
out-out-core data structures in Ocaml. I've never seen anyone
following up this work, possibly because RAM has got so cheap in the
last decade. If you have such large trees you may find the paper
interesting.

Although the authors used Caml they did use monads.

Tyng-Ruey Chuang and Shin-Cheng Mu, Out-of-core functional
programming with type-based primitives,

The paper seems to be on Citeseer.

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


Re: [Haskell-cafe] MSIL manipulation libraries

2012-03-21 Thread Stephen Tetley
I think there are two libraries for CIL on Hackage, one is for
Microsoft's CIL (aka MSIL) the other is for George Necula et als CIL
(C Intermediate Language). Obviously you want the one for Microsoft
CIL.

http://hackage.haskell.org/package/language-cil

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


Re: [Haskell-cafe] HughesPJ vs. Wadler-Leijen

2012-03-20 Thread Stephen Tetley
A quick suggestion - does setting the ribbon_frac to something like
0.8 improve things?

The Show instance for wl-pprint's Doc uses 0.4 which I've found too low.

This means you'll have to write your own display function using
`renderPretty`...

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


Re: [Haskell-cafe] HughesPJ vs. Wadler-Leijen

2012-03-20 Thread Stephen Tetley
Ahem - there was a severe typo in my last message. Usually I wouldn't
spam the list to repair my failings but edit distance on the error in
that message was so large it made no sense at all.


 printing that cannot be undone by `group`, or the combinators that use
 group are given more long-winded **names** to make them secondary. I've
 bits and bobs on the go to do this, but nothing near a concrete
 library.

Apologies to all.

(Funny how I can spot typos after the fact...)

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


Re: [Haskell-cafe] Google Summer of Code idea of project application

2012-03-19 Thread Stephen Tetley
Hi Damien

A translator might be a lot of work.

Matthew Naylor had a translator between Haskell and Clean [1], which
performed well according to [2]. The translator was his Master project
in the UK so I think that means it would represent approximately a
years work.

[1] http://www-users.cs.york.ac.uk/~mfn/hacle/hacle.pdf
[2] http://www.st.cs.ru.nl/papers/2010/groj10-Haskell_front_end_Clean.pdf

The paper [2] covers the Clean groups own interop between Haskell and
Clean and points to more related work alongside Matthew Naylor's.

Best wishes

Stephen

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


Re: [Haskell-cafe] cabal-install problem with alex dependency in bytestring-lexing

2012-03-16 Thread Stephen Tetley
Alex is supplied as part of the Platform though which is the
recommended system for beginners, is Yesod currently in advance of the
Platform?

On 16 March 2012 10:56, Erik de Castro Lopo mle...@mega-nerd.com wrote:

 The problem is that many of the people trying out Yesod are newcomers to
 Haskell. They are going to try  cabal install yesod and have it fail
 because alex is missing. This is not a good introduction Haskell/Yesod.

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


Re: [Haskell-cafe] Adding type annotations to an AST?

2012-03-14 Thread Stephen Tetley
Hi Sean

Many thanks - the note on flow-issues might be particularly helpful
for me (last para section 4 introduction). My current code has a bug
which maybe this identifies.

I'm currently using a modified algorithm M which I believe is top
down, I'll switch to algorithm W.

Thanks again

Stephen

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


Re: [Haskell-cafe] using mutable data structures in pure functions

2012-03-12 Thread Stephen Tetley
There is a trick to `nub` where you couldn't implement the internal
lookup list with an (assumed faster) search tree anyway.

`nub` only mandates equality not ordering, so building a ordered
structure like a binary tree is impossible. In practice i would be
hard to beat list as the intermediate structure in this case.

On 12 March 2012 03:38, E R pc88m...@gmail.com wrote:
[Chop]

 For example, consider the definition of Data.List.nub:

 nub l                   = nub' l []
  where
    nub' [] _           = []
    nub' (x:xs) ls
        | x `elem` ls   = nub' xs ls
        | otherwise     = x : nub' xs (x:ls)

 Clearly the memory allocated to ls never escapes nub', so it seems
 that ls could be replaced with a mutable data structure (with an eye
 towards improving performance in special cases).

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


Re: [Haskell-cafe] Adding type annotations to an AST?

2012-03-06 Thread Stephen Tetley
Hi Oleg - many thanks



On 6 March 2012 07:15,  o...@okmij.org wrote:

 How do I add type annotations to interior locations in an abstract
 syntax tree?
 {Snip}
        Here is the solution
 http://okmij.org/ftp/Computation/FLOLAC/TEvalNR.hs

        There is a bit of the explanation here:
 http://okmij.org/ftp/Computation/FLOLAC/lecture.pdf



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


Re: [Haskell-cafe] Adding type annotations to an AST?

2012-03-05 Thread Stephen Tetley
Partially answering my own question - it seems like I want type
directed translation as per section 8 of Practical Type Inference
for Arbitrary Ranked Types.

Does anyone know of a presentation with a simpler type language?

Thanks again

Stephen

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


[Haskell-cafe] Adding type annotations to an AST?

2012-03-04 Thread Stephen Tetley
Hello All

How do I add type annotations to interior locations in an abstract syntax tree?

I have a small ML language where programs are a single expression, but
the expression type has let-rec so it supports recursive function
definitions. Source programs have no type annotations.

I want to annotate the lec-rec with type annotations, but my type
inference is a simple implementation of Algorithm J so it seems
monolithic to me - i.e. the type it infers is the type of the whole
program, I would also like  the types of any internal let-rec
definitions so I can label my AST.

What is the idiom for accomplishing this?

I'm using Eijiro Sumii's MinCaml as reference - this embeds mutable
references for types in the AST. So this appears a non-starter.

My other thought is to uniquely label all type locations during
parsing then collect them in a map (location - type) whilst computing
the outermost type - I presume I can identify inner types as they are
resolved during Algorithm J's run...

Any solutions?

Many thanks

Stephen

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


Re: [Haskell-cafe] Impact of try on Parsec performance

2012-03-03 Thread Stephen Tetley
I'd suggest `try` can make parsers had to debug and fragile when refactoring.

`try` is very useful for char parsers, where you don't really want to
be sharing a prefix amongst different parsers. For regular parsers you
have equivalents of the EBNF operators plus the `sepBy` etc. parsers
so the obsessive left recursion removal you see in text books isn't
so burdensome - you have combinators to help you do it rather than
having to rely on introducing more productions.

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


Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-28 Thread Stephen Tetley
On 28 February 2012 17:06, Johan Holmquist holmi...@gmail.com wrote:

 Function 'withPair' takes a pair and applies a function to it's first
 element, another function to it's second element and finally combines
 the results with yet another function.

 withPair :: (a' - b' - c) - (a - a') - (b - b') - (a,b) - c
 withPair f fa fb (a,b) = fa a `f` fb b


withPair is the Dovekie function from combinatory logic but with a
pair for the non-combinator arguments (a,b) and the arg order changed
to be more convenient to program with.

There was a thread about inter[*] on the beginners list last month


http://www.haskell.org/pipermail/beginners/2012-January/009329.html

[*] or an inter-like function depending how you want to treat the
initial value. I made a mistake with my suggestion.

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


Re: [Haskell-cafe] Using multiplate to get free variables from a syntax tree

2012-02-24 Thread Stephen Tetley
I'm not familiar with Multiplate either, but presumably you can
descend into the decl - collect the bound vars, then descend into the
body expr.

  Let $ decl child d * expr child e

This seems like a common traversal that Strafunski would handle, and
with Multiplate being a competitor / successor to Strafunski it should
be able to do it too. Naturally you would need a monadic traversal
rather than an applicative one...

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


Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Stephen Tetley
There is also the DMS from Ira Baxter's company Semantic Design's.
This is an industry proven refactoring framework that handles C++ as
well as other languages.

I think the Antlr C++ parser may have advanced since the article
Antoine Latter link to, but personally I'd run a mile before trying to
do any source transformation of C++ even if someone were waving a very
large cheque at me.

On 24 January 2012 14:54, Christopher Brown cm...@st-andrews.ac.uk wrote:
 Hi Everyone,

 Thanks for everyone's kind responses: very helpful so far!

 I fully appreciate and understand how difficult writing a C++ parser is. 
 However I may need one for our new Paraphrase project, where I may be 
 targeting C++ for writing a refactoring tool.

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


Re: [Haskell-cafe] generating parens for pretty-printing code in haskell-src-exts

2012-01-14 Thread Stephen Tetley
Hi Conal

I don't know if any Haskell src-exts code exists. Norman Ramsey has
published an algorithm for it, plus ML code:

http://www.cs.tufts.edu/~nr/pubs/unparse-abstract.html

I've transcribed the code to Haskell a couple of times for small
expression languages. As far as I remember you need to know what
constructors you are working with so it can't be put in a generic
pretty print library, but the constructor specific code is
stereotypical so it should be easy (if boring) to write for Haskell
src-exts.

Best wishes

Stephen

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


Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Stephen Tetley
On 31 December 2011 12:26, Jerzy Karczmarczuk
jerzy.karczmarc...@unicaen.fr wrote:
 Yves Parès :

 all standard Monads are newtypes wrapping functions

 What about Maybe and [] ?

And Identity ...

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


Re: [Haskell-cafe] Avoiding parametric function binding

2011-12-31 Thread Stephen Tetley
Maybe you want a deconstructor (sometime called an eliminator)?

deconsVar :: (Maybe Int - a) - (Maybe String - a) - Var - a
deconsVar f g (V1 a) = f a
deconsVar f g (V2 b) = g b

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


Re: [Haskell-cafe] MIDI-controlled application

2011-12-27 Thread Stephen Tetley
Hi Tim

Events in FRP / Yampa are typically key presses / mouse movement, so a
MIDI controller generating Note-on / Note-off events would be a direct
analogue to key presses.

More problematic is that FRP models hybrid (continuous and discrete)
systems. For me at least, MIDI seems essentially discrete - a stream
of control events. In MIDI files control events are twinned with a
time stamp so they can be played. Presumably events are instantaneous
in real-time interactive MIDI - not something I've looked at.

Working with an FRP system like Yampa might add a lot of complexity,
which admittedly you should be able to ignore - but initially it might
be difficult to identify what parts are needed for a mostly discrete
system like MIDI. (If you are time-stamping MIDI events yourself you
will presumably need to sample a running clock which seems like a
continuous behaviour...)

Unfortunately I can't think of any systems in Haskell that are more
discrete than continuous so you might have to choose a FRP system
anyway.


Incidentally, I've been working on a MIDI animation language for the
last couple of days based on the animation language in Paul Hudak's
book. I've wanted continuous behaviours to model modulating volumes
(crescendos, decrescendos) and panning, but I've found the work tough
going for modelling the note lists where I want the system discrete in
both input (specification) and output.

Best wishes

Stephen

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


Re: [Haskell-cafe] Generating Code

2011-12-09 Thread Stephen Tetley
Geoffrey Mainland did significant work generating C with his GHC quasi
quote extension. I'm not sure the status or availability of the code
but there was a good Haskell Workshop paper describing it.

For the specific problem of OpenGL - as the package already exists I'm
not sure a generative approach would actually pay its way

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


Re: [Haskell-cafe] Anonymous, Unique Types, maybe

2011-12-03 Thread Stephen Tetley
Umm, an obvious point is that if you really are using lists as streams
they should appear infinite to the processing code, so you shouldn't
encounter operations that fail due to incompatible lengths.

Otherwise I think there might be packages on Hackage for fixed sized
lists, its a common example for the power of GADTs, though personally
I've found size annotated lists unusable at the point where I need
`filter` (which you are calling mySelect?).

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


Re: [Haskell-cafe] Interpreter with Cont

2011-11-21 Thread Stephen Tetley
On 21 November 2011 14:48, Yves Parès limestr...@gmail.com wrote:
 I've read Martin Erwig and Steve Kollmansberger's Probabilistic functional
 programming in Haskell.
 Does someone know if the library they are talking about is available on
 hackage?

Henning Thielemann has a batteries included version on Hackage:

http://hackage.haskell.org/package/probability

I'd expect the original (micro) library is still available from Martin
Erwig's website.

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


Re: [Haskell-cafe] Tutorial/slides on pretty-printing combinators?

2011-11-16 Thread Stephen Tetley
Hi Sean

Doaiste Swierstra has fairly extensive notes on the development of the
attribute grammar versions of uulib's pretty printers.

The notes are called Designing and Implementing Combinator
Languages. As they were a showcase for UUAG there is quite a lot on
attribute grammars in the notes, but the should be still be a good
source of inspiration.

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


Re: [Haskell-cafe] deepseq-1.2.0.1 missing Data.Map instance

2011-11-15 Thread Stephen Tetley
Hello Henry

I think it is a case of the dependency changing recently from deepseq
depending on containers to containers depending on deepseq.

Thus you want to check you are using compatible versions of deepseq
and containers.

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


Re: [Haskell-cafe] ANN: diagrams 0.4

2011-10-24 Thread Stephen Tetley
 Rustom Mody rustompm...@gmail.com writes:

 I remember (vaguely) a 'live page' ie where one could enter (into the
 browser) changes to the diagrams code and see the results immediately.
 Is that page there? (Or am I mixing up with something else?)

Maybe it was Péter Diviánszky's 'dia' (entirely different to 'diagrams') ?

 http://pnyf.inf.elte.hu/fp/Diagrams_en.xml

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


Re: [Haskell-cafe] lost in generics

2011-10-20 Thread Stephen Tetley
On 20 October 2011 18:12, Rustom Mody rustompm...@gmail.com wrote:
 I need some help finding my way around the various generics libraries.

 My usage scenario is -- at least to start with -- the ASTs of programming
 languages.


 In general my question is:  What is alive/active and what is alive/active
 and what is -- um -- moved-on-from.
 And of course which are easier and which more difficult to dig into.


I'd group Strafunski, Uniplate and Kure together as they are all have
extensive traversal control.

Uniplate is a good choice as it is well documented and in active use.

Kure is good if you know Strafunski, but might be a struggle to work
with otherwise.

Strafunski was pre-Hackage and used Drift for pre-processing so
installing it nowadays would be a challenge. However, Strafunksi is
well documented, especially the Design Patterns for Functional
Strategic Programming[*] paper. Its worth reading this even if you
don't use Strafunski.

[*] http://arxiv.org/abs/cs/0204015

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


Re: [Haskell-cafe] ANNOUNCE: vector-bytestring-0.0.0.0

2011-10-19 Thread Stephen Tetley
On 19 October 2011 15:59, AM age...@themactionfaction.com wrote:

 Note that other programming languages have had to solve this exact problem 
 and they usually end up with multiple functions- one for debugging, one for 
 serialization, one for displaying how the object was constructed.


As per Haskell with Show (representation) and Data.Binary
(serialization), of course.

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


Re: [Haskell-cafe] Comparison Haskell, Java, C and LISP

2011-10-18 Thread Stephen Tetley
Haskell has no support for reflection whatsoever.

It can support compile time meta-programming with Template Haskell.

Reflection itself might be antagonistic to functional programming, I
suspect it is at odds with referential transparency. Most of the work
on reflection seemed based around Lisp / Scheme - Christian Queinnec's
reflective interpreter in Lisp in Small Pieces uses an awful lot of
set! 

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


Re: [Haskell-cafe] ANNOUNCE: vector-bytestring-0.0.0.0

2011-10-16 Thread Stephen Tetley
On 15 October 2011 23:56, Bas van Dijk v.dijk@gmail.com wrote:
 On 15 October 2011 23:17, Ertugrul Soeylemez e...@ertes.de wrote:
 Both instances are valid here, and there is no mechanism to choose one of 
 them.

 There is: OverlappingInstances[1] chooses the most specific instance.
 So in case someVector :: Vector Word8 the instance Show (Vector Word8)
 is chosen because it's the most specific.

This has the problem of incoherence in multi-module programs - GHC
might chose different instances for the same type depending on
compilation order. For a Show instance, this may be acceptable.

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


Re: [Haskell-cafe] ANNOUNCE: vector-bytestring-0.0.0.0

2011-10-16 Thread Stephen Tetley
On 16 October 2011 10:06, Bas van Dijk v.dijk@gmail.com wrote:

 But is this a problem when both instances are exported from the same
 module and OverlappingInstances is only enabled in that module, as is
 the case here?


No - if the only instances defined are in the same module GHC would
pick the most specific one.

If there was no instance for Ivan's use-case of Vector Word8 in the
offical module, and he chose to define this more specific instance
elsewhere there is the potential for incoherence.

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


Re: [Haskell-cafe] DSL for data definition (e.g. compiling Haskell type defs into Google's protocol buffers type defs)

2011-10-04 Thread Stephen Tetley
On 4 October 2011 17:02, Karel Gardas karel.gar...@centrum.cz wrote:

 Hello,

[SNIP]

 So
 basically speaking I'm thinking about using Haskell sub-set as a
 data-definition DSL together with some functions which will generate some
 code based on supplied defined data types. ...

This seems reminiscent of ASDL - the Abstract Syntax Definition
Language - and ASDLgen (its generator) which used sum and product
types (essentially the same a Haskell or ML's algebraic types) to
define data for compiler internals. The definitions could be compiled
to C++, C, Java, ML, and Haskell. As well as data type definitions
ASDLgen generated marshallers for the ASDL binary format.

Unfortunately the Zephyr project which sponsored ASDL seems to have
had an early demise - so what info there still is available on the web
might be patchy.

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


Re: [Haskell-cafe] hackage library info

2011-09-20 Thread Stephen Tetley
Hi

There have been plans to add rankings to Hackage and a GSOC looked
into adding them.

Roel van Dijk built reverse dependencies for Hackage which illustrated
the most popular libraries, unfortunately the link seems broken:

http://bifunctor.homelinux.net/~roel/hackage/packages/hackage.html

Of course, the best library for you is the one that does more of
want you need in a way that you like the most. Social proof might not
always help for this...

Best regards

Stephen

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


Re: [Haskell-cafe] Categorized Weaknesses from the State of Haskell 2011 Survey

2011-09-12 Thread Stephen Tetley
Replying to someone's compliant in the first section:

Malcolm Wallace and Colin Runciman's ICFP99 paper functioned well as a
tutorial for HaXml when I used it - maybe it is a bit out of date now?
HaXml is hardly a dire case.

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


Re: [Haskell-cafe] Solving the configuration problem with parametrized modules

2011-09-06 Thread Stephen Tetley
On 6 September 2011 15:33, Joachim Breitner m...@joachim-breitner.de wrote:


 I think the benefit you get from being able to treat runtime constants
 as plain values manifests mostly when writing pure code. If your code
 has already been written or re-written in monadic style, adding a
 transformation layer is indeed less of a problem.

Run time constants are still an effect, though, just like error,
state, IO... that's why they are usually propagated with the Reader
monad or sometimes implicit params.

This does seem to irritate newcomers on Stack Overflow who don't
equate constant (but not statically known) values with more active
effects like state or file IO.

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


Re: [Haskell-cafe] Smarter do notation

2011-09-04 Thread Stephen Tetley
It seems like complication for very slight advantage.

Firstly, so far only UU Parsing and Trifecta appear to have optimized
Applicative instances (does the optimization work for mixed
Monad+Applicative parsers or only if the whole parser is
Applicative?). Secondly if you want Applicative then you can write in
the Applicative style, often as succinct as do-notation.

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


Re: [Haskell-cafe] Question about data

2011-08-19 Thread Stephen Tetley
Others have pointed out your first bug.

To get floating-point numeric literals you will need to define
instances of Num and then Fractional for your symbolic type.

On 19 August 2011 21:40, Paul Reiners paul.rein...@gmail.com wrote:

 *Main let pi = 3.14 :: MathExpression


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


Re: [Haskell-cafe] Hiding growing state using existentials.

2011-08-16 Thread Stephen Tetley
You can't define (=) if your state type changes:

(=) :: m a - (a - m b) - m c

Whereas, your bind is effectively three different parametric types:

_bind :: m1 a - (a - m2 b) - m3 b

You can use parametric monads to represent state changing within a
monad. Oleg Kiselyov has tutorials on their use on his website (search
for the Monadish class). The SHE experimental extension of Haskell
also has parametric monads built in.

bindish :: m s1 a - (a - m s2 b) - m s2 b

I don't think parametric monads will solve your problem though, as you
want a product of the states as the result of bind. Are you really
sure you want this behavior?, I'd imagine it breaks the monad laws
anyway.

http://okmij.org/ftp/Computation/monads.html

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


Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-11 Thread Stephen Tetley
Wouldn't this be dependent upon your AST and thus not readily
package-able as a library?

Expression simplification has been a prime example for Strafunski
style traversal libraries. You might be able to find examples that you
can adapt to your own AST written with Uniplate or similar library.

On 11 August 2011 05:00, Anton Kholomiov anton.kholom...@gmail.com wrote:
 Is there a library on common sub-expression elimination?


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


Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-11 Thread Stephen Tetley
Strafunski and its successors (Uniplate, SYB, KURE) are really for
working on trees. If you want to work on graphs you would probably be
better of with something else.

I think I overlooked that you want common sub-expression
_elimination_, rather than expression simplification. There are
libraries for observable sharing (Andy Gill's recent one is the
state-of-the-art, its on Hackage but I've forgotten its name) - that
are pertinent where you have built the expressions as an embedded DSL
in Haskell and you want sharing in code you generate from the Haskell
DSL.



On 11 August 2011 08:57, Anton Kholomiov anton.kholom...@gmail.com wrote:
 Thank you for the reference to Strafunski libraries, I read
 HaskellWiki, but I don't have a permission to visit their site.
 All links are forbidden.

 Can it be a function:

 fun :: Eq a = Tree a - [(Int, (a, [Int]))]

 where tuple codes nodes, and Int's code edges.

 2011/8/11 Stephen Tetley stephen.tet...@gmail.com

 Wouldn't this be dependent upon your AST and thus not readily
 package-able as a library?

 Expression simplification has been a prime example for Strafunski
 style traversal libraries. You might be able to find examples that you
 can adapt to your own AST written with Uniplate or similar library.

 On 11 August 2011 05:00, Anton Kholomiov anton.kholom...@gmail.com
 wrote:
  Is there a library on common sub-expression elimination?
 

 ___
 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] Idiomatic ways to make all instances of a certain class also instances of another?

2011-07-26 Thread Stephen Tetley
For:

instance (Ord a) = Max a where
 maximum = max

The same could more simply be achieved with a function:

maximum :: Ord a = a
maximum = max

Now, you probably wanted both a base-case using max and type specific,
special cases:

instance Max Int where
  maximum = 2^16

If you have both instances defined in the same module, GHC should
always pick the special case for Int if overlapping instances is
turned on. However, I've never found a description of how it resolves
instance selection if you have the specialized cases in different
modules. Unspecified [*] behaviour is not something I'd want to rely
on, so I always avoid Overlapping Instances.


[*] Of course, the multiple module behaviour might be specified somewhere...

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


Re: [Haskell-cafe] Grammar hacker in Haskell

2011-07-22 Thread Stephen Tetley
The algorithms are common practice and a web search should provide
lecture notes detailing them - you will likely have to translate to
Haskell yourself.

If you have a university affiliation, I'd go to the library and check
books on compiler construction. The classic is the Dragon Book -
Compilers: Principles, Techniques, and Tools by Aho et al. though
the presentation in this book is quite formal. I liked Modern
Compiler Design by Grune et al. myself.

Be cautious about buying a book without surveying it first - the
presentation of the algorithms varies considerably.

Best wishes

Stephen

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


Re: [Haskell-cafe] Introspection

2011-07-22 Thread Stephen Tetley
As Haskell is statically typed, if y.length  100, y is still of type Big...

On 22 July 2011 10:18, Patrick Browne patrick.bro...@dit.ie wrote:

 2) Assert the type of a variable
 e.g. if y.length  100 then y is of type big.

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


Re: [Haskell-cafe] Grammar hacker in Haskell

2011-07-22 Thread Stephen Tetley
On 22 July 2011 16:32, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote:
 Stephen Tetley stephen.tetley at gmail.com writes:

 Compilers: Principles, Techniques, and Tools by Aho et al. though
 the presentation in this book is quite formal.

 you make that sound like a bad thing ...

Well - not intentionally, and for the cognoscenti formal presentations
can often be translated to a high-level language like Haskell more
easily than say pseudo code; but if you don't have much prior
experience I'd think something at the Dragon Book's level would be
quite demanding.

Myself, I bought the Grune et al. book after getting stranded with the
Dragon Book. Working through the Grune made reading the Dragon Book a
lot more accessible.

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


Re: [Haskell-cafe] Constructor discipline and dependent types.

2011-07-17 Thread Stephen Tetley
On 17 July 2011 10:03, Patrick Browne patrick.bro...@dit.ie wrote:

 Question 1: Is the above a reasonable understanding of CD?

From a brief look, constructor discipline (CD) restricts left-hand
sides of equations to have no function calls themselves.

http://users.dsic.upv.es/~gvidal/german/pepm97/paper.pdf

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


Re: [Haskell-cafe] Baffling Hackage build log

2011-07-13 Thread Stephen Tetley
This seems to be a general problem with the Hackage server as other
packages uploaded after yours have failed to build with similar
errors...

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


  1   2   3   4   5   6   >