File: Options.hs

package info (click to toggle)
darcs 2.12.4-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,748 kB
  • sloc: haskell: 42,936; sh: 11,086; ansic: 837; perl: 129; makefile: 8
file content (31 lines) | stat: -rw-r--r-- 913 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Darcs.UI.Options
    ( module Darcs.UI.Options.Core
    , module Darcs.UI.Options.Markdown
    , DarcsOption
    , PrimDarcsOption
    , DarcsOptDescr
    , optDescr
    ) where

import Prelude ()
import Darcs.Prelude

import Data.Functor.Compose
import System.Console.GetOpt

import Darcs.UI.Options.All
import Darcs.UI.Options.Core
import Darcs.UI.Options.Markdown
import Darcs.UI.Options.Util ( DarcsOptDescr, PrimDarcsOption )
import Darcs.Util.Path ( AbsolutePath )

-- * Type instantiations

-- | The @instance Functor OptDescr@ was introduced only in base-4.7.0.0, which is
-- why we implement it here manually.
optDescr :: AbsolutePath -> DarcsOptDescr f -> OptDescr f
optDescr path = omap ($path) . getCompose where
  omap f (Option s l a h) = Option s l (amap f a) h
  amap f (NoArg a) = NoArg (f a)
  amap f (ReqArg mkF n) = ReqArg (fmap f mkF) n
  amap f (OptArg mkF n) = OptArg (fmap f mkF) n