Dan Fornika <[email protected]> writes:

> I'd like to implement a function "translate" that uses the standard
> translation table by default, but can optionally use a different
> translation table if it is passed as an argument.  

Okay.

> Does it make sense to write this with the type signature:

> translate :: SeqData -> Offset -> Maybe TransTable -> SeqData

To some extent.  You'll need to supply 'Nothing' as the third parameter,
so you might as well write 'default_table' or some such, avoiding the
maybe.

> I'd like to be able to call the function with only the first two
> argument and get the hard-coded standard translation table, but if I
> pass a third argument with type TransTable, I get the customized
> translation.

Variable number of arguments is possible (see e.g. Printf) but it
involves some trickery.  I think it might not be worth it, and suggest
'translate' always take an argument, possibly with a specialized
'translateStd' function supplying the default argument.

Regarding the implementation, you can simplify the 'translate' function
(since it basically repeats the same function twice) by using something
like:

  translate s' o' mb_tab = unfoldr codons (s',o',mytable)
       where mytable = fromMaybe trans_table_std mb_tab
             codons (s, o, trans_table) = ....

Also, -Wall will warn you about recycling names, which can cause errors.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
_______________________________________________
Biohaskell mailing list
[email protected]
http://malde.org/cgi-bin/mailman/listinfo/biohaskell

Reply via email to