# How to write \`length\` in TypedRacket with inlined types?

**URL:** <https://racket.discourse.group/t/how-to-write-length-in-typedracket-with-inlined-types/1742>\
**Category:** Questions & Answers\
**Tags:** question, typed-racket\
**Created:** [February 27, 2023, 10:01pm UTC](https://racket.discourse.group/t/how-to-write-length-in-typedracket-with-inlined-types/1742 "2023-02-27T22:01:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AssertionError](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/assertionerror/32/1016_2.png) [@AssertionError](https://racket.discourse.group/u/AssertionError)\
**Post date:** [February 27, 2023, 10:01pm UTC](https://racket.discourse.group/t/how-to-write-length-in-typedracket-with-inlined-types/1742/1 "2023-02-27T22:01:43Z")

</div>

Hi everyone,

I am sorry for the newbie question. I'm wondering why TypedRacket complains about the following implementation of length

```scheme
#lang typed/racket

(define #:forall [T] (len [l : (Listof T)] ) : Number
  (match l
    [(list) 0]
    [(list _ l ...) (+ 1 (len l))] ; <--- error is here (line 6)
  )
)

```

Error:

```scheme
foo.rkt:6:26: Type Checker: missing type for identifier;
 consider adding a type annotation with `:'
  identifier: len
  in: len
  location...:
   foo.rkt:6:26
  context...:

```

What exactly is the type annotation that is missing? Isn't function `len` annotated with the return type?

FYI,

```scheme
$ racket --version
Welcome to Racket v8.2 [cs].

```

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [February 27, 2023, 10:20pm UTC](https://racket.discourse.group/t/how-to-write-length-in-typedracket-with-inlined-types/1742/2 "2023-02-27T22:20:30Z")

</div>

Strangely, adding this type annotation placates the type checker:

```scheme
(: len (∀ [T] (-> (Listof T) Number)))

```

I would have expected a type annotation as part of `define` to work the same way as providing the type annotation separately, so this seems like a bug to me. (@samth?)
