Logo

dev-resources.site

for different kinds of informations.

Elm challenge on Exercism: Rna Transcription

Published at
9/1/2018
Categories
elm
exercism
codechallenge
Author
antonrich
Categories
3 categories in total
elm
open
exercism
open
codechallenge
open
Author
9 person written this
antonrich
open
Elm challenge on Exercism: Rna Transcription

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.


Featured ones: