Giter Club home page Giter Club logo

subtypes.jl's Introduction

SubTypes.jl

Stable Docs Latest Docs Travis Build Status Appveyor Build status Formatting

DOI

Custom Subtyping in Julia

Installation

To install, run the following in a Julia session:

]add SubTypes

Custom Subtype

To create a custom subtype define the following data

SubType{T, P, Ctx}
        ^  ^  ^
        |  |  |
        |  |  L ______ Type Context
        |  L _________ Predicate Data
        L ____________ Underlying Type

and a predicate processing function

check_predicate(P, Val(Ctx), x::T)

which checks if x::T should be of type SubType{T, P, Ctx}. The context Ctx is the way to mark the subtypes for overloading.

Predefined Custom Subtypes

The custom subtypes Constrained and ConstrainedSymbol are predefined in the SubType module. They emulate set inclusion subtyping, i.e.

x::Constrained{T, S}  <=>  x.value::T in S

The ConstrainedSymbol type emulates set inclusion for Symbol types. The Constrained type is defined as follows:

const Constrained{T,S} = SubType{T,S,:Constrained}

Inspiration for this type comes from this post by Mohamed Tarek @mohamed82008.

Helper Functions

This module also comes with these helper functions defined for terms and types:

Helper Function Component Description
eltype SubType{T} => T The underlying type where the subtype terms are drawn from.
predicate SubType{T,P} => P The predicate data which determines the subtype terms.
context SubType{T,P,Ctx} => Ctx The implementation label for the check_predicate function.
support Constrained{T,S} => S The underlying set where the constrained variables are constrained to.

Author License GitHub Repo

subtypes.jl's People

Contributors

juliatagbot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.