packages feed

refined-http-api-data (empty) → 0.1.0.0

raw patch · 5 files changed

+104/−0 lines, 5 filesdep +basedep +http-api-datadep +refinedsetup-changed

Dependencies added: base, http-api-data, refined, text

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Changelog+All notable changes to this project will be documented in this file.++The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)+and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/).
+ LICENSE view
@@ -0,0 +1,22 @@+Copyright © 2019 Brandon Hamilton++Permission is hereby granted, free of charge, to any person+obtaining a copy of this software and associated documentation+files (the "Software"), to deal in the Software without+restriction, including without limitation the rights to use,+copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the+Software is furnished to do so, subject to the following+conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ refined-http-api-data.cabal view
@@ -0,0 +1,32 @@+cabal-version:       >=1.10+name:                refined-http-api-data+version:             0.1.0.0+synopsis:            http-api-data instances for refined types+description:         Orphan instances of Web.HttpApiData for refinement types+category:            Data+license:             MIT+license-file:        LICENSE+author:              Brandon Hamilton+maintainer:          brandon.hamilton@gmail.com+copyright:           Copyright © 2019 Brandon Hamilton+build-type:          Simple+extra-source-files:  CHANGELOG.md+tested-with:         GHC == 8.0.2+                   , GHC == 8.2.2+                   , GHC == 8.4.4+                   , GHC == 8.6.5+                   , GHC == 8.8.1++library+  hs-source-dirs:      src+  exposed-modules:     Refined.Orphan.HttpApiData+  default-language:    Haskell2010+  ghc-options:         -Wall+  build-depends:       base >= 4.9.1 && < 4.14+                     , http-api-data+                     , refined >= 0.4+                     , text++source-repository head+  type:     git+  location: git://github.com/brandonhamilton/refined-http-api-data.git
+ src/Refined/Orphan/HttpApiData.hs view
@@ -0,0 +1,43 @@+--------------------------------------------------------------------------------++-- Copyright © 2019 Brandon Hamilton+--+-- Permission is hereby granted, free of charge, to any person+-- obtaining a copy of this software and associated documentation+-- files (the "Software"), to deal in the Software without+-- restriction, including without limitation the rights to use,+-- copy, modify, merge, publish, distribute, sublicense, and/or sell+-- copies of the Software, and to permit persons to whom the+-- Software is furnished to do so, subject to the following+-- conditions:+--+-- The above copyright notice and this permission notice shall be+-- included in all copies or substantial portions of the Software.+--+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES+-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT+-- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+-- OTHER DEALINGS IN THE SOFTWARE.++--------------------------------------------------------------------------------++{-# OPTIONS_GHC -fno-warn-orphans #-}++module Refined.Orphan.HttpApiData () where++import Control.Arrow (left)+import Control.Exception (Exception(displayException))+import Control.Monad ((<=<))+import Data.Text (pack)+import Web.HttpApiData (FromHttpApiData(parseUrlPiece), ToHttpApiData(toUrlPiece))+import Refined.Internal (Refined, Predicate, refine, unrefine)++instance (FromHttpApiData a, Predicate p a) => FromHttpApiData (Refined p a) where+  parseUrlPiece = (left (pack . displayException)) . refine <=< parseUrlPiece++instance (ToHttpApiData a, Predicate p a) => ToHttpApiData (Refined p a) where+  toUrlPiece = toUrlPiece . unrefine