Re: [Haskell-cafe] Storables and Ptrs

2010-12-06 Thread Erik Hesselink
 This can be used to call into C code expecting pointer input or output
 types to great effect:

 wrapperAroundForeignCode :: InputType - IO OutputType
 wrapperAroundForeignCode in =
  alloca $ \inPtr -
  alloca $ outPtr - do
    poke inPtr in
    c_call inPtr outPtr
    peek outPtr

There is also 'with' (:: Storable a = a - (Ptr a - IO b) - IO b),
which is exactly the combination of 'alloca' and 'poke' you use on
'in'.

Erik

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


[Haskell-cafe] Cabal, xmonad-contrib, X11-xft, pkg-config ... questioning my sanity

2010-12-06 Thread Jacek Generowicz

In short: I can't cabal install xmonad-contrib.

Longer version:

It a appears that a program which does not exist on my computer seems  
to insist on a package version which does not exist in my universe,  
I'm starting to wonder whether I have lost my marbles. Could some kind  
soul please point me in some sensible direction?



cabal install xmonad-contrib
Resolving dependencies...
Configuring X11-xft-0.3...
cabal: pkg-config version =0.9.0 is required but it could not be found.
cabal: Error: some packages failed to install:
X11-xft-0.3 failed during the configure step. The exception was:
ExitFailure 1
xmonad-contrib-0.9.1 depends on X11-xft-0.3 which failed to install.


cabal install x11-xft
Resolving dependencies...
Configuring X11-xft-0.3...
cabal: pkg-config version =0.9.0 is required but it could not be found.
cabal: Error: some packages failed to install:
X11-xft-0.3 failed during the configure step. The exception was:
ExitFailure 1


X11-xft version 0.9.0 doesn't even exist, as far a I can tell: 0.3  
seems to be the highest. So what is making cabal believe that such a  
version is needed? Is it pkg-config?


I'm not at all familiar with pkg-config, and, as far as I can tell  
it's not even installed on the Mac on which I am trying to do this.  
Curiously, its man page *does* work (it's in /usr/X11/man, for some  
reason). Does Cabal have some sort of embedded pkg-config?





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


Re: [Haskell-cafe] Cabal, xmonad-contrib, X11-xft, pkg-config ... questioning my sanity

2010-12-06 Thread Duncan Coutts
On 6 December 2010 11:02, Jacek Generowicz jacek.generow...@cern.ch wrote:

 It a appears that a program which does not exist on my computer seems to
 insist on a package version which does not exist in my universe, I'm
 starting to wonder whether I have lost my marbles. Could some kind soul
 please point me in some sensible direction?

 cabal install xmonad-contrib
 Resolving dependencies...
 Configuring X11-xft-0.3...
 cabal: pkg-config version =0.9.0 is required but it could not be found.

 X11-xft version 0.9.0 doesn't even exist, as far a I can tell

In the development version of cabal we have changed that error message
to try and make it clear that it is looking for a program called
pkg-config, not a Haskell package or a C lib.

cabal: The program pkg-config version =0.9.0 is required but it could not be
found.

Do you think that message would have helped avoid your confusion? Is
there an alternative message that would have been better?

pkg-config [1] is a tool used by C libraries to describe things like
dependencies on other C libs and what C compiler flags are needed to
use the packages.

The Haskell package X11-xft is a binding to the C library xft. On most
modern unix systems xft C library provides meta-data that pkg-config
can use. For example, on my system I can run:

$ pkg-config --cflags xft
-I/usr/include/freetype2

$ pkg-config --libs xft
-lXft -lXrender -lfontconfig -lfreetype -lX11

Cabal does exactly the same thing, to work out what flags are needed
to use the xft C library.

The problem on your system is that the pkg-config program is not
installed. Perhaps on OSX it comes with Xcode, I'm not sure. It may
well also be the case that you don't have the development files for
X11 or xft installed either (e.g. C header files). Hopefully some OSX
person can advise you on what you need to install to do X11
development on OSX.

[1]: http://pkg-config.freedesktop.org/wiki/

Duncan

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


Re: [Haskell-cafe] Cabal, xmonad-contrib, X11-xft, pkg-config ... questioning my sanity

2010-12-06 Thread Antoine Latter
On Mon, Dec 6, 2010 at 7:15 AM, Duncan Coutts
duncan.cou...@googlemail.com wrote:
 On 6 December 2010 11:02, Jacek Generowicz jacek.generow...@cern.ch wrote:

 It a appears that a program which does not exist on my computer seems to
 insist on a package version which does not exist in my universe, I'm
 starting to wonder whether I have lost my marbles. Could some kind soul
 please point me in some sensible direction?

 cabal install xmonad-contrib
 Resolving dependencies...
 Configuring X11-xft-0.3...
 cabal: pkg-config version =0.9.0 is required but it could not be found.

 X11-xft version 0.9.0 doesn't even exist, as far a I can tell

 In the development version of cabal we have changed that error message
 to try and make it clear that it is looking for a program called
 pkg-config, not a Haskell package or a C lib.

 cabal: The program pkg-config version =0.9.0 is required but it could not be
 found.

 Do you think that message would have helped avoid your confusion? Is
 there an alternative message that would have been better?

 pkg-config [1] is a tool used by C libraries to describe things like
 dependencies on other C libs and what C compiler flags are needed to
 use the packages.

 The Haskell package X11-xft is a binding to the C library xft. On most
 modern unix systems xft C library provides meta-data that pkg-config
 can use. For example, on my system I can run:

 $ pkg-config --cflags xft
 -I/usr/include/freetype2

 $ pkg-config --libs xft
 -lXft -lXrender -lfontconfig -lfreetype -lX11

 Cabal does exactly the same thing, to work out what flags are needed
 to use the xft C library.

 The problem on your system is that the pkg-config program is not
 installed. Perhaps on OSX it comes with Xcode, I'm not sure. It may
 well also be the case that you don't have the development files for
 X11 or xft installed either (e.g. C header files). Hopefully some OSX
 person can advise you on what you need to install to do X11
 development on OSX.


On my Mac 'which -a pkg-config' returns:
/opt/local/bin/pkg-config
/opt/local/bin/pkg-config

I'm not sure why it prints twice. The folder means I've installed it
from MacPorts, which also means I guess you'll need to install the
MacPorts version of X11-xft, but I'm not sure.

However building Haskell libraries against MacPorts often leads to
nightmarish scenarios involving libiconv, but I haven't run into that
on my current installation yet.

Antoine

 [1]: http://pkg-config.freedesktop.org/wiki/

 Duncan

 ___
 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] Berlin Haskell Meeting

2010-12-06 Thread Sönke Hahn
The Berlin Haskell meeting is due again:

Date: Tuesday, December 7th
Time: from 20:00
Location: c-base, Rungestrasse 20, 10179 Berlin

See you there.
Sönke

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


Re: [Haskell-cafe] Cabal, xmonad-contrib, X11-xft, pkg-config ... questioning my sanity

2010-12-06 Thread Jacek Generowicz

Problem solved: 2 solutions described below.


On 2010 Dec 6, at 14:15, Duncan Coutts wrote:

On 6 December 2010 11:02, Jacek Generowicz  
jacek.generow...@cern.ch wrote:


It a appears that a program which does not exist on my computer  
seems to

insist on a package version which does not exist in my universe, I'm
starting to wonder whether I have lost my marbles. Could some kind  
soul

please point me in some sensible direction?

cabal install xmonad-contrib
Resolving dependencies...
Configuring X11-xft-0.3...
cabal: pkg-config version =0.9.0 is required but it could not be  
found.



X11-xft version 0.9.0 doesn't even exist, as far a I can tell


In the development version of cabal we have changed that error message
to try and make it clear that it is looking for a program called
pkg-config, not a Haskell package or a C lib.

cabal: The program pkg-config version =0.9.0 is required but it  
could not be

found.

Do you think that message would have helped avoid your confusion?


Oooh, that's a difficult question to answer, as I had read your  
earlier paragraph before coming to this question. After your  
explanation explained the error message (to the extent that I now  
wonder how on earth I ever took it to mean that it's looking for X11- 
xft version =0.9.0, when it quite clearly states pkg-config version  
=0.9.0 is required but could not be found), I have no idea whether  
the new message would have been better.



Is there an alternative message that would have been better?


Well, if I try to understand how I could have misunderstood the  
original message, I suspect that it is because of the common style of  
error message where the program generating the message precedes the  
actual message on the same line, just like cabal: ... precedes the  
message in this case. So I guess that I parsed it something like ...  
pkg-config: version =0.9.0 is required ... and inferred that  
'version' refers to the package mentioned in an earlier message.


In which case, maybe something like

cabal: version =0.9.0 of pkg-config is required ...

would have prevented me from making this particular mistake in this  
particular case.



pkg-config [1] is a tool used by C libraries to describe things like
dependencies on other C libs and what C compiler flags are needed to
use the packages.

The Haskell package X11-xft is a binding to the C library xft. On most
modern unix systems xft C library provides meta-data that pkg-config
can use. For example, on my system I can run:

$ pkg-config --cflags xft
-I/usr/include/freetype2

$ pkg-config --libs xft
-lXft -lXrender -lfontconfig -lfreetype -lX11

Cabal does exactly the same thing, to work out what flags are needed
to use the xft C library.

The problem on your system is that the pkg-config program is not
installed. Perhaps on OSX it comes with Xcode, I'm not sure. It may
well also be the case that you don't have the development files for
X11 or xft installed either (e.g. C header files). Hopefully some OSX
person can advise you on what you need to install to do X11
development on OSX.


Solution 1 (more complicated version):

Although I never use XCode itself, I thought that I had it installed  
along with all the developer tools in order to get at GCC etc.  
Apparently not.


Anyway, pkg-config seems to be available through darwinports, but I  
don't use darwinports (as, many years ago, I concluded that it's more  
trouble than it's worth, because of the strange places where it puts  
the stuff it manages).


However, a plain manual compilation Just Works (for me):

curl http://pkgconfig.freedesktop.org/releases/pkg-config-0.25.tar.gz 
 -o pkgconfig.tgz

tar zxf pkgconfig.tgz
cd pkgconfig.tgz
./configure
make
sudo make install

and I now have pkg-config

If I try

pkg-config --cflags xft

it complains about the package not being found, and mentions the  
relevant environment variable.


I *do* have /usr/X11/lib/pkgconfig/xft.pc, and popping its directiory  
into PKG_CONFIG_PATH makes the above pkg-config call now work.


In this state,

cabal install xmonad-contrib

also works.

= 
= 
= 



Solution 2 (simpler):

I did manage to get xmonad-contrib to cabal install (without pkg- 
config) by asking for it not to use xft


cabal install xmonad-contrib --flags=-use_xft

Presumably cabal uses pkg-config for only a subset of the things it  
manages, and xft is the only one of those on which xmonad-contrib  
depends.



Thank you Duncan for your concise, clear and complete answer: it was  
just what I needed to unblock me.



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


Re: [Haskell-cafe] Cabal, xmonad-contrib, X11-xft, pkg-config ... questioning my sanity

2010-12-06 Thread Jacek Generowicz


On 2010 Dec 6, at 15:05, Antoine Latter wrote:


On my Mac 'which -a pkg-config' returns:
/opt/local/bin/pkg-config
/opt/local/bin/pkg-config

I'm not sure why it prints twice.


Same happens with my hand-installed version when I use the -a flag: it  
only shows it once when invoked without -a.



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


Re: [Haskell-cafe] Cabal, xmonad-contrib, X11-xft, pkg-config ... questioning my sanity

2010-12-06 Thread Jacek Generowicz


On 2010 Dec 6, at 15:39, Jacek Generowicz wrote:


On 2010 Dec 6, at 14:15, Duncan Coutts wrote:



In the development version of cabal we have changed that error  
message

to try and make it clear that it is looking for a program called
pkg-config, not a Haskell package or a C lib.

cabal: The program pkg-config version =0.9.0 is required but it  
could not be

found.

Do you think that message would have helped avoid your confusion?


Oooh, that's a difficult question to answer, as I had read your  
earlier paragraph before coming to this question. After your  
explanation explained the error message (to the extent that I now  
wonder how on earth I ever took it to mean that it's looking for X11- 
xft version =0.9.0, when it quite clearly states pkg-config  
version =0.9.0 is required but could not be found), I have no idea  
whether the new message would have been better.



Is there an alternative message that would have been better?


Well, if I try to understand how I could have misunderstood the  
original message, I suspect that it is because of the common style  
of error message where the program generating the message precedes  
the actual message on the same line, just like cabal: ... precedes  
the message in this case. So I guess that I parsed it something like  
... pkg-config: version =0.9.0 is required ... and inferred that  
'version' refers to the package mentioned in an earlier message.


In which case, maybe something like

   cabal: version =0.9.0 of pkg-config is required ...

would have prevented me from making this particular mistake in this  
particular case.


Another thing that would probably have made it easier to understand:  
the message is strictly correct, but is *too* specific: it talks about  
pkg-config version =0.9.0 not being found, while the problem was that  
*no version at all* was present.


I would understand if making the error message change according to  
such subtle distinctions would be more effort that it is worth.



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


Re: [Haskell-cafe] the beginning of the end

2010-12-06 Thread C. McCann
On Mon, Dec 6, 2010 at 2:33 AM, David Virebayre
dav.vire+hask...@gmail.com wrote:
 Level 5

 I'm out of layers here. I think this is all there is to it.

Level 5 is after you've spent way too much time writing questions
and/or answers that people like and have over 10k reputation. This
unlocks some basic moderation tools for helping deal with spam and
other problematic content. SO is a largely community-driven site,
rather than having a bunch of moderators appointed by the
administrators.

There's also other things that some people track, like weekly scores
and per-tag rankings. For instance, I'm apparently SO's foremost
expert on lazy-evaluation and typeclass, and the only user so far
to get a tag badge for monads. This is obviously a very significant
accomplishment.

But seriously, it's mostly just a medium for providing QA in a
structured, searchable way. In fact, you missed the most important
part by far:

Level 0:
You have an unresolved programming problem. You search the web for
information and the first Google hit is a question on StackOverflow
that describes your problem exactly. You look at the accepted answer,
find that it has the solution you need, and go on your way in a matter
of minutes.

- C.

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


Re: [Haskell-cafe] Cabal, xmonad-contrib, X11-xft, pkg-config ... questioning my sanity

2010-12-06 Thread Duncan Coutts
On 6 December 2010 14:48, Jacek Generowicz jacek.generow...@cern.ch wrote:

 Another thing that would probably have made it easier to understand: the
 message is strictly correct, but is *too* specific: it talks about
 pkg-config version =0.9.0 not being found, while the problem was that *no
 version at all* was present.

 I would understand if making the error message change according to such
 subtle distinctions would be more effort that it is worth.

Yes. The version is there so that when you do go and install it, you
will know what version to look for, so you don't end up in the
situation where you've gone to all the effort of installing
pkg-config, only to find it now complains that it found it, but it was
too old.

Perhaps something like this would be better:

cabal: The program 'pkg-config' is required but it could not be found
on the system (version 0.9.0 or later of pkg-config is required).


Duncan

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


[Haskell-cafe] An Haskell implementation of a sweep line algorithm for the detection of segments intersection

2010-12-06 Thread vince vegga
Hi,

Here is my Haskell implementation of the Shamos and Hoey algorithm for
detecting segments intersection in the plane:

http://neonstorm242.blogspot.com/2010/12/sweep-line-algorithm-for-detection-of.html

I'm new to Haskell, so any useful comments will be appreciated.

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


[Haskell-cafe] Trying out GHC 7

2010-12-06 Thread Andrew Coppin

OK, so the other day I decided to take GHC 7.0.1 for a spin.

Suffice it to say, it definitely compiles stuff. So far, I've only tried 
running it in a Windows XP virtual machine with a single core, so I 
haven't been able to test what multicore performance is like.


One thing that did interest me is the conflicting information about 
whether or not dynamic linking is supported on Windows. Half the User 
Guide claims that this /is/ supported, and the other half still contains 
statements that it is /not/ supported. So I thought I'd just go 
physically try it and see if it works.


Well... it compiles stuff. Hello World goes from being 518KB to being a 
piffling 13KB. Which is nice.


I almost didn't bother actually trying to /run/ the resulting binary... 
But when I did, I discovered that it immediately crashes, whining that 
it can't find the DLL it wants. So, out of the box, the Windows setup is 
broken. (Obviously the Windows section of the User Guide makes no 
mention of how DLLs are located; it only explains the situation for 
Linux and Mac OS. I especially liked the bit where it says that there 
are three modes, and then proceeds to list only two...)


In the interests of science, I wanted to see if I could make it run by 
just putting the necessary DLLs into the same folder as the binary. But 
first I had to /find/ them. I had expected to find a folder somewhere 
with all the DLLs in it... but no, the installer appears to have 
sprinkled them around the filesystem more or less at random. Some of 
them are in folders named for the package, some of them just sit in the 
root folder.


After about 20 minutes of searching, I found the RTS DLL. Running the 
program, it now instantly crashes because of a /different/ DLL. This one 
didn't take quite so long to find (now that I know roughly where to 
look). I fixed that, and now the binary crashes with yet another missing 
DLL. And so on and so forth. In the end, Hello World required 5 DLLs. 
Better still, together these totalled 8MB of data. (!) So the 
distribution package is now about 16x bigger than with static linking. 
Oh joy.


Clearly if you just want to distribute one executable binary, you're 
going to use static linking. (E.g., darcs.exe will hopefully remain 
statically linked.) But I suppose if I had a whole heap of Haskell 
programs then the extra complexity of delivering half a dozen DLLs might 
may off in terms of space reductions. And of course, on /my/ development 
box, I don't need a zillion redundant copies of the RTS code, etc. (Or 
at least, I won't if I can figure out how to make the programs able to 
actually /find/ the necessary DLLs...)


Actually, of all the DLLs, only base is actually large - it's 
approximately 6MB on its own. GHC-Prim is 0.5MB, and the others are all 
relatively tiny. It feels slightly irritating that I need to inclide the 
FFI DLL when I'm not doing and FFI - but of course, the entire Haskell 
I/O subsystem /is/ doing FFI. Similarly, I'm not using 
arbitrary-precision integers, but various I/O operations return file 
sizes as Integer, so GMP must also be included. Neither of these things 
are actually especially large.


It's rather confusing that the User Guide is out of date in so many 
places. (And not just regarding dynamic linking on Windows. For example, 
one section claims that +RTS -f will tell you what options are 
supported, but that actually yields unknown RTS opion: -f. It seems 
that -? is the correct option name.) If I can get a suitable Linux VM 
going, I might have a go at contributing some updates.


Just for completeness, I tried asking for dynamic linking with an older 
version of GHC (6.10, IIRC) - one that supports it on Linux but not 
Windows. I was expecting to get either dynamic linking is not supported 
on this platform, or at worst unknown option -dynamic. In fact, what 
I got was gcc: cannot find file Main.dyn_hi. Oh, that's graceful 
failure then. _


I did also briefly see if the LLVM backend would work under Windows. I 
wasn't entirely sure if LLVM comes with the installer binary or you need 
to get it seperately. (You might say obviously it's seperate, but the 
installer already contains the entire GCC system, for example.) 
Attempting to use this resulted in a summary error message (cannot run: 
opt) which doesn't make it especially clear that the problem is that 
LLVM isn't installed. Perhaps there's no better way of detecting this 
condition, I don't know, but something more illuminating would be nice.


I briefly had a look at how to install LLVM, but it appears that you 
have to build it from source. This is not my idea of a fun time, so 
given the minimal speed difference, I just won't bother.


I haven't had time to play with any of the other new good stuff in GHC 
7. (The multicore performance, the new GC stuff, etc.)



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org

Re: [Haskell-cafe] An Haskell implementation of a sweep line algorithm for the detection of segments intersection

2010-12-06 Thread Serguey Zefirov
2010/12/6 vince vegga megatron...@gmail.com:
 Here is my Haskell implementation of the Shamos and Hoey algorithm for
 detecting segments intersection in the plane:

 http://neonstorm242.blogspot.com/2010/12/sweep-line-algorithm-for-detection-of.html

Quite good, actually.

Myself, I rarely write code that is on par with yours. ;)

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


Re: [Haskell-cafe] Cabal, xmonad-contrib, X11-xft, pkg-config ... questioning my sanity

2010-12-06 Thread Simon Michael

On 12/6/10 7:25 AM, Duncan Coutts wrote:

cabal: The program 'pkg-config' is required but it could not be found
on the system (version 0.9.0 or later of pkg-config is required).


Looks good.


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


Re: [Haskell-cafe] LLVM, getElementPtr?

2010-12-06 Thread Ryan Ingram
On Sun, Dec 5, 2010 at 12:45 PM, Lally Singh lally.si...@gmail.com wrote:
 Is that how it's intended?

I think that's correct, (it at least fits the pattern for 'with'
functions in Haskell).

They're idiomatically used with syntax like this:

 buildReaderFun :: String - CodeGenModule (Function (IO ()))
 buildReaderFun nm = do
  puts - newNamedFunction ExternalLinkage puts :: TFunction (Ptr Word8 - 
 IO Word32)
  withStringNul nm $ \greetz - createFunction ExternalLinkage $ do
          tmp - getElementPtr greetz (0 :: Word32,(0 :: Word32, ()))
          call puts  tmp -- Throw away return value.
          ret ()

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


Re: [Haskell-cafe] Trying out GHC 7

2010-12-06 Thread Antoine Latter
Inlcuding the ghc-users list.

On Mon, Dec 6, 2010 at 10:10 AM, Andrew Coppin
andrewcop...@btinternet.com wrote:
 OK, so the other day I decided to take GHC 7.0.1 for a spin.

 Suffice it to say, it definitely compiles stuff. So far, I've only tried
 running it in a Windows XP virtual machine with a single core, so I haven't
 been able to test what multicore performance is like.

 One thing that did interest me is the conflicting information about whether
 or not dynamic linking is supported on Windows. Half the User Guide claims
 that this /is/ supported, and the other half still contains statements that
 it is /not/ supported. So I thought I'd just go physically try it and see if
 it works.

 Well... it compiles stuff. Hello World goes from being 518KB to being a
 piffling 13KB. Which is nice.

 I almost didn't bother actually trying to /run/ the resulting binary... But
 when I did, I discovered that it immediately crashes, whining that it can't
 find the DLL it wants. So, out of the box, the Windows setup is broken.
 (Obviously the Windows section of the User Guide makes no mention of how
 DLLs are located; it only explains the situation for Linux and Mac OS. I
 especially liked the bit where it says that there are three modes, and
 then proceeds to list only two...)

 In the interests of science, I wanted to see if I could make it run by just
 putting the necessary DLLs into the same folder as the binary. But first I
 had to /find/ them. I had expected to find a folder somewhere with all the
 DLLs in it... but no, the installer appears to have sprinkled them around
 the filesystem more or less at random. Some of them are in folders named for
 the package, some of them just sit in the root folder.

 After about 20 minutes of searching, I found the RTS DLL. Running the
 program, it now instantly crashes because of a /different/ DLL. This one
 didn't take quite so long to find (now that I know roughly where to look). I
 fixed that, and now the binary crashes with yet another missing DLL. And so
 on and so forth. In the end, Hello World required 5 DLLs. Better still,
 together these totalled 8MB of data. (!) So the distribution package is now
 about 16x bigger than with static linking. Oh joy.

 Clearly if you just want to distribute one executable binary, you're going
 to use static linking. (E.g., darcs.exe will hopefully remain statically
 linked.) But I suppose if I had a whole heap of Haskell programs then the
 extra complexity of delivering half a dozen DLLs might may off in terms of
 space reductions. And of course, on /my/ development box, I don't need a
 zillion redundant copies of the RTS code, etc. (Or at least, I won't if I
 can figure out how to make the programs able to actually /find/ the
 necessary DLLs...)

 Actually, of all the DLLs, only base is actually large - it's
 approximately 6MB on its own. GHC-Prim is 0.5MB, and the others are all
 relatively tiny. It feels slightly irritating that I need to inclide the FFI
 DLL when I'm not doing and FFI - but of course, the entire Haskell I/O
 subsystem /is/ doing FFI. Similarly, I'm not using arbitrary-precision
 integers, but various I/O operations return file sizes as Integer, so GMP
 must also be included. Neither of these things are actually especially
 large.

 It's rather confusing that the User Guide is out of date in so many places.
 (And not just regarding dynamic linking on Windows. For example, one section
 claims that +RTS -f will tell you what options are supported, but that
 actually yields unknown RTS opion: -f. It seems that -? is the correct
 option name.) If I can get a suitable Linux VM going, I might have a go at
 contributing some updates.

 Just for completeness, I tried asking for dynamic linking with an older
 version of GHC (6.10, IIRC) - one that supports it on Linux but not Windows.
 I was expecting to get either dynamic linking is not supported on this
 platform, or at worst unknown option -dynamic. In fact, what I got was
 gcc: cannot find file Main.dyn_hi. Oh, that's graceful failure then. _

 I did also briefly see if the LLVM backend would work under Windows. I
 wasn't entirely sure if LLVM comes with the installer binary or you need to
 get it seperately. (You might say obviously it's seperate, but the
 installer already contains the entire GCC system, for example.) Attempting
 to use this resulted in a summary error message (cannot run: opt) which
 doesn't make it especially clear that the problem is that LLVM isn't
 installed. Perhaps there's no better way of detecting this condition, I
 don't know, but something more illuminating would be nice.

 I briefly had a look at how to install LLVM, but it appears that you have to
 build it from source. This is not my idea of a fun time, so given the
 minimal speed difference, I just won't bother.

 I haven't had time to play with any of the other new good stuff in GHC 7.
 (The multicore performance, the new GC stuff, etc.)


 

Re: [Haskell-cafe] Trying out GHC 7

2010-12-06 Thread Don Stewart
 andrewcoppin:

[100 lines snipped]

Andrew, if you have a bug report, please use the bug tracker:

http://hackage.haskell.org/trac/ghc/wiki/ReportABug

Keep your reports concise and to-the-point, for the best hope of getting
useful stuff done.

Cheers,
  Don

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


Re: [Haskell-cafe] Trying out GHC 7

2010-12-06 Thread Darrin Chandler
On Mon, Dec 06, 2010 at 10:04:35AM -0800, Don Stewart wrote:
 Andrew, if you have a bug report, please use the bug tracker:
 
 http://hackage.haskell.org/trac/ghc/wiki/ReportABug

Or reddit, of course. ;-)

-- 
You've been warned.

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


Re: [Haskell-cafe] Storables and Ptrs

2010-12-06 Thread Antoine Latter
On Mon, Dec 6, 2010 at 12:03 PM, Tyler Pirtle tee...@gmail.com wrote:
 On Sun, Dec 5, 2010 at 9:46 PM, Antoine Latter aslat...@gmail.com wrote:
 On Sun, Dec 5, 2010 at 10:45 PM, Tyler Pirtle tee...@gmail.com wrote:
 Hi cafe,

 I'm just getting into Foreign.Storable and friends and I'm confused
 about the class storable. For GHC, there are instances of storable for
 all kinds of basic types (bool, int, etc) - but I can't find the
 actual declaration of those instances.

 I'm confused that it seems that all Storable instances operate on a
 Ptr, yet none of these types allow access to an underlying Ptr. I
 noticed that it's possible via Foreign.Marshal.Utils to call 'new' and
 get a datatype wrapped by a Ptr, but this isn't memory managed - I'd
 have to explicitly free it? Is that my only choice?

 The Storable class defines how to copy a particular Haskell type to or
 from a raw memory buffer - specifically represented by the Ptr type.
 It is most commonly used when interacting with non-Haskell (or
 'Foreign') code, which is why a lot of the tools look like they
 require manual memory management (because foreign-owned resources must
 often be managed separately anyway).

 Not all of the means of creating a Ptr type require manual memory
 management - the 'alloca' family of Haskell functions allocate a
 buffer and then free it automatically when outside the scope of the
 passed-in callback (although 'continuation' or 'action' would be the
 more Haskell-y way to refer to the idea):

 alloca :: Storable a = (Ptr a - IO b) - IO b

 This can be used to call into C code expecting pointer input or output
 types to great effect:

 wrapperAroundForeignCode :: InputType - IO OutputType
 wrapperAroundForeignCode in =
  alloca $ \inPtr -
  alloca $ outPtr - do
    poke inPtr in
    c_call inPtr outPtr
    peek outPtr

 The functions 'peek' and 'poke' are from the Storable class, and I
 used the 'alloca' function to allocate temporary storage for the
 pointers I pass into C-land.

 Is there a particular problem you're trying to solve? We might be able
 to offer more specific advice. The Storable and Foreign operations may
 not even be the best solution to what you're trying to do.



 Hey Antoine,

 Thanks for the clarity, it's very helpful. There is in fact a particular
 problem I'm trying to solve - persisting data structures. I'm a huge
 fan of Data.Vector.Storable.MMap, and I'm interested in other things
 like it - but i realize that the whole thing is built up/on/around
 storables, and building vectors with storables (read == peek, write ==
 poke, etc), because i'm trying to write the raw structures themselves
 to disk (via mmap).

 I am aware of Data.Binary, but I feel that this kind of serialization
 for the application I'm building would be too cumbersome considering the
 number of objects I'm dealing with (on the order of hundreds-of-millions
 to billions), especially considering that the application I'm building
 has some very nice pure-ish semantics (an append-only list). I'd
 like the application to able to simply load a file and interact with
 that memory - not have to load the file and then deserialize everything.

 If you have any suggestions here, or if anyone has any general feelings
 about the design or implementation of Data.Vector.Storable.MMap I'd be
 very interested in hearing them. Or about any ideas involving persisting
 native data structures in an append-only fashion, too. ;)


If you took the approach of Data.Vector.Storable.MMap, every time you
read an element out of the array you would be un-marshalling the
object from a pointer into a Haskell type - in effect, making a copy.
There are probably ways to do this for ByteStrings to make this copy
free, but that's about it.

So depending on your data and usage patterns, that might be a great
approach. Just rember that operations involving Storable make copies
of your data.

For large and complex types you would have a trade-off - each read
might be more expensive than otherwise, but depending on your usage
patterns you could save a lot on how much you keep in memory at a
given time.

If you're lucky, you might be able to write your Storable instance
such that you can take advantage of Haskell's laziness, so that common
operations only need to unmarhsall part of the object. But this might
be overkill.

Maybe you could email the maintainer of the vector package, to see if
they have used the 'MMap' backed vector, or have any feedback from
anyone that has. Most of what I've written is speculation - I've never
tried that sort of thing.

Take care,
Antoine


 Thanks,


 Tyler







 Take care,
 Antoine



 Is there a way that given just simply an Int I could obtain a Ptr from
 it, and then invoke the storable functions on it? Or for that matter,
 if I go and create some new data type, is there some generic
 underlying thing (ghc-only or otherwise) that would let me have a Ptr
 of it?

 Thanks,


 Tyler

 

Re: [Haskell-cafe] Cabal, xmonad-contrib, X11-xft, pkg-config ... questioning my sanity

2010-12-06 Thread Jacek Generowicz


On 2010 Dec 6, at 16:25, Duncan Coutts wrote:


Perhaps something like this would be better:

cabal: The program 'pkg-config' is required but it could not be found
on the system (version 0.9.0 or later of pkg-config is required).


That looks pretty good. I'm having trouble finding any holes in it.

There is also the issue (if my understanding is correct) that cabal  
install only needs pkg-config for some packages. So it is possible  
that someone has happily been using cabal install for some time, and  
then suddenly it doesn't work. And then they are left wondering what  
broke: But I'm sure it worked last week, and I haven't changed  
anything etc. At which point it could be helpful to be told that it's  
a circumstantial rather than a fundamental problem.



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


Re: [Haskell-cafe] Question about TagSoup

2010-12-06 Thread Neil Mitchell
Hi David,

I see no reason not to use TagSoup for this, assuming it does what you
want. It wasn't really designed for either modification or round
tripping, so be careful that things like entities don't become
corrupted. Also note that this won't replace all the contents of the
Content tag, only the first text node, so if someone writes
ContentiText/i/Content you won't hit it. But if it works, I'd
stick with it - it's light weight and easy to get to grips with.

Also your use of recursion seems perfectly reasonable. I often find
the easiest way to encode some kind of multiple element search (i.e.
for the Content tag and it's following text) is with direct
recursion - although I'm certain some kind of fold would also work.

Thanks, Neil

On Fri, Dec 3, 2010 at 1:45 PM, Alex Rozenshteyn rpglove...@gmail.com wrote:
 I really wouldn't use tag soup for this.  Haskell has libraries specifically
 for XML processing which might be better suited to your needs.

 On Fri, Dec 3, 2010 at 5:59 AM, David Virebayre dav.vire+hask...@gmail.com
 wrote:

 Hello café,

 I have seen tutorials about extracting information from a tag soup, but I
 have a different use case:
 I want to read a xml file, find a tag, change its content, and write the
 xml file back.

 This is an example of the files

 ?xml version=1.0 encoding=UTF-8 standalone=yes?
 idPkg:Story
 xmlns:idPkg=http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging;
 DOMVersion=7.0
        Story Self=ub9fad AppliedTOCStyle=n TrackChanges=false
 StoryTitle=$ID/ AppliedNamedGrid=n
                StoryPreference OpticalMarginAlignment=false
 OpticalMarginSize=12 FrameType=TextFrameType
 StoryOrientation=Horizontal StoryDirection=LeftToRightDirection/
                InCopyExportOption IncludeGraphicProxies=true
 IncludeAllResources=false/
                ParagraphStyleRange
 AppliedParagraphStyle=ParagraphStyle/prix
                        CharacterStyleRange
 AppliedCharacterStyle=CharacterStyle/$ID/[No character style]
                                Contentzzznba5/Content
                        /CharacterStyleRange
                /ParagraphStyleRange
        /Story
 /idPkg:Story

 Assuming I want to change the content of the Content tag, this is what I
 came up with (simplified), I'm using direct recursion. Is there a better way
 ?
 ts = do
  soup - parseTags `fmap` readFile idml/h00/Stories/Story_ub9fad.xml
  writeFile test $ renderTagsOptions renderOptions{optMinimize = const
 True}
                   $ modif soup

 modif [] = []
 modif (x@(TagOpen Content []):TagText _m : xs) = x : TagText modified
 : modif xs
 modif (x:xs) = x : modif xs

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




 --
           Alex R

 ___
 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] Storables and Ptrs

2010-12-06 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 12/6/10 13:22 , Antoine Latter wrote:
 On Mon, Dec 6, 2010 at 12:03 PM, Tyler Pirtle tee...@gmail.com wrote:
 On Sun, Dec 5, 2010 at 9:46 PM, Antoine Latter aslat...@gmail.com wrote:
 On Sun, Dec 5, 2010 at 10:45 PM, Tyler Pirtle tee...@gmail.com wrote:
 Hi cafe,

 I'm just getting into Foreign.Storable and friends and I'm confused
 about the class storable. For GHC, there are instances of storable for
 all kinds of basic types (bool, int, etc) - but I can't find the
 actual declaration of those instances.

 I'm confused that it seems that all Storable instances operate on a
 Ptr, yet none of these types allow access to an underlying Ptr. I
 noticed that it's possible via Foreign.Marshal.Utils to call 'new' and
 get a datatype wrapped by a Ptr, but this isn't memory managed - I'd
 have to explicitly free it? Is that my only choice?

 The Storable class defines how to copy a particular Haskell type to or
 from a raw memory buffer - specifically represented by the Ptr type.
 It is most commonly used when interacting with non-Haskell (or
 'Foreign') code, which is why a lot of the tools look like they
 require manual memory management (because foreign-owned resources must
 often be managed separately anyway).

 Not all of the means of creating a Ptr type require manual memory
 management - the 'alloca' family of Haskell functions allocate a
 buffer and then free it automatically when outside the scope of the
 passed-in callback (although 'continuation' or 'action' would be the
 more Haskell-y way to refer to the idea):

 alloca :: Storable a = (Ptr a - IO b) - IO b

 This can be used to call into C code expecting pointer input or output
 types to great effect:

 wrapperAroundForeignCode :: InputType - IO OutputType
 wrapperAroundForeignCode in =
  alloca $ \inPtr -
  alloca $ outPtr - do
poke inPtr in
c_call inPtr outPtr
peek outPtr

 The functions 'peek' and 'poke' are from the Storable class, and I
 used the 'alloca' function to allocate temporary storage for the
 pointers I pass into C-land.

 Is there a particular problem you're trying to solve? We might be able
 to offer more specific advice. The Storable and Foreign operations may
 not even be the best solution to what you're trying to do.



 Hey Antoine,

 Thanks for the clarity, it's very helpful. There is in fact a particular
 problem I'm trying to solve - persisting data structures. I'm a huge
 fan of Data.Vector.Storable.MMap, and I'm interested in other things
 like it - but i realize that the whole thing is built up/on/around
 storables, and building vectors with storables (read == peek, write ==
 poke, etc), because i'm trying to write the raw structures themselves
 to disk (via mmap).

 I am aware of Data.Binary, but I feel that this kind of serialization
 for the application I'm building would be too cumbersome considering the
 number of objects I'm dealing with (on the order of hundreds-of-millions
 to billions), especially considering that the application I'm building
 has some very nice pure-ish semantics (an append-only list). I'd
 like the application to able to simply load a file and interact with
 that memory - not have to load the file and then deserialize everything.

 If you have any suggestions here, or if anyone has any general feelings
 about the design or implementation of Data.Vector.Storable.MMap I'd be
 very interested in hearing them. Or about any ideas involving persisting
 native data structures in an append-only fashion, too. ;)

 
 If you took the approach of Data.Vector.Storable.MMap, every time you
 read an element out of the array you would be un-marshalling the
 object from a pointer into a Haskell type - in effect, making a copy.
 There are probably ways to do this for ByteStrings to make this copy
 free, but that's about it.

IIRC bytestring-mmap uses pinned bytestrings; might be easier/faster to use
that directly if the vector package is troublesome.  You'd want to use the
bytestring internals module for the equivalent of peek/poke.

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]  allb...@kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university  KF8NH
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz9Mm0ACgkQIn7hlCsL25UgKgCgqV/BIXRDm5BVEPBzNllpVVD9
QsYAoJMU7kvHWxoAmb2eYV9b5tll9U0d
=p1GN
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] Offer to mirror Hackage

2010-12-06 Thread wren ng thornton

On 12/6/10 2:35 AM, Vincent Hanquez wrote:

I would really like mirrors too.

But before that happens it would be nice to have signed packages on
Hackage, preventing
a mirror to distribute compromised stuff (intentionally or
unintentionally).


+1.

This should be done during sdist, before uploading, so that maintainers 
can be sure that the central mirror gets the right thing too.


--
Live well,
~wren

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


[Haskell-cafe] include modules in DLL? undefined reference

2010-12-06 Thread Gerold Meisinger
Hello!

I'm trying to compile a Windows DLL and need to include an additional module
(specifically FRP.Yampa).
I was successful with a Hello World type of DLL but when I use Yampa I get:

$ ghc -shared -o hs.dll DLLTest.o DLLTest_stub.o StartEnd.o
 Creating library file: hs.dll.a
 DLLTest.o:fake:(.text+0x46): undefined reference to
`Yampazm0zi9zi2zi3_FRPziYamp
a_integral_closure'
 DLLTest.o:fake:(.text+0x4d): undefined reference to
`Yampazm0zi9zi2zi3_FRPziYamp
aziVectorSpace_zdfVectorSpaceDoubleDouble_closure'
 DLLTest.o:fake:(.text+0x194): undefined reference to
`Yampazm0zi9zi2zi3_FRPziYam
pa_embed_closure'
 DLLTest.o:fake:(.text+0x381): undefined reference to
`__stginit_Yampazm0zi9zi2zi
3_FRPziYampa_'
 DLLTest.o:fake:(.data+0x0): undefined reference to
`Yampazm0zi9zi2zi3_FRPziYampa
_integral_closure'
 DLLTest.o:fake:(.data+0x4): undefined reference to
`Yampazm0zi9zi2zi3_FRPziYampa
ziVectorSpace_zdfVectorSpaceDoubleDouble_closure'
 DLLTest.o:fake:(.data+0x38): undefined reference to
`Yampazm0zi9zi2zi3_FRPziYamp
a_embed_closure'
 collect2: ld returned 1 exit status

How can I define the references of Yampa in the DLL?


I also tried to reinstall Yampa shared with:
$ cabal install --reinstall --enable-shared yampa
 Could not find module `Data.IORef':
   Perhaps you haven't installed the dyn libraries for package
`base-3.0.3.
 2'?
   Use -v to see a list of the files searched for.

$ cabal install --reinstall --enable-shared base # :)
 Resolving dependencies...
 cabal: internal error: impossible



(StartEnd is taken from:
http://www.haskell.org/ghc//docs/latest/html/users_guide/win32-dlls.html )

DLLTest.hs:
 {-# LANGUAGE ForeignFunctionInterface, Arrows #-}

 module DLLTest

 embeddedSF :: Double - Double - Double - IO Double
 embeddedSF v0 v1 v2 = return . last $ embed integral (v0, [(1.0, Just v1),
(1.0, Just v2)])

 foreign export ccall embeddedSF :: Double - Double - Double - IO Double
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: Haddock 2.9.0

2010-12-06 Thread David Waern

-- Haddock 2.9.0


A new version of Haddock, the Haskell documentation tool, is out!

This version is compatible with .haddock files produced by the version of
Haddock that comes with GHC 7.0.1.


-- Changes in version 2.9.0


Changes in version 2.9.0

  * Drop support for ghc  7

  * New flag --qual for qualification of names

  * Print doc coverage information to stdout when generating docs

  * Include an 'All' option in the A-Z subdivided index

  * Make TOC group header identifiers validate

  * Minor changes to the API


-- Links


Homepage:
 http://www.haskell.org/haddock

Hackage page:
 http://hackage.haskell.org/package/haddock-2.9.0

Bugtracker and wiki:
 http://trac.haskell.org/haddock

Mailing list:
 hadd...@projects.haskell.org

Code repository:
 http://code.haskell.org/haddock


-- Contributors


The following people contributed patches to this release:

Tobias Brandt
Mark Lentczner
Ian Lynagh
Simon Marlow
Simon Michael
Ryan Newton
David Waern


-- Get Involved


We would be very happy to get more contributors. To get involved, start by
grabbing the code:

 http://code.haskell.org/haddock

Then take a look at the bug and feature tracker for things to work on:

 http://trac.haskell.org/haddock

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


Re: [Haskell-cafe] Trying out GHC 7

2010-12-06 Thread Andrew Coppin

On 06/12/2010 06:04 PM, Don Stewart wrote:

Andrew, if you have a bug report, please use the bug tracker:


From what I've seen, the GHC devs already have vastly more bug reports 
than they know what to do with. I tend to hessitate filing tickets until 
I'm sure I'm looking at an actual bug, rather than just a 
misunderstanding on my part.



Keep your reports concise and to-the-point, for the best hope of getting
useful stuff done.


There's actually a couple of seperate issues there, which should 
presumably end up being seperate tickets. The fact that, out of the box, 
dynamic linking fails is a bug. The fact that I can't work out the 
reason or rhyme behind where the DLLs get put is more sort of a hey 
guys, I'm not really sure what you were going for here type of thing 
than an actual /bug/.


I don't know if it's worth filing a ticket for prior versions of GHC 
failing to build dynamically in a less than graceful way. On one hand, 
the problem doesn't exist in GHC7. On the other hand, maybe we want to 
record this information anyway?


Regarding the documentation, what's the best way to fix this? Do I just 
file a bug against every sentence that's wrong, or would it be quicker 
for me to actually download a copy of the source and fix the problems 
myself? (I can probably fix some of it myself, but in other cases I 
actually don't know what the correct information is, so it would have to 
be written by somebody who knows what they're talking about.)



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


[Haskell-cafe] need help with syntax...

2010-12-06 Thread Daryoush Mehrtash
I am having hard time understanding the following code.  The code is from
Applicative Parser library:
http://hackage.haskell.org/packages/archive/uu-parsinglib/2.5.5.2/doc/html/src/Text-ParserCombinators-UU-BasicInstances.html

 instance (Show a,  loc `IsLocationUpdatedBy` a) = Provides  (Str  a
loc)  (a - Bool, String, a)  a where
splitState (p, msg, a) k (Str  tts   msgs pos  del_ok)
  = let ins exp =   (5, k a (Str tts (msgs ++ [Inserted
(show a)  pos  exp]) pos  False))
del exp =   (5, splitState (p,msg, a)
k
(Str (tail tts)
 (msgs ++ [Deleted  (show(head
tts))  pos  exp])
 (advance pos (head tts))
 True ))
in case tts of
   (t:ts)  -  if p t
   then  show_symbol (Accepting symbol:  ++
show t ++  at position:  ++ show pos ++\n)
 (Step 1 (k t (Str ts msgs (advance
pos t) True)))
   else  Fail [msg] (*ins:* if *del_ok* then
*[del*] else [])
   []  -  Fail [msg] [*ins*]




Specifically I am having hard time understanding how the ins exp and del
exp in the let is related to ins:  del_ok, [del], [ins].
I don't understand how given the let expression the following expressions
are expanded

 Fail [msg] (*ins:* if *del_ok* then *[del*] else [])


and

Fail [msg] [*ins*]


Appreciate any help.


Thanks

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


Re: [Haskell-cafe] Offer to mirror Hackage

2010-12-06 Thread Dan Knapp
Wow, this thread got long.  Good!  I'm hopeful that we can take some
action now. :)

My views on the issues that have been raised -

The Haskell steering committee is a good thing and I fully support
them.  I also support the current maintainer of the site; I don't want
to take over or anything, only to assist.  In fact, I'll go further,
please don't anybody attempt to foist any high-level responsibility on
me.  I'm a bad receptacle for it.  But I do have these technological
resources at my disposal and there's no reason the community shouldn't
benefit from them.

Re incorporation, the person who said that it has to happen was
dead-on.  So the rest of the discussion on that point is moot.  But
it's quite independent of when and how we set up mirroring.

I agree that signed packages are a good idea.  We should move with all
haste to implement them.  But I'm not sure we want to hold up
everything else while we wait for that.  That's also my take on a
peer-peer repository, as I said already.  Can somebody who understands
the technologies typically used for this suggest one, and possibly
also talk to dcoutts directly to make him aware of the discussion and
get his thoughts on how to implement it?  I've found he often makes
points that save me a lot of work. :)

I can certainly conceive of life events that could take my attention,
despite all good intentions, in much the fashion that the current
maintainer's often is.  (That's awkward to say - what's his name,
again?  I know I should know it...  It's not dcoutts, is it?)  So I
want to build something that works well with minimal manual
intervention.

I was of the impression that most of the members of the steering
committee were on this list, which is one reason I posted here.  Is
there some other way I should contact them?

I will talk to dcoutts, and see what the current status of the
distributed-operation code is and figure out how much time I can
devote to helping with that.


-- 
Dan Knapp
An infallible method of conciliating a tiger is to allow oneself to
be devoured. (Konrad Adenauer)

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


[Haskell-cafe] ANN: hledger 0.13

2010-12-06 Thread Simon Michael
I've released hledger 0.13, with readline editing and tab completion  
from Judah Jacobson, more ledger compatibility, a more robust and  
installable web interface, bugfixes, and a much-deliberated package  
split.


Docs and mac and 64-bit linux binaries are at http://hledger.org , and  
of course you can cabal update and cabal install hledger, cabal  
install hledger-web and so on. I didn't manage to build new windows or  
linux 32-bit binaries today, but they'll appear when I do. Let it be  
noted that maintaining a non-trivial cross-platform haskell app is  
currently quite hard.


Release notes:

  * move web, vty, chart commands into separate hledger-web, hledger- 
vty,
hledger-chart packages. This both simplifies (no more build  
flags) and
complicates (more room for dependency hassles), but I hope  
overall it

will be easier and more scalable.

  * all packages but chart are now marked beta, ie not finished but
suitable for everyday use

  * parsing: ledger compatibility: support D default commodity  
directive
  * parsing: ledger compatibility: ignore metadata tags on  
transactions and postings
  * parsing: ledger compatibility: ignore cleared flags at the start  
of postings
  * parsing: ledger compatibility: ignore C commodity conversion  
directives
  * parsing: price precisions no longer affect commodities' display  
precisions

  * add: readline-style editing
  * add: tab-completion for account names
  * add: add the default commodity, if any, to commodity-less amounts  
(#26)

  * add: misc. commodity/precision/defaults-related bugfixes
  * chart: give a meaningful error message for empty journals
  * chart: update for current Chart lib (0.14)
  * web: support files now live in ./.hledger/web/ and will be auto- 
created at startup

  * web: page layout is more robust with wide content
  * web: allow editing of included files
  * web: handle multiple filter patterns correctly
  * web: allow single- or double-quoted filter patterns containing  
spaces

  * web: update for current yesod lib (0.6.*)
  * transaction balancing is now based on display precision (#23)
  * briefer, more informative usage error messages

Stats: 91 days and 117 commits since last release, now at 5997 lines  
of code with 151 tests.


hledger is at a point where real-world user and developer input is  
needed to focus it; participants welcome. Best,


-Simon


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


Re: [Haskell-cafe] Bifold: a simultaneous foldr and foldl

2010-12-06 Thread Larry Evans
On 12/01/10 21:35, Larry Evans wrote:
[snip]
 Hi Noah,
 
 The attached is my attempt at reproducing your code
[snip]
 However, ghci compilation of bifold produces an error message:
 
   BifoldIfRecur.hs:20:19: parse error on input `='
 
[snip]
Apparently I had some extra leading spaces in the last line.
Taking those out (as shown in attached) results in a good
reading of the file by ghci.

-Larry
{-
  Purpose:
Test bifold code shown in post:
  http://article.gmane.org/gmane.comp.lang.haskell.cafe/83874
-}

module Bifold where
  {--}
  bifold :: (l - a - r - (r,l)) - (l,r) - [a] - (r,l)
  bifold _ (l,r) [] = (r,l)
  bifold f (l,r) (a:as) = (ra,las)
   where (ras,las) = bifold f (la,r) as
 (ra,la) = f l a ras
  {--}
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Help defining a Typeable polymorphic-state monad transformer

2010-12-06 Thread Brandon Simmons
Hi all,

I gave myself until this evening to figure this out on my own, and
time is up! Hopefully this makes for a good discussion, though the
idea could be dumb.

What I'm trying to do is define a state monad in which the passed
state can change type during the computation. The only constraint is
that the state types must always be of the Typeable class (see:
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Typeable.html
).

The idea is that the new monad would be something like 'StateT s Maybe
a', but where the 's' type is not fixed (indeed is hidden in an
existential type) and where any programmer errors in the chaining of
the polymorphic state will be caught in the Maybe type (or really the
'fail' implementation of any monad).

Here is how I imagine a computation might look:

computation :: TypeableState Maybe String
computation = do
(c:cs) -  getTS
putTS (length cs)
return (c ++  was the first letter of the string passed as
initial state.)

So TypeableState is very similar to StateT, except that the state type
is not present as a type argument. In the example above 'Maybe' is the
monad that catches Typeable errors, and String is the return type of
the computation.

getTS and putTS would be get and put functions that constrain their
arguments to the Typeable class.

Here is what I have so far (at least this is my most recent
uncommented attempt):

 {-# LANGUAGE ExistentialQuantification #-}
 module Main
   where

 import Control.Monad.State
 import Data.Typeable

 -- we might have restricted our 'm' to MonadPlus and used the explicit
 -- 'mzero', but decided instead to use Monad, with 'fail'. This is
 -- more appropriate since we won't be using 'mplus'. See 'liftMaybe'.
 data TypeableState m a = forall s0 sN. (Typeable s0, Typeable sN)=
TypeableState (s0 - m (a,sN))

 -- this is probably one of the more non-sensical attempts I've made at
 -- this... but I'm not sure:
 runTypeableState :: (Monad m, Typeable s0, Typeable sN)= TypeableState m a 
 - s0 - m (a,sN)
 runTypeableState (TypeableState st) s0 = (liftMaybe $ cast s0) = st

 -- copied from Control.Monad.StateT
 instance (Monad m) = Monad (TypeableState m) where
 return a = TypeableState $ \s - return (a, s)
 m = k  = TypeableState $ \s - do
 ~(a, s') - runTypeableState m s
 runTypeableState (k a) s'
 fail str = TypeableState $ \_ - fail str

 -- I imagine using this with 'cast' to thread the type in our monad
 -- transformer
 liftMaybe :: (Monad m)= Maybe a - m a
 liftMaybe = maybe (fail Monadic failure) return

So is this even feasible? Or do I not grok what we can and can't do
with the Typeable class?

Any thoughts on this are appreciated.

Sincerely,
Brandon Simmons
http://coder.bsimmons.name

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


[Haskell-cafe] Question: mime-mail and base64 encoding

2010-12-06 Thread Michael Snoyman
Hi all,

I've gotten a request for the mime-mail package that I'd like some
input on. Right now, there's the ability to fully specify whether or
not to base64-encode each part in a message, but the included
simpleMail function defaults to non-encoded parts for both its HTML
and plain text alternatives. This has apparently caused some issues
where long HTML strings have been word-wrapped at bad locations,
causing breakage in the meaning of the markup.

The request is to make both the HTML and plain text parts use base64
encoding by default. This *seems* to me to make a lot of sense, since
it will ensure that your message arrives exactly as you intended it,
and will ensure that any non-ASCII code points don't get killed
somewhere along the way. On the other hand, I'm not sure what client
support is like for base-64 encoding. Don't we need to leave *some*
form of non-encoded data for less sophisticated email clients?

Thanks,
Michael

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


Re: [Haskell-cafe] Help defining a Typeable polymorphic-state monad transformer

2010-12-06 Thread Luke Palmer
This has nothing to do with a monad.  This is just about data.  You
want a type that can contain any Typeable type, and a safe way to cast
out of that type into the type that came in.  Such a thing exists,
it's called Data.Dynamic.

Then your monad is just StateT Dynamic, where your magical maybeifying get is:

getD :: (Monad m, Typeable a) = StateT Dynamic m a
getD = maybe (fail Type error) return . cast = get

Luke

On Mon, Dec 6, 2010 at 9:09 PM, Brandon Simmons
brandon.m.simm...@gmail.com wrote:
 Hi all,

 I gave myself until this evening to figure this out on my own, and
 time is up! Hopefully this makes for a good discussion, though the
 idea could be dumb.

 What I'm trying to do is define a state monad in which the passed
 state can change type during the computation. The only constraint is
 that the state types must always be of the Typeable class (see:
 http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Typeable.html
 ).

 The idea is that the new monad would be something like 'StateT s Maybe
 a', but where the 's' type is not fixed (indeed is hidden in an
 existential type) and where any programmer errors in the chaining of
 the polymorphic state will be caught in the Maybe type (or really the
 'fail' implementation of any monad).

 Here is how I imagine a computation might look:

    computation :: TypeableState Maybe String
    computation = do
        (c:cs) -  getTS
        putTS (length cs)
        return (c ++  was the first letter of the string passed as
 initial state.)

 So TypeableState is very similar to StateT, except that the state type
 is not present as a type argument. In the example above 'Maybe' is the
 monad that catches Typeable errors, and String is the return type of
 the computation.

 getTS and putTS would be get and put functions that constrain their
 arguments to the Typeable class.

 Here is what I have so far (at least this is my most recent
 uncommented attempt):

 {-# LANGUAGE ExistentialQuantification #-}
 module Main
       where

 import Control.Monad.State
 import Data.Typeable

 -- we might have restricted our 'm' to MonadPlus and used the explicit
 -- 'mzero', but decided instead to use Monad, with 'fail'. This is
 -- more appropriate since we won't be using 'mplus'. See 'liftMaybe'.
 data TypeableState m a = forall s0 sN. (Typeable s0, Typeable sN)=
                            TypeableState (s0 - m (a,sN))

 -- this is probably one of the more non-sensical attempts I've made at
 -- this... but I'm not sure:
 runTypeableState :: (Monad m, Typeable s0, Typeable sN)= TypeableState m a 
 - s0 - m (a,sN)
 runTypeableState (TypeableState st) s0 = (liftMaybe $ cast s0) = st

 -- copied from Control.Monad.StateT
 instance (Monad m) = Monad (TypeableState m) where
     return a = TypeableState $ \s - return (a, s)
     m = k  = TypeableState $ \s - do
         ~(a, s') - runTypeableState m s
         runTypeableState (k a) s'
     fail str = TypeableState $ \_ - fail str

 -- I imagine using this with 'cast' to thread the type in our monad
 -- transformer
 liftMaybe :: (Monad m)= Maybe a - m a
 liftMaybe = maybe (fail Monadic failure) return

 So is this even feasible? Or do I not grok what we can and can't do
 with the Typeable class?

 Any thoughts on this are appreciated.

 Sincerely,
 Brandon Simmons
 http://coder.bsimmons.name

 ___
 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] Question: mime-mail and base64 encoding

2010-12-06 Thread Conrad Parker
On 7 December 2010 13:42, Michael Snoyman mich...@snoyman.com wrote:
 Hi all,

 I've gotten a request for the mime-mail package that I'd like some
 input on. Right now, there's the ability to fully specify whether or
 not to base64-encode each part in a message, but the included
 simpleMail function defaults to non-encoded parts for both its HTML
 and plain text alternatives. This has apparently caused some issues
 where long HTML strings have been word-wrapped at bad locations,
 causing breakage in the meaning of the markup.

 The request is to make both the HTML and plain text parts use base64
 encoding by default. This *seems* to me to make a lot of sense, since
 it will ensure that your message arrives exactly as you intended it,
 and will ensure that any non-ASCII code points don't get killed
 somewhere along the way. On the other hand, I'm not sure what client
 support is like for base-64 encoding. Don't we need to leave *some*
 form of non-encoded data for less sophisticated email clients?


What does the wrapping here? My understanding of the symptom is that
newlines are sometimes inserted between the  and / of a closing HTML
tag, breaking the tag and leaving stray markup in the file.

Would it be possible to either not do the wrapping, or to avoid
putting newlines inside a tag?

Conrad.

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


Re: [Haskell-cafe] Question: mime-mail and base64 encoding

2010-12-06 Thread Nathan Howell
On Mon, Dec 6, 2010 at 8:42 PM, Michael Snoyman mich...@snoyman.com wrote:
 The request is to make both the HTML and plain text parts use base64
 encoding by default. This *seems* to me to make a lot of sense, since
 it will ensure that your message arrives exactly as you intended it,
 and will ensure that any non-ASCII code points don't get killed
 somewhere along the way. On the other hand, I'm not sure what client
 support is like for base-64 encoding. Don't we need to leave *some*
 form of non-encoded data for less sophisticated email clients?

The way I've seen it done before was to:
- calculate the size of the body in quoted-printable and base64 encoding
- select the smaller encoded form of the two

quoted-printable is fairly human readable. This strategy also works
for encoding headers, particularly Subject: lines (substituting
q-encoding for qp).

-n

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


Re: [Haskell-cafe] need help with syntax...

2010-12-06 Thread wren ng thornton

On 12/6/10 7:26 PM, Daryoush Mehrtash wrote:

I am having hard time understanding the following code.  The code is from
Applicative Parser library:
http://hackage.haskell.org/packages/archive/uu-parsinglib/2.5.5.2/doc/html/src/Text-ParserCombinators-UU-BasicInstances.html

  instance (Show a,  loc `IsLocationUpdatedBy` a) =  Provides  (Str  a
loc)  (a -  Bool, String, a)  a where
 splitState (p, msg, a) k (Str  tts   msgs pos  del_ok)
   = let ins exp = ...1
 del exp = ...2
 in case tts of
(t:ts)  -   if p t
then  ...3
else  Fail [msg] (*ins:* if *del_ok* then
*[del*] else [])
[]  -   Fail [msg] [*ins*]


Specifically I am having hard time understanding how the ins exp and del
exp in the let is related to ins:  del_ok, [del], [ins].
I don't understand how given the let expression the following expressions
are expanded


The let expressions are binding functions so ins names (\exp - ...1) 
and del names (\exp - ...2). Thus, when del_ok is true we get,


Fail [msg] (ins : if del_ok then [del] else [])
==
Fail [msg] (ins : if del_ok then del : [] else [])
==
Fail [msg] (ins : del : [])
==
Fail [msg] ((\exp - ...1) : (\exp - ...2) : [])

and when del_ok is false we get

Fail [msg] ((\exp - ...1) : [])

--
Live well,
~wren

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