Created
February 2, 2022 13:43
-
-
Save tstarck/d391a92d92706ae781a4c2aeaff69ed7 to your computer and use it in GitHub Desktop.
GHCI usage example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Foo where | |
import Data.List | |
comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering | |
comparing f x y = compare (f x) (f y) | |
sortByLength :: [[a]] -> [[a]] | |
sortByLength = sortBy (comparing length) | |
-- This file can be loaded with GHCI: | |
-- $ stack ghci Foo.hs | |
-- | |
-- And then the function should be available: | |
-- *Foo> sortByLength [[1,2,3],[4,5],[4,5,6,7]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment