diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2024-08-02 17:44:25 +0200 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2024-08-02 17:44:25 +0200 |
| commit | 749e96d23a6a71139ef84322708e6b1338072b7d (patch) | |
| tree | 3e94053256aa8fee5a34100a15fbcb30319ef632 /wayland | |
initial commit
Diffstat (limited to 'wayland')
| -rw-r--r-- | wayland/Wayland/Server.hs | 77 | ||||
| -rw-r--r-- | wayland/wayland.cabal | 17 |
2 files changed, 94 insertions, 0 deletions
diff --git a/wayland/Wayland/Server.hs b/wayland/Wayland/Server.hs new file mode 100644 index 0000000..9162d5e --- /dev/null +++ b/wayland/Wayland/Server.hs @@ -0,0 +1,77 @@ +{-# LANGUAGE ExistentialQuantification #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE UndecidableInstances #-} + +module Wayland.Server + ( Request(..) + , ObjectID + , Global + , DisplayM(..) + , Resource(..) + , fromRequest + , withDisplay + , bindSocket + , processRequests + , flushEvents + , sendEvent + , destroyResource + , registerGlobal + , unregisterGlobal + ) where + +import Data.Typeable (Typeable, cast) +import Data.Kind (Type) +import Control.Monad.State.Strict (StateT, MonadState(..), MonadIO(..)) +import Lens.Micro.Mtl.Internal (Zoom(..), Zoomed) + +data DisplayState + +data Global + +newtype ObjectID = ObjectID String + deriving (Show, Eq, Ord) + +class Resource r where + type ResourceRequest r :: Type + type ResourceEvent r :: Type + objectID :: r -> ObjectID + +data Request = forall a. Typeable a => Request a + +newtype DisplayM s a = DisplayM { runDisplayM :: StateT s (StateT DisplayState IO) a } + deriving (Functor, Applicative, Monad, MonadIO, MonadState s) + +type instance Zoomed (DisplayM s) = Zoomed (StateT s (StateT DisplayState IO)) + +instance Zoom (DisplayM s) (DisplayM t) s t where + zoom l (DisplayM m) = DisplayM (zoom l m) + +fromRequest :: Typeable a => Request -> Maybe a +fromRequest (Request x) = cast x + +withDisplay :: s -> DisplayM s a -> IO (s, a) +withDisplay _ _ = undefined + +bindSocket :: DisplayM s String +bindSocket = undefined + +processRequests :: (Request -> DisplayM s ()) -> DisplayM s () +processRequests _ = undefined + +sendEvent :: Resource r => r -> ResourceEvent r -> DisplayM s () +sendEvent _ _ = undefined + +flushEvents :: DisplayM s () +flushEvents = undefined + +destroyResource :: Resource r => r -> DisplayM s () +destroyResource _ = undefined + +registerGlobal :: Resource r => Typeable req => (r -> req) -> DisplayM s Global +registerGlobal _ = undefined + +unregisterGlobal :: Global -> DisplayM s () +unregisterGlobal _ = undefined diff --git a/wayland/wayland.cabal b/wayland/wayland.cabal new file mode 100644 index 0000000..b34d9a0 --- /dev/null +++ b/wayland/wayland.cabal @@ -0,0 +1,17 @@ +cabal-version: 3.0 +name: highway-wayland +version: 1.0.0 +synopsis: Low-level API for implementing the Wayland protocol. +build-type: Simple + +common warnings + ghc-options: -Wall + +library + import: warnings + build-depends: base ^>=4.18.2.1, + mtl, + microlens, + microlens-mtl + default-language: Haskell2010 + exposed-modules: Wayland.Server |
