encoding grids as 64bits integer + a nice module interface with phantom types to ensure various things