Skip to content

Instantly share code, notes, and snippets.

View aitoroses's full-sized avatar

Aitor Oses aitoroses

View GitHub Profile
@aitoroses
aitoroses / README.md
Created December 10, 2024 08:18 — forked from disler/README.md
Use Meta Prompting to rapidly generate results in the GenAI Age

Meta Prompting

In the Generative AI Age your ability to generate prompts is your ability to generate results.

Guide

Claude 3.5 Sonnet and o1 series models are recommended for meta prompting.

Replace {{user-input}} with your own input to generate prompts.

Use mp_*.txt as example user-inputs to see how to generate high quality prompts.

@aitoroses
aitoroses / Free.re
Created August 18, 2022 15:01
Free Monads in ReasonML
module type Functor = {
type t('a);
let map: (t('a), 'a => 'b) => t('b);
};
module type Monad = {
type t('a);
let return: 'a => t('a);
let flatMap: (t('a), 'a => t('b)) => t('b);
@aitoroses
aitoroses / di-in-fp.md
Created May 13, 2022 15:14 — forked from gvolpe/di-in-fp.md
Dependency Injection in Functional Programming

Dependency Injection in Functional Programming

There exist several DI frameworks / libraries in the Scala ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.

A few of the most claimed benefits are the following:

  • Dependency Injection.
  • Life cycle management.
  • Dependency graph rewriting.
@aitoroses
aitoroses / AppM.purs
Created April 12, 2022 08:30
Purescript Example: Application Monad (AppM) with parallelization
type Env
= { hello :: String }
newtype AppM a
= AppM (ReaderT Env Aff a)
runAppM ∷ Env → AppM ~> Aff
runAppM env (AppM m) = runReaderT m env
@aitoroses
aitoroses / background.js
Created April 4, 2022 08:41 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
module Main where
import Prelude
import Control.Monad.Reader (Reader, runReader, ReaderT(..), runReaderT, ask, class MonadAsk)
import Effect (Effect)
import Effect.Class (class MonadEffect, liftEffect)
import Effect.Console (log)
---------------------------------------------------------
@aitoroses
aitoroses / AsyncEx.fs
Created March 14, 2021 20:15 — forked from panesofglass/AsyncEx.fs
Create an Observable from an F# Async.
module AsyncEx
open System
type Async<'a> with
member this.ToObservable() =
{ new IObservable<_> with
member x.Subscribe(o) =
if o = null then nullArg "observer"
let cts = new System.Threading.CancellationTokenSource()
let invoked = ref 0
@aitoroses
aitoroses / ReaderM.fs
Created February 27, 2021 11:56 — forked from CarstenKoenig/ReaderM.fs
Reader monad in F#
namespace ReaderM
type ReaderM<'d,'out> =
'd -> 'out
module Reader =
// basic operations
let run dep (rm : ReaderM<_,_>) =
@aitoroses
aitoroses / GADT.re
Created June 23, 2020 08:46
Using GADT's to parametrize functions
module Arg = {
type arg(_) =
| Arg(argument('a)): arg('a)
and argument('a) =
| Scalar({
name: option(string),
description: option(string),
validator: 'a => bool,
})
and arglist(_, _) =
@aitoroses
aitoroses / Eff.re
Created June 4, 2020 13:42
Tracking Effects in ReasonML
module Eff: {
type t('t, 'a);
let make: (unit => 'a) => t('t, 'a);
let run: t('t, 'a) => 'a;
let map: (t('t, 'a), 'a => 'b) => t('t, 'b);
let join: t('t, t('t, 'a)) => t('t, 'a);
let bind: (t('t, 'a), 'a => t('t, 'b)) => t('t, 'b);
} = {
type t('t, 'a) = unit => 'a;
let make: (unit => 'a) => t('t, 'a) = m => m;