Working out the datatypes.

This commit is contained in:
Elliot Glaysher 2019-05-15 17:00:10 -07:00
parent 90470dc67d
commit 7dfc6b9c19
4 changed files with 110 additions and 0 deletions

26
pkg/hair/lib/Vere.hs Normal file
View File

@ -0,0 +1,26 @@
module Vere where
import ClassyPrelude
import Data.Void
import qualified Vere.Http.Server as Server
import qualified Vere.Http.Client as Client
-- +vere -----------------------------------------------------------------------
data WTFIsThis
= WTFIsThis (Maybe Varience) TheActualFuckingThing
data Varience = Gold | Iron | Lead
data TheActualFuckingThing
= HttpServer Server.Eff
| HttpClient Client.Eff
| Behn Void
| Clay Void
| Boat Void
| Sync Void
| Newt Void
| Ames Void
| Init Void
| Term Void

37
pkg/hair/lib/Vere/Http.hs Normal file
View File

@ -0,0 +1,37 @@
-- zuse: +http -----------------------------------------------------------------
module Vere.Http where
import ClassyPrelude
import Data.Noun
data Header = Header Text Text
data Method = CONNECT
| DELETE
| GET
| HEAD
| OPTIONS
| POST
| PUT
| TRACE
deriving (Eq,Ord,Show)
data Request = Request
{ method :: Method
, url :: Text
, headerList :: [Header]
, body :: Maybe ByteString
}
data ResponseHeader = ResponseHeader
{ statusCode :: Integer
, headers :: [Header]
}
data Event = Start ResponseHeader (Maybe ByteString) Bool
| Continue (Maybe ByteString) Bool
| Cancel
--instance FromNoun Event where
-- fromNoun = undefined

View File

@ -0,0 +1,12 @@
-- +http-client ----------------------------------------------------------------
module Vere.Http.Client where
import ClassyPrelude
import Vere.Http
-- | An http client effect is either requesting outbound, or canceling an old
-- outbound connection.
data Eff
= Request Word Request
| CancelRequest Word

View File

@ -0,0 +1,35 @@
-- +http-server ----------------------------------------------------------------
module Vere.Http.Server where
import ClassyPrelude
import Vere.Http
type ServerId = Word
type ConnectionId = Word
type RequestId = Word
data Eff = Eff ServerId ConnectionId RequestId ServerRequest
-- | An http server effect is configuration, or it sends an outbound response
data ServerRequest
= SetConfig Config
| Response Event
data Config = Config
{ secure :: Maybe (Key, Cert)
, proxy :: Bool
, log :: Bool
, redirect :: Bool
}
newtype Key = Key Wain
newtype Cert = Cert Wain
data Wain = Wain [Text]
data ClientResponse
= Progress ResponseHeader Int (Maybe Int) (Maybe ByteString)
| Finished ResponseHeader (Maybe MimeData)
| Cancel
data MimeData = MimeData Text ByteString