<feed xmlns='http://www.w3.org/2005/Atom'>
<title>sorbot/src/Plugin, branch master</title>
<subtitle></subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/'/>
<entry>
<title>Lib: Test application of Bot reader</title>
<updated>2017-11-19T18:34:56+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-11-19T18:22:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=6961ef49cbcb88e4f3466a5852a4cf90d95a587a'/>
<id>6961ef49cbcb88e4f3466a5852a4cf90d95a587a</id>
<content type='text'>
A test to try to get _something_ to compile. And it does!

Here we try to run a plugin with `runReaderT` and `runBot` to pass
`Options` to the plugin, using the "help" plugin as an example. It feeds
hard-coded `Options` to the plugin and outputs its response to STDOUT.

Also get an implementation of `initializePlugins` working that will
allow us to build a list of plugins with `Options` applied to the
reader.

This commit comments out the whole of IRC.hs in order to get the code to
compile. That file still has a bunch of `Bot` monad-related type errors.

To build the final plugin list, I think what we'll want to do is use
something like `initializePlugins` in Lib to apply all our plugins with
the `Options` and then feed that to `connectIRC`. In order to build the
"help" plugin, the plan is to re-apply the `Options` after `ask`ing for
them inside the `PluginAction` for "help" to all plugins, thus enabling
us to get a plugin list with the applied reader for proper localisation
of the help output.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A test to try to get _something_ to compile. And it does!

Here we try to run a plugin with `runReaderT` and `runBot` to pass
`Options` to the plugin, using the "help" plugin as an example. It feeds
hard-coded `Options` to the plugin and outputs its response to STDOUT.

Also get an implementation of `initializePlugins` working that will
allow us to build a list of plugins with `Options` applied to the
reader.

This commit comments out the whole of IRC.hs in order to get the code to
compile. That file still has a bunch of `Bot` monad-related type errors.

To build the final plugin list, I think what we'll want to do is use
something like `initializePlugins` in Lib to apply all our plugins with
the `Options` and then feed that to `connectIRC`. In order to build the
"help" plugin, the plan is to re-apply the `Options` after `ask`ing for
them inside the `PluginAction` for "help" to all plugins, thus enabling
us to get a plugin list with the applied reader for proper localisation
of the help output.
</pre>
</div>
</content>
</entry>
<entry>
<title>Help: Fix type error resulting from new plugin list type with `Bot`</title>
<updated>2017-09-14T20:45:35+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-09-14T20:45:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=1f9c9d43ef475167ac6e886a71a782cf41bd549e'/>
<id>1f9c9d43ef475167ac6e886a71a782cf41bd549e</id>
<content type='text'>
The plugin list's type has changed from `[Plugin]` to `[Bot Plugin]`. In
order for our code here to work, we need to unwrap the `Bot` part so we
can get access to the `Plugin` again and do the same work.

Fortunately, using `sequence`, we can turn our `[Bot Plugin]` into a
`Bot [Plugin]`, which is then easily bound with `&lt;-` and passed to our
old code to be handled like before. Yay!
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The plugin list's type has changed from `[Plugin]` to `[Bot Plugin]`. In
order for our code here to work, we need to unwrap the `Bot` part so we
can get access to the `Plugin` again and do the same work.

Fortunately, using `sequence`, we can turn our `[Bot Plugin]` into a
`Bot [Plugin]`, which is then easily bound with `&lt;-` and passed to our
old code to be handled like before. Yay!
</pre>
</div>
</content>
</entry>
<entry>
<title>Add `Bot` to rest of plugins</title>
<updated>2017-09-14T01:44:38+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-09-14T01:44:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=ea190de02cea99347ae125d86cc22bf8cd926c88'/>
<id>ea190de02cea99347ae125d86cc22bf8cd926c88</id>
<content type='text'>
Add our `Bot` monad to the rest of the plugins:

* Factorial
* GitRemoteSetOrigin
* Help

The only problem is with the Help plugin. Still trying to figure out how
to set up my list comprehension so that it works with the `Bot`-wrapped
`Plugin` list.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add our `Bot` monad to the rest of the plugins:

* Factorial
* GitRemoteSetOrigin
* Help

The only problem is with the Help plugin. Still trying to figure out how
to set up my list comprehension so that it works with the `Bot`-wrapped
`Plugin` list.
</pre>
</div>
</content>
</entry>
<entry>
<title>gitHubCommit: Fix type error</title>
<updated>2017-09-13T02:47:08+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-09-10T22:53:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=ae6949327ed8bd8cfa528da7741333274203af44'/>
<id>ae6949327ed8bd8cfa528da7741333274203af44</id>
<content type='text'>
Oh my goodness, it works!!!!!!! I've been wrestling with this for the
past week and a half, and it finally works!

Here's the compiler error I was getting:

    sorbot/src/Plugin/GitHubCommit.hs:25:12: error:
        • Couldn't match type ‘Control.Monad.Trans.Reader.ReaderT r0 m1’
                         with ‘Bot’
          Expected type: Bot t0
            Actual type: Control.Monad.Trans.Reader.ReaderT r0 m1 t0
        • In a stmt of a 'do' block: cfg &lt;- asks language
          In the expression:
            do { cfg &lt;- asks language;
                 return
                   (defaultPlugin
                      {matchRegex = "^[0-9a-f]{40}$", perform = gitHubCommitAction,
                       command = "&lt;git_sha&gt;",
                       description = translate (lang cfg) GitHubCommitDescription}) }
          In an equation for ‘gitHubCommit’:
              gitHubCommit
                = do { cfg &lt;- asks language;
                       return
                         (defaultPlugin
                            {matchRegex = "^[0-9a-f]{40}$", perform = gitHubCommitAction,
                             command = "&lt;git_sha&gt;",
                             description = translate (lang cfg) GitHubCommitDescription}) }

The problem ended up being that I was using the wrong `ask` &amp; `asks`
functions. After a lot of searching online and reading articles and
things about how to set up `ReaderT` configuration, I finally started
looking at some code, from a "language:Haskell newtype app readert"
search on GitHub. Reading different code bits, I tried to compare with
what I had already, kept reading. Finally I noticed that the imports
were different, and I tried getting `ask` not from the transformer
library, and it worked!! OMG! So glad.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Oh my goodness, it works!!!!!!! I've been wrestling with this for the
past week and a half, and it finally works!

Here's the compiler error I was getting:

    sorbot/src/Plugin/GitHubCommit.hs:25:12: error:
        • Couldn't match type ‘Control.Monad.Trans.Reader.ReaderT r0 m1’
                         with ‘Bot’
          Expected type: Bot t0
            Actual type: Control.Monad.Trans.Reader.ReaderT r0 m1 t0
        • In a stmt of a 'do' block: cfg &lt;- asks language
          In the expression:
            do { cfg &lt;- asks language;
                 return
                   (defaultPlugin
                      {matchRegex = "^[0-9a-f]{40}$", perform = gitHubCommitAction,
                       command = "&lt;git_sha&gt;",
                       description = translate (lang cfg) GitHubCommitDescription}) }
          In an equation for ‘gitHubCommit’:
              gitHubCommit
                = do { cfg &lt;- asks language;
                       return
                         (defaultPlugin
                            {matchRegex = "^[0-9a-f]{40}$", perform = gitHubCommitAction,
                             command = "&lt;git_sha&gt;",
                             description = translate (lang cfg) GitHubCommitDescription}) }

The problem ended up being that I was using the wrong `ask` &amp; `asks`
functions. After a lot of searching online and reading articles and
things about how to set up `ReaderT` configuration, I finally started
looking at some code, from a "language:Haskell newtype app readert"
search on GitHub. Reading different code bits, I tried to compare with
what I had already, kept reading. Finally I noticed that the imports
were different, and I tried getting `ask` not from the transformer
library, and it worked!! OMG! So glad.
</pre>
</div>
</content>
</entry>
<entry>
<title>GitHubCommit: Use `Cli.language` to get language</title>
<updated>2017-09-13T02:47:08+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-09-10T22:50:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=515de5dd5d44fb361fe7ca68d698776e84c4d523'/>
<id>515de5dd5d44fb361fe7ca68d698776e84c4d523</id>
<content type='text'>
Since we're trying to get the language from an `Options` type in the
reader, we need to use the `language` helper instead of our custom
`lang` (which operates on `IO`).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since we're trying to get the language from an `Options` type in the
reader, we need to use the `language` helper instead of our custom
`lang` (which operates on `IO`).
</pre>
</div>
</content>
</entry>
<entry>
<title>Bot: Try adding a BotConfig type</title>
<updated>2017-09-13T02:47:08+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-09-10T22:48:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=3698d614bca4f88c2ffb0c4bf7867e8c5b140b8a'/>
<id>3698d614bca4f88c2ffb0c4bf7867e8c5b140b8a</id>
<content type='text'>
Tried adding this to replicate some code I had been reading, but
ultimately it didn't really change anything. In the end I don't need
this type, at least not right now, but it was an interesting exercise I
suppose.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Tried adding this to replicate some code I had been reading, but
ultimately it didn't really change anything. In the end I don't need
this type, at least not right now, but it was an interesting exercise I
suppose.
</pre>
</div>
</content>
</entry>
<entry>
<title>gitHubCommit: Remove unnecessary `$`</title>
<updated>2017-09-13T02:47:08+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-09-10T22:46:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=3b35cb9872af5f866521250547671c329ffbfe13'/>
<id>3b35cb9872af5f866521250547671c329ffbfe13</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>gitHubCommitAction: Didn't need `liftIO` here</title>
<updated>2017-09-13T02:47:08+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-09-10T22:43:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=c0cdcfecf1082982b78a5cf1d053025e0edadcef'/>
<id>c0cdcfecf1082982b78a5cf1d053025e0edadcef</id>
<content type='text'>
Added this for whatever reason trying to get types to line up, but it's
not necessary. In fact, I didn't even really notice it as I was bothered
by another compiler error, but 'monochrom' on Freenode#haskell pointed
it out, thanks.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Added this for whatever reason trying to get types to line up, but it's
not necessary. In fact, I didn't even really notice it as I was bothered
by another compiler error, but 'monochrom' on Freenode#haskell pointed
it out, thanks.
</pre>
</div>
</content>
</entry>
<entry>
<title>GitHubCommit: Try to add `Bot` monad</title>
<updated>2017-09-13T02:46:26+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-09-10T22:39:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=613e0d9a67d29b2bb27efd7ca993d4108724b30a'/>
<id>613e0d9a67d29b2bb27efd7ca993d4108724b30a</id>
<content type='text'>
This is an attempt at wrapping the functions in this plugin with the new
`Bot` monad. It didn't go very well.

These changes are the result of some initial code and then a lot of
fiddling to try to resolve compiler errors, many of which are still
present.

The ultimate goal is to be able to wrap the functions in `Bot` so that
we can use the language configuration option to determine which
translation to use.

Thanks to 'dmwit' on Freenode#haskell for looking at my code and giving
me suggestions for my type errors.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is an attempt at wrapping the functions in this plugin with the new
`Bot` monad. It didn't go very well.

These changes are the result of some initial code and then a lot of
fiddling to try to resolve compiler errors, many of which are still
present.

The ultimate goal is to be able to wrap the functions in `Bot` so that
we can use the language configuration option to determine which
translation to use.

Thanks to 'dmwit' on Freenode#haskell for looking at my code and giving
me suggestions for my type errors.
</pre>
</div>
</content>
</entry>
<entry>
<title>Plugin.Base: Make `PluginAction` return a `Bot` monad</title>
<updated>2017-09-10T22:35:47+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2017-09-10T22:35:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/sorbot/commit/?id=8e0f025188e55b7463707205174c54cbbf8255d3'/>
<id>8e0f025188e55b7463707205174c54cbbf8255d3</id>
<content type='text'>
Replace the `IO` return monad with `Bot`. `Bot` wraps the `IO` monad so
it should cover us for that, while additionally providing configuration
to plugin action functions.

There's also some extra cruft here from when I was experimenting. The
commit before this one and the next one or more were all written at once
in a jumbled mess. All the extra code is collateral from that.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replace the `IO` return monad with `Bot`. `Bot` wraps the `IO` monad so
it should cover us for that, while additionally providing configuration
to plugin action functions.

There's also some extra cruft here from when I was experimenting. The
commit before this one and the next one or more were all written at once
in a jumbled mess. All the extra code is collateral from that.
</pre>
</div>
</content>
</entry>
</feed>
