{-# OPTIONS -XExistentialQuantification -XTypeSynonymInstances -XFlexibleInstances -XDeriveDataTypeable #-} module MFlow.Hack.Response where import Hack import MFlow.Cookies import Data.ByteString.Lazy.Char8 import MFlow(HttpData(..)) import Data.Typeable import Data.Monoid --import Debug.Trace -- --(!>)= flip trace class ToResponse a where toResponse :: a -> Response data TResp = TRempty | forall a.ToResponse a=>TRespR a | forall a.(Typeable a, ToResponse a, Monoid a) => TResp a deriving Typeable instance Monoid TResp where mempty = TRempty mappend (TResp x) (TResp y)= case cast y of Just y' -> TResp $ mappend x y' Nothing -> error $ "fragment of type " ++ show ( typeOf y) ++ " after fragment of type " ++ show ( typeOf x) defaultResponse :: String -> IO Response defaultResponse msg= return . toResponse $ "
Page not found or error ocurred:
" ++ msg ++ "
home