# Fighting with racket type-system & match

**URL:** <https://racket.discourse.group/t/fighting-with-racket-type-system-match/1669>\
**Category:** General\
**Created:** [January 28, 2023, 8:50am UTC](https://racket.discourse.group/t/fighting-with-racket-type-system-match/1669 "2023-01-28T08:50:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![devosalain](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/devosalain/32/546_2.png) [@devosalain](https://racket.discourse.group/u/devosalain)\
**Post date:** [January 28, 2023, 8:50am UTC](https://racket.discourse.group/t/fighting-with-racket-type-system-match/1669/1 "2023-01-28T08:50:36Z")

</div>

Following program defines 3 types and one function which tries to match the 3 types.  
The error given is : "match syntax error in pattern in : (stc x)  
Obvious question why ?

```scheme
#lang typed/racket
(require racket/match )
(define-struct dsa ([A : [U 'plus 'minus] ]))
(struct sb ([B : Number]))
(define-type stc (U dsa sb))

(define f1
  (lambda (x)
    (match (x)
      [(dsa A) 1]
      [(sb B) 2]
      [(stc x) 3]
      )
    )
  )

```

---

<div class="post-metadata">

**Author:** ![AlexKnauth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/alexknauth/32/242_2.png) [@AlexKnauth](https://racket.discourse.group/u/AlexKnauth)\
**Post date:** [January 28, 2023, 1:55pm UTC](https://racket.discourse.group/t/fighting-with-racket-type-system-match/1669/2 "2023-01-28T13:55:58Z")

</div>

The main issue is that `stc` is not a struct constructor, it's "just" a type. On the other hand, `dsa` and `sb` are both struct constructors _and_ types. They can be used at runtime like `(dsa 'plus)`, `(dsa 'minus)`, `(sb 0)`, and so on, but `stc` cannot be used like that.

Also, do you want `f1` to take an `stc`, or do you want it to take a function that produces an `stc`?
