I wrote a haskell code for translate RNA codon like this:
data Base = U | C | A | G
data Amino = Phe | Lue | Ile | Met | Val | Ser | Pro | Thr | Ala |
Tyr | Stop | His | Gln | Asn | Lys | Asp | Glu | Cys | Trp | Arg | Gly deriving Show
codon :: Base -> Base -> Base -> Amino
parse :: String -> [Base]
parse = map go where
go 'U' = U
go 'A' = A
go 'C' = C
go 'G' = G
convert :: [Base] -> [Amino]
convert [] = []
convert (x1:x2:x3:xs) = codon x1 x2 x3 : convert xs
convert _ = undefined
main = do
input <- getLine
let x = show . convert . parse $ input
putStrLn x
codon U U U = Phe
codon U U C = Phe
codon U U A = Lue
codon U U G = Lue
codon C U U = Lue
And i want to write julia code like that. To make a new type like Base or Amino, i found abstract type at julia document, i couldn't find how to make a new type.
How to define new type like Base and U, C, A, G ?