named 0.2.0.0 → 0.3.0.0
raw patch · 7 files changed
+72/−20 lines, 7 files
Files
- ChangeLog.md +5/−0
- LICENSE +2/−1
- named.cabal +7/−6
- src/Named.hs +6/−8
- src/Named/Internal.hs +30/−0
- test/Test.hs +19/−5
- test/TestImport.hs +3/−0
ChangeLog.md view
@@ -1,3 +1,8 @@+## 0.3.0.0++* Added 'param', 'paramF'.+* Export 'NamedF(Arg, ArgF)' as a bundle.+ ## 0.2.0.0 * Removed 'Flag', 'named', 'Apply', 'apply'.
LICENSE view
@@ -1,4 +1,5 @@ Copyright (c) 2018, Vladislav Zavialov+ 2018, Monadfix All rights reserved. @@ -13,7 +14,7 @@ disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Vladislav Zavialov nor the names of other+ * Neither the name of Monadfix nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
named.cabal view
@@ -1,5 +1,5 @@ name: named-version: 0.2.0.0+version: 0.3.0.0 synopsis: Named parameters (keyword arguments) for Haskell description: `named` is a lightweight library for named function parameters (keyword@@ -31,20 +31,20 @@ license: BSD3 license-file: LICENSE author: Vladislav Zavialov-maintainer: Vladislav Zavialov <vlad.z.4096@gmail.com>+maintainer: Monadfix <hi@monadfix.io> category: Control build-type: Simple extra-source-files: ChangeLog.md-tested-with: GHC ==8.0.2, GHC ==8.2.2, GHC ==8.4.1+tested-with: GHC ==8.0.2, GHC ==8.2.2, GHC ==8.4.4, GHC ==8.6.4 cabal-version: >=1.10 source-repository head type: git- location: git@github.com:int-index/named.git+ location: git@github.com:monadfix/named.git library exposed-modules: Named, Named.Internal- build-depends: base >=4.9 && <4.12+ build-depends: base >=4.9 && <4.13 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall@@ -53,7 +53,8 @@ test-suite regression type: exitcode-stdio-1.0 main-is: Test.hs- build-depends: base >=4.9 && <4.12,+ other-modules: TestImport+ build-depends: base >=4.9 && <4.13, named hs-source-dirs: test default-language: Haskell2010
src/Named.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE PatternSynonyms, ExplicitNamespaces #-}+{-# LANGUAGE ExplicitNamespaces #-} {- | @@ -154,23 +154,21 @@ -} module Named (- -- * Calling functions+ -- * Call site (!), WithParam(..),+ param,+ paramF, defaults, - -- * Types+ -- * Definition site type (:!), type (:?),- NamedF,-- -- * Patterns+ NamedF(Arg, ArgF), Name(..), arg, argDef, argF,- pattern Arg,- pattern ArgF, ) where import Named.Internal
src/Named/Internal.hs view
@@ -67,6 +67,36 @@ #endif {-# INLINE fromLabel #-} +{- | Explicitly build a function parameter:++@+fn '!' 'param' \#param_name value+@++This is equivalent to the implicit notation:++@+fn '!' \#param_name value+@++-}+param :: Name name -> a -> Param (name :! a)+param _ a = Param (Arg a)++{- | Explicitly build a function parameter inside an arity wrapper:++@+fn '!' 'paramF' \#param_name ('Identity' value)+fn '!' 'paramF' \#param_name ('Just' value)+fn '!' 'paramF' \#param_name 'Nothing'+@++This has no equivalent implicit notation.++-}+paramF :: Name name -> f a -> Param (NamedF f a name)+paramF _ fa = Param (ArgF fa)+ {- | Supply a parameter to a function: @
test/Test.hs view
@@ -60,11 +60,11 @@ -- test3' :: _ => "a" :! _ -> _ :! "b" -> _ -- test3' (arg #b -> a) (arg #a -> b) = a + b --- test4 ::--- "b" :! Bool ->--- NamedF _ Char "x" ->--- "y" :? Char ->--- Char+test4 ::+ "b" :! Bool ->+ NamedF _ Char "x" ->+ "y" :? Char ->+ Char test4 (arg #b -> b) (argDef #x 'x' -> x)@@ -75,7 +75,19 @@ test4_2 = test4 ! #b False ! defaults test4_3 = test4 ! #x 'z' ! #b True ! defaults test4_4 = test4 ! defaults ! #b True+test4_5 = test4 ! paramF #x (Just 'q') ! #b True ! defaults+test4_6 = test4 ! paramF #x Nothing ! #b True ! #y '-' +test5_1 :: ("bar" :! Int -> ()) -> ()+test5_1 f = f ! #bar 3++test5_2 :: ("bar" :! Int -> ()) -> "bar" :! Int -> ()+test5_2 f x = f x++test6 :: Maybe ("x" :! Int -> Int) -> Int+test6 Nothing = 0+test6 (Just f) = f ! #x 42+ main :: IO () main = do test1_1@@ -89,6 +101,8 @@ test4_2 `mustBe` 'y' test4_3 `mustBe` 'z' test4_4 `mustBe` 'x'+ test4_5 `mustBe` 'q'+ test4_6 `mustBe` 'x' mustBe :: (Eq a, Show a) => a -> a -> IO () mustBe a b
+ test/TestImport.hs view
@@ -0,0 +1,3 @@+module TestImport (module Named) where++import Named (NamedF(Arg, ArgF))