module Data.PrimitiveArray.Index.Unit where
import Control.Applicative (pure)
import Control.DeepSeq (NFData(..))
import Data.Aeson (FromJSON,FromJSONKey,ToJSON,ToJSONKey)
import Data.Binary (Binary)
import Data.Hashable (Hashable)
import Data.Serialize (Serialize)
import Data.Vector.Fusion.Stream.Monadic (Step(..), map)
import Data.Vector.Unboxed.Deriving
import GHC.Generics (Generic)
import Prelude hiding (map)
import Test.QuickCheck (Arbitrary(..), choose)
import Data.PrimitiveArray.Index.Class
data Unit t = Unit
deriving (Eq,Ord,Show,Generic,Read)
derivingUnbox "Unit"
[t| forall t . Unit t -> () |]
[| \ Unit -> () |]
[| \ () -> Unit |]
instance Binary (Unit t)
instance Serialize (Unit t)
instance FromJSON (Unit t)
instance FromJSONKey (Unit t)
instance ToJSON (Unit t)
instance ToJSONKey (Unit t)
instance Hashable (Unit t)
instance NFData (Unit t) where
rnf Unit = ()
instance Index (Unit t) where
linearIndex _ _ _ = 0
smallestLinearIndex _ = 0
largestLinearIndex _ = 0
size _ _ = 1
inBounds _ _ _ = True
instance IndexStream z => IndexStream (z:.Unit t) where
streamUp (ls:.Unit) (hs:.Unit) = map (\z -> z:.Unit) $ streamUp ls hs
streamDown (ls:.Unit) (hs:.Unit) = map (\z -> z:.Unit) $ streamDown ls hs
instance (IndexStream (Z:.Unit t)) => IndexStream (Unit t)
instance Arbitrary (Unit t) where
arbitrary = pure Unit
shrink Unit = []