elm-lang / elm-reactor

Interactive development tool that makes it easy to develop and debug Elm programs.
BSD 3-Clause "New" or "Revised" License
428 stars 63 forks source link

The argument to function `start` is causing a mismatch. #172

Closed willfish closed 8 years ago

willfish commented 8 years ago

I've been following the Elm tutorials through the Pragmatic Studio and am adding the following to main:

main =
  StartApp.start { model = initialModel, view = view, update = update }

This seems pretty straight forward as per https://github.com/evancz/start-app.

I am getting the following error and can't seem to find the source of the problem:

>> Detected errors in 1 module.
>> ==================================== ERRORS ====================================
>>
>> -- TYPE MISMATCH ----------------------------------------------------- Bingo.elm
>>
>> The argument to function `start` is causing a mismatch.
>>
>> 74│   StartApp.start { model = initialModel, view = view, update = update }
>>                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> Function `start` is expecting the argument to be:
>>
>>     { ..., init : ..., inputs : ... }
>>
>> But it is:
>>
>>     { ..., model : ... }

This is my Gruntfile:

module.exports = function(grunt) {

  grunt.initConfig({
    elm: {
      compile: {
        files: {
          "bingo.js": ["Bingo.elm"]
        }
      }
    },
    watch: {
      elm: {
        files: ["Bingo.elm", "BingoUtils.elm"],
        tasks: ["elm"]
      }
    },
    clean: ["elm-stuff/build-artifacts"]
  });

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-elm');

  grunt.registerTask('default', ['elm']);

};

This is my elm package json:

{
    "version": "1.0.0",
    "summary": "helpful summary of your project, less than 80 characters",
    "repository": "https://github.com/user/project.git",
    "license": "BSD3",
    "source-directories": [
        "."
    ],
    "exposed-modules": [],
    "dependencies": {
        "elm-lang/core": "3.0.0 <= v < 4.0.0",
        "evancz/elm-html": "4.0.2 <= v < 5.0.0",
        "evancz/start-app": "2.0.2 <= v < 3.0.0"
    },
    "elm-version": "0.16.0 <= v < 0.17.0"
}

I installed elm-platform using brew cask at first: https://github.com/caskroom/homebrew-cask/blob/master/Casks/elm-platform.rb. Completely uninstalled and then reinstalled using the elm websites link: http://elm-lang.org/install.

Found that someone else had similar issues (though compiling their own things https://github.com/elm-lang/elm-reactor/issues/162).

Not sure whether I'm doing something wrong :(

jvoigtlaender commented 8 years ago

The problem is in your code. Note that http://package.elm-lang.org/packages/evancz/start-app/2.0.2/StartApp#start and http://package.elm-lang.org/packages/evancz/start-app/2.0.2/StartApp-Simple#start are different functions with different types. You have imported StartApp, but are trying to use StartApp.Simple.start. Change the line

import StartApp

in your code to

import StartApp.Simple as StartApp

(just like in https://github.com/evancz/start-app/blob/master/README.md)

willfish commented 8 years ago

That was really helpful! Thanks :)