packages feed

kempe 0.2.0.5 → 0.2.0.6

raw patch · 10 files changed

+48/−16 lines, 10 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # kempe +## 0.2.0.6++  * Add `absInt` and `chocie` functions to prelude.+  * Add lints for `swap >`, `swap *` &c.+  * Fix bug in typing `>=`, `>`, `!=`+   ## 0.2.0.5    * Fix bug in arm control-flow analysis
kempe.cabal view
@@ -1,6 +1,6 @@ cabal-version:   3.0 name:            kempe-version:         0.2.0.5+version:         0.2.0.6 license:         BSD-3-Clause license-file:    LICENSE copyright:       Copyright: (c) 2020-2021 Vanessa McHale
prelude/arith.kmp view
@@ -10,6 +10,11 @@ isZeroInt : Int -- Bool           =: [ 0 = ] +absInt : Int -- Int+       =: [ dup 0 <+            if (~ ,)+          ]+ ; More from Mirth maxInt : Int Int -- Int        =: [ dup2 < if(nip, drop) ]
prelude/fn.kmp view
@@ -32,3 +32,10 @@  drop3 : a b c --       =: [ drop drop drop ]++; from Joy+choice : a a Bool -- a+       =: [ if( drop+              , nip+              )+          ]
src/Kempe/Check/Lint.hs view
@@ -17,6 +17,21 @@ lintDecl (FunDecl _ _ _ _ as) = lintAtoms as  lintAtoms :: [Atom b b] -> Maybe (Warning b)-lintAtoms []                       = Nothing-lintAtoms (a@(Dip l _):a'@Dip{}:_) = Just (DoubleDip l a a')-lintAtoms (_:as)                   = lintAtoms as+lintAtoms []                                                = Nothing+lintAtoms (a@(Dip l _):a'@Dip{}:_)                          = Just (DoubleDip l a a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ IntEq):_)     = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ IntNeq):_)    = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ And):_)       = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ Or):_)        = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ Xor):_)       = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ WordXor):_)   = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ IntTimes):_)  = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ IntPlus):_)   = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ WordPlus):_)  = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ WordTimes):_) = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin _ IntXor):_)    = Just (SwapBinary l a' a')+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin l' IntGt):_)    = Just (SwapBinary l a' (AtBuiltin l' IntLt))+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin l' IntGeq):_)   = Just (SwapBinary l a' (AtBuiltin l' IntLeq))+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin l' IntLt):_)    = Just (SwapBinary l a' (AtBuiltin l' IntGt))+lintAtoms ((AtBuiltin l Swap):a'@(AtBuiltin l' IntLeq):_)   = Just (SwapBinary l a' (AtBuiltin l' IntGeq))+lintAtoms (_:as)                                            = lintAtoms as
src/Kempe/Error/Warning.hs view
@@ -8,14 +8,16 @@ import           Data.Typeable     (Typeable) import           Kempe.AST import           Kempe.Name-import           Prettyprinter     (Pretty (pretty), (<+>))+import           Prettyprinter     (Pretty (pretty), squotes, (<+>))  data Warning a = NameClash a (Name a)                | DoubleDip a (Atom a a) (Atom a a)+               | SwapBinary a (Atom a a) (Atom a a)  instance Pretty a => Pretty (Warning a) where-    pretty (NameClash l x)    = pretty l <> " '" <> pretty x <> "' is defined more than once."-    pretty (DoubleDip l a a') = pretty l <+> pretty a <+> pretty a' <+> "could be written as a single dip()"+    pretty (NameClash l x)     = pretty l <> " '" <> pretty x <> "' is defined more than once."+    pretty (DoubleDip l a a')  = pretty l <+> pretty a <+> pretty a' <+> "could be written as a single dip()"+    pretty (SwapBinary l a a') = pretty l <+> squotes ("swap" <+> pretty a) <+> "is" <+> pretty a'  instance (Pretty a) => Show (Warning a) where     show = show . pretty
src/Kempe/TyAssign.hs view
@@ -175,9 +175,9 @@ typeOfBuiltin WordTimes  = pure wordBinOp typeOfBuiltin WordShiftR = pure wordShift typeOfBuiltin WordShiftL = pure wordShift-typeOfBuiltin IntGeq     = pure intBinOp-typeOfBuiltin IntNeq     = pure intBinOp-typeOfBuiltin IntGt      = pure intBinOp+typeOfBuiltin IntGeq     = pure intRel+typeOfBuiltin IntNeq     = pure intRel+typeOfBuiltin IntGt      = pure intRel typeOfBuiltin WordMinus  = pure wordBinOp typeOfBuiltin WordDiv    = pure wordBinOp typeOfBuiltin WordMod    = pure wordBinOp@@ -492,7 +492,7 @@ tyPattern :: Pattern b a -> TypeM () (StackType ()) tyPattern PatternWildcard{} = do     aN <- dummyName "a"-    pure $ StackType (S.singleton aN) [TyVar () aN] [] -- FIXME: this is wrong for constructors, could be a -- b c (for instance)+    pure $ StackType (S.singleton aN) [TyVar () aN] [] tyPattern PatternInt{} = pure $ StackType S.empty [TyBuiltin () TyInt] [] tyPattern PatternBool{} = pure $ StackType S.empty [TyBuiltin () TyBool] [] tyPattern (PatternCons _ tn) = renameStack . flipStackType =<< consLookup (void tn)
test/Type.hs view
@@ -27,7 +27,6 @@         , tyInfer "lib/gaussian.kmp"         , tyInfer "test/data/transitive.kmp"         , tyInfer "lib/tuple.kmp"-        , tyInfer "test/data/type.kmp"         , badType "test/err/merge.kmp" "Type a_5 -- Int a_4 is not as general as type a_3 -- a_3 a_3"         , badType "test/err/kind.kmp" "Ill-kinded type: '(Maybe_1 Maybe_1)'. Note that type variables have kind \11089 in Kempe."         , badType "test/err/patternMatch.kmp" "Inexhaustive pattern match."
− test/data/type.kmp
@@ -1,4 +0,0 @@-import"lib/maybe.kmp"--id1 : Int -- Int-     =: [ Just {case | Nothing -> 0 | _ ->} ]
+ test/err/swapBinOp.kmp view
@@ -0,0 +1,2 @@+lte : Int Int -- Bool+    =: [ swap > ]