parsonsmatt / kale Goto Github PK
View Code? Open in Web Editor NEWA quick, easy, and declarative task runner for Haskell code to destroy your boiler plate!
License: BSD 3-Clause "New" or "Revised" License
A quick, easy, and declarative task runner for Haskell code to destroy your boiler plate!
License: BSD 3-Clause "New" or "Revised" License
Issue #10 says that we need to have a configuration data type. How do we load that configuration?
Idea: allow the user to specify a config-as-Haskell code that is imported from a specific location.
I think I'm mostly a fan of 3, as we already need to provide the user a way to import a module to provide relevant types (as raised in issue #1). If that module contains a kaleConfig
value, then we can import it and use it.
Depending on the type of kaleConfig
, we could handle it in different ways:
kaleConfig :: Config
= just use thiskaleConfig :: Config -> Config
= given the defaults, modify them like thiskaleConfig :: IO Config
= bind this out of IOkaleConfig :: Config -> IO Config
= given the defaults, load this configurationRight now, the rendering function looks something like:
unlines
[ "module " ++ something ++ " where"
, "import Kale.Discovery"
, makeSomeString
, "woo i love strings"
]
This kinda sucks! Instead, let's write some limited data types that represents the syntax we want.
data Syntax = ...
data Import = Import Module (Maybe Qualified)
Etc. Finally, we'll write a function render :: Syntax -> String
that will be used to turn this into valid Haskell.
Running make test
, for example, results in make: 'test' is up to date.
without running any commands.
Currently, the argument parser only accepts named arguments:
module AsdfTask where
data Args = Args { foo :: String }
generates a command line task used like asdf --foo hello
We should also accept positional arguments:
module PosTask where
data Args = Args String Int
which generates a command line task like pos hello 10
kale
needs to be able to handle parsing command line arguments, implicitly.
Search for a data Args = Args
data type. If it is not present, then we ignore it. If it is not a product type, then we should fail loudly, probably.
Extract the text of the record. So data Args = Args Int
gives us Int
. data Args = Args { userName :: String }
is {userName :: String }
. data Args = Args { fooId :: Int <?> "The Foo's ID" }
gives us { fooId :: Int <?> "The Foo's ID" }
.
Paste the text of the arguments to the record into the creation of that variant of the sum type. So if we have
module FooTask where
data Args = Args { userName :: String }
then the generated code should do:
data Command
= Foo { userName :: String }
A problem with this is that any duplicate fields need to share a type.
Then, we'll need to transform the Command
arguments into the Args
constructor:
case cmd of
Foo {..} -> FooTask.task FooTask.Args {..}
is probably sufficient. hooray for recordwildcards!
There's a ton of String -> String
crap going on in here. Going to need more tests to make sure it's right.
This project needs:
Right now, a ton of things are hardcoded. This is less than ideal. A Config type would be a better way to centralize these points of configuration.
data Config = Config
{ configMainIs :: String -- ^ Name of the main function to be exported.
, ...
}
Config
data type to the libraryConfig
instead.ReaderT Config IO a
instead of Config -> IO a
as the type of functions.As noted in #1, if a user uses non-Prelude types for arguments, they'll be out of scope when copying them into the arguments datatype.
For a Foo
module with the preprocessor, we should search for Foo.Import
, and import that. That module will need to provide all of the types for the import to work.
Use newtype
over the various String
s that are being passed around to make it difficult to mix them up.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.