Skip to content

Instantly share code, notes, and snippets.

@paulcc
Forked from mattwynne/sketch.rb
Created June 29, 2012 16:04
Show Gist options
  • Save paulcc/3018839 to your computer and use it in GitHub Desktop.
Save paulcc/3018839 to your computer and use it in GitHub Desktop.
pseudo-haskell
class Valid a where
valid :: a -> OkF Errors
class Valid a => Persist m a where
save :: a -> m (OkF a) -- or errors
data User = User {name :: String}
data Organisation = Organisation {name :: String, users :: [User]}
class Url r
show :: r -> Url
edit :: r -> Url
list :: [r] -> Url -- ?
instance Restful r => Url r where ...
-- yank constrs out?
-- responsibility: marshall, save, redirect
-- constr can be (\n -> Org n u), closure
create_ constr args
= do
res <- save (constr args)
case res of
Ok r -> redirect (show r)
Fail "oops" -> render template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment