One question:
getBlockChain :: (SpockState m ~ BlockChainState, MonadIO m, HasSpock m) => m [Block]
What does the squiggle mean?One question:
getBlockChain :: (SpockState m ~ BlockChainState, MonadIO m, HasSpock m) => m [Block]
What does the squiggle mean?https://github.com/garry-sharp/x/tree/master/CA4/HydraLib-0....
After reading for just an hour, the lightbulb came on and I not-only felt I had learned how a digital simulator works but also what a mighty hammer Haskell can be for teaching.
Since then I've read (and unfortunately written) a lot of Haskell that is far less elucidating. It's great to come across something that reminds me how I got turned on in the first place and that I should aspire to produce code that not-only barely gets the job done but also explains itself and embodies a modicum of beauty. Thanks again.
(BlockChainState chain _ _) <- getState
But it has to be anyway so, I guess I'm still confused. Is the squiggle for extra documentation or is it a hint to help the type inference? Why would type inference need help? Does it have to do with some of the extensions that are applied in the source (but appear to be otherwise unused)?It should be noted that it's entirely possible there's a less confusing way to write that type signature. I'm far from an expert in Haskell.
One thing I see people doing when they have real gnarly type signature is to concentrate the horror in one place and paint a veneer of simplicity elsewhere:
type Get stateType returnType
= forall monad.
(SpockState monad ~ stateType, MonadIO monad, HasSpock monad)
=> monad returnType
Then elsewhere: getBlockChain :: Get BlockChainState [Block]
getLatestBlock :: Get BlockChainState Block
This may only help superficially as type errors will still be hard-to-understand.