On Mar 28, 2011, at 5:16 PM, Ketil Malde wrote:

> Nicholas Ingolia <n...@ingolia.org> writes:
> 
>> I'm pretty strongly in favor of 0-based indexing,
>  [...]
>> If you're committed to 1-based indices, 
> 
> Three votes for zero so far, and I'm not very committed, so I guess zero
> it is. But
> 
>> we could exploit the newtype wrapper around Offset to provide an
>> interface with 1-based offsets.
> 
> this line of thought is interesting, I think.  Perhaps we can supply an
> Offset1 newtype as well for use with 1-based data formats?  Probably
> only internally, so that e.g. a SeqLoc will always use zero-based
> offsets. 

I was thinking that there could be an alternate Bio.SeqLoc.Position1Based 
module that re-exported Offset as an opaque data type and provided

mkOffset1 :: Int64 -> Offset
unOffset1 :: Offset -> Int64

The internal representation would be unchanged but the client would see the 
conversion of offsets to numbers using 1-based indexing (and your call on how 
it deals with the -1/+1 jump).

Handling the Num instance would be tricky, some of the operations would be 
wrong (e.g., literal 0 of type (Num a) => a would not be shifted properly) and 
others would be confusing (e.g., you don't add two 1-based offsets) but I don't 
believe we can control the re-export of the Offset Num instance.

Best,
--Nick
_______________________________________________
Biohaskell mailing list
Biohaskell@biohaskell.org
http://malde.org/cgi-bin/mailman/listinfo/biohaskell

Reply via email to