packages feed

egison 3.2.5 → 3.2.6

raw patch · 6 files changed

+50/−25 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Language.Egison.Types: fromRationalValue :: WHNFData -> Either EgisonError Rational

Files

egison.cabal view
@@ -1,5 +1,5 @@ Name:                egison-Version:             3.2.5+Version:             3.2.6 Synopsis:            Programming language with non-linear pattern-matching against unfree data types Description:         An interpreter for Egison, the programming langugage that realized non-linear pattern-matching with unfree data types.                      With Egison, you can represent pattern-matching with unfree data types intuitively,
hs-src/Language/Egison/Primitives.hs view
@@ -124,6 +124,7 @@              , ("ceiling",  floatToIntegerOp ceiling)              , ("truncate", floatToIntegerOp truncate)              , ("itof", integerToFloat)+             , ("rtof", rationalToFloat)              , ("eq?",  eq)              , ("lt?",  lt)              , ("lte?", lte)@@ -173,6 +174,10 @@ integerToFloat = (liftError .) $ oneArg $ \val ->   Float . fromInteger <$> fromIntegerValue val +rationalToFloat :: PrimitiveFunc+rationalToFloat = (liftError .) $ oneArg $ \val ->+  Float . fromRational <$> fromRationalValue val+ eq :: PrimitiveFunc eq = (liftError .) $ twoArgs $ \val val' ->   (Bool .) . (==) <$> fromPrimitiveValue val@@ -286,8 +291,12 @@       if denominator y == 1         then return $ Integer $ numerator y         else return $ Rational y-  divide' (Value (Rational _)) val = throwError $ TypeMismatch "rational number" val-  divide' val _ = throwError $ TypeMismatch "rational number" val+  divide' (Value (Rational x)) (Value (Float f)) = return $ Float $ (fromRational x) / f+  divide' (Value (Float f)) (Value (Rational x)) = return $ Float $ f / (fromRational x)+  divide' (Value (Rational _)) val = throwError $ TypeMismatch "number" val+  divide' (Value (Float f)) (Value (Float f')) = return $ Float $ f / f'+  divide' (Value (Float _)) val = throwError $ TypeMismatch "number" val+  divide' val _ = throwError $ TypeMismatch "number" val   stringAppend :: PrimitiveFunc@@ -339,8 +348,6 @@                , ("eof-port?", isEOFPort) --             , ("print-to-port", writeStringLineToPort)                , ("flush-port", flushPort) ---               , ("rand", rand)---               , ("rand-range", randRange) ]                , ("rand", randRange) ]                  --             , ("get-lib-dir-name", getLibDirName) ] 
hs-src/Language/Egison/Types.hs view
@@ -278,6 +278,10 @@ fromBoolValue (Value (Bool b)) = return b fromBoolValue val = throwError $ TypeMismatch "bool" val +fromRationalValue :: WHNFData -> Either EgisonError Rational+fromRationalValue (Value (Rational x)) = return x+fromRationalValue val = throwError $ TypeMismatch "rational" val+ fromIntegerValue :: WHNFData -> Either EgisonError Integer fromIntegerValue (Value (Integer i)) = return i fromIntegerValue val = throwError $ TypeMismatch "integer" val
lib/core/collection.egi view
@@ -43,15 +43,18 @@  (define $between   (lambda [$s $e]-    (if (gt-i? s e)+    (if (gt-i? (+ s 10) e)+      (if (gt-i? s e)         {}-        {s @(between (+ s 1) e)})))+        {s @(between (+ s 1) e)})+      {s (+ s 1) (+ s 2) (+ s 3) (+ s 4) (+ s 5) (+ s 6) (+ s 7) (+ s 8) (+ s 9) (+ s 10) @(between (+ s 11) e)})+    ))  (define $map-  (lambda [$fn $ls]-    (match ls (list something)+  (lambda [$fn $xs]+    (match xs (list something)       {[<nil> {}]-       [<cons $x $xs> {(fn x) @(map fn xs)}]})))+       [<cons $x $rs> {(fn x) @(map fn rs)}]})))  (define $concat   (lambda [$xss]@@ -73,13 +76,13 @@                         (foldl fn y xs))]})))  (define $filter-  (lambda [$pred $ls]-    (match ls (list something)+  (lambda [$pred $xs]+    (match xs (list something)       {[<nil> {}]-       [<cons $x $xs>+       [<cons $x $rs>         (if (pred x)-            {x @(filter pred xs)}-            (filter pred xs))]})))+            {x @(filter pred rs)}+            (filter pred rs))]})))  (define $split   (lambda [$pred $ls]@@ -179,6 +182,12 @@           <cons $x _>)         x]}))) +(define $take-and-drop+  (lambda [$n $xs]+    (match xs (list something)+      {[(loop $i [1 ,n] <cons $a_i ...> $rs)+        [(map (lambda [$i] a_i) (between 1 n)) rs]]})))+ (define $take   (lambda [$n $xs]     (if (eq? n 0)@@ -187,6 +196,14 @@           {[<cons $x $xs> {x @(take (- n 1) xs)}]            [<nil> {}]})))) +(define $drop+  (lambda [$n $xs]+    (if (eq? n 0)+        xs+        (match xs (list something)+          {[<cons _ $xs> (drop (- n 1) xs)]+           [<nil> {}]}))))+ (define $while   (lambda [$pred $xs]     (match xs (list something)@@ -195,14 +212,6 @@         (if (pred x)             {x @(while pred rs)}             {})]})))--(define $drop-  (lambda [$n $xs]-    (if (eq? n 0)-        xs-        (match xs (list something)-          {[<cons _ $xs> (drop (- n 1) xs)]-           [<nil> {}]}))))  (define $reverse   (lambda [$xs]
lib/core/natural-number.egi view
@@ -53,9 +53,9 @@ ;;; ;;; Number Collections ;;;-(define $nats {1 @(map (+ 1 $) nats)})+(define $nats {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 @(map (+ 100 $) nats)}) -(define $nats0 {0 @(map (+ 1 $) nats0)})+(define $nats0 {0 @nats})  (define $primes   (letrec {[$next-primes
lib/core/number.egi view
@@ -68,6 +68,11 @@                   {[<greater> [min-n n]]                    [_ [min-n max-n]]})]}))]}))) +(define $power+  (lambda [$x $n]+    (letrec {[$xs {x @xs}]}+      (foldl * 1 (take n xs)))))+ (define $mod   (lambda [$m]     (matcher