const Right = x => ({
map: f => Right(f(x)),
chain: f => f(x),
fold: (f, g) => g(x)
})
const Left = x => ({
map: f => Left(x),
chain: f => Left(x),
fold: (f, g) => f(x)
})
const getPackages = user =>
(user.premium ? Right(user) : Left('not premium'))
.map(u => u.preferences)
.fold(() => defaultsPackages, props => loadPackages(props))