Elm challenge on Exercism: Rna Transcription
Anton
Posted on September 1, 2018
I'm gonna be short.
I'm going through exercism exercises.
At one moment I had a beef with the compiler.
The 4th and 5th branches of this if
produce different types of values.
4| if x == 'G' then
5| 'C'
6| else if x == 'C' then
7| 'G'
8| else if x == 'T' then
9| 'A'
10| else if x == 'A' then
11| 'U'
12| else
13|> "There is an Unknown Character in the DNA sequence!!!"
The 4th branch has this type:
Char
But the 5th is:
String
Hint: All the branches of an if
need to match so that no matter which one we
take, we get back the same type of value overall.
To me, it seemed unreasonable :)
Now, I'm just stuck here.
The definition of toRNA
does not match its type annotation.
17| toRNA : String -> Result Char String
18| toRNA dna =
19|> converted_to_list dna
20|> |> List.map convert
21|> |> String.fromList
The type annotation for toRNA
says it always returns:
Result Char String
But the returned value (shown above) is a:
String
Detected errors in 1 module.
Posted on September 1, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.