Skip to content

Instantly share code, notes, and snippets.

@YuMingLiao
Created May 22, 2019 14:27
Show Gist options
  • Save YuMingLiao/34b05f74ffae5a389a5cb5d4dcebcc8e to your computer and use it in GitHub Desktop.
Save YuMingLiao/34b05f74ffae5a389a5cb5d4dcebcc8e to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.String
import GHC.OverloadedLabels
import GHC.TypeLits
import Data.Proxy
data Html = Html String [String] [Html] | String String deriving (Show)
-- Expected type: [inner] -> Html
-- Actual type: [String] -> [Html] -> Html
-- • Probable cause: ‘Html’ is applied to too few arguments
instance IsString Html where fromString = String
instance (KnownSymbol symbol,attr ~ String,inner ~ Html) => IsLabel symbol ([attr] -> [inner] -> Html) where
fromLabel p = Html (symbolVal' (Proxy :: Proxy symbol))
instance (KnownSymbol symbol,attr ~ String,inner ~ Html) => IsLabel symbol ([inner] -> Html) where
fromLabel p = Html (symbolVal' p) []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment