Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mailbox not in the scope

Tags:

elm

I am trying to create a frontend using elm with elm-router in order to manage the routing.

I have this main file :

-- Main.elm
import Router               exposing (Route, match, (:->))
import History              exposing (path)
import Routing as Routing   exposing (route)
import Signal               exposing ((<~))
import Html                 exposing (Html)
import Signal               exposing (Mailbox, mailbox, Signal)
import Task                 exposing (Task)
import Test as Test exposing (pathChangeMailbox)

main : Signal Html
main = route <~ path

port runTask : Signal (Task error())
port runTask = 
    pathChangeMailbox.signal

This module to handle a mailbox. I could use a mailbox by page but it's ugly so I tried make a module to handle all the common code.

module Test where

import Signal               exposing (Mailbox, mailbox, Signal)
import Task                 exposing (Task)

pathChangeMailbox : Mailbox (Task error ())
pathChangeMailbox = mailbox (Task.succeed())

I also have a module Routing to list the route and associate action to them.

And here is the module to handle the menu, and so the navigation.

module Menu where

import Html             exposing (a, text, Html, div)
import Html.Events      exposing (onClick)
import Task             exposing (Task)
import History          exposing (setPath)
import Test as Test exposing (pathChangeMailbox)

display : String -> Html
display _ =
  div []
    [
      a []
      [ onClick Test.pathChangeMailbox.address (setPath "/CV.elm") ]
      [ text "Mon CV" ]
    ]

When I try to run the program I got the following error :

Error in .\src\Menu.elm:

Error on line 14, column 22 to 47:
Could not find variable 'Test.pathChangeMailbox.address'.

Looks like the prefix 'Test.pathChangeMailbox' is not in scope. Is it spelled correctly?
Is it imported correctly?

You can read about how imports work at the following address:

Do you have anyidea, why even if I import the Test module it's keep saying that Test.pathChangeMailbox is not in scope ?

Edit : Add Routing.elm

module Routing where

import Html             exposing (Html, div, text, br)
import Signal           exposing (Mailbox, mailbox, Signal)
import Task             exposing (Task)
import Router           exposing (match, (:->), Route)

-- Import displays
import CV as CV         exposing (display)
import Home as Home     exposing (display)

route : Route Html
route = match
    [ 
      "/src/Main.elm"   :-> Home.display
    , "/CV.elm"         :-> CV.display
    ] display404

display404 : String -> Html
display404 url =  
  div []
    [
      text "Erreur 404"
    , br [] []
    , text ("url : " ++ url ++ " not found.")
    ]
like image 707
Maxime Mangel Avatar asked May 05 '15 12:05

Maxime Mangel


People also ask

Why can't I send an email from a shared mailbox?

Cause. In this configuration, Exchange Server requires Send As permissions to send the email message. If you don't have Send As permissions for the shared mailbox, Outlook can't send the message.

How do I fix a shared mailbox in Outlook?

Locate the Outlook Profile name of the profile that the shared mailbox is not updating and select it. Locate this key in the profile where the parent key is just above the GroupStore as shown below. Right click on key name: 0102663e and select Delete. Close Registry Editor and restart Outlook.

How do I change the search scope in Outlook?

You can change the default Search Scope in Outlook via: File-> Options-> Search.


1 Answers

I think you've found a bug here. You should file an issue.
EDIT: good job :) Summary of the link: The problem comes from mixing the . used for qualified module access and record access.

Here's a workaround for now, import the name unqualified and use it unqualified. Note I also removed an extra []:

@@ -4,13 +4,13 @@ import Html             exposing (a, text, Html, div)
 import Html.Events      exposing (onClick)
 import Task             exposing (Task)
 import History          exposing (setPath)
 import Test as Test     exposing (pathChangeMailbox)

 display : String -> Html
 display _ =
   div []
     [
-      a []
-      [ onClick Test.pathChangeMailbox.address (setPath "/CV.elm") ]
+      a
+      [ onClick pathChangeMailbox.address (setPath "/CV.elm") ]
       [ text "Mon CV" ]
     ]

(Menu.elm)

like image 59
Apanatshka Avatar answered Oct 08 '22 13:10

Apanatshka