I'm new to Haskell, and now I'm trying to solve some kind of solution, but it seems like I can't find anything.
I defined a data type called binary recursively
data Binary = BaseOne | Zero Binary | One Binary
And I'm trying to make a function that takes a binary number in the form of a list (ie [1, 1, 0, 1] and converts it to my Binary data type.
binListaBin :: [Int] -> Binary
binListaBin [] = error "Empty List."
binListaBin [1] = BaseOne
binListaBin x:xs
| x == 0 = Zero (binListaBin xs)
| x == 1 = One (binListaBin xs)
| otherwise = error "Not a binary."
The problem is that my function returns a result, so I assume that if I can change the input list before the function works with it, it should work correctly, but I do not know how to do this inside the function. I tried to combine with the offers and offer the offers, but it seems that there can be no rights.