Browse Source

Add interface'.

tags/0.1.0.0
Thomas Kerber 1 year ago
parent
commit
a65486c1d2
Signed by: Thomas Kerber <tk@drwx.org> GPG Key ID: 8489B911F9ED617B
4 changed files with 7 additions and 9 deletions
  1. +1
    -1
      src/Yggdrasil/Adversarial.hs
  2. +5
    -5
      src/Yggdrasil/ExecutionModel.hs
  3. +1
    -1
      src/Yggdrasil/Functionalities.hs
  4. +0
    -2
      yggdrasil.cabal

+ 1
- 1
src/Yggdrasil/Adversarial.hs View File

@@ -14,7 +14,7 @@ type Adversary s a b = Functionality s (Action (Maybe a), b)
-- | An adversary that just returns 'Nothing'.
noAdversary :: Adversary () a ()
noAdversary = Functionality ()
((,()) . (\f -> f ()) <$> interface (\_ -> return ((), Nothing)))
((,()) <$> interface' (\_ -> return ((), Nothing)))

-- | An adversary that simply forwards a reference to the environment
dummyAdversary :: Action (Maybe b) -> Adversary () b ()

+ 5
- 5
src/Yggdrasil/ExecutionModel.hs View File

@@ -1,11 +1,11 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

module Yggdrasil.ExecutionModel (
Operation, Ref, Action, Functionality(..), external, weaken, abort,
interface, self, doSample, create, run
interface, interface', self, doSample, create, run
) where

import Control.Monad
@@ -80,6 +80,9 @@ abort = Abort
-- 's'.
interface :: Typeable s => Operation s a b -> Action (a -> Action b)
interface = StrengthenSelf

interface' :: Typeable s => Operation s () b -> Action (Action b)
interface' op = (\f -> f ()) <$> interface op
-- | Obtain a weak reference on ourselves.
self :: Action Ref
self = Self
@@ -103,9 +106,6 @@ instance Monad Action where
run :: Action b -> Distribution (Maybe b)
run a = runMaybeT $ snd <$> run' (World []) external a

--run :: Sampler s => s -> Action b -> Maybe (b, s)
--run s a = (\(_, b, s') -> (b, s')) <$> run' s (World []) external a

run' :: World -> Ref -> Action b -> MaybeT Distribution (World, b)
run' _ _ Abort = MaybeT $ return Nothing
run' wld slf (StrengthenSelf f) = MaybeT $ return $

+ 1
- 1
src/Yggdrasil/Functionalities.hs View File

@@ -14,7 +14,7 @@ crsOp _ (Just x, _, ()) = return (Just x, x)
crsOp d (Nothing, _, ()) = (\x -> (Just x, x)) <$> doSample d
commonRandomString :: Typeable b =>
Distribution b -> Functionality (Maybe b) (Action b)
commonRandomString d = Functionality Nothing ((\f -> f ()) <$> interface (crsOp d))
commonRandomString d = Functionality Nothing (interface' (crsOp d))

type ROState a b = [(a, b)]
roLookup :: Eq a => ROState a b -> a -> Maybe b

+ 0
- 2
yggdrasil.cabal View File

@@ -26,7 +26,6 @@ library
Rank2Types
ScopedTypeVariables
TupleSections
TypeOperators
build-depends: base
, cryptonite
, memory
@@ -38,7 +37,6 @@ library
test-suite spec
type: exitcode-stdio-1.0
other-extensions: ScopedTypeVariables
TypeOperators
default-language: Haskell2010
hs-source-dirs: tests
ghc-options: -Wall -Werror

Loading…
Cancel
Save