-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
type: enhancementA new feature or addition.A new feature or addition.
Milestone
Description
Looking at #30
There is a couple of suggestions
Type classes for lenses
class HasScheme a where
_scheme :: ALens' a (Maybe Scheme)Using records instead
type AbsoluteURI =
{ scheme :: Maybe Scheme
, query :: Maybe Query
, hiePart :: HierarchicalPart
}
_scheme :: forall r a. Lens' { scheme :: a |r } a
_scheme = lens _.scheme _{ scheme = _ }Using newtype around records
newtype AbsoluteURI = AbsoluteURI
{ scheme :: Maybe Scheme
... }
derive instance newtypeAbsoluteURI :: Newtype AbsoluteURI _
_scheme :: forall r n a rr. Newtype n r => RowCons "scheme" a r rr => Lens' n a
_scheme = _Newtype <<< prop "scheme"@garyb @kritzcreek What do you think? I think the 3rd one preserves both typesafety and polymorphic behaviour w/o introducing new entities.
Metadata
Metadata
Assignees
Labels
type: enhancementA new feature or addition.A new feature or addition.