been trying to wrap my head around this problem for a while, i was working on https://exercism.org/tracks/haskell/exercises/rna-transcription
with the idea of an inner function that recurses to iterate over the input (so that i can return the wrong character like it asks)
but for some reason Either refuses to match the types I'm returning
toRNA :: String -> Either Char String
toRNA xs = inner xs ""
where
inner :: String -> String -> Either Char String
inner st out = case st of
"" -> out
(x:xs) -> case x of
'G' -> inner xs (out ++ "C")
'C' -> inner xs (out ++ "G")
'T' -> inner xs (out ++ "A")
'A' -> inner xs (out ++ "U")
x -> x```
my thinking is that i can recurse like this
inner "AGT" "" -> inner "GT" "U" -> inner "T" "UC" -> inner "" "UCA" -> "UCA"
or on a wrong character:
inner "AX" "" -> inner "X" "U" -> 'X'
but I can't even get the compiler to accept my code due to some type issue that I can't wrap my head around with Either
it keeps giving me compiler errors like ```
/mnt/exercism-iteration/src/DNA.hs:10:29: error:
• Couldn't match type: [Char]
with: Either Char String
Expected: Either Char String
Actual: String
• In the expression: out
In a case alternative: "" -> out
I don't understand this, isnt String the same as [Char]?