
Hi, I´m doing a project in haskell and I need to define an operator that concatenate some own defined data types, just like the operator ++ does for lists. I don´t see how to define the operator recursively since this adding function (:) doesn´t work on my own data types. This is my code: data Allele = Aone | Atwo deriving Show type Lifespan = Int data Population = Pop [(Allele,Allele,Lifespan)] deriving Show genepool :: Population genepool = Pop [] --can only concatenate 2 elements (+-) :: Population -> Population -> Population Pop [(a,b,c)] +- Pop [] = Pop [(a,b,c)] Pop [(a,b,c)] +- Pop [(d,e,f)] = Pop [(a,b,c),(d,e,f)] --and thats why this function goes non-exhaustive. gpinsertaoneaone :: Int -> Int -> Population gpinsertaoneaone 0 age = genepool gpinsertaoneaone n age = Pop [(Aone,Aone,70-age)] +- gpinsertaoneaone (n-1) age Thx for help and advice! -- View this message in context: http://haskell.1045720.n5.nabble.com/Help-with-how-to-concatenate-with-own-d... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.