packages feed

brainheck 0.1.0.6 → 0.1.0.7

raw patch · 5 files changed

+105/−96 lines, 5 filesdep ~base

Dependency ranges changed: base

Files

app/Main.hs view
@@ -1,17 +1,16 @@ module Main where -import Brainheck-import Options.Applicative-import qualified Data.Text.IO as TIO-import Data.Monoid-import Data.Version-import Paths_brainheck+import           Brainheck+import qualified Data.Text.IO        as TIO+import           Data.Version+import           Options.Applicative+import           Paths_brainheck  program :: Parser FilePath program = argument str (metavar "FILE" <> help "Brainfuck file")  main :: IO ()-main = let runFile filepath = either (error . show) id . (parseBrainheck filepath) <$> TIO.readFile filepath >>= run in+main = let runFile filepath = either (error . show) id . parseBrainheck filepath <$> TIO.readFile filepath >>= run in     runFile =<< execParser (info (program <**> helper <**> versionInfo) (fullDesc         <> progDesc "Brainh*ck - an interpreter"         <> header "brainheck - a brainfuck intrepreter written in haskell and supporting utf-8"))
brainheck.cabal view
@@ -1,68 +1,99 @@-name:                brainheck-version:             0.1.0.6-synopsis:            Brainh*ck interpreter in haskell-description:         Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries-homepage:            https://github.com/vmchale/brainheck#readme-license:             BSD3-license-file:        LICENSE-author:              Vanessa McHale-maintainer:          tmchale@wisc.edu-copyright:           Copyright: (c) 2016-2017 Vanessa McHale-category:            Web-build-type:          Simple-extra-source-files:  README.md-                   , bf/helloworld.bf-                   , default.nix-                   , release.nix-cabal-version:       >=1.10+cabal-version: 1.18+name: brainheck+version: 0.1.0.7+license: BSD3+license-file: LICENSE+copyright: Copyright: (c) 2016-2018 Vanessa McHale+maintainer: vamchale@gmail.com+author: Vanessa McHale+homepage: https://github.com/vmchale/brainheck#readme+synopsis: Brainh*ck interpreter in haskell+description:+    Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries+category: Web+build-type: Simple+extra-source-files:+    README.md+    bf/helloworld.bf -Flag llvm-fast {-  Description: Enable build with llvm backend-  Default: False-}+source-repository head+    type: git+    location: https://github.com/vmchale/brainheck +flag llvm-fast+    description:+        Enable build with llvm backend+    default: False++flag development+    description:+        Turn on '-Werror'+    default: False+    manual: True+ library-  hs-source-dirs:      src-  exposed-modules:     Brainheck-  build-depends:       base >= 4.9 && < 5-                     , mtl-                     , vector-                     , recursion-schemes-                     , text-                     , lens-                     , megaparsec >= 6.0-                     , containers-  default-language:    Haskell2010-  default-extensions:  DeriveFunctor-                     , DeriveFoldable-                     , DeriveTraversable-                     , TypeFamilies+    exposed-modules:+        Brainheck+    hs-source-dirs: src+    default-language: Haskell2010+    default-extensions: DeriveFunctor DeriveFoldable DeriveTraversable+                        TypeFamilies+    ghc-options: -Wall+    build-depends:+        base >=4.11 && <5,+        mtl -any,+        vector -any,+        recursion-schemes -any,+        text -any,+        lens -any,+        megaparsec >=6.0,+        containers -any+    +    if flag(development)+        ghc-options: -Werror+    +    if impl(ghc >=8.0)+        ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates  executable brainheck-  hs-source-dirs:      app-  main-is:             Main.hs-  other-modules:       Paths_brainheck-  ghc-options:         -threaded -rtsopts -with-rtsopts=-N-  build-depends:       base-                     , brainheck-                     , optparse-applicative-                     , text-  default-language:    Haskell2010+    main-is: Main.hs+    hs-source-dirs: app+    other-modules:+        Paths_brainheck+    default-language: Haskell2010+    ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall+    build-depends:+        base -any,+        brainheck -any,+        optparse-applicative -any,+        text -any+    +    if flag(development)+        ghc-options: -Werror+    +    if impl(ghc >=8.0)+        ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates  benchmark brainheck-bench-  type:             exitcode-stdio-1.0-  hs-source-dirs:   bench-  main-is:          Bench.hs-  build-depends:    base-                  , criterion-                  , brainheck-                  , text-  if flag(llvm-fast)-    ghc-options:       -threaded -rtsopts -with-rtsopts=-N -fllvm -optlo-O3 -O3-  else-    ghc-options:       -threaded -rtsopts -with-rtsopts=-N -O3-  default-language: Haskell2010--source-repository head-  type:     git-  location: https://github.com/vmchale/brainheck+    type: exitcode-stdio-1.0+    main-is: Bench.hs+    hs-source-dirs: bench+    default-language: Haskell2010+    ghc-options: -Wall+    build-depends:+        base -any,+        criterion -any,+        brainheck -any,+        text -any+    +    if flag(llvm-fast)+        ghc-options: -threaded -rtsopts -with-rtsopts=-N -fllvm -optlo-O3+                     -O3+    else+        ghc-options: -threaded -rtsopts -with-rtsopts=-N -O3+    +    if flag(development)+        ghc-options: -Werror+    +    if impl(ghc >=8.0)+        ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates
− default.nix
@@ -1,17 +0,0 @@-{ mkDerivation, base, containers, lens, megaparsec, mtl-, optparse-applicative, recursion-schemes, stdenv, text, vector-}:-mkDerivation {-  pname = "brainheck";-  version = "0.1.0.3";-  src = ./.;-  isLibrary = true;-  isExecutable = true;-  libraryHaskellDepends = [-    base containers lens megaparsec mtl recursion-schemes text vector-  ];-  executableHaskellDepends = [ base optparse-applicative text ];-  homepage = "https://github.com/vmchale/brainheck#readme";-  description = "Brainh*ck interpreter in haskell";-  license = stdenv.lib.licenses.bsd3;-}
− release.nix
@@ -1,5 +0,0 @@-let-  pkgs = import <nixpkgs> { };--in-  pkgs.haskell.lib.justStaticExecutables (pkgs.haskellPackages.callPackage ./default.nix { })
src/Brainheck.hs view
@@ -10,11 +10,12 @@     , Syntax (..)     ) where -import           Control.Lens+import           Control.Lens             hiding (lens) import           Control.Monad.State.Lazy import           Data.Functor.Foldable import           Data.Functor.Foldable.TH import qualified Data.Map                 as M+import           Data.Maybe import qualified Data.Text                as T import qualified Data.Vector              as V import           Data.Vector.Lens@@ -35,11 +36,11 @@  -- | Map a char to its action in the `St` monad toAction :: Char -> St ()-toAction = maybe (error mempty) id . flip M.lookup keys+toAction = fromMaybe (error mempty) . flip M.lookup keys     where modifyVal f = flip modifyByIndex f . snd =<< get           modifyByIndex i = modifyState (_1 . sliced i 1 . forced) . fmap           modifyState lens = (lens %%=) . (pure .)-          readChar = get >>= (\(_,i) -> modifyByIndex i . const =<< (liftIO . (fmap fromEnum)) getChar)+          readChar = get >>= (\(_,i) -> modifyByIndex i . const =<< (liftIO . fmap fromEnum) getChar)           displayChar = get >>= (\(arr,i) -> liftIO . putChar . toEnum . (V.! i) $ arr)           keys = M.fromList [ ('.', displayChar)                             , (',', readChar)@@ -50,7 +51,7 @@  -- | Parse to syntax tree brainheck :: Parser (Syntax Char)-brainheck = Seq <$> many (Seq . (fmap Token) <$> (some . oneOf) "+-.,<>"+brainheck = Seq <$> many (Seq . fmap Token <$> (some . oneOf) "+-.,<>"     <|> Loop <$> between (char '[') (char ']') brainheck)  algebra :: Base (Syntax Char) (St ()) -> St ()@@ -60,9 +61,9 @@     where check = get >>= (\(arr,i) -> pure . (==0) . (V.! i) $ arr)  -- | Evaluate syntax tree-run :: (Syntax Char) -> IO ()+run :: Syntax Char -> IO () run parsed = fst <$> runStateT (cata algebra parsed) (V.replicate 30000 0, 0)  -- | Parse and return an error or a syntax tree parseBrainheck :: FilePath -> T.Text -> Either (ParseError (Token T.Text) Void) (Syntax Char)-parseBrainheck filepath = (parse (brainheck) filepath) . (T.filter (`elem` "[]+-.,<>"))+parseBrainheck filepath = parse brainheck filepath . T.filter (`elem` "[]+-.,<>")