mirror of
https://github.com/zoriya/applicative-getopt.git
synced 2026-05-27 16:42:06 +00:00
Starting the wolfram
This commit is contained in:
+21
-6
@@ -3,13 +3,28 @@ module Main where
|
||||
import Lib
|
||||
import MyGetOpt
|
||||
|
||||
data Cell = Empty | Full
|
||||
newType CellList = CellList { left :: [], middle :: [], right :: [] }
|
||||
|
||||
run :: Int -> [CellList]
|
||||
run _ = []
|
||||
|
||||
printCells :: Configuration -> [CellList] -> IO()
|
||||
printCells _ [] = return
|
||||
printCells config (x:xs) = pl x >> printCells config xs
|
||||
where
|
||||
pl cl =
|
||||
|
||||
main :: IO ()
|
||||
main = print option
|
||||
( long "rule"
|
||||
<> short "r"
|
||||
<> metavar "RULE"
|
||||
<> help "The rulset used."
|
||||
)
|
||||
main = do
|
||||
config = Configuration 30 0 10 80 0
|
||||
printCells config $ run (rule config)
|
||||
-- print option
|
||||
-- ( long "rule"
|
||||
-- <> short "r"
|
||||
-- <> metavar "RULE"
|
||||
-- <> help "The rulset used."
|
||||
-- )
|
||||
|
||||
|
||||
data Configuration = Configuration {
|
||||
|
||||
+16
-16
@@ -111,19 +111,19 @@ instance Semigroup (Mod a) where
|
||||
-- (<>) a -> a -> a
|
||||
(<>) (Mod a) (Mod b) = Mod (a . b)
|
||||
|
||||
-- If need to compile, comment everything bellow.
|
||||
option :: Parser Int -> Mod Int -> Parser a
|
||||
option p (Mod m) = optionParser (m $ def p)
|
||||
where
|
||||
def = Option "VAR" "" ' ' Nothing "No help message set."
|
||||
|
||||
optionParser :: Option a -> Parser a
|
||||
optionParser _ []
|
||||
|
||||
|
||||
-- TODO Create a type OptionParser witch contains the short & long names & n args parsers.
|
||||
-- TODO Pattern match for the OptionParser or a default parser in the runParser. Option parser will check named args while the default one will do positional ones.
|
||||
-- EXAMPLE: https://www.paolocapriotti.com/blog/2012/04/27/applicative-option-parser/
|
||||
|
||||
runParser :: Parser a -> [String] -> Maybe (a, [String])
|
||||
runParser ::
|
||||
---- If need to compile, comment everything bellow.
|
||||
--option :: Parser Int -> Mod Int -> Parser a
|
||||
--option p (Mod m) = optionParser (m $ def p)
|
||||
-- where
|
||||
-- def = Option "VAR" "" ' ' Nothing "No help message set."
|
||||
--
|
||||
--optionParser :: Option a -> Parser a
|
||||
--optionParser _ []
|
||||
--
|
||||
--
|
||||
---- TODO Create a type OptionParser witch contains the short & long names & n args parsers.
|
||||
---- TODO Pattern match for the OptionParser or a default parser in the runParser. Option parser will check named args while the default one will do positional ones.
|
||||
---- EXAMPLE: https://www.paolocapriotti.com/blog/2012/04/27/applicative-option-parser/
|
||||
--
|
||||
--runParser :: Parser a -> [String] -> Maybe (a, [String])
|
||||
--runParser ::
|
||||
|
||||
Reference in New Issue
Block a user