Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Module, containing on-chain views declarations.
Synopsis
- newtype ViewName where
- UnsafeViewName {
- unViewName :: Text
- pattern ViewName :: Text -> ViewName
- UnsafeViewName {
- mkViewName :: Text -> Either BadViewNameError ViewName
- viewNameToMText :: ViewName -> MText
- type ViewCode' instr arg st ret = instr '['TPair arg st] '[ret]
- data View' instr arg st ret = (ViewableScope arg, SingI st, ViewableScope ret) => View {}
- data SomeView' instr st where
- someViewName :: SomeView' instr st -> ViewName
- newtype ViewsSet' instr st where
- data ViewsSetError = DuplicatedViewName ViewName
- mkViewsSet :: [SomeView' instr st] -> Either ViewsSetError (ViewsSet' instr st)
- emptyViewsSet :: ViewsSet' instr st
- addViewToSet :: View' instr arg st ret -> ViewsSet' instr st -> Either ViewsSetError (ViewsSet' instr st)
- lookupView :: ViewName -> ViewsSet' instr st -> Maybe (SomeView' instr st)
- viewsSetNames :: ViewsSet' instr st -> [ViewName]
- data SomeViewsSet' instr where
- SomeViewsSet :: SingI st => ViewsSet' instr st -> SomeViewsSet' instr
View
Name of the view.
- It must not exceed 31 chars length;
- Must use [a-zA-Z0-9_.%@] charset.
Instances
mkViewName :: Text -> Either BadViewNameError ViewName Source #
Construct ViewName
performing all the checks.
viewNameToMText :: ViewName -> MText Source #
Valid view names form a subset of valid Michelson texts.
data View' instr arg st ret Source #
Contract view.
(ViewableScope arg, SingI st, ViewableScope ret) => View | |
data SomeView' instr st where Source #
Instances
(forall (arg :: T) (ret :: T). Show (ViewCode' instr arg st ret)) => Show (SomeView' instr st) Source # | |
(forall (arg :: T) (ret :: T). NFData (ViewCode' instr arg st ret)) => NFData (SomeView' instr st) Source # | |
Defined in Morley.Michelson.Typed.View | |
(forall (arg :: T) (ret :: T). Eq (ViewCode' instr arg st ret)) => Eq (SomeView' instr st) Source # | |
someViewName :: SomeView' instr st -> ViewName Source #
Obtain the name of the view.
Views set
newtype ViewsSet' instr st Source #
Views that belong to one contract.
Invariant: all view names are unique.
Implementation note: lookups still take linear time.
We use Seq
for simplicity, as in either case we need to preserve the order
of views (so that decoding/encoding roundtrip).
UnsafeViewsSet | |
|
pattern ViewsSet :: Seq (SomeView' instr st) -> ViewsSet' instr st | |
pattern ViewsList :: [SomeView' instr st] -> ViewsSet' instr st |
Instances
(forall (i :: [T]) (o :: [T]). Show (instr i o)) => Show (ViewsSet' instr st) Source # | |
Default (ViewsSet' instr st) Source # | |
Defined in Morley.Michelson.Typed.View | |
(forall (i :: [T]) (o :: [T]). NFData (instr i o)) => NFData (ViewsSet' instr st) Source # | |
Defined in Morley.Michelson.Typed.View | |
(forall (i :: [T]) (o :: [T]). Eq (instr i o)) => Eq (ViewsSet' instr st) Source # | |
Container (ViewsSet' instr st) Source # | |
Defined in Morley.Michelson.Typed.View toList :: ViewsSet' instr st -> [Element (ViewsSet' instr st)] # null :: ViewsSet' instr st -> Bool # foldr :: (Element (ViewsSet' instr st) -> b -> b) -> b -> ViewsSet' instr st -> b # foldl :: (b -> Element (ViewsSet' instr st) -> b) -> b -> ViewsSet' instr st -> b # foldl' :: (b -> Element (ViewsSet' instr st) -> b) -> b -> ViewsSet' instr st -> b # length :: ViewsSet' instr st -> Int # elem :: Element (ViewsSet' instr st) -> ViewsSet' instr st -> Bool # foldMap :: Monoid m => (Element (ViewsSet' instr st) -> m) -> ViewsSet' instr st -> m # fold :: ViewsSet' instr st -> Element (ViewsSet' instr st) # foldr' :: (Element (ViewsSet' instr st) -> b -> b) -> b -> ViewsSet' instr st -> b # notElem :: Element (ViewsSet' instr st) -> ViewsSet' instr st -> Bool # all :: (Element (ViewsSet' instr st) -> Bool) -> ViewsSet' instr st -> Bool # any :: (Element (ViewsSet' instr st) -> Bool) -> ViewsSet' instr st -> Bool # and :: ViewsSet' instr st -> Bool # or :: ViewsSet' instr st -> Bool # find :: (Element (ViewsSet' instr st) -> Bool) -> ViewsSet' instr st -> Maybe (Element (ViewsSet' instr st)) # safeHead :: ViewsSet' instr st -> Maybe (Element (ViewsSet' instr st)) # safeMaximum :: ViewsSet' instr st -> Maybe (Element (ViewsSet' instr st)) # safeMinimum :: ViewsSet' instr st -> Maybe (Element (ViewsSet' instr st)) # safeFoldr1 :: (Element (ViewsSet' instr st) -> Element (ViewsSet' instr st) -> Element (ViewsSet' instr st)) -> ViewsSet' instr st -> Maybe (Element (ViewsSet' instr st)) # safeFoldl1 :: (Element (ViewsSet' instr st) -> Element (ViewsSet' instr st) -> Element (ViewsSet' instr st)) -> ViewsSet' instr st -> Maybe (Element (ViewsSet' instr st)) # | |
type Element (ViewsSet' instr st) Source # | |
data ViewsSetError Source #
Errors possible when constructing 'ViewsSet''.
Instances
Show ViewsSetError Source # | |
Defined in Morley.Michelson.Typed.View showsPrec :: Int -> ViewsSetError -> ShowS # show :: ViewsSetError -> String # showList :: [ViewsSetError] -> ShowS # | |
Buildable ViewsSetError Source # | |
Defined in Morley.Michelson.Typed.View build :: ViewsSetError -> Builder # | |
Eq ViewsSetError Source # | |
Defined in Morley.Michelson.Typed.View (==) :: ViewsSetError -> ViewsSetError -> Bool # (/=) :: ViewsSetError -> ViewsSetError -> Bool # |
mkViewsSet :: [SomeView' instr st] -> Either ViewsSetError (ViewsSet' instr st) Source #
Construct views set.
emptyViewsSet :: ViewsSet' instr st Source #
No views.
addViewToSet :: View' instr arg st ret -> ViewsSet' instr st -> Either ViewsSetError (ViewsSet' instr st) Source #
Add a view to set.
lookupView :: ViewName -> ViewsSet' instr st -> Maybe (SomeView' instr st) Source #
Find a view in the set.
viewsSetNames :: ViewsSet' instr st -> [ViewName] Source #
Get all taken names in views set.
data SomeViewsSet' instr where Source #
SomeViewsSet :: SingI st => ViewsSet' instr st -> SomeViewsSet' instr |
Instances
(forall (i :: [T]) (o :: [T]). Show (instr i o)) => Show (SomeViewsSet' instr) Source # | |
Defined in Morley.Michelson.Typed.View showsPrec :: Int -> SomeViewsSet' instr -> ShowS # show :: SomeViewsSet' instr -> String # showList :: [SomeViewsSet' instr] -> ShowS # | |
(forall (i :: [T]) (o :: [T]). NFData (instr i o)) => NFData (SomeViewsSet' instr) Source # | |
Defined in Morley.Michelson.Typed.View rnf :: SomeViewsSet' instr -> () # | |
(forall (i :: [T]) (o :: [T]). Eq (instr i o)) => Eq (SomeViewsSet' instr) Source # | |
Defined in Morley.Michelson.Typed.View (==) :: SomeViewsSet' instr -> SomeViewsSet' instr -> Bool # (/=) :: SomeViewsSet' instr -> SomeViewsSet' instr -> Bool # |