obsidiansystems / obelisk

Functional reactive web and mobile applications, with batteries included.
https://reflex-frp.org
BSD 3-Clause "New" or "Revised" License
958 stars 107 forks source link

Ambiguous module name ‘Crypto.Hash’ #395

Closed clojurians-org closed 5 years ago

clojurians-org commented 5 years ago

module conflicit occurs when i add some module to backend/backend.cabal..

how should i fix this problem under obelisk?

Prelude Obelisk.Run> import Crypto.Hash

<no location info>: error:
    Ambiguous module name ‘Crypto.Hash’:
      it was found in multiple packages:
      cryptohash-0.11.9 cryptonite-0.25
larrys-MBP:edmp-plugins larluo$ cat frontend/frontend.cabal 
name: frontend
version: 0.1
cabal-version: >= 1.8
build-type: Simple

library
  hs-source-dirs: src
  build-depends: base
               , common
               , obelisk-frontend
               , obelisk-route
               , reflex-dom
               , obelisk-generated-static
               , text
  exposed-modules:
    Frontend
  ghc-options: -Wall

executable frontend
  main-is: main.hs
  hs-source-dirs: src-bin
  build-depends: base
               , common
               , obelisk-frontend
               , obelisk-route
               , reflex-dom
               , obelisk-generated-static
               , frontend
  --TODO: Make these ghc-options optional
  ghc-options: -threaded
  if os(darwin)
     ghc-options: -dynamic

larrys-MBP:edmp-plugins larluo$ cat backend/backend.cabal
name: backend
version: 0.1
cabal-version: >= 1.8
build-type: Simple

library
  hs-source-dirs: src
  if impl(ghcjs)
    buildable: False
  build-depends: base
               , common
               , frontend
               , obelisk-backend
               , obelisk-route
               , http-client
               , http-client-tls
               , cryptonite
               , servant
               , servant-client
  exposed-modules:
    Backend
  ghc-options: -Wall

executable backend
  main-is: main.hs
  hs-source-dirs: src-bin
  if impl(ghcjs)
    buildable: False
  build-depends: base
               , backend
               , common
               , frontend
               , obelisk-backend

larrys-MBP:edmp-plugins larluo$ cat common/common.cabal 
name: common
version: 0.1
cabal-version: >= 1.2
build-type: Simple

library
  hs-source-dirs: src
  build-depends: base
               , obelisk-route
               , mtl
               , text
  default-extensions:
    TypeFamilies
    PolyKinds
  exposed-modules:
    Common.Api
    Common.Route
clojurians-org commented 5 years ago

i use "ob init" to create empty project, the same error occur.

larrys-MBP:test larluo$ ob --no-handoff repl
GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
[1 of 4] Compiling Common.Api       ( common/src/Common/Api.hs, interpreted )
[2 of 4] Compiling Common.Route     ( common/src/Common/Route.hs, interpreted )
[3 of 4] Compiling Backend          ( backend/src/Backend.hs, interpreted )
[4 of 4] Compiling Frontend         ( frontend/src/Frontend.hs, interpreted )
Ok, four modules loaded.
Loaded GHCi configuration from /private/var/folders/_3/80s5534109d2j83cfgtwjcjc0000gn/T/ob-ghci-bd8b990800beaccf/.ghci
*Backend Obelisk.Run Frontend Backend> import Crypto.Hash

<no location info>: error:
    Ambiguous module name ‘Crypto.Hash’:
      it was found in multiple packages:
      cryptohash-0.11.9 cryptonite-0.25
alexfmpe commented 5 years ago

I ran into this a week ago with Crypto.Hash as well - since obelisk throws the common/backend/frontend ~modules~ packages into the same ghci, and ghci doesn't "sandbox" them, the likelihood of conflicting modules/extensions increases.

You can disambiguate the import, via PackageImports e.g. import "cryptonite" Crypto.Hash

alexfmpe commented 5 years ago

Added to FAQ.md: #396