slamdata / purescript-quasar

Quasar API library for PureScript
Apache License 2.0
1 stars 7 forks source link

combine MountF and MountConfig #86

Open safareli opened 7 years ago

safareli commented 7 years ago
data MountF f
  = View (f FilePath)
  | ..

data MountConfig
  = ViewConfig View.Config
  | ..

This ^ could be combined into:

data MountF f g
  = View (f FilePath)  (g View.Config)

then:

type MountConfig = MountF (Const Unit) Identity
type Mount = MountF Identity (Const Unit)
type MountType = MountF (Const Unit) (Const Unit)
safareli commented 6 years ago

This way CreateMount AbsPath MountConfig will change to CreateMount (MountF Identity Identity)

kritzcreek commented 6 years ago

What's the benefit of more and more indirection?

garyb commented 6 years ago

This change would ensure that the path you use to create a mount is appropriate for the type of mount: currently you can try to mount a view on a directory path, a connection on a file path, etc.

Well, a change along these lines, I'm not sure on the specific implementation, but I mentioned about using the types to do this to Irakli which is why he commented on it again just now.

safareli commented 6 years ago

We would be able to express all this types with just one MountF:

type CreateMountConfig = MountF Identity Identity
type MountConfig = MountF (Const Unit) Identity
type Mount = MountF Identity (Const Unit)
type MountType = MountF (Const Unit) (Const Unit)

This way it's more clear and fun :D

type On = Identity
type Off = Const Unit

type CreateMountConfig = MountF On  On
type MountConfig       = MountF Off On
type Mount             = MountF On  Off
type MountType         = MountF Off Off
safareli commented 6 years ago

Related change https://github.com/slamdata/purescript-quasar/pull/104

We could change Resource to ResourceF (like for MountF) and have deleteResource and moveResource instead of moveData, MoveMount, etc.