diff --git a/Bindings/Haskell/flake.lock b/Bindings/Haskell/flake.lock index 09f35b2..b20190e 100644 --- a/Bindings/Haskell/flake.lock +++ b/Bindings/Haskell/flake.lock @@ -79,12 +79,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-SNCJZpBetNSp/V2z/ywWb11HjBWmos9uHUM+LRC4ZyI=", - "path": "/nix/store/kf835db5hb805pmbrigx9dsq8pkdmfz6-source", + "narHash": "sha256-f4e4JcQzBS+R+8HqJbQVeecInm2ggInJuSSymj6gtQo=", + "path": "/nix/store/hmk8v0lxifsscll054qsdnzxqfql1998-source", "type": "path" }, "original": { - "path": "/nix/store/kf835db5hb805pmbrigx9dsq8pkdmfz6-source", + "path": "/nix/store/hmk8v0lxifsscll054qsdnzxqfql1998-source", "type": "path" } }, diff --git a/Bindings/Haskell/gen_docs.sh b/Bindings/Haskell/gen_docs.sh index d732d17..44ad4dc 100755 --- a/Bindings/Haskell/gen_docs.sh +++ b/Bindings/Haskell/gen_docs.sh @@ -1,9 +1,11 @@ #!/bin/bash +rm -rf dist-newstyle/ cabal haddock +rm -rf ../../Docs/haskell -rm -rf ../Docs/haskell - -cp -r ./dist-newstyle/build/x86_64-linux/ghc-9.6.5/p2prc-0.1.0.0/doc/html/p2prc/ ../Docs/haskell +cp -r \ + ./dist-newstyle/build/x86_64-linux/ghc-9.6.6/p2prc-0.1.0.0/doc/html/p2prc/ \ + ../../Docs/haskell diff --git a/Bindings/Haskell/lib/API.hs b/Bindings/Haskell/lib/API.hs index 1d881d0..d82fbb1 100644 --- a/Bindings/Haskell/lib/API.hs +++ b/Bindings/Haskell/lib/API.hs @@ -58,31 +58,35 @@ data MapPortRequest = {-| - This function intiates a pure P2PRC runtime state and builds up a 'P2PRCapi' API instance. + This function intiates a pure P2PRC runtime state and builds up a 'P2PRCapi' API instance. It allows a developer to create computing orchestration algorithms using the API primitives. ==== __Example__ The following example show how this function can be used to expose the runtime functionalities: @ - example :: IOEitherError P2PRCapi - example = do +module Main where - eitherP2prcAPI <- getP2prcAPI +import P2PRC + ( p2prcAPI + , P2PRCapi(..) + ) - case eitherP2prcAPI of - ( Right - ( MkP2PRCapi - { startServer = startServer - , execInitConfig = execInitConfig - , execListServers = execListServers - , execMapPort = execMapPort - } - )) -> do +main :: IO () +main = - -- Your code logic + print "Hello P2PRC" - errValue -> errValue + -- your code logic goes here + + where + + MkP2PRCapi + { startServer=startServer + , execMapPort=execMapPort + , execListServers=execListServers + , execInitConfig=execInitConfig + } = p2prcAPI @ -} @@ -139,6 +143,7 @@ p2prcAPI = execProcP2PrcParser :: FromJSON a => [CLIOpt] -> StdInput -> IOEitherError a + execProcP2PrcParser = eitherExecProcessParser p2PrcCmdName -- TODO: GHC question, why does it scope down instead staying generic diff --git a/Bindings/Haskell/lib/CLI.hs b/Bindings/Haskell/lib/CLI.hs index caef85c..ff0b69e 100644 --- a/Bindings/Haskell/lib/CLI.hs +++ b/Bindings/Haskell/lib/CLI.hs @@ -77,7 +77,6 @@ eitherExecProcess cmd opts input = ExitFailure i -> Left $ MkCLISystemError i cmd err _ -> Right out - optsToCLI :: [CLIOpt] -> CLIOptsInput optsToCLI = concatMap _optToCLI where diff --git a/Bindings/Haskell/lib/Engine.hs b/Bindings/Haskell/lib/Engine.hs index ac4b3f7..4a78e77 100644 --- a/Bindings/Haskell/lib/Engine.hs +++ b/Bindings/Haskell/lib/Engine.hs @@ -60,7 +60,13 @@ import API runP2PRC :: MapPortRequest -- ^ TCP Port Request -> IO () -runP2PRC (MkMapPortRequest portNumber domainName) = let +runP2PRC + ( MkMapPortRequest + portNumber + domainName + ) + = + let -- -- TODO: add quickcheck testing (quickchecking-dynamic) diff --git a/Docs/haskell/P2PRC.html b/Docs/haskell/P2PRC.html index 9c67729..606121b 100644 --- a/Docs/haskell/P2PRC.html +++ b/Docs/haskell/P2PRC.html @@ -9,28 +9,32 @@ main :: IO () main = runP2PRC ( MkMapPortRequest 8080 "jose.akilan.io" - )
These are the available functions available to interact with the P2Prc environment, at a lower level of abstraction. - It is intended this way to give freedom to the developer to implement their own orchestration strategies.
Arguments
| :: MapPortRequest | TCP Port Request |
| -> IO () |
This function starts and bootstraps the P2PRC runtime that associates the a specific host's machine port to a DNS address to expose a certain application to the P2PRC network. You will only need to also import the MkMapPortRequest data constructor to represent the this port request.
This example demonstrates how it can be ran on the IO context:
example :: IO () + )
These are the available functions available to interact with the P2Prc environment, at a lower level of abstraction. + It is intended this way to give freedom to the developer to implement their own orchestration strategies.
Arguments
| :: MapPortRequest | TCP Port Request |
| -> IO () |
This function starts and bootstraps the P2PRC runtime that associates the a specific host's machine port to a DNS address to expose a certain application to the P2PRC network. You will only need to also import the MkMapPortRequest data constructor to represent the this port request.
This example demonstrates how it can be ran on the IO context:
example :: IO ()
example = do
runP2PRC
( MkMapPortRequest 8080 "jose.akilan.io"
)
- getP2prcAPI :: IOEitherError P2PRCapi #
Warning: This function is currently unstable since it assumes that the Haskell program is executed from the P2PRC "haskell" subfolder and the "p2prc" executable in the the root folder.
This function cleans the previous running state (ensuring a pure P2PRC runtime state) and builds up a conditional P2PRCapi instance.
The following example show how this function can be used to expose the runtime functionalities:
example :: IOEitherError P2PRCapi - example = do +
Warning: This function is currently unstable because the configuration reading is dependent on the following issue: https://github.com/Akilan1999/p2p-rendering-computation/issues/120
This function intiates a pure P2PRC runtime state and builds up a P2PRCapi API instance. It allows a developer to create computing orchestration algorithms using the API primitives.
The following example show how this function can be used to expose the runtime functionalities:
module Main where
- eitherP2prcAPI <- getP2prcAPI
+import P2PRC
+ ( p2prcAPI
+ , P2PRCapi(..)
+ )
- case eitherP2prcAPI of
- ( Right
- ( MkP2PRCapi
- { startServer = startServer
- , execInitConfig = execInitConfig
- , execListServers = execListServers
- , execMapPort = execMapPort
- }
- )) -> do
+main :: IO ()
+main =
- -- Your code logic
+ print "Hello P2PRC"
- errValue -> errValue
- This section describes and explains the library's type system, more specifically, the interfaces and primitive types.
This section gives an overview on the runtime and host machine interfaces.
Lower level P2PRC Haskell api that exposes basic functionality necessary to joint the network.
Constructors
| MkP2PRCapi | |
Fields
| |
newtype P2prcConfig #
Warning: This type is unstable at the moment due to the P2PRC's library error handling bug. For more information visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114#issuecomment-2474737015
This represents the server configuration that defines its attributes and behaviours in the network, as well as, the location of the runtime persistence artifacts.
Constructors
| MkP2prConfig | |
Fields
| |
| FromJSON P2prcConfig # | |
Defined in JSON | |
| Show P2prcConfig # | |
Defined in JSON Methods showsPrec :: Int -> P2prcConfig -> ShowS # show :: P2prcConfig -> String # showList :: [P2prcConfig] -> ShowS # | |
data MapPortRequest #
This defines the request required to create an association between a TCP socket port and a DNS server in the network. If successful, it makes a resource available in the network.
Constructors
| MkMapPortRequest | P2PRC's port allocation request value |
newtype MapPortResponse #
Warning: This newtype is unstable at the moment due to the P2PRC's library error handling bug. For more information visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114#issuecomment-2474737015
This represents P2PRC's response to the TCP port and DNS address allocation. This value will confirm the successful allocation and return information about it.
Constructors
| MkMapPortResponse | Allocation information value |
Fields
| |
| FromJSON MapPortResponse # | |
Defined in JSON Methods parseJSON :: Value -> Parser MapPortResponse # parseJSONList :: Value -> Parser [MapPortResponse] # | |
| Show MapPortResponse # | |
Defined in JSON Methods showsPrec :: Int -> MapPortResponse -> ShowS # show :: MapPortResponse -> String # showList :: [MapPortResponse] -> ShowS # | |
These types represent the core data that is communicated between requests and the runtime.
newtype IPAddressTable #
Warning: This newtype is highly unstable due to undergoing work on improving P2PRC's server api. For more information, visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114
This is a wrapper value that parses a json key value from the list of ip addresses in the network.
Constructors
| MkIPAddressTable | Wrapping constructor |
Fields
| |
| FromJSON IPAddressTable # | |
Defined in JSON Methods parseJSON :: Value -> Parser IPAddressTable # parseJSONList :: Value -> Parser [IPAddressTable] # | |
| Show IPAddressTable # | |
Defined in JSON Methods showsPrec :: Int -> IPAddressTable -> ShowS # show :: IPAddressTable -> String # showList :: [IPAddressTable] -> ShowS # | |
data ServerInfo #
Warning: This type is highly unstable due to undergoing work on improving P2PRC's server api. For more information, visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114
This is a record that keeps track of the current state of every node in the network. It is crucial information required for orchestration strategies.
Constructors
| MkServerInfo | |
Fields
| |
| FromJSON ServerInfo # | |
Defined in JSON | |
| Show ServerInfo # | |
Defined in JSON Methods showsPrec :: Int -> ServerInfo -> ShowS # show :: ServerInfo -> String # showList :: [ServerInfo] -> ShowS # | |
This is a simple representation of the IP address of nodes in the network.
Haskell-side Error value. This type is designed to parse and track System and P2PRC's error signals in a safe and effective manner.
It does have an MkUnknownError value which is meant to be warn about new kinds of error not yet accounted in this client. Github issues and pull requests are very welcome to improve error handling by parsing more types of errors.
Constructors
| MkCLISystemError | This is a CLI System Error |
| MkErrorSpawningProcess | Spawing process error |
Fields
| |
| MkUnknownError | This is an unparsed P2PRC's error |
Fields
| |
This section is reserved to some useful type synonyms that add significant ergonomics.
type IOEitherError a = IO (Either Error a) #
Type synonym for an IO action with either returns an Error or a parsed value