{-# LANGUAGE FlexibleContexts, FlexibleInstances , MultiParamTypeClasses, TemplateHaskell, UndecidableInstances #-} {- Who made what? Shelarcy made the AFDirectoryPath extension. The rest is made by Mads Lindstrøm. -} -- |Contain types which implementations of the 'AutoForm' class should handle specially. module Graphics.UI.AF.General.CustomTypes ( AFFilePath(..) , AFDirectoryPath(..) , afOpenFile ) where import Graphics.UI.AF.General.MySYB import IO import Graphics.UI.AF.General.AutoForm -- |Contains a file system pointer in form of a text string, just like FilePath. -- A new type were needed as FilePath is just a type synonym (for string). Otherwise, -- It would be impossible to behave in one way for strings and another for file paths. newtype AFFilePath = AFFilePath { filePath :: String } deriving (Show, Read, Eq) -- |afOpenFil is the counterpart of IO.openFile, just using AFFilePath -- instead. afOpenFile :: AFFilePath -> IOMode -> IO Handle afOpenFile (AFFilePath path) mode = openFile path mode -- Note that, a list of AFFilePath should probably also behave -- specially, like being able to select multiple files in a file -- requester dialog. But this is not implemented yet. $(derive [''AFFilePath]) instance (AutoForm action comH builder satCxt com) => TypePresentation AFFilePath action comH builder satCxt com -- |AutoForms directory path -type. A new type is needed for the same -- reason it was needed for 'AFFilePath'. newtype AFDirectoryPath = AFDirectoryPath { directoryPath :: String } deriving (Show, Read, Eq) instance (AutoForm action comH builder satCxt com) => TypePresentation AFDirectoryPath action comH builder satCxt com $(derive [''AFDirectoryPath])