All Projects → sectore → program-imperatively-using-purescript

sectore / program-imperatively-using-purescript

Licence: other
Program imperatively using PureScript, State monad and lenses

Programming Languages

purescript
368 projects

Labels

Projects that are alternatives of or similar to program-imperatively-using-purescript

Lambda
Functional patterns for Java
Stars: ✭ 737 (+3104.35%)
Mutual labels:  lenses
Elm Monocle
Functional abstractions to manipulate complex records in Elm - Iso, Prism, Lens, Optional, Traversal.
Stars: ✭ 137 (+495.65%)
Mutual labels:  lenses
xml-lens
XML Optics library for Scala
Stars: ✭ 32 (+39.13%)
Mutual labels:  lenses
Lens
A Racket package for creating and composing pure functional lenses
Stars: ✭ 54 (+134.78%)
Mutual labels:  lenses
Lens Regex Pcre
Text lenses using PCRE regexes
Stars: ✭ 116 (+404.35%)
Mutual labels:  lenses
Documentation
How does it all fit together?
Stars: ✭ 177 (+669.57%)
Mutual labels:  lenses
Monocle Ts
Functional optics: a (partial) porting of Scala monocle
Stars: ✭ 657 (+2756.52%)
Mutual labels:  lenses
futils
Utilities for generic functional programming
Stars: ✭ 21 (-8.7%)
Mutual labels:  lenses
Typed
The TypeScript Standard Library
Stars: ✭ 124 (+439.13%)
Mutual labels:  lenses
Microlens
A lightweight (but compatible with ‘lens’) lenses library
Stars: ✭ 254 (+1004.35%)
Mutual labels:  lenses
Prolens
👓 Profunctor based lightweight implementation of Lenses
Stars: ✭ 63 (+173.91%)
Mutual labels:  lenses
Datum
pure functional and generic programming for Erlang
Stars: ✭ 111 (+382.61%)
Mutual labels:  lenses
Python Lenses
A python lens library for manipulating deeply nested immutable structures
Stars: ✭ 179 (+678.26%)
Mutual labels:  lenses
Dart functional data
Simple and non-intrusive code generator for lenses and boilerplate of data types
Stars: ✭ 39 (+69.57%)
Mutual labels:  lenses
lentes
Functional references for Clojure and ClojureScript
Stars: ✭ 80 (+247.83%)
Mutual labels:  lenses
Frunk
Funktional generic type-level programming in Rust: HList, Coproduct, Generic, LabelledGeneric, Validated, Monoid and friends.
Stars: ✭ 725 (+3052.17%)
Mutual labels:  lenses
Sauron
Yet another Scala lens macro
Stars: ✭ 166 (+621.74%)
Mutual labels:  lenses
exercises-monocle
Scala Exercises for the Scala Optics library Monocle http://julien-truffaut.github.io/Monocle/
Stars: ✭ 12 (-47.83%)
Mutual labels:  lenses
lenticular.ts
(Yet another) implementation of functional lenses in JavaScript/TypeScript.
Stars: ✭ 29 (+26.09%)
Mutual labels:  lenses
Focus
Lightweight Elixir lenses
Stars: ✭ 224 (+873.91%)
Mutual labels:  lenses

Program imperatively with PureScript using State and Lenses

I guess people really aren't joking when they say Haskell is the finest imperative language.

Quote by Gabriel Gonzalez at his famous blog post "Program imperatively using Haskell lenses"

👾 👾 👾 Let's have with PureScript an another finest imperative language! 👾 👾 👾

That's why you will find here all code of Program imperatively using Haskell lenses (originally written by @Gabriel439) ported to PureScript.

The fun part with lenses are supported by purescript-profunctor-lenses

Have fun 😎

How to ...?

Read the code

To understand all code start to read the original Haskell tutorial. Compare the original Haskell examples with the following PureScript files:

Run

npm install
npm start

Output

##################
Getter / Setter
##################

# get score
0

# set score
(Game { boss: (GameUnit { health: 100, position: (GamePoint { x: 0.0, y: 0.0 }) }), score: 10000, units: [(GameUnit { health: 10, position: (GamePoint { x: 3.5, y: 7.0 }) }),(GameUnit { health: 15, position: (GamePoint { x: 1.0, y: 1.0 }) }),(GameUnit { health: 8, position: (GamePoint { x: 0.0, y: 2.1 }) })] })

# update score
(Game { boss: (GameUnit { health: 100, position: (GamePoint { x: 0.0, y: 0.0 }) }), score: 222, units: [(GameUnit { health: 10, position: (GamePoint { x: 3.5, y: 7.0 }) }),(GameUnit { health: 15, position: (GamePoint { x: 1.0, y: 1.0 }) }),(GameUnit { health: 8, position: (GamePoint { x: 0.0, y: 2.1 }) })] })

##################
Composition
##################

# strike
*shink*
(Game { boss: (GameUnit { health: 133, position: (GamePoint { x: 0.0, y: 0.0 }) }), score: 0, units: [(GameUnit { health: 10, position: (GamePoint { x: 3.5, y: 7.0 }) }),(GameUnit { health: 15, position: (GamePoint { x: 1.0, y: 1.0 }) }),(GameUnit { health: 8, position: (GamePoint { x: 0.0, y: 2.1 }) })] })

# strike'
*shink*
(Game { boss: (GameUnit { health: 133, position: (GamePoint { x: 0.0, y: 0.0 }) }), score: 0, units: [(GameUnit { health: 10, position: (GamePoint { x: 3.5, y: 7.0 }) }),(GameUnit { health: 15, position: (GamePoint { x: 1.0, y: 1.0 }) }),(GameUnit { health: 8, position: (GamePoint { x: 0.0, y: 2.1 }) })] })

##################
Traversal
##################

# fireBreath
*srawr*
(Game { boss: (GameUnit { health: 100, position: (GamePoint { x: 0.0, y: 0.0 }) }), score: 0, units: [(GameUnit { health: 7, position: (GamePoint { x: 3.5, y: 7.0 }) }),(GameUnit { health: 12, position: (GamePoint { x: 1.0, y: 1.0 }) }),(GameUnit { health: 5, position: (GamePoint { x: 0.0, y: 2.1 }) })] })

# fireBreath'
*srawr*
(Game { boss: (GameUnit { health: 100, position: (GamePoint { x: 0.0, y: 0.0 }) }), score: 0, units: [(GameUnit { health: 10, position: (GamePoint { x: 3.5, y: 7.0 }) }),(GameUnit { health: 12, position: (GamePoint { x: 1.0, y: 1.0 }) }),(GameUnit { health: 5, position: (GamePoint { x: 0.0, y: 2.1 }) })] })

##################
Zooming
##################

# partyLoc
((GamePoint { x: 3.5, y: 7.0 }) : (GamePoint { x: 1.0, y: 1.0 }) : (GamePoint { x: 0.0, y: 2.1 }) : Nil)

# retreat
Retreat!
(Game { boss: (GameUnit { health: 100, position: (GamePoint { x: 0.0, y: 0.0 }) }), score: 0, units: [(GameUnit { health: 10, position: (GamePoint { x: 3.5, y: 17.0 }) }),(GameUnit { health: 15, position: (GamePoint { x: 1.0, y: 11.0 }) }),(GameUnit { health: 8, position: (GamePoint { x: 0.0, y: 12.1 }) })] })

# retreat newstate
Retreat!
((GamePoint { x: 3.5, y: 17.0 }) : (GamePoint { x: 1.0, y: 11.0 }) : (GamePoint { x: 0.0, y: 12.1 }) : Nil)
Retreat!
((GamePoint { x: 3.5, y: 17.0 }) : (GamePoint { x: 1.0, y: 11.0 }) : (GamePoint { x: 0.0, y: 12.1 }) : Nil)

##################
Combining
##################

# battle
Take that!
*shink*
and that!
*shink*
and that!
*shink*
*srawr*
Retreat!
Retreat!
Retreat!
(Game { boss: (GameUnit { health: 199, position: (GamePoint { x: 0.0, y: 0.0 }) }), score: 0, units: [(GameUnit { health: 10, position: (GamePoint { x: 3.5, y: 67.0 }) }),(GameUnit { health: 12, position: (GamePoint { x: 1.0, y: 61.0 }) }),(GameUnit { health: 5, position: (GamePoint { x: 0.0, y: 62.1 }) })] })
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].