
I just wrote a small module for dealing with half-integers. (That is, any number I/2 where I is an integer. Note that the set of integers is a subset of this; Wikipedia seems to reserve "half-integer" for such numbers that are *not* integers.) module HalfInteger where data HalfInteger i instance (Eq i) => Eq (HalfInteger i) instance (Ord i) => Ord (HalfInteger i) instance (Integral i) => Show (HalfInteger i) instance (Integral i) => Num (HalfInteger i) half :: (Num i) => HalfInteger i fromNum :: (Integral i, RealFrac x) => x -> HalfInteger i toNum :: (Integral i, Fractional x) => HalfInteger i -> x isInteger :: (Integral i) => HalfInteger i -> Bool Note carefully that the set of half-integers is *not* closed under multiplication! This means that for certain arguments, there are two reasonable products that could be returned. (E.g., 1/2 * 1/2 = 1/4, so 0 or 1/2 would be a reasonable rounding.) I haven't put a lot of effort into the rounding details of (*) or fromNum; which answer you get is kind of arbitrary. (However, addition and subtraction are exact, and for multiplications where an exact result is possible, you will get that result.) The Show instance outputs strings such as fromInteger 5 fromInteger 5 + half fromInteger (-5) - half depending on the isInteger predicate. Now, the question is... Is this useful enough to be worth putting on Hackage?

Felipe Lessa wrote:
On Sun, Jun 28, 2009 at 02:24:30PM +0100, Andrew Coppin wrote:
Now, the question is... Is this useful enough to be worth putting on Hackage?
Why not? :)
Just upload it! I mean, at any point in time most package on hackage will be useless _to_me_. That doesn't mean they won't become useful in the future, and it certainly doesn't mean that someone else won't find them useful right now. :-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

2009/6/28 Andrew Coppin
Felipe Lessa wrote:
On Sun, Jun 28, 2009 at 02:24:30PM +0100, Andrew Coppin wrote:
Now, the question is... Is this useful enough to be worth putting on Hackage?
Why not? :)
Well, it *does* mean I'll have to figure out how Cabal actually works...
Usually, it's pretty straight-forward and most options are self-explanatory. http://en.wikibooks.org/wiki/Haskell/Packaging#The_Cabal_file -- Deniz Dogan

Deniz Dogan wrote:
2009/6/28 Andrew Coppin
: Felipe Lessa wrote:
On Sun, Jun 28, 2009 at 02:24:30PM +0100, Andrew Coppin wrote:
Now, the question is... Is this useful enough to be worth putting on Hackage?
Why not? :)
Well, it *does* mean I'll have to figure out how Cabal actually works...
Usually, it's pretty straight-forward and most options are self-explanatory. http://en.wikibooks.org/wiki/Haskell/Packaging#The_Cabal_file
Yes, one would *hope* that a 1-module library with no dependencies would be fairly trivial. ;-) Also Haddock; I'm thinking some documentation might be nice...

Andrew Coppin wrote:
Deniz Dogan wrote:
2009/6/28 Andrew Coppin
: Well, it *does* mean I'll have to figure out how Cabal actually works...
Usually, it's pretty straight-forward and most options are self-explanatory. http://en.wikibooks.org/wiki/Haskell/Packaging#The_Cabal_file
Yes, one would *hope* that a 1-module library with no dependencies would be fairly trivial. ;-)
Ah, but it's not as easy as you'd think. The instructions above fail to mention several required or strongly recommended fields. (E.g., apparently Category and Synopsis are both required, Cabal-Version is strongly recommended, several fields are meant to be in the Library subsection...) And then of course there's the question of choosing a licence. But I think I'm nearly there now. Oh, one last thing. I know I'm going to regret this for the rest of my life, but... which version of Base should it depend on?
Also Haddock; I'm thinking some documentation might be nice...
This at least *was* fairly trivial. ;-) [The only hard part being figuring out how to manually run Haddock...]

Antoine Latter wrote:
On Sun, Jun 28, 2009 at 2:13 PM, Andrew Coppin
wrote: Oh, one last thing. I know I'm going to regret this for the rest of my life, but... which version of Base should it depend on?
Which versions of base have you tested it with? :-)
Whichever one GHC 6.10.3 ships with... Frankly, I highly doubt it makes any difference either way. (Does anybody know how base3 differs from base4?) It only uses a few type classes from the Prelude...

On Sun, Jun 28, 2009 at 9:29 PM, Andrew
Coppin
Which versions of base have you tested it with? :-)
Whichever one GHC 6.10.3 ships with...
"ghc-pkg list base" will tell you which version you have installed.
Frankly, I highly doubt it makes any difference either way. (Does anybody know how base3 differs from base4?) It only uses a few type classes from the Prelude...
If it *only* uses the prelude (i.e., does not include *any* modules), then it should work with any version of base. --Max

Max Rabkin wrote:
On Sun, Jun 28, 2009 at 9:29 PM, Andrew Coppin
wrote: Which versions of base have you tested it with? :-)
Whichever one GHC 6.10.3 ships with...
"ghc-pkg list base" will tell you which version you have installed.
Which tells me I have base-3.0.3.1 *and* base-4.1.0.0 ;-)
Frankly, I highly doubt it makes any difference either way. (Does anybody know how base3 differs from base4?) It only uses a few type classes from the Prelude...
If it *only* uses the prelude (i.e., does not include *any* modules), then it should work with any version of base.
Yeah, that's what I figured... Alrighty then, so how I just do Setup configure, and now Setup sdist, and then I can upload the result to Ha-- oh, don't be silly. That would simply be too easy. ;-) E:\Haskell\AOC-HalfInteger>runhaskell Setup sdist Building source dist for AOC-HalfInteger-1.0... Preprocessing library AOC-HalfInteger-1.0... Setup: tar is required but it could not be found. Time to go search the web and find out what the other 50 people who stumbled into this did... *sigh*

Andrew Coppin wrote:
Alrighty then, so how I just do Setup configure, and now Setup sdist, and then I can upload the result to Ha-- oh, don't be silly. That would simply be too easy. ;-)
E:\Haskell\AOC-HalfInteger>runhaskell Setup sdist Building source dist for AOC-HalfInteger-1.0... Preprocessing library AOC-HalfInteger-1.0... Setup: tar is required but it could not be found.
Time to go search the web and find out what the other 50 people who stumbled into this did... *sigh*
Ah. Apparently it's "fixed": http://hackage.haskell.org/trac/hackage/ticket/40 Except that it isn't fixed. Yay for me... It seems that GHC provides ar but not tar. Looks like I might actually have to copy the entire directory tree to a Linux box just so I can run sdist... Nice to know this stuff is so easy. :-/

On Sun, Jun 28, 2009 at 3:42 PM, Andrew
Coppin
Andrew Coppin wrote:
Alrighty then, so how I just do Setup configure, and now Setup sdist, and then I can upload the result to Ha-- oh, don't be silly. That would simply be too easy. ;-)
E:\Haskell\AOC-HalfInteger>runhaskell Setup sdist Building source dist for AOC-HalfInteger-1.0... Preprocessing library AOC-HalfInteger-1.0... Setup: tar is required but it could not be found.
Time to go search the web and find out what the other 50 people who stumbled into this did... *sigh*
Ah. Apparently it's "fixed":
http://hackage.haskell.org/trac/hackage/ticket/40
Except that it isn't fixed. Yay for me...
It seems that GHC provides ar but not tar. Looks like I might actually have to copy the entire directory tree to a Linux box just so I can run sdist... Nice to know this stuff is so easy. :-/
I don't know anything that's gauranteed to work, as I've never tried packaging from a Windows box, but: - Is 'htar' a good enough 'tar' replacement for cabal? - Does cabal-install also require an external tar? You could try "cabal sdist" Antoine

On Sun, Jun 28, 2009 at 4:11 PM, Antoine Latter
On Sun, Jun 28, 2009 at 3:42 PM, Andrew Coppin
wrote: Andrew Coppin wrote:
Alrighty then, so how I just do Setup configure, and now Setup sdist, and then I can upload the result to Ha-- oh, don't be silly. That would simply be too easy. ;-)
E:\Haskell\AOC-HalfInteger>runhaskell Setup sdist Building source dist for AOC-HalfInteger-1.0... Preprocessing library AOC-HalfInteger-1.0... Setup: tar is required but it could not be found.
Time to go search the web and find out what the other 50 people who stumbled into this did... *sigh*
Ah. Apparently it's "fixed":
Except that it isn't fixed. Yay for me...
It seems that GHC provides ar but not tar. Looks like I might actually have to copy the entire directory tree to a Linux box just so I can run sdist... Nice to know this stuff is so easy. :-/
I don't know anything that's gauranteed to work, as I've never tried packaging from a Windows box, but:
- Is 'htar' a good enough 'tar' replacement for cabal? - Does cabal-install also require an external tar? You could try "cabal sdist"
If one actually reads the discussion in the ticket, it is clear that the conclusion was to have cabal-install handle it and that cabal-install uses it's own tar implementation.

Derek Elkins wrote:
On Sun, Jun 28, 2009 at 4:11 PM, Antoine Latter
wrote: On Sun, Jun 28, 2009 at 3:42 PM, Andrew Coppin
wrote: Ah. Apparently it's "fixed":
http://hackage.haskell.org/trac/hackage/ticket/40
Except that it isn't fixed. Yay for me.. If one actually reads the discussion in the ticket, it is clear that the conclusion was to have cabal-install handle it and that cabal-install uses it's own tar implementation.
This was not at all clear to me from reading the ticker. OK, so I need to find another seperate tool in order to do this. I guess not every single Haskell user tries to release stuff to Hackage, while presumably most users want to install stuff from it. I could just about live with that. However, the following important question remains: If sdist is broken on Windows, and the developers know this, why does it just die with an unhelpful message? Why does it not say "this functionallity is not supported; you need to get this tool..."? Why did I have to do a custom search of closed tickets on the Trac to even find this information? Why is this not written in big, huge letters in the user guide? The fact that this is broken by default on every Windows box in the land seems like a rather big deal... Seriously... when the next person behind me comes along and tries to do this, they're going to trip over in exactly the same way. All the Cabal guides I've seen so far recommend the use of sdist. (And, indeed, on any other OS it presumably works. It's just another thing you have to do differently if you happen to be on Windows.) GHC already ships with Cabal, and half a dozen GNU utilities; would it have been so hard to just add tar.exe? Anyway, I now [hopefully] have a way to fix my immediate problem. I hope the people in charge will do something to help the next guy behind me...

On Mon, Jun 29, 2009 at 1:03 PM, Andrew
Coppin
This was not at all clear to me from reading the ticker.
OK, so I need to find another seperate tool in order to do this. I guess not every single Haskell user tries to release stuff to Hackage, while presumably most users want to install stuff from it. I could just about live with that. However, the following important question remains: If sdist is broken on Windows, and the developers know this, why does it just die with an unhelpful message? Why does it not say "this functionallity is not supported; you need to get this tool..."? Why did I have to do a custom search of closed tickets on the Trac to even find this information? Why is this not written in big, huge letters in the user guide? The fact that this is broken by default on every Windows box in the land seems like a rather big deal...
Seriously... when the next person behind me comes along and tries to do this, they're going to trip over in exactly the same way. All the Cabal guides I've seen so far recommend the use of sdist. (And, indeed, on any other OS it presumably works. It's just another thing you have to do differently if you happen to be on Windows.)
GHC already ships with Cabal, and half a dozen GNU utilities; would it have been so hard to just add tar.exe?
Anyway, I now [hopefully] have a way to fix my immediate problem. I hope the people in charge will do something to help the next guy behind me...
Personally, I've never used "runhaskell Setup sdist" and I've only ever used "cabal sdist". But I'm not sure where I learned that. I think cabal-install is a pretty standard util for people to have, and it ships with the Haskell platform now. So the big hurdle is documentation. Andrew - where does it state that "Setup sdist" is the recommended way of doing this? If it's a wiki you could go and edit it yourself. Antoine

Antoine Latter wrote:
Personally, I've never used "runhaskell Setup sdist" and I've only ever used "cabal sdist". But I'm not sure where I learned that.
I think cabal-install is a pretty standard util for people to have, and it ships with the Haskell platform now. So the big hurdle is documentation.
Indeed. I've heard a few people claim that cabal-install is the best thing since sliced bread, but I've never touched it. I don't even know where to get it. (Presumably this will become fairly obvious once I go look for it...)
Andrew - where does it state that "Setup sdist" is the recommended way of doing this? If it's a wiki you could go and edit it yourself.
The link posted earlier: http://en.wikibooks.org/wiki/Haskell/Packaging#The_Cabal_file I'm pretty sure there's some essentially similar content on the Haskell wiki. (Or there was... I don't know if it got removed when this was put up.) The Cabal manual itself mentions absolutely nothing about cabal-install, as far as I can tell. (At least, I didn't see anything about it while I was looking up the *.cabal format nor the command invocation syntax.) It's news to me that cabal-install ships with the Haskell Platform. (Can you tell how much I've tried out the Platform?) I'm still not completely understanding the direction we're going with this - but that's for another email...

Andrew Coppin wrote:
Indeed. I've heard a few people claim that cabal-install is the best thing since sliced bread, but I've never touched it. I don't even know where to get it. (Presumably this will become fairly obvious once I go look for it...)
Fortunately, it turns out that a trivial Google search is all that is required to locate cabal-install. (Assuming you already know it exists.) Unfortunately I got as far as actually downloading the sources from Hackage before discovering that on Windows you actually need to download the pre-build binary. (Couldn't you mention this on the Hackage download page?) Also fortunately, it appears to be pretty trivial to operate cabal-install. I didn't bother reading any instructions, just cabal --help. (Not sure why it needs to download the package list from Hackage - or where it puts it. But I'm sure there's a good reason.) Rather less fortunately, it still doesn't actually fix my problem: E:\Haskell\AOC-HalfInteger>cabal configure Resolving dependencies... Configuring AOC-HalfInteger-1.0... E:\Haskell\AOC-HalfInteger>cabal sdist Building source dist for AOC-HalfInteger-1.0... Preprocessing library AOC-HalfInteger-1.0... Source tarball created: dist\AOC-HalfInteger-1.0.tar.gz cabal: dist\src\sdist.1288\AOC-HalfInteger-1.0\Data\HalfInteger.hs: removeFile: permission denied (Permission denied) I have no idea what the hell it's upset about now... I've now been trying to create this damned tarball since 5PM yesterday, and I still haven't managed it. At this point I'm losing the will to continue with this crazy project. Clearly this is way too much effort to expend just to upload 50 lines of code.

On Mon, Jun 29, 2009 at 11:57 AM, Andrew Coppin wrote: Andrew Coppin wrote: Indeed. I've heard a few people claim that cabal-install is the best thing
since sliced bread, but I've never touched it. I don't even know where to
get it. (Presumably this will become fairly obvious once I go look for
it...) Fortunately, it turns out that a trivial Google search is all that is
required to locate cabal-install. (Assuming you already know it exists.)
Unfortunately I got as far as actually downloading the sources from Hackage
before discovering that on Windows you actually need to download the
pre-build binary. (Couldn't you mention this on the Hackage download page?) Also fortunately, it appears to be pretty trivial to operate cabal-install.
I didn't bother reading any instructions, just cabal --help. (Not sure why
it needs to download the package list from Hackage - or where it puts it.
But I'm sure there's a good reason.) Rather less fortunately, it still doesn't actually fix my problem: E:\Haskell\AOC-HalfInteger>cabal configure
Resolving dependencies...
Configuring AOC-HalfInteger-1.0... E:\Haskell\AOC-HalfInteger>cabal sdist
Building source dist for AOC-HalfInteger-1.0...
Preprocessing library AOC-HalfInteger-1.0...
Source tarball created: dist\AOC-HalfInteger-1.0.tar.gz
cabal: dist\src\sdist.1288\AOC-HalfInteger-1.0\Data\HalfInteger.hs:
removeFile: permission denied (Permission denied) I have no idea what the hell it's upset about now... I've now been trying
to create this damned tarball since 5PM yesterday, and I still haven't
managed it. At this point I'm losing the will to continue with this crazy
project. Clearly this is way too much effort to expend just to upload 50
lines of code. I can't say for certain, but just reading the output it looks like it
created a tarball in a temporary folder (that worked) and then when it tried
to clean it up it failed. Sounds like a bug report is in order.
Jason

On Mon, Jun 29, 2009 at 2:12 PM, Jason Dagit
I can't say for certain, but just reading the output it looks like it created a tarball in a temporary folder (that worked) and then when it tried to clean it up it failed. Sounds like a bug report is in order.
You may want to check the "dist" subdirectory of the folder you're working in to see if it made the tarball. Antoine

Jason Dagit wrote:
On Mon, Jun 29, 2009 at 11:57 AM, Andrew Coppin
mailto:andrewcoppin@btinternet.com> wrote: Rather less fortunately, it still doesn't actually fix my problem:
E:\Haskell\AOC-HalfInteger>cabal configure Resolving dependencies... Configuring AOC-HalfInteger-1.0...
E:\Haskell\AOC-HalfInteger>cabal sdist
Building source dist for AOC-HalfInteger-1.0... Preprocessing library AOC-HalfInteger-1.0... Source tarball created: dist\AOC-HalfInteger-1.0.tar.gz cabal: dist\src\sdist.1288\AOC-HalfInteger-1.0\Data\HalfInteger.hs: removeFile: permission denied (Permission denied)
I have no idea what the hell it's upset about now... I've now been trying to create this damned tarball since 5PM yesterday, and I still haven't managed it. At this point I'm losing the will to continue with this crazy project. Clearly this is way too much effort to expend just to upload 50 lines of code.
I can't say for certain, but just reading the output it looks like it created a tarball in a temporary folder (that worked) and then when it tried to clean it up it failed. Sounds like a bug report is in order.
So, yet again, it appears I'm the first poor soul to try using this on Windows. The very first time I tried to use Gtk2hs, the installer for Windows was trivially broken. In fairness, Duncan fixed this within an hour or two of me pointing out the problem. But the fact remains: It had been out for a week, and I was the *only* person to have tried to use it on Windows. (Or possibly the only person to actually complain, rather than just give up.) Don kept telling me about some cool Core syntax hilighter he wrote, so I went to all the trouble of downloading it, downloading and building all of its dependencies, only to discover "oh, by the way, it only works on Linux". A while back Cabal had a bug where (on Windows only) it couldn't find ld or something daft. [Again, fortunately that one got corrected - eventually - in the next GHC release.] I try to run sdist, and discover that that's broken on Windows too. But don't worry, there's a replacement tool... which is also broken on Windows... This is an exercise in pure frustration! Sometimes it seems as if *everything* is broken on Windows. Hmm... I'm just ranting now. One presumes that when they "fixed" cabal sdist to work on Windows, at least one person checked that it did, in fact, work. That would mean it got broken again at some point after this. Maybe I just need to find an older version or something... And after that... I guess I create *another* account on *another* bug tracker and submit *another* "hey, this is broken on Windows" ticket...

I presume that many of the developers do not have windows machines (presumably because windows sucks). Maybe you could help them by trying to track down where the error in the code is, and even better yet submitting a patch? This is all free by the virtue of people giving what time they can, and if you don't happen to have a windows box to test on, it can be very hard to provide compatibility for it. Same in the reverse direction. -Ross On Jun 29, 2009, at 3:55 PM, Andrew Coppin wrote:
Jason Dagit wrote:
On Mon, Jun 29, 2009 at 11:57 AM, Andrew Coppin
mailto:andrewcoppin@btinternet.com> wrote: Rather less fortunately, it still doesn't actually fix my problem:
E:\Haskell\AOC-HalfInteger>cabal configure Resolving dependencies... Configuring AOC-HalfInteger-1.0...
E:\Haskell\AOC-HalfInteger>cabal sdist
Building source dist for AOC-HalfInteger-1.0... Preprocessing library AOC-HalfInteger-1.0... Source tarball created: dist\AOC-HalfInteger-1.0.tar.gz cabal: dist\src\sdist.1288\AOC-HalfInteger-1.0\Data\HalfInteger.hs: removeFile: permission denied (Permission denied)
I have no idea what the hell it's upset about now... I've now been trying to create this damned tarball since 5PM yesterday, and I still haven't managed it. At this point I'm losing the will to continue with this crazy project. Clearly this is way too much effort to expend just to upload 50 lines of code.
I can't say for certain, but just reading the output it looks like it created a tarball in a temporary folder (that worked) and then when it tried to clean it up it failed. Sounds like a bug report is in order.
So, yet again, it appears I'm the first poor soul to try using this on Windows.
The very first time I tried to use Gtk2hs, the installer for Windows was trivially broken. In fairness, Duncan fixed this within an hour or two of me pointing out the problem. But the fact remains: It had been out for a week, and I was the *only* person to have tried to use it on Windows. (Or possibly the only person to actually complain, rather than just give up.) Don kept telling me about some cool Core syntax hilighter he wrote, so I went to all the trouble of downloading it, downloading and building all of its dependencies, only to discover "oh, by the way, it only works on Linux". A while back Cabal had a bug where (on Windows only) it couldn't find ld or something daft. [Again, fortunately that one got corrected - eventually - in the next GHC release.] I try to run sdist, and discover that that's broken on Windows too. But don't worry, there's a replacement tool... which is also broken on Windows... This is an exercise in pure frustration! Sometimes it seems as if *everything* is broken on Windows.
Hmm... I'm just ranting now. One presumes that when they "fixed" cabal sdist to work on Windows, at least one person checked that it did, in fact, work. That would mean it got broken again at some point after this. Maybe I just need to find an older version or something...
And after that... I guess I create *another* account on *another* bug tracker and submit *another* "hey, this is broken on Windows" ticket...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Ross Mellgren wrote:
I presume that many of the developers do not have windows machines (presumably because windows sucks). Maybe you could help them by trying to track down where the error in the code is, and even better yet submitting a patch?
This is all free by the virtue of people giving what time they can, and if you don't happen to have a windows box to test on, it can be very hard to provide compatibility for it. Same in the reverse direction.
-Ross
Well, Duncan informs me that he's just set up a Windows XP VM for this exact reason... Still, I guess this problem will only really be solved once he have large quantities of Windows users hitting this stuff. Indeed, Duncan seems to be one of the more helpful inhabitants of the Haskell IRC channel. I talked to him tonight, and he's already fixed some of the documentation issues I pointed out earlier, and done a preliminary analysis of the sdist bug. (It's filed as ticket #565 now, by the way.) Anyway, for the time being, cabal-install does in fact generate the tarball, it's just tripping over trying to delete the temp files afterwards. So I can still uplo-- wait, you need an account? Is anything ELSE going to stop me?? Time for bed, I think...

On Mon, Jun 29, 2009 at 12:55 PM, Andrew Coppin wrote: This is an exercise in pure frustration! Sometimes it seems as if *everything* is broken on Windows. In my opinion you're right, Windows, and things built on it, tend to be very
broken. Maybe that's why so many of the Haskell devs aren't using Windows? Hmm... I'm just ranting now. Yes, you are :) You'll catch more flies with honey than vinegar.
Good luck,
Jason

Antoine Latter wrote:
Personally, I've never used "runhaskell Setup sdist" and I've only ever used "cabal sdist". But I'm not sure where I learned that.
I think cabal-install is a pretty standard util for people to have, and it ships with the Haskell platform now. So the big hurdle is documentation.
Andrew - where does it state that "Setup sdist" is the recommended way of doing this? If it's a wiki you could go and edit it yourself.
Start from the Hackage homepage: http://hackage.haskell.org/packages/hackage.html Click on "how to create a Haskell package", takes you to http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program Section 2.10.1.1 shows you how to create a tarball - using setup sdist rather than cabal sdist. Indeed, I don't think cabal-install is mentioned anywhere. If people seriously want this to become the preferred way to do things, it needs to be much more prominently documented.

On Sun, Jun 28, 2009 at 15:24, Andrew Coppin
I just wrote a small module for dealing with half-integers. (That is, any number I/2 where I is an integer. Note that the set of integers is a subset of this; Wikipedia seems to reserve "half-integer" for such numbers that are *not* integers.)
module HalfInteger where
data HalfInteger i
instance (Eq i) => Eq (HalfInteger i) instance (Ord i) => Ord (HalfInteger i) instance (Integral i) => Show (HalfInteger i) instance (Integral i) => Num (HalfInteger i)
half :: (Num i) => HalfInteger i
fromNum :: (Integral i, RealFrac x) => x -> HalfInteger i toNum :: (Integral i, Fractional x) => HalfInteger i -> x
isInteger :: (Integral i) => HalfInteger i -> Bool
Note carefully that the set of half-integers is *not* closed under multiplication! This means that for certain arguments, there are two reasonable products that could be returned. (E.g., 1/2 * 1/2 = 1/4, so 0 or 1/2 would be a reasonable rounding.) I haven't put a lot of effort into the rounding details of (*) or fromNum; which answer you get is kind of arbitrary. (However, addition and subtraction are exact, and for multiplications where an exact result is possible, you will get that result.)
The Show instance outputs strings such as
fromInteger 5 fromInteger 5 + half fromInteger (-5) - half
depending on the isInteger predicate.
Now, the question is... Is this useful enough to be worth putting on Hackage?
Out of curiosity, what are *you* using it for? Thomas

Thomas ten Cate wrote:
Out of curiosity, what are *you* using it for?
Centering things. In you have an odd number of items, the middle one will be at position 0, with the others at integer positions on either side. However, if you have an even number, the middle two will be at 0 +- 1/2, and so forth.

Andrew Coppin wrote:
I just wrote a small module for dealing with half-integers. (That is, any number I/2 where I is an integer. Note that the set of integers is a subset of this; Wikipedia seems to reserve "half-integer" for such numbers that are *not* integers.)
Now, the question is... Is this useful enough to be worth putting on Hackage?
It's on Hackage: http://hackage.haskell.org/package/AC-HalfInteger-1.1.1 It'll be interesting to see if I uploaded it right... o_O

On Sat, Jul 04, 2009 at 12:37:21PM +0100, Andrew Coppin wrote:
It's on Hackage:
http://hackage.haskell.org/package/AC-HalfInteger-1.1.1
It'll be interesting to see if I uploaded it right... o_O
I guess you did, congrats! :) ...on the Haddock comments of halve and double, it should be "halve . double" and not "half . double", right? You'll see that after the first upload it is easy to do another one (hopefully). -- Felipe.

Felipe Lessa wrote:
On Sat, Jul 04, 2009 at 12:37:21PM +0100, Andrew Coppin wrote:
It's on Hackage:
http://hackage.haskell.org/package/AC-HalfInteger-1.1.1
It'll be interesting to see if I uploaded it right... o_O
I guess you did, congrats! :)
...on the Haddock comments of halve and double, it should be "halve . double" and not "half . double", right? You'll see that after the first upload it is easy to do another one (hopefully).
Well that's a good start. Already somebody has found a bug to be fixed. And in such a trivial package... o_O Still, at least it's an easy fix. ;-) I don't think I'll bother making another upload just for this; the fix is applied to my local copy, but I'll wait until I have something more substantial to upload for the next version. "Thanks for the report."
participants (10)
-
Andrew Coppin
-
Antoine Latter
-
Deniz Dogan
-
Derek Elkins
-
Felipe Lessa
-
Jason Dagit
-
Magnus Therning
-
Max Rabkin
-
Ross Mellgren
-
Thomas ten Cate