I'm trying to get the current POSIX time from the system clock using Haskell but get the following error:
• No instance for (Show (IO POSIXTime))
arising from the sixth field of ‘Block’ (type ‘IO POSIXTime’)
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (Show Block)
|
16 | , nonce :: Maybe Integer } deriving Show
| ^^^^
Here is the code for context:
import Data.Time
import Data.Time.Clock.POSIX
data Transaction = Transaction { from :: String
, to :: String
, value :: Float } deriving Show
data Block = Block { version :: Int
, index :: Int
, transactions :: [Transaction]
, prevBlockHash :: String
, merkleRootHash :: String
, time :: IO POSIXTime
, nonce :: Maybe Integer } deriving Show
genesis :: Block
genesis = Block version index transactions prevBlockHash merkleRootHash time Nothing
where version = 1
index = 0
transactions = []
prevBlockHash = "000000000000000000000000000000000"
merkleRootHash = ""
time = getPOSIXTime
nonce = Nothing
I've referenced a number of solutions to similar questions on stack overflow but haven't been able to get past the error for a few days.