From 36ad96d129b3ae46f745208d0070349035436cff Mon Sep 17 00:00:00 2001 From: Roman Galochkin Date: Fri, 21 Feb 2020 15:29:25 +0300 Subject: [PATCH] Step 2 --- src/utility/lib/CDFunctor.re | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utility/lib/CDFunctor.re b/src/utility/lib/CDFunctor.re index c6b823dd..6e1a3719 100644 --- a/src/utility/lib/CDFunctor.re +++ b/src/utility/lib/CDFunctor.re @@ -1,7 +1,15 @@ module type Config = {let shape: DistributionTypes.xyShape;}; +exception ShapeWrong(string); + module Make = (Config: Config) => { let validateHasLength = (): bool => Array.length(Config.shape.xs) > 0; let validateSize = (): bool => Array.length(Config.shape.xs) == Array.length(Config.shape.ys); + if (!validateHasLength()) { + raise(ShapeWrong("You need at least one element.")); + }; + if (!validateSize()) { + raise(ShapeWrong("Arrays of \"xs\" and \"ys\" have different sizes.")); + }; };