clifford.beshers at gmail.com
Fri Jul 17 12:53:08 EDT 2009
Ian, I don't think it matters much either way. Personally, I like the
point-free style. Of all the things that have puzzled me over the years
when reading core libraries, that was one of the easiest to learn about.
One can hardly miss it if one visits #haskell at all.
On Fri, Jul 17, 2009 at 8:33 AM, Ian Lynagh <igloo at earth.li> wrote:
> On Thu, Jul 09, 2009 at 11:42:20AM +0200, Laszlo Nagy wrote:
> > I also run the hlint program
> > against the random library and applied the recommendations. Here are
> > the patches:
> > http://sites.google.com/site/rizsotto/patches/random-hlintclean.darcs
> Thanks for taking the time to look into this.
> I'd be interested in other people's opinions on whether the hlint
> recommendations are an improvement or not.
> In my opinion there are a handful of things that are slightly less clear
> for no real benefit:
> createStdGen :: Integer -> StdGen
> -createStdGen s = mkStdGen32 $ fromIntegral s
> +createStdGen = mkStdGen32 . fromIntegral
> randoms :: RandomGen g => g -> [a]
> - randoms g = (\(x,g') -> x : randoms g') (random g)
> + randoms = (\(x,g') -> x : randoms g') . random
> theStdGen :: IORef StdGen
> -theStdGen = unsafePerformIO $ do
> - rng <- mkStdRNG 0
> - newIORef rng
> +theStdGen = unsafePerformIO $ mkStdRNG 0 >>= newIORef
> In fact, I would change randoms to:
> randoms g = case random g of
> (x,g') -> x : randoms g'
> And the rest aren't really better or worse in my opinion, e.g.:
> instance Random Int where
> - randomR (a,b) g = randomIvalInteger (toInteger a, toInteger b) g
> - random g = randomR (minBound,maxBound) g
> + randomR (a,b) = randomIvalInteger (toInteger a, toInteger b)
> + random = randomR (minBound,maxBound)
> > http://sites.google.com/site/rizsotto/patches/random-time.darcs
> Thanks; I'll take a look at adding time to GHC's corelibs, and then
> apply this.
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries