Skip to content
Permalink
Browse files

Merge PR #132: Automatically format using Ormolu

  • Loading branch information...
cwgoes committed Oct 13, 2019
1 parent cca6d53 commit 2e4036a6a48f803046607b2bdc7505ed01d92e3f
Showing with 3,227 additions and 2,458 deletions.
  1. +0 −53 .stylish-haskell.yaml
  2. +1 −1 Makefile
  3. +2 −0 README.md
  4. +1 −1 Setup.hs
  5. +19 −16 app/Config.hs
  6. +45 −44 app/Interactive.hs
  7. +45 −40 app/Main.hs
  8. +21 −18 app/Options.hs
  9. +5 −5 bench/ghc/Church.hs
  10. +3 −3 bench/ghc/Map.hs
  11. +5 −0 doc/CONTRIBUTING.md
  12. +8 −8 experimental/family/test.hs
  13. +20 −21 experimental/family/test2.hs
  14. +62 −58 experimental/playground/EAL/eal.hs
  15. +31 −27 experimental/playground/Mendler.hs
  16. +8 −11 experimental/playground/Typed-Based-Termination.hs
  17. +98 −75 experimental/playground/splayground.hs
  18. +61 −44 src/Juvix/Backends/Env.hs
  19. +70 −45 src/Juvix/Backends/Graph.hs
  20. +111 −83 src/Juvix/Backends/Interface.hs
  21. +89 −71 src/Juvix/Backends/Maps.hs
  22. +11 −10 src/Juvix/Bohm.hs
  23. +42 −41 src/Juvix/Bohm/Default.hs
  24. +144 −83 src/Juvix/Bohm/Parser.hs
  25. +15 −13 src/Juvix/Bohm/Shared.hs
  26. +212 −194 src/Juvix/Bohm/Translation.hs
  27. +15 −14 src/Juvix/Bohm/Type.hs
  28. +11 −10 src/Juvix/Core.hs
  29. +64 −50 src/Juvix/Core/Erasure.hs
  30. +82 −72 src/Juvix/Core/MainLang.hs
  31. +64 −63 src/Juvix/Core/Parser.hs
  32. +11 −10 src/Juvix/Core/SemiRing.hs
  33. +13 −12 src/Juvix/EAC.hs
  34. +27 −26 src/Juvix/EAC/Check.hs
  35. +118 −91 src/Juvix/EAC/EAC.hs
  36. +101 −60 src/Juvix/EAC/Parser.hs
  37. +56 −44 src/Juvix/EAC/Solve.hs
  38. +81 −63 src/Juvix/EAC/Types.hs
  39. +44 −35 src/Juvix/Encoding/Encoding.hs
  40. +120 −93 src/Juvix/Encoding/Mendler.hs
  41. +53 −41 src/Juvix/Encoding/Scott.hs
  42. +56 −41 src/Juvix/Encoding/Types.hs
  43. +61 −30 src/Juvix/Library.hs
  44. +321 −246 src/Juvix/Nets/Bohm.hs
  45. +88 −76 src/Juvix/Nets/Combinators.hs
  46. +22 −17 src/Juvix/NodeInterface.hs
  47. +9 −8 src/Juvix/Utility.hs
  48. +8 −7 src/Juvix/Utility/HashMap.hs
  49. +8 −10 src/Juvix/Utility/Helper.hs
  50. +13 −6 src/Juvix/Utility/PrettyPrint.hs
  51. +38 −31 src/Juvix/Visualize/Dot.hs
  52. +4 −4 src/Juvix/Visualize/Graph.hs
  53. +46 −38 test/Bohm.hs
  54. +27 −9 test/EAC.hs
  55. +139 −79 test/EAC2.hs
  56. +234 −95 test/Encoding.hs
  57. +19 −20 test/Erasure.hs
  58. +71 −40 test/MainLang.hs
  59. +16 −10 test/Nets/Bohm.hs
  60. +58 −42 test/Nets/Combinators.hs

This file was deleted.

@@ -25,7 +25,7 @@ lint:
stack exec -- hlint app src test

format:
find . -type f -name "*.hs" -exec stylish-haskell -i {} \;
find . -path ./.stack-work -prune -o -path ./archived -prune -o -type f -name "*.hs" -exec ormolu --mode inplace {} \;

test:
stack test --fast
@@ -64,6 +64,8 @@ juvix interactive

## Development

[Ormolu](https://github.com/cryptiumlabs/ormolu) required for source formatting.

To open a REPL with the library scoped:

```bash
@@ -1,4 +1,4 @@
import Distribution.Simple
import Distribution.Simple

main IO ()
main = defaultMain
@@ -1,36 +1,39 @@
module Config where

import qualified Data.Aeson as A
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as A
import Data.Char (isLower, toLower)
import qualified Data.Yaml as Y
import Protolude
import Data.Char (isLower, toLower)
import qualified Data.Yaml as Y
import Protolude

data Config = Config {
configTezosNode Text
} deriving (Generic)
data Config
= Config
{ configTezosNode Text
}
deriving (Generic)

defaultConfig Config
defaultConfig = Config {
configTezosNode = "127.0.0.1"
}
defaultConfig = Config
{ configTezosNode = "127.0.0.1"
}

loadConfig FilePath IO (Maybe Config)
loadConfig path = do
config Y.decodeFileEither path
return $ case config of
Right parsed pure parsed
Left _ Nothing
Left _ Nothing

instance Y.FromJSON Config where
parseJSON = customParseJSON

jsonOptions A.Options
jsonOptions = A.defaultOptions {
A.fieldLabelModifier = (\(h:t) toLower h : t) . dropWhile isLower,
A.omitNothingFields = True,
A.sumEncoding = A.ObjectWithSingleField
}
jsonOptions =
A.defaultOptions
{ A.fieldLabelModifier = (\(h : t) toLower h : t) . dropWhile isLower,
A.omitNothingFields = True,
A.sumEncoding = A.ObjectWithSingleField
}

customParseJSON (A.GFromJSON A.Zero (Rep a), Generic a) A.Value A.Parser a
customParseJSON = A.genericParseJSON jsonOptions
@@ -1,22 +1,20 @@
module Interactive where

import Control.Monad.IO.Class
import qualified Data.Text as T
import Prelude (String)
import Protolude
import qualified System.Console.Haskeline as H
import Text.PrettyPrint.ANSI.Leijen hiding ((<>))

import Config
import Options

import qualified Juvix.Backends.Env as Env
import qualified Juvix.Backends.Graph as Graph
import qualified Juvix.Backends.Maps as Maps ()
import qualified Juvix.Bohm as Bohm
import qualified Juvix.Core as Core
import qualified Juvix.EAC as EAC
import qualified Juvix.Nets.Bohm as Bohm
import Config
import Control.Monad.IO.Class
import qualified Data.Text as T
import qualified Juvix.Backends.Env as Env
import qualified Juvix.Backends.Graph as Graph
import qualified Juvix.Backends.Maps as Maps ()
import qualified Juvix.Bohm as Bohm
import qualified Juvix.Core as Core
import qualified Juvix.EAC as EAC
import qualified Juvix.Nets.Bohm as Bohm
import Options
import Protolude
import qualified System.Console.Haskeline as H
import Text.PrettyPrint.ANSI.Leijen hiding ((<>))
import Prelude (String)

interactive Context Config IO ()
interactive ctx _ = do
@@ -26,9 +24,9 @@ interactive ctx _ = do
settings Context H.Settings IO
settings ctx =
H.Settings
{ H.complete = H.completeFilename
, H.historyFile = Just (contextHomeDirectory ctx <> "/.jvxi_history")
, H.autoAddHistory = True
{ H.complete = H.completeFilename,
H.historyFile = Just (contextHomeDirectory ctx <> "/.jvxi_history"),
H.autoAddHistory = True
}

mainLoop (String IO String) H.InputT IO ()
@@ -46,7 +44,7 @@ mainLoop func = do
handleSpecial String H.InputT IO () H.InputT IO ()
handleSpecial str cont = do
case str of
"?" liftIO (putDoc specialsDoc) >> cont
"?" liftIO (putDoc specialsDoc) >> cont
"exit" return ()
"tutorial" do
H.outputStrLn "Interactive tutorial coming soon!"
@@ -64,7 +62,7 @@ handleSpecial str cont = do
H.outputStrLn $ show eval
Nothing return ()
cont
'c' : 'e' : ' ': rest do
'c' : 'e' : ' ' : rest do
let parsed = Core.parseString Core.cterm rest
H.outputStrLn $ show parsed
case parsed of
@@ -80,25 +78,25 @@ handleSpecial str cont = do
let parsed = EAC.parseEal rest
case parsed of
Right r transformAndEvaluateEal True r
_ return ()
_ return ()
cont
'e' : 'q' : ' ' : rest do
let parsed = EAC.parseEal rest
case parsed of
Right r transformAndEvaluateEal False r
_ return ()
_ return ()
cont
'e' : 'e' : ' ' : rest do
let parsed = EAC.parseEal rest
H.outputStrLn $ show parsed
case parsed of
Right r transformAndEvaluateEal True r
_ return ()
_ return ()
cont
_ H.outputStrLn "Unknown special command" >> cont

eraseAndSolveCore
Core.CTerm H.InputT IO (Either EAC.Errors (EAC.RPT, EAC.ParamTypeAssignment))
Core.CTerm H.InputT IO (Either EAC.Errors (EAC.RPT, EAC.ParamTypeAssignment))
eraseAndSolveCore cterm = do
let (term, typeAssignment) = Core.erase' cterm
res liftIO (EAC.validEal term typeAssignment)
@@ -122,30 +120,33 @@ transformAndEvaluateEal debug term = do

specialsDoc Doc
specialsDoc =
mconcat [ line
, mconcat (fmap (flip (<>) line . specialDoc) specials)
, line ]
mconcat
[ line,
mconcat (fmap (flip (<>) line . specialDoc) specials),
line
]

specialDoc Special Doc
specialDoc (Special command helpDesc) =
text $ T.unpack $ mconcat [":", command, " - ", helpDesc]

specials [Special]
specials =
[ Special "cp [term]" "Parse a Juvix Core term"
, Special "ct [term}" "Parse, typecheck, & evaluate a Juvix Core term"
, Special "ce [term"
"Parse a Juvix Core term, translate to EAC, solve constraints, evaluate & read-back"
, Special "ep [term]" "Parse an EAC term"
, Special "ee [term]" "Parse an EAC term, evaluate & read-back"
, Special "eq [term]" "Parse an EAC term, evaluate & read-back quietly"
, Special "tutorial" "Embark upon an interactive tutorial"
, Special "?" "Show this help message"
, Special "exit" "Quit interactive mode"
[ Special "cp [term]" "Parse a Juvix Core term",
Special "ct [term}" "Parse, typecheck, & evaluate a Juvix Core term",
Special
"ce [term"
"Parse a Juvix Core term, translate to EAC, solve constraints, evaluate & read-back",
Special "ep [term]" "Parse an EAC term",
Special "ee [term]" "Parse an EAC term, evaluate & read-back",
Special "eq [term]" "Parse an EAC term, evaluate & read-back quietly",
Special "tutorial" "Embark upon an interactive tutorial",
Special "?" "Show this help message",
Special "exit" "Quit interactive mode"
]

data Special =
Special
{ specialCommand :: Text
, specialHelpDesc :: Text
}
data Special
= Special
{ specialCommand Text,
specialHelpDesc Text
}

0 comments on commit 2e4036a

Please sign in to comment.
You can’t perform that action at this time.