[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: LL1 Discussion <address@hidden>*Subject*: Re: dynamic vs. static typing*From*: Ken Shan <address@hidden>*Date*: Mon, 24 Nov 2003 14:27:18 -0500*In-reply-to*: <oev1u367.fsf@ccs.neu.edu>*Mail-followup-to*: LL1 Discussion <ll1-discuss@ai.mit.edu>*Organization*: very far away from anywhere else*References*: <20031124155511.GA17437@proper.eecs.harvard.edu> <oev1u367.fsf@ccs.neu.edu>*Sender*: address@hidden*User-agent*: Mutt/1.5.4i

On 2003-11-24T11:44:32-0500, Joe Marshall wrote: > If there is no `identity' for the objects in the list, then the list > cannot be permuted (all `permutations' would be indistinguishable). You can permute the list without -knowing- how to compare the objects in the list for identity. The caller of the permutation function may well know more about the objects in the list than the list permutation function needs to know. $ ghci ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.0.1, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. Prelude> let f x = "foo" ++ x Prelude> let g x = "bar" ++ x Prelude> let myList = [f, g] Prelude> let revlist = reverse myList Prelude> map (\h -> h "string") myList ["foostring","barstring"] Prelude> map (\h -> h "string") revlist ["barstring","foostring"] Prelude> :t reverse reverse :: forall a. [a] -> [a] Prelude> f == g <interactive>:1: No instance for (Eq ([Char] -> [Char])) arising from use of `==' at <interactive>:1 In the definition of `it': it = f == g Note that even though Haskell gives me no way to compare the functions f and g for identity, I was still able to invoke the permutation function "reverse" on a list containing these functions. I was able to distinguish between myList and revlist, two lists of equal length, by applying the functions in them to the string "string". -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig Sexy types in action: http://www.eecs.harvard.edu/~ccshan/cs252/usage.pdf new journal Physical Biology: http://sansom.biop.ox.ac.uk/images/physbio.gif What if All Chemists Went on Strike? (science fiction): http://www.iupac.org/publications/ci/2003/2506/iw3_letters.html

**Attachment:
signature.asc**

**Follow-Ups**:**Re: dynamic vs. static typing***From:*Joe Marshall <jrm@ccs.neu.edu>

**References**:**Re: dynamic vs. static typing***From:*Ken Shan <ken@digitas.harvard.edu>

**Re: dynamic vs. static typing***From:*Joe Marshall <jrm@ccs.neu.edu>

- Prev by Date:
**type inference in imperative langauges** - Next by Date:
**Re: dynamic vs. static typing** - Previous by thread:
**Re: dynamic vs. static typing** - Next by thread:
**Re: dynamic vs. static typing** - Index(es):