| Ralf Hinze. Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science, 3(4):159-180, September 1999. |
.... a functional language or a typed lambda calculus is implicit in [9] and appears explicated in [12,7] In the functional programming community, also the general theory of heterogeneous, non uniform or nested datatypes (recursive constructors of rank 2) is currently on the research agenda, see [10,11,20,27]. Typed lambda calculi featuring heterogeneous and higher kind inductive and coinductive constructors are the topic of [23,1,2] A very accessible extended presentation of aspects of Fiore, Plotkin and Turi s work [15] appears in [14] Hofmann [21] has given a category theoretic explanation of the ....
Hinze, R., Polytypic functions over nested datatypes, Discrete Math. and Theoret. Comput. Sci. 3 (1999), pp. 193-214.
....datatypes using explicit fixpoints. This takes away some of the work when implementing a new datatype. However, the types get a lot more complicated and become unmanageable when dealing with more complicated types than regular datatypes. Another big help would be a polytypic programming tool [9, 7]. The resulting language is rather naive in several ways. First of all, the syntax of the programs is often more clumsy than the way you could write it in a dedicated logic programming language. This could be solved by adding some syntactic sugar. Second, the search strategies are not as fancy ....
Ralf Hinze. Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science, 3(4):159--180, 1999.
....2 ) Note that the result of zip is a partial structure if the two arguments have not the same shape. Alternatively, one can de ne a zipping function of type Ziph i t 1 t 2 t 3 = t 1 t 2 Maybe t 3 , which uses the exception monad Maybe to signal incompatibility of the argument structures, see (Hinze, 1999). Polytypic values possess polykinded types 15 6.3 Reductions A reduction or a crush (Meertens, 1996) is a polytypic function that collapses a structure of values of type x into a single value of type x . This section explains how to de ne reductions that work for all types of all kinds. To ....
....this amounts to showing that const e id = const e ( 1 O 2 ) 1 2 ) 1 1 ) O ( 2 2 ) uncurry ( 1 2 ) 1 2 ) uncurry ( 1 1 ) 2 2 ) All three conditions hold. Previous approaches to polytypic programming (Jansson Jeuring, 1997; Hinze, 1999) required the programmer to specify the action of a polytypic function for the composition of two type constructors: for instance, for fsize the polytypic programmer had to supply the equation fsizehf 1 f 2 i = fsumhf 1 i maphf 1 i (fsizehf 2 i) Interestingly, using reduce map fusion this ....
Hinze, Ralf. (1999). Polytypic functions over nested datatypes. Discrete mathematics and theoretical computer science, 3(4), 159-180.
....before generation and is rather rigid in that incorporation of a new traversal scheme requires reprogramming the generator. Generation can also lead to scaling problems [10] 16 Section: Conclusion In polytypic functional programming in PolyP [9] and in in the generalization proposed by Hinze [8, 7], generic functions are de ned on a universal data type and conversion functions between regular data and the universal data type are provided. Polytypic functions can be implemented by implementing the conversion or by generating specializations as needed in a program. Only the conversion ....
Ralf Hinze. Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science, 3(4):159-180, 1999.
....t) a) j One (t a) Vector 0 (Fork t) a) This datatype implements higher order random access lists (Hinze, 1998) If we firstify the type constructor Vector 0 , we obtain the first order variant as defined in Section 4.2. For a discussion of the tradeoffs we refer the interested reader to (Hinze, 1998) The vector (0; 1; 2; 3; 4; 5) is represented by Zero (One (Fork (Id 0) Id 1) One (Fork (Fork (Id 2) Id 3) Fork (Id 4) Id 6) Null) Interestingly, using a slight generalization of Theorem 1 we can transform nat 0 Manufacturing Datatypes 13 into a tail recursive form, as well. nat 7 = nat 0 7 ....
....children of size n and a Braun tree of size 2 n 2 has a left child of size n 1 and a right child of size n. This motivates the following definition. braun = braun 0 0 1 braun 0 n n 0 = n ] braun 0 (n 1 n) n 0 1 n) braun 0 (n 0 1 n) n 0 1 n 0 ) 14 R. Hinze The arguments of braun 0 are always two successive natural numbers. From the corresponding functor equations Braun = Braun 0 (K Unit) Id Braun 0 f f 0 = f j Braun 0 (f Theta Id Theta f ) f 0 Theta Id Theta f ) j Braun 0 (f 0 Theta Id Theta f ) f 0 Theta Id Theta f 0 ) we can derive the ....
Hinze, Ralf. 1999b (March). Polytypic functions over nested datatypes (extended abstract) . 3rd latin-american conference on functional programming (CLaPF'99).
No context found.
Ralf Hinze. Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science, 3(4):159-180, September 1999.
....(zip A a 1 a 2 , zip B b 1 b 2 ) Note that the result of zip is a partial structure if the two arguments have not the same shape. Alternatively, one can define a zipping function of type Maybe X 3 , which uses the exception monad Maybe to signal incompatibility of the argument structures, see [11]. 24 7.3 Reductions A reduction or a crush [23] is a polytypic function that collapses a structure of values of type X into a single value of type X . This section explains how to define reductions that work for all types of all kinds. To illustrate the main idea let us start with three ....
....Using the point free definitions of map and red this amounts to showing that const e id = const e (# 1 # (# 1 # 2 ) # 1 # 1 ) # (# 2 uncurry op # 2 ) uncurry op ( # 1 # 1 ) # 2 # 2 ) All three conditions hold. Previous approaches to polytypic programming [16,11] required the programmer to specify the action of a polytypic function for the composition of two type constructors: for instance, for fsize the polytypic programmer had to supply the equation fsize F 1 = fsum F 1 ) Interestingly, using reduce map fusion this equation can be derived from ....
Ralf Hinze. Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science, 3(4):193--214, September 1999. 35
....x 1 y 1 = z 1 ziphF 2 i x 2 y 2 = z 2 return (z 1 ; z 2 ) Note that the type of zip could be generalized to arbitrary monads that contain a zero element such as fail . 7 Related and Future Work This article can be regarded as a successor to my previous work on polytypic programming [10], where a similar approach using rational trees is presented. The major di erence between the two frameworks lies in the treatment of functor composition. In the rational tree approach functor composition is regarded as a function symbol, which implies that a polytypic de nition must specify the ....
Ralf Hinze. Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science, 3(4):159-180, September 1999.
....2 ) Note that the result of zip is a partial structure if the two arguments have not the same shape. Alternatively, one can de ne a zipping function of type Ziph i t 1 t 2 t 3 = t 1 t 2 Maybe t 3 , which uses the exception monad Maybe to signal incompatibility of the argument structures, see [7]. 6.3 Reductions A reduction or a crush [18] is a polytypic function that collapses a structure of values of type x into a single value of type x . This section explains how to de ne reductions that work for all types of all kinds. To illustrate the main idea let us start with three motivating ....
....de nitions of map and red this amounts to showing that const e id = const e ( 1 O 2 ) 1 2 ) 1 1 ) O ( 2 2 ) uncurry ( 1 2 ) 1 2 ) uncurry ( 1 1 ) 2 2 ) All three conditions hold. Previous approaches to polytypic programming [11, 7] required the programmer to specify the action of a polytypic function for the composition of two type constructors: for instance, for fsize the polytypic programmer had to supply the equation fsizehf 1 f 2 i = fsumhf 1 i maphf 1 i (fsizehf 2 i) Interestingly, using reducemap fusion this ....
Ralf Hinze. Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science, 3(4):159-180, September 1999.
....this translation. In the rest of this section we will briefly sketch the correctness of the translation. Informally, the functor corresponding to a multiset M contains, for each member of M, a container of that size. This statement can be made precise using the framework of polytypic programming [11]. Briefly, a polytypic function is one that is defined by induction on the structure of functor expressions. A simple example for a polytypic function is sumhf i : f N N, which sums a structure of natural numbers. To make the relationship between multisets and functors precise we furthermore ....
....tree algorithms to nested representations of search trees using constructor classes. It is conceivable that this approach can be applied to matrix algorithms, as well. Furthermore, many functions like map, listify, sum etc can be generated automatically using the technique of polytypic programming [11]. On the theoretical side, it would be interesting to investigate the expressiveness of the framework and of higher order polymorphic types in general. Which class of multisets can be described using higher order recursion equations For instance, it appears to be impossible to specify the ....
Ralf Hinze. Polytypic functions over nested datatypes (extended abstract). In 3rd Latin-American Conference on Functional Programming (CLaPF'99), March 1999.
....a suitable reduction function is constructed which then reduces the perfect tree in a top down pass. Clearly, the latter procedure is more efficient than the former. The polytypic function reducemaphf i can be used to implement a number of general purpose functions, see, for instance, 11] 8] or [6]. As a single example here is the definition of size (note that we use the symbol both for coproducts and for addition) sizehf i : Num n) f a n sizehf i = reducemaphf i 0 ( const 1) Polytypic reduction satisfies a fusion law analogous to the fusion law for catamorphisms [11] h ffi ....
....t t and out : t t 0 t we can now define catahti : t 0 a a) t a) catahti = ffi mapht 0 i (catahti ) ffi out anahti : a t 0 a) a t) anahti = in ffi mapht 0 i (anahti ) ffi : Directions for future work suggest themselves. In the full version of this paper [6] we show how to generalize the technique to n ary functors. The full paper also contains additional examples, among others the definition of polytypic equality. It remains to broaden the approach to include exponentials and higher order polymorphism [10] The former extension should be fairly ....
Ralf Hinze. Polytypic functions over nested datatypes. Technical Report IAI-TR98 -10, Institut fur Informatik III, Universitat Bonn, October 1998.
No context found.
Hinze, Ralf. 1999b (March). Polytypic functions over nested datatypes (extended abstract) . 3rd latin-american conference on functional programming (CLaPF'99).
No context found.
Hinze, Ralf. (1999d). Polytypic functions over nested datatypes. Discrete mathematics and theoretical computer science. Accepted for publication.
Online articles have much greater impact More about CiteSeer.IST Add search form to your site Submit documents Feedback
CiteSeer.IST - Copyright Penn State and NEC