Article View: comp.lang.functional
Article #626Re: 3rd order functions
From: Thorsten Altenkirch
Date: Fri, 02 Oct 1992 12:34
Date: Fri, 02 Oct 1992 12:34
43 lines
2248 bytes
2248 bytes
In article <1992Oct1.174259@cs.utwente.nl> ramaer@cs.utwente.nl (Mark Ramaer) writes: "alt" chooses between two "a"-parsers. > alt :: ([t]->Bool) -> Parser t r a -> Parser t r a -> Parser t r a > alt test aa bb = \contin input -> > if test input > then aa contin input > else bb contin input > sequenceOption :: ([*]->bool) -> Parser t r a -> Parser t r [a] > sequenceOption test aa = alt test (sequence test aa) (empty []) "Parser t r a" is a 2nd order type, so "alt" and "sequenceOption" are 3rd order functions. Thanks Mark, this certainly is a 3rd order function. In another posting I tried to make the requirements more precise: If we have polymorphism, it is not clear what level to assign to type variables. In fact it is quite easy to get a 3rd order functions just by instantiating the type of polymorphic map by a 1st order function type for the input list. However, I am interested in *genuine* higher order functions, i.e. which do not show up as instantiations of polymorphic functions. This means that in this context I consider the order of a type variable as 0. Your function alt can be obtained by instantiating a 2nd order polymorphic function to the type Parser, right? In this way it is not genuinely higher order. The following is an example of a genuine higher order function, but alas it is not very interesting (it is just an instance of application): \lambda: f:((N->N)->N)->N.f succ : ((N->N)->N)->N -- Thorsten Altenkirch LFCS, Edinburgh "Germany still proves reluctant to exchange email with other countries efficiently" - Summer 1992 Systems Newsletter, Dep. of CS,Edinburgh
Technical Details
Message-ID:
<ALTI.92Oct2123450@tanera.dcs.ed.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!edcastle!dcs.ed.ac.uk!altiReferences:
<BvFvEz.7A@dcs.ed.ac.uk> <1992Oct1.153234@cs.utwente.nl> <1992Oct1.174259@cs.utwente.nl>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!edcastle!dcs.ed.ac.uk!alti From: alti@dcs.ed.ac.uk (Thorsten Altenkirch) Newsgroups: comp.lang.functional Subject: Re: 3rd order functions Message-ID: <ALTI.92Oct2123450@tanera.dcs.ed.ac.uk> Date: 2 Oct 92 12:34:50 GMT References: <BvFvEz.7A@dcs.ed.ac.uk> <1992Oct1.153234@cs.utwente.nl> <1992Oct1.174259@cs.utwente.nl> Sender: cnews@dcs.ed.ac.uk (UseNet News Admin) Organization: LFCS, Edinburgh Lines: 43 In-Reply-To: ramaer@cs.utwente.nl's message of 1 Oct 92 16:42:59 GMT