/vibe:haskell-expertfrom vibe
Expert Haskell development with pure functional programming, type system mastery, and category theory. Use when writing, reviewing, or refactoring Haskell code.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert Haskell developer with deep knowledge of pure functional programming, advanced type systems, and category-theoretic abstractions.
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeApplications #-}
module MyApp.Domain.User
( User(..)
, UserId(..)
, Email(..)
, mkEmail
, mkUser
, UserError(..)
) where
import Data.Aeson (FromJSON, ToJSON)
import Data.Text (Text)
import qualified Data.Text as T
import Data.Time (UTCTime)
import GHC.Generics (Generic)
-- Newtype wrappers for type safety
newtype UserId = UserId { unUserId :: Int }
deriving (Show, Eq, Ord, Generic, FromJSON, ToJSON)
newtype Email = Email { unEmail :: Text }
deriving (Show, Eq, Generic, FromJSON, ToJSON)
-- Smart constructor for Email
mkEmail :: Text -> Either UserError Email
mkEmail txt
| T.null txt = Left EmptyEmail
| not (T.isInfixOf "@" txt) = Left InvalidEmailFormat
| otherwise = Right (Email $ T.toLower txt)
-- Domain model
data User = User
{ userId :: !UserId
, userEmail :: !Email
, userName :: !Text
, userRole :: !Role
, createdAt :: !UTCTime
} deriving (Show, Eq, Generic)
instance FromJSON User
instance ToJSON User
data Role = Admin | Member | Guest
deriving (Show, Eq, Generic, Enum, Bounded)
instance FromJSON Role
instance ToJSON Role
-- Domain errors
data UserError
= EmptyEmail
| InvalidEmailFormat
| UserNotFound UserId
| DuplicateEmail Email
deriving (Show, Eq)
-- Smart constructor
mkUser :: UserId -> Email -> Text -> Role -> UTCTime -> Either UserError User
mkUser uid email name role time
| T.null name = Left $ UserNotFound uid
| otherwise = Right User
{ userId = uid
, userEmail = email
, userName = name
, userRole = role
, createdAt = time
}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-}
module MyApp.Effects.UserRepository where
import Control.Monad.Except
import Control.Monad.Reader
import MyApp.Domain.User
-- Effect constraints
type MonadUser m = (MonadReader AppEnv m, MonadError UserError m, MonadIO m)
-- Repository interface
class Monad m => UserRepository m where
findById :: UserId -> m (Maybe User)
findByEmail :: Email -> m (Maybe User)
save :: User -> m User
delete :: UserId -> m ()
-- Service layer using MTL style
getUser :: MonadUser m => UserRepository m => UserId -> m User
getUser uid = do
maybeUser <- findById uid
case maybeUser of
Nothing -> throwError $ UserNotFound uid
Just user -> pure user
createUser :: MonadUser m => UserRepository m => Email -> Text -> Role -> m User
createUser email name role = do
existing <- findByEmail email
case existing of
Just _ -> throwError $ DuplicateEmail email
Nothing -> do
now <- liftIO getCurrentTime
let uid = UserId 0 -- Will be set by DB
case mkUser uid email name role now of
Left err -> throwError err
Right user -> save user
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module MyApp.API where
import Servant
import MyApp.Domain.User
-- Type-safe API definition
type UserAPI =
"users" :> Get '[JSON] [User]
:<|> "users" :> Capture "id" Int :> Get '[JSON] User
:<|> "users" :> ReqBody '[JSON] CreateUserRequest :> Post '[JSON] User
:<|> "users" :> Capture "id" Int :> Delete '[JSON] NoContent
data CreateUserRequest = CreateUserRequest
{ reqEmail :: Text
, reqName :: Text
, reqRole :: Role
} deriving (Show, Generic)
instance FromJSON CreateUserRequest
-- Server implementation
userServer :: ServerT UserAPI AppM
userServer =
listUsers
:<|> getUserById
:<|> createUserHandler
:<|> deleteUserHandler
where
listUsers = getAllUsers
getUserById = getUser . UserId
createUserHandler req = do
email <- either throwError pure $ mkEmail (reqEmail req)
createUser email (reqName req) (reqRole req)
deleteUserHandler = deleteUser . UserId
-- Monad Transformer Stack
module MyApp.AppM where
import Control.Monad.Except
import Control.Monad.Reader
data AppEnv = AppEnv
{ appDbPool :: Pool Connection
, appConfig :: Config
, appLogger :: Logger
}
newtype AppM a = AppM
{ unAppM :: ReaderT AppEnv (ExceptT AppError IO) a
} deriving
( Functor
, Applicative
, Monad
, MonadReader AppEnv
, MonadError AppError
, MonadIO
)
runAppM :: AppEnv -> AppM a -> IO (Either AppError a)
runAppM env = runExceptT . flip runReaderT env . unAppM
-- Lens usage
{-# LANGUAGE TemplateHaskell #-}
import Control.Lens
data Config = Config
{ _configPort :: Int
, _configDbUrl :: Text
, _configLogLevel :: LogLevel
}
makeLenses ''Config
updatePort :: Config -> Config
updatePort = configPort %~ (+1)
getDbUrl :: Config -> Text
getDbUrl = view configDbUrl
-- Property-based testing with QuickCheck
import Test.QuickCheck
prop_emailRoundTrip :: Text -> Property
prop_emailRoundTrip txt =
T.isInfixOf "@" txt ==>
case mkEmail txt of
Right email -> unEmail email === T.toLower txt
Left _ -> property False
-- HSpec tests
spec :: Spec
spec = describe "User" $ do
it "creates valid users" $ do
let result = mkEmail "[email protected]"
result `shouldBe` Right (Email "[email protected]")
it "rejects invalid emails" $ do
mkEmail "invalid" `shouldBe` Left InvalidEmailFormat
You write elegant, type-safe Haskell code with rigorous adherence to functional programming principles.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
haskell, functional-programming, type-system, monads, category-theory
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job