Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.haskell > #180 > unrolled thread

sell me on strong typing, type safety, etc.

Started byultranewb <pineapple.link@yahoo.com>
First post2012-03-30 09:53 -0700
Last post2012-04-06 22:17 -0400
Articles 10 on this page of 30 — 8 participants

Back to article view | Back to comp.lang.haskell


Contents

  sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-03-30 09:53 -0700
    Re: sell me on strong typing, type safety, etc. John Coleman <jcoleman@franciscan.edu> - 2012-03-31 06:25 -0700
      Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-03-31 11:57 -0700
    Re: sell me on strong typing, type safety, etc. ingo.wechsung@googlemail.com - 2012-04-01 08:23 -0700
      Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-01 13:35 -0700
        Re: sell me on strong typing, type safety, etc. ingo.wechsung@googlemail.com - 2012-04-02 03:51 -0700
          Re: sell me on strong typing, type safety, etc. Roman W <bloody_rabbit@gazeta.pl> - 2012-04-02 04:31 -0700
      Re: sell me on strong typing, type safety, etc. dvandeun@wilma.vub.ac.be (Dirk van Deun) - 2012-04-03 09:13 +0000
        Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-03 11:00 -0700
    Re: sell me on strong typing, type safety, etc. Roman W <bloody_rabbit@gazeta.pl> - 2012-04-02 02:03 -0700
      Re: sell me on strong typing, type safety, etc. ingo.wechsung@googlemail.com - 2012-04-02 03:30 -0700
        Re: sell me on strong typing, type safety, etc. Roman W <bloody_rabbit@gazeta.pl> - 2012-04-02 04:28 -0700
          Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-02 12:17 -0700
            Re: sell me on strong typing, type safety, etc. Roman W <bloody_rabbit@gazeta.pl> - 2012-04-03 06:58 -0700
              Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-03 10:58 -0700
                Re: sell me on strong typing, type safety, etc. Paul Rubin <no.email@nospam.invalid> - 2012-04-03 12:07 -0700
                  Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-03 13:44 -0700
                  Re: sell me on strong typing, type safety, etc. Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-04-03 20:01 -0300
                    Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-04 12:10 -0700
                Re: sell me on strong typing, type safety, etc. Roman W <bloody_rabbit@gazeta.pl> - 2012-04-04 03:32 -0700
                  Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-04 09:37 -0700
                    Re: sell me on strong typing, type safety, etc. Roman W <bloody_rabbit@gazeta.pl> - 2012-04-04 09:43 -0700
                      Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-04 11:11 -0700
                        Re: sell me on strong typing, type safety, etc. Roman W <bloody_rabbit@gazeta.pl> - 2012-04-05 01:42 -0700
                          Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-06 08:22 -0700
                            Re: sell me on strong typing, type safety, etc. ingo.wechsung@googlemail.com - 2012-04-06 08:32 -0700
                              Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-06 18:29 -0700
                                Re: sell me on strong typing, type safety, etc. Paul Rubin <no.email@nospam.invalid> - 2012-04-06 18:44 -0700
                              Re: sell me on strong typing, type safety, etc. ultranewb <pineapple.link@yahoo.com> - 2012-04-06 18:32 -0700
                                Re: sell me on strong typing, type safety, etc. "Mark T. B. Carroll" <mtbc@bcs.org> - 2012-04-06 22:17 -0400

Page 2 of 2 — ← Prev page 1 [2]


#199

Fromultranewb <pineapple.link@yahoo.com>
Date2012-04-04 09:37 -0700
Message-ID<94d05788-f606-4156-8761-443d710e7451@v7g2000pbs.googlegroups.com>
In reply to#198
On Apr 4, 5:32 pm, Roman W <bloody_rab...@gazeta.pl> wrote:
> But that's a different question: "why test software?".

No, that's not the question.  I think everyone agrees software should
be tested, and I test software extensively.  The question is whether
one should have reams of type-testing code strewn throughout software
to constantly check dynamically the types of widgets coming from
factories.

For me, it's good enough to do this (Smalltalk-style):

Car new.

I never thought I had to do this:

(Car new isa: Car) ifTrue: [...] ifFalse:[...].

[toc] | [prev] | [next] | [standalone]


#200

FromRoman W <bloody_rabbit@gazeta.pl>
Date2012-04-04 09:43 -0700
Message-ID<31682321.205.1333557802939.JavaMail.geo-discussion-forums@vbtg38>
In reply to#199
On Wednesday, April 4, 2012 5:37:51 PM UTC+1, ultranewb wrote:
> On Apr 4, 5:32 pm, Roman W <bloody_rab...@gazeta.pl> wrote:
> > But that's a different question: "why test software?".
> 
> No, that's not the question.  I think everyone agrees software should
> be tested, and I test software extensively.  The question is whether
> one should have reams of type-testing code strewn throughout software
> to constantly check dynamically the types of widgets coming from
> factories.
> 
> For me, it's good enough to do this (Smalltalk-style):
> 
> Car new.
> 
> I never thought I had to do this:
> 
> (Car new isa: Car) ifTrue: [...] ifFalse:[...].

I don't mean that you need to put it in the actual production code. I was thinking of unit tests.

RW

[toc] | [prev] | [next] | [standalone]


#201

Fromultranewb <pineapple.link@yahoo.com>
Date2012-04-04 11:11 -0700
Message-ID<fc414e4d-325c-4c74-9d96-ae7e7edfac30@px4g2000pbc.googlegroups.com>
In reply to#200
On Apr 4, 11:43 pm, Roman W <bloody_rab...@gazeta.pl> wrote:
> I don't mean that you need to put it in the actual production code. I was thinking of unit tests.

Ah, well we agree one needs to do unit tests - sure.

[toc] | [prev] | [next] | [standalone]


#203

FromRoman W <bloody_rabbit@gazeta.pl>
Date2012-04-05 01:42 -0700
Message-ID<11121860.1045.1333615360100.JavaMail.geo-discussion-forums@vbtv42>
In reply to#201
On Wednesday, April 4, 2012 7:11:07 PM UTC+1, ultranewb wrote:
> On Apr 4, 11:43 pm, Roman W <bloody_rab...@gazeta.pl> wrote:
> > I don't mean that you need to put it in the actual production code. I was thinking of unit tests.
> 
> Ah, well we agree one needs to do unit tests - sure.

Exactly. And with dynamic typing, some of the testing which would be done automagically by the compiler needs to be shifted to unit tests, which require active maintenance. More work.

RW

[toc] | [prev] | [next] | [standalone]


#204

Fromultranewb <pineapple.link@yahoo.com>
Date2012-04-06 08:22 -0700
Message-ID<93eeaa84-87e1-445d-bcb4-a1ee394ad5bb@a8g2000pbe.googlegroups.com>
In reply to#203
>> What would you do with such a list if you don't know what is in there?

> sure, you normally need to know what's in there

On second thought, I disagree.  You don't necessarily need to know
what's in a list.

Erlang:

xlength([]) -> 0;
xlength([_|Xs]) -> 1 + xlength(Xs).

56> xlength([5]).
1
57> xlength("hi").
2
58> xlength([]).
0
59> xlength([1, $2, "three", {four, 5}, {}]).
5

[toc] | [prev] | [next] | [standalone]


#205

Fromingo.wechsung@googlemail.com
Date2012-04-06 08:32 -0700
Message-ID<2761773.849.1333726377020.JavaMail.geo-discussion-forums@ynbj3>
In reply to#204
Am Freitag, 6. April 2012 17:22:43 UTC+2 schrieb ultranewb:
> >> What would you do with such a list if you don't know what is in there?
> 
> > sure, you normally need to know what's in there
> 
> On second thought, I disagree.  You don't necessarily need to know
> what's in a list.

You're right.
Of course you can do many things with a list without knowing what's in there. Haskell has plenty of functions with [a] (list of unknown things) in the type.

My question should have been: What would you do with the elements of such a list? You're not going to tell me that you want to put different things into a list just to count them, or to reverse them?

[toc] | [prev] | [next] | [standalone]


#206

Fromultranewb <pineapple.link@yahoo.com>
Date2012-04-06 18:29 -0700
Message-ID<7372b60a-9fa3-4388-aaed-11a91b7f573c@ri8g2000pbc.googlegroups.com>
In reply to#205
On Apr 6, 10:32 pm, ingo.wechs...@googlemail.com wrote:
> My question should have been: What would you do with the elements of such a list? You're not going to tell me that you want to put different things into a list just to count them...?

Why not?  Just off the top of my head, picture an application where
you need to count whatever elements are in a file, whether it be text,
numbers, characters, whatever.  Maybe you don't know what's in the
file.  The list could represent the file that was read in.

You have to be careful about assumptions like "nobody would ever need
to do such-and-such by using such-and-such in such-and-such way to do
it."  The problem domain is too big.

[toc] | [prev] | [next] | [standalone]


#207

FromPaul Rubin <no.email@nospam.invalid>
Date2012-04-06 18:44 -0700
Message-ID<7xaa2o71t5.fsf@ruckus.brouhaha.com>
In reply to#206
ultranewb <pineapple.link@yahoo.com> writes:
> Why not?  Just off the top of my head, picture an application where
> you need to count whatever elements are in a file, whether it be text,
> numbers, characters, whatever.  Maybe you don't know what's in the
> file.  The list could represent the file that was read in.

You would typically use a sum type for that:

   data FileElement = TextElement String | NumberElement Int | ...

and then use a list of type [FileElement].  Lisp like languages are
sometimes called "unityped".  They aren't type-free.  They have just one
type, which is a big sum type, and they use it for everything.

[toc] | [prev] | [next] | [standalone]


#208

Fromultranewb <pineapple.link@yahoo.com>
Date2012-04-06 18:32 -0700
Message-ID<cc5042cf-0f4f-4b66-bca4-6e6a55e0a04e@vy9g2000pbc.googlegroups.com>
In reply to#205
On Apr 6, 10:32 pm, ingo.wechs...@googlemail.com wrote:
> Am Freitag, 6. April 2012 17:22:43 UTC+2 schrieb ultranewb:
> Of course you can do many things with a list without knowing what's in there. Haskell has plenty of functions with [a] (list of unknown things) in the type.

But Haskell can apparently only handle homogeneous lists, I assume
because of the strong typing.  The point of my erlang example was,
dynamic typing can handle lists of truly unknown stuff, where the list
could be a hodge-podge of anything.

[toc] | [prev] | [next] | [standalone]


#209

From"Mark T. B. Carroll" <mtbc@bcs.org>
Date2012-04-06 22:17 -0400
Message-ID<87k41sffp3.fsf@ixod.org>
In reply to#208
ultranewb <pineapple.link@yahoo.com> writes:

> But Haskell can apparently only handle homogeneous lists, I assume
> because of the strong typing.  The point of my erlang example was,
> dynamic typing can handle lists of truly unknown stuff, where the list
> could be a hodge-podge of anything.

But, in actual real-world programs, given that we also have fixed-length
tuples, heterogeneous lists very rarely crop up; sum types, and type
class restrictions, cover typical needs. Haskell /can/ handle
heterogeneous lists using tricks with existential types and suchlike --
for instance, see http://homepages.cwi.nl/~ralf/HList/paper.pdf -- and I
think I once made use of that kind of technique, but the need just
doesn't usually come up. Lists typically aren't just a "hodge-podge of
anything" unless the type system wasn't expressive enough, like lacking
good algebraic types, to say truly what the useful thing is that the
list's elements have in common. Even when one's serializing and
deserializing one normally has lists of bytes or legal datastructure
elements or something. At least, a quick glance through the code I've
written suggests that, at most, I've used functional dependencies to
constrain what kinds of things I have in homogeneous lists passed to the
same function, relative to each other (so, to take an odd but possibly
illustrative example, if the first argument lists hippos, then the
second must have cats, or something), but I'm just not managing to
imagine the motivating example for these truly hodge-podge lists given
sufficiently expressive typing.

Mark

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.haskell


csiph-web