aqua-playground/aqua/examples/dataAlias.aqua

18 lines
523 B
Plaintext
Raw Permalink Normal View History

-- set `PeerId` name to be a type alias for `string` type
alias PeerId : string
-- define data structure (ADT)
data NodeId:
peerId: PeerId
name: string
2021-04-15 12:45:18 +03:00
-- define service `NodeIdGetter` that will be callable on local client via `somesrv` service id
service NodeIdGetter("somesrv"):
get: -> NodeId
2021-04-15 12:45:18 +03:00
-- 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()
2021-04-14 17:32:01 +03:00
<- res.peerId