~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to test/succeed/Rose.agda

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-08-05 06:38:12 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140805063812-io8e77niomivhd49
Tags: 2.4.0.2-1
* [6e140ac] Imported Upstream version 2.4.0.2
* [2049fc8] Update Build-Depends to match control
* [93dc4d4] Install the new primitives
* [e48f40f] Fix typo dev→doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{-# OPTIONS --sized-types #-}
2
 
 
3
 
module Rose where
4
 
 
5
 
postulate
6
 
  Size : Set
7
 
  _^   : Size -> Size
8
 
  ∞    : Size
9
 
 
10
 
{-# BUILTIN SIZE Size  #-}
11
 
{-# BUILTIN SIZESUC _^ #-}
12
 
{-# BUILTIN SIZEINF ∞  #-}
13
 
 
14
 
data List (A : Set) : {_ : Size} -> Set where
15
 
  []   : {size : Size} -> List A {size ^}
16
 
  _::_ : {size : Size} -> A -> List A {size} -> List A {size ^}
17
 
 
18
 
map : {A B : Set} -> (A -> B) -> 
19
 
      {size : Size} -> List A {size} -> List B {size}
20
 
map f [] = []
21
 
map f (x :: xs) = f x :: map f xs
22
 
 
23
 
data Rose (A : Set) : {_ : Size} -> Set where
24
 
  rose : {size : Size} -> A -> List (Rose A {size}) {∞} -> Rose A {size ^}
25
 
 
26
 
{-
27
 
mapRose : {A B : Set} -> (A -> B) -> 
28
 
          {size : Size} -> Rose A {size} -> Rose B {size}
29
 
mapRose {A} {B} f .{size ^} (rose {size} a l) =
30
 
   rose (f a) (map (\ r -> mapRose {A} {B} f {size} r) l)
31
 
-}
32
 
 
33
 
mapRose : {A B : Set} -> (A -> B) -> 
34
 
          {size : Size} -> Rose A {size} -> Rose B {size}
35
 
mapRose f (rose a l) = rose (f a) (map (mapRose f) l)
36