Safe Haskell | None |
---|---|
Language | Haskell2010 |
- notify :: forall api endpoint. (IsElem endpoint api, HasLink endpoint, IsValidEndpoint endpoint, IsSubscribable endpoint api) => Subscriber api -> Event -> Proxy endpoint -> (MkLink endpoint -> URI) -> STM ()
- makeSubscriber :: Path -> LogRunner -> STM (Subscriber api)
- serveSubscriber :: forall api. HasServer api '[] => Subscriber api -> Server api -> Application
- data Subscriber api
- data Event
- type family IsElem endpoint api :: Constraint where ...
- class HasLink k endpoint where
- type family IsValidEndpoint endpoint :: Constraint where ...
- type family IsSubscribable endpoint api :: Constraint where ...
- data Proxy k t :: forall k. k -> *
- type family MkLink k (endpoint :: k) :: *
- data URI :: *
- data STM a :: * -> *
Documentation
notify :: forall api endpoint. (IsElem endpoint api, HasLink endpoint, IsValidEndpoint endpoint, IsSubscribable endpoint api) => Subscriber api -> Event -> Proxy endpoint -> (MkLink endpoint -> URI) -> STM () Source #
Notify the subscriber about a changed resource. You have to provide a typesafe link to the changed resource. Only Symbols and Captures are allowed in this link.
You need to provide a proxy to the API too. This is needed to check that the endpoint is valid
and points to a Subscribable
resource.
One piece is still missing - we have to fill out captures, that's what the getLink parameter is for: You will typicall provide a lamda there providing needed parameters.
TODO: Example!
makeSubscriber :: Path -> LogRunner -> STM (Subscriber api) Source #
serveSubscriber :: forall api. HasServer api '[] => Subscriber api -> Server api -> Application Source #
data Subscriber api Source #
type family IsElem endpoint api :: Constraint where ... #
Closed type family, check if endpoint is within api
IsElem e ((:<|>) sa sb) = Or (IsElem e sa) (IsElem e sb) | |
IsElem ((:>) k * e sa) ((:>) k * e sb) = IsElem sa sb | |
IsElem sa ((:>) * * (Header sym x) sb) = IsElem sa sb | |
IsElem sa ((:>) * * (ReqBody k y x) sb) = IsElem sa sb | |
IsElem ((:>) * * (Capture k z y) sa) ((:>) * * (Capture k x y) sb) = IsElem sa sb | |
IsElem ((:>) * * (CaptureAll k z y) sa) ((:>) * * (CaptureAll k x y) sb) = IsElem sa sb | |
IsElem sa ((:>) * * (QueryParam k x y) sb) = IsElem sa sb | |
IsElem sa ((:>) * * (QueryParams k x y) sb) = IsElem sa sb | |
IsElem sa ((:>) * * (QueryFlag x) sb) = IsElem sa sb | |
IsElem (Verb k1 k m s ct typ) (Verb k1 k m s ct' typ) = IsSubList * ct ct' | |
IsElem e e = () | |
IsElem e a = IsElem' e a |
Construct a toLink for an endpoint.
HasLink * Raw | |
HasLink * sub => HasLink * ((:>) * * Subscribable sub) # | |
(KnownSymbol sym, ToHttpApiData v, HasLink k sub) => HasLink * ((:>) * k (QueryParam * sym v) sub) | |
(KnownSymbol sym, ToHttpApiData v, HasLink k sub) => HasLink * ((:>) * k (QueryParams * sym v) sub) | |
(KnownSymbol sym, HasLink k sub) => HasLink * ((:>) * k (QueryFlag sym) sub) | |
HasLink k sub => HasLink * ((:>) * k (ReqBody k1 ct a) sub) | |
(ToHttpApiData v, HasLink k sub) => HasLink * ((:>) * k (Capture * sym v) sub) | |
(ToHttpApiData v, HasLink k sub) => HasLink * ((:>) * k (CaptureAll * sym v) sub) | |
HasLink k sub => HasLink * ((:>) * k (Header sym a) sub) | |
HasLink k sub => HasLink * ((:>) * k RemoteHost sub) | |
HasLink k sub => HasLink * ((:>) * k (BasicAuth realm a) sub) | |
(KnownSymbol sym, HasLink k sub) => HasLink * ((:>) Symbol k sym sub) | |
HasLink * (Verb k1 k m s ct a) | |
type family IsValidEndpoint endpoint :: Constraint where ... Source #
A valid endpoint may only contain Symbols and captures & for convenince Subscribable:
IsValidEndpoint ((sym :: Symbol) :> sub) = IsValidEndpoint sub | |
IsValidEndpoint (Capture z y :> sub) = IsValidEndpoint sub | |
IsValidEndpoint (Subscribable :> sub) = IsValidEndpoint sub | |
IsValidEndpoint (Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [*]) (a :: *)) = () |
type family IsSubscribable endpoint api :: Constraint where ... Source #
IsSubscribable sa (Subscribable :> sb) = () | |
IsSubscribable e (sa :<|> sb) = Or (IsSubscribable e sa) (IsSubscribable e sb) | |
IsSubscribable ((sym :: Symbol) :> sa) (sym :> sb) = IsSubscribable sa sb | |
IsSubscribable (e :> sa) (e :> sb) = IsSubscribable sa sb | |
IsSubscribable sa (Header sym x :> sb) = IsSubscribable sa sb | |
IsSubscribable sa (ReqBody y x :> sb) = IsSubscribable sa sb | |
IsSubscribable (Capture z y :> sa) (Capture x y :> sb) = IsSubscribable sa sb | |
IsSubscribable sa (QueryParam x y :> sb) = IsSubscribable sa sb | |
IsSubscribable sa (QueryParams x y :> sb) = IsSubscribable sa sb | |
IsSubscribable sa (QueryFlag x :> sb) = IsSubscribable sa sb | |
IsSubscribable e a = IsSubscribable' e a |
data Proxy k t :: forall k. k -> * #
A concrete, poly-kinded proxy type
Monad (Proxy *) | |
Functor (Proxy *) | |
Applicative (Proxy *) | |
Foldable (Proxy *) | |
Traversable (Proxy *) | |
Generic1 (Proxy *) | |
Contravariant (Proxy *) | |
Representable (Proxy *) | |
Alternative (Proxy *) | |
MonadPlus (Proxy *) | |
Eq1 (Proxy *) | Since: 4.9.0.0 |
Ord1 (Proxy *) | Since: 4.9.0.0 |
Read1 (Proxy *) | Since: 4.9.0.0 |
Show1 (Proxy *) | Since: 4.9.0.0 |
Bounded (Proxy k s) | |
Enum (Proxy k s) | |
Eq (Proxy k s) | |
Data t => Data (Proxy * t) | |
Ord (Proxy k s) | |
Read (Proxy k s) | |
Show (Proxy k s) | |
Ix (Proxy k s) | |
Generic (Proxy k t) | |
Semigroup (Proxy k s) | |
Monoid (Proxy k s) | |
FromJSON (Proxy k a) | |
ToJSON (Proxy k a) | |
type Rep1 (Proxy *) | |
type Rep (Proxy *) | |
type Rep (Proxy k t) | |
type family MkLink k (endpoint :: k) :: * #
type MkLink * Raw | |
type MkLink * ((:>) * * Subscribable sub) # | |
type MkLink * ((:>) * k (BasicAuth realm a) sub) | |
type MkLink * ((:>) * k RemoteHost sub) | |
type MkLink * ((:>) * k (Header sym a) sub) | |
type MkLink * ((:>) * k (CaptureAll * sym v) sub) | |
type MkLink * ((:>) * k (Capture * sym v) sub) | |
type MkLink * ((:>) * k (ReqBody k1 ct a) sub) | |
type MkLink * ((:>) * k (QueryFlag sym) sub) | |
type MkLink * ((:>) * k (QueryParams * sym v) sub) | |
type MkLink * ((:>) * k (QueryParam * sym v) sub) | |
type MkLink * ((:>) Symbol k sym sub) | |
type MkLink * (Verb k1 k m s ct a) | |
Represents a general universal resource identifier using its component parts.
For example, for the URI
foo://anonymous@www.haskell.org:42/ghc?query#frag
the components are: