diff --git a/fn/src/Web/Fn.hs b/fn/src/Web/Fn.hs index 6b5ba7d..03ae8b1 100644 --- a/fn/src/Web/Fn.hs +++ b/fn/src/Web/Fn.hs @@ -423,6 +423,10 @@ instance FromParam Text where fromParam [x] = Right x fromParam [] = Left ParamMissing fromParam _ = Left ParamTooMany +instance {-# INCOHERENT #-} FromParam String where + fromParam [t] = Right (T.unpack t) + fromParam [] = Left ParamMissing + fromParam _ = Left ParamTooMany instance FromParam Int where fromParam [t] = case decimal t of Left _ -> Left ParamUnparsable diff --git a/fn/test/Spec.hs b/fn/test/Spec.hs index ce55a63..4fee779 100644 --- a/fn/test/Spec.hs +++ b/fn/test/Spec.hs @@ -170,6 +170,8 @@ main = hspec $ do describe "parameter parsing" $ do it "should parse Text" $ fromParam ["hello"] `shouldBe` Right ("hello" :: Text) + it "should parse String" $ + fromParam ["hello"] `shouldBe` Right ("hello" :: String) it "should parse Int" $ do fromParam ["1"] `shouldBe` Right (1 :: Int) fromParam ["2011"] `shouldBe` Right (2011 :: Int)