packages feed

sugar-scheme (empty) → 0.0.0

raw patch · 6 files changed

+132/−0 lines, 6 filesdep +basedep +containersdep +husk-scheme

Dependencies added: base, containers, husk-scheme, parsec, sugar, tasty, tasty-hspec, text

Files

+ CHANGELOG.md view
@@ -0,0 +1,7 @@+# Change log++sugar uses [Semantic Versioning][].+The change log is available through the [releases on GitHub][].++[Semantic Versioning]: http://semver.org/spec/v2.0.0.html+[releases on GitHub]: https://github.com/jxv/sugar/releases
+ LICENSE view
@@ -0,0 +1,29 @@+BSD 3-Clause License++Copyright (c) 2022, Joe Vargas+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++* Redistributions of source code must retain the above copyright notice, this+  list of conditions and the following disclaimer.++* Redistributions in binary form must reproduce the above copyright notice,+  this list of conditions and the following disclaimer in the documentation+  and/or other materials provided with the distribution.++* Neither the name of the copyright holder nor the names of its+  contributors may be used to endorse or promote products derived from+  this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
+ src/Sugar/Scheme.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE OverloadedStrings #-}+module Sugar.Scheme where+  +import Sugar+import Language.Scheme.Types+import Language.Scheme.Parser+import Data.Text (unpack)+import qualified Data.Map as Map+import qualified Text.Parsec.Token as P+import Text.ParserCombinators.Parsec+import Text.Parsec.Language ()+++toLispVal :: Sugar -> LispVal+toLispVal (Sugar'Unit _) = List [] -- TODO: should this be 'nil'?+toLispVal (Sugar'Text txt _) =  case parse valParser "valParser" (unpack txt) of+  Left _ -> String (unpack txt)+  Right v -> v+  where+    lexeme = P.lexeme lexer+    lexer = P.makeTokenParser lispDef+    valParser =+          try (lexeme parseComplexNumber)+      <|> try (lexeme parseRationalNumber)+      <|> try (lexeme parseRealNumber)+      <|> try (lexeme parseNumber)+      <|> try parseAtom+      <|> lexeme parseString+      <|> lexeme parseBool+      <|> parseQuoted+      <|> parseQuasiQuoted+      <|> parseUnquoted+toLispVal (Sugar'List ls _ _) = List (map toLispVal ls)+toLispVal (Sugar'Map m _) = HashTable $ Map.fromList $ map (\(x,y) -> (toLispVal x, toLispVal y)) m
+ sugar-scheme.cabal view
@@ -0,0 +1,50 @@+name: sugar-scheme+version: 0.0.0+synopsis: Sugar with Scheme+homepage: https://github.com/jxv/sugar#readme+description: Please see the README on GitHub at <https://github.com/jxv/sugar#readme>+category: Text, Language+bug-reports: https://github.com/jxv/sugar/issues+author: Joe Vargas+maintainer: Joe Vargas+license: MIT+license-file: LICENSE+build-type: Simple+cabal-version: 1.14+extra-source-files:+    CHANGELOG.md+    LICENSE+    README.md++source-repository head+  type: git+  location: https://github.com/jxv/sugar++library+  exposed-modules:+      Sugar.Scheme+  hs-source-dirs:+      src+  default-extensions:+  ghc-options: -Wall+  build-depends:+      base >=4.7 && <5+    , containers+    , husk-scheme+    , parsec+    , sugar == 0.0.0+    , text+  default-language: Haskell2010++test-suite sugar-scheme-test-suite+  type: exitcode-stdio-1.0+  main-is: Main.hs+  hs-source-dirs:+      test-suite+  ghc-options: -Wall -rtsopts -threaded -with-rtsopts=-N+  build-depends:+      base+    , sugar+    , tasty+    , tasty-hspec+  default-language: Haskell2010
+ test-suite/Main.hs view
@@ -0,0 +1,12 @@+import qualified Test.Tasty+import Test.Tasty.Hspec++main :: IO ()+main = do+    test <- testSpec "sugar" spec+    Test.Tasty.defaultMain test++spec :: Spec+spec = parallel $ do+    it "is trivially true" $ do+        True `shouldBe` True