sessiontypes 0.1.1 → 0.1.2
raw patch · 3 files changed
+20/−17 lines, 3 filesdep ~exceptions
Dependency ranges changed: exceptions
Files
- ChangeLog +4/−0
- sessiontypes.cabal +1/−1
- src/Control/SessionTypes/Visualize.hs +15/−16
ChangeLog view
@@ -1,3 +1,7 @@+2018-01-13 Ferdinand van Walree 0.1.2+* Fixed compiler warning+* Upgraded to LTS-10.3+ 2017-10-11 Ferdinand van Walree 0.1.1 * Fixed Functor definition for STTerm
sessiontypes.cabal view
@@ -1,5 +1,5 @@ name: sessiontypes-version: 0.1.1+version: 0.1.2 synopsis: Session types library description: This packages provides a deep embedded domain-specific language for writing session typed program. A session typed program is a program annotated with session types. A session type describes a communication protocol at the type-level.
src/Control/SessionTypes/Visualize.hs view
@@ -7,6 +7,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE PolyKinds #-}+{-# LANGUAGE ConstraintKinds #-} -- | This module defines an interpreter for visualizing session types. -- -- Using `visualize` or `visualizeP` you can create a diagram that displays a session type using a set of nodes and arrows that connect these nodes.@@ -41,7 +42,7 @@ visualize _ = mainWith $ mkDiagram (Proxy :: Proxy s) -- | Visualizes a given session type denoted by a Proxy.-visualizeP :: forall s. MkDiagram s => Proxy s -> IO ()+visualizeP :: MkDiagram s => Proxy s -> IO () visualizeP p = mainWith $ mkDiagram p @@ -302,22 +303,20 @@ -} --- | Type class for constructing a diagram that visualizes the session types-class MkDiagram (s :: ST k) where- mkDiagram :: Proxy s -> IO (Diagram B)-- default mkDiagram :: (Coordinates s, PlaceNodes s) => Proxy s -> IO (Diagram B)- mkDiagram p = do- -- place nodes in the grid- dstate <- dstateWNodesIO- -- connect the grid and build a Diagram- (diag, DState n _ _ d g) <- runStateT connectGrid dstate- -- Place arrows going from a `V` to a `R`- fmap fst $ runStateT connectRecursions (DState n 0 (0,0) diag g)- where- dstateWNodesIO = fmap snd $ runStateT (placeNodes p) (newDState $ newGrid (getX p) (getY p))+-- | Necessary type constraints for making a diagram +type MkDiagram s = (Coordinates s, PlaceNodes s) -instance (Coordinates s, PlaceNodes s) => MkDiagram s+-- | Makes a diagram for a given session type+mkDiagram :: MkDiagram s => Proxy s -> IO (Diagram B)+mkDiagram p = do+ -- place nodes in the grid+ dstate <- dstateWNodesIO+ -- connect the grid and build a Diagram+ (diag, DState n _ _ d g) <- runStateT connectGrid dstate+ -- Place arrows going from a `V` to a `R`+ fmap fst $ runStateT connectRecursions (DState n 0 (0,0) diag g)+ where+ dstateWNodesIO = fmap snd $ runStateT (placeNodes p) (newDState $ newGrid (getX p) (getY p)) -- | Determines size of grid based on the session types class Coordinates (s :: ST k) where