Skip to content

Instantly share code, notes, and snippets.

@gdejohn
Last active April 11, 2017 14:04
Show Gist options
  • Save gdejohn/d49cc3fe801e308ba7d3 to your computer and use it in GitHub Desktop.
Save gdejohn/d49cc3fe801e308ba7d3 to your computer and use it in GitHub Desktop.
Deforested tree sort, point-free one-liner
import Control.Applicative (liftA2)
import Data.List (partition)
import Data.List.Extra (list)
import Data.Tuple.Extra (both, second)
sort :: Ord a => [a] -> [a]
sort = [] `list` liftA2 (.) ((uncurry (++) .) . second . (:)) ((both sort .) . partition . (>))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment