Re: [Haskell-cafe] question about Data.Binary and Double instance
On Tue, Apr 17, 2007 at 10:32:02AM -0700, David Roundy wrote: > I'm wondering what exactly inspired the decode/encodeFloat implementation I kind of wondered the same thing when I first saw it. Looks like it was just the quickest way to get it going. > Are there any suggestions how I could use Data.Binary to actually read a > binary file full of Doubles? Should I just use the Array interface, and > forget laziness and hopes of handling different-endian machines? Or is > there some way to reasonably do this using Data.Binary? I threw together a somewhat portable "longBitsToDouble" function a while ago for another project. http://darcs.brianweb.net/hsutils/src/Brianweb/Data/Float.lhs It doesn't depend on any unsafe operations or external ffi functions but it will only works on IEEE 754 machines (but that includes every machine ghc run on). It might not be fast enough for you though as it still goes via Integer in the conversion. -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] question about Data.Binary and Double instance
On Tue, Apr 17, 2007 at 12:18:29PM -0700, David Roundy wrote: > > machine ghc run on). It might not be fast enough for you though as it > > still goes via Integer in the conversion. > > It seems like this conversion shouldn't take any time at all, and we ought > to be able to just copy the memory right over, or just do a unsafeCoerce# > (which is admittedly unsafe, but in practice between a Word64 and a Double > should be fine)... True. I only wrote it that way so I wouldn't have to muck with low level details between haskell implementations. The right thing to do for Data.Binary is probably to just peek the Double off the ForeignPtr in the ByteString, no sense going through Word64 at all. -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] question about Data.Binary and Double instance
On Wed, Apr 18, 2007 at 12:34:58PM +1000, Duncan Coutts wrote: > We'd like to use IEEE format as the default Data.Binary serialisation > format for Haskell's Float and Double type, the only thing that makes > this tricky is doing it portably and efficiently. You should note that your current method of serializing Doubles (encodeFloat/decodeFloat) isn't portable either as the results of these functions depend on floatRadix. So using some method that depends on IEEE representation isn't much worse (might actually be better as you'd get an error at runtime rather than writing data that could potentially be read back as garbage). I think the only way to do this 100% portably is to encode it as a Rational before serializing. Also even if someone were to bother to write the code to convert from an arbitrary floating point rep to IEEE for serialization you'd run the risk losing information if the hosts floating point rep was more accurate that IEEE FP. It seems like it might come down to making a choice between 100% portable but incompatable with the default serialization mechanisms in other languages or non-portable (but ok for just about every popular arch used today) and compatable with other languages. > Perhaps we just don't care about ARM or other arches where GHC runs that Are there really any architectures supported by GHC that don't use IEEE floating point? If so GHC.Float is wrong as isIEEE is always true. -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] New book: Real-World Haskell!
On Wed, May 23, 2007 at 10:48:38PM -0700, Bryan O'Sullivan wrote: > >Number two on my wish list: interfacing with Java. > > The temptation to cover new and exciting material is of course strong. > LambdaVM is both, but it's also an in-progress one-person master's > project. We think we'd do best to focus on libraries and extensions > that are either distributed as standard or widely used. I think he was probably talking about this: http://semantic.org/jvm-bridge/ which is much more widely used than LambdaVM. Thanks for the LambdaVM plug though. -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implementations of bit vectors
On Sat, Nov 25, 2006 at 10:41:56AM -0200, Maur??cio wrote: > Does anyone knows of a nice implementation of bit vectors? > I like the functions I see in Data.Bits (rotate, shift etc.), > but that only works with predefined sizes and I need a bit > vector of exactly 33 bits. Check out http://darcs.brianweb.net/hsutils/src/Brianweb/Word.lhs It supports typesafe (and efficient) operations on words of any bit length (including 33-bits). You can also safely split and join words. The type system ensures concatenating a Word16 and a Word32 results in a Word48, etc. -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Lambada and connecting Haskell to a Weblogic server
On Thu, Feb 15, 2007 at 11:24:31AM -0800, Adam Megacz wrote: > You should check out Brian Alliet's LambdaVM: > > http://www.cs.rit.edu/~bja8464/lambdavm/ I think what is in darcs is actually broken right now (the base repo is out of sync with the ghc repo), but thanks for giving me a big incentive to fix it. If anyone is interested in playing with it drop me an email and I'll let you know when it works again. -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] LambdaVM (was Re: Lambada and connecting Haskell to a Weblogic server)
On Thu, Feb 15, 2007 at 02:53:47PM -0500, Mark T.B. Carroll wrote: > Is it easy to create Haskell stubs (in the IO monad, presumably) for > standard Java libraries so that your compiled-to-JVM Haskell code can > easily use the usual Java APIs like Swing? One source of vexation for us > is mapping between Java types and Haskell types. Yep. Normal FFI style foreign imports work. foreign import jvm unsafe "java.lang.Character.isDigit" isDigit :: Int -> Bool -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell on the JVM
On Mon, Oct 27, 2008 at 10:58:11AM +, Simon Peyton-Jones wrote: > Is there an interest in hosting GHC on the JVM (besides my own). Yep. I wrote a JVM backend for GHC (LambdaVM). It is suffering from bit-rot though. I think this thread has re-spaked my interest in it though. > I don't think it's so hard to translate GHC's Core language to the > JVM. Definitely not. That is more or less the route I took (I actually transform STG it into yet another simple intermediate laguage that is more JVM friendly, this was more for optimization purposes though). While C-- looks fantastic for generating native code, it just didn't seem worth the effort to shoehorn it into the JVM. Although I haven't looked at any of the new backend stuff, I suspect it still won't be suitable for the JVM. -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell and Java
On Wed, Sep 10, 2008 at 02:12:00PM +0200, Marc Weber wrote: > There used to be. > http://www.cs.rit.edu/~bja8464/lambdavm/ > (Last darcs change log entry: > Sun Oct 21 03:05:20 CEST 2007 Brian Alliet <[EMAIL PROTECTED]> > * fix build for hsjava change > ) Sorry about this. I hit a critical mass of darcs conflicts (I look forward to giving git a try) around the same time I got really busy at work. I've been meaning to get back into it (and update it to GHC HEAD) but I haven't received sufficient nagging yet. Please yell if you're interested in LambdaVM. At the very least I should be able to help get whatever is in darcs compiling. -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haskell and Java
On Wed, Sep 10, 2008 at 09:50:36PM -0300, Mauricio wrote: > Would it allow allow Haskell to also call Java code, > besides running in JVM? Yep. LambdaVM can fully access existing Java code. The base library heavily uses FFI to access java.io.* to implement Handle, etc. 'foreign export' even works so you can call back into Haskell from Java. For more information see: http://wiki.brianweb.net/LambdaVM/FFI -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GSOC idea: Haskell JVM bytecode library
On Fri, Mar 26, 2010 at 08:01:57PM +, Alexandru Scvortov wrote: > I'm thinking of writing a library for analyzing/generating/manipulating JVM > bytecode. To be clear, this library would allow one to load and work with > JVM > classfiles; it wouldn't be a compiler, interpretor or a GHC backend. I wrote a JVM classfile library as part of LambdaVM (which is actually a JVM backend for GHC, it is a bit bit-rotted though, I need to get back into it): http://darcs.brianweb.net/hsjava/ It requires my hsutils library (also available on darcs.brianweb.net). I haven't touched the code in a while and it might need a tweak or two with recent GHC versions. Drop me a line if you have any trouble getting it working (and patches are certainly welcome). There isn't much documentation, besides the code and a few example programs that dump a pretty printed version of the data structure. I'd be more than happy to give anybody who is interested in using it some pointers though. -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe