Bae-no Backend Server Tech Stack
- Framework: Nest.JS
- API: GraphQL
- Database: MongoDB
- ORM: Prismawebsite·Indexed 30 days ago
https://jbl428.github.ioA comprehensive guide to learning Haskell by building a blog generator. The tutorial covers creating an HTML EDSL, parsing custom markup languages into Haskell data types, handling IO and error management with Either and ExceptT, and implementing a command-line interface using optparse-applicative. It also explores project specification with .cabal files, testing, and documentation using Haddock.
- Framework: Nest.JS
- API: GraphQL
- Database: MongoDB
- ORM: PrismaOption represents the presence or absence of a value, Either<E, A> is used to represent a computation that can either fail with a specific error of type E (Left) or succeed with a value of type A (Right).interface Left<E> { readonly _tag: 'Left'; readonly left: E }
interface Right<A> { readonly _tag: 'Right'; readonly right: A }
type Either<E, A> = Left<E> | Right<A>
const left = <E, A>(left: E): Either<E, A> => ({ _tag: 'Left', left })
const right = <A, E>(right: A): Either<E, A> => ({ _tag: 'Right', right })
const match = <E, R, A>(onLeft: (left: E) => R, onRight: (right: A) => R) =>
(fa: Either<E, A>): R => {
switch (fa._tag) {
case 'Left': return onLeft(fa.left)
case 'Right': return onRight(fa.right)
}
}f: (a: A) => F<B> with a pure unary function g: (b: B) => C using map(g). However, Functors are limited to unary functions. If a pure function g requires multiple parameters (e.g., two arguments), a standard Functor instance cannot transform g to operate on effectful values, necessitating the use of Applicative Functors.// Functor composition (Unary)
// f: (a: A) => F<B>
// g: (b: B) => C
// Result: map(g) ∘ fFunctional programming is built upon two core foundational elements:
Functional Programming (FP) is a paradigm that utilizes pure functions and mathematical models to manage system complexity.
Key concepts include:
The project uses a Hexagonal Architecture (Ports and Adapters pattern) to decouple business logic from infrastructure. The directory structure is divided into three main layers:
inbound port interfaces (for external use) and outbound port interfaces (used by services).outbound ports and use inbound ports to handle API requests and responses.sample
├── SampleModule.ts
├── adapter
│ ├── in
│ │ └── gql
│ │ ├── SampleMutationResolver.ts
│ │ ├── SampleQueryResolver.ts
│ │ └── SampleSubscriptionResolver.ts
│ └── out
│ └── persistence
│ ├── SampleOrmMapper.ts
│ └── SampleRepositoryAdapter.ts
├── application
│ ├── port
│ │ ├── in
│ │ │ └── SampleCommandUseCase.ts
│ │ └── out
│ │ └── SampleRepositoryPort.ts
│ └── service
│ └── SampleCommandService.ts
└── domain
└── Sample.tsenum class. This is referred to as a sum type in functional programming. Using an enum instead of a String reduces complexity and prevents invalid values from being assigned to the property.enum class AgeRestriction(val description: String) {
General("All ages admitted."),
PG("Parental guidance suggested"),
PG13("Parents urged to be cautious"),
Restricted("Under 17 requires guardian"),
NC17("No One 17 and Under Admitted")
}