Re: [Haskell-cafe] Data.Bitmap, readBitmap exception

2012-06-29 Thread Balazs Komuves
Hello,

Author of Data.Bitmap here. The issue is caused by the fact that
Data.Bitmap does *not* support
bmp files at all. This should be clear from the documentation. The
functions you tried to used use
their own file format, which a really very simple format; they are only
added for simple experimentation.
(again, this is explicit in the docs). The same documentation points to the
stb-image [1] package,
 which supports loading of some common formats (png, jpg, bmp).

In general, I suggest that with package-specific question, unless it is a
widely used package,
mail the maintainer directly; you have better chance to get an answer that
way.

Regards,
Balazs

[1] http://hackage.haskell.org/package/stb-image

Hello,

 I am using bitmap-0.2 [1] to load a Bitmap file [2]. However, the
 following sample GHCi session fails for me.

  Prelude Data.Bitmap Data.Bitmap.Pure.File readBitmap b.bmp :: IO
 (Bitmap Word8)
  *** Exception: Data/Bitmap/Internal.hs:(63,17)-(67,15): Non-exhaustive
 patterns in case

 I downloaded the sources of bitmap-0.2 from Hackage and modified the
 relevant function by appending the last line.

  decodeCType :: CInt - PixelComponentType
  decodeCType k = case k of
1 - PctWord8
2 - PctWord16
3 - PctWord32
4 - PctFloat
_ - error $ decodeCType: unexpected integer ( ++ show k ++ )

 With this modification the same GHCi session given above results in
 the following error.

  Prelude Data.Bitmap Data.Bitmap.Pure.File readBitmap b.bmp :: IO
 (Bitmap Word8)
  *** Exception: decodeCType: unexpected integer (7077888)

 I don't have any idea where 7077888 comes from. Am I doing something
 wrong? Is my bitmap corrupted in some way? The number 7077888 has no
 apparent significance except that it is a perfect cube [3]. So I guess
 this is not a problem with endianness.

 In fact as far as I can tell `decodeCType` is only called on
 `(PixelComponent t = c_type t)` and `c_type t` only yields integer
 values in the (inclusive) range of 1 to 4. That is if I am not missing
 some orphaned instance.

 Could anyone please enlighten me what is happening and if I am doing
 something wrong?

 In case this is relevant: I am using bitmap-0.2 from Hackage with GHC
 7.4.1 on a 3.2.20 kernel i686 architecture Linux.

 Regards,
 Alexander Foremny

 [1] http://hackage.haskell.org/package/bitmap
 [2] https://www.dropbox.com/s/pyutvni9vx6f6mo/b.bmp
 [3] http://www.wolframalpha.com/input/?i=7077888

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


Re: [Haskell-cafe] ANN: combinatorics

2012-01-30 Thread Balazs Komuves
 
 -- combinatorics 0.1.0
 

 The combinatorics package offers efficient *exact* computation of common
 combinatorial functions like the binomial coefficients and factorial.
 (For fast *approximations*, see the math-functions package instead.)



Shameless self-promotion: The combinat package (which deliberately
does not try to own the valuable namespace Math.Combinatorics) is
a more extensive combinatorics library:

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

While the main focus is the generation of combinatorial objects themselves,
counting functions and common number sequences like the above are
also offered.

Even though the binomial and factorial definition in this package are the
naive ones, a quick experiment imply that the differences start show
themselves around 100,000 factorial, or choosing 50,000 elements out
of 100,000, which is probably a rather specialized use case.

The primes function in the combinat package is based on an old Cafe
thread, and actually seems to be faster than the one in the combinatorics
package.

In any case, I may switch to the faster algorithms in the future :)

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