packages feed

purescript-bridge 0.9.0.0 → 0.10.0.0

raw patch · 6 files changed

+31/−19 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Language.PureScript.Bridge.PSTypes: psNumber :: PSType
+ Language.PureScript.Bridge.Primitives: doubleBridge :: BridgePart
- Language.PureScript.Bridge.SumType: recLabel :: forall lang_ad5l. Lens' (RecordEntry lang_ad5l) Text
+ Language.PureScript.Bridge.SumType: recLabel :: forall lang_ad5n. Lens' (RecordEntry lang_ad5n) Text
- Language.PureScript.Bridge.SumType: recValue :: forall lang_ad5l lang_aeYj. Lens (RecordEntry lang_ad5l) (RecordEntry lang_aeYj) (TypeInfo lang_ad5l) (TypeInfo lang_aeYj)
+ Language.PureScript.Bridge.SumType: recValue :: forall lang_ad5n lang_aeYl. Lens (RecordEntry lang_ad5n) (RecordEntry lang_aeYl) (TypeInfo lang_ad5n) (TypeInfo lang_aeYl)
- Language.PureScript.Bridge.SumType: sigConstructor :: forall lang_ad5m. Lens' (DataConstructor lang_ad5m) Text
+ Language.PureScript.Bridge.SumType: sigConstructor :: forall lang_ad5o. Lens' (DataConstructor lang_ad5o) Text
- Language.PureScript.Bridge.SumType: sigValues :: forall lang_ad5m lang_aeXf. Lens (DataConstructor lang_ad5m) (DataConstructor lang_aeXf) (Either [TypeInfo lang_ad5m] [RecordEntry lang_ad5m]) (Either [TypeInfo lang_aeXf] [RecordEntry lang_aeXf])
+ Language.PureScript.Bridge.SumType: sigValues :: forall lang_ad5o lang_aeXh. Lens (DataConstructor lang_ad5o) (DataConstructor lang_aeXh) (Either [TypeInfo lang_ad5o] [RecordEntry lang_ad5o]) (Either [TypeInfo lang_aeXh] [RecordEntry lang_aeXh])
- Language.PureScript.Bridge.TypeInfo: typeModule :: forall lang_a7Oo. Lens' (TypeInfo lang_a7Oo) Text
+ Language.PureScript.Bridge.TypeInfo: typeModule :: forall lang_a7Oq. Lens' (TypeInfo lang_a7Oq) Text
- Language.PureScript.Bridge.TypeInfo: typeName :: forall lang_a7Oo. Lens' (TypeInfo lang_a7Oo) Text
+ Language.PureScript.Bridge.TypeInfo: typeName :: forall lang_a7Oq. Lens' (TypeInfo lang_a7Oq) Text
- Language.PureScript.Bridge.TypeInfo: typePackage :: forall lang_a7Oo. Lens' (TypeInfo lang_a7Oo) Text
+ Language.PureScript.Bridge.TypeInfo: typePackage :: forall lang_a7Oq. Lens' (TypeInfo lang_a7Oq) Text
- Language.PureScript.Bridge.TypeInfo: typeParameters :: forall lang_a7Oo lang_abpm. Lens (TypeInfo lang_a7Oo) (TypeInfo lang_abpm) [TypeInfo lang_a7Oo] [TypeInfo lang_abpm]
+ Language.PureScript.Bridge.TypeInfo: typeParameters :: forall lang_a7Oq lang_abpo. Lens (TypeInfo lang_a7Oq) (TypeInfo lang_abpo) [TypeInfo lang_a7Oq] [TypeInfo lang_abpo]

Files

purescript-bridge.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.9.0.0+version:             0.10.0.0  -- A short (one-line) description of the package. synopsis:            Generate PureScript data types from Haskell data types
src/Language/PureScript/Bridge.hs view
@@ -103,6 +103,7 @@     <|> eitherBridge     <|> boolBridge     <|> intBridge+    <|> doubleBridge     <|> tupleBridge     <|> unitBridge 
src/Language/PureScript/Bridge/PSTypes.hs view
@@ -40,6 +40,14 @@   , _typeParameters = []   } +psNumber :: PSType+psNumber = TypeInfo {+    _typePackage = "purescript-prim"+  , _typeModule = "Prim"+  , _typeName = "Number"+  , _typeParameters = []+  }+ -- | Uses  type parameters from 'haskType' (bridged). psMaybe :: MonadReader BridgeData m => m PSType psMaybe = TypeInfo "purescript-maybe" "Data.Maybe" "Maybe" <$> psTypeParameters
src/Language/PureScript/Bridge/Primitives.hs view
@@ -26,6 +26,9 @@ intBridge :: BridgePart intBridge = typeName ^== "Int" >> return psInt +doubleBridge :: BridgePart+doubleBridge = typeName ^== "Double" >> return psNumber+ listBridge :: BridgePart listBridge = typeName ^== "[]" >> psArray 
src/Language/PureScript/Bridge/Printer.hs view
@@ -73,7 +73,7 @@ _lensImports = [     ImportLine "Data.Maybe" $ Set.fromList ["Maybe(..)"]   -- , ImportLine "Prelude" mempty-  , ImportLine "Data.Lens" $ Set.fromList ["PrismP", "LensP", "prism'", "lens"]+  , ImportLine "Data.Lens" $ Set.fromList ["Prism'", "Lens'", "prism'", "lens"]   ]  importLineToText :: ImportLine -> Text@@ -163,7 +163,7 @@ constructorToPrism :: Bool -> SumType 'PureScript -> DataConstructor 'PureScript -> Text constructorToPrism otherConstructors st (DataConstructor n args) =   case args of-    Left cs  -> pName <> forAll <>  "PrismP " <> typName <> " " <> mkTypeSig types <> "\n"+    Left cs  -> pName <> forAll <>  "Prism' " <> typName <> " " <> mkTypeSig types <> "\n"              <> pName <> " = prism' " <> getter <> " f\n"              <> spaces 2 <> "where\n"              <> spaces 4 <> "f " <> mkF cs@@ -177,7 +177,7 @@           where             cArgs = map (T.singleton . fst) $ zip ['a'..] cs         types = [RecordEntry (T.singleton label) t | (label, t) <- zip ['a'..] cs]-    Right rs -> pName <> forAll <> "PrismP " <> typName <> " { " <> recordSig <> "}\n"+    Right rs -> pName <> forAll <> "Prism' " <> typName <> " { " <> recordSig <> "}\n"              <> pName <> " = prism' " <> n <> " f\n"              <> spaces 2 <> "where\n"              <> spaces 4 <> "f (" <> n <> " r) = Just r\n"@@ -195,7 +195,7 @@   case hasUnderscore of     False -> ""     True ->-         lensName <> forAll <>  "LensP " <> typName <> " " <> recType <> "\n"+         lensName <> forAll <>  "Lens' " <> typName <> " " <> recType <> "\n"       <> lensName <> " = lens get set\n  where\n"       <> spaces 4 <> "get (" <> constructorName <> " r) = r." <> recName <> "\n"       <> spaces 4 <> "set (" <> constructorName <> " r) = " <> setter
test/Spec.hs view
@@ -62,7 +62,7 @@                           , "module TestData where"                           , ""                           , "import Data.Either (Either)"-                          , "import Data.Lens (LensP, PrismP, lens, prism')"+                          , "import Data.Lens (Lens', Prism', lens, prism')"                           , "import Data.Maybe (Maybe, Maybe(..))"                           , ""                           , "import Prelude"@@ -79,25 +79,25 @@                           , "derive instance genericBar :: (Generic a, Generic b, Generic (m b)) => Generic (Bar a b m c)"                           , ""                           , "--------------------------------------------------------------------------------"-                          , "_Bar1 :: forall a b m c. PrismP (Bar a b m c) (Maybe a)"+                          , "_Bar1 :: forall a b m c. Prism' (Bar a b m c) (Maybe a)"                           , "_Bar1 = prism' Bar1 f"                           , "  where"                           , "    f (Bar1 a) = Just $ a"                           , "    f _ = Nothing"                           , ""-                          , "_Bar2 :: forall a b m c. PrismP (Bar a b m c) (Either a b)"+                          , "_Bar2 :: forall a b m c. Prism' (Bar a b m c) (Either a b)"                           , "_Bar2 = prism' Bar2 f"                           , "  where"                           , "    f (Bar2 a) = Just $ a"                           , "    f _ = Nothing"                           , ""-                          , "_Bar3 :: forall a b m c. PrismP (Bar a b m c) a"+                          , "_Bar3 :: forall a b m c. Prism' (Bar a b m c) a"                           , "_Bar3 = prism' Bar3 f"                           , "  where"                           , "    f (Bar3 a) = Just $ a"                           , "    f _ = Nothing"                           , ""-                          , "_Bar4 :: forall a b m c. PrismP (Bar a b m c) { myMonadicResult :: m b}"+                          , "_Bar4 :: forall a b m c. Prism' (Bar a b m c) { myMonadicResult :: m b}"                           , "_Bar4 = prism' Bar4 f"                           , "  where"                           , "    f (Bar4 r) = Just r"@@ -112,43 +112,43 @@           barPrisms = sumTypeToPrisms bar           fooPrisms = sumTypeToPrisms foo           txt = T.unlines [-                            "_Bar1 :: forall a b m c. PrismP (Bar a b m c) (Maybe a)"+                            "_Bar1 :: forall a b m c. Prism' (Bar a b m c) (Maybe a)"                           , "_Bar1 = prism' Bar1 f"                           , "  where"                           , "    f (Bar1 a) = Just $ a"                           , "    f _ = Nothing"                           , ""-                          , "_Bar2 :: forall a b m c. PrismP (Bar a b m c) (Either a b)"+                          , "_Bar2 :: forall a b m c. Prism' (Bar a b m c) (Either a b)"                           , "_Bar2 = prism' Bar2 f"                           , "  where"                           , "    f (Bar2 a) = Just $ a"                           , "    f _ = Nothing"                           , ""-                          , "_Bar3 :: forall a b m c. PrismP (Bar a b m c) a"+                          , "_Bar3 :: forall a b m c. Prism' (Bar a b m c) a"                           , "_Bar3 = prism' Bar3 f"                           , "  where"                           , "    f (Bar3 a) = Just $ a"                           , "    f _ = Nothing"                           , ""-                          , "_Bar4 :: forall a b m c. PrismP (Bar a b m c) { myMonadicResult :: m b}"+                          , "_Bar4 :: forall a b m c. Prism' (Bar a b m c) { myMonadicResult :: m b}"                           , "_Bar4 = prism' Bar4 f"                           , "  where"                           , "    f (Bar4 r) = Just r"                           , "    f _ = Nothing"                           , ""-                          , "_Foo :: PrismP Foo Unit"+                          , "_Foo :: Prism' Foo Unit"                           , "_Foo = prism' (\\_ -> Foo) f"                           , "  where"                           , "    f Foo = Just unit"                           , "    f _ = Nothing"                           , ""-                          , "_Bar :: PrismP Foo Int"+                          , "_Bar :: Prism' Foo Int"                           , "_Bar = prism' Bar f"                           , "  where"                           , "    f (Bar a) = Just $ a"                           , "    f _ = Nothing"                           , ""-                          , "_FooBar :: PrismP Foo { a :: Int, b :: String }"+                          , "_FooBar :: Prism' Foo { a :: Int, b :: String }"                           , "_FooBar = prism' (\\{ a, b } -> FooBar a b) f"                           , "  where"                           , "    f (FooBar a b) = Just $ { a: a, b: b }"@@ -162,13 +162,13 @@           barLenses = sumTypeToLenses bar           recTypeLenses = sumTypeToLenses recType           txt = T.unlines [-                            "a :: forall a b. LensP (SingleRecord a b) a"+                            "a :: forall a b. Lens' (SingleRecord a b) a"                           , "a = lens get set"                           , "  where"                           , "    get (SingleRecord r) = r._a"                           , "    set (SingleRecord r) = SingleRecord <<< r { _a = _ }"                           , ""-                          , "b :: forall a b. LensP (SingleRecord a b) b"+                          , "b :: forall a b. Lens' (SingleRecord a b) b"                           , "b = lens get set"                           , "  where"                           , "    get (SingleRecord r) = r._b"