packages feed

distributed-static 0.3.5.0 → 0.3.6

raw patch · 3 files changed

+13/−43 lines, 3 filesdep ~rank1dynamicPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: rank1dynamic

API changes (from Hackage documentation)

- Control.Distributed.Static: instance Data.Typeable.Internal.Typeable a => Data.Binary.Class.Binary (Control.Distributed.Static.Closure a)
- Control.Distributed.Static: instance Data.Typeable.Internal.Typeable a => Data.Binary.Class.Binary (Control.Distributed.Static.Static a)
+ Control.Distributed.Static: instance Data.Binary.Class.Binary (Control.Distributed.Static.Closure a)
+ Control.Distributed.Static: instance Data.Binary.Class.Binary (Control.Distributed.Static.Static a)

Files

ChangeLog view
@@ -1,3 +1,8 @@+2017-08-22  Facundo Domínguez  <facundo.dominguez@tweag.io>  0.3.6++* Move upper bound of rank1dynamic to support ghc-8.2.1.+* Remove dynamic type check in Static Binary instance.+ 2016-06-01  Facundo Domínguez  <facundo.dominguez@tweag.io>  0.3.5.0  * Add compatibility with ghc-8.
distributed-static.cabal view
@@ -1,5 +1,5 @@ Name:                distributed-static-Version:             0.3.5.0+Version:             0.3.6 Synopsis:            Compositional, type-safe, polymorphic static values and closures Description:         /Towards Haskell in the Cloud/ (Epstein et al, Haskell                      Symposium 2011) introduces the concept of /static/ values:@@ -33,7 +33,7 @@ Library   Exposed-Modules:     Control.Distributed.Static   Build-Depends:       base >= 4 && < 5,-                       rank1dynamic >= 0.1 && < 0.4,+                       rank1dynamic >= 0.1 && < 0.5,                        containers >= 0.4 && < 0.6,                        bytestring >= 0.9 && < 0.11,                        binary >= 0.5 && < 0.9,
src/Control/Distributed/Static.hs view
@@ -8,35 +8,6 @@ -- all distributed nodes are using the same 'RemoteTable'). In this module -- we implement this mimickry and various extensions. ----- [Dynamic type checking]------ The paper stipulates that 'Static' values should have a free 'Binary'--- instance:------ > instance Binary (Static a)------ This however is not (runtime) type safe: for instance, what would be the--- behaviour of------ > f :: Static Int -> Static Bool--- > f = decode . encode------ For this reason we work only with 'Typeable' terms in this module, and--- implement runtime checks------ > instance Typeable a => Binary (Static a)------ The above function 'f' typechecks but throws an exception if executed. The--- type representation we use, however, is not the standard--- 'Data.Typeable.TypeRep' from "Data.Typeable" but--- 'Data.Rank1Typeable.TypeRep' from "Data.Rank1Typeable". This means that we--- can represent polymorphic static values (see below for an example).------ Since the runtime mapping ('RemoteTable') contains values of different types,--- it maps labels ('String's) to 'Data.Rank1Dynamic.Dynamic' values. Again, we--- use the implementation from "Data.Rank1Dynamic" so that we can store--- polymorphic dynamic values.--- -- [Compositionality] -- -- Static values as described in the paper are not compositional: there is no@@ -252,14 +223,13 @@ import Data.Rank1Dynamic (Dynamic, toDynamic, fromDynamic, dynApply) import Data.Rank1Typeable   ( Typeable-  , typeOf   , ANY1   , ANY2   , ANY3   , ANY4-  , isInstanceOf #if __GLASGOW_HASKELL__ >= 710   , TypeRep+  , typeOf #endif   ) @@ -322,14 +292,9 @@ instance NFData (Static a) where   rnf (Static s) = rnf s -instance Typeable a => Binary (Static a) where-  put (Static label) = putStaticLabel label >> put (typeOf (undefined :: a))-  get = do-    label   <- getStaticLabel-    typeRep <- get-    case typeOf (undefined :: a) `isInstanceOf` typeRep of-      Left err -> fail $ "Static.get: type error: " ++ err-      Right () -> return (Static label)+instance Binary (Static a) where+  put (Static label) = putStaticLabel label+  get = Static <$> getStaticLabel  -- We don't want StaticLabel to be its own Binary instance putStaticLabel :: StaticLabel -> Put@@ -446,8 +411,8 @@ data Closure a = Closure !(Static (ByteString -> a)) !ByteString   deriving (Eq, Ord, Typeable, Show) -instance Typeable a => Binary (Closure a) where-  put (Closure dec env) = put dec >> put env+instance Binary (Closure a) where+  put (Closure st env) = put st >> put env   get = Closure <$> get <*> get  #if MIN_VERSION_bytestring(0,10,0)