bff-mono 0.2.1 → 0.2.2
raw patch · 5 files changed
+29/−13 lines, 5 files
Files
- Data/BffMono/Base.hs +25/−9
- Data/BffMono/CheckHistory.hs +1/−2
- Data/BffMono/EquivMap.hs +1/−0
- Data/BffMono/EquivWitness.hs +1/−1
- bff-mono.cabal +1/−1
Data/BffMono/Base.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, - FunctionalDependencies, Rank2Types,+ FunctionalDependencies, RankNTypes, ImpredicativeTypes, FlexibleContexts, PatternGuards #-}@@ -28,9 +28,18 @@ ---------------------------------------------------------------- -- | @Pack conc abs@ provides a way to abstract @conc@ by @abs@. +-- The class is used just as an interface. Thus, no instances +-- are provided by this package. class Pack conc abs | abs -> conc where new :: conc -> abs +-- | @PackM@ is the interface for our bidirectionalization. +-- See also 'fwd' and 'bwd'. +-- +-- @PackM conc abs monad@ provides a way to abstract @conc@ by @abs@, +-- with recording "observations" through @monad@. +-- Similarly to @Pack@, this class is also used just as an interface. +-- Thus, no instances are provided by this package. class (Pack conc abs, Monad m, Functor m) => PackM conc abs m where liftO :: Eq r => ([conc] -> r) -> ([abs] -> m r)@@ -69,6 +78,7 @@ -- type Update a = IntMap a type Update a = EquivMap Int a + ---------------------------------------------------------------- @@ -131,16 +141,22 @@ ------------------------------------------------------+-- | Data type for the forward execution+newtype New a = New {runNew :: a} +instance Functor New where + fmap f (New a) = New $ f a ++ -- | used internally -instance Pack a (Identity a) where - new = Identity +instance Pack a (New a) where + new = New -- | used internally -instance PackM a (Identity a) Identity where - liftO obs xs = return $ obs (map runIdentity xs)- eqSync x y = return $ runIdentity x == runIdentity y - compareSync x y = return $ runIdentity x `compare` runIdentity y +instance PackM a (New a) Identity where + liftO obs xs = return $ obs (map runNew xs)+ eqSync x y = return $ runNew x == runNew y + compareSync x y = return $ runNew x `compare` runNew y -- | used internally instance Pack a (Loc a) where @@ -209,6 +225,6 @@ (forall a m. (PackM c a m) => sf a -> m (vf a)) -> sf c -> vf c fwd pget src =- let Identity r = pget $ fmap Identity src - in fmap runIdentity r+ let Identity r = pget $ fmap New src + in fmap runNew r
Data/BffMono/CheckHistory.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE Rank2Types, ExistentialQuantification #-}+{-# LANGUAGE RankNTypes, ExistentialQuantification #-} module Data.BffMono.CheckHistory where @@ -7,7 +7,6 @@ -- observation function, a list observed elements and an observation -- result. We used an existential type here to store heterogeneous -- observation results into a list.- data CheckResult a = forall b. Eq b => CheckResult ([a] -> b) [a] b
Data/BffMono/EquivMap.hs view
@@ -27,6 +27,7 @@ import Control.Monad.State +-- | A datastructure implements "map" based on Union-Find tree. data EquivMap k a = EquivMap { elemMap :: Map k Int,
Data/BffMono/EquivWitness.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleContexts, Rank2Types #-}+{-# LANGUAGE FlexibleContexts, RankNTypes #-} {-| A restricted version of @EquivMap@, which just records equivalence. -}
bff-mono.cabal view
@@ -1,5 +1,5 @@ name: bff-mono-version: 0.2.1+version: 0.2.2 synopsis: "Bidirectionalization for Free" for Monomorphic Transformations description: This package provides a way to make a bidirectional transformation (a getter/setter pair, or so-called lens)