{-# LANGUAGE GADTs #-} {-# LANGUAGE InstanceSigs #-} module Matcha.Query where import Data.Text (Text) import Network.HTTP.Types (Query) import Network.Wai (Request) import Web.HttpApiData (FromHttpApiData, ToHttpApiData) data Parser a where FMap :: (a -> b) -> Parser a -> Parser b Pure :: a -> Parser a Apply :: Parser (a -> b) -> Parser a -> Parser b Optional :: Parser a -> Parser (Maybe a) Option :: a -> Parser a -> Parser a Param :: (FromHttpApiData a, ToHttpApiData a) => Text -> Parser a Flag :: Text -> Parser () instance Functor Parser where fmap :: (a -> b) -> Parser a -> Parser b fmap :: forall a b. (a -> b) -> Parser a -> Parser b fmap = (a -> b) -> Parser a -> Parser b forall a b. (a -> b) -> Parser a -> Parser b FMap instance Applicative Parser where pure :: a -> Parser a pure :: forall a. a -> Parser a pure = a -> Parser a forall a. a -> Parser a Pure (<*>) :: Parser (a -> b) -> Parser a -> Parser b <*> :: forall a b. Parser (a -> b) -> Parser a -> Parser b (<*>) = Parser (a -> b) -> Parser a -> Parser b forall a b. Parser (a -> b) -> Parser a -> Parser b Apply data Error = Error parse :: Request -> Parser a -> Either Error a parse :: forall a. Request -> Parser a -> Either Error a parse = Request -> Parser a -> Either Error a forall a. HasCallStack => a undefined match :: Parser a -> Query -> Either Error a match :: forall a. Parser a -> Query -> Either Error a match = Parser a -> Query -> Either Error a forall a. HasCallStack => a undefined on :: Parser a -> Query -> (Error -> b) -> (a -> b) -> b on :: forall a b. Parser a -> Query -> (Error -> b) -> (a -> b) -> b on = Parser a -> Query -> (Error -> b) -> (a -> b) -> b forall a. HasCallStack => a undefined