diff options
Diffstat (limited to 'examples/example0/Example0.hs')
-rw-r--r-- | examples/example0/Example0.hs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/example0/Example0.hs b/examples/example0/Example0.hs new file mode 100644 index 0000000..a8e74c3 --- /dev/null +++ b/examples/example0/Example0.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE Arrows #-} + +import Data.DocRecord +import qualified Data.Text.Lazy as T +import Porcupine + + +resultFile :: DataSink T.Text +resultFile = dataSink ["result"] $ + somePureSerial (PlainTextSerial (Just "txt")) + +myTask :: (LogThrow m) => PTask m () () +myTask = proc () -> do + (FV char :& FV num :& _) <- getMyOptions -< () + let txt = T.replicate (fromIntegral num) (T.singleton char) + writeData resultFile -< txt + where + getMyOptions = + getOptions ["options"] + ( docField @"char" 'a' "The character to repeat" + :& docField @"replications" (10::Int) "The number of replications" + :& RNil) + +main :: IO () +-- main = simpleRunPTask myTask () +main = runLocalPipelineTask (FullConfig "example0" "example0.yaml" "." ()) myTask () |