diff --git a/.kakrc b/.kakrc index 4269aef..fe19a90 100644 --- a/.kakrc +++ b/.kakrc @@ -1,9 +1,10 @@ -hook -once -group eoc global KakBegin .* %{ - repl-buffer-new racket -i - repl-buffer-send-text "(require xrepl) -" -%} - -define-command xrepl-enter %{ - repl-buffer-send-text ",en %val{buffile}" -} +set global makecmd 'cabal build' +#hook -once -group eoc global KakBegin .* %{ +# repl-buffer-new racket -i +# repl-buffer-send-text "(require xrepl) +#" +#%} +# +#define-command xrepl-enter %{ +# repl-buffer-send-text ",en %val{buffile}" +#} diff --git a/Main.hs b/Main.hs new file mode 100644 index 0000000..2fbdd98 --- /dev/null +++ b/Main.hs @@ -0,0 +1,46 @@ +module Main where + +import Data.Aeson (FromJSON, parseJSON, withObject, withText, (.:), decode) + +data Program = Program { programFns :: [Function] } + deriving (Show) + +data Function = Function { + functionName :: String, + returnType :: Maybe Type, + functionArgs :: [FunctionArg] + } deriving (Show) + +data Type = Int | Bool + deriving (Show) + +data FunctionArg = FunctionArg { + argName :: String, + argType :: Type + } deriving (Show) + +instance FromJSON Program where + parseJSON = withObject "Program" $ \v -> Program + <$> v .: "functions" + +instance FromJSON Function where + parseJSON = withObject "Function" $ \v -> Function + <$> v .: "name" + <*> v .: "type" + <*> v .: "args" + +instance FromJSON FunctionArg where + parseJSON = withObject "FunctionArg" $ \v -> FunctionArg + <$> v .: "name" + <*> v .: "type" + +instance FromJSON Type where + parseJSON = withText "Type" $ \v -> + case v of + "int" -> return Int + "bool" -> return Bool + _ -> fail "wrong type" + +main :: IO () +main = do + putStrLn $ show (decode "int" :: Maybe Type) diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/eoc.cabal b/eoc.cabal new file mode 100644 index 0000000..4beb66d --- /dev/null +++ b/eoc.cabal @@ -0,0 +1,28 @@ +cabal-version: >=1.10 +-- Initial package description 'eoc.cabal' generated by 'cabal init'. For +-- further documentation, see http://haskell.org/cabal/users-guide/ + +name: eoc +version: 0.1.0.0 +-- synopsis: +-- description: +-- bug-reports: +-- license: +license-file: LICENSE +author: Enrico Lumetti +maintainer: enrico.lumetti@gmail.com +-- copyright: +-- category: +build-type: Simple +extra-source-files: README.md + +executable eoc + main-is: Main.hs + -- other-modules: + -- other-extensions: + build-depends: + base >=4.13 && <4.14, + aeson >= 2.2 + -- hs-source-dirs: + default-language: Haskell2010 + default-extensions: DeriveGeneric, OverloadedStrings