|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
Half-integerI 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? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerOn 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? :) -- Felipe. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerFelipe 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 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerOn Sun, Jun 28, 2009 at 15:24, Andrew Coppin<andrewcoppin@...> 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.) > > 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 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerThomas 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. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerFelipe 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... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integer2009/6/28 Andrew Coppin <andrewcoppin@...>:
> 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 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerDeniz Dogan wrote:
> 2009/6/28 Andrew Coppin <andrewcoppin@...>: > >> 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... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerAndrew Coppin wrote:
> Deniz Dogan wrote: >> 2009/6/28 Andrew Coppin <andrewcoppin@...>: >>> 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...] _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerOn Sun, Jun 28, 2009 at 2:13 PM, Andrew
Coppin<andrewcoppin@...> 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? :-) Antoine _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerAntoine Latter wrote:
> On Sun, Jun 28, 2009 at 2:13 PM, Andrew > Coppin<andrewcoppin@...> 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... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Half-integerOn Sun, Jun 28, 2009 at 9:29 PM, Andrew
Coppin<andrewcoppin@...> 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. > 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 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Cabal fun [Half-integer]Max Rabkin wrote:
> On Sun, Jun 28, 2009 at 9:29 PM, Andrew > Coppin<andrewcoppin@...> 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* _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Cabal fun [Half-integer]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. :-/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Cabal fun [Half-integer]On Sun, Jun 28, 2009 at 3:42 PM, Andrew
Coppin<andrewcoppin@...> 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": > > 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 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Cabal fun [Half-integer]On Sun, Jun 28, 2009 at 4:11 PM, Antoine Latter<aslatter@...> wrote:
> On Sun, Jun 28, 2009 at 3:42 PM, Andrew > Coppin<andrewcoppin@...> 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": >> >> 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" 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. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Cabal fun [Half-integer]Derek Elkins wrote:
> On Sun, Jun 28, 2009 at 4:11 PM, Antoine Latter<aslatter@...> wrote: > >> On Sun, Jun 28, 2009 at 3:42 PM, Andrew >> Coppin<andrewcoppin@...> 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... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Cabal fun [Half-integer]On Mon, Jun 29, 2009 at 1:03 PM, Andrew
Coppin<andrewcoppin@...> wrote: > > 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 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Cabal fun [Half-integer]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... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Cabal fun [Half-integer]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. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |