CR1 - Atidot/platform Wiki

General

Type annotations

producerPath :: Text
producerPath = "/home/atidot/platform/testDockers/producer"

Space your code

producerPath :: Text
producerPath = "/home/atidot/platform/testDockers/producer"

consumerPath :: Text
consumerPath = "/home/atidot/platform/testDockers/consumer"

launch :: Sh ()
launch "atidot/producer" = dummyLaunch -- startDockerLocal producerPath
launch "atidot/consumer" = pure () --startDockerLocal consumerPath

Qualified Imports

import           "text" Data.Text hiding (drop)
import qualified "text" Data.Text as T (drop)

startDockerLocal :: Text -> Text
startDockerLocal = T.drop 7

Imports

{-# LANGUAGE PackageImports #-}

import           "base"           Control.Monad.IO.Class (liftIO)
import           "base"           Data.Monoid ((<>))
import           "lens"           Control.Lens
import qualified "bytestring"     Data.ByteString.Char8 as B (unpack)
import qualified "text"           Data.Text as T (pack)
import           "platform-types" Platform.Types

Records

{-# LANGUAGE BangPatterns #-}
import "base" GHC.Generics  (Generic)
import "base" Data.Typeable (Typeable)
import "base" Data.Data     (Data)

data Direction
    = North
    | East
    | South
    | West
    deriving (Show, Read, Eq, Ord, Enum, Bounded, Typeable, Data, Generic)

data Turtle
    = Turtle
    { _turtle_x    :: !Int
    , _turtle_y    :: !Int
    , _turtle_vX   :: !Int
    , _turtle_vY   :: !Int
    , _turtle_head :: !Direction
    , _turtle_name :: !(Maybe String)
    } deriving (Show, Read, Eq, Ord, Typeable, Data, Generic)

Function Arguments

connect :: Text 
        -> Text
        -> Sh ()

Specific

Docker integration

16:09 [email protected]:~ $ ls -la /usr/bin
lrwxrwxrwx 66 root 13 Nov 23:48 env -> /nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin/env
16:09 [email protected]:~ $
data DockerCommand
    = Build
    | Pull
    | Start
    deriving (Show, Read, Eq, Ord, Enum, Bounded, Typeable, Data, Generic)

docker :: DockerCommand
       -> [Text]
       -> Sh ()
docker command args'
    = run_ (fromText "docker") args
    where
        args :: [Text]
        args = [T.toLower . T.pack . show $ command]
            <> args'