RE: [Haskell-cafe] global variables

2007-05-21 Thread Simon Peyton-Jones

| I see no need two answer this again I believe I have already made my
| views perfectly clear already and provided ample evidence to justify
| them. Surely I don't need to do it again?

Is there a Wiki page about this somewhere?  Often email gets into a loop 
because not everyone reads everything on Haskell Cafe. (There's just too much 
of it.)  When that happens, a good thing do to is to summarise the various 
positions on a Wiki page, so the debate can progress by refining text rather 
than by repeating it.  There is the additional advantage that someone coming 
along later can still make sense of the debate.

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


Re: [Haskell-cafe] Profiling, GUIs and libraries

2007-05-21 Thread Arthur van Leeuwen


On 20-mei-2007, at 17:39, Anthony Chaumas-Pellet wrote:


Hello,

I'm currently hacking away a wxhaskell program that uses up 100% CPU
even when it should be idle. So, rather than doing blind guesswork,
I've thought about using profiling to spot the zealous function. I do
not need a very accurate result, though.

ghc with -prof -auto(-all) produces the following error message,
however: Could not find module `Graphics.UI.WX': Perhaps you haven't
installed the profiling libraries for package wx-0.10.1? Use -v to see
a list of the files searched for.

So, I guess I need to rebuild wx with profiling, but I'm not sure how
to do that exactly; search engine and the Wiki did not turn up any
pointers, and there are no ready-made options to build wx with
profiling. It seems Cabal can build a library with profiling
automatically, but I don't think there exists a Cabalized version of
wx yet.

That, and I'm not sure if recompiling libraries to add profiling is a
great idea, as wx itself may depend on other external libraries. So,
is there a better way than profiling in my case, or am I missing
something obvious here?


You are not missing anything obvious. The process is in fact
somewhat tricky. What you have to do is the following:

- compile wxHaskell with profiling (by editing the makefiles to  
include the

-prof -auto-all argument to GHC)
- *install* the profiled wxHaskell
- manually move the profiled object libraries to ones including the _p
string before the .a, e.g. move
/usr/local/wxhaskell/lib/libwx.a to /usr/local/wxhaskell/lib/libwx_p.a
- manually move the profiled .hi files to .p_hi files, e.g. move
/usr/local/wxhaskell/lib/imports/Graphics/UI/WX.hi to
/usr/local/wxhaskell/lib/imports/Graphics/UI/WX.p_hi
- compile wxHaskell without profiling
- install the non-profiled wxHaskell
- enjoy the ability to use wxHaskell in both profiled and unprofiled
versions

Note: this assumes you are on a Unix-like system. I have no clue how
to do this on Windows, but I'm told it is similar.

Oh, and this is tested and works. The external libraries that wx relies
on are either truly external, as in called through the FFI, or GHC  
standard

libs that  normally already have a profiling version available.

With regards, Arthur van Leeuwen.

--

  /\/ |   [EMAIL PROTECTED]   | Work like you don't need  
the money
/__\  /  | A friend is someone with whom | Love like you have never  
been hurt
/\/__ | you can dare to be yourself   | Dance like there's nobody  
watching




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


Re: [Haskell-cafe] global variables

2007-05-21 Thread Arthur van Leeuwen


On 21-mei-2007, at 9:31, Simon Peyton-Jones wrote:



| I see no need two answer this again I believe I have already made my
| views perfectly clear already and provided ample evidence to justify
| them. Surely I don't need to do it again?

Is there a Wiki page about this somewhere?  Often email gets into a  
loop because not everyone reads everything on Haskell Cafe.  
(There's just too much of it.)  When that happens, a good thing do  
to is to summarise the various positions on a Wiki page, so the  
debate can progress by refining text rather than by repeating it.   
There is the additional advantage that someone coming along later  
can still make sense of the debate.


As I am sure Adrian would tell you were he awake:

http://www.haskell.org/haskellwiki/Top_level_mutable_state

With regards, Arthur van Leeuwen

--

  /\/ |   [EMAIL PROTECTED]   | Work like you don't need  
the money
/__\  /  | A friend is someone with whom | Love like you have never  
been hurt
/\/__ | you can dare to be yourself   | Dance like there's nobody  
watching




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


[Haskell-cafe] SWIG with Haskell ?

2007-05-21 Thread Mark Wassell

Hello,

Has anyone got any pointers on using SWIG with Haskell to integrate a 
C++ library? For the library there other language bindings, so I am in a 
position to leverage off these.


In general what are the particular issues with C++ and Haskell. One 
obvious one is management of object lifecycle - making sure the object 
stays around long enough but doesn't out stay its welcome. Is using 
ForeignPtr sufficient?


Cheers

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


RE: [Haskell-cafe] Scope of type variables in associated types

2007-05-21 Thread Simon Peyton-Jones
| The following doesn't seem to work. Is this a limitation of the current
| implementation or will it never work? Are there any work arounds without
| introducing extra type params into the data type E?
|
|  class G a b | a - b where
|  data E a :: *
|  wrap :: b - E a
|  unwrap :: E a - b
|
|  instance G a b where
|  data E a = EC b -- this line - the b is not in scope.
|  wrap = EC
|  unwrap (EC b) = b
|
| I get Not in scope: type variable `b'.

That's a bug.  b should be in scope


However, your program is very suspicious!  Associated data types *replace* 
functional dependencies, so you should not use both.  Your probably want 
something like

class G a where
  data E a :: *
  wrap :: a - E a
  unwrap :: E a - a

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


Re: [Haskell-cafe] How Albus Dumbledore would sell Haskell

2007-05-21 Thread Henning Thielemann

On Wed, 18 Apr 2007, Dan Weston wrote:

 You have already won over the scientists.

I only know few mathematicians using Haskell, most of the (applied)
mathematician colleagues I know prefer MatLab.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A wish for relaxed layout syntax

2007-05-21 Thread Henning Thielemann

On Wed, 28 Mar 2007, Benjamin Franksen wrote:

 Hi,

 I often run into the following issue: I want to write a list of lengthy
 items like this

 mylist = [
   quite_lengthy_list_item_number_one,
   quite_lengthy_list_item_number_two,
   quite_lengthy_list_item_number_three
 ]

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


Re: [Haskell-cafe] Follow up on 'GroupBy behavior'

2007-05-21 Thread Henning Thielemann

On Sat, 28 Apr 2007, Hans van Thiel wrote:

 Thanks again for the help, and, to follow up, this now does what I
 need..

 -- partitions a list according to an equivalence relation

 partition1 :: (a - a - Bool) - [a] - ([a],[a])
 partition1 eq ls = partition ((head ls) `eq`) ls
 --
 partitionBy :: (a - a - Bool) - [a] - [[a]]
 partitionBy eq [] = []
 partitionBy eq ls =
 (fst x):(partitionBy eq (snd x))  where
  x =  partition1 eq ls

partitionBy is essentially a List.unfoldr

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


Re: [Haskell-cafe] Behavior of groupBy

2007-05-21 Thread Henning Thielemann

On Sat, 28 Apr 2007, Hans van Thiel wrote:

 Hello All,

 The standard function groupBy of List.hs doesn't work as I expect in
 this case:

 groupBy (\x y - (last x) == (last y)) [abc, bd,cac]

 results in:

 [[abc],[bd],[cac]]

 where I want:

 [[abc,cac], [bd]]

I think you must roll your own one. How about repeated 'partition' to
extract all elements that have the same trailing character like the head
word of the list?

I have done this in a more complex setting and called it 'slice':
  http://darcs.haskell.org/haskore/src/Haskore/Basic/TimeOrderedList.lhs


 slice :: (Eq a, Num time) =
(body - a) - T time body - [(a, T time body)]
 slice f perf =
   let splitByHeadKey pf =
  fmap
 (\ev -
let i = f (eventBody ev)
(pf0, pf1) = partition ((i==) . f) 0 0 pf
in  ((i,pf0), pf1))
 (listToMaybe pf)
   in  List.unfoldr splitByHeadKey perf

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


Re: [Haskell-cafe] Unresolved overloading error

2007-05-21 Thread Henning Thielemann

On Sat, 31 Mar 2007, Jacques Carette wrote:

 Bryan Burgers wrote:
  On 3/31/07, Scott Brown [EMAIL PROTECTED] wrote:
 
  It's working now, thank you.
  I changed the definition to
 
   binom n j = div (fac n) ((fac j)*(fac (n - j)))
 
   bernoulli n p j = fromIntegral(binom n j)*(p ^ j) * ((1 - p)^(n - j))
 
  As a matter of style suggestion, it might make 'binom' more clear if
  you use 'div' as an infix operator:
 
  binom n j = (fac n) `div` ( fac j * fac (n - j) )
 And as a matter of efficiency, no one would write binom using factorial,
 but would rather write at least
 binom u k = (product [(u-i+1)  | i - [1..k]]) `div` (product [1..k])
 and even better would be to do it this way
 -- bb u k = toInteger $ product [ (u-i+1) / i | i - [1..k]]
 but that does not type (for a good reason).

How about

binomialSeq :: Integral a = a - [a]
binomialSeq n =
   scanl (\acc (num,den) - div (acc*num) den) 1
 (zip [n, pred n ..] [1..n])

and the use of (!!) ?


http://darcs.haskell.org/htam/src/Combinatorics.hs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Scope of type variables in associated types

2007-05-21 Thread Matthew Sackman
On Mon, May 21, 2007 at 10:36:00AM +0100, Simon Peyton-Jones wrote:
 | The following doesn't seem to work. Is this a limitation of the current
 | implementation or will it never work? Are there any work arounds without
 | introducing extra type params into the data type E?
 |
 |  class G a b | a - b where
 |  data E a :: *
 |  wrap :: b - E a
 |  unwrap :: E a - b
 |
 |  instance G a b where
 |  data E a = EC b -- this line - the b is not in scope.
 |  wrap = EC
 |  unwrap (EC b) = b
 |
 | I get Not in scope: type variable `b'.
 
 That's a bug.  b should be in scope

Ahh, cool. I which case I wonder if this too is a bug? :

data Nil = Nil
data Cons :: * - * - * where
 Cons :: val - tail - Cons val tail

class F c v t | c - v t where
data FD c t :: *

instance F (Cons v t) v t where
-- this blows up with conflicting definitions for `t'
data FD (Cons v t) t = FDC v

 However, your program is very suspicious!  Associated data types
 *replace* functional dependencies, so you should not use both.  Your
 probably want something like

 class G a where
   data E a :: *
   wrap :: a - E a
   unwrap :: E a - a

I'm afraid not. I really need wrap to take a 'b' and unwrap to return a 'b'.
Talking on #haskell to sjanssen last night, he came up with:

class F a b where
data F a :: *

instance F a b where
data F a = F b

cast :: (F a b, F a c) = b - c
cast x = case F x of
(F y) - y

as evidence as to why it's unsafe. But with the fundep, I would have
thought it would have been safe. The associated type way would be to
drop the b and then have data F a :: * - *  - just like in the papers.
But I really need the b to be part of the class in order to match the b
against other class constraints in other functions. In particular I need
to be able to write something like:

instance (G a b) = F a b where
...

Somehow I doubt it, but is the following any less suspicious?

class F a b where
type BThing a :: *
data FD a :: *
wrap :: b - FD a
unwrap :: FD a - b

instance F a b where
type BThing a = b
data FD a = FDC (BThing a)
wrap b = FDC b
unwrap (FDC b) = b

Incidentally, that type BThing a = b line also blows up with
Not in scope: type variable `b'.

Thanks,

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


[Haskell-cafe] Editor

2007-05-21 Thread Michael T. Richter
I have a dream.  It's not a little dream.  It's a big dream.  I have a
dream that someday I can find a UNIX/Linux text editor for Haskell
hacking (and possibly two or three hundred other programming languages,
although that's optional) that can give me all of the following:


 1. A real GUI environment that takes into account some of the HID
advances made in the past 30 years.  (Emacs and Vim don't count,
in other words.)
 2. Good quality syntax highlighting for Haskell that includes all
of the usual syntax highlighting goodies, plus:

  * the ability to seamlessly handle raw Haskell and both
common forms of Literate Haskell;
  * the ability to properly highlight Haddock comments;
  * the ability to highlight functions and types from
libraries (user-expandable) differently from local
functions and types.

 3. Line folding to hide and show blocks of code.
 4. Code completion (user-expandable, ideally) for common library
functions, type declarations, etc.
 5. Easy, quick access to online documentation for said functions
and declarations.
 6. Good (ideally scriptable) access to external utilities for
compilation, debugging, profiling, type inference, project
management, etc.
 7. A good plug-in system (ideally written in Haskell?) for
expansion.


Is there such a beast available out there somewhere?  If not, is such a
beast lurking in the background ready to pounce in the near future?
-- 
Michael T. Richter [EMAIL PROTECTED] (GoogleTalk:
[EMAIL PROTECTED])
I have to wonder why people think that when they can't manage local
personnel within easy strangling and shooting distance, then they can
manage personnel thousands of miles away that have different languages,
cultures, and business rules. (Joe Celko)


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] how can I select all the 3-element-combination out of a list efficiently

2007-05-21 Thread geniusfat

What I meant is this:
http://en.wikipedia.org/wiki/Combinatorics#Combination_without_repetition 
the order does not matter and each object can be chosen only once.
But thank all those who have offered help, it helps a lot ;)

-- 
View this message in context: 
http://www.nabble.com/how-can-I-select-all-the-3-element-combination-out-of-a-list-efficiently-tf3776055.html#a10716285
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Jules Bean

Michael T. Richter wrote:
I have a dream.  It's not a little dream.  It's a big dream.  I have a 
dream that someday I can find a UNIX/Linux text editor for Haskell 
hacking (and possibly two or three hundred other programming languages, 
although that's optional) that can give me all of the following:


   1. A real GUI environment that takes into account some of the HID
  advances made in the past 30 years.  (Emacs and Vim don't count,
  in other words.)



That particular part is trolling. Both emacs and vim take into account 
many of the HID advances made in the past 30 years. You're going to have 
to be more explicit about what you find unacceptable about them to get 
useful answers, in my opinion.


I can't speak for vim, but emacs certainly satisfies 2.3, 2.4, 3, 4, 5, 
6, and 7.  (I'm not sure if 5 is 100% out-of-the-box but it would be 
very easy to sort it out if not).


2.5 I'd not really thought about before as an interesting requirement. 
Could be useful.




   2. Good quality syntax highlighting for Haskell that includes all of
  the usual syntax highlighting goodies, plus:

   3. the ability to seamlessly handle raw Haskell and both common
  forms of Literate Haskell;
   4. the ability to properly highlight Haddock comments;
   5. the ability to highlight functions and types from libraries
  (user-expandable) differently from local functions and types. 


   3. Line folding to hide and show blocks of code.
   4. Code completion (user-expandable, ideally) for common library
  functions, type declarations, etc.
   5. Easy, quick access to online documentation for said functions and
  declarations.
   6. Good (ideally scriptable) access to external utilities for
  compilation, debugging, profiling, type inference, project
  management, etc.
   7. A good plug-in system (ideally written in Haskell?) for expansion. 



Is there such a beast available out there somewhere?  If not, is such a 
beast lurking in the background ready to pounce in the near future?

--
*Michael T. Richter* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] (*GoogleTalk:* [EMAIL PROTECTED])
/I have to wonder why people think that when they can't manage local 
personnel within easy strangling and shooting distance, then they can 
manage personnel thousands of miles away that have different languages, 
cultures, and business rules. (Joe Celko)/





___
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] Profiling, GUIs and libraries

2007-05-21 Thread Anthony Chaumas-Pellet
 You are not missing anything obvious. The process is in fact
 somewhat tricky. What you have to do is the following snip

Thanks! I've followed your instructions and got a profiler-enabled
binary up and running. I'd figured out how to modify the Makefile
(silly me searching for *G*HC), but I had no idea about the manual
renaming of files.

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


RE: [Haskell-cafe] Scope of type variables in associated types

2007-05-21 Thread Simon Peyton-Jones
|  |  instance G a b where
|  |  data E a = EC b -- this line - the b is not in scope.
|  |  wrap = EC
|  |  unwrap (EC b) = b
|  |
|  | I get Not in scope: type variable `b'.
| 
|  That's a bug.  b should be in scope

I was wrong.  It's not a bug.  E is supposed to be a type *function*, so it 
can't mention anything on the RHS that is not bound on the LHS.  We'll improve 
the documentation.

| Ahh, cool. I which case I wonder if this too is a bug? :
|
| data Nil = Nil
| data Cons :: * - * - * where
|  Cons :: val - tail - Cons val tail
|
| class F c v t | c - v t where
| data FD c t :: *
|
| instance F (Cons v t) v t where
| -- this blows up with conflicting definitions for `t'
| data FD (Cons v t) t = FDC v

As I said, associated types are an *alternative* to fundeps. We have not even 
begun to think about what happens if you use both of them together.  You should 
not need to do so.

| Somehow I doubt it, but is the following any less suspicious?
|
| class F a b where
| type BThing a :: *
| data FD a :: *
| wrap :: b - FD a
| unwrap :: FD a - b
|
| instance F a b where
| type BThing a = b
| data FD a = FDC (BThing a)
| wrap b = FDC b
| unwrap (FDC b) = b
|
| Incidentally, that type BThing a = b line also blows up with
| Not in scope: type variable `b'.

No, that is wrong in the same way as before.  BThing is a *function* so its 
results must depend only on its arguments.

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


Re: [Haskell-cafe] how can I select all the 3-element-combination out of a list efficiently

2007-05-21 Thread haskell
geniusfat wrote:
 What I meant is this:
 http://en.wikipedia.org/wiki/Combinatorics#Combination_without_repetition 
 the order does not matter and each object can be chosen only once.
 But thank all those who have offered help, it helps a lot ;)
 

Then you want triples1 from the code below.

The idea for triples1, triples2, and triples3 is that each pickOne returns a
list of pairs.  The first element of each pair is the chosen element and the
second element of each pair is the list of choices for the next element (given
the current choice).
import Data.List

-- Order does not matter, no repetition
-- preserves sorting
triples1 xs = do
  (x,ys) - pickOne xs
  (y,zs) - pickOne ys
  z - zs
  return (x,y,z)
 where pickOne [] = []
   pickOne (x:xs) = (x,xs) : pickOne xs
   -- Alternative
   -- pickOne xs = map helper . init . tails $ xs
   -- helper (x:xs) = (x,xs)

-- Order does matter, no repetition
-- does not preserve sorting
triples2 xs = do
  (x,ys) - pickOne xs
  (y,zs) - pickOne ys
  z - zs
  return (x,y,z)
 where pickOne xs = helper [] xs
   helper bs [] = []
   helper bs (x:xs) = (x,bs++xs) : helper (x:bs) xs
   -- Alternative (produces results in different order
   --  and preserves sorting)
   -- pickOne xs = zipWith helper (inits xs) (init (tails xs))
   -- helper pre (x:post) = (x,pre++post)

-- Order does not matter, repetition allowed
-- preserves sorting
triples3 xs = do
  (x,ys) - pickOne xs
  (y,zs) - pickOne ys
  z - zs
  return (x,y,z)
 where pickOne [] = []
   pickOne a@(x:xs) = (x,a) : pickOne xs
   -- Alternative
   -- pickOne xs = map helper . init . tails $ xs
   -- helper xs@(x:_) = (x,xs)

-- Order does matter, repetition allowed
-- preserves sorting
triples4 xs = do
  x - xs
  y - xs
  z - xs
  return (x,y,z)

temp = map ($ [1..4]) $ [triples1,triples2,triples3,triples4]

preservesSorting = map (\xs - xs == sort xs) temp

test1 = putStr . unlines . map show $ temp
test2 = putStr . unlines . map show . map length $ temp
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] how can I select all the 3-element-combination out of a list efficiently

2007-05-21 Thread Jules Bean

[EMAIL PROTECTED] wrote:

Then you want triples1 from the code below.

The idea for triples1, triples2, and triples3 is that each pickOne returns a
list of pairs.  The first element of each pair is the chosen element and the
second element of each pair is the list of choices for the next element (given
the current choice).


In the spirit of multiple implementations; another approach is to note 
that you're really asking for all 3-element sublists:


power [] = [[]]
power (x:xs) = power xs ++ map (x:) (power xs)

triples1' l = [ t | t - power l, length t == 3]

(this implementation also preserves sorting)

Jules


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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Michael T. Richter
On Mon, 2007-21-05 at 11:47 +0100, Jules Bean wrote:

 Michael T. Richter wrote:
 1. A real GUI environment that takes into account some of the HID
advances made in the past 30 years.  (Emacs and Vim don't count,
in other words.)



 That particular part is trolling. Both emacs and vim take into account 
 many of the HID advances made in the past 30 years. You're going to have 
 to be more explicit about what you find unacceptable about them to get 
 useful answers, in my opinion.


Vim is eliminated before it reaches the gate because it's a modal
editor.  Even with GVim in place, it still has that modal stench to it
that leaps up and bites at awkward moments.  And HID advances (the modal
issue aside)?  Go to an underpowered little editor like Gedit (what I
use currently for raw Haskell, but which sadly isn't applicable to .lhs
files of either stripe) and adjust your editing preferences.  It's not a
particularly good programmer's editor, but look at the lovely tabbed
dialog box with all those lovely HID bits like checkboxes, radio
buttons, spin buttons, dropdown lists, lists, etc.  Now do the same in
GVim and get ... a text file with some editing tricks to make things
slightly easier.  (It's not immediately obvious how to get rid of it
either.)  Where is the accounting for HID advances there?  (Raw Vim is
even worse.)  

Hell, even comparing the out-of-the-box syntax highlighting support in
Gedit vs. (G)Vim is instructive.  Code like makeRandomValueST :: StdGen
- (MyType, StdGen) (which, incidentally, was far easier to copy from
in Gedit than GVim to paste into this message) only differentiates ::
and - from the text and delimiters in GVim while in Gedit (keeping in
mind that Gedit isn't a very good editor!) differentiates those plus
makeRandomValueST vs. StdGen and MyType.  And the parentheses.

(G)Vim is losing to freakin' GEDIT here!  The Notepad of the GNOME
world.

Emacs is its own set of nightmares.  I'm not even going to start going
down the path of that particular holy war (and bucky-bit Hell).  I'll
acknowledge freely that it's an incredibly powerful programming
environment.  It just really doesn't play well with others at almost any
level and quite definitely doesn't have anything resembling modern HID
thought behind it.  (To be fair to it, it does predate most modern HID
work by a couple of decades.)

-- 
Michael T. Richter [EMAIL PROTECTED] (GoogleTalk:
[EMAIL PROTECTED])
All really first class designers are both artists, engineers, and men of
a powerful and intolerant temper, quick to resist the least modification
of the plans, energetic in fighting the least infringement upon what
they regard as their own sphere of action. (Nevil Shute)


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] Scope of type variables in associated types

2007-05-21 Thread Matthew Sackman
On Mon, May 21, 2007 at 12:39:20PM +0100, Simon Peyton-Jones wrote:
 |  |  instance G a b where
 |  |  data E a = EC b -- this line - the b is not in scope.
 |  |  wrap = EC
 |  |  unwrap (EC b) = b
 |  |
 |  | I get Not in scope: type variable `b'.
 | 
 |  That's a bug.  b should be in scope
 
 I was wrong.  It's not a bug.  E is supposed to be a type *function*,
 so it can't mention anything on the RHS that is not bound on the LHS.
 We'll improve the documentation.

Ok, thanks for the clarification. One final question then, how could I
rewrite the following in associated types:

class OneStep a b | a - b
instance OneStep (Cons v t) t

class TwoStep a b | a - b
instance (OneStep a b, OneStep b c) = TwoStep a c

If the fundep and b is dropped then I get:

class OneStep a
data OS a :: *
instance OneStep (Cons v t)
data OS (Cons v t) = t

class TwoStep a
data TS a :: *
instance (OneStep a, OneStep b) = TwoStep a

This last one can't be right, as I can't express the fact that the OS in
OneStep a provides the link with OneStep b. So is there a way to
achieve this sort of chaining with associated types?

Sure, the fundep version requires undecidable instances, but I've been
writing quite a lot of code lately that requires that!

Many thanks,

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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Rodrigo Queiro

My friend read your email and remarked:
How is this guy not embarrassed posting on the internet about not liking
vim because he doesn't like editing config files?

On 21/05/07, Michael T. Richter [EMAIL PROTECTED] wrote:


 On Mon, 2007-21-05 at 11:47 +0100, Jules Bean wrote:

Michael T. Richter wrote:1. A real GUI environment that takes into account some 
of the HID   advances made in the past 30 years.  (Emacs and Vim don't 
count,   in other words.)


 That particular part is trolling. Both emacs and vim take into account many of 
the HID advances made in the past 30 years. You're going to have to be more 
explicit about what you find unacceptable about them to get useful answers, in 
my opinion.


Vim is eliminated before it reaches the gate because it's a modal editor.
Even with GVim in place, it still has that modal stench to it that leaps up
and bites at awkward moments.  And HID advances (the modal issue aside)?  Go
to an underpowered little editor like Gedit (what I use currently for raw
Haskell, but which sadly isn't applicable to .lhs files of either stripe)
and adjust your editing preferences.  It's not a particularly good
programmer's editor, but look at the lovely tabbed dialog box with all those
lovely HID bits like checkboxes, radio buttons, spin buttons, dropdown
lists, lists, etc.  Now do the same in GVim and get ... a text file with
some editing tricks to make things slightly easier.  (It's not immediately
obvious how to get rid of it either.)  Where is the accounting for HID
advances there?  (Raw Vim is even worse.)

Hell, even comparing the out-of-the-box syntax highlighting support in
Gedit vs. (G)Vim is instructive.  Code like makeRandomValueST :: StdGen -
(MyType, StdGen) (which, incidentally, was far easier to copy from in Gedit
than GVim to paste into this message) only differentiates :: and - from
the text and delimiters in GVim while in Gedit (keeping in mind that Gedit
isn't a very good editor!) differentiates those *plus* makeRandomValueST
vs. StdGen and MyType.  And the parentheses.

(G)Vim is losing to freakin' GEDIT here!  The Notepad of the GNOME world.

Emacs is its own set of nightmares.  I'm not even going to start going
down the path of that particular holy war (and bucky-bit Hell).  I'll
acknowledge freely that it's an incredibly powerful programming
environment.  It just really doesn't play well with others at almost any
level and quite definitely doesn't have anything resembling modern HID
thought behind it.  (To be fair to it, it does predate most modern HID work
by a couple of decades.)

  --
*Michael T. Richter* [EMAIL PROTECTED] (*GoogleTalk:*
[EMAIL PROTECTED])
*All really first class designers are both artists, engineers, and men of
a powerful and intolerant temper, quick to resist the least modification of
the plans, energetic in fighting the least infringement upon what they
regard as their own sphere of action. (Nevil Shute)*

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

2007-05-21 Thread Thomas Davie


On 21 May 2007, at 13:04, Rodrigo Queiro wrote:


My friend read your email and remarked:
How is this guy not embarrassed posting on the internet about not  
liking vim because he doesn't like editing config files?


Two points
1)  This guy doesn't like editing config files -- that's his  
preference.  He's stated he doesn't like either of vim or emacs, and  
whether you agree or not, you maybe should respect that and try to be  
useful and answer his question.
2) Believe it or not, a computer is a tool, it's there to get things  
done in the fastest and easiest way possible -- I should be able to  
edit my preferences in three clicks of a mouse button, rather than  
opening the preferences, finding the right place to edit (possibly  
looking up the manual to find the relevant things to insert in the  
config), typing a load in, and then having my preferences edited!


Yes, I really do think that's an advantage, and no, I don't think  
snarky comments about not liking editing config files are either  
relevant or useful.


Bob

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


Re: [Haskell-cafe] how can I select all the 3-element-combination out of a list efficiently

2007-05-21 Thread Mirko Rahn

Jules Bean wrote:

In the spirit of multiple implementations; another approach is to note 
that you're really asking for all 3-element sublists:


power [] = [[]]
power (x:xs) = power xs ++ map (x:) (power xs)

triples1' l = [ t | t - power l, length t == 3]

(this implementation also preserves sorting)


...but is exponentially slower than necessary, and fails on infinite 
lists. Try this one:


sublistsN 0 _  = [[]]
sublistsN n (x:xs) = map (x:) (sublistsN (n-1) xs) ++ sublistsN n xs
sublistsN _ _  = []

triples = sublistsN 3

BR,

--
-- Mirko Rahn -- Tel +49-721 608 7504 --
--- http://liinwww.ira.uka.de/~rahn/ ---
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Editor

2007-05-21 Thread Michael T. Richter
On Mon, 2007-21-05 at 13:04 +0100, Rodrigo Queiro wrote:

 My friend read your email and remarked:
 How is this guy not embarrassed posting on the internet about not
 liking vim because he doesn't like editing config files?


Because, unlike your friend, I actually have seen the advances in HID
over the past 30 years.  Editing text files is not the be-all/end-all of
user interfaces.  Indeed there is astonishingly high volumes of evidence
showing that it's a pretty miserable user interface -- a misery
amplified by the fact that every two-bit program has its own entirely
unique syntax (usually broken in many exciting ways!) full of cryptic
commands and settings.  Don't believe it?  Go to your home directory and
compare all the .files you find.  You really think it's a good thing
to maintain each of those manually?

Oh, and of course it wasn't just the config files I showed problems
with, now, was it?  I seem to remember something about modality and bad
syntax highlighting.  Maybe I was tripping.  It happens.

For your friend's reference, here's a good outline of what principles
underlie HID: http://www.asktog.com/basics/firstPrinciples.html.  For
even more modern outlooks, I'm sure a quick search at Amazon.com (or his
bookseller of choice) can give him other ideas.

So am I embarrassed for asking for something resembling a 21st-century
user interface instead of a 1970s vintage one?  Not in the slightest.

-- 
Michael T. Richter [EMAIL PROTECTED] (GoogleTalk:
[EMAIL PROTECTED])
It's OK to figure out murder mysteries, but you shouldn't need to figure
out code. You should be able to read it. (Steve McConnell)


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] how can I select all the 3-element-combination out of a list efficiently

2007-05-21 Thread Mark T.B. Carroll
geniusfat [EMAIL PROTECTED] writes:
(snip)
 the order does not matter and each object can be chosen only once.
(snip)

In that case, with the help of Data.List.tails, one can do:

threeOf :: [a] - [(a,a,a)]

threeOf xs =
[ (p,q,r) | (p:ps) - tails xs, (q:qs) - tails ps, r - qs ]

(the r - qs is a simpler version of (r:rs) - tails qs)

or maybe,

nOf :: Int - [a] - [[a]]

nOf _[]  = []
nOf 1xs  = map return xs
nOf n (x:xs) = map (x:) (nOf (n-1) xs) ++ nOf n xs

(These are fairly naive versions that just took me a few minutes, but
perhaps they'll do.)

-- Mark

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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Alex Queiroz

Hallo,

On 5/21/07, Michael T. Richter [EMAIL PROTECTED] wrote:


 Oh, and of course it wasn't just the config files I showed problems with, now, 
was it?  I seem to remember something about modality and bad syntax 
highlighting.  Maybe I was tripping.  It happens.



   You may not like modality, it's entirely within your rights, but
it is *not* a problem. Fortunately it's still there for the millions
of us who like it.

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


[Haskell-cafe] Ann: Emping 0.2

2007-05-21 Thread Hans van Thiel
Hello All,

Version 0.2 of Emping, a utility to derive heuristic rules from a table
of nominal data, is available. In addition to a reduced normal form
in .csv format, which can be read by Open Office Calc, it now also
displays observed implications and equivalences in the reduced rules (if
present) and ambiguities in original rules (if present). 
A bug in the response to a user typing error has been fixed and some
code has been simplified, compared to 0.1. An online user guide is at:
http://j-van-thiel.speedlinq.nl/emp/empug.html and the Cabal package can
be downloaded from there, or from the HackageDB.

Thanks,

Hans van Thiel


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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Thomas Schilling

Your rant accomplishes nothing.  Just note that programmers can
generally be considered more open towards harder-to-learn but
eventually more efficient to use interfaces.  Yes, to a large part
they lack visibility, consistency, integration, or other such
properties; then again, once you learn to use them you're so much more
efficient than before.  And you loose the incentive to improve things.

So instead of insulting people and complaining that nothing fits your
needs you have at least two options:

1. Implement it.  Of course, this is a _major_ effort and many many
things are completely unsolved research issues.

2. Take what's there, learn to use it.  Yes, it will lack so many
things but one way or another you'll eventually get things done.

On 5/21/07, Michael T. Richter [EMAIL PROTECTED] wrote:


 On Mon, 2007-21-05 at 13:04 +0100, Rodrigo Queiro wrote:

 My friend read your email and remarked:
 How is this guy not embarrassed posting on the internet about not liking vim 
because he doesn't like editing config files?

 Because, unlike your friend, I actually have seen the advances in HID over the past 
30 years.  Editing text files is not the be-all/end-all of user interfaces.  Indeed 
there is astonishingly high volumes of evidence showing that it's a pretty miserable 
user interface -- a misery amplified by the fact that every two-bit program has its 
own entirely unique syntax (usually broken in many exciting ways!) full of cryptic 
commands and settings.  Don't believe it?  Go to your home directory and compare all 
the .files you find.  You really think it's a good thing to maintain each of 
those manually?

 Oh, and of course it wasn't just the config files I showed problems with, now, 
was it?  I seem to remember something about modality and bad syntax 
highlighting.  Maybe I was tripping.  It happens.

 For your friend's reference, here's a good outline of what principles underlie 
HID: http://www.asktog.com/basics/firstPrinciples.html.  For even more modern 
outlooks, I'm sure a quick search at Amazon.com (or his bookseller of choice) 
can give him other ideas.

 So am I embarrassed for asking for something resembling a 21st-century user 
interface instead of a 1970s vintage one?  Not in the slightest.


  --
 Michael T. Richter [EMAIL PROTECTED] (GoogleTalk: [EMAIL PROTECTED])
 It's OK to figure out murder mysteries, but you shouldn't need to figure out 
code. You should be able to read it. (Steve McConnell)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe







--
Remember! Everytime you say 'Web 2.0' God kills a startup! -
userfriendly.org, Jul 31, 2006
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Scope of type variables in associated types

2007-05-21 Thread Tom Schrijvers

Ok, thanks for the clarification. One final question then, how could I
rewrite the following in associated types:

class OneStep a b | a - b
instance OneStep (Cons v t) t

class TwoStep a b | a - b
instance (OneStep a b, OneStep b c) = TwoStep a c

If the fundep and b is dropped then I get:

class OneStep a
   data OS a :: *
instance OneStep (Cons v t)
   data OS (Cons v t) = t  data constructor missing !!!

class TwoStep a
   data TS a :: *
instance (OneStep a, OneStep b) = TwoStep a

This last one can't be right, as I can't express the fact that the OS in
OneStep a provides the link with OneStep b. So is there a way to
achieve this sort of chaining with associated types?


You'd have to write


class OneStep a
   data OS a :: *
instance OneStep (Cons v t)
   data OS (Cons v t) = OSC t

class TwoStep a
   data TS a :: *
instance (OneStep a, OneStep (OS a)) = TwoStep a where
   type TS a = TSC (OS (OS a))


which seems rather awkward with all these additional data type 
constructors.


You'd be better off with associated type synonyms:


class OneStep a
   type OS a :: *
instance OneStep (Cons v t)
   type OS (Cons v t) = t

class TwoStep a
   type TS a :: *
instance (OneStep a, OneStep (OS a)) = TwoStep a
   type TS a = OS (OS a)


which are currently under development.

--
Tom Schrijvers

Department of Computer Science
K.U. Leuven
Celestijnenlaan 200A
B-3001 Heverlee
Belgium

tel: +32 16 327544
e-mail: [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] how can I select all the 3-element-combination out of a list efficiently

2007-05-21 Thread Mirko Rahn

Mark T.B. Carroll wrote:


nOf _[]  = []
nOf 1xs  = map return xs
nOf n (x:xs) = map (x:) (nOf (n-1) xs) ++ nOf n xs


No! With this implementation we have nOf 0 _ == [] but it should be nOf 
0 _ == [[]]: The list of all sublists of length 0 is not empty, it 
contains the empty list!


Correct (and more natural):

nOf 0 _  = [[]]
nOf n (x:xs) = map (x:) (nOf (n-1) xs) ++ nOf n xs
nOf _ [] = []

BR,

--
-- Mirko Rahn -- Tel +49-721 608 7504 --
--- http://liinwww.ira.uka.de/~rahn/ ---
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Scope of type variables in associated types

2007-05-21 Thread Matthew Sackman
Andres Loeh [EMAIL PROTECTED] wrote:
  class OneStep a
  data OS a :: *
  instance OneStep (Cons v t)
  data OS (Cons v t) = t
  
  class TwoStep a
  data TS a :: *
  instance (OneStep a, OneStep b) = TwoStep a
 
 instance (OneStep a, OneStep (OS a)) = TwoStep a
 ?

Doesn't seem to work. Ok, my original was wrong as I had no constructor
on the associated type. So below are 2 versions, one with fundeps, which
works, one with associated type synonynms which doesn't work, which
made me remember the warnings about how type synonynms aren't fully
implemented yet, and so I wrote a third version with indexed types, but
whilst I can make it work, wrapping up values in indexed types gets
really really messy.

 {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances #-}
 
 module TestProb where
 
 data Nil = Nil
 data Cons v t = Cons v t
 
 class OneStep a b | a - b
 instance OneStep (Cons v t) t
 
 class TwoStep a b | a - b
 instance (OneStep a b, OneStep b c) = TwoStep a c
 
 class OneStep' a where
 type OS' a :: *
 
 instance OneStep' (Cons v t) where
 type OS' (Cons v t) = t
 
 class TwoStep' a where
 type TS' a :: *
 
 instance (OneStep' a, OneStep' (OS' a)) = TwoStep' a where
 type TS' a = (OS' (OS' a))
 
 foo :: (TwoStep a b) = a - b - Bool
 foo _ _ = True
 
 foo' :: (TwoStep' a) = a - TS' a - Bool
 foo' _ _ = True

*TestProb foo (Cons True (Cons 'b' (Cons hello Nil))) (Cons boo Nil)
True

*TestProb :t foo (Cons True (Cons 'b' (Cons hello Nil)))
foo (Cons True (Cons 'b' (Cons hello Nil))) :: Cons [Char] Nil - Bool

*TestProb :t foo' (Cons True (Cons 'b' (Cons hello Nil)))

interactive:1:0:
No instance for (OneStep'
   (OS' (Cons Bool (Cons Char (Cons [Char] Nil)
  arising from a use of `foo'' at interactive:1:0-45
Possible fix:
  add an instance declaration for
  (OneStep' (OS' (Cons Bool (Cons Char (Cons [Char] Nil)

Mmm. This is as a result of the instance (OneStep' a, OneStep' (OS' a))
constraint. Is it just me or does this look like the type synonynm isn't
being applied? So how about adding:

 instance (OneStep' a) = OneStep' (OS' a) where
 type OS' (OS' a) = a

*TestProb :t foo' (Cons True (Cons 'c' (Cons 5.3 (Cons hello Nil
foo' (Cons True (Cons 'c' (Cons 5.3 (Cons hello Nil :: (Fractional t) =
 TS' (Cons Bool 
(Cons Char (Cons t (Cons [Char] Nil
 - Bool

Okay, but how do I inhabit that type?

*TestProb :t foo' (Cons True (Cons 'c' (Cons 5.3 (Cons hello Nil (Cons 
5.3 (Cons hello Nil))

interactive:1:59:
Couldn't match expected type `TS'
(Cons Bool (Cons Char (Cons t (Cons [Char] 
Nil'
   against inferred type `Cons t1 (Cons [Char] Nil)'
In the second argument of `foo'', namely
`(Cons 5.3 (Cons hello Nil))'

So now, the third (and final!) version using indexed types:

 class OneStep'' a where
 data OS'' a :: *
 mkOS'' :: a - OS'' a
 
 instance OneStep'' (Cons v t) where
 data OS'' (Cons v t) = OSC'' t
 mkOS'' (Cons v t) = OSC'' t
 
 instance (OneStep'' a) = OneStep'' (OS'' a) where
 data OS'' (OS'' a) = OSC''w a
 
 class TwoStep'' a where
 data TS'' a :: *
 mkTS'' :: a - TS'' a
 
 instance (OneStep'' a, OneStep'' (OS'' a)) = TwoStep'' a where
 data TS'' a = TSC'' (OS'' (OS'' a))
 mkTS'' = TSC'' . mkOS'' . mkOS''
 
 foo'' :: (TwoStep'' a) = a - TS'' a - Bool
 foo'' _ _ = True

This, sort of works:

*TestProb let ts = mkTS'' (Cons True (Cons 'c' (Cons 5.3 (Cons hello Nil 
in foo'' (Cons True (Cons 'c' (Cons 5.3 (Cons hello Nil ts
True

But of course, the wrapping into the indexed type demands the use of
mkTS''.

You can't even write:
*TestProb let ts = mkOS'' (Cons 'c' (Cons 5.3 (Cons hello Nil))) in foo'' 
(Cons True (Cons 'c' (Cons 5.3 (Cons hello Nil ts

interactive:1:119:
Couldn't match expected type `TS''
(Cons Bool (Cons Char (Cons t (Cons [Char] 
Nil'
   against inferred type `OS''
(Cons Char (Cons t1 (Cons [Char] Nil)))'
In the second argument of `foo''', namely `ts'
In the expression:
let ts = mkOS'' (Cons 'c' (Cons 5.3 (Cons hello Nil)))
in foo'' (Cons True (Cons 'c' (Cons 5.3 (Cons hello Nil ts
In the definition of `it':
it = let ts = mkOS'' (Cons 'c' (Cons 5.3 (Cons hello Nil)))
 in foo'' (Cons True (Cons 'c' (Cons 5.3 (Cons hello Nil ts

Further, it is *impossible* to define mkTS'' for the extra
instance instance (OneStep'' a) = OneStep'' (OS'' a) where as to do
so would demand unwrapping the supplied (OS'' a) which can't be done -
if you try to add unwrop :: OS'' a - a to the class OneStep'' then try
to define it for the Cons instance - I've thrown away v so how are you
going to get it back? undefined?

Matthew
-- 
Matthew 

Re: [Haskell-cafe] Lazy HTML parsing with HXT, HaXML/polyparse, what else?

2007-05-21 Thread Henning Thielemann

On Mon, 14 May 2007, Malcolm Wallace wrote:

 Henning Thielemann [EMAIL PROTECTED] wrote:

*Text.ParserCombinators.PolyLazy
  runParser (exactly 4 (satisfy Char.isAlpha))
  (abc104++undefined)
(*** Exception: Parse.satisfy: failed
 
  How can I rewrite the above example that it returns
(abc*** Exception: Parse.satisfy: failed

 The problem in your example is that the 'exactly' combinator forces
 parsing of 'n' items before returning any of them.  If you roll your
 own, then you can return partial results:

  let one = return (:) `apply` satisfy (Char.isAlpha)
   in runParser (one `apply` (one `apply`
(one `apply` (one `apply` return []
  (abc104++undefined)
 (abc*** Exception: Parse.satisfy: failed

 Equivalently:

  let one f = ((return (:)) `apply` satisfy (Char.isAlpha)) `apply` f
   in runParser (one (one (one (one (return []) (abc104++undefined)
 (abc*** Exception: Parse.satisfy: failed

 I wonder whether 'apply' merges two separate ideas: Applying a generated
function to some parser generated value and forcing some parser to always
succeed. From the documentation of 'apply' I assumed that 'apply f x'
fails if 'f' or 'x' fails. In contrast to that it seems to succeed if only
'f' succeeds. Wouldn't it be better to have an explicit 'force' which
declares a parser to never fail - and to return 'undefined' if this
assumption is wrong.
 I have seen this 'force' in the MIDI loader of Haskore:
  http://darcs.haskell.org/haskore/src/Haskore/General/Parser.hs

 It would hold:
   apply f x  ==  do g - f; fmap g (force x)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Behavior of groupBy

2007-05-21 Thread Hans van Thiel
Thanks for the help! Strangely, I just now received your messages from
April 28, hence the late reply...

Hans van Thiel
On Sat, 2007-04-28 at 18:09 +0200, Henning Thielemann wrote:
 On Sat, 28 Apr 2007, Hans van Thiel wrote:
 
  Hello All,
 
  The standard function groupBy of List.hs doesn't work as I expect in
  this case:
 
  groupBy (\x y - (last x) == (last y)) [abc, bd,cac]
 
  results in:
 
  [[abc],[bd],[cac]]
 
  where I want:
 
  [[abc,cac], [bd]]
 
 I think you must roll your own one. How about repeated 'partition' to
 extract all elements that have the same trailing character like the head
 word of the list?
 
 I have done this in a more complex setting and called it 'slice':
   http://darcs.haskell.org/haskore/src/Haskore/Basic/TimeOrderedList.lhs
 
 
  slice :: (Eq a, Num time) =
 (body - a) - T time body - [(a, T time body)]
  slice f perf =
let splitByHeadKey pf =
   fmap
  (\ev -
 let i = f (eventBody ev)
 (pf0, pf1) = partition ((i==) . f) 0 0 pf
 in  ((i,pf0), pf1))
  (listToMaybe pf)
in  List.unfoldr splitByHeadKey perf
 

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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Claus Reinke

I have a dream.  It's not a little dream.  It's a big dream.  I have a
dream that someday I can find a UNIX/Linux text editor for Haskell
hacking (and possibly two or three hundred other programming languages,
although that's optional) that can give me all of the following:


'find / -type dream | xargs rm' is not a good way to go about that
that search, is it?-) by excluding the editors that fullfill most of your
criteria, without any good reason, you're guaranteed to come up
empty. i have a dream that there is an answer to life the universe
and everything, and it isn't 42?

you might not like the answer most people give, but there is a reason
why that answer is so popular. of course, just because it is one valid
answer, it need not be the right answer for you. you just need to be
specific about why that particular answer doesn't suit you.


1. A real GUI environment that takes into account some of the HID
   advances made in the past 30 years.  (Emacs and Vim don't count,
   in other words.)


be specific, please! emacs and vim are often the first to integrate
and experiment with whatever new ideas come into view (some even
originated there). only few of those experiments find enough followers
to make it into the main distributions, though. whatever it is you're
missing, if you can't even name it, it can't be good enough reason to
discard either emacs or vim).

in my experience, most people complain about vim or emacs because
they aren't aware of what these can do. it is not just that there is so much
functionality and variation available that one has to invest time to learn
even parts of that, one new feature a day. it is that much of what people
don't like is deliberately not fixed, but configurable.

some people don't like the complexity of emacs interactions, and
prefer vim's brief and efficient modeskey-strokes, some don't like
vim modes and prefer emacs-style commands, some prefer plain
text, some prefer gui, some ... you might prefer either vim or emacs,
but you shouldn't complain about anything that you can configure
yourself (such as modes vs long commands, gui vs text, os-style
or vim-style copypaste, colours and specifics of syntax highlighting,
available menus, and so on).

vim has a good integrated manual, and tutorials, but if i want that
much functionality, i have to learn about it, and spend a lot of time
in that documentation. the more my personal needs deviate from
default settings, the more i have to learn and configure; the more
specific functionality i need the more i have to delve into the details
of what is available. if i don't want to learn how to use such powers,
i have to make do with a less powerful, out-of-the-box environment.

some people are happy with textpad, but i know nobody who has
studied all of current vim or emacs. most users start out with the
textpad equivalent of functionality in vim or emacs, then add to their
knowledge and toolbox as and when they need to do so.

looking at your requirements, for vim, to the extent i know it:


2. Good quality syntax highlighting for Haskell that includes all
   of the usual syntax highlighting goodies, plus:


yes


 * the ability to seamlessly handle raw Haskell and both
   common forms of Literate Haskell;


i stopped using literate haskell long ago, so i can't really say.

(i always wanted literate haskell _sessions_, not programs, with
definitions, redefinitions, evaluations, explanations, but all with a
quite different structure than is useful for the programs being
explored/described in such a session)


 * the ability to properly highlight Haddock comments;


seem to be highlighted only as comments, by default, but you could
change that, if you really wanted to. if the change looks useful, it
should make it into the next vim release - that's how the current haskell
highlighting got there and keeps developing.


 * the ability to highlight functions and types from
   libraries (user-expandable) differently from local
   functions and types.


that sounds potentially useful, and some of the information is
available (my vim settings have tables of local and library definitions
for completion). however, vim doesn't know about haskell scopes,
so the easiest solution would be unaware of renaming/hiding/etc.


3. Line folding to hide and show blocks of code.


yes, along with other folding modes


4. Code completion (user-expandable, ideally) for common library
   functions, type declarations, etc.


several completions, including two user-expandable ones. in my setup,
completion can be based on source, tag files, haddock indices, ghci
:browse,..


5. Easy, quick access to online documentation for said functions
   and declarations.


yes. open your favourite browser on the haddocks for the id under cursor.


6. Good (ideally scriptable) access to external utilities for
   compilation, debugging, profiling, 

Re: [Haskell-cafe] Scope of type variables in associated types

2007-05-21 Thread Matthew Sackman
On Mon, May 21, 2007 at 02:08:13PM +0100, Matthew Sackman wrote:
 Further, it is *impossible* to define mkTS'' for the extra
 -- should be mkOS''

But actually, in that code, the data declaration was never even used
either - all that is needed is:
instance (OneStep'' a) = OneStep'' (OS'' a)

But it does rather leave a mess in the code.

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


Re: [Haskell-cafe] how can I select all the 3-element-combination out of a list efficiently

2007-05-21 Thread Mark T.B. Carroll
Mirko Rahn [EMAIL PROTECTED] writes:
(snip)
 Correct (and more natural):

 nOf 0 _  = [[]]
 nOf n (x:xs) = map (x:) (nOf (n-1) xs) ++ nOf n xs
 nOf _ [] = []

Thanks very much - in both claims you're indeed correct.

-- Mark

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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Rodrigo Queiro

With a slightly less flippant response, have you ever tried TextMate? I
haven't, but I've heard many wax lyrical about its combination of the UNIXy
power of Vim et al with the intuitive and simple UI that OS X has a
reputation for. Unfortunately, it's not free and is only for Mac OS X, but
it seems that it was created by someone who shared your dream (although a
less Haskell-centric version, no doubt).

On 21/05/07, Michael T. Richter [EMAIL PROTECTED] wrote:


 I have a dream.  It's not a little dream.  It's a big dream.  I have a
dream that someday I can find a UNIX/Linux text editor for Haskell hacking
(and possibly two or three hundred other programming languages, although
that's optional) that can give me all of the following:


   1. A real GUI environment that takes into account some of the HID
   advances made in the past 30 years.  (Emacs and Vim don't count, in other
   words.)
   2. Good quality syntax highlighting for Haskell that includes all of
   the usual syntax highlighting goodies, plus:

   3. the ability to seamlessly handle raw Haskell and both common
   forms of Literate Haskell;
   4. the ability to properly highlight Haddock comments;
   5. the ability to highlight functions and types from libraries
   (user-expandable) differently from local functions and types.

   6. Line folding to hide and show blocks of code.
   7. Code completion (user-expandable, ideally) for common library
   functions, type declarations, etc.
   8. Easy, quick access to online documentation for said functions and
   declarations.
   9. Good (ideally scriptable) access to external utilities for
   compilation, debugging, profiling, type inference, project management, etc.
   10. A good plug-in system (ideally written in Haskell?) for
   expansion.


Is there such a beast available out there somewhere?  If not, is such a
beast lurking in the background ready to pounce in the near future?
  --
*Michael T. Richter* [EMAIL PROTECTED] (*GoogleTalk:*
[EMAIL PROTECTED])
*I have to wonder why people think that when they can't manage local
personnel within easy strangling and shooting distance, then they can manage
personnel thousands of miles away that have different languages, cultures,
and business rules. (Joe Celko)*

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

2007-05-21 Thread Michael T. Richter
On Mon, 2007-21-05 at 13:41 +0100, Neil Mitchell wrote:

 Michael is asking is there something more GUI like? - to
 which the answer is yes - Visual Haskell -


Sadly what I was asking was is there anything more GUI like for
Linux.  ;)  It doesn't surprise me that Macs and Windows boxes have
something like what I'm looking for.  Usability testing isn't alien to
those platforms' mindsets.  Unfortunately Macs are basically unavailable
where I live.  (I guess I could travel 24 hours round-trip to the
nearest Apple store I know of and pay five months' spending money for a
MacBook, not to mention the ticket prices, but that's not going to
happen, I'm afraid.)  And Windows as a platform lacks certain features I
like (including stability, security and an absence of Trusted
Computing) that made me turn away from it in the first place.  It's one
of those trade-off situations, but sometimes I really wish this
particular trade-off weren't necessary.

-- 
Michael T. Richter [EMAIL PROTECTED] (GoogleTalk:
[EMAIL PROTECTED])
Theory is knowledge that doesn't work. Practice is when everything works
and you don't know why. (Hermann Hesse)
attachment: smiley-4.png

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] Editor

2007-05-21 Thread Bayley, Alistair
 1.A real GUI
 2.Good quality syntax highlighting for Haskell..., plus: 
   3.  raw Haskell both forms of Literate Haskell; 
   4.  properly highlight Haddock comments; 
   5.  highlight functions and types from libraries differently
from local 
 3.Line folding to hide and show blocks of code.
 4.Code completion
 5.Easy, quick access to online documentation 
 6.access to external utilities for compilation, debugging,
profiling, type inference, 
 project management, etc. 
 7.A good plug-in system

Having dismissed Visual Haskell for being Windows-only, have you
considered EclipseFP? It doesn't tick all of your boxes, but maybe it
goes far enough in the right direction. AFAICT it fulfills 1, 2.3, 2.5
(but I'm not sure about this), 3, 6, and 7 (ish - plugins would be
written in Java).

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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Arthur van Leeuwen


On 21-mei-2007, at 13:56, Michael T. Richter wrote:


Hell, even comparing the out-of-the-box syntax highlighting support  
in Gedit vs. (G)Vim is instructive.  Code like  
makeRandomValueST :: StdGen - (MyType, StdGen) (which,  
incidentally, was far easier to copy from in Gedit than GVim to  
paste into this message) only differentiates :: and - from the  
text and delimiters in GVim while in Gedit (keeping in mind that  
Gedit isn't a very good editor!) differentiates those plus  
makeRandomValueST vs. StdGen and MyType.  And the parentheses.


This is an interesting take on things. What to highlight and why is
decidedly non-trivial. Personally, I strongly *dislike* highlighting
of user-defined identifiers. And honestly, in Haskell, most identifiers
are user-defined. Furthermore, the haskell vim highlighter actually
allows you to highlight delimiters, True and False, the names of a
number of types, and the names of debugging functions. It requires
settings to turn that on though, as the highlighter should be as  
minimally
visually intrusive in its default setting as possible. Or at least,  
that's what
I think, and I was the last person to get his grubby paws on vim's  
highlighter
for Haskell. It does highlight literate Haskell code quite nicely  
however,
both in bird track style and in TeX style. It does expect literate  
Haskell

to be in .lhs files though...

Note that it is somewhat tricky to distinguish between the occurences
of the a's before and after the semicolon in the following:
map :: ( a - b ) - [a] - [b]; map f (a:as) = f a : (map f as)

I'd like to see what GEdit does to that. :)

Doei, Arthur van Leeuwen.

--

  /\/ |   [EMAIL PROTECTED]   | Work like you don't need  
the money
/__\  /  | A friend is someone with whom | Love like you have never  
been hurt
/\/__ | you can dare to be yourself   | Dance like there's nobody  
watching




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


Re: [Haskell-cafe] Behavior of groupBy

2007-05-21 Thread Henning Thielemann

On Mon, 21 May 2007, Hans van Thiel wrote:

 Thanks for the help! Strangely, I just now received your messages from
 April 28, hence the late reply...

Our mail server does now send a bunch of mails I thought that were sent
long ago.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Editor

2007-05-21 Thread Leif Frenzel

Bayley, Alistair wrote:

1.  A real GUI
2.	Good quality syntax highlighting for Haskell..., plus: 
	3.	raw Haskell both forms of Literate Haskell; 
	4.	properly highlight Haddock comments; 
	5.	highlight functions and types from libraries differently
from local 

3.  Line folding to hide and show blocks of code.
4.  Code completion
5.	Easy, quick access to online documentation 
6.	access to external utilities for compilation, debugging,
profiling, type inference, 
project management, etc. 
7.	A good plug-in system


Having dismissed Visual Haskell for being Windows-only, have you
considered EclipseFP? It doesn't tick all of your boxes, but maybe it
goes far enough in the right direction. AFAICT it fulfills 1, 2.3, 2.5
(but I'm not sure about this), 3, 6, and 7 (ish - plugins would be
written in Java).
There is also some experimentation under way to implement plugins in 
Haskell: http://leiffrenzel.de/eclipse/cohatoe/ The Haskell code is 
plugged into Eclipse via hs-plugins. However, the ultimate entry point 
to the IDE is still Eclipse's, so there will be some Java/XML 
boilerplate necessary for getting a plugin hooked.


Thanks  ciao,
Leif



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



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


[Haskell-cafe] AngloHaskell 2007

2007-05-21 Thread Philippa Cowderoy
I'd like to announce AngloHaskell 2007, or at least the start of the 
process of organising it!

Last year there was a get-together organised around the interviews for the 
job of GHC maintainer. There were talks, with a largely pragmatic 
flavour, and there was plenty of socialising. It was fun, and doing it 
again seems a good idea.

In the vein of last year's process, organising an event this year shall 
take place on the Haskell Wiki page at:

http://www.haskell.org/haskellwiki/AngloHaskell

and on IRC, in #anglohaskell on irc.freenode.net

So far this is almost all the detail available, as neither date nor venue 
have been set - a summer date seems good though, and by the time we're 
organised I imagine late July or August looks most likely. Simon 
Peyton-Jones has offered to ask Microsoft Research for space to give talks 
in. This worked well last year, but if anyone else wants to offer a venue 
that's fine!

-- 
[EMAIL PROTECTED]

The task of the academic is not to scale great
intellectual mountains, but to flatten them.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Editor

2007-05-21 Thread David House

On 21/05/07, Michael T. Richter [EMAIL PROTECTED] wrote:

Easy, quick access to online documentation for said functions and declarations.


I'm writing this for Emacs right now. At the moment both Emacs and Vim
can access everything that GHCi has to offer on a function, which
means where it's defined, it's type and so on, but not Haddock
documentation. I'm extending haskell-mode's inf-haskell.el to take
this into account.

--
-David House, [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Profiling, GUIs and libraries

2007-05-21 Thread Duncan Coutts
Just in case anyone was wondering how to do this with the other major
Haskell GUI lib Gtk2Hs...

./configure --enable-profiling

some day when Gtk2Hs is cabalised it'll be even easier.

Duncan

On Sun, 2007-05-20 at 17:39 +0200, Anthony Chaumas-Pellet wrote:
 Hello,
 
 I'm currently hacking away a wxhaskell program that uses up 100% CPU
 even when it should be idle. So, rather than doing blind guesswork,
 I've thought about using profiling to spot the zealous function. I do
 not need a very accurate result, though.
 
 ghc with -prof -auto(-all) produces the following error message,
 however: Could not find module `Graphics.UI.WX': Perhaps you haven't
 installed the profiling libraries for package wx-0.10.1? Use -v to see
 a list of the files searched for.
 
 So, I guess I need to rebuild wx with profiling, but I'm not sure how
 to do that exactly; search engine and the Wiki did not turn up any
 pointers, and there are no ready-made options to build wx with
 profiling. It seems Cabal can build a library with profiling
 automatically, but I don't think there exists a Cabalized version of
 wx yet.
 
 That, and I'm not sure if recompiling libraries to add profiling is a
 great idea, as wx itself may depend on other external libraries. So,
 is there a better way than profiling in my case, or am I missing
 something obvious here?


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


Re: [Haskell-cafe] Scope of type variables in associated types

2007-05-21 Thread Bertram Felgenhauer
Matthew Sackman wrote:
  class G a where
data E a :: *
wrap :: a - E a
unwrap :: E a - a
 
 I'm afraid not. I really need wrap to take a 'b' and unwrap to return a 'b'.
 Talking on #haskell to sjanssen last night, he came up with:

How does

  class F a where
  data B a :: *
  data E a :: *
  wrap :: B a - E a
  unwrap :: E a - B a

sound? 'B a' would represent the 'b' in your previous attempt,

  class F a b | a - b where
  ...

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


Re: [Haskell-cafe] Haskell: the Craft of Functional Programming

2007-05-21 Thread PR Stanley


I'm not sure what you mean by a lot of transcription 
work.  It's an excellent book, aimed at beginners.

transcribe :: Print - Etext





Mike

PR Stanley wrote:

Hi
I've acquired a copy of the above title but it requires a lot of 
transcription work. So, I thought I'd first ensure it's worth the 
time and effort. This edition was published in 1999.

All Opinions on the text, good or bad, would be very welcome.
Thanks,
Paul
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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


Re: [Haskell-cafe] How Albus Dumbledore would sell Haskell

2007-05-21 Thread Andrew Coppin

Henning Thielemann wrote:

On Wed, 18 Apr 2007, Dan Weston wrote:

  

You have already won over the scientists.



I only know few mathematicians using Haskell, most of the (applied)
mathematician colleagues I know prefer MatLab.
  



Blehr! _

I hate MatLab... it's horrid!

(OTOH, I'm not a real mathematition, so...)

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


Re: [Haskell-cafe] How Albus Dumbledore would sell Haskell

2007-05-21 Thread Brandon S. Allbery KF8NH


On May 21, 2007, at 14:15 , Andrew Coppin wrote:


Henning Thielemann wrote:

I only know few mathematicians using Haskell, most of the (applied)
mathematician colleagues I know prefer MatLab.

I hate MatLab... it's horrid!


Everyone hates Matlab.  Problem is, it's hard to find anything like  
its toolkits


--
brandon s. allbery [linux,solaris,freebsd,perl]   
[EMAIL PROTECTED]
system administrator  [openafs,heimdal,too many hats]   
[EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university   
KF8NH




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


Re: [Haskell-cafe] How do I insert an element in HaXml?

2007-05-21 Thread Jeremy Shaw
At Sun, 20 May 2007 10:55:26 +0100,
Malcolm Wallace wrote:
 
 Jeremy Shaw [EMAIL PROTECTED] writes:
 
  How do I create a HaXml filter that adds a new element as a child of
  an existing element. For example, let's say I have the XML document:
  a b/ c/ /a
  How do I add a new element under a / so that I have the document:
  a newElement/ b/ c/ /a
 
 Using the combinators, it goes something like this:
 
 mkElem a [ mkElem newElement []
, children ] `o` tag a
 
 Having matched the outer tag, you then rebuild it with some extra stuff
 added.  Obviously you would abstract the common pattern if you do this
 frequently:
 
 insertAtStart :: String - String - CFilter
 insertAtStart outer newelem =
 mkElem outer [ mkElem newElem []
  , children ] `o` tag outer

Thanks! I should probably mention that I don't actually have a
specific problem I am trying to solve here. I am trying to write a
tutorial on how to use the combinators, and there is a certain class
of problems I can't seem to handle. I am not sure if it is because
there is a hole in my understanding, or if there is an hole in what
the combinators can express. The hole is related to operations that
want to edit the children of a element in some sort of aggregate
manner. The current example is inserting a new element. Another
example is sorting the children.

Going back to the example at hand, what if I don't know the name and
attributes of the parent?  For example, if I have the document:

top
  section attr=value1
b /
b /
  /section
  section2 attr=value3
b /
  /section2
  othersection attr=\value2\/
/top

And a I want to add single newElement / to any child of top that
already has one or more b / element, so I get this output:

top
  section attr=value1
newElement /
b /
b /
  /section
  section2 attr=value3
newElement /
b /
  /section2
  othersection attr=value2/
/top

A solution that comes close is this filter:

 chip ((chip (mkElem newElement [] `union` keep)) `when` (elm / tag b))

Except that it will produce a newElement / for *every* b /,
whereas I only want a single newElement / per parent.

If I introduce a new (poorly named) primitive:

 editElem :: CFilter - CFilter
 editElem f c@(CElem (Elem name as _)) = [ CElem (Elem name as (f c)) ]

Then I can express the filter like this:

 chip (editElem (mkElem newElement [] `union` children) `when` (keep / tag 
 b))

But, I don't see an obvious way to implement 'editElem' using the
existing combinators. 

On the other hand, 'chip' can be implemented in terms of 'editElem':

 chip' = editElem children

but, I am not sure what implications that has, if any.

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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Ben Moseley

You mentioned a dream 

Have you looked at Yi? might be worth a peek if you're prepared  
to work towards your dream.


http://www.haskell.org/haskellwiki/Yi

...a long way to go - but it certainly nails #7!

--Ben

On 21 May 2007, at 15:44, Leif Frenzel wrote:


Bayley, Alistair wrote:

1.  A real GUI
2.	Good quality syntax highlighting for Haskell..., plus: 	3.	raw  
Haskell both forms of Literate Haskell; 	4.	properly highlight  
Haddock comments; 	5.	highlight functions and types from  
libraries differently

from local

3.  Line folding to hide and show blocks of code.
4.  Code completion
5.	Easy, quick access to online documentation 6.	access to  
external utilities for compilation, debugging,

profiling, type inference,

project management, etc. 7. A good plug-in system

Having dismissed Visual Haskell for being Windows-only, have you
considered EclipseFP? It doesn't tick all of your boxes, but maybe it
goes far enough in the right direction. AFAICT it fulfills 1, 2.3,  
2.5

(but I'm not sure about this), 3, 6, and 7 (ish - plugins would be
written in Java).
There is also some experimentation under way to implement plugins  
in Haskell: http://leiffrenzel.de/eclipse/cohatoe/ The Haskell code  
is plugged into Eclipse via hs-plugins. However, the ultimate entry  
point to the IDE is still Eclipse's, so there will be some Java/XML  
boilerplate necessary for getting a plugin hooked.


Thanks  ciao,
Leif


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


___
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 Albus Dumbledore would sell Haskell

2007-05-21 Thread Dipankar Ray


(aside to Dylan T: I hope you don't mind me advertising your (well, 
public) web pages here. In my opinion a lot more people should know about 
the stuff that both you and Ken are doing!)


Here's an example of some great math being done in haskell:

http://www.math.columbia.edu/~dpt/genus2fiber/

(the code for this paper):

http://arxiv.org/abs/math.GT/0510129


On Mon, 21 May 2007, Brandon S. Allbery KF8NH wrote:



On May 21, 2007, at 14:15 , Andrew Coppin wrote:


Henning Thielemann wrote:

I only know few mathematicians using Haskell, most of the (applied)
mathematician colleagues I know prefer MatLab.

I hate MatLab... it's horrid!


Everyone hates Matlab.  Problem is, it's hard to find anything like its 
toolkits


--
brandon s. allbery [linux,solaris,freebsd,perl]  [EMAIL PROTECTED]
system administrator  [openafs,heimdal,too many hats]  [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university  KF8NH



___
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] List algorithm

2007-05-21 Thread Steffen Mazanek

Hello,

is there an efficient algorithm that takes two positive numbers n and m and
that computes all lists l of numbers 0x=n such that sum l = m?

For instance
alg 5 1 = [[1]]
alg 5 2 = [[1,1],[2]]
alg 5 3 = [[1,1,1],[1,2],[2,1],[3]]
...

I know that filter (\l-sum l == m) (powerSet [1..n]) would do the job,
however I am looking for a more efficient approach. Help is greatly
appreciated, even a google search term would be fine :-) I really
hope for a polynomial algorithm although I am not very optimistic
about this.

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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Albert Y. C. Lai

Michael T. Richter wrote:

   1. A real GUI environment that takes into account some of the HID
  advances made in the past 30 years.  (Emacs and Vim don't count,
  in other words.)


I for my life think HID refers to human input devices: keyboard, mouse, 
joystick, gamepad, pedal, microphone, touchscreen... When this HID 
statement is brought up, the first and only thing I think of is the 
recent Mathematica 6: It supports the gamepad for rotating 3D plots.
Apart from that, absolutely no programming environment takes into 
account much of the HID advances in the past 30 years; they only go up 
to keyboard and mouse.


GUI, menu, modal, modeless... those would be HCI.

But that inspires some real fantasy for the next century.

I want to watch a function definition as a 3D thunk, and rotate it with 
the gamepad. It is even better than a parse tree, because I want let 
x2=x*x in x2+x2 to be displayed as:


 *
/ \
   x2  x2
|  |
---
  +
 / \
 \ /
  x

or any topological equivalence. At my selection, some nodes stick out 
blurbs containing their types or haddocks. No more 20th century dark age 
dogma of vertical serialization of horizontal serialization of 
characters euphemized as plain text file, the least problem of which 
is the sorry kludge of operator precedences and parenthesizing. In this 
thread I ask, can programming be liberated from the plain text file, 
now that it is liberated from the von Neumann style?


Module dependency graphs receive the same treatment. Modules in a 
project are shown as a 3D graph. Using the gamepad, I rotate the graph, 
bring a module to the forefront, and press the circle button to open it.


Debugging has never been more enticing! All CAFs and thunks are 
displayed in 3D. (As usual, you can use the gamepad to change 
perspective at will.) A small virtual organism, dubbed the bug, walks 
the thunks and does the graph reductions. You can of course interrupt 
the bug and give explorative instructions. You may want to rename this 
activity to bugging. Imperative communities may boast the best 
debuggers, but only in Haskell you find the best buggers!


(On second thought, dubbing the virtual organism the alligator may bug 
you less.)

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


Re: [Haskell-cafe] List algorithm

2007-05-21 Thread Mark T.B. Carroll
Steffen Mazanek [EMAIL PROTECTED] writes:

 alg 5 1 = [[1]]
 alg 5 2 = [[1,1],[2]]
 alg 5 3 = [[1,1,1],[1,2],[2,1],[3]]

Would this be better?

alg n m =
case signum m of
  -1 - []
  0 - [[]]
  1 - [ x : xs | x - [1..n], xs - alg n (m - x) ]

-- Mark

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


[Haskell-cafe] efficient and/or lazy partitions of a multiset

2007-05-21 Thread Greg Meredith

HC-er's,

Find below some simple-minded code from a naive Haskeller for generating all
partitions of a multiset about which i have two questions.

mSplit :: [a] - [([a], [a])]
mSplit [x] = [([x],[])]
mSplit (x:xs) = (zip (map (x:) lxs) rxs)
 ++ (zip lxs (map (x:) rxs))
 where (lxs,rxs) = unzip (mSplit xs)

  1. Is there a clever way to reduce the horrid complexity of the naive
  approach?
  2. How lazy is this code? Is there a lazier way?

i ask this in the context of checking statements of the form \phi * \psi |=
e_1 * ... * e_n where

  - [| \phi * \psi |] = { a \in U : a === b_1 * b_2, b_1 \in [| \phi |],
  b_2 \in [| \psi |] }
  - === is some congruence generated from a set of relations

A nice implementation for checking such statements will iterate through the
partitions, generating them as needed, checking subconditions and stopping
at the first one that works (possibly saving remainder for a rainy day when
the client of the check decides that wasn't the partition they meant).

Best wishes,

--greg

--
L.G. Meredith
Managing Partner
Biosimilarity LLC
505 N 72nd St
Seattle, WA 98103

+1 206.650.3740

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


Re: [Haskell-cafe] List algorithm

2007-05-21 Thread Mark T.B. Carroll
[EMAIL PROTECTED] (Mark T.B. Carroll) writes:

 alg n m =
 case signum m of
   -1 - []
   0 - [[]]
   1 - [ x : xs | x - [1..n], xs - alg n (m - x) ]

FWIW it's faster if you do some memoising:

algMemo n m = lookupMemo m
where
  memo = [[]] : map helper [1..m]
  lookupMemo m = if m  0 then [] else memo !! m
  helper m' = [ x : xs | x - [1..n], xs - lookupMemo (m' - x) ]

-- Mark

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


Re: [Haskell-cafe] List algorithm

2007-05-21 Thread Mark T.B. Carroll
[EMAIL PROTECTED] (Mark T.B. Carroll) writes:
(snip)
 algMemo n m = lookupMemo m
 where
   memo = [[]] : map helper [1..m]
   lookupMemo m = if m  0 then [] else memo !! m
   helper m' = [ x : xs | x - [1..n], xs - lookupMemo (m' - x) ]

which, I suppose, is rather like,

algMemo n m = last memo
where
  memo = [[]] : map helper [1 .. m]
  helper m' = [ x : xs | x - [1 .. min m' n], xs - memo !! (m' - x) ]

-- Mark

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


Re: [Haskell-cafe] Editor

2007-05-21 Thread Alexis
On Tuesday 22 May 2007 02:30, Claus Reinke wrote:
 Vim is eliminated before it reaches the gate because it's a modal
 editor.  Even with GVim in place, it still has that modal stench to it
 that leaps up and bites at awkward moments.

 that's a bit more specific, at least. but as far as i recall, modes were
 considered bad for specific reasons, such as 'users can't see where
 they are, modewise',  'functionality becomes unavailable in a mode',
 'users have no way to get out of a mode', etc. and most of these
 specific issues have actually been addressed in vim.

Since no-one else has done so, i thought i should mention Cream:

http://cream.sourceforge.net/featurelist.html

Cream is a customisation of Vim/gVim, providing a more contemporary GUI style 
and single-mode editing (although modal editing is available if one wants 
it)  - with all the power of Vim under the hood. :-)


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


[Haskell-cafe] type class question

2007-05-21 Thread Tim Docker

I think this must almost be a FAQ, or at least a PAQ (Previously AQ)...
 
If I have a type class for conversion to a type X:
 
class XType a where
toX   :: a - X
 
I can define instances for 
 
instance XType Int where toX  = ...
instance XType Double where toX  = ...
instance XType Tuple where toX  = ...
 
but not for Strings, given that they are a synonym for [Char]. Hence:
 
instance XType String where toX  = ...
 
results in:
 
Illegal instance declaration for `XType String'
(The instance type must be of form (T a b c)
 where T is not a synonym, and a,b,c are distinct type
variables)
In the instance declaration for `XType String'
 
Is there some type class cleverness that can make this work in haskell
98? I can create a new wrapper type for strings:

newtype StringWrap = StringWrap String

and write an instance for that, but then I'll have to litter my code
with calls to this constructor.

I'm aware of the approach taken by class Show in the prelude, which
adds a extra method to the class:
 
class XType a where
toX :: a - X
listToX :: [a] - X
 
but I believe this says that whenever we can convert a to an X we can
also
convert [a] to an X, whereas I only want [Char] to be acceptable.
 
Thanks for any pointers.
 
Tim
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] type class question

2007-05-21 Thread Derek Elkins

Tim Docker wrote:

I think this must almost be a FAQ, or at least a PAQ (Previously AQ)...
 
If I have a type class for conversion to a type X:
 
class XType a where

toX   :: a - X
 
I can define instances for 
 
instance XType Int where toX  = ...

instance XType Double where toX  = ...
instance XType Tuple where toX  = ...
 
but not for Strings, given that they are a synonym for [Char]. Hence:
 
instance XType String where toX  = ...
 
results in:
 
Illegal instance declaration for `XType String'

(The instance type must be of form (T a b c)
 where T is not a synonym, and a,b,c are distinct type
variables)
In the instance declaration for `XType String'
 
Is there some type class cleverness that can make this work in haskell

98? I can create a new wrapper type for strings:

newtype StringWrap = StringWrap String

and write an instance for that, but then I'll have to litter my code
with calls to this constructor.

I'm aware of the approach taken by class Show in the prelude, which
adds a extra method to the class:
 
class XType a where

toX :: a - X
listToX :: [a] - X
 
but I believe this says that whenever we can convert a to an X we can

also
convert [a] to an X, whereas I only want [Char] to be acceptable.


I believe there is a trick where essentially you end up with,
instance IsChar a = XType [a] where ...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Editor OT: streamofconciousness

2007-05-21 Thread John Meacham
On Mon, May 21, 2007 at 06:37:22PM +0800, Michael T. Richter wrote:
  1. A real GUI environment that takes into account some of the HID
 advances made in the past 30 years.  (Emacs and Vim don't count,
 in other words.)

heh. find me a new GUI editor that takes into account the HID advances
that were well established 30 years ago and I will be happy. I am all
for innovation, but not at the cost of needed and useful functionality.

I recently had a discussion with a coworker where he went off for a long
time about his new 'refactoring' editor, telling me cool stuff he could
do with it. Excited and interested, I went to see what it was about (I
always am interested in new stuff, especially if it can make my life
easier). I watched as he used pop-up windows and dialogs to happily
indent and unindent methods and rename variables, after which he turned
to me and said proudly now this is refactoring.. To which, I, puzzled,
responded, Really? to me it just looked like you were editing.

It is a perhaps sad fact that a lot of innovation when it comes to
editing interfaces is simply one of terminology. Inventing names for
well established practices, imbuing them with the magical power of
buzzwords to sway opinion in the face of rationality and then dismiss
every feature that one cannot list on a features FAQ as irrelevant.

It is somewhat depressing that immutable pre-packaged macros[1] and the
simple brute-force inclusion of separate tools[2] into the editor are
hailed as innovation, when new innovations, whether they are simple
refinements of old ideas[3], excercises in orthoginality[4], or truely
new research[5] are left to the wayside. But such is the power of the
bullet point.

John

[1] many (but not all) refactoring features i have seen.
[2] http://en.wikipedia.org/wiki/Cscope
[3] http://en.wikipedia.org/wiki/Sam_(text_editor)
[4] http://en.wikipedia.org/wiki/Acme_%28Plan_9%29
[5] http://tlau.org/research/smartedit/


-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Scope of type variables in associated types

2007-05-21 Thread Matthew Brecknell
Bertram Felgenhauer:
 How does
 
   class F a where
   data B a :: *
   data E a :: *
   wrap :: B a - E a
   unwrap :: E a - B a
 
 sound? 'B a' would represent the 'b' in your previous attempt,
 
   class F a b | a - b where
   ...
 

I'm with Simon in thinking that this code is suspicious.

For any given call to wrap or unwrap, how is the compiler supposed
to determine which instance to use, given that a cannot be uniquely
determined from the type of the function? The same question also applies
to Matthew's original formulation using functional dependencies:

 class G a b | a - b where
 data E a :: *
 wrap :: b - E a
 unwrap :: E a - b

Simon's reformulation doesn't have this problem:

 class G a where
 data E a :: *
 wrap :: a - E a
 unwrap :: E a - a

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


RE: [Haskell-cafe] type class question

2007-05-21 Thread Tim Docker
Derek Elkins wrote:
 I believe there is a trick where essentially you end up with, instance
IsChar a = XType [a] where ...

That is simple enough, and works fine. Thanks!

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


[Haskell-cafe] Wanted: extended static checking for xmonad

2007-05-21 Thread Donald Bruce Stewart

When working on xmonad, we're trying to produce very clean, correct
code -- a window manager that just works. To do this, we're looking to
employ more static checking tools to the code base. Currently we use:

* QuickCheck (checks high level window manager behaviour)
* Catch (Neil's pattern match verifier, caught a couple of bugs)
* ghc -Wall

One other tool we're considering:

* HPC. check program coverage of the test suite.

But I suspect that there's an awful lot of other small checkers of
various kinds out there. 

So: 
* Do you know of some other cool code checking tool for Haskell?
* That could be used on xmonad (xmonad.org) to reduce code smell? 

If so, let us know! :-)

-- Don

P.S. Perhaps it is time for a wiki page documenting the available
extended static checking tools for Haskell.

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