Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Recursively dependent types
(ns sprang
(:require [clojure.core.typed :refer :all]))
(declare-protocols IValidator)
(ann-record ValidationError [validator :- IValidator
value :- Any])
(defrecord ValidationError [validator value])
; TODO: Figure out how to make occurrence typing type :errors
(ann-record ValidationResult
[status :- (U ':ok ':error)
result :- Any
errors :- (U nil (ISeq ValidationError))
input :- Any])
(defrecord ValidationResult [status result errors input])
(ann-protocol IValidator
validate- [IValidator Any -> ValidationResult])
(defprotocol> IValidator
"Validator abstraction"
(validate- [this value] "Evaluates the validator."))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.