Values to string

In haskell one can use (show x) to convert x to string , provided that x is
showable and new datatypes can implement show for converting values of that
type to string.

Is there already some thing like show in ATS that can use to convert
to string from integer , char , bool and other types.

Thanks.

I added tostring.sats and tostring.dats into ATSLIB/prelude:

This will be made available in the next release.

In general, a tostring_* function is based on its corresponding tostrptr_*
function; the latter
returns a linear string that can be freed after its use.

Here are a few short examples:

https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATSLIB/prelude_tostring.datsOn Saturday, April 4, 2015 at 11:28:11 PM UTC-4, Chotu S wrote:

Thanks for reply.

Main purpose is to have a documented uniform interface for common tasks
like for converting values to string , reading values from string and
others.

It is not like that you cannot do Haskell style of programming in ATS.

However, you
can quickly feel that such a style of programming done in ATS is rather
wasteful.

Okay :slight_smile:

On Saturday, April 4, 2015 at 11:11:02 PM UTC+5:30, gmhwxi wrote:

As of now, the primary way to “show” a value in ATS is to call some
kind of ‘fprint’ function.

‘show’ in Haskell sounds like a misnomer; it should really be called
‘toString’.

There is a tostring (not toString) function for bool and another for
char. I can gradually
add such functions for other common types.

It is not like that you cannot do Haskell style of programming in ATS.
However, you
can quickly feel that such a style of programming done in ATS is rather
wasteful.

On Saturday, April 4, 2015 at 10:27:28 AM UTC-4, Chotu S wrote:

In haskell one can use (show x) to convert x to string , provided that x
is showable and new datatypes can implement show for converting values of
that type to string.

Is there already some thing like show in ATS that can use to
convert to string from integer , char , bool and other types.

Thanks.

The kind of polymorphism involved in tostring_val is often referred to as
ad-hoc polymorphism
(in contrast to parametric polymorphism).On Wed, Apr 8, 2015 at 12:24 PM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:

Le dimanche 5 avril 2015 22:20:59 UTC+2, gmhwxi a écrit :

Here are a few short examples:

https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATSLIB/prelude_tostring.dats

The things like tostring_val<int> here , is this classical generic as it
looks like or is this static polymorphism as I feel to guess?


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.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at 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/d7d0d222-11fd-4994-89b7-243dc9b3d6c3%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/d7d0d222-11fd-4994-89b7-243dc9b3d6c3%40googlegroups.com?utm_medium=email&utm_source=footer
.

I believe your guess is correct:
https://github.com/githwxi/ATS-Postiats/commit/28b20bc1ec78e3cf70bd2ac7ca676867a75b8c32On Wed, Apr 8, 2015 at 12:24 PM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:

Le dimanche 5 avril 2015 22:20:59 UTC+2, gmhwxi a écrit :

Here are a few short examples:

https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATSLIB/prelude_tostring.dats

The things like tostring_val<int> here , is this classical generic as it
looks like or is this static polymorphism as I feel to guess?


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.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at 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/d7d0d222-11fd-4994-89b7-243dc9b3d6c3%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/d7d0d222-11fd-4994-89b7-243dc9b3d6c3%40googlegroups.com?utm_medium=email&utm_source=footer
.

Brandon Barker
brandon...@gmail.com

Thanks for reply.

Main purpose is to have a documented uniform interface for common tasks
like for converting values to string , reading values from string and
others.

It is not like that you cannot do Haskell style of programming in ATS.

However, you
can quickly feel that such a style of programming done in ATS is rather
wasteful.

Okay :-)On Saturday, April 4, 2015 at 11:11:02 PM UTC+5:30, gmhwxi wrote:

As of now, the primary way to “show” a value in ATS is to call some
kind of ‘fprint’ function.

‘show’ in Haskell sounds like a misnomer; it should really be called
‘toString’.

There is a tostring (not toString) function for bool and another for char.
I can gradually
add such functions for other common types.

It is not like that you cannot do Haskell style of programming in ATS.
However, you
can quickly feel that such a style of programming done in ATS is rather
wasteful.

On Saturday, April 4, 2015 at 10:27:28 AM UTC-4, Chotu S wrote:

In haskell one can use (show x) to convert x to string , provided that x
is showable and new datatypes can implement show for converting values of
that type to string.

Is there already some thing like show in ATS that can use to
convert to string from integer , char , bool and other types.

Thanks.

Here are a few short examples:

https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/ATSLIB/prelude_tostring.dats

The things like tostring_val<int> here , is this classical generic as it
looks like or is this static polymorphism as I feel to guess?

As of now, the primary way to “show” a value in ATS is to call some
kind of ‘fprint’ function.

‘show’ in Haskell sounds like a misnomer; it should really be called
‘toString’.

There is a tostring (not toString) function for bool and another for char.
I can gradually
add such functions for other common types.

It is not like that you cannot do Haskell style of programming in ATS.
However, you
can quickly feel that such a style of programming done in ATS is rather
wasteful.On Saturday, April 4, 2015 at 10:27:28 AM UTC-4, Chotu S wrote:

In haskell one can use (show x) to convert x to string , provided that x
is showable and new datatypes can implement show for converting values of
that type to string.

Is there already some thing like show in ATS that can use to
convert to string from integer , char , bool and other types.

Thanks.