项目作者: kubaPod

项目描述 :
Control flow utilities
高级语言: Mathematica
项目地址: git://github.com/kubaPod/Meh.git
创建时间: 2018-07-04T10:55:21Z
项目社区:https://github.com/kubaPod/Meh

开源协议:

下载


Meh

Control flow utilities.

It happens that for more complicated or interactive applications solutions offered by native Messages and related functions are not enough.
There was an attempt to address this problem by developers of GeneralUtilities` but it is still undocumented and not polished.

This package is meant to provide solutions for easier exceptions handling and keep it idiomatic/ natural to regular WL experience.

It also comes with few minor utilities that I found to be used by me quite frequently.

It is still under development, there is a brief documentation in WIKI

Installation

Manual

Go to ‘releases’ tab and download appropriate .paclet file.

Run PacletInstall @ path/to/the.paclet file

Via MPM`

If you don’t have MPM` yet, run:

  1. Import["https://raw.githubusercontent.com/kubapod/mpm/master/install.m"]

and then:

  1. Needs @ "MPM`"
  2. MPM`MPMInstall["kubapod", "meh"]

Usage teaser

  1. MCatch[
  2. MThrowAll["500", General::appname, "1asd"]
  3. ]

General::appname: The name 1asd is not valid for the application. A valid name starts with a letter and is followed by letters and digits.

  1. Failure["500", <| "MessageTemplate" :> General::appname, "MessageParameters" -> {"1asd"}]]
  1. foo // ClearAll
  2. $fooPatt = KeyValuePattern[{"a" -> _Integer, "c" -> _String}];
  3. foo // MValidateByDefault[ $fooPatt ]
  4. foo[ in: $fooPatt]:= in["a"]
  5. foo @ <|"a" -> 1, "c" -> "c"|>
  6. foo @ <|"b" -> 1, "c" -> {1}|>

1

foo::InvalidArg: Argument No. 1 has invalid structure at:

{Key[c]} List

{Key[a]} Missing[]

It needs to match:

<|a -> _Integer, c -> _String|>

Failure[...]