Skip to content

Instantly share code, notes, and snippets.

@ericmoritz
Created July 12, 2013 01:33
Show Gist options
  • Select an option

  • Save ericmoritz/5980747 to your computer and use it in GitHub Desktop.

Select an option

Save ericmoritz/5980747 to your computer and use it in GitHub Desktop.
module Config (Config, config, dir, enqueue) where
import Data.Sequence (Seq, empty, (|>))
import qualified Data.Foldable as F
data Config = Config {
dir :: String
, seq :: Seq String
} deriving (Show)
config dir =
Config dir empty
enqueue :: Config -> [String] -> Config
c `enqueue` urls =
Config (dir c) q'
where
q' = foldl (|>) (Config.seq c) urls
-- TODO: make an instance of Foldable?
instance F.Foldable Config where
foldr f z c =
Config (dir c) q'
where
q' = F.foldr f z (Config.seq c)
foldMap f c =
Config (dir c) q'
where
q' = F.foldMap f (Config.seq c)
@ericmoritz
Copy link
Author

Error:

[1 of 1] Compiling Config           ( src/Config.hs, interpreted )

src/Config.hs:21:21:
    Kind mis-match
    The first argument of `F.Foldable' should have kind `* -> *',
    but `Config' has kind `*'
    In the instance declaration for `F.Foldable Config'
Failed, modules loaded: none.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment