active-group / active-group/active-clojure

Sum types with aliases

Open
#33 5 comments 0 reactions 1 assignee Claimed by @smoes View on GitHub
enhancement
Dominant language
Clojure
Stars
31
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Defining sum types does not work when aliasing types or predicates in match expressions, in ClojureScript at least:

```
(require '[active.clojure.sum-type :as st :include-macros true])
(require '[active.clojure.cljs.record :as rec :include-macros true])

(rec/define-record-type T {:rtd-record? true} (make-t) t? [])
(st/define-sum-type S1 s? [T])
(def S2 S1)
(st/define-sum-type S2 s? [T])
(def T2 T)
(st/define-sum-type S2 s? [T2])

Compile Exception: rtd-record or sum-type required, found: T2
```

A similar error is raised when using an alias of `t?` in a match expression.

This is quite a burden for code reuse/abstraction, and should be fixed if possible.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.