This commit brings in an HLint configuration file and several recommended modifications such as: * End-of-line extra spaces removal; * Import lines ordering; * Redundant $ removal; * Generalisation of ++ and map to <> and fmap; * Preferring `pure` over `return`; * Removing extraenous extensions. And finally, a `stylish-haskell` helper script that detects if code files are dirty. Can be useful for CI, although manually calling it can be nice if you would rather first implement then beautify.
32 lines
1 KiB
Haskell
32 lines
1 KiB
Haskell
module Main where
|
|
|
|
import Control.Concurrent
|
|
import Data.IP (IPv6, toHostAddress6)
|
|
import System.Environment
|
|
|
|
import Hash2Pub.FediChord
|
|
|
|
main :: IO ()
|
|
main = do
|
|
-- ToDo: parse and pass config
|
|
-- probably use `tomland` for that
|
|
conf <- readConfig
|
|
-- ToDo: load persisted caches, bootstrapping nodes …
|
|
(serverSock, thisNode) <- fediChordInit conf
|
|
print thisNode
|
|
print serverSock
|
|
-- currently no masking is necessary, as there is nothing to clean up
|
|
cacheWriterThread <- forkIO $ cacheWriter thisNode
|
|
-- idea: list of bootstrapping nodes, try joining within a timeout
|
|
-- stop main thread from terminating during development
|
|
getChar
|
|
pure ()
|
|
|
|
readConfig :: IO FediChordConf
|
|
readConfig = do
|
|
confDomainString : ipString : portString : _ <- getArgs
|
|
pure $ FediChordConf {
|
|
confDomain = confDomainString
|
|
, confIP = toHostAddress6 . read $ ipString
|
|
, confDhtPort = read portString
|
|
}
|