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" - )
Synopsis

Functions

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.

runP2PRC #

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.

Example

Expand

This example demonstrates how it can be ran on the IO context:

 example :: IO ()
+    )
Synopsis

Functions

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.

runP2PRC #

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.

Example

Expand

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.

Example

Expand

The following example show how this function can be used to expose the runtime functionalities:

 example :: IOEitherError P2PRCapi
- example = do
+ 

p2prcAPI :: P2PRCapi #

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.

Example

Expand

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
- 

Data Types

This section describes and explains the library's type system, more specifically, the interfaces and primitive types.

Interface data types

This section gives an overview on the runtime and host machine interfaces.

data P2PRCapi #

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

Instances

Instances details
FromJSON P2prcConfig # 
Instance details

Defined in JSON

Show P2prcConfig # 
Instance details

Defined in JSON

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

Fields

  • Int

    TCP socket number

  • String

    Network domain name

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

  • String

    Column separated Host's IP address and Port String

Instances

Instances details
FromJSON MapPortResponse # 
Instance details

Defined in JSON

Show MapPortResponse # 
Instance details

Defined in JSON

Primitive data types

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

Instances

Instances details
FromJSON IPAddressTable # 
Instance details

Defined in JSON

Show IPAddressTable # 
Instance details

Defined in JSON

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

Instances

Instances details
FromJSON ServerInfo # 
Instance details

Defined in JSON

Show ServerInfo # 
Instance details

Defined in JSON

data IPAddress #

This is a simple representation of the IP address of nodes in the network.

Constructors

MkIPv4 String

IP version 4 address

MkIPv6 String

IP version 6 address

Instances

Instances details
Show IPAddress # 
Instance details

Defined in JSON

data Error #

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

Fields

MkErrorSpawningProcess

Spawing process error

Fields

  • String

    Spawning executable name

MkUnknownError

This is an unparsed P2PRC's error

Fields

Instances

Instances details
Show Error # 
Instance details

Defined in Error

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

Type Synonyms

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

\ No newline at end of file + -- your code logic goes here + + where + + MkP2PRCapi + { startServer=startServer + , execMapPort=execMapPort + , execListServers=execListServers + , execInitConfig=execInitConfig + } = p2prcAPI +

Data Types

This section describes and explains the library's type system, more specifically, the interfaces and primitive types.

Interface data types

This section gives an overview on the runtime and host machine interfaces.

data P2PRCapi #

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

Instances

Instances details
FromJSON P2prcConfig # 
Instance details

Defined in JSON

Show P2prcConfig # 
Instance details

Defined in JSON

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

Fields

  • Int

    TCP socket number

  • String

    Network domain name

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

  • String

    Column separated Host's IP address and Port String

Instances

Instances details
FromJSON MapPortResponse # 
Instance details

Defined in JSON

Show MapPortResponse # 
Instance details

Defined in JSON

Primitive data types

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

Instances

Instances details
FromJSON IPAddressTable # 
Instance details

Defined in JSON

Show IPAddressTable # 
Instance details

Defined in JSON

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

Instances

Instances details
FromJSON ServerInfo # 
Instance details

Defined in JSON

Show ServerInfo # 
Instance details

Defined in JSON

data IPAddress #

This is a simple representation of the IP address of nodes in the network.

Constructors

MkIPv4 String

IP version 4 address

MkIPv6 String

IP version 6 address

Instances

Instances details
Show IPAddress # 
Instance details

Defined in JSON

data Error #

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

Fields

MkErrorSpawningProcess

Spawing process error

Fields

  • String

    Spawning executable name

MkUnknownError

This is an unparsed P2PRC's error

Fields

Instances

Instances details
Show Error # 
Instance details

Defined in Error

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

Type Synonyms

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

\ No newline at end of file diff --git a/Docs/haskell/P2PRC.md b/Docs/haskell/P2PRC.md deleted file mode 100644 index a5c96dd..0000000 --- a/Docs/haskell/P2PRC.md +++ /dev/null @@ -1,120 +0,0 @@ -
- -p2prc-0.1.0.0: P2PRC haskell library - -- [Contents](index.html) -- [Index](doc-index.html) - -
- -
- -
- -| | | -|--------------|-----------------------------------------| -| Copyright | Copyright (C) 2006-2024 John MacFarlane | -| License | GNU GPL, version 2 or above | -| Maintainer | John MacFarlane \ | -| Stability | alpha | -| Portability | portable | -| Safe Haskell | Safe-Inferred | -| Language | GHC2021 | - -P2PRC - -
- -
- -Description - -
- -This helper module exports the main writers, readers, and data structure -definitions from the Pandoc libraries. - -A typical application will chain together a reader and a writer to -convert strings from one format to another. For example, the following -simple program will act as a filter converting markdown fragments to -reStructuredText, using reference-style links instead of inline links: - - module Main where - import Text.Pandoc - import Data.Text (Text) - import qualified Data.Text.IO as T - - mdToRST :: Text -> IO Text - mdToRST txt = runIOorExplode $ - readMarkdown def txt - >>= writeRST def{ writerReferenceLinks = True } - - main :: IO () - main = do - T.getContents >>= mdToRST >>= T.putStrLn - -
- -
- -
- -Synopsis - -- [runP2PRC](#v:runP2PRC) :: - [MapPortRequest](P2PRC.html#t:MapPortRequest "P2PRC") -\> - [IO]($%7Bpkgroot%7D/../../../../dcnyq1a8qi8x59n5p53d0dx42cl8hf8x-ghc-9.6.5-doc/share/doc/ghc/html/libraries/base-4.18.2.1/System-IO.html#t:IO "System.IO") - () -- data [MapPortRequest](#t:MapPortRequest) - = [MkMapPortRequest](#v:MkMapPortRequest) - [Int]($%7Bpkgroot%7D/../../../../dcnyq1a8qi8x59n5p53d0dx42cl8hf8x-ghc-9.6.5-doc/share/doc/ghc/html/libraries/base-4.18.2.1/Data-Int.html#t:Int "Data.Int") - [String]($%7Bpkgroot%7D/../../../../dcnyq1a8qi8x59n5p53d0dx42cl8hf8x-ghc-9.6.5-doc/share/doc/ghc/html/libraries/base-4.18.2.1/Data-String.html#t:String "Data.String") - -
- -
- -# Documentation - -
- -runP2PRC :: -[MapPortRequest](P2PRC.html#t:MapPortRequest "P2PRC") -\> -[IO]($%7Bpkgroot%7D/../../../../dcnyq1a8qi8x59n5p53d0dx42cl8hf8x-ghc-9.6.5-doc/share/doc/ghc/html/libraries/base-4.18.2.1/System-IO.html#t:IO "System.IO") -() # - -
- -Hello World - -
- -
- -
- -data MapPortRequest -# - -
- -Constructors - -| | | -|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----| -| MkMapPortRequest [Int]($%7Bpkgroot%7D/../../../../dcnyq1a8qi8x59n5p53d0dx42cl8hf8x-ghc-9.6.5-doc/share/doc/ghc/html/libraries/base-4.18.2.1/Data-Int.html#t:Int "Data.Int") [String]($%7Bpkgroot%7D/../../../../dcnyq1a8qi8x59n5p53d0dx42cl8hf8x-ghc-9.6.5-doc/share/doc/ghc/html/libraries/base-4.18.2.1/Data-String.html#t:String "Data.String") |   | - -
- -
- -
- -
- - diff --git a/Docs/haskell/doc-index.html b/Docs/haskell/doc-index.html index f5cfe01..ec5d110 100644 --- a/Docs/haskell/doc-index.html +++ b/Docs/haskell/doc-index.html @@ -1 +1 @@ -p2prc-0.1.0.0: P2PRC haskell library (Index)
p2prc-0.1.0.0: P2PRC haskell library

Index

bareMetalSSHPortP2PRC
customInformationP2PRC
downloadP2PRC
ErrorP2PRC
escapeImplementationP2PRC
execInitConfigP2PRC
execListServersP2PRC
execMapPortP2PRC
getP2prcAPIP2PRC
IOEitherErrorP2PRC
ipP2PRC
IPAddressP2PRC
IPAddressTableP2PRC
latencyP2PRC
machineNameP2PRC
MapPortRequestP2PRC
MapPortResponseP2PRC
MkCLISystemErrorP2PRC
MkErrorSpawningProcessP2PRC
MkIPAddressTableP2PRC
MkIPv4P2PRC
MkIPv6P2PRC
MkMapPortRequestP2PRC
MkMapPortResponseP2PRC
MkP2PRCapiP2PRC
MkP2prConfigP2PRC
MkServerInfoP2PRC
MkUnknownErrorP2PRC
nameP2PRC
natP2PRC
P2PRCapiP2PRC
P2prcConfigP2PRC
runP2PRCP2PRC
ServerInfoP2PRC
serverPortP2PRC
startServerP2PRC
uploadP2PRC
\ No newline at end of file +p2prc-0.1.0.0: P2PRC haskell library (Index)
p2prc-0.1.0.0: P2PRC haskell library

Index

bareMetalSSHPortP2PRC
customInformationP2PRC
downloadP2PRC
ErrorP2PRC
escapeImplementationP2PRC
execInitConfigP2PRC
execListServersP2PRC
execMapPortP2PRC
IOEitherErrorP2PRC
ipP2PRC
IPAddressP2PRC
IPAddressTableP2PRC
latencyP2PRC
machineNameP2PRC
MapPortRequestP2PRC
MapPortResponseP2PRC
MkCLISystemErrorP2PRC
MkErrorSpawningProcessP2PRC
MkIPAddressTableP2PRC
MkIPv4P2PRC
MkIPv6P2PRC
MkMapPortRequestP2PRC
MkMapPortResponseP2PRC
MkP2PRCapiP2PRC
MkP2prConfigP2PRC
MkServerInfoP2PRC
MkUnknownErrorP2PRC
nameP2PRC
natP2PRC
P2PRCapiP2PRC
p2prcAPIP2PRC
P2prcConfigP2PRC
runP2PRCP2PRC
ServerInfoP2PRC
serverPortP2PRC
startServerP2PRC
uploadP2PRC
\ No newline at end of file diff --git a/Docs/haskell/doc-index.md b/Docs/haskell/doc-index.md deleted file mode 100644 index 11b10db..0000000 --- a/Docs/haskell/doc-index.md +++ /dev/null @@ -1,30 +0,0 @@ -
- -p2prc-0.1.0.0: P2PRC haskell library - -- [Contents](index.html) -- [Index](doc-index.html) - -
- -
- -
- -Index - -| | | -|------------------|------------------------------------------------| -| MapPortRequest | [P2PRC](P2PRC.html#t:MapPortRequest "P2PRC") | -| MkMapPortRequest | [P2PRC](P2PRC.html#v:MkMapPortRequest "P2PRC") | -| runP2PRC | [P2PRC](P2PRC.html#v:runP2PRC "P2PRC") | - -
- -
- - diff --git a/Docs/haskell/index.md b/Docs/haskell/index.md deleted file mode 100644 index 5a74ed5..0000000 --- a/Docs/haskell/index.md +++ /dev/null @@ -1,44 +0,0 @@ -
- -p2prc-0.1.0.0: P2PRC haskell library - -- [Contents](index.html) -- [Index](doc-index.html) - -
- -
- -
- -# p2prc-0.1.0.0: P2PRC haskell library - -
- -Implements a client interface to the P2PRC networking runtime - -
- -
- -
- -Modules - -
- -p2prc-0.1.0.0 - --  [P2PRC](P2PRC.html) - -
- -
- -
- - diff --git a/Docs/haskell/p2prc.haddock b/Docs/haskell/p2prc.haddock index af23673..b9863d9 100644 Binary files a/Docs/haskell/p2prc.haddock and b/Docs/haskell/p2prc.haddock differ