
How is it possible to define a user datatype consisting of instances of String? Suppose I am preparing a party for wine connoisseurs, and want to define the following data types: data Wine = Red | White data Red = "Merlot" data White = "Sauvignon Blanc" data Entree = "pork" | "chicken" | "tuna" data SideDish = "garlic bread" | "mozzarella sticks" | "caviar" Then, I want to write a Haskell function that takes two lists; e.g., ["pork", "chicken", "tuna"] and ["garlic bread", "mozzarella sticks", "caviar"] and that constructs a three-tuple of the following type: (Entree, SideDish, Wine) such that which Wine is chosen depends on the particular combination of Entree and SideDish, with respect to the following rules: ("pork", "garlic bread") -> ("pork", "garlic bread", "Merlot") ("pork", "mozzarella sticks") -> ("pork", "mozzarella sticks", "Merlot") ("pork", "caviar") -> ("pork", "Beluga", "Sauvignon Blanc") ("chicken", "garlic bread") -> ("chicken", "garlic bread", "Merlot") ("chicken", "mozzarella sticks") -> ("chicken", "mozzarella sticks", "Sauvignon Blanc") ("chicken", "caviar") -> ("chicken", "caviar", "Merlot") ("tuna", "garlic bread") -> ("tuna", "garlic bread", "Sauvignon Blanc") ("tuna", "mozzarella sticks") -> ("tuna", "mozzarella sticks", "Merlot") ("tuna", "caviar") -> ("tuna", "caviar", "Merlot") So far, I have written the following Haskell code: module Wine where data Wine = Red | White data Red = "Merlot" data White = "Sauvignon Blanc" data Entree = "pork" | "chicken" | "tuna" data SideDish = "garlic bread" | "mozzarella sticks" | "caviar" wine :: [Entree] -> [SideDish] -> [(Entree, SideDish, Wine)] wine entree sidedish | entree == "pork" = | sidedish == "garlic bread" = ("pork", "garlic bread", "Merlot") | sidedish == "mozzarella sticks" = ("pork", "mozzarella sticks", "Merlot") | sidedish == "caviar" = ("pork", "caviar", "Sauvignon Blanc") | entree == "chicken" = | sidedish == "garlic bread" = ("chicken", "garlic bread", "Merlot") | sidedish == "mozzarella sticks" = ("chicken", "mozzarella sticks", "Sauvignon Blanc") | sidedish == "caviar"= ("chicken", "caviar", "Merlot") | entree == "tuna" = | sidedish == "garlic bread" = ("tuna", "garlic bread", "Sauvignon Blanc") | sidedish == "mozzarella sticks" = ("tuna", "mozzarella sticks", "Merlot") | sidedish == "caviar"= ("tuna", "caviar", "Merlot") However, when I load this code into GHCi, I get the following error message: [1 of 1] Compiling Wine ( wine.hs, interpreted ) wine.hs:18:11: parse error on input `"' Failed, modules loaded: none. Prelude> I discovered the following seemingly relevant HaskellWiki page, but am not sure about how to apply the advice in it to this problem, because the advice does not seem sufficiently specific or detailed: List instance - HaskellWiki http://www.haskell.org/haskellwiki/List_instance What would be a good way to overcome this error? -- Benjamin L. Russell