Re: resolving overloaded operators and staload

2020-09-24 Thread Hongwei Xi
Yes, you are correct.

An overload declaration in a package is available only when the package is
opened.

>>is it ok to have such 2 staloads or are there any other good practice to
staload only overloaded symbols? Maybe, there is a way to staload only some
of symbols (like in haskell's 'import' command like this:

Staloading is idempotent. It is totally okay to overload it multiple times.

I often just add the following line in the file where appendC is used:

overload + with $BS.appendC

Supporting haskell-like imports should be straightforward. Let me postpone
this until ATS3 is ready.

--Hongwei



On Thu, Sep 24, 2020 at 12:11 AM Dambaev Alexander 
wrote:

> Hi,
> I want to confirm what I see in practice:
> 1. I had defined abstract vtype Bytesting and overloaded '+' operator for
> it like this:
> ```
> (* the same as append, but consumes arguments in order to make caller's
> code clear from bunch of val's and free()
>  *)
> fn
>   appendC
>   {l_n, r_n, l_cap, r_cap: nat}
>   ( l: Bytestring(l_n, l_cap)
>   , r: Bytestring(r_n, r_cap)
>   ):
>   [res_cap: nat | res_cap >= l_n + r_n]
>   Bytestring( l_n+r_n, res_cap)
>
> overload + with appendC
> ```
> in the SATS file
>
> 2. I want to have an alias for symbols from this SATS file, so I am
> staloading it like this:
> ```
> staload BS="{$LIBS}/ats-bytestring/SATS/bytestring.sats"
> ```
> 3. but this is not enough to bring overloading of '+' into the scope and I
> have to add another staload:
> ```
> staload "{$LIBS}/ats-bytestring/SATS/bytestring.sats" (* for operator
> overloading in scope *)
> ```
>
> am I correct to assume, that I need the second staload to add overloading
> info into the global scope?
> Because without second staload, I can't write:
> ```
> val one = $BS.pack "one"
> val two = $BS.pack "two"
> val three = one + two (* failes to resolve + here without second staload *)
> ```
>
> is it ok to have such 2 staloads or are there any other good practice to
> staload only overloaded symbols? Maybe, there is a way to staload only some
> of symbols (like in haskell's 'import' command like this:
> ```
> import Data.ByteString (ByteString) -- imports only ByteString type into
> global scope
> import qualified Data.ByteString as BS -- the rest are being accessed only
> through alias BS
> ```
> )
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ats-lang-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ats-lang-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KyUefdSgSMyunE_QYDHCp1L6uUdRt-sbBKjWgWNKxHZJg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ats-lang-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLpn6PjWcoP49opMnwzL2q0BMT%2BHz3NWwFqfEtuO-pZSAw%40mail.gmail.com.


resolving overloaded operators and staload

2020-09-23 Thread Dambaev Alexander
Hi,
I want to confirm what I see in practice:
1. I had defined abstract vtype Bytesting and overloaded '+' operator for
it like this:
```
(* the same as append, but consumes arguments in order to make caller's
code clear from bunch of val's and free()
 *)
fn
  appendC
  {l_n, r_n, l_cap, r_cap: nat}
  ( l: Bytestring(l_n, l_cap)
  , r: Bytestring(r_n, r_cap)
  ):
  [res_cap: nat | res_cap >= l_n + r_n]
  Bytestring( l_n+r_n, res_cap)

overload + with appendC
```
in the SATS file

2. I want to have an alias for symbols from this SATS file, so I am
staloading it like this:
```
staload BS="{$LIBS}/ats-bytestring/SATS/bytestring.sats"
```
3. but this is not enough to bring overloading of '+' into the scope and I
have to add another staload:
```
staload "{$LIBS}/ats-bytestring/SATS/bytestring.sats" (* for operator
overloading in scope *)
```

am I correct to assume, that I need the second staload to add overloading
info into the global scope?
Because without second staload, I can't write:
```
val one = $BS.pack "one"
val two = $BS.pack "two"
val three = one + two (* failes to resolve + here without second staload *)
```

is it ok to have such 2 staloads or are there any other good practice to
staload only overloaded symbols? Maybe, there is a way to staload only some
of symbols (like in haskell's 'import' command like this:
```
import Data.ByteString (ByteString) -- imports only ByteString type into
global scope
import qualified Data.ByteString as BS -- the rest are being accessed only
through alias BS
```
)

-- 
You received this message because you are subscribed to the Google Groups 
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ats-lang-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KyUefdSgSMyunE_QYDHCp1L6uUdRt-sbBKjWgWNKxHZJg%40mail.gmail.com.