Skip to content

Commit

Permalink
fix: examples, TODO wait for spago monorepo support
Browse files Browse the repository at this point in the history
  • Loading branch information
srghma committed Oct 12, 2024
1 parent 7c25e26 commit 630dcdb
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
run: spago test --offline --censor-stats --strict --pedantic-packages

- name: Verify formatting
run: purs-tidy check src test
run: purs-tidy check src test examples/src
1 change: 0 additions & 1 deletion examples/spago.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ package:
name: profunctor-lenses-examples
dependencies:
- colors
- generics-rep
- record-extra
32 changes: 12 additions & 20 deletions examples/src/PrismsForSumTypes.purs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ import Color (Color)
import Color as Color
import Data.Either (Either(..))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq as GEq
import Data.Generic.Rep.Show as GShow
import Data.Show.Generic (genericShow)
import Data.Lens (Prism', is, isn't, nearly, only, preview, prism, prism', review)
import Data.Maybe (Maybe(..), maybe)

Expand Down Expand Up @@ -72,7 +71,7 @@ solidFocus = prism' constructor focus
constructor = Solid
focus fill = case fill of
Solid color -> Just color
otherCases -> Nothing
_ -> Nothing

-- In real life, you might abbreviate the above to this:

Expand Down Expand Up @@ -239,26 +238,19 @@ n5 = review brightSolidFocus unit

-- ... although Eq is only required for `only`.

derive instance genericPercent :: Generic Percent _
derive instance Generic Percent _
derive instance Eq Percent

instance eqPercent :: Eq Percent where
eq = GEq.genericEq

instance showPercent :: Show Percent where
instance Show Percent where
show (Percent f) = "(" <> show f <> "%)"

derive instance genericPoint :: Generic Point _

instance eqPoint :: Eq Point where
eq = GEq.genericEq
derive instance Generic Point _
derive instance Eq Point

instance showPoint :: Show Point where
instance Show Point where
show (Point x y) = "(" <> show x <> ", " <> show y <> ")"

derive instance genericFill :: Generic Fill _

instance eqFill :: Eq Fill where
eq = GEq.genericEq

instance showFill :: Show Fill where
show x = GShow.genericShow x
derive instance Generic Fill _
derive instance Eq Fill
instance Show Fill where
show = genericShow
141 changes: 141 additions & 0 deletions spago.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,61 @@
"prelude"
]
}
},
"profunctor-lenses-examples": {
"path": "examples",
"core": {
"dependencies": [
"colors",
"record-extra"
],
"build_plan": [
"arrays",
"bifunctors",
"colors",
"const",
"contravariant",
"control",
"distributive",
"effect",
"either",
"enums",
"exists",
"foldable-traversable",
"functions",
"functors",
"gen",
"identity",
"integers",
"invariant",
"lazy",
"lists",
"maybe",
"newtype",
"nonempty",
"numbers",
"orders",
"partial",
"prelude",
"profunctor",
"record",
"record-extra",
"refs",
"safe-coerce",
"st",
"strings",
"tailrec",
"tuples",
"type-equality",
"typelevel-prelude",
"unfoldable",
"unsafe-coerce"
]
},
"test": {
"dependencies": [],
"build_plan": []
}
}
},
"package_set": {
Expand Down Expand Up @@ -685,6 +740,19 @@
"tuples"
]
},
"colors": {
"type": "registry",
"version": "7.0.1",
"integrity": "sha256-udlg/y2PFsHYli8Tgz8BQGGrOjyGo0BcJj36IfgYADs=",
"dependencies": [
"arrays",
"integers",
"lists",
"numbers",
"partial",
"strings"
]
},
"console": {
"type": "registry",
"version": "6.1.0",
Expand Down Expand Up @@ -756,6 +824,23 @@
"prelude"
]
},
"enums": {
"type": "registry",
"version": "6.0.1",
"integrity": "sha256-HWaD73JFLorc4A6trKIRUeDMdzE+GpkJaEOM1nTNkC8=",
"dependencies": [
"control",
"either",
"gen",
"maybe",
"newtype",
"nonempty",
"partial",
"prelude",
"tuples",
"unfoldable"
]
},
"exceptions": {
"type": "registry",
"version": "6.1.0",
Expand Down Expand Up @@ -868,6 +953,16 @@
"prelude"
]
},
"integers": {
"type": "registry",
"version": "6.0.0",
"integrity": "sha256-sf+sK26R1hzwl3NhXR7WAu9zCDjQnfoXwcyGoseX158=",
"dependencies": [
"maybe",
"numbers",
"prelude"
]
},
"invariant": {
"type": "registry",
"version": "6.0.0",
Expand Down Expand Up @@ -940,6 +1035,15 @@
"unfoldable"
]
},
"numbers": {
"type": "registry",
"version": "9.0.1",
"integrity": "sha256-/9M6aeMDBdB4cwYDeJvLFprAHZ49EbtKQLIJsneXLIk=",
"dependencies": [
"functions",
"maybe"
]
},
"ordered-collections": {
"type": "registry",
"version": "3.2.0",
Expand Down Expand Up @@ -1004,6 +1108,20 @@
"unsafe-coerce"
]
},
"record-extra": {
"type": "registry",
"version": "5.0.1",
"integrity": "sha256-7vnREK2fpGJ7exswSeA9UpZFuU+UXRt3SA7AFUldT/Y=",
"dependencies": [
"arrays",
"functions",
"lists",
"prelude",
"record",
"tuples",
"typelevel-prelude"
]
},
"refs": {
"type": "registry",
"version": "6.0.0",
Expand Down Expand Up @@ -1032,6 +1150,29 @@
"unsafe-coerce"
]
},
"strings": {
"type": "registry",
"version": "6.0.1",
"integrity": "sha256-WssD3DbX4OPzxSdjvRMX0yvc9+pS7n5gyPv5I2Trb7k=",
"dependencies": [
"arrays",
"control",
"either",
"enums",
"foldable-traversable",
"gen",
"integers",
"maybe",
"newtype",
"nonempty",
"partial",
"prelude",
"tailrec",
"tuples",
"unfoldable",
"unsafe-coerce"
]
},
"tailrec": {
"type": "registry",
"version": "6.1.0",
Expand Down

0 comments on commit 630dcdb

Please sign in to comment.