Skip to content

Instantly share code, notes, and snippets.

View i-am-the-slime's full-sized avatar
🪝

Mark Eibes i-am-the-slime

🪝
View GitHub Profile
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBH+PGmOOSfcfU5B2KF3PSbmahEka7QeLOH/FhpRJx2JwBu8w0M7dnPryIZulO3ErPsX2r+vFDq8+YHROexI7ZlE= [email protected]
@i-am-the-slime
i-am-the-slime / ObjectMap.purs
Last active February 3, 2024 17:12
Object that allows using any String newtype as the keys
module Sentence.Biz.Types.ObjectMap
( ObjectMap(..)
, empty
, isEmpty
, size
, singleton
, insert
, lookup
, toUnfoldable
, toAscUnfoldable
module BuildTime.GetMDXFiles where
import Prelude
import Node.FS.Aff (readTextFile, readdir)
import Data.Foldable (for_)
import Node.Glob.Basic (expandGlobsCwd)
import BuildTime.MDXBundler (EsbuildOptions, Extension(Extension), RehypePlugin, RemarkPlugin, addLoader, addRehypePlugins, addRemarkPlugins, bundleMDX, setPlatform)
import Node.Encoding (Encoding(..))
import Debug (spy)
import Effect.Aff (launchAff_)
module GraphQL.FunDeps where
import Prelude
import Data.Either (Either(..))
import Data.Foldable (foldMap)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Data.Semigroup.Foldable (intercalateMap)
import Data.String as String
module Main where
import Prelude
import Effect (Effect)
import TryPureScript (p, render, text)
import Data.Generic.Rep (class Generic, Constructor, Sum(..), from)
import Data.Reflectable (class Reflectable, reflectType)
import Type.Proxy (Proxy(..))

Motivation

Let's say we have the following data:

hobby :: { name :: String }
hobby = { name: "Football" }

Before visible type applications we could write this:

module SelectionManager where
import Yoga.Prelude.View
import Data.Set (Set)
import Data.Set as Set
import Hooks.UseSelectable (UseSelectable, UseSelectableResult, useSelectable)
type State a =
{ selection ∷ Set a
@i-am-the-slime
i-am-the-slime / PrintSideBySide.purs
Last active September 5, 2022 15:45
Print two strings side-by-side for easy comparison
module Main where
import Prelude
import Data.Array (intercalate, zip)
import Data.Foldable (fold)
import Data.String.Utils (lines, padEnd)
import Effect.Console (log)
import Data.Tuple.Nested ((/\))
import TryPureScript (render, code, text, p)
exports.purescriptSyntax = {
displayName: "Purescript",
name: "purescript",
mimeTypes: ["text/purescript"],
fileExtensions: ["purs"],
editorOptions: { tabSize: 2, insertSpaces: true },
lineComment: "--",
blockCommentStart: "{-",
blockCommentEnd: "-}",
keywords: [
data OnConflict = OnConflictDoNothing | OnConflictDoUpdate
-- | typeclass-alias for `genericShowInsert` constraints
class GenericShowInsertOnConflict t r where
genericShowInsertOnConflict
∷ { ph ∷ String }
→ Table t
→ Array { | r }
-> OnConflict
→ String