GithubHelp home page GithubHelp logo

setzer22 / malli-instrument Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 3.0 28 KB

Instrumentation for malli mimicking the clojure.spec.alpha API

License: Eclipse Public License 2.0

Emacs Lisp 13.80% Clojure 86.20%

malli-instrument's Introduction

malli-instrument

This repository implements instrumentation for malli with a very similar API to clojure.spec.alpha's instrumentation.

Rationale

Malli is awesome, but instrumentation doesn't seem to be implemented yet, so I scratched my own itch. There are libraries like aave offering similar features on top of malli. However, to the best of my knowledge this is the only library that uses the same instrumentation API as clojure.spec.alpha, where instrumentation occurs in a dedicated command, and with no special defn wrappers.

Tool maturity

This library is in a very early stage. It works but is not yet intended for production use. Please feel free to suggest new features or report any bugs in the issue tracker.

Installation

Using deps.edn and git dependencies:

{setzer22/malli-instrument {:git/url "https://github.com/setzer22/malli-instrument.git" :sha "<latest master branch sha>"}}

Being in a very early stage, this library is not published in any maven repository, so other forms of distribution are currently unsupported.

Usage example

(require '[malli.core :as m])
(require '[malli-instrument.core :as mi])

(m/=> foo [:=> [:cat int? int?] string?])
(defn foo [x, y]
  (+ x y))
  
(mi/instrument-all!)

(foo 1 2) ;; Throws ex-info with message "Function returned wrong output"
          ;; and data {:error ["should be a string"], :value 3}

Integration with existing tooling

Spacemacs

Currently, this library offers limited support for emacs (more specifically Spacemacs). This enables the following features:

  • Dedicated commands in clojure-mode: , e k (instrument all functions) and , e K (unstrument all functions)
  • Reloading all instrumentations on buffer reload with , e b (i.e. cider-eval-buffer)

To enable this configuration, copy the contents of spacemacs-setup.el in your .spacemacs' dotspacemacs/user-config function, or any other equivalent initialization code.

malli-instrument's People

Contributors

setzer22 avatar yvern avatar

Stargazers

Tsunemichi Harada avatar Tom H. avatar Rayat Rahman avatar Justin Roche avatar Amar Sood avatar  avatar Daniel Schleindlsperger avatar Lauri Oherd avatar Will Acton avatar Tommi Reiman avatar  avatar

Watchers

 avatar  avatar

Forkers

yvern lsenjov viebel

malli-instrument's Issues

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.