{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
module Text.Appar.Input where
import qualified Data.ByteString.Char8 as S
import qualified Data.ByteString.Lazy.Char8 as L
class Eq inp => Input inp where
car :: inp -> Char
cdr :: inp -> inp
nil :: inp
isNil :: inp -> Bool
instance Input S.ByteString where
car :: ByteString -> Char
car = ByteString -> Char
S.head
cdr :: ByteString -> ByteString
cdr = HasCallStack => ByteString -> ByteString
ByteString -> ByteString
S.tail
nil :: ByteString
nil = ByteString
S.empty
isNil :: ByteString -> Bool
isNil = ByteString -> Bool
S.null
instance Input L.ByteString where
car :: ByteString -> Char
car = ByteString -> Char
L.head
cdr :: ByteString -> ByteString
cdr = HasCallStack => ByteString -> ByteString
ByteString -> ByteString
L.tail
nil :: ByteString
nil = ByteString
L.empty
isNil :: ByteString -> Bool
isNil = ByteString -> Bool
L.null
instance Input String where
car :: String -> Char
car = String -> Char
forall a. HasCallStack => [a] -> a
head
cdr :: String -> String
cdr = String -> String
forall a. HasCallStack => [a] -> [a]
tail
isNil :: String -> Bool
isNil = String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null
nil :: String
nil = String
""