Re: [Haskell-cafe] writing to a fifo when the reader stops reading

2011-03-13 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 3/13/11 03:16 , bri...@aracnet.com wrote:
> ghc: fdWriteBuf: resource vanished (Broken pipe)
> 
> which make sense, sort of.  I write a value, let's say 10, and the
> reader reads it.  It's the last value so it "closes" the fifo.
> 
> Now there's nothing reading, so when I get to threadWaitWrite, I would
> expect the program to wait, just as it does when it starts up and there
> is no reader.

FIFOs don't work that way; like a regular pipe, once all readers go away it
doesn't work any more.  You need to open it read-write initially to keep a
reader around.  Haskell has no control over this:  it's how they're defined
to work.

In general, trying to use a FIFO like an AF_UNIX socket is a mistake.

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]allber...@gmail.com
system administrator  [openafs,heimdal,too many hats]kf8nh
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk19tqkACgkQIn7hlCsL25VxGwCgsInAy4YJhOA2Ca/tQTRd0Cjs
NmAAn2hjqtQm0/eZXVoLM8GMCMv+yxR4
=SDd8
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] Data.ByteString.Lazy.ByteString vs Data.ByteString.Lazy.Internal.ByteString

2011-03-13 Thread C K Kashyap
>
> Looks like a job for Data.Binary.
>
> > I'd like to use it with just the libraries that are part of the platform
>
>
I forgot to mention, Data.Binary does not seem to be in the platform.

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


Re: [Haskell-cafe] Data.ByteString.Lazy.ByteString vs Data.ByteString.Lazy.Internal.ByteString

2011-03-13 Thread Daniel Fischer
On Monday 14 March 2011 05:45:04, C K Kashyap wrote:
> Thanks Brandon,
> 
> data Endian = Big | Little
> data Size = Eight | Sixteen | ThirtyTwo | SixtyFour
> type EncTuple = (Int,Size,Endian)
> 
> My requirement is to write encode :: [EncTuple] -> ByteString

Looks like a job for Data.Binary.

> I'd like to use it with just the libraries that are part of the platform

I don't know whether binary is in the platform, though (but I expect it to 
be).

> - and I am not a fan of using the internal stuff :)
> I'd appreciate it very much if you could give me a sample.

instance Binary Endian where
put Big = putWord8 0
put Little = putWord8 1
get = do
  w <- getWord8
  case w of
0 -> return Big
1 -> return Little
_ -> error ("Bad Endian tag: " ++ show w)

instance Binary Size where
put Eight = putWord8 8
put Sixteen = putWord8 16
...
get = do
  w <- getWord8
  case w of
8 -> return 8
...

putAux Eight _ i = putWord8 (fromIntegral i)
putAux Sixteen Big i = putWord16be (fromIntegral i)
...


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


Re: [Haskell-cafe] Data.ByteString.Lazy.ByteString vs Data.ByteString.Lazy.Internal.ByteString

2011-03-13 Thread C K Kashyap
Thanks Brandon,

data Endian = Big | Little
data Size = Eight | Sixteen | ThirtyTwo | SixtyFour
type EncTuple = (Int,Size,Endian)

My requirement is to write encode :: [EncTuple] -> ByteString
I'd like to use it with just the libraries that are part of the platform -
and I am not a fan of using the internal stuff :)
I'd appreciate it very much if you could give me a sample.

And thank you very much for
http://research.microsoft.com/en-us/um/people/simonpj/papers/unboxed-values.ps.Z

Regards,
Kashyap


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


Re: [Haskell-cafe] Yesod 0.7.1 using GHC 7.0.2 on Arch Linux

2011-03-13 Thread Krzysztof Skrzętnicki
You can also download binary tarball, untar, ./configure
--prefix=$HOME/ghc-7.0.2, make install, export PATH=$PATH:$HOME/ghc-7.0.2
and you will be good to go.

Best regards,
Krzysztof Skrzętnicki

On Mon, Mar 14, 2011 at 02:15, Ertugrul Soeylemez  wrote:

> I know, but at least I can go on with development.  I hope, the problem
> will be fixed soon.
>
>
> vagif.ve...@gmail.com wrote:
>
> > No, it is not solved.
> > With -fproduction flag you are loosing devel-server functionality.
> >
> > On Saturday, March 12, 2011 02:45:11 PM Ertugrul Soeylemez wrote:
> > > Oh, I just noticed the other thread about this issue.  Compiling Yesod
> > > with the -fproduction flag solved it.
> > >
> > > Thanks to Michael for that.
> > >
> > >
> > > Greets,
> > > Ertugrul
> > >
> > > Ertugrul Soeylemez  wrote:
> > > > Hello Ryan,
> > > >
> > > > thanks a lot.
> > > >
> > > > Is there a workaround for this, until it's fixed?
> > > >
> > > >
> > > > Greets,
> > > > Ertugrul
> > > >
> > > > Ryan Yates  wrote:
> > > > > Looks to be reported here:
> > > > >
> > > > > http://hackage.haskell.org/trac/ghc/ticket/5004
> > > > >
> > > > >
> > > > > Ryan
> > > > >
> > > > > On Sat, Mar 12, 2011 at 3:26 PM, Ertugrul Soeylemez 
> wrote:
> > > > > > Hello there,
> > > > > >
> > > > > > today I have upgraded to GHC 7.0.2 by doing a system update on my
> > > > > > Arch Linux box (x86, 32 bits), and I'm having difficulties to
> > > > > > install Yesod. Its dependencies seem to have been installed
> without
> > > > > > problems, but the
> > > > > >
> > > > > > Yesod package itself fails.  The complete build log follows:
> > > > > >% cabal install yesod
> > > > > >Resolving dependencies...
> > > > > >Configuring yesod-0.7.1...
> > > > > >Preprocessing library yesod-0.7.1...
> > > > > >Preprocessing executables for yesod-0.7.1...
> > > > > >Building yesod-0.7.1...
> > > > > >[1 of 1] Compiling Yesod( Yesod.hs,
> dist/build/Yesod.o
> > > > > >) Registering yesod-0.7.1...
> > > > > >[1 of 2] Compiling CodeGen  ( CodeGen.hs,
> > > > > >
> > > > > > dist/build/yesod/yesod-tmp/CodeGen.o )
> > > > > >
> > > > > >[2 of 2] Compiling Main ( scaffold.hs,
> > > > > >
> > > > > > dist/build/yesod/yesod-tmp/Main.o )
> > > > > >
> > > > > >Loading package ghc-prim ... linking ... done.
> > > > > >Loading package integer-gmp ... linking ... done.
> > > > > >Loading package base ... linking ... done.
> > > > > >Loading package bytestring-0.9.1.10 ... linking ... done.
> > > > > >Loading package base64-bytestring-0.1.0.2 ... linking ...
> done.
> > > > > >Loading package array-0.3.0.2 ... linking ... done.
> > > > > >Loading package containers-0.4.0.0 ... linking ... done.
> > > > > >Loading package cereal-0.3.0.0 ... linking ... done.
> > > > > >Loading package filepath-1.2.0.0 ... linking ... done.
> > > > > >Loading package old-locale-1.0.0.2 ... linking ... done.
> > > > > >Loading package old-time-1.0.0.6 ... linking ... done.
> > > > > >Loading package unix-2.4.2.0 ... linking ... done.
> > > > > >Loading package directory-1.1.0.0 ... linking ... done.
> > > > > >Loading package binary-0.5.0.2 ... linking ... done.
> > > > > >Loading package data-default-0.2.0.1 ... linking ... done.
> > > > > >Loading package tagged-0.2 ... linking ... done.
> > > > > >Loading package crypto-api-0.5.2 ... linking ... done.
> > > > > >Loading package pureMD5-2.1.0.3 ... linking ... done.
> > > > > >Loading package pretty-1.0.1.2 ... linking ... done.
> > > > > >Loading package template-haskell ... linking ... done.
> > > > > >Loading package transformers-0.2.2.0 ... linking ... done.
> > > > > >Loading package deepseq-1.1.0.2 ... linking ... done.
> > > > > >Loading package text-0.11.0.5 ... linking ... done.
> > > > > >Loading package blaze-builder-0.2.1.4 ... linking ... done.
> > > > > >Loading package blaze-html-0.4.1.0 ... linking ... done.
> > > > > >Loading package file-embed-0.0.3.1 ... linking ... done.
> > > > > >Loading package time-1.2.0.3 ... linking ... done.
> > > > > >Loading package unix-compat-0.2.1.1 ... linking ... done.
> > > > > >Loading package enumerator-0.4.7 ... linking ... done.
> > > > > >Loading package mtl-2.0.1.0 ... linking ... done.
> > > > > >Loading package parsec-3.1.1 ... linking ... done.
> > > > > >Loading package network-2.2.1.10 ... linking ... done.
> > > > > >Loading package wai-0.3.2 ... linking ... done.
> > > > > >Loading package utf8-string-0.3.6 ... linking ... done.
> > > > > >Loading package web-routes-0.23.4 ... linking ... done.
> > > > > >Loading package wai-app-static-0.0.1.1 ... linking ... done.
> > > > > >Loading package random-1.0.0.3 ... linking ... done.
> > > > > >Loading package clientsession-0.4.1 ... linking ... done.
> > > > > >Loading pa

Re: [Haskell-cafe] Yesod 0.7.1 using GHC 7.0.2 on Arch Linux

2011-03-13 Thread Ertugrul Soeylemez
I know, but at least I can go on with development.  I hope, the problem
will be fixed soon.


vagif.ve...@gmail.com wrote:

> No, it is not solved.
> With -fproduction flag you are loosing devel-server functionality.
> 
> On Saturday, March 12, 2011 02:45:11 PM Ertugrul Soeylemez wrote:
> > Oh, I just noticed the other thread about this issue.  Compiling Yesod
> > with the -fproduction flag solved it.
> > 
> > Thanks to Michael for that.
> > 
> > 
> > Greets,
> > Ertugrul
> > 
> > Ertugrul Soeylemez  wrote:
> > > Hello Ryan,
> > > 
> > > thanks a lot.
> > > 
> > > Is there a workaround for this, until it's fixed?
> > > 
> > > 
> > > Greets,
> > > Ertugrul
> > > 
> > > Ryan Yates  wrote:
> > > > Looks to be reported here:
> > > > 
> > > > http://hackage.haskell.org/trac/ghc/ticket/5004
> > > > 
> > > > 
> > > > Ryan
> > > > 
> > > > On Sat, Mar 12, 2011 at 3:26 PM, Ertugrul Soeylemez  
> > > > wrote:
> > > > > Hello there,
> > > > > 
> > > > > today I have upgraded to GHC 7.0.2 by doing a system update on my
> > > > > Arch Linux box (x86, 32 bits), and I'm having difficulties to
> > > > > install Yesod. Its dependencies seem to have been installed without
> > > > > problems, but the
> > > > > 
> > > > > Yesod package itself fails.  The complete build log follows:
> > > > >% cabal install yesod
> > > > >Resolving dependencies...
> > > > >Configuring yesod-0.7.1...
> > > > >Preprocessing library yesod-0.7.1...
> > > > >Preprocessing executables for yesod-0.7.1...
> > > > >Building yesod-0.7.1...
> > > > >[1 of 1] Compiling Yesod( Yesod.hs, dist/build/Yesod.o
> > > > >) Registering yesod-0.7.1...
> > > > >[1 of 2] Compiling CodeGen  ( CodeGen.hs,
> > > > > 
> > > > > dist/build/yesod/yesod-tmp/CodeGen.o )
> > > > > 
> > > > >[2 of 2] Compiling Main ( scaffold.hs,
> > > > > 
> > > > > dist/build/yesod/yesod-tmp/Main.o )
> > > > > 
> > > > >Loading package ghc-prim ... linking ... done.
> > > > >Loading package integer-gmp ... linking ... done.
> > > > >Loading package base ... linking ... done.
> > > > >Loading package bytestring-0.9.1.10 ... linking ... done.
> > > > >Loading package base64-bytestring-0.1.0.2 ... linking ... done.
> > > > >Loading package array-0.3.0.2 ... linking ... done.
> > > > >Loading package containers-0.4.0.0 ... linking ... done.
> > > > >Loading package cereal-0.3.0.0 ... linking ... done.
> > > > >Loading package filepath-1.2.0.0 ... linking ... done.
> > > > >Loading package old-locale-1.0.0.2 ... linking ... done.
> > > > >Loading package old-time-1.0.0.6 ... linking ... done.
> > > > >Loading package unix-2.4.2.0 ... linking ... done.
> > > > >Loading package directory-1.1.0.0 ... linking ... done.
> > > > >Loading package binary-0.5.0.2 ... linking ... done.
> > > > >Loading package data-default-0.2.0.1 ... linking ... done.
> > > > >Loading package tagged-0.2 ... linking ... done.
> > > > >Loading package crypto-api-0.5.2 ... linking ... done.
> > > > >Loading package pureMD5-2.1.0.3 ... linking ... done.
> > > > >Loading package pretty-1.0.1.2 ... linking ... done.
> > > > >Loading package template-haskell ... linking ... done.
> > > > >Loading package transformers-0.2.2.0 ... linking ... done.
> > > > >Loading package deepseq-1.1.0.2 ... linking ... done.
> > > > >Loading package text-0.11.0.5 ... linking ... done.
> > > > >Loading package blaze-builder-0.2.1.4 ... linking ... done.
> > > > >Loading package blaze-html-0.4.1.0 ... linking ... done.
> > > > >Loading package file-embed-0.0.3.1 ... linking ... done.
> > > > >Loading package time-1.2.0.3 ... linking ... done.
> > > > >Loading package unix-compat-0.2.1.1 ... linking ... done.
> > > > >Loading package enumerator-0.4.7 ... linking ... done.
> > > > >Loading package mtl-2.0.1.0 ... linking ... done.
> > > > >Loading package parsec-3.1.1 ... linking ... done.
> > > > >Loading package network-2.2.1.10 ... linking ... done.
> > > > >Loading package wai-0.3.2 ... linking ... done.
> > > > >Loading package utf8-string-0.3.6 ... linking ... done.
> > > > >Loading package web-routes-0.23.4 ... linking ... done.
> > > > >Loading package wai-app-static-0.0.1.1 ... linking ... done.
> > > > >Loading package random-1.0.0.3 ... linking ... done.
> > > > >Loading package clientsession-0.4.1 ... linking ... done.
> > > > >Loading package cookie-0.0.0 ... linking ... done.
> > > > >Loading package failure-0.1.0.1 ... linking ... done.
> > > > >Loading package extensible-exceptions-0.1.1.2 ... linking ...
> > > > >done. Loading package QuickCheck-2.4.0.1 ... linking ... done.
> > > > >Loading package blaze-builder-enumerator-0.2.0.1 ... linking ...
> > > > >done. Loading package json-types-0.1 ... linking ... done.
> > > > >Loading packag

Re: [Haskell-cafe] [Haskell] Linker flags for foreign export.

2011-03-13 Thread Jason Dusek
  I have managed to get both static and dynamic to work on
  Ubuntu; and I've set aside a repo on Github to collect notes
  on this stuff as I work out building on various systems.

https://github.com/solidsnack/hso

  I need rpath for the dynamic-dynamic case on Ubuntu:

ghc -shared -dynamic -o libfoo.dynamic-dynamic.so \
Foo.o Foo_stub.o fooinit.o \
-L/usr/lib/ghc-6.12.1 \
-optl-Wl,-rpath,/usr/lib/ghc-6.12.1 \
-lHSrts-ghc6.12.1

  The linker options in both cases could be derived
  automagically from ghc-pkg, I think.

  I've set aside dynamic-static for now (not sure what use it
  would be). It turns out there is a simpler way to write
  Foo_init:

extern void __stginit_Foo(void);
static void Foo_init (void) __attribute__ ((constructor));
void Foo_init (void) {
  int argc = 1;
  char *arg = "";
  char **argv = &arg;
  hs_init(&argc, &argv);
  hs_add_root(__stginit_Foo);
}

  Is there any case in which the empty string would be unsafe?

--
Jason Dusek
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

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


[Haskell-cafe] ANN: hsmagick 0.5

2011-03-13 Thread Vincent Gerard
Hello Haskellers,

I am currently taking over the maintainership of hsmagick, a FFI
bindings library to ImageMagick.

Therefore, I am pleased to announce the 0.5 release of hsmagick.

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

Major changes:
--
* imageToBlob and blobToImage functions using ByteStrings
* Use of ForeignPtr instead of Ptr as memory references representation.

Thanks to Steffen Siering patches, the internal representation has
been changed from Ptr to ForeignPtr. The finalization of ForeignPtr
should resolve space leaks issues.

* destroyImage function is exposed, to release the memory immediately.
* hsmagick builds with GHC 7

The source repository is now hosted on github
https://github.com/vincentg/hsmagick

Please, do not hesitate to contact me by email or with github for any
questions, requests, bugs, patches, anything about hsmagick.

Cheers,

Vincent Gerard

(Please make sure not to reply to hask...@haskell.org.)

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


Re: [Haskell-cafe] binary twidling modules

2011-03-13 Thread Don Stewart
Data.Binary or Data.Serialize perhaps? They provide encode/decode
functions for packing to binary formats:

 * cabal install binary
 * cabal install cereal

http://hackage.haskell.org/packages/archive/binary/0.5.0.2/doc/html/Data-Binary.html

On Sun, Mar 13, 2011 at 11:17 AM, rusi  wrote:
> I am not sure what would be the generic names I am asking for...
> examples are the nearest I can get.
>
> In perl there is pack/unpack http://perldoc.perl.org/perlpacktut.html
> Likewise in python there is struct module 
> http://docs.python.org/library/struct.html
>
> What is/are the Haskell equivalents?
>
> ___
> 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] binary twidling modules

2011-03-13 Thread rusi
I am not sure what would be the generic names I am asking for...
examples are the nearest I can get.

In perl there is pack/unpack http://perldoc.perl.org/perlpacktut.html
Likewise in python there is struct module 
http://docs.python.org/library/struct.html

What is/are the Haskell equivalents?

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