This is a simple tutorial that doesn't go deep into nix.
Use mkdir to create a new folder and cabal init to initialize a new cabal project.
Here are some tips I found useful for writing Haskell code that abstracts over effects, along with the articles that describe them.
ReaderT Config IO
,
where Config is a record with all the mutable references to everything
needed for the application.data SmallError = Error1 | Error2 | Error3 deriving (Show, Eq) | |
data MediumError = Error4 | Error5 | Error6 deriving (Show, Eq) | |
class HasSmallError e where | |
fromSmallError :: SmallError -> e | |
toSmallError :: e -> Maybe SmallError | |
class HasMediumError e where | |
fromMediumError :: MediumError -> e | |
toMediumError :: e -> Maybe MediumError |
use std::fmt::Debug; | |
use std::ptr::NonNull; | |
#[derive(Debug)] | |
pub struct DListNode<T: Debug> { | |
data: T, | |
next: Option<Box<DListNode<T>>>, | |
prev: Option<NonNull<DListNode<T>>>, | |
} |
cabal install ghcid
Plugin 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' }
:PluginInstall
to install the plugin.:Ghcid --restart=[project].cabal -c "stack repl --ghci-options=-fno-code"
where [project]
is the name of the project. If you want to load tests (but not load the app/Main module), run :Ghcid
.stack build
.
Ghcid will automatically restart and watch the new modules/dependencies.{-# LANGUAGE TypeInType #-} | |
module Main where | |
import Control.Concurrent.STM | |
import Control.Exception.Base | |
import Control.Monad.Except | |
import Control.Monad.Identity | |
import Control.Monad.Reader | |
import Control.Monad.State |
module Main where | |
import Control.Monad | |
import Data.List | |
newtype Indent = Indent { unIndent :: Int } deriving (Show, Eq) | |
squareText :: String -> Maybe String | |
squareText [] = Nothing | |
squareText [_] = Nothing |
module Main where | |
import Conduit | |
import Control.Concurrent (forkIO) | |
import Control.Concurrent.STM | |
import Data.Conduit.Network | |
import Data.ByteString hiding (putStrLn) | |
import Data.String | |
import qualified Data.STM.RollingQueue as RQ |
default-extensions: | |
- BangPatterns | |
- ConstraintKinds | |
- DataKinds | |
- DefaultSignatures | |
- DeriveFoldable | |
- DeriveFunctor | |
- DeriveGeneric | |
- DeriveLift | |
- DeriveTraversable |