Quantcast
Channel: Confused about custom data types in Haskell - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Confused about custom data types in Haskell

$
0
0

The task: I am trying to create a custom data type and have it able to print to the console. I also want to be able to sort it using Haskell's natural ordering.

The issue: Write now, I can't get this code to compile. It throws the following error: No instance for (Show Person) arising from a use of 'print'.

What I have so far:

-- Omitted working selection-sort functionselection_sort_ord :: (Ord a) => [a] -> [a]selection_sort_ord xs = selection_sort (<) xsdata Person = Person {     first_name :: String,     last_name :: String,       age :: Int }            main :: IO ()main = print $ print_person (Person "Paul""Bouchon" 21)

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images