colorless 0.1.0 → 1.0.0
raw patch · 5 files changed
+9/−13 lines, 5 files
Files
- README.md +1/−1
- colorless.cabal +1/−1
- library/Colorless/Runtime/Val.hs +4/−8
- package.yaml +1/−1
- tests/ValSpec.hs +2/−2
README.md view
@@ -1,4 +1,4 @@ # colorless-haskell This is the Haskell colorless library which includes the server-side runtime.-It's meant to be used in conjunction with the command line [code generator](github.com/jxv/colorless).+It's meant to be used in conjunction with the command line [code generator](https://github.com/jxv/colorless).
colorless.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: colorless-version: 0.1.0+version: 1.0.0 synopsis: Colorless description: Colorless category: Web
library/Colorless/Runtime/Val.hs view
@@ -160,9 +160,8 @@ toVal d = Val'Const $ Const'Number $ fromFloatDigits d instance ToVal a => ToVal (Maybe a) where- toVal m = Val'ApiVal $ ApiVal'Enumeral $ case m of- Nothing -> Enumeral "None" Nothing- Just s -> Enumeral "Some" (Just $ Map.singleton "some" (toVal s))+ toVal Nothing = Val'Const Const'Null+ toVal (Just v) = toVal v instance (ToVal a, ToVal b) => ToVal (Either a b) where toVal m = Val'ApiVal $ ApiVal'Enumeral $ case m of@@ -256,11 +255,8 @@ fromVal _ = Nothing instance FromVal a => FromVal (Maybe a) where- fromVal (Val'ApiVal (ApiVal'Enumeral (Enumeral tag m))) = case (tag,m) of- ("Some",Just m') -> fromVal <$> Map.lookup "some" m'- ("None",Nothing) -> Just Nothing- _ -> Nothing- fromVal _ = Nothing+ fromVal (Val'Const Const'Null) = Just Nothing+ fromVal v = Just <$> fromVal v instance (FromVal a, FromVal b) => FromVal (Either a b) where fromVal (Val'ApiVal (ApiVal'Enumeral (Enumeral tag m))) = case (tag,m) of
package.yaml view
@@ -1,5 +1,5 @@ name: colorless-version: '0.1.0'+version: '1.0.0' category: Web synopsis: Colorless description: Colorless
tests/ValSpec.hs view
@@ -24,8 +24,8 @@ describe "parse types from val" $ do context "Option" $ do it "None" $ shouldBe- (fromVal $ Val'ApiVal $ ApiVal'Enumeral $ Enumeral "None" Nothing)+ (fromVal $ Val'Const Const'Null) (Just Nothing :: Maybe (Maybe Bool)) it "Some" $ shouldBe- (fromVal $ Val'ApiVal $ ApiVal'Enumeral $ Enumeral "Some" $ Just $ Map.fromList [("some", Val'Const $ Const'Bool $ True)])+ (fromVal $ Val'Const $ Const'Bool $ True) (Just (Just True) :: Maybe (Maybe Bool))