| 
 Copyright    : ( c )   , 2016 
 License      :      :  
 Stability    : experimental 
 Portability : non - portable 

Copyright   : (c) Dave Laing, 2016
License     : BSD3
Maintainer  : 
Stability   : experimental
Portability : non-portable
-}
module Component.Type.Error.UnknownType (
    AsUnknownType(..)
  , unknownTypeInput
  ) where

import           Control.Lens                        (preview)
import           Text.PrettyPrint.ANSI.Leijen        (Doc, text)

import           Component.Type.Error.UnknownType.Class (AsUnknownType (..))
import           Component                           (ComponentInput (..))
import           Component.Type.Error                (TypeErrorInput (..))
import           Component.Type.Error.Pretty         (PrettyTypeErrorInput (..),
                                                      PrettyTypeErrorRule (..))

prettyUnknownType :: AsUnknownType e
                  => e n String
                  -> Maybe Doc
prettyUnknownType =
    let
      prettyUnknownType' _ =
        text "Unknown type"
    in
      fmap prettyUnknownType' .
      preview _UnknownType

unknownTypeTypeErrorInput :: AsUnknownType e
                          => TypeErrorInput e ty
unknownTypeTypeErrorInput =
  TypeErrorInput
   (PrettyTypeErrorInput [PrettyTypeErrorBase prettyUnknownType])

unknownTypeInput :: AsUnknownType e
                 => ComponentInput r e ty tm
unknownTypeInput =
  ComponentInput
    mempty
    unknownTypeTypeErrorInput
    mempty

| 
 Copyright    : ( c )   , 2016 
 License      :      :  
 Stability    : experimental 
 Portability : non - portable 

Copyright   : (c) Dave Laing, 2016
License     : BSD3
Maintainer  : 
Stability   : experimental
Portability : non-portable
-}
module Component.Type.Error.UnknownType (
    AsUnknownType(..)
  , unknownTypeInput
  ) where

import           Control.Lens                        (preview)
import           Text.PrettyPrint.ANSI.Leijen        (Doc, text)

import           Component.Type.Error.UnknownType.Class (AsUnknownType (..))
import           Component                           (ComponentInput (..))
import           Component.Type.Error                (TypeErrorInput (..))
import           Component.Type.Error.Pretty         (PrettyTypeErrorInput (..),
                                                      PrettyTypeErrorRule (..))

prettyUnknownType :: AsUnknownType e
                  => e n String
                  -> Maybe Doc
prettyUnknownType =
    let
      prettyUnknownType' _ =
        text "Unknown type"
    in
      fmap prettyUnknownType' .
      preview _UnknownType

unknownTypeTypeErrorInput :: AsUnknownType e
                          => TypeErrorInput e ty
unknownTypeTypeErrorInput =
  TypeErrorInput
   (PrettyTypeErrorInput [PrettyTypeErrorBase prettyUnknownType])

unknownTypeInput :: AsUnknownType e
                 => ComponentInput r e ty tm
unknownTypeInput =
  ComponentInput
    mempty
    unknownTypeTypeErrorInput
    mempty
