aqua-playground/aqua/examples/dataAlias.aqua
2021-05-26 18:24:45 +03:00

18 lines
523 B
Plaintext

-- set `PeerId` name to be a type alias for `string` type
alias PeerId : string
-- define data structure (ADT)
data NodeId:
peerId: PeerId
name: string
-- define service `NodeIdGetter` that will be callable on local client via `somesrv` service id
service NodeIdGetter("somesrv"):
get: -> NodeId
-- showcases a function that gets data structure from a local service,
-- and then retrieves aliased data type from that structure
func getAliasedData() -> PeerId:
res <- NodeIdGetter.get()
<- res.peerId