{-# LANGUAGE TypeSynonymInstances #-}
module HaskellWorks.Data.Positioning
( Count
, Position
, lastPositionOf
, toCount
, toPosition
) where
import Data.Int
import Data.Word
type Count = Word64
type Position = Int64
class ToPosition a where
toPosition :: a -> Position
instance ToPosition Count where
toPosition :: Count -> Position
toPosition = Count -> Position
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toPosition #-}
class ToCount a where
toCount :: a -> Count
instance ToCount Position where
toCount :: Position -> Count
toCount = Position -> Count
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toCount #-}
lastPositionOf :: Count -> Position
lastPositionOf :: Count -> Position
lastPositionOf Count
c = Count -> Position
forall a b. (Integral a, Num b) => a -> b
fromIntegral Count
c Position -> Position -> Position
forall a. Num a => a -> a -> a
- Position
1
{-# INLINE lastPositionOf #-}