{-# LANGUAGE TypeFamilies #-}
module Parsers.Utils.Handrolled where

import Data.Bool (Bool)
import Data.Char (Char)
import Data.Maybe (Maybe(..))
import Data.Word (Word8)
import qualified Data.ByteString as BS
import qualified Data.Text as T

-- * Class 'Inputable'
class Inputable inp where
  type Token inp
  null :: inp -> Bool
  empty :: inp
  uncons :: inp -> Maybe (Token inp, inp)
instance Inputable T.Text where
  type Token T.Text = Char
  null = T.null
  empty = T.empty
  uncons = T.uncons
instance Inputable BS.ByteString where
  type Token BS.ByteString = Word8
  null = BS.null
  empty = BS.empty
  uncons = BS.uncons