
2009/10/30 Colin Paul Adams
Is there a "Bluffer's guide to Haskell"?
Whilst not a bluffers guide, this one contains several dozen flavours of 'obscurantism' (** add your less pejorative term here **) http://www.willamette.edu/~fruehr/haskell/evolution.html Methinks your being a bit hard on the pointfree style, but it does often diminish an _operation reading_ of the code (you can tell what the code does from looking at it). So you either have to trust it, or work it out to some expanded form you are happy with. For what its worth I came up with this bit of golf which saves a few keystrokes if you're prepare not to count the helper functions (I consider them generally useful): combinations :: Int -> [a] -> [[a]] combinations = foldr (<:>) [[]] `oo` replicate -- Helpers that I like but are not in the libraries -- | Applicative 'cons'. Equivalent to - liftA2 (:) - but I like having it around. -- The monadic version is attributable to a parser library in Clean. (<:>) :: Applicative f => f a -> f [a] -> f [a] (<:>) a b = (:) <$> a <*> b -- | Compose an arity 1 function and an arity 2 function. -- -- I call this combinator 'specs' (aka glasses) due to its infix -- appearance `oo` - I believe fans of Raymond Smullyan's -- 'To Mock a Mockingbird' call it blackbird... oo :: (c -> d) -> (a -> b -> c) -> a -> b -> d oo f g = (f .) . g Best wishes Stephen