Barlow lens increases your magnification and let's you see the stars ✨
Ehh, wat ?
Barlow lens is a lens for records that makes it easy to zoom deep into the record.
spago install barlow-lenssky =
{ zodiac:
{ virgo:
{ alpha: "Spica"
}
}
}
view (barlow (key :: _ "zodiac.virgo.alpha")) sky
-- "Spica"
over (barlow (key :: _ "zodiac.virgo.alpha")) toUpper sky
-- { zodiac: { virgo: { alpha: "SPICA" } } }
-- view (barlow (key :: _ "zodiac.virgo.alfa")) sky
-- doesn't compileNow you can also zoom into Maybes using ?...
sky =
{ zodiac:
Just
{ virgo:
Just
{ alpha: Just "Spica"
}
}
}
preview (barlow (key :: _ "zodiac?.virgo?.alpha?")) sky... and Eithers using < for Left and > for Right...
sky =
{ zodiac:
Right
{ virgo:
Just
{ alpha: Left "Spica"
}
}
}
preview (barlow (key :: _ "zodiac>.virgo?.alpha<")) sky... and Arrays (and other Traversables) using + ...
sky =
{ zodiac:
[ { virgo:
Just
{ star: "Spica"
}
}
, { virgo:
Just
{ star: "Serpentis"
}
}
]
}
over (barlow (key :: _ "zodiac+.virgo?.star")) toUpper sky... and Newtypes using !
newtype Alpha = Alpha { alpha :: String }
instance alphaNT :: Newtype Alpha { alpha :: String
sky =
{ zodiac:
Just
{ virgo:
Alpha { alpha: "Spica"
}
}
}
preview (barlow (key :: _ "zodiac?.virgo!.alpha")) skyThis lib was heavily inspired by this incredible blog post.