Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Types related to Share and Codeservers.
Synopsis
- data CodeserverURI = CodeserverURI {}
- newtype CodeserverId = CodeserverId {
- codeserverId :: Text
- data Scheme
- codeserverFromURI :: URI -> Maybe CodeserverURI
- codeserverIdFromURI :: URI -> Either Text CodeserverId
- codeserverToURI :: CodeserverURI -> URI
- codeserverIdFromCodeserverURI :: CodeserverURI -> CodeserverId
- codeserverBaseURL :: CodeserverURI -> BaseUrl
Documentation
data CodeserverURI Source #
This type is expanded out into all of its fields because we require certain pieces which are optional in a URI, and also to make it more typesafe to eventually convert into a BaseURL for servant clients.
Instances
Show CodeserverURI Source # | |
Defined in Unison.Share.Types showsPrec :: Int -> CodeserverURI -> ShowS # show :: CodeserverURI -> String # showList :: [CodeserverURI] -> ShowS # | |
Eq CodeserverURI Source # | |
Defined in Unison.Share.Types (==) :: CodeserverURI -> CodeserverURI -> Bool # (/=) :: CodeserverURI -> CodeserverURI -> Bool # | |
Ord CodeserverURI Source # | |
Defined in Unison.Share.Types compare :: CodeserverURI -> CodeserverURI -> Ordering # (<) :: CodeserverURI -> CodeserverURI -> Bool # (<=) :: CodeserverURI -> CodeserverURI -> Bool # (>) :: CodeserverURI -> CodeserverURI -> Bool # (>=) :: CodeserverURI -> CodeserverURI -> Bool # max :: CodeserverURI -> CodeserverURI -> CodeserverURI # min :: CodeserverURI -> CodeserverURI -> CodeserverURI # |
newtype CodeserverId Source #
This is distinct from the codeserver URI in that we store credentials by a normalized ID, since it's much easier to look up that way than from an arbitrary path. We may wish to use explicitly named configurations in the future. This currently uses a stringified uriAuthority.
Instances
codeserverFromURI :: URI -> Maybe CodeserverURI Source #
>>>
import Data.Maybe (fromJust)
>>>
codeserverFromURI . fromJust $ parseURI "http://localhost:8080"
Just http://localhost:8080>>>
codeserverFromURI . fromJust $ parseURI "http://localhost:80"
Just http://localhost:80>>>
codeserverFromURI . fromJust $ parseURI "https://share.unison-lang.org/api"
Just https://share.unison-lang.org/api>>>
codeserverFromURI . fromJust $ parseURI "http://share.unison-lang.org/api"
Just http://share.unison-lang.org/api
codeserverIdFromURI :: URI -> Either Text CodeserverId Source #
Gets the part of the CodeserverURI that we use for identifying that codeserver in credentials files.
>>>
import Data.Maybe (fromJust)
>>>
import Network.URI (parseURI)
>>>
codeserverIdFromURI (fromJust $ parseURI "http://localhost:5424/api")
>>>
codeserverIdFromURI (fromJust $ parseURI "https://share.unison-lang.org/api")
Right "localhost:5424" Right "share.unison-lang.org"
codeserverToURI :: CodeserverURI -> URI Source #
codeserverIdFromCodeserverURI :: CodeserverURI -> CodeserverId Source #
Gets the CodeserverId for a given CodeserverURI
codeserverBaseURL :: CodeserverURI -> BaseUrl Source #
Builds a servant-compatible BaseUrl for a given CodeserverURI.