elm-bridge 0.8.3 → 0.8.4
raw patch · 3 files changed
+11/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- elm-bridge.cabal +1/−1
- src/Elm/Derive.hs +4/−4
- src/Elm/TyRep.hs +6/−3
elm-bridge.cabal view
@@ -1,5 +1,5 @@ name: elm-bridge-version: 0.8.3+version: 0.8.4 synopsis: Derive Elm types and Json code from Haskell types, using aeson's options description: Building the bridge from Haskell to Elm and back. Define types once, and derive the aeson and elm functions at the same time, using any aeson
src/Elm/Derive.hs view
@@ -94,7 +94,7 @@ TaggedObject tn cn -> [|SumEncoding' (TaggedObject tn cn)|] UntaggedValue -> [|SumEncoding' UntaggedValue|] -runDerive :: Name -> [TyVarBndr ()] -> (Q Exp -> Q Exp) -> Q [Dec]+runDerive :: Name -> [TyVarBndr a] -> (Q Exp -> Q Exp) -> Q [Dec] runDerive name vars mkBody = liftM (:[]) elmDefInst where@@ -125,7 +125,7 @@ PlainTV tv _ -> tv KindedTV tv _ _ -> tv -deriveAlias :: Bool -> A.Options -> Name -> [TyVarBndr ()] -> [VarStrictType] -> Q [Dec]+deriveAlias :: Bool -> A.Options -> Name -> [TyVarBndr a] -> [VarStrictType] -> Q [Dec] deriveAlias isNewtype opts name vars conFields = runDerive name vars $ \typeName -> [|ETypeAlias (EAlias $typeName $fields omitNothing isNewtype unwrapUnary)|] -- default to no newtype@@ -140,7 +140,7 @@ fldName = A.fieldLabelModifier opts $ nameBase fname fldType = compileType ftype -deriveSum :: A.Options -> Name -> [TyVarBndr ()] -> [Con] -> Q [Dec]+deriveSum :: A.Options -> Name -> [TyVarBndr a] -> [Con] -> Q [Dec] deriveSum opts name vars constrs = runDerive name vars $ \typeName -> [|ETypeSum (ESum $typeName $sumOpts $sumEncOpts omitNothing allNullary)|]@@ -164,7 +164,7 @@ in [|STC b n (Named $tyArgs)|] _ -> fail ("Can't derive this sum: " ++ show c) -deriveSynonym :: A.Options -> Name -> [TyVarBndr ()] -> Type -> Q [Dec]+deriveSynonym :: A.Options -> Name -> [TyVarBndr a] -> Type -> Q [Dec] deriveSynonym _ name vars otherT = runDerive name vars $ \typeName -> [|ETypePrimAlias (EPrimAlias $typeName $otherType)|]
src/Elm/TyRep.hs view
@@ -3,6 +3,7 @@ -} module Elm.TyRep where +import qualified Data.Char as Char import Data.List import Data.Proxy import Data.Typeable (TyCon, TypeRep, Typeable, splitTyConApp,@@ -84,8 +85,8 @@ isEmpty :: SumTypeFields -> Bool isEmpty (Anonymous []) = True-isEmpty (Named []) = True-isEmpty _ = False+isEmpty (Named []) = True+isEmpty _ = False data SumTypeConstructor = STC@@ -186,7 +187,9 @@ (con, args) = splitTyConApp rep isTuple :: String -> Bool- isTuple ('(':xs) = isTuple' $ reverse xs+ isTuple "Unit" = True+ isTuple ('T': 'u' : 'p': 'l' : 'e' : ds) = all Char.isDigit ds+ isTuple ('(':xs) = isTuple' $ reverse xs -- base <= 4.17 where isTuple' :: String -> Bool isTuple' (')':xs') = all (== ',') xs'