任务:我正在尝试创建一个自定义数据类型并让它能够打印到控制台。我还希望能够使用 Haskell 的自然排序对其进行排序。
问题:现在写,我无法编译这段代码。它抛出以下错误:No instance for (Show Person) arising from a use of 'print'
.
到目前为止我所拥有的:
-- Omitted working selection-sort function
selection_sort_ord :: (Ord a) => [a] -> [a]
selection_sort_ord xs = selection_sort (<) xs
data Person = Person {
first_name :: String,
last_name :: String,
age :: Int }
main :: IO ()
main = print $ print_person (Person "Paul" "Bouchon" 21)