This guide outlines an approach to overcome some problems with concrete monad stacks and monad composition.
So we're writing some code in IO, and everything is going great:
doStuff :: IO Int
doStuff = do
drv = | |
pkgs.haskell.lib.addBuildDepends | |
(pkgs.haskellPackages.callPackage ./default.nix {}) | |
(with pkgs; [ docker ]) | |
; |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
module DynamicReader where | |
import Control.Monad.Reader (MonadReader(ask, local), ask, ReaderT(ReaderT), runReaderT) |
class HasLoggingRep a where | |
toLogEntry :: a -> Text | |
-- ... | |
where | |
logInfo :: forall a . HasLoggingRep a => a -> IO () | |
logInfo = loggerF logger Info . toLogEntry | |
-- ... | |
someFn response = do | |
logInfo response |
module ConstraintsOnFunction (mkLookup) where | |
type Lookup m = Request -> m Response | |
mkLookup :: ( | |
AsSomeError e, | |
MonadCatch m, | |
MonadError e m, | |
MonadIO m, | |
MonadResource m) => Lookup m |
someFn :: b -> m a -> m a | |
someStack :: ActionT e m a | |
someStack = do | |
r <- ask | |
info = r ^. getInfo | |
lift $ someFn info _ |
A guide to setting up the Haskell tooling for Emacs in a Nix environment.
# Running Emacs Haskell Tooling in a Nix environment | |
A guide to setting up the Haskell tooling for Emacs in a Nix environment. | |
## Configuration | |
### Requirements | |
You will need the following packages: |
fn | |
:: ( Monad m | |
, MonadReader r m | |
, HasX r m | |
, HasY r m | |
, HasZ r m | |
) | |
=> m Bool | |
fn = do | |
r <- ask |
• Couldn't match type ‘a’ with ‘a1’ | |
‘a’ is a rigid type variable bound by | |
the type signature for: | |
mogel :: forall a. Show a => a -> (String, a) | |
at src/Types.hs:105:1-48 | |
‘a1’ is a rigid type variable bound by | |
the type signature for: | |
b :: forall a1. Show a1 => Maybe a1 | |
at src/Types.hs:108:5-39 | |
Expected type: Maybe a1 |