Skip to content

Commit

Permalink
switch from monadic to applicative syntax where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
mengwong committed Oct 7, 2022
1 parent 1fb2d2d commit 091b824
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/ToDMN/FromSimpleToReg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module ToDMN.FromSimpleToReg where

import ToDMN.Types
import Text.StringRandom
import qualified Data.Text.Lazy as TL
import qualified System.Random as Random
import qualified Data.Text as T

mkID :: String -> IO String
Expand All @@ -30,9 +28,9 @@ sInfoReqToInfoReq (SimpleReqInputEl reqInput) = do

sSchemaToSchema :: SimpleSchema -> IO Schema
sSchemaToSchema (SimpleSchema sInputSchemas' sOutputSchema') = do
sins <- mapM sInputSchemaToInputSchema sInputSchemas'
souts <- sOutputSchemaToOutputSchema sOutputSchema'
return $ Schema sins souts
Schema
<$> mapM sInputSchemaToInputSchema sInputSchemas'
<*> sOutputSchemaToOutputSchema sOutputSchema'

sInputSchemaToInputSchema :: SimpleInputSchema -> IO InputSchema
sInputSchemaToInputSchema (SimpleInputSchema sInpExprVarName sInpExprFEELType) = do
Expand All @@ -49,10 +47,10 @@ sOutputSchemaToOutputSchema (SimpleOutputSchema sOutSchemaVarName sOutSchemaFEEL

sDMNRuleToDMNRule :: SimpleDMNRule -> IO DMNRule
sDMNRuleToDMNRule (SimpleDMNRule sInpEntries sOutputEntry') = do
iddr <- mkID "DecisionRule"
sinps <- mapM sInputEntryToInputEntry sInpEntries
souts <- sOutputEntryToOutputEntry sOutputEntry'
return $ DMNRule iddr sinps souts
DMNRule
<$> mkID "DecisionRule"
<*> mapM sInputEntryToInputEntry sInpEntries
<*> sOutputEntryToOutputEntry sOutputEntry'

sInputEntryToInputEntry :: SimpleInputEntry -> IO InputEntry
sInputEntryToInputEntry (SimpleInputEntry mCondition) = do
Expand All @@ -61,5 +59,4 @@ sInputEntryToInputEntry (SimpleInputEntry mCondition) = do

sOutputEntryToOutputEntry :: SimpleOutputEntry -> IO OutputEntry
sOutputEntryToOutputEntry (SimpleOutputEntry feelExpr) = do
idle <- mkID "LiteralExpression"
return $ OutputEntry idle feelExpr
OutputEntry <$> mkID "LiteralExpression" <*> pure feelExpr

0 comments on commit 091b824

Please sign in to comment.