Skip to content

Instantly share code, notes, and snippets.

@esad
Created January 23, 2017 14:28
Show Gist options
  • Save esad/65b6c29c074c53b89901e7f32c33adca to your computer and use it in GitHub Desktop.
Save esad/65b6c29c074c53b89901e7f32c33adca to your computer and use it in GitHub Desktop.
type ItemRef = Int
newtype Item = Item
{ text :: String
, done :: Boolean
, ref :: ItemRef
}
derive instance newtypeItem :: Newtype Item _
newtype Model = Model
{ items :: M.Map ItemRef Item
, selection :: Maybe ItemRef
, nextRef :: ItemRef
}
derive instance newtypeModel :: Newtype Model _
_items :: forall a . Traversal' Model Item
_items = _Newtype <<< (lens _.items (_ { items = _})) <<< traversed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment