Skip to content

Instantly share code, notes, and snippets.

@ocharles
Created December 3, 2012 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocharles/853b7733d35eeaeeb7e2 to your computer and use it in GitHub Desktop.
Save ocharles/853b7733d35eeaeeb7e2 to your computer and use it in GitHub Desktop.
testForm :: Monad m => Form Text m [Pokemon]
testForm = "pokemon" .: pokemon
where pokemon = listOf (Pokemon <$> "n" .: listOf ("x" .: stringRead "Read failure" Nothing))
testForm :: Monad m => Form Text m [Pokemon]
testForm = "pokemon" .: pokemon
where pokemon = listOf (Pokemon <$> "n" .: listOf (stringRead "Read failure" Nothing)
blah :: IO (View Text, Maybe [Pokemon])
blah = postForm "form-name" testForm pokeEnv
where
pokeEnv (ActualPath p) = case p of
["form-name", "pokemon", Index 0, "name"] -> return [TextInput "5"]
["form-name", "pokemon", Index 0, "n", Index 0, "x"] -> return [TextInput "1"]
["form-name", "pokemon", Index 0, "n", Index 1, "x"] -> return [TextInput "2"]
["form-name", "pokemon", Index 1, "name"] -> return [TextInput "3"]
["form-name", "pokemon", Index 1, "n", Index 0, "x"] -> return [TextInput "3"]
_ -> return []
pokeEnv (MetaPath p) = case p of
["form-name", "pokemon"] -> return [Container 2]
["form-name", "pokemon", Index 0, "n"] -> return [Container 2]
["form-name", "pokemon", Index 1, "n"] -> return [Container 1]
_ -> return []
λ> fmap snd blah
Just [Pokemon [1,2],Pokemon [3]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment