Skip to content

Commit

Permalink
No Contract type in the AST
Browse files Browse the repository at this point in the history
zoep committed Sep 17, 2024
1 parent 8eb0ca4 commit d2af737
Showing 3 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Act/Syntax/TimeAgnostic.hs
Original file line number Diff line number Diff line change
@@ -218,7 +218,7 @@ data Exp (a :: ActType) (t :: Timing) where
ByLit :: Pn -> ByteString -> Exp AByteStr t
ByEnv :: Pn -> EthEnv -> Exp AByteStr t
-- contracts
Create :: Pn -> Id -> [TypedExp t] -> Exp AContract t
Create :: Pn -> Id -> [TypedExp t] -> Exp AInteger t
-- polymorphic
Eq :: Pn -> SType a -> Exp a t -> Exp a t -> Exp ABoolean t
NEq :: Pn -> SType a -> Exp a t -> Exp a t -> Exp ABoolean t
9 changes: 1 addition & 8 deletions src/Act/Syntax/Types.hs
Original file line number Diff line number Diff line change
@@ -31,7 +31,6 @@ data ActType
= AInteger
| ABoolean
| AByteStr
| AContract

-- | Singleton runtime witness for Act types
-- Sometimes we need to examine type tags at runime. Tagging structures
@@ -40,23 +39,20 @@ data SType (a :: ActType) where
SInteger :: SType AInteger
SBoolean :: SType ABoolean
SByteStr :: SType AByteStr
SContract :: SType AContract
deriving instance Eq (SType a)

instance Show (SType a) where
show = \case
SInteger -> "int"
SBoolean -> "bool"
SByteStr -> "bytestring"
SContract -> "contract"

type instance Sing = SType

instance TestEquality SType where
testEquality SInteger SInteger = Just Refl
testEquality SBoolean SBoolean = Just Refl
testEquality SByteStr SByteStr = Just Refl
testEquality SContract SContract = Just Refl
testEquality _ _ = Nothing


@@ -70,7 +66,6 @@ eqS fa fb = maybe False (\Refl -> fa == fb) $ testEquality (sing @a) (sing @b)
instance SingI 'AInteger where sing = SInteger
instance SingI 'ABoolean where sing = SBoolean
instance SingI 'AByteStr where sing = SByteStr
instance SingI 'AContract where sing = SContract

-- | Reflection of an Act type into a haskell type. Usefull to define
-- the result type of the evaluation function.
@@ -95,17 +90,15 @@ someType :: ActType -> SomeType
someType AInteger = SomeType SInteger
someType ABoolean = SomeType SBoolean
someType AByteStr = SomeType SByteStr
someType AContract = SomeType SContract

actType :: SType s -> ActType
actType SInteger = AInteger
actType SBoolean = ABoolean
actType SByteStr = AByteStr
actType SContract = AContract

fromValueType :: ValueType -> ActType
fromValueType (PrimitiveType t) = fromAbiType t
fromValueType (ContractType _) = AContract
fromValueType (ContractType _) = AInteger

data SomeType where
SomeType :: SingI a => SType a -> SomeType
2 changes: 1 addition & 1 deletion src/Act/Type.hs
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ topologicalSort (Act store contracts) =
else if OM.member v visited then pure visited
else
let (ws, code) = adjacent v in
let stack' = Set.insert v stack in
let stack' = Set.insert v stack \in
(OM.|<) (v, code) <$> foldValidation (dfs stack') visited ws

adjacent :: Id -> ([Id], Contract)

0 comments on commit d2af737

Please sign in to comment.