Skip to content

Instantly share code, notes, and snippets.

@okram
Created February 24, 2020 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okram/afc4fc1a1b06e2b0d707f2423881863a to your computer and use it in GitHub Desktop.
Save okram/afc4fc1a1b06e2b0d707f2423881863a to your computer and use it in GitHub Desktop.

I realized the difference between a RecType and a RecValue.

A RecType is written:

[a->b|c->d]

A RecValue is written:

[a:b,c:d]

RecTypes key/values are computed (types). RecValues key/values are retrieved (values).


Assume following two recs:

[[is>5]  : 'big' , int  : 'small']  // value
[[is>5] -> 'big' | int -> 'small']  // type

RECTYPES

33 => [[is>5]  -> 'big' , int  -> 'small']
33 => str<=int[int{?}<=int[is,bool<=int[gt,5]]->'big'|int->'small']
           33         
                        33          
                                     33
                               true
                33  
                                              33
                                                'big'
     'big'

Thus,

mmlang> 33 => [[is>5]  -> 'big' | int  -> 'small']
==>'big'
mmlang> [[is>5]  -> 'big' | int  -> 'small'][get,33]
==>'big'
mmlang> [[is>5]  -> 'big' | int  -> 'small'][get,1]
==>'small'
mmlang> [[is>5]  -> 'big' | int  -> 'small'][get,'hello']
==>Error: No key has a domain of 'hello'

The empty rec type: [->]

RECVALUES

[[is>5]  : 'big' , int  : 'small'] => [get,33]
==>Error: No key has a value 33
[[is>5]  : 'big' , int  : 'small'] => [get,int]
==>'small'

The empty rec value: [:]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment