I am just starting off in a haskell course and I am trying to write a program that takes a list representing an int such as [1,4,3] would mean 143, and convert it to binary and return it as a list in the same fashion. I have written the following code but I keep getting the same annoying error and I cant figure out how to fix it.
decimaltobinary :: [Int] -> [Int] decimaltobinary xs = d2b2(d2b(reverse xs)) d2b :: [Int] -> Int d2b [x] = x d2b (x:xs) = x + d2b(map (10*) xs) d2b2 :: Int -> [Int] d2b2 0 =  d2b2 1 =  d2b2 n = if (n `mod` 2 == 1) then ( return ((d2b2(n / 2)):1)) else ( return ((d2b2(n / 2)):0))
Couldn't match expected type 'Int' against inferred type '[[Int]]' in the first argument of the return namely '((d2b2(n / 2)):1)' and so forth
I don't understand why its saying [[Int]] instead of just [Int] either.