-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sum types with aliases #33
Comments
I'm not sure if this is possible. These checks are done at macro-expansion time, how would we handle
Various languages offer a function for type-aliasing. Maybe we'd need something like:
Could you provide an example/a rationale why this currently is a burden for code reuse/abstraction? |
Your "ELM-style" architecture in the Siemens-Client requires a page package to provide a State type, and I wanted to define two almost identical pages by specializing an "abstract page" - delegating what the State type actually is to that package. Can be worked around to some extent by defining both concrete pages in the same namespace. |
More detailed example: (ns utility)
(rec/define-record-type T {:rtd-record? true} (make-t) t? [])
(ns page-1
(:require [utility :as utility)
(def T utility/T)
(ns home-page
(:require [page-1 :as page-1]))
(st/define-sum-type State s? [page-1/T]) I wanted to keep the use of the 'utility' module an implementation detail of module 'page-1'. |
With this example, I can see why it would be useful. However, we have to introduce a specific macro for that, this cannot be achieved by |
We also have to implement that type-alias operation for records. |
Defining sum types does not work when aliasing types or predicates in match expressions, in ClojureScript at least:
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.
The text was updated successfully, but these errors were encountered: