All Projects → FrankBro → ordo

FrankBro / ordo

Licence: other
Ordo: A minimalist language with row polymorphism

Programming Languages

F#
602 projects

Projects that are alternatives of or similar to ordo

indigo
Indigo: SNV and InDel Discovery in Chromatogram traces obtained from Sanger sequencing of PCR products
Stars: ✭ 26 (-48%)
Mutual labels:  variants
pepper
PEPPER-Margin-DeepVariant
Stars: ✭ 179 (+258%)
Mutual labels:  variants
VariantRetriever
VariantRetriever is a minimalist package for feature flagging
Stars: ✭ 23 (-54%)
Mutual labels:  variants
record-builder
Record builder generator for Java records
Stars: ✭ 426 (+752%)
Mutual labels:  records
pulsar-core
🚀 Handy dynamic styles utilities for React Native and React Native Web.
Stars: ✭ 27 (-46%)
Mutual labels:  variants
civic-server
Backend Server for CIViC Project
Stars: ✭ 39 (-22%)
Mutual labels:  variants
awesome-csv
Awesome Comma-Separated Values (CSV) - What's Next? - Frequently Asked Questions (F.A.Q.s) - Libraries & Tools
Stars: ✭ 46 (-8%)
Mutual labels:  records
ftor
ftor enables ML-like type-directed, functional programming with Javascript including reasonable debugging.
Stars: ✭ 44 (-12%)
Mutual labels:  row-polymorphism
Harbol
Harbol is a collection of data structure and miscellaneous libraries, similar in nature to C++'s Boost, STL, and GNOME's GLib
Stars: ✭ 18 (-64%)
Mutual labels:  variants
jrec
Literally the best anonymous records
Stars: ✭ 31 (-38%)
Mutual labels:  records
styled-variants
A scalable styled-component theming system that fully leverages JavaScript as a language for styles authoring and theming at both local and global levels.
Stars: ✭ 19 (-62%)
Mutual labels:  variants
recursive-variant
Recursive Variant: A simple library for Recursive Variant Types
Stars: ✭ 67 (+34%)
Mutual labels:  variants
vcf stuff
📊Evaluating, filtering, comparing, and visualising VCF
Stars: ✭ 19 (-62%)
Mutual labels:  variants
HLA
xHLA: Fast and accurate HLA typing from short read sequence data
Stars: ✭ 84 (+68%)
Mutual labels:  variants
rec-core
Data pipelining service
Stars: ✭ 19 (-62%)
Mutual labels:  records
Language Ext
C# functional language extensions - a base class library for functional programming
Stars: ✭ 3,964 (+7828%)
Mutual labels:  records
CuteVCF
simple viewer for variant call format using htslib
Stars: ✭ 30 (-40%)
Mutual labels:  variants
records-migrate
A migration system for Records.
Stars: ✭ 30 (-40%)
Mutual labels:  records
phenomenet-vp
A phenotype-based tool for variant prioritization in WES and WGS data
Stars: ✭ 31 (-38%)
Mutual labels:  variants
needlestack
Multi-sample somatic variant caller
Stars: ✭ 45 (-10%)
Mutual labels:  variants

Ordo

Latin : ordo

English : a methodical series, arrangement, or order; regular line, row, or series

Introduction

Ordo is a minimal statically-typed functional programming language with a ml-like syntax and focused around row polymorphism.

Row polymorphism focuses around allowing you to compose simple types to create more complex types: mainly records and variants.

Where in most ml-languages, you need to pre-define your records and variants, in ordo, they will be infered.

For records:

ordo>>> let record = { x = 1, y = 2 }
{ x : 1, y : 2 }
ordo>>> :type record
{x : int, y : int}

For variants:

ordo>>> let variant = :variant 1
:variant 1
ordo>>> :type variant
forall r. (r\variant) => <variant : int | r>

The extra syntax at the end of the variant means it is an open variant. Rows (record or variants) can be open or closed. By default, record literals are closed but variant literals are open. Rows also infer their restrictions. While the signature can be fairly hard to read at first, here is the meaning of it:

forall r. (r\variant) => <variant : int | r>

Here, forall signifies that generic types will be given next. We might also have a portion between parenthesis, indicating row restrictions. In this case, for a generic type r, which we know is a row because it's followed by the restriction that this row should not have the value variant. Next we finally have the actual type of our expression, we know it's a variant because it's surrounded by < >, whereas records are surrounded by { }. The type of the expression is a variant that extends the generic row r by having a new case that is specified: variant of type int.

Record

The few new expressions introduced for records:

  • Record initialization
ordo>>> {}
{  }
  • Record extension adds fields to the record
ordo>>> { x = 1 | {} }
{ x : 1 }
  • Record initialization, being sugar for record extension
ordo>>> { x = 1 } = { x = 1 | {} }
True
  • The order of insertion of labels is not important
ordo>>> { x = 1, y = 2 } = { y = 2, x = 1 }
True
  • Record restriction removes fields from a record
ordo>>> { x = 1 }\x = {}
True
  • Record cannot have the same label twice
ordo>>> { x = 1, x = 2 }
Error: OrdoException (Infer (RowConstraintFail "x"))

In fact, we can see this property being infered by the type system and shown:

ordo>>> let f r = { y = 0 | r }
<Lambda>
ordo>>> f { x = 0 }
{ x : 0, y : 0 }
ordo>>> :type f
forall r. (r\y) => {r} -> {y : int | r}

The signature here specifies that the function takes a row that does not contain the field y. If you provide a record with the field y already it in, the type inference won't let you.

ordo>>> f { y = 1 }
Error: OrdoException (Infer (RowConstraintFail "y"))
  • Structual pattern matching and even make sure it is valid via type checking:
ordo>>> let { x = x } = { x = 1 }
{ x : 1 }
ordo>>> x
1
ordo>>> let { y = y } = { x = 1 }
Error: OrdoException (Generic (FieldNotFound "y"))
  • Record matching is open

While record literals are closed rows, record matching is open:

ordo>>> let record = { x = 0 }
{ x : 0 }
ordo>>> :type record
{x : int}
ordo>>> let f { x = x } = x
<Lambda>
ordo>>> :type f
forall a r. (r\x) => {x : a | r} -> a
  • Sugar for matching and creation

Records can either directly assign fields to variables in a shorthand syntax or capture variables via closure and set them automatically to their variable name as label:

ordo>>> let f {x,y} = x + y
<Lambda>
ordo>>> let x = 1
1
ordo>>> let y = 2
2
ordo>>> f {x,y}
3
ordo>>> :type f
forall a r. (r\x\y) => {x : a, y : a | r} -> a

Variant

The few new expressions introduced for variants:

  • Variant creation
ordo>>> let variant = :variant 1
:variant 1
  • Variant elimination

Variant can be eliminated via pattern matching. While variant literals are open rows, we can deduce if the input if open on closed based on the fact that a default case is provided or not.

ordo>>> let defaultwith default value = match value { :some value -> value, :none {} -> default }
<Lambda>
ordo>>> :type defaultwith
forall a => a -> <none : {}, some : a> -> a

In this case, we did not provide a default case and therefore, the variant was infered to be closed. However, if we wrote it this way:

ordo>>> let issuccess v = match v { :success a -> true | otherwise -> false }
<Lambda>
ordo>>> :type issuccess
forall a r. (r\success) => <success : a | r> -> bool

This is useful to make sure which variant can be passed in.

ordo>>> issuccess (:fail 0)
False
ordo>>> defaultwith 1 (:fail 0)
Error: OrdoException
  (Infer
     (UnifyFail
        (TRowEmpty,
         TRowExtend
           ("fail",TVar {contents = Link TInt;},
            TVar {contents = UnboundRow (34,0,set ["fail"]);}))))
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].