As m0nhawk writes in the comments, you cannot directly have a Haskell list from both lists of integers and integers. However, there are several alternatives.
Alternatively, you can use a list of lists of integers ( [[1, 2, 3], [4], [5], [6]]), for example:
combine:: [Int] -> [Int] -> [[Int]]
combine xs ys = [xs] ++ [[y] | y <- ys]
main = do
putStrLn $ show $ combine [1, 2, 3] [4, 5, 6]
(performed this really prints [[1, 2, 3], [4], [5], [6]]).
Another alternative is to use algebraic data types :
Prelude> data ScalarOrList = Scalar Int | List [Int] deriving(Show)
Prelude> [List [1, 2, 3], Scalar 4, Scalar 5, Scalar 6]
[List [1,2,3],Scalar 4,Scalar 5,Scalar 6]
source
share