{-# LANGUAGE GADTs #-} import Data.List import Data.Function import Data.Ord main :: IO () main = do putStrLn "hello" data StringOrd where StringOrd :: Ord a => (String -> a) -> StringOrd myList :: [StringOrd] myList = [ StringOrd $ \str -> 2 , StringOrd $ \str -> "hello: " <> str ] sort' :: StringOrd -> [String] -> [String] sort' (StringOrd f) xs = sortBy (comparing f) xs myFunction :: [String] -> [String] myFunction xs = sort' (myList !! 0) xs