hsp-0.2: HTTP/Common.hs
module HTTP.Common where
import HTTP.Util
newtype HTTPVersion = HTTPVersion (Int, Int)
instance Show HTTPVersion where
showsPrec _ (HTTPVersion (maj, min))
= showString "HTTP/" .
shows maj .
showString "." .
shows min
newtype Header = Header (FieldName, FieldValue)
instance Show Header where
showsPrec _ (Header (fn, fv))
= showString fn .
showString ": " .
showString fv .
showsCRLF
showList [] = showString ""
showList (hdr:hdrs)
= shows hdr .
showList hdrs
type FieldName = String
type FieldValue = String
data MessageBody = EmptyBody | MessageBody String
instance Show MessageBody where
show EmptyBody = ""
show (MessageBody str) = str
infixr 9 .|.
(.|.) :: (b -> c, b1 -> c1) -> (a -> b,a1 -> b1) -> (a, a1) -> (c, c1)
((f1, f2) .|. (g1, g2)) (x1,x2) = (f1 . g1 $ x1, f2 . g2 $ x2)
app :: (a -> b, a1 -> b1) -> (a, a1) -> (b, b1)
app (f, g) (x, y) = (f x, g y)
dup :: a -> (a,a)
dup a = (a,a)