# Is it possible to have typeof

**URL:** <https://discourse.ats-lang.org/t/is-it-possible-to-have-typeof/121>\
**Category:** Google Group\
**Created:** [February 21, 2014, 6:43am UTC](https://discourse.ats-lang.org/t/is-it-possible-to-have-typeof/121 "2014-02-21T06:43:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chotu\_S](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Chotu\_S](https://discourse.ats-lang.org/u/Chotu_S)\
**Post date:** [February 21, 2014, 6:43am UTC](https://discourse.ats-lang.org/t/is-it-possible-to-have-typeof/121/1 "2014-02-21T06:43:59Z")

</div>

Is it possible to have primitive “typeof” which takes a expression and  
produce the type of that expression rep as a string which can be printed.

For example :

val x : string = typeof(10)

Thanks

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [May 12, 2015, 10:13pm UTC](https://discourse.ats-lang.org/t/is-it-possible-to-have-typeof/121/2 "2015-05-12T22:13:20Z")

</div>

> I put an example on-line showing how to use ‘showtype’ and ‘showlvaltype’:
> 
> [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/qa-list-205.dats](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/qa-list-205.dats)
> 
> If showtype is not available, try $showtype; showlvaltype should be  
> available.

`showlvaltype` seems to not be anymore.

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [February 21, 2014, 5:45pm UTC](https://discourse.ats-lang.org/t/is-it-possible-to-have-typeof/121/3 "2014-02-21T17:45:42Z")

</div>

I put an example on-line showing how to use ‘showtype’ and ‘showlvaltype’:

> <https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/qa-list-205.dats>

If showtype is not available, try $showtype; showlvaltype should be  
available.

Both showtype and showlvaltype are based on $showtype, which indicates to  
the typechecker of ATS  
that the type of its argument needs to be printed out during typechecking.On Friday, February 21, 2014 1:43:59 AM UTC-5, chotu s wrote:

> Is it possible to have primitive “typeof” which takes a expression and  
> produce the type of that expression rep as a string which can be printed.
> 
> For example :
> 
> val x : string = typeof(10)
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [May 12, 2015, 10:17pm UTC](https://discourse.ats-lang.org/t/is-it-possible-to-have-typeof/121/4 "2015-05-12T22:17:02Z")

</div>

See prelude/macrodef.sats:

macdef showtype (x) = $showtype ,(x)  
macdef showview (x) = pridentity\_v ($showtype ,(x))  
macdef showviewtype (x) = pridentity\_vt ($showtype ,(x))

It is called showviewtype. I will add showvtype for showviewtype later.On Tue, May 12, 2015 at 6:13 PM, ‘Yannick Duchêne’ via ats-lang-users \< [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com)\> wrote:

> Le vendredi 21 février 2014 18:45:42 UTC+1, gmhwxi a écrit :
> 
> > I put an example on-line showing how to use ‘showtype’ and ‘showlvaltype’:
> > 
> > [https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/qa-list-205.dats](https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATS-QA-LIST/qa-list-205.dats)
> > 
> > If showtype is not available, try $showtype; showlvaltype should be  
> > available.
> 
> `showlvaltype` seems to not be anymore.
> 
> –  
> 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-user...@googlegroups.com](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/ats-lang-users/c94db493-430e-483b-a9f9-d914fc6dbacb%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/c94db493-430e-483b-a9f9-d914fc6dbacb%40googlegroups.com)  
> [https://groups.google.com/d/msgid/ats-lang-users/c94db493-430e-483b-a9f9-d914fc6dbacb%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/c94db493-430e-483b-a9f9-d914fc6dbacb%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [February 21, 2014, 1:40pm UTC](https://discourse.ats-lang.org/t/is-it-possible-to-have-typeof/121/5 "2014-02-21T13:40:44Z")

</div>

$showtype does this.On Feb 21, 2014 1:44 AM, “chotu s” [chot...@gmail.com](mailto:chot...@gmail.com) wrote:

> Is it possible to have primitive “typeof” which takes a expression and  
> produce the type of that expression rep as a string which can be printed.
> 
> For example :
> 
> val x : string = typeof(10)
> 
> Thanks
> 
> –  
> 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-user...@googlegroups.com](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zkDJ82JeSZFQF8GCFGk5f%2BuS70HGUbgSfyY4B9S019Wg%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zkDJ82JeSZFQF8GCFGk5f%2BuS70HGUbgSfyY4B9S019Wg%40mail.gmail.com)  
> .

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [February 21, 2014, 1:41pm UTC](https://discourse.ats-lang.org/t/is-it-possible-to-have-typeof/121/6 "2014-02-21T13:41:57Z")

</div>

But I think it directly prints the string.On Feb 21, 2014 8:40 AM, “Brandon Barker” [brandon...@gmail.com](mailto:brandon...@gmail.com) wrote:

> $showtype does this.  
> On Feb 21, 2014 1:44 AM, “chotu s” [chot...@gmail.com](mailto:chot...@gmail.com) wrote:
> 
> > Is it possible to have primitive “typeof” which takes a expression and  
> > produce the type of that expression rep as a string which can be printed.
> > 
> > For example :
> > 
> > val x : string = typeof(10)
> > 
> > Thanks
> > 
> > –  
> > 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-user...@googlegroups.com](mailto:ats-lang-user...@googlegroups.com).  
> > To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zkDJ82JeSZFQF8GCFGk5f%2BuS70HGUbgSfyY4B9S019Wg%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4zkDJ82JeSZFQF8GCFGk5f%2BuS70HGUbgSfyY4B9S019Wg%40mail.gmail.com)  
> > .
