Re: [Haskell-cafe] IO trouble

2009-05-14 Thread Henning Thielemann
Xiao-Yong Jin schrieb:
 Lauri Alanko l...@iki.fi writes:
 
 On Tue, May 12, 2009 at 04:59:36PM -0400, Xiao-Yong Jin wrote:
 f :: a - b
 g :: (a - b) - c - d
 gf :: c - d
 gf = g f
 Now I want to handle exceptions in f and redefine f as in f'

 f' :: a - IO (Either e b)
 So my question is how to define gf' now to use f' instead of
 f?

 gf' :: c - IO (Either e d)
 Use Control.Monad.Error.ErrorT, it's exactly for this. You have to
 monadize g to be able to pass f' as an argument to it.

 f' :: a - ErrorT e IO b
 g' :: Monad m = (a - m b) - c - m d
 gf' :: c - ErrorT e IO d
 gf' = g' f'
 
 So there is no way to do it without monadize g to g', is
 it?  Big trouble, sigh.

Sure, but I'm afraid that gets more complicated. Btw. you can also use
ExceptionalT and Exceptional from explicit-exception package, which does
not require a constraint on the exception type.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [darcs-users] [Haskell-cafe] Darcs as undo/redo system?

2009-05-14 Thread Wolfgang Jeltsch
Am Mittwoch, 13. Mai 2009 02:55 schrieb Trent W. Buck:
 Wolfgang Jeltsch g9ks1...@acme.softbase.org writes:
  Am Freitag, 8. Mai 2009 18:43 schrieb Jason Dagit:
  If you wanted to work on this, I would encourage you to read more
  about patch theory[1,2,3,4] and also try out libdarcs[5].
 
  Is libdarcs the same as the darcs library package on Hackage (which
  exports the darcs API)?

 The Darcs package (both on Hackage and elsewhere) builds two things: the
 darcs(1) binary, and libHSdarcs.  The latter is what Jason was referring
 to.  Note that currently it just exposes all our internal functions,
 rather than providing a coherent (or stable!) API.

I know. My students, who worked on a darcs GUI frontend, already experienced 
this. ;-) 

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


Re: [Haskell-cafe] Removing mtl from the Haskell Platform

2009-05-14 Thread Wolfgang Jeltsch
Am Mittwoch, 13. Mai 2009 01:03 schrieb rocon...@theorem.ca:
 I wanted to pass this idea around the cafe to get some thoughts before
 submitting a trac on this topic.

 I'd like to see the mtl removed from the Haskell Platform.

 The mtl was a tremendous step forward when it was developed.  However, we
 have learned a few things about monad transformers since the development
 of the mtl, and it is time that we moved forward.

 There are at least 3 significant problem with the mtl.

 1) `pass' should not be a member functions of the MonadWriter class.  It
 is my understanding that there is no `MonadWriter w m = MonadWriter w
 (ContT s m)' instance because the `pass' function cannot be implemented.
 I'm also highly suspicious of some other methods too (I'm looking at you
 `local').

 2) The `StateT s (Cont r a)' instance of callCC is wrong.  The paper on
 modular monad transformers
 http://www.cs.nott.ac.uk/~mjj/pubs/mmt/mmt.pdf describes why this is
 wrong.

 3) I am told by many people that the order of the state and value pair in
 `State' is backwards.  Actually, I'm not entirely sure what the issue is
 here, but I trust the people who say this.

4) The identifiers State and StateT are flawed. Something of value State s a 
doesn’t denote a state but a state transformer or however you want to name 
it.

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


Re: [Haskell-cafe] [ANNOUNCE] Bindings for libguestfs

2009-05-14 Thread Richard W.M. Jones
On Wed, May 13, 2009 at 11:15:24PM +1000, Peter Gammie wrote:
 Hope this helps!

Thanks for your honest  helpful answer.  I think I will try again at
compiling c2hs so I can look at the code that it generates.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Removing mtl from the Haskell Platform

2009-05-14 Thread Thomas ten Cate
On Thu, May 14, 2009 at 10:14, Wolfgang Jeltsch
g9ks1...@acme.softbase.org wrote:
 4) The identifiers State and StateT are flawed. Something of value State s a
 doesn’t denote a state but a state transformer or however you want to name
 it.

A state monad, i.e. a monad containing a state? If you use it in a
sentence in that way, the name State makes sense. StateTransformer
or something like that would lead to much confusion with the state
transformer transformer that is currently called StateT. I don't
really see a good alternative to the name State, and a good thing
about it is that it is short. Oh, bikesheds ought to be brown, of
course.

Cheers,

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


Re: [Haskell-cafe] Functional Reactive Web Application Framework?

2009-05-14 Thread Robert Wills
Yes, I didn't realise that until Arjun mentioned that.  I'm going to
try to find some time to look more closely at Flapjax...

-Rob

On Wed, May 13, 2009 at 11:30 PM, Don Stewart d...@galois.com wrote:
 wrwills:
 The  only web-oriented frp framework that I know of is Flapjax
 http://www.flapjax-lang.org/

 Flapjax is javascript so possibly there could be a way to integrate it
 into Haskell using HJavascript?  Maybe it could even be integrated
 into Happstack?

 I'm also quite new to Haskell.

 Isn't the flapjax compiler implemented in Haskell?

 -- Don

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


Re: [Haskell-cafe] Structural sharing in haskell data structures?

2009-05-14 Thread Vladimir Ivanov
Wren,

It's not true for Java either.
The idea of cheap throw-away objects isn't foreign for modern JVMs.
GC favors short-lived immutable objects since:
 - all collectors are generational;
 - GC cycle duration is proportional to the size of live objects, not
the heap size;
 - object allocation is _very_ cheap, even in parallel;

Moreover, many advanced techniques are used in JVM GCs:
  - there are parallel  concurrent collectors;
  - adaptive ergonomics (e.g. heap resizing, according to some goals
on collection duration);

There are problems with functional languages on top of JVM, but GC
isn't among them.
If you are interested in current work, you may look at mlvm project [1].

-- vi

[1] http://openjdk.java.net/projects/mlvm/

On Thu, May 14, 2009 at 2:58 AM, wren ng thornton w...@freegeek.org wrote:
 Jan-Willem Maessen wrote:

 I wanted to clear up one misconception here...

 wren ng thornton wrote:
  In heavily GCed languages like Haskell allocation and collection is 
  cheap, so we don't mind too much; but in Java and the like, both 
  allocation and collection are expensive so the idea of cheap throwaway 
  objects is foreign.

 Not true!

 I was speaking of Java, not Clojure. I believe the costs in Java are well
 documented, though I don't know enough about the JVM to know where the blame
 belongs. (All I know of Clojure is that it's a Lisp-like on the JVM :)


 If you look at the internals of Clojure, you'll discover they're using
 trees with *very* wide fanout (eg fanout-64 leaf trees for lists).  Why?
  Because it's so cheap to allocate and GC these structures!  By using
 shallow-but-wide trees we reduce the cost of indexing and accessing list
 elements.  I suspect you'd still be hard-pressed to support this kind of
 allocation behavior in any of the present Haskell implementations, and
 Haskell implementations of the same kinds of structures have limited fanout
 to 2-4 elements or so.

 I was under the impression that the reason datastructures in Haskell tend to
 be limited to 4-fanout had more to do with the cleanliness of the
 implementations--- pattern matching on 64-wide cells is quite ugly, as is
 dealing with the proliferation of corner cases for complex structures like
 finger trees, patricia trees, etc. The use of view patterns could clean this
 up significantly. On the other hand, we do have things like lazy ByteStrings
 and UVector which do have wide fanouts.

 --
 Live well,
 ~wren
 ___
 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] Fun with type functions

2009-05-14 Thread Simon Peyton-Jones
Friends

Ken, Oleg, and I have been working on a tutorial paper about type families (aka 
associated data types, or type functions). It's in draft at the moment, and 
we'd really appreciate feedback that would help us improve it.

Here it is: http://haskell.org/haskellwiki/Simonpj/Talk:FunWithTypeFuns

Thank you!

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


[Haskell-cafe] haskellnet

2009-05-14 Thread Robert Wills
Hello,

Yesterday I found myself wanting to clear out a spam-ridden pop
account without downloading all the messages. Rather than just using
Python's poplib, I thought I might look for a haskell solution and
came across Haskellnet:
http://darcs.haskell.org/SoC/haskellnet/

I ended up spending much of the afternoon getting it to compile and
much of last night trying to get the pop library to actually work (the
'strip' method produced exceptions).  It was a good learning
experience (this was helpful:
http://donsbot.wordpress.com/2007/11/14/no-more-exceptions-debugging-haskell-code-with-ghci/).

I'm writing here because I'm wondering whether it would be worthwhile
putting it up on hackage? From searching this list, there seem to have
been a few times when people have stumbled across it but got
frustrated when it didn't compile.  If so, what's the protocol? Is the
original author, Jun Mukai, still around?

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


Re: [Haskell-cafe] Structural sharing in haskell data structures?

2009-05-14 Thread Jan-Willem Maessen


On May 13, 2009, at 6:58 PM, wren ng thornton wrote:


Jan-Willem Maessen wrote:

I wanted to clear up one misconception here...
wren ng thornton wrote:
 In heavily GCed languages like Haskell allocation and collection  
is  cheap, so we don't mind too much; but in Java and the like,  
both  allocation and collection are expensive so the idea of cheap  
throwaway  objects is foreign.

Not true!


I was speaking of Java, not Clojure. I believe the costs in Java are  
well documented, though I don't know enough about the JVM to know  
where the blame belongs. (All I know of Clojure is that it's a Lisp- 
like on the JVM :)


I think you're missing the point here: the code I refer to below *is  
in Java* and is running on a standard JVM; the costs you refer to  
simply don't exist!  As Vladimir Ivanov points out, and as Rich Hickey  
is happy to observe in his talks on Clojure, the JVM handles  
allocation-intensive garbage-intensive programs very well.


If you look at the internals of Clojure, you'll discover they're  
using trees with *very* wide fanout (eg fanout-64 leaf trees for  
lists).  Why?  Because it's so cheap to allocate and GC these  
structures!  By using shallow-but-wide trees we reduce the cost of  
indexing and accessing list elements.  I suspect you'd still be  
hard-pressed to support this kind of allocation behavior in any of  
the present Haskell implementations, and Haskell implementations of  
the same kinds of structures have limited fanout to 2-4 elements or  
so.


I was under the impression that the reason datastructures in Haskell  
tend to be limited to 4-fanout had more to do with the cleanliness  
of the implementations--- pattern matching on 64-wide cells is quite  
ugly, as is dealing with the proliferation of corner cases for  
complex structures like finger trees, patricia trees, etc. The use  
of view patterns could clean this up significantly. On the other  
hand, we do have things like lazy ByteStrings and UVector which do  
have wide fanouts.


Hmm, I think neither of the data structures you name actually support  
both O(lg n) indexing and O(lg n) cons or append.  That said, your  
point is well taken, so let's instead state it as a challenge:


Can you, oh Haskellers, implement a fast, wide-fanout (say = 8) tree- 
based sequence implementation in Haskell, which supports at-least-log- 
time indexing and at-least-log-time cons with a large base for the  
logarithm?  Can you do it without turning off array bounds checking  
(either by using unsafe operations or low-level peeking and poking)  
and without using an algebraic data type with O(f) constructors for  
fanout of f?  You can turn off bounds checks if your program encodes  
static guarantees that indices cannot be out of bounds (there are a  
couple of libraries to do this).


The spirit here is Work in Haskell with safe operations and no FFI  
except through safe libraries, but otherwise use any extensions you  
like.


I actually think this *is* doable, but it touches a few areas where  
Haskell doesn't presently do well (the bounds checking in particular  
is a challenge).  I threw in the bounds checking when I realized that  
in fact the equivalent Java code is always bounds checked, and these  
bounds checks are then optimized away where possible.  Actually, I'd  
*love* to see an *in*efficient solution to eliminating as many bounds  
checks as possible!


-Jan




--
Live well,
~wren
___
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] haskellnet

2009-05-14 Thread Neil Mitchell
Hi

Email the original author, if you can. Ideally work with them to
upload a working version to hackage. If they're not interested
hopefully they'll make you the new maintainer. If you can't contact
them, just upload a new version anyway - as long as it's done for the
benefit of the community and not with malicious intent, everyone is
happy.

And please do make sure you upload something working, I imagine this
will be very useful to lots of people!

Thanks for your efforts

Neil

On Thu, May 14, 2009 at 12:51 PM, Robert Wills wrwi...@gmail.com wrote:
 Hello,

 Yesterday I found myself wanting to clear out a spam-ridden pop
 account without downloading all the messages. Rather than just using
 Python's poplib, I thought I might look for a haskell solution and
 came across Haskellnet:
 http://darcs.haskell.org/SoC/haskellnet/

 I ended up spending much of the afternoon getting it to compile and
 much of last night trying to get the pop library to actually work (the
 'strip' method produced exceptions).  It was a good learning
 experience (this was helpful:
 http://donsbot.wordpress.com/2007/11/14/no-more-exceptions-debugging-haskell-code-with-ghci/).

 I'm writing here because I'm wondering whether it would be worthwhile
 putting it up on hackage? From searching this list, there seem to have
 been a few times when people have stumbled across it but got
 frustrated when it didn't compile.  If so, what's the protocol? Is the
 original author, Jun Mukai, still around?

 Thanks,
 Rob
 ___
 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] Structural sharing in haskell data structures?

2009-05-14 Thread Duncan Coutts
On Thu, 2009-05-14 at 09:03 -0400, Jan-Willem Maessen wrote:

 Hmm, I think neither of the data structures you name actually support  
 both O(lg n) indexing and O(lg n) cons or append.  That said, your  
 point is well taken, so let's instead state it as a challenge:
 
 Can you, oh Haskellers, implement a fast, wide-fanout (say = 8) tree- 
 based sequence implementation in Haskell, which supports at-least-log- 
 time indexing and at-least-log-time cons with a large base for the  
 logarithm?  Can you do it without turning off array bounds checking  
 (either by using unsafe operations or low-level peeking and poking)  
 and without using an algebraic data type with O(f) constructors for  
 fanout of f?  You can turn off bounds checks if your program encodes  
 static guarantees that indices cannot be out of bounds (there are a  
 couple of libraries to do this).

Can we motivate the restriction of not using multiple constructors? If
we're only talking about a fanout of 8 then it doesn't look like a
problem. It sounds like you're really asking for an array but without
wanting to say so explicitly. Perhaps you should ask for a variable
fanout or a fanout of something bigger like 32 (and presumably these
requirements could be justified too?).

Duncan

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


Re: [Haskell-cafe] Structural sharing in haskell data structures?

2009-05-14 Thread Jan-Willem Maessen


On May 14, 2009, at 10:17 AM, Duncan Coutts wrote:


On Thu, 2009-05-14 at 09:03 -0400, Jan-Willem Maessen wrote:


Hmm, I think neither of the data structures you name actually support
both O(lg n) indexing and O(lg n) cons or append.  That said, your
point is well taken, so let's instead state it as a challenge:

Can you, oh Haskellers, implement a fast, wide-fanout (say = 8)  
tree-
based sequence implementation in Haskell, which supports at-least- 
log-

time indexing and at-least-log-time cons with a large base for the
logarithm?  Can you do it without turning off array bounds checking
(either by using unsafe operations or low-level peeking and poking)
and without using an algebraic data type with O(f) constructors for
fanout of f?  You can turn off bounds checks if your program encodes
static guarantees that indices cannot be out of bounds (there are a
couple of libraries to do this).


Can we motivate the restriction of not using multiple constructors? If
we're only talking about a fanout of 8 then it doesn't look like a
problem.


I actually expect this will cause some fairly nasty code bloat, but  
I'm happy to be proven wrong. :-)



It sounds like you're really asking for an array but without
wanting to say so explicitly. Perhaps you should ask for a variable
fanout or a fanout of something bigger like 32 (and presumably these
requirements could be justified too?).


Wide fanout seems fair.

-Jan




Duncan



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


[Haskell-cafe] PhD position in Nottingham

2009-05-14 Thread vxc

PhD position in Type Theory at Nottingham
-

A new PhD position is available in the Functional Programming Laboratory at 
the University of Nottingham. The topic of research for the project is 
Programming and Reasoning with Infinite Structures: it consists in the 
theoretical study and development of software tools for coinductive types 
and structured corecursion.


The candidate must be a UK resident with an excellent degree in Computer 
Science or Mathematics at MSc (preferred) or BSc level (first class or 
equivalent). The applicant should have a good background in mathematical 
logic, theoretical computer science or functional programming. (S)he should 
be interested doing research in type theory, constructive mathematics, 
category theory and foundations of formal reasoning.


We offer: PhD place with living expenses (standard UK level) for 3 years. 
The grants also provide laptops and travel expenses for conference and 
workshop visits. Nottingham University provides a vibrant research 
environment in the Functional Programming Laboratory.


Deadline for applications: 20 June 2009.
Send a cover letter and your CV to Venanzio Capretta (v...@cs.nott.ac.uk).
Please contact me for any additional information that you need.


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

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


RE: [Haskell-cafe] Performance Problem with Typeable

2009-05-14 Thread Simon Peyton-Jones
Interesting.  Would anyone care to make a Trac ticket for this (with perf bug 
as  the ticket kind), and (if at all possible) do some investigation to see 
what is going on?

Many thanks

Simon

| -Original Message-
| From: haskell-cafe-boun...@haskell.org 
[mailto:haskell-cafe-boun...@haskell.org] On
| Behalf Of Michael D. Adams
| Sent: 13 May 2009 22:57
| To: Haskell Cafe
| Subject: [Haskell-cafe] Performance Problem with Typeable
|
| I'm not sure where this should be reported, but I think I've found a
| significant asymptotic performance problem with Data.Typeable.  In the
| attached code, sum2 runs much slower than either sum1 or sum3.  It
| should be linear but it seems to slow down quadratically (i.e.
| doubling len quadruples the time for sum2).  Here is an example run:
|
| $ ghc --make -O3 CastSpeed.hs
| $ ./CastSpeed 2
| gsum1
| Result: 20001
| Time(sec): 7.999e-3
| Result: 20001
| Time(sec): 0.0
| Result: 20001
| Time(sec): 1.0e-3
|
| gsum2
| Result: 20001
| Time(sec): 1.483774
| Result: 20001
| Time(sec): 1.46
| Result: 20001
| Time(sec): 1.523768
|
| gsum3
| Result: 20001
| Time(sec): 5.999e-3
| Result: 20001
| Time(sec): 0.0
| Result: 20001
| Time(sec): 0.0
|
| The only difference between sum1 and sum2 is that sum2 wraps a
| singleton list around each element (i.e. the cast is to [Int] instead
| of Int).  The only difference between sum2 and sum3 is that sum3 uses
| an unchecked cast (unsafeCoerce) instead of a checked cast.  This
| problem seems to crop up only for those types which are made up of a
| type constructor applied to an argument (e.g. [] applied to Int).
|
| Because of sum3 runs fast, I suspect that something is going wrong
| with the typeOf call in a checked cast, and because sum1 runs fast I
| suspect that what is going wrong is the call to appKey that is called
| from mkAppTy that is called from typeOfDefault that is called from the
| Typeable instance for [Int] (i.e. instance (Typeable1 s, Typeable a)
| = Typeable (s a)).  This is a bit of speculation and I don't have
| hard evidence for that being the source of the problems, but tests
| that I have run (not listed here) are strongly suggestive of appKey
| being the culprit.
|
| Michael D. Adams
| mdmko...@gmail.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Developing 3 dimensional interactive environments/functional objects

2009-05-14 Thread paulfrancis
 Thanks guys, I appreciate the feedback. I'll update the mailing list with progress in my endeavors in the best way. With best wishes,  Paul    Original Message  Subject: Re: [Haskell-cafe] Developing 3 dimensional interactive  environments/functional objects From: Peter Verswyvelen bugf...@gmail.com Date: Tue, May 12, 2009 3:24 pm To: Don Stewart d...@galois.com Cc: paulfran...@friendbliss.com, haskell-cafe@haskell.org  You might want to contact the author of RogueStar GLhttp://roguestar.downstairspeople.org/ On Tue, May 12, 2009 at 5:21 PM, Don Stewart d...@galois.com wrote: paulfrancis:   Does any programmer on this mailing list have experience with developing 3  dimensional interactive environments/functional objects within them, au Second  Life? Is Haskell useful for such an endeavor?  Mm..   Anygmahttp://www.anygma.com/JobOfferA.html   gamr7http://www.gamr7.com/  Both use Haskell to some extent. ___ 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] Structural sharing in haskell data structures?

2009-05-14 Thread Jan-Willem Maessen


On May 14, 2009, at 11:01 AM, Dan Doel wrote:


On Thursday 14 May 2009 9:03:30 am Jan-Willem Maessen wrote:

Hmm, I think neither of the data structures you name actually support
both O(lg n) indexing and O(lg n) cons or append.  That said, your
point is well taken, so let's instead state it as a challenge:


Data.Sequence has O(log n) index, concatenation, update, take, drop  
and
splitAt, and O(1) cons, snoc, and viewing at both ends, according to  
the

documentation.


Yes.  But large sequences end up being quite deep.  Can a wide-fanout  
version be made that is actually faster?  Note that the effective  
fanout of Hinze's finger trees is approximately e; consider effective  
fanouts of e^2 to e^4 (which may require substantially higher maximum  
fanout).


-Jan


-- Dan


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


Re: [Haskell-cafe] Structural sharing in haskell data structures?

2009-05-14 Thread Dan Doel
On Thursday 14 May 2009 9:03:30 am Jan-Willem Maessen wrote:
 Hmm, I think neither of the data structures you name actually support
 both O(lg n) indexing and O(lg n) cons or append.  That said, your
 point is well taken, so let's instead state it as a challenge:

Data.Sequence has O(log n) index, concatenation, update, take, drop and 
splitAt, and O(1) cons, snoc, and viewing at both ends, according to the 
documentation.

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


[Haskell-cafe] hsffig and duplicate typedef declarations

2009-05-14 Thread Dimitry Golubovsky
Dean,

I am not sure how HSFFIG would deal with duplicate typedefs (I'm
afraid you get error from gcc when processing hsc2hs output).

In case you haven't seen this, I put a repo for HSFFIG here recently:

http://code.haskell.org/hsffig/

Before running cabal install run make at the toplevel of the repo first.

I have fixed some glitches recently, and adjusted both hsffig and
ffipkg to work with contemporary GHC and Cabal (at least 1.6.0.x).

I'd be glad to get any feedback on HSFFIG. E-mail me to golubovsky at
gmail dot com.

Thanks.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] Building 'text-icu-0.1' on Windows

2009-05-14 Thread Bryan O'Sullivan
On Wed, May 13, 2009 at 4:46 PM, Alexander Dunlap 
alexander.dun...@gmail.com wrote:


 This isn't really helpful, but I received similar errors when trying
 to build icu-text on Windows


If one of you has the time to dig into this and send a patch that corrects
the problem, I'd welcome the help. As I'm sure you can tell, I developed
text-icu on Unix, and I don't have regular enough Windows access to make
debugging this a quick and easy matter.

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


Re: [Haskell-cafe] Structural sharing in haskell data structures?

2009-05-14 Thread Don Stewart
jmaessen:

 On May 14, 2009, at 11:01 AM, Dan Doel wrote:

 On Thursday 14 May 2009 9:03:30 am Jan-Willem Maessen wrote:
 Hmm, I think neither of the data structures you name actually support
 both O(lg n) indexing and O(lg n) cons or append.  That said, your
 point is well taken, so let's instead state it as a challenge:

 Data.Sequence has O(log n) index, concatenation, update, take, drop  
 and
 splitAt, and O(1) cons, snoc, and viewing at both ends, according to  
 the
 documentation.

 Yes.  But large sequences end up being quite deep.  Can a wide-fanout  
 version be made that is actually faster?  Note that the effective fanout 
 of Hinze's finger trees is approximately e; consider effective fanouts of 
 e^2 to e^4 (which may require substantially higher maximum fanout).

Ah, so I see what Jan's asking for (I think).

During the hackathon a number of us were experimenting with
associated types to flatten groups of nodes in Data.Map (by unpacking
them into the constructor). We were playing with fan out of up to 16
(while preserving pattern matching that makes it look like the original
constructors).

Good speedups followed, thanks to the improved data density.

Here's a video (first part is about visualizing heap structures):

http://vimeo.com/4258084

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


Re: [Haskell-cafe] Building 'text-icu-0.1' on Windows

2009-05-14 Thread Bryan O'Sullivan
On Thu, May 14, 2009 at 10:18 AM, Bryan O'Sullivan b...@serpentine.comwrote:


 If one of you has the time to dig into this and send a patch that corrects
 the problem, I'd welcome the help. As I'm sure you can tell, I developed
 text-icu on Unix, and I don't have regular enough Windows access to make
 debugging this a quick and easy matter.

 By the way, if you run into problems building or using text or text-icu,
please file a ticket here: http://trac.haskell.org/text/newticket
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Pretty printing a tree

2009-05-14 Thread José Romildo Malaquias
Hello.

I would like to pretty print a tree in a way that its structure is
easily perceived.

For instance, consider the declarations:

   data Node a = Node a [Node a]

   type Tree a = [ Node a ]

   t = [ Node a [ Node b []
  , Node c [ Node c1 []
 , Node c2 [] ]
  , Node d [ Node d1 [ Node d1a [] ]
 , Node d2 [] ] ] ]

Then the resulting of pretty printing the given tree would be something
like the following:

   a
   |
+-+
|||
bcd
 ||
   +---++---+
   |   ||   |
   c1  c2   d1  d2
|
   d1a

There is the module Text.PrettyPrint.HughesPJ, but it lacks examples on
how to use the pretty print combinators, and it is not well docomented.

I would like to see solutions for this problem, or clues on how to solve
it.

Regards,

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


Re: [Haskell-cafe] Pretty printing a tree

2009-05-14 Thread Andrew Wagner
Perhaps drawTree on
http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Tree.html
2009/5/14 José Romildo Malaquias j.romi...@gmail.com

 Hello.

 I would like to pretty print a tree in a way that its structure is
 easily perceived.

 For instance, consider the declarations:

   data Node a = Node a [Node a]

   type Tree a = [ Node a ]

   t = [ Node a [ Node b []
  , Node c [ Node c1 []
 , Node c2 [] ]
  , Node d [ Node d1 [ Node d1a [] ]
 , Node d2 [] ] ] ]

 Then the resulting of pretty printing the given tree would be something
 like the following:

   a
   |
 +-+
 |||
 bcd
 ||
   +---++---+
   |   ||   |
   c1  c2   d1  d2
|
   d1a

 There is the module Text.PrettyPrint.HughesPJ, but it lacks examples on
 how to use the pretty print combinators, and it is not well docomented.

 I would like to see solutions for this problem, or clues on how to solve
 it.

 Regards,

 José Romildo
 ___
 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] commending Design concepts in programming languages

2009-05-14 Thread Gregg Reynolds
On Tue, May 12, 2009 at 1:04 PM, Max Rabkin max.rab...@gmail.com wrote:
 On Tue, May 12, 2009 at 1:41 PM, Wolfgang Jeltsch
 g9ks1...@acme.softbase.org wrote:
 At least, I cannot
 remember seeing the other notation (first morphism on the left) in
category
 theory literature so far. It’s just that my above-mentioned professor
told me
 that category theorists would use the first-morphism-on-the-left
notation.

 I've seen the notation f;g for g.f somewhere (and Wikipedia mentions
 it). I think it's less ambiguous than just fg (which I've seen for f.g
 too), but in Haskell we have the option of . A flipped application
 might be nice to go with it. How about $ ?

FYI:

Unicode U+2A3E  Zed notation relational composition (small circle over a 9)

Examples at http://staff.washington.edu/jon/z/toolkit.html#pair3
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] looking for suggestion on pattern matching problem

2009-05-14 Thread Daryoush Mehrtash
I am trying to analyze a list of items (say integers) for longest matches on
patterns and their location on the list.  One catch is that pattern may be
defined in terms of other patterns. Example of patterns would be the any
sequence of increasing numbers, or sequence of increasing numbers followed
by upto 5 zeros then followed by any odd digits.

I don't know much about the actual patterns, but would like to be able to
define EDSL for composing the patterns and an execution environment to
actually find the patterns.

I like to find out various ways I can structure the problem and its trade
offs.  I appreciate any  books, articles, suggestions, papers, etc on this
type of problems.

Thanks,

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


[Haskell-cafe] hiddenness

2009-05-14 Thread Vasili I. Galchin
Hello,

 When I am compiling a module, I get Could not find module
'Control.Module.State':
  it is a
member of package mtl-1.1.0.2, which is hidden

 1) What is the efficacy of hiddenness?

 2) I have forgotten what tool I run to expose a package. ??

 3) In another vein, the code is using Data.Finitemap ... so I guess I
must darcs install this?

Regards,

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


Re: [Haskell-cafe] hiddenness

2009-05-14 Thread Max Rabkin
On Thu, May 14, 2009 at 10:51 PM, Vasili I. Galchin vigalc...@gmail.com wrote:
 Hello,

  When I am compiling a module, I get Could not find module
 'Control.Module.State':
   it is a
 member of package mtl-1.1.0.2, which is hidden

  1) What is the efficacy of hiddenness?

As I understand it, the purpose is two-fold. Firstly, if you have
multiple versions a package (or multiple packages containing the same
module), you can hide the ones not in use. Second, it ensures you have
declared all dependencies.

  2) I have forgotten what tool I run to expose a package. ??

I've only ever had this when working with Cabal, where I have missed a
dependency. In this case, it looks like you have an undeclared
dependency on mtl. I'm not sure whether this arises in the non-Cabal
case.

  3) In another vein, the code is using Data.Finitemap ... so I guess I
 must darcs install this?

I believe it was just uploaded to Hackage (it's obsolete, but useful
for getting old code to run).

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


Re: [Haskell-cafe] hiddenness

2009-05-14 Thread Vasili I. Galchin
oh ... yes .. my .cabal file is incomplete! Thanks, Max.

Vasili

On Thu, May 14, 2009 at 3:56 PM, Max Rabkin max.rab...@gmail.com wrote:

 On Thu, May 14, 2009 at 10:51 PM, Vasili I. Galchin vigalc...@gmail.com
 wrote:
  Hello,
 
   When I am compiling a module, I get Could not find module
  'Control.Module.State':
it is a
  member of package mtl-1.1.0.2, which is hidden
 
   1) What is the efficacy of hiddenness?

 As I understand it, the purpose is two-fold. Firstly, if you have
 multiple versions a package (or multiple packages containing the same
 module), you can hide the ones not in use. Second, it ensures you have
 declared all dependencies.

   2) I have forgotten what tool I run to expose a package. ??

 I've only ever had this when working with Cabal, where I have missed a
 dependency. In this case, it looks like you have an undeclared
 dependency on mtl. I'm not sure whether this arises in the non-Cabal
 case.

   3) In another vein, the code is using Data.Finitemap ... so I guess
 I
  must darcs install this?

 I believe it was just uploaded to Hackage (it's obsolete, but useful
 for getting old code to run).

 HTH,
 Max

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


Re: [Haskell-cafe] looking for suggestion on pattern matching problem

2009-05-14 Thread Paul Johnson
Sounds like you need regular expressions applied to the string 
representation, although the sequence of increasing numbers is not 
something any of the standard regexp packages do.  So you will have to 
roll your own.


Alternatively you could use one of the parsing libraries to parse the 
string and define sequence of increasing numbers using a stateful parser.


Paul.

Daryoush Mehrtash wrote:
I am trying to analyze a list of items (say integers) for longest 
matches on patterns and their location on the list.  One catch is that 
pattern may be defined in terms of other patterns. Example of 
patterns would be the any sequence of increasing numbers, or sequence 
of increasing numbers followed by upto 5 zeros then followed by any 
odd digits.  

I don't know much about the actual patterns, but would like to be able 
to define EDSL for composing the patterns and an execution environment 
to actually find the patterns.


I like to find out various ways I can structure the problem and its 
trade offs.  I appreciate any  books, articles, suggestions, papers, 
etc on this type of problems.


Thanks,

Daryoush


___
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] Pretty printing a tree

2009-05-14 Thread Brent Yorgey
On Thu, May 14, 2009 at 03:58:18PM -0300, José Romildo Malaquias wrote:
 
 Then the resulting of pretty printing the given tree would be something
 like the following:
 
a
|
 +-+
 |||
 bcd
  ||
+---++---+
|   ||   |
c1  c2   d1  d2
 |
d1a
 
 There is the module Text.PrettyPrint.HughesPJ, but it lacks examples on
 how to use the pretty print combinators, and it is not well docomented.

Text.PrettyPrint.HughesPJ is actually not a good tool for this, since
it is for pretty-printing line-oriented material (i.e. source code).
I actually have a library I was developing a while ago to do the sort
of pretty-printing/layout of text that you're looking for, using a box
model similar to that of TeX, but I never released it.  Hopefully I'll
get around to polishing and releasing it this summer.

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


Re: [Haskell-cafe] looking for suggestion on pattern matching problem

2009-05-14 Thread Christopher Lane Hinson


Parsec 3 should be able to handle this pretty easily.  It can parse any 
data structure that implements it's Stream class.


Friendly,
--Lane

On Thu, 14 May 2009, Daryoush Mehrtash wrote:


I am trying to analyze a list of items (say integers) for longest matches on 
patterns and their location on the list.  One catch is that pattern may be 
defined in terms of other
patterns.     Example of patterns would be the any sequence of increasing 
numbers, or sequence of increasing numbers followed by upto 5 zeros then 
followed by any odd digits.  

I don't know much about the actual patterns, but would like to be able to 
define EDSL for composing the patterns and an execution environment to actually 
find the patterns.

I like to find out various ways I can structure the problem and its trade 
offs.  I appreciate any  books, articles, suggestions, papers, etc on this type 
of problems.

Thanks,

Daryoush

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


[Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread David Leimbach
I actually need little endian encoding... wondering if anyone else hit this
with Data.Binary. (because I'm working with Bell Lab's 9P protocol which
does encode things on the network in little-endian order).
Anyone got some tricks for this?

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


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread Don Stewart
leimy2k:
 I actually need little endian encoding... wondering if anyone else hit this
 with Data.Binary. (because I'm working with Bell Lab's 9P protocol which does
 encode things on the network in little-endian order).
 
 Anyone got some tricks for this?

Yes!
There are big, little and host-endian primitives in the Get/Put monads.


http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/Data-Binary-Put.html#v%3AputWord16le

You can use these to build encoders directly.

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


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread David Leimbach
On Thu, May 14, 2009 at 8:40 PM, Don Stewart d...@galois.com wrote:

 leimy2k:
  I actually need little endian encoding... wondering if anyone else hit
 this
  with Data.Binary. (because I'm working with Bell Lab's 9P protocol which
 does
  encode things on the network in little-endian order).
 
  Anyone got some tricks for this?

 Yes!
 There are big, little and host-endian primitives in the Get/Put monads.


 http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/Data-Binary-Put.html#v%3AputWord16le

 You can use these to build encoders directly.


Cool... I just have to write my own encoder and decoder now.

As a request could we get encodeLe decodeLe for a later version of this
library?  :-)  That'd be totally awesome.




 Cheers,
   Don

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


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread Don Stewart
leimy2k:
 
 
 On Thu, May 14, 2009 at 8:40 PM, Don Stewart d...@galois.com wrote:
 
 leimy2k:
  I actually need little endian encoding... wondering if anyone else hit
 this
  with Data.Binary. (because I'm working with Bell Lab's 9P protocol which
 does
  encode things on the network in little-endian order).
 
  Anyone got some tricks for this?
 
 Yes!
 There are big, little and host-endian primitives in the Get/Put monads.
 
http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/
 Data-Binary-Put.html#v%3AputWord16le
 
 You can use these to build encoders directly.
 
 
 Cool... I just have to write my own encoder and decoder now.
 
 As a request could we get encodeLe decodeLe for a later version of this
 library?  :-)  That'd be totally awesome.

Oh, you mean entirely different instances for all the current ones, that
use LE encodings? 

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


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread David Leimbach
On Thu, May 14, 2009 at 8:46 PM, Don Stewart d...@galois.com wrote:

 leimy2k:
 
 
  On Thu, May 14, 2009 at 8:40 PM, Don Stewart d...@galois.com wrote:
 
  leimy2k:
   I actually need little endian encoding... wondering if anyone else
 hit
  this
   with Data.Binary. (because I'm working with Bell Lab's 9P protocol
 which
  does
   encode things on the network in little-endian order).
  
   Anyone got some tricks for this?
 
  Yes!
  There are big, little and host-endian primitives in the Get/Put
 monads.
 
 
 http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/
  Data-Binary-Put.html#v%3AputWord16le
 
  You can use these to build encoders directly.
 
 
  Cool... I just have to write my own encoder and decoder now.
 
  As a request could we get encodeLe decodeLe for a later version of this
  library?  :-)  That'd be totally awesome.

 Oh, you mean entirely different instances for all the current ones, that
 use LE encodings?


Well the library is leaning towards Network Byte Order in that it has
encode/decode that only encode/decode for Big Endian.

Us folks who have to do little endian all now have to write our own
encoding/decoding :-)

I'm speaking specifically of the encode/decode functions.  I have no idea
how they're implemented.

Are you saying that encode is doing something really simple and the default
encodings for things just happen to be big endian?  If so, then I understand
the pain but it still means I have to roll my own :-)  I guess if one
must choose, big endian kind of makes sense, except that the whole world is
little endian now, except for networks :-)  (No one *really* cares about
anything but x86 anyway these days right?)

I'm only half-kidding.



 -- Don

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


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread Don Stewart
 I'm speaking specifically of the encode/decode functions.  I have no idea how
 they're implemented.
 
 Are you saying that encode is doing something really simple and the default
 encodings for things just happen to be big endian?  If so, then I understand
 the pain but it still means I have to roll my own :-)  I guess if one must
 choose, big endian kind of makes sense, except that the whole world is little
 endian now, except for networks :-)  (No one *really* cares about anything but
 x86 anyway these days right?)

Oh, 'encode' has type:

encode :: Binary a = a - ByteString

it just encodes with the default instances, which are all network order:

http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking

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


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread David Leimbach
On Thu, May 14, 2009 at 8:54 PM, Don Stewart d...@galois.com wrote:

  I'm speaking specifically of the encode/decode functions.  I have no idea
 how
  they're implemented.
 
  Are you saying that encode is doing something really simple and the
 default
  encodings for things just happen to be big endian?  If so, then I
 understand
  the pain but it still means I have to roll my own :-)  I guess if one
 must
  choose, big endian kind of makes sense, except that the whole world is
 little
  endian now, except for networks :-)  (No one *really* cares about
 anything but
  x86 anyway these days right?)

 Oh, 'encode' has type:

encode :: Binary a = a - ByteString

 it just encodes with the default instances, which are all network order:

http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking


Yeah I understand that Big Endian == Network Byte Order... which would be
true, if I wasn't talking about Plan 9's 9P protocol which specifies little
endian bytes on the wire (as far as I can tell anyway from the man page).

Dave



 -- Don

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


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread David Leimbach
On Thu, May 14, 2009 at 8:57 PM, David Leimbach leim...@gmail.com wrote:



 On Thu, May 14, 2009 at 8:54 PM, Don Stewart d...@galois.com wrote:

  I'm speaking specifically of the encode/decode functions.  I have no
 idea how
  they're implemented.
 
  Are you saying that encode is doing something really simple and the
 default
  encodings for things just happen to be big endian?  If so, then I
 understand
  the pain but it still means I have to roll my own :-)  I guess if
 one must
  choose, big endian kind of makes sense, except that the whole world is
 little
  endian now, except for networks :-)  (No one *really* cares about
 anything but
  x86 anyway these days right?)

 Oh, 'encode' has type:

encode :: Binary a = a - ByteString

 it just encodes with the default instances, which are all network order:

http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking


 Yeah I understand that Big Endian == Network Byte Order... which would be
 true, if I wasn't talking about Plan 9's 9P protocol which specifies little
 endian bytes on the wire (as far as I can tell anyway from the man page).

 Dave


FYI here's what I've ended up trying to write to negotiate the version of
a 9p server:

main = withSocketsDo $
   do
  ainfo - getAddrInfo Nothing (Just 127.0.0.1) (Just 6872)  --
hardcoded for now, it's an IRC filesystem server
  let a = head ainfo
  sock - socket AF_INET Stream defaultProtocol
  connect sock (addrAddress a)
  sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (16
::Int32
  sendAll sock $ (encode (100 ::Int8))
  sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (1024
::Int32
  sendAll sock $ (encode (C.pack 9P2000))


I feel like I should use wireshark or something to watch the bytes :-)  I'm
not feeling very sure about this.




 -- Don



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


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread David Leimbach
On Thu, May 14, 2009 at 9:10 PM, David Leimbach leim...@gmail.com wrote:



 On Thu, May 14, 2009 at 8:57 PM, David Leimbach leim...@gmail.com wrote:



 On Thu, May 14, 2009 at 8:54 PM, Don Stewart d...@galois.com wrote:

  I'm speaking specifically of the encode/decode functions.  I have no
 idea how
  they're implemented.
 
  Are you saying that encode is doing something really simple and the
 default
  encodings for things just happen to be big endian?  If so, then I
 understand
  the pain but it still means I have to roll my own :-)  I guess if
 one must
  choose, big endian kind of makes sense, except that the whole world is
 little
  endian now, except for networks :-)  (No one *really* cares about
 anything but
  x86 anyway these days right?)

 Oh, 'encode' has type:

encode :: Binary a = a - ByteString

 it just encodes with the default instances, which are all network order:

http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking


 Yeah I understand that Big Endian == Network Byte Order... which would be
 true, if I wasn't talking about Plan 9's 9P protocol which specifies little
 endian bytes on the wire (as far as I can tell anyway from the man page).

 Dave


 FYI here's what I've ended up trying to write to negotiate the version of
 a 9p server:

 main = withSocketsDo $
do
   ainfo - getAddrInfo Nothing (Just 127.0.0.1) (Just 6872)  --
 hardcoded for now, it's an IRC filesystem server
   let a = head ainfo
   sock - socket AF_INET Stream defaultProtocol
   connect sock (addrAddress a)
   sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (16
 ::Int32
   sendAll sock $ (encode (100 ::Int8))
   sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (1024
 ::Int32
   sendAll sock $ (encode (C.pack 9P2000))



I totally forgot the tag part of 9p ugh.  I think I should probably just
go to bed now.



 I feel like I should use wireshark or something to watch the bytes :-)  I'm
 not feeling very sure about this.




 -- Don




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


RE: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread Tim Docker
On a related matter, I am using Data.Binary to serialise data from
haskell
for use from other languages. The Data.Binary encoding of a Double is a
long
integer for the mantissa, and an int for the exponent.  This doesn't
work too well for interacting with other languages as I'd need to have
an arbitrary precision int type there to decode/encode. The CORBA CDR
standard encodes doubles in a big ended fashion like this (excuse my
possibly incorrect ascii art):


| byte | msb   lsb |
|--+---|
|0 | S   E6 E0 |
|1 | E10 E9 E8 E7 F3 F2 F1  F0 |
|2 | F11F4 |
|3 | F19   F12 |
|4 | F27   F20 |
|5 | F35   F28 |
|6 | F43   F36 |
|7 | F51   F44 |

Up until now, my code is pure haskell.  Is it possible to get at the
internal bits of a Double/CDouble in ghc? Or Should I use the FFI and
write C to encode something like the above?

Tim



From: haskell-cafe-boun...@haskell.org
[mailto:haskell-cafe-boun...@haskell.org] On Behalf Of David Leimbach
Sent: Friday, 15 May 2009 1:58 PM
To: Don Stewart
Cc: Haskell Cafe
Subject: Re: [Haskell-cafe] Data.Binary and little endian encoding




On Thu, May 14, 2009 at 8:54 PM, Don Stewart d...@galois.com wrote:


 I'm speaking specifically of the encode/decode functions.  I
have no idea how
 they're implemented.

 Are you saying that encode is doing something really simple
and the default
 encodings for things just happen to be big endian?  If so,
then I understand
 the pain but it still means I have to roll my own :-)  I
guess if one must
 choose, big endian kind of makes sense, except that the whole
world is little
 endian now, except for networks :-)  (No one *really* cares
about anything but
 x86 anyway these days right?)


Oh, 'encode' has type:

   encode :: Binary a = a - ByteString

it just encodes with the default instances, which are all
network order:


http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking



Yeah I understand that Big Endian == Network Byte Order... which would
be true, if I wasn't talking about Plan 9's 9P protocol which specifies
little endian bytes on the wire (as far as I can tell anyway from the
man page).

Dave
 


-- Don



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


[Haskell-cafe] I have forgotten .. my bad

2009-05-14 Thread Vasili I. Galchin
Hello,

   darcs get --init ?? I want to pull down Data.FiniteMap. I
have forgotten the path to Hackage .. I tried 

 sudo darcs get http://hackage.haskell.org/ Data.FiniteMap
[sudo] password for vigalchin:
Invalid repository:  http://hackage.haskell.org

darcs failed:  Failed to download URL
http://hackage.haskell.org/_darcs/inventory : HTTP error (404?)

??

Obviously the code I am cabalizing needs to be upgraded(i.e. not using
deprecated packages) but first I want it to build!


Thanks,

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


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-14 Thread Don Stewart
timd:
 On a related matter, I am using Data.Binary to serialise data from
 haskell
 for use from other languages. The Data.Binary encoding of a Double is a
 long
 integer for the mantissa, and an int for the exponent.  This doesn't
 work too well for interacting with other languages as I'd need to have
 an arbitrary precision int type there to decode/encode. The CORBA CDR
 standard encodes doubles in a big ended fashion like this (excuse my
 possibly incorrect ascii art):
 
 
 | byte | msb   lsb |
 |--+---|
 |0 | S   E6 E0 |
 |1 | E10 E9 E8 E7 F3 F2 F1  F0 |
 |2 | F11F4 |
 |3 | F19   F12 |
 |4 | F27   F20 |
 |5 | F35   F28 |
 |6 | F43   F36 |
 |7 | F51   F44 |
 
 Up until now, my code is pure haskell.  Is it possible to get at the
 internal bits of a Double/CDouble in ghc? Or Should I use the FFI and
 write C to encode something like the above?

Yep, it's possible, just not portably so. Google for Data.Binary IEEE
discussions.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe