input-output-hk / cardano-sl

Cryptographic currency implementing Ouroboros PoS protocol
Apache License 2.0
3.76k stars 631 forks source link

stack ghci failing #2214

Open h4ck3rm1k3 opened 6 years ago

h4ck3rm1k3 commented 6 years ago

Trying to load cardano into stack ghci gives me errors. stack ghci --no-load

And then :l Pos.Core.Class

Gives me errors due to Universum not being used

[35 of 51] Compiling Mockable.Class   ( /home/mdupont/experiments/cardano-sl/networking/src/Mockable/Class.hs, interpreted )

/home/mdupont/experiments/cardano-sl/networking/src/Mockable/Class.hs:30:9: error:
    Not in scope: type constructor or class ‘Monad’
Failed, modules loaded: Pos.Binary.Class, Pos.Binary.Class.Core, Pos.Binary.Class.Numbers, Pos.Binary.Class.Primitive, Pos.Binary.Class.TH, Pos.Binary.Crypto\
, Pos.Core.Common, Pos.Core.Common.Address, Pos.Core.Common.Coin, Pos.Core.Common.Fee, Pos.Core.Common.Types, Pos.Core.Constants, Pos.Crypto, Pos.Crypto.AsBi\
nary, Pos.Crypto.Configuration, Pos.Crypto.Encryption, Pos.Crypto.HD, Pos.Crypto.Hashing, Pos.Crypto.Random, Pos.Crypto.Scrypt, Pos.Crypto.SecretSharing, Pos\
.Crypto.Signing, Pos.Crypto.Signing.Redeem, Pos.Crypto.Signing.Safe, Pos.Crypto.Signing.Signing, Pos.Crypto.Signing.Tag, Pos.Crypto.Signing.Types, Pos.Crypto\
.Signing.Types.Redeem, Pos.Crypto.Signing.Types.Safe, Pos.Crypto.Signing.Types.Signing, Pos.Crypto.Signing.Types.Tag, Pos.Data.Attributes, Pos.Util.Some, Pos\
.Util.Util.
*Pos.Core.Common> 

I have create a PR for this

p-alik commented 6 years ago

:l Pos.Core works fine in my environment.

$ nixos-version 
17.09.1971.937ea32f1f (Hummingbird)
$ stack --version
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.
$ git log -n1 --oneline
57e271054 (HEAD -> master, origin/master) [DEVOPS-61] Rewrite appveyor caching (#2178)

Build instructions I used:

$ nix-shell
$ ./scripts/build/cardano-sl.sh
h4ck3rm1k3 commented 6 years ago

thanks

p-alik commented 6 years ago

no issue on Ubuntu 16.04.

Build instructions:

h4ck3rm1k3 commented 6 years ago

I am going to have to review this and reopen later if needed.

p-alik commented 6 years ago

@h4ck3rm1k3, after rebuilding cardano-sl project based on c489f3ecd I got the issue you described.

So at the end I added some lazy import Universum lines to be able to load Pos.Core.Class.

diff --git a/networking/src/Mockable/Channel.hs b/networking/src/Mockable/Channel.hs
index b3fdfc531..f9c5a0dab 100644
--- a/networking/src/Mockable/Channel.hs
+++ b/networking/src/Mockable/Channel.hs
@@ -18,6 +18,8 @@ module Mockable.Channel (

 import           Mockable.Class (MFunctor' (hoist'), Mockable (liftMockable))

+import           Universum
+
 type family ChannelT (m :: * -> *) :: * -> *

 data Channel (m :: * -> *) (t :: *) where
diff --git a/networking/src/Mockable/Class.hs b/networking/src/Mockable/Class.hs
index 9e7e48e16..60896a7e9 100644
--- a/networking/src/Mockable/Class.hs
+++ b/networking/src/Mockable/Class.hs
@@ -13,6 +13,7 @@ module Mockable.Class
   ) where

 import           Data.Kind (Constraint)
+import Universum (Monad)

 class MFunctor' f m n where
     hoist' :: (forall a . m a -> n a) -> f m t -> f n t
diff --git a/networking/src/Mockable/Concurrent.hs b/networking/src/Mockable/Concurrent.hs
index 5e0c50884..140ede9c4 100644
--- a/networking/src/Mockable/Concurrent.hs
+++ b/networking/src/Mockable/Concurrent.hs
@@ -51,6 +51,8 @@ import           Data.Time.Units (TimeUnit)
 import           Mockable.Class
 import           Mockable.Exception

+import           Universum -- (Applicative(..), Maybe(..), Either(..), Functor(..), Traversable(..), Eq,  (.), ($), (<$), flip, snd, const)
+
 type family ThreadId (m :: * -> *) :: *

 -- | Fork mock to add ability for threads manipulation.
diff --git a/networking/src/Mockable/Exception.hs b/networking/src/Mockable/Exception.hs
index d78c1a3be..fcb8ff4b0 100644
--- a/networking/src/Mockable/Exception.hs
+++ b/networking/src/Mockable/Exception.hs
@@ -33,6 +33,7 @@ module Mockable.Exception (

 import           Control.Exception (Exception, SomeException)
 import           Mockable.Class (MFunctor' (hoist'), Mockable (liftMockable))
+import           Universum (Maybe(..), Either(..), (.), (>>), ($), const, fmap, flip, return)

 data Bracket (m :: * -> *) (t :: *) where
     Mask_ :: m a -> Bracket m a
diff --git a/networking/src/Mockable/Instances.hs b/networking/src/Mockable/Instances.hs
index f6cb8b5f5..960dc3cfe 100644
--- a/networking/src/Mockable/Instances.hs
+++ b/networking/src/Mockable/Instances.hs
@@ -21,6 +21,8 @@ import           Mockable.Metrics
 import           Mockable.SharedAtomic (SharedAtomicT)
 import           Mockable.SharedExclusive (SharedExclusiveT)

+import           Universum hiding (view)
+
 instance (Mockable d m, MFunctor' d (ReaderT r m) m) => Mockable d (ReaderT r m) where
     liftMockable dmt = ReaderT $ \r -> liftMockable $ hoist' (flip runReaderT r) dmt

diff --git a/networking/src/Mockable/Metrics.hs b/networking/src/Mockable/Metrics.hs
index 55d6d5aca..b7ec89524 100644
--- a/networking/src/Mockable/Metrics.hs
+++ b/networking/src/Mockable/Metrics.hs
@@ -32,6 +32,8 @@ module Mockable.Metrics (
 import           Data.Int (Int64)
 import           Mockable.Class

+import           Universum
+
 type family Gauge (m :: * -> *) :: *
 type family Counter (m :: * -> *) :: *
 type family Distribution (m :: * -> *) :: *
diff --git a/networking/src/Mockable/Monad.hs b/networking/src/Mockable/Monad.hs
index 2bf717efb..1fe52a611 100644
--- a/networking/src/Mockable/Monad.hs
+++ b/networking/src/Mockable/Monad.hs
@@ -16,6 +16,8 @@ import           Mockable.Metrics (Metrics)
 import           Mockable.SharedAtomic (SharedAtomic)
 import           Mockable.SharedExclusive (SharedExclusive)

+import           Universum
+
 -- | Bunch of Mockable-constraints.
 type MonadMockable m
     = ( Mockable Delay m
diff --git a/networking/src/Mockable/Production.hs b/networking/src/Mockable/Production.hs
index fccd50bdf..e8fe88418 100644
--- a/networking/src/Mockable/Production.hs
+++ b/networking/src/Mockable/Production.hs
@@ -40,6 +40,9 @@ import qualified Mockable.Metrics as Metrics
 import           Mockable.SharedAtomic (SharedAtomic (..), SharedAtomicT)
 import           Mockable.SharedExclusive (SharedExclusive (..), SharedExclusiveT)

+import           Universum hiding (catch)
+import           GHC.Base (id)
+
 newtype Production t = Production
     { runProduction :: IO t
     } deriving (Functor, Applicative, Monad)
diff --git a/networking/src/Mockable/SharedAtomic.hs b/networking/src/Mockable/SharedAtomic.hs
index f227e09f2..d06e6208d 100644
--- a/networking/src/Mockable/SharedAtomic.hs
+++ b/networking/src/Mockable/SharedAtomic.hs
@@ -18,6 +18,8 @@ module Mockable.SharedAtomic (

 import           Mockable.Class (MFunctor' (hoist'), Mockable (liftMockable))

+import           Universum
+
 type family SharedAtomicT (m :: * -> *) :: * -> *

 data SharedAtomic (m :: * -> *) (t :: *) where
diff --git a/networking/src/Mockable/SharedExclusive.hs b/networking/src/Mockable/SharedExclusive.hs
index 21d0c6ff5..f880d128d 100644
--- a/networking/src/Mockable/SharedExclusive.hs
+++ b/networking/src/Mockable/SharedExclusive.hs
@@ -20,6 +20,8 @@ module Mockable.SharedExclusive (

 import           Mockable.Class (MFunctor' (hoist'), Mockable (liftMockable))

+import           Universum
+
 type family SharedExclusiveT (m :: * -> *) :: * -> *

 data SharedExclusive (m :: * -> *) (t :: *) where

It looks like there is no issue with Pos.Core.Class only on master branch. See (#issuecomment-354642054). I think you have to reopen the issue again.