mirror of
https://github.com/zoriya/applicative-getopt.git
synced 2026-05-27 16:42:06 +00:00
Trying to start the applicative implementation of OptParser
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
module GetOpt.Options where
|
||||
|
||||
import GetOpt.Data(Option(..), OptionParser)
|
||||
import GetOpt.Parsers
|
||||
import GetOpt.Data( Option(..), OptionParser )
|
||||
import GetOpt.Parsers ( Parser(..) )
|
||||
|
||||
meta :: String -> Mod a
|
||||
meta v = Mod $ \x -> x { metavar = v }
|
||||
|
||||
@@ -12,3 +12,11 @@ instance Functor Parser where
|
||||
fmap f (DefParser a) = DefParser $ f a
|
||||
fmap f (OptParser opt next) = OptParser (fmap (f .) opt) next
|
||||
|
||||
instance Applicative Parser where
|
||||
-- pure a -> f a
|
||||
pure a = DefParser a
|
||||
|
||||
-- (<*>) f (a -> b) -> f a -> f b
|
||||
(<*>) (DefParser f) p = fmap f p
|
||||
-- (<*>) (OptParser (Option (a -> b -> c)) Parser (a -> b)) -> Parser a -> Parser c
|
||||
(<*>) (OptParser f next) p = OptParser () next
|
||||
@@ -17,19 +17,19 @@ getParser = Configuration
|
||||
<> meta "RULE"
|
||||
<> help "The rulset used."
|
||||
)
|
||||
-- <*> option (
|
||||
-- long "start"
|
||||
-- <> short 's'
|
||||
-- <> meta "START"
|
||||
-- <> help "At witch line should we start"
|
||||
-- <> value 0
|
||||
-- )
|
||||
<*> option auto (
|
||||
long "start"
|
||||
<> short 's'
|
||||
<> meta "START"
|
||||
<> help "At witch line should we start"
|
||||
<> value 0
|
||||
)
|
||||
|
||||
|
||||
|
||||
data Configuration = Configuration {
|
||||
rule :: Int
|
||||
-- start :: Int,
|
||||
rule :: Int,
|
||||
start :: Int
|
||||
-- lines :: Maybe Int,
|
||||
-- window :: Int,
|
||||
-- move :: Int
|
||||
|
||||
Reference in New Issue
Block a user