Code Snippets PureScript

Short texts PureScript 🧑‍💻 Code snippets PureScript ✍️ Reading lists PureScript 👀

Loop from Ableton

module Main where import Prelude import Control.Comonad (extract) import Control.Comonad.Cofree ((: FoldingWithIndex InstrumentsToScore (Proxy prop) (V.Vec n (NonEmpty Array ScoreRep)) (NonEmpty Array (Note Int)) (V.Vec nPlus1 (NonEmpty Array ScoreRep)) where foldingWithIndex InstrumentsToScore prop v nea = V.cons ( map ( \(Note vol st ed) -> ScoreRep { volume: toNumber vol / 127.0 , startsAt: toNumber […]

Generic to row

module Main where import Prelude import Data.Foldable (fold) import Effect (Effect) import TryPureScript (h1, h2, p, text, list, indent, link, render, code) import Data.Generic.Rep (class Generic, Argument(..), Constructor(..), Product(..), from) import Data.Symbol (class IsSymbol) import Data.Typelevel.Num (class Nat, class Succ, type (:*), D0, D1, D2, D3, D4, D5, D6, D7, D8, D9) import Effect (Effect) […]

impredicative.purs

module Main where import Prelude hiding (show) import Prelude as Prelude import Data.Foldable (fold) import Effect (Effect) import TryPureScript (p, text, render) newtype Identity a = Identity a runIdentity :: forall a. Identity a -> a runIdentity (Identity x) = x — DOES NOT WORK 🙁 — myWrappedShow1 :: Identity (forall a. Show a => […]

Formless + Halogen Store

module Main where import Prelude import Data.Newtype (class Newtype, unwrap) import Data.Either (Either(..)) import Data.Int as Int import Data.Maybe (Maybe(..)) import Effect (Effect) import Effect.Aff.Class (class MonadAff) import Effect.Class (liftEffect) import Effect.Class.Console (logShow) import Formless as F import Halogen as H import Halogen.Aff as HA import Halogen.HTML as HH import Halogen.HTML.Events as HE import Halogen.HTML.Properties […]

a purescript solution to the Leetcode twosum problem

module TwoSum where import Data.Array (head, tail) import Data.HashMap import Data.Maybe import Effect import Prelude import Data.Foldable (for_) import Effect.Console (log) {- https://leetcode.com/problems/two-sum/ Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly […]