p2p --pair with magic wormhole (untested)
It builds. I have not tried to run it yet. :) This commit was sponsored by Jake Vosloo on Patreon.
This commit is contained in:
parent
b2b6296f9d
commit
ccde0932a5
8 changed files with 288 additions and 79 deletions
|
@ -5,9 +5,11 @@
|
|||
- License: BSD-2-clause
|
||||
-}
|
||||
|
||||
module Utility.MagicWormHole (
|
||||
module Utility.MagicWormhole (
|
||||
Code,
|
||||
mkCode,
|
||||
toCode,
|
||||
fromCode,
|
||||
validCode,
|
||||
CodeObserver,
|
||||
CodeProducer,
|
||||
|
@ -32,9 +34,11 @@ import System.Exit
|
|||
import Control.Concurrent
|
||||
import Control.Exception
|
||||
import Data.Char
|
||||
import Data.List
|
||||
|
||||
-- | A Magic Wormhole code.
|
||||
newtype Code = Code String
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- | Smart constructor for Code
|
||||
mkCode :: String -> Maybe Code
|
||||
|
@ -42,6 +46,13 @@ mkCode s
|
|||
| validCode s = Just (Code s)
|
||||
| otherwise = Nothing
|
||||
|
||||
-- | Tries to fix up some common mistakes in a homan-entered code.
|
||||
toCode :: String -> Maybe Code
|
||||
toCode s = mkCode $ intercalate "-" $ words s
|
||||
|
||||
fromCode :: Code -> String
|
||||
fromCode (Code s) = s
|
||||
|
||||
-- | Codes have the form number-word-word and may contain 2 or more words.
|
||||
validCode :: String -> Bool
|
||||
validCode s =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue