Skip to content

Instantly share code, notes, and snippets.

@drewr
Created January 2, 2015 15:12
Show Gist options
  • Save drewr/98a57ca42e0f25a54926 to your computer and use it in GitHub Desktop.
Save drewr/98a57ca42e0f25a54926 to your computer and use it in GitHub Desktop.
psci can't find symbol
% cat src/Data/PhoneBook.purs
module Data.PhoneBook where
import Data.List
import Data.Maybe
import Control.Plus (empty)
type Entry = { firstName :: String
, lastName :: String
, phone :: String
}
type PhoneBook = List Entry
showEntry :: Entry -> String
showEntry entry = entry.lastName ++ ", " ++
entry.firstName ++ ": " ++
entry.phone
emptyBook :: PhoneBook
emptyBook = empty
insertEntry :: Entry -> PhoneBook -> PhoneBook
insertEntry e pb = Cons e pb
% psci
psci
____ ____ _ _
| _ \ _ _ _ __ ___/ ___| ___ _ __(_)_ __ | |_
| |_) | | | | '__/ _ \___ \ / __| '__| | '_ \| __|
| __/| |_| | | | __/___) | (__| | | | |_) | |_
|_| \__,_|_| \___|____/ \___|_| |_| .__/ \__|
|_|
:? shows help
Expressions are terminated using Ctrl+D
> :i Data.PhoneBook
:i Data.PhoneBook
> :t insertEntry
:t insertEntry
Error at line 1, column 4 - line 1, column 15:
Error in module $PSCI
Unknown value 'insertEntry'
> :q
:q
See ya!
%
@AlainODea
Copy link

I'm seeing the same thing here. Did you find a solution to this?

@AlainODea
Copy link

I figured it out. It's a PSCI bug. If you declare showEntry last the problem goes away:

module Data.PhoneBook where

import Data.List
import Data.Maybe

import Control.Plus (empty)

type Entry = { firstName :: String
             , lastName :: String
             , phone :: String
             }

type PhoneBook = List Entry

emptyBook :: PhoneBook
emptyBook = empty

insertEntry :: Entry -> PhoneBook -> PhoneBook
insertEntry e pb = Cons e pb

showEntry :: Entry -> String
showEntry entry = entry.lastName ++ ", " ++
                  entry.firstName ++ ": " ++
                  entry.phone

I suspect it has something to do with how PSCI handles the offside rule. It's frustrating because Main.js clearly contains valid JS versions of all the functions in Data.PhoneBook in either case.

@AlainODea
Copy link

Bizarrely, after making that change and running it this problem is not reproducible. I can even put Data/PhoneBook.purs back to the original declaration order and it loads and runs perfectly in psci.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment