Commit 3c9dec70 authored by David Davó's avatar David Davó

ByteString: Removed orphan

parent 1f772ccb
...@@ -69,6 +69,7 @@ import Control.Applicative ((<$>)) ...@@ -69,6 +69,7 @@ import Control.Applicative ((<$>))
import qualified Control.Exception as Ex import qualified Control.Exception as Ex
import Data.Typeable (Typeable, TypeRep, typeOf) import Data.Typeable (Typeable, TypeRep, typeOf)
import Data.IORef (IORef, readIORef, modifyIORef) import Data.IORef (IORef, readIORef, modifyIORef)
import Data.String
import Data.Text (Text, pack) import Data.Text (Text, pack)
import System.IO.Error import System.IO.Error
import System.Posix.IO import System.Posix.IO
...@@ -197,7 +198,7 @@ type instance FieldType 'S.Placeholder = Text ...@@ -197,7 +198,7 @@ type instance FieldType 'S.Placeholder = Text
type instance FieldType 'S.Tooltip = Maybe Text type instance FieldType 'S.Tooltip = Maybe Text
type instance FieldType 'S.Icon = Text type instance FieldType 'S.Icon = Text
type instance FieldType 'S.ButtonStyle = ButtonStyleValue type instance FieldType 'S.ButtonStyle = ButtonStyleValue
type instance FieldType 'S.BSValue = ByteString type instance FieldType 'S.BSValue = JSONByteString
type instance FieldType 'S.ImageFormat = ImageFormatValue type instance FieldType 'S.ImageFormat = ImageFormatValue
type instance FieldType 'S.BoolValue = Bool type instance FieldType 'S.BoolValue = Bool
type instance FieldType 'S.OptionsLabels = [Text] type instance FieldType 'S.OptionsLabels = [Text]
...@@ -502,9 +503,14 @@ instance HasKey f ~ 'False => ToPairs' 'False f where ...@@ -502,9 +503,14 @@ instance HasKey f ~ 'False => ToPairs' 'False f where
instance (ToJSON (FieldType f), HasKey f ~ 'True) => ToPairs' 'True f where instance (ToJSON (FieldType f), HasKey f ~ 'True) => ToPairs' 'True f where
toPairs' x = [ pack (toKey $ _field x) .= toJSON x ] toPairs' x = [ pack (toKey $ _field x) .= toJSON x ]
newtype JSONByteString = JSONByteString ByteString
deriving (Eq,Ord)
instance ToJSON ByteString where instance ToJSON JSONByteString where
toJSON = toJSON . base64 toJSON (JSONByteString x) = toJSON $ base64 x
instance IsString JSONByteString where
fromString = JSONByteString . fromString
-- | Store the value for a field, as an object parametrized by the Field. No verification is done -- | Store the value for a field, as an object parametrized by the Field. No verification is done
-- for these values. -- for these values.
...@@ -850,7 +856,7 @@ setField :: (f ∈ WidgetFields w, IHaskellWidget (IPythonWidget w), ToPairs (At ...@@ -850,7 +856,7 @@ setField :: (f ∈ WidgetFields w, IHaskellWidget (IPythonWidget w), ToPairs (At
=> IPythonWidget w -> SField f -> FieldType f -> IO () => IPythonWidget w -> SField f -> FieldType f -> IO ()
setField widget sfield fval = do setField widget sfield fval = do
attr <- getAttr widget sfield attr <- getAttr widget sfield
when (_ro attr) $ error ("The field " ++ show sfield ++ " is read only") when (_ro attr) $ error ("The field " ++ show (fromSing sfield) ++ " is read only")
!newattr <- setField' widget sfield fval !newattr <- setField' widget sfield fval
let pairs = toPairs newattr let pairs = toPairs newattr
unless (null pairs) $ widgetSendUpdate widget (object pairs) unless (null pairs) $ widgetSendUpdate widget (object pairs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment