hpastetwo

.

author
.
age
437 days
language
haskell
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{-# LANGUAGE TypeSynonymInstances #-}
module Foo where

import Text.XHtml.Strict

data MyData =
  Foo {nums :: [Int]} |
  Bar {strs :: [String]}

instance HTML Int where
  toHtml = primHtml.show

instance HTML String where
  toHtml = primHtml

instance HTML MyData where
  toHtml (Foo ns) = primHtml ("Integers "++(show ns))
  toHtml (Bar ss) = primHtml ("Strings "++(show ss))

gen :: HTML a => ([a] -> Html) -> MyData -> Html
gen listFunc (Foo ns) 
  | length ns == 0 = p << "no integers"
  | length ns == 1 = p << "one integer" +++ (p << (listFunc ns))
  | length ns == 2 = (h1 << "several integers") +++ (p << (listFunc ns))
gen listFunc (Bar ss) =
  (h1 << "Bar Heading") +++ (p << (listFunc ss))

foo = gen unordList

{-
Compiles with this error:

Foo.hs:21:0:
    Couldn't match expected type `Int' against inferred type `[Char]'
      Expected type: [a]
      Inferred type: [String]
    In the first argument of `listFunc', namely `ss'
    In the second argument of `(<<)', namely `(listFunc ss)'
-}

.

author
.
age
437 days
language
haskell
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{-# LANGUAGE TypeSynonymInstances #-}
module Foo where

import Text.XHtml.Strict

data MyData =
  Foo {nums :: [Int]} |
  Bar {strs :: [String]}

instance HTML Int where
  toHtml = primHtml.show

instance HTML String where
  toHtml = primHtml

instance HTML MyData where
  toHtml (Foo ns) = primHtml ("Integers "++(show ns))
  toHtml (Bar ss) = primHtml ("Strings "++(show ss))

gen listFunc (Foo ns) 
  | length ns == 0 = p << "no integers"
  | length ns == 1 = p << "one integer" +++ (p << (listFunc ns))
  | length ns == 2 = (h1 << "several integers") +++ (p << (listFunc ns))
gen listFunc (Bar ss) =
  (h1 << "Bar Heading") +++ (p << (listFunc ss))

foo = gen unordList

{-
Without a type signature for gen, it gives this error:

Foo.hs:26:35:
    Couldn't match expected type `[Char]' against inferred type `Int'
      Expected type: [String] -> a
      Inferred type: [Int] -> a1
    In the second argument of `(<<)', namely `(listFunc ss)'
    In the second argument of `(+++)', namely `(p << (listFunc ss))'

-}

.

author
.
age
437 days
language
haskell
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{-# LANGUAGE TypeSynonymInstances #-}
module Foo where

import Text.XHtml.Strict

data MyData =
  Foo {nums :: [Int]} |
  Bar {strs :: [Double]}

instance HTML Int where
  toHtml = primHtml.show

instance HTML Double where
  toHtml = primHtml.show

instance HTML MyData where
  toHtml (Foo ns) = primHtml ("Integers "++(show ns))
  toHtml (Bar ss) = primHtml ("Doubles "++(show ss))

gen (Foo ns) 
  | length ns == 0 = p << "no integers"
  | length ns == 1 = p << "one integer" +++ (p << (unordList ns))
  | length ns == 2 = (h1 << "several integers") +++ (p << (unordList ns))
gen (Bar ss) =
  (h1 << "Bar Heading") +++ (p << (unordList ss))

{-
  This one compiles fine.
-}

.

author
.
age
437 days
language
haskell
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE TypeSynonymInstances #-}
module Foo where

import Text.XHtml.Strict

data MyData =
  Foo {nums :: [Int]} |
  Bar {strs :: [Double]}

instance HTML Int where
  toHtml = primHtml.show

instance HTML Double where
  toHtml = primHtml.show

instance HTML MyData where
  toHtml (Foo ns) = primHtml ("Integers "++(show ns))
  toHtml (Bar ss) = primHtml ("Doubles "++(show ss))

gen listFunc (Foo ns) 
  | length ns == 0 = p << "no integers"
  | length ns == 1 = p << "one integer" +++ (p << (listFunc ns))
  | length ns == 2 = (h1 << "several integers") +++ (p << (listFunc ns))
gen listFunc (Bar ss) =
  (h1 << "Bar Heading") +++ (p << (listFunc ss))

{-
  And back to not working.
  For some reason, parameterizing gen with listFunc causes the error.
-}

.

author
.
age
437 days
language
haskell
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleContexts  #-}

module Foo where

import Text.XHtml.Strict

data MyData =
  Foo {nums :: [Int]} |
  Bar {strs :: [String]}

instance HTML Int where
  toHtml = primHtml.show

-- instance HTML String where
--   toHtml = primHtml

instance HTML MyData where
  toHtml (Foo ns) = primHtml ("Integers "++(show ns))
  toHtml (Bar ss) = primHtml ("Strings "++(show ss))

gen :: (forall a . HTML a => [a] -> Html) -> MyData -> Html
gen listFunc (Foo ns) 
  | length ns == 0 = p << "no integers"
  | length ns == 1 = p << "one integer" +++ (p << (listFunc ns))
  | length ns == 2 = (h1 << "several integers") +++ (p << (listFunc ns))
  | otherwise = undefined
gen listFunc (Bar ss) =
  (h1 << "Bar Heading") +++ (p << (listFunc ss))


foo :: MyData -> Html
foo = gen unordList

cnqBCVTdwbhIwZUg

author
rfhfnqopuw
age
430 days
language
haskell
1
v6zeDv  <a href="http://evtvsdmjqvnt.com/">evtvsdmjqvnt</a>, [url=http://pqsqeowxluib.com/]pqsqeowxluib[/url], [link=http://xrgkvmsxzpft.com/]xrgkvmsxzpft[/link], http://glxwdfszolic.com/

cnqBCVTdwbhIwZUg

author
rfhfnqopuw
age
430 days
language
haskell
1
v6zeDv  <a href="http://evtvsdmjqvnt.com/">evtvsdmjqvnt</a>, [url=http://pqsqeowxluib.com/]pqsqeowxluib[/url], [link=http://xrgkvmsxzpft.com/]xrgkvmsxzpft[/link], http://glxwdfszolic.com/

cnqBCVTdwbhIwZUg

author
rfhfnqopuw
age
430 days
language
haskell
1
v6zeDv  <a href="http://evtvsdmjqvnt.com/">evtvsdmjqvnt</a>, [url=http://pqsqeowxluib.com/]pqsqeowxluib[/url], [link=http://xrgkvmsxzpft.com/]xrgkvmsxzpft[/link], http://glxwdfszolic.com/

QUtvvvXdFnZG

author
hndxhxkhtrh
age
430 days
language
haskell
1
hwHGN2  <a href="http://itxzzvfmhdpu.com/">itxzzvfmhdpu</a>, [url=http://sercntivbyob.com/]sercntivbyob[/url], [link=http://pptipchycbjo.com/]pptipchycbjo[/link], http://hsgxrilzzasw.com/

QUtvvvXdFnZG

author
hndxhxkhtrh
age
430 days
language
haskell
1
hwHGN2  <a href="http://itxzzvfmhdpu.com/">itxzzvfmhdpu</a>, [url=http://sercntivbyob.com/]sercntivbyob[/url], [link=http://pptipchycbjo.com/]pptipchycbjo[/link], http://hsgxrilzzasw.com/

QUtvvvXdFnZG

author
hndxhxkhtrh
age
430 days
language
haskell
1
hwHGN2  <a href="http://itxzzvfmhdpu.com/">itxzzvfmhdpu</a>, [url=http://sercntivbyob.com/]sercntivbyob[/url], [link=http://pptipchycbjo.com/]pptipchycbjo[/link], http://hsgxrilzzasw.com/

rNBvRHmvqarPaELlxDo

author
npfdxjzknwb
age
430 days
language
haskell
1
vIml3F  <a href="http://bnfphdgerugi.com/">bnfphdgerugi</a>, [url=http://qpzsfknoitra.com/]qpzsfknoitra[/url], [link=http://kdnfhctczmqv.com/]kdnfhctczmqv[/link], http://nvjpbjgusejb.com/

rNBvRHmvqarPaELlxDo

author
npfdxjzknwb
age
430 days
language
haskell
1
vIml3F  <a href="http://bnfphdgerugi.com/">bnfphdgerugi</a>, [url=http://qpzsfknoitra.com/]qpzsfknoitra[/url], [link=http://kdnfhctczmqv.com/]kdnfhctczmqv[/link], http://nvjpbjgusejb.com/

aGJsJhAEawEghbkAZ

author
kwpunbx
age
430 days
language
haskell
1
Ththa3  <a href="http://ipkzackvcnsl.com/">ipkzackvcnsl</a>, [url=http://ylzyzzmuokgf.com/]ylzyzzmuokgf[/url], [link=http://qxkddqyohjsr.com/]qxkddqyohjsr[/link], http://dxcuwqocusqq.com/

aGJsJhAEawEghbkAZ

author
kwpunbx
age
430 days
language
haskell
1
Ththa3  <a href="http://ipkzackvcnsl.com/">ipkzackvcnsl</a>, [url=http://ylzyzzmuokgf.com/]ylzyzzmuokgf[/url], [link=http://qxkddqyohjsr.com/]qxkddqyohjsr[/link], http://dxcuwqocusqq.com/

rNBvRHmvqarPaELlxDo

author
npfdxjzknwb
age
430 days
language
haskell
1
vIml3F  <a href="http://bnfphdgerugi.com/">bnfphdgerugi</a>, [url=http://qpzsfknoitra.com/]qpzsfknoitra[/url], [link=http://kdnfhctczmqv.com/]kdnfhctczmqv[/link], http://nvjpbjgusejb.com/

aGJsJhAEawEghbkAZ

author
kwpunbx
age
430 days
language
haskell
1
Ththa3  <a href="http://ipkzackvcnsl.com/">ipkzackvcnsl</a>, [url=http://ylzyzzmuokgf.com/]ylzyzzmuokgf[/url], [link=http://qxkddqyohjsr.com/]qxkddqyohjsr[/link], http://dxcuwqocusqq.com/

qugmSpxCvcRkfBTLsQu

author
mazuscgsgyk
age
430 days
language
haskell
1
EAMDAl  <a href="http://hxqgizyuwjvh.com/">hxqgizyuwjvh</a>, [url=http://offmcrwcsbbz.com/]offmcrwcsbbz[/url], [link=http://wjyasqwvjkah.com/]wjyasqwvjkah[/link], http://xpmhijulochg.com/

qugmSpxCvcRkfBTLsQu

author
mazuscgsgyk
age
430 days
language
haskell
1
EAMDAl  <a href="http://hxqgizyuwjvh.com/">hxqgizyuwjvh</a>, [url=http://offmcrwcsbbz.com/]offmcrwcsbbz[/url], [link=http://wjyasqwvjkah.com/]wjyasqwvjkah[/link], http://xpmhijulochg.com/

qugmSpxCvcRkfBTLsQu

author
mazuscgsgyk
age
430 days
language
haskell
1
EAMDAl  <a href="http://hxqgizyuwjvh.com/">hxqgizyuwjvh</a>, [url=http://offmcrwcsbbz.com/]offmcrwcsbbz[/url], [link=http://wjyasqwvjkah.com/]wjyasqwvjkah[/link], http://xpmhijulochg.com/