ethul / purescript-angular

AngularJS 1.2 bindings for PureScript (currently in the experimental stage)
MIT License
23 stars 3 forks source link

trouble using purescript-angular in psci #11

Closed wcbeard closed 10 years ago

wcbeard commented 10 years ago

When I try querying Angular types in psci, the first query goes alright after compiling, but I get errors after subsequent queries:

$ psci src/**/*.purs bower_components/purescript-*/src/**/*.purs
> :i Angular.Http.Types
> :t fnHeader
*Compiling stuff*
Prim.String -> (Prelude.Unit -> Prim.String) -> Angular.Http.Types.Header
> :t fnHeader
Error at .psci_modules/node_modules/Angular.This/externs.purs line 7, column 1:
Error in module Angular.This
Unknown type 'Angular.This.WriteThis'

(Although it's not complaining about classes, it looks a little similar to purescript/purescript#562)

When I export , HttpEff() from Http.purs

and

, WriteThis()
, ReadThis()

from This.purs and re-compile and try again in psci, it again works on the first try. But when I query the type again, I get

> :t fnHeader
Error at .psci_modules/node_modules/Angular.Scope/externs.purs line 27, column 1:
Error in foreign import declaration apply
Cannot unify * with # *.

This file has the line

foreign import apply :: forall e r a. Angular.Scope.ApplyExpr e r a -> Angular.Scope.Scope a -> Control.Monad.Eff.Eff e r

I don't really follow this error. At this point I'm not sure if this is a bug with purescript, purescript-angular, or if I'm just not supposed to be using it in psci?

ethul commented 10 years ago

I think I have this fixed. I will push up a fix soon. It seems to be due to how the constructors are exported. For example, if we write

module Angular.Scope
  ( ...
  , ApplyExpr()
  , ...
  ) where

We get

Error in foreign import declaration apply
Cannot unify * with # *.

However, if we write

module Angular.Scope
  ( ...
  , ApplyExpr(..)
  , ...
  ) where

It compiles.