{-# LANGUAGE TypeFamilies #-}
module Data.Greskell.AsIterator
( AsIterator(..)
) where
import qualified Data.HashMap.Lazy as L (HashMap)
import Data.HashSet (HashSet)
import Data.List.NonEmpty (NonEmpty)
import Data.Int (Int8, Int16, Int32, Int64)
import qualified Data.IntMap.Lazy as L (IntMap)
import Data.IntSet (IntSet)
import qualified Data.Map.Lazy as L (Map)
import Data.Ratio (Ratio)
import Data.Scientific (Scientific)
import Data.Sequence (Seq)
import Data.Set (Set)
import Data.Text (Text)
import qualified Data.Text.Lazy as TL
import Data.Vector (Vector)
import Data.Word (Word8, Word16, Word32, Word64)
import Numeric.Natural (Natural)
import Data.Greskell.GMap (GMap, GMapEntry)
class AsIterator a where
type IteratorItem a
instance AsIterator () where
type IteratorItem () = ()
instance AsIterator Int where
type IteratorItem Int = Int
instance AsIterator Text where
type IteratorItem Text = Text
instance AsIterator TL.Text where
type IteratorItem TL.Text = TL.Text
instance AsIterator Bool where
type IteratorItem Bool = Bool
instance AsIterator Char where
type IteratorItem Char = Char
instance AsIterator Double where
type IteratorItem Double = Double
instance AsIterator Float where
type IteratorItem Float = Float
instance AsIterator Int8 where
type IteratorItem Int8 = Int8
instance AsIterator Int16 where
type IteratorItem Int16 = Int16
instance AsIterator Int32 where
type IteratorItem Int32 = Int32
instance AsIterator Int64 where
type IteratorItem Int64 = Int64
instance AsIterator Integer where
type IteratorItem Integer = Integer
instance AsIterator Natural where
type IteratorItem Natural = Natural
instance Integral a => AsIterator (Ratio a) where
type IteratorItem (Ratio a) = Ratio a
instance AsIterator Word where
type IteratorItem Word = Word
instance AsIterator Word8 where
type IteratorItem Word8 = Word8
instance AsIterator Word16 where
type IteratorItem Word16 = Word16
instance AsIterator Word32 where
type IteratorItem Word32 = Word32
instance AsIterator Word64 where
type IteratorItem Word64 = Word64
instance AsIterator Scientific where
type IteratorItem Scientific = Scientific
instance AsIterator [a] where
type IteratorItem [a] = a
instance AsIterator (Vector a) where
type IteratorItem (Vector a) = a
instance AsIterator (HashSet a) where
type IteratorItem (HashSet a) = a
instance AsIterator (Seq a) where
type IteratorItem (Seq a) = a
instance AsIterator (Set a) where
type IteratorItem (Set a) = a
instance AsIterator IntSet where
type IteratorItem IntSet = Int
instance AsIterator (NonEmpty a) where
type IteratorItem (NonEmpty a) = a
instance AsIterator (GMap c k v) where
type IteratorItem (GMap c k v) = GMapEntry k v
instance AsIterator (GMapEntry k v) where
type IteratorItem (GMapEntry k v) = GMapEntry k v
instance AsIterator (L.HashMap k v) where
type IteratorItem (L.HashMap k v) = GMapEntry k v
instance AsIterator (L.Map k v) where
type IteratorItem (L.Map k v) = GMapEntry k v
instance AsIterator (L.IntMap v) where
type IteratorItem (L.IntMap v) = GMapEntry Int v
instance AsIterator a => AsIterator (Maybe a) where
type IteratorItem (Maybe a) = Maybe (IteratorItem a)