JustusAdam / marvin

The paranoid bot (framework)
https://marvin.readthedocs.io
BSD 3-Clause "New" or "Revised" License
53 stars 6 forks source link

Default MyScript.hs out of date #11

Closed dogwith1eye closed 7 years ago

dogwith1eye commented 7 years ago

Here is a quick rundown of what I had to get to get a chatbot example up and working on a slack channel.

marvin-init HelloWorld stack init stack setup

changed resolver back to resolver: nightly-2017-02-19

stack install text-icu \ --extra-lib-dirs=/usr/local/opt/icu4c/lib \ --extra-include-dirs=/usr/local/opt/icu4c/include

stack install

{-# LANGUAGE TemplateHaskell #-} module MyScript where

import Prelude import Marvin.Prelude import Marvin.Adapter.Slack.RTM

script :: ScriptInit (SlackAdapter RTM) script = defineScript "my-script" $ do hear (r [CaseInsensitive] "ping") $ do -- react to any message msg <- getMessage -- read the message contents logInfoN $(isT "#{msg}") send "Pong" -- sending messages back respond "hello" $ do -- react to direct commands reply "Hello to you too"

stack build

Looks like the mustache file needs to be updated

JustusAdam commented 7 years ago

It seems the mustache file was mostly fine, but the initialiser not.

It was out of date on the available adapters and also it would never add import the module for the concrete adapter.

JustusAdam commented 7 years ago

Can you build marvin from source on your machine?

dogwith1eye commented 7 years ago

Nearly, this is what happens when compiling marvin-pp

[1 of 1] Compiling Main ( preprocessor/Main.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.0.0/build/marvin-pp/marvin-pp-tmp/Main.o ) : can't load .so/.DLL for: /Users/dogwith1eye/GitHub/marvin/.stack-work/dist/x86_64-osx/Cabal-1.24.0.0/build/libHSmarvin-0.2. 0-GZHLGNsFUv9KUiXTyV6N6N-ghc8.0.1.dylib (dlopen(/Users/dogwith1eye/GitHub/marvin/.stack-work/dist/x86_64-osx/Cabal-1.24.0.0/build/libHSmarv in-0.2.0-GZHLGNsFUv9KUiXTyV6N6N-ghc8.0.1.dylib, 5): no suitable image found. Did find: /Users/dogwith1eye/GitHub/marvin/.stack-work/dist/x86_64-osx/Cabal-1.24.0.0/build/libHSmarvin-0.2.0-GZHLGNsFUv9KUiXTyV6N6N-ghc8.0.1 .dylib: malformed mach-o: load commands size (38608) > 32768)

JustusAdam commented 7 years ago

Ah, yes. that is a problem caused by the new linker in OSX. If you use GHC 8.0.2 it should resolve the problem.

For me there was also a problem with the irc-conduit library, which the author was nice enough to fix.

This stack.yaml works for me again:

resolver: lts-8.3
extra-deps:
- marvin-interpolate-1.1
- mustache-2.1.2
- wreq-0.5.0.0
- irc-conduit-0.2.2.1
packages:
- '.'
JustusAdam commented 7 years ago

Marvin will also itself be on stack soon and make all this easier.

JustusAdam commented 7 years ago

Oh and i totally forgot to reference this issue in 1335dabe2c093c28691d8d36875fe12a47cbcdd1

dogwith1eye commented 7 years ago

Yep build for me now. The MyScript.hs file still requires a few changes in order for it to run. I have to add...

import Prelude so that ($) function is found

and I have to comment out the line of logging --infoM (content msg) -- logging

Would be nice if the MyScript.hs file ran without any changes.

JustusAdam commented 7 years ago

I should have fixed that. If you run stack install, in the marvin repo it should install a version from source.

That should incude the fixed initializer.

I also added an integration test to make sure it produces something which compiles without modification.