Image Unit Processing Interface. INFO: This is a mirror from GitHub. github.com/sona-tau/iupi
at main 74 lines 2.1 kB view raw
1#lang plait 2 3;----- Language Types -----; 4; Language type 5(define-type Language 6 [binary-operation (op : BinaryOperation)] 7 [unary-operation (op : UnaryOperation)] 8 [lang-color (c : RGBColor)]) 9 10; General Expression type 11(define-type Expr 12 [operation (op : BinaryOperation)] 13 [color (c : RGBColor)]) 14 15; BinaryOperation type 16(define-type BinaryOperation 17 [add (color : RGBColor) (e : Expr)] 18 [subtract (color : RGBColor) (e : Expr)] 19 [multiply (color : RGBColor) (e : Expr)] 20 [divide (color : RGBColor) (e : Expr)] 21 [interpolate (color : RGBColor) (e : Expr) (percent : Float)] 22 [max (color : RGBColor) (e : Expr)] 23 [min (color : RGBColor) (e : Expr)]) 24 25; OperatorType type 26(define-type OperatorType 27 [floating-type (n : Float)] 28 [string-type (s : String)]) 29 30; UnaryOperation type 31(define-type UnaryOperation 32 [value-invert (l : Language)] 33 [linear-invert (l : Language)]) 34 35; Float type 36(define-type Float 37 [float (ds : Decimals)]) 38 39; Digits type 40(define-type Digits 41 [number (first : Digit) (rest : Digits)] 42 [empty-digit]) 43 44; Digit type 45(define-type Digit 46 [digit (n : Number)]) 47 48; Decimals type 49(define-type Decimals 50 [decimals (first : Digit) (rest : Decimals)] 51 [empty-decimal]) 52 53; RGBColor type 54(define-type RGBColor 55 [rgbcolor (red : Digits) (blue : Digits) (green : Digits)]) 56 57; HSVColor type 58(define-type HSVColor 59 [hsvcolor (hue : Number) (saturation : Number) (value : Number)]) 60 61;----- Parser Types -----; 62; This is simply a shorthand including either an (ok) variant, indicating that 63; something of type ('a) was parsed succesfully. The (err) variant indicates 64; that something of type ('a) could not be parsed. The pair inside the (ok) 65; variant includes ('a) the thing that was just parsed and a (String), the rest 66; of the source code that has not been consumed yet. 67(define-type (ParseResult 'a) 68 [ok (r : (String * 'a))] 69 [err]) 70 71; An alias for a parser type. A parser is a function that takes a (String) and 72; produces a (ParseResult) of ('a). 73(define-type-alias (Parser 'a) 74 (String -> (ParseResult 'a)))