Compare commits
2 Commits
04f48fe0ee
...
a8ec2f9f21
| Author | SHA1 | Date |
|---|---|---|
|
|
a8ec2f9f21 | |
|
|
3265b7bbb0 |
19
.kakrc
19
.kakrc
|
|
@ -1,9 +1,10 @@
|
||||||
hook -once -group eoc global KakBegin .* %{
|
set global makecmd 'cabal build'
|
||||||
repl-buffer-new racket -i
|
#hook -once -group eoc global KakBegin .* %{
|
||||||
repl-buffer-send-text "(require xrepl)
|
# repl-buffer-new racket -i
|
||||||
"
|
# repl-buffer-send-text "(require xrepl)
|
||||||
%}
|
#"
|
||||||
|
#%}
|
||||||
define-command xrepl-enter %{
|
#
|
||||||
repl-buffer-send-text ",en %val{buffile}"
|
#define-command xrepl-enter %{
|
||||||
}
|
# repl-buffer-send-text ",en %val{buffile}"
|
||||||
|
#}
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue