Re: [Haskell-cafe] Re: OpenGL Speed!

2010-09-17 Thread Svein Ove Aas
On Fri, Sep 17, 2010 at 7:53 PM, Lie Ryan  wrote:
> It depends. Updating 800x600 screen at 24-bit color 30 times per second
> requires 800*600*24*30 = 34560 bytes/s = 329 MB/s which is larger
> than the size of typical Video Memory, and the first version of PCI
> Express (introduced 2003) is only 250 MB/s/lane.
>
Hold on, don't GPUs typically use 16 lanes?

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


Re: [Haskell-cafe] ANN: Haskell-mode 2.8.0

2010-07-02 Thread Svein Ove Aas
On Sat, Jul 3, 2010 at 1:07 AM, Deniz Dogan  wrote:
>
> Since there is no reason what so ever to integrate this external
> Haskell indenter tightly into haskell-mode, I don't see any reason to
> do so. Doing so would only mean that haskell-mode will most likely
> never be a part of Emacs, meaning that anyone looking for programming
> Haskell in Emacs would have to download an external library, be it
> through package.el or not.
>
> To put it short, there are no pros in making the new Haskell indenter
> a strict part of haskell-mode.
>
Sure there is. I expect there to be quite a lot of shared code.

It's not solely an indenter; the same interface and capabilities will
be used for a debugger, refactoring, and type signature info.
Haskell-mode should still work without it, to about the same degree as
today, but actually doing so would be a *major* degradation compared
to the state of the art once I'm done with it.

In any case, I expect the actual installation to be via cabal-install.

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


Re: [Haskell-cafe] ANN: Haskell-mode 2.8.0

2010-07-02 Thread Svein Ove Aas
On Fri, Jul 2, 2010 at 3:23 PM, Deniz Dogan  wrote:
> Why do you want to rewrite the indenter in Haskell? If haskell-mode
> has any external dependencies such as that one, it will most likely
> never make it into Emacs.
>
In no particular order:

- For any given line, there are typically several possible
indentations. We can cycle between these, but it's better to minimize
them.

- I want the parser to be as accurate as possible. This essentially
means reimplementing haskell-src-exts, unless I *use*
haskell-src-exts.

- In many cases, the legal indentations depend on the types of the
expressions involved. This can be figured out, but requires part of
the code to be running in GHC *anyway*.

- Elisp is a lousy language compared to haskell, and I don't really
care about getting haskell-mode into the emacs distribution. It makes
more sense to bundle it with GHC, if it has to be bundled.

- Most of haskell-mode will work without this helper program,
including the three other indentation modes.

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


[Haskell-cafe] ANN: Haskell-mode 2.8.0

2010-07-02 Thread Svein Ove Aas
I'm happy to (finally) announce haskell-mode 2.8.0, which can be found at
http://projects.haskell.org/haskellmode-emacs/

This is a feature release. I'll let the changelog speak for itself:


* Minimal indentation support for arrow syntax

* Autolaunch haskell-mode for files starting with #!/usr/bin/runghc
 and similar

* Added minimal major mode for parsing GHC core files, courtesy of Johan Tibell.
 There is a corresponding Haskell menu entry.

* Allow configuration of where-clause indentation; M-x customize-group
 haskell-indentation.


You can expect a 2.8.1 or even 2.8.2 in the near future, as I attempt
to empty the bug list, but I thought I might as well get the new
features out there quickly. There's bound to be new bugs associated
with them.

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


Re: [Haskell-cafe] Re: persist and retrieve of IO type?

2010-04-10 Thread Svein Ove Aas
On Sat, Apr 10, 2010 at 7:32 PM, Daryoush Mehrtash  wrote:
> Can you please explain this:
>
>> the parameters baked into the  thunk may be infinite
>
I'm a bit bushed today, I think..

I was thinking of thunks. A haskell value can be infinite, since it's
lazily evaluated; however, at the machine level a thunk is just a
function pointer plus a bunch of value (possibly meaning other thunk)
references - eminently walkable, assuming the GHC developers don't
decide to alter the format.

So, there are two ways a function serializer could work, taking
currying into account:

- Store the function pointer (or, preferably, the matching symbol
name), force all the values and write those out along with it. This
has the advantage of being less likely to break on upgrades, but since
the values may be infinite.. yeah.
- Store the function pointer, and walk the value references, storing
the entire tree of thunks/function pointers pointed to by the original
function value, but don't force any values. This at least guarantees
that the serialized form is finite.

All things considered, I'll be shooting for option #2.


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


Re: [Haskell-cafe] Re: persist and retrieve of IO type?

2010-04-10 Thread Svein Ove Aas
On Sat, Apr 10, 2010 at 11:19 AM, Jon Fairbairn
 wrote:
> It sounds more like he wants two functions something like
>
> save:: FilePath -> [IO ()] -> IO ()
> restore:: FilePath -> IO [IO ()]
>
> to which the answer would be no.
>
It's an insoluble problem in general - the parameters baked into the
thunk may be infinite, or at least too large to persist, and the
functions may not be around if you try to load the persisted data into
a different version of the executable - but it's an interesting
problem to attempt solving.

Given that GHC 6.12 has added some of the base functionality required
(i.e. dynamic linking), I was planning to take a bash at it
(persisting functions in general, not just IO actions) in the summer.

I don't know if that would help you, though. It's certainly not a good
idea in general, and at any rate there's a good chance I won't
succeed.

(Of course, thunks aren't /actually/ infinite, in memory. Part of the
project would be an attempt to persist the thunks, allowing lazy
evaluation after reading them back in. Naturally this would only work
with the exact same executable, but that's not necessarily a problem.)

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


Re: [Haskell-cafe] cannot post to haskellmode-em...@projects.haskell.org

2010-02-08 Thread Svein Ove Aas
On Sun, Feb 7, 2010 at 6:42 AM, Jens Petersen  wrote:
> On 7 February 2010 07:39, Jose A. Ortega Ruiz  wrote:
>> all my posts to the haskellmode-emacs list (using the address in the
>> subject) are being rejected with the error:
>>  451 451 Temporary local problem - please try later (state 18)
>> (after several retries by the Google smtp server, which i use as a
>> smarthost).
>
> I have been experiencing this often too recently when trying to
> post to haskell-platform list.  I wonder if some of the googlemail
> smtp servers got blacklisted on projects.haskell.org because of
> spam?
>
I see the same thing, also posting from gmail - email is a no-go.

Hm. There's nothing blacklisted in the administrative interface.

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


Re: [Haskell-cafe] I/O performance drop in ghc 6.12.1

2010-01-14 Thread Svein Ove Aas
On Thu, Jan 14, 2010 at 11:38 PM, Bryan O'Sullivan  wrote:
> On Thu, Jan 14, 2010 at 2:30 PM, Peter Simons  wrote:
>>
>> I just updated to GHC 6.12.1, and I noticed a significant drop in I/O
>> performance that I can't explain.
>
> This is probably brought about by the new Unicode I/O support in 6.12. Your
> file isn't open in binary mode, so it's probably getting translated from
> something like UTF-8 before it reaches you. Might want to compare the two.
> I'm a little surprised by the magnitude of the difference; I might have
> expected it to be 33%, not 400%.
>
Hold on, he's using hGetBuf/hPutBuf.

Although I'd suggest wrapping that in bytestrings.. the point is,
those functions are documented to ignore encoding and always use
binary I/O. There shouldn't be a difference at all.

I wonder if the difference goes away if the handle is explicitly set
to binary? It shouldn't, but then again it shouldn't exist in the
first place.

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


Re: [Haskell-cafe] short licensing question

2010-01-11 Thread Svein Ove Aas
On Mon, Jan 11, 2010 at 2:08 PM, Don Stewart  wrote:
> sebf:
>> Hello Café,
>>
>> when writing a Haskell library that uses two other Haskell libraries --
>> one licensed under BSD3 and one under LGPL -- what are allowed
>> possibilities for licensing the written package? PublicDomain? BSD3?
>> LGPL?
>>
>
> Libraries don't link in other things as such -- the .cabal file is the only
> thing that ties them together -- so you can use whatever license you
> like.
>
> Any resulting binaries might contain a mixture of such libraries, and
> the most restrictive license will usually be the license of the result.
>
So, let's look at binaries then.

In this case, LGPL is a problem. It requires you to offer a way to
re-link such binaries against new versions/implementations of the
library, which in practice requires it to be either open source or
dynamically linked.

Dynamic linking doesn't exist in GHC 6.10 and below. LGPL is thus
restricted to open-source applications there.

In 6.12.. well, dynamic linking exists, but in practice trying to
replace a library implementation won't work. In fact, there's code in
specifically to prevent it from working (well, crashing, really). So
LGPL isn't very useful on that either.

In practice, then, LGPL'd haskell libraries are probably useless for
the stated purpose of supporting closed-source applications. You'd
have to modify the license, or rather find something that fits better.
I'm sure that exists, and chances are the author will be understanding
if you ask.

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


Re: [Haskell-cafe] Linking in Large ByteStrings

2010-01-01 Thread Svein Ove Aas
On Fri, Jan 1, 2010 at 8:11 PM, John Millikin  wrote:
> On Fri, Jan 1, 2010 at 08:49, Svein Ove Aas  wrote:
>> foo.hs
>> ===
>> foreign import ptr bytestring :: Ptr Word8
>> foreign import ptr bytestring_end :: Ptr Word8
>
> Is this valid syntax? I get a syntax error in 6.10.1, and I don't see
> it documented in the FFI report.
>
That's why I called it pseudocode.

No, it's not valid syntax, though it wouldn't have overly surprised me
if it were. You probably get the idea, though; importing a symbol,
instead of a function.

Actually reading the FFi got me this, though:

foreign import ccall "&" bytestring :: Ptr Word8
foreign import ccall "&" bytestring_end :: Ptr Word8


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


Re: [Haskell-cafe] Linking in Large ByteStrings

2010-01-01 Thread Svein Ove Aas
On Fri, Jan 1, 2010 at 4:09 PM, Tom Hawkins  wrote:
> I have a large tarball I want to link into an executable as a
> ByteString.  What is the best way to do this?  I can convert the
> tarball into a haskell file, but I'm afraid ghc would take a long time
> to compile it.  Is there any way to link constant data directly with
> ghc?  If not, what's the most efficient way to code large ByteStrings
> for fast compilation?
>
In the limit, you can convert it to an assembly file.

Something like this, though I've done very little checking indeed of
the syntax. Consider this to be pseudocode.

foo.s


.global bytestring, bytestring_end
.label bytestring
.db 0x0c 0xdf 0xwhatever
.label bytestring_end

foo.hs
===
import Foreign
import Data.ByteString.Internal

foreign import ptr bytestring :: Ptr Word8
foreign import ptr bytestring_end :: Ptr Word8

yourString :: ByteString
yourString = unsafePerformIO $ do
  fptr <- newForeignPtr_ bytestring
  return $ fromForeignPtr (fptr, bytestring_end `minusPtr` bytestring,
0) -- ^ If I got the foreignPtr parameter order right


Unfortunately Data.ByteString.Internal, though still exported, is no
longer haddocked; this makes it hard to check the parameters. You
should go look up the 6.10.1 version's documentation, which is still
correct.

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


Re: [Haskell-cafe] Performance of functional priority queues

2009-12-25 Thread Svein Ove Aas
On Mon, Jun 15, 2009 at 4:18 AM, Richard O'Keefe  wrote:
> There's a current thread in the Erlang mailing list about
> priority queues.  I'm aware of, for example, the Brodal/Okasaki
> paper and the David King paper. I'm also aware of James Cook's
> priority queue package in Hackage, have my own copy of Okasaki's
> book, and have just spent an hour searching the web.
>
> One of the correspondents in that thread claims that it is
> provably impossible to have an efficient priority queue implementation
> without mutability.  I think he's cuckoo.  But I'd like to have some
> numbers to back me up.
>
Regardless of whether he is correct or not, the result would not apply
to haskell.

Lazyness can be considered to be a controlled form of mutation, which
Okasaki takes advantage of in a number of his data structures. Most
(all I've seen) arguments stating that purely functional languages
have asymptotic performance worse than mutating languages simply don't
apply to lazy ones.


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


Re: [Haskell-cafe] Memory-aware Haskell?

2009-12-25 Thread Svein Ove Aas
On Thu, Dec 24, 2009 at 11:38 PM, Roman Cheplyaka  wrote:
> So, let's think what we can do at runtime. Suppose RTS takes the parameter --
> upper limit of consumed memory. When it sees that memory consumption is
> close to upper bound, it can:
>
> 1. force garbage collection
>
This is already implemented. See the -M RTS option.

> 2. apply some heuristics to find and reduce some chunks which will
>   benefit from reduction in terms of size
>
For example, by un-evaluating them. It would often be possible to
reduce size like that, just so long as they aren't evaluated again the
next second. Well, this one would be hard.

> 3. if nothing helps, throw an exeption. It can be caught in IO and
>   memory-aware program can make apropriate decision -- e.g. abort
>   opening a large file and gracefully warn the user.
>
That should be relative simple. Get implementing, will you?:D

> (And there still is a problem of foreign code whose memory consumption
> we know nothing about...)
>
In theory, you could deal with that by hooking malloc.

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


Re: [Haskell-cafe] Does the TMVar and TChan really obey STM rules?

2009-12-24 Thread Svein Ove Aas
On Thu, Dec 24, 2009 at 4:03 PM, Andrey Sisoyev
 wrote:
>
> Hi everyone,
>
>>isEmptyTMVar :: TMVar a -> STM Bool    Source
>>
>>Check whether a given TMVar is empty.
>>
>>Notice that the boolean value returned is just a snapshot
>>of the state of the TMVar. By the time you get to react on its result,
>>the TMVar may have been filled (or emptied) - so be extremely careful
>>when using this operation. Use tryTakeTMVar instead if possible.
>
> When I read this in the haddock to Control.Concurrent.STM.TMVar, I started
> to suspect that the behavior of TMVar and TChan might be worse than I
> imagined.
>
That looks like it was copied and pasted from the MVar documentation.
It's not in the least correct; in fact, TMVar a is implemented as TVar
(Maybe a), so it is just as atomic.

> Few questions on TMVar and TChan:
> (1) If 2 threads are sleeping-waiting for the output of TChan, and it gets
> filled, do they both wakeup, or just one?

You will only see one react. It's just about possible that both in
fact wake, but one will go back to sleep; the abstraction doesn't
leak.

> (2) Similar question about reading/writing TMVar.

Same answer.

> (3) If a thread is sleeping-waiting for the output of TChan, but transaction
> wants to restart due to the change in any of touched TVar, then does the
> thread wakeup and restart the transaction?

If an STM transaction blocks, the runtime keeps track of all cells
(TVars) that have been read until the point in the transaction at
which it called retry, and restarts it - from the beginning - if any
of them change.

This could be optimized. It may even have been optimized. But tose are
the semantics; it'll behave like that's true.

> (4) Similar question about TMVar.
>
It's all implemented by TVars, so all your questions are about those.

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


Re: [Haskell-cafe] inotify-alike for mac os x?

2009-12-04 Thread Svein Ove Aas
On Fri, Dec 4, 2009 at 5:31 PM, Ross Mellgren  wrote:
> kqueue is the "low level" interface, but requires that you handle all file
> system events as they happen, and fast.
>
For the purposes of creating a binding in haskell, my preferred way
would be to use the low-level interface and build saner abstractions
on top of that; it would be trivial to buffer them haskell-side.

That said.. you say you have to handle the events "fast". What happens
if you don't?

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


[Haskell-cafe] ANNOUNCE: haskell-mode 2.7.0

2009-11-30 Thread Svein Ove Aas
Haskell-mode, a major mode for writing Haskell code in Emacs, has been
updated to version 2.7.0.

This release contains mostly bugfixes, but also adds support for hlint
highlighting via flymake.
Additionally, haskell-mode now has a bug-tracker and mailing list.

Mailing list: 
http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs
Bug tracker:  http://trac.haskell.org/haskellmode-emacs/

Unless I am asked not to, minor (N.M.x) releases will only be
announced on the mailing list from now on.

Download location is, as always, http://projects.haskell.org/haskellmode-emacs/


The changelog is as follows:

===
Changes since 2.6.4

* fill-paragraph (M-q) now only affects comments, and correctly
  handles Haddock commentary. adaptive-fill-mode is turned off, as it
  was interfering.

* Yet more unicode symbols

* Better support for unicode encoding of haskell source files

* mdo correctly indented

* Indentation fixes, fixes to the fixes, and fixes to the fixes to the
  fixes

* New command: M-x haskell-check, calls (by default) hlint on the
  current file. Also bound to C-c C-v.

  You can also use the flymake minor mode with this.




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


[Haskell-cafe] Custom cabal languages (hooks?)

2009-11-28 Thread Svein Ove Aas
I'm currently working on a binding to Brian Gladman's C/assembler AES
implementation.

This code is sufficiently small that it makes little sense to create a
separate C library for it; furthermore, it isn't typically packaged by
the various linux distributions, never mind other OSs. As a result,
I'd like to make it part of the cabalized AES package.

This works well enough with the pure-C variant of the implementation,
but it also has assembly-based implementations of the core encryption
routines for x86 and x86_64, specifically using yasm, which I would
like to use when possible.

So, two problems..

- First, I need to make cabal detect yasm's presence, and call out to
it when appropriate. The former I can do with a configure script; the
latter, I'm not quite sure how to do. Currently, cabal can only do C;
basically, I'm looking for a way to let it use any language that can
be compiled to .o files.
- Second, having manually compiled the C/asm bits to .a and .so form,
I did eventually get cabal to link (seemingly) correctly against it,
but it then did not proceed to copy libaes.so into
~/.cabal/lib/AES/ I'm not sure how to make it do that, either. I
suppose I'll have to use hooks, but I'd appreciate a little advice on
how, exactly

Well, I've put a snapshot of my current code at
http://brage.info/~svein/aes/, so you can have a look. I'd really
appreciate the help.

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


Re: [Haskell-cafe] Data.Binary and error handling

2009-11-27 Thread Svein Ove Aas
On Fri, Nov 27, 2009 at 12:00 PM, Alexey Khudyakov
 wrote:
> Hello
>
>  Is there any plans to add error handling for binary? When it comes to
> binary parsing most awkward part is error handling
>
> I presume answer will be like "there are some vague plans but no one
> to implement them" so the second question how could it be done?
>
> Naive implementation of error handliing which converts Get monad into
> hybrid of state monad and error monad (Either like) gives about 5
> times slowdown.
>
There is a Cereal package on Hackage that does exactly that, which may
have better performance characteristics than what you've tried. I
haven't personally benchmarked it.

However, it insists on strict bytestrings everywhere, including as the
return type of encode. This has made it mostly a no-go for me.

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


Re: [Haskell-cafe] Re: haskell-mode.el mailing list (+ dpatch)

2009-11-25 Thread Svein Ove Aas
On Wed, Nov 25, 2009 at 11:37 AM, Jose A. Ortega Ruiz  wrote:
> Svein Ove Aas  writes:
>
>> Well, I know when I'm beat..
>>
>> http://trac.haskell.org/haskellmode-emacs/
>>
>> http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs
>
> Excellent! Thanks. Any objection to my adding the list to gmane.org?
>
I certainly don't mind.

I've noticed that the list administrative interface has a news-gateway
option. Is there anything I should do there?

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


Re: [Haskell-cafe] haskell-mode.el mailing list (+ dpatch)

2009-11-25 Thread Svein Ove Aas
On Wed, Nov 25, 2009 at 9:21 AM, Bas van Dijk  wrote:
> On Wed, Nov 25, 2009 at 12:06 AM, Valery V. Vorotyntsev
>  wrote:
>> Is there anybody except me feeling the need for mailing list and issue
>> tracker for emacs' haskell-mode?
>
> +1
>
> Since there already is a haskellmode-emacs project on the
> http://community.haskell.org server we can start a mailing list and
> issue tracker easily:
>
Well, I know when I'm beat..

http://trac.haskell.org/haskellmode-emacs/

http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs

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


Re: [Haskell-cafe] haskell code from hi

2009-11-22 Thread Svein Ove Aas
On Sun, Nov 22, 2009 at 1:04 AM, Uwe Hollerbach  wrote:
> Ouch... my condolences, but I think you're screwed. I think the .hi
> files are purely interface info, and the .o files have all the info on
> what to actually do (and getting to .hs files from .hi+.o is gonna be
> like going from sausage to pig, in any case). If you haven't messed
> with the disk, I think your best bet might be to try and undelete
> files. That might be as messy as looking at the raw disk image and
> trying to recover disk sectors, or possibly there are still entire
> files there that are just not referenced by directory entries. Either
> (or any) way, it's a bit chancy...
>
And this why you always, *always* use a revision-control system or at
least good backups.

.hi files actually do contain some code, specifically what ghc decides
can be inlined (see ghc --show-iface), but it's not the sort of code
you'd get any use from. Have a look, you'll see.

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


Re: [Haskell-cafe] What's wrong with code.haskell.org ?

2009-11-22 Thread Svein Ove Aas
On Sun, Nov 22, 2009 at 4:39 AM, John Millikin  wrote:
> code.h.o and community.h.o have rather flaky hosting, and have been
> going down often recently. The only solution seems to be waiting until
> the admins notice.
>
They have hardware problems - dying HDs and such.

IIRC there were plans to replace the problematic hardware, but I don't
know how far that has gotten. Maybe we should have a fundraiser for
the purpose?

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


Re: [Haskell-cafe] pthread_kill missing?

2009-11-18 Thread Svein Ove Aas
On Wed, Nov 18, 2009 at 2:03 PM, Gabor Greif  wrote:
> PS: I guess some of you will say, "use condition variables".
> But that won't answer my question :-)
>
Actually, I was going to say "use throwTo".

Is there som reason you have to use the POSIX routines directly
instead of using native haskell exceptions?


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


Re: [Haskell-cafe] Static Linking Problem

2009-11-12 Thread Svein Ove Aas
On Thu, Nov 12, 2009 at 8:57 AM, David Virebayre
 wrote:
> On Wed, Nov 11, 2009 at 5:44 PM, Svein Ove Aas  wrote:
>
>> My recommendation would be to take glibc off the list of statically
>> linked libraries.
>
> How do you do that ?
>
By specifying the entire list manually, and not naming glibc.

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


Re: [Haskell-cafe] Static Linking Problem

2009-11-11 Thread Svein Ove Aas
On Wed, Nov 11, 2009 at 3:22 PM, MightyByte  wrote:
>
> (.text+0x3068): warning: Using 'getaddrinfo' in statically linked
> applications requires at runtime the shared libraries from the glibc
> version used for linking
>
> But glibc is pretty standard, so I don't think this will be a problem
> for me.  Thanks for the help.
>
You may have unexpected results.

That warning occurs because some of glibc (namely, the getaddrinfo
bit) is dynamically linked regardless of what you want; this is
apparently to make NSS work, or something along those lines.

However, if you then link the rest of glibc statically, you get
dependencies between your program and the installed glibc, for
internal, unstable APIs. (!)

This is generally a Big No. Doing this means your program definitely
won't be compatible with older versions of glibc, but it probably
wouldn't be either way. However, in this case it also won't be
compatible with *newer* versions of glibc.

My recommendation would be to take glibc off the list of statically
linked libraries.


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


Re: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..)

2009-11-11 Thread Svein Ove Aas
On Wed, Nov 11, 2009 at 12:58 PM, Tillmann Vogt
 wrote:
> Hi,
>
> I tried to use unboxed arrays for generating an antialiased texture. To make
> it easier to understand, here is the stripped down code that produces an
> error:
>
*snip*
>
> What do you think?
>
It is generally acknowledged that the array types bundled with GHC
have serious shortcomings, such as for example the one you just
pointed out. There is not, however, a consensus on how to change them.

To solve your particular problem, I would suggest looking up the
storablevector package on Hackage, which I know can handle arbitrary
unboxed elements.

That said, I'm sure someone will be along shortly to give you the full
story. :-)


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


Re: [Haskell-cafe] filter using foldr point-free?

2009-11-10 Thread Svein Ove Aas
On Tue, Nov 10, 2009 at 12:47 PM, damodar kulkarni
 wrote:
> Hi,
> We can define filter using foldr as under:
>
> filter1 p = foldr (\x xs -> (if (p x) then (x:xs) else xs))  []
>
> Can we define filter using foldr but in pointfree style?
>
Pointfree code is (nearly) always possible, but sometimes not very
desirable. The first thing to do is to ask lambdabot for help; in this
case, the answer is.. this:

filter1 =  flip foldr [] . flip flip id . (ap .) . (`ap` (:)) . (((.) . if') .)

if' p a b = if p then a else b


Now, there may be a better way to go about this, but I don't think I'd
bother trying. The pointful variant seems quite readable as-is. :P

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


Re: [Haskell-cafe] Is () a 0-length tuple?

2009-11-08 Thread Svein Ove Aas
On Sun, Nov 8, 2009 at 9:52 AM, Ketil Malde  wrote:
> Eugene Kirpichov  writes:
>
>>> In JavaScript there is a "null" value, that is the only value of the null 
>>> type.
>>> Isn't () the same thing?  The only value of the unary type?
>
>> No, () has two values: () and undefined (t.i., _|_).
>
How should I put it..?
undefined is bottom, but bottom is not undefined?

There are plenty of other constructions that are bottom. Infinite
loops, throws, errors.. common for all of them, of course, is that you
can't pattern-match on them or otherwise use them in pure code, and
they generally don't act like values.

So, can't we just say that () has a single value, namely ()? It'd make
this much simpler, and we won't have to deal with the Nihil monoid.

==

data Nihil

instance Monoid Nihil where
  mappend _ _ = undefined

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


Re: [Haskell-cafe] Haskell Weekly News: Issue 138 - November 07, 2009

2009-11-07 Thread Svein Ove Aas
On Sat, Nov 7, 2009 at 10:48 AM, Felipe Lessa  wrote:
> On Fri, Nov 06, 2009 at 10:04:45PM -0800, jfred...@gmail.com wrote:
>>      * mauke: @unpl const (flip const)
>>        lambdabot: (\ _ c d -> d)
>
> I didn't get this one, is it just because lambdabot didn't change
> 'c' to an underscore?
>
We were experimenting with @pl and yes, that's part of it, but it's
also that it skipped a entirely in this case.

Just struck me as weird.

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


[Haskell-cafe] Re: ANN: haskell-mode 2.6

2009-11-03 Thread Svein Ove Aas
On Sun, Nov 1, 2009 at 8:20 PM, Svein Ove Aas  wrote:
> Fellow haskellers:
>
> Haskell-mode 2.6 has been released.
>
2.6.2 is now out.

This is a pure bugfix release; it fixes some parse issues in
haskell-decl-scan and haskell-indentation.


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


Re: [Haskell-cafe] Re: ANN: haskell-mode 2.6

2009-11-02 Thread Svein Ove Aas
On Mon, Nov 2, 2009 at 4:18 PM, Svein Ove Aas  wrote:
>
> I'm going to try teaching it. Hopefully I won't break anything in the process.
>
I have so taught.

If you grab the latest darcs version, it should work. However, I won't
be releasing this without further testing, so if you do - caveat
emptor.


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


Re: [Haskell-cafe] Re: ANN: haskell-mode 2.6

2009-11-02 Thread Svein Ove Aas
On Mon, Nov 2, 2009 at 1:18 PM, Dan Doel  wrote:
> On Sunday 01 November 2009 4:45:58 pm Svein Ove Aas wrote:
>> On Sun, Nov 1, 2009 at 8:20 PM, Svein Ove Aas  wrote:
>> > Fellow haskellers:
>> >
>> > Haskell-mode 2.6 has been released.
>>
>> Make that 2.6.1. Naturally, I broke something, but I think I'm about
>> out of things to break now.
>
> As it happens, the haskell-indentation mode (the new one) doesn't like
> hierarchical modules names. Something like:
>
>  module Foo.Bar (\n
>
> will begin at the beginning of the line, complaining about there being an
> operator (the '.').
>
> Though you may not have broken it. :) I can't recall if that happened
> previously or not.
>
What seems to be going on is that haskell-indentation simply isn't
prepared to deal with hierarchical module names at all, or qualified
imports.

The latter works because it interprets "Foo.bar" as actually using the
operator (.), which it considers to be valid syntax. Operators are not
valid in module statements, however.

I'm going to try teaching it. Hopefully I won't break anything in the process.

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


[Haskell-cafe] Re: ANN: haskell-mode 2.6

2009-11-01 Thread Svein Ove Aas
On Sun, Nov 1, 2009 at 8:20 PM, Svein Ove Aas  wrote:
> Fellow haskellers:
>
> Haskell-mode 2.6 has been released.
>
> * By web: http://projects.haskell.org/haskellmode-emacs/
> * By darcs: http://code.haskell.org/haskellmode-emacs/
>
Since there appears to be some confusion:

Indentation is now /off by default/. This is because there are several
indentation modules, and I don't want to force people to use a
particular one.

If you want indentation, read the README; it explains how to turn it on.


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


Re: [Haskell-cafe] hSeek in Windows

2009-11-01 Thread Svein Ove Aas
On Sun, Nov 1, 2009 at 9:44 PM, Philippos Apolinarius  wrote:
> To make a long story short, the program compiles, but does not run. This is 
> interesting, because when Clean compiles an input/output operation it 
> certainly executes it. In any case, what I should do in order to make file 
> operations work on Windows? I need random access to text files.
>
The reason it fails to run is because, on windows, there isn't a
one-to-one mapping between characters and bytes on text files. You
have to use binary mode, in which case you're likely to see doubled
newlines - \r\n, or the other way around, I don't remember.

Which brings up the interesting question of how this works in 6.12,
which has text support for modes that are 1:N on /all/ platforms; e.g.
UTF-8. If hSeek works there, then chances are it'll work in text mode
on windows as well.

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


[Haskell-cafe] Re: ANN: haskell-mode 2.6

2009-11-01 Thread Svein Ove Aas
On Sun, Nov 1, 2009 at 8:20 PM, Svein Ove Aas  wrote:
> Fellow haskellers:
>
> Haskell-mode 2.6 has been released.
>
Make that 2.6.1. Naturally, I broke something, but I think I'm about
out of things to break now.

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


[Haskell-cafe] ANN: haskell-mode 2.6

2009-11-01 Thread Svein Ove Aas
Fellow haskellers:

Haskell-mode 2.6 has been released.

* By web: http://projects.haskell.org/haskellmode-emacs/
* By darcs: http://code.haskell.org/haskellmode-emacs/

This is mainly a bugfix release; to anyone using
haskell-indentation, the big news will be that it no longer
under some circumstances hands you a parse error and
refuses to insert a newline, or backspace.

It still gives you a parse error. It just tries its best to proceed
anyway.


There are also some new features, courtesy of Alex Ott:
More font-lock symbols, and a hayoo function.

In the case of the font-lock symbols, your mileage may vary
on how nice the picked ones are. Mine certainly does. As such,
I'm announcing open season on font-lock symbols: Comment
to your heart's desire, and I'll use whatever you decide on for
the next official release.

The tab-cycle implementation is thanks to ivanm, whose random
comments can trigger hours and hours of work.


I'll just quote from the NEWS file now:

===

Changes since 2.5.1

* haskell-indentation: Pressing tab in the rightmost position now
  moves to the leftmost, by default with a warning.

* Typo fix: One haskell-indentation variable had ended up in the
  haskell-ntation customize group.

* haskell-hoogle aliased to hoogle, haskell-hayoo aliased to hayoo

* Courtesy of Alex Ott:
  - Additional unicode symbols for font-lock-symbols: () == /= >= <=
!! && || sqrt
  - M-x haskell-hayoo search added, opens using browse-url
  - Bug-fix for inferior-haskell-type

* If haskell-indentation errors out, it now fail-safes to inserting
  a literal newline or deleting one character, for return and
  backspace respectively.


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


Re: [Haskell-cafe] simple parsing

2009-10-27 Thread Svein Ove Aas
On Tue, Oct 27, 2009 at 11:38 PM, satorisanitarium
 wrote:
> I'm trying to parse a list of numbers plus four diferent signs (+-*/)
> in this way:
>
*snip*
> I suspect my approach is flawed but i have exausted my ideas.
> I need  a fresh approach so if anybody would be kind enough and just
> give me a hint how to approach the problem.
>
To begin with, try using the Parsec parser-combinator library instead
of writing your own from scratch?


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


Re: [Haskell-cafe] ANN: haskell-mode 2.5

2009-10-27 Thread Svein Ove Aas
On Tue, Oct 27, 2009 at 8:31 PM, Colin Paul Adams
 wrote:
>>>>>> "Svein" == Svein Ove Aas  writes:
>
>    Svein> Known bugs: * Occasionally, the haskell-indentation parser
>    Svein> will get stuck   on what it considers to be invalid haskell
>
> Quite often.
>
>    Svein> code, and refuse to accept your commands; this includes,
>    Svein> mainly, haskell-newline-and-indent. To avoid annoyance, if
>    Svein> you bind RET to haskell-newline-and-indent, you should bind
>
> I don't, but haskell-indentation.el does.
>
>    Svein> M-RET to plain newline.
>
> So perhaps the mode should also do this? here's a patch:
>
Thanks, but I've already got a (slightly hacky) solution to the
problem, namely catching the errors and bypassing the indenter in this
case - grab the darcs version if you're impatient.

I'll put it together with the various other patches and bug reports
I've been sent (thanks for those, guys!), and have a 2.5.2 out by
sunday.

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


Re: Re[2]: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-27 Thread Svein Ove Aas
On Tue, Oct 27, 2009 at 7:07 PM, Bulat Ziganshin
 wrote:
> Hello Kim-Ee,
>
> Tuesday, October 27, 2009, 8:08:27 PM, you wrote:
>
>> Just for completeness' sake, bottom is a value for any expression.
>> Wouldn't making the else clause optional by defaulting to "undefined"
>> worthy of consideration for Evil Haskell?
>
> in this case you will get an exception when condition is false (when
> 'if' used in expression)
>
Yes, that's why it's evil.

Or.. I know!

ifWithoutElse :: a -> Bool -> Maybe a

(Wait...)
-- 
Svein Ove Aas
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A 3 line program. Preprocessor?

2009-10-27 Thread Svein Ove Aas
On Tue, Oct 27, 2009 at 3:57 PM, Philippos Apolinarius
 wrote:
>
> In a private email to Ketil Malde, I said that Ocaml programmers use the 
> preprocessor to solve the problem of character encoding:
>
> ocamlopt -pp myfilter.exe myprogram.ml -o myoutput.exe
>
> I wonder whether a similar solution could be used with Haskell. I am new to 
> Haskell, but I suppose that Haskell may accept something like
>
> ghc -pgmF myfilter.exe myprogram.hs --make
>
> If the answer is yes, what should I substitute for myfilter.exe?
>
Converting a non-utf-8 input file to utf-8?

There's no obvious reason it shouldn't work, and you could use recode
for the filter.

However, wouldn't it be much better to just generate utf-8 in the
first place? I find it hard to believe that it's really as hard as all
that.


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


[Haskell-cafe] Re: ANN: haskell-mode 2.5

2009-10-25 Thread Svein Ove Aas
On Sun, Oct 25, 2009 at 4:14 PM, Svein Ove Aas  wrote:
> Fellow Haskellers,
>
> I'm happy to announce the release of haskell-mode 2.5.
>
> * By web: http://projects.haskell.org/haskellmode-emacs/
> * By darcs: http://code.haskell.org/haskellmode-emacs/
>
Make that 2.5.1. There were some niggling remaining issues that should
now be fixed.

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


Re: [Haskell-cafe] ANN: haskell-mode 2.5

2009-10-25 Thread Svein Ove Aas
On Sun, Oct 25, 2009 at 5:34 PM, Paulo Tanimoto  wrote:
> I updated the Wiki entry:
>
>  http://haskell.org/haskellwiki/Haskell_mode_for_Emacs
>
> with your name and download links.  Can you check if it's OK?  I
> wasn't sure which of your email addresses to use.  On a side note,
> that page looks so messy.  : )
>
It looks fine, ignoring the mess. :P

While you're at it, you might want to copy the "minimal setup" from
what is described in the README, i.e. including the indentation setup.
Or not, if you wish; I'll leave that to your judgement.


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


[Haskell-cafe] ANN: haskell-mode 2.5

2009-10-25 Thread Svein Ove Aas
Fellow Haskellers,

I'm happy to announce the release of haskell-mode 2.5.

* By web: http://projects.haskell.org/haskellmode-emacs/
* By darcs: http://code.haskell.org/haskellmode-emacs/

Furthermore, there is a change of maintainer; if you have
issues, you should now contact me instead of Stefan Monnier.


haskell-mode 2.5
=

I was uncertain whether to mark this a minor or major release.

On the one hand, very little has changed in core functionality.
On the other, a new minor mode for indentation has been added:
haskell-indentation.el, written by Kristof Bastiaensen.

It will be familiar to those of you who have been tracking the CVS
repository; there are only minor bug-fixes relative to the last
version to be uploaded there.

For the rest of you:

haskell-indentation.el is an intelligent indentation mode in the
style of haskell-indent.el, with a few changes to improve
usability. Specifically, instead of a tab cycle, backspace is now
used to reduce the nesting level, while tab will increase it.

The behaviour is otherwise substantially the same; only valid
nestings will be considered.

It can be turned on by adding
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
to your .emacs file, as described in the README. As usual,
it is mutually exclusive with the two other indentation modes.

Known bugs:
* Occasionally, the haskell-indentation parser will get stuck
  on what it considers to be invalid haskell code, and refuse
  to accept your commands; this includes, mainly,
  haskell-newline-and-indent. To avoid annoyance, if you bind
  RET to haskell-newline-and-indent, you should bind M-RET
  to plain newline.

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


Re: [Haskell-cafe] Re: cvs.haskell.org down? haskell-mode abandoned?

2009-10-22 Thread Svein Ove Aas
On Thu, Oct 22, 2009 at 9:02 PM, Stefan Monnier
 wrote:
> Can you show me the patches?
>
Sure, once cvs.haskell.org comes back up. :P

It's mostly newer variants of haskell-indentation.el, with a little
homegrown code. Well, you can see what I'm currently running at
http://brage.info/~svein/haskell-mode/; the other stuff is all the
same as what's in CVS.

I think.


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


Re: [Haskell-cafe] Re: cvs.haskell.org down? haskell-mode abandoned?

2009-10-20 Thread Svein Ove Aas
On Tue, Oct 20, 2009 at 4:22 PM, Stefan Monnier
 wrote:
>> In any case, I need it fixed before I can work on haskell-mode.
>> Preferably by migrating haskell-mode over to cvs. :-)
>
> You mean migrating to DaRCS?  That would be appreciated, yes.
>
Um, yes.

I can get the revision history into darcs pretty easily, such as it
is, assuming cvs.haskell.org comes back up. Then I'll put the
repository somewhere you can get at it. That fine?

>> who *is* the current maintainer?
>
> Last I heard, it was me.  But if someone wants to take over,
> he's welcome.
>
You're saying you don't have time to maintain it?

I'd like to say I could take over, but really, I'm not familiar enough
with either elisp or haskell-mode to do that, and I don't currently
have the time to familiarize myself with it either, so I know how that
is.

Still, there needs to be a new release, and I've got a lot of improved
haskell-mode code (written by other people) that isn't currently in
the repository. I can handle that much, if nobody else steps up.

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


[Haskell-cafe] cvs.haskell.org down? haskell-mode abandoned?

2009-10-20 Thread Svein Ove Aas
Attempting to update haskell-mode, I've been getting authorization
failures from the cvs.haskell.org pserver.

I thought this might have some connection to the recent disk crash,
and as nobody uses cvs anymore, it could have been overlooked.

In any case, I need it fixed before I can work on haskell-mode.
Preferably by migrating haskell-mode over to cvs. :-)


On a different note, I've been unable to contact the apparent current
maintainer of haskell-mode, while in a state of having a useful patch.
Though it may already have made it to cvs, with me simply being unable
to check that.. actually, who *is* the current maintainer? The last
release was Dec. 2007.

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


Re: [Haskell-cafe] Haskell-tan competition

2009-10-13 Thread Svein Ove Aas
On Tue, Oct 13, 2009 at 1:12 PM, Ariel J. Birnbaum  wrote:
>> What about Lambdabot?
>
> The official (?) personification of Lambdabot is OK, but lacks moe[1],
> which the OP seems to intend by using the suffix '-tan'. In any case,
> she represents Lambdabot only, not Haskell in general.
>
A lambdabot-specific personification is fine too, but I agree that it
lacks charm.

Though I wonder, where should we put these?
Having the lambdabot one on the lambdabot page is fine, but
haskell-tan would have to be stuck on the front page. Which seems a
bit too much.

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


Re: [Haskell-cafe] Haskell-tan competition

2009-10-11 Thread Svein Ove Aas
On Sun, Oct 11, 2009 at 5:58 PM, Paul Johnson  wrote:
> What about Lambdabot?
>
You're welcome to draw one for her. :-)

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


[Haskell-cafe] Haskell-tan competition

2009-10-10 Thread Svein Ove Aas
I say "competition", but.. at the moment I'm only aware of a single
Haskell-tan, namely the one at
http://www.reddit.com/r/programming/comments/9ss7n/haskell%E3%82%BF%E3%83%B3_%E7%B5%B5/.

This cannot stand. Haskell needs an anthropomorphized personification,
like any other modern language. Anyway, have any of you seen any
others?

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


Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Svein Ove Aas
As a general sort of warning, do not use hGetContents (or lazy i/o, in
general) in combination with withFile.

withFile closes the handle when the program lexically exits its scope.
However, when using hGetContents, the file contents will not be read
until after you do this, and will therefore fail to be read at all;
I'm not sure whether this will produce a truncated string or an
exception.

Instead, use openFile directly. Handles have (ISTR) finalizers on
them, and so should be automatically closed if you lose hold of one..
eventually. getContents of course closes it once it hits EOF, but that
isn't exactly reliable.

If that isn't satisfactory, use strict I/O. It's less convenient, but
it's also easier to reason about.

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


Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Svein Ove Aas
I have a number of suggestions, some of which conflict with each
other, so I'll just throw them out here. Let's see..

First off, the IO monad does indeed enforce sequencing; that's its
primary purpose. However, you can ask for it to run I/O out of order,
specifically when the value the out-of-order action returns is
actually forced (used); that's lazy I/O, and is implemented using
unsafeInterleaveIO.

You would not usually use unsafeInterleaveIO directly, though.
Instead, you'd use an existing wrapper, such as hGetContents. (for
Strings, or lazy bytestrings; the strict bytestring variant reasonably
has a strict semantics)

One thing to keep in mind about lazy I/O is that the I/O in question
can run at any arbitrary time, or not at all; not more than once,
though. You must make sure this is safe. For file input, that
basically means the file should not change during the program's
lifetime.

hGetLine is not lazy in this way, but the hGetContents you use is. I'm
not sure whether this means your program should work as-is, and I'm
not going to examine it closely enough to tell - as you mentioned it's
a mockup anyway. Besides..

Strings are also *slow*. What you want for I/O is, when reasonably
possible, bytestrings. You'd then use parsec-bytestring, or if
possible Data.Binary, to parse said bytestring; the latter is faster
(..probably), if more limited in function.

You could use the lazy bytestring hGetContents for this. However...

There is also a bytestring-mmap package on hackage, which outsources
the decision of what blocks to load into memory to the OS, and has the
best performance overall. Use this.


Oh. And unsafePerformIO is a trap that will kill you. See
http://www.girlgeniusonline.com/comic.php?date=20070725 for details.

On Tue, Sep 15, 2009 at 8:36 PM, Cristiano Paris
 wrote:
> Hi Cafè,
>
> I've the following problem: I have a (possibly very long) list of
> files on disk. Each file contains some metadata at the beginning and
> continues with a (possibly very large) chunk of data.
>
> Now, the program I'm writing can be run in two modes: either read a
> specific file from the disk and show the whole chunk of data on
> screen, or read all the files' metadata, sort the file list based on
> the metadata, and display a summary of those without reading the chunk
> of data from each file. I've factored out the file access machinery in
> a single module so as to use it indifferently under the two scenarios.
>
> At first, I wrote a piece of code which, in spirit, works like the
> following reduced case:
>
> --
> module Main where
>
> import System.IO
> import Control.Applicative
> import Data.List
> import Data.Ord
>
> import Debug.Trace
>
> data Bit = Bit { index :: Integer, body :: String }
>
> readBit fn = withFile fn ReadMode $ \h -> Bit <$> (hGetLine h >>=
> return . read) <*> readBody
>             where readBody = withFile fn ReadMode $ \h -> do b <-
> hGetContents h
>                                                              seq b $
> trace ("Read body from: " ++ fn) $ return b
>
> main = do bl <- mapM readBit ["file1.txt","file2.txt"]
>          mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl
> 
>
> which is very expressive as it's written in applicative style.
>
> Each file is like the following:
>
>  file1.txt 
> 1
> foo
> 
>
> I've created a separate IO action for reading the body in the hope
> that it wouldn't get executed when the file list is sorted. But, to my
> surprise, it didn't work as the trace message gets written for each
> file before the summary is displayed.
>
> Thinking about this, I came to the conclusion that the IO Monad is
> enforcing proper IO ordering so that the IO action for file1's body
> must be executed right before IO action for file2's index one.
>
> If this is true, the only solution that came into my mind was to wrap
> the IO action for reading the body in an unsafePerformIO call. I
> actually ran the program with this modification and it works properly.
>
> So, as using unsafePerformIO is a Great Evil (TM), I'm wondering if
> there's a different way to do this which doesn't rely on retyping body
> as an IO action returning a String, which would break my pure code
> manipulating the files.
>
> My opinion is that using unsafePerformIO here is like ensuring the
> compiler that there're no observable side effects in running the IO
> action for reading the body and that no other side effects would
> impact this IO action.
>
> Thank you for any thoughts.
>
> Cristiano
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



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


Re: [Haskell-cafe] Alternative to Data.Binary

2009-03-14 Thread Svein Ove Aas
On Sat, Mar 14, 2009 at 1:37 PM, Grzegorz Chrupala
 wrote:
>
> Hi all,
> Is there a serialization library other than the Data.Binary from hackage?
>
> I am using Data.Binary in a couple of projects, but I have found its stack
> and memory usage very hard to control. Its very common that decoding a map
> or list of non-trivial size uses up all available RAM, or causes a stack
> overflow.
>
That little problem appears to be an artifact of the particular Binary
instance for lists (the map instance starts by converting to/from a
list), and should be fixable in principle, for example by writing them
in chunks of 256 elements.

That said, the current instance really should only have problems when
*writing*, in that it'll force the entire list to figure out its
length before it starts writing any of it. That this is not, in fact,
the case suggests that the reader should be fixable without changing
its on-disk format.

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


Re: [Haskell-cafe] View patterns and warnings about overlapping or non-exhaustive patterns

2009-03-11 Thread Svein Ove Aas
On Wed, Mar 11, 2009 at 5:22 PM, Stephan Friedrichs
 wrote:
> Hi,
>
> I'm working on a data structure that uses Data.Sequence a lot, so views
> are important and I tried to simplify my code using view patterns.
>
> The problem is, that I keep getting warnings about both overlapping and
> non-exhaustive pattern matches. A simple test case:
>
The view pattern implementation is currently incomplete, specifically
in that it is unable to decide whether a pattern match using them is
overlapping or non-exhaustive. Arguably the warnings should be
suppressed instead..

For the time being, it will *work*, you just won't get useful
warnings. Hopefully it's going to be fixed for 10.2.

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


Re: [Haskell-cafe] Mystified by Cabal

2009-03-08 Thread Svein Ove Aas
On Sun, Mar 8, 2009 at 12:32 PM, Duncan Coutts
 wrote:
> Note also that the list of licenses mkcabal offers is wrong. You can get
> the list from the Cabal lib itself so there is no need to maintain the
> list manually.
>
It would also be nice to expand that list somewhat, to at least cover
the most used licences - GPL2, GPL3, AGPL, etc.

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


Re: [Haskell-cafe] Mystified by Cabal

2009-03-07 Thread Svein Ove Aas
On Sat, Mar 7, 2009 at 6:18 PM, Colin Paul Adams
 wrote:
> I have just attempted Cabal-izing my program (splitting it into a
> library and main program as well), and I'm mystified by some problems
> I am having.
>
> First, when I try to build the library I get:
>
> [co...@susannah game-tree]$ runhaskell Setup build
> Preprocessing library game-tree-1.0.0.0...
> Building game-tree-1.0.0.0...
>
> Data/Tree/Game/Negascout.hs:31:0: Unrecognised pragma
> [1 of 2] Compiling Data.Tree.Game.Tree ( Data/Tree/Game/Tree.hs, 
> dist/build/Data/Tree/Game/Tree.o )
>
> Data/Tree/Game/Tree.hs:1:0:
>    Failed to load interface for `Prelude':
>      it is a member of package base-3.0.3.0, which is hidden
>
What does your .cabal file look like?


>
> Perhaps Cabal should be named Caballa instead.
>
Nah, it's not /that/ bad. :P

You might want to install the mkcabal package, use that to generate
the initial .cabal file. Though I'm not sure what you might have
gotten wrong.. well, show us the file first.

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


Re: [Haskell-cafe] Re: [Haskell] Lazy IO breaks purity

2009-03-05 Thread Svein Ove Aas
On Thu, Mar 5, 2009 at 2:08 PM, Simon Marlow  wrote:
>
> So the argument is something like: we can think of the result of a call to
> unsafeInterleaveIO as having been chosen at the time we called
> unsafeInterleaveIO, rather than when its result is actually evaluated. This
> is on dodgy ground, IMO: either you admit that the IO monad contains an
> Oracle, or you admit it can time-travel.   I don't believe in either of
> those things :-)
>
As it turns out, time-travel as a vehicle for computation has a long
tradition in the more advanced systems; see
http://www.frc.ri.cmu.edu/~hpm/project.archive/general.articles/1991/TempComp.html
for an example.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] Threading and Mullticore Computation

2009-03-03 Thread Svein Ove Aas
So, apparently the 6.10.1 code runs amiss of this bug:
http://hackage.haskell.org/trac/ghc/ticket/2747

I'll be upgrading to HEAD now. If no-one else gets around to it first,
I'll probably post some more benchmarks afterwards.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Threading and Mullticore Computation

2009-03-03 Thread Svein Ove Aas
I feel the need to point something out here.

Both for me and Andrew, the program tops out at allocating ~22MB of
memory - in total, over its whole run.

Why, then, is max heap size over a gigabyte?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Threading and Mullticore Computation

2009-03-03 Thread Svein Ove Aas
On Tue, Mar 3, 2009 at 6:54 PM,   wrote:
> I am using GHC 6.8.3. The -O2 option made both runs faster but the 2 core run
> is still much slower that the 1 core version. Will switching to 6.10 make the 
> difference?
>
There are a lot of improvements; it's certainly worth a try.

For what it's worth, I tried it myself on 6.10.. details follow, but
overall impression is that while you lose some time to overhead, it's
still 50% faster than unthreaded.

While trying to optimize it, I ran "./test +RTS -N2 -H64m -M64m"; the
program promptly ate all my memory, invoking the OOM killer and
messing up my system something fierce. This has to be a bug.

GC time only accounts for 10% of the time used, but as I read these,
the parallell GC didn't do any good.

..I'm stumped.

 time ./test +RTS -N1 -s 
"Task1 done!"
"Task2 done!"
57500
  22,712,520 bytes allocated in the heap
   2,982,440 bytes copied during GC
   1,983,288 bytes maximum residency (2 sample(s))
  30,208 bytes maximum slop
 636 MB total memory in use (58 MB lost due to fragmentation)

  Generation 0:42 collections, 0 parallel,  0.12s,  0.13s elapsed
  Generation 1: 2 collections, 0 parallel,  0.00s,  0.01s elapsed

  Task  0 (worker) :  MUT time:   2.85s  (  6.09s elapsed)
  GC  time:   0.07s  (  0.08s elapsed)

  Task  1 (worker) :  MUT time:   0.00s  (  6.09s elapsed)
  GC  time:   0.00s  (  0.00s elapsed)

  Task  2 (worker) :  MUT time:   2.66s  (  6.09s elapsed)
  GC  time:   0.05s  (  0.06s elapsed)

  INIT  time0.00s  (  0.00s elapsed)
  MUT   time4.78s  (  6.09s elapsed)
  GCtime0.12s  (  0.14s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time4.81s  (  6.23s elapsed)

  %GC time   2.5%  (2.3% elapsed)

  Alloc rate4,842,754 bytes per MUT second

  Productivity  97.5% of total user, 75.3% of total elapsed

recordMutableGen_sync: 0
gc_alloc_block_sync: 0
whitehole_spin: 0
gen[0].steps[0].sync_todo: 0
gen[0].steps[0].sync_large_objects: 0
gen[0].steps[1].sync_todo: 0
gen[0].steps[1].sync_large_objects: 0
gen[1].steps[0].sync_todo: 0
gen[1].steps[0].sync_large_objects: 0

real0m6.319s
user0m4.810s
sys 0m0.920s


 time ./test +RTS -N2 -s 
"Task2 done!"
"Task1 done!"
68600
  22,734,040 bytes allocated in the heap
   2,926,160 bytes copied during GC
   1,976,240 bytes maximum residency (2 sample(s))
 117,584 bytes maximum slop
1234 MB total memory in use (107 MB lost due to fragmentation)

  Generation 0:32 collections,13 parallel,  0.47s,  0.43s elapsed
  Generation 1: 2 collections, 0 parallel,  0.01s,  0.01s elapsed

  Parallel GC work balance: 1.00 (4188 / 4188, ideal 2)

  Task  0 (worker) :  MUT time:   0.00s  (  0.00s elapsed)
  GC  time:   0.00s  (  0.00s elapsed)

  Task  1 (worker) :  MUT time:   0.00s  (  0.00s elapsed)
  GC  time:   0.00s  (  0.00s elapsed)

  Task  2 (worker) :  MUT time:   3.10s  (  3.82s elapsed)
  GC  time:   0.09s  (  0.05s elapsed)

  Task  3 (worker) :  MUT time:   2.96s  (  3.82s elapsed)
  GC  time:   0.39s  (  0.39s elapsed)

  Task  4 (worker) :  MUT time:   0.00s  (  3.82s elapsed)
  GC  time:   0.00s  (  0.00s elapsed)

  INIT  time0.00s  (  0.00s elapsed)
  MUT   time5.23s  (  3.82s elapsed)
  GCtime0.48s  (  0.44s elapsed)
  EXIT  time0.01s  (  0.00s elapsed)
  Total time5.72s  (  4.26s elapsed)

  %GC time   8.4%  (10.4% elapsed)

  Alloc rate4,338,557 bytes per MUT second

  Productivity  91.6% of total user, 123.0% of total elapsed

recordMutableGen_sync: 0
gc_alloc_block_sync: 0
whitehole_spin: 0
gen[0].steps[0].sync_todo: 0
gen[0].steps[0].sync_large_objects: 0
gen[0].steps[1].sync_todo: 0
gen[0].steps[1].sync_large_objects: 0
gen[1].steps[0].sync_todo: 0
gen[1].steps[0].sync_large_objects: 0

real0m4.345s
user0m5.680s
sys 0m1.250s
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Threading and Mullticore Computation

2009-03-03 Thread Svein Ove Aas
On Tue, Mar 3, 2009 at 6:41 PM, Don Stewart  wrote:
> allbery:
>> On 2009 Mar 3, at 12:31, mwin...@brocku.ca wrote:
>>> In both runs the same computations are done (sequentially resp.
>>> parallel), so the gc should be the same. But still using 2 cores is
>>> much slower than using 1 core (same program - no communication).
>>
>> The same GCs are done, but GC has to be done on a single core
>> (currently; parallel GC is in development) so you will see a lot more
>> lock contention when the GC kicks in.
>>
>
> Assuming he is using GHC 6.10, the parallel GC is enabled by default
> when you use -Nn where n > 1. That's is -N4 will use -g4   (4 cores to
> collect). So GC should be the same or a little faster.
>
Further, GHC (6.10 at least) uses one allocation area per thread,
meaning there's no contention on allocation.

I'd echo the request to try it with -O2, though.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Supplying a default implementation for a typeclass based on another class

2009-03-01 Thread Svein Ove Aas
On Sun, Mar 1, 2009 at 6:42 PM, Martin Huschenbett  wrote:
> Hi,
>
> you could do something like
>
>> instance (Show a,Read a) => Binary a where
>>  put = put . show
>>  get = fmap read get
>
> But then you will need the following language extensions: FlexibleInstances,
> OverlappingInstances, UndecidableInstances
>
Well, isn't there a good chance it'll end up picking that instance
even when a more specific one is available, then?

I think the problem here is that I don't know of any way to inform GHC
that any particular instance is "less specific".
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Supplying a default implementation for a typeclass based on another class

2009-02-28 Thread Svein Ove Aas
2009/2/28 Lennart Augustsson :
> If you were writing your own Binary class you could simply make Show
> and Read superclasses of Binary and it would be trivial to have
> default implementations based on Show and Read.
>
That's my fallback approach, yes, but I don't really want to make
Binary a subclass of Show,Read. I'd like to be able to define this for
classes in packages I *don't* control, and without *requiring* the
fallback to work..

As you say, it isn't exactly a critical issue. I was just wondering if
it was possible, really.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Supplying a default implementation for a typeclass based on another class

2009-02-28 Thread Svein Ove Aas
I'm in the process of writing a distributed filesystem (in haskell,
yay), which of course means I'm using Binary for de/serialization.

Now, that's fine enough, but for simplicity (and for wireshark), I'd
like to be able to have Binary fall back on an instance based on
Show/Read for any type that lacks any other Binary instance..

Well, I understand why this would be somewhere between extremely hard
and impossible in haskell '98, but I'm not entirely up on all the
extensions, so I thought I'd ask - given every extension implemented
in ghc 6.10.1, is there any reasonable way to do this?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cabal: local documentation

2009-02-24 Thread Svein Ove Aas
2009/2/24 Felipe Lessa :
> Just pass '--enable-documentation' to 'cabal install'. On *nix they're
> generated at ~/.cabal/share/doc.
>
Or edit ~/.cabal/config and set the documentation key to True
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: Pickling a finite map (Binary + zlib) [was: [Haskell-cafe] Data.Binary poor read performance]

2009-02-24 Thread Svein Ove Aas
2009/2/24 Bulat Ziganshin :
> Hello Felipe,
>
> Tuesday, February 24, 2009, 11:24:19 AM, you wrote:
>
>> Too bad 'Map' is exported as an abstract data type and it's not
>> straighforward to test this conjecture. Any ideas?
>
> just make a copy of its implementation to test
>
> btw, i always thought that it should be a way to overcome any export
> lists and go directly to module internals. limiting export is the way
> to protect programmer from errors, not security feature, and it should
> be left to programmer to decide when he don't need it. compilers
> should just be able to check whether some module/library imported
> abstractly or with internals too. this will render useless all those
> .Internals modules that now we need to add everywhere
>
I agree in principle, but GHC also uses that knowledge to optimize the
code better - if a function is exported it has to produce the most
polymorphic possible code for its type, if it isn't it can specialize
better... that sort of thing.

So it's not for security purposes, it's for technical reasons; you
can't override the export list externally because the information
you'd need to use the functions simply doesn't exist.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hoogle and Network.Socket

2009-02-21 Thread Svein Ove Aas
On Sat, Feb 21, 2009 at 11:55 AM, Martijn van Steenbergen
 wrote:
>
> How about allowing an extra search flag +windows that reveals
> windows-specific APIs? Likewise for other OS's.
>
> Being able to enable API for a specific package requires me knowing in what
> package I want to look, while an OS flag doesn't, all the while still making
> very explicit I want to look for OS-specific API.
>
There aren't enough platforms supported that we need this kind of freeform flag.

My preference would be for a bunch of (initially hidden, drop-down)
checkboxes, that remember their state via a cookie; if I wanted to see
windows-specific functions last search, chances are I still do this
time.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hoogle and Network.Socket

2009-02-19 Thread Svein Ove Aas
2009/2/19 Bryan O'Sullivan :
> On Wed, Feb 18, 2009 at 6:50 PM, Thomas DuBuisson
>  wrote:
>>
>> I recall that Niel made sure hoogle doesn't search through
>> non-portable libraries (a shame), but I thought Network.Socket could
>> be used on Windows and yet Hoogle does not give any results for
>> 'socket' or any other functions within Network.Socket.
>
> I can't suggest why the network package isn't being indexed by Hoogle, but
> it does indeed work on Windows and is not, as erroneously stated by another
> respondent, POSIX-only.
>
If you say so, but..

Unix domain sockets?
sendFd?

I can't claim *none* of it works on windows, but those functions must
at best be undefined on windows - right?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A typeclass for Data.Map etc?

2009-02-19 Thread Svein Ove Aas
On Thu, Feb 19, 2009 at 2:46 PM, Mark Wotton  wrote:
> On Thu, Feb 19, 2009 at 9:51 PM, Eugene Kirpichov  
> wrote:
>> Greetings,
>>
>> Is there a typeclass for mappings with a Data.Map-like interface, with
>> stuff like: empty, insert, insertWithKey, unionWith etc. ?
>> And, probably, a similar typeclass for mutable mappings like Data.Hashtable.
>>
There are some apparently useful classes for this sort of thing in the
EdisonAPI package, with corresponding implementations in EdisonCore.
Have a look.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hoogle and Network.Socket

2009-02-19 Thread Svein Ove Aas
On Thu, Feb 19, 2009 at 3:50 AM, Thomas DuBuisson
 wrote:
> I recall that Niel made sure hoogle doesn't search through
> non-portable libraries (a shame), but I thought Network.Socket could
> be used on Windows and yet Hoogle does not give any results for
> 'socket' or any other functions within Network.Socket.
>
> First, am I mistaken and Network.Socket is POSIX only?  I could swear
> it wasn't.  Secondly - is there any chance of lifting the non-portable
> libraries ban, Niel?  From the stand point of an application developer
> it might not sound good, but even in Haskell some software is system
> level and bound to be single platform (case and point: XCB, xmonad,
> hsXenCtrl).  Judging by the amount of research in systems level
> functional programming I wouldn't be surprised to see this collection
> grow and making functions hard to find isn't productive.
>

"The Network.Socket module is for when you want full control over
sockets. Essentially the entire C socket API is exposed through this
module; in general the operations follow the behaviour of the C
functions of the same name (consult your favourite Unix networking
book)."

The C socket API in question is the POSIX one, I'm afraid. It has no
exact equivalent on windows.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to create an online poll

2009-02-18 Thread Svein Ove Aas
2009/2/18 Andrew Wagner :
> Help! Help! I'm being suppressed!!
>
Aha!
Now we see the violence inherent in the system.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] concurrent haskell debugging

2009-02-18 Thread Svein Ove Aas
2009/2/18 Jianzhou Zhao :
> Hi Folks,
>
> If I am using Control.Concurrent package, does GHC have any
> static or runtime tools or debuggers to detect problems,
> such as deadlock, data races?
>
Deadlocks should be detected out of the box if you compile with
-threaded, with the system being able to detect whenever there is
absolutely no possibility that a thread can ever wake again, but note
that installing signal handlers will tend to break (sort of) that
logic; after all, you might actually want to use signals to wake them.

Races, not so much. It's pretty easy to design your program so the
issue just never shows up, so I don't think anyone's given it much
thought.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Intergalactic Telefunctors

2009-02-15 Thread Svein Ove Aas
On Sun, Feb 15, 2009 at 7:54 PM, Svein Ove Aas  wrote:
> 2009/2/15 Gregg Reynolds :
>>
>> The metaphor is action-at-a-distance.  Quantum entanglement is a vivid way
>> of conveying it since it is so strange, but true.  Obviously one is not
>> expected to understand quantum entanglement, only the idea of two things
>> linked "invisibly" across a boundary.
>>
> This is unrelated to haskell, but it's so common a misconception that
> I have to debunk it.
>
> What actually happens, if you run through the math, is that when you
> entangle two particles it affects the entangled property such that,
> when you later start spreading information about the entangled state -
> the universe is effectively divided in whatever the possible results
> are, MWI style, but once the information contacts the related
> entangled information from the other particle, inconsistent results
> cancel out and you get a big fat zero for a wavefunction. Consistent
> results reinforce, so it's still unitary as a whole.
>
> See, it all adds up to normality. Pay no attention to the bazillion
> timelines being continually destroyed behind the scenes, please;
> anyhow, you can never actually *observe* inconsistency, so if your
> notion of "self" is flexible enough you can just claim you continue
> along the consistent timeline.
>
Oh yeah. The crucial point is, this view has no spooky action at a
distance involved. The speed of light limit is maintained - nice and
elegant, really.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Intergalactic Telefunctors

2009-02-15 Thread Svein Ove Aas
2009/2/15 Gregg Reynolds :
>
> The metaphor is action-at-a-distance.  Quantum entanglement is a vivid way
> of conveying it since it is so strange, but true.  Obviously one is not
> expected to understand quantum entanglement, only the idea of two things
> linked "invisibly" across a boundary.
>
This is unrelated to haskell, but it's so common a misconception that
I have to debunk it.

What actually happens, if you run through the math, is that when you
entangle two particles it affects the entangled property such that,
when you later start spreading information about the entangled state -
the universe is effectively divided in whatever the possible results
are, MWI style, but once the information contacts the related
entangled information from the other particle, inconsistent results
cancel out and you get a big fat zero for a wavefunction. Consistent
results reinforce, so it's still unitary as a whole.

See, it all adds up to normality. Pay no attention to the bazillion
timelines being continually destroyed behind the scenes, please;
anyhow, you can never actually *observe* inconsistency, so if your
notion of "self" is flexible enough you can just claim you continue
along the consistent timeline.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: space leak with 'concat' ?

2009-02-12 Thread Svein Ove Aas
On Thu, Feb 12, 2009 at 10:36 AM, Simon Marlow  wrote:
> Peter Verswyvelen wrote:
>>
>> Yes, I was really surprised that this was the case. I while ago I did a
>> little FRP experiment. I made a top level binding to a list of timer event
>> occurrences. The list was generated on another thread. To my surprise, I did
>> not have space leak, which is amazingly cool, but it felt odd :) Is it
>> documented when GHC will garbage collect CAFs?
>
> CAFs are garbage collected when they are unreachable by traversing the code
> that is reachable from the currently running program.  In practice we don't
> actually traverse the code, instead we have these "static reference tables"
> that list the top-level closures referenced by each code block, and traverse
> those instead.
>
> Unfortunately we didn't get around to documenting the details of how this
> works...
>
Using this as a guide, I tested these two programs:


str = concat $ repeat "foo "

main1 = print foo
main2 = print foo >> print foo
=

As I'm sure you realize, the first ran in constant memory; the second,
not so much. Very interesting.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] threadDelay

2009-02-09 Thread Svein Ove Aas
2009/2/9 Immanuel Litzroth :
> Am I correct in assuming this program should run 100 secs?
>
No, you're off by a factor of a thousand. It's based on microseconds,
not milliseconds.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Data.Map: Enumerating ordered subset of keys

2009-02-08 Thread Svein Ove Aas
On Mon, Feb 9, 2009 at 8:02 AM, Jared Updike  wrote:
> It looks like two "Map.split"s will do what I need except for allowing
> more exact testing of <= vs. < (since == elements are left out of both
> maps...?)
>
If your key is an instance of Enum, you can use succ/pred to work
around that little problem.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Quite confused by simple transformations on this code not working

2009-01-21 Thread Svein Ove Aas
Or if the specificity of (/\) is important to you, you could define f
at the global scope using that type, not export it, then declare (/\)
as equal to f but with a more restrictive type.

On Wed, Jan 21, 2009 at 5:45 AM, Alexander Dunlap
 wrote:
> Instead of declaring (/\) :: Eq a => Sentence a -> Sentence a ->
> Sentence a, you could say (/\) :: Eq a -> [a] -> [a] -> [a]. Then it
> would work in both places. ([a] -> [a] -> [a] is a more general type
> than [[Term a]] -> [[Term a]] -> [[Term a]], so functions with the
> former type can be used in place of functions of the latter type but
> not vice versa.)
>
> Alex
>
> 2009/1/20 Andrew Wagner :
>> So...there's just no good way to avoid the duplication?
>>
>> On Tue, Jan 20, 2009 at 11:10 PM, wren ng thornton 
>> wrote:
>>>
>>> Andrew Wagner wrote:

 Strange little bit of code:
 http://moonpatio.com:8080/fastcgi/hpaste.fcgi/view?id=829#a829

 If I do any of the following, all of which seem natural to me, it fails
 to
 typecheck:

   1. move f out of the 'where' clause (with or without a type signature)
   2. put the same type signature on f as is on (/\)
   3. replace f with (/\) completely

 What's going on here?
>>>
>>>> :t (nub .) . (++)
>>>(nub .) . (++) :: (Eq a) => [a] -> [a] -> [a]
>>>
>>>> :t foldr (map . (nub .) . (++))
>>>foldr (map . (nub .) . (++)) :: (Eq a) => [[a]] -> [[a]] -> [[a]]
>>>
>>> The type you give to (/\) is more restrictive than the type of the
>>> expression, and f uses the generality of the expression.
>>>
>>> --
>>> 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 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] Array bug?

2008-11-03 Thread Svein Ove Aas
On Mon, Nov 3, 2008 at 4:55 PM, Henning Thielemann
>
> I think it is a good idea to switch this feature on and off by a compiler
> switch. It does not alter the correctness of a program. If the program is
> incorrect, the switch does only affect the way how the program goes wrong.
>

I disagree.
In a normal program, you may want to mix the two - use the safe
functions for untrusted input, the unsafe ones once you have already
validated the input.

Such a switch, if it existed, should only affect the *unsafe* version
of the call - this way, it would be possible to remove all chance of
corruption from a program at need.

Also, of course, the exceptions should be catchable based on the new
ghc 6.10 exception library (on ghc 6.10, anyhow)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Array bug?

2008-11-03 Thread Svein Ove Aas
On Sun, Nov 2, 2008 at 7:53 PM, Andrew Coppin
<[EMAIL PROTECTED]> wrote:
> Bertram Felgenhauer wrote:
>>
>> It's not going to be fixed by itself - the first comment for the
>> bug report basically asks interested parties to submit a proposal
>> for changing this.
>>
>
> Well I certainly don't have the skill to fix it. (Presumably all that array
> stuff is hard-wired into the compiler.)
>
Actually, it isn't.
The code - the bounds-checking code, at least - is fairly plain haskell in
the Array package. You could take a look and, quite possibly, fix it.

> In my opinion, what we should have is
>
> 1. An interface that is guaranteed-safe, no matter how inefficient that is.
>
> 2. An interface that is guaranteed-efficient, no matter how unsafe that is.
>
> 3. It should be extremely easy to switch from one to the other.
>
> You write your code against the safe interface, test it until you're happy
> with it, and then switch to the fast interface.
>
Sounds good to me.

> Currently, the "safe" interface actually allows out-of-bounds indicies (in a
> way which reveals the underlying implementation), and the "fast" interface
> isn't publicly supported. Both of these things should be changed.
>
Go ahead. :)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Memory efficiency questions for real-time graphics

2008-11-03 Thread Svein Ove Aas
On Mon, Nov 3, 2008 at 11:31 AM, Tobias Bexelius
<[EMAIL PROTECTED]> wrote:
> Before Direct3D 10, its too costly to read back the updated vertex data
> in every frame, which force you to make this kind of operations on the
> CPU.
> With D3D 10 however, you should use the new Stream-Output stage which is
> used to return updated vertex data directly to a vertex buffer on the
> GPU. So if you can afford a new graphics card and likes Vista, that's
> the way to go :)
>
Or you could use OpenGL, which has supported that since the first GPUs
that did were released.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] building c2hs on Mac

2008-10-23 Thread Svein Ove Aas
On Thu, Oct 23, 2008 at 12:38 PM, John Lato <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I've been trying to build c2hs-0.15.1 on an Intel Mac (10.4), and am
> having some difficulty.  It has dependencies on happy and alex, which
> would be fine, except that alex itself seems to require alex (using
> alex 2.2).  Does anyone have any suggestions for how to get around
> this?  I have ghc-6.8.3 and ghc-6.10 RC, and could use either.
>
That sounds familiar - happy depends on happy too, at least in the
latest version.

The general solution is to preprocess the alex files on another
machine, that does have alex installed. Ideally they'd come bundled.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal-install question

2008-10-21 Thread Svein Ove Aas
On Tue, Oct 21, 2008 at 11:37 PM, Ken98 <[EMAIL PROTECTED]> wrote:
>
> Hello, I recently started using cabal-install to install packages. However,
> ran into a problem today trying to install ftphs where the current HUnit
> dependency required base (==4). I'm using ghc-6.8.2 on ubuntu.
>
Right, that's the 6.10 version of base.

> So my question is, could I have used cabal install to specify the specific
> version of HUnit without having to do the manual
> download/configure/build/install?
>
Yes, you should be able to say "cabal install HUnit-1.2.0.0" or so.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell newbie indentation query.

2008-10-16 Thread Svein Ove Aas
On Wed, Oct 15, 2008 at 5:25 PM, Jules Bean <[EMAIL PROTECTED]> wrote:
>
> There is a new indentation module which does much better at the indentation
> stuff:
>
> http://kuribas.hcoop.net/haskell-indentation.el
>
I didn't realize until I tried to use yours that there are two
indentation modules in haskell-mode, and I'd been using the inferior
one.

This does mean I can't tell what changes you have made, though. If
it's not too much trouble, could you summarize your changes?

Also, is this code going to make it into haskell-mode proper, or are
there issues preventing that?
If the latter, I wouldn't mind having a darcs repository to pull from.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Where did House/hOp go?

2008-10-16 Thread Svein Ove Aas
I'd finally gotten to the point in learning haskell at which they
might be interesting to look at, and then.. they were gone.

Does anyone know what happened to these projects? They used to be
open-source, so the code should still be around somewhere, right?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Interesting new user perspective

2008-10-11 Thread Svein Ove Aas
On Sat, Oct 11, 2008 at 9:30 PM, Iain Barnett <[EMAIL PROTECTED]> wrote:
>
> Personally, I use stored procedures with a database as they protect from sql
> injection attacks (unless you write some really stupid procedures).
>
Isn't this what parametrized queries are for?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] OT: Haskell desktop wallpaper?

2008-10-08 Thread Svein Ove Aas
2008/10/8 Magnus Therning <[EMAIL PROTECTED]>:
> This morning I got tired of my desktop wallpaper (one that ships with
> Debian's Gnome packages).  Typing "haskell desktop wallpaper" yeilded
> a lot of links to wallpapers with Colleen Haskell, while she's a
> beautiful lady it wasn't exactly what I was hoping to find.  Hence
> this email.  Where can I find some nice wallpapers inspired by
> Haskell, or maybe even created by Haskell code?
>
It's not quite what you asked for, but
http://arcanux.org/lambdacats.html does contain my current wallpaper.
Close enough?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal upgrade

2008-10-01 Thread Svein Ove Aas
On Wed, Oct 1, 2008 at 10:52 PM, Duncan Coutts
<[EMAIL PROTECTED]> wrote:
> On Wed, 2008-10-01 at 20:53 +0200, Svein Ove Aas wrote:

>> and you have network access, start updating it.
>
> That's hard. Detecting if we would be able to make a network connection
> without actually doing it is not something I know how to do (esp in a
> portable way). We would very much appreciate some help in this area.
>
OS X has a function to test that, and a way to get notified when the
access state changes; it never occurred to me that other OSs might
not. It only tests for local connectivity, though.

That aside, why not start downloading in the background, while it's
doing whatever you started cabal for? Assuming the network is working,
you should have an updated package list by the time it's done;
granted, it won't be used for *that* invocation, but next time you
invoke cabal it will. If the download fails, just ignore it.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal upgrade

2008-10-01 Thread Svein Ove Aas
On Wed, Oct 1, 2008 at 9:52 PM, Martin DeMello <[EMAIL PROTECTED]> wrote:
>
> $ cabal install yi
> Resolving dependencies...
> 'yi-0.4.6.2' is cached.
> Configuring yi-0.4.6.2...
> cabal: alex version >=2.0.1 && <3 is required but it could not be found.
> cabal: Error: some packages failed to install:
> yi-0.4.6.2 failed during the configure step. The exception was:
> exit: ExitFailure 1
>
> $ cabal install yi-gtk
> Resolving dependencies...
> cabal: cannot configure yi-gtk-0.2.1. It requires sourceview >=0.9.11
> There is no available version of sourceview that satisfies >=0.9.11
>
> Trying cabal upgrade didn't fix it - it still throws the same error.
>
This is because the sourceview package is not on hackage - it's
legacy, non-cabal code and can be found on
http://www.haskell.org/gtk2hs/

You'll have to install it manually, I'm afraid.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: cabal upgrade

2008-10-01 Thread Svein Ove Aas
On Wed, Oct 1, 2008 at 9:56 PM, Stefan Monnier <[EMAIL PROTECTED]> wrote:
>> It's something to consider in the future, although a change-aware
>> "filesystem" (git, say? It's fast) would probably be better.
>^^^
>
> You misspelled "darcs".
>
I know how git would improve on darcs here:
It's (much) faster, and uses less space.

How would darcs improve on git?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: cabal upgrade

2008-10-01 Thread Svein Ove Aas
On Wed, Oct 1, 2008 at 8:59 PM, Achim Schneider <[EMAIL PROTECTED]> wrote:
> Additionally, you could use rsync instead of a tbz download to speed
> things up. Gentoo does this right.
>
It wouldn't be *that* much faster, and the server load would be
higher. The current package index is.. what, half a megabyte?

It's something to consider in the future, although a change-aware
"filesystem" (git, say? It's fast) would probably be better.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal upgrade

2008-10-01 Thread Svein Ove Aas
On Wed, Oct 1, 2008 at 7:54 PM, Duncan Coutts
> Because we actually consult the index of available packages more often
> than you think. Every time you cabal install in a local directory we
> make sure all the required packages are available and consistent. If we
> had to go to the network every time you would not be happy.
>
> There should be a solution here that lets us update more automatically
> while still allowing people to do offline operations. I'm not sure what
> that solution is yet though.
>
The solution seems obvious to me, actually:

Check the timestamp of the package file at every access. If it's older
than some configurable value, and you have network access, start
updating it.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] System.Process

2008-09-30 Thread Svein Ove Aas
On Tue, Sep 30, 2008 at 2:32 AM, Timothy Goddard <[EMAIL PROTECTED]> wrote:
> On Tue, 30 Sep 2008 08:49:44 Andrew Coppin wrote:
>> Before anybody remarks that "words" will do this, consider the "echo"
> command, which treats whitespace meaningfully.)
>
> [EMAIL PROTECTED]:~/$ echo foo  barbaz
> foo bar baz
>
> Echo doesn't receive special treatment. It joins its arguments with spaces.
>
To clarify, the shell is what's responsible for splitting the argument
line; the argument array you'd pass to runProcess is what the process
would literally get, but if you use runCommand it gets passed to the
shell for splitting first.

All programs want argument arrays, not un-split lines, and if you
don't have the shell split it you'll have to do it yourself. words
works fine.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] GHC 6.10, OS X, Fink and CPPFLAGS

2008-09-25 Thread Svein Ove Aas
While trying to test 6.10, I ran into the issue that a number of the
libraries it wants are not installed by default, and are most
conveniently added via Fink. This includes gmp, binutils, readline,
etc.

/sw/ is not in the default gcc path, of course, so the usual solution
is to add -I/sw/include, -L/sw/lib, etc. to it via the CPPFLAGS and
LDFLAGS environment variables, which are supported by most[1]
autoconf-based packages. The help text for ghc's configure script does
in fact suggest that this is the case, and it has some code meant to
read it; broken code, as it happens.

As it is, the script fails to propagate those variables to whatever is
responsible for compiling the RTS, which fails with a missing gmp.h,
bfd.h, and so on. All those files exist live quite happily in
/sw/include, and would no doubt appreciate visiting makefiles.

So my question is two-fold:
Is the help file wrong? Is there some other way to do it?
Or is this in fact a bug, and if so, will any of you volunteer to fix
it for me? ^_^
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: How to check if two Haskell files are the same?

2008-09-17 Thread Svein Ove Aas
On Wed, Sep 17, 2008 at 7:04 PM, Mauricio <[EMAIL PROTECTED]> wrote:
>>> I would like to write a Haskell pretty-printer,
>>> using standard libraries for that. How can I
>>> check if the original and the pretty-printed
>>> versions are the same? For instance, is there
>>> a file generated by GHC at the compilation
>>> pipe that is always guaranteed to have the
>>> same MD5 hash when it comes from equivalent
>>> source?
>>
>> Compare .hi files?
>>
>
> That was my first thought, but can I be sure
> .hi files are going to be exactly the same,
> i.e., isn't there some kind of information
> (timestamps?) that can change without changes
> in the code?
>
For that matter, the code can change without the .hi file doing so,
eg. if a pragma noinline'd function is altered without changing its
type/strictness - or a function the optimizer decides is just
pointless to try inlining, for all I know.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Graphical graph reduction

2008-02-22 Thread Svein Ove Aas
2008/2/22  <[EMAIL PROTECTED]>:
> Does anybody know if such a tool exists? I'd be grateful for pointers if it
> does. I very much doubt that I'm the first person who has thoughts like
> this, but then again, who knows. People who really know Haskell might think
> this is too trivial a task to really be worth spending time on.
>
> If nothing similar exists, I was thinking about creating such a tool (i.e.
> an interpreter with additional graph-displaying features) for a very, very
> small subset/dialect of Haskell. I would probably be lazy (no pun intended)
> and start right away with abstract syntax trees to avoid lexing and parsing
> and such. My language of implementation would be SML, using references as
> the edges of the graph.
>
> Any ideas/comments would be welcome.
>
Rather than spending time on a project specifically to do this, it
seems like a great addition to GHCi's still mostly theoretical
debugger. I'll understand if you don't want to take on such a project
right now, though.

I'm not aware of any program that does exactly what you're asking for,
but I'm attaching a lambdabot interaction for your reading pleasure. I
believe it will speak for itself.

< Baughn> > let fibs = 1 : 1 : zipWith (+) fibs (tail fibs) in fibs :: [Expr]
< lambdabot>  [1,1,1 + 1,1 + (1 + 1),1 + 1 + (1 + (1 + 1)),1 + (1 + 1)
+ (1 + 1 + (1 + (1 ...
1

-- 
In a demon-haunted world, science is a candle in the dark
http://dresdencodak.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Windows, or GHC?

2008-02-12 Thread Svein Ove Aas
2008/2/12 Magnus Therning <[EMAIL PROTECTED]>:
> The following code will on Linux print three strings each followed by a NULL
> byte:
>
> module Main where
>
> putStr0 = putStr $ s ++ "\0"
>
> main = do
> putStr0 "Hello"
> putStr0 "Hello"
>  putStr0 "Hello"
>
> On Windows however it will print nothing!  In order to trigger printing I
> have to change the definition of putStr0 to
>
> putStr0 = putStr (s ++ "\0") >> hFlush stdout
>
> Is this difference in behaviour due to a bug in GHC on Windows or just a
> quirkiness of the platform?
>
I can't directly answer, but a way to find out would be to try the
same thing in C.

It seems to me that, while Linux implicitly flushes streams on exit,
Windows is failing to do so. So try the same output in C, with and
without fflush, and.. you'll see.

A program to do this follows for your convenience.


#include 

int main() {
  int i;
  for (int i=0; i<3; i++)
puts("Hello\0");
  //fflush(stdout);
  return 0;
}
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe