-- Leak example from
-- convenience
parseStr :: String -> (String, String)
parseStr = packedPair . parse . unpacked where
packedPair (x,y) = (packed x, packed y)
parse :: [Char] -> ([Char], [Char])
parse [] = ([], [])
parse (' ': cs) = ([], cs)
View Balanced.purs
module Balanced where
import Prelude (Unit, discard, ($), (+), (-), (>=), (<=), (&&), (==), negate)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, logShow)
import Data.Foldable (traverse_, foldMap)
import Control.Monad.State (State, execState)
import Control.Monad.State.Class (modify)
import Data.String (toCharArray)
View FizzBuzz.idr
module FizzBuzz
import Data.Vect
Rule : Type
Rule = (n: Int) -> (old: List String) -> (List String)
everyNthRule : (every: Int) -> (replacement: String) -> Rule
everyNthRule every replacement n old =
if (mod n every == 0) then old ++ [replacement] else old
View Either.groovy
// Either type in Groovy as a special implementation of the generic sum type
// see: Phil Wadler at LambdaWorld 2016:
import java.util.function.*
import groovy.transform.*
interface Either<A,B> {
public <C> C match (Function <A,C> leftCase, Function <B,C> rightCase)
View MultipleButtonsDemo.groovy
import static groovyx.javafx.GroovyFX.start
Demo of using methods to create multiple nodes (here Buttons) as a composite view and use those
factory methods multiple times.
@author Dierk Koenig
start {
sgb = delegate
module Ants where
import STM
import Control.Concurrent (forkIO, forkOS)
import Data.List (!!, nub, sortBy)
import System.Random
View Counter.tsx
import * as React from "react";
export interface HelloProps { compiler: string; framework: string; }
export interface HelloState { slices: number; table: number }
export class Hello extends React.Component<HelloProps, HelloState> {
constructor(props: HelloProps) {
this.state = { slices:10, table:2 }
View Counter.elm
import Html exposing (Html, button, div, text)
import Html.App as App
import Html.Events exposing (onClick)
import Svg exposing (svg, circle, line)
import Svg.Attributes exposing (..)
import List exposing (map, (::))
main =
App.beginnerProgram { model = state, view = view, update = update }
View Counter.purs
module App.Counter where
import Prelude (($), (+), (-), (*), (/), (>), const, show)
import Data.Array ((..), (:), mapWithIndex)
import Data.Int (toNumber, floor)
import Math (sin, cos, pi )
import Pux.Html (Html, div, span, button, text, canvas, svg, circle, line )
import Pux.Html.Attributes (width, height, viewBox, cx, cy, r, fill, x1, y1, x2, y2, stroke, strokeWidth)
import Pux.Html.Events (onClick)
View Main.purs
module Main where
import Control.Monad.Eff.Console (log)
import Data.List.Lazy (take, zipWith, fromFoldable, cycle, iterate, foldr)
import Data.Monoid (mempty, (<>))
import Data.Maybe (Maybe(..), fromMaybe)
import Prelude ( show, map, ($), (+))
main = do