packages feed

hflags 0.3 → 0.4

raw patch · 6 files changed

+53/−19 lines, 6 files

Files

HFlags.hs view
@@ -84,6 +84,7 @@   undefinedOptions,   -- * For debugging, shouldn't be used in production code   Flag(..),+  MakeThisOrphan(..),   globalHFlags,   globalArguments,   globalUndefinedOptions@@ -105,7 +106,7 @@ -- evaluated if they are needed.  (The user hasn't specified the -- option in the command line or via environment variables.) import qualified Data.Map.Lazy as Map-import Data.Map.Lazy (Map, (!))+import Data.Map.Lazy (Map) import qualified Data.Text import Language.Haskell.TH import System.Console.GetOpt@@ -116,6 +117,14 @@  import Prelude +-- | This is a temporary hack to force visibility of flags inside+-- libraries, by making the module that defines the flag orphan.  For+-- usage example, check out+-- <http://github.com/errge/hflags/blob/master/examples/package/Tup.hs>.+-- A proper fix is already proposed for GHC 7.8, see+-- <http://ghc.haskell.org/trac/ghc/ticket/7867>.+data MakeThisOrphan = MakeThisOrphan+ -- | Data type for storing every property of a flag. data FlagData = FlagData             { fName :: String@@ -189,7 +198,8 @@                                               argHelp                                               description                                               moduleName-                                              (evaluate $(varE accessorName) >> return ())+                                              -- seq'ng the constructor name, so it's not unused in the generated code+                                              ($(conE dataConstrName) `seq` evaluate $(varE accessorName) >> return ())                                            |]) []]]      flagPragmaDec <- pragInlD accessorName NoInline FunLike AllPhases      flagSig <- sigD accessorName flagType@@ -319,7 +329,9 @@ lookupFlag fName fModuleName = unsafePerformIO $ do   flags <- readIORef globalHFlags   case flags of-    Just flagmap -> return $ flagmap ! fName+    Just flagmap -> case Map.lookup fName flagmap of+      Just v -> return v+      Nothing -> error $ "Flag " ++ fName ++ " not found at runtime, look into HFlags-source/examples/package/Tup.hs.  Sorry."     Nothing -> error $ "Flag " ++ fName ++ " (from module: " ++ fModuleName ++ ") used before calling initHFlags."  -- | Lisp like alist, key -> value pairs.
+ changelog view
@@ -0,0 +1,20 @@+-*-change-log-*-++0.5 (current development version)++0.4 Gergely Risko <gergely@risko.hu> 2013-10-03+        * Add changelog file+        * Add documentation, test and temporary fix for orphanness issue+        * Fix HFlagC unused warnings in generated code++0.3 Gergely Risko <gergely@risko.hu>+        * Add undefindeOptions+        * Add Char support as flag value++0.2 Gergely Risko <gergely@risko.hu>+        * API change: the caller mustn't use parantheses around @initHFlags@+        * New feature: dependent defaults, ability to compute some flags'+          default values based on the current values of other flags++0.1 Gergely Risko <gergely@risko.hu>+        * Initial release
examples/package/Tup.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE TemplateHaskell #-}+-- remove when hflags 0.5 is released with ghc 7.8+{-# OPTIONS_GHC -fno-warn-orphans #-}  module Tup (get) where @@ -6,7 +8,15 @@  defineFlag "which" (1 :: Int) "which" +-- This is unfortunately neccessary for make flags visible through+-- compilation boundaries (e.g. from packages).  The correct solution+-- is already being worked on inside GHC:+-- http://ghc.haskell.org/trac/ghc/ticket/7867++-- remove when hflags 0.5 is released with GHC 7.8+{-# RULES "make_this_orphan" id = id :: MakeThisOrphan -> MakeThisOrphan #-}+ get :: (a, a) -> a get x = case flags_which of   1 -> fst x-  2 -> snd x+  _ -> snd x
examples/package/test/main.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE TemplateHaskell #-}  import HFlags-import Tup+import TupMain  main = do   $initHFlags "foobar"
examples/package/tup.cabal view
@@ -15,5 +15,7 @@     , template-haskell >= 2.8     , hflags >= 0.1 +  ghc-options: -Wall   exposed-modules:-    Tup+    Tup,+    TupMain
hflags.cabal view
@@ -1,5 +1,5 @@ name: hflags-version: 0.3+version: 0.4 license: OtherLicense license-file: COPYING author: Mihaly Barasz <klao@google.com>, Gergely Risko <gergely@risko.hu>@@ -58,18 +58,7 @@   .   /Since version 0.2, you mustn't put the initHFlags in a parentheses with the program description.  Just/ @$initHFlags@, /it's cleaner./   .-  Changes in version 0.3-  .-  * Added @undefinedOptions@-  .-  * Added support for @Char@-  .-  Changes in version 0.2-  .-  * API change: the caller mustn't use parantheses around @initHFlags@-  .-  * New feature: dependent defaults, ability to compute some flags'-    default values based on the current values of other flags+  See <http://github.com/errge/hflags/tree/master/changelog> for recent changes.  extra-source-files:   examples/ComplexExample.hs@@ -82,6 +71,7 @@   examples/package/tup.cabal   BLOG.md   README.md+  changelog  source-repository head   type: git